@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskStore.mjs","names":[],"sources":["../../../src/adapters/store/taskStore.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { isProcessAlive } from '../../services/store/processLiveness.ts';\nimport { emptyDocument, STORE_SCHEMA_VERSION, type Task, type TaskDocument } from '../../services/store/types.ts';\nimport { TASK_EVENT, type TaskFailureReporter } from '../telemetry/logSinkTelemetry.ts';\nimport { lockPathFor, resolveStorePath, STORE_PATH_ENV, tempPathFor } from './paths.ts';\n\nconst LOCK_TIMEOUT_MS = 2000;\nconst LOCK_STALE_MS = 10_000;\nconst LOCK_RETRY_BASE_MS = 10;\nconst LOCK_RETRY_MAX_MS = 60;\nconst WATCH_DEBOUNCE_MS = 150;\nconst POLL_INTERVAL_MS = 2000;\nconst UTF8_ENCODING = 'utf8';\nconst MISSING_FILE_CODE = 'ENOENT';\nconst LOCK_EXISTS_CODE = 'EEXIST';\nconst STORE_PATH_ATTRIBUTE = 'store.path';\n\nexport type TaskStoreCommitListener = (previous: TaskDocument, committed: TaskDocument) => void;\n\nexport interface TaskStoreOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n storePath?: string;\n onCommitted?: TaskStoreCommitListener;\n /** Backstop poll cadence for change detection. Lowered in tests so they do\n * not depend on `fs.watch`, whose delivery timing is platform-dependent. */\n pollIntervalMs?: number;\n /** How long to wait for the advisory lock before proceeding lock-free. */\n lockTimeoutMs?: number;\n /** Where swallowed failures go, so silent degradation stays visible. */\n report?: TaskFailureReporter;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid document.\n *\n * A corrupt or truncated store must not take the session down: the worst\n * acceptable outcome is starting from an empty list, never a crash on startup.\n */\nfunction normalizeDocument(parsed: unknown): TaskDocument {\n if (!parsed || typeof parsed !== 'object') return emptyDocument();\n const candidate = parsed as Partial<TaskDocument>;\n if (!Array.isArray(candidate.tasks)) return emptyDocument();\n\n const tasks = candidate.tasks.filter(\n (task): task is Task => Boolean(task) && typeof task === 'object' && typeof (task as Task).id === 'number',\n );\n const maxId = tasks.reduce((max, task) => Math.max(max, task.id), 0);\n return {\n version: typeof candidate.version === 'number' ? candidate.version : STORE_SCHEMA_VERSION,\n rev: typeof candidate.rev === 'number' ? candidate.rev : 0,\n nextId: typeof candidate.nextId === 'number' && candidate.nextId > maxId ? candidate.nextId : maxId + 1,\n tasks,\n };\n}\n\n/**\n * File-backed task store shared by one root session and its delegated children.\n *\n * Durability model: the JSON file is the source of truth. Mutations are\n * read-modify-write under an advisory lock so concurrent delegated processes\n * cannot clobber each other, and writes land via temp-file rename so a\n * crash mid-write can never leave a partial document behind.\n */\nexport class TaskStore {\n storePath: string;\n\n private readonly cwd: string;\n private readonly env: NodeJS.ProcessEnv;\n private cached: TaskDocument = emptyDocument();\n private lastKnownRev = -1;\n private watcher?: fs.FSWatcher;\n private pollTimer?: NodeJS.Timeout;\n private debounceTimer?: NodeJS.Timeout;\n private checkInFlight?: Promise<void>;\n private checkQueued = false;\n private watchGeneration = 0;\n private readonly listeners = new Set<(document: TaskDocument) => void>();\n private readonly pollIntervalMs: number;\n private readonly lockTimeoutMs: number;\n private readonly report?: TaskFailureReporter;\n private readonly onCommitted?: TaskStoreCommitListener;\n\n constructor(options: TaskStoreOptions = {}) {\n this.cwd = options.cwd ?? process.cwd();\n this.env = options.env ?? process.env;\n this.storePath = options.storePath ?? resolveStorePath(this.cwd, this.env);\n this.pollIntervalMs = options.pollIntervalMs ?? POLL_INTERVAL_MS;\n this.lockTimeoutMs = options.lockTimeoutMs ?? LOCK_TIMEOUT_MS;\n this.report = options.report;\n this.onCommitted = options.onCommitted;\n }\n\n /** Bind a default store to the current session tree before reading or watching it. */\n configureSession(sessionKey: string): void {\n if (this.env[STORE_PATH_ENV]?.trim()) return;\n this.stopWatching();\n this.storePath = resolveStorePath(this.cwd, this.env, sessionKey);\n this.cached = emptyDocument();\n this.lastKnownRev = -1;\n }\n\n /** Last document read from disk, without hitting the filesystem. */\n get snapshot(): TaskDocument {\n return this.cached;\n }\n\n read(): TaskDocument {\n try {\n const raw = fs.readFileSync(this.storePath, UTF8_ENCODING);\n this.cached = normalizeDocument(JSON.parse(raw));\n } catch (error) {\n // A missing file is the normal state before the first write. Anything\n // else means the task list just silently became empty, which is worth a\n // record: unreadable or corrupt JSON looks identical to \"no tasks yet\".\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n this.cached = emptyDocument();\n }\n this.lastKnownRev = this.cached.rev;\n return this.cached;\n }\n\n async readAsync(): Promise<TaskDocument> {\n this.cached = await this.readDocumentAsync();\n this.lastKnownRev = this.cached.rev;\n return this.cached;\n }\n\n private async readDocumentAsync(): Promise<TaskDocument> {\n try {\n const raw = await fs.promises.readFile(this.storePath, UTF8_ENCODING);\n return normalizeDocument(JSON.parse(raw));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n return emptyDocument();\n }\n }\n\n /**\n * Apply a mutation under the store lock.\n *\n * `mutate` receives the freshest on-disk document and returns either the next\n * document to commit or `undefined` for a read-only action (list/get), which\n * skips the write entirely so queries never bump `rev`.\n */\n async mutate<T>(\n mutate: (document: TaskDocument) => { document?: TaskDocument; value: T },\n ): Promise<{ document: TaskDocument; value: T }> {\n const release = await this.acquireLock();\n const outcome = (() => {\n try {\n const current = this.read();\n const mutation = mutate(current);\n if (!mutation.document) {\n return { result: { document: current, value: mutation.value } };\n }\n const committed = this.write(mutation.document);\n return {\n result: { document: committed, value: mutation.value },\n notification: { previous: current, committed },\n };\n } finally {\n release();\n }\n })();\n if (outcome.notification) {\n this.notifyCommitted(outcome.notification.previous, outcome.notification.committed);\n }\n return outcome.result;\n }\n\n private notifyCommitted(previous: TaskDocument, committed: TaskDocument): void {\n try {\n this.onCommitted?.(previous, committed);\n } catch (error) {\n this.report?.error(TASK_EVENT.storeCommitListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n\n private write(document: TaskDocument): TaskDocument {\n const next: TaskDocument = { ...document, version: STORE_SCHEMA_VERSION, rev: document.rev + 1 };\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const temp = tempPathFor(this.storePath);\n fs.writeFileSync(temp, `${JSON.stringify(next, undefined, 2)}\\n`, UTF8_ENCODING);\n fs.renameSync(temp, this.storePath);\n this.cached = next;\n this.lastKnownRev = next.rev;\n return next;\n }\n\n private async acquireLock(): Promise<() => void> {\n const lockPath = lockPathFor(this.storePath);\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const deadline = Date.now() + this.lockTimeoutMs;\n\n for (;;) {\n try {\n const handle = fs.openSync(lockPath, 'wx');\n fs.writeSync(handle, JSON.stringify({ pid: process.pid, time: Date.now() }));\n fs.closeSync(handle);\n return () => fs.rmSync(lockPath, { force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== LOCK_EXISTS_CODE) throw error;\n // The deadline is checked before breaking a stale lock so a peer that\n // keeps recreating one cannot spin this loop without bound.\n if (Date.now() >= deadline) {\n // Proceeding lock-free beats stalling the agent: the rename is atomic,\n // so the worst case is a lost concurrent update, not a corrupt file.\n // Reported because a lost update here can strand a delegation.\n this.report?.warn(\n TASK_EVENT.storeLockTimeout,\n new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),\n { [STORE_PATH_ATTRIBUTE]: this.storePath },\n );\n return () => {};\n }\n // Clearing a dead holder's lock still goes through the backoff. Yielding\n // on every iteration is what stops a peer that keeps recreating the\n // lock from turning this into a spin.\n this.breakStaleLock(lockPath);\n await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);\n }\n }\n }\n\n /** Remove a lock left behind by a dead process or one held implausibly long. */\n private breakStaleLock(lockPath: string): boolean {\n try {\n const holder = JSON.parse(fs.readFileSync(lockPath, UTF8_ENCODING)) as { pid?: number; time?: number };\n const expired = typeof holder.time === 'number' && Date.now() - holder.time > LOCK_STALE_MS;\n const dead = typeof holder.pid === 'number' && !isProcessAlive(holder.pid);\n if (!expired && !dead) return false;\n fs.unlinkSync(lockPath);\n return true;\n } catch (error) {\n // Losing the race to another breaker is normal; a persistent failure here\n // shows up as the lock timeout above, so this stays a warning.\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.warn(TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });\n }\n return false;\n }\n }\n\n /**\n * Notify when another process changes the store.\n *\n * `fs.watch` alone is unreliable across the rename-based write (and on some\n * network filesystems), so a slow poll backs it up. Writes made by this\n * process are filtered out by revision so the UI does not redraw twice.\n */\n onExternalChange(listener: (document: TaskDocument) => void): () => void {\n this.listeners.add(listener);\n this.startWatching();\n return () => {\n this.listeners.delete(listener);\n if (this.listeners.size === 0) this.stopWatching();\n };\n }\n\n private startWatching(): void {\n if (this.watcher || this.pollTimer) return;\n this.watchGeneration += 1;\n const directory = path.dirname(this.storePath);\n const fileName = path.basename(this.storePath);\n\n try {\n fs.mkdirSync(directory, { recursive: true });\n this.watcher = fs.watch(directory, (_event, changed) => {\n if (changed && changed !== fileName) return;\n this.scheduleCheck();\n });\n } catch (error) {\n // Polling still covers change detection, just more slowly.\n this.report?.warn(TASK_EVENT.storeWatchFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n\n this.pollTimer = setInterval(() => this.queueChangeCheck(), this.pollIntervalMs);\n this.pollTimer.unref?.();\n }\n\n private scheduleCheck(): void {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = setTimeout(() => this.queueChangeCheck(), WATCH_DEBOUNCE_MS);\n this.debounceTimer.unref?.();\n }\n\n private queueChangeCheck(): void {\n if (this.checkInFlight) {\n this.checkQueued = true;\n return;\n }\n const generation = this.watchGeneration;\n const execution = (async () => {\n do {\n this.checkQueued = false;\n await this.checkForChange(generation);\n } while (this.checkQueued && generation === this.watchGeneration);\n })().finally(() => {\n if (this.checkInFlight === execution) this.checkInFlight = undefined;\n });\n this.checkInFlight = execution;\n }\n\n private async checkForChange(generation: number): Promise<void> {\n const previousRev = this.lastKnownRev;\n const document = await this.readDocumentAsync();\n if (generation !== this.watchGeneration) return;\n if (this.lastKnownRev !== previousRev) {\n this.checkQueued = true;\n return;\n }\n this.cached = document;\n this.lastKnownRev = document.rev;\n if (document.rev === previousRev) return;\n for (const listener of this.listeners) {\n try {\n listener(document);\n } catch (error) {\n // This runs from a timer and from the fs.watch callback, so an\n // unguarded listener throw is an uncaught exception that takes the\n // harness down rather than a handled render failure.\n this.report?.error(TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n }\n\n private stopWatching(): void {\n this.watchGeneration += 1;\n this.checkQueued = false;\n this.watcher?.close();\n this.watcher = undefined;\n if (this.pollTimer) clearInterval(this.pollTimer);\n this.pollTimer = undefined;\n clearTimeout(this.debounceTimer);\n this.debounceTimer = undefined;\n }\n\n dispose(): void {\n this.listeners.clear();\n this.stopWatching();\n }\n}\n"],"mappings":"yUAOA,MAMM,EAAgB,OAChB,EAAoB,SAEpB,EAAuB,aAkB7B,SAAS,EAAM,EAA2B,CACxC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,CAAE,CAAC,CACzD,CAQA,SAAS,EAAkB,EAA+B,CACxD,GAAI,CAAC,GAAU,OAAO,GAAW,SAAU,OAAO,EAAc,EAChE,IAAM,EAAY,EAClB,GAAI,CAAC,MAAM,QAAQ,EAAU,KAAK,EAAG,OAAO,EAAc,EAE1D,IAAM,EAAQ,EAAU,MAAM,OAC3B,GAAuB,EAAQ,GAAS,OAAO,GAAS,UAAY,OAAQ,EAAc,IAAO,QACpG,EACM,EAAQ,EAAM,QAAQ,EAAK,IAAS,KAAK,IAAI,EAAK,EAAK,EAAE,EAAG,CAAC,EACnE,MAAO,CACL,QAAS,OAAO,EAAU,SAAY,SAAW,EAAU,QAAA,EAC3D,IAAK,OAAO,EAAU,KAAQ,SAAW,EAAU,IAAM,EACzD,OAAQ,OAAO,EAAU,QAAW,UAAY,EAAU,OAAS,EAAQ,EAAU,OAAS,EAAQ,EACtG,OACF,CACF,CAUA,IAAa,EAAb,KAAuB,CACrB,UAEA,IACA,IACA,OAA+B,EAAc,EAC7C,aAAuB,GACvB,QACA,UACA,cACA,cACA,YAAsB,GACtB,gBAA0B,EAC1B,UAA6B,IAAI,IACjC,eACA,cACA,OACA,YAEA,YAAY,EAA4B,CAAC,EAAG,CAC1C,KAAK,IAAM,EAAQ,KAAO,QAAQ,IAAI,EACtC,KAAK,I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c,GACnB,KAAK,SAAS,MAAM,EACpB,KAAK,QAAU,IAAA,GACX,KAAK,WAAW,cAAc,KAAK,SAAS,EAChD,KAAK,UAAY,IAAA,GACjB,aAAa,KAAK,aAAa,EAC/B,KAAK,cAAgB,IAAA,EACvB,CAEA,SAAgB,CACd,KAAK,UAAU,MAAM,EACrB,KAAK,aAAa,CACpB,CACF"}
@@ -0,0 +1,2 @@
1
+ let e=require("@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`,storeCommitListenerFailed:`doom_task.store_commit_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=(0,e.createDoomTelemetry)({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)}}exports.TASK_EVENT=t,exports.createTaskErrorReporter=n,exports.toFailureReporter=r;
2
+ //# sourceMappingURL=logSinkTelemetry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.cjs","names":["createDoomTelemetry"],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/doompi-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport const TASK_EVENT = {\n notificationFailed: 'doom_task.notification_failed',\n storeReadFailed: 'doom_task.store_read_failed',\n storeLockTimeout: 'doom_task.store_lock_timeout',\n storeLockBreakFailed: 'doom_task.store_lock_break_failed',\n storeWatchFailed: 'doom_task.store_watch_failed',\n storeListenerFailed: 'doom_task.store_listener_failed',\n storeCommitListenerFailed: 'doom_task.store_commit_listener_failed',\n storeSweepFailed: 'doom_task.store_sweep_failed',\n sessionStartFailed: 'doom_task.session_start_failed',\n toolFailed: 'doom_task.tool_failed',\n delegationRequestFailed: 'doom_task.delegation_request_failed',\n delegationStartFailed: 'doom_task.delegation_start_failed',\n delegationResponseFailed: 'doom_task.delegation_response_failed',\n delegationSettleFailed: 'doom_task.delegation_settle_failed',\n delegationTimedOut: 'doom_task.delegation_timed_out',\n delegationOrphaned: 'doom_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'doom_task.delegation_assigned',\n delegationCompleted: 'doom_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":"6CA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ry.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 storeCommitListenerFailed: "doom_task.store_commit_listener_failed";
11
+ readonly storeSweepFailed: "doom_task.store_sweep_failed";
12
+ readonly sessionStartFailed: "doom_task.session_start_failed";
13
+ readonly toolFailed: "doom_task.tool_failed";
14
+ readonly delegationRequestFailed: "doom_task.delegation_request_failed";
15
+ readonly delegationStartFailed: "doom_task.delegation_start_failed";
16
+ readonly delegationResponseFailed: "doom_task.delegation_response_failed";
17
+ readonly delegationSettleFailed: "doom_task.delegation_settle_failed";
18
+ readonly delegationTimedOut: "doom_task.delegation_timed_out";
19
+ readonly delegationOrphaned: "doom_task.delegation_orphaned";
20
+ readonly delegationAssigned: "doom_task.delegation_assigned";
21
+ readonly delegationCompleted: "doom_task.delegation_completed";
22
+ };
23
+ type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];
24
+ type TaskErrorAttributes = Record<string, string | number | boolean>;
25
+ type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;
26
+ type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;
27
+ interface TaskFailureReporter {
28
+ error: TaskErrorSink;
29
+ warn: TaskErrorSink;
30
+ /** Info-level event sink. Required so an unwired reporter fails to compile. */
31
+ event: TaskEventSink;
32
+ }
33
+ interface TaskErrorReporterOptions {
34
+ cwd?: string;
35
+ workspaceRoot?: string;
36
+ env?: NodeJS.ProcessEnv;
37
+ telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
38
+ warn?: (message: string) => void;
39
+ }
40
+ interface TaskErrorReporter {
41
+ recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
42
+ recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
43
+ recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;
44
+ recordNotificationError(error: unknown, taskId: number): Promise<void>;
45
+ flush(): Promise<void>;
46
+ shutdown(): Promise<void>;
47
+ }
48
+ declare function createTaskErrorReporter(options?: TaskErrorReporterOptions): TaskErrorReporter;
49
+ declare function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter;
50
+ //#endregion
51
+ export { TASK_EVENT, TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter, createTaskErrorReporter, toFailureReporter };
52
+ //# sourceMappingURL=logSinkTelemetry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.d.cts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;cAMa;;;;;;;;;;;;;;;;;;;;KAuBD,wBAAwB,yBAAyB;KACjD,sBAAsB;KACtB,iBAAiB,OAAO,eAAe,gBAAgB,aAAa;KACpE,iBAAiB,OAAO,eAAe,aAAa;UAE/C;EACf,OAAO;EACP,MAAM;;EAEN,OAAO;;UAGQ;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,eAAe,gBAAgB,aAAa,sBAAsB;EAC9E,cAAc,eAAe,gBAAgB,aAAa,sBAAsB;EAChF,YAAY,eAAe,aAAa,sBAAsB;EAC9D,wBAAwB,gBAAgB,iBAAiB;EACzD,SAAS;EACT,YAAY;;iBAGE,wBAAwB,UAAS,2BAAgC;iBA0BjE,kBAAkB,UAAU,oBAAoB"}
@@ -0,0 +1,52 @@
1
+ import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
2
+ //#region src/adapters/telemetry/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 storeCommitListenerFailed: "doom_task.store_commit_listener_failed";
11
+ readonly storeSweepFailed: "doom_task.store_sweep_failed";
12
+ readonly sessionStartFailed: "doom_task.session_start_failed";
13
+ readonly toolFailed: "doom_task.tool_failed";
14
+ readonly delegationRequestFailed: "doom_task.delegation_request_failed";
15
+ readonly delegationStartFailed: "doom_task.delegation_start_failed";
16
+ readonly delegationResponseFailed: "doom_task.delegation_response_failed";
17
+ readonly delegationSettleFailed: "doom_task.delegation_settle_failed";
18
+ readonly delegationTimedOut: "doom_task.delegation_timed_out";
19
+ readonly delegationOrphaned: "doom_task.delegation_orphaned";
20
+ readonly delegationAssigned: "doom_task.delegation_assigned";
21
+ readonly delegationCompleted: "doom_task.delegation_completed";
22
+ };
23
+ type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];
24
+ type TaskErrorAttributes = Record<string, string | number | boolean>;
25
+ type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;
26
+ type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;
27
+ interface TaskFailureReporter {
28
+ error: TaskErrorSink;
29
+ warn: TaskErrorSink;
30
+ /** Info-level event sink. Required so an unwired reporter fails to compile. */
31
+ event: TaskEventSink;
32
+ }
33
+ interface TaskErrorReporterOptions {
34
+ cwd?: string;
35
+ workspaceRoot?: string;
36
+ env?: NodeJS.ProcessEnv;
37
+ telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
38
+ warn?: (message: string) => void;
39
+ }
40
+ interface TaskErrorReporter {
41
+ recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
42
+ recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
43
+ recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;
44
+ recordNotificationError(error: unknown, taskId: number): Promise<void>;
45
+ flush(): Promise<void>;
46
+ shutdown(): Promise<void>;
47
+ }
48
+ declare function createTaskErrorReporter(options?: TaskErrorReporterOptions): TaskErrorReporter;
49
+ declare function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter;
50
+ //#endregion
51
+ export { TASK_EVENT, TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter, createTaskErrorReporter, toFailureReporter };
52
+ //# sourceMappingURL=logSinkTelemetry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;cAMa;;;;;;;;;;;;;;;;;;;;KAuBD,wBAAwB,yBAAyB;KACjD,sBAAsB;KACtB,iBAAiB,OAAO,eAAe,gBAAgB,aAAa;KACpE,iBAAiB,OAAO,eAAe,aAAa;UAE/C;EACf,OAAO;EACP,MAAM;;EAEN,OAAO;;UAGQ;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,eAAe,gBAAgB,aAAa,sBAAsB;EAC9E,cAAc,eAAe,gBAAgB,aAAa,sBAAsB;EAChF,YAAY,eAAe,aAAa,sBAAsB;EAC9D,wBAAwB,gBAAgB,iBAAiB;EACzD,SAAS;EACT,YAAY;;iBAGE,wBAAwB,UAAS,2BAAgC;iBA0BjE,kBAAkB,UAAU,oBAAoB"}
@@ -0,0 +1,2 @@
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`,storeCommitListenerFailed:`doom_task.store_commit_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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.mjs","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/doompi-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport const TASK_EVENT = {\n notificationFailed: 'doom_task.notification_failed',\n storeReadFailed: 'doom_task.store_read_failed',\n storeLockTimeout: 'doom_task.store_lock_timeout',\n storeLockBreakFailed: 'doom_task.store_lock_break_failed',\n storeWatchFailed: 'doom_task.store_watch_failed',\n storeListenerFailed: 'doom_task.store_listener_failed',\n storeCommitListenerFailed: 'doom_task.store_commit_listener_failed',\n storeSweepFailed: 'doom_task.store_sweep_failed',\n sessionStartFailed: 'doom_task.session_start_failed',\n toolFailed: 'doom_task.tool_failed',\n delegationRequestFailed: 'doom_task.delegation_request_failed',\n delegationStartFailed: 'doom_task.delegation_start_failed',\n delegationResponseFailed: 'doom_task.delegation_response_failed',\n delegationSettleFailed: 'doom_task.delegation_settle_failed',\n delegationTimedOut: 'doom_task.delegation_timed_out',\n delegationOrphaned: 'doom_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'doom_task.delegation_assigned',\n delegationCompleted: 'doom_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":"kEAEA,MAIa,EAAa,CACxB,mBAAoB,gCACpB,gBAAiB,8BACjB,iBAAkB,+BAClB,qBAAsB,oCACtB,iBAAkB,+BAClB,oBAAqB,kCACrB,0BAA2B,yCAC3B,iBAAkB,+BAClB,mBAAoB,iCACpB,WAAY,wBACZ,wBAAyB,sCACzB,sBAAuB,oCACvB,yBAA0B,uCAC1B,uBAAwB,qCACxB,mBAAoB,iCACpB,mBAAoB,gCAGpB,mBAAoB,gCACpB,oBAAqB,gCACvB,EA+BA,SAAgB,EAAwB,EAAoC,CAAC,EAAsB,CACjG,IAAM,EAA2B,EAAoB,CACnD,YAAa,YACb,YAAa,yBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,yBAA0B,EAAO,IAC/B,EAAU,YAAY,EAAW,mBAAoB,EAAO,CAC1D,UAAW,EACX,iBAAkB,yBACpB,CAAC,EACH,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF,CAEA,SAAgB,EAAkB,EAAkD,CAClF,MAAO,CACL,OAAQ,EAAO,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,EAAO,CAAU,EACvF,MAAO,EAAO,EAAO,IAAe,KAAK,EAAS,cAAc,EAAO,EAAO,CAAU,EACxF,OAAQ,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,CAAU,CAC3E,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../schemas/task.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=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["COMMAND_NAME","ERR_REQUIRES_INTERACTIVE","openTaskSpace"],"sources":["../../src/commands/index.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE } from '../schemas/task.ts';\nimport type { TaskStore } from '../services/store/taskStore.ts';\nimport { openTaskSpace } from '../tui/taskSpace.ts';\n\n/**\n * `/tasks`, reachable from the leader palette as `SPC t t`.\n *\n * The command opens the Task Space overlay rather than printing a listing: the\n * overlay is the readable surface and it can edit, while a transcript dump could\n * only be read.\n */\nexport function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void {\n pi.registerCommand(COMMAND_NAME, {\n description: 'Open Task Space for this session tree',\n handler: async (_args, ctx) => {\n if (!ctx.hasUI) {\n ctx.ui.notify(ERR_REQUIRES_INTERACTIVE, 'error');\n return;\n }\n\n store.read();\n await openTaskSpace(ctx, { store });\n },\n });\n}\n"],"mappings":"yEAYA,SAAgB,EAAqB,EAAkB,EAAwB,CAC7E,EAAG,gBAAgBA,EAAAA,aAAc,CAC/B,YAAa,wCACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,GAAI,CAAC,EAAI,MAAO,CACd,EAAI,GAAG,OAAOC,EAAAA,yBAA0B,OAAO,EAC/C,MACF,CAEA,EAAM,KAAK,EACX,MAAMC,EAAAA,cAAc,EAAK,CAAE,OAAM,CAAC,CACpC,CACF,CAAC,CACH"}
@@ -0,0 +1,15 @@
1
+ import { TaskStore } from "../adapters/store/taskStore.cjs";
2
+ import "../services/store/taskStore.cjs";
3
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
+ //#region src/commands/index.d.ts
5
+ /**
6
+ * `/tasks`, reachable from the leader palette as `SPC t t`.
7
+ *
8
+ * The command opens the Task Space overlay rather than printing a listing: the
9
+ * overlay is the readable surface and it can edit, while a transcript dump could
10
+ * only be read.
11
+ */
12
+ declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void;
13
+ //#endregion
14
+ export { registerTasksCommand };
15
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/commands/index.ts"],"mappings":";;;;;;;;;;;iBAYgB,qBAAqB,IAAI,cAAc,OAAO"}
@@ -0,0 +1,15 @@
1
+ import { TaskStore } from "../adapters/store/taskStore.mjs";
2
+ import "../services/store/taskStore.mjs";
3
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
+ //#region src/commands/index.d.ts
5
+ /**
6
+ * `/tasks`, reachable from the leader palette as `SPC t t`.
7
+ *
8
+ * The command opens the Task Space overlay rather than printing a listing: the
9
+ * overlay is the readable surface and it can edit, while a transcript dump could
10
+ * only be read.
11
+ */
12
+ declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void;
13
+ //#endregion
14
+ export { registerTasksCommand };
15
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/commands/index.ts"],"mappings":";;;;;;;;;;;iBAYgB,qBAAqB,IAAI,cAAc,OAAO"}
@@ -0,0 +1,2 @@
1
+ import{COMMAND_NAME as e,ERR_REQUIRES_INTERACTIVE as t}from"../schemas/task.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=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/commands/index.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE } from '../schemas/task.ts';\nimport type { TaskStore } from '../services/store/taskStore.ts';\nimport { openTaskSpace } from '../tui/taskSpace.ts';\n\n/**\n * `/tasks`, reachable from the leader palette as `SPC t t`.\n *\n * The command opens the Task Space overlay rather than printing a listing: the\n * overlay is the readable surface and it can edit, while a transcript dump could\n * only be read.\n */\nexport function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void {\n pi.registerCommand(COMMAND_NAME, {\n description: 'Open Task Space for this session tree',\n handler: async (_args, ctx) => {\n if (!ctx.hasUI) {\n ctx.ui.notify(ERR_REQUIRES_INTERACTIVE, 'error');\n return;\n }\n\n store.read();\n await openTaskSpace(ctx, { store });\n },\n });\n}\n"],"mappings":"sIAYA,SAAgB,EAAqB,EAAkB,EAAwB,CAC7E,EAAG,gBAAgB,EAAc,CAC/B,YAAa,wCACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,GAAI,CAAC,EAAI,MAAO,CACd,EAAI,GAAG,OAAO,EAA0B,OAAO,EAC/C,MACF,CAEA,EAAM,KAAK,EACX,MAAM,EAAc,EAAK,CAAE,OAAM,CAAC,CACpC,CACF,CAAC,CACH"}
@@ -0,0 +1,2 @@
1
+ const e=["Use `task` for work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.",`Capture a whole plan in one call: {"action":"upsert","tasks":[{"subject":"Research existing tool"},{"subject":"Write the reducer"},{"subject":"Add tests"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.`,`Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.`,`Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status "failed" or keep it in_progress and add a new task for the blocker in the same upsert.`,`When every non-deleted task is completed, review the full task list once more and call task {"action":"clear"} to close it. Do not leave an all-completed list open.`,`Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.`,`One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {"action":"upsert","tasks":[{"id":3,"status":"completed"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.`,`Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a "ref" and list the ref string in place of an id: [{"ref":"api","subject":"Design the API"},{"subject":"Implement the API","blockedBy":["api"]}]. A ref must be declared before it is used. Cycles are rejected.`,`upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.`,`Before assigning work, call subagent with {"action":"agents"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.`,`Assign every unblocked pending task, including implementation tasks. Use assignments[] for every assign call, including one task: {"action":"assign","assignments":[{"id":1,"agent":"researcher"}]}. Put all assign-time fields — including model, inlineAgent, instructions, relevantFiles, priorFindings, and context — inside each assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.`,`A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.`,`Hand over what you already know when you assign. Pass relevantFiles with the paths you have actually read or located for that task, and priorFindings with the facts you established: symbol names, call sites, the approach you picked, what you ruled out. A fresh-context child starts with none of your context and will otherwise spend most of its run re-reading the repo. It treats this verified pack as satisfying initial context exploration, reads known paths directly, and widens discovery only for a concrete missing dependency. Send at most a dozen files and only ones you really opened — a guessed path costs the child more than an omitted one — and keep priorFindings to a few lines of facts, not directives.`,`After assigning work, continue non-overlapping parent work or end your turn. Do not poll or duplicate delegated scope.`,`When a delegated task completes and unblocks another task, repeat agent discovery if needed and assign that newly eligible task promptly. Do not poll in a loop. Completion notifications wake the parent session.`,`If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.`,`assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {"action":"cancel","id":3} to stop a running delegation; the task returns to pending.`,`Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly. Read the completion or failure result before deciding what to do next.`,`The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.`,`Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.`];exports.DEFAULT_PROMPT_GUIDELINES=e;
2
+ //# sourceMappingURL=promptGuidelines.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines.cjs","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"sourcesContent":["export const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Use `task` for work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.',\n 'Capture a whole plan in one call: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research existing tool\"},{\"subject\":\"Write the reducer\"},{\"subject\":\"Add tests\"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.',\n 'Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.',\n 'Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status \"failed\" or keep it in_progress and add a new task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the full task list once more and call task {\"action\":\"clear\"} to close it. Do not leave an all-completed list open.',\n \"Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.\",\n 'One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.',\n 'Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a \"ref\" and list the ref string in place of an id: [{\"ref\":\"api\",\"subject\":\"Design the API\"},{\"subject\":\"Implement the API\",\"blockedBy\":[\"api\"]}]. A ref must be declared before it is used. Cycles are rejected.',\n 'upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.',\n 'Before assigning work, call subagent with {\"action\":\"agents\"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.',\n 'Assign every unblocked pending task, including implementation tasks. Use assignments[] for every assign call, including one task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put all assign-time fields — including model, inlineAgent, instructions, relevantFiles, priorFindings, and context — inside each assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.',\n 'A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.',\n 'Hand over what you already know when you assign. Pass relevantFiles with the paths you have actually read or located for that task, and priorFindings with the facts you established: symbol names, call sites, the approach you picked, what you ruled out. A fresh-context child starts with none of your context and will otherwise spend most of its run re-reading the repo. It treats this verified pack as satisfying initial context exploration, reads known paths directly, and widens discovery only for a concrete missing dependency. Send at most a dozen files and only ones you really opened — a guessed path costs the child more than an omitted one — and keep priorFindings to a few lines of facts, not directives.',\n 'After assigning work, continue non-overlapping parent work or end your turn. Do not poll or duplicate delegated scope.',\n 'When a delegated task completes and unblocks another task, repeat agent discovery if needed and assign that newly eligible task promptly. Do not poll in a loop. Completion notifications wake the parent session.',\n 'If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.',\n 'assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {\"action\":\"cancel\",\"id\":3} to stop a running delegation; the task returns to pending.',\n 'Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly. Read the completion or failure result before deciding what to do next.',\n 'The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.',\n \"Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.\",\n];\n"],"mappings":"AAAA,MAAa,EAAsC,CACjD,4NACA,6XACA,ukBACA,mNACA,uKACA,kPACA,qXACA,0fACA,qTACA,sRACA,iuBACA,0MACA,4sBACA,yHACA,qNACA,8LACA,4LACA,+LACA,8KACA,uXACF"}
@@ -0,0 +1,5 @@
1
+ //#region src/commands/task/promptGuidelines.d.ts
2
+ declare const DEFAULT_PROMPT_GUIDELINES: string[];
3
+ //#endregion
4
+ export { DEFAULT_PROMPT_GUIDELINES };
5
+ //# sourceMappingURL=promptGuidelines.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines.d.cts","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"mappings":";cAAa"}
@@ -0,0 +1,5 @@
1
+ //#region src/commands/task/promptGuidelines.d.ts
2
+ declare const DEFAULT_PROMPT_GUIDELINES: string[];
3
+ //#endregion
4
+ export { DEFAULT_PROMPT_GUIDELINES };
5
+ //# sourceMappingURL=promptGuidelines.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines.d.mts","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"mappings":";cAAa"}
@@ -0,0 +1,2 @@
1
+ const e=["Use `task` for work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.",`Capture a whole plan in one call: {"action":"upsert","tasks":[{"subject":"Research existing tool"},{"subject":"Write the reducer"},{"subject":"Add tests"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.`,`Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.`,`Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status "failed" or keep it in_progress and add a new task for the blocker in the same upsert.`,`When every non-deleted task is completed, review the full task list once more and call task {"action":"clear"} to close it. Do not leave an all-completed list open.`,`Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.`,`One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {"action":"upsert","tasks":[{"id":3,"status":"completed"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.`,`Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a "ref" and list the ref string in place of an id: [{"ref":"api","subject":"Design the API"},{"subject":"Implement the API","blockedBy":["api"]}]. A ref must be declared before it is used. Cycles are rejected.`,`upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.`,`Before assigning work, call subagent with {"action":"agents"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.`,`Assign every unblocked pending task, including implementation tasks. Use assignments[] for every assign call, including one task: {"action":"assign","assignments":[{"id":1,"agent":"researcher"}]}. Put all assign-time fields — including model, inlineAgent, instructions, relevantFiles, priorFindings, and context — inside each assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.`,`A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.`,`Hand over what you already know when you assign. Pass relevantFiles with the paths you have actually read or located for that task, and priorFindings with the facts you established: symbol names, call sites, the approach you picked, what you ruled out. A fresh-context child starts with none of your context and will otherwise spend most of its run re-reading the repo. It treats this verified pack as satisfying initial context exploration, reads known paths directly, and widens discovery only for a concrete missing dependency. Send at most a dozen files and only ones you really opened — a guessed path costs the child more than an omitted one — and keep priorFindings to a few lines of facts, not directives.`,`After assigning work, continue non-overlapping parent work or end your turn. Do not poll or duplicate delegated scope.`,`When a delegated task completes and unblocks another task, repeat agent discovery if needed and assign that newly eligible task promptly. Do not poll in a loop. Completion notifications wake the parent session.`,`If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.`,`assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {"action":"cancel","id":3} to stop a running delegation; the task returns to pending.`,`Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly. Read the completion or failure result before deciding what to do next.`,`The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.`,`Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.`];export{e as DEFAULT_PROMPT_GUIDELINES};
2
+ //# sourceMappingURL=promptGuidelines.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptGuidelines.mjs","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"sourcesContent":["export const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Use `task` for work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.',\n 'Capture a whole plan in one call: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research existing tool\"},{\"subject\":\"Write the reducer\"},{\"subject\":\"Add tests\"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.',\n 'Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.',\n 'Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status \"failed\" or keep it in_progress and add a new task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the full task list once more and call task {\"action\":\"clear\"} to close it. Do not leave an all-completed list open.',\n \"Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.\",\n 'One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.',\n 'Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a \"ref\" and list the ref string in place of an id: [{\"ref\":\"api\",\"subject\":\"Design the API\"},{\"subject\":\"Implement the API\",\"blockedBy\":[\"api\"]}]. A ref must be declared before it is used. Cycles are rejected.',\n 'upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.',\n 'Before assigning work, call subagent with {\"action\":\"agents\"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.',\n 'Assign every unblocked pending task, including implementation tasks. Use assignments[] for every assign call, including one task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put all assign-time fields — including model, inlineAgent, instructions, relevantFiles, priorFindings, and context — inside each assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.',\n 'A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.',\n 'Hand over what you already know when you assign. Pass relevantFiles with the paths you have actually read or located for that task, and priorFindings with the facts you established: symbol names, call sites, the approach you picked, what you ruled out. A fresh-context child starts with none of your context and will otherwise spend most of its run re-reading the repo. It treats this verified pack as satisfying initial context exploration, reads known paths directly, and widens discovery only for a concrete missing dependency. Send at most a dozen files and only ones you really opened — a guessed path costs the child more than an omitted one — and keep priorFindings to a few lines of facts, not directives.',\n 'After assigning work, continue non-overlapping parent work or end your turn. Do not poll or duplicate delegated scope.',\n 'When a delegated task completes and unblocks another task, repeat agent discovery if needed and assign that newly eligible task promptly. Do not poll in a loop. Completion notifications wake the parent session.',\n 'If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.',\n 'assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {\"action\":\"cancel\",\"id\":3} to stop a running delegation; the task returns to pending.',\n 'Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly. Read the completion or failure result before deciding what to do next.',\n 'The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.',\n \"Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.\",\n];\n"],"mappings":"AAAA,MAAa,EAAsC,CACjD,4NACA,6XACA,ukBACA,mNACA,uKACA,kPACA,qXACA,0fACA,qTACA,sRACA,iuBACA,0MACA,4sBACA,yHACA,qNACA,8LACA,4LACA,+LACA,8KACA,uXACF"}
@@ -0,0 +1,7 @@
1
+ const e=require("../../services/store/taskGraph.cjs"),t=`All tasks are completed. Review the full task list once more, then close it with task {"action":"clear"}.`,n=`The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.`,r=`No task changed, so the whole call can be resent once corrected.`,i=`Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.`;function a(e){if(e.length===1)return e[0].message;let t=e.filter(e=>e.ok).length,n=e.length-t,r=[`Assigned ${t}/${e.length} tasks${n>0?`; ${n} failed`:``}.`,...e.map(e=>e.ok?`- [${e.index}] Delegated #${e.id} to ${e.agent}`:`- [${e.index}] Failed #${e.id} → ${e.agent}: ${e.message}`)];return n>0&&t>0&&r.push(``,i),n===0&&r.push(``,`All assignments are running independently in the background. Continue non-overlapping work, or end your turn.`),r.join(`
2
+ `)}function o(e){let t=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``,n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation&&e.delegation.state!==`cancelled`?` [${e.delegation.agent}]`:``;return`[${e.status}] #${e.id} ${e.subject}${n}${r}${t}`}function s(e){let t=e.delegation;if(!t)return[];let n=[` delegated to: ${t.agent} (${t.state})`];return t.model&&n.push(` model: ${t.model}`),t.result?.error&&n.push(` error: ${t.result.error}`),t.result?.outputPath&&n.push(` output file: ${t.result.outputPath}`),t.result?.output&&n.push(` output: ${t.result.output}`),n}function c(t,n){let r=e.deriveBlocks(n.tasks).get(t.id)??[],i=[`#${t.id} [${t.status}] ${t.subject}`];return t.description&&i.push(` description: ${t.description}`),t.activeForm&&i.push(` activeForm: ${t.activeForm}`),t.blockedBy?.length&&i.push(` blockedBy: ${t.blockedBy.map(e=>`#${e}`).join(`, `)}`),r.length&&i.push(` blocks: ${r.map(e=>`#${e}`).join(`, `)}`),t.owner&&i.push(` owner: ${t.owner}`),i.push(...s(t)),i.join(`
3
+ `)}function l(e){switch(e.kind){case`created`:{let t=e.ref?` (ref "${e.ref}")`:``,n=e.blockedBy?.length?` — blocked by ${e.blockedBy.map(e=>`#${e}`).join(`, `)}`:``;return`Created #${e.id}${t}: ${e.subject} (${e.status})${n}`}case`updated`:{let t=e.fromStatus===e.toStatus?``:` (${e.fromStatus} -> ${e.toStatus})`;return`Updated #${e.id}${t}`}case`unchanged`:return`No change: #${e.id} already matches the requested values (status: ${e.status})`;case`failed`:return`Failed${e.id===void 0?``:` #${e.id}`}: ${e.message}`}}function u(e){return e.items.length===1?e.items[0].kind===`failed`?e.items[0].message:`no entry was applied`:[`no entry was applied.`,...e.items.map(e=>`- [${e.index}] ${l(e)}`),r].join(`
4
+ `)}function d(r,i){switch(r.kind){case`upsert`:{let a=r.items.length===1?[l(r.items[0])]:[`Upsert applied ${r.applied}/${r.items.length} entries${r.failed>0?`; ${r.failed} failed`:``}.`,...r.items.map(e=>`- [${e.index}] ${l(e)}`),...r.failed>0?[``,n]:[]];return r.applied>0&&e.isTaskListComplete(i.tasks)&&a.push(t),a.join(`
5
+ `)}case`delete`:return`Deleted #${r.id}: ${r.subject}`;case`clear`:return`Closed task list (cleared ${r.count} tasks)`;case`list`:{let e=i.tasks;return r.includeDeleted||(e=e.filter(e=>e.status!==`deleted`)),r.statusFilter&&(e=e.filter(e=>e.status===r.statusFilter)),e.length===0?`No tasks`:e.map(o).join(`
6
+ `)}case`get`:return c(r.task,i);case`error`:return`Error: ${r.message}`}}function f(e,t,n,r){return{content:[{type:`text`,text:d(r,n)}],details:{action:e,params:t,tasks:n.tasks,nextId:n.nextId,rev:n.rev,...r.kind===`error`?{error:r.message}:{},...r.kind===`upsert`?{upsert:{applied:r.items.flatMap(e=>e.kind===`failed`?[]:[e.id]),failed:r.failed}}:{}}}}function p(e,t,n,r){return{content:[{type:`text`,text:n}],details:{action:`assign`,params:e,tasks:t.tasks,nextId:t.nextId,rev:t.rev,assignment:r}}}function m(e,t,n,r,i){return{content:[{type:`text`,text:i?`Error: ${i}`:r}],details:{action:e,params:t,tasks:n.tasks,nextId:n.nextId,rev:n.rev,...i?{error:i}:{}}}}exports.MSG_ALL_COMPLETE_CLEAR=t,exports.MSG_ASSIGN_PARTIAL=i,exports.MSG_UPSERT_NONE_APPLIED=r,exports.MSG_UPSERT_PARTIAL=n,exports.buildAssignmentResult=p,exports.buildTextResult=m,exports.buildToolResult=f,exports.formatAssignmentResults=a,exports.formatContent=d,exports.formatUpsertFailureText=u;
7
+ //# sourceMappingURL=responseEnvelope.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseEnvelope.cjs","names":["deriveBlocks","isTaskListComplete"],"sources":["../../../src/commands/task/responseEnvelope.ts"],"sourcesContent":["import type { Op } from '../../services/store/reducer.ts';\nimport { deriveBlocks, isTaskListComplete } from '../../services/store/taskGraph.ts';\nimport type {\n AssignmentSummary,\n Task,\n TaskAction,\n TaskDetails,\n TaskDocument,\n TaskMutationParams,\n UpsertItemOutcome,\n} from '../../services/store/types.ts';\n\nexport const MSG_ALL_COMPLETE_CLEAR =\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.';\n\n/**\n * Steering for a mixed batch. Unlike a batch of spawned subagents, a failed\n * entry here had no side effect at all, so retrying the failures is the safe\n * move and the model must be told so or it will do nothing. The hazard is the\n * other half: resending an applied create would make a second task.\n */\nexport const MSG_UPSERT_PARTIAL =\n 'The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.';\n\nexport const MSG_UPSERT_NONE_APPLIED = 'No task changed, so the whole call can be resent once corrected.';\n\nexport const MSG_ASSIGN_PARTIAL =\n 'Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.';\n\nexport interface AssignmentItemResult {\n index: number;\n id: number;\n agent: string;\n ok: boolean;\n message: string;\n}\n\n/** LLM-facing report for a native assignment batch. */\nexport function formatAssignmentResults(items: readonly AssignmentItemResult[]): string {\n if (items.length === 1) return items[0].message;\n\n const succeeded = items.filter((item) => item.ok).length;\n const failed = items.length - succeeded;\n const lines = [\n `Assigned ${succeeded}/${items.length} tasks${failed > 0 ? `; ${failed} failed` : ''}.`,\n ...items.map((item) =>\n item.ok\n ? `- [${item.index}] Delegated #${item.id} to ${item.agent}`\n : `- [${item.index}] Failed #${item.id} → ${item.agent}: ${item.message}`,\n ),\n ];\n\n if (failed > 0 && succeeded > 0) lines.push('', MSG_ASSIGN_PARTIAL);\n if (failed === 0) {\n lines.push(\n '',\n 'All assignments are running independently in the background. Continue non-overlapping work, or end your turn.',\n );\n }\n return lines.join('\\n');\n}\n\n/** `[status] #id subject (activeForm) [agent] ⛓ #dep` — the `list` line format. */\nfunction formatListLine(task: Task): string {\n const block = task.blockedBy?.length ? ` ⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}` : '';\n const form = task.status === 'in_progress' && task.activeForm ? ` (${task.activeForm})` : '';\n const delegated = task.delegation && task.delegation.state !== 'cancelled' ? ` [${task.delegation.agent}]` : '';\n return `[${task.status}] #${task.id} ${task.subject}${form}${delegated}${block}`;\n}\n\nfunction formatDelegationLines(task: Task): string[] {\n const delegation = task.delegation;\n if (!delegation) return [];\n\n const lines = [` delegated to: ${delegation.agent} (${delegation.state})`];\n if (delegation.model) lines.push(` model: ${delegation.model}`);\n if (delegation.result?.error) lines.push(` error: ${delegation.result.error}`);\n if (delegation.result?.outputPath) lines.push(` output file: ${delegation.result.outputPath}`);\n if (delegation.result?.output) lines.push(` output: ${delegation.result.output}`);\n return lines;\n}\n\nfunction formatGetLines(task: Task, document: TaskDocument): string {\n const blocks = deriveBlocks(document.tasks).get(task.id) ?? [];\n const lines = [`#${task.id} [${task.status}] ${task.subject}`];\n if (task.description) lines.push(` description: ${task.description}`);\n if (task.activeForm) lines.push(` activeForm: ${task.activeForm}`);\n if (task.blockedBy?.length) lines.push(` blockedBy: ${task.blockedBy.map((id) => `#${id}`).join(', ')}`);\n if (blocks.length) lines.push(` blocks: ${blocks.map((id) => `#${id}`).join(', ')}`);\n if (task.owner) lines.push(` owner: ${task.owner}`);\n lines.push(...formatDelegationLines(task));\n return lines.join('\\n');\n}\n\n/** One entry's outcome. Batch lines prefix this with `- [n] `. */\nfunction formatUpsertItem(item: UpsertItemOutcome): string {\n switch (item.kind) {\n case 'created': {\n const ref = item.ref ? ` (ref \"${item.ref}\")` : '';\n const deps = item.blockedBy?.length ? ` — blocked by ${item.blockedBy.map((id) => `#${id}`).join(', ')}` : '';\n return `Created #${item.id}${ref}: ${item.subject} (${item.status})${deps}`;\n }\n case 'updated': {\n const transition = item.fromStatus === item.toStatus ? '' : ` (${item.fromStatus} -> ${item.toStatus})`;\n return `Updated #${item.id}${transition}`;\n }\n case 'unchanged':\n return `No change: #${item.id} already matches the requested values (status: ${item.status})`;\n case 'failed':\n return `Failed${item.id === undefined ? '' : ` #${item.id}`}: ${item.message}`;\n }\n}\n\n/**\n * The thrown message when an upsert applied nothing. Kept separate from\n * `formatContent` because the caller wraps it in the actionable Options block\n * rather than returning it as a successful result.\n */\nexport function formatUpsertFailureText(op: Extract<Op, { kind: 'upsert' }>): string {\n if (op.items.length === 1) return op.items[0].kind === 'failed' ? op.items[0].message : 'no entry was applied';\n return [\n 'no entry was applied.',\n ...op.items.map((item) => `- [${item.index}] ${formatUpsertItem(item)}`),\n MSG_UPSERT_NONE_APPLIED,\n ].join('\\n');\n}\n\n/**\n * Pure formatter: `(op, document) -> string`. The switch is closed over `Op`,\n * so a new reducer variant fails to compile until it is handled here.\n */\nexport function formatContent(op: Op, document: TaskDocument): string {\n switch (op.kind) {\n case 'upsert': {\n // A batch of one is the common case and must not read like a bulk\n // report, so it keeps the exact single-line shape it has always had.\n const lines =\n op.items.length === 1\n ? [formatUpsertItem(op.items[0])]\n : [\n `Upsert applied ${op.applied}/${op.items.length} entries${op.failed > 0 ? `; ${op.failed} failed` : ''}.`,\n ...op.items.map((item) => `- [${item.index}] ${formatUpsertItem(item)}`),\n ...(op.failed > 0 ? ['', MSG_UPSERT_PARTIAL] : []),\n ];\n // Once, last, and only when something landed: emitting it per entry\n // would repeat it for every completion in a batch.\n if (op.applied > 0 && isTaskListComplete(document.tasks)) lines.push(MSG_ALL_COMPLETE_CLEAR);\n return lines.join('\\n');\n }\n case 'delete':\n return `Deleted #${op.id}: ${op.subject}`;\n case 'clear':\n return `Closed task list (cleared ${op.count} tasks)`;\n case 'list': {\n let view = document.tasks;\n if (!op.includeDeleted) view = view.filter((task) => task.status !== 'deleted');\n if (op.statusFilter) view = view.filter((task) => task.status === op.statusFilter);\n return view.length === 0 ? 'No tasks' : view.map(formatListLine).join('\\n');\n }\n case 'get':\n return formatGetLines(op.task, document);\n case 'error':\n return `Error: ${op.message}`;\n }\n}\n\nexport interface ToolResult {\n content: Array<{ type: 'text'; text: string }>;\n details: TaskDetails;\n}\n\n/** Build the LLM-facing envelope. `details` carries the post-mutation snapshot. */\nexport function buildToolResult(\n action: TaskAction,\n params: TaskMutationParams,\n document: TaskDocument,\n op: Op,\n): ToolResult {\n return {\n content: [{ type: 'text', text: formatContent(op, document) }],\n details: {\n action,\n params: params as Record<string, unknown>,\n tasks: document.tasks,\n nextId: document.nextId,\n rev: document.rev,\n ...(op.kind === 'error' ? { error: op.message } : {}),\n // Deliberately no `error` on a partial success: renderResult treats\n // `details.error` as total failure and would hide the rows for the\n // entries that did land.\n ...(op.kind === 'upsert'\n ? {\n upsert: {\n applied: op.items.flatMap((item) => (item.kind === 'failed' ? [] : [item.id])),\n failed: op.failed,\n },\n }\n : {}),\n },\n };\n}\n\n/** Envelope for a native assignment batch, including ids used by the consolidated TUI result. */\nexport function buildAssignmentResult(\n params: TaskMutationParams,\n document: TaskDocument,\n text: string,\n assignment: AssignmentSummary,\n): ToolResult {\n return {\n content: [{ type: 'text', text }],\n details: {\n action: 'assign',\n params: params as Record<string, unknown>,\n tasks: document.tasks,\n nextId: document.nextId,\n rev: document.rev,\n assignment,\n },\n };\n}\n\n/** Envelope for delegation actions, which do not flow through the reducer. */\nexport function buildTextResult(\n action: TaskAction,\n params: TaskMutationParams,\n document: TaskDocument,\n text: string,\n error?: string,\n): ToolResult {\n return {\n content: [{ type: 'text', text: error ? `Error: ${error}` : text }],\n details: {\n action,\n params: params as Record<string, unknown>,\n tasks: document.tasks,\n nextId: document.nextId,\n rev: document.rev,\n ...(error ? { error } : {}),\n },\n };\n}\n"],"mappings":"sDAYa,EACX,4GAQW,EACX,0OAEW,EAA0B,mEAE1B,EACX,8JAWF,SAAgB,EAAwB,EAAgD,CACtF,GAAI,EAAM,SAAW,EAAG,OAAO,EAAM,EAAE,CAAC,QAExC,IAAM,EAAY,EAAM,OAAQ,GAAS,EAAK,EAAE,C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ACF,CAQA,SAAgB,EACd,EACA,EACA,EACA,EACY,CACZ,MAAO,CACL,QAAS,CAAC,CAAE,KAAM,OAAQ,KAAM,EAAc,EAAI,CAAQ,CAAE,CAAC,EAC7D,QAAS,CACP,SACQ,SACR,MAAO,EAAS,MAChB,OAAQ,EAAS,OACjB,IAAK,EAAS,IACd,GAAI,EAAG,OAAS,QAAU,CAAE,MAAO,EAAG,OAAQ,EAAI,CAAC,EAInD,GAAI,EAAG,OAAS,SACZ,CACE,OAAQ,CACN,QAAS,EAAG,MAAM,QAAS,GAAU,EAAK,OAAS,SAAW,CAAC,EAAI,CAAC,EAAK,EAAE,CAAE,EAC7E,OAAQ,EAAG,MACb,CACF,EACA,CAAC,CACP,CACF,CACF,CAGA,SAAgB,EACd,EACA,EACA,EACA,EACY,CACZ,MAAO,CACL,QAAS,CAAC,CAAE,KAAM,OAAQ,MAAK,CAAC,EAChC,QAAS,CACP,OAAQ,SACA,SACR,MAAO,EAAS,MAChB,OAAQ,EAAS,OACjB,IAAK,EAAS,IACd,YACF,CACF,CACF,CAGA,SAAgB,EACd,EACA,EACA,EACA,EACA,EACY,CACZ,MAAO,CACL,QAAS,CAAC,CAAE,KAAM,OAAQ,KAAM,EAAQ,UAAU,IAAU,CAAK,CAAC,EAClE,QAAS,CACP,SACQ,SACR,MAAO,EAAS,MAChB,OAAQ,EAAS,OACjB,IAAK,EAAS,IACd,GAAI,EAAQ,CAAE,OAAM,EAAI,CAAC,CAC3B,CACF,CACF"}
@@ -0,0 +1,51 @@
1
+ import { AssignmentSummary, TaskAction, TaskDetails, TaskDocument, TaskMutationParams } from "../../services/store/types.cjs";
2
+ import { Op } from "../../services/store/reducer.cjs";
3
+ //#region src/commands/task/responseEnvelope.d.ts
4
+ declare const MSG_ALL_COMPLETE_CLEAR = "All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.";
5
+ /**
6
+ * Steering for a mixed batch. Unlike a batch of spawned subagents, a failed
7
+ * entry here had no side effect at all, so retrying the failures is the safe
8
+ * move and the model must be told so or it will do nothing. The hazard is the
9
+ * other half: resending an applied create would make a second task.
10
+ */
11
+ declare const MSG_UPSERT_PARTIAL = "The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.";
12
+ declare const MSG_UPSERT_NONE_APPLIED = "No task changed, so the whole call can be resent once corrected.";
13
+ declare const MSG_ASSIGN_PARTIAL = "Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.";
14
+ interface AssignmentItemResult {
15
+ index: number;
16
+ id: number;
17
+ agent: string;
18
+ ok: boolean;
19
+ message: string;
20
+ }
21
+ /** LLM-facing report for a native assignment batch. */
22
+ declare function formatAssignmentResults(items: readonly AssignmentItemResult[]): string;
23
+ /**
24
+ * The thrown message when an upsert applied nothing. Kept separate from
25
+ * `formatContent` because the caller wraps it in the actionable Options block
26
+ * rather than returning it as a successful result.
27
+ */
28
+ declare function formatUpsertFailureText(op: Extract<Op, {
29
+ kind: 'upsert';
30
+ }>): string;
31
+ /**
32
+ * Pure formatter: `(op, document) -> string`. The switch is closed over `Op`,
33
+ * so a new reducer variant fails to compile until it is handled here.
34
+ */
35
+ declare function formatContent(op: Op, document: TaskDocument): string;
36
+ interface ToolResult {
37
+ content: Array<{
38
+ type: 'text';
39
+ text: string;
40
+ }>;
41
+ details: TaskDetails;
42
+ }
43
+ /** Build the LLM-facing envelope. `details` carries the post-mutation snapshot. */
44
+ declare function buildToolResult(action: TaskAction, params: TaskMutationParams, document: TaskDocument, op: Op): ToolResult;
45
+ /** Envelope for a native assignment batch, including ids used by the consolidated TUI result. */
46
+ declare function buildAssignmentResult(params: TaskMutationParams, document: TaskDocument, text: string, assignment: AssignmentSummary): ToolResult;
47
+ /** Envelope for delegation actions, which do not flow through the reducer. */
48
+ declare function buildTextResult(action: TaskAction, params: TaskMutationParams, document: TaskDocument, text: string, error?: string): ToolResult;
49
+ //#endregion
50
+ export { AssignmentItemResult, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText };
51
+ //# sourceMappingURL=responseEnvelope.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseEnvelope.d.cts","names":[],"sources":["../../../src/commands/task/responseEnvelope.ts"],"mappings":";;;cAYa;;;;;;;cASA;cAGA;cAEA;UAGI;EACf;EACA;EACA;EACA;EACA;;;iBAIc,wBAAwB,gBAAgB;;;;;;iBAgFxC,wBAAwB,IAAI,QAAQ;EAAM;;;;;;iBAa1C,cAAc,IAAI,IAAI,UAAU;UAmC/B;EACf,SAAS;IAAQ;IAAc;;EAC/B,SAAS;;;iBAIK,gBACd,QAAQ,YACR,QAAQ,oBACR,UAAU,cACV,IAAI,KACH;;iBA0Ba,sBACd,QAAQ,oBACR,UAAU,cACV,cACA,YAAY,oBACX;;iBAea,gBACd,QAAQ,YACR,QAAQ,oBACR,UAAU,cACV,cACA,iBACC"}
@@ -0,0 +1,51 @@
1
+ import { AssignmentSummary, TaskAction, TaskDetails, TaskDocument, TaskMutationParams } from "../../services/store/types.mjs";
2
+ import { Op } from "../../services/store/reducer.mjs";
3
+ //#region src/commands/task/responseEnvelope.d.ts
4
+ declare const MSG_ALL_COMPLETE_CLEAR = "All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.";
5
+ /**
6
+ * Steering for a mixed batch. Unlike a batch of spawned subagents, a failed
7
+ * entry here had no side effect at all, so retrying the failures is the safe
8
+ * move and the model must be told so or it will do nothing. The hazard is the
9
+ * other half: resending an applied create would make a second task.
10
+ */
11
+ declare const MSG_UPSERT_PARTIAL = "The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.";
12
+ declare const MSG_UPSERT_NONE_APPLIED = "No task changed, so the whole call can be resent once corrected.";
13
+ declare const MSG_ASSIGN_PARTIAL = "Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.";
14
+ interface AssignmentItemResult {
15
+ index: number;
16
+ id: number;
17
+ agent: string;
18
+ ok: boolean;
19
+ message: string;
20
+ }
21
+ /** LLM-facing report for a native assignment batch. */
22
+ declare function formatAssignmentResults(items: readonly AssignmentItemResult[]): string;
23
+ /**
24
+ * The thrown message when an upsert applied nothing. Kept separate from
25
+ * `formatContent` because the caller wraps it in the actionable Options block
26
+ * rather than returning it as a successful result.
27
+ */
28
+ declare function formatUpsertFailureText(op: Extract<Op, {
29
+ kind: 'upsert';
30
+ }>): string;
31
+ /**
32
+ * Pure formatter: `(op, document) -> string`. The switch is closed over `Op`,
33
+ * so a new reducer variant fails to compile until it is handled here.
34
+ */
35
+ declare function formatContent(op: Op, document: TaskDocument): string;
36
+ interface ToolResult {
37
+ content: Array<{
38
+ type: 'text';
39
+ text: string;
40
+ }>;
41
+ details: TaskDetails;
42
+ }
43
+ /** Build the LLM-facing envelope. `details` carries the post-mutation snapshot. */
44
+ declare function buildToolResult(action: TaskAction, params: TaskMutationParams, document: TaskDocument, op: Op): ToolResult;
45
+ /** Envelope for a native assignment batch, including ids used by the consolidated TUI result. */
46
+ declare function buildAssignmentResult(params: TaskMutationParams, document: TaskDocument, text: string, assignment: AssignmentSummary): ToolResult;
47
+ /** Envelope for delegation actions, which do not flow through the reducer. */
48
+ declare function buildTextResult(action: TaskAction, params: TaskMutationParams, document: TaskDocument, text: string, error?: string): ToolResult;
49
+ //#endregion
50
+ export { AssignmentItemResult, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, ToolResult, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText };
51
+ //# sourceMappingURL=responseEnvelope.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseEnvelope.d.mts","names":[],"sources":["../../../src/commands/task/responseEnvelope.ts"],"mappings":";;;cAYa;;;;;;;cASA;cAGA;cAEA;UAGI;EACf;EACA;EACA;EACA;EACA;;;iBAIc,wBAAwB,gBAAgB;;;;;;iBAgFxC,wBAAwB,IAAI,QAAQ;EAAM;;;;;;iBAa1C,cAAc,IAAI,IAAI,UAAU;UAmC/B;EACf,SAAS;IAAQ;IAAc;;EAC/B,SAAS;;;iBAIK,gBACd,QAAQ,YACR,QAAQ,oBACR,UAAU,cACV,IAAI,KACH;;iBA0Ba,sBACd,QAAQ,oBACR,UAAU,cACV,cACA,YAAY,oBACX;;iBAea,gBACd,QAAQ,YACR,QAAQ,oBACR,UAAU,cACV,cACA,iBACC"}
@@ -0,0 +1,7 @@
1
+ import{deriveBlocks as e,isTaskListComplete as t}from"../../services/store/taskGraph.mjs";const n=`All tasks are completed. Review the full task list once more, then close it with task {"action":"clear"}.`,r=`The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.`,i=`No task changed, so the whole call can be resent once corrected.`,a=`Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.`;function o(e){if(e.length===1)return e[0].message;let t=e.filter(e=>e.ok).length,n=e.length-t,r=[`Assigned ${t}/${e.length} tasks${n>0?`; ${n} failed`:``}.`,...e.map(e=>e.ok?`- [${e.index}] Delegated #${e.id} to ${e.agent}`:`- [${e.index}] Failed #${e.id} → ${e.agent}: ${e.message}`)];return n>0&&t>0&&r.push(``,a),n===0&&r.push(``,`All assignments are running independently in the background. Continue non-overlapping work, or end your turn.`),r.join(`
2
+ `)}function s(e){let t=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``,n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation&&e.delegation.state!==`cancelled`?` [${e.delegation.agent}]`:``;return`[${e.status}] #${e.id} ${e.subject}${n}${r}${t}`}function c(e){let t=e.delegation;if(!t)return[];let n=[` delegated to: ${t.agent} (${t.state})`];return t.model&&n.push(` model: ${t.model}`),t.result?.error&&n.push(` error: ${t.result.error}`),t.result?.outputPath&&n.push(` output file: ${t.result.outputPath}`),t.result?.output&&n.push(` output: ${t.result.output}`),n}function l(t,n){let r=e(n.tasks).get(t.id)??[],i=[`#${t.id} [${t.status}] ${t.subject}`];return t.description&&i.push(` description: ${t.description}`),t.activeForm&&i.push(` activeForm: ${t.activeForm}`),t.blockedBy?.length&&i.push(` blockedBy: ${t.blockedBy.map(e=>`#${e}`).join(`, `)}`),r.length&&i.push(` blocks: ${r.map(e=>`#${e}`).join(`, `)}`),t.owner&&i.push(` owner: ${t.owner}`),i.push(...c(t)),i.join(`
3
+ `)}function u(e){switch(e.kind){case`created`:{let t=e.ref?` (ref "${e.ref}")`:``,n=e.blockedBy?.length?` — blocked by ${e.blockedBy.map(e=>`#${e}`).join(`, `)}`:``;return`Created #${e.id}${t}: ${e.subject} (${e.status})${n}`}case`updated`:{let t=e.fromStatus===e.toStatus?``:` (${e.fromStatus} -> ${e.toStatus})`;return`Updated #${e.id}${t}`}case`unchanged`:return`No change: #${e.id} already matches the requested values (status: ${e.status})`;case`failed`:return`Failed${e.id===void 0?``:` #${e.id}`}: ${e.message}`}}function d(e){return e.items.length===1?e.items[0].kind===`failed`?e.items[0].message:`no entry was applied`:[`no entry was applied.`,...e.items.map(e=>`- [${e.index}] ${u(e)}`),i].join(`
4
+ `)}function f(e,i){switch(e.kind){case`upsert`:{let a=e.items.length===1?[u(e.items[0])]:[`Upsert applied ${e.applied}/${e.items.length} entries${e.failed>0?`; ${e.failed} failed`:``}.`,...e.items.map(e=>`- [${e.index}] ${u(e)}`),...e.failed>0?[``,r]:[]];return e.applied>0&&t(i.tasks)&&a.push(n),a.join(`
5
+ `)}case`delete`:return`Deleted #${e.id}: ${e.subject}`;case`clear`:return`Closed task list (cleared ${e.count} tasks)`;case`list`:{let t=i.tasks;return e.includeDeleted||(t=t.filter(e=>e.status!==`deleted`)),e.statusFilter&&(t=t.filter(t=>t.status===e.statusFilter)),t.length===0?`No tasks`:t.map(s).join(`
6
+ `)}case`get`:return l(e.task,i);case`error`:return`Error: ${e.message}`}}function p(e,t,n,r){return{content:[{type:`text`,text:f(r,n)}],details:{action:e,params:t,tasks:n.tasks,nextId:n.nextId,rev:n.rev,...r.kind===`error`?{error:r.message}:{},...r.kind===`upsert`?{upsert:{applied:r.items.flatMap(e=>e.kind===`failed`?[]:[e.id]),failed:r.failed}}:{}}}}function m(e,t,n,r){return{content:[{type:`text`,text:n}],details:{action:`assign`,params:e,tasks:t.tasks,nextId:t.nextId,rev:t.rev,assignment:r}}}function h(e,t,n,r,i){return{content:[{type:`text`,text:i?`Error: ${i}`:r}],details:{action:e,params:t,tasks:n.tasks,nextId:n.nextId,rev:n.rev,...i?{error:i}:{}}}}export{n as MSG_ALL_COMPLETE_CLEAR,a as MSG_ASSIGN_PARTIAL,i as MSG_UPSERT_NONE_APPLIED,r as MSG_UPSERT_PARTIAL,m as buildAssignmentResult,h as buildTextResult,p as buildToolResult,o as formatAssignmentResults,f as formatContent,d as formatUpsertFailureText};
7
+ //# sourceMappingURL=responseEnvelope.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseEnvelope.mjs","names":[],"sources":["../../../src/commands/task/responseEnvelope.ts"],"sourcesContent":["import type { Op } from '../../services/store/reducer.ts';\nimport { deriveBlocks, isTaskListComplete } from '../../services/store/taskGraph.ts';\nimport type {\n AssignmentSummary,\n Task,\n TaskAction,\n TaskDetails,\n TaskDocument,\n TaskMutationParams,\n UpsertItemOutcome,\n} from '../../services/store/types.ts';\n\nexport const MSG_ALL_COMPLETE_CLEAR =\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.';\n\n/**\n * Steering for a mixed batch. Unlike a batch of spawned subagents, a failed\n * entry here had no side effect at all, so retrying the failures is the safe\n * move and the model must be told so or it will do nothing. The hazard is the\n * other half: resending an applied create would make a second task.\n */\nexport const MSG_UPSERT_PARTIAL =\n 'The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.';\n\nexport const MSG_UPSERT_NONE_APPLIED = 'No task changed, so the whole call can be resent once corrected.';\n\nexport const MSG_ASSIGN_PARTIAL =\n 'Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.';\n\nexport interface AssignmentItemResult {\n index: number;\n id: number;\n agent: string;\n ok: boolean;\n message: string;\n}\n\n/** LLM-facing report for a native assignment batch. */\nexport function formatAssignmentResults(items: readonly AssignmentItemResult[]): string {\n if (items.length === 1) return items[0].message;\n\n const succeeded = items.filter((item) => item.ok).length;\n const failed = items.length - succeeded;\n const lines = [\n `Assigned ${succeeded}/${items.length} tasks${failed > 0 ? `; ${failed} failed` : ''}.`,\n ...items.map((item) =>\n item.ok\n ? `- [${item.index}] Delegated #${item.id} to ${item.agent}`\n : `- [${item.index}] Failed #${item.id} → ${item.agent}: ${item.message}`,\n ),\n ];\n\n if (failed > 0 && succeeded > 0) lines.push('', MSG_ASSIGN_PARTIAL);\n if (failed === 0) {\n lines.push(\n '',\n 'All assignments are running independently in the background. Continue non-overlapping work, or end your turn.',\n );\n }\n return lines.join('\\n');\n}\n\n/** `[status] #id subject (activeForm) [agent] ⛓ #dep` — the `list` line format. */\nfunction formatListLine(task: Task): string {\n const block = task.blockedBy?.length ? ` ⛓ ${task.blockedBy.map((id) => `#${id}`).join(',')}` : '';\n const form = task.status === 'in_progress' && task.activeForm ? ` (${task.activeForm})` : '';\n const delegated = task.delegation && task.delegation.state !== 'cancelled' ? ` [${task.delegation.agent}]` : '';\n return `[${task.status}] #${task.id} ${task.subject}${form}${delegated}${block}`;\n}\n\nfunction formatDelegationLines(task: Task): string[] {\n const delegation = task.delegation;\n if (!delegation) return [];\n\n const lines = [` delegated to: ${delegation.agent} (${delegation.state})`];\n if (delegation.model) lines.push(` model: ${delegation.model}`);\n if (delegation.result?.error) lines.push(` error: ${delegation.result.error}`);\n if (delegation.result?.outputPath) lines.push(` output file: ${delegation.result.outputPath}`);\n if (delegation.result?.output) lines.push(` output: ${delegation.result.output}`);\n return lines;\n}\n\nfunction formatGetLines(task: Task, document: TaskDocument): string {\n const blocks = deriveBlocks(document.tasks).get(task.id) ?? [];\n const lines = [`#${task.id} [${task.status}] ${task.subject}`];\n if (task.description) lines.push(` description: ${task.description}`);\n if (task.activeForm) lines.push(` activeForm: ${task.activeForm}`);\n if (task.blockedBy?.length) lines.push(` blockedBy: ${task.blockedBy.map((id) => `#${id}`).join(', ')}`);\n if (blocks.length) lines.push(` blocks: ${blocks.map((id) => `#${id}`).join(', ')}`);\n if (task.owner) lines.push(` owner: ${task.owner}`);\n lines.push(...formatDelegationLines(task));\n return lines.join('\\n');\n}\n\n/** One entry's outcome. Batch lines prefix this with `- [n] `. */\nfunction formatUpsertItem(item: UpsertItemOutcome): string {\n switch (item.kind) {\n case 'created': {\n const ref = item.ref ? ` (ref \"${item.ref}\")` : '';\n const deps = item.blockedBy?.length ? ` — blocked by ${item.blockedBy.map((id) => `#${id}`).join(', ')}` : '';\n return `Created #${item.id}${ref}: ${item.subject} (${item.status})${deps}`;\n }\n case 'updated': {\n const transition = item.fromStatus === item.toStatus ? '' : ` (${item.fromStatus} -> ${item.toStatus})`;\n return `Updated #${item.id}${transition}`;\n }\n case 'unchanged':\n return `No change: #${item.id} already matches the requested values (status: ${item.status})`;\n case 'failed':\n return `Failed${item.id === undefined ? '' : ` #${item.id}`}: ${item.message}`;\n }\n}\n\n/**\n * The thrown message when an upsert applied nothing. Kept separate from\n * `formatContent` because the caller wraps it in the actionable Options block\n * rather than returning it as a successful result.\n */\nexport function formatUpsertFailureText(op: Extract<Op, { kind: 'upsert' }>): string {\n if (op.items.length === 1) return op.items[0].kind === 'failed' ? op.items[0].message : 'no entry was applied';\n return [\n 'no entry was applied.',\n ...op.items.map((item) => `- [${item.index}] ${formatUpsertItem(item)}`),\n MSG_UPSERT_NONE_APPLIED,\n ].join('\\n');\n}\n\n/**\n * Pure formatter: `(op, document) -> string`. The switch is closed over `Op`,\n * so a new reducer variant fails to compile until it is handled here.\n */\nexport function formatContent(op: Op, document: TaskDocument): string {\n switch (op.kind) {\n case 'upsert': {\n // A batch of one is the common case and must not read like a bulk\n // report, so it keeps the exact single-line shape it has always had.\n const lines =\n op.items.length === 1\n ? [formatUpsertItem(op.items[0])]\n : [\n `Upsert applied ${op.applied}/${op.items.length} entries${op.failed > 0 ? `; ${op.failed} failed` : ''}.`,\n ...op.items.map((item) => `- [${item.index}] ${formatUpsertItem(item)}`),\n ...(op.failed > 0 ? ['', MSG_UPSERT_PARTIAL] : []),\n ];\n // Once, last, and only when something landed: emitting it per entry\n // would repeat it for every completion in a batch.\n if (op.applied > 0 && isTaskListComplete(document.tasks)) lines.push(MSG_ALL_COMPLETE_CLEAR);\n return lines.join('\\n');\n }\n case 'delete':\n return `Deleted #${op.id}: ${op.subject}`;\n case 'clear':\n return `Closed task list (cleared ${op.count} tasks)`;\n case 'list': {\n let view = document.tasks;\n if (!op.includeDeleted) view = view.filter((task) => task.status !== 'deleted');\n if (op.statusFilter) view = view.filter((task) => task.status === op.statusFilter);\n return view.length === 0 ? 'No tasks' : view.map(formatListLine).join('\\n');\n }\n case 'get':\n return formatGetLines(op.task, document);\n case 'error':\n return `Error: ${op.message}`;\n }\n}\n\nexport interface ToolResult {\n content: Array<{ type: 'text'; text: string }>;\n details: TaskDetails;\n}\n\n/** Build the LLM-facing envelope. `details` carries the post-mutation snapshot. */\nexport function buildToolResult(\n action: TaskAction,\n params: TaskMutationParams,\n document: TaskDocument,\n op: Op,\n): ToolResult {\n return {\n content: [{ type: 'text', text: formatContent(op, document) }],\n details: {\n action,\n params: params as Record<string, unknown>,\n tasks: document.tasks,\n nextId: document.nextId,\n rev: document.rev,\n ...(op.kind === 'error' ? { error: op.message } : {}),\n // Deliberately no `error` on a partial success: renderResult treats\n // `details.error` as total failure and would hide the rows for the\n // entries that did land.\n ...(op.kind === 'upsert'\n ? {\n upsert: {\n applied: op.items.flatMap((item) => (item.kind === 'failed' ? [] : [item.id])),\n failed: op.failed,\n },\n }\n : {}),\n },\n };\n}\n\n/** Envelope for a native assignment batch, including ids used by the consolidated TUI result. */\nexport function buildAssignmentResult(\n params: TaskMutationParams,\n document: TaskDocument,\n text: string,\n assignment: AssignmentSummary,\n): ToolResult {\n return {\n content: [{ type: 'text', text }],\n details: {\n action: 'assign',\n params: params as Record<string, unknown>,\n tasks: document.tasks,\n nextId: document.nextId,\n rev: document.rev,\n assignment,\n },\n };\n}\n\n/** Envelope for delegation actions, which do not flow through the reducer. */\nexport function buildTextResult(\n action: TaskAction,\n params: TaskMutationParams,\n document: TaskDocument,\n text: string,\n error?: string,\n): ToolResult {\n return {\n content: [{ type: 'text', text: error ? `Error: ${error}` : text }],\n details: {\n action,\n params: params as Record<string, unknown>,\n tasks: document.tasks,\n nextId: document.nextId,\n rev: document.rev,\n ...(error ? { error } : {}),\n },\n };\n}\n"],"mappings":"0FAYA,MAAa,EACX,4GAQW,EACX,0OAEW,EAA0B,mEAE1B,EACX,8JAWF,SAAgB,EAAwB,EAAgD,CACtF,GAAI,EAAM,SAAW,EAAG,OAAO,EAAM,EAAE,CAAC,QAExC,IAAM,EAAY,EAAM,OAAQ,GAAS,EAAK,EAAE,CAAC,CAAC,OAC5C,EAAS,EAAM,OAAS,EACxB,EAAQ,CACZ,YAAY,EAAU,GAAG,EAAM,OAAO,QAAQ,EAAS,EAAI,KAAK,EAAO,SAAW,GAAG,GACrF,GAAG,EAAM,IAAK,GACZ,EAAK,GACD,MAAM,EAAK,MAAM,eAAe,EAAK,GAAG,MAAM,EAAK,QACnD,MAAM,EAAK,MAAM,YAAY,EAAK,GAAG,KAAK,EAAK,MAAM,IAAI,EAAK,SACpE,CACF,EASA,OAPI,EAAS,GAAK,EAAY,GAAG,EAAM,KAAK,GAAI,CAAkB,EAC9D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