Skip to content

feat(isolator): 新增 Forge microVM 隔離器#8

Open
eouzoe wants to merge 2 commits intoDeepractice:mainfrom
eouzoe:feat/forge-isolator
Open

feat(isolator): 新增 Forge microVM 隔離器#8
eouzoe wants to merge 2 commits intoDeepractice:mainfrom
eouzoe:feat/forge-isolator

Conversation

@eouzoe
Copy link

@eouzoe eouzoe commented Feb 21, 2026

概述

新增 ForgeIsolator,填補 IsolatorTypee2b 的空缺。

Forge 是一個自託管的 Rust/Axum gateway,透過 HTTP 橋接到 Firecracker microVM,提供確定性執行環境。與 e2b 不同,Forge 零外部依賴、零 API 費用。

改動

  • 新增 packages/core/src/isolators/ForgeIsolator.ts(172 行)
  • IsolatorType 加入 "forge"
  • Sandbox.tsindex.ts 加入 export
  • 3 個 unit tests(bun:test)
  • changeset(@sandboxxjs/core minor bump)

使用方式

import { createSandbox } from "sandboxxjs";

const sandbox = createSandbox({ isolator: "forge", runtime: "node" });
const result = await sandbox.shell("echo hello");
// { success: true, stdout: "hello\n", stderr: "", exitCode: 0, executionTime: 42 }
await sandbox.destroy();

需要先啟動 forge-gateway(預設 http://127.0.0.1:3456)。

技術細節

ForgeIsolator 實作 Isolator 的 6 個方法,內部全部是 HTTP call:

  • POST /v1/sandbox → 建立 sandbox
  • POST /v1/sandbox/:id/shell → 執行命令
  • POST /v1/sandbox/:id/execute → 執行代碼
  • DELETE /v1/sandbox/:id → 銷毀

使用原生 fetch,不引入額外依賴。錯誤處理沿用 ExecutionError / FileSystemError

後續計劃

  • Firecracker rootfs 預建映像(node:20, python:3.12)
  • 與 e2b 的 benchmark 對比
  • gateway 文檔

相關專案

  • forge — Rust gateway + Firecracker executor

HTTP bridge to forge-gateway (Rust/Axum) for deterministic execution
in Firecracker microVMs. Zero external dependency — self-hosted.
Implements all 6 Isolator methods via REST API.
Add .changeset/forge-isolator.md marking @sandboxxjs/core as minor bump.
Add ForgeIsolator.test.ts with three bun:test cases covering default
gatewayUrl, no-op destroy, and ExecutionError on gateway failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant