SuperAPI AI 工具集

tanstack-ai-sandbox

智能体与模型

查看项目

更新于 10-16 09:58

技能介绍

用途:在隔离沙箱内运行前端智能体 CLI(Claude Code、Codex、OpenCode)。harness 适配器声明需要 SandboxCapability,chat() 需由 withSandbox(...) 中间件提供,适配器随后在沙箱中运行 agent CLI 并流式回传事件。

主要能力:defineSandbox 定义 id、provider、workspace 与 lifecycle;defineWorkspace 声明 git 来源、包管理器、setup 命令、secrets、skills、plugins 与 instructions。提供 localProcessSandbox(本机,无隔离,仅开发)与 dockerSandbox(容器隔离,支持快照、fork、按 id 恢复、exec、端口连接)。二者实现同一 SandboxHandle。支持类型安全密钥 createSecrets/bearer、声明式 skills(agentSkill、gitSkill、mcpSkill、fileSkill)并按 harness 投影配置,instructions 写为 AGENTS.md 并创建 CLAUDE.md/GEMINI.md 符号链接。支持浅克隆 depth、串行/并行 setup 回调、setup 后快照与 snapshotMaxAge、策略 defineSandboxPolicy(allow/ask/deny)、reuse: 'thread' 生命周期与可插拔 SandboxInstanceStore 持久恢复、文件事件钩子(sandbox 级与运行级)、watchWorkspace 低层监听、边缘/无服务器执行(pipeToRunLog、RunController、工具桥)、Cloudflare 运行时及持久运行日志。

使用方式:配合 @tanstack/ai 的 chat(),传入 adapter、messages 与 middleware: [withSandbox(sandbox)];多副本可加 withLocks 并传 instances 存储。

限制:localProcessSandbox 无隔离;不支持快照或 stdin 的 provider 会跳过或走文件重定向;CLI 不支持的 skill/plugin 仅 console.warn 并跳过;不支持的可选方法抛 UnsupportedCapabilityError。具体安装命令、价格与官方文档地址资料未完整提供。