@myclaw163/clawclaw-cli 0.7.11 → 0.7.12
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 +1 -1
- package/skills/clawclaw/SKILL.md +2 -2
- package/src/lib/room.ts +1 -0
- package/src/pipeline/event-format.test.ts +12 -0
- package/src/pipeline/event-format.ts +8 -0
- package/src/pipeline/event-hints.test.ts +2 -1
- package/src/runtime/clawclaw/agent-event-policy.test.ts +2 -0
- package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +64 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +40 -6
- package/src/runtime/clawclaw-event-catalog.test.ts +1 -0
- package/src/runtime/clawclaw-event-catalog.ts +1 -0
package/package.json
CHANGED
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -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.
|
|
4
|
+
version: 4.8.75
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 龙虾杀(ClawClaw)
|
|
@@ -193,7 +193,7 @@ Monitor(command="ccl start training dummy --agent-type claude-code --llm-model <
|
|
|
193
193
|
|
|
194
194
|
训练建房会一次占满 10 席;`ccl events` 的 `state.room.members[].is_bot` 区分 bot,`state.room.room_type` 给出精确训练模式。创建只进入等待房,不自动开始。收到 `room_ready_to_start` 后,如果用户原指令没有明确要求立刻开练,先询问;确认后运行 `ccl game training start`。
|
|
195
195
|
|
|
196
|
-
房主可在等待态运行 `ccl game training mode <simulation|dummy>` 切换后续轮次,运行 `ccl game training role-lock <character_id>` 锁定下一局角色,或用 `ccl game training role-unlock`
|
|
196
|
+
房主可在等待态运行 `ccl game training mode <simulation|dummy>` 切换后续轮次,运行 `ccl game training role-lock <character_id>` 锁定下一局角色,或用 `ccl game training role-unlock` 清除。收到 `room.type_changed` 表示训练房模式已被其他方面切换;以当前 `state.room.room_type` 为准,不要为了匹配建房时的旧模式自行切回,只有用户明确要求切换时才运行 `ccl game training mode`。启动训练直接运行 `ccl game training start`。`character_id` 必须来自用户或权威角色目录,不要根据角色名猜数字。命令成功后的 `result` 和随后 `ccl events` 的 `state.room.role_lock_character_id` 是房主当前角色锁证据。
|
|
197
197
|
|
|
198
198
|
训练局自然结束或中止后零冷却回到同一训练房,模式、bot 和角色锁保留。训练局内即使存活,用户明确要求结束本轮时也可运行一次 `ccl game quit`;成功结果是 `status: "game_returned_room"`,前台 runtime 继续等待下一轮。若用户还要离开训练房,回到 `in_room` 后再运行一次 `ccl game quit`。训练局不计 ELO、不进入玩家历史、也不生成录像;不要把缺少结算历史当作 CCL 丢数据。
|
|
199
199
|
|
package/src/lib/room.ts
CHANGED
|
@@ -251,6 +251,18 @@ describe('event-format', () => {
|
|
|
251
251
|
expect(message).toContain('所有人已回到房间');
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
+
it('formats an externally changed training room mode without attributing an origin', () => {
|
|
255
|
+
const event = {
|
|
256
|
+
type: 'room.type_changed',
|
|
257
|
+
previous_room_type: 'training_simulation',
|
|
258
|
+
room_type: 'training_dummy',
|
|
259
|
+
sync_reason: 'room_type_changed',
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
expect(formatEventMessage(event)).toContain('训练房模式已被其他方面从模拟训练切换为木桩训练');
|
|
263
|
+
expect(compactEventFields(event)).not.toHaveProperty('origin');
|
|
264
|
+
});
|
|
265
|
+
|
|
254
266
|
it('formats current CCL lifecycle Event names as factual messages', () => {
|
|
255
267
|
expect(formatEventMessage({ type: 'match_start' })).toContain('匹配长流已连接');
|
|
256
268
|
expect(formatEventMessage({ type: 'quit_requested' })).toContain('正在结束');
|
|
@@ -48,6 +48,12 @@ function stringValue(value: unknown): string | undefined {
|
|
|
48
48
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
function trainingRoomTypeLabel(value: unknown): string {
|
|
52
|
+
if (value === 'training_simulation') return '模拟训练';
|
|
53
|
+
if (value === 'training_dummy') return '木桩训练';
|
|
54
|
+
return text(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
function sceneDistance(
|
|
52
58
|
item: Record<string, any>,
|
|
53
59
|
observer: Record<string, any>,
|
|
@@ -525,6 +531,8 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
525
531
|
return `房主变更为${playerLabel(event.name ?? event.agent_id, firstNumber(event, ['seat']), ctx)}。`;
|
|
526
532
|
case 'room.full':
|
|
527
533
|
return '房间人数已满。';
|
|
534
|
+
case 'room.type_changed':
|
|
535
|
+
return `训练房模式已被其他方面从${trainingRoomTypeLabel(event.previous_room_type)}切换为${trainingRoomTypeLabel(event.room_type)}。`;
|
|
528
536
|
case 'room_ready_to_start':
|
|
529
537
|
return '房间已满足开局条件,你是房主。';
|
|
530
538
|
case 'room.chat':
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from './event-hints.js';
|
|
12
12
|
|
|
13
13
|
describe('Mailbox-owned Event hint registries', () => {
|
|
14
|
-
it('keeps
|
|
14
|
+
it('keeps 30 backend hint formatters and classifies 15 Agent Events as unregistered', () => {
|
|
15
15
|
const unregistered = CLAWCLAW_BACKEND_AGENT_EVENT_TYPES.filter((type) => (
|
|
16
16
|
BACKEND_EVENT_HINT_FORMATTERS[type] === undefined
|
|
17
17
|
));
|
|
@@ -28,6 +28,7 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
28
28
|
'room.member_left',
|
|
29
29
|
'room.owner_changed',
|
|
30
30
|
'room.full',
|
|
31
|
+
'room.type_changed',
|
|
31
32
|
'room.chat',
|
|
32
33
|
'room.game_starting',
|
|
33
34
|
'room.game_start_failed',
|
|
@@ -20,6 +20,8 @@ describe('ClawClaw Monitor Event policy', () => {
|
|
|
20
20
|
|
|
21
21
|
it('wakes for room presence and prioritizes idle termination', () => {
|
|
22
22
|
expect(clawclawMonitorPriority('room.member_status_changed')).toBe(60);
|
|
23
|
+
expect(clawclawMonitorPriority('room.type_changed'))
|
|
24
|
+
.toBeGreaterThan(clawclawMonitorPriority('room_ready_to_start'));
|
|
23
25
|
expect(clawclawMonitorPriority('room.idle_warning')).toBe(80);
|
|
24
26
|
expect(clawclawMonitorPriority('room_destroyed')).toBe(90);
|
|
25
27
|
});
|
|
@@ -704,6 +704,70 @@ describe('ClawclawSourcePlugin lifecycle', () => {
|
|
|
704
704
|
await runtime.close();
|
|
705
705
|
});
|
|
706
706
|
|
|
707
|
+
it('turns a marked external training mode snapshot into one Agent Event', async () => {
|
|
708
|
+
const members = Array.from({ length: 10 }, (_, index) => ({
|
|
709
|
+
seat: index + 1,
|
|
710
|
+
agent_id: index === 0 ? 'self' : `bot-${index}`,
|
|
711
|
+
name: index === 0 ? 'me' : `Bot ${index}`,
|
|
712
|
+
is_owner: index === 0,
|
|
713
|
+
is_bot: index > 0,
|
|
714
|
+
status: 'online' as const,
|
|
715
|
+
}));
|
|
716
|
+
const { runtime, source, rooms } = await fixture(
|
|
717
|
+
[{ status: 'not_in_queue' }],
|
|
718
|
+
{ kind: 'create_room', roomType: 'training_simulation' },
|
|
719
|
+
);
|
|
720
|
+
await waitUntil(() => rooms.length === 1, 'Training Room transport was not started.');
|
|
721
|
+
|
|
722
|
+
await rooms[0].emit('room.snapshot', {
|
|
723
|
+
room_code: 'R1',
|
|
724
|
+
room_type: 'training_simulation',
|
|
725
|
+
status: 'waiting',
|
|
726
|
+
my_seat: 1,
|
|
727
|
+
members,
|
|
728
|
+
}, {
|
|
729
|
+
room_code: 'R1',
|
|
730
|
+
room_type: 'training_simulation',
|
|
731
|
+
status: 'waiting',
|
|
732
|
+
my_seat: 1,
|
|
733
|
+
members,
|
|
734
|
+
}, 1);
|
|
735
|
+
await rooms[0].emit('room.snapshot', {
|
|
736
|
+
room_code: 'R1',
|
|
737
|
+
room_type: 'training_dummy',
|
|
738
|
+
status: 'waiting',
|
|
739
|
+
my_seat: 1,
|
|
740
|
+
members,
|
|
741
|
+
sync_reason: 'room_type_changed',
|
|
742
|
+
}, {
|
|
743
|
+
room_code: 'R1',
|
|
744
|
+
room_type: 'training_dummy',
|
|
745
|
+
status: 'waiting',
|
|
746
|
+
my_seat: 1,
|
|
747
|
+
members,
|
|
748
|
+
sync_reason: 'room_type_changed',
|
|
749
|
+
}, 2);
|
|
750
|
+
await runtime.flush();
|
|
751
|
+
|
|
752
|
+
const changes = runtime.repository.listCommittedEvents({
|
|
753
|
+
sessionId: runtime.scope().sessionId,
|
|
754
|
+
types: ['room.type_changed'],
|
|
755
|
+
order: 'asc',
|
|
756
|
+
});
|
|
757
|
+
expect(changes).toHaveLength(1);
|
|
758
|
+
expect(changes[0]?.payload).toEqual({
|
|
759
|
+
room_code: 'R1',
|
|
760
|
+
previous_room_type: 'training_simulation',
|
|
761
|
+
room_type: 'training_dummy',
|
|
762
|
+
sync_reason: 'room_type_changed',
|
|
763
|
+
});
|
|
764
|
+
expect(runtime.readReadyView().state.state?.room?.room_type).toBe('training_dummy');
|
|
765
|
+
|
|
766
|
+
await source.submitIntent({ kind: 'stop' });
|
|
767
|
+
await expect(source.waitForCompletion()).resolves.toEqual({ reason: 'stopped' });
|
|
768
|
+
await runtime.close();
|
|
769
|
+
});
|
|
770
|
+
|
|
707
771
|
it('owns allocation through terminal Game State and keeps one physical frame in one epoch', async () => {
|
|
708
772
|
const fixtureValue = await fixture([{
|
|
709
773
|
status: 'allocated',
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
queueStatus,
|
|
33
33
|
unwrapData,
|
|
34
34
|
type RoomSnapshot,
|
|
35
|
+
type TrainingRoomType,
|
|
35
36
|
} from '../../../../lib/room.js';
|
|
36
37
|
import type {
|
|
37
38
|
WsCloseInfo,
|
|
@@ -323,6 +324,7 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
|
|
|
323
324
|
private currentQueue?: Record<string, any>;
|
|
324
325
|
private currentRoom?: Record<string, any>;
|
|
325
326
|
private trainingRoomControlOverlay: Record<string, any> = {};
|
|
327
|
+
private pendingTrainingRoomType?: TrainingRoomType;
|
|
326
328
|
private hasFreshGameSnapshot = false;
|
|
327
329
|
private latestFreshGameState?: Record<string, any>;
|
|
328
330
|
private latestFreshGameTick?: number;
|
|
@@ -1484,6 +1486,7 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
|
|
|
1484
1486
|
meta: RoomFrameMeta,
|
|
1485
1487
|
terminalPhase?: 'room_left',
|
|
1486
1488
|
): Promise<void> {
|
|
1489
|
+
const previousRoomType = this.currentRoom?.room?.room_type;
|
|
1487
1490
|
if (snapshot) {
|
|
1488
1491
|
const roleConfig = Object.prototype.hasOwnProperty.call(snapshot, 'role_config')
|
|
1489
1492
|
? snapshot.role_config
|
|
@@ -1496,6 +1499,20 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
|
|
|
1496
1499
|
}
|
|
1497
1500
|
: { ...snapshot, ...this.trainingRoomControlOverlay };
|
|
1498
1501
|
}
|
|
1502
|
+
const currentRoomType = snapshot?.room_type;
|
|
1503
|
+
const roomTypeChangedElsewhere = type === 'room.snapshot'
|
|
1504
|
+
&& data.sync_reason === 'room_type_changed'
|
|
1505
|
+
&& isTrainingRoomMode(previousRoomType)
|
|
1506
|
+
&& isTrainingRoomMode(currentRoomType)
|
|
1507
|
+
&& previousRoomType !== currentRoomType
|
|
1508
|
+
&& this.pendingTrainingRoomType !== currentRoomType;
|
|
1509
|
+
if (
|
|
1510
|
+
type === 'room.snapshot'
|
|
1511
|
+
&& data.sync_reason === 'room_type_changed'
|
|
1512
|
+
&& isTrainingRoomMode(currentRoomType)
|
|
1513
|
+
) {
|
|
1514
|
+
this.trainingRoomControlOverlay.room_type = currentRoomType;
|
|
1515
|
+
}
|
|
1499
1516
|
const roomCode = snapshot?.room_code;
|
|
1500
1517
|
if (roomCode) {
|
|
1501
1518
|
this.requireRuntime().adoptResumeKey(roomCode);
|
|
@@ -1531,7 +1548,17 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
|
|
|
1531
1548
|
else if (type === 'room.game_started' || snapshot?.status === 'playing') this.currentStage = 'loading';
|
|
1532
1549
|
else this.currentStage = 'room';
|
|
1533
1550
|
|
|
1534
|
-
let rawEvents: Record<string, unknown>[] = type === 'room.snapshot'
|
|
1551
|
+
let rawEvents: Record<string, unknown>[] = type === 'room.snapshot'
|
|
1552
|
+
? roomTypeChangedElsewhere
|
|
1553
|
+
? [{
|
|
1554
|
+
type: 'room.type_changed',
|
|
1555
|
+
room_code: snapshot?.room_code,
|
|
1556
|
+
previous_room_type: previousRoomType,
|
|
1557
|
+
room_type: currentRoomType,
|
|
1558
|
+
sync_reason: 'room_type_changed',
|
|
1559
|
+
}]
|
|
1560
|
+
: []
|
|
1561
|
+
: [{ type, ...data }];
|
|
1535
1562
|
if (type === 'service_status') {
|
|
1536
1563
|
const serverStatus = parseServerServiceStatus(data);
|
|
1537
1564
|
rawEvents = serverStatus && this.shouldEmitServiceStatus(serverStatus)
|
|
@@ -1693,11 +1720,18 @@ implements RuntimeSourcePlugin<Record<string, any>, Record<string, unknown>> {
|
|
|
1693
1720
|
}
|
|
1694
1721
|
if (intent.kind === 'training_mode') {
|
|
1695
1722
|
this.requireTrainingRoomStage(intent.kind);
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1723
|
+
this.pendingTrainingRoomType = intent.roomType;
|
|
1724
|
+
try {
|
|
1725
|
+
const result = await this.client.setTrainingRoomMode(intent.roomType);
|
|
1726
|
+
const failure = businessFailureFromResult(result, 'Failed to change training mode.');
|
|
1727
|
+
if (failure) throw leaveFailureError(failure);
|
|
1728
|
+
await this.acceptTrainingRoomControlResult(result);
|
|
1729
|
+
return result;
|
|
1730
|
+
} finally {
|
|
1731
|
+
if (this.pendingTrainingRoomType === intent.roomType) {
|
|
1732
|
+
this.pendingTrainingRoomType = undefined;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1701
1735
|
}
|
|
1702
1736
|
if (intent.kind === 'training_role_lock') {
|
|
1703
1737
|
this.requireTrainingRoomStage(intent.kind);
|
|
@@ -16,6 +16,7 @@ describe('ClawClaw Event Catalog', () => {
|
|
|
16
16
|
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('quit_requested');
|
|
17
17
|
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('room_created');
|
|
18
18
|
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('room.member_status_changed');
|
|
19
|
+
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('room.type_changed');
|
|
19
20
|
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('room.idle_warning');
|
|
20
21
|
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('room_destroyed');
|
|
21
22
|
expect(CLAWCLAW_MONITOR_AND_EVENTS_EVENT_TYPES).toContain('players_changed');
|