@adhdev/daemon-core 0.9.82-rc.43 → 0.9.82-rc.430
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,231 @@
|
|
|
1
|
+
import type { MeshLedgerEntry } from './mesh-ledger.js';
|
|
2
|
+
import type { PendingMeshCoordinatorEvent } from './mesh-events.js';
|
|
3
|
+
import type { MeshAsyncJobLifecycle } from '../repo-mesh-types.js';
|
|
4
|
+
|
|
5
|
+
export type MeshAsyncRefineJobStatus = 'accepted' | 'running' | 'completed' | 'failed';
|
|
6
|
+
|
|
7
|
+
export interface MeshAsyncRefineJobSummary extends MeshAsyncJobLifecycle {
|
|
8
|
+
jobId: string;
|
|
9
|
+
interactionId?: string;
|
|
10
|
+
status: MeshAsyncRefineJobStatus;
|
|
11
|
+
meshId?: string;
|
|
12
|
+
nodeId?: string;
|
|
13
|
+
targetNodeId?: string;
|
|
14
|
+
targetDaemonId?: string;
|
|
15
|
+
workspace?: string;
|
|
16
|
+
branch?: string;
|
|
17
|
+
into?: string;
|
|
18
|
+
retryOfJobId?: string;
|
|
19
|
+
lastEvent?: string;
|
|
20
|
+
lastLedgerKind?: string;
|
|
21
|
+
lastUpdatedAt?: string;
|
|
22
|
+
instruction: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function readString(value: unknown): string | undefined {
|
|
26
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function readRecord(value: unknown): Record<string, unknown> | undefined {
|
|
30
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
31
|
+
? value as Record<string, unknown>
|
|
32
|
+
: undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function eventStatus(event: string | undefined, fallback?: string): MeshAsyncRefineJobStatus | undefined {
|
|
36
|
+
if (event === 'refine:accepted') return 'accepted';
|
|
37
|
+
if (event === 'refine:completed') return 'completed';
|
|
38
|
+
if (event === 'refine:failed') return 'failed';
|
|
39
|
+
if (fallback === 'completed' || fallback === 'failed' || fallback === 'accepted') return fallback;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ledgerStatus(kind: string, fallback?: string): MeshAsyncRefineJobStatus {
|
|
44
|
+
if (kind === 'task_completed') return 'completed';
|
|
45
|
+
if (kind === 'task_failed') return 'failed';
|
|
46
|
+
if (fallback === 'accepted') return 'accepted';
|
|
47
|
+
return 'running';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function instructionForStatus(status: MeshAsyncRefineJobStatus): string {
|
|
51
|
+
if (status === 'accepted') return 'Refine job is accepted; wait for asyncRefineJobs or pendingCoordinatorEvents to report running/completed/failed.';
|
|
52
|
+
if (status === 'running') return 'Refine job is running; do not poll the ledger repeatedly. Watch asyncRefineJobs or pendingCoordinatorEvents for the terminal result.';
|
|
53
|
+
if (status === 'completed') return 'Refine job completed; inspect branch convergence and cleanup evidence before reporting final merge state.';
|
|
54
|
+
return 'Refine job failed; inspect result/finalBranchConvergenceState in mesh_task_history, fix the blocker, then rerun mesh_refine_node when ready.';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function mergeJob(
|
|
58
|
+
jobs: Map<string, MeshAsyncRefineJobSummary>,
|
|
59
|
+
patch: Partial<MeshAsyncRefineJobSummary> & { jobId?: string },
|
|
60
|
+
): void {
|
|
61
|
+
const jobId = readString(patch.jobId);
|
|
62
|
+
if (!jobId) return;
|
|
63
|
+
const previous = jobs.get(jobId);
|
|
64
|
+
const status = patch.status || previous?.status || 'running';
|
|
65
|
+
const definedPatch = Object.fromEntries(
|
|
66
|
+
Object.entries(patch).filter(([, value]) => value !== undefined),
|
|
67
|
+
) as Partial<MeshAsyncRefineJobSummary>;
|
|
68
|
+
jobs.set(jobId, {
|
|
69
|
+
...previous,
|
|
70
|
+
...definedPatch,
|
|
71
|
+
jobId,
|
|
72
|
+
status,
|
|
73
|
+
instruction: instructionForStatus(status),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function buildMeshAsyncRefineJobs(args: {
|
|
78
|
+
meshId?: string;
|
|
79
|
+
ledgerEntries?: MeshLedgerEntry[];
|
|
80
|
+
pendingEvents?: PendingMeshCoordinatorEvent[];
|
|
81
|
+
}): MeshAsyncRefineJobSummary[] {
|
|
82
|
+
const jobs = new Map<string, MeshAsyncRefineJobSummary>();
|
|
83
|
+
|
|
84
|
+
for (const entry of args.ledgerEntries || []) {
|
|
85
|
+
const payload = readRecord(entry.payload);
|
|
86
|
+
if (payload?.source !== 'refine_mesh_node_async_job') continue;
|
|
87
|
+
const refineJob = readRecord(payload.refineJob);
|
|
88
|
+
const result = readRecord(payload.result);
|
|
89
|
+
const finalState = readRecord(payload.finalBranchConvergenceState) || readRecord(result?.finalBranchConvergenceState);
|
|
90
|
+
const jobId = readString(refineJob?.jobId);
|
|
91
|
+
if (!jobId) continue;
|
|
92
|
+
const status = ledgerStatus(entry.kind, readString(refineJob?.status));
|
|
93
|
+
mergeJob(jobs, {
|
|
94
|
+
jobId,
|
|
95
|
+
interactionId: readString(refineJob?.interactionId),
|
|
96
|
+
status,
|
|
97
|
+
meshId: readString(refineJob?.meshId) || args.meshId,
|
|
98
|
+
nodeId: readString(refineJob?.nodeId) || entry.nodeId,
|
|
99
|
+
targetNodeId: readString(refineJob?.nodeId) || entry.nodeId,
|
|
100
|
+
targetDaemonId: readString(refineJob?.targetDaemonId),
|
|
101
|
+
workspace: readString(refineJob?.workspace),
|
|
102
|
+
branch: readString(result?.branch) || readString(finalState?.branch),
|
|
103
|
+
into: readString(result?.into) || readString(finalState?.baseBranch),
|
|
104
|
+
startedAt: readString(refineJob?.startedAt),
|
|
105
|
+
completedAt: readString(refineJob?.completedAt),
|
|
106
|
+
retryOfJobId: readString(refineJob?.retryOfJobId) || readString(payload.retryOfJobId),
|
|
107
|
+
lastLedgerKind: entry.kind,
|
|
108
|
+
lastUpdatedAt: entry.timestamp,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for (const event of args.pendingEvents || []) {
|
|
113
|
+
const metadata = readRecord(event.metadataEvent);
|
|
114
|
+
if (metadata?.source !== 'refine_mesh_node_async_job') continue;
|
|
115
|
+
const result = readRecord(metadata.result);
|
|
116
|
+
const finalState = readRecord(result?.finalBranchConvergenceState);
|
|
117
|
+
const jobId = readString(metadata.jobId);
|
|
118
|
+
if (!jobId) continue;
|
|
119
|
+
const status = eventStatus(event.event, readString(metadata.status));
|
|
120
|
+
mergeJob(jobs, {
|
|
121
|
+
jobId,
|
|
122
|
+
interactionId: readString(metadata.interactionId),
|
|
123
|
+
...(status ? { status } : {}),
|
|
124
|
+
meshId: readString(metadata.meshId) || event.meshId || args.meshId,
|
|
125
|
+
nodeId: readString(metadata.nodeId) || event.nodeId,
|
|
126
|
+
targetNodeId: readString(metadata.nodeId) || event.nodeId,
|
|
127
|
+
targetDaemonId: readString(metadata.targetDaemonId),
|
|
128
|
+
workspace: readString(metadata.workspace) || event.workspace,
|
|
129
|
+
branch: readString(result?.branch) || readString(finalState?.branch),
|
|
130
|
+
into: readString(result?.into) || readString(finalState?.baseBranch),
|
|
131
|
+
startedAt: readString(metadata.startedAt),
|
|
132
|
+
completedAt: readString(metadata.completedAt),
|
|
133
|
+
retryOfJobId: readString(metadata.retryOfJobId),
|
|
134
|
+
lastEvent: event.event,
|
|
135
|
+
lastUpdatedAt: new Date(event.queuedAt).toISOString(),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return Array.from(jobs.values()).sort((a, b) => {
|
|
140
|
+
const aTime = new Date(a.lastUpdatedAt || a.startedAt || '').getTime();
|
|
141
|
+
const bTime = new Date(b.lastUpdatedAt || b.startedAt || '').getTime();
|
|
142
|
+
return (Number.isFinite(bTime) ? bTime : 0) - (Number.isFinite(aTime) ? aTime : 0);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const TERMINAL_REFINE_STATUSES = new Set<MeshAsyncRefineJobStatus>(['completed', 'failed']);
|
|
147
|
+
|
|
148
|
+
/** Terminal refine jobs older than this (relative to the newest job in the set) are
|
|
149
|
+
* "stale" — already-resolved historical refinery rejections/successes that should not
|
|
150
|
+
* keep inflating the status counts in mesh_status. 6h covers a long working session
|
|
151
|
+
* while still folding multi-day-old residue. */
|
|
152
|
+
export const STALE_TERMINAL_REFINE_WINDOW_MS = 6 * 60 * 60 * 1000;
|
|
153
|
+
|
|
154
|
+
/** Cap on how many recent terminal jobs are counted even if all fall inside the freshness
|
|
155
|
+
* window — prevents a burst of refines from dominating the summary. */
|
|
156
|
+
export const RECENT_TERMINAL_REFINE_CAP = 8;
|
|
157
|
+
|
|
158
|
+
export interface MeshAsyncRefineJobsSummary {
|
|
159
|
+
/** Count of jobs reflected in `byStatus` (active jobs + recent terminal jobs). */
|
|
160
|
+
total: number;
|
|
161
|
+
byStatus: Record<string, number>;
|
|
162
|
+
/** Terminal jobs dropped from the counts because they are stale residue. */
|
|
163
|
+
staleTerminal: number;
|
|
164
|
+
/** Non-terminal (accepted/running) jobs still in flight. */
|
|
165
|
+
activeJobs: MeshAsyncRefineJobSummary[];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function jobActivityTime(job: MeshAsyncRefineJobSummary): number {
|
|
169
|
+
const raw = job.lastUpdatedAt || job.completedAt || job.startedAt || '';
|
|
170
|
+
const t = new Date(raw).getTime();
|
|
171
|
+
return Number.isFinite(t) ? t : 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Build a compact summary of refine jobs that folds stale terminal jobs.
|
|
176
|
+
*
|
|
177
|
+
* The full job list (from `buildMeshAsyncRefineJobs`) is derived from a recent ledger
|
|
178
|
+
* window and deduped by jobId, but it still includes every terminal (completed/failed)
|
|
179
|
+
* job that happens to fall in that window — including multi-day-old refinery rejections
|
|
180
|
+
* that have long since been resolved. Those stale terminals inflate `byStatus.failed`
|
|
181
|
+
* and read as "current breakage" when they are historical noise.
|
|
182
|
+
*
|
|
183
|
+
* Active (accepted/running) jobs are always counted. Terminal jobs are counted only when
|
|
184
|
+
* they are recent: within `STALE_TERMINAL_REFINE_WINDOW_MS` of the newest job's activity
|
|
185
|
+
* time AND among the `RECENT_TERMINAL_REFINE_CAP` most-recent terminals. Everything else
|
|
186
|
+
* is folded into `staleTerminal` and excluded from `byStatus`.
|
|
187
|
+
*
|
|
188
|
+
* Freshness is measured relative to the newest job in the set (not wall-clock), so the
|
|
189
|
+
* result is deterministic for a given input — important for tests and for stale-clock
|
|
190
|
+
* environments.
|
|
191
|
+
*/
|
|
192
|
+
export function summarizeMeshAsyncRefineJobs(
|
|
193
|
+
jobs: MeshAsyncRefineJobSummary[],
|
|
194
|
+
): MeshAsyncRefineJobsSummary {
|
|
195
|
+
const activeJobs: MeshAsyncRefineJobSummary[] = [];
|
|
196
|
+
const terminalJobs: MeshAsyncRefineJobSummary[] = [];
|
|
197
|
+
for (const job of jobs) {
|
|
198
|
+
if (TERMINAL_REFINE_STATUSES.has(job.status)) terminalJobs.push(job);
|
|
199
|
+
else activeJobs.push(job);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Newest activity across ALL jobs anchors the freshness window.
|
|
203
|
+
let newest = 0;
|
|
204
|
+
for (const job of jobs) newest = Math.max(newest, jobActivityTime(job));
|
|
205
|
+
const cutoff = newest - STALE_TERMINAL_REFINE_WINDOW_MS;
|
|
206
|
+
|
|
207
|
+
const terminalByRecency = [...terminalJobs].sort(
|
|
208
|
+
(a, b) => jobActivityTime(b) - jobActivityTime(a),
|
|
209
|
+
);
|
|
210
|
+
const freshTerminal = terminalByRecency
|
|
211
|
+
.filter(job => jobActivityTime(job) >= cutoff)
|
|
212
|
+
.slice(0, RECENT_TERMINAL_REFINE_CAP);
|
|
213
|
+
const freshTerminalIds = new Set(freshTerminal.map(job => job.jobId));
|
|
214
|
+
|
|
215
|
+
const byStatus: Record<string, number> = {};
|
|
216
|
+
for (const job of activeJobs) {
|
|
217
|
+
byStatus[job.status] = (byStatus[job.status] ?? 0) + 1;
|
|
218
|
+
}
|
|
219
|
+
for (const job of freshTerminal) {
|
|
220
|
+
byStatus[job.status] = (byStatus[job.status] ?? 0) + 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const staleTerminal = terminalJobs.length - freshTerminalIds.size;
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
total: activeJobs.length + freshTerminal.length,
|
|
227
|
+
byStatus,
|
|
228
|
+
staleTerminal,
|
|
229
|
+
activeJobs,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M4.0: Review inbox — derive review items from existing truth.
|
|
3
|
+
*
|
|
4
|
+
* No new store: review items are a query-time projection of
|
|
5
|
+
* - mesh_status node statuses (daemon-owned branchConvergence), and
|
|
6
|
+
* - the task ledger (completion evidence envelopes + refine job results).
|
|
7
|
+
*
|
|
8
|
+
* Scope (M4.0): host-daemon-local nodes only. Remote nodes are excluded and
|
|
9
|
+
* surfaced via remoteNodesExcluded/excludedRemoteNodeIds until the
|
|
10
|
+
* daemon↔daemon P2P relay path is live-verified (M4.2).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { MeshLedgerEntry } from './mesh-ledger.js';
|
|
14
|
+
import { buildMeshAsyncRefineJobs } from './mesh-refine-status.js';
|
|
15
|
+
|
|
16
|
+
export type MeshReviewInboxReason = 'merge_candidate' | 'refine_blocked_review';
|
|
17
|
+
|
|
18
|
+
export interface MeshReviewInboxConvergence {
|
|
19
|
+
status: string;
|
|
20
|
+
reason: string | null;
|
|
21
|
+
nextStep: string | null;
|
|
22
|
+
needsConvergence: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface MeshReviewInboxEvidence {
|
|
26
|
+
available: boolean;
|
|
27
|
+
/** Ledger kind of the entry the evidence came from. */
|
|
28
|
+
kind?: 'task_completed' | 'task_failed';
|
|
29
|
+
/** 'task_completion' = ordinary worker completion envelope; 'refine_job' = Refinery result. */
|
|
30
|
+
source?: 'task_completion' | 'refine_job';
|
|
31
|
+
timestamp?: string;
|
|
32
|
+
taskId?: string;
|
|
33
|
+
sessionId?: string;
|
|
34
|
+
/** M2-3 bootstrap stage from the refine validation gate: cached|ran|failed|skipped|legacy|not_configured. */
|
|
35
|
+
bootstrap?: Record<string, unknown> | null;
|
|
36
|
+
validation?: Record<string, unknown> | null;
|
|
37
|
+
checkpoint?: Record<string, unknown> | null;
|
|
38
|
+
worker?: {
|
|
39
|
+
status: string;
|
|
40
|
+
classification?: string;
|
|
41
|
+
changedFiles: string[];
|
|
42
|
+
changedFilesTruncated?: true;
|
|
43
|
+
validationResults: Array<Record<string, unknown>>;
|
|
44
|
+
errors: string[];
|
|
45
|
+
requiresUserAction: boolean;
|
|
46
|
+
} | null;
|
|
47
|
+
finalBranchConvergenceState?: Record<string, unknown>;
|
|
48
|
+
refineJob?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface MeshReviewInboxDiffFile {
|
|
52
|
+
path: string;
|
|
53
|
+
status?: string;
|
|
54
|
+
insertions?: number;
|
|
55
|
+
deletions?: number;
|
|
56
|
+
binary?: boolean;
|
|
57
|
+
oldPath?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface MeshReviewInboxDiffSummary {
|
|
61
|
+
baseRef: string;
|
|
62
|
+
files: MeshReviewInboxDiffFile[];
|
|
63
|
+
totalFiles: number;
|
|
64
|
+
totalInsertions: number;
|
|
65
|
+
totalDeletions: number;
|
|
66
|
+
truncated: boolean;
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface MeshReviewInboxItem {
|
|
71
|
+
nodeId: string;
|
|
72
|
+
workspace: string | null;
|
|
73
|
+
branch: string | null;
|
|
74
|
+
defaultBranch: string | null;
|
|
75
|
+
isLocalWorktree: boolean;
|
|
76
|
+
reviewReason: MeshReviewInboxReason;
|
|
77
|
+
convergence: MeshReviewInboxConvergence;
|
|
78
|
+
evidence: MeshReviewInboxEvidence;
|
|
79
|
+
transcriptHandle: Record<string, unknown> | null;
|
|
80
|
+
/** Latest non-terminal Refinery job for this node (accepted/running), if any. */
|
|
81
|
+
activeRefineJob: Record<string, unknown> | null;
|
|
82
|
+
lastActivityAt: string | null;
|
|
83
|
+
/** Filled by the daemon command with a bounded base-branch diff probe; null when the workspace is not locally readable. */
|
|
84
|
+
diffSummary?: MeshReviewInboxDiffSummary | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface MeshReviewInboxDerivation {
|
|
88
|
+
items: MeshReviewInboxItem[];
|
|
89
|
+
remoteNodesExcluded: boolean;
|
|
90
|
+
excludedRemoteNodeIds: string[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const MAX_CHANGED_FILES = 100;
|
|
94
|
+
|
|
95
|
+
function readString(value: unknown): string | null {
|
|
96
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function readRecord(value: unknown): Record<string, unknown> | null {
|
|
100
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
101
|
+
? value as Record<string, unknown>
|
|
102
|
+
: null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function readStringArray(value: unknown, max: number): { values: string[]; truncated: boolean } {
|
|
106
|
+
if (!Array.isArray(value)) return { values: [], truncated: false };
|
|
107
|
+
const values = value.filter((item): item is string => typeof item === 'string' && item.trim().length > 0);
|
|
108
|
+
return { values: values.slice(0, max), truncated: values.length > max };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isLocalNodeStatus(node: Record<string, unknown>): boolean {
|
|
112
|
+
if (node.isLocalWorktree === true) return true;
|
|
113
|
+
const connection = readRecord(node.connection);
|
|
114
|
+
return readString(connection?.state) === 'self';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function readNodeConvergence(node: Record<string, unknown>): (MeshReviewInboxConvergence & { branch: string | null; defaultBranch: string | null }) | null {
|
|
118
|
+
const convergence = readRecord(node.branchConvergence);
|
|
119
|
+
const status = readString(convergence?.status);
|
|
120
|
+
if (!convergence || !status) return null;
|
|
121
|
+
return {
|
|
122
|
+
status,
|
|
123
|
+
reason: readString(convergence.reason),
|
|
124
|
+
nextStep: readString(convergence.nextStep),
|
|
125
|
+
needsConvergence: convergence.needsConvergence === true,
|
|
126
|
+
branch: readString(convergence.branch),
|
|
127
|
+
defaultBranch: readString(convergence.defaultBranch),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isMergeCandidate(convergence: MeshReviewInboxConvergence): boolean {
|
|
132
|
+
if (convergence.status === 'pushed_feature_branch_needs_merge') return true;
|
|
133
|
+
// Clean non-default worktree branch — the local merge candidate shape
|
|
134
|
+
// (router classifies it cleanup_candidate with this reason).
|
|
135
|
+
return convergence.status === 'cleanup_candidate'
|
|
136
|
+
&& convergence.reason === 'clean_non_default_worktree_branch';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function readWorkerArtifact(value: unknown): MeshReviewInboxEvidence['worker'] {
|
|
140
|
+
const worker = readRecord(value);
|
|
141
|
+
if (!worker) return null;
|
|
142
|
+
const changed = readStringArray(worker.changedFiles, MAX_CHANGED_FILES);
|
|
143
|
+
return {
|
|
144
|
+
status: readString(worker.status) ?? 'unknown',
|
|
145
|
+
...(readString(worker.classification) ? { classification: readString(worker.classification)! } : {}),
|
|
146
|
+
changedFiles: changed.values,
|
|
147
|
+
...(changed.truncated ? { changedFilesTruncated: true as const } : {}),
|
|
148
|
+
validationResults: Array.isArray(worker.validationResults)
|
|
149
|
+
? worker.validationResults.map(item => readRecord(item)).filter((item): item is Record<string, unknown> => item !== null)
|
|
150
|
+
: [],
|
|
151
|
+
errors: readStringArray(worker.errors, 20).values,
|
|
152
|
+
requiresUserAction: worker.requiresUserAction === true,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function isTerminalLedgerKind(kind: string): kind is 'task_completed' | 'task_failed' {
|
|
157
|
+
return kind === 'task_completed' || kind === 'task_failed';
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Latest terminal evidence for a node, normalized into the review card shape.
|
|
162
|
+
* Refine job entries carry the validation gate summary (incl. the M2-3
|
|
163
|
+
* bootstrap stage); ordinary completions carry the B-series evidence envelope.
|
|
164
|
+
*/
|
|
165
|
+
function resolveNodeEvidence(nodeId: string, ledgerEntries: MeshLedgerEntry[]): {
|
|
166
|
+
evidence: MeshReviewInboxEvidence;
|
|
167
|
+
transcriptHandle: Record<string, unknown> | null;
|
|
168
|
+
} {
|
|
169
|
+
let evidence: MeshReviewInboxEvidence = { available: false };
|
|
170
|
+
let transcriptHandle: Record<string, unknown> | null = null;
|
|
171
|
+
|
|
172
|
+
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
173
|
+
const entry = ledgerEntries[i];
|
|
174
|
+
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
175
|
+
const payload = readRecord(entry.payload) ?? {};
|
|
176
|
+
|
|
177
|
+
if (!evidence.available) {
|
|
178
|
+
if (payload.source === 'refine_mesh_node_async_job') {
|
|
179
|
+
const result = readRecord(payload.result);
|
|
180
|
+
const validationSummary = readRecord(result?.validationSummary);
|
|
181
|
+
evidence = {
|
|
182
|
+
available: true,
|
|
183
|
+
kind: entry.kind,
|
|
184
|
+
source: 'refine_job',
|
|
185
|
+
timestamp: entry.timestamp,
|
|
186
|
+
...(entry.sessionId ? { sessionId: entry.sessionId } : {}),
|
|
187
|
+
bootstrap: readRecord(validationSummary?.bootstrap),
|
|
188
|
+
validation: validationSummary
|
|
189
|
+
? Object.fromEntries(Object.entries(validationSummary).filter(([key]) => key !== 'bootstrap'))
|
|
190
|
+
: null,
|
|
191
|
+
checkpoint: readRecord(result?.checkpoint),
|
|
192
|
+
worker: null,
|
|
193
|
+
...(readRecord(payload.finalBranchConvergenceState) ?? readRecord(result?.finalBranchConvergenceState)
|
|
194
|
+
? { finalBranchConvergenceState: (readRecord(payload.finalBranchConvergenceState) ?? readRecord(result?.finalBranchConvergenceState))! }
|
|
195
|
+
: {}),
|
|
196
|
+
...(readRecord(payload.refineJob) ? { refineJob: readRecord(payload.refineJob)! } : {}),
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
const envelope = readRecord(payload.evidence);
|
|
200
|
+
evidence = {
|
|
201
|
+
available: true,
|
|
202
|
+
kind: entry.kind,
|
|
203
|
+
source: 'task_completion',
|
|
204
|
+
timestamp: entry.timestamp,
|
|
205
|
+
...(readString(payload.taskId) ? { taskId: readString(payload.taskId)! } : {}),
|
|
206
|
+
...(entry.sessionId ? { sessionId: entry.sessionId } : {}),
|
|
207
|
+
bootstrap: null,
|
|
208
|
+
validation: readRecord(envelope?.validation),
|
|
209
|
+
checkpoint: readRecord(envelope?.checkpoint),
|
|
210
|
+
worker: readWorkerArtifact(envelope?.workerResult ?? payload.workerResult),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (!transcriptHandle) {
|
|
216
|
+
const envelope = readRecord(payload.evidence);
|
|
217
|
+
transcriptHandle = readRecord(envelope?.transcriptHandle);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (evidence.available && transcriptHandle) break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return { evidence, transcriptHandle };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Latest refine terminal result for a node that classified it blocked_review. */
|
|
227
|
+
function hasBlockedReviewRefineResult(nodeId: string, ledgerEntries: MeshLedgerEntry[]): boolean {
|
|
228
|
+
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
229
|
+
const entry = ledgerEntries[i];
|
|
230
|
+
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
231
|
+
const payload = readRecord(entry.payload) ?? {};
|
|
232
|
+
if (payload.source !== 'refine_mesh_node_async_job') continue;
|
|
233
|
+
const result = readRecord(payload.result);
|
|
234
|
+
const finalState = readRecord(payload.finalBranchConvergenceState) ?? readRecord(result?.finalBranchConvergenceState);
|
|
235
|
+
// Only the most recent refine terminal counts — an older blocked_review
|
|
236
|
+
// superseded by a successful refine must not resurrect the card.
|
|
237
|
+
return readString(finalState?.status) === 'blocked_review'
|
|
238
|
+
|| readString(result?.code) === 'blocked_review';
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Derive review inbox items from mesh_status node statuses and a bounded
|
|
245
|
+
* ledger tail. Pure and read-only; the caller attaches diffSummary separately.
|
|
246
|
+
*/
|
|
247
|
+
export function deriveMeshReviewInboxItems(args: {
|
|
248
|
+
nodes: Array<Record<string, unknown>>;
|
|
249
|
+
ledgerEntries: MeshLedgerEntry[];
|
|
250
|
+
}): MeshReviewInboxDerivation {
|
|
251
|
+
const items: MeshReviewInboxItem[] = [];
|
|
252
|
+
const excludedRemoteNodeIds: string[] = [];
|
|
253
|
+
const refineJobs = buildMeshAsyncRefineJobs({ ledgerEntries: args.ledgerEntries });
|
|
254
|
+
|
|
255
|
+
for (const node of args.nodes) {
|
|
256
|
+
const nodeId = readString(node.nodeId) ?? readString(node.id);
|
|
257
|
+
if (!nodeId) continue;
|
|
258
|
+
|
|
259
|
+
if (!isLocalNodeStatus(node)) {
|
|
260
|
+
excludedRemoteNodeIds.push(nodeId);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const convergence = readNodeConvergence(node);
|
|
265
|
+
if (!convergence) continue;
|
|
266
|
+
if (convergence.status === 'merged_to_main') continue;
|
|
267
|
+
|
|
268
|
+
let reviewReason: MeshReviewInboxReason | null = null;
|
|
269
|
+
if (hasBlockedReviewRefineResult(nodeId, args.ledgerEntries)) {
|
|
270
|
+
reviewReason = 'refine_blocked_review';
|
|
271
|
+
} else if (isMergeCandidate(convergence)) {
|
|
272
|
+
reviewReason = 'merge_candidate';
|
|
273
|
+
}
|
|
274
|
+
if (!reviewReason) continue;
|
|
275
|
+
|
|
276
|
+
const { evidence, transcriptHandle } = resolveNodeEvidence(nodeId, args.ledgerEntries);
|
|
277
|
+
const activeRefineJob = [...refineJobs].reverse().find(job =>
|
|
278
|
+
(job.nodeId === nodeId || job.targetNodeId === nodeId)
|
|
279
|
+
&& (job.status === 'accepted' || job.status === 'running'),
|
|
280
|
+
) ?? null;
|
|
281
|
+
|
|
282
|
+
items.push({
|
|
283
|
+
nodeId,
|
|
284
|
+
workspace: readString(node.workspace),
|
|
285
|
+
branch: convergence.branch ?? readString(node.worktreeBranch),
|
|
286
|
+
defaultBranch: convergence.defaultBranch,
|
|
287
|
+
isLocalWorktree: node.isLocalWorktree === true,
|
|
288
|
+
reviewReason,
|
|
289
|
+
convergence: {
|
|
290
|
+
status: convergence.status,
|
|
291
|
+
reason: convergence.reason,
|
|
292
|
+
nextStep: convergence.nextStep,
|
|
293
|
+
needsConvergence: convergence.needsConvergence,
|
|
294
|
+
},
|
|
295
|
+
evidence,
|
|
296
|
+
transcriptHandle,
|
|
297
|
+
activeRefineJob: activeRefineJob as Record<string, unknown> | null,
|
|
298
|
+
lastActivityAt: evidence.timestamp ?? null,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
items,
|
|
304
|
+
remoteNodesExcluded: excludedRemoteNodeIds.length > 0,
|
|
305
|
+
excludedRemoteNodeIds,
|
|
306
|
+
};
|
|
307
|
+
}
|