@agimon-ai/doompi-task 0.0.1-alpha.0 → 0.0.1-alpha.10

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 (329) hide show
  1. package/dist/adapters/pi/extension.cjs +3 -0
  2. package/dist/adapters/pi/extension.cjs.map +1 -0
  3. package/dist/adapters/pi/extension.d.cts +12 -0
  4. package/dist/adapters/pi/extension.d.cts.map +1 -0
  5. package/dist/adapters/pi/extension.d.mts +12 -0
  6. package/dist/adapters/pi/extension.d.mts.map +1 -0
  7. package/dist/adapters/pi/extension.mjs +3 -0
  8. package/dist/adapters/pi/extension.mjs.map +1 -0
  9. package/dist/adapters/store/paths.cjs +2 -0
  10. package/dist/adapters/store/paths.cjs.map +1 -0
  11. package/dist/adapters/store/paths.d.cts +26 -0
  12. package/dist/adapters/store/paths.d.cts.map +1 -0
  13. package/dist/adapters/store/paths.d.mts +26 -0
  14. package/dist/adapters/store/paths.d.mts.map +1 -0
  15. package/dist/adapters/store/paths.mjs +2 -0
  16. package/dist/adapters/store/paths.mjs.map +1 -0
  17. package/dist/adapters/store/taskStore.cjs +2 -0
  18. package/dist/adapters/store/taskStore.cjs.map +1 -0
  19. package/dist/adapters/store/taskStore.d.cts +87 -0
  20. package/dist/adapters/store/taskStore.d.cts.map +1 -0
  21. package/dist/adapters/store/taskStore.d.mts +87 -0
  22. package/dist/adapters/store/taskStore.d.mts.map +1 -0
  23. package/dist/adapters/store/taskStore.mjs +2 -0
  24. package/dist/adapters/store/taskStore.mjs.map +1 -0
  25. package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
  26. package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
  27. package/dist/adapters/telemetry/logSinkTelemetry.d.cts +52 -0
  28. package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
  29. package/dist/adapters/telemetry/logSinkTelemetry.d.mts +52 -0
  30. package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
  31. package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
  32. package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
  33. package/dist/commands/index.cjs +2 -0
  34. package/dist/commands/index.cjs.map +1 -0
  35. package/dist/commands/index.d.cts +15 -0
  36. package/dist/commands/index.d.cts.map +1 -0
  37. package/dist/commands/index.d.mts +15 -0
  38. package/dist/commands/index.d.mts.map +1 -0
  39. package/dist/commands/index.mjs +2 -0
  40. package/dist/commands/index.mjs.map +1 -0
  41. package/dist/commands/task/promptGuidelines.cjs +2 -0
  42. package/dist/commands/task/promptGuidelines.cjs.map +1 -0
  43. package/dist/commands/task/promptGuidelines.d.cts +5 -0
  44. package/dist/commands/task/promptGuidelines.d.cts.map +1 -0
  45. package/dist/commands/task/promptGuidelines.d.mts +5 -0
  46. package/dist/commands/task/promptGuidelines.d.mts.map +1 -0
  47. package/dist/commands/task/promptGuidelines.mjs +2 -0
  48. package/dist/commands/task/promptGuidelines.mjs.map +1 -0
  49. package/dist/commands/task/responseEnvelope.cjs +6 -0
  50. package/dist/commands/task/responseEnvelope.cjs.map +1 -0
  51. package/dist/commands/task/responseEnvelope.d.cts +39 -0
  52. package/dist/commands/task/responseEnvelope.d.cts.map +1 -0
  53. package/dist/commands/task/responseEnvelope.d.mts +39 -0
  54. package/dist/commands/task/responseEnvelope.d.mts.map +1 -0
  55. package/dist/commands/task/responseEnvelope.mjs +6 -0
  56. package/dist/commands/task/responseEnvelope.mjs.map +1 -0
  57. package/dist/commands/task/taskTool.cjs +3 -0
  58. package/dist/commands/task/taskTool.cjs.map +1 -0
  59. package/dist/commands/task/taskTool.d.cts +18 -0
  60. package/dist/commands/task/taskTool.d.cts.map +1 -0
  61. package/dist/commands/task/taskTool.d.mts +18 -0
  62. package/dist/commands/task/taskTool.d.mts.map +1 -0
  63. package/dist/commands/task/taskTool.mjs +3 -0
  64. package/dist/commands/task/taskTool.mjs.map +1 -0
  65. package/dist/commands.cjs +1 -2
  66. package/dist/commands.d.cts +2 -14
  67. package/dist/commands.d.mts +2 -14
  68. package/dist/commands.mjs +1 -2
  69. package/dist/config.cjs +1 -2
  70. package/dist/config.d.cts +2 -38
  71. package/dist/config.d.mts +2 -38
  72. package/dist/config.mjs +1 -2
  73. package/dist/delegation/manager.cjs +1 -5
  74. package/dist/delegation/manager.d.cts +2 -189
  75. package/dist/delegation/manager.d.mts +2 -189
  76. package/dist/delegation/manager.mjs +1 -5
  77. package/dist/extension.cjs +1 -3
  78. package/dist/extension.d.cts +2 -12
  79. package/dist/extension.d.mts +2 -12
  80. package/dist/extension.mjs +1 -3
  81. package/dist/extensions/doom.cjs +1 -1
  82. package/dist/extensions/doom.cjs.map +1 -1
  83. package/dist/extensions/doom.mjs +1 -1
  84. package/dist/extensions/doom.mjs.map +1 -1
  85. package/dist/extensions/pi.cjs +1 -1
  86. package/dist/extensions/pi.cjs.map +1 -1
  87. package/dist/extensions/pi.d.cts +1 -1
  88. package/dist/extensions/pi.d.mts +1 -1
  89. package/dist/extensions/pi.mjs +1 -1
  90. package/dist/extensions/pi.mjs.map +1 -1
  91. package/dist/index.cjs +1 -1
  92. package/dist/index.d.cts +16 -15
  93. package/dist/index.d.mts +16 -15
  94. package/dist/index.mjs +1 -1
  95. package/dist/logSinkTelemetry.cjs +1 -2
  96. package/dist/logSinkTelemetry.d.cts +2 -51
  97. package/dist/logSinkTelemetry.d.mts +2 -51
  98. package/dist/logSinkTelemetry.mjs +1 -2
  99. package/dist/schemas/task.cjs +2 -0
  100. package/dist/schemas/task.cjs.map +1 -0
  101. package/dist/schemas/task.d.cts +86 -0
  102. package/dist/schemas/task.d.cts.map +1 -0
  103. package/dist/schemas/task.d.mts +86 -0
  104. package/dist/schemas/task.d.mts.map +1 -0
  105. package/dist/schemas/task.mjs +2 -0
  106. package/dist/schemas/task.mjs.map +1 -0
  107. package/dist/services/delegation/manager.cjs +6 -0
  108. package/dist/services/delegation/manager.cjs.map +1 -0
  109. package/dist/services/delegation/manager.d.cts +188 -0
  110. package/dist/services/delegation/manager.d.cts.map +1 -0
  111. package/dist/services/delegation/manager.d.mts +188 -0
  112. package/dist/services/delegation/manager.d.mts.map +1 -0
  113. package/dist/services/delegation/manager.mjs +6 -0
  114. package/dist/services/delegation/manager.mjs.map +1 -0
  115. package/dist/services/narration/taskNarration.cjs +2 -0
  116. package/dist/services/narration/taskNarration.cjs.map +1 -0
  117. package/dist/services/narration/taskNarration.mjs +2 -0
  118. package/dist/services/narration/taskNarration.mjs.map +1 -0
  119. package/dist/services/store/invariants.cjs +2 -0
  120. package/dist/services/store/invariants.cjs.map +1 -0
  121. package/dist/services/store/invariants.d.cts +14 -0
  122. package/dist/services/store/invariants.d.cts.map +1 -0
  123. package/dist/services/store/invariants.d.mts +14 -0
  124. package/dist/services/store/invariants.d.mts.map +1 -0
  125. package/dist/services/store/invariants.mjs +2 -0
  126. package/dist/services/store/invariants.mjs.map +1 -0
  127. package/dist/services/store/paths.cjs +1 -0
  128. package/dist/services/store/paths.mjs +1 -0
  129. package/dist/services/store/processLiveness.cjs +2 -0
  130. package/dist/services/store/processLiveness.cjs.map +1 -0
  131. package/dist/services/store/processLiveness.d.cts +12 -0
  132. package/dist/services/store/processLiveness.d.cts.map +1 -0
  133. package/dist/services/store/processLiveness.d.mts +12 -0
  134. package/dist/services/store/processLiveness.d.mts.map +1 -0
  135. package/dist/services/store/processLiveness.mjs +2 -0
  136. package/dist/services/store/processLiveness.mjs.map +1 -0
  137. package/dist/services/store/reconcile.cjs +2 -0
  138. package/dist/services/store/reconcile.cjs.map +1 -0
  139. package/dist/services/store/reconcile.d.cts +34 -0
  140. package/dist/services/store/reconcile.d.cts.map +1 -0
  141. package/dist/services/store/reconcile.d.mts +34 -0
  142. package/dist/services/store/reconcile.d.mts.map +1 -0
  143. package/dist/services/store/reconcile.mjs +2 -0
  144. package/dist/services/store/reconcile.mjs.map +1 -0
  145. package/dist/services/store/reducer.cjs +3 -0
  146. package/dist/services/store/reducer.cjs.map +1 -0
  147. package/dist/services/store/reducer.d.cts +72 -0
  148. package/dist/services/store/reducer.d.cts.map +1 -0
  149. package/dist/services/store/reducer.d.mts +72 -0
  150. package/dist/services/store/reducer.d.mts.map +1 -0
  151. package/dist/services/store/reducer.mjs +3 -0
  152. package/dist/services/store/reducer.mjs.map +1 -0
  153. package/dist/services/store/taskGraph.cjs +2 -0
  154. package/dist/services/store/taskGraph.cjs.map +1 -0
  155. package/dist/services/store/taskGraph.d.cts +25 -0
  156. package/dist/services/store/taskGraph.d.cts.map +1 -0
  157. package/dist/services/store/taskGraph.d.mts +25 -0
  158. package/dist/services/store/taskGraph.d.mts.map +1 -0
  159. package/dist/services/store/taskGraph.mjs +2 -0
  160. package/dist/services/store/taskGraph.mjs.map +1 -0
  161. package/dist/services/store/taskStore.cjs +1 -0
  162. package/dist/services/store/taskStore.d.cts +2 -0
  163. package/dist/services/store/taskStore.d.mts +2 -0
  164. package/dist/services/store/taskStore.mjs +1 -0
  165. package/dist/services/store/types.cjs +2 -0
  166. package/dist/services/store/types.cjs.map +1 -0
  167. package/dist/services/store/types.d.cts +165 -0
  168. package/dist/services/store/types.d.cts.map +1 -0
  169. package/dist/services/store/types.d.mts +165 -0
  170. package/dist/services/store/types.d.mts.map +1 -0
  171. package/dist/services/store/types.mjs +2 -0
  172. package/dist/services/store/types.mjs.map +1 -0
  173. package/dist/store/invariants.cjs +1 -2
  174. package/dist/store/invariants.d.cts +2 -14
  175. package/dist/store/invariants.d.mts +2 -14
  176. package/dist/store/invariants.mjs +1 -2
  177. package/dist/store/paths.cjs +1 -2
  178. package/dist/store/paths.d.cts +2 -23
  179. package/dist/store/paths.d.mts +2 -23
  180. package/dist/store/paths.mjs +1 -2
  181. package/dist/store/processLiveness.cjs +1 -2
  182. package/dist/store/processLiveness.d.cts +2 -12
  183. package/dist/store/processLiveness.d.mts +2 -12
  184. package/dist/store/processLiveness.mjs +1 -2
  185. package/dist/store/reconcile.cjs +1 -2
  186. package/dist/store/reconcile.d.cts +2 -34
  187. package/dist/store/reconcile.d.mts +2 -34
  188. package/dist/store/reconcile.mjs +1 -2
  189. package/dist/store/reducer.cjs +1 -3
  190. package/dist/store/reducer.d.cts +2 -72
  191. package/dist/store/reducer.d.mts +2 -72
  192. package/dist/store/reducer.mjs +1 -3
  193. package/dist/store/taskGraph.cjs +1 -2
  194. package/dist/store/taskGraph.d.cts +2 -25
  195. package/dist/store/taskGraph.d.mts +2 -25
  196. package/dist/store/taskGraph.mjs +1 -2
  197. package/dist/store/taskStore.cjs +1 -2
  198. package/dist/store/taskStore.d.cts +3 -77
  199. package/dist/store/taskStore.d.mts +3 -77
  200. package/dist/store/taskStore.mjs +1 -2
  201. package/dist/store/types.cjs +1 -2
  202. package/dist/store/types.d.cts +2 -165
  203. package/dist/store/types.d.mts +2 -165
  204. package/dist/store/types.mjs +1 -2
  205. package/dist/tool/promptGuidelines.cjs +1 -2
  206. package/dist/tool/promptGuidelines.d.cts +2 -5
  207. package/dist/tool/promptGuidelines.d.mts +2 -5
  208. package/dist/tool/promptGuidelines.mjs +1 -2
  209. package/dist/tool/responseEnvelope.cjs +1 -6
  210. package/dist/tool/responseEnvelope.d.cts +2 -39
  211. package/dist/tool/responseEnvelope.d.mts +2 -39
  212. package/dist/tool/responseEnvelope.mjs +1 -6
  213. package/dist/tool/schema.cjs +1 -2
  214. package/dist/tool/schema.d.cts +2 -86
  215. package/dist/tool/schema.d.mts +2 -86
  216. package/dist/tool/schema.mjs +1 -2
  217. package/dist/tool/taskTool.cjs +1 -3
  218. package/dist/tool/taskTool.d.cts +3 -17
  219. package/dist/tool/taskTool.d.mts +3 -17
  220. package/dist/tool/taskTool.mjs +1 -3
  221. package/dist/tui/format.cjs +3 -3
  222. package/dist/tui/format.cjs.map +1 -1
  223. package/dist/tui/format.d.cts +3 -3
  224. package/dist/tui/format.d.cts.map +1 -1
  225. package/dist/tui/format.d.mts +3 -3
  226. package/dist/tui/format.d.mts.map +1 -1
  227. package/dist/tui/format.mjs +3 -3
  228. package/dist/tui/format.mjs.map +1 -1
  229. package/dist/tui/selectors.cjs +1 -1
  230. package/dist/tui/selectors.cjs.map +1 -1
  231. package/dist/tui/selectors.d.cts +17 -9
  232. package/dist/tui/selectors.d.cts.map +1 -1
  233. package/dist/tui/selectors.d.mts +17 -9
  234. package/dist/tui/selectors.d.mts.map +1 -1
  235. package/dist/tui/selectors.mjs +1 -1
  236. package/dist/tui/selectors.mjs.map +1 -1
  237. package/dist/tui/taskOverlay.cjs +1 -1
  238. package/dist/tui/taskOverlay.cjs.map +1 -1
  239. package/dist/tui/taskOverlay.d.cts +2 -2
  240. package/dist/tui/taskOverlay.d.cts.map +1 -1
  241. package/dist/tui/taskOverlay.d.mts +2 -2
  242. package/dist/tui/taskOverlay.d.mts.map +1 -1
  243. package/dist/tui/taskOverlay.mjs +1 -1
  244. package/dist/tui/taskOverlay.mjs.map +1 -1
  245. package/dist/tui/taskSpace.cjs +1 -1
  246. package/dist/tui/taskSpace.cjs.map +1 -1
  247. package/dist/tui/taskSpace.d.cts +2 -1
  248. package/dist/tui/taskSpace.d.cts.map +1 -1
  249. package/dist/tui/taskSpace.d.mts +2 -1
  250. package/dist/tui/taskSpace.d.mts.map +1 -1
  251. package/dist/tui/taskSpace.mjs +1 -1
  252. package/dist/tui/taskSpace.mjs.map +1 -1
  253. package/dist/types/config.cjs +2 -0
  254. package/dist/types/config.cjs.map +1 -0
  255. package/dist/types/config.d.cts +38 -0
  256. package/dist/types/config.d.cts.map +1 -0
  257. package/dist/types/config.d.mts +38 -0
  258. package/dist/types/config.d.mts.map +1 -0
  259. package/dist/types/config.mjs +2 -0
  260. package/dist/types/config.mjs.map +1 -0
  261. package/package.json +4 -4
  262. package/dist/commands.cjs.map +0 -1
  263. package/dist/commands.d.cts.map +0 -1
  264. package/dist/commands.d.mts.map +0 -1
  265. package/dist/commands.mjs.map +0 -1
  266. package/dist/config.cjs.map +0 -1
  267. package/dist/config.d.cts.map +0 -1
  268. package/dist/config.d.mts.map +0 -1
  269. package/dist/config.mjs.map +0 -1
  270. package/dist/delegation/manager.cjs.map +0 -1
  271. package/dist/delegation/manager.d.cts.map +0 -1
  272. package/dist/delegation/manager.d.mts.map +0 -1
  273. package/dist/delegation/manager.mjs.map +0 -1
  274. package/dist/extension.cjs.map +0 -1
  275. package/dist/extension.d.cts.map +0 -1
  276. package/dist/extension.d.mts.map +0 -1
  277. package/dist/extension.mjs.map +0 -1
  278. package/dist/logSinkTelemetry.cjs.map +0 -1
  279. package/dist/logSinkTelemetry.d.cts.map +0 -1
  280. package/dist/logSinkTelemetry.d.mts.map +0 -1
  281. package/dist/logSinkTelemetry.mjs.map +0 -1
  282. package/dist/store/invariants.cjs.map +0 -1
  283. package/dist/store/invariants.d.cts.map +0 -1
  284. package/dist/store/invariants.d.mts.map +0 -1
  285. package/dist/store/invariants.mjs.map +0 -1
  286. package/dist/store/paths.cjs.map +0 -1
  287. package/dist/store/paths.d.cts.map +0 -1
  288. package/dist/store/paths.d.mts.map +0 -1
  289. package/dist/store/paths.mjs.map +0 -1
  290. package/dist/store/processLiveness.cjs.map +0 -1
  291. package/dist/store/processLiveness.d.cts.map +0 -1
  292. package/dist/store/processLiveness.d.mts.map +0 -1
  293. package/dist/store/processLiveness.mjs.map +0 -1
  294. package/dist/store/reconcile.cjs.map +0 -1
  295. package/dist/store/reconcile.d.cts.map +0 -1
  296. package/dist/store/reconcile.d.mts.map +0 -1
  297. package/dist/store/reconcile.mjs.map +0 -1
  298. package/dist/store/reducer.cjs.map +0 -1
  299. package/dist/store/reducer.d.cts.map +0 -1
  300. package/dist/store/reducer.d.mts.map +0 -1
  301. package/dist/store/reducer.mjs.map +0 -1
  302. package/dist/store/taskGraph.cjs.map +0 -1
  303. package/dist/store/taskGraph.d.cts.map +0 -1
  304. package/dist/store/taskGraph.d.mts.map +0 -1
  305. package/dist/store/taskGraph.mjs.map +0 -1
  306. package/dist/store/taskStore.cjs.map +0 -1
  307. package/dist/store/taskStore.d.cts.map +0 -1
  308. package/dist/store/taskStore.d.mts.map +0 -1
  309. package/dist/store/taskStore.mjs.map +0 -1
  310. package/dist/store/types.cjs.map +0 -1
  311. package/dist/store/types.d.cts.map +0 -1
  312. package/dist/store/types.d.mts.map +0 -1
  313. package/dist/store/types.mjs.map +0 -1
  314. package/dist/tool/promptGuidelines.cjs.map +0 -1
  315. package/dist/tool/promptGuidelines.d.cts.map +0 -1
  316. package/dist/tool/promptGuidelines.d.mts.map +0 -1
  317. package/dist/tool/promptGuidelines.mjs.map +0 -1
  318. package/dist/tool/responseEnvelope.cjs.map +0 -1
  319. package/dist/tool/responseEnvelope.d.cts.map +0 -1
  320. package/dist/tool/responseEnvelope.d.mts.map +0 -1
  321. package/dist/tool/responseEnvelope.mjs.map +0 -1
  322. package/dist/tool/schema.cjs.map +0 -1
  323. package/dist/tool/schema.d.cts.map +0 -1
  324. package/dist/tool/schema.d.mts.map +0 -1
  325. package/dist/tool/schema.mjs.map +0 -1
  326. package/dist/tool/taskTool.cjs.map +0 -1
  327. package/dist/tool/taskTool.d.cts.map +0 -1
  328. package/dist/tool/taskTool.d.mts.map +0 -1
  329. package/dist/tool/taskTool.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskTool.mjs","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport {\n MSG_UPSERT_FIELD_MISPLACED,\n TaskParamsSchema,\n TOOL_LABEL,\n TOOL_NAME,\n taskActionAcceptsField,\n} from '../../schemas/task.ts';\nimport type { DelegationManager, DelegationOutcome } from '../../services/delegation/manager.ts';\nimport { applyTaskMutation, isCommittingOp, type ReducerAction } from '../../services/store/reducer.ts';\nimport type { TaskStore } from '../../services/store/taskStore.ts';\nimport type { TaskAction, TaskMutationParams } from '../../services/store/types.ts';\nimport { renderTaskCall, renderTaskResult } from '../../tui/format.ts';\nimport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\nimport { buildTextResult, buildToolResult, formatUpsertFailureText, type ToolResult } from './responseEnvelope.ts';\n\nexport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\n\nexport const DEFAULT_PROMPT_SNIPPET =\n 'Manage a shared task list to track multi-step progress, and delegate tasks to subagents';\n\nexport interface TaskToolDependencies {\n store: TaskStore;\n delegation: DelegationManager;\n onChange?: () => void;\n report?: TaskFailureReporter;\n}\n\nconst ACTION_ATTRIBUTE = 'tool.action';\nconst TASK_ID_ATTRIBUTE = 'task.id';\n\nconst REDUCER_ACTIONS = new Set<TaskAction>(['upsert', 'list', 'get', 'delete', 'clear']);\n\nclass TaskToolExecutionError extends Error {}\n\nfunction actionableTaskError(action: TaskAction, message: string): TaskToolExecutionError {\n return new TaskToolExecutionError(\n [\n `Task ${action} failed: ${message}`,\n '',\n 'Options:',\n '- List the task board and inspect the current ids, states, and blockers.',\n '- Correct the arguments or state conflict, then retry once.',\n '- Ask the user before cancelling work or changing dependencies to recover.',\n ].join('\\n'),\n );\n}\n\n/**\n * Reject a field that belongs to a different action.\n *\n * The params schema is flat and shared across every action, so this is the only\n * place `{\"action\":\"upsert\",\"id\":3}` can be caught — and it must be, because\n * the entry it carries has no id and would silently create a duplicate task.\n */\nfunction rejectStrayFields(action: TaskAction, params: TaskMutationParams): void {\n const stray = Object.keys(params).filter((key) => params[key] !== undefined && !taskActionAcceptsField(action, key));\n if (stray.length === 0) return;\n const hint = action === 'upsert' ? ` ${MSG_UPSERT_FIELD_MISPLACED}` : '';\n throw actionableTaskError(action, `${action} does not accept ${stray.join(', ')}.${hint}`);\n}\n\n/** Run an action through the reducer, persisting only when it produced a change. */\nasync function executeReducerAction(\n store: TaskStore,\n action: ReducerAction,\n params: TaskMutationParams,\n): Promise<ToolResult> {\n const { document, value } = await store.mutate((current) => {\n const result = applyTaskMutation(current, action, params);\n return {\n ...(isCommittingOp(result.op) ? { document: result.document } : {}),\n value: result,\n };\n });\n if (value.op.kind === 'error') throw actionableTaskError(action, value.op.message);\n // An upsert that applied nothing is a failed call: it wrote nothing and left\n // `rev` alone, so it must not read to the model as a success. A batch where\n // some entries landed returns normally — that is what partial apply means.\n if (value.op.kind === 'upsert' && value.op.applied === 0) {\n throw actionableTaskError(action, formatUpsertFailureText(value.op));\n }\n // `document` is the committed document, so `details.rev` matches what landed\n // on disk; `value.document` is the pre-write copy and lags by one.\n return buildToolResult(action, params, document, value.op);\n}\n\nexport function registerTaskTool(pi: ExtensionAPI, dependencies: TaskToolDependencies): void {\n const { store, delegation } = dependencies;\n\n pi.registerTool({\n name: TOOL_NAME,\n label: TOOL_LABEL,\n description:\n 'Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand the task to a named subagent that works it in the background), cancel (stop a delegated run). upsert applies each entry independently: successes are committed and failures are reported by array index, and an entry can depend on a task created by an earlier entry in the same call via a ref. Batch when writing a plan down; report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.',\n promptSnippet: DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: DEFAULT_PROMPT_GUIDELINES,\n parameters: TaskParamsSchema,\n\n async execute(_toolCallId, params, signal, onUpdate, _ctx) {\n const action = params.action as TaskAction;\n const mutationParams = params as TaskMutationParams;\n\n try {\n rejectStrayFields(action, mutationParams);\n if (REDUCER_ACTIONS.has(action)) {\n const result = await executeReducerAction(store, action as ReducerAction, mutationParams);\n dependencies.onChange?.();\n return result;\n }\n\n let outcome: DelegationOutcome;\n if (action === 'assign') {\n onUpdate?.(\n buildTextResult(\n action,\n mutationParams,\n store.snapshot,\n `Delegating task #${mutationParams.id ?? 'unknown'}...`,\n ),\n );\n outcome = await delegation.assign(mutationParams.id ?? Number.NaN, {\n agent: mutationParams.agent,\n inlineAgent: mutationParams.inlineAgent,\n instructions: mutationParams.instructions,\n relevantFiles: mutationParams.relevantFiles,\n priorFindings: mutationParams.priorFindings,\n model: mutationParams.model,\n context: mutationParams.context,\n signal,\n });\n } else {\n onUpdate?.(\n buildTextResult(\n action,\n mutationParams,\n store.snapshot,\n `Requesting cancellation for task #${mutationParams.id ?? 'unknown'}...`,\n ),\n );\n outcome = await delegation.cancel(mutationParams.id ?? Number.NaN);\n }\n\n dependencies.onChange?.();\n if (!outcome.ok) throw actionableTaskError(action, outcome.message);\n return buildTextResult(action, mutationParams, store.snapshot, outcome.message, undefined);\n } catch (error) {\n // Rethrown so pi still renders the failure to the model; recorded\n // because this is where a store fault becomes visible to the user.\n dependencies.report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: action,\n ...(mutationParams.id === undefined ? {} : { [TASK_ID_ATTRIBUTE]: mutationParams.id }),\n });\n if (error instanceof TaskToolExecutionError) throw error;\n throw actionableTaskError(action, error instanceof Error ? error.message : String(error));\n }\n },\n\n // Render hooks receive no session identity, so they read the store snapshot\n // that the executing session last loaded. That is the foreground session's\n // own view, which is exactly what its transcript should show.\n renderCall(args, theme, _context) {\n return renderTaskCall(args as never, theme, store.snapshot.tasks);\n },\n\n renderResult(result, options, theme, _context) {\n return renderTaskResult(result, options, theme);\n },\n });\n}\n"],"mappings":"mjBAmBA,MAAa,EACX,0FAYI,EAAkB,IAAI,IAAgB,CAAC,SAAU,OAAQ,MAAO,SAAU,OAAO,CAAC,EAExF,IAAM,EAAN,cAAqC,KAAM,CAAC,EAE5C,SAAS,EAAoB,EAAoB,EAAyC,CACxF,OAAO,IAAI,EACT,CACE,QAAQ,EAAO,WAAW,IAC1B,GACA,WACA,2EACA,8DACA,4EACF,CAAC,CAAC,KAAK;CAAI,CACb,CACF,CASA,SAAS,EAAkB,EAAoB,EAAkC,CAC/E,IAAM,EAAQ,OAAO,KAAK,CAAM,CAAC,CAAC,OAAQ,GAAQ,EAAO,KAAS,IAAA,IAAa,CAAC,EAAuB,EAAQ,CAAG,CAAC,EACnH,GAAI,EAAM,SAAW,EAAG,OACxB,IAAM,EAAO,IAAW,SAAW,IAAI,IAA+B,GACtE,MAAM,EAAoB,EAAQ,GAAG,EAAO,mBAAmB,EAAM,KAAK,IAAI,EAAE,GAAG,GAAM,CAC3F,CAGA,eAAe,EACb,EACA,EACA,EACqB,CACrB,GAAM,CAAE,WAAU,SAAU,MAAM,EAAM,OAAQ,GAAY,CAC1D,IAAM,EAAS,EAAkB,EAAS,EAAQ,CAAM,EACxD,MAAO,CACL,GAAI,EAAe,EAAO,EAAE,EAAI,CAAE,SAAU,EAAO,QAAS,EAAI,CAAC,EACjE,MAAO,CACT,CACF,CAAC,EACD,GAAI,EAAM,GAAG,OAAS,QAAS,MAAM,EAAoB,EAAQ,EAAM,GAAG,OAAO,EAIjF,GAAI,EAAM,GAAG,OAAS,UAAY,EAAM,GAAG,UAAY,EACrD,MAAM,EAAoB,EAAQ,EAAwB,EAAM,EAAE,CAAC,EAIrE,OAAO,EAAgB,EAAQ,EAAQ,EAAU,EAAM,EAAE,CAC3D,CAEA,SAAgB,EAAiB,EAAkB,EAA0C,CAC3F,GAAM,CAAE,QAAO,cAAe,EAE9B,EAAG,aAAa,CACd,KAAM,EACN,MAAO,EACP,YACE,m7BACF,cAAe,EACf,iBAAkB,EAClB,WAAY,EAEZ,MAAM,QAAQ,EAAa,EAAQ,EAAQ,EAAU,EAAM,CACzD,IAAM,EAAS,EAAO,OAChB,EAAiB,EAEvB,GAAI,CAEF,GADA,EAAkB,EAAQ,CAAc,EACpC,EAAgB,IAAI,CAAM,EAAG,CAC/B,IAAM,EAAS,MAAM,EAAqB,EAAO,EAAyB,CAAc,EAExF,OADA,EAAa,WAAW,EACjB,CACT,CAEA,IAAI,EAiCJ,GAhCI,IAAW,UACb,IACE,EACE,EACA,EACA,EAAM,SACN,oBAAoB,EAAe,IAAM,UAAU,IACrD,CACF,EACA,EAAU,MAAM,EAAW,OAAO,EAAe,IAAM,IAAY,CACjE,MAAO,EAAe,MACtB,YAAa,EAAe,YAC5B,aAAc,EAAe,aAC7B,cAAe,EAAe,cAC9B,cAAe,EAAe,cAC9B,MAAO,EAAe,MACtB,QAAS,EAAe,QACxB,QACF,CAAC,IAED,IACE,EACE,EACA,EACA,EAAM,SACN,qCAAqC,EAAe,IAAM,UAAU,IACtE,CACF,EACA,EAAU,MAAM,EAAW,OAAO,EAAe,IAAM,GAAU,GAGnE,EAAa,WAAW,EACpB,CAAC,EAAQ,GAAI,MAAM,EAAoB,EAAQ,EAAQ,OAAO,EAClE,OAAO,EAAgB,EAAQ,EAAgB,EAAM,SAAU,EAAQ,QAAS,IAAA,EAAS,CAC3F,OAAS,EAAO,CAQd,MALA,EAAa,QAAQ,MAAM,EAAW,WAAY,EAAO,CACtD,cAAmB,EACpB,GAAI,EAAe,KAAO,IAAA,GAAY,CAAC,EAAI,CAAG,UAAoB,EAAe,EAAG,CACtF,CAAC,EACG,aAAiB,EAA8B,EAC7C,EAAoB,EAAQ,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAAC,CAC1F,CACF,EAKA,WAAW,EAAM,EAAO,EAAU,CAChC,OAAO,EAAe,EAAe,EAAO,EAAM,SAAS,KAAK,CAClE,EAEA,aAAa,EAAQ,EAAS,EAAO,EAAU,CAC7C,OAAO,EAAiB,EAAQ,EAAS,CAAK,CAChD,CACF,CAAC,CACH"}
package/dist/commands.cjs CHANGED
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./tool/schema.cjs"),t=require("./tui/taskSpace.cjs");function n(n,r){n.registerCommand(e.COMMAND_NAME,{description:`Open Task Space for this session tree`,handler:async(n,i)=>{if(!i.hasUI){i.ui.notify(e.ERR_REQUIRES_INTERACTIVE,`error`);return}r.read(),await t.openTaskSpace(i,{store:r})}})}exports.registerTasksCommand=n;
2
- //# sourceMappingURL=commands.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./commands/index.cjs");exports.registerTasksCommand=e.registerTasksCommand;
@@ -1,14 +1,2 @@
1
- import { TaskStore } from "./store/taskStore.cjs";
2
- import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
- //#region src/commands.d.ts
4
- /**
5
- * `/tasks`, reachable from the leader palette as `SPC t t`.
6
- *
7
- * The command opens the Task Space overlay rather than printing a listing: the
8
- * overlay is the readable surface and it can edit, while a transcript dump could
9
- * only be read.
10
- */
11
- declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void;
12
- //#endregion
13
- export { registerTasksCommand };
14
- //# sourceMappingURL=commands.d.cts.map
1
+ import { registerTasksCommand } from "./commands/index.cjs";
2
+ export { registerTasksCommand };
@@ -1,14 +1,2 @@
1
- import { TaskStore } from "./store/taskStore.mjs";
2
- import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
- //#region src/commands.d.ts
4
- /**
5
- * `/tasks`, reachable from the leader palette as `SPC t t`.
6
- *
7
- * The command opens the Task Space overlay rather than printing a listing: the
8
- * overlay is the readable surface and it can edit, while a transcript dump could
9
- * only be read.
10
- */
11
- declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void;
12
- //#endregion
13
- export { registerTasksCommand };
14
- //# sourceMappingURL=commands.d.mts.map
1
+ import { registerTasksCommand } from "./commands/index.mjs";
2
+ export { registerTasksCommand };
package/dist/commands.mjs CHANGED
@@ -1,2 +1 @@
1
- import{COMMAND_NAME as e,ERR_REQUIRES_INTERACTIVE as t}from"./tool/schema.mjs";import{openTaskSpace as n}from"./tui/taskSpace.mjs";function r(r,i){r.registerCommand(e,{description:`Open Task Space for this session tree`,handler:async(e,r)=>{if(!r.hasUI){r.ui.notify(t,`error`);return}i.read(),await n(r,{store:i})}})}export{r as registerTasksCommand};
2
- //# sourceMappingURL=commands.mjs.map
1
+ import{registerTasksCommand as e}from"./commands/index.mjs";export{e as registerTasksCommand};
package/dist/config.cjs CHANGED
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=`DOOM_TASK_COLLAPSE_KEY`,t=`DOOM_TASK_STORE_TTL_MS`,n=`DOOM_TASK_DELEGATION_TIMEOUT_MS`,r=`ctrl+shift+t`,i=2592e6,a=12e5;function o(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function s(e){let t=o(e),n=typeof t.maxWidgetLines==`number`&&Number.isFinite(t.maxWidgetLines)?Math.min(Math.max(t.maxWidgetLines,3),60):12,s=typeof t.storeTtlMs==`number`&&Number.isFinite(t.storeTtlMs)&&t.storeTtlMs>0?t.storeTtlMs:i,c=typeof t.delegationTimeoutMs==`number`&&Number.isFinite(t.delegationTimeoutMs)&&t.delegationTimeoutMs>0?t.delegationTimeoutMs:a;return{maxWidgetLines:n,storeTtlMs:s,collapseKey:typeof t.collapseKey==`string`&&t.collapseKey.trim()?t.collapseKey.trim().toLowerCase()===`off`?`off`:t.collapseKey.trim():r,delegationTimeoutMs:c}}function c(e=process.env){let t=Number.parseInt(e.DOOM_TASK_MAX_WIDGET_LINES??``,10);return Number.isFinite(t)?Math.min(Math.max(t,3),60):12}function l(e=process.env){let n=Number(e[t]);return Number.isFinite(n)&&n>0?n:i}function u(e=process.env){let t=Number(e[n]);return Number.isFinite(t)&&t>0?t:a}function d(t=process.env){let n=t[e]?.trim();return n?n.toLowerCase()===`off`?`off`:n:r}exports.COLLAPSE_KEY_ENV=e,exports.COLLAPSE_KEY_OFF=`off`,exports.DEFAULT_COLLAPSE_KEY=r,exports.DEFAULT_DELEGATION_TIMEOUT_MS=a,exports.DEFAULT_MAX_WIDGET_LINES=12,exports.DEFAULT_STORE_TTL_MS=i,exports.DELEGATION_TIMEOUT_MS_ENV=n,exports.MAX_WIDGET_LINES_ENV=`DOOM_TASK_MAX_WIDGET_LINES`,exports.STORE_TTL_MS_ENV=t,exports.getDelegationTimeoutMs=u,exports.getMaxWidgetLines=c,exports.getStoreTtlMs=l,exports.parsePiTaskConfig=s,exports.resolveCollapseKey=d;
2
- //# sourceMappingURL=config.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./types/config.cjs");exports.COLLAPSE_KEY_ENV=e.COLLAPSE_KEY_ENV,exports.COLLAPSE_KEY_OFF=e.COLLAPSE_KEY_OFF,exports.DEFAULT_COLLAPSE_KEY=e.DEFAULT_COLLAPSE_KEY,exports.DEFAULT_DELEGATION_TIMEOUT_MS=e.DEFAULT_DELEGATION_TIMEOUT_MS,exports.DEFAULT_MAX_WIDGET_LINES=e.DEFAULT_MAX_WIDGET_LINES,exports.DEFAULT_STORE_TTL_MS=e.DEFAULT_STORE_TTL_MS,exports.DELEGATION_TIMEOUT_MS_ENV=e.DELEGATION_TIMEOUT_MS_ENV,exports.MAX_WIDGET_LINES_ENV=e.MAX_WIDGET_LINES_ENV,exports.STORE_TTL_MS_ENV=e.STORE_TTL_MS_ENV,exports.getDelegationTimeoutMs=e.getDelegationTimeoutMs,exports.getMaxWidgetLines=e.getMaxWidgetLines,exports.getStoreTtlMs=e.getStoreTtlMs,exports.parsePiTaskConfig=e.parsePiTaskConfig,exports.resolveCollapseKey=e.resolveCollapseKey;
package/dist/config.d.cts CHANGED
@@ -1,38 +1,2 @@
1
- //#region src/config.d.ts
2
- /**
3
- * Extension configuration, read from the environment.
4
- *
5
- * Env rather than a config file: doom-pi already carries per-launch state to Pi
6
- * through env vars, so this keeps doom-task consistent with how the harness
7
- * configures the rest of the extension set.
8
- */
9
- declare const MAX_WIDGET_LINES_ENV = "DOOM_TASK_MAX_WIDGET_LINES";
10
- declare const COLLAPSE_KEY_ENV = "DOOM_TASK_COLLAPSE_KEY";
11
- declare const STORE_TTL_MS_ENV = "DOOM_TASK_STORE_TTL_MS";
12
- declare const DELEGATION_TIMEOUT_MS_ENV = "DOOM_TASK_DELEGATION_TIMEOUT_MS";
13
- declare const DEFAULT_MAX_WIDGET_LINES = 12;
14
- declare const DEFAULT_COLLAPSE_KEY = "ctrl+shift+t";
15
- declare const DEFAULT_STORE_TTL_MS: number;
16
- /** Deliberately under the subagents auto-drain ceiling (30 min) so a headless
17
- * session still gets the failure and a model turn before draining gives up. */
18
- declare const DEFAULT_DELEGATION_TIMEOUT_MS: number;
19
- declare const COLLAPSE_KEY_OFF = "off";
20
- interface PiTaskConfig {
21
- maxWidgetLines: number;
22
- storeTtlMs: number;
23
- collapseKey: string;
24
- delegationTimeoutMs: number;
25
- }
26
- /** Parse configuration only after the Pi host has applied its project-trust policy. */
27
- declare function parsePiTaskConfig(value: unknown): PiTaskConfig;
28
- /** Rows the overlay may use for content, clamped to a sane range. */
29
- declare function getMaxWidgetLines(env?: NodeJS.ProcessEnv): number;
30
- /** Retention window for inactive session-tree stores. */
31
- declare function getStoreTtlMs(env?: NodeJS.ProcessEnv): number;
32
- /** How long a delegated run may go without reporting a result. */
33
- declare function getDelegationTimeoutMs(env?: NodeJS.ProcessEnv): number;
34
- /** Collapse shortcut, or the `off` sentinel when the user disabled it. */
35
- declare function resolveCollapseKey(env?: NodeJS.ProcessEnv): string;
36
- //#endregion
37
- export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
38
- //# sourceMappingURL=config.d.cts.map
1
+ import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.cjs";
2
+ export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
package/dist/config.d.mts CHANGED
@@ -1,38 +1,2 @@
1
- //#region src/config.d.ts
2
- /**
3
- * Extension configuration, read from the environment.
4
- *
5
- * Env rather than a config file: doom-pi already carries per-launch state to Pi
6
- * through env vars, so this keeps doom-task consistent with how the harness
7
- * configures the rest of the extension set.
8
- */
9
- declare const MAX_WIDGET_LINES_ENV = "DOOM_TASK_MAX_WIDGET_LINES";
10
- declare const COLLAPSE_KEY_ENV = "DOOM_TASK_COLLAPSE_KEY";
11
- declare const STORE_TTL_MS_ENV = "DOOM_TASK_STORE_TTL_MS";
12
- declare const DELEGATION_TIMEOUT_MS_ENV = "DOOM_TASK_DELEGATION_TIMEOUT_MS";
13
- declare const DEFAULT_MAX_WIDGET_LINES = 12;
14
- declare const DEFAULT_COLLAPSE_KEY = "ctrl+shift+t";
15
- declare const DEFAULT_STORE_TTL_MS: number;
16
- /** Deliberately under the subagents auto-drain ceiling (30 min) so a headless
17
- * session still gets the failure and a model turn before draining gives up. */
18
- declare const DEFAULT_DELEGATION_TIMEOUT_MS: number;
19
- declare const COLLAPSE_KEY_OFF = "off";
20
- interface PiTaskConfig {
21
- maxWidgetLines: number;
22
- storeTtlMs: number;
23
- collapseKey: string;
24
- delegationTimeoutMs: number;
25
- }
26
- /** Parse configuration only after the Pi host has applied its project-trust policy. */
27
- declare function parsePiTaskConfig(value: unknown): PiTaskConfig;
28
- /** Rows the overlay may use for content, clamped to a sane range. */
29
- declare function getMaxWidgetLines(env?: NodeJS.ProcessEnv): number;
30
- /** Retention window for inactive session-tree stores. */
31
- declare function getStoreTtlMs(env?: NodeJS.ProcessEnv): number;
32
- /** How long a delegated run may go without reporting a result. */
33
- declare function getDelegationTimeoutMs(env?: NodeJS.ProcessEnv): number;
34
- /** Collapse shortcut, or the `off` sentinel when the user disabled it. */
35
- declare function resolveCollapseKey(env?: NodeJS.ProcessEnv): string;
36
- //#endregion
37
- export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
38
- //# sourceMappingURL=config.d.mts.map
1
+ import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.mjs";
2
+ export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
package/dist/config.mjs CHANGED
@@ -1,2 +1 @@
1
- const e=`DOOM_TASK_MAX_WIDGET_LINES`,t=`DOOM_TASK_COLLAPSE_KEY`,n=`DOOM_TASK_STORE_TTL_MS`,r=`DOOM_TASK_DELEGATION_TIMEOUT_MS`,i=12,a=`ctrl+shift+t`,o=2592e6,s=12e5,c=`off`;function l(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function u(e){let t=l(e),n=typeof t.maxWidgetLines==`number`&&Number.isFinite(t.maxWidgetLines)?Math.min(Math.max(t.maxWidgetLines,3),60):12,r=typeof t.storeTtlMs==`number`&&Number.isFinite(t.storeTtlMs)&&t.storeTtlMs>0?t.storeTtlMs:o,i=typeof t.delegationTimeoutMs==`number`&&Number.isFinite(t.delegationTimeoutMs)&&t.delegationTimeoutMs>0?t.delegationTimeoutMs:s;return{maxWidgetLines:n,storeTtlMs:r,collapseKey:typeof t.collapseKey==`string`&&t.collapseKey.trim()?t.collapseKey.trim().toLowerCase()===`off`?`off`:t.collapseKey.trim():a,delegationTimeoutMs:i}}function d(e=process.env){let t=Number.parseInt(e.DOOM_TASK_MAX_WIDGET_LINES??``,10);return Number.isFinite(t)?Math.min(Math.max(t,3),60):12}function f(e=process.env){let t=Number(e[n]);return Number.isFinite(t)&&t>0?t:o}function p(e=process.env){let t=Number(e[r]);return Number.isFinite(t)&&t>0?t:s}function m(e=process.env){let n=e[t]?.trim();return n?n.toLowerCase()===`off`?`off`:n:a}export{t as COLLAPSE_KEY_ENV,c as COLLAPSE_KEY_OFF,a as DEFAULT_COLLAPSE_KEY,s as DEFAULT_DELEGATION_TIMEOUT_MS,i as DEFAULT_MAX_WIDGET_LINES,o as DEFAULT_STORE_TTL_MS,r as DELEGATION_TIMEOUT_MS_ENV,e as MAX_WIDGET_LINES_ENV,n as STORE_TTL_MS_ENV,p as getDelegationTimeoutMs,d as getMaxWidgetLines,f as getStoreTtlMs,u as parsePiTaskConfig,m as resolveCollapseKey};
2
- //# sourceMappingURL=config.mjs.map
1
+ import{COLLAPSE_KEY_ENV as e,COLLAPSE_KEY_OFF as t,DEFAULT_COLLAPSE_KEY as n,DEFAULT_DELEGATION_TIMEOUT_MS as r,DEFAULT_MAX_WIDGET_LINES as i,DEFAULT_STORE_TTL_MS as a,DELEGATION_TIMEOUT_MS_ENV as o,MAX_WIDGET_LINES_ENV as s,STORE_TTL_MS_ENV as c,getDelegationTimeoutMs as l,getMaxWidgetLines as u,getStoreTtlMs as d,parsePiTaskConfig as f,resolveCollapseKey as p}from"./types/config.mjs";export{e as COLLAPSE_KEY_ENV,t as COLLAPSE_KEY_OFF,n as DEFAULT_COLLAPSE_KEY,r as DEFAULT_DELEGATION_TIMEOUT_MS,i as DEFAULT_MAX_WIDGET_LINES,a as DEFAULT_STORE_TTL_MS,o as DELEGATION_TIMEOUT_MS_ENV,s as MAX_WIDGET_LINES_ENV,c as STORE_TTL_MS_ENV,l as getDelegationTimeoutMs,u as getMaxWidgetLines,d as getStoreTtlMs,f as parsePiTaskConfig,p as resolveCollapseKey};
@@ -1,5 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../logSinkTelemetry.cjs"),n=require("../store/types.cjs"),r=require("../store/reconcile.cjs"),i=require("../store/taskGraph.cjs");let a=require("node:crypto"),o=require("node:path");o=e.__toESM(o,1);let s=require("@agimon-ai/doompi-extension-contracts/delegation"),c=require("@agimon-ai/doompi-extension-contracts/protocol");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(!o.default.isAbsolute(e))return o.default.normalize(e);let n=o.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}`];return e.description&&r.push(e.description),t&&r.push(t),n.files.length>0&&r.push(`Start here (main already located these, the list may be incomplete): ${n.files.join(`, `)}`),n.notes&&r.push(`Already established by main, do not re-derive: ${n.notes}`),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(`
2
-
3
- `)}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,c.createProtocolRuntime)({bus:this.options.events,source:`@agimon-ai/doompi-task`,sessionId:e}),this.subscriptions.push(this.protocol.onNotification(s.DelegationAccepted,e=>{this.handleAccepted(e)}),this.protocol.onNotification(s.DelegationStarted,e=>{this.handleStarted(e)}),this.protocol.onNotification(s.DelegationUpdated,e=>{this.handleUpdate(e)}),this.protocol.onNotification(s.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 o=r.agent?.trim();if(!o)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 c=(0,a.randomUUID)(),l=this.now(),f=T(r,this.options.cwd),{value:x}=await this.options.store.mutate(t=>{let a=t.tasks.findIndex(t=>t.id===e);if(a===-1)return{value:{ok:!1,message:`#${e} not found`}};let s=t.tasks[a];if(s.status===`deleted`)return{value:{ok:!1,message:`#${e} is deleted`}};if(s.status===u)return{value:{ok:!1,message:`#${e} is already completed`}};if(n.isDelegationActive(s))return{value:{ok:!1,message:`#${e} is already delegated to ${s.delegation?.agent}`}};if(i.isBlocked(t.tasks,s))return{value:{ok:!1,message:`#${e} is blocked by ${(s.blockedBy??[]).map(e=>`#${e}`).join(`, `)}`}};let d={requestId:c,agent:o,state:`requested`,pid:process.pid,startedAt:l,...this.options.getSessionId?.()?{sessionId:this.options.getSessionId()}:{},...r.model?{model:r.model}:{}},f=[...t.tasks];return f[a]={...s,owner:o,updatedAt:l,delegation:d},{document:{...t,tasks:f},value:{ok:!0,message:``,task:f[a]}}});if(!x.ok||!x.task)return{ok:!1,message:x.message};let S=f.notes?.length??0;this.pendingTasks.set(c,e),this.progress.set(c,{agent:o,contextFileCount:f.files.length,contextNotesLength:S}),this.armStartedTimeout(c);let w={requestId:c,taskId:e,agent:o,...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(s.DelegationRequested,w)}catch(n){this.report(t.TASK_EVENT.delegationRequestFailed,n,{[p]:e,[m]:c,[h]:o});let r=C(n);return await this.settle(c,d,{status:d,error:`Delegation request failed: ${r}`}),{ok:!1,message:`Could not dispatch #${e} to ${o}: ${r}`}}return this.options.report?.event(t.TASK_EVENT.delegationAssigned,{[p]:e,[m]:c,[h]:o,[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 ${o} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end the turn and wait.`}}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(s.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(s.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(`
4
- `),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;
5
- //# sourceMappingURL=manager.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/delegation/manager.cjs");exports.BACKGROUND_WORK_PROVIDER=e.BACKGROUND_WORK_PROVIDER,exports.DelegationManager=e.DelegationManager,exports.ERR_CANCEL_UNACKNOWLEDGED=e.ERR_CANCEL_UNACKNOWLEDGED,exports.ERR_CHILD_SESSION=e.ERR_CHILD_SESSION,exports.ERR_NO_RUNTIME=e.ERR_NO_RUNTIME,exports.MAX_BRIEF_FILES=e.MAX_BRIEF_FILES,exports.NOTIFY_CUSTOM_TYPE=e.NOTIFY_CUSTOM_TYPE;
@@ -1,189 +1,2 @@
1
- import { TaskFailureReporter } from "../logSinkTelemetry.cjs";
2
- import { Task } from "../store/types.cjs";
3
- import { TaskStore } from "../store/taskStore.cjs";
4
- import { InlineAgent } from "@agimon-ai/doompi-extension-contracts/subagent-tool";
5
- import { EventBusLike } from "@agimon-ai/doompi-extension-contracts/protocol";
6
- //#region src/delegation/manager.d.ts
7
- declare const NOTIFY_CUSTOM_TYPE = "doom-task-notify";
8
- declare const BACKGROUND_WORK_PROVIDER = "doom-task";
9
- /**
10
- * Cap on files rendered into a brief. Exported so the tool schema can state the
11
- * same number to the model rather than restating it and drifting.
12
- */
13
- declare const MAX_BRIEF_FILES = 12;
14
- declare const ERR_NO_RUNTIME = "No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.";
15
- declare const ERR_CHILD_SESSION = "assign is only available in the main session. Update this task directly instead of re-delegating it.";
16
- declare const ERR_CANCEL_UNACKNOWLEDGED = "Subagent did not acknowledge the cancel request";
17
- /** Live progress from a running subagent. Kept in memory: persisting per-tool
18
- * ticks would rewrite the store file every second for no durable benefit. */
19
- interface DelegationProgress {
20
- agent: string;
21
- currentTool?: string;
22
- toolCount?: number;
23
- tokens?: number;
24
- /** Latest child-runtime duration baseline, excluding assignment wait. */
25
- durationMs?: number;
26
- /** Wall-clock time at which durationMs was observed or rebased. */
27
- durationObservedAt?: number;
28
- /** Assign-time context-pack shape, carried so the completion event can be
29
- * grouped by it without joining back to the assignment event. */
30
- contextFileCount?: number;
31
- contextNotesLength?: number;
32
- }
33
- interface DelegationNotifier {
34
- (message: {
35
- customType: string;
36
- content: string;
37
- display: boolean;
38
- }, options?: {
39
- triggerTurn?: boolean;
40
- deliverAs?: 'steer' | 'followUp' | 'nextTurn';
41
- }): void;
42
- }
43
- interface DelegationManagerOptions {
44
- events: EventBusLike;
45
- store: TaskStore;
46
- cwd: string;
47
- notify?: DelegationNotifier;
48
- getSessionId?: () => string | undefined;
49
- env?: NodeJS.ProcessEnv;
50
- onChange?: () => void;
51
- startedTimeoutMs?: number;
52
- /** How long a started run may go without reporting a result. */
53
- runTimeoutMs?: number;
54
- /** How long to wait for a cancelled run to report back before forcing it. */
55
- cancelTimeoutMs?: number;
56
- now?: () => string;
57
- nowMs?: () => number;
58
- /** Called when a completion notification could not be delivered. */
59
- onNotifyError: (error: unknown, taskId: number) => void;
60
- /** Where other swallowed delegation failures go. */
61
- report?: TaskFailureReporter;
62
- }
63
- interface AssignOptions {
64
- agent?: string;
65
- inlineAgent?: InlineAgent;
66
- instructions?: string;
67
- /** Paths the parent already located, rendered into the brief so the child
68
- * skips rediscovering them. */
69
- relevantFiles?: string[];
70
- /** Facts the parent already established, rendered into the brief so the child
71
- * does not re-derive them. */
72
- priorFindings?: string;
73
- model?: string;
74
- context?: 'fresh' | 'fork';
75
- signal?: AbortSignal;
76
- }
77
- interface DelegationOutcome {
78
- ok: boolean;
79
- message: string;
80
- }
81
- /**
82
- * Owns the lifecycle of tasks delegated to subagents.
83
- *
84
- * Delegation rides the Doom Team event bus rather than spawning
85
- * processes directly, so doom-task stays decoupled from the subagent runtime
86
- * and degrades to a clear error when that runtime is not loaded.
87
- *
88
- * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so
89
- * a delegation always has a deadline no matter which phase it is in. Losing
90
- * that pairing is what previously left tasks running forever.
91
- */
92
- declare class DelegationManager {
93
- private readonly options;
94
- private readonly progress;
95
- private readonly pendingTasks;
96
- private readonly timers;
97
- private readonly subscriptions;
98
- private protocol;
99
- constructor(options: DelegationManagerOptions);
100
- private now;
101
- private nowMs;
102
- private get env();
103
- private get runTimeoutMs();
104
- private report;
105
- /** True in a session that is itself a subagent child. */
106
- get isChildSession(): boolean;
107
- /** Live progress for a task, for the overlay to render. */
108
- progressFor(task: Task): DelegationProgress | undefined;
109
- /** Displayed runtime duration, rebased from the latest child observation. */
110
- static elapsedMs(progress: DelegationProgress, nowMs?: number): number;
111
- /** Idempotent: a session restart re-subscribes without stacking handlers. */
112
- start(): void;
113
- /** Items still in flight, surfaced so auto-stop will not kill the harness. */
114
- listActiveWork(): Array<{
115
- id: string;
116
- sessionId: string;
117
- }>;
118
- /**
119
- * Return tasks nothing can finish to `pending`.
120
- *
121
- * The live request set is read inside the mutation so a delegation assigned
122
- * while the lock was contended is not mistaken for a leftover.
123
- */
124
- reconcile(): Promise<Task[]>;
125
- assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome>;
126
- cancel(taskId: number): Promise<DelegationOutcome>;
127
- /** Settle without awaiting, reporting rather than dropping a failure. */
128
- private settleDetached;
129
- /**
130
- * Fail a delegation that nobody acknowledged.
131
- *
132
- * The bus cannot be probed for listeners, so silence is the only available
133
- * signal that the subagents runtime is absent. Without this the task would
134
- * sit in `requested` forever.
135
- */
136
- private armStartedTimeout;
137
- /**
138
- * Bound a run that already started.
139
- *
140
- * The request carries the same budget, so in the normal case the runtime ends
141
- * the run itself and reports a richer result. The grace period biases toward
142
- * that answer; this timer only covers a runtime that goes silent, which is
143
- * precisely the case where no response event will ever arrive.
144
- */
145
- private armRunTimeout;
146
- /**
147
- * Guarantee a cancel reaches a terminal state.
148
- *
149
- * Emitting the cancel event is a request, not an outcome: a runtime that has
150
- * already forgotten the request answers nothing at all. The window still
151
- * favours a real response, which carries the run's partial output.
152
- */
153
- private armCancelTimeout;
154
- private armTimer;
155
- private clearTimer;
156
- /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */
157
- private handleAccepted;
158
- private handleStarted;
159
- private handleUpdate;
160
- private handleResponse;
161
- /**
162
- * Apply the terminal state of a delegation and tell the model about it.
163
- *
164
- * A cancelled run returns the task to `pending` (the work is still wanted,
165
- * just not by that agent); a failure marks it `failed` so it stays visible
166
- * rather than silently rejoining the backlog.
167
- *
168
- * Dropping the pending entry first makes this single-shot: a response racing
169
- * the watchdog cannot settle the same run twice. A failed write therefore
170
- * must not abort the rest — the model still gets told, the run stops counting
171
- * as active work, and `reconcile` repairs the file at the next session start.
172
- */
173
- private settle;
174
- private notifyModel;
175
- /**
176
- * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.
177
- *
178
- * Terminal delegations are left alone. The document here is the freshest one,
179
- * read under the store lock, which is the only place the check is meaningful:
180
- * a `started` event can land after a cancel already settled the run, and
181
- * without this guard its write would resurrect a delegation that nothing is
182
- * tracking any more.
183
- */
184
- private patchDelegation;
185
- dispose(): void;
186
- }
187
- //#endregion
188
- export { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE };
189
- //# sourceMappingURL=manager.d.cts.map
1
+ import { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE } from "../services/delegation/manager.cjs";
2
+ export { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE };
@@ -1,189 +1,2 @@
1
- import { TaskFailureReporter } from "../logSinkTelemetry.mjs";
2
- import { Task } from "../store/types.mjs";
3
- import { TaskStore } from "../store/taskStore.mjs";
4
- import { EventBusLike } from "@agimon-ai/doompi-extension-contracts/protocol";
5
- import { InlineAgent } from "@agimon-ai/doompi-extension-contracts/subagent-tool";
6
- //#region src/delegation/manager.d.ts
7
- declare const NOTIFY_CUSTOM_TYPE = "doom-task-notify";
8
- declare const BACKGROUND_WORK_PROVIDER = "doom-task";
9
- /**
10
- * Cap on files rendered into a brief. Exported so the tool schema can state the
11
- * same number to the model rather than restating it and drifting.
12
- */
13
- declare const MAX_BRIEF_FILES = 12;
14
- declare const ERR_NO_RUNTIME = "No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.";
15
- declare const ERR_CHILD_SESSION = "assign is only available in the main session. Update this task directly instead of re-delegating it.";
16
- declare const ERR_CANCEL_UNACKNOWLEDGED = "Subagent did not acknowledge the cancel request";
17
- /** Live progress from a running subagent. Kept in memory: persisting per-tool
18
- * ticks would rewrite the store file every second for no durable benefit. */
19
- interface DelegationProgress {
20
- agent: string;
21
- currentTool?: string;
22
- toolCount?: number;
23
- tokens?: number;
24
- /** Latest child-runtime duration baseline, excluding assignment wait. */
25
- durationMs?: number;
26
- /** Wall-clock time at which durationMs was observed or rebased. */
27
- durationObservedAt?: number;
28
- /** Assign-time context-pack shape, carried so the completion event can be
29
- * grouped by it without joining back to the assignment event. */
30
- contextFileCount?: number;
31
- contextNotesLength?: number;
32
- }
33
- interface DelegationNotifier {
34
- (message: {
35
- customType: string;
36
- content: string;
37
- display: boolean;
38
- }, options?: {
39
- triggerTurn?: boolean;
40
- deliverAs?: 'steer' | 'followUp' | 'nextTurn';
41
- }): void;
42
- }
43
- interface DelegationManagerOptions {
44
- events: EventBusLike;
45
- store: TaskStore;
46
- cwd: string;
47
- notify?: DelegationNotifier;
48
- getSessionId?: () => string | undefined;
49
- env?: NodeJS.ProcessEnv;
50
- onChange?: () => void;
51
- startedTimeoutMs?: number;
52
- /** How long a started run may go without reporting a result. */
53
- runTimeoutMs?: number;
54
- /** How long to wait for a cancelled run to report back before forcing it. */
55
- cancelTimeoutMs?: number;
56
- now?: () => string;
57
- nowMs?: () => number;
58
- /** Called when a completion notification could not be delivered. */
59
- onNotifyError: (error: unknown, taskId: number) => void;
60
- /** Where other swallowed delegation failures go. */
61
- report?: TaskFailureReporter;
62
- }
63
- interface AssignOptions {
64
- agent?: string;
65
- inlineAgent?: InlineAgent;
66
- instructions?: string;
67
- /** Paths the parent already located, rendered into the brief so the child
68
- * skips rediscovering them. */
69
- relevantFiles?: string[];
70
- /** Facts the parent already established, rendered into the brief so the child
71
- * does not re-derive them. */
72
- priorFindings?: string;
73
- model?: string;
74
- context?: 'fresh' | 'fork';
75
- signal?: AbortSignal;
76
- }
77
- interface DelegationOutcome {
78
- ok: boolean;
79
- message: string;
80
- }
81
- /**
82
- * Owns the lifecycle of tasks delegated to subagents.
83
- *
84
- * Delegation rides the Doom Team event bus rather than spawning
85
- * processes directly, so doom-task stays decoupled from the subagent runtime
86
- * and degrades to a clear error when that runtime is not loaded.
87
- *
88
- * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so
89
- * a delegation always has a deadline no matter which phase it is in. Losing
90
- * that pairing is what previously left tasks running forever.
91
- */
92
- declare class DelegationManager {
93
- private readonly options;
94
- private readonly progress;
95
- private readonly pendingTasks;
96
- private readonly timers;
97
- private readonly subscriptions;
98
- private protocol;
99
- constructor(options: DelegationManagerOptions);
100
- private now;
101
- private nowMs;
102
- private get env();
103
- private get runTimeoutMs();
104
- private report;
105
- /** True in a session that is itself a subagent child. */
106
- get isChildSession(): boolean;
107
- /** Live progress for a task, for the overlay to render. */
108
- progressFor(task: Task): DelegationProgress | undefined;
109
- /** Displayed runtime duration, rebased from the latest child observation. */
110
- static elapsedMs(progress: DelegationProgress, nowMs?: number): number;
111
- /** Idempotent: a session restart re-subscribes without stacking handlers. */
112
- start(): void;
113
- /** Items still in flight, surfaced so auto-stop will not kill the harness. */
114
- listActiveWork(): Array<{
115
- id: string;
116
- sessionId: string;
117
- }>;
118
- /**
119
- * Return tasks nothing can finish to `pending`.
120
- *
121
- * The live request set is read inside the mutation so a delegation assigned
122
- * while the lock was contended is not mistaken for a leftover.
123
- */
124
- reconcile(): Promise<Task[]>;
125
- assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome>;
126
- cancel(taskId: number): Promise<DelegationOutcome>;
127
- /** Settle without awaiting, reporting rather than dropping a failure. */
128
- private settleDetached;
129
- /**
130
- * Fail a delegation that nobody acknowledged.
131
- *
132
- * The bus cannot be probed for listeners, so silence is the only available
133
- * signal that the subagents runtime is absent. Without this the task would
134
- * sit in `requested` forever.
135
- */
136
- private armStartedTimeout;
137
- /**
138
- * Bound a run that already started.
139
- *
140
- * The request carries the same budget, so in the normal case the runtime ends
141
- * the run itself and reports a richer result. The grace period biases toward
142
- * that answer; this timer only covers a runtime that goes silent, which is
143
- * precisely the case where no response event will ever arrive.
144
- */
145
- private armRunTimeout;
146
- /**
147
- * Guarantee a cancel reaches a terminal state.
148
- *
149
- * Emitting the cancel event is a request, not an outcome: a runtime that has
150
- * already forgotten the request answers nothing at all. The window still
151
- * favours a real response, which carries the run's partial output.
152
- */
153
- private armCancelTimeout;
154
- private armTimer;
155
- private clearTimer;
156
- /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */
157
- private handleAccepted;
158
- private handleStarted;
159
- private handleUpdate;
160
- private handleResponse;
161
- /**
162
- * Apply the terminal state of a delegation and tell the model about it.
163
- *
164
- * A cancelled run returns the task to `pending` (the work is still wanted,
165
- * just not by that agent); a failure marks it `failed` so it stays visible
166
- * rather than silently rejoining the backlog.
167
- *
168
- * Dropping the pending entry first makes this single-shot: a response racing
169
- * the watchdog cannot settle the same run twice. A failed write therefore
170
- * must not abort the rest — the model still gets told, the run stops counting
171
- * as active work, and `reconcile` repairs the file at the next session start.
172
- */
173
- private settle;
174
- private notifyModel;
175
- /**
176
- * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.
177
- *
178
- * Terminal delegations are left alone. The document here is the freshest one,
179
- * read under the store lock, which is the only place the check is meaningful:
180
- * a `started` event can land after a cancel already settled the run, and
181
- * without this guard its write would resurrect a delegation that nothing is
182
- * tracking any more.
183
- */
184
- private patchDelegation;
185
- dispose(): void;
186
- }
187
- //#endregion
188
- export { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE };
189
- //# sourceMappingURL=manager.d.mts.map
1
+ import { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE } from "../services/delegation/manager.mjs";
2
+ export { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE };
@@ -1,5 +1 @@
1
- import{TASK_EVENT as e}from"../logSinkTelemetry.mjs";import{isDelegationActive as t}from"../store/types.mjs";import{reconcileOrphanedDelegations as n}from"../store/reconcile.mjs";import{isBlocked as r,isTaskListComplete as i}from"../store/taskGraph.mjs";import{randomUUID as a}from"node:crypto";import o from"node:path";import{DelegationAccepted as s,DelegationCancelled as c,DelegationFinished as l,DelegationRequested as u,DelegationStarted as d,DelegationUpdated as f}from"@agimon-ai/doompi-extension-contracts/delegation";import{createProtocolRuntime as p}from"@agimon-ai/doompi-extension-contracts/protocol";const m=`doom-task-notify`,h=`doom-task`,g=12,_=`completed`,v=`failed`,y=`cancelled`,b=`task.id`,x=`delegation.request_id`,S=`delegation.agent_name`,C=`delegation.context_present`,w=`delegation.context_file_count`,T=`delegation.context_notes_length`,E=`No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.`,D=`assign is only available in the main session. Update this task directly instead of re-delegating it.`,O=`Subagent did not acknowledge the cancel request`;function k(e,t=4e3){if(e)return e.length<=t?e:`${e.slice(0,t)}\n… (truncated)`}function A(e){return e instanceof Error?e.message:String(e)}function j(e,t){if(!o.isAbsolute(e))return o.normalize(e);let n=o.relative(t,e);return n&&!n.startsWith(`..`)?n:e}function M(e,t){let n=new Set;for(let r of e.relevantFiles??[]){if(n.size>=12)break;let e=j(r.trim(),t);e&&e!==`.`&&n.add(e)}return{files:[...n],notes:k(e.priorFindings?.trim(),1500)}}function N(e,t,n){let r=[`Task #${e.id}: ${e.subject}`];return e.description&&r.push(e.description),t&&r.push(t),n.files.length>0&&r.push(`Start here (main already located these, the list may be incomplete): ${n.files.join(`, `)}`),n.notes&&r.push(`Already established by main, do not re-derive: ${n.notes}`),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(`
2
-
3
- `)}var P=class o{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 t=this.options.getSessionId?.();t&&(this.protocol=p({bus:this.options.events,source:`@agimon-ai/doompi-task`,sessionId:t}),this.subscriptions.push(this.protocol.onNotification(s,e=>{this.handleAccepted(e)}),this.protocol.onNotification(d,e=>{this.handleStarted(e)}),this.protocol.onNotification(f,e=>{this.handleUpdate(e)}),this.protocol.onNotification(l,t=>{this.handleResponse(t).catch(n=>{this.report(e.delegationResponseFailed,n,{[x]:t.requestId})})})))}listActiveWork(){let e=this.options.getSessionId?.()??``;return[...this.pendingTasks.entries()].map(([t,n])=>({id:`task-${n}:${t}`,sessionId:e}))}async reconcile(){let{value:t}=await this.options.store.mutate(e=>{let t=n(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 t)this.options.report?.warn(e.delegationOrphaned,Error(n.delegation?.result?.error??``),{[b]:n.id,...n.delegation?.agent?{[S]:n.delegation.agent}:{},...n.delegation?.pid===void 0?{}:{"delegation.pid":n.delegation.pid}});return t.length>0&&this.options.onChange?.(),t}async assign(n,i){let o=i.agent?.trim();if(!o)return{ok:!1,message:`agent required for assign`};if(this.isChildSession)return{ok:!1,message:D};if(i.signal?.aborted)return{ok:!1,message:`delegation cancelled before it started`};let s=a(),c=this.now(),l=M(i,this.options.cwd),{value:d}=await this.options.store.mutate(e=>{let a=e.tasks.findIndex(e=>e.id===n);if(a===-1)return{value:{ok:!1,message:`#${n} not found`}};let l=e.tasks[a];if(l.status===`deleted`)return{value:{ok:!1,message:`#${n} is deleted`}};if(l.status===_)return{value:{ok:!1,message:`#${n} is already completed`}};if(t(l))return{value:{ok:!1,message:`#${n} is already delegated to ${l.delegation?.agent}`}};if(r(e.tasks,l))return{value:{ok:!1,message:`#${n} is blocked by ${(l.blockedBy??[]).map(e=>`#${e}`).join(`, `)}`}};let u={requestId:s,agent:o,state:`requested`,pid:process.pid,startedAt:c,...this.options.getSessionId?.()?{sessionId:this.options.getSessionId()}:{},...i.model?{model:i.model}:{}},d=[...e.tasks];return d[a]={...l,owner:o,updatedAt:c,delegation:u},{document:{...e,tasks:d},value:{ok:!0,message:``,task:d[a]}}});if(!d.ok||!d.task)return{ok:!1,message:d.message};let f=l.notes?.length??0;this.pendingTasks.set(s,n),this.progress.set(s,{agent:o,contextFileCount:l.files.length,contextNotesLength:f}),this.armStartedTimeout(s);let p={requestId:s,taskId:n,agent:o,...i.inlineAgent?{inlineAgent:i.inlineAgent}:{},prompt:N(d.task,i.instructions,l),...i.context?{context:i.context}:{},cwd:this.options.cwd,artifacts:!0,timeoutMs:this.runTimeoutMs,runMode:`detached`,teamTask:{id:String(d.task.id),subject:d.task.subject},...i.model?{model:i.model}:{}};try{if(!this.protocol)throw Error(E);this.protocol.notify(u,p)}catch(t){this.report(e.delegationRequestFailed,t,{[b]:n,[x]:s,[S]:o});let r=A(t);return await this.settle(s,v,{status:v,error:`Delegation request failed: ${r}`}),{ok:!1,message:`Could not dispatch #${n} to ${o}: ${r}`}}return this.options.report?.event(e.delegationAssigned,{[b]:n,[x]:s,[S]:o,[C]:l.files.length>0||f>0,[w]:l.files.length,[T]:f,"delegation.brief_length":p.prompt.length}),this.options.onChange?.(),{ok:!0,message:`Delegated #${n} to ${o} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end the turn and wait.`}}async cancel(e){let n=this.options.store.read().tasks.find(t=>t.id===e);if(!n)return{ok:!1,message:`#${e} not found`};if(!n.delegation||!t(n))return{ok:!1,message:`#${e} has no running delegation`};let{requestId:r}=n.delegation;return this.protocol?.notify(c,{requestId:r}),this.armCancelTimeout(r),{ok:!0,message:`Cancelling delegation for #${e} (${n.delegation.agent})`}}settleDetached(t,n,r,i=e.delegationSettleFailed){this.settle(t,n,r).catch(e=>{this.report(i,e,{[x]:t})})}armStartedTimeout(e){this.armTimer(e,this.options.startedTimeoutMs??5e3,()=>{this.settleDetached(e,v,{status:v,error:E})})}armRunTimeout(t){let n=Math.min(6e4,this.runTimeoutMs);this.armTimer(t,this.runTimeoutMs+n,()=>{let n=this.pendingTasks.get(t),r=this.progress.get(t)?.agent,i=Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);this.options.report?.warn(e.delegationTimedOut,i,{...n===void 0?{}:{[b]:n},[x]:t,...r?{[S]:r}:{}}),this.protocol?.notify(c,{requestId:t,reason:i.message}),this.settleDetached(t,v,{status:`timed_out`,error:i.message})})}armCancelTimeout(e){this.pendingTasks.has(e)&&this.armTimer(e,this.options.cancelTimeoutMs??1e4,()=>{this.settleDetached(e,y,{status:y,error:O})})}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(t){let{runId:n}=t,r=this.pendingTasks.get(t.requestId);if(r===void 0)return;this.armRunTimeout(t.requestId);let i=this.progress.get(t.requestId);i&&this.progress.set(t.requestId,{...i,durationMs:i.durationMs??0,durationObservedAt:i.durationObservedAt??this.nowMs()}),this.options.store.mutate(e=>this.patchDelegation(e,t.requestId,(e,t)=>({...e,status:e.status===_?e.status:`in_progress`,delegation:{...t,state:`running`,startedAt:t.startedAt??this.now(),...n?{runId:n}:{}}}))).then(()=>this.options.onChange?.()).catch(n=>{this.report(e.delegationStartFailed,n,{[b]:r,[x]:t.requestId})})}handleUpdate(e){let t=this.progress.get(e.requestId);if(!t)return;let n=this.nowMs(),r=o.elapsedMs(t,n),i=e.durationMs!==void 0;this.progress.set(e.requestId,{...t,currentTool:e.currentTool??t.currentTool,toolCount:e.toolCount===void 0?t.toolCount:Math.max(t.toolCount??0,e.toolCount),tokens:e.tokens===void 0?t.tokens:Math.max(t.tokens??0,e.tokens),durationMs:i?Math.max(r,e.durationMs):t.durationMs,durationObservedAt:i?n:t.durationObservedAt}),this.options.onChange?.()}async handleResponse(e){if(!this.pendingTasks.has(e.requestId))return;let t=e.status===_&&!e.error?_:e.status===y?y:v;await this.settle(e.requestId,t,{status:e.status,error:e.error,output:k(e.output),outputPath:e.outputPath,sessionFile:e.sessionFile,durationMs:e.durationMs,toolCount:e.toolCount})}async settle(t,n,r){let a=this.pendingTasks.get(t);if(a===void 0)return;this.pendingTasks.delete(t),this.clearTimer(t);let o=this.progress.get(t);this.progress.delete(t);let s=this.now(),c;try{let{value:e}=await this.options.store.mutate(e=>this.patchDelegation(e,t,(e,t)=>({...e,status:n===_?_:n===y?`pending`:v,updatedAt:s,delegation:{...t,state:n,endedAt:s,...r?{result:r}:{}}})));c=e}catch(n){this.report(e.delegationSettleFailed,n,{[b]:a,[x]:t})}this.options.onChange?.();let l=c?.delegation?.agent??o?.agent??`subagent`,u=c?.subject??`#${a}`;this.options.report?.event(e.delegationCompleted,{[b]:a,[x]:t,[S]:l,"delegation.outcome":n,[C]:(o?.contextFileCount??0)>0||(o?.contextNotesLength??0)>0,[w]:o?.contextFileCount??0,[T]:o?.contextNotesLength??0,...r?.toolCount===void 0?{}:{"delegation.tool_count":r.toolCount},...r?.durationMs===void 0?{}:{"delegation.duration_ms":r.durationMs}});let d=n===_&&c!==void 0&&i(this.options.store.snapshot.tasks);this.notifyModel(n,a,u,l,r,d)}notifyModel(e,t,n,r,i,a){let o=this.options.notify;if(!o)return;let s=[e===_?`Subagent ${r} completed task #${t}: ${n}`:e===y?`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:m,content:s.join(`
4
- `),display:!0},{triggerTurn:!0,deliverAs:`steer`})}catch(e){this.options.onNotifyError(e,t)}}patchDelegation(e,n,r){let i=e.tasks.findIndex(e=>e.delegation?.requestId===n);if(i===-1)return{value:void 0};let a=e.tasks[i];if(!t(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()}};export{h as BACKGROUND_WORK_PROVIDER,P as DelegationManager,O as ERR_CANCEL_UNACKNOWLEDGED,D as ERR_CHILD_SESSION,E as ERR_NO_RUNTIME,g as MAX_BRIEF_FILES,m as NOTIFY_CUSTOM_TYPE};
5
- //# sourceMappingURL=manager.mjs.map
1
+ import{BACKGROUND_WORK_PROVIDER as e,DelegationManager as t,ERR_CANCEL_UNACKNOWLEDGED as n,ERR_CHILD_SESSION as r,ERR_NO_RUNTIME as i,MAX_BRIEF_FILES as a,NOTIFY_CUSTOM_TYPE as o}from"../services/delegation/manager.mjs";export{e as BACKGROUND_WORK_PROVIDER,t as DelegationManager,n as ERR_CANCEL_UNACKNOWLEDGED,r as ERR_CHILD_SESSION,i as ERR_NO_RUNTIME,a as MAX_BRIEF_FILES,o as NOTIFY_CUSTOM_TYPE};