@adhdev/daemon-core 0.9.82-rc.29 → 0.9.82-rc.290

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.
Files changed (281) hide show
  1. package/dist/boot/daemon-lifecycle.d.ts +8 -0
  2. package/dist/boot/process-hardening.d.ts +50 -0
  3. package/dist/build-info.d.ts +37 -0
  4. package/dist/chat/source-machine.d.ts +166 -0
  5. package/dist/chat/source-resolver.d.ts +104 -0
  6. package/dist/chat/subscription-updates.d.ts +1 -0
  7. package/dist/cli-adapter-types.d.ts +23 -2
  8. package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
  9. package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
  10. package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
  11. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  12. package/dist/cli-adapters/provider-cli-shared.d.ts +38 -0
  13. package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
  14. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
  15. package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
  16. package/dist/cli-adapters/terminal-screen.d.ts +4 -11
  17. package/dist/commands/cli-manager.d.ts +2 -1
  18. package/dist/commands/handler.d.ts +110 -0
  19. package/dist/commands/mesh-coordinator.d.ts +85 -1
  20. package/dist/commands/router.d.ts +160 -1
  21. package/dist/config/chat-history.d.ts +9 -0
  22. package/dist/config/config.d.ts +5 -0
  23. package/dist/config/mesh-config.d.ts +72 -1
  24. package/dist/git/git-commands.d.ts +9 -1
  25. package/dist/git/git-diff.d.ts +6 -0
  26. package/dist/git/git-status.d.ts +7 -0
  27. package/dist/git/git-types.d.ts +2 -50
  28. package/dist/index.d.ts +51 -12
  29. package/dist/index.js +34510 -12948
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +38172 -16711
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/installer.d.ts +1 -4
  34. package/dist/ipc/local-ipc-server.d.ts +91 -0
  35. package/dist/launch.d.ts +1 -1
  36. package/dist/logging/async-batch-writer.d.ts +10 -0
  37. package/dist/mesh/contracts.d.ts +164 -0
  38. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  39. package/dist/mesh/coordinator-registry.d.ts +59 -0
  40. package/dist/mesh/mesh-active-work.d.ts +108 -0
  41. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  42. package/dist/mesh/mesh-events-coordinator.d.ts +133 -0
  43. package/dist/mesh/mesh-events-pending.d.ts +45 -0
  44. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  45. package/dist/mesh/mesh-events-utils.d.ts +47 -0
  46. package/dist/mesh/mesh-events.d.ts +6 -49
  47. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  48. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  49. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  50. package/dist/mesh/mesh-ledger.d.ts +77 -1
  51. package/dist/mesh/mesh-missions.d.ts +68 -0
  52. package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
  53. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  54. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  55. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  56. package/dist/mesh/mesh-routing.d.ts +70 -0
  57. package/dist/mesh/mesh-runtime-store.d.ts +345 -0
  58. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  59. package/dist/mesh/mesh-work-queue.d.ts +166 -5
  60. package/dist/mesh/preview-freshness.d.ts +18 -0
  61. package/dist/mesh/refine-config.d.ts +215 -0
  62. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  63. package/dist/providers/acp-provider-instance.d.ts +2 -0
  64. package/dist/providers/approval-utils.d.ts +13 -0
  65. package/dist/providers/cli-provider-instance.d.ts +61 -3
  66. package/dist/providers/contracts.d.ts +130 -6
  67. package/dist/providers/external-sources.d.ts +71 -0
  68. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  69. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  70. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  71. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  72. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  73. package/dist/providers/native-history/index.d.ts +13 -0
  74. package/dist/providers/provider-instance-manager.d.ts +13 -0
  75. package/dist/providers/provider-instance.d.ts +13 -1
  76. package/dist/providers/provider-loader.d.ts +26 -4
  77. package/dist/providers/provider-trust.d.ts +31 -0
  78. package/dist/providers/read-chat-contract.d.ts +29 -0
  79. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  80. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  81. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  82. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  83. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  84. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  85. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  86. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  87. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  88. package/dist/providers/sdk/v1/index.d.ts +30 -0
  89. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  90. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  91. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  92. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  93. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  94. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  95. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  96. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  97. package/dist/providers/spec/adapter.d.ts +59 -0
  98. package/dist/providers/spec/cli-adapter.d.ts +140 -0
  99. package/dist/providers/spec/evaluator.d.ts +23 -0
  100. package/dist/providers/spec/fsm-driver.d.ts +278 -0
  101. package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
  102. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  103. package/dist/providers/spec/fsm-types.d.ts +128 -0
  104. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  105. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  106. package/dist/providers/spec/route.d.ts +4 -0
  107. package/dist/providers/spec/types.d.ts +144 -0
  108. package/dist/providers/transcript-v2.d.ts +176 -0
  109. package/dist/providers/types/interactive-prompt.d.ts +48 -0
  110. package/dist/repo-mesh-types.d.ts +148 -13
  111. package/dist/sessions/registry.d.ts +6 -0
  112. package/dist/shared-types-extra.d.ts +2 -4
  113. package/dist/shared-types.d.ts +42 -1
  114. package/dist/status/normalize.d.ts +1 -1
  115. package/dist/status/normalize.js +1 -0
  116. package/dist/status/normalize.js.map +1 -1
  117. package/dist/status/normalize.mjs +1 -0
  118. package/dist/status/normalize.mjs.map +1 -1
  119. package/dist/status/reporter.d.ts +2 -0
  120. package/dist/status/snapshot.d.ts +1 -0
  121. package/dist/types.d.ts +5 -0
  122. package/package.json +7 -3
  123. package/src/agent-stream/poller.ts +2 -3
  124. package/src/boot/daemon-lifecycle.ts +55 -12
  125. package/src/boot/process-hardening.ts +89 -0
  126. package/src/build-info.ts +73 -0
  127. package/src/chat/source-machine.ts +534 -0
  128. package/src/chat/source-resolver.ts +0 -0
  129. package/src/chat/subscription-updates.ts +20 -1
  130. package/src/cli-adapter-types.d.ts +1 -0
  131. package/src/cli-adapter-types.ts +22 -2
  132. package/src/cli-adapters/cli-script-runner.ts +421 -0
  133. package/src/cli-adapters/cli-state-engine.ts +1215 -0
  134. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  135. package/src/cli-adapters/provider-cli-adapter.ts +674 -1139
  136. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  137. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  138. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  139. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  140. package/src/cli-adapters/provider-cli-shared.ts +68 -11
  141. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  142. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -29
  143. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  144. package/src/cli-adapters/terminal-screen.ts +16 -81
  145. package/src/commands/chat-commands.ts +1813 -60
  146. package/src/commands/cli-manager.ts +286 -14
  147. package/src/commands/handler.ts +809 -2
  148. package/src/commands/mesh-coordinator.ts +332 -122
  149. package/src/commands/router.ts +5721 -546
  150. package/src/config/chat-history.ts +229 -24
  151. package/src/config/config.ts +12 -0
  152. package/src/config/mesh-config.ts +303 -3
  153. package/src/config/recent-activity.ts +8 -2
  154. package/src/daemon/dev-auto-implement.ts +3 -2
  155. package/src/daemon/dev-cli-debug.ts +10 -1
  156. package/src/detection/ide-detector.ts +26 -16
  157. package/src/git/git-commands.ts +42 -12
  158. package/src/git/git-diff.ts +53 -0
  159. package/src/git/git-status.ts +198 -7
  160. package/src/git/git-types.ts +14 -62
  161. package/src/git/git-worktree.ts +8 -1
  162. package/src/index.ts +131 -11
  163. package/src/installer.d.ts +1 -1
  164. package/src/installer.ts +8 -6
  165. package/src/ipc/local-ipc-server.ts +278 -0
  166. package/src/launch.d.ts +1 -1
  167. package/src/launch.ts +37 -28
  168. package/src/logging/async-batch-writer.ts +55 -0
  169. package/src/logging/logger.ts +2 -1
  170. package/src/mesh/contracts.ts +329 -0
  171. package/src/mesh/coordinator-prompt.ts +219 -31
  172. package/src/mesh/coordinator-registry.ts +121 -0
  173. package/src/mesh/mesh-active-work.ts +468 -0
  174. package/src/mesh/mesh-delivery-policy.ts +315 -0
  175. package/src/mesh/mesh-events-coordinator.ts +1679 -0
  176. package/src/mesh/mesh-events-pending.ts +508 -0
  177. package/src/mesh/mesh-events-stale.ts +283 -0
  178. package/src/mesh/mesh-events-utils.ts +254 -0
  179. package/src/mesh/mesh-events.ts +30 -1035
  180. package/src/mesh/mesh-fast-forward.ts +839 -0
  181. package/src/mesh/mesh-host-ownership.ts +73 -0
  182. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  183. package/src/mesh/mesh-ledger.ts +589 -102
  184. package/src/mesh/mesh-missions.ts +172 -0
  185. package/src/mesh/mesh-reconcile-loop.ts +411 -0
  186. package/src/mesh/mesh-refine-batch.ts +197 -0
  187. package/src/mesh/mesh-refine-status.ts +231 -0
  188. package/src/mesh/mesh-review-inbox.ts +307 -0
  189. package/src/mesh/mesh-routing.ts +275 -0
  190. package/src/mesh/mesh-runtime-store.ts +1399 -0
  191. package/src/mesh/mesh-task-stats.ts +154 -0
  192. package/src/mesh/mesh-work-queue.ts +586 -145
  193. package/src/mesh/preview-freshness.ts +118 -0
  194. package/src/mesh/refine-config.ts +403 -0
  195. package/src/mesh/worktree-bootstrap-config.ts +326 -0
  196. package/src/providers/acp-provider-instance.ts +15 -1
  197. package/src/providers/approval-utils.d.ts +4 -0
  198. package/src/providers/approval-utils.ts +47 -5
  199. package/src/providers/chat-message-normalization.ts +4 -11
  200. package/src/providers/cli-provider-instance.ts +920 -81
  201. package/src/providers/contracts.d.ts +55 -0
  202. package/src/providers/contracts.ts +141 -6
  203. package/src/providers/external-sources.ts +218 -0
  204. package/src/providers/ide-provider-instance.ts +19 -5
  205. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  206. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  207. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  208. package/src/providers/native-history/dispatcher.ts +340 -0
  209. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  210. package/src/providers/native-history/index.ts +30 -0
  211. package/src/providers/provider-instance-manager.ts +30 -0
  212. package/src/providers/provider-instance.ts +10 -1
  213. package/src/providers/provider-loader.ts +584 -50
  214. package/src/providers/provider-schema.ts +87 -14
  215. package/src/providers/provider-trust.ts +114 -0
  216. package/src/providers/read-chat-contract.ts +76 -16
  217. package/src/providers/sdk/README.md +49 -0
  218. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  219. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  220. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  221. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  222. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  223. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  224. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  225. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  226. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  227. package/src/providers/sdk/v1/index.ts +152 -0
  228. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  229. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  230. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  231. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  232. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  233. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  234. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  235. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  236. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  237. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  238. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  239. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  240. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  241. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  242. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  243. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  244. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  245. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  246. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  247. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  248. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  249. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  250. package/src/providers/sdk/v1/validators/index.ts +19 -0
  251. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  252. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  253. package/src/providers/spec/adapter.ts +155 -0
  254. package/src/providers/spec/cli-adapter.ts +730 -0
  255. package/src/providers/spec/evaluator.ts +345 -0
  256. package/src/providers/spec/fsm-driver.ts +875 -0
  257. package/src/providers/spec/fsm-evaluator.ts +255 -0
  258. package/src/providers/spec/fsm-loader.ts +112 -0
  259. package/src/providers/spec/fsm-types.ts +222 -0
  260. package/src/providers/spec/native-history-executor.ts +943 -0
  261. package/src/providers/spec/pre-launch-trust.ts +104 -0
  262. package/src/providers/spec/route.ts +51 -0
  263. package/src/providers/spec/types.ts +189 -0
  264. package/src/providers/transcript-v2.ts +567 -0
  265. package/src/providers/types/interactive-prompt.ts +488 -0
  266. package/src/providers/version-archive.ts +38 -20
  267. package/src/repo-mesh-types.ts +177 -13
  268. package/src/sessions/registry.ts +6 -0
  269. package/src/shared-types-extra.ts +2 -4
  270. package/src/shared-types.ts +45 -1
  271. package/src/status/builders.ts +26 -6
  272. package/src/status/normalize.ts +2 -0
  273. package/src/status/reporter.ts +15 -0
  274. package/src/status/snapshot.ts +84 -25
  275. package/src/system/host-memory.ts +29 -12
  276. package/src/types.ts +5 -0
  277. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  278. package/dist/mesh/mesh-sync.d.ts +0 -53
  279. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  280. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  281. package/src/mesh/mesh-sync.ts +0 -111
