显示HN:Era – 开源本地AI代理沙箱
Show HN: Era – Open-source local sandbox for AI agents

原始链接: https://github.com/BinSquare/ERA

## ERA:使用微型虚拟机安全运行不受信任的代码 ERA 允许您使用类似于容器的微型虚拟机,在本地安全地运行不受信任或 AI 生成的代码。它具有快速启动时间(约 200 毫秒)和友好的开发体验。通过全球部署的 Worker/API(参见 cloudflare/README.md),也可提供完全托管的云层。 **安装:** 主要通过 Homebrew(推荐):`brew tap binsquare/era-agent-cli` & `brew install era-agent-cli`。依赖项包括 `krunvm` 和 `buildah`。macOS 用户需要区分大小写的 APFS 卷,可通过提供的脚本轻松设置。 **主要特性:** * **安全执行:** 将代码隔离在微型虚拟机中。 * **快速性能:** 200 毫秒启动时间。 * **语言支持:** Python、JavaScript/Node.js/TypeScript、Go、Ruby。 * **CLI 工具:** `agent vm create`、`agent vm exec`、`agent vm temp` 用于虚拟机管理和代码执行。 * **云部署:** 可选择作为 Cloudflare Worker 部署。 **配置:** 重要的环境变量包括 `AGENT_STATE_DIR`(用于虚拟机数据)和 `AGENT_LOG_LEVEL` 用于日志控制。 详细的平台特定说明和示例可在 `era-agent/README.md` 中找到。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN: Era – 开源本地 AI 代理沙箱 (github.com/binsquare) 5 分,由 gregTurri 1 小时前发布 | 隐藏 | 过去 | 收藏 | 讨论 刚刚看了 ThePrimeagen (https://www.youtube.com/watch?v=efwDZw7l2Nk) 的视频,关于攻击者越狱 Claude 以运行网络攻击。核心问题:AI 代理需要隔离。我们构建 ERA 来解决这个问题 – 基于本地微型 VM 的沙箱,为 AI 生成的代码提供硬件级安全。可以把它想象成容器,但更安全。在 ERA 中运行,此类攻击不会影响你的主机。 GitHub: https://github.com/BinSquare/ERA 快速上手: https://github.com/BinSquare/ERA/tree/main/era-agent/tutoria... 期待你的想法和反馈! 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索:
相关文章

原文

Run untrusted or AI-generated code locally inside microVMs that behave like containers for great devX, 200ms launch time, and better security.

There's a fully managed cloud layer, globally deployed Worker/API, jump to cloudflare/README.md.

Publish Release

option 1: homebrew (recommended)

# 1. install the tap
brew tap binsquare/era-agent-cli

# 2. install era agent
brew install binsquare/era-agent-cli/era-agent

# 3. install dependencies
brew install krunvm buildah

# 4. verify the CLI is on PATH
agent vm exec --help

# 4. follow platform-specific setup (see below)
# 1. install dependencies
brew install krunvm buildah  # on macos

# 2. clone the repository
git clone https://github.com/binsquare/era
cd era-agent

# 3. build the agent
make

# 4. follow platform-specific setup (see below)
brew tap binsquare/era-agent-cli
brew install era-agent-cli
brew install krunvm buildah

Run the post-install helper to prepare the case-sensitive volume/state dir on macOS:

$(brew --prefix era-agent)/libexec/setup/setup.sh

homebrew installation setup

if you installed era agent via homebrew, use the setup script from the installed location:

# for macos users with homebrew installation
$(brew --prefix era-agent)/libexec/setup/setup.sh

# or run the setup script directly after installation
$(brew --prefix)/bin/era-agent-setup  # if setup script is linked separately
  • Run scripts/macos/setup.sh to bootstrap dependencies, validate (or create) a case-sensitive volume, and prepare an agent state directory (the script may prompt for your password to run diskutil). The script will also detect your Homebrew installation and recommend the correct value for the DYLD_LIBRARY_PATH environment variable, which may be required for krunvm to find its dynamic libraries.

  • If you prefer to create the dedicated volume manually, open a separate terminal and run (with sudo as required):

    diskutil apfs addVolume disk3 "Case-sensitive APFS" krunvm
    

    (replace disk3 with the identifier reported by diskutil list). The operation is non-destructive, does not require sudo, and shares space with the source container volume.

  • When prompted by the setup script, accept the default mount point (/Volumes/krunvm) or provide your own. Afterwards, export the environment variables printed by the script (at minimum AGENT_STATE_DIR, KRUNVM_DATA_DIR, and CONTAINERS_STORAGE_CONF) before invoking agent or running krunvm/buildah directly. The helper now prepares a matching container-storage configuration under the case-sensitive volume so the CLI can run without extra manual steps.

    • The script also writes policy.json/registries.conf under the same directory so Buildah doesn't look for root-owned files in /etc/containers. Export the variables it prints (CONTAINERS_POLICY, CONTAINERS_REGISTRIES_CONF) if you invoke Buildah manually.
  • Install krunvm and buildah using your package manager (the specific installation method may vary)
  • Ensure the system is properly configured to run microVMs (may require kernel modules or specific privileges)
  • Consider setting AGENT_STATE_DIR to a writable location if running as non-root
  • krunvm must be installed and available on $PATH (Homebrew: brew install krunvm; see upstream docs for other platforms).
  • buildah must also be present because krunvm shells out to it for OCI image handling.
  • On macOS, krunvm requires a case-sensitive APFS volume; see the macOS setup notes above.
make          # builds the agent CLI
make clean    # removes build artifacts (Go cache)

Full platform-specific steps (macOS volume setup, Linux env vars, troubleshooting) live in era-agent/README.md.

Demo Video

A demo video showing how to install and use the CLI tool is available in the era-agent directory. This video covers:

  • Installing dependencies and compiling the CLI tool
  • Creating and accessing local VMs
  • Running code and agents through commands or scripts
  • Uploading and downloading files to/from a VM
# create a long-running VM
agent vm create --language python --cpu 1 --mem 256 --network allow_all

# run something inside it
agent vm exec --vm <id> --cmd "python -c 'print(\"hi\")'"

# ephemeral one-off execution
agent vm temp --language javascript --cmd "node -e 'console.log(42)'"

# inspect / cleanup
agent vm list
agent vm stop --all
agent vm clean --all

Supported --language values: python, javascript/node/typescript, go, ruby. Override the base image with --image if you need a custom runtime.

⚙ Configuration Highlights

  • AGENT_STATE_DIR: writable directory for VM metadata, krunvm state, and Buildah storage. The macOS setup script prints the correct exports.
  • AGENT_LOG_LEVEL (debug|info|warn|error) and AGENT_LOG_FILE: control logging.
  • AGENT_ENABLE_GUEST_VOLUMES=1: re-enable /in, /out, /persist mounts for advanced workflows.

See era-agent/README.md for every tunable.

cd era-agent
make agent
./agent vm temp --language python --cmd "python -c 'print(\"Smoke test\")'"

Integration helpers and sample recipes live under examples/, recipes/, and docs/.

To deploy ERA as a Cloudflare Worker with Durable Object-backed sessions and HTTP APIs:

  • Follow cloudflare/README.md for setup, local Wrangler dev, and deployment.
  • The Worker reuses the same Go agent primitives but adds session orchestration, package caching, and REST endpoints.

Apache 2.0

联系我们 contact @ memedata.com