@yoooclaw/cli 0.1.1 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoooclaw/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "yoooclaw 独立 CLI:本地守护进程接收手机通知、Relay 隧道、灯效规则评估,Agent-Native",
6
6
  "bin": {
@@ -57,6 +57,7 @@ yoooclaw lightrule delete <name> --yes # 删除
57
57
  ## 错误处理
58
58
 
59
59
  - `YOOOCLAW_DAEMON_NOT_RUNNING`:先 `yoooclaw daemon start` 再重试。
60
- - 创建失败常见为 `VALIDATION_FAILED`(segments 不合法)或 `INVALID_PARAMS`(缺 name/description):
61
- `error.message`(含具体校验项)后修正 JSON 重新提交。
60
+ - 创建失败通常表现为 `YOOOCLAW_INVALID_ARGUMENT`,`error.message` 中会带底层
61
+ `VALIDATION_FAILED`(segments 不合法)或 `INVALID_PARAMS`(缺 name/description);
62
+ 按具体校验项修正 JSON 后重新提交。
62
63
  - 规则名重复:换 `name` 或先 `delete`。
@@ -1,52 +1,63 @@
1
1
  ---
2
2
  name: yoooclaw-tunnel-debug
3
- description: 用 yoooclaw CLI 排查手机端推送链路是否通。当用户说"手机推送收不到""通知没同步过来""检查一下隧道/连接""daemon 还活着吗""手机连不上"时激活。组合使用 daemon status / tunnel status / tunnel +test / gateway test 自检整条接收链路。多数命令需要 daemon 在运行(🟡)。
3
+ description: 用 yoooclaw CLI 排查手机端推送链路是否通。当用户说“手机推送收不到”“通知没同步过来”“检查一下隧道/连接”“daemon 还活着吗”“手机连不上”时激活。组合使用 auth status / daemon status / tunnel status / tunnel +test / gateway test / daemon logs 定位本地配置、daemon、本地 ingest 鉴权与 Relay WebSocket 状态。多数命令需要 daemon 在运行(🟡)。
4
4
  ---
5
5
 
6
- # yoooclaw 隧道 / 接收链路排查
6
+ # yoooclaw Relay / 接收链路排查
7
7
 
8
- 独立 daemon 当前以**直连 HTTP** 接收手机推送(`POST /notifications`),
9
- 配合用户自建 `cloudflared` / `tailscale serve` 反代到 daemon 的本地地址即可让手机端推达。
10
-
11
- ## 何时激活
12
-
13
- - "手机推送收不到 / 通知没同步过来"
14
- - "检查隧道 / 连接 / daemon 状态"
15
- - "手机连不上 / 一直没新消息"
8
+ 独立 daemon 默认用 account api-key 连接托管 Relay WebSocket,手机 App 绑定同一账号后经 Relay 收发。也可以在 Relay 未启用或不可用时,将 `POST /notifications` 通过用户自建 `cloudflared` / `tailscale serve` 暴露为直连 HTTP fallback。
16
9
 
17
10
  ## 排查顺序
18
11
 
19
12
  ```bash
20
- # 1) daemon 是否在跑、监听哪个地址端口
13
+ # 1) 本地凭据是否存在;不调 daemon
14
+ yoooclaw auth status --format json
15
+
16
+ # 2) daemon 是否在跑、监听哪个地址端口
21
17
  yoooclaw daemon status --format json
22
- # 未运行 → {"ok":false,"error":{"code":"YOOOCLAW_DAEMON_NOT_RUNNING",...}} → yoooclaw daemon start
18
+ # 未运行 → yoooclaw daemon start --format json
23
19
 
24
- # 2) 隧道状态(relay 模式 / 是否连接 / relay URL
20
+ # 3) Relay 模式、连接状态、URL、多隧道状态
25
21
  yoooclaw tunnel status --format json
26
- # → {"ok":true,"mode":"standalone-http","connected":false,"relayUrl":"...","note":"..."}
27
22
 
28
- # 3) 端到端回环自检:daemon 通过本地 HTTP 给自己发一条 echo 通知,验证 ingest+鉴权链路
23
+ # 4) daemon 本地回环:验证本地 ingest + 鉴权
29
24
  yoooclaw tunnel +test --format json
30
- # → {"ok":true,"loopback":{"ok":true,"status":200}} 表示本机接收链路 OK
31
25
 
32
- # 4) 模拟手机端调 /notifications,验证鉴权与连通
26
+ # 5) 模拟手机端直接调本地 /notifications
33
27
  yoooclaw gateway test --format json
34
- # → {"ok":true,"status":200,"response":{"ok":true,"ingested":1,...}}
35
- # 要强制走 relay 旁路:yoooclaw gateway test --via-relay
28
+
29
+ # 6) Relay 连接与重连日志
30
+ yoooclaw daemon logs --lines 200 --format json
31
+ yoooclaw log +errors --format json
36
32
  ```
37
33
 
34
+ `tunnel +test` 会让 daemon 给本地 `/notifications` 发一条 echo 通知。它可以确认本地 ingest + 鉴权链路,但不会让流量真正绕行远端 Relay。`gateway test --via-relay` 当前也是复用这条本地回环路径,不应单独作为远端 Relay 可达性的证据。
35
+
38
36
  ## 判读
39
37
 
40
- - `daemon status` `YOOOCLAW_DAEMON_NOT_RUNNING` daemon 没起,先 `yoooclaw daemon start`。
41
- - `tunnel +test` `loopback.ok=true` `gateway test` `ok=true`:**本机接收链路正常**。
42
- 手机仍收不到 问题在网络可达性:检查防火墙、反代(cloudflared/tailscale)、手机端填的地址是否指向 daemon 的对外地址。
43
- - `gateway test` 返回 `401 / YOOOCLAW_UNAUTHORIZED`:token 不一致。
44
- `yoooclaw auth status` token 来源,必要时 `yoooclaw auth token-rotate` 后重启 daemon、并更新手机端 token。
45
- - 想看 daemon 自身日志定位 ingest 失败:`yoooclaw daemon logs --lines 200`(或 `yoooclaw log +errors`)。
38
+ - `auth status` api-key 不存在:先用 `yoooclaw auth set-api-key -` stdin 设置,再启动或 reload daemon
39
+ - `daemon status` `YOOOCLAW_DAEMON_NOT_RUNNING`:运行 `yoooclaw daemon start`。
40
+ - `tunnel status` 的 `mode=relay` 且 `connected=true`:daemon 当前已连上 Relay WebSocket。
41
+ - `tunnel status` `mode=relay` `connected=false`:结合 `lastDisconnectReason`、`reconnectAttempt` 和 daemon 日志排查 api-key、网络与 Relay 服务。
42
+ - `tunnel status` `mode=standalone-http`:当前没有 Relay 隧道;按返回的 `note` 检查 `relay.enabled` api-key。只有明确采用直连 fallback 时才检查防火墙、反代和手机端地址。
43
+ - `tunnel +test` `gateway test` 失败:先排查本地 gateway token。运行 `yoooclaw auth status`,必要时 `yoooclaw auth token-rotate`;daemon 已运行时随后执行 `yoooclaw daemon restart`。
44
+
45
+ ## 多 clientLabel
46
46
 
47
- ## 鉴权前置检查(不调 daemon)
47
+ api-key 模式下,每个 label 对应一条 Relay 隧道。按 label 缩小排查范围:
48
48
 
49
49
  ```bash
50
- yoooclaw auth status --format json # api-key / gateway token 是否存在、来源、daemon 是否可达
51
- yoooclaw auth check --format json # 端到端:用本地 token 调 daemon /daemon/status 验证一致性
50
+ yoooclaw auth list-api-keys --format json
51
+ yoooclaw tunnel status --client work --format json
52
+ yoooclaw tunnel +test --client work --format json
53
+ yoooclaw tunnel reconnect --client work --format json
52
54
  ```
55
+
56
+ ## 鉴权检查
57
+
58
+ ```bash
59
+ yoooclaw auth status --format json
60
+ yoooclaw auth check --format json
61
+ ```
62
+
63
+ `auth status` 只读本地凭据与 daemon lock。`auth check` 会用本地 gateway token 调 daemon `/daemon/status`,用于确认 CLI 和 daemon 的 token 是否一致。