ai-cli-online 2.9.9 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -76
- package/README.zh-CN.md +157 -72
- package/package.json +1 -1
- package/server/dist/index.js +27 -552
- package/server/dist/middleware/auth.d.ts +9 -0
- package/server/dist/middleware/auth.js +39 -0
- package/server/dist/routes/editor.d.ts +2 -0
- package/server/dist/routes/editor.js +94 -0
- package/server/dist/routes/files.d.ts +2 -0
- package/server/dist/routes/files.js +312 -0
- package/server/dist/routes/sessions.d.ts +2 -0
- package/server/dist/routes/sessions.js +64 -0
- package/server/dist/routes/settings.d.ts +2 -0
- package/server/dist/routes/settings.js +72 -0
- package/server/package.json +1 -1
- package/shared/package.json +1 -1
- package/web/dist/assets/index-D2zgyu4q.js +32 -0
- package/web/dist/index.html +1 -1
- package/web/package.json +1 -1
- package/web/dist/assets/index-DjhdaelF.js +0 -32
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
An AI-powered development environment that runs in your browser. Persistent terminal sessions, structured task lifecycle, and autonomous execution — all through a single Node.js process.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Built for running Claude Code, Codex, or any AI coding agent over unstable networks. tmux keeps everything alive when connections drop; the browser UI provides planning, annotation, and chat panels alongside the terminal.
|
|
10
10
|
|
|
11
11
|
**npm:** https://www.npmjs.com/package/ai-cli-online | **GitHub:** https://github.com/huacheng/ai-cli-online
|
|
12
12
|
|
|
@@ -14,49 +14,110 @@ Ideal for **unstable networks** where SSH drops frequently, or as a **local stat
|
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## What It Does
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
**Terminal + Planning + Execution in one screen:**
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
┌─ Tabs ──────────────────────────────────────────────────────┐
|
|
23
|
+
│ ┌─ Plan Panel ──────┬─ Terminal ────────────────────────┐ │
|
|
24
|
+
│ │ AiTasks/ browser │ │ │
|
|
25
|
+
│ │ Markdown viewer │ $ /ai-cli-task auto my-feature │ │
|
|
26
|
+
│ │ Inline annotations │ ▶ planning... │ │
|
|
27
|
+
│ │ (insert/delete/ │ ▶ check(post-plan): PASS │ │
|
|
28
|
+
│ │ replace/comment) │ ▶ executing step 1/4... │ │
|
|
29
|
+
│ │ │ ▶ executing step 2/4... │ │
|
|
30
|
+
│ │ Mermaid diagrams │ ... │ │
|
|
31
|
+
│ │ ├───────────────────────────────────┤ │
|
|
32
|
+
│ │ │ Chat Editor │ │
|
|
33
|
+
│ │ │ Multi-line Markdown + /commands │ │
|
|
34
|
+
│ └────────────────────┴───────────────────────────────────┘ │
|
|
35
|
+
└──────────────────────────────────────────────────────────────┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **Plan Panel** — browse `AiTasks/` files, annotate documents with 4 annotation types, send structured feedback to AI
|
|
39
|
+
- **Terminal** — full xterm.js with WebGL rendering, binary protocol for ultra-low latency
|
|
40
|
+
- **Chat Editor** — multi-line Markdown editor with slash commands, server-side draft persistence
|
|
41
|
+
- All three panels can be open simultaneously, each independently resizable
|
|
42
|
+
|
|
43
|
+
## AI Task Lifecycle
|
|
44
|
+
|
|
45
|
+
The `ai-cli-task` plugin provides an 8-skill lifecycle for structured AI task execution:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
init → plan → check → exec → check → merge → report
|
|
49
|
+
↑ ↓
|
|
50
|
+
re-plan ←──┘ (on issues)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Skill | What it does |
|
|
54
|
+
|-------|-------------|
|
|
55
|
+
| **init** | Create task module (`AiTasks/<name>/`), git branch, optional worktree |
|
|
56
|
+
| **plan** | Generate implementation plan or process human annotations |
|
|
57
|
+
| **check** | Evaluate feasibility at 3 checkpoints (post-plan / mid-exec / post-exec) |
|
|
58
|
+
| **exec** | Execute plan steps with per-step verification |
|
|
59
|
+
| **merge** | Merge task branch to main with conflict resolution (up to 3 retries) |
|
|
60
|
+
| **report** | Generate completion report, distill lessons to experience database |
|
|
61
|
+
| **auto** | Run the full lifecycle autonomously in a single Claude session |
|
|
62
|
+
| **cancel** | Stop execution, set status to cancelled, optional cleanup |
|
|
63
|
+
|
|
64
|
+
### Auto Mode
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
/ai-cli-task auto my-feature
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
One command triggers the entire lifecycle. A single Claude session runs plan → check → exec → merge → report internally, sharing context across all steps. A daemon monitors progress via `.auto-signal` files, enforces timeouts, and detects stalls.
|
|
71
|
+
|
|
72
|
+
### Task Structure
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
AiTasks/
|
|
76
|
+
├── .index.md # Module listing
|
|
77
|
+
├── .experience/ # Cross-task knowledge base (by domain type)
|
|
78
|
+
│ ├── software.md
|
|
79
|
+
│ └── <type>.md
|
|
80
|
+
└── my-feature/
|
|
81
|
+
├── .index.md # Status, phase, timestamps, dependencies (YAML)
|
|
82
|
+
├── .target.md # Requirements (human-authored)
|
|
83
|
+
├── .summary.md # Condensed context (prevents context overflow)
|
|
84
|
+
├── .analysis/ # Evaluation history
|
|
85
|
+
├── .test/ # Test criteria & results
|
|
86
|
+
├── .bugfix/ # Issue history
|
|
87
|
+
├── .notes/ # Research findings
|
|
88
|
+
├── .report.md # Completion report
|
|
89
|
+
└── plan.md # Implementation plan
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Type-Aware Execution
|
|
93
|
+
|
|
94
|
+
Tasks are classified by domain type (`software`, `dsp`, `ml`, `literary`, `science:physics`, etc.). Each type adapts planning methodology, execution tools, and verification criteria. Completed task lessons are stored in `.experience/<type>.md` and referenced by future tasks of the same type.
|
|
95
|
+
|
|
96
|
+
## Terminal Features
|
|
97
|
+
|
|
98
|
+
- **Session Persistence** — tmux keeps processes alive through disconnects; fixed socket path ensures auto-reconnect after server restarts
|
|
99
|
+
- **Multi-Tab** — independent terminal groups with layout persistence across refreshes
|
|
22
100
|
- **Split Panes** — horizontal / vertical splits, arbitrarily nested
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **File Transfer** — upload files
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
| **Core Use Case** | Browser-based remote terminal access | Multi-channel AI assistant |
|
|
44
|
-
| **Terminal Emulation** | xterm.js + WebGL | None |
|
|
45
|
-
| **Session Persistence** | tmux (survives disconnects) | Gateway in-memory state |
|
|
46
|
-
| **Multi-Tab / Split** | Tabs + arbitrarily nested panes | None |
|
|
47
|
-
| **Message Channels** | WebSocket (single channel) | 16+ (WhatsApp / Telegram / Slack / Discord...) |
|
|
48
|
-
| **Native Apps** | None (pure web) | macOS + iOS + Android |
|
|
49
|
-
| **Voice Interaction** | None | Voice Wake + Talk Mode |
|
|
50
|
-
| **AI Agent** | None built-in (run any CLI) | Pi Agent runtime + multi-agent routing |
|
|
51
|
-
| **Canvas / UI** | Plan annotations (Markdown) | A2UI real-time visual workspace |
|
|
52
|
-
| **File Transfer** | REST API upload / download | Channel-native media |
|
|
53
|
-
| **Security Model** | Token auth + timing-safe | Device pairing + DM policy + Docker sandbox |
|
|
54
|
-
| **Extensibility** | Shell scripts | 33 extensions + 60+ skills + ClawHub |
|
|
55
|
-
| **Transport** | Binary frames (ultra-low latency) | JSON WebSocket |
|
|
56
|
-
| **Deployment** | Single-node Node.js | Single-node + Tailscale Serve/Funnel |
|
|
57
|
-
| **Tech Stack** | React + Express + node-pty | Lit + Express + Pi Agent |
|
|
58
|
-
| **Package Size** | ~1 MB | ~300 MB+ |
|
|
59
|
-
| **Install** | `npx ai-cli-online` | `npm i -g openclaw && openclaw onboard` |
|
|
101
|
+
- **Binary Protocol** — 1-byte prefix frames for terminal I/O, TCP Nagle disabled, WebSocket compression
|
|
102
|
+
- **WebGL Rendering** — 3-10x throughput vs canvas
|
|
103
|
+
- **Copy & Paste** — mouse selection auto-copies; right-click pastes
|
|
104
|
+
- **Scroll History** — capture-pane scrollback with ANSI color preservation
|
|
105
|
+
- **File Transfer** — upload/download files, browse directories, download CWD as tar.gz
|
|
106
|
+
- **Network Indicator** — real-time RTT latency with signal bars
|
|
107
|
+
- **Auto Reconnect** — exponential backoff with jitter
|
|
108
|
+
|
|
109
|
+
## Annotation System
|
|
110
|
+
|
|
111
|
+
The Plan panel provides 4 annotation types for structured AI feedback:
|
|
112
|
+
|
|
113
|
+
| Type | Icon | Description |
|
|
114
|
+
|------|------|------------|
|
|
115
|
+
| **Insert** | `+` | Add content at a specific location |
|
|
116
|
+
| **Delete** | `−` | Mark text for removal |
|
|
117
|
+
| **Replace** | `↔` | Substitute old text with new |
|
|
118
|
+
| **Comment** | `?` | Ask questions or leave notes |
|
|
119
|
+
|
|
120
|
+
Annotations are persisted (localStorage + SQLite) and sent to the AI as structured JSON. The `plan` skill processes them — triaging by impact, applying changes, and updating task files.
|
|
60
121
|
|
|
61
122
|
## Quick Start
|
|
62
123
|
|
|
@@ -106,49 +167,64 @@ See `server/.env.example` for all available options.
|
|
|
106
167
|
## Architecture
|
|
107
168
|
|
|
108
169
|
```
|
|
109
|
-
Browser (xterm.js + WebGL)
|
|
170
|
+
Browser (xterm.js + WebGL)
|
|
171
|
+
├── Plan Panel (annotation editor)
|
|
172
|
+
├── Chat Editor (Markdown + /commands)
|
|
173
|
+
└── Terminal View (WebGL renderer)
|
|
174
|
+
│
|
|
175
|
+
↕ WebSocket binary/JSON + REST API
|
|
176
|
+
│
|
|
177
|
+
Express Server (Node.js)
|
|
178
|
+
├── WebSocket ↔ PTY relay
|
|
179
|
+
├── tmux session manager
|
|
180
|
+
├── File transfer API
|
|
181
|
+
├── SQLite (drafts, annotations, settings)
|
|
182
|
+
└── Route modules (sessions, files, editor, settings)
|
|
183
|
+
│
|
|
184
|
+
↕ PTY / tmux sockets
|
|
185
|
+
│
|
|
186
|
+
tmux sessions → shell → Claude Code / AI agents
|
|
187
|
+
└── AiTasks/ lifecycle (init/plan/check/exec/merge/report/auto)
|
|
110
188
|
```
|
|
111
189
|
|
|
112
|
-
- **Frontend**: React + Zustand + xterm.js (WebGL
|
|
190
|
+
- **Frontend**: React + Zustand + xterm.js (WebGL)
|
|
113
191
|
- **Backend**: Node.js + Express + node-pty + WebSocket + better-sqlite3
|
|
114
192
|
- **Session Manager**: tmux (persistent terminal sessions)
|
|
115
|
-
- **Layout
|
|
193
|
+
- **Layout**: Tabs + recursive split tree (LeafNode / SplitNode)
|
|
116
194
|
- **Transport**: Binary frames (hot path) + JSON (control messages)
|
|
117
|
-
- **
|
|
118
|
-
|
|
119
|
-
### Performance
|
|
120
|
-
|
|
121
|
-
- **Binary protocol** — 1-byte prefix frames for terminal I/O, eliminating JSON overhead
|
|
122
|
-
- **TCP Nagle disabled** — `setNoDelay(true)` removes up to 40 ms keystroke delay
|
|
123
|
-
- **WebSocket compression** — `perMessageDeflate` (level 1, threshold 128 B), 50-70% bandwidth reduction
|
|
124
|
-
- **WebGL renderer** — 3-10x rendering throughput vs canvas
|
|
125
|
-
- **Parallel initialization** — PTY creation, tmux config, and resize run concurrently
|
|
126
|
-
- **Smart re-render** — responsive layout hook, conditional Zustand selectors, batched stat calls
|
|
195
|
+
- **Task System**: 8-skill plugin with state machine, dependency gates, and experience database
|
|
127
196
|
|
|
128
197
|
## Project Structure
|
|
129
198
|
|
|
130
199
|
```
|
|
131
200
|
ai-cli-online/
|
|
132
|
-
├── shared/
|
|
133
|
-
├── server/
|
|
134
|
-
│
|
|
135
|
-
│
|
|
136
|
-
│
|
|
137
|
-
│
|
|
138
|
-
│
|
|
139
|
-
│
|
|
140
|
-
│
|
|
141
|
-
│
|
|
142
|
-
│
|
|
143
|
-
├── web/
|
|
144
|
-
│
|
|
145
|
-
│
|
|
146
|
-
│
|
|
147
|
-
│
|
|
148
|
-
│
|
|
149
|
-
│
|
|
150
|
-
├──
|
|
151
|
-
|
|
201
|
+
├── shared/ # Shared type definitions
|
|
202
|
+
├── server/src/
|
|
203
|
+
│ ├── index.ts # Main entry (middleware + routes + server)
|
|
204
|
+
│ ├── websocket.ts # WebSocket ↔ PTY relay (binary + JSON)
|
|
205
|
+
│ ├── tmux.ts # tmux session management
|
|
206
|
+
│ ├── files.ts # File operations + path validation
|
|
207
|
+
│ ├── pty.ts # node-pty wrapper
|
|
208
|
+
│ ├── db.ts # SQLite database
|
|
209
|
+
│ ├── auth.ts # Auth utilities
|
|
210
|
+
│ ├── middleware/ # Auth middleware
|
|
211
|
+
│ └── routes/ # REST API routes (sessions, files, editor, settings)
|
|
212
|
+
├── web/src/
|
|
213
|
+
│ ├── App.tsx # Main app (Login / TabBar / Terminal / Theme)
|
|
214
|
+
│ ├── store/ # Zustand store (modular slices)
|
|
215
|
+
│ ├── components/
|
|
216
|
+
│ │ ├── TerminalPane.tsx # 2D grid layout (Plan + Terminal + Chat)
|
|
217
|
+
│ │ ├── TerminalView.tsx # xterm.js terminal
|
|
218
|
+
│ │ ├── PlanPanel.tsx # Plan annotation panel
|
|
219
|
+
│ │ ├── PlanAnnotationRenderer.tsx # Markdown + inline annotations
|
|
220
|
+
│ │ ├── PlanFileBrowser.tsx # AiTasks/ file browser
|
|
221
|
+
│ │ ├── MarkdownEditor.tsx # Chat editor
|
|
222
|
+
│ │ └── ...
|
|
223
|
+
│ ├── hooks/ # React hooks (WebSocket, file stream, resize, etc.)
|
|
224
|
+
│ └── api/ # Typed API client modules
|
|
225
|
+
├── bin/ # npx entry point
|
|
226
|
+
├── start.sh # Production start script
|
|
227
|
+
└── install-service.sh # systemd + nginx installer
|
|
152
228
|
```
|
|
153
229
|
|
|
154
230
|
## Development
|
|
@@ -177,6 +253,15 @@ The install script will:
|
|
|
177
253
|
2. Detect nginx and optionally configure reverse proxy (WebSocket support, SSL, `client_max_body_size`)
|
|
178
254
|
3. Auto-set `HTTPS_ENABLED=false` and `TRUST_PROXY=1` in `server/.env` when nginx is enabled
|
|
179
255
|
|
|
256
|
+
## Security
|
|
257
|
+
|
|
258
|
+
- Token authentication with timing-safe comparison
|
|
259
|
+
- Symlink traversal protection on all file operations
|
|
260
|
+
- Unauthenticated WebSocket connection limits
|
|
261
|
+
- TOCTOU download guard (streaming size check)
|
|
262
|
+
- CSP headers (frame-ancestors, base-uri, form-action)
|
|
263
|
+
- Rate limiting (configurable read/write thresholds)
|
|
264
|
+
|
|
180
265
|
## License
|
|
181
266
|
|
|
182
267
|
MIT
|
package/README.zh-CN.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
在浏览器中运行的 AI 开发环境。持久化终端会话、结构化任务生命周期、自主执行 — 单个 Node.js 进程即可运行。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
专为在不稳定网络下运行 Claude Code、Codex 或任意 AI 编码代理而构建。tmux 保证断网后进程存活;浏览器 UI 在终端旁提供规划、批注和对话面板。
|
|
10
10
|
|
|
11
11
|
**npm:** https://www.npmjs.com/package/ai-cli-online | **GitHub:** https://github.com/huacheng/ai-cli-online
|
|
12
12
|
|
|
@@ -14,49 +14,110 @@
|
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## 核心能力
|
|
18
|
+
|
|
19
|
+
**终端 + 规划 + 执行,一屏完成:**
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
┌─ 标签页 ────────────────────────────────────────────────────┐
|
|
23
|
+
│ ┌─ Plan 面板 ──────┬─ 终端 ─────────────────────────────┐ │
|
|
24
|
+
│ │ AiTasks/ 文件浏览 │ │ │
|
|
25
|
+
│ │ Markdown 查看器 │ $ /ai-cli-task auto my-feature │ │
|
|
26
|
+
│ │ 内联批注 │ ▶ 规划中... │ │
|
|
27
|
+
│ │ (插入/删除/ │ ▶ 检查(post-plan): 通过 │ │
|
|
28
|
+
│ │ 替换/评注) │ ▶ 执行步骤 1/4... │ │
|
|
29
|
+
│ │ │ ▶ 执行步骤 2/4... │ │
|
|
30
|
+
│ │ Mermaid 图表 │ ... │ │
|
|
31
|
+
│ │ ├────────────────────────────────────┤ │
|
|
32
|
+
│ │ │ Chat 编辑器 │ │
|
|
33
|
+
│ │ │ 多行 Markdown + /命令 │ │
|
|
34
|
+
│ └───────────────────┴────────────────────────────────────┘ │
|
|
35
|
+
└──────────────────────────────────────────────────────────────┘
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **Plan 面板** — 浏览 `AiTasks/` 文件,4 种批注类型标注文档,向 AI 发送结构化反馈
|
|
39
|
+
- **终端** — 完整 xterm.js + WebGL 渲染,二进制协议实现超低延迟
|
|
40
|
+
- **Chat 编辑器** — 多行 Markdown 编辑器,斜杠命令,草稿服务端持久化
|
|
41
|
+
- 三个面板可同时打开,各自独立调整大小
|
|
42
|
+
|
|
43
|
+
## AI 任务生命周期
|
|
44
|
+
|
|
45
|
+
`ai-cli-task` 插件提供 8 个 skill 的完整任务执行生命周期:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
init → plan → check → exec → check → merge → report
|
|
49
|
+
↑ ↓
|
|
50
|
+
re-plan ←──┘ (遇到问题时)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
| Skill | 功能 |
|
|
54
|
+
|-------|------|
|
|
55
|
+
| **init** | 创建任务模块 (`AiTasks/<name>/`),git 分支,可选 worktree |
|
|
56
|
+
| **plan** | 生成实施计划或处理人工批注 |
|
|
57
|
+
| **check** | 在 3 个检查点评估可行性 (post-plan / mid-exec / post-exec) |
|
|
58
|
+
| **exec** | 逐步执行计划,每步验证 |
|
|
59
|
+
| **merge** | 合并任务分支到主干,冲突解决(最多 3 次重试) |
|
|
60
|
+
| **report** | 生成完成报告,提炼经验到知识库 |
|
|
61
|
+
| **auto** | 在单个 Claude 会话中自主运行完整生命周期 |
|
|
62
|
+
| **cancel** | 停止执行,设为已取消,可选清理 |
|
|
63
|
+
|
|
64
|
+
### 自主模式
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
/ai-cli-task auto my-feature
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
一条命令触发完整生命周期。单个 Claude 会话在内部依次运行 plan → check → exec → merge → report,所有步骤共享上下文。守护进程通过 `.auto-signal` 文件监控进度,强制超时,检测停滞。
|
|
71
|
+
|
|
72
|
+
### 任务结构
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
AiTasks/
|
|
76
|
+
├── .index.md # 模块索引
|
|
77
|
+
├── .experience/ # 跨任务知识库(按领域类型分类)
|
|
78
|
+
│ ├── software.md
|
|
79
|
+
│ └── <type>.md
|
|
80
|
+
└── my-feature/
|
|
81
|
+
├── .index.md # 状态、阶段、时间戳、依赖 (YAML)
|
|
82
|
+
├── .target.md # 需求描述(人工编写)
|
|
83
|
+
├── .summary.md # 浓缩上下文(防止上下文溢出)
|
|
84
|
+
├── .analysis/ # 评估历史
|
|
85
|
+
├── .test/ # 测试标准与结果
|
|
86
|
+
├── .bugfix/ # 问题历史
|
|
87
|
+
├── .notes/ # 研究发现
|
|
88
|
+
├── .report.md # 完成报告
|
|
89
|
+
└── plan.md # 实施计划
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 类型感知执行
|
|
93
|
+
|
|
94
|
+
任务按领域类型分类(`software`、`dsp`、`ml`、`literary`、`science:physics` 等)。每种类型会调整规划方法、执行工具和验证标准。已完成任务的经验存储在 `.experience/<type>.md` 中,供同类型的后续任务参考。
|
|
95
|
+
|
|
96
|
+
## 终端特性
|
|
18
97
|
|
|
19
|
-
- **完整 Web 终端** — xterm.js + WebGL 渲染,二进制协议实现超低延迟
|
|
20
98
|
- **会话持久化** — tmux 保证断网后进程存活;固定 socket 路径,服务重启后自动重连
|
|
21
99
|
- **Tab 多标签页** — 独立终端分组,布局跨刷新持久化
|
|
22
100
|
- **分屏布局** — 水平/垂直任意嵌套分割
|
|
23
|
-
-
|
|
24
|
-
- **
|
|
25
|
-
-
|
|
26
|
-
- **复制粘贴** — 鼠标选中自动复制到剪贴板,右键粘贴到终端
|
|
27
|
-
- **文件传输** — 上传文件到 CWD,浏览/下载通过 REST API
|
|
101
|
+
- **二进制协议** — 1 字节前缀帧用于终端 I/O,TCP Nagle 禁用,WebSocket 压缩
|
|
102
|
+
- **WebGL 渲染** — 吞吐量比 canvas 提升 3-10 倍
|
|
103
|
+
- **复制粘贴** — 鼠标选中自动复制,右键粘贴
|
|
28
104
|
- **滚动历史** — capture-pane 回看,保留 ANSI 颜色
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
- **字体大小控制** — 可调节终端字体大小 (A−/A+),设置服务端持久化
|
|
32
|
-
- **版本号显示** — Header 显示当前版本号,构建时从 `package.json` 自动注入
|
|
33
|
-
- **网络指示器** — 实时 RTT 延迟显示 + 信号条
|
|
105
|
+
- **文件传输** — 上传/下载文件,浏览目录,CWD 打包下载为 tar.gz
|
|
106
|
+
- **网络指示器** — 实时 RTT 延迟 + 信号条
|
|
34
107
|
- **自动重连** — 指数退避 + jitter 防雷群效应
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
| **原生应用** | 无(纯 Web) | macOS + iOS + Android |
|
|
49
|
-
| **语音交互** | 无 | Voice Wake + Talk Mode |
|
|
50
|
-
| **AI Agent** | 无内置(运行任意 CLI) | Pi Agent 运行时 + 多 Agent 路由 |
|
|
51
|
-
| **Canvas/UI** | Plan 批注系统(Markdown) | A2UI 实时可视化工作区 |
|
|
52
|
-
| **文件传输** | REST API 上传/下载 | 渠道原生媒体 |
|
|
53
|
-
| **安全模型** | Token auth + timing-safe | 设备配对 + DM 策略 + Docker 沙箱 |
|
|
54
|
-
| **可扩展性** | Shell 脚本 | 33 扩展 + 60+ Skills + ClawHub |
|
|
55
|
-
| **传输协议** | 二进制帧(超低延迟) | JSON WebSocket |
|
|
56
|
-
| **部署** | 单机 Node.js | 单机 + Tailscale Serve/Funnel |
|
|
57
|
-
| **技术栈** | React + Express + node-pty | Lit + Express + Pi Agent |
|
|
58
|
-
| **包大小** | ~1 MB | ~300 MB+ |
|
|
59
|
-
| **安装** | `npx ai-cli-online` | `npm i -g openclaw && openclaw onboard` |
|
|
108
|
+
|
|
109
|
+
## 批注系统
|
|
110
|
+
|
|
111
|
+
Plan 面板提供 4 种批注类型,用于向 AI 发送结构化反馈:
|
|
112
|
+
|
|
113
|
+
| 类型 | 图标 | 说明 |
|
|
114
|
+
|------|------|------|
|
|
115
|
+
| **插入** | `+` | 在指定位置添加内容 |
|
|
116
|
+
| **删除** | `−` | 标记待删除的文本 |
|
|
117
|
+
| **替换** | `↔` | 用新文本替换旧文本 |
|
|
118
|
+
| **评注** | `?` | 提问或留下备注 |
|
|
119
|
+
|
|
120
|
+
批注双层持久化(localStorage + SQLite),以结构化 JSON 发送给 AI。`plan` skill 处理批注 — 按影响分级、应用变更、更新任务文件。
|
|
60
121
|
|
|
61
122
|
## 快速开始
|
|
62
123
|
|
|
@@ -106,49 +167,64 @@ TRUST_PROXY=1 # nginx 反代时设为 1
|
|
|
106
167
|
## 架构
|
|
107
168
|
|
|
108
169
|
```
|
|
109
|
-
浏览器 (xterm.js + WebGL)
|
|
170
|
+
浏览器 (xterm.js + WebGL)
|
|
171
|
+
├── Plan 面板 (批注编辑器)
|
|
172
|
+
├── Chat 编辑器 (Markdown + /命令)
|
|
173
|
+
└── 终端视图 (WebGL 渲染器)
|
|
174
|
+
│
|
|
175
|
+
↕ WebSocket binary/JSON + REST API
|
|
176
|
+
│
|
|
177
|
+
Express 服务 (Node.js)
|
|
178
|
+
├── WebSocket ↔ PTY relay
|
|
179
|
+
├── tmux 会话管理
|
|
180
|
+
├── 文件传输 API
|
|
181
|
+
├── SQLite (草稿、批注、设置)
|
|
182
|
+
└── 路由模块 (sessions, files, editor, settings)
|
|
183
|
+
│
|
|
184
|
+
↕ PTY / tmux sockets
|
|
185
|
+
│
|
|
186
|
+
tmux sessions → shell → Claude Code / AI agents
|
|
187
|
+
└── AiTasks/ 生命周期 (init/plan/check/exec/merge/report/auto)
|
|
110
188
|
```
|
|
111
189
|
|
|
112
|
-
- **前端**: React + Zustand + xterm.js
|
|
190
|
+
- **前端**: React + Zustand + xterm.js (WebGL)
|
|
113
191
|
- **后端**: Node.js + Express + node-pty + WebSocket + better-sqlite3
|
|
114
192
|
- **会话管理**: tmux(持久化终端会话)
|
|
115
|
-
- **布局系统**: Tab 标签页 +
|
|
193
|
+
- **布局系统**: Tab 标签页 + 递归分割树(LeafNode / SplitNode)
|
|
116
194
|
- **传输协议**: 二进制帧(热路径)+ JSON(控制消息)
|
|
117
|
-
-
|
|
118
|
-
|
|
119
|
-
### 性能优化
|
|
120
|
-
|
|
121
|
-
- **二进制协议** — 1 字节前缀帧用于终端 I/O,消除 JSON 序列化开销
|
|
122
|
-
- **TCP Nagle 禁用** — `setNoDelay(true)` 消除最多 40 ms 按键延迟
|
|
123
|
-
- **WebSocket 压缩** — `perMessageDeflate`(level 1,threshold 128 B),带宽减少 50-70%
|
|
124
|
-
- **WebGL 渲染器** — 渲染吞吐量提升 3-10 倍
|
|
125
|
-
- **并行初始化** — PTY 创建、tmux 配置、resize 并行执行
|
|
126
|
-
- **智能重渲染** — 响应式布局 hook、条件 Zustand selector、分批 stat 调用
|
|
195
|
+
- **任务系统**: 8-skill 插件,状态机 + 依赖门控 + 经验知识库
|
|
127
196
|
|
|
128
197
|
## 项目结构
|
|
129
198
|
|
|
130
199
|
```
|
|
131
200
|
ai-cli-online/
|
|
132
|
-
├── shared/
|
|
133
|
-
├── server/
|
|
134
|
-
│
|
|
135
|
-
│
|
|
136
|
-
│
|
|
137
|
-
│
|
|
138
|
-
│
|
|
139
|
-
│
|
|
140
|
-
│
|
|
141
|
-
│
|
|
142
|
-
│
|
|
143
|
-
├── web/
|
|
144
|
-
│
|
|
145
|
-
│
|
|
146
|
-
│
|
|
147
|
-
│
|
|
148
|
-
│
|
|
149
|
-
│
|
|
150
|
-
├──
|
|
151
|
-
|
|
201
|
+
├── shared/ # 共享类型定义
|
|
202
|
+
├── server/src/
|
|
203
|
+
│ ├── index.ts # 主入口 (中间件 + 路由 + 服务)
|
|
204
|
+
│ ├── websocket.ts # WebSocket ↔ PTY relay (二进制 + JSON)
|
|
205
|
+
│ ├── tmux.ts # tmux 会话管理
|
|
206
|
+
│ ├── files.ts # 文件操作 + 路径校验
|
|
207
|
+
│ ├── pty.ts # node-pty 封装
|
|
208
|
+
│ ├── db.ts # SQLite 数据库
|
|
209
|
+
│ ├── auth.ts # 认证工具
|
|
210
|
+
│ ├── middleware/ # 认证中间件
|
|
211
|
+
│ └── routes/ # REST API 路由 (sessions, files, editor, settings)
|
|
212
|
+
├── web/src/
|
|
213
|
+
│ ├── App.tsx # 主应用 (登录 / TabBar / 终端 / 主题)
|
|
214
|
+
│ ├── store/ # Zustand 状态管理 (模块化切片)
|
|
215
|
+
│ ├── components/
|
|
216
|
+
│ │ ├── TerminalPane.tsx # 2D 网格布局 (Plan + 终端 + Chat)
|
|
217
|
+
│ │ ├── TerminalView.tsx # xterm.js 终端
|
|
218
|
+
│ │ ├── PlanPanel.tsx # Plan 批注面板
|
|
219
|
+
│ │ ├── PlanAnnotationRenderer.tsx # Markdown + 内联批注
|
|
220
|
+
│ │ ├── PlanFileBrowser.tsx # AiTasks/ 文件浏览器
|
|
221
|
+
│ │ ├── MarkdownEditor.tsx # Chat 编辑器
|
|
222
|
+
│ │ └── ...
|
|
223
|
+
│ ├── hooks/ # React Hooks (WebSocket, 文件流, resize 等)
|
|
224
|
+
│ └── api/ # 类型化 API 客户端模块
|
|
225
|
+
├── bin/ # npx 入口
|
|
226
|
+
├── start.sh # 生产启动脚本
|
|
227
|
+
└── install-service.sh # systemd + nginx 安装器
|
|
152
228
|
```
|
|
153
229
|
|
|
154
230
|
## 开发
|
|
@@ -177,6 +253,15 @@ sudo journalctl -u ai-cli-online -f # 查看日志
|
|
|
177
253
|
2. 检测 nginx 并可选配置反向代理(WebSocket 支持、SSL、`client_max_body_size`)
|
|
178
254
|
3. nginx 启用时自动设置 `HTTPS_ENABLED=false` 和 `TRUST_PROXY=1`
|
|
179
255
|
|
|
256
|
+
## 安全
|
|
257
|
+
|
|
258
|
+
- Token 认证 + timing-safe 比较
|
|
259
|
+
- 所有文件操作的 symlink 穿越防护
|
|
260
|
+
- 未认证 WebSocket 连接限制
|
|
261
|
+
- TOCTOU 下载防护(流式大小检查)
|
|
262
|
+
- CSP Headers (frame-ancestors, base-uri, form-action)
|
|
263
|
+
- 限速(可配置读/写阈值)
|
|
264
|
+
|
|
180
265
|
## License
|
|
181
266
|
|
|
182
267
|
MIT
|