@adhdev/daemon-core 0.9.82-rc.31 → 0.9.82-rc.310

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 (293) 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/resolve-executable.d.ts +14 -0
  15. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
  16. package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
  17. package/dist/cli-adapters/terminal-screen.d.ts +4 -11
  18. package/dist/commands/cli-manager.d.ts +2 -1
  19. package/dist/commands/handler.d.ts +110 -0
  20. package/dist/commands/mesh-coordinator.d.ts +85 -1
  21. package/dist/commands/router.d.ts +210 -1
  22. package/dist/config/chat-history.d.ts +9 -0
  23. package/dist/config/config.d.ts +5 -0
  24. package/dist/config/mesh-config.d.ts +72 -1
  25. package/dist/git/git-commands.d.ts +9 -1
  26. package/dist/git/git-diff.d.ts +6 -0
  27. package/dist/git/git-executor.d.ts +11 -0
  28. package/dist/git/git-status.d.ts +9 -0
  29. package/dist/git/git-types.d.ts +2 -50
  30. package/dist/index.d.ts +51 -12
  31. package/dist/index.js +38320 -16024
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +38009 -15817
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/installer.d.ts +1 -4
  36. package/dist/ipc/local-ipc-server.d.ts +91 -0
  37. package/dist/launch.d.ts +1 -1
  38. package/dist/logging/async-batch-writer.d.ts +10 -0
  39. package/dist/mesh/contracts.d.ts +164 -0
  40. package/dist/mesh/coordinator-prompt.d.ts +36 -0
  41. package/dist/mesh/coordinator-registry.d.ts +59 -0
  42. package/dist/mesh/mesh-active-work.d.ts +108 -0
  43. package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
  44. package/dist/mesh/mesh-events-coordinator.d.ts +138 -0
  45. package/dist/mesh/mesh-events-pending.d.ts +45 -0
  46. package/dist/mesh/mesh-events-stale.d.ts +40 -0
  47. package/dist/mesh/mesh-events-utils.d.ts +47 -0
  48. package/dist/mesh/mesh-events.d.ts +6 -49
  49. package/dist/mesh/mesh-fast-forward.d.ts +81 -0
  50. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  51. package/dist/mesh/mesh-init.d.ts +86 -0
  52. package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
  53. package/dist/mesh/mesh-ledger.d.ts +77 -1
  54. package/dist/mesh/mesh-missions.d.ts +116 -0
  55. package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
  56. package/dist/mesh/mesh-refine-batch.d.ts +68 -0
  57. package/dist/mesh/mesh-refine-status.d.ts +62 -0
  58. package/dist/mesh/mesh-review-inbox.d.ts +90 -0
  59. package/dist/mesh/mesh-routing.d.ts +70 -0
  60. package/dist/mesh/mesh-runtime-store.d.ts +377 -0
  61. package/dist/mesh/mesh-task-stats.d.ts +49 -0
  62. package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
  63. package/dist/mesh/mesh-work-queue.d.ts +181 -5
  64. package/dist/mesh/preview-freshness.d.ts +18 -0
  65. package/dist/mesh/refine-config.d.ts +215 -0
  66. package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
  67. package/dist/providers/acp-provider-instance.d.ts +2 -0
  68. package/dist/providers/approval-utils.d.ts +13 -0
  69. package/dist/providers/cli-provider-instance.d.ts +61 -3
  70. package/dist/providers/contracts.d.ts +130 -6
  71. package/dist/providers/external-sources.d.ts +71 -0
  72. package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
  73. package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
  74. package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
  75. package/dist/providers/native-history/dispatcher.d.ts +27 -0
  76. package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
  77. package/dist/providers/native-history/index.d.ts +13 -0
  78. package/dist/providers/provider-instance-manager.d.ts +13 -0
  79. package/dist/providers/provider-instance.d.ts +13 -1
  80. package/dist/providers/provider-loader.d.ts +26 -4
  81. package/dist/providers/provider-trust.d.ts +31 -0
  82. package/dist/providers/read-chat-contract.d.ts +29 -0
  83. package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
  84. package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
  85. package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
  86. package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
  87. package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
  88. package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
  89. package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
  90. package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
  91. package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
  92. package/dist/providers/sdk/v1/index.d.ts +30 -0
  93. package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
  94. package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
  95. package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
  96. package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
  97. package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
  98. package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
  99. package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
  100. package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
  101. package/dist/providers/spec/adapter.d.ts +59 -0
  102. package/dist/providers/spec/cli-adapter.d.ts +186 -0
  103. package/dist/providers/spec/evaluator.d.ts +23 -0
  104. package/dist/providers/spec/fsm-driver.d.ts +278 -0
  105. package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
  106. package/dist/providers/spec/fsm-loader.d.ts +14 -0
  107. package/dist/providers/spec/fsm-types.d.ts +128 -0
  108. package/dist/providers/spec/native-history-executor.d.ts +41 -0
  109. package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
  110. package/dist/providers/spec/route.d.ts +4 -0
  111. package/dist/providers/spec/types.d.ts +144 -0
  112. package/dist/providers/transcript-v2.d.ts +176 -0
  113. package/dist/providers/types/interactive-prompt.d.ts +84 -0
  114. package/dist/repo-mesh-types.d.ts +203 -13
  115. package/dist/sessions/registry.d.ts +6 -0
  116. package/dist/shared-types-extra.d.ts +2 -4
  117. package/dist/shared-types.d.ts +42 -1
  118. package/dist/status/normalize.d.ts +1 -1
  119. package/dist/status/normalize.js +1 -0
  120. package/dist/status/normalize.js.map +1 -1
  121. package/dist/status/normalize.mjs +1 -0
  122. package/dist/status/normalize.mjs.map +1 -1
  123. package/dist/status/reporter.d.ts +2 -0
  124. package/dist/status/snapshot.d.ts +1 -0
  125. package/dist/types.d.ts +5 -0
  126. package/package.json +7 -3
  127. package/src/agent-stream/poller.ts +2 -3
  128. package/src/boot/daemon-lifecycle.ts +55 -12
  129. package/src/boot/process-hardening.ts +89 -0
  130. package/src/build-info.ts +73 -0
  131. package/src/chat/source-machine.ts +534 -0
  132. package/src/chat/source-resolver.ts +0 -0
  133. package/src/chat/subscription-updates.ts +20 -1
  134. package/src/cli-adapter-types.d.ts +1 -0
  135. package/src/cli-adapter-types.ts +22 -2
  136. package/src/cli-adapters/cli-script-runner.ts +421 -0
  137. package/src/cli-adapters/cli-state-engine.ts +1215 -0
  138. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  139. package/src/cli-adapters/provider-cli-adapter.ts +674 -1139
  140. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  141. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  142. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  143. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  144. package/src/cli-adapters/provider-cli-shared.ts +68 -11
  145. package/src/cli-adapters/pty-transport.ts +2 -1
  146. package/src/cli-adapters/raw-terminal-io.ts +252 -0
  147. package/src/cli-adapters/resolve-executable.ts +45 -0
  148. package/src/cli-adapters/session-host-transport.ts +2 -1
  149. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -29
  150. package/src/cli-adapters/terminal-backends/types.ts +10 -3
  151. package/src/cli-adapters/terminal-screen.ts +16 -81
  152. package/src/commands/chat-commands.ts +1813 -60
  153. package/src/commands/cli-manager.ts +286 -14
  154. package/src/commands/handler.ts +809 -2
  155. package/src/commands/mesh-coordinator.ts +332 -122
  156. package/src/commands/router.ts +5911 -595
  157. package/src/commands/upgrade-helper.ts +29 -0
  158. package/src/config/chat-history.ts +474 -24
  159. package/src/config/config.ts +12 -0
  160. package/src/config/mesh-config.ts +303 -3
  161. package/src/config/recent-activity.ts +8 -2
  162. package/src/daemon/dev-auto-implement.ts +3 -2
  163. package/src/daemon/dev-cli-debug.ts +10 -1
  164. package/src/detection/ide-detector.ts +26 -16
  165. package/src/git/git-commands.ts +42 -12
  166. package/src/git/git-diff.ts +53 -0
  167. package/src/git/git-executor.ts +12 -0
  168. package/src/git/git-status.ts +302 -18
  169. package/src/git/git-types.ts +14 -62
  170. package/src/git/git-worktree.ts +8 -1
  171. package/src/index.ts +131 -11
  172. package/src/installer.d.ts +1 -1
  173. package/src/installer.ts +8 -6
  174. package/src/ipc/local-ipc-server.ts +278 -0
  175. package/src/launch.d.ts +1 -1
  176. package/src/launch.ts +37 -28
  177. package/src/logging/async-batch-writer.ts +55 -0
  178. package/src/logging/logger.ts +2 -1
  179. package/src/mesh/contracts.ts +329 -0
  180. package/src/mesh/coordinator-prompt.ts +234 -31
  181. package/src/mesh/coordinator-registry.ts +121 -0
  182. package/src/mesh/mesh-active-work.ts +469 -0
  183. package/src/mesh/mesh-delivery-policy.ts +315 -0
  184. package/src/mesh/mesh-events-coordinator.ts +1786 -0
  185. package/src/mesh/mesh-events-pending.ts +508 -0
  186. package/src/mesh/mesh-events-stale.ts +290 -0
  187. package/src/mesh/mesh-events-utils.ts +254 -0
  188. package/src/mesh/mesh-events.ts +30 -1035
  189. package/src/mesh/mesh-fast-forward.ts +839 -0
  190. package/src/mesh/mesh-host-ownership.ts +73 -0
  191. package/src/mesh/mesh-init.ts +260 -0
  192. package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
  193. package/src/mesh/mesh-ledger.ts +589 -102
  194. package/src/mesh/mesh-missions.ts +248 -0
  195. package/src/mesh/mesh-reconcile-loop.ts +466 -0
  196. package/src/mesh/mesh-refine-batch.ts +197 -0
  197. package/src/mesh/mesh-refine-status.ts +231 -0
  198. package/src/mesh/mesh-review-inbox.ts +307 -0
  199. package/src/mesh/mesh-routing.ts +291 -0
  200. package/src/mesh/mesh-runtime-store.ts +1513 -0
  201. package/src/mesh/mesh-task-stats.ts +154 -0
  202. package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
  203. package/src/mesh/mesh-work-queue.ts +604 -145
  204. package/src/mesh/preview-freshness.ts +118 -0
  205. package/src/mesh/refine-config.ts +403 -0
  206. package/src/mesh/worktree-bootstrap-config.ts +326 -0
  207. package/src/providers/acp-provider-instance.ts +15 -1
  208. package/src/providers/approval-utils.d.ts +4 -0
  209. package/src/providers/approval-utils.ts +47 -5
  210. package/src/providers/chat-message-normalization.ts +4 -11
  211. package/src/providers/cli-provider-instance.ts +953 -87
  212. package/src/providers/contracts.d.ts +55 -0
  213. package/src/providers/contracts.ts +141 -6
  214. package/src/providers/extension-provider-instance.ts +5 -1
  215. package/src/providers/external-sources.ts +218 -0
  216. package/src/providers/ide-provider-instance.ts +25 -6
  217. package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
  218. package/src/providers/native-history/claude-cli-transcript.ts +396 -0
  219. package/src/providers/native-history/codex-cli-transcript.ts +479 -0
  220. package/src/providers/native-history/dispatcher.ts +340 -0
  221. package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
  222. package/src/providers/native-history/index.ts +30 -0
  223. package/src/providers/provider-instance-manager.ts +30 -0
  224. package/src/providers/provider-instance.ts +10 -1
  225. package/src/providers/provider-loader.ts +584 -50
  226. package/src/providers/provider-schema.ts +87 -14
  227. package/src/providers/provider-trust.ts +114 -0
  228. package/src/providers/read-chat-contract.ts +76 -16
  229. package/src/providers/sdk/README.md +49 -0
  230. package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
  231. package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
  232. package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
  233. package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
  234. package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
  235. package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
  236. package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
  237. package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
  238. package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
  239. package/src/providers/sdk/v1/index.ts +152 -0
  240. package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
  241. package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
  242. package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
  243. package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
  244. package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
  245. package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
  246. package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
  247. package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
  248. package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
  249. package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
  250. package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
  251. package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
  252. package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
  253. package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
  254. package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
  255. package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
  256. package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
  257. package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
  258. package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
  259. package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
  260. package/src/providers/sdk/v1/types/cli/index.ts +365 -0
  261. package/src/providers/sdk/v1/types/common/index.ts +229 -0
  262. package/src/providers/sdk/v1/validators/index.ts +19 -0
  263. package/src/providers/sdk/v1/validators/manifest.ts +110 -0
  264. package/src/providers/sdk/v1/validators/taint.ts +309 -0
  265. package/src/providers/spec/adapter.ts +155 -0
  266. package/src/providers/spec/cli-adapter.ts +838 -0
  267. package/src/providers/spec/evaluator.ts +345 -0
  268. package/src/providers/spec/fsm-driver.ts +875 -0
  269. package/src/providers/spec/fsm-evaluator.ts +255 -0
  270. package/src/providers/spec/fsm-loader.ts +112 -0
  271. package/src/providers/spec/fsm-types.ts +222 -0
  272. package/src/providers/spec/native-history-executor.ts +943 -0
  273. package/src/providers/spec/pre-launch-trust.ts +104 -0
  274. package/src/providers/spec/route.ts +51 -0
  275. package/src/providers/spec/types.ts +189 -0
  276. package/src/providers/transcript-v2.ts +567 -0
  277. package/src/providers/types/interactive-prompt.ts +536 -0
  278. package/src/providers/version-archive.ts +38 -20
  279. package/src/repo-mesh-types.ts +257 -13
  280. package/src/sessions/registry.ts +6 -0
  281. package/src/shared-types-extra.ts +2 -4
  282. package/src/shared-types.ts +45 -1
  283. package/src/status/builders.ts +26 -6
  284. package/src/status/normalize.ts +2 -0
  285. package/src/status/reporter.ts +15 -0
  286. package/src/status/snapshot.ts +84 -25
  287. package/src/system/host-memory.ts +29 -12
  288. package/src/types.ts +5 -0
  289. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
  290. package/dist/mesh/mesh-sync.d.ts +0 -53
  291. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
  292. package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
  293. package/src/mesh/mesh-sync.ts +0 -111
