@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,878 @@
|
|
|
1
|
+
import { startupSpan, timeStartup } from "../../bin/startup-trace.mjs";
|
|
2
|
+
import { isPackageManagedSkill } from "../lib/package-skills.js";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { basename, extname, resolve } from "node:path";
|
|
6
|
+
import { formatLoadReport, loadContext } from "../lib/load-context.js";
|
|
7
|
+
import { summarizeStartupBlockers } from "../lib/load-startup.js";
|
|
8
|
+
import { saveStartupContext } from "../lib/load-startup-context.js";
|
|
9
|
+
import { AuthStore } from "../lib/auth.js";
|
|
10
|
+
import { noAccountMessage } from "../lib/account-guidance.js";
|
|
11
|
+
import { runAutoUpgradeOnLoad } from "../runtime/auto-upgrade.js";
|
|
12
|
+
import {
|
|
13
|
+
CLAWCLAW_ROLE_IDS,
|
|
14
|
+
readGameplayConfig
|
|
15
|
+
} from "../lib/gameplay-config.js";
|
|
16
|
+
import { getWorkspaceDir } from "../lib/init-command.js";
|
|
17
|
+
import {
|
|
18
|
+
ensureAccountUserDataLayout,
|
|
19
|
+
getUserDataAccountBehaviorsDir,
|
|
20
|
+
getUserDataAccountPerceptionsDir,
|
|
21
|
+
getUserDataAccountTriggersDir
|
|
22
|
+
} from "../lib/user-data.js";
|
|
23
|
+
import {
|
|
24
|
+
behaviorSourceCompatibilityError
|
|
25
|
+
} from "../runtime/clawclaw/plugins/behavior/behavior-source.js";
|
|
26
|
+
import { listClawclawTriggerSources } from "../runtime/clawclaw/plugins/trigger/trigger-source.js";
|
|
27
|
+
import { GameClient } from "../lib/game-client.js";
|
|
28
|
+
import {
|
|
29
|
+
GAME_STATUS_SCHEMA,
|
|
30
|
+
queryGameParticipationStatus
|
|
31
|
+
} from "../lib/participation-status.js";
|
|
32
|
+
import { BEHAVIOR_PLUGIN_API_VERSION } from "../sdk/behavior-plugin/index.js";
|
|
33
|
+
import { TRIGGER_PLUGIN_API_VERSION } from "../sdk/trigger-plugin/index.js";
|
|
34
|
+
import { PERCEPTION_PLUGIN_API_VERSION } from "../sdk/perception-plugin/index.js";
|
|
35
|
+
import { expectedPerceptionApiVersion, isSupportedPerceptionSource } from "../runtime/clawclaw/plugins/perception/perception-source.js";
|
|
36
|
+
import { resolveReactionBehavior } from "../runtime/clawclaw/reaction-behavior-resolution.js";
|
|
37
|
+
import { pluginApiVersionStatus } from "../runtime/clawclaw/plugins/plugin-api-version.js";
|
|
38
|
+
import {
|
|
39
|
+
readLocalAgentWorkspaceSnapshot,
|
|
40
|
+
resolveLocalAgentWorkspacePath,
|
|
41
|
+
resolveLocalAgentWorkspaceWorkingCopyPath,
|
|
42
|
+
resolveLocalAgentWorkspaceSnapshot,
|
|
43
|
+
syncAgentWorkspaceConfig
|
|
44
|
+
} from "../lib/agent-workspace-sync.js";
|
|
45
|
+
import { inspectSkillNameConflicts, syncAgentWorkspaceSkills } from "../lib/agent-workspace-skills.js";
|
|
46
|
+
import { skillConflictNames, skillNameKey } from "../lib/skill-name-conflicts.js";
|
|
47
|
+
import {
|
|
48
|
+
listAgentWorkspaceBehaviorSources,
|
|
49
|
+
listAgentWorkspacePerceptionSources,
|
|
50
|
+
mergeAgentWorkspaceBehaviorSources,
|
|
51
|
+
mergeAgentWorkspacePerceptionSources
|
|
52
|
+
} from "../lib/agent-workspace-runtime.js";
|
|
53
|
+
import {
|
|
54
|
+
diagnoseRejectedCapabilityModule,
|
|
55
|
+
listCapabilityModuleCandidates,
|
|
56
|
+
warningFromStaticDiagnostic
|
|
57
|
+
} from "../lib/capability-load-diagnostics.js";
|
|
58
|
+
import { resolveClawclawResourceMetadata } from "../sdk/resource-metadata.js";
|
|
59
|
+
import { discoverLocalCapabilities } from "../lib/capability-discovery.js";
|
|
60
|
+
import {
|
|
61
|
+
capabilitySelectionRef,
|
|
62
|
+
capabilityWorkspacePath,
|
|
63
|
+
classifyStrategyLifecycle,
|
|
64
|
+
pendingCapabilitySelections,
|
|
65
|
+
readCapabilityWorkspaceRegistry,
|
|
66
|
+
registerDiscoveredCapability,
|
|
67
|
+
capabilityEntryForPath,
|
|
68
|
+
capabilityEntryForHubResource
|
|
69
|
+
} from "../lib/capability-workspace.js";
|
|
70
|
+
import { syncCapabilitiesToCloud } from "../lib/capability-cloud-sync.js";
|
|
71
|
+
import {
|
|
72
|
+
refreshCapabilitiesFromCloud,
|
|
73
|
+
syncInstalledCapabilityUpdates
|
|
74
|
+
} from "../lib/capability-cloud-refresh.js";
|
|
75
|
+
import {
|
|
76
|
+
filterInactiveAgentWorkspaceSnapshot,
|
|
77
|
+
reconcileCapabilityWorkspacePresence,
|
|
78
|
+
reconcileCapabilityLoadout
|
|
79
|
+
} from "../lib/capability-cloud-presence.js";
|
|
80
|
+
const PREPARE_SCHEMA = "ccl.prepare.v1";
|
|
81
|
+
const LOAD_DISPLAY_LOCALE = "en-US";
|
|
82
|
+
function inferredWorkspaceVersionUpdates(current, previous) {
|
|
83
|
+
if (!current || !previous) return [];
|
|
84
|
+
const previousByResource = new Map(
|
|
85
|
+
Object.values(previous.items).flat().map((item) => [
|
|
86
|
+
`${item.resourceType}:${item.resourceId}`,
|
|
87
|
+
item
|
|
88
|
+
])
|
|
89
|
+
);
|
|
90
|
+
return Object.values(current.items).flat().flatMap((item) => {
|
|
91
|
+
const before = previousByResource.get(`${item.resourceType}:${item.resourceId}`);
|
|
92
|
+
if (!before || before.versionId === item.versionId || item.resolution !== "hub" && item.resolution !== "known_online_old") return [];
|
|
93
|
+
return [{
|
|
94
|
+
type: item.resourceType,
|
|
95
|
+
resource_id: item.resourceId,
|
|
96
|
+
workspace_item_id: item.workspaceItemId,
|
|
97
|
+
from_version: before.versionId,
|
|
98
|
+
version_id: item.versionId
|
|
99
|
+
}];
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function mergeWorkspaceVersionUpdates(reported, inferred) {
|
|
103
|
+
const merged = /* @__PURE__ */ new Map();
|
|
104
|
+
for (const item of inferred) merged.set(`${item.type}:${item.resource_id}`, { ...item });
|
|
105
|
+
for (const item of reported) {
|
|
106
|
+
const key = `${item.type}:${item.resource_id}`;
|
|
107
|
+
merged.set(key, { ...merged.get(key), ...item });
|
|
108
|
+
}
|
|
109
|
+
return [...merged.values()];
|
|
110
|
+
}
|
|
111
|
+
function compatibilityWarning(type, source, value, reason) {
|
|
112
|
+
return {
|
|
113
|
+
code: "CAPABILITY_NOT_LOADED",
|
|
114
|
+
capability_type: type,
|
|
115
|
+
source,
|
|
116
|
+
reason,
|
|
117
|
+
stage: "static_discovery",
|
|
118
|
+
id: value.id,
|
|
119
|
+
name: value.name,
|
|
120
|
+
file: basename(value.sourcePath),
|
|
121
|
+
path: value.sourcePath,
|
|
122
|
+
...value.management?.resourceId ? { resource_id: value.management.resourceId } : {},
|
|
123
|
+
...value.management?.versionId ? { version_id: value.management.versionId } : {}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function missingProjectionWarning(type, item) {
|
|
127
|
+
return {
|
|
128
|
+
code: "CAPABILITY_NOT_LOADED",
|
|
129
|
+
capability_type: type,
|
|
130
|
+
source: "hub",
|
|
131
|
+
reason: "projection_missing",
|
|
132
|
+
stage: "projection",
|
|
133
|
+
resource_id: item.resourceId,
|
|
134
|
+
version_id: item.versionId,
|
|
135
|
+
file: item.sourceFiles[0]?.relativePath ?? item.resourceId,
|
|
136
|
+
path: null
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function compactCapabilityWarning(warning) {
|
|
140
|
+
const keys = [
|
|
141
|
+
"code",
|
|
142
|
+
"capability_type",
|
|
143
|
+
"source",
|
|
144
|
+
"reason",
|
|
145
|
+
"stage",
|
|
146
|
+
"id",
|
|
147
|
+
"file",
|
|
148
|
+
"expected_import",
|
|
149
|
+
"received_imports"
|
|
150
|
+
];
|
|
151
|
+
return Object.fromEntries(keys.flatMap((key) => warning[key] === void 0 ? [] : [[key, warning[key]]]));
|
|
152
|
+
}
|
|
153
|
+
function compactSkillChanges(changes) {
|
|
154
|
+
const keys = ["added", "updated", "removed", "preservedModified", "failed", "skipped", "conflicts"];
|
|
155
|
+
const value = Object.fromEntries(keys.flatMap((key) => !changes[key]?.length ? [] : [[key, changes[key]]]));
|
|
156
|
+
return Object.keys(value).length > 0 || changes.requiresUserConfirmation ? {
|
|
157
|
+
...value,
|
|
158
|
+
...changes.requiresUserConfirmation ? { requires_user_confirmation: true } : {}
|
|
159
|
+
} : void 0;
|
|
160
|
+
}
|
|
161
|
+
function compactConfigurationWarnings(warnings) {
|
|
162
|
+
return warnings.map((warning) => {
|
|
163
|
+
if (warning.code !== "DEFAULT_LONG_BEHAVIOR_UNAVAILABLE" || typeof warning.behavior_id !== "string" || typeof warning.role !== "string") {
|
|
164
|
+
return { ...warning };
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
code: "FALLBACK_BEHAVIOR_NOT_LOADED",
|
|
168
|
+
role: warning.role,
|
|
169
|
+
behavior_id: warning.behavior_id,
|
|
170
|
+
message: `Fallback Behavior ${warning.behavior_id} configured for role ${warning.role} is not loaded.`
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function compactParticipation(value) {
|
|
175
|
+
const { schema: _schema, ...participation } = value;
|
|
176
|
+
return participation;
|
|
177
|
+
}
|
|
178
|
+
function createPrepareCommand(dependencies = {}) {
|
|
179
|
+
return new Command("prepare").description("Prepare gameplay resources, resolve startup blockers, and query participation").option("--full", "Include persona, memory and the full synchronization and capability report").action(async ({ full }) => {
|
|
180
|
+
timeStartup("prepare.auto_upgrade", () => runAutoUpgradeOnLoad({ notify: (message) => console.error(message) }));
|
|
181
|
+
const accountReady = startupSpan("prepare.account");
|
|
182
|
+
const workspaceDir = getWorkspaceDir();
|
|
183
|
+
const authStore = dependencies.authStore ?? new AuthStore();
|
|
184
|
+
const profile = authStore.getActive();
|
|
185
|
+
if (!profile) throw new Error(noAccountMessage("prepare"));
|
|
186
|
+
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
187
|
+
accountReady?.();
|
|
188
|
+
let cloudWorkspaceUpdates = {
|
|
189
|
+
updated: [],
|
|
190
|
+
failed: [],
|
|
191
|
+
inventory: [],
|
|
192
|
+
inventoryComplete: false
|
|
193
|
+
};
|
|
194
|
+
let inventoryReadFailed = false;
|
|
195
|
+
try {
|
|
196
|
+
cloudWorkspaceUpdates = await timeStartup("prepare.hub_inventory", () => (dependencies.cloudWorkspaceUpdates ?? syncInstalledCapabilityUpdates)(profile));
|
|
197
|
+
} catch (error) {
|
|
198
|
+
inventoryReadFailed = true;
|
|
199
|
+
console.error(`[clawclaw-cli] Hub workspace update check unavailable: ${error instanceof Error ? error.message : String(error)}`);
|
|
200
|
+
}
|
|
201
|
+
let workspaceResult;
|
|
202
|
+
const storedWorkspace = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
203
|
+
let activeWorkspace = storedWorkspace ? resolveLocalAgentWorkspaceSnapshot(workspaceDir, profile, storedWorkspace) : void 0;
|
|
204
|
+
let workspaceSyncStatus;
|
|
205
|
+
let workspaceSyncError;
|
|
206
|
+
try {
|
|
207
|
+
workspaceResult = await timeStartup("prepare.workspace_sync", () => (dependencies.workspaceSync ?? syncAgentWorkspaceConfig)(workspaceDir, profile, {
|
|
208
|
+
workspaceInventory: cloudWorkspaceUpdates.inventoryComplete ? cloudWorkspaceUpdates.inventory : void 0
|
|
209
|
+
}));
|
|
210
|
+
activeWorkspace = workspaceResult.snapshot;
|
|
211
|
+
workspaceSyncStatus = workspaceResult.status;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
workspaceSyncStatus = activeWorkspace ? "stale_fallback" : "unavailable";
|
|
214
|
+
workspaceSyncError = error instanceof Error ? error.message : String(error);
|
|
215
|
+
console.error(`[clawclaw-cli] Agent workspace sync unavailable: ${workspaceSyncError}`);
|
|
216
|
+
}
|
|
217
|
+
let cloudPresence = cloudWorkspaceUpdates.inventoryComplete ? reconcileCapabilityWorkspacePresence(workspaceDir, profile, cloudWorkspaceUpdates.inventory, workspaceResult?.snapshot) : workspaceResult?.snapshot ? reconcileCapabilityLoadout(workspaceDir, profile, workspaceResult.snapshot) : { deactivated: [], restored: [], inactiveResourceIds: [] };
|
|
218
|
+
activeWorkspace = filterInactiveAgentWorkspaceSnapshot(
|
|
219
|
+
workspaceDir,
|
|
220
|
+
profile,
|
|
221
|
+
activeWorkspace,
|
|
222
|
+
cloudPresence.inactiveResourceIds
|
|
223
|
+
);
|
|
224
|
+
const cloudRefreshChanges = inventoryReadFailed ? { downloaded: [], conflicts: [], failed: [], unchanged: [] } : await timeStartup("prepare.cloud_refresh", () => (dependencies.cloudRefresh ?? refreshCapabilitiesFromCloud)(
|
|
225
|
+
workspaceDir,
|
|
226
|
+
profile,
|
|
227
|
+
activeWorkspace
|
|
228
|
+
));
|
|
229
|
+
const newForkReplacements = activeWorkspace ? Object.values(activeWorkspace.items).flat().filter((item) => workspaceResult?.forkReplacements?.includes(item.resourceId)) : [];
|
|
230
|
+
let firstSkillChanges;
|
|
231
|
+
const renderFinalContext = async (completedSync) => {
|
|
232
|
+
const inspectDone = startupSpan("prepare.local_inspection");
|
|
233
|
+
let snapshot;
|
|
234
|
+
try {
|
|
235
|
+
snapshot = loadContext(authStore, { includeContent: false });
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (error instanceof Error && error.message === "Not logged in.") {
|
|
238
|
+
throw new Error(noAccountMessage("prepare"));
|
|
239
|
+
}
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
if (snapshot.persona.source === "hub" && snapshot.persona.resource_id && cloudPresence.inactiveResourceIds.includes(snapshot.persona.resource_id)) {
|
|
243
|
+
snapshot.persona = { path: null, exists: false, content: "", source: "none" };
|
|
244
|
+
}
|
|
245
|
+
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
246
|
+
const discoveredLocal = timeStartup("prepare.capability_scan", () => discoverLocalCapabilities(workspaceDir, profile));
|
|
247
|
+
const strategyLifecycles = /* @__PURE__ */ new Map();
|
|
248
|
+
const strategyLifecycle = (path) => {
|
|
249
|
+
const known = strategyLifecycles.get(path);
|
|
250
|
+
if (known !== void 0) return known;
|
|
251
|
+
const lifecycle = classifyStrategyLifecycle(readFileSync(path, "utf8"));
|
|
252
|
+
strategyLifecycles.set(path, lifecycle);
|
|
253
|
+
return lifecycle;
|
|
254
|
+
};
|
|
255
|
+
const capabilityWarnings = [];
|
|
256
|
+
const disabledBehaviors = new Set(gameplay.disabled_behaviors);
|
|
257
|
+
const hubBehaviors = activeWorkspace ? listAgentWorkspaceBehaviorSources(workspaceDir, profile, activeWorkspace) : [];
|
|
258
|
+
if (activeWorkspace) {
|
|
259
|
+
for (const source of hubBehaviors) {
|
|
260
|
+
const item = activeWorkspace.items.strategy.find((candidate) => candidate.resourceId === source.management.resourceId);
|
|
261
|
+
const workingPath = item ? resolveLocalAgentWorkspaceWorkingCopyPath(workspaceDir, profile, item) : void 0;
|
|
262
|
+
if (!item || !workingPath) continue;
|
|
263
|
+
registerDiscoveredCapability(workspaceDir, profile, {
|
|
264
|
+
type: "behavior",
|
|
265
|
+
path: workingPath,
|
|
266
|
+
runtimeId: source.declaredId ?? source.id,
|
|
267
|
+
title: source.name,
|
|
268
|
+
description: source.description,
|
|
269
|
+
strategyLifecycle: strategyLifecycle(workingPath),
|
|
270
|
+
selectedByHub: true,
|
|
271
|
+
hub: {
|
|
272
|
+
resourceId: item.resourceId,
|
|
273
|
+
versionId: item.versionId,
|
|
274
|
+
workspaceItemId: item.workspaceItemId,
|
|
275
|
+
publisher: item.hub?.publisher ?? "community",
|
|
276
|
+
baseSha256: item.sourceFiles[0]?.sha256,
|
|
277
|
+
localOriginUnrecognized: item.resolution === "local_origin_unrecognized" ? true : void 0
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const localBehaviorDir = getUserDataAccountBehaviorsDir(workspaceDir, profile);
|
|
283
|
+
const allLocalBehaviors = discoveredLocal.behaviors.map(({ source }) => source);
|
|
284
|
+
const localBehaviors = discoveredLocal.behaviors.filter(({ source, entry }) => entry.selection === "equipped" && !disabledBehaviors.has(source.id) && !activeWorkspace?.items.strategy.some((item) => item.resourceId === entry.hub?.resourceId)).map(({ source }) => source);
|
|
285
|
+
const localBehaviorSourcePaths = new Set(allLocalBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
286
|
+
let expectedLocalBehaviors = localBehaviors.length;
|
|
287
|
+
for (const path of listCapabilityModuleCandidates(localBehaviorDir)) {
|
|
288
|
+
if (localBehaviorSourcePaths.has(resolve(path))) continue;
|
|
289
|
+
const diagnostic = diagnoseRejectedCapabilityModule("behavior", path);
|
|
290
|
+
const operationName = capabilityEntryForPath(workspaceDir, profile, "behavior", path)?.runtimeId ?? diagnostic.declaredId;
|
|
291
|
+
if (operationName && disabledBehaviors.has(operationName)) continue;
|
|
292
|
+
expectedLocalBehaviors += 1;
|
|
293
|
+
capabilityWarnings.push({
|
|
294
|
+
...warningFromStaticDiagnostic("behavior", "local", diagnostic),
|
|
295
|
+
...operationName ? { id: operationName } : {}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (activeWorkspace) {
|
|
299
|
+
const discoveredPaths = new Set(hubBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
300
|
+
for (const item of activeWorkspace.items.strategy) {
|
|
301
|
+
if (!item.runtimeEntryPath) {
|
|
302
|
+
capabilityWarnings.push(missingProjectionWarning("behavior", item));
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
const path = resolveLocalAgentWorkspacePath(
|
|
306
|
+
workspaceDir,
|
|
307
|
+
profile,
|
|
308
|
+
activeWorkspace,
|
|
309
|
+
item.runtimeEntryPath
|
|
310
|
+
);
|
|
311
|
+
if (discoveredPaths.has(resolve(path))) continue;
|
|
312
|
+
capabilityWarnings.push(warningFromStaticDiagnostic(
|
|
313
|
+
"behavior",
|
|
314
|
+
"hub",
|
|
315
|
+
diagnoseRejectedCapabilityModule("behavior", path),
|
|
316
|
+
{ resourceId: item.resourceId, versionId: item.versionId }
|
|
317
|
+
));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const enabledBehaviors = mergeAgentWorkspaceBehaviorSources(
|
|
321
|
+
localBehaviors,
|
|
322
|
+
hubBehaviors,
|
|
323
|
+
disabledBehaviors
|
|
324
|
+
);
|
|
325
|
+
const behaviorEntry = (source) => {
|
|
326
|
+
const compatibilityError = behaviorSourceCompatibilityError(source);
|
|
327
|
+
const versionCompatible = source.apiVersion === BEHAVIOR_PLUGIN_API_VERSION;
|
|
328
|
+
const loadable = versionCompatible && compatibilityError === void 0;
|
|
329
|
+
return {
|
|
330
|
+
id: source.id,
|
|
331
|
+
name: source.name,
|
|
332
|
+
description: source.description,
|
|
333
|
+
api_version: source.apiVersion ?? null,
|
|
334
|
+
expected_api_version: BEHAVIOR_PLUGIN_API_VERSION,
|
|
335
|
+
loadable,
|
|
336
|
+
...loadable ? {} : {
|
|
337
|
+
compatibility_error: versionCompatible ? compatibilityError : `behavior_api_version_unsupported:expected=${BEHAVIOR_PLUGIN_API_VERSION}:received=${source.apiVersion ?? "missing"}`
|
|
338
|
+
},
|
|
339
|
+
source: source.management.source,
|
|
340
|
+
managed_by: source.management.managedBy,
|
|
341
|
+
...source.management.publisher ? { publisher: source.management.publisher } : {},
|
|
342
|
+
...source.management.resourceId ? { resource_id: source.management.resourceId } : {},
|
|
343
|
+
...source.management.versionId ? { version_id: source.management.versionId } : {},
|
|
344
|
+
...source.management.resolution ? { resolution: source.management.resolution } : {}
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
const behaviorEntries = enabledBehaviors.map(behaviorEntry);
|
|
348
|
+
const behaviors = behaviorEntries.filter(({ loadable }) => loadable);
|
|
349
|
+
const incompatibleBehaviors = behaviorEntries.filter(({ loadable }) => !loadable);
|
|
350
|
+
for (const source of enabledBehaviors) {
|
|
351
|
+
const compatibilityError = behaviorSourceCompatibilityError(source);
|
|
352
|
+
const reason = source.apiVersion === BEHAVIOR_PLUGIN_API_VERSION ? compatibilityError : `behavior_api_version_unsupported:expected=${BEHAVIOR_PLUGIN_API_VERSION}:received=${source.apiVersion ?? "missing"}`;
|
|
353
|
+
if (!reason) continue;
|
|
354
|
+
capabilityWarnings.push(compatibilityWarning(
|
|
355
|
+
"behavior",
|
|
356
|
+
source.management.source,
|
|
357
|
+
source,
|
|
358
|
+
reason
|
|
359
|
+
));
|
|
360
|
+
}
|
|
361
|
+
const selectedLocalBehaviorPaths = new Set(localBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
362
|
+
for (const source of allLocalBehaviors) {
|
|
363
|
+
if (selectedLocalBehaviorPaths.has(resolve(source.sourcePath))) continue;
|
|
364
|
+
const compatibilityError = behaviorSourceCompatibilityError(source);
|
|
365
|
+
const reason = source.apiVersion === BEHAVIOR_PLUGIN_API_VERSION ? compatibilityError : `behavior_api_version_unsupported:expected=${BEHAVIOR_PLUGIN_API_VERSION}:received=${source.apiVersion ?? "missing"}`;
|
|
366
|
+
if (!reason) continue;
|
|
367
|
+
capabilityWarnings.push(compatibilityWarning("behavior", "local", source, reason));
|
|
368
|
+
}
|
|
369
|
+
const configurationWarnings = [];
|
|
370
|
+
for (const item of Object.values(activeWorkspace?.items ?? {}).flat()) {
|
|
371
|
+
const relation = item.forkReconciliation;
|
|
372
|
+
if (relation?.status !== "unresolved") continue;
|
|
373
|
+
configurationWarnings.push({
|
|
374
|
+
code: "FORK_RECONCILIATION_SKIPPED",
|
|
375
|
+
resource_id: item.resourceId,
|
|
376
|
+
forked_from_resource_id: relation.parentResourceId,
|
|
377
|
+
reason: relation.reason,
|
|
378
|
+
message: "Fork relationship was not automatically merged. Original local files are preserved; review the resource relationship before synchronizing edits."
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
if (workspaceSyncError) configurationWarnings.push({
|
|
382
|
+
code: "WORKSPACE_SYNC_FAILED",
|
|
383
|
+
message: workspaceSyncError,
|
|
384
|
+
using_previous_snapshot: !!activeWorkspace
|
|
385
|
+
});
|
|
386
|
+
if (inventoryReadFailed) configurationWarnings.push({
|
|
387
|
+
code: "WORKSPACE_INVENTORY_UNAVAILABLE",
|
|
388
|
+
message: "Backpack could not be verified; automatic cloud writes and inactive-resource refresh were skipped."
|
|
389
|
+
});
|
|
390
|
+
for (const role of CLAWCLAW_ROLE_IDS) {
|
|
391
|
+
const fallback = gameplay.fallback_behaviors[role];
|
|
392
|
+
if (fallback === null) continue;
|
|
393
|
+
if (!behaviors.some(({ id }) => id === fallback)) {
|
|
394
|
+
configurationWarnings.push({
|
|
395
|
+
code: "DEFAULT_LONG_BEHAVIOR_UNAVAILABLE",
|
|
396
|
+
role,
|
|
397
|
+
behavior_id: fallback,
|
|
398
|
+
reason: disabledBehaviors.has(fallback) ? "local_disabled_or_unselected" : "not_loaded"
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const disabledPerceptions = new Set(gameplay.disabled_perception_modules);
|
|
403
|
+
const hubPerceptions = activeWorkspace ? listAgentWorkspacePerceptionSources(workspaceDir, profile, activeWorkspace) : [];
|
|
404
|
+
if (activeWorkspace) {
|
|
405
|
+
for (const source of hubPerceptions) {
|
|
406
|
+
const item = activeWorkspace.items.perception.find((candidate) => !!candidate.runtimeEntryPath && resolveLocalAgentWorkspacePath(
|
|
407
|
+
workspaceDir,
|
|
408
|
+
profile,
|
|
409
|
+
activeWorkspace,
|
|
410
|
+
candidate.runtimeEntryPath
|
|
411
|
+
) === source.sourcePath);
|
|
412
|
+
const workingPath = item ? resolveLocalAgentWorkspaceWorkingCopyPath(workspaceDir, profile, item) : void 0;
|
|
413
|
+
if (!item || !workingPath) continue;
|
|
414
|
+
registerDiscoveredCapability(workspaceDir, profile, {
|
|
415
|
+
type: "perception",
|
|
416
|
+
path: workingPath,
|
|
417
|
+
runtimeId: source.declaredId ?? source.id,
|
|
418
|
+
title: source.name,
|
|
419
|
+
description: source.description,
|
|
420
|
+
selectedByHub: true,
|
|
421
|
+
hub: {
|
|
422
|
+
resourceId: item.resourceId,
|
|
423
|
+
versionId: item.versionId,
|
|
424
|
+
workspaceItemId: item.workspaceItemId,
|
|
425
|
+
publisher: item.hub?.publisher ?? "community",
|
|
426
|
+
baseSha256: item.sourceFiles[0]?.sha256,
|
|
427
|
+
localOriginUnrecognized: item.resolution === "local_origin_unrecognized" ? true : void 0
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const hubPerceptionIds = new Set(hubPerceptions.map(({ id }) => id));
|
|
433
|
+
const localPerceptionDir = getUserDataAccountPerceptionsDir(workspaceDir, profile);
|
|
434
|
+
const allLocalPerceptions = discoveredLocal.perceptions.map(({ source }) => source);
|
|
435
|
+
const localPerceptions = discoveredLocal.perceptions.filter(({ source, entry }) => entry.selection === "equipped" && !disabledPerceptions.has(source.id) && !activeWorkspace?.items.perception.some((item) => item.resourceId === entry.hub?.resourceId)).map(({ source }) => source);
|
|
436
|
+
const localPerceptionSourcePaths = new Set(
|
|
437
|
+
allLocalPerceptions.map(({ sourcePath }) => resolve(sourcePath))
|
|
438
|
+
);
|
|
439
|
+
let expectedLocalPerceptions = localPerceptions.length;
|
|
440
|
+
for (const path of listCapabilityModuleCandidates(localPerceptionDir)) {
|
|
441
|
+
if (localPerceptionSourcePaths.has(resolve(path))) continue;
|
|
442
|
+
const diagnostic = diagnoseRejectedCapabilityModule("perception", path);
|
|
443
|
+
const operationName = capabilityEntryForPath(workspaceDir, profile, "perception", path)?.runtimeId ?? diagnostic.declaredId;
|
|
444
|
+
if (operationName && disabledPerceptions.has(operationName)) continue;
|
|
445
|
+
expectedLocalPerceptions += 1;
|
|
446
|
+
capabilityWarnings.push({
|
|
447
|
+
...warningFromStaticDiagnostic("perception", "local", diagnostic),
|
|
448
|
+
...operationName ? { id: operationName } : {}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
if (activeWorkspace) {
|
|
452
|
+
const discoveredPaths = new Set(hubPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
|
|
453
|
+
for (const item of activeWorkspace.items.perception) {
|
|
454
|
+
if (!item.runtimeEntryPath) {
|
|
455
|
+
capabilityWarnings.push(missingProjectionWarning("perception", item));
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
const path = resolveLocalAgentWorkspacePath(
|
|
459
|
+
workspaceDir,
|
|
460
|
+
profile,
|
|
461
|
+
activeWorkspace,
|
|
462
|
+
item.runtimeEntryPath
|
|
463
|
+
);
|
|
464
|
+
if (discoveredPaths.has(resolve(path))) continue;
|
|
465
|
+
capabilityWarnings.push(warningFromStaticDiagnostic(
|
|
466
|
+
"perception",
|
|
467
|
+
"hub",
|
|
468
|
+
diagnoseRejectedCapabilityModule("perception", path),
|
|
469
|
+
{ resourceId: item.resourceId, versionId: item.versionId }
|
|
470
|
+
));
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const enabledPerceptions = mergeAgentWorkspacePerceptionSources(
|
|
474
|
+
localPerceptions,
|
|
475
|
+
hubPerceptions,
|
|
476
|
+
disabledPerceptions
|
|
477
|
+
);
|
|
478
|
+
const reminderTopics = /* @__PURE__ */ new Map();
|
|
479
|
+
for (const source of enabledPerceptions) {
|
|
480
|
+
if (!source.reminder || source.apiVersion !== PERCEPTION_PLUGIN_API_VERSION) continue;
|
|
481
|
+
const ids = reminderTopics.get(source.reminder.topic) ?? [];
|
|
482
|
+
ids.push(source.id);
|
|
483
|
+
reminderTopics.set(source.reminder.topic, ids);
|
|
484
|
+
}
|
|
485
|
+
const conflictingPerceptions = new Set([...reminderTopics.values()].filter((ids) => ids.length > 1).flat());
|
|
486
|
+
for (const source of enabledPerceptions.filter((source2) => conflictingPerceptions.has(source2.id))) {
|
|
487
|
+
capabilityWarnings.push({
|
|
488
|
+
code: "CAPABILITY_NOT_LOADED",
|
|
489
|
+
capability_type: "perception",
|
|
490
|
+
source: hubPerceptionIds.has(source.id) ? "hub" : "local",
|
|
491
|
+
stage: "selection",
|
|
492
|
+
id: source.id,
|
|
493
|
+
reason: `perception_topic_conflict:${source.reminder.topic}:${reminderTopics.get(source.reminder.topic).join(",")}`
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
const reflexBindings = enabledPerceptions.filter(isSupportedPerceptionSource).flatMap((source) => Object.entries(source.module?.behaviors ?? {}).map(([key, binding]) => {
|
|
497
|
+
const id = resolveReactionBehavior(binding, behaviorEntries.map((entry) => ({
|
|
498
|
+
id: entry.id,
|
|
499
|
+
declaredId: enabledBehaviors.find((source2) => source2.id === entry.id)?.declaredId,
|
|
500
|
+
resourceId: entry.resource_id,
|
|
501
|
+
loadable: entry.loadable
|
|
502
|
+
})));
|
|
503
|
+
if (!id) configurationWarnings.push({
|
|
504
|
+
code: "PERCEPTION_BEHAVIOR_NOT_LOADED",
|
|
505
|
+
perception_id: source.id,
|
|
506
|
+
binding: key,
|
|
507
|
+
behavior_name: binding.name,
|
|
508
|
+
message: `Equip the paired strategy ${binding.name}; perception observation and notifications remain available.`
|
|
509
|
+
});
|
|
510
|
+
return {
|
|
511
|
+
perception_id: source.id,
|
|
512
|
+
binding: key,
|
|
513
|
+
behavior_id: id ?? binding.name,
|
|
514
|
+
available: !!id,
|
|
515
|
+
default_enabled: false,
|
|
516
|
+
...id ? {} : { reason: "behavior_not_loaded" }
|
|
517
|
+
};
|
|
518
|
+
}));
|
|
519
|
+
const perceptionEntry = (source) => ({
|
|
520
|
+
id: source.id,
|
|
521
|
+
name: source.name,
|
|
522
|
+
description: source.description,
|
|
523
|
+
source: hubPerceptionIds.has(source.id) ? "hub" : "workspace",
|
|
524
|
+
...pluginApiVersionStatus("perception", expectedPerceptionApiVersion(source), source.apiVersion),
|
|
525
|
+
...source.compatibilityError ? { loadable: false, compatibility_error: source.compatibilityError } : {}
|
|
526
|
+
});
|
|
527
|
+
const perceptions = enabledPerceptions.filter((source) => isSupportedPerceptionSource(source) && !conflictingPerceptions.has(source.id)).map(perceptionEntry);
|
|
528
|
+
const incompatiblePerceptions = enabledPerceptions.filter((source) => !isSupportedPerceptionSource(source)).map(perceptionEntry);
|
|
529
|
+
for (const source of enabledPerceptions) {
|
|
530
|
+
if (isSupportedPerceptionSource(source)) continue;
|
|
531
|
+
capabilityWarnings.push(compatibilityWarning(
|
|
532
|
+
"perception",
|
|
533
|
+
hubPerceptionIds.has(source.id) ? "hub" : "local",
|
|
534
|
+
source,
|
|
535
|
+
source.compatibilityError ?? `perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? "missing"}`
|
|
536
|
+
));
|
|
537
|
+
}
|
|
538
|
+
const selectedLocalPerceptionPaths = new Set(localPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
|
|
539
|
+
for (const source of allLocalPerceptions) {
|
|
540
|
+
if (selectedLocalPerceptionPaths.has(resolve(source.sourcePath)) || isSupportedPerceptionSource(source)) continue;
|
|
541
|
+
capabilityWarnings.push(compatibilityWarning(
|
|
542
|
+
"perception",
|
|
543
|
+
"local",
|
|
544
|
+
source,
|
|
545
|
+
source.compatibilityError ?? `perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? "missing"}`
|
|
546
|
+
));
|
|
547
|
+
}
|
|
548
|
+
const disabledTriggers = new Set(gameplay.disabled_triggers);
|
|
549
|
+
const localTriggerDir = getUserDataAccountTriggersDir(workspaceDir, profile);
|
|
550
|
+
const triggerSources = listClawclawTriggerSources(localTriggerDir);
|
|
551
|
+
const enabledTriggers = triggerSources.filter((source) => !disabledTriggers.has(source.id));
|
|
552
|
+
const triggerSourcePaths = new Set(triggerSources.map(({ sourcePath }) => resolve(sourcePath)));
|
|
553
|
+
let expectedLocalTriggers = enabledTriggers.length;
|
|
554
|
+
for (const path of listCapabilityModuleCandidates(localTriggerDir)) {
|
|
555
|
+
if (triggerSourcePaths.has(resolve(path))) continue;
|
|
556
|
+
const diagnostic = diagnoseRejectedCapabilityModule("trigger", path);
|
|
557
|
+
if (diagnostic.declaredId && disabledTriggers.has(diagnostic.declaredId)) continue;
|
|
558
|
+
expectedLocalTriggers += 1;
|
|
559
|
+
capabilityWarnings.push(warningFromStaticDiagnostic("trigger", "local", diagnostic));
|
|
560
|
+
}
|
|
561
|
+
const availableBehaviorIds = new Set(behaviors.map(({ id }) => id));
|
|
562
|
+
const triggerEntry = (source) => {
|
|
563
|
+
const behaviorId = gameplay.triggers[source.id]?.behavior ?? source.manifest.defaultBehavior;
|
|
564
|
+
const versionCompatible = source.apiVersion === TRIGGER_PLUGIN_API_VERSION;
|
|
565
|
+
const bindingAvailable = availableBehaviorIds.has(behaviorId);
|
|
566
|
+
const loadable = versionCompatible && bindingAvailable;
|
|
567
|
+
return {
|
|
568
|
+
id: source.id,
|
|
569
|
+
name: source.name,
|
|
570
|
+
description: source.description,
|
|
571
|
+
api_version: source.apiVersion,
|
|
572
|
+
expected_api_version: TRIGGER_PLUGIN_API_VERSION,
|
|
573
|
+
loadable,
|
|
574
|
+
...loadable ? {} : {
|
|
575
|
+
compatibility_error: versionCompatible ? `trigger_binding_unavailable:${behaviorId}` : `trigger_api_version_unsupported:expected=${TRIGGER_PLUGIN_API_VERSION}:received=${source.apiVersion}`
|
|
576
|
+
},
|
|
577
|
+
behavior_id: behaviorId,
|
|
578
|
+
source: "local"
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
const triggerEntries = enabledTriggers.map(triggerEntry);
|
|
582
|
+
const triggers = triggerEntries.filter(({ loadable }) => loadable);
|
|
583
|
+
const incompatibleTriggers = triggerEntries.filter(({ loadable }) => !loadable);
|
|
584
|
+
for (const entry of incompatibleTriggers) {
|
|
585
|
+
const source = enabledTriggers.find(({ id }) => id === entry.id);
|
|
586
|
+
capabilityWarnings.push(compatibilityWarning(
|
|
587
|
+
"trigger",
|
|
588
|
+
"local",
|
|
589
|
+
source,
|
|
590
|
+
String(entry.compatibility_error)
|
|
591
|
+
));
|
|
592
|
+
}
|
|
593
|
+
inspectDone?.();
|
|
594
|
+
const projectDone = startupSpan("prepare.skill_persona_projection");
|
|
595
|
+
const skillChanges = activeWorkspace ? (dependencies.skillSync ?? syncAgentWorkspaceSkills)(workspaceDir, profile, activeWorkspace) : {
|
|
596
|
+
added: [],
|
|
597
|
+
updated: [],
|
|
598
|
+
removed: [],
|
|
599
|
+
unchanged: [],
|
|
600
|
+
failed: [],
|
|
601
|
+
preservedModified: [],
|
|
602
|
+
conflicts: inspectSkillNameConflicts(workspaceDir, profile),
|
|
603
|
+
requiresUserConfirmation: false
|
|
604
|
+
};
|
|
605
|
+
const hubPersonaItem = activeWorkspace?.items.persona[0];
|
|
606
|
+
if (hubPersonaItem && snapshot.persona.source !== "local" && (snapshot.persona.source !== "hub" || snapshot.persona.resource_id !== hubPersonaItem.resourceId || snapshot.persona.exists !== true)) {
|
|
607
|
+
capabilityWarnings.push({
|
|
608
|
+
code: "CAPABILITY_NOT_LOADED",
|
|
609
|
+
capability_type: "persona",
|
|
610
|
+
source: "hub",
|
|
611
|
+
reason: "persona_file_unavailable",
|
|
612
|
+
stage: "selection",
|
|
613
|
+
resource_id: hubPersonaItem.resourceId,
|
|
614
|
+
version_id: hubPersonaItem.versionId,
|
|
615
|
+
path: snapshot.persona.path
|
|
616
|
+
});
|
|
617
|
+
} else if (snapshot.persona.source === "local" && snapshot.persona.exists !== true) {
|
|
618
|
+
capabilityWarnings.push({
|
|
619
|
+
code: "CAPABILITY_NOT_LOADED",
|
|
620
|
+
capability_type: "persona",
|
|
621
|
+
source: "local",
|
|
622
|
+
reason: "persona_file_unavailable",
|
|
623
|
+
stage: "selection",
|
|
624
|
+
...snapshot.persona.id ? { id: snapshot.persona.id } : {},
|
|
625
|
+
path: snapshot.persona.path
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
if (hubPersonaItem && snapshot.persona.source === "hub" && snapshot.persona.path && snapshot.persona.exists) {
|
|
629
|
+
registerDiscoveredCapability(workspaceDir, profile, {
|
|
630
|
+
type: "persona",
|
|
631
|
+
path: snapshot.persona.path,
|
|
632
|
+
runtimeId: basename(snapshot.persona.path, extname(snapshot.persona.path)),
|
|
633
|
+
title: hubPersonaItem.title,
|
|
634
|
+
description: hubPersonaItem.description,
|
|
635
|
+
initialDescription: `Persona ${basename(snapshot.persona.path)}`,
|
|
636
|
+
selectedByHub: true,
|
|
637
|
+
hub: {
|
|
638
|
+
resourceId: hubPersonaItem.resourceId,
|
|
639
|
+
versionId: hubPersonaItem.versionId,
|
|
640
|
+
workspaceItemId: hubPersonaItem.workspaceItemId,
|
|
641
|
+
publisher: hubPersonaItem.hub?.publisher ?? "community",
|
|
642
|
+
baseSha256: hubPersonaItem.sourceFiles[0]?.sha256,
|
|
643
|
+
localOriginUnrecognized: hubPersonaItem.resolution === "local_origin_unrecognized" ? true : void 0
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
projectDone?.();
|
|
648
|
+
const cloudChanges = completedSync ?? (activeWorkspace && !inventoryReadFailed ? await timeStartup("prepare.cloud_upload", () => (dependencies.cloudSync ?? syncCapabilitiesToCloud)(
|
|
649
|
+
workspaceDir,
|
|
650
|
+
profile,
|
|
651
|
+
activeWorkspace
|
|
652
|
+
)) : void 0);
|
|
653
|
+
if (!completedSync && cloudChanges && (cloudChanges.uploaded.length > 0 || cloudChanges.equipmentChanged || cloudChanges.failed.some((item) => item.action === "equipment"))) {
|
|
654
|
+
firstSkillChanges = skillChanges;
|
|
655
|
+
try {
|
|
656
|
+
strategyLifecycles.clear();
|
|
657
|
+
const updatedInventory = await timeStartup("prepare.hub_inventory", () => (dependencies.cloudWorkspaceUpdates ?? syncInstalledCapabilityUpdates)(profile));
|
|
658
|
+
workspaceResult = await timeStartup("prepare.workspace_sync", () => (dependencies.workspaceSync ?? syncAgentWorkspaceConfig)(workspaceDir, profile, {
|
|
659
|
+
workspaceInventory: updatedInventory.inventoryComplete ? updatedInventory.inventory : void 0
|
|
660
|
+
}));
|
|
661
|
+
activeWorkspace = workspaceResult.snapshot;
|
|
662
|
+
workspaceSyncStatus = workspaceResult.status;
|
|
663
|
+
if (updatedInventory.inventoryComplete) {
|
|
664
|
+
const presence = reconcileCapabilityWorkspacePresence(workspaceDir, profile, updatedInventory.inventory, activeWorkspace);
|
|
665
|
+
cloudPresence = {
|
|
666
|
+
deactivated: [...cloudPresence.deactivated, ...presence.deactivated],
|
|
667
|
+
restored: [...cloudPresence.restored, ...presence.restored],
|
|
668
|
+
inactiveResourceIds: presence.inactiveResourceIds
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
activeWorkspace = filterInactiveAgentWorkspaceSnapshot(workspaceDir, profile, activeWorkspace, cloudPresence.inactiveResourceIds);
|
|
672
|
+
} catch (error) {
|
|
673
|
+
workspaceSyncStatus = "stale_fallback";
|
|
674
|
+
workspaceSyncError = `post_upload_workspace_refresh_failed:${error instanceof Error ? error.message : String(error)}`;
|
|
675
|
+
console.error(`[clawclaw-cli] ${workspaceSyncError}`);
|
|
676
|
+
}
|
|
677
|
+
return renderFinalContext(cloudChanges);
|
|
678
|
+
}
|
|
679
|
+
let participation;
|
|
680
|
+
try {
|
|
681
|
+
const client = (dependencies.clientFactory ?? (() => GameClient.fromAuth()))();
|
|
682
|
+
participation = await timeStartup("prepare.participation", () => queryGameParticipationStatus(client));
|
|
683
|
+
} catch (error) {
|
|
684
|
+
participation = {
|
|
685
|
+
schema: GAME_STATUS_SCHEMA,
|
|
686
|
+
status: "unknown",
|
|
687
|
+
queue_status: null
|
|
688
|
+
};
|
|
689
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
690
|
+
console.error(`[clawclaw-cli] participation status unavailable: ${message}`);
|
|
691
|
+
}
|
|
692
|
+
const capabilitySummary = {
|
|
693
|
+
behavior: {
|
|
694
|
+
selected_hub: activeWorkspace?.items.strategy.length ?? 0,
|
|
695
|
+
eligible_local: expectedLocalBehaviors,
|
|
696
|
+
available: behaviors.length,
|
|
697
|
+
warnings: capabilityWarnings.filter(({ capability_type }) => capability_type === "behavior").length
|
|
698
|
+
},
|
|
699
|
+
perception: {
|
|
700
|
+
selected_hub: activeWorkspace?.items.perception.length ?? 0,
|
|
701
|
+
eligible_local: expectedLocalPerceptions,
|
|
702
|
+
available: perceptions.length,
|
|
703
|
+
warnings: capabilityWarnings.filter(({ capability_type }) => capability_type === "perception").length
|
|
704
|
+
},
|
|
705
|
+
trigger: {
|
|
706
|
+
selected_hub: 0,
|
|
707
|
+
eligible_local: expectedLocalTriggers,
|
|
708
|
+
available: triggers.length,
|
|
709
|
+
warnings: capabilityWarnings.filter(({ capability_type }) => capability_type === "trigger").length
|
|
710
|
+
},
|
|
711
|
+
persona: {
|
|
712
|
+
selected_hub: activeWorkspace?.items.persona.length ?? 0,
|
|
713
|
+
selected_local: snapshot.persona.source === "local" ? 1 : 0,
|
|
714
|
+
available: snapshot.persona.exists ? 1 : 0,
|
|
715
|
+
warnings: capabilityWarnings.filter(({ capability_type }) => capability_type === "persona").length
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
const behaviorSourceById = new Map(enabledBehaviors.map((source) => [source.id, source]));
|
|
719
|
+
const perceptionSourceById = new Map(enabledPerceptions.map((source) => [source.id, source]));
|
|
720
|
+
const triggerSourceById = new Map(enabledTriggers.map((source) => [source.id, source]));
|
|
721
|
+
const skillChangeSummary = compactSkillChanges(firstSkillChanges ? {
|
|
722
|
+
...skillChanges,
|
|
723
|
+
added: [.../* @__PURE__ */ new Set([...firstSkillChanges.added, ...skillChanges.added])],
|
|
724
|
+
updated: [.../* @__PURE__ */ new Set([...firstSkillChanges.updated, ...skillChanges.updated])],
|
|
725
|
+
removed: [.../* @__PURE__ */ new Set([...firstSkillChanges.removed, ...skillChanges.removed])],
|
|
726
|
+
failed: [...firstSkillChanges.failed, ...skillChanges.failed],
|
|
727
|
+
skipped: skillChanges.skipped
|
|
728
|
+
} : skillChanges);
|
|
729
|
+
const cloudConflicts = [...cloudRefreshChanges.conflicts, ...cloudChanges?.conflicts ?? []].filter((value, index, values) => values.findIndex((candidate) => candidate.type === value.type && candidate.id === value.id && candidate.resource_id === value.resource_id) === index).map((value) => {
|
|
730
|
+
const entry = capabilityEntryForHubResource(workspaceDir, profile, value.type, value.resource_id);
|
|
731
|
+
return { ...value, ...entry ? {
|
|
732
|
+
selection_ref: capabilitySelectionRef(entry),
|
|
733
|
+
working_copy_path: capabilityWorkspacePath(workspaceDir, profile, entry)
|
|
734
|
+
} : {} };
|
|
735
|
+
});
|
|
736
|
+
const cloudFailures = [...cloudRefreshChanges.failed, ...cloudChanges?.failed ?? []];
|
|
737
|
+
const forkReplacements = newForkReplacements.map((item) => {
|
|
738
|
+
const type = item.resourceType === "strategy" ? "behavior" : item.resourceType;
|
|
739
|
+
const entry = capabilityEntryForHubResource(workspaceDir, profile, type, item.resourceId);
|
|
740
|
+
const finalItem = Object.values(activeWorkspace?.items ?? {}).flat().find((current) => current.resourceId === item.resourceId);
|
|
741
|
+
return {
|
|
742
|
+
type,
|
|
743
|
+
id: entry?.runtimeId,
|
|
744
|
+
resource_id: item.resourceId,
|
|
745
|
+
...entry ? { selection_ref: capabilitySelectionRef(entry) } : {},
|
|
746
|
+
forked_from_resource_id: item.forkReconciliation.parentResourceId,
|
|
747
|
+
from_id: item.forkReconciliation.parentOperationName,
|
|
748
|
+
resolution: finalItem?.resolution ?? item.resolution
|
|
749
|
+
};
|
|
750
|
+
});
|
|
751
|
+
const workspaceVersionUpdates = mergeWorkspaceVersionUpdates(
|
|
752
|
+
cloudWorkspaceUpdates.updated,
|
|
753
|
+
inferredWorkspaceVersionUpdates(activeWorkspace, workspaceResult?.previous)
|
|
754
|
+
);
|
|
755
|
+
const cloudChangeSummary = workspaceVersionUpdates.length > 0 || cloudWorkspaceUpdates.failed.length > 0 || cloudRefreshChanges.downloaded.length > 0 || (cloudChanges?.uploaded.length ?? 0) > 0 || (cloudChanges?.skipped.length ?? 0) > 0 || cloudConflicts.length > 0 || cloudFailures.length > 0 || cloudPresence.deactivated.length > 0 || cloudPresence.restored.length > 0 || forkReplacements.length > 0 ? {
|
|
756
|
+
workspace_updated: workspaceVersionUpdates,
|
|
757
|
+
workspace_update_failed: cloudWorkspaceUpdates.failed,
|
|
758
|
+
downloaded: cloudRefreshChanges.downloaded,
|
|
759
|
+
uploaded: cloudChanges?.uploaded ?? [],
|
|
760
|
+
skipped: cloudChanges?.skipped ?? [],
|
|
761
|
+
conflicts: cloudConflicts,
|
|
762
|
+
failed: cloudFailures,
|
|
763
|
+
deactivated: cloudPresence.deactivated,
|
|
764
|
+
restored: cloudPresence.restored,
|
|
765
|
+
...forkReplacements.length ? { fork_replacements: forkReplacements } : {},
|
|
766
|
+
unchanged: cloudChanges?.unchanged ?? []
|
|
767
|
+
} : void 0;
|
|
768
|
+
const selectionRequired = pendingCapabilitySelections(workspaceDir, profile);
|
|
769
|
+
const blockedSkillNames = skillConflictNames(skillChanges.conflicts ?? []);
|
|
770
|
+
const reservedSkillPaths = new Set(discoveredLocal.reservedSkills.map((skill) => skill.path));
|
|
771
|
+
const skills = [...new Set(Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries).filter((entry) => entry.type === "skill" && entry.selection === "equipped" && !blockedSkillNames.has(skillNameKey(entry.runtimeId)) && !entry.hub?.cloudStatus && !isPackageManagedSkill(entry.runtimeId) && !reservedSkillPaths.has(capabilityWorkspacePath(workspaceDir, profile, entry))).map((entry) => entry.runtimeId).concat((skillChanges.conflicts ?? []).flatMap((item) => item.active ? [item.active.id ?? item.active.name] : [])))].sort();
|
|
772
|
+
const output = {
|
|
773
|
+
startup: summarizeStartupBlockers(selectionRequired.map((entry) => ({
|
|
774
|
+
type: entry.type,
|
|
775
|
+
id: entry.runtimeId,
|
|
776
|
+
selection_ref: capabilitySelectionRef(entry)
|
|
777
|
+
})), cloudConflicts, cloudFailures),
|
|
778
|
+
sync: {
|
|
779
|
+
status: workspaceSyncStatus,
|
|
780
|
+
revision: activeWorkspace?.revision ?? null,
|
|
781
|
+
...workspaceSyncError ? { error: workspaceSyncError } : {}
|
|
782
|
+
},
|
|
783
|
+
...skillChangeSummary || cloudChangeSummary || discoveredLocal.reservedSkills.length ? {
|
|
784
|
+
changes: {
|
|
785
|
+
...discoveredLocal.reservedSkills.length ? { skipped_local_skills: discoveredLocal.reservedSkills } : {},
|
|
786
|
+
...skillChangeSummary ? { skills: skillChangeSummary } : {},
|
|
787
|
+
...cloudChangeSummary ? { cloud_sync: cloudChangeSummary } : {}
|
|
788
|
+
}
|
|
789
|
+
} : {},
|
|
790
|
+
capabilities: {
|
|
791
|
+
summary: capabilitySummary,
|
|
792
|
+
skills,
|
|
793
|
+
behaviors: behaviors.map((entry) => {
|
|
794
|
+
const source = behaviorSourceById.get(entry.id);
|
|
795
|
+
const localized = resolveClawclawResourceMetadata(source, LOAD_DISPLAY_LOCALE);
|
|
796
|
+
return {
|
|
797
|
+
id: entry.id,
|
|
798
|
+
name: localized.name,
|
|
799
|
+
description: source.description,
|
|
800
|
+
source: entry.source,
|
|
801
|
+
strategy_type: strategyLifecycle(source.sourcePath),
|
|
802
|
+
...source.management.versionNumber ? {
|
|
803
|
+
version_number: source.management.versionNumber,
|
|
804
|
+
version_description: source.management.versionDescription ?? ""
|
|
805
|
+
} : {}
|
|
806
|
+
};
|
|
807
|
+
}),
|
|
808
|
+
perceptions: perceptions.map((entry) => {
|
|
809
|
+
const source = perceptionSourceById.get(entry.id);
|
|
810
|
+
const localized = resolveClawclawResourceMetadata({ ...source.manifest, display: source.display }, LOAD_DISPLAY_LOCALE);
|
|
811
|
+
return {
|
|
812
|
+
id: entry.id,
|
|
813
|
+
name: localized.name,
|
|
814
|
+
description: source.description,
|
|
815
|
+
source: entry.source,
|
|
816
|
+
...reflexBindings.some((binding) => binding.perception_id === entry.id) ? { reflex_bindings: reflexBindings.filter((binding) => binding.perception_id === entry.id) } : {}
|
|
817
|
+
};
|
|
818
|
+
}),
|
|
819
|
+
triggers: triggers.map((entry) => {
|
|
820
|
+
const source = triggerSourceById.get(entry.id);
|
|
821
|
+
const localized = resolveClawclawResourceMetadata(source.manifest, LOAD_DISPLAY_LOCALE);
|
|
822
|
+
return {
|
|
823
|
+
id: entry.id,
|
|
824
|
+
name: localized.name,
|
|
825
|
+
description: localized.description,
|
|
826
|
+
source: entry.source,
|
|
827
|
+
behavior_id: entry.behavior_id
|
|
828
|
+
};
|
|
829
|
+
}),
|
|
830
|
+
warnings: capabilityWarnings.map(compactCapabilityWarning),
|
|
831
|
+
selection_required: selectionRequired.map((entry) => ({
|
|
832
|
+
type: entry.type,
|
|
833
|
+
id: entry.runtimeId,
|
|
834
|
+
declared_id: entry.declaredId ?? entry.runtimeId,
|
|
835
|
+
selection_ref: capabilitySelectionRef(entry),
|
|
836
|
+
working_copy_path: capabilityWorkspacePath(workspaceDir, profile, entry),
|
|
837
|
+
title: entry.title,
|
|
838
|
+
...entry.hub ? {
|
|
839
|
+
resource_id: entry.hub.resourceId,
|
|
840
|
+
publisher: entry.hub.publisher,
|
|
841
|
+
owner_id: entry.hub.ownerId,
|
|
842
|
+
owner_name: entry.hub.ownerName
|
|
843
|
+
} : {},
|
|
844
|
+
strategy_type: entry.strategyLifecycle,
|
|
845
|
+
action: `Choose once with ccl capability equip ${capabilitySelectionRef(entry)} or ccl capability unequip ${capabilitySelectionRef(entry)}.`
|
|
846
|
+
}))
|
|
847
|
+
},
|
|
848
|
+
configuration_warnings: compactConfigurationWarnings(configurationWarnings),
|
|
849
|
+
participation: compactParticipation(participation)
|
|
850
|
+
};
|
|
851
|
+
const report = {
|
|
852
|
+
sync: output.sync,
|
|
853
|
+
changes: output.changes,
|
|
854
|
+
capabilities: output.capabilities,
|
|
855
|
+
configuration_warnings: output.configuration_warnings,
|
|
856
|
+
persona_available: snapshot.persona.exists
|
|
857
|
+
};
|
|
858
|
+
const { prepared_at } = timeStartup("prepare.save_report", () => saveStartupContext(workspaceDir, profile, report));
|
|
859
|
+
const startup = { schema: PREPARE_SCHEMA, startup: output.startup, participation: output.participation };
|
|
860
|
+
if (full) {
|
|
861
|
+
console.log(JSON.stringify({ ...startup, ...formatLoadReport(loadContext(authStore), { ...report, prepared_at }) }, null, 2));
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
const equipmentConflicts = cloudFailures.filter((value) => value.action === "equipment" && "code" in value && value.code === "SKILL_NAME_CONFLICT");
|
|
865
|
+
console.log(JSON.stringify({
|
|
866
|
+
...startup,
|
|
867
|
+
...selectionRequired.length ? { capabilities: { selection_required: output.capabilities.selection_required } } : {},
|
|
868
|
+
...cloudConflicts.length || equipmentConflicts.length ? {
|
|
869
|
+
changes: { cloud_sync: { conflicts: cloudConflicts, failed: equipmentConflicts } }
|
|
870
|
+
} : {}
|
|
871
|
+
}, null, 2));
|
|
872
|
+
};
|
|
873
|
+
await renderFinalContext();
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
export {
|
|
877
|
+
createPrepareCommand
|
|
878
|
+
};
|