@myclaw163/clawclaw-cli 0.7.16 → 0.8.2
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_HERMES.md +1 -1
- package/QUICKSTART_OPENCLAW.md +3 -11
- package/QUICKSTART_OTHER.md +8 -8
- package/README.md +18 -9
- package/bin/clawclaw-channel.mjs +13 -0
- package/docs/configuration.md +86 -33
- package/docs/custom-modules/README.md +148 -0
- package/docs/custom-modules/api-reference.md +767 -0
- package/docs/custom-modules/behavior.md +318 -0
- package/docs/custom-modules/perception.md +305 -0
- package/docs/custom-modules/trigger.md +292 -0
- package/docs/desktop-event-push.md +6 -4
- package/docs/runtime/README.md +28 -10
- package/docs/runtime/agent-notifications.md +48 -29
- package/docs/runtime/behavior-runtime.md +139 -0
- package/docs/runtime/components-and-boundaries.md +89 -173
- package/docs/runtime/events-and-state.md +55 -66
- package/docs/runtime/official-perception-modules.md +17 -9
- package/docs/runtime/owner-lifecycle-and-observability.md +62 -39
- package/docs/runtime/perception-replay.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +35 -37
- package/package.json +10 -7
- package/scripts/check-skill-command-surface.mjs +54 -10
- package/scripts/compare-perception-replays.test.ts +10 -10
- package/scripts/compare-perception-replays.ts +14 -10
- package/scripts/replay-perception.ts +3 -3
- package/scripts/watch-perception-events.test.ts +1 -1
- package/skills/clawclaw/SKILL.md +97 -59
- package/skills/clawclaw/references/BEHAVIORS.md +154 -0
- package/skills/clawclaw/references/CHANNELS.md +115 -0
- package/skills/clawclaw/references/CHATTERBOX.md +3 -2
- package/skills/clawclaw/references/COMMANDS.md +108 -58
- package/skills/clawclaw/references/GAME-MECHANICS.md +4 -3
- package/skills/clawclaw/references/HUB.md +27 -23
- package/skills/clawclaw/references/STREAM.md +18 -14
- package/skills/clawclaw/references/TACTICS.md +2 -2
- package/src/behaviors/official-finite/do-task.ts +141 -0
- package/src/behaviors/official-finite/evade.ts +78 -0
- package/src/behaviors/official-finite/find-player.ts +50 -0
- package/src/behaviors/official-finite/follow-player.ts +70 -0
- package/src/behaviors/official-finite/go-to.ts +69 -0
- package/src/behaviors/official-finite/hide-temporarily.ts +77 -0
- package/src/behaviors/official-finite/hold-position.ts +48 -0
- package/src/behaviors/official-finite/hunt-player.ts +47 -0
- package/src/behaviors/official-finite/index.test.ts +202 -0
- package/src/behaviors/official-finite/index.ts +47 -0
- package/src/behaviors/official-finite/inspect-corpse.ts +64 -0
- package/src/behaviors/official-finite/patrol-area.ts +80 -0
- package/src/behaviors/official-finite/report-corpse.ts +73 -0
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +152 -0
- package/src/behaviors/official-finite/shared.ts +27 -0
- package/src/behaviors/official-finite/trigger-alarm.ts +53 -0
- package/src/channel/claude-channel-ipc-server.ts +295 -0
- package/src/channel/claude-channel-ipc.ts +152 -0
- package/src/channel/claude-channel-server.test.ts +202 -0
- package/src/channel/claude-channel-server.ts +221 -0
- package/src/cli.ts +4 -2
- package/src/commands/account.test.ts +17 -17
- package/src/commands/behavior.test.ts +158 -0
- package/src/commands/behavior.ts +443 -0
- package/src/commands/communication.test.ts +12 -0
- package/src/commands/communication.ts +6 -3
- package/src/commands/data.test.ts +1 -1
- package/src/commands/data.ts +1 -1
- package/src/commands/events-canonical-state.test.ts +221 -2
- package/src/commands/events.ts +205 -12
- package/src/commands/game/index.test.ts +172 -3
- package/src/commands/game/index.ts +69 -32
- package/src/commands/hub.test.ts +25 -14
- package/src/commands/hub.ts +15 -19
- package/src/commands/load.test.ts +228 -6
- package/src/commands/load.ts +102 -18
- package/src/commands/memory.ts +1 -1
- package/src/commands/peek.ts +1 -1
- package/src/commands/perception.test.ts +30 -1
- package/src/commands/perception.ts +15 -17
- package/src/commands/trigger.test.ts +140 -0
- package/src/commands/trigger.ts +314 -0
- package/src/lib/account-guidance.test.ts +4 -0
- package/src/lib/account-guidance.ts +1 -1
- package/src/lib/behavior-export.test.ts +282 -0
- package/src/lib/behavior-export.ts +514 -0
- package/src/lib/game-client.test.ts +4 -17
- package/src/lib/game-client.ts +1 -0
- package/src/lib/gameplay-config.test.ts +258 -37
- package/src/lib/gameplay-config.ts +175 -35
- package/src/lib/hub-install.test.ts +19 -41
- package/src/lib/hub-install.ts +10 -38
- package/src/lib/hub-reminder.ts +7 -9
- package/src/lib/init-command.ts +1 -1
- package/src/lib/official-resource-sync.test.ts +199 -0
- package/src/lib/official-resource-sync.ts +221 -0
- package/src/lib/perception-config.test.ts +9 -4
- package/src/lib/perception-config.ts +10 -13
- package/src/lib/perception-export.test.ts +145 -0
- package/src/lib/perception-export.ts +178 -0
- package/src/lib/trigger-config.test.ts +102 -0
- package/src/lib/trigger-config.ts +217 -0
- package/src/lib/user-data.test.ts +23 -6
- package/src/lib/user-data.ts +15 -123
- package/src/pipeline/canonical-event-presentation.test.ts +5 -5
- package/src/pipeline/canonical-event-presentation.ts +13 -5
- package/src/pipeline/event-format.test.ts +106 -3
- package/src/pipeline/event-format.ts +172 -4
- package/src/pipeline/event-hints.test.ts +57 -4
- package/src/pipeline/event-hints.ts +34 -8
- package/src/runtime/canonical-monitor.test.ts +2 -0
- package/src/runtime/canonical-monitor.ts +6 -2
- package/src/runtime/clawclaw/agent-event-policy.test.ts +23 -2
- package/src/runtime/clawclaw/agent-event-policy.ts +12 -5
- package/src/runtime/clawclaw/behavior-decision.test.ts +29 -0
- package/src/runtime/clawclaw/behavior-decision.ts +82 -0
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +175 -0
- package/src/runtime/clawclaw/behavior-input-fields.ts +270 -0
- package/src/runtime/clawclaw/behavior-input.test.ts +151 -0
- package/src/runtime/clawclaw/behavior-input.ts +70 -0
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +59 -0
- package/src/runtime/clawclaw/behavior-observation-memory.ts +142 -0
- package/src/runtime/clawclaw/behavior-read-api.test.ts +123 -0
- package/src/runtime/clawclaw/behavior-read-api.ts +158 -0
- package/src/runtime/clawclaw/{plugins/perception/visual-state-projector.ts → observation-frame-projector.ts} +44 -25
- package/src/runtime/clawclaw/owner.test.ts +187 -0
- package/src/runtime/clawclaw/owner.ts +431 -69
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +304 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +285 -41
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +82 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +135 -29
- package/src/runtime/clawclaw/plugins/assembly.ts +54 -28
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +468 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +40 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.ts +30 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +152 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +156 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +104 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-manifest.ts +173 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +182 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +223 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +157 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +848 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +1347 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +212 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +174 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +621 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +195 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/index.ts +11 -0
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +766 -0
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +283 -0
- package/src/runtime/clawclaw/plugins/{strategy/thread-strategy-executor.ts → behavior/thread-behavior-executor.ts} +109 -121
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +80 -0
- package/src/runtime/clawclaw/plugins/behavior-input-source.ts +247 -0
- package/src/runtime/clawclaw/plugins/{strategy → game-query}/context-capabilities.ts +1 -1
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +13 -10
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +26 -14
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +3 -1
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +239 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +100 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +346 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +230 -12
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +118 -90
- package/src/runtime/clawclaw/plugins/mailbox/consumer-ids.ts +5 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +1 -1
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +4 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +87 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +70 -12
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +94 -11
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1229 -345
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +479 -35
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -3
- package/src/runtime/clawclaw/plugins/perception/index.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +23 -13
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +11 -9
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +39 -38
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +92 -0
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +248 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +39 -37
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +22 -21
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +15 -9
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +3 -3
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +33 -18
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +22 -16
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +18 -12
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +14 -10
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +20 -14
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +49 -34
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +126 -20
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +24 -3
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +59 -46
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +27 -5
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +381 -49
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +267 -245
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +98 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +89 -16
- package/src/runtime/clawclaw/plugins/perception/perception-test-fixtures.ts +34 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +27 -15
- package/src/runtime/clawclaw/plugins/perception/replay.ts +10 -5
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +1 -107
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +7 -10
- package/src/runtime/clawclaw/plugins/plugin-api-version.ts +112 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +388 -559
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +56 -5
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +135 -26
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +249 -16
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +99 -2
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.ts +259 -0
- package/src/runtime/clawclaw/plugins/trigger/contracts.ts +97 -0
- package/src/runtime/clawclaw/plugins/trigger/index.ts +4 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +118 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +548 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +655 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +169 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.ts +457 -0
- package/src/runtime/clawclaw/runtime.ts +8 -0
- package/src/runtime/clawclaw/spatial-api.ts +76 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +46 -1
- package/src/runtime/clawclaw-event-catalog.ts +40 -3
- package/src/runtime/framework/capability-registry.test.ts +196 -55
- package/src/runtime/framework/capability-registry.ts +99 -17
- package/src/runtime/framework/contracts.ts +30 -4
- package/src/runtime/framework/control/control-scheduler.ts +13 -5
- package/src/runtime/framework/control/types.ts +11 -4
- package/src/runtime/framework/control-coordinator.test.ts +95 -80
- package/src/runtime/framework/events/event-delivery-service.ts +4 -2
- package/src/runtime/framework/events/event-ingress.test.ts +25 -0
- package/src/runtime/framework/events/event-ingress.ts +2 -1
- package/src/runtime/framework/events/event-repository.ts +24 -2
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +124 -8
- package/src/runtime/framework/events/memory-event-repository.ts +92 -28
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +604 -2
- package/src/runtime/framework/events/sqlite-event-repository.ts +531 -21
- package/src/runtime/framework/events/types.ts +24 -8
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +38 -1
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +233 -7
- package/src/runtime/framework/modules/runtime-module-loader.ts +69 -4
- package/src/runtime/framework/plugins/contracts.ts +12 -18
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +81 -71
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +38 -20
- package/src/runtime/framework/runtime.ts +20 -23
- package/src/runtime/host-monitor-rate-gate.test.ts +73 -0
- package/src/runtime/host-monitor-rate-gate.ts +123 -0
- package/src/runtime/mailbox-host-relay.test.ts +45 -0
- package/src/runtime/mailbox-host-relay.ts +25 -0
- package/src/runtime/observability/factory.ts +4 -4
- package/src/runtime/observability/observability.test.ts +25 -3
- package/src/runtime/observability/reporter.ts +1 -1
- package/src/runtime/observability/types.ts +2 -2
- package/src/runtime/owner-control.ts +10 -2
- package/src/runtime/runtime-logger.test.ts +1 -1
- package/src/runtime/runtime-logger.ts +4 -6
- package/src/runtime/runtime.test.ts +88 -22
- package/src/sdk/action.ts +2 -2
- package/src/sdk/behavior-plugin/index.test.ts +74 -0
- package/src/sdk/behavior-plugin/index.ts +335 -0
- package/src/sdk/behavior-toolkit/corpse-search.ts +87 -0
- package/src/sdk/behavior-toolkit/escape.ts +40 -0
- package/src/sdk/behavior-toolkit/index.ts +7 -0
- package/src/sdk/behavior-toolkit/kill-flow.ts +299 -0
- package/src/sdk/behavior-toolkit/model.ts +263 -0
- package/src/sdk/behavior-toolkit/move-gate.ts +52 -0
- package/src/sdk/behavior-toolkit/patrol.ts +53 -0
- package/src/sdk/behavior-toolkit/search.ts +102 -0
- package/src/sdk/index.test.ts +45 -0
- package/src/sdk/index.ts +67 -73
- package/src/sdk/module-input/index.test.ts +49 -0
- package/src/sdk/module-input/index.ts +229 -0
- package/src/sdk/perception-plugin/index.test.ts +2 -2
- package/src/sdk/perception-plugin/index.ts +51 -142
- package/src/sdk/perception-plugin/math.ts +107 -0
- package/src/sdk/trigger-plugin/index.test.ts +41 -0
- package/src/sdk/trigger-plugin/index.ts +128 -0
- package/src/strategies/avoid-lone.ts +21 -10
- package/src/strategies/avoid-players.ts +26 -16
- package/src/strategies/corpse-patrol.ts +25 -14
- package/src/strategies/crab-sabotage.ts +20 -9
- package/src/strategies/find-player.ts +33 -21
- package/src/strategies/game-utils.ts +1 -1
- package/src/strategies/goals/crab-sabotage-top.test.ts +145 -0
- package/src/strategies/goals/crab-sabotage-top.ts +32 -69
- package/src/strategies/hide.ts +25 -15
- package/src/strategies/kill-frenzy.ts +21 -10
- package/src/strategies/kill-lone.ts +27 -17
- package/src/strategies/kill-target.ts +33 -22
- package/src/strategies/lone-kill-task.ts +20 -9
- package/src/strategies/move-room.ts +29 -18
- package/src/strategies/official-long-behavior.test.ts +89 -0
- package/src/strategies/paradise-fish.ts +29 -18
- package/src/strategies/pathfind/astar-path.test.ts +127 -2
- package/src/strategies/pathfind/astar-path.ts +136 -26
- package/src/strategies/patrol.ts +21 -10
- package/src/strategies/player-targets.test.ts +10 -0
- package/src/strategies/player-targets.ts +13 -0
- package/src/strategies/report-patrol.ts +21 -10
- package/src/strategies/shrimp-memory.ts +30 -19
- package/src/strategies/social-task.ts +34 -23
- package/src/strategies/task-kill-report.ts +33 -22
- package/src/strategies/task-only.test.ts +99 -85
- package/src/strategies/task-only.ts +23 -12
- package/src/strategies/task-report.ts +25 -14
- package/src/strategies/types.ts +8 -8
- package/src/strategies/warrior-memory.ts +29 -19
- package/docs/runtime/strategy-runtime.md +0 -111
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +0 -502
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +0 -395
- package/skills/clawclaw/references/STRATEGIES.md +0 -76
- package/src/commands/strategy.test.ts +0 -209
- package/src/commands/strategy.ts +0 -242
- package/src/lib/strategy-export.test.ts +0 -406
- package/src/lib/strategy-export.ts +0 -381
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +0 -31
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +0 -177
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +0 -191
- package/src/runtime/clawclaw/plugins/strategy/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +0 -412
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +0 -80
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +0 -183
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +0 -29
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +0 -693
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +0 -57
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +0 -168
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +0 -2175
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +0 -1774
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +0 -153
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +0 -443
- package/src/sdk/strategy-plugin/index.test.ts +0 -958
- package/src/sdk/strategy-plugin/index.ts +0 -1350
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
OwnerControlResponse,
|
|
13
13
|
HostRelayOwnerControlType,
|
|
14
14
|
} from './owner-control.js';
|
|
15
|
+
import type { HostMonitorWriteGate } from './host-monitor-rate-gate.js';
|
|
15
16
|
|
|
16
17
|
export const MAILBOX_RELAY_REQUEST_TYPES = [
|
|
17
18
|
'mailbox_claim',
|
|
@@ -176,6 +177,13 @@ export interface StdoutMailboxRelayOptions {
|
|
|
176
177
|
emit: (payload: Record<string, unknown>) => Promise<void>;
|
|
177
178
|
/** Compose one Host wake-up from all items in a coalesced Mailbox claim. */
|
|
178
179
|
compose?: (payloads: readonly Record<string, unknown>[]) => Record<string, unknown>;
|
|
180
|
+
/**
|
|
181
|
+
* Mirror of the Host Monitor rate limiter. When this gate denies a write,
|
|
182
|
+
* the claimed batch is nack'ed (released back to pending) instead of emitted,
|
|
183
|
+
* so events are never dropped — they either reach the agent via a later
|
|
184
|
+
* stdout write, or are pulled by `ccl events`.
|
|
185
|
+
*/
|
|
186
|
+
rateGate?: HostMonitorWriteGate;
|
|
179
187
|
isOwnerAlive: () => boolean;
|
|
180
188
|
mode: MailboxDeliveryMode;
|
|
181
189
|
signal?: AbortSignal;
|
|
@@ -277,6 +285,23 @@ export async function runStdoutMailboxRelay(options: StdoutMailboxRelayOptions):
|
|
|
277
285
|
}
|
|
278
286
|
const claim = relayClaim(response.claim);
|
|
279
287
|
if (!claim) throw new Error('invalid_mailbox_claim');
|
|
288
|
+
// Mirror the Host Monitor token bucket: if the Host would suppress this
|
|
289
|
+
// write (bucket empty), do NOT emit. Nack the claim so the batch returns to
|
|
290
|
+
// pending — events stay durable and reach the agent on a later poll or via
|
|
291
|
+
// `ccl events`. Emitting anyway would be silently dropped by the Host.
|
|
292
|
+
if (options.rateGate && !options.rateGate.allow()) {
|
|
293
|
+
try {
|
|
294
|
+
await options.request('mailbox_nack', {
|
|
295
|
+
relay_id: relayId,
|
|
296
|
+
mode: options.mode,
|
|
297
|
+
claim_token: claim.claimToken,
|
|
298
|
+
retry_at_ms: Date.now() + pollMs,
|
|
299
|
+
error_code: 'host_rate_limited',
|
|
300
|
+
}, options.requestTimeoutMs);
|
|
301
|
+
} catch {}
|
|
302
|
+
await sleep(Math.max(25, Number(response.wait_ms) || pollMs), options.signal);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
280
305
|
try {
|
|
281
306
|
if (options.compose) {
|
|
282
307
|
await options.emit(options.compose(claim.items.map((item) => item.payload)));
|
|
@@ -26,12 +26,12 @@ export interface OwnerObservabilityRetention {
|
|
|
26
26
|
|
|
27
27
|
const DEFAULT_MAX_FILE_MIB = 10;
|
|
28
28
|
const DEFAULT_RETAINED_FILES = 5;
|
|
29
|
-
const
|
|
29
|
+
const MINIMUM_OPERATIONAL_RECORD = /^(?:runtime\.owner\.(?:started|stopped)|runtime\.scope\.switched|runtime\.mailbox\.monitor_batch_split)$/;
|
|
30
30
|
const FULL_REDUNDANT_DEBUG_RECORDS = new Set([
|
|
31
31
|
'runtime.input.accepted',
|
|
32
|
-
'runtime.
|
|
32
|
+
'runtime.channel.ready_advanced',
|
|
33
33
|
'runtime.view.ready',
|
|
34
|
-
'
|
|
34
|
+
'behavior.decide.started',
|
|
35
35
|
]);
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -123,7 +123,7 @@ export function observabilityInputEnabled(
|
|
|
123
123
|
const severity = input.severity ?? (input.kind === 'error' ? 'error' : 'info');
|
|
124
124
|
if (level === 'telemetry') return severity !== 'debug';
|
|
125
125
|
return severity === 'error'
|
|
126
|
-
||
|
|
126
|
+
|| MINIMUM_OPERATIONAL_RECORD.test(input.name);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export function observabilityLogPath(runtimeStateDir: string): string {
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
observabilityLogPath,
|
|
17
17
|
} from './factory.js';
|
|
18
18
|
import { Runtime } from '../framework/runtime.js';
|
|
19
|
+
import { behaviorControllerSpec } from '../framework/capability-registry.js';
|
|
19
20
|
import { EventCatalog, MemoryEventRepository } from '../framework/events/index.js';
|
|
20
21
|
import { MemoryStateHistoryRepository } from '../framework/state/index.js';
|
|
21
22
|
|
|
@@ -66,6 +67,11 @@ describe('observability', () => {
|
|
|
66
67
|
severity: 'info',
|
|
67
68
|
name: 'runtime.owner.started',
|
|
68
69
|
})).toBe(true);
|
|
70
|
+
expect(observabilityInputEnabled('errors', {
|
|
71
|
+
kind: 'log',
|
|
72
|
+
severity: 'info',
|
|
73
|
+
name: 'runtime.mailbox.monitor_batch_split',
|
|
74
|
+
})).toBe(true);
|
|
69
75
|
expect(observabilityInputEnabled('errors', {
|
|
70
76
|
kind: 'log',
|
|
71
77
|
severity: 'info',
|
|
@@ -484,11 +490,23 @@ describe('observability', () => {
|
|
|
484
490
|
},
|
|
485
491
|
});
|
|
486
492
|
const scope = runtime.publicScope();
|
|
493
|
+
const behavior = {
|
|
494
|
+
kind: 'behavior' as const,
|
|
495
|
+
activationId: 'worker-1',
|
|
496
|
+
layer: 'long' as const,
|
|
497
|
+
activationGeneration: 1,
|
|
498
|
+
};
|
|
499
|
+
runtime.actions.controls.registerController(behaviorControllerSpec(behavior, {
|
|
500
|
+
scope: runtime.scope(),
|
|
501
|
+
domains: ['*'],
|
|
502
|
+
lifecycle: 'persistent',
|
|
503
|
+
ready: true,
|
|
504
|
+
}));
|
|
487
505
|
await runtime.performAction(
|
|
488
506
|
'test.action',
|
|
489
507
|
{ speech: 'must-not-be-logged' },
|
|
490
508
|
{ sessionId: scope.sessionId, segmentId: scope.segmentId },
|
|
491
|
-
|
|
509
|
+
behavior,
|
|
492
510
|
);
|
|
493
511
|
await runtime.performAction(
|
|
494
512
|
'test.action',
|
|
@@ -512,8 +530,12 @@ describe('observability', () => {
|
|
|
512
530
|
|
|
513
531
|
const actionRecord = sink.records.find((record) => record.name === 'runtime.action.completed');
|
|
514
532
|
expect(actionRecord).toMatchObject({
|
|
515
|
-
correlation: {
|
|
516
|
-
|
|
533
|
+
correlation: {
|
|
534
|
+
actionId: 'action-1',
|
|
535
|
+
behaviorActivationId: 'worker-1',
|
|
536
|
+
behaviorActivationGeneration: 1,
|
|
537
|
+
},
|
|
538
|
+
attributes: { capability: 'test.action', caller_kind: 'behavior', status: 'success' },
|
|
517
539
|
});
|
|
518
540
|
expect(JSON.stringify(actionRecord)).not.toContain('must-not-be-logged');
|
|
519
541
|
expect(JSON.stringify(sink.records)).not.toContain('account-secret');
|
|
@@ -11,7 +11,7 @@ export interface BufferedObservabilityReporterOptions {
|
|
|
11
11
|
flushIntervalMs?: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const CRITICAL_LIFECYCLE_RECORD = /^(?:runtime\.owner\.(?:started|stopped)|runtime\.scope\.switched|runtime\.persistence\.degraded|owner\.control\.(?:started|stopped)|
|
|
14
|
+
const CRITICAL_LIFECYCLE_RECORD = /^(?:runtime\.owner\.(?:started|stopped)|runtime\.scope\.switched|runtime\.persistence\.degraded|owner\.control\.(?:started|stopped)|behavior\.thread(?:_pool)?\.(?:started|stopped|retired|replacement_failed))$/;
|
|
15
15
|
|
|
16
16
|
function recordPriority(record: ObservabilityRecord): number {
|
|
17
17
|
if (
|
|
@@ -17,8 +17,8 @@ export interface ObservabilityCorrelation {
|
|
|
17
17
|
commandId?: string;
|
|
18
18
|
requestId?: string;
|
|
19
19
|
actionId?: string;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
behaviorActivationId?: string;
|
|
21
|
+
behaviorActivationGeneration?: number;
|
|
22
22
|
traceId?: string;
|
|
23
23
|
parentRecordId?: string;
|
|
24
24
|
}
|
|
@@ -32,7 +32,16 @@ export type MasterOwnerControlType =
|
|
|
32
32
|
| 'mailbox_nack'
|
|
33
33
|
| 'mailbox_events_prepare'
|
|
34
34
|
| 'mailbox_events_ack'
|
|
35
|
-
| 'mailbox_events_release'
|
|
35
|
+
| 'mailbox_events_release'
|
|
36
|
+
| 'behavior_start'
|
|
37
|
+
| 'behavior_status'
|
|
38
|
+
| 'behavior_cancel'
|
|
39
|
+
| 'behavior_fallback'
|
|
40
|
+
| 'behavior_idle'
|
|
41
|
+
| 'trigger_configure'
|
|
42
|
+
| 'intent_start'
|
|
43
|
+
| 'intent_status'
|
|
44
|
+
| 'intent_cancel';
|
|
36
45
|
|
|
37
46
|
export type HostRelayOwnerControlType =
|
|
38
47
|
| 'mailbox_claim'
|
|
@@ -173,7 +182,6 @@ export async function startOwnerControlServer(
|
|
|
173
182
|
respond(response);
|
|
174
183
|
return;
|
|
175
184
|
}
|
|
176
|
-
|
|
177
185
|
respond({ ok: false, error: 'invalid_token' });
|
|
178
186
|
} catch (err: any) {
|
|
179
187
|
respond({ ok: false, error: err?.message ?? String(err) });
|
|
@@ -12,7 +12,7 @@ afterEach(() => {
|
|
|
12
12
|
vi.restoreAllMocks();
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
describe('RuntimeLogger
|
|
15
|
+
describe('RuntimeLogger stdout isolation', () => {
|
|
16
16
|
it('keeps every runtime log level off stdout when console diagnostics are enabled', () => {
|
|
17
17
|
process.env.CLAWCLAW_RUNTIME_LOG_TO_CONSOLE = '1';
|
|
18
18
|
const rawStdout = vi.spyOn(process.stdout, 'write')
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Control via env var CLAWCLAW_LOG_LEVEL (default: DEBUG).
|
|
13
13
|
* Console output is disabled by default so game runtime diagnostics do not
|
|
14
|
-
* leak into
|
|
15
|
-
* diagnostics to stderr. Runtime logs must never write
|
|
16
|
-
* protocol stream.
|
|
14
|
+
* leak into machine-readable process output. Set CLAWCLAW_RUNTIME_LOG_TO_CONSOLE=1
|
|
15
|
+
* to print diagnostics to stderr. Runtime logs must never write to stdout.
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
export enum LogLevel {
|
|
@@ -96,9 +95,8 @@ export class RuntimeLogger {
|
|
|
96
95
|
if (!this.logToConsole) return;
|
|
97
96
|
const prefix = `[Runtime:${LEVEL_NAMES[level]}]`;
|
|
98
97
|
const line = `${prefix} ${tag} ${msg}`;
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
// corrupt one-record-per-line canonical Event delivery.
|
|
98
|
+
// Keep opt-in runtime diagnostics on stderr so stdout remains available for
|
|
99
|
+
// machine-readable process output.
|
|
102
100
|
console.error(line);
|
|
103
101
|
}
|
|
104
102
|
}
|
|
@@ -6,11 +6,15 @@ import {
|
|
|
6
6
|
} from './clawclaw/plugins/source/source-transports.js';
|
|
7
7
|
import type {
|
|
8
8
|
RuntimeInputBatch,
|
|
9
|
+
RuntimeEpochPlugin,
|
|
9
10
|
RuntimeSourceContext,
|
|
10
11
|
RuntimeSourcePlugin,
|
|
11
12
|
} from './framework/plugins/index.js';
|
|
12
13
|
import { MemoryRuntimeInputJournal } from './framework/plugins/index.js';
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_EVENT_CONSUMER_ID,
|
|
16
|
+
MemoryEventRepository,
|
|
17
|
+
} from './framework/events/index.js';
|
|
14
18
|
import {
|
|
15
19
|
MemoryStateHistoryRepository,
|
|
16
20
|
type StateHistoryRepository,
|
|
@@ -23,7 +27,6 @@ import {
|
|
|
23
27
|
createClawclawRuntime,
|
|
24
28
|
} from './clawclaw/runtime.js';
|
|
25
29
|
import { projectClawclawCurrentState } from './clawclaw/runtime-state.js';
|
|
26
|
-
import { ClawclawMailboxService } from './clawclaw/plugins/mailbox/mailbox-service.js';
|
|
27
30
|
|
|
28
31
|
interface TestInputMeta {
|
|
29
32
|
connectionId: string;
|
|
@@ -717,19 +720,19 @@ describe('Runtime', () => {
|
|
|
717
720
|
currentStateFromRuntimeState: (state) => state,
|
|
718
721
|
runtimeEpochPlugins: [{
|
|
719
722
|
kind: 'epoch',
|
|
720
|
-
id: 'clawclaw.
|
|
723
|
+
id: 'clawclaw.behavior',
|
|
721
724
|
version: '1',
|
|
722
|
-
produces: { states: ['
|
|
725
|
+
produces: { states: ['behavior.status'] },
|
|
723
726
|
update() {
|
|
724
727
|
updateCount += 1;
|
|
725
728
|
if (updateCount > 1) {
|
|
726
|
-
return { outcome: 'noop', reason: '
|
|
729
|
+
return { outcome: 'noop', reason: 'behavior_cadence_wait' };
|
|
727
730
|
}
|
|
728
731
|
return {
|
|
729
732
|
outcome: 'processed',
|
|
730
733
|
states: [{
|
|
731
|
-
topic: '
|
|
732
|
-
value: {
|
|
734
|
+
topic: 'behavior.status',
|
|
735
|
+
value: { running: true, behavior: 'task-only', status: { summary: 'Going to engine.' } },
|
|
733
736
|
}],
|
|
734
737
|
};
|
|
735
738
|
},
|
|
@@ -764,29 +767,29 @@ describe('Runtime', () => {
|
|
|
764
767
|
await runtime.flush();
|
|
765
768
|
|
|
766
769
|
const firstReady = await runtime.waitForEpochReadyView(first.epoch.epochSeq);
|
|
767
|
-
expect(firstReady.pluginStates['
|
|
768
|
-
pluginId: 'clawclaw.
|
|
769
|
-
value: {
|
|
770
|
+
expect(firstReady.pluginStates['behavior.status']).toMatchObject({
|
|
771
|
+
pluginId: 'clawclaw.behavior',
|
|
772
|
+
value: { running: true, behavior: 'task-only', status: { summary: 'Going to engine.' } },
|
|
770
773
|
updatedEpochSeq: 1,
|
|
771
774
|
updatedDomainTick: 100,
|
|
772
775
|
});
|
|
773
|
-
expect(firstReady.pluginOutcomes['clawclaw.
|
|
776
|
+
expect(firstReady.pluginOutcomes['clawclaw.behavior']).toMatchObject({
|
|
774
777
|
epochSeq: 1,
|
|
775
778
|
domainTick: 100,
|
|
776
779
|
outcome: 'processed',
|
|
777
780
|
});
|
|
778
781
|
|
|
779
782
|
const current = runtime.readReadyView();
|
|
780
|
-
expect(current.pluginStates['
|
|
783
|
+
expect(current.pluginStates['behavior.status']).toMatchObject({
|
|
781
784
|
updatedEpochSeq: 1,
|
|
782
785
|
updatedDomainTick: 100,
|
|
783
|
-
value: {
|
|
786
|
+
value: { running: true, behavior: 'task-only' },
|
|
784
787
|
});
|
|
785
|
-
expect(current.pluginOutcomes['clawclaw.
|
|
788
|
+
expect(current.pluginOutcomes['clawclaw.behavior']).toMatchObject({
|
|
786
789
|
epochSeq: 2,
|
|
787
790
|
domainTick: 105,
|
|
788
791
|
outcome: 'noop',
|
|
789
|
-
reason: '
|
|
792
|
+
reason: 'behavior_cadence_wait',
|
|
790
793
|
});
|
|
791
794
|
await runtime.activateSegment('game', 'game-2');
|
|
792
795
|
expect(runtime.readReadyView()).toMatchObject({
|
|
@@ -1422,6 +1425,44 @@ describe('Runtime', () => {
|
|
|
1422
1425
|
await runtime.close();
|
|
1423
1426
|
});
|
|
1424
1427
|
|
|
1428
|
+
it('lets enabled ACK adapters create ClawClaw delivery lanes on demand', async () => {
|
|
1429
|
+
const events = new MemoryEventRepository();
|
|
1430
|
+
const commit = vi.spyOn(events, 'commitEvent');
|
|
1431
|
+
const runtime = createClawclawRuntime({
|
|
1432
|
+
apiKey: 'mailbox-lanes-key',
|
|
1433
|
+
runtimeAccountId: 'acct_cccccccccccccccccccccccccccccccc',
|
|
1434
|
+
}, {
|
|
1435
|
+
eventRepository: events,
|
|
1436
|
+
stateHistoryRepository: new MemoryStateHistoryRepository<ClawclawPosition>(),
|
|
1437
|
+
durableStateSnapshot: false,
|
|
1438
|
+
initialSegment: { kind: 'game', identity: 'game-mailbox-lanes' },
|
|
1439
|
+
});
|
|
1440
|
+
const scope = runtime.scope();
|
|
1441
|
+
const connectionId = 'mailbox-lanes-ws';
|
|
1442
|
+
runtime.bindConnection(CLAWCLAW_GAME_WS_SOURCE.sourceId, connectionId);
|
|
1443
|
+
|
|
1444
|
+
await submitTestInput(runtime, testInputBatch(
|
|
1445
|
+
scope,
|
|
1446
|
+
CLAWCLAW_GAME_WS_SOURCE,
|
|
1447
|
+
'event',
|
|
1448
|
+
{ type: 'task_completed', task_name: 'wires' },
|
|
1449
|
+
{ connectionId, sourceSeq: 1, sourceEventId: 'mailbox-lanes-event' },
|
|
1450
|
+
));
|
|
1451
|
+
|
|
1452
|
+
const event = events.latestEventByType(scope.sessionId, 'task_completed');
|
|
1453
|
+
expect(event).not.toBeNull();
|
|
1454
|
+
const committed = commit.mock.calls.find(([request]) => request.event.eventId === event!.eventId);
|
|
1455
|
+
expect(committed?.[0].consumerIds).toEqual([]);
|
|
1456
|
+
|
|
1457
|
+
events.ensureDeliveries(scope.sessionId, 'local-agent:desktop');
|
|
1458
|
+
expect(events.delivery(event!.eventId, 'local-agent:desktop')).toMatchObject({
|
|
1459
|
+
consumerId: 'local-agent:desktop',
|
|
1460
|
+
detailState: 'pending',
|
|
1461
|
+
});
|
|
1462
|
+
|
|
1463
|
+
await runtime.close();
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1425
1466
|
it('resumes logical participation without restoring a physical connection', async () => {
|
|
1426
1467
|
const events = new MemoryEventRepository();
|
|
1427
1468
|
const history = new MemoryStateHistoryRepository<ClawclawPosition>();
|
|
@@ -1467,7 +1508,7 @@ describe('Runtime', () => {
|
|
|
1467
1508
|
await resumed.close();
|
|
1468
1509
|
});
|
|
1469
1510
|
|
|
1470
|
-
it('resumes an unsealed room game by current game id and keeps unread Events
|
|
1511
|
+
it('resumes an unsealed room game by current game id and keeps unread Events pending', async () => {
|
|
1471
1512
|
const events = new MemoryEventRepository();
|
|
1472
1513
|
const history = new MemoryStateHistoryRepository<ClawclawPosition>();
|
|
1473
1514
|
const first = new Runtime({
|
|
@@ -1514,12 +1555,14 @@ describe('Runtime', () => {
|
|
|
1514
1555
|
{ tick: 2, phase: 'wandering' },
|
|
1515
1556
|
{ connectionId: 'after-owner-restart', sourceSeq: 2 },
|
|
1516
1557
|
));
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1558
|
+
events.ensureDeliveries(resumed.scope().sessionId, DEFAULT_EVENT_CONSUMER_ID);
|
|
1559
|
+
expect(events.listEvents({
|
|
1560
|
+
sessionId: resumed.scope().sessionId,
|
|
1561
|
+
types: ['task_completed'],
|
|
1562
|
+
detailStates: ['pending'],
|
|
1563
|
+
}, DEFAULT_EVENT_CONSUMER_ID).map((row) => row.event)).toMatchObject([
|
|
1564
|
+
{ type: 'task_completed', payload: { task_name: 'wires' } },
|
|
1565
|
+
]);
|
|
1523
1566
|
|
|
1524
1567
|
await first.close();
|
|
1525
1568
|
await resumed.close();
|
|
@@ -1666,6 +1709,29 @@ describe('Runtime', () => {
|
|
|
1666
1709
|
await custom.close();
|
|
1667
1710
|
});
|
|
1668
1711
|
|
|
1712
|
+
it('freezes Behavior Event declarations into the catalog before building the plugin graph', async () => {
|
|
1713
|
+
const behaviorPlugin: RuntimeEpochPlugin<Record<string, any>> = {
|
|
1714
|
+
kind: 'epoch',
|
|
1715
|
+
id: 'test.behavior-events',
|
|
1716
|
+
version: '1',
|
|
1717
|
+
produces: { events: ['strategy.runtime_declared'] },
|
|
1718
|
+
update: () => ({ outcome: 'noop' }),
|
|
1719
|
+
};
|
|
1720
|
+
const runtime = createClawclawRuntime({
|
|
1721
|
+
apiKey: 'behavior-event-key',
|
|
1722
|
+
runtimeAccountId: 'acct_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
|
1723
|
+
}, {
|
|
1724
|
+
eventRepository: new MemoryEventRepository(),
|
|
1725
|
+
stateHistoryRepository: new MemoryStateHistoryRepository<ClawclawPosition>(),
|
|
1726
|
+
durableStateSnapshot: false,
|
|
1727
|
+
initialSegment: { kind: 'game', identity: 'game-behavior-event' },
|
|
1728
|
+
runtimeEpochPlugins: [behaviorPlugin],
|
|
1729
|
+
behaviorEventTypes: ['strategy.runtime_declared'],
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
await runtime.close();
|
|
1733
|
+
});
|
|
1734
|
+
|
|
1669
1735
|
it('keeps on-change room State fresh from connection liveness, not snapshot age', async () => {
|
|
1670
1736
|
const runtime = createClawclawRuntime({
|
|
1671
1737
|
apiKey: 'room-key',
|
package/src/sdk/action.ts
CHANGED
|
@@ -70,8 +70,8 @@ export class Action {
|
|
|
70
70
|
* @param text Words spoken (audible to nearby players).
|
|
71
71
|
* @param thinkingContent Optional spectator-visible reasoning.
|
|
72
72
|
* @param audioUrl Legacy owner/manual-command-only uploaded audio URL.
|
|
73
|
-
*
|
|
74
|
-
* the runtime rejects
|
|
73
|
+
* Behavior-originated actions must omit this parameter;
|
|
74
|
+
* the runtime rejects Behavior actions that contain `audio_url`.
|
|
75
75
|
*/
|
|
76
76
|
static speech(text: string, thinkingContent?: string, audioUrl?: string): Action {
|
|
77
77
|
const payload: Record<string, any> = { text };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { BEHAVIOR_PLUGIN_API_VERSION, ClawclawBehavior } from './index.js';
|
|
3
|
+
import type {
|
|
4
|
+
BehaviorInput,
|
|
5
|
+
BehaviorDecision,
|
|
6
|
+
BehaviorReadApi,
|
|
7
|
+
ClawclawBehaviorManifest,
|
|
8
|
+
GameAction,
|
|
9
|
+
} from './index.js';
|
|
10
|
+
|
|
11
|
+
describe('Behavior authoring contract', () => {
|
|
12
|
+
it('uses one typed effect-only Decision for continuous and finite Behavior', () => {
|
|
13
|
+
const action = { action: 'kill', target_seat: 3 } satisfies GameAction;
|
|
14
|
+
const continuous = {
|
|
15
|
+
actions: [action],
|
|
16
|
+
status: { activity: 'hunting', summary: '追踪 3 号玩家' },
|
|
17
|
+
events: [{ type: 'target_selected', payload: { seat: 3 } }],
|
|
18
|
+
} satisfies BehaviorDecision;
|
|
19
|
+
const finite = {
|
|
20
|
+
...continuous,
|
|
21
|
+
finish: { outcome: 'completed', reason: 'target_reached' },
|
|
22
|
+
} satisfies BehaviorDecision;
|
|
23
|
+
|
|
24
|
+
expect(finite.actions).toEqual([action]);
|
|
25
|
+
expect(finite.finish.outcome).toBe('completed');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('keeps every callback capability read-only by construction', () => {
|
|
29
|
+
const keys: readonly (keyof BehaviorReadApi)[] = ['spatial', 'navigation', 'observation'];
|
|
30
|
+
expect(keys).toEqual(['spatial', 'navigation', 'observation']);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('keeps meeting votes outside the Behavior Action contract', () => {
|
|
34
|
+
// @ts-expect-error vote remains a direct Agent/User command handled by ActionPlugin.
|
|
35
|
+
const vote = { action: 'vote', target_seat: 3 } satisfies GameAction;
|
|
36
|
+
expect(vote.action).toBe('vote');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('uses one class and manifest for long, short, and reflex Activations', async () => {
|
|
40
|
+
class ExampleBehavior extends ClawclawBehavior<{ readonly target: string }> {
|
|
41
|
+
static override readonly manifest = {
|
|
42
|
+
apiVersion: BEHAVIOR_PLUGIN_API_VERSION,
|
|
43
|
+
id: 'example',
|
|
44
|
+
name: 'Example',
|
|
45
|
+
description: 'One author surface for every activation layer.',
|
|
46
|
+
inputs: [{
|
|
47
|
+
id: 'target',
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Semantic target.',
|
|
50
|
+
required: true,
|
|
51
|
+
}],
|
|
52
|
+
runtime: { defaultMs: 5_000, deadlineOutcome: 'failed' },
|
|
53
|
+
} as const satisfies ClawclawBehaviorManifest;
|
|
54
|
+
|
|
55
|
+
override decide(input: BehaviorInput<{ readonly target: string }>) {
|
|
56
|
+
return {
|
|
57
|
+
status: { summary: `going to ${input.input.target}` },
|
|
58
|
+
finish: { outcome: 'completed' as const, reason: 'done' },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
expect(ExampleBehavior.manifest.apiVersion).toBe(3);
|
|
64
|
+
const decision = await new ExampleBehavior().decide({
|
|
65
|
+
epochId: 1,
|
|
66
|
+
scope: { sessionId: 's', segmentId: 'g' },
|
|
67
|
+
nowMs: 100,
|
|
68
|
+
gameState: { game_id: 'game', tick: 1 },
|
|
69
|
+
events: [],
|
|
70
|
+
input: { target: 'engine' },
|
|
71
|
+
});
|
|
72
|
+
expect(decision.finish?.reason).toBe('done');
|
|
73
|
+
});
|
|
74
|
+
});
|