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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/README.md +39 -12
  2. package/dist/adapters/pi/extension.cjs +3 -0
  3. package/dist/adapters/pi/extension.cjs.map +1 -0
  4. package/dist/adapters/pi/extension.d.cts +12 -0
  5. package/dist/adapters/pi/extension.d.cts.map +1 -0
  6. package/dist/adapters/pi/extension.d.mts +12 -0
  7. package/dist/adapters/pi/extension.d.mts.map +1 -0
  8. package/dist/adapters/pi/extension.mjs +3 -0
  9. package/dist/adapters/pi/extension.mjs.map +1 -0
  10. package/dist/adapters/store/paths.cjs +2 -0
  11. package/dist/adapters/store/paths.cjs.map +1 -0
  12. package/dist/adapters/store/paths.d.cts +26 -0
  13. package/dist/adapters/store/paths.d.cts.map +1 -0
  14. package/dist/adapters/store/paths.d.mts +26 -0
  15. package/dist/adapters/store/paths.d.mts.map +1 -0
  16. package/dist/adapters/store/paths.mjs +2 -0
  17. package/dist/adapters/store/paths.mjs.map +1 -0
  18. package/dist/adapters/store/taskStore.cjs +2 -0
  19. package/dist/adapters/store/taskStore.cjs.map +1 -0
  20. package/dist/adapters/store/taskStore.d.cts +87 -0
  21. package/dist/adapters/store/taskStore.d.cts.map +1 -0
  22. package/dist/adapters/store/taskStore.d.mts +87 -0
  23. package/dist/adapters/store/taskStore.d.mts.map +1 -0
  24. package/dist/adapters/store/taskStore.mjs +2 -0
  25. package/dist/adapters/store/taskStore.mjs.map +1 -0
  26. package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
  27. package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
  28. package/dist/adapters/telemetry/logSinkTelemetry.d.cts +52 -0
  29. package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
  30. package/dist/adapters/telemetry/logSinkTelemetry.d.mts +52 -0
  31. package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
  32. package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
  33. package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
  34. package/dist/commands/index.cjs +2 -0
  35. package/dist/commands/index.cjs.map +1 -0
  36. package/dist/commands/index.d.cts +15 -0
  37. package/dist/commands/index.d.cts.map +1 -0
  38. package/dist/commands/index.d.mts +15 -0
  39. package/dist/commands/index.d.mts.map +1 -0
  40. package/dist/commands/index.mjs +2 -0
  41. package/dist/commands/index.mjs.map +1 -0
  42. package/dist/commands/task/promptGuidelines.cjs +2 -0
  43. package/dist/commands/task/promptGuidelines.cjs.map +1 -0
  44. package/dist/commands/task/promptGuidelines.d.cts +5 -0
  45. package/dist/commands/task/promptGuidelines.d.cts.map +1 -0
  46. package/dist/commands/task/promptGuidelines.d.mts +5 -0
  47. package/dist/commands/task/promptGuidelines.d.mts.map +1 -0
  48. package/dist/commands/task/promptGuidelines.mjs +2 -0
  49. package/dist/commands/task/promptGuidelines.mjs.map +1 -0
  50. package/dist/commands/task/responseEnvelope.cjs +7 -0
  51. package/dist/commands/task/responseEnvelope.cjs.map +1 -0
  52. package/dist/commands/task/responseEnvelope.d.cts +51 -0
  53. package/dist/commands/task/responseEnvelope.d.cts.map +1 -0
  54. package/dist/commands/task/responseEnvelope.d.mts +51 -0
  55. package/dist/commands/task/responseEnvelope.d.mts.map +1 -0
  56. package/dist/commands/task/responseEnvelope.mjs +7 -0
  57. package/dist/commands/task/responseEnvelope.mjs.map +1 -0
  58. package/dist/commands/task/taskTool.cjs +3 -0
  59. package/dist/commands/task/taskTool.cjs.map +1 -0
  60. package/dist/commands/task/taskTool.d.cts +19 -0
  61. package/dist/commands/task/taskTool.d.cts.map +1 -0
  62. package/dist/commands/task/taskTool.d.mts +19 -0
  63. package/dist/commands/task/taskTool.d.mts.map +1 -0
  64. package/dist/commands/task/taskTool.mjs +3 -0
  65. package/dist/commands/task/taskTool.mjs.map +1 -0
  66. package/dist/commands.cjs +1 -2
  67. package/dist/commands.d.cts +2 -14
  68. package/dist/commands.d.mts +2 -14
  69. package/dist/commands.mjs +1 -2
  70. package/dist/config.cjs +1 -2
  71. package/dist/config.d.cts +2 -38
  72. package/dist/config.d.mts +2 -38
  73. package/dist/config.mjs +1 -2
  74. package/dist/delegation/manager.cjs +1 -6
  75. package/dist/delegation/manager.d.cts +2 -189
  76. package/dist/delegation/manager.d.mts +2 -189
  77. package/dist/delegation/manager.mjs +1 -6
  78. package/dist/extension.cjs +1 -3
  79. package/dist/extension.d.cts +2 -12
  80. package/dist/extension.d.mts +2 -12
  81. package/dist/extension.mjs +1 -3
  82. package/dist/extensions/doom.cjs +1 -1
  83. package/dist/extensions/doom.cjs.map +1 -1
  84. package/dist/extensions/doom.mjs +1 -1
  85. package/dist/extensions/doom.mjs.map +1 -1
  86. package/dist/extensions/pi.cjs +1 -1
  87. package/dist/extensions/pi.cjs.map +1 -1
  88. package/dist/extensions/pi.d.cts +1 -1
  89. package/dist/extensions/pi.d.mts +1 -1
  90. package/dist/extensions/pi.mjs +1 -1
  91. package/dist/extensions/pi.mjs.map +1 -1
  92. package/dist/index.cjs +1 -1
  93. package/dist/index.d.cts +15 -14
  94. package/dist/index.d.mts +15 -14
  95. package/dist/index.mjs +1 -1
  96. package/dist/logSinkTelemetry.cjs +1 -2
  97. package/dist/logSinkTelemetry.d.cts +2 -51
  98. package/dist/logSinkTelemetry.d.mts +2 -51
  99. package/dist/logSinkTelemetry.mjs +1 -2
  100. package/dist/schemas/task.cjs +2 -0
  101. package/dist/schemas/task.cjs.map +1 -0
  102. package/dist/schemas/task.d.cts +103 -0
  103. package/dist/schemas/task.d.cts.map +1 -0
  104. package/dist/schemas/task.d.mts +103 -0
  105. package/dist/schemas/task.d.mts.map +1 -0
  106. package/dist/schemas/task.mjs +2 -0
  107. package/dist/schemas/task.mjs.map +1 -0
  108. package/dist/services/delegation/manager.cjs +6 -0
  109. package/dist/services/delegation/manager.cjs.map +1 -0
  110. package/dist/services/delegation/manager.d.cts +188 -0
  111. package/dist/services/delegation/manager.d.cts.map +1 -0
  112. package/dist/services/delegation/manager.d.mts +188 -0
  113. package/dist/services/delegation/manager.d.mts.map +1 -0
  114. package/dist/services/delegation/manager.mjs +6 -0
  115. package/dist/services/delegation/manager.mjs.map +1 -0
  116. package/dist/services/narration/taskNarration.cjs +2 -0
  117. package/dist/services/narration/taskNarration.cjs.map +1 -0
  118. package/dist/services/narration/taskNarration.mjs +2 -0
  119. package/dist/services/narration/taskNarration.mjs.map +1 -0
  120. package/dist/services/store/invariants.cjs +2 -0
  121. package/dist/services/store/invariants.cjs.map +1 -0
  122. package/dist/services/store/invariants.d.cts +14 -0
  123. package/dist/services/store/invariants.d.cts.map +1 -0
  124. package/dist/services/store/invariants.d.mts +14 -0
  125. package/dist/services/store/invariants.d.mts.map +1 -0
  126. package/dist/services/store/invariants.mjs +2 -0
  127. package/dist/services/store/invariants.mjs.map +1 -0
  128. package/dist/services/store/paths.cjs +1 -0
  129. package/dist/services/store/paths.mjs +1 -0
  130. package/dist/services/store/processLiveness.cjs +2 -0
  131. package/dist/services/store/processLiveness.cjs.map +1 -0
  132. package/dist/services/store/processLiveness.d.cts +12 -0
  133. package/dist/services/store/processLiveness.d.cts.map +1 -0
  134. package/dist/services/store/processLiveness.d.mts +12 -0
  135. package/dist/services/store/processLiveness.d.mts.map +1 -0
  136. package/dist/services/store/processLiveness.mjs +2 -0
  137. package/dist/services/store/processLiveness.mjs.map +1 -0
  138. package/dist/services/store/reconcile.cjs +2 -0
  139. package/dist/services/store/reconcile.cjs.map +1 -0
  140. package/dist/services/store/reconcile.d.cts +34 -0
  141. package/dist/services/store/reconcile.d.cts.map +1 -0
  142. package/dist/services/store/reconcile.d.mts +34 -0
  143. package/dist/services/store/reconcile.d.mts.map +1 -0
  144. package/dist/services/store/reconcile.mjs +2 -0
  145. package/dist/services/store/reconcile.mjs.map +1 -0
  146. package/dist/services/store/reducer.cjs +3 -0
  147. package/dist/services/store/reducer.cjs.map +1 -0
  148. package/dist/services/store/reducer.d.cts +72 -0
  149. package/dist/services/store/reducer.d.cts.map +1 -0
  150. package/dist/services/store/reducer.d.mts +72 -0
  151. package/dist/services/store/reducer.d.mts.map +1 -0
  152. package/dist/services/store/reducer.mjs +3 -0
  153. package/dist/services/store/reducer.mjs.map +1 -0
  154. package/dist/services/store/taskGraph.cjs +2 -0
  155. package/dist/services/store/taskGraph.cjs.map +1 -0
  156. package/dist/services/store/taskGraph.d.cts +25 -0
  157. package/dist/services/store/taskGraph.d.cts.map +1 -0
  158. package/dist/services/store/taskGraph.d.mts +25 -0
  159. package/dist/services/store/taskGraph.d.mts.map +1 -0
  160. package/dist/services/store/taskGraph.mjs +2 -0
  161. package/dist/services/store/taskGraph.mjs.map +1 -0
  162. package/dist/services/store/taskStore.cjs +1 -0
  163. package/dist/services/store/taskStore.d.cts +2 -0
  164. package/dist/services/store/taskStore.d.mts +2 -0
  165. package/dist/services/store/taskStore.mjs +1 -0
  166. package/dist/services/store/types.cjs +2 -0
  167. package/dist/services/store/types.cjs.map +1 -0
  168. package/dist/services/store/types.d.cts +177 -0
  169. package/dist/services/store/types.d.cts.map +1 -0
  170. package/dist/services/store/types.d.mts +177 -0
  171. package/dist/services/store/types.d.mts.map +1 -0
  172. package/dist/services/store/types.mjs +2 -0
  173. package/dist/services/store/types.mjs.map +1 -0
  174. package/dist/store/invariants.cjs +1 -2
  175. package/dist/store/invariants.d.cts +2 -14
  176. package/dist/store/invariants.d.mts +2 -14
  177. package/dist/store/invariants.mjs +1 -2
  178. package/dist/store/paths.cjs +1 -2
  179. package/dist/store/paths.d.cts +2 -23
  180. package/dist/store/paths.d.mts +2 -23
  181. package/dist/store/paths.mjs +1 -2
  182. package/dist/store/processLiveness.cjs +1 -2
  183. package/dist/store/processLiveness.d.cts +2 -12
  184. package/dist/store/processLiveness.d.mts +2 -12
  185. package/dist/store/processLiveness.mjs +1 -2
  186. package/dist/store/reconcile.cjs +1 -2
  187. package/dist/store/reconcile.d.cts +2 -34
  188. package/dist/store/reconcile.d.mts +2 -34
  189. package/dist/store/reconcile.mjs +1 -2
  190. package/dist/store/reducer.cjs +1 -3
  191. package/dist/store/reducer.d.cts +2 -72
  192. package/dist/store/reducer.d.mts +2 -72
  193. package/dist/store/reducer.mjs +1 -3
  194. package/dist/store/taskGraph.cjs +1 -2
  195. package/dist/store/taskGraph.d.cts +2 -25
  196. package/dist/store/taskGraph.d.mts +2 -25
  197. package/dist/store/taskGraph.mjs +1 -2
  198. package/dist/store/taskStore.cjs +1 -2
  199. package/dist/store/taskStore.d.cts +3 -77
  200. package/dist/store/taskStore.d.mts +3 -77
  201. package/dist/store/taskStore.mjs +1 -2
  202. package/dist/store/types.cjs +1 -2
  203. package/dist/store/types.d.cts +2 -165
  204. package/dist/store/types.d.mts +2 -165
  205. package/dist/store/types.mjs +1 -2
  206. package/dist/tool/promptGuidelines.cjs +1 -2
  207. package/dist/tool/promptGuidelines.d.cts +2 -5
  208. package/dist/tool/promptGuidelines.d.mts +2 -5
  209. package/dist/tool/promptGuidelines.mjs +1 -2
  210. package/dist/tool/responseEnvelope.cjs +1 -6
  211. package/dist/tool/responseEnvelope.d.cts +2 -39
  212. package/dist/tool/responseEnvelope.d.mts +2 -39
  213. package/dist/tool/responseEnvelope.mjs +1 -6
  214. package/dist/tool/schema.cjs +1 -2
  215. package/dist/tool/schema.d.cts +2 -86
  216. package/dist/tool/schema.d.mts +2 -86
  217. package/dist/tool/schema.mjs +1 -2
  218. package/dist/tool/taskTool.cjs +1 -3
  219. package/dist/tool/taskTool.d.cts +3 -17
  220. package/dist/tool/taskTool.d.mts +3 -17
  221. package/dist/tool/taskTool.mjs +1 -3
  222. package/dist/tui/format.cjs +3 -3
  223. package/dist/tui/format.cjs.map +1 -1
  224. package/dist/tui/format.d.cts +5 -5
  225. package/dist/tui/format.d.cts.map +1 -1
  226. package/dist/tui/format.d.mts +5 -5
  227. package/dist/tui/format.d.mts.map +1 -1
  228. package/dist/tui/format.mjs +3 -3
  229. package/dist/tui/format.mjs.map +1 -1
  230. package/dist/tui/selectors.cjs +1 -1
  231. package/dist/tui/selectors.cjs.map +1 -1
  232. package/dist/tui/selectors.d.cts +8 -1
  233. package/dist/tui/selectors.d.cts.map +1 -1
  234. package/dist/tui/selectors.d.mts +8 -1
  235. package/dist/tui/selectors.d.mts.map +1 -1
  236. package/dist/tui/selectors.mjs +1 -1
  237. package/dist/tui/selectors.mjs.map +1 -1
  238. package/dist/tui/taskOverlay.cjs +1 -1
  239. package/dist/tui/taskOverlay.cjs.map +1 -1
  240. package/dist/tui/taskOverlay.d.cts +2 -2
  241. package/dist/tui/taskOverlay.d.cts.map +1 -1
  242. package/dist/tui/taskOverlay.d.mts +2 -2
  243. package/dist/tui/taskOverlay.d.mts.map +1 -1
  244. package/dist/tui/taskOverlay.mjs +1 -1
  245. package/dist/tui/taskOverlay.mjs.map +1 -1
  246. package/dist/tui/taskSpace.cjs +3 -3
  247. package/dist/tui/taskSpace.cjs.map +1 -1
  248. package/dist/tui/taskSpace.d.cts +2 -1
  249. package/dist/tui/taskSpace.d.cts.map +1 -1
  250. package/dist/tui/taskSpace.d.mts +2 -1
  251. package/dist/tui/taskSpace.d.mts.map +1 -1
  252. package/dist/tui/taskSpace.mjs +3 -3
  253. package/dist/tui/taskSpace.mjs.map +1 -1
  254. package/dist/types/config.cjs +2 -0
  255. package/dist/types/config.cjs.map +1 -0
  256. package/dist/types/config.d.cts +43 -0
  257. package/dist/types/config.d.cts.map +1 -0
  258. package/dist/types/config.d.mts +43 -0
  259. package/dist/types/config.d.mts.map +1 -0
  260. package/dist/types/config.mjs +2 -0
  261. package/dist/types/config.mjs.map +1 -0
  262. package/package.json +16 -9
  263. package/dist/commands.cjs.map +0 -1
  264. package/dist/commands.d.cts.map +0 -1
  265. package/dist/commands.d.mts.map +0 -1
  266. package/dist/commands.mjs.map +0 -1
  267. package/dist/config.cjs.map +0 -1
  268. package/dist/config.d.cts.map +0 -1
  269. package/dist/config.d.mts.map +0 -1
  270. package/dist/config.mjs.map +0 -1
  271. package/dist/delegation/manager.cjs.map +0 -1
  272. package/dist/delegation/manager.d.cts.map +0 -1
  273. package/dist/delegation/manager.d.mts.map +0 -1
  274. package/dist/delegation/manager.mjs.map +0 -1
  275. package/dist/extension.cjs.map +0 -1
  276. package/dist/extension.d.cts.map +0 -1
  277. package/dist/extension.d.mts.map +0 -1
  278. package/dist/extension.mjs.map +0 -1
  279. package/dist/logSinkTelemetry.cjs.map +0 -1
  280. package/dist/logSinkTelemetry.d.cts.map +0 -1
  281. package/dist/logSinkTelemetry.d.mts.map +0 -1
  282. package/dist/logSinkTelemetry.mjs.map +0 -1
  283. package/dist/store/invariants.cjs.map +0 -1
  284. package/dist/store/invariants.d.cts.map +0 -1
  285. package/dist/store/invariants.d.mts.map +0 -1
  286. package/dist/store/invariants.mjs.map +0 -1
  287. package/dist/store/paths.cjs.map +0 -1
  288. package/dist/store/paths.d.cts.map +0 -1
  289. package/dist/store/paths.d.mts.map +0 -1
  290. package/dist/store/paths.mjs.map +0 -1
  291. package/dist/store/processLiveness.cjs.map +0 -1
  292. package/dist/store/processLiveness.d.cts.map +0 -1
  293. package/dist/store/processLiveness.d.mts.map +0 -1
  294. package/dist/store/processLiveness.mjs.map +0 -1
  295. package/dist/store/reconcile.cjs.map +0 -1
  296. package/dist/store/reconcile.d.cts.map +0 -1
  297. package/dist/store/reconcile.d.mts.map +0 -1
  298. package/dist/store/reconcile.mjs.map +0 -1
  299. package/dist/store/reducer.cjs.map +0 -1
  300. package/dist/store/reducer.d.cts.map +0 -1
  301. package/dist/store/reducer.d.mts.map +0 -1
  302. package/dist/store/reducer.mjs.map +0 -1
  303. package/dist/store/taskGraph.cjs.map +0 -1
  304. package/dist/store/taskGraph.d.cts.map +0 -1
  305. package/dist/store/taskGraph.d.mts.map +0 -1
  306. package/dist/store/taskGraph.mjs.map +0 -1
  307. package/dist/store/taskStore.cjs.map +0 -1
  308. package/dist/store/taskStore.d.cts.map +0 -1
  309. package/dist/store/taskStore.d.mts.map +0 -1
  310. package/dist/store/taskStore.mjs.map +0 -1
  311. package/dist/store/types.cjs.map +0 -1
  312. package/dist/store/types.d.cts.map +0 -1
  313. package/dist/store/types.d.mts.map +0 -1
  314. package/dist/store/types.mjs.map +0 -1
  315. package/dist/tool/promptGuidelines.cjs.map +0 -1
  316. package/dist/tool/promptGuidelines.d.cts.map +0 -1
  317. package/dist/tool/promptGuidelines.d.mts.map +0 -1
  318. package/dist/tool/promptGuidelines.mjs.map +0 -1
  319. package/dist/tool/responseEnvelope.cjs.map +0 -1
  320. package/dist/tool/responseEnvelope.d.cts.map +0 -1
  321. package/dist/tool/responseEnvelope.d.mts.map +0 -1
  322. package/dist/tool/responseEnvelope.mjs.map +0 -1
  323. package/dist/tool/schema.cjs.map +0 -1
  324. package/dist/tool/schema.d.cts.map +0 -1
  325. package/dist/tool/schema.d.mts.map +0 -1
  326. package/dist/tool/schema.mjs.map +0 -1
  327. package/dist/tool/taskTool.cjs.map +0 -1
  328. package/dist/tool/taskTool.d.cts.map +0 -1
  329. package/dist/tool/taskTool.d.mts.map +0 -1
  330. package/dist/tool/taskTool.mjs.map +0 -1
