@agimon-ai/doompi-task 0.0.1-alpha.12 → 0.0.1-alpha.121

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 (463) hide show
  1. package/README.md +123 -15
  2. package/dist/apiContracts.cjs +54 -0
  3. package/dist/apiContracts.cjs.map +1 -0
  4. package/dist/apiContracts.d.mts +53 -0
  5. package/dist/apiContracts.d.mts.map +1 -0
  6. package/dist/apiContracts.mjs +49 -0
  7. package/dist/apiContracts.mjs.map +1 -0
  8. package/dist/commands.cjs +4 -1
  9. package/dist/commands.d.mts +20 -2
  10. package/dist/commands.d.mts.map +1 -0
  11. package/dist/commands.mjs +2 -1
  12. package/dist/config-BPNE_wEU.cjs +173 -0
  13. package/dist/config-BPNE_wEU.cjs.map +1 -0
  14. package/dist/config-DmsCPDuF.mjs +72 -0
  15. package/dist/config-DmsCPDuF.mjs.map +1 -0
  16. package/dist/config.cjs +19 -1
  17. package/dist/config.d.mts +2 -2
  18. package/dist/config.mjs +2 -1
  19. package/dist/delegation-3hMdTFXF.cjs +661 -0
  20. package/dist/delegation-3hMdTFXF.cjs.map +1 -0
  21. package/dist/delegation-BiOy3_7g.mjs +7 -0
  22. package/dist/delegation-BiOy3_7g.mjs.map +1 -0
  23. package/dist/delegation-CkGbRaOl.mjs +626 -0
  24. package/dist/delegation-CkGbRaOl.mjs.map +1 -0
  25. package/dist/delegation-LDpHP2CC.cjs +12 -0
  26. package/dist/delegation-LDpHP2CC.cjs.map +1 -0
  27. package/dist/delegation-Ot2xltLi.d.mts +6 -0
  28. package/dist/delegation-Ot2xltLi.d.mts.map +1 -0
  29. package/dist/delegationManager.cjs +10 -0
  30. package/dist/delegationManager.d.mts +3 -0
  31. package/dist/delegationManager.mjs +3 -0
  32. package/dist/delegationPlatform-Cfn-Lqew.cjs +95 -0
  33. package/dist/delegationPlatform-Cfn-Lqew.cjs.map +1 -0
  34. package/dist/delegationPlatform-DZ4SZ8a5.mjs +64 -0
  35. package/dist/delegationPlatform-DZ4SZ8a5.mjs.map +1 -0
  36. package/dist/extensions/mcp-ui.mjs +23 -0
  37. package/dist/extensions/mcp-ui.mjs.map +1 -0
  38. package/dist/extensions/mcp.cjs +1876 -0
  39. package/dist/extensions/mcp.cjs.map +1 -0
  40. package/dist/extensions/mcp.d.mts +5 -0
  41. package/dist/extensions/mcp.d.mts.map +1 -0
  42. package/dist/extensions/mcp.mjs +1846 -0
  43. package/dist/extensions/mcp.mjs.map +1 -0
  44. package/dist/extensions/pi.cjs +437 -1
  45. package/dist/extensions/pi.cjs.map +1 -1
  46. package/dist/extensions/pi.d.mts +5 -2
  47. package/dist/extensions/pi.d.mts.map +1 -0
  48. package/dist/extensions/pi.mjs +432 -1
  49. package/dist/extensions/pi.mjs.map +1 -1
  50. package/dist/extensions/server.cjs +380 -0
  51. package/dist/extensions/server.cjs.map +1 -0
  52. package/dist/extensions/server.d.mts +5 -0
  53. package/dist/extensions/server.d.mts.map +1 -0
  54. package/dist/extensions/server.mjs +375 -0
  55. package/dist/extensions/server.mjs.map +1 -0
  56. package/dist/extensions/web.mjs +1013 -0
  57. package/dist/extensions/web.mjs.map +1 -0
  58. package/dist/format.cli-ChQsP1MQ.cjs +393 -0
  59. package/dist/format.cli-ChQsP1MQ.cjs.map +1 -0
  60. package/dist/format.cli-Cnc591eb.mjs +322 -0
  61. package/dist/format.cli-Cnc591eb.mjs.map +1 -0
  62. package/dist/{services/delegation/manager.d.mts → index-3-3ZJlaH.d.mts} +35 -31
  63. package/dist/index-3-3ZJlaH.d.mts.map +1 -0
  64. package/dist/{adapters/store/taskStore.d.cts → index-B7oVjSey.d.mts} +11 -28
  65. package/dist/index-B7oVjSey.d.mts.map +1 -0
  66. package/dist/{services/store/reconcile.d.cts → index-BNMm9g0K.d.mts} +4 -4
  67. package/dist/index-BNMm9g0K.d.mts.map +1 -0
  68. package/dist/{commands/task/responseEnvelope.d.cts → index-C3DgOhEm.d.mts} +17 -5
  69. package/dist/index-C3DgOhEm.d.mts.map +1 -0
  70. package/dist/{types/config.d.cts → index-D4goIk4Z.d.mts} +8 -3
  71. package/dist/index-D4goIk4Z.d.mts.map +1 -0
  72. package/dist/{services/store/reducer.d.cts → index-DIpc6_uJ.d.mts} +5 -5
  73. package/dist/index-DIpc6_uJ.d.mts.map +1 -0
  74. package/dist/{adapters/store/paths.d.cts → index-XY9VPmfm.d.mts} +6 -6
  75. package/dist/index-XY9VPmfm.d.mts.map +1 -0
  76. package/dist/index.cjs +106 -1
  77. package/dist/index.d.mts +16 -16
  78. package/dist/index.mjs +16 -1
  79. package/dist/invariants-DhjEjBPU.cjs +79 -0
  80. package/dist/invariants-DhjEjBPU.cjs.map +1 -0
  81. package/dist/invariants-q_UamF7D.mjs +62 -0
  82. package/dist/invariants-q_UamF7D.mjs.map +1 -0
  83. package/dist/logSinkTelemetry-C5QjZipw.mjs +41 -0
  84. package/dist/logSinkTelemetry-C5QjZipw.mjs.map +1 -0
  85. package/dist/logSinkTelemetry-CqiTuh3a.cjs +52 -0
  86. package/dist/logSinkTelemetry-CqiTuh3a.cjs.map +1 -0
  87. package/dist/logSinkTelemetry.cjs +6 -1
  88. package/dist/logSinkTelemetry.d.mts +23 -2
  89. package/dist/logSinkTelemetry.d.mts.map +1 -0
  90. package/dist/logSinkTelemetry.mjs +3 -1
  91. package/dist/paths-Bg8EEbk1.mjs +218 -0
  92. package/dist/paths-Bg8EEbk1.mjs.map +1 -0
  93. package/dist/paths-BsFVRulr.cjs +320 -0
  94. package/dist/paths-BsFVRulr.cjs.map +1 -0
  95. package/dist/processLiveness-Ccd9wenT.mjs +20 -0
  96. package/dist/processLiveness-Ccd9wenT.mjs.map +1 -0
  97. package/dist/processLiveness-umpNgsPR.cjs +25 -0
  98. package/dist/processLiveness-umpNgsPR.cjs.map +1 -0
  99. package/dist/promptGuidelines-DaxWrqud.d.mts +14 -0
  100. package/dist/promptGuidelines-DaxWrqud.d.mts.map +1 -0
  101. package/dist/promptGuidelines-g4QT8GNM.mjs +26 -0
  102. package/dist/promptGuidelines-g4QT8GNM.mjs.map +1 -0
  103. package/dist/promptGuidelines-j_SZTzlH.cjs +31 -0
  104. package/dist/promptGuidelines-j_SZTzlH.cjs.map +1 -0
  105. package/dist/reconcile-BcD-hTbd.mjs +63 -0
  106. package/dist/reconcile-BcD-hTbd.mjs.map +1 -0
  107. package/dist/reconcile-cRL0NjDr.cjs +80 -0
  108. package/dist/reconcile-cRL0NjDr.cjs.map +1 -0
  109. package/dist/reducer-BEfJFM5L.mjs +345 -0
  110. package/dist/reducer-BEfJFM5L.mjs.map +1 -0
  111. package/dist/reducer-BV0YIZ2o.cjs +380 -0
  112. package/dist/reducer-BV0YIZ2o.cjs.map +1 -0
  113. package/dist/root.cli-swHZqusx.d.mts +56 -0
  114. package/dist/root.cli-swHZqusx.d.mts.map +1 -0
  115. package/dist/selectors-BaS6dObz.mjs +142 -0
  116. package/dist/selectors-BaS6dObz.mjs.map +1 -0
  117. package/dist/{tui/selectors.d.cts → selectors-DPDPPjH3.d.mts} +11 -4
  118. package/dist/selectors-DPDPPjH3.d.mts.map +1 -0
  119. package/dist/selectors-b-69vb4W.cjs +189 -0
  120. package/dist/selectors-b-69vb4W.cjs.map +1 -0
  121. package/dist/storeInvariants.cjs +5 -0
  122. package/dist/storeInvariants.d.mts +23 -0
  123. package/dist/storeInvariants.d.mts.map +1 -0
  124. package/dist/storeInvariants.mjs +2 -0
  125. package/dist/storePaths.cjs +14 -0
  126. package/dist/storePaths.d.mts +2 -0
  127. package/dist/storePaths.mjs +2 -0
  128. package/dist/storeProcessLiveness.cjs +3 -0
  129. package/dist/{services/store/processLiveness.d.cts → storeProcessLiveness.d.mts} +3 -4
  130. package/dist/storeProcessLiveness.d.mts.map +1 -0
  131. package/dist/storeProcessLiveness.mjs +2 -0
  132. package/dist/storeReconcile.cjs +5 -0
  133. package/dist/storeReconcile.d.mts +2 -0
  134. package/dist/storeReconcile.mjs +2 -0
  135. package/dist/storeReducer.cjs +8 -0
  136. package/dist/storeReducer.d.mts +2 -0
  137. package/dist/storeReducer.mjs +2 -0
  138. package/dist/storeTaskGraph.cjs +7 -0
  139. package/dist/storeTaskGraph.d.mts +2 -0
  140. package/dist/storeTaskGraph.mjs +2 -0
  141. package/dist/storeTaskStore.cjs +3 -0
  142. package/dist/storeTaskStore.d.mts +2 -0
  143. package/dist/storeTaskStore.mjs +2 -0
  144. package/dist/storeTypes.cjs +6 -0
  145. package/dist/storeTypes.d.mts +2 -0
  146. package/dist/storeTypes.mjs +2 -0
  147. package/dist/task-B4aF5J9s.mjs +6 -0
  148. package/dist/task-B4aF5J9s.mjs.map +1 -0
  149. package/dist/task-CXF9VULl.cjs +49 -0
  150. package/dist/task-CXF9VULl.cjs.map +1 -0
  151. package/dist/task-CkFjC3Fo.d.mts +5 -0
  152. package/dist/task-CkFjC3Fo.d.mts.map +1 -0
  153. package/dist/{schemas/task.d.mts → task-DHSvdK6E.d.mts} +33 -17
  154. package/dist/task-DHSvdK6E.d.mts.map +1 -0
  155. package/dist/task-DKHKuems.mjs +116 -0
  156. package/dist/task-DKHKuems.mjs.map +1 -0
  157. package/dist/task-DaagqdPK.cjs +11 -0
  158. package/dist/task-DaagqdPK.cjs.map +1 -0
  159. package/dist/task-Dqy88_rr.cjs +193 -0
  160. package/dist/task-Dqy88_rr.cjs.map +1 -0
  161. package/dist/task-giCbpKzV.mjs +26 -0
  162. package/dist/task-giCbpKzV.mjs.map +1 -0
  163. package/dist/{services/store/types.d.mts → task-hLh4BOO7.d.mts} +37 -15
  164. package/dist/task-hLh4BOO7.d.mts.map +1 -0
  165. package/dist/task-space.cli-BH4Iy_7m.cjs +372 -0
  166. package/dist/task-space.cli-BH4Iy_7m.cjs.map +1 -0
  167. package/dist/task-space.cli-CMYNjgOW.mjs +355 -0
  168. package/dist/task-space.cli-CMYNjgOW.mjs.map +1 -0
  169. package/dist/task.cli-BM34E7GG.mjs +157 -0
  170. package/dist/task.cli-BM34E7GG.mjs.map +1 -0
  171. package/dist/task.cli-CiTkjUaX.cjs +174 -0
  172. package/dist/task.cli-CiTkjUaX.cjs.map +1 -0
  173. package/dist/taskGraph-BOQvT0-M.mjs +63 -0
  174. package/dist/taskGraph-BOQvT0-M.mjs.map +1 -0
  175. package/dist/taskGraph-BskRslrr.cjs +92 -0
  176. package/dist/taskGraph-BskRslrr.cjs.map +1 -0
  177. package/dist/{services/store/taskGraph.d.cts → taskGraph-YQXCfXTn.d.mts} +4 -4
  178. package/dist/taskGraph-YQXCfXTn.d.mts.map +1 -0
  179. package/dist/taskOverlay-B5wJHiml.cjs +175 -0
  180. package/dist/taskOverlay-B5wJHiml.cjs.map +1 -0
  181. package/dist/taskOverlay-CljDoTj_.mjs +164 -0
  182. package/dist/taskOverlay-CljDoTj_.mjs.map +1 -0
  183. package/dist/taskResult-D2G7b4w-.cjs +224 -0
  184. package/dist/taskResult-D2G7b4w-.cjs.map +1 -0
  185. package/dist/taskResult-edBAAKSH.mjs +165 -0
  186. package/dist/taskResult-edBAAKSH.mjs.map +1 -0
  187. package/dist/taskStore-CFx12KJk.mjs +213 -0
  188. package/dist/taskStore-CFx12KJk.mjs.map +1 -0
  189. package/dist/taskStore-T1pPy-UJ.cjs +220 -0
  190. package/dist/taskStore-T1pPy-UJ.cjs.map +1 -0
  191. package/dist/tasks.cli-8VvuN9YQ.cjs +40 -0
  192. package/dist/tasks.cli-8VvuN9YQ.cjs.map +1 -0
  193. package/dist/tasks.cli-BZj83YD_.mjs +29 -0
  194. package/dist/tasks.cli-BZj83YD_.mjs.map +1 -0
  195. package/dist/telemetry-DOyZLj8E.d.mts +36 -0
  196. package/dist/telemetry-DOyZLj8E.d.mts.map +1 -0
  197. package/dist/telemetry-I4md7Xzz.cjs +31 -0
  198. package/dist/telemetry-I4md7Xzz.cjs.map +1 -0
  199. package/dist/telemetry-PmX_1Y8a.mjs +26 -0
  200. package/dist/telemetry-PmX_1Y8a.mjs.map +1 -0
  201. package/dist/toolPromptGuidelines.cjs +3 -0
  202. package/dist/toolPromptGuidelines.d.mts +2 -0
  203. package/dist/toolPromptGuidelines.mjs +2 -0
  204. package/dist/toolResponseEnvelope.cjs +12 -0
  205. package/dist/toolResponseEnvelope.d.mts +2 -0
  206. package/dist/toolResponseEnvelope.mjs +2 -0
  207. package/dist/toolSchema.cjs +17 -0
  208. package/dist/toolSchema.d.mts +3 -0
  209. package/dist/toolSchema.mjs +3 -0
  210. package/dist/toolTaskTool.cjs +6 -0
  211. package/dist/toolTaskTool.d.mts +3 -0
  212. package/dist/toolTaskTool.mjs +3 -0
  213. package/dist/tuiFormat.cjs +14 -0
  214. package/dist/tuiFormat.d.mts +61 -0
  215. package/dist/tuiFormat.d.mts.map +1 -0
  216. package/dist/tuiFormat.mjs +2 -0
  217. package/dist/tuiSelectors.cjs +10 -0
  218. package/dist/tuiSelectors.d.mts +2 -0
  219. package/dist/tuiSelectors.mjs +2 -0
  220. package/dist/tuiTaskOverlay.cjs +4 -0
  221. package/dist/{tui/taskOverlay.d.cts → tuiTaskOverlay.d.mts} +9 -8
  222. package/dist/tuiTaskOverlay.d.mts.map +1 -0
  223. package/dist/tuiTaskOverlay.mjs +2 -0
  224. package/dist/tuiTaskSpace.cjs +5 -0
  225. package/dist/{tui/taskSpace.d.cts → tuiTaskSpace.d.mts} +11 -13
  226. package/dist/tuiTaskSpace.d.mts.map +1 -0
  227. package/dist/tuiTaskSpace.mjs +2 -0
  228. package/package.json +175 -109
  229. package/src/types/webTasks.ts +24 -0
  230. package/dist/_virtual/_rolldown/runtime.cjs +0 -1
  231. package/dist/adapters/pi/extension.cjs +0 -3
  232. package/dist/adapters/pi/extension.cjs.map +0 -1
  233. package/dist/adapters/pi/extension.d.cts +0 -12
  234. package/dist/adapters/pi/extension.d.cts.map +0 -1
  235. package/dist/adapters/pi/extension.d.mts +0 -12
  236. package/dist/adapters/pi/extension.d.mts.map +0 -1
  237. package/dist/adapters/pi/extension.mjs +0 -3
  238. package/dist/adapters/pi/extension.mjs.map +0 -1
  239. package/dist/adapters/store/paths.cjs +0 -2
  240. package/dist/adapters/store/paths.cjs.map +0 -1
  241. package/dist/adapters/store/paths.d.cts.map +0 -1
  242. package/dist/adapters/store/paths.d.mts +0 -26
  243. package/dist/adapters/store/paths.d.mts.map +0 -1
  244. package/dist/adapters/store/paths.mjs +0 -2
  245. package/dist/adapters/store/paths.mjs.map +0 -1
  246. package/dist/adapters/store/taskStore.cjs +0 -2
  247. package/dist/adapters/store/taskStore.cjs.map +0 -1
  248. package/dist/adapters/store/taskStore.d.cts.map +0 -1
  249. package/dist/adapters/store/taskStore.d.mts +0 -87
  250. package/dist/adapters/store/taskStore.d.mts.map +0 -1
  251. package/dist/adapters/store/taskStore.mjs +0 -2
  252. package/dist/adapters/store/taskStore.mjs.map +0 -1
  253. package/dist/adapters/telemetry/logSinkTelemetry.cjs +0 -2
  254. package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +0 -1
  255. package/dist/adapters/telemetry/logSinkTelemetry.d.cts +0 -52
  256. package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +0 -1
  257. package/dist/adapters/telemetry/logSinkTelemetry.d.mts +0 -52
  258. package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +0 -1
  259. package/dist/adapters/telemetry/logSinkTelemetry.mjs +0 -2
  260. package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +0 -1
  261. package/dist/commands/index.cjs +0 -2
  262. package/dist/commands/index.cjs.map +0 -1
  263. package/dist/commands/index.d.cts +0 -15
  264. package/dist/commands/index.d.cts.map +0 -1
  265. package/dist/commands/index.d.mts +0 -15
  266. package/dist/commands/index.d.mts.map +0 -1
  267. package/dist/commands/index.mjs +0 -2
  268. package/dist/commands/index.mjs.map +0 -1
  269. package/dist/commands/task/promptGuidelines.cjs +0 -2
  270. package/dist/commands/task/promptGuidelines.cjs.map +0 -1
  271. package/dist/commands/task/promptGuidelines.d.cts +0 -5
  272. package/dist/commands/task/promptGuidelines.d.cts.map +0 -1
  273. package/dist/commands/task/promptGuidelines.d.mts +0 -5
  274. package/dist/commands/task/promptGuidelines.d.mts.map +0 -1
  275. package/dist/commands/task/promptGuidelines.mjs +0 -2
  276. package/dist/commands/task/promptGuidelines.mjs.map +0 -1
  277. package/dist/commands/task/responseEnvelope.cjs +0 -6
  278. package/dist/commands/task/responseEnvelope.cjs.map +0 -1
  279. package/dist/commands/task/responseEnvelope.d.cts.map +0 -1
  280. package/dist/commands/task/responseEnvelope.d.mts +0 -39
  281. package/dist/commands/task/responseEnvelope.d.mts.map +0 -1
  282. package/dist/commands/task/responseEnvelope.mjs +0 -6
  283. package/dist/commands/task/responseEnvelope.mjs.map +0 -1
  284. package/dist/commands/task/taskTool.cjs +0 -3
  285. package/dist/commands/task/taskTool.cjs.map +0 -1
  286. package/dist/commands/task/taskTool.d.cts +0 -18
  287. package/dist/commands/task/taskTool.d.cts.map +0 -1
  288. package/dist/commands/task/taskTool.d.mts +0 -18
  289. package/dist/commands/task/taskTool.d.mts.map +0 -1
  290. package/dist/commands/task/taskTool.mjs +0 -3
  291. package/dist/commands/task/taskTool.mjs.map +0 -1
  292. package/dist/commands.d.cts +0 -2
  293. package/dist/config.d.cts +0 -2
  294. package/dist/delegation/manager.cjs +0 -1
  295. package/dist/delegation/manager.d.cts +0 -2
  296. package/dist/delegation/manager.d.mts +0 -2
  297. package/dist/delegation/manager.mjs +0 -1
  298. package/dist/extension.cjs +0 -1
  299. package/dist/extension.d.cts +0 -2
  300. package/dist/extension.d.mts +0 -2
  301. package/dist/extension.mjs +0 -1
  302. package/dist/extensions/doom.cjs +0 -2
  303. package/dist/extensions/doom.cjs.map +0 -1
  304. package/dist/extensions/doom.d.cts +0 -6
  305. package/dist/extensions/doom.d.cts.map +0 -1
  306. package/dist/extensions/doom.d.mts +0 -7
  307. package/dist/extensions/doom.d.mts.map +0 -1
  308. package/dist/extensions/doom.mjs +0 -2
  309. package/dist/extensions/doom.mjs.map +0 -1
  310. package/dist/extensions/pi.d.cts +0 -2
  311. package/dist/index.d.cts +0 -16
  312. package/dist/logSinkTelemetry.d.cts +0 -2
  313. package/dist/schemas/task.cjs +0 -2
  314. package/dist/schemas/task.cjs.map +0 -1
  315. package/dist/schemas/task.d.cts +0 -86
  316. package/dist/schemas/task.d.cts.map +0 -1
  317. package/dist/schemas/task.d.mts.map +0 -1
  318. package/dist/schemas/task.mjs +0 -2
  319. package/dist/schemas/task.mjs.map +0 -1
  320. package/dist/services/delegation/manager.cjs +0 -6
  321. package/dist/services/delegation/manager.cjs.map +0 -1
  322. package/dist/services/delegation/manager.d.cts +0 -188
  323. package/dist/services/delegation/manager.d.cts.map +0 -1
  324. package/dist/services/delegation/manager.d.mts.map +0 -1
  325. package/dist/services/delegation/manager.mjs +0 -6
  326. package/dist/services/delegation/manager.mjs.map +0 -1
  327. package/dist/services/narration/taskNarration.cjs +0 -2
  328. package/dist/services/narration/taskNarration.cjs.map +0 -1
  329. package/dist/services/narration/taskNarration.mjs +0 -2
  330. package/dist/services/narration/taskNarration.mjs.map +0 -1
  331. package/dist/services/store/invariants.cjs +0 -2
  332. package/dist/services/store/invariants.cjs.map +0 -1
  333. package/dist/services/store/invariants.d.cts +0 -14
  334. package/dist/services/store/invariants.d.cts.map +0 -1
  335. package/dist/services/store/invariants.d.mts +0 -14
  336. package/dist/services/store/invariants.d.mts.map +0 -1
  337. package/dist/services/store/invariants.mjs +0 -2
  338. package/dist/services/store/invariants.mjs.map +0 -1
  339. package/dist/services/store/paths.cjs +0 -1
  340. package/dist/services/store/paths.mjs +0 -1
  341. package/dist/services/store/processLiveness.cjs +0 -2
  342. package/dist/services/store/processLiveness.cjs.map +0 -1
  343. package/dist/services/store/processLiveness.d.cts.map +0 -1
  344. package/dist/services/store/processLiveness.d.mts +0 -12
  345. package/dist/services/store/processLiveness.d.mts.map +0 -1
  346. package/dist/services/store/processLiveness.mjs +0 -2
  347. package/dist/services/store/processLiveness.mjs.map +0 -1
  348. package/dist/services/store/reconcile.cjs +0 -2
  349. package/dist/services/store/reconcile.cjs.map +0 -1
  350. package/dist/services/store/reconcile.d.cts.map +0 -1
  351. package/dist/services/store/reconcile.d.mts +0 -34
  352. package/dist/services/store/reconcile.d.mts.map +0 -1
  353. package/dist/services/store/reconcile.mjs +0 -2
  354. package/dist/services/store/reconcile.mjs.map +0 -1
  355. package/dist/services/store/reducer.cjs +0 -3
  356. package/dist/services/store/reducer.cjs.map +0 -1
  357. package/dist/services/store/reducer.d.cts.map +0 -1
  358. package/dist/services/store/reducer.d.mts +0 -72
  359. package/dist/services/store/reducer.d.mts.map +0 -1
  360. package/dist/services/store/reducer.mjs +0 -3
  361. package/dist/services/store/reducer.mjs.map +0 -1
  362. package/dist/services/store/taskGraph.cjs +0 -2
  363. package/dist/services/store/taskGraph.cjs.map +0 -1
  364. package/dist/services/store/taskGraph.d.cts.map +0 -1
  365. package/dist/services/store/taskGraph.d.mts +0 -25
  366. package/dist/services/store/taskGraph.d.mts.map +0 -1
  367. package/dist/services/store/taskGraph.mjs +0 -2
  368. package/dist/services/store/taskGraph.mjs.map +0 -1
  369. package/dist/services/store/taskStore.cjs +0 -1
  370. package/dist/services/store/taskStore.d.cts +0 -2
  371. package/dist/services/store/taskStore.d.mts +0 -2
  372. package/dist/services/store/taskStore.mjs +0 -1
  373. package/dist/services/store/types.cjs +0 -2
  374. package/dist/services/store/types.cjs.map +0 -1
  375. package/dist/services/store/types.d.cts +0 -165
  376. package/dist/services/store/types.d.cts.map +0 -1
  377. package/dist/services/store/types.d.mts.map +0 -1
  378. package/dist/services/store/types.mjs +0 -2
  379. package/dist/services/store/types.mjs.map +0 -1
  380. package/dist/store/invariants.cjs +0 -1
  381. package/dist/store/invariants.d.cts +0 -2
  382. package/dist/store/invariants.d.mts +0 -2
  383. package/dist/store/invariants.mjs +0 -1
  384. package/dist/store/paths.cjs +0 -1
  385. package/dist/store/paths.d.cts +0 -2
  386. package/dist/store/paths.d.mts +0 -2
  387. package/dist/store/paths.mjs +0 -1
  388. package/dist/store/processLiveness.cjs +0 -1
  389. package/dist/store/processLiveness.d.cts +0 -2
  390. package/dist/store/processLiveness.d.mts +0 -2
  391. package/dist/store/processLiveness.mjs +0 -1
  392. package/dist/store/reconcile.cjs +0 -1
  393. package/dist/store/reconcile.d.cts +0 -2
  394. package/dist/store/reconcile.d.mts +0 -2
  395. package/dist/store/reconcile.mjs +0 -1
  396. package/dist/store/reducer.cjs +0 -1
  397. package/dist/store/reducer.d.cts +0 -2
  398. package/dist/store/reducer.d.mts +0 -2
  399. package/dist/store/reducer.mjs +0 -1
  400. package/dist/store/taskGraph.cjs +0 -1
  401. package/dist/store/taskGraph.d.cts +0 -2
  402. package/dist/store/taskGraph.d.mts +0 -2
  403. package/dist/store/taskGraph.mjs +0 -1
  404. package/dist/store/taskStore.cjs +0 -1
  405. package/dist/store/taskStore.d.cts +0 -3
  406. package/dist/store/taskStore.d.mts +0 -3
  407. package/dist/store/taskStore.mjs +0 -1
  408. package/dist/store/types.cjs +0 -1
  409. package/dist/store/types.d.cts +0 -2
  410. package/dist/store/types.d.mts +0 -2
  411. package/dist/store/types.mjs +0 -1
  412. package/dist/tool/promptGuidelines.cjs +0 -1
  413. package/dist/tool/promptGuidelines.d.cts +0 -2
  414. package/dist/tool/promptGuidelines.d.mts +0 -2
  415. package/dist/tool/promptGuidelines.mjs +0 -1
  416. package/dist/tool/responseEnvelope.cjs +0 -1
  417. package/dist/tool/responseEnvelope.d.cts +0 -2
  418. package/dist/tool/responseEnvelope.d.mts +0 -2
  419. package/dist/tool/responseEnvelope.mjs +0 -1
  420. package/dist/tool/schema.cjs +0 -1
  421. package/dist/tool/schema.d.cts +0 -2
  422. package/dist/tool/schema.d.mts +0 -2
  423. package/dist/tool/schema.mjs +0 -1
  424. package/dist/tool/taskTool.cjs +0 -1
  425. package/dist/tool/taskTool.d.cts +0 -3
  426. package/dist/tool/taskTool.d.mts +0 -3
  427. package/dist/tool/taskTool.mjs +0 -1
  428. package/dist/tui/format.cjs +0 -4
  429. package/dist/tui/format.cjs.map +0 -1
  430. package/dist/tui/format.d.cts +0 -62
  431. package/dist/tui/format.d.cts.map +0 -1
  432. package/dist/tui/format.d.mts +0 -62
  433. package/dist/tui/format.d.mts.map +0 -1
  434. package/dist/tui/format.mjs +0 -4
  435. package/dist/tui/format.mjs.map +0 -1
  436. package/dist/tui/selectors.cjs +0 -2
  437. package/dist/tui/selectors.cjs.map +0 -1
  438. package/dist/tui/selectors.d.cts.map +0 -1
  439. package/dist/tui/selectors.d.mts +0 -53
  440. package/dist/tui/selectors.d.mts.map +0 -1
  441. package/dist/tui/selectors.mjs +0 -2
  442. package/dist/tui/selectors.mjs.map +0 -1
  443. package/dist/tui/taskOverlay.cjs +0 -2
  444. package/dist/tui/taskOverlay.cjs.map +0 -1
  445. package/dist/tui/taskOverlay.d.cts.map +0 -1
  446. package/dist/tui/taskOverlay.d.mts +0 -38
  447. package/dist/tui/taskOverlay.d.mts.map +0 -1
  448. package/dist/tui/taskOverlay.mjs +0 -2
  449. package/dist/tui/taskOverlay.mjs.map +0 -1
  450. package/dist/tui/taskSpace.cjs +0 -5
  451. package/dist/tui/taskSpace.cjs.map +0 -1
  452. package/dist/tui/taskSpace.d.cts.map +0 -1
  453. package/dist/tui/taskSpace.d.mts +0 -62
  454. package/dist/tui/taskSpace.d.mts.map +0 -1
  455. package/dist/tui/taskSpace.mjs +0 -5
  456. package/dist/tui/taskSpace.mjs.map +0 -1
  457. package/dist/types/config.cjs +0 -2
  458. package/dist/types/config.cjs.map +0 -1
  459. package/dist/types/config.d.cts.map +0 -1
  460. package/dist/types/config.d.mts +0 -38
  461. package/dist/types/config.d.mts.map +0 -1
  462. package/dist/types/config.mjs +0 -2
  463. package/dist/types/config.mjs.map +0 -1
