@adhdev/daemon-core 0.9.82-rc.41 → 0.9.82-rc.410
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/dist/boot/daemon-lifecycle.d.ts +9 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +68 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +200 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +126 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +5 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +74 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +14 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands-debug-bundle.d.ts +14 -0
- package/dist/commands/chat-commands-read.d.ts +7 -0
- package/dist/commands/chat-commands-scope.d.ts +39 -0
- package/dist/commands/chat-commands-shared.d.ts +33 -0
- package/dist/commands/chat-commands-write.d.ts +14 -0
- package/dist/commands/chat-commands.d.ts +10 -23
- package/dist/commands/cli-manager.d.ts +15 -1
- package/dist/commands/handler.d.ts +125 -0
- package/dist/commands/high-family/index.d.ts +3 -0
- package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
- package/dist/commands/high-family/mesh-events.d.ts +2 -0
- package/dist/commands/high-family/mesh-status.d.ts +2 -0
- package/dist/commands/high-family/types.d.ts +60 -0
- package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
- package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
- package/dist/commands/low-family/diagnostics.d.ts +2 -0
- package/dist/commands/low-family/index.d.ts +3 -0
- package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
- package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
- package/dist/commands/low-family/notification.d.ts +2 -0
- package/dist/commands/low-family/refine-config.d.ts +2 -0
- package/dist/commands/low-family/session-host.d.ts +2 -0
- package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
- package/dist/commands/low-family/status-meta.d.ts +2 -0
- package/dist/commands/low-family/types.d.ts +33 -0
- package/dist/commands/med-family/cli-agent.d.ts +2 -0
- package/dist/commands/med-family/fast-forward.d.ts +2 -0
- package/dist/commands/med-family/ide.d.ts +10 -0
- package/dist/commands/med-family/index.d.ts +3 -0
- package/dist/commands/med-family/mesh-crud.d.ts +2 -0
- package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
- package/dist/commands/med-family/mesh-queue.d.ts +2 -0
- package/dist/commands/med-family/mesh-restart.d.ts +2 -0
- package/dist/commands/med-family/types.d.ts +116 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +256 -2
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +77 -1
- package/dist/config/mesh-json-config.d.ts +299 -0
- package/dist/daemon/dev-server.d.ts +0 -2
- package/dist/detection/ide-detector.d.ts +13 -0
- package/dist/detection/win32-ide-version.d.ts +37 -0
- package/dist/git/change-impact-config.d.ts +159 -0
- package/dist/git/git-commands.d.ts +11 -1
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +57 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/git-worktree.d.ts +71 -1
- package/dist/git/index.d.ts +3 -1
- package/dist/index.d.ts +57 -13
- package/dist/index.js +46445 -17229
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46052 -16978
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/logging/log-redactor.d.ts +24 -0
- package/dist/logging/log-tail-reader.d.ts +81 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +89 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +174 -0
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-event-classify.d.ts +5 -0
- package/dist/mesh/mesh-event-forwarding.d.ts +19 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +4 -0
- package/dist/mesh/mesh-events-pending.d.ts +55 -0
- package/dist/mesh/mesh-events-stale.d.ts +61 -0
- package/dist/mesh/mesh-events-utils.d.ts +75 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-init.d.ts +86 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -4
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-missions.d.ts +164 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +95 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +65 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +447 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/dist/mesh/mesh-work-queue.d.ts +281 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +216 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +145 -0
- package/dist/providers/acp-provider-instance.d.ts +5 -0
- package/dist/providers/approval-utils.d.ts +20 -0
- package/dist/providers/chat-message-normalization.d.ts +31 -1
- package/dist/providers/cli-provider-instance.d.ts +197 -3
- package/dist/providers/contracts.d.ts +139 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/manual-attendance.d.ts +63 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/constants.d.ts +12 -0
- package/dist/providers/native-history/dispatcher.d.ts +27 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +14 -0
- package/dist/providers/provider-instance.d.ts +23 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +91 -0
- package/dist/providers/spec/cli-adapter.d.ts +223 -0
- package/dist/providers/spec/evaluator.d.ts +45 -0
- package/dist/providers/spec/fsm-driver.d.ts +407 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +76 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +174 -0
- package/dist/providers/spec/native-history-executor.d.ts +41 -0
- package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/types.d.ts +222 -0
- package/dist/providers/status-monitor.d.ts +7 -7
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/providers/working-dir.d.ts +17 -0
- package/dist/repo-mesh-types.d.ts +420 -13
- package/dist/runtime-defaults.d.ts +2 -0
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +59 -2
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +26 -0
- package/dist/system/hash.d.ts +8 -0
- package/dist/system/load-better-sqlite3.d.ts +21 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/agent-stream/provider-adapter.ts +1 -1
- package/src/boot/daemon-lifecycle.ts +63 -12
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +3 -1
- package/src/cli-adapter-types.ts +68 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1246 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +914 -1144
- package/src/cli-adapters/provider-cli-parse.d.ts +2 -0
- package/src/cli-adapters/provider-cli-parse.ts +19 -0
- package/src/cli-adapters/provider-cli-runtime.ts +56 -7
- package/src/cli-adapters/provider-cli-shared.d.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.ts +121 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +90 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +63 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/WINDOWS-UPGRADE-LOCK-FAILURE.md +198 -0
- package/src/commands/chat-commands-debug-bundle.ts +398 -0
- package/src/commands/chat-commands-read.ts +2327 -0
- package/src/commands/chat-commands-scope.ts +54 -0
- package/src/commands/chat-commands-shared.ts +114 -0
- package/src/commands/chat-commands-write.ts +891 -0
- package/src/commands/chat-commands.ts +19 -1841
- package/src/commands/cli-manager.ts +527 -26
- package/src/commands/handler.ts +841 -2
- package/src/commands/high-family/index.ts +28 -0
- package/src/commands/high-family/mesh-coordinator-launch.ts +673 -0
- package/src/commands/high-family/mesh-events.ts +80 -0
- package/src/commands/high-family/mesh-status.ts +678 -0
- package/src/commands/high-family/types.ts +76 -0
- package/src/commands/low-family/coordinator-prompt.ts +72 -0
- package/src/commands/low-family/daemon-lifecycle.ts +107 -0
- package/src/commands/low-family/diagnostics.ts +57 -0
- package/src/commands/low-family/index.ts +37 -0
- package/src/commands/low-family/mesh-ledger.ts +62 -0
- package/src/commands/low-family/mesh-node-logs.ts +87 -0
- package/src/commands/low-family/notification.ts +116 -0
- package/src/commands/low-family/refine-config.ts +106 -0
- package/src/commands/low-family/session-host.ts +274 -0
- package/src/commands/low-family/spec-providerdev.ts +217 -0
- package/src/commands/low-family/status-meta.ts +112 -0
- package/src/commands/low-family/types.ts +39 -0
- package/src/commands/med-family/cli-agent.ts +238 -0
- package/src/commands/med-family/fast-forward.ts +230 -0
- package/src/commands/med-family/ide.ts +163 -0
- package/src/commands/med-family/index.ts +37 -0
- package/src/commands/med-family/mesh-crud.ts +874 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +131 -0
- package/src/commands/med-family/mesh-restart.ts +92 -0
- package/src/commands/med-family/types.ts +120 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router.ts +2516 -3221
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +310 -45
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +353 -22
- package/src/config/mesh-json-config.ts +617 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +28 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +59 -15
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +767 -48
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +261 -4
- package/src/git/index.ts +17 -0
- package/src/index.ts +171 -12
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/command-log.ts +7 -5
- package/src/logging/log-redactor.ts +100 -0
- package/src/logging/log-tail-reader.ts +341 -0
- package/src/logging/logger.ts +14 -7
- package/src/mesh/contracts.ts +338 -0
- package/src/mesh/coordinator-prompt.ts +381 -33
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +645 -0
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-event-classify.ts +51 -0
- package/src/mesh/mesh-event-forwarding.ts +1773 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +31 -0
- package/src/mesh/mesh-events-pending.ts +590 -0
- package/src/mesh/mesh-events-stale.ts +389 -0
- package/src/mesh/mesh-events-utils.ts +443 -0
- package/src/mesh/mesh-events.ts +32 -1035
- package/src/mesh/mesh-fast-forward.ts +843 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-init.ts +260 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -7
- package/src/mesh/mesh-ledger.ts +596 -102
- package/src/mesh/mesh-missions.ts +322 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-queue-assignment.ts +1738 -0
- package/src/mesh/mesh-reconcile-loop.ts +1726 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1666 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-review-inbox.ts +307 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +1836 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-stats.ts +161 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
- package/src/mesh/mesh-work-queue.ts +1205 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +369 -0
- package/src/providers/acp-provider-instance.ts +43 -10
- package/src/providers/approval-utils.d.ts +5 -0
- package/src/providers/approval-utils.ts +57 -5
- package/src/providers/chat-message-normalization.ts +92 -4
- package/src/providers/cli-provider-instance.ts +1865 -104
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +150 -6
- package/src/providers/extension-provider-instance.ts +12 -7
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +35 -12
- package/src/providers/manual-attendance.ts +85 -0
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/constants.ts +19 -0
- package/src/providers/native-history/dispatcher.ts +339 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +30 -0
- package/src/providers/provider-instance.ts +19 -1
- package/src/providers/provider-loader.ts +668 -50
- package/src/providers/provider-schema.ts +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +235 -0
- package/src/providers/spec/cli-adapter.ts +1056 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1304 -0
- package/src/providers/spec/fsm-evaluator.ts +272 -0
- package/src/providers/spec/fsm-loader.ts +120 -0
- package/src/providers/spec/fsm-types.ts +273 -0
- package/src/providers/spec/native-history-executor.ts +1128 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +262 -0
- package/src/providers/status-monitor.d.ts +7 -7
- package/src/providers/status-monitor.ts +37 -22
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +64 -24
- package/src/providers/working-dir.ts +23 -0
- package/src/repo-mesh-types.ts +629 -14
- package/src/runtime-defaults.ts +39 -0
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.d.ts +8 -0
- package/src/shared-types.ts +64 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +19 -1
- package/src/status/snapshot.ts +95 -26
- package/src/system/hash.ts +23 -0
- package/src/system/host-memory.ts +29 -12
- package/src/system/load-better-sqlite3.ts +68 -0
- package/src/types.ts +5 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
10
10
|
import { join } from 'path';
|
|
11
|
-
import { randomUUID } from 'crypto';
|
|
11
|
+
import { randomBytes, randomUUID } from 'crypto';
|
|
12
|
+
import { shortHash } from '../system/hash.js';
|
|
12
13
|
import { getConfigDir } from './config.js';
|
|
13
14
|
import type {
|
|
14
15
|
LocalMeshConfig,
|
|
@@ -18,8 +19,11 @@ import type {
|
|
|
18
19
|
RepoMeshNodePolicy,
|
|
19
20
|
RepoMeshNodeCapabilities,
|
|
20
21
|
RepoMeshCoordinatorConfig,
|
|
22
|
+
RepoMeshHostMetadata,
|
|
23
|
+
RepoMeshDaemonRole,
|
|
21
24
|
} from '../repo-mesh-types.js';
|
|
22
|
-
import {
|
|
25
|
+
import { mergeAndNormalizePolicy } from '../repo-mesh-types.js';
|
|
26
|
+
import { createDefaultMeshHostMetadata } from '../mesh/mesh-host-ownership.js';
|
|
23
27
|
|
|
24
28
|
// ─── Persistence ────────────────────────────────
|
|
25
29
|
|
|
@@ -33,12 +37,85 @@ function loadMeshConfig(): LocalMeshConfig {
|
|
|
33
37
|
try {
|
|
34
38
|
const raw = JSON.parse(readFileSync(path, 'utf-8'));
|
|
35
39
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
36
|
-
|
|
40
|
+
const config = raw as LocalMeshConfig;
|
|
41
|
+
const migrated = migrateLoadedMeshConfig(config);
|
|
42
|
+
// Persist eagerly when the on-load migration changed anything, so the
|
|
43
|
+
// dead field is gone from disk even on a pure-read path (mesh_status /
|
|
44
|
+
// mesh_list_nodes) that never otherwise mutates the config. Best-effort:
|
|
45
|
+
// a write failure (e.g. read-only fs) must not break reads, so swallow.
|
|
46
|
+
if (migrated) {
|
|
47
|
+
try {
|
|
48
|
+
saveMeshConfig(config);
|
|
49
|
+
} catch {
|
|
50
|
+
// keep the in-memory strip; disk converges on the next mutating op
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return config;
|
|
37
54
|
} catch {
|
|
38
55
|
return { meshes: [] };
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
|
|
59
|
+
/**
|
|
60
|
+
* In-place migration applied to every loaded meshes.json. Strips data that
|
|
61
|
+
* outlived the feature that wrote it so the persisted config converges on the
|
|
62
|
+
* current schema the next time it is saved.
|
|
63
|
+
*
|
|
64
|
+
* Currently: drops the dead `role` field from each node policy's providerRoles
|
|
65
|
+
* entries. providerRoles is retained for its `maxParallel` per-(node, provider)
|
|
66
|
+
* cap, but the routing `role` was removed (routing is governed solely by
|
|
67
|
+
* required_tags). A meshes.json written before the removal still carries
|
|
68
|
+
* `role: "validator"` etc.; this drops it on load so mesh_status / mesh_list_nodes
|
|
69
|
+
* never surface the dead field and the next saveMeshConfig() persists it gone.
|
|
70
|
+
*
|
|
71
|
+
* Returns true when the config was mutated (caller may persist eagerly).
|
|
72
|
+
*/
|
|
73
|
+
function migrateLoadedMeshConfig(config: LocalMeshConfig): boolean {
|
|
74
|
+
let changed = false;
|
|
75
|
+
for (const mesh of config.meshes) {
|
|
76
|
+
if (!mesh || !Array.isArray(mesh.nodes)) continue;
|
|
77
|
+
for (const node of mesh.nodes) {
|
|
78
|
+
if (stripDeadRoleFromProviderRoles(node?.policy)) changed = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return changed;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Drop the legacy `role` field from each providerRoles entry of a node policy,
|
|
86
|
+
* in place. Keeps providerType + maxParallel (the still-meaningful per-(node,
|
|
87
|
+
* provider) cap). Defensive against malformed entries — non-object items are
|
|
88
|
+
* left untouched. Returns true when at least one `role` field was removed.
|
|
89
|
+
*/
|
|
90
|
+
function stripDeadRoleFromProviderRoles(policy: unknown): boolean {
|
|
91
|
+
if (!policy || typeof policy !== 'object') return false;
|
|
92
|
+
const roles = (policy as { providerRoles?: unknown }).providerRoles;
|
|
93
|
+
if (!Array.isArray(roles)) return false;
|
|
94
|
+
let changed = false;
|
|
95
|
+
for (const entry of roles) {
|
|
96
|
+
if (entry && typeof entry === 'object' && !Array.isArray(entry)
|
|
97
|
+
&& Object.prototype.hasOwnProperty.call(entry, 'role')) {
|
|
98
|
+
delete (entry as Record<string, unknown>).role;
|
|
99
|
+
changed = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return changed;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function normalizeCapabilityTags(value: unknown): string[] | undefined {
|
|
106
|
+
if (!Array.isArray(value)) return undefined;
|
|
107
|
+
const seen = new Set<string>();
|
|
108
|
+
const tags = value
|
|
109
|
+
.map(tag => typeof tag === 'string' ? tag.trim() : '')
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.filter(tag => {
|
|
112
|
+
if (seen.has(tag)) return false;
|
|
113
|
+
seen.add(tag);
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
return tags.length ? tags : undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
42
119
|
function saveMeshConfig(config: LocalMeshConfig): void {
|
|
43
120
|
const path = getMeshConfigPath();
|
|
44
121
|
writeFileSync(path, JSON.stringify(config, null, 2), { encoding: 'utf-8', mode: 0o600 });
|
|
@@ -74,24 +151,11 @@ export function normalizeRepoIdentity(remoteUrl: string): string {
|
|
|
74
151
|
|
|
75
152
|
// ─── CRUD Operations ────────────────────────────
|
|
76
153
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!['block', 'warn', 'checkpoint_then_continue'].includes(policy.dirtyWorkspaceBehavior)) {
|
|
83
|
-
policy.dirtyWorkspaceBehavior = 'warn';
|
|
84
|
-
}
|
|
85
|
-
const maxParallelTasks = Number(policy.maxParallelTasks);
|
|
86
|
-
policy.maxParallelTasks = Number.isFinite(maxParallelTasks) ? Math.max(1, Math.min(8, Math.floor(maxParallelTasks))) : 2;
|
|
87
|
-
if (!SESSION_CLEANUP_MODES.has(String(policy.sessionCleanupOnNodeRemove))) {
|
|
88
|
-
policy.sessionCleanupOnNodeRemove = 'preserve';
|
|
89
|
-
}
|
|
90
|
-
if (!SPAWNED_SESSION_VISIBILITY_MODES.has(String(policy.spawnedSessionVisibility))) {
|
|
91
|
-
policy.spawnedSessionVisibility = 'visible';
|
|
92
|
-
}
|
|
93
|
-
return policy;
|
|
94
|
-
}
|
|
154
|
+
// Single source of truth for default+merge+per-field normalization is
|
|
155
|
+
// mergeAndNormalizePolicy in repo-mesh-types.ts. This thin alias keeps the local
|
|
156
|
+
// call sites (createMesh/updateMesh) reading naturally while ensuring config
|
|
157
|
+
// writes go through the exact same normalizer the scheduler/display paths use.
|
|
158
|
+
const mergeMeshPolicy = mergeAndNormalizePolicy;
|
|
95
159
|
|
|
96
160
|
export function listMeshes(): LocalMeshEntry[] {
|
|
97
161
|
return loadMeshConfig().meshes;
|
|
@@ -112,6 +176,7 @@ export interface CreateMeshOptions {
|
|
|
112
176
|
defaultBranch?: string;
|
|
113
177
|
policy?: Partial<RepoMeshPolicy>;
|
|
114
178
|
coordinator?: RepoMeshCoordinatorConfig;
|
|
179
|
+
meshHost?: RepoMeshHostMetadata;
|
|
115
180
|
}
|
|
116
181
|
|
|
117
182
|
export function createMesh(opts: CreateMeshOptions): LocalMeshEntry {
|
|
@@ -133,6 +198,7 @@ export function createMesh(opts: CreateMeshOptions): LocalMeshEntry {
|
|
|
133
198
|
defaultBranch: opts.defaultBranch,
|
|
134
199
|
policy: mergeMeshPolicy(undefined, opts.policy),
|
|
135
200
|
coordinator: opts.coordinator || {},
|
|
201
|
+
meshHost: opts.meshHost || createDefaultMeshHostMetadata(),
|
|
136
202
|
nodes: [],
|
|
137
203
|
createdAt: now,
|
|
138
204
|
updatedAt: now,
|
|
@@ -148,6 +214,7 @@ export interface UpdateMeshOptions {
|
|
|
148
214
|
defaultBranch?: string;
|
|
149
215
|
policy?: Partial<RepoMeshPolicy>;
|
|
150
216
|
coordinator?: RepoMeshCoordinatorConfig;
|
|
217
|
+
meshHost?: RepoMeshHostMetadata;
|
|
151
218
|
}
|
|
152
219
|
|
|
153
220
|
export function updateMesh(meshId: string, opts: UpdateMeshOptions): LocalMeshEntry | undefined {
|
|
@@ -159,6 +226,7 @@ export function updateMesh(meshId: string, opts: UpdateMeshOptions): LocalMeshEn
|
|
|
159
226
|
if (opts.defaultBranch !== undefined) mesh.defaultBranch = opts.defaultBranch;
|
|
160
227
|
if (opts.policy) mesh.policy = mergeMeshPolicy(mesh.policy, opts.policy);
|
|
161
228
|
if (opts.coordinator) mesh.coordinator = opts.coordinator;
|
|
229
|
+
if (opts.meshHost) mesh.meshHost = opts.meshHost;
|
|
162
230
|
mesh.updatedAt = new Date().toISOString();
|
|
163
231
|
|
|
164
232
|
saveMeshConfig(config);
|
|
@@ -174,6 +242,240 @@ export function deleteMesh(meshId: string): boolean {
|
|
|
174
242
|
return true;
|
|
175
243
|
}
|
|
176
244
|
|
|
245
|
+
function normalizeManualHostAddress(hostAddress: string): string {
|
|
246
|
+
const normalized = hostAddress.trim().replace(/\/+$/, '');
|
|
247
|
+
if (!normalized) throw new Error('hostAddress required');
|
|
248
|
+
let parsed: URL;
|
|
249
|
+
try {
|
|
250
|
+
parsed = new URL(normalized);
|
|
251
|
+
} catch {
|
|
252
|
+
throw new Error('hostAddress must be a valid http(s) or ws(s) URL');
|
|
253
|
+
}
|
|
254
|
+
if (!['http:', 'https:', 'ws:', 'wss:'].includes(parsed.protocol)) {
|
|
255
|
+
throw new Error('hostAddress must use http, https, ws, or wss');
|
|
256
|
+
}
|
|
257
|
+
return normalized;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function tokenIdForManualPairing(token: string): string {
|
|
261
|
+
return `tok_${shortHash(token)}`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function normalizeTokenExpiry(value: unknown): string | undefined {
|
|
265
|
+
if (typeof value !== 'string' || !value.trim()) return undefined;
|
|
266
|
+
const date = new Date(value);
|
|
267
|
+
if (Number.isNaN(date.getTime())) throw new Error('expiresAt must be a valid ISO date');
|
|
268
|
+
return date.toISOString();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function assertPairingTokenValid(pairing: RepoMeshHostMetadata['pairing'], rawToken: string, nowIso: string): { ok: true; tokenId: string } | { ok: false; reason: string; expectedTokenId?: string; presentedTokenId?: string } {
|
|
272
|
+
const token = rawToken.trim();
|
|
273
|
+
if (!token) return { ok: false, reason: 'token required' };
|
|
274
|
+
const presentedTokenId = tokenIdForManualPairing(token);
|
|
275
|
+
const expectedTokenId = pairing?.tokenId;
|
|
276
|
+
if (!expectedTokenId || pairing?.status === 'not_configured' || pairing?.status === 'revoked') {
|
|
277
|
+
return { ok: false, reason: 'host pairing token is not configured', presentedTokenId };
|
|
278
|
+
}
|
|
279
|
+
if (pairing.expiresAt && new Date(pairing.expiresAt).getTime() <= new Date(nowIso).getTime()) {
|
|
280
|
+
return { ok: false, reason: 'host pairing token expired', expectedTokenId, presentedTokenId };
|
|
281
|
+
}
|
|
282
|
+
if (presentedTokenId !== expectedTokenId) {
|
|
283
|
+
return { ok: false, reason: 'invalid pairing token', expectedTokenId, presentedTokenId };
|
|
284
|
+
}
|
|
285
|
+
return { ok: true, tokenId: presentedTokenId };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface ConfigureMeshHostPairingOptions {
|
|
289
|
+
hostAddress: string;
|
|
290
|
+
token: string;
|
|
291
|
+
now?: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function configureMeshHostPairing(
|
|
295
|
+
meshId: string,
|
|
296
|
+
opts: ConfigureMeshHostPairingOptions,
|
|
297
|
+
): { mesh: LocalMeshEntry; meshHost: RepoMeshHostMetadata; hostAddress: string } | undefined {
|
|
298
|
+
const hostAddress = normalizeManualHostAddress(opts.hostAddress);
|
|
299
|
+
const token = opts.token.trim();
|
|
300
|
+
if (!token) throw new Error('token required');
|
|
301
|
+
|
|
302
|
+
const config = loadMeshConfig();
|
|
303
|
+
const mesh = config.meshes.find(m => m.id === meshId);
|
|
304
|
+
if (!mesh) return undefined;
|
|
305
|
+
|
|
306
|
+
const now = opts.now || new Date().toISOString();
|
|
307
|
+
const previous = mesh.meshHost || createDefaultMeshHostMetadata();
|
|
308
|
+
const meshHost: RepoMeshHostMetadata = {
|
|
309
|
+
...previous,
|
|
310
|
+
role: 'member',
|
|
311
|
+
hostAddress,
|
|
312
|
+
pairing: {
|
|
313
|
+
status: 'pairing',
|
|
314
|
+
tokenId: tokenIdForManualPairing(token),
|
|
315
|
+
lastPairedAt: now,
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
mesh.meshHost = meshHost;
|
|
320
|
+
mesh.updatedAt = now;
|
|
321
|
+
saveMeshConfig(config);
|
|
322
|
+
return { mesh, meshHost, hostAddress };
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface CreateMeshHostPairingTokenOptions {
|
|
326
|
+
token?: string;
|
|
327
|
+
expiresAt?: string;
|
|
328
|
+
now?: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function createMeshHostPairingToken(
|
|
332
|
+
meshId: string,
|
|
333
|
+
opts: CreateMeshHostPairingTokenOptions = {},
|
|
334
|
+
): { mesh: LocalMeshEntry; meshHost: RepoMeshHostMetadata; token: string; tokenId: string; expiresAt?: string } | undefined {
|
|
335
|
+
const config = loadMeshConfig();
|
|
336
|
+
const mesh = config.meshes.find(m => m.id === meshId);
|
|
337
|
+
if (!mesh) return undefined;
|
|
338
|
+
const now = opts.now || new Date().toISOString();
|
|
339
|
+
const token = (opts.token || `mhj_${randomBytes(24).toString('base64url')}`).trim();
|
|
340
|
+
if (!token) throw new Error('token required');
|
|
341
|
+
const tokenId = tokenIdForManualPairing(token);
|
|
342
|
+
const expiresAt = normalizeTokenExpiry(opts.expiresAt);
|
|
343
|
+
const previous = mesh.meshHost || createDefaultMeshHostMetadata();
|
|
344
|
+
if (previous.role === 'member') {
|
|
345
|
+
throw new Error('Mesh Host daemon required to create host pairing tokens; member daemons cannot mint host join tokens.');
|
|
346
|
+
}
|
|
347
|
+
const meshHost: RepoMeshHostMetadata = {
|
|
348
|
+
...previous,
|
|
349
|
+
role: 'host',
|
|
350
|
+
pairing: {
|
|
351
|
+
status: 'pairing',
|
|
352
|
+
tokenId,
|
|
353
|
+
lastPairedAt: now,
|
|
354
|
+
...(expiresAt ? { expiresAt } : {}),
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
mesh.meshHost = meshHost;
|
|
358
|
+
mesh.updatedAt = now;
|
|
359
|
+
saveMeshConfig(config);
|
|
360
|
+
return { mesh, meshHost, token, tokenId, ...(expiresAt ? { expiresAt } : {}) };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface MeshHostJoinMemberNodeInput {
|
|
364
|
+
id?: string;
|
|
365
|
+
workspace: string;
|
|
366
|
+
repoRoot?: string;
|
|
367
|
+
daemonId?: string;
|
|
368
|
+
machineId?: string;
|
|
369
|
+
userOverrides?: Partial<RepoMeshNodeCapabilities>;
|
|
370
|
+
policy?: RepoMeshNodePolicy;
|
|
371
|
+
role?: RepoMeshDaemonRole;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface ApplyMeshHostJoinOptions {
|
|
375
|
+
token: string;
|
|
376
|
+
memberNode: MeshHostJoinMemberNodeInput;
|
|
377
|
+
memberMeshId?: string;
|
|
378
|
+
now?: string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function applyMeshHostJoinRequest(
|
|
382
|
+
meshId: string,
|
|
383
|
+
opts: ApplyMeshHostJoinOptions,
|
|
384
|
+
): { accepted: true; mesh: LocalMeshEntry; meshHost: RepoMeshHostMetadata; node: LocalMeshNodeEntry; tokenId: string } | { accepted: false; mesh?: LocalMeshEntry; meshHost?: RepoMeshHostMetadata; tokenId?: string; reason: string } | undefined {
|
|
385
|
+
const config = loadMeshConfig();
|
|
386
|
+
const mesh = config.meshes.find(m => m.id === meshId);
|
|
387
|
+
if (!mesh) return undefined;
|
|
388
|
+
const now = opts.now || new Date().toISOString();
|
|
389
|
+
const previous = mesh.meshHost || createDefaultMeshHostMetadata();
|
|
390
|
+
if (previous.role === 'member') {
|
|
391
|
+
return { accepted: false, mesh, meshHost: previous, reason: 'Mesh Host daemon required to accept join requests' };
|
|
392
|
+
}
|
|
393
|
+
const meshHost: RepoMeshHostMetadata = { ...previous, role: 'host' };
|
|
394
|
+
const validation = assertPairingTokenValid(meshHost.pairing, opts.token, now);
|
|
395
|
+
if (!validation.ok) {
|
|
396
|
+
mesh.meshHost = {
|
|
397
|
+
...meshHost,
|
|
398
|
+
pairing: {
|
|
399
|
+
...(meshHost.pairing || { status: 'not_configured' as const }),
|
|
400
|
+
status: 'rejected',
|
|
401
|
+
lastRejectedAt: now,
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
mesh.updatedAt = now;
|
|
405
|
+
saveMeshConfig(config);
|
|
406
|
+
return { accepted: false, mesh, meshHost: mesh.meshHost, tokenId: validation.presentedTokenId, reason: validation.reason };
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const workspace = opts.memberNode.workspace.trim();
|
|
410
|
+
if (!workspace) throw new Error('memberNode.workspace required');
|
|
411
|
+
const memberId = opts.memberNode.id?.trim();
|
|
412
|
+
let node = mesh.nodes.find(n => (memberId && n.id === memberId) || n.workspace === workspace);
|
|
413
|
+
if (node) {
|
|
414
|
+
node.workspace = workspace;
|
|
415
|
+
node.repoRoot = opts.memberNode.repoRoot;
|
|
416
|
+
node.daemonId = opts.memberNode.daemonId;
|
|
417
|
+
node.machineId = opts.memberNode.machineId;
|
|
418
|
+
node.userOverrides = opts.memberNode.userOverrides || node.userOverrides || {};
|
|
419
|
+
node.policy = { ...(node.policy || {}), ...(opts.memberNode.policy || {}) };
|
|
420
|
+
node.role = 'member';
|
|
421
|
+
} else {
|
|
422
|
+
if (mesh.nodes.length >= 10) throw new Error('Maximum 10 nodes per mesh');
|
|
423
|
+
node = {
|
|
424
|
+
id: memberId || `node_${randomUUID().replace(/-/g, '')}`,
|
|
425
|
+
workspace,
|
|
426
|
+
repoRoot: opts.memberNode.repoRoot,
|
|
427
|
+
daemonId: opts.memberNode.daemonId,
|
|
428
|
+
machineId: opts.memberNode.machineId,
|
|
429
|
+
userOverrides: opts.memberNode.userOverrides || {},
|
|
430
|
+
policy: opts.memberNode.policy || {},
|
|
431
|
+
role: 'member',
|
|
432
|
+
};
|
|
433
|
+
mesh.nodes.push(node);
|
|
434
|
+
}
|
|
435
|
+
mesh.meshHost = {
|
|
436
|
+
...meshHost,
|
|
437
|
+
pairing: {
|
|
438
|
+
...(meshHost.pairing || {}),
|
|
439
|
+
status: 'paired',
|
|
440
|
+
tokenId: validation.tokenId,
|
|
441
|
+
joinedAt: now,
|
|
442
|
+
lastPairedAt: meshHost.pairing?.lastPairedAt || now,
|
|
443
|
+
...(meshHost.pairing?.expiresAt ? { expiresAt: meshHost.pairing.expiresAt } : {}),
|
|
444
|
+
},
|
|
445
|
+
};
|
|
446
|
+
mesh.updatedAt = now;
|
|
447
|
+
saveMeshConfig(config);
|
|
448
|
+
return { accepted: true, mesh, meshHost: mesh.meshHost, node, tokenId: validation.tokenId };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export function markMeshHostPairingJoined(
|
|
452
|
+
meshId: string,
|
|
453
|
+
opts: { hostDaemonId?: string; hostNodeId?: string; joinedAt?: string; token?: string; tokenId?: string },
|
|
454
|
+
): { mesh: LocalMeshEntry; meshHost: RepoMeshHostMetadata } | undefined {
|
|
455
|
+
const config = loadMeshConfig();
|
|
456
|
+
const mesh = config.meshes.find(m => m.id === meshId);
|
|
457
|
+
if (!mesh) return undefined;
|
|
458
|
+
const now = opts.joinedAt || new Date().toISOString();
|
|
459
|
+
const previous = mesh.meshHost || createDefaultMeshHostMetadata();
|
|
460
|
+
const tokenId = opts.tokenId || (opts.token ? tokenIdForManualPairing(opts.token) : previous.pairing?.tokenId);
|
|
461
|
+
mesh.meshHost = {
|
|
462
|
+
...previous,
|
|
463
|
+
role: 'member',
|
|
464
|
+
...(opts.hostDaemonId ? { hostDaemonId: opts.hostDaemonId } : {}),
|
|
465
|
+
...(opts.hostNodeId ? { hostNodeId: opts.hostNodeId } : {}),
|
|
466
|
+
pairing: {
|
|
467
|
+
...(previous.pairing || {}),
|
|
468
|
+
status: 'paired',
|
|
469
|
+
...(tokenId ? { tokenId } : {}),
|
|
470
|
+
joinedAt: now,
|
|
471
|
+
lastPairedAt: previous.pairing?.lastPairedAt || now,
|
|
472
|
+
},
|
|
473
|
+
};
|
|
474
|
+
mesh.updatedAt = now;
|
|
475
|
+
saveMeshConfig(config);
|
|
476
|
+
return { mesh, meshHost: mesh.meshHost };
|
|
477
|
+
}
|
|
478
|
+
|
|
177
479
|
// ─── Node Operations ────────────────────────────
|
|
178
480
|
|
|
179
481
|
export interface AddNodeOptions {
|
|
@@ -181,11 +483,14 @@ export interface AddNodeOptions {
|
|
|
181
483
|
repoRoot?: string;
|
|
182
484
|
daemonId?: string;
|
|
183
485
|
machineId?: string;
|
|
486
|
+
capabilities?: string[];
|
|
184
487
|
userOverrides?: Partial<RepoMeshNodeCapabilities>;
|
|
185
488
|
policy?: RepoMeshNodePolicy;
|
|
186
489
|
isLocalWorktree?: boolean;
|
|
187
490
|
worktreeBranch?: string;
|
|
188
491
|
clonedFromNodeId?: string;
|
|
492
|
+
worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
|
|
493
|
+
role?: RepoMeshDaemonRole;
|
|
189
494
|
}
|
|
190
495
|
|
|
191
496
|
export function addNode(meshId: string, opts: AddNodeOptions): LocalMeshNodeEntry | undefined {
|
|
@@ -208,11 +513,14 @@ export function addNode(meshId: string, opts: AddNodeOptions): LocalMeshNodeEntr
|
|
|
208
513
|
repoRoot: opts.repoRoot,
|
|
209
514
|
daemonId: opts.daemonId,
|
|
210
515
|
machineId: opts.machineId,
|
|
516
|
+
capabilities: normalizeCapabilityTags(opts.capabilities),
|
|
211
517
|
userOverrides: opts.userOverrides || {},
|
|
212
518
|
policy: opts.policy || {},
|
|
213
519
|
isLocalWorktree: opts.isLocalWorktree,
|
|
214
520
|
worktreeBranch: opts.worktreeBranch,
|
|
215
521
|
clonedFromNodeId: opts.clonedFromNodeId,
|
|
522
|
+
worktreeBootstrap: opts.worktreeBootstrap,
|
|
523
|
+
role: opts.role,
|
|
216
524
|
};
|
|
217
525
|
|
|
218
526
|
mesh.nodes.push(node);
|
|
@@ -238,7 +546,19 @@ export function removeNode(meshId: string, nodeId: string): boolean {
|
|
|
238
546
|
export function updateNode(
|
|
239
547
|
meshId: string,
|
|
240
548
|
nodeId: string,
|
|
241
|
-
opts: {
|
|
549
|
+
opts: {
|
|
550
|
+
userOverrides?: Partial<RepoMeshNodeCapabilities>;
|
|
551
|
+
policy?: RepoMeshNodePolicy;
|
|
552
|
+
worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
|
|
553
|
+
/** Per-node instruction surfaced in the coordinator prompt. Pass an
|
|
554
|
+
* empty string or undefined to clear it. */
|
|
555
|
+
systemPrompt?: string;
|
|
556
|
+
/** Live self-reported platform/arch from the owning daemon's git_status
|
|
557
|
+
* envelope. Persisted distinctly from userOverrides (auto-detected, not
|
|
558
|
+
* operator intent) so capability-tag os=/arch= self-heals across loads. */
|
|
559
|
+
reportedPlatform?: string;
|
|
560
|
+
reportedArch?: string;
|
|
561
|
+
},
|
|
242
562
|
): LocalMeshNodeEntry | undefined {
|
|
243
563
|
const config = loadMeshConfig();
|
|
244
564
|
const mesh = config.meshes.find(m => m.id === meshId);
|
|
@@ -248,7 +568,18 @@ export function updateNode(
|
|
|
248
568
|
if (!node) return undefined;
|
|
249
569
|
|
|
250
570
|
if (opts.userOverrides) node.userOverrides = { ...node.userOverrides, ...opts.userOverrides };
|
|
571
|
+
if (opts.reportedPlatform && opts.reportedPlatform.trim()) node.reportedPlatform = opts.reportedPlatform.trim();
|
|
572
|
+
if (opts.reportedArch && opts.reportedArch.trim()) node.reportedArch = opts.reportedArch.trim();
|
|
251
573
|
if (opts.policy) node.policy = { ...node.policy, ...opts.policy };
|
|
574
|
+
if (opts.worktreeBootstrap) node.worktreeBootstrap = opts.worktreeBootstrap;
|
|
575
|
+
if (Object.prototype.hasOwnProperty.call(opts, 'systemPrompt')) {
|
|
576
|
+
// Honor explicit clears: { systemPrompt: undefined } drops the field.
|
|
577
|
+
if (opts.systemPrompt && opts.systemPrompt.trim()) {
|
|
578
|
+
node.systemPrompt = opts.systemPrompt;
|
|
579
|
+
} else {
|
|
580
|
+
delete node.systemPrompt;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
252
583
|
mesh.updatedAt = new Date().toISOString();
|
|
253
584
|
saveMeshConfig(config);
|
|
254
585
|
return node;
|