@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,16 @@
|
|
|
1
|
+
const TRIGGER_PLUGIN_API_VERSION = 4;
|
|
2
|
+
const MAX_TRIGGER_RUNTIME_MS = 12e4;
|
|
3
|
+
import {
|
|
4
|
+
hasValidClawclawResourceLocalizations,
|
|
5
|
+
resolveClawclawResourceMetadata
|
|
6
|
+
} from "../resource-metadata.js";
|
|
7
|
+
class ClawclawTrigger {
|
|
8
|
+
static manifest;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
ClawclawTrigger,
|
|
12
|
+
MAX_TRIGGER_RUNTIME_MS,
|
|
13
|
+
TRIGGER_PLUGIN_API_VERSION,
|
|
14
|
+
hasValidClawclawResourceLocalizations,
|
|
15
|
+
resolveClawclawResourceMetadata
|
|
16
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BehaviorInputFieldSpec,
|
|
3
|
+
BehaviorReadApi,
|
|
4
|
+
} from '../behavior-plugin/index.js';
|
|
5
|
+
export type { StrategyMemory, StrategyMemoryValue } from '../strategy-memory.js';
|
|
6
|
+
import type {
|
|
7
|
+
GameEvent,
|
|
8
|
+
ObservationFrame,
|
|
9
|
+
} from '../module-input/index.js';
|
|
10
|
+
import type { ClawclawResourceLocalizations } from '../resource-metadata.js';
|
|
11
|
+
|
|
12
|
+
export const TRIGGER_PLUGIN_API_VERSION = 4 as const;
|
|
13
|
+
/** Hard upper bound for one Reflex activation, regardless of module or runtime override. */
|
|
14
|
+
export const MAX_TRIGGER_RUNTIME_MS = 120_000;
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
hasValidClawclawResourceLocalizations,
|
|
18
|
+
resolveClawclawResourceMetadata,
|
|
19
|
+
} from '../resource-metadata.js';
|
|
20
|
+
export type {
|
|
21
|
+
ClawclawLocalizedResourceText,
|
|
22
|
+
ClawclawResolvedResourceMetadata,
|
|
23
|
+
ClawclawResourceLocalizations,
|
|
24
|
+
ClawclawResourceMetadata,
|
|
25
|
+
} from '../resource-metadata.js';
|
|
26
|
+
export type {
|
|
27
|
+
BehaviorInputFieldSpec,
|
|
28
|
+
BehaviorReadApi,
|
|
29
|
+
} from '../behavior-plugin/index.js';
|
|
30
|
+
export type {
|
|
31
|
+
BehaviorScope,
|
|
32
|
+
GameEvent,
|
|
33
|
+
GameState,
|
|
34
|
+
KnownPlayer,
|
|
35
|
+
ObservationFrame,
|
|
36
|
+
PlayerRef,
|
|
37
|
+
Position,
|
|
38
|
+
VisualCorpse,
|
|
39
|
+
VisualObservation,
|
|
40
|
+
VisualPlayer,
|
|
41
|
+
VisualPosition,
|
|
42
|
+
VisibleCorpse,
|
|
43
|
+
VisiblePlayer,
|
|
44
|
+
} from '../module-input/index.js';
|
|
45
|
+
|
|
46
|
+
/** How a matched Trigger becomes eligible to fire again. */
|
|
47
|
+
export type TriggerRearm = 'after_clear' | 'after_cooldown';
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Statically readable description and safe defaults for one Trigger.
|
|
51
|
+
*
|
|
52
|
+
* `defaultReflexPriority` is only relative to other Reflex activations. It
|
|
53
|
+
* never changes the fixed Runtime control order of reflex > short > long.
|
|
54
|
+
*/
|
|
55
|
+
export interface ClawclawTriggerManifest {
|
|
56
|
+
readonly apiVersion: typeof TRIGGER_PLUGIN_API_VERSION;
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly description: string;
|
|
60
|
+
readonly localizations?: ClawclawResourceLocalizations;
|
|
61
|
+
/** Rule parameters delivered through TriggerInput.input. Every field needs a default. */
|
|
62
|
+
readonly inputs: readonly BehaviorInputFieldSpec[];
|
|
63
|
+
/** Backend-pushed Event types observed by this Trigger. Empty means frame-only. */
|
|
64
|
+
readonly consumes: readonly string[];
|
|
65
|
+
/** Default fixed Behavior binding; effective configuration may replace this binding. */
|
|
66
|
+
readonly defaultBehavior: string;
|
|
67
|
+
readonly defaultBehaviorInput: Readonly<Record<string, unknown>>;
|
|
68
|
+
/** Relative priority among Reflex activations only. */
|
|
69
|
+
readonly defaultReflexPriority: number;
|
|
70
|
+
readonly defaultCooldownMs: number;
|
|
71
|
+
readonly defaultRearm: TriggerRearm;
|
|
72
|
+
readonly defaultMaxRuntimeMs: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* One immutable observation frame, backend-pushed Runtime Events, and configured rule
|
|
77
|
+
* parameters. Perception and Trigger receive the same frame independently;
|
|
78
|
+
* `events` never contains output from any Runtime computation plugin.
|
|
79
|
+
*/
|
|
80
|
+
export interface TriggerInput<
|
|
81
|
+
TInput extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>,
|
|
82
|
+
> {
|
|
83
|
+
readonly cycle?: import('../module-input/index.js').ProcessingCycleInfo;
|
|
84
|
+
readonly frame: Readonly<ObservationFrame>;
|
|
85
|
+
readonly events: readonly Readonly<GameEvent>[];
|
|
86
|
+
readonly input: Readonly<TInput>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type TriggerResetReason =
|
|
90
|
+
| 'phase_changed'
|
|
91
|
+
| 'trajectory_gap'
|
|
92
|
+
| 'segment_ending'
|
|
93
|
+
| 'shutdown';
|
|
94
|
+
|
|
95
|
+
/** Read-only game queries plus private memory shared with the same resource's Behavior. */
|
|
96
|
+
export type TriggerReadApi = BehaviorReadApi;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* One rule match. The target Behavior and Reflex priority deliberately do not
|
|
100
|
+
* appear here: Runtime takes both from the effective, already-authorized
|
|
101
|
+
* Trigger configuration.
|
|
102
|
+
*/
|
|
103
|
+
export interface TriggerMatch {
|
|
104
|
+
readonly reason: string;
|
|
105
|
+
readonly evidence?: Readonly<Record<string, unknown>>;
|
|
106
|
+
/** Dynamic values merged over the configured default Behavior input. */
|
|
107
|
+
readonly behaviorInput?: Readonly<Record<string, unknown>>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Public authoring surface for one rule; game writes remain Behavior Actions. */
|
|
111
|
+
export abstract class ClawclawTrigger<
|
|
112
|
+
TInput extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>,
|
|
113
|
+
> {
|
|
114
|
+
static readonly manifest?: ClawclawTriggerManifest;
|
|
115
|
+
|
|
116
|
+
abstract evaluate(
|
|
117
|
+
input: Readonly<TriggerInput<TInput>>,
|
|
118
|
+
api: TriggerReadApi,
|
|
119
|
+
): TriggerMatch | void | Promise<TriggerMatch | void>;
|
|
120
|
+
|
|
121
|
+
/** Clears private cross-frame rule state at an observation boundary. */
|
|
122
|
+
reset?(reason: TriggerResetReason): void | Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ClawclawTriggerClass<
|
|
126
|
+
TInput extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>,
|
|
127
|
+
> {
|
|
128
|
+
readonly manifest?: ClawclawTriggerManifest;
|
|
129
|
+
new(): ClawclawTrigger<TInput>;
|
|
130
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var ActionErrorCode = /* @__PURE__ */ ((ActionErrorCode2) => {
|
|
2
|
+
ActionErrorCode2["TASK_ALREADY_COMPLETED"] = "task_already_completed";
|
|
3
|
+
ActionErrorCode2["TASK_NOT_ASSIGNED"] = "task_not_assigned_to_you";
|
|
4
|
+
ActionErrorCode2["TASK_ALREADY_IN_PROGRESS"] = "task_already_in_progress";
|
|
5
|
+
ActionErrorCode2["NO_SABOTAGE_COMPLETED"] = "no_sabotage_completed";
|
|
6
|
+
ActionErrorCode2["ROLE_CANNOT_KILL"] = "role_cannot_kill";
|
|
7
|
+
ActionErrorCode2["EMERGENCY_ALREADY_ACTIVE"] = "emergency_already_active";
|
|
8
|
+
ActionErrorCode2["ON_COOLDOWN"] = "on_cooldown";
|
|
9
|
+
ActionErrorCode2["TARGET_UNREACHABLE"] = "target_unreachable_or_too_far";
|
|
10
|
+
ActionErrorCode2["PATH_NOT_FOUND"] = "path_not_found";
|
|
11
|
+
ActionErrorCode2["INVALID_POSITION"] = "invalid_position_blocked";
|
|
12
|
+
return ActionErrorCode2;
|
|
13
|
+
})(ActionErrorCode || {});
|
|
14
|
+
var WsConnectionState = /* @__PURE__ */ ((WsConnectionState2) => {
|
|
15
|
+
WsConnectionState2["Disconnected"] = "disconnected";
|
|
16
|
+
WsConnectionState2["Connecting"] = "connecting";
|
|
17
|
+
WsConnectionState2["Connected"] = "connected";
|
|
18
|
+
WsConnectionState2["Reconnecting"] = "reconnecting";
|
|
19
|
+
WsConnectionState2["Switching"] = "switching";
|
|
20
|
+
return WsConnectionState2;
|
|
21
|
+
})(WsConnectionState || {});
|
|
22
|
+
export {
|
|
23
|
+
ActionErrorCode,
|
|
24
|
+
WsConnectionState
|
|
25
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// ─── Spatial ───
|
|
2
|
+
|
|
3
|
+
export interface Position {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface MapRoom {
|
|
9
|
+
id: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ─── WebSocket Events ───
|
|
15
|
+
|
|
16
|
+
export interface GameEvent {
|
|
17
|
+
type: string;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ─── Action Error Codes ───
|
|
22
|
+
|
|
23
|
+
export enum ActionErrorCode {
|
|
24
|
+
TASK_ALREADY_COMPLETED = 'task_already_completed',
|
|
25
|
+
TASK_NOT_ASSIGNED = 'task_not_assigned_to_you',
|
|
26
|
+
TASK_ALREADY_IN_PROGRESS = 'task_already_in_progress',
|
|
27
|
+
NO_SABOTAGE_COMPLETED = 'no_sabotage_completed',
|
|
28
|
+
ROLE_CANNOT_KILL = 'role_cannot_kill',
|
|
29
|
+
EMERGENCY_ALREADY_ACTIVE = 'emergency_already_active',
|
|
30
|
+
/** 动作撞上服务端冷却;具体冷却语义由 action 类型决定。 */
|
|
31
|
+
ON_COOLDOWN = 'on_cooldown',
|
|
32
|
+
TARGET_UNREACHABLE = 'target_unreachable_or_too_far',
|
|
33
|
+
PATH_NOT_FOUND = 'path_not_found',
|
|
34
|
+
INVALID_POSITION = 'invalid_position_blocked',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ─── WebSocket Connection State ───
|
|
38
|
+
|
|
39
|
+
export enum WsConnectionState {
|
|
40
|
+
Disconnected = 'disconnected',
|
|
41
|
+
Connecting = 'connecting',
|
|
42
|
+
Connected = 'connected',
|
|
43
|
+
Reconnecting = 'reconnecting',
|
|
44
|
+
Switching = 'switching',
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ─── Phase ───
|
|
48
|
+
|
|
49
|
+
export type Phase = 'preparing' | 'wandering' | 'meeting' | 'game_over';
|
|
50
|
+
export type MeetingSubPhase = 'entry' | 'speech' | 'vote';
|
|
51
|
+
|
|
52
|
+
// ─── Game State ───
|
|
53
|
+
|
|
54
|
+
export interface PlayerSelf {
|
|
55
|
+
name: string;
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
room: string;
|
|
59
|
+
seat?: number;
|
|
60
|
+
role: string;
|
|
61
|
+
faction: string;
|
|
62
|
+
is_alive: boolean;
|
|
63
|
+
kill_cooldown_secs?: number;
|
|
64
|
+
kills_remaining?: number | null;
|
|
65
|
+
currently_moving?: boolean;
|
|
66
|
+
remaining_secs?: number;
|
|
67
|
+
doing_task?: boolean;
|
|
68
|
+
task_name?: string;
|
|
69
|
+
crab_teammates?: Array<{ seat: number; name: string }>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PlayerInfo {
|
|
73
|
+
name: string;
|
|
74
|
+
seat?: number;
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
room: string;
|
|
78
|
+
distance?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface CorpseInfo {
|
|
82
|
+
name: string;
|
|
83
|
+
seat?: number;
|
|
84
|
+
room: string;
|
|
85
|
+
distance?: number;
|
|
86
|
+
x?: number;
|
|
87
|
+
y?: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface MeetingState {
|
|
91
|
+
caller: string | null;
|
|
92
|
+
sub_phase: MeetingSubPhase;
|
|
93
|
+
alive_players: string[];
|
|
94
|
+
current_speaker?: string | null;
|
|
95
|
+
speeches_so_far?: Record<string, string>;
|
|
96
|
+
speeches?: Record<string, string>;
|
|
97
|
+
votes_submitted?: string[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface TaskInfo {
|
|
101
|
+
task_id: string;
|
|
102
|
+
task_name: string;
|
|
103
|
+
room: string;
|
|
104
|
+
status: string;
|
|
105
|
+
x?: number;
|
|
106
|
+
y?: number;
|
|
107
|
+
is_fake_shrimp?: boolean;
|
|
108
|
+
faction?: 'lobster' | 'crab';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 全局任务站点(map 的 all_task_locations):所有玩家共享、开局固定的任务点位置。与 `your_tasks` /
|
|
113
|
+
* `StrategyContext.taskData`(仅自己被分配、带 status)不同——这里只有位置,没有 status。
|
|
114
|
+
* faction='lobster' 是正常任务点,'crab' 是破坏点。
|
|
115
|
+
*/
|
|
116
|
+
export interface TaskLocation {
|
|
117
|
+
name: string;
|
|
118
|
+
room?: string;
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
faction?: 'lobster' | 'crab';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface EmergencyInfo extends TaskInfo {
|
|
125
|
+
remaining_secs: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface GameState {
|
|
129
|
+
phase: Phase;
|
|
130
|
+
tick: number;
|
|
131
|
+
you: PlayerSelf;
|
|
132
|
+
/** Omitted when GameSync has not supplied an authoritative current task list. */
|
|
133
|
+
your_tasks?: TaskInfo[];
|
|
134
|
+
players: PlayerInfo[];
|
|
135
|
+
corpses: CorpseInfo[];
|
|
136
|
+
emergency?: EmergencyInfo;
|
|
137
|
+
/** 服务端下发的「已知存活人数」:存活者 + 本玩家尚未目睹其死亡者之和。残局抢修紧急任务的门槛。 */
|
|
138
|
+
alive_count?: number;
|
|
139
|
+
task_progress?: { completed: number; goal: number };
|
|
140
|
+
new_events?: Array<Record<string, any>>;
|
|
141
|
+
stale: boolean;
|
|
142
|
+
meeting?: MeetingState;
|
|
143
|
+
winner?: string | null;
|
|
144
|
+
win_reason?: string;
|
|
145
|
+
all_players?: Array<{ name: string; role: string; is_alive: boolean; seat: number }>;
|
|
146
|
+
settlement?: Record<string, any>;
|
|
147
|
+
game_id?: string;
|
|
148
|
+
last_ejected?: string | null;
|
|
149
|
+
last_votes?: Record<string, string>;
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ─── Review ───
|
|
154
|
+
|
|
155
|
+
export interface GameResult {
|
|
156
|
+
gameId: string;
|
|
157
|
+
won: boolean;
|
|
158
|
+
role: string;
|
|
159
|
+
faction: string;
|
|
160
|
+
winner: string;
|
|
161
|
+
winReason: string;
|
|
162
|
+
survivedToEnd: boolean;
|
|
163
|
+
totalTicks: number;
|
|
164
|
+
allPlayers: Array<{ name: string; role: string; is_alive: boolean; seat: number }>;
|
|
165
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isHttpSuccess
|
|
3
|
+
} from "./transport-response.js";
|
|
4
|
+
function isObjectRoot(value) {
|
|
5
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function valueAtPath(root, path) {
|
|
8
|
+
let current = root;
|
|
9
|
+
for (const part of path) {
|
|
10
|
+
if (typeof part === "number") {
|
|
11
|
+
if (!Array.isArray(current) || part < 0 || part >= current.length) {
|
|
12
|
+
return { exists: false, value: void 0 };
|
|
13
|
+
}
|
|
14
|
+
current = current[part];
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (!current || typeof current !== "object" || !Object.prototype.hasOwnProperty.call(current, part)) {
|
|
18
|
+
return { exists: false, value: void 0 };
|
|
19
|
+
}
|
|
20
|
+
current = current[part];
|
|
21
|
+
}
|
|
22
|
+
return { exists: true, value: current };
|
|
23
|
+
}
|
|
24
|
+
function matchesPredicate(actual, predicate) {
|
|
25
|
+
switch (predicate.operator) {
|
|
26
|
+
case "equals":
|
|
27
|
+
return actual.exists && Object.is(actual.value, predicate.value);
|
|
28
|
+
case "one_of":
|
|
29
|
+
return actual.exists && predicate.values.some((value) => Object.is(actual.value, value));
|
|
30
|
+
case "exists":
|
|
31
|
+
return actual.exists === (predicate.value ?? true);
|
|
32
|
+
case "truthy":
|
|
33
|
+
return actual.exists && !!actual.value;
|
|
34
|
+
case "falsy":
|
|
35
|
+
return actual.exists && !actual.value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function matchesCondition(root, condition) {
|
|
39
|
+
return matchesPredicate(valueAtPath(root, condition.path), condition.predicate);
|
|
40
|
+
}
|
|
41
|
+
function matchesRule(root, rule) {
|
|
42
|
+
const conditions = Array.isArray(rule.when) ? rule.when : [rule.when];
|
|
43
|
+
return rule.match === "any" ? conditions.some((condition) => matchesCondition(root, condition)) : conditions.every((condition) => matchesCondition(root, condition));
|
|
44
|
+
}
|
|
45
|
+
function missingRequiredPath(root, paths) {
|
|
46
|
+
return paths?.find((path) => !valueAtPath(root, path).exists);
|
|
47
|
+
}
|
|
48
|
+
function printablePath(path) {
|
|
49
|
+
return path.map((part, index) => typeof part === "number" ? `[${part}]` : `${index === 0 ? "" : "."}${part}`).join("");
|
|
50
|
+
}
|
|
51
|
+
class ResponseClassifier {
|
|
52
|
+
classify(response, contract) {
|
|
53
|
+
if (response.body.kind !== "json") {
|
|
54
|
+
return {
|
|
55
|
+
kind: "protocol_failure",
|
|
56
|
+
response,
|
|
57
|
+
reason: response.body.kind === "empty" ? "empty_response_body" : "non_json_response_body"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (!isObjectRoot(response.body.value)) {
|
|
61
|
+
return {
|
|
62
|
+
kind: "protocol_failure",
|
|
63
|
+
response,
|
|
64
|
+
reason: "json_root_must_be_object"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const root = response.body.value;
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(root, "_ccl")) {
|
|
69
|
+
return {
|
|
70
|
+
kind: "protocol_failure",
|
|
71
|
+
response,
|
|
72
|
+
reason: "reserved_field_conflict:_ccl"
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (!isHttpSuccess(response)) {
|
|
76
|
+
return { kind: "backend_failure", response, upstreamRoot: root };
|
|
77
|
+
}
|
|
78
|
+
const matched = contract.rules?.find((rule) => matchesRule(root, rule));
|
|
79
|
+
if (matched) {
|
|
80
|
+
if (matched.outcome === "failure") {
|
|
81
|
+
return {
|
|
82
|
+
kind: "backend_failure",
|
|
83
|
+
response,
|
|
84
|
+
upstreamRoot: root,
|
|
85
|
+
guidance: matched.guidance
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (matched.outcome === "partial") {
|
|
89
|
+
return {
|
|
90
|
+
kind: "partial",
|
|
91
|
+
response,
|
|
92
|
+
upstreamRoot: root,
|
|
93
|
+
guidance: matched.guidance
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const missing = missingRequiredPath(root, contract.requiredSuccessPaths);
|
|
97
|
+
if (missing) {
|
|
98
|
+
return {
|
|
99
|
+
kind: "protocol_failure",
|
|
100
|
+
response,
|
|
101
|
+
upstreamRoot: root,
|
|
102
|
+
reason: `missing_required_success_field:${printablePath(missing)}`
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return { kind: "success", response, upstreamRoot: root, guidance: matched.guidance };
|
|
106
|
+
}
|
|
107
|
+
if (contract.default2xxOutcome === "success") {
|
|
108
|
+
const missing = missingRequiredPath(root, contract.requiredSuccessPaths);
|
|
109
|
+
if (missing) {
|
|
110
|
+
return {
|
|
111
|
+
kind: "protocol_failure",
|
|
112
|
+
response,
|
|
113
|
+
upstreamRoot: root,
|
|
114
|
+
reason: `missing_required_success_field:${printablePath(missing)}`
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return { kind: "success", response, upstreamRoot: root };
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
kind: "protocol_failure",
|
|
121
|
+
response,
|
|
122
|
+
upstreamRoot: root,
|
|
123
|
+
reason: `unclassified_response:${contract.id}`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
ResponseClassifier
|
|
129
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { randomUUID } from "crypto";
|
|
2
|
+
import { SensitiveDataFilter } from "./sensitive-data-filter.js";
|
|
3
|
+
function cloneObject(value) {
|
|
4
|
+
return JSON.parse(JSON.stringify(value));
|
|
5
|
+
}
|
|
6
|
+
function guidanceFor(classifiedGuidance, overrides) {
|
|
7
|
+
return Object.prototype.hasOwnProperty.call(overrides, "guidance") ? overrides.guidance ?? null : classifiedGuidance ?? null;
|
|
8
|
+
}
|
|
9
|
+
function statusFor(classification) {
|
|
10
|
+
if (classification === "success") return "success";
|
|
11
|
+
if (classification === "partial") return "partial";
|
|
12
|
+
return "failure";
|
|
13
|
+
}
|
|
14
|
+
function sourceFor(classification) {
|
|
15
|
+
return classification === "protocol_failure" ? "protocol" : "backend";
|
|
16
|
+
}
|
|
17
|
+
class ShortCommandPresenter {
|
|
18
|
+
filter;
|
|
19
|
+
diagnosticIdFactory;
|
|
20
|
+
exitCodes;
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.filter = options.filter ?? new SensitiveDataFilter();
|
|
23
|
+
this.diagnosticIdFactory = options.diagnosticIdFactory ?? (() => `diag_${randomUUID()}`);
|
|
24
|
+
this.exitCodes = {
|
|
25
|
+
success: options.exitCodes?.success ?? 0,
|
|
26
|
+
partial: options.exitCodes?.partial ?? 2,
|
|
27
|
+
failure: options.exitCodes?.failure ?? 1
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
presentBackend(classified, context, overrides = {}) {
|
|
31
|
+
const status = statusFor(classified.kind);
|
|
32
|
+
let root = classified.upstreamRoot ? cloneObject(classified.upstreamRoot) : void 0;
|
|
33
|
+
if (classified.kind === "success" && root) {
|
|
34
|
+
if (overrides.projectSuccess) root = overrides.projectSuccess(cloneObject(root));
|
|
35
|
+
if (overrides.enhanceSuccess) {
|
|
36
|
+
root = { ...root, ...overrides.enhanceSuccess(cloneObject(root)) };
|
|
37
|
+
}
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(root, "_ccl")) {
|
|
39
|
+
return this.presentLocalFailure(
|
|
40
|
+
{
|
|
41
|
+
code: "RESERVED_FIELD_CONFLICT",
|
|
42
|
+
message: "The successful command projection used the reserved _ccl field."
|
|
43
|
+
},
|
|
44
|
+
"protocol",
|
|
45
|
+
context,
|
|
46
|
+
{ guidance: overrides.guidance }
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!root) {
|
|
51
|
+
const diagnosticId = context.diagnosticId ?? this.diagnosticIdFactory();
|
|
52
|
+
return this.presentLocalFailure(
|
|
53
|
+
{
|
|
54
|
+
code: "PROTOCOL_ERROR",
|
|
55
|
+
message: "The upstream response could not be represented safely."
|
|
56
|
+
},
|
|
57
|
+
"protocol",
|
|
58
|
+
{ ...context, diagnosticId },
|
|
59
|
+
{
|
|
60
|
+
...overrides,
|
|
61
|
+
guidance: guidanceFor(classified.guidance, overrides)
|
|
62
|
+
},
|
|
63
|
+
classified.reason
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
const filtered = this.filter.filter(root, {
|
|
67
|
+
status,
|
|
68
|
+
policy: context.descriptor.sensitivePolicy
|
|
69
|
+
});
|
|
70
|
+
const meta = this.buildMeta({
|
|
71
|
+
context,
|
|
72
|
+
status,
|
|
73
|
+
source: sourceFor(classified.kind),
|
|
74
|
+
filteredFields: filtered.filteredFields,
|
|
75
|
+
guidance: guidanceFor(classified.guidance, overrides),
|
|
76
|
+
httpStatus: classified.response.status,
|
|
77
|
+
requestId: classified.response.requestId,
|
|
78
|
+
reason: classified.reason,
|
|
79
|
+
overrides
|
|
80
|
+
});
|
|
81
|
+
return this.finish(filtered.value, meta, status);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Present an owner-adapted backend result without moving the upstream root.
|
|
85
|
+
* This is used when an owner ActionService has already classified a
|
|
86
|
+
* multi-process result and the CLI no longer owns the original Response.
|
|
87
|
+
*/
|
|
88
|
+
presentBackendOutcome(upstreamRoot, status, context, overrides = {}, response) {
|
|
89
|
+
if (Object.prototype.hasOwnProperty.call(upstreamRoot, "_ccl")) {
|
|
90
|
+
return this.presentLocalFailure(
|
|
91
|
+
{
|
|
92
|
+
code: "RESERVED_FIELD_CONFLICT",
|
|
93
|
+
message: "The backend result used the reserved _ccl field."
|
|
94
|
+
},
|
|
95
|
+
"protocol",
|
|
96
|
+
context
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
let root = cloneObject(upstreamRoot);
|
|
100
|
+
if (status === "success" && overrides.projectSuccess) root = overrides.projectSuccess(cloneObject(root));
|
|
101
|
+
if (status === "success" && overrides.enhanceSuccess) {
|
|
102
|
+
root = { ...root, ...overrides.enhanceSuccess(cloneObject(root)) };
|
|
103
|
+
}
|
|
104
|
+
if (Object.prototype.hasOwnProperty.call(root, "_ccl")) {
|
|
105
|
+
return this.presentLocalFailure(
|
|
106
|
+
{
|
|
107
|
+
code: "RESERVED_FIELD_CONFLICT",
|
|
108
|
+
message: "The successful command projection used the reserved _ccl field."
|
|
109
|
+
},
|
|
110
|
+
"protocol",
|
|
111
|
+
context
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const filtered = this.filter.filter(root, {
|
|
115
|
+
status,
|
|
116
|
+
policy: context.descriptor.sensitivePolicy
|
|
117
|
+
});
|
|
118
|
+
const meta = this.buildMeta({
|
|
119
|
+
context,
|
|
120
|
+
status,
|
|
121
|
+
source: "backend",
|
|
122
|
+
filteredFields: filtered.filteredFields,
|
|
123
|
+
guidance: overrides.guidance ?? null,
|
|
124
|
+
httpStatus: response?.status,
|
|
125
|
+
requestId: response?.requestId,
|
|
126
|
+
overrides
|
|
127
|
+
});
|
|
128
|
+
return this.finish(filtered.value, meta, status);
|
|
129
|
+
}
|
|
130
|
+
presentLocalSuccess(value, source, context, overrides = {}) {
|
|
131
|
+
return this.presentLocalOutcome(value, "success", source, context, overrides);
|
|
132
|
+
}
|
|
133
|
+
presentLocalOutcome(value, status, source, context, overrides = {}, reason) {
|
|
134
|
+
if (Object.prototype.hasOwnProperty.call(value, "_ccl")) {
|
|
135
|
+
return this.presentLocalFailure(
|
|
136
|
+
{
|
|
137
|
+
code: "RESERVED_FIELD_CONFLICT",
|
|
138
|
+
message: "The command result used the reserved _ccl field."
|
|
139
|
+
},
|
|
140
|
+
"protocol",
|
|
141
|
+
context
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
let projected = cloneObject(value);
|
|
145
|
+
if (status === "success" && overrides.projectSuccess) projected = overrides.projectSuccess(cloneObject(projected));
|
|
146
|
+
if (status === "success" && overrides.enhanceSuccess) {
|
|
147
|
+
projected = { ...projected, ...overrides.enhanceSuccess(cloneObject(projected)) };
|
|
148
|
+
}
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(projected, "_ccl")) {
|
|
150
|
+
return this.presentLocalFailure(
|
|
151
|
+
{
|
|
152
|
+
code: "RESERVED_FIELD_CONFLICT",
|
|
153
|
+
message: "The successful command projection used the reserved _ccl field."
|
|
154
|
+
},
|
|
155
|
+
"protocol",
|
|
156
|
+
context
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
const filtered = this.filter.filter(projected, {
|
|
160
|
+
status,
|
|
161
|
+
policy: context.descriptor.sensitivePolicy
|
|
162
|
+
});
|
|
163
|
+
const meta = this.buildMeta({
|
|
164
|
+
context,
|
|
165
|
+
status,
|
|
166
|
+
source,
|
|
167
|
+
filteredFields: filtered.filteredFields,
|
|
168
|
+
guidance: overrides.guidance ?? null,
|
|
169
|
+
reason,
|
|
170
|
+
overrides
|
|
171
|
+
});
|
|
172
|
+
return this.finish(filtered.value, meta, status);
|
|
173
|
+
}
|
|
174
|
+
presentLocalFailure(error, source, context, overrides = {}, reason) {
|
|
175
|
+
const root = {
|
|
176
|
+
success: false,
|
|
177
|
+
error: {
|
|
178
|
+
code: error.code,
|
|
179
|
+
message: error.message,
|
|
180
|
+
...error.details === void 0 ? {} : { details: error.details }
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const filtered = this.filter.filter(root, {
|
|
184
|
+
status: "failure",
|
|
185
|
+
policy: context.descriptor.sensitivePolicy
|
|
186
|
+
});
|
|
187
|
+
const meta = this.buildMeta({
|
|
188
|
+
context,
|
|
189
|
+
status: "failure",
|
|
190
|
+
source,
|
|
191
|
+
filteredFields: filtered.filteredFields,
|
|
192
|
+
guidance: overrides.guidance ?? null,
|
|
193
|
+
reason,
|
|
194
|
+
diagnosticId: context.diagnosticId,
|
|
195
|
+
overrides
|
|
196
|
+
});
|
|
197
|
+
return this.finish(filtered.value, meta, "failure");
|
|
198
|
+
}
|
|
199
|
+
buildMeta(input) {
|
|
200
|
+
return {
|
|
201
|
+
schema: "ccl.command-meta.v1",
|
|
202
|
+
command_id: input.context.commandId,
|
|
203
|
+
command: input.context.descriptor.command,
|
|
204
|
+
command_status: input.status,
|
|
205
|
+
source: input.source,
|
|
206
|
+
service: input.context.descriptor.service,
|
|
207
|
+
operation: input.context.descriptor.operation,
|
|
208
|
+
http_status: input.httpStatus,
|
|
209
|
+
request_id: input.requestId,
|
|
210
|
+
diagnostic_id: input.diagnosticId,
|
|
211
|
+
reason: input.reason,
|
|
212
|
+
failed_effect: input.overrides.failedEffect,
|
|
213
|
+
filtered_fields: input.filteredFields,
|
|
214
|
+
effects: input.overrides.effects,
|
|
215
|
+
guidance: input.guidance
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
finish(root, meta, status) {
|
|
219
|
+
const value = { ...root, _ccl: meta };
|
|
220
|
+
return { value, status, exitCode: this.exitCodes[status] };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
ShortCommandPresenter
|
|
225
|
+
};
|