@myclaw163/clawclaw-cli 0.8.3 → 0.8.5
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/README.md +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/api-reference.md +3 -7
- package/docs/custom-modules/behavior.md +6 -4
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/README.md +4 -4
- package/docs/runtime/official-perception-modules.md +2 -2
- package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
- package/package.json +9 -2
- package/scripts/build-official-hub-behaviors.mjs +136 -0
- package/scripts/build-official-hub-behaviors.test.mjs +178 -0
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/enable_ccl_permissions.test.mjs +8 -4
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/scripts/sync-bundled-skill.test.mjs +9 -74
- package/skills/clawclaw/SKILL.md +18 -13
- package/skills/clawclaw/references/BEHAVIORS.md +4 -4
- package/skills/clawclaw/references/COMMANDS.md +33 -18
- package/skills/clawclaw/references/GAME-MECHANICS.md +16 -18
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/STREAM.md +9 -11
- package/src/behaviors/official-finite/do-task.ts +70 -0
- package/src/behaviors/official-finite/index.ts +0 -3
- package/src/commands/account.ts +58 -14
- package/src/commands/behavior.ts +116 -38
- package/src/commands/hub.ts +110 -153
- package/src/commands/load.ts +138 -33
- package/src/commands/perception.ts +55 -24
- package/src/commands/persona.ts +66 -20
- package/src/commands/skill.ts +12 -48
- package/src/commands/trigger.ts +68 -40
- package/src/hub-official-behaviors/kill-lone.ts +138 -0
- package/src/hub-official-behaviors/patrol.ts +30 -0
- package/src/hub-official-behaviors/shared.ts +125 -0
- package/src/hub-official-behaviors/task-only.ts +158 -0
- package/src/lib/account-guidance.ts +54 -9
- package/src/lib/agent-workspace-client.ts +135 -0
- package/src/lib/agent-workspace-runtime.ts +154 -0
- package/src/lib/agent-workspace-skills.ts +177 -0
- package/src/lib/agent-workspace-sync.ts +852 -0
- package/src/lib/gameplay-config.ts +29 -15
- package/src/lib/hub-client.ts +252 -34
- package/src/lib/hub-reminder.ts +22 -7
- package/src/lib/init-command.ts +0 -6
- package/src/lib/load-context.ts +12 -6
- package/src/lib/persona.ts +141 -69
- package/src/lib/server-status.ts +78 -0
- package/src/lib/skill-host.ts +160 -0
- package/src/lib/user-data.ts +197 -4
- package/src/pipeline/event-format.ts +20 -4
- package/src/pipeline/event-hints.ts +20 -6
- package/src/pipeline/game-sync-event-normalization.ts +9 -0
- package/src/pipeline/role-display.ts +22 -0
- package/src/runtime/clawclaw/agent-ability-state.ts +1 -21
- package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +8 -1
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +0 -1
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -9
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
- package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
- package/src/runtime/clawclaw-event-catalog.ts +2 -0
- package/src/runtime/framework/action-diagnostics.ts +1 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -1
- package/src/sdk/action.ts +8 -6
- package/src/sdk/behavior-plugin/index.ts +1 -2
- package/src/sdk/behavior-toolkit/model.ts +2 -0
- package/src/sdk/module-input/index.ts +0 -2
- package/src/strategies/goals/crab-sabotage-top.ts +5 -61
- package/src/strategies/types.ts +0 -6
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
- package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
- package/src/behaviors/official-finite/index.test.ts +0 -202
- package/src/behaviors/official-finite/trigger-alarm.ts +0 -53
- package/src/channel/claude-channel-server.test.ts +0 -202
- package/src/commands/account.test.ts +0 -570
- package/src/commands/behavior.test.ts +0 -158
- package/src/commands/communication.test.ts +0 -282
- package/src/commands/competition.test.ts +0 -116
- package/src/commands/data.test.ts +0 -89
- package/src/commands/events-canonical-state.test.ts +0 -406
- package/src/commands/events.test.ts +0 -58
- package/src/commands/game/index.test.ts +0 -1251
- package/src/commands/game-map.test.ts +0 -69
- package/src/commands/hub.test.ts +0 -124
- package/src/commands/load.test.ts +0 -440
- package/src/commands/perception.test.ts +0 -75
- package/src/commands/setup/hermes.test.ts +0 -96
- package/src/commands/setup/openclaw.test.ts +0 -124
- package/src/commands/trigger.test.ts +0 -140
- package/src/commands/upgrade.test.ts +0 -82
- package/src/lib/account-guidance.test.ts +0 -36
- package/src/lib/auth.test.ts +0 -151
- package/src/lib/behavior-export.test.ts +0 -282
- package/src/lib/behavior-export.ts +0 -514
- package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
- package/src/lib/custom-tts.test.ts +0 -387
- package/src/lib/diagnostics-config.test.ts +0 -59
- package/src/lib/game-client-tts.test.ts +0 -151
- package/src/lib/game-client.test.ts +0 -250
- package/src/lib/gameplay-config.test.ts +0 -301
- package/src/lib/host-config-patcher.test.ts +0 -130
- package/src/lib/http-transport.test.ts +0 -124
- package/src/lib/hub-client.test.ts +0 -57
- package/src/lib/hub-install.test.ts +0 -135
- package/src/lib/hub-install.ts +0 -185
- package/src/lib/hub-unzip.test.ts +0 -69
- package/src/lib/init-command.test.ts +0 -103
- package/src/lib/load-context.test.ts +0 -62
- package/src/lib/match-state.test.ts +0 -134
- package/src/lib/official-resource-sync.test.ts +0 -199
- package/src/lib/official-resource-sync.ts +0 -221
- package/src/lib/perception-config.test.ts +0 -143
- package/src/lib/perception-export.test.ts +0 -145
- package/src/lib/perception-export.ts +0 -178
- package/src/lib/persona.test.ts +0 -84
- package/src/lib/room.test.ts +0 -88
- package/src/lib/server-registry.test.ts +0 -64
- package/src/lib/service-status.test.ts +0 -81
- package/src/lib/skill-version.test.ts +0 -48
- package/src/lib/trigger-config.test.ts +0 -102
- package/src/lib/trigger-export.test.ts +0 -80
- package/src/lib/trigger-export.ts +0 -210
- package/src/lib/user-data.test.ts +0 -121
- package/src/lib/workspace-argv.test.ts +0 -49
- package/src/pipeline/canonical-event-presentation.test.ts +0 -255
- package/src/pipeline/event-format.test.ts +0 -828
- package/src/pipeline/event-hints.test.ts +0 -316
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -371
- package/src/pipeline/player-projection.test.ts +0 -247
- package/src/runtime/auto-upgrade.test.ts +0 -66
- package/src/runtime/canonical-event-emitter.test.ts +0 -70
- package/src/runtime/canonical-monitor.test.ts +0 -577
- package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -58
- package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
- package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
- package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
- package/src/runtime/clawclaw/notifications.test.ts +0 -47
- package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
- package/src/runtime/clawclaw/owner.test.ts +0 -203
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -40
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -854
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
- package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
- package/src/runtime/clawclaw-event-catalog.test.ts +0 -126
- package/src/runtime/framework/action-diagnostics.test.ts +0 -81
- package/src/runtime/framework/capability-registry.test.ts +0 -423
- package/src/runtime/framework/control-coordinator.test.ts +0 -675
- package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
- package/src/runtime/framework/events/event-ingress.test.ts +0 -203
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
- package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
- package/src/runtime/framework/mailbox/identity.test.ts +0 -38
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
- package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
- package/src/runtime/framework/participation-manager.test.ts +0 -108
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
- package/src/runtime/framework/state/history/state-history.test.ts +0 -251
- package/src/runtime/framework/state/state-core.test.ts +0 -197
- package/src/runtime/game-sync-protocol.test.ts +0 -123
- package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
- package/src/runtime/mailbox-host-relay.test.ts +0 -293
- package/src/runtime/observability/observability.test.ts +0 -583
- package/src/runtime/owner-control.test.ts +0 -153
- package/src/runtime/parent-process-watch.test.ts +0 -27
- package/src/runtime/pending-event-handoff.test.ts +0 -29
- package/src/runtime/raw-ws-log.test.ts +0 -102
- package/src/runtime/runtime-logger.test.ts +0 -58
- package/src/runtime/runtime-persistence.test.ts +0 -26
- package/src/runtime/runtime.test.ts +0 -1770
- package/src/runtime/ws-client.test.ts +0 -562
- package/src/sdk/behavior-plugin/index.test.ts +0 -74
- package/src/sdk/index.test.ts +0 -45
- package/src/sdk/module-input/index.test.ts +0 -49
- package/src/sdk/perception-plugin/index.test.ts +0 -22
- package/src/sdk/resource-metadata.test.ts +0 -40
- package/src/sdk/trigger-plugin/index.test.ts +0 -41
- package/src/short-command/classifier.test.ts +0 -107
- package/src/short-command/presenter.test.ts +0 -119
- package/src/short-command/runner.test.ts +0 -78
- package/src/short-command/sensitive-data-filter.test.ts +0 -56
- package/src/short-command/transport-response.test.ts +0 -39
- package/src/strategies/custom-module.test.ts +0 -268
- package/src/strategies/game-utils.test.ts +0 -306
- package/src/strategies/goals/avoid-players-top.test.ts +0 -96
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -145
- package/src/strategies/goals/kill-lone-top.test.ts +0 -97
- package/src/strategies/goals/kill-target-top.test.ts +0 -66
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -85
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -113
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -204
- package/src/strategies/goals/task-only-top.test.ts +0 -89
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -139
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/task-only.test.ts +0 -138
|
@@ -1,828 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
compactEventFields,
|
|
4
|
-
compactEventForEvents,
|
|
5
|
-
compactStateForEvents,
|
|
6
|
-
formatEventMessage,
|
|
7
|
-
shortStateText,
|
|
8
|
-
} from './event-format.js';
|
|
9
|
-
import { BACKEND_EVENT_HINT_FORMATTERS } from './event-hints.js';
|
|
10
|
-
|
|
11
|
-
describe('event-format', () => {
|
|
12
|
-
it('formats unified Behavior lifecycle Events', () => {
|
|
13
|
-
expect(formatEventMessage({
|
|
14
|
-
type: 'behavior.completed',
|
|
15
|
-
behavior: 'do-task',
|
|
16
|
-
layer: 'short',
|
|
17
|
-
reason: 'task_completed',
|
|
18
|
-
})).toContain('behavior.completed do-task(short)已完成:task_completed');
|
|
19
|
-
expect(formatEventMessage({
|
|
20
|
-
type: 'behavior.restarted',
|
|
21
|
-
behavior: 'hunt-player',
|
|
22
|
-
layer: 'short',
|
|
23
|
-
})).toContain('behavior.restarted hunt-player(short)已重新启动');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('formats upcoming and active maintenance as explicit service messages', () => {
|
|
27
|
-
const maintenance = {
|
|
28
|
-
starts_at: '2026-08-05T01:00:00+00:00',
|
|
29
|
-
ends_at: '2026-08-05T03:00:00+00:00',
|
|
30
|
-
description: '本次维护将升级匹配服务。',
|
|
31
|
-
};
|
|
32
|
-
expect(formatEventMessage({
|
|
33
|
-
type: 'service_status', service_status: 'maintenance_upcoming', maintenance,
|
|
34
|
-
})).toContain('当前请求仍可继续');
|
|
35
|
-
expect(formatEventMessage({
|
|
36
|
-
type: 'service_status', service_status: 'maintenance_upcoming', maintenance,
|
|
37
|
-
})).toContain(maintenance.description);
|
|
38
|
-
expect(formatEventMessage({
|
|
39
|
-
type: 'service_status', service_status: 'maintenance_active', maintenance,
|
|
40
|
-
})).toContain('新的匹配和房间操作已停止');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('formats killed as a short message and keeps direct compaction separate from presentation ownership', () => {
|
|
44
|
-
const event = {
|
|
45
|
-
type: 'killed',
|
|
46
|
-
tick: 5330,
|
|
47
|
-
room: '情报室',
|
|
48
|
-
killer_name: '哈基米南北绿豆',
|
|
49
|
-
killer_seat: 8,
|
|
50
|
-
hint: 'YOU ARE DEAD: 哈基米南北绿豆 removed you from play. Your hands are off the board now — alert your user, then spectate or leave while your teammates weaponize what you learned.',
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const message = formatEventMessage(event);
|
|
54
|
-
const { hint: _hint, ...facts } = event;
|
|
55
|
-
const formatted = compactEventFields(facts, {}, 1158);
|
|
56
|
-
|
|
57
|
-
expect(message).toContain('t5330 killed');
|
|
58
|
-
expect(message).toContain('8号哈基米南北绿豆');
|
|
59
|
-
expect(formatted).not.toHaveProperty('notice');
|
|
60
|
-
expect(formatted).not.toHaveProperty('hint');
|
|
61
|
-
expect(JSON.stringify(formatted)).not.toContain('Your hands are off the board');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('formats a system killer without a fake player seat', () => {
|
|
65
|
-
const message = formatEventMessage({
|
|
66
|
-
type: 'killed',
|
|
67
|
-
tick: 41,
|
|
68
|
-
room: '制氧舱',
|
|
69
|
-
killer_kind: 'system',
|
|
70
|
-
killer_name: 'Shrimp God',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
expect(message).toContain('被Shrimp God击杀');
|
|
74
|
-
expect(message).not.toContain('?号Shrimp God');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('downgrades self-killer murder_witnessed presentation to neutral diagnostics', () => {
|
|
78
|
-
const message = formatEventMessage({
|
|
79
|
-
type: 'murder_witnessed',
|
|
80
|
-
tick: 42,
|
|
81
|
-
room: '制氧舱',
|
|
82
|
-
killer_name: 'self',
|
|
83
|
-
killer_seat: 1,
|
|
84
|
-
target_name: 'target',
|
|
85
|
-
target_seat: 2,
|
|
86
|
-
}, {
|
|
87
|
-
summary: { you: { player: { name: 'self', seat: 1 } } },
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(message).toContain('已降级为诊断信息');
|
|
91
|
-
expect(message).toContain('不能据此判断任何目击者');
|
|
92
|
-
expect(message).not.toContain('你在制氧舱目击');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('keeps meeting_briefing details aligned with the compact monitor payload', () => {
|
|
96
|
-
const formatted = compactEventFields({
|
|
97
|
-
type: 'meeting_briefing',
|
|
98
|
-
tick: 979,
|
|
99
|
-
room: '会议室',
|
|
100
|
-
meeting_caller_name: '单钳渔夫',
|
|
101
|
-
meeting_caller_seat: 1,
|
|
102
|
-
reported_corpses: [{ name: '丹霞兄', seat: 3 }],
|
|
103
|
-
your_seat: 6,
|
|
104
|
-
all_seats: [{ name: '单钳渔夫', seat: 1 }],
|
|
105
|
-
speech_order: ['单钳渔夫', '洋流王子'],
|
|
106
|
-
crab_teammates: [{ name: '暗礁壳壳', seat: 5 }],
|
|
107
|
-
}, {}, 941);
|
|
108
|
-
|
|
109
|
-
expect(formatted).toMatchObject({
|
|
110
|
-
line: 941,
|
|
111
|
-
type: 'meeting_briefing',
|
|
112
|
-
tick: 979,
|
|
113
|
-
meeting_caller_name: '单钳渔夫',
|
|
114
|
-
meeting_caller_seat: 1,
|
|
115
|
-
reported_corpses: [{ name: '丹霞兄', seat: 3 }],
|
|
116
|
-
your_seat: 6,
|
|
117
|
-
all_seats: [{ name: '单钳渔夫', seat: 1 }],
|
|
118
|
-
speech_order: ['单钳渔夫', '洋流王子'],
|
|
119
|
-
crab_teammates: [{ name: '暗礁壳壳', seat: 5 }],
|
|
120
|
-
});
|
|
121
|
-
expect(formatted).not.toHaveProperty('room');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('hides vote targets in event details', () => {
|
|
125
|
-
const formatted = compactEventFields({
|
|
126
|
-
type: 'vote_cast',
|
|
127
|
-
tick: 3409,
|
|
128
|
-
actor_name: '菜逼油条',
|
|
129
|
-
actor_seat: 8,
|
|
130
|
-
target: '单钳渔夫',
|
|
131
|
-
target_name: '单钳渔夫',
|
|
132
|
-
target_seat: 1,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(formatted).toMatchObject({
|
|
136
|
-
type: 'vote_cast',
|
|
137
|
-
tick: 3409,
|
|
138
|
-
actor_name: '菜逼油条',
|
|
139
|
-
actor_seat: 8,
|
|
140
|
-
});
|
|
141
|
-
expect(formatted).not.toHaveProperty('target');
|
|
142
|
-
expect(formatted).not.toHaveProperty('target_name');
|
|
143
|
-
expect(formatted).not.toHaveProperty('target_seat');
|
|
144
|
-
expect(JSON.stringify(formatted)).not.toContain('单钳渔夫');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('formats meeting result Events as meeting-ended facts with seat-aware votes', () => {
|
|
148
|
-
const ctx = {
|
|
149
|
-
summary: {
|
|
150
|
-
players: [
|
|
151
|
-
{ name: '菜逼油条', seat: 8, known_status: { is_alive: true } },
|
|
152
|
-
{ name: '单钳渔夫', seat: 1, known_status: { is_alive: true } },
|
|
153
|
-
{ name: '暗礁壳壳', seat: 5, known_status: { is_alive: true } },
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
const exile = {
|
|
158
|
-
type: 'exile',
|
|
159
|
-
tick: 3411,
|
|
160
|
-
actor_name: '单钳渔夫',
|
|
161
|
-
votes: {
|
|
162
|
-
菜逼油条: '单钳渔夫',
|
|
163
|
-
暗礁壳壳: 'skip',
|
|
164
|
-
},
|
|
165
|
-
hint: 'backend hint',
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
expect(formatEventMessage(exile, ctx))
|
|
169
|
-
.toBe('t3411 exile 会议结束:1号单钳渔夫被放逐。 Hint: backend hint');
|
|
170
|
-
const { hint: _hint, ...exileFacts } = exile;
|
|
171
|
-
expect(compactEventFields(exileFacts, ctx)).toMatchObject({
|
|
172
|
-
type: 'exile',
|
|
173
|
-
tick: 3411,
|
|
174
|
-
meeting_ended: true,
|
|
175
|
-
result: 'exiled',
|
|
176
|
-
exiled_player: { name: '单钳渔夫', seat: 1 },
|
|
177
|
-
votes: {
|
|
178
|
-
'8号菜逼油条': '1号单钳渔夫',
|
|
179
|
-
'5号暗礁壳壳': 'skip',
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
expect(formatEventMessage({ type: 'no_exile', tick: 3412 }, ctx)).toBe('t3412 no_exile 会议结束:无人被放逐。');
|
|
184
|
-
expect(compactEventFields({ type: 'no_exile', tick: 3412 }, ctx)).toMatchObject({
|
|
185
|
-
type: 'no_exile',
|
|
186
|
-
tick: 3412,
|
|
187
|
-
meeting_ended: true,
|
|
188
|
-
result: 'no_exile',
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('formats death_speech with explicit speaker fields', () => {
|
|
193
|
-
const event = {
|
|
194
|
-
type: 'death_speech',
|
|
195
|
-
tick: 2201,
|
|
196
|
-
actor_name: '旧字段',
|
|
197
|
-
actor_seat: 2,
|
|
198
|
-
speaker_name: '暗礁壳壳',
|
|
199
|
-
speaker_seat: 5,
|
|
200
|
-
text: '我看到2号在尸体旁。',
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
expect(formatEventMessage(event)).toBe('t2201 death_speech 5号暗礁壳壳死亡弹幕:我看到2号在尸体旁。');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('keeps Monitor facts separate and appends the projected Event hint', () => {
|
|
207
|
-
const factual = formatEventMessage({
|
|
208
|
-
type: 'vote_phase_start',
|
|
209
|
-
tick: 3408,
|
|
210
|
-
message: 'Speech phase ended. All alive players, please cast your vote',
|
|
211
|
-
});
|
|
212
|
-
const hint = BACKEND_EVENT_HINT_FORMATTERS.vote_phase_start({}, {}) ?? '';
|
|
213
|
-
const withHint = formatEventMessage({
|
|
214
|
-
type: 'vote_phase_start',
|
|
215
|
-
tick: 3408,
|
|
216
|
-
hint,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(factual).toBe('t3408 vote_phase_start 投票阶段开始。');
|
|
220
|
-
expect(factual).not.toContain('ccl speak');
|
|
221
|
-
expect(factual).not.toContain('ccl vote');
|
|
222
|
-
expect(withHint).toContain(`Hint: ${hint}`);
|
|
223
|
-
expect(withHint).toContain('ccl speak');
|
|
224
|
-
expect(withHint).toContain('ccl vote');
|
|
225
|
-
expect(withHint).not.toContain('ccl do');
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('uses standalone speak and vote commands in Agent hints', () => {
|
|
229
|
-
const speech = BACKEND_EVENT_HINT_FORMATTERS.speech_your_turn({}, {}) ?? '';
|
|
230
|
-
const vote = BACKEND_EVENT_HINT_FORMATTERS.vote_phase_start({}, {}) ?? '';
|
|
231
|
-
const voteNow = BACKEND_EVENT_HINT_FORMATTERS.vote_speech_phase_ended({}, {}) ?? '';
|
|
232
|
-
|
|
233
|
-
expect(speech).toContain('ccl speak');
|
|
234
|
-
expect(vote).toContain('ccl speak');
|
|
235
|
-
expect(vote).toContain('ccl vote');
|
|
236
|
-
expect(vote.indexOf('ccl speak')).toBeLessThan(vote.indexOf('ccl vote'));
|
|
237
|
-
expect(voteNow).toContain('ccl vote');
|
|
238
|
-
expect([speech, vote, voteNow].join('\n')).not.toContain('ccl do');
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('formats game_started as a factual Monitor message plus the projected hint', () => {
|
|
242
|
-
const hint = BACKEND_EVENT_HINT_FORMATTERS.game_started({
|
|
243
|
-
player_count: 10,
|
|
244
|
-
}, {}) ?? '';
|
|
245
|
-
const message = formatEventMessage({
|
|
246
|
-
type: 'game_started',
|
|
247
|
-
tick: 0,
|
|
248
|
-
player_count: 10,
|
|
249
|
-
game_mode: 'competition',
|
|
250
|
-
hint,
|
|
251
|
-
});
|
|
252
|
-
const formatted = compactEventFields({
|
|
253
|
-
type: 'game_started',
|
|
254
|
-
tick: 0,
|
|
255
|
-
player_count: 10,
|
|
256
|
-
game_mode: 'competition',
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
expect(message).toContain('t0 game_started');
|
|
260
|
-
expect(message).toContain('10');
|
|
261
|
-
expect(message).toContain('竞赛模式');
|
|
262
|
-
expect(message).toContain('full Event delivery');
|
|
263
|
-
expect(message).not.toContain('ccl events game_started');
|
|
264
|
-
expect(message).not.toContain('ccl events role_assigned');
|
|
265
|
-
expect(message).toContain(`Hint: ${hint}`);
|
|
266
|
-
expect(formatted).toMatchObject({
|
|
267
|
-
type: 'game_started',
|
|
268
|
-
tick: 0,
|
|
269
|
-
player_count: 10,
|
|
270
|
-
game_mode: 'competition',
|
|
271
|
-
});
|
|
272
|
-
expect(formatted).not.toHaveProperty('hint');
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('formats room readiness as a fact plus the projected confirmation hint', () => {
|
|
276
|
-
const message = formatEventMessage({
|
|
277
|
-
type: 'room_ready_to_start',
|
|
278
|
-
hint: 'The room is ready to start and you are the owner. Ask the user whether to start now before running `ccl game start-room`.',
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
expect(message).toContain('房间已满足开局条件,你是房主。');
|
|
282
|
-
expect(message).toContain('Hint: The room is ready');
|
|
283
|
-
expect(message).toContain('ccl game start-room');
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('formats room game finished as a factual short message', () => {
|
|
287
|
-
const message = formatEventMessage({
|
|
288
|
-
type: 'room.game_finished',
|
|
289
|
-
game_id: 'game-1',
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
expect(message).toContain('上一轮房间对局已结束');
|
|
293
|
-
expect(message).toContain('所有人已回到房间');
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('formats an externally changed training room mode without attributing an origin', () => {
|
|
297
|
-
const event = {
|
|
298
|
-
type: 'room.type_changed',
|
|
299
|
-
previous_room_type: 'training_simulation',
|
|
300
|
-
room_type: 'training_dummy',
|
|
301
|
-
sync_reason: 'room_type_changed',
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
expect(formatEventMessage(event)).toContain('训练房模式已被其他方面从模拟训练切换为木桩训练');
|
|
305
|
-
expect(compactEventFields(event)).not.toHaveProperty('origin');
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('formats current CCL lifecycle Event names as factual messages', () => {
|
|
309
|
-
expect(formatEventMessage({ type: 'match_start' })).toContain('匹配长流已连接');
|
|
310
|
-
expect(formatEventMessage({ type: 'quit_requested' })).toContain('正在结束');
|
|
311
|
-
expect(formatEventMessage({ type: 'room_created', room_code: '123456' })).toContain('123456');
|
|
312
|
-
expect(formatEventMessage({ type: 'room_lobby_reconnect_failed' })).toContain('失败');
|
|
313
|
-
expect(formatEventMessage({
|
|
314
|
-
type: 'behavior.completed', behavior: 'evade', layer: 'short', reason: 'escaped',
|
|
315
|
-
})).toContain('evade(short)已完成:escaped');
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('formats backend Event types that previously fell through to raw names', () => {
|
|
319
|
-
const cases = [
|
|
320
|
-
[{ type: 'move_interrupted', nearby_players: [{ name: 'Alpha', seat: 2 }] }, 'Alpha'],
|
|
321
|
-
[{ type: 'body_dropped', room: 'Room A' }, 'Room A'],
|
|
322
|
-
[{ type: 'speech_next_turn', current_speaker: 'Alpha' }, 'Alpha'],
|
|
323
|
-
[{ type: 'emergency_interrupted', actor_name: 'Alpha', task_name: 'Task A' }, 'Task A'],
|
|
324
|
-
[{ type: 'exile_game_over', winner: 'lobster' }, 'lobster'],
|
|
325
|
-
[{ type: 'octopus_time_win', winner_name: 'Alpha' }, 'Alpha'],
|
|
326
|
-
[{ type: 'win_blocked_by_octopus', blocked_winner: 'lobster', reason: 'tasks' }, 'tasks'],
|
|
327
|
-
] as const;
|
|
328
|
-
|
|
329
|
-
for (const [event, expected] of cases) {
|
|
330
|
-
expect(formatEventMessage(event)).toContain(expected);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it('keeps every nearby player in a move interruption fact', () => {
|
|
335
|
-
const message = formatEventMessage({
|
|
336
|
-
type: 'move_interrupted',
|
|
337
|
-
nearby_players: [
|
|
338
|
-
{ name: 'Alpha', seat: 2 },
|
|
339
|
-
{ name: 'Beta', seat: 3 },
|
|
340
|
-
{ name: 'Gamma', seat: 4 },
|
|
341
|
-
{ name: 'Delta', seat: 5 },
|
|
342
|
-
],
|
|
343
|
-
});
|
|
344
|
-
expect(message).toContain('2号Alpha、3号Beta、4号Gamma、5号Delta');
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it('mentions a newly assigned task only when task_completed carries one', () => {
|
|
348
|
-
expect(formatEventMessage({
|
|
349
|
-
type: 'task_completed',
|
|
350
|
-
task_name: '擦拭酒瓶',
|
|
351
|
-
newly_assigned_task: {
|
|
352
|
-
name: '消毒淋浴器',
|
|
353
|
-
room: '制氧舱',
|
|
354
|
-
x: 123,
|
|
355
|
-
y: 456,
|
|
356
|
-
},
|
|
357
|
-
})).toContain('任务完成:擦拭酒瓶;新分配任务:消毒淋浴器(制氧舱)');
|
|
358
|
-
expect(formatEventMessage({
|
|
359
|
-
type: 'task_completed',
|
|
360
|
-
task_name: '擦拭酒瓶',
|
|
361
|
-
})).toBe('tick=null task_completed 任务完成:擦拭酒瓶。');
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it('removes the duplicate single assignment once a task Event has full list context', () => {
|
|
365
|
-
const compact = compactEventForEvents({
|
|
366
|
-
type: 'task_completed',
|
|
367
|
-
tick: 42,
|
|
368
|
-
task_name: '擦拭酒瓶',
|
|
369
|
-
newly_assigned_task: { name: '消毒淋浴器' },
|
|
370
|
-
reason: 'task_completed',
|
|
371
|
-
delta: [{ change: 'added', task: { name: '消毒淋浴器', status: 'normal' } }],
|
|
372
|
-
tasks: [{ name: '消毒淋浴器', status: 'normal' }],
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
expect(compact).not.toHaveProperty('newly_assigned_task');
|
|
376
|
-
expect(compact).toMatchObject({
|
|
377
|
-
reason: 'task_completed',
|
|
378
|
-
delta: [{ change: 'added', task: { name: '消毒淋浴器', status: 'normal' } }],
|
|
379
|
-
tasks: [{ name: '消毒淋浴器', status: 'normal' }],
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
it('preserves old and new values for a player status delta', () => {
|
|
384
|
-
const compact = compactEventForEvents({
|
|
385
|
-
type: 'players_changed',
|
|
386
|
-
reason: 'player_status_changed',
|
|
387
|
-
changes: [{
|
|
388
|
-
change: 'status_changed',
|
|
389
|
-
name: 'Hidden',
|
|
390
|
-
seat: 2,
|
|
391
|
-
from_status: 'unknown',
|
|
392
|
-
to_status: 'alive',
|
|
393
|
-
}],
|
|
394
|
-
players: [{ name: 'Hidden', seat: 2, status: 'alive', death: null }],
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
expect(compact).toMatchObject({
|
|
398
|
-
changes: [{
|
|
399
|
-
change: 'status_changed',
|
|
400
|
-
name: 'Hidden',
|
|
401
|
-
seat: 2,
|
|
402
|
-
from_status: 'unknown',
|
|
403
|
-
to_status: 'alive',
|
|
404
|
-
}],
|
|
405
|
-
players: [{ name: 'Hidden', seat: 2, status: 'alive', death: null }],
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it('formats room presence and idle lifecycle Events', () => {
|
|
410
|
-
expect(formatEventMessage({
|
|
411
|
-
type: 'room.member_status_changed', agent_id: 'agent-2', status: 'online',
|
|
412
|
-
})).toContain('在线');
|
|
413
|
-
expect(formatEventMessage({
|
|
414
|
-
type: 'room.idle_warning', seconds_remaining: 119,
|
|
415
|
-
})).toContain('119秒后自动销毁');
|
|
416
|
-
expect(formatEventMessage({
|
|
417
|
-
type: 'room_destroyed', reason: 'idle_timeout', close_code: 4005,
|
|
418
|
-
})).toContain('已自动销毁');
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
it('uses custom heartbeat messages when provided', () => {
|
|
422
|
-
expect(formatEventMessage({
|
|
423
|
-
type: 'heartbeat',
|
|
424
|
-
message: '房间 123456 当前 6/10 人,正在等待更多玩家加入。',
|
|
425
|
-
})).toContain('正在等待更多玩家加入');
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it('compacts room waiting state without game player projection', () => {
|
|
429
|
-
const state = compactStateForEvents({
|
|
430
|
-
phase: 'room_waiting',
|
|
431
|
-
you: { name: 'me', seat: 1, is_owner: true },
|
|
432
|
-
room: {
|
|
433
|
-
room_code: '123456',
|
|
434
|
-
room_type: 'casual',
|
|
435
|
-
status: 'waiting',
|
|
436
|
-
member_count: 10,
|
|
437
|
-
cooldown_seconds: 44,
|
|
438
|
-
idle_destroy_at: 1719000900,
|
|
439
|
-
is_owner: true,
|
|
440
|
-
ready_to_start: true,
|
|
441
|
-
members: [{ seat: 1, name: 'me', is_owner: true }],
|
|
442
|
-
},
|
|
443
|
-
}, [
|
|
444
|
-
{ type: 'room_ready_to_start', room_code: '123456' },
|
|
445
|
-
]);
|
|
446
|
-
|
|
447
|
-
expect(state).toMatchObject({
|
|
448
|
-
phase: 'room_waiting',
|
|
449
|
-
you: { name: 'me', seat: 1, is_owner: true },
|
|
450
|
-
room: {
|
|
451
|
-
room_code: '123456',
|
|
452
|
-
status: 'waiting',
|
|
453
|
-
member_count: 10,
|
|
454
|
-
idle_destroy_at: 1719000900,
|
|
455
|
-
ready_to_start: true,
|
|
456
|
-
},
|
|
457
|
-
recent_events: [{ type: 'room_ready_to_start', room_code: '123456' }],
|
|
458
|
-
});
|
|
459
|
-
expect(state).not.toHaveProperty('players');
|
|
460
|
-
expect(state?.room).not.toHaveProperty('cooldown_seconds');
|
|
461
|
-
expect(shortStateText(state)).toContain('ready=confirm-start');
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it('returns the authoritative known-player view alongside the bounded current scene', () => {
|
|
465
|
-
const state = compactStateForEvents({
|
|
466
|
-
phase: 'wandering',
|
|
467
|
-
tick: 120,
|
|
468
|
-
you: {
|
|
469
|
-
player: { name: 'me', seat: 1 },
|
|
470
|
-
x: 100,
|
|
471
|
-
y: 100,
|
|
472
|
-
room: '情报室',
|
|
473
|
-
crab_teammates: [{ name: 'ally', seat: 5 }],
|
|
474
|
-
tasks: [{
|
|
475
|
-
name: '丢垃圾', room: '自助餐厅', x: 321, y: 654,
|
|
476
|
-
status: 'normal', is_fake_shrimp: true,
|
|
477
|
-
}],
|
|
478
|
-
},
|
|
479
|
-
players: [
|
|
480
|
-
{ name: 'me', seat: 1, known_status: { is_alive: true } },
|
|
481
|
-
{ name: 'nearby', seat: 2, known_status: { is_alive: true } },
|
|
482
|
-
{
|
|
483
|
-
name: 'fallen',
|
|
484
|
-
seat: 3,
|
|
485
|
-
known_status: {
|
|
486
|
-
is_alive: false,
|
|
487
|
-
death_cause: 'killed',
|
|
488
|
-
reported_in_current_meeting: true,
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
{ name: 'unknown', seat: 4, known_status: {} },
|
|
492
|
-
],
|
|
493
|
-
visible_players: [{
|
|
494
|
-
player: { name: 'nearby', seat: 2 },
|
|
495
|
-
room: '5号走廊',
|
|
496
|
-
x: 130,
|
|
497
|
-
y: 140,
|
|
498
|
-
role: 'must-not-leak',
|
|
499
|
-
}],
|
|
500
|
-
visible_corpses: [{
|
|
501
|
-
player: { name: 'fallen', seat: 3 },
|
|
502
|
-
room: '情报室',
|
|
503
|
-
x: 60,
|
|
504
|
-
y: 100,
|
|
505
|
-
distance: 8.44,
|
|
506
|
-
agent_id: 'must-not-leak',
|
|
507
|
-
}],
|
|
508
|
-
crab_sabotage: {
|
|
509
|
-
status: 'cooldown_charged',
|
|
510
|
-
cooldown_remaining_secs: 4.25,
|
|
511
|
-
internal_charge_id: 'must-not-leak',
|
|
512
|
-
},
|
|
513
|
-
}, [{
|
|
514
|
-
type: 'corpse_spotted',
|
|
515
|
-
corpse_name: 'fallen',
|
|
516
|
-
corpse_seat: 3,
|
|
517
|
-
}]);
|
|
518
|
-
|
|
519
|
-
expect(state?.visible_players).toEqual([{
|
|
520
|
-
name: 'nearby',
|
|
521
|
-
seat: 2,
|
|
522
|
-
room: '5号走廊',
|
|
523
|
-
relative_direction: '右下',
|
|
524
|
-
distance_px: 50,
|
|
525
|
-
}]);
|
|
526
|
-
expect(state?.you.tasks).toEqual([{
|
|
527
|
-
name: '丢垃圾', room: '自助餐厅', x: 321, y: 654,
|
|
528
|
-
status: 'normal', is_fake_shrimp: true,
|
|
529
|
-
}]);
|
|
530
|
-
expect(state?.you.crab_teammates).toEqual([{ name: 'ally', seat: 5 }]);
|
|
531
|
-
expect(state?.nearby_corpses).toEqual([{
|
|
532
|
-
name: 'fallen',
|
|
533
|
-
seat: 3,
|
|
534
|
-
room: '情报室',
|
|
535
|
-
relative_direction: '左',
|
|
536
|
-
distance_px: 8.4,
|
|
537
|
-
}]);
|
|
538
|
-
expect(state?.crab_sabotage).toEqual({
|
|
539
|
-
status: 'cooldown_charged',
|
|
540
|
-
cooldown_remaining_secs: 4.25,
|
|
541
|
-
});
|
|
542
|
-
expect(state?.players).toEqual([
|
|
543
|
-
{ name: 'me', seat: 1, known_status: { is_alive: true } },
|
|
544
|
-
{ name: 'nearby', seat: 2, known_status: { is_alive: true } },
|
|
545
|
-
{
|
|
546
|
-
name: 'fallen',
|
|
547
|
-
seat: 3,
|
|
548
|
-
known_status: {
|
|
549
|
-
is_alive: false,
|
|
550
|
-
death_cause: 'killed',
|
|
551
|
-
reported_in_current_meeting: true,
|
|
552
|
-
},
|
|
553
|
-
},
|
|
554
|
-
{ name: 'unknown', seat: 4, known_status: {} },
|
|
555
|
-
]);
|
|
556
|
-
expect(state?.visible_players[0]).not.toHaveProperty('x');
|
|
557
|
-
expect(state?.visible_players[0]).not.toHaveProperty('y');
|
|
558
|
-
expect(state?.visible_players[0]).not.toHaveProperty('role');
|
|
559
|
-
expect(state?.nearby_corpses[0]).not.toHaveProperty('agent_id');
|
|
560
|
-
expect(state?.nearby_corpses[0]).not.toHaveProperty('x');
|
|
561
|
-
expect(state?.nearby_corpses[0]).not.toHaveProperty('y');
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it('omits a malformed known-player roster instead of returning partial evidence', () => {
|
|
565
|
-
const state = compactStateForEvents({
|
|
566
|
-
phase: 'wandering',
|
|
567
|
-
you: { player: { name: 'me', seat: 1 } },
|
|
568
|
-
players: [
|
|
569
|
-
{ name: 'me', seat: 1, known_status: { is_alive: true } },
|
|
570
|
-
{ name: 'missing-seat', known_status: {} },
|
|
571
|
-
],
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
expect(state).not.toHaveProperty('players');
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
it('uses separate compact Monitor and detailed ccl events projections for player changes', () => {
|
|
578
|
-
const event = {
|
|
579
|
-
type: 'players_changed',
|
|
580
|
-
tick: 644,
|
|
581
|
-
meeting: true,
|
|
582
|
-
meeting_count: 1,
|
|
583
|
-
changes: [{
|
|
584
|
-
change: 'died',
|
|
585
|
-
name: '陈皮一带四#c7',
|
|
586
|
-
seat: 9,
|
|
587
|
-
cause: 'killed',
|
|
588
|
-
killer: null,
|
|
589
|
-
internal_field: 'must-not-leak',
|
|
590
|
-
}],
|
|
591
|
-
players: [{
|
|
592
|
-
name: 'Alpha',
|
|
593
|
-
seat: 2,
|
|
594
|
-
status: 'alive',
|
|
595
|
-
death: null,
|
|
596
|
-
internal_field: 'must-not-leak',
|
|
597
|
-
}, {
|
|
598
|
-
name: '陈皮一带四#c7',
|
|
599
|
-
seat: 9,
|
|
600
|
-
status: 'dead',
|
|
601
|
-
death: {
|
|
602
|
-
cause: 'killed',
|
|
603
|
-
killer: null,
|
|
604
|
-
source: 'event_log',
|
|
605
|
-
},
|
|
606
|
-
}],
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
expect(formatEventMessage(event)).toBe(
|
|
610
|
-
't644 players_changed 第1次会议中发现9号陈皮一带四#c7已被击杀,凶手未知。',
|
|
611
|
-
);
|
|
612
|
-
expect(compactEventFields(event)).toEqual({
|
|
613
|
-
type: 'players_changed',
|
|
614
|
-
tick: 644,
|
|
615
|
-
meeting: true,
|
|
616
|
-
meeting_count: 1,
|
|
617
|
-
changes: [{
|
|
618
|
-
change: 'died',
|
|
619
|
-
name: '陈皮一带四#c7',
|
|
620
|
-
seat: 9,
|
|
621
|
-
cause: 'killed',
|
|
622
|
-
killer: null,
|
|
623
|
-
}],
|
|
624
|
-
players: [{
|
|
625
|
-
name: 'Alpha',
|
|
626
|
-
seat: 2,
|
|
627
|
-
status: 'alive',
|
|
628
|
-
death: null,
|
|
629
|
-
}, {
|
|
630
|
-
name: '陈皮一带四#c7',
|
|
631
|
-
seat: 9,
|
|
632
|
-
status: 'dead',
|
|
633
|
-
death: {
|
|
634
|
-
cause: 'killed',
|
|
635
|
-
killer: null,
|
|
636
|
-
},
|
|
637
|
-
}],
|
|
638
|
-
});
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
it('keeps explicit empty scene sets and omits scene fields outside raw visual state', () => {
|
|
642
|
-
const emptyScene = compactStateForEvents({
|
|
643
|
-
phase: 'wandering',
|
|
644
|
-
you: { player: { name: 'me', seat: 1 } },
|
|
645
|
-
visible_players: [],
|
|
646
|
-
visible_corpses: [],
|
|
647
|
-
});
|
|
648
|
-
expect(emptyScene).toMatchObject({
|
|
649
|
-
visible_players: [],
|
|
650
|
-
nearby_corpses: [],
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
const meeting = compactStateForEvents({
|
|
654
|
-
phase: 'meeting',
|
|
655
|
-
you: { player: { name: 'me', seat: 1 } },
|
|
656
|
-
meeting: { active: true, sub_phase: 'speech' },
|
|
657
|
-
});
|
|
658
|
-
expect(meeting).not.toHaveProperty('visible_players');
|
|
659
|
-
expect(meeting).not.toHaveProperty('nearby_corpses');
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
it('uses heading sectors for current-scene direction and never calls unprojectable entries empty', () => {
|
|
663
|
-
const nearHorizontal = compactStateForEvents({
|
|
664
|
-
phase: 'wandering',
|
|
665
|
-
you: { player: { name: 'me', seat: 1 }, x: 0, y: 0 },
|
|
666
|
-
visible_players: [{ player: { name: 'other', seat: 2 }, x: 100, y: 1 }],
|
|
667
|
-
visible_corpses: [],
|
|
668
|
-
});
|
|
669
|
-
expect(nearHorizontal?.visible_players).toEqual([{
|
|
670
|
-
name: 'other',
|
|
671
|
-
seat: 2,
|
|
672
|
-
relative_direction: '右',
|
|
673
|
-
distance_px: 100,
|
|
674
|
-
}]);
|
|
675
|
-
|
|
676
|
-
const unavailable = compactStateForEvents({
|
|
677
|
-
phase: 'wandering',
|
|
678
|
-
you: { player: { name: 'me', seat: 1 }, x: 0, y: 0 },
|
|
679
|
-
visible_players: [{ x: 10, y: 10 }],
|
|
680
|
-
visible_corpses: [],
|
|
681
|
-
});
|
|
682
|
-
expect(unavailable).not.toHaveProperty('visible_players');
|
|
683
|
-
expect(unavailable?.nearby_corpses).toEqual([]);
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
it('formats corpse_spotted Monitor messages as my discovery with body owner', () => {
|
|
687
|
-
const message = formatEventMessage({
|
|
688
|
-
type: 'corpse_spotted',
|
|
689
|
-
tick: 3410,
|
|
690
|
-
corpse_name: '丹霞兄',
|
|
691
|
-
corpse_seat: 3,
|
|
692
|
-
corpse_room: '情报室',
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
expect(message).toBe('t3410 corpse_spotted 我发现了3号丹霞兄的尸体,在情报室。');
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
it('describes octopus time without narrowing the trigger to exactly three survivors', () => {
|
|
699
|
-
const event = { type: 'octopus_time_start', tick: 3413 };
|
|
700
|
-
|
|
701
|
-
expect(formatEventMessage(event)).toContain('存活人数已降至3人或更少');
|
|
702
|
-
expect(BACKEND_EVENT_HINT_FORMATTERS.octopus_time_start(event, {})).toContain('At most three players remain');
|
|
703
|
-
expect(BACKEND_EVENT_HINT_FORMATTERS.octopus_time_start(event, {})).toContain('emergency timeout');
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
it('formats emergency countdown and ability transition facts', () => {
|
|
707
|
-
expect(formatEventMessage({
|
|
708
|
-
type: 'emergency_countdown_warning',
|
|
709
|
-
tick: 12,
|
|
710
|
-
task_name: '修复供氧',
|
|
711
|
-
threshold_secs: 30,
|
|
712
|
-
remaining_secs: 29.8,
|
|
713
|
-
})).toBe('t12 emergency_countdown_warning 紧急任务修复供氧只剩29.8秒(30秒提醒)。');
|
|
714
|
-
expect(formatEventMessage({
|
|
715
|
-
type: 'ability.ready',
|
|
716
|
-
tick: 13,
|
|
717
|
-
ability_id: 'kill',
|
|
718
|
-
ability_name: '攻击',
|
|
719
|
-
})).toBe('t13 ability.ready 能力“攻击”现在可以使用。');
|
|
720
|
-
expect(formatEventMessage({
|
|
721
|
-
type: 'ability.exhausted',
|
|
722
|
-
tick: 14,
|
|
723
|
-
ability_id: 'kill',
|
|
724
|
-
ability_name: '攻击',
|
|
725
|
-
})).toBe('t14 ability.exhausted 能力“攻击”已无剩余次数。');
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
it('includes current emergency and stateful abilities in Agent State', () => {
|
|
729
|
-
const state = compactStateForEvents({
|
|
730
|
-
phase: 'wandering',
|
|
731
|
-
tick: 88,
|
|
732
|
-
you: {
|
|
733
|
-
player: { name: 'me', seat: 1 },
|
|
734
|
-
role: 'shrimp_pistol',
|
|
735
|
-
is_alive: true,
|
|
736
|
-
kill_cooldown_secs: 0,
|
|
737
|
-
kills_remaining: 1,
|
|
738
|
-
},
|
|
739
|
-
emergency: {
|
|
740
|
-
active: true,
|
|
741
|
-
task_name: '修复供氧',
|
|
742
|
-
room: '制氧舱',
|
|
743
|
-
x: 120,
|
|
744
|
-
y: 240,
|
|
745
|
-
remaining_secs: 27.5,
|
|
746
|
-
internal_id: 'must-not-leak',
|
|
747
|
-
},
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
expect(state?.emergency).toEqual({
|
|
751
|
-
active: true,
|
|
752
|
-
task_name: '修复供氧',
|
|
753
|
-
room: '制氧舱',
|
|
754
|
-
x: 120,
|
|
755
|
-
y: 240,
|
|
756
|
-
remaining_secs: 27.5,
|
|
757
|
-
});
|
|
758
|
-
expect(state?.abilities).toEqual([{
|
|
759
|
-
id: 'kill',
|
|
760
|
-
name: '攻击',
|
|
761
|
-
ready: true,
|
|
762
|
-
cooldown_remaining_secs: 0,
|
|
763
|
-
remaining_uses: 1,
|
|
764
|
-
effective_range_px: 160,
|
|
765
|
-
}]);
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
it('tells every surviving role that emergency repair is real and available', () => {
|
|
769
|
-
const hint = BACKEND_EVENT_HINT_FORMATTERS.emergency_started({
|
|
770
|
-
type: 'emergency_started',
|
|
771
|
-
task_name: '修复氧气',
|
|
772
|
-
room: '控制室',
|
|
773
|
-
timeout_secs: 80,
|
|
774
|
-
}, {});
|
|
775
|
-
|
|
776
|
-
expect(hint).toContain('Any surviving role can complete this real emergency repair');
|
|
777
|
-
expect(hint).not.toContain('Lobsters —');
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
it('states when a meeting, rather than a player, resolves an emergency', () => {
|
|
781
|
-
const event = {
|
|
782
|
-
type: 'emergency_resolved',
|
|
783
|
-
task_name: '修复氧气',
|
|
784
|
-
reason: 'meeting_started',
|
|
785
|
-
};
|
|
786
|
-
|
|
787
|
-
expect(formatEventMessage(event)).toContain('会议开始');
|
|
788
|
-
expect(formatEventMessage(event)).toContain('自动解除');
|
|
789
|
-
const hint = BACKEND_EVENT_HINT_FORMATTERS.emergency_resolved(event, {});
|
|
790
|
-
expect(hint).toContain('Meeting started');
|
|
791
|
-
expect(hint).toContain('No player completed the repair');
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
it('distinguishes a private self repair from an anonymous emergency resolution', () => {
|
|
795
|
-
const self = { type: 'emergency_resolved', task_name: 'repair oxygen', resolved_by_self: true };
|
|
796
|
-
const anonymous = { type: 'emergency_resolved', task_name: 'repair oxygen' };
|
|
797
|
-
|
|
798
|
-
expect(formatEventMessage(self)).toContain('你已解决');
|
|
799
|
-
expect(BACKEND_EVENT_HINT_FORMATTERS.emergency_resolved(self, {})).toContain('You resolved');
|
|
800
|
-
expect(BACKEND_EVENT_HINT_FORMATTERS.emergency_resolved(anonymous, {}))
|
|
801
|
-
.toContain("identity is not visible to you");
|
|
802
|
-
});
|
|
803
|
-
|
|
804
|
-
it('keeps local hint formatters for backend-hinted monitor events', () => {
|
|
805
|
-
const backendHintedMonitorEvents = [
|
|
806
|
-
'corpse_spotted',
|
|
807
|
-
'emergency_resolved',
|
|
808
|
-
'emergency_started',
|
|
809
|
-
'exile',
|
|
810
|
-
'game_over',
|
|
811
|
-
'game_started',
|
|
812
|
-
'kill',
|
|
813
|
-
'killed',
|
|
814
|
-
'meeting_briefing',
|
|
815
|
-
'murder_witnessed',
|
|
816
|
-
'no_exile',
|
|
817
|
-
'octopus_time_start',
|
|
818
|
-
'role_assigned',
|
|
819
|
-
'speech_skipped',
|
|
820
|
-
'vote_phase_start',
|
|
821
|
-
'vote_speech_phase_ended',
|
|
822
|
-
];
|
|
823
|
-
|
|
824
|
-
for (const type of backendHintedMonitorEvents) {
|
|
825
|
-
expect(BACKEND_EVENT_HINT_FORMATTERS[type], type).toBeTypeOf('function');
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
});
|