Skip to content
forked from zjy365/devbox-sdk

Cloud-native development environment SDK for running sandboxed code with high-performance file operations

License

Notifications You must be signed in to change notification settings

zzjin/devbox-sdk

Β 
Β 

Devbox SDK

Enterprise TypeScript SDK for Sealos Devbox management with HTTP API + Bun runtime architecture.

πŸ—οΈ Architecture

This project is a monorepo containing two main packages:

  • @sealos/devbox-sdk - TypeScript SDK for Devbox management
  • @sealos/devbox-server - HTTP server for Devbox runtime (Bun-based)

πŸ“¦ Packages

@sealos/devbox-sdk

TypeScript/Node.js SDK providing high-level APIs for Devbox management:

  • Devbox lifecycle management
  • HTTP connection pooling
  • File transfer with adaptive strategies
  • Security and monitoring

@sealos/devbox-server

High-performance HTTP server running in Devbox containers:

  • File operations API
  • Process execution
  • Real-time file watching via WebSocket
  • Built on Bun runtime

πŸš€ Quick Start

Installation

npm install @sealos/devbox-sdk

Basic Usage

import { DevboxSDK } from '@sealos/devbox-sdk'

const sdk = new DevboxSDK({
  kubeconfig: process.env.KUBECONFIG
})

// Create a Devbox
const devbox = await sdk.createDevbox({
  name: 'my-app',
  runtime: 'node.js',
  resource: { cpu: 1, memory: 2 }
})

// Write files
await devbox.writeFile('index.js', 'console.log("Hello World")')

// Execute commands
const result = await devbox.executeCommand('node index.js')
console.log(result.stdout)

πŸ› οΈ Development

Setup

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm test

# Lint code
npm run lint:fix

Package Scripts

# Build SDK only
npm run build:sdk

# Build server only
npm run build:server

# Run in development mode
npm run dev

πŸ“ Project Structure

devbox-sdk/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ sdk/              # Main SDK package
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ core/     # Core SDK functionality
β”‚   β”‚   β”‚   β”œβ”€β”€ api/      # API integration
β”‚   β”‚   β”‚   β”œβ”€β”€ http/     # HTTP client
β”‚   β”‚   β”‚   β”œβ”€β”€ transfer/ # File transfer
β”‚   β”‚   β”‚   β”œβ”€β”€ security/ # Security features
β”‚   β”‚   β”‚   └── monitoring/ # Metrics & logging
β”‚   β”‚   └── dist/         # Built output
β”‚   └── server/           # HTTP server package
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ handlers/ # Request handlers
β”‚       β”‚   β”œβ”€β”€ utils/    # Server utilities
β”‚       β”‚   └── types/    # Type definitions
β”‚       └── dist/         # Built output
β”œβ”€β”€ openspec/             # OpenSpec specifications
β”œβ”€β”€ tasks/                # Task documentation
β”œβ”€β”€ docs/                 # Additional documentation
└── dist/                 # Build outputs

⚑ Performance

  • Connection Pooling: Efficient HTTP connection reuse
  • Adaptive Transfer: Smart file transfer strategies
  • Bun Runtime: High-performance server runtime
  • TypeScript: Full type safety and IDE support

πŸ”§ Configuration

Environment Variables

Server (@sealos/devbox-server)

  • PORT - Server port (default: 3000)
  • HOST - Server host (default: 0.0.0.0)
  • WORKSPACE_PATH - Workspace directory (default: /workspace)
  • ENABLE_CORS - Enable CORS (default: false)
  • MAX_FILE_SIZE - Max file size in bytes (default: 100MB)

SDK (@sealos/devbox-sdk)

  • KUBECONFIG - Kubernetes configuration for Devbox API access

πŸ§ͺ Testing

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run E2E tests
npm run test:e2e

πŸ“š Documentation

πŸ“„ License

Apache-2.0

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

πŸ“ž Support

For issues and questions:

  • Create an issue on GitHub
  • Check the documentation
  • Contact the maintainers

About

Cloud-native development environment SDK for running sandboxed code with high-performance file operations

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%