@clawos-dev/clawd 0.2.626 → 0.2.628

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 CHANGED
@@ -1,109 +1,40 @@
1
1
  # @clawos-dev/clawd
2
2
 
3
- 独立 clawd daemon —— Claude Code(以及未来的 Codex 等)会话服务,对外暴露 WebSocket 协议。
3
+ Clawd daemon CLI:管理 Claude Code、Codex、pi 会话,通过 WebSocket 与 HTTP RPC 提供会话、persona、权限、历史和远程接入能力。
4
4
 
5
5
  ## 安装与启动
6
6
 
7
- 推荐用 `npx`,每次自动拉最新版(无需全局安装):
8
-
9
7
  ```bash
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 鉴权
8
+ npx @clawos-dev/clawd@latest
9
+ npx @clawos-dev/clawd@latest --port 28790
10
+ npx @clawos-dev/clawd@latest --data-dir /path/to/data
11
+ npx @clawos-dev/clawd@latest --tunnel
14
12
  ```
15
13
 
16
- 也可以 `npm i -g @clawos-dev/clawd` 后直接 `clawd …`。
17
-
18
- 启动成功 stdout 会打印 `Ready: ws://127.0.0.1:18790`,运行时元数据(`{url, pid, authToken?, tunnelUrl?, ...}`)写入 `~/.clawd/state.json`(0600 权限)。
19
-
20
- > **本机模式无鉴权**:监听 `127.0.0.1`,所有连接直接放行;`--tunnel` 模式强制开启 first-message token 鉴权。
14
+ 也可全局安装后运行 `clawd`。默认监听 `127.0.0.1:18790`,数据目录为 `~/.clawd`;参数与配置的当前定义见 [config.ts](./src/config.ts)。完整参数用 `clawd --help` 查看。
21
15
 
22
- ## CLI 参数
16
+ 常用选项:`--port`、`--data-dir`、`--config`、`--log-level`、`--tunnel`、`--clawos-api`、`--auth-token`、`--no-log-shipping`。环境变量由 `resolveConfig` 解析,不根据旧示例猜测支持范围。
23
17
 
24
- | Flag | 默认 | 说明 |
25
- |---|---|---|
26
- | `--port <n>` | `18790` | WebSocket 监听端口 |
27
- | `--data-dir <path>` | `~/.clawd` | 数据目录 |
28
- | `--config <path>` | `<data-dir>/config.json` | 配置文件(存在则加载) |
29
- | `--log-level <level>` | `info` | `debug` / `info` / `warn` / `error` |
30
- | `--tunnel` | `false` | 启用 frp tunnel 把本地端口暴露到公网 |
31
- | `--clawos-api <url>` | `https://api.clawos.chat` | tunnel register 接口 base url |
32
- | `--auth-token <s>` | 自动生成 | 指定 daemon auth token;缺省时 tunnel 模式从 `~/.clawd/auth.json` 复用,不存在则生成 32 字节 base64url |
33
- | `--help` / `-h` | — | 显示帮助 |
34
- | `--version` / `-v` | — | 显示版本 |
18
+ ## 鉴权与远程接入
35
19
 
36
- ### 环境变量(高级)
20
+ - **WebSocket**:无 tunnel 时 loopback 连接可豁免首帧鉴权;启用 tunnel 后 loopback 也要求鉴权。需要鉴权的客户端发送 `{"type":"auth","token":"<token>"}` 并等待 `auth:ok` 后再发送业务帧。凭据决定 owner / guest 身份与权限,不由客户端自报身份。
21
+ - **HTTP RPC**:无论是否启用 tunnel 都使用已解析的 Bearer token。WebSocket 的本机豁免不适用于 HTTP。
22
+ - `--tunnel` 注册公网隧道并启动 frpc,使手机和授权的远端客户端能连接本机 daemon。连接串包含凭据,只交给授权客户端,不贴入诊断报告。
37
23
 
38
- | Var | 说明 |
39
- |---|---|
40
- | `CLAWD_FRPC_BIN` | 自带 frpc 二进制路径(缺省时按需下载到 `~/.clawd/bin/frpc`) |
41
- | `CLAWD_NO_TUNNEL_PERSIST` | `=1` 启动时不复用 `~/.clawd/tunnel.json`(dev only;`NODE_ENV=development` 自动开启) |
42
- | `CLAWD_TUNNEL` | `=1` 等价于 `--tunnel` |
43
- | `CLAWOS_API` | 等价于 `--clawos-api` |
44
- | `CLAWD_AUTH_TOKEN` | 等价于 `--auth-token` |
24
+ 本地 owner token、中心登录票 loginPass、云 gateway API key 各自有不同用途;当前边界见 [identity](../doc/glossary/identity.md) 和 [peer-mesh](../doc/glossary/peer-mesh.md)。
45
25
 
