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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/dist/adapters/pi/extension.cjs +3 -0
  2. package/dist/adapters/pi/extension.cjs.map +1 -0
  3. package/dist/adapters/pi/extension.d.cts +12 -0
  4. package/dist/adapters/pi/extension.d.cts.map +1 -0
  5. package/dist/adapters/pi/extension.d.mts +12 -0
  6. package/dist/adapters/pi/extension.d.mts.map +1 -0
  7. package/dist/adapters/pi/extension.mjs +3 -0
  8. package/dist/adapters/pi/extension.mjs.map +1 -0
  9. package/dist/adapters/store/paths.cjs +2 -0
  10. package/dist/adapters/store/paths.cjs.map +1 -0
  11. package/dist/adapters/store/paths.d.cts +26 -0
  12. package/dist/adapters/store/paths.d.cts.map +1 -0
  13. package/dist/adapters/store/paths.d.mts +26 -0
  14. package/dist/adapters/store/paths.d.mts.map +1 -0
  15. package/dist/adapters/store/paths.mjs +2 -0
  16. package/dist/adapters/store/paths.mjs.map +1 -0
  17. package/dist/adapters/store/taskStore.cjs +2 -0
  18. package/dist/adapters/store/taskStore.cjs.map +1 -0
  19. package/dist/adapters/store/taskStore.d.cts +87 -0
  20. package/dist/adapters/store/taskStore.d.cts.map +1 -0
  21. package/dist/adapters/store/taskStore.d.mts +87 -0
  22. package/dist/adapters/store/taskStore.d.mts.map +1 -0
  23. package/dist/adapters/store/taskStore.mjs +2 -0
  24. package/dist/adapters/store/taskStore.mjs.map +1 -0
  25. package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
  26. package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
  27. package/dist/adapters/telemetry/logSinkTelemetry.d.cts +52 -0
  28. package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
  29. package/dist/adapters/telemetry/logSinkTelemetry.d.mts +52 -0
  30. package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
  31. package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
  32. package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
  33. package/dist/commands/index.cjs +2 -0
  34. package/dist/commands/index.cjs.map +1 -0
  35. package/dist/commands/index.d.cts +15 -0
  36. package/dist/commands/index.d.cts.map +1 -0
  37. package/dist/commands/index.d.mts +15 -0
  38. package/dist/commands/index.d.mts.map +1 -0
  39. package/dist/commands/index.mjs +2 -0
  40. package/dist/commands/index.mjs.map +1 -0
  41. package/dist/commands/task/promptGuidelines.cjs +2 -0
  42. package/dist/commands/task/promptGuidelines.cjs.map +1 -0
  43. package/dist/commands/task/promptGuidelines.d.cts +5 -0
  44. package/dist/commands/task/promptGuidelines.d.cts.map +1 -0
  45. package/dist/commands/task/promptGuidelines.d.mts +5 -0
  46. package/dist/commands/task/promptGuidelines.d.mts.map +1 -0
  47. package/dist/commands/task/promptGuidelines.mjs +2 -0
  48. package/dist/commands/task/promptGuidelines.mjs.map +1 -0
  49. package/dist/commands/task/responseEnvelope.cjs +6 -0
  50. package/dist/commands/task/responseEnvelope.cjs.map +1 -0
  51. package/dist/commands/task/responseEnvelope.d.cts +39 -0
  52. package/dist/commands/task/responseEnvelope.d.cts.map +1 -0
  53. package/dist/commands/task/responseEnvelope.d.mts +39 -0
  54. package/dist/commands/task/responseEnvelope.d.mts.map +1 -0
  55. package/dist/commands/task/responseEnvelope.mjs +6 -0
  56. package/dist/commands/task/responseEnvelope.mjs.map +1 -0
  57. package/dist/commands/task/taskTool.cjs +3 -0
  58. package/dist/commands/task/taskTool.cjs.map +1 -0
  59. package/dist/commands/task/taskTool.d.cts +18 -0
  60. package/dist/commands/task/taskTool.d.cts.map +1 -0
  61. package/dist/commands/task/taskTool.d.mts +18 -0
  62. package/dist/commands/task/taskTool.d.mts.map +1 -0
  63. package/dist/commands/task/taskTool.mjs +3 -0
  64. package/dist/commands/task/taskTool.mjs.map +1 -0
  65. package/dist/commands.cjs +1 -2
  66. package/dist/commands.d.cts +2 -14
  67. package/dist/commands.d.mts +2 -14
  68. package/dist/commands.mjs +1 -2
  69. package/dist/config.cjs +1 -2
  70. package/dist/config.d.cts +2 -38
  71. package/dist/config.d.mts +2 -38
  72. package/dist/config.mjs +1 -2
  73. package/dist/delegation/manager.cjs +1 -5
  74. package/dist/delegation/manager.d.cts +2 -189
  75. package/dist/delegation/manager.d.mts +2 -189
  76. package/dist/delegation/manager.mjs +1 -5
  77. package/dist/extension.cjs +1 -3
  78. package/dist/extension.d.cts +2 -12
  79. package/dist/extension.d.mts +2 -12
  80. package/dist/extension.mjs +1 -3
  81. package/dist/extensions/doom.cjs +1 -1
  82. package/dist/extensions/doom.cjs.map +1 -1
  83. package/dist/extensions/doom.mjs +1 -1
  84. package/dist/extensions/doom.mjs.map +1 -1
  85. package/dist/extensions/pi.cjs +1 -1
  86. package/dist/extensions/pi.cjs.map +1 -1
  87. package/dist/extensions/pi.d.cts +1 -1
  88. package/dist/extensions/pi.d.mts +1 -1
  89. package/dist/extensions/pi.mjs +1 -1
  90. package/dist/extensions/pi.mjs.map +1 -1
  91. package/dist/index.cjs +1 -1
  92. package/dist/index.d.cts +16 -15
  93. package/dist/index.d.mts +16 -15
  94. package/dist/index.mjs +1 -1
  95. package/dist/logSinkTelemetry.cjs +1 -2
  96. package/dist/logSinkTelemetry.d.cts +2 -51
  97. package/dist/logSinkTelemetry.d.mts +2 -51
  98. package/dist/logSinkTelemetry.mjs +1 -2
  99. package/dist/schemas/task.cjs +2 -0
  100. package/dist/schemas/task.cjs.map +1 -0
  101. package/dist/schemas/task.d.cts +86 -0
  102. package/dist/schemas/task.d.cts.map +1 -0
  103. package/dist/schemas/task.d.mts +86 -0
  104. package/dist/schemas/task.d.mts.map +1 -0
  105. package/dist/schemas/task.mjs +2 -0
  106. package/dist/schemas/task.mjs.map +1 -0
  107. package/dist/services/delegation/manager.cjs +6 -0
  108. package/dist/services/delegation/manager.cjs.map +1 -0
  109. package/dist/services/delegation/manager.d.cts +188 -0
  110. package/dist/services/delegation/manager.d.cts.map +1 -0
  111. package/dist/services/delegation/manager.d.mts +188 -0
  112. package/dist/services/delegation/manager.d.mts.map +1 -0
  113. package/dist/services/delegation/manager.mjs +6 -0
  114. package/dist/services/delegation/manager.mjs.map +1 -0
  115. package/dist/services/narration/taskNarration.cjs +2 -0
  116. package/dist/services/narration/taskNarration.cjs.map +1 -0
  117. package/dist/services/narration/taskNarration.mjs +2 -0
  118. package/dist/services/narration/taskNarration.mjs.map +1 -0
  119. package/dist/services/store/invariants.cjs +2 -0
  120. package/dist/services/store/invariants.cjs.map +1 -0
  121. package/dist/services/store/invariants.d.cts +14 -0
  122. package/dist/services/store/invariants.d.cts.map +1 -0
  123. package/dist/services/store/invariants.d.mts +14 -0
  124. package/dist/services/store/invariants.d.mts.map +1 -0
  125. package/dist/services/store/invariants.mjs +2 -0
  126. package/dist/services/store/invariants.mjs.map +1 -0
  127. package/dist/services/store/paths.cjs +1 -0
  128. package/dist/services/store/paths.mjs +1 -0
  129. package/dist/services/store/processLiveness.cjs +2 -0
  130. package/dist/services/store/processLiveness.cjs.map +1 -0
  131. package/dist/services/store/processLiveness.d.cts +12 -0
  132. package/dist/services/store/processLiveness.d.cts.map +1 -0
  133. package/dist/services/store/processLiveness.d.mts +12 -0
  134. package/dist/services/store/processLiveness.d.mts.map +1 -0
  135. package/dist/services/store/processLiveness.mjs +2 -0
  136. package/dist/services/store/processLiveness.mjs.map +1 -0
  137. package/dist/services/store/reconcile.cjs +2 -0
  138. package/dist/services/store/reconcile.cjs.map +1 -0
  139. package/dist/services/store/reconcile.d.cts +34 -0
  140. package/dist/services/store/reconcile.d.cts.map +1 -0
  141. package/dist/services/store/reconcile.d.mts +34 -0
  142. package/dist/services/store/reconcile.d.mts.map +1 -0
  143. package/dist/services/store/reconcile.mjs +2 -0
  144. package/dist/services/store/reconcile.mjs.map +1 -0
  145. package/dist/services/store/reducer.cjs +3 -0
  146. package/dist/services/store/reducer.cjs.map +1 -0
  147. package/dist/services/store/reducer.d.cts +72 -0
  148. package/dist/services/store/reducer.d.cts.map +1 -0
  149. package/dist/services/store/reducer.d.mts +72 -0
  150. package/dist/services/store/reducer.d.mts.map +1 -0
  151. package/dist/services/store/reducer.mjs +3 -0
  152. package/dist/services/store/reducer.mjs.map +1 -0
  153. package/dist/services/store/taskGraph.cjs +2 -0
  154. package/dist/services/store/taskGraph.cjs.map +1 -0
  155. package/dist/services/store/taskGraph.d.cts +25 -0
  156. package/dist/services/store/taskGraph.d.cts.map +1 -0
  157. package/dist/services/store/taskGraph.d.mts +25 -0
  158. package/dist/services/store/taskGraph.d.mts.map +1 -0
  159. package/dist/services/store/taskGraph.mjs +2 -0
  160. package/dist/services/store/taskGraph.mjs.map +1 -0
  161. package/dist/services/store/taskStore.cjs +1 -0
  162. package/dist/services/store/taskStore.d.cts +2 -0
  163. package/dist/services/store/taskStore.d.mts +2 -0
  164. package/dist/services/store/taskStore.mjs +1 -0
  165. package/dist/services/store/types.cjs +2 -0
  166. package/dist/services/store/types.cjs.map +1 -0
  167. package/dist/services/store/types.d.cts +165 -0
  168. package/dist/services/store/types.d.cts.map +1 -0
  169. package/dist/services/store/types.d.mts +165 -0
  170. package/dist/services/store/types.d.mts.map +1 -0
  171. package/dist/services/store/types.mjs +2 -0
  172. package/dist/services/store/types.mjs.map +1 -0
  173. package/dist/store/invariants.cjs +1 -2
  174. package/dist/store/invariants.d.cts +2 -14
  175. package/dist/store/invariants.d.mts +2 -14
  176. package/dist/store/invariants.mjs +1 -2
  177. package/dist/store/paths.cjs +1 -2
  178. package/dist/store/paths.d.cts +2 -23
  179. package/dist/store/paths.d.mts +2 -23
  180. package/dist/store/paths.mjs +1 -2
  181. package/dist/store/processLiveness.cjs +1 -2
  182. package/dist/store/processLiveness.d.cts +2 -12
  183. package/dist/store/processLiveness.d.mts +2 -12
  184. package/dist/store/processLiveness.mjs +1 -2
  185. package/dist/store/reconcile.cjs +1 -2
  186. package/dist/store/reconcile.d.cts +2 -34
  187. package/dist/store/reconcile.d.mts +2 -34
  188. package/dist/store/reconcile.mjs +1 -2
  189. package/dist/store/reducer.cjs +1 -3
  190. package/dist/store/reducer.d.cts +2 -72
  191. package/dist/store/reducer.d.mts +2 -72
  192. package/dist/store/reducer.mjs +1 -3
  193. package/dist/store/taskGraph.cjs +1 -2
  194. package/dist/store/taskGraph.d.cts +2 -25
  195. package/dist/store/taskGraph.d.mts +2 -25
  196. package/dist/store/taskGraph.mjs +1 -2
  197. package/dist/store/taskStore.cjs +1 -2
  198. package/dist/store/taskStore.d.cts +3 -77
  199. package/dist/store/taskStore.d.mts +3 -77
  200. package/dist/store/taskStore.mjs +1 -2
  201. package/dist/store/types.cjs +1 -2
  202. package/dist/store/types.d.cts +2 -165
  203. package/dist/store/types.d.mts +2 -165
  204. package/dist/store/types.mjs +1 -2
  205. package/dist/tool/promptGuidelines.cjs +1 -2
  206. package/dist/tool/promptGuidelines.d.cts +2 -5
  207. package/dist/tool/promptGuidelines.d.mts +2 -5
  208. package/dist/tool/promptGuidelines.mjs +1 -2
  209. package/dist/tool/responseEnvelope.cjs +1 -6
  210. package/dist/tool/responseEnvelope.d.cts +2 -39
  211. package/dist/tool/responseEnvelope.d.mts +2 -39
  212. package/dist/tool/responseEnvelope.mjs +1 -6
  213. package/dist/tool/schema.cjs +1 -2
  214. package/dist/tool/schema.d.cts +2 -86
  215. package/dist/tool/schema.d.mts +2 -86
  216. package/dist/tool/schema.mjs +1 -2
  217. package/dist/tool/taskTool.cjs +1 -3
  218. package/dist/tool/taskTool.d.cts +3 -17
  219. package/dist/tool/taskTool.d.mts +3 -17
  220. package/dist/tool/taskTool.mjs +1 -3
  221. package/dist/tui/format.cjs +3 -3
  222. package/dist/tui/format.cjs.map +1 -1
  223. package/dist/tui/format.d.cts +3 -3
  224. package/dist/tui/format.d.cts.map +1 -1
  225. package/dist/tui/format.d.mts +3 -3
  226. package/dist/tui/format.d.mts.map +1 -1
  227. package/dist/tui/format.mjs +3 -3
  228. package/dist/tui/format.mjs.map +1 -1
  229. package/dist/tui/selectors.cjs +1 -1
  230. package/dist/tui/selectors.cjs.map +1 -1
  231. package/dist/tui/selectors.d.cts +17 -9
  232. package/dist/tui/selectors.d.cts.map +1 -1
  233. package/dist/tui/selectors.d.mts +17 -9
  234. package/dist/tui/selectors.d.mts.map +1 -1
  235. package/dist/tui/selectors.mjs +1 -1
  236. package/dist/tui/selectors.mjs.map +1 -1
  237. package/dist/tui/taskOverlay.cjs +1 -1
  238. package/dist/tui/taskOverlay.cjs.map +1 -1
  239. package/dist/tui/taskOverlay.d.cts +2 -2
  240. package/dist/tui/taskOverlay.d.cts.map +1 -1
  241. package/dist/tui/taskOverlay.d.mts +2 -2
  242. package/dist/tui/taskOverlay.d.mts.map +1 -1
  243. package/dist/tui/taskOverlay.mjs +1 -1
  244. package/dist/tui/taskOverlay.mjs.map +1 -1
  245. package/dist/tui/taskSpace.cjs +1 -1
  246. package/dist/tui/taskSpace.cjs.map +1 -1
  247. package/dist/tui/taskSpace.d.cts +2 -1
  248. package/dist/tui/taskSpace.d.cts.map +1 -1
  249. package/dist/tui/taskSpace.d.mts +2 -1
  250. package/dist/tui/taskSpace.d.mts.map +1 -1
  251. package/dist/tui/taskSpace.mjs +1 -1
  252. package/dist/tui/taskSpace.mjs.map +1 -1
  253. package/dist/types/config.cjs +2 -0
  254. package/dist/types/config.cjs.map +1 -0
  255. package/dist/types/config.d.cts +38 -0
  256. package/dist/types/config.d.cts.map +1 -0
  257. package/dist/types/config.d.mts +38 -0
  258. package/dist/types/config.d.mts.map +1 -0
  259. package/dist/types/config.mjs +2 -0
  260. package/dist/types/config.mjs.map +1 -0
  261. package/package.json +4 -4
  262. package/dist/commands.cjs.map +0 -1
  263. package/dist/commands.d.cts.map +0 -1
  264. package/dist/commands.d.mts.map +0 -1
  265. package/dist/commands.mjs.map +0 -1
  266. package/dist/config.cjs.map +0 -1
  267. package/dist/config.d.cts.map +0 -1
  268. package/dist/config.d.mts.map +0 -1
  269. package/dist/config.mjs.map +0 -1
  270. package/dist/delegation/manager.cjs.map +0 -1
  271. package/dist/delegation/manager.d.cts.map +0 -1
  272. package/dist/delegation/manager.d.mts.map +0 -1
  273. package/dist/delegation/manager.mjs.map +0 -1
  274. package/dist/extension.cjs.map +0 -1
  275. package/dist/extension.d.cts.map +0 -1
  276. package/dist/extension.d.mts.map +0 -1
  277. package/dist/extension.mjs.map +0 -1
  278. package/dist/logSinkTelemetry.cjs.map +0 -1
  279. package/dist/logSinkTelemetry.d.cts.map +0 -1
  280. package/dist/logSinkTelemetry.d.mts.map +0 -1
  281. package/dist/logSinkTelemetry.mjs.map +0 -1
  282. package/dist/store/invariants.cjs.map +0 -1
  283. package/dist/store/invariants.d.cts.map +0 -1
  284. package/dist/store/invariants.d.mts.map +0 -1
  285. package/dist/store/invariants.mjs.map +0 -1
  286. package/dist/store/paths.cjs.map +0 -1
  287. package/dist/store/paths.d.cts.map +0 -1
  288. package/dist/store/paths.d.mts.map +0 -1
  289. package/dist/store/paths.mjs.map +0 -1
  290. package/dist/store/processLiveness.cjs.map +0 -1
  291. package/dist/store/processLiveness.d.cts.map +0 -1
  292. package/dist/store/processLiveness.d.mts.map +0 -1
  293. package/dist/store/processLiveness.mjs.map +0 -1
  294. package/dist/store/reconcile.cjs.map +0 -1
  295. package/dist/store/reconcile.d.cts.map +0 -1
  296. package/dist/store/reconcile.d.mts.map +0 -1
  297. package/dist/store/reconcile.mjs.map +0 -1
  298. package/dist/store/reducer.cjs.map +0 -1
  299. package/dist/store/reducer.d.cts.map +0 -1
  300. package/dist/store/reducer.d.mts.map +0 -1
  301. package/dist/store/reducer.mjs.map +0 -1
  302. package/dist/store/taskGraph.cjs.map +0 -1
  303. package/dist/store/taskGraph.d.cts.map +0 -1
  304. package/dist/store/taskGraph.d.mts.map +0 -1
  305. package/dist/store/taskGraph.mjs.map +0 -1
  306. package/dist/store/taskStore.cjs.map +0 -1
  307. package/dist/store/taskStore.d.cts.map +0 -1
  308. package/dist/store/taskStore.d.mts.map +0 -1
  309. package/dist/store/taskStore.mjs.map +0 -1
  310. package/dist/store/types.cjs.map +0 -1
  311. package/dist/store/types.d.cts.map +0 -1
  312. package/dist/store/types.d.mts.map +0 -1
  313. package/dist/store/types.mjs.map +0 -1
  314. package/dist/tool/promptGuidelines.cjs.map +0 -1
  315. package/dist/tool/promptGuidelines.d.cts.map +0 -1
  316. package/dist/tool/promptGuidelines.d.mts.map +0 -1
  317. package/dist/tool/promptGuidelines.mjs.map +0 -1
  318. package/dist/tool/responseEnvelope.cjs.map +0 -1
  319. package/dist/tool/responseEnvelope.d.cts.map +0 -1
  320. package/dist/tool/responseEnvelope.d.mts.map +0 -1
  321. package/dist/tool/responseEnvelope.mjs.map +0 -1
  322. package/dist/tool/schema.cjs.map +0 -1
  323. package/dist/tool/schema.d.cts.map +0 -1
  324. package/dist/tool/schema.d.mts.map +0 -1
  325. package/dist/tool/schema.mjs.map +0 -1
  326. package/dist/tool/taskTool.cjs.map +0 -1
  327. package/dist/tool/taskTool.d.cts.map +0 -1
  328. package/dist/tool/taskTool.d.mts.map +0 -1
  329. package/dist/tool/taskTool.mjs.map +0 -1
