@adhdev/daemon-core 0.9.82-rc.37 → 0.9.82-rc.370
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 +55 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +116 -64
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-runtime.d.ts +34 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +63 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +14 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/chat-commands.d.ts +27 -0
- package/dist/commands/cli-manager.d.ts +15 -1
- package/dist/commands/handler.d.ts +125 -0
- package/dist/commands/high-family/index.d.ts +3 -0
- package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
- package/dist/commands/high-family/mesh-events.d.ts +2 -0
- package/dist/commands/high-family/mesh-status.d.ts +2 -0
- package/dist/commands/high-family/types.d.ts +60 -0
- package/dist/commands/low-family/coordinator-prompt.d.ts +9 -0
- package/dist/commands/low-family/daemon-lifecycle.d.ts +2 -0
- package/dist/commands/low-family/diagnostics.d.ts +2 -0
- package/dist/commands/low-family/index.d.ts +3 -0
- package/dist/commands/low-family/mesh-ledger.d.ts +10 -0
- package/dist/commands/low-family/mesh-node-logs.d.ts +2 -0
- package/dist/commands/low-family/notification.d.ts +2 -0
- package/dist/commands/low-family/refine-config.d.ts +2 -0
- package/dist/commands/low-family/session-host.d.ts +2 -0
- package/dist/commands/low-family/spec-providerdev.d.ts +11 -0
- package/dist/commands/low-family/status-meta.d.ts +2 -0
- package/dist/commands/low-family/types.d.ts +33 -0
- package/dist/commands/med-family/cli-agent.d.ts +2 -0
- package/dist/commands/med-family/fast-forward.d.ts +2 -0
- package/dist/commands/med-family/ide.d.ts +10 -0
- package/dist/commands/med-family/index.d.ts +3 -0
- package/dist/commands/med-family/mesh-crud.d.ts +2 -0
- package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
- package/dist/commands/med-family/mesh-queue.d.ts +2 -0
- package/dist/commands/med-family/types.d.ts +116 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +666 -2
- package/dist/commands/upgrade-helper.d.ts +41 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +77 -1
- package/dist/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 +23 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/git/index.d.ts +2 -0
- package/dist/index.d.ts +55 -13
- package/dist/index.js +46516 -19739
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43516 -16870
- 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 +46 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +36 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +174 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-event-trace.d.ts +21 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +91 -0
- package/dist/mesh/mesh-events-pending.d.ts +55 -0
- package/dist/mesh/mesh-events-stale.d.ts +40 -0
- package/dist/mesh/mesh-events-utils.d.ts +61 -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 -3
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-missions.d.ts +164 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -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 +429 -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 +246 -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 +135 -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 +12 -0
- package/dist/providers/cli-provider-instance.d.ts +108 -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/dispatcher.d.ts +27 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +14 -0
- package/dist/providers/provider-instance.d.ts +23 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +86 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +91 -0
- package/dist/providers/spec/cli-adapter.d.ts +223 -0
- package/dist/providers/spec/evaluator.d.ts +45 -0
- package/dist/providers/spec/fsm-driver.d.ts +395 -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 +295 -13
- 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 +1 -0
- package/src/cli-adapter-types.ts +56 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1221 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +775 -1141
- package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/src/cli-adapters/provider-cli-parse.ts +13 -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 +110 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +90 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -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.ts +1917 -62
- package/src/commands/cli-manager.ts +502 -24
- 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 +592 -0
- package/src/commands/high-family/mesh-events.ts +47 -0
- package/src/commands/high-family/mesh-status.ts +642 -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 +81 -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 +218 -0
- package/src/commands/med-family/fast-forward.ts +198 -0
- package/src/commands/med-family/ide.ts +163 -0
- package/src/commands/med-family/index.ts +35 -0
- package/src/commands/med-family/mesh-crud.ts +788 -0
- package/src/commands/med-family/mesh-host-pairing.ts +234 -0
- package/src/commands/med-family/mesh-queue.ts +131 -0
- package/src/commands/med-family/types.ts +120 -0
- package/src/commands/mesh-coordinator.ts +334 -124
- package/src/commands/router.ts +5121 -2369
- 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 +389 -6
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/daemon/dev-server.ts +0 -541
- package/src/detection/cli-detector.ts +28 -9
- package/src/detection/ide-detector.ts +55 -16
- package/src/detection/win32-ide-version.ts +106 -0
- package/src/git/change-impact-config.ts +354 -0
- package/src/git/git-commands.ts +55 -14
- package/src/git/git-diff.ts +81 -11
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +574 -43
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +8 -1
- package/src/git/index.ts +16 -0
- package/src/index.ts +158 -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 +220 -0
- package/src/logging/logger.ts +14 -7
- package/src/mesh/contracts.ts +338 -0
- package/src/mesh/coordinator-prompt.ts +234 -31
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +645 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-event-trace.ts +67 -0
- package/src/mesh/mesh-events-coordinator.ts +2866 -0
- package/src/mesh/mesh-events-pending.ts +599 -0
- package/src/mesh/mesh-events-stale.ts +309 -0
- package/src/mesh/mesh-events-utils.ts +387 -0
- package/src/mesh/mesh-events.ts +30 -1035
- package/src/mesh/mesh-fast-forward.ts +839 -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 -5
- package/src/mesh/mesh-ledger.ts +591 -102
- package/src/mesh/mesh-missions.ts +322 -0
- package/src/mesh/mesh-reconcile-loop.ts +1134 -0
- package/src/mesh/mesh-refine-batch.ts +197 -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 +1697 -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 +997 -141
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +423 -0
- package/src/mesh/worktree-bootstrap-config.ts +331 -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 +45 -5
- package/src/providers/cli-provider-instance.ts +1310 -101
- 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/dispatcher.ts +340 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +30 -0
- package/src/providers/provider-instance.ts +19 -1
- package/src/providers/provider-loader.ts +668 -50
- package/src/providers/provider-schema.ts +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +313 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +235 -0
- package/src/providers/spec/cli-adapter.ts +1051 -0
- package/src/providers/spec/evaluator.ts +407 -0
- package/src/providers/spec/fsm-driver.ts +1305 -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 +1136 -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 +378 -14
- 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
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import type { AppendRemoteLedgerResult,
|
|
1
|
+
import type { AppendRemoteLedgerResult, MeshLedgerSummary } from './mesh-ledger.js';
|
|
2
|
+
/** Minimal ledger slice shape accepted by buildMeshLedgerReplicaEvidence. Covers both JSONL and SQLite slices. */
|
|
3
|
+
export interface AnyLedgerSlice {
|
|
4
|
+
entries: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
meshId: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
nodeId?: string | null;
|
|
10
|
+
sessionId?: string | null;
|
|
11
|
+
providerType?: string | null;
|
|
12
|
+
payload: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
cursor: {
|
|
15
|
+
afterId: string | null;
|
|
16
|
+
nextAfterId: string | null;
|
|
17
|
+
limit: number;
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
};
|
|
20
|
+
summary?: MeshLedgerSummary;
|
|
21
|
+
}
|
|
2
22
|
export type MeshLedgerReplicaStatus = 'local' | 'queried' | 'imported' | 'failed';
|
|
3
23
|
export interface MeshLedgerReplicaEvidence {
|
|
4
24
|
nodeId: string;
|
|
@@ -22,7 +42,7 @@ export interface MeshLedgerReconciliationEvidence {
|
|
|
22
42
|
meshId: string;
|
|
23
43
|
generatedAt: string;
|
|
24
44
|
sourceOfTruth: {
|
|
25
|
-
kind: '
|
|
45
|
+
kind: 'coordinator_local_sqlite';
|
|
26
46
|
p2pOnly: true;
|
|
27
47
|
cloudD1LedgerSync: false;
|
|
28
48
|
notes: string;
|
|
@@ -47,7 +67,7 @@ export declare function buildMeshLedgerReplicaEvidence(args: {
|
|
|
47
67
|
nodeId: string;
|
|
48
68
|
daemonId?: string;
|
|
49
69
|
transport: 'local' | 'p2p_datachannel';
|
|
50
|
-
slice?:
|
|
70
|
+
slice?: AnyLedgerSlice;
|
|
51
71
|
importResult?: AppendRemoteLedgerResult;
|
|
52
72
|
status?: MeshLedgerReplicaStatus;
|
|
53
73
|
error?: string;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* Safety: mode 0o600, atomic append via appendFileSync
|
|
14
14
|
*/
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
|
-
|
|
16
|
+
import { MeshRuntimeStore } from './mesh-runtime-store.js';
|
|
17
|
+
export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'p2p_dispatch_failed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_joined' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled' | 'direct_fast_forward' | 'delivery_unroutable' | 'direct_dispatch_pruned' | 'event_held' | 'task_reclaimed';
|
|
17
18
|
export interface MeshLedgerEntry {
|
|
18
19
|
id: string;
|
|
19
20
|
meshId: string;
|
|
@@ -25,6 +26,40 @@ export interface MeshLedgerEntry {
|
|
|
25
26
|
payload: Record<string, unknown>;
|
|
26
27
|
}
|
|
27
28
|
export declare function isIntentionalCleanupStopEntry(entry: Pick<MeshLedgerEntry, 'kind' | 'payload'>): boolean;
|
|
29
|
+
export type MeshWorkerResultStatus = 'completed' | 'failed' | 'blocked' | 'partial' | 'unknown';
|
|
30
|
+
export type MeshProcessArtifactKind = 'process' | 'log' | 'port' | 'window' | 'session' | 'file' | 'url' | 'other';
|
|
31
|
+
export interface MeshValidationResultArtifact {
|
|
32
|
+
command?: string;
|
|
33
|
+
status: 'passed' | 'failed' | 'skipped' | 'unknown';
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
outputPath?: string;
|
|
36
|
+
summary?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface MeshProcessArtifact {
|
|
39
|
+
kind: MeshProcessArtifactKind;
|
|
40
|
+
id?: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
locator?: string;
|
|
43
|
+
pid?: number;
|
|
44
|
+
port?: number;
|
|
45
|
+
url?: string;
|
|
46
|
+
path?: string;
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
keepRunning?: boolean;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface MeshWorkerResultArtifact {
|
|
52
|
+
status: MeshWorkerResultStatus;
|
|
53
|
+
classification?: string;
|
|
54
|
+
changedFiles: string[];
|
|
55
|
+
validationResults: MeshValidationResultArtifact[];
|
|
56
|
+
gitStatus?: Record<string, unknown>;
|
|
57
|
+
processArtifacts: MeshProcessArtifact[];
|
|
58
|
+
errors: string[];
|
|
59
|
+
nextAction?: string;
|
|
60
|
+
requiresUserAction: boolean;
|
|
61
|
+
source: 'explicit_metadata' | 'final_summary_json' | 'default';
|
|
62
|
+
}
|
|
28
63
|
export interface MeshTaskCompletionEvidence {
|
|
29
64
|
source: 'agent_status_event';
|
|
30
65
|
event: 'agent:generating_completed' | 'agent:ready';
|
|
@@ -38,6 +73,7 @@ export interface MeshTaskCompletionEvidence {
|
|
|
38
73
|
providerSessionId?: string;
|
|
39
74
|
finalSummaryAvailable: boolean;
|
|
40
75
|
};
|
|
76
|
+
workerResult: MeshWorkerResultArtifact;
|
|
41
77
|
git: {
|
|
42
78
|
status: 'deferred';
|
|
43
79
|
reason: string;
|
|
@@ -59,6 +95,7 @@ export interface BuildTaskCompletionEvidenceOptions {
|
|
|
59
95
|
providerType?: string;
|
|
60
96
|
providerSessionId?: string;
|
|
61
97
|
finalSummary?: string;
|
|
98
|
+
workerResult?: Record<string, unknown>;
|
|
62
99
|
completedAt?: string;
|
|
63
100
|
}
|
|
64
101
|
export interface MeshLedgerSummary {
|
|
@@ -115,6 +152,27 @@ export interface AppendRemoteLedgerResult {
|
|
|
115
152
|
}
|
|
116
153
|
export declare const MAX_LEDGER_SLICE_LIMIT = 500;
|
|
117
154
|
export declare function getLedgerDir(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Footer to append to worker task messages so workers output structured results
|
|
157
|
+
* that the daemon parses via extractJsonObjectFromSummary / normalizeMeshWorkerResult.
|
|
158
|
+
*
|
|
159
|
+
* Usage: append buildWorkerTaskFooter() to the task message in mesh_send_task /
|
|
160
|
+
* mesh_enqueue_task. The coordinator prompt rules instruct coordinators to do this.
|
|
161
|
+
*/
|
|
162
|
+
export declare function buildWorkerTaskFooter(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Compact the active ledger file for a mesh by moving old terminal entries
|
|
165
|
+
* (task_completed, task_failed, task_stalled, recovery_attempted older than 7 days)
|
|
166
|
+
* to <meshId>.archive.jsonl, keeping the active file lean.
|
|
167
|
+
*
|
|
168
|
+
* Non-terminal entries (dispatch, sessions, node lifecycle) are always retained.
|
|
169
|
+
* Called automatically from appendLedgerEntry when the file exceeds COMPACT_THRESHOLD_BYTES.
|
|
170
|
+
*/
|
|
171
|
+
export declare function compactLedger(meshId: string): {
|
|
172
|
+
archivedCount: number;
|
|
173
|
+
retainedCount: number;
|
|
174
|
+
};
|
|
175
|
+
export declare function normalizeMeshWorkerResult(input?: Record<string, unknown>, source?: MeshWorkerResultArtifact['source']): MeshWorkerResultArtifact;
|
|
118
176
|
export declare function buildTaskCompletionEvidence(opts: BuildTaskCompletionEvidenceOptions): MeshTaskCompletionEvidence;
|
|
119
177
|
/**
|
|
120
178
|
* Append a new entry to the mesh ledger.
|
|
@@ -127,8 +185,16 @@ export declare function appendLedgerEntry(meshId: string, partial: Omit<MeshLedg
|
|
|
127
185
|
* This skips deduplicated entries and rejects malformed/cross-mesh entries.
|
|
128
186
|
*/
|
|
129
187
|
export declare function appendRemoteLedgerEntries(meshId: string, entries: MeshLedgerEntry[]): AppendRemoteLedgerResult;
|
|
188
|
+
/**
|
|
189
|
+
* Test helper: clear all runtime ledger state for a mesh — SQLite rows, read
|
|
190
|
+
* cache, and the one-time import flag. JSONL files are the caller's concern.
|
|
191
|
+
*/
|
|
192
|
+
export declare function __clearMeshLedgerForTests(meshId: string): void;
|
|
130
193
|
/**
|
|
131
194
|
* Read ledger entries with optional filtering.
|
|
195
|
+
* G2: SQLite (mesh_event_ledger) is the primary read path; legacy JSONL is
|
|
196
|
+
* imported once per store instance and otherwise retained as an
|
|
197
|
+
* export/import/debug artifact only.
|
|
132
198
|
*/
|
|
133
199
|
export declare function readLedgerEntries(meshId: string, opts?: ReadLedgerOptions): MeshLedgerEntry[];
|
|
134
200
|
/**
|
|
@@ -137,6 +203,16 @@ export declare function readLedgerEntries(meshId: string, opts?: ReadLedgerOptio
|
|
|
137
203
|
* remote daemons on demand without Cloud/D1 becoming a ledger data-plane.
|
|
138
204
|
*/
|
|
139
205
|
export declare function readLedgerSlice(meshId: string, opts?: ReadLedgerSliceOptions): MeshLedgerSlice;
|
|
206
|
+
/**
|
|
207
|
+
* G4: Read a bounded ledger slice from the SQLite mesh_event_ledger table.
|
|
208
|
+
* This is the preferred P2P reconcile read path; JSONL files are retained as
|
|
209
|
+
* export/import/debug/legacy artifacts only.
|
|
210
|
+
*
|
|
211
|
+
* Returns a shape structurally compatible with MeshLedgerSlice (minus the
|
|
212
|
+
* JSONL-specific `summary` and `sourceOfTruth.path` fields) so callers can
|
|
213
|
+
* pass it to buildMeshLedgerReplicaEvidence without modification.
|
|
214
|
+
*/
|
|
215
|
+
export declare function readLedgerSliceFromStore(meshId: string, opts?: ReadLedgerSliceOptions): ReturnType<typeof MeshRuntimeStore.prototype.readLedgerSlice>;
|
|
140
216
|
/**
|
|
141
217
|
* Get a summary of mesh activity from the ledger.
|
|
142
218
|
*/
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M3: Mission persistence (minimal form).
|
|
3
|
+
*
|
|
4
|
+
* A mission is a persistent record of a multi-task goal so the plan lives in
|
|
5
|
+
* the system rather than in the coordinator LLM's context. Coordinator
|
|
6
|
+
* sessions can die or compact; a new coordinator reads the mission back at
|
|
7
|
+
* launch and continues.
|
|
8
|
+
*
|
|
9
|
+
* Explicit non-goals (see docs/mesh-product-plan-v2.md Phase M3): this is not
|
|
10
|
+
* a workflow engine and there is no automatic takeover daemon. Progress is
|
|
11
|
+
* never stored — it is derived from queue task statuses (mission_id) at
|
|
12
|
+
* query time.
|
|
13
|
+
*/
|
|
14
|
+
import { type MeshMissionStats } from './mesh-task-stats.js';
|
|
15
|
+
export type MeshMissionStatus = 'active' | 'paused' | 'completed' | 'abandoned';
|
|
16
|
+
export declare const MESH_MISSION_STATUSES: MeshMissionStatus[];
|
|
17
|
+
export interface MeshMissionRecord {
|
|
18
|
+
id: string;
|
|
19
|
+
meshId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
goal: string;
|
|
22
|
+
status: MeshMissionStatus;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MeshMissionTaskAggregate {
|
|
27
|
+
total: number;
|
|
28
|
+
pending: number;
|
|
29
|
+
assigned: number;
|
|
30
|
+
completed: number;
|
|
31
|
+
failed: number;
|
|
32
|
+
cancelled: number;
|
|
33
|
+
/** Pending tasks held back by a dependency failure (blockedReason set). */
|
|
34
|
+
blocked: number;
|
|
35
|
+
/** Latest updatedAt across the mission's tasks, or null with no tasks. */
|
|
36
|
+
lastActivityAt: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface MeshMissionSummary extends MeshMissionRecord {
|
|
39
|
+
tasks: MeshMissionTaskAggregate;
|
|
40
|
+
/**
|
|
41
|
+
* Operational rollup (durations / attempts) derived from the ledger via
|
|
42
|
+
* computeMeshMissionStats. Optional: only populated by surfaces that opt in
|
|
43
|
+
* (e.g. mesh_status), since the rollup scans a bounded ledger tail per
|
|
44
|
+
* mission. Absent on the lightweight task-aggregate-only summaries.
|
|
45
|
+
*/
|
|
46
|
+
stats?: MeshMissionStats;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Slim mission summary for the mesh_status compact (default) surface. Drops the
|
|
50
|
+
* full `goal` text — which can be hundreds of chars per mission and is repeated
|
|
51
|
+
* for every mission on every status call — keeping only a short preview plus a
|
|
52
|
+
* `goalTruncated` flag when the original was longer. The stored goal is never
|
|
53
|
+
* mutated; this is an output-only projection. Coordinators that need the full
|
|
54
|
+
* goal call mesh_status with verbose=true, or read the mission directly via
|
|
55
|
+
* mesh_mission_upsert / getMeshMission.
|
|
56
|
+
*/
|
|
57
|
+
export interface MeshMissionSlimSummary extends Omit<MeshMissionSummary, 'goal'> {
|
|
58
|
+
/** Short preview of the goal (≤ GOAL_PREVIEW_MAX chars), '' when goal empty. */
|
|
59
|
+
goalPreview: string;
|
|
60
|
+
/** True when the stored goal was longer than the preview (full text elided). */
|
|
61
|
+
goalTruncated: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Max chars of goal text retained in the slim (compact) mission summary. */
|
|
64
|
+
export declare const GOAL_PREVIEW_MAX = 120;
|
|
65
|
+
/**
|
|
66
|
+
* Shorter goal preview used by the mesh_status compact (LLM coordinator) surface.
|
|
67
|
+
* The coordinator only needs to recognize a mission, not read its full goal, and
|
|
68
|
+
* mesh_status repeats every live mission on every poll — so the status preview is
|
|
69
|
+
* tighter than the dashboard / mesh_mission_list preview (GOAL_PREVIEW_MAX).
|
|
70
|
+
*/
|
|
71
|
+
export declare const COMPACT_STATUS_GOAL_PREVIEW_MAX = 80;
|
|
72
|
+
export declare function upsertMeshMission(meshId: string, input: {
|
|
73
|
+
id?: string;
|
|
74
|
+
title: string;
|
|
75
|
+
goal?: string;
|
|
76
|
+
status?: string;
|
|
77
|
+
}): MeshMissionRecord;
|
|
78
|
+
export declare function getMeshMissions(meshId: string, statuses?: MeshMissionStatus[]): MeshMissionRecord[];
|
|
79
|
+
export declare function getMeshMission(meshId: string, missionId: string): MeshMissionRecord | null;
|
|
80
|
+
/** Aggregate task statuses for a mission at query time (no stored progress). */
|
|
81
|
+
export declare function summarizeMissionTasks(meshId: string, missionId: string): MeshMissionTaskAggregate;
|
|
82
|
+
export declare function summarizeMeshMission(meshId: string, mission: MeshMissionRecord): MeshMissionSummary;
|
|
83
|
+
/** Active mission summaries for mesh_status / coordinator prompt injection. */
|
|
84
|
+
export declare function getActiveMeshMissionSummaries(meshId: string): MeshMissionSummary[];
|
|
85
|
+
/**
|
|
86
|
+
* Mission summaries for the mesh_status dashboard surface: every active/paused
|
|
87
|
+
* mission plus a capped, newest-first slice of completed/abandoned history so
|
|
88
|
+
* the dashboard can render a collapsible "history" section without unbounded
|
|
89
|
+
* payload growth. Returned newest-first within each group (active/paused first,
|
|
90
|
+
* then history), so the frontend can split on `status` directly.
|
|
91
|
+
*
|
|
92
|
+
* Compact mode (the default) elides each mission's full `goal` text — which is
|
|
93
|
+
* repeated verbatim on every status poll and dominates the payload when a mesh
|
|
94
|
+
* has many missions — returning only a short `goalPreview` + `goalTruncated`
|
|
95
|
+
* flag. Pass `verbose: true` to get the full `goal` text per mission. The stored
|
|
96
|
+
* goal is untouched in both modes; this is an output-only projection.
|
|
97
|
+
*/
|
|
98
|
+
export declare function getMeshStatusMissionSummaries(meshId: string, options?: {
|
|
99
|
+
historyLimit?: number;
|
|
100
|
+
verbose?: boolean;
|
|
101
|
+
withStats?: boolean;
|
|
102
|
+
}): MeshMissionSummary[] | MeshMissionSlimSummary[];
|
|
103
|
+
/** Folded completed/abandoned history for the mesh_status compact surface. */
|
|
104
|
+
export interface MeshStatusMissionsHistoryFold {
|
|
105
|
+
/** Total completed + abandoned missions. */
|
|
106
|
+
count: number;
|
|
107
|
+
/** Count by lifecycle status (e.g. { completed, abandoned }). */
|
|
108
|
+
byStatus: Record<string, number>;
|
|
109
|
+
/** Newest-first id list (capped) so each folded mission stays addressable. */
|
|
110
|
+
missionIds: string[];
|
|
111
|
+
note: string;
|
|
112
|
+
}
|
|
113
|
+
/** Compact mesh_status mission projection: live detail + folded history. */
|
|
114
|
+
export interface MeshStatusMissionsCompact {
|
|
115
|
+
/**
|
|
116
|
+
* Active + paused missions, goal-elided to COMPACT_STATUS_GOAL_PREVIEW_MAX and
|
|
117
|
+
* WITHOUT the operational `stats` rollup — the `tasks` aggregate already carries
|
|
118
|
+
* progress, and stats (durations/retries) is a verbose/dashboard concern.
|
|
119
|
+
*/
|
|
120
|
+
live: MeshMissionSlimSummary[];
|
|
121
|
+
/** Completed + abandoned missions folded to counts + ids; null when none. */
|
|
122
|
+
historyFold: MeshStatusMissionsHistoryFold | null;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Mission projection for the mesh_status COMPACT (LLM coordinator) surface.
|
|
126
|
+
*
|
|
127
|
+
* Unlike getMeshStatusMissionSummaries (which emits every live mission plus a
|
|
128
|
+
* capped slice of full-detail history, each carrying a stats rollup), this keeps
|
|
129
|
+
* per-mission detail ONLY for live (active/paused) missions and folds the whole
|
|
130
|
+
* completed/abandoned history into a counts + id-list summary. Combined with the
|
|
131
|
+
* tighter goal preview and dropped stats, this is what keeps the compact
|
|
132
|
+
* mesh_status payload bounded as a mesh accumulates missions — the missions
|
|
133
|
+
* section previously dominated the payload (full goalPreview + tasks + stats per
|
|
134
|
+
* mission, for every live mission and up to 10 history missions, on every poll).
|
|
135
|
+
*
|
|
136
|
+
* The stored missions are untouched; this is an output-only projection. Full
|
|
137
|
+
* mission detail (goal text + stats + history) stays available via
|
|
138
|
+
* mesh_status verbose=true or mesh_mission_list.
|
|
139
|
+
*/
|
|
140
|
+
export declare function getMeshStatusMissionsCompact(meshId: string, options?: {
|
|
141
|
+
previewMax?: number;
|
|
142
|
+
historyIdLimit?: number;
|
|
143
|
+
}): MeshStatusMissionsCompact;
|
|
144
|
+
/**
|
|
145
|
+
* Read-only mission listing for the mesh_mission_list tool. Returns summaries
|
|
146
|
+
* (record + live task aggregate) for missions matching `statuses` — or every
|
|
147
|
+
* mission when `statuses` is omitted/empty — newest-first by updatedAt. Unlike
|
|
148
|
+
* getMeshStatusMissionSummaries this does NOT cap or group by lifecycle, so a
|
|
149
|
+
* coordinator can deliberately surface paused/abandoned/completed missions that
|
|
150
|
+
* the live status view would hide or truncate.
|
|
151
|
+
*
|
|
152
|
+
* Compact (the default) elides each goal to a capped preview + goalTruncated
|
|
153
|
+
* flag; verbose returns the full goal text. The stored goal is never mutated.
|
|
154
|
+
*/
|
|
155
|
+
export declare function listMeshMissionSummaries(meshId: string, options?: {
|
|
156
|
+
statuses?: MeshMissionStatus[];
|
|
157
|
+
verbose?: boolean;
|
|
158
|
+
}): MeshMissionSummary[] | MeshMissionSlimSummary[];
|
|
159
|
+
/**
|
|
160
|
+
* M3-3: render active missions as a prompt section for {{mission}}.
|
|
161
|
+
* Empty string when no active mission — the prompt stays byte-identical to
|
|
162
|
+
* the pre-M3 output in that case (regression guarantee).
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildMissionPromptSection(meshId: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
|
|
2
|
+
export declare function runMeshReconcileTick(components: DaemonComponents): Promise<void>;
|
|
3
|
+
interface ReconcileLoopHandle {
|
|
4
|
+
stop(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function setupMeshReconcileLoop(components: DaemonComponents): ReconcileLoopHandle;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change-area analysis for one worktree node, used to order sibling nodes for
|
|
3
|
+
* batch refinement so that nodes least likely to conflict merge first.
|
|
4
|
+
*
|
|
5
|
+
* The heuristic is deliberately git-only and side-effect-free: it inspects the
|
|
6
|
+
* commits the node's branch adds on top of the base (`base..branch`) and records
|
|
7
|
+
* - whether any submodule gitlink path is touched (high-conflict signal: the
|
|
8
|
+
* batch must rebase later siblings onto the advanced submodule main), and
|
|
9
|
+
* - the set of changed top-level paths (so siblings touching disjoint trees can
|
|
10
|
+
* be ordered ahead of ones that overlap).
|
|
11
|
+
*/
|
|
12
|
+
export interface MeshRefineBatchNodeChangeArea {
|
|
13
|
+
nodeId: string;
|
|
14
|
+
workspace: string;
|
|
15
|
+
branch: string;
|
|
16
|
+
/** Top-level path segments changed by the branch vs. base (e.g. 'oss', 'packages'). */
|
|
17
|
+
changedTopLevelPaths: string[];
|
|
18
|
+
/** Full changed file list (bounded) for overlap detection. */
|
|
19
|
+
changedFiles: string[];
|
|
20
|
+
/** Submodule gitlink paths touched by the branch (subset of changedTopLevelPaths). */
|
|
21
|
+
touchedSubmodulePaths: string[];
|
|
22
|
+
/** True when the branch touches at least one submodule gitlink. */
|
|
23
|
+
touchesSubmodule: boolean;
|
|
24
|
+
/** Number of commits the branch is ahead of base; 0 means nothing to merge. */
|
|
25
|
+
aheadCount: number;
|
|
26
|
+
/** Non-fatal analysis error (e.g. base/branch unresolved); ordering falls back to neutral. */
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MeshRefineBatchOrderingResult {
|
|
30
|
+
/** Node IDs in the order they should be refined. */
|
|
31
|
+
order: string[];
|
|
32
|
+
/** Per-node change areas, keyed by node id, for plan transparency. */
|
|
33
|
+
changeAreas: Record<string, MeshRefineBatchNodeChangeArea>;
|
|
34
|
+
/** Human-readable explanation of why the order was chosen. */
|
|
35
|
+
rationale: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Analyze one worktree node's change area against its merge base.
|
|
39
|
+
*
|
|
40
|
+
* @param baseRef ref that the node will merge into (e.g. 'origin/main' or a SHA)
|
|
41
|
+
* @param branchRef the node's branch tip
|
|
42
|
+
* @param diffCwd repo to run the diff in (the worktree itself is authoritative for
|
|
43
|
+
* `branch` resolution, but the diff `base..branch` is symmetric, so
|
|
44
|
+
* the worktree cwd works for both refs once base is a reachable SHA).
|
|
45
|
+
*/
|
|
46
|
+
export declare function analyzeMeshRefineNodeChangeArea(args: {
|
|
47
|
+
nodeId: string;
|
|
48
|
+
workspace: string;
|
|
49
|
+
branch: string;
|
|
50
|
+
baseRef: string;
|
|
51
|
+
branchRef: string;
|
|
52
|
+
diffCwd: string;
|
|
53
|
+
submodulePaths: Set<string>;
|
|
54
|
+
}): Promise<MeshRefineBatchNodeChangeArea>;
|
|
55
|
+
/**
|
|
56
|
+
* Order nodes for batch refinement to minimize cross-sibling conflicts.
|
|
57
|
+
*
|
|
58
|
+
* Heuristic (deterministic, stable):
|
|
59
|
+
* 1. Nodes that do NOT touch any submodule come first — they cannot advance the
|
|
60
|
+
* submodule main, so they never force a later submodule rebase.
|
|
61
|
+
* 2. Within each group, fewer touched top-level paths first (smaller blast radius).
|
|
62
|
+
* 3. Tie-break by node id for determinism.
|
|
63
|
+
*
|
|
64
|
+
* Submodule-touching siblings are intrinsically serial: each one that merges
|
|
65
|
+
* advances oss main, so the next must rebase. Ordering them last keeps the
|
|
66
|
+
* non-submodule merges (which never need a submodule rebase) clean and up front.
|
|
67
|
+
*/
|
|
68
|
+
export declare function orderMeshRefineBatchNodes(changeAreas: MeshRefineBatchNodeChangeArea[]): MeshRefineBatchOrderingResult;
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
export type MeshAsyncRefineJobStatus = 'accepted' | 'running' | 'completed' | 'failed';
|
|
5
|
+
export interface MeshAsyncRefineJobSummary extends MeshAsyncJobLifecycle {
|
|
6
|
+
jobId: string;
|
|
7
|
+
interactionId?: string;
|
|
8
|
+
status: MeshAsyncRefineJobStatus;
|
|
9
|
+
meshId?: string;
|
|
10
|
+
nodeId?: string;
|
|
11
|
+
targetNodeId?: string;
|
|
12
|
+
targetDaemonId?: string;
|
|
13
|
+
workspace?: string;
|
|
14
|
+
branch?: string;
|
|
15
|
+
into?: string;
|
|
16
|
+
retryOfJobId?: string;
|
|
17
|
+
lastEvent?: string;
|
|
18
|
+
lastLedgerKind?: string;
|
|
19
|
+
lastUpdatedAt?: string;
|
|
20
|
+
instruction: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function buildMeshAsyncRefineJobs(args: {
|
|
23
|
+
meshId?: string;
|
|
24
|
+
ledgerEntries?: MeshLedgerEntry[];
|
|
25
|
+
pendingEvents?: PendingMeshCoordinatorEvent[];
|
|
26
|
+
}): MeshAsyncRefineJobSummary[];
|
|
27
|
+
/** Terminal refine jobs older than this (relative to the newest job in the set) are
|
|
28
|
+
* "stale" — already-resolved historical refinery rejections/successes that should not
|
|
29
|
+
* keep inflating the status counts in mesh_status. 6h covers a long working session
|
|
30
|
+
* while still folding multi-day-old residue. */
|
|
31
|
+
export declare const STALE_TERMINAL_REFINE_WINDOW_MS: number;
|
|
32
|
+
/** Cap on how many recent terminal jobs are counted even if all fall inside the freshness
|
|
33
|
+
* window — prevents a burst of refines from dominating the summary. */
|
|
34
|
+
export declare const RECENT_TERMINAL_REFINE_CAP = 8;
|
|
35
|
+
export interface MeshAsyncRefineJobsSummary {
|
|
36
|
+
/** Count of jobs reflected in `byStatus` (active jobs + recent terminal jobs). */
|
|
37
|
+
total: number;
|
|
38
|
+
byStatus: Record<string, number>;
|
|
39
|
+
/** Terminal jobs dropped from the counts because they are stale residue. */
|
|
40
|
+
staleTerminal: number;
|
|
41
|
+
/** Non-terminal (accepted/running) jobs still in flight. */
|
|
42
|
+
activeJobs: MeshAsyncRefineJobSummary[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build a compact summary of refine jobs that folds stale terminal jobs.
|
|
46
|
+
*
|
|
47
|
+
* The full job list (from `buildMeshAsyncRefineJobs`) is derived from a recent ledger
|
|
48
|
+
* window and deduped by jobId, but it still includes every terminal (completed/failed)
|
|
49
|
+
* job that happens to fall in that window — including multi-day-old refinery rejections
|
|
50
|
+
* that have long since been resolved. Those stale terminals inflate `byStatus.failed`
|
|
51
|
+
* and read as "current breakage" when they are historical noise.
|
|
52
|
+
*
|
|
53
|
+
* Active (accepted/running) jobs are always counted. Terminal jobs are counted only when
|
|
54
|
+
* they are recent: within `STALE_TERMINAL_REFINE_WINDOW_MS` of the newest job's activity
|
|
55
|
+
* time AND among the `RECENT_TERMINAL_REFINE_CAP` most-recent terminals. Everything else
|
|
56
|
+
* is folded into `staleTerminal` and excluded from `byStatus`.
|
|
57
|
+
*
|
|
58
|
+
* Freshness is measured relative to the newest job in the set (not wall-clock), so the
|
|
59
|
+
* result is deterministic for a given input — important for tests and for stale-clock
|
|
60
|
+
* environments.
|
|
61
|
+
*/
|
|
62
|
+
export declare function summarizeMeshAsyncRefineJobs(jobs: MeshAsyncRefineJobSummary[]): MeshAsyncRefineJobsSummary;
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
import type { MeshLedgerEntry } from './mesh-ledger.js';
|
|
13
|
+
export type MeshReviewInboxReason = 'merge_candidate' | 'refine_blocked_review';
|
|
14
|
+
export interface MeshReviewInboxConvergence {
|
|
15
|
+
status: string;
|
|
16
|
+
reason: string | null;
|
|
17
|
+
nextStep: string | null;
|
|
18
|
+
needsConvergence: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface MeshReviewInboxEvidence {
|
|
21
|
+
available: boolean;
|
|
22
|
+
/** Ledger kind of the entry the evidence came from. */
|
|
23
|
+
kind?: 'task_completed' | 'task_failed';
|
|
24
|
+
/** 'task_completion' = ordinary worker completion envelope; 'refine_job' = Refinery result. */
|
|
25
|
+
source?: 'task_completion' | 'refine_job';
|
|
26
|
+
timestamp?: string;
|
|
27
|
+
taskId?: string;
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
/** M2-3 bootstrap stage from the refine validation gate: cached|ran|failed|skipped|legacy|not_configured. */
|
|
30
|
+
bootstrap?: Record<string, unknown> | null;
|
|
31
|
+
validation?: Record<string, unknown> | null;
|
|
32
|
+
checkpoint?: Record<string, unknown> | null;
|
|
33
|
+
worker?: {
|
|
34
|
+
status: string;
|
|
35
|
+
classification?: string;
|
|
36
|
+
changedFiles: string[];
|
|
37
|
+
changedFilesTruncated?: true;
|
|
38
|
+
validationResults: Array<Record<string, unknown>>;
|
|
39
|
+
errors: string[];
|
|
40
|
+
requiresUserAction: boolean;
|
|
41
|
+
} | null;
|
|
42
|
+
finalBranchConvergenceState?: Record<string, unknown>;
|
|
43
|
+
refineJob?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export interface MeshReviewInboxDiffFile {
|
|
46
|
+
path: string;
|
|
47
|
+
status?: string;
|
|
48
|
+
insertions?: number;
|
|
49
|
+
deletions?: number;
|
|
50
|
+
binary?: boolean;
|
|
51
|
+
oldPath?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface MeshReviewInboxDiffSummary {
|
|
54
|
+
baseRef: string;
|
|
55
|
+
files: MeshReviewInboxDiffFile[];
|
|
56
|
+
totalFiles: number;
|
|
57
|
+
totalInsertions: number;
|
|
58
|
+
totalDeletions: number;
|
|
59
|
+
truncated: boolean;
|
|
60
|
+
error?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface MeshReviewInboxItem {
|
|
63
|
+
nodeId: string;
|
|
64
|
+
workspace: string | null;
|
|
65
|
+
branch: string | null;
|
|
66
|
+
defaultBranch: string | null;
|
|
67
|
+
isLocalWorktree: boolean;
|
|
68
|
+
reviewReason: MeshReviewInboxReason;
|
|
69
|
+
convergence: MeshReviewInboxConvergence;
|
|
70
|
+
evidence: MeshReviewInboxEvidence;
|
|
71
|
+
transcriptHandle: Record<string, unknown> | null;
|
|
72
|
+
/** Latest non-terminal Refinery job for this node (accepted/running), if any. */
|
|
73
|
+
activeRefineJob: Record<string, unknown> | null;
|
|
74
|
+
lastActivityAt: string | null;
|
|
75
|
+
/** Filled by the daemon command with a bounded base-branch diff probe; null when the workspace is not locally readable. */
|
|
76
|
+
diffSummary?: MeshReviewInboxDiffSummary | null;
|
|
77
|
+
}
|
|
78
|
+
export interface MeshReviewInboxDerivation {
|
|
79
|
+
items: MeshReviewInboxItem[];
|
|
80
|
+
remoteNodesExcluded: boolean;
|
|
81
|
+
excludedRemoteNodeIds: string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Derive review inbox items from mesh_status node statuses and a bounded
|
|
85
|
+
* ledger tail. Pure and read-only; the caller attaches diffSummary separately.
|
|
86
|
+
*/
|
|
87
|
+
export declare function deriveMeshReviewInboxItems(args: {
|
|
88
|
+
nodes: Array<Record<string, unknown>>;
|
|
89
|
+
ledgerEntries: MeshLedgerEntry[];
|
|
90
|
+
}): MeshReviewInboxDerivation;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
|
|
2
|
+
export type WorkerDelegateRejectionReason = 'not_cli' | 'no_workspace' | 'no_worker_envelope' | 'coordinator_not_dispatch_target' | 'mesh_unresolved';
|
|
3
|
+
export interface WorkerDelegateRouting {
|
|
4
|
+
/** True when the source session is a mesh worker whose events must route to a coordinator. */
|
|
5
|
+
isDelegate: boolean;
|
|
6
|
+
/** Resolved mesh id (runtime stamp, direct-dispatch recovery, or workspace lookup). */
|
|
7
|
+
meshId: string;
|
|
8
|
+
/** Resolved node id within the mesh, or '' when it cannot be determined. */
|
|
9
|
+
nodeId: string;
|
|
10
|
+
/** Human-readable node label for the coordinator system message. */
|
|
11
|
+
nodeLabel: string;
|
|
12
|
+
/** Coordinator daemon anchor (prefixed id) when the worker carries one; '' otherwise. */
|
|
13
|
+
coordinatorDaemonId: string;
|
|
14
|
+
/** Source session workspace (best-effort; '' when the session/workspace is missing). */
|
|
15
|
+
workspace: string;
|
|
16
|
+
/** Source session id echoed back, so diagnostics can name the dropped event's origin. */
|
|
17
|
+
sessionId: string;
|
|
18
|
+
/** Why routing was rejected (isDelegate=false), for fail-loud diagnostics (R4). */
|
|
19
|
+
rejectionReason?: WorkerDelegateRejectionReason;
|
|
20
|
+
}
|
|
21
|
+
interface ResolveDeps {
|
|
22
|
+
/** Resolve a mesh by id (local config + inline cache). */
|
|
23
|
+
getMeshById: (meshId: string) => any | undefined;
|
|
24
|
+
/** Resolve a mesh by workspace path (cached repo lookup). */
|
|
25
|
+
getMeshByWorkspace: (workspace: string) => any | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve how a source CLI session's mesh events should route to a coordinator.
|
|
29
|
+
*
|
|
30
|
+
* This is the single authoritative interpretation of the worker envelope. It folds
|
|
31
|
+
* together every signal that previously lived in inline branches:
|
|
32
|
+
* - runtime stamps (meshNodeFor / meshNodeId)
|
|
33
|
+
* - the coordinator anchor (meshCoordinatorDaemonId) and launch marker (launchedByCoordinator,
|
|
34
|
+
* meshCoordinatorNodeId) — any one proves delegation even if the node/mesh stamp was dropped
|
|
35
|
+
* - direct-dispatch recovery: a coordinator session that is itself a dispatch target
|
|
36
|
+
* - workspace→mesh fallback when no runtime mesh id survived
|
|
37
|
+
*
|
|
38
|
+
* Returns isDelegate=false (with a rejectionReason) instead of throwing, so the caller
|
|
39
|
+
* can either ignore non-delegate events or surface a diagnostic.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveWorkerDelegateRouting(components: DaemonComponents, instanceId: string, deps: ResolveDeps): WorkerDelegateRouting;
|
|
42
|
+
/** Ledger stream that collects delivery_unroutable diagnostics (no real mesh id exists for them). */
|
|
43
|
+
export declare const UNROUTABLE_DIAGNOSTIC_STREAM = "__unroutable__";
|
|
44
|
+
export declare function __resetUnroutableDiagnosticsForTests(): void;
|
|
45
|
+
/** True only for rejections that represent a silently-dropped delegate event worth a diagnostic. */
|
|
46
|
+
export declare function isUnroutableDelegateRejection(routing: WorkerDelegateRouting): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* R4: record that a worker event with a valid envelope could not be routed to a coordinator.
|
|
49
|
+
* Writes a `delivery_unroutable` ledger entry (deduped within a short window) so operators see
|
|
50
|
+
* WHY a completion never arrived instead of it vanishing. No-op for non-diagnostic rejections.
|
|
51
|
+
*/
|
|
52
|
+
export declare function recordUnroutableDelegateEvent(routing: WorkerDelegateRouting, eventName: string): boolean;
|
|
53
|
+
export interface UnroutableDeliveryDiagnostic {
|
|
54
|
+
timestamp: string;
|
|
55
|
+
event: string;
|
|
56
|
+
sessionId?: string;
|
|
57
|
+
workspace?: string;
|
|
58
|
+
coordinatorDaemonId?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* R4 visibility: recent delivery_unroutable diagnostics, newest first. Surfaced in mesh_status
|
|
62
|
+
* so an operator/coordinator can see that completions were dropped (envelope present, mesh
|
|
63
|
+
* unresolved) rather than the drops being invisible in a ledger nobody reads. The diagnostics
|
|
64
|
+
* live in a single shared stream because an unroutable event has no resolvable mesh.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getRecentUnroutableDeliveries(opts?: {
|
|
67
|
+
sinceMs?: number;
|
|
68
|
+
limit?: number;
|
|
69
|
+
}): UnroutableDeliveryDiagnostic[];
|
|
70
|
+
export {};
|