46
- ## Tunnel 模式
47
-
48
- 零参数即可启用:
49
-
50
- ```bash
51
- clawd --tunnel
52
- ```
53
-
54
- 启动后 stdout 会输出一段 banner,包含 tunnel URL 与一键连接串:
55
-
56
- ```
57
- ══════════════════════════════════════════════════════
58
- Tunnel: wss://abcd1234.tunnel.clawos.chat
59
- Connect: wss://abcd1234.tunnel.clawos.chat#token=kF3p...
60
- Frpc config: ~/.clawd/frpc.toml
61
- Frpc log: ~/.clawd/frpc.log
62
- ══════════════════════════════════════════════════════
63
- ```
26
+ ## 查询状态与排障
64
27
 
65
- 把 `Connect:` 整行复制到客户端的"远程连接"输入框即可,客户端会从 fragment 拆出 token。同样的内容也会落盘到 `~/.clawd/connect.txt`(0600)方便事后查阅。
28
+ persona / 会话 / 联系人 / 任务 / tunnel 的实际状态先通过 `clawd-rpc` 的 `list` + `call` 查询。会话列表走 `session:list`;历史读取用 `history:read` 并加 `slim:true`。不要按旧目录示例拼路径,也不直接读取 `auth.json` 或含 connectToken 的联系人记录。
66
29
 
67
- 要换 register base url:`--clawos-api https://example.com`。
30
+ 默认日志在 `~/.clawd/log/`,daemon 主日志为 `clawd.log`。远端和云 persona 状态不能由本机文件判断;按 [日志排障手册](../doc/debug-with-logs.md) 查对应时间窗与 owner。
68
31
 
69
- 启用后 daemon 会:
32
+ ## 开发入口
70
33
 
71
- 1. 调 `POST <clawos-api>/api/tunnel/register` 拿 frps 凭证
72
- 2. 缓存到 `~/.clawd/tunnel.json`(0600,TTL 7 天,下次启动复用)
73
- 3. 按 OS/arch 下载 frpc 到 `~/.clawd/bin/frpc`(仅首次)
74
- 4. 写 `~/.clawd/frpc.toml` 并 spawn frpc 子进程
75
- 5. 把 `tunnelUrl` 写进 `~/.clawd/state.json`
76
-
77
- 退出时 SIGTERM frpc 子进程,5 秒后 SIGKILL。
78
-
79
- ## Auth: first-message handshake
80
-
81
- 启用 tunnel 时,daemon 强制要求 first-message auth:
82
-
83
- - 客户端连上后 5 秒内必须发送 `{"type":"auth","token":"<token>"}`
84
- - 通过 → daemon 回 `{"type":"auth:ok"}`
85
- - 失败 / 超时 / 越权 → close code 1008
86
-
87
- token 来源(任选其一):
88
- - 启动 banner 里 `Connect:` 整行(带 `#token=`),客户端一次粘贴即可
89
- - 单独从 `Auth Token:` 行复制
90
- - `~/.clawd/state.json` 的 `authToken` 字段(0600,仅本机用户可读)
91
-
92
- 非 tunnel 模式下,`127.0.0.1` / `::1` 来源连接默认豁免 auth;`--tunnel` 模式所有连接都要 auth。
93
-
94
- ## 目录结构
95
-
96
- ```
97
- ~/.clawd/
98
- ├── config.json # 可选配置文件
99
- ├── state.json # 运行时发现文件(启动写,退出删)
100
- ├── auth.json # tunnel auth token 持久化
101
- ├── tunnel.json # frps 凭证缓存
102
- ├── connect.txt # tunnel 连接串
103
- ├── frpc.toml / frpc.log # frpc 子进程配置 / 日志
104
- ├── clawd.log # daemon 运行日志
105
- └── sessions/default/*.json # 会话持久化
106
- ```
34
+ - 工作规范:[CLAUDE.md](./CLAUDE.md)与[workspace 规范](../CLAUDE.md)。
35
+ - wire 字段与 schema:[protocol/src/](../protocol/src/);说明见 [wire-protocol](../doc/glossary/wire-protocol.md)。
36
+ - 模块边界和当前术语:[glossary](../doc/glossary/README.md)。
37
+ - 运行时持久化布局:[disk-layout](../doc/glossary/disk-layout.md),它是实现说明,不是状态查询接口。
107
38
 
108
39
  ## License
109
40
 
package/dist/cli.cjs CHANGED
@@ -73600,7 +73600,7 @@ function computeMethodAccess(args) {
73600
73600
  }
73601
73601
 
73602
73602
  // src/version.ts
73603
- var version = "0.2.626".length > 0 ? "0.2.626" : "dev";
73603
+ var version = "0.2.628".length > 0 ? "0.2.628" : "dev";
73604
73604
 
73605
73605
  // src/cli-probe/probe.ts
73606
73606
  var fs84 = __toESM(require("fs"), 1);