@computesdk/promigence

中文文档
1.0.9发布于 2026/11/06MITTypeScriptESM + CJS近 30 天下载 7738

Promigence provider for ComputeSDK - production-grade sandboxes for AI agents, with filesystem and streaming output

原始使用文档
文档目录13 节
  1. Installation
  2. Setup
  3. Quick Start
  4. Configuration
  5. Configuration Options
  6. create() options
  7. Features
  8. Supported runtimes
  9. The Promigence SDK underneath
  10. Error Handling
  11. Limitations
  12. Support
  13. License

@computesdk/promigence

Promigence provider for ComputeSDK - production-grade sandboxes for AI agents, with filesystem and streaming output.

Promigence runs AI agents and their code in sandboxes, each forked from a snapshot and run under a spend cap. A snapshot you build with a test command is stored only once that test passes. With this package, code written against computesdk runs on Promigence sandboxes.

Installation

npm install @computesdk/promigence

It needs Node.js 20 or later.

Setup

Sign up with the Promigence CLI. It stores an API key on this machine, and the provider uses that key whenever none is passed or set:

npm install -g promigence
promigence signup    # or `promigence login` for an account you already have

On a server or in CI, set the key in the environment instead:

export PROMIGENCE_API_KEY=prom_api_...
Environment variableMeaning
PROMIGENCE_API_KEYYour API key, when apiKey is not passed
PROMIGENCE_SPEND_CAPOptional: the most one sandbox may spend, in US dollars, when spendCap is not passed. Unset, your organization's default cap applies
PROMIGENCE_API_URLOptional: the API to use, when apiUrl is not passed

Quick Start

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

compute.setConfig({
  provider: promigence({ apiKey: process.env.PROMIGENCE_API_KEY }),
});

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

const result = await sandbox.runCommand(`python3 - <<'PY'
print("Hello from Promigence")
PY`);
console.log(result.stdout);

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

await sandbox.destroy();

You can also call the provider directly:

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

const provider = promigence({}); // PROMIGENCE_API_KEY, or the key the CLI stored
const sandbox = await provider.instances.create({ templateId: 'my-app' }); // a snapshot you built, by its alias

Configuration

Configuration Options

interface PromigenceConfig {
  /** Promigence API key - if not provided, uses PROMIGENCE_API_KEY, then the key `promigence login` stored */
  apiKey?: string;
  /** Promigence API URL - if not provided, uses PROMIGENCE_API_URL, then the default Promigence API */
  apiUrl?: string;
  /** The most one sandbox may spend, in US dollars - if not provided, uses PROMIGENCE_SPEND_CAP, then your organization's default cap */
  spendCap?: number;
  /** The snapshot create() starts from when it names none (id, alias or alias@commit); default: the built-in base snapshot */
  snapshot?: string;
  /** Sandbox lifetime in milliseconds when create() sets none; also the bound on a command that sets none */
  timeout?: number;
  /** Size of a sandbox created from an image: 'xsmall', 'small', 'medium', 'large', 'xlarge' or '2xlarge' */
  tier?: string;
  /** 'start' (the default) or 'compute' (long, memory-heavy jobs on the larger tiers) */
  optimizeFor?: 'start' | 'compute';
  /** A client from @promigence/sdk to use instead of one built from apiKey and apiUrl */
  client?: PromigenceClient;
}

The provider checks this config before it sends anything. A missing key, or a malformed URL, spend cap or timeout, is an error that says what to fix.

create() options

OptionWhat it does
templateId / snapshotIdThe snapshot to start from: its id, its alias, alias@commit, or the name of a Promigence template (promigence templates lists them)
imageA container image instead of a snapshot: a tag such as python:3.12, or name@sha256:.... The first create() from an image builds its snapshot, billed per second while it builds; later ones reuse it. Not together with templateId / snapshotId
tier, registrySecretWith image: the sandbox size, and the name of a stored secret that holds the registry credentials
timeoutSandbox lifetime in milliseconds
envsEnvironment variables for every command run through this sandbox
metadataLabels on the sandbox (values that are not strings are stored as JSON)
allowInternetAccess: falseNo network access
allowHosts: [...]Only these destinations can be reached
spendCap, optimizeForOverride the provider config for this sandbox
runtime, name, CPU and memory fieldsIgnored: a sandbox has its snapshot's size

