MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

madarco/agentbox 深度技术分析

项目背景与痛点

在现代化的软件开发和测试中,常常需要在不同的环境中运行多个测试代理或模拟系统,这不仅增加了成本,同时也带来了复杂性。madarco/agentbox 项目设计的核心理念是在同一台 PC 或云端上使用单个命令运行多个代理实例,这些实例运行在彼此隔离的虚拟机中,可以大幅缩减资源消耗,简化管理和维护工作。

虚拟机隔离技术可以极大地提升测试和开发环境的安全性和独立性。尤其是在开发复杂的系统应用时,这种隔离技术可以避免不同应用间因环境不一致产生的潜在问题。这种环境隔离不仅有助于快速实现环境的复制和切换,还可以极大地减少配置和管理的成本。

核心技术揭秘

madarco/agentbox 的技术实现,主要是围绕在虚拟机技术、容器管理以及底层操作系统支持等层面。通过配置文件驱动,用户可以灵活地定义和管理多个代理实例。默认提供的是沙箱化的虚拟机实例,这种设计既能够保持各实例间的隔离性,又大大节省了资源。

下面是 agentbox 的整个数据流的一个简要概述:

graph TD A[用户配置] --> B{"启动逻辑"} B -->|"验证参数"| C[启动代理] C --> D{"分配 VM 资源"} D -->|"成功"| E[运行沙箱环境] D -->|"失败"| F[返回错误] E --> G[执行代理任务] G --> H[监控和日志]

其中,最为关键的是 启动逻辑 模块,它负责读取并验证用户的配置文件,然后根据配置信息来启动、管理和监控多个代理实例,同时确保每个实例都在自己的隔离环境中运行。分配 VM 资源 步骤则是通过底层虚拟化技术,如 KVM 或 VirtualBox,来为每个代理提供一个完全隔离的运行环境。

功能亮点与差异

相比其他同类竞品,madarco/agentbox 的优势在于其能够快速、方便地在一站式环境中运行多个代理实例。对于需要在多种环境下发大量的测试任务的开发团队来说,这一点相当重要。它提供了一个灵活的配置文件接口,让用户能够精确地控制实例在什么条件下启动以及如何运行。这种设计带来了极大的灵活性与适应性,能够兼容不同的业务场景。

此外,通过使用已沙箱化的虚拟机,agentbox 确保了各个代理任务执行过程中的环境统一性和独立性,避免资源争用,极大地提升了开发和测试环境的一致性与效率。

应用场景与落地建议

对于需要频繁执行多环境下的开发与测试任务的团队,madarco/agentbox 提供了一种极具吸引力的解决方案。无论是构建跨平台的测试环境,还是实现不同版本间的快速切换,都显得格外简明易用。不过,需要注意的是,由于涉及到虚拟机技术,高并发运行时可能会对资源(如 CPU 与内存)提出较高的要求。

生产环境中使用 agentbox 时,应做好详细的计划,确保有足够的资源支持。同时也应当考虑到安全性和稳定性规划,避免任何单点故障。

综合评价

优点:

  • 理念先进:利用隔离技术,提升环境安全性。
  • 灵活易管理:通过配置文件管理,简化了多代理任务的启动和管理。
  • 适用性强:非常适用于开发团队需求,尤其是在多环境间需要频繁切换的情景中。

缺点:

  • 资源消耗:在生产环境中可能导致 CPU 和内存资源高消耗。
  • 技术要求:相较于容器管理工具,可能对虚拟化技术有一定要求。

尽管 madarco/agentbox 在某些方面存在不足,但对于合理的资源规划和使用它带来的诸多好处,其价值不可小觑,基本能够为开发团队与测试提供一个效率和安全兼得的解决方案。

关于

GitHub 原始描述(英文)

Run multiple agents in parallel sandboxed VMs, with a single command, on your PC or in the cloud

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

CSS
Dockerfile
HTML
JavaScript
MDX
Shell
Swift
TypeScript

README

AgentBox 

Run multiple agents in parallel, with a single command, on your PC, self-hosted, or in the cloud

Works with iterm2 - cmux - tmux - Herdr

AgentBox

How it works

