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

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 (190) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  4. package/dist/commands.cjs +2 -0
  5. package/dist/commands.cjs.map +1 -0
  6. package/dist/commands.d.cts +14 -0
  7. package/dist/commands.d.cts.map +1 -0
  8. package/dist/commands.d.mts +14 -0
  9. package/dist/commands.d.mts.map +1 -0
  10. package/dist/commands.mjs +2 -0
  11. package/dist/commands.mjs.map +1 -0
  12. package/dist/config.cjs +2 -0
  13. package/dist/config.cjs.map +1 -0
  14. package/dist/config.d.cts +38 -0
  15. package/dist/config.d.cts.map +1 -0
  16. package/dist/config.d.mts +38 -0
  17. package/dist/config.d.mts.map +1 -0
  18. package/dist/config.mjs +2 -0
  19. package/dist/config.mjs.map +1 -0
  20. package/dist/delegation/manager.cjs +5 -0
  21. package/dist/delegation/manager.cjs.map +1 -0
  22. package/dist/delegation/manager.d.cts +189 -0
  23. package/dist/delegation/manager.d.cts.map +1 -0
  24. package/dist/delegation/manager.d.mts +189 -0
  25. package/dist/delegation/manager.d.mts.map +1 -0
  26. package/dist/delegation/manager.mjs +5 -0
  27. package/dist/delegation/manager.mjs.map +1 -0
  28. package/dist/extension.cjs +3 -0
  29. package/dist/extension.cjs.map +1 -0
  30. package/dist/extension.d.cts +12 -0
  31. package/dist/extension.d.cts.map +1 -0
  32. package/dist/extension.d.mts +12 -0
  33. package/dist/extension.d.mts.map +1 -0
  34. package/dist/extension.mjs +3 -0
  35. package/dist/extension.mjs.map +1 -0
  36. package/dist/extensions/doom.cjs +2 -0
  37. package/dist/extensions/doom.cjs.map +1 -0
  38. package/dist/extensions/doom.d.cts +6 -0
  39. package/dist/extensions/doom.d.cts.map +1 -0
  40. package/dist/extensions/doom.d.mts +7 -0
  41. package/dist/extensions/doom.d.mts.map +1 -0
  42. package/dist/extensions/doom.mjs +2 -0
  43. package/dist/extensions/doom.mjs.map +1 -0
  44. package/dist/extensions/pi.cjs +2 -0
  45. package/dist/extensions/pi.cjs.map +1 -0
  46. package/dist/extensions/pi.d.cts +2 -0
  47. package/dist/extensions/pi.d.mts +2 -0
  48. package/dist/extensions/pi.mjs +2 -0
  49. package/dist/extensions/pi.mjs.map +1 -0
  50. package/dist/index.cjs +1 -0
  51. package/dist/index.d.cts +15 -0
  52. package/dist/index.d.mts +15 -0
  53. package/dist/index.mjs +1 -0
  54. package/dist/logSinkTelemetry.cjs +2 -0
  55. package/dist/logSinkTelemetry.cjs.map +1 -0
  56. package/dist/logSinkTelemetry.d.cts +51 -0
  57. package/dist/logSinkTelemetry.d.cts.map +1 -0
  58. package/dist/logSinkTelemetry.d.mts +51 -0
  59. package/dist/logSinkTelemetry.d.mts.map +1 -0
  60. package/dist/logSinkTelemetry.mjs +2 -0
  61. package/dist/logSinkTelemetry.mjs.map +1 -0
  62. package/dist/store/invariants.cjs +2 -0
  63. package/dist/store/invariants.cjs.map +1 -0
  64. package/dist/store/invariants.d.cts +14 -0
  65. package/dist/store/invariants.d.cts.map +1 -0
  66. package/dist/store/invariants.d.mts +14 -0
  67. package/dist/store/invariants.d.mts.map +1 -0
  68. package/dist/store/invariants.mjs +2 -0
  69. package/dist/store/invariants.mjs.map +1 -0
  70. package/dist/store/paths.cjs +2 -0
  71. package/dist/store/paths.cjs.map +1 -0
  72. package/dist/store/paths.d.cts +23 -0
  73. package/dist/store/paths.d.cts.map +1 -0
  74. package/dist/store/paths.d.mts +23 -0
  75. package/dist/store/paths.d.mts.map +1 -0
  76. package/dist/store/paths.mjs +2 -0
  77. package/dist/store/paths.mjs.map +1 -0
  78. package/dist/store/processLiveness.cjs +2 -0
  79. package/dist/store/processLiveness.cjs.map +1 -0
  80. package/dist/store/processLiveness.d.cts +12 -0
  81. package/dist/store/processLiveness.d.cts.map +1 -0
  82. package/dist/store/processLiveness.d.mts +12 -0
  83. package/dist/store/processLiveness.d.mts.map +1 -0
  84. package/dist/store/processLiveness.mjs +2 -0
  85. package/dist/store/processLiveness.mjs.map +1 -0
  86. package/dist/store/reconcile.cjs +2 -0
  87. package/dist/store/reconcile.cjs.map +1 -0
  88. package/dist/store/reconcile.d.cts +34 -0
  89. package/dist/store/reconcile.d.cts.map +1 -0
  90. package/dist/store/reconcile.d.mts +34 -0
  91. package/dist/store/reconcile.d.mts.map +1 -0
  92. package/dist/store/reconcile.mjs +2 -0
  93. package/dist/store/reconcile.mjs.map +1 -0
  94. package/dist/store/reducer.cjs +3 -0
  95. package/dist/store/reducer.cjs.map +1 -0
  96. package/dist/store/reducer.d.cts +72 -0
  97. package/dist/store/reducer.d.cts.map +1 -0
  98. package/dist/store/reducer.d.mts +72 -0
  99. package/dist/store/reducer.d.mts.map +1 -0
  100. package/dist/store/reducer.mjs +3 -0
  101. package/dist/store/reducer.mjs.map +1 -0
  102. package/dist/store/taskGraph.cjs +2 -0
  103. package/dist/store/taskGraph.cjs.map +1 -0
  104. package/dist/store/taskGraph.d.cts +25 -0
  105. package/dist/store/taskGraph.d.cts.map +1 -0
  106. package/dist/store/taskGraph.d.mts +25 -0
  107. package/dist/store/taskGraph.d.mts.map +1 -0
  108. package/dist/store/taskGraph.mjs +2 -0
  109. package/dist/store/taskGraph.mjs.map +1 -0
  110. package/dist/store/taskStore.cjs +2 -0
  111. package/dist/store/taskStore.cjs.map +1 -0
  112. package/dist/store/taskStore.d.cts +77 -0
  113. package/dist/store/taskStore.d.cts.map +1 -0
  114. package/dist/store/taskStore.d.mts +77 -0
  115. package/dist/store/taskStore.d.mts.map +1 -0
  116. package/dist/store/taskStore.mjs +2 -0
  117. package/dist/store/taskStore.mjs.map +1 -0
  118. package/dist/store/types.cjs +2 -0
  119. package/dist/store/types.cjs.map +1 -0
  120. package/dist/store/types.d.cts +165 -0
  121. package/dist/store/types.d.cts.map +1 -0
  122. package/dist/store/types.d.mts +165 -0
  123. package/dist/store/types.d.mts.map +1 -0
  124. package/dist/store/types.mjs +2 -0
  125. package/dist/store/types.mjs.map +1 -0
  126. package/dist/tool/promptGuidelines.cjs +2 -0
  127. package/dist/tool/promptGuidelines.cjs.map +1 -0
  128. package/dist/tool/promptGuidelines.d.cts +5 -0
  129. package/dist/tool/promptGuidelines.d.cts.map +1 -0
  130. package/dist/tool/promptGuidelines.d.mts +5 -0
  131. package/dist/tool/promptGuidelines.d.mts.map +1 -0
  132. package/dist/tool/promptGuidelines.mjs +2 -0
  133. package/dist/tool/promptGuidelines.mjs.map +1 -0
  134. package/dist/tool/responseEnvelope.cjs +6 -0
  135. package/dist/tool/responseEnvelope.cjs.map +1 -0
  136. package/dist/tool/responseEnvelope.d.cts +39 -0
  137. package/dist/tool/responseEnvelope.d.cts.map +1 -0
  138. package/dist/tool/responseEnvelope.d.mts +39 -0
  139. package/dist/tool/responseEnvelope.d.mts.map +1 -0
  140. package/dist/tool/responseEnvelope.mjs +6 -0
  141. package/dist/tool/responseEnvelope.mjs.map +1 -0
  142. package/dist/tool/schema.cjs +2 -0
  143. package/dist/tool/schema.cjs.map +1 -0
  144. package/dist/tool/schema.d.cts +86 -0
  145. package/dist/tool/schema.d.cts.map +1 -0
  146. package/dist/tool/schema.d.mts +86 -0
  147. package/dist/tool/schema.d.mts.map +1 -0
  148. package/dist/tool/schema.mjs +2 -0
  149. package/dist/tool/schema.mjs.map +1 -0
  150. package/dist/tool/taskTool.cjs +3 -0
  151. package/dist/tool/taskTool.cjs.map +1 -0
  152. package/dist/tool/taskTool.d.cts +17 -0
  153. package/dist/tool/taskTool.d.cts.map +1 -0
  154. package/dist/tool/taskTool.d.mts +17 -0
  155. package/dist/tool/taskTool.d.mts.map +1 -0
  156. package/dist/tool/taskTool.mjs +3 -0
  157. package/dist/tool/taskTool.mjs.map +1 -0
  158. package/dist/tui/format.cjs +4 -0
  159. package/dist/tui/format.cjs.map +1 -0
  160. package/dist/tui/format.d.cts +62 -0
  161. package/dist/tui/format.d.cts.map +1 -0
  162. package/dist/tui/format.d.mts +62 -0
  163. package/dist/tui/format.d.mts.map +1 -0
  164. package/dist/tui/format.mjs +4 -0
  165. package/dist/tui/format.mjs.map +1 -0
  166. package/dist/tui/selectors.cjs +2 -0
  167. package/dist/tui/selectors.cjs.map +1 -0
  168. package/dist/tui/selectors.d.cts +45 -0
  169. package/dist/tui/selectors.d.cts.map +1 -0
  170. package/dist/tui/selectors.d.mts +45 -0
  171. package/dist/tui/selectors.d.mts.map +1 -0
  172. package/dist/tui/selectors.mjs +2 -0
  173. package/dist/tui/selectors.mjs.map +1 -0
  174. package/dist/tui/taskOverlay.cjs +2 -0
  175. package/dist/tui/taskOverlay.cjs.map +1 -0
  176. package/dist/tui/taskOverlay.d.cts +38 -0
  177. package/dist/tui/taskOverlay.d.cts.map +1 -0
  178. package/dist/tui/taskOverlay.d.mts +38 -0
  179. package/dist/tui/taskOverlay.d.mts.map +1 -0
  180. package/dist/tui/taskOverlay.mjs +2 -0
  181. package/dist/tui/taskOverlay.mjs.map +1 -0
  182. package/dist/tui/taskSpace.cjs +5 -0
  183. package/dist/tui/taskSpace.cjs.map +1 -0
  184. package/dist/tui/taskSpace.d.cts +61 -0
  185. package/dist/tui/taskSpace.d.cts.map +1 -0
  186. package/dist/tui/taskSpace.d.mts +61 -0
  187. package/dist/tui/taskSpace.d.mts.map +1 -0
  188. package/dist/tui/taskSpace.mjs +5 -0
  189. package/dist/tui/taskSpace.mjs.map +1 -0
  190. package/package.json +185 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vuong Ngo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @agimon-ai/doompi-task
