@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,748 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../sdk/types.js';
|
|
2
|
-
import { existsSync, writeFileSync, unlinkSync, readFileSync, statSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { execFileSync } from 'child_process';
|
|
5
|
-
import { GameClient } from '../lib/game-client.js';
|
|
6
|
-
import { ApiError, formatApiError } from '../lib/http-transport.js';
|
|
7
|
-
import { EventStore, extractNewEvents } from '../pipeline/event-store.js';
|
|
8
|
-
import { AuthStore } from '../lib/auth.js';
|
|
9
|
-
import { getProfileStateDir } from '../lib/init-command.js';
|
|
10
|
-
import type { Action } from '../sdk/action.js';
|
|
11
|
-
import type { Strategy, StrategyContext, BehaviorDecision } from './types.js';
|
|
12
|
-
import { resolveStrategy } from './loader.js';
|
|
13
|
-
import { CorpseMemory } from './game-utils.js';
|
|
14
|
-
import {
|
|
15
|
-
meetingEndedInEvents,
|
|
16
|
-
meetingStartedInEvents,
|
|
17
|
-
octopusTimeStartedInEvents,
|
|
18
|
-
shouldPauseForMeeting,
|
|
19
|
-
} from './meeting-gate.js';
|
|
20
|
-
import { createStrategyNewEventsBackfill } from './new-events-backfill.js';
|
|
21
|
-
import {
|
|
22
|
-
buildKnowledgeView,
|
|
23
|
-
currentGameId,
|
|
24
|
-
emptyKnowledgeView,
|
|
25
|
-
knowledgeFilePathForActiveAccount,
|
|
26
|
-
readKnowledgeFileResult,
|
|
27
|
-
} from '../lib/knowledge-store.js';
|
|
28
|
-
|
|
29
|
-
function sleep(ms: number): Promise<void> {
|
|
30
|
-
return new Promise(r => setTimeout(r, ms));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const RECENT_KILL_IGNORE_MS = 3000;
|
|
34
|
-
const SETUP_EVENTS_BACKFILLED_BY_STATE = new Set(['role_assigned', 'game_started', 'crab_teammates']);
|
|
35
|
-
|
|
36
|
-
function formatErrorMessage(err: unknown): string {
|
|
37
|
-
if (err instanceof ApiError) return formatApiError(err);
|
|
38
|
-
return err instanceof Error ? err.message : String(err);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function eventsForStrategyStateLog(events: any): Record<string, any>[] {
|
|
42
|
-
return extractNewEvents(events).filter((event) => !SETUP_EVENTS_BACKFILLED_BY_STATE.has(event.type));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** 章鱼时间进入提示,动作响应与主循环两条消费入口共用同一文案。 */
|
|
46
|
-
const OCTOPUS_TIME_START_NOTICE =
|
|
47
|
-
'章鱼时间开始,会议/报尸已禁用,切换到生存优先,不再报尸召集会议。';
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 消费 octopus_time_start:置 ctx.octopusTimeActive 并提示一次。动作响应的 new_events 与主循环
|
|
51
|
-
* 补偿后的 state.new_events 两条入口都走它,避免置位/文案逻辑分叉。已在章鱼时间则幂等跳过,
|
|
52
|
-
* 因此同一事件经动作响应与日志补偿重复到达也只提示一次。
|
|
53
|
-
*/
|
|
54
|
-
function enterOctopusTimeIfStarted(ctx: StrategyContext, events: any[] | undefined): void {
|
|
55
|
-
if (ctx.octopusTimeActive || !octopusTimeStartedInEvents(events)) return;
|
|
56
|
-
ctx.octopusTimeActive = true;
|
|
57
|
-
ctx.notifications.push(OCTOPUS_TIME_START_NOTICE);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function getPidPath(): string {
|
|
61
|
-
const profile = new AuthStore().getActive();
|
|
62
|
-
if (!profile) throw new Error('Not logged in.');
|
|
63
|
-
return join(getProfileStateDir(profile), 'auto.pid');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function getStatusPath(): string {
|
|
67
|
-
const profile = new AuthStore().getActive();
|
|
68
|
-
if (!profile) throw new Error('Not logged in.');
|
|
69
|
-
return join(getProfileStateDir(profile), 'auto.json');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function shouldWriteStrategyRuntimeFiles(): boolean {
|
|
73
|
-
return process.env.CLAWCLAW_STRATEGY_RUNTIME_FILES === '1';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function isStrategyRunning(): boolean {
|
|
77
|
-
try {
|
|
78
|
-
const pidPath = getPidPath();
|
|
79
|
-
if (!existsSync(pidPath)) return false;
|
|
80
|
-
const pid = Number(readFileSync(pidPath, 'utf8').trim());
|
|
81
|
-
if (pid <= 0) return false;
|
|
82
|
-
try {
|
|
83
|
-
process.kill(pid, 0);
|
|
84
|
-
return true;
|
|
85
|
-
} catch {
|
|
86
|
-
try { unlinkSync(pidPath); } catch {}
|
|
87
|
-
try { unlinkSync(getStatusPath()); } catch {}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
} catch {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function stopStrategyIfRunning(): void {
|
|
96
|
-
try {
|
|
97
|
-
const pidPath = getPidPath();
|
|
98
|
-
if (existsSync(pidPath)) {
|
|
99
|
-
const pid = Number(readFileSync(pidPath, 'utf8').trim());
|
|
100
|
-
stopPid(pid);
|
|
101
|
-
try { unlinkSync(pidPath); } catch {}
|
|
102
|
-
try { unlinkSync(getStatusPath()); } catch {}
|
|
103
|
-
}
|
|
104
|
-
try { unlinkSync(getStatusPath()); } catch {}
|
|
105
|
-
} catch {}
|
|
106
|
-
stopOrphanProcesses();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function stopPid(pid: number): void {
|
|
110
|
-
if (!Number.isFinite(pid) || pid <= 0 || pid === process.pid) return;
|
|
111
|
-
try { process.kill(pid, 'SIGTERM'); } catch {}
|
|
112
|
-
const waitBuffer = new SharedArrayBuffer(4);
|
|
113
|
-
Atomics.wait(new Int32Array(waitBuffer), 0, 0, 200);
|
|
114
|
-
try {
|
|
115
|
-
process.kill(pid, 0);
|
|
116
|
-
process.kill(pid, 'SIGKILL');
|
|
117
|
-
} catch {}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function stopOrphanProcesses(): void {
|
|
121
|
-
if (process.platform === 'win32') return;
|
|
122
|
-
try {
|
|
123
|
-
const lines = execFileSync('ps', ['-axo', 'pid=,command='], { encoding: 'utf8' }).split('\n');
|
|
124
|
-
for (const line of lines) {
|
|
125
|
-
const match = line.trim().match(/^(\d+)\s+(.+)$/);
|
|
126
|
-
if (!match) continue;
|
|
127
|
-
const pid = Number(match[1]);
|
|
128
|
-
const command = match[2];
|
|
129
|
-
if (pid === process.pid) continue;
|
|
130
|
-
if (!command.includes('clawclaw-cli') || !command.includes(' _strategy ')) continue;
|
|
131
|
-
stopPid(pid);
|
|
132
|
-
}
|
|
133
|
-
} catch {}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface RoomTarget {
|
|
137
|
-
name: string;
|
|
138
|
-
x: number;
|
|
139
|
-
y: number;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function pointFromMapEntry(entry: any): { x: number; y: number } | null {
|
|
143
|
-
const x = Number(entry?.x ?? entry?.[0]);
|
|
144
|
-
const y = Number(entry?.y ?? entry?.[1]);
|
|
145
|
-
return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function roomName(r: any, index = 0): string {
|
|
149
|
-
return String(r?.name ?? r?.id ?? r?.room ?? `room-${index + 1}`);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function taskLocationsByRoom(allTaskLocations: any[] | undefined): Map<string, any[]> {
|
|
153
|
-
const byRoom = new Map<string, any[]>();
|
|
154
|
-
if (!Array.isArray(allTaskLocations)) return byRoom;
|
|
155
|
-
for (const task of allTaskLocations) {
|
|
156
|
-
const room = typeof task?.room === 'string' ? task.room : '';
|
|
157
|
-
const point = pointFromMapEntry(task);
|
|
158
|
-
if (!room || !point) continue;
|
|
159
|
-
const list = byRoom.get(room) ?? [];
|
|
160
|
-
list.push(task);
|
|
161
|
-
byRoom.set(room, list);
|
|
162
|
-
}
|
|
163
|
-
return byRoom;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function roomAnchor(r: any, index = 0, allTaskLocationsByRoom = new Map<string, any[]>()): RoomTarget {
|
|
167
|
-
const taskLocations = Array.isArray(r?.task_locations) ? r.task_locations : [];
|
|
168
|
-
const name = roomName(r, index);
|
|
169
|
-
const candidates = [
|
|
170
|
-
...taskLocations,
|
|
171
|
-
...(allTaskLocationsByRoom.get(name) ?? []),
|
|
172
|
-
]
|
|
173
|
-
.map(pointFromMapEntry)
|
|
174
|
-
.filter((p): p is { x: number; y: number } => p != null);
|
|
175
|
-
if (candidates.length > 0) {
|
|
176
|
-
return { name, ...candidates[Math.floor(Math.random() * candidates.length)] };
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const poly: number[][] = Array.isArray(r?.polygon) ? r.polygon : [];
|
|
180
|
-
if (poly.length === 0) return { name, x: 0, y: 0 };
|
|
181
|
-
|
|
182
|
-
let area = 0;
|
|
183
|
-
let cx = 0;
|
|
184
|
-
let cy = 0;
|
|
185
|
-
for (let i = 0; i < poly.length; i += 1) {
|
|
186
|
-
const [x1, y1] = poly[i];
|
|
187
|
-
const [x2, y2] = poly[(i + 1) % poly.length];
|
|
188
|
-
const cross = x1 * y2 - x2 * y1;
|
|
189
|
-
area += cross;
|
|
190
|
-
cx += (x1 + x2) * cross;
|
|
191
|
-
cy += (y1 + y2) * cross;
|
|
192
|
-
}
|
|
193
|
-
area *= 0.5;
|
|
194
|
-
if (Math.abs(area) < 1e-6) {
|
|
195
|
-
const ax = poly.reduce((s, p) => s + p[0], 0) / poly.length;
|
|
196
|
-
const ay = poly.reduce((s, p) => s + p[1], 0) / poly.length;
|
|
197
|
-
return { name, x: ax, y: ay };
|
|
198
|
-
}
|
|
199
|
-
return { name, x: cx / (6 * area), y: cy / (6 * area) };
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function learnTeammatesFromEvents(events: any[] | undefined, teammates: Set<string>): void {
|
|
203
|
-
if (!Array.isArray(events)) return;
|
|
204
|
-
for (const evt of events) {
|
|
205
|
-
if (evt?.type !== 'crab_teammates') continue;
|
|
206
|
-
const list = Array.isArray(evt.teammates) ? evt.teammates : [];
|
|
207
|
-
for (const name of list) {
|
|
208
|
-
if (typeof name === 'string' && name.length > 0) teammates.add(name);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const MOVEMENT_TERMINAL_EVENT_TYPES = new Set(['move_end', 'move_interrupted']);
|
|
214
|
-
|
|
215
|
-
function ownMovementTerminalEvent(events: any[] | undefined, playerName: string): any | null {
|
|
216
|
-
if (!Array.isArray(events)) return null;
|
|
217
|
-
return events.find(evt => {
|
|
218
|
-
if (!MOVEMENT_TERMINAL_EVENT_TYPES.has(evt?.type)) return false;
|
|
219
|
-
if (evt.actor_name && evt.actor_name !== playerName) return false;
|
|
220
|
-
return true;
|
|
221
|
-
}) ?? null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function ownKillEvent(events: any[] | undefined, playerName: string): boolean {
|
|
225
|
-
if (!Array.isArray(events) || !playerName) return false;
|
|
226
|
-
return events.some(evt => evt?.type === 'kill' && evt.actor_name === playerName);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function learnSeatNames(players: any[] | undefined, target: Record<string, string>): void {
|
|
230
|
-
if (!Array.isArray(players)) return;
|
|
231
|
-
for (const player of players) {
|
|
232
|
-
const seat = player?.seat;
|
|
233
|
-
const name = player?.name;
|
|
234
|
-
if (seat == null || typeof name !== 'string' || name.length === 0) continue;
|
|
235
|
-
target[String(seat)] = name;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function eventsSinceCurrentSession(events: any[] | undefined): any[] {
|
|
240
|
-
if (!Array.isArray(events)) return [];
|
|
241
|
-
let idx = -1;
|
|
242
|
-
for (let i = events.length - 1; i >= 0; i--) {
|
|
243
|
-
if (events[i]?.type === 'session_started') { idx = i; break; }
|
|
244
|
-
}
|
|
245
|
-
return idx >= 0 ? events.slice(idx + 1) : events;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
interface MoveTarget {
|
|
249
|
-
kind: 'point' | 'room';
|
|
250
|
-
x?: number;
|
|
251
|
-
y?: number;
|
|
252
|
-
room?: string;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
interface ActiveMoveTarget extends MoveTarget {
|
|
256
|
-
until: number;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const SAME_MOVE_TARGET_DISTANCE = 10;
|
|
260
|
-
|
|
261
|
-
function moveTargetFromPayload(payload: Record<string, any>): MoveTarget | null {
|
|
262
|
-
if (typeof payload.target === 'string' && payload.target.trim()) {
|
|
263
|
-
return { kind: 'room', room: payload.target.trim().toLowerCase() };
|
|
264
|
-
}
|
|
265
|
-
const x = Number(payload.target_x);
|
|
266
|
-
const y = Number(payload.target_y);
|
|
267
|
-
if (Number.isFinite(x) && Number.isFinite(y)) return { kind: 'point', x, y };
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function sameMoveTarget(a: MoveTarget, b: MoveTarget): boolean {
|
|
272
|
-
if (a.kind !== b.kind) return false;
|
|
273
|
-
if (a.kind === 'room') return a.room === b.room;
|
|
274
|
-
const dx = (a.x ?? 0) - (b.x ?? 0);
|
|
275
|
-
const dy = (a.y ?? 0) - (b.y ?? 0);
|
|
276
|
-
return Math.sqrt(dx ** 2 + dy ** 2) <= SAME_MOVE_TARGET_DISTANCE;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function activeMoveTargetFromPayload(payload: Record<string, any>, until: number): ActiveMoveTarget | null {
|
|
280
|
-
const target = moveTargetFromPayload(payload);
|
|
281
|
-
return target ? { ...target, until } : null;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function repeatsActiveMoveTarget(decision: BehaviorDecision, activeMoveTarget: ActiveMoveTarget | null): boolean {
|
|
285
|
-
if (!activeMoveTarget || Date.now() >= activeMoveTarget.until) return false;
|
|
286
|
-
const payload = decision.action.toJSON();
|
|
287
|
-
if (payload.action !== 'move') return false;
|
|
288
|
-
const target = moveTargetFromPayload(payload);
|
|
289
|
-
return !!target && sameMoveTarget(target, activeMoveTarget);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function pickDecision(
|
|
293
|
-
decisions: BehaviorDecision[],
|
|
294
|
-
blockedMoveTarget: ({ x: number; y: number; until: number }) | null,
|
|
295
|
-
activeMoveTarget: ActiveMoveTarget | null,
|
|
296
|
-
): BehaviorDecision | null {
|
|
297
|
-
return decisions.find(d => {
|
|
298
|
-
if (repeatsActiveMoveTarget(d, activeMoveTarget)) return false;
|
|
299
|
-
const a = d.action.toJSON();
|
|
300
|
-
if (a.action !== 'move') return true;
|
|
301
|
-
if (!blockedMoveTarget || Date.now() >= blockedMoveTarget.until) return true;
|
|
302
|
-
const x = Number(a.target_x);
|
|
303
|
-
const y = Number(a.target_y);
|
|
304
|
-
if (!Number.isFinite(x) || !Number.isFinite(y)) return true;
|
|
305
|
-
const dx = x - blockedMoveTarget.x;
|
|
306
|
-
const dy = y - blockedMoveTarget.y;
|
|
307
|
-
return Math.sqrt(dx ** 2 + dy ** 2) > 10;
|
|
308
|
-
}) ?? null;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function isSpeechDecision(decision: BehaviorDecision): boolean {
|
|
312
|
-
return decision.action.toJSON().action === 'speech';
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function supportsSidecarSpeech(strategyId: string): boolean {
|
|
316
|
-
return strategyId === 'task-report'
|
|
317
|
-
|| strategyId === 'corpse-patrol'
|
|
318
|
-
|| strategyId === 'shrimp-memory'
|
|
319
|
-
|| strategyId === 'paradise-fish';
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export async function runStrategyLoop(strategyId: string, args?: string[]): Promise<void> {
|
|
323
|
-
const strategy = await resolveStrategy(strategyId, args);
|
|
324
|
-
const store = EventStore.forActiveAccount();
|
|
325
|
-
const pidPath = getPidPath();
|
|
326
|
-
|
|
327
|
-
if (shouldWriteStrategyRuntimeFiles()) writeFileSync(pidPath, String(process.pid));
|
|
328
|
-
store.append({ type: 'auto', message: 'strategy started', strategy: strategyId, pid: process.pid });
|
|
329
|
-
|
|
330
|
-
const client = GameClient.fromAuth();
|
|
331
|
-
await client.discoverGameServer();
|
|
332
|
-
|
|
333
|
-
const teammates = new Set<string>();
|
|
334
|
-
const playerNamesBySeat: Record<string, string> = {};
|
|
335
|
-
let blockedMoveTarget: { x: number; y: number; until: number } | null = null;
|
|
336
|
-
let consecutiveBlocks = 0;
|
|
337
|
-
const BLOCK_SKIP_THRESHOLD = 3;
|
|
338
|
-
let mapDirty = true;
|
|
339
|
-
let lastMapRefreshAt = 0;
|
|
340
|
-
const MAP_REFRESH_INTERVAL_MS = 10_000;
|
|
341
|
-
|
|
342
|
-
const knowledgePath = (() => { try { return knowledgeFilePathForActiveAccount(); } catch { return ''; } })();
|
|
343
|
-
const knowledgeGameId = currentGameId();
|
|
344
|
-
let lastKnowledgeMtimeMs = -1;
|
|
345
|
-
|
|
346
|
-
const ctx: StrategyContext = {
|
|
347
|
-
taskData: [],
|
|
348
|
-
taskLocations: [],
|
|
349
|
-
emergency: null,
|
|
350
|
-
taskLocalBlockedUntil: 0,
|
|
351
|
-
reportCorpseTarget: null,
|
|
352
|
-
reportBlockedUntil: 0,
|
|
353
|
-
octopusTimeActive: false,
|
|
354
|
-
notifications: [],
|
|
355
|
-
lastProgressNotifyAt: 0,
|
|
356
|
-
teammates,
|
|
357
|
-
alarmDone: false,
|
|
358
|
-
alarmOnCooldown: false,
|
|
359
|
-
rooms: [],
|
|
360
|
-
playerNamesBySeat,
|
|
361
|
-
forcePatrolAdvance: false,
|
|
362
|
-
blockedMoveTarget: null,
|
|
363
|
-
mySeat: 0,
|
|
364
|
-
speechNotifications: [],
|
|
365
|
-
agentAlerts: [],
|
|
366
|
-
knownCorpses: [],
|
|
367
|
-
knowledge: emptyKnowledgeView(),
|
|
368
|
-
recentlyKilledTargets: new Map(),
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
// 全局唯一的尸体记忆:每 tick observe 后写入 ctx.knownCorpses,开会清场时 reset。
|
|
372
|
-
const corpseMemory = new CorpseMemory();
|
|
373
|
-
|
|
374
|
-
try { learnTeammatesFromEvents(eventsSinceCurrentSession(store.tail(1000)), teammates); } catch {}
|
|
375
|
-
const newEventsBackfill = createStrategyNewEventsBackfill(store.path);
|
|
376
|
-
try {
|
|
377
|
-
const roleInfo = await client.getRoleInfo();
|
|
378
|
-
learnSeatNames(roleInfo?.data?.all_seats ?? roleInfo?.all_seats, playerNamesBySeat);
|
|
379
|
-
const crabTeammates: any[] = roleInfo?.data?.crab_teammates ?? roleInfo?.crab_teammates ?? [];
|
|
380
|
-
for (const name of crabTeammates) {
|
|
381
|
-
if (typeof name === 'string' && name.length > 0) teammates.add(name);
|
|
382
|
-
}
|
|
383
|
-
const mySeat = Number(roleInfo?.data?.seat ?? roleInfo?.seat ?? 0);
|
|
384
|
-
if (mySeat > 0) ctx.mySeat = mySeat;
|
|
385
|
-
const role: string = roleInfo?.data?.role ?? roleInfo?.role ?? '';
|
|
386
|
-
if (role && strategy.updateRole) strategy.updateRole(role);
|
|
387
|
-
} catch {}
|
|
388
|
-
|
|
389
|
-
// Register custom modules before main loop so tick-1 events are captured
|
|
390
|
-
const customModules = strategy.customModules?.() ?? [];
|
|
391
|
-
if (customModules.length > 0) ctx.customModules = customModules;
|
|
392
|
-
|
|
393
|
-
let running = true;
|
|
394
|
-
let activeMoveTarget: ActiveMoveTarget | null = null;
|
|
395
|
-
let pausedForMeeting = false;
|
|
396
|
-
let releasedMeetingPause = false;
|
|
397
|
-
let currentRole = '';
|
|
398
|
-
let currentPlayerName = '';
|
|
399
|
-
let pistolKillUsed = false;
|
|
400
|
-
let pistolKillInitialized = false;
|
|
401
|
-
const onSignal = () => { running = false; };
|
|
402
|
-
process.on('SIGINT', onSignal);
|
|
403
|
-
process.on('SIGTERM', onSignal);
|
|
404
|
-
|
|
405
|
-
const submitAction = async (action: Action): Promise<{ acted: boolean }> => {
|
|
406
|
-
try {
|
|
407
|
-
const payload = action.toJSON();
|
|
408
|
-
const actionType = payload.action;
|
|
409
|
-
const result = await client.submitAction(payload as any);
|
|
410
|
-
const newEvents = extractNewEvents(result);
|
|
411
|
-
store.appendNewEvents(newEvents);
|
|
412
|
-
// action 结果里回来的 corpse_spotted 也入账尸体记忆——主循环只 observe state.new_events,
|
|
413
|
-
// 那条通道会被 runtime WS listener 抢游标,这里补上避免尸体坐标漏记(ctx.knownCorpses 与 list() 同引用,立即可见)。
|
|
414
|
-
corpseMemory.ingestEvents(newEvents);
|
|
415
|
-
learnTeammatesFromEvents(newEvents, teammates);
|
|
416
|
-
// 章鱼时间可能只从本次动作响应的 new_events 到达(服务端游标一次性增量,下次 GET 不再重复);
|
|
417
|
-
// 立即消费,避免下一 tick 前仍走报尸分支,直到 report 被拒才靠错误文本兜底进入生存模式。
|
|
418
|
-
enterOctopusTimeIfStarted(ctx, newEvents);
|
|
419
|
-
if (currentRole === 'shrimp_pistol' && ownKillEvent(newEvents, currentPlayerName)) {
|
|
420
|
-
pistolKillUsed = true;
|
|
421
|
-
}
|
|
422
|
-
const actionResult = result?.data ?? result;
|
|
423
|
-
store.append({ type: 'auto', action: actionType, result: actionResult ?? result?.error ?? 'ok' });
|
|
424
|
-
|
|
425
|
-
const errorCode = actionResult?.error?.code ?? actionResult?.code ?? result?.error?.code;
|
|
426
|
-
const errorMessage = String(
|
|
427
|
-
actionResult?.error?.message ?? actionResult?.message ?? result?.error?.message ?? actionResult?.reason ?? '',
|
|
428
|
-
);
|
|
429
|
-
const failed = errorCode === 'ACTION_FAILED' || actionResult?.success === false || result?.success === false;
|
|
430
|
-
const queued = actionResult?.status === 'queued';
|
|
431
|
-
|
|
432
|
-
if (failed) {
|
|
433
|
-
ctx.reportCorpseTarget = null;
|
|
434
|
-
const failureText = JSON.stringify(actionResult ?? result ?? {});
|
|
435
|
-
if (actionType === 'kill' && currentRole === 'shrimp_pistol' && failureText.includes('role_cannot_kill')) {
|
|
436
|
-
pistolKillUsed = true;
|
|
437
|
-
}
|
|
438
|
-
if (actionType === 'task' || actionType === 'kill' || actionType === 'report' || actionType === 'trigger_alarm') {
|
|
439
|
-
activeMoveTarget = null;
|
|
440
|
-
}
|
|
441
|
-
if (actionType === 'trigger_alarm') {
|
|
442
|
-
// on_cooldown = 撞上 20s 阵营共享 CD,破坏仍装填、CD 好后可补打——透给蟹策略回滚乐观去重、退避重试。
|
|
443
|
-
ctx.alarmOnCooldown = errorMessage.includes('on_cooldown');
|
|
444
|
-
}
|
|
445
|
-
if (actionType === 'kill' && errorMessage.includes('cannot_kill_teammate')) {
|
|
446
|
-
const target = action.toJSON().target;
|
|
447
|
-
if (typeof target === 'string' && target.length > 0) teammates.add(target);
|
|
448
|
-
}
|
|
449
|
-
if (actionType === 'task' && errorMessage.includes('not_at_task_location')) {
|
|
450
|
-
ctx.taskLocalBlockedUntil = Date.now() + 5000;
|
|
451
|
-
activeMoveTarget = null;
|
|
452
|
-
}
|
|
453
|
-
if (actionType === 'report') {
|
|
454
|
-
// 章鱼时间服务端禁用报尸,返回 cannot_report_during_octopus_time;漏掉 octopus_time_start 事件时靠它兜底进入生存模式。
|
|
455
|
-
if (failureText.includes('octopus')) {
|
|
456
|
-
ctx.octopusTimeActive = true;
|
|
457
|
-
}
|
|
458
|
-
// doing_task 型失败不是真报不了:服务端只是因正在做任务而拒绝,下一 tick 任务被 move 打断后即可补报。
|
|
459
|
-
// 这种情况不设 5 秒退避,否则会错过「目击者刚靠近尸体」的报尸自证窗口;其余原因(距离不够等)仍退避避免空报刷屏。
|
|
460
|
-
if (!failureText.includes('doing_task')) {
|
|
461
|
-
ctx.reportBlockedUntil = Date.now() + 5000;
|
|
462
|
-
}
|
|
463
|
-
activeMoveTarget = null;
|
|
464
|
-
}
|
|
465
|
-
if (actionType === 'move') {
|
|
466
|
-
if (errorMessage.includes('invalid_position_blocked')) {
|
|
467
|
-
consecutiveBlocks++;
|
|
468
|
-
const payload = action.toJSON();
|
|
469
|
-
const x = Number(payload.target_x);
|
|
470
|
-
const y = Number(payload.target_y);
|
|
471
|
-
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
472
|
-
if (consecutiveBlocks >= BLOCK_SKIP_THRESHOLD) {
|
|
473
|
-
blockedMoveTarget = null;
|
|
474
|
-
consecutiveBlocks = 0;
|
|
475
|
-
ctx.forcePatrolAdvance = true;
|
|
476
|
-
ctx.notifications.push('移动目标多次不可达,跳过。');
|
|
477
|
-
} else {
|
|
478
|
-
blockedMoveTarget = { x, y, until: Date.now() + 5000 };
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
} else {
|
|
482
|
-
consecutiveBlocks = 0;
|
|
483
|
-
}
|
|
484
|
-
activeMoveTarget = null;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if (!failed && actionType === 'kill') {
|
|
489
|
-
const target = typeof payload.target === 'string' ? payload.target.trim().toLowerCase() : '';
|
|
490
|
-
if (target) ctx.recentlyKilledTargets?.set(target, Date.now() + RECENT_KILL_IGNORE_MS);
|
|
491
|
-
if (currentRole === 'shrimp_pistol') pistolKillUsed = true;
|
|
492
|
-
activeMoveTarget = null;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
if (!failed && actionType === 'trigger_alarm') {
|
|
496
|
-
ctx.alarmOnCooldown = false;
|
|
497
|
-
activeMoveTarget = null;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (queued) {
|
|
501
|
-
if (actionType === 'task') {
|
|
502
|
-
mapDirty = true;
|
|
503
|
-
activeMoveTarget = null;
|
|
504
|
-
}
|
|
505
|
-
} else if (actionType === 'move' && !failed) {
|
|
506
|
-
consecutiveBlocks = 0;
|
|
507
|
-
const durationSecs = actionResult?.duration_secs ?? result?.duration_secs ?? 0;
|
|
508
|
-
const arrivalAt = Date.now() + Math.max(0.5, durationSecs) * 1000;
|
|
509
|
-
activeMoveTarget = activeMoveTargetFromPayload(payload, arrivalAt + 500);
|
|
510
|
-
} else if (!failed && (actionType === 'task' || actionType === 'report')) {
|
|
511
|
-
activeMoveTarget = null;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
return { acted: true };
|
|
515
|
-
} catch (e: any) {
|
|
516
|
-
store.append({ type: 'auto', error: 'submit_action_failed', message: formatErrorMessage(e) });
|
|
517
|
-
ctx.reportCorpseTarget = null;
|
|
518
|
-
if (action.toJSON().action === 'move') {
|
|
519
|
-
activeMoveTarget = null;
|
|
520
|
-
}
|
|
521
|
-
return { acted: true };
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
while (running) {
|
|
526
|
-
let state: GameState | null;
|
|
527
|
-
try {
|
|
528
|
-
state = await client.getGameState();
|
|
529
|
-
} catch {
|
|
530
|
-
await sleep(2000);
|
|
531
|
-
continue;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (!state) {
|
|
535
|
-
store.append({ type: 'auto', message: 'no active game, retrying' });
|
|
536
|
-
await sleep(2000);
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
store.appendNewEvents(eventsForStrategyStateLog(state.new_events));
|
|
541
|
-
state.new_events = newEventsBackfill.correct(state.new_events);
|
|
542
|
-
currentRole = state.you.role ?? currentRole;
|
|
543
|
-
currentPlayerName = state.you.name ?? currentPlayerName;
|
|
544
|
-
if (currentRole === 'shrimp_pistol') {
|
|
545
|
-
if (!pistolKillInitialized) {
|
|
546
|
-
pistolKillUsed = pistolKillUsed || ownKillEvent(eventsSinceCurrentSession(store.tail(1000)), currentPlayerName);
|
|
547
|
-
pistolKillInitialized = true;
|
|
548
|
-
}
|
|
549
|
-
if (state.you.kills_remaining === 0 || ownKillEvent(state.new_events, currentPlayerName)) {
|
|
550
|
-
pistolKillUsed = true;
|
|
551
|
-
}
|
|
552
|
-
state.you.kills_remaining = pistolKillUsed ? 0 : (state.you.kills_remaining ?? 1);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
learnTeammatesFromEvents(state.new_events, teammates);
|
|
556
|
-
enterOctopusTimeIfStarted(ctx, state.new_events);
|
|
557
|
-
learnSeatNames(state.all_players, playerNamesBySeat);
|
|
558
|
-
const terminalMove = ownMovementTerminalEvent(state.new_events, state.you.name);
|
|
559
|
-
if (terminalMove) {
|
|
560
|
-
activeMoveTarget = null;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// Process events through strategy-registered custom modules
|
|
564
|
-
const currentTick = state.tick ?? 0;
|
|
565
|
-
const newEvents = state.new_events ?? [];
|
|
566
|
-
for (const mod of ctx.customModules ?? []) {
|
|
567
|
-
mod.processEvents(newEvents, currentTick, state);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (ctx.mySeat === 0 && state.you.seat != null) {
|
|
571
|
-
ctx.mySeat = state.you.seat;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
const prevEmergency = ctx.emergency;
|
|
575
|
-
ctx.emergency = state.emergency ?? null;
|
|
576
|
-
if (ctx.emergency && !prevEmergency) {
|
|
577
|
-
const room = ctx.emergency.room ?? '未知';
|
|
578
|
-
ctx.notifications.push(`紧急任务出现!「${ctx.emergency.task_name}」在${room},剩余${Math.round(ctx.emergency.remaining_secs)}秒。`);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if (meetingStartedInEvents(state.new_events)) {
|
|
582
|
-
releasedMeetingPause = false;
|
|
583
|
-
}
|
|
584
|
-
if (state.phase !== 'meeting') {
|
|
585
|
-
releasedMeetingPause = false;
|
|
586
|
-
}
|
|
587
|
-
if (meetingEndedInEvents(state.new_events)) {
|
|
588
|
-
releasedMeetingPause = true;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
if (state.phase === 'game_over') {
|
|
592
|
-
store.append({ type: 'auto', message: 'game over' });
|
|
593
|
-
break;
|
|
594
|
-
}
|
|
595
|
-
if (state.you.is_alive === false) {
|
|
596
|
-
store.append({ type: 'auto', message: 'player dead, stopping strategy', strategy: strategyId });
|
|
597
|
-
break;
|
|
598
|
-
}
|
|
599
|
-
if (shouldPauseForMeeting(state, releasedMeetingPause)) {
|
|
600
|
-
if (!pausedForMeeting) {
|
|
601
|
-
store.append({ type: 'auto', message: 'meeting started, pausing strategy', strategy: strategyId });
|
|
602
|
-
pausedForMeeting = true;
|
|
603
|
-
activeMoveTarget = null;
|
|
604
|
-
}
|
|
605
|
-
await sleep(2000);
|
|
606
|
-
continue;
|
|
607
|
-
}
|
|
608
|
-
if (pausedForMeeting) {
|
|
609
|
-
store.append({ type: 'auto', message: 'meeting ended, resuming strategy', strategy: strategyId });
|
|
610
|
-
pausedForMeeting = false;
|
|
611
|
-
releasedMeetingPause = true;
|
|
612
|
-
mapDirty = true;
|
|
613
|
-
activeMoveTarget = null;
|
|
614
|
-
blockedMoveTarget = null;
|
|
615
|
-
consecutiveBlocks = 0;
|
|
616
|
-
ctx.taskLocalBlockedUntil = 0;
|
|
617
|
-
ctx.reportCorpseTarget = null;
|
|
618
|
-
ctx.reportBlockedUntil = 0;
|
|
619
|
-
ctx.octopusTimeActive = false;
|
|
620
|
-
ctx.forcePatrolAdvance = false;
|
|
621
|
-
ctx.blockedMoveTarget = null;
|
|
622
|
-
// 开会后尸体清场:清空尸体记忆,避免回避/报告已不存在的尸体。
|
|
623
|
-
corpseMemory.reset();
|
|
624
|
-
ctx.knownCorpses = [];
|
|
625
|
-
// Notify strategy-registered custom modules (decay instead of full reset)
|
|
626
|
-
for (const mod of ctx.customModules ?? []) {
|
|
627
|
-
mod.onMeetingResume?.();
|
|
628
|
-
}
|
|
629
|
-
strategy.onMeetingResume?.();
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if (mapDirty || Date.now() - lastMapRefreshAt >= MAP_REFRESH_INTERVAL_MS) {
|
|
633
|
-
try {
|
|
634
|
-
const mapData = await client.getMap();
|
|
635
|
-
const taskFactionByName = new Map<string, 'lobster' | 'crab'>(
|
|
636
|
-
(mapData?.all_task_locations ?? [])
|
|
637
|
-
.filter((t: any) => t?.name && (t.faction === 'lobster' || t.faction === 'crab'))
|
|
638
|
-
.map((t: any) => [t.name, t.faction]),
|
|
639
|
-
);
|
|
640
|
-
ctx.taskData = (mapData?.your_tasks ?? []).map((t: any) => ({
|
|
641
|
-
task_id: t.name ?? '',
|
|
642
|
-
task_name: t.name ?? '',
|
|
643
|
-
room: t.room ?? '',
|
|
644
|
-
status: t.status ?? 'normal',
|
|
645
|
-
x: t.x,
|
|
646
|
-
y: t.y,
|
|
647
|
-
is_fake_shrimp: t.is_fake_shrimp ?? false,
|
|
648
|
-
faction: taskFactionByName.get(t.name),
|
|
649
|
-
}));
|
|
650
|
-
ctx.taskLocations = (mapData?.all_task_locations ?? [])
|
|
651
|
-
.filter((t: any) => t && typeof t.name === 'string' && typeof t.x === 'number' && typeof t.y === 'number')
|
|
652
|
-
.map((t: any) => ({ name: t.name, room: t.room, x: t.x, y: t.y, faction: t.faction }));
|
|
653
|
-
if (Array.isArray(mapData?.rooms)) {
|
|
654
|
-
if (ctx.rooms.length === 0) {
|
|
655
|
-
const byRoom = taskLocationsByRoom(mapData?.all_task_locations);
|
|
656
|
-
ctx.rooms = mapData.rooms.map((r: any, index: number) => roomAnchor(r, index, byRoom));
|
|
657
|
-
}
|
|
658
|
-
// Notify custom modules of new map data
|
|
659
|
-
for (const mod of ctx.customModules ?? []) {
|
|
660
|
-
mod.onMapLoaded?.(mapData.rooms);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
mapDirty = false;
|
|
664
|
-
lastMapRefreshAt = Date.now();
|
|
665
|
-
} catch (e: any) {
|
|
666
|
-
store.append({ type: 'auto', error: 'map_load_failed', message: formatErrorMessage(e) });
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const activeBlockedMoveTarget = ((): { x: number; y: number; until: number } | null => blockedMoveTarget)();
|
|
671
|
-
ctx.blockedMoveTarget = activeBlockedMoveTarget && Date.now() < activeBlockedMoveTarget.until
|
|
672
|
-
? { x: activeBlockedMoveTarget.x, y: activeBlockedMoveTarget.y }
|
|
673
|
-
: null;
|
|
674
|
-
|
|
675
|
-
if (knowledgePath) {
|
|
676
|
-
try {
|
|
677
|
-
const mtime = existsSync(knowledgePath) ? statSync(knowledgePath).mtimeMs : 0;
|
|
678
|
-
if (mtime !== lastKnowledgeMtimeMs) {
|
|
679
|
-
lastKnowledgeMtimeMs = mtime;
|
|
680
|
-
const result = readKnowledgeFileResult(knowledgePath);
|
|
681
|
-
if (result.status !== 'invalid') {
|
|
682
|
-
const scoped = result.status === 'ok' && result.file.gameId === knowledgeGameId ? result.file : null;
|
|
683
|
-
ctx.knowledge = buildKnowledgeView(scoped, { playerNamesBySeat });
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
} catch {}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// 更新跨 tick 尸体记忆,暴露给所有策略(检测/接近/任务回避/死亡确认统一读 ctx.knownCorpses)。
|
|
690
|
-
corpseMemory.observe(state, ctx.recentlyKilledTargets);
|
|
691
|
-
ctx.knownCorpses = corpseMemory.list();
|
|
692
|
-
|
|
693
|
-
let decisions = strategy.decide(state, ctx);
|
|
694
|
-
|
|
695
|
-
// Run custom module afterDecide pipeline (chained by registration order)
|
|
696
|
-
for (const mod of ctx.customModules ?? []) {
|
|
697
|
-
if (mod.afterDecide) {
|
|
698
|
-
decisions = mod.afterDecide(decisions, state, ctx);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
const sidecarSpeech = supportsSidecarSpeech(strategyId) ? decisions.filter(isSpeechDecision) : [];
|
|
703
|
-
const mainDecisions = sidecarSpeech.length > 0 ? decisions.filter(d => !isSpeechDecision(d)) : decisions;
|
|
704
|
-
|
|
705
|
-
const decision = pickDecision(
|
|
706
|
-
mainDecisions,
|
|
707
|
-
activeBlockedMoveTarget,
|
|
708
|
-
activeMoveTarget,
|
|
709
|
-
);
|
|
710
|
-
|
|
711
|
-
if (decision) {
|
|
712
|
-
await submitAction(decision.action);
|
|
713
|
-
}
|
|
714
|
-
for (const speech of sidecarSpeech) {
|
|
715
|
-
await submitAction(speech.action);
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
if (ctx.notifications.length > 0) {
|
|
719
|
-
for (const msg of ctx.notifications) {
|
|
720
|
-
store.append({ type: 'auto', message: msg, strategy: strategyId });
|
|
721
|
-
}
|
|
722
|
-
ctx.notifications.length = 0;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
if (ctx.agentAlerts.length > 0) {
|
|
726
|
-
const tick = typeof state.tick === 'number' ? state.tick : undefined;
|
|
727
|
-
for (const msg of ctx.agentAlerts) {
|
|
728
|
-
store.append({ type: 'strategy_alert', message: msg, strategy: strategyId, tick });
|
|
729
|
-
}
|
|
730
|
-
ctx.agentAlerts.length = 0;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
if (ctx.speechNotifications.length > 0) {
|
|
734
|
-
for (const msg of ctx.speechNotifications) {
|
|
735
|
-
store.append({ type: 'robot_speak_rule', message: msg });
|
|
736
|
-
}
|
|
737
|
-
ctx.speechNotifications.length = 0;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
await sleep(500);
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
process.off('SIGINT', onSignal);
|
|
744
|
-
process.off('SIGTERM', onSignal);
|
|
745
|
-
if (shouldWriteStrategyRuntimeFiles()) {
|
|
746
|
-
try { unlinkSync(pidPath); } catch {}
|
|
747
|
-
}
|
|
748
|
-
}
|