agentbox claude # launch a new VM with claude and your project inside
  • 📦 Teleport - Move your project to a dedicated VM, local or in the cloud, with a single command.
  • 🤖 Automatic - Bring all your skills, plugins, and settings for Claude Code, Codex, Open Code
  • 🌐 A full Computer — Dedicated browser, screen sharing, persistent shells and warmed up VS Code / Cursor IDE, with each box.
  • 💾 Checkpoints — Sub <1s startup of new boxes from a previous checkpoint, auto pause to save cost/resources when not in use.
  • 🔒 Safe - Your git credentials are kept on your local machine, with permission requests to push to the remote repository.

Full Documentation

Complete setup:

npm -g install @madarco/agentbox
agentbox install

# Launch a new VM with claude, copy all your settings and workspace
agentbox claude

# Also install required project libraries and launch your dev server
> Run setup wizard? -> Yes

# Also use a cloud:
agentbox hetzner claude # or vercel, daytona

# Ctrl+a d to detach, claude keep going, to reconnect later:
agentbox attach 1

# To open a persistent shell inside the box:
agentbox shell 1

# Create a second box:
agentbox claude
agentbox attach 2
agentbox shell 2

# Open your web project on a .local url tunnel on your pc
agentbox url 2
# Or the in-box browser via webVNC:
agentbox screen 2
# Or connect to vscode/cursor inside the box:
agentbox code 2

# See status and quickly switch between agents:
agentbox dashboard

Demo

AgentBox demo

Install

npm -g install @madarco/agentbox

Want to help test what’s coming? npm -g install @madarco/agentbox@nightly puts you on the nightly channel — pre-release builds, with stable releases still reaching you automatically. agentbox self-update --channel stable opts back out.

Requirements: macOS (arm64 or Intel) or Linux, Docker (Docker Desktop or OrbStack), Node >=20.10. The first agentbox create / agentbox claude builds the agentbox/box:dev image (~1 GB, one-time). Uses portless to give box web apps the same URL from inside the box and on the host.

Cloud Providers

local docker remote docker hetzner daytona vercel e2b
Support ✅ ✅ ✅ ⚠️ Partial ✅ ✅
Base image Dockerfile Dockerfile (on the remote) Setup script (Ubuntu) Dockerfile Setup script Dockerfile (Template.build)
Live snapshots ✅ ✅ (docker commit) ✅ 🧪 Experimental ✅ ✅
Private preview URLs ✅ (portless or OrbStack) ✅ (portless over SSH) ✅ (portless) ✅ (native) ✅ (native) ✅ (native)

Cloud setup (optional — skip for local Docker)

  • agentbox install — interactive setup wizard to choose which providers to use and configure them.
  • agentbox vercel login — interactive Vercel Sandbox token setup, saved to ~/.agentbox/secrets.env
  • agentbox hetzner login — interactive Hetzner Cloud token setup, saved to ~/.agentbox/secrets.env
  • agentbox daytona login — interactive Daytona API key setup, saved to ~/.agentbox/secrets.env
  • agentbox e2b login — interactive E2B API key setup, saved to ~/.agentbox/secrets.env
  • agentbox digitalocean login — interactive DigitalOcean Personal Access Token setup, saved to ~/.agentbox/secrets.env
  • agentbox remote-docker doctor <host> — run boxes on a machine you already own, over SSH. No login and no token: it connects as you, using your own ~/.ssh/config. Then agentbox docker:<host> claude.
  • agentbox prepare [--provider daytona|hetzner|vercel|e2b|digitalocean|docker:<host>] — build the image and initial snapshot (e2b builds from a Dockerfile via Template.build())
  • agentbox hetzner claude, agentbox hetzner codex, agentbox hetzner create, etc.

How to use

<box> is optional almost everywhere — it defaults to the box for the current project, or use its short index (1, 2, …), name, or id prefix.

Create & run

  • agentbox create — Create and start a new agent box (Docker container with FUSE overlay)
  • agentbox claude — Create a sandboxed box and launch Claude Code in a detachable tmux session