2
+
3
+ Pi task tracking extension with file-backed tasks and subagent delegation.
4
+
5
+ A file-backed task graph with dependencies and delegation, not a scratch list. Tasks survive
6
+ compaction because the store is on disk rather than in the transcript.
7
+
8
+ Part of [Doompi](https://www.npmjs.com/package/@agimon-ai/doompi), a coding agent that loads
9
+ only the skills and tools you name. This package is composed by Doompi and is not usually
10
+ installed on its own.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install @agimon-ai/doompi-task
16
+ ```
17
+
18
+ ## How it loads
19
+
20
+ Doompi loads this unconditionally. It is core, not a layer, so it does not appear in
21
+ `.doom/modes.yaml`: making it optional would only create broken configurations.
22
+
23
+ Extension entry: `@agimon-ai/doompi-task/extensions/pi`
24
+
25
+ ## Leader
26
+
27
+ `SPC t t` opens tasks, once the extension is loaded.
28
+
29
+ ## Entry points
30
+
31
+ 24 subpaths are declared in the `exports` field of `package.json`.
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));exports.__toESM=s;
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./tool/schema.cjs"),t=require("./tui/taskSpace.cjs");function n(n,r){n.registerCommand(e.COMMAND_NAME,{description:`Open Task Space for this session tree`,handler:async(n,i)=>{if(!i.hasUI){i.ui.notify(e.ERR_REQUIRES_INTERACTIVE,`error`);return}r.read(),await t.openTaskSpace(i,{store:r})}})}exports.registerTasksCommand=n;
2
+ //# sourceMappingURL=commands.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.cjs","names":["COMMAND_NAME","ERR_REQUIRES_INTERACTIVE","openTaskSpace"],"sources":["../src/commands.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { TaskStore } from './store/taskStore.ts';\nimport { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE } from './tool/schema.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":"yIAYA,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,14 @@
1
+ import { TaskStore } from "./store/taskStore.cjs";
2
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ //#region src/commands.d.ts
4
+ /**
5
+ * `/tasks`, reachable from the leader palette as `SPC t t`.
6
+ *
7
+ * The command opens the Task Space overlay rather than printing a listing: the
8
+ * overlay is the readable surface and it can edit, while a transcript dump could
9
+ * only be read.
10
+ */
11
+ declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void;
12
+ //#endregion
13
+ export { registerTasksCommand };
14
+ //# sourceMappingURL=commands.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.cts","names":[],"sources":["../src/commands.ts"],"mappings":";;;;;;;;;;iBAYgB,qBAAqB,IAAI,cAAc,OAAO"}
@@ -0,0 +1,14 @@
1
+ import { TaskStore } from "./store/taskStore.mjs";
2
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ //#region src/commands.d.ts
4
+ /**
5
+ * `/tasks`, reachable from the leader palette as `SPC t t`.
6
+ *
7
+ * The command opens the Task Space overlay rather than printing a listing: the
8
+ * overlay is the readable surface and it can edit, while a transcript dump could
9
+ * only be read.
10
+ */
11
+ declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore): void;
12
+ //#endregion
13
+ export { registerTasksCommand };
14
+ //# sourceMappingURL=commands.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.mts","names":[],"sources":["../src/commands.ts"],"mappings":";;;;;;;;;;iBAYgB,qBAAqB,IAAI,cAAc,OAAO"}
@@ -0,0 +1,2 @@
1
+ import{COMMAND_NAME as e,ERR_REQUIRES_INTERACTIVE as t}from"./tool/schema.mjs";import{openTaskSpace as n}from"./tui/taskSpace.mjs";function r(r,i){r.registerCommand(e,{description:`Open Task Space for this session tree`,handler:async(e,r)=>{if(!r.hasUI){r.ui.notify(t,`error`);return}i.read(),await n(r,{store:i})}})}export{r as registerTasksCommand};
2
+ //# sourceMappingURL=commands.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.mjs","names":[],"sources":["../src/commands.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { TaskStore } from './store/taskStore.ts';\nimport { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE } from './tool/schema.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":"mIAYA,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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=`DOOM_TASK_COLLAPSE_KEY`,t=`DOOM_TASK_STORE_TTL_MS`,n=`DOOM_TASK_DELEGATION_TIMEOUT_MS`,r=`ctrl+shift+t`,i=2592e6,a=12e5;function o(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function s(e){let t=o(e),n=typeof t.maxWidgetLines==`number`&&Number.isFinite(t.maxWidgetLines)?Math.min(Math.max(t.maxWidgetLines,3),60):12,s=typeof t.storeTtlMs==`number`&&Number.isFinite(t.storeTtlMs)&&t.storeTtlMs>0?t.storeTtlMs:i,c=typeof t.delegationTimeoutMs==`number`&&Number.isFinite(t.delegationTimeoutMs)&&t.delegationTimeoutMs>0?t.delegationTimeoutMs:a;return{maxWidgetLines:n,storeTtlMs:s,collapseKey:typeof t.collapseKey==`string`&&t.collapseKey.trim()?t.collapseKey.trim().toLowerCase()===`off`?`off`:t.collapseKey.trim():r,delegationTimeoutMs:c}}function c(e=process.env){let t=Number.parseInt(e.DOOM_TASK_MAX_WIDGET_LINES??``,10);return Number.isFinite(t)?Math.min(Math.max(t,3),60):12}function l(e=process.env){let n=Number(e[t]);return Number.isFinite(n)&&n>0?n:i}function u(e=process.env){let t=Number(e[n]);return Number.isFinite(t)&&t>0?t:a}function d(t=process.env){let n=t[e]?.trim();return n?n.toLowerCase()===`off`?`off`:n:r}exports.COLLAPSE_KEY_ENV=e,exports.COLLAPSE_KEY_OFF=`off`,exports.DEFAULT_COLLAPSE_KEY=r,exports.DEFAULT_DELEGATION_TIMEOUT_MS=a,exports.DEFAULT_MAX_WIDGET_LINES=12,exports.DEFAULT_STORE_TTL_MS=i,exports.DELEGATION_TIMEOUT_MS_ENV=n,exports.MAX_WIDGET_LINES_ENV=`DOOM_TASK_MAX_WIDGET_LINES`,exports.STORE_TTL_MS_ENV=t,exports.getDelegationTimeoutMs=u,exports.getMaxWidgetLines=c,exports.getStoreTtlMs=l,exports.parsePiTaskConfig=s,exports.resolveCollapseKey=d;
2
+ //# sourceMappingURL=config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Extension configuration, read from the environment.\n *\n * Env rather than a config file: doom-pi already carries per-launch state to Pi\n * through env vars, so this keeps doom-task consistent with how the harness\n * configures the rest of the extension set.\n */\n\nexport const MAX_WIDGET_LINES_ENV = 'DOOM_TASK_MAX_WIDGET_LINES';\nexport const COLLAPSE_KEY_ENV = 'DOOM_TASK_COLLAPSE_KEY';\nexport const STORE_TTL_MS_ENV = 'DOOM_TASK_STORE_TTL_MS';\nexport const DELEGATION_TIMEOUT_MS_ENV = 'DOOM_TASK_DELEGATION_TIMEOUT_MS';\n\nexport const DEFAULT_MAX_WIDGET_LINES = 12;\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+shift+t';\nexport const DEFAULT_STORE_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n/** Deliberately under the subagents auto-drain ceiling (30 min) so a headless\n * session still gets the failure and a model turn before draining gives up. */\nexport const DEFAULT_DELEGATION_TIMEOUT_MS = 20 * 60 * 1000;\nexport const COLLAPSE_KEY_OFF = 'off';\n\nconst MIN_WIDGET_LINES = 3;\nconst MAX_WIDGET_LINES = 60;\n\nexport interface PiTaskConfig {\n maxWidgetLines: number;\n storeTtlMs: number;\n collapseKey: string;\n delegationTimeoutMs: number;\n}\n\nfunction configRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\n/** Parse configuration only after the Pi host has applied its project-trust policy. */\nexport function parsePiTaskConfig(value: unknown): PiTaskConfig {\n const config = configRecord(value);\n const maxWidgetLines =\n typeof config.maxWidgetLines === 'number' && Number.isFinite(config.maxWidgetLines)\n ? Math.min(Math.max(config.maxWidgetLines, MIN_WIDGET_LINES), MAX_WIDGET_LINES)\n : DEFAULT_MAX_WIDGET_LINES;\n const storeTtlMs =\n typeof config.storeTtlMs === 'number' && Number.isFinite(config.storeTtlMs) && config.storeTtlMs > 0\n ? config.storeTtlMs\n : DEFAULT_STORE_TTL_MS;\n const delegationTimeoutMs =\n typeof config.delegationTimeoutMs === 'number' &&\n Number.isFinite(config.delegationTimeoutMs) &&\n config.delegationTimeoutMs > 0\n ? config.delegationTimeoutMs\n : DEFAULT_DELEGATION_TIMEOUT_MS;\n const collapseKey =\n typeof config.collapseKey === 'string' && config.collapseKey.trim()\n ? config.collapseKey.trim().toLowerCase() === COLLAPSE_KEY_OFF\n ? COLLAPSE_KEY_OFF\n : config.collapseKey.trim()\n : DEFAULT_COLLAPSE_KEY;\n\n return { maxWidgetLines, storeTtlMs, collapseKey, delegationTimeoutMs };\n}\n\n/** Rows the overlay may use for content, clamped to a sane range. */\nexport function getMaxWidgetLines(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number.parseInt(env[MAX_WIDGET_LINES_ENV] ?? '', 10);\n if (!Number.isFinite(raw)) return DEFAULT_MAX_WIDGET_LINES;\n return Math.min(Math.max(raw, MIN_WIDGET_LINES), MAX_WIDGET_LINES);\n}\n\n/** Retention window for inactive session-tree stores. */\nexport function getStoreTtlMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[STORE_TTL_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_STORE_TTL_MS;\n}\n\n/** How long a delegated run may go without reporting a result. */\nexport function getDelegationTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[DELEGATION_TIMEOUT_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_DELEGATION_TIMEOUT_MS;\n}\n\n/** Collapse shortcut, or the `off` sentinel when the user disabled it. */\nexport function resolveCollapseKey(env: NodeJS.ProcessEnv = process.env): string {\n const configured = env[COLLAPSE_KEY_ENV]?.trim();\n if (!configured) return DEFAULT_COLLAPSE_KEY;\n return configured.toLowerCase() === COLLAPSE_KEY_OFF ? COLLAPSE_KEY_OFF : configured;\n}\n"],"mappings":"mEAQA,MACa,EAAmB,yBACnB,EAAmB,yBACnB,EAA4B,kCAG5B,EAAuB,eACvB,EAAuB,OAGvB,EA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IAAM,EAAa,EAAI,EAAiB,EAAE,KAAK,EAE/C,OADK,EACE,EAAW,YAAY,IAAA,MAAA,MAA4C,EADlD,CAE1B"}
@@ -0,0 +1,38 @@
1
+ //#region src/config.d.ts
2
+ /**
3
+ * Extension configuration, read from the environment.
4
+ *
5
+ * Env rather than a config file: doom-pi already carries per-launch state to Pi
6
+ * through env vars, so this keeps doom-task consistent with how the harness
7
+ * configures the rest of the extension set.
8
+ */
9
+ declare const MAX_WIDGET_LINES_ENV = "DOOM_TASK_MAX_WIDGET_LINES";
10
+ declare const COLLAPSE_KEY_ENV = "DOOM_TASK_COLLAPSE_KEY";
11
+ declare const STORE_TTL_MS_ENV = "DOOM_TASK_STORE_TTL_MS";
12
+ declare const DELEGATION_TIMEOUT_MS_ENV = "DOOM_TASK_DELEGATION_TIMEOUT_MS";
13
+ declare const DEFAULT_MAX_WIDGET_LINES = 12;
14
+ declare const DEFAULT_COLLAPSE_KEY = "ctrl+shift+t";
15
+ declare const DEFAULT_STORE_TTL_MS: number;
16
+ /** Deliberately under the subagents auto-drain ceiling (30 min) so a headless
17
+ * session still gets the failure and a model turn before draining gives up. */
18
+ declare const DEFAULT_DELEGATION_TIMEOUT_MS: number;
19
+ declare const COLLAPSE_KEY_OFF = "off";
20
+ interface PiTaskConfig {
21
+ maxWidgetLines: number;
22
+ storeTtlMs: number;
23
+ collapseKey: string;
24
+ delegationTimeoutMs: number;
25
+ }
26
+ /** Parse configuration only after the Pi host has applied its project-trust policy. */
27
+ declare function parsePiTaskConfig(value: unknown): PiTaskConfig;
28
+ /** Rows the overlay may use for content, clamped to a sane range. */
29
+ declare function getMaxWidgetLines(env?: NodeJS.ProcessEnv): number;
30
+ /** Retention window for inactive session-tree stores. */
31
+ declare function getStoreTtlMs(env?: NodeJS.ProcessEnv): number;
32
+ /** How long a delegated run may go without reporting a result. */
33
+ declare function getDelegationTimeoutMs(env?: NodeJS.ProcessEnv): number;
34
+ /** Collapse shortcut, or the `off` sentinel when the user disabled it. */
35
+ declare function resolveCollapseKey(env?: NodeJS.ProcessEnv): string;
36
+ //#endregion
37
+ export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
38
+ //# sourceMappingURL=config.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;;cAQa;cACA;cACA;cACA;cAEA;cACA;cACA;;;cAGA;cACA;UAKI;EACf;EACA;EACA;EACA;;;iBAQc,kBAAkB,iBAAiB;;iBA2BnC,kBAAkB,MAAK,OAAO;;iBAO9B,cAAc,MAAK,OAAO;;iBAM1B,uBAAuB,MAAK,OAAO;;iBAMnC,mBAAmB,MAAK,OAAO"}
@@ -0,0 +1,38 @@
1
+ //#region src/config.d.ts
2
+ /**
3
+ * Extension configuration, read from the environment.
4
+ *
5
+ * Env rather than a config file: doom-pi already carries per-launch state to Pi
6
+ * through env vars, so this keeps doom-task consistent with how the harness
7
+ * configures the rest of the extension set.
8
+ */
9
+ declare const MAX_WIDGET_LINES_ENV = "DOOM_TASK_MAX_WIDGET_LINES";
10
+ declare const COLLAPSE_KEY_ENV = "DOOM_TASK_COLLAPSE_KEY";
11
+ declare const STORE_TTL_MS_ENV = "DOOM_TASK_STORE_TTL_MS";
12
+ declare const DELEGATION_TIMEOUT_MS_ENV = "DOOM_TASK_DELEGATION_TIMEOUT_MS";
13
+ declare const DEFAULT_MAX_WIDGET_LINES = 12;
14
+ declare const DEFAULT_COLLAPSE_KEY = "ctrl+shift+t";
15
+ declare const DEFAULT_STORE_TTL_MS: number;
16
+ /** Deliberately under the subagents auto-drain ceiling (30 min) so a headless
17
+ * session still gets the failure and a model turn before draining gives up. */
18
+ declare const DEFAULT_DELEGATION_TIMEOUT_MS: number;
19
+ declare const COLLAPSE_KEY_OFF = "off";
20
+ interface PiTaskConfig {
21
+ maxWidgetLines: number;
22
+ storeTtlMs: number;
23
+ collapseKey: string;
24
+ delegationTimeoutMs: number;
25
+ }
26
+ /** Parse configuration only after the Pi host has applied its project-trust policy. */
27
+ declare function parsePiTaskConfig(value: unknown): PiTaskConfig;
28
+ /** Rows the overlay may use for content, clamped to a sane range. */
29
+ declare function getMaxWidgetLines(env?: NodeJS.ProcessEnv): number;
30
+ /** Retention window for inactive session-tree stores. */
31
+ declare function getStoreTtlMs(env?: NodeJS.ProcessEnv): number;
32
+ /** How long a delegated run may go without reporting a result. */
33
+ declare function getDelegationTimeoutMs(env?: NodeJS.ProcessEnv): number;
34
+ /** Collapse shortcut, or the `off` sentinel when the user disabled it. */
35
+ declare function resolveCollapseKey(env?: NodeJS.ProcessEnv): string;
36
+ //#endregion
37
+ export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
38
+ //# sourceMappingURL=config.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;;cAQa;cACA;cACA;cACA;cAEA;cACA;cACA;;;cAGA;cACA;UAKI;EACf;EACA;EACA;EACA;;;iBAQc,kBAAkB,iBAAiB;;iBA2BnC,kBAAkB,MAAK,OAAO;;iBAO9B,cAAc,MAAK,OAAO;;iBAM1B,uBAAuB,MAAK,OAAO;;iBAMnC,mBAAmB,MAAK,OAAO"}
@@ -0,0 +1,2 @@
1
+ const e=`DOOM_TASK_MAX_WIDGET_LINES`,t=`DOOM_TASK_COLLAPSE_KEY`,n=`DOOM_TASK_STORE_TTL_MS`,r=`DOOM_TASK_DELEGATION_TIMEOUT_MS`,i=12,a=`ctrl+shift+t`,o=2592e6,s=12e5,c=`off`;function l(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function u(e){let t=l(e),n=typeof t.maxWidgetLines==`number`&&Number.isFinite(t.maxWidgetLines)?Math.min(Math.max(t.maxWidgetLines,3),60):12,r=typeof t.storeTtlMs==`number`&&Number.isFinite(t.storeTtlMs)&&t.storeTtlMs>0?t.storeTtlMs:o,i=typeof t.delegationTimeoutMs==`number`&&Number.isFinite(t.delegationTimeoutMs)&&t.delegationTimeoutMs>0?t.delegationTimeoutMs:s;return{maxWidgetLines:n,storeTtlMs:r,collapseKey:typeof t.collapseKey==`string`&&t.collapseKey.trim()?t.collapseKey.trim().toLowerCase()===`off`?`off`:t.collapseKey.trim():a,delegationTimeoutMs:i}}function d(e=process.env){let t=Number.parseInt(e.DOOM_TASK_MAX_WIDGET_LINES??``,10);return Number.isFinite(t)?Math.min(Math.max(t,3),60):12}function f(e=process.env){let t=Number(e[n]);return Number.isFinite(t)&&t>0?t:o}function p(e=process.env){let t=Number(e[r]);return Number.isFinite(t)&&t>0?t:s}function m(e=process.env){let n=e[t]?.trim();return n?n.toLowerCase()===`off`?`off`:n:a}export{t as COLLAPSE_KEY_ENV,c as COLLAPSE_KEY_OFF,a as DEFAULT_COLLAPSE_KEY,s as DEFAULT_DELEGATION_TIMEOUT_MS,i as DEFAULT_MAX_WIDGET_LINES,o as DEFAULT_STORE_TTL_MS,r as DELEGATION_TIMEOUT_MS_ENV,e as MAX_WIDGET_LINES_ENV,n as STORE_TTL_MS_ENV,p as getDelegationTimeoutMs,d as getMaxWidgetLines,f as getStoreTtlMs,u as parsePiTaskConfig,m as resolveCollapseKey};
2
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Extension configuration, read from the environment.\n *\n * Env rather than a config file: doom-pi already carries per-launch state to Pi\n * through env vars, so this keeps doom-task consistent with how the harness\n * configures the rest of the extension set.\n */\n\nexport const MAX_WIDGET_LINES_ENV = 'DOOM_TASK_MAX_WIDGET_LINES';\nexport const COLLAPSE_KEY_ENV = 'DOOM_TASK_COLLAPSE_KEY';\nexport const STORE_TTL_MS_ENV = 'DOOM_TASK_STORE_TTL_MS';\nexport const DELEGATION_TIMEOUT_MS_ENV = 'DOOM_TASK_DELEGATION_TIMEOUT_MS';\n\nexport const DEFAULT_MAX_WIDGET_LINES = 12;\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+shift+t';\nexport const DEFAULT_STORE_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n/** Deliberately under the subagents auto-drain ceiling (30 min) so a headless\n * session still gets the failure and a model turn before draining gives up. */\nexport const DEFAULT_DELEGATION_TIMEOUT_MS = 20 * 60 * 1000;\nexport const COLLAPSE_KEY_OFF = 'off';\n\nconst MIN_WIDGET_LINES = 3;\nconst MAX_WIDGET_LINES = 60;\n\nexport interface PiTaskConfig {\n maxWidgetLines: number;\n storeTtlMs: number;\n collapseKey: string;\n delegationTimeoutMs: number;\n}\n\nfunction configRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\n/** Parse configuration only after the Pi host has applied its project-trust policy. */\nexport function parsePiTaskConfig(value: unknown): PiTaskConfig {\n const config = configRecord(value);\n const maxWidgetLines =\n typeof config.maxWidgetLines === 'number' && Number.isFinite(config.maxWidgetLines)\n ? Math.min(Math.max(config.maxWidgetLines, MIN_WIDGET_LINES), MAX_WIDGET_LINES)\n : DEFAULT_MAX_WIDGET_LINES;\n const storeTtlMs =\n typeof config.storeTtlMs === 'number' && Number.isFinite(config.storeTtlMs) && config.storeTtlMs > 0\n ? config.storeTtlMs\n : DEFAULT_STORE_TTL_MS;\n const delegationTimeoutMs =\n typeof config.delegationTimeoutMs === 'number' &&\n Number.isFinite(config.delegationTimeoutMs) &&\n config.delegationTimeoutMs > 0\n ? config.delegationTimeoutMs\n : DEFAULT_DELEGATION_TIMEOUT_MS;\n const collapseKey =\n typeof config.collapseKey === 'string' && config.collapseKey.trim()\n ? config.collapseKey.trim().toLowerCase() === COLLAPSE_KEY_OFF\n ? COLLAPSE_KEY_OFF\n : config.collapseKey.trim()\n : DEFAULT_COLLAPSE_KEY;\n\n return { maxWidgetLines, storeTtlMs, collapseKey, delegationTimeoutMs };\n}\n\n/** Rows the overlay may use for content, clamped to a sane range. */\nexport function getMaxWidgetLines(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number.parseInt(env[MAX_WIDGET_LINES_ENV] ?? '', 10);\n if (!Number.isFinite(raw)) return DEFAULT_MAX_WIDGET_LINES;\n return Math.min(Math.max(raw, MIN_WIDGET_LINES), MAX_WIDGET_LINES);\n}\n\n/** Retention window for inactive session-tree stores. */\nexport function getStoreTtlMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[STORE_TTL_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_STORE_TTL_MS;\n}\n\n/** How long a delegated run may go without reporting a result. */\nexport function getDelegationTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[DELEGATION_TIMEOUT_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_DELEGATION_TIMEOUT_MS;\n}\n\n/** Collapse shortcut, or the `off` sentinel when the user disabled it. */\nexport function resolveCollapseKey(env: NodeJS.ProcessEnv = process.env): string {\n const configured = env[COLLAPSE_KEY_ENV]?.trim();\n if (!configured) return DEFAULT_COLLAPSE_KEY;\n return configured.toLowerCase() === COLLAPSE_KEY_OFF ? COLLAPSE_KEY_OFF : configured;\n}\n"],"mappings":"AA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AAO,EAAI,EAA0B,EACjD,OAAO,OAAO,SAAS,CAAG,GAAK,EAAM,EAAI,EAAM,CACjD,CAGA,SAAgB,EAAmB,EAAyB,QAAQ,IAAa,CAC/E,IAAM,EAAa,EAAI,EAAiB,EAAE,KAAK,EAE/C,OADK,EACE,EAAW,YAAY,IAAA,MAAA,MAA4C,EADlD,CAE1B"}
@@ -0,0 +1,5 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("../logSinkTelemetry.cjs"),n=require("../store/types.cjs"),r=require("../store/reconcile.cjs"),i=require("../store/taskGraph.cjs");let a=require("node:crypto"),o=require("node:path");o=e.__toESM(o,1);let s=require("@agimon-ai/doompi-extension-contracts/delegation"),c=require("@agimon-ai/doompi-extension-contracts/protocol");const l=`doom-task-notify`,u=`completed`,d=`failed`,f=`cancelled`,p=`task.id`,m=`delegation.request_id`,h=`delegation.agent_name`,g=`delegation.context_present`,_=`delegation.context_file_count`,v=`delegation.context_notes_length`,y=`No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.`,b=`assign is only available in the main session. Update this task directly instead of re-delegating it.`,x=`Subagent did not acknowledge the cancel request`;function S(e,t=4e3){if(e)return e.length<=t?e:`${e.slice(0,t)}\n… (truncated)`}function C(e){return e instanceof Error?e.message:String(e)}function w(e,t){if(!o.default.isAbsolute(e))return o.default.normalize(e);let n=o.default.relative(t,e);return n&&!n.startsWith(`..`)?n:e}function T(e,t){let n=new Set;for(let r of e.relevantFiles??[]){if(n.size>=12)break;let e=w(r.trim(),t);e&&e!==`.`&&n.add(e)}return{files:[...n],notes:S(e.priorFindings?.trim(),1500)}}function E(e,t,n){let r=[`Task #${e.id}: ${e.subject}`];return e.description&&r.push(e.description),t&&r.push(t),n.files.length>0&&r.push(`Start here (main already located these, the list may be incomplete): ${n.files.join(`, `)}`),n.notes&&r.push(`Already established by main, do not re-derive: ${n.notes}`),r.push(`Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.`),r.join(`
2
+
3
+ `)}var D=class e{options;progress=new Map;pendingTasks=new Map;timers=new Map;subscriptions=[];protocol;constructor(e){this.options=e}now(){return this.options.now?.()??new Date().toISOString()}nowMs(){return this.options.nowMs?.()??Date.now()}get env(){return this.options.env??process.env}get runTimeoutMs(){return this.options.runTimeoutMs??12e5}report(e,t,n){this.options.report?.error(e,t,n)}get isChildSession(){return!!this.env.PI_SUBAGENT_CHILD}progressFor(e){let t=e.delegation?.requestId;return t?this.progress.get(t):void 0}static elapsedMs(e,t=Date.now()){let n=e.durationMs??0,r=e.durationObservedAt??t;return n+Math.max(0,t-r)}start(){if(this.subscriptions.length>0)return;let e=this.options.getSessionId?.();e&&(this.protocol=(0,c.createProtocolRuntime)({bus:this.options.events,source:`@agimon-ai/doompi-task`,sessionId:e}),this.subscriptions.push(this.protocol.onNotification(s.DelegationAccepted,e=>{this.handleAccepted(e)}),this.protocol.onNotification(s.DelegationStarted,e=>{this.handleStarted(e)}),this.protocol.onNotification(s.DelegationUpdated,e=>{this.handleUpdate(e)}),this.protocol.onNotification(s.DelegationFinished,e=>{this.handleResponse(e).catch(n=>{this.report(t.TASK_EVENT.delegationResponseFailed,n,{[m]:e.requestId})})})))}listActiveWork(){let e=this.options.getSessionId?.()??``;return[...this.pendingTasks.entries()].map(([t,n])=>({id:`task-${n}:${t}`,sessionId:e}))}async reconcile(){let{value:e}=await this.options.store.mutate(e=>{let t=r.reconcileOrphanedDelegations(e,this.now(),void 0,{pid:process.pid,liveRequestIds:new Set(this.pendingTasks.keys())});return t.orphaned.length===0?{value:[]}:{document:t.document,value:t.orphaned}});for(let n of e)this.options.report?.warn(t.TASK_EVENT.delegationOrphaned,Error(n.delegation?.result?.error??``),{[p]:n.id,...n.delegation?.agent?{[h]:n.delegation.agent}:{},...n.delegation?.pid===void 0?{}:{"delegation.pid":n.delegation.pid}});return e.length>0&&this.options.onChange?.(),e}async assign(e,r){let o=r.agent?.trim();if(!o)return{ok:!1,message:`agent required for assign`};if(this.isChildSession)return{ok:!1,message:b};if(r.signal?.aborted)return{ok:!1,message:`delegation cancelled before it started`};let c=(0,a.randomUUID)(),l=this.now(),f=T(r,this.options.cwd),{value:x}=await this.options.store.mutate(t=>{let a=t.tasks.findIndex(t=>t.id===e);if(a===-1)return{value:{ok:!1,message:`#${e} not found`}};let s=t.tasks[a];if(s.status===`deleted`)return{value:{ok:!1,message:`#${e} is deleted`}};if(s.status===u)return{value:{ok:!1,message:`#${e} is already completed`}};if(n.isDelegationActive(s))return{value:{ok:!1,message:`#${e} is already delegated to ${s.delegation?.agent}`}};if(i.isBlocked(t.tasks,s))return{value:{ok:!1,message:`#${e} is blocked by ${(s.blockedBy??[]).map(e=>`#${e}`).join(`, `)}`}};let d={requestId:c,agent:o,state:`requested`,pid:process.pid,startedAt:l,...this.options.getSessionId?.()?{sessionId:this.options.getSessionId()}:{},...r.model?{model:r.model}:{}},f=[...t.tasks];return f[a]={...s,owner:o,updatedAt:l,delegation:d},{document:{...t,tasks:f},value:{ok:!0,message:``,task:f[a]}}});if(!x.ok||!x.task)return{ok:!1,message:x.message};let S=f.notes?.length??0;this.pendingTasks.set(c,e),this.progress.set(c,{agent:o,contextFileCount:f.files.length,contextNotesLength:S}),this.armStartedTimeout(c);let w={requestId:c,taskId:e,agent:o,...r.inlineAgent?{inlineAgent:r.inlineAgent}:{},prompt:E(x.task,r.instructions,f),...r.context?{context:r.context}:{},cwd:this.options.cwd,artifacts:!0,timeoutMs:this.runTimeoutMs,runMode:`detached`,teamTask:{id:String(x.task.id),subject:x.task.subject},...r.model?{model:r.model}:{}};try{if(!this.protocol)throw Error(y);this.protocol.notify(s.DelegationRequested,w)}catch(n){this.report(t.TASK_EVENT.delegationRequestFailed,n,{[p]:e,[m]:c,[h]:o});let r=C(n);return await this.settle(c,d,{status:d,error:`Delegation request failed: ${r}`}),{ok:!1,message:`Could not dispatch #${e} to ${o}: ${r}`}}return this.options.report?.event(t.TASK_EVENT.delegationAssigned,{[p]:e,[m]:c,[h]:o,[g]:f.files.length>0||S>0,[_]:f.files.length,[v]:S,"delegation.brief_length":w.prompt.length}),this.options.onChange?.(),{ok:!0,message:`Delegated #${e} to ${o} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end the turn and wait.`}}async cancel(e){let t=this.options.store.read().tasks.find(t=>t.id===e);if(!t)return{ok:!1,message:`#${e} not found`};if(!t.delegation||!n.isDelegationActive(t))return{ok:!1,message:`#${e} has no running delegation`};let{requestId:r}=t.delegation;return this.protocol?.notify(s.DelegationCancelled,{requestId:r}),this.armCancelTimeout(r),{ok:!0,message:`Cancelling delegation for #${e} (${t.delegation.agent})`}}settleDetached(e,n,r,i=t.TASK_EVENT.delegationSettleFailed){this.settle(e,n,r).catch(t=>{this.report(i,t,{[m]:e})})}armStartedTimeout(e){this.armTimer(e,this.options.startedTimeoutMs??5e3,()=>{this.settleDetached(e,d,{status:d,error:y})})}armRunTimeout(e){let n=Math.min(6e4,this.runTimeoutMs);this.armTimer(e,this.runTimeoutMs+n,()=>{let n=this.pendingTasks.get(e),r=this.progress.get(e)?.agent,i=Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);this.options.report?.warn(t.TASK_EVENT.delegationTimedOut,i,{...n===void 0?{}:{[p]:n},[m]:e,...r?{[h]:r}:{}}),this.protocol?.notify(s.DelegationCancelled,{requestId:e,reason:i.message}),this.settleDetached(e,d,{status:`timed_out`,error:i.message})})}armCancelTimeout(e){this.pendingTasks.has(e)&&this.armTimer(e,this.options.cancelTimeoutMs??1e4,()=>{this.settleDetached(e,f,{status:f,error:x})})}armTimer(e,t,n){this.clearTimer(e);let r=setTimeout(n,t);r.unref?.(),this.timers.set(e,r)}clearTimer(e){let t=this.timers.get(e);t&&clearTimeout(t),this.timers.delete(e)}handleAccepted(e){this.pendingTasks.has(e.requestId)&&this.armRunTimeout(e.requestId)}handleStarted(e){let{runId:n}=e,r=this.pendingTasks.get(e.requestId);if(r===void 0)return;this.armRunTimeout(e.requestId);let i=this.progress.get(e.requestId);i&&this.progress.set(e.requestId,{...i,durationMs:i.durationMs??0,durationObservedAt:i.durationObservedAt??this.nowMs()}),this.options.store.mutate(t=>this.patchDelegation(t,e.requestId,(e,t)=>({...e,status:e.status===u?e.status:`in_progress`,delegation:{...t,state:`running`,startedAt:t.startedAt??this.now(),...n?{runId:n}:{}}}))).then(()=>this.options.onChange?.()).catch(n=>{this.report(t.TASK_EVENT.delegationStartFailed,n,{[p]:r,[m]:e.requestId})})}handleUpdate(t){let n=this.progress.get(t.requestId);if(!n)return;let r=this.nowMs(),i=e.elapsedMs(n,r),a=t.durationMs!==void 0;this.progress.set(t.requestId,{...n,currentTool:t.currentTool??n.currentTool,toolCount:t.toolCount===void 0?n.toolCount:Math.max(n.toolCount??0,t.toolCount),tokens:t.tokens===void 0?n.tokens:Math.max(n.tokens??0,t.tokens),durationMs:a?Math.max(i,t.durationMs):n.durationMs,durationObservedAt:a?r:n.durationObservedAt}),this.options.onChange?.()}async handleResponse(e){if(!this.pendingTasks.has(e.requestId))return;let t=e.status===u&&!e.error?u:e.status===f?f:d;await this.settle(e.requestId,t,{status:e.status,error:e.error,output:S(e.output),outputPath:e.outputPath,sessionFile:e.sessionFile,durationMs:e.durationMs,toolCount:e.toolCount})}async settle(e,n,r){let a=this.pendingTasks.get(e);if(a===void 0)return;this.pendingTasks.delete(e),this.clearTimer(e);let o=this.progress.get(e);this.progress.delete(e);let s=this.now(),c;try{let{value:t}=await this.options.store.mutate(t=>this.patchDelegation(t,e,(e,t)=>({...e,status:n===u?u:n===f?`pending`:d,updatedAt:s,delegation:{...t,state:n,endedAt:s,...r?{result:r}:{}}})));c=t}catch(n){this.report(t.TASK_EVENT.delegationSettleFailed,n,{[p]:a,[m]:e})}this.options.onChange?.();let l=c?.delegation?.agent??o?.agent??`subagent`,y=c?.subject??`#${a}`;this.options.report?.event(t.TASK_EVENT.delegationCompleted,{[p]:a,[m]:e,[h]:l,"delegation.outcome":n,[g]:(o?.contextFileCount??0)>0||(o?.contextNotesLength??0)>0,[_]:o?.contextFileCount??0,[v]:o?.contextNotesLength??0,...r?.toolCount===void 0?{}:{"delegation.tool_count":r.toolCount},...r?.durationMs===void 0?{}:{"delegation.duration_ms":r.durationMs}});let b=n===u&&c!==void 0&&i.isTaskListComplete(this.options.store.snapshot.tasks);this.notifyModel(n,a,y,l,r,b)}notifyModel(e,t,n,r,i,a){let o=this.options.notify;if(!o)return;let s=[e===u?`Subagent ${r} completed task #${t}: ${n}`:e===f?`Subagent ${r} was cancelled on task #${t}: ${n} (returned to pending)`:`Subagent ${r} failed task #${t}: ${n}`];a&&s.push(``,`All tasks are completed. Review the full task list once more, then close it with task {"action":"clear"}.`),i?.error&&s.push(`Error: ${i.error}`),i?.output&&s.push(``,i.output),i?.outputPath&&s.push(``,`Full output: ${i.outputPath}`);try{o({customType:l,content:s.join(`
4
+ `),display:!0},{triggerTurn:!0,deliverAs:`steer`})}catch(e){this.options.onNotifyError(e,t)}}patchDelegation(e,t,r){let i=e.tasks.findIndex(e=>e.delegation?.requestId===t);if(i===-1)return{value:void 0};let a=e.tasks[i];if(!n.isDelegationActive(a))return{value:a};let o=r(a,a.delegation);if(o===a)return{value:a};let s=[...e.tasks];return s[i]=o,{document:{...e,tasks:s},value:o}}dispose(){for(let e of this.subscriptions)e();this.subscriptions.length=0,this.protocol=void 0;for(let e of this.timers.values())clearTimeout(e);this.timers.clear(),this.pendingTasks.clear(),this.progress.clear()}};exports.BACKGROUND_WORK_PROVIDER=`doom-task`,exports.DelegationManager=D,exports.ERR_CANCEL_UNACKNOWLEDGED=x,exports.ERR_CHILD_SESSION=b,exports.ERR_NO_RUNTIME=y,exports.MAX_BRIEF_FILES=12,exports.NOTIFY_CUSTOM_TYPE=l;
5
+ //# sourceMappingURL=manager.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.cjs","names":["path","createProtocolRuntime","DelegationAccepted","DelegationStarted","DelegationUpdated","DelegationFinished","TASK_EVENT","reconcileOrphanedDelegations","randomUUID","isDelegationActive","isBlocked","DelegationRequested","DelegationCancelled","isTaskListComplete"],"sources":["../../src/delegation/manager.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport path from 'node:path';\nimport {\n DelegationAccepted,\n DelegationCancelled,\n DelegationFinished,\n DelegationRequested,\n DelegationStarted,\n DelegationUpdated,\n type DelegationAccepted as DelegationAcceptedPayload,\n type DelegationResult,\n type DelegationStarted as DelegationStartedPayload,\n type DelegationUpdate,\n} from '@agimon-ai/doompi-extension-contracts/delegation';\nimport {\n createProtocolRuntime,\n type EventBusLike,\n type ProtocolRuntime,\n} from '@agimon-ai/doompi-extension-contracts/protocol';\nimport type { InlineAgent } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\nimport { TASK_EVENT, type TaskEventName, type TaskFailureReporter } from '../logSinkTelemetry.ts';\nimport { reconcileOrphanedDelegations } from '../store/reconcile.ts';\nimport { isBlocked, isTaskListComplete } from '../store/taskGraph.ts';\nimport type { TaskStore } from '../store/taskStore.ts';\nimport { isDelegationActive, type Task, type TaskDelegation, type TaskDocument } from '../store/types.ts';\n\nexport const NOTIFY_CUSTOM_TYPE = 'doom-task-notify';\nexport const BACKGROUND_WORK_PROVIDER = 'doom-task';\n\nconst DEFAULT_STARTED_TIMEOUT_MS = 5000;\nconst DEFAULT_RUN_TIMEOUT_MS = 20 * 60 * 1000;\nconst DEFAULT_CANCEL_TIMEOUT_MS = 10_000;\nconst MAX_RUN_TIMEOUT_GRACE_MS = 60_000;\nconst MAX_STORED_OUTPUT = 4000;\n/**\n * Cap on files rendered into a brief. Exported so the tool schema can state the\n * same number to the model rather than restating it and drifting.\n */\nexport const MAX_BRIEF_FILES = 12;\nconst MAX_BRIEF_NOTES = 1500;\nconst COMPLETED_STATE = 'completed';\nconst FAILED_STATE = 'failed';\nconst CANCELLED_STATE = 'cancelled';\nconst TIMED_OUT_STATUS = 'timed_out';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REQUEST_ID_ATTRIBUTE = 'delegation.request_id';\n// `_name` suffix is load-bearing: the telemetry redactor drops string values\n// whose key has no safe meaning, and a bare `delegation.agent` is dropped.\nconst AGENT_ATTRIBUTE = 'delegation.agent_name';\nconst PID_ATTRIBUTE = 'delegation.pid';\nconst CONTEXT_PRESENT_ATTRIBUTE = 'delegation.context_present';\nconst CONTEXT_FILE_COUNT_ATTRIBUTE = 'delegation.context_file_count';\nconst CONTEXT_NOTES_LENGTH_ATTRIBUTE = 'delegation.context_notes_length';\nconst BRIEF_LENGTH_ATTRIBUTE = 'delegation.brief_length';\nconst TOOL_COUNT_ATTRIBUTE = 'delegation.tool_count';\nconst DURATION_MS_ATTRIBUTE = 'delegation.duration_ms';\nconst OUTCOME_ATTRIBUTE = 'delegation.outcome';\n\ntype SettlementState = typeof COMPLETED_STATE | typeof FAILED_STATE | typeof CANCELLED_STATE;\n\nexport const ERR_NO_RUNTIME =\n 'No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.';\nexport const ERR_CHILD_SESSION =\n 'assign is only available in the main session. Update this task directly instead of re-delegating it.';\nexport const ERR_CANCEL_UNACKNOWLEDGED = 'Subagent did not acknowledge the cancel request';\n\n/** Live progress from a running subagent. Kept in memory: persisting per-tool\n * ticks would rewrite the store file every second for no durable benefit. */\nexport interface DelegationProgress {\n agent: string;\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n /** Latest child-runtime duration baseline, excluding assignment wait. */\n durationMs?: number;\n /** Wall-clock time at which durationMs was observed or rebased. */\n durationObservedAt?: number;\n /** Assign-time context-pack shape, carried so the completion event can be\n * grouped by it without joining back to the assignment event. */\n contextFileCount?: number;\n contextNotesLength?: number;\n}\n\nexport interface DelegationNotifier {\n (\n message: { customType: string; content: string; display: boolean },\n options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn' },\n ): void;\n}\n\nexport interface DelegationManagerOptions {\n events: EventBusLike;\n store: TaskStore;\n cwd: string;\n notify?: DelegationNotifier;\n getSessionId?: () => string | undefined;\n env?: NodeJS.ProcessEnv;\n onChange?: () => void;\n startedTimeoutMs?: number;\n /** How long a started run may go without reporting a result. */\n runTimeoutMs?: number;\n /** How long to wait for a cancelled run to report back before forcing it. */\n cancelTimeoutMs?: number;\n now?: () => string;\n nowMs?: () => number;\n /** Called when a completion notification could not be delivered. */\n onNotifyError: (error: unknown, taskId: number) => void;\n /** Where other swallowed delegation failures go. */\n report?: TaskFailureReporter;\n}\n\nexport interface AssignOptions {\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** Paths the parent already located, rendered into the brief so the child\n * skips rediscovering them. */\n relevantFiles?: string[];\n /** Facts the parent already established, rendered into the brief so the child\n * does not re-derive them. */\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n signal?: AbortSignal;\n}\n\nexport interface DelegationOutcome {\n ok: boolean;\n message: string;\n}\n\n/** Result of the guarded store mutation that claims a task for delegation. */\ninterface AssignAttempt extends DelegationOutcome {\n task?: Task;\n}\n\nfunction truncate(value: string | undefined, limit = MAX_STORED_OUTPUT): string | undefined {\n if (!value) return undefined;\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n… (truncated)`;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The assign-time context pack, normalized once for the brief and the telemetry. */\ninterface BriefContext {\n files: string[];\n notes?: string;\n}\n\n/**\n * Render a supplied path the way the child will see it, from `cwd`.\n *\n * Existence is deliberately not checked: an fs probe here duplicates the read\n * the child performs anyway, and it cannot detect the failure that actually\n * matters — a path that exists but is no longer the right one.\n */\nfunction briefPath(entry: string, cwd: string): string {\n if (!path.isAbsolute(entry)) return path.normalize(entry);\n const relative = path.relative(cwd, entry);\n // Outside the run directory the original beats a `../../` chain.\n return relative && !relative.startsWith('..') ? relative : entry;\n}\n\nfunction briefContext(options: AssignOptions, cwd: string): BriefContext {\n const files = new Set<string>();\n for (const entry of options.relevantFiles ?? []) {\n if (files.size >= MAX_BRIEF_FILES) break;\n const normalized = briefPath(entry.trim(), cwd);\n if (normalized && normalized !== '.') files.add(normalized);\n }\n return { files: [...files], notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES) };\n}\n\n/**\n * Build the brief handed to the subagent.\n *\n * Doom Team owns the child tool surface and the parent owns the task record.\n * Keeping those responsibilities explicit prevents a child from attempting to\n * call a task tool that is not loaded in its runtime, while still giving it a\n * reliable path to ask the parent for a decision.\n *\n * The context pack is the parent's discovery handed over. Both lines are\n * omitted entirely when nothing was supplied: this brief is the child's whole\n * starting context, so an empty section header is pure token cost.\n */\nfunction buildBrief(task: Task, instructions: string | undefined, context: BriefContext): string {\n const sections = [`Task #${task.id}: ${task.subject}`];\n if (task.description) sections.push(task.description);\n if (instructions) sections.push(instructions);\n if (context.files.length > 0) {\n sections.push(`Start here (main already located these, the list may be incomplete): ${context.files.join(', ')}`);\n }\n if (context.notes) sections.push(`Already established by main, do not re-derive: ${context.notes}`);\n sections.push(\n 'Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.',\n );\n return sections.join('\\n\\n');\n}\n\n/**\n * Owns the lifecycle of tasks delegated to subagents.\n *\n * Delegation rides the Doom Team event bus rather than spawning\n * processes directly, so doom-task stays decoupled from the subagent runtime\n * and degrades to a clear error when that runtime is not loaded.\n *\n * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so\n * a delegation always has a deadline no matter which phase it is in. Losing\n * that pairing is what previously left tasks running forever.\n */\nexport class DelegationManager {\n private readonly options: DelegationManagerOptions;\n private readonly progress = new Map<string, DelegationProgress>();\n private readonly pendingTasks = new Map<string, number>();\n private readonly timers = new Map<string, NodeJS.Timeout>();\n private readonly subscriptions: Array<() => void> = [];\n private protocol: ProtocolRuntime | undefined;\n\n constructor(options: DelegationManagerOptions) {\n this.options = options;\n }\n\n private now(): string {\n return this.options.now?.() ?? new Date().toISOString();\n }\n\n private nowMs(): number {\n return this.options.nowMs?.() ?? Date.now();\n }\n\n private get env(): NodeJS.ProcessEnv {\n return this.options.env ?? process.env;\n }\n\n private get runTimeoutMs(): number {\n return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;\n }\n\n private report(event: TaskEventName, error: unknown, attributes?: Record<string, string | number | boolean>): void {\n this.options.report?.error(event, error, attributes);\n }\n\n /** True in a session that is itself a subagent child. */\n get isChildSession(): boolean {\n return Boolean(this.env.PI_SUBAGENT_CHILD);\n }\n\n /** Live progress for a task, for the overlay to render. */\n progressFor(task: Task): DelegationProgress | undefined {\n const requestId = task.delegation?.requestId;\n return requestId ? this.progress.get(requestId) : undefined;\n }\n\n /** Displayed runtime duration, rebased from the latest child observation. */\n static elapsedMs(progress: DelegationProgress, nowMs = Date.now()): number {\n const baseline = progress.durationMs ?? 0;\n const observedAt = progress.durationObservedAt ?? nowMs;\n return baseline + Math.max(0, nowMs - observedAt);\n }\n\n /** Idempotent: a session restart re-subscribes without stacking handlers. */\n start(): void {\n if (this.subscriptions.length > 0) return;\n const sessionId = this.options.getSessionId?.();\n if (!sessionId) return;\n this.protocol = createProtocolRuntime({\n bus: this.options.events,\n source: '@agimon-ai/doompi-task',\n sessionId,\n });\n this.subscriptions.push(\n this.protocol.onNotification(DelegationAccepted, (event) => {\n this.handleAccepted(event);\n }),\n this.protocol.onNotification(DelegationStarted, (event) => {\n this.handleStarted(event);\n }),\n this.protocol.onNotification(DelegationUpdated, (event) => {\n this.handleUpdate(event);\n }),\n this.protocol.onNotification(DelegationFinished, (event) => {\n void this.handleResponse(event).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });\n });\n }),\n );\n }\n\n /** Items still in flight, surfaced so auto-stop will not kill the harness. */\n listActiveWork(): Array<{ id: string; sessionId: string }> {\n const sessionId = this.options.getSessionId?.() ?? '';\n return [...this.pendingTasks.entries()].map(([requestId, taskId]) => ({\n id: `task-${taskId}:${requestId}`,\n sessionId,\n }));\n }\n\n /**\n * Return tasks nothing can finish to `pending`.\n *\n * The live request set is read inside the mutation so a delegation assigned\n * while the lock was contended is not mistaken for a leftover.\n */\n async reconcile(): Promise<Task[]> {\n const { value } = await this.options.store.mutate((document) => {\n const result = reconcileOrphanedDelegations(document, this.now(), undefined, {\n pid: process.pid,\n liveRequestIds: new Set(this.pendingTasks.keys()),\n });\n if (result.orphaned.length === 0) return { value: [] as Task[] };\n return { document: result.document, value: result.orphaned };\n });\n\n for (const task of value) {\n this.options.report?.warn(TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ''), {\n [TASK_ID_ATTRIBUTE]: task.id,\n ...(task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {}),\n ...(task.delegation?.pid === undefined ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }),\n });\n }\n\n if (value.length > 0) this.options.onChange?.();\n return value;\n }\n\n async assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome> {\n const agent = options.agent?.trim();\n if (!agent) return { ok: false, message: 'agent required for assign' };\n if (this.isChildSession) return { ok: false, message: ERR_CHILD_SESSION };\n if (options.signal?.aborted) return { ok: false, message: 'delegation cancelled before it started' };\n\n const requestId = randomUUID();\n const startedAt = this.now();\n const context = briefContext(options, this.options.cwd);\n\n const { value: outcome } = await this.options.store.mutate<AssignAttempt>((current) => {\n const index = current.tasks.findIndex((task) => task.id === taskId);\n if (index === -1) return { value: { ok: false, message: `#${taskId} not found` } };\n\n const task = current.tasks[index];\n if (task.status === DELETED_STATUS) return { value: { ok: false, message: `#${taskId} is deleted` } };\n if (task.status === COMPLETED_STATE) {\n return { value: { ok: false, message: `#${taskId} is already completed` } };\n }\n if (isDelegationActive(task)) {\n return { value: { ok: false, message: `#${taskId} is already delegated to ${task.delegation?.agent}` } };\n }\n if (isBlocked(current.tasks, task)) {\n const blockers = (task.blockedBy ?? []).map((id) => `#${id}`).join(', ');\n return { value: { ok: false, message: `#${taskId} is blocked by ${blockers}` } };\n }\n\n const delegation: TaskDelegation = {\n requestId,\n agent,\n state: 'requested',\n pid: process.pid,\n startedAt,\n ...(this.options.getSessionId?.() ? { sessionId: this.options.getSessionId!() } : {}),\n ...(options.model ? { model: options.model } : {}),\n };\n\n const tasks = [...current.tasks];\n tasks[index] = { ...task, owner: agent, updatedAt: startedAt, delegation };\n return {\n document: { ...current, tasks },\n value: { ok: true, message: '', task: tasks[index] },\n };\n });\n\n if (!outcome.ok || !outcome.task) return { ok: false, message: outcome.message };\n\n const contextNotesLength = context.notes?.length ?? 0;\n this.pendingTasks.set(requestId, taskId);\n this.progress.set(requestId, { agent, contextFileCount: context.files.length, contextNotesLength });\n this.armStartedTimeout(requestId);\n\n const request = {\n requestId,\n taskId,\n agent,\n ...(options.inlineAgent ? { inlineAgent: options.inlineAgent } : {}),\n prompt: buildBrief(outcome.task, options.instructions, context),\n ...(options.context ? { context: options.context } : {}),\n cwd: this.options.cwd,\n artifacts: true,\n timeoutMs: this.runTimeoutMs,\n runMode: 'detached' as const,\n teamTask: { id: String(outcome.task.id), subject: outcome.task.subject },\n ...(options.model ? { model: options.model } : {}),\n };\n\n try {\n if (!this.protocol) throw new Error(ERR_NO_RUNTIME);\n this.protocol.notify(DelegationRequested, request);\n } catch (error) {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n const detail = messageOf(error);\n await this.settle(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${detail}`,\n });\n return { ok: false, message: `Could not dispatch #${taskId} to ${agent}: ${detail}` };\n }\n\n // Emitted only after the notify succeeds, so it means \"a brief of this\n // shape actually went out\" rather than \"one was assembled\".\n this.options.report?.event(TASK_EVENT.delegationAssigned, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,\n [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length,\n });\n\n this.options.onChange?.();\n\n return {\n ok: true,\n message: `Delegated #${taskId} to ${agent} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end the turn and wait.`,\n };\n }\n\n async cancel(taskId: number): Promise<DelegationOutcome> {\n const document = this.options.store.read();\n const task = document.tasks.find((candidate) => candidate.id === taskId);\n if (!task) return { ok: false, message: `#${taskId} not found` };\n if (!task.delegation || !isDelegationActive(task)) {\n return { ok: false, message: `#${taskId} has no running delegation` };\n }\n\n const { requestId } = task.delegation;\n this.protocol?.notify(DelegationCancelled, { requestId });\n // Only this session can force the outcome; a delegation owned elsewhere\n // gets the request and nothing more.\n this.armCancelTimeout(requestId);\n return { ok: true, message: `Cancelling delegation for #${taskId} (${task.delegation.agent})` };\n }\n\n /** Settle without awaiting, reporting rather than dropping a failure. */\n private settleDetached(\n requestId: string,\n state: SettlementState,\n result: TaskDelegation['result'],\n event: TaskEventName = TASK_EVENT.delegationSettleFailed,\n ): void {\n void this.settle(requestId, state, result).catch((error: unknown) => {\n this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });\n });\n }\n\n /**\n * Fail a delegation that nobody acknowledged.\n *\n * The bus cannot be probed for listeners, so silence is the only available\n * signal that the subagents runtime is absent. Without this the task would\n * sit in `requested` forever.\n */\n private armStartedTimeout(requestId: string): void {\n this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {\n this.settleDetached(requestId, FAILED_STATE, { status: FAILED_STATE, error: ERR_NO_RUNTIME });\n });\n }\n\n /**\n * Bound a run that already started.\n *\n * The request carries the same budget, so in the normal case the runtime ends\n * the run itself and reports a richer result. The grace period biases toward\n * that answer; this timer only covers a runtime that goes silent, which is\n * precisely the case where no response event will ever arrive.\n */\n private armRunTimeout(requestId: string): void {\n const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);\n this.armTimer(requestId, this.runTimeoutMs + grace, () => {\n const taskId = this.pendingTasks.get(requestId);\n const agent = this.progress.get(requestId)?.agent;\n const error = new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);\n this.options.report?.warn(TASK_EVENT.delegationTimedOut, error, {\n ...(taskId === undefined ? {} : { [TASK_ID_ATTRIBUTE]: taskId }),\n [REQUEST_ID_ATTRIBUTE]: requestId,\n ...(agent ? { [AGENT_ATTRIBUTE]: agent } : {}),\n });\n this.protocol?.notify(DelegationCancelled, { requestId, reason: error.message });\n this.settleDetached(requestId, FAILED_STATE, { status: TIMED_OUT_STATUS, error: error.message });\n });\n }\n\n /**\n * Guarantee a cancel reaches a terminal state.\n *\n * Emitting the cancel event is a request, not an outcome: a runtime that has\n * already forgotten the request answers nothing at all. The window still\n * favours a real response, which carries the run's partial output.\n */\n private armCancelTimeout(requestId: string): void {\n if (!this.pendingTasks.has(requestId)) return;\n this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {\n this.settleDetached(requestId, CANCELLED_STATE, {\n status: CANCELLED_STATE,\n error: ERR_CANCEL_UNACKNOWLEDGED,\n });\n });\n }\n\n private armTimer(requestId: string, delayMs: number, onFire: () => void): void {\n this.clearTimer(requestId);\n const timer = setTimeout(onFire, delayMs);\n timer.unref?.();\n this.timers.set(requestId, timer);\n }\n\n private clearTimer(requestId: string): void {\n const timer = this.timers.get(requestId);\n if (timer) clearTimeout(timer);\n this.timers.delete(requestId);\n }\n\n /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */\n private handleAccepted(event: DelegationAcceptedPayload): void {\n if (!this.pendingTasks.has(event.requestId)) return;\n this.armRunTimeout(event.requestId);\n }\n\n private handleStarted(event: DelegationStartedPayload): void {\n const { runId } = event;\n const taskId = this.pendingTasks.get(event.requestId);\n if (taskId === undefined) return;\n this.armRunTimeout(event.requestId);\n const existing = this.progress.get(event.requestId);\n if (existing) {\n this.progress.set(event.requestId, {\n ...existing,\n durationMs: existing.durationMs ?? 0,\n durationObservedAt: existing.durationObservedAt ?? this.nowMs(),\n });\n }\n\n void this.options.store\n .mutate((document) =>\n this.patchDelegation(document, event.requestId, (task, delegation) => ({\n ...task,\n status: task.status === COMPLETED_STATE ? task.status : 'in_progress',\n delegation: {\n ...delegation,\n state: 'running',\n startedAt: delegation.startedAt ?? this.now(),\n ...(runId ? { runId } : {}),\n },\n })),\n )\n .then(() => this.options.onChange?.())\n .catch((error: unknown) => {\n this.report(TASK_EVENT.delegationStartFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: event.requestId,\n });\n });\n }\n\n private handleUpdate(event: DelegationUpdate): void {\n const existing = this.progress.get(event.requestId);\n if (!existing) return;\n\n const observedAt = this.nowMs();\n const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);\n const hasDuration = event.durationMs !== undefined;\n this.progress.set(event.requestId, {\n // Spread, not field-by-field: anything carried on progress that this\n // event does not report (the assign-time context shape) must survive the\n // first update, or the completion event reports it as absent.\n ...existing,\n currentTool: event.currentTool ?? existing.currentTool,\n toolCount:\n event.toolCount === undefined ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),\n tokens: event.tokens === undefined ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),\n durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs!) : existing.durationMs,\n durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt,\n });\n this.options.onChange?.();\n }\n\n private async handleResponse(event: DelegationResult): Promise<void> {\n if (!this.pendingTasks.has(event.requestId)) return;\n\n const succeeded = event.status === COMPLETED_STATE && !event.error;\n const state = succeeded ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;\n await this.settle(event.requestId, state, {\n status: event.status,\n error: event.error,\n output: truncate(event.output),\n outputPath: event.outputPath,\n sessionFile: event.sessionFile,\n durationMs: event.durationMs,\n toolCount: event.toolCount,\n });\n }\n\n /**\n * Apply the terminal state of a delegation and tell the model about it.\n *\n * A cancelled run returns the task to `pending` (the work is still wanted,\n * just not by that agent); a failure marks it `failed` so it stays visible\n * rather than silently rejoining the backlog.\n *\n * Dropping the pending entry first makes this single-shot: a response racing\n * the watchdog cannot settle the same run twice. A failed write therefore\n * must not abort the rest — the model still gets told, the run stops counting\n * as active work, and `reconcile` repairs the file at the next session start.\n */\n private async settle(requestId: string, state: SettlementState, result: TaskDelegation['result']): Promise<void> {\n const taskId = this.pendingTasks.get(requestId);\n if (taskId === undefined) return;\n this.pendingTasks.delete(requestId);\n this.clearTimer(requestId);\n const progress = this.progress.get(requestId);\n this.progress.delete(requestId);\n\n const endedAt = this.now();\n let task: Task | undefined;\n try {\n const { value } = await this.options.store.mutate((document) =>\n this.patchDelegation(document, requestId, (current, delegation) => ({\n ...current,\n status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? 'pending' : FAILED_STATE,\n updatedAt: endedAt,\n delegation: { ...delegation, state, endedAt, ...(result ? { result } : {}) },\n })),\n );\n task = value;\n } catch (error) {\n this.report(TASK_EVENT.delegationSettleFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n });\n }\n\n this.options.onChange?.();\n\n const agent = task?.delegation?.agent ?? progress?.agent ?? 'subagent';\n const subject = task?.subject ?? `#${taskId}`;\n\n // Repeats the assign-time context shape so the cost question (\"did packs\n // reduce child tool calls?\") is one grouping rather than a self-join.\n // A run that never started reports neither metric, keeping the medians clean.\n this.options.report?.event(TASK_EVENT.delegationCompleted, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [OUTCOME_ATTRIBUTE]: state,\n [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,\n ...(result?.toolCount === undefined ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount }),\n ...(result?.durationMs === undefined ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }),\n });\n const listComplete =\n state === COMPLETED_STATE && task !== undefined && isTaskListComplete(this.options.store.snapshot.tasks);\n this.notifyModel(state, taskId, subject, agent, result, listComplete);\n }\n\n private notifyModel(\n state: SettlementState,\n taskId: number,\n subject: string,\n agent: string,\n result: TaskDelegation['result'],\n listComplete: boolean,\n ): void {\n const notify = this.options.notify;\n if (!notify) return;\n\n const headline =\n state === COMPLETED_STATE\n ? `Subagent ${agent} completed task #${taskId}: ${subject}`\n : state === CANCELLED_STATE\n ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)`\n : `Subagent ${agent} failed task #${taskId}: ${subject}`;\n\n const lines = [headline];\n if (listComplete) {\n lines.push(\n '',\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.',\n );\n }\n if (result?.error) lines.push(`Error: ${result.error}`);\n if (result?.output) lines.push('', result.output);\n if (result?.outputPath) lines.push('', `Full output: ${result.outputPath}`);\n\n try {\n notify(\n { customType: NOTIFY_CUSTOM_TYPE, content: lines.join('\\n'), display: true },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n } catch (error) {\n // The delegation state is already committed to the store, so a failed\n // notification costs the model its wake-up, not the result. Report it\n // rather than rethrowing, which would strand the settled run.\n this.options.onNotifyError(error, taskId);\n }\n }\n\n /**\n * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.\n *\n * Terminal delegations are left alone. The document here is the freshest one,\n * read under the store lock, which is the only place the check is meaningful:\n * a `started` event can land after a cancel already settled the run, and\n * without this guard its write would resurrect a delegation that nothing is\n * tracking any more.\n */\n private patchDelegation(\n document: TaskDocument,\n requestId: string,\n patch: (task: Task, delegation: TaskDelegation) => Task,\n ): { document?: TaskDocument; value: Task | undefined } {\n const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);\n if (index === -1) return { value: undefined };\n\n const task = document.tasks[index];\n if (!isDelegationActive(task)) return { value: task };\n\n const updated = patch(task, task.delegation!);\n if (updated === task) return { value: task };\n const tasks = [...document.tasks];\n tasks[index] = updated;\n return { document: { ...document, tasks }, value: updated };\n }\n\n dispose(): void {\n for (const unsubscribe of this.subscriptions) unsubscribe();\n this.subscriptions.length = 0;\n this.protocol = undefined;\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pendingTasks.clear();\n this.progress.clear();\n }\n}\n"],"mappings":"wcA0BA,MAAa,EAAqB,mBAc5B,EAAkB,YAClB,EAAe,SACf,EAAkB,YAIlB,EAAoB,UACpB,EAAuB,wBAGvB,EAAkB,wBAElB,EAA4B,6BAC5B,EAA+B,gCAC/B,EAAiC,kCAQ1B,EACX,kHACW,EACX,uGACW,EAA4B,kDAwEzC,SAAS,EAAS,EAA2B,EAAQ,IAAuC,CACrF,KACL,OAAO,EAAM,QAAU,EAAQ,EAAQ,GAAG,EAAM,MAAM,EAAG,CAAK,EAAE,gBAClE,CAEA,SAAS,EAAU,EAAwB,CACzC,OAAO,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAC9D,CAeA,SAAS,EAAU,EAAe,EAAqB,CACrD,GAAI,CAACA,EAAAA,QAAK,WAAW,CAAK,EAAG,OAAOA,EAAAA,QAAK,UAAU,CAAK,EACxD,IAAM,EAAWA,EAAAA,QAAK,SAAS,EAAK,CAAK,EAEzC,OAAO,GAAY,CAAC,EAAS,WAAW,IAAI,EAAI,EAAW,CAC7D,CAEA,SAAS,EAAa,EA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M,MAAO,CAAE,MAAO,CAAK,EAC3C,IAAM,EAAQ,CAAC,GAAG,EAAS,KAAK,EAEhC,MADA,GAAM,GAAS,EACR,CAAE,SAAU,CAAE,GAAG,EAAU,OAAM,EAAG,MAAO,CAAQ,CAC5D,CAEA,SAAgB,CACd,IAAK,IAAM,KAAe,KAAK,cAAe,EAAY,EAC1D,KAAK,cAAc,OAAS,EAC5B,KAAK,SAAW,IAAA,GAChB,IAAK,IAAM,KAAS,KAAK,OAAO,OAAO,EAAG,aAAa,CAAK,EAC5D,KAAK,OAAO,MAAM,EAClB,KAAK,aAAa,MAAM,EACxB,KAAK,SAAS,MAAM,CACtB,CACF"}
@@ -0,0 +1,189 @@
1
+ import { TaskFailureReporter } from "../logSinkTelemetry.cjs";
2
+ import { Task } from "../store/types.cjs";
3
+ import { TaskStore } from "../store/taskStore.cjs";
4
+ import { InlineAgent } from "@agimon-ai/doompi-extension-contracts/subagent-tool";
5
+ import { EventBusLike } from "@agimon-ai/doompi-extension-contracts/protocol";
6
+ //#region src/delegation/manager.d.ts
7
+ declare const NOTIFY_CUSTOM_TYPE = "doom-task-notify";
8
+ declare const BACKGROUND_WORK_PROVIDER = "doom-task";
9
+ /**
10
+ * Cap on files rendered into a brief. Exported so the tool schema can state the
11
+ * same number to the model rather than restating it and drifting.
12
+ */
13
+ declare const MAX_BRIEF_FILES = 12;
14
+ declare const ERR_NO_RUNTIME = "No subagent runtime responded. Delegation needs the subagents extension — relaunch doom-pi with agents enabled.";
15
+ declare const ERR_CHILD_SESSION = "assign is only available in the main session. Update this task directly instead of re-delegating it.";
16
+ declare const ERR_CANCEL_UNACKNOWLEDGED = "Subagent did not acknowledge the cancel request";
17
+ /** Live progress from a running subagent. Kept in memory: persisting per-tool
18
+ * ticks would rewrite the store file every second for no durable benefit. */
19
+ interface DelegationProgress {
20
+ agent: string;
21
+ currentTool?: string;
22
+ toolCount?: number;
23
+ tokens?: number;
24
+ /** Latest child-runtime duration baseline, excluding assignment wait. */
25
+ durationMs?: number;
26
+ /** Wall-clock time at which durationMs was observed or rebased. */
27
+ durationObservedAt?: number;
28
+ /** Assign-time context-pack shape, carried so the completion event can be
29
+ * grouped by it without joining back to the assignment event. */
30
+ contextFileCount?: number;
31
+ contextNotesLength?: number;
32
+ }
33
+ interface DelegationNotifier {
34
+ (message: {
35
+ customType: string;
36
+ content: string;
37
+ display: boolean;
38
+ }, options?: {
39
+ triggerTurn?: boolean;
40
+ deliverAs?: 'steer' | 'followUp' | 'nextTurn';
41
+ }): void;
42
+ }
43
+ interface DelegationManagerOptions {
44
+ events: EventBusLike;
45
+ store: TaskStore;
46
+ cwd: string;
47
+ notify?: DelegationNotifier;
48
+ getSessionId?: () => string | undefined;
49
+ env?: NodeJS.ProcessEnv;
50
+ onChange?: () => void;
51
+ startedTimeoutMs?: number;
52
+ /** How long a started run may go without reporting a result. */
53
+ runTimeoutMs?: number;
54
+ /** How long to wait for a cancelled run to report back before forcing it. */
55
+ cancelTimeoutMs?: number;
56
+ now?: () => string;
57
+ nowMs?: () => number;
58
+ /** Called when a completion notification could not be delivered. */
59
+ onNotifyError: (error: unknown, taskId: number) => void;
60
+ /** Where other swallowed delegation failures go. */
61
+ report?: TaskFailureReporter;
62
+ }
63
+ interface AssignOptions {
64
+ agent?: string;
65
+ inlineAgent?: InlineAgent;
66
+ instructions?: string;
67
+ /** Paths the parent already located, rendered into the brief so the child
68
+ * skips rediscovering them. */
69
+ relevantFiles?: string[];
70
+ /** Facts the parent already established, rendered into the brief so the child
71
+ * does not re-derive them. */
72
+ priorFindings?: string;
73
+ model?: string;
74
+ context?: 'fresh' | 'fork';
75
+ signal?: AbortSignal;
76
+ }
77
+ interface DelegationOutcome {
78
+ ok: boolean;
79
+ message: string;
80
+ }
81
+ /**
82
+ * Owns the lifecycle of tasks delegated to subagents.
83
+ *
84
+ * Delegation rides the Doom Team event bus rather than spawning
85
+ * processes directly, so doom-task stays decoupled from the subagent runtime
86
+ * and degrades to a clear error when that runtime is not loaded.
87
+ *
88
+ * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so
89
+ * a delegation always has a deadline no matter which phase it is in. Losing
90
+ * that pairing is what previously left tasks running forever.
91
+ */
92
+ declare class DelegationManager {
93
+ private readonly options;
94
+ private readonly progress;
95
+ private readonly pendingTasks;
96
+ private readonly timers;
97
+ private readonly subscriptions;
98
+ private protocol;
99
+ constructor(options: DelegationManagerOptions);
100
+ private now;
101
+ private nowMs;
102
+ private get env();
103
+ private get runTimeoutMs();
104
+ private report;
105
+ /** True in a session that is itself a subagent child. */
106
+ get isChildSession(): boolean;
107
+ /** Live progress for a task, for the overlay to render. */
108
+ progressFor(task: Task): DelegationProgress | undefined;
109
+ /** Displayed runtime duration, rebased from the latest child observation. */
110
+ static elapsedMs(progress: DelegationProgress, nowMs?: number): number;
111
+ /** Idempotent: a session restart re-subscribes without stacking handlers. */
112
+ start(): void;
113
+ /** Items still in flight, surfaced so auto-stop will not kill the harness. */
114
+ listActiveWork(): Array<{
115
+ id: string;
116
+ sessionId: string;
117
+ }>;
118
+ /**
119
+ * Return tasks nothing can finish to `pending`.
120
+ *
121
+ * The live request set is read inside the mutation so a delegation assigned
122
+ * while the lock was contended is not mistaken for a leftover.
123
+ */
124
+ reconcile(): Promise<Task[]>;
125
+ assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome>;
126
+ cancel(taskId: number): Promise<DelegationOutcome>;
127
+ /** Settle without awaiting, reporting rather than dropping a failure. */
128
+ private settleDetached;
129
+ /**
130
+ * Fail a delegation that nobody acknowledged.
131
+ *
132
+ * The bus cannot be probed for listeners, so silence is the only available
133
+ * signal that the subagents runtime is absent. Without this the task would
134
+ * sit in `requested` forever.
135
+ */
136
+ private armStartedTimeout;
137
+ /**
138
+ * Bound a run that already started.
139
+ *
140
+ * The request carries the same budget, so in the normal case the runtime ends
141
+ * the run itself and reports a richer result. The grace period biases toward
142
+ * that answer; this timer only covers a runtime that goes silent, which is
143
+ * precisely the case where no response event will ever arrive.
144
+ */
145
+ private armRunTimeout;
146
+ /**
147
+ * Guarantee a cancel reaches a terminal state.
148
+ *
149
+ * Emitting the cancel event is a request, not an outcome: a runtime that has
150
+ * already forgotten the request answers nothing at all. The window still
151
+ * favours a real response, which carries the run's partial output.
152
+ */
153
+ private armCancelTimeout;
154
+ private armTimer;
155
+ private clearTimer;
156
+ /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */
157
+ private handleAccepted;
158
+ private handleStarted;
159
+ private handleUpdate;
160
+ private handleResponse;
161
+ /**
162
+ * Apply the terminal state of a delegation and tell the model about it.
163
+ *
164
+ * A cancelled run returns the task to `pending` (the work is still wanted,
165
+ * just not by that agent); a failure marks it `failed` so it stays visible
166
+ * rather than silently rejoining the backlog.
167
+ *
168
+ * Dropping the pending entry first makes this single-shot: a response racing
169
+ * the watchdog cannot settle the same run twice. A failed write therefore
170
+ * must not abort the rest — the model still gets told, the run stops counting
171
+ * as active work, and `reconcile` repairs the file at the next session start.
172
+ */
173
+ private settle;
174
+ private notifyModel;
175
+ /**
176
+ * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.
177
+ *
178
+ * Terminal delegations are left alone. The document here is the freshest one,
179
+ * read under the store lock, which is the only place the check is meaningful:
180
+ * a `started` event can land after a cancel already settled the run, and
181
+ * without this guard its write would resurrect a delegation that nothing is
182
+ * tracking any more.
183
+ */
184
+ private patchDelegation;
185
+ dispose(): void;
186
+ }
187
+ //#endregion
188
+ export { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE };
189
+ //# sourceMappingURL=manager.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.cts","names":[],"sources":["../../src/delegation/manager.ts"],"mappings":";;;;;;cA0Ba;cACA;;;;;cAWA;cAwBA;cAEA;cAEA;;;UAII;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;;EAGA;EACA;;UAGe;GAEb;IAAW;IAAoB;IAAiB;KAChD;IAAY;IAAuB;;;UAItB;EACf,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT;EACA,MAAM,OAAO;EACb;EACA;;EAEA;;EAEA;EACA;EACA;;EAEA,gBAAgB,gBAAgB;;EAEhC,SAAS;;UAGM;EACf;EACA,cAAc;EACd;;;EAGA;;;EAGA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;;;;;;;;;;;;;cAoFW;mBACM;mBACA;mBACA;mBACA;mBACA;UACT;EAEI,YAAA,SAAS;UAIb;UAIA;cAII;cAIA;UAIJ;;MAKJ;;EAKJ,YAAY,MAAM,OAAO;;SAMlB,UAAU,UAAU,oBAAoB;;EAO/C;;EA4BA,kBAAkB;IAAQ;IAAY;;;;;;;;EAchC,aAAa,QAAQ;EAsBrB,OAAO,gBAAgB,SAAS,gBAAgB,QAAQ;EAwGxD,OAAO,iBAAiB,QAAQ;;UAiB9B;;;;;;;;UAkBA;;;;;;;;;UAcA;;;;;;;;UAuBA;UAUA;UAOA;;UAOA;UAKA;UAoCA;UAsBM;;;;;;;;;;;;;UA4BA;UAmDN;;;;;;;;;;UAmDA;EAkBR"}