@myclaw163/clawclaw-cli 0.8.4 → 0.8.6
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/README.md +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/behavior.md +10 -19
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/README.md +4 -4
- package/docs/runtime/official-perception-modules.md +2 -2
- package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
- package/package.json +15 -2
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/find-hide-spots.py +2 -2
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/skills/clawclaw/SKILL.md +25 -18
- package/skills/clawclaw/references/BEHAVIORS.md +15 -11
- package/skills/clawclaw/references/COMMANDS.md +45 -41
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/commands/account.ts +58 -14
- package/src/commands/behavior.ts +116 -38
- package/src/commands/hub.ts +110 -153
- package/src/commands/load.ts +138 -33
- package/src/commands/perception.ts +55 -24
- package/src/commands/persona.ts +66 -20
- package/src/commands/skill.ts +12 -48
- package/src/commands/trigger.ts +68 -40
- package/src/lib/account-guidance.ts +54 -9
- package/src/lib/agent-workspace-client.ts +135 -0
- package/src/lib/agent-workspace-runtime.ts +154 -0
- package/src/lib/agent-workspace-skills.ts +177 -0
- package/src/lib/agent-workspace-sync.ts +852 -0
- package/src/lib/gameplay-config.ts +29 -15
- package/src/lib/hub-client.ts +252 -34
- package/src/lib/hub-reminder.ts +24 -11
- package/src/lib/init-command.ts +0 -6
- package/src/lib/load-context.ts +12 -6
- package/src/lib/persona.ts +141 -69
- package/src/lib/server-status.ts +78 -0
- package/src/lib/skill-host.ts +160 -0
- package/src/lib/user-data.ts +197 -4
- package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
- package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
- package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
- package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
- package/src/sdk/behavior-toolkit/escape.ts +2 -2
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
- package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
- package/scripts/compare-perception-replays.test.ts +0 -188
- package/scripts/enable_ccl_permissions.test.mjs +0 -163
- package/scripts/enable_monitor.test.mjs +0 -201
- package/scripts/sync-bundled-skill.test.mjs +0 -152
- package/scripts/watch-perception-events.test.ts +0 -43
- package/src/behaviors/official-finite/do-task.ts +0 -211
- package/src/behaviors/official-finite/evade.ts +0 -78
- package/src/behaviors/official-finite/find-player.ts +0 -50
- package/src/behaviors/official-finite/follow-player.ts +0 -70
- package/src/behaviors/official-finite/go-to.ts +0 -69
- package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
- package/src/behaviors/official-finite/hold-position.ts +0 -48
- package/src/behaviors/official-finite/hunt-player.ts +0 -47
- package/src/behaviors/official-finite/index.test.ts +0 -249
- package/src/behaviors/official-finite/index.ts +0 -44
- package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
- package/src/behaviors/official-finite/patrol-area.ts +0 -80
- package/src/behaviors/official-finite/report-corpse.ts +0 -73
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
- package/src/behaviors/official-finite/shared.ts +0 -27
- package/src/channel/claude-channel-server.test.ts +0 -202
- package/src/commands/account.test.ts +0 -570
- package/src/commands/behavior.test.ts +0 -158
- package/src/commands/communication.test.ts +0 -282
- package/src/commands/competition.test.ts +0 -116
- package/src/commands/data.test.ts +0 -89
- package/src/commands/events-canonical-state.test.ts +0 -406
- package/src/commands/events.test.ts +0 -58
- package/src/commands/game/index.test.ts +0 -1251
- package/src/commands/game-map.test.ts +0 -69
- package/src/commands/hub.test.ts +0 -124
- package/src/commands/load.test.ts +0 -440
- package/src/commands/perception.test.ts +0 -75
- package/src/commands/setup/hermes.test.ts +0 -96
- package/src/commands/setup/openclaw.test.ts +0 -124
- package/src/commands/trigger.test.ts +0 -140
- package/src/commands/upgrade.test.ts +0 -82
- package/src/lib/account-guidance.test.ts +0 -36
- package/src/lib/auth.test.ts +0 -151
- package/src/lib/behavior-export.test.ts +0 -326
- package/src/lib/behavior-export.ts +0 -537
- package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
- package/src/lib/custom-tts.test.ts +0 -387
- package/src/lib/diagnostics-config.test.ts +0 -59
- package/src/lib/game-client-tts.test.ts +0 -151
- package/src/lib/game-client.test.ts +0 -250
- package/src/lib/gameplay-config.test.ts +0 -301
- package/src/lib/host-config-patcher.test.ts +0 -130
- package/src/lib/http-transport.test.ts +0 -124
- package/src/lib/hub-client.test.ts +0 -57
- package/src/lib/hub-install.test.ts +0 -135
- package/src/lib/hub-install.ts +0 -185
- package/src/lib/hub-unzip.test.ts +0 -69
- package/src/lib/init-command.test.ts +0 -103
- package/src/lib/load-context.test.ts +0 -62
- package/src/lib/match-state.test.ts +0 -134
- package/src/lib/official-resource-sync.test.ts +0 -199
- package/src/lib/official-resource-sync.ts +0 -221
- package/src/lib/perception-config.test.ts +0 -143
- package/src/lib/perception-export.test.ts +0 -145
- package/src/lib/perception-export.ts +0 -178
- package/src/lib/persona.test.ts +0 -84
- package/src/lib/room.test.ts +0 -88
- package/src/lib/server-registry.test.ts +0 -64
- package/src/lib/service-status.test.ts +0 -81
- package/src/lib/skill-version.test.ts +0 -48
- package/src/lib/trigger-config.test.ts +0 -102
- package/src/lib/trigger-export.test.ts +0 -80
- package/src/lib/trigger-export.ts +0 -210
- package/src/lib/user-data.test.ts +0 -121
- package/src/lib/workspace-argv.test.ts +0 -49
- package/src/pipeline/canonical-event-presentation.test.ts +0 -257
- package/src/pipeline/event-format.test.ts +0 -879
- package/src/pipeline/event-hints.test.ts +0 -337
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
- package/src/pipeline/player-projection.test.ts +0 -247
- package/src/runtime/auto-upgrade.test.ts +0 -66
- package/src/runtime/canonical-event-emitter.test.ts +0 -70
- package/src/runtime/canonical-monitor.test.ts +0 -577
- package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
- package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
- package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
- package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
- package/src/runtime/clawclaw/notifications.test.ts +0 -47
- package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
- package/src/runtime/clawclaw/owner.test.ts +0 -203
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
- package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
- package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
- package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
- package/src/runtime/framework/action-diagnostics.test.ts +0 -81
- package/src/runtime/framework/capability-registry.test.ts +0 -423
- package/src/runtime/framework/control-coordinator.test.ts +0 -675
- package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
- package/src/runtime/framework/events/event-ingress.test.ts +0 -203
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
- package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
- package/src/runtime/framework/mailbox/identity.test.ts +0 -38
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
- package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
- package/src/runtime/framework/participation-manager.test.ts +0 -108
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
- package/src/runtime/framework/state/history/state-history.test.ts +0 -251
- package/src/runtime/framework/state/state-core.test.ts +0 -197
- package/src/runtime/game-sync-protocol.test.ts +0 -123
- package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
- package/src/runtime/mailbox-host-relay.test.ts +0 -293
- package/src/runtime/observability/observability.test.ts +0 -583
- package/src/runtime/owner-control.test.ts +0 -153
- package/src/runtime/parent-process-watch.test.ts +0 -27
- package/src/runtime/pending-event-handoff.test.ts +0 -29
- package/src/runtime/raw-ws-log.test.ts +0 -102
- package/src/runtime/runtime-logger.test.ts +0 -58
- package/src/runtime/runtime-persistence.test.ts +0 -26
- package/src/runtime/runtime.test.ts +0 -1770
- package/src/runtime/ws-client.test.ts +0 -562
- package/src/sdk/action.test.ts +0 -8
- package/src/sdk/behavior-plugin/index.test.ts +0 -74
- package/src/sdk/index.test.ts +0 -45
- package/src/sdk/module-input/index.test.ts +0 -49
- package/src/sdk/perception-plugin/index.test.ts +0 -22
- package/src/sdk/resource-metadata.test.ts +0 -40
- package/src/sdk/trigger-plugin/index.test.ts +0 -41
- package/src/short-command/classifier.test.ts +0 -107
- package/src/short-command/presenter.test.ts +0 -119
- package/src/short-command/runner.test.ts +0 -78
- package/src/short-command/sensitive-data-filter.test.ts +0 -56
- package/src/short-command/transport-response.test.ts +0 -39
- package/src/strategies/avoid-lone.ts +0 -32
- package/src/strategies/avoid-players.ts +0 -43
- package/src/strategies/corpse-patrol.ts +0 -50
- package/src/strategies/crab-sabotage.ts +0 -48
- package/src/strategies/custom-module.test.ts +0 -267
- package/src/strategies/find-player.ts +0 -49
- package/src/strategies/game-utils.test.ts +0 -305
- package/src/strategies/game-utils.ts +0 -927
- package/src/strategies/goals/anchor-linger.ts +0 -77
- package/src/strategies/goals/avoid-lone-top.ts +0 -189
- package/src/strategies/goals/avoid-players-top.test.ts +0 -95
- package/src/strategies/goals/avoid-players-top.ts +0 -122
- package/src/strategies/goals/conversation-goal.ts +0 -51
- package/src/strategies/goals/corpse-patrol-top.ts +0 -120
- package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
- package/src/strategies/goals/crab-sabotage-top.ts +0 -139
- package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
- package/src/strategies/goals/find-player-top.ts +0 -136
- package/src/strategies/goals/flee-players-goal.ts +0 -55
- package/src/strategies/goals/follow-companion-goal.ts +0 -130
- package/src/strategies/goals/goal-manager.ts +0 -41
- package/src/strategies/goals/goal-root-strategy.ts +0 -49
- package/src/strategies/goals/goal.ts +0 -28
- package/src/strategies/goals/hide-top.ts +0 -240
- package/src/strategies/goals/keep-away-goal.ts +0 -243
- package/src/strategies/goals/kill-frenzy-top.ts +0 -90
- package/src/strategies/goals/kill-lone-top.test.ts +0 -96
- package/src/strategies/goals/kill-lone-top.ts +0 -166
- package/src/strategies/goals/kill-target-goal.ts +0 -69
- package/src/strategies/goals/kill-target-top.test.ts +0 -65
- package/src/strategies/goals/kill-target-top.ts +0 -121
- package/src/strategies/goals/leaf-goal.ts +0 -27
- package/src/strategies/goals/linger-corpse-goal.ts +0 -43
- package/src/strategies/goals/lone-kill-core.ts +0 -86
- package/src/strategies/goals/lone-kill-goal.ts +0 -24
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
- package/src/strategies/goals/lone-kill-task-top.ts +0 -133
- package/src/strategies/goals/move-room-goal.ts +0 -102
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
- package/src/strategies/goals/normal-shrimp-top.ts +0 -248
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
- package/src/strategies/goals/paradise-fish-top.ts +0 -234
- package/src/strategies/goals/patrol-top.ts +0 -68
- package/src/strategies/goals/report-patrol-top.ts +0 -97
- package/src/strategies/goals/safe-task-goal.ts +0 -130
- package/src/strategies/goals/social-task-top.ts +0 -192
- package/src/strategies/goals/task-kill-report-top.ts +0 -187
- package/src/strategies/goals/task-only-top.test.ts +0 -88
- package/src/strategies/goals/task-only-top.ts +0 -64
- package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
- package/src/strategies/goals/task-report-top.ts +0 -57
- package/src/strategies/goals/wander-task-goal.ts +0 -33
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
- package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
- package/src/strategies/greeting.ts +0 -60
- package/src/strategies/hide.ts +0 -51
- package/src/strategies/kill-frenzy.ts +0 -32
- package/src/strategies/kill-lone.ts +0 -52
- package/src/strategies/kill-target.ts +0 -48
- package/src/strategies/lone-kill-task.ts +0 -48
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/meeting-gate.ts +0 -28
- package/src/strategies/move-room.ts +0 -46
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/paradise-fish.ts +0 -70
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/patrol.ts +0 -32
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/player-targets.ts +0 -18
- package/src/strategies/report-patrol.ts +0 -32
- package/src/strategies/shrimp-memory.ts +0 -87
- package/src/strategies/social-task.ts +0 -67
- package/src/strategies/speech-module.ts +0 -123
- package/src/strategies/task-kill-report.ts +0 -49
- package/src/strategies/task-only.test.ts +0 -138
- package/src/strategies/task-only.ts +0 -34
- package/src/strategies/task-report.ts +0 -50
- package/src/strategies/types.ts +0 -116
- package/src/strategies/warrior-memory.ts +0 -54
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
FinitePlayerSearch,
|
|
10
|
-
SemanticMoveGate,
|
|
11
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
12
|
-
import { finished, running } from './shared.js';
|
|
13
|
-
|
|
14
|
-
type FindPlayerInput = Readonly<Record<string, unknown>> & {
|
|
15
|
-
readonly player_seat: number;
|
|
16
|
-
readonly timeout_ms?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default class FindPlayerBehavior extends ClawclawBehavior<FindPlayerInput> {
|
|
20
|
-
static override readonly manifest = {
|
|
21
|
-
apiVersion: 3,
|
|
22
|
-
id: 'find_player',
|
|
23
|
-
name: 'Find Player',
|
|
24
|
-
description: 'Search a finite route for one known player.',
|
|
25
|
-
localizations: { 'zh-CN': { name: '寻找玩家', description: '沿有限路线寻找一名已知玩家。' } },
|
|
26
|
-
inputs: [{ id: 'player_seat', type: 'player_seat', description: 'Authoritative seat of the player to find (1-10).', required: true }],
|
|
27
|
-
execution: 'serial',
|
|
28
|
-
runtime: { defaultMs: 45_000, deadlineOutcome: 'failed' },
|
|
29
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
30
|
-
|
|
31
|
-
private readonly search = new FinitePlayerSearch();
|
|
32
|
-
private readonly move = new SemanticMoveGate();
|
|
33
|
-
|
|
34
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): FindPlayerInput {
|
|
35
|
-
return {
|
|
36
|
-
player_seat: api.number(input.player_seat, 'player_seat', { integer: true, min: 1, max: 10 }),
|
|
37
|
-
...api.timing(input),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
override async decide(input: Readonly<BehaviorInput<FindPlayerInput>>, api: BehaviorReadApi) {
|
|
42
|
-
const result = await this.search.step(input, api, input.input.player_seat);
|
|
43
|
-
if (result.kind === 'visible') {
|
|
44
|
-
return finished('completed', 'player_found', `已在${result.player.room ?? '当前区域'}看到${result.player.name}。`);
|
|
45
|
-
}
|
|
46
|
-
if (result.kind === 'failed') return finished('failed', result.reason, result.summary);
|
|
47
|
-
const action = this.move.propose(input, result.target, false, result.summary);
|
|
48
|
-
return running(result.summary, 'moving', action ? [action] : []);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
behaviorDistance,
|
|
10
|
-
behaviorSelf,
|
|
11
|
-
FinitePlayerSearch,
|
|
12
|
-
SemanticMoveGate,
|
|
13
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
14
|
-
import { finished, running } from './shared.js';
|
|
15
|
-
|
|
16
|
-
type FollowPlayerInput = Readonly<Record<string, unknown>> & {
|
|
17
|
-
readonly player_seat: number;
|
|
18
|
-
readonly distance: number;
|
|
19
|
-
readonly duration_ms?: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default class FollowPlayerBehavior extends ClawclawBehavior<FollowPlayerInput> {
|
|
23
|
-
static override readonly manifest = {
|
|
24
|
-
apiVersion: 3,
|
|
25
|
-
id: 'follow_player',
|
|
26
|
-
name: 'Follow Player',
|
|
27
|
-
description: 'Follow one known player at a bounded distance.',
|
|
28
|
-
localizations: { 'zh-CN': { name: '跟随玩家', description: '在有限距离内跟随一名已知玩家。' } },
|
|
29
|
-
inputs: [
|
|
30
|
-
{ id: 'player_seat', type: 'player_seat', description: 'Authoritative seat of the player to follow (1-10).', required: true },
|
|
31
|
-
{ id: 'distance', type: 'number', description: 'Preferred following distance in pixels.', min: 20, max: 500, default: 90 },
|
|
32
|
-
],
|
|
33
|
-
execution: 'serial',
|
|
34
|
-
runtime: { defaultMs: 30_000, deadlineOutcome: 'completed' },
|
|
35
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
36
|
-
|
|
37
|
-
private readonly search = new FinitePlayerSearch();
|
|
38
|
-
private readonly move = new SemanticMoveGate();
|
|
39
|
-
|
|
40
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): FollowPlayerInput {
|
|
41
|
-
return {
|
|
42
|
-
player_seat: api.number(input.player_seat, 'player_seat', { integer: true, min: 1, max: 10 }),
|
|
43
|
-
distance: api.number(input.distance, 'follow_distance', { min: 20, max: 500 }),
|
|
44
|
-
...api.timing(input),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
override async decide(input: Readonly<BehaviorInput<FollowPlayerInput>>, api: BehaviorReadApi) {
|
|
49
|
-
const result = await this.search.step(input, api, input.input.player_seat);
|
|
50
|
-
if (result.kind === 'failed') return finished('failed', result.reason, result.summary);
|
|
51
|
-
if (result.kind === 'move') {
|
|
52
|
-
const action = this.move.propose(input, result.target, false, result.summary);
|
|
53
|
-
return running(result.summary, 'moving', action ? [action] : []);
|
|
54
|
-
}
|
|
55
|
-
const self = behaviorSelf(input);
|
|
56
|
-
if (!self) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
57
|
-
const distance = behaviorDistance(self, result.player);
|
|
58
|
-
if (distance <= input.input.distance * 1.15) {
|
|
59
|
-
return running(`正在与${result.player.name}保持约${Math.round(distance)}距离。`, 'waiting', [], { targetPlayer: result.player.name });
|
|
60
|
-
}
|
|
61
|
-
const travel = Math.max(0, distance - input.input.distance);
|
|
62
|
-
const target = {
|
|
63
|
-
x: self.x + ((result.player.x - self.x) * travel) / distance,
|
|
64
|
-
y: self.y + ((result.player.y - self.y) * travel) / distance,
|
|
65
|
-
};
|
|
66
|
-
const summary = `正在跟随${result.player.name}并保持距离。`;
|
|
67
|
-
const action = this.move.propose(input, target, false, summary);
|
|
68
|
-
return running(summary, 'moving', action ? [action] : [], { targetPlayer: result.player.name });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
behaviorSelf,
|
|
10
|
-
behaviorTasks,
|
|
11
|
-
findBehaviorRoom,
|
|
12
|
-
normalizedBehaviorLabel,
|
|
13
|
-
SemanticMoveGate,
|
|
14
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
15
|
-
import { finished, running } from './shared.js';
|
|
16
|
-
|
|
17
|
-
type GoToInput = Readonly<Record<string, unknown>> & {
|
|
18
|
-
readonly destination: string;
|
|
19
|
-
readonly timeout_ms?: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default class GoToBehavior extends ClawclawBehavior<GoToInput> {
|
|
23
|
-
static override readonly manifest = {
|
|
24
|
-
apiVersion: 3,
|
|
25
|
-
id: 'go_to',
|
|
26
|
-
name: 'Go To',
|
|
27
|
-
description: 'Navigate to one semantic room or task destination.',
|
|
28
|
-
localizations: { 'zh-CN': { name: '前往', description: '前往一个语义房间或任务地点。' } },
|
|
29
|
-
inputs: [{
|
|
30
|
-
id: 'destination',
|
|
31
|
-
type: 'string',
|
|
32
|
-
description: 'Known room name or exact current task id or name.',
|
|
33
|
-
required: true,
|
|
34
|
-
}],
|
|
35
|
-
execution: 'serial',
|
|
36
|
-
runtime: { defaultMs: 45_000, deadlineOutcome: 'failed' },
|
|
37
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
38
|
-
|
|
39
|
-
private readonly move = new SemanticMoveGate();
|
|
40
|
-
|
|
41
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): GoToInput {
|
|
42
|
-
return {
|
|
43
|
-
destination: api.string(input.destination, 'destination'),
|
|
44
|
-
...api.timing(input),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
override async decide(input: Readonly<BehaviorInput<GoToInput>>, api: BehaviorReadApi) {
|
|
49
|
-
const room = findBehaviorRoom(api, input.input.destination);
|
|
50
|
-
const task = behaviorTasks(input).find((candidate) => (
|
|
51
|
-
normalizedBehaviorLabel(candidate.name) === normalizedBehaviorLabel(input.input.destination)
|
|
52
|
-
|| (!!candidate.id && normalizedBehaviorLabel(candidate.id) === normalizedBehaviorLabel(input.input.destination))
|
|
53
|
-
));
|
|
54
|
-
const target = task ?? room;
|
|
55
|
-
const label = room?.name ?? task?.name ?? input.input.destination;
|
|
56
|
-
if (!target) return finished('failed', 'destination_unknown', `找不到语义目标“${input.input.destination}”。`);
|
|
57
|
-
if (room && input.gameState.you?.room === room.name) {
|
|
58
|
-
return finished('completed', 'arrived', `已到达${label}。`);
|
|
59
|
-
}
|
|
60
|
-
const self = behaviorSelf(input);
|
|
61
|
-
if (!self) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
62
|
-
const distance = await api.navigation.pathDistance(self, target);
|
|
63
|
-
if (distance === null) return finished('failed', 'destination_unreachable', `当前没有到达${label}的可用路径。`);
|
|
64
|
-
if (distance <= 70) return finished('completed', 'arrived', `已到达${label}。`);
|
|
65
|
-
const summary = `正在前往${label}。`;
|
|
66
|
-
const action = this.move.propose(input, target, false, summary);
|
|
67
|
-
return running(summary, 'moving', action ? [action] : [], room ? { room: room.name } : task ? { task: task.name } : {});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
behaviorDistance,
|
|
10
|
-
behaviorHideSpots,
|
|
11
|
-
behaviorSelf,
|
|
12
|
-
behaviorTeammateSeats,
|
|
13
|
-
behaviorVisiblePlayers,
|
|
14
|
-
nearestBehaviorHideSpot,
|
|
15
|
-
normalizedBehaviorLabel,
|
|
16
|
-
planBehaviorEscape,
|
|
17
|
-
SemanticMoveGate,
|
|
18
|
-
type HideSpot,
|
|
19
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
20
|
-
import { finished, running } from './shared.js';
|
|
21
|
-
|
|
22
|
-
type HideInput = Readonly<Record<string, unknown>> & {
|
|
23
|
-
readonly area?: string;
|
|
24
|
-
readonly duration_ms?: number;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default class HideTemporarilyBehavior extends ClawclawBehavior<HideInput> {
|
|
28
|
-
static override readonly manifest = {
|
|
29
|
-
apiVersion: 3,
|
|
30
|
-
id: 'hide_temporarily',
|
|
31
|
-
name: 'Hide Temporarily',
|
|
32
|
-
description: 'Move to and remain near a bounded hide point.',
|
|
33
|
-
localizations: { 'zh-CN': { name: '短暂隐藏', description: '移动到一个隐藏点并在附近有限停留。' } },
|
|
34
|
-
inputs: [{ id: 'area', type: 'string', description: 'Optional preferred room name.' }],
|
|
35
|
-
execution: 'serial',
|
|
36
|
-
runtime: { defaultMs: 20_000, deadlineOutcome: 'completed' },
|
|
37
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
38
|
-
|
|
39
|
-
private readonly move = new SemanticMoveGate();
|
|
40
|
-
private hideTarget?: HideSpot;
|
|
41
|
-
private escapeTarget?: Readonly<{ x: number; y: number }>;
|
|
42
|
-
|
|
43
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): HideInput {
|
|
44
|
-
const area = api.optionalString(input.area, 'area');
|
|
45
|
-
return { ...api.timing(input), ...(area ? { area } : {}) };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
override decide(input: Readonly<BehaviorInput<HideInput>>, _api: BehaviorReadApi) {
|
|
49
|
-
const self = behaviorSelf(input);
|
|
50
|
-
if (!self) return finished('failed', 'self_position_unavailable', '当前无法取得自身位置。');
|
|
51
|
-
const teammates = behaviorTeammateSeats(input);
|
|
52
|
-
const threats = behaviorVisiblePlayers(input).filter((player) => (
|
|
53
|
-
player.isAlive !== false && !teammates.has(player.seat)
|
|
54
|
-
));
|
|
55
|
-
if (threats.some((threat) => behaviorDistance(self, threat) <= 420)) {
|
|
56
|
-
const plan = planBehaviorEscape(self, threats);
|
|
57
|
-
if (plan.caught && plan.survivedSteps === 0) return finished('failed', 'no_escape_route', '当前没有可确认的逃生路线。');
|
|
58
|
-
this.escapeTarget = plan.target;
|
|
59
|
-
const summary = `威胁过近,正在先远离${threats.map((threat) => threat.name).join('、')}。`;
|
|
60
|
-
const action = this.move.propose(input, this.escapeTarget, false, summary);
|
|
61
|
-
return running(summary, 'moving', action ? [action] : []);
|
|
62
|
-
}
|
|
63
|
-
const preferred = input.input.area
|
|
64
|
-
? behaviorHideSpots()
|
|
65
|
-
.filter((spot) => normalizedBehaviorLabel(spot.room) === normalizedBehaviorLabel(input.input.area!))
|
|
66
|
-
.sort((left, right) => behaviorDistance(self, left) - behaviorDistance(self, right))[0]
|
|
67
|
-
: undefined;
|
|
68
|
-
this.hideTarget = preferred ?? nearestBehaviorHideSpot(self, threats, this.hideTarget) ?? undefined;
|
|
69
|
-
if (!this.hideTarget) return finished('failed', 'hide_spot_unavailable', '没有可用的隐藏点。');
|
|
70
|
-
if (behaviorDistance(self, this.hideTarget) <= 35) {
|
|
71
|
-
return running(`正在${this.hideTarget.room}隐蔽等待。`, 'waiting', [], { room: this.hideTarget.room });
|
|
72
|
-
}
|
|
73
|
-
const summary = `正在前往${this.hideTarget.room}的隐藏点。`;
|
|
74
|
-
const action = this.move.propose(input, this.hideTarget, false, summary);
|
|
75
|
-
return running(summary, 'moving', action ? [action] : [], { room: this.hideTarget.room });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type ClawclawBehaviorManifest,
|
|
6
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
7
|
-
import { finished, running } from './shared.js';
|
|
8
|
-
|
|
9
|
-
type HoldInput = Readonly<Record<string, unknown>> & {
|
|
10
|
-
readonly duration_ms?: number;
|
|
11
|
-
readonly timeout_ms?: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default class HoldPositionBehavior extends ClawclawBehavior<HoldInput> {
|
|
15
|
-
static override readonly manifest = {
|
|
16
|
-
apiVersion: 3,
|
|
17
|
-
id: 'hold_position',
|
|
18
|
-
name: 'Hold Position',
|
|
19
|
-
description: 'Stop planning movement and wait in place for a finite duration.',
|
|
20
|
-
localizations: { 'zh-CN': { name: '原地等待', description: '停止规划移动,并在原地等待有限时长。' } },
|
|
21
|
-
inputs: [],
|
|
22
|
-
execution: 'serial',
|
|
23
|
-
runtime: { defaultMs: 5_000, deadlineOutcome: 'failed', controlGraceMs: 11_000 },
|
|
24
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
25
|
-
|
|
26
|
-
private startedAtMs?: number;
|
|
27
|
-
private holdUntilMs?: number;
|
|
28
|
-
|
|
29
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): HoldInput {
|
|
30
|
-
return { ...api.timing(input) };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
override decide(input: Readonly<BehaviorInput<HoldInput>>) {
|
|
34
|
-
this.startedAtMs ??= input.nowMs;
|
|
35
|
-
if (input.gameState.you?.activity?.kind === 'moving') {
|
|
36
|
-
if (input.nowMs - this.startedAtMs >= 10_000) {
|
|
37
|
-
return finished('failed', 'motion_did_not_stop', '底层已有移动未在等待预算内结束,无法开始原地等待。');
|
|
38
|
-
}
|
|
39
|
-
return running('已停止规划新移动,等待底层现有移动结束后原地等待。', 'waiting');
|
|
40
|
-
}
|
|
41
|
-
const duration = input.input.duration_ms ?? input.input.timeout_ms ?? 5_000;
|
|
42
|
-
this.holdUntilMs ??= input.nowMs + duration;
|
|
43
|
-
if (input.nowMs >= this.holdUntilMs) {
|
|
44
|
-
return finished('completed', 'duration_elapsed', '已完成明确的原地有限等待。');
|
|
45
|
-
}
|
|
46
|
-
return running(`正在原地有限等待,剩余约${Math.max(0, Math.ceil((this.holdUntilMs - input.nowMs) / 1_000))}秒。`, 'waiting');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClawclawBehavior,
|
|
3
|
-
type BehaviorInput,
|
|
4
|
-
type BehaviorNormalizationApi,
|
|
5
|
-
type BehaviorReadApi,
|
|
6
|
-
type ClawclawBehaviorManifest,
|
|
7
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
8
|
-
import {
|
|
9
|
-
AuthoritativeKillFlow,
|
|
10
|
-
type AfterKillBehavior,
|
|
11
|
-
} from '../../sdk/behavior-toolkit/index.js';
|
|
12
|
-
|
|
13
|
-
type HuntInput = Readonly<Record<string, unknown>> & {
|
|
14
|
-
readonly player_seat: number;
|
|
15
|
-
readonly after_kill: AfterKillBehavior;
|
|
16
|
-
readonly timeout_ms?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default class HuntPlayerBehavior extends ClawclawBehavior<HuntInput> {
|
|
20
|
-
static override readonly manifest = {
|
|
21
|
-
apiVersion: 3,
|
|
22
|
-
id: 'hunt_player',
|
|
23
|
-
name: 'Hunt Player',
|
|
24
|
-
description: 'Find and attempt one authoritative kill against a player seat.',
|
|
25
|
-
localizations: { 'zh-CN': { name: '追猎玩家', description: '寻找指定玩家并尝试一次由权威状态确认的击杀。' } },
|
|
26
|
-
inputs: [
|
|
27
|
-
{ id: 'player_seat', type: 'player_seat', description: 'Authoritative seat of the player to hunt (1-10).', required: true },
|
|
28
|
-
{ id: 'after_kill', type: 'enum', description: 'Follow-up after a confirmed kill.', values: ['escape', 'hold', 'report', 'replan'], default: 'escape' },
|
|
29
|
-
],
|
|
30
|
-
execution: 'serial',
|
|
31
|
-
runtime: { defaultMs: 60_000, deadlineOutcome: 'failed' },
|
|
32
|
-
} as const satisfies ClawclawBehaviorManifest;
|
|
33
|
-
|
|
34
|
-
private readonly kill = new AuthoritativeKillFlow();
|
|
35
|
-
|
|
36
|
-
override normalize(input: Readonly<Record<string, unknown>>, api: BehaviorNormalizationApi): HuntInput {
|
|
37
|
-
return {
|
|
38
|
-
player_seat: api.number(input.player_seat, 'player_seat', { integer: true, min: 1, max: 10 }),
|
|
39
|
-
after_kill: api.choice(input.after_kill, 'after_kill', ['escape', 'hold', 'report', 'replan'] as const),
|
|
40
|
-
...api.timing(input),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
override decide(input: Readonly<BehaviorInput<HuntInput>>, api: BehaviorReadApi) {
|
|
45
|
-
return this.kill.step(input, api, input.input.player_seat, input.input.after_kill);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type {
|
|
3
|
-
BehaviorInput,
|
|
4
|
-
BehaviorReadApi,
|
|
5
|
-
GameState,
|
|
6
|
-
ObservedCorpse,
|
|
7
|
-
ObservedPlayer,
|
|
8
|
-
} from '../../sdk/behavior-plugin/index.js';
|
|
9
|
-
import {
|
|
10
|
-
DoTaskBehavior,
|
|
11
|
-
GoToBehavior,
|
|
12
|
-
HuntPlayerBehavior,
|
|
13
|
-
OFFICIAL_FINITE_BEHAVIOR_CLASSES,
|
|
14
|
-
ReportCorpseBehavior,
|
|
15
|
-
} from './index.js';
|
|
16
|
-
|
|
17
|
-
const rooms = [{
|
|
18
|
-
name: '厨房',
|
|
19
|
-
polygon: [[100, 0], [200, 0], [200, 100], [100, 100]] as const,
|
|
20
|
-
bbox: { left: 100, top: 0, right: 200, bottom: 100 },
|
|
21
|
-
}, {
|
|
22
|
-
name: '酒吧',
|
|
23
|
-
polygon: [[300, 0], [400, 0], [400, 100], [300, 100]] as const,
|
|
24
|
-
bbox: { left: 300, top: 0, right: 400, bottom: 100 },
|
|
25
|
-
}] as const;
|
|
26
|
-
|
|
27
|
-
function api(options: Readonly<{
|
|
28
|
-
players?: readonly Readonly<ObservedPlayer>[];
|
|
29
|
-
corpses?: readonly Readonly<ObservedCorpse>[];
|
|
30
|
-
}> = {}): BehaviorReadApi {
|
|
31
|
-
const distance = (from: Readonly<{ x: number; y: number }>, to: Readonly<{ x: number; y: number }>) => (
|
|
32
|
-
Math.hypot(from.x - to.x, from.y - to.y)
|
|
33
|
-
);
|
|
34
|
-
return {
|
|
35
|
-
spatial: {
|
|
36
|
-
xPositive: 'right',
|
|
37
|
-
yPositive: 'down',
|
|
38
|
-
playerBodyLengthPx: 64,
|
|
39
|
-
rooms,
|
|
40
|
-
roomAt: () => null,
|
|
41
|
-
sideInRoom: () => null,
|
|
42
|
-
placeLabel: () => '',
|
|
43
|
-
transitionIsMapped: () => true,
|
|
44
|
-
},
|
|
45
|
-
navigation: {
|
|
46
|
-
pathDistance: async (from, to) => distance(from, to),
|
|
47
|
-
pathDistances: async (queries) => queries.map(({ from, to }) => distance(from, to)),
|
|
48
|
-
},
|
|
49
|
-
observation: {
|
|
50
|
-
lastSeenPlayer: (seat, maxAgeMs) => options.players?.find((player) => (
|
|
51
|
-
player.seat === seat && (maxAgeMs === undefined || player.ageMs <= maxAgeMs)
|
|
52
|
-
)),
|
|
53
|
-
lastSeenCorpse: (seat) => options.corpses?.find((corpse) => (
|
|
54
|
-
seat === undefined || corpse.seat === seat
|
|
55
|
-
)),
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function state(overrides: Partial<GameState> = {}): GameState {
|
|
61
|
-
return {
|
|
62
|
-
game_id: 'game',
|
|
63
|
-
tick: 1,
|
|
64
|
-
phase: 'wandering',
|
|
65
|
-
you: {
|
|
66
|
-
player: { seat: 1, name: 'Self' },
|
|
67
|
-
x: 0,
|
|
68
|
-
y: 0,
|
|
69
|
-
room: '走廊',
|
|
70
|
-
role: 'shrimp_generic',
|
|
71
|
-
faction: 'lobster',
|
|
72
|
-
is_alive: true,
|
|
73
|
-
activity: { kind: 'idle' },
|
|
74
|
-
tasks: [],
|
|
75
|
-
},
|
|
76
|
-
players: [],
|
|
77
|
-
visible_players: [],
|
|
78
|
-
visible_corpses: [],
|
|
79
|
-
...overrides,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function frame<T extends Readonly<Record<string, unknown>>>(
|
|
84
|
-
gameState: GameState,
|
|
85
|
-
values: T,
|
|
86
|
-
epochId = 1,
|
|
87
|
-
nowMs = 1_000,
|
|
88
|
-
events: BehaviorInput<T>['events'] = [],
|
|
89
|
-
): BehaviorInput<T> {
|
|
90
|
-
return {
|
|
91
|
-
epochId,
|
|
92
|
-
scope: { sessionId: 'session', segmentId: 'segment' },
|
|
93
|
-
nowMs,
|
|
94
|
-
gameState,
|
|
95
|
-
events,
|
|
96
|
-
input: values,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
describe('official finite Behavior modules', () => {
|
|
101
|
-
it('exposes twelve unique serial API v3 modules with real decide handlers', () => {
|
|
102
|
-
expect(OFFICIAL_FINITE_BEHAVIOR_CLASSES).toHaveLength(12);
|
|
103
|
-
const ids = OFFICIAL_FINITE_BEHAVIOR_CLASSES.map((BehaviorClass) => BehaviorClass.manifest?.id);
|
|
104
|
-
expect(new Set(ids).size).toBe(12);
|
|
105
|
-
expect(ids).toContain('hide_temporarily');
|
|
106
|
-
expect(ids).not.toContain('hide');
|
|
107
|
-
for (const BehaviorClass of OFFICIAL_FINITE_BEHAVIOR_CLASSES) {
|
|
108
|
-
expect(BehaviorClass.manifest).toMatchObject({ apiVersion: 3, execution: 'serial' });
|
|
109
|
-
expect(String(BehaviorClass.prototype.decide).replace(/\s/g, '')).not.toMatch(/\{return\{\};?\}$/);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('go_to moves and completes only from later authoritative position', async () => {
|
|
114
|
-
const behavior = new GoToBehavior();
|
|
115
|
-
const first = await behavior.decide(frame(state(), { destination: '厨房', timeout_ms: 45_000 }), api());
|
|
116
|
-
expect(first?.actions).toEqual([expect.objectContaining({ action: 'move' })]);
|
|
117
|
-
expect(first?.finish).toBeUndefined();
|
|
118
|
-
|
|
119
|
-
const arrived = state({ you: { ...state().you!, x: 150, y: 50, room: '厨房' } });
|
|
120
|
-
const second = await behavior.decide(frame(arrived, { destination: '厨房', timeout_ms: 45_000 }, 2), api());
|
|
121
|
-
expect(second?.finish).toMatchObject({ outcome: 'completed', reason: 'arrived' });
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('hunt_player waits for later authoritative kill evidence without a receipt', async () => {
|
|
125
|
-
const behavior = new HuntPlayerBehavior();
|
|
126
|
-
const hunting = state({
|
|
127
|
-
you: { ...state().you!, role: 'crab_generic', faction: 'crab', kills_remaining: 1, crab_teammates: [] },
|
|
128
|
-
players: [{ seat: 2, name: 'Target', known_status: { is_alive: true } }],
|
|
129
|
-
visible_players: [{ player: { seat: 2, name: 'Target' }, x: 10, y: 0, room: '走廊', distance: 10, is_alive: true }],
|
|
130
|
-
});
|
|
131
|
-
const first = await behavior.decide(frame(hunting, {
|
|
132
|
-
player_seat: 2,
|
|
133
|
-
after_kill: 'replan',
|
|
134
|
-
timeout_ms: 60_000,
|
|
135
|
-
}), api());
|
|
136
|
-
expect(first?.actions).toEqual([expect.objectContaining({ action: 'kill', target_seat: 2 })]);
|
|
137
|
-
expect(first?.finish).toBeUndefined();
|
|
138
|
-
|
|
139
|
-
const confirmed = state({
|
|
140
|
-
you: { ...hunting.you!, kills_remaining: 0 },
|
|
141
|
-
players: [{ seat: 2, name: 'Target', known_status: { is_alive: false } }],
|
|
142
|
-
});
|
|
143
|
-
const second = await behavior.decide(frame(confirmed, {
|
|
144
|
-
player_seat: 2,
|
|
145
|
-
after_kill: 'replan',
|
|
146
|
-
timeout_ms: 60_000,
|
|
147
|
-
}, 2, 1_100), api());
|
|
148
|
-
expect(second?.finish).toMatchObject({ outcome: 'completed', reason: 'kill_confirmed' });
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('do_task waits for a later authoritative completed task', async () => {
|
|
152
|
-
const behavior = new DoTaskBehavior();
|
|
153
|
-
const taskState = state({
|
|
154
|
-
you: {
|
|
155
|
-
...state().you!,
|
|
156
|
-
tasks: [{ task_id: 'wires', name: '接线', room: '走廊', x: 5, y: 0, is_fake_shrimp: false, status: 'normal' }],
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
const first = await behavior.decide(frame(taskState, { task: 'wires', timeout_ms: 60_000 }), api());
|
|
160
|
-
expect(first?.actions).toEqual([expect.objectContaining({ action: 'task', task_name: '接线' })]);
|
|
161
|
-
const completed = state({
|
|
162
|
-
you: {
|
|
163
|
-
...taskState.you!,
|
|
164
|
-
tasks: [{ task_id: 'wires', name: '接线', room: '走廊', x: 5, y: 0, is_fake_shrimp: false, status: 'completed' }],
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
const second = await behavior.decide(frame(completed, { task: 'wires', timeout_ms: 60_000 }, 2), api());
|
|
168
|
-
expect(second?.finish).toMatchObject({ outcome: 'completed', reason: 'task_completed' });
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('do_task refuses a Crab sabotage task while the shared cooldown is active', async () => {
|
|
172
|
-
const behavior = new DoTaskBehavior();
|
|
173
|
-
const taskState = state({
|
|
174
|
-
crab_sabotage: { status: 'cooldown_charged', cooldown_remaining_secs: 72.4 },
|
|
175
|
-
you: {
|
|
176
|
-
...state().you!,
|
|
177
|
-
role: 'crab_generic',
|
|
178
|
-
faction: 'crab',
|
|
179
|
-
tasks: [{ task_id: '102', name: '投放毒药', room: '走廊', x: 5, y: 0, is_fake_shrimp: false, status: 'normal' }],
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const decision = await behavior.decide(frame(taskState, { task: '102', timeout_ms: 60_000 }), api());
|
|
184
|
-
expect(decision?.actions).toBeUndefined();
|
|
185
|
-
expect(decision?.finish).toMatchObject({ outcome: 'failed', reason: 'sabotage_on_cooldown' });
|
|
186
|
-
expect(decision?.finish?.summary).toContain('72.4秒');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('do_task releases an interrupted Crab sabotage task without consuming or resubmitting it', async () => {
|
|
190
|
-
const behavior = new DoTaskBehavior();
|
|
191
|
-
const ready = state({
|
|
192
|
-
crab_sabotage: { status: 'ready' },
|
|
193
|
-
you: {
|
|
194
|
-
...state().you!,
|
|
195
|
-
role: 'crab_generic',
|
|
196
|
-
faction: 'crab',
|
|
197
|
-
tasks: [{ task_id: '102', name: '投放毒药', room: '走廊', x: 5, y: 0, is_fake_shrimp: false, status: 'normal' }],
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
const first = await behavior.decide(frame(ready, { task: '102', timeout_ms: 60_000 }), api());
|
|
201
|
-
expect(first?.actions).toEqual([expect.objectContaining({ action: 'task', task_name: '投放毒药' })]);
|
|
202
|
-
|
|
203
|
-
const interrupted = state({
|
|
204
|
-
crab_sabotage: { status: 'emergency_active' },
|
|
205
|
-
emergency: { active: true, task_name: '解除毒药' },
|
|
206
|
-
you: {
|
|
207
|
-
...ready.you!,
|
|
208
|
-
activity: { kind: 'idle' },
|
|
209
|
-
tasks: [{ task_id: '102', name: '投放毒药', room: '走廊', x: 5, y: 0, is_fake_shrimp: false, status: 'normal' }],
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
const second = await behavior.decide(frame(
|
|
213
|
-
interrupted,
|
|
214
|
-
{ task: '102', timeout_ms: 60_000 },
|
|
215
|
-
2,
|
|
216
|
-
1_100,
|
|
217
|
-
[{
|
|
218
|
-
eventId: 'interrupted-1',
|
|
219
|
-
epochId: 2,
|
|
220
|
-
type: 'task_interrupted',
|
|
221
|
-
occurredAt: '2026-08-25T00:00:00.000Z',
|
|
222
|
-
payload: {
|
|
223
|
-
task_id: '102',
|
|
224
|
-
task_name: '投放毒药',
|
|
225
|
-
reason: 'emergency_started',
|
|
226
|
-
cooldown_remaining_secs: 100,
|
|
227
|
-
},
|
|
228
|
-
}],
|
|
229
|
-
), api());
|
|
230
|
-
expect(second?.actions).toBeUndefined();
|
|
231
|
-
expect(second?.finish).toMatchObject({ outcome: 'failed', reason: 'task_interrupted' });
|
|
232
|
-
expect(second?.finish?.summary).toContain('任务未消耗');
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('report_corpse completes only after a later meeting transition', async () => {
|
|
236
|
-
const behavior = new ReportCorpseBehavior();
|
|
237
|
-
const corpseState = state({
|
|
238
|
-
visible_corpses: [{ corpse_id: 'corpse-2', player: { seat: 2, name: 'Dead' }, x: 10, y: 0, room: '走廊', distance: 10 }],
|
|
239
|
-
});
|
|
240
|
-
const first = await behavior.decide(frame(corpseState, { corpse_seat: 2, timeout_ms: 45_000 }), api());
|
|
241
|
-
expect(first?.actions).toEqual([expect.objectContaining({ action: 'report' })]);
|
|
242
|
-
expect(first?.finish).toBeUndefined();
|
|
243
|
-
|
|
244
|
-
const meeting = state({ phase: 'meeting', meeting: { active: true } });
|
|
245
|
-
const second = await behavior.decide(frame(meeting, { corpse_seat: 2, timeout_ms: 45_000 }, 2), api());
|
|
246
|
-
expect(second?.finish).toMatchObject({ outcome: 'completed', reason: 'corpse_reported' });
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { ClawclawBehaviorClass } from '../../sdk/behavior-plugin/index.js';
|
|
2
|
-
import DoTaskBehavior from './do-task.js';
|
|
3
|
-
import EvadeBehavior from './evade.js';
|
|
4
|
-
import FindPlayerBehavior from './find-player.js';
|
|
5
|
-
import FollowPlayerBehavior from './follow-player.js';
|
|
6
|
-
import GoToBehavior from './go-to.js';
|
|
7
|
-
import HideTemporarilyBehavior from './hide-temporarily.js';
|
|
8
|
-
import HoldPositionBehavior from './hold-position.js';
|
|
9
|
-
import HuntPlayerBehavior from './hunt-player.js';
|
|
10
|
-
import InspectCorpseBehavior from './inspect-corpse.js';
|
|
11
|
-
import PatrolAreaBehavior from './patrol-area.js';
|
|
12
|
-
import ReportCorpseBehavior from './report-corpse.js';
|
|
13
|
-
import SeekKillOpportunityBehavior from './seek-kill-opportunity.js';
|
|
14
|
-
|
|
15
|
-
/** Standard public-API implementations; Runtime must load them like user modules. */
|
|
16
|
-
export const OFFICIAL_FINITE_BEHAVIOR_CLASSES = Object.freeze([
|
|
17
|
-
GoToBehavior,
|
|
18
|
-
PatrolAreaBehavior,
|
|
19
|
-
FindPlayerBehavior,
|
|
20
|
-
FollowPlayerBehavior,
|
|
21
|
-
HuntPlayerBehavior,
|
|
22
|
-
SeekKillOpportunityBehavior,
|
|
23
|
-
EvadeBehavior,
|
|
24
|
-
HideTemporarilyBehavior,
|
|
25
|
-
HoldPositionBehavior,
|
|
26
|
-
DoTaskBehavior,
|
|
27
|
-
InspectCorpseBehavior,
|
|
28
|
-
ReportCorpseBehavior,
|
|
29
|
-
] as const satisfies readonly ClawclawBehaviorClass[]);
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
DoTaskBehavior,
|
|
33
|
-
EvadeBehavior,
|
|
34
|
-
FindPlayerBehavior,
|
|
35
|
-
FollowPlayerBehavior,
|
|
36
|
-
GoToBehavior,
|
|
37
|
-
HideTemporarilyBehavior,
|
|
38
|
-
HoldPositionBehavior,
|
|
39
|
-
HuntPlayerBehavior,
|
|
40
|
-
InspectCorpseBehavior,
|
|
41
|
-
PatrolAreaBehavior,
|
|
42
|
-
ReportCorpseBehavior,
|
|
43
|
-
SeekKillOpportunityBehavior,
|
|
44
|
-
};
|