@myclaw163/clawclaw-cli 0.6.112 → 0.7.4
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 +25 -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 +120 -64
- 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 +18 -8
- 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/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 +40 -3
- 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 +29 -0
- 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 +195 -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/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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { formatEventHint, roleAssignedHint } from './event-hints.js';
|
|
2
1
|
import { projectPlayers } from './player-projection.js';
|
|
2
|
+
import { headingDirection } from '../runtime/clawclaw/plugins/perception/shared/math.js';
|
|
3
|
+
import { isRoomMode } from '../lib/room.js';
|
|
3
4
|
|
|
4
5
|
export interface EventFormatContext {
|
|
5
6
|
summary?: any | null;
|
|
@@ -12,8 +13,6 @@ export interface FormattedEvent {
|
|
|
12
13
|
line?: number;
|
|
13
14
|
type: string;
|
|
14
15
|
tick: number | null;
|
|
15
|
-
notice?: string;
|
|
16
|
-
hint?: string;
|
|
17
16
|
[key: string]: any;
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -25,9 +24,9 @@ function cleanObject<T extends Record<string, any>>(obj: T): T {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
function isRoomGameEvent(event: Record<string, any>, ctx: EventFormatContext): boolean {
|
|
28
|
-
return event.game_mode
|
|
29
|
-
|| ctx.summary?.game?.mode
|
|
30
|
-
|| ctx.summary?.game_mode
|
|
27
|
+
return isRoomMode(event.game_mode)
|
|
28
|
+
|| isRoomMode(ctx.summary?.game?.mode)
|
|
29
|
+
|| isRoomMode(ctx.summary?.game_mode);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
function text(value: unknown, fallback = '?'): string {
|
|
@@ -45,6 +44,121 @@ function numberValue(value: unknown): number | undefined {
|
|
|
45
44
|
return undefined;
|
|
46
45
|
}
|
|
47
46
|
|
|
47
|
+
function stringValue(value: unknown): string | undefined {
|
|
48
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function sceneDistance(
|
|
52
|
+
item: Record<string, any>,
|
|
53
|
+
observer: Record<string, any>,
|
|
54
|
+
): number | undefined {
|
|
55
|
+
const reported = numberValue(item.distance);
|
|
56
|
+
if (reported !== undefined) return Math.round(reported * 10) / 10;
|
|
57
|
+
const observerX = numberValue(observer.x);
|
|
58
|
+
const observerY = numberValue(observer.y);
|
|
59
|
+
const itemX = numberValue(item.x);
|
|
60
|
+
const itemY = numberValue(item.y);
|
|
61
|
+
if (observerX === undefined || observerY === undefined || itemX === undefined || itemY === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return Math.round(Math.hypot(itemX - observerX, itemY - observerY) * 10) / 10;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function sceneDirection(
|
|
68
|
+
item: Record<string, any>,
|
|
69
|
+
observer: Record<string, any>,
|
|
70
|
+
): string | undefined {
|
|
71
|
+
const observerX = numberValue(observer.x);
|
|
72
|
+
const observerY = numberValue(observer.y);
|
|
73
|
+
const itemX = numberValue(item.x);
|
|
74
|
+
const itemY = numberValue(item.y);
|
|
75
|
+
if (observerX === undefined || observerY === undefined || itemX === undefined || itemY === undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return headingDirection({ x: observerX, y: observerY }, { x: itemX, y: itemY }, 1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function projectCurrentScene(
|
|
82
|
+
summary: Record<string, any>,
|
|
83
|
+
players: Array<{ name: string; seat?: number }>,
|
|
84
|
+
): Pick<Record<string, any>, 'visible_players' | 'nearby_corpses'> {
|
|
85
|
+
const observer = summary.you && typeof summary.you === 'object' ? summary.you : {};
|
|
86
|
+
const seatsByName = new Map(players
|
|
87
|
+
.filter((player) => player.seat !== undefined)
|
|
88
|
+
.map((player) => [player.name, player.seat] as const));
|
|
89
|
+
const project = (raw: unknown, withDirection: boolean): Record<string, any> | null => {
|
|
90
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
|
|
91
|
+
const item = raw as Record<string, any>;
|
|
92
|
+
const player = item.player && typeof item.player === 'object' && !Array.isArray(item.player)
|
|
93
|
+
? item.player as Record<string, any>
|
|
94
|
+
: {};
|
|
95
|
+
const name = stringValue(player.name);
|
|
96
|
+
const seat = numberValue(player.seat) ?? (name ? seatsByName.get(name) : undefined);
|
|
97
|
+
if (!name && seat === undefined) return null;
|
|
98
|
+
return cleanObject({
|
|
99
|
+
name,
|
|
100
|
+
seat,
|
|
101
|
+
room: stringValue(item.room),
|
|
102
|
+
relative_direction: withDirection ? sceneDirection(item, observer) : undefined,
|
|
103
|
+
distance_px: sceneDistance(item, observer),
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const projectList = (raw: unknown, withDirection: boolean): Record<string, any>[] | undefined => {
|
|
107
|
+
if (!Array.isArray(raw)) return undefined;
|
|
108
|
+
const projected = raw.map((item: unknown) => project(item, withDirection));
|
|
109
|
+
// An explicit empty set means "nobody visible". A non-empty source with
|
|
110
|
+
// an unidentifiable entry is instead unavailable evidence; do not silently
|
|
111
|
+
// turn a projection failure into an authoritative empty/partial scene.
|
|
112
|
+
return projected.some((item) => item === null)
|
|
113
|
+
? undefined
|
|
114
|
+
: projected as Record<string, any>[];
|
|
115
|
+
};
|
|
116
|
+
return cleanObject({
|
|
117
|
+
visible_players: projectList(summary.visible_players, true),
|
|
118
|
+
nearby_corpses: projectList(summary.visible_corpses, false),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface KnownPlayerForEvents {
|
|
123
|
+
name: string;
|
|
124
|
+
seat: number;
|
|
125
|
+
known_status: Record<string, any>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function projectKnownPlayers(raw: unknown): KnownPlayerForEvents[] | undefined {
|
|
129
|
+
if (!Array.isArray(raw)) return undefined;
|
|
130
|
+
const projected = raw.map((entry: unknown): KnownPlayerForEvents | null => {
|
|
131
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) return null;
|
|
132
|
+
const player = entry as Record<string, any>;
|
|
133
|
+
const name = stringValue(player.name);
|
|
134
|
+
const seat = numberValue(player.seat);
|
|
135
|
+
const knownStatus = player.known_status;
|
|
136
|
+
if (!name || seat === undefined || !Number.isInteger(seat) || seat < 0
|
|
137
|
+
|| !knownStatus || typeof knownStatus !== 'object' || Array.isArray(knownStatus)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const status = knownStatus as Record<string, any>;
|
|
141
|
+
const deathCause = status.death_cause === 'killed' || status.death_cause === 'exiled'
|
|
142
|
+
? status.death_cause
|
|
143
|
+
: undefined;
|
|
144
|
+
return {
|
|
145
|
+
name,
|
|
146
|
+
seat,
|
|
147
|
+
known_status: cleanObject({
|
|
148
|
+
is_alive: typeof status.is_alive === 'boolean' ? status.is_alive : undefined,
|
|
149
|
+
death_cause: deathCause,
|
|
150
|
+
reported_in_current_meeting: typeof status.reported_in_current_meeting === 'boolean'
|
|
151
|
+
? status.reported_in_current_meeting
|
|
152
|
+
: undefined,
|
|
153
|
+
}),
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
// Never turn malformed backend evidence into an authoritative partial roster.
|
|
157
|
+
return projected.some((player) => player === null)
|
|
158
|
+
? undefined
|
|
159
|
+
: projected as KnownPlayerForEvents[];
|
|
160
|
+
}
|
|
161
|
+
|
|
48
162
|
function firstString(event: Record<string, any>, keys: string[], fallback = '?'): string {
|
|
49
163
|
for (const key of keys) {
|
|
50
164
|
const value = event[key];
|
|
@@ -76,25 +190,29 @@ export function seatMapFromSummary(summary: any | null | undefined, extra?: Reco
|
|
|
76
190
|
if (parsed !== undefined) seats[name] = parsed;
|
|
77
191
|
};
|
|
78
192
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
summary?.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
193
|
+
const roomState = typeof summary?.phase === 'string' && summary.phase.startsWith('room_');
|
|
194
|
+
if (roomState) {
|
|
195
|
+
remember(summary?.you?.name, summary?.you?.seat);
|
|
196
|
+
for (const member of Array.isArray(summary?.room?.members) ? summary.room.members : []) {
|
|
197
|
+
remember(member?.name, member?.seat);
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
remember(summary?.you?.player?.name, summary?.you?.player?.seat);
|
|
201
|
+
for (const player of Array.isArray(summary?.players) ? summary.players : []) {
|
|
202
|
+
remember(player?.name, player?.seat);
|
|
203
|
+
}
|
|
204
|
+
for (const collection of [summary?.visible_players, summary?.visible_corpses]) {
|
|
205
|
+
for (const entry of Array.isArray(collection) ? collection : []) {
|
|
206
|
+
remember(entry?.player?.name, entry?.player?.seat);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
remember(summary?.meeting?.caller?.name, summary?.meeting?.caller?.seat);
|
|
210
|
+
remember(summary?.meeting?.current_speaker?.name, summary?.meeting?.current_speaker?.seat);
|
|
211
|
+
for (const speaker of Array.isArray(summary?.meeting?.speech_order)
|
|
212
|
+
? summary.meeting.speech_order
|
|
213
|
+
: []) {
|
|
214
|
+
remember(speaker?.name, speaker?.seat);
|
|
92
215
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const allSeats = summary?.all_seats ?? summary?.game?.all_seats;
|
|
96
|
-
if (allSeats && typeof allSeats === 'object' && !Array.isArray(allSeats)) {
|
|
97
|
-
for (const [name, seat] of Object.entries(allSeats)) remember(name, seat);
|
|
98
216
|
}
|
|
99
217
|
|
|
100
218
|
return seats;
|
|
@@ -185,6 +303,38 @@ function firstReportedCorpse(event: Record<string, any>): Record<string, any> |
|
|
|
185
303
|
return null;
|
|
186
304
|
}
|
|
187
305
|
|
|
306
|
+
function playerChangeDeathText(change: Record<string, any>, ctx: EventFormatContext): string {
|
|
307
|
+
const player = playerLabel(change.name, numberValue(change.seat), ctx);
|
|
308
|
+
if (change.cause === 'exiled') return `${player}已被放逐`;
|
|
309
|
+
if (change.cause === 'self_destruct') return `${player}已自爆出局`;
|
|
310
|
+
const killer = stringValue(change.killer);
|
|
311
|
+
return `${player}已被击杀${killer ? `,凶手${playerLabel(killer, undefined, ctx)}` : ',凶手未知'}`;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function playersChangedBody(event: Record<string, any>, ctx: EventFormatContext): string {
|
|
315
|
+
const changes = Array.isArray(event.changes)
|
|
316
|
+
? event.changes.filter((change: unknown): change is Record<string, any> => (
|
|
317
|
+
!!change && typeof change === 'object' && !Array.isArray(change)
|
|
318
|
+
))
|
|
319
|
+
: [];
|
|
320
|
+
if (changes.length === 0) return '玩家信息发生变化。';
|
|
321
|
+
|
|
322
|
+
const deathsOnly = changes.every((change) => (
|
|
323
|
+
change.change === 'died' || change.change === 'death_updated'
|
|
324
|
+
));
|
|
325
|
+
const details = changes.map((change) => {
|
|
326
|
+
if (change.change === 'discovered') {
|
|
327
|
+
return `发现${playerLabel(change.name, numberValue(change.seat), ctx)}`;
|
|
328
|
+
}
|
|
329
|
+
const death = playerChangeDeathText(change, ctx);
|
|
330
|
+
return change.change === 'death_updated' ? `${death}(死亡信息更新)` : death;
|
|
331
|
+
}).join(';');
|
|
332
|
+
const meetingCount = numberValue(event.meeting_count);
|
|
333
|
+
if (meetingCount !== undefined && deathsOnly) return `第${meetingCount}次会议中发现${details}。`;
|
|
334
|
+
if (event.meeting === true && deathsOnly) return `会议中发现${details}。`;
|
|
335
|
+
return `玩家信息变化:${details}。`;
|
|
336
|
+
}
|
|
337
|
+
|
|
188
338
|
function shortBody(event: Record<string, any>, ctx: EventFormatContext): string {
|
|
189
339
|
const maxTextLength = ctx.maxTextLength ?? 100;
|
|
190
340
|
switch (event.type) {
|
|
@@ -197,7 +347,7 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
197
347
|
? '普通匹配'
|
|
198
348
|
: '';
|
|
199
349
|
const prefixText = modeText ? `${countText}(${modeText})` : countText;
|
|
200
|
-
return `${prefixText}
|
|
350
|
+
return `${prefixText}。`;
|
|
201
351
|
}
|
|
202
352
|
case 'role_assigned': {
|
|
203
353
|
const start = ctx.isFirstVisibleEvent ? '对局开始。' : '';
|
|
@@ -217,14 +367,36 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
217
367
|
}
|
|
218
368
|
case 'task_sabotaged':
|
|
219
369
|
return `破坏任务完成:${firstString(event, ['task_name'])}(${firstString(event, ['room'])})。`;
|
|
370
|
+
case 'players_changed':
|
|
371
|
+
return playersChangedBody(event, ctx);
|
|
372
|
+
case 'move_interrupted': {
|
|
373
|
+
const nearby = Array.isArray(event.nearby_players)
|
|
374
|
+
? event.nearby_players
|
|
375
|
+
.slice(0, 3)
|
|
376
|
+
.map((player: any) => playerLabel(player?.name, numberValue(player?.seat), ctx))
|
|
377
|
+
.filter(Boolean)
|
|
378
|
+
: [];
|
|
379
|
+
const contact = nearby.length > 0 ? `,附近有${nearby.join('、')}` : '';
|
|
380
|
+
return `移动已中断${contact}。`;
|
|
381
|
+
}
|
|
220
382
|
case 'corpse_spotted':
|
|
221
383
|
return `我发现了${playerLabel(event.corpse_name, firstNumber(event, ['corpse_seat', 'corpse_player_seat']), ctx)}的尸体,在${firstString(event, ['corpse_room', 'room'])}。`;
|
|
384
|
+
case 'body_dropped':
|
|
385
|
+
return `你听到${firstString(event, ['room'])}附近有尸体倒地。`;
|
|
222
386
|
case 'octopus_time_start':
|
|
223
387
|
return '章鱼时间开始:存活人数已降至3人或更少,章鱼存活60秒将获胜;会议已禁用,但虾方任务完成或紧急任务超时仍可先结束本局。';
|
|
224
388
|
case 'emergency_started':
|
|
225
389
|
return `紧急任务:${firstString(event, ['task_name'])}在${firstString(event, ['room'])},${text(event.timeout_secs, '?')}秒内处理。`;
|
|
226
390
|
case 'emergency_resolved':
|
|
391
|
+
if (event.reason === 'meeting_started') {
|
|
392
|
+
return `会议开始,紧急任务${firstString(event, ['task_name'])}已自动解除。`;
|
|
393
|
+
}
|
|
394
|
+
if (event.resolved_by_self === true) {
|
|
395
|
+
return `你已解决紧急任务:${firstString(event, ['task_name'])}。`;
|
|
396
|
+
}
|
|
227
397
|
return `紧急任务已解决:${firstString(event, ['task_name'])}。`;
|
|
398
|
+
case 'emergency_interrupted':
|
|
399
|
+
return `${playerLabel(event.actor_name, firstNumber(event, ['actor_seat', 'seat']), ctx)}在处理${firstString(event, ['task_name'])}时死亡,紧急任务仍未解除。`;
|
|
228
400
|
case 'meeting_briefing': {
|
|
229
401
|
const callerName = firstString(event, ['meeting_caller_name', 'caller', 'actor_name']);
|
|
230
402
|
const caller = playerLabel(callerName, firstNumber(event, ['meeting_caller_seat', 'caller_seat', 'actor_seat']), ctx);
|
|
@@ -239,13 +411,15 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
239
411
|
case 'speech_skipped':
|
|
240
412
|
return `${playerLabel(event.actor_name, firstNumber(event, ['actor_seat', 'seat']), ctx)}发言超时,被跳过。`;
|
|
241
413
|
case 'speech_your_turn':
|
|
242
|
-
return '
|
|
414
|
+
return '轮到你发言。';
|
|
415
|
+
case 'speech_next_turn':
|
|
416
|
+
return `${playerLabel(event.current_speaker, firstNumber(event, ['current_speaker_seat']), ctx)}正在发言,下一位轮到你。`;
|
|
243
417
|
case 'vote_phase_start':
|
|
244
|
-
return '
|
|
418
|
+
return '投票阶段开始。';
|
|
245
419
|
case 'vote_cast':
|
|
246
420
|
return `${playerLabel(event.actor_name, firstNumber(event, ['actor_seat', 'seat']), ctx)}已投票。`;
|
|
247
421
|
case 'vote_speech_phase_ended':
|
|
248
|
-
return '
|
|
422
|
+
return '投票弹幕窗口已关闭。';
|
|
249
423
|
case 'exile': {
|
|
250
424
|
const exiledName = event.result_target ?? event.actor_name;
|
|
251
425
|
const exiledSeat = firstNumber(event, ['result_target_seat', 'actor_seat', 'seat']);
|
|
@@ -255,6 +429,8 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
255
429
|
return '会议结束:无人被放逐。';
|
|
256
430
|
case 'meeting_ended':
|
|
257
431
|
return '会议结束。';
|
|
432
|
+
case 'exile_game_over':
|
|
433
|
+
return `放逐结算后游戏结束:${firstString(event, ['winner'])}阵营获胜。`;
|
|
258
434
|
case 'death_speech': {
|
|
259
435
|
const speakerName = event.speaker_name ?? event.actor_name;
|
|
260
436
|
const speakerSeat = firstNumber(event, ['speaker_seat', 'actor_seat', 'seat']);
|
|
@@ -267,14 +443,48 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
267
443
|
case 'wandering_speech':
|
|
268
444
|
return `${text(event.actor_name, '你')}在${firstString(event, ['room'])}说:${truncate(event.text ?? event.message, maxTextLength)}`;
|
|
269
445
|
case 'game_over':
|
|
270
|
-
if (isRoomGameEvent(event, ctx)) return '
|
|
446
|
+
if (isRoomGameEvent(event, ctx)) return '本轮房间对局结束。';
|
|
271
447
|
return `游戏结束:${firstString(event, ['winner_name'], '未知玩家')}获胜(${firstString(event, ['winner'])}),原因 ${firstString(event, ['reason'])}。`;
|
|
448
|
+
case 'octopus_time_win':
|
|
449
|
+
return `${playerLabel(event.winner_name ?? event.actor_name, firstNumber(event, ['winner_seat', 'actor_seat']), ctx)}作为章鱼存活满60秒并获胜。`;
|
|
450
|
+
case 'win_blocked_by_octopus':
|
|
451
|
+
return `${firstString(event, ['blocked_winner'])}已满足胜利条件,但章鱼仍存活,当前尚未获胜(${firstString(event, ['reason'])})。`;
|
|
272
452
|
case 'user_left_game':
|
|
273
|
-
return '
|
|
453
|
+
return '用户已从网页离开本局。';
|
|
454
|
+
case 'joined':
|
|
455
|
+
return '已加入匹配队列,游戏长流已接入。';
|
|
456
|
+
case 'room_created':
|
|
457
|
+
return `已创建房间 ${firstString(event, ['room_code'])},房间长流已接入。`;
|
|
458
|
+
case 'room_joined':
|
|
459
|
+
return `已加入房间 ${firstString(event, ['room_code'])},房间长流已接入。`;
|
|
460
|
+
case 'session_resumed':
|
|
461
|
+
return '已重新接入后端现有的匹配或对局。';
|
|
462
|
+
case 'session_recovered':
|
|
463
|
+
return '初始请求确认缺失或失败;队列状态回查已确认当前参与有效,本地缺失期间的历史可能不完整。';
|
|
464
|
+
case 'session_left':
|
|
465
|
+
return '后端已确认离开当前匹配、对局或房间。';
|
|
466
|
+
case 'quit_failed':
|
|
467
|
+
return `退出远端参与失败:${firstString(event.error ?? event, ['message', 'code'], 'unknown')}。`;
|
|
468
|
+
case 'match_start':
|
|
469
|
+
return '匹配长流已连接,正在等待分配对局。';
|
|
274
470
|
case 'match_waiting':
|
|
275
471
|
return `仍在匹配队列,已等待${text(event.waited_secs, '?')}秒。`;
|
|
276
472
|
case 'match_timeout':
|
|
277
|
-
return `匹配超时,累计等待${text(event.waited_secs, '?')}
|
|
473
|
+
return `匹配超时,累计等待${text(event.waited_secs, '?')}秒。`;
|
|
474
|
+
case 'not_in_queue':
|
|
475
|
+
return '账号已不在匹配队列,本次长流即将退出。';
|
|
476
|
+
case 'poll_error':
|
|
477
|
+
return `匹配状态查询暂时失败,Owner仍在重试(${text(event.consecutive_failures, '?')}次)。`;
|
|
478
|
+
case 'game_start_failed':
|
|
479
|
+
return `启动对局失败:${firstString(event.error ?? event, ['message', 'code'], 'unknown')}。`;
|
|
480
|
+
case 'game_stream_disconnected':
|
|
481
|
+
return 'GameServer长流已断开,Owner正在重连。';
|
|
482
|
+
case 'game_stream_reconnected':
|
|
483
|
+
return 'GameServer长流已重新连接。';
|
|
484
|
+
case 'quit_requested':
|
|
485
|
+
return 'Owner已接受退出请求,正在结束当前游戏长流。';
|
|
486
|
+
case 'stop_requested':
|
|
487
|
+
return 'Owner已接受停止请求,正在关闭本地游戏长流。';
|
|
278
488
|
case 'room.snapshot': {
|
|
279
489
|
const count = Array.isArray(event.members) ? event.members.length : event.member_count;
|
|
280
490
|
const owner = event.is_owner ? '你是房主' : '等待房主';
|
|
@@ -284,14 +494,22 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
284
494
|
}
|
|
285
495
|
case 'room.member_joined':
|
|
286
496
|
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ['seat']), ctx)}加入房间。`;
|
|
497
|
+
case 'room.member_status_changed': {
|
|
498
|
+
const status = event.status === 'online'
|
|
499
|
+
? '在线'
|
|
500
|
+
: event.status === 'offline'
|
|
501
|
+
? '离线'
|
|
502
|
+
: event.status === 'in_game' ? '游戏中' : text(event.status, '未知');
|
|
503
|
+
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ['seat']), ctx)}状态变为${status}。`;
|
|
504
|
+
}
|
|
287
505
|
case 'room.member_left':
|
|
288
506
|
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ['seat']), ctx)}离开房间。`;
|
|
289
507
|
case 'room.owner_changed':
|
|
290
508
|
return `房主变更为${playerLabel(event.name ?? event.agent_id, firstNumber(event, ['seat']), ctx)}。`;
|
|
291
509
|
case 'room.full':
|
|
292
|
-
return '
|
|
510
|
+
return '房间人数已满。';
|
|
293
511
|
case 'room_ready_to_start':
|
|
294
|
-
return '
|
|
512
|
+
return '房间已满足开局条件,你是房主。';
|
|
295
513
|
case 'room.chat':
|
|
296
514
|
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ['seat']), ctx)}房间弹幕:${truncate(event.content ?? event.text ?? event.message, maxTextLength)}`;
|
|
297
515
|
case 'room.game_starting':
|
|
@@ -304,11 +522,22 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
304
522
|
return '上一轮房间对局已结束,所有人已回到房间。';
|
|
305
523
|
case 'room.cooldown':
|
|
306
524
|
return `房间冷却中:${text(event.seconds_remaining ?? event.cooldown_seconds, '?')}秒。`;
|
|
525
|
+
case 'room.idle_warning':
|
|
526
|
+
return `房间等待超时,将在${text(event.seconds_remaining, '?')}秒后自动销毁。`;
|
|
307
527
|
case 'room.self_left':
|
|
308
|
-
|
|
309
|
-
|
|
528
|
+
return '当前账号已离开房间。';
|
|
529
|
+
case 'room_destroyed':
|
|
530
|
+
if (event.reason === 'idle_timeout') return '房间因等待超时已自动销毁。';
|
|
531
|
+
if (event.reason === 'gm_destroy') return '房间已由管理员销毁。';
|
|
532
|
+
return `房间已销毁:${text(event.reason, 'room_destroyed')}。`;
|
|
310
533
|
case 'room_returning_to_lobby':
|
|
311
534
|
return '房间对局已结束,正在重连 Lobby 房间长流。';
|
|
535
|
+
case 'room_attached':
|
|
536
|
+
return '房间长流已连接,正在等待房间更新。';
|
|
537
|
+
case 'room_lobby_reconnect_failed':
|
|
538
|
+
return '房间对局已结束,但重新连接 Lobby 失败。';
|
|
539
|
+
case 'room_lobby_missing':
|
|
540
|
+
return '房间对局已结束,但账号已不在原房间。';
|
|
312
541
|
case 'room_ping_timeout':
|
|
313
542
|
return '房间 Lobby 连接心跳超时,正在重连。';
|
|
314
543
|
case 'robot_speak_rule':
|
|
@@ -325,16 +554,19 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
|
|
|
325
554
|
case 'not_logged_in':
|
|
326
555
|
return '未登录。';
|
|
327
556
|
case 'not_ready':
|
|
328
|
-
return '
|
|
557
|
+
return '游戏运行时未就绪。';
|
|
329
558
|
case 'error':
|
|
330
559
|
return text(event.message ?? event.error, '发生错误。');
|
|
331
560
|
default:
|
|
332
|
-
return truncate(event.message ?? event.
|
|
561
|
+
return truncate(event.message ?? event.text ?? event.type, maxTextLength);
|
|
333
562
|
}
|
|
334
563
|
}
|
|
335
564
|
|
|
336
565
|
export function formatEventMessage(event: Record<string, any>, ctx: EventFormatContext = {}): string {
|
|
337
|
-
|
|
566
|
+
const factual = `${prefix(event)} ${shortBody(event, ctx)}`;
|
|
567
|
+
return typeof event.hint === 'string' && event.hint.length > 0
|
|
568
|
+
? `${factual} Hint: ${event.hint}`
|
|
569
|
+
: factual;
|
|
338
570
|
}
|
|
339
571
|
|
|
340
572
|
function taskKindForEvents(task: any, event: Record<string, any>): string | undefined {
|
|
@@ -350,6 +582,8 @@ function compactRoleAssignedForEvents(event: Record<string, any>): FormattedEven
|
|
|
350
582
|
? event.assigned_tasks.map((task: any) => cleanObject({
|
|
351
583
|
name: task?.name,
|
|
352
584
|
room: task?.room,
|
|
585
|
+
x: task?.x,
|
|
586
|
+
y: task?.y,
|
|
353
587
|
kind: taskKindForEvents(task, event),
|
|
354
588
|
}))
|
|
355
589
|
: undefined;
|
|
@@ -376,18 +610,11 @@ function compactRoleAssignedForEvents(event: Record<string, any>): FormattedEven
|
|
|
376
610
|
task_kind: useTopLevelTaskKind ? taskKinds[0] : undefined,
|
|
377
611
|
task_note: hasFakeTask ? 'Fake shrimp tasks: disguise only; no lobster progress.' : undefined,
|
|
378
612
|
tasks: compactTasks,
|
|
379
|
-
hint: roleAssignedHint(event),
|
|
380
613
|
});
|
|
381
614
|
}
|
|
382
615
|
|
|
383
|
-
function stripBackendHint(event: Record<string, any>): Record<string, any> {
|
|
384
|
-
const { hint: _hint, ...rest } = event;
|
|
385
|
-
return { ...rest };
|
|
386
|
-
}
|
|
387
|
-
|
|
388
616
|
function compactVoteCastForEvents(event: Record<string, any>, ctx: EventFormatContext): FormattedEvent {
|
|
389
617
|
const {
|
|
390
|
-
hint: _hint,
|
|
391
618
|
target: _target,
|
|
392
619
|
target_name: _targetName,
|
|
393
620
|
target_seat: _targetSeat,
|
|
@@ -398,13 +625,11 @@ function compactVoteCastForEvents(event: Record<string, any>, ctx: EventFormatCo
|
|
|
398
625
|
...rest,
|
|
399
626
|
type: text(rest.type, 'event'),
|
|
400
627
|
tick: numberValue(rest.tick) ?? null,
|
|
401
|
-
hint: formatEventHint(event, ctx),
|
|
402
628
|
});
|
|
403
629
|
}
|
|
404
630
|
|
|
405
631
|
function compactCrabTeammatesForEvents(event: Record<string, any>, ctx: EventFormatContext): FormattedEvent {
|
|
406
632
|
const {
|
|
407
|
-
hint: _hint,
|
|
408
633
|
teammates: _teammates,
|
|
409
634
|
crab_teammates: _crabTeammates,
|
|
410
635
|
...rest
|
|
@@ -414,13 +639,11 @@ function compactCrabTeammatesForEvents(event: Record<string, any>, ctx: EventFor
|
|
|
414
639
|
type: text(rest.type, 'event'),
|
|
415
640
|
tick: numberValue(rest.tick) ?? null,
|
|
416
641
|
crab_teammates: teammateObjects(event, ctx),
|
|
417
|
-
hint: formatEventHint(event, ctx),
|
|
418
642
|
});
|
|
419
643
|
}
|
|
420
644
|
|
|
421
645
|
function compactMeetingResultForEvents(event: Record<string, any>, ctx: EventFormatContext): FormattedEvent {
|
|
422
646
|
const {
|
|
423
|
-
hint: _hint,
|
|
424
647
|
votes: _votes,
|
|
425
648
|
...rest
|
|
426
649
|
} = event;
|
|
@@ -438,7 +661,47 @@ function compactMeetingResultForEvents(event: Record<string, any>, ctx: EventFor
|
|
|
438
661
|
result: event.type === 'exile' ? 'exiled' : 'no_exile',
|
|
439
662
|
exiled_player: playerObject(exiledName, exiledSeat, ctx),
|
|
440
663
|
votes: formatVotes(event.votes, ctx),
|
|
441
|
-
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function compactPlayersChangedForEvents(event: Record<string, any>): FormattedEvent {
|
|
668
|
+
const changes = Array.isArray(event.changes)
|
|
669
|
+
? event.changes
|
|
670
|
+
.filter((change: unknown): change is Record<string, any> => (
|
|
671
|
+
!!change && typeof change === 'object' && !Array.isArray(change)
|
|
672
|
+
))
|
|
673
|
+
.map((change) => cleanObject({
|
|
674
|
+
change: change.change,
|
|
675
|
+
name: change.name,
|
|
676
|
+
seat: numberValue(change.seat),
|
|
677
|
+
cause: change.cause,
|
|
678
|
+
killer: change.killer,
|
|
679
|
+
}))
|
|
680
|
+
: [];
|
|
681
|
+
const players = Array.isArray(event.players)
|
|
682
|
+
? event.players
|
|
683
|
+
.filter((player: unknown): player is Record<string, any> => (
|
|
684
|
+
!!player && typeof player === 'object' && !Array.isArray(player)
|
|
685
|
+
))
|
|
686
|
+
.map((player) => cleanObject({
|
|
687
|
+
name: player.name,
|
|
688
|
+
seat: numberValue(player.seat),
|
|
689
|
+
status: player.status,
|
|
690
|
+
death: player.death && typeof player.death === 'object'
|
|
691
|
+
? cleanObject({
|
|
692
|
+
cause: player.death.cause,
|
|
693
|
+
killer: player.death.killer ?? null,
|
|
694
|
+
})
|
|
695
|
+
: null,
|
|
696
|
+
}))
|
|
697
|
+
: [];
|
|
698
|
+
return cleanObject({
|
|
699
|
+
type: 'players_changed',
|
|
700
|
+
tick: numberValue(event.tick) ?? null,
|
|
701
|
+
meeting: event.meeting === true ? true : undefined,
|
|
702
|
+
meeting_count: numberValue(event.meeting_count),
|
|
703
|
+
changes,
|
|
704
|
+
players,
|
|
442
705
|
});
|
|
443
706
|
}
|
|
444
707
|
|
|
@@ -449,25 +712,23 @@ export function compactEventForEvents(
|
|
|
449
712
|
if (event.type === 'role_assigned') return compactRoleAssignedForEvents(event);
|
|
450
713
|
|
|
451
714
|
if (event.type === 'meeting_briefing') {
|
|
452
|
-
const { room: _room,
|
|
715
|
+
const { room: _room, ...rest } = event;
|
|
453
716
|
return cleanObject({
|
|
454
717
|
...rest,
|
|
455
718
|
type: text(rest.type, 'event'),
|
|
456
719
|
tick: numberValue(rest.tick) ?? null,
|
|
457
|
-
hint: formatEventHint(event, ctx),
|
|
458
720
|
});
|
|
459
721
|
}
|
|
460
722
|
|
|
461
723
|
if (event.type === 'vote_cast') return compactVoteCastForEvents(event, ctx);
|
|
462
724
|
if (event.type === 'crab_teammates') return compactCrabTeammatesForEvents(event, ctx);
|
|
463
725
|
if (event.type === 'exile' || event.type === 'no_exile') return compactMeetingResultForEvents(event, ctx);
|
|
726
|
+
if (event.type === 'players_changed') return compactPlayersChangedForEvents(event);
|
|
464
727
|
|
|
465
|
-
const compact = stripBackendHint(event);
|
|
466
728
|
return cleanObject({
|
|
467
|
-
...
|
|
468
|
-
type: text(
|
|
469
|
-
tick: numberValue(
|
|
470
|
-
hint: formatEventHint(event, ctx),
|
|
729
|
+
...event,
|
|
730
|
+
type: text(event.type, 'event'),
|
|
731
|
+
tick: numberValue(event.tick) ?? null,
|
|
471
732
|
});
|
|
472
733
|
}
|
|
473
734
|
|
|
@@ -503,8 +764,11 @@ export function compactStateForEvents(
|
|
|
503
764
|
status: room.status,
|
|
504
765
|
member_count: room.member_count,
|
|
505
766
|
deadline: room.deadline,
|
|
767
|
+
idle_destroy_at: room.idle_destroy_at,
|
|
506
768
|
is_owner: room.is_owner,
|
|
507
769
|
ready_to_start: room.ready_to_start,
|
|
770
|
+
role_config: room.role_config,
|
|
771
|
+
role_lock_character_id: room.role_lock_character_id,
|
|
508
772
|
members: room.members,
|
|
509
773
|
game_id: room.game_id,
|
|
510
774
|
game_server_name: room.game_server_name,
|
|
@@ -513,9 +777,13 @@ export function compactStateForEvents(
|
|
|
513
777
|
type: event.type,
|
|
514
778
|
room_code: event.room_code,
|
|
515
779
|
name: event.name,
|
|
780
|
+
agent_id: event.agent_id,
|
|
516
781
|
seat: event.seat,
|
|
782
|
+
status: event.status,
|
|
517
783
|
content: event.content,
|
|
518
784
|
reason: event.reason,
|
|
785
|
+
destroy_at: event.destroy_at,
|
|
786
|
+
close_code: event.close_code,
|
|
519
787
|
seconds_remaining: event.seconds_remaining,
|
|
520
788
|
})),
|
|
521
789
|
automation: summary.automation,
|
|
@@ -523,39 +791,56 @@ export function compactStateForEvents(
|
|
|
523
791
|
}
|
|
524
792
|
const you = summary.you ?? {};
|
|
525
793
|
const meeting = summary.meeting ?? null;
|
|
526
|
-
const
|
|
794
|
+
const crabSabotage = summary.crab_sabotage && typeof summary.crab_sabotage === 'object'
|
|
795
|
+
&& !Array.isArray(summary.crab_sabotage)
|
|
796
|
+
? summary.crab_sabotage
|
|
797
|
+
: null;
|
|
527
798
|
const votesSubmitted = Array.isArray(meeting?.votes_submitted) ? meeting.votes_submitted : undefined;
|
|
799
|
+
const knownPlayers = projectKnownPlayers(summary.players);
|
|
800
|
+
const currentScene = projectCurrentScene(summary, knownPlayers ?? projectPlayers({ summary }));
|
|
528
801
|
return cleanObject({
|
|
529
802
|
phase: summary.phase,
|
|
530
803
|
tick: summary.tick,
|
|
531
804
|
you: cleanObject({
|
|
532
|
-
name: you.name,
|
|
533
|
-
seat: you.seat,
|
|
805
|
+
name: you.player?.name,
|
|
806
|
+
seat: you.player?.seat,
|
|
534
807
|
role: you.role,
|
|
535
|
-
role_display: you.role_display,
|
|
536
808
|
faction: you.faction,
|
|
537
|
-
alive: you.
|
|
809
|
+
alive: you.is_alive,
|
|
538
810
|
room: you.room,
|
|
539
811
|
kill_cooldown_secs: you.kill_cooldown_secs,
|
|
540
|
-
|
|
541
|
-
|
|
812
|
+
activity: you.activity,
|
|
813
|
+
tasks: Array.isArray(you.tasks) ? you.tasks : undefined,
|
|
814
|
+
crab_teammates: Array.isArray(you.crab_teammates)
|
|
815
|
+
? teammateObjects({ crab_teammates: you.crab_teammates }, { summary })
|
|
816
|
+
: undefined,
|
|
542
817
|
}),
|
|
543
|
-
game:
|
|
544
|
-
|
|
545
|
-
|
|
818
|
+
game: cleanObject({
|
|
819
|
+
alive_count: Array.isArray(summary.players)
|
|
820
|
+
? summary.players.filter((player: any) => player?.known_status?.is_alive !== false).length
|
|
821
|
+
: undefined,
|
|
546
822
|
task_progress: summary.task_progress,
|
|
823
|
+
winner: summary.winner,
|
|
824
|
+
settlement: summary.settlement,
|
|
547
825
|
}),
|
|
548
|
-
players:
|
|
549
|
-
|
|
826
|
+
players: knownPlayers,
|
|
827
|
+
...currentScene,
|
|
828
|
+
meeting: meeting?.active === true
|
|
550
829
|
? cleanObject({
|
|
551
830
|
caller: meeting.caller,
|
|
552
831
|
sub_phase: meeting.sub_phase,
|
|
553
832
|
current_speaker: meeting.current_speaker,
|
|
554
|
-
is_my_turn: meeting.
|
|
555
|
-
|
|
833
|
+
is_my_turn: meeting.current_speaker?.seat !== undefined
|
|
834
|
+
&& meeting.current_speaker.seat === you.player?.seat,
|
|
556
835
|
votes_submitted_count: votesSubmitted?.length,
|
|
557
836
|
})
|
|
558
837
|
: undefined,
|
|
838
|
+
crab_sabotage: crabSabotage
|
|
839
|
+
? cleanObject({
|
|
840
|
+
status: stringValue(crabSabotage.status),
|
|
841
|
+
cooldown_remaining_secs: numberValue(crabSabotage.cooldown_remaining_secs),
|
|
842
|
+
})
|
|
843
|
+
: undefined,
|
|
559
844
|
urgent: summary.urgent,
|
|
560
845
|
automation: summary.automation,
|
|
561
846
|
});
|
|
@@ -568,6 +853,7 @@ export function shortStateText(summary: any | null | undefined): string {
|
|
|
568
853
|
const room = summary.room ?? {};
|
|
569
854
|
const parts = [phase];
|
|
570
855
|
if (room.room_code) parts.push(`room=${room.room_code}`);
|
|
856
|
+
if (room.room_type) parts.push(`mode=${room.room_type}`);
|
|
571
857
|
if (room.status) parts.push(`status=${room.status}`);
|
|
572
858
|
if (room.member_count !== undefined) parts.push(`members=${room.member_count}/10`);
|
|
573
859
|
if (room.is_owner !== undefined) parts.push(room.is_owner ? 'owner=yes' : 'owner=no');
|
|
@@ -577,17 +863,16 @@ export function shortStateText(summary: any | null | undefined): string {
|
|
|
577
863
|
const sub = typeof summary.meeting?.sub_phase === 'string' ? `/${summary.meeting.sub_phase}` : '';
|
|
578
864
|
const parts = [`${phase}${sub}`];
|
|
579
865
|
const you = summary.you ?? {};
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (typeof
|
|
583
|
-
else parts.push(`you=${
|
|
866
|
+
const self = you.player && typeof you.player === 'object' ? you.player : {};
|
|
867
|
+
if (self.name) {
|
|
868
|
+
if (typeof you.is_alive === 'boolean') parts.push(`you=${self.name} ${you.is_alive ? 'alive' : 'dead'}`);
|
|
869
|
+
else parts.push(`you=${self.name}`);
|
|
584
870
|
}
|
|
585
871
|
const speaker = summary.meeting?.current_speaker;
|
|
586
|
-
if (speaker) parts.push(`speaker=${
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
: summary.game?.alive_count ?? summary.alive_count;
|
|
872
|
+
if (speaker?.name) parts.push(`speaker=${speaker.seat === self.seat ? 'you' : speaker.name}`);
|
|
873
|
+
const aliveCount = Array.isArray(summary.players)
|
|
874
|
+
? summary.players.filter((player: any) => player?.known_status?.is_alive !== false).length
|
|
875
|
+
: undefined;
|
|
591
876
|
if (aliveCount !== undefined) parts.push(`alive=${aliveCount}`);
|
|
592
877
|
if (summary.urgent?.emergency_active) parts.push('urgent=emergency');
|
|
593
878
|
if (summary.urgent?.corpse_nearby) parts.push('urgent=corpse');
|