@bunny-agent/sandbox-sandock

中文文档
0.10.3-beta1发布于 2026/11/07Apache-2.0TypeScriptES Module近 30 天下载 6156

Sandock sandbox adapter for BunnyAgent

原始使用文档
文档目录14 节
  1. Prerequisites
  2. Install
  3. Quick Start
  4. Key Options
  5. Usage Patterns
  6. 1. Minimal (Pre-built Image)
  7. 2. With Persistent Volumes
  8. 3. Reuse Existing Sandbox
  9. With @bunny-agent/sdk
  10. API
  11. SandockSandbox (Adapter)
  12. SandboxHandle (returned by attach() )
  13. About skipBootstrap
  14. License

@bunny-agent/sandbox-sandock

Sandock sandbox adapter for Bunny Agent. Runs AI agents in Sandock remote sandboxes (instead of locally or via E2B/Daytona), with persistent volumes, seed-file uploads, and fast-start images.

Prerequisites

Install

npm install @bunny-agent/sandbox-sandock

Quick Start

import { SandockSandbox } from "@bunny-agent/sandbox-sandock";

const sandbox = new SandockSandbox({
  apiKey: process.env.SANDOCK_API_KEY,
  workdir: "/workspace",
  image: "ghcr.io/vikadata/bunny-agent:latest",
  skipBootstrap: true,
});

Key Options

OptionTypeDefaultDescription
apiKeystringSANDOCK_API_KEYSandock API key
imagestringsandockai/sandock-code:latestContainer image
workdirstring/workspaceWorking directory inside the sandbox
templatesPathstring-Local directory of files to seed the workspace; contents are uploaded to workdir on attach (e.g. project skeleton, configs)
volumes{ volumeName, volumeMountPath }[][]Persistent volumes; created or reused by name
skipBootstrapbooleanfalseIf true, skip runner install; image must include runner
envRecord<string, string>{}Environment variables injected into the sandbox
timeoutnumber300000Operation timeout in milliseconds
sandboxIdstring-Existing sandbox ID to reattach to; falls back to creating new on failure
namestring-Sandbox display name (e.g. for Sandock dashboard)
keepbooleantrueKeep sandbox running after execution

Usage Patterns

1. Minimal (Pre-built Image)

new SandockSandbox({
  apiKey: process.env.SANDOCK_API_KEY,
  image: "ghcr.io/vikadata/bunny-agent:latest",
  skipBootstrap: true,
  workdir: "/workspace",
});

2. With Persistent Volumes

new SandockSandbox({
  apiKey: process.env.SANDOCK_API_KEY,
  image: "ghcr.io/vikadata/bunny-agent:latest",
  skipBootstrap: true,
  workdir: "/workspace",
  volumes: [
    { volumeName: "my-workspace", volumeMountPath: "/workspace" },
    { volumeName: "my-session", volumeMountPath: "/root/.claude" },
  ],
});

3. Reuse Existing Sandbox

Pass sandboxId to reattach to a previously created sandbox. The adapter will only reattach if the sandbox is currently in RUNNING state. If the sandbox is stopped, paused, or no longer exists, attach() falls back to creating a new one automatically.

const sandbox = new SandockSandbox({
  apiKey: process.env.SANDOCK_API_KEY,
  image: "ghcr.io/vikadata/bunny-agent:latest",
  skipBootstrap: true,
  workdir: "/workspace",
  sandboxId: "cached-sandbox-id", // from your cache
});

const handle = await sandbox.attach();
// Store handle.getSandboxId() for next request

Note: The adapter does not attempt to start a stopped sandbox. Only RUNNING sandboxes are reused. This avoids unexpected cold-start delays and ensures a consistent attach experience.

For web apps, cache the sandboxId server-side (e.g. in-memory Map with 30-min TTL) so subsequent requests reuse the same sandbox without client-side state. Use keep: true (the default) to keep sandboxes running between requests.

With @bunny-agent/sdk

import { createBunnyAgent } from "@bunny-agent/sdk";
import { SandockSandbox } from "@bunny-agent/sandbox-sandock";
import { generateText } from "ai";

const bunnyAgent = createBunnyAgent({
  sandbox: new SandockSandbox({
    apiKey: process.env.SANDOCK_API_KEY,
    workdir: "/workspace",
    image: "ghcr.io/vikadata/bunny-agent:latest",
    skipBootstrap: true,
  }),
  env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY! },
});

const { text } = await generateText({
  model: bunnyAgent("sonnet"),
  prompt: "Create a hello world program",
});

Install: npm install @bunny-agent/sandbox-sandock @bunny-agent/sdk ai

API

SandockSandbox (Adapter)

  • attach() — Create or reuse a sandbox; returns a SandboxHandle
  • getHandle() — Returns the current handle if attached, otherwise null

SandboxHandle (returned by attach())

  • getSandboxId() — Returns the sandbox instance ID
  • getVolumes() — Returns mounted volume list (or null)
  • getWorkdir() — Returns the working directory
  • exec(command, opts) — Execute a command and stream output
  • upload(files, targetDir) — Upload files to the sandbox
  • readFile(filePath) — Read a file from the sandbox
  • destroy() — Stop and delete the sandbox

About skipBootstrap

  • skipBootstrap: true: Image already includes bunny-agent run; only upload seed files (from templatesPath), no runner install. Use with pre-built images like ghcr.io/vikadata/bunny-agent:latest.
  • skipBootstrap: false: On attach, runs npm install @bunny-agent/runner-cli@latest in workdir, then uses ${workdir}/node_modules/.bin/bunny-agent run for execution.

License

Apache-2.0

版本与发布记录

@bunny-agent/sandbox-sandock 共发布 115 个版本,首次发布于 2026/04/14;过去 12 个月发布了 115 个版本。

版本发布日期距今
0.10.3-beta1latest2026/11/071 天前
0.10.22026/10/2811 天前
0.10.1-beta.22026/10/2811 天前
0.10.1-beta.12026/10/2712 天前
0.10.0-release.62026/10/2613 天前
0.10.0-release.52026/10/2316 天前

关于 @bunny-agent/sandbox-sandock 的常见问题

@bunny-agent/sandbox-sandock 是什么?

Sandock sandbox adapter for BunnyAgent

如何安装 @bunny-agent/sandbox-sandock?

在项目目录运行 npm install @bunny-agent/sandbox-sandock,或使用 pnpm add / yarn add / bun add。

@bunny-agent/sandbox-sandock 支持 TypeScript 吗?

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

@bunny-agent/sandbox-sandock 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bunny-agent/sandbox-sandock 可以商用吗?

@bunny-agent/sandbox-sandock 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@bunny-agent/sandbox-sandock 的下载量有多少?

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

@bunny-agent/sandbox-sandock 还在维护吗?

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