Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
885cdbd
docs(design): add Electron + Rust daemon architecture design
May 29, 2026
3ac5815
docs(design): update comms protocol (WS+RPC), port discovery, remove …
May 29, 2026
0533568
docs(plan): add Phase 1 implementation plan for Electron+Rust daemon
May 29, 2026
f9e59da
feat(daemon): scaffold sandbox-daemon binary crate
May 29, 2026
544ba5f
fix(daemon): remove unused deps, use tracing for startup message
May 29, 2026
d4a76c4
feat(daemon): implement daemon lifecycle and multi-sandbox HTTP API
May 29, 2026
48f0457
fix(daemon): dedupe request types, scope input handlers to sandbox
May 29, 2026
04ad905
feat(cli): refactor to use daemon HTTP API for all commands
May 29, 2026
ce5464d
fix(cli): address code review issues — fmt, clippy, daemon API coverage
May 29, 2026
a099a10
chore: add daemon RPATH, mark legacy server deprecated
May 29, 2026
3e0109b
fix(release): replace broad pkill -f with PID-based cleanup
May 30, 2026
b6e1fbc
feat(daemon): add PTY write endpoint and daemon binary to release
May 30, 2026
87282ea
fix(cli): honor --pty flag in daemon mode for type and key commands
May 30, 2026
0665445
fix(release): re-sign binaries after cp to fix macOS code signing cache
May 30, 2026
0def920
docs(plan): add Phase 2 Electron shell implementation plan
May 30, 2026
93c457a
feat(electron): scaffold electron-app with electron-vite
May 30, 2026
523a0c8
feat(electron): single-instance lock + spawn sandbox-daemon
May 30, 2026
d001644
feat(electron): tab manager with WebContentsView + off-screen positio…
May 30, 2026
43c4bbc
feat(electron): renderer with xterm.js terminal using standard term.w…
May 30, 2026
2d2a6c5
feat(cli): spawn Electron app when running sandbox start
May 30, 2026
a713b63
feat(electron): auto-create tabs from daemon sandbox list on second-i…
May 30, 2026
eb47ea2
fix(electron): write electron.json for CLI discovery and clean up on …
May 30, 2026
be4cbf9
update release_test.md
May 30, 2026
6aed2b1
feat(release): replace Tauri with Electron in release build
May 31, 2026
458fabb
fix(cli): correct Electron binary path (System Test Sandbox, not syst…
May 31, 2026
a34fe63
feat(ui): macOS-native Electron UI with dark/light mode
May 31, 2026
eb66841
feat(daemon): add UI inspection HTTP endpoints
May 31, 2026
c4d8825
feat(cli): add ui-inspect, ui-find, ui-value commands
May 31, 2026
49e5f85
feat(core): add recorder, player, and screenshot diff modules
May 31, 2026
17d4c8c
feat(cli): add diff command and record/playback stubs
May 31, 2026
8f0ba1c
test(core): add screenshot diff unit tests
May 31, 2026
09bce60
feat(daemon): multi-instance hardening
May 31, 2026
ca64c42
feat(renderer): new sandbox dialog + APP mode panel
May 31, 2026
4958c36
feat(cli): add MCP stdio server with sandbox management tools
May 31, 2026
ac0808c
test(core): add daemon HTTP integration tests
May 31, 2026
5d02d0e
docs: update architecture for Electron + daemon model
May 31, 2026
9cfd0df
fix(daemon): auto-discover Electron window_id for screenshots
May 31, 2026
fa324f5
fix(daemon): spawn_app_handler tracks app window_id
May 31, 2026
a8837d0
fix(daemon): add sandbox screenshot region endpoint
May 31, 2026
26876fe
fix(process): use session liveness check instead of OS PID for cleanup
May 31, 2026
e3bae48
chore: remove Tauri code, migrate to Electron + daemon architecture
May 31, 2026
66959c2
fix(ci): resolve clippy warnings and update frontend test paths
May 31, 2026
bfa07a0
test(electron): add vitest setup with API unit tests
May 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,20 @@ jobs:
version: "10"

- name: 安装依赖
working-directory: sandbox-web
working-directory: electron-app
run: pnpm install --frozen-lockfile

- name: TypeScript 类型检查
working-directory: sandbox-web
working-directory: electron-app
run: pnpm typecheck

- name: 运行前端测试 + 覆盖率
working-directory: sandbox-web
working-directory: electron-app
run: pnpm vitest run --coverage --coverage.reporter=json-summary --coverage.reporter=text

- name: 生成前端覆盖率摘要
if: always()
working-directory: sandbox-web
working-directory: electron-app
run: |
SUMMARY_FILE="frontend-coverage-summary.md"
echo "## 前端测试覆盖率" > "$SUMMARY_FILE"
Expand Down Expand Up @@ -260,15 +260,15 @@ jobs:
if: always()
with:
name: frontend-coverage-summary
path: sandbox-web/frontend-coverage-summary.md
path: electron-app/frontend-coverage-summary.md
retention-days: 1

- name: 上传前端覆盖率报告
uses: actions/upload-artifact@v4
if: always()
with:
name: frontend-coverage
path: sandbox-web/coverage/
path: electron-app/coverage/
retention-days: 14

# ==================== 安全检查 ====================
Expand Down
65 changes: 18 additions & 47 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,33 @@
>
> 对目标应用**零侵入**,所有操作在 OS 层面完成(CGEvent + AXUIElement + ScreenCaptureKit)。
>
> **多实例架构**:每个沙箱是一个独立的 Tauri 窗口进程,拥有唯一 ID、内嵌 HTTP API 服务器,通过文件系统注册中心(`~/.sandbox/instances/`)进行实例发现和管理
> **Daemon + Electron 架构**:一个长驻 Rust daemon 管理所有沙箱实例(PTY 进程 + macOS 应用),通过单一 HTTP API 对外服务。Electron 应用作为 GUI 前端,提供 tab 管理、xterm.js 终端和截图预览。CLI 直接与 daemon 通信

## 一、架构总览

```
┌──────────────────────────────────────────────────────────────┐
│ Agent / 用户 (CLI / MCP / HTTP) │
│ │
│ sandbox start → 返回 sandbox-id │
│ sandbox list → 列出所有实例 │
│ sandbox screenshot <id> → 截取沙箱截图 │
│ sandbox click <id> 100 200 → 模拟点击 │
│ sandbox close <id> → 关闭沙箱 │
└──────────────────────┬───────────────────────────────────────┘
│ CLI (子进程启动) / MCP stdio / HTTP
│ sandbox start / list / screenshot / click / type / key │
└───────────────────────────────┬───────────────────────────────┘
│ HTTP (localhost:15801)
┌──────────────────────────────────────────────────────────────┐
│ 沙箱实例注册中心 (~/.sandbox/instances/) │
│ │
│ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ Sandbox Instance #1 │ │ Sandbox Instance #2 │ ... │
│ │ id: abc123 │ │ id: def456 │ │
│ │ port: 15801 │ │ port: 15802 │ │
│ │ mode: cli (claude) │ │ mode: app (cc-switch)│ │
│ │ status: Running │ │ status: Running │ │
│ └─────────┬───────────┘ └─────────┬───────────┘ │
│ │ │ │
│ │ HTTP :15801 │ HTTP :15802 │
└────────────┼─────────────────────────┼────────────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Tauri Window #1 │ │ Tauri Window #2 │
│ "System Test │ │ "System Test │
│ Sandbox [abc]" │ │ Sandbox [def]" │
│ │ │ │
│ ┌────────────┐ │ │ ┌────────────┐ │
│ │ xterm.js │ │ │ │ App 关联 │ │
│ │ (claude) │ │ │ │ (cc-switch)│ │
│ └────────────┘ │ │ └────────────┘ │
│ │ │ │
│ 内嵌 HTTP API │ │ 内嵌 HTTP API │
│ + Automation │ │ + Automation │
│ Engine │ │ Engine │
└──────────────────┘ └──────────────────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────────┐
│ CLI 进程 │ │ macOS .app │
│ (PTY) │ │ (NSWorkspace) │
└─────────────┘ └─────────────────┘
│ sandbox-daemon (Rust, 单实例) │
│ PTY Manager + App Manager + Automation Engine │
│ Instance Registry (~/.sandbox/instances/) │
└───────────────────────────────┬───────────────────────────────┘
│ WebSocket (PTY 流)
┌──────────────────────────────────────────────────────────────┐
│ Electron App (单实例, Chromium) │
│ Tab 管理 + xterm.js + 控制面板 + 截图预览 │
└──────────────────────────────────────────────────────────────┘
```

**设计原则**:
1. **零侵入**:目标应用不需要任何适配,所有操作在 OS 层面完成
2. **多实例**:每个沙箱是独立的 Tauri 窗口进程,通过 CLI 管理生命周期
2. **单 daemon 多沙箱**:一个 daemon 进程管理所有沙箱实例,通过 CLI 管理生命周期
3. **窗口级截图**:ScreenCaptureKit 按窗口 ID 截图,不需要窗口在前台
4. **双协议**:MCP (Agent CLI 原生) + HTTP (通用调用)
5. **文件系统注册中心**:沙箱实例通过 `~/.sandbox/instances/<id>.json` 注册和发现
Expand All @@ -72,8 +43,8 @@
|---------|--------|
| 核心库 | Rust (Edition 2021, >=1.88), `sandbox-core` library crate |
| CLI | Rust, `sandbox-cli` binary crate |
| 桌面框架 | Tauri 2.x |
| 桌面前端 | React 18 + TS + Vite + TailwindCSS + xterm.js |
| 桌面框架 | Electron (Chromium) |
| 桌面前端 | React 18 + TS + Vite + xterm.js |
| 异步运行时 | tokio |
| macOS API | CoreGraphics (CGEvent), ApplicationServices (AXUIElement), ScreenCaptureKit |
| 包管理 | Cargo Workspace + pnpm |
Expand Down
Loading
Loading