@myclaw163/clawclaw-cli 0.6.112 → 0.7.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/QUICKSTART.md +46 -0
- package/QUICKSTART_HERMES.md +134 -0
- package/QUICKSTART_OPENCLAW.md +134 -0
- package/QUICKSTART_OTHER.md +134 -0
- package/README.md +23 -398
- package/bin/clawclaw-cli.mjs +9 -1
- package/docs/configuration.md +197 -0
- package/docs/runtime/README.md +52 -0
- package/docs/runtime/agent-notifications.md +55 -0
- package/docs/runtime/components-and-boundaries.md +213 -0
- package/docs/runtime/events-and-state.md +105 -0
- package/docs/runtime/owner-lifecycle-and-observability.md +69 -0
- package/docs/runtime/perception-replay.md +51 -0
- package/docs/runtime/short-commands-and-capabilities.md +55 -0
- package/docs/runtime/strategy-runtime.md +111 -0
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +488 -0
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +395 -0
- package/package.json +26 -8
- package/scripts/check-skill-command-surface.mjs +16 -7
- package/scripts/compare-perception-replays.test.ts +188 -0
- package/scripts/compare-perception-replays.ts +589 -0
- package/scripts/generate-spatial-facts.py +246 -0
- package/scripts/package-readme.mjs +48 -0
- package/scripts/replay-perception.ts +347 -0
- package/scripts/sync-frontend-map.mjs +195 -0
- package/scripts/watch-perception-events.test.ts +43 -0
- package/scripts/watch-perception-events.ts +162 -0
- package/skills/clawclaw/SKILL.md +121 -65
- package/skills/clawclaw/references/CHATTERBOX.md +2 -4
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +95 -61
- package/skills/clawclaw/references/GAME-MECHANICS.md +19 -9
- package/skills/clawclaw/references/HUB.md +5 -5
- package/skills/clawclaw/references/STRATEGIES.md +34 -17
- package/skills/clawclaw/references/STREAM.md +82 -46
- package/src/assets/clawclaw-map.json +1692 -0
- package/src/assets/clawclaw-spatial-facts.json +1291 -0
- package/src/assets/clawclaw-spatial-model.txt +142 -0
- package/src/cli.ts +21 -47
- package/src/commands/account.test.ts +229 -50
- package/src/commands/account.ts +456 -223
- package/src/commands/communication.test.ts +259 -0
- package/src/commands/communication.ts +391 -0
- package/src/commands/competition.test.ts +116 -0
- package/src/commands/competition.ts +50 -28
- package/src/commands/data.test.ts +57 -1
- package/src/commands/data.ts +79 -4
- package/src/commands/events-canonical-state.test.ts +187 -0
- package/src/commands/events.test.ts +50 -136
- package/src/commands/events.ts +175 -241
- package/src/commands/game/index.test.ts +510 -0
- package/src/commands/game/index.ts +556 -0
- package/src/commands/game-map.test.ts +48 -7
- package/src/commands/hub.test.ts +2 -23
- package/src/commands/hub.ts +4 -16
- package/src/commands/load.test.ts +10 -22
- package/src/commands/load.ts +15 -2
- package/src/commands/peek.ts +2 -3
- package/src/commands/perception.test.ts +46 -0
- package/src/commands/perception.ts +92 -0
- package/src/commands/setup/codex.ts +0 -1
- package/src/commands/strategy.test.ts +139 -102
- package/src/commands/strategy.ts +175 -103
- package/src/commands/upgrade.ts +0 -21
- package/src/lib/auth.test.ts +35 -0
- package/src/lib/auth.ts +45 -6
- package/src/lib/diagnostics-config.test.ts +59 -0
- package/src/lib/diagnostics-config.ts +76 -0
- package/src/lib/game-client.test.ts +166 -0
- package/src/lib/game-client.ts +316 -87
- package/src/lib/game-context.ts +33 -4
- package/src/lib/gameplay-config.test.ts +66 -0
- package/src/lib/gameplay-config.ts +151 -0
- package/src/lib/http-transport.test.ts +63 -0
- package/src/lib/http-transport.ts +76 -10
- package/src/lib/init-command.test.ts +25 -1
- package/src/lib/init-command.ts +66 -1
- package/src/lib/participation-leave.ts +78 -0
- package/src/lib/perception-config.test.ts +138 -0
- package/src/lib/perception-config.ts +101 -0
- package/src/lib/room.test.ts +14 -0
- package/src/lib/room.ts +28 -2
- package/src/lib/server-registry.test.ts +15 -5
- package/src/lib/server-registry.ts +9 -10
- package/src/lib/strategy-export.test.ts +123 -44
- package/src/lib/strategy-export.ts +110 -81
- package/src/lib/user-data.test.ts +2 -0
- package/src/lib/user-data.ts +17 -16
- package/src/pipeline/canonical-event-presentation.test.ts +196 -0
- package/src/pipeline/canonical-event-presentation.ts +71 -0
- package/src/pipeline/event-format.test.ts +357 -59
- package/src/pipeline/event-format.ts +365 -80
- package/src/pipeline/event-hints.test.ts +241 -0
- package/src/pipeline/event-hints.ts +202 -51
- package/src/pipeline/game-sync-event-normalization.test.ts +239 -0
- package/src/pipeline/game-sync-event-normalization.ts +215 -0
- package/src/pipeline/player-projection.test.ts +164 -102
- package/src/pipeline/player-projection.ts +194 -235
- package/src/runtime/canonical-event-emitter.test.ts +70 -0
- package/src/runtime/canonical-event-emitter.ts +78 -0
- package/src/runtime/canonical-monitor.test.ts +575 -0
- package/src/runtime/canonical-monitor.ts +388 -0
- package/src/runtime/clawclaw/agent-event-policy.test.ts +27 -0
- package/src/runtime/clawclaw/agent-event-policy.ts +35 -0
- package/src/runtime/clawclaw/index.ts +4 -0
- package/src/runtime/clawclaw/notifications.test.ts +47 -0
- package/src/runtime/clawclaw/notifications.ts +65 -0
- package/src/runtime/clawclaw/owner-lock.test.ts +221 -0
- package/src/runtime/clawclaw/owner.ts +945 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +299 -0
- package/src/runtime/clawclaw/plugins/action/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +81 -0
- package/src/runtime/clawclaw/plugins/assembly.ts +116 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +150 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +100 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +162 -0
- package/src/runtime/clawclaw/plugins/derived-event/index.ts +2 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +223 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +236 -0
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +7 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +77 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +91 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1008 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +475 -0
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +32 -0
- package/src/runtime/clawclaw/plugins/perception/index.ts +8 -0
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +204 -0
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +290 -0
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +324 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +365 -0
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +7 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +341 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +447 -0
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +30 -0
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +289 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +329 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +82 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +172 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +256 -0
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +121 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +106 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +225 -0
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +11 -0
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +31 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +759 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +707 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +215 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +61 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +1516 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +1529 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +119 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +244 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +65 -0
- package/src/runtime/clawclaw/plugins/perception/replay.ts +86 -0
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +107 -0
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +114 -0
- package/src/runtime/clawclaw/plugins/perception/visual-state-projector.ts +98 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +1019 -0
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +287 -0
- package/src/runtime/clawclaw/plugins/source/game-transport.ts +281 -0
- package/src/runtime/clawclaw/plugins/source/index.ts +5 -0
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +270 -0
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +151 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +307 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.ts +480 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +1909 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +2055 -0
- package/src/runtime/clawclaw/plugins/source/source-transports.ts +30 -0
- package/src/runtime/clawclaw/plugins/source/types.ts +79 -0
- package/src/runtime/clawclaw/plugins/strategy/context-capabilities.ts +5 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +177 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +185 -0
- package/src/runtime/clawclaw/plugins/strategy/index.ts +8 -0
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +412 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +73 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +183 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +25 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +693 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +57 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +164 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +1936 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +1557 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +131 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +413 -0
- package/src/runtime/clawclaw/plugins/strategy/thread-strategy-executor.ts +792 -0
- package/src/runtime/clawclaw/runtime-data-export.test.ts +249 -0
- package/src/runtime/clawclaw/runtime-data-export.ts +402 -0
- package/src/runtime/clawclaw/runtime-state.ts +98 -0
- package/src/runtime/clawclaw/runtime.ts +133 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +74 -0
- package/src/runtime/clawclaw-event-catalog.ts +266 -0
- package/src/runtime/clawclaw-position.ts +4 -0
- package/src/runtime/clawclaw-room-state.ts +51 -0
- package/src/runtime/framework/action-diagnostics.test.ts +81 -0
- package/src/runtime/framework/action-diagnostics.ts +146 -0
- package/src/runtime/framework/capability-registry.test.ts +282 -0
- package/src/runtime/framework/capability-registry.ts +283 -0
- package/src/runtime/framework/contracts.ts +118 -0
- package/src/runtime/framework/control/control-scheduler.ts +1260 -0
- package/src/runtime/framework/control/domain-set.ts +81 -0
- package/src/runtime/framework/control/index.ts +3 -0
- package/src/runtime/framework/control/types.ts +184 -0
- package/src/runtime/framework/control-coordinator.test.ts +660 -0
- package/src/runtime/framework/control-coordinator.ts +11 -0
- package/src/runtime/framework/events/event-catalog.ts +74 -0
- package/src/runtime/framework/events/event-delivery-service.test.ts +84 -0
- package/src/runtime/framework/events/event-delivery-service.ts +198 -0
- package/src/runtime/framework/events/event-ingress.test.ts +178 -0
- package/src/runtime/framework/events/event-ingress.ts +97 -0
- package/src/runtime/framework/events/event-repository.ts +59 -0
- package/src/runtime/framework/events/index.ts +7 -0
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +594 -0
- package/src/runtime/framework/events/memory-event-repository.ts +928 -0
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +200 -0
- package/src/runtime/framework/events/sqlite-event-repository.ts +1681 -0
- package/src/runtime/framework/events/test-helpers.ts +78 -0
- package/src/runtime/framework/events/types.ts +286 -0
- package/src/runtime/framework/index.ts +7 -0
- package/src/runtime/framework/load-node-sqlite.ts +17 -0
- package/src/runtime/framework/mailbox/coalescer.test.ts +55 -0
- package/src/runtime/framework/mailbox/coalescer.ts +83 -0
- package/src/runtime/framework/mailbox/host-notification-sink.ts +44 -0
- package/src/runtime/framework/mailbox/identity.test.ts +38 -0
- package/src/runtime/framework/mailbox/identity.ts +38 -0
- package/src/runtime/framework/mailbox/index.ts +7 -0
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +513 -0
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +282 -0
- package/src/runtime/framework/mailbox/mailbox-repository.ts +44 -0
- package/src/runtime/framework/mailbox/notification-projector.test.ts +77 -0
- package/src/runtime/framework/mailbox/notification-projector.ts +65 -0
- package/src/runtime/framework/mailbox/types.ts +139 -0
- package/src/runtime/framework/modules/runtime-module-loader-hooks.d.mts +19 -0
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +117 -0
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +209 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +71 -0
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +23 -0
- package/src/runtime/framework/participation-manager.test.ts +108 -0
- package/src/runtime/framework/participation-manager.ts +244 -0
- package/src/runtime/framework/plugins/contracts.ts +382 -0
- package/src/runtime/framework/plugins/index.ts +4 -0
- package/src/runtime/framework/plugins/runtime-event-identity.ts +17 -0
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +179 -0
- package/src/runtime/framework/plugins/runtime-input-journal.ts +693 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +1994 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +1860 -0
- package/src/runtime/framework/runtime.ts +1756 -0
- package/src/runtime/framework/serial-task-queue.ts +14 -0
- package/src/runtime/framework/state/contracts.ts +49 -0
- package/src/runtime/framework/state/current-state-store.ts +184 -0
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +144 -0
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +209 -0
- package/src/runtime/framework/state/freshness.ts +72 -0
- package/src/runtime/framework/state/history/contracts.ts +150 -0
- package/src/runtime/framework/state/history/history-writer.ts +194 -0
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +178 -0
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +157 -0
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +629 -0
- package/src/runtime/framework/state/history/state-history.test.ts +251 -0
- package/src/runtime/framework/state/history/trajectory-projector.ts +209 -0
- package/src/runtime/framework/state/index.ts +13 -0
- package/src/runtime/framework/state/state-core.test.ts +197 -0
- package/src/runtime/framework/state/state-ingress.ts +95 -0
- package/src/runtime/framework/state/state-provider.ts +62 -0
- package/src/runtime/framework/state/types.ts +155 -0
- package/src/runtime/game-sync-protocol.test.ts +123 -0
- package/src/runtime/game-sync-protocol.ts +261 -0
- package/src/runtime/mailbox-host-relay.test.ts +248 -0
- package/src/runtime/mailbox-host-relay.ts +300 -0
- package/src/runtime/observability/factory.ts +188 -0
- package/src/runtime/observability/index.ts +6 -0
- package/src/runtime/observability/observability.test.ts +561 -0
- package/src/runtime/observability/recorder.ts +209 -0
- package/src/runtime/observability/redaction.ts +154 -0
- package/src/runtime/observability/reporter.ts +154 -0
- package/src/runtime/observability/sinks.ts +135 -0
- package/src/runtime/observability/types.ts +92 -0
- package/src/runtime/owner-control.test.ts +153 -0
- package/src/runtime/owner-control.ts +206 -42
- package/src/runtime/parent-process-watch.test.ts +27 -0
- package/src/runtime/parent-process-watch.ts +51 -0
- package/src/runtime/pending-event-handoff.test.ts +29 -0
- package/src/runtime/pending-event-handoff.ts +61 -0
- package/src/runtime/raw-ws-log.test.ts +86 -17
- package/src/runtime/raw-ws-log.ts +230 -21
- package/src/runtime/runtime-logger.test.ts +58 -0
- package/src/runtime/runtime-logger.ts +10 -13
- package/src/runtime/runtime-persistence.test.ts +26 -0
- package/src/runtime/runtime.test.ts +1704 -0
- package/src/runtime/ws-client.test.ts +496 -103
- package/src/runtime/ws-client.ts +546 -166
- package/src/sdk/action.ts +3 -1
- package/src/sdk/index.ts +4 -19
- package/src/sdk/perception-plugin/index.test.ts +22 -0
- package/src/sdk/perception-plugin/index.ts +285 -0
- package/src/sdk/strategy-plugin/index.test.ts +952 -0
- package/src/sdk/strategy-plugin/index.ts +1324 -0
- package/src/sdk/types.ts +3 -1
- package/src/short-command/classifier.test.ts +107 -0
- package/src/short-command/classifier.ts +169 -0
- package/src/short-command/index.ts +7 -0
- package/src/short-command/presenter.test.ts +119 -0
- package/src/short-command/presenter.ts +308 -0
- package/src/short-command/process-io.ts +13 -0
- package/src/short-command/response-contract.ts +58 -0
- package/src/short-command/runner.test.ts +78 -0
- package/src/short-command/runner.ts +164 -0
- package/src/short-command/sensitive-data-filter.test.ts +56 -0
- package/src/short-command/sensitive-data-filter.ts +123 -0
- package/src/short-command/transport-response.test.ts +39 -0
- package/src/short-command/transport-response.ts +89 -0
- package/src/short-command/types.ts +92 -0
- package/src/strategies/avoid-lone.ts +18 -11
- package/src/strategies/avoid-players.ts +29 -13
- package/src/strategies/corpse-patrol.ts +29 -11
- package/src/strategies/crab-sabotage.ts +31 -18
- package/src/strategies/custom-module.test.ts +3 -5
- package/src/strategies/find-player.ts +34 -15
- package/src/strategies/game-utils.test.ts +42 -0
- package/src/strategies/game-utils.ts +143 -53
- package/src/strategies/goals/avoid-lone-top.ts +22 -1
- package/src/strategies/goals/avoid-players-top.test.ts +13 -0
- package/src/strategies/goals/avoid-players-top.ts +6 -5
- package/src/strategies/goals/corpse-patrol-top.ts +9 -2
- package/src/strategies/goals/crab-octopus-reflexes.ts +6 -2
- package/src/strategies/goals/crab-sabotage-top.ts +7 -1
- package/src/strategies/goals/emergency-hunt-goal.ts +15 -3
- package/src/strategies/goals/find-player-top.ts +47 -3
- package/src/strategies/goals/flee-players-goal.ts +2 -0
- package/src/strategies/goals/follow-companion-goal.ts +27 -3
- package/src/strategies/goals/hide-top.ts +47 -5
- package/src/strategies/goals/keep-away-goal.ts +24 -2
- package/src/strategies/goals/kill-frenzy-top.ts +12 -2
- package/src/strategies/goals/kill-lone-top.test.ts +72 -0
- package/src/strategies/goals/kill-lone-top.ts +8 -6
- package/src/strategies/goals/kill-target-goal.ts +16 -7
- package/src/strategies/goals/kill-target-top.ts +16 -2
- package/src/strategies/goals/linger-corpse-goal.ts +11 -3
- package/src/strategies/goals/lone-kill-core.ts +4 -2
- package/src/strategies/goals/move-room-goal.ts +46 -4
- package/src/strategies/goals/normal-shrimp-top.test.ts +16 -0
- package/src/strategies/goals/normal-shrimp-top.ts +18 -18
- package/src/strategies/goals/paradise-fish-top.test.ts +78 -0
- package/src/strategies/goals/paradise-fish-top.ts +16 -6
- package/src/strategies/goals/patrol-top.ts +14 -3
- package/src/strategies/goals/report-patrol-top.ts +14 -3
- package/src/strategies/goals/safe-task-goal.ts +32 -4
- package/src/strategies/goals/social-task-top.ts +39 -8
- package/src/strategies/goals/task-kill-report-top.ts +33 -10
- package/src/strategies/goals/task-only-top.test.ts +89 -0
- package/src/strategies/goals/task-only-top.ts +9 -2
- package/src/strategies/goals/task-or-patrol-goal.ts +21 -3
- package/src/strategies/goals/warrior-shrimp-top.test.ts +75 -23
- package/src/strategies/goals/warrior-shrimp-top.ts +34 -13
- package/src/strategies/greeting.ts +10 -3
- package/src/strategies/hide-spots.ts +4 -0
- package/src/strategies/hide.ts +35 -20
- package/src/strategies/kill-frenzy.ts +18 -12
- package/src/strategies/kill-lone.ts +43 -12
- package/src/strategies/kill-target.ts +34 -17
- package/src/strategies/lone-kill-task.ts +31 -18
- package/src/strategies/move-room.ts +32 -15
- package/src/strategies/off-route-points.ts +12 -4
- package/src/strategies/paradise-fish.ts +49 -14
- package/src/strategies/pathfind/astar-path.test.ts +73 -0
- package/src/strategies/pathfind/astar-path.ts +196 -0
- package/src/strategies/pathfind/escape-planner.test.ts +27 -1
- package/src/strategies/pathfind/escape-planner.ts +108 -0
- package/src/strategies/patrol.ts +18 -11
- package/src/strategies/report-patrol.ts +18 -11
- package/src/strategies/shrimp-memory.ts +66 -14
- package/src/strategies/social-task.ts +49 -45
- package/src/strategies/task-kill-report.ts +34 -16
- package/src/strategies/task-only.test.ts +124 -0
- package/src/strategies/task-only.ts +20 -11
- package/src/strategies/task-report.ts +29 -11
- package/src/strategies/types.ts +29 -62
- package/src/strategies/warrior-memory.ts +44 -14
- package/scripts/check_monitor.test.mjs +0 -212
- package/skills/clawclaw/references/KNOWLEDGE.md +0 -42
- package/src/assets/clawclaw-ascii-map.txt +0 -40
- package/src/commands/do.test.ts +0 -117
- package/src/commands/do.ts +0 -195
- package/src/commands/game-monitor-status.test.ts +0 -58
- package/src/commands/game-start-plan.test.ts +0 -356
- package/src/commands/game.ts +0 -2046
- package/src/commands/history-player.test.ts +0 -105
- package/src/commands/history.ts +0 -573
- package/src/commands/knowledge.test.ts +0 -13
- package/src/commands/knowledge.ts +0 -176
- package/src/commands/meeting-history.test.ts +0 -106
- package/src/commands/state.ts +0 -46
- package/src/commands/watch.test.ts +0 -1313
- package/src/commands/watch.ts +0 -824
- package/src/lib/knowledge-store.test.ts +0 -170
- package/src/lib/knowledge-store.ts +0 -369
- package/src/perception/player-history-store.test.ts +0 -177
- package/src/perception/player-history-store.ts +0 -262
- package/src/pipeline/event-store.test.ts +0 -28
- package/src/pipeline/event-store.ts +0 -193
- package/src/pipeline/pipeline.ts +0 -35
- package/src/runtime/event-daemon.test.ts +0 -268
- package/src/runtime/event-daemon.ts +0 -531
- package/src/runtime/room-lobby-runtime.test.ts +0 -95
- package/src/runtime/room-lobby-runtime.ts +0 -367
- package/src/strategies/avoid-players.knowledge.md +0 -19
- package/src/strategies/kill-lone.knowledge.md +0 -17
- package/src/strategies/knowledge-contract.ts +0 -85
- package/src/strategies/loader.test.ts +0 -710
- package/src/strategies/loader.ts +0 -183
- package/src/strategies/new-events-backfill.ts +0 -98
- package/src/strategies/paradise-fish.knowledge.md +0 -19
- package/src/strategies/scanner.ts +0 -238
- package/src/strategies/shrimp-memory.knowledge.md +0 -19
- package/src/strategies/social-task.test.ts +0 -28
- package/src/strategies/spawn.ts +0 -82
- package/src/strategies/strategy-loop.test.ts +0 -15
- package/src/strategies/strategy-loop.ts +0 -748
- package/src/strategies/warrior-memory.knowledge.md +0 -21
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
CLAWCLAW_BACKEND_AGENT_EVENT_TYPES,
|
|
4
|
+
CLAWCLAW_LOCAL_AGENT_EVENT_TYPES,
|
|
5
|
+
} from '../runtime/clawclaw-event-catalog.js';
|
|
6
|
+
import {
|
|
7
|
+
BACKEND_EVENT_HINT_FORMATTERS,
|
|
8
|
+
DERIVED_EVENT_HINT_FORMATTERS,
|
|
9
|
+
formatCanonicalEventHint,
|
|
10
|
+
LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS,
|
|
11
|
+
} from './event-hints.js';
|
|
12
|
+
|
|
13
|
+
describe('Mailbox-owned Event hint registries', () => {
|
|
14
|
+
it('keeps 30 backend hint formatters and classifies 14 Agent Events as unregistered', () => {
|
|
15
|
+
const unregistered = CLAWCLAW_BACKEND_AGENT_EVENT_TYPES.filter((type) => (
|
|
16
|
+
BACKEND_EVENT_HINT_FORMATTERS[type] === undefined
|
|
17
|
+
));
|
|
18
|
+
|
|
19
|
+
expect(Object.keys(BACKEND_EVENT_HINT_FORMATTERS)).toHaveLength(30);
|
|
20
|
+
expect(unregistered).toEqual([
|
|
21
|
+
'task_completed',
|
|
22
|
+
'task_sabotaged',
|
|
23
|
+
'death_speech',
|
|
24
|
+
'wandering_speech',
|
|
25
|
+
'speech',
|
|
26
|
+
'room.member_joined',
|
|
27
|
+
'room.member_status_changed',
|
|
28
|
+
'room.member_left',
|
|
29
|
+
'room.owner_changed',
|
|
30
|
+
'room.full',
|
|
31
|
+
'room.chat',
|
|
32
|
+
'room.game_starting',
|
|
33
|
+
'room.game_start_failed',
|
|
34
|
+
'room.cooldown',
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('classifies Source and Derived lifecycle Events with players_changed factual-only', () => {
|
|
39
|
+
const excluded = new Set(['robot_speak_rule', 'strategy_alert']);
|
|
40
|
+
const sourceTypes = CLAWCLAW_LOCAL_AGENT_EVENT_TYPES.filter((type) => (
|
|
41
|
+
type !== 'room_ready_to_start' && !excluded.has(type)
|
|
42
|
+
));
|
|
43
|
+
const unregistered = sourceTypes.filter((type) => (
|
|
44
|
+
LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS[type] === undefined
|
|
45
|
+
));
|
|
46
|
+
|
|
47
|
+
expect(Object.keys(LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS)).toHaveLength(19);
|
|
48
|
+
expect(Object.keys(DERIVED_EVENT_HINT_FORMATTERS)).toEqual(['room_ready_to_start']);
|
|
49
|
+
expect(unregistered).toEqual([
|
|
50
|
+
'session_resumed',
|
|
51
|
+
'session_recovered',
|
|
52
|
+
'session_left',
|
|
53
|
+
'quit_failed',
|
|
54
|
+
'room_attached',
|
|
55
|
+
'room_ping_timeout',
|
|
56
|
+
'players_changed',
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('adds actionable guidance for room idle warning and destruction', () => {
|
|
61
|
+
expect(formatCanonicalEventHint(
|
|
62
|
+
{ producer: 'backend_push' },
|
|
63
|
+
{ type: 'room.idle_warning', seconds_remaining: 119 },
|
|
64
|
+
)).toContain('pings do not extend');
|
|
65
|
+
expect(formatCanonicalEventHint(
|
|
66
|
+
{ producer: 'local_synth' },
|
|
67
|
+
{ type: 'room_destroyed', reason: 'idle_timeout' },
|
|
68
|
+
)).toContain('do not create or join another room');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('routes training readiness to the dedicated start command', () => {
|
|
72
|
+
expect(formatCanonicalEventHint(
|
|
73
|
+
{ producer: 'local_synth', producerPluginId: 'clawclaw.derived-event' },
|
|
74
|
+
{ type: 'room_ready_to_start', room_type: 'training_dummy' },
|
|
75
|
+
)).toContain('ccl game training start');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('applies instance conditions without emitting null or a default hint', () => {
|
|
79
|
+
expect(formatCanonicalEventHint(
|
|
80
|
+
{ producer: 'local_synth' },
|
|
81
|
+
{ type: 'joined' },
|
|
82
|
+
)).toBeUndefined();
|
|
83
|
+
expect(formatCanonicalEventHint(
|
|
84
|
+
{ producer: 'local_synth' },
|
|
85
|
+
{ type: 'poll_error', retrying: false },
|
|
86
|
+
)).toBeUndefined();
|
|
87
|
+
expect(formatCanonicalEventHint(
|
|
88
|
+
{ producer: 'backend_push' },
|
|
89
|
+
{ type: 'meeting_briefing' },
|
|
90
|
+
)).toBeUndefined();
|
|
91
|
+
expect(formatCanonicalEventHint(
|
|
92
|
+
{ producer: 'backend_push' },
|
|
93
|
+
{ type: 'unknown' },
|
|
94
|
+
)).toBeUndefined();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('uses producerPluginId to exclude Strategy, Perception, and unknown local plugins', () => {
|
|
98
|
+
const event = { type: 'match_timeout', waited_secs: 300 };
|
|
99
|
+
|
|
100
|
+
expect(formatCanonicalEventHint({ producer: 'local_synth' }, event)).toContain('300s');
|
|
101
|
+
expect(formatCanonicalEventHint({
|
|
102
|
+
producer: 'local_synth',
|
|
103
|
+
producerPluginId: 'clawclaw.source',
|
|
104
|
+
}, event)).toContain('300s');
|
|
105
|
+
expect(formatCanonicalEventHint({
|
|
106
|
+
producer: 'local_synth',
|
|
107
|
+
producerPluginId: 'clawclaw.strategy',
|
|
108
|
+
}, event)).toBeUndefined();
|
|
109
|
+
expect(formatCanonicalEventHint({
|
|
110
|
+
producer: 'local_synth',
|
|
111
|
+
producerPluginId: 'clawclaw.perception',
|
|
112
|
+
}, event)).toBeUndefined();
|
|
113
|
+
expect(formatCanonicalEventHint({
|
|
114
|
+
producer: 'local_synth',
|
|
115
|
+
producerPluginId: 'third-party.plugin',
|
|
116
|
+
}, event)).toBeUndefined();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('keeps room.full factual and gives start advice only to the authorized Derived Event', () => {
|
|
120
|
+
expect(formatCanonicalEventHint(
|
|
121
|
+
{ producer: 'backend_push' },
|
|
122
|
+
{ type: 'room.full' },
|
|
123
|
+
)).toBeUndefined();
|
|
124
|
+
expect(formatCanonicalEventHint({
|
|
125
|
+
producer: 'local_synth',
|
|
126
|
+
producerPluginId: 'clawclaw.derived-event',
|
|
127
|
+
}, {
|
|
128
|
+
type: 'room_ready_to_start',
|
|
129
|
+
ready_to_start: true,
|
|
130
|
+
})).toContain('you are the owner');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('preserves npm competition failure guidance by error code', () => {
|
|
134
|
+
const origin = {
|
|
135
|
+
producer: 'local_synth',
|
|
136
|
+
producerPluginId: 'clawclaw.source',
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
expect(formatCanonicalEventHint(origin, {
|
|
140
|
+
type: 'game_start_failed',
|
|
141
|
+
game_mode: 'competition',
|
|
142
|
+
error: { code: 'NO_ACTIVE_COMPETITION' },
|
|
143
|
+
})).toContain('no active competition');
|
|
144
|
+
expect(formatCanonicalEventHint(origin, {
|
|
145
|
+
type: 'game_start_failed',
|
|
146
|
+
game_mode: 'competition',
|
|
147
|
+
error: { code: 'COMPETITION_NOT_OPEN' },
|
|
148
|
+
})).toContain('competition.daily_windows');
|
|
149
|
+
expect(formatCanonicalEventHint(origin, {
|
|
150
|
+
type: 'game_start_failed',
|
|
151
|
+
game_mode: 'competition',
|
|
152
|
+
error: { code: 'ALREADY_IN_GAME' },
|
|
153
|
+
})).toContain('Reconnect or continue');
|
|
154
|
+
expect(formatCanonicalEventHint(origin, {
|
|
155
|
+
type: 'game_start_failed',
|
|
156
|
+
game_mode: 'competition',
|
|
157
|
+
error: { code: 'REQUEST_FAILED' },
|
|
158
|
+
})).toContain('Do not start normal matchmaking');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('preserves the useful incremental semantics from npm batch next_step routes', () => {
|
|
162
|
+
expect(BACKEND_EVENT_HINT_FORMATTERS.game_started({}, {})).toContain('do not relaunch');
|
|
163
|
+
expect(BACKEND_EVENT_HINT_FORMATTERS.crab_teammates({
|
|
164
|
+
crab_teammates: [{ name: 'Bob', seat: 2 }],
|
|
165
|
+
}, {})).toContain('avoid voting for or killing them');
|
|
166
|
+
|
|
167
|
+
const normalGameOver = BACKEND_EVENT_HINT_FORMATTERS.game_over({
|
|
168
|
+
winner: 'lobster',
|
|
169
|
+
}, {});
|
|
170
|
+
expect(normalGameOver).toContain('runtime is ending automatically');
|
|
171
|
+
expect(normalGameOver).toContain('only if the user asks');
|
|
172
|
+
expect(BACKEND_EVENT_HINT_FORMATTERS.game_over({
|
|
173
|
+
winner: 'lobster',
|
|
174
|
+
game_mode: 'match',
|
|
175
|
+
}, { summary: { game_mode: 'room' } })).toContain('runtime is ending automatically');
|
|
176
|
+
expect(BACKEND_EVENT_HINT_FORMATTERS.game_over({
|
|
177
|
+
winner: 'lobster',
|
|
178
|
+
game_mode: 'room',
|
|
179
|
+
}, { summary: { game_mode: 'match' } })).toContain('room lifecycle');
|
|
180
|
+
expect(BACKEND_EVENT_HINT_FORMATTERS.exile_game_over({
|
|
181
|
+
winner: 'lobster',
|
|
182
|
+
game_mode: 'room',
|
|
183
|
+
}, {})).toContain('room lifecycle');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('keeps backend prose and player speech in facts instead of the CCL-owned hint', () => {
|
|
187
|
+
const roleHint = formatCanonicalEventHint(
|
|
188
|
+
{ producer: 'backend_push' },
|
|
189
|
+
{
|
|
190
|
+
type: 'role_assigned',
|
|
191
|
+
role_display_name: 'Shrimp',
|
|
192
|
+
faction: 'lobster',
|
|
193
|
+
role_description: '后端角色描述',
|
|
194
|
+
fake_task_briefing: '后端假任务说明',
|
|
195
|
+
},
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(roleHint).toBe('You are Shrimp (lobster). Read `references/GAME-MECHANICS.md` for the exact rules, then tell your user your role, faction, win condition, and first plan.');
|
|
199
|
+
expect(roleHint).not.toMatch(/[一-鿿]/);
|
|
200
|
+
expect(formatCanonicalEventHint(
|
|
201
|
+
{ producer: 'backend_push' },
|
|
202
|
+
{ type: 'death_speech', text: '我在厨房。' },
|
|
203
|
+
)).toBeUndefined();
|
|
204
|
+
expect(formatCanonicalEventHint(
|
|
205
|
+
{ producer: 'backend_push' },
|
|
206
|
+
{ type: 'wandering_speech', text: '跟我走。' },
|
|
207
|
+
)).toBeUndefined();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('keeps every CCL-authored hint template in English', () => {
|
|
211
|
+
const sample = {
|
|
212
|
+
actor_name: 'Alice',
|
|
213
|
+
target_name: 'Bob',
|
|
214
|
+
killer_name: 'Alice',
|
|
215
|
+
corpse_name: 'Bob',
|
|
216
|
+
winner_name: 'Alice',
|
|
217
|
+
current_speaker: 'Alice',
|
|
218
|
+
meeting_caller_name: 'Alice',
|
|
219
|
+
reported_corpses: [{ name: 'Bob', seat: 2 }],
|
|
220
|
+
nearby_players: [{ name: 'Bob', seat: 2 }],
|
|
221
|
+
crab_teammates: [{ name: 'Bob', seat: 2 }],
|
|
222
|
+
task_name: 'Repair',
|
|
223
|
+
room: 'Engine Room',
|
|
224
|
+
winner: 'lobster',
|
|
225
|
+
blocked_winner: 'lobster',
|
|
226
|
+
text: 'hello',
|
|
227
|
+
url: 'https://example.test/game',
|
|
228
|
+
spectate_url: 'https://example.test/room',
|
|
229
|
+
retrying: true,
|
|
230
|
+
waited_secs: 300,
|
|
231
|
+
};
|
|
232
|
+
const hints = [
|
|
233
|
+
...Object.values(BACKEND_EVENT_HINT_FORMATTERS).map((formatter) => formatter(sample, {})),
|
|
234
|
+
...Object.values(LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS).map((formatter) => formatter(sample, {})),
|
|
235
|
+
...Object.values(DERIVED_EVENT_HINT_FORMATTERS).map((formatter) => formatter(sample, {})),
|
|
236
|
+
].filter((hint): hint is string => typeof hint === 'string');
|
|
237
|
+
|
|
238
|
+
expect(hints).toHaveLength(50);
|
|
239
|
+
for (const hint of hints) expect(hint).not.toMatch(/[一-鿿]/);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isRoomMode, isTrainingRoomMode } from '../lib/room.js';
|
|
2
|
+
|
|
1
3
|
export interface EventHintContext {
|
|
2
4
|
summary?: any | null;
|
|
3
5
|
seats?: Record<string, number>;
|
|
@@ -7,6 +9,16 @@ export interface EventHintContext {
|
|
|
7
9
|
|
|
8
10
|
export type EventHintFormatter = (event: Record<string, any>, ctx: EventHintContext) => string | undefined;
|
|
9
11
|
|
|
12
|
+
export interface EventHintOrigin {
|
|
13
|
+
producer: string;
|
|
14
|
+
producerPluginId?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const CLAWCLAW_SOURCE_PLUGIN_ID = 'clawclaw.source';
|
|
18
|
+
export const CLAWCLAW_DERIVED_EVENT_PLUGIN_ID = 'clawclaw.derived-event';
|
|
19
|
+
|
|
20
|
+
const ROOM_GAME_OVER_HINT = 'This room round has ended. Review the result with the user, wait for the room lifecycle to resume, and do not start normal matchmaking.';
|
|
21
|
+
|
|
10
22
|
function text(value: unknown, fallback = '?'): string {
|
|
11
23
|
if (typeof value === 'string' && value.length > 0) return value;
|
|
12
24
|
if (typeof value === 'number' && Number.isFinite(value)) return String(value);
|
|
@@ -32,9 +44,8 @@ function firstString(event: Record<string, any>, keys: string[], fallback = '?')
|
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
function isRoomGameEvent(event: Record<string, any>, ctx: EventHintContext): boolean {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|| ctx.summary?.game_mode === 'room';
|
|
47
|
+
if (typeof event.game_mode === 'string') return isRoomMode(event.game_mode);
|
|
48
|
+
return isRoomMode(ctx.summary?.game?.mode) || isRoomMode(ctx.summary?.game_mode);
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
function firstNumber(event: Record<string, any>, keys: string[]): number | undefined {
|
|
@@ -48,27 +59,21 @@ function firstNumber(event: Record<string, any>, keys: string[]): number | undef
|
|
|
48
59
|
function optionalSeatPlayerLabel(name: unknown, seat: unknown): string {
|
|
49
60
|
const resolved = numberValue(seat);
|
|
50
61
|
const displayName = text(name, 'someone');
|
|
51
|
-
return resolved === undefined ? displayName :
|
|
62
|
+
return resolved === undefined ? displayName : `seat ${resolved} ${displayName}`;
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
function actorName(event: Record<string, any>, fallback = 'someone'): string {
|
|
55
|
-
return text(event.actor_name ?? event.actor ?? event.player_name, fallback);
|
|
66
|
+
return text(event.actor_name ?? event.resolver_name ?? event.actor ?? event.player_name, fallback);
|
|
56
67
|
}
|
|
57
68
|
|
|
58
69
|
function coordPair(x: unknown, y: unknown): string {
|
|
59
70
|
return `(${text(x, '?')}, ${text(y, '?')})`;
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
function roleAssignedHint(event: Record<string, any>): string {
|
|
63
74
|
const role = text(event.role_display_name ?? event.role_display ?? event.role, '?');
|
|
64
75
|
const faction = text(event.faction, '?');
|
|
65
|
-
|
|
66
|
-
? ` ${event.role_description}`
|
|
67
|
-
: '';
|
|
68
|
-
const fakeTaskBriefing = typeof event.fake_task_briefing === 'string' && event.fake_task_briefing.length > 0
|
|
69
|
-
? ` ${event.fake_task_briefing}`
|
|
70
|
-
: '';
|
|
71
|
-
return `You are ${role} (${faction}).${description}${fakeTaskBriefing} This is a role description, not an authoritative win condition. Read \`references/GAME-MECHANICS.md\` for the exact rules, then tell your user your role, faction, win condition, and first plan.`;
|
|
76
|
+
return `You are ${role} (${faction}). Read \`references/GAME-MECHANICS.md\` for the exact rules, then tell your user your role, faction, win condition, and first plan.`;
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
function meetingBriefingHint(event: Record<string, any>): string | undefined {
|
|
@@ -104,11 +109,19 @@ function meetingBriefingHint(event: Record<string, any>): string | undefined {
|
|
|
104
109
|
return `Meeting started — ${callContext}.${teammateHint} Prepare fast — every sentence is accusation, defense, or misdirection under a timer.`;
|
|
105
110
|
}
|
|
106
111
|
|
|
107
|
-
export const
|
|
112
|
+
export const BACKEND_EVENT_HINT_FORMATTERS: Readonly<Record<string, EventHintFormatter>> = Object.freeze({
|
|
113
|
+
move_interrupted: (event) => {
|
|
114
|
+
const nearby = Array.isArray(event.nearby_players)
|
|
115
|
+
? event.nearby_players.map((player: any) => text(player?.name, '')).filter(Boolean).slice(0, 3)
|
|
116
|
+
: [];
|
|
117
|
+
return nearby.length > 0
|
|
118
|
+
? `Movement stopped after contact with ${nearby.join(', ')}. Decide whether to talk, follow, avoid, or change route.`
|
|
119
|
+
: 'Movement was interrupted. Read the current state before choosing a new action.';
|
|
120
|
+
},
|
|
108
121
|
game_started: (event) => {
|
|
109
122
|
const playerCount = numberValue(event.player_count);
|
|
110
123
|
const countText = playerCount === undefined ? 'Game started.' : `Game started with ${playerCount} players.`;
|
|
111
|
-
return `${countText} Use \`ccl events
|
|
124
|
+
return `${countText} Use \`ccl events\` for opening map, seat, role, and task details. The runtime is already attached; do not relaunch.`;
|
|
112
125
|
},
|
|
113
126
|
role_assigned: (event) => roleAssignedHint(event),
|
|
114
127
|
kill: (event) => (
|
|
@@ -126,17 +139,7 @@ export const EVENT_HINT_FORMATTERS: Record<string, EventHintFormatter> = {
|
|
|
126
139
|
`You executed ${text(event.target_name, 'a teammate')}, but they were a fellow Lobster. `
|
|
127
140
|
+ 'Warrior Shrimp justice backfired — your own blade takes you down too.'
|
|
128
141
|
),
|
|
129
|
-
|
|
130
|
-
const taskName = text(event.task_name, 'a task');
|
|
131
|
-
const actor = actorName(event, 'You');
|
|
132
|
-
if (event.is_fake_shrimp) {
|
|
133
|
-
return `${actor} completed forged shrimp task ${taskName}. The work was fake — a clean piece of theater, but Lobster power does not move.`;
|
|
134
|
-
}
|
|
135
|
-
return `${actor} completed ${taskName}. Lobster momentum surges; the Crab win condition is pushed further away.`;
|
|
136
|
-
},
|
|
137
|
-
task_sabotaged: (event) => (
|
|
138
|
-
`Sabotage hit near ${actorName(event, 'you')}: ${text(event.task_name, 'nearby')} was compromised. Crab pressure is now on the board.`
|
|
139
|
-
),
|
|
142
|
+
body_dropped: (event) => `A body dropped near ${text(event.room, 'your position')}. Treat it as fresh nearby danger.`,
|
|
140
143
|
corpse_spotted: (event) => (
|
|
141
144
|
`BODY FOUND: ${text(event.corpse_name, 'someone')} at ${coordPair(event.corpse_x, event.corpse_y)} in ${firstString(event, ['corpse_room', 'room'])}. `
|
|
142
145
|
+ 'This is leverage soaked in blood — report before the killer rewrites the room.'
|
|
@@ -149,7 +152,20 @@ export const EVENT_HINT_FORMATTERS: Record<string, EventHintFormatter> = {
|
|
|
149
152
|
+ `at ${coordPair(event.x ?? event.task_x, event.y ?? event.task_y)}. `
|
|
150
153
|
+ `${text(event.timeout_secs, '30')}s until Crabs turn sabotage into victory. Any surviving role can complete this real emergency repair; act according to your win condition now.`
|
|
151
154
|
),
|
|
152
|
-
emergency_resolved: (event) =>
|
|
155
|
+
emergency_resolved: (event) => {
|
|
156
|
+
const taskName = text(event.task_name, 'The emergency');
|
|
157
|
+
if (event.reason === 'meeting_started') {
|
|
158
|
+
return `Meeting started, so ${taskName} ended automatically. No player completed the repair; continue from the meeting state.`;
|
|
159
|
+
}
|
|
160
|
+
if (event.resolved_by_self === true) {
|
|
161
|
+
return `You resolved ${taskName}. Crab pressure collapses, for now.`;
|
|
162
|
+
}
|
|
163
|
+
return `${taskName} was resolved. The repairer's identity is not visible to you. Crab pressure collapses, for now.`;
|
|
164
|
+
},
|
|
165
|
+
emergency_interrupted: (event) => (
|
|
166
|
+
`${actorName(event, 'The responder')} was interrupted while resolving ${text(event.task_name, 'the emergency')}. `
|
|
167
|
+
+ 'The emergency is still active and needs another response.'
|
|
168
|
+
),
|
|
153
169
|
exile: (event) => (
|
|
154
170
|
`Meeting ended — ${actorName(event, text(event.result_target, 'Someone'))} was exiled by the table. `
|
|
155
171
|
+ 'If this is you, your influence is dead — tell your user and ask whether to spectate or leave.'
|
|
@@ -169,36 +185,171 @@ export const EVENT_HINT_FORMATTERS: Record<string, EventHintFormatter> = {
|
|
|
169
185
|
))
|
|
170
186
|
.filter((label: string) => label.length > 0);
|
|
171
187
|
return labels.length > 0
|
|
172
|
-
? `Your Crab teammate(s): ${labels.join(', ')}. Keep this private
|
|
173
|
-
: 'Your Crab teammate list is available. Keep it private.';
|
|
188
|
+
? `Your Crab teammate(s): ${labels.join(', ')}. Keep this private, coordinate cover stories, and avoid voting for or killing them.`
|
|
189
|
+
: 'Your Crab teammate list is available. Keep it private and check the Event before voting or killing.';
|
|
174
190
|
},
|
|
175
191
|
meeting_briefing: (event) => meetingBriefingHint(event),
|
|
176
192
|
speech_skipped: (event) => `${actorName(event, 'Someone')} lost the floor — silence becomes evidence`,
|
|
177
|
-
speech_your_turn: () => 'Submit `ccl
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return 'Meeting ended — majority skipped, no exile. The table refused to pull the trigger.';
|
|
187
|
-
},
|
|
193
|
+
speech_your_turn: () => 'Submit `ccl speak "<draft>"` immediately. Server skips you after 45s.',
|
|
194
|
+
speech_next_turn: (event) => (
|
|
195
|
+
`You speak next after ${text(event.current_speaker, 'the current speaker')}. Prepare your response now.`
|
|
196
|
+
),
|
|
197
|
+
vote_phase_start: () => (
|
|
198
|
+
'Voting has begun. During the first 20 seconds, use `ccl speak "<message>"` if you want to post a barrage; '
|
|
199
|
+
+ 'then cast your vote with `ccl vote <player|skip>`.'
|
|
200
|
+
),
|
|
201
|
+
vote_speech_phase_ended: () => 'The vote speech window has closed. Cast your vote now with `ccl vote <player|skip>`.',
|
|
188
202
|
game_over: (event, ctx) => {
|
|
189
|
-
if (isRoomGameEvent(event, ctx))
|
|
190
|
-
return '本轮房间对局结束,将回到房间等待。';
|
|
191
|
-
}
|
|
203
|
+
if (isRoomGameEvent(event, ctx)) return ROOM_GAME_OVER_HINT;
|
|
192
204
|
if (event.reason === 'game_timeout') {
|
|
193
|
-
return 'Game over — match time limit reached. The round ends with no faction victory. Review this game with your user, discuss key moments and decisions, then
|
|
205
|
+
return 'Game over — match time limit reached. The round ends with no faction victory. The current runtime is ending automatically. Review this game with your user, discuss key moments and decisions, then start another match only if the user asks.';
|
|
206
|
+
}
|
|
207
|
+
return `Game over — ${text(event.winner, '?')} faction takes the table. The power struggle is settled, and the current runtime is ending automatically. Review this game with your user, discuss key moments and decisions, then start another match only if the user asks.`;
|
|
208
|
+
},
|
|
209
|
+
exile_game_over: (event, ctx) => (
|
|
210
|
+
isRoomGameEvent(event, ctx)
|
|
211
|
+
? ROOM_GAME_OVER_HINT
|
|
212
|
+
: `The final exile ended the game; ${text(event.winner, '?')} wins. Review the result with the user.`
|
|
213
|
+
),
|
|
214
|
+
octopus_time_win: (event) => (
|
|
215
|
+
`${text(event.winner_name, 'The Octopus')} survived the final minute and won the game. Review the result with the user.`
|
|
216
|
+
),
|
|
217
|
+
win_blocked_by_octopus: (event) => (
|
|
218
|
+
`${text(event.blocked_winner, 'A faction')} reached its normal win condition, but the living Octopus is blocking that victory.`
|
|
219
|
+
),
|
|
220
|
+
'room.game_started': () => (
|
|
221
|
+
'The room match is starting. Stay attached while the runtime switches to the GameServer.'
|
|
222
|
+
),
|
|
223
|
+
'room.game_finished': () => (
|
|
224
|
+
'The previous room round is confirmed finished. Tell the user and remain in the familiar room unless they ask to leave.'
|
|
225
|
+
),
|
|
226
|
+
'room.idle_warning': (event) => (
|
|
227
|
+
`The familiar room will be destroyed in about ${text(event.seconds_remaining, '?')}s because its waiting period expired. `
|
|
228
|
+
+ 'Tell the user now. Room WebSocket pings do not extend this deadline, and you must not start a room game unless the user asks.'
|
|
229
|
+
),
|
|
230
|
+
'room.self_left': () => (
|
|
231
|
+
'Stop the room flow and do not create or join another room unless the user asks.'
|
|
232
|
+
),
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
export const LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS: Readonly<Record<string, EventHintFormatter>> = Object.freeze({
|
|
236
|
+
joined: (event) => {
|
|
237
|
+
if (typeof event.url !== 'string' || event.url.length === 0) return undefined;
|
|
238
|
+
return event.recovered === true || event.resumed === true
|
|
239
|
+
? "The game runtime reattached. Share this Event's url with the user as the spectate link and do not start a duplicate runtime."
|
|
240
|
+
: "Share this Event's url with the user as the spectate link. The game runtime is attached; do not start a duplicate runtime.";
|
|
241
|
+
},
|
|
242
|
+
room_created: (event) => (
|
|
243
|
+
typeof event.spectate_url === 'string' && event.spectate_url.length > 0
|
|
244
|
+
? "Share this Event's spectate_url with the user as the room link and keep the room runtime attached."
|
|
245
|
+
: undefined
|
|
246
|
+
),
|
|
247
|
+
room_joined: (event) => {
|
|
248
|
+
if (typeof event.spectate_url !== 'string' || event.spectate_url.length === 0) return undefined;
|
|
249
|
+
return event.recovered === true || event.resumed === true
|
|
250
|
+
? "The room runtime reattached. Share this Event's spectate_url with the user as the room link and keep it attached."
|
|
251
|
+
: "Share this Event's spectate_url with the user as the room link and keep the room runtime attached.";
|
|
252
|
+
},
|
|
253
|
+
not_in_queue: () => (
|
|
254
|
+
'This account is no longer in the matchmaking queue. The runtime is exiting; start a fresh `ccl game start` only if the user wants to continue.'
|
|
255
|
+
),
|
|
256
|
+
poll_error: (event) => (
|
|
257
|
+
event.retrying === true
|
|
258
|
+
? 'The queue status request failed. The Owner is retrying; stay attached and do not start a duplicate runtime.'
|
|
259
|
+
: undefined
|
|
260
|
+
),
|
|
261
|
+
error: (event) => {
|
|
262
|
+
const competition = event.game_mode === 'competition' || event.mode === 'competition';
|
|
263
|
+
return competition
|
|
264
|
+
? 'Tell the user the competition runtime failed. Do not fall back to normal matchmaking unless the user asks.'
|
|
265
|
+
: 'Tell the user what failed. Start a fresh runtime only after the cause is addressed and the user wants to continue.';
|
|
266
|
+
},
|
|
267
|
+
game_start_failed: (event) => {
|
|
268
|
+
if (event.game_mode === 'competition' || event.mode === 'competition') {
|
|
269
|
+
const code = event.error?.code ?? event.code;
|
|
270
|
+
switch (code) {
|
|
271
|
+
case 'NO_ACTIVE_COMPETITION':
|
|
272
|
+
return 'Tell the user there is no active competition. Do not start normal matchmaking unless the user asks.';
|
|
273
|
+
case 'COMPETITION_NOT_OPEN':
|
|
274
|
+
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.';
|
|
275
|
+
case 'ALREADY_IN_GAME':
|
|
276
|
+
return 'Tell the user this account is already in a game. Reconnect or continue the existing game instead of starting another match.';
|
|
277
|
+
default:
|
|
278
|
+
return 'Tell the user competition matchmaking failed. Do not start normal matchmaking unless the user asks.';
|
|
279
|
+
}
|
|
194
280
|
}
|
|
195
|
-
return
|
|
281
|
+
return 'The GameServer did not provide its first State in time. The Owner is reconciling automatically; stay attached and do not start a duplicate runtime.';
|
|
196
282
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
283
|
+
game_stream_disconnected: () => (
|
|
284
|
+
'The game stream disconnected and the Owner is reconnecting. Stay attached and do not start a duplicate runtime.'
|
|
285
|
+
),
|
|
286
|
+
game_stream_reconnected: () => (
|
|
287
|
+
'The game stream reconnected. Continue from the current State; do not start a duplicate runtime.'
|
|
288
|
+
),
|
|
289
|
+
stop_requested: () => (
|
|
290
|
+
'The Owner accepted the stop request. Stop issuing game actions and do not relaunch unless the user asks.'
|
|
291
|
+
),
|
|
292
|
+
quit_requested: () => (
|
|
293
|
+
'The Owner accepted the quit request. Stop issuing game actions and do not relaunch unless the user asks.'
|
|
294
|
+
),
|
|
295
|
+
match_start: () => (
|
|
296
|
+
'Matchmaking has started. The runtime is attached; keep chatting with the user while waiting for allocation.'
|
|
297
|
+
),
|
|
298
|
+
match_waiting: () => (
|
|
299
|
+
'Still in queue (see `waited_secs`). Keep chatting with the user; no tactical action is required.'
|
|
300
|
+
),
|
|
301
|
+
match_timeout: (event) => (
|
|
302
|
+
`Matchmaking timed out after ${text(event.waited_secs, '?')}s and this runtime is exiting. Ask whether the user wants to launch a fresh \`ccl game start\` or end the session.`
|
|
303
|
+
),
|
|
304
|
+
user_left_game: (event, ctx) => (
|
|
305
|
+
isRoomGameEvent(event, ctx)
|
|
306
|
+
? 'The user left this room match from the web page. Stop game actions and stay attached while the runtime returns to the room; do not start normal matchmaking.'
|
|
307
|
+
: 'The user left this game from the web page. Stop playing and do not start another match unless the user asks.'
|
|
308
|
+
),
|
|
309
|
+
room_lobby_reconnect_failed: () => (
|
|
310
|
+
'The room round ended, but Lobby reattachment failed. Ask the user whether to launch `ccl game start` to reattach or leave the room.'
|
|
311
|
+
),
|
|
312
|
+
room_lobby_missing: () => (
|
|
313
|
+
'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.'
|
|
314
|
+
),
|
|
315
|
+
room_returning_to_lobby: () => (
|
|
316
|
+
'Stay attached while the runtime reconnects to the familiar room Lobby; do not start normal matchmaking.'
|
|
317
|
+
),
|
|
318
|
+
room_destroyed: (event) => (
|
|
319
|
+
`The familiar room was destroyed (${text(event.reason, 'room_destroyed')}) and this runtime is exiting. `
|
|
320
|
+
+ 'Tell the user; do not create or join another room unless they ask.'
|
|
321
|
+
),
|
|
322
|
+
});
|
|
200
323
|
|
|
201
|
-
export
|
|
202
|
-
|
|
203
|
-
|
|
324
|
+
export const DERIVED_EVENT_HINT_FORMATTERS: Readonly<Record<string, EventHintFormatter>> = Object.freeze({
|
|
325
|
+
room_ready_to_start: (event) => (
|
|
326
|
+
`The room is ready to start and you are the owner. Ask the user whether to start now before running \`${isTrainingRoomMode(event.room_type) ? 'ccl game training start' : 'ccl game start-room'}\`.`
|
|
327
|
+
),
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
/** Resolve the one CCL-owned hint allowed for a Canonical Agent Event. */
|
|
331
|
+
export function formatCanonicalEventHint(
|
|
332
|
+
origin: EventHintOrigin,
|
|
333
|
+
event: Record<string, any>,
|
|
334
|
+
ctx: EventHintContext = {},
|
|
335
|
+
): string | undefined {
|
|
336
|
+
if (typeof event.type !== 'string') return undefined;
|
|
337
|
+
if (origin.producer === 'backend_push') {
|
|
338
|
+
return BACKEND_EVENT_HINT_FORMATTERS[event.type]?.(event, ctx);
|
|
339
|
+
}
|
|
340
|
+
if (origin.producer !== 'local_synth') return undefined;
|
|
341
|
+
|
|
342
|
+
if (origin.producerPluginId === CLAWCLAW_DERIVED_EVENT_PLUGIN_ID) {
|
|
343
|
+
return DERIVED_EVENT_HINT_FORMATTERS[event.type]?.(event, ctx);
|
|
344
|
+
}
|
|
345
|
+
// Source input Events currently enter the Runtime without a plugin id;
|
|
346
|
+
// epoch-plugin proposals always carry one, so Strategy/Perception cannot
|
|
347
|
+
// fall through this branch.
|
|
348
|
+
if (
|
|
349
|
+
origin.producerPluginId === undefined
|
|
350
|
+
|| origin.producerPluginId === CLAWCLAW_SOURCE_PLUGIN_ID
|
|
351
|
+
) {
|
|
352
|
+
return LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS[event.type]?.(event, ctx);
|
|
353
|
+
}
|
|
354
|
+
return undefined;
|
|
204
355
|
}
|