@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,235 @@
|
|
|
1
|
+
import { isRoomMode, isTrainingRoomMode } from "../lib/room.js";
|
|
2
|
+
import { roleDisplayName } from "./role-display.js";
|
|
3
|
+
const CLAWCLAW_SOURCE_PLUGIN_ID = "clawclaw.source";
|
|
4
|
+
const CLAWCLAW_FLOW_PERCEPTION_PLUGIN_ID = "clawclaw.perception.system.flow";
|
|
5
|
+
const ROOM_GAME_OVER_HINT = "This room round has ended. Review the result with the user, wait for the room lifecycle to resume, and do not start normal matchmaking.";
|
|
6
|
+
function text(value, fallback = "?") {
|
|
7
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
8
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
9
|
+
return fallback;
|
|
10
|
+
}
|
|
11
|
+
function numberValue(value) {
|
|
12
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
13
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
14
|
+
const parsed = Number(value);
|
|
15
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
16
|
+
}
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
function nonEmptyString(value) {
|
|
20
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
21
|
+
}
|
|
22
|
+
function killerRoleSuffix(event) {
|
|
23
|
+
if (event.killer_kind === "system") return "";
|
|
24
|
+
const role = roleDisplayName(event.killer_role, "en");
|
|
25
|
+
return role ? ` (${role})` : "";
|
|
26
|
+
}
|
|
27
|
+
function isSelfKillerMurderWitnessed(event, summary) {
|
|
28
|
+
if (event.type !== "murder_witnessed") return false;
|
|
29
|
+
const killerSeat = firstNumber(event, ["killer_seat", "killer_player_seat"]);
|
|
30
|
+
const selfSeat = numberValue(
|
|
31
|
+
summary?.you?.player?.seat ?? summary?.you?.seat ?? summary?.my_seat
|
|
32
|
+
);
|
|
33
|
+
if (killerSeat !== void 0 && selfSeat !== void 0) return killerSeat === selfSeat;
|
|
34
|
+
const killerName = nonEmptyString(event.killer_name);
|
|
35
|
+
const selfName = nonEmptyString(summary?.you?.player?.name) ?? nonEmptyString(summary?.you?.name);
|
|
36
|
+
return killerName !== void 0 && selfName !== void 0 && killerName === selfName;
|
|
37
|
+
}
|
|
38
|
+
function firstString(event, keys, fallback = "?") {
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
const value = event[key];
|
|
41
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
42
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
43
|
+
}
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
function isRoomGameEvent(event, ctx) {
|
|
47
|
+
if (typeof event.game_mode === "string") return isRoomMode(event.game_mode);
|
|
48
|
+
return isRoomMode(ctx.summary?.game?.mode) || isRoomMode(ctx.summary?.game_mode);
|
|
49
|
+
}
|
|
50
|
+
function firstNumber(event, keys) {
|
|
51
|
+
for (const key of keys) {
|
|
52
|
+
const value = numberValue(event[key]);
|
|
53
|
+
if (value !== void 0) return value;
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
function optionalSeatPlayerLabel(name, seat) {
|
|
58
|
+
const resolved = numberValue(seat);
|
|
59
|
+
const displayName = text(name, "someone");
|
|
60
|
+
return resolved === void 0 ? displayName : `seat ${resolved} ${displayName}`;
|
|
61
|
+
}
|
|
62
|
+
function actorName(event, fallback = "someone") {
|
|
63
|
+
return text(event.actor_name ?? event.resolver_name ?? event.actor ?? event.player_name, fallback);
|
|
64
|
+
}
|
|
65
|
+
function coordPair(x, y) {
|
|
66
|
+
return `(${text(x, "?")}, ${text(y, "?")})`;
|
|
67
|
+
}
|
|
68
|
+
function roleAssignedHint(event) {
|
|
69
|
+
const role = text(event.role_display_name ?? event.role_display ?? event.role, "?");
|
|
70
|
+
const faction = text(event.faction, "?");
|
|
71
|
+
return `You are ${role} (${faction}). Tell your user your role, faction, win condition, and first plan.`;
|
|
72
|
+
}
|
|
73
|
+
function meetingBriefingHint(event) {
|
|
74
|
+
if (!event.meeting_caller_name && !Array.isArray(event.reported_corpses)) return void 0;
|
|
75
|
+
const callerName = event.meeting_caller_name || event.caller || "Someone";
|
|
76
|
+
const callerSeat = firstNumber(event, ["meeting_caller_seat", "caller_seat", "actor_seat"]);
|
|
77
|
+
const callerLabel = callerSeat === void 0 ? callerName : `seat ${callerSeat} ${callerName}`;
|
|
78
|
+
const corpses = Array.isArray(event.reported_corpses) ? event.reported_corpses.map((corpse) => corpse?.seat === void 0 ? text(corpse?.name, "someone") : `seat ${corpse.seat} ${text(corpse?.name, "someone")}`).filter(Boolean) : [];
|
|
79
|
+
let callContext = `${callerLabel} called this meeting`;
|
|
80
|
+
if (corpses.length === 1) {
|
|
81
|
+
callContext = `${callerLabel} called this meeting after reporting the body of ${corpses[0]}`;
|
|
82
|
+
} else if (corpses.length > 1) {
|
|
83
|
+
callContext = `${callerLabel} called this meeting after reporting the bodies of ${corpses.join(", ")}`;
|
|
84
|
+
}
|
|
85
|
+
const teammates = Array.isArray(event.crab_teammates) ? event.crab_teammates : [];
|
|
86
|
+
const teammateHint = teammates.length > 0 ? ` Your Crab teammate(s): ${teammates.map((teammate) => teammate?.seat === void 0 ? text(teammate?.name, "someone") : `seat ${teammate.seat} ${text(teammate?.name, "someone")}`).join(", ")}. Shield them, redirect heat, split suspicion, and control the vote.` : "";
|
|
87
|
+
return `Meeting started \u2014 ${callContext}.${teammateHint} Prepare fast \u2014 every sentence is accusation, defense, or misdirection under a timer.`;
|
|
88
|
+
}
|
|
89
|
+
const BACKEND_EVENT_HINT_FORMATTERS = Object.freeze({
|
|
90
|
+
service_status: (event) => {
|
|
91
|
+
const startsAt = text(event.maintenance?.starts_at, "the scheduled start time");
|
|
92
|
+
const endsAt = text(event.maintenance?.ends_at, "the scheduled end time");
|
|
93
|
+
const description = typeof event.maintenance?.description === "string" && event.maintenance.description.length > 0 ? ` Maintenance description: ${event.maintenance.description}` : "";
|
|
94
|
+
if (event.service_status === "maintenance_upcoming") {
|
|
95
|
+
return `Tell the user that maintenance is scheduled from ${startsAt} to ${endsAt}.${description} The current request succeeded and may continue; do not start an extra runtime.`;
|
|
96
|
+
}
|
|
97
|
+
if (event.service_status === "maintenance_active") {
|
|
98
|
+
return `Tell the user that the service is under maintenance until ${endsAt}.${description} Do not retry matchmaking, room creation, room joining, or room start before then; query server status before trying again.`;
|
|
99
|
+
}
|
|
100
|
+
return "The service is available again. Tell the user if they were waiting, but do not replay a previously blocked request unless they still want it.";
|
|
101
|
+
},
|
|
102
|
+
move_interrupted: (event) => {
|
|
103
|
+
const nearby = Array.isArray(event.nearby_players) ? event.nearby_players.map((player) => text(player?.name, "")).filter(Boolean).slice(0, 3) : [];
|
|
104
|
+
return nearby.length > 0 ? `Movement stopped after contact with ${nearby.join(", ")}. Decide whether to talk, follow, avoid, or change route.` : "Movement was interrupted. Read the current state before choosing a new action.";
|
|
105
|
+
},
|
|
106
|
+
game_started: (event) => {
|
|
107
|
+
const playerCount = numberValue(event.player_count);
|
|
108
|
+
const countText = playerCount === void 0 ? "Game started." : `Game started with ${playerCount} players.`;
|
|
109
|
+
return `${countText} Opening map, seat, role, and task details are included in the full Event delivery. The runtime is already attached; do not relaunch.`;
|
|
110
|
+
},
|
|
111
|
+
role_assigned: (event) => roleAssignedHint(event),
|
|
112
|
+
kill: (event) => `MURDER: ${text(event.actor_name, "someone")} butchered ${text(event.target_name, "someone")}. Blood is on the floor, one voice is gone, and the killer's side moves closer to victory.`,
|
|
113
|
+
killed: (event) => `YOU ARE DEAD: ${optionalSeatPlayerLabel(event.killer_name, firstNumber(event, ["killer_seat", "killer_player_seat"]))}${killerRoleSuffix(event)} removed you from play.`,
|
|
114
|
+
murder_witnessed: (event, ctx) => isSelfKillerMurderWitnessed(event, ctx.summary) ? "IGNORE AS WITNESS EVIDENCE: this event conflicts with the recipient identity and was downgraded. Do not infer any witness or observer from it; rely on the separate kill Event and current State." : `WITNESS: You saw ${text(event.killer_name, "someone")} kill ${text(event.target_name, "someone")}. This is hard evidence; survive, report, or weaponize it.`,
|
|
115
|
+
warrior_shrimp_self_destruct: (event) => `You executed ${text(event.target_name, "a teammate")}, but they were a fellow Lobster. Warrior Shrimp justice backfired \u2014 your own blade takes you down too.`,
|
|
116
|
+
body_dropped: (event) => `A body dropped near ${text(event.room, "your position")}. Treat it as fresh nearby danger.`,
|
|
117
|
+
corpse_spotted: (event) => `BODY FOUND: ${text(event.corpse_name, "someone")} at ${coordPair(event.corpse_x, event.corpse_y)} in ${firstString(event, ["corpse_room", "room"])}. This is leverage soaked in blood \u2014 report before the killer rewrites the room.`,
|
|
118
|
+
octopus_time_start: () => "\u26A0\uFE0F OCTOPUS TIME. At most three players remain; if the Octopus survives 60 seconds, it wins. Meetings are disabled, but Lobster task completion or an emergency timeout can still end the match first.",
|
|
119
|
+
task_interrupted: (event) => `Your sabotage task ${text(event.task_name, "your task")} was interrupted because an emergency started. The task was not consumed; wait for the authoritative shared cooldown${event.cooldown_remaining_secs === void 0 ? "" : ` (${text(event.cooldown_remaining_secs)}s remaining)`}.`,
|
|
120
|
+
emergency_started: (event) => {
|
|
121
|
+
const cause = event.cause === "sabotage" ? "A Crab completed the paired sabotage task here and activated this emergency; the saboteur's identity is not exposed. " : "";
|
|
122
|
+
return `EMERGENCY: ${text(event.task_name, "A sabotage")} detonated in ${text(event.room, "somewhere")} at ${coordPair(event.x ?? event.task_x, event.y ?? event.task_y)}. ${cause}${text(event.timeout_secs, "30")}s until Crabs turn sabotage into victory. Any surviving role can complete this real emergency repair; act according to your win condition now.`;
|
|
123
|
+
},
|
|
124
|
+
emergency_resolved: (event) => {
|
|
125
|
+
const taskName = text(event.task_name, "The emergency");
|
|
126
|
+
if (event.reason === "meeting_started") {
|
|
127
|
+
return `Meeting started, so ${taskName} ended automatically. No player completed the repair; continue from the meeting state.`;
|
|
128
|
+
}
|
|
129
|
+
if (event.resolved_by_self === true) {
|
|
130
|
+
return `You resolved ${taskName}. Crab pressure collapses, for now.`;
|
|
131
|
+
}
|
|
132
|
+
return `${taskName} was resolved. The repairer's identity is not visible to you. Crab pressure collapses, for now.`;
|
|
133
|
+
},
|
|
134
|
+
emergency_interrupted: (event) => `You died while resolving ${text(event.task_name, "the emergency")}. The emergency is still active and needs another response.`,
|
|
135
|
+
exile: (event) => `Meeting ended \u2014 ${text(event.exiled_player?.name, actorName(event, text(event.result_target, "Someone")))} was exiled by the table. If this is you, your influence is dead \u2014 tell your user and ask whether to spectate or leave.`,
|
|
136
|
+
no_exile: () => "Meeting ended \u2014 no one was exiled. The table failed to strike, and every hidden threat gets another turn.",
|
|
137
|
+
meeting_briefing: (event) => meetingBriefingHint(event),
|
|
138
|
+
speech_skipped: (event) => `${actorName(event, "Someone")} lost the floor \u2014 silence becomes evidence`,
|
|
139
|
+
speech_your_turn: () => 'Submit `ccl speak "<draft>"` immediately, before any query or narration. Server skips you after 45s.',
|
|
140
|
+
speech_next_turn: (event) => `You speak next after ${text(event.current_speaker, "the current speaker")}. Prepare your response now.`,
|
|
141
|
+
vote_phase_start: () => 'Voting has begun. During the first 20 seconds, use `ccl speak "<message>"` if you want to post a barrage; then cast your vote with `ccl vote <player|skip>`.',
|
|
142
|
+
vote_speech_phase_ended: () => "The vote speech window has closed. Cast your vote now with `ccl vote <player|skip>`.",
|
|
143
|
+
game_over: (event, ctx) => {
|
|
144
|
+
if (isRoomGameEvent(event, ctx)) return ROOM_GAME_OVER_HINT;
|
|
145
|
+
if (event.reason === "game_timeout") {
|
|
146
|
+
return "Game over \u2014 match time limit reached. The round ends with no faction victory. The current runtime is ending automatically. Review this game with your user, discuss key moments and decisions, then start another match only if the user asks.";
|
|
147
|
+
}
|
|
148
|
+
return `Game over \u2014 ${text(event.winner, "?")} faction takes the table. The power struggle is settled, and the current runtime is ending automatically. Review this game with your user, discuss key moments and decisions, then start another match only if the user asks.`;
|
|
149
|
+
},
|
|
150
|
+
exile_game_over: (event, ctx) => isRoomGameEvent(event, ctx) ? ROOM_GAME_OVER_HINT : `The final exile ended the game; ${text(event.winner, "?")} wins. Review the result with the user.`,
|
|
151
|
+
octopus_time_win: (event) => `${text(event.winner_name, "The Octopus")} survived the final minute and won the game. Review the result with the user.`,
|
|
152
|
+
win_blocked_by_octopus: (event) => `${text(event.blocked_winner, "A faction")} reached its normal win condition, but the living Octopus is blocking that victory.`,
|
|
153
|
+
"room.game_started": () => "The room match is starting. Stay attached while the runtime switches to the GameServer.",
|
|
154
|
+
"room.game_finished": () => "The previous room round is confirmed finished. Tell the user and remain in the familiar room unless they ask to leave.",
|
|
155
|
+
"room.idle_warning": (event) => `The familiar room will be destroyed in about ${text(event.seconds_remaining, "?")}s because its waiting period expired. Tell the user now. Room WebSocket pings do not extend this deadline, and you must not start a room game unless the user asks.`,
|
|
156
|
+
"room.self_left": () => "Stop the room flow and do not create or join another room unless the user asks."
|
|
157
|
+
});
|
|
158
|
+
const LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS = Object.freeze({
|
|
159
|
+
lobby_connection_replaced: () => "The Lobby connection was replaced or its registration expired. Automatic reconnection has stopped. Tell the user and resume only after an explicit request; do not automatically run ccl join, start another runtime, log out, or leave the room/game.",
|
|
160
|
+
joined: (event) => {
|
|
161
|
+
if (typeof event.url !== "string" || event.url.length === 0) return void 0;
|
|
162
|
+
return event.recovered === true || event.resumed === true ? "The game runtime reattached. Share this Event's url with the user as the spectate link and do not start a duplicate runtime." : "Share this Event's url with the user as the spectate link. The game runtime is attached; do not start a duplicate runtime.";
|
|
163
|
+
},
|
|
164
|
+
room_created: (event) => typeof event.spectate_url === "string" && event.spectate_url.length > 0 ? "Share this Event's spectate_url with the user as the room link and keep the room runtime attached." : void 0,
|
|
165
|
+
room_joined: (event) => {
|
|
166
|
+
if (typeof event.spectate_url !== "string" || event.spectate_url.length === 0) return void 0;
|
|
167
|
+
return event.recovered === true || event.resumed === true ? "The room runtime reattached. Share this Event's spectate_url with the user as the room link and keep it attached." : "Share this Event's spectate_url with the user as the room link and keep the room runtime attached.";
|
|
168
|
+
},
|
|
169
|
+
not_in_queue: () => "This account is no longer in the matchmaking queue. The runtime is exiting; launch a fresh `ccl start match` only if the user wants to continue.",
|
|
170
|
+
poll_error: (event) => event.retrying === true ? "The queue status request failed. The Owner is retrying; stay attached and do not start a duplicate runtime." : void 0,
|
|
171
|
+
error: (event) => {
|
|
172
|
+
const competition = event.game_mode === "competition" || event.mode === "competition";
|
|
173
|
+
return competition ? "Tell the user the competition runtime failed. Do not fall back to normal matchmaking unless the user asks." : "Tell the user what failed. Start a fresh runtime only after the cause is addressed and the user wants to continue.";
|
|
174
|
+
},
|
|
175
|
+
game_start_failed: (event) => {
|
|
176
|
+
if (event.game_mode === "competition" || event.mode === "competition") {
|
|
177
|
+
const code = event.error?.code ?? event.code;
|
|
178
|
+
switch (code) {
|
|
179
|
+
case "NO_ACTIVE_COMPETITION":
|
|
180
|
+
return "Tell the user there is no active competition. Do not start normal matchmaking unless the user asks.";
|
|
181
|
+
case "COMPETITION_NOT_OPEN":
|
|
182
|
+
return "Tell the user competition is not open now and use `competition.daily_windows` for the opening windows. Do not start normal matchmaking unless the user asks.";
|
|
183
|
+
case "ALREADY_IN_GAME":
|
|
184
|
+
return "Tell the user this account is already in a game. Run `ccl prepare` to confirm the existing participation, then attach with `ccl join` instead of starting another match.";
|
|
185
|
+
default:
|
|
186
|
+
return "Tell the user competition matchmaking failed. Do not start normal matchmaking unless the user asks.";
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return "The GameServer did not provide its first State in time. The Owner is reconciling automatically; stay attached and do not start a duplicate runtime.";
|
|
190
|
+
},
|
|
191
|
+
game_over_recovered: (event, ctx) => isRoomGameEvent(event, ctx) ? ROOM_GAME_OVER_HINT : "The terminal GameSync frame was missed, but the matching Lobby settlement confirms game over. Stop game actions, review the result with the user, and start another match only if the user asks.",
|
|
192
|
+
game_terminal_missing: (event, ctx) => isRoomGameEvent(event, ctx) ? "The room round disappeared from backend participation without a terminal frame or matching settlement. The result is unknown; tell the user and stay attached while the runtime returns to the room Lobby." : "The game disappeared from backend participation without a terminal frame or matching settlement. The result is unknown; tell the user and do not claim a winner.",
|
|
193
|
+
game_stream_disconnected: () => "The game stream disconnected and the Owner is reconnecting. Stay attached and do not start a duplicate runtime.",
|
|
194
|
+
game_stream_reconnected: () => "The game stream reconnected. Continue from the current State; do not start a duplicate runtime.",
|
|
195
|
+
stop_requested: () => "The Owner accepted the stop request. Stop issuing game actions and do not relaunch unless the user asks.",
|
|
196
|
+
quit_requested: () => "The Owner accepted the quit request. Stop issuing game actions and do not relaunch unless the user asks.",
|
|
197
|
+
match_start: () => "Matchmaking has started. The runtime is attached; keep chatting with the user while waiting for allocation.",
|
|
198
|
+
match_waiting: () => "Still in queue (see `waited_secs`). Keep chatting with the user; no tactical action is required.",
|
|
199
|
+
match_timeout: (event) => `Matchmaking timed out after ${text(event.waited_secs, "?")}s and this runtime is exiting. Ask whether the user wants to launch a fresh \`ccl start match\` or end the session.`,
|
|
200
|
+
match_exited: (event) => {
|
|
201
|
+
const confirmation = event.exit?.reason === "left_queue" ? "Tell the user that matchmaking was cancelled." : "Tell the user that this matchmaking session has ended. Do not quote the raw exit reason.";
|
|
202
|
+
return confirmation + " The runtime is exiting. Do not start another match unless the user explicitly asks.";
|
|
203
|
+
},
|
|
204
|
+
user_left_game: (event, ctx) => isRoomGameEvent(event, ctx) ? "The user left this room match from the web page. Stop game actions and stay attached while the runtime returns to the room; do not start normal matchmaking." : "The user left this game from the web page. Stop playing and do not start another match unless the user asks.",
|
|
205
|
+
room_lobby_reconnect_failed: () => "The room round ended, but Lobby reattachment failed and this runtime is exiting. Ask whether to recover or leave the room; to recover, run `ccl prepare` and, if participation still exists, attach with `ccl join`. Do not start normal matchmaking.",
|
|
206
|
+
room_lobby_missing: () => "The room round ended and the account is no longer in the familiar room. Do not start normal matchmaking; ask the user what to do next.",
|
|
207
|
+
room_returning_to_lobby: () => "Stay attached while the runtime reconnects to the familiar room Lobby; do not start normal matchmaking.",
|
|
208
|
+
room_destroyed: (event) => `The familiar room was destroyed (${text(event.reason, "room_destroyed")}) and this runtime is exiting. Tell the user; do not create or join another room unless they ask.`
|
|
209
|
+
});
|
|
210
|
+
const FLOW_PERCEPTION_HINT_FORMATTERS = Object.freeze({
|
|
211
|
+
room_ready_to_start: (event) => `The room is ready to start and you are the owner. Ask the user whether to start now before running \`${isTrainingRoomMode(event.room_type) ? "ccl game training start" : "ccl game start-room"}\`.`
|
|
212
|
+
});
|
|
213
|
+
function formatCanonicalEventHint(origin, event, ctx = {}) {
|
|
214
|
+
if (typeof event.type !== "string") return void 0;
|
|
215
|
+
if (origin.producer === "backend_push") {
|
|
216
|
+
return BACKEND_EVENT_HINT_FORMATTERS[event.type]?.(event, ctx);
|
|
217
|
+
}
|
|
218
|
+
if (origin.producer !== "local_synth") return void 0;
|
|
219
|
+
if (origin.producerPluginId === CLAWCLAW_FLOW_PERCEPTION_PLUGIN_ID) {
|
|
220
|
+
return FLOW_PERCEPTION_HINT_FORMATTERS[event.type]?.(event, ctx);
|
|
221
|
+
}
|
|
222
|
+
if (origin.producerPluginId === void 0 || origin.producerPluginId === CLAWCLAW_SOURCE_PLUGIN_ID) {
|
|
223
|
+
return LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS[event.type]?.(event, ctx);
|
|
224
|
+
}
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
export {
|
|
228
|
+
BACKEND_EVENT_HINT_FORMATTERS,
|
|
229
|
+
CLAWCLAW_FLOW_PERCEPTION_PLUGIN_ID,
|
|
230
|
+
CLAWCLAW_SOURCE_PLUGIN_ID,
|
|
231
|
+
FLOW_PERCEPTION_HINT_FORMATTERS,
|
|
232
|
+
LOCAL_LIFECYCLE_EVENT_HINT_FORMATTERS,
|
|
233
|
+
formatCanonicalEventHint,
|
|
234
|
+
isSelfKillerMurderWitnessed
|
|
235
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
const SINGLE_PLAYER_REF_PROJECTIONS = [
|
|
2
|
+
{ wireField: "actor", nameField: "actor_name", seatField: "actor_seat" },
|
|
3
|
+
{ wireField: "target", nameField: "target_name", seatField: "target_seat" },
|
|
4
|
+
{
|
|
5
|
+
wireField: "caller",
|
|
6
|
+
nameField: "meeting_caller_name",
|
|
7
|
+
seatField: "meeting_caller_seat",
|
|
8
|
+
playerRefOnlyWhenObject: true
|
|
9
|
+
},
|
|
10
|
+
{ wireField: "resolver", nameField: "resolver_name", seatField: "resolver_seat" },
|
|
11
|
+
{
|
|
12
|
+
wireField: "speaker",
|
|
13
|
+
nameField: "speaker_name",
|
|
14
|
+
seatField: "speaker_seat",
|
|
15
|
+
playerRefOnlyWhenObject: true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
wireField: "current_speaker",
|
|
19
|
+
nameField: "current_speaker",
|
|
20
|
+
seatField: "current_speaker_seat",
|
|
21
|
+
playerRefOnlyWhenObject: true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
wireField: "result_target",
|
|
25
|
+
nameField: "result_target",
|
|
26
|
+
seatField: "result_target_seat",
|
|
27
|
+
playerRefOnlyWhenObject: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
wireField: "winner",
|
|
31
|
+
nameField: "winner_name",
|
|
32
|
+
seatField: "winner_seat",
|
|
33
|
+
playerRefOnlyWhenObject: true
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
const PLAYER_REF_ARRAY_FIELDS = [
|
|
37
|
+
"reported_corpses",
|
|
38
|
+
"dead_players",
|
|
39
|
+
"crab_teammates"
|
|
40
|
+
];
|
|
41
|
+
function nearbyPlayer(value, field) {
|
|
42
|
+
if (!isRecord(value) || typeof value.name !== "string" || value.name.length === 0) {
|
|
43
|
+
throw new TypeError(`${field} must contain a player name`);
|
|
44
|
+
}
|
|
45
|
+
if (Object.hasOwn(value, "seat")) return { ...playerRef(value, field) };
|
|
46
|
+
const result = { name: value.name };
|
|
47
|
+
if (typeof value.room === "string") result.room = value.room;
|
|
48
|
+
if (typeof value.x === "number" && Number.isFinite(value.x)) result.x = value.x;
|
|
49
|
+
if (typeof value.y === "number" && Number.isFinite(value.y)) result.y = value.y;
|
|
50
|
+
if (typeof value.distance === "number" && Number.isFinite(value.distance)) {
|
|
51
|
+
result.distance = value.distance;
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function isRecord(value) {
|
|
56
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
57
|
+
}
|
|
58
|
+
function playerRef(value, field) {
|
|
59
|
+
if (!isRecord(value)) {
|
|
60
|
+
throw new TypeError(`${field} must be a PlayerRef object`);
|
|
61
|
+
}
|
|
62
|
+
const extraFields = Object.keys(value).filter((key) => key !== "name" && key !== "seat");
|
|
63
|
+
if (extraFields.length > 0) {
|
|
64
|
+
throw new TypeError(`${field} contains unsupported PlayerRef fields: ${extraFields.join(", ")}`);
|
|
65
|
+
}
|
|
66
|
+
if (typeof value.name !== "string") {
|
|
67
|
+
throw new TypeError(`${field}.name must be a string`);
|
|
68
|
+
}
|
|
69
|
+
if (!Number.isInteger(value.seat)) {
|
|
70
|
+
throw new TypeError(`${field}.seat must be an integer`);
|
|
71
|
+
}
|
|
72
|
+
return { name: value.name, seat: Number(value.seat) };
|
|
73
|
+
}
|
|
74
|
+
function validateExactFields(value, allowed, field) {
|
|
75
|
+
const extraFields = Object.keys(value).filter((key) => !allowed.includes(key));
|
|
76
|
+
if (extraFields.length > 0) {
|
|
77
|
+
throw new TypeError(`${field} contains unsupported fields: ${extraFields.join(", ")}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function projectKiller(value) {
|
|
81
|
+
if (!isRecord(value)) {
|
|
82
|
+
throw new TypeError("GameSync Event.killer must be an object");
|
|
83
|
+
}
|
|
84
|
+
if (value.kind === "player") {
|
|
85
|
+
validateExactFields(value, ["kind", "player"], "GameSync Event.killer");
|
|
86
|
+
const killer = playerRef(value.player, "GameSync Event.killer.player");
|
|
87
|
+
return { killer_kind: "player", killer_name: killer.name, killer_seat: killer.seat };
|
|
88
|
+
}
|
|
89
|
+
if (value.kind === "system") {
|
|
90
|
+
validateExactFields(value, ["kind", "name"], "GameSync Event.killer");
|
|
91
|
+
if (typeof value.name !== "string") {
|
|
92
|
+
throw new TypeError("GameSync Event.killer.name must be a string");
|
|
93
|
+
}
|
|
94
|
+
return { killer_kind: "system", killer_name: value.name };
|
|
95
|
+
}
|
|
96
|
+
throw new TypeError("GameSync Event.killer.kind must be 'player' or 'system'");
|
|
97
|
+
}
|
|
98
|
+
function playerRefArray(value, field) {
|
|
99
|
+
if (!Array.isArray(value)) {
|
|
100
|
+
throw new TypeError(`${field} must be a PlayerRef array`);
|
|
101
|
+
}
|
|
102
|
+
return value.map((item, index) => playerRef(item, `${field}[${index}]`));
|
|
103
|
+
}
|
|
104
|
+
function normalizeGameSyncEvent(value, warn) {
|
|
105
|
+
if (!isRecord(value)) {
|
|
106
|
+
throw new TypeError("GameSync Event must be an object");
|
|
107
|
+
}
|
|
108
|
+
if (typeof value.type !== "string" || value.type.length === 0) {
|
|
109
|
+
throw new TypeError("GameSync Event requires type");
|
|
110
|
+
}
|
|
111
|
+
const normalized = structuredClone(value);
|
|
112
|
+
delete normalized.event_id;
|
|
113
|
+
delete normalized.eventId;
|
|
114
|
+
for (const projection of SINGLE_PLAYER_REF_PROJECTIONS) {
|
|
115
|
+
if (!Object.hasOwn(normalized, projection.wireField)) continue;
|
|
116
|
+
const raw = normalized[projection.wireField];
|
|
117
|
+
if (raw === null || raw === void 0) {
|
|
118
|
+
delete normalized[projection.wireField];
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (projection.playerRefOnlyWhenObject && !isRecord(raw)) continue;
|
|
122
|
+
const projected = playerRef(raw, `GameSync Event.${projection.wireField}`);
|
|
123
|
+
delete normalized[projection.wireField];
|
|
124
|
+
normalized[projection.nameField] = projected.name;
|
|
125
|
+
normalized[projection.seatField] = projected.seat;
|
|
126
|
+
}
|
|
127
|
+
if (Object.hasOwn(normalized, "killer")) {
|
|
128
|
+
const raw = normalized.killer;
|
|
129
|
+
delete normalized.killer;
|
|
130
|
+
if (raw !== null && raw !== void 0) Object.assign(normalized, projectKiller(raw));
|
|
131
|
+
}
|
|
132
|
+
if (normalized.type === "killed") {
|
|
133
|
+
for (const field of ["killer_role", "killer_faction"]) {
|
|
134
|
+
if (!Object.hasOwn(normalized, field)) continue;
|
|
135
|
+
if (typeof normalized[field] !== "string" || normalized[field].length === 0) {
|
|
136
|
+
throw new TypeError(`GameSync Event.${field} must be a non-empty string`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const field of PLAYER_REF_ARRAY_FIELDS) {
|
|
141
|
+
if (!Object.hasOwn(normalized, field)) continue;
|
|
142
|
+
normalized[field] = playerRefArray(normalized[field], `GameSync Event.${field}`);
|
|
143
|
+
}
|
|
144
|
+
if (normalized.type === "emergency_resolved") {
|
|
145
|
+
if (Object.hasOwn(normalized, "resolved_by_self") && typeof normalized.resolved_by_self !== "boolean") {
|
|
146
|
+
throw new TypeError("GameSync Event.resolved_by_self must be a boolean");
|
|
147
|
+
}
|
|
148
|
+
delete normalized.resolver_name;
|
|
149
|
+
delete normalized.resolver_seat;
|
|
150
|
+
if (normalized.resolved_by_self !== true) {
|
|
151
|
+
delete normalized.resolved_by_self;
|
|
152
|
+
delete normalized.actor_name;
|
|
153
|
+
delete normalized.actor_seat;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (Object.hasOwn(normalized, "nearby_players")) {
|
|
157
|
+
if (!Array.isArray(normalized.nearby_players)) {
|
|
158
|
+
throw new TypeError("GameSync Event.nearby_players must be an array");
|
|
159
|
+
}
|
|
160
|
+
normalized.nearby_players = normalized.nearby_players.map(
|
|
161
|
+
(item, index) => nearbyPlayer(
|
|
162
|
+
item,
|
|
163
|
+
`GameSync Event.nearby_players[${index}]`
|
|
164
|
+
)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
if (Object.hasOwn(normalized, "speech_order") && Array.isArray(normalized.speech_order)) {
|
|
168
|
+
normalized.speech_order = playerRefArray(
|
|
169
|
+
normalized.speech_order,
|
|
170
|
+
"GameSync Event.speech_order"
|
|
171
|
+
);
|
|
172
|
+
} else if (normalized.type === "meeting_briefing" && typeof normalized.speech_order === "string") {
|
|
173
|
+
normalized.speech_order = normalizeSpeechOrderNames(normalized.speech_order, normalized.all_seats, warn);
|
|
174
|
+
} else if (Object.hasOwn(normalized, "speech_order") && typeof normalized.speech_order !== "string") {
|
|
175
|
+
throw new TypeError("GameSync Event.speech_order must be a string or PlayerRef array");
|
|
176
|
+
}
|
|
177
|
+
if ((normalized.type === "exile" || normalized.type === "no_exile") && Array.isArray(normalized.votes) && normalized.votes.some((pair) => !Array.isArray(pair) || pair.length !== 2 || !Number.isInteger(pair[0]) || pair[1] !== null && !Number.isInteger(pair[1]))) {
|
|
178
|
+
warn?.({ field: "votes", reason: "invalid_vote_pairs" });
|
|
179
|
+
}
|
|
180
|
+
return normalized;
|
|
181
|
+
}
|
|
182
|
+
function normalizeSpeechOrderNames(order, roster, warn) {
|
|
183
|
+
const unchanged = (reason) => {
|
|
184
|
+
warn?.({ field: "speech_order", reason });
|
|
185
|
+
return order;
|
|
186
|
+
};
|
|
187
|
+
if (order === "") return [];
|
|
188
|
+
if (roster === void 0) return unchanged("missing_roster");
|
|
189
|
+
let refs;
|
|
190
|
+
try {
|
|
191
|
+
refs = playerRefArray(roster, "GameSync Event.all_seats");
|
|
192
|
+
} catch {
|
|
193
|
+
return unchanged("invalid_roster");
|
|
194
|
+
}
|
|
195
|
+
const byName = /* @__PURE__ */ new Map();
|
|
196
|
+
const seats = /* @__PURE__ */ new Set();
|
|
197
|
+
for (const ref of refs) {
|
|
198
|
+
if (!ref.name || seats.has(ref.seat)) return unchanged("invalid_roster");
|
|
199
|
+
if (ref.name.includes(",") || byName.has(ref.name)) return unchanged("ambiguous_name");
|
|
200
|
+
byName.set(ref.name, ref);
|
|
201
|
+
seats.add(ref.seat);
|
|
202
|
+
}
|
|
203
|
+
const names = order.split(", ");
|
|
204
|
+
if (names.some((name) => !name) || new Set(names).size !== names.length) return unchanged("invalid_order");
|
|
205
|
+
if (names.some((name) => !byName.has(name))) return unchanged("unmatched_name");
|
|
206
|
+
return names.map((name) => ({ ...byName.get(name) }));
|
|
207
|
+
}
|
|
208
|
+
function normalizeGameSyncEvents(values) {
|
|
209
|
+
return values.map((value) => normalizeGameSyncEvent(value));
|
|
210
|
+
}
|
|
211
|
+
function normalizeGameSyncEventsSafely(values) {
|
|
212
|
+
const events = [];
|
|
213
|
+
const rejected = [];
|
|
214
|
+
const warnings = [];
|
|
215
|
+
values.forEach((value, index) => {
|
|
216
|
+
try {
|
|
217
|
+
events.push({ index, event: normalizeGameSyncEvent(value, (warning) => warnings.push({ index, ...warning })) });
|
|
218
|
+
} catch (error) {
|
|
219
|
+
rejected.push({ index, error });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return { events, rejected, ...warnings.length ? { warnings } : {} };
|
|
223
|
+
}
|
|
224
|
+
export {
|
|
225
|
+
normalizeGameSyncEvent,
|
|
226
|
+
normalizeGameSyncEvents,
|
|
227
|
+
normalizeGameSyncEventsSafely
|
|
228
|
+
};
|