@@ -1,51 +1,2 @@
1
- import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
2
- //#region src/logSinkTelemetry.d.ts
3
- declare const TASK_EVENT: {
4
- readonly notificationFailed: "doom_task.notification_failed";
5
- readonly storeReadFailed: "doom_task.store_read_failed";
6
- readonly storeLockTimeout: "doom_task.store_lock_timeout";
7
- readonly storeLockBreakFailed: "doom_task.store_lock_break_failed";
8
- readonly storeWatchFailed: "doom_task.store_watch_failed";
9
- readonly storeListenerFailed: "doom_task.store_listener_failed";
10
- readonly storeSweepFailed: "doom_task.store_sweep_failed";
11
- readonly sessionStartFailed: "doom_task.session_start_failed";
12
- readonly toolFailed: "doom_task.tool_failed";
13
- readonly delegationRequestFailed: "doom_task.delegation_request_failed";
14
- readonly delegationStartFailed: "doom_task.delegation_start_failed";
15
- readonly delegationResponseFailed: "doom_task.delegation_response_failed";
16
- readonly delegationSettleFailed: "doom_task.delegation_settle_failed";
17
- readonly delegationTimedOut: "doom_task.delegation_timed_out";
18
- readonly delegationOrphaned: "doom_task.delegation_orphaned";
19
- readonly delegationAssigned: "doom_task.delegation_assigned";
20
- readonly delegationCompleted: "doom_task.delegation_completed";
21
- };
22
- type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];
23
- type TaskErrorAttributes = Record<string, string | number | boolean>;
24
- type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;
25
- type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;
26
- interface TaskFailureReporter {
27
- error: TaskErrorSink;
28
- warn: TaskErrorSink;
29
- /** Info-level event sink. Required so an unwired reporter fails to compile. */
30
- event: TaskEventSink;
31
- }
32
- interface TaskErrorReporterOptions {
33
- cwd?: string;
34
- workspaceRoot?: string;
35
- env?: NodeJS.ProcessEnv;
36
- telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
37
- warn?: (message: string) => void;
38
- }
39
- interface TaskErrorReporter {
40
- recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
41
- recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
42
- recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;
43
- recordNotificationError(error: unknown, taskId: number): Promise<void>;
44
- flush(): Promise<void>;
45
- shutdown(): Promise<void>;
46
- }
47
- declare function createTaskErrorReporter(options?: TaskErrorReporterOptions): TaskErrorReporter;
48
- declare function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter;
49
- //#endregion
50
- export { TASK_EVENT, TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter, createTaskErrorReporter, toFailureReporter };
51
- //# sourceMappingURL=logSinkTelemetry.d.mts.map
1
+ import { TASK_EVENT, TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter, createTaskErrorReporter, toFailureReporter } from "./adapters/telemetry/logSinkTelemetry.mjs";
2
+ export { TASK_EVENT, TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter, createTaskErrorReporter, toFailureReporter };
@@ -1,2 +1 @@
1
- import{createDoomTelemetry as e}from"@agimon-ai/doompi-telemetry";const t={notificationFailed:`doom_task.notification_failed`,storeReadFailed:`doom_task.store_read_failed`,storeLockTimeout:`doom_task.store_lock_timeout`,storeLockBreakFailed:`doom_task.store_lock_break_failed`,storeWatchFailed:`doom_task.store_watch_failed`,storeListenerFailed:`doom_task.store_listener_failed`,storeSweepFailed:`doom_task.store_sweep_failed`,sessionStartFailed:`doom_task.session_start_failed`,toolFailed:`doom_task.tool_failed`,delegationRequestFailed:`doom_task.delegation_request_failed`,delegationStartFailed:`doom_task.delegation_start_failed`,delegationResponseFailed:`doom_task.delegation_response_failed`,delegationSettleFailed:`doom_task.delegation_settle_failed`,delegationTimedOut:`doom_task.delegation_timed_out`,delegationOrphaned:`doom_task.delegation_orphaned`,delegationAssigned:`doom_task.delegation_assigned`,delegationCompleted:`doom_task.delegation_completed`};function n(n={}){let r=e({serviceName:`doom-task`,packageName:`@agimon-ai/doompi-task`,cwd:n.cwd,workspaceRoot:n.workspaceRoot,env:n.env,telemetryFactory:n.telemetryFactory,warn:n.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,n)=>r.recordError(e,t,n),recordWarning:(e,t,n)=>r.recordWarning(e,t,n),recordEvent:(e,t)=>r.recordEvent(e,t),recordNotificationError:(e,n)=>r.recordError(t.notificationFailed,e,{"task.id":n,"task.operation":`completion_notification`}),flush:()=>r.flush(),shutdown:()=>r.shutdown()}}function r(e){return{error:(t,n,r)=>void e.recordError(t,n,r),warn:(t,n,r)=>void e.recordWarning(t,n,r),event:(t,n)=>void e.recordEvent(t,n)}}export{t as TASK_EVENT,n as createTaskErrorReporter,r as toFailureReporter};
2
- //# sourceMappingURL=logSinkTelemetry.mjs.map
1
+ import{TASK_EVENT as e,createTaskErrorReporter as t,toFailureReporter as n}from"./adapters/telemetry/logSinkTelemetry.mjs";export{e as TASK_EVENT,t as createTaskErrorReporter,n as toFailureReporter};
@@ -0,0 +1,2 @@
1
+ require("../services/delegation/manager.cjs");let e=require("@agimon-ai/doompi-extension-contracts/subagent-tool"),t=require("typebox");const n=[`upsert`,`list`,`get`,`delete`,`clear`,`assign`,`cancel`],r=[`pending`,`in_progress`,`completed`,`failed`,`deleted`],i=[`fresh`,`fork`],a={upsert:[`action`,`tasks`],list:[`action`,`status`,`includeDeleted`],get:[`action`,`id`],delete:[`action`,`id`],clear:[`action`],assign:[`action`,`assignments`],cancel:[`action`,`id`]};function o(e,t){return a[e].includes(t)}const s=t.Type.Union([t.Type.Integer(),t.Type.String()]),c=t.Type.Object({id:t.Type.Optional(t.Type.Integer({description:`Existing task id to change. Omit to create a new task. An entry with an id never creates: if the id is unknown, only that entry fails.`})),ref:t.Type.Optional(t.Type.String({description:`Temporary name for a task created by this entry, so a LATER entry in the same tasks[] can list it in blockedBy before its real id exists. Must start with a letter. Scoped to this one call and never stored; the response reports which real id it became.`})),subject:t.Type.Optional(t.Type.String({description:`Short imperative subject line (e.g. 'Research existing tool'). Required when the entry has no id; on an entry with an id it renames the task.`})),description:t.Type.Optional(t.Type.String({description:`Long-form task detail. This becomes the brief handed to the subagent when the task is assigned.`})),activeForm:t.Type.Optional(t.Type.String({description:`Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')`})),status:t.Type.Optional(t.Type.String({enum:[...r],description:`Starting status for a new entry (default pending; deleted is rejected), or the target status for an entry with an id, where the transition must be legal.`})),blockedBy:t.Type.Optional(t.Type.Array(s,{description:`Dependencies for a NEW entry (one with no id): this task is blocked by each target. A number is an existing task id; a string is the ref of a task created by an EARLIER entry in this same array. Use addBlockedBy / removeBlockedBy on an entry that has an id.`})),addBlockedBy:t.Type.Optional(t.Type.Array(s,{description:`Dependencies to add, for an entry with an id. Task ids, or refs declared by an earlier entry. Additive merge — do not resend the full array.`})),removeBlockedBy:t.Type.Optional(t.Type.Array(s,{description:`Dependencies to remove, for an entry with an id. Additive merge — do not resend the full array.`})),owner:t.Type.Optional(t.Type.String({description:`Owner label for this task. assign sets this to the subagent name automatically.`})),metadata:t.Type.Optional(t.Type.Record(t.Type.String(),t.Type.Unknown(),{description:`Arbitrary metadata merged into the task; pass null as a value to delete that key`}))},{additionalProperties:!1}),l=t.Type.Object({id:t.Type.Integer({description:`Pending, unblocked task id to delegate`}),agent:t.Type.String({description:`Exact discovered subagent name`}),inlineAgent:t.Type.Optional(e.InlineAgentSchema),instructions:t.Type.Optional(t.Type.String({description:`Extra instructions appended to this delegated brief`})),relevantFiles:t.Type.Optional(t.Type.Array(t.Type.String(),{description:`Files already read or located for this task. Paths are relative to the working directory; at most 12 are used.`})),priorFindings:t.Type.Optional(t.Type.String({description:`Established facts this child should consume rather than re-derive`})),model:t.Type.Optional(t.Type.String({description:`Model override for this delegated run`})),context:t.Type.Optional(t.Type.String({enum:[...i],description:`Starting context for this child: 'fresh' or 'fork'`}))},{additionalProperties:!1}),u=t.Type.Object({action:t.Type.String({enum:[...n],description:`upsert (create new tasks and change existing ones, one or many per call), list, get, delete (tombstone), clear (close/reset the list), assign (delegate one or more tasks through assignments[]), cancel (stop a delegated run)`}),tasks:t.Type.Optional(t.Type.Array(c,{minItems:1,description:`upsert only. One entry per task: an entry with an id changes that task, an entry without an id creates one. Entries apply in array order, so a later entry can depend on an earlier one by ref. Each entry succeeds or fails on its own: the ones that succeed are committed and the ones that fail are reported by their array index.`})),assignments:t.Type.Optional(t.Type.Array(l,{minItems:1,description:`Required for assign, including one task. Each entry selects its own pending, unblocked task, agent, model, and context pack; successful entries remain delegated if another entry fails. assign has no top-level single-task form.`})),id:t.Type.Optional(t.Type.Integer({description:`Task id, for get, delete, and cancel. For assign, put every id inside assignments[]. upsert does not accept this field — put the id inside the tasks[] entry you want to change.`})),status:t.Type.Optional(t.Type.String({enum:[...r],description:`list only: return just the tasks in this status. To SET a status, use upsert with the task id inside tasks[].`})),includeDeleted:t.Type.Optional(t.Type.Boolean({description:`If true, list returns deleted (tombstoned) tasks as well. Default: false.`}))});exports.COMMAND_NAME=`tasks`,exports.ERR_REQUIRES_INTERACTIVE=`/tasks requires interactive mode`,exports.MSG_NO_TASKS=`No tasks yet. Ask the agent to add some!`,exports.MSG_UPSERT_FIELD_MISPLACED=`Per-task fields belong inside each tasks[] entry, not at the top level: {"action":"upsert","tasks":[{"id":3,"status":"completed"}]}.`,exports.TASK_ACTIONS=n,exports.TASK_ACTION_FIELDS=a,exports.TASK_CONTEXTS=i,exports.TASK_STATUSES=r,exports.TOOL_LABEL=`Task`,exports.TOOL_NAME=`task`,exports.TaskAssignmentSchema=l,exports.TaskItemSchema=c,exports.TaskParamsSchema=u,exports.taskActionAcceptsField=o;
2
+ //# sourceMappingURL=task.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.cjs","names":["Type","InlineAgentSchema"],"sources":["../../src/schemas/task.ts"],"sourcesContent":["import { InlineAgentSchema } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\nimport { type Static, Type } from 'typebox';\nimport { MAX_BRIEF_FILES } from '../services/delegation/manager.ts';\nimport type { TaskAction } from '../services/store/types.ts';\n\nexport const TASK_ACTIONS = ['upsert', 'list', 'get', 'delete', 'clear', 'assign', 'cancel'] as const;\nexport const TASK_STATUSES = ['pending', 'in_progress', 'completed', 'failed', 'deleted'] as const;\nexport const TASK_CONTEXTS = ['fresh', 'fork'] as const;\n\nexport const TOOL_NAME = 'task';\nexport const TOOL_LABEL = 'Task';\nexport const COMMAND_NAME = 'tasks';\n\nexport const ERR_REQUIRES_INTERACTIVE = '/tasks requires interactive mode';\nexport const MSG_NO_TASKS = 'No tasks yet. Ask the agent to add some!';\n\n/**\n * Which top-level fields each action accepts.\n *\n * The params object is flat and shared across every action, so the schema alone\n * cannot express \"upsert has no top-level id\". That gap matters: a call like\n * `{\"action\":\"upsert\",\"id\":3,\"tasks\":[{\"status\":\"completed\"}]}` would otherwise\n * silently create a duplicate task, because the entry itself carries no id.\n */\nexport const TASK_ACTION_FIELDS = {\n upsert: ['action', 'tasks'],\n list: ['action', 'status', 'includeDeleted'],\n get: ['action', 'id'],\n delete: ['action', 'id'],\n clear: ['action'],\n assign: ['action', 'assignments'],\n cancel: ['action', 'id'],\n} as const satisfies Record<TaskAction, readonly string[]>;\n\nexport function taskActionAcceptsField(action: TaskAction, field: string): boolean {\n return (TASK_ACTION_FIELDS[action] as readonly string[]).includes(field);\n}\n\n/** Correction hint appended when a per-task field lands at the top level. */\nexport const MSG_UPSERT_FIELD_MISPLACED =\n 'Per-task fields belong inside each tasks[] entry, not at the top level: {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}.';\n\n/**\n * A dependency target: an existing task id, or the `ref` of a task created\n * earlier in the same call.\n */\nconst DepTokenSchema = Type.Union([Type.Integer(), Type.String()]);\n\n/**\n * One entry of an upsert. `additionalProperties: false` is load-bearing: pi\n * validates tool arguments against this schema before `execute` runs, so a\n * stray `{\"action\":\"update\"}` inside an entry is rejected at the boundary.\n */\nexport const TaskItemSchema = Type.Object(\n {\n id: Type.Optional(\n Type.Integer({\n description:\n 'Existing task id to change. Omit to create a new task. An entry with an id never creates: if the id is unknown, only that entry fails.',\n }),\n ),\n ref: Type.Optional(\n Type.String({\n description:\n 'Temporary name for a task created by this entry, so a LATER entry in the same tasks[] can list it in blockedBy before its real id exists. Must start with a letter. Scoped to this one call and never stored; the response reports which real id it became.',\n }),\n ),\n subject: Type.Optional(\n Type.String({\n description:\n \"Short imperative subject line (e.g. 'Research existing tool'). Required when the entry has no id; on an entry with an id it renames the task.\",\n }),\n ),\n description: Type.Optional(\n Type.String({\n description: 'Long-form task detail. This becomes the brief handed to the subagent when the task is assigned.',\n }),\n ),\n activeForm: Type.Optional(\n Type.String({\n description: \"Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')\",\n }),\n ),\n status: Type.Optional(\n Type.String({\n enum: [...TASK_STATUSES],\n description:\n 'Starting status for a new entry (default pending; deleted is rejected), or the target status for an entry with an id, where the transition must be legal.',\n }),\n ),\n blockedBy: Type.Optional(\n Type.Array(DepTokenSchema, {\n description:\n 'Dependencies for a NEW entry (one with no id): this task is blocked by each target. A number is an existing task id; a string is the ref of a task created by an EARLIER entry in this same array. Use addBlockedBy / removeBlockedBy on an entry that has an id.',\n }),\n ),\n addBlockedBy: Type.Optional(\n Type.Array(DepTokenSchema, {\n description:\n 'Dependencies to add, for an entry with an id. Task ids, or refs declared by an earlier entry. Additive merge — do not resend the full array.',\n }),\n ),\n removeBlockedBy: Type.Optional(\n Type.Array(DepTokenSchema, {\n description: 'Dependencies to remove, for an entry with an id. Additive merge — do not resend the full array.',\n }),\n ),\n owner: Type.Optional(\n Type.String({ description: 'Owner label for this task. assign sets this to the subagent name automatically.' }),\n ),\n metadata: Type.Optional(\n Type.Record(Type.String(), Type.Unknown(), {\n description: 'Arbitrary metadata merged into the task; pass null as a value to delete that key',\n }),\n ),\n },\n { additionalProperties: false },\n);\n\n/** One task-to-agent handoff in a native assignment batch. */\nexport const TaskAssignmentSchema = Type.Object(\n {\n id: Type.Integer({ description: 'Pending, unblocked task id to delegate' }),\n agent: Type.String({ description: 'Exact discovered subagent name' }),\n inlineAgent: Type.Optional(InlineAgentSchema),\n instructions: Type.Optional(Type.String({ description: 'Extra instructions appended to this delegated brief' })),\n relevantFiles: Type.Optional(\n Type.Array(Type.String(), {\n description: `Files already read or located for this task. Paths are relative to the working directory; at most ${MAX_BRIEF_FILES} are used.`,\n }),\n ),\n priorFindings: Type.Optional(\n Type.String({ description: 'Established facts this child should consume rather than re-derive' }),\n ),\n model: Type.Optional(Type.String({ description: 'Model override for this delegated run' })),\n context: Type.Optional(\n Type.String({\n enum: [...TASK_CONTEXTS],\n description: \"Starting context for this child: 'fresh' or 'fork'\",\n }),\n ),\n },\n { additionalProperties: false },\n);\n\n/**\n * Tool parameters. Every `description` doubles as LLM-facing prompt copy, so\n * wording changes here change model behaviour.\n */\nexport const TaskParamsSchema = Type.Object({\n action: Type.String({\n enum: [...TASK_ACTIONS],\n description:\n 'upsert (create new tasks and change existing ones, one or many per call), list, get, delete (tombstone), clear (close/reset the list), assign (delegate one or more tasks through assignments[]), cancel (stop a delegated run)',\n }),\n tasks: Type.Optional(\n Type.Array(TaskItemSchema, {\n minItems: 1,\n description:\n 'upsert only. One entry per task: an entry with an id changes that task, an entry without an id creates one. Entries apply in array order, so a later entry can depend on an earlier one by ref. Each entry succeeds or fails on its own: the ones that succeed are committed and the ones that fail are reported by their array index.',\n }),\n ),\n assignments: Type.Optional(\n Type.Array(TaskAssignmentSchema, {\n minItems: 1,\n description:\n 'Required for assign, including one task. Each entry selects its own pending, unblocked task, agent, model, and context pack; successful entries remain delegated if another entry fails. assign has no top-level single-task form.',\n }),\n ),\n id: Type.Optional(\n Type.Integer({\n description:\n 'Task id, for get, delete, and cancel. For assign, put every id inside assignments[]. upsert does not accept this field — put the id inside the tasks[] entry you want to change.',\n }),\n ),\n status: Type.Optional(\n Type.String({\n enum: [...TASK_STATUSES],\n description:\n 'list only: return just the tasks in this status. To SET a status, use upsert with the task id inside tasks[].',\n }),\n ),\n includeDeleted: Type.Optional(\n Type.Boolean({\n description: 'If true, list returns deleted (tombstoned) tasks as well. Default: false.',\n }),\n ),\n});\n\nexport type TaskItemParams = Static<typeof TaskItemSchema>;\nexport type TaskAssignmentParams = Static<typeof TaskAssignmentSchema>;\nexport type TaskParams = Static<typeof TaskParamsSchema>;\n"],"mappings":"wIAKA,MAAa,EAAe,CAAC,SAAU,OAAQ,MAAO,SAAU,QAAS,SAAU,QAAQ,EAC9E,EAAgB,CAAC,UAAW,cAAe,YAAa,SAAU,SAAS,EAC3E,EAAgB,CAAC,QAAS,MAAM,EAiB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AsB,CAC/B,SAAU,EACV,YACE,oOACJ,CAAC,CACH,EACA,GAAIA,EAAAA,KAAK,SACPA,EAAAA,KAAK,QAAQ,CACX,YACE,kLACJ,CAAC,CACH,EACA,OAAQA,EAAAA,KAAK,SACXA,EAAAA,KAAK,OAAO,CACV,KAAM,CAAC,GAAG,CAAa,EACvB,YACE,+GACJ,CAAC,CACH,EACA,eAAgBA,EAAAA,KAAK,SACnBA,EAAAA,KAAK,QAAQ,CACX,YAAa,2EACf,CAAC,CACH,CACF,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { TaskAction } from "../services/store/types.cjs";
2
+ import { Static, Type } from "typebox";
3
+ //#region src/schemas/task.d.ts
4
+ declare const TASK_ACTIONS: readonly ["upsert", "list", "get", "delete", "clear", "assign", "cancel"];
5
+ declare const TASK_STATUSES: readonly ["pending", "in_progress", "completed", "failed", "deleted"];
6
+ declare const TASK_CONTEXTS: readonly ["fresh", "fork"];
7
+ declare const TOOL_NAME = "task";
8
+ declare const TOOL_LABEL = "Task";
9
+ declare const COMMAND_NAME = "tasks";
10
+ declare const ERR_REQUIRES_INTERACTIVE = "/tasks requires interactive mode";
11
+ declare const MSG_NO_TASKS = "No tasks yet. Ask the agent to add some!";
12
+ /**
13
+ * Which top-level fields each action accepts.
14
+ *
15
+ * The params object is flat and shared across every action, so the schema alone
16
+ * cannot express "upsert has no top-level id". That gap matters: a call like
17
+ * `{"action":"upsert","id":3,"tasks":[{"status":"completed"}]}` would otherwise
18
+ * silently create a duplicate task, because the entry itself carries no id.
19
+ */
20
+ declare const TASK_ACTION_FIELDS: {
21
+ readonly upsert: readonly ["action", "tasks"];
22
+ readonly list: readonly ["action", "status", "includeDeleted"];
23
+ readonly get: readonly ["action", "id"];
24
+ readonly delete: readonly ["action", "id"];
25
+ readonly clear: readonly ["action"];
26
+ readonly assign: readonly ["action", "assignments"];
27
+ readonly cancel: readonly ["action", "id"];
28
+ };
29
+ declare function taskActionAcceptsField(action: TaskAction, field: string): boolean;
30
+ /** Correction hint appended when a per-task field lands at the top level. */
31
+ declare const MSG_UPSERT_FIELD_MISPLACED = "Per-task fields belong inside each tasks[] entry, not at the top level: {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}.";
32
+ /**
33
+ * One entry of an upsert. `additionalProperties: false` is load-bearing: pi
34
+ * validates tool arguments against this schema before `execute` runs, so a
35
+ * stray `{"action":"update"}` inside an entry is rejected at the boundary.
36
+ */
37
+ declare const TaskItemSchema: Type.TObject<{
38
+ id: Type.TOptional<Type.TInteger>;
39
+ ref: Type.TOptional<Type.TString>;
40
+ subject: Type.TOptional<Type.TString>;
41
+ description: Type.TOptional<Type.TString>;
42
+ activeForm: Type.TOptional<Type.TString>;
43
+ status: Type.TOptional<Type.TString>;
44
+ blockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
45
+ addBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
46
+ removeBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
47
+ owner: Type.TOptional<Type.TString>;
48
+ metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
49
+ }>;
50
+ /** One task-to-agent handoff in a native assignment batch. */
51
+ declare const TaskAssignmentSchema: Type.TObject<{
52
+ id: Type.TInteger;
53
+ agent: Type.TString;
54
+ inlineAgent: Type.TOptional<Type.TObject<{
55
+ systemPrompt: Type.TString;
56
+ }>>;
57
+ instructions: Type.TOptional<Type.TString>;
58
+ relevantFiles: Type.TOptional<Type.TArray<Type.TString>>;
59
+ priorFindings: Type.TOptional<Type.TString>;
60
+ model: Type.TOptional<Type.TString>;
61
+ context: Type.TOptional<Type.TString>;
62
+ }>;
63
+ /**
64
+ * Tool parameters. Every `description` doubles as LLM-facing prompt copy, so
65
+ * wording changes here change model behaviour.
66
+ */
67
+ declare const TaskParamsSchema: Type.TObject<{
68
+ action: Type.TString;
69
+ tasks: Type.TOptional<Type.TArray<Type.TObject<{
70
+ id: Type.TOptional<Type.TInteger>;
71
+ ref: Type.TOptional<Type.TString>;
72
+ subject: Type.TOptional<Type.TString>;
73
+ description: Type.TOptional<Type.TString>;
74
+ activeForm: Type.TOptional<Type.TString>;
75
+ status: Type.TOptional<Type.TString>;
76
+ blockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
77
+ addBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
78
+ removeBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
79
+ owner: Type.TOptional<Type.TString>;
80
+ metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
81
+ }>>>;
82
+ assignments: Type.TOptional<Type.TArray<Type.TObject<{
83
+ id: Type.TInteger;
84
+ agent: Type.TString;
85
+ inlineAgent: Type.TOptional<Type.TObject<{
86
+ systemPrompt: Type.TString;
87
+ }>>;
88
+ instructions: Type.TOptional<Type.TString>;
89
+ relevantFiles: Type.TOptional<Type.TArray<Type.TString>>;
90
+ priorFindings: Type.TOptional<Type.TString>;
91
+ model: Type.TOptional<Type.TString>;
92
+ context: Type.TOptional<Type.TString>;
93
+ }>>>;
94
+ id: Type.TOptional<Type.TInteger>;
95
+ status: Type.TOptional<Type.TString>;
96
+ includeDeleted: Type.TOptional<Type.TBoolean>;
97
+ }>;
98
+ type TaskItemParams = Static<typeof TaskItemSchema>;
99
+ type TaskAssignmentParams = Static<typeof TaskAssignmentSchema>;
100
+ type TaskParams = Static<typeof TaskParamsSchema>;
101
+ //#endregion
102
+ export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
103
+ //# sourceMappingURL=task.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.cts","names":[],"sources":["../../src/schemas/task.ts"],"mappings":";;;cAKa;cACA;cACA;cAEA;cACA;cACA;cAEA;cACA;;;;;;;;;cAUA;;;;;;;;;iBAUG,uBAAuB,QAAQ,YAAY;;cAK9C;;;;;;cAcA,gBAAc,KAAA;;;;;;;;;;;;;;cAmEd,sBAAoB,KAAA;;;;;;;;;;;;;;;;cA6BpB,kBAAgB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCjB,iBAAiB,cAAc;KAC/B,uBAAuB,cAAc;KACrC,aAAa,cAAc"}
@@ -0,0 +1,103 @@
1
+ import { TaskAction } from "../services/store/types.mjs";
2
+ import { Static, Type } from "typebox";
3
+ //#region src/schemas/task.d.ts
4
+ declare const TASK_ACTIONS: readonly ["upsert", "list", "get", "delete", "clear", "assign", "cancel"];
5
+ declare const TASK_STATUSES: readonly ["pending", "in_progress", "completed", "failed", "deleted"];
6
+ declare const TASK_CONTEXTS: readonly ["fresh", "fork"];
7
+ declare const TOOL_NAME = "task";
8
+ declare const TOOL_LABEL = "Task";
9
+ declare const COMMAND_NAME = "tasks";
10
+ declare const ERR_REQUIRES_INTERACTIVE = "/tasks requires interactive mode";
11
+ declare const MSG_NO_TASKS = "No tasks yet. Ask the agent to add some!";
12
+ /**
13
+ * Which top-level fields each action accepts.
14
+ *
15
+ * The params object is flat and shared across every action, so the schema alone
16
+ * cannot express "upsert has no top-level id". That gap matters: a call like
17
+ * `{"action":"upsert","id":3,"tasks":[{"status":"completed"}]}` would otherwise
18
+ * silently create a duplicate task, because the entry itself carries no id.
19
+ */
20
+ declare const TASK_ACTION_FIELDS: {
21
+ readonly upsert: readonly ["action", "tasks"];
22
+ readonly list: readonly ["action", "status", "includeDeleted"];
23
+ readonly get: readonly ["action", "id"];
24
+ readonly delete: readonly ["action", "id"];
25
+ readonly clear: readonly ["action"];
26
+ readonly assign: readonly ["action", "assignments"];
27
+ readonly cancel: readonly ["action", "id"];
28
+ };
29
+ declare function taskActionAcceptsField(action: TaskAction, field: string): boolean;
30
+ /** Correction hint appended when a per-task field lands at the top level. */
31
+ declare const MSG_UPSERT_FIELD_MISPLACED = "Per-task fields belong inside each tasks[] entry, not at the top level: {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}.";
32
+ /**
33
+ * One entry of an upsert. `additionalProperties: false` is load-bearing: pi
34
+ * validates tool arguments against this schema before `execute` runs, so a
35
+ * stray `{"action":"update"}` inside an entry is rejected at the boundary.
36
+ */
37
+ declare const TaskItemSchema: Type.TObject<{
38
+ id: Type.TOptional<Type.TInteger>;
39
+ ref: Type.TOptional<Type.TString>;
40
+ subject: Type.TOptional<Type.TString>;
41
+ description: Type.TOptional<Type.TString>;
42
+ activeForm: Type.TOptional<Type.TString>;
43
+ status: Type.TOptional<Type.TString>;
44
+ blockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
45
+ addBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
46
+ removeBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
47
+ owner: Type.TOptional<Type.TString>;
48
+ metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
49
+ }>;
50
+ /** One task-to-agent handoff in a native assignment batch. */
51
+ declare const TaskAssignmentSchema: Type.TObject<{
52
+ id: Type.TInteger;
53
+ agent: Type.TString;
54
+ inlineAgent: Type.TOptional<Type.TObject<{
55
+ systemPrompt: Type.TString;
56
+ }>>;
57
+ instructions: Type.TOptional<Type.TString>;
58
+ relevantFiles: Type.TOptional<Type.TArray<Type.TString>>;
59
+ priorFindings: Type.TOptional<Type.TString>;
60
+ model: Type.TOptional<Type.TString>;
61
+ context: Type.TOptional<Type.TString>;
62
+ }>;
63
+ /**
64
+ * Tool parameters. Every `description` doubles as LLM-facing prompt copy, so
65
+ * wording changes here change model behaviour.
66
+ */
67
+ declare const TaskParamsSchema: Type.TObject<{
68
+ action: Type.TString;
69
+ tasks: Type.TOptional<Type.TArray<Type.TObject<{
70
+ id: Type.TOptional<Type.TInteger>;
71
+ ref: Type.TOptional<Type.TString>;
72
+ subject: Type.TOptional<Type.TString>;
73
+ description: Type.TOptional<Type.TString>;
74
+ activeForm: Type.TOptional<Type.TString>;
75
+ status: Type.TOptional<Type.TString>;
76
+ blockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
77
+ addBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
78
+ removeBlockedBy: Type.TOptional<Type.TArray<Type.TUnion<[Type.TInteger, Type.TString]>>>;
79
+ owner: Type.TOptional<Type.TString>;
80
+ metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
81
+ }>>>;
82
+ assignments: Type.TOptional<Type.TArray<Type.TObject<{
83
+ id: Type.TInteger;
84
+ agent: Type.TString;
85
+ inlineAgent: Type.TOptional<Type.TObject<{
86
+ systemPrompt: Type.TString;
87
+ }>>;
88
+ instructions: Type.TOptional<Type.TString>;
89
+ relevantFiles: Type.TOptional<Type.TArray<Type.TString>>;
90
+ priorFindings: Type.TOptional<Type.TString>;
91
+ model: Type.TOptional<Type.TString>;
92
+ context: Type.TOptional<Type.TString>;
93
+ }>>>;
94
+ id: Type.TOptional<Type.TInteger>;
95
+ status: Type.TOptional<Type.TString>;
96
+ includeDeleted: Type.TOptional<Type.TBoolean>;
97
+ }>;
98
+ type TaskItemParams = Static<typeof TaskItemSchema>;
99
+ type TaskAssignmentParams = Static<typeof TaskAssignmentSchema>;
100
+ type TaskParams = Static<typeof TaskParamsSchema>;
101
+ //#endregion
102
+ export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
103
+ //# sourceMappingURL=task.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.mts","names":[],"sources":["../../src/schemas/task.ts"],"mappings":";;;cAKa;cACA;cACA;cAEA;cACA;cACA;cAEA;cACA;;;;;;;;;cAUA;;;;;;;;;iBAUG,uBAAuB,QAAQ,YAAY;;cAK9C;;;;;;cAcA,gBAAc,KAAA;;;;;;;;;;;;;;cAmEd,sBAAoB,KAAA;;;;;;;;;;;;;;;;cA6BpB,kBAAgB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCjB,iBAAiB,cAAc;KAC/B,uBAAuB,cAAc;KACrC,aAAa,cAAc"}
@@ -0,0 +1,2 @@
1
+ import"../services/delegation/manager.mjs";import{InlineAgentSchema as e}from"@agimon-ai/doompi-extension-contracts/subagent-tool";import{Type as t}from"typebox";const n=[`upsert`,`list`,`get`,`delete`,`clear`,`assign`,`cancel`],r=[`pending`,`in_progress`,`completed`,`failed`,`deleted`],i=[`fresh`,`fork`],a=`task`,o=`Task`,s=`tasks`,c=`/tasks requires interactive mode`,l=`No tasks yet. Ask the agent to add some!`,u={upsert:[`action`,`tasks`],list:[`action`,`status`,`includeDeleted`],get:[`action`,`id`],delete:[`action`,`id`],clear:[`action`],assign:[`action`,`assignments`],cancel:[`action`,`id`]};function d(e,t){return u[e].includes(t)}const f=`Per-task fields belong inside each tasks[] entry, not at the top level: {"action":"upsert","tasks":[{"id":3,"status":"completed"}]}.`,p=t.Union([t.Integer(),t.String()]),m=t.Object({id:t.Optional(t.Integer({description:`Existing task id to change. Omit to create a new task. An entry with an id never creates: if the id is unknown, only that entry fails.`})),ref:t.Optional(t.String({description:`Temporary name for a task created by this entry, so a LATER entry in the same tasks[] can list it in blockedBy before its real id exists. Must start with a letter. Scoped to this one call and never stored; the response reports which real id it became.`})),subject:t.Optional(t.String({description:`Short imperative subject line (e.g. 'Research existing tool'). Required when the entry has no id; on an entry with an id it renames the task.`})),description:t.Optional(t.String({description:`Long-form task detail. This becomes the brief handed to the subagent when the task is assigned.`})),activeForm:t.Optional(t.String({description:`Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')`})),status:t.Optional(t.String({enum:[...r],description:`Starting status for a new entry (default pending; deleted is rejected), or the target status for an entry with an id, where the transition must be legal.`})),blockedBy:t.Optional(t.Array(p,{description:`Dependencies for a NEW entry (one with no id): this task is blocked by each target. A number is an existing task id; a string is the ref of a task created by an EARLIER entry in this same array. Use addBlockedBy / removeBlockedBy on an entry that has an id.`})),addBlockedBy:t.Optional(t.Array(p,{description:`Dependencies to add, for an entry with an id. Task ids, or refs declared by an earlier entry. Additive merge — do not resend the full array.`})),removeBlockedBy:t.Optional(t.Array(p,{description:`Dependencies to remove, for an entry with an id. Additive merge — do not resend the full array.`})),owner:t.Optional(t.String({description:`Owner label for this task. assign sets this to the subagent name automatically.`})),metadata:t.Optional(t.Record(t.String(),t.Unknown(),{description:`Arbitrary metadata merged into the task; pass null as a value to delete that key`}))},{additionalProperties:!1}),h=t.Object({id:t.Integer({description:`Pending, unblocked task id to delegate`}),agent:t.String({description:`Exact discovered subagent name`}),inlineAgent:t.Optional(e),instructions:t.Optional(t.String({description:`Extra instructions appended to this delegated brief`})),relevantFiles:t.Optional(t.Array(t.String(),{description:`Files already read or located for this task. Paths are relative to the working directory; at most 12 are used.`})),priorFindings:t.Optional(t.String({description:`Established facts this child should consume rather than re-derive`})),model:t.Optional(t.String({description:`Model override for this delegated run`})),context:t.Optional(t.String({enum:[...i],description:`Starting context for this child: 'fresh' or 'fork'`}))},{additionalProperties:!1}),g=t.Object({action:t.String({enum:[...n],description:`upsert (create new tasks and change existing ones, one or many per call), list, get, delete (tombstone), clear (close/reset the list), assign (delegate one or more tasks through assignments[]), cancel (stop a delegated run)`}),tasks:t.Optional(t.Array(m,{minItems:1,description:`upsert only. One entry per task: an entry with an id changes that task, an entry without an id creates one. Entries apply in array order, so a later entry can depend on an earlier one by ref. Each entry succeeds or fails on its own: the ones that succeed are committed and the ones that fail are reported by their array index.`})),assignments:t.Optional(t.Array(h,{minItems:1,description:`Required for assign, including one task. Each entry selects its own pending, unblocked task, agent, model, and context pack; successful entries remain delegated if another entry fails. assign has no top-level single-task form.`})),id:t.Optional(t.Integer({description:`Task id, for get, delete, and cancel. For assign, put every id inside assignments[]. upsert does not accept this field — put the id inside the tasks[] entry you want to change.`})),status:t.Optional(t.String({enum:[...r],description:`list only: return just the tasks in this status. To SET a status, use upsert with the task id inside tasks[].`})),includeDeleted:t.Optional(t.Boolean({description:`If true, list returns deleted (tombstoned) tasks as well. Default: false.`}))});export{s as COMMAND_NAME,c as ERR_REQUIRES_INTERACTIVE,l as MSG_NO_TASKS,f as MSG_UPSERT_FIELD_MISPLACED,n as TASK_ACTIONS,u as TASK_ACTION_FIELDS,i as TASK_CONTEXTS,r as TASK_STATUSES,o as TOOL_LABEL,a as TOOL_NAME,h as TaskAssignmentSchema,m as TaskItemSchema,g as TaskParamsSchema,d as taskActionAcceptsField};
2
+ //# sourceMappingURL=task.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.mjs","names":[],"sources":["../../src/schemas/task.ts"],"sourcesContent":["import { InlineAgentSchema } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\nimport { type Static, Type } from 'typebox';\nimport { MAX_BRIEF_FILES } from '../services/delegation/manager.ts';\nimport type { TaskAction } from '../services/store/types.ts';\n\nexport const TASK_ACTIONS = ['upsert', 'list', 'get', 'delete', 'clear', 'assign', 'cancel'] as const;\nexport const TASK_STATUSES = ['pending', 'in_progress', 'completed', 'failed', 'deleted'] as const;\nexport const TASK_CONTEXTS = ['fresh', 'fork'] as const;\n\nexport const TOOL_NAME = 'task';\nexport const TOOL_LABEL = 'Task';\nexport const COMMAND_NAME = 'tasks';\n\nexport const ERR_REQUIRES_INTERACTIVE = '/tasks requires interactive mode';\nexport const MSG_NO_TASKS = 'No tasks yet. Ask the agent to add some!';\n\n/**\n * Which top-level fields each action accepts.\n *\n * The params object is flat and shared across every action, so the schema alone\n * cannot express \"upsert has no top-level id\". That gap matters: a call like\n * `{\"action\":\"upsert\",\"id\":3,\"tasks\":[{\"status\":\"completed\"}]}` would otherwise\n * silently create a duplicate task, because the entry itself carries no id.\n */\nexport const TASK_ACTION_FIELDS = {\n upsert: ['action', 'tasks'],\n list: ['action', 'status', 'includeDeleted'],\n get: ['action', 'id'],\n delete: ['action', 'id'],\n clear: ['action'],\n assign: ['action', 'assignments'],\n cancel: ['action', 'id'],\n} as const satisfies Record<TaskAction, readonly string[]>;\n\nexport function taskActionAcceptsField(action: TaskAction, field: string): boolean {\n return (TASK_ACTION_FIELDS[action] as readonly string[]).includes(field);\n}\n\n/** Correction hint appended when a per-task field lands at the top level. */\nexport const MSG_UPSERT_FIELD_MISPLACED =\n 'Per-task fields belong inside each tasks[] entry, not at the top level: {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}.';\n\n/**\n * A dependency target: an existing task id, or the `ref` of a task created\n * earlier in the same call.\n */\nconst DepTokenSchema = Type.Union([Type.Integer(), Type.String()]);\n\n/**\n * One entry of an upsert. `additionalProperties: false` is load-bearing: pi\n * validates tool arguments against this schema before `execute` runs, so a\n * stray `{\"action\":\"update\"}` inside an entry is rejected at the boundary.\n */\nexport const TaskItemSchema = Type.Object(\n {\n id: Type.Optional(\n Type.Integer({\n description:\n 'Existing task id to change. Omit to create a new task. An entry with an id never creates: if the id is unknown, only that entry fails.',\n }),\n ),\n ref: Type.Optional(\n Type.String({\n description:\n 'Temporary name for a task created by this entry, so a LATER entry in the same tasks[] can list it in blockedBy before its real id exists. Must start with a letter. Scoped to this one call and never stored; the response reports which real id it became.',\n }),\n ),\n subject: Type.Optional(\n Type.String({\n description:\n \"Short imperative subject line (e.g. 'Research existing tool'). Required when the entry has no id; on an entry with an id it renames the task.\",\n }),\n ),\n description: Type.Optional(\n Type.String({\n description: 'Long-form task detail. This becomes the brief handed to the subagent when the task is assigned.',\n }),\n ),\n activeForm: Type.Optional(\n Type.String({\n description: \"Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')\",\n }),\n ),\n status: Type.Optional(\n Type.String({\n enum: [...TASK_STATUSES],\n description:\n 'Starting status for a new entry (default pending; deleted is rejected), or the target status for an entry with an id, where the transition must be legal.',\n }),\n ),\n blockedBy: Type.Optional(\n Type.Array(DepTokenSchema, {\n description:\n 'Dependencies for a NEW entry (one with no id): this task is blocked by each target. A number is an existing task id; a string is the ref of a task created by an EARLIER entry in this same array. Use addBlockedBy / removeBlockedBy on an entry that has an id.',\n }),\n ),\n addBlockedBy: Type.Optional(\n Type.Array(DepTokenSchema, {\n description:\n 'Dependencies to add, for an entry with an id. Task ids, or refs declared by an earlier entry. Additive merge — do not resend the full array.',\n }),\n ),\n removeBlockedBy: Type.Optional(\n Type.Array(DepTokenSchema, {\n description: 'Dependencies to remove, for an entry with an id. Additive merge — do not resend the full array.',\n }),\n ),\n owner: Type.Optional(\n Type.String({ description: 'Owner label for this task. assign sets this to the subagent name automatically.' }),\n ),\n metadata: Type.Optional(\n Type.Record(Type.String(), Type.Unknown(), {\n description: 'Arbitrary metadata merged into the task; pass null as a value to delete that key',\n }),\n ),\n },\n { additionalProperties: false },\n);\n\n/** One task-to-agent handoff in a native assignment batch. */\nexport const TaskAssignmentSchema = Type.Object(\n {\n id: Type.Integer({ description: 'Pending, unblocked task id to delegate' }),\n agent: Type.String({ description: 'Exact discovered subagent name' }),\n inlineAgent: Type.Optional(InlineAgentSchema),\n instructions: Type.Optional(Type.String({ description: 'Extra instructions appended to this delegated brief' })),\n relevantFiles: Type.Optional(\n Type.Array(Type.String(), {\n description: `Files already read or located for this task. Paths are relative to the working directory; at most ${MAX_BRIEF_FILES} are used.`,\n }),\n ),\n priorFindings: Type.Optional(\n Type.String({ description: 'Established facts this child should consume rather than re-derive' }),\n ),\n model: Type.Optional(Type.String({ description: 'Model override for this delegated run' })),\n context: Type.Optional(\n Type.String({\n enum: [...TASK_CONTEXTS],\n description: \"Starting context for this child: 'fresh' or 'fork'\",\n }),\n ),\n },\n { additionalProperties: false },\n);\n\n/**\n * Tool parameters. Every `description` doubles as LLM-facing prompt copy, so\n * wording changes here change model behaviour.\n */\nexport const TaskParamsSchema = Type.Object({\n action: Type.String({\n enum: [...TASK_ACTIONS],\n description:\n 'upsert (create new tasks and change existing ones, one or many per call), list, get, delete (tombstone), clear (close/reset the list), assign (delegate one or more tasks through assignments[]), cancel (stop a delegated run)',\n }),\n tasks: Type.Optional(\n Type.Array(TaskItemSchema, {\n minItems: 1,\n description:\n 'upsert only. One entry per task: an entry with an id changes that task, an entry without an id creates one. Entries apply in array order, so a later entry can depend on an earlier one by ref. Each entry succeeds or fails on its own: the ones that succeed are committed and the ones that fail are reported by their array index.',\n }),\n ),\n assignments: Type.Optional(\n Type.Array(TaskAssignmentSchema, {\n minItems: 1,\n description:\n 'Required for assign, including one task. Each entry selects its own pending, unblocked task, agent, model, and context pack; successful entries remain delegated if another entry fails. assign has no top-level single-task form.',\n }),\n ),\n id: Type.Optional(\n Type.Integer({\n description:\n 'Task id, for get, delete, and cancel. For assign, put every id inside assignments[]. upsert does not accept this field — put the id inside the tasks[] entry you want to change.',\n }),\n ),\n status: Type.Optional(\n Type.String({\n enum: [...TASK_STATUSES],\n description:\n 'list only: return just the tasks in this status. To SET a status, use upsert with the task id inside tasks[].',\n }),\n ),\n includeDeleted: Type.Optional(\n Type.Boolean({\n description: 'If true, list returns deleted (tombstoned) tasks as well. Default: false.',\n }),\n ),\n});\n\nexport type TaskItemParams = Static<typeof TaskItemSchema>;\nexport type TaskAssignmentParams = Static<typeof TaskAssignmentSchema>;\nexport type TaskParams = Static<typeof TaskParamsSchema>;\n"],"mappings":"kKAKA,MAAa,EAAe,CAAC,SAAU,OAAQ,MA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SACnB,EAAK,QAAQ,CACX,YAAa,2EACf,CAAC,CACH,CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../adapters/telemetry/logSinkTelemetry.cjs"),n=require("../store/types.cjs"),r=require("../store/reconcile.cjs"),i=require("../store/taskGraph.cjs");let a=require("@agimon-ai/doompi-extension-contracts/protocol"),o=require("node:crypto"),s=require("node:path");s=e.__toESM(s,1);let c=require("@agimon-ai/doompi-extension-contracts/delegation");const l=`doom-task-notify`,u=`completed`,d=`failed`,f=`cancelled`,p=`task.id`,m=`delegation.request_id`,h=`delegation.agent_name`,g=`delegation.context_present`,_=`delegation.context_file_count`,v=`delegation.context_notes_length`,y=`No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.`,b=`assign is only available in the main session. Update this task directly instead of re-delegating it.`,x=`Subagent did not acknowledge the cancel request`;function S(e,t=4e3){if(e)return e.length<=t?e:`${e.slice(0,t)}\n… (truncated)`}function C(e){return e instanceof Error?e.message:String(e)}function w(e,t){if(!s.default.isAbsolute(e))return s.default.normalize(e);let n=s.default.relative(t,e);return n&&!n.startsWith(`..`)?n:e}function T(e,t){let n=new Set;for(let r of e.relevantFiles??[]){if(n.size>=12)break;let e=w(r.trim(),t);e&&e!==`.`&&n.add(e)}return{files:[...n],notes:S(e.priorFindings?.trim(),1500)}}function E(e,t,n){let r=[`Task #${e.id}: ${e.subject}`];if(e.description&&r.push(e.description),t&&r.push(t),n.files.length>0||n.notes){let e=[`Parent context — consume before repository discovery:`];n.files.length>0&&e.push(`- Parent-verified files (read these first with direct reads): ${n.files.join(`, `)}`),n.notes&&e.push(`- Established facts (do not re-derive unless direct evidence contradicts them): ${n.notes}`),e.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.`),r.push(e.join(`
2
+ `))}return r.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.`),r.join(`
3
+
4
+ `)}var D=class e{options;progress=new Map;pendingTasks=new Map;timers=new Map;subscriptions=[];protocol;constructor(e){this.options=e}now(){return this.options.now?.()??new Date().toISOString()}nowMs(){return this.options.nowMs?.()??Date.now()}get env(){return this.options.env??process.env}get runTimeoutMs(){return this.options.runTimeoutMs??12e5}report(e,t,n){this.options.report?.error(e,t,n)}get isChildSession(){return!!this.env.PI_SUBAGENT_CHILD}progressFor(e){let t=e.delegation?.requestId;return t?this.progress.get(t):void 0}static elapsedMs(e,t=Date.now()){let n=e.durationMs??0,r=e.durationObservedAt??t;return n+Math.max(0,t-r)}start(){if(this.subscriptions.length>0)return;let e=this.options.getSessionId?.();e&&(this.protocol=(0,a.createProtocolRuntime)({bus:this.options.events,source:`@agimon-ai/doompi-task`,sessionId:e}),this.subscriptions.push(this.protocol.onNotification(c.DelegationAccepted,e=>{this.handleAccepted(e)}),this.protocol.onNotification(c.DelegationStarted,e=>{this.handleStarted(e)}),this.protocol.onNotification(c.DelegationUpdated,e=>{this.handleUpdate(e)}),this.protocol.onNotification(c.DelegationFinished,e=>{this.handleResponse(e).catch(n=>{this.report(t.TASK_EVENT.delegationResponseFailed,n,{[m]:e.requestId})})})))}listActiveWork(){let e=this.options.getSessionId?.()??``;return[...this.pendingTasks.entries()].map(([t,n])=>({id:`task-${n}:${t}`,sessionId:e}))}async reconcile(){let{value:e}=await this.options.store.mutate(e=>{let t=r.reconcileOrphanedDelegations(e,this.now(),void 0,{pid:process.pid,liveRequestIds:new Set(this.pendingTasks.keys())});return t.orphaned.length===0?{value:[]}:{document:t.document,value:t.orphaned}});for(let n of e)this.options.report?.warn(t.TASK_EVENT.delegationOrphaned,Error(n.delegation?.result?.error??``),{[p]:n.id,...n.delegation?.agent?{[h]:n.delegation.agent}:{},...n.delegation?.pid===void 0?{}:{"delegation.pid":n.delegation.pid}});return e.length>0&&this.options.onChange?.(),e}async assign(e,r){let a=r.agent?.trim();if(!a)return{ok:!1,message:`agent required for assign`};if(this.isChildSession)return{ok:!1,message:b};if(r.signal?.aborted)return{ok:!1,message:`delegation cancelled before it started`};let s=(0,o.randomUUID)(),l=this.now(),f=T(r,this.options.cwd),{value:x}=await this.options.store.mutate(t=>{let o=t.tasks.findIndex(t=>t.id===e);if(o===-1)return{value:{ok:!1,message:`#${e} not found`}};let c=t.tasks[o];if(c.status===`deleted`)return{value:{ok:!1,message:`#${e} is deleted`}};if(c.status===u)return{value:{ok:!1,message:`#${e} is already completed`}};if(n.isDelegationActive(c))return{value:{ok:!1,message:`#${e} is already delegated to ${c.delegation?.agent}`}};if(i.isBlocked(t.tasks,c))return{value:{ok:!1,message:`#${e} is blocked by ${(c.blockedBy??[]).map(e=>`#${e}`).join(`, `)}`}};let d={requestId:s,agent:a,state:`requested`,pid:process.pid,startedAt:l,...this.options.getSessionId?.()?{sessionId:this.options.getSessionId()}:{},...r.model?{model:r.model}:{}},f=[...t.tasks];return f[o]={...c,owner:a,updatedAt:l,delegation:d},{document:{...t,tasks:f},value:{ok:!0,message:``,task:f[o]}}});if(!x.ok||!x.task)return{ok:!1,message:x.message};let S=f.notes?.length??0;this.pendingTasks.set(s,e),this.progress.set(s,{agent:a,contextFileCount:f.files.length,contextNotesLength:S}),this.armStartedTimeout(s);let w={requestId:s,taskId:e,agent:a,...r.inlineAgent?{inlineAgent:r.inlineAgent}:{},prompt:E(x.task,r.instructions,f),...r.context?{context:r.context}:{},cwd:this.options.cwd,artifacts:!0,timeoutMs:this.runTimeoutMs,runMode:`detached`,teamTask:{id:String(x.task.id),subject:x.task.subject},...r.model?{model:r.model}:{}};try{if(!this.protocol)throw Error(y);this.protocol.notify(c.DelegationRequested,w)}catch(n){this.report(t.TASK_EVENT.delegationRequestFailed,n,{[p]:e,[m]:s,[h]:a});let r=C(n);return await this.settle(s,d,{status:d,error:`Delegation request failed: ${r}`}),{ok:!1,message:`Could not dispatch #${e} to ${a}: ${r}`}}return this.options.report?.event(t.TASK_EVENT.delegationAssigned,{[p]:e,[m]:s,[h]:a,[g]:f.files.length>0||S>0,[_]:f.files.length,[v]:S,"delegation.brief_length":w.prompt.length}),this.options.onChange?.(),{ok:!0,message:`Delegated #${e} to ${a} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end your turn.`}}async cancel(e){let t=this.options.store.read().tasks.find(t=>t.id===e);if(!t)return{ok:!1,message:`#${e} not found`};if(!t.delegation||!n.isDelegationActive(t))return{ok:!1,message:`#${e} has no running delegation`};let{requestId:r}=t.delegation;return this.protocol?.notify(c.DelegationCancelled,{requestId:r}),this.armCancelTimeout(r),{ok:!0,message:`Cancelling delegation for #${e} (${t.delegation.agent})`}}settleDetached(e,n,r,i=t.TASK_EVENT.delegationSettleFailed){this.settle(e,n,r).catch(t=>{this.report(i,t,{[m]:e})})}armStartedTimeout(e){this.armTimer(e,this.options.startedTimeoutMs??5e3,()=>{this.settleDetached(e,d,{status:d,error:y})})}armRunTimeout(e){let n=Math.min(6e4,this.runTimeoutMs);this.armTimer(e,this.runTimeoutMs+n,()=>{let n=this.pendingTasks.get(e),r=this.progress.get(e)?.agent,i=Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);this.options.report?.warn(t.TASK_EVENT.delegationTimedOut,i,{...n===void 0?{}:{[p]:n},[m]:e,...r?{[h]:r}:{}}),this.protocol?.notify(c.DelegationCancelled,{requestId:e,reason:i.message}),this.settleDetached(e,d,{status:`timed_out`,error:i.message})})}armCancelTimeout(e){this.pendingTasks.has(e)&&this.armTimer(e,this.options.cancelTimeoutMs??1e4,()=>{this.settleDetached(e,f,{status:f,error:x})})}armTimer(e,t,n){this.clearTimer(e);let r=setTimeout(n,t);r.unref?.(),this.timers.set(e,r)}clearTimer(e){let t=this.timers.get(e);t&&clearTimeout(t),this.timers.delete(e)}handleAccepted(e){this.pendingTasks.has(e.requestId)&&this.armRunTimeout(e.requestId)}handleStarted(e){let{runId:n}=e,r=this.pendingTasks.get(e.requestId);if(r===void 0)return;this.armRunTimeout(e.requestId);let i=this.progress.get(e.requestId);i&&this.progress.set(e.requestId,{...i,durationMs:i.durationMs??0,durationObservedAt:i.durationObservedAt??this.nowMs()}),this.options.store.mutate(t=>this.patchDelegation(t,e.requestId,(e,t)=>({...e,status:e.status===u?e.status:`in_progress`,delegation:{...t,state:`running`,startedAt:t.startedAt??this.now(),...n?{runId:n}:{}}}))).then(()=>this.options.onChange?.()).catch(n=>{this.report(t.TASK_EVENT.delegationStartFailed,n,{[p]:r,[m]:e.requestId})})}handleUpdate(t){let n=this.progress.get(t.requestId);if(!n)return;let r=this.nowMs(),i=e.elapsedMs(n,r),a=t.durationMs!==void 0;this.progress.set(t.requestId,{...n,currentTool:t.currentTool??n.currentTool,toolCount:t.toolCount===void 0?n.toolCount:Math.max(n.toolCount??0,t.toolCount),tokens:t.tokens===void 0?n.tokens:Math.max(n.tokens??0,t.tokens),durationMs:a?Math.max(i,t.durationMs):n.durationMs,durationObservedAt:a?r:n.durationObservedAt}),this.options.onChange?.()}async handleResponse(e){if(!this.pendingTasks.has(e.requestId))return;let t=e.status===u&&!e.error?u:e.status===f?f:d;await this.settle(e.requestId,t,{status:e.status,error:e.error,output:S(e.output),outputPath:e.outputPath,sessionFile:e.sessionFile,durationMs:e.durationMs,toolCount:e.toolCount})}async settle(e,n,r){let a=this.pendingTasks.get(e);if(a===void 0)return;this.pendingTasks.delete(e),this.clearTimer(e);let o=this.progress.get(e);this.progress.delete(e);let s=this.now(),c;try{let{value:t}=await this.options.store.mutate(t=>this.patchDelegation(t,e,(e,t)=>({...e,status:n===u?u:n===f?`pending`:d,updatedAt:s,delegation:{...t,state:n,endedAt:s,...r?{result:r}:{}}})));c=t}catch(n){this.report(t.TASK_EVENT.delegationSettleFailed,n,{[p]:a,[m]:e})}this.options.onChange?.();let l=c?.delegation?.agent??o?.agent??`subagent`,y=c?.subject??`#${a}`;this.options.report?.event(t.TASK_EVENT.delegationCompleted,{[p]:a,[m]:e,[h]:l,"delegation.outcome":n,[g]:(o?.contextFileCount??0)>0||(o?.contextNotesLength??0)>0,[_]:o?.contextFileCount??0,[v]:o?.contextNotesLength??0,...r?.toolCount===void 0?{}:{"delegation.tool_count":r.toolCount},...r?.durationMs===void 0?{}:{"delegation.duration_ms":r.durationMs}});let b=n===u&&c!==void 0&&i.isTaskListComplete(this.options.store.snapshot.tasks);this.notifyModel(n,a,y,l,r,b)}notifyModel(e,t,n,r,i,a){let o=this.options.notify;if(!o)return;let s=[e===u?`Subagent ${r} completed task #${t}: ${n}`:e===f?`Subagent ${r} was cancelled on task #${t}: ${n} (returned to pending)`:`Subagent ${r} failed task #${t}: ${n}`];a&&s.push(``,`All tasks are completed. Review the full task list once more, then close it with task {"action":"clear"}.`),i?.error&&s.push(`Error: ${i.error}`),i?.output&&s.push(``,i.output),i?.outputPath&&s.push(``,`Full output: ${i.outputPath}`);try{o({customType:l,content:s.join(`
5
+ `),display:!0},{triggerTurn:!0,deliverAs:`steer`})}catch(e){this.options.onNotifyError(e,t)}}patchDelegation(e,t,r){let i=e.tasks.findIndex(e=>e.delegation?.requestId===t);if(i===-1)return{value:void 0};let a=e.tasks[i];if(!n.isDelegationActive(a))return{value:a};let o=r(a,a.delegation);if(o===a)return{value:a};let s=[...e.tasks];return s[i]=o,{document:{...e,tasks:s},value:o}}dispose(){for(let e of this.subscriptions)e();this.subscriptions.length=0,this.protocol=void 0;for(let e of this.timers.values())clearTimeout(e);this.timers.clear(),this.pendingTasks.clear(),this.progress.clear()}};exports.BACKGROUND_WORK_PROVIDER=`doom-task`,exports.DelegationManager=D,exports.ERR_CANCEL_UNACKNOWLEDGED=x,exports.ERR_CHILD_SESSION=b,exports.ERR_NO_RUNTIME=y,exports.MAX_BRIEF_FILES=12,exports.NOTIFY_CUSTOM_TYPE=l;
6
+ //# sourceMappingURL=manager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.cjs","names":["path","createProtocolRuntime","DelegationAccepted","DelegationStarted","DelegationUpdated","DelegationFinished","TASK_EVENT","reconcileOrphanedDelegations","randomUUID","isDelegationActive","isBlocked","DelegationRequested","DelegationCancelled","isTaskListComplete"],"sources":["../../../src/services/delegation/manager.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport path from 'node:path';\nimport {\n DelegationAccepted,\n type DelegationAccepted as DelegationAcceptedPayload,\n DelegationCancelled,\n DelegationFinished,\n DelegationRequested,\n type DelegationResult,\n DelegationStarted,\n type DelegationStarted as DelegationStartedPayload,\n type DelegationUpdate,\n DelegationUpdated,\n} from '@agimon-ai/doompi-extension-contracts/delegation';\nimport {\n createProtocolRuntime,\n type EventBusLike,\n type ProtocolRuntime,\n} from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { InlineAgent } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\nimport { TASK_EVENT, type TaskEventName, type TaskFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport { reconcileOrphanedDelegations } from '../store/reconcile.ts';\nimport { isBlocked, isTaskListComplete } from '../store/taskGraph.ts';\nimport type { TaskStore } from '../store/taskStore.ts';\nimport { isDelegationActive, type Task, type TaskDelegation, type TaskDocument } from '../store/types.ts';\n\nexport const NOTIFY_CUSTOM_TYPE = 'doom-task-notify';\nexport const BACKGROUND_WORK_PROVIDER = 'doom-task';\n\nconst DEFAULT_STARTED_TIMEOUT_MS = 5000;\nconst DEFAULT_RUN_TIMEOUT_MS = 20 * 60 * 1000;\nconst DEFAULT_CANCEL_TIMEOUT_MS = 10_000;\nconst MAX_RUN_TIMEOUT_GRACE_MS = 60_000;\nconst MAX_STORED_OUTPUT = 4000;\n/**\n * Cap on files rendered into a brief. Exported so the tool schema can state the\n * same number to the model rather than restating it and drifting.\n */\nexport const MAX_BRIEF_FILES = 12;\nconst MAX_BRIEF_NOTES = 1500;\nconst COMPLETED_STATE = 'completed';\nconst FAILED_STATE = 'failed';\nconst CANCELLED_STATE = 'cancelled';\nconst TIMED_OUT_STATUS = 'timed_out';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REQUEST_ID_ATTRIBUTE = 'delegation.request_id';\n// `_name` suffix is load-bearing: the telemetry redactor drops string values\n// whose key has no safe meaning, and a bare `delegation.agent` is dropped.\nconst AGENT_ATTRIBUTE = 'delegation.agent_name';\nconst PID_ATTRIBUTE = 'delegation.pid';\nconst CONTEXT_PRESENT_ATTRIBUTE = 'delegation.context_present';\nconst CONTEXT_FILE_COUNT_ATTRIBUTE = 'delegation.context_file_count';\nconst CONTEXT_NOTES_LENGTH_ATTRIBUTE = 'delegation.context_notes_length';\nconst BRIEF_LENGTH_ATTRIBUTE = 'delegation.brief_length';\nconst TOOL_COUNT_ATTRIBUTE = 'delegation.tool_count';\nconst DURATION_MS_ATTRIBUTE = 'delegation.duration_ms';\nconst OUTCOME_ATTRIBUTE = 'delegation.outcome';\n\ntype SettlementState = typeof COMPLETED_STATE | typeof FAILED_STATE | typeof CANCELLED_STATE;\n\nexport const ERR_NO_RUNTIME =\n 'No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.';\nexport const ERR_CHILD_SESSION =\n 'assign is only available in the main session. Update this task directly instead of re-delegating it.';\nexport const ERR_CANCEL_UNACKNOWLEDGED = 'Subagent did not acknowledge the cancel request';\n\n/** Live progress from a running subagent. Kept in memory: persisting per-tool\n * ticks would rewrite the store file every second for no durable benefit. */\nexport interface DelegationProgress {\n agent: string;\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n /** Latest child-runtime duration baseline, excluding assignment wait. */\n durationMs?: number;\n /** Wall-clock time at which durationMs was observed or rebased. */\n durationObservedAt?: number;\n /** Assign-time context-pack shape, carried so the completion event can be\n * grouped by it without joining back to the assignment event. */\n contextFileCount?: number;\n contextNotesLength?: number;\n}\n\nexport type DelegationNotifier = (\n message: { customType: string; content: string; display: boolean },\n options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn' },\n) => void;\n\nexport interface DelegationManagerOptions {\n events: EventBusLike;\n store: TaskStore;\n cwd: string;\n notify?: DelegationNotifier;\n getSessionId?: () => string | undefined;\n env?: NodeJS.ProcessEnv;\n onChange?: () => void;\n startedTimeoutMs?: number;\n /** How long a started run may go without reporting a result. */\n runTimeoutMs?: number;\n /** How long to wait for a cancelled run to report back before forcing it. */\n cancelTimeoutMs?: number;\n now?: () => string;\n nowMs?: () => number;\n /** Called when a completion notification could not be delivered. */\n onNotifyError: (error: unknown, taskId: number) => void;\n /** Where other swallowed delegation failures go. */\n report?: TaskFailureReporter;\n}\n\nexport interface AssignOptions {\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** Paths the parent already located, rendered into the brief so the child\n * skips rediscovering them. */\n relevantFiles?: string[];\n /** Facts the parent already established, rendered into the brief so the child\n * does not re-derive them. */\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n signal?: AbortSignal;\n}\n\nexport interface DelegationOutcome {\n ok: boolean;\n message: string;\n}\n\n/** Result of the guarded store mutation that claims a task for delegation. */\ninterface AssignAttempt extends DelegationOutcome {\n task?: Task;\n}\n\nfunction truncate(value: string | undefined, limit = MAX_STORED_OUTPUT): string | undefined {\n if (!value) return undefined;\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n… (truncated)`;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The assign-time context pack, normalized once for the brief and the telemetry. */\ninterface BriefContext {\n files: string[];\n notes?: string;\n}\n\n/**\n * Render a supplied path the way the child will see it, from `cwd`.\n *\n * Existence is deliberately not checked: an fs probe here duplicates the read\n * the child performs anyway, and it cannot detect the failure that actually\n * matters — a path that exists but is no longer the right one.\n */\nfunction briefPath(entry: string, cwd: string): string {\n if (!path.isAbsolute(entry)) return path.normalize(entry);\n const relative = path.relative(cwd, entry);\n // Outside the run directory the original beats a `../../` chain.\n return relative && !relative.startsWith('..') ? relative : entry;\n}\n\nfunction briefContext(options: AssignOptions, cwd: string): BriefContext {\n const files = new Set<string>();\n for (const entry of options.relevantFiles ?? []) {\n if (files.size >= MAX_BRIEF_FILES) break;\n const normalized = briefPath(entry.trim(), cwd);\n if (normalized && normalized !== '.') files.add(normalized);\n }\n return { files: [...files], notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES) };\n}\n\n/**\n * Build the brief handed to the subagent.\n *\n * Doom Team owns the child tool surface and the parent owns the task record.\n * Keeping those responsibilities explicit prevents a child from attempting to\n * call a task tool that is not loaded in its runtime, while still giving it a\n * reliable path to ask the parent for a decision.\n *\n * The context pack is the parent's verified discovery handed over. The whole\n * block is omitted when nothing was supplied: this brief is the child's whole\n * starting context, so an empty section header is pure token cost.\n */\nfunction buildBrief(task: Task, instructions: string | undefined, context: BriefContext): string {\n const sections = [`Task #${task.id}: ${task.subject}`];\n if (task.description) sections.push(task.description);\n if (instructions) sections.push(instructions);\n if (context.files.length > 0 || context.notes) {\n const contextLines = ['Parent context — consume before repository discovery:'];\n if (context.files.length > 0) {\n contextLines.push(`- Parent-verified files (read these first with direct reads): ${context.files.join(', ')}`);\n }\n if (context.notes) {\n contextLines.push(\n `- Established facts (do not re-derive unless direct evidence contradicts them): ${context.notes}`,\n );\n }\n contextLines.push(\n 'This pack satisfies initial repository/context exploration. Do not begin with repository-wide listing, find, or grep. Expand only after consuming the pack and naming a concrete missing dependency or invalid path; search narrowly for that item and state why.',\n );\n sections.push(contextLines.join('\\n'));\n }\n sections.push(\n 'Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.',\n );\n return sections.join('\\n\\n');\n}\n\n/**\n * Owns the lifecycle of tasks delegated to subagents.\n *\n * Delegation rides the Doom Team event bus rather than spawning\n * processes directly, so doom-task stays decoupled from the subagent runtime\n * and degrades to a clear error when that runtime is not loaded.\n *\n * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so\n * a delegation always has a deadline no matter which phase it is in. Losing\n * that pairing is what previously left tasks running forever.\n */\nexport class DelegationManager {\n private readonly options: DelegationManagerOptions;\n private readonly progress = new Map<string, DelegationProgress>();\n private readonly pendingTasks = new Map<string, number>();\n private readonly timers = new Map<string, NodeJS.Timeout>();\n private readonly subscriptions: Array<() => void> = [];\n private protocol: ProtocolRuntime | undefined;\n\n constructor(options: DelegationManagerOptions) {\n this.options = options;\n }\n\n private now(): string {\n return this.options.now?.() ?? new Date().toISOString();\n }\n\n private nowMs(): number {\n return this.options.nowMs?.() ?? Date.now();\n }\n\n private get env(): NodeJS.ProcessEnv {\n return this.options.env ?? process.env;\n }\n\n private get runTimeoutMs(): number {\n return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;\n }\n\n private report(event: TaskEventName, error: unknown, attributes?: Record<string, string | number | boolean>): void {\n this.options.report?.error(event, error, attributes);\n }\n\n /** True in a session that is itself a subagent child. */\n get isChildSession(): boolean {\n return Boolean(this.env.PI_SUBAGENT_CHILD);\n }\n\n /** Live progress for a task, for the overlay to render. */\n progressFor(task: Task): DelegationProgress | undefined {\n const requestId = task.delegation?.requestId;\n return requestId ? this.progress.get(requestId) : undefined;\n }\n\n /** Displayed runtime duration, rebased from the latest child observation. */\n static elapsedMs(progress: DelegationProgress, nowMs = Date.now()): number {\n const baseline = progress.durationMs ?? 0;\n const observedAt = progress.durationObservedAt ?? nowMs;\n return baseline + Math.max(0, nowMs - observedAt);\n }\n\n /** Idempotent: a session restart re-subscribes without stacking handlers. */\n start(): void {\n if (this.subscriptions.length > 0) return;\n const sessionId = this.options.getSessionId?.();\n if (!sessionId) return;\n this.protocol = createProtocolRuntime({\n bus: this.options.events,\n source: '@agimon-ai/doompi-task',\n sessionId,\n });\n this.subscriptions.push(\n this.protocol.onNotification(DelegationAccepted, (event) => {\n this.handleAccepted(event);\n }),\n this.protocol.onNotification(DelegationStarted, (event) => {\n this.handleStarted(event);\n }),\n this.protocol.onNotification(DelegationUpdated, (event) => {\n this.handleUpdate(event);\n }),\n this.protocol.onNotification(DelegationFinished, (event) => {\n void this.handleResponse(event).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });\n });\n }),\n );\n }\n\n /** Items still in flight, surfaced so auto-stop will not kill the harness. */\n listActiveWork(): Array<{ id: string; sessionId: string }> {\n const sessionId = this.options.getSessionId?.() ?? '';\n return [...this.pendingTasks.entries()].map(([requestId, taskId]) => ({\n id: `task-${taskId}:${requestId}`,\n sessionId,\n }));\n }\n\n /**\n * Return tasks nothing can finish to `pending`.\n *\n * The live request set is read inside the mutation so a delegation assigned\n * while the lock was contended is not mistaken for a leftover.\n */\n async reconcile(): Promise<Task[]> {\n const { value } = await this.options.store.mutate((document) => {\n const result = reconcileOrphanedDelegations(document, this.now(), undefined, {\n pid: process.pid,\n liveRequestIds: new Set(this.pendingTasks.keys()),\n });\n if (result.orphaned.length === 0) return { value: [] as Task[] };\n return { document: result.document, value: result.orphaned };\n });\n\n for (const task of value) {\n this.options.report?.warn(TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ''), {\n [TASK_ID_ATTRIBUTE]: task.id,\n ...(task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {}),\n ...(task.delegation?.pid === undefined ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }),\n });\n }\n\n if (value.length > 0) this.options.onChange?.();\n return value;\n }\n\n async assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome> {\n const agent = options.agent?.trim();\n if (!agent) return { ok: false, message: 'agent required for assign' };\n if (this.isChildSession) return { ok: false, message: ERR_CHILD_SESSION };\n if (options.signal?.aborted) return { ok: false, message: 'delegation cancelled before it started' };\n\n const requestId = randomUUID();\n const startedAt = this.now();\n const context = briefContext(options, this.options.cwd);\n\n const { value: outcome } = await this.options.store.mutate<AssignAttempt>((current) => {\n const index = current.tasks.findIndex((task) => task.id === taskId);\n if (index === -1) return { value: { ok: false, message: `#${taskId} not found` } };\n\n const task = current.tasks[index];\n if (task.status === DELETED_STATUS) return { value: { ok: false, message: `#${taskId} is deleted` } };\n if (task.status === COMPLETED_STATE) {\n return { value: { ok: false, message: `#${taskId} is already completed` } };\n }\n if (isDelegationActive(task)) {\n return { value: { ok: false, message: `#${taskId} is already delegated to ${task.delegation?.agent}` } };\n }\n if (isBlocked(current.tasks, task)) {\n const blockers = (task.blockedBy ?? []).map((id) => `#${id}`).join(', ');\n return { value: { ok: false, message: `#${taskId} is blocked by ${blockers}` } };\n }\n\n const delegation: TaskDelegation = {\n requestId,\n agent,\n state: 'requested',\n pid: process.pid,\n startedAt,\n ...(this.options.getSessionId?.() ? { sessionId: this.options.getSessionId!() } : {}),\n ...(options.model ? { model: options.model } : {}),\n };\n\n const tasks = [...current.tasks];\n tasks[index] = { ...task, owner: agent, updatedAt: startedAt, delegation };\n return {\n document: { ...current, tasks },\n value: { ok: true, message: '', task: tasks[index] },\n };\n });\n\n if (!outcome.ok || !outcome.task) return { ok: false, message: outcome.message };\n\n const contextNotesLength = context.notes?.length ?? 0;\n this.pendingTasks.set(requestId, taskId);\n this.progress.set(requestId, { agent, contextFileCount: context.files.length, contextNotesLength });\n this.armStartedTimeout(requestId);\n\n const request = {\n requestId,\n taskId,\n agent,\n ...(options.inlineAgent ? { inlineAgent: options.inlineAgent } : {}),\n prompt: buildBrief(outcome.task, options.instructions, context),\n ...(options.context ? { context: options.context } : {}),\n cwd: this.options.cwd,\n artifacts: true,\n timeoutMs: this.runTimeoutMs,\n runMode: 'detached' as const,\n teamTask: { id: String(outcome.task.id), subject: outcome.task.subject },\n ...(options.model ? { model: options.model } : {}),\n };\n\n try {\n if (!this.protocol) throw new Error(ERR_NO_RUNTIME);\n this.protocol.notify(DelegationRequested, request);\n } catch (error) {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n const detail = messageOf(error);\n await this.settle(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${detail}`,\n });\n return { ok: false, message: `Could not dispatch #${taskId} to ${agent}: ${detail}` };\n }\n\n // Emitted only after the notify succeeds, so it means \"a brief of this\n // shape actually went out\" rather than \"one was assembled\".\n this.options.report?.event(TASK_EVENT.delegationAssigned, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,\n [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length,\n });\n\n this.options.onChange?.();\n\n return {\n ok: true,\n message: `Delegated #${taskId} to ${agent} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end your turn.`,\n };\n }\n\n async cancel(taskId: number): Promise<DelegationOutcome> {\n const document = this.options.store.read();\n const task = document.tasks.find((candidate) => candidate.id === taskId);\n if (!task) return { ok: false, message: `#${taskId} not found` };\n if (!task.delegation || !isDelegationActive(task)) {\n return { ok: false, message: `#${taskId} has no running delegation` };\n }\n\n const { requestId } = task.delegation;\n this.protocol?.notify(DelegationCancelled, { requestId });\n // Only this session can force the outcome; a delegation owned elsewhere\n // gets the request and nothing more.\n this.armCancelTimeout(requestId);\n return { ok: true, message: `Cancelling delegation for #${taskId} (${task.delegation.agent})` };\n }\n\n /** Settle without awaiting, reporting rather than dropping a failure. */\n private settleDetached(\n requestId: string,\n state: SettlementState,\n result: TaskDelegation['result'],\n event: TaskEventName = TASK_EVENT.delegationSettleFailed,\n ): void {\n void this.settle(requestId, state, result).catch((error: unknown) => {\n this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });\n });\n }\n\n /**\n * Fail a delegation that nobody acknowledged.\n *\n * The bus cannot be probed for listeners, so silence is the only available\n * signal that the subagents runtime is absent. Without this the task would\n * sit in `requested` forever.\n */\n private armStartedTimeout(requestId: string): void {\n this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {\n this.settleDetached(requestId, FAILED_STATE, { status: FAILED_STATE, error: ERR_NO_RUNTIME });\n });\n }\n\n /**\n * Bound a run that already started.\n *\n * The request carries the same budget, so in the normal case the runtime ends\n * the run itself and reports a richer result. The grace period biases toward\n * that answer; this timer only covers a runtime that goes silent, which is\n * precisely the case where no response event will ever arrive.\n */\n private armRunTimeout(requestId: string): void {\n const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);\n this.armTimer(requestId, this.runTimeoutMs + grace, () => {\n const taskId = this.pendingTasks.get(requestId);\n const agent = this.progress.get(requestId)?.agent;\n const error = new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);\n this.options.report?.warn(TASK_EVENT.delegationTimedOut, error, {\n ...(taskId === undefined ? {} : { [TASK_ID_ATTRIBUTE]: taskId }),\n [REQUEST_ID_ATTRIBUTE]: requestId,\n ...(agent ? { [AGENT_ATTRIBUTE]: agent } : {}),\n });\n this.protocol?.notify(DelegationCancelled, { requestId, reason: error.message });\n this.settleDetached(requestId, FAILED_STATE, { status: TIMED_OUT_STATUS, error: error.message });\n });\n }\n\n /**\n * Guarantee a cancel reaches a terminal state.\n *\n * Emitting the cancel event is a request, not an outcome: a runtime that has\n * already forgotten the request answers nothing at all. The window still\n * favours a real response, which carries the run's partial output.\n */\n private armCancelTimeout(requestId: string): void {\n if (!this.pendingTasks.has(requestId)) return;\n this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {\n this.settleDetached(requestId, CANCELLED_STATE, {\n status: CANCELLED_STATE,\n error: ERR_CANCEL_UNACKNOWLEDGED,\n });\n });\n }\n\n private armTimer(requestId: string, delayMs: number, onFire: () => void): void {\n this.clearTimer(requestId);\n const timer = setTimeout(onFire, delayMs);\n timer.unref?.();\n this.timers.set(requestId, timer);\n }\n\n private clearTimer(requestId: string): void {\n const timer = this.timers.get(requestId);\n if (timer) clearTimeout(timer);\n this.timers.delete(requestId);\n }\n\n /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */\n private handleAccepted(event: DelegationAcceptedPayload): void {\n if (!this.pendingTasks.has(event.requestId)) return;\n this.armRunTimeout(event.requestId);\n }\n\n private handleStarted(event: DelegationStartedPayload): void {\n const { runId } = event;\n const taskId = this.pendingTasks.get(event.requestId);\n if (taskId === undefined) return;\n this.armRunTimeout(event.requestId);\n const existing = this.progress.get(event.requestId);\n if (existing) {\n this.progress.set(event.requestId, {\n ...existing,\n durationMs: existing.durationMs ?? 0,\n durationObservedAt: existing.durationObservedAt ?? this.nowMs(),\n });\n }\n\n void this.options.store\n .mutate((document) =>\n this.patchDelegation(document, event.requestId, (task, delegation) => ({\n ...task,\n status: task.status === COMPLETED_STATE ? task.status : 'in_progress',\n delegation: {\n ...delegation,\n state: 'running',\n startedAt: delegation.startedAt ?? this.now(),\n ...(runId ? { runId } : {}),\n },\n })),\n )\n .then(() => this.options.onChange?.())\n .catch((error: unknown) => {\n this.report(TASK_EVENT.delegationStartFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: event.requestId,\n });\n });\n }\n\n private handleUpdate(event: DelegationUpdate): void {\n const existing = this.progress.get(event.requestId);\n if (!existing) return;\n\n const observedAt = this.nowMs();\n const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);\n const hasDuration = event.durationMs !== undefined;\n this.progress.set(event.requestId, {\n // Spread, not field-by-field: anything carried on progress that this\n // event does not report (the assign-time context shape) must survive the\n // first update, or the completion event reports it as absent.\n ...existing,\n currentTool: event.currentTool ?? existing.currentTool,\n toolCount:\n event.toolCount === undefined ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),\n tokens: event.tokens === undefined ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),\n durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs!) : existing.durationMs,\n durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt,\n });\n this.options.onChange?.();\n }\n\n private async handleResponse(event: DelegationResult): Promise<void> {\n if (!this.pendingTasks.has(event.requestId)) return;\n\n const succeeded = event.status === COMPLETED_STATE && !event.error;\n const state = succeeded ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;\n await this.settle(event.requestId, state, {\n status: event.status,\n error: event.error,\n output: truncate(event.output),\n outputPath: event.outputPath,\n sessionFile: event.sessionFile,\n durationMs: event.durationMs,\n toolCount: event.toolCount,\n });\n }\n\n /**\n * Apply the terminal state of a delegation and tell the model about it.\n *\n * A cancelled run returns the task to `pending` (the work is still wanted,\n * just not by that agent); a failure marks it `failed` so it stays visible\n * rather than silently rejoining the backlog.\n *\n * Dropping the pending entry first makes this single-shot: a response racing\n * the watchdog cannot settle the same run twice. A failed write therefore\n * must not abort the rest — the model still gets told, the run stops counting\n * as active work, and `reconcile` repairs the file at the next session start.\n */\n private async settle(requestId: string, state: SettlementState, result: TaskDelegation['result']): Promise<void> {\n const taskId = this.pendingTasks.get(requestId);\n if (taskId === undefined) return;\n this.pendingTasks.delete(requestId);\n this.clearTimer(requestId);\n const progress = this.progress.get(requestId);\n this.progress.delete(requestId);\n\n const endedAt = this.now();\n let task: Task | undefined;\n try {\n const { value } = await this.options.store.mutate((document) =>\n this.patchDelegation(document, requestId, (current, delegation) => ({\n ...current,\n status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? 'pending' : FAILED_STATE,\n updatedAt: endedAt,\n delegation: { ...delegation, state, endedAt, ...(result ? { result } : {}) },\n })),\n );\n task = value;\n } catch (error) {\n this.report(TASK_EVENT.delegationSettleFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n });\n }\n\n this.options.onChange?.();\n\n const agent = task?.delegation?.agent ?? progress?.agent ?? 'subagent';\n const subject = task?.subject ?? `#${taskId}`;\n\n // Repeats the assign-time context shape so the cost question (\"did packs\n // reduce child tool calls?\") is one grouping rather than a self-join.\n // A run that never started reports neither metric, keeping the medians clean.\n this.options.report?.event(TASK_EVENT.delegationCompleted, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [OUTCOME_ATTRIBUTE]: state,\n [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,\n ...(result?.toolCount === undefined ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount }),\n ...(result?.durationMs === undefined ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }),\n });\n const listComplete =\n state === COMPLETED_STATE && task !== undefined && isTaskListComplete(this.options.store.snapshot.tasks);\n this.notifyModel(state, taskId, subject, agent, result, listComplete);\n }\n\n private notifyModel(\n state: SettlementState,\n taskId: number,\n subject: string,\n agent: string,\n result: TaskDelegation['result'],\n listComplete: boolean,\n ): void {\n const notify = this.options.notify;\n if (!notify) return;\n\n const headline =\n state === COMPLETED_STATE\n ? `Subagent ${agent} completed task #${taskId}: ${subject}`\n : state === CANCELLED_STATE\n ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)`\n : `Subagent ${agent} failed task #${taskId}: ${subject}`;\n\n const lines = [headline];\n if (listComplete) {\n lines.push(\n '',\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.',\n );\n }\n if (result?.error) lines.push(`Error: ${result.error}`);\n if (result?.output) lines.push('', result.output);\n if (result?.outputPath) lines.push('', `Full output: ${result.outputPath}`);\n\n try {\n notify(\n { customType: NOTIFY_CUSTOM_TYPE, content: lines.join('\\n'), display: true },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n } catch (error) {\n // The delegation state is already committed to the store, so a failed\n // notification costs the model its wake-up, not the result. Report it\n // rather than rethrowing, which would strand the settled run.\n this.options.onNotifyError(error, taskId);\n }\n }\n\n /**\n * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.\n *\n * Terminal delegations are left alone. The document here is the freshest one,\n * read under the store lock, which is the only place the check is meaningful:\n * a `started` event can land after a cancel already settled the run, and\n * without this guard its write would resurrect a delegation that nothing is\n * tracking any more.\n */\n private patchDelegation(\n document: TaskDocument,\n requestId: string,\n patch: (task: Task, delegation: TaskDelegation) => Task,\n ): { document?: TaskDocument; value: Task | undefined } {\n const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);\n if (index === -1) return { value: undefined };\n\n const task = document.tasks[index];\n if (!isDelegationActive(task)) return { value: task };\n\n const updated = patch(task, task.delegation!);\n if (updated === task) return { value: task };\n const tasks = [...document.tasks];\n tasks[index] = updated;\n return { document: { ...document, tasks }, value: updated };\n }\n\n dispose(): void {\n for (const unsubscribe of this.subscriptions) unsubscribe();\n this.subscriptions.length = 0;\n this.protocol = undefined;\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pendingTasks.clear();\n this.progress.clear();\n }\n}\n"],"mappings":"8ZA0BA,MAAa,EAAqB,mBAc5B,EAAkB,YAClB,EAAe,SACf,EAAkB,YAIlB,EAAoB,UACpB,EAAuB,wBAGvB,EAAkB,wBAElB,EAA4B,6BAC5B,EAA+B,gCAC/B,EAAiC,kCAQ1B,EACX,kHACW,EACX,uGACW,EAA4B,kDAsEzC,SAAS,EAAS,EAA2B,EAAQ,IAAuC,CACrF,KACL,OAAO,EAAM,QAAU,EAAQ,EAAQ,GAAG,EAAM,MAAM,EAAG,CAAK,EAAE,gBAClE,CAEA,SAAS,EAAU,EAAwB,CACzC,OAAO,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAC9D,CAeA,SAAS,EAAU,EAAe,EAA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