@myclaw163/clawclaw-cli 0.7.15 → 0.8.1
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_HERMES.md +1 -1
- package/QUICKSTART_OPENCLAW.md +3 -11
- package/QUICKSTART_OTHER.md +8 -8
- package/README.md +18 -9
- package/bin/clawclaw-channel.mjs +13 -0
- package/docs/configuration.md +86 -33
- package/docs/custom-modules/README.md +148 -0
- package/docs/custom-modules/api-reference.md +767 -0
- package/docs/custom-modules/behavior.md +318 -0
- package/docs/custom-modules/perception.md +305 -0
- package/docs/custom-modules/trigger.md +292 -0
- package/docs/desktop-event-push.md +6 -4
- package/docs/runtime/README.md +28 -10
- package/docs/runtime/agent-notifications.md +48 -29
- package/docs/runtime/behavior-runtime.md +139 -0
- package/docs/runtime/components-and-boundaries.md +89 -173
- package/docs/runtime/events-and-state.md +55 -66
- package/docs/runtime/official-perception-modules.md +17 -9
- package/docs/runtime/owner-lifecycle-and-observability.md +62 -39
- package/docs/runtime/perception-replay.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +35 -37
- package/package.json +7 -4
- package/scripts/check-skill-command-surface.mjs +54 -10
- package/scripts/compare-perception-replays.test.ts +10 -10
- package/scripts/compare-perception-replays.ts +14 -10
- package/scripts/replay-perception.ts +3 -3
- package/scripts/watch-perception-events.test.ts +1 -1
- package/skills/clawclaw/SKILL.md +97 -59
- package/skills/clawclaw/references/BEHAVIORS.md +154 -0
- package/skills/clawclaw/references/CHANNELS.md +115 -0
- package/skills/clawclaw/references/CHATTERBOX.md +3 -2
- package/skills/clawclaw/references/COMMANDS.md +108 -58
- package/skills/clawclaw/references/GAME-MECHANICS.md +4 -3
- package/skills/clawclaw/references/HUB.md +27 -23
- package/skills/clawclaw/references/STREAM.md +18 -14
- package/skills/clawclaw/references/TACTICS.md +2 -2
- package/src/behaviors/official-finite/do-task.ts +141 -0
- package/src/behaviors/official-finite/evade.ts +78 -0
- package/src/behaviors/official-finite/find-player.ts +50 -0
- package/src/behaviors/official-finite/follow-player.ts +70 -0
- package/src/behaviors/official-finite/go-to.ts +69 -0
- package/src/behaviors/official-finite/hide-temporarily.ts +77 -0
- package/src/behaviors/official-finite/hold-position.ts +48 -0
- package/src/behaviors/official-finite/hunt-player.ts +47 -0
- package/src/behaviors/official-finite/index.test.ts +202 -0
- package/src/behaviors/official-finite/index.ts +47 -0
- package/src/behaviors/official-finite/inspect-corpse.ts +64 -0
- package/src/behaviors/official-finite/patrol-area.ts +80 -0
- package/src/behaviors/official-finite/report-corpse.ts +73 -0
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +152 -0
- package/src/behaviors/official-finite/shared.ts +27 -0
- package/src/behaviors/official-finite/trigger-alarm.ts +53 -0
- package/src/channel/claude-channel-ipc-server.ts +295 -0
- package/src/channel/claude-channel-ipc.ts +152 -0
- package/src/channel/claude-channel-server.test.ts +202 -0
- package/src/channel/claude-channel-server.ts +221 -0
- package/src/cli.ts +4 -2
- package/src/commands/account.test.ts +17 -17
- package/src/commands/behavior.test.ts +158 -0
- package/src/commands/behavior.ts +443 -0
- package/src/commands/communication.test.ts +12 -0
- package/src/commands/communication.ts +6 -3
- package/src/commands/data.test.ts +1 -1
- package/src/commands/data.ts +1 -1
- package/src/commands/events-canonical-state.test.ts +221 -2
- package/src/commands/events.ts +205 -12
- package/src/commands/game/index.test.ts +172 -3
- package/src/commands/game/index.ts +69 -32
- package/src/commands/hub.test.ts +25 -14
- package/src/commands/hub.ts +15 -19
- package/src/commands/load.test.ts +228 -6
- package/src/commands/load.ts +102 -18
- package/src/commands/memory.ts +1 -1
- package/src/commands/peek.ts +1 -1
- package/src/commands/perception.test.ts +30 -1
- package/src/commands/perception.ts +15 -17
- package/src/commands/trigger.test.ts +140 -0
- package/src/commands/trigger.ts +314 -0
- package/src/lib/account-guidance.test.ts +4 -0
- package/src/lib/account-guidance.ts +1 -1
- package/src/lib/behavior-export.test.ts +282 -0
- package/src/lib/behavior-export.ts +514 -0
- package/src/lib/game-client.test.ts +4 -17
- package/src/lib/game-client.ts +3 -0
- package/src/lib/gameplay-config.test.ts +258 -37
- package/src/lib/gameplay-config.ts +175 -35
- package/src/lib/hub-install.test.ts +19 -41
- package/src/lib/hub-install.ts +10 -38
- package/src/lib/hub-reminder.ts +7 -9
- package/src/lib/init-command.ts +1 -1
- package/src/lib/official-resource-sync.test.ts +199 -0
- package/src/lib/official-resource-sync.ts +221 -0
- package/src/lib/perception-config.test.ts +9 -4
- package/src/lib/perception-config.ts +10 -13
- package/src/lib/perception-export.test.ts +145 -0
- package/src/lib/perception-export.ts +178 -0
- package/src/lib/trigger-config.test.ts +102 -0
- package/src/lib/trigger-config.ts +217 -0
- package/src/lib/user-data.test.ts +23 -6
- package/src/lib/user-data.ts +15 -123
- package/src/pipeline/canonical-event-presentation.test.ts +5 -5
- package/src/pipeline/canonical-event-presentation.ts +13 -5
- package/src/pipeline/event-format.test.ts +106 -3
- package/src/pipeline/event-format.ts +172 -4
- package/src/pipeline/event-hints.test.ts +57 -4
- package/src/pipeline/event-hints.ts +34 -8
- package/src/runtime/canonical-monitor.test.ts +2 -0
- package/src/runtime/canonical-monitor.ts +6 -2
- package/src/runtime/clawclaw/agent-event-policy.test.ts +23 -2
- package/src/runtime/clawclaw/agent-event-policy.ts +12 -5
- package/src/runtime/clawclaw/behavior-decision.test.ts +29 -0
- package/src/runtime/clawclaw/behavior-decision.ts +82 -0
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +175 -0
- package/src/runtime/clawclaw/behavior-input-fields.ts +270 -0
- package/src/runtime/clawclaw/behavior-input.test.ts +151 -0
- package/src/runtime/clawclaw/behavior-input.ts +70 -0
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +59 -0
- package/src/runtime/clawclaw/behavior-observation-memory.ts +142 -0
- package/src/runtime/clawclaw/behavior-read-api.test.ts +123 -0
- package/src/runtime/clawclaw/behavior-read-api.ts +158 -0
- package/src/runtime/clawclaw/{plugins/perception/visual-state-projector.ts → observation-frame-projector.ts} +44 -25
- package/src/runtime/clawclaw/owner.test.ts +187 -0
- package/src/runtime/clawclaw/owner.ts +431 -69
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +304 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +286 -41
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +82 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +135 -29
- package/src/runtime/clawclaw/plugins/assembly.ts +54 -28
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +468 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +40 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.ts +30 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +152 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +156 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +104 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-manifest.ts +173 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +182 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +223 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +157 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +848 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +1347 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +212 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +174 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +621 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +195 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/index.ts +11 -0
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +766 -0
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +283 -0
- package/src/runtime/clawclaw/plugins/{strategy/thread-strategy-executor.ts → behavior/thread-behavior-executor.ts} +109 -121
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +80 -0
- package/src/runtime/clawclaw/plugins/behavior-input-source.ts +247 -0
- package/src/runtime/clawclaw/plugins/{strategy → game-query}/context-capabilities.ts +1 -1
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +13 -10
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +26 -14
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +3 -1
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +239 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +100 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +346 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +230 -12
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +118 -90
- package/src/runtime/clawclaw/plugins/mailbox/consumer-ids.ts +5 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +1 -1
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +4 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +87 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +70 -12
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +94 -11
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1229 -345
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +479 -35
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -3
- package/src/runtime/clawclaw/plugins/perception/index.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +23 -13
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +11 -9
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +39 -38
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +92 -0
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +248 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +39 -37
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +22 -21
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +15 -9
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +3 -3
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +33 -18
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +22 -16
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +18 -12
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +14 -10
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +20 -14
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +49 -34
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +126 -20
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +24 -3
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +59 -46
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +27 -5
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +381 -49
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +267 -245
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +98 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +89 -16
- package/src/runtime/clawclaw/plugins/perception/perception-test-fixtures.ts +34 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +27 -15
- package/src/runtime/clawclaw/plugins/perception/replay.ts +10 -5
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +1 -107
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +7 -10
- package/src/runtime/clawclaw/plugins/plugin-api-version.ts +112 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +389 -559
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +56 -5
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +135 -26
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +249 -16
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +99 -2
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.ts +259 -0
- package/src/runtime/clawclaw/plugins/trigger/contracts.ts +97 -0
- package/src/runtime/clawclaw/plugins/trigger/index.ts +4 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +118 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +548 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +655 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +169 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.ts +457 -0
- package/src/runtime/clawclaw/runtime.ts +8 -0
- package/src/runtime/clawclaw/spatial-api.ts +76 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +46 -1
- package/src/runtime/clawclaw-event-catalog.ts +40 -3
- package/src/runtime/framework/capability-registry.test.ts +196 -55
- package/src/runtime/framework/capability-registry.ts +99 -17
- package/src/runtime/framework/contracts.ts +30 -4
- package/src/runtime/framework/control/control-scheduler.ts +13 -5
- package/src/runtime/framework/control/types.ts +11 -4
- package/src/runtime/framework/control-coordinator.test.ts +95 -80
- package/src/runtime/framework/events/event-delivery-service.ts +4 -2
- package/src/runtime/framework/events/event-ingress.test.ts +25 -0
- package/src/runtime/framework/events/event-ingress.ts +2 -1
- package/src/runtime/framework/events/event-repository.ts +24 -2
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +124 -8
- package/src/runtime/framework/events/memory-event-repository.ts +92 -28
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +604 -2
- package/src/runtime/framework/events/sqlite-event-repository.ts +531 -21
- package/src/runtime/framework/events/types.ts +24 -8
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +38 -1
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +233 -7
- package/src/runtime/framework/modules/runtime-module-loader.ts +69 -4
- package/src/runtime/framework/plugins/contracts.ts +12 -18
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +81 -71
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +38 -20
- package/src/runtime/framework/runtime.ts +20 -23
- package/src/runtime/host-monitor-rate-gate.test.ts +73 -0
- package/src/runtime/host-monitor-rate-gate.ts +123 -0
- package/src/runtime/mailbox-host-relay.test.ts +45 -0
- package/src/runtime/mailbox-host-relay.ts +25 -0
- package/src/runtime/observability/factory.ts +4 -4
- package/src/runtime/observability/observability.test.ts +25 -3
- package/src/runtime/observability/reporter.ts +1 -1
- package/src/runtime/observability/types.ts +2 -2
- package/src/runtime/owner-control.ts +10 -2
- package/src/runtime/runtime-logger.test.ts +1 -1
- package/src/runtime/runtime-logger.ts +4 -6
- package/src/runtime/runtime.test.ts +88 -22
- package/src/sdk/action.ts +2 -2
- package/src/sdk/behavior-plugin/index.test.ts +74 -0
- package/src/sdk/behavior-plugin/index.ts +335 -0
- package/src/sdk/behavior-toolkit/corpse-search.ts +87 -0
- package/src/sdk/behavior-toolkit/escape.ts +40 -0
- package/src/sdk/behavior-toolkit/index.ts +7 -0
- package/src/sdk/behavior-toolkit/kill-flow.ts +299 -0
- package/src/sdk/behavior-toolkit/model.ts +263 -0
- package/src/sdk/behavior-toolkit/move-gate.ts +52 -0
- package/src/sdk/behavior-toolkit/patrol.ts +53 -0
- package/src/sdk/behavior-toolkit/search.ts +102 -0
- package/src/sdk/index.test.ts +45 -0
- package/src/sdk/index.ts +67 -73
- package/src/sdk/module-input/index.test.ts +49 -0
- package/src/sdk/module-input/index.ts +229 -0
- package/src/sdk/perception-plugin/index.test.ts +2 -2
- package/src/sdk/perception-plugin/index.ts +51 -142
- package/src/sdk/perception-plugin/math.ts +107 -0
- package/src/sdk/trigger-plugin/index.test.ts +41 -0
- package/src/sdk/trigger-plugin/index.ts +128 -0
- package/src/strategies/avoid-lone.ts +21 -10
- package/src/strategies/avoid-players.ts +26 -16
- package/src/strategies/corpse-patrol.ts +25 -14
- package/src/strategies/crab-sabotage.ts +20 -9
- package/src/strategies/find-player.ts +33 -21
- package/src/strategies/game-utils.ts +1 -1
- package/src/strategies/goals/crab-sabotage-top.test.ts +145 -0
- package/src/strategies/goals/crab-sabotage-top.ts +32 -69
- package/src/strategies/hide.ts +25 -15
- package/src/strategies/kill-frenzy.ts +21 -10
- package/src/strategies/kill-lone.ts +27 -17
- package/src/strategies/kill-target.ts +33 -22
- package/src/strategies/lone-kill-task.ts +20 -9
- package/src/strategies/move-room.ts +29 -18
- package/src/strategies/official-long-behavior.test.ts +89 -0
- package/src/strategies/paradise-fish.ts +29 -18
- package/src/strategies/pathfind/astar-path.test.ts +127 -2
- package/src/strategies/pathfind/astar-path.ts +136 -26
- package/src/strategies/patrol.ts +21 -10
- package/src/strategies/player-targets.test.ts +10 -0
- package/src/strategies/player-targets.ts +13 -0
- package/src/strategies/report-patrol.ts +21 -10
- package/src/strategies/shrimp-memory.ts +30 -19
- package/src/strategies/social-task.ts +34 -23
- package/src/strategies/task-kill-report.ts +33 -22
- package/src/strategies/task-only.test.ts +99 -85
- package/src/strategies/task-only.ts +23 -12
- package/src/strategies/task-report.ts +25 -14
- package/src/strategies/types.ts +8 -8
- package/src/strategies/warrior-memory.ts +29 -19
- package/docs/runtime/strategy-runtime.md +0 -111
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +0 -502
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +0 -395
- package/skills/clawclaw/references/STRATEGIES.md +0 -76
- package/src/commands/strategy.test.ts +0 -209
- package/src/commands/strategy.ts +0 -242
- package/src/lib/strategy-export.test.ts +0 -406
- package/src/lib/strategy-export.ts +0 -381
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +0 -31
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +0 -177
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +0 -191
- package/src/runtime/clawclaw/plugins/strategy/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +0 -412
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +0 -80
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +0 -183
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +0 -29
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +0 -693
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +0 -57
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +0 -168
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +0 -1994
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +0 -1579
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +0 -153
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +0 -443
- package/src/sdk/strategy-plugin/index.test.ts +0 -958
- package/src/sdk/strategy-plugin/index.ts +0 -1350
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
compactEventFields,
|
|
4
|
+
compactEventForEvents,
|
|
5
|
+
compactStateForEvents,
|
|
6
|
+
formatEventMessage,
|
|
7
|
+
shortStateText,
|
|
8
|
+
} from './event-format.js';
|
|
3
9
|
import { BACKEND_EVENT_HINT_FORMATTERS } from './event-hints.js';
|
|
4
10
|
|
|
5
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
|
+
|
|
6
26
|
it('formats upcoming and active maintenance as explicit service messages', () => {
|
|
7
27
|
const maintenance = {
|
|
8
28
|
starts_at: '2026-08-05T01:00:00+00:00',
|
|
@@ -54,6 +74,24 @@ describe('event-format', () => {
|
|
|
54
74
|
expect(message).not.toContain('?号Shrimp God');
|
|
55
75
|
});
|
|
56
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
|
+
|
|
57
95
|
it('keeps meeting_briefing details aligned with the compact monitor payload', () => {
|
|
58
96
|
const formatted = compactEventFields({
|
|
59
97
|
type: 'meeting_briefing',
|
|
@@ -221,7 +259,7 @@ describe('event-format', () => {
|
|
|
221
259
|
expect(message).toContain('t0 game_started');
|
|
222
260
|
expect(message).toContain('10');
|
|
223
261
|
expect(message).toContain('竞赛模式');
|
|
224
|
-
expect(message).toContain('
|
|
262
|
+
expect(message).toContain('full Event delivery');
|
|
225
263
|
expect(message).not.toContain('ccl events game_started');
|
|
226
264
|
expect(message).not.toContain('ccl events role_assigned');
|
|
227
265
|
expect(message).toContain(`Hint: ${hint}`);
|
|
@@ -272,6 +310,9 @@ describe('event-format', () => {
|
|
|
272
310
|
expect(formatEventMessage({ type: 'quit_requested' })).toContain('正在结束');
|
|
273
311
|
expect(formatEventMessage({ type: 'room_created', room_code: '123456' })).toContain('123456');
|
|
274
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');
|
|
275
316
|
});
|
|
276
317
|
|
|
277
318
|
it('formats backend Event types that previously fell through to raw names', () => {
|
|
@@ -290,6 +331,19 @@ describe('event-format', () => {
|
|
|
290
331
|
}
|
|
291
332
|
});
|
|
292
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
|
+
|
|
293
347
|
it('mentions a newly assigned task only when task_completed carries one', () => {
|
|
294
348
|
expect(formatEventMessage({
|
|
295
349
|
type: 'task_completed',
|
|
@@ -307,6 +361,51 @@ describe('event-format', () => {
|
|
|
307
361
|
})).toBe('tick=null task_completed 任务完成:擦拭酒瓶。');
|
|
308
362
|
});
|
|
309
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
|
+
|
|
310
409
|
it('formats room presence and idle lifecycle Events', () => {
|
|
311
410
|
expect(formatEventMessage({
|
|
312
411
|
type: 'room.member_status_changed', agent_id: 'agent-2', status: 'online',
|
|
@@ -401,6 +500,8 @@ describe('event-format', () => {
|
|
|
401
500
|
visible_corpses: [{
|
|
402
501
|
player: { name: 'fallen', seat: 3 },
|
|
403
502
|
room: '情报室',
|
|
503
|
+
x: 60,
|
|
504
|
+
y: 100,
|
|
404
505
|
distance: 8.44,
|
|
405
506
|
agent_id: 'must-not-leak',
|
|
406
507
|
}],
|
|
@@ -431,6 +532,7 @@ describe('event-format', () => {
|
|
|
431
532
|
name: 'fallen',
|
|
432
533
|
seat: 3,
|
|
433
534
|
room: '情报室',
|
|
535
|
+
relative_direction: '左',
|
|
434
536
|
distance_px: 8.4,
|
|
435
537
|
}]);
|
|
436
538
|
expect(state?.crab_sabotage).toEqual({
|
|
@@ -455,7 +557,8 @@ describe('event-format', () => {
|
|
|
455
557
|
expect(state?.visible_players[0]).not.toHaveProperty('y');
|
|
456
558
|
expect(state?.visible_players[0]).not.toHaveProperty('role');
|
|
457
559
|
expect(state?.nearby_corpses[0]).not.toHaveProperty('agent_id');
|
|
458
|
-
expect(state?.nearby_corpses[0]).not.toHaveProperty('
|
|
560
|
+
expect(state?.nearby_corpses[0]).not.toHaveProperty('x');
|
|
561
|
+
expect(state?.nearby_corpses[0]).not.toHaveProperty('y');
|
|
459
562
|
});
|
|
460
563
|
|
|
461
564
|
it('omits a malformed known-player roster instead of returning partial evidence', () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { projectPlayers } from './player-projection.js';
|
|
2
2
|
import { headingDirection } from '../runtime/clawclaw/plugins/perception/shared/math.js';
|
|
3
3
|
import { isRoomMode } from '../lib/room.js';
|
|
4
|
+
import { isSelfKillerMurderWitnessed } from './event-hints.js';
|
|
4
5
|
|
|
5
6
|
export interface EventFormatContext {
|
|
6
7
|
summary?: any | null;
|
|
@@ -121,7 +122,7 @@ function projectCurrentScene(
|
|
|
121
122
|
};
|
|
122
123
|
return cleanObject({
|
|
123
124
|
visible_players: projectList(summary.visible_players, true),
|
|
124
|
-
nearby_corpses: projectList(summary.visible_corpses,
|
|
125
|
+
nearby_corpses: projectList(summary.visible_corpses, true),
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -328,6 +329,9 @@ function playersChangedBody(event: Record<string, any>, ctx: EventFormatContext)
|
|
|
328
329
|
if (change.change === 'discovered') {
|
|
329
330
|
return `发现${playerLabel(change.name, numberValue(change.seat), ctx)}`;
|
|
330
331
|
}
|
|
332
|
+
if (change.change === 'status_changed') {
|
|
333
|
+
return `${playerLabel(change.name, numberValue(change.seat), ctx)}状态由${text(change.from_status)}变为${text(change.to_status)}`;
|
|
334
|
+
}
|
|
331
335
|
const death = playerChangeDeathText(change, ctx);
|
|
332
336
|
return change.change === 'death_updated' ? `${death}(死亡信息更新)` : death;
|
|
333
337
|
}).join(';');
|
|
@@ -373,6 +377,9 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
373
377
|
case 'killed':
|
|
374
378
|
return `你在${firstString(event, ['room'])}被${killerLabel(event.killer_name, firstNumber(event, ['killer_seat', 'killer_player_seat']), event.killer_kind, ctx)}击杀了,你已死亡。`;
|
|
375
379
|
case 'murder_witnessed':
|
|
380
|
+
if (isSelfKillerMurderWitnessed(event, ctx.summary)) {
|
|
381
|
+
return '收到一条与自身击杀身份冲突的 murder_witnessed 事件;该事件已降级为诊断信息,不能据此判断任何目击者。';
|
|
382
|
+
}
|
|
376
383
|
return `你在${firstString(event, ['room'])}目击${playerLabel(event.killer_name, firstNumber(event, ['killer_seat', 'killer_player_seat']), ctx)}击杀${playerLabel(event.target_name, firstNumber(event, ['target_seat', 'target_player_seat']), ctx)}。`;
|
|
377
384
|
case 'warrior_shrimp_self_destruct':
|
|
378
385
|
return `你误杀了${playerLabel(event.target_name, firstNumber(event, ['target_seat', 'target_player_seat']), ctx)},武士虾自爆出局。`;
|
|
@@ -396,12 +403,13 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
396
403
|
}
|
|
397
404
|
case 'task_sabotaged':
|
|
398
405
|
return `破坏任务完成:${firstString(event, ['task_name'])}(${firstString(event, ['room'])})。`;
|
|
406
|
+
case 'tasks_changed':
|
|
407
|
+
return `任务列表已更新(${firstString(event, ['reason'])})。`;
|
|
399
408
|
case 'players_changed':
|
|
400
409
|
return playersChangedBody(event, ctx);
|
|
401
410
|
case 'move_interrupted': {
|
|
402
411
|
const nearby = Array.isArray(event.nearby_players)
|
|
403
412
|
? event.nearby_players
|
|
404
|
-
.slice(0, 3)
|
|
405
413
|
.map((player: any) => playerLabel(player?.name, numberValue(player?.seat), ctx))
|
|
406
414
|
.filter(Boolean)
|
|
407
415
|
: [];
|
|
@@ -571,6 +579,35 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
571
579
|
return `发言提示:${truncate(event.message ?? event.text, maxTextLength)}`;
|
|
572
580
|
case 'strategy_alert':
|
|
573
581
|
return truncate(event.message ?? event.text, maxTextLength);
|
|
582
|
+
case 'behavior.started':
|
|
583
|
+
case 'behavior.restarted':
|
|
584
|
+
case 'behavior.suspended':
|
|
585
|
+
case 'behavior.completed':
|
|
586
|
+
case 'behavior.failed':
|
|
587
|
+
case 'behavior.cancelled':
|
|
588
|
+
case 'behavior.replaced': {
|
|
589
|
+
const behavior = text(event.behavior, 'behavior');
|
|
590
|
+
const layer = typeof event.layer === 'string' && event.layer.length > 0
|
|
591
|
+
? `(${event.layer})`
|
|
592
|
+
: '';
|
|
593
|
+
const action = event.type === 'behavior.started'
|
|
594
|
+
? '已启动'
|
|
595
|
+
: event.type === 'behavior.restarted'
|
|
596
|
+
? '已重新启动'
|
|
597
|
+
: event.type === 'behavior.suspended'
|
|
598
|
+
? '已暂停'
|
|
599
|
+
: event.type === 'behavior.completed'
|
|
600
|
+
? '已完成'
|
|
601
|
+
: event.type === 'behavior.failed'
|
|
602
|
+
? '执行失败'
|
|
603
|
+
: event.type === 'behavior.cancelled'
|
|
604
|
+
? '已取消'
|
|
605
|
+
: '已被替换';
|
|
606
|
+
const reason = typeof event.reason === 'string' && event.reason.length > 0
|
|
607
|
+
? `:${event.reason}`
|
|
608
|
+
: '';
|
|
609
|
+
return `${behavior}${layer}${action}${reason}`;
|
|
610
|
+
}
|
|
574
611
|
case 'game_start':
|
|
575
612
|
return '事件流已连接,等待身份分配。';
|
|
576
613
|
case 'heartbeat':
|
|
@@ -605,12 +642,18 @@ function taskKindForEvents(task: any, event: Record<string, any>): string | unde
|
|
|
605
642
|
}
|
|
606
643
|
|
|
607
644
|
function compactRoleAssignedForEvents(event: Record<string, any>): FormattedEvent {
|
|
608
|
-
const
|
|
609
|
-
? event.
|
|
645
|
+
const sourceTasks = Array.isArray(event.tasks)
|
|
646
|
+
? event.tasks
|
|
647
|
+
: Array.isArray(event.assigned_tasks) ? event.assigned_tasks : undefined;
|
|
648
|
+
const tasks = Array.isArray(sourceTasks)
|
|
649
|
+
? sourceTasks.map((task: any) => cleanObject({
|
|
650
|
+
task_id: task?.task_id,
|
|
610
651
|
name: task?.name,
|
|
611
652
|
room: task?.room,
|
|
612
653
|
x: task?.x,
|
|
613
654
|
y: task?.y,
|
|
655
|
+
status: task?.status,
|
|
656
|
+
task_note: task?.task_note,
|
|
614
657
|
kind: taskKindForEvents(task, event),
|
|
615
658
|
}))
|
|
616
659
|
: undefined;
|
|
@@ -637,6 +680,8 @@ function compactRoleAssignedForEvents(event: Record<string, any>): FormattedEven
|
|
|
637
680
|
task_kind: useTopLevelTaskKind ? taskKinds[0] : undefined,
|
|
638
681
|
task_note: hasFakeTask ? 'Fake shrimp tasks: disguise only; no lobster progress.' : undefined,
|
|
639
682
|
tasks: compactTasks,
|
|
683
|
+
reason: event.reason,
|
|
684
|
+
delta: event.delta,
|
|
640
685
|
});
|
|
641
686
|
}
|
|
642
687
|
|
|
@@ -689,6 +734,8 @@ function compactPlayersChangedForEvents(event: Record<string, any>): FormattedEv
|
|
|
689
734
|
seat: numberValue(change.seat),
|
|
690
735
|
cause: change.cause,
|
|
691
736
|
killer: change.killer,
|
|
737
|
+
from_status: change.from_status,
|
|
738
|
+
to_status: change.to_status,
|
|
692
739
|
}))
|
|
693
740
|
: [];
|
|
694
741
|
const players = Array.isArray(event.players)
|
|
@@ -713,6 +760,7 @@ function compactPlayersChangedForEvents(event: Record<string, any>): FormattedEv
|
|
|
713
760
|
tick: numberValue(event.tick) ?? null,
|
|
714
761
|
meeting: event.meeting === true ? true : undefined,
|
|
715
762
|
meeting_count: numberValue(event.meeting_count),
|
|
763
|
+
reason: event.reason,
|
|
716
764
|
changes,
|
|
717
765
|
players,
|
|
718
766
|
});
|
|
@@ -736,6 +784,14 @@ export function compactEventForEvents(
|
|
|
736
784
|
if (event.type === 'vote_cast') return compactVoteCastForEvents(event, ctx);
|
|
737
785
|
if (event.type === 'exile' || event.type === 'no_exile') return compactMeetingResultForEvents(event, ctx);
|
|
738
786
|
if (event.type === 'players_changed') return compactPlayersChangedForEvents(event);
|
|
787
|
+
if (event.type === 'task_completed' && Array.isArray(event.tasks) && Array.isArray(event.delta)) {
|
|
788
|
+
const { newly_assigned_task: _duplicateAssignment, ...rest } = event;
|
|
789
|
+
return cleanObject({
|
|
790
|
+
...rest,
|
|
791
|
+
type: text(rest.type, 'event'),
|
|
792
|
+
tick: numberValue(rest.tick) ?? null,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
739
795
|
|
|
740
796
|
return cleanObject({
|
|
741
797
|
...event,
|
|
@@ -744,6 +800,14 @@ export function compactEventForEvents(
|
|
|
744
800
|
});
|
|
745
801
|
}
|
|
746
802
|
|
|
803
|
+
/** Realtime adapters share the authoritative structured Agent projection. */
|
|
804
|
+
export function compactEventForChannel(
|
|
805
|
+
event: Record<string, any>,
|
|
806
|
+
ctx: EventFormatContext = {},
|
|
807
|
+
): FormattedEvent {
|
|
808
|
+
return compactEventForEvents(event, ctx);
|
|
809
|
+
}
|
|
810
|
+
|
|
747
811
|
export function compactEventFields(
|
|
748
812
|
event: Record<string, any>,
|
|
749
813
|
ctx: EventFormatContext = {},
|
|
@@ -755,6 +819,110 @@ export function compactEventFields(
|
|
|
755
819
|
});
|
|
756
820
|
}
|
|
757
821
|
|
|
822
|
+
/** Compact, decision-oriented projection used by realtime Agent adapters. */
|
|
823
|
+
export function compactStateForChannel(
|
|
824
|
+
summary: any | null | undefined,
|
|
825
|
+
events: Array<Record<string, any>> = [],
|
|
826
|
+
): Record<string, any> | null {
|
|
827
|
+
if (!summary || typeof summary !== 'object') return null;
|
|
828
|
+
if (typeof summary.phase === 'string' && summary.phase.startsWith('room_')) {
|
|
829
|
+
const room = summary.room ?? {};
|
|
830
|
+
const you = summary.you ?? {};
|
|
831
|
+
return cleanObject({
|
|
832
|
+
phase: summary.phase,
|
|
833
|
+
you: cleanObject({
|
|
834
|
+
name: you.name,
|
|
835
|
+
seat: you.seat,
|
|
836
|
+
is_owner: you.is_owner,
|
|
837
|
+
}),
|
|
838
|
+
room: cleanObject({
|
|
839
|
+
room_code: room.room_code,
|
|
840
|
+
room_type: room.room_type,
|
|
841
|
+
status: room.status,
|
|
842
|
+
member_count: room.member_count,
|
|
843
|
+
deadline: room.deadline,
|
|
844
|
+
idle_destroy_at: room.idle_destroy_at,
|
|
845
|
+
is_owner: room.is_owner,
|
|
846
|
+
ready_to_start: room.ready_to_start,
|
|
847
|
+
role_config: room.role_config,
|
|
848
|
+
role_lock_character_id: room.role_lock_character_id,
|
|
849
|
+
members: room.members,
|
|
850
|
+
game_id: room.game_id,
|
|
851
|
+
game_server_name: room.game_server_name,
|
|
852
|
+
}),
|
|
853
|
+
recent_events: events.slice(-10).map((event) => cleanObject({
|
|
854
|
+
type: event.type,
|
|
855
|
+
room_code: event.room_code,
|
|
856
|
+
name: event.name,
|
|
857
|
+
agent_id: event.agent_id,
|
|
858
|
+
seat: event.seat,
|
|
859
|
+
status: event.status,
|
|
860
|
+
content: event.content,
|
|
861
|
+
reason: event.reason,
|
|
862
|
+
destroy_at: event.destroy_at,
|
|
863
|
+
close_code: event.close_code,
|
|
864
|
+
seconds_remaining: event.seconds_remaining,
|
|
865
|
+
})),
|
|
866
|
+
automation: summary.automation,
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
const you = summary.you ?? {};
|
|
870
|
+
const meeting = summary.meeting ?? null;
|
|
871
|
+
const crabSabotage = summary.crab_sabotage && typeof summary.crab_sabotage === 'object'
|
|
872
|
+
&& !Array.isArray(summary.crab_sabotage)
|
|
873
|
+
? summary.crab_sabotage
|
|
874
|
+
: null;
|
|
875
|
+
const votesSubmitted = Array.isArray(meeting?.votes_submitted) ? meeting.votes_submitted : undefined;
|
|
876
|
+
const knownPlayers = projectKnownPlayers(summary.players);
|
|
877
|
+
const currentScene = projectCurrentScene(summary, knownPlayers ?? projectPlayers({ summary }));
|
|
878
|
+
return cleanObject({
|
|
879
|
+
phase: summary.phase,
|
|
880
|
+
tick: summary.tick,
|
|
881
|
+
you: cleanObject({
|
|
882
|
+
name: you.player?.name,
|
|
883
|
+
seat: you.player?.seat,
|
|
884
|
+
role: you.role,
|
|
885
|
+
faction: you.faction,
|
|
886
|
+
alive: you.is_alive,
|
|
887
|
+
room: you.room,
|
|
888
|
+
kill_cooldown_secs: you.kill_cooldown_secs,
|
|
889
|
+
activity: you.activity,
|
|
890
|
+
tasks: Array.isArray(you.tasks) ? you.tasks : undefined,
|
|
891
|
+
crab_teammates: Array.isArray(you.crab_teammates)
|
|
892
|
+
? teammateObjects({ crab_teammates: you.crab_teammates }, { summary })
|
|
893
|
+
: undefined,
|
|
894
|
+
}),
|
|
895
|
+
game: cleanObject({
|
|
896
|
+
alive_count: Array.isArray(summary.players)
|
|
897
|
+
? summary.players.filter((player: any) => player?.known_status?.is_alive !== false).length
|
|
898
|
+
: undefined,
|
|
899
|
+
task_progress: summary.task_progress,
|
|
900
|
+
winner: summary.winner,
|
|
901
|
+
settlement: summary.settlement,
|
|
902
|
+
}),
|
|
903
|
+
players: knownPlayers,
|
|
904
|
+
...currentScene,
|
|
905
|
+
meeting: meeting?.active === true
|
|
906
|
+
? cleanObject({
|
|
907
|
+
caller: meeting.caller,
|
|
908
|
+
sub_phase: meeting.sub_phase,
|
|
909
|
+
current_speaker: meeting.current_speaker,
|
|
910
|
+
is_my_turn: meeting.current_speaker?.seat !== undefined
|
|
911
|
+
&& meeting.current_speaker.seat === you.player?.seat,
|
|
912
|
+
votes_submitted_count: votesSubmitted?.length,
|
|
913
|
+
})
|
|
914
|
+
: undefined,
|
|
915
|
+
crab_sabotage: crabSabotage
|
|
916
|
+
? cleanObject({
|
|
917
|
+
status: stringValue(crabSabotage.status),
|
|
918
|
+
cooldown_remaining_secs: numberValue(crabSabotage.cooldown_remaining_secs),
|
|
919
|
+
})
|
|
920
|
+
: undefined,
|
|
921
|
+
urgent: summary.urgent,
|
|
922
|
+
automation: summary.automation,
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
|
|
758
926
|
export function compactStateForEvents(
|
|
759
927
|
summary: any | null | undefined,
|
|
760
928
|
events: Array<Record<string, any>> = [],
|
|
@@ -56,7 +56,7 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
56
56
|
)).toContain('Do not retry matchmaking');
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it('classifies Source and Derived lifecycle Events with
|
|
59
|
+
it('classifies Source and Derived lifecycle Events with list changes factual-only', () => {
|
|
60
60
|
const excluded = new Set(['robot_speak_rule', 'strategy_alert']);
|
|
61
61
|
const sourceTypes = CLAWCLAW_LOCAL_AGENT_EVENT_TYPES.filter((type) => (
|
|
62
62
|
type !== 'room_ready_to_start' && !excluded.has(type)
|
|
@@ -74,7 +74,15 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
74
74
|
'quit_failed',
|
|
75
75
|
'room_attached',
|
|
76
76
|
'room_ping_timeout',
|
|
77
|
+
'behavior.started',
|
|
78
|
+
'behavior.suspended',
|
|
79
|
+
'behavior.restarted',
|
|
80
|
+
'behavior.completed',
|
|
81
|
+
'behavior.failed',
|
|
82
|
+
'behavior.cancelled',
|
|
83
|
+
'behavior.replaced',
|
|
77
84
|
'players_changed',
|
|
85
|
+
'tasks_changed',
|
|
78
86
|
]);
|
|
79
87
|
});
|
|
80
88
|
|
|
@@ -115,7 +123,31 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
115
123
|
)).toBeUndefined();
|
|
116
124
|
});
|
|
117
125
|
|
|
118
|
-
it('
|
|
126
|
+
it('does not present a self-killer murder_witnessed anomaly as witness evidence', () => {
|
|
127
|
+
const event = {
|
|
128
|
+
type: 'murder_witnessed',
|
|
129
|
+
killer_name: 'self',
|
|
130
|
+
killer_seat: 1,
|
|
131
|
+
target_name: 'target',
|
|
132
|
+
target_seat: 2,
|
|
133
|
+
};
|
|
134
|
+
const downgraded = formatCanonicalEventHint(
|
|
135
|
+
{ producer: 'backend_push' },
|
|
136
|
+
event,
|
|
137
|
+
{ summary: { you: { player: { name: 'self', seat: 1 } } } },
|
|
138
|
+
);
|
|
139
|
+
expect(downgraded).toContain('IGNORE AS WITNESS EVIDENCE');
|
|
140
|
+
expect(downgraded).toContain('Do not infer any witness or observer');
|
|
141
|
+
expect(downgraded).not.toContain('You saw');
|
|
142
|
+
|
|
143
|
+
expect(formatCanonicalEventHint(
|
|
144
|
+
{ producer: 'backend_push' },
|
|
145
|
+
event,
|
|
146
|
+
{ summary: { you: { player: { name: 'observer', seat: 3 } } } },
|
|
147
|
+
)).toContain('You saw self kill target');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('uses producerPluginId to exclude Behavior, Perception, and unknown local plugins', () => {
|
|
119
151
|
const event = { type: 'match_timeout', waited_secs: 300 };
|
|
120
152
|
|
|
121
153
|
expect(formatCanonicalEventHint({ producer: 'local_synth' }, event)).toContain('300s');
|
|
@@ -125,7 +157,7 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
125
157
|
}, event)).toContain('300s');
|
|
126
158
|
expect(formatCanonicalEventHint({
|
|
127
159
|
producer: 'local_synth',
|
|
128
|
-
producerPluginId: 'clawclaw.
|
|
160
|
+
producerPluginId: 'clawclaw.behavior',
|
|
129
161
|
}, event)).toBeUndefined();
|
|
130
162
|
expect(formatCanonicalEventHint({
|
|
131
163
|
producer: 'local_synth',
|
|
@@ -171,7 +203,7 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
171
203
|
type: 'game_start_failed',
|
|
172
204
|
game_mode: 'competition',
|
|
173
205
|
error: { code: 'ALREADY_IN_GAME' },
|
|
174
|
-
})).toContain('
|
|
206
|
+
})).toContain('`ccl join`');
|
|
175
207
|
expect(formatCanonicalEventHint(origin, {
|
|
176
208
|
type: 'game_start_failed',
|
|
177
209
|
game_mode: 'competition',
|
|
@@ -179,6 +211,27 @@ describe('Mailbox-owned Event hint registries', () => {
|
|
|
179
211
|
})).toContain('Do not start normal matchmaking');
|
|
180
212
|
});
|
|
181
213
|
|
|
214
|
+
it('uses top-level start and join commands for lifecycle recovery guidance', () => {
|
|
215
|
+
const notInQueue = LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS.not_in_queue({}, {});
|
|
216
|
+
const matchTimeout = LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS.match_timeout({
|
|
217
|
+
waited_secs: 300,
|
|
218
|
+
}, {});
|
|
219
|
+
const roomRecovery = LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS.room_lobby_reconnect_failed({}, {});
|
|
220
|
+
const existingGame = LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS.game_start_failed({
|
|
221
|
+
game_mode: 'competition',
|
|
222
|
+
error: { code: 'ALREADY_IN_GAME' },
|
|
223
|
+
}, {});
|
|
224
|
+
|
|
225
|
+
expect(notInQueue).toContain('`ccl start match`');
|
|
226
|
+
expect(matchTimeout).toContain('`ccl start match`');
|
|
227
|
+
expect(roomRecovery).toContain('`ccl load`');
|
|
228
|
+
expect(roomRecovery).toContain('`ccl join`');
|
|
229
|
+
expect(existingGame).toContain('`ccl load`');
|
|
230
|
+
expect(existingGame).toContain('`ccl join`');
|
|
231
|
+
expect([notInQueue, matchTimeout, roomRecovery, existingGame].join('\n'))
|
|
232
|
+
.not.toContain('`ccl game start`');
|
|
233
|
+
});
|
|
234
|
+
|
|
182
235
|
it('preserves the useful incremental semantics from npm batch next_step routes', () => {
|
|
183
236
|
expect(BACKEND_EVENT_HINT_FORMATTERS.game_started({}, {})).toContain('do not relaunch');
|
|
184
237
|
|
|
@@ -34,6 +34,30 @@ function numberValue(value: unknown): number | undefined {
|
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function nonEmptyString(value: unknown): string | undefined {
|
|
38
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Defensive recipient check for a backend event that contradicts witness semantics. */
|
|
42
|
+
export function isSelfKillerMurderWitnessed(
|
|
43
|
+
event: Record<string, any>,
|
|
44
|
+
summary: any | null | undefined,
|
|
45
|
+
): boolean {
|
|
46
|
+
if (event.type !== 'murder_witnessed') return false;
|
|
47
|
+
const killerSeat = firstNumber(event, ['killer_seat', 'killer_player_seat']);
|
|
48
|
+
const selfSeat = numberValue(
|
|
49
|
+
summary?.you?.player?.seat
|
|
50
|
+
?? summary?.you?.seat
|
|
51
|
+
?? summary?.my_seat,
|
|
52
|
+
);
|
|
53
|
+
if (killerSeat !== undefined && selfSeat !== undefined) return killerSeat === selfSeat;
|
|
54
|
+
|
|
55
|
+
const killerName = nonEmptyString(event.killer_name);
|
|
56
|
+
const selfName = nonEmptyString(summary?.you?.player?.name)
|
|
57
|
+
?? nonEmptyString(summary?.you?.name);
|
|
58
|
+
return killerName !== undefined && selfName !== undefined && killerName === selfName;
|
|
59
|
+
}
|
|
60
|
+
|
|
37
61
|
function firstString(event: Record<string, any>, keys: string[], fallback = '?'): string {
|
|
38
62
|
for (const key of keys) {
|
|
39
63
|
const value = event[key];
|
|
@@ -136,7 +160,7 @@ export const BACKEND_EVENT_HINT_FORMATTERS: Readonly<Record<string, EventHintFor
|
|
|
136
160
|
game_started: (event) => {
|
|
137
161
|
const playerCount = numberValue(event.player_count);
|
|
138
162
|
const countText = playerCount === undefined ? 'Game started.' : `Game started with ${playerCount} players.`;
|
|
139
|
-
return `${countText}
|
|
163
|
+
return `${countText} Opening map, seat, role, and task details are included in the full Event delivery. The runtime is already attached; do not relaunch.`;
|
|
140
164
|
},
|
|
141
165
|
role_assigned: (event) => roleAssignedHint(event),
|
|
142
166
|
kill: (event) => (
|
|
@@ -146,9 +170,11 @@ export const BACKEND_EVENT_HINT_FORMATTERS: Readonly<Record<string, EventHintFor
|
|
|
146
170
|
killed: (event) => (
|
|
147
171
|
`YOU ARE DEAD: ${optionalSeatPlayerLabel(event.killer_name, firstNumber(event, ['killer_seat', 'killer_player_seat']))} removed you from play.`
|
|
148
172
|
),
|
|
149
|
-
murder_witnessed: (event) => (
|
|
150
|
-
|
|
151
|
-
|
|
173
|
+
murder_witnessed: (event, ctx) => (
|
|
174
|
+
isSelfKillerMurderWitnessed(event, ctx.summary)
|
|
175
|
+
? 'IGNORE AS WITNESS EVIDENCE: this event conflicts with the recipient identity and was downgraded. Do not infer any witness or observer from it; rely on the separate kill Event and current State.'
|
|
176
|
+
: `WITNESS: You saw ${text(event.killer_name, 'someone')} kill ${text(event.target_name, 'someone')}. `
|
|
177
|
+
+ 'This is hard evidence; survive, report, or weaponize it.'
|
|
152
178
|
),
|
|
153
179
|
warrior_shrimp_self_destruct: (event) => (
|
|
154
180
|
`You executed ${text(event.target_name, 'a teammate')}, but they were a fellow Lobster. `
|
|
@@ -249,7 +275,7 @@ export const LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS: Readonly<Record<string, Even
|
|
|
249
275
|
: "Share this Event's spectate_url with the user as the room link and keep the room runtime attached.";
|
|
250
276
|
},
|
|
251
277
|
not_in_queue: () => (
|
|
252
|
-
'This account is no longer in the matchmaking queue. The runtime is exiting;
|
|
278
|
+
'This account is no longer in the matchmaking queue. The runtime is exiting; launch a fresh `ccl start match` only if the user wants to continue.'
|
|
253
279
|
),
|
|
254
280
|
poll_error: (event) => (
|
|
255
281
|
event.retrying === true
|
|
@@ -271,7 +297,7 @@ export const LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS: Readonly<Record<string, Even
|
|
|
271
297
|
case 'COMPETITION_NOT_OPEN':
|
|
272
298
|
return 'Tell the user competition is not open now and use `competition.daily_windows` for the opening windows. Do not start normal matchmaking unless the user asks.';
|
|
273
299
|
case 'ALREADY_IN_GAME':
|
|
274
|
-
return 'Tell the user this account is already in a game.
|
|
300
|
+
return 'Tell the user this account is already in a game. Run `ccl load` to confirm the existing participation, then attach with `ccl join` instead of starting another match.';
|
|
275
301
|
default:
|
|
276
302
|
return 'Tell the user competition matchmaking failed. Do not start normal matchmaking unless the user asks.';
|
|
277
303
|
}
|
|
@@ -297,7 +323,7 @@ export const LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS: Readonly<Record<string, Even
|
|
|
297
323
|
'Still in queue (see `waited_secs`). Keep chatting with the user; no tactical action is required.'
|
|
298
324
|
),
|
|
299
325
|
match_timeout: (event) => (
|
|
300
|
-
`Matchmaking timed out after ${text(event.waited_secs, '?')}s and this runtime is exiting. Ask whether the user wants to launch a fresh \`ccl
|
|
326
|
+
`Matchmaking timed out after ${text(event.waited_secs, '?')}s and this runtime is exiting. Ask whether the user wants to launch a fresh \`ccl start match\` or end the session.`
|
|
301
327
|
),
|
|
302
328
|
user_left_game: (event, ctx) => (
|
|
303
329
|
isRoomGameEvent(event, ctx)
|
|
@@ -305,7 +331,7 @@ export const LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS: Readonly<Record<string, Even
|
|
|
305
331
|
: 'The user left this game from the web page. Stop playing and do not start another match unless the user asks.'
|
|
306
332
|
),
|
|
307
333
|
room_lobby_reconnect_failed: () => (
|
|
308
|
-
'The room round ended, but Lobby reattachment failed. Ask the
|
|
334
|
+
'The room round ended, but Lobby reattachment failed and this runtime is exiting. Ask whether to recover or leave the room; to recover, run `ccl load` and, if participation still exists, attach with `ccl join`. Do not start normal matchmaking.'
|
|
309
335
|
),
|
|
310
336
|
room_lobby_missing: () => (
|
|
311
337
|
'The room round ended and the account is no longer in the familiar room. Do not start normal matchmaking; ask the user what to do next.'
|
|
@@ -558,6 +558,7 @@ describe('CanonicalMonitor', () => {
|
|
|
558
558
|
schema: 'ccl.monitor.v1',
|
|
559
559
|
mode: 'short',
|
|
560
560
|
events: [{ type: 'speech', event_id: 'evt-1', text: 'x'.repeat(1_000) }],
|
|
561
|
+
details_required: ['speech'],
|
|
561
562
|
messages: ['m'.repeat(1_000)],
|
|
562
563
|
state: 's'.repeat(1_000),
|
|
563
564
|
guidance: `Take the next legal action: ${'g'.repeat(1_000)}`,
|
|
@@ -568,6 +569,7 @@ describe('CanonicalMonitor', () => {
|
|
|
568
569
|
schema: 'ccl.monitor.v1',
|
|
569
570
|
mode: 'short',
|
|
570
571
|
events: [{ type: 'speech' }],
|
|
572
|
+
details_required: ['speech'],
|
|
571
573
|
truncated: true,
|
|
572
574
|
});
|
|
573
575
|
expect(oversized.messages[0]).toHaveLength(1_000);
|