@bunny-agent/manager

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

BunnyAgent Manager - Manages sandbox and runner lifecycle, defines core interfaces

原始使用文档
文档目录15 节
  1. Overview
  2. Installation
  3. Quickstart
  4. Basic Usage
  5. With Transcript Logging
  6. Upload Files
  7. Core Interfaces
  8. SandboxAdapter
  9. SandboxHandle
  10. RunnerSpec
  11. Transcript Writers
  12. API Reference
  13. Bunny Agent
  14. Requirements
  15. License

@bunny-agent/manager

⚠️ Deprecated (exec-based transport)

@bunny-agent/manager works by spawning bunny-agent run CLI inside a sandbox via exec(). This approach is being superseded by @bunny-agent/daemon — a unified HTTP gateway that runs inside the sandbox and exposes the same capabilities over a clean REST API.

Prefer createBunnyAgent with an explicit daemonUrl from @bunny-agent/sdk when using the HTTP daemon.

This package remains supported for sandboxes that only provide exec() capability (E2B, Daytona, etc.) and has no planned removal date.

Core manager package for Bunny Agent - manages sandbox and runner lifecycle, defines core interfaces.

This package is the core runtime that wires sandbox adapters + a runner spec into an AI SDK UI stream you can consume from your server or CLI.

Overview

@bunny-agent/manager is the foundational package that provides:

  • Bunny Agent: Main class for managing sandboxed agent instances
  • Core Interfaces: SandboxAdapter, SandboxHandle, RunnerSpec, etc.
  • Transcript Writers: Tools for logging agent execution (JSONL, Memory, Console, Multi)
  • Type Definitions: Shared types for messages, streams, and sandbox operations

This package is typically used as a dependency by higher-level packages like @bunny-agent/sdk and sandbox adapters.

Installation

npm install @bunny-agent/manager

Quickstart

Basic Usage

import { Bunny Agent } from '@bunny-agent/manager';
import { E2BSandbox } from '@bunny-agent/sandbox-e2b';

const agent = new BunnyAgent({
  sandbox: new E2BSandbox({ apiKey: 'xxx' }),
  runner: {
    model: 'claude-sonnet-4-20250514',
    outputFormat: 'stream',
  },
  env: {
    ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!,
  },
});

// Stream a task
const stream = await agent.stream({
  messages: [
    { role: 'user', content: 'Create a hello world program' }
  ],
  workspace: {
    path: '/workspace',
  },
});

// Read the stream
const reader = stream.getReader();
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  process.stdout.write(value);
}

// Cleanup
await agent.destroy();

With Transcript Logging

import { Bunny Agent, JsonlTranscriptWriter } from '@bunny-agent/manager';

const transcriptWriter = new JsonlTranscriptWriter('./transcript.jsonl');

const stream = await agent.stream({
  messages: [{ role: 'user', content: 'Do something' }],
  workspace: { path: '/workspace' },
  transcriptWriter,
});

Upload Files

await agent.uploadFiles([
  { path: 'hello.txt', content: 'Hello World!' },
  { path: 'data.json', content: JSON.stringify({ key: 'value' }) },
], '/workspace');

Core Interfaces

SandboxAdapter

Interface that sandbox implementations must follow:

interface SandboxAdapter {
  attach(): Promise<SandboxHandle>;
  getHandle(): SandboxHandle | null;
  getEnv?(): Record<string, string>;
  getWorkdir?(): string;
}

SandboxHandle

Interface for interacting with an attached sandbox:

interface SandboxHandle {
  exec(command: string[], opts?: ExecOptions): AsyncIterable<Uint8Array>;
  upload(files: Array<{ path: string; content: Uint8Array | string }>, targetDir: string): Promise<void>;
  readFile?(filePath: string): Promise<string>;
  runCommand?(command: string): Promise<{ stdout: string; stderr: string; exitCode: number }>;
  destroy(): Promise<void>;
  getWorkdir?(): string;
}

RunnerSpec

Specification for the runner to execute inside the sandbox:

interface RunnerSpec {
  model: string;
  systemPrompt?: string;
  maxTurns?: number;
  allowedTools?: string[];
  outputFormat?: 'stream' | 'json';
}

Transcript Writers

Available transcript writers:

  • JsonlTranscriptWriter: Write to JSONL file
  • MemoryTranscriptWriter: Store in memory
  • ConsoleTranscriptWriter: Log to console
  • MultiTranscriptWriter: Write to multiple writers
import { 
  JsonlTranscriptWriter,
  MemoryTranscriptWriter,
  MultiTranscriptWriter 
} from '@bunny-agent/manager';

const transcriptWriter = new MultiTranscriptWriter([
  new JsonlTranscriptWriter('./transcript.jsonl'),
  new ConsoleTranscriptWriter(),
]);

API Reference

Bunny Agent

Constructor

new BunnyAgent(options: BunnyAgentOptions)

Options:

  • sandbox (required): A SandboxAdapter instance
  • runner (required): RunnerSpec configuration
  • env: Environment variables for the sandbox

Methods

stream(input: StreamInput): Promise<ReadableStream>

Stream a task through the agent. Returns a ReadableStream of AI SDK UI messages.

uploadFiles(files: Array<{ path: string; content: Uint8Array | string }>, targetDir?: string): Promise

Upload files to the agent's workspace.

destroy(): Promise

Destroy the sandbox and release resources.

Requirements

  • Node.js 20+
  • A sandbox adapter (@bunny-agent/sandbox-e2b, @bunny-agent/sandbox-local, etc.)

License

Apache-2.0

版本与发布记录

@bunny-agent/manager 共发布 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-beta.52026/10/2316 天前

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

@bunny-agent/manager 是什么?

BunnyAgent Manager - Manages sandbox and runner lifecycle, defines core interfaces

如何安装 @bunny-agent/manager?

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

@bunny-agent/manager 支持 TypeScript 吗?

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

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

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

@bunny-agent/manager 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bunny-agent/manager 可以商用吗?

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

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

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

@bunny-agent/manager 还在维护吗?

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