@clawos-dev/clawd 0.2.626 → 0.2.627

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.627".length > 0 ? "0.2.627" : "dev";
73604
73604
 
73605
73605
  // src/cli-probe/probe.ts
73606
73606
  var fs84 = __toESM(require("fs"), 1);
@@ -11,32 +11,15 @@ description: 老板问本机 clawd 状态时触发——装了哪些 persona/ext
11
11
 
12
12
  **第一步先走 RPC**(clawd-rpc MCP 的 list / call)——daemon 在跑时它是状态的真源,目录布局只是实现细节。用 list 拉方法表(每条带中文说明),对着老板的问题挑方法调;方法表就是能力清单,别凭印象说 clawd 没有某能力。
13
13
 
14
- **RPC 查不到答案、或 daemon 没在跑,再翻文件。** 先 fetch 一次 `${CLAWOS_API}/api/docs/introspection/file-map.md`——它讲 `~/.clawd/` 下每个文件/目录是干啥的,是文件路线的地图。
14
+ **文档只解释结构,不代表当前状态。** 需要了解字段含义时 fetch `${CLAWOS_API}/api/docs/introspection/file-map.md` 或 `state-schemas.md`;故障表征参考 `common-issues.md`。
15
15
 
16
- 然后按具体子问题挑:
16
+ **不直接读凭证或扫目录列状态。** `auth.json`、带凭证的 tunnel / owner identity 文件和含 connectToken 的 `contacts.json` 不读、不贴、不落盘;不调会返回 connectToken 的 `contact:list`。联系人授权通过界面或方法表里不返回凭证的接口查看。
17
17
 
18
- | 老板问的 | fetch |
19
- |---|---|
20
- | 具体 state/auth/tunnel/dispatch json 里字段啥意思 | `${CLAWOS_API}/api/docs/introspection/state-schemas.md` |
21
- | 典型故障表征怎么排(比如 tunnel 挂了、dispatch 卡住、session 报错) | `${CLAWOS_API}/api/docs/introspection/common-issues.md` |
22
-
23
- **文件兜底清单(Read / Bash)** —— 仅在 RPC 答不了时用:
24
-
25
- - `~/.clawd/state.json` daemon 运行时状态(pid / url / tunnelUrl)
26
- - `~/.clawd/tunnel.json` 远程接入配置
27
- - `~/.clawd/dispatch.json` dispatch 台账(正在跑 / 已完成的任务)
28
- - `~/.clawd/contacts.json` 联系人 + 授权(T-35 后授权数据全在这一份,legacy `capabilities.json` / `received-capabilities.json` 已 retire)
29
- - `~/.clawd/personas/` 装了哪些 persona
30
- - `~/.clawd/extensions-published.json` / `~/.clawd/extensions/` 装了哪些 extension
31
- - `~/.clawd/*.log` 各类 log(`clawd.log` 是 daemon 主 log)
32
-
33
- 读文件时凭证不外显:`auth.json`(owner token)整份别读,`contacts.json` 里的 `connectToken` 等 token / secret 字段不贴进回答、不落盘。
34
-
35
- 排障时:先走 RPC 看 daemon 侧状态;daemon 没响应再按 file-map 定位文件 Read,最后按 common-issues 里的表征匹配可能原因。
18
+ RPC 不可用时说明无法确认当前状态。诊断可按用户的时间窗读取 `~/.clawd/log/clawd.log`、`frpc.log` 等日志,禁止把 persona 目录、旧 JSON 或远端不在本机的文件当作实时清单。读会话走 `history:read`,一定加 `slim:true`。
36
19
 
37
20
  ## fetch 失败了
38
21
 
39
- fetch 不到文档就照本机文件+ 现有认知答。**如果本机文件也答不了、又需要文档知识,直接告诉老板"我需要那份自省文档但拉不到,稍后再问一次或让 David 看一眼"**。别瞎猜字段含义。
22
+ fetch 不到文档时仍先用 RPC 方法表与返回结果回答;需要的结构知识无法核实时,明确说明缺少哪份文档。RPC 也不可用就说明无法确认当前状态,不以目录或旧文件补猜。
40
23
 
41
24
  ## 回答风格
42
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.626",
3
+ "version": "0.2.627",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",