Access

  • agentbox url — Open a box’s web app URL in the browser (even with no expose: service)
  • agentbox screen — Open a box’s VNC (noVNC) viewer in the browser
  • agentbox code — Open a box in VS Code or Cursor via the Dev Containers extension
  • agentbox shell — Open an interactive bash shell in a box
  • agentbox open — Open a box’s merged workspace in Finder
  • agentbox logs — Print recent log lines from a box service; -f to stream
  • agentbox dashboard — Box list + the selected box’s live agent session

Inspect

  • agentbox list (ls) — List boxes in current project or -g for all
  • agentbox status — Show service + task status from a box’s agentbox-ctl daemon
  • agentbox top — Live resource monitor (cpu/mem/pids/disk) for a box, project, or all boxes

Lifecycle

  • agentbox start — Start a stopped box (docker start + re-mount the FUSE overlay)
  • agentbox stop — Stop a box (preserves the upper volume, node_modules included)
  • agentbox destroy (rm) — Destroy a box and discard its upper volume
  • agentbox pause / agentbox unpause — Freeze / resume a box (sub-second)

Sync & state

  • agentbox download — Download a box’s /workspace back into your host workspace (gitignore-aware)
  • agentbox cp <src> [dst] — Copy individual files between host and box (like docker cp; direction picked by name: prefix)
  • agentbox checkpoint (alias checkpoints) — List and manage project checkpoints (warm box state to start new boxes from); bare command lists, checkpoint create captures

Advanced

  • agentbox wait — Block until the box reports all autostart units ready
  • agentbox prune — Clean up orphan state records (and with --all, orphan docker resources)
  • agentbox self-update — Update agentbox, wipe the box image so it rebuilds, reload the relay
  • agentbox config — Read / write layered config (global, per-project, workspace defaults:)
  • agentbox relay — Manage the host relay process (status / stop / start / restart)
  • agentbox app — Control the macOS menu-bar app process (status / start / stop / restart); install it with agentbox install app

Run agentbox <command> --help for command-specific options.

Documentation

Full documentation lives at agent-box.sh/docs:

Development

git clone https://github.com/madarco/agentbox && cd agentbox
pnpm install && pnpm build
node apps/cli/dist/index.js --help

The full development workflow, stack, end-to-end smoke tests, and teardown live in docs/development.md.

The macOS tray app lives in the sibling repo ../agentbox-tray. When you have it checked out next to this repo, these scripts build and run your local dev build (ad-hoc signed, at ../agentbox-tray/AgentBoxTray.app) — separate from the notarized copy agentbox install app puts in /Applications:

pnpm tray:dev        # rebuild the dev .app and relaunch it (the one you'll use most)
pnpm tray:build      # just rebuild (scripts/make-app.sh)
pnpm tray:start      # launch the dev build
pnpm tray:stop       # quit any running instance
pnpm tray:restart    # quit + relaunch the dev build

Note: agentbox app start|restart targets the installed /Applications copy, not this dev build. Use the pnpm tray:* scripts while iterating on the tray here; run agentbox install app to refresh /Applications from the current CLI build.

Custom providers (plugins)

AgentBox’s provider surface is open — you can run agents on your own cloud/infra by shipping a provider plugin (its own npm package built on @madarco/agentbox-provider-sdk), with no changes to AgentBox. Build and test against the bundled example provider locally:

# build the SDK, then build + register the example provider
pnpm --filter @madarco/agentbox-provider-sdk build
cd examples/agentbox-provider-example && npm install && npm run build
node ../../apps/cli/dist/index.js plugin add .      # register it
node ../../apps/cli/dist/index.js doctor            # shows the provider's group

# verify the SDK artifact in isolation (packs + installs the tarball, asserts exports)
pnpm --filter @madarco/agentbox-provider-sdk pack:test

Full guide: Build a provider (and the authoring reference docs/provider-plugins.md). Reference packages: examples/agentbox-provider-sample (stub) and examples/agentbox-provider-example (a real, Vercel-backed provider).

Contributing

Bug reports, docs fixes, and provider work are welcome — see CONTRIBUTING.md. First-time contributors sign a one-line CLA on their first pull request. Security issues go through SECURITY.md, not a public issue.

For new sandbox providers, see Build a provider and the authoring reference docs/provider-plugins.md.

Author

Marco D’Alia - @madarco - Linkedin

License

MIT. See LICENSE.

评论

暂无评论