@@ -10,6 +10,20 @@ export interface GitDiffOptions {
10
10
  timeoutMs?: number;
11
11
  maxFiles?: number;
12
12
  maxBytes?: number;
13
+ /**
14
+ * When set, diff `<baseRef>...HEAD` (merge-base range — "what this branch
15
+ * adds on top of base") instead of the working tree. Staged/untracked
16
+ * sections do not apply in this mode.
17
+ */
18
+ baseRef?: string;
19
+ }
20
+
21
+ function validateBaseRef(ref: string): string {
22
+ const trimmed = ref.trim();
23
+ if (!trimmed || trimmed.startsWith('-') || trimmed.includes('..') || !/^[A-Za-z0-9][A-Za-z0-9._/@-]*$/.test(trimmed)) {
24
+ throw new GitCommandError('invalid_args', `Invalid base ref: ${ref}`);
25
+ }
26
+ return trimmed;
13
27
  }
14
28
 
15
29
  export interface GitFileDiffResult {
@@ -44,6 +58,30 @@ export async function getGitDiffSummary(
44
58
  try {
45
59
  const repo = await resolveGitRepository(workspace, options);
46
60
  const repoRoot = repo.repoRoot!;
61
+
62
+ if (options.baseRef) {
63
+ const range = `${validateBaseRef(options.baseRef)}...HEAD`;
64
+ const [nameStatus, numstat] = await Promise.all([
65
+ runGit(repo, ['diff', '--no-ext-diff', '--name-status', range, '--'], { ...options, cwd: repoRoot }),
66
+ runGit(repo, ['diff', '--no-ext-diff', '--numstat', range, '--'], { ...options, cwd: repoRoot }),
67
+ ]);
68
+ const outputBytes = byteLength(nameStatus.stdout + numstat.stdout);
69
+ const changes = combineDiffEntries(nameStatus.stdout, numstat.stdout, false);
70
+ const maxFiles = normalizePositiveInteger(options.maxFiles, DEFAULT_MAX_FILES);
71
+ const maxBytes = normalizePositiveInteger(options.maxBytes, DEFAULT_MAX_BYTES);
72
+ const files = changes.slice(0, maxFiles);
73
+ return {
74
+ workspace: repo.workspace,
75
+ repoRoot,
76
+ isGitRepo: true,
77
+ files,
78
+ totalInsertions: files.reduce((sum, file) => sum + file.insertions, 0),
79
+ totalDeletions: files.reduce((sum, file) => sum + file.deletions, 0),
80
+ truncated: changes.length > files.length || outputBytes > maxBytes,
81
+ lastCheckedAt,
82
+ };
83
+ }
84
+
47
85
  const [unstagedNameStatus, unstagedNumstat, stagedNameStatus, stagedNumstat, untracked] = await Promise.all([
48
86
  runGit(repo, ['diff', '--no-ext-diff', '--name-status'], { ...options, cwd: repoRoot }),
49
87
  runGit(repo, ['diff', '--no-ext-diff', '--numstat'], { ...options, cwd: repoRoot }),
@@ -106,6 +144,21 @@ export async function getGitFileDiff(
106
144
  const selected = await resolveRepoFilePath(repoRoot, filePath);
107
145
  const maxBytes = normalizePositiveInteger(options.maxBytes, DEFAULT_MAX_BYTES);
108
146
 
147
+ if (options.baseRef) {
148
+ const range = `${validateBaseRef(options.baseRef)}...HEAD`;
149
+ const result = await runGit(repo, ['diff', '--no-ext-diff', range, '--', selected.relativePath], { ...options, cwd: repoRoot });
150
+ const bounded = truncateText(result.stdout, maxBytes);
151
+ return {
152
+ workspace: repo.workspace,
153
+ repoRoot,
154
+ isGitRepo: true,
155
+ path: selected.relativePath,
156
+ diff: bounded.text,
157
+ truncated: bounded.truncated,
158
+ lastCheckedAt,
159
+ };
160
+ }
161
+
109
162
  const [unstaged, staged] = await Promise.all([
110
163
  runGit(repo, ['diff', '--no-ext-diff', '--', selected.relativePath], { ...options, cwd: repoRoot }),
111
164
  runGit(repo, ['diff', '--cached', '--no-ext-diff', '--', selected.relativePath], { ...options, cwd: repoRoot }),
@@ -1,5 +1,6 @@
1
- import type { GitRepoStatus, GitSubmoduleStatus, GitUpstreamFreshness } from './git-types.js';
1
+ import type { DaemonBuildBehind, GitRepoStatus, GitSubmoduleStatus, GitUpstreamFreshness } from './git-types.js';
2
2
  import { GitCommandError, resolveGitRepository, runGit } from './git-executor.js';
3
+ import { getDaemonBuildInfo, type DaemonBuildInfo } from '../build-info.js';
3
4
 
4
5
  type ResolvedGitRepo = { workspace: string; repoRoot: string | null; isGitRepo: boolean };
5
6
 
@@ -14,6 +15,12 @@ export interface GitStatusOptions {
14
15
  * Callers should opt into this only for convergence-critical surfaces.
15
16
  */
16
17
  refreshUpstream?: boolean;
18
+ /**
19
+ * Test/override seam for the daemon build stamp used by the stale-build
20
+ * detector. Production callers omit this so the real baked-in build commit
21
+ * (getDaemonBuildInfo) is used.
22
+ */
23
+ daemonBuildInfo?: DaemonBuildInfo;
17
24
  }
18
25
 
19
26
  interface GitUpstreamProbe {
@@ -48,6 +55,13 @@ export async function getGitRepoStatus(
48
55
  if (includeSubmodules) {
49
56
  submodules = await getSubmoduleStatuses(repo, options);
50
57
  }
58
+ const submoduleDirty = (submodules || []).some(submodule => submodule.dirty || submodule.outOfSync || !!submodule.error);
59
+ const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0
60
+ || parsed.conflictFiles.length > 0
61
+ || stashCount > 0
62
+ || submoduleDirty;
63
+
64
+ const daemonBuildBehind = await detectDaemonBuildBehind(repo, submodules, options);
51
65
 
52
66
  return {
53
67
  workspace: repo.workspace,
@@ -67,11 +81,13 @@ export async function getGitRepoStatus(
67
81
  untracked: parsed.untracked,
68
82
  deleted: parsed.deleted,
69
83
  renamed: parsed.renamed,
84
+ dirty,
70
85
  hasConflicts: parsed.conflictFiles.length > 0,
71
86
  conflictFiles: parsed.conflictFiles,
72
87
  stashCount,
73
88
  lastCheckedAt,
74
89
  submodules,
90
+ ...(daemonBuildBehind ? { daemonBuildBehind } : {}),
75
91
  };
76
92
  } catch (error) {
77
93
  if (error instanceof GitCommandError) {
@@ -85,6 +101,158 @@ export async function getGitRepoStatus(
85
101
  }
86
102
  }
87
103
 
104
+ /**
105
+ * Detect whether the running daemon's build commit is a STRICT ancestor of this
106
+ * workspace's HEAD (root) or any of its submodules' HEAD. This surfaces the
107
+ * "merged a fix to main but the live daemon still ships the old bundle" gap:
108
+ * once the fix is committed, the workspace HEAD advances past the daemon's
109
+ * baked-in build commit, but the daemon keeps the old behavior until it is
110
+ * rebuilt/redeployed and restarted.
111
+ *
112
+ * Conservative by construction — returns undefined unless ancestry is provable:
113
+ * - build commit unknown → undefined
114
+ * - build commit not an object in this repo/submodule (different repo) → skip
115
+ * - build commit === HEAD (daemon is current) → undefined
116
+ * - build commit NOT an ancestor of HEAD (daemon ahead / diverged) → undefined
117
+ * Any git error is swallowed (no warning) so a flaky probe never over-warns.
118
+ */
119
+ /**
120
+ * Package names that, when changed, mean the daemon runtime is stale and must be
121
+ * rebuilt/redeployed + restarted. Everything NOT in this set (web-core,
122
+ * web-standalone, web-devconsole, terminal-render-web) is web-only — a daemon
123
+ * restart is not required for those, only a web redeploy. mcp-server runs in the
124
+ * same process surface as the daemon tooling, so it is classified as
125
+ * daemon-affecting (conservative). Unknown package → daemon-affecting.
126
+ */
127
+ const DAEMON_RUNTIME_PACKAGES = new Set([
128
+ 'daemon-core',
129
+ 'daemon-standalone',
130
+ 'session-host-core',
131
+ 'session-host-daemon',
132
+ 'terminal-mux-core',
133
+ 'terminal-mux-control',
134
+ 'terminal-mux-cli',
135
+ 'ghostty-vt-node',
136
+ 'mcp-server',
137
+ ]);
138
+
139
+ const WEB_ONLY_PACKAGES = new Set([
140
+ 'web-core',
141
+ 'web-standalone',
142
+ 'web-devconsole',
143
+ 'terminal-render-web',
144
+ ]);
145
+
146
+ /**
147
+ * Determine whether the changes between buildCommit..HEAD touch any daemon-runtime
148
+ * package. Returns isDaemonAffecting:true conservatively when the changed-file set
149
+ * can't be obtained or any changed path is outside the known web-only package set
150
+ * (including root-level / non-package files).
151
+ */
152
+ async function classifyDaemonBuildChange(
153
+ repoPath: string,
154
+ buildCommit: string,
155
+ options: GitStatusOptions,
156
+ ): Promise<{ isDaemonAffecting: boolean; affectedPackages: string[] }> {
157
+ try {
158
+ const diff = await runGit(repoPath, ['diff', '--name-only', `${buildCommit}..HEAD`], options);
159
+ const files = diff.stdout
160
+ .split('\n')
161
+ .map((line) => line.trim())
162
+ .filter(Boolean);
163
+ if (files.length === 0) {
164
+ // No file diff (e.g. only merge metadata) — nothing actionable, but stay
165
+ // conservative and treat as daemon-affecting so we don't suppress a real warning.
166
+ return { isDaemonAffecting: true, affectedPackages: [] };
167
+ }
168
+ const pkgs = new Set<string>();
169
+ let sawNonPackageOrUnknown = false;
170
+ for (const file of files) {
171
+ const match = file.match(/(?:^|\/)packages\/([^/]+)\//);
172
+ if (!match) {
173
+ sawNonPackageOrUnknown = true;
174
+ continue;
175
+ }
176
+ pkgs.add(match[1]);
177
+ }
178
+ const affectedPackages = [...pkgs].sort();
179
+ // Daemon-affecting if: any non-package/root file changed, any unknown package
180
+ // changed, or any explicit daemon-runtime package changed. Only when EVERY
181
+ // changed file maps to a known web-only package is the daemon unaffected.
182
+ const allWebOnly =
183
+ !sawNonPackageOrUnknown &&
184
+ affectedPackages.length > 0 &&
185
+ affectedPackages.every((p) => WEB_ONLY_PACKAGES.has(p) && !DAEMON_RUNTIME_PACKAGES.has(p));
186
+ return { isDaemonAffecting: !allWebOnly, affectedPackages };
187
+ } catch {
188
+ // diff probe failed → can't prove web-only; stay conservative.
189
+ return { isDaemonAffecting: true, affectedPackages: [] };
190
+ }
191
+ }
192
+
193
+ async function detectDaemonBuildBehind(
194
+ repo: ResolvedGitRepo,
195
+ submodules: GitSubmoduleStatus[] | undefined,
196
+ options: GitStatusOptions,
197
+ ): Promise<DaemonBuildBehind | undefined> {
198
+ const build = options.daemonBuildInfo ?? getDaemonBuildInfo();
199
+ if (!build.commit || build.commit === 'unknown') return undefined;
200
+
201
+ // Check the root repo first, then each submodule. The daemon build commit is
202
+ // baked from the daemon-core (oss submodule) HEAD, so on an adhdev
203
+ // superproject worktree the match is expected on the `oss` submodule, not the
204
+ // root — checking both keeps the helper repo-agnostic.
205
+ const scopes: Array<{ scope: string; repoPath: string }> = [
206
+ { scope: 'root', repoPath: repo.repoRoot || repo.workspace },
207
+ ];
208
+ for (const sub of submodules || []) {
209
+ if (sub.repoPath && !sub.error) scopes.push({ scope: sub.path, repoPath: sub.repoPath });
210
+ }
211
+
212
+ for (const { scope, repoPath } of scopes) {
213
+ try {
214
+ // Build commit must be a real object in THIS repo, else it's a different repo.
215
+ await runGit(repoPath, ['cat-file', '-e', `${build.commit}^{commit}`], options);
216
+ const headResult = await runGit(repoPath, ['rev-parse', 'HEAD'], options);
217
+ const head = headResult.stdout.trim();
218
+ if (!head || head === build.commit) continue;
219
+ // Strict ancestor: build commit is reachable from HEAD but is not HEAD.
220
+ await runGit(repoPath, ['merge-base', '--is-ancestor', build.commit, 'HEAD'], options);
221
+ // No throw → build commit IS an ancestor of HEAD → daemon is behind.
222
+ // Inspect WHICH packages changed in buildCommit..HEAD. A daemon rebuild/restart
223
+ // is only actually required when a daemon-runtime package changed; if only web /
224
+ // render packages changed, the daemon is unaffected and just the web deploy is
225
+ // pending. Conservative: any probe failure → treat as daemon-affecting.
226
+ const { isDaemonAffecting, affectedPackages } = await classifyDaemonBuildChange(
227
+ repoPath,
228
+ build.commit,
229
+ options,
230
+ );
231
+ const scopeLabel = scope === 'root' ? 'workspace' : scope;
232
+ const warning = isDaemonAffecting
233
+ ? `Live daemon was built from ${build.commitShort} which is behind ${scopeLabel} HEAD ${head.slice(0, 7)}. ` +
234
+ `Merged code is NOT live until the daemon is rebuilt/redeployed and restarted — a local dist rebuild alone does not update a cloud daemon.`
235
+ : `Live daemon was built from ${build.commitShort} which is behind ${scopeLabel} HEAD ${head.slice(0, 7)}, ` +
236
+ `but only web packages changed (${(affectedPackages || []).join(', ') || 'web'}). ` +
237
+ `Daemon restart NOT required — redeploy the web app to reflect the change.`;
238
+ return {
239
+ buildCommit: build.commit,
240
+ buildCommitShort: build.commitShort,
241
+ head,
242
+ scope,
243
+ isDaemonAffecting,
244
+ ...(affectedPackages && affectedPackages.length > 0 ? { affectedPackages } : {}),
245
+ warning,
246
+ };
247
+ } catch {
248
+ // cat-file / merge-base non-zero exit (commit absent or not an ancestor)
249
+ // or any git error → not a provable staleness for this scope; try next.
250
+ continue;
251
+ }
252
+ }
253
+ return undefined;
254
+ }
255
+
88
256
  interface ParsedPorcelainStatus {
89
257
  branch: string | null;
90
258
  upstream: string | null;
@@ -285,6 +453,7 @@ function emptyStatus(workspace: string, lastCheckedAt: number, error: GitCommand
285
453
  untracked: 0,
286
454
  deleted: 0,
287
455
  renamed: 0,
456
+ dirty: false,
288
457
  hasConflicts: false,
289
458
  conflictFiles: [],
290
459
  stashCount: 0,
@@ -304,12 +473,34 @@ async function getSubmoduleStatuses(
304
473
 
305
474
  try {
306
475
  const result = await runGit(repo, ['submodule', 'status', '--recursive'], options);
307
- return parseSubmoduleStatusOutput(result.stdout, repo.repoRoot, options.submoduleIgnorePaths);
476
+ const submodules = parseSubmoduleStatusOutput(result.stdout, repo.repoRoot, options.submoduleIgnorePaths);
477
+ await Promise.all(submodules.map(submodule => enrichSubmoduleWorktreeStatus(repo, submodule, options)));
478
+ return submodules;
308
479
  } catch {
309
480
  return [];
310
481
  }
311
482
  }
312
483
 
484
+ async function enrichSubmoduleWorktreeStatus(
485
+ repo: ResolvedGitRepo,
486
+ submodule: GitSubmoduleStatus,
487
+ options: GitStatusOptions,
488
+ ): Promise<void> {
489
+ try {
490
+ const result = await runGit(repo, ['status', '--porcelain=v2', '--branch'], {
491
+ ...options,
492
+ cwd: submodule.repoPath,
493
+ });
494
+ const parsed = parsePorcelainV2Status(result.stdout);
495
+ const dirty = parsed.staged + parsed.modified + parsed.untracked + parsed.deleted + parsed.renamed > 0
496
+ || parsed.conflictFiles.length > 0;
497
+ submodule.dirty = submodule.dirty || dirty;
498
+ } catch (error) {
499
+ submodule.dirty = true;
500
+ submodule.error = formatGitError(error);
501
+ }
502
+ }
503
+
313
504
  function parseSubmoduleStatusOutput(
314
505
  output: string,
315
506
  repoRoot: string,
@@ -321,9 +512,9 @@ function parseSubmoduleStatusOutput(
321
512
  for (const line of output.split('\n')) {
322
513
  if (!line.trim()) continue;
323
514
 
324
- // Format: [+- ]<commit> <path> (<branch>)
325
- // - = out of sync, + = dirty, ' ' = clean
326
- const match = line.match(/^([\-+\s])([0-9a-f]{40})\s+(\S+)(?:\s+\(([^)]+)\))?/);
515
+ // Format: [+-U ]<commit> <path> (<branch>)
516
+ // - = not initialized, + = gitlink out of sync, U = conflict, ' ' = aligned.
517
+ const match = line.match(/^([\-+U\s])([0-9a-f]{40})\s+(\S+)(?:\s+\(([^)]+)\))?/);
327
518
  if (!match) continue;
328
519
 
329
520
  const prefix = match[1];
@@ -336,8 +527,8 @@ function parseSubmoduleStatusOutput(
336
527
  path,
337
528
  commit,
338
529
  repoPath: repoRoot + '/' + path,
339
- dirty: prefix === '+',
340
- outOfSync: prefix === '-',
530
+ dirty: prefix === 'U',
531
+ outOfSync: prefix === '-' || prefix === '+',
341
532
  lastCheckedAt: Date.now(),
342
533
  });
343
534
  }
@@ -6,69 +6,21 @@
6
6
  * infer these values from agent transcripts in frontend code.
7
7
  */
8
8
 
9
- export type GitFailureReason =
10
- | 'not_git_repo'
11
- | 'git_not_installed'
12
- | 'timeout'
13
- | 'path_outside_repo'
14
- | 'dirty_index_required'
15
- | 'conflict'
16
- | 'invalid_args'
17
- | 'nothing_to_commit'
18
- | 'git_command_failed';
9
+ // Pure shape types now live in @adhdev/mesh-shared so the cloud (web-core) and
10
+ // standalone (daemon-core) transports share ONE definition instead of hand-syncing
11
+ // two. Re-exported here so existing `from './git-types'` / package imports keep
12
+ // working unchanged. Daemon-specific types (GitSnapshot, GitCommandName, …) stay
13
+ // local below and consume these re-exports.
14
+ export type {
15
+ GitFailureReason,
16
+ GitRepoIdentity,
17
+ GitSubmoduleStatus,
18
+ GitUpstreamFreshness,
19
+ GitRepoStatus,
20
+ DaemonBuildBehind,
21
+ } from '@adhdev/mesh-shared';
19
22
 
20
- export interface GitRepoIdentity {
21
- workspace: string;
22
- repoRoot: string | null;
23
- isGitRepo: boolean;
24
- }
25
-
26
- export interface GitSubmoduleStatus {
27
- /** Submodule path relative to repo root */
28
- path: string;
29
- /** Current commit SHA the submodule is at */
30
- commit: string;
31
- /** Path to the submodule repo (absolute) */
32
- repoPath: string;
33
- /** Whether the submodule has uncommitted changes */
34
- dirty: boolean;
35
- /** Whether the submodule commit differs from what the parent repo expects */
36
- outOfSync: boolean;
37
- /** Last checked timestamp */
38
- lastCheckedAt: number;
39
- /** Error message if submodule status could not be read */
40
- error?: string;
41
- }
42
-
43
- export type GitUpstreamFreshness = 'fresh' | 'unchecked' | 'stale' | 'no_upstream' | 'unavailable';
44
-
45
- export interface GitRepoStatus extends GitRepoIdentity {
46
- branch: string | null;
47
- headCommit: string | null;
48
- headMessage: string | null;
49
- upstream: string | null;
50
- /** Whether ahead/behind was verified against a freshly fetched upstream ref. */
51
- upstreamStatus: GitUpstreamFreshness;
52
- /** Timestamp for the fetch that refreshed upstream refs when upstreamStatus === 'fresh'. */
53
- upstreamFetchedAt?: number;
54
- /** Error from the last refresh attempt when upstreamStatus === 'stale'. */
55
- upstreamFetchError?: string;
56
- ahead: number;
57
- behind: number;
58
- staged: number;
59
- modified: number;
60
- untracked: number;
61
- deleted: number;
62
- renamed: number;
63
- hasConflicts: boolean;
64
- conflictFiles: string[];
65
- stashCount: number;
66
- lastCheckedAt: number;
67
- /** Submodule statuses when auto-discover is enabled */
68
- submodules?: GitSubmoduleStatus[];
69
- error?: string;
70
- reason?: GitFailureReason;
71
- }
23
+ import type { GitRepoIdentity, GitRepoStatus, GitFailureReason, GitUpstreamFreshness } from '@adhdev/mesh-shared';
72
24
 
73
25
  export type GitFileChangeStatus =
74
26
  | 'added'
@@ -116,8 +116,11 @@ export async function createWorktree(opts: WorktreeCreateOptions): Promise<Workt
116
116
  });
117
117
  } catch (error: any) {
118
118
  const stderr = typeof error.stderr === 'string' ? error.stderr : '';
119
- // Clean error messages for common failures
120
119
  if (/already exists/i.test(stderr)) {
120
+ // Distinguish directory-collision (TOCTOU race) from branch-already-exists
121
+ if (existsSync(targetDir)) {
122
+ throw new Error(`Worktree target directory was created concurrently: ${targetDir}`);
123
+ }
121
124
  throw new Error(`Branch '${branch}' already exists or is checked out in another worktree`);
122
125
  }
123
126
  throw new Error(`git worktree add failed: ${stderr.trim() || error.message}`);
@@ -170,6 +173,10 @@ export async function removeWorktree(repoRoot: string, worktreePath: string, opt
170
173
  const stdout = typeof error.stdout === 'string' ? error.stdout : '';
171
174
  const detail = `${stderr}\n${stdout}\n${error.message || ''}`;
172
175
  if (opts.allowSubmoduleForceFallback && SUBMODULE_WORKTREE_REMOVE_RE.test(detail)) {
176
+ process.stderr.write(
177
+ `[adhdev-mesh] WARNING: git worktree remove --force fallback for submodule worktree '${worktreePath}'. `
178
+ + `Any uncommitted changes inside submodules will be lost.\n`,
179
+ );
173
180
  try {
174
181
  await execFileAsync('git', ['worktree', 'remove', '--force', worktreePath], {
175
182
  cwd: repoRoot,
package/src/index.ts CHANGED
@@ -85,9 +85,28 @@ export type {
85
85
  InputMediaType,
86
86
  } from './shared-types.js';
87
87
 
88
+ export type {
89
+ InteractivePrompt,
90
+ InteractiveQuestion,
91
+ InteractiveOption,
92
+ InteractivePromptResponse,
93
+ InteractiveAnswer,
94
+ } from './providers/types/interactive-prompt.js';
95
+ export {
96
+ normalizeInteractivePrompt,
97
+ normalizeInteractivePromptResponse,
98
+ buildClaudeInteractiveToolResult,
99
+ interactivePromptFromClaudeAskUserQuestion,
100
+ detectClaudeAskUserQuestionPromptFromJson,
101
+ } from './providers/types/interactive-prompt.js';
102
+
88
103
  // ── Repo Mesh Types (cross-package) ──
89
104
  export type {
90
105
  RepoMesh,
106
+ RepoMeshDaemonRole,
107
+ RepoMeshHostMetadata,
108
+ RepoMeshHostPairingMetadata,
109
+ RepoMeshHostStatus,
91
110
  RepoMeshNode,
92
111
  RepoMeshNodeHealth,
93
112
  RepoMeshPolicy,
@@ -111,8 +130,9 @@ export type {
111
130
  RepoMeshLedgerEntryStatus,
112
131
  RepoMeshLedgerSummaryStatus,
113
132
  RepoMeshLedgerStatus,
133
+ MeshAsyncJobLifecycle,
114
134
  } from './repo-mesh-types.js';
115
- export { DEFAULT_MESH_POLICY } from './repo-mesh-types.js';
135
+ export { DEFAULT_MESH_POLICY, resolveDelegatedWorkerAutoApprove } from './repo-mesh-types.js';
116
136
 
117
137
  // ── Git Surface ──
118
138
  export * from './git/index.js';
@@ -138,7 +158,7 @@ export type RecentSessionBucket = 'needs_attention' | 'working' | 'task_complete
138
158
  export type { IDaemonCore, DaemonCoreOptions } from './daemon-core.js';
139
159
 
140
160
  // ── Config ──
141
- export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig } from './config/config.js';
161
+ export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig, getDaemonDataDir } from './config/config.js';
142
162
  export { getWorkspaceState } from './config/workspaces.js';
143
163
  export { appendRecentActivity, getRecentActivity } from './config/recent-activity.js';
144
164
  export type { RecentActivityEntry } from './config/recent-activity.js';
@@ -154,19 +174,59 @@ export type { CreateMeshOptions, UpdateMeshOptions, AddNodeOptions } from './con
154
174
 
155
175
  // ── Mesh Coordinator ──
156
176
  export { buildCoordinatorSystemPrompt } from './mesh/coordinator-prompt.js';
177
+ export { upsertMeshMission, getMeshMissions, getMeshMission, summarizeMissionTasks, summarizeMeshMission, getActiveMeshMissionSummaries, buildMissionPromptSection, MESH_MISSION_STATUSES } from './mesh/mesh-missions.js';
178
+ export type { MeshMissionRecord, MeshMissionStatus, MeshMissionSummary, MeshMissionTaskAggregate } from './mesh/mesh-missions.js';
179
+ export { computeMeshTaskStats, computeMeshMissionStats } from './mesh/mesh-task-stats.js';
180
+ export type { MeshTaskStats, MeshMissionStats } from './mesh/mesh-task-stats.js';
181
+ export { deriveMeshReviewInboxItems } from './mesh/mesh-review-inbox.js';
182
+ export type { MeshReviewInboxItem, MeshReviewInboxDerivation, MeshReviewInboxEvidence, MeshReviewInboxDiffSummary, MeshReviewInboxDiffFile, MeshReviewInboxReason, MeshReviewInboxConvergence } from './mesh/mesh-review-inbox.js';
157
183
  export type { CoordinatorPromptContext } from './mesh/coordinator-prompt.js';
158
- export { syncMeshes } from './mesh/mesh-sync.js';
159
- export type { MeshSyncTransport, MeshSyncResult, RemoteMeshRecord } from './mesh/mesh-sync.js';
184
+ export { loadMeshCoordinatorRegistry, registerMeshCoordinator, unregisterMeshCoordinator, getCoordinatorForSession, listCoordinatorsForWorkspace } from './mesh/coordinator-registry.js';
185
+ export type { CoordinatorRegistryEntry } from './mesh/coordinator-registry.js';
186
+ export {
187
+ MESH_REFINE_CONFIG_LOCATIONS,
188
+ MESH_REFINE_CONFIG_SCHEMA,
189
+ loadMeshRefineConfig,
190
+ resolveMeshRefineValidationPlan,
191
+ suggestMeshRefineConfig,
192
+ validateMeshRefineConfig,
193
+ } from './mesh/refine-config.js';
194
+ export {
195
+ MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
196
+ MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
197
+ loadMeshWorktreeBootstrapConfig,
198
+ runMeshWorktreeBootstrap,
199
+ validateMeshWorktreeBootstrapConfig,
200
+ type RepoMeshWorktreeBootstrapConfig,
201
+ type WorktreeBootstrapState,
202
+ } from './mesh/worktree-bootstrap-config.js';
203
+ export type {
204
+ MeshRefineValidationCategory,
205
+ MeshRefineValidationCommandPlan,
206
+ MeshRefineValidationPlan,
207
+ RepoMeshRefineConfig,
208
+ RepoMeshRefineValidationCommandConfig,
209
+ } from './mesh/refine-config.js';
160
210
 
161
211
  // ── Mesh Task Ledger ──
162
- export { appendLedgerEntry, appendRemoteLedgerEntries, readLedgerEntries, readLedgerSlice, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
163
- export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext } from './mesh/mesh-ledger.js';
212
+ export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, readLedgerSliceFromStore, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
213
+ export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext, MeshTaskCompletionEvidence, MeshWorkerResultArtifact, MeshProcessArtifact, MeshValidationResultArtifact } from './mesh/mesh-ledger.js';
214
+ export { fastForwardMeshNode } from './mesh/mesh-fast-forward.js';
215
+ export type { MeshFastForwardNodeArgs, MeshFastForwardPlannedStep, MeshFastForwardResult } from './mesh/mesh-fast-forward.js';
164
216
  export { buildMeshLedgerReconciliationEvidence, buildMeshLedgerReplicaEvidence } from './mesh/mesh-ledger-reconciliation.js';
165
- export type { MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
217
+ export type { AnyLedgerSlice, MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
166
218
 
167
219
  // ── Mesh Work Queue (GUPP) ──
168
- export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats } from './mesh/mesh-work-queue.js';
169
- export type { MeshWorkQueueEntry, MeshTaskStatus, MeshWorkQueueStats } from './mesh/mesh-work-queue.js';
220
+ export { enqueueTask, recordDirectDispatchTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats, getMeshQueueRevision, normalizeMeshTaskMode, validateMeshTaskModeRequest, buildMeshNodeCapabilityTags, nodeSatisfiesRequiredTags, normalizeMeshCapabilityTags, insertDirectDispatch, getActiveDirectDispatches, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, markStaleDirectDispatches, deleteDirectDispatchesByTaskId, recordMeshToolCall, assertNoDependencyCycle, hasPendingDependents, describeTaskDependencyState } from './mesh/mesh-work-queue.js';
221
+ export type { MeshWorkQueueEntry, MeshTaskStatus, MeshTaskMode, MeshWorkQueueStats, MeshQueueMutationOptions, MeshTaskModeValidationResult, DirectDispatchRecord, MeshToolCallRateResult } from './mesh/mesh-work-queue.js';
222
+ export { buildCompactStaleDirectWorkSummary, buildMeshActiveWork, buildMeshActiveWorkSummary, classifyStaleDirectForPrune, PRUNABLE_ORPHAN_STALE_REASONS } from './mesh/mesh-active-work.js';
223
+ export type { StaleDirectPruneClassification } from './mesh/mesh-active-work.js';
224
+ export type { MeshActiveWorkRecord, MeshActiveWorkStatus, MeshActiveWorkSummary, MeshActiveWorkSource, MeshStaleDirectWorkSummary } from './mesh/mesh-active-work.js';
225
+ export { buildMeshAsyncRefineJobs, summarizeMeshAsyncRefineJobs, STALE_TERMINAL_REFINE_WINDOW_MS, RECENT_TERMINAL_REFINE_CAP } from './mesh/mesh-refine-status.js';
226
+ export type { MeshAsyncRefineJobStatus, MeshAsyncRefineJobSummary, MeshAsyncRefineJobsSummary } from './mesh/mesh-refine-status.js';
227
+
228
+ // ── Mesh Host Ownership ──
229
+ export { buildMeshHostRequiredFailure, createDefaultMeshHostMetadata, isMeshHostOwner, normalizeMeshDaemonRole, requireMeshHostQueueOwner, resolveMeshHostStatus } from './mesh/mesh-host-ownership.js';
170
230
 
171
231
  // ── Mesh Visualization ──
172
232
  // buildMeshGraph and MeshGraph types moved to @adhdev/web-core to avoid
@@ -176,9 +236,13 @@ export type { MeshWorkQueueEntry, MeshTaskStatus, MeshWorkQueueStats } from './m
176
236
  // export type { MeshGraph, MeshGraphNode, MeshGraphEdge, MeshGraphNodeType, MeshGraphEdgeType } from './mesh/mesh-visualization.js';
177
237
 
178
238
  // ── Mesh Events ──
179
- export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
239
+ export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent, reconcileDirectDispatchCompletionFromTranscript } from './mesh/mesh-events.js';
180
240
  export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
181
241
 
242
+ // ── Mesh Delivery Policy ──
243
+ export { resolveDeliveryDecision, createSessionDelivery, updateSessionDeliveryStatus, getActiveSessionDeliveries, markSessionDeliveriesTerminal, recordCompletionConflict, getRecentCompletionConflicts } from './mesh/mesh-delivery-policy.js';
244
+ export type { MeshSessionDeliveryStatus, MeshSessionDeliveryKind, MeshDeliveryDecision, MeshDeliveryPolicyResult, SessionDeliveryRecord } from './mesh/mesh-delivery-policy.js';
245
+
182
246
  // ── Mesh P2P Relay Failure Classification ──
183
247
  export {
184
248
  P2pRelayFailureError,
@@ -222,7 +286,7 @@ export type { CdpInitializerConfig } from './cdp/initializer.js';
222
286
  // ── Commands ──
223
287
  export { DaemonCommandHandler } from './commands/handler.js';
224
288
  export type { CommandResult, CommandContext } from './commands/handler.js';
225
- export { DaemonCommandRouter } from './commands/router.js';
289
+ export { DaemonCommandRouter, readCachedInlineMeshActiveSessionDetails } from './commands/router.js';
226
290
  export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
227
291
  export {
228
292
  maybeRunDaemonUpgradeHelperFromEnv,
@@ -243,6 +307,8 @@ export type {
243
307
  export { DaemonStatusReporter } from './status/reporter.js';
244
308
  export { buildSessionEntries, findCdpManager, hasCdpManager, isCdpConnected } from './status/builders.js';
245
309
  export { buildStatusSnapshot, buildMachineInfo } from './status/snapshot.js';
310
+ export { getDaemonBuildInfo } from './build-info.js';
311
+ export type { DaemonBuildInfo } from './build-info.js';
246
312
  export { normalizeManagedStatus, isManagedStatusWorking, isManagedStatusWaiting, normalizeActiveChatData } from './status/normalize.js';
247
313
  export type { ManagedStatus } from './status/normalize.js';
248
314
  export type { StatusSnapshotOptions, StatusSnapshot } from './status/snapshot.js';
@@ -388,6 +454,13 @@ export type { CliAdapter } from './cli-adapter-types.js';
388
454
  export { NodePtyTransportFactory } from './cli-adapters/pty-transport.js';
389
455
  export type { PtyRuntimeTransport, PtyTransportFactory, PtySpawnOptions } from './cli-adapters/pty-transport.js';
390
456
  export { SessionHostPtyTransportFactory } from './cli-adapters/session-host-transport.js';
457
+ export {
458
+ RawTerminalAttachment,
459
+ namedKeyToAnsi,
460
+ namedKeysToAnsi,
461
+ withRawTerminalAttachment,
462
+ } from './cli-adapters/raw-terminal-io.js';
463
+ export type { NamedKey, RawTerminalAttachmentOptions, RawTerminalSessionHostClient } from './cli-adapters/raw-terminal-io.js';
391
464
  export type { HostedCliRuntimeDescriptor, CliTransportFactoryParams } from './commands/cli-manager.js';
392
465
  export {
393
466
  DEFAULT_SESSION_HOST_APP_NAME,
@@ -415,3 +488,50 @@ export type { ExtensionInfo as InstallerExtensionInfo } from './installer.js';
415
488
  // ── Boot / Lifecycle ──
416
489
  export { initDaemonComponents, startDaemonDevSupport, shutdownDaemonComponents } from './boot/daemon-lifecycle.js';
417
490
  export type { DaemonInitConfig, DaemonComponents, DaemonDevSupportOptions } from './boot/daemon-lifecycle.js';
491
+
492
+ // ── Local IPC server (shared between cloud + standalone daemons) ──
493
+ export {
494
+ startLocalIpcServer,
495
+ buildIpcStatusHttpResponse,
496
+ type LocalIpcServerOptions,
497
+ type LocalIpcServerHandle,
498
+ type IpcCommandContext,
499
+ type IpcCommandResult,
500
+ type IpcStatusPayload,
501
+ } from './ipc/local-ipc-server.js';
502
+
503
+ // ── CLI Spec (adhdev:cli/spec@4) ──
504
+ export { createNativeHistoryDispatcher } from './providers/native-history/index.js';
505
+ export type { ReaderId } from './providers/native-history/index.js';
506
+ export {
507
+ readClaudeCliSession, readCodexCliSession,
508
+ readAntigravityCliSession, readHermesCliSession,
509
+ } from './providers/native-history/index.js';
510
+ export type {
511
+ ControlAction, Control,
512
+ NotificationRule, DelegateTrigger,
513
+ } from './providers/spec/types.js';
514
+ export type { TraceEntry } from './providers/spec/evaluator.js';
515
+ export { evaluateFsm } from './providers/spec/fsm-evaluator.js';
516
+ export type { FsmClock } from './providers/spec/fsm-evaluator.js';
517
+ export { validateFsmSpec } from './providers/spec/fsm-loader.js';
518
+ export { FsmDriver } from './providers/spec/fsm-driver.js';
519
+ export type { DashboardEvent, DashboardCommand, SpecDriverOpts, ISpecDriver } from './providers/spec/fsm-driver.js';
520
+ export { TerminalAdapter } from './providers/spec/adapter.js';
521
+ export type { TerminalAdapterOpts, TerminalAdapterHandlers } from './providers/spec/adapter.js';
522
+
523
+ // ── Provider SDK (v1) — selective re-exports for external tooling ──
524
+ // Tooling (registry publish, dashboard validators, the e2e harness) needs
525
+ // the manifest validator, the builder catalog, and the contract version.
526
+ // We don't re-export *everything* from the SDK to keep the public surface
527
+ // stable; consumers that need internal SDK types still import from the
528
+ // sdk/v1 subpath.
529
+ export {
530
+ validateCliProviderManifest,
531
+ formatManifestValidationIssues,
532
+ type ManifestValidationIssue,
533
+ type ManifestValidationResult,
534
+ V1_CONTRACT_VERSION,
535
+ V1_PRIMITIVE_CATALOG,
536
+ V1_ALL_PRIMITIVES,
537
+ } from './providers/sdk/v1/index.js';