@myclaw163/clawclaw-cli 0.7.10 → 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/QUICKSTART_OTHER.md +2 -2
- package/docs/configuration.md +1 -1
- package/package.json +1 -1
- package/scripts/check-skill-command-surface.mjs +2 -0
- package/skills/clawclaw/SKILL.md +61 -40
- package/skills/clawclaw/references/CHATTERBOX.md +1 -1
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +2 -2
- package/skills/clawclaw/references/COMMANDS.md +27 -15
- package/skills/clawclaw/references/GAME-MECHANICS.md +2 -2
- package/skills/clawclaw/references/STRATEGIES.md +1 -1
- package/skills/clawclaw/references/STREAM.md +3 -3
- package/src/cli.ts +7 -1
- package/src/commands/game/index.test.ts +198 -1
- package/src/commands/game/index.ts +229 -4
- package/src/commands/load.test.ts +68 -1
- package/src/commands/load.ts +26 -3
- 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
|
@@ -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');
|