@adhdev/daemon-core 0.9.82-rc.43 → 0.9.82-rc.431
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 +69 -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 +29 -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 +142 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +276 -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 +100 -1
- package/dist/config/mesh-json-config.d.ts +199 -0
- package/dist/config/repo-settings.d.ts +77 -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 +64 -14
- package/dist/index.js +49391 -19228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48574 -18570
- 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-clone-grace.d.ts +8 -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 +41 -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 +69 -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-magi-status.d.ts +63 -0
- package/dist/mesh/mesh-missions.d.ts +189 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-queue-assignment.d.ts +113 -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 +450 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/mesh/mesh-task-inflight.d.ts +46 -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 +290 -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 +221 -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 +29 -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 +422 -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 +501 -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 +204 -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 +544 -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 +678 -0
- package/src/commands/high-family/mesh-events.ts +80 -0
- package/src/commands/high-family/mesh-status.ts +710 -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 +1066 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +167 -0
- package/src/commands/med-family/mesh-restart.ts +92 -0
- package/src/commands/med-family/types.ts +143 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router.ts +2711 -3254
- 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 +495 -22
- package/src/config/mesh-json-config.ts +376 -0
- package/src/config/recent-activity.ts +8 -2
- package/src/config/repo-settings.ts +111 -0
- 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 +194 -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-clone-grace.ts +68 -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 +1888 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +32 -0
- package/src/mesh/mesh-events-pending.ts +656 -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 +33 -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 +656 -102
- package/src/mesh/mesh-magi-status.ts +223 -0
- package/src/mesh/mesh-missions.ts +449 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-queue-assignment.ts +1918 -0
- package/src/mesh/mesh-reconcile-loop.ts +1780 -0
- package/src/mesh/mesh-refine-batch.ts +205 -0
- package/src/mesh/mesh-refine-gates.ts +1673 -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 +1853 -0
- package/src/mesh/mesh-scheduling-runtime.ts +198 -0
- package/src/mesh/mesh-task-inflight.ts +70 -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 +1243 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +450 -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 +1933 -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 +71 -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 +1410 -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 +740 -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
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RF-ROUTER HIGH family — mesh aggregate status + review inbox.
|
|
3
|
+
*
|
|
4
|
+
* mesh_status: the coordinator's aggregate mesh render — resolves membership,
|
|
5
|
+
* gates the memory cache against pending coordinator events / explicit refresh,
|
|
6
|
+
* optionally fans out a direct peer-truth probe, then renders per-node health
|
|
7
|
+
* (live session records, local/remote/inline git truth, branch convergence) and
|
|
8
|
+
* folds in queue/ledger/missions/async-refine/historical-session/active-refine
|
|
9
|
+
* state. get_mesh_review_inbox: derives review-inbox items from node statuses +
|
|
10
|
+
* ledger and annotates each with a worktree git-diff summary. Extracted verbatim
|
|
11
|
+
* from executeDaemonCommand — only `this.*` router members became `ctx.*` and the
|
|
12
|
+
* relative dynamic-import paths were re-based one directory deeper.
|
|
13
|
+
*/
|
|
14
|
+
import * as fs from 'fs';
|
|
15
|
+
import { hostname as osHostname } from 'os';
|
|
16
|
+
import { loadConfig } from '../../config/config.js';
|
|
17
|
+
import { getGitRepoStatus } from '../../git/git-status.js';
|
|
18
|
+
import {
|
|
19
|
+
normalizeMeshNodeId,
|
|
20
|
+
daemonIdsEquivalent,
|
|
21
|
+
} from '@adhdev/mesh-shared';
|
|
22
|
+
import { getPendingMeshCoordinatorEvents } from '../../mesh/mesh-events.js';
|
|
23
|
+
import { getRecentUnroutableDeliveries } from '../../mesh/mesh-routing.js';
|
|
24
|
+
import { normalizeMeshDaemonRole, resolveMeshHostStatus } from '../../mesh/mesh-host-ownership.js';
|
|
25
|
+
import { buildPreviewFreshness } from '../../mesh/preview-freshness.js';
|
|
26
|
+
import { buildMeshAsyncRefineJobs } from '../../mesh/mesh-refine-status.js';
|
|
27
|
+
import { partitionSessionHostRecords } from '../../session-host/runtime-surface.js';
|
|
28
|
+
import {
|
|
29
|
+
readStringValue,
|
|
30
|
+
readObjectRecord,
|
|
31
|
+
readBooleanValue,
|
|
32
|
+
readMeshNodeMachineId,
|
|
33
|
+
readMeshNodeHostname,
|
|
34
|
+
readProviderPriorityFromPolicy,
|
|
35
|
+
buildMeshNodeMachineIdentity,
|
|
36
|
+
buildMeshNodeDisplayLabel,
|
|
37
|
+
collectLiveMeshSessionRecords,
|
|
38
|
+
readLiveMeshNodeWorkspace,
|
|
39
|
+
summarizeMeshSessionRecord,
|
|
40
|
+
buildInlineMeshTransitGitStatus,
|
|
41
|
+
deriveMeshNodeHealthFromGit,
|
|
42
|
+
buildLivePeerGitConnection,
|
|
43
|
+
probeRemoteMeshGitStatusWithRetry,
|
|
44
|
+
recordInlineMeshDirectGitTruth,
|
|
45
|
+
persistNodeReporterPlatform,
|
|
46
|
+
applyCachedInlineMeshNodeStatus,
|
|
47
|
+
applyInlineMeshBranchConvergence,
|
|
48
|
+
finalizeMeshNodeStatus,
|
|
49
|
+
summarizeInlineMeshBranchConvergence,
|
|
50
|
+
buildHistoricalMeshSessions,
|
|
51
|
+
hydrateInlineMeshDirectTruth,
|
|
52
|
+
MESH_NODE_LIVE_TRUTH_MARKER,
|
|
53
|
+
logRepoMeshStatusDebug,
|
|
54
|
+
summarizeRepoMeshStatusDebug,
|
|
55
|
+
MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
56
|
+
MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
57
|
+
} from '../router.js';
|
|
58
|
+
import type { HighFamilyContext, HighFamilyHandler } from './types.js';
|
|
59
|
+
|
|
60
|
+
export const meshStatusHandlers: Record<string, HighFamilyHandler> = {
|
|
61
|
+
mesh_status: async (ctx: HighFamilyContext, args: any) => {
|
|
62
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
63
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
64
|
+
try {
|
|
65
|
+
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
66
|
+
const mesh = meshRecord?.mesh;
|
|
67
|
+
if (!mesh) return { success: false, error: 'Mesh not found' };
|
|
68
|
+
const meshHost = resolveMeshHostStatus(mesh);
|
|
69
|
+
|
|
70
|
+
const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
|
|
71
|
+
// Compact (default) elides each mission's full goal text from the
|
|
72
|
+
// payload — coordinators polling node health don't need every
|
|
73
|
+
// mission's multi-hundred-char goal repeated. verbose=true (or the
|
|
74
|
+
// explicit compact=false) restores full goals. Verbose bypasses the
|
|
75
|
+
// shared (compact) aggregate cache so a verbose call never poisons
|
|
76
|
+
// the compact cache and vice versa.
|
|
77
|
+
const verboseMissions = args?.verbose === true || args?.compact === false;
|
|
78
|
+
// See (B3) below: scope the peek to this daemon when the
|
|
79
|
+
// caller doesn't tell us, otherwise scoped events look
|
|
80
|
+
// missing and we falsely return a stale cache.
|
|
81
|
+
const peekScope = typeof args?.coordinatorDaemonId === 'string' && args.coordinatorDaemonId.trim()
|
|
82
|
+
? args.coordinatorDaemonId.trim()
|
|
83
|
+
: (ctx.deps.statusInstanceId || undefined);
|
|
84
|
+
const pendingCoordinatorEventCount = getPendingMeshCoordinatorEvents(meshId, peekScope).length;
|
|
85
|
+
const hadAggregateCache = ctx.aggregateMeshStatusCache.has(meshId);
|
|
86
|
+
if (!refreshRequested && !verboseMissions && pendingCoordinatorEventCount === 0) {
|
|
87
|
+
const cachedStatus = ctx.getCachedAggregateMeshStatus(meshId, mesh, { requireDirectPeerTruth: args?.requireDirectPeerTruth === true });
|
|
88
|
+
if (cachedStatus) {
|
|
89
|
+
logRepoMeshStatusDebug('return_cached', {
|
|
90
|
+
meshId,
|
|
91
|
+
command: 'mesh_status',
|
|
92
|
+
refreshRequested,
|
|
93
|
+
summary: summarizeRepoMeshStatusDebug(cachedStatus),
|
|
94
|
+
});
|
|
95
|
+
return cachedStatus;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const refreshReason = refreshRequested
|
|
99
|
+
? 'explicit_refresh'
|
|
100
|
+
: pendingCoordinatorEventCount > 0
|
|
101
|
+
? 'pending_coordinator_events'
|
|
102
|
+
: hadAggregateCache
|
|
103
|
+
? 'stale_pending_cache_refresh'
|
|
104
|
+
: 'cold_cache_miss';
|
|
105
|
+
|
|
106
|
+
const { getMeshQueueStats, getQueue } = await import('../../mesh/mesh-work-queue.js');
|
|
107
|
+
const queue = getQueue(meshId);
|
|
108
|
+
const queueSummary = getMeshQueueStats(meshId);
|
|
109
|
+
|
|
110
|
+
// Scheduling-runtime projection — the load-balancer's live view (tie-break
|
|
111
|
+
// strategy, global parallel caps + consumption, per-node load/priority/provider
|
|
112
|
+
// caps). Built from the SAME helper + args the MCP `mesh_status` tool uses
|
|
113
|
+
// (mesh-tools-status.ts: buildMeshSchedulingRuntime(mesh, getQueue(mesh.id)))
|
|
114
|
+
// so the dashboard surface and the coordinator MCP surface render an identical
|
|
115
|
+
// runtime. Without this the dashboard Status/Runtime tab showed the
|
|
116
|
+
// "not reported by this daemon (older build)" fallback (RepoMeshStatus.scheduling
|
|
117
|
+
// was never populated by this daemon-command producer). Computed once so each
|
|
118
|
+
// node entry can attach its slice and statusResult can carry the mesh rollup.
|
|
119
|
+
const { buildMeshSchedulingRuntime } = await import('../../mesh/mesh-scheduling-runtime.js');
|
|
120
|
+
const schedulingRuntime = buildMeshSchedulingRuntime(mesh, queue);
|
|
121
|
+
const schedulingByNode = new Map(schedulingRuntime.nodes.map(n => [n.nodeId, n]));
|
|
122
|
+
|
|
123
|
+
const { readLedgerEntries, getLedgerSummary } = await import('../../mesh/mesh-ledger.js');
|
|
124
|
+
const ledgerEntries = readLedgerEntries(meshId, { tail: 20 });
|
|
125
|
+
const asyncRefineLedgerEntries = readLedgerEntries(meshId, { tail: 100 });
|
|
126
|
+
const ledgerSummary = getLedgerSummary(meshId);
|
|
127
|
+
const sessionHostRecords = ctx.deps.sessionHostControl?.listSessions
|
|
128
|
+
? await ctx.deps.sessionHostControl.listSessions().catch(() => [])
|
|
129
|
+
: [];
|
|
130
|
+
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
131
|
+
|
|
132
|
+
const localMachineId = loadConfig().machineId || '';
|
|
133
|
+
const requireDirectPeerTruth = args?.requireDirectPeerTruth === true;
|
|
134
|
+
// Shared probe gate for this mesh_status call: the bootstrap
|
|
135
|
+
// hydrate below and the per-node render loop further down both
|
|
136
|
+
// probe the same peers — route both through this cache so they
|
|
137
|
+
// dedup within the call and reuse recent results across calls.
|
|
138
|
+
const meshGitProbeCache = ctx.meshGitProbeCache;
|
|
139
|
+
const directTruth = requireDirectPeerTruth
|
|
140
|
+
? await hydrateInlineMeshDirectTruth({
|
|
141
|
+
mesh,
|
|
142
|
+
meshSource: meshRecord.source,
|
|
143
|
+
dispatchMeshCommand: ctx.deps.dispatchMeshCommand,
|
|
144
|
+
getMeshPeerConnectionStatus: ctx.deps.getMeshPeerConnectionStatus,
|
|
145
|
+
statusInstanceId: ctx.deps.statusInstanceId,
|
|
146
|
+
localMachineId,
|
|
147
|
+
// Standing-state model: only an explicit refresh fans
|
|
148
|
+
// out a blocking peer git probe. Default loads return
|
|
149
|
+
// held truth so one slow peer can't block the graph.
|
|
150
|
+
probeRemotePeers: refreshRequested,
|
|
151
|
+
probeCache: meshGitProbeCache,
|
|
152
|
+
})
|
|
153
|
+
: {
|
|
154
|
+
directEvidenceCount: 0,
|
|
155
|
+
localConfirmedCount: 0,
|
|
156
|
+
peerAttemptedCount: 0,
|
|
157
|
+
peerConfirmedCount: 0,
|
|
158
|
+
standingEvidenceCount: 0,
|
|
159
|
+
unavailableNodeIds: [] as string[],
|
|
160
|
+
deadNodeIds: [] as string[],
|
|
161
|
+
};
|
|
162
|
+
// Default/cached loads may not attempt a remote peer probe yet; do not surface that as
|
|
163
|
+
// a direct mesh truth failure until an explicit probe attempt actually fails.
|
|
164
|
+
const passivePeerTruthNotAttempted = requireDirectPeerTruth
|
|
165
|
+
&& !refreshRequested
|
|
166
|
+
&& directTruth.directEvidenceCount > 0
|
|
167
|
+
&& directTruth.peerAttemptedCount === 0;
|
|
168
|
+
const effectiveDirectTruth = passivePeerTruthNotAttempted
|
|
169
|
+
? { ...directTruth, unavailableNodeIds: [] as string[] }
|
|
170
|
+
: directTruth;
|
|
171
|
+
const unavailableDirectTruthNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
172
|
+
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0
|
|
173
|
+
&& Array.isArray(mesh.nodes)
|
|
174
|
+
&& mesh.nodes
|
|
175
|
+
.filter((node: any) => unavailableDirectTruthNodeIds.has(normalizeMeshNodeId(node) ?? ''))
|
|
176
|
+
.every((node: any) => node?.isLocalWorktree === true);
|
|
177
|
+
// Default (non-refresh) loads never hard-fail: held
|
|
178
|
+
// standing-state truth is returned and the graph renders
|
|
179
|
+
// immediately. The hard mesh_direct_peer_truth_unavailable
|
|
180
|
+
// failure is reserved for an explicit refresh that actually
|
|
181
|
+
// attempted a peer probe and could not confirm any evidence.
|
|
182
|
+
const directTruthSatisfied = !requireDirectPeerTruth
|
|
183
|
+
|| !refreshRequested
|
|
184
|
+
|| (effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees));
|
|
185
|
+
if (requireDirectPeerTruth && refreshRequested && !directTruthSatisfied) {
|
|
186
|
+
const failureResult = {
|
|
187
|
+
success: false,
|
|
188
|
+
code: 'mesh_direct_peer_truth_unavailable',
|
|
189
|
+
error: 'Selected coordinator could not confirm direct mesh truth yet. Bootstrap inventory stays unavailable until direct mesh_status probes succeed.',
|
|
190
|
+
sourceOfTruth: {
|
|
191
|
+
membership: meshRecord.source === 'inline_cache'
|
|
192
|
+
? 'coordinator_inline_mesh_cache'
|
|
193
|
+
: meshRecord.source === 'local_config'
|
|
194
|
+
? 'local_mesh_config'
|
|
195
|
+
: 'inline_bootstrap_snapshot',
|
|
196
|
+
coordinatorOwnsLiveTruth: false,
|
|
197
|
+
currentStatus: 'direct_peer_truth_unavailable',
|
|
198
|
+
directPeerTruth: {
|
|
199
|
+
required: true,
|
|
200
|
+
satisfied: false,
|
|
201
|
+
directEvidenceCount: directTruth.directEvidenceCount,
|
|
202
|
+
localConfirmedCount: directTruth.localConfirmedCount,
|
|
203
|
+
peerAttemptedCount: directTruth.peerAttemptedCount,
|
|
204
|
+
peerConfirmedCount: directTruth.peerConfirmedCount,
|
|
205
|
+
unavailableNodeIds: directTruth.unavailableNodeIds,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
logRepoMeshStatusDebug('direct_truth_unavailable', {
|
|
210
|
+
meshId,
|
|
211
|
+
command: 'mesh_status',
|
|
212
|
+
refreshRequested,
|
|
213
|
+
meshSource: meshRecord.source,
|
|
214
|
+
directTruth,
|
|
215
|
+
});
|
|
216
|
+
return failureResult;
|
|
217
|
+
}
|
|
218
|
+
const directTruthUnavailableNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
219
|
+
const coordinatorHostname = osHostname();
|
|
220
|
+
const selectedCoordinatorNodeId = readStringValue(
|
|
221
|
+
mesh.coordinator?.preferredNodeId,
|
|
222
|
+
normalizeMeshNodeId(mesh.nodes?.[0] as any),
|
|
223
|
+
);
|
|
224
|
+
const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes)
|
|
225
|
+
? selectedCoordinatorNodeId
|
|
226
|
+
: undefined;
|
|
227
|
+
const refreshedAt = new Date().toISOString();
|
|
228
|
+
const nodeStatuses = [];
|
|
229
|
+
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
230
|
+
const nodeId = normalizeMeshNodeId(node) ?? '';
|
|
231
|
+
const daemonId = readStringValue(node.daemonId);
|
|
232
|
+
const nodeMachineId = readMeshNodeMachineId(node as Record<string, unknown>);
|
|
233
|
+
const nodeHostname = readMeshNodeHostname(node as Record<string, unknown>);
|
|
234
|
+
const providerPriority = readProviderPriorityFromPolicy(node.policy);
|
|
235
|
+
const configuredCoordinatorNode = Boolean(
|
|
236
|
+
nodeId && selectedCoordinatorNodeId && nodeId === selectedCoordinatorNodeId,
|
|
237
|
+
);
|
|
238
|
+
const sparseConfiguredCoordinatorNode = configuredCoordinatorNode
|
|
239
|
+
&& !daemonId
|
|
240
|
+
&& !nodeMachineId
|
|
241
|
+
&& !nodeHostname;
|
|
242
|
+
const isSelfNode = Boolean(
|
|
243
|
+
nodeId && inlineCoordinatorNodeId && nodeId === inlineCoordinatorNodeId,
|
|
244
|
+
) || Boolean(
|
|
245
|
+
daemonId && (daemonIdsEquivalent(daemonId, localMachineId) || daemonIdsEquivalent(daemonId, ctx.deps.statusInstanceId)),
|
|
246
|
+
) || Boolean(meshRecord?.inline && nodeIndex === 0)
|
|
247
|
+
|| sparseConfiguredCoordinatorNode;
|
|
248
|
+
const machineIdentity = buildMeshNodeMachineIdentity(node as Record<string, unknown>, {
|
|
249
|
+
localMachineId,
|
|
250
|
+
localDaemonId: ctx.deps.statusInstanceId,
|
|
251
|
+
coordinatorHostname,
|
|
252
|
+
isSelfNode,
|
|
253
|
+
});
|
|
254
|
+
const status: Record<string, unknown> = {
|
|
255
|
+
nodeId,
|
|
256
|
+
machineLabel: buildMeshNodeDisplayLabel(node as Record<string, unknown>, nodeId, providerPriority),
|
|
257
|
+
labelSource: readStringValue(node.machineLabel, node.machine_label, node.machineNickname, node.machine_nickname, node.alias)
|
|
258
|
+
? 'explicit_metadata'
|
|
259
|
+
: 'workspace_host_provider_context',
|
|
260
|
+
workspace: node.workspace,
|
|
261
|
+
repoRoot: node.repoRoot,
|
|
262
|
+
isLocalWorktree: node.isLocalWorktree,
|
|
263
|
+
worktreeBranch: node.worktreeBranch,
|
|
264
|
+
role: normalizeMeshDaemonRole(node.role) || (meshHost.hostNodeId && nodeId === meshHost.hostNodeId ? 'host' : undefined),
|
|
265
|
+
daemonId,
|
|
266
|
+
machineId: nodeMachineId || node.machineId,
|
|
267
|
+
machine: machineIdentity,
|
|
268
|
+
machineStatus: node.machineStatus,
|
|
269
|
+
health: 'unknown',
|
|
270
|
+
providers: node.providers || [],
|
|
271
|
+
providerPriority,
|
|
272
|
+
activeSessions: [],
|
|
273
|
+
activeSessionDetails: [],
|
|
274
|
+
launchReady: false,
|
|
275
|
+
};
|
|
276
|
+
// Per-node scheduling slice (load / priority / provider caps / claim-block
|
|
277
|
+
// reasons) read by the dashboard's MeshNodeSchedulingBadges. Full shape —
|
|
278
|
+
// unlike the MCP compact path this is a dashboard surface, so it keeps the
|
|
279
|
+
// whole RepoMeshNodeSchedulingStatus. Redundant nodeId dropped (the entry
|
|
280
|
+
// already carries it).
|
|
281
|
+
const nodeScheduling = schedulingByNode.get(nodeId);
|
|
282
|
+
if (nodeScheduling) {
|
|
283
|
+
const { nodeId: _omitNodeId, ...nodeSchedulingRest } = nodeScheduling;
|
|
284
|
+
status.scheduling = nodeSchedulingRest;
|
|
285
|
+
}
|
|
286
|
+
if (isSelfNode) {
|
|
287
|
+
status.connection = {
|
|
288
|
+
perspective: 'selected_coordinator',
|
|
289
|
+
source: 'mesh_peer_status',
|
|
290
|
+
state: 'self',
|
|
291
|
+
transport: 'local',
|
|
292
|
+
reported: true,
|
|
293
|
+
reason: 'Selected coordinator daemon',
|
|
294
|
+
lastStateChangeAt: refreshedAt,
|
|
295
|
+
};
|
|
296
|
+
} else if (daemonId) {
|
|
297
|
+
const connection = ctx.deps.getMeshPeerConnectionStatus?.(daemonId);
|
|
298
|
+
status.connection = connection ?? {
|
|
299
|
+
perspective: 'selected_coordinator',
|
|
300
|
+
source: 'not_reported',
|
|
301
|
+
state: 'unknown',
|
|
302
|
+
transport: 'unknown',
|
|
303
|
+
reported: false,
|
|
304
|
+
reason: 'No live mesh peer telemetry reported by the selected coordinator yet.',
|
|
305
|
+
};
|
|
306
|
+
} else {
|
|
307
|
+
status.connection = {
|
|
308
|
+
perspective: 'selected_coordinator',
|
|
309
|
+
source: 'not_reported',
|
|
310
|
+
state: 'unknown',
|
|
311
|
+
transport: 'unknown',
|
|
312
|
+
reported: false,
|
|
313
|
+
reason: 'Node has no daemon id, so mesh transport cannot be reported from the selected coordinator.',
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const matchedLiveSessionRecords = collectLiveMeshSessionRecords({
|
|
317
|
+
meshId,
|
|
318
|
+
node,
|
|
319
|
+
nodeId,
|
|
320
|
+
liveSessionRecords: liveMeshSessions,
|
|
321
|
+
allowCoordinatorSession: nodeId === selectedCoordinatorNodeId,
|
|
322
|
+
});
|
|
323
|
+
const workspace = readLiveMeshNodeWorkspace({
|
|
324
|
+
meshId,
|
|
325
|
+
nodeId,
|
|
326
|
+
liveSessionRecords: matchedLiveSessionRecords,
|
|
327
|
+
allowCoordinatorSession: nodeId === selectedCoordinatorNodeId,
|
|
328
|
+
}) || (typeof node.workspace === 'string' ? node.workspace : '');
|
|
329
|
+
status.workspace = workspace || node.workspace;
|
|
330
|
+
if (matchedLiveSessionRecords.length > 0) {
|
|
331
|
+
const sessionIds = matchedLiveSessionRecords
|
|
332
|
+
.map((record: any) => typeof record?.sessionId === 'string' ? record.sessionId : '')
|
|
333
|
+
.filter(Boolean);
|
|
334
|
+
const providerTypes = matchedLiveSessionRecords
|
|
335
|
+
.map((record: any) => readStringValue(record?.providerType))
|
|
336
|
+
.filter(Boolean) as string[];
|
|
337
|
+
status.activeSessions = sessionIds;
|
|
338
|
+
status.activeSessionDetails = matchedLiveSessionRecords.map(summarizeMeshSessionRecord);
|
|
339
|
+
if (providerTypes.length > 0) {
|
|
340
|
+
status.providers = Array.from(new Set([...(Array.isArray(status.providers) ? status.providers as string[] : []), ...providerTypes]));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (workspace) {
|
|
344
|
+
if (!fs.existsSync(workspace)) {
|
|
345
|
+
// Workspace not local — prefer direct live inline truth, then attempt a P2P git probe.
|
|
346
|
+
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
347
|
+
let remoteProbeApplied = false;
|
|
348
|
+
if (inlineTransitGit) {
|
|
349
|
+
status.git = inlineTransitGit;
|
|
350
|
+
status.health = inlineTransitGit.isGitRepo
|
|
351
|
+
? deriveMeshNodeHealthFromGit(inlineTransitGit as unknown as Record<string, unknown>)
|
|
352
|
+
: 'degraded';
|
|
353
|
+
const connection = readObjectRecord(status.connection);
|
|
354
|
+
const connectionState = readStringValue(connection.state);
|
|
355
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
356
|
+
if (!connectionReported || connectionState === 'unknown') {
|
|
357
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
358
|
+
}
|
|
359
|
+
remoteProbeApplied = true;
|
|
360
|
+
} else if (refreshRequested && !isSelfNode && daemonId && ctx.deps.dispatchMeshCommand && !directTruthUnavailableNodeIds.has(nodeId)) {
|
|
361
|
+
// Only an explicit refresh fans out a blocking
|
|
362
|
+
// per-node git probe. On the default load a peer
|
|
363
|
+
// with no held truth falls through to
|
|
364
|
+
// gitProbePending below — the graph still renders.
|
|
365
|
+
// Bounded retry (shared with the bootstrap hydrate
|
|
366
|
+
// path), gated on the peer staying connected, so a
|
|
367
|
+
// slow TURN-relayed peer is recovered rather than
|
|
368
|
+
// dropped after a single timeout.
|
|
369
|
+
const runNodeProbe = () => probeRemoteMeshGitStatusWithRetry({
|
|
370
|
+
dispatchMeshCommand: ctx.deps.dispatchMeshCommand,
|
|
371
|
+
daemonId,
|
|
372
|
+
workspace,
|
|
373
|
+
timeoutMs: MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
374
|
+
retryTimeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
375
|
+
getConnection: ctx.deps.getMeshPeerConnectionStatus,
|
|
376
|
+
onConnection: connection => { status.connection = connection; },
|
|
377
|
+
});
|
|
378
|
+
// Same shared cache as the bootstrap hydrate path: within one
|
|
379
|
+
// mesh_status call this dedups the bootstrap probe against this
|
|
380
|
+
// per-node probe for the same peer, and across calls it reuses a
|
|
381
|
+
// recent result so the dashboard auto-retry loop can't restart a
|
|
382
|
+
// fresh refreshUpstream probe seconds apart.
|
|
383
|
+
const remoteGit = await meshGitProbeCache.probe(daemonId, workspace, runNodeProbe);
|
|
384
|
+
if (remoteGit) {
|
|
385
|
+
status.git = remoteGit;
|
|
386
|
+
status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
387
|
+
status.health = remoteGit.isGitRepo
|
|
388
|
+
? deriveMeshNodeHealthFromGit(remoteGit as unknown as Record<string, unknown>)
|
|
389
|
+
: 'degraded';
|
|
390
|
+
const connection = readObjectRecord(status.connection);
|
|
391
|
+
const connectionState = readStringValue(connection.state);
|
|
392
|
+
const connectionReported = readBooleanValue(connection.reported) ?? false;
|
|
393
|
+
if (!connectionReported || connectionState === 'unknown') {
|
|
394
|
+
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
395
|
+
}
|
|
396
|
+
const reporter = recordInlineMeshDirectGitTruth(node, remoteGit, 'selected_coordinator_mesh_p2p_git');
|
|
397
|
+
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
398
|
+
remoteProbeApplied = true;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (!remoteProbeApplied) {
|
|
402
|
+
const connectionState = readStringValue((status.connection as any)?.state);
|
|
403
|
+
const pendingPeerGitProbe = !inlineTransitGit
|
|
404
|
+
&& !isSelfNode
|
|
405
|
+
&& !!daemonId
|
|
406
|
+
&& (
|
|
407
|
+
readStringValue(status.machineStatus) === 'online'
|
|
408
|
+
|| readStringValue(status.health) === 'online'
|
|
409
|
+
|| connectionState === 'connecting'
|
|
410
|
+
|| connectionState === 'connected'
|
|
411
|
+
|| connectionState === 'unknown'
|
|
412
|
+
);
|
|
413
|
+
if (pendingPeerGitProbe) {
|
|
414
|
+
status.gitProbePending = true;
|
|
415
|
+
status.health = 'unknown';
|
|
416
|
+
}
|
|
417
|
+
if (applyCachedInlineMeshNodeStatus(
|
|
418
|
+
status,
|
|
419
|
+
node,
|
|
420
|
+
pendingPeerGitProbe ? { skipGit: true, skipError: true, skipHealth: true } : undefined,
|
|
421
|
+
)) {
|
|
422
|
+
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
423
|
+
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
424
|
+
nodeStatuses.push(status);
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (meshRecord?.source === 'inline_cache' && !isSelfNode) {
|
|
428
|
+
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
429
|
+
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
430
|
+
nodeStatuses.push(status);
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
try {
|
|
436
|
+
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 10_000, refreshUpstream: true });
|
|
437
|
+
status.git = gitStatus;
|
|
438
|
+
status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
439
|
+
const reporter = recordInlineMeshDirectGitTruth(node, gitStatus as unknown as Record<string, unknown>, 'selected_coordinator_local_git');
|
|
440
|
+
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
441
|
+
if (gitStatus.isGitRepo) {
|
|
442
|
+
status.health = deriveMeshNodeHealthFromGit(gitStatus as unknown as Record<string, unknown>);
|
|
443
|
+
} else {
|
|
444
|
+
status.health = 'degraded';
|
|
445
|
+
if (gitStatus.error && !status.error) status.error = gitStatus.error;
|
|
446
|
+
}
|
|
447
|
+
} catch {
|
|
448
|
+
if (!applyCachedInlineMeshNodeStatus(status, node)) {
|
|
449
|
+
status.health = 'degraded';
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
applyCachedInlineMeshNodeStatus(status, node);
|
|
455
|
+
}
|
|
456
|
+
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
457
|
+
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
458
|
+
nodeStatuses.push(status);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// (B3) Resolve the coordinator daemon scope for the peek.
|
|
462
|
+
// mesh_status is a read-only status query — it must not consume
|
|
463
|
+
// (drain) pending events as a side effect. Coordinators that see
|
|
464
|
+
// pendingCoordinatorEvents in the response are expected to call
|
|
465
|
+
// get_pending_mesh_events to explicitly drain them after processing.
|
|
466
|
+
const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === 'string' && args.coordinatorDaemonId.trim()
|
|
467
|
+
? args.coordinatorDaemonId.trim()
|
|
468
|
+
: (ctx.deps.statusInstanceId || undefined);
|
|
469
|
+
const pendingCoordinatorEvents = getPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
|
|
470
|
+
// R4: surface recent fail-loud routing drops so a coordinator/operator can see
|
|
471
|
+
// that a worker completion was lost (envelope present, mesh unresolved) instead
|
|
472
|
+
// of it vanishing silently. Diagnostic-only — never cached (see omit below).
|
|
473
|
+
const unroutableDeliveries = getRecentUnroutableDeliveries();
|
|
474
|
+
const previewFreshness = (() => {
|
|
475
|
+
const localRepoRoot = nodeStatuses
|
|
476
|
+
.map((node: any) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace))
|
|
477
|
+
.find((candidate: string | undefined) => !!candidate && fs.existsSync(candidate));
|
|
478
|
+
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : undefined;
|
|
479
|
+
})();
|
|
480
|
+
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
481
|
+
meshId,
|
|
482
|
+
ledgerEntries: asyncRefineLedgerEntries,
|
|
483
|
+
pendingEvents: [...pendingCoordinatorEvents],
|
|
484
|
+
});
|
|
485
|
+
const historicalSessions = buildHistoricalMeshSessions({
|
|
486
|
+
meshId,
|
|
487
|
+
nodes: mesh.nodes || [],
|
|
488
|
+
liveSessionRecords: liveMeshSessions,
|
|
489
|
+
});
|
|
490
|
+
const { getMeshStatusMissionSummaries } = await import('../../mesh/mesh-missions.js');
|
|
491
|
+
// withStats opts in to per-mission operational rollups (durations /
|
|
492
|
+
// retries) for the dashboard mission detail. The rollup scans a
|
|
493
|
+
// bounded ledger tail per mission, but only over the bounded set
|
|
494
|
+
// returned here (live + capped history), so the cost stays linear
|
|
495
|
+
// in visible missions rather than the whole mesh history.
|
|
496
|
+
const missions = getMeshStatusMissionSummaries(meshId, { verbose: verboseMissions, withStats: true });
|
|
497
|
+
|
|
498
|
+
// FIX C-backend: fold persisted MAGI cross-verification activity into the
|
|
499
|
+
// dashboard mesh_status payload so the web MAGI surface (extractMagiActivity)
|
|
500
|
+
// can read synthesis output — needs_verification counts, the independence
|
|
501
|
+
// banner, git skew, and a bounded needs_verification preview — without
|
|
502
|
+
// re-running collection. Mirrors the MCP mesh_status tool
|
|
503
|
+
// (mesh-tools-status.ts buildMeshMagiActivity / summarizeMeshMagiActivity).
|
|
504
|
+
// Read magi_dispatched/magi_synthesis entries over a wider tail than the 20
|
|
505
|
+
// rendered above (MAGI events are sparse — a 20-entry tail routinely misses
|
|
506
|
+
// the dispatch/synthesis pair). Compact (the default) folds synthesized groups
|
|
507
|
+
// to a bounded recent set + a count summary; verbose carries the full list.
|
|
508
|
+
const { buildMeshMagiActivity, summarizeMeshMagiActivity } = await import('../../mesh/mesh-magi-status.js');
|
|
509
|
+
const magiLedgerEntries = readLedgerEntries(meshId, { kind: ['magi_dispatched', 'magi_synthesis'], tail: 200 });
|
|
510
|
+
const magiActivity = buildMeshMagiActivity({ meshId, ledgerEntries: magiLedgerEntries });
|
|
511
|
+
let magiActivityFold: ReturnType<typeof summarizeMeshMagiActivity> | undefined;
|
|
512
|
+
if (magiActivity.length > 0 && !verboseMissions) {
|
|
513
|
+
magiActivityFold = summarizeMeshMagiActivity(magiActivity);
|
|
514
|
+
}
|
|
515
|
+
const statusResult = {
|
|
516
|
+
success: true,
|
|
517
|
+
meshId: mesh.id,
|
|
518
|
+
meshName: mesh.name,
|
|
519
|
+
repoIdentity: mesh.repoIdentity,
|
|
520
|
+
defaultBranch: mesh.defaultBranch,
|
|
521
|
+
refreshedAt,
|
|
522
|
+
meshHost,
|
|
523
|
+
sourceOfTruth: {
|
|
524
|
+
membership: meshRecord?.source === 'inline_cache'
|
|
525
|
+
? 'coordinator_inline_mesh_cache'
|
|
526
|
+
: meshRecord?.source === 'local_config'
|
|
527
|
+
? 'local_mesh_config'
|
|
528
|
+
: 'inline_bootstrap_snapshot',
|
|
529
|
+
coordinatorOwnsLiveTruth: directTruthSatisfied,
|
|
530
|
+
meshHost: {
|
|
531
|
+
owner: 'mesh_host_daemon',
|
|
532
|
+
localRole: meshHost.role,
|
|
533
|
+
hostDaemonId: meshHost.hostDaemonId,
|
|
534
|
+
hostNodeId: meshHost.hostNodeId,
|
|
535
|
+
hostAddress: meshHost.hostAddress,
|
|
536
|
+
},
|
|
537
|
+
...(requireDirectPeerTruth ? {
|
|
538
|
+
currentStatus: directTruthSatisfied ? 'live_git_and_session_probes' : 'direct_peer_truth_unavailable',
|
|
539
|
+
directPeerTruth: {
|
|
540
|
+
required: true,
|
|
541
|
+
satisfied: directTruthSatisfied,
|
|
542
|
+
directEvidenceCount: effectiveDirectTruth.directEvidenceCount,
|
|
543
|
+
localConfirmedCount: effectiveDirectTruth.localConfirmedCount,
|
|
544
|
+
peerAttemptedCount: effectiveDirectTruth.peerAttemptedCount,
|
|
545
|
+
peerConfirmedCount: effectiveDirectTruth.peerConfirmedCount,
|
|
546
|
+
unavailableNodeIds: effectiveDirectTruth.unavailableNodeIds,
|
|
547
|
+
partialNodeFailures: effectiveDirectTruth.unavailableNodeIds,
|
|
548
|
+
},
|
|
549
|
+
} : {}),
|
|
550
|
+
historicalEvidenceOnly: ['recoveryHints', 'ledger.summary', 'queue.summary', 'historicalSessions'],
|
|
551
|
+
},
|
|
552
|
+
branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
|
|
553
|
+
...(previewFreshness ? { previewFreshness, deployFreshness: previewFreshness } : {}),
|
|
554
|
+
nodes: nodeStatuses,
|
|
555
|
+
// Mesh-level scheduling rollup (strategy + global cap consumption). Mirrors
|
|
556
|
+
// the MCP `mesh_status` tool's `scheduling` block field-for-field so both
|
|
557
|
+
// surfaces read the same runtime; per-node detail lives on each
|
|
558
|
+
// nodes[].scheduling above.
|
|
559
|
+
scheduling: {
|
|
560
|
+
strategy: schedulingRuntime.strategy,
|
|
561
|
+
maxParallelTasks: schedulingRuntime.maxParallelTasks,
|
|
562
|
+
maxReadonlyParallelTasks: schedulingRuntime.maxReadonlyParallelTasks,
|
|
563
|
+
activeWriteAssigned: schedulingRuntime.activeWriteAssigned,
|
|
564
|
+
activeReadonlyAssigned: schedulingRuntime.activeReadonlyAssigned,
|
|
565
|
+
globalWriteCapReached: schedulingRuntime.globalWriteCapReached,
|
|
566
|
+
globalReadonlyCapReached: schedulingRuntime.globalReadonlyCapReached,
|
|
567
|
+
},
|
|
568
|
+
queue: { tasks: queue, summary: queueSummary },
|
|
569
|
+
ledger: { entries: ledgerEntries, summary: ledgerSummary },
|
|
570
|
+
...(missions.length > 0 ? { missions } : {}),
|
|
571
|
+
// Compact (default): bounded folded groups + a status-count summary.
|
|
572
|
+
// Verbose: the full reconstructed activity list. Mirrors the MCP tool.
|
|
573
|
+
...(magiActivity.length > 0
|
|
574
|
+
? (magiActivityFold
|
|
575
|
+
? {
|
|
576
|
+
...(magiActivityFold.groups.length > 0 ? { magiActivity: magiActivityFold.groups } : {}),
|
|
577
|
+
magiActivitySummary: {
|
|
578
|
+
total: magiActivityFold.total,
|
|
579
|
+
byStatus: magiActivityFold.byStatus,
|
|
580
|
+
...(magiActivityFold.staleSynthesized > 0 ? { staleSynthesized: magiActivityFold.staleSynthesized } : {}),
|
|
581
|
+
},
|
|
582
|
+
}
|
|
583
|
+
: { magiActivity })
|
|
584
|
+
: {}),
|
|
585
|
+
...(asyncRefineJobs.length > 0 ? { asyncRefineJobs } : {}),
|
|
586
|
+
...(historicalSessions ? { historicalSessions } : {}),
|
|
587
|
+
...(pendingCoordinatorEvents.length > 0 ? { pendingCoordinatorEvents } : {}),
|
|
588
|
+
...(unroutableDeliveries.length > 0 ? { unroutableDeliveries } : {}),
|
|
589
|
+
activeRefineJobs: Array.from(ctx.runningRefineJobs.values())
|
|
590
|
+
.filter(job => job.meshId === meshId)
|
|
591
|
+
.map(job => ({
|
|
592
|
+
jobId: job.jobId,
|
|
593
|
+
nodeId: job.targetNodeId,
|
|
594
|
+
workspace: job.workspace,
|
|
595
|
+
startedAt: job.startedAt,
|
|
596
|
+
status: job.status,
|
|
597
|
+
targetCoordinatorDaemonId: job.targetCoordinatorDaemonId,
|
|
598
|
+
})),
|
|
599
|
+
};
|
|
600
|
+
const { pendingCoordinatorEvents: _pendingCoordinatorEvents, unroutableDeliveries: _unroutableDeliveries, ...cacheableStatusResult } = statusResult as any;
|
|
601
|
+
// Verbose carries full mission goals; never store it in the shared
|
|
602
|
+
// (compact) aggregate cache or a later compact poll would return the
|
|
603
|
+
// heavy goals from cache. Return it without caching.
|
|
604
|
+
const rememberedStatus = verboseMissions
|
|
605
|
+
? cacheableStatusResult
|
|
606
|
+
: ctx.rememberAggregateMeshStatus(meshId, cacheableStatusResult, refreshReason);
|
|
607
|
+
const returnedStatus = {
|
|
608
|
+
...rememberedStatus,
|
|
609
|
+
...(pendingCoordinatorEvents.length > 0 ? { pendingCoordinatorEvents } : {}),
|
|
610
|
+
...(unroutableDeliveries.length > 0 ? { unroutableDeliveries } : {}),
|
|
611
|
+
};
|
|
612
|
+
logRepoMeshStatusDebug('return_live', {
|
|
613
|
+
meshId,
|
|
614
|
+
command: 'mesh_status',
|
|
615
|
+
refreshRequested,
|
|
616
|
+
refreshReason,
|
|
617
|
+
meshSource: meshRecord.source,
|
|
618
|
+
directTruth,
|
|
619
|
+
summary: summarizeRepoMeshStatusDebug(returnedStatus),
|
|
620
|
+
});
|
|
621
|
+
return returnedStatus;
|
|
622
|
+
} catch (e: any) {
|
|
623
|
+
return { success: false, error: e.message };
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
get_mesh_review_inbox: async (ctx: HighFamilyContext, args: any) => {
|
|
628
|
+
const meshId = typeof args?.meshId === 'string' ? args.meshId.trim() : '';
|
|
629
|
+
if (!meshId) return { success: false, error: 'meshId required' };
|
|
630
|
+
try {
|
|
631
|
+
const { deriveMeshReviewInboxItems } = await import('../../mesh/mesh-review-inbox.js');
|
|
632
|
+
const { readLedgerEntries } = await import('../../mesh/mesh-ledger.js');
|
|
633
|
+
const { getGitDiffSummary } = await import('../../git/git-diff.js');
|
|
634
|
+
const { existsSync } = await import('node:fs');
|
|
635
|
+
|
|
636
|
+
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
637
|
+
const mesh = meshRecord?.mesh;
|
|
638
|
+
if (!mesh) return { success: false, error: 'Mesh not found' };
|
|
639
|
+
|
|
640
|
+
// Ensure we have a fresh aggregate status so nodeStatuses carry
|
|
641
|
+
// computed fields (connection.state, branchConvergence, isLocalWorktree)
|
|
642
|
+
// that the raw mesh.nodes config objects don't have.
|
|
643
|
+
// When the caller provides an inlineMesh, prefer its nodes directly
|
|
644
|
+
// (they already carry the computed fields from the coordinator).
|
|
645
|
+
const inlineNodes = args?.inlineMesh && Array.isArray((args.inlineMesh as any)?.nodes)
|
|
646
|
+
? (args.inlineMesh as any).nodes as Record<string, unknown>[]
|
|
647
|
+
: null;
|
|
648
|
+
let cachedStatus = !inlineNodes ? ctx.getCachedAggregateMeshStatus(meshId, mesh, {}) : null;
|
|
649
|
+
if (!cachedStatus && !inlineNodes) {
|
|
650
|
+
const freshStatus = await ctx.execute('mesh_status', {
|
|
651
|
+
meshId,
|
|
652
|
+
inlineMesh: args?.inlineMesh,
|
|
653
|
+
refresh: true,
|
|
654
|
+
}, 'get_mesh_review_inbox');
|
|
655
|
+
cachedStatus = (freshStatus?.success !== false) ? freshStatus : null;
|
|
656
|
+
}
|
|
657
|
+
const nodeStatuses: Record<string, unknown>[] = inlineNodes
|
|
658
|
+
? inlineNodes
|
|
659
|
+
: Array.isArray(cachedStatus?.nodes)
|
|
660
|
+
? cachedStatus.nodes as Record<string, unknown>[]
|
|
661
|
+
: Array.isArray(mesh.nodes)
|
|
662
|
+
? mesh.nodes as Record<string, unknown>[]
|
|
663
|
+
: [];
|
|
664
|
+
|
|
665
|
+
const ledgerEntries = readLedgerEntries(meshId, { tail: 300 });
|
|
666
|
+
const derivation = deriveMeshReviewInboxItems({ nodes: nodeStatuses, ledgerEntries });
|
|
667
|
+
|
|
668
|
+
for (const item of derivation.items) {
|
|
669
|
+
const workspace = item.workspace;
|
|
670
|
+
if (!workspace || !existsSync(workspace)) continue;
|
|
671
|
+
const baseRef = item.defaultBranch
|
|
672
|
+
? `origin/${item.defaultBranch}`
|
|
673
|
+
: 'origin/main';
|
|
674
|
+
try {
|
|
675
|
+
const diffResult = await getGitDiffSummary(workspace, { baseRef, maxFiles: 100 });
|
|
676
|
+
if (diffResult.isGitRepo) {
|
|
677
|
+
item.diffSummary = {
|
|
678
|
+
baseRef,
|
|
679
|
+
files: diffResult.files.map(f => ({
|
|
680
|
+
path: f.path,
|
|
681
|
+
status: f.status,
|
|
682
|
+
insertions: f.insertions,
|
|
683
|
+
deletions: f.deletions,
|
|
684
|
+
binary: f.binary,
|
|
685
|
+
oldPath: f.oldPath,
|
|
686
|
+
})),
|
|
687
|
+
totalFiles: diffResult.files.length,
|
|
688
|
+
totalInsertions: diffResult.totalInsertions,
|
|
689
|
+
totalDeletions: diffResult.totalDeletions,
|
|
690
|
+
truncated: diffResult.truncated,
|
|
691
|
+
...(diffResult.error ? { error: diffResult.error } : {}),
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
} catch {
|
|
695
|
+
item.diffSummary = null;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return {
|
|
700
|
+
success: true,
|
|
701
|
+
meshId,
|
|
702
|
+
inbox: derivation.items,
|
|
703
|
+
remoteNodesExcluded: derivation.remoteNodesExcluded,
|
|
704
|
+
excludedRemoteNodeIds: derivation.excludedRemoteNodeIds,
|
|
705
|
+
};
|
|
706
|
+
} catch (e: any) {
|
|
707
|
+
return { success: false, error: e.message };
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
};
|