@myclaw163/clawclaw-cli 0.6.112 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QUICKSTART.md +46 -0
- package/QUICKSTART_HERMES.md +134 -0
- package/QUICKSTART_OPENCLAW.md +134 -0
- package/QUICKSTART_OTHER.md +134 -0
- package/README.md +23 -398
- package/bin/clawclaw-cli.mjs +9 -1
- package/docs/configuration.md +197 -0
- package/docs/runtime/README.md +52 -0
- package/docs/runtime/agent-notifications.md +55 -0
- package/docs/runtime/components-and-boundaries.md +213 -0
- package/docs/runtime/events-and-state.md +105 -0
- package/docs/runtime/owner-lifecycle-and-observability.md +69 -0
- package/docs/runtime/perception-replay.md +51 -0
- package/docs/runtime/short-commands-and-capabilities.md +55 -0
- package/docs/runtime/strategy-runtime.md +111 -0
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +488 -0
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +395 -0
- package/package.json +26 -8
- package/scripts/check-skill-command-surface.mjs +16 -7
- package/scripts/compare-perception-replays.test.ts +188 -0
- package/scripts/compare-perception-replays.ts +589 -0
- package/scripts/generate-spatial-facts.py +246 -0
- package/scripts/package-readme.mjs +48 -0
- package/scripts/replay-perception.ts +347 -0
- package/scripts/sync-frontend-map.mjs +195 -0
- package/scripts/watch-perception-events.test.ts +43 -0
- package/scripts/watch-perception-events.ts +162 -0
- package/skills/clawclaw/SKILL.md +121 -65
- package/skills/clawclaw/references/CHATTERBOX.md +2 -4
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +95 -61
- package/skills/clawclaw/references/GAME-MECHANICS.md +19 -9
- package/skills/clawclaw/references/HUB.md +5 -5
- package/skills/clawclaw/references/STRATEGIES.md +34 -17
- package/skills/clawclaw/references/STREAM.md +82 -46
- package/src/assets/clawclaw-map.json +1692 -0
- package/src/assets/clawclaw-spatial-facts.json +1291 -0
- package/src/assets/clawclaw-spatial-model.txt +142 -0
- package/src/cli.ts +21 -47
- package/src/commands/account.test.ts +229 -50
- package/src/commands/account.ts +456 -223
- package/src/commands/communication.test.ts +259 -0
- package/src/commands/communication.ts +391 -0
- package/src/commands/competition.test.ts +116 -0
- package/src/commands/competition.ts +50 -28
- package/src/commands/data.test.ts +57 -1
- package/src/commands/data.ts +79 -4
- package/src/commands/events-canonical-state.test.ts +187 -0
- package/src/commands/events.test.ts +50 -136
- package/src/commands/events.ts +175 -241
- package/src/commands/game/index.test.ts +510 -0
- package/src/commands/game/index.ts +556 -0
- package/src/commands/game-map.test.ts +48 -7
- package/src/commands/hub.test.ts +2 -23
- package/src/commands/hub.ts +4 -16
- package/src/commands/load.test.ts +10 -22
- package/src/commands/load.ts +15 -2
- package/src/commands/peek.ts +2 -3
- package/src/commands/perception.test.ts +46 -0
- package/src/commands/perception.ts +92 -0
- package/src/commands/setup/codex.ts +0 -1
- package/src/commands/strategy.test.ts +139 -102
- package/src/commands/strategy.ts +175 -103
- package/src/commands/upgrade.ts +0 -21
- package/src/lib/auth.test.ts +35 -0
- package/src/lib/auth.ts +45 -6
- package/src/lib/diagnostics-config.test.ts +59 -0
- package/src/lib/diagnostics-config.ts +76 -0
- package/src/lib/game-client.test.ts +166 -0
- package/src/lib/game-client.ts +316 -87
- package/src/lib/game-context.ts +33 -4
- package/src/lib/gameplay-config.test.ts +66 -0
- package/src/lib/gameplay-config.ts +151 -0
- package/src/lib/http-transport.test.ts +63 -0
- package/src/lib/http-transport.ts +76 -10
- package/src/lib/init-command.test.ts +25 -1
- package/src/lib/init-command.ts +66 -1
- package/src/lib/participation-leave.ts +78 -0
- package/src/lib/perception-config.test.ts +138 -0
- package/src/lib/perception-config.ts +101 -0
- package/src/lib/room.test.ts +14 -0
- package/src/lib/room.ts +28 -2
- package/src/lib/server-registry.test.ts +15 -5
- package/src/lib/server-registry.ts +9 -10
- package/src/lib/strategy-export.test.ts +123 -44
- package/src/lib/strategy-export.ts +110 -81
- package/src/lib/user-data.test.ts +2 -0
- package/src/lib/user-data.ts +17 -16
- package/src/pipeline/canonical-event-presentation.test.ts +196 -0
- package/src/pipeline/canonical-event-presentation.ts +71 -0
- package/src/pipeline/event-format.test.ts +357 -59
- package/src/pipeline/event-format.ts +365 -80
- package/src/pipeline/event-hints.test.ts +241 -0
- package/src/pipeline/event-hints.ts +202 -51
- package/src/pipeline/game-sync-event-normalization.test.ts +239 -0
- package/src/pipeline/game-sync-event-normalization.ts +215 -0
- package/src/pipeline/player-projection.test.ts +164 -102
- package/src/pipeline/player-projection.ts +194 -235
- package/src/runtime/canonical-event-emitter.test.ts +70 -0
- package/src/runtime/canonical-event-emitter.ts +78 -0
- package/src/runtime/canonical-monitor.test.ts +575 -0
- package/src/runtime/canonical-monitor.ts +388 -0
- package/src/runtime/clawclaw/agent-event-policy.test.ts +27 -0
- package/src/runtime/clawclaw/agent-event-policy.ts +35 -0
- package/src/runtime/clawclaw/index.ts +4 -0
- package/src/runtime/clawclaw/notifications.test.ts +47 -0
- package/src/runtime/clawclaw/notifications.ts +65 -0
- package/src/runtime/clawclaw/owner-lock.test.ts +221 -0
- package/src/runtime/clawclaw/owner.ts +945 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +299 -0
- package/src/runtime/clawclaw/plugins/action/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +81 -0
- package/src/runtime/clawclaw/plugins/assembly.ts +116 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +150 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +100 -0
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +162 -0
- package/src/runtime/clawclaw/plugins/derived-event/index.ts +2 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +223 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +236 -0
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +7 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +77 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +91 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1008 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +475 -0
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +32 -0
- package/src/runtime/clawclaw/plugins/perception/index.ts +8 -0
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +204 -0
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +290 -0
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +324 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +365 -0
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +7 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +341 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +447 -0
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +30 -0
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +289 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +329 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +82 -0
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +172 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +256 -0
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +121 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +106 -0
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +225 -0
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +11 -0
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +31 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +759 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +707 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +215 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +61 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +1516 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +1529 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +119 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +244 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +65 -0
- package/src/runtime/clawclaw/plugins/perception/replay.ts +86 -0
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +107 -0
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +114 -0
- package/src/runtime/clawclaw/plugins/perception/visual-state-projector.ts +98 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +1019 -0
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +287 -0
- package/src/runtime/clawclaw/plugins/source/game-transport.ts +281 -0
- package/src/runtime/clawclaw/plugins/source/index.ts +5 -0
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +270 -0
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +151 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +307 -0
- package/src/runtime/clawclaw/plugins/source/room-transport.ts +480 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +1909 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +2055 -0
- package/src/runtime/clawclaw/plugins/source/source-transports.ts +30 -0
- package/src/runtime/clawclaw/plugins/source/types.ts +79 -0
- package/src/runtime/clawclaw/plugins/strategy/context-capabilities.ts +5 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +177 -0
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +185 -0
- package/src/runtime/clawclaw/plugins/strategy/index.ts +8 -0
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +412 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +73 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +183 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +25 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +693 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +57 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +164 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +1936 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +1557 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +131 -0
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +413 -0
- package/src/runtime/clawclaw/plugins/strategy/thread-strategy-executor.ts +792 -0
- package/src/runtime/clawclaw/runtime-data-export.test.ts +249 -0
- package/src/runtime/clawclaw/runtime-data-export.ts +402 -0
- package/src/runtime/clawclaw/runtime-state.ts +98 -0
- package/src/runtime/clawclaw/runtime.ts +133 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +74 -0
- package/src/runtime/clawclaw-event-catalog.ts +266 -0
- package/src/runtime/clawclaw-position.ts +4 -0
- package/src/runtime/clawclaw-room-state.ts +51 -0
- package/src/runtime/framework/action-diagnostics.test.ts +81 -0
- package/src/runtime/framework/action-diagnostics.ts +146 -0
- package/src/runtime/framework/capability-registry.test.ts +282 -0
- package/src/runtime/framework/capability-registry.ts +283 -0
- package/src/runtime/framework/contracts.ts +118 -0
- package/src/runtime/framework/control/control-scheduler.ts +1260 -0
- package/src/runtime/framework/control/domain-set.ts +81 -0
- package/src/runtime/framework/control/index.ts +3 -0
- package/src/runtime/framework/control/types.ts +184 -0
- package/src/runtime/framework/control-coordinator.test.ts +660 -0
- package/src/runtime/framework/control-coordinator.ts +11 -0
- package/src/runtime/framework/events/event-catalog.ts +74 -0
- package/src/runtime/framework/events/event-delivery-service.test.ts +84 -0
- package/src/runtime/framework/events/event-delivery-service.ts +198 -0
- package/src/runtime/framework/events/event-ingress.test.ts +178 -0
- package/src/runtime/framework/events/event-ingress.ts +97 -0
- package/src/runtime/framework/events/event-repository.ts +59 -0
- package/src/runtime/framework/events/index.ts +7 -0
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +594 -0
- package/src/runtime/framework/events/memory-event-repository.ts +928 -0
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +200 -0
- package/src/runtime/framework/events/sqlite-event-repository.ts +1681 -0
- package/src/runtime/framework/events/test-helpers.ts +78 -0
- package/src/runtime/framework/events/types.ts +286 -0
- package/src/runtime/framework/index.ts +7 -0
- package/src/runtime/framework/load-node-sqlite.ts +17 -0
- package/src/runtime/framework/mailbox/coalescer.test.ts +55 -0
- package/src/runtime/framework/mailbox/coalescer.ts +83 -0
- package/src/runtime/framework/mailbox/host-notification-sink.ts +44 -0
- package/src/runtime/framework/mailbox/identity.test.ts +38 -0
- package/src/runtime/framework/mailbox/identity.ts +38 -0
- package/src/runtime/framework/mailbox/index.ts +7 -0
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +513 -0
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +282 -0
- package/src/runtime/framework/mailbox/mailbox-repository.ts +44 -0
- package/src/runtime/framework/mailbox/notification-projector.test.ts +77 -0
- package/src/runtime/framework/mailbox/notification-projector.ts +65 -0
- package/src/runtime/framework/mailbox/types.ts +139 -0
- package/src/runtime/framework/modules/runtime-module-loader-hooks.d.mts +19 -0
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +117 -0
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +209 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +71 -0
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +23 -0
- package/src/runtime/framework/participation-manager.test.ts +108 -0
- package/src/runtime/framework/participation-manager.ts +244 -0
- package/src/runtime/framework/plugins/contracts.ts +382 -0
- package/src/runtime/framework/plugins/index.ts +4 -0
- package/src/runtime/framework/plugins/runtime-event-identity.ts +17 -0
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +179 -0
- package/src/runtime/framework/plugins/runtime-input-journal.ts +693 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +1994 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +1860 -0
- package/src/runtime/framework/runtime.ts +1756 -0
- package/src/runtime/framework/serial-task-queue.ts +14 -0
- package/src/runtime/framework/state/contracts.ts +49 -0
- package/src/runtime/framework/state/current-state-store.ts +184 -0
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +144 -0
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +209 -0
- package/src/runtime/framework/state/freshness.ts +72 -0
- package/src/runtime/framework/state/history/contracts.ts +150 -0
- package/src/runtime/framework/state/history/history-writer.ts +194 -0
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +178 -0
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +157 -0
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +629 -0
- package/src/runtime/framework/state/history/state-history.test.ts +251 -0
- package/src/runtime/framework/state/history/trajectory-projector.ts +209 -0
- package/src/runtime/framework/state/index.ts +13 -0
- package/src/runtime/framework/state/state-core.test.ts +197 -0
- package/src/runtime/framework/state/state-ingress.ts +95 -0
- package/src/runtime/framework/state/state-provider.ts +62 -0
- package/src/runtime/framework/state/types.ts +155 -0
- package/src/runtime/game-sync-protocol.test.ts +123 -0
- package/src/runtime/game-sync-protocol.ts +261 -0
- package/src/runtime/mailbox-host-relay.test.ts +248 -0
- package/src/runtime/mailbox-host-relay.ts +300 -0
- package/src/runtime/observability/factory.ts +188 -0
- package/src/runtime/observability/index.ts +6 -0
- package/src/runtime/observability/observability.test.ts +561 -0
- package/src/runtime/observability/recorder.ts +209 -0
- package/src/runtime/observability/redaction.ts +154 -0
- package/src/runtime/observability/reporter.ts +154 -0
- package/src/runtime/observability/sinks.ts +135 -0
- package/src/runtime/observability/types.ts +92 -0
- package/src/runtime/owner-control.test.ts +153 -0
- package/src/runtime/owner-control.ts +206 -42
- package/src/runtime/parent-process-watch.test.ts +27 -0
- package/src/runtime/parent-process-watch.ts +51 -0
- package/src/runtime/pending-event-handoff.test.ts +29 -0
- package/src/runtime/pending-event-handoff.ts +61 -0
- package/src/runtime/raw-ws-log.test.ts +86 -17
- package/src/runtime/raw-ws-log.ts +230 -21
- package/src/runtime/runtime-logger.test.ts +58 -0
- package/src/runtime/runtime-logger.ts +10 -13
- package/src/runtime/runtime-persistence.test.ts +26 -0
- package/src/runtime/runtime.test.ts +1704 -0
- package/src/runtime/ws-client.test.ts +496 -103
- package/src/runtime/ws-client.ts +546 -166
- package/src/sdk/action.ts +3 -1
- package/src/sdk/index.ts +4 -19
- package/src/sdk/perception-plugin/index.test.ts +22 -0
- package/src/sdk/perception-plugin/index.ts +285 -0
- package/src/sdk/strategy-plugin/index.test.ts +952 -0
- package/src/sdk/strategy-plugin/index.ts +1324 -0
- package/src/sdk/types.ts +3 -1
- package/src/short-command/classifier.test.ts +107 -0
- package/src/short-command/classifier.ts +169 -0
- package/src/short-command/index.ts +7 -0
- package/src/short-command/presenter.test.ts +119 -0
- package/src/short-command/presenter.ts +308 -0
- package/src/short-command/process-io.ts +13 -0
- package/src/short-command/response-contract.ts +58 -0
- package/src/short-command/runner.test.ts +78 -0
- package/src/short-command/runner.ts +164 -0
- package/src/short-command/sensitive-data-filter.test.ts +56 -0
- package/src/short-command/sensitive-data-filter.ts +123 -0
- package/src/short-command/transport-response.test.ts +39 -0
- package/src/short-command/transport-response.ts +89 -0
- package/src/short-command/types.ts +92 -0
- package/src/strategies/avoid-lone.ts +18 -11
- package/src/strategies/avoid-players.ts +29 -13
- package/src/strategies/corpse-patrol.ts +29 -11
- package/src/strategies/crab-sabotage.ts +31 -18
- package/src/strategies/custom-module.test.ts +3 -5
- package/src/strategies/find-player.ts +34 -15
- package/src/strategies/game-utils.test.ts +42 -0
- package/src/strategies/game-utils.ts +143 -53
- package/src/strategies/goals/avoid-lone-top.ts +22 -1
- package/src/strategies/goals/avoid-players-top.test.ts +13 -0
- package/src/strategies/goals/avoid-players-top.ts +6 -5
- package/src/strategies/goals/corpse-patrol-top.ts +9 -2
- package/src/strategies/goals/crab-octopus-reflexes.ts +6 -2
- package/src/strategies/goals/crab-sabotage-top.ts +7 -1
- package/src/strategies/goals/emergency-hunt-goal.ts +15 -3
- package/src/strategies/goals/find-player-top.ts +47 -3
- package/src/strategies/goals/flee-players-goal.ts +2 -0
- package/src/strategies/goals/follow-companion-goal.ts +27 -3
- package/src/strategies/goals/hide-top.ts +47 -5
- package/src/strategies/goals/keep-away-goal.ts +24 -2
- package/src/strategies/goals/kill-frenzy-top.ts +12 -2
- package/src/strategies/goals/kill-lone-top.test.ts +72 -0
- package/src/strategies/goals/kill-lone-top.ts +8 -6
- package/src/strategies/goals/kill-target-goal.ts +16 -7
- package/src/strategies/goals/kill-target-top.ts +16 -2
- package/src/strategies/goals/linger-corpse-goal.ts +11 -3
- package/src/strategies/goals/lone-kill-core.ts +4 -2
- package/src/strategies/goals/move-room-goal.ts +46 -4
- package/src/strategies/goals/normal-shrimp-top.test.ts +16 -0
- package/src/strategies/goals/normal-shrimp-top.ts +18 -18
- package/src/strategies/goals/paradise-fish-top.test.ts +78 -0
- package/src/strategies/goals/paradise-fish-top.ts +16 -6
- package/src/strategies/goals/patrol-top.ts +14 -3
- package/src/strategies/goals/report-patrol-top.ts +14 -3
- package/src/strategies/goals/safe-task-goal.ts +32 -4
- package/src/strategies/goals/social-task-top.ts +39 -8
- package/src/strategies/goals/task-kill-report-top.ts +33 -10
- package/src/strategies/goals/task-only-top.test.ts +89 -0
- package/src/strategies/goals/task-only-top.ts +9 -2
- package/src/strategies/goals/task-or-patrol-goal.ts +21 -3
- package/src/strategies/goals/warrior-shrimp-top.test.ts +75 -23
- package/src/strategies/goals/warrior-shrimp-top.ts +34 -13
- package/src/strategies/greeting.ts +10 -3
- package/src/strategies/hide-spots.ts +4 -0
- package/src/strategies/hide.ts +35 -20
- package/src/strategies/kill-frenzy.ts +18 -12
- package/src/strategies/kill-lone.ts +43 -12
- package/src/strategies/kill-target.ts +34 -17
- package/src/strategies/lone-kill-task.ts +31 -18
- package/src/strategies/move-room.ts +32 -15
- package/src/strategies/off-route-points.ts +12 -4
- package/src/strategies/paradise-fish.ts +49 -14
- package/src/strategies/pathfind/astar-path.test.ts +73 -0
- package/src/strategies/pathfind/astar-path.ts +196 -0
- package/src/strategies/pathfind/escape-planner.test.ts +27 -1
- package/src/strategies/pathfind/escape-planner.ts +108 -0
- package/src/strategies/patrol.ts +18 -11
- package/src/strategies/report-patrol.ts +18 -11
- package/src/strategies/shrimp-memory.ts +66 -14
- package/src/strategies/social-task.ts +49 -45
- package/src/strategies/task-kill-report.ts +34 -16
- package/src/strategies/task-only.test.ts +124 -0
- package/src/strategies/task-only.ts +20 -11
- package/src/strategies/task-report.ts +29 -11
- package/src/strategies/types.ts +29 -62
- package/src/strategies/warrior-memory.ts +44 -14
- package/scripts/check_monitor.test.mjs +0 -212
- package/skills/clawclaw/references/KNOWLEDGE.md +0 -42
- package/src/assets/clawclaw-ascii-map.txt +0 -40
- package/src/commands/do.test.ts +0 -117
- package/src/commands/do.ts +0 -195
- package/src/commands/game-monitor-status.test.ts +0 -58
- package/src/commands/game-start-plan.test.ts +0 -356
- package/src/commands/game.ts +0 -2046
- package/src/commands/history-player.test.ts +0 -105
- package/src/commands/history.ts +0 -573
- package/src/commands/knowledge.test.ts +0 -13
- package/src/commands/knowledge.ts +0 -176
- package/src/commands/meeting-history.test.ts +0 -106
- package/src/commands/state.ts +0 -46
- package/src/commands/watch.test.ts +0 -1313
- package/src/commands/watch.ts +0 -824
- package/src/lib/knowledge-store.test.ts +0 -170
- package/src/lib/knowledge-store.ts +0 -369
- package/src/perception/player-history-store.test.ts +0 -177
- package/src/perception/player-history-store.ts +0 -262
- package/src/pipeline/event-store.test.ts +0 -28
- package/src/pipeline/event-store.ts +0 -193
- package/src/pipeline/pipeline.ts +0 -35
- package/src/runtime/event-daemon.test.ts +0 -268
- package/src/runtime/event-daemon.ts +0 -531
- package/src/runtime/room-lobby-runtime.test.ts +0 -95
- package/src/runtime/room-lobby-runtime.ts +0 -367
- package/src/strategies/avoid-players.knowledge.md +0 -19
- package/src/strategies/kill-lone.knowledge.md +0 -17
- package/src/strategies/knowledge-contract.ts +0 -85
- package/src/strategies/loader.test.ts +0 -710
- package/src/strategies/loader.ts +0 -183
- package/src/strategies/new-events-backfill.ts +0 -98
- package/src/strategies/paradise-fish.knowledge.md +0 -19
- package/src/strategies/scanner.ts +0 -238
- package/src/strategies/shrimp-memory.knowledge.md +0 -19
- package/src/strategies/social-task.test.ts +0 -28
- package/src/strategies/spawn.ts +0 -82
- package/src/strategies/strategy-loop.test.ts +0 -15
- package/src/strategies/strategy-loop.ts +0 -748
- package/src/strategies/warrior-memory.knowledge.md +0 -21
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
nearestSafeTask,
|
|
10
10
|
PatrolState,
|
|
11
11
|
safePatrolStep,
|
|
12
|
+
taskMoveDecision,
|
|
12
13
|
} from './game-utils.js';
|
|
13
14
|
|
|
14
15
|
function state(overrides: Partial<GameState> = {}): GameState {
|
|
@@ -156,6 +157,11 @@ describe('safePatrolStep', () => {
|
|
|
156
157
|
expect(first).toHaveLength(1);
|
|
157
158
|
expect(first[0].action.type).toBe('move');
|
|
158
159
|
expect(first[0].action.payload).toMatchObject({ target_x: 2602, target_y: 586 });
|
|
160
|
+
expect(first[0].intent).toEqual({
|
|
161
|
+
activity: 'moving',
|
|
162
|
+
summary: '正在巡逻,前往safe-route。',
|
|
163
|
+
room: 'safe-route',
|
|
164
|
+
});
|
|
159
165
|
|
|
160
166
|
const second = safePatrolStep(
|
|
161
167
|
routeState,
|
|
@@ -212,6 +218,42 @@ describe('emergency repair kill yielding', () => {
|
|
|
212
218
|
|
|
213
219
|
expect(decision?.action.type).toBe('move');
|
|
214
220
|
expect(decision?.action.payload).toMatchObject({ target_x: 100, target_y: 0 });
|
|
221
|
+
expect(decision?.intent).toEqual({
|
|
222
|
+
activity: 'moving',
|
|
223
|
+
summary: '正在前往control执行紧急任务“repair”。',
|
|
224
|
+
room: 'control',
|
|
225
|
+
task: 'repair',
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('semantic strategy intent', () => {
|
|
231
|
+
it('describes task movement and submission without exposing coordinates', () => {
|
|
232
|
+
const task = {
|
|
233
|
+
...taskAt(100, 50),
|
|
234
|
+
room: '医务室',
|
|
235
|
+
task_name: '检查医疗报告',
|
|
236
|
+
};
|
|
237
|
+
const moving = taskMoveDecision(state(), context(), task);
|
|
238
|
+
expect(moving.intent).toEqual({
|
|
239
|
+
activity: 'moving',
|
|
240
|
+
summary: '正在前往医务室执行任务“检查医疗报告”。',
|
|
241
|
+
room: '医务室',
|
|
242
|
+
task: '检查医疗报告',
|
|
243
|
+
});
|
|
244
|
+
expect(JSON.stringify(moving.intent)).not.toContain('100');
|
|
245
|
+
expect(JSON.stringify(moving.intent)).not.toContain('50');
|
|
246
|
+
|
|
247
|
+
const doing = taskMoveDecision(state({
|
|
248
|
+
you: { ...state().you, x: 100, y: 50, room: '医务室' },
|
|
249
|
+
}), context(), task);
|
|
250
|
+
expect(doing.action.type).toBe('task');
|
|
251
|
+
expect(doing.intent).toEqual({
|
|
252
|
+
activity: 'doing_task',
|
|
253
|
+
summary: '正在医务室执行任务“检查医疗报告”。',
|
|
254
|
+
room: '医务室',
|
|
255
|
+
task: '检查医疗报告',
|
|
256
|
+
});
|
|
215
257
|
});
|
|
216
258
|
});
|
|
217
259
|
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { GameState, PlayerInfo, Position, TaskInfo, EmergencyInfo, CorpseInfo } from '../sdk/types.js';
|
|
2
2
|
import { Action } from '../sdk/action.js';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
BehaviorDecision,
|
|
5
|
+
CorpseTarget,
|
|
6
|
+
RoomTarget,
|
|
7
|
+
StrategyContext,
|
|
8
|
+
StrategyIntent,
|
|
9
|
+
} from './types.js';
|
|
10
|
+
import {
|
|
11
|
+
assessRoutes,
|
|
12
|
+
assessRoutesFromEvidence,
|
|
13
|
+
type RouteEvidence,
|
|
14
|
+
} from './pathfind/escape-planner.js';
|
|
6
15
|
|
|
7
16
|
export const TASK_SUBMIT_RADIUS = 12;
|
|
8
17
|
/** 蟹/章鱼/兜底角色的服务端击杀距离(= 后端全局 kill_range)。 */
|
|
@@ -29,6 +38,70 @@ export const CORPSE_TASK_AVOID_RANGE = CORPSE_SCENE_RANGE;
|
|
|
29
38
|
/** 判「同一具尸体」的极近半径:尸体不会移动,跨 tick 只有坐标取整抖动,远小于两具不同尸体的间距。 */
|
|
30
39
|
export const CORPSE_SAME_BODY_RADIUS = 20;
|
|
31
40
|
|
|
41
|
+
export function setStrategyIntent(ctx: StrategyContext, intent: StrategyIntent): StrategyIntent {
|
|
42
|
+
ctx.intent = intent;
|
|
43
|
+
return intent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function strategyDecision(action: Action, intent: StrategyIntent): BehaviorDecision {
|
|
47
|
+
return { action, intent };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function patrolStrategyIntent(room: RoomTarget, purpose = '巡逻'): StrategyIntent {
|
|
51
|
+
return {
|
|
52
|
+
activity: 'moving',
|
|
53
|
+
summary: `正在${purpose},前往${room.name}。`,
|
|
54
|
+
room: room.name,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function taskKind(task: TaskInfo, ctx: StrategyContext): string {
|
|
59
|
+
const emergency = ctx.emergency;
|
|
60
|
+
if (emergency && (
|
|
61
|
+
emergency.task_id === task.task_id
|
|
62
|
+
|| (emergency.task_name === task.task_name && emergency.room === task.room)
|
|
63
|
+
)) return '紧急任务';
|
|
64
|
+
if (task.faction === 'crab') return '破坏任务';
|
|
65
|
+
if (task.is_fake_shrimp) return '伪装任务';
|
|
66
|
+
return '任务';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function taskStrategyIntent(
|
|
70
|
+
task: TaskInfo,
|
|
71
|
+
ctx: StrategyContext,
|
|
72
|
+
activity: 'moving' | 'doing_task',
|
|
73
|
+
): StrategyIntent {
|
|
74
|
+
const kind = taskKind(task, ctx);
|
|
75
|
+
return {
|
|
76
|
+
activity,
|
|
77
|
+
summary: activity === 'moving'
|
|
78
|
+
? `正在前往${task.room}执行${kind}“${task.task_name}”。`
|
|
79
|
+
: `正在${task.room}执行${kind}“${task.task_name}”。`,
|
|
80
|
+
room: task.room,
|
|
81
|
+
task: task.task_name,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function strategyPlayerLabel(player: Pick<PlayerInfo, 'name' | 'seat'>): string {
|
|
86
|
+
return player.seat != null ? `${player.seat}号${player.name}` : player.name;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function playerStrategyIntent(
|
|
90
|
+
target: PlayerInfo,
|
|
91
|
+
purpose: '追杀' | '跟随',
|
|
92
|
+
activity: 'moving' | 'acting',
|
|
93
|
+
): StrategyIntent {
|
|
94
|
+
const label = strategyPlayerLabel(target);
|
|
95
|
+
return {
|
|
96
|
+
activity,
|
|
97
|
+
summary: purpose === '追杀'
|
|
98
|
+
? `正在追杀${label}${target.room ? `,前往${target.room}` : ''}。`
|
|
99
|
+
: `正在跟随${label}${target.room ? `,前往${target.room}` : ''}。`,
|
|
100
|
+
...(target.room ? { room: target.room } : {}),
|
|
101
|
+
targetPlayer: target.name,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
32
105
|
export function killCooldownSecs(state: GameState): number {
|
|
33
106
|
return state.you.kill_cooldown_secs ?? 0;
|
|
34
107
|
}
|
|
@@ -134,6 +207,8 @@ export interface SafeTaskOptions {
|
|
|
134
207
|
pathThreatRadius?: number;
|
|
135
208
|
/** 粘性:该任务仍是合法候选就直接返回它,不重新比距离,杜绝等距摇摆。 */
|
|
136
209
|
stickyTaskName?: string | null;
|
|
210
|
+
/** Current-frame parallel A* projection; invalid or incomplete evidence falls back safely. */
|
|
211
|
+
routeEvidence?: Readonly<RouteEvidence> | null;
|
|
137
212
|
}
|
|
138
213
|
|
|
139
214
|
export interface SafePatrolOptions {
|
|
@@ -184,12 +259,16 @@ export function nearestSafeTask(
|
|
|
184
259
|
if (sticky) return sticky;
|
|
185
260
|
}
|
|
186
261
|
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
262
|
+
const from = { x: state.you.x, y: state.you.y };
|
|
263
|
+
const points = candidates.map(t => ({ x: t.x!, y: t.y! }));
|
|
264
|
+
const pathThreatRadius = opts.pathThreatRadius ?? TASK_PATH_THREAT_RADIUS;
|
|
265
|
+
const routes = assessRoutesFromEvidence(
|
|
266
|
+
opts.routeEvidence,
|
|
267
|
+
from,
|
|
268
|
+
points,
|
|
190
269
|
threatPoints,
|
|
191
|
-
|
|
192
|
-
);
|
|
270
|
+
pathThreatRadius,
|
|
271
|
+
) ?? assessRoutes(from, points, threatPoints, pathThreatRadius);
|
|
193
272
|
// routes 为 null(自己不在可走格上,极少见)时退回欧氏排序,无路径排除。
|
|
194
273
|
const viable = routes == null
|
|
195
274
|
? candidates.map((t, i) => ({ t, i }))
|
|
@@ -225,6 +304,7 @@ export function patrolStep(
|
|
|
225
304
|
ctx: StrategyContext,
|
|
226
305
|
patrol: PatrolState,
|
|
227
306
|
stopOnPlayer = true,
|
|
307
|
+
purpose = '巡逻',
|
|
228
308
|
): BehaviorDecision[] {
|
|
229
309
|
let room = patrol.nextRoom(ctx);
|
|
230
310
|
if (!room) return [];
|
|
@@ -233,7 +313,10 @@ export function patrolStep(
|
|
|
233
313
|
const next = patrol.nextRoom(ctx);
|
|
234
314
|
if (next) room = next;
|
|
235
315
|
}
|
|
236
|
-
return [
|
|
316
|
+
return [strategyDecision(
|
|
317
|
+
Action.move({ x: room.x, y: room.y }, stopOnPlayer),
|
|
318
|
+
patrolStrategyIntent(room, purpose),
|
|
319
|
+
)];
|
|
237
320
|
}
|
|
238
321
|
|
|
239
322
|
export function safePatrolStep(
|
|
@@ -242,9 +325,13 @@ export function safePatrolStep(
|
|
|
242
325
|
patrol: PatrolState,
|
|
243
326
|
stopOnPlayer = true,
|
|
244
327
|
opts: SafePatrolOptions = {},
|
|
328
|
+
purpose = '巡逻',
|
|
245
329
|
): BehaviorDecision[] {
|
|
246
330
|
const room = nextSafePatrolRoom(state, ctx, patrol, opts);
|
|
247
|
-
return room ? [
|
|
331
|
+
return room ? [strategyDecision(
|
|
332
|
+
Action.move({ x: room.x, y: room.y }, stopOnPlayer),
|
|
333
|
+
patrolStrategyIntent(room, purpose),
|
|
334
|
+
)] : [];
|
|
248
335
|
}
|
|
249
336
|
|
|
250
337
|
function nextSafePatrolRoom(
|
|
@@ -277,12 +364,16 @@ function nextSafePatrolRoom(
|
|
|
277
364
|
!threatPoints.some(p => dist(room.x, room.y, p.x, p.y) <= threatRadius));
|
|
278
365
|
if (endpointSafe.length === 0) return null;
|
|
279
366
|
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
367
|
+
const from = { x: state.you.x, y: state.you.y };
|
|
368
|
+
const points = endpointSafe.map(room => ({ x: room.x, y: room.y }));
|
|
369
|
+
const pathThreatRadius = opts.pathThreatRadius ?? TASK_PATH_THREAT_RADIUS;
|
|
370
|
+
const routes = assessRoutesFromEvidence(
|
|
371
|
+
ctx.routeEvidence,
|
|
372
|
+
from,
|
|
373
|
+
points,
|
|
283
374
|
threatPoints,
|
|
284
|
-
|
|
285
|
-
);
|
|
375
|
+
pathThreatRadius,
|
|
376
|
+
) ?? assessRoutes(from, points, threatPoints, pathThreatRadius);
|
|
286
377
|
const viable = routes == null
|
|
287
378
|
? endpointSafe
|
|
288
379
|
: endpointSafe.filter((_room, i) => !routes[i].nearThreat);
|
|
@@ -322,19 +413,24 @@ export function approachOrDoTaskStep(
|
|
|
322
413
|
): BehaviorDecision[] | null {
|
|
323
414
|
const d = dist(state.you.x, state.you.y, task.x!, task.y!);
|
|
324
415
|
if (d <= TASK_SUBMIT_RADIUS) {
|
|
325
|
-
if (Date.now() >= ctx.taskLocalBlockedUntil)
|
|
416
|
+
if (Date.now() >= ctx.taskLocalBlockedUntil) {
|
|
417
|
+
return [strategyDecision(Action.doTask(task.task_name), taskStrategyIntent(task, ctx, 'doing_task'))];
|
|
418
|
+
}
|
|
326
419
|
return null;
|
|
327
420
|
}
|
|
328
|
-
return [
|
|
421
|
+
return [strategyDecision(
|
|
422
|
+
Action.move({ x: task.x!, y: task.y! }, stopOnPlayer),
|
|
423
|
+
taskStrategyIntent(task, ctx, 'moving'),
|
|
424
|
+
)];
|
|
329
425
|
}
|
|
330
426
|
|
|
331
427
|
/** 单个任务的「靠近 → 到点提交」决策:在提交半径内且本地未被冷却就 doTask,否则移动过去。 */
|
|
332
428
|
export function taskMoveDecision(state: GameState, ctx: StrategyContext, task: TaskInfo): BehaviorDecision {
|
|
333
429
|
const d = dist(state.you.x, state.you.y, task.x!, task.y!);
|
|
334
430
|
if (d <= TASK_SUBMIT_RADIUS && Date.now() >= ctx.taskLocalBlockedUntil) {
|
|
335
|
-
return
|
|
431
|
+
return strategyDecision(Action.doTask(task.task_name), taskStrategyIntent(task, ctx, 'doing_task'));
|
|
336
432
|
}
|
|
337
|
-
return
|
|
433
|
+
return strategyDecision(Action.move({ x: task.x!, y: task.y! }), taskStrategyIntent(task, ctx, 'moving'));
|
|
338
434
|
}
|
|
339
435
|
|
|
340
436
|
/** 已知存活人数 ≤ 此值才触发「残局抢修紧急任务」。 */
|
|
@@ -441,7 +537,7 @@ export function nearestKnownCorpseNav(state: GameState, ctx: StrategyContext): C
|
|
|
441
537
|
return null;
|
|
442
538
|
}
|
|
443
539
|
|
|
444
|
-
/** 是否已知任何尸体(含看见过、已离开视野的)。开会清场后由
|
|
540
|
+
/** 是否已知任何尸体(含看见过、已离开视野的)。开会清场后由 Goal 策略宿主清空。供「该不该去报尸/回避」类**导航**判断用。 */
|
|
445
541
|
export function hasKnownCorpse(ctx: StrategyContext): boolean {
|
|
446
542
|
return (ctx.knownCorpses?.length ?? 0) > 0;
|
|
447
543
|
}
|
|
@@ -493,11 +589,11 @@ export function spottedCorpsesFromEventList(events: any[] | undefined): CorpseTa
|
|
|
493
589
|
}
|
|
494
590
|
|
|
495
591
|
/**
|
|
496
|
-
* 已知尸体的跨 tick
|
|
592
|
+
* 已知尸体的跨 tick 记忆,每个 ClawclawGoalStrategy 实例持有一份,每次运行 `observe` 后写入 `ctx.knownCorpses`,
|
|
497
593
|
* 供所有策略统一读取(检测 hasKnownCorpse、接近 nearestKnownCorpse、任务回避 firstAvailableTask/nearestSafeTask、
|
|
498
594
|
* 死亡确认按名/座位匹配)。`state.corpses` 只含当前视野(nearby)尸体,`corpse_spotted` 事件又只在尸体出现的
|
|
499
595
|
* 那一 tick 进增量——两者都没有持久性,尸体一离开视野下一 tick 就会丢。CorpseMemory 把见过的尸体按身份累积
|
|
500
|
-
* 去重,使「看见过、已离开视野」的尸体仍持续可见。尸体在游戏里出现后一直存在到开会才被清场,故
|
|
596
|
+
* 去重,使「看见过、已离开视野」的尸体仍持续可见。尸体在游戏里出现后一直存在到开会才被清场,故 Goal 策略宿主
|
|
501
597
|
* 在 `onMeetingResume` 时 `reset` 并清空 `ctx.knownCorpses`。报尸本身仍按近距触发(nearestReportableCorpse
|
|
502
598
|
* 读 state.corpses),记忆负责把 bot 带回尸体旁。
|
|
503
599
|
*/
|
|
@@ -614,12 +710,23 @@ export function reportCorpseDecision(
|
|
|
614
710
|
if (nav) {
|
|
615
711
|
ctx.reportCorpseTarget = null;
|
|
616
712
|
ctx.notifications.push(`正在做任务,先移动打断任务再报尸。`);
|
|
617
|
-
|
|
713
|
+
const label = reportable.name ? `${reportable.name}的尸体` : '尸体';
|
|
714
|
+
const room = reportable.room || state.you.room || '当前位置';
|
|
715
|
+
return strategyDecision(Action.move({ x: nav.x, y: nav.y }), {
|
|
716
|
+
activity: 'moving',
|
|
717
|
+
summary: `正在靠近${room}的${label},准备报告。`,
|
|
718
|
+
...(reportable.room ? { room: reportable.room } : {}),
|
|
719
|
+
});
|
|
618
720
|
}
|
|
619
721
|
}
|
|
620
722
|
ctx.reportCorpseTarget = null;
|
|
621
723
|
ctx.notifications.push(`发现尸体,正在报告!`);
|
|
622
|
-
|
|
724
|
+
const room = reportable.room || state.you.room || '当前位置';
|
|
725
|
+
return strategyDecision(Action.report(reportable.name, reportable.room), {
|
|
726
|
+
activity: 'acting',
|
|
727
|
+
summary: `正在报告${room}的${reportable.name ? `${reportable.name}的尸体` : '尸体'}。`,
|
|
728
|
+
...(reportable.room ? { room: reportable.room } : {}),
|
|
729
|
+
});
|
|
623
730
|
}
|
|
624
731
|
|
|
625
732
|
const corpse = nearestKnownCorpse(state, ctx);
|
|
@@ -628,7 +735,13 @@ export function reportCorpseDecision(
|
|
|
628
735
|
ctx.notifications.push(`发现尸体,正在靠近准备报告。`);
|
|
629
736
|
}
|
|
630
737
|
ctx.reportCorpseTarget = corpse;
|
|
631
|
-
|
|
738
|
+
const label = corpse.name ? `${corpse.name}的尸体` : '尸体';
|
|
739
|
+
const room = corpse.room || state.you.room || '当前位置';
|
|
740
|
+
return strategyDecision(Action.move({ x: corpse.x, y: corpse.y }), {
|
|
741
|
+
activity: 'moving',
|
|
742
|
+
summary: `正在靠近${room}的${label},准备报告。`,
|
|
743
|
+
...(corpse.room ? { room: corpse.room } : {}),
|
|
744
|
+
});
|
|
632
745
|
}
|
|
633
746
|
|
|
634
747
|
ctx.reportCorpseTarget = null;
|
|
@@ -726,40 +839,17 @@ export function pursueVisibleTarget(
|
|
|
726
839
|
const d = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
|
|
727
840
|
if (opts.kill && !hasKillUseRemaining(state)) return null;
|
|
728
841
|
if (opts.kill && d <= killCommitRange(state.you.role) && canUseKill(state)) {
|
|
729
|
-
return
|
|
842
|
+
return strategyDecision(Action.kill(target.name), playerStrategyIntent(target, '追杀', 'acting'));
|
|
730
843
|
}
|
|
731
844
|
if (d > opts.followDistance) {
|
|
732
|
-
return
|
|
845
|
+
return strategyDecision(
|
|
846
|
+
Action.move({ x: target.x, y: target.y }),
|
|
847
|
+
playerStrategyIntent(target, opts.kill ? '追杀' : '跟随', 'moving'),
|
|
848
|
+
);
|
|
733
849
|
}
|
|
734
850
|
return null;
|
|
735
851
|
}
|
|
736
852
|
|
|
737
|
-
// ── 知识系统语义助手 ────────────────────────────────────────────────
|
|
738
|
-
// 把 ctx.knowledge 的查询统一成「躲/杀/护」三种意图,供内置与用户策略复用。
|
|
739
|
-
// 见 docs/策略知识系统-by-claude.md。
|
|
740
|
-
|
|
741
|
-
type PlayerRef = { name?: string; seat?: number };
|
|
742
|
-
const FALLBACK_KNOWLEDGE = emptyKnowledgeView();
|
|
743
|
-
|
|
744
|
-
function knowledgeOf(ctx: StrategyContext) {
|
|
745
|
-
return ctx.knowledge ?? FALLBACK_KNOWLEDGE;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/** hostile(坏人):明确敌对。带刀策略刀好时可主动攻击;无刀策略硬回避。 */
|
|
749
|
-
export function isKnowledgeHostile(p: PlayerRef, ctx: StrategyContext): boolean {
|
|
750
|
-
return knowledgeOf(ctx).isHostile(p);
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
/** 威胁 = 非 trusted(坏人 + 被怀疑)。未标记 trusted 的人一律按需警惕——「除好人外都值得提防」。 */
|
|
754
|
-
export function isKnowledgeThreat(p: PlayerRef, ctx: StrategyContext): boolean {
|
|
755
|
-
return !knowledgeOf(ctx).isTrusted(p);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
/** trusted(好人):可信同伴,永远优先于回避与击杀。 */
|
|
759
|
-
export function isKnowledgeTrusted(p: PlayerRef, ctx: StrategyContext): boolean {
|
|
760
|
-
return knowledgeOf(ctx).isTrusted(p);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
853
|
export function resolveRoom(name: string, ctx: StrategyContext): RoomTarget | null {
|
|
764
854
|
const folded = name.trim().toLowerCase();
|
|
765
855
|
if (!folded) return null;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
dist,
|
|
4
|
+
hasReachedRoomTarget,
|
|
5
|
+
PatrolState,
|
|
6
|
+
PROGRESS_INTERVAL_MS,
|
|
7
|
+
pursueVisibleTarget,
|
|
8
|
+
setStrategyIntent,
|
|
9
|
+
strategyPlayerLabel,
|
|
10
|
+
} from '../game-utils.js';
|
|
3
11
|
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
4
12
|
import { Goal } from './goal.js';
|
|
5
13
|
import { KeepAwayGoal, type ThreatResolver } from './keep-away-goal.js';
|
|
@@ -64,8 +72,20 @@ export class AvoidLoneTop extends Goal {
|
|
|
64
72
|
action: decision.action.withThinking(
|
|
65
73
|
`跟住次近的${anchor.name},维持视野内至少两人,避免落单。`,
|
|
66
74
|
),
|
|
75
|
+
intent: {
|
|
76
|
+
activity: 'moving',
|
|
77
|
+
summary: `正在${anchor.room || state.you.room || '当前位置'}跟随${strategyPlayerLabel(anchor)},保持在人群中。`,
|
|
78
|
+
...(anchor.room ? { room: anchor.room } : {}),
|
|
79
|
+
targetPlayer: anchor.name,
|
|
80
|
+
},
|
|
67
81
|
}];
|
|
68
82
|
}
|
|
83
|
+
setStrategyIntent(ctx, {
|
|
84
|
+
activity: 'waiting',
|
|
85
|
+
summary: `正在${state.you.room || '当前位置'}和${strategyPlayerLabel(anchor)}保持在人群中。`,
|
|
86
|
+
...(state.you.room ? { room: state.you.room } : {}),
|
|
87
|
+
targetPlayer: anchor.name,
|
|
88
|
+
});
|
|
69
89
|
if (!this.emitNotice(ctx, `gather:hold:${visible.length}`,
|
|
70
90
|
`视野内${visible.length}人,已和大家在一起保持安全。`))
|
|
71
91
|
this.emitProgress(state, ctx, 'gather', null, visible);
|
|
@@ -129,6 +149,7 @@ export class AvoidLoneTop extends Goal {
|
|
|
129
149
|
this.setSubGoal(new MoveRoomGoal(room.name, hasArrived, {
|
|
130
150
|
emitProgress: false,
|
|
131
151
|
stopOnPlayer,
|
|
152
|
+
purpose: mode === 'patrol' ? '巡逻寻找人群' : '靠近人群',
|
|
132
153
|
}), priority);
|
|
133
154
|
this.moveMode = mode;
|
|
134
155
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import type { GameState } from '../../sdk/types.js';
|
|
3
3
|
import type { StrategyContext } from '../types.js';
|
|
4
|
+
import { KeepAwayGoal } from './keep-away-goal.js';
|
|
4
5
|
import { AvoidPlayersTop } from './avoid-players-top.js';
|
|
5
6
|
|
|
6
7
|
function state(overrides: Partial<GameState> = {}): GameState {
|
|
@@ -80,4 +81,16 @@ describe('AvoidPlayersTop', () => {
|
|
|
80
81
|
expect(decisions).toHaveLength(1);
|
|
81
82
|
expect(decisions[0].action.payload).not.toHaveProperty('stop_on_player');
|
|
82
83
|
});
|
|
84
|
+
|
|
85
|
+
it('uses targets as the complete active avoid list', () => {
|
|
86
|
+
const top = new AvoidPlayersTop(['danger']);
|
|
87
|
+
const current = state({
|
|
88
|
+
players: [{ name: 'danger', seat: 2, x: 200, y: 0, room: 'start' }],
|
|
89
|
+
all_players: [{ name: 'danger', seat: 2, role: 'unknown', is_alive: true }],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
top.tick(current, context({ playerNamesBySeat: { '2': 'danger' } }));
|
|
93
|
+
|
|
94
|
+
expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
|
|
95
|
+
});
|
|
83
96
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { hasReachedRoomTarget,
|
|
2
|
+
import { hasReachedRoomTarget, isTargetAlive, matchesAnyTarget, PatrolState, PROGRESS_INTERVAL_MS } from '../game-utils.js';
|
|
3
3
|
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
4
4
|
import { Goal } from './goal.js';
|
|
5
5
|
import { KeepAwayGoal, type KeepAwayGoalOptions, type ThreatResolver } from './keep-away-goal.js';
|
|
@@ -49,7 +49,7 @@ export class AvoidPlayersTop extends Goal {
|
|
|
49
49
|
|
|
50
50
|
/** 寻路躲避:用 KeepAwayGoal 推演逃点远离回避目标(不限距离,名单上的人始终要躲)。 */
|
|
51
51
|
private setKeepAway(): void {
|
|
52
|
-
const key = this.targets.
|
|
52
|
+
const key = this.targets.join('|');
|
|
53
53
|
const resolve: ThreatResolver = (state, ctx) => this.threats(state, ctx);
|
|
54
54
|
const options: KeepAwayGoalOptions = { threatRadius: Infinity, noun: '回避目标' };
|
|
55
55
|
const worker = this.subGoal;
|
|
@@ -62,10 +62,10 @@ export class AvoidPlayersTop extends Goal {
|
|
|
62
62
|
this.moveMode = 'flee';
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/**
|
|
65
|
+
/** targets 中仍存活的玩家;空名单表示只巡逻。 */
|
|
66
66
|
private threats(state: GameState, ctx: StrategyContext): PlayerInfo[] {
|
|
67
67
|
const validTargets = this.targets.filter(target => isTargetAlive(state, target, ctx));
|
|
68
|
-
return state.players.filter(p => matchesAnyTarget(p, validTargets, ctx)
|
|
68
|
+
return state.players.filter(p => matchesAnyTarget(p, validTargets, ctx));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
private setMoveGoal(room: RoomTarget, priority: number, mode: 'patrol' | 'flee', stopOnPlayer: boolean): void {
|
|
@@ -75,6 +75,7 @@ export class AvoidPlayersTop extends Goal {
|
|
|
75
75
|
this.setSubGoal(new MoveRoomGoal(room.name, hasReachedRoomTarget, {
|
|
76
76
|
emitProgress: false,
|
|
77
77
|
stopOnPlayer,
|
|
78
|
+
purpose: '巡逻并避开指定玩家',
|
|
78
79
|
}), priority);
|
|
79
80
|
this.moveMode = mode;
|
|
80
81
|
}
|
|
@@ -95,7 +96,7 @@ export class AvoidPlayersTop extends Goal {
|
|
|
95
96
|
ctx.lastProgressNotifyAt = now;
|
|
96
97
|
|
|
97
98
|
const room = state.you.room ?? '未知';
|
|
98
|
-
const targetNames = this.targets.length > 0 ? this.targets.join(', ') : '(
|
|
99
|
+
const targetNames = this.targets.length > 0 ? this.targets.join(', ') : '(未配置)';
|
|
99
100
|
|
|
100
101
|
let msg = `[进度] 当前在${room},巡逻中,回避名单: ${targetNames}`;
|
|
101
102
|
if (target) {
|
|
@@ -53,7 +53,7 @@ export class CorpsePatrolTop extends Goal {
|
|
|
53
53
|
if (canMove) decisions.push(...this.linger.tick(state, ctx));
|
|
54
54
|
} else {
|
|
55
55
|
this.lastCorpseNotified = false;
|
|
56
|
-
if (canMove) decisions.push(...patrolStep(state, ctx, this.patrol, false));
|
|
56
|
+
if (canMove) decisions.push(...patrolStep(state, ctx, this.patrol, false, '巡逻寻找尸体'));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
this.emitProgress(state, ctx, corpse);
|
|
@@ -69,7 +69,14 @@ export class CorpsePatrolTop extends Goal {
|
|
|
69
69
|
|
|
70
70
|
const text = this.greetingPhrases[Math.floor(Math.random() * this.greetingPhrases.length)];
|
|
71
71
|
this.lastGreetingAt = now;
|
|
72
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
action: Action.speech(text),
|
|
74
|
+
intent: {
|
|
75
|
+
activity: 'acting',
|
|
76
|
+
summary: `正在${state.you.room || '当前位置'}向附近玩家打招呼。`,
|
|
77
|
+
...(state.you.room ? { room: state.you.room } : {}),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
private emitProgress(
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
nearestReportableCorpse,
|
|
9
9
|
nonTeammatesVisible,
|
|
10
10
|
reportCorpseDecision,
|
|
11
|
+
playerStrategyIntent,
|
|
12
|
+
strategyDecision,
|
|
11
13
|
} from '../game-utils.js';
|
|
12
14
|
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
13
15
|
|
|
@@ -21,7 +23,7 @@ import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
|
21
23
|
* 造成的(含队友的杀),靠主动报警伪装好人 / 把嫌疑栽到在场者身上。
|
|
22
24
|
*
|
|
23
25
|
* 调用方按「能贴脸杀就杀,否则报警」的次序:先 immediateLoneKillDecision 再 corpseReportWithNonTeammate。
|
|
24
|
-
*
|
|
26
|
+
* 两者都不读取玩家分类参数,与默认蟹/章鱼对任意落单非队友照杀的设定一致;蟹/章鱼目前
|
|
25
27
|
* 没有记忆版策略,故没有「点名/保护」入口。
|
|
26
28
|
*/
|
|
27
29
|
|
|
@@ -50,11 +52,13 @@ export function corpseReportWithNonTeammate(state: GameState, ctx: StrategyConte
|
|
|
50
52
|
const base = report.action.thinkingContent ?? '发现尸体,报告召开会议';
|
|
51
53
|
return [{
|
|
52
54
|
action: report.action.withThinking(`${base};尸体旁有${witnessNames}在场,立刻报告自证。`),
|
|
55
|
+
intent: report.intent,
|
|
53
56
|
}];
|
|
54
57
|
}
|
|
55
58
|
ctx.notifications.push(`尸体旁有${witnessNames}在场,靠近尸体准备报告自证。`);
|
|
56
59
|
return [{
|
|
57
60
|
action: report.action.withThinking(`尸体旁有${witnessNames}在场,靠近尸体准备报告自证。`),
|
|
61
|
+
intent: report.intent,
|
|
58
62
|
}];
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -78,7 +82,7 @@ export function immediateLoneKillDecision(
|
|
|
78
82
|
if (skipTarget?.(target)) return null;
|
|
79
83
|
|
|
80
84
|
ctx.notifications.push(`发现落单目标${target.name}就在身边,立刻出刀!`);
|
|
81
|
-
return [
|
|
85
|
+
return [strategyDecision(Action.kill(target.name), playerStrategyIntent(target, '追杀', 'acting'))];
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
/**
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
nonTeammatesVisible,
|
|
8
8
|
PatrolState,
|
|
9
9
|
PROGRESS_INTERVAL_MS,
|
|
10
|
+
strategyDecision,
|
|
10
11
|
} from '../game-utils.js';
|
|
11
12
|
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
12
13
|
import { Goal } from './goal.js';
|
|
@@ -133,7 +134,12 @@ export class CrabSabotageTop extends Goal {
|
|
|
133
134
|
this.lastFiredAlarmKey = this.sabotageTaskKey(completed);
|
|
134
135
|
ctx.alarmDone = true;
|
|
135
136
|
ctx.notifications.push('破坏任务完成,触发紧急警报(撞阵营冷却会被拒、冷却好自动补打);警报期照样会被举报,只清落单目标。');
|
|
136
|
-
return [
|
|
137
|
+
return [strategyDecision(Action.triggerAlarm(), {
|
|
138
|
+
activity: 'acting',
|
|
139
|
+
summary: `破坏任务“${completed.task_name}”已完成,正在触发紧急警报。`,
|
|
140
|
+
...(completed.room ? { room: completed.room } : {}),
|
|
141
|
+
task: completed.task_name,
|
|
142
|
+
})];
|
|
137
143
|
}
|
|
138
144
|
return null;
|
|
139
145
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { GameState } from '../../sdk/types.js';
|
|
2
2
|
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
nonTeammatesVisible,
|
|
5
|
+
patrolStep,
|
|
6
|
+
PatrolState,
|
|
7
|
+
patrolStrategyIntent,
|
|
8
|
+
roomAwayFromPlayers,
|
|
9
|
+
strategyDecision,
|
|
10
|
+
} from '../game-utils.js';
|
|
4
11
|
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
5
12
|
import { Goal } from './goal.js';
|
|
6
13
|
import type { LoneKillCore } from './lone-kill-core.js';
|
|
@@ -22,7 +29,12 @@ export class EmergencyHuntGoal extends Goal {
|
|
|
22
29
|
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
23
30
|
const crowd = nonTeammatesVisible(state, ctx);
|
|
24
31
|
const room = roomAwayFromPlayers(state, ctx, crowd);
|
|
25
|
-
if (room)
|
|
26
|
-
|
|
32
|
+
if (room) {
|
|
33
|
+
return [strategyDecision(
|
|
34
|
+
Action.move({ x: room.x, y: room.y }, false),
|
|
35
|
+
patrolStrategyIntent(room, '寻找落单目标'),
|
|
36
|
+
)];
|
|
37
|
+
}
|
|
38
|
+
return patrolStep(state, ctx, this.patrol, this.core.patrolStopOnPlayer(), '巡逻寻找落单目标');
|
|
27
39
|
}
|
|
28
40
|
}
|