Skip to content

Commit ef040c5

Browse files
committed
feat(boxlite): use official node sdk locally
1 parent 1d3e211 commit ef040c5

15 files changed

Lines changed: 696 additions & 1443 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
1616

1717
### Changed
1818
- README terminal capability updated from ❌ to ✅ for all providers (ttyd-based implementation)
19+
- `@sandbank.dev/boxlite` local mode now uses the official `@boxlite-ai/boxlite` Node.js SDK instead of the Python bridge
1920

2021
## [0.1.0] - 2026-02-27
2122

docs/boxlite-troubleshooting.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
BoxLite 是一个嵌入式微虚拟机运行时,使用 libkrun(基于 KVM/Hypervisor.framework)在硬件隔离的 VM 中运行 OCI 容器。BoxRun 是其 CLI 管理层,提供 REST API。
44

5+
> 当前 Sandbank JS SDK 的 local 模式使用官方 `@boxlite-ai/boxlite` Node.js SDK。本文中关于 `boxlite` Python 库和 BoxRun v0.3.0 的内容主要是历史排障背景,用于理解旧版本兼容性问题。
6+
57
## 平台支持
68

79
| 平台 | 状态 | 虚拟化后端 |
@@ -14,7 +16,18 @@ BoxLite 是一个嵌入式微虚拟机运行时,使用 libkrun(基于 KVM/Hy
1416

1517
## 安装
1618

17-
### BoxLite Python 库
19+
### BoxLite Node.js SDK
20+
21+
Sandbank 的 `@sandbank.dev/boxlite` local 模式会通过 `@boxlite-ai/boxlite` 直接调用官方 Node.js SDK,不需要再配置 Python venv:
22+
23+
```typescript
24+
new BoxLiteAdapter({
25+
mode: 'local',
26+
boxliteHome: '~/.boxlite',
27+
})
28+
```
29+
30+
### BoxLite Python 库(历史排障)
1831

1932
```bash
2033
# 需要 Python 3.10+
@@ -108,7 +121,7 @@ EOF
108121
chmod +x ~/.boxrun/runtime/boxlite-shim
109122
```
110123

111-
**解决方案(macOS):** BoxRun v0.3.0 在 macOS 上还有额外问题(jailer 被禁用),wrapper shim 不够。建议直接使用 boxlite Python
124+
**解决方案(macOS):** BoxRun v0.3.0 在 macOS 上还有额外问题(jailer 被禁用),wrapper shim 不够。当前 JS SDK 建议使用 `@sandbank.dev/boxlite` local 模式;旧版排障也可以直接使用 boxlite Python 库验证底层 runtime
112125

113126
```python
114127
import boxlite, asyncio
@@ -136,7 +149,7 @@ BoxRun v0.3.0 在 macOS 上不启用 seatbelt sandbox,而 boxlite v0.6.0 需
136149
| Guest rootfs | 直接引用 image disk | Reflink + version key 管理 |
137150
| 结果 | ❌ Timeout | ✅ 正常启动 |
138151

139-
**解决方案:** 在 macOS 上使用 boxlite Python 库而非 BoxRun。
152+
**解决方案:** 在 macOS 上使用官方 SDK(Sandbank JS local 模式或 Python 库)而非旧 BoxRun。
140153

141154
#### 1c. Hypervisor entitlement 缺失
142155

@@ -396,10 +409,11 @@ log stream --predicate 'eventMessage CONTAINS "Sandbox:" AND eventMessage CONTAI
396409

397410
## 版本兼容性矩阵
398411

399-
| BoxRun | boxlite (Python) | boxlite-shim | DB Schema | 兼容性 |
400-
|--------|------------------|--------------|-----------|--------|
412+
| BoxRun | SDK | boxlite-shim | DB Schema | 兼容性 |
413+
|--------|-----|--------------|-----------|--------|
401414
| v0.3.0 || v0.5.10 | v4 | ✅ (Linux/WSL2 only) |
402-
| v0.3.0 | v0.6.0 | v0.6.0 | v4 vs v6 ❌ | ❌ 不兼容 |
403-
|| v0.6.0 | v0.6.0 | v6 | ✅ (Python 直接使用) |
415+
| v0.3.0 | Python v0.6.0 | v0.6.0 | v4 vs v6 ❌ | ❌ 不兼容 |
416+
|| Python v0.6.0 | v0.6.0 | v6 | ✅ (Python 直接使用) |
417+
|| Node.js `@boxlite-ai/boxlite` v0.9.7 | v0.9.7 | current | ✅ (Sandbank JS local mode) |
404418

405-
**建议:** 在 BoxRun 更新到兼容 v0.6.0 之前,macOS 上优先使用 boxlite Python 库直接操作 VM
419+
**建议:** Sandbank JS SDK 优先使用 local Node.js SDK 路径;只有在排查旧 BoxRun 或 Python 调用方时才使用 Python 库

docs/sandbank-agent-configuration.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ await runWorkspaceSandboxTask({
182182
| Fly.io | `FLY_API_TOKEN``FLY_APP_NAME`。任意で `FLY_REGION` |
183183
| Cloudflare | `env.SANDBOX` などの Worker Durable Object binding。volume には任意の storage config |
184184
| BoxLite remote | `BOXLITE_API_URL` と、`BOXLITE_API_TOKEN` または OAuth2 client credentials |
185-
| BoxLite local | ローカルの `boxlite` Python package。任意で `pythonPath` `boxliteHome` |
185+
| BoxLite local | 公式 `@boxlite-ai/boxlite` Node.js SDK。任意で `boxliteHome` |
186186
| E2B | `E2B_API_KEY`。論理イメージは E2B template にマップされます |
187187

188188
## イメージ要件

docs/sandbank-agent-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ await runWorkspaceSandboxTask({
182182
| Fly.io | `FLY_API_TOKEN`, `FLY_APP_NAME`; optional `FLY_REGION` |
183183
| Cloudflare | Worker Durable Object binding such as `env.SANDBOX`; optional storage config for volumes |
184184
| BoxLite remote | `BOXLITE_API_URL` plus `BOXLITE_API_TOKEN` or OAuth2 client credentials |
185-
| BoxLite local | local `boxlite` Python package; optional `pythonPath` and `boxliteHome` |
185+
| BoxLite local | official `@boxlite-ai/boxlite` Node.js SDK; optional `boxliteHome` |
186186
| E2B | `E2B_API_KEY`; logical images map to E2B templates |
187187

188188
## Image Requirements

docs/sandbank-agent-configuration.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ await runWorkspaceSandboxTask({
182182
| Fly.io | `FLY_API_TOKEN``FLY_APP_NAME`;可选 `FLY_REGION` |
183183
| Cloudflare | Worker Durable Object binding,例如 `env.SANDBOX`;volume 需要可选 storage config |
184184
| BoxLite remote | `BOXLITE_API_URL`,以及 `BOXLITE_API_TOKEN` 或 OAuth2 client credentials |
185-
| BoxLite local | 本机 `boxlite` Python package;可选 `pythonPath` `boxliteHome` |
185+
| BoxLite local | 官方 `@boxlite-ai/boxlite` Node.js SDK;可选 `boxliteHome` |
186186
| E2B | `E2B_API_KEY`;逻辑镜像映射到 E2B template |
187187

188188
## 镜像要求

packages/boxlite/README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@
55
BoxLite provides lightweight micro-VMs using libkrun (Hypervisor.framework on macOS, KVM on Linux). This adapter supports two modes of operation:
66

77
- **Remote mode** — Connect to a [BoxRun](https://github.com/nicholasgasior/boxlite) REST API server
8-
- **Local mode** — Run VMs directly on the local machine via the boxlite Python SDK
8+
- **Local mode** — Run VMs directly on the local machine via the official BoxLite Node.js SDK
99

1010
## Install
1111

1212
```bash
1313
pnpm add @sandbank.dev/core @sandbank.dev/boxlite
1414
```
1515

16-
For local mode, you also need the boxlite Python package:
17-
18-
```bash
19-
pip install boxlite
20-
```
21-
2216
## Usage
2317

2418
### Remote mode (BoxRun REST API)
@@ -44,7 +38,7 @@ const { stdout } = await sandbox.exec('uname -a')
4438
await provider.destroy(sandbox.id)
4539
```
4640

47-
### Local mode (Python SDK)
41+
### Local mode (Node.js SDK)
4842

4943
```typescript
5044
import { createProvider } from '@sandbank.dev/core'
@@ -53,8 +47,7 @@ import { BoxLiteAdapter } from '@sandbank.dev/boxlite'
5347
const provider = createProvider(
5448
new BoxLiteAdapter({
5549
mode: 'local',
56-
pythonPath: '/usr/bin/python3', // optional, defaults to 'python3'
57-
boxliteHome: '~/.boxlite', // optional
50+
boxliteHome: '~/.boxlite', // optional
5851
})
5952
)
6053

@@ -90,15 +83,15 @@ new BoxLiteAdapter({
9083
| `terminal` |||
9184
| `sleep` |||
9285
| `port.expose` |||
93-
| `snapshot` || |
86+
| `snapshot` || |
9487

9588
## Characteristics
9689

9790
- **Runtime:** Micro-VM (libkrun)
9891
- **Cold start:** ~3-5s
9992
- **File I/O:** tar archive upload/download
10093
- **Hypervisor:** Hypervisor.framework (macOS) / KVM (Linux)
101-
- **Local dependency:** `boxlite` Python package (local mode only)
94+
- **Local dependency:** official `@boxlite-ai/boxlite` Node.js SDK (local mode only)
10295

10396
## Architecture
10497

@@ -108,10 +101,10 @@ new BoxLiteAdapter({
108101
│ mode: 'remote' | 'local' │
109102
├──────────────┬──────────────────────┤
110103
│ REST Client │ Local Client │
111-
│ (fetch) │ (Python subprocess)
104+
│ (fetch) │ (Node.js SDK)
112105
├──────────────┼──────────────────────┤
113-
│ BoxRun API │ boxlite Python SDK
114-
│ (HTTP/JSON) │ (JSON-line bridge)
106+
│ BoxRun API │ @boxlite-ai/boxlite
107+
│ (HTTP/JSON) │ (N-API binding)
115108
└──────────────┴──────────────────────┘
116109
```
117110

packages/boxlite/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sandbank.dev/boxlite",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "BoxLite bare-metal sandbox adapter for Sandbank",
55
"license": "MIT",
66
"type": "module",
@@ -32,6 +32,7 @@
3232
"clean": "rm -rf dist"
3333
},
3434
"dependencies": {
35+
"@boxlite-ai/boxlite": "^0.9.7",
3536
"@sandbank.dev/core": "workspace:*"
3637
},
3738
"devDependencies": {

packages/boxlite/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @sandbank.dev/boxlite — BoxLite sandbox adapter (remote REST API + local Python SDK)
1+
// @sandbank.dev/boxlite — BoxLite sandbox adapter (remote REST API + local Node.js SDK)
22
export { BoxLiteAdapter } from './adapter.js'
33
export type {
44
BoxLiteAdapterConfig,

0 commit comments

Comments
 (0)