@agimon-ai/doompi-task 0.0.1-alpha.9 → 0.0.1-alpha.91

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 (383) 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 -2
  9. package/dist/commands.d.mts +12 -6
  10. package/dist/commands.d.mts.map +1 -1
  11. package/dist/commands.mjs +2 -2
  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 -2
  17. package/dist/config.d.mts +2 -38
  18. package/dist/config.mjs +2 -2
  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/{delegation/manager.d.cts → index-3-3ZJlaH.d.mts} +42 -39
  63. package/dist/index-3-3ZJlaH.d.mts.map +1 -0
  64. package/dist/{store/taskStore.d.cts → index-B7oVjSey.d.mts} +16 -23
  65. package/dist/index-B7oVjSey.d.mts.map +1 -0
  66. package/dist/{store/reconcile.d.cts → index-BNMm9g0K.d.mts} +4 -4
  67. package/dist/index-BNMm9g0K.d.mts.map +1 -0
  68. package/dist/{tool/responseEnvelope.d.cts → index-C3DgOhEm.d.mts} +17 -5
  69. package/dist/index-C3DgOhEm.d.mts.map +1 -0
  70. package/dist/{config.d.cts → index-D4goIk4Z.d.mts} +8 -3
  71. package/dist/index-D4goIk4Z.d.mts.map +1 -0
  72. package/dist/{store/reducer.d.mts → index-DIpc6_uJ.d.mts} +5 -5
  73. package/dist/index-DIpc6_uJ.d.mts.map +1 -0
  74. package/dist/{store/paths.d.cts → index-XY9VPmfm.d.mts} +9 -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 -15
  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 -2
  88. package/dist/logSinkTelemetry.d.mts +7 -35
  89. package/dist/logSinkTelemetry.d.mts.map +1 -1
  90. package/dist/logSinkTelemetry.mjs +3 -2
  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/{store/processLiveness.d.mts → 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/{tool/schema.d.cts → task-DHSvdK6E.d.mts} +34 -18
  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/{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/{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 -12
  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/commands.cjs.map +0 -1
  232. package/dist/commands.d.cts +0 -14
  233. package/dist/commands.d.cts.map +0 -1
  234. package/dist/commands.mjs.map +0 -1
  235. package/dist/config.cjs.map +0 -1
  236. package/dist/config.d.cts.map +0 -1
  237. package/dist/config.d.mts.map +0 -1
  238. package/dist/config.mjs.map +0 -1
  239. package/dist/delegation/manager.cjs +0 -6
  240. package/dist/delegation/manager.cjs.map +0 -1
  241. package/dist/delegation/manager.d.cts.map +0 -1
  242. package/dist/delegation/manager.d.mts +0 -189
  243. package/dist/delegation/manager.d.mts.map +0 -1
  244. package/dist/delegation/manager.mjs +0 -6
  245. package/dist/delegation/manager.mjs.map +0 -1
  246. package/dist/extension.cjs +0 -3
  247. package/dist/extension.cjs.map +0 -1
  248. package/dist/extension.d.cts +0 -12
  249. package/dist/extension.d.cts.map +0 -1
  250. package/dist/extension.d.mts +0 -12
  251. package/dist/extension.d.mts.map +0 -1
  252. package/dist/extension.mjs +0 -3
  253. package/dist/extension.mjs.map +0 -1
  254. package/dist/extensions/doom.cjs +0 -2
  255. package/dist/extensions/doom.cjs.map +0 -1
  256. package/dist/extensions/doom.d.cts +0 -6
  257. package/dist/extensions/doom.d.cts.map +0 -1
  258. package/dist/extensions/doom.d.mts +0 -7
  259. package/dist/extensions/doom.d.mts.map +0 -1
  260. package/dist/extensions/doom.mjs +0 -2
  261. package/dist/extensions/doom.mjs.map +0 -1
  262. package/dist/extensions/pi.d.cts +0 -2
  263. package/dist/index.d.cts +0 -15
  264. package/dist/logSinkTelemetry.cjs.map +0 -1
  265. package/dist/logSinkTelemetry.d.cts +0 -51
  266. package/dist/logSinkTelemetry.d.cts.map +0 -1
  267. package/dist/logSinkTelemetry.mjs.map +0 -1
  268. package/dist/store/invariants.cjs +0 -2
  269. package/dist/store/invariants.cjs.map +0 -1
  270. package/dist/store/invariants.d.cts +0 -14
  271. package/dist/store/invariants.d.cts.map +0 -1
  272. package/dist/store/invariants.d.mts +0 -14
  273. package/dist/store/invariants.d.mts.map +0 -1
  274. package/dist/store/invariants.mjs +0 -2
  275. package/dist/store/invariants.mjs.map +0 -1
  276. package/dist/store/paths.cjs +0 -2
  277. package/dist/store/paths.cjs.map +0 -1
  278. package/dist/store/paths.d.cts.map +0 -1
  279. package/dist/store/paths.d.mts +0 -23
  280. package/dist/store/paths.d.mts.map +0 -1
  281. package/dist/store/paths.mjs +0 -2
  282. package/dist/store/paths.mjs.map +0 -1
  283. package/dist/store/processLiveness.cjs +0 -2
  284. package/dist/store/processLiveness.cjs.map +0 -1
  285. package/dist/store/processLiveness.d.cts +0 -12
  286. package/dist/store/processLiveness.d.cts.map +0 -1
  287. package/dist/store/processLiveness.d.mts.map +0 -1
  288. package/dist/store/processLiveness.mjs +0 -2
  289. package/dist/store/processLiveness.mjs.map +0 -1
  290. package/dist/store/reconcile.cjs +0 -2
  291. package/dist/store/reconcile.cjs.map +0 -1
  292. package/dist/store/reconcile.d.cts.map +0 -1
  293. package/dist/store/reconcile.d.mts +0 -34
  294. package/dist/store/reconcile.d.mts.map +0 -1
  295. package/dist/store/reconcile.mjs +0 -2
  296. package/dist/store/reconcile.mjs.map +0 -1
  297. package/dist/store/reducer.cjs +0 -3
  298. package/dist/store/reducer.cjs.map +0 -1
  299. package/dist/store/reducer.d.cts +0 -72
  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 +0 -3
  303. package/dist/store/reducer.mjs.map +0 -1
  304. package/dist/store/taskGraph.cjs +0 -2
  305. package/dist/store/taskGraph.cjs.map +0 -1
  306. package/dist/store/taskGraph.d.cts.map +0 -1
  307. package/dist/store/taskGraph.d.mts +0 -25
  308. package/dist/store/taskGraph.d.mts.map +0 -1
  309. package/dist/store/taskGraph.mjs +0 -2
  310. package/dist/store/taskGraph.mjs.map +0 -1
  311. package/dist/store/taskStore.cjs +0 -2
  312. package/dist/store/taskStore.cjs.map +0 -1
  313. package/dist/store/taskStore.d.cts.map +0 -1
  314. package/dist/store/taskStore.d.mts +0 -77
  315. package/dist/store/taskStore.d.mts.map +0 -1
  316. package/dist/store/taskStore.mjs +0 -2
  317. package/dist/store/taskStore.mjs.map +0 -1
  318. package/dist/store/types.cjs +0 -2
  319. package/dist/store/types.cjs.map +0 -1
  320. package/dist/store/types.d.cts +0 -165
  321. package/dist/store/types.d.cts.map +0 -1
  322. package/dist/store/types.d.mts.map +0 -1
  323. package/dist/store/types.mjs +0 -2
  324. package/dist/store/types.mjs.map +0 -1
  325. package/dist/tool/promptGuidelines.cjs +0 -2
  326. package/dist/tool/promptGuidelines.cjs.map +0 -1
  327. package/dist/tool/promptGuidelines.d.cts +0 -5
  328. package/dist/tool/promptGuidelines.d.cts.map +0 -1
  329. package/dist/tool/promptGuidelines.d.mts +0 -5
  330. package/dist/tool/promptGuidelines.d.mts.map +0 -1
  331. package/dist/tool/promptGuidelines.mjs +0 -2
  332. package/dist/tool/promptGuidelines.mjs.map +0 -1
  333. package/dist/tool/responseEnvelope.cjs +0 -6
  334. package/dist/tool/responseEnvelope.cjs.map +0 -1
  335. package/dist/tool/responseEnvelope.d.cts.map +0 -1
  336. package/dist/tool/responseEnvelope.d.mts +0 -39
  337. package/dist/tool/responseEnvelope.d.mts.map +0 -1
  338. package/dist/tool/responseEnvelope.mjs +0 -6
  339. package/dist/tool/responseEnvelope.mjs.map +0 -1
  340. package/dist/tool/schema.cjs +0 -2
  341. package/dist/tool/schema.cjs.map +0 -1
  342. package/dist/tool/schema.d.cts.map +0 -1
  343. package/dist/tool/schema.d.mts +0 -86
  344. package/dist/tool/schema.d.mts.map +0 -1
  345. package/dist/tool/schema.mjs +0 -2
  346. package/dist/tool/schema.mjs.map +0 -1
  347. package/dist/tool/taskTool.cjs +0 -3
  348. package/dist/tool/taskTool.cjs.map +0 -1
  349. package/dist/tool/taskTool.d.cts +0 -17
  350. package/dist/tool/taskTool.d.cts.map +0 -1
  351. package/dist/tool/taskTool.d.mts +0 -17
  352. package/dist/tool/taskTool.d.mts.map +0 -1
  353. package/dist/tool/taskTool.mjs +0 -3
  354. package/dist/tool/taskTool.mjs.map +0 -1
  355. package/dist/tui/format.cjs +0 -4
  356. package/dist/tui/format.cjs.map +0 -1
  357. package/dist/tui/format.d.cts +0 -62
  358. package/dist/tui/format.d.cts.map +0 -1
  359. package/dist/tui/format.d.mts +0 -62
  360. package/dist/tui/format.d.mts.map +0 -1
  361. package/dist/tui/format.mjs +0 -4
  362. package/dist/tui/format.mjs.map +0 -1
  363. package/dist/tui/selectors.cjs +0 -2
  364. package/dist/tui/selectors.cjs.map +0 -1
  365. package/dist/tui/selectors.d.cts.map +0 -1
  366. package/dist/tui/selectors.d.mts +0 -53
  367. package/dist/tui/selectors.d.mts.map +0 -1
  368. package/dist/tui/selectors.mjs +0 -2
  369. package/dist/tui/selectors.mjs.map +0 -1
  370. package/dist/tui/taskOverlay.cjs +0 -2
  371. package/dist/tui/taskOverlay.cjs.map +0 -1
  372. package/dist/tui/taskOverlay.d.cts.map +0 -1
  373. package/dist/tui/taskOverlay.d.mts +0 -38
  374. package/dist/tui/taskOverlay.d.mts.map +0 -1
  375. package/dist/tui/taskOverlay.mjs +0 -2
  376. package/dist/tui/taskOverlay.mjs.map +0 -1
  377. package/dist/tui/taskSpace.cjs +0 -5
  378. package/dist/tui/taskSpace.cjs.map +0 -1
  379. package/dist/tui/taskSpace.d.cts.map +0 -1
  380. package/dist/tui/taskSpace.d.mts +0 -61
  381. package/dist/tui/taskSpace.d.mts.map +0 -1
  382. package/dist/tui/taskSpace.mjs +0 -5
  383. package/dist/tui/taskSpace.mjs.map +0 -1
@@ -0,0 +1,661 @@
1
+ require("./delegation-LDpHP2CC.cjs");
2
+ const require_taskGraph = require("./taskGraph-BskRslrr.cjs");
3
+ const require_telemetry = require("./telemetry-I4md7Xzz.cjs");
4
+ const require_task = require("./task-CXF9VULl.cjs");
5
+ const require_reconcile = require("./reconcile-cRL0NjDr.cjs");
6
+ let _agimon_ai_doompi_core_delegation = require("@agimon-ai/doompi-core/delegation");
7
+ //#region src/services/delegation/index.ts
8
+ const NOTIFY_CUSTOM_TYPE = "doom-task-notify";
9
+ const BACKGROUND_WORK_PROVIDER = "doom-task";
10
+ const DEFAULT_STARTED_TIMEOUT_MS = 5e3;
11
+ const DEFAULT_RUN_TIMEOUT_MS = 12e5;
12
+ const DEFAULT_CANCEL_TIMEOUT_MS = 1e4;
13
+ const MAX_RUN_TIMEOUT_GRACE_MS = 6e4;
14
+ const MAX_STORED_OUTPUT = 4e3;
15
+ /**
16
+ * Cap on files rendered into a brief. Exported so the tool schema can state the
17
+ * same number to the model rather than restating it and drifting.
18
+ */
19
+ const MAX_BRIEF_NOTES = 1500;
20
+ const COMPLETED_STATE = "completed";
21
+ const FAILED_STATE = "failed";
22
+ const CANCELLED_STATE = "cancelled";
23
+ const TIMED_OUT_STATUS = "timed_out";
24
+ const DELETED_STATUS = "deleted";
25
+ const TASK_ID_ATTRIBUTE = "task.id";
26
+ const REQUEST_ID_ATTRIBUTE = "delegation.request_id";
27
+ const AGENT_ATTRIBUTE = "delegation.agent_name";
28
+ const PID_ATTRIBUTE = "delegation.pid";
29
+ const CONTEXT_PRESENT_ATTRIBUTE = "delegation.context_present";
30
+ const CONTEXT_FILE_COUNT_ATTRIBUTE = "delegation.context_file_count";
31
+ const CONTEXT_NOTES_LENGTH_ATTRIBUTE = "delegation.context_notes_length";
32
+ const BRIEF_LENGTH_ATTRIBUTE = "delegation.brief_length";
33
+ const TOOL_COUNT_ATTRIBUTE = "delegation.tool_count";
34
+ const DURATION_MS_ATTRIBUTE = "delegation.duration_ms";
35
+ const OUTCOME_ATTRIBUTE = "delegation.outcome";
36
+ const ERR_NO_RUNTIME = "No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.";
37
+ const ERR_CHILD_SESSION = "assign is only available in the main session. Update this task directly instead of re-delegating it.";
38
+ const ERR_CANCEL_UNACKNOWLEDGED = "Subagent did not acknowledge the cancel request";
39
+ function truncate(value, limit = MAX_STORED_OUTPUT) {
40
+ if (!value) return void 0;
41
+ return value.length <= limit ? value : `${value.slice(0, limit)}\n… (truncated)`;
42
+ }
43
+ function messageOf(error) {
44
+ return error instanceof Error ? error.message : String(error);
45
+ }
46
+ /** Normalize the parent context with host-owned path semantics. */
47
+ function briefContext(options, cwd, platform) {
48
+ const files = /* @__PURE__ */ new Set();
49
+ for (const entry of options.relevantFiles ?? []) {
50
+ if (files.size >= 12) break;
51
+ const normalized = platform.formatBriefPath(entry.trim(), cwd);
52
+ if (normalized && normalized !== ".") files.add(normalized);
53
+ }
54
+ return {
55
+ files: [...files],
56
+ notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES)
57
+ };
58
+ }
59
+ /**
60
+ * Build the brief handed to the subagent.
61
+ *
62
+ * Doom Team owns the child tool surface and the parent owns the task record.
63
+ * Keeping those responsibilities explicit prevents a child from attempting to
64
+ * call a task tool that is not loaded in its runtime, while still giving it a
65
+ * reliable path to ask the parent for a decision.
66
+ *
67
+ * The context pack is the parent's verified discovery handed over. The whole
68
+ * block is omitted when nothing was supplied: this brief is the child's whole
69
+ * starting context, so an empty section header is pure token cost.
70
+ */
71
+ function buildBrief(task, instructions, context) {
72
+ const sections = [`Task #${task.id}: ${task.subject}`];
73
+ if (task.description) sections.push(task.description);
74
+ if (instructions) sections.push(instructions);
75
+ if (context.files.length > 0 || context.notes) {
76
+ const contextLines = ["Parent context — consume before repository discovery:"];
77
+ if (context.files.length > 0) contextLines.push(`- Parent-verified files (read these first with direct reads): ${context.files.join(", ")}`);
78
+ if (context.notes) contextLines.push(`- Established facts (do not re-derive unless direct evidence contradicts them): ${context.notes}`);
79
+ contextLines.push("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.");
80
+ sections.push(contextLines.join("\n"));
81
+ }
82
+ sections.push("Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.");
83
+ return sections.join("\n\n");
84
+ }
85
+ /**
86
+ * Owns the lifecycle of tasks delegated to subagents.
87
+ *
88
+ * Delegation rides Team's injected Cordis service rather than spawning
89
+ * processes directly, so doom-task stays decoupled from the subagent runtime
90
+ * and degrades to a clear error when that service is not loaded.
91
+ *
92
+ * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so
93
+ * a delegation always has a deadline no matter which phase it is in. Losing
94
+ * that pairing is what previously left tasks running forever.
95
+ */
96
+ var DelegationManager = class DelegationManager {
97
+ options;
98
+ progress = /* @__PURE__ */ new Map();
99
+ pendingTasks = /* @__PURE__ */ new Map();
100
+ settlingRequests = /* @__PURE__ */ new Set();
101
+ timers = /* @__PURE__ */ new Map();
102
+ subscriptions = [];
103
+ service;
104
+ constructor(options) {
105
+ this.options = options;
106
+ }
107
+ setCwd(cwd) {
108
+ this.options.cwd = cwd;
109
+ }
110
+ now() {
111
+ return this.options.now?.() ?? (/* @__PURE__ */ new Date()).toISOString();
112
+ }
113
+ nowMs() {
114
+ return this.options.nowMs?.() ?? Date.now();
115
+ }
116
+ get runTimeoutMs() {
117
+ return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;
118
+ }
119
+ report(event, error, attributes) {
120
+ this.options.report?.error(event, error, attributes);
121
+ }
122
+ /** True in a session that is itself a subagent child. */
123
+ get isChildSession() {
124
+ return Boolean(this.options.platform.environment.PI_SUBAGENT_CHILD);
125
+ }
126
+ /** Live progress for a task, for the overlay to render. */
127
+ progressFor(task) {
128
+ const requestId = task.delegation?.requestId;
129
+ return requestId ? this.progress.get(requestId) : void 0;
130
+ }
131
+ /** Displayed runtime duration, rebased from the latest child observation. */
132
+ static elapsedMs(progress, nowMs = Date.now()) {
133
+ const baseline = progress.durationMs ?? 0;
134
+ const observedAt = progress.durationObservedAt ?? nowMs;
135
+ return baseline + Math.max(0, nowMs - observedAt);
136
+ }
137
+ /** Rebind to the active Team service without stacking lifecycle listeners. */
138
+ bind(ctx, service) {
139
+ this.unbind();
140
+ this.service = service;
141
+ this.subscriptions.push(ctx.on(_agimon_ai_doompi_core_delegation.DOOM_DELEGATION_ACCEPTED_EVENT, (event) => {
142
+ this.handleAccepted(event);
143
+ }), ctx.on(_agimon_ai_doompi_core_delegation.DOOM_DELEGATION_STARTED_EVENT, (event) => {
144
+ this.handleStarted(event);
145
+ }), ctx.on(_agimon_ai_doompi_core_delegation.DOOM_DELEGATION_UPDATED_EVENT, (event) => {
146
+ this.handleUpdate(event);
147
+ }), ctx.on(_agimon_ai_doompi_core_delegation.DOOM_DELEGATION_FINISHED_EVENT, (event) => {
148
+ this.handleResponse(event).catch((error) => {
149
+ this.report(require_telemetry.TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });
150
+ });
151
+ }));
152
+ return () => {
153
+ if (this.service === service) this.unbind();
154
+ };
155
+ }
156
+ /** Remove only the cross-package binding; task state and watchdogs remain live. */
157
+ unbind() {
158
+ for (const unsubscribe of this.subscriptions.splice(0)) unsubscribe();
159
+ this.service = void 0;
160
+ }
161
+ /** Items still in flight, surfaced so auto-stop will not kill the harness. */
162
+ listActiveWork() {
163
+ return [...this.pendingTasks.entries()].flatMap(([requestId, pending]) => pending.sessionId ? [{
164
+ id: `task-${pending.taskId}:${requestId}`,
165
+ sessionId: pending.sessionId
166
+ }] : []);
167
+ }
168
+ /**
169
+ * Return tasks nothing can finish to `pending`.
170
+ *
171
+ * The live request set is read inside the mutation so a delegation assigned
172
+ * while the lock was contended is not mistaken for a leftover.
173
+ */
174
+ async reconcile(isCurrent = () => true) {
175
+ const { value } = await this.options.store.mutate((document) => {
176
+ if (!isCurrent()) return { value: [] };
177
+ const result = require_reconcile.reconcileOrphanedDelegations(document, this.now(), void 0, {
178
+ pid: this.options.platform.processId,
179
+ liveRequestIds: new Set(this.pendingTasks.keys())
180
+ });
181
+ if (result.orphaned.length === 0) return { value: [] };
182
+ return {
183
+ document: result.document,
184
+ value: result.orphaned
185
+ };
186
+ });
187
+ if (!isCurrent()) return [];
188
+ for (const task of value) this.options.report?.warn(require_telemetry.TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ""), {
189
+ [TASK_ID_ATTRIBUTE]: task.id,
190
+ ...task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {},
191
+ ...task.delegation?.pid === void 0 ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }
192
+ });
193
+ if (value.length > 0) this.options.onChange?.();
194
+ return value;
195
+ }
196
+ async assign(taskId, options) {
197
+ const agent = options.agent?.trim();
198
+ if (!agent) return {
199
+ ok: false,
200
+ message: "agent required for assign"
201
+ };
202
+ if (this.isChildSession) return {
203
+ ok: false,
204
+ message: ERR_CHILD_SESSION
205
+ };
206
+ if (options.signal?.aborted) return {
207
+ ok: false,
208
+ message: "delegation cancelled before it started"
209
+ };
210
+ const requestId = this.options.platform.createRequestId();
211
+ const startedAt = this.now();
212
+ const sessionId = this.options.getSessionId?.();
213
+ const context = briefContext(options, this.options.cwd, this.options.platform);
214
+ const { value: outcome } = await this.options.store.mutate((current) => {
215
+ const index = current.tasks.findIndex((task) => task.id === taskId);
216
+ if (index === -1) return { value: {
217
+ ok: false,
218
+ message: `#${taskId} not found`
219
+ } };
220
+ const task = current.tasks[index];
221
+ if (task.status === DELETED_STATUS) return { value: {
222
+ ok: false,
223
+ message: `#${taskId} is deleted`
224
+ } };
225
+ if (task.status === COMPLETED_STATE) return { value: {
226
+ ok: false,
227
+ message: `#${taskId} is already completed`
228
+ } };
229
+ if (require_task.isDelegationActive(task)) return { value: {
230
+ ok: false,
231
+ message: `#${taskId} is already delegated to ${task.delegation?.agent}`
232
+ } };
233
+ if (require_taskGraph.isBlocked(current.tasks, task)) return { value: {
234
+ ok: false,
235
+ message: `#${taskId} is blocked by ${(task.blockedBy ?? []).map((id) => `#${id}`).join(", ")}`
236
+ } };
237
+ const delegation = {
238
+ requestId,
239
+ agent,
240
+ state: "requested",
241
+ pid: this.options.platform.processId,
242
+ startedAt,
243
+ ...sessionId ? { sessionId } : {},
244
+ ...options.model ? { model: options.model } : {}
245
+ };
246
+ const tasks = [...current.tasks];
247
+ tasks[index] = {
248
+ ...task,
249
+ owner: agent,
250
+ updatedAt: startedAt,
251
+ delegation
252
+ };
253
+ return {
254
+ document: {
255
+ ...current,
256
+ tasks
257
+ },
258
+ value: {
259
+ ok: true,
260
+ message: "",
261
+ task: tasks[index]
262
+ }
263
+ };
264
+ });
265
+ if (!outcome.ok || !outcome.task) return {
266
+ ok: false,
267
+ message: outcome.message
268
+ };
269
+ const contextNotesLength = context.notes?.length ?? 0;
270
+ this.pendingTasks.set(requestId, {
271
+ taskId,
272
+ sessionId
273
+ });
274
+ this.progress.set(requestId, {
275
+ agent,
276
+ contextFileCount: context.files.length,
277
+ contextNotesLength
278
+ });
279
+ this.armStartedTimeout(requestId);
280
+ this.options.onChange?.();
281
+ const request = {
282
+ requestId,
283
+ taskId,
284
+ agent,
285
+ ...options.inlineAgent ? { inlineAgent: options.inlineAgent } : {},
286
+ prompt: buildBrief(outcome.task, options.instructions, context),
287
+ ...options.context ? { context: options.context } : {},
288
+ cwd: this.options.cwd,
289
+ artifacts: true,
290
+ timeoutMs: this.runTimeoutMs,
291
+ runMode: "detached",
292
+ teamTask: {
293
+ id: String(outcome.task.id),
294
+ subject: outcome.task.subject
295
+ },
296
+ ...options.model ? { model: options.model } : {}
297
+ };
298
+ try {
299
+ const service = this.service;
300
+ if (!service) throw new Error(ERR_NO_RUNTIME);
301
+ service.request(request).catch((error) => {
302
+ this.report(require_telemetry.TASK_EVENT.delegationRequestFailed, error, {
303
+ [TASK_ID_ATTRIBUTE]: taskId,
304
+ [REQUEST_ID_ATTRIBUTE]: requestId,
305
+ [AGENT_ATTRIBUTE]: agent
306
+ });
307
+ this.settleDetached(requestId, FAILED_STATE, {
308
+ status: FAILED_STATE,
309
+ error: `Delegation request failed: ${messageOf(error)}`
310
+ });
311
+ });
312
+ } catch (error) {
313
+ this.report(require_telemetry.TASK_EVENT.delegationRequestFailed, error, {
314
+ [TASK_ID_ATTRIBUTE]: taskId,
315
+ [REQUEST_ID_ATTRIBUTE]: requestId,
316
+ [AGENT_ATTRIBUTE]: agent
317
+ });
318
+ const detail = messageOf(error);
319
+ await this.settle(requestId, FAILED_STATE, {
320
+ status: FAILED_STATE,
321
+ error: `Delegation request failed: ${detail}`
322
+ });
323
+ return {
324
+ ok: false,
325
+ message: `Could not dispatch #${taskId} to ${agent}: ${detail}`
326
+ };
327
+ }
328
+ this.options.report?.event(require_telemetry.TASK_EVENT.delegationAssigned, {
329
+ [TASK_ID_ATTRIBUTE]: taskId,
330
+ [REQUEST_ID_ATTRIBUTE]: requestId,
331
+ [AGENT_ATTRIBUTE]: agent,
332
+ [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,
333
+ [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,
334
+ [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,
335
+ [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length
336
+ });
337
+ return {
338
+ ok: true,
339
+ 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 your turn.`
340
+ };
341
+ }
342
+ async cancel(taskId) {
343
+ const task = this.options.store.read().tasks.find((candidate) => candidate.id === taskId);
344
+ if (!task) return {
345
+ ok: false,
346
+ message: `#${taskId} not found`
347
+ };
348
+ if (!task.delegation || !require_task.isDelegationActive(task)) return {
349
+ ok: false,
350
+ message: `#${taskId} has no running delegation`
351
+ };
352
+ const { requestId } = task.delegation;
353
+ this.service?.cancel({ requestId });
354
+ this.armCancelTimeout(requestId);
355
+ return {
356
+ ok: true,
357
+ message: `Cancelling delegation for #${taskId} (${task.delegation.agent})`
358
+ };
359
+ }
360
+ /** Settle without awaiting, reporting rather than dropping a failure. */
361
+ settleDetached(requestId, state, result, event = require_telemetry.TASK_EVENT.delegationSettleFailed) {
362
+ this.settle(requestId, state, result).catch((error) => {
363
+ this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });
364
+ });
365
+ }
366
+ /**
367
+ * Fail a delegation that nobody acknowledged.
368
+ *
369
+ * Provider loss or a stalled Team runtime can still leave a dispatched
370
+ * request silent. Without this acknowledgement deadline the task would sit
371
+ * in `requested` forever.
372
+ */
373
+ armStartedTimeout(requestId) {
374
+ this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {
375
+ this.settleDetached(requestId, FAILED_STATE, {
376
+ status: FAILED_STATE,
377
+ error: ERR_NO_RUNTIME
378
+ });
379
+ });
380
+ }
381
+ /**
382
+ * Bound a run that already started.
383
+ *
384
+ * The request carries the same budget, so in the normal case the runtime ends
385
+ * the run itself and reports a richer result. The grace period biases toward
386
+ * that answer; this timer only covers a runtime that goes silent, which is
387
+ * precisely the case where no response event will ever arrive.
388
+ */
389
+ armRunTimeout(requestId) {
390
+ const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);
391
+ this.armTimer(requestId, this.runTimeoutMs + grace, () => {
392
+ const taskId = this.pendingTasks.get(requestId)?.taskId;
393
+ const agent = this.progress.get(requestId)?.agent;
394
+ const error = /* @__PURE__ */ new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);
395
+ this.options.report?.warn(require_telemetry.TASK_EVENT.delegationTimedOut, error, {
396
+ ...taskId === void 0 ? {} : { [TASK_ID_ATTRIBUTE]: taskId },
397
+ [REQUEST_ID_ATTRIBUTE]: requestId,
398
+ ...agent ? { [AGENT_ATTRIBUTE]: agent } : {}
399
+ });
400
+ this.service?.cancel({
401
+ requestId,
402
+ reason: error.message
403
+ });
404
+ this.settleDetached(requestId, FAILED_STATE, {
405
+ status: TIMED_OUT_STATUS,
406
+ error: error.message
407
+ });
408
+ });
409
+ }
410
+ /**
411
+ * Guarantee a cancel reaches a terminal state.
412
+ *
413
+ * Calling the service is a request, not an outcome: a runtime that has
414
+ * already forgotten the request answers nothing at all. The window still
415
+ * favours a real response, which carries the run's partial output.
416
+ */
417
+ armCancelTimeout(requestId) {
418
+ if (!this.pendingTasks.has(requestId)) return;
419
+ this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {
420
+ this.settleDetached(requestId, CANCELLED_STATE, {
421
+ status: CANCELLED_STATE,
422
+ error: ERR_CANCEL_UNACKNOWLEDGED
423
+ });
424
+ });
425
+ }
426
+ armTimer(requestId, delayMs, onFire) {
427
+ this.clearTimer(requestId);
428
+ const timer = setTimeout(onFire, delayMs);
429
+ timer.unref?.();
430
+ this.timers.set(requestId, timer);
431
+ }
432
+ clearTimer(requestId) {
433
+ const timer = this.timers.get(requestId);
434
+ if (timer) clearTimeout(timer);
435
+ this.timers.delete(requestId);
436
+ }
437
+ /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */
438
+ handleAccepted(event) {
439
+ if (!this.pendingTasks.has(event.requestId)) return;
440
+ this.armRunTimeout(event.requestId);
441
+ }
442
+ handleStarted(event) {
443
+ const { runId } = event;
444
+ const taskId = this.pendingTasks.get(event.requestId)?.taskId;
445
+ if (taskId === void 0) return;
446
+ this.armRunTimeout(event.requestId);
447
+ const existing = this.progress.get(event.requestId);
448
+ if (existing) this.progress.set(event.requestId, {
449
+ ...existing,
450
+ durationMs: existing.durationMs ?? 0,
451
+ durationObservedAt: existing.durationObservedAt ?? this.nowMs()
452
+ });
453
+ this.options.store.mutate((document) => this.patchDelegation(document, event.requestId, (task, delegation) => ({
454
+ ...task,
455
+ status: task.status === COMPLETED_STATE ? task.status : "in_progress",
456
+ delegation: {
457
+ ...delegation,
458
+ state: "running",
459
+ startedAt: delegation.startedAt ?? this.now(),
460
+ ...runId ? { runId } : {}
461
+ }
462
+ }))).then(() => this.options.onChange?.()).catch((error) => {
463
+ this.report(require_telemetry.TASK_EVENT.delegationStartFailed, error, {
464
+ [TASK_ID_ATTRIBUTE]: taskId,
465
+ [REQUEST_ID_ATTRIBUTE]: event.requestId
466
+ });
467
+ });
468
+ }
469
+ handleUpdate(event) {
470
+ const existing = this.progress.get(event.requestId);
471
+ if (!existing) return;
472
+ const observedAt = this.nowMs();
473
+ const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);
474
+ const hasDuration = event.durationMs !== void 0;
475
+ this.progress.set(event.requestId, {
476
+ ...existing,
477
+ currentTool: event.currentTool ?? existing.currentTool,
478
+ toolCount: event.toolCount === void 0 ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),
479
+ tokens: event.tokens === void 0 ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),
480
+ durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs) : existing.durationMs,
481
+ durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt
482
+ });
483
+ this.options.onChange?.();
484
+ }
485
+ async handleResponse(event) {
486
+ if (!this.pendingTasks.has(event.requestId)) return;
487
+ const state = event.status === COMPLETED_STATE && !event.error ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;
488
+ await this.settle(event.requestId, state, {
489
+ status: event.status,
490
+ error: event.error,
491
+ output: truncate(event.output),
492
+ outputPath: event.outputPath,
493
+ sessionFile: event.sessionFile,
494
+ durationMs: event.durationMs,
495
+ toolCount: event.toolCount
496
+ });
497
+ }
498
+ /**
499
+ * Apply the terminal state of a delegation and tell the model about it.
500
+ *
501
+ * A cancelled run returns the task to `pending` (the work is still wanted,
502
+ * just not by that agent); a failure marks it `failed` so it stays visible
503
+ * rather than silently rejoining the backlog.
504
+ *
505
+ * The request is claimed in `settlingRequests` while it remains published as
506
+ * active work. It is removed only after the terminal state and model notification
507
+ * have been handed off, so an auto-stop observer cannot end the session between
508
+ * receiving the result and delivering it to the model.
509
+ */
510
+ async settle(requestId, state, result) {
511
+ const pending = this.pendingTasks.get(requestId);
512
+ if (!pending || this.settlingRequests.has(requestId)) return;
513
+ this.settlingRequests.add(requestId);
514
+ this.clearTimer(requestId);
515
+ const { taskId } = pending;
516
+ const progress = this.progress.get(requestId);
517
+ try {
518
+ const endedAt = this.now();
519
+ let task;
520
+ try {
521
+ const { value } = await this.options.store.mutate((document) => this.patchDelegation(document, requestId, (current, delegation) => ({
522
+ ...current,
523
+ status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? "pending" : FAILED_STATE,
524
+ updatedAt: endedAt,
525
+ delegation: {
526
+ ...delegation,
527
+ state,
528
+ endedAt,
529
+ ...result ? { result } : {}
530
+ }
531
+ })));
532
+ task = value;
533
+ } catch (error) {
534
+ this.report(require_telemetry.TASK_EVENT.delegationSettleFailed, error, {
535
+ [TASK_ID_ATTRIBUTE]: taskId,
536
+ [REQUEST_ID_ATTRIBUTE]: requestId
537
+ });
538
+ }
539
+ const agent = task?.delegation?.agent ?? progress?.agent ?? "subagent";
540
+ const subject = task?.subject ?? `#${taskId}`;
541
+ this.options.report?.event(require_telemetry.TASK_EVENT.delegationCompleted, {
542
+ [TASK_ID_ATTRIBUTE]: taskId,
543
+ [REQUEST_ID_ATTRIBUTE]: requestId,
544
+ [AGENT_ATTRIBUTE]: agent,
545
+ [OUTCOME_ATTRIBUTE]: state,
546
+ [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,
547
+ [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,
548
+ [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,
549
+ ...result?.toolCount === void 0 ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount },
550
+ ...result?.durationMs === void 0 ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }
551
+ });
552
+ const listComplete = state === COMPLETED_STATE && task !== void 0 && require_taskGraph.isTaskListComplete(this.options.store.snapshot.tasks);
553
+ this.notifyModel(state, taskId, subject, agent, result, listComplete);
554
+ } finally {
555
+ this.pendingTasks.delete(requestId);
556
+ this.progress.delete(requestId);
557
+ this.settlingRequests.delete(requestId);
558
+ this.options.onChange?.();
559
+ }
560
+ }
561
+ notifyModel(state, taskId, subject, agent, result, listComplete) {
562
+ const notify = this.options.notify;
563
+ if (!notify) return;
564
+ const lines = [state === COMPLETED_STATE ? `Subagent ${agent} completed task #${taskId}: ${subject}` : state === CANCELLED_STATE ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)` : `Subagent ${agent} failed task #${taskId}: ${subject}`];
565
+ if (listComplete) lines.push("", "All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.");
566
+ if (result?.error) lines.push(`Error: ${result.error}`);
567
+ if (result?.output) lines.push("", result.output);
568
+ if (result?.outputPath) lines.push("", `Full output: ${result.outputPath}`);
569
+ try {
570
+ notify({
571
+ customType: NOTIFY_CUSTOM_TYPE,
572
+ content: lines.join("\n"),
573
+ display: true
574
+ }, {
575
+ triggerTurn: true,
576
+ deliverAs: "steer"
577
+ });
578
+ } catch (error) {
579
+ this.options.onNotifyError(error, taskId);
580
+ }
581
+ }
582
+ /**
583
+ * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.
584
+ *
585
+ * Terminal delegations are left alone. The document here is the freshest one,
586
+ * read under the store lock, which is the only place the check is meaningful:
587
+ * a `started` event can land after a cancel already settled the run, and
588
+ * without this guard its write would resurrect a delegation that nothing is
589
+ * tracking any more.
590
+ */
591
+ patchDelegation(document, requestId, patch) {
592
+ const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);
593
+ if (index === -1) return { value: void 0 };
594
+ const task = document.tasks[index];
595
+ if (!require_task.isDelegationActive(task)) return { value: task };
596
+ const updated = patch(task, task.delegation);
597
+ if (updated === task) return { value: task };
598
+ const tasks = [...document.tasks];
599
+ tasks[index] = updated;
600
+ return {
601
+ document: {
602
+ ...document,
603
+ tasks
604
+ },
605
+ value: updated
606
+ };
607
+ }
608
+ dispose() {
609
+ this.unbind();
610
+ this.reset();
611
+ }
612
+ /** Clear one Pi session's transient delegation state without losing service injection. */
613
+ reset() {
614
+ const changed = this.pendingTasks.size > 0 || this.progress.size > 0;
615
+ for (const timer of this.timers.values()) clearTimeout(timer);
616
+ this.timers.clear();
617
+ this.pendingTasks.clear();
618
+ this.settlingRequests.clear();
619
+ this.progress.clear();
620
+ if (changed) this.options.onChange?.();
621
+ }
622
+ };
623
+ //#endregion
624
+ Object.defineProperty(exports, "BACKGROUND_WORK_PROVIDER", {
625
+ enumerable: true,
626
+ get: function() {
627
+ return BACKGROUND_WORK_PROVIDER;
628
+ }
629
+ });
630
+ Object.defineProperty(exports, "DelegationManager", {
631
+ enumerable: true,
632
+ get: function() {
633
+ return DelegationManager;
634
+ }
635
+ });
636
+ Object.defineProperty(exports, "ERR_CANCEL_UNACKNOWLEDGED", {
637
+ enumerable: true,
638
+ get: function() {
639
+ return ERR_CANCEL_UNACKNOWLEDGED;
640
+ }
641
+ });
642
+ Object.defineProperty(exports, "ERR_CHILD_SESSION", {
643
+ enumerable: true,
644
+ get: function() {
645
+ return ERR_CHILD_SESSION;
646
+ }
647
+ });
648
+ Object.defineProperty(exports, "ERR_NO_RUNTIME", {
649
+ enumerable: true,
650
+ get: function() {
651
+ return ERR_NO_RUNTIME;
652
+ }
653
+ });
654
+ Object.defineProperty(exports, "NOTIFY_CUSTOM_TYPE", {
655
+ enumerable: true,
656
+ get: function() {
657
+ return NOTIFY_CUSTOM_TYPE;
658
+ }
659
+ });
660
+
661
+ //# sourceMappingURL=delegation-3hMdTFXF.cjs.map