swarmpath-claudecode-bridge 1.1.0 → 1.2.0
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 +30 -16
- package/index.mjs +22 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# SwarmPath Claude Code Bridge v2.
|
|
1
|
+
# SwarmPath Claude Code Bridge v2.5
|
|
2
2
|
|
|
3
|
-
手机远程控制 Mac 本地 Claude Code —
|
|
3
|
+
手机远程控制 Mac 本地 Claude Code — 一行命令连接,自动登录,支持 Chat + Terminal 双模式。
|
|
4
4
|
|
|
5
5
|
## 快速开始
|
|
6
6
|
|
|
@@ -18,18 +18,28 @@ npx swarmpath-claudecode-bridge@latest
|
|
|
18
18
|
|
|
19
19
|
npm 包地址:https://www.npmjs.com/package/swarmpath-claudecode-bridge
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## 双模式
|
|
22
|
+
|
|
23
|
+
### Chat 模式(默认)
|
|
24
|
+
|
|
25
|
+
在 Bridge session 中发消息,Claude Code 以 `claude -p` 非交互模式执行,流式返回结果。适合手机端使用。
|
|
26
|
+
|
|
27
|
+
### Terminal 模式(v2.5 新增)
|
|
28
|
+
|
|
29
|
+
点击 header 栏的 `>_` 按钮切换到 Terminal 模式,在网页中嵌入真正的终端(xterm.js),通过 PTY 双向通信,获得和本地终端完全一致的 Claude Code 体验:
|
|
30
|
+
|
|
31
|
+
- 完整交互式 TUI(进度条、颜色、动画)
|
|
32
|
+
- 支持 `/` 命令(`/help`、`/compact` 等)
|
|
33
|
+
- 窗口 resize 自适应
|
|
34
|
+
- 建议在桌面端使用(手机屏幕较小)
|
|
22
35
|
|
|
23
36
|
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|-- 发送消息 ------------->|-- ws 转发 ------------>|
|
|
31
|
-
| | | claude -p "..." --resume
|
|
32
|
-
|<-- 流式回显 -------------|<-- ws 流式回传 --------|
|
|
37
|
+
手机/桌面 xterm.js SwarmPath 服务器 Mac 本地
|
|
38
|
+
| | |
|
|
39
|
+
|-- ws {input} --------------->|-- ws terminal_input ->|
|
|
40
|
+
| | | node-pty → claude 交互模式
|
|
41
|
+
|<-- ws {data} ----------------|<-- ws terminal_data --|
|
|
42
|
+
|-- ws {resize} -------------->|-- ws terminal_resize >|
|
|
33
43
|
```
|
|
34
44
|
|
|
35
45
|
## 安装 & 配置
|
|
@@ -37,7 +47,7 @@ npm 包地址:https://www.npmjs.com/package/swarmpath-claudecode-bridge
|
|
|
37
47
|
### 前置条件
|
|
38
48
|
|
|
39
49
|
- [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code)(终端输入 `claude --version` 验证)
|
|
40
|
-
- Node.js 18
|
|
50
|
+
- Node.js 18+(Terminal 模式需要编译 `node-pty` 原生模块)
|
|
41
51
|
- SwarmPath Chat 账号
|
|
42
52
|
|
|
43
53
|
### 首次配置
|
|
@@ -96,13 +106,16 @@ npx swarmpath-claudecode-bridge@latest --cwd /Users/apple/my-project
|
|
|
96
106
|
/connect F8USY4
|
|
97
107
|
```
|
|
98
108
|
|
|
99
|
-
###
|
|
109
|
+
### Chat 模式对话
|
|
100
110
|
|
|
101
111
|
在 Bridge session 中直接发消息:
|
|
102
112
|
- `帮我看看当前目录有什么文件`
|
|
103
113
|
- `帮我写一个 hello.py`
|
|
104
114
|
- `运行测试`
|
|
105
|
-
|
|
115
|
+
|
|
116
|
+
### Terminal 模式
|
|
117
|
+
|
|
118
|
+
点击 header 右侧 `>_` 图标切换到 Terminal 模式,直接使用 Claude Code 交互式界面。
|
|
106
119
|
|
|
107
120
|
### 切换模型
|
|
108
121
|
|
|
@@ -141,13 +154,14 @@ export SWARMPATH_TOKEN=eyJ...
|
|
|
141
154
|
|
|
142
155
|
| 特性 | 说明 |
|
|
143
156
|
|------|------|
|
|
157
|
+
| **Chat + Terminal 双模式** | Chat 模式适合手机,Terminal 模式提供完整 TUI 体验 |
|
|
144
158
|
| **自动登录** | 首次 `--setup` 后,后续启动自动用存储的凭据登录 |
|
|
145
159
|
| **Token 自动续期** | 每 12 分钟自动刷新,无需手动干预 |
|
|
146
160
|
| **断线重连** | WebSocket 断开后自动重连(指数退避 5s → 60s) |
|
|
147
161
|
| **Token 过期自动恢复** | 4001 断开时自动重新登录并重连 |
|
|
148
162
|
| **长对话上下文** | `--resume` 复用 Claude session,多轮对话保持上下文 |
|
|
149
163
|
| **远程文件浏览** | 资源管理器远程浏览 Mac 文件(只读) |
|
|
150
|
-
| **`/cd` 切目录** |
|
|
164
|
+
| **`/cd` 切目录** | 动态切换工作目录,自动重置 session |
|
|
151
165
|
|
|
152
166
|
## 安全
|
|
153
167
|
|
package/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* npx swarmpath-claudecode-bridge --server wss://... --token <jwt> # Manual token mode
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { spawn } from 'child_process';
|
|
13
|
+
import { spawn, execSync as _execSync } from 'child_process';
|
|
14
14
|
import { resolve, join, extname } from 'path';
|
|
15
15
|
import { readdirSync, statSync, readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
16
16
|
import { homedir } from 'os';
|
|
@@ -460,14 +460,27 @@ function handleTerminalStart(msg) {
|
|
|
460
460
|
terminalSessions.delete(requestId);
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
463
|
+
// Resolve full path to claude — node-pty doesn't search PATH like shell
|
|
464
|
+
let claudePath = 'claude';
|
|
465
|
+
try {
|
|
466
|
+
claudePath = _execSync('which claude', { encoding: 'utf-8' }).trim() || 'claude';
|
|
467
|
+
} catch {}
|
|
468
|
+
|
|
469
|
+
console.log(` 🖥 Terminal start [${requestId}] (${cols}x${rows}) → ${claudePath}`);
|
|
470
|
+
let term;
|
|
471
|
+
try {
|
|
472
|
+
term = pty.spawn(claudePath, [], {
|
|
473
|
+
name: 'xterm-256color',
|
|
474
|
+
cols: cols || 120,
|
|
475
|
+
rows: rows || 30,
|
|
476
|
+
cwd: CWD,
|
|
477
|
+
env: { ...process.env, TERM: 'xterm-256color' },
|
|
478
|
+
});
|
|
479
|
+
} catch (err) {
|
|
480
|
+
console.error(` 🖥 Terminal spawn failed: ${err.message}`);
|
|
481
|
+
wsSend({ type: 'terminal_exit', requestId, exitCode: -1, error: err.message });
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
471
484
|
terminalSessions.set(requestId, term);
|
|
472
485
|
|
|
473
486
|
term.onData((data) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swarmpath-claudecode-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Connect local Claude Code to SwarmPath Chat — control your Mac from your phone",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"node-pty": "^1.0.
|
|
22
|
+
"node-pty": "^1.2.0-beta.12",
|
|
23
23
|
"ws": "^8.19.0"
|
|
24
24
|
}
|
|
25
25
|
}
|