@computesdk/sandbox0

中文文档
1.0.23发布于 2026/11/07MITTypeScriptESM + CJS近 30 天下载 9839

Sandbox0 provider for ComputeSDK - fast persistent sandboxes with command execution and native filesystem access

原始使用文档
文档目录6 节
  1. Installation
  2. Setup
  3. Usage
  4. Configuration
  5. Feature support
  6. License

@computesdk/sandbox0

Sandbox0 provider for ComputeSDK. Create fast persistent sandboxes, run shell commands, and use native filesystem operations through the official Sandbox0 JavaScript SDK.

Installation

npm install computesdk @computesdk/sandbox0

Setup

Create a team API key and export it:

export SANDBOX0_TOKEN=your_sandbox0_token

SANDBOX0_BASE_URL is optional and defaults to the public Sandbox0 API at https://api.sandbox0.ai. For automated team workloads, set it to the team's home-region endpoint so requests go directly to the regional gateway.

An interactive access token can also be used by setting both SANDBOX0_TOKEN and SANDBOX0_TEAM_ID.

Usage

import { compute } from 'computesdk';
import { sandbox0 } from '@computesdk/sandbox0';

compute.setConfig({
  provider: sandbox0({
    token: process.env.SANDBOX0_TOKEN,
    hardTtl: 600,
  }),
});

const sandbox = await compute.instances.create({
  templateId: 'coding-agent',
  memory: 256,
});

const result = await sandbox.runCommand('node --version');
console.log(result.stdout);

await sandbox.filesystem.writeFile('/tmp/hello.txt', 'Hello from Sandbox0');
console.log(await sandbox.filesystem.readFile('/tmp/hello.txt'));

await sandbox.destroy();

Configuration

OptionEnvironment variableDefaultDescription
tokenSANDBOX0_TOKEN or SANDBOX0_API_KEYrequiredTeam API key, or an access token when teamId is set
teamIdSANDBOX0_TEAM_IDnoneTeam ID required with access-token authentication
baseUrlSANDBOX0_BASE_URLSDK defaultSandbox0 API endpoint
templateIdSANDBOX0_TEMPLATEcoding-agentTemplate used for new sandboxes
ttl-platform defaultSoft runtime TTL in seconds
hardTtl-platform defaultHard sandbox TTL in seconds
memory-template defaultMemory in MiB or a quantity such as 1Gi
envs-noneDefault environment variables
commandTimeout-noneDefault command timeout in milliseconds

Per-create templateId, snapshotId, memory, envs, ttl, hardTtl, and autoResume options override provider defaults where applicable. Numeric memory values are interpreted as MiB.

Feature support

FeatureSupported
Create / getById / list / destroyYes
Shell commandsYes, through sh -lc
Command cwd, environment, timeout, and background modeYes
FilesystemYes, through Sandbox0's native file API
Public URLsYes, for public services already configured on the sandbox
Restore from snapshotYes, with snapshotId at create time
Snapshot managementUse the native Sandbox0 SDK

Foreground runCommand calls start an asynchronous Sandbox0 Context, follow its WebSocket terminal event, and read the final result from the Context API. If the WebSocket disconnects, the provider polls the Context until it exits. The command timeout is also applied as the Context TTL, and a timed-out call attempts to delete the Context.

destroy is idempotent and retries short-lived throttling or server failures. Setting hardTtl is still recommended for automated workloads so a failed client cannot leave a sandbox indefinitely.

For Sandbox0-specific capabilities such as pause/resume, services, snapshots, volumes, and observability, call sandbox.getInstance() to access the native sandbox0 SDK handle.

License

MIT

版本与发布记录

@computesdk/sandbox0 共发布 23 个版本,首次发布于 2026/07/28;过去 12 个月发布了 23 个版本。

版本发布日期距今
1.0.23latest2026/11/073 天前
1.0.222026/11/064 天前
1.0.212026/11/046 天前
1.0.202026/10/3110 天前
1.0.192026/10/2812 天前
1.0.182026/10/2714 天前

关于 @computesdk/sandbox0 的常见问题

@computesdk/sandbox0 是什么?

Sandbox0 provider for ComputeSDK - fast persistent sandboxes with command execution and native filesystem access

如何安装 @computesdk/sandbox0?

在项目目录运行 npm install @computesdk/sandbox0,或使用 pnpm add / yarn add / bun add。

@computesdk/sandbox0 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@computesdk/sandbox0 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@computesdk/sandbox0 可以商用吗?

@computesdk/sandbox0 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@computesdk/sandbox0 的下载量有多少?

根据 npm 官方下载统计,@computesdk/sandbox0 在 2026/10/11 – 2026/11/09 这 30 天内被下载 9,839 次,日均约 328 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@computesdk/sandbox0 还在维护吗?

最新版本 1.0.23 发布于 2026/11/07(3 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/07/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。