@@ -0,0 +1,165 @@
1
+ import { InlineAgent } from "@agimon-ai/doompi-extension-contracts/subagent-tool";
2
+ //#region src/services/store/types.d.ts
3
+ type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';
4
+ declare const DELETED_STATUS: TaskStatus;
5
+ type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';
6
+ type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';
7
+ /** Terminal result of a delegated subagent run, copied off the delegation response. */
8
+ interface DelegationResult {
9
+ status: string;
10
+ output?: string;
11
+ outputPath?: string;
12
+ sessionFile?: string;
13
+ error?: string;
14
+ durationMs?: number;
15
+ toolCount?: number;
16
+ }
17
+ /**
18
+ * Delegation bookkeeping attached to a task that was handed to a subagent.
19
+ *
20
+ * `pid` is the harness process that owns the run: it is the only way to tell an
21
+ * genuinely-running delegation from one orphaned by a harness crash, since the
22
+ * child dies with its parent but the file survives.
23
+ */
24
+ interface TaskDelegation {
25
+ requestId: string;
26
+ agent: string;
27
+ state: DelegationState;
28
+ sessionId?: string;
29
+ pid?: number;
30
+ runId?: string;
31
+ model?: string;
32
+ startedAt?: string;
33
+ endedAt?: string;
34
+ result?: DelegationResult;
35
+ }
36
+ interface Task {
37
+ id: number;
38
+ subject: string;
39
+ description?: string;
40
+ activeForm?: string;
41
+ status: TaskStatus;
42
+ blockedBy?: number[];
43
+ owner?: string;
44
+ metadata?: Record<string, unknown>;
45
+ createdAt?: string;
46
+ updatedAt?: string;
47
+ delegation?: TaskDelegation;
48
+ }
49
+ declare const STORE_SCHEMA_VERSION = 1;
50
+ /** The complete on-disk document. `rev` increments on every committed write. */
51
+ interface TaskDocument {
52
+ version: number;
53
+ rev: number;
54
+ nextId: number;
55
+ tasks: Task[];
56
+ }
57
+ declare function emptyDocument(): TaskDocument;
58
+ /**
59
+ * A dependency target inside an upsert item: an existing task id, or the `ref`
60
+ * of a task created earlier in the same call.
61
+ *
62
+ * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally
63
+ * unconfusable with a stringified id and the discrimination is just `typeof`.
64
+ */
65
+ type DepToken = number | string;
66
+ /**
67
+ * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.
68
+ *
69
+ * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`
70
+ * (additive merge) are update-only, matching the split the two former actions
71
+ * had. A field used against the wrong kind fails that item rather than being
72
+ * silently ignored.
73
+ */
74
+ interface TaskItemMutation {
75
+ id?: number;
76
+ ref?: string;
77
+ subject?: string;
78
+ description?: string;
79
+ activeForm?: string;
80
+ status?: TaskStatus;
81
+ blockedBy?: DepToken[];
82
+ addBlockedBy?: DepToken[];
83
+ removeBlockedBy?: DepToken[];
84
+ owner?: string;
85
+ metadata?: Record<string, unknown>;
86
+ }
87
+ /**
88
+ * What one upsert item did. `index` is its position in the request array, so a
89
+ * model reading a partial result can tell which entries still need resending.
90
+ *
91
+ * `message` is unprefixed: the `item[N] failed:` framing belongs to the
92
+ * formatter, because the Task Space overlay shows this text on its own.
93
+ */
94
+ type UpsertItemOutcome = {
95
+ index: number;
96
+ kind: 'created';
97
+ id: number;
98
+ subject: string;
99
+ status: TaskStatus;
100
+ ref?: string;
101
+ blockedBy?: number[];
102
+ } | {
103
+ index: number;
104
+ kind: 'updated';
105
+ id: number;
106
+ fromStatus: TaskStatus;
107
+ toStatus: TaskStatus;
108
+ } | {
109
+ index: number;
110
+ kind: 'unchanged';
111
+ id: number;
112
+ status: TaskStatus;
113
+ } | {
114
+ index: number;
115
+ kind: 'failed';
116
+ message: string;
117
+ id?: number;
118
+ ref?: string;
119
+ };
120
+ /** Which tasks an upsert touched, so renderResult names them instead of guessing. */
121
+ interface UpsertSummary {
122
+ /** Ids of applied entries, in request order. A failed entry contributes nothing. */
123
+ applied: number[];
124
+ failed: number;
125
+ }
126
+ /**
127
+ * Open-shape input bag the reducer accepts. The index signature lets the
128
+ * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without
129
+ * casting each field.
130
+ *
131
+ * Per-task fields live on `tasks[]`, not here: a top-level `subject` or
132
+ * `status` would be ambiguous once one call can carry many tasks.
133
+ */
134
+ interface TaskMutationParams {
135
+ [key: string]: unknown;
136
+ tasks?: TaskItemMutation[];
137
+ /** `list` filter only. To set a status, upsert the task by id. */
138
+ status?: TaskStatus;
139
+ /** `get`, `delete`, `assign` and `cancel` only. */
140
+ id?: number;
141
+ includeDeleted?: boolean;
142
+ agent?: string;
143
+ inlineAgent?: InlineAgent;
144
+ instructions?: string;
145
+ /** `assign` only: the context pack the parent hands to the child. */
146
+ relevantFiles?: string[];
147
+ priorFindings?: string;
148
+ model?: string;
149
+ context?: 'fresh' | 'fork';
150
+ }
151
+ /** Snapshot returned under a tool result's `details` for renderResult. */
152
+ interface TaskDetails {
153
+ action: TaskAction;
154
+ params: Record<string, unknown>;
155
+ tasks: Task[];
156
+ nextId: number;
157
+ rev: number;
158
+ error?: string;
159
+ upsert?: UpsertSummary;
160
+ }
161
+ /** A delegation is "live" while the owning run may still produce a response. */
162
+ declare function isDelegationActive(task: Task): boolean;
163
+ //#endregion
164
+ export { DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
165
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/services/store/types.ts"],"mappings":";;KAUY;cAEC,gBAAgB;KAEjB;KAEA;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAUe;EACf;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA;EACA,aAAa;;cAGF;;UAGI;EACf;EACA;EACA;EACA,OAAO;;iBAGO,iBAAiB;;;;;;;;KAWrB;;;;;;;;;UAUK;EACf;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,YAAY;EACZ,eAAe;EACf,kBAAkB;EAClB;EACA,WAAW;;;;;;;;;KAUD;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EAAe;EAAiB;EAAY,YAAY;EAAY,UAAU;;EAC9E;EAAe;EAAmB;EAAY,QAAQ;;EACtD;EAAe;EAAgB;EAAiB;EAAa;;;UAGlD;;EAEf;EACA;;;;;;;;;;UAWe;GACd;EACD,QAAQ;;EAER,SAAS;;EAET;EACA;EACA;EACA,cAAc;EACd;;EAEA;EACA;EACA;EACA;;;UAIe;EACf,QAAQ;EACR,QAAQ;EACR,OAAO;EACP;EACA;EACA;EACA,SAAS;;;iBAIK,mBAAmB,MAAM"}
@@ -0,0 +1,2 @@
1
+ const e=`deleted`,t=1;function n(){return{version:1,rev:0,nextId:1,tasks:[]}}function r(e){let t=e.delegation?.state;return t===`requested`||t===`running`}export{e as DELETED_STATUS,t as STORE_SCHEMA_VERSION,n as emptyDocument,r as isDelegationActive};
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../../../src/services/store/types.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/doompi-extension-contracts/subagent-tool';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`, `assign` and `cancel` only. */\n id?: number;\n includeDeleted?: boolean;\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** `assign` only: the context pack the parent hands to the child. */\n relevantFiles?: string[];\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n}\n\n/** Snapshot returned under a tool result's `details` for renderResult. */\nexport interface TaskDetails {\n action: TaskAction;\n params: Record<string, unknown>;\n tasks: Task[];\n nextId: number;\n rev: number;\n error?: string;\n upsert?: UpsertSummary;\n}\n\n/** A delegation is \"live\" while the owning run may still produce a response. */\nexport function isDelegationActive(task: Task): boolean {\n const state = task.delegation?.state;\n return state === 'requested' || state === 'running';\n}\n"],"mappings":"AAYA,MAAa,EAA6B,UAmD7B,EAAuB,EAUpC,SAAgB,GAA8B,CAC5C,MAAO,CAAE,QAAA,EAA+B,IAAK,EAAG,OAAQ,EAAG,MAAO,CAAC,CAAE,CACvE,CAmGA,SAAgB,EAAmB,EAAqB,CACtD,IAAM,EAAQ,EAAK,YAAY,MAC/B,OAAO,IAAU,aAAe,IAAU,SAC5C"}
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e={pending:new Set([`in_progress`,`completed`,`failed`,`deleted`]),in_progress:new Set([`pending`,`completed`,`failed`,`deleted`]),failed:new Set([`pending`,`in_progress`,`completed`,`deleted`]),completed:new Set([`deleted`]),deleted:new Set};function t(t,n){return t===n||e[t].has(n)}exports.VALID_TRANSITIONS=e,exports.isTransitionValid=t;
2
- //# sourceMappingURL=invariants.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/store/invariants.cjs");exports.VALID_TRANSITIONS=e.VALID_TRANSITIONS,exports.isTransitionValid=e.isTransitionValid;
@@ -1,14 +1,2 @@
1
- import { TaskStatus } from "./types.cjs";
2
- //#region src/store/invariants.d.ts
3
- /**
4
- * Allowed forward transitions per source status.
5
- *
6
- * `failed` is recoverable (a delegation can be retried) so it may return to
7
- * pending or in_progress. `completed` is one-way to `deleted`; `deleted` is a
8
- * terminal tombstone.
9
- */
10
- declare const VALID_TRANSITIONS: Record<TaskStatus, ReadonlySet<TaskStatus>>;
11
- declare function isTransitionValid(from: TaskStatus, to: TaskStatus): boolean;
12
- //#endregion
13
- export { VALID_TRANSITIONS, isTransitionValid };
14
- //# sourceMappingURL=invariants.d.cts.map
1
+ import { VALID_TRANSITIONS, isTransitionValid } from "../services/store/invariants.cjs";
2
+ export { VALID_TRANSITIONS, isTransitionValid };
@@ -1,14 +1,2 @@
1
- import { TaskStatus } from "./types.mjs";
2
- //#region src/store/invariants.d.ts
3
- /**
4
- * Allowed forward transitions per source status.
5
- *
6
- * `failed` is recoverable (a delegation can be retried) so it may return to
7
- * pending or in_progress. `completed` is one-way to `deleted`; `deleted` is a
8
- * terminal tombstone.
9
- */
10
- declare const VALID_TRANSITIONS: Record<TaskStatus, ReadonlySet<TaskStatus>>;
11
- declare function isTransitionValid(from: TaskStatus, to: TaskStatus): boolean;
12
- //#endregion
13
- export { VALID_TRANSITIONS, isTransitionValid };
14
- //# sourceMappingURL=invariants.d.mts.map
1
+ import { VALID_TRANSITIONS, isTransitionValid } from "../services/store/invariants.mjs";
2
+ export { VALID_TRANSITIONS, isTransitionValid };
@@ -1,2 +1 @@
1
- const e={pending:new Set([`in_progress`,`completed`,`failed`,`deleted`]),in_progress:new Set([`pending`,`completed`,`failed`,`deleted`]),failed:new Set([`pending`,`in_progress`,`completed`,`deleted`]),completed:new Set([`deleted`]),deleted:new Set};function t(t,n){return t===n||e[t].has(n)}export{e as VALID_TRANSITIONS,t as isTransitionValid};
2
- //# sourceMappingURL=invariants.mjs.map
1
+ import{VALID_TRANSITIONS as e,isTransitionValid as t}from"../services/store/invariants.mjs";export{e as VALID_TRANSITIONS,t as isTransitionValid};
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:path");t=e.__toESM(t,1);let n=require("node:os");n=e.__toESM(n,1);let r=require("node:child_process"),i=require("node:fs");i=e.__toESM(i,1);let a=require("@agimon-ai/doompi-extension-contracts/child-process");const o=`DOOM_TASK_STORE`,s=`doom-task`,c=`tasks.json`,l=`utf8`;function u(e,t){try{let n=(0,r.execFileSync)(`git`,e,{cwd:t,encoding:l,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return n.length>0?n:void 0}catch{return}}function d(e){let r=e.PI_CODING_AGENT_DIR?.trim();return r===`~`?n.default.homedir():r?.startsWith(`~/`)?t.default.join(n.default.homedir(),r.slice(2)):r?t.default.resolve(r):t.default.join(n.default.homedir(),`.pi`,`agent`)}function f(e,n){let r=t.default.relative(t.default.resolve(e),t.default.resolve(n));return r===``||!r.startsWith(`..`)&&!t.default.isAbsolute(r)}function p(e,t=process.env){if(!t[a.SUBAGENT_CHILD_ENV])return e;let n=t[a.SUBAGENT_PARENT_SESSION_ENV]?.trim();if(!n)throw Error(`${a.SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);return n}function m(e=process.cwd(),n=process.env,r=`standalone`){let i=n[o]?.trim();if(i)return t.default.resolve(i);let a=r.trim();if(!a)throw Error(`doom-task session id cannot be blank`);return t.default.join(d(n),s,a,c)}function h(e=process.env){return!!e[o]?.trim()}function g(e=process.cwd()){let n=u([`rev-parse`,`--path-format=absolute`,`--git-common-dir`],e);return n?t.default.join(n,s):void 0}function _(e,n=process.cwd()){let r={removed:[],errors:[]},a=g(n);if(!a||t.default.basename(a)!==s||f(a,e))return r;try{if(!i.default.existsSync(a))return r;i.default.rmSync(a,{recursive:!0,force:!0}),r.removed.push(a)}catch(e){r.errors.push(`Could not remove legacy task store ${a}: ${String(e)}`)}return r}function v(e,n,r=Date.now()){let a={removed:[],errors:[]},o=t.default.dirname(e),s=t.default.dirname(o),u;try{u=i.default.readdirSync(s)}catch(e){return e.code===`ENOENT`||a.errors.push(`Could not read task store directory ${s}: ${String(e)}`),a}for(let e of u){let u=t.default.join(s,e),d=t.default.join(u,c);if(!(u===o||!i.default.existsSync(d)))try{if(i.default.existsSync(y(d))||(JSON.parse(i.default.readFileSync(d,l)),r-i.default.statSync(d).mtimeMs<=n))continue;i.default.rmSync(u,{recursive:!0,force:!0}),a.removed.push(u)}catch(e){a.errors.push(`Could not sweep task store ${d}: ${String(e)}`)}}return a}function y(e){return`${e}.lock`}function b(e,t=process.pid){return`${e}.tmp.${t}`}exports.STORE_PATH_ENV=o,exports.hasStorePathOverride=h,exports.lockPathFor=y,exports.removeLegacyStoreDirectory=_,exports.resolveLegacyStoreDirectory=g,exports.resolveSessionKey=p,exports.resolveStorePath=m,exports.sweepStoreFiles=v,exports.tempPathFor=b;
2
- //# sourceMappingURL=paths.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../adapters/store/paths.cjs");require("../services/store/paths.cjs"),exports.STORE_PATH_ENV=e.STORE_PATH_ENV,exports.hasStorePathOverride=e.hasStorePathOverride,exports.lockPathFor=e.lockPathFor,exports.removeLegacyStoreDirectory=e.removeLegacyStoreDirectory,exports.removeLegacyStoreDirectoryAsync=e.removeLegacyStoreDirectoryAsync,exports.resolveLegacyStoreDirectory=e.resolveLegacyStoreDirectory,exports.resolveLegacyStoreDirectoryAsync=e.resolveLegacyStoreDirectoryAsync,exports.resolveSessionKey=e.resolveSessionKey,exports.resolveStorePath=e.resolveStorePath,exports.sweepStoreFiles=e.sweepStoreFiles,exports.sweepStoreFilesAsync=e.sweepStoreFilesAsync,exports.tempPathFor=e.tempPathFor;
@@ -1,23 +1,2 @@
1
- //#region src/store/paths.d.ts
2
- declare const STORE_PATH_ENV = "DOOM_TASK_STORE";
3
- /** Resolve the tree root without relying on extension startup order. */
4
- declare function resolveSessionKey(rootSessionId: string, env?: NodeJS.ProcessEnv): string;
5
- /** Resolve one root session tree to a task document under the Pi agent directory. */
6
- declare function resolveStorePath(_cwd?: string, env?: NodeJS.ProcessEnv, sessionKey?: string): string;
7
- /** Whether a deliberate unscoped task-store override is active. */
8
- declare function hasStorePathOverride(env?: NodeJS.ProcessEnv): boolean;
9
- /** Exact legacy Git-directory store, if the current working tree has one. */
10
- declare function resolveLegacyStoreDirectory(cwd?: string): string | undefined;
11
- interface StoreSweepResult {
12
- removed: string[];
13
- errors: string[];
14
- }
15
- /** Remove only the validated legacy Git store unless it contains the active override. */
16
- declare function removeLegacyStoreDirectory(currentStorePath: string, cwd?: string): StoreSweepResult;
17
- /** Delete expired sibling session stores while preserving active or unreadable stores. */
18
- declare function sweepStoreFiles(currentStorePath: string, ttlMs: number, now?: number): StoreSweepResult;
19
- declare function lockPathFor(storePath: string): string;
20
- declare function tempPathFor(storePath: string, pid?: number): string;
21
- //#endregion
22
- export { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, resolveLegacyStoreDirectory, resolveSessionKey, resolveStorePath, sweepStoreFiles, tempPathFor };
23
- //# sourceMappingURL=paths.d.cts.map
1
+ import { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, sweepStoreFiles, sweepStoreFilesAsync, tempPathFor } from "../adapters/store/paths.cjs";
2
+ export { STORE_PATH_ENV, type StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, sweepStoreFiles, sweepStoreFilesAsync, tempPathFor };
@@ -1,23 +1,2 @@
1
- //#region src/store/paths.d.ts
2
- declare const STORE_PATH_ENV = "DOOM_TASK_STORE";
3
- /** Resolve the tree root without relying on extension startup order. */
4
- declare function resolveSessionKey(rootSessionId: string, env?: NodeJS.ProcessEnv): string;
5
- /** Resolve one root session tree to a task document under the Pi agent directory. */
6
- declare function resolveStorePath(_cwd?: string, env?: NodeJS.ProcessEnv, sessionKey?: string): string;
7
- /** Whether a deliberate unscoped task-store override is active. */
8
- declare function hasStorePathOverride(env?: NodeJS.ProcessEnv): boolean;
9
- /** Exact legacy Git-directory store, if the current working tree has one. */
10
- declare function resolveLegacyStoreDirectory(cwd?: string): string | undefined;
11
- interface StoreSweepResult {
12
- removed: string[];
13
- errors: string[];
14
- }
15
- /** Remove only the validated legacy Git store unless it contains the active override. */
16
- declare function removeLegacyStoreDirectory(currentStorePath: string, cwd?: string): StoreSweepResult;
17
- /** Delete expired sibling session stores while preserving active or unreadable stores. */
18
- declare function sweepStoreFiles(currentStorePath: string, ttlMs: number, now?: number): StoreSweepResult;
19
- declare function lockPathFor(storePath: string): string;
20
- declare function tempPathFor(storePath: string, pid?: number): string;
21
- //#endregion
22
- export { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, resolveLegacyStoreDirectory, resolveSessionKey, resolveStorePath, sweepStoreFiles, tempPathFor };
23
- //# sourceMappingURL=paths.d.mts.map
1
+ import { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, sweepStoreFiles, sweepStoreFilesAsync, tempPathFor } from "../adapters/store/paths.mjs";
2
+ export { STORE_PATH_ENV, type StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, sweepStoreFiles, sweepStoreFilesAsync, tempPathFor };
@@ -1,2 +1 @@
1
- import e from"node:path";import t from"node:os";import{execFileSync as n}from"node:child_process";import r from"node:fs";import{SUBAGENT_CHILD_ENV as i,SUBAGENT_PARENT_SESSION_ENV as a}from"@agimon-ai/doompi-extension-contracts/child-process";const o=`DOOM_TASK_STORE`,s=`doom-task`,c=`tasks.json`,l=`utf8`;function u(e,t){try{let r=n(`git`,e,{cwd:t,encoding:l,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return r.length>0?r:void 0}catch{return}}function d(n){let r=n.PI_CODING_AGENT_DIR?.trim();return r===`~`?t.homedir():r?.startsWith(`~/`)?e.join(t.homedir(),r.slice(2)):r?e.resolve(r):e.join(t.homedir(),`.pi`,`agent`)}function f(t,n){let r=e.relative(e.resolve(t),e.resolve(n));return r===``||!r.startsWith(`..`)&&!e.isAbsolute(r)}function p(e,t=process.env){if(!t[i])return e;let n=t[a]?.trim();if(!n)throw Error(`${a} is required in a subagent child`);return n}function m(t=process.cwd(),n=process.env,r=`standalone`){let i=n[o]?.trim();if(i)return e.resolve(i);let a=r.trim();if(!a)throw Error(`doom-task session id cannot be blank`);return e.join(d(n),s,a,c)}function h(e=process.env){return!!e[o]?.trim()}function g(t=process.cwd()){let n=u([`rev-parse`,`--path-format=absolute`,`--git-common-dir`],t);return n?e.join(n,s):void 0}function _(t,n=process.cwd()){let i={removed:[],errors:[]},a=g(n);if(!a||e.basename(a)!==s||f(a,t))return i;try{if(!r.existsSync(a))return i;r.rmSync(a,{recursive:!0,force:!0}),i.removed.push(a)}catch(e){i.errors.push(`Could not remove legacy task store ${a}: ${String(e)}`)}return i}function v(t,n,i=Date.now()){let a={removed:[],errors:[]},o=e.dirname(t),s=e.dirname(o),u;try{u=r.readdirSync(s)}catch(e){return e.code===`ENOENT`||a.errors.push(`Could not read task store directory ${s}: ${String(e)}`),a}for(let t of u){let u=e.join(s,t),d=e.join(u,c);if(!(u===o||!r.existsSync(d)))try{if(r.existsSync(y(d))||(JSON.parse(r.readFileSync(d,l)),i-r.statSync(d).mtimeMs<=n))continue;r.rmSync(u,{recursive:!0,force:!0}),a.removed.push(u)}catch(e){a.errors.push(`Could not sweep task store ${d}: ${String(e)}`)}}return a}function y(e){return`${e}.lock`}function b(e,t=process.pid){return`${e}.tmp.${t}`}export{o as STORE_PATH_ENV,h as hasStorePathOverride,y as lockPathFor,_ as removeLegacyStoreDirectory,g as resolveLegacyStoreDirectory,p as resolveSessionKey,m as resolveStorePath,v as sweepStoreFiles,b as tempPathFor};
2
- //# sourceMappingURL=paths.mjs.map
1
+ import{STORE_PATH_ENV as e,hasStorePathOverride as t,lockPathFor as n,removeLegacyStoreDirectory as r,removeLegacyStoreDirectoryAsync as i,resolveLegacyStoreDirectory as a,resolveLegacyStoreDirectoryAsync as o,resolveSessionKey as s,resolveStorePath as c,sweepStoreFiles as l,sweepStoreFilesAsync as u,tempPathFor as d}from"../adapters/store/paths.mjs";import"../services/store/paths.mjs";export{e as STORE_PATH_ENV,t as hasStorePathOverride,n as lockPathFor,r as removeLegacyStoreDirectory,i as removeLegacyStoreDirectoryAsync,a as resolveLegacyStoreDirectory,o as resolveLegacyStoreDirectoryAsync,s as resolveSessionKey,c as resolveStorePath,l as sweepStoreFiles,u as sweepStoreFilesAsync,d as tempPathFor};
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}exports.isProcessAlive=e;
2
- //# sourceMappingURL=processLiveness.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/store/processLiveness.cjs");exports.isProcessAlive=e.isProcessAlive;
@@ -1,12 +1,2 @@
1
- //#region src/store/processLiveness.d.ts
2
- /**
3
- * Is a process still running?
4
- *
5
- * Signal 0 performs the permission and existence check without delivering a
6
- * signal. EPERM means the process exists but belongs to another user, which
7
- * still counts as alive.
8
- */
9
- declare function isProcessAlive(pid: number): boolean;
10
- //#endregion
11
- export { isProcessAlive };
12
- //# sourceMappingURL=processLiveness.d.cts.map
1
+ import { isProcessAlive } from "../services/store/processLiveness.cjs";
2
+ export { isProcessAlive };
@@ -1,12 +1,2 @@
1
- //#region src/store/processLiveness.d.ts
2
- /**
3
- * Is a process still running?
4
- *
5
- * Signal 0 performs the permission and existence check without delivering a
6
- * signal. EPERM means the process exists but belongs to another user, which
7
- * still counts as alive.
8
- */
9
- declare function isProcessAlive(pid: number): boolean;
10
- //#endregion
11
- export { isProcessAlive };
12
- //# sourceMappingURL=processLiveness.d.mts.map
1
+ import { isProcessAlive } from "../services/store/processLiveness.mjs";
2
+ export { isProcessAlive };
@@ -1,2 +1 @@
1
- function e(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}export{e as isProcessAlive};
2
- //# sourceMappingURL=processLiveness.mjs.map
1
+ import{isProcessAlive as e}from"../services/store/processLiveness.mjs";export{e as isProcessAlive};
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./processLiveness.cjs"),t=require("./types.cjs"),n=`Delegation orphaned by harness restart`,r=`Delegation orphaned by session restart`;function i(i,a=new Date().toISOString(),o=e.isProcessAlive,s){let c=[],l=i.tasks.map(e=>{if(!t.isDelegationActive(e))return e;let i=e.delegation?.pid;if(i===void 0)return e;let l=s!==void 0&&i===s.pid&&!s.liveRequestIds.has(e.delegation.requestId);if(!l&&o(i))return e;let u={...e,status:`pending`,updatedAt:a,delegation:{...e.delegation,state:`failed`,endedAt:a,result:{status:`failed`,error:l?r:n}}};return c.push(u),u});return c.length===0?{document:i,orphaned:c}:{document:{...i,tasks:l},orphaned:c}}exports.ERR_ORPHANED_BY_RESTART=n,exports.ERR_ORPHANED_BY_SESSION=r,exports.reconcileOrphanedDelegations=i;
2
- //# sourceMappingURL=reconcile.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/store/reconcile.cjs");exports.ERR_ORPHANED_BY_RESTART=e.ERR_ORPHANED_BY_RESTART,exports.ERR_ORPHANED_BY_SESSION=e.ERR_ORPHANED_BY_SESSION,exports.reconcileOrphanedDelegations=e.reconcileOrphanedDelegations;
@@ -1,34 +1,2 @@
1
- import { Task, TaskDocument } from "./types.cjs";
2
- //#region src/store/reconcile.d.ts
3
- declare const ERR_ORPHANED_BY_RESTART = "Delegation orphaned by harness restart";
4
- declare const ERR_ORPHANED_BY_SESSION = "Delegation orphaned by session restart";
5
- interface ReconcileResult {
6
- document: TaskDocument;
7
- orphaned: Task[];
8
- }
9
- /** The delegations this process can still settle, used to spot its own leftovers. */
10
- interface ReconcileSelf {
11
- pid: number;
12
- liveRequestIds: ReadonlySet<string>;
13
- }
14
- /**
15
- * Recover tasks that no longer have anyone able to finish them.
16
- *
17
- * A subagent run dies with the harness that spawned it, but the store file
18
- * outlives both, so a crash leaves tasks stuck in `in_progress` forever. Two
19
- * kinds of delegation qualify as dead:
20
- *
21
- * - the owning pid is gone, so nothing is left to report a result;
22
- * - the owning pid is *this* process, yet the request is absent from the live
23
- * set. Settling requires an in-memory record, so an in-process session
24
- * restart (which clears that map without writing to the store) leaves rows
25
- * nothing can ever resolve. Checking pid liveness alone misses these, because
26
- * the pid is our own and very much alive.
27
- *
28
- * Delegations owned by a different, still-running pid belong to a parallel
29
- * session and are left untouched.
30
- */
31
- declare function reconcileOrphanedDelegations(document: TaskDocument, now?: string, isAlive?: (pid: number) => boolean, self?: ReconcileSelf): ReconcileResult;
32
- //#endregion
33
- export { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations };
34
- //# sourceMappingURL=reconcile.d.cts.map
1
+ import { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations } from "../services/store/reconcile.cjs";
2
+ export { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations };
@@ -1,34 +1,2 @@
1
- import { Task, TaskDocument } from "./types.mjs";
2
- //#region src/store/reconcile.d.ts
3
- declare const ERR_ORPHANED_BY_RESTART = "Delegation orphaned by harness restart";
4
- declare const ERR_ORPHANED_BY_SESSION = "Delegation orphaned by session restart";
5
- interface ReconcileResult {
6
- document: TaskDocument;
7
- orphaned: Task[];
8
- }
9
- /** The delegations this process can still settle, used to spot its own leftovers. */
10
- interface ReconcileSelf {
11
- pid: number;
12
- liveRequestIds: ReadonlySet<string>;
13
- }
14
- /**
15
- * Recover tasks that no longer have anyone able to finish them.
16
- *
17
- * A subagent run dies with the harness that spawned it, but the store file
18
- * outlives both, so a crash leaves tasks stuck in `in_progress` forever. Two
19
- * kinds of delegation qualify as dead:
20
- *
21
- * - the owning pid is gone, so nothing is left to report a result;
22
- * - the owning pid is *this* process, yet the request is absent from the live
23
- * set. Settling requires an in-memory record, so an in-process session
24
- * restart (which clears that map without writing to the store) leaves rows
25
- * nothing can ever resolve. Checking pid liveness alone misses these, because
26
- * the pid is our own and very much alive.
27
- *
28
- * Delegations owned by a different, still-running pid belong to a parallel
29
- * session and are left untouched.
30
- */
31
- declare function reconcileOrphanedDelegations(document: TaskDocument, now?: string, isAlive?: (pid: number) => boolean, self?: ReconcileSelf): ReconcileResult;
32
- //#endregion
33
- export { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations };
34
- //# sourceMappingURL=reconcile.d.mts.map
1
+ import { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations } from "../services/store/reconcile.mjs";
2
+ export { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations };
@@ -1,2 +1 @@
1
- import{isProcessAlive as e}from"./processLiveness.mjs";import{isDelegationActive as t}from"./types.mjs";const n=`Delegation orphaned by harness restart`,r=`Delegation orphaned by session restart`;function i(i,a=new Date().toISOString(),o=e,s){let c=[],l=i.tasks.map(e=>{if(!t(e))return e;let i=e.delegation?.pid;if(i===void 0)return e;let l=s!==void 0&&i===s.pid&&!s.liveRequestIds.has(e.delegation.requestId);if(!l&&o(i))return e;let u={...e,status:`pending`,updatedAt:a,delegation:{...e.delegation,state:`failed`,endedAt:a,result:{status:`failed`,error:l?r:n}}};return c.push(u),u});return c.length===0?{document:i,orphaned:c}:{document:{...i,tasks:l},orphaned:c}}export{n as ERR_ORPHANED_BY_RESTART,r as ERR_ORPHANED_BY_SESSION,i as reconcileOrphanedDelegations};
2
- //# sourceMappingURL=reconcile.mjs.map
1
+ import{ERR_ORPHANED_BY_RESTART as e,ERR_ORPHANED_BY_SESSION as t,reconcileOrphanedDelegations as n}from"../services/store/reconcile.mjs";export{e as ERR_ORPHANED_BY_RESTART,t as ERR_ORPHANED_BY_SESSION,n as reconcileOrphanedDelegations};
@@ -1,3 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./types.cjs"),t=require("./taskGraph.cjs"),n=require("./invariants.cjs"),r=/^[A-Za-z][A-Za-z0-9_-]{0,31}$/;function i(e){switch(e.kind){case`error`:case`list`:case`get`:return!1;case`upsert`:return e.applied>0;case`delete`:case`clear`:return!0}}function a(e){return e.items.filter(e=>e.kind===`failed`).map(e=>`item[${e.index}]: ${e.message}`).join(`
2
- `)}function o(e){return e.kind===`upsert`?e.items[0]:void 0}function s(e,t){return{document:e,op:{kind:`error`,message:t}}}function c(e,t){let n=e??[],r=t??[];return n.length===r.length&&n.every((e,t)=>e===r[t])}function l(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function u(e,t){return e.subject!==t.subject||e.status!==t.status||e.description!==t.description||e.activeForm!==t.activeForm||e.owner!==t.owner||!c(e.blockedBy,t.blockedBy)||!l(e.metadata,t.metadata)}function d(e,t,n=e.nextId){return{...e,tasks:t,nextId:n}}function f(e,t){let n={...e};for(let[e,r]of Object.entries(t))r===null?delete n[e]:n[e]=r;return Object.keys(n).length?n:void 0}function p(e,t){if(t.subject!==void 0&&(e.subject=t.subject),t.description!==void 0&&(e.description=t.description),t.activeForm!==void 0&&(e.activeForm=t.activeForm),t.owner!==void 0&&(e.owner=t.owner),t.metadata!==void 0){let n=f(e.metadata,t.metadata);n===void 0?delete e.metadata:e.metadata=n}}function m(e,t,n){if(typeof n==`number`)return{ok:!0,id:n};if(!r.test(n))return{ok:!1,message:`${t}: "${n}" is not a valid ref; pass an existing task id as a number`};let i=e.refIds.get(n);if(i!==void 0)return{ok:!0,id:i};let a=e.failedRefs.get(n);return a===void 0?{ok:!1,message:`${t}: unknown ref "${n}" — a ref must be declared by an earlier entry in the same call`}:{ok:!1,message:`${t}: ref "${n}" refers to item[${a}], which failed`}}function h(e){return{ok:!1,message:e}}function g(e,t){if(t.ref!==void 0){if(t.id!==void 0)return`ref is only valid when creating a task; drop the id, or drop the ref`;if(!r.test(t.ref))return`ref "${t.ref}" is invalid: a ref must start with a letter and contain only letters, digits, - or _`;if(e.refIds.get(t.ref)!==void 0||e.failedRefs.has(t.ref))return`duplicate ref "${t.ref}": it was already declared by an earlier entry`}}function _(e,t,n,r){if(t.subject===void 0)return h(`subject is required when the entry has no id`);if(!t.subject.trim())return h(`subject must not be blank`);if(t.addBlockedBy!==void 0||t.removeBlockedBy!==void 0)return h(`addBlockedBy / removeBlockedBy are only for an entry with an id; a new task uses blockedBy`);if(t.status===`deleted`)return h(`cannot create a task with status deleted; create it, then use action delete`);let i=[];for(let n of t.blockedBy??[]){let t=m(e,`blockedBy`,n);if(!t.ok)return h(t.message);let r=e.tasks.find(e=>e.id===t.id);if(!r)return h(`blockedBy: #${t.id} not found`);if(r.status===`deleted`)return h(`blockedBy: #${t.id} is deleted`);i.includes(t.id)||i.push(t.id)}let a={id:e.nextId,subject:t.subject,status:t.status??`pending`,createdAt:r,updatedAt:r};return p(a,t),i.length&&(a.blockedBy=i),e.nextId+=1,e.tasks.push(a),t.ref&&e.refIds.set(t.ref,a.id),{ok:!0,outcome:{index:n,kind:`created`,id:a.id,subject:a.subject,status:a.status,...t.ref?{ref:t.ref}:{},...i.length?{blockedBy:i}:{}}}}function v(e,r,i,a){let o=r.id,s=e.tasks.findIndex(e=>e.id===o);if(s===-1)return h(`#${o} not found`);if(r.blockedBy!==void 0)return h(`blockedBy is only for a new entry; use addBlockedBy / removeBlockedBy on an entry that has an id`);if(!(r.subject!==void 0||r.description!==void 0||r.activeForm!==void 0||r.status!==void 0||r.owner!==void 0||r.metadata!==void 0||r.addBlockedBy?.length||r.removeBlockedBy?.length))return h(`nothing to change: provide at least one of subject, description, activeForm, status, owner, metadata, addBlockedBy, or removeBlockedBy`);let c=e.tasks[s];if(r.subject!==void 0&&!r.subject.trim())return h(`subject must not be blank`);let l=c.status;if(r.status!==void 0){if(!n.isTransitionValid(c.status,r.status))return h(`illegal transition ${c.status} -> ${r.status}`);l=r.status}let d=c.blockedBy?[...c.blockedBy]:[];for(let t of r.removeBlockedBy??[]){let n=m(e,`removeBlockedBy`,t);if(!n.ok)return h(n.message);d=d.filter(e=>e!==n.id)}for(let t of r.addBlockedBy??[]){let n=m(e,`addBlockedBy`,t);if(!n.ok)return h(n.message);if(n.id===o)return h(`cannot block #${o} on itself`);let r=e.tasks.find(e=>e.id===n.id);if(!r)return h(`addBlockedBy: #${n.id} not found`);if(r.status===`deleted`)return h(`addBlockedBy: #${n.id} is deleted`);d.includes(n.id)||d.push(n.id)}let f={...c,status:l};p(f,r),d.length?f.blockedBy=d:delete f.blockedBy;let g=[...e.tasks];if(g[s]=f,r.addBlockedBy?.length&&t.detectCycle(g,o,d))return h(`addBlockedBy would create a cycle in the blockedBy graph`);let _=u(c,f);return _&&(f.updatedAt=a),e.tasks=g,{ok:!0,outcome:_?{index:i,kind:`updated`,id:o,fromStatus:c.status,toStatus:l}:{index:i,kind:`unchanged`,id:o,status:l}}}function y(e,t,n){let i={tasks:[...e.tasks],nextId:e.nextId,refIds:new Map,failedRefs:new Map},a=[],o=0;for(let[e,s]of t.entries()){let t=g(i,s),c=t?h(t):s.id===void 0?_(i,s,e,n):v(i,s,e,n);if(c.ok){a.push(c.outcome),o+=1;continue}s.ref&&r.test(s.ref)&&!i.refIds.has(s.ref)&&i.failedRefs.set(s.ref,e),a.push({index:e,kind:`failed`,message:c.message,...s.id===void 0?{}:{id:s.id},...s.ref?{ref:s.ref}:{}})}return{document:o>0?d(e,i.tasks,i.nextId):e,op:{kind:`upsert`,items:a,applied:o,failed:a.length-o}}}function b(t,n,r,i=new Date().toISOString()){switch(n){case`upsert`:{let e=r.tasks;return!Array.isArray(e)||e.length===0?s(t,`upsert requires a non-empty tasks array, e.g. {"action":"upsert","tasks":[{"subject":"Write tests"}]}`):e.length>100?s(t,`upsert accepts at most 100 entries per call (received ${e.length})`):y(t,e,i)}case`list`:return{document:t,op:{kind:`list`,includeDeleted:r.includeDeleted===!0,...r.status===void 0?{}:{statusFilter:r.status}}};case`get`:{if(r.id===void 0)return s(t,`id required for get`);let e=t.tasks.find(e=>e.id===r.id);return e?{document:t,op:{kind:`get`,task:e}}:s(t,`#${r.id} not found`)}case`delete`:{if(r.id===void 0)return s(t,`id required for delete`);let n=t.tasks.findIndex(e=>e.id===r.id);if(n===-1)return s(t,`#${r.id} not found`);let a=t.tasks[n];if(a.status===`deleted`)return s(t,`#${a.id} is already deleted`);if(e.isDelegationActive(a))return s(t,`#${a.id} has a running delegation — cancel it before deleting`);let o=[...t.tasks];return o[n]={...a,status:e.DELETED_STATUS,updatedAt:i},{document:d(t,o),op:{kind:`delete`,id:a.id,subject:a.subject}}}case`clear`:{let n=t.tasks.filter(e.isDelegationActive);if(n.length>0)return s(t,`cannot clear while delegations are running (${n.map(e=>`#${e.id}`).join(`, `)}) — cancel them first`);let r=t.tasks.length;return{document:d(t,[],1),op:{kind:`clear`,count:r}}}}}exports.MAX_UPSERT_ITEMS=100,exports.REF_PATTERN=r,exports.applyTaskMutation=b,exports.formatUpsertFailure=a,exports.isCommittingOp=i,exports.singleItemOutcome=o;
3
- //# sourceMappingURL=reducer.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../services/store/reducer.cjs");exports.MAX_UPSERT_ITEMS=e.MAX_UPSERT_ITEMS,exports.REF_PATTERN=e.REF_PATTERN,exports.applyTaskMutation=e.applyTaskMutation,exports.formatUpsertFailure=e.formatUpsertFailure,exports.isCommittingOp=e.isCommittingOp,exports.singleItemOutcome=e.singleItemOutcome;
@@ -1,72 +1,2 @@
1
- import { Task, TaskAction, TaskDocument, TaskMutationParams, TaskStatus, UpsertItemOutcome } from "./types.cjs";
2
- //#region src/store/reducer.d.ts
3
- /** Bounds the work one call can do, and with it the size of one committed write. */
4
- declare const MAX_UPSERT_ITEMS = 100;
5
- /**
6
- * A ref must start with a letter, which makes it structurally unconfusable with
7
- * a stringified id. That is why resolving a dependency token is just a `typeof`
8
- * check with no coercion heuristics.
9
- */
10
- declare const REF_PATTERN: RegExp;
11
- /**
12
- * Reducer outcome. Closed tagged union: adding an action requires extending
13
- * this union and the response formatter, which the compiler enforces.
14
- *
15
- * `upsert` carries one outcome per request item. It is returned even when every
16
- * item failed — `error` is reserved for whole-call faults — so the tool layer
17
- * still has the per-item messages to report.
18
- */
19
- type Op = {
20
- kind: 'upsert';
21
- items: UpsertItemOutcome[];
22
- applied: number;
23
- failed: number;
24
- } | {
25
- kind: 'delete';
26
- id: number;
27
- subject: string;
28
- } | {
29
- kind: 'list';
30
- statusFilter?: TaskStatus;
31
- includeDeleted: boolean;
32
- } | {
33
- kind: 'get';
34
- task: Task;
35
- } | {
36
- kind: 'clear';
37
- count: number;
38
- } | {
39
- kind: 'error';
40
- message: string;
41
- };
42
- interface ApplyResult {
43
- document: TaskDocument;
44
- op: Op;
45
- }
46
- /** Actions the reducer owns. `assign`/`cancel` are handled by the delegation manager. */
47
- type ReducerAction = Exclude<TaskAction, 'assign' | 'cancel'>;
48
- /**
49
- * Does this op represent state that must reach disk?
50
- *
51
- * The exhaustive switch is the point: a future `Op` variant cannot be added
52
- * without declaring its persistence intent, so nothing silently starts or stops
53
- * bumping `rev`.
54
- */
55
- declare function isCommittingOp(op: Op): boolean;
56
- /** Joined per-item failures, for the thrown error when an upsert applied nothing. */
57
- declare function formatUpsertFailure(op: Extract<Op, {
58
- kind: 'upsert';
59
- }>): string;
60
- /** The single item's outcome, for callers that only ever send a batch of one. */
61
- declare function singleItemOutcome(op: Op): UpsertItemOutcome | undefined;
62
- /**
63
- * Pure reducer: (document, action, params) -> (document, op).
64
- *
65
- * All validation is in-line: structural guards plus state-aware checks
66
- * (transition legality, dangling or deleted blockedBy, self-block, cycles,
67
- * in-flight delegations). The caller owns persistence and formatting.
68
- */
69
- declare function applyTaskMutation(document: TaskDocument, action: ReducerAction, params: TaskMutationParams, now?: string): ApplyResult;
70
- //#endregion
71
- export { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome };
72
- //# sourceMappingURL=reducer.d.cts.map
1
+ import { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome } from "../services/store/reducer.cjs";
2
+ export { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome };
@@ -1,72 +1,2 @@
1
- import { Task, TaskAction, TaskDocument, TaskMutationParams, TaskStatus, UpsertItemOutcome } from "./types.mjs";
2
- //#region src/store/reducer.d.ts
3
- /** Bounds the work one call can do, and with it the size of one committed write. */
4
- declare const MAX_UPSERT_ITEMS = 100;
5
- /**
6
- * A ref must start with a letter, which makes it structurally unconfusable with
7
- * a stringified id. That is why resolving a dependency token is just a `typeof`
8
- * check with no coercion heuristics.
9
- */
10
- declare const REF_PATTERN: RegExp;
11
- /**
12
- * Reducer outcome. Closed tagged union: adding an action requires extending
13
- * this union and the response formatter, which the compiler enforces.
14
- *
15
- * `upsert` carries one outcome per request item. It is returned even when every
16
- * item failed — `error` is reserved for whole-call faults — so the tool layer
17
- * still has the per-item messages to report.
18
- */
19
- type Op = {
20
- kind: 'upsert';
21
- items: UpsertItemOutcome[];
22
- applied: number;
23
- failed: number;
24
- } | {
25
- kind: 'delete';
26
- id: number;
27
- subject: string;
28
- } | {
29
- kind: 'list';
30
- statusFilter?: TaskStatus;
31
- includeDeleted: boolean;
32
- } | {
33
- kind: 'get';
34
- task: Task;
35
- } | {
36
- kind: 'clear';
37
- count: number;
38
- } | {
39
- kind: 'error';
40
- message: string;
41
- };
42
- interface ApplyResult {
43
- document: TaskDocument;
44
- op: Op;
45
- }
46
- /** Actions the reducer owns. `assign`/`cancel` are handled by the delegation manager. */
47
- type ReducerAction = Exclude<TaskAction, 'assign' | 'cancel'>;
48
- /**
49
- * Does this op represent state that must reach disk?
50
- *
51
- * The exhaustive switch is the point: a future `Op` variant cannot be added
52
- * without declaring its persistence intent, so nothing silently starts or stops
53
- * bumping `rev`.
54
- */
55
- declare function isCommittingOp(op: Op): boolean;
56
- /** Joined per-item failures, for the thrown error when an upsert applied nothing. */
57
- declare function formatUpsertFailure(op: Extract<Op, {
58
- kind: 'upsert';
59
- }>): string;
60
- /** The single item's outcome, for callers that only ever send a batch of one. */
61
- declare function singleItemOutcome(op: Op): UpsertItemOutcome | undefined;
62
- /**
63
- * Pure reducer: (document, action, params) -> (document, op).
64
- *
65
- * All validation is in-line: structural guards plus state-aware checks
66
- * (transition legality, dangling or deleted blockedBy, self-block, cycles,
67
- * in-flight delegations). The caller owns persistence and formatting.
68
- */
69
- declare function applyTaskMutation(document: TaskDocument, action: ReducerAction, params: TaskMutationParams, now?: string): ApplyResult;
70
- //#endregion
71
- export { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome };
72
- //# sourceMappingURL=reducer.d.mts.map
1
+ import { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome } from "../services/store/reducer.mjs";
2
+ export { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome };