@clawos-dev/clawd 0.1.2 → 0.2.2-beta.1.e86e2eb
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 +58 -10
- package/dist/cli.cjs +892 -124
- package/package.json +13 -1
- package/dist/cli.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
# @clawos/clawd
|
|
1
|
+
# @clawos-dev/clawd
|
|
2
2
|
|
|
3
3
|
独立 clawd daemon——Claude Code(未来包含 Codex 等)会话服务,WebSocket 协议见 `../doc/clawd-protocol.md`。
|
|
4
4
|
|
|
5
|
-
## 安装
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install -g @clawos/clawd
|
|
9
|
-
```
|
|
10
|
-
|
|
11
5
|
## 启动
|
|
12
6
|
|
|
7
|
+
推荐用 `npx`,每次自动拉最新版(无需全局安装):
|
|
8
|
+
|
|
13
9
|
```bash
|
|
14
|
-
clawd
|
|
15
|
-
clawd --port 28790
|
|
16
|
-
clawd --data-dir /path/to/data
|
|
10
|
+
npx @clawos-dev/clawd@latest # 默认 ws://127.0.0.1:18790
|
|
11
|
+
npx @clawos-dev/clawd@latest --port 28790 # 自定义端口
|
|
12
|
+
npx @clawos-dev/clawd@latest --data-dir /path/to/data # 覆盖默认 ~/.clawd
|
|
13
|
+
npx @clawos-dev/clawd@latest --tunnel # 远程:起 frp tunnel + first-message token 鉴权
|
|
17
14
|
```
|
|
18
15
|
|
|
16
|
+
也可以 `npm i -g @clawos-dev/clawd` 后直接 `clawd …`。
|
|
17
|
+
|
|
19
18
|
启动成功后 stdout 会打印 `Ready: ws://127.0.0.1:18790`,完整 `{url, pid, ...}` 在 `~/.clawd/state.json`(0600 权限)。
|
|
20
19
|
|
|
21
20
|
> **当前阶段无鉴权**:本机 ws 监听 `127.0.0.1`,所有连接直接放行;未来公开远端 transport 时会再引入鉴权。
|
|
@@ -27,8 +26,57 @@ clawd --data-dir /path/to/data # 覆盖默认 ~/.clawd
|
|
|
27
26
|
- `--config <path>` 配置文件,默认 `<data-dir>/config.json`(若存在)
|
|
28
27
|
- `--log-level <level>` `debug` / `info` / `warn` / `error`(默认 `info`)
|
|
29
28
|
- `--server-url <url>` 反连远端中继(v2,暂未实装)
|
|
29
|
+
- `--tunnel` 启用 frp tunnel 把本地端口暴露到公网(搭配 `--clawos-api`)
|
|
30
|
+
- `--clawos-api <url>` `/api/tunnel/register` 接口的 base url
|
|
31
|
+
- `--auth-token <s>` 指定 daemon auth token;缺省时 tunnel 模式自动生成 32 字节 base64url
|
|
32
|
+
- `--no-auth` 关掉 first-message auth(仅开发用,stderr 警告)
|
|
33
|
+
- `--no-tunnel-persist` 启动时不复用 `~/.clawd/tunnel.json`,强制重新 register
|
|
34
|
+
- `--frpc-binary <path>` 指定本地 frpc 二进制;缺省时按需下载到 `~/.clawd/bin/frpc`
|
|
35
|
+
- `--open` 启动后自动用系统默认浏览器打开 ext-clawd UI(需配 `--web-url`)
|
|
36
|
+
- `--web-url <url>` ext-clawd setup 页面完整 URL;由 setup 页面生成的命令自动带
|
|
30
37
|
- `--help` / `-h`、`--version` / `-v`
|
|
31
38
|
|
|
39
|
+
## Tunnel 模式
|
|
40
|
+
|
|
41
|
+
零参数即可(默认 base url 是 `https://api.clawos.chat`):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
clawd --tunnel
|
|
45
|
+
# Ready: ws://127.0.0.1:18790
|
|
46
|
+
# Auth Token: kF3p...43chars
|
|
47
|
+
# Tunnel: wss://abcd1234.tunnel.clawos.chat
|
|
48
|
+
# Connect: wss://abcd1234.tunnel.clawos.chat#token=kF3p...43chars
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
把 `Connect:` 整行复制到 ext-clawd UI 的"远程"模式输入框即可,UI 会自动从 fragment 拆出 token。
|
|
52
|
+
|
|
53
|
+
要换 base url:`--clawos-api https://example.com`
|
|
54
|
+
|
|
55
|
+
启用后 daemon 会:
|
|
56
|
+
|
|
57
|
+
1. 调 `POST <clawos-api>/api/tunnel/register` 拿 frps 凭证
|
|
58
|
+
2. 缓存到 `~/.clawd/tunnel.json`(0600,TTL 7 天,下次启动复用)
|
|
59
|
+
3. 按 OS/arch 下载 frpc 到 `~/.clawd/bin/frpc`(仅首次)
|
|
60
|
+
4. 写 `~/.clawd/frpc.toml` 并 spawn frpc 子进程
|
|
61
|
+
5. 把 `tunnelUrl` 写进 `~/.clawd/state.json`
|
|
62
|
+
|
|
63
|
+
退出时 SIGTERM frpc 子进程,5 秒后 SIGKILL。
|
|
64
|
+
|
|
65
|
+
## Auth: first-message handshake
|
|
66
|
+
|
|
67
|
+
启用 tunnel 时,daemon 强制要求 first-message auth:
|
|
68
|
+
|
|
69
|
+
- 客户端连上后 5 秒内必须发送 `{"type":"auth","token":"<token>"}`
|
|
70
|
+
- 通过 → daemon 回 `{"type":"auth:ok"}`
|
|
71
|
+
- 失败/超时/越权 → close code 1008
|
|
72
|
+
|
|
73
|
+
token 来源(任选其一):
|
|
74
|
+
- daemon 启动时 `Connect:` 那行整体复制(带 `#token=`),ext UI 一次粘贴即可
|
|
75
|
+
- 单独从 `Auth Token:` 那行复制
|
|
76
|
+
- `~/.clawd/state.json` 的 `authToken` 字段(0600,仅本机用户可读)
|
|
77
|
+
|
|
78
|
+
非 tunnel 模式下 `127.0.0.1` / `::1` 来源连接默认豁免 auth(保持 1.0 体验);`--tunnel` 模式所有连接都要 auth。
|
|
79
|
+
|
|
32
80
|
## 协议
|
|
33
81
|
|
|
34
82
|
完整方法与事件表见 [`../doc/clawd-protocol.md`](../doc/clawd-protocol.md)。
|