@myclaw163/clawclaw-cli 0.10.11 → 0.10.13
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/bin/clawclaw-cli.mjs +15 -6
- package/bin/startup-trace.d.mts +9 -0
- package/bin/startup-trace.mjs +100 -0
- package/cli-runtime/assets/clawclaw-map.json +1782 -0
- package/cli-runtime/assets/clawclaw-spatial-facts.json +1383 -0
- package/cli-runtime/assets/clawclaw-spatial-model.txt +142 -0
- package/cli-runtime/channel/claude-channel-ipc-server.js +220 -0
- package/cli-runtime/channel/claude-channel-ipc.js +135 -0
- package/cli-runtime/channel/claude-channel-server.js +209 -0
- package/cli-runtime/cli.js +81 -0
- package/cli-runtime/commands/_schema.js +60 -0
- package/cli-runtime/commands/account.js +577 -0
- package/cli-runtime/commands/auth.js +140 -0
- package/cli-runtime/commands/behavior.js +422 -0
- package/cli-runtime/commands/capability.js +327 -0
- package/cli-runtime/commands/communication.js +339 -0
- package/cli-runtime/commands/competition.js +55 -0
- package/cli-runtime/commands/config.js +28 -0
- package/cli-runtime/commands/data.js +78 -0
- package/cli-runtime/commands/events.js +339 -0
- package/cli-runtime/commands/game/index.js +646 -0
- package/cli-runtime/commands/hub.js +152 -0
- package/cli-runtime/commands/load.js +22 -0
- package/cli-runtime/commands/memory.js +30 -0
- package/cli-runtime/commands/module-runtime-control.js +110 -0
- package/cli-runtime/commands/peek.js +38 -0
- package/cli-runtime/commands/perception.js +146 -0
- package/cli-runtime/commands/persona.js +165 -0
- package/cli-runtime/commands/prepare.js +878 -0
- package/cli-runtime/commands/setup/codex.js +244 -0
- package/cli-runtime/commands/setup/hermes.js +55 -0
- package/cli-runtime/commands/setup/index.js +15 -0
- package/cli-runtime/commands/setup/openclaw.js +103 -0
- package/cli-runtime/commands/skill.js +76 -0
- package/cli-runtime/commands/strategy.js +4 -0
- package/cli-runtime/commands/trigger.js +271 -0
- package/cli-runtime/commands/upgrade.js +112 -0
- package/cli-runtime/lib/account-guidance.js +97 -0
- package/cli-runtime/lib/agent-workspace-client.js +66 -0
- package/cli-runtime/lib/agent-workspace-runtime.js +174 -0
- package/cli-runtime/lib/agent-workspace-skills.js +453 -0
- package/cli-runtime/lib/agent-workspace-sync.js +812 -0
- package/cli-runtime/lib/auth.js +210 -0
- package/cli-runtime/lib/capability-cloud-presence.js +134 -0
- package/cli-runtime/lib/capability-cloud-refresh.js +263 -0
- package/cli-runtime/lib/capability-cloud-sync.js +385 -0
- package/cli-runtime/lib/capability-discovery.js +94 -0
- package/cli-runtime/lib/capability-load-diagnostics.js +121 -0
- package/cli-runtime/lib/capability-operation-name.js +24 -0
- package/cli-runtime/lib/capability-operation-rename.js +120 -0
- package/cli-runtime/lib/capability-selection.js +69 -0
- package/cli-runtime/lib/capability-workspace.js +214 -0
- package/cli-runtime/lib/command-error.js +25 -0
- package/cli-runtime/lib/command-meta.js +13 -0
- package/cli-runtime/lib/competition.js +77 -0
- package/cli-runtime/lib/custom-tts.js +363 -0
- package/cli-runtime/lib/desktop-auth.js +44 -0
- package/cli-runtime/lib/desktop-mode.js +12 -0
- package/cli-runtime/lib/diagnostics-config.js +82 -0
- package/cli-runtime/lib/game-client.js +602 -0
- package/cli-runtime/lib/game-context.js +117 -0
- package/cli-runtime/lib/gameplay-config.js +232 -0
- package/cli-runtime/lib/host-config-patcher.js +101 -0
- package/cli-runtime/lib/http-keepalive.js +15 -0
- package/cli-runtime/lib/http-transport.js +163 -0
- package/cli-runtime/lib/hub-client.js +292 -0
- package/cli-runtime/lib/hub-errors.js +51 -0
- package/cli-runtime/lib/hub-reminder.js +65 -0
- package/cli-runtime/lib/hub-unzip.js +52 -0
- package/cli-runtime/lib/init-command.js +160 -0
- package/cli-runtime/lib/load-context.js +97 -0
- package/cli-runtime/lib/load-startup-context.js +59 -0
- package/cli-runtime/lib/load-startup.js +23 -0
- package/cli-runtime/lib/lobby-host-context.js +70 -0
- package/cli-runtime/lib/match-state.js +61 -0
- package/cli-runtime/lib/normalize.js +28 -0
- package/cli-runtime/lib/package-skills.js +15 -0
- package/cli-runtime/lib/participation-leave.js +54 -0
- package/cli-runtime/lib/participation-status.js +73 -0
- package/cli-runtime/lib/perception-config.js +85 -0
- package/cli-runtime/lib/persona.js +157 -0
- package/cli-runtime/lib/room.js +108 -0
- package/cli-runtime/lib/runtime-cadence-config.js +18 -0
- package/cli-runtime/lib/server-registry.js +155 -0
- package/cli-runtime/lib/server-status.js +44 -0
- package/cli-runtime/lib/service-status.js +88 -0
- package/cli-runtime/lib/skill-host.js +246 -0
- package/cli-runtime/lib/skill-name-conflicts.js +89 -0
- package/cli-runtime/lib/skill-version.js +20 -0
- package/cli-runtime/lib/training-role.js +23 -0
- package/cli-runtime/lib/trigger-config.js +138 -0
- package/cli-runtime/lib/user-data.js +336 -0
- package/cli-runtime/lib/workspace-argv.js +35 -0
- package/cli-runtime/lib/workspace-runtime-lock.js +6 -0
- package/cli-runtime/lib/zip-store.js +78 -0
- package/cli-runtime/pipeline/canonical-event-presentation.js +32 -0
- package/cli-runtime/pipeline/event-format.js +921 -0
- package/cli-runtime/pipeline/event-hints.js +235 -0
- package/cli-runtime/pipeline/game-sync-event-normalization.js +228 -0
- package/cli-runtime/pipeline/player-projection.js +272 -0
- package/cli-runtime/pipeline/role-display.js +22 -0
- package/cli-runtime/runtime/auto-upgrade.js +30 -0
- package/cli-runtime/runtime/canonical-event-emitter.js +58 -0
- package/cli-runtime/runtime/canonical-monitor.js +332 -0
- package/cli-runtime/runtime/clawclaw/agent-ability-state.js +41 -0
- package/cli-runtime/runtime/clawclaw/agent-event-policy.js +58 -0
- package/cli-runtime/runtime/clawclaw/behavior-decision.js +84 -0
- package/cli-runtime/runtime/clawclaw/behavior-input-fields.js +212 -0
- package/cli-runtime/runtime/clawclaw/behavior-input.js +54 -0
- package/cli-runtime/runtime/clawclaw/behavior-observation-memory.js +106 -0
- package/cli-runtime/runtime/clawclaw/behavior-read-api.js +110 -0
- package/cli-runtime/runtime/clawclaw/behavior-reflex-control.js +97 -0
- package/cli-runtime/runtime/clawclaw/behavior-start-control.js +159 -0
- package/cli-runtime/runtime/clawclaw/index.js +3 -0
- package/cli-runtime/runtime/clawclaw/navigation/astar-path.js +244 -0
- package/cli-runtime/runtime/clawclaw/navigation/clawclaw-walkable.bin +0 -0
- package/cli-runtime/runtime/clawclaw/navigation/distance-field.js +136 -0
- package/cli-runtime/runtime/clawclaw/navigation/escape-planner.js +273 -0
- package/cli-runtime/runtime/clawclaw/navigation/hide-spots.js +31 -0
- package/cli-runtime/runtime/clawclaw/navigation/off-route-points.js +64 -0
- package/cli-runtime/runtime/clawclaw/navigation/walkable-grid.js +85 -0
- package/cli-runtime/runtime/clawclaw/notification-policy.js +59 -0
- package/cli-runtime/runtime/clawclaw/notification-turn.js +28 -0
- package/cli-runtime/runtime/clawclaw/notifications.js +65 -0
- package/cli-runtime/runtime/clawclaw/observation-frame-projector.js +94 -0
- package/cli-runtime/runtime/clawclaw/owner-lock-error.js +17 -0
- package/cli-runtime/runtime/clawclaw/owner-lock.js +219 -0
- package/cli-runtime/runtime/clawclaw/owner.js +1257 -0
- package/cli-runtime/runtime/clawclaw/perception-module-manifest.js +67 -0
- package/cli-runtime/runtime/clawclaw/perception-strategy-names.js +12 -0
- package/cli-runtime/runtime/clawclaw/persistence-compatibility.js +38 -0
- package/cli-runtime/runtime/clawclaw/plugins/action/action-plugin.js +604 -0
- package/cli-runtime/runtime/clawclaw/plugins/action/automated-action-normalization.js +67 -0
- package/cli-runtime/runtime/clawclaw/plugins/action/index.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/assembly.js +134 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/activation-manager.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-action.js +26 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.js +21 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +25 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-catalog.js +90 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-decision-history.js +60 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-manifest.js +136 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-module-loader.js +230 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-normalization.js +92 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-plugin.js +162 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-runner.js +20 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-source.js +493 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.js +28 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/control-driver.js +5 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/index.js +11 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/thread-behavior-executor.js +18 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior-input-source.js +233 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-plugin.js +25 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-rules.js +289 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/index.js +2 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/player-change-tracker.js +162 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-plugin.js +182 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-rules.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-runner.js +83 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.js +35 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.ts +33 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/state-change-rules.js +111 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/task-change-tracker.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/game-query/context-capabilities.js +10 -0
- package/cli-runtime/runtime/clawclaw/plugins/game-query/game-query-plugin.js +196 -0
- package/cli-runtime/runtime/clawclaw/plugins/game-query/index.js +2 -0
- package/cli-runtime/runtime/clawclaw/plugins/index.js +9 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.js +24 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.js +21 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.js +84 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-runtime-report-adapter.js +54 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.js +61 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/consumer-ids.js +10 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/desktop-event-socket.js +45 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/index.js +11 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-plugin.js +13 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-presentation.js +99 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-service.js +84 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/contracts.js +14 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/index.js +11 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/map-concurrent.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/module-input-boundary.js +64 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/module-runner.js +182 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/notification-content.js +47 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/official-module-ids.js +13 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.js +684 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.js +145 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +252 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-loader.js +78 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-output.js +15 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-plugin.js +144 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-runner.js +22 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.js +18 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.ts +19 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-plugin.js +1343 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-pool.js +522 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.js +161 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.ts +262 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-source.js +489 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-test-fixtures.js +31 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/replay.js +56 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/report-content.js +39 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/shared/math.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/spatial-facts.js +103 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/task-baseline.js +29 -0
- package/cli-runtime/runtime/clawclaw/plugins/plugin-api-version.js +89 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/game-transport.js +204 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/index.js +5 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/room-transport.js +399 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/source-plugin.js +2003 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/source-transports.js +26 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/types.js +0 -0
- package/cli-runtime/runtime/clawclaw/plugins/system-perception/rule-runner.js +90 -0
- package/cli-runtime/runtime/clawclaw/plugins/system-perception/sabotage-availability-rule.js +59 -0
- package/cli-runtime/runtime/clawclaw/plugins/system-perception/system-perceptions.js +241 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/contracts.js +12 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/index.js +4 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-module-loader.js +105 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-plugin.js +741 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-source.js +372 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-pool.js +378 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.js +118 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +168 -0
- package/cli-runtime/runtime/clawclaw/reaction-behavior-resolution.js +1 -0
- package/cli-runtime/runtime/clawclaw/reaction-manifest.js +62 -0
- package/cli-runtime/runtime/clawclaw/reminder-manifest.js +39 -0
- package/cli-runtime/runtime/clawclaw/runtime-cadence.js +28 -0
- package/cli-runtime/runtime/clawclaw/runtime-data-export.js +321 -0
- package/cli-runtime/runtime/clawclaw/runtime-state.js +51 -0
- package/cli-runtime/runtime/clawclaw/runtime.js +132 -0
- package/cli-runtime/runtime/clawclaw/spatial-api.js +48 -0
- package/cli-runtime/runtime/clawclaw/starting-owner-control.js +24 -0
- package/cli-runtime/runtime/clawclaw/strategy-memory-rpc.js +1 -0
- package/cli-runtime/runtime/clawclaw/strategy-memory.js +6 -0
- package/cli-runtime/runtime/clawclaw/task-choice-projection.js +72 -0
- package/cli-runtime/runtime/clawclaw-event-catalog.js +284 -0
- package/cli-runtime/runtime/clawclaw-position.js +0 -0
- package/cli-runtime/runtime/clawclaw-room-state.js +38 -0
- package/cli-runtime/runtime/framework/action-diagnostics.js +69 -0
- package/cli-runtime/runtime/framework/capability-registry.js +1 -0
- package/cli-runtime/runtime/framework/contracts.js +1 -0
- package/cli-runtime/runtime/framework/control/control-scheduler.js +1 -0
- package/cli-runtime/runtime/framework/control/domain-set.js +1 -0
- package/cli-runtime/runtime/framework/control/index.js +1 -0
- package/cli-runtime/runtime/framework/control/types.js +1 -0
- package/cli-runtime/runtime/framework/control-coordinator.js +1 -0
- package/cli-runtime/runtime/framework/events/event-catalog.js +1 -0
- package/cli-runtime/runtime/framework/events/event-delivery-service.js +1 -0
- package/cli-runtime/runtime/framework/events/event-ingress.js +1 -0
- package/cli-runtime/runtime/framework/events/event-repository.js +1 -0
- package/cli-runtime/runtime/framework/events/index.js +5 -0
- package/cli-runtime/runtime/framework/events/memory-event-repository.js +1 -0
- package/cli-runtime/runtime/framework/events/runtime-resume.js +1 -0
- package/cli-runtime/runtime/framework/events/sqlite-event-repository.js +6 -0
- package/cli-runtime/runtime/framework/events/test-helpers.js +56 -0
- package/cli-runtime/runtime/framework/events/types.js +1 -0
- package/cli-runtime/runtime/framework/index.js +7 -0
- package/cli-runtime/runtime/framework/load-node-sqlite.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/coalescer.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/host-notification-sink.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/identity.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/index.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/mailbox-dispatcher.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/mailbox-repository.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/notification-projector.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/types.js +1 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-loader.js +31 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-output.js +1 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -0
- package/cli-runtime/runtime/framework/participation-manager.js +1 -0
- package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.js +1 -0
- package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -0
- package/cli-runtime/runtime/framework/persistence/memory-first-persistence.js +9 -0
- package/cli-runtime/runtime/framework/plugins/contracts.js +1 -0
- package/cli-runtime/runtime/framework/plugins/index.js +1 -0
- package/cli-runtime/runtime/framework/plugins/runtime-event-identity.js +1 -0
- package/cli-runtime/runtime/framework/plugins/runtime-input-journal.js +1 -0
- package/cli-runtime/runtime/framework/plugins/runtime-plugin-scheduler.js +1 -0
- package/cli-runtime/runtime/framework/runtime.js +12 -0
- package/cli-runtime/runtime/framework/serial-task-queue.js +1 -0
- package/cli-runtime/runtime/framework/state/contracts.js +1 -0
- package/cli-runtime/runtime/framework/state/current-state-store.js +1 -0
- package/cli-runtime/runtime/framework/state/durable-agent-state-snapshot.js +1 -0
- package/cli-runtime/runtime/framework/state/freshness.js +1 -0
- package/cli-runtime/runtime/framework/state/history/contracts.js +1 -0
- package/cli-runtime/runtime/framework/state/history/history-writer.js +1 -0
- package/cli-runtime/runtime/framework/state/history/memory-state-history-repository.js +1 -0
- package/cli-runtime/runtime/framework/state/history/sqlite-state-history-repository.js +1 -0
- package/cli-runtime/runtime/framework/state/history/trajectory-projector.js +1 -0
- package/cli-runtime/runtime/framework/state/index.js +1 -0
- package/cli-runtime/runtime/framework/state/state-ingress.js +1 -0
- package/cli-runtime/runtime/framework/state/state-provider.js +1 -0
- package/cli-runtime/runtime/framework/state/types.js +1 -0
- package/cli-runtime/runtime/game-sync-ingress-protocol.js +0 -0
- package/cli-runtime/runtime/game-sync-ingress-worker.js +310 -0
- package/cli-runtime/runtime/game-sync-ingress-worker.ts +274 -0
- package/cli-runtime/runtime/game-sync-protocol.js +278 -0
- package/cli-runtime/runtime/host-monitor-rate-gate.js +1 -0
- package/cli-runtime/runtime/mailbox-host-relay.js +1 -0
- package/cli-runtime/runtime/observability/detail-capture.js +35 -0
- package/cli-runtime/runtime/observability/factory.js +137 -0
- package/cli-runtime/runtime/observability/index.js +6 -0
- package/cli-runtime/runtime/observability/process-timing.js +1 -0
- package/cli-runtime/runtime/observability/recorder.js +1 -0
- package/cli-runtime/runtime/observability/redaction.js +1 -0
- package/cli-runtime/runtime/observability/reporter.js +1 -0
- package/cli-runtime/runtime/observability/sinks.js +1 -0
- package/cli-runtime/runtime/observability/types.js +1 -0
- package/cli-runtime/runtime/owner-control.js +59 -0
- package/cli-runtime/runtime/parent-process-watch.js +1 -0
- package/cli-runtime/runtime/pending-event-handoff.js +48 -0
- package/cli-runtime/runtime/process-identity.js +45 -0
- package/cli-runtime/runtime/raw-ws-log.js +181 -0
- package/cli-runtime/runtime/runtime-logger.js +79 -0
- package/cli-runtime/runtime/threaded-ws-client.js +263 -0
- package/cli-runtime/runtime/ws-client.js +563 -0
- package/cli-runtime/sdk/action.js +133 -0
- package/cli-runtime/sdk/action.ts +160 -0
- package/cli-runtime/sdk/behavior-plugin/index.js +23 -0
- package/cli-runtime/sdk/behavior-plugin/index.ts +341 -0
- package/cli-runtime/sdk/behavior-toolkit/corpse-search.js +56 -0
- package/cli-runtime/sdk/behavior-toolkit/corpse-search.ts +87 -0
- package/cli-runtime/sdk/behavior-toolkit/escape.js +25 -0
- package/cli-runtime/sdk/behavior-toolkit/escape.ts +40 -0
- package/cli-runtime/sdk/behavior-toolkit/index.js +7 -0
- package/cli-runtime/sdk/behavior-toolkit/index.ts +7 -0
- package/cli-runtime/sdk/behavior-toolkit/kill-flow.js +239 -0
- package/cli-runtime/sdk/behavior-toolkit/kill-flow.ts +299 -0
- package/cli-runtime/sdk/behavior-toolkit/model.js +183 -0
- package/cli-runtime/sdk/behavior-toolkit/model.ts +265 -0
- package/cli-runtime/sdk/behavior-toolkit/move-gate.js +30 -0
- package/cli-runtime/sdk/behavior-toolkit/move-gate.ts +52 -0
- package/cli-runtime/sdk/behavior-toolkit/patrol.js +39 -0
- package/cli-runtime/sdk/behavior-toolkit/patrol.ts +53 -0
- package/cli-runtime/sdk/behavior-toolkit/search.js +81 -0
- package/cli-runtime/sdk/behavior-toolkit/search.ts +102 -0
- package/cli-runtime/sdk/index.js +78 -0
- package/cli-runtime/sdk/index.ts +136 -0
- package/cli-runtime/sdk/module-input/index.js +0 -0
- package/cli-runtime/sdk/module-input/index.ts +310 -0
- package/cli-runtime/sdk/perception-plugin/index.js +79 -0
- package/cli-runtime/sdk/perception-plugin/index.ts +251 -0
- package/cli-runtime/sdk/perception-plugin/lifecycle.js +18 -0
- package/cli-runtime/sdk/perception-plugin/lifecycle.ts +15 -0
- package/cli-runtime/sdk/perception-plugin/math.js +99 -0
- package/cli-runtime/sdk/perception-plugin/math.ts +107 -0
- package/cli-runtime/sdk/perception-plugin/module.js +4 -0
- package/cli-runtime/sdk/perception-plugin/module.ts +80 -0
- package/cli-runtime/sdk/perception-plugin/reaction.js +6 -0
- package/cli-runtime/sdk/perception-plugin/reaction.ts +79 -0
- package/cli-runtime/sdk/perception-plugin/reminder-rules.js +131 -0
- package/cli-runtime/sdk/perception-plugin/reminder-rules.ts +89 -0
- package/cli-runtime/sdk/perception-plugin/reminder.js +8 -0
- package/cli-runtime/sdk/perception-plugin/reminder.ts +68 -0
- package/cli-runtime/sdk/perception-plugin/task-change-tracker.js +150 -0
- package/cli-runtime/sdk/perception-plugin/task-change-tracker.ts +258 -0
- package/cli-runtime/sdk/resource-metadata.js +27 -0
- package/cli-runtime/sdk/resource-metadata.ts +66 -0
- package/cli-runtime/sdk/strategy-memory.js +1 -0
- package/cli-runtime/sdk/strategy-memory.ts +1 -0
- package/cli-runtime/sdk/strategy-plugin/index.js +6 -0
- package/cli-runtime/sdk/strategy-plugin/index.ts +36 -0
- package/cli-runtime/sdk/task-availability.js +56 -0
- package/cli-runtime/sdk/task-availability.ts +70 -0
- package/cli-runtime/sdk/trigger-plugin/index.js +16 -0
- package/cli-runtime/sdk/trigger-plugin/index.ts +130 -0
- package/cli-runtime/sdk/types.js +25 -0
- package/cli-runtime/sdk/types.ts +165 -0
- package/cli-runtime/short-command/classifier.js +129 -0
- package/cli-runtime/short-command/index.js +7 -0
- package/cli-runtime/short-command/presenter.js +225 -0
- package/cli-runtime/short-command/process-io.js +13 -0
- package/cli-runtime/short-command/response-contract.js +24 -0
- package/cli-runtime/short-command/runner.js +94 -0
- package/cli-runtime/short-command/sensitive-data-filter.js +92 -0
- package/cli-runtime/short-command/transport-response.js +57 -0
- package/cli-runtime/short-command/types.js +0 -0
- package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/host.js +21 -29
- package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/sdk-sdk.js +76 -6
- package/docs/configuration.md +13 -0
- package/package.json +7 -4
- package/scripts/build-cli.mjs +34 -0
- package/skills/clawclaw/SKILL.md +1 -1
- package/skills/clawclaw/references/STREAM.md +1 -0
- package/skills/clawclaw-start/SKILL.md +1 -0
- package/skills/clawclaw-start/references/STARTUP.md +1 -0
- package/src/cli.ts +75 -77
- package/src/commands/auth.ts +3 -2
- package/src/commands/game/index.ts +33 -9
- package/src/commands/prepare.ts +34 -18
- package/src/lib/agent-workspace-client.ts +12 -9
- package/src/lib/game-client.ts +1 -1
- package/src/lib/http-transport.ts +17 -2
- package/src/lib/hub-client.ts +10 -7
- package/src/pipeline/event-format.ts +2 -0
- package/src/pipeline/event-hints.ts +6 -0
- package/src/runtime/clawclaw/notification-policy.ts +1 -1
- package/src/runtime/clawclaw/owner-lock.ts +3 -2
- package/src/runtime/clawclaw/owner.ts +36 -10
- package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +1 -1
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +19 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +1 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +33 -9
- package/src/runtime/clawclaw-event-catalog.ts +1 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +24 -29
- package/src/runtime/process-identity.ts +44 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { DetailCapture } from "../../../observability/detail-capture.js";
|
|
3
|
+
import { performance } from "node:perf_hooks";
|
|
4
|
+
import { ApiError } from "../../../../lib/http-transport.js";
|
|
5
|
+
import { actionFailureDiagnosticSeverity } from "../../../framework/action-diagnostics.js";
|
|
6
|
+
import { isClawclawRuntimeState } from "../../runtime-state.js";
|
|
7
|
+
import { sabotageTaskActionBlocked } from "../../task-choice-projection.js";
|
|
8
|
+
const CLAWCLAW_ACTION_PLUGIN_ID = "clawclaw.action";
|
|
9
|
+
const CLAWCLAW_ACTION_CAPABILITY = "clawclaw.action";
|
|
10
|
+
const CLAWCLAW_AGENT_CONTROL_LEASE_MS = 1e3;
|
|
11
|
+
function describeClawclawActionControl(request) {
|
|
12
|
+
const action = typeof request.action?.action === "string" ? request.action.action : void 0;
|
|
13
|
+
let domains;
|
|
14
|
+
switch (action) {
|
|
15
|
+
case "move":
|
|
16
|
+
case "task":
|
|
17
|
+
case "kill":
|
|
18
|
+
case "report":
|
|
19
|
+
domains = ["physical"];
|
|
20
|
+
break;
|
|
21
|
+
case "speech":
|
|
22
|
+
domains = ["communication"];
|
|
23
|
+
break;
|
|
24
|
+
case "vote":
|
|
25
|
+
domains = ["meeting_vote"];
|
|
26
|
+
break;
|
|
27
|
+
case "think":
|
|
28
|
+
case "strategy":
|
|
29
|
+
domains = [];
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
domains = ["*"];
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return { domains, agentLeaseMs: CLAWCLAW_AGENT_CONTROL_LEASE_MS };
|
|
36
|
+
}
|
|
37
|
+
function cleanActionResponseValue(value) {
|
|
38
|
+
return value === void 0 ? void 0 : structuredClone(value);
|
|
39
|
+
}
|
|
40
|
+
function backendError(error) {
|
|
41
|
+
if (error instanceof ApiError) {
|
|
42
|
+
const parsed = error.response?.body.kind === "json" ? error.response.body.value : (() => {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(error.body);
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
return parsed ?? {
|
|
50
|
+
error: { code: `HTTP_${error.status}`, message: error.body },
|
|
51
|
+
http_status: error.status
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
error: {
|
|
56
|
+
code: "ACTION_REQUEST_FAILED",
|
|
57
|
+
message: error instanceof Error ? error.message : String(error)
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function actionResultErrorCode(result) {
|
|
62
|
+
const outer = result.error && typeof result.error === "object" && !Array.isArray(result.error) ? result.error : {};
|
|
63
|
+
const nested = outer.error && typeof outer.error === "object" && !Array.isArray(outer.error) ? outer.error : {};
|
|
64
|
+
const code = nested.code ?? outer.code;
|
|
65
|
+
return typeof code === "string" && code.trim() ? code.trim() : void 0;
|
|
66
|
+
}
|
|
67
|
+
function actionResult(scope, actionId, status, value, error, metadata = {}) {
|
|
68
|
+
return {
|
|
69
|
+
scope,
|
|
70
|
+
actionId,
|
|
71
|
+
status,
|
|
72
|
+
...metadata,
|
|
73
|
+
...value === void 0 ? {} : { value: cleanActionResponseValue(value) },
|
|
74
|
+
...error === void 0 ? {} : { error: cleanActionResponseValue(error) }
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function deferredAtCommitBoundary(context) {
|
|
78
|
+
const authority = context.revalidate();
|
|
79
|
+
return authority.status === "deferred" ? authority.result : void 0;
|
|
80
|
+
}
|
|
81
|
+
function untilAborted(operation, signal) {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
const abort = () => reject(signal.reason ?? new Error("ACTION_CANCELLED"));
|
|
84
|
+
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
85
|
+
operation.then((value) => {
|
|
86
|
+
cleanup();
|
|
87
|
+
resolve(value);
|
|
88
|
+
}, (error) => {
|
|
89
|
+
cleanup();
|
|
90
|
+
reject(error);
|
|
91
|
+
});
|
|
92
|
+
if (signal.aborted) abort();
|
|
93
|
+
else signal.addEventListener("abort", abort, { once: true });
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function isAutomatedCaller(caller) {
|
|
97
|
+
return caller.kind === "behavior";
|
|
98
|
+
}
|
|
99
|
+
function elapsedMs(startedAtMs, endedAtMs = performance.now()) {
|
|
100
|
+
return Math.round(Math.max(0, endedAtMs - startedAtMs) * 1e3) / 1e3;
|
|
101
|
+
}
|
|
102
|
+
function automatedDiagnosticAttributes(request, admitted, caller) {
|
|
103
|
+
return {
|
|
104
|
+
action_id: admitted.actionId,
|
|
105
|
+
action_kind: typeof admitted.action.action === "string" ? admitted.action.action : "unknown",
|
|
106
|
+
route: admitted.route,
|
|
107
|
+
caller_kind: caller.kind,
|
|
108
|
+
behavior_id: request.behaviorOriginId,
|
|
109
|
+
behavior_activation_id: caller.activationId,
|
|
110
|
+
behavior_activation_generation: caller.activationGeneration,
|
|
111
|
+
behavior_layer: caller.layer,
|
|
112
|
+
...request.behaviorOriginEpochSeq === void 0 ? {} : {
|
|
113
|
+
epoch_seq: request.behaviorOriginEpochSeq,
|
|
114
|
+
origin_epoch_seq: request.behaviorOriginEpochSeq
|
|
115
|
+
},
|
|
116
|
+
...request.behaviorOriginTick === void 0 ? {} : { origin_tick: request.behaviorOriginTick }
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function prepareActionTarget(action) {
|
|
120
|
+
if (action.action !== "kill" && action.action !== "vote") return { action };
|
|
121
|
+
const seat = action.target_seat;
|
|
122
|
+
if (!Number.isInteger(seat) || seat < (action.action === "vote" ? 0 : 1) || seat > 10) {
|
|
123
|
+
return {
|
|
124
|
+
failure: {
|
|
125
|
+
code: "INVALID_ACTION_TARGET_SEAT",
|
|
126
|
+
message: "Kill requires target_seat 1-10; vote requires target_seat 0-10, where 0 skips."
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return { action };
|
|
131
|
+
}
|
|
132
|
+
function acknowledgedActionResult(scope, actionId, response) {
|
|
133
|
+
const root = response.body.kind === "json" && response.body.value && typeof response.body.value === "object" && !Array.isArray(response.body.value) ? response.body.value : null;
|
|
134
|
+
if (!root) {
|
|
135
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
136
|
+
error: {
|
|
137
|
+
code: "ACTION_PROTOCOL_ERROR",
|
|
138
|
+
message: response.body.kind === "empty" ? "The action endpoint returned an empty response." : "The action endpoint returned a non-object response."
|
|
139
|
+
},
|
|
140
|
+
http_status: response.status
|
|
141
|
+
}, { source: "protocol", actionOutcome: "unknown" });
|
|
142
|
+
}
|
|
143
|
+
const rejected = response.status < 200 || response.status >= 300 || root.success === false || root.ok === false;
|
|
144
|
+
return rejected ? actionResult(scope, actionId, "failure", void 0, root, {
|
|
145
|
+
source: "backend",
|
|
146
|
+
actionOutcome: "confirmed"
|
|
147
|
+
}) : actionResult(scope, actionId, "success", root, void 0, {
|
|
148
|
+
source: "backend",
|
|
149
|
+
actionOutcome: "confirmed"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
class ClawclawActionPlugin {
|
|
153
|
+
constructor(client) {
|
|
154
|
+
this.client = client;
|
|
155
|
+
}
|
|
156
|
+
client;
|
|
157
|
+
kind = "epoch";
|
|
158
|
+
id = CLAWCLAW_ACTION_PLUGIN_ID;
|
|
159
|
+
version = "1";
|
|
160
|
+
capabilities = { provides: [CLAWCLAW_ACTION_CAPABILITY] };
|
|
161
|
+
unregister;
|
|
162
|
+
stage = "matching";
|
|
163
|
+
connection = "disconnected";
|
|
164
|
+
noteAgentActivity;
|
|
165
|
+
diagnostic;
|
|
166
|
+
latestTaskGameState;
|
|
167
|
+
ownedSettlements = /* @__PURE__ */ new Map();
|
|
168
|
+
/**
|
|
169
|
+
* Automated callers may receive a queued receipt before HTTP settlement.
|
|
170
|
+
* Keep one provider-start FIFO per scope so a controller replacement or a
|
|
171
|
+
* Behavior handoff cannot let a later admitted Action reach the
|
|
172
|
+
* gameplay endpoint before an earlier one has started.
|
|
173
|
+
*/
|
|
174
|
+
automatedProviderStarts = /* @__PURE__ */ new Map();
|
|
175
|
+
automatedProviderQueueDepths = /* @__PURE__ */ new Map();
|
|
176
|
+
detailCapture;
|
|
177
|
+
attachAgentActivity(listener) {
|
|
178
|
+
this.noteAgentActivity = listener;
|
|
179
|
+
}
|
|
180
|
+
start(context) {
|
|
181
|
+
if (this.unregister) throw new Error("Clawclaw Action Plugin is already started.");
|
|
182
|
+
this.latestTaskGameState = void 0;
|
|
183
|
+
this.stage = context.currentSegment().kind === "room_lobby" ? "room" : "matching";
|
|
184
|
+
this.diagnostic = context.diagnostic;
|
|
185
|
+
this.detailCapture = new DetailCapture("actions", context.diagnostic);
|
|
186
|
+
this.unregister = context.capabilities.provideAction({
|
|
187
|
+
capability: CLAWCLAW_ACTION_CAPABILITY,
|
|
188
|
+
describeControl: describeClawclawActionControl,
|
|
189
|
+
perform: (request, scope, caller, actionContext) => this.perform(request, scope, caller, actionContext)
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
update(input) {
|
|
193
|
+
const scopeKey = this.automatedProviderQueueKey(input.epoch.scope);
|
|
194
|
+
if (this.latestTaskGameState?.scopeKey !== scopeKey) this.latestTaskGameState = void 0;
|
|
195
|
+
if (isClawclawRuntimeState(input.epoch.state)) {
|
|
196
|
+
this.stage = input.epoch.state.stage;
|
|
197
|
+
this.connection = input.epoch.state.connection;
|
|
198
|
+
if (input.epoch.state.game_snapshot.status === "fresh" || input.epoch.state.game_snapshot.status === "cached") {
|
|
199
|
+
this.rememberTaskGameState(input.epoch.scope, input.epoch.epochSeq, input.epoch.state.game_snapshot.state);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return { outcome: "noop", reason: "no_action_request" };
|
|
203
|
+
}
|
|
204
|
+
stop() {
|
|
205
|
+
this.unregister?.();
|
|
206
|
+
this.unregister = void 0;
|
|
207
|
+
this.diagnostic = void 0;
|
|
208
|
+
this.latestTaskGameState = void 0;
|
|
209
|
+
this.automatedProviderStarts.clear();
|
|
210
|
+
this.automatedProviderQueueDepths.clear();
|
|
211
|
+
}
|
|
212
|
+
automatedProviderQueueKey(scope) {
|
|
213
|
+
return `${scope.sessionId}:${scope.segmentId}`;
|
|
214
|
+
}
|
|
215
|
+
rememberTaskGameState(scope, epochSeq, state) {
|
|
216
|
+
const scopeKey = this.automatedProviderQueueKey(scope);
|
|
217
|
+
if (this.latestTaskGameState?.scopeKey === scopeKey && this.latestTaskGameState.epochSeq > epochSeq) return;
|
|
218
|
+
this.latestTaskGameState = { scopeKey, epochSeq, state: structuredClone(state) };
|
|
219
|
+
}
|
|
220
|
+
taskAdmissionRejection(request, scope, actionId, context) {
|
|
221
|
+
if (request.action.action !== "task") return void 0;
|
|
222
|
+
const scopeKey = this.automatedProviderQueueKey(scope);
|
|
223
|
+
if (this.latestTaskGameState?.scopeKey !== scopeKey) this.latestTaskGameState = void 0;
|
|
224
|
+
const latest = context.latestAcceptedState();
|
|
225
|
+
const runtimeState = latest?.state;
|
|
226
|
+
let game;
|
|
227
|
+
if (isClawclawRuntimeState(runtimeState)) {
|
|
228
|
+
if (runtimeState.game_snapshot.status === "fresh" || runtimeState.game_snapshot.status === "cached") {
|
|
229
|
+
game = runtimeState.game_snapshot.state;
|
|
230
|
+
this.rememberTaskGameState(scope, latest.epochSeq, game);
|
|
231
|
+
} else if (runtimeState.game_snapshot.status === "not_updated" && runtimeState.connection === "connected") {
|
|
232
|
+
game = this.latestTaskGameState?.state;
|
|
233
|
+
}
|
|
234
|
+
if (runtimeState.connection !== "connected") game = void 0;
|
|
235
|
+
} else if (runtimeState) {
|
|
236
|
+
game = runtimeState;
|
|
237
|
+
this.rememberTaskGameState(scope, latest.epochSeq, game);
|
|
238
|
+
}
|
|
239
|
+
if (!game && this.latestTaskGameState) {
|
|
240
|
+
game = { ...this.latestTaskGameState.state, crab_sabotage: void 0 };
|
|
241
|
+
}
|
|
242
|
+
if (!sabotageTaskActionBlocked(game, request.action.task_name)) return void 0;
|
|
243
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
244
|
+
error: {
|
|
245
|
+
code: "SABOTAGE_NOT_READY",
|
|
246
|
+
message: "The sabotage task requires the current shared sabotage state to be ready."
|
|
247
|
+
}
|
|
248
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
249
|
+
}
|
|
250
|
+
enqueueAutomatedSubmission(request, scope, caller, context, admitted) {
|
|
251
|
+
const queueKey = this.automatedProviderQueueKey(scope);
|
|
252
|
+
const previousStarted = this.automatedProviderStarts.get(queueKey) ?? Promise.resolve();
|
|
253
|
+
const queueDepthAtAdmission = (this.automatedProviderQueueDepths.get(queueKey) ?? 0) + 1;
|
|
254
|
+
this.automatedProviderQueueDepths.set(queueKey, queueDepthAtAdmission);
|
|
255
|
+
const timing = {
|
|
256
|
+
queuedAtMs: performance.now(),
|
|
257
|
+
queueDepthAtAdmission,
|
|
258
|
+
inFlightAtAdmission: this.ownedSettlements.size + 1
|
|
259
|
+
};
|
|
260
|
+
const diagnostic = this.diagnostic;
|
|
261
|
+
let markStarted;
|
|
262
|
+
const started = new Promise((resolve) => {
|
|
263
|
+
markStarted = resolve;
|
|
264
|
+
});
|
|
265
|
+
this.automatedProviderStarts.set(queueKey, started);
|
|
266
|
+
void started.finally(() => {
|
|
267
|
+
if (this.automatedProviderStarts.get(queueKey) === started) {
|
|
268
|
+
this.automatedProviderStarts.delete(queueKey);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
let queuePositionReleased = false;
|
|
272
|
+
const releaseQueuePosition = (endpointStarted) => {
|
|
273
|
+
if (queuePositionReleased) return;
|
|
274
|
+
queuePositionReleased = true;
|
|
275
|
+
const releasedAtMs = performance.now();
|
|
276
|
+
if (endpointStarted) timing.startedAtMs = releasedAtMs;
|
|
277
|
+
this.detailCapture?.emit(endpointStarted ? "queue_released" : "provider_skipped", () => ({
|
|
278
|
+
...automatedDiagnosticAttributes(request, admitted, caller),
|
|
279
|
+
action: admitted.action,
|
|
280
|
+
queue_wait_ms: elapsedMs(timing.queuedAtMs, releasedAtMs)
|
|
281
|
+
}));
|
|
282
|
+
const remainingQueueDepth = Math.max(
|
|
283
|
+
0,
|
|
284
|
+
(this.automatedProviderQueueDepths.get(queueKey) ?? 1) - 1
|
|
285
|
+
);
|
|
286
|
+
if (remainingQueueDepth === 0) this.automatedProviderQueueDepths.delete(queueKey);
|
|
287
|
+
else this.automatedProviderQueueDepths.set(queueKey, remainingQueueDepth);
|
|
288
|
+
this.emitDiagnostic(
|
|
289
|
+
endpointStarted ? "runtime.action.provider_started" : "runtime.action.provider_skipped",
|
|
290
|
+
{
|
|
291
|
+
...automatedDiagnosticAttributes(request, admitted, caller),
|
|
292
|
+
queue_wait_ms: elapsedMs(timing.queuedAtMs, releasedAtMs),
|
|
293
|
+
queue_depth_at_admission: timing.queueDepthAtAdmission,
|
|
294
|
+
in_flight_at_admission: timing.inFlightAtAdmission,
|
|
295
|
+
remaining_queue_depth: remainingQueueDepth
|
|
296
|
+
},
|
|
297
|
+
"debug",
|
|
298
|
+
diagnostic
|
|
299
|
+
);
|
|
300
|
+
const queueWaitMs = elapsedMs(timing.queuedAtMs, releasedAtMs);
|
|
301
|
+
if (endpointStarted && (queueWaitMs >= 20 || timing.queueDepthAtAdmission >= 2)) {
|
|
302
|
+
this.emitDiagnostic("runtime.action.provider_queue_delayed", {
|
|
303
|
+
...automatedDiagnosticAttributes(request, admitted, caller),
|
|
304
|
+
queue_wait_ms: queueWaitMs,
|
|
305
|
+
queue_depth_at_admission: timing.queueDepthAtAdmission,
|
|
306
|
+
in_flight_at_admission: timing.inFlightAtAdmission,
|
|
307
|
+
remaining_queue_depth: remainingQueueDepth,
|
|
308
|
+
budget_exceeded: queueWaitMs >= 100
|
|
309
|
+
}, "warn", diagnostic);
|
|
310
|
+
}
|
|
311
|
+
markStarted();
|
|
312
|
+
};
|
|
313
|
+
const settlement = previousStarted.catch(() => {
|
|
314
|
+
}).then(() => this.submitAdmitted(
|
|
315
|
+
request,
|
|
316
|
+
scope,
|
|
317
|
+
caller,
|
|
318
|
+
context,
|
|
319
|
+
admitted,
|
|
320
|
+
releaseQueuePosition
|
|
321
|
+
));
|
|
322
|
+
return { settlement, timing };
|
|
323
|
+
}
|
|
324
|
+
automationSafetyRejection(request, scope, actionId, caller, context) {
|
|
325
|
+
if (!isAutomatedCaller(caller)) return void 0;
|
|
326
|
+
const originEpochSeq = request.behaviorOriginEpochSeq;
|
|
327
|
+
const actionSafetyGeneration = request.behaviorActionSafetyGeneration;
|
|
328
|
+
if (!Number.isInteger(originEpochSeq) || originEpochSeq <= 0 || !Number.isInteger(actionSafetyGeneration) || actionSafetyGeneration < 0 || !Number.isSafeInteger(request.behaviorActivationGeneration) || request.behaviorActivationGeneration <= 0) {
|
|
329
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
330
|
+
error: {
|
|
331
|
+
code: "BEHAVIOR_ACTION_PRECONDITION_MISSING",
|
|
332
|
+
message: "The Behavior Action is missing its Runtime safety precondition."
|
|
333
|
+
}
|
|
334
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
335
|
+
}
|
|
336
|
+
if (request.behaviorActivationGeneration !== caller.activationGeneration) {
|
|
337
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
338
|
+
error: {
|
|
339
|
+
code: "STALE_BEHAVIOR_ACTION",
|
|
340
|
+
message: "The Behavior Action belongs to another activation generation."
|
|
341
|
+
}
|
|
342
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
343
|
+
}
|
|
344
|
+
const latest = context.latestAcceptedState();
|
|
345
|
+
const state = latest?.state;
|
|
346
|
+
if (latest && latest.epochSeq >= originEpochSeq && isClawclawRuntimeState(state) && state.action_safety_generation === actionSafetyGeneration && state.connection === "connected" && state.stage === "game" && (state.game_snapshot.status !== "fresh" && state.game_snapshot.status !== "cached" || state.game_snapshot.state.phase === "wandering" && state.game_snapshot.state.you?.is_alive !== false)) return void 0;
|
|
347
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
348
|
+
error: {
|
|
349
|
+
code: "STALE_BEHAVIOR_ACTION",
|
|
350
|
+
message: "The automated Action was computed before the latest game safety boundary."
|
|
351
|
+
}
|
|
352
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
353
|
+
}
|
|
354
|
+
commitBoundaryRejection(request, scope, actionId, caller, context) {
|
|
355
|
+
const stale = this.automationSafetyRejection(request, scope, actionId, caller, context);
|
|
356
|
+
if (stale) return stale;
|
|
357
|
+
const taskRejected = this.taskAdmissionRejection(request, scope, actionId, context);
|
|
358
|
+
if (taskRejected) return taskRejected;
|
|
359
|
+
if (caller.kind === "behavior") {
|
|
360
|
+
return deferredAtCommitBoundary(context);
|
|
361
|
+
}
|
|
362
|
+
return deferredAtCommitBoundary(context);
|
|
363
|
+
}
|
|
364
|
+
perform(request, scope, caller, context) {
|
|
365
|
+
const actionId = randomUUID();
|
|
366
|
+
try {
|
|
367
|
+
if (caller.kind === "agent" || caller.kind === "user") this.noteAgentActivity?.();
|
|
368
|
+
const staleAtStart = this.automationSafetyRejection(request, scope, actionId, caller, context);
|
|
369
|
+
if (staleAtStart) return staleAtStart;
|
|
370
|
+
const action = { ...request.action };
|
|
371
|
+
if (action.action === "trigger_alarm") {
|
|
372
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
373
|
+
error: {
|
|
374
|
+
code: "TRIGGER_ALARM_REMOVED_USE_TASK",
|
|
375
|
+
message: "Crab sabotage emergencies now start when an assigned sabotage task completes."
|
|
376
|
+
}
|
|
377
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
378
|
+
}
|
|
379
|
+
const route = request.route === "auto" ? this.stage === "room" && action.action === "speech" ? "room_chat" : "game" : request.route ?? "game";
|
|
380
|
+
if (route === "game" && this.connection !== "connected") {
|
|
381
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
382
|
+
error: {
|
|
383
|
+
code: "GAME_SYNC_NOT_READY",
|
|
384
|
+
message: "GameSync snapshot/resume has not completed; retry after the next authoritative State."
|
|
385
|
+
}
|
|
386
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
387
|
+
}
|
|
388
|
+
if (route === "room_chat") {
|
|
389
|
+
if (action.action !== "speech" || typeof action.text !== "string") {
|
|
390
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
391
|
+
error: { code: "INVALID_ROOM_ACTION", message: "Room chat requires a speech action." }
|
|
392
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
const taskRejected = this.taskAdmissionRejection(request, scope, actionId, context);
|
|
396
|
+
if (taskRejected) return taskRejected;
|
|
397
|
+
const targetPreparation = prepareActionTarget(action);
|
|
398
|
+
if ("failure" in targetPreparation) {
|
|
399
|
+
return actionResult(scope, actionId, "failure", void 0, {
|
|
400
|
+
error: targetPreparation.failure
|
|
401
|
+
}, { source: "local", actionOutcome: "not_submitted" });
|
|
402
|
+
}
|
|
403
|
+
Object.assign(action, targetPreparation.action);
|
|
404
|
+
}
|
|
405
|
+
const admitted = { actionId, action, route };
|
|
406
|
+
if (!isAutomatedCaller(caller)) {
|
|
407
|
+
return this.submitAdmitted(request, scope, caller, context, admitted);
|
|
408
|
+
}
|
|
409
|
+
const queued = this.enqueueAutomatedSubmission(
|
|
410
|
+
request,
|
|
411
|
+
scope,
|
|
412
|
+
caller,
|
|
413
|
+
context,
|
|
414
|
+
admitted
|
|
415
|
+
);
|
|
416
|
+
this.emitDiagnostic("runtime.action.provider_queued", {
|
|
417
|
+
...automatedDiagnosticAttributes(request, admitted, caller),
|
|
418
|
+
queue_depth: queued.timing.queueDepthAtAdmission,
|
|
419
|
+
in_flight: queued.timing.inFlightAtAdmission
|
|
420
|
+
});
|
|
421
|
+
this.detailCapture?.emit("queued", () => ({
|
|
422
|
+
...automatedDiagnosticAttributes(request, admitted, caller),
|
|
423
|
+
action: admitted.action,
|
|
424
|
+
queue_depth: queued.timing.queueDepthAtAdmission
|
|
425
|
+
}));
|
|
426
|
+
const ownedSettlement = this.ownSettlement(
|
|
427
|
+
scope,
|
|
428
|
+
caller,
|
|
429
|
+
action,
|
|
430
|
+
actionId,
|
|
431
|
+
admitted.route,
|
|
432
|
+
request,
|
|
433
|
+
queued.settlement,
|
|
434
|
+
queued.timing
|
|
435
|
+
);
|
|
436
|
+
const dispatch = {
|
|
437
|
+
receipt: actionResult(scope, actionId, "success", {
|
|
438
|
+
accepted: true,
|
|
439
|
+
status: "queued"
|
|
440
|
+
}, void 0, { source: "local", actionOutcome: "unknown" }),
|
|
441
|
+
settled: ownedSettlement
|
|
442
|
+
};
|
|
443
|
+
return dispatch;
|
|
444
|
+
} catch (error) {
|
|
445
|
+
return actionResult(scope, actionId, "failure", void 0, backendError(error), {
|
|
446
|
+
source: "local",
|
|
447
|
+
actionOutcome: "not_submitted"
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
async submitAdmitted(request, scope, caller, context, admitted, markProviderStartedOrSkipped = () => {
|
|
452
|
+
}) {
|
|
453
|
+
let actionEndpointStarted = false;
|
|
454
|
+
const action = { ...admitted.action };
|
|
455
|
+
try {
|
|
456
|
+
context.signal.throwIfAborted();
|
|
457
|
+
if (request.audioFile) {
|
|
458
|
+
const uploaded = await untilAborted(this.client.uploadAudio(
|
|
459
|
+
request.audioFile.path,
|
|
460
|
+
void 0,
|
|
461
|
+
request.audioFile.contentType
|
|
462
|
+
), context.signal);
|
|
463
|
+
action.audio_url = uploaded.audio_url;
|
|
464
|
+
const rejected2 = this.commitBoundaryRejection(
|
|
465
|
+
request,
|
|
466
|
+
scope,
|
|
467
|
+
admitted.actionId,
|
|
468
|
+
caller,
|
|
469
|
+
context
|
|
470
|
+
);
|
|
471
|
+
if (rejected2) return rejected2;
|
|
472
|
+
}
|
|
473
|
+
if (admitted.route === "room_chat") {
|
|
474
|
+
const rejected2 = this.commitBoundaryRejection(
|
|
475
|
+
request,
|
|
476
|
+
scope,
|
|
477
|
+
admitted.actionId,
|
|
478
|
+
caller,
|
|
479
|
+
context
|
|
480
|
+
);
|
|
481
|
+
if (rejected2) return rejected2;
|
|
482
|
+
const pending2 = this.client.chatRoomConfirmed(action.text);
|
|
483
|
+
this.detailCapture?.emit("provider_started", () => ({
|
|
484
|
+
action_id: admitted.actionId,
|
|
485
|
+
action,
|
|
486
|
+
caller,
|
|
487
|
+
behavior_id: request.behaviorOriginId,
|
|
488
|
+
route: admitted.route
|
|
489
|
+
}));
|
|
490
|
+
actionEndpointStarted = true;
|
|
491
|
+
markProviderStartedOrSkipped(true);
|
|
492
|
+
return acknowledgedActionResult(
|
|
493
|
+
scope,
|
|
494
|
+
admitted.actionId,
|
|
495
|
+
await untilAborted(pending2, context.signal)
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
const preparedAction = await untilAborted(this.client.prepareActionForConfirmedSubmission(action), context.signal);
|
|
499
|
+
context.signal.throwIfAborted();
|
|
500
|
+
const rejected = this.commitBoundaryRejection(
|
|
501
|
+
request,
|
|
502
|
+
scope,
|
|
503
|
+
admitted.actionId,
|
|
504
|
+
caller,
|
|
505
|
+
context
|
|
506
|
+
);
|
|
507
|
+
if (rejected) return rejected;
|
|
508
|
+
const pending = this.client.submitPreparedActionConfirmed(preparedAction, context.signal);
|
|
509
|
+
this.detailCapture?.emit("provider_started", () => ({
|
|
510
|
+
action_id: admitted.actionId,
|
|
511
|
+
action: preparedAction,
|
|
512
|
+
caller,
|
|
513
|
+
behavior_id: request.behaviorOriginId,
|
|
514
|
+
origin_epoch_seq: request.behaviorOriginEpochSeq,
|
|
515
|
+
origin_tick: request.behaviorOriginTick,
|
|
516
|
+
route: admitted.route
|
|
517
|
+
}));
|
|
518
|
+
actionEndpointStarted = true;
|
|
519
|
+
markProviderStartedOrSkipped(true);
|
|
520
|
+
const response = await untilAborted(pending, context.signal);
|
|
521
|
+
return acknowledgedActionResult(scope, admitted.actionId, response);
|
|
522
|
+
} catch (error) {
|
|
523
|
+
if (context.signal.aborted) {
|
|
524
|
+
if (!actionEndpointStarted) {
|
|
525
|
+
const rejected = deferredAtCommitBoundary(context);
|
|
526
|
+
if (rejected) return rejected;
|
|
527
|
+
}
|
|
528
|
+
const reason = context.signal.reason;
|
|
529
|
+
const code = reason instanceof Error && ["GAME_ENDED", "ACTION_SCOPE_ENDED"].includes(reason.message) ? reason.message : "ACTION_CANCELLED";
|
|
530
|
+
return actionResult(scope, admitted.actionId, "failure", void 0, {
|
|
531
|
+
error: { code, message: actionEndpointStarted ? "Action wait cancelled; the backend execution outcome is unknown." : "Action cancelled before submission." }
|
|
532
|
+
}, { source: "local", actionOutcome: actionEndpointStarted ? "unknown" : "not_submitted" });
|
|
533
|
+
}
|
|
534
|
+
return actionResult(scope, admitted.actionId, "failure", void 0, backendError(error), {
|
|
535
|
+
source: error instanceof ApiError ? "backend" : "transport",
|
|
536
|
+
actionOutcome: actionEndpointStarted ? error instanceof ApiError ? "confirmed" : "unknown" : "not_submitted"
|
|
537
|
+
});
|
|
538
|
+
} finally {
|
|
539
|
+
markProviderStartedOrSkipped(false);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
ownSettlement(scope, caller, action, actionId, route, request, settlement, timing) {
|
|
543
|
+
const diagnostic = this.diagnostic;
|
|
544
|
+
const detailCapture = this.detailCapture;
|
|
545
|
+
const report = (result) => {
|
|
546
|
+
const settledAtMs = performance.now();
|
|
547
|
+
const errorCode = actionResultErrorCode(result);
|
|
548
|
+
detailCapture?.emit("provider_settled", () => ({
|
|
549
|
+
action_id: actionId,
|
|
550
|
+
action,
|
|
551
|
+
caller,
|
|
552
|
+
behavior_id: request.behaviorOriginId,
|
|
553
|
+
origin_epoch_seq: request.behaviorOriginEpochSeq,
|
|
554
|
+
origin_tick: request.behaviorOriginTick,
|
|
555
|
+
result,
|
|
556
|
+
total_duration_ms: elapsedMs(timing.queuedAtMs, settledAtMs)
|
|
557
|
+
}));
|
|
558
|
+
this.emitDiagnostic("runtime.action.provider_settled", {
|
|
559
|
+
...automatedDiagnosticAttributes(request, {
|
|
560
|
+
actionId,
|
|
561
|
+
action,
|
|
562
|
+
route
|
|
563
|
+
}, caller),
|
|
564
|
+
status: result.status,
|
|
565
|
+
...result.source ? { action_source: result.source } : {},
|
|
566
|
+
...result.actionOutcome ? { action_outcome: result.actionOutcome } : {},
|
|
567
|
+
...errorCode ? { error_code: errorCode } : {},
|
|
568
|
+
queue_depth_at_admission: timing.queueDepthAtAdmission,
|
|
569
|
+
in_flight_at_admission: timing.inFlightAtAdmission,
|
|
570
|
+
in_flight_at_settlement: this.ownedSettlements.size,
|
|
571
|
+
queue_wait_ms: timing.startedAtMs === void 0 ? elapsedMs(timing.queuedAtMs, settledAtMs) : elapsedMs(timing.queuedAtMs, timing.startedAtMs),
|
|
572
|
+
...timing.startedAtMs === void 0 ? {} : { provider_duration_ms: elapsedMs(timing.startedAtMs, settledAtMs) },
|
|
573
|
+
total_duration_ms: elapsedMs(timing.queuedAtMs, settledAtMs)
|
|
574
|
+
}, result.status === "failure" ? actionFailureDiagnosticSeverity(result) : "debug", diagnostic);
|
|
575
|
+
return result;
|
|
576
|
+
};
|
|
577
|
+
let owned;
|
|
578
|
+
owned = settlement.then(report, (error) => report(actionResult(
|
|
579
|
+
scope,
|
|
580
|
+
actionId,
|
|
581
|
+
"failure",
|
|
582
|
+
void 0,
|
|
583
|
+
backendError(error),
|
|
584
|
+
{ source: "transport", actionOutcome: "unknown" }
|
|
585
|
+
))).finally(() => {
|
|
586
|
+
if (this.ownedSettlements.get(actionId) === owned) this.ownedSettlements.delete(actionId);
|
|
587
|
+
});
|
|
588
|
+
this.ownedSettlements.set(actionId, owned);
|
|
589
|
+
return owned;
|
|
590
|
+
}
|
|
591
|
+
emitDiagnostic(name, attributes, severity = "debug", diagnostic = this.diagnostic) {
|
|
592
|
+
try {
|
|
593
|
+
diagnostic?.(name, attributes, severity);
|
|
594
|
+
} catch {
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
export {
|
|
599
|
+
CLAWCLAW_ACTION_CAPABILITY,
|
|
600
|
+
CLAWCLAW_ACTION_PLUGIN_ID,
|
|
601
|
+
CLAWCLAW_AGENT_CONTROL_LEASE_MS,
|
|
602
|
+
ClawclawActionPlugin,
|
|
603
|
+
describeClawclawActionControl
|
|
604
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const ACTION_FIELDS = Object.freeze({
|
|
2
|
+
move: ["action", "target", "target_x", "target_y", "stop_on_player", "thinking_content"],
|
|
3
|
+
kill: ["action", "target_seat", "thinking_content"],
|
|
4
|
+
speech: ["action", "text", "thinking_content"],
|
|
5
|
+
task: ["action", "task_name", "thinking_content"],
|
|
6
|
+
report: ["action", "thinking_content"],
|
|
7
|
+
think: ["action", "thinking_content"]
|
|
8
|
+
});
|
|
9
|
+
const ERRORS = Object.freeze({
|
|
10
|
+
unsupported: "unsupported_behavior_action",
|
|
11
|
+
fieldDenied: "behavior_action_field_denied",
|
|
12
|
+
invalid: "invalid_behavior_action",
|
|
13
|
+
move: "invalid_behavior_move",
|
|
14
|
+
target: "invalid_behavior_target",
|
|
15
|
+
speech: "invalid_behavior_speech",
|
|
16
|
+
task: "invalid_behavior_task"
|
|
17
|
+
});
|
|
18
|
+
function nonEmpty(value) {
|
|
19
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
20
|
+
}
|
|
21
|
+
function normalizeClawclawBehaviorActionPayload(value) {
|
|
22
|
+
const errors = ERRORS;
|
|
23
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
24
|
+
throw new Error(errors.invalid);
|
|
25
|
+
}
|
|
26
|
+
const record = value;
|
|
27
|
+
const actionType = record.action;
|
|
28
|
+
if (typeof actionType !== "string" || !ACTION_FIELDS[actionType]) {
|
|
29
|
+
throw new Error(errors.unsupported);
|
|
30
|
+
}
|
|
31
|
+
const allowed = new Set(ACTION_FIELDS[actionType]);
|
|
32
|
+
if (Object.keys(record).some((key) => !allowed.has(key))) {
|
|
33
|
+
throw new Error(errors.fieldDenied);
|
|
34
|
+
}
|
|
35
|
+
if (record.thinking_content !== void 0 && typeof record.thinking_content !== "string") {
|
|
36
|
+
throw new Error(errors.invalid);
|
|
37
|
+
}
|
|
38
|
+
switch (actionType) {
|
|
39
|
+
case "move": {
|
|
40
|
+
const room = nonEmpty(record.target);
|
|
41
|
+
const coordinates = Number.isFinite(record.target_x) && Number.isFinite(record.target_y);
|
|
42
|
+
if (room === coordinates) throw new Error(errors.move);
|
|
43
|
+
if (record.stop_on_player !== void 0 && typeof record.stop_on_player !== "boolean") {
|
|
44
|
+
throw new Error(errors.move);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "kill": {
|
|
49
|
+
const seat = record.target_seat;
|
|
50
|
+
const validSeat = typeof seat === "number" && Number.isInteger(seat) && seat >= 1 && seat <= 10;
|
|
51
|
+
if (!validSeat) throw new Error(errors.target);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case "speech":
|
|
55
|
+
if (!nonEmpty(record.text)) throw new Error(errors.speech);
|
|
56
|
+
break;
|
|
57
|
+
case "task":
|
|
58
|
+
if (record.task_name !== void 0 && !nonEmpty(record.task_name)) {
|
|
59
|
+
throw new Error(errors.task);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => allowed.has(key)));
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
normalizeClawclawBehaviorActionPayload
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./action-plugin.js";
|