@computesdk/arker

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

计算SDK 的 Arker 提供者 - 有持续文件系统的沙盒 VMs, 从金色图像取出

中文使用文档
文档目录15 节
  1. 安装
  2. 设置
  3. 快速启动
  4. 沙盒是如何创建的
  5. 配置
  6. 环境变量
  7. 配置选项
  8. API 参考
  9. 命令执行
  10. 文件系统操作
  11. 沙盒管理
  12. 特征
  13. 限制
  14. 支助
  15. 许可证

@ computesdk/ arker (帮助)

计算SDK的 Arker 提供者——运行代码 阿克尔 沙盒 VMs 有持久的每VM文件系统.

安装

npm install @computesdk/arker

设置

  1. 获取您的 Arker API 密钥( 启动于 ark_从 方舟鱼.ai。 。 。 .
  2. 设置环境变量 :
export ARKER_API_KEY=ark_live_your_api_key_here

默认情况下,提供者的目标是 aws-us-east-1 区域。 选择另一个区域 region 编号 : ARKER_REGION。 。 。 .

快速启动

配置 compute 与 Arker 提供者创建沙盒 :

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();

或者在只需要一个供货商时直接给供货厂打电话:

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

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

沙盒是如何创建的

Arker 禁用直接 VM 创建—— 每个沙盒是 从源 VM 防御。 。 。 . create() 叉车 ubuntu-small 金色(Node.js + Python 预设)默认. 来源可以选择两种方式:

  • 名称 - 一个金色/模版,通过 source 在配置中或 templateId 在创建选项中.
  • 依编号 - 通过下列途径,确定一个具体的现有VM: snapshotId 在创建选项中。 这个 instanceId 返回时间 create() 本身是一个有效的源,所以这个分支从它的当前状态(Arker相当于快照还原)中分出一个沙盒. 如果两者都给出了, snapshotId 赢了.
// 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 });

配置

环境变量

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

配置选项

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 参考

命令执行

// 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 返回时 { stdout, stderr, exitCode, durationMs }。 。 。 .

文件系统操作

文件系统操作在VM中作为 shell 命令运行,并在任意路径上工作.

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');

沙盒管理

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();

特征

  • ✅ 命令执行 ——全外壳,节点js & Python 预装(ubuntu-small(中文(简体) )
  • ✅ 文件系统操作 连续的每VM文件系统(阅读/写作/列表/mkdir/存在/删除)
  • ✅ 快速冷却开始 - 将默认的金靴扔到地上..
  • ✅ 自动重试 - 基础 @arker-ai/sdk 重试瞬间故障(HTTP 429/502/503/504和瞬间后端错误)

限制

  • 创建仅为叉 直接的VM创建被禁用; create() 叉出一个金色的名字(templateId编号 :source)或以id为单位的现有 VM(snapshotId) (中文(简体) ). 没有单独的快照店,但任何 instanceId 能够重起炉子 snapshotId。 。 。 .
  • getUrl 不支持 - Arker不披露每个港口的URL; getUrl 掷出. 以网络可达性为条件的VMs 获得一个稳定的每VM主机名——见 方舟SDK 分叉网络选项.
  • getInfo 状态 - 总是报告 running; 闲置的沙盒会在其下一个命令上自动恢复.

支助

许可证

麻省理工学院

版本与发布记录

@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 是什么?

计算SDK 的 Arker 提供者 - 有持续文件系统的沙盒 VMs, 从金色图像取出

如何安装 @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 和提交记录判断。