@computesdk/arker

中文文档
0.1.23发布于 2026/11/07MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1万

Arker provider for ComputeSDK - sandboxed VMs with persistent filesystems, forked from golden images

原始使用文档
文档目录15 节
  1. Installation
  2. Setup
  3. Quick Start
  4. How sandboxes are created
  5. Configuration
  6. Environment Variables
  7. Configuration Options
  8. API Reference
  9. Command Execution
  10. Filesystem Operations
  11. Sandbox Management
  12. Features
  13. Limitations
  14. Support
  15. License

@computesdk/arker

Arker provider for ComputeSDK — run code in Arker sandboxed VMs with persistent per-VM filesystems.

Installation

npm install @computesdk/arker

Setup

  1. Get your Arker API key (starts with ark_) from arker.ai.
  2. Set the environment variable:
export ARKER_API_KEY=ark_live_your_api_key_here

By default the provider targets the aws-us-east-1 region. Select another region with region / ARKER_REGION.

Quick Start

Configure compute with the Arker provider and create a sandbox:

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

compute.setConfig({
  provider: arker({ apiKey: process.env.ARKER_API_KEY }),
});

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

const result = await sandbox.runCommand('node -v');
console.log(result.stdout); // v18.x

await sandbox.destroy();

Or call the provider factory directly when you only need one provider:

import { arker } from '@computesdk/arker';

const sdk = arker({ apiKey: process.env.ARKER_API_KEY });
const sandbox = await sdk.sandbox.create();

How sandboxes are created

Arker disables direct VM creation — every sandbox is forked from a source VM. create() forks the ubuntu-small golden (Node.js + Python preinstalled) by default. The source can be chosen two ways:

  • By name — a golden/template, via source in config or templateId in create options.
  • By id — a specific existing VM, via snapshotId in create options. The instanceId returned by create() is itself a valid source, so this branches a sandbox from its current state (Arker's equivalent of a snapshot restore). If both are given, snapshotId wins.
// Default: forks the `ubuntu-small` golden
const sandbox = await sdk.sandbox.create();

// Pick a golden globally for this provider
const heavy = arker({ apiKey, source: 'ubuntu-full' });

// ...or per sandbox, by name
const other = await sdk.sandbox.create({ templateId: 'ubuntu-full' });

// Fork an existing sandbox by id — branches from its current state
const forked = await sdk.sandbox.create({ snapshotId: sandbox.instanceId });

Configuration

Environment Variables

export ARKER_API_KEY=ark_live_your_api_key_here
export ARKER_REGION=aws-us-east-1     # optional, this is the default
export ARKER_SOURCE=ubuntu-small      # optional default golden

Configuration Options

interface ArkerConfig {
  /** Arker API key (starts with `ark_`). Falls back to ARKER_API_KEY. */
  apiKey?: string;
  /** Region, e.g. `aws-us-east-1`. Falls back to ARKER_REGION, then the us-east-1 default. */
  region?: string;
  /** Golden source VM to fork on create(). Falls back to ARKER_SOURCE, then `ubuntu-small`. */
  source?: string;
}

API Reference

Command Execution

// Shell command
const result = await sandbox.runCommand('echo hello');

// Run a script via heredoc
const result = await sandbox.runCommand(`python3 - <<'PY'
print("Hello from Python")
PY`);

// With environment and working directory
const result = await sandbox.runCommand('npm test', {
  cwd: '/app',
  env: { CI: '1' },
});

runCommand returns { stdout, stderr, exitCode, durationMs }.

Filesystem Operations

Filesystem operations run as shell commands in the VM and work over arbitrary paths.

await sandbox.filesystem.writeFile('/tmp/hello.txt', 'hi');
const content = await sandbox.filesystem.readFile('/tmp/hello.txt');
await sandbox.filesystem.mkdir('/tmp/data');
const entries = await sandbox.filesystem.readdir('/tmp');
const exists = await sandbox.filesystem.exists('/tmp/hello.txt');
await sandbox.filesystem.remove('/tmp/hello.txt');

Sandbox Management

const sandbox = await sdk.sandbox.create();
const info = await sandbox.getInfo();      // { id, provider, status, createdAt, ... }
const all = await sdk.sandbox.list();      // VMs visible to the API key
const existing = await sdk.sandbox.getById(sandbox.instanceId);
await sandbox.destroy();

Features

  • ✅ Command Execution — full shell, Node.js & Python preinstalled (ubuntu-small)
  • ✅ Filesystem Operations — persistent per-VM filesystem (read/write/list/mkdir/exists/remove)
  • ✅ Fast cold start — forking the default golden boots a sandbox in well under a second
  • ✅ Automatic retries — the underlying @arker-ai/sdk retries transient failures (HTTP 429/502/503/504 and transient backend errors)

Limitations

  • Creation is fork-only — direct VM creation is disabled; create() forks a golden by name (templateId/source) or an existing VM by id (snapshotId). There's no separate snapshot store, but any instanceId can be re-forked as a snapshotId.
  • getUrl is not supported — Arker does not expose per-port URLs; getUrl throws. VMs forked with network reachability enabled get a stable per-VM hostname — see the Arker SDK fork network options.
  • getInfo status — always reports running; idle sandboxes resume automatically on their next command.

Support

License

MIT

版本与发布记录

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

版本发布日期距今
0.1.23latest2026/11/073 天前
0.1.222026/11/073 天前
0.1.212026/11/064 天前
0.1.202026/11/046 天前
0.1.192026/10/2812 天前
0.1.182026/10/2317 天前

关于 @computesdk/arker 的常见问题

@computesdk/arker 是什么?

Arker provider for ComputeSDK - sandboxed VMs with persistent filesystems, forked from golden images

如何安装 @computesdk/arker?

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

@computesdk/arker 支持 TypeScript 吗?

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

@computesdk/arker 支持 ESM 还是 CommonJS?

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

@computesdk/arker 可以商用吗?

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

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

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

@computesdk/arker 还在维护吗?

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