@agimon-ai/doompi-task 0.0.1-alpha.2 → 0.0.1-alpha.21

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 (330) hide show
  1. package/README.md +39 -12
  2. package/dist/adapters/pi/extension.cjs +3 -0
  3. package/dist/adapters/pi/extension.cjs.map +1 -0
  4. package/dist/adapters/pi/extension.d.cts +12 -0
  5. package/dist/adapters/pi/extension.d.cts.map +1 -0
  6. package/dist/adapters/pi/extension.d.mts +12 -0
  7. package/dist/adapters/pi/extension.d.mts.map +1 -0
  8. package/dist/adapters/pi/extension.mjs +3 -0
  9. package/dist/adapters/pi/extension.mjs.map +1 -0
  10. package/dist/adapters/store/paths.cjs +2 -0
  11. package/dist/adapters/store/paths.cjs.map +1 -0
  12. package/dist/adapters/store/paths.d.cts +26 -0
  13. package/dist/adapters/store/paths.d.cts.map +1 -0
  14. package/dist/adapters/store/paths.d.mts +26 -0
  15. package/dist/adapters/store/paths.d.mts.map +1 -0
  16. package/dist/adapters/store/paths.mjs +2 -0
  17. package/dist/adapters/store/paths.mjs.map +1 -0
  18. package/dist/adapters/store/taskStore.cjs +2 -0
  19. package/dist/adapters/store/taskStore.cjs.map +1 -0
  20. package/dist/adapters/store/taskStore.d.cts +87 -0
  21. package/dist/adapters/store/taskStore.d.cts.map +1 -0
  22. package/dist/adapters/store/taskStore.d.mts +87 -0
  23. package/dist/adapters/store/taskStore.d.mts.map +1 -0
  24. package/dist/adapters/store/taskStore.mjs +2 -0
  25. package/dist/adapters/store/taskStore.mjs.map +1 -0
  26. package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
  27. package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
  28. package/dist/adapters/telemetry/logSinkTelemetry.d.cts +52 -0
  29. package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
  30. package/dist/adapters/telemetry/logSinkTelemetry.d.mts +52 -0
  31. package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
  32. package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
  33. package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
  34. package/dist/commands/index.cjs +2 -0
  35. package/dist/commands/index.cjs.map +1 -0
  36. package/dist/commands/index.d.cts +15 -0
  37. package/dist/commands/index.d.cts.map +1 -0
  38. package/dist/commands/index.d.mts +15 -0
  39. package/dist/commands/index.d.mts.map +1 -0
  40. package/dist/commands/index.mjs +2 -0
  41. package/dist/commands/index.mjs.map +1 -0
  42. package/dist/commands/task/promptGuidelines.cjs +2 -0
  43. package/dist/commands/task/promptGuidelines.cjs.map +1 -0
  44. package/dist/commands/task/promptGuidelines.d.cts +5 -0
  45. package/dist/commands/task/promptGuidelines.d.cts.map +1 -0
  46. package/dist/commands/task/promptGuidelines.d.mts +5 -0
  47. package/dist/commands/task/promptGuidelines.d.mts.map +1 -0
  48. package/dist/commands/task/promptGuidelines.mjs +2 -0
  49. package/dist/commands/task/promptGuidelines.mjs.map +1 -0
  50. package/dist/commands/task/responseEnvelope.cjs +7 -0
  51. package/dist/commands/task/responseEnvelope.cjs.map +1 -0
  52. package/dist/commands/task/responseEnvelope.d.cts +51 -0
  53. package/dist/commands/task/responseEnvelope.d.cts.map +1 -0
  54. package/dist/commands/task/responseEnvelope.d.mts +51 -0
  55. package/dist/commands/task/responseEnvelope.d.mts.map +1 -0
  56. package/dist/commands/task/responseEnvelope.mjs +7 -0
  57. package/dist/commands/task/responseEnvelope.mjs.map +1 -0
  58. package/dist/commands/task/taskTool.cjs +3 -0
  59. package/dist/commands/task/taskTool.cjs.map +1 -0
  60. package/dist/commands/task/taskTool.d.cts +19 -0
  61. package/dist/commands/task/taskTool.d.cts.map +1 -0
  62. package/dist/commands/task/taskTool.d.mts +19 -0
  63. package/dist/commands/task/taskTool.d.mts.map +1 -0
  64. package/dist/commands/task/taskTool.mjs +3 -0
  65. package/dist/commands/task/taskTool.mjs.map +1 -0
  66. package/dist/commands.cjs +1 -2
  67. package/dist/commands.d.cts +2 -14
  68. package/dist/commands.d.mts +2 -14
  69. package/dist/commands.mjs +1 -2
  70. package/dist/config.cjs +1 -2
  71. package/dist/config.d.cts +2 -38
  72. package/dist/config.d.mts +2 -38
  73. package/dist/config.mjs +1 -2
  74. package/dist/delegation/manager.cjs +1 -6
  75. package/dist/delegation/manager.d.cts +2 -189
  76. package/dist/delegation/manager.d.mts +2 -189
  77. package/dist/delegation/manager.mjs +1 -6
  78. package/dist/extension.cjs +1 -3
  79. package/dist/extension.d.cts +2 -12
  80. package/dist/extension.d.mts +2 -12
  81. package/dist/extension.mjs +1 -3
  82. package/dist/extensions/doom.cjs +1 -1
  83. package/dist/extensions/doom.cjs.map +1 -1
  84. package/dist/extensions/doom.mjs +1 -1
  85. package/dist/extensions/doom.mjs.map +1 -1
  86. package/dist/extensions/pi.cjs +1 -1
  87. package/dist/extensions/pi.cjs.map +1 -1
  88. package/dist/extensions/pi.d.cts +1 -1
  89. package/dist/extensions/pi.d.mts +1 -1
  90. package/dist/extensions/pi.mjs +1 -1
  91. package/dist/extensions/pi.mjs.map +1 -1
  92. package/dist/index.cjs +1 -1
  93. package/dist/index.d.cts +15 -14
  94. package/dist/index.d.mts +15 -14
  95. package/dist/index.mjs +1 -1
  96. package/dist/logSinkTelemetry.cjs +1 -2
  97. package/dist/logSinkTelemetry.d.cts +2 -51
  98. package/dist/logSinkTelemetry.d.mts +2 -51
  99. package/dist/logSinkTelemetry.mjs +1 -2
  100. package/dist/schemas/task.cjs +2 -0
  101. package/dist/schemas/task.cjs.map +1 -0
  102. package/dist/schemas/task.d.cts +103 -0
  103. package/dist/schemas/task.d.cts.map +1 -0
  104. package/dist/schemas/task.d.mts +103 -0
  105. package/dist/schemas/task.d.mts.map +1 -0
  106. package/dist/schemas/task.mjs +2 -0
  107. package/dist/schemas/task.mjs.map +1 -0
  108. package/dist/services/delegation/manager.cjs +6 -0
  109. package/dist/services/delegation/manager.cjs.map +1 -0
  110. package/dist/services/delegation/manager.d.cts +188 -0
  111. package/dist/services/delegation/manager.d.cts.map +1 -0
  112. package/dist/services/delegation/manager.d.mts +188 -0
  113. package/dist/services/delegation/manager.d.mts.map +1 -0
  114. package/dist/services/delegation/manager.mjs +6 -0
  115. package/dist/services/delegation/manager.mjs.map +1 -0
  116. package/dist/services/narration/taskNarration.cjs +2 -0
  117. package/dist/services/narration/taskNarration.cjs.map +1 -0
  118. package/dist/services/narration/taskNarration.mjs +2 -0
  119. package/dist/services/narration/taskNarration.mjs.map +1 -0
  120. package/dist/services/store/invariants.cjs +2 -0
  121. package/dist/services/store/invariants.cjs.map +1 -0
  122. package/dist/services/store/invariants.d.cts +14 -0
  123. package/dist/services/store/invariants.d.cts.map +1 -0
  124. package/dist/services/store/invariants.d.mts +14 -0
  125. package/dist/services/store/invariants.d.mts.map +1 -0
  126. package/dist/services/store/invariants.mjs +2 -0
  127. package/dist/services/store/invariants.mjs.map +1 -0
  128. package/dist/services/store/paths.cjs +1 -0
  129. package/dist/services/store/paths.mjs +1 -0
  130. package/dist/services/store/processLiveness.cjs +2 -0
  131. package/dist/services/store/processLiveness.cjs.map +1 -0
  132. package/dist/services/store/processLiveness.d.cts +12 -0
  133. package/dist/services/store/processLiveness.d.cts.map +1 -0
  134. package/dist/services/store/processLiveness.d.mts +12 -0
  135. package/dist/services/store/processLiveness.d.mts.map +1 -0
  136. package/dist/services/store/processLiveness.mjs +2 -0
  137. package/dist/services/store/processLiveness.mjs.map +1 -0
  138. package/dist/services/store/reconcile.cjs +2 -0
  139. package/dist/services/store/reconcile.cjs.map +1 -0
  140. package/dist/services/store/reconcile.d.cts +34 -0
  141. package/dist/services/store/reconcile.d.cts.map +1 -0
  142. package/dist/services/store/reconcile.d.mts +34 -0
  143. package/dist/services/store/reconcile.d.mts.map +1 -0
  144. package/dist/services/store/reconcile.mjs +2 -0
  145. package/dist/services/store/reconcile.mjs.map +1 -0
  146. package/dist/services/store/reducer.cjs +3 -0
  147. package/dist/services/store/reducer.cjs.map +1 -0
  148. package/dist/services/store/reducer.d.cts +72 -0
  149. package/dist/services/store/reducer.d.cts.map +1 -0
  150. package/dist/services/store/reducer.d.mts +72 -0
  151. package/dist/services/store/reducer.d.mts.map +1 -0
  152. package/dist/services/store/reducer.mjs +3 -0
  153. package/dist/services/store/reducer.mjs.map +1 -0
  154. package/dist/services/store/taskGraph.cjs +2 -0
  155. package/dist/services/store/taskGraph.cjs.map +1 -0
  156. package/dist/services/store/taskGraph.d.cts +25 -0
  157. package/dist/services/store/taskGraph.d.cts.map +1 -0
  158. package/dist/services/store/taskGraph.d.mts +25 -0
  159. package/dist/services/store/taskGraph.d.mts.map +1 -0
  160. package/dist/services/store/taskGraph.mjs +2 -0
  161. package/dist/services/store/taskGraph.mjs.map +1 -0
  162. package/dist/services/store/taskStore.cjs +1 -0
  163. package/dist/services/store/taskStore.d.cts +2 -0
  164. package/dist/services/store/taskStore.d.mts +2 -0
  165. package/dist/services/store/taskStore.mjs +1 -0
  166. package/dist/services/store/types.cjs +2 -0
  167. package/dist/services/store/types.cjs.map +1 -0
  168. package/dist/services/store/types.d.cts +177 -0
  169. package/dist/services/store/types.d.cts.map +1 -0
  170. package/dist/services/store/types.d.mts +177 -0
  171. package/dist/services/store/types.d.mts.map +1 -0
  172. package/dist/services/store/types.mjs +2 -0
  173. package/dist/services/store/types.mjs.map +1 -0
  174. package/dist/store/invariants.cjs +1 -2
  175. package/dist/store/invariants.d.cts +2 -14
  176. package/dist/store/invariants.d.mts +2 -14
  177. package/dist/store/invariants.mjs +1 -2
  178. package/dist/store/paths.cjs +1 -2
  179. package/dist/store/paths.d.cts +2 -23
  180. package/dist/store/paths.d.mts +2 -23
  181. package/dist/store/paths.mjs +1 -2
  182. package/dist/store/processLiveness.cjs +1 -2
  183. package/dist/store/processLiveness.d.cts +2 -12
  184. package/dist/store/processLiveness.d.mts +2 -12
  185. package/dist/store/processLiveness.mjs +1 -2
  186. package/dist/store/reconcile.cjs +1 -2
  187. package/dist/store/reconcile.d.cts +2 -34
  188. package/dist/store/reconcile.d.mts +2 -34
  189. package/dist/store/reconcile.mjs +1 -2
  190. package/dist/store/reducer.cjs +1 -3
  191. package/dist/store/reducer.d.cts +2 -72
  192. package/dist/store/reducer.d.mts +2 -72
  193. package/dist/store/reducer.mjs +1 -3
  194. package/dist/store/taskGraph.cjs +1 -2
  195. package/dist/store/taskGraph.d.cts +2 -25
  196. package/dist/store/taskGraph.d.mts +2 -25
  197. package/dist/store/taskGraph.mjs +1 -2
  198. package/dist/store/taskStore.cjs +1 -2
  199. package/dist/store/taskStore.d.cts +3 -77
  200. package/dist/store/taskStore.d.mts +3 -77
  201. package/dist/store/taskStore.mjs +1 -2
  202. package/dist/store/types.cjs +1 -2
  203. package/dist/store/types.d.cts +2 -165
  204. package/dist/store/types.d.mts +2 -165
  205. package/dist/store/types.mjs +1 -2
  206. package/dist/tool/promptGuidelines.cjs +1 -2
  207. package/dist/tool/promptGuidelines.d.cts +2 -5
  208. package/dist/tool/promptGuidelines.d.mts +2 -5
  209. package/dist/tool/promptGuidelines.mjs +1 -2
  210. package/dist/tool/responseEnvelope.cjs +1 -6
  211. package/dist/tool/responseEnvelope.d.cts +2 -39
  212. package/dist/tool/responseEnvelope.d.mts +2 -39
  213. package/dist/tool/responseEnvelope.mjs +1 -6
  214. package/dist/tool/schema.cjs +1 -2
  215. package/dist/tool/schema.d.cts +2 -86
  216. package/dist/tool/schema.d.mts +2 -86
  217. package/dist/tool/schema.mjs +1 -2
  218. package/dist/tool/taskTool.cjs +1 -3
  219. package/dist/tool/taskTool.d.cts +3 -17
  220. package/dist/tool/taskTool.d.mts +3 -17
  221. package/dist/tool/taskTool.mjs +1 -3
  222. package/dist/tui/format.cjs +3 -3
  223. package/dist/tui/format.cjs.map +1 -1
  224. package/dist/tui/format.d.cts +5 -5
  225. package/dist/tui/format.d.cts.map +1 -1
  226. package/dist/tui/format.d.mts +5 -5
  227. package/dist/tui/format.d.mts.map +1 -1
  228. package/dist/tui/format.mjs +3 -3
  229. package/dist/tui/format.mjs.map +1 -1
  230. package/dist/tui/selectors.cjs +1 -1
  231. package/dist/tui/selectors.cjs.map +1 -1
  232. package/dist/tui/selectors.d.cts +8 -1
  233. package/dist/tui/selectors.d.cts.map +1 -1
  234. package/dist/tui/selectors.d.mts +8 -1
  235. package/dist/tui/selectors.d.mts.map +1 -1
  236. package/dist/tui/selectors.mjs +1 -1
  237. package/dist/tui/selectors.mjs.map +1 -1
  238. package/dist/tui/taskOverlay.cjs +1 -1
  239. package/dist/tui/taskOverlay.cjs.map +1 -1
  240. package/dist/tui/taskOverlay.d.cts +2 -2
  241. package/dist/tui/taskOverlay.d.cts.map +1 -1
  242. package/dist/tui/taskOverlay.d.mts +2 -2
  243. package/dist/tui/taskOverlay.d.mts.map +1 -1
  244. package/dist/tui/taskOverlay.mjs +1 -1
  245. package/dist/tui/taskOverlay.mjs.map +1 -1
  246. package/dist/tui/taskSpace.cjs +3 -3
  247. package/dist/tui/taskSpace.cjs.map +1 -1
  248. package/dist/tui/taskSpace.d.cts +2 -1
  249. package/dist/tui/taskSpace.d.cts.map +1 -1
  250. package/dist/tui/taskSpace.d.mts +2 -1
  251. package/dist/tui/taskSpace.d.mts.map +1 -1
  252. package/dist/tui/taskSpace.mjs +3 -3
  253. package/dist/tui/taskSpace.mjs.map +1 -1
  254. package/dist/types/config.cjs +2 -0
  255. package/dist/types/config.cjs.map +1 -0
  256. package/dist/types/config.d.cts +43 -0
  257. package/dist/types/config.d.cts.map +1 -0
  258. package/dist/types/config.d.mts +43 -0
  259. package/dist/types/config.d.mts.map +1 -0
  260. package/dist/types/config.mjs +2 -0
  261. package/dist/types/config.mjs.map +1 -0
  262. package/package.json +16 -9
  263. package/dist/commands.cjs.map +0 -1
  264. package/dist/commands.d.cts.map +0 -1
  265. package/dist/commands.d.mts.map +0 -1
  266. package/dist/commands.mjs.map +0 -1
  267. package/dist/config.cjs.map +0 -1
  268. package/dist/config.d.cts.map +0 -1
  269. package/dist/config.d.mts.map +0 -1
  270. package/dist/config.mjs.map +0 -1
  271. package/dist/delegation/manager.cjs.map +0 -1
  272. package/dist/delegation/manager.d.cts.map +0 -1
  273. package/dist/delegation/manager.d.mts.map +0 -1
  274. package/dist/delegation/manager.mjs.map +0 -1
  275. package/dist/extension.cjs.map +0 -1
  276. package/dist/extension.d.cts.map +0 -1
  277. package/dist/extension.d.mts.map +0 -1
  278. package/dist/extension.mjs.map +0 -1
  279. package/dist/logSinkTelemetry.cjs.map +0 -1
  280. package/dist/logSinkTelemetry.d.cts.map +0 -1
  281. package/dist/logSinkTelemetry.d.mts.map +0 -1
  282. package/dist/logSinkTelemetry.mjs.map +0 -1
  283. package/dist/store/invariants.cjs.map +0 -1
  284. package/dist/store/invariants.d.cts.map +0 -1
  285. package/dist/store/invariants.d.mts.map +0 -1
  286. package/dist/store/invariants.mjs.map +0 -1
  287. package/dist/store/paths.cjs.map +0 -1
  288. package/dist/store/paths.d.cts.map +0 -1
  289. package/dist/store/paths.d.mts.map +0 -1
  290. package/dist/store/paths.mjs.map +0 -1
  291. package/dist/store/processLiveness.cjs.map +0 -1
  292. package/dist/store/processLiveness.d.cts.map +0 -1
  293. package/dist/store/processLiveness.d.mts.map +0 -1
  294. package/dist/store/processLiveness.mjs.map +0 -1
  295. package/dist/store/reconcile.cjs.map +0 -1
  296. package/dist/store/reconcile.d.cts.map +0 -1
  297. package/dist/store/reconcile.d.mts.map +0 -1
  298. package/dist/store/reconcile.mjs.map +0 -1
  299. package/dist/store/reducer.cjs.map +0 -1
  300. package/dist/store/reducer.d.cts.map +0 -1
  301. package/dist/store/reducer.d.mts.map +0 -1
  302. package/dist/store/reducer.mjs.map +0 -1
  303. package/dist/store/taskGraph.cjs.map +0 -1
  304. package/dist/store/taskGraph.d.cts.map +0 -1
  305. package/dist/store/taskGraph.d.mts.map +0 -1
  306. package/dist/store/taskGraph.mjs.map +0 -1
  307. package/dist/store/taskStore.cjs.map +0 -1
  308. package/dist/store/taskStore.d.cts.map +0 -1
  309. package/dist/store/taskStore.d.mts.map +0 -1
  310. package/dist/store/taskStore.mjs.map +0 -1
  311. package/dist/store/types.cjs.map +0 -1
  312. package/dist/store/types.d.cts.map +0 -1
  313. package/dist/store/types.d.mts.map +0 -1
  314. package/dist/store/types.mjs.map +0 -1
  315. package/dist/tool/promptGuidelines.cjs.map +0 -1
  316. package/dist/tool/promptGuidelines.d.cts.map +0 -1
  317. package/dist/tool/promptGuidelines.d.mts.map +0 -1
  318. package/dist/tool/promptGuidelines.mjs.map +0 -1
  319. package/dist/tool/responseEnvelope.cjs.map +0 -1
  320. package/dist/tool/responseEnvelope.d.cts.map +0 -1
  321. package/dist/tool/responseEnvelope.d.mts.map +0 -1
  322. package/dist/tool/responseEnvelope.mjs.map +0 -1
  323. package/dist/tool/schema.cjs.map +0 -1
  324. package/dist/tool/schema.d.cts.map +0 -1
  325. package/dist/tool/schema.d.mts.map +0 -1
  326. package/dist/tool/schema.mjs.map +0 -1
  327. package/dist/tool/taskTool.cjs.map +0 -1
  328. package/dist/tool/taskTool.d.cts.map +0 -1
  329. package/dist/tool/taskTool.d.mts.map +0 -1
  330. package/dist/tool/taskTool.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager.mjs","names":[],"sources":["../../src/delegation/manager.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport path from 'node:path';\nimport {\n DelegationAccepted,\n DelegationCancelled,\n DelegationFinished,\n DelegationRequested,\n DelegationStarted,\n DelegationUpdated,\n type DelegationAccepted as DelegationAcceptedPayload,\n type DelegationResult,\n type DelegationStarted as DelegationStartedPayload,\n type DelegationUpdate,\n} from '@agimon-ai/doompi-extension-contracts/delegation';\nimport {\n createProtocolRuntime,\n type EventBusLike,\n type ProtocolRuntime,\n} from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { InlineAgent } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\nimport { TASK_EVENT, type TaskEventName, type TaskFailureReporter } from '../logSinkTelemetry.ts';\nimport { reconcileOrphanedDelegations } from '../store/reconcile.ts';\nimport { isBlocked, isTaskListComplete } from '../store/taskGraph.ts';\nimport type { TaskStore } from '../store/taskStore.ts';\nimport { isDelegationActive, type Task, type TaskDelegation, type TaskDocument } from '../store/types.ts';\n\nexport const NOTIFY_CUSTOM_TYPE = 'doom-task-notify';\nexport const BACKGROUND_WORK_PROVIDER = 'doom-task';\n\nconst DEFAULT_STARTED_TIMEOUT_MS = 5000;\nconst DEFAULT_RUN_TIMEOUT_MS = 20 * 60 * 1000;\nconst DEFAULT_CANCEL_TIMEOUT_MS = 10_000;\nconst MAX_RUN_TIMEOUT_GRACE_MS = 60_000;\nconst MAX_STORED_OUTPUT = 4000;\n/**\n * Cap on files rendered into a brief. Exported so the tool schema can state the\n * same number to the model rather than restating it and drifting.\n */\nexport const MAX_BRIEF_FILES = 12;\nconst MAX_BRIEF_NOTES = 1500;\nconst COMPLETED_STATE = 'completed';\nconst FAILED_STATE = 'failed';\nconst CANCELLED_STATE = 'cancelled';\nconst TIMED_OUT_STATUS = 'timed_out';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REQUEST_ID_ATTRIBUTE = 'delegation.request_id';\n// `_name` suffix is load-bearing: the telemetry redactor drops string values\n// whose key has no safe meaning, and a bare `delegation.agent` is dropped.\nconst AGENT_ATTRIBUTE = 'delegation.agent_name';\nconst PID_ATTRIBUTE = 'delegation.pid';\nconst CONTEXT_PRESENT_ATTRIBUTE = 'delegation.context_present';\nconst CONTEXT_FILE_COUNT_ATTRIBUTE = 'delegation.context_file_count';\nconst CONTEXT_NOTES_LENGTH_ATTRIBUTE = 'delegation.context_notes_length';\nconst BRIEF_LENGTH_ATTRIBUTE = 'delegation.brief_length';\nconst TOOL_COUNT_ATTRIBUTE = 'delegation.tool_count';\nconst DURATION_MS_ATTRIBUTE = 'delegation.duration_ms';\nconst OUTCOME_ATTRIBUTE = 'delegation.outcome';\n\ntype SettlementState = typeof COMPLETED_STATE | typeof FAILED_STATE | typeof CANCELLED_STATE;\n\nexport const ERR_NO_RUNTIME =\n 'No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.';\nexport const ERR_CHILD_SESSION =\n 'assign is only available in the main session. Update this task directly instead of re-delegating it.';\nexport const ERR_CANCEL_UNACKNOWLEDGED = 'Subagent did not acknowledge the cancel request';\n\n/** Live progress from a running subagent. Kept in memory: persisting per-tool\n * ticks would rewrite the store file every second for no durable benefit. */\nexport interface DelegationProgress {\n agent: string;\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n /** Latest child-runtime duration baseline, excluding assignment wait. */\n durationMs?: number;\n /** Wall-clock time at which durationMs was observed or rebased. */\n durationObservedAt?: number;\n /** Assign-time context-pack shape, carried so the completion event can be\n * grouped by it without joining back to the assignment event. */\n contextFileCount?: number;\n contextNotesLength?: number;\n}\n\nexport interface DelegationNotifier {\n (\n message: { customType: string; content: string; display: boolean },\n options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn' },\n ): void;\n}\n\nexport interface DelegationManagerOptions {\n events: EventBusLike;\n store: TaskStore;\n cwd: string;\n notify?: DelegationNotifier;\n getSessionId?: () => string | undefined;\n env?: NodeJS.ProcessEnv;\n onChange?: () => void;\n startedTimeoutMs?: number;\n /** How long a started run may go without reporting a result. */\n runTimeoutMs?: number;\n /** How long to wait for a cancelled run to report back before forcing it. */\n cancelTimeoutMs?: number;\n now?: () => string;\n nowMs?: () => number;\n /** Called when a completion notification could not be delivered. */\n onNotifyError: (error: unknown, taskId: number) => void;\n /** Where other swallowed delegation failures go. */\n report?: TaskFailureReporter;\n}\n\nexport interface AssignOptions {\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** Paths the parent already located, rendered into the brief so the child\n * skips rediscovering them. */\n relevantFiles?: string[];\n /** Facts the parent already established, rendered into the brief so the child\n * does not re-derive them. */\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n signal?: AbortSignal;\n}\n\nexport interface DelegationOutcome {\n ok: boolean;\n message: string;\n}\n\n/** Result of the guarded store mutation that claims a task for delegation. */\ninterface AssignAttempt extends DelegationOutcome {\n task?: Task;\n}\n\nfunction truncate(value: string | undefined, limit = MAX_STORED_OUTPUT): string | undefined {\n if (!value) return undefined;\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n… (truncated)`;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The assign-time context pack, normalized once for the brief and the telemetry. */\ninterface BriefContext {\n files: string[];\n notes?: string;\n}\n\n/**\n * Render a supplied path the way the child will see it, from `cwd`.\n *\n * Existence is deliberately not checked: an fs probe here duplicates the read\n * the child performs anyway, and it cannot detect the failure that actually\n * matters — a path that exists but is no longer the right one.\n */\nfunction briefPath(entry: string, cwd: string): string {\n if (!path.isAbsolute(entry)) return path.normalize(entry);\n const relative = path.relative(cwd, entry);\n // Outside the run directory the original beats a `../../` chain.\n return relative && !relative.startsWith('..') ? relative : entry;\n}\n\nfunction briefContext(options: AssignOptions, cwd: string): BriefContext {\n const files = new Set<string>();\n for (const entry of options.relevantFiles ?? []) {\n if (files.size >= MAX_BRIEF_FILES) break;\n const normalized = briefPath(entry.trim(), cwd);\n if (normalized && normalized !== '.') files.add(normalized);\n }\n return { files: [...files], notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES) };\n}\n\n/**\n * Build the brief handed to the subagent.\n *\n * Doom Team owns the child tool surface and the parent owns the task record.\n * Keeping those responsibilities explicit prevents a child from attempting to\n * call a task tool that is not loaded in its runtime, while still giving it a\n * reliable path to ask the parent for a decision.\n *\n * The context pack is the parent's verified discovery handed over. The whole\n * block is omitted when nothing was supplied: this brief is the child's whole\n * starting context, so an empty section header is pure token cost.\n */\nfunction buildBrief(task: Task, instructions: string | undefined, context: BriefContext): string {\n const sections = [`Task #${task.id}: ${task.subject}`];\n if (task.description) sections.push(task.description);\n if (instructions) sections.push(instructions);\n if (context.files.length > 0 || context.notes) {\n const contextLines = ['Parent context — consume before repository discovery:'];\n if (context.files.length > 0) {\n contextLines.push(`- Parent-verified files (read these first with direct reads): ${context.files.join(', ')}`);\n }\n if (context.notes) {\n contextLines.push(\n `- Established facts (do not re-derive unless direct evidence contradicts them): ${context.notes}`,\n );\n }\n contextLines.push(\n 'This pack satisfies initial repository/context exploration. Do not begin with repository-wide listing, find, or grep. Expand only after consuming the pack and naming a concrete missing dependency or invalid path; search narrowly for that item and state why.',\n );\n sections.push(contextLines.join('\\n'));\n }\n sections.push(\n 'Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.',\n );\n return sections.join('\\n\\n');\n}\n\n/**\n * Owns the lifecycle of tasks delegated to subagents.\n *\n * Delegation rides the Doom Team event bus rather than spawning\n * processes directly, so doom-task stays decoupled from the subagent runtime\n * and degrades to a clear error when that runtime is not loaded.\n *\n * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so\n * a delegation always has a deadline no matter which phase it is in. Losing\n * that pairing is what previously left tasks running forever.\n */\nexport class DelegationManager {\n private readonly options: DelegationManagerOptions;\n private readonly progress = new Map<string, DelegationProgress>();\n private readonly pendingTasks = new Map<string, number>();\n private readonly timers = new Map<string, NodeJS.Timeout>();\n private readonly subscriptions: Array<() => void> = [];\n private protocol: ProtocolRuntime | undefined;\n\n constructor(options: DelegationManagerOptions) {\n this.options = options;\n }\n\n private now(): string {\n return this.options.now?.() ?? new Date().toISOString();\n }\n\n private nowMs(): number {\n return this.options.nowMs?.() ?? Date.now();\n }\n\n private get env(): NodeJS.ProcessEnv {\n return this.options.env ?? process.env;\n }\n\n private get runTimeoutMs(): number {\n return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;\n }\n\n private report(event: TaskEventName, error: unknown, attributes?: Record<string, string | number | boolean>): void {\n this.options.report?.error(event, error, attributes);\n }\n\n /** True in a session that is itself a subagent child. */\n get isChildSession(): boolean {\n return Boolean(this.env.PI_SUBAGENT_CHILD);\n }\n\n /** Live progress for a task, for the overlay to render. */\n progressFor(task: Task): DelegationProgress | undefined {\n const requestId = task.delegation?.requestId;\n return requestId ? this.progress.get(requestId) : undefined;\n }\n\n /** Displayed runtime duration, rebased from the latest child observation. */\n static elapsedMs(progress: DelegationProgress, nowMs = Date.now()): number {\n const baseline = progress.durationMs ?? 0;\n const observedAt = progress.durationObservedAt ?? nowMs;\n return baseline + Math.max(0, nowMs - observedAt);\n }\n\n /** Idempotent: a session restart re-subscribes without stacking handlers. */\n start(): void {\n if (this.subscriptions.length > 0) return;\n const sessionId = this.options.getSessionId?.();\n if (!sessionId) return;\n this.protocol = createProtocolRuntime({\n bus: this.options.events,\n source: '@agimon-ai/doompi-task',\n sessionId,\n });\n this.subscriptions.push(\n this.protocol.onNotification(DelegationAccepted, (event) => {\n this.handleAccepted(event);\n }),\n this.protocol.onNotification(DelegationStarted, (event) => {\n this.handleStarted(event);\n }),\n this.protocol.onNotification(DelegationUpdated, (event) => {\n this.handleUpdate(event);\n }),\n this.protocol.onNotification(DelegationFinished, (event) => {\n void this.handleResponse(event).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });\n });\n }),\n );\n }\n\n /** Items still in flight, surfaced so auto-stop will not kill the harness. */\n listActiveWork(): Array<{ id: string; sessionId: string }> {\n const sessionId = this.options.getSessionId?.() ?? '';\n return [...this.pendingTasks.entries()].map(([requestId, taskId]) => ({\n id: `task-${taskId}:${requestId}`,\n sessionId,\n }));\n }\n\n /**\n * Return tasks nothing can finish to `pending`.\n *\n * The live request set is read inside the mutation so a delegation assigned\n * while the lock was contended is not mistaken for a leftover.\n */\n async reconcile(): Promise<Task[]> {\n const { value } = await this.options.store.mutate((document) => {\n const result = reconcileOrphanedDelegations(document, this.now(), undefined, {\n pid: process.pid,\n liveRequestIds: new Set(this.pendingTasks.keys()),\n });\n if (result.orphaned.length === 0) return { value: [] as Task[] };\n return { document: result.document, value: result.orphaned };\n });\n\n for (const task of value) {\n this.options.report?.warn(TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ''), {\n [TASK_ID_ATTRIBUTE]: task.id,\n ...(task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {}),\n ...(task.delegation?.pid === undefined ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }),\n });\n }\n\n if (value.length > 0) this.options.onChange?.();\n return value;\n }\n\n async assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome> {\n const agent = options.agent?.trim();\n if (!agent) return { ok: false, message: 'agent required for assign' };\n if (this.isChildSession) return { ok: false, message: ERR_CHILD_SESSION };\n if (options.signal?.aborted) return { ok: false, message: 'delegation cancelled before it started' };\n\n const requestId = randomUUID();\n const startedAt = this.now();\n const context = briefContext(options, this.options.cwd);\n\n const { value: outcome } = await this.options.store.mutate<AssignAttempt>((current) => {\n const index = current.tasks.findIndex((task) => task.id === taskId);\n if (index === -1) return { value: { ok: false, message: `#${taskId} not found` } };\n\n const task = current.tasks[index];\n if (task.status === DELETED_STATUS) return { value: { ok: false, message: `#${taskId} is deleted` } };\n if (task.status === COMPLETED_STATE) {\n return { value: { ok: false, message: `#${taskId} is already completed` } };\n }\n if (isDelegationActive(task)) {\n return { value: { ok: false, message: `#${taskId} is already delegated to ${task.delegation?.agent}` } };\n }\n if (isBlocked(current.tasks, task)) {\n const blockers = (task.blockedBy ?? []).map((id) => `#${id}`).join(', ');\n return { value: { ok: false, message: `#${taskId} is blocked by ${blockers}` } };\n }\n\n const delegation: TaskDelegation = {\n requestId,\n agent,\n state: 'requested',\n pid: process.pid,\n startedAt,\n ...(this.options.getSessionId?.() ? { sessionId: this.options.getSessionId!() } : {}),\n ...(options.model ? { model: options.model } : {}),\n };\n\n const tasks = [...current.tasks];\n tasks[index] = { ...task, owner: agent, updatedAt: startedAt, delegation };\n return {\n document: { ...current, tasks },\n value: { ok: true, message: '', task: tasks[index] },\n };\n });\n\n if (!outcome.ok || !outcome.task) return { ok: false, message: outcome.message };\n\n const contextNotesLength = context.notes?.length ?? 0;\n this.pendingTasks.set(requestId, taskId);\n this.progress.set(requestId, { agent, contextFileCount: context.files.length, contextNotesLength });\n this.armStartedTimeout(requestId);\n\n const request = {\n requestId,\n taskId,\n agent,\n ...(options.inlineAgent ? { inlineAgent: options.inlineAgent } : {}),\n prompt: buildBrief(outcome.task, options.instructions, context),\n ...(options.context ? { context: options.context } : {}),\n cwd: this.options.cwd,\n artifacts: true,\n timeoutMs: this.runTimeoutMs,\n runMode: 'detached' as const,\n teamTask: { id: String(outcome.task.id), subject: outcome.task.subject },\n ...(options.model ? { model: options.model } : {}),\n };\n\n try {\n if (!this.protocol) throw new Error(ERR_NO_RUNTIME);\n this.protocol.notify(DelegationRequested, request);\n } catch (error) {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n const detail = messageOf(error);\n await this.settle(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${detail}`,\n });\n return { ok: false, message: `Could not dispatch #${taskId} to ${agent}: ${detail}` };\n }\n\n // Emitted only after the notify succeeds, so it means \"a brief of this\n // shape actually went out\" rather than \"one was assembled\".\n this.options.report?.event(TASK_EVENT.delegationAssigned, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,\n [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length,\n });\n\n this.options.onChange?.();\n\n return {\n ok: true,\n message: `Delegated #${taskId} to ${agent} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end the turn and wait.`,\n };\n }\n\n async cancel(taskId: number): Promise<DelegationOutcome> {\n const document = this.options.store.read();\n const task = document.tasks.find((candidate) => candidate.id === taskId);\n if (!task) return { ok: false, message: `#${taskId} not found` };\n if (!task.delegation || !isDelegationActive(task)) {\n return { ok: false, message: `#${taskId} has no running delegation` };\n }\n\n const { requestId } = task.delegation;\n this.protocol?.notify(DelegationCancelled, { requestId });\n // Only this session can force the outcome; a delegation owned elsewhere\n // gets the request and nothing more.\n this.armCancelTimeout(requestId);\n return { ok: true, message: `Cancelling delegation for #${taskId} (${task.delegation.agent})` };\n }\n\n /** Settle without awaiting, reporting rather than dropping a failure. */\n private settleDetached(\n requestId: string,\n state: SettlementState,\n result: TaskDelegation['result'],\n event: TaskEventName = TASK_EVENT.delegationSettleFailed,\n ): void {\n void this.settle(requestId, state, result).catch((error: unknown) => {\n this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });\n });\n }\n\n /**\n * Fail a delegation that nobody acknowledged.\n *\n * The bus cannot be probed for listeners, so silence is the only available\n * signal that the subagents runtime is absent. Without this the task would\n * sit in `requested` forever.\n */\n private armStartedTimeout(requestId: string): void {\n this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {\n this.settleDetached(requestId, FAILED_STATE, { status: FAILED_STATE, error: ERR_NO_RUNTIME });\n });\n }\n\n /**\n * Bound a run that already started.\n *\n * The request carries the same budget, so in the normal case the runtime ends\n * the run itself and reports a richer result. The grace period biases toward\n * that answer; this timer only covers a runtime that goes silent, which is\n * precisely the case where no response event will ever arrive.\n */\n private armRunTimeout(requestId: string): void {\n const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);\n this.armTimer(requestId, this.runTimeoutMs + grace, () => {\n const taskId = this.pendingTasks.get(requestId);\n const agent = this.progress.get(requestId)?.agent;\n const error = new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);\n this.options.report?.warn(TASK_EVENT.delegationTimedOut, error, {\n ...(taskId === undefined ? {} : { [TASK_ID_ATTRIBUTE]: taskId }),\n [REQUEST_ID_ATTRIBUTE]: requestId,\n ...(agent ? { [AGENT_ATTRIBUTE]: agent } : {}),\n });\n this.protocol?.notify(DelegationCancelled, { requestId, reason: error.message });\n this.settleDetached(requestId, FAILED_STATE, { status: TIMED_OUT_STATUS, error: error.message });\n });\n }\n\n /**\n * Guarantee a cancel reaches a terminal state.\n *\n * Emitting the cancel event is a request, not an outcome: a runtime that has\n * already forgotten the request answers nothing at all. The window still\n * favours a real response, which carries the run's partial output.\n */\n private armCancelTimeout(requestId: string): void {\n if (!this.pendingTasks.has(requestId)) return;\n this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {\n this.settleDetached(requestId, CANCELLED_STATE, {\n status: CANCELLED_STATE,\n error: ERR_CANCEL_UNACKNOWLEDGED,\n });\n });\n }\n\n private armTimer(requestId: string, delayMs: number, onFire: () => void): void {\n this.clearTimer(requestId);\n const timer = setTimeout(onFire, delayMs);\n timer.unref?.();\n this.timers.set(requestId, timer);\n }\n\n private clearTimer(requestId: string): void {\n const timer = this.timers.get(requestId);\n if (timer) clearTimeout(timer);\n this.timers.delete(requestId);\n }\n\n /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */\n private handleAccepted(event: DelegationAcceptedPayload): void {\n if (!this.pendingTasks.has(event.requestId)) return;\n this.armRunTimeout(event.requestId);\n }\n\n private handleStarted(event: DelegationStartedPayload): void {\n const { runId } = event;\n const taskId = this.pendingTasks.get(event.requestId);\n if (taskId === undefined) return;\n this.armRunTimeout(event.requestId);\n const existing = this.progress.get(event.requestId);\n if (existing) {\n this.progress.set(event.requestId, {\n ...existing,\n durationMs: existing.durationMs ?? 0,\n durationObservedAt: existing.durationObservedAt ?? this.nowMs(),\n });\n }\n\n void this.options.store\n .mutate((document) =>\n this.patchDelegation(document, event.requestId, (task, delegation) => ({\n ...task,\n status: task.status === COMPLETED_STATE ? task.status : 'in_progress',\n delegation: {\n ...delegation,\n state: 'running',\n startedAt: delegation.startedAt ?? this.now(),\n ...(runId ? { runId } : {}),\n },\n })),\n )\n .then(() => this.options.onChange?.())\n .catch((error: unknown) => {\n this.report(TASK_EVENT.delegationStartFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: event.requestId,\n });\n });\n }\n\n private handleUpdate(event: DelegationUpdate): void {\n const existing = this.progress.get(event.requestId);\n if (!existing) return;\n\n const observedAt = this.nowMs();\n const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);\n const hasDuration = event.durationMs !== undefined;\n this.progress.set(event.requestId, {\n // Spread, not field-by-field: anything carried on progress that this\n // event does not report (the assign-time context shape) must survive the\n // first update, or the completion event reports it as absent.\n ...existing,\n currentTool: event.currentTool ?? existing.currentTool,\n toolCount:\n event.toolCount === undefined ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),\n tokens: event.tokens === undefined ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),\n durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs!) : existing.durationMs,\n durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt,\n });\n this.options.onChange?.();\n }\n\n private async handleResponse(event: DelegationResult): Promise<void> {\n if (!this.pendingTasks.has(event.requestId)) return;\n\n const succeeded = event.status === COMPLETED_STATE && !event.error;\n const state = succeeded ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;\n await this.settle(event.requestId, state, {\n status: event.status,\n error: event.error,\n output: truncate(event.output),\n outputPath: event.outputPath,\n sessionFile: event.sessionFile,\n durationMs: event.durationMs,\n toolCount: event.toolCount,\n });\n }\n\n /**\n * Apply the terminal state of a delegation and tell the model about it.\n *\n * A cancelled run returns the task to `pending` (the work is still wanted,\n * just not by that agent); a failure marks it `failed` so it stays visible\n * rather than silently rejoining the backlog.\n *\n * Dropping the pending entry first makes this single-shot: a response racing\n * the watchdog cannot settle the same run twice. A failed write therefore\n * must not abort the rest — the model still gets told, the run stops counting\n * as active work, and `reconcile` repairs the file at the next session start.\n */\n private async settle(requestId: string, state: SettlementState, result: TaskDelegation['result']): Promise<void> {\n const taskId = this.pendingTasks.get(requestId);\n if (taskId === undefined) return;\n this.pendingTasks.delete(requestId);\n this.clearTimer(requestId);\n const progress = this.progress.get(requestId);\n this.progress.delete(requestId);\n\n const endedAt = this.now();\n let task: Task | undefined;\n try {\n const { value } = await this.options.store.mutate((document) =>\n this.patchDelegation(document, requestId, (current, delegation) => ({\n ...current,\n status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? 'pending' : FAILED_STATE,\n updatedAt: endedAt,\n delegation: { ...delegation, state, endedAt, ...(result ? { result } : {}) },\n })),\n );\n task = value;\n } catch (error) {\n this.report(TASK_EVENT.delegationSettleFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n });\n }\n\n this.options.onChange?.();\n\n const agent = task?.delegation?.agent ?? progress?.agent ?? 'subagent';\n const subject = task?.subject ?? `#${taskId}`;\n\n // Repeats the assign-time context shape so the cost question (\"did packs\n // reduce child tool calls?\") is one grouping rather than a self-join.\n // A run that never started reports neither metric, keeping the medians clean.\n this.options.report?.event(TASK_EVENT.delegationCompleted, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [OUTCOME_ATTRIBUTE]: state,\n [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,\n ...(result?.toolCount === undefined ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount }),\n ...(result?.durationMs === undefined ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }),\n });\n const listComplete =\n state === COMPLETED_STATE && task !== undefined && isTaskListComplete(this.options.store.snapshot.tasks);\n this.notifyModel(state, taskId, subject, agent, result, listComplete);\n }\n\n private notifyModel(\n state: SettlementState,\n taskId: number,\n subject: string,\n agent: string,\n result: TaskDelegation['result'],\n listComplete: boolean,\n ): void {\n const notify = this.options.notify;\n if (!notify) return;\n\n const headline =\n state === COMPLETED_STATE\n ? `Subagent ${agent} completed task #${taskId}: ${subject}`\n : state === CANCELLED_STATE\n ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)`\n : `Subagent ${agent} failed task #${taskId}: ${subject}`;\n\n const lines = [headline];\n if (listComplete) {\n lines.push(\n '',\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.',\n );\n }\n if (result?.error) lines.push(`Error: ${result.error}`);\n if (result?.output) lines.push('', result.output);\n if (result?.outputPath) lines.push('', `Full output: ${result.outputPath}`);\n\n try {\n notify(\n { customType: NOTIFY_CUSTOM_TYPE, content: lines.join('\\n'), display: true },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n } catch (error) {\n // The delegation state is already committed to the store, so a failed\n // notification costs the model its wake-up, not the result. Report it\n // rather than rethrowing, which would strand the settled run.\n this.options.onNotifyError(error, taskId);\n }\n }\n\n /**\n * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.\n *\n * Terminal delegations are left alone. The document here is the freshest one,\n * read under the store lock, which is the only place the check is meaningful:\n * a `started` event can land after a cancel already settled the run, and\n * without this guard its write would resurrect a delegation that nothing is\n * tracking any more.\n */\n private patchDelegation(\n document: TaskDocument,\n requestId: string,\n patch: (task: Task, delegation: TaskDelegation) => Task,\n ): { document?: TaskDocument; value: Task | undefined } {\n const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);\n if (index === -1) return { value: undefined };\n\n const task = document.tasks[index];\n if (!isDelegationActive(task)) return { value: task };\n\n const updated = patch(task, task.delegation!);\n if (updated === task) return { value: task };\n const tasks = [...document.tasks];\n tasks[index] = updated;\n return { document: { ...document, tasks }, value: updated };\n }\n\n dispose(): void {\n for (const unsubscribe of this.subscriptions) unsubscribe();\n this.subscriptions.length = 0;\n this.protocol = undefined;\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pendingTasks.clear();\n this.progress.clear();\n }\n}\n"],"mappings":"qmBA0BA,MAAa,EAAqB,mBACrB,EAA2B,YAW3B,EAAkB,GAEzB,EAAkB,YAClB,EAAe,SACf,EAAkB,YAIlB,EAAoB,UACpB,EAAuB,wBAGvB,EAAkB,wBAElB,EAA4B,6BAC5B,EAA+B,gCAC/B,EAAiC,kCAQ1B,EACX,kHACW,EACX,uGACW,EAA4B,kDAwEzC,SAAS,EAAS,EAA2B,EAAQ,IAAuC,CACrF,KACL,OAAO,EAAM,QAAU,EAAQ,EAAQ,GAAG,EAAM,MAAM,EAAG,CAAK,EAAE,gBAClE,CAEA,SAAS,EAAU,EAAwB,CACzC,OAAO,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAC9D,CAeA,SAAS,EAAU,EAAe,EAAqB,CACrD,GAAI,CAAC,EAAK,WAAW,CAAK,EAAG,OAAO,EAAK,UAAU,CAAK,EACxD,IAAM,EAAW,EAAK,SAAS,EAAK,CAAK,EAEzC,OAAO,GAAY,CAAC,EAAS,WAAW,IAAI,EAAI,EAAW,CAC7D,CAEA,SAAS,EAAa,EAAwB,EAA2B,CACvE,IAAM,EAAQ,IAAI,IAClB,IAAK,IAAM,KAAS,EAAQ,eAAiB,CAAC,EAAG,CAC/C,GAAI,EAAM,MAAA,GAAyB,MACnC,IAAM,EAAa,EAAU,EAAM,KAAK,EAAG,CAAG,EAC1C,GAAc,IAAe,KAAK,EAAM,IAAI,CAAU,CAC5D,CACA,MAAO,CAAE,MAAO,CAAC,GAAG,CAAK,EAAG,MAAO,EAAS,EAAQ,eAAe,KAAK,EAAG,IAAe,CAAE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CACtB,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.cjs","names":["createTaskErrorReporter","toFailureReporter","TaskStore","DelegationManager","getDelegationTimeoutMs","TaskOverlay","COMMAND_NAME","NOTIFY_CUSTOM_TYPE","Text","resolveCollapseKey","registerBackgroundWorkProvider","createProtocolRuntime","BACKGROUND_WORK_PROVIDER","resolveSessionKey","removeLegacyStoreDirectory","hasStorePathOverride","sweepStoreFiles","getStoreTtlMs","TASK_EVENT"],"sources":["../src/extension.ts"],"sourcesContent":["import {\n registerBackgroundWorkProvider,\n type BackgroundWorkProviderHandle,\n} from '@agimon-ai/doompi-extension-contracts/background-work';\nimport { createProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { KeyId } from '@earendil-works/pi-tui';\nimport { Text } from '@earendil-works/pi-tui';\nimport { registerTasksCommand } from './commands.ts';\nimport { COLLAPSE_KEY_OFF, getDelegationTimeoutMs, getStoreTtlMs, resolveCollapseKey } from './config.ts';\nimport { BACKGROUND_WORK_PROVIDER, DelegationManager, NOTIFY_CUSTOM_TYPE } from './delegation/manager.ts';\nimport { createTaskErrorReporter, TASK_EVENT, toFailureReporter } from './logSinkTelemetry.ts';\nimport { hasStorePathOverride, removeLegacyStoreDirectory, resolveSessionKey, sweepStoreFiles } from './store/paths.ts';\nimport { TaskStore } from './store/taskStore.ts';\nimport { registerTaskTool } from './tool/taskTool.ts';\nimport { COMMAND_NAME, TOOL_NAME } from './tool/schema.ts';\nimport { TaskOverlay } from './tui/taskOverlay.ts';\n\ninterface SessionContextLike {\n hasUI: boolean;\n ui: Parameters<TaskOverlay['setUICtx']>[0];\n sessionManager?: { getSessionId(): string };\n}\n\nconst LEADER_SOURCE = '@agimon-ai/doompi-task';\n/** Between doom-plan's 60 and the core help group's 70, so `t` sits after `p`. */\nconst LEADER_GROUP_ORDER = 65;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_COMPACT_EVENT = 'session_compact';\nconst SESSION_TREE_EVENT = 'session_tree';\nconst TOOL_EXECUTION_END_EVENT = 'tool_execution_end';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\n/**\n * doom-task: a session-tree-scoped, file-backed task list with delegation.\n *\n * A root session and its delegated descendants share one durable JSON file.\n * Unrelated sessions resolve to separate stores outside repository metadata.\n */\nexport function taskExtension(pi: ExtensionAPI): void {\n const errorReporter = createTaskErrorReporter();\n const report = toFailureReporter(errorReporter);\n const store = new TaskStore({ report });\n let sessionId: string | undefined;\n let overlay: TaskOverlay | undefined;\n let unwatch: (() => void) | undefined;\n let backgroundWork: BackgroundWorkProviderHandle | undefined;\n\n const refresh = (): void => {\n overlay?.update();\n backgroundWork?.update();\n };\n\n const delegation = new DelegationManager({\n events: pi.events,\n store,\n cwd: process.cwd(),\n notify: (message, options) => pi.sendMessage(message, options),\n getSessionId: () => sessionId,\n onChange: refresh,\n runTimeoutMs: getDelegationTimeoutMs(),\n report,\n onNotifyError: (error, taskId) => {\n void errorReporter.recordNotificationError(error, taskId);\n },\n });\n\n overlay = new TaskOverlay({ getTasks: () => store.snapshot.tasks, delegation });\n\n registerTaskTool(pi, { store, delegation, onChange: refresh, report });\n registerTasksCommand(pi, store);\n\n // `SPC t` remains a group so other task-related surfaces can share the prefix.\n // doom-pi-ui keeps no core group on `t`; a conflicting claim is rejected there\n // with a diagnostic.\n registerDoomLeaderContribution(pi, {\n source: LEADER_SOURCE,\n bindings: [\n {\n id: 'tasks.open',\n path: [\n { key: 't', label: 'tasks', order: LEADER_GROUP_ORDER },\n { key: 't', label: 'tasks' },\n ],\n command: { name: COMMAND_NAME },\n },\n ],\n });\n\n pi.registerMessageRenderer(NOTIFY_CUSTOM_TYPE, (message, _options, theme) => {\n const content = typeof message.content === 'string' ? message.content : '';\n return new Text(theme.fg('muted', content), 0, 0);\n });\n\n const collapseKey = resolveCollapseKey();\n if (collapseKey !== COLLAPSE_KEY_OFF) {\n pi.registerShortcut(collapseKey as KeyId, {\n description: 'Collapse or expand the task overlay',\n handler: (ctx) => {\n if (!ctx.hasUI || !overlay?.isRegistered()) return;\n overlay.toggleCollapse();\n },\n });\n }\n\n pi.on(SESSION_START_EVENT, async (_event, ctx) => {\n // Anything thrown before reconcile() skips the only recovery pass for\n // delegations left behind by the previous session, so the failure must not\n // disappear into the harness.\n try {\n const context = ctx as unknown as SessionContextLike;\n sessionId = context.sessionManager?.getSessionId();\n if (!sessionId) throw new Error('doom-task requires a session id');\n backgroundWork?.dispose();\n backgroundWork = context.hasUI\n ? undefined\n : registerBackgroundWorkProvider(\n createProtocolRuntime({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n }),\n {\n provider: BACKGROUND_WORK_PROVIDER,\n listActiveWork: () => delegation.listActiveWork(),\n },\n );\n store.configureSession(resolveSessionKey(sessionId));\n const cleanup = removeLegacyStoreDirectory(store.storePath);\n const sweep = hasStorePathOverride()\n ? { removed: [], errors: [] }\n : sweepStoreFiles(store.storePath, getStoreTtlMs());\n const storeErrors = [...cleanup.errors, ...sweep.errors];\n for (const failure of storeErrors) report.warn(TASK_EVENT.storeSweepFailed, new Error(failure));\n if (storeErrors.length > 0 && context.hasUI) context.ui.notify(storeErrors.join('\\n'), 'warning');\n if (context.hasUI) overlay?.setUICtx(context.ui);\n store.read();\n unwatch = store.onExternalChange(refresh);\n // A shutdown that kept the process alive left the manager unsubscribed.\n delegation.start();\n await delegation.reconcile();\n refresh();\n } catch (error) {\n report.error(TASK_EVENT.sessionStartFailed, error);\n throw error;\n }\n });\n\n pi.on(SESSION_COMPACT_EVENT, () => refresh());\n pi.on(SESSION_TREE_EVENT, () => refresh());\n\n pi.on(TOOL_EXECUTION_END_EVENT, (event) => {\n if (event.toolName === TOOL_NAME) refresh();\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async () => {\n try {\n unwatch?.();\n backgroundWork?.dispose();\n backgroundWork = undefined;\n delegation.dispose();\n overlay?.dispose();\n store.dispose();\n } finally {\n // Runs even if teardown throws: the buffered records are most valuable\n // exactly when something went wrong on the way out.\n await errorReporter.shutdown();\n }\n });\n}\n\nexport default taskExtension;\n"],"mappings":"0lBAyBA,MAAM,EAAgB,yBAetB,SAAgB,EAAc,EAAwB,CACpD,IAAM,EAAgBA,EAAAA,wBAAwB,EACxC,EAASC,EAAAA,kBAAkB,CAAa,EACxC,EAAQ,IAAIC,EAAAA,UAAU,CAAE,QAAO,CAAC,EAClC,EACA,EACA,EACA,EAEE,MAAsB,CAC1B,GAAS,OAAO,EAChB,GAAgB,OAAO,CACzB,EAEM,EAAa,IAAIC,EAAAA,kBAAkB,CACvC,OAAQ,EAAG,OACX,QACA,IAAK,QAAQ,IAAI,EACjB,QAAS,EAAS,IAAY,EAAG,YAAY,EAAS,CAAO,EAC7D,iBAAoB,EACpB,SAAU,EACV,aAAcC,EAAAA,uBAAuB,EACrC,SACA,eAAgB,EAAO,IAAW,CAChC,EAAmB,wBAAwB,EAAO,CAAM,CAC1D,CACF,CAAC,EAED,EAAU,IAAIC,EAAAA,YAAY,CAAE,aAAgB,EAAM,SAAS,MAAO,YAAW,CAAC,EAE9E,EAAA,iBAAiB,EAAI,CAAE,QAAO,aAAY,SAAU,EAAS,QAAO,CAAC,EACrE,EAAA,qBAAqB,EAAI,CAAK,GAK9B,EAAA,EAAA,+BAAA,CAA+B,EAAI,CACjC,OAAQ,EACR,SAAU,CACR,CACE,GAAI,aACJ,KAAM,CACJ,CAAE,IAAK,IAAK,MAAO,QAAS,MAAO,EAAmB,EACtD,CAAE,IAAK,IAAK,MAAO,OAAQ,CAC7B,EACA,QAAS,CAAE,KAAMC,EAAAA,YAAa,CAChC,CACF,CACF,CAAC,EAED,EAAG,wBAAwBC,EAAAA,oBAAqB,EAAS,EAAU,IAAU,CAC3E,IAAM,EAAU,OAAO,EAAQ,SAAY,SAAW,EAAQ,QAAU,GACxE,OAAO,IAAIC,EAAAA,KAA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CACV,OAAS,EAAO,CAEd,MADA,EAAO,MAAMA,EAAAA,WAAW,mBAAoB,CAAK,EAC3C,CACR,CACF,CAAC,EAED,EAAG,GAAG,sBAA6B,EAAQ,CAAC,EAC5C,EAAG,GAAG,mBAA0B,EAAQ,CAAC,EAEzC,EAAG,GAAG,qBAA2B,GAAU,CACrC,EAAM,WAAA,QAAwB,EAAQ,CAC5C,CAAC,EAED,EAAG,GAAG,mBAAwB,SAAY,CACxC,GAAI,CACF,IAAU,EACV,GAAgB,QAAQ,EACxB,EAAiB,IAAA,GACjB,EAAW,QAAQ,EACnB,GAAS,QAAQ,EACjB,EAAM,QAAQ,CAChB,QAAU,CAGR,MAAM,EAAc,SAAS,CAC/B,CACF,CAAC,CACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.d.cts","names":[],"sources":["../src/extension.ts"],"mappings":";;;;;;;;iBAwCgB,cAAc,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.d.mts","names":[],"sources":["../src/extension.ts"],"mappings":";;;;;;;;iBAwCgB,cAAc,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.mjs","names":[],"sources":["../src/extension.ts"],"sourcesContent":["import {\n registerBackgroundWorkProvider,\n type BackgroundWorkProviderHandle,\n} from '@agimon-ai/doompi-extension-contracts/background-work';\nimport { createProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { KeyId } from '@earendil-works/pi-tui';\nimport { Text } from '@earendil-works/pi-tui';\nimport { registerTasksCommand } from './commands.ts';\nimport { COLLAPSE_KEY_OFF, getDelegationTimeoutMs, getStoreTtlMs, resolveCollapseKey } from './config.ts';\nimport { BACKGROUND_WORK_PROVIDER, DelegationManager, NOTIFY_CUSTOM_TYPE } from './delegation/manager.ts';\nimport { createTaskErrorReporter, TASK_EVENT, toFailureReporter } from './logSinkTelemetry.ts';\nimport { hasStorePathOverride, removeLegacyStoreDirectory, resolveSessionKey, sweepStoreFiles } from './store/paths.ts';\nimport { TaskStore } from './store/taskStore.ts';\nimport { registerTaskTool } from './tool/taskTool.ts';\nimport { COMMAND_NAME, TOOL_NAME } from './tool/schema.ts';\nimport { TaskOverlay } from './tui/taskOverlay.ts';\n\ninterface SessionContextLike {\n hasUI: boolean;\n ui: Parameters<TaskOverlay['setUICtx']>[0];\n sessionManager?: { getSessionId(): string };\n}\n\nconst LEADER_SOURCE = '@agimon-ai/doompi-task';\n/** Between doom-plan's 60 and the core help group's 70, so `t` sits after `p`. */\nconst LEADER_GROUP_ORDER = 65;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_COMPACT_EVENT = 'session_compact';\nconst SESSION_TREE_EVENT = 'session_tree';\nconst TOOL_EXECUTION_END_EVENT = 'tool_execution_end';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\n/**\n * doom-task: a session-tree-scoped, file-backed task list with delegation.\n *\n * A root session and its delegated descendants share one durable JSON file.\n * Unrelated sessions resolve to separate stores outside repository metadata.\n */\nexport function taskExtension(pi: ExtensionAPI): void {\n const errorReporter = createTaskErrorReporter();\n const report = toFailureReporter(errorReporter);\n const store = new TaskStore({ report });\n let sessionId: string | undefined;\n let overlay: TaskOverlay | undefined;\n let unwatch: (() => void) | undefined;\n let backgroundWork: BackgroundWorkProviderHandle | undefined;\n\n const refresh = (): void => {\n overlay?.update();\n backgroundWork?.update();\n };\n\n const delegation = new DelegationManager({\n events: pi.events,\n store,\n cwd: process.cwd(),\n notify: (message, options) => pi.sendMessage(message, options),\n getSessionId: () => sessionId,\n onChange: refresh,\n runTimeoutMs: getDelegationTimeoutMs(),\n report,\n onNotifyError: (error, taskId) => {\n void errorReporter.recordNotificationError(error, taskId);\n },\n });\n\n overlay = new TaskOverlay({ getTasks: () => store.snapshot.tasks, delegation });\n\n registerTaskTool(pi, { store, delegation, onChange: refresh, report });\n registerTasksCommand(pi, store);\n\n // `SPC t` remains a group so other task-related surfaces can share the prefix.\n // doom-pi-ui keeps no core group on `t`; a conflicting claim is rejected there\n // with a diagnostic.\n registerDoomLeaderContribution(pi, {\n source: LEADER_SOURCE,\n bindings: [\n {\n id: 'tasks.open',\n path: [\n { key: 't', label: 'tasks', order: LEADER_GROUP_ORDER },\n { key: 't', label: 'tasks' },\n ],\n command: { name: COMMAND_NAME },\n },\n ],\n });\n\n pi.registerMessageRenderer(NOTIFY_CUSTOM_TYPE, (message, _options, theme) => {\n const content = typeof message.content === 'string' ? message.content : '';\n return new Text(theme.fg('muted', content), 0, 0);\n });\n\n const collapseKey = resolveCollapseKey();\n if (collapseKey !== COLLAPSE_KEY_OFF) {\n pi.registerShortcut(collapseKey as KeyId, {\n description: 'Collapse or expand the task overlay',\n handler: (ctx) => {\n if (!ctx.hasUI || !overlay?.isRegistered()) return;\n overlay.toggleCollapse();\n },\n });\n }\n\n pi.on(SESSION_START_EVENT, async (_event, ctx) => {\n // Anything thrown before reconcile() skips the only recovery pass for\n // delegations left behind by the previous session, so the failure must not\n // disappear into the harness.\n try {\n const context = ctx as unknown as SessionContextLike;\n sessionId = context.sessionManager?.getSessionId();\n if (!sessionId) throw new Error('doom-task requires a session id');\n backgroundWork?.dispose();\n backgroundWork = context.hasUI\n ? undefined\n : registerBackgroundWorkProvider(\n createProtocolRuntime({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n }),\n {\n provider: BACKGROUND_WORK_PROVIDER,\n listActiveWork: () => delegation.listActiveWork(),\n },\n );\n store.configureSession(resolveSessionKey(sessionId));\n const cleanup = removeLegacyStoreDirectory(store.storePath);\n const sweep = hasStorePathOverride()\n ? { removed: [], errors: [] }\n : sweepStoreFiles(store.storePath, getStoreTtlMs());\n const storeErrors = [...cleanup.errors, ...sweep.errors];\n for (const failure of storeErrors) report.warn(TASK_EVENT.storeSweepFailed, new Error(failure));\n if (storeErrors.length > 0 && context.hasUI) context.ui.notify(storeErrors.join('\\n'), 'warning');\n if (context.hasUI) overlay?.setUICtx(context.ui);\n store.read();\n unwatch = store.onExternalChange(refresh);\n // A shutdown that kept the process alive left the manager unsubscribed.\n delegation.start();\n await delegation.reconcile();\n refresh();\n } catch (error) {\n report.error(TASK_EVENT.sessionStartFailed, error);\n throw error;\n }\n });\n\n pi.on(SESSION_COMPACT_EVENT, () => refresh());\n pi.on(SESSION_TREE_EVENT, () => refresh());\n\n pi.on(TOOL_EXECUTION_END_EVENT, (event) => {\n if (event.toolName === TOOL_NAME) refresh();\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async () => {\n try {\n unwatch?.();\n backgroundWork?.dispose();\n backgroundWork = undefined;\n delegation.dispose();\n overlay?.dispose();\n store.dispose();\n } finally {\n // Runs even if teardown throws: the buffered records are most valuable\n // exactly when something went wrong on the way out.\n await errorReporter.shutdown();\n }\n });\n}\n\nexport default taskExtension;\n"],"mappings":"8/BAyBA,MAAM,EAAgB,yBAetB,SAAgB,EAAc,EAAwB,CACpD,IAAM,EAAgB,EAAwB,EACxC,EAAS,EAAkB,CAAa,EACxC,EAAQ,IAAI,EAAU,CAAE,QAAO,CAAC,EAClC,EACA,EACA,EACA,EAEE,MAAsB,CAC1B,GAAS,OAAO,EAChB,GAAgB,OAAO,CACzB,EAEM,EAAa,IAAI,EAAkB,CACvC,OAAQ,EAAG,OACX,QACA,IAAK,QAAQ,IAAI,EACjB,QAAS,EAAS,IAAY,EAAG,YAAY,EAAS,CAAO,EAC7D,iBAAoB,EACpB,SAAU,EACV,aAAc,EAAuB,EACrC,SACA,eAAgB,EAAO,IAAW,CAChC,EAAmB,wBAAwB,EAAO,CAAM,CAC1D,CACF,CAAC,EAED,EAAU,IAAI,EAAY,CAAE,aAAgB,EAAM,SAAS,MAAO,YAAW,CAAC,EAE9E,EAAiB,EAAI,CAAE,QAAO,aAAY,SAAU,EAAS,QAAO,CAAC,EACrE,EAAqB,EAAI,CAAK,EAK9B,EAA+B,EAAI,CACjC,OAAQ,EACR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EAAY,KAAK;CAAI,EAAG,SAAS,EAC5F,EAAQ,OAAO,GAAS,SAAS,EAAQ,EAAE,EAC/C,EAAM,KAAK,EACX,EAAU,EAAM,iBAAiB,CAAO,EAExC,EAAW,MAAM,EACjB,MAAM,EAAW,UAAU,EAC3B,EAAQ,CACV,OAAS,EAAO,CAEd,MADA,EAAO,MAAM,EAAW,mBAAoB,CAAK,EAC3C,CACR,CACF,CAAC,EAED,EAAG,GAAG,sBAA6B,EAAQ,CAAC,EAC5C,EAAG,GAAG,mBAA0B,EAAQ,CAAC,EAEzC,EAAG,GAAG,qBAA2B,GAAU,CACrC,EAAM,WAAA,QAAwB,EAAQ,CAC5C,CAAC,EAED,EAAG,GAAG,mBAAwB,SAAY,CACxC,GAAI,CACF,IAAU,EACV,GAAgB,QAAQ,EACxB,EAAiB,IAAA,GACjB,EAAW,QAAQ,EACnB,GAAS,QAAQ,EACjB,EAAM,QAAQ,CAChB,QAAU,CAGR,MAAM,EAAc,SAAS,CAC/B,CACF,CAAC,CACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logSinkTelemetry.cjs","names":["createDoomTelemetry"],"sources":["../src/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/doompi-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport const TASK_EVENT = {\n notificationFailed: 'doom_task.notification_failed',\n storeReadFailed: 'doom_task.store_read_failed',\n storeLockTimeout: 'doom_task.store_lock_timeout',\n storeLockBreakFailed: 'doom_task.store_lock_break_failed',\n storeWatchFailed: 'doom_task.store_watch_failed',\n storeListenerFailed: 'doom_task.store_listener_failed',\n storeSweepFailed: 'doom_task.store_sweep_failed',\n sessionStartFailed: 'doom_task.session_start_failed',\n toolFailed: 'doom_task.tool_failed',\n delegationRequestFailed: 'doom_task.delegation_request_failed',\n delegationStartFailed: 'doom_task.delegation_start_failed',\n delegationResponseFailed: 'doom_task.delegation_response_failed',\n delegationSettleFailed: 'doom_task.delegation_settle_failed',\n delegationTimedOut: 'doom_task.delegation_timed_out',\n delegationOrphaned: 'doom_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'doom_task.delegation_assigned',\n delegationCompleted: 'doom_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":"gHAEA,MAIa,EAAa,CACxB,mBAAoB,gCACpB,gBAAiB,8BACjB,iBAAkB,+BAClB,qBAAsB,oCACtB,iBAAkB,+BAClB,oBAAqB,kCACrB,iBAAkB,+BAClB,mBAAoB,iCACpB,WAAY,wBACZ,wBAAyB,sCACzB,sBAAuB,oCACvB,yBAA0B,uCAC1B,uBAAwB,qCACxB,mBAAoB,iCACpB,mBAAoB,gCAGpB,mBAAoB,gCACpB,oBAAqB,gCACvB,EA+BA,SAAgB,EAAwB,EAAoC,CAAC,EAAsB,CACjG,IAAM,GAAA,EAA2BA,EAAAA,oBAAAA,CAAoB,CACnD,YAAa,YACb,YAAa,yBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,yBAA0B,EAAO,IAC/B,EAAU,YAAY,EAAW,mBAAoB,EAAO,CAC1D,UAAW,EACX,iBAAkB,yBACpB,CAAC,EACH,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF,CAEA,SAAgB,EAAkB,EAAkD,CAClF,MAAO,CACL,OAAQ,EAAO,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,EAAO,CAAU,EACvF,MAAO,EAAO,EAAO,IAAe,KAAK,EAAS,cAAc,EAAO,EAAO,CAAU,EACxF,OAAQ,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,CAAU,CAC3E,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logSinkTelemetry.d.cts","names":[],"sources":["../src/logSinkTelemetry.ts"],"mappings":";;cAMa;;;;;;;;;;;;;;;;;;;KAsBD,wBAAwB,yBAAyB;KACjD,sBAAsB;KACtB,iBAAiB,OAAO,eAAe,gBAAgB,aAAa;KACpE,iBAAiB,OAAO,eAAe,aAAa;UAE/C;EACf,OAAO;EACP,MAAM;;EAEN,OAAO;;UAGQ;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,eAAe,gBAAgB,aAAa,sBAAsB;EAC9E,cAAc,eAAe,gBAAgB,aAAa,sBAAsB;EAChF,YAAY,eAAe,aAAa,sBAAsB;EAC9D,wBAAwB,gBAAgB,iBAAiB;EACzD,SAAS;EACT,YAAY;;iBAGE,wBAAwB,UAAS,2BAAgC;iBA0BjE,kBAAkB,UAAU,oBAAoB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../src/logSinkTelemetry.ts"],"mappings":";;cAMa;;;;;;;;;;;;;;;;;;;KAsBD,wBAAwB,yBAAyB;KACjD,sBAAsB;KACtB,iBAAiB,OAAO,eAAe,gBAAgB,aAAa;KACpE,iBAAiB,OAAO,eAAe,aAAa;UAE/C;EACf,OAAO;EACP,MAAM;;EAEN,OAAO;;UAGQ;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,eAAe,gBAAgB,aAAa,sBAAsB;EAC9E,cAAc,eAAe,gBAAgB,aAAa,sBAAsB;EAChF,YAAY,eAAe,aAAa,sBAAsB;EAC9D,wBAAwB,gBAAgB,iBAAiB;EACzD,SAAS;EACT,YAAY;;iBAGE,wBAAwB,UAAS,2BAAgC;iBA0BjE,kBAAkB,UAAU,oBAAoB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logSinkTelemetry.mjs","names":[],"sources":["../src/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/doompi-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport const TASK_EVENT = {\n notificationFailed: 'doom_task.notification_failed',\n storeReadFailed: 'doom_task.store_read_failed',\n storeLockTimeout: 'doom_task.store_lock_timeout',\n storeLockBreakFailed: 'doom_task.store_lock_break_failed',\n storeWatchFailed: 'doom_task.store_watch_failed',\n storeListenerFailed: 'doom_task.store_listener_failed',\n storeSweepFailed: 'doom_task.store_sweep_failed',\n sessionStartFailed: 'doom_task.session_start_failed',\n toolFailed: 'doom_task.tool_failed',\n delegationRequestFailed: 'doom_task.delegation_request_failed',\n delegationStartFailed: 'doom_task.delegation_start_failed',\n delegationResponseFailed: 'doom_task.delegation_response_failed',\n delegationSettleFailed: 'doom_task.delegation_settle_failed',\n delegationTimedOut: 'doom_task.delegation_timed_out',\n delegationOrphaned: 'doom_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'doom_task.delegation_assigned',\n delegationCompleted: 'doom_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":"kEAEA,MAIa,EAAa,CACxB,mBAAoB,gCACpB,gBAAiB,8BACjB,iBAAkB,+BAClB,qBAAsB,oCACtB,iBAAkB,+BAClB,oBAAqB,kCACrB,iBAAkB,+BAClB,mBAAoB,iCACpB,WAAY,wBACZ,wBAAyB,sCACzB,sBAAuB,oCACvB,yBAA0B,uCAC1B,uBAAwB,qCACxB,mBAAoB,iCACpB,mBAAoB,gCAGpB,mBAAoB,gCACpB,oBAAqB,gCACvB,EA+BA,SAAgB,EAAwB,EAAoC,CAAC,EAAsB,CACjG,IAAM,EAA2B,EAAoB,CACnD,YAAa,YACb,YAAa,yBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,yBAA0B,EAAO,IAC/B,EAAU,YAAY,EAAW,mBAAoB,EAAO,CAC1D,UAAW,EACX,iBAAkB,yBACpB,CAAC,EACH,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF,CAEA,SAAgB,EAAkB,EAAkD,CAClF,MAAO,CACL,OAAQ,EAAO,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,EAAO,CAAU,EACvF,MAAO,EAAO,EAAO,IAAe,KAAK,EAAS,cAAc,EAAO,EAAO,CAAU,EACxF,OAAQ,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,CAAU,CAC3E,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"invariants.cjs","names":[],"sources":["../../src/store/invariants.ts"],"sourcesContent":["import type { TaskStatus } from './types.ts';\n\n/**\n * Allowed forward transitions per source status.\n *\n * `failed` is recoverable (a delegation can be retried) so it may return to\n * pending or in_progress. `completed` is one-way to `deleted`; `deleted` is a\n * terminal tombstone.\n */\nexport const VALID_TRANSITIONS: Record<TaskStatus, ReadonlySet<TaskStatus>> = {\n pending: new Set<TaskStatus>(['in_progress', 'completed', 'failed', 'deleted']),\n in_progress: new Set<TaskStatus>(['pending', 'completed', 'failed', 'deleted']),\n failed: new Set<TaskStatus>(['pending', 'in_progress', 'completed', 'deleted']),\n completed: new Set<TaskStatus>(['deleted']),\n deleted: new Set<TaskStatus>(),\n};\n\nexport function isTransitionValid(from: TaskStatus, to: TaskStatus): boolean {\n if (from === to) return true;\n return VALID_TRANSITIONS[from].has(to);\n}\n"],"mappings":"mEASA,MAAa,EAAiE,CAC5E,QAAS,IAAI,IAAgB,CAAC,cAAe,YAAa,SAAU,SAAS,CAAC,EAC9E,YAAa,IAAI,IAAgB,CAAC,UAAW,YAAa,SAAU,SAAS,CAAC,EAC9E,OAAQ,IAAI,IAAgB,CAAC,UAAW,cAAe,YAAa,SAAS,CAAC,EAC9E,UAAW,IAAI,IAAgB,CAAC,SAAS,CAAC,EAC1C,QAAS,IAAI,GACf,EAEA,SAAgB,EAAkB,EAAkB,EAAyB,CAE3E,OADI,IAAS,GACN,EAAkB,EAAK,CAAC,IAAI,CAAE,CACvC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"invariants.d.cts","names":[],"sources":["../../src/store/invariants.ts"],"mappings":";;;;;;;;;cASa,mBAAmB,OAAO,YAAY,YAAY;iBAQ/C,kBAAkB,MAAM,YAAY,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"invariants.d.mts","names":[],"sources":["../../src/store/invariants.ts"],"mappings":";;;;;;;;;cASa,mBAAmB,OAAO,YAAY,YAAY;iBAQ/C,kBAAkB,MAAM,YAAY,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"invariants.mjs","names":[],"sources":["../../src/store/invariants.ts"],"sourcesContent":["import type { TaskStatus } from './types.ts';\n\n/**\n * Allowed forward transitions per source status.\n *\n * `failed` is recoverable (a delegation can be retried) so it may return to\n * pending or in_progress. `completed` is one-way to `deleted`; `deleted` is a\n * terminal tombstone.\n */\nexport const VALID_TRANSITIONS: Record<TaskStatus, ReadonlySet<TaskStatus>> = {\n pending: new Set<TaskStatus>(['in_progress', 'completed', 'failed', 'deleted']),\n in_progress: new Set<TaskStatus>(['pending', 'completed', 'failed', 'deleted']),\n failed: new Set<TaskStatus>(['pending', 'in_progress', 'completed', 'deleted']),\n completed: new Set<TaskStatus>(['deleted']),\n deleted: new Set<TaskStatus>(),\n};\n\nexport function isTransitionValid(from: TaskStatus, to: TaskStatus): boolean {\n if (from === to) return true;\n return VALID_TRANSITIONS[from].has(to);\n}\n"],"mappings":"AASA,MAAa,EAAiE,CAC5E,QAAS,IAAI,IAAgB,CAAC,cAAe,YAAa,SAAU,SAAS,CAAC,EAC9E,YAAa,IAAI,IAAgB,CAAC,UAAW,YAAa,SAAU,SAAS,CAAC,EAC9E,OAAQ,IAAI,IAAgB,CAAC,UAAW,cAAe,YAAa,SAAS,CAAC,EAC9E,UAAW,IAAI,IAAgB,CAAC,SAAS,CAAC,EAC1C,QAAS,IAAI,GACf,EAEA,SAAgB,EAAkB,EAAkB,EAAyB,CAE3E,OADI,IAAS,GACN,EAAkB,EAAK,CAAC,IAAI,CAAE,CACvC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.cjs","names":["execFileSync","os","path","SUBAGENT_CHILD_ENV","SUBAGENT_PARENT_SESSION_ENV","fs"],"sources":["../../src/store/paths.ts"],"sourcesContent":["import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from '@agimon-ai/doompi-extension-contracts/child-process';\n\nexport const STORE_PATH_ENV = 'DOOM_TASK_STORE';\n\nconst STORE_DIR_NAME = 'doom-task';\nconst STORE_FILE_NAME = 'tasks.json';\nconst DEFAULT_CONFIG_DIR_NAME = '.pi';\nconst AGENT_DIR_NAME = 'agent';\nconst PI_CODING_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst HOME_ALIAS = '~';\nconst HOME_ALIAS_PREFIX = '~/';\nconst FILE_ENCODING = 'utf8';\nconst NOT_FOUND_ERROR_CODE = 'ENOENT';\n\nfunction git(args: string[], cwd: string): string | undefined {\n try {\n const output = execFileSync('git', args, {\n cwd,\n encoding: FILE_ENCODING,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n const trimmed = output.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveAgentDirectory(env: NodeJS.ProcessEnv): string {\n const configured = env[PI_CODING_AGENT_DIR_ENV]?.trim();\n if (configured === HOME_ALIAS) return os.homedir();\n if (configured?.startsWith(HOME_ALIAS_PREFIX)) {\n return path.join(os.homedir(), configured.slice(HOME_ALIAS_PREFIX.length));\n }\n return configured ? path.resolve(configured) : path.join(os.homedir(), DEFAULT_CONFIG_DIR_NAME, AGENT_DIR_NAME);\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(candidate));\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Resolve the tree root without relying on extension startup order. */\nexport function resolveSessionKey(rootSessionId: string, env: NodeJS.ProcessEnv = process.env): string {\n if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;\n const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();\n if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);\n return parentSessionId;\n}\n\n/** Resolve one root session tree to a task document under the Pi agent directory. */\nexport function resolveStorePath(\n _cwd: string = process.cwd(),\n env: NodeJS.ProcessEnv = process.env,\n sessionKey: string = 'standalone',\n): string {\n const override = env[STORE_PATH_ENV]?.trim();\n if (override) return path.resolve(override);\n\n const trimmedSessionKey = sessionKey.trim();\n if (!trimmedSessionKey) throw new Error('doom-task session id cannot be blank');\n return path.join(resolveAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);\n}\n\n/** Whether a deliberate unscoped task-store override is active. */\nexport function hasStorePathOverride(env: NodeJS.ProcessEnv = process.env): boolean {\n return Boolean(env[STORE_PATH_ENV]?.trim());\n}\n\n/** Exact legacy Git-directory store, if the current working tree has one. */\nexport function resolveLegacyStoreDirectory(cwd: string = process.cwd()): string | undefined {\n const commonDirectory = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport interface StoreSweepResult {\n removed: string[];\n errors: string[];\n}\n\n/** Remove only the validated legacy Git store unless it contains the active override. */\nexport function removeLegacyStoreDirectory(currentStorePath: string, cwd: string = process.cwd()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = resolveLegacyStoreDirectory(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n if (!fs.existsSync(target)) return result;\n fs.rmSync(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n return result;\n}\n\n/** Delete expired sibling session stores while preserving active or unreadable stores. */\nexport function sweepStoreFiles(currentStorePath: string, ttlMs: number, now: number = Date.now()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = fs.readdirSync(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory || !fs.existsSync(candidate)) continue;\n try {\n if (fs.existsSync(lockPathFor(candidate))) continue;\n JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));\n if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;\n fs.rmSync(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport function lockPathFor(storePath: string): string {\n return `${storePath}.lock`;\n}\n\nexport function tempPathFor(storePath: string, pid: number = process.pid): string {\n return `${storePath}.tmp.${pid}`;\n}\n"],"mappings":"6VAMA,MAAa,EAAiB,kBAExB,EAAiB,YACjB,EAAkB,aAMlB,EAAgB,OAGtB,SAAS,EAAI,EAAgB,EAAiC,CAC5D,GAAI,CAMF,IAAM,GAAA,EALSA,EAAAA,aAAAA,CAAa,MAAO,EAAM,CACvC,MACA,SAAU,EACV,MAAO,CAAC,SAAU,OAAQ,QAAQ,CACpC,CACqB,CAAC,CAAC,KAAK,EAC5B,OAAO,EAAQ,OAAS,EAAI,EAAU,IAAA,EACxC,MAAQ,CACN,MACF,CACF,CAEA,SAAS,EAAsB,EAAgC,CAC7D,IAAM,EAAa,EAAI,qBAA0B,KAAK,EAKtD,OAJI,IAAe,IAAmBC,EAAAA,QAAG,QAAQ,EAC7C,GAAY,WAAW,IAAiB,EACnCC,EAAAA,QAAK,KAAKD,EAAAA,QAAG,QAAQ,EAAG,EAAW,MAAM,CAAwB,CAAC,EAEpE,EAAaC,EAAAA,QAAK,QAAQ,CAAU,EAAIA,EAAAA,QAAK,KAAKD,EAAAA,QAAG,QAAQ,EAAG,MAAyB,OAAc,CAChH,CAEA,SAAS,EAAS,EAAc,EAA4B,CAC1D,IAAM,EAAWC,EAAAA,QAAK,SAASA,EAAAA,QAA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gB,EAAY,EAA2B,CACrD,MAAO,GAAG,EAAU,MACtB,CAEA,SAAgB,EAAY,EAAmB,EAAc,QAAQ,IAAa,CAChF,MAAO,GAAG,EAAU,OAAO,GAC7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.d.cts","names":[],"sources":["../../src/store/paths.ts"],"mappings":";cAMa;;iBAyCG,kBAAkB,uBAAuB,MAAK,OAAO;;iBAQrD,iBACd,eACA,MAAK,OAAO,YACZ;;iBAWc,qBAAqB,MAAK,OAAO;;iBAKjC,4BAA4B;UAK3B;EACf;EACA;;;iBAIc,2BAA2B,0BAA0B,eAA8B;;iBAgBnF,gBAAgB,0BAA0B,eAAe,eAA2B;iBA8BpF,YAAY;iBAIZ,YAAY,mBAAmB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.d.mts","names":[],"sources":["../../src/store/paths.ts"],"mappings":";cAMa;;iBAyCG,kBAAkB,uBAAuB,MAAK,OAAO;;iBAQrD,iBACd,eACA,MAAK,OAAO,YACZ;;iBAWc,qBAAqB,MAAK,OAAO;;iBAKjC,4BAA4B;UAK3B;EACf;EACA;;;iBAIc,2BAA2B,0BAA0B,eAA8B;;iBAgBnF,gBAAgB,0BAA0B,eAAe,eAA2B;iBA8BpF,YAAY;iBAIZ,YAAY,mBAAmB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.mjs","names":[],"sources":["../../src/store/paths.ts"],"sourcesContent":["import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from '@agimon-ai/doompi-extension-contracts/child-process';\n\nexport const STORE_PATH_ENV = 'DOOM_TASK_STORE';\n\nconst STORE_DIR_NAME = 'doom-task';\nconst STORE_FILE_NAME = 'tasks.json';\nconst DEFAULT_CONFIG_DIR_NAME = '.pi';\nconst AGENT_DIR_NAME = 'agent';\nconst PI_CODING_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst HOME_ALIAS = '~';\nconst HOME_ALIAS_PREFIX = '~/';\nconst FILE_ENCODING = 'utf8';\nconst NOT_FOUND_ERROR_CODE = 'ENOENT';\n\nfunction git(args: string[], cwd: string): string | undefined {\n try {\n const output = execFileSync('git', args, {\n cwd,\n encoding: FILE_ENCODING,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n const trimmed = output.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveAgentDirectory(env: NodeJS.ProcessEnv): string {\n const configured = env[PI_CODING_AGENT_DIR_ENV]?.trim();\n if (configured === HOME_ALIAS) return os.homedir();\n if (configured?.startsWith(HOME_ALIAS_PREFIX)) {\n return path.join(os.homedir(), configured.slice(HOME_ALIAS_PREFIX.length));\n }\n return configured ? path.resolve(configured) : path.join(os.homedir(), DEFAULT_CONFIG_DIR_NAME, AGENT_DIR_NAME);\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(candidate));\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Resolve the tree root without relying on extension startup order. */\nexport function resolveSessionKey(rootSessionId: string, env: NodeJS.ProcessEnv = process.env): string {\n if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;\n const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();\n if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);\n return parentSessionId;\n}\n\n/** Resolve one root session tree to a task document under the Pi agent directory. */\nexport function resolveStorePath(\n _cwd: string = process.cwd(),\n env: NodeJS.ProcessEnv = process.env,\n sessionKey: string = 'standalone',\n): string {\n const override = env[STORE_PATH_ENV]?.trim();\n if (override) return path.resolve(override);\n\n const trimmedSessionKey = sessionKey.trim();\n if (!trimmedSessionKey) throw new Error('doom-task session id cannot be blank');\n return path.join(resolveAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);\n}\n\n/** Whether a deliberate unscoped task-store override is active. */\nexport function hasStorePathOverride(env: NodeJS.ProcessEnv = process.env): boolean {\n return Boolean(env[STORE_PATH_ENV]?.trim());\n}\n\n/** Exact legacy Git-directory store, if the current working tree has one. */\nexport function resolveLegacyStoreDirectory(cwd: string = process.cwd()): string | undefined {\n const commonDirectory = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport interface StoreSweepResult {\n removed: string[];\n errors: string[];\n}\n\n/** Remove only the validated legacy Git store unless it contains the active override. */\nexport function removeLegacyStoreDirectory(currentStorePath: string, cwd: string = process.cwd()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = resolveLegacyStoreDirectory(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n if (!fs.existsSync(target)) return result;\n fs.rmSync(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n return result;\n}\n\n/** Delete expired sibling session stores while preserving active or unreadable stores. */\nexport function sweepStoreFiles(currentStorePath: string, ttlMs: number, now: number = Date.now()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = fs.readdirSync(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory || !fs.existsSync(candidate)) continue;\n try {\n if (fs.existsSync(lockPathFor(candidate))) continue;\n JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));\n if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;\n fs.rmSync(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport function lockPathFor(storePath: string): string {\n return `${storePath}.lock`;\n}\n\nexport function tempPathFor(storePath: string, pid: number = process.pid): string {\n return `${storePath}.tmp.${pid}`;\n}\n"],"mappings":"mPAMA,MAAa,EAAiB,kBAExB,EAAiB,YACjB,EAAkB,aAMlB,EAAgB,OAGtB,SAAS,EAAI,EAAgB,EAAiC,CAC5D,GAAI,CAMF,IAAM,EALS,EAAa,MAAO,EAAM,CACvC,MACA,SAAU,EACV,MAAO,CAAC,SAAU,OAAQ,QAAQ,CACpC,CACqB,CAAC,CAAC,KAAK,EAC5B,OAAO,EAAQ,OAAS,EAAI,EAAU,IAAA,EACxC,MAAQ,CACN,MACF,CACF,CAEA,SAAS,EAAsB,EAAgC,CAC7D,IAAM,EAAa,EAAI,qBAA0B,KAAK,EAKtD,OAJI,IAAe,IAAmB,EAAG,QAAQ,EAC7C,GAAY,WAAW,IAAiB,EACnC,EAAK,KAAK,EAAG,QAAQ,EAAG,EAAW,MAAM,CAAwB,CAAC,EAEpE,EAAa,EAAK,QAAQ,CAAU,EAAI,EAAK,KAAK,EAAG,QAAQ,EAAG,MAAyB,OAAc,CAChH,CAEA,SAAS,EAAS,EAAc,EAA4B,CAC1D,IAAM,EAAW,EAAK,SAAS,EAAK,QAAQ,CAAI,EAAG,EAAK,QAAQ,CAAS,CAAC,EAC1E,OAAO,IAAa,IAAO,CAAC,EAAS,WAAW,IAAI,GAAK,CAAC,EAAK,WAAW,CAAQ,CACpF,CAGA,SAAgB,EAAkB,EAAuB,EAAyB,QAAQ,IAAa,CACrG,GAAI,CAAC,EAAI,GAAqB,OAAO,EACrC,IAAM,EAAkB,EAAI,EAA4B,EAA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,CAAE,QAAS,CAAC,EAAG,OAAQ,CAAC,CAAE,EACrD,EAA0B,EAAK,QAAQ,CAAgB,EACvD,EAAiB,EAAK,QAAQ,CAAuB,EACvD,EACJ,GAAI,CACF,EAAU,EAAG,YAAY,CAAc,CACzC,OAAS,EAAO,CAGd,OAFK,EAAgC,OAAS,UAC9C,EAAO,OAAO,KAAK,uCAAuC,EAAe,IAAI,OAAO,CAAK,GAAG,EADjB,CAG7E,CAEA,IAAK,IAAM,KAAS,EAAS,CAC3B,IAAM,EAAmB,EAAK,KAAK,EAAgB,CAAK,EAClD,EAAY,EAAK,KAAK,EAAkB,CAAe,EACzD,SAAqB,GAA2B,CAAC,EAAG,WAAW,CAAS,GAC5E,GAAI,CAGF,GAFI,EAAG,WAAW,EAAY,CAAS,CAAC,IACxC,KAAK,MAAM,EAAG,aAAa,EAAW,CAAa,CAAC,EAChD,EAAM,EAAG,SAAS,CAAS,CAAC,CAAC,SAAW,GAAO,SACnD,EAAG,OAAO,EAAkB,CAAE,UAAW,GAAM,MAAO,EAAK,CAAC,EAC5D,EAAO,QAAQ,KAAK,CAAgB,CACtC,OAAS,EAAO,CACd,EAAO,OAAO,KAAK,8BAA8B,EAAU,IAAI,OAAO,CAAK,GAAG,CAChF,CACF,CACA,OAAO,CACT,CAEA,SAAgB,EAAY,EAA2B,CACrD,MAAO,GAAG,EAAU,MACtB,CAEA,SAAgB,EAAY,EAAmB,EAAc,QAAQ,IAAa,CAChF,MAAO,GAAG,EAAU,OAAO,GAC7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"processLiveness.cjs","names":[],"sources":["../../src/store/processLiveness.ts"],"sourcesContent":["/**\n * Is a process still running?\n *\n * Signal 0 performs the permission and existence check without delivering a\n * signal. EPERM means the process exists but belongs to another user, which\n * still counts as alive.\n */\nexport function isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === 'EPERM';\n }\n}\n"],"mappings":"mEAOA,SAAgB,EAAe,EAAsB,CACnD,GAAI,CAEF,OADA,QAAQ,KAAK,EAAK,CAAC,EACZ,EACT,OAAS,EAAO,CACd,OAAQ,EAAgC,OAAS,OACnD,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"processLiveness.d.cts","names":[],"sources":["../../src/store/processLiveness.ts"],"mappings":";;;;;;;;iBAOgB,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"processLiveness.d.mts","names":[],"sources":["../../src/store/processLiveness.ts"],"mappings":";;;;;;;;iBAOgB,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"processLiveness.mjs","names":[],"sources":["../../src/store/processLiveness.ts"],"sourcesContent":["/**\n * Is a process still running?\n *\n * Signal 0 performs the permission and existence check without delivering a\n * signal. EPERM means the process exists but belongs to another user, which\n * still counts as alive.\n */\nexport function isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === 'EPERM';\n }\n}\n"],"mappings":"AAOA,SAAgB,EAAe,EAAsB,CACnD,GAAI,CAEF,OADA,QAAQ,KAAK,EAAK,CAAC,EACZ,EACT,OAAS,EAAO,CACd,OAAQ,EAAgC,OAAS,OACnD,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile.cjs","names":["isProcessAlive","isDelegationActive"],"sources":["../../src/store/reconcile.ts"],"sourcesContent":["import { isProcessAlive } from './processLiveness.ts';\nimport { isDelegationActive, type Task, type TaskDocument } from './types.ts';\n\nexport const ERR_ORPHANED_BY_RESTART = 'Delegation orphaned by harness restart';\nexport const ERR_ORPHANED_BY_SESSION = 'Delegation orphaned by session restart';\n\nexport interface ReconcileResult {\n document: TaskDocument;\n orphaned: Task[];\n}\n\n/** The delegations this process can still settle, used to spot its own leftovers. */\nexport interface ReconcileSelf {\n pid: number;\n liveRequestIds: ReadonlySet<string>;\n}\n\n/**\n * Recover tasks that no longer have anyone able to finish them.\n *\n * A subagent run dies with the harness that spawned it, but the store file\n * outlives both, so a crash leaves tasks stuck in `in_progress` forever. Two\n * kinds of delegation qualify as dead:\n *\n * - the owning pid is gone, so nothing is left to report a result;\n * - the owning pid is *this* process, yet the request is absent from the live\n * set. Settling requires an in-memory record, so an in-process session\n * restart (which clears that map without writing to the store) leaves rows\n * nothing can ever resolve. Checking pid liveness alone misses these, because\n * the pid is our own and very much alive.\n *\n * Delegations owned by a different, still-running pid belong to a parallel\n * session and are left untouched.\n */\nexport function reconcileOrphanedDelegations(\n document: TaskDocument,\n now: string = new Date().toISOString(),\n isAlive: (pid: number) => boolean = isProcessAlive,\n self?: ReconcileSelf,\n): ReconcileResult {\n const orphaned: Task[] = [];\n\n const tasks = document.tasks.map((task) => {\n if (!isDelegationActive(task)) return task;\n const pid = task.delegation?.pid;\n if (pid === undefined) return task;\n\n const ownedByThisSession = self !== undefined && pid === self.pid;\n const abandonedHere = ownedByThisSession && !self.liveRequestIds.has(task.delegation!.requestId);\n if (!abandonedHere && isAlive(pid)) return task;\n\n const recovered: Task = {\n ...task,\n status: 'pending',\n updatedAt: now,\n delegation: {\n ...task.delegation!,\n state: 'failed',\n endedAt: now,\n result: {\n status: 'failed',\n error: abandonedHere ? ERR_ORPHANED_BY_SESSION : ERR_ORPHANED_BY_RESTART,\n },\n },\n };\n orphaned.push(recovered);\n return recovered;\n });\n\n if (orphaned.length === 0) return { document, orphaned };\n return { document: { ...document, tasks }, orphaned };\n}\n"],"mappings":"qIAGa,EAA0B,yCAC1B,EAA0B,yCA8BvC,SAAgB,EACd,EACA,EAAc,IAAI,KAAK,CAAA,CAAE,YAAY,EACrC,EAAoCA,EAAAA,eACpC,EACiB,CACjB,IAAM,EAAmB,CAAC,EAEpB,EAAQ,EAAS,MAAM,IAAK,GAAS,CACzC,GAAI,CAACC,EAAAA,mBAAmB,CAAI,EAAG,OAAO,EACtC,IAAM,EAAM,EAAK,YAAY,IAC7B,GAAI,IAAQ,IAAA,GAAW,OAAO,EAG9B,IAAM,EADqB,IAAS,IAAA,IAAa,IAAQ,EAAK,KAClB,CAAC,EAAK,eAAe,IAAI,EAAK,WAAY,SAAS,EAC/F,GAAI,CAAC,GAAiB,EAAQ,CAAG,EAAG,OAAO,EAE3C,IAAM,EAAkB,CACtB,GAAG,EACH,OAAQ,UACR,UAAW,EACX,WAAY,CACV,GAAG,EAAK,WACR,MAAO,SACP,QAAS,EACT,OAAQ,CACN,OAAQ,SACR,MAAO,EAAgB,EAA0B,CACnD,CACF,CACF,EAEA,OADA,EAAS,KAAK,CAAS,EAChB,CACT,CAAC,EAGD,OADI,EAAS,SAAW,EAAU,CAAE,WAAU,UAAS,EAChD,CAAE,SAAU,CAAE,GAAG,EAAU,OAAM,EAAG,UAAS,CACtD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile.d.cts","names":[],"sources":["../../src/store/reconcile.ts"],"mappings":";;cAGa;cACA;UAEI;EACf,UAAU;EACV,UAAU;;;UAIK;EACf;EACA,gBAAgB;;;;;;;;;;;;;;;;;;;iBAoBF,6BACd,UAAU,cACV,cACA,WAAU,yBACV,OAAO,gBACN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile.d.mts","names":[],"sources":["../../src/store/reconcile.ts"],"mappings":";;cAGa;cACA;UAEI;EACf,UAAU;EACV,UAAU;;;UAIK;EACf;EACA,gBAAgB;;;;;;;;;;;;;;;;;;;iBAoBF,6BACd,UAAU,cACV,cACA,WAAU,yBACV,OAAO,gBACN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile.mjs","names":[],"sources":["../../src/store/reconcile.ts"],"sourcesContent":["import { isProcessAlive } from './processLiveness.ts';\nimport { isDelegationActive, type Task, type TaskDocument } from './types.ts';\n\nexport const ERR_ORPHANED_BY_RESTART = 'Delegation orphaned by harness restart';\nexport const ERR_ORPHANED_BY_SESSION = 'Delegation orphaned by session restart';\n\nexport interface ReconcileResult {\n document: TaskDocument;\n orphaned: Task[];\n}\n\n/** The delegations this process can still settle, used to spot its own leftovers. */\nexport interface ReconcileSelf {\n pid: number;\n liveRequestIds: ReadonlySet<string>;\n}\n\n/**\n * Recover tasks that no longer have anyone able to finish them.\n *\n * A subagent run dies with the harness that spawned it, but the store file\n * outlives both, so a crash leaves tasks stuck in `in_progress` forever. Two\n * kinds of delegation qualify as dead:\n *\n * - the owning pid is gone, so nothing is left to report a result;\n * - the owning pid is *this* process, yet the request is absent from the live\n * set. Settling requires an in-memory record, so an in-process session\n * restart (which clears that map without writing to the store) leaves rows\n * nothing can ever resolve. Checking pid liveness alone misses these, because\n * the pid is our own and very much alive.\n *\n * Delegations owned by a different, still-running pid belong to a parallel\n * session and are left untouched.\n */\nexport function reconcileOrphanedDelegations(\n document: TaskDocument,\n now: string = new Date().toISOString(),\n isAlive: (pid: number) => boolean = isProcessAlive,\n self?: ReconcileSelf,\n): ReconcileResult {\n const orphaned: Task[] = [];\n\n const tasks = document.tasks.map((task) => {\n if (!isDelegationActive(task)) return task;\n const pid = task.delegation?.pid;\n if (pid === undefined) return task;\n\n const ownedByThisSession = self !== undefined && pid === self.pid;\n const abandonedHere = ownedByThisSession && !self.liveRequestIds.has(task.delegation!.requestId);\n if (!abandonedHere && isAlive(pid)) return task;\n\n const recovered: Task = {\n ...task,\n status: 'pending',\n updatedAt: now,\n delegation: {\n ...task.delegation!,\n state: 'failed',\n endedAt: now,\n result: {\n status: 'failed',\n error: abandonedHere ? ERR_ORPHANED_BY_SESSION : ERR_ORPHANED_BY_RESTART,\n },\n },\n };\n orphaned.push(recovered);\n return recovered;\n });\n\n if (orphaned.length === 0) return { document, orphaned };\n return { document: { ...document, tasks }, orphaned };\n}\n"],"mappings":"wGAGA,MAAa,EAA0B,yCAC1B,EAA0B,yCA8BvC,SAAgB,EACd,EACA,EAAc,IAAI,KAAK,CAAA,CAAE,YAAY,EACrC,EAAoC,EACpC,EACiB,CACjB,IAAM,EAAmB,CAAC,EAEpB,EAAQ,EAAS,MAAM,IAAK,GAAS,CACzC,GAAI,CAAC,EAAmB,CAAI,EAAG,OAAO,EACtC,IAAM,EAAM,EAAK,YAAY,IAC7B,GAAI,IAAQ,IAAA,GAAW,OAAO,EAG9B,IAAM,EADqB,IAAS,IAAA,IAAa,IAAQ,EAAK,KAClB,CAAC,EAAK,eAAe,IAAI,EAAK,WAAY,SAAS,EAC/F,GAAI,CAAC,GAAiB,EAAQ,CAAG,EAAG,OAAO,EAE3C,IAAM,EAAkB,CACtB,GAAG,EACH,OAAQ,UACR,UAAW,EACX,WAAY,CACV,GAAG,EAAK,WACR,MAAO,SACP,QAAS,EACT,OAAQ,CACN,OAAQ,SACR,MAAO,EAAgB,EAA0B,CACnD,CACF,CACF,EAEA,OADA,EAAS,KAAK,CAAS,EAChB,CACT,CAAC,EAGD,OADI,EAAS,SAAW,EAAU,CAAE,WAAU,UAAS,EAChD,CAAE,SAAU,CAAE,GAAG,EAAU,OAAM,EAAG,UAAS,CACtD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.cjs","names":["isTransitionValid","detectCycle","isDelegationActive","DELETED_STATUS"],"sources":["../../src/store/reducer.ts"],"sourcesContent":["import { isTransitionValid } from './invariants.ts';\nimport { detectCycle } from './taskGraph.ts';\nimport {\n DELETED_STATUS,\n type DepToken,\n isDelegationActive,\n type Task,\n type TaskAction,\n type TaskDocument,\n type TaskItemMutation,\n type TaskMutationParams,\n type TaskStatus,\n type UpsertItemOutcome,\n} from './types.ts';\n\n/** Bounds the work one call can do, and with it the size of one committed write. */\nexport const MAX_UPSERT_ITEMS = 100;\n\n/**\n * A ref must start with a letter, which makes it structurally unconfusable with\n * a stringified id. That is why resolving a dependency token is just a `typeof`\n * check with no coercion heuristics.\n */\nexport const REF_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,31}$/;\n\n/**\n * Reducer outcome. Closed tagged union: adding an action requires extending\n * this union and the response formatter, which the compiler enforces.\n *\n * `upsert` carries one outcome per request item. It is returned even when every\n * item failed — `error` is reserved for whole-call faults — so the tool layer\n * still has the per-item messages to report.\n */\nexport type Op =\n | { kind: 'upsert'; items: UpsertItemOutcome[]; applied: number; failed: number }\n | { kind: 'delete'; id: number; subject: string }\n | { kind: 'list'; statusFilter?: TaskStatus; includeDeleted: boolean }\n | { kind: 'get'; task: Task }\n | { kind: 'clear'; count: number }\n | { kind: 'error'; message: string };\n\nexport interface ApplyResult {\n document: TaskDocument;\n op: Op;\n}\n\n/** Actions the reducer owns. `assign`/`cancel` are handled by the delegation manager. */\nexport type ReducerAction = Exclude<TaskAction, 'assign' | 'cancel'>;\n\n/**\n * Does this op represent state that must reach disk?\n *\n * The exhaustive switch is the point: a future `Op` variant cannot be added\n * without declaring its persistence intent, so nothing silently starts or stops\n * bumping `rev`.\n */\nexport function isCommittingOp(op: Op): boolean {\n switch (op.kind) {\n case 'error':\n case 'list':\n case 'get':\n return false;\n case 'upsert':\n return op.items.some((item) => item.kind === 'created' || item.kind === 'updated');\n case 'delete':\n case 'clear':\n return true;\n }\n}\n\n/** Joined per-item failures, for the thrown error when an upsert applied nothing. */\nexport function formatUpsertFailure(op: Extract<Op, { kind: 'upsert' }>): string {\n return op.items\n .filter((item) => item.kind === 'failed')\n .map((item) => `item[${item.index}]: ${item.message}`)\n .join('\\n');\n}\n\n/** The single item's outcome, for callers that only ever send a batch of one. */\nexport function singleItemOutcome(op: Op): UpsertItemOutcome | undefined {\n return op.kind === 'upsert' ? op.items[0] : undefined;\n}\n\nfunction errorResult(document: TaskDocument, message: string): ApplyResult {\n return { document, op: { kind: 'error', message } };\n}\n\nfunction sameNumberList(a: number[] | undefined, b: number[] | undefined): boolean {\n const x = a ?? [];\n const y = b ?? [];\n return x.length === y.length && x.every((value, index) => value === y[index]);\n}\n\nfunction sameRecord(a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): boolean {\n return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);\n}\n\n/**\n * Did this update change anything? A no-effect update (status re-set to its\n * current value, fields re-sent unchanged) reports \"No change\" rather than\n * \"Updated #N\" — without the distinction a model can loop re-issuing the same\n * call believing it never landed.\n */\nfunction taskChanged(before: Task, after: Task): boolean {\n return (\n before.subject !== after.subject ||\n before.status !== after.status ||\n before.description !== after.description ||\n before.activeForm !== after.activeForm ||\n before.owner !== after.owner ||\n !sameNumberList(before.blockedBy, after.blockedBy) ||\n !sameRecord(before.metadata, after.metadata)\n );\n}\n\nfunction withTasks(document: TaskDocument, tasks: Task[], nextId = document.nextId): TaskDocument {\n return { ...document, tasks, nextId };\n}\n\n/** Merge incoming metadata over a base; a `null` value deletes its key. */\nfunction mergeMetadata(\n base: Record<string, unknown> | undefined,\n incoming: Record<string, unknown>,\n): Record<string, unknown> | undefined {\n const merged: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(incoming)) {\n if (value === null) delete merged[key];\n else merged[key] = value;\n }\n return Object.keys(merged).length ? merged : undefined;\n}\n\n/** Copy the optional scalar fields an item may set onto a task, in place. */\nfunction assignScalars(target: Task, item: TaskItemMutation): void {\n if (item.subject !== undefined) target.subject = item.subject;\n if (item.description !== undefined) target.description = item.description;\n if (item.activeForm !== undefined) target.activeForm = item.activeForm;\n if (item.owner !== undefined) target.owner = item.owner;\n if (item.metadata !== undefined) {\n const merged = mergeMetadata(target.metadata, item.metadata);\n if (merged === undefined) delete target.metadata;\n else target.metadata = merged;\n }\n}\n\n/**\n * Working state threaded item to item, so entry N observes every effect of\n * entries 1..N-1. `refIds` and `failedRefs` are what make the cascade work:\n * refs resolve backward only, so an entry that names a failed sibling is always\n * processed after the failure that killed it.\n */\ninterface UpsertContext {\n tasks: Task[];\n nextId: number;\n refIds: Map<string, number>;\n failedRefs: Map<string, number>;\n}\n\ntype Resolved = { ok: true; id: number } | { ok: false; message: string };\n\nfunction resolveDep(context: UpsertContext, field: string, token: DepToken): Resolved {\n if (typeof token === 'number') return { ok: true, id: token };\n if (!REF_PATTERN.test(token)) {\n return { ok: false, message: `${field}: \"${token}\" is not a valid ref; pass an existing task id as a number` };\n }\n const id = context.refIds.get(token);\n if (id !== undefined) return { ok: true, id };\n const failedAt = context.failedRefs.get(token);\n if (failedAt !== undefined) {\n return { ok: false, message: `${field}: ref \"${token}\" refers to item[${failedAt}], which failed` };\n }\n return {\n ok: false,\n message: `${field}: unknown ref \"${token}\" — a ref must be declared by an earlier entry in the same call`,\n };\n}\n\ntype ItemResult = { ok: true; outcome: UpsertItemOutcome } | { ok: false; message: string };\n\nfunction fail(message: string): ItemResult {\n return { ok: false, message };\n}\n\n/** Structural checks that apply to every entry, whichever kind it is. */\nfunction checkShape(context: UpsertContext, item: TaskItemMutation): string | undefined {\n if (item.ref !== undefined) {\n if (item.id !== undefined) return 'ref is only valid when creating a task; drop the id, or drop the ref';\n if (!REF_PATTERN.test(item.ref)) {\n return `ref \"${item.ref}\" is invalid: a ref must start with a letter and contain only letters, digits, - or _`;\n }\n const owner = context.refIds.get(item.ref) !== undefined || context.failedRefs.has(item.ref);\n if (owner) return `duplicate ref \"${item.ref}\": it was already declared by an earlier entry`;\n }\n return undefined;\n}\n\nfunction applyCreateItem(context: UpsertContext, item: TaskItemMutation, index: number, now: string): ItemResult {\n if (item.subject === undefined) return fail('subject is required when the entry has no id');\n if (!item.subject.trim()) return fail('subject must not be blank');\n if (item.addBlockedBy !== undefined || item.removeBlockedBy !== undefined) {\n return fail('addBlockedBy / removeBlockedBy are only for an entry with an id; a new task uses blockedBy');\n }\n // A task created as a tombstone is invisible to every view and can never\n // leave `deleted`, so it would be a write-only black hole.\n if (item.status === DELETED_STATUS) {\n return fail('cannot create a task with status deleted; create it, then use action delete');\n }\n\n const blockedBy: number[] = [];\n for (const token of item.blockedBy ?? []) {\n const resolved = resolveDep(context, 'blockedBy', token);\n if (!resolved.ok) return fail(resolved.message);\n const dep = context.tasks.find((task) => task.id === resolved.id);\n if (!dep) return fail(`blockedBy: #${resolved.id} not found`);\n if (dep.status === DELETED_STATUS) return fail(`blockedBy: #${resolved.id} is deleted`);\n if (!blockedBy.includes(resolved.id)) blockedBy.push(resolved.id);\n }\n\n // No cycle check is needed: the id is freshly allocated, so nothing already\n // in the document can point at it yet.\n const created: Task = {\n id: context.nextId,\n subject: item.subject,\n status: item.status ?? 'pending',\n createdAt: now,\n updatedAt: now,\n };\n assignScalars(created, item);\n if (blockedBy.length) created.blockedBy = blockedBy;\n\n context.nextId += 1;\n context.tasks.push(created);\n if (item.ref) context.refIds.set(item.ref, created.id);\n\n return {\n ok: true,\n outcome: {\n index,\n kind: 'created',\n id: created.id,\n subject: created.subject,\n status: created.status,\n ...(item.ref ? { ref: item.ref } : {}),\n ...(blockedBy.length ? { blockedBy } : {}),\n },\n };\n}\n\nfunction applyUpdateItem(context: UpsertContext, item: TaskItemMutation, index: number, now: string): ItemResult {\n const id = item.id as number;\n const at = context.tasks.findIndex((task) => task.id === id);\n if (at === -1) return fail(`#${id} not found`);\n if (item.blockedBy !== undefined) {\n return fail('blockedBy is only for a new entry; use addBlockedBy / removeBlockedBy on an entry that has an id');\n }\n\n const hasMutation =\n item.subject !== undefined ||\n item.description !== undefined ||\n item.activeForm !== undefined ||\n item.status !== undefined ||\n item.owner !== undefined ||\n item.metadata !== undefined ||\n Boolean(item.addBlockedBy?.length) ||\n Boolean(item.removeBlockedBy?.length);\n if (!hasMutation) {\n return fail(\n 'nothing to change: provide at least one of subject, description, activeForm, status, owner, metadata, addBlockedBy, or removeBlockedBy',\n );\n }\n\n const current = context.tasks[at];\n\n // The Task Space overlay commits free text from an inline editor, so a blank\n // subject reaches the reducer as a real update rather than as a missing\n // field. Persisting it would leave an unidentifiable row.\n if (item.subject !== undefined && !item.subject.trim()) return fail('subject must not be blank');\n\n let newStatus = current.status;\n if (item.status !== undefined) {\n if (!isTransitionValid(current.status, item.status)) {\n return fail(`illegal transition ${current.status} -> ${item.status}`);\n }\n newStatus = item.status;\n }\n\n let newBlockedBy = current.blockedBy ? [...current.blockedBy] : [];\n for (const token of item.removeBlockedBy ?? []) {\n const resolved = resolveDep(context, 'removeBlockedBy', token);\n if (!resolved.ok) return fail(resolved.message);\n // Removing an id that is not there is a well-defined no-op, so unlike the\n // add path this deliberately skips the existence check.\n newBlockedBy = newBlockedBy.filter((dep) => dep !== resolved.id);\n }\n for (const token of item.addBlockedBy ?? []) {\n const resolved = resolveDep(context, 'addBlockedBy', token);\n if (!resolved.ok) return fail(resolved.message);\n if (resolved.id === id) return fail(`cannot block #${id} on itself`);\n const dep = context.tasks.find((task) => task.id === resolved.id);\n if (!dep) return fail(`addBlockedBy: #${resolved.id} not found`);\n if (dep.status === DELETED_STATUS) return fail(`addBlockedBy: #${resolved.id} is deleted`);\n if (!newBlockedBy.includes(resolved.id)) newBlockedBy.push(resolved.id);\n }\n\n const updated: Task = { ...current, status: newStatus };\n assignScalars(updated, item);\n if (newBlockedBy.length) updated.blockedBy = newBlockedBy;\n else delete updated.blockedBy;\n\n // The candidate is written before the check because `detectCycle` unions the\n // node's stored edges with the ones passed in: checking against the old array\n // would resurrect an edge `removeBlockedBy` just stripped and reject a\n // remove+add that legitimately breaks a cycle.\n const candidate = [...context.tasks];\n candidate[at] = updated;\n if (item.addBlockedBy?.length && detectCycle(candidate, id, newBlockedBy)) {\n return fail('addBlockedBy would create a cycle in the blockedBy graph');\n }\n\n const changed = taskChanged(current, updated);\n if (changed) updated.updatedAt = now;\n context.tasks = candidate;\n\n return {\n ok: true,\n outcome: changed\n ? { index, kind: 'updated', id, fromStatus: current.status, toStatus: newStatus }\n : { index, kind: 'unchanged', id, status: newStatus },\n };\n}\n\n/**\n * Apply every entry in request order, threading the document.\n *\n * Each entry lands completely or not at all: a create whose dependencies fail\n * is not kept dependency-free, because handing back an unblocked task the\n * caller asked to be blocked is a lie it may immediately act on.\n */\nfunction applyUpsert(document: TaskDocument, items: TaskItemMutation[], now: string): ApplyResult {\n const context: UpsertContext = {\n tasks: [...document.tasks],\n nextId: document.nextId,\n refIds: new Map(),\n failedRefs: new Map(),\n };\n const outcomes: UpsertItemOutcome[] = [];\n let applied = 0;\n\n for (const [index, item] of items.entries()) {\n const shapeError = checkShape(context, item);\n const result = shapeError\n ? fail(shapeError)\n : item.id === undefined\n ? applyCreateItem(context, item, index, now)\n : applyUpdateItem(context, item, index, now);\n\n if (result.ok) {\n outcomes.push(result.outcome);\n applied += 1;\n continue;\n }\n // A ref whose owner failed must not read as a typo to the entries that\n // depend on it, so the dead ref is recorded rather than left unknown.\n if (item.ref && REF_PATTERN.test(item.ref) && !context.refIds.has(item.ref)) {\n context.failedRefs.set(item.ref, index);\n }\n outcomes.push({\n index,\n kind: 'failed',\n message: result.message,\n ...(item.id === undefined ? {} : { id: item.id }),\n ...(item.ref ? { ref: item.ref } : {}),\n });\n }\n\n return {\n // Nothing applied means nothing to write: returning the original object by\n // reference keeps the caller's write-skip path identical to a hard error.\n document: applied > 0 ? withTasks(document, context.tasks, context.nextId) : document,\n op: { kind: 'upsert', items: outcomes, applied, failed: outcomes.length - applied },\n };\n}\n\n/**\n * Pure reducer: (document, action, params) -> (document, op).\n *\n * All validation is in-line: structural guards plus state-aware checks\n * (transition legality, dangling or deleted blockedBy, self-block, cycles,\n * in-flight delegations). The caller owns persistence and formatting.\n */\nexport function applyTaskMutation(\n document: TaskDocument,\n action: ReducerAction,\n params: TaskMutationParams,\n now: string = new Date().toISOString(),\n): ApplyResult {\n switch (action) {\n case 'upsert': {\n const items = params.tasks;\n if (!Array.isArray(items) || items.length === 0) {\n return errorResult(\n document,\n 'upsert requires a non-empty tasks array, e.g. {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Write tests\"}]}',\n );\n }\n if (items.length > MAX_UPSERT_ITEMS) {\n return errorResult(\n document,\n `upsert accepts at most ${MAX_UPSERT_ITEMS} entries per call (received ${items.length})`,\n );\n }\n return applyUpsert(document, items, now);\n }\n\n case 'list': {\n return {\n document,\n op: {\n kind: 'list',\n includeDeleted: params.includeDeleted === true,\n ...(params.status !== undefined ? { statusFilter: params.status } : {}),\n },\n };\n }\n\n case 'get': {\n if (params.id === undefined) return errorResult(document, 'id required for get');\n const task = document.tasks.find((candidate) => candidate.id === params.id);\n if (!task) return errorResult(document, `#${params.id} not found`);\n return { document, op: { kind: 'get', task } };\n }\n\n case 'delete': {\n if (params.id === undefined) return errorResult(document, 'id required for delete');\n const index = document.tasks.findIndex((task) => task.id === params.id);\n if (index === -1) return errorResult(document, `#${params.id} not found`);\n const current = document.tasks[index];\n if (current.status === DELETED_STATUS) return errorResult(document, `#${current.id} is already deleted`);\n if (isDelegationActive(current)) {\n return errorResult(document, `#${current.id} has a running delegation — cancel it before deleting`);\n }\n\n const tasks = [...document.tasks];\n tasks[index] = { ...current, status: DELETED_STATUS, updatedAt: now };\n return {\n document: withTasks(document, tasks),\n op: { kind: 'delete', id: current.id, subject: current.subject },\n };\n }\n\n case 'clear': {\n const active = document.tasks.filter(isDelegationActive);\n if (active.length > 0) {\n const ids = active.map((task) => `#${task.id}`).join(', ');\n return errorResult(document, `cannot clear while delegations are running (${ids}) — cancel them first`);\n }\n const count = document.tasks.length;\n return {\n document: withTasks(document, [], 1),\n op: { kind: 'clear', count },\n };\n }\n }\n}\n"],"mappings":"6JAuBa,EAAc,gCAiC3B,SAAgB,EAAe,EAAiB,CAC9C,OAAQ,EAAG,KAAX,CACE,IAAK,QACL,IAAK,OACL,IAAK,MACH,MAAO,GACT,IAAK,SACH,OAAO,EAAG,MAAM,KAAM,GAAS,EAAK,OAAS,WAAa,EAAK,OAAS,SAAS,EACnF,IAAK,SACL,IAAK,QACH,MAAO,EACX,CACF,CAGA,SAAgB,EAAoB,EAA6C,CAC/E,OAAO,EAAG,MACP,OAAQ,GAAS,EAAK,OAAS,QAAQ,CAAC,CACxC,IAAK,GAAS,QAAQ,EAAK,MAAM,KAAK,EAAK,SAAS,CAAC,CACrD,KAAK;CAAI,CACd,CAGA,SAAgB,EAAkB,EAAuC,CACvE,OAAO,EAAG,OAAS,SAAW,EAAG,MAAM,GAAK,IAAA,EAC9C,CAEA,SAAS,EAAY,EAAwB,EAA8B,CACzE,MAAO,CAAE,WAAU,GAAI,CAAE,KAAM,QAAS,SAAQ,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;;iBAuT3B,kBACd,UAAU,cACV,QAAQ,eACR,QAAQ,oBACR,eACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.d.mts","names":[],"sources":["../../src/store/reducer.ts"],"mappings":";;;cAgBa;;;;;;cAOA,aAAW;;;;;;;;;KAUZ;EACN;EAAgB,OAAO;EAAqB;EAAiB;;EAC7D;EAAgB;EAAY;;EAC5B;EAAc,eAAe;EAAY;;EACzC;EAAa,MAAM;;EACnB;EAAe;;EACf;EAAe;;UAEJ;EACf,UAAU;EACV,IAAI;;;KAIM,gBAAgB,QAAQ;;;;;;;;iBASpB,eAAe,IAAI;;iBAenB,oBAAoB,IAAI,QAAQ;EAAM;;;iBAQtC,kBAAkB,IAAI,KAAK;;;;;;;;iBAuT3B,kBACd,UAAU,cACV,QAAQ,eACR,QAAQ,oBACR,eACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.mjs","names":[],"sources":["../../src/store/reducer.ts"],"sourcesContent":["import { isTransitionValid } from './invariants.ts';\nimport { detectCycle } from './taskGraph.ts';\nimport {\n DELETED_STATUS,\n type DepToken,\n isDelegationActive,\n type Task,\n type TaskAction,\n type TaskDocument,\n type TaskItemMutation,\n type TaskMutationParams,\n type TaskStatus,\n type UpsertItemOutcome,\n} from './types.ts';\n\n/** Bounds the work one call can do, and with it the size of one committed write. */\nexport const MAX_UPSERT_ITEMS = 100;\n\n/**\n * A ref must start with a letter, which makes it structurally unconfusable with\n * a stringified id. That is why resolving a dependency token is just a `typeof`\n * check with no coercion heuristics.\n */\nexport const REF_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,31}$/;\n\n/**\n * Reducer outcome. Closed tagged union: adding an action requires extending\n * this union and the response formatter, which the compiler enforces.\n *\n * `upsert` carries one outcome per request item. It is returned even when every\n * item failed — `error` is reserved for whole-call faults — so the tool layer\n * still has the per-item messages to report.\n */\nexport type Op =\n | { kind: 'upsert'; items: UpsertItemOutcome[]; applied: number; failed: number }\n | { kind: 'delete'; id: number; subject: string }\n | { kind: 'list'; statusFilter?: TaskStatus; includeDeleted: boolean }\n | { kind: 'get'; task: Task }\n | { kind: 'clear'; count: number }\n | { kind: 'error'; message: string };\n\nexport interface ApplyResult {\n document: TaskDocument;\n op: Op;\n}\n\n/** Actions the reducer owns. `assign`/`cancel` are handled by the delegation manager. */\nexport type ReducerAction = Exclude<TaskAction, 'assign' | 'cancel'>;\n\n/**\n * Does this op represent state that must reach disk?\n *\n * The exhaustive switch is the point: a future `Op` variant cannot be added\n * without declaring its persistence intent, so nothing silently starts or stops\n * bumping `rev`.\n */\nexport function isCommittingOp(op: Op): boolean {\n switch (op.kind) {\n case 'error':\n case 'list':\n case 'get':\n return false;\n case 'upsert':\n return op.items.some((item) => item.kind === 'created' || item.kind === 'updated');\n case 'delete':\n case 'clear':\n return true;\n }\n}\n\n/** Joined per-item failures, for the thrown error when an upsert applied nothing. */\nexport function formatUpsertFailure(op: Extract<Op, { kind: 'upsert' }>): string {\n return op.items\n .filter((item) => item.kind === 'failed')\n .map((item) => `item[${item.index}]: ${item.message}`)\n .join('\\n');\n}\n\n/** The single item's outcome, for callers that only ever send a batch of one. */\nexport function singleItemOutcome(op: Op): UpsertItemOutcome | undefined {\n return op.kind === 'upsert' ? op.items[0] : undefined;\n}\n\nfunction errorResult(document: TaskDocument, message: string): ApplyResult {\n return { document, op: { kind: 'error', message } };\n}\n\nfunction sameNumberList(a: number[] | undefined, b: number[] | undefined): boolean {\n const x = a ?? [];\n const y = b ?? [];\n return x.length === y.length && x.every((value, index) => value === y[index]);\n}\n\nfunction sameRecord(a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): boolean {\n return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);\n}\n\n/**\n * Did this update change anything? A no-effect update (status re-set to its\n * current value, fields re-sent unchanged) reports \"No change\" rather than\n * \"Updated #N\" — without the distinction a model can loop re-issuing the same\n * call believing it never landed.\n */\nfunction taskChanged(before: Task, after: Task): boolean {\n return (\n before.subject !== after.subject ||\n before.status !== after.status ||\n before.description !== after.description ||\n before.activeForm !== after.activeForm ||\n before.owner !== after.owner ||\n !sameNumberList(before.blockedBy, after.blockedBy) ||\n !sameRecord(before.metadata, after.metadata)\n );\n}\n\nfunction withTasks(document: TaskDocument, tasks: Task[], nextId = document.nextId): TaskDocument {\n return { ...document, tasks, nextId };\n}\n\n/** Merge incoming metadata over a base; a `null` value deletes its key. */\nfunction mergeMetadata(\n base: Record<string, unknown> | undefined,\n incoming: Record<string, unknown>,\n): Record<string, unknown> | undefined {\n const merged: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(incoming)) {\n if (value === null) delete merged[key];\n else merged[key] = value;\n }\n return Object.keys(merged).length ? merged : undefined;\n}\n\n/** Copy the optional scalar fields an item may set onto a task, in place. */\nfunction assignScalars(target: Task, item: TaskItemMutation): void {\n if (item.subject !== undefined) target.subject = item.subject;\n if (item.description !== undefined) target.description = item.description;\n if (item.activeForm !== undefined) target.activeForm = item.activeForm;\n if (item.owner !== undefined) target.owner = item.owner;\n if (item.metadata !== undefined) {\n const merged = mergeMetadata(target.metadata, item.metadata);\n if (merged === undefined) delete target.metadata;\n else target.metadata = merged;\n }\n}\n\n/**\n * Working state threaded item to item, so entry N observes every effect of\n * entries 1..N-1. `refIds` and `failedRefs` are what make the cascade work:\n * refs resolve backward only, so an entry that names a failed sibling is always\n * processed after the failure that killed it.\n */\ninterface UpsertContext {\n tasks: Task[];\n nextId: number;\n refIds: Map<string, number>;\n failedRefs: Map<string, number>;\n}\n\ntype Resolved = { ok: true; id: number } | { ok: false; message: string };\n\nfunction resolveDep(context: UpsertContext, field: string, token: DepToken): Resolved {\n if (typeof token === 'number') return { ok: true, id: token };\n if (!REF_PATTERN.test(token)) {\n return { ok: false, message: `${field}: \"${token}\" is not a valid ref; pass an existing task id as a number` };\n }\n const id = context.refIds.get(token);\n if (id !== undefined) return { ok: true, id };\n const failedAt = context.failedRefs.get(token);\n if (failedAt !== undefined) {\n return { ok: false, message: `${field}: ref \"${token}\" refers to item[${failedAt}], which failed` };\n }\n return {\n ok: false,\n message: `${field}: unknown ref \"${token}\" — a ref must be declared by an earlier entry in the same call`,\n };\n}\n\ntype ItemResult = { ok: true; outcome: UpsertItemOutcome } | { ok: false; message: string };\n\nfunction fail(message: string): ItemResult {\n return { ok: false, message };\n}\n\n/** Structural checks that apply to every entry, whichever kind it is. */\nfunction checkShape(context: UpsertContext, item: TaskItemMutation): string | undefined {\n if (item.ref !== undefined) {\n if (item.id !== undefined) return 'ref is only valid when creating a task; drop the id, or drop the ref';\n if (!REF_PATTERN.test(item.ref)) {\n return `ref \"${item.ref}\" is invalid: a ref must start with a letter and contain only letters, digits, - or _`;\n }\n const owner = context.refIds.get(item.ref) !== undefined || context.failedRefs.has(item.ref);\n if (owner) return `duplicate ref \"${item.ref}\": it was already declared by an earlier entry`;\n }\n return undefined;\n}\n\nfunction applyCreateItem(context: UpsertContext, item: TaskItemMutation, index: number, now: string): ItemResult {\n if (item.subject === undefined) return fail('subject is required when the entry has no id');\n if (!item.subject.trim()) return fail('subject must not be blank');\n if (item.addBlockedBy !== undefined || item.removeBlockedBy !== undefined) {\n return fail('addBlockedBy / removeBlockedBy are only for an entry with an id; a new task uses blockedBy');\n }\n // A task created as a tombstone is invisible to every view and can never\n // leave `deleted`, so it would be a write-only black hole.\n if (item.status === DELETED_STATUS) {\n return fail('cannot create a task with status deleted; create it, then use action delete');\n }\n\n const blockedBy: number[] = [];\n for (const token of item.blockedBy ?? []) {\n const resolved = resolveDep(context, 'blockedBy', token);\n if (!resolved.ok) return fail(resolved.message);\n const dep = context.tasks.find((task) => task.id === resolved.id);\n if (!dep) return fail(`blockedBy: #${resolved.id} not found`);\n if (dep.status === DELETED_STATUS) return fail(`blockedBy: #${resolved.id} is deleted`);\n if (!blockedBy.includes(resolved.id)) blockedBy.push(resolved.id);\n }\n\n // No cycle check is needed: the id is freshly allocated, so nothing already\n // in the document can point at it yet.\n const created: Task = {\n id: context.nextId,\n subject: item.subject,\n status: item.status ?? 'pending',\n createdAt: now,\n updatedAt: now,\n };\n assignScalars(created, item);\n if (blockedBy.length) created.blockedBy = blockedBy;\n\n context.nextId += 1;\n context.tasks.push(created);\n if (item.ref) context.refIds.set(item.ref, created.id);\n\n return {\n ok: true,\n outcome: {\n index,\n kind: 'created',\n id: created.id,\n subject: created.subject,\n status: created.status,\n ...(item.ref ? { ref: item.ref } : {}),\n ...(blockedBy.length ? { blockedBy } : {}),\n },\n };\n}\n\nfunction applyUpdateItem(context: UpsertContext, item: TaskItemMutation, index: number, now: string): ItemResult {\n const id = item.id as number;\n const at = context.tasks.findIndex((task) => task.id === id);\n if (at === -1) return fail(`#${id} not found`);\n if (item.blockedBy !== undefined) {\n return fail('blockedBy is only for a new entry; use addBlockedBy / removeBlockedBy on an entry that has an id');\n }\n\n const hasMutation =\n item.subject !== undefined ||\n item.description !== undefined ||\n item.activeForm !== undefined ||\n item.status !== undefined ||\n item.owner !== undefined ||\n item.metadata !== undefined ||\n Boolean(item.addBlockedBy?.length) ||\n Boolean(item.removeBlockedBy?.length);\n if (!hasMutation) {\n return fail(\n 'nothing to change: provide at least one of subject, description, activeForm, status, owner, metadata, addBlockedBy, or removeBlockedBy',\n );\n }\n\n const current = context.tasks[at];\n\n // The Task Space overlay commits free text from an inline editor, so a blank\n // subject reaches the reducer as a real update rather than as a missing\n // field. Persisting it would leave an unidentifiable row.\n if (item.subject !== undefined && !item.subject.trim()) return fail('subject must not be blank');\n\n let newStatus = current.status;\n if (item.status !== undefined) {\n if (!isTransitionValid(current.status, item.status)) {\n return fail(`illegal transition ${current.status} -> ${item.status}`);\n }\n newStatus = item.status;\n }\n\n let newBlockedBy = current.blockedBy ? [...current.blockedBy] : [];\n for (const token of item.removeBlockedBy ?? []) {\n const resolved = resolveDep(context, 'removeBlockedBy', token);\n if (!resolved.ok) return fail(resolved.message);\n // Removing an id that is not there is a well-defined no-op, so unlike the\n // add path this deliberately skips the existence check.\n newBlockedBy = newBlockedBy.filter((dep) => dep !== resolved.id);\n }\n for (const token of item.addBlockedBy ?? []) {\n const resolved = resolveDep(context, 'addBlockedBy', token);\n if (!resolved.ok) return fail(resolved.message);\n if (resolved.id === id) return fail(`cannot block #${id} on itself`);\n const dep = context.tasks.find((task) => task.id === resolved.id);\n if (!dep) return fail(`addBlockedBy: #${resolved.id} not found`);\n if (dep.status === DELETED_STATUS) return fail(`addBlockedBy: #${resolved.id} is deleted`);\n if (!newBlockedBy.includes(resolved.id)) newBlockedBy.push(resolved.id);\n }\n\n const updated: Task = { ...current, status: newStatus };\n assignScalars(updated, item);\n if (newBlockedBy.length) updated.blockedBy = newBlockedBy;\n else delete updated.blockedBy;\n\n // The candidate is written before the check because `detectCycle` unions the\n // node's stored edges with the ones passed in: checking against the old array\n // would resurrect an edge `removeBlockedBy` just stripped and reject a\n // remove+add that legitimately breaks a cycle.\n const candidate = [...context.tasks];\n candidate[at] = updated;\n if (item.addBlockedBy?.length && detectCycle(candidate, id, newBlockedBy)) {\n return fail('addBlockedBy would create a cycle in the blockedBy graph');\n }\n\n const changed = taskChanged(current, updated);\n if (changed) updated.updatedAt = now;\n context.tasks = candidate;\n\n return {\n ok: true,\n outcome: changed\n ? { index, kind: 'updated', id, fromStatus: current.status, toStatus: newStatus }\n : { index, kind: 'unchanged', id, status: newStatus },\n };\n}\n\n/**\n * Apply every entry in request order, threading the document.\n *\n * Each entry lands completely or not at all: a create whose dependencies fail\n * is not kept dependency-free, because handing back an unblocked task the\n * caller asked to be blocked is a lie it may immediately act on.\n */\nfunction applyUpsert(document: TaskDocument, items: TaskItemMutation[], now: string): ApplyResult {\n const context: UpsertContext = {\n tasks: [...document.tasks],\n nextId: document.nextId,\n refIds: new Map(),\n failedRefs: new Map(),\n };\n const outcomes: UpsertItemOutcome[] = [];\n let applied = 0;\n\n for (const [index, item] of items.entries()) {\n const shapeError = checkShape(context, item);\n const result = shapeError\n ? fail(shapeError)\n : item.id === undefined\n ? applyCreateItem(context, item, index, now)\n : applyUpdateItem(context, item, index, now);\n\n if (result.ok) {\n outcomes.push(result.outcome);\n applied += 1;\n continue;\n }\n // A ref whose owner failed must not read as a typo to the entries that\n // depend on it, so the dead ref is recorded rather than left unknown.\n if (item.ref && REF_PATTERN.test(item.ref) && !context.refIds.has(item.ref)) {\n context.failedRefs.set(item.ref, index);\n }\n outcomes.push({\n index,\n kind: 'failed',\n message: result.message,\n ...(item.id === undefined ? {} : { id: item.id }),\n ...(item.ref ? { ref: item.ref } : {}),\n });\n }\n\n return {\n // Nothing applied means nothing to write: returning the original object by\n // reference keeps the caller's write-skip path identical to a hard error.\n document: applied > 0 ? withTasks(document, context.tasks, context.nextId) : document,\n op: { kind: 'upsert', items: outcomes, applied, failed: outcomes.length - applied },\n };\n}\n\n/**\n * Pure reducer: (document, action, params) -> (document, op).\n *\n * All validation is in-line: structural guards plus state-aware checks\n * (transition legality, dangling or deleted blockedBy, self-block, cycles,\n * in-flight delegations). The caller owns persistence and formatting.\n */\nexport function applyTaskMutation(\n document: TaskDocument,\n action: ReducerAction,\n params: TaskMutationParams,\n now: string = new Date().toISOString(),\n): ApplyResult {\n switch (action) {\n case 'upsert': {\n const items = params.tasks;\n if (!Array.isArray(items) || items.length === 0) {\n return errorResult(\n document,\n 'upsert requires a non-empty tasks array, e.g. {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Write tests\"}]}',\n );\n }\n if (items.length > MAX_UPSERT_ITEMS) {\n return errorResult(\n document,\n `upsert accepts at most ${MAX_UPSERT_ITEMS} entries per call (received ${items.length})`,\n );\n }\n return applyUpsert(document, items, now);\n }\n\n case 'list': {\n return {\n document,\n op: {\n kind: 'list',\n includeDeleted: params.includeDeleted === true,\n ...(params.status !== undefined ? { statusFilter: params.status } : {}),\n },\n };\n }\n\n case 'get': {\n if (params.id === undefined) return errorResult(document, 'id required for get');\n const task = document.tasks.find((candidate) => candidate.id === params.id);\n if (!task) return errorResult(document, `#${params.id} not found`);\n return { document, op: { kind: 'get', task } };\n }\n\n case 'delete': {\n if (params.id === undefined) return errorResult(document, 'id required for delete');\n const index = document.tasks.findIndex((task) => task.id === params.id);\n if (index === -1) return errorResult(document, `#${params.id} not found`);\n const current = document.tasks[index];\n if (current.status === DELETED_STATUS) return errorResult(document, `#${current.id} is already deleted`);\n if (isDelegationActive(current)) {\n return errorResult(document, `#${current.id} has a running delegation — cancel it before deleting`);\n }\n\n const tasks = [...document.tasks];\n tasks[index] = { ...current, status: DELETED_STATUS, updatedAt: now };\n return {\n document: withTasks(document, tasks),\n op: { kind: 'delete', id: current.id, subject: current.subject },\n };\n }\n\n case 'clear': {\n const active = document.tasks.filter(isDelegationActive);\n if (active.length > 0) {\n const ids = active.map((task) => `#${task.id}`).join(', ');\n return errorResult(document, `cannot clear while delegations are running (${ids}) — cancel them first`);\n }\n const count = document.tasks.length;\n return {\n document: withTasks(document, [], 1),\n op: { kind: 'clear', count },\n };\n }\n }\n}\n"],"mappings":"wKAgBA,MAAa,EAAmB,IAOnB,EAAc,gCAiC3B,SAAgB,EAAe,EAAiB,CAC9C,OAAQ,EAAG,KAAX,CACE,IAAK,QACL,IAAK,OACL,IAAK,MACH,MAAO,GACT,IAAK,SACH,OAAO,EAAG,MAAM,KAAM,GAAS,EAAK,OAAS,WAAa,EAAK,OAAS,SAAS,EACnF,IAAK,SACL,IAAK,QACH,MAAO,EACX,CACF,CAGA,SAAgB,EAAoB,EAA6C,CAC/E,OAAO,EAAG,MACP,OAAQ,GAAS,EAAK,OAAS,QAAQ,CAAC,CACxC,IAAK,GAAS,QAAQ,EAAK,MAAM,KAAK,EAAK,SAAS,CAAC,CACrD,KAAK;CAAI,CACd,CAGA,SAAgB,EAAkB,EAAuC,CACvE,OAAO,EAAG,OAAS,SAAW,EAAG,MAAM,GAAK,IAAA,EAC9C,CAEA,SAAS,EAAY,EAAwB,EAA8B,CACzE,MAAO,CAAE,WAAU,GAAI,CAAE,KAAM,QAAS,SAAQ,CAAE,CACpD,CAEA,SAAS,EAAe,EAAyB,EAAkC,CACjF,IAAM,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AAM,GAC/B,GAAI,EAAQ,SAAA,UAA2B,OAAO,EAAY,EAAU,IAAI,EAAQ,GAAG,oBAAoB,EACvG,GAAI,EAAmB,CAAO,EAC5B,OAAO,EAAY,EAAU,IAAI,EAAQ,GAAG,sDAAsD,EAGpG,IAAM,EAAQ,CAAC,GAAG,EAAS,KAAK,EAEhC,MADA,GAAM,GAAS,CAAE,GAAG,EAAS,OAAQ,EAAgB,UAAW,CAAI,EAC7D,CACL,SAAU,EAAU,EAAU,CAAK,EACnC,GAAI,CAAE,KAAM,SAAU,GAAI,EAAQ,GAAI,QAAS,EAAQ,OAAQ,CACjE,CACF,CAEA,IAAK,QAAS,CACZ,IAAM,EAAS,EAAS,MAAM,OAAO,CAAkB,EACvD,GAAI,EAAO,OAAS,EAElB,OAAO,EAAY,EAAU,+CADjB,EAAO,IAAK,GAAS,IAAI,EAAK,IAAI,CAAC,CAAC,KAAK,IACyB,EAAE,sBAAsB,EAExG,IAAM,EAAQ,EAAS,MAAM,OAC7B,MAAO,CACL,SAAU,EAAU,EAAU,CAAC,EAAG,CAAC,EACnC,GAAI,CAAE,KAAM,QAAS,OAAM,CAC7B,CACF,CACF,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"taskGraph.cjs","names":[],"sources":["../../src/store/taskGraph.ts"],"sourcesContent":["import type { Task } from './types.ts';\n\nconst COMPLETED_STATUS: Task['status'] = 'completed';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\n/** True when a non-empty list has no visible work left to finish. */\nexport function isTaskListComplete(taskList: readonly Task[]): boolean {\n const visible = taskList.filter((task) => task.status !== DELETED_STATUS);\n return visible.length > 0 && visible.every((task) => task.status === COMPLETED_STATUS);\n}\n\n/**\n * Would merging `newBlockedBy` into `taskId`'s dependencies introduce a cycle?\n *\n * Takes the proposed additions explicitly so the reducer can ask the question\n * before mutating anything.\n */\nexport function detectCycle(taskList: readonly Task[], taskId: number, newBlockedBy: readonly number[]): boolean {\n const edges = new Map<number, number[]>();\n for (const task of taskList) {\n if (task.id === taskId) {\n edges.set(task.id, [...new Set([...(task.blockedBy ?? []), ...newBlockedBy])]);\n } else {\n edges.set(task.id, task.blockedBy ? [...task.blockedBy] : []);\n }\n }\n\n const visiting = new Set<number>();\n const visited = new Set<number>();\n const hasCycleFrom = (node: number): boolean => {\n if (visiting.has(node)) return true;\n if (visited.has(node)) return false;\n visiting.add(node);\n for (const next of edges.get(node) ?? []) {\n if (hasCycleFrom(next)) return true;\n }\n visiting.delete(node);\n visited.add(node);\n return false;\n };\n\n for (const node of edges.keys()) {\n if (hasCycleFrom(node)) return true;\n }\n return false;\n}\n\n/** Inverse adjacency: for each task, which tasks list it in their blockedBy. */\nexport function deriveBlocks(taskList: readonly Task[]): Map<number, number[]> {\n const blocks = new Map<number, number[]>();\n for (const task of taskList) {\n for (const dep of task.blockedBy ?? []) {\n const dependents = blocks.get(dep) ?? [];\n dependents.push(task.id);\n blocks.set(dep, dependents);\n }\n }\n return blocks;\n}\n\n/**\n * Blocking dependencies of a task that are not yet resolved.\n *\n * `completed` clears a dependency; `failed` deliberately does not, so a failed\n * delegation keeps its dependents blocked instead of silently releasing work\n * that was never actually finished.\n */\nexport function unresolvedBlockers(taskList: readonly Task[], task: Task): number[] {\n return (task.blockedBy ?? []).filter((dep) => {\n const blocker = taskList.find((candidate) => candidate.id === dep);\n if (!blocker) return false;\n return blocker.status !== COMPLETED_STATUS && blocker.status !== DELETED_STATUS;\n });\n}\n\nexport function isBlocked(taskList: readonly Task[], task: Task): boolean {\n return unresolvedBlockers(taskList, task).length > 0;\n}\n"],"mappings":"mEAEA,MAAM,EAAmC,YACnC,EAAiC,UAGvC,SAAgB,EAAmB,EAAoC,CACrE,IAAM,EAAU,EAAS,OAAQ,GAAS,EAAK,SAAW,CAAc,EACxE,OAAO,EAAQ,OAAS,GAAK,EAAQ,MAAO,GAAS,EAAK,SAAW,CAAgB,CACvF,CAQA,SAAgB,EAAY,EAA2B,EAAgB,EAA0C,CAC/G,IAAM,EAAQ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AAC,OAAS,CACrD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"taskGraph.d.cts","names":[],"sources":["../../src/store/taskGraph.ts"],"mappings":";;;iBAMgB,mBAAmB,mBAAmB;;;;;;;iBAWtC,YAAY,mBAAmB,QAAQ,gBAAgB;;iBA+BvD,aAAa,mBAAmB,SAAS;;;;;;;;iBAmBzC,mBAAmB,mBAAmB,QAAQ,MAAM;iBAQpD,UAAU,mBAAmB,QAAQ,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"taskGraph.d.mts","names":[],"sources":["../../src/store/taskGraph.ts"],"mappings":";;;iBAMgB,mBAAmB,mBAAmB;;;;;;;iBAWtC,YAAY,mBAAmB,QAAQ,gBAAgB;;iBA+BvD,aAAa,mBAAmB,SAAS;;;;;;;;iBAmBzC,mBAAmB,mBAAmB,QAAQ,MAAM;iBAQpD,UAAU,mBAAmB,QAAQ,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"taskGraph.mjs","names":[],"sources":["../../src/store/taskGraph.ts"],"sourcesContent":["import type { Task } from './types.ts';\n\nconst COMPLETED_STATUS: Task['status'] = 'completed';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\n/** True when a non-empty list has no visible work left to finish. */\nexport function isTaskListComplete(taskList: readonly Task[]): boolean {\n const visible = taskList.filter((task) => task.status !== DELETED_STATUS);\n return visible.length > 0 && visible.every((task) => task.status === COMPLETED_STATUS);\n}\n\n/**\n * Would merging `newBlockedBy` into `taskId`'s dependencies introduce a cycle?\n *\n * Takes the proposed additions explicitly so the reducer can ask the question\n * before mutating anything.\n */\nexport function detectCycle(taskList: readonly Task[], taskId: number, newBlockedBy: readonly number[]): boolean {\n const edges = new Map<number, number[]>();\n for (const task of taskList) {\n if (task.id === taskId) {\n edges.set(task.id, [...new Set([...(task.blockedBy ?? []), ...newBlockedBy])]);\n } else {\n edges.set(task.id, task.blockedBy ? [...task.blockedBy] : []);\n }\n }\n\n const visiting = new Set<number>();\n const visited = new Set<number>();\n const hasCycleFrom = (node: number): boolean => {\n if (visiting.has(node)) return true;\n if (visited.has(node)) return false;\n visiting.add(node);\n for (const next of edges.get(node) ?? []) {\n if (hasCycleFrom(next)) return true;\n }\n visiting.delete(node);\n visited.add(node);\n return false;\n };\n\n for (const node of edges.keys()) {\n if (hasCycleFrom(node)) return true;\n }\n return false;\n}\n\n/** Inverse adjacency: for each task, which tasks list it in their blockedBy. */\nexport function deriveBlocks(taskList: readonly Task[]): Map<number, number[]> {\n const blocks = new Map<number, number[]>();\n for (const task of taskList) {\n for (const dep of task.blockedBy ?? []) {\n const dependents = blocks.get(dep) ?? [];\n dependents.push(task.id);\n blocks.set(dep, dependents);\n }\n }\n return blocks;\n}\n\n/**\n * Blocking dependencies of a task that are not yet resolved.\n *\n * `completed` clears a dependency; `failed` deliberately does not, so a failed\n * delegation keeps its dependents blocked instead of silently releasing work\n * that was never actually finished.\n */\nexport function unresolvedBlockers(taskList: readonly Task[], task: Task): number[] {\n return (task.blockedBy ?? []).filter((dep) => {\n const blocker = taskList.find((candidate) => candidate.id === dep);\n if (!blocker) return false;\n return blocker.status !== COMPLETED_STATUS && blocker.status !== DELETED_STATUS;\n });\n}\n\nexport function isBlocked(taskList: readonly Task[], task: Task): boolean {\n return unresolvedBlockers(taskList, task).length > 0;\n}\n"],"mappings":"AAEA,MAAM,EAAmC,YACnC,EAAiC,UAGvC,SAAgB,EAAmB,EAAoC,CACrE,IAAM,EAAU,EAAS,OAAQ,GAAS,EAAK,SAAW,CAAc,EACxE,OAAO,EAAQ,OAAS,GAAK,EAAQ,MAAO,GAAS,EAAK,SAAW,CAAgB,CACvF,CAQA,SAAgB,EAAY,EAA2B,EAAgB,EAA0C,CAC/G,IAAM,EAAQ,IAAI,IAClB,IAAK,IAAM,KAAQ,EACb,EAAK,KAAO,EACd,EAAM,IAAI,EAAK,GAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAI,EAAK,WAAa,CAAC,EAAI,GAAG,CAAY,CAAC,CAAC,CAAC,EAE7E,EAAM,IAAI,EAAK,GAAI,EAAK,UAAY,CAAC,GAAG,EAAK,SAAS,EAAI,CAAC,CAAC,EAIhE,IAAM,EAAW,IAAI,IACf,EAAU,IAAI,IACd,EAAgB,GAA0B,CAC9C,GAAI,EAAS,IAAI,CAAI,EAAG,MAAO,GAC/B,GAAI,EAAQ,IAAI,CAAI,EAAG,MAAO,GAC9B,EAAS,IAAI,CAAI,EACjB,IAAK,IAAM,KAAQ,EAAM,IAAI,CAAI,GAAK,CAAC,EACrC,GAAI,EAAa,CAAI,EAAG,MAAO,GAIjC,OAFA,EAAS,OAAO,CAAI,EACpB,EAAQ,IAAI,CAAI,EACT,EACT,EAEA,IAAK,IAAM,KAAQ,EAAM,KAAK,EAC5B,GAAI,EAAa,CAAI,EAAG,MAAO,GAEjC,MAAO,EACT,CAGA,SAAgB,EAAa,EAAkD,CAC7E,IAAM,EAAS,IAAI,IACnB,IAAK,IAAM,KAAQ,EACjB,IAAK,IAAM,KAAO,EAAK,WAAa,CAAC,EAAG,CACtC,IAAM,EAAa,EAAO,IAAI,CAAG,GAAK,CAAC,EACvC,EAAW,KAAK,EAAK,EAAE,EACvB,EAAO,IAAI,EAAK,CAAU,CAC5B,CAEF,OAAO,CACT,CASA,SAAgB,EAAmB,EAA2B,EAAsB,CAClF,OAAQ,EAAK,WAAa,CAAC,EAAA,CAAG,OAAQ,GAAQ,CAC5C,IAAM,EAAU,EAAS,KAAM,GAAc,EAAU,KAAO,CAAG,EAEjE,OADK,EACE,EAAQ,SAAW,GAAoB,EAAQ,SAAW,EAD5C,EAEvB,CAAC,CACH,CAEA,SAAgB,EAAU,EAA2B,EAAqB,CACxE,OAAO,EAAmB,EAAU,CAAI,CAAC,CAAC,OAAS,CACrD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"taskStore.cjs","names":["emptyDocument","resolveStorePath","fs","TASK_EVENT","path","tempPathFor","lockPathFor","isProcessAlive"],"sources":["../../src/store/taskStore.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { TASK_EVENT, type TaskFailureReporter } from '../logSinkTelemetry.ts';\nimport { lockPathFor, resolveStorePath, STORE_PATH_ENV, tempPathFor } from './paths.ts';\nimport { isProcessAlive } from './processLiveness.ts';\nimport { emptyDocument, STORE_SCHEMA_VERSION, type Task, type TaskDocument } from './types.ts';\n\nconst LOCK_TIMEOUT_MS = 2000;\nconst LOCK_STALE_MS = 10_000;\nconst LOCK_RETRY_BASE_MS = 10;\nconst LOCK_RETRY_MAX_MS = 60;\nconst WATCH_DEBOUNCE_MS = 150;\nconst POLL_INTERVAL_MS = 2000;\nconst UTF8_ENCODING = 'utf8';\nconst MISSING_FILE_CODE = 'ENOENT';\nconst LOCK_EXISTS_CODE = 'EEXIST';\nconst STORE_PATH_ATTRIBUTE = 'store.path';\n\nexport interface TaskStoreOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n storePath?: string;\n /** Backstop poll cadence for change detection. Lowered in tests so they do\n * not depend on `fs.watch`, whose delivery timing is platform-dependent. */\n pollIntervalMs?: number;\n /** How long to wait for the advisory lock before proceeding lock-free. */\n lockTimeoutMs?: number;\n /** Where swallowed failures go, so silent degradation stays visible. */\n report?: TaskFailureReporter;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid document.\n *\n * A corrupt or truncated store must not take the session down: the worst\n * acceptable outcome is starting from an empty list, never a crash on startup.\n */\nfunction normalizeDocument(parsed: unknown): TaskDocument {\n if (!parsed || typeof parsed !== 'object') return emptyDocument();\n const candidate = parsed as Partial<TaskDocument>;\n if (!Array.isArray(candidate.tasks)) return emptyDocument();\n\n const tasks = candidate.tasks.filter(\n (task): task is Task => Boolean(task) && typeof task === 'object' && typeof (task as Task).id === 'number',\n );\n const maxId = tasks.reduce((max, task) => Math.max(max, task.id), 0);\n return {\n version: typeof candidate.version === 'number' ? candidate.version : STORE_SCHEMA_VERSION,\n rev: typeof candidate.rev === 'number' ? candidate.rev : 0,\n nextId: typeof candidate.nextId === 'number' && candidate.nextId > maxId ? candidate.nextId : maxId + 1,\n tasks,\n };\n}\n\n/**\n * File-backed task store shared by one root session and its delegated children.\n *\n * Durability model: the JSON file is the source of truth. Mutations are\n * read-modify-write under an advisory lock so concurrent delegated processes\n * cannot clobber each other, and writes land via temp-file rename so a\n * crash mid-write can never leave a partial document behind.\n */\nexport class TaskStore {\n storePath: string;\n\n private readonly cwd: string;\n private readonly env: NodeJS.ProcessEnv;\n private cached: TaskDocument = emptyDocument();\n private lastKnownRev = -1;\n private watcher?: fs.FSWatcher;\n private pollTimer?: NodeJS.Timeout;\n private debounceTimer?: NodeJS.Timeout;\n private readonly listeners = new Set<(document: TaskDocument) => void>();\n private readonly pollIntervalMs: number;\n private readonly lockTimeoutMs: number;\n private readonly report?: TaskFailureReporter;\n\n constructor(options: TaskStoreOptions = {}) {\n this.cwd = options.cwd ?? process.cwd();\n this.env = options.env ?? process.env;\n this.storePath = options.storePath ?? resolveStorePath(this.cwd, this.env);\n this.pollIntervalMs = options.pollIntervalMs ?? POLL_INTERVAL_MS;\n this.lockTimeoutMs = options.lockTimeoutMs ?? LOCK_TIMEOUT_MS;\n this.report = options.report;\n }\n\n /** Bind a default store to the current session tree before reading or watching it. */\n configureSession(sessionKey: string): void {\n if (this.env[STORE_PATH_ENV]?.trim()) return;\n this.stopWatching();\n this.storePath = resolveStorePath(this.cwd, this.env, sessionKey);\n this.cached = emptyDocument();\n this.lastKnownRev = -1;\n }\n\n /** Last document read from disk, without hitting the filesystem. */\n get snapshot(): TaskDocument {\n return this.cached;\n }\n\n read(): TaskDocument {\n try {\n const raw = fs.readFileSync(this.storePath, UTF8_ENCODING);\n this.cached = normalizeDocument(JSON.parse(raw));\n } catch (error) {\n // A missing file is the normal state before the first write. Anything\n // else means the task list just silently became empty, which is worth a\n // record: unreadable or corrupt JSON looks identical to \"no tasks yet\".\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n this.cached = emptyDocument();\n }\n this.lastKnownRev = this.cached.rev;\n return this.cached;\n }\n\n /**\n * Apply a mutation under the store lock.\n *\n * `mutate` receives the freshest on-disk document and returns either the next\n * document to commit or `undefined` for a read-only action (list/get), which\n * skips the write entirely so queries never bump `rev`.\n */\n async mutate<T>(\n mutate: (document: TaskDocument) => { document?: TaskDocument; value: T },\n ): Promise<{ document: TaskDocument; value: T }> {\n const release = await this.acquireLock();\n try {\n const current = this.read();\n const outcome = mutate(current);\n if (!outcome.document) {\n return { document: current, value: outcome.value };\n }\n const committed = this.write(outcome.document);\n return { document: committed, value: outcome.value };\n } finally {\n release();\n }\n }\n\n private write(document: TaskDocument): TaskDocument {\n const next: TaskDocument = { ...document, version: STORE_SCHEMA_VERSION, rev: document.rev + 1 };\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const temp = tempPathFor(this.storePath);\n fs.writeFileSync(temp, `${JSON.stringify(next, undefined, 2)}\\n`, UTF8_ENCODING);\n fs.renameSync(temp, this.storePath);\n this.cached = next;\n this.lastKnownRev = next.rev;\n return next;\n }\n\n private async acquireLock(): Promise<() => void> {\n const lockPath = lockPathFor(this.storePath);\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const deadline = Date.now() + this.lockTimeoutMs;\n\n for (;;) {\n try {\n const handle = fs.openSync(lockPath, 'wx');\n fs.writeSync(handle, JSON.stringify({ pid: process.pid, time: Date.now() }));\n fs.closeSync(handle);\n return () => fs.rmSync(lockPath, { force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== LOCK_EXISTS_CODE) throw error;\n // The deadline is checked before breaking a stale lock so a peer that\n // keeps recreating one cannot spin this loop without bound.\n if (Date.now() >= deadline) {\n // Proceeding lock-free beats stalling the agent: the rename is atomic,\n // so the worst case is a lost concurrent update, not a corrupt file.\n // Reported because a lost update here can strand a delegation.\n this.report?.warn(\n TASK_EVENT.storeLockTimeout,\n new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),\n { [STORE_PATH_ATTRIBUTE]: this.storePath },\n );\n return () => {};\n }\n // Clearing a dead holder's lock still goes through the backoff. Yielding\n // on every iteration is what stops a peer that keeps recreating the\n // lock from turning this into a spin.\n this.breakStaleLock(lockPath);\n await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);\n }\n }\n }\n\n /** Remove a lock left behind by a dead process or one held implausibly long. */\n private breakStaleLock(lockPath: string): boolean {\n try {\n const holder = JSON.parse(fs.readFileSync(lockPath, UTF8_ENCODING)) as { pid?: number; time?: number };\n const expired = typeof holder.time === 'number' && Date.now() - holder.time > LOCK_STALE_MS;\n const dead = typeof holder.pid === 'number' && !isProcessAlive(holder.pid);\n if (!expired && !dead) return false;\n fs.unlinkSync(lockPath);\n return true;\n } catch (error) {\n // Losing the race to another breaker is normal; a persistent failure here\n // shows up as the lock timeout above, so this stays a warning.\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.warn(TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });\n }\n return false;\n }\n }\n\n /**\n * Notify when another process changes the store.\n *\n * `fs.watch` alone is unreliable across the rename-based write (and on some\n * network filesystems), so a slow poll backs it up. Writes made by this\n * process are filtered out by revision so the UI does not redraw twice.\n */\n onExternalChange(listener: (document: TaskDocument) => void): () => void {\n this.listeners.add(listener);\n this.startWatching();\n return () => {\n this.listeners.delete(listener);\n if (this.listeners.size === 0) this.stopWatching();\n };\n }\n\n private startWatching(): void {\n if (this.watcher || this.pollTimer) return;\n const directory = path.dirname(this.storePath);\n const fileName = path.basename(this.storePath);\n\n try {\n fs.mkdirSync(directory, { recursive: true });\n this.watcher = fs.watch(directory, (_event, changed) => {\n if (changed && changed !== fileName) return;\n this.scheduleCheck();\n });\n } catch (error) {\n // Polling still covers change detection, just more slowly.\n this.report?.warn(TASK_EVENT.storeWatchFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n\n this.pollTimer = setInterval(() => this.checkForChange(), this.pollIntervalMs);\n this.pollTimer.unref?.();\n }\n\n private scheduleCheck(): void {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = setTimeout(() => this.checkForChange(), WATCH_DEBOUNCE_MS);\n this.debounceTimer.unref?.();\n }\n\n private checkForChange(): void {\n const previousRev = this.lastKnownRev;\n const document = this.read();\n if (document.rev === previousRev) return;\n for (const listener of this.listeners) {\n try {\n listener(document);\n } catch (error) {\n // This runs from a timer and from the fs.watch callback, so an\n // unguarded listener throw is an uncaught exception that takes the\n // harness down rather than a handled render failure.\n this.report?.error(TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n }\n\n private stopWatching(): void {\n this.watcher?.close();\n this.watcher = undefined;\n if (this.pollTimer) clearInterval(this.pollTimer);\n this.pollTimer = undefined;\n clearTimeout(this.debounceTimer);\n this.debounceTimer = undefined;\n }\n\n dispose(): void {\n this.listeners.clear();\n this.stopWatching();\n }\n}\n"],"mappings":"wUAOA,MAMM,EAAgB,OAChB,EAAoB,SAEpB,EAAuB,aAe7B,SAAS,EAAM,EAA2B,CACxC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,CAAE,CAAC,CACzD,CAQA,SAAS,EAAkB,EAA+B,CACxD,GAAI,CAAC,GAAU,OAAO,GAAW,SAAU,OAAOA,EAAAA,cAAc,EAChE,IAAM,EAAY,EAClB,GAAI,CAAC,MAAM,QAAQ,EAAU,KAAK,EAAG,OAAOA,EAAAA,cAAc,EAE1D,IAAM,EAAQ,EAAU,MAAM,OAC3B,GAAuB,EAAQ,GAAS,OAAO,GAAS,UAAY,OAAQ,EAAc,IAAO,QACpG,EACM,EAAQ,EAAM,QAAQ,EAAK,IAAS,KAAK,IAAI,EAAK,EAAK,EAAE,EAAG,CAAC,EACnE,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"taskStore.d.mts","names":[],"sources":["../../src/store/taskStore.ts"],"mappings":";;;UAkBiB;EACf;EACA,MAAM,OAAO;EACb;;;EAGA;;EAEA;;EAEA,SAAS;;;;;;;;;;cAsCE;EACX;mBAEiB;mBACA;UACT;UACA;UACA;UACA;UACA;mBACS;mBACA;mBACA;mBACA;EAEL,YAAA,UAAS;;EAUrB,iBAAiB;;MASb,YAAY;EAIhB,QAAQ;;;;;;;;EAwBF,OAAO,GACX,SAAS,UAAU;IAAmB,WAAW;IAAc,OAAO;MACrE;IAAU,UAAU;IAAc,OAAO;;UAepC;UAWM;;UAoCN;;;;;;;;EAyBR,iBAAiB,WAAW,UAAU;UAS9B;UAoBA;UAMA;UAgBA;EASR"}