@@ -0,0 +1,116 @@
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
+ export declare function upsertMeshMission(meshId: string, input: {
66
+ id?: string;
67
+ title: string;
68
+ goal?: string;
69
+ status?: string;
70
+ }): MeshMissionRecord;
71
+ export declare function getMeshMissions(meshId: string, statuses?: MeshMissionStatus[]): MeshMissionRecord[];
72
+ export declare function getMeshMission(meshId: string, missionId: string): MeshMissionRecord | null;
73
+ /** Aggregate task statuses for a mission at query time (no stored progress). */
74
+ export declare function summarizeMissionTasks(meshId: string, missionId: string): MeshMissionTaskAggregate;
75
+ export declare function summarizeMeshMission(meshId: string, mission: MeshMissionRecord): MeshMissionSummary;
76
+ /** Active mission summaries for mesh_status / coordinator prompt injection. */
77
+ export declare function getActiveMeshMissionSummaries(meshId: string): MeshMissionSummary[];
78
+ /**
79
+ * Mission summaries for the mesh_status dashboard surface: every active/paused
80
+ * mission plus a capped, newest-first slice of completed/abandoned history so
81
+ * the dashboard can render a collapsible "history" section without unbounded
82
+ * payload growth. Returned newest-first within each group (active/paused first,
83
+ * then history), so the frontend can split on `status` directly.
84
+ *
85
+ * Compact mode (the default) elides each mission's full `goal` text — which is
86
+ * repeated verbatim on every status poll and dominates the payload when a mesh
87
+ * has many missions — returning only a short `goalPreview` + `goalTruncated`
88
+ * flag. Pass `verbose: true` to get the full `goal` text per mission. The stored
89
+ * goal is untouched in both modes; this is an output-only projection.
90
+ */
91
+ export declare function getMeshStatusMissionSummaries(meshId: string, options?: {
92
+ historyLimit?: number;
93
+ verbose?: boolean;
94
+ withStats?: boolean;
95
+ }): MeshMissionSummary[] | MeshMissionSlimSummary[];
96
+ /**
97
+ * Read-only mission listing for the mesh_mission_list tool. Returns summaries
98
+ * (record + live task aggregate) for missions matching `statuses` — or every
99
+ * mission when `statuses` is omitted/empty — newest-first by updatedAt. Unlike
100
+ * getMeshStatusMissionSummaries this does NOT cap or group by lifecycle, so a
101
+ * coordinator can deliberately surface paused/abandoned/completed missions that
102
+ * the live status view would hide or truncate.
103
+ *
104
+ * Compact (the default) elides each goal to a capped preview + goalTruncated
105
+ * flag; verbose returns the full goal text. The stored goal is never mutated.
106
+ */
107
+ export declare function listMeshMissionSummaries(meshId: string, options?: {
108
+ statuses?: MeshMissionStatus[];
109
+ verbose?: boolean;
110
+ }): MeshMissionSummary[] | MeshMissionSlimSummary[];
111
+ /**
112
+ * M3-3: render active missions as a prompt section for {{mission}}.
113
+ * Empty string when no active mission — the prompt stays byte-identical to
114
+ * the pre-M3 output in that case (regression guarantee).
115
+ */
116
+ 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 {};