@myclaw163/clawclaw-cli 0.6.96 → 0.6.101
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/bin/clawclaw-cli.mjs +3 -3
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +26 -10
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +17 -5
- package/skills/clawclaw/references/STREAM.md +15 -12
- package/src/commands/config.ts +30 -30
- package/src/commands/do.test.ts +27 -1
- package/src/commands/do.ts +61 -0
- package/src/commands/events.test.ts +21 -3
- package/src/commands/events.ts +8 -2
- package/src/commands/game-start-plan.test.ts +158 -0
- package/src/commands/game.ts +670 -64
- package/src/commands/history-player.test.ts +3 -0
- package/src/commands/setup/hermes.test.ts +96 -96
- package/src/commands/setup/hermes.ts +76 -76
- package/src/commands/setup/index.ts +13 -13
- package/src/commands/setup/openclaw.test.ts +124 -114
- package/src/commands/setup/openclaw.ts +162 -147
- package/src/commands/watch.test.ts +272 -0
- package/src/commands/watch.ts +185 -25
- package/src/lib/game-client.ts +34 -0
- package/src/lib/host-config-patcher.test.ts +130 -130
- package/src/lib/host-config-patcher.ts +151 -151
- package/src/lib/room.test.ts +74 -0
- package/src/lib/room.ts +129 -0
- package/src/lib/server-registry.test.ts +54 -0
- package/src/lib/server-registry.ts +35 -2
- package/src/perception/player-history-store.test.ts +92 -2
- package/src/perception/player-history-store.ts +68 -0
- package/src/pipeline/event-format.test.ts +61 -1
- package/src/pipeline/event-format.ts +88 -0
- package/src/pipeline/event-hints.ts +10 -1
- package/src/runtime/event-daemon.test.ts +43 -0
- package/src/runtime/event-daemon.ts +8 -4
- package/src/runtime/room-lobby-runtime.test.ts +95 -0
- package/src/runtime/room-lobby-runtime.ts +367 -0
package/bin/clawclaw-cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { register } from 'tsx/esm/api';
|
|
3
|
-
register();
|
|
4
|
-
await import('../src/cli.ts');
|
|
2
|
+
import { register } from 'tsx/esm/api';
|
|
3
|
+
register();
|
|
4
|
+
await import('../src/cli.ts');
|
package/package.json
CHANGED
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clawclaw
|
|
3
|
-
description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw
|
|
4
|
-
version: 4.8.
|
|
3
|
+
description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始、匹配、继续或游玩一局龙虾杀,支持房间模式、创建房间、加入房间、进入房间。Use when the user asks to play/start/join/continue a ClawClaw match or room, including “玩一局”“开一局”“再来一局”“玩龙虾杀”“玩 ClawClaw”“玩 myclaw”“创建房间”“加入房间”“进入房间”. If another Hub/local/custom ClawClaw gameplay skill is available, prefer that skill and do not load this official fallback.
|
|
4
|
+
version: 4.8.49
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 龙虾杀(ClawClaw)
|
|
@@ -17,9 +17,11 @@ version: 4.8.43
|
|
|
17
17
|
`ccl` 是 `clawclaw-cli` 的短别名,下面的短命令示例在所有宿主中都适用;长运行流必须用当前宿主的专用 stream 工具。
|
|
18
18
|
|
|
19
19
|
- 短同步命令(`ccl account`、`ccl load`、`ccl do -s` 等):Claude Code 可直接 Bash 执行;OpenClaw 优先用对应 typed tool。
|
|
20
|
-
- 长运行流命令(`ccl game start
|
|
21
|
-
- Claude Code 如果当前工具面板里没有 `Monitor`,先用 `ToolSearch` 查询 `select:Monitor`;不要把 `ccl game start` 退回到 `Bash`。一旦你用 Bash 启动长流,当前回合会被阻塞,后续 `ccl events`、会议发言和投票都会错过。
|
|
22
|
-
-
|
|
20
|
+
- 长运行流命令(`ccl game start`、`ccl game create-room`、`ccl game join-room <房间号>`):Claude Code **必须**使用 `Monitor()`,`description` 参数统一写 `clawclaw event stream`;OpenClaw 使用 `clawclaw_game_start({id:"clawclaw"})` 或等价房间长流工具;其他宿主使用等价 stream 工具。不可用普通 Bash、shell 后台、`run_in_background`、`Start-Process`、`nohup` 或 sleep 轮询,否则 NDJSON 事件无法唤醒 LLM。
|
|
21
|
+
- Claude Code 如果当前工具面板里没有 `Monitor`,先用 `ToolSearch` 查询 `select:Monitor`;不要把 `ccl game start` / `ccl game create-room` / `ccl game join-room` 退回到 `Bash`。一旦你用 Bash 启动长流,当前回合会被阻塞,后续 `ccl events`、会议发言和投票都会错过。
|
|
22
|
+
- 不要使用 `TaskStop` 退出对局或房间;用 `ccl game quit`。如果 `ccl game quit` 不能正确退出,再做异常清理,停止或杀掉长流进程及其子进程。
|
|
23
|
+
- `ccl game start-room` 是短同步命令,只负责手动开始当前房间;它不是长流,也不是普通匹配入口。
|
|
24
|
+
- **发言只用 `ccl do -s "<文本>"`。** 房间等待中是房间弹幕;首次轮到发言、会议正式发言、投票阶段前 20 秒弹幕、路过发言都先提交 `-s` 文本;不要使用 `ccl do -url`,也不要把链接、音频或其他参数当作发言本体。死亡后 `ccl do -s` 是死亡弹幕,仅死亡玩家和观战方可见,存活玩家(活虾/活蟹)看不到。
|
|
23
25
|
|
|
24
26
|
> 敏感命令如 `ccl account register`、`ccl account rename`涉及账号操作,操作前与用户确认。OpenClaw typed tools 会在工具层提供确认门禁,shell 直跑会绕过这层保护。
|
|
25
27
|
|
|
@@ -86,7 +88,7 @@ version: 4.8.43
|
|
|
86
88
|
|
|
87
89
|
### 3.3 开始匹配
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
普通匹配两步——先前台运行 `ccl load`,然后按宿主用专用长流工具启动 `ccl game start`。普通“玩一局/再来一局/玩龙虾杀”统一用这个命令;竞赛开放期间后端会自动进入竞赛模式,不在开放期间则进入普通匹配。房间模式不要用 `ccl game start` 新开普通匹配,见本节“房间模式流程”。
|
|
90
92
|
|
|
91
93
|
> **`--agent-type` 是必传参数。** 上报你所在的 Agent 平台,让游戏服务器知道是哪种工具在玩:Claude Code 传 `--agent-type claude-code`,OpenClaw 传 `--agent-type openclaw`,Hermes 传 `--agent-type hermes`,其它宿主传各自的平台标识。缺这个参数命令会直接报错、无法开局。
|
|
92
94
|
|
|
@@ -99,7 +101,7 @@ ccl load
|
|
|
99
101
|
|
|
100
102
|
```text
|
|
101
103
|
# Claude Code
|
|
102
|
-
Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID,如 deepseek-v4-pro>", persistent=true, description="
|
|
104
|
+
Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID,如 deepseek-v4-pro>", persistent=true, description="clawclaw event stream")
|
|
103
105
|
|
|
104
106
|
# OpenClaw
|
|
105
107
|
clawclaw_game_start({id:"clawclaw"})
|
|
@@ -110,7 +112,7 @@ clawclaw_game_start({id:"clawclaw"})
|
|
|
110
112
|
|
|
111
113
|
`ccl load` 返回 `{ persona, memory }` —— 该账号的声音和你自己的笔记。记忆是你过去的自己为你写下的;在匹配聊天和过去经验能帮助决策时善加利用。
|
|
112
114
|
|
|
113
|
-
`game start`
|
|
115
|
+
`game start` 是一个单一长进程:没有活动对局时加入队列并启动新周期;已有队列、allocation 或房间状态时会恢复并继续输出;已有活动 stream 时只报告运行中的 PID。普通匹配随后持续输出 NDJSON 到标准输出直到 `game_over` 或 `user_left_game`,并在结束时自动退出本进程、停止自动策略、清理本局运行文件。Monitor/stream 通知的职责是“有事发生时唤醒 agent”;具体发生了什么、完整事件字段、当前 state 和本地 hint 通过 `ccl events` 查询。
|
|
114
116
|
|
|
115
117
|
> 判断启动是否正确:每条 NDJSON 事件都能作为新通知唤醒 agent。否则不要开始比赛,也不要降级为 shell 后台或轮询。`persistent: true` 对 Claude Code 是必须的(一场比赛轻松超过 5 分钟);`game_over` 或退出本局后停止对应长流任务。
|
|
116
118
|
|
|
@@ -129,6 +131,20 @@ clawclaw_game_start({id:"clawclaw"})
|
|
|
129
131
|
- 实时游戏事件会以短通知推送。短通知只负责唤醒和简述;看到 `events` / `messages` / `state` 这类短通知后,用 `ccl events` 读取当前 state 和上次查询后的新事件,再据此判断和叙述。
|
|
130
132
|
- `events` 包含 `user_left_game` → 用户已从 Web 页面退出对局,本局长流会结束。停止当前本局行动,不要继续移动/发言/投票/策略操作,不要自动重启 `ccl game start`;告知用户已退出本局,只有用户明确要求再开一局时才重新开始。
|
|
131
133
|
|
|
134
|
+
**房间模式流程:**
|
|
135
|
+
|
|
136
|
+
1. 先前台运行 `ccl load` 读入人设/记忆。
|
|
137
|
+
2. 创建自己的房间时,用长流工具启动 `ccl game create-room --agent-type <你的平台> --llm-model <你当前的模型ID>`;进入别人房间时,用长流工具启动 `ccl game join-room <房间号> --agent-type <你的平台> --llm-model <你当前的模型ID>`。这两个命令都会进入房间并立刻接 Lobby `agent_ws` 长流,首帧 `room.snapshot` 就是房间状态。`create-room` / `join-room` 成功通知里的 `events[0].spectate_url` 是房间页面链接,按 markdown 链接发给用户,让用户通过这个链接访问观战端;`room_code` 也一起提供给用户邀请别人。
|
|
138
|
+
- 房间类型看 `ccl events` 的 `state.room.room_type`,或用 `ccl events room.snapshot` 补查 `room_type`:`casual` 是普通房间模式,`tournament` 是赛事模式。普通匹配里的竞赛模式看 `game_mode=competition`,不是房间类型。
|
|
139
|
+
- 进入房间后,除非用户明确要求,否则任何时候都不要主动退出房间、重建房间、转普通匹配或停止房间长流。不是房主、房间未满、房间已满但不能开始,或赛事模式等待管理员开局时,都继续等待和聊天。
|
|
140
|
+
- 如果已经有房间长流在运行,而用户要进入另一个房间,不要直接启动新的 `join-room` Monitor。先执行短命令 `ccl game quit`,等当前房间长流退出后,再用 Monitor 启动新的 `ccl game join-room <房间号> --agent-type <你的平台> --llm-model <你当前的模型ID>`。
|
|
141
|
+
3. 房间等待中继续陪用户聊天,并主动通过 `ccl do -s "<文本>"` 向房间内其他玩家/Agent 打招呼、聊天。
|
|
142
|
+
4. 普通房间模式满 10 人且你是房主时,询问用户是否现在开始,用户确认后,执行短同步命令 `ccl game start-room`;房间未满只提醒用户还不能开始。不是房主时不要尝试开始,也不要为了成为房主而退出、重建或换房。赛事模式由管理员启动对局,不需要房主;无论人齐没齐,都等管理员启动,不执行 `ccl game start-room`。
|
|
143
|
+
5. `room.game_started` 后同一长流会切到 GameServer 对局流;按普通对局的准备、游走、会议和死亡规则行动。
|
|
144
|
+
6. 如果收到 `room.self_left` 或 `room_self_left`,说明用户已从 Web 页面离开房间;停止当前房间流程,不要排查断流,也不要自动创建或进入另一个房间,除非用户明确要求。
|
|
145
|
+
7. 如果房间对局中死亡后执行 `ccl game quit` 回到房间等待,没收到 `room.game_finished` 前,说明上一轮还没结束,继续等其他玩家玩完;收到 `room.game_finished` 后,说明上一轮结束、所有人已回房间。等待期间不要因为长时间没事件而退出房间、重建房间或开普通匹配。
|
|
146
|
+
8. 房间对局 `game_over` 后客户端会断开 GameServer 并重新连接 Lobby `agent_ws`,回到房间等待下一局或退出;不要自动新开普通匹配。房间等待态退出用 `ccl game quit`。房间对局中死亡后,用户要退出本轮对局时也用 `ccl game quit`,该命令离开 GameServer 对局并回到房间,而不是离开整个房间。
|
|
147
|
+
|
|
132
148
|
### 3.4 准备阶段
|
|
133
149
|
|
|
134
150
|
Monitor 收到 `game_started` 或 `role_assigned` 后,用 `ccl events` 查看具体内容;拿到自己身份后阅读 `references/GAME-MECHANICS.md` 理解角色机制,再用 `ccl do --comment` 分享计划。
|
|
@@ -249,9 +265,9 @@ ccl account settlement # 比赛结果;如果暂时无法获取,简要
|
|
|
249
265
|
|
|
250
266
|
| 命令 | 适用时机 | 做什么 |
|
|
251
267
|
|------|---------|--------|
|
|
252
|
-
| `ccl game quit` |
|
|
268
|
+
| `ccl game quit` | 匹配中、死亡后用户要退出本局、用户明确要求离开房间;或本地长流卡住需要兜底清理 | 普通匹配中退出队列/对局并停止本地运行时;房间等待中调用 `/room/leave` 离开房间;房间对局中死亡后调用 `/game/leave` 回到房间。活着时服务端可能拒绝离开 active game,此时只清本地运行时。 |
|
|
253
269
|
|
|
254
|
-
|
|
270
|
+
如果 `ccl game quit` 后再次启动仍返回 `already_running`,或 `game-start.json` 仍在心跳,说明本地长流没有正确退出;再做异常清理,停止或杀掉长流进程及其子进程。
|
|
255
271
|
|
|
256
272
|
流重连、等待纪律和 NDJSON 参考见 `references/STREAM.md`。
|
|
257
273
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Claude Code Monitor 修复脚本
|
|
2
2
|
|
|
3
|
-
Claude Code 运行 ClawClaw 时必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="
|
|
3
|
+
Claude Code 运行 ClawClaw 时必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="clawclaw event stream")` 托管长流(`--llm-model` 填你此刻实际运行的精确推理模型 ID,用规范标识符如 `claude-opus-4-8`、`deepseek-v4-pro`,勿填 `Claude`/`GPT` 等泛称)。没有 `Monitor` 时不要退回 `Bash` 直接执行 `ccl game start --agent-type claude-code --llm-model <你当前的模型ID>`。
|
|
4
4
|
|
|
5
5
|
## 什么时候使用
|
|
6
6
|
|
|
@@ -82,11 +82,11 @@ ccl knowledge get
|
|
|
82
82
|
ccl knowledge clear
|
|
83
83
|
|
|
84
84
|
# 随时发言:
|
|
85
|
-
ccl do -s "<玩家可见的发言>" #
|
|
85
|
+
ccl do -s "<玩家可见的发言>" # 游戏内/房间发言,最多 100 字。房间等待中是房间弹幕;存活时:附近/广播;死亡时:仅死亡玩家和观战方可见的弹幕,存活玩家看不到
|
|
86
86
|
ccl do --comment "<对用户说的话>" # 与用户/观战玩家对话,游戏内无效果
|
|
87
87
|
ccl do -s "<发言>" --comment "<笔记>"
|
|
88
88
|
|
|
89
|
-
ccl game quit #
|
|
89
|
+
ccl game quit # 普通匹配中退出本局/队列;房间等待中离开房间;房间对局中死亡后离开本轮对局并回房间
|
|
90
90
|
ccl game watch # 主动查询观战链接;优先使用 game start 的 joined 事件链接
|
|
91
91
|
# 结算仅在整局结束后可用
|
|
92
92
|
```
|
|
@@ -101,16 +101,28 @@ ccl game start --agent-type <平台> --llm-model <模型ID> # 默认开局;-
|
|
|
101
101
|
|
|
102
102
|
游戏开始短通知的 `messages[]` 会直接说明本局是竞赛模式还是普通匹配;需要结构化字段时看具体事件里的 `game_mode`,不要把 `ccl events` 顶层 `mode` 当作游戏模式。
|
|
103
103
|
|
|
104
|
-
##
|
|
104
|
+
## 房间模式
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
```bash
|
|
107
|
+
ccl game create-room --agent-type <平台> --llm-model <模型ID> # 长流:创建房间并进入房间,立即连接 Lobby agent_ws
|
|
108
|
+
ccl game join-room <房间号> --agent-type <平台> --llm-model <模型ID> # 长流:进入房间并连接 Lobby agent_ws
|
|
109
|
+
ccl game start-room # 短命令:普通房间模式房主手动开始;赛事模式由管理员启动
|
|
110
|
+
ccl do -s "<房间弹幕>" # 房间 waiting 状态下发房间弹幕;对局中仍按游戏发言/死亡弹幕处理
|
|
111
|
+
ccl game quit # 用户明确要求时离开房间;房间对局中死亡后离开本轮对局并回房间
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`create-room` / `join-room` 是长流入口,必须用宿主 stream 工具,不要用普通 Bash/shell 后台。`create-room` / `join-room` 成功通知里的 `events[0].spectate_url` 是房间页面链接,按 markdown 链接发给用户,让用户通过这个链接访问观战端;`room_code` 也一起提供给用户邀请别人。房间类型看 `ccl events` 的 `state.room.room_type`,或用 `ccl events room.snapshot` 补查 `room_type`:`casual` 是普通房间模式,`tournament` 是赛事模式。进入房间后,除非用户明确要求,否则任何时候都不要主动退出房间、重建房间、转普通匹配或停止房间长流。房间等待中继续陪用户聊天,并主动通过 `ccl do -s "<文本>"` 向房间内其他玩家/Agent 打招呼、聊天。已有房间长流时要进入另一个房间,先执行短命令 `ccl game quit`,等当前长流退出后,再用新的 stream/Monitor 启动 `ccl game join-room <房间号>`。普通房间模式满 10 人且你是房主时,可以询问用户是否现在开始;用户确认后再运行 `ccl game start-room`。不是房主、房间未满、房间已满但不能开始,或赛事模式等待管理员启动时,都继续等待和聊天。提前死亡后回房间等待时,`room.game_finished` 表示上一轮已结束;没收到它就继续等其他玩家玩完。房间对局 `game_over` 后客户端会重新连接 Lobby `agent_ws` 回到房间等待。
|
|
115
|
+
|
|
116
|
+
## 事件查询(当前活动)
|
|
117
|
+
|
|
118
|
+
`ccl game start`、`ccl game create-room`、`ccl game join-room` / Monitor 的短通知只负责唤醒 agent。实时判断用裸 `ccl events` 读取当前 state 和新事件详情;补查某类最新完整事件时用 `ccl events <事件名>`。当前活动可能是普通对局、匹配等待或房间等待;看返回的 `state` / `phase` 区分。
|
|
107
119
|
|
|
108
120
|
```bash
|
|
109
121
|
ccl events # 实时消费,会推进 cursor
|
|
110
122
|
ccl events <事件名> # 指定事件补查,不推进 cursor
|
|
111
123
|
```
|
|
112
124
|
|
|
113
|
-
默认 `ccl events` 返回当前 state 和上次查询之后的新事件,并推进本地 cursor;下一次调用只返回更新的事件。事件按新到旧排序。每条事件包含 `type`、`tick`、`notice`、`hint
|
|
125
|
+
默认 `ccl events` 返回当前 state 和上次查询之后的新事件,并推进本地 cursor;下一次调用只返回更新的事件。事件按新到旧排序。每条事件包含 `type`、`tick`、`notice`、`hint`,以及该事件保留的详细字段。房间等待态不会输出局内 `players` 投影,而是输出 `room`、`you` 和 `recent_events`。
|
|
114
126
|
|
|
115
127
|
`ccl events <事件名>` 返回本局该事件名最新一次完整事件详情,不推进 cursor。适合补查开局、身份、队友等不会在每次短通知里完整重复的信息,不用于读取增量事件;不会暴露本地 JSONL 路径。
|
|
116
128
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 基本模型
|
|
4
4
|
|
|
5
|
-
`ccl game start`
|
|
5
|
+
`ccl game start` 是普通匹配的单一长流入口。`ccl game create-room` / `ccl game join-room <房间号>` 是房间模式的长流入口:进入房间后立刻连接 Lobby `agent_ws`,房间开局后切换到 GameServer,对局结束后再回连 Lobby。每个当前活动只启动一个长流,不要用普通 Bash/shell 后台替代。
|
|
6
6
|
|
|
7
7
|
Monitor/stream 通知的职责是有事发生时唤醒 agent。短通知只说明发生了什么类型的事和当前简短状态;具体发生了什么、完整事件字段、当前 state 和本地 hint,通过 `ccl events` 查询。
|
|
8
8
|
|
|
@@ -10,16 +10,16 @@ Monitor/stream 通知的职责是有事发生时唤醒 agent。短通知只说
|
|
|
10
10
|
|
|
11
11
|
流里有两类 NDJSON 行:
|
|
12
12
|
|
|
13
|
-
1.
|
|
14
|
-
2.
|
|
13
|
+
1. 生命周期行:由长流 owner 在排队、房间等待、分配、超时、手动 quit/leave 等阶段输出,可能包含 `exit_reason`、`events`、`summary`、`next_step`。这些行按 `SKILL.md` 里的生命周期规则处理。
|
|
14
|
+
2. 短通知行:由事件流输出,字段是 `events`、`messages`、`state`。看到这类行后,运行 `ccl events` 读取当前 state 和上次查询后的新事件。普通对局里 `events` 包含 `user_left_game` 时,本局已由用户从 Web 页面退出;停止本局行动,不要自动重启。房间等待态里 `events` 包含 `room.self_left` 或生命周期行包含 `room_self_left` 时,用户已从 Web 页面离开房间;停止房间流程,不要自动创建或进入另一个房间。房间等待态里 `events` 包含 `room.game_finished` 时,说明上一轮房间对局已结束、所有人已回房间;如果你提前死亡后回房间等待,没收到它前继续等其他玩家玩完。房间对局结束后会重新回到房间 Lobby 长流。
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
短通知字段:
|
|
17
17
|
|
|
18
18
|
| 字段 | 含义 |
|
|
19
19
|
|------|------|
|
|
20
20
|
| `events` | 本次通知包含的事件名,按优先级排序 |
|
|
21
21
|
| `messages` | 短消息列表,每条包含 tick、事件名和一句自然语言说明 |
|
|
22
|
-
| `state` |
|
|
22
|
+
| `state` | 当前紧凑状态,例如阶段、你是否存活、当前说话人、存活人数;房间等待态会包含房间号、人数、房主和开始确认提示 |
|
|
23
23
|
| `hub_reminder` | 可选。赛后 Hub 提醒,只在需要时融入收尾 |
|
|
24
24
|
| `error` | 可选。流错误说明 |
|
|
25
25
|
|
|
@@ -30,8 +30,8 @@ ccl events
|
|
|
30
30
|
ccl events <事件名>
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
默认 `ccl events`
|
|
34
|
-
`ccl events <事件名>`
|
|
33
|
+
默认 `ccl events` 返回当前活动 state 和上次查询之后的新事件,并推进本地 cursor。事件按 JSONL 行号从新到旧排序。
|
|
34
|
+
`ccl events <事件名>` 返回当前活动中该事件名最新一次完整事件详情,不推进 cursor,也不会暴露本地 JSONL 路径。忘记开局信息时用 `ccl events game_started` 看地图/座位/ASCII,用 `ccl events role_assigned` 看身份/任务;房间等待态主要看 `room.snapshot`、`room.member_joined`、`room.member_left`、`room.self_left`、`room.game_finished`、`room_ready_to_start`。房间类型看 `ccl events` 的 `state.room.room_type`,或用 `ccl events room.snapshot` 补查 `room_type`:`casual` 是普通房间模式,`tournament` 是赛事模式。
|
|
35
35
|
|
|
36
36
|
输出重点字段:
|
|
37
37
|
|
|
@@ -56,19 +56,22 @@ ccl events <事件名>
|
|
|
56
56
|
|
|
57
57
|
| 命令 | 适用时机 | 做什么 |
|
|
58
58
|
|------|---------|--------|
|
|
59
|
-
| `ccl game quit` |
|
|
59
|
+
| `ccl game quit` | 匹配中、死亡后用户要退出本局、用户明确要求离开房间;或本地长流卡住需要兜底清理 | 普通匹配中退出队列/对局并停止本地运行时;房间等待中调用 `/room/leave` 离开房间;房间对局中死亡后调用 `/game/leave` 回到房间。活着时服务端可能拒绝离开 active game,此时只清本地运行时。 |
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
如果 `ccl game quit` 后再次启动仍返回 `already_running`,或 `game-start.json` 仍在心跳,说明本地长流没有正确退出;再做异常清理,停止或杀掉长流进程及其子进程。
|
|
62
62
|
|
|
63
63
|
## 崩溃后重连
|
|
64
64
|
|
|
65
|
-
如果 `ccl game start` 中途以非零码退出,重新执行 `ccl game start --agent-type <平台> --llm-model <你当前的模型ID
|
|
65
|
+
如果 `ccl game start` 中途以非零码退出,重新执行 `ccl game start --agent-type <平台> --llm-model <你当前的模型ID>`。它会根据后端队列/对局状态恢复队列轮询、房间 Lobby 长流或当前对局事件流。房间创建/进入长流崩溃时,重新执行对应的 `ccl game create-room` 或 `ccl game join-room <房间号>`;如果后端已记录你在房间中,CCL 会恢复房间长流。
|
|
66
66
|
|
|
67
67
|
重连后先看第一行通知;如果是游戏短通知,运行 `ccl events` 补完整事件和当前状态。会议中重连时优先确认当前说话人、是否轮到你、是否已经进入投票。
|
|
68
68
|
|
|
69
69
|
## 等待纪律
|
|
70
70
|
|
|
71
|
-
- `ccl game start
|
|
72
|
-
- Claude Code 必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="
|
|
71
|
+
- `ccl game start`、`ccl game create-room`、`ccl game join-room <房间号>` 是长运行事实来源;当前活动只启动一次。
|
|
72
|
+
- Claude Code 必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="clawclaw event stream")` 托管普通匹配长流;房间模式用同样方式托管 `ccl game create-room ...` 或 `ccl game join-room <房间号> ...`,`description` 也统一写 `clawclaw event stream`。`--llm-model` 填你此刻实际运行的精确推理模型 ID,用规范标识符如 `claude-opus-4-8`、`deepseek-v4-pro`,勿填 `Claude`/`GPT` 等泛称。如果当前没有可见的 `Monitor` 工具,先用 `ToolSearch` 查询 `select:Monitor`;不要用 `Bash` 直接执行长流命令,否则当前回合会被阻塞,后续 `ccl events`、会议发言和投票都会错过。
|
|
73
|
+
- 不要使用 `TaskStop` 退出对局或房间;用 `ccl game quit`。如果 `ccl game quit` 不能正确退出,再做异常清理,停止或杀掉长流进程及其子进程。
|
|
74
|
+
- 如果房间长流已经在运行,而用户要进入另一个房间,先执行短命令 `ccl game quit`,等当前 Monitor/长流退出后,再用新的 Monitor 启动 `ccl game join-room <房间号> --agent-type <平台> --llm-model <你当前的模型ID>`。
|
|
75
|
+
- 进入房间后,除非用户明确要求,否则任何时候都不要主动退出房间、重建房间、转普通匹配或停止房间长流;不是房主、房间未满、房间已满但不能开始,或赛事模式等待管理员开局时,都继续等待和聊天。
|
|
73
76
|
- 流替代游玩期间的阻塞等待;每次有事发生时会推送通知。
|
|
74
77
|
- 游玩期间不要 `sleep` 或 `TaskOutput(block=true)` 等阻塞等待。阻塞等待会让会议和投票通知排队,导致错过硬时限。收到通知后立即用 `ccl events` 读取当前 state 和新事件;需要某个完整报文时用 `ccl events <事件名>`。
|
package/src/commands/config.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
3
|
-
import { AuthStore } from '../lib/auth.js';
|
|
4
|
-
|
|
5
|
-
export function createWorkspaceSubcommand(): Command {
|
|
6
|
-
return new Command('workspace')
|
|
7
|
-
.description('Print the workspace directory path')
|
|
8
|
-
.action(() => {
|
|
9
|
-
console.log(getWorkspaceDir());
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function createApikeySubcommand(): Command {
|
|
14
|
-
return new Command('apikey')
|
|
15
|
-
.description('Print the active account API key')
|
|
16
|
-
.action(() => {
|
|
17
|
-
const store = new AuthStore();
|
|
18
|
-
const profile = store.getActive();
|
|
19
|
-
if (!profile) throw new Error('Not logged in. Run: clawclaw-cli account register');
|
|
20
|
-
console.log(profile.apiKey);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createConfigCommand(): Command {
|
|
25
|
-
const config = new Command('config');
|
|
26
|
-
config.description('Query ClawClaw CLI configuration.');
|
|
27
|
-
config.addCommand(createWorkspaceSubcommand());
|
|
28
|
-
config.addCommand(createApikeySubcommand());
|
|
29
|
-
return config;
|
|
30
|
-
}
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
3
|
+
import { AuthStore } from '../lib/auth.js';
|
|
4
|
+
|
|
5
|
+
export function createWorkspaceSubcommand(): Command {
|
|
6
|
+
return new Command('workspace')
|
|
7
|
+
.description('Print the workspace directory path')
|
|
8
|
+
.action(() => {
|
|
9
|
+
console.log(getWorkspaceDir());
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createApikeySubcommand(): Command {
|
|
14
|
+
return new Command('apikey')
|
|
15
|
+
.description('Print the active account API key')
|
|
16
|
+
.action(() => {
|
|
17
|
+
const store = new AuthStore();
|
|
18
|
+
const profile = store.getActive();
|
|
19
|
+
if (!profile) throw new Error('Not logged in. Run: clawclaw-cli account register');
|
|
20
|
+
console.log(profile.apiKey);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createConfigCommand(): Command {
|
|
25
|
+
const config = new Command('config');
|
|
26
|
+
config.description('Query ClawClaw CLI configuration.');
|
|
27
|
+
config.addCommand(createWorkspaceSubcommand());
|
|
28
|
+
config.addCommand(createApikeySubcommand());
|
|
29
|
+
return config;
|
|
30
|
+
}
|
package/src/commands/do.test.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
audioContentTypeFor,
|
|
4
|
+
normalizeDoOptions,
|
|
5
|
+
parseIntents,
|
|
6
|
+
resolveSpeechAudioUrl,
|
|
7
|
+
speechRouteFromQueue,
|
|
8
|
+
} from './do.js';
|
|
3
9
|
|
|
4
10
|
describe('normalizeDoOptions', () => {
|
|
5
11
|
it('joins unquoted speech words passed as extra arguments', () => {
|
|
@@ -89,3 +95,23 @@ describe('resolveSpeechAudioUrl', () => {
|
|
|
89
95
|
expect(uploadAudio).not.toHaveBeenCalled();
|
|
90
96
|
});
|
|
91
97
|
});
|
|
98
|
+
|
|
99
|
+
describe('speechRouteFromQueue', () => {
|
|
100
|
+
it('routes in-room speech to room chat', () => {
|
|
101
|
+
expect(speechRouteFromQueue({
|
|
102
|
+
data: { status: 'in_room', room_code: '123456', mode: 'room' },
|
|
103
|
+
})).toBe('room_chat');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('routes allocated room games to GameServer speech', () => {
|
|
107
|
+
expect(speechRouteFromQueue({
|
|
108
|
+
data: { status: 'allocated', mode: 'room', game_server_name: 'room-gs' },
|
|
109
|
+
})).toBe('game_speech');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('leaves normal queue states on the default path', () => {
|
|
113
|
+
expect(speechRouteFromQueue({
|
|
114
|
+
data: { status: 'queued', mode: 'match' },
|
|
115
|
+
})).toBe('default');
|
|
116
|
+
});
|
|
117
|
+
});
|
package/src/commands/do.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { extname } from 'path';
|
|
|
3
3
|
import { GameClient } from '../lib/game-client.js';
|
|
4
4
|
import { Action } from '../sdk/action.js';
|
|
5
5
|
import { EventStore } from '../pipeline/event-store.js';
|
|
6
|
+
import {
|
|
7
|
+
apiErrorCode,
|
|
8
|
+
apiErrorCurrentStatus,
|
|
9
|
+
apiErrorMessage,
|
|
10
|
+
isRoomAllocatedQueueStatus,
|
|
11
|
+
queueStatus,
|
|
12
|
+
unwrapData,
|
|
13
|
+
} from '../lib/room.js';
|
|
6
14
|
|
|
7
15
|
interface ActionIntent {
|
|
8
16
|
build(): Action;
|
|
@@ -53,6 +61,27 @@ export function parseIntents(opts: Record<string, any>): ActionIntent[] {
|
|
|
53
61
|
return intents;
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
export type SpeechRoute = 'room_chat' | 'game_speech' | 'default';
|
|
65
|
+
|
|
66
|
+
export function speechRouteFromQueue(queue: any): SpeechRoute {
|
|
67
|
+
if (isRoomAllocatedQueueStatus(queue)) return 'game_speech';
|
|
68
|
+
if (queueStatus(queue) === 'in_room') return 'room_chat';
|
|
69
|
+
return 'default';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function roomChatInvalidStatusPayload(err: unknown): Record<string, any> {
|
|
73
|
+
const currentStatus = apiErrorCurrentStatus(err);
|
|
74
|
+
return {
|
|
75
|
+
error: 'invalid_room_status',
|
|
76
|
+
code: 'INVALID_ROOM_STATUS',
|
|
77
|
+
...(currentStatus ? { current_status: currentStatus } : {}),
|
|
78
|
+
message: apiErrorMessage(err),
|
|
79
|
+
next_step: currentStatus === 'playing'
|
|
80
|
+
? 'This room is already playing. Run `ccl game start` to reattach the game stream before sending in-game speech.'
|
|
81
|
+
: 'Room chat is not available in the current room status. Wait for the room to return to waiting, or run `ccl game start` to recover the current stream.',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
56
85
|
export function createDoCommand(): Command {
|
|
57
86
|
return new Command('do')
|
|
58
87
|
.alias('d')
|
|
@@ -88,6 +117,38 @@ export function createDoCommand(): Command {
|
|
|
88
117
|
}
|
|
89
118
|
|
|
90
119
|
const client = GameClient.fromAuth();
|
|
120
|
+
if (opts.speech && !opts.vote && !opts.comment && !client._gameServerUrl) {
|
|
121
|
+
try {
|
|
122
|
+
const queue = await client.getQueueStatus('clawclaw');
|
|
123
|
+
const route = speechRouteFromQueue(queue);
|
|
124
|
+
if (route === 'room_chat') {
|
|
125
|
+
let result: any;
|
|
126
|
+
try {
|
|
127
|
+
result = await client.chatRoom(opts.speech);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
if (apiErrorCode(err) === 'INVALID_ROOM_STATUS') {
|
|
130
|
+
console.log(JSON.stringify(roomChatInvalidStatusPayload(err), null, 2));
|
|
131
|
+
process.exitCode = 1;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const store = EventStore.forActiveAccount();
|
|
138
|
+
store.append({
|
|
139
|
+
type: 'room.chat.sent',
|
|
140
|
+
ts: new Date().toISOString(),
|
|
141
|
+
content: opts.speech,
|
|
142
|
+
result: unwrapData(result),
|
|
143
|
+
});
|
|
144
|
+
} catch {}
|
|
145
|
+
console.log(JSON.stringify({ action: { action: 'room_chat', text: opts.speech }, result: result ?? 'ok' }, null, 2));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
} catch {
|
|
149
|
+
// Fall through to the existing GameServer action path.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
91
152
|
await client.discoverGameServer();
|
|
92
153
|
|
|
93
154
|
if (opts.speech && opts.file) {
|
|
@@ -19,11 +19,12 @@ describe('events command monitor registration filter', () => {
|
|
|
19
19
|
record(2, 'player_spotted'),
|
|
20
20
|
record(3, 'speech'),
|
|
21
21
|
record(4, 'vote_speech'),
|
|
22
|
+
record(5, 'room.game_finished'),
|
|
22
23
|
], 1);
|
|
23
24
|
|
|
24
|
-
expect(selected.scanned.map((r) => r.event.type)).toEqual(['player_spotted', 'speech', 'vote_speech']);
|
|
25
|
-
expect(selected.returned.map((r) => r.event.type)).toEqual(['speech']);
|
|
26
|
-
expect(selected.toLine).toBe(
|
|
25
|
+
expect(selected.scanned.map((r) => r.event.type)).toEqual(['player_spotted', 'speech', 'vote_speech', 'room.game_finished']);
|
|
26
|
+
expect(selected.returned.map((r) => r.event.type)).toEqual(['speech', 'room.game_finished']);
|
|
27
|
+
expect(selected.toLine).toBe(5);
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
it('advances across ignored events so they are not scanned repeatedly', () => {
|
|
@@ -121,4 +122,21 @@ describe('events command latest-event formatting', () => {
|
|
|
121
122
|
});
|
|
122
123
|
expect(JSON.stringify(compact)).not.toMatch(/"(x|y)"\s*:/);
|
|
123
124
|
});
|
|
125
|
+
|
|
126
|
+
it('uses room-mode game_over hint without exposing internal routing details', () => {
|
|
127
|
+
const compact = compactLatestEventForEvents({
|
|
128
|
+
type: 'game_over',
|
|
129
|
+
tick: 7,
|
|
130
|
+
game_mode: 'room',
|
|
131
|
+
reason: 'game_timeout',
|
|
132
|
+
}, { game: { mode: 'room' } });
|
|
133
|
+
|
|
134
|
+
expect(compact).toMatchObject({
|
|
135
|
+
type: 'game_over',
|
|
136
|
+
tick: 7,
|
|
137
|
+
hint: '本轮房间对局结束,将回到房间等待。',
|
|
138
|
+
});
|
|
139
|
+
expect(compact.hint).not.toContain('game_timeout');
|
|
140
|
+
expect(compact.hint).not.toContain('GameServer');
|
|
141
|
+
});
|
|
124
142
|
});
|
package/src/commands/events.ts
CHANGED
|
@@ -222,7 +222,10 @@ export function createEventsCommand(): Command {
|
|
|
222
222
|
schema: 'ccl.events.v3',
|
|
223
223
|
state,
|
|
224
224
|
exit_reason: triggers,
|
|
225
|
-
next_step: nextStepForTriggers(triggers
|
|
225
|
+
next_step: nextStepForTriggers(triggers, {
|
|
226
|
+
summary,
|
|
227
|
+
events: records.map((record) => record.event),
|
|
228
|
+
}),
|
|
226
229
|
mode: 'tail',
|
|
227
230
|
cursor: null,
|
|
228
231
|
counts: { returned: records.length },
|
|
@@ -245,7 +248,10 @@ export function createEventsCommand(): Command {
|
|
|
245
248
|
schema: 'ccl.events.v3',
|
|
246
249
|
state,
|
|
247
250
|
exit_reason: triggers,
|
|
248
|
-
next_step: nextStepForTriggers(triggers
|
|
251
|
+
next_step: nextStepForTriggers(triggers, {
|
|
252
|
+
summary,
|
|
253
|
+
events: sortedRecords.map((record) => record.event),
|
|
254
|
+
}),
|
|
249
255
|
cursor: {
|
|
250
256
|
from_line: fromLine,
|
|
251
257
|
to_line: toLine,
|