@computesdk/opencomputer

中文文档
1.0.21发布于 2026/11/06MITTypeScriptESM + CJS构建来源已验证近 30 天下载 8995

OpenComputer provider for ComputeSDK - persistent cloud VMs with checkpoints, preview URLs, command execution, and filesystem access

原始使用文档
文档目录6 节
  1. Installation
  2. Setup
  3. Quick Start
  4. Configuration
  5. Features
  6. Snapshots

@computesdk/opencomputer

OpenComputer provider for ComputeSDK - create persistent cloud VMs, run commands, read/write files, expose preview URLs, and manage checkpoints through the ComputeSDK interface.

Installation

npm install computesdk @computesdk/opencomputer

Setup

Create an OpenComputer API key and set:

export OPENCOMPUTER_API_KEY=your_api_key_here

Optionally override the API URL:

export OPENCOMPUTER_API_URL=https://app.opencomputer.dev

Quick Start

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

compute.setConfig({
  provider: opencomputer({ apiKey: process.env.OPENCOMPUTER_API_KEY }),
});

const sandbox = await compute.instances.create({ templateId: 'base' });

const result = await sandbox.runCommand('echo "Hello from OpenComputer"');
console.log(result.stdout);

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

const url = await sandbox.getUrl({ port: 3000 });
console.log(url);

await sandbox.destroy();

Configuration

interface OpenComputerConfig {
  apiKey?: string;
  apiUrl?: string;
  template?: string;
  timeout?: number;
  envs?: Record<string, string>;
  metadata?: Record<string, string>;
  cpuCount?: number;
  memoryMB?: number;
  diskMB?: number;
  secretStore?: string;
  burst?: boolean;
  previewAuth?: { scheme?: 'bearer'; token?: 'auto' | string };
}

timeout uses ComputeSDK's millisecond convention and is converted to OpenComputer's seconds-based API.

Features

  • Command execution via OpenComputer exec
  • Filesystem read, write, mkdir, list, exists, and remove
  • Sandbox create, reconnect by ID, and destroy
  • Preview URLs for sandbox ports
  • Checkpoints through ComputeSDK snapshots

Snapshots

OpenComputer checkpoints are scoped to a source sandbox. This provider returns snapshot IDs in the form instanceId:checkpointId so ComputeSDK can later delete the checkpoint.

const sandbox = await compute.instances.create();

const snapshot = await compute.snapshot.create(sandbox.instanceId, {
  name: 'ready-state',
});

const clone = await compute.instances.create({ snapshotId: snapshot.id });

await compute.snapshot.delete(snapshot.id);
await clone.destroy();
await sandbox.destroy();

You can also pass a raw OpenComputer checkpoint ID to compute.instances.create({ snapshotId }) when you only need to fork from it.

Snapshots default to OpenComputer disk_only checkpoints with promoteToFull: true. Override with metadata: { kind: 'full' } or metadata: { promoteToFull: false } when needed.

版本与发布记录

@computesdk/opencomputer 共发布 21 个版本,首次发布于 2026/07/24;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.21latest2026/11/064 天前
1.0.202026/11/046 天前
1.0.192026/10/2812 天前
1.0.182026/10/2317 天前
1.0.172026/10/2318 天前
1.0.162026/10/2218 天前

关于 @computesdk/opencomputer 的常见问题

@computesdk/opencomputer 是什么?

OpenComputer provider for ComputeSDK - persistent cloud VMs with checkpoints, preview URLs, command execution, and filesystem access

如何安装 @computesdk/opencomputer?

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

@computesdk/opencomputer 支持 TypeScript 吗?

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

@computesdk/opencomputer 支持 ESM 还是 CommonJS?

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

@computesdk/opencomputer 可以商用吗?

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

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

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

@computesdk/opencomputer 还在维护吗?

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