Features

Commands take cwd, env, timeout and background, and one that exits non-zero comes back as a normal result with its exitCode. Pass onStdout or onStderr and the output arrives while the command runs. A command that outruns its timeout is stopped and reported with exit code 124.

The filesystem API reads, writes, lists and removes files, creates directories and checks whether a path exists. Sandboxes are managed with create, getById, list (every sandbox that has not ended) and destroy; snapshots with snapshot.create(sandboxId), snapshot.list() and snapshot.delete(id). Every sandbox runs under a spend cap: yours, PROMIGENCE_SPEND_CAP, or your organization's default.

Supported runtimes

The built-in base snapshot comes with Python, Node.js and Go, plus git and common build tools. Any container image works through image. So does any snapshot you build with the Promigence CLI, through templateId.

The Promigence SDK underneath

sandbox.getInstance() returns { sandbox, client, config }: the Sandbox from @promigence/sdk, the client it uses and the provider config. Reach for it when you need something the SDK offers beyond the ComputeSDK interface; the TypeScript SDK docs describe it.

Error Handling

A Promigence error is re-thrown with the operation named. It keeps the SDK's code and fix (what to do next) and the original error as cause; every code is listed at promigence.ai/docs/errors.

try {
  await promigence({}).instances.create();
} catch (error) {
  const { code, fix } = error as { code?: string; fix?: string };
  console.error(code, fix); // for example: auth, and how to pass a key
}

While fallbackOnError is on (the default), compute.instances.create() combines the failures of every configured provider into one error. Pass fallbackOnError: false to compute.setConfig() to receive the Promigence error itself.

Limitations

  • There are no preview URLs yet, so getUrl() throws. To reach a server in the sandbox, call it from a command in the same sandbox, for example with curl.
  • snapshot.create(sandboxId) takes a snapshot of a running sandbox, which keeps running; start new sandboxes from it with create({ snapshotId }). The whole sandbox is kept, memory included: files anywhere (/tmp and /dev/shm too) and the processes it was running. Only commands started with runCommand(cmd, { background: true }) are ended to take it.
  • sandbox.pause() stops billing and frees capacity until sandbox.resume(), which brings the sandbox back as it was: files, memory and running processes. Commands started with { background: true } end at the pause.
  • Templates are snapshots here. The template methods throw, and templateId on create() names a snapshot.
  • runCommand(cmd, { background: true }) answers at once with exit code 0 and does not collect the command's output.
  • CPU and memory fields on create() are ignored. A sandbox has its snapshot's size, and tier picks one for a sandbox created from image.
  • Environment variables passed to create() apply to commands run through the sandbox it returned. A handle from getById() or list() does not have them, so pass env with each command there.

Support

Read the Promigence documentation and the error codes, or write to [email protected]. Problems with ComputeSDK itself go to ComputeSDK Issues.

License

MIT

版本与发布记录

@computesdk/promigence 共发布 10 个版本,首次发布于 2026/10/21;过去 12 个月发布了 10 个版本。

版本发布日期距今
1.0.9latest2026/11/064 天前
1.0.82026/11/046 天前
1.0.72026/10/2813 天前
1.0.62026/10/2318 天前
1.0.52026/10/2318 天前
1.0.42026/10/2219 天前

关于 @computesdk/promigence 的常见问题

@computesdk/promigence 是什么?

Promigence provider for ComputeSDK - production-grade sandboxes for AI agents, with filesystem and streaming output

如何安装 @computesdk/promigence?

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

@computesdk/promigence 支持 TypeScript 吗?

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

@computesdk/promigence 支持 ESM 还是 CommonJS?

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

@computesdk/promigence 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@computesdk/promigence 可以商用吗?

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

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

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

@computesdk/promigence 还在维护吗?

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