# @computesdk/freestyle 中文文档

规范地址：https://npmcn.com/package/%40computesdk/freestyle/

版本：0\.2\.19
npm 元数据更新时间：2026-11-06T13:39:35.374Z
中文译文更新时间：2026-11-10T14:49:04.326Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40computesdk/freestyle
原文对照：https://npmcn.com/package/%40computesdk/freestyle/?lang=original
项目主页：https://www.computesdk.com/
源码仓库：https://github.com/computesdk/computesdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：110 kB，9 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2026-03-18T19:18:37.173Z
- 最新版本发布：2026-11-06T13:39:34.961Z
- 近 30 天下载量：8580（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：33（近 12 个月 33 个）

## 中文简介

ComputeSDK的自由式提供者 - 用于长期代理任务的全 Linux VMS, 即时启动和廉价快照

## 安装

```sh
npm install @computesdk/freestyle
```

也可以使用：`pnpm add @computesdk/freestyle`、`yarn add @computesdk/freestyle`、`bun add @computesdk/freestyle`

## README

# @ computesdk/ 免费样式

[自由风格](https://www.freestyle.sh/) computeSDK的提供商——为长期运行,复杂的代理任务而设计的全Linux虚拟机,具有即时启动,持续,廉价快照等功能.

## 安装

```bash
npm install @computesdk/freestyle

# .env
FREESTYLE_API_KEY=your_freestyle_api_key
```

自由式基础图像没有语言运行时间,所以 **第一个** 账户上的沙盒会烤出一个节点+Python快照一次(~20 s),并用~200–300ms从中取出后的每一个沙盒. 设定 `FREESTYLE_SNAPSHOT_ID` (或 `snapshotId` 选项),以跳过烘焙.

## 使用量

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

## 配置

```typescript
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[] };
}
```

## 能力

| 特性 | 支助 |
| --- | --- |
| `runCommand` | ✅ |
| 文件系统: 读取、 写入、 读取、 mkdir、 存在、 删除 | (本国) |
| 抓图: 创建、 列表、 删除 | ✅ |
| 由 id 重新连接( N)`compute.instances.getById`(中文(简体) ) | ✅ |
| 列出沙盒 | QQ( 此提供者创建的 VMs) |
| 长期运行的命令( R)`timeout` 最高24小时) | ✅ |
| 标准尺寸(`sizeClass: 'lg' | 'xl'`和 `cpu` 编号 : `memory` (微调) | QQ( 仅来自 4 vCPU / 8 GiB 运行时快照) |
| 暂停/ 恢复( N)`getInstance().pause()` 编号 : `.start()`(中文(简体) ) | ✅(默认沙盒; `ephemeral: true` VM 无法暂停) |
| `getUrl` (每个端口 URL) | qq — 绘制一个域名 [`freestyle.domains`](https://docs.freestyle.sh/) |

## 许可证

麻省理工学院

## 常见问题

### @computesdk/freestyle 是什么？

ComputeSDK的自由式提供者 - 用于长期代理任务的全 Linux VMS, 即时启动和廉价快照

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

