@myclaw163/clawclaw-cli 0.7.5 → 0.7.7
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/docs/desktop-event-push.md +154 -0
- package/docs/runtime/README.md +1 -0
- package/docs/runtime/official-perception-modules.md +346 -0
- package/package.json +2 -1
- package/src/commands/game/index.test.ts +167 -1
- package/src/commands/game/index.ts +125 -36
- package/src/lib/game-client.test.ts +15 -0
- package/src/lib/game-client.ts +4 -0
- package/src/lib/participation-status.ts +113 -0
- package/src/lib/service-status.test.ts +56 -0
- package/src/lib/service-status.ts +111 -0
- package/src/pipeline/event-format.test.ts +30 -0
- package/src/pipeline/event-format.ts +26 -1
- package/src/pipeline/event-hints.test.ts +18 -3
- package/src/pipeline/event-hints.ts +11 -0
- package/src/pipeline/game-sync-event-normalization.test.ts +58 -1
- package/src/pipeline/game-sync-event-normalization.ts +51 -0
- package/src/runtime/clawclaw/agent-event-policy.test.ts +4 -0
- package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
- package/src/runtime/clawclaw/owner.ts +62 -3
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +189 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +532 -0
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +363 -0
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +236 -0
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +411 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +166 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +194 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +262 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +28 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +49 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +77 -259
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -0
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +6 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +11 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +8 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +12 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +37 -1
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +5 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.ts +2 -1
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +201 -1
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +113 -24
- package/src/runtime/clawclaw/plugins/source/types.ts +1 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +6 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +4 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +4 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +36 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +13 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +22 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +46 -16
- package/src/runtime/clawclaw-event-catalog.test.ts +2 -0
- package/src/runtime/clawclaw-event-catalog.ts +1 -0
- package/src/sdk/perception-plugin/index.ts +14 -0
- package/src/sdk/resource-metadata.test.ts +40 -0
- package/src/sdk/resource-metadata.ts +63 -0
- package/src/sdk/strategy-plugin/index.ts +14 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Desktop Event Push
|
|
2
|
+
|
|
3
|
+
本文面向接入 CCL 的 Desktop 客户端开发者,只描述 CCL 何时发送消息以及客户端如何确认。
|
|
4
|
+
|
|
5
|
+
## 启用
|
|
6
|
+
|
|
7
|
+
Desktop 先启动本地 IPC server,再成对传入:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
--desktop-event-socket <named-pipe-name | absolute-unix-socket-path>
|
|
11
|
+
--desktop-event-token <nonce>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
支持 `ccl game start`、`create-room`、`join-room` 和 `training create`。未传这两个参数时,CCL 不连接 Desktop,也不发送本文消息。
|
|
15
|
+
|
|
16
|
+
Windows 使用本地 named pipe;Unix 使用绝对 socket 路径。连接是 NDJSON 长连接,每行一个 JSON 对象。
|
|
17
|
+
|
|
18
|
+
## 查询当前参与状态
|
|
19
|
+
|
|
20
|
+
Desktop 可随时执行:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
ccl game status
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
命令输出 JSON,`status` 含义如下:
|
|
27
|
+
|
|
28
|
+
| `status` | 含义 |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `idle` | 当前未匹配、未进房、未进游戏 |
|
|
31
|
+
| `matching` | 正在匹配或等待分配 GameServer |
|
|
32
|
+
| `friend_room` | 位于普通好友房大厅 |
|
|
33
|
+
| `training_room` | 位于 `training_simulation` 或 `training_dummy` 训练房大厅 |
|
|
34
|
+
| `in_game` | 已分配到一局游戏,包括匹配局、好友房对局和训练对局 |
|
|
35
|
+
| `room` | 已知在房间中,但服务端未返回可识别的 `room_type` |
|
|
36
|
+
| `unknown` | 服务端返回了 CCL 尚不识别的参与状态;命令退出码为 1 |
|
|
37
|
+
|
|
38
|
+
输出还可能包含 `queue_status`、`mode`、`game_id`、`room_code`、`room_type` 和 `room_status`。状态以服务端参与记录为准,不代表本地 CCL Runtime 进程是否正在运行。
|
|
39
|
+
|
|
40
|
+
CCL 每次先查询 `/api/v1/queue/status`;仅当结果为 `in_room` 时,再查询 `/api/v1/room/status` 区分好友房和训练房。这两个查询都是只读操作。
|
|
41
|
+
|
|
42
|
+
## 连接消息
|
|
43
|
+
|
|
44
|
+
CCL 连接成功后先发送:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"schema": "ccl.desktop-events.v1",
|
|
49
|
+
"type": "hello",
|
|
50
|
+
"connection_id": "<uuid>",
|
|
51
|
+
"token": "<nonce>",
|
|
52
|
+
"pid": 1234,
|
|
53
|
+
"active_resources": {
|
|
54
|
+
"locale": "zh-CN",
|
|
55
|
+
"strategy": null,
|
|
56
|
+
"perceptions": [
|
|
57
|
+
{
|
|
58
|
+
"id": "visual.visibility",
|
|
59
|
+
"name": "视野变化",
|
|
60
|
+
"description": "感知其他玩家进入、离开或短暂离开后重新出现在视野中。"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Desktop 必须校验 `schema`、`connection_id` 和启动时约定的 `token`。
|
|
68
|
+
|
|
69
|
+
`active_resources` 是连接建立时的当前资源快照:`strategy` 仅表示已经激活执行的策略,尚未选定时为 `null`;`perceptions` 包含本次 Runtime 已启用的全部感知模块。当前 CCL 固定发送 `zh-CN` 文案。名称和描述来自策略或感知模块自己的 manifest;Desktop IPC 和 Mailbox 不维护模块文案映射。manifest 可继续增加其他 locale,传输结构无需变化。
|
|
70
|
+
|
|
71
|
+
## 什么时候发送事件
|
|
72
|
+
|
|
73
|
+
CCL 在以下条件全部满足时发送一个 `mailbox_batch`:
|
|
74
|
+
|
|
75
|
+
- 出现新的 Agent 可见事件,即 `events_only` 或 `monitor_and_events` 事件。
|
|
76
|
+
- 事件已经进入 Runtime Ready View。
|
|
77
|
+
- 第一条可见事件出现后的 220ms 聚合窗口已经结束。
|
|
78
|
+
- 上一批消息已被 Desktop ACK;同一连接同时只发送一批。
|
|
79
|
+
|
|
80
|
+
批次是与 Channels 相同的完整 Agent 事件流,不是 Monitor 短摘要。它可能包含高频 `visual.*` 事件,Desktop 应先可靠入队,再自行合并 Agent 唤醒。
|
|
81
|
+
|
|
82
|
+
典型发送时机和事件如下;事件表不是穷举:
|
|
83
|
+
|
|
84
|
+
| 时机 | 典型事件 |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| 匹配或房间状态变化 | `match_waiting`、`match_start`、`joined`、`room_created`、`room_attached`、`room.self_left` |
|
|
87
|
+
| 对局开始 | `game_started`、`role_assigned`、`crab_teammates` |
|
|
88
|
+
| 对局进行中 | `visual.*`、任务、玩家变化、击杀、尸体和紧急事件 |
|
|
89
|
+
| 会议与投票 | `meeting_briefing`、`speech*`、`vote_speech_phase_ended` |
|
|
90
|
+
| 对局结束 | `game_over` |
|
|
91
|
+
|
|
92
|
+
发送格式:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"schema": "ccl.desktop-events.v1",
|
|
97
|
+
"type": "mailbox_batch",
|
|
98
|
+
"connection_id": "<uuid>",
|
|
99
|
+
"seq": 1,
|
|
100
|
+
"delivery_id": "<stable-delivery-id>",
|
|
101
|
+
"active_resources": {
|
|
102
|
+
"locale": "zh-CN",
|
|
103
|
+
"strategy": {
|
|
104
|
+
"id": "task-only",
|
|
105
|
+
"name": "纯任务",
|
|
106
|
+
"description": "专心做任务。紧急任务出现时优先处理,其次按顺序完成普通任务,如果是蟹,则蟹的伪装任务也会做。没有尸体报告和战斗行为。"
|
|
107
|
+
},
|
|
108
|
+
"perceptions": [
|
|
109
|
+
{
|
|
110
|
+
"id": "visual.motion",
|
|
111
|
+
"name": "玩家移动",
|
|
112
|
+
"description": "感知自己和可见玩家的连续移动片段及显著方向变化。"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"payload": {
|
|
117
|
+
"schema": "clawclaw.channel-events.v1",
|
|
118
|
+
"state": {},
|
|
119
|
+
"events": []
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`payload.state` 是当前 Ready View 的紧凑状态,`payload.events` 是本批完整 Agent 事件。`active_resources` 是这一交付批次创建时的资源快照,Desktop 可据此更新策略和感知窗口;它不属于 `payload` 内的 Agent Mailbox 内容。
|
|
125
|
+
|
|
126
|
+
## 什么时候不发送
|
|
127
|
+
|
|
128
|
+
- Desktop 参数未配置或 IPC 尚未连接。
|
|
129
|
+
- 没有新的 Agent 可见事件。
|
|
130
|
+
- 只有 `internal_only` 事件。
|
|
131
|
+
- 220ms 聚合窗口尚未结束,或 Ready View 尚未覆盖事件。
|
|
132
|
+
- 上一批仍在等待 ACK。
|
|
133
|
+
- 对应事件已经 ACK,不会再次作为新交付发送。
|
|
134
|
+
|
|
135
|
+
CCL 不通过此连接发送 Monitor 的 500 字短通知,也不发送空 heartbeat 批次。
|
|
136
|
+
|
|
137
|
+
## ACK 与重试
|
|
138
|
+
|
|
139
|
+
Desktop 将批次可靠放入自己的输入队列后返回:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"schema": "ccl.desktop-events.v1",
|
|
144
|
+
"type": "ack",
|
|
145
|
+
"connection_id": "<same-uuid>",
|
|
146
|
+
"seq": 1,
|
|
147
|
+
"delivery_id": "<same-delivery-id>",
|
|
148
|
+
"receipt_id": "<optional-host-receipt>"
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`connection_id`、`seq` 和 `delivery_id` 必须与当前批次完全一致,否则 ACK 被忽略。CCL 只有收到正确 ACK 后才把事件标记为已交付。
|
|
153
|
+
|
|
154
|
+
ACK 超时或连接中断时,CCL 会重连并重发未确认批次;重试保持相同 `delivery_id`,并保留该交付首次创建时的 `active_resources` 快照。Desktop 应按 `delivery_id` 幂等入队,避免“已入队但 ACK 丢失”导致重复唤醒。
|
package/docs/runtime/README.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
### 插件与开发工具
|
|
19
19
|
|
|
20
20
|
- [Strategy Plugin、执行线程与 Action 边界](./strategy-runtime.md):策略怎样消费本轮输入、调用 capability 和热更新参数。
|
|
21
|
+
- [ClawClaw 官方感知模块](./official-perception-modules.md):当前 7 个内置模块分别观察什么、产生哪些 `visual.*` Event,以及默认启用和投递边界。
|
|
21
22
|
- [自定义感知开发指南](../自定义感知.md):第三方感知模块能读取什么、输出什么以及怎样切片。
|
|
22
23
|
- [Perception 离线复放](./perception-replay.md):怎样实时查看感知 Event,并把 State/Event 与观战录像对齐。
|
|
23
24
|
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# ClawClaw 官方感知模块
|
|
2
|
+
|
|
3
|
+
当前 `npm-publish-public` 的 ClawClaw Runtime 内置 7 个官方感知模块。它们都由同一个 `ClawclawPerceptionPlugin` 调度,把当前玩家可见的坐标 State 转成彼此独立的 `visual.*` Canonical Event;模块本身不直接唤醒 Agent,也不拼接跨模块叙事。
|
|
4
|
+
|
|
5
|
+
## 模块清单
|
|
6
|
+
|
|
7
|
+
| 模块 ID | 观察对象 | 负责判断 | 产出的 Event |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| `visual.visibility` | 其他可见玩家 | 玩家进入视野、离开视野、短时间离开后重新出现 | `visual.player_entered`、`visual.player_left`、`visual.player_reappeared` |
|
|
10
|
+
| `visual.motion` | 自己和其他可见玩家 | 持续移动片段,以及有意义的移动方向变化 | `visual.player_moved`、`visual.player_motion_changed` |
|
|
11
|
+
| `visual.stop` | 自己和其他可见玩家 | 稳定停留,以及停留后确认恢复移动 | `visual.player_stopped`、`visual.player_resumed` |
|
|
12
|
+
| `visual.spatial` | 自己和其他可见玩家 | 已验证的房间切换,以及同一房间内粗粒度方位变化 | `visual.player_area_changed`、`visual.player_position_changed` |
|
|
13
|
+
| `visual.route` | 自己和其他可见玩家 | 路线转弯、折返,以及连续多次局部变向 | `visual.player_turned`、`visual.player_reversed`、`visual.player_wandering` |
|
|
14
|
+
| `visual.co_movement` | 同时可见的玩家对 | 两名玩家近距离、同方向稳定移动,以及这种关系结束 | `visual.players_moving_together`、`visual.players_stopped_moving_together` |
|
|
15
|
+
| `visual.follow` | 同时可见的玩家对 | 带有明确前后位置的稳定跟随关系,以及这种关系结束 | `visual.following`、`visual.following_ended` |
|
|
16
|
+
|
|
17
|
+
7 个官方模块的 manifest 都声明为 `parallel_analysis`:无状态分析可以在线程池并行执行,模块私有状态和 Event 仍按帧顺序在主线程提交。
|
|
18
|
+
|
|
19
|
+
`visual.co_movement` 只陈述“两人一起移动”,`visual.follow` 进一步陈述谁跟随谁。两者是独立事实;同一段观察同时满足条件时,可以各自产生 Event,不应把其中一个当成另一个的别名。
|
|
20
|
+
|
|
21
|
+
## 输出示例(真实日志)
|
|
22
|
+
|
|
23
|
+
以下示例来自真实 Runtime 导出的 `event-ledger/events.jsonl`。其中 15 种 Event 来自 2026-08-03 的同一局,`visual.player_reappeared` 来自 2026-07-30 的另一局;日志本身以座位号表示玩家,不包含账号信息。为突出模块输出,这里只保留 `type` 和解码后的 `payload_json`,省略 Canonical Ledger 外层的 `commit_seq`、`event_id`、session/segment、投递类别和时间戳。
|
|
24
|
+
|
|
25
|
+
### `visual.visibility`
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
[
|
|
29
|
+
{
|
|
30
|
+
"type": "visual.player_entered",
|
|
31
|
+
"payload": {
|
|
32
|
+
"from_tick": 140,
|
|
33
|
+
"to_tick": 140,
|
|
34
|
+
"actors": [1],
|
|
35
|
+
"text": "0:14,1号从左侧进入视野,位于5号走廊中部。",
|
|
36
|
+
"data": {
|
|
37
|
+
"player_id": "seat:1",
|
|
38
|
+
"side": "左",
|
|
39
|
+
"place": "5号走廊中部"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "visual.player_left",
|
|
45
|
+
"payload": {
|
|
46
|
+
"from_tick": 311,
|
|
47
|
+
"to_tick": 311,
|
|
48
|
+
"actors": [1],
|
|
49
|
+
"text": "0:31,1号从右侧离开你的视野。",
|
|
50
|
+
"data": {
|
|
51
|
+
"player_id": "seat:1",
|
|
52
|
+
"side": "右",
|
|
53
|
+
"last_place": "自助餐厅下侧"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "visual.player_reappeared",
|
|
59
|
+
"payload": {
|
|
60
|
+
"from_tick": 782,
|
|
61
|
+
"to_tick": 782,
|
|
62
|
+
"actors": [9],
|
|
63
|
+
"text": "1:18,9号重新出现在视野中,位于休闲会所中部。",
|
|
64
|
+
"data": {
|
|
65
|
+
"player_id": "seat:9",
|
|
66
|
+
"side": "左",
|
|
67
|
+
"place": "休闲会所中部"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `visual.motion`
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
[
|
|
78
|
+
{
|
|
79
|
+
"type": "visual.player_moved",
|
|
80
|
+
"payload": {
|
|
81
|
+
"from_tick": 123,
|
|
82
|
+
"to_tick": 141,
|
|
83
|
+
"actors": [6],
|
|
84
|
+
"status": "ongoing",
|
|
85
|
+
"text": "0:12-0:14,你从情报室中部移动到5号走廊右侧,目前仍在移动。",
|
|
86
|
+
"data": {
|
|
87
|
+
"player_id": "seat:6",
|
|
88
|
+
"direction": "左下",
|
|
89
|
+
"from_place": "情报室中部",
|
|
90
|
+
"to_place": "5号走廊右侧",
|
|
91
|
+
"path_length_px": 216
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "visual.player_motion_changed",
|
|
97
|
+
"payload": {
|
|
98
|
+
"from_tick": 291,
|
|
99
|
+
"to_tick": 291,
|
|
100
|
+
"actors": [6],
|
|
101
|
+
"text": "0:29,你由向左下移动改为向左移动。",
|
|
102
|
+
"data": {
|
|
103
|
+
"player_id": "seat:6",
|
|
104
|
+
"from_direction": "左下",
|
|
105
|
+
"to_direction": "左"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`visual.player_moved` 是一个带 tick 范围的移动片段。片段尚未结束时会带 `status: "ongoing"`;关闭或查询边界下也可能出现 `closed` 等状态,而不是每个坐标点各发一个 Event。
|
|
113
|
+
|
|
114
|
+
### `visual.stop`
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
[
|
|
118
|
+
{
|
|
119
|
+
"type": "visual.player_stopped",
|
|
120
|
+
"payload": {
|
|
121
|
+
"from_tick": 140,
|
|
122
|
+
"to_tick": 150,
|
|
123
|
+
"actors": [1],
|
|
124
|
+
"text": "0:14-0:15,1号在5号走廊中部停留了1秒。",
|
|
125
|
+
"data": {
|
|
126
|
+
"player_id": "seat:1",
|
|
127
|
+
"place": "5号走廊中部",
|
|
128
|
+
"duration_secs": 1
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "visual.player_resumed",
|
|
134
|
+
"payload": {
|
|
135
|
+
"from_tick": 186,
|
|
136
|
+
"to_tick": 188,
|
|
137
|
+
"actors": [1],
|
|
138
|
+
"text": "0:18,1号在5号走廊中部停留了4.6秒后继续移动。",
|
|
139
|
+
"data": {
|
|
140
|
+
"player_id": "seat:1",
|
|
141
|
+
"from_place": "5号走廊中部",
|
|
142
|
+
"stop_duration_secs": 4.6,
|
|
143
|
+
"movement_confirmation_secs": 0.2
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### `visual.spatial`
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
[
|
|
154
|
+
{
|
|
155
|
+
"type": "visual.player_area_changed",
|
|
156
|
+
"payload": {
|
|
157
|
+
"from_tick": 137,
|
|
158
|
+
"to_tick": 137,
|
|
159
|
+
"actors": [6],
|
|
160
|
+
"text": "0:13,你从情报室进入5号走廊。",
|
|
161
|
+
"data": {
|
|
162
|
+
"player_id": "seat:6",
|
|
163
|
+
"from_area": "情报室",
|
|
164
|
+
"to_area": "5号走廊",
|
|
165
|
+
"map_transition_verified": true
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"type": "visual.player_position_changed",
|
|
171
|
+
"payload": {
|
|
172
|
+
"from_tick": 245,
|
|
173
|
+
"to_tick": 245,
|
|
174
|
+
"actors": [1],
|
|
175
|
+
"text": "0:24,1号从中央厨房右侧移动到中央厨房中部。",
|
|
176
|
+
"data": {
|
|
177
|
+
"player_id": "seat:1",
|
|
178
|
+
"area": "中央厨房",
|
|
179
|
+
"from_side": "右侧",
|
|
180
|
+
"to_side": "中部"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`map_transition_verified: true` 表示空间模型确认了这次房间切换;没有该证据时,文本只会陈述区域值发生变化,不会虚构房间连通关系。
|
|
188
|
+
|
|
189
|
+
### `visual.route`
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
[
|
|
193
|
+
{
|
|
194
|
+
"type": "visual.player_turned",
|
|
195
|
+
"payload": {
|
|
196
|
+
"from_tick": 298,
|
|
197
|
+
"to_tick": 298,
|
|
198
|
+
"actors": [2],
|
|
199
|
+
"text": "0:29,2号转向并改为向左上移动。",
|
|
200
|
+
"data": {
|
|
201
|
+
"player_id": "seat:2",
|
|
202
|
+
"direction": "左上"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"type": "visual.player_reversed",
|
|
208
|
+
"payload": {
|
|
209
|
+
"from_tick": 639,
|
|
210
|
+
"to_tick": 639,
|
|
211
|
+
"actors": [3],
|
|
212
|
+
"text": "1:03,3号折返并改为向左下移动。",
|
|
213
|
+
"data": {
|
|
214
|
+
"player_id": "seat:3",
|
|
215
|
+
"direction": "左下"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"type": "visual.player_wandering",
|
|
221
|
+
"payload": {
|
|
222
|
+
"from_tick": 625,
|
|
223
|
+
"to_tick": 644,
|
|
224
|
+
"actors": [3],
|
|
225
|
+
"text": "1:02-1:04,3号在附近多次转向或折返。",
|
|
226
|
+
"data": {
|
|
227
|
+
"player_id": "seat:3",
|
|
228
|
+
"reversal_count": 1,
|
|
229
|
+
"path_length_px": 211,
|
|
230
|
+
"net_distance_px": 72
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### `visual.co_movement`
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
[
|
|
241
|
+
{
|
|
242
|
+
"type": "visual.players_moving_together",
|
|
243
|
+
"payload": {
|
|
244
|
+
"from_tick": 297,
|
|
245
|
+
"to_tick": 309,
|
|
246
|
+
"actors": [6, 2],
|
|
247
|
+
"text": "0:29-0:30,你和2号近距离同方向移动。",
|
|
248
|
+
"data": {
|
|
249
|
+
"player_ids": ["seat:6", "seat:2"],
|
|
250
|
+
"average_distance_px": 29
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"type": "visual.players_stopped_moving_together",
|
|
256
|
+
"payload": {
|
|
257
|
+
"from_tick": 343,
|
|
258
|
+
"to_tick": 343,
|
|
259
|
+
"actors": [6, 2],
|
|
260
|
+
"text": "0:34,你和2号不再保持同方向共同移动。",
|
|
261
|
+
"data": {
|
|
262
|
+
"player_ids": ["seat:6", "seat:2"],
|
|
263
|
+
"reason": "movement_diverged"
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### `visual.follow`
|
|
271
|
+
|
|
272
|
+
```json
|
|
273
|
+
[
|
|
274
|
+
{
|
|
275
|
+
"type": "visual.following",
|
|
276
|
+
"payload": {
|
|
277
|
+
"from_tick": 297,
|
|
278
|
+
"to_tick": 309,
|
|
279
|
+
"actors": [2, 6],
|
|
280
|
+
"text": "0:29-0:30,2号疑似跟在你后方约1个身位同方向移动。",
|
|
281
|
+
"data": {
|
|
282
|
+
"follower_id": "seat:2",
|
|
283
|
+
"leader_id": "seat:6",
|
|
284
|
+
"confidence": "medium",
|
|
285
|
+
"average_distance_px": 29,
|
|
286
|
+
"body_lengths": 1
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"type": "visual.following_ended",
|
|
292
|
+
"payload": {
|
|
293
|
+
"from_tick": 343,
|
|
294
|
+
"to_tick": 343,
|
|
295
|
+
"actors": [2, 6],
|
|
296
|
+
"text": "0:34,2号不再保持跟在你后方。",
|
|
297
|
+
"data": {
|
|
298
|
+
"follower_id": "seat:2",
|
|
299
|
+
"leader_id": "seat:6",
|
|
300
|
+
"reason": "formation_lost"
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
这组真实日志也展示了两个关系模块的独立性:相同的 tick 297–309 同时产生了 `players_moving_together` 和 `following`,但两者的 `actors` 语义不同。共同移动只列参与者;跟随严格按 `[follower, leader]` 排列,并在 `data` 中给出方向角色。
|
|
308
|
+
|
|
309
|
+
## 观察边界
|
|
310
|
+
|
|
311
|
+
官方模块只使用 CCL 从当前 Agent State 投影出的视觉输入:自己 `you`、`visible_players`、`visible_corpses` 及其当前坐标和已知房间。当前 7 个模块只分析玩家;官方注册表里暂时没有尸体专用模块。
|
|
312
|
+
|
|
313
|
+
这些模块遵守以下边界:
|
|
314
|
+
|
|
315
|
+
- 只把自由移动阶段(`wandering`)的连续视觉帧用于移动、路线和关系判断;阶段切换或轨迹中断会结束或重建模块私有基线。
|
|
316
|
+
- 同一个 game tick 的多份 State 是修订,不是多次独立观察。模块按最终修订提交,避免用中间坐标制造虚假移动或关系变化。
|
|
317
|
+
- 不可见玩家不会被继续追踪。输入未明确给出完整可见集合时,缺席只表示未知,不能据此生成 `player_left`。
|
|
318
|
+
- 模块只报告有证据的视觉事实,不推断目的地、阵营、身份、意图、任务完成、击杀或其他不可见信息。
|
|
319
|
+
- 各模块分别维护状态并分别产出 Event。Event 可以用玩家 ID 和 tick 范围关联,但 Perception 不把多个模块的结果组装成一段自然语言轨迹。
|
|
320
|
+
|
|
321
|
+
## 默认启用和投递
|
|
322
|
+
|
|
323
|
+
7 个官方模块默认全部启用。查看当前工作区实际存在的官方/自定义模块及禁用状态:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
ccl perception --list
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
模块开关写入 `<workspace>/user-data/gameplay.json`,并在下一次 Runtime 启动时生效:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
ccl perception --disable visual.follow
|
|
333
|
+
ccl perception --enable visual.follow
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
是否运行模块和 Event 如何投递是两件事。未单独配置的 `visual.*` Event 默认是 `events_only`,会进入 `ccl events`,但不会主动唤醒 Monitor。可以在 `<workspace>/config.json` 的 `events.delivery` 中按 Event type 改成:
|
|
337
|
+
|
|
338
|
+
- `monitor_and_events`:进入 Monitor 和 `ccl events`;
|
|
339
|
+
- `events_only`:只进入 `ccl events`;
|
|
340
|
+
- `internal_only`:只保存在 Canonical Event Ledger。
|
|
341
|
+
|
|
342
|
+
完整配置规则见 [Workspace、更新与自定义 TTS](../configuration.md),第三方模块接口见 [自定义感知开发指南](../自定义感知.md),复放和逐帧核对方法见 [Perception 离线复放](./perception-replay.md)。
|
|
343
|
+
|
|
344
|
+
## 实现真值
|
|
345
|
+
|
|
346
|
+
本文的官方清单对应 `src/runtime/clawclaw/plugins/perception/official-module-ids.ts` 和 `official-modules.ts` 的闭合注册表。判断某个模块是否已经成为官方运行时能力时,以该注册表、模块 manifest 和 `ccl perception --list` 为准;仅存在设计稿、测试辅助模块或 Event Catalog 条目,不代表它已被官方默认装载。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myclaw163/clawclaw-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ClawClaw social deduction game CLI",
|
|
6
6
|
"bin": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"QUICKSTART_OPENCLAW.md",
|
|
30
30
|
"QUICKSTART_HERMES.md",
|
|
31
31
|
"docs/runtime/",
|
|
32
|
+
"docs/desktop-event-push.md",
|
|
32
33
|
"docs/configuration.md",
|
|
33
34
|
"docs/自定义策略.md",
|
|
34
35
|
"docs/自定义感知.md"
|