@@ -0,0 +1,20 @@
1
+ //#region src/services/processLiveness/index.ts
2
+ /**
3
+ * Is a process still running?
4
+ *
5
+ * Signal 0 performs the permission and existence check without delivering a
6
+ * signal. EPERM means the process exists but belongs to another user, which
7
+ * still counts as alive.
8
+ */
9
+ function isProcessAlive(pid) {
10
+ try {
11
+ process.kill(pid, 0);
12
+ return true;
13
+ } catch (error) {
14
+ return error.code === "EPERM";
15
+ }
16
+ }
17
+ //#endregion
18
+ export { isProcessAlive as t };
19
+
20
+ //# sourceMappingURL=processLiveness-Ccd9wenT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processLiveness-Ccd9wenT.mjs","names":[],"sources":["../src/services/processLiveness/index.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,KAAsB;CACnD,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EACd,OAAQ,MAAgC,SAAS;CACnD;AACF"}
@@ -0,0 +1,25 @@
1
+ //#region src/services/processLiveness/index.ts
2
+ /**
3
+ * Is a process still running?
4
+ *
5
+ * Signal 0 performs the permission and existence check without delivering a
6
+ * signal. EPERM means the process exists but belongs to another user, which
7
+ * still counts as alive.
8
+ */
9
+ function isProcessAlive(pid) {
10
+ try {
11
+ process.kill(pid, 0);
12
+ return true;
13
+ } catch (error) {
14
+ return error.code === "EPERM";
15
+ }
16
+ }
17
+ //#endregion
18
+ Object.defineProperty(exports, "isProcessAlive", {
19
+ enumerable: true,
20
+ get: function() {
21
+ return isProcessAlive;
22
+ }
23
+ });
24
+
25
+ //# sourceMappingURL=processLiveness-umpNgsPR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processLiveness-umpNgsPR.cjs","names":[],"sources":["../src/services/processLiveness/index.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,KAAsB;CACnD,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EACd,OAAQ,MAAgC,SAAS;CACnD;AACF"}
@@ -0,0 +1,14 @@
1
+ //#region src/constants/promptGuidelines.d.ts
2
+ /**
3
+ * Cross-call behaviour the schema cannot express.
4
+ *
5
+ * Every rule lives in exactly one surface. Argument-site mechanics belong to
6
+ * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy
7
+ * and session scoping belong to the tool description, and general delegation
8
+ * judgement belongs to the Team orchestrator prompt. What is left here is what
9
+ * none of those three can carry: how calls should be sequenced across a turn.
10
+ */
11
+ declare const DEFAULT_PROMPT_GUIDELINES: string[];
12
+ //#endregion
13
+ export { DEFAULT_PROMPT_GUIDELINES as t };
14
+ //# sourceMappingURL=promptGuidelines-DaxWrqud.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines-DaxWrqud.d.mts","names":[],"sources":["../src/constants/promptGuidelines.ts"],"mappings":";;;;;;;;;;cASa"}
@@ -0,0 +1,26 @@
1
+ //#region src/constants/promptGuidelines.ts
2
+ /**
3
+ * Cross-call behaviour the schema cannot express.
4
+ *
5
+ * Every rule lives in exactly one surface. Argument-site mechanics belong to
6
+ * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy
7
+ * and session scoping belong to the tool description, and general delegation
8
+ * judgement belongs to the Team orchestrator prompt. What is left here is what
9
+ * none of those three can carry: how calls should be sequenced across a turn.
10
+ */
11
+ const DEFAULT_PROMPT_GUIDELINES = [
12
+ "Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.",
13
+ "Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.",
14
+ "When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.",
15
+ "Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.",
16
+ "upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.",
17
+ "Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.",
18
+ "Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.",
19
+ "Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.",
20
+ "Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.",
21
+ "When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Doom Task records delegated lifecycle and results on the task itself."
22
+ ];
23
+ //#endregion
24
+ export { DEFAULT_PROMPT_GUIDELINES as t };
25
+
26
+ //# sourceMappingURL=promptGuidelines-g4QT8GNM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines-g4QT8GNM.mjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Doom Task records delegated lifecycle and results on the task itself.',\n];\n"],"mappings":";;;;;;;;;;AASA,MAAa,4BAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,31 @@
1
+ //#region src/constants/promptGuidelines.ts
2
+ /**
3
+ * Cross-call behaviour the schema cannot express.
4
+ *
5
+ * Every rule lives in exactly one surface. Argument-site mechanics belong to
6
+ * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy
7
+ * and session scoping belong to the tool description, and general delegation
8
+ * judgement belongs to the Team orchestrator prompt. What is left here is what
9
+ * none of those three can carry: how calls should be sequenced across a turn.
10
+ */
11
+ const DEFAULT_PROMPT_GUIDELINES = [
12
+ "Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.",
13
+ "Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.",
14
+ "When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.",
15
+ "Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.",
16
+ "upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.",
17
+ "Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.",
18
+ "Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.",
19
+ "Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.",
20
+ "Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.",
21
+ "When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Doom Task records delegated lifecycle and results on the task itself."
22
+ ];
23
+ //#endregion
24
+ Object.defineProperty(exports, "DEFAULT_PROMPT_GUIDELINES", {
25
+ enumerable: true,
26
+ get: function() {
27
+ return DEFAULT_PROMPT_GUIDELINES;
28
+ }
29
+ });
30
+
31
+ //# sourceMappingURL=promptGuidelines-j_SZTzlH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines-j_SZTzlH.cjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Doom Task records delegated lifecycle and results on the task itself.',\n];\n"],"mappings":";;;;;;;;;;AASA,MAAa,4BAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,63 @@
1
+ import { i as isDelegationActive } from "./task-giCbpKzV.mjs";
2
+ import { t as isProcessAlive } from "./processLiveness-Ccd9wenT.mjs";
3
+ //#region src/services/reconcile/index.ts
4
+ const ERR_ORPHANED_BY_RESTART = "Delegation orphaned by harness restart";
5
+ const ERR_ORPHANED_BY_SESSION = "Delegation orphaned by session restart";
6
+ /**
7
+ * Recover tasks that no longer have anyone able to finish them.
8
+ *
9
+ * A subagent run dies with the harness that spawned it, but the store file
10
+ * outlives both, so a crash leaves tasks stuck in `in_progress` forever. Two
11
+ * kinds of delegation qualify as dead:
12
+ *
13
+ * - the owning pid is gone, so nothing is left to report a result;
14
+ * - the owning pid is *this* process, yet the request is absent from the live
15
+ * set. Settling requires an in-memory record, so an in-process session
16
+ * restart (which clears that map without writing to the store) leaves rows
17
+ * nothing can ever resolve. Checking pid liveness alone misses these, because
18
+ * the pid is our own and very much alive.
19
+ *
20
+ * Delegations owned by a different, still-running pid belong to a parallel
21
+ * session and are left untouched.
22
+ */
23
+ function reconcileOrphanedDelegations(document, now = (/* @__PURE__ */ new Date()).toISOString(), isAlive = isProcessAlive, self) {
24
+ const orphaned = [];
25
+ const tasks = document.tasks.map((task) => {
26
+ if (!isDelegationActive(task)) return task;
27
+ const pid = task.delegation?.pid;
28
+ if (pid === void 0) return task;
29
+ const abandonedHere = self !== void 0 && pid === self.pid && !self.liveRequestIds.has(task.delegation.requestId);
30
+ if (!abandonedHere && isAlive(pid)) return task;
31
+ const recovered = {
32
+ ...task,
33
+ status: "pending",
34
+ updatedAt: now,
35
+ delegation: {
36
+ ...task.delegation,
37
+ state: "failed",
38
+ endedAt: now,
39
+ result: {
40
+ status: "failed",
41
+ error: abandonedHere ? ERR_ORPHANED_BY_SESSION : ERR_ORPHANED_BY_RESTART
42
+ }
43
+ }
44
+ };
45
+ orphaned.push(recovered);
46
+ return recovered;
47
+ });
48
+ if (orphaned.length === 0) return {
49
+ document,
50
+ orphaned
51
+ };
52
+ return {
53
+ document: {
54
+ ...document,
55
+ tasks
56
+ },
57
+ orphaned
58
+ };
59
+ }
60
+ //#endregion
61
+ export { ERR_ORPHANED_BY_SESSION as n, reconcileOrphanedDelegations as r, ERR_ORPHANED_BY_RESTART as t };
62
+
63
+ //# sourceMappingURL=reconcile-BcD-hTbd.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile-BcD-hTbd.mjs","names":[],"sources":["../src/services/reconcile/index.ts"],"sourcesContent":["import { isDelegationActive, type Task, type TaskDocument } from '../../models/task';\nimport { isProcessAlive } from '../processLiveness';\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":";;;AAGA,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;;;;;;;;;;;;;;;;;AA8BvC,SAAgB,6BACd,UACA,uBAAc,IAAI,KAAK,EAAA,CAAE,YAAY,GACrC,UAAoC,gBACpC,MACiB;CACjB,MAAM,WAAmB,CAAC;CAE1B,MAAM,QAAQ,SAAS,MAAM,KAAK,SAAS;EACzC,IAAI,CAAC,mBAAmB,IAAI,GAAG,OAAO;EACtC,MAAM,MAAM,KAAK,YAAY;EAC7B,IAAI,QAAQ,KAAA,GAAW,OAAO;EAG9B,MAAM,gBADqB,SAAS,KAAA,KAAa,QAAQ,KAAK,OAClB,CAAC,KAAK,eAAe,IAAI,KAAK,WAAY,SAAS;EAC/F,IAAI,CAAC,iBAAiB,QAAQ,GAAG,GAAG,OAAO;EAE3C,MAAM,YAAkB;GACtB,GAAG;GACH,QAAQ;GACR,WAAW;GACX,YAAY;IACV,GAAG,KAAK;IACR,OAAO;IACP,SAAS;IACT,QAAQ;KACN,QAAQ;KACR,OAAO,gBAAgB,0BAA0B;IACnD;GACF;EACF;EACA,SAAS,KAAK,SAAS;EACvB,OAAO;CACT,CAAC;CAED,IAAI,SAAS,WAAW,GAAG,OAAO;EAAE;EAAU;CAAS;CACvD,OAAO;EAAE,UAAU;GAAE,GAAG;GAAU;EAAM;EAAG;CAAS;AACtD"}
@@ -0,0 +1,80 @@
1
+ const require_task = require("./task-CXF9VULl.cjs");
2
+ const require_processLiveness = require("./processLiveness-umpNgsPR.cjs");
3
+ //#region src/services/reconcile/index.ts
4
+ const ERR_ORPHANED_BY_RESTART = "Delegation orphaned by harness restart";
5
+ const ERR_ORPHANED_BY_SESSION = "Delegation orphaned by session restart";
6
+ /**
7
+ * Recover tasks that no longer have anyone able to finish them.
8
+ *
9
+ * A subagent run dies with the harness that spawned it, but the store file
10
+ * outlives both, so a crash leaves tasks stuck in `in_progress` forever. Two
11
+ * kinds of delegation qualify as dead:
12
+ *
13
+ * - the owning pid is gone, so nothing is left to report a result;
14
+ * - the owning pid is *this* process, yet the request is absent from the live
15
+ * set. Settling requires an in-memory record, so an in-process session
16
+ * restart (which clears that map without writing to the store) leaves rows
17
+ * nothing can ever resolve. Checking pid liveness alone misses these, because
18
+ * the pid is our own and very much alive.
19
+ *
20
+ * Delegations owned by a different, still-running pid belong to a parallel
21
+ * session and are left untouched.
22
+ */
23
+ function reconcileOrphanedDelegations(document, now = (/* @__PURE__ */ new Date()).toISOString(), isAlive = require_processLiveness.isProcessAlive, self) {
24
+ const orphaned = [];
25
+ const tasks = document.tasks.map((task) => {
26
+ if (!require_task.isDelegationActive(task)) return task;
27
+ const pid = task.delegation?.pid;
28
+ if (pid === void 0) return task;
29
+ const abandonedHere = self !== void 0 && pid === self.pid && !self.liveRequestIds.has(task.delegation.requestId);
30
+ if (!abandonedHere && isAlive(pid)) return task;
31
+ const recovered = {
32
+ ...task,
33
+ status: "pending",
34
+ updatedAt: now,
35
+ delegation: {
36
+ ...task.delegation,
37
+ state: "failed",
38
+ endedAt: now,
39
+ result: {
40
+ status: "failed",
41
+ error: abandonedHere ? ERR_ORPHANED_BY_SESSION : ERR_ORPHANED_BY_RESTART
42
+ }
43
+ }
44
+ };
45
+ orphaned.push(recovered);
46
+ return recovered;
47
+ });
48
+ if (orphaned.length === 0) return {
49
+ document,
50
+ orphaned
51
+ };
52
+ return {
53
+ document: {
54
+ ...document,
55
+ tasks
56
+ },
57
+ orphaned
58
+ };
59
+ }
60
+ //#endregion
61
+ Object.defineProperty(exports, "ERR_ORPHANED_BY_RESTART", {
62
+ enumerable: true,
63
+ get: function() {
64
+ return ERR_ORPHANED_BY_RESTART;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "ERR_ORPHANED_BY_SESSION", {
68
+ enumerable: true,
69
+ get: function() {
70
+ return ERR_ORPHANED_BY_SESSION;
71
+ }
72
+ });
73
+ Object.defineProperty(exports, "reconcileOrphanedDelegations", {
74
+ enumerable: true,
75
+ get: function() {
76
+ return reconcileOrphanedDelegations;
77
+ }
78
+ });
79
+
80
+ //# sourceMappingURL=reconcile-cRL0NjDr.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconcile-cRL0NjDr.cjs","names":["isProcessAlive","isDelegationActive"],"sources":["../src/services/reconcile/index.ts"],"sourcesContent":["import { isDelegationActive, type Task, type TaskDocument } from '../../models/task';\nimport { isProcessAlive } from '../processLiveness';\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":";;;AAGA,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;;;;;;;;;;;;;;;;;AA8BvC,SAAgB,6BACd,UACA,uBAAc,IAAI,KAAK,EAAA,CAAE,YAAY,GACrC,UAAoCA,wBAAAA,gBACpC,MACiB;CACjB,MAAM,WAAmB,CAAC;CAE1B,MAAM,QAAQ,SAAS,MAAM,KAAK,SAAS;EACzC,IAAI,CAACC,aAAAA,mBAAmB,IAAI,GAAG,OAAO;EACtC,MAAM,MAAM,KAAK,YAAY;EAC7B,IAAI,QAAQ,KAAA,GAAW,OAAO;EAG9B,MAAM,gBADqB,SAAS,KAAA,KAAa,QAAQ,KAAK,OAClB,CAAC,KAAK,eAAe,IAAI,KAAK,WAAY,SAAS;EAC/F,IAAI,CAAC,iBAAiB,QAAQ,GAAG,GAAG,OAAO;EAE3C,MAAM,YAAkB;GACtB,GAAG;GACH,QAAQ;GACR,WAAW;GACX,YAAY;IACV,GAAG,KAAK;IACR,OAAO;IACP,SAAS;IACT,QAAQ;KACN,QAAQ;KACR,OAAO,gBAAgB,0BAA0B;IACnD;GACF;EACF;EACA,SAAS,KAAK,SAAS;EACvB,OAAO;CACT,CAAC;CAED,IAAI,SAAS,WAAW,GAAG,OAAO;EAAE;EAAU;CAAS;CACvD,OAAO;EAAE,UAAU;GAAE,GAAG;GAAU;EAAM;EAAG;CAAS;AACtD"}
@@ -0,0 +1,345 @@
1
+ import { n as detectCycle } from "./taskGraph-BOQvT0-M.mjs";
2
+ import { i as isDelegationActive, t as DELETED_STATUS } from "./task-giCbpKzV.mjs";
3
+ import { r as isTransitionValid } from "./invariants-q_UamF7D.mjs";
4
+ //#region src/services/reducer/index.ts
5
+ /** Default board capacity when a caller does not provide a configured limit. */
6
+ const DEFAULT_REDUCER_MAX_TASKS = 15;
7
+ /** Bounds the work one call can do, and with it the size of one committed write. */
8
+ const MAX_UPSERT_ITEMS = 100;
9
+ /**
10
+ * A ref must start with a letter, which makes it structurally unconfusable with
11
+ * a stringified id. That is why resolving a dependency token is just a `typeof`
12
+ * check with no coercion heuristics.
13
+ */
14
+ const REF_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,31}$/;
15
+ /**
16
+ * Does this op represent state that must reach disk?
17
+ *
18
+ * The exhaustive switch is the point: a future `Op` variant cannot be added
19
+ * without declaring its persistence intent, so nothing silently starts or stops
20
+ * bumping `rev`.
21
+ */
22
+ function isCommittingOp(op) {
23
+ switch (op.kind) {
24
+ case "error":
25
+ case "list":
26
+ case "get": return false;
27
+ case "upsert": return op.items.some((item) => item.kind === "created" || item.kind === "updated");
28
+ case "delete":
29
+ case "clear": return true;
30
+ }
31
+ }
32
+ /** Joined per-item failures, for the thrown error when an upsert applied nothing. */
33
+ function formatUpsertFailure(op) {
34
+ return op.items.filter((item) => item.kind === "failed").map((item) => `item[${item.index}]: ${item.message}`).join("\n");
35
+ }
36
+ /** The single item's outcome, for callers that only ever send a batch of one. */
37
+ function singleItemOutcome(op) {
38
+ return op.kind === "upsert" ? op.items[0] : void 0;
39
+ }
40
+ function errorResult(document, message) {
41
+ return {
42
+ document,
43
+ op: {
44
+ kind: "error",
45
+ message
46
+ }
47
+ };
48
+ }
49
+ function sameNumberList(a, b) {
50
+ const x = a ?? [];
51
+ const y = b ?? [];
52
+ return x.length === y.length && x.every((value, index) => value === y[index]);
53
+ }
54
+ function sameRecord(a, b) {
55
+ return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
56
+ }
57
+ /**
58
+ * Did this update change anything? A no-effect update (status re-set to its
59
+ * current value, fields re-sent unchanged) reports "No change" rather than
60
+ * "Updated #N" — without the distinction a model can loop re-issuing the same
61
+ * call believing it never landed.
62
+ */
63
+ function taskChanged(before, after) {
64
+ return before.subject !== after.subject || before.status !== after.status || before.description !== after.description || before.activeForm !== after.activeForm || before.owner !== after.owner || !sameNumberList(before.blockedBy, after.blockedBy) || !sameRecord(before.metadata, after.metadata);
65
+ }
66
+ function withTasks(document, tasks, nextId = document.nextId) {
67
+ return {
68
+ ...document,
69
+ tasks,
70
+ nextId
71
+ };
72
+ }
73
+ /** Merge incoming metadata over a base; a `null` value deletes its key. */
74
+ function mergeMetadata(base, incoming) {
75
+ const merged = { ...base };
76
+ for (const [key, value] of Object.entries(incoming)) if (value === null) delete merged[key];
77
+ else merged[key] = value;
78
+ return Object.keys(merged).length ? merged : void 0;
79
+ }
80
+ /** Copy the optional scalar fields an item may set onto a task, in place. */
81
+ function assignScalars(target, item) {
82
+ if (item.subject !== void 0) target.subject = item.subject;
83
+ if (item.description !== void 0) target.description = item.description;
84
+ if (item.activeForm !== void 0) target.activeForm = item.activeForm;
85
+ if (item.owner !== void 0) target.owner = item.owner;
86
+ if (item.metadata !== void 0) {
87
+ const merged = mergeMetadata(target.metadata, item.metadata);
88
+ if (merged === void 0) delete target.metadata;
89
+ else target.metadata = merged;
90
+ }
91
+ }
92
+ function resolveDep(context, field, token) {
93
+ if (typeof token === "number") return {
94
+ ok: true,
95
+ id: token
96
+ };
97
+ if (!REF_PATTERN.test(token)) return {
98
+ ok: false,
99
+ message: `${field}: "${token}" is not a valid ref; pass an existing task id as a number`
100
+ };
101
+ const id = context.refIds.get(token);
102
+ if (id !== void 0) return {
103
+ ok: true,
104
+ id
105
+ };
106
+ const failedAt = context.failedRefs.get(token);
107
+ if (failedAt !== void 0) return {
108
+ ok: false,
109
+ message: `${field}: ref "${token}" refers to item[${failedAt}], which failed`
110
+ };
111
+ return {
112
+ ok: false,
113
+ message: `${field}: unknown ref "${token}" — a ref must be declared by an earlier entry in the same call`
114
+ };
115
+ }
116
+ function fail(message) {
117
+ return {
118
+ ok: false,
119
+ message
120
+ };
121
+ }
122
+ /** Structural checks that apply to every entry, whichever kind it is. */
123
+ function checkShape(context, item) {
124
+ if (item.ref !== void 0) {
125
+ if (item.id !== void 0) return "ref is only valid when creating a task; drop the id, or drop the ref";
126
+ if (!REF_PATTERN.test(item.ref)) return `ref "${item.ref}" is invalid: a ref must start with a letter and contain only letters, digits, - or _`;
127
+ if (context.refIds.get(item.ref) !== void 0 || context.failedRefs.has(item.ref)) return `duplicate ref "${item.ref}": it was already declared by an earlier entry`;
128
+ }
129
+ }
130
+ function applyCreateItem(context, item, index, now) {
131
+ if (item.subject === void 0) return fail("subject is required when the entry has no id");
132
+ if (!item.subject.trim()) return fail("subject must not be blank");
133
+ if (item.addBlockedBy !== void 0 || item.removeBlockedBy !== void 0) return fail("addBlockedBy / removeBlockedBy are only for an entry with an id; a new task uses blockedBy");
134
+ if (item.status === "deleted") return fail("cannot create a task with status deleted; create it, then use action delete");
135
+ if (context.tasks.filter((task) => task.status !== "deleted").length >= context.maxTasks) return fail(`task limit of ${context.maxTasks} reached; delete completed tasks first before creating new tasks`);
136
+ const blockedBy = [];
137
+ for (const token of item.blockedBy ?? []) {
138
+ const resolved = resolveDep(context, "blockedBy", token);
139
+ if (!resolved.ok) return fail(resolved.message);
140
+ const dep = context.tasks.find((task) => task.id === resolved.id);
141
+ if (!dep) return fail(`blockedBy: #${resolved.id} not found`);
142
+ if (dep.status === "deleted") return fail(`blockedBy: #${resolved.id} is deleted`);
143
+ if (!blockedBy.includes(resolved.id)) blockedBy.push(resolved.id);
144
+ }
145
+ const created = {
146
+ id: context.nextId,
147
+ subject: item.subject,
148
+ status: item.status ?? "pending",
149
+ createdAt: now,
150
+ updatedAt: now
151
+ };
152
+ assignScalars(created, item);
153
+ if (blockedBy.length) created.blockedBy = blockedBy;
154
+ context.nextId += 1;
155
+ context.tasks.push(created);
156
+ if (item.ref) context.refIds.set(item.ref, created.id);
157
+ return {
158
+ ok: true,
159
+ outcome: {
160
+ index,
161
+ kind: "created",
162
+ id: created.id,
163
+ subject: created.subject,
164
+ status: created.status,
165
+ ...item.ref ? { ref: item.ref } : {},
166
+ ...blockedBy.length ? { blockedBy } : {}
167
+ }
168
+ };
169
+ }
170
+ function applyUpdateItem(context, item, index, now) {
171
+ const id = item.id;
172
+ const at = context.tasks.findIndex((task) => task.id === id);
173
+ if (at === -1) return fail(`#${id} not found`);
174
+ if (item.blockedBy !== void 0) return fail("blockedBy is only for a new entry; use addBlockedBy / removeBlockedBy on an entry that has an id");
175
+ if (!(item.subject !== void 0 || item.description !== void 0 || item.activeForm !== void 0 || item.status !== void 0 || item.owner !== void 0 || item.metadata !== void 0 || Boolean(item.addBlockedBy?.length) || Boolean(item.removeBlockedBy?.length))) return fail("nothing to change: provide at least one of subject, description, activeForm, status, owner, metadata, addBlockedBy, or removeBlockedBy");
176
+ const current = context.tasks[at];
177
+ if (item.subject !== void 0 && !item.subject.trim()) return fail("subject must not be blank");
178
+ let newStatus = current.status;
179
+ if (item.status !== void 0) {
180
+ if (!isTransitionValid(current.status, item.status)) return fail(`illegal transition ${current.status} -> ${item.status}`);
181
+ newStatus = item.status;
182
+ }
183
+ let newBlockedBy = current.blockedBy ? [...current.blockedBy] : [];
184
+ for (const token of item.removeBlockedBy ?? []) {
185
+ const resolved = resolveDep(context, "removeBlockedBy", token);
186
+ if (!resolved.ok) return fail(resolved.message);
187
+ newBlockedBy = newBlockedBy.filter((dep) => dep !== resolved.id);
188
+ }
189
+ for (const token of item.addBlockedBy ?? []) {
190
+ const resolved = resolveDep(context, "addBlockedBy", token);
191
+ if (!resolved.ok) return fail(resolved.message);
192
+ if (resolved.id === id) return fail(`cannot block #${id} on itself`);
193
+ const dep = context.tasks.find((task) => task.id === resolved.id);
194
+ if (!dep) return fail(`addBlockedBy: #${resolved.id} not found`);
195
+ if (dep.status === "deleted") return fail(`addBlockedBy: #${resolved.id} is deleted`);
196
+ if (!newBlockedBy.includes(resolved.id)) newBlockedBy.push(resolved.id);
197
+ }
198
+ const updated = {
199
+ ...current,
200
+ status: newStatus
201
+ };
202
+ assignScalars(updated, item);
203
+ if (newBlockedBy.length) updated.blockedBy = newBlockedBy;
204
+ else delete updated.blockedBy;
205
+ const candidate = [...context.tasks];
206
+ candidate[at] = updated;
207
+ if (item.addBlockedBy?.length && detectCycle(candidate, id, newBlockedBy)) return fail("addBlockedBy would create a cycle in the blockedBy graph");
208
+ const changed = taskChanged(current, updated);
209
+ if (changed) updated.updatedAt = now;
210
+ context.tasks = candidate;
211
+ return {
212
+ ok: true,
213
+ outcome: changed ? {
214
+ index,
215
+ kind: "updated",
216
+ id,
217
+ fromStatus: current.status,
218
+ toStatus: newStatus
219
+ } : {
220
+ index,
221
+ kind: "unchanged",
222
+ id,
223
+ status: newStatus
224
+ }
225
+ };
226
+ }
227
+ /**
228
+ * Apply every entry in request order, threading the document.
229
+ *
230
+ * Each entry lands completely or not at all: a create whose dependencies fail
231
+ * is not kept dependency-free, because handing back an unblocked task the
232
+ * caller asked to be blocked is a lie it may immediately act on.
233
+ */
234
+ function applyUpsert(document, items, now, maxTasks) {
235
+ const context = {
236
+ tasks: [...document.tasks],
237
+ nextId: document.nextId,
238
+ maxTasks,
239
+ refIds: /* @__PURE__ */ new Map(),
240
+ failedRefs: /* @__PURE__ */ new Map()
241
+ };
242
+ const outcomes = [];
243
+ let applied = 0;
244
+ for (const [index, item] of items.entries()) {
245
+ const shapeError = checkShape(context, item);
246
+ const result = shapeError ? fail(shapeError) : item.id === void 0 ? applyCreateItem(context, item, index, now) : applyUpdateItem(context, item, index, now);
247
+ if (result.ok) {
248
+ outcomes.push(result.outcome);
249
+ applied += 1;
250
+ continue;
251
+ }
252
+ if (item.ref && REF_PATTERN.test(item.ref) && !context.refIds.has(item.ref)) context.failedRefs.set(item.ref, index);
253
+ outcomes.push({
254
+ index,
255
+ kind: "failed",
256
+ message: result.message,
257
+ ...item.id === void 0 ? {} : { id: item.id },
258
+ ...item.ref ? { ref: item.ref } : {}
259
+ });
260
+ }
261
+ return {
262
+ document: applied > 0 ? withTasks(document, context.tasks, context.nextId) : document,
263
+ op: {
264
+ kind: "upsert",
265
+ items: outcomes,
266
+ applied,
267
+ failed: outcomes.length - applied
268
+ }
269
+ };
270
+ }
271
+ /**
272
+ * Pure reducer: (document, action, params) -> (document, op).
273
+ *
274
+ * All validation is in-line: structural guards plus state-aware checks
275
+ * (transition legality, dangling or deleted blockedBy, self-block, cycles,
276
+ * in-flight delegations). The caller owns persistence and formatting.
277
+ */
278
+ function applyTaskMutation(document, action, params, now = (/* @__PURE__ */ new Date()).toISOString(), maxTasks = DEFAULT_REDUCER_MAX_TASKS) {
279
+ switch (action) {
280
+ case "upsert": {
281
+ const items = params.tasks;
282
+ if (!Array.isArray(items) || items.length === 0) return errorResult(document, "upsert requires a non-empty tasks array, e.g. {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Write tests\"}]}");
283
+ if (items.length > 100) return errorResult(document, `upsert accepts at most 100 entries per call (received ${items.length})`);
284
+ return applyUpsert(document, items, now, maxTasks);
285
+ }
286
+ case "list": return {
287
+ document,
288
+ op: {
289
+ kind: "list",
290
+ includeDeleted: params.includeDeleted === true,
291
+ ...params.status !== void 0 ? { statusFilter: params.status } : {}
292
+ }
293
+ };
294
+ case "get": {
295
+ if (params.id === void 0) return errorResult(document, "id required for get");
296
+ const task = document.tasks.find((candidate) => candidate.id === params.id);
297
+ if (!task) return errorResult(document, `#${params.id} not found`);
298
+ return {
299
+ document,
300
+ op: {
301
+ kind: "get",
302
+ task
303
+ }
304
+ };
305
+ }
306
+ case "delete": {
307
+ if (params.id === void 0) return errorResult(document, "id required for delete");
308
+ const index = document.tasks.findIndex((task) => task.id === params.id);
309
+ if (index === -1) return errorResult(document, `#${params.id} not found`);
310
+ const current = document.tasks[index];
311
+ if (current.status === "deleted") return errorResult(document, `#${current.id} is already deleted`);
312
+ if (isDelegationActive(current)) return errorResult(document, `#${current.id} has a running delegation — cancel it before deleting`);
313
+ const tasks = [...document.tasks];
314
+ tasks[index] = {
315
+ ...current,
316
+ status: DELETED_STATUS,
317
+ updatedAt: now
318
+ };
319
+ return {
320
+ document: withTasks(document, tasks),
321
+ op: {
322
+ kind: "delete",
323
+ id: current.id,
324
+ subject: current.subject
325
+ }
326
+ };
327
+ }
328
+ case "clear": {
329
+ const active = document.tasks.filter(isDelegationActive);
330
+ if (active.length > 0) return errorResult(document, `cannot clear while delegations are running (${active.map((task) => `#${task.id}`).join(", ")}) — cancel them first`);
331
+ const count = document.tasks.length;
332
+ return {
333
+ document: withTasks(document, [], 1),
334
+ op: {
335
+ kind: "clear",
336
+ count
337
+ }
338
+ };
339
+ }
340
+ }
341
+ }
342
+ //#endregion
343
+ export { isCommittingOp as a, formatUpsertFailure as i, REF_PATTERN as n, singleItemOutcome as o, applyTaskMutation as r, MAX_UPSERT_ITEMS as t };
344
+
345
+ //# sourceMappingURL=reducer-BEfJFM5L.mjs.map