@computesdk/freestyle

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

Freestyle provider for ComputeSDK - full Linux VMs for long-running agent tasks, with instant startup and cheap snapshotting

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Configuration
  4. Capabilities
  5. License

@computesdk/freestyle

Freestyle provider for ComputeSDK — full Linux virtual machines designed for long-running, complex agent tasks, with instant startup, persistence, and cheap snapshotting.

Installation

npm install @computesdk/freestyle

# .env
FREESTYLE_API_KEY=your_freestyle_api_key

Freestyle base images ship no language runtime, so the first sandbox on an account bakes a Node + Python snapshot once (~20 s) and every sandbox after boots from it in ~200–300 ms. Set FREESTYLE_SNAPSHOT_ID (or the snapshotId option) to your own snapshot to skip baking.

Usage

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

const compute = freestyle({ apiKey: process.env.FREESTYLE_API_KEY });

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

const result = await sandbox.runCommand('node -v');
console.log(result.stdout); // "v22.19.0\n"

// Full native filesystem — Freestyle VMs are real Linux guests
await sandbox.filesystem.writeFile('/tmp/app.js', 'console.log("hi")');
console.log(await sandbox.filesystem.readFile('/tmp/app.js'));

await sandbox.destroy();

Configuration

interface FreestyleConfig {
  /** Freestyle API key. Falls back to FREESTYLE_API_KEY. */
  apiKey?: string;
  /** Snapshot every sandbox boots from. Falls back to FREESTYLE_SNAPSHOT_ID; auto-baked when unset. */
  snapshotId?: string;
  /** API base URL. Falls back to FREESTYLE_API_URL, then the SDK default. */
  baseUrl?: string;
  /** Idle seconds before Freestyle stops the VM (default 300). */
  idleTimeoutSeconds?: number;
  /** Default wall-clock limit for a single command, ms (default 300000; up to 24h per call). */
  timeout?: number;
  /** Keep the VM after it stops instead of deleting it (default: kept 5 min after stop/pause, so it can be resumed). */
  persistent?: boolean;
  /** Outbound firewall. Defaults to allow-all outbound; pass { rules: [] } to seal. */
  firewall?: { rules: unknown[] };
}

Capabilities

FeatureSupport
runCommand✅
Filesystem: read, write, readdir, mkdir, exists, remove✅ (native)
Snapshots: create, list, delete✅
Reconnect by id (compute.instances.getById)✅
List sandboxes✅ (VMs this provider created)
Long-running commands (timeout up to 24h)✅
Standard sizes (sizeClass: 'lg' | 'xl') and cpu / memory (MiB)✅ (grow-only from the 4 vCPU / 8 GiB runtime snapshot)
Pause / resume (getInstance().pause() / .start())✅ (default sandboxes; ephemeral: true VMs cannot pause)
getUrl (per-port URL)❌ — map a domain via freestyle.domains

License

MIT

版本与发布记录

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

版本发布日期距今
0.2.19latest2026/11/064 天前
0.2.182026/11/046 天前
0.2.172026/10/2813 天前
0.2.162026/10/2318 天前
0.2.152026/10/2318 天前
0.2.142026/10/2219 天前

关于 @computesdk/freestyle 的常见问题

@computesdk/freestyle 是什么?

Freestyle provider for ComputeSDK - full Linux VMs for long-running agent tasks, with instant startup and cheap snapshotting

如何安装 @computesdk/freestyle?

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

@computesdk/freestyle 支持 TypeScript 吗?

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

@computesdk/freestyle 支持 ESM 还是 CommonJS?

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

@computesdk/freestyle 可以商用吗?

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

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

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

@computesdk/freestyle 还在维护吗?

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