vercel-sandbox

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vercel Sandbox Skill

Vercel Sandbox 技能

Vercel Sandbox is an ephemeral compute primitive (Beta, all plans) that runs untrusted or user-generated code in isolated Linux microVMs on Vercel. It supports AI agents, code generation tools, developer sandboxes, and backend logic testing.
Vercel Sandbox 是一种临时计算原语(Beta版,支持所有套餐),可在Vercel的隔离Linux microVM中运行不受信任或用户生成的代码。它支持AI Agent、代码生成工具、开发者sandbox以及后端逻辑测试。

When to consult reference files

何时查阅参考文件

  • Getting started / setup: Read references/quickstart.md
  • SDK usage (TypeScript): Read references/sdk-reference.md
  • CLI commands: Read references/cli-reference.md
  • Pricing, limits, resource specs: Read references/pricing-and-specs.md
  • Authentication details: Covered in both quickstart and SDK reference files
  • 入门/设置:阅读 references/quickstart.md
  • SDK使用(TypeScript):阅读 references/sdk-reference.md
  • CLI命令:阅读 references/cli-reference.md
  • 定价、限制、资源规格:阅读 references/pricing-and-specs.md
  • 身份验证详情:在快速入门和SDK参考文件中均有涵盖

Quick reference

快速参考

Install

安装

bash
pnpm i @vercel/sandbox    # TypeScript
pip install vercel-sandbox # Python
bash
pnpm i @vercel/sandbox    # TypeScript
pip install vercel-sandbox # Python

Authentication setup

身份验证设置

bash
vercel link         # Link to a Vercel project
vercel env pull     # Pull OIDC token to .env.local (expires 12h locally)
bash
vercel link         # 关联到Vercel项目
vercel env pull     # 将OIDC token拉取到.env.local(本地有效期12小时)

Minimal example (TypeScript)

最简示例(TypeScript)

ts
import { Sandbox } from '@vercel/sandbox';

const sandbox = await Sandbox.create();
const result = await sandbox.runCommand('echo', ['Hello from Vercel Sandbox!']);
console.log(await result.stdout());
await sandbox.stop();
ts
import { Sandbox } from '@vercel/sandbox';

const sandbox = await Sandbox.create();
const result = await sandbox.runCommand('echo', ['Hello from Vercel Sandbox!']);
console.log(await result.stdout());
await sandbox.stop();

Key SDK classes

核心SDK类

ClassPurpose
Sandbox
Create, manage, list, snapshot microVMs
Command
Interact with running/detached commands
CommandFinished
Access exit code, stdout, stderr after completion
Snapshot
Save/restore sandbox state for fast restarts
类名用途
Sandbox
创建、管理、列出、快照microVM
Command
与运行中/分离的命令交互
CommandFinished
完成后访问退出码、标准输出、标准错误
Snapshot
保存/恢复sandbox状态以实现快速重启

Available runtimes

可用运行时

node24
,
node22
,
python3.13
— all on Amazon Linux 2023.
node24
,
node22
,
python3.13
— 均基于Amazon Linux 2023。

Default working directory

默认工作目录

/vercel/sandbox
— user code runs as
vercel-sandbox
user.
/vercel/sandbox
— 用户代码以
vercel-sandbox
用户身份运行。

Timeouts

超时设置

Default 5 min. Max: 45 min (Hobby), 5 hours (Pro/Enterprise). Extend with
sandbox.extendTimeout()
.
默认5分钟。最大值:Hobby套餐45分钟,Pro/Enterprise套餐5小时。可通过
sandbox.extendTimeout()
延长。

Snapshots

快照

Capture with
sandbox.snapshot()
— sandbox stops after snapshot. Expire after 7 days.
使用
sandbox.snapshot()
捕获——快照完成后sandbox会停止。7天后过期。

Updating documentation

更新文档

When the user asks to "update the Vercel Sandbox documentation", choose the right method based on the environment:
当用户要求“更新Vercel Sandbox文档”时,根据环境选择合适的方法:

Method selection

方法选择

  • claude.ai / Claude Desktop (has
    web_fetch
    tool) → Use Path A: web_fetch
  • Claude Code (has bash with internet) → Use Path B: Python script
To detect: if
web_fetch
is in your available tools, use Path A. Otherwise use Path B.
  • claude.ai / Claude Desktop(具备
    web_fetch
    工具)→ 使用 路径A:web_fetch
  • Claude Code(具备联网bash环境)→ 使用 路径B:Python脚本
检测方式:如果可用工具中包含
web_fetch
,则使用路径A,否则使用路径B。

Path A: web_fetch (claude.ai / Claude Desktop)

路径A:web_fetch(claude.ai / Claude Desktop)

  1. Use
    web_fetch
    to retrieve https://vercel.com/docs/vercel-sandbox (the main page)
  2. Discover all sub-page links under
    /docs/vercel-sandbox/
  3. Fetch each known sub-page URL (see list below) plus any newly discovered pages
  4. For each reference file in
    references/
    : a. Read the existing file content b. Compare with fetched content — note additions, removals, changes c. Rewrite the reference file with updated, clean markdown d. Update the
    > Last fetched:
    date at the top
  5. Report to user: pages fetched, what changed per file, update date
  1. 使用
    web_fetch
    获取https://vercel.com/docs/vercel-sandbox(主页面)
  2. 发现
    /docs/vercel-sandbox/
    下的所有子页面链接
  3. 获取所有已知子页面URL(见下方列表)以及任何新发现的页面
  4. 对于
    references/
    中的每个参考文件: a. 读取现有文件内容 b. 与获取的内容进行比较——记录新增、删除和修改内容 c. 用更新后的清晰Markdown重写参考文件 d. 更新顶部的
    > Last fetched:
    日期
  5. 向用户报告:获取的页面数量、每个文件的变更内容、更新日期

Path B: Python script (Claude Code / local terminal)

路径B:Python脚本(Claude Code / 本地终端)

Run the update script which has full internet access:
bash
python3 <skill-path>/scripts/update_docs.py <skill-path>/references
The script will:
  1. Fetch all known sandbox doc URLs from vercel.com
  2. Discover any new sub-pages from the main page
  3. For each reference file: compute a diff, overwrite with new content, report changes
  4. Print a summary of what changed and when
After the script runs, review its output and report changes to the user.
运行具备完整联网权限的更新脚本:
bash
python3 <skill-path>/scripts/update_docs.py <skill-path>/references
该脚本将:
  1. 从vercel.com获取所有已知sandbox文档URL
  2. 从主页面发现任何新的子页面
  3. 对于每个参考文件:计算差异,用新内容覆盖,报告变更
  4. 打印变更内容和时间的摘要
脚本运行后,查看其输出并向用户报告变更情况。

Known doc page URLs

已知文档页面URL