@myclaw163/clawclaw-cli 0.7.13 → 0.7.14

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": "@myclaw163/clawclaw-cli",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: clawclaw
3
3
  description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始、匹配、创建或加入好友房、继续或游玩一局龙虾杀。Use when the user asks to play/start/join/continue a ClawClaw match or friend 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.77
4
+ version: 4.8.78
5
5
  ---
6
6
 
7
7
  # 龙虾杀(ClawClaw)
@@ -158,8 +158,8 @@ Monitor(command="ccl join", persistent=true, description="clawclaw event stream"
158
158
  2. 后端空闲时按上表启动一条 `start`;后端已有参与且 Monitor 不健康时先启动一条裸 `ccl join`。跟上后再决定继续当前参与还是询问切换。
159
159
  3. **等待时与用户聊天**——不要沉默。用人设的声音打招呼,分享本局计划,回忆一条适用的记忆,指出观战中有趣的地方。闲扯话术见 `references/CHATTERBOX.md`。如果聊天变成操作指令,在承诺前核实当前策略能力。
160
160
  4. 接收 NDJSON 行(字段参考见 `references/STREAM.md`)。按 canonical 事件名判断;短模式的 `events` 是事件名字符串数组,`messages[]` 是对应 Event 的事实摘要,并在有 hint 时追加同一份英文模板 hint。兼容字段 `exit_reason` 如果存在是数组,不要把它当成字符串比较:
161
- - `joined` → short 通知只给事件名和摘要;运行一次 `ccl events` 读取完整 `joined` Event。它的 `url` 是后端返回的观战链接,分享给用户作为 markdown 链接——**严禁缩写或省略 URL 中的任何部分(包括 token 参数)。** View URL: `[点击观战](<完整URL>)` 使用原始完整 URL,不要用 `...` 省略。
162
- - `session_resumed` → CCL 已重新接上后端已有的队列、房间或对局。事件中的 `source` 表示这份后端参与最初的来源,不是本次 Agent 执行的命令;不得把它叙述成“本次创建请求恢复出了另一种房间”。运行一次 `ccl events` 读取完整 Event,以当前 `state.room.room_type` 和参与状态为准;有 `url` 就按上条完整分享,没有时才运行 `ccl game watch` 生成本地兜底链接。`ccl game watch` 不会额外请求服务器。
161
+ - `joined` → short 通知只给事件名和摘要;运行一次 `ccl events` 读取完整 `joined` Event。
162
+ - `session_resumed` → CCL 已重新接上后端已有的队列、房间或对局。事件中的 `source` 表示这份后端参与最初的来源,不是本次 Agent 执行的命令;不得把它叙述成“本次创建请求恢复出了另一种房间”。运行一次 `ccl events` 读取完整 Event,以当前 `state.room.room_type` 和参与状态为准。
163
163
  - `match_waiting` → 仍在排队,`messages[]` 会摘要 `waited_secs`。继续聊天,无需战术操作。
164
164
  - `match_timeout` → 累计等待 ≥10 分钟。流退出——告诉用户匹配超时,询问是否重新执行 `ccl start match`。
165
165
  - `match_start` → 事件流已连接,等待身份分配;不要重启。
@@ -188,7 +188,7 @@ Monitor(command="ccl join room <6位房间码> --agent-type claude-code --llm-mo
188
188
 
189
189
  已经在同一房间时直接 `ccl join`;已经在不同房间、匹配或对局时先告诉玩家当前参与,询问是否退出。`ccl join room` 返回冲突时不得自动执行 `ccl game quit`。玩家确认切换后,先退出并确认长流结束,再重新运行 `ccl load` 和目标命令。
190
190
 
191
- `--agent-type` 必传,`--llm-model` 填此刻实际运行的精确模型 ID;其它宿主把 `claude-code` 换成自己的平台标识。收到 `room_created`、`room_joined` 或 `session_resumed` 后运行一次 `ccl events`,把完整房间码告诉用户;事件里有 `url` / `spectate_url` 时按原样分享完整链接,禁止省略 token 或查询参数。
191
+ `--agent-type` 必传,`--llm-model` 填此刻实际运行的精确模型 ID;其它宿主把 `claude-code` 换成自己的平台标识。收到 `room_created`、`room_joined` 或 `session_resumed` 后运行一次 `ccl events`,把完整房间码告诉用户。
192
192
 
193
193
  房间等待期间保持同一个 Monitor。`room.member_joined`、`room.member_left`、`room.member_status_changed`、`room.owner_changed`、`room.full` 都会唤醒 Agent;收到后运行一次 `ccl events` 查看当前 `state.room.members`,告诉用户人数、在线状态或房主变化,不要重启长流。`room.member_status_changed` 也必须作为需要处理的房间变化,不能因为成员名单没变就忽略。
194
194
 
@@ -139,7 +139,7 @@ ccl join --force # 替
139
139
  ccl game start-room # 仅房主;当前房间满 10 人后开始
140
140
  ```
141
141
 
142
- `--agent-type` 必传;`--llm-model` 填当前实际运行的精确模型 ID。已经在同一房间时用 `ccl join`;已经在不同房间、匹配或对局时,`ccl join room` 返回冲突,不自动退房。`room_created` / `room_joined` / `session_resumed` 后用 `ccl events` 读取并分享完整房间码和可用的完整观战链接。等待期间房间事件通过同一长流唤醒 Agent;不要重启 Monitor。
142
+ `--agent-type` 必传;`--llm-model` 填当前实际运行的精确模型 ID。已经在同一房间时用 `ccl join`;已经在不同房间、匹配或对局时,`ccl join room` 返回冲突,不自动退房。`room_created` / `room_joined` / `session_resumed` 后用 `ccl events` 读取并分享完整房间码。等待期间房间事件通过同一长流唤醒 Agent;不要重启 Monitor。
143
143
 
144
144
  ## 训练模式
145
145
 
@@ -28,7 +28,7 @@ Monitor 字段如下:
28
28
  - `room.member_joined` / `room.member_left` / `room.member_status_changed` / `room.owner_changed` / `room.full`:房间成员、在线状态、房主或人数发生变化;这些事件都会唤醒 Agent,随后用 `ccl events` 读取当前 `state.room.members`。
29
29
  - `room_ready_to_start`:当前房间已满足开局条件;只有房主按用户意图运行一次 `ccl game start-room`。
30
30
  - `room.game_started`:现有房间 Runtime 自动切换到本局 GameSync,不另起 `start` 或 `join`。
31
- - `session_resumed`:重新接上后端已有匹配或对局;有 `url` 就直接分享,没有时才用 `ccl game watch` 的本地兜底链接。
31
+ - `session_resumed`:重新接上后端已有匹配或对局。
32
32
  - `match_start`:匹配长流已连接。
33
33
  - `match_waiting`:仍在队列。
34
34
  - `match_timeout`、`not_in_queue`、`game_start_failed`:本次流即将或已经结束;读取对应完整 Event 的事实和可选 `hint`。
@@ -3,6 +3,7 @@ import type { CanonicalEvent } from '../runtime/framework/events/index.js';
3
3
  import {
4
4
  presentCanonicalEvent,
5
5
  presentCanonicalEventForCclEvents,
6
+ presentCanonicalEventForDesktop,
6
7
  } from './canonical-event-presentation.js';
7
8
 
8
9
  function canonical(
@@ -193,4 +194,62 @@ describe('canonical Agent Event presentation', () => {
193
194
  expect(nonVisual).not.toHaveProperty('occurred_at');
194
195
  expect(nonVisual).not.toHaveProperty('received_at');
195
196
  });
197
+
198
+ it('withholds spectate links only from the Desktop Agent projection', () => {
199
+ const source = canonical('joined', {
200
+ status: 'matched',
201
+ recovered: true,
202
+ url: 'https://example.test/lobby?token=top-secret',
203
+ spectate_url: 'https://example.test/lobby?token=spread-secret',
204
+ queue: {
205
+ status: 'matched',
206
+ spectate_url: 'https://example.test/lobby?token=nested-secret',
207
+ data: {
208
+ url: 'https://example.test/lobby?token=deep-secret',
209
+ },
210
+ },
211
+ }, { producer: 'local_synth' });
212
+
213
+ const external = presentCanonicalEventForCclEvents(source, null);
214
+ const desktop = presentCanonicalEventForDesktop(source, null);
215
+
216
+ expect(external).toMatchObject({
217
+ type: 'joined',
218
+ url: 'https://example.test/lobby?token=top-secret',
219
+ hint: expect.stringContaining("Share this Event's url"),
220
+ });
221
+ expect(JSON.stringify(desktop)).not.toContain('example.test');
222
+ expect(desktop).toMatchObject({
223
+ type: 'joined',
224
+ status: 'matched',
225
+ queue: { status: 'matched' },
226
+ hint: 'The game runtime reattached; do not start a duplicate runtime.',
227
+ });
228
+ expect(JSON.stringify((desktop as Record<string, unknown>).hint))
229
+ .not.toMatch(/url|link|user/iu);
230
+ expect(source.payload.url).toBe('https://example.test/lobby?token=top-secret');
231
+
232
+ const roomSource = canonical('room_joined', {
233
+ status: 'room_waiting',
234
+ room_code: '123456',
235
+ resumed: true,
236
+ spectate_url: 'https://example.test/room?token=room-secret',
237
+ }, { producer: 'local_synth' });
238
+ const externalRoom = presentCanonicalEventForCclEvents(roomSource, null);
239
+ const desktopRoom = presentCanonicalEventForDesktop(roomSource, null);
240
+
241
+ expect(externalRoom).toMatchObject({
242
+ spectate_url: 'https://example.test/room?token=room-secret',
243
+ hint: expect.stringContaining("Share this Event's spectate_url"),
244
+ });
245
+ expect(desktopRoom).toMatchObject({
246
+ status: 'room_waiting',
247
+ room_code: '123456',
248
+ resumed: true,
249
+ type: 'room_joined',
250
+ hint: 'The room runtime reattached; keep it attached.',
251
+ });
252
+ expect(JSON.stringify(desktopRoom)).not.toContain('example.test');
253
+ expect(JSON.stringify(desktopRoom)).not.toMatch(/url|link|user/iu);
254
+ });
196
255
  });
@@ -3,6 +3,19 @@ import { buildLocalGameStartedEnrichment } from '../lib/game-context.js';
3
3
  import { compactEventForEvents } from './event-format.js';
4
4
  import { formatCanonicalEventHint } from './event-hints.js';
5
5
 
6
+ const DESKTOP_SPECTATE_EVENT_TYPES = new Set([
7
+ 'joined',
8
+ 'room_created',
9
+ 'room_joined',
10
+ 'session_resumed',
11
+ ]);
12
+
13
+ const DESKTOP_SPECTATE_FIELD_NAMES = new Set([
14
+ 'url',
15
+ 'spectate_url',
16
+ 'spectateUrl',
17
+ ]);
18
+
6
19
  function cleanObject<T extends Record<string, any>>(value: T): T {
7
20
  for (const key of Object.keys(value)) {
8
21
  if (value[key] === undefined) delete value[key];
@@ -10,6 +23,31 @@ function cleanObject<T extends Record<string, any>>(value: T): T {
10
23
  return value;
11
24
  }
12
25
 
26
+ function stripDesktopSpectateFields(value: unknown): unknown {
27
+ if (Array.isArray(value)) return value.map((item) => stripDesktopSpectateFields(item));
28
+ if (!value || typeof value !== 'object') return value;
29
+ return Object.fromEntries(Object.entries(value)
30
+ .filter(([key]) => !DESKTOP_SPECTATE_FIELD_NAMES.has(key))
31
+ .map(([key, item]) => [key, stripDesktopSpectateFields(item)]));
32
+ }
33
+
34
+ function desktopLifecycleHint(event: Record<string, any>): string | undefined {
35
+ switch (event.type) {
36
+ case 'joined':
37
+ return event.recovered === true || event.resumed === true
38
+ ? 'The game runtime reattached; do not start a duplicate runtime.'
39
+ : 'The game runtime is attached; do not start a duplicate runtime.';
40
+ case 'room_created':
41
+ return 'Keep the room runtime attached.';
42
+ case 'room_joined':
43
+ return event.recovered === true || event.resumed === true
44
+ ? 'The room runtime reattached; keep it attached.'
45
+ : 'Keep the room runtime attached.';
46
+ default:
47
+ return undefined;
48
+ }
49
+ }
50
+
13
51
  /** CCL-owned enrichment for Agent-visible Event details. */
14
52
  export function enrichCanonicalEventForAgent(
15
53
  event: Record<string, any>,
@@ -69,3 +107,19 @@ export function presentCanonicalEventForCclEvents(
69
107
  }
70
108
  return presentCanonicalEvent(event, summary);
71
109
  }
110
+
111
+ /** Desktop projection keeps lifecycle guidance but withholds spectate links from its Agent. */
112
+ export function presentCanonicalEventForDesktop(
113
+ event: CanonicalEvent,
114
+ summary: any | null | undefined,
115
+ ): Record<string, any> | string {
116
+ const presented = presentCanonicalEventForCclEvents(event, summary);
117
+ if (
118
+ typeof presented === 'string'
119
+ || !DESKTOP_SPECTATE_EVENT_TYPES.has(event.type)
120
+ ) return presented;
121
+ return cleanObject({
122
+ ...stripDesktopSpectateFields(presented) as Record<string, any>,
123
+ hint: desktopLifecycleHint(presented),
124
+ });
125
+ }
@@ -44,7 +44,10 @@ import {
44
44
  type ParentProcessWatchHandle,
45
45
  } from '../parent-process-watch.js';
46
46
  import { BufferedRawWsLog, ownerRawWsLogPath } from '../raw-ws-log.js';
47
- import { presentCanonicalEventForCclEvents } from '../../pipeline/canonical-event-presentation.js';
47
+ import {
48
+ presentCanonicalEventForCclEvents,
49
+ presentCanonicalEventForDesktop,
50
+ } from '../../pipeline/canonical-event-presentation.js';
48
51
  import { compactStateForEvents } from '../../pipeline/event-format.js';
49
52
  import { createClawclawRuntime } from './runtime.js';
50
53
  import { assembleClawclawPlugins } from './plugins/assembly.js';
@@ -550,7 +553,9 @@ export async function runClawclawOwner(
550
553
  agentMailbox = new AgentMailboxCoordinator({
551
554
  repository: mailboxRepository,
552
555
  readyView: () => runtime!.readReadyView(0, 1),
553
- presentEvent: presentCanonicalEventForCclEvents,
556
+ presentEvent: options.desktopEvents
557
+ ? presentCanonicalEventForDesktop
558
+ : presentCanonicalEventForCclEvents,
554
559
  compactState: compactStateForEvents,
555
560
  diagnostic: (name, attributes) => runtime?.diagnostic(name, attributes),
556
561
  });
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { createServer, type Server, type Socket } from 'node:net';
3
3
  import { afterEach, describe, expect, it, vi } from 'vitest';
4
- import { presentCanonicalEventForCclEvents } from '../../../../pipeline/canonical-event-presentation.js';
4
+ import { presentCanonicalEventForDesktop } from '../../../../pipeline/canonical-event-presentation.js';
5
5
  import { compactStateForEvents } from '../../../../pipeline/event-format.js';
6
6
  import { createClawclawEventCatalog } from '../../../clawclaw-event-catalog.js';
7
7
  import {
@@ -128,7 +128,7 @@ function sendAck(
128
128
  }
129
129
 
130
130
  describe('Desktop Agent event push integration', () => {
131
- it('pushes only ready visible Events and retries one durable batch until exact ACK', async () => {
131
+ it('pushes sanitized ready visible Events and retries one durable batch until exact ACK', async () => {
132
132
  const pipeName = `ccl-desktop-integration-${randomUUID()}`;
133
133
  const socketPath = process.platform === 'win32'
134
134
  ? `\\\\.\\pipe\\${pipeName}`
@@ -185,7 +185,7 @@ describe('Desktop Agent event push integration', () => {
185
185
  const coordinator = new AgentMailboxCoordinator({
186
186
  repository,
187
187
  readyView: () => structuredClone(ready),
188
- presentEvent: presentCanonicalEventForCclEvents,
188
+ presentEvent: presentCanonicalEventForDesktop,
189
189
  compactState: compactStateForEvents,
190
190
  });
191
191
  let pump: MailboxEventBatchPump | undefined;
@@ -258,6 +258,20 @@ describe('Desktop Agent event push integration', () => {
258
258
  await delay(AGENT_MAILBOX_COALESCE_MS + 60);
259
259
  expect(received.filter(({ frame }) => frame.type === 'mailbox_batch')).toHaveLength(0);
260
260
 
261
+ const joined = await publish(ingress, {
262
+ eventId: 'joined-1',
263
+ type: 'joined',
264
+ epochSeq: 2,
265
+ producer: 'local_synth',
266
+ payload: {
267
+ status: 'matched',
268
+ url: 'https://example.test/lobby?token=desktop-secret',
269
+ queue: {
270
+ status: 'matched',
271
+ spectate_url: 'https://example.test/lobby?token=nested-desktop-secret',
272
+ },
273
+ },
274
+ });
261
275
  const longText = `BEGIN-${'x'.repeat(70 * 1024)}-END`;
262
276
  const speech = await publish(ingress, {
263
277
  eventId: 'speech-1',
@@ -268,7 +282,7 @@ describe('Desktop Agent event push integration', () => {
268
282
  expect(speech.deliveryClass).toBe('monitor_and_events');
269
283
  ready = readyView(2, speech.commitSeq);
270
284
  const firstObservedAt = Date.now();
271
- await mailbox.update({ pendingEvents: [speech] } as any);
285
+ await mailbox.update({ pendingEvents: [joined, speech] } as any);
272
286
  await delay(100);
273
287
 
274
288
  const visual = await publish(ingress, {
@@ -307,7 +321,15 @@ describe('Desktop Agent event push integration', () => {
307
321
  expect(firstBatch.frame.payload.events).toEqual([
308
322
  'visual.player_moved | player-2 moved through engine',
309
323
  expect.objectContaining({ type: 'speech', text: longText }),
324
+ expect.objectContaining({
325
+ type: 'joined',
326
+ status: 'matched',
327
+ hint: 'The game runtime is attached; do not start a duplicate runtime.',
328
+ }),
310
329
  ]);
330
+ expect(JSON.stringify(firstBatch.frame.payload)).not.toContain('desktop-secret');
331
+ expect(JSON.stringify(firstBatch.frame.payload)).not.toMatch(/spectate_url/iu);
332
+ expect(JSON.stringify(firstBatch.frame.payload)).not.toMatch(/Share this Event/iu);
311
333
  expect(Buffer.byteLength(JSON.stringify(firstBatch.frame.payload), 'utf8'))
312
334
  .toBeGreaterThan(64 * 1024);
313
335
  expect(JSON.stringify(firstBatch.frame.payload)).not.toContain('task_assigned');