{"_id":"@anyany/sandbox_provider","_rev":"3-800a06d13c9e63c86bb52f8256caaffd","name":"@anyany/sandbox_provider","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@anyany/sandbox_provider","version":"0.1.0","keywords":["sandbox","cloud","adapter","abstraction"],"author":"","license":"MIT","_id":"@anyany/sandbox_provider@0.1.0","maintainers":[{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"}],"dist":{"shasum":"02a5653ab25375b04542fc85dc878248d16bbdd3","tarball":"https://registry.npmjs.org/@anyany/sandbox_provider/-/sandbox_provider-0.1.0.tgz","fileCount":130,"integrity":"sha512-fpQyt1/NkapGXeadci+AOjnb4E1FvLNrKnEAk5vZUaRnL1MufCKEWk0KuUkxmVjcIPuPeiGm7q9ZqjFwWpv6xw==","signatures":[{"sig":"MEYCIQDziUQS8qnoFFuFby/EnMyGk+aKhWaMCK3EOyotAHxkGQIhAOyL/bdir8Zvn0tP/L9GpFChLildmszQ/ZJZP61bR9Pr","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1218267},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"768a5debce6cea4335c2ec90c7fe3105176f0e95","scripts":{"ci":"bun run ci:check && bun run ci:test && bun run ci:build","dev":"bun run --watch src/index.ts","lint":"tsc --noEmit && biome lint","test":"bun test","build":"bun run build:types && bun build ./src/index.ts --outdir ./dist --target node","check":"biome check --write","format":"biome format --write","ci:lint":"tsc --noEmit && biome lint --error-on-warnings","ci:test":"bun test","prepare":"husky","ci:build":"bun run build","ci:check":"biome check --error-on-warnings","lint:fix":"biome lint --write","ci:format":"biome format --error-on-warnings","test:watch":"bun test --watch","build:types":"tsc -p tsconfig.json --outDir ./dist --emitDeclarationOnly","test:coverage":"bun test --coverage"},"_npmUser":{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"},"_npmVersion":"11.6.2","description":"Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling","directories":{},"lint-staged":{"*.{json,md}":["biome format --write --no-errors-on-unmatched"],"*.{ts,tsx,js,jsx}":["biome check --write --no-errors-on-unmatched"]},"_nodeVersion":"24.12.0","dependencies":{"@alibaba-group/opensandbox":"^0.1.3"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","@types/bun":"latest","typescript":"^5.3.0","lint-staged":"^16.2.7","@biomejs/biome":"^2.3.13"},"peerDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sandbox_provider_0.1.0_1770299602257_0.7253155585756663","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@anyany/sandbox_provider","version":"0.1.1","keywords":["sandbox","cloud","adapter","abstraction"],"author":"","license":"MIT","_id":"@anyany/sandbox_provider@0.1.1","maintainers":[{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"}],"dist":{"shasum":"34ed1968baddc500ab3e7ab030c239221e6ffcf9","tarball":"https://registry.npmjs.org/@anyany/sandbox_provider/-/sandbox_provider-0.1.1.tgz","fileCount":67,"integrity":"sha512-zX+Bl+xVv7aSw8wl9x5XTBtNhk8PCRRVY+iFkymU9FYLjzP3d2DhC0K5CXc5l5wpsjmVEdTwgtD7woPlSncV/g==","signatures":[{"sig":"MEQCIFIIioyPuat2locQlFPGrSLREcYZr1MbzTmHAn2SyNIRAiBFOquZeOxLftR3rlw20KfK8UzLMzGFVfB8vtLsSYi5iA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1068012},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"768a5debce6cea4335c2ec90c7fe3105176f0e95","scripts":{"ci":"bun run ci:check && bun run ci:test && bun run ci:build","dev":"bun run --watch src/index.ts","lint":"tsc --noEmit && biome lint","test":"bun test","build":"bun run build:types && bun build ./src/index.ts --outdir ./dist --target node","check":"biome check --write","format":"biome format --write","ci:lint":"tsc --noEmit && biome lint --error-on-warnings","ci:test":"bun test","prepare":"husky","ci:build":"bun run build","ci:check":"biome check --error-on-warnings","lint:fix":"biome lint --write","ci:format":"biome format --error-on-warnings","test:watch":"bun test --watch","build:types":"tsc -p tsconfig.json --outDir ./dist --emitDeclarationOnly","test:coverage":"bun test --coverage"},"_npmUser":{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"},"_npmVersion":"11.6.2","description":"Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling","directories":{},"lint-staged":{"*.{json,md}":["biome format --write --no-errors-on-unmatched"],"*.{ts,tsx,js,jsx}":["biome check --write --no-errors-on-unmatched"]},"_nodeVersion":"24.12.0","dependencies":{"@alibaba-group/opensandbox":"^0.1.3"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","@types/bun":"latest","typescript":"^5.3.0","lint-staged":"^16.2.7","@biomejs/biome":"^2.3.13"},"peerDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sandbox_provider_0.1.1_1772706663165_0.9406745224744282","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@anyany/sandbox_provider","version":"0.1.2","description":"Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"bun run build:types && bun build ./src/index.ts --outdir ./dist --target node","build:types":"tsc -p tsconfig.json --outDir ./dist --emitDeclarationOnly","dev":"bun run --watch src/index.ts","test":"bun test","test:watch":"bun test --watch","test:coverage":"bun test --coverage","lint":"tsc --noEmit && biome lint","lint:fix":"biome lint --write","format":"biome format --write","check":"biome check --write","ci:lint":"tsc --noEmit && biome lint --error-on-warnings","ci:format":"biome format --error-on-warnings","ci:check":"biome check --error-on-warnings","ci:test":"bun test","ci:build":"bun run build","ci":"bun run ci:check && bun run ci:test && bun run ci:build","prepare":"husky"},"keywords":["sandbox","cloud","adapter","abstraction"],"author":"","license":"MIT","dependencies":{"@alibaba-group/opensandbox":"^0.1.3"},"lint-staged":{"*.{ts,tsx,js,jsx}":["biome check --write --no-errors-on-unmatched"],"*.{json,md}":["biome format --write --no-errors-on-unmatched"]},"devDependencies":{"@biomejs/biome":"^2.3.13","@types/bun":"latest","husky":"^9.1.7","lint-staged":"^16.2.7","typescript":"^5.3.0"},"peerDependencies":{"typescript":"^5.0.0"},"engines":{"node":">=16.0.0"},"gitHead":"768a5debce6cea4335c2ec90c7fe3105176f0e95","_id":"@anyany/sandbox_provider@0.1.2","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-EtpG2PC+ZNPMqmFnK9LlH/Lh+dL234HysF1l1mcaEaz25APxcSERy3kDajR+i2WuVYU6adPLF5DHPivJt1k5XA==","shasum":"2b6618c7475a97aeb44af06f13c80ebf7ce94c19","tarball":"https://registry.npmjs.org/@anyany/sandbox_provider/-/sandbox_provider-0.1.2.tgz","fileCount":67,"unpackedSize":1068256,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDfoeYnVZsVKNict58zuTCX7bXmDr8YnsBaIrRf3pnODgIgME1b2kl2zoHB7Pq4RyrG6fDEePw/+OggIlnv8GgLtfc="}]},"_npmUser":{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"},"directories":{},"maintainers":[{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sandbox_provider_0.1.2_1773218256791_0.3031291578553852"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-05T13:53:22.176Z","modified":"2026-03-11T08:37:37.137Z","0.1.0":"2026-02-05T13:53:22.491Z","0.1.1":"2026-03-05T10:31:03.332Z","0.1.2":"2026-03-11T08:37:37.008Z"},"license":"MIT","keywords":["sandbox","cloud","adapter","abstraction"],"description":"Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling","maintainers":[{"name":"ctlaltlaltc","email":"ljp@sangfor.com.cn"}],"readme":"# sandbox_provider\n\nA unified, high-level abstraction layer for cloud sandbox providers with strict OOP/SOLID principles, Adapter Pattern, and comprehensive feature polyfilling.\n\n## Features\n\n- **Adapter Pattern**: Clean abstraction over provider-specific implementations\n- **Feature Polyfilling**: Automatic emulation of missing features via command execution\n- **SOLID Principles**: Interface segregation, dependency inversion, open/closed\n- **Full TypeScript**: Type-safe with strict configuration\n- **TDD**: Comprehensive test suite with Bun test runner\n- **Provider Support**:\n  - OpenSandbox (full native support)\n  - MinimalProvider (command-only with polyfills)\n  - Extensible for Daytona, Modal, Runloop, etc.\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────┐\n│  CONSUMER API                                                   │\n│  - SandboxProviderFactory, ISandbox interface                   │\n├─────────────────────────────────────────────────────────────────┤\n│  SERVICE INTERFACES (Abstract Contracts)                        │\n│  - ISandboxLifecycle, ICommandExecution, IFileSystem, etc.      │\n├─────────────────────────────────────────────────────────────────┤\n│  ADAPTER LAYER (Provider Implementations)                       │\n│  - OpenSandboxAdapter, MinimalProviderAdapter                   │\n├─────────────────────────────────────────────────────────────────┤\n│  CAPABILITY BRIDGE (Polyfill Engine)                            │\n│  - CommandPolyfillService implements FS via exec                │\n├─────────────────────────────────────────────────────────────────┤\n│  TRANSPORT & ERRORS                                             │\n│  - Exception hierarchy, connection management                   │\n└─────────────────────────────────────────────────────────────────┘\n```\n\n## Installation\n\n```bash\nbun install\n```\n\n## Usage\n\n### Basic Usage with OpenSandbox\n\n```typescript\nimport { createSandbox } from 'sandbox_provider';\n\n// Create a sandbox\nconst sandbox = createSandbox({\n  provider: 'opensandbox',\n  connection: {\n    apiKey: process.env.OPEN_SANDBOX_API_KEY,\n  },\n});\n\n// Create and initialize\nawait sandbox.create({\n  image: { repository: 'node', tag: '18' },\n  entrypoint: ['node', '--version'],\n});\n\n// Execute commands\nconst result = await sandbox.execute('npm install');\nconsole.log(result.stdout);\n\n// File operations\nawait sandbox.writeFiles([\n  { path: '/app/index.js', data: 'console.log(\"Hello\")' },\n]);\n\nconst files = await sandbox.readFiles(['/app/index.js']);\n\n// Cleanup\nawait sandbox.delete();\nawait sandbox.close();\n```\n\n### Minimal Provider (SSH/Command-only)\n\n```typescript\nimport { MinimalProviderAdapter } from 'sandbox_provider';\n\n// Connect to a minimal provider (e.g., SSH-based sandbox)\nconst adapter = new MinimalProviderAdapter();\n\nawait adapter.connect({\n  id: 'my-sandbox',\n  execute: async (cmd) => {\n    // Your SSH execution logic here\n    return { stdout: '', stderr: '', exitCode: 0 };\n  },\n  getStatus: async () => ({ state: 'Running' }),\n  close: async () => {},\n});\n\n// Filesystem operations work via polyfill!\nawait adapter.writeFiles([\n  { path: '/tmp/test.txt', data: 'Hello' },\n]);\n\nconst files = await adapter.readFiles(['/tmp/test.txt']);\n```\n\n### Feature Detection\n\n```typescript\nconst sandbox = createSandbox({ provider: 'opensandbox' });\n\n// Check capabilities\nif (sandbox.capabilities.nativeFileSystem) {\n  console.log('Native FS available');\n}\n\nif (sandbox.capabilities.supportsStreamingOutput) {\n  await sandbox.executeStream('long-running', {\n    onStdout: (msg) => console.log(msg.text),\n  });\n}\n```\n\n## API Reference\n\n### Interfaces\n\n#### ISandbox\n\nThe main interface combining all capabilities:\n\n```typescript\ninterface ISandbox\n  extends ISandboxLifecycle,\n    ICommandExecution,\n    IFileSystem,\n    IHealthCheck {\n  readonly provider: string;\n  readonly capabilities: ProviderCapabilities;\n  close(): Promise<void>;\n}\n```\n\n#### ICommandExecution\n\n```typescript\ninterface ICommandExecution {\n  execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;\n  executeStream(command: string, handlers: StreamHandlers, options?: ExecuteOptions): Promise<void>;\n  executeBackground(command: string, options?: ExecuteOptions): Promise<{ sessionId: string; kill(): Promise<void> }>;\n  interrupt(sessionId: string): Promise<void>;\n}\n```\n\n#### IFileSystem\n\n```typescript\ninterface IFileSystem {\n  readFiles(paths: string[], options?: ReadFileOptions): Promise<FileReadResult[]>;\n  writeFiles(entries: FileWriteEntry[]): Promise<FileWriteResult[]>;\n  deleteFiles(paths: string[]): Promise<FileDeleteResult[]>;\n  createDirectories(paths: string[], options?: { mode?: number; owner?: string; group?: string }): Promise<void>;\n  listDirectory(path: string): Promise<DirectoryEntry[]>;\n  getFileInfo(paths: string[]): Promise<Map<string, FileInfo>>;\n  search(pattern: string, path?: string): Promise<SearchResult[]>;\n  // ... and more\n}\n```\n\n### Error Handling\n\n```typescript\nimport {\n  SandboxException,\n  FeatureNotSupportedError,\n  FileOperationError,\n  CommandExecutionError,\n  TimeoutError,\n} from 'sandbox_provider';\n\ntry {\n  await sandbox.readFiles(['/secret']);\n} catch (error) {\n  if (error instanceof FileOperationError) {\n    console.log(`File error: ${error.fileErrorCode}`);\n  }\n}\n```\n\n## Provider Capabilities\n\n| Feature | OpenSandbox | MinimalProvider |\n|---------|-------------|-----------------|\n| Native Filesystem | ✅ | ❌ (polyfilled) |\n| Streaming Output | ✅ | ❌ (fallback) |\n| Background Exec | ✅ | ⚠️ (simulated) |\n| Pause/Resume | ✅ | ❌ |\n| Health Check | ✅ | ⚠️ (polyfilled) |\n| Metrics | ✅ | ⚠️ (polyfilled) |\n| File Search | ✅ | ⚠️ (polyfilled) |\n\n## Development\n\n### Run Tests\n\n```bash\n# Run all tests\nbun test\n\n# Watch mode\nbun test --watch\n\n# Coverage\nbun test --coverage\n```\n\n### Build\n\n```bash\nbun run build\n```\n\n### Lint\n\n```bash\nbun run lint\n```\n\n## Adding a New Provider\n\nTo add a new provider:\n\n1. Create `src/adapters/FooBarAdapter.ts`\n2. Extend `BaseSandboxAdapter`\n3. Implement native methods\n4. Set appropriate capability flags\n5. Register in `SandboxProviderFactory`\n\n```typescript\nexport class FooBarAdapter extends BaseSandboxAdapter {\n  readonly provider = 'foobar';\n  readonly capabilities: ProviderCapabilities = {\n    nativeFileSystem: true,\n    supportsStreamingOutput: true,\n    // ... etc\n  };\n\n  // Implement abstract methods...\n}\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}