@oyasmi/pipiclaw 0.9.5-beta.2 → 0.9.5-beta.3

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 (272) hide show
  1. package/README.en.md +9 -11
  2. package/README.md +9 -11
  3. package/dist/agent/channel-runner.d.ts +12 -24
  4. package/dist/agent/channel-runner.js +74 -30
  5. package/dist/agent/maintenance-context.d.ts +2 -0
  6. package/dist/agent/maintenance-context.js +15 -0
  7. package/dist/agent/prompt/sections.js +8 -6
  8. package/dist/agent/prompt/types.d.ts +1 -1
  9. package/dist/agent/runner-factory.js +1 -1
  10. package/dist/agent/session/command-extension.js +11 -0
  11. package/dist/agent/session/compaction-summary.js +6 -2
  12. package/dist/agent/session/execution-trace.d.ts +14 -0
  13. package/dist/agent/session/execution-trace.js +57 -0
  14. package/dist/agent/session/session-events.d.ts +2 -7
  15. package/dist/agent/session/session-events.js +35 -12
  16. package/dist/agent/session/session-host.d.ts +12 -22
  17. package/dist/agent/session/session-host.js +46 -65
  18. package/dist/agent/turn/task-digest.d.ts +1 -2
  19. package/dist/agent/turn/task-digest.js +33 -33
  20. package/dist/agent/turn/turn-context.d.ts +1 -1
  21. package/dist/agent/turn/turn-context.js +1 -1
  22. package/dist/agent/turn/turn-finish.d.ts +2 -2
  23. package/dist/agent/turn/turn-finish.js +3 -2
  24. package/dist/agent/turn/turn-pipeline.d.ts +4 -2
  25. package/dist/agent/turn/turn-pipeline.js +33 -5
  26. package/dist/agent/types.d.ts +64 -14
  27. package/dist/agent/types.js +3 -0
  28. package/dist/app/home.js +3 -4
  29. package/dist/channel/channel-event.d.ts +4 -12
  30. package/dist/channel/ingress.d.ts +1 -9
  31. package/dist/channel/store.d.ts +1 -1
  32. package/dist/commands/catalog.js +25 -19
  33. package/dist/commands/router.d.ts +5 -2
  34. package/dist/commands/router.js +9 -4
  35. package/dist/config/settings.d.ts +5 -12
  36. package/dist/config/settings.js +0 -7
  37. package/dist/config/tools.d.ts +2 -2
  38. package/dist/config/tools.js +2 -2
  39. package/dist/dingtalk/bot.d.ts +2 -0
  40. package/dist/dingtalk/bot.js +4 -0
  41. package/dist/dingtalk/cards.d.ts +7 -0
  42. package/dist/dingtalk/cards.js +32 -2
  43. package/dist/dingtalk/delivery.d.ts +5 -1
  44. package/dist/dingtalk/delivery.js +157 -142
  45. package/dist/dingtalk/progress.d.ts +55 -6
  46. package/dist/dingtalk/progress.js +195 -16
  47. package/dist/file-store.d.ts +4 -0
  48. package/dist/file-store.js +6 -1
  49. package/dist/jobs/completion-observer.d.ts +20 -0
  50. package/dist/jobs/completion-observer.js +107 -0
  51. package/dist/jobs/completion-signal.d.ts +9 -0
  52. package/dist/jobs/completion-signal.js +32 -0
  53. package/dist/jobs/completion-wake.d.ts +1 -1
  54. package/dist/jobs/completion-wake.js +2 -13
  55. package/dist/jobs/manager.d.ts +11 -29
  56. package/dist/jobs/manager.js +103 -176
  57. package/dist/jobs/probe.d.ts +3 -0
  58. package/dist/jobs/probe.js +42 -0
  59. package/dist/jobs/record.d.ts +3 -6
  60. package/dist/jobs/runtime.d.ts +28 -0
  61. package/dist/jobs/runtime.js +69 -0
  62. package/dist/memory/boundary-work.d.ts +2 -0
  63. package/dist/memory/boundary-work.js +79 -37
  64. package/dist/memory/commands.js +4 -1
  65. package/dist/memory/index-budget.js +18 -15
  66. package/dist/memory/journal.js +2 -1
  67. package/dist/memory/lifecycle.d.ts +4 -8
  68. package/dist/memory/lifecycle.js +21 -51
  69. package/dist/memory/reflect-job.d.ts +0 -6
  70. package/dist/memory/reflect-job.js +13 -34
  71. package/dist/memory/reflect.d.ts +4 -0
  72. package/dist/memory/reflect.js +32 -5
  73. package/dist/memory/review-log.d.ts +13 -0
  74. package/dist/memory/review-log.js +49 -0
  75. package/dist/memory/search.js +7 -4
  76. package/dist/memory/source-window.d.ts +18 -1
  77. package/dist/memory/source-window.js +59 -9
  78. package/dist/memory/store.d.ts +2 -0
  79. package/dist/memory/store.js +45 -13
  80. package/dist/playbooks/agent-delegation.md +10 -4
  81. package/dist/playbooks/background-jobs.md +4 -4
  82. package/dist/playbooks/event-scheduling.md +2 -2
  83. package/dist/playbooks/memory-and-learning.md +3 -3
  84. package/dist/playbooks/outbound-media.md +2 -2
  85. package/dist/playbooks/runtime-orientation.md +10 -6
  86. package/dist/playbooks/task-lead.md +54 -33
  87. package/dist/runtime/bootstrap.d.ts +11 -24
  88. package/dist/runtime/bootstrap.js +92 -59
  89. package/dist/runtime/channel-queue.d.ts +2 -0
  90. package/dist/runtime/channel-queue.js +5 -1
  91. package/dist/runtime/durable-dispatch.d.ts +7 -0
  92. package/dist/runtime/durable-dispatch.js +66 -7
  93. package/dist/runtime/ingress-busy.d.ts +1 -2
  94. package/dist/runtime/ingress-busy.js +2 -35
  95. package/dist/runtime/ingress-commands.d.ts +1 -1
  96. package/dist/runtime/ingress-commands.js +28 -20
  97. package/dist/runtime/ingress-deps.d.ts +4 -7
  98. package/dist/runtime/ingress.js +23 -13
  99. package/dist/runtime/shutdown.d.ts +1 -1
  100. package/dist/runtime/shutdown.js +2 -2
  101. package/dist/runtime/task-close.d.ts +4 -0
  102. package/dist/runtime/task-close.js +102 -0
  103. package/dist/runtime/task-control.d.ts +34 -0
  104. package/dist/runtime/task-control.js +225 -0
  105. package/dist/runtime/task-input.d.ts +13 -0
  106. package/dist/runtime/task-input.js +129 -0
  107. package/dist/runtime/task-lane-types.d.ts +123 -0
  108. package/dist/runtime/task-lane-types.js +14 -0
  109. package/dist/runtime/task-lane.d.ts +99 -0
  110. package/dist/runtime/task-lane.js +703 -0
  111. package/dist/runtime/task-pending.d.ts +8 -0
  112. package/dist/runtime/task-pending.js +40 -0
  113. package/dist/runtime/task-spawn.d.ts +4 -4
  114. package/dist/runtime/task-spawn.js +4 -4
  115. package/dist/runtime/task-step.d.ts +32 -0
  116. package/dist/runtime/task-step.js +276 -0
  117. package/dist/runtime/turn-run.d.ts +4 -16
  118. package/dist/runtime/turn-run.js +17 -155
  119. package/dist/runtime/wake-coalescing.d.ts +1 -3
  120. package/dist/runtime/wake-coalescing.js +2 -4
  121. package/dist/shared/format.d.ts +0 -6
  122. package/dist/shared/format.js +0 -17
  123. package/dist/shared/host-process.d.ts +2 -0
  124. package/dist/shared/host-process.js +16 -1
  125. package/dist/shared/jsonl-appender.d.ts +5 -0
  126. package/dist/shared/jsonl-appender.js +25 -2
  127. package/dist/skills/catalog.d.ts +9 -0
  128. package/dist/skills/catalog.js +34 -0
  129. package/dist/skills/commands.d.ts +3 -12
  130. package/dist/skills/commands.js +36 -22
  131. package/dist/skills/loader.d.ts +2 -31
  132. package/dist/skills/loader.js +101 -68
  133. package/dist/skills/roots.d.ts +12 -0
  134. package/dist/skills/roots.js +18 -0
  135. package/dist/skills/types.d.ts +24 -0
  136. package/dist/skills/types.js +1 -0
  137. package/dist/subagents/completion-wake.js +0 -10
  138. package/dist/subagents/discovery.d.ts +1 -1
  139. package/dist/subagents/discovery.js +10 -16
  140. package/dist/subagents/dispatch.js +8 -16
  141. package/dist/subagents/external/cursor-cli.d.ts +2 -0
  142. package/dist/subagents/external/cursor-cli.js +256 -0
  143. package/dist/subagents/external/harness.d.ts +5 -5
  144. package/dist/subagents/external/reconciliation.d.ts +7 -0
  145. package/dist/subagents/external/reconciliation.js +105 -0
  146. package/dist/subagents/external/recovery.d.ts +20 -0
  147. package/dist/subagents/external/recovery.js +71 -0
  148. package/dist/subagents/external/registry.js +2 -0
  149. package/dist/subagents/external/role-warnings.d.ts +17 -0
  150. package/dist/subagents/external/role-warnings.js +42 -0
  151. package/dist/subagents/external/run.js +18 -22
  152. package/dist/subagents/format.d.ts +1 -1
  153. package/dist/subagents/format.js +1 -1
  154. package/dist/subagents/grace.d.ts +2 -2
  155. package/dist/subagents/grace.js +3 -3
  156. package/dist/subagents/internal/run.js +7 -5
  157. package/dist/subagents/internal/worker.js +31 -2
  158. package/dist/subagents/result.js +2 -3
  159. package/dist/subagents/run-record.d.ts +4 -7
  160. package/dist/subagents/run-record.js +2 -2
  161. package/dist/subagents/runs.d.ts +33 -46
  162. package/dist/subagents/runs.js +126 -245
  163. package/dist/subagents/task-settlement.d.ts +3 -0
  164. package/dist/subagents/task-settlement.js +20 -0
  165. package/dist/subagents/types.d.ts +1 -2
  166. package/dist/subagents/workspace-summary.js +5 -1
  167. package/dist/tasks/archive.d.ts +11 -0
  168. package/dist/tasks/archive.js +141 -0
  169. package/dist/tasks/board.d.ts +5 -12
  170. package/dist/tasks/board.js +4 -30
  171. package/dist/tasks/bound-work.d.ts +12 -6
  172. package/dist/tasks/bound-work.js +37 -24
  173. package/dist/tasks/brief.d.ts +38 -14
  174. package/dist/tasks/brief.js +128 -70
  175. package/dist/tasks/budget.d.ts +3 -3
  176. package/dist/tasks/budget.js +9 -4
  177. package/dist/tasks/commands.d.ts +14 -9
  178. package/dist/tasks/commands.js +190 -121
  179. package/dist/tasks/completion.d.ts +12 -0
  180. package/dist/tasks/completion.js +35 -0
  181. package/dist/tasks/contract.d.ts +8 -17
  182. package/dist/tasks/contract.js +41 -43
  183. package/dist/tasks/control.d.ts +138 -0
  184. package/dist/tasks/control.js +1 -0
  185. package/dist/tasks/create.d.ts +1 -1
  186. package/dist/tasks/create.js +3 -3
  187. package/dist/tasks/delivery.d.ts +24 -0
  188. package/dist/tasks/delivery.js +221 -0
  189. package/dist/tasks/file-mutation.d.ts +5 -0
  190. package/dist/tasks/file-mutation.js +38 -0
  191. package/dist/tasks/frontmatter.d.ts +43 -28
  192. package/dist/tasks/frontmatter.js +83 -40
  193. package/dist/tasks/input-receipts.d.ts +7 -0
  194. package/dist/tasks/input-receipts.js +60 -0
  195. package/dist/tasks/loop-log.d.ts +147 -28
  196. package/dist/tasks/loop-log.js +239 -28
  197. package/dist/tasks/receipts.d.ts +19 -0
  198. package/dist/tasks/receipts.js +48 -0
  199. package/dist/tasks/state.d.ts +93 -0
  200. package/dist/tasks/state.js +156 -0
  201. package/dist/tasks/store.d.ts +81 -49
  202. package/dist/tasks/store.js +244 -147
  203. package/dist/tools/bash.d.ts +3 -5
  204. package/dist/tools/bash.js +8 -22
  205. package/dist/tools/contract/details.d.ts +6 -6
  206. package/dist/tools/contract/details.js +6 -6
  207. package/dist/tools/contract/execution-trace.d.ts +4 -0
  208. package/dist/tools/contract/execution-trace.js +23 -0
  209. package/dist/tools/contract/presentation.js +6 -2
  210. package/dist/tools/edit.d.ts +1 -0
  211. package/dist/tools/edit.js +45 -42
  212. package/dist/tools/index.d.ts +8 -12
  213. package/dist/tools/index.js +16 -6
  214. package/dist/tools/memory-manage.js +8 -1
  215. package/dist/tools/registry.d.ts +7 -11
  216. package/dist/tools/registry.js +52 -25
  217. package/dist/tools/skill.d.ts +2 -2
  218. package/dist/tools/skill.js +24 -10
  219. package/dist/tools/subagent-manage.js +7 -4
  220. package/dist/tools/subagent.d.ts +0 -2
  221. package/dist/tools/subagent.js +2 -7
  222. package/dist/tools/task-manage/control-tools.d.ts +4 -0
  223. package/dist/tools/task-manage/control-tools.js +65 -0
  224. package/dist/tools/task-manage/create.js +2 -1
  225. package/dist/tools/task-manage/factory.d.ts +12 -6
  226. package/dist/tools/task-manage/factory.js +72 -57
  227. package/dist/tools/task-manage/lifecycle.d.ts +7 -12
  228. package/dist/tools/task-manage/lifecycle.js +118 -66
  229. package/dist/tools/task-manage/log-view.js +8 -5
  230. package/dist/tools/task-manage/schema.d.ts +21 -26
  231. package/dist/tools/task-manage/schema.js +29 -35
  232. package/dist/tools/task-manage/shared.d.ts +8 -39
  233. package/dist/tools/task-manage/shared.js +19 -68
  234. package/dist/tools/task-manage/step-tools.d.ts +5 -0
  235. package/dist/tools/task-manage/step-tools.js +103 -0
  236. package/dist/tools/task-manage/types.d.ts +25 -18
  237. package/dist/tools/write-content.d.ts +1 -0
  238. package/dist/tools/write-content.js +6 -1
  239. package/dist/tools/write.d.ts +1 -0
  240. package/dist/tools/write.js +1 -0
  241. package/dist/usage/ledger.d.ts +4 -4
  242. package/dist/usage/render.js +2 -2
  243. package/dist/web/search-providers.js +0 -33
  244. package/dist/webapi/request-policy.js +1 -1
  245. package/examples/sub-agents/README.md +23 -16
  246. package/examples/sub-agents/agents/claude-high.md +1 -1
  247. package/examples/sub-agents/agents/claude-main.md +1 -1
  248. package/examples/sub-agents/agents/codex-flash.md +1 -1
  249. package/examples/sub-agents/agents/codex-high.md +1 -1
  250. package/examples/sub-agents/agents/codex-main.md +4 -4
  251. package/examples/sub-agents/agents/cursor-high.md +22 -0
  252. package/examples/sub-agents/agents/cursor-main.md +22 -0
  253. package/examples/sub-agents/agents/glm-flash.md +1 -1
  254. package/examples/sub-agents/agents/glm-high.md +2 -2
  255. package/examples/sub-agents/agents/scout.md +30 -0
  256. package/package.json +6 -6
  257. package/dist/runtime/task-driver.d.ts +0 -116
  258. package/dist/runtime/task-driver.js +0 -443
  259. package/dist/runtime/task-wake.d.ts +0 -48
  260. package/dist/runtime/task-wake.js +0 -32
  261. package/dist/shared/wake-claim.d.ts +0 -23
  262. package/dist/shared/wake-claim.js +0 -26
  263. package/dist/skills/validation.d.ts +0 -8
  264. package/dist/skills/validation.js +0 -91
  265. package/dist/skills/workspace.d.ts +0 -33
  266. package/dist/skills/workspace.js +0 -116
  267. package/dist/tasks/steer.d.ts +0 -8
  268. package/dist/tasks/steer.js +0 -81
  269. package/dist/tasks/ticket.d.ts +0 -71
  270. package/dist/tasks/ticket.js +0 -138
  271. package/dist/tools/task-manage/step-end.d.ts +0 -11
  272. package/dist/tools/task-manage/step-end.js +0 -117
@@ -1,20 +1,21 @@
1
- import { readdir, readFile, rename, rmdir, stat, unlink } from "node:fs/promises";
1
+ import { readdir, readFile, rename, rmdir, unlink } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import * as log from "../log.js";
4
4
  import { writeFileAtomically } from "../shared/atomic-file.js";
5
- import { isProcessAlive, killProcessGroup, readProcessStartTime } from "../shared/host-process.js";
5
+ import { isProcessAlive, killProcessGroup } from "../shared/host-process.js";
6
6
  import { RecoverableToolError } from "../shared/recoverable-error.js";
7
7
  import { createSerialQueue } from "../shared/serial-queue.js";
8
8
  import { errorMessage } from "../shared/text-utils.js";
9
- import { beginWakeClaim, finishWakeClaim } from "../shared/wake-claim.js";
10
- import { logTaskDispatch, logTaskSettlement } from "../tasks/bound-work.js";
11
- import { redeemTicket } from "../tasks/store.js";
9
+ import { logTaskDispatch, logTaskStall } from "../tasks/bound-work.js";
10
+ import { readStoredTask } from "../tasks/store.js";
12
11
  import { createEmptyUsageTotals } from "../usage/totals.js";
13
- import { buildRunCompletionWake, countWakeSiblings, WAKE_OUTPUT_TAIL_CHARS } from "./completion-wake.js";
12
+ import { buildRunCompletionWake, countWakeSiblings } from "./completion-wake.js";
14
13
  import { createProgressPacer, startExternalProgressTail } from "./external/progress-tail.js";
15
- import { finalizeExternalRun } from "./external/settlement.js";
14
+ import { processIdentity, reconcileExternalRun } from "./external/reconciliation.js";
15
+ import { AdoptedRunObserver } from "./external/recovery.js";
16
16
  import { runArchiveEntry, runLedgerEntry } from "./run-archive.js";
17
17
  import { applyPendingSettlement, createPendingSettlement, isTerminal, MAX_RUNNING_SUBAGENT_RUNS_PER_DESK, MAX_RUNNING_SUBAGENT_RUNS_PER_HOST, normalizeRunIdQuery, parseRunRecord, RUN_ARTIFACT_FILENAMES, RUN_ID_PREFIX, RUN_RETENTION_MS, randomRunIdSuffix, } from "./run-record.js";
18
+ import { creditTaskForRun } from "./task-settlement.js";
18
19
  import { acquireWorkspaceLease, formatWorkspaceLeaseConflict, releaseWorkspaceLease } from "./workspace-lease.js";
19
20
  /** Registration is serialized across channel managers so the host-wide count and insertion are
20
21
  * one admission transaction. The per-run manager queue alone cannot protect the 19 -> 20 edge
@@ -48,9 +49,7 @@ export class SubAgentRunManager {
48
49
  /** External launch intents exist before a safe live child handle does. A cancel in that window
49
50
  * is remembered here and consumed before spawn, rather than spawning a process nothing can cancel. */
50
51
  this.externalLaunches = new Map();
51
- /** One-shot deadline checks for external processes adopted during restore. Unlike a child this
52
- * daemon spawned itself, an adopted process cannot emit a `close` event to this process. */
53
- this.externalRecoveryTimers = new Map();
52
+ this.recoveryQueue = createSerialQueue();
54
53
  /** Live external runs' tail-the-artifact-file progress pollers (P1a). Never persisted or
55
54
  * reconstructed on restore — an adopted run has no fresher information to poll for than
56
55
  * restart reconciliation already reads once from the finished process's own output. */
@@ -60,16 +59,23 @@ export class SubAgentRunManager {
60
59
  * external tail does. Created on first report, dropped at settlement. */
61
60
  this.internalProgressPacers = new Map();
62
61
  this.queue = createSerialQueue();
62
+ this.recovery = new AdoptedRunObserver((id) => this.runs.get(id), async (id) => {
63
+ const record = this.runs.get(id);
64
+ if (record)
65
+ await this.reconcileExternalRunAtDeadline(record);
66
+ }, (runId, error) => log.logWarn("subagent.reconcile.failed", "Adopted external run reconcile failed", {
67
+ reason: errorMessage(error),
68
+ fields: { runId, desk: this.target.desk },
69
+ }), options.adoptedCheckIntervalMs);
63
70
  }
64
- /** The completion wake's dispatch id — the only id `beginWakeConsumption` accepts for it. */
71
+ /** The completion wake's dispatch id (a chat-level run; a task-bound run never wakes a channel). */
65
72
  wakeDispatchId(runId) {
66
73
  return `subagent:${this.target.desk}:${runId}:done`;
67
74
  }
68
75
  /** Release observation timers without cancelling dispatched work or its settlement. */
69
76
  stop() {
70
77
  this.stopped = true;
71
- for (const runId of this.externalRecoveryTimers.keys())
72
- this.clearExternalRecoveryTimer(runId);
78
+ this.recovery.stop();
73
79
  for (const runId of this.externalProgressTails.keys())
74
80
  this.stopExternalProgressTail(runId);
75
81
  }
@@ -160,10 +166,29 @@ export class SubAgentRunManager {
160
166
  durationMs: Date.now() - (record.processStartedAt ?? record.startedAt),
161
167
  silentMs,
162
168
  });
169
+ this.noteTaskStall(record, silentMs);
163
170
  },
164
171
  });
165
172
  this.externalProgressTails.set(record.runId, tail);
166
173
  }
174
+ /** Tell a task-bound run's task that the run has gone quiet: it is the leader's call what to do (spec 064, D16). */
175
+ noteTaskStall(record, silentMs) {
176
+ const taskId = record.taskId;
177
+ if (!taskId || this.stopped)
178
+ return;
179
+ void logTaskStall(this.target.deskDir, taskId, {
180
+ ref: record.runId,
181
+ silentMinutes: Math.max(1, Math.round(silentMs / 60_000)),
182
+ })
183
+ .then((logged) => {
184
+ if (logged)
185
+ this.options.onTaskInput?.(this.target.desk, taskId);
186
+ })
187
+ .catch((error) => log.logWarn("subagent.task_stall.log_failed", "Task stall record for run failed", {
188
+ reason: errorMessage(error),
189
+ fields: { runId: record.runId, taskId },
190
+ }));
191
+ }
167
192
  /**
168
193
  * A step label from an internal run that has outlived its sync grace window: nobody is watching
169
194
  * the tool call any more, so without this the run would be silent until it settles. Paced by the
@@ -211,7 +236,7 @@ export class SubAgentRunManager {
211
236
  this.cancelHandles.delete(record.runId);
212
237
  this.externalLaunches.delete(record.runId);
213
238
  this.internalProgressPacers.delete(record.runId);
214
- this.clearExternalRecoveryTimer(record.runId);
239
+ this.recovery.remove(record.runId);
215
240
  }
216
241
  get(runId) {
217
242
  return this.runs.get(runId);
@@ -353,10 +378,12 @@ export class SubAgentRunManager {
353
378
  }
354
379
  /** Persist best-effort probe results after the pid/launch recovery record is already durable.
355
380
  * A slow or unavailable `ps`/`--version` probe must never reopen the post-spawn recovery window. */
356
- async updateLaunchMetadata(runId, info) {
381
+ async updateLaunchMetadata(runId, info, launch) {
357
382
  await this.queue.run(runId, async () => {
358
383
  const record = this.runs.get(runId);
359
- if (!record || record.status !== "running" || !record.pid)
384
+ if (this.stopped || !record || !record.pid)
385
+ return;
386
+ if (launch && (record.pid !== launch.pid || record.processStartedAt !== launch.processStartedAt))
360
387
  return;
361
388
  if (info.pidStartedAt !== undefined)
362
389
  record.pidStartedAt = info.pidStartedAt;
@@ -365,42 +392,6 @@ export class SubAgentRunManager {
365
392
  await this.persist(record);
366
393
  });
367
394
  }
368
- /** Reserve a task wake exactly once. A replay of the same durable dispatch may resume an
369
- * interrupted activation, while copied text or a different dispatch id can never claim it. */
370
- async beginWakeConsumption(runId, taskId, dispatchId) {
371
- return this.queue.run(runId, async () => {
372
- const record = this.runs.get(runId);
373
- if (!record)
374
- return false;
375
- const expected = this.wakeDispatchId(runId);
376
- const eligible = record.settledAt !== undefined && record.taskId === taskId && dispatchId === expected;
377
- const previousClaim = record.wakeClaimDispatchId;
378
- if (!beginWakeClaim(record, eligible, dispatchId))
379
- return false;
380
- try {
381
- await this.persist(record, true);
382
- }
383
- catch (error) {
384
- record.wakeClaimDispatchId = previousClaim;
385
- throw error;
386
- }
387
- return true;
388
- });
389
- }
390
- async finishWakeConsumption(runId, dispatchId) {
391
- await this.queue.run(runId, async () => {
392
- const record = this.runs.get(runId);
393
- if (!record || !finishWakeClaim(record, dispatchId))
394
- return;
395
- try {
396
- await this.persist(record, true);
397
- }
398
- catch (error) {
399
- record.wakeConsumedAt = undefined;
400
- throw error;
401
- }
402
- });
403
- }
404
395
  /** Let a caller (subagent tool) register a way to abort this run's in-process worker. */
405
396
  registerCancelHandle(runId, cancel) {
406
397
  this.cancelHandles.set(runId, cancel);
@@ -408,18 +399,20 @@ export class SubAgentRunManager {
408
399
  /** Record why a still-running external run is about to be killed, before the signal is sent
409
400
  * (P1-1) — see the `terminationReason` field doc. A no-op once the run is no longer running.
410
401
  * Called by both the live in-process watcher (`external/run.ts`) and `sweep()` below. */
411
- async markTerminationReason(runId, reason) {
402
+ async markTerminationReason(runId, reason, required = false) {
412
403
  await this.queue.run(runId, async () => {
413
404
  const record = this.runs.get(runId);
414
405
  if (!record || record.status !== "running")
415
406
  return;
407
+ const previous = record.terminationReason;
416
408
  record.terminationReason = reason;
417
- await this.persist(record).catch((error) => {
418
- log.logWarn("subagent.persist.failed", "Termination reason persist failed", {
419
- reason: errorMessage(error),
420
- fields: { runId },
421
- });
422
- });
409
+ try {
410
+ await this.persist(record, required);
411
+ }
412
+ catch (error) {
413
+ record.terminationReason = previous;
414
+ throw error;
415
+ }
423
416
  });
424
417
  }
425
418
  clearCancelHandle(runId) {
@@ -464,7 +457,7 @@ export class SubAgentRunManager {
464
457
  await this.persist(record);
465
458
  this.cancelHandles.delete(runId);
466
459
  this.externalLaunches.delete(runId);
467
- this.clearExternalRecoveryTimer(runId);
460
+ this.recovery.remove(runId);
468
461
  this.stopExternalProgressTail(runId);
469
462
  this.internalProgressPacers.delete(runId);
470
463
  if (!record.usageRecorded) {
@@ -487,14 +480,18 @@ export class SubAgentRunManager {
487
480
  // is still around by the time the leader looks. Guarded by its own idempotency marker
488
481
  // inside the same settlement lock, so a replay writes nothing twice.
489
482
  if (!record.taskAccounted && record.taskId) {
490
- record.taskAccounted = true;
491
- await this.creditOwningTask(record, input, outputSaved).catch((error) => {
483
+ try {
484
+ await creditTaskForRun(this.target.deskDir, record, input, outputSaved, !options.announce);
485
+ record.taskAccounted = true;
486
+ await this.persist(record);
487
+ }
488
+ catch (error) {
492
489
  log.logWarn("subagent.task_settle.log_failed", "Task credit for run failed", {
493
490
  reason: errorMessage(error),
494
491
  fields: { runId: record.runId, taskId: record.taskId },
495
492
  });
496
- });
497
- await this.persist(record);
493
+ return; // Keep the unacknowledged terminal record eligible for retry.
494
+ }
498
495
  }
499
496
  if (record.wakeEnqueued)
500
497
  return;
@@ -504,28 +501,11 @@ export class SubAgentRunManager {
504
501
  return;
505
502
  }
506
503
  await this.announce(record, input.outputText, outputSaved);
504
+ log.logInfoEvent("subagent.settlement.committed", "Run settlement committed", {
505
+ fields: { desk: this.target.desk, runId, taskId: record.taskId, durationMs: record.durationMs },
506
+ });
507
507
  });
508
508
  }
509
- /**
510
- * Credit one settled run to the task that owns it: cost onto its usage, outcome onto its log.
511
- * Best-effort by design: a task whose file has since been archived or hand-deleted must not
512
- * block the completion wake.
513
- */
514
- async creditOwningTask(record, input, outputSaved) {
515
- const taskId = record.taskId;
516
- if (!taskId)
517
- return;
518
- await logTaskSettlement(this.target.deskDir, taskId, {
519
- ref: record.runId,
520
- item: record.item,
521
- status: record.status,
522
- verdict: record.purpose === "verify" ? record.verificationVerdict : undefined,
523
- output: outputSaved ? join(record.artifactDir, "output.md") : undefined,
524
- tail: input.outputText.slice(-WAKE_OUTPUT_TAIL_CHARS).trim() || undefined,
525
- changed: record.workspaceSummary,
526
- durationMs: input.durationMs,
527
- }, { usd: input.usage.cost.total, estimated: input.costKnown === false });
528
- }
529
509
  /**
530
510
  * Dispatch the completion wake. Durable-dispatch persists its own pending record before this
531
511
  * call can be interrupted (`DurableDispatchService.dispatch`), and `dispatch()` is idempotent on
@@ -533,6 +513,11 @@ export class SubAgentRunManager {
533
513
  * harmless — this is the same fix as jobs/manager's `announce()` reordering (D7).
534
514
  */
535
515
  async announce(record, outputText, outputSaved) {
516
+ if (record.taskId && !record.taskAccounted) {
517
+ await creditTaskForRun(this.target.deskDir, record, { outputText, durationMs: record.durationMs ?? 0, usage: record.usage, costKnown: record.costKnown }, outputSaved, false);
518
+ record.taskAccounted = true;
519
+ await this.persist(record);
520
+ }
536
521
  // P0-1: a settled notice fires whenever this run actually needs a wake — i.e. whenever the
537
522
  // caller was not already holding the result in the same tool call (`announce: true`, the same
538
523
  // condition that gates the wake below). It reaches the channel in roughly the time the run
@@ -544,6 +529,15 @@ export class SubAgentRunManager {
544
529
  status: record.status,
545
530
  durationMs: record.durationMs ?? 0,
546
531
  });
532
+ // A task-bound run reports to its task, not to a channel (spec 064, D19): the settle record
533
+ // is already in the task's log, so the lane only needs to look. A task that has since vanished
534
+ // has nowhere to read the result, so the run falls back to waking the chat.
535
+ if (record.taskId && (await readStoredTask(this.target.deskDir, record.taskId))) {
536
+ this.options.onTaskInput?.(this.target.desk, record.taskId);
537
+ record.wakeEnqueued = true;
538
+ await this.persist(record);
539
+ return;
540
+ }
547
541
  if (!this.options.dispatch)
548
542
  return;
549
543
  if (this.options.isBoundTo && !this.options.isBoundTo(record.channelId, this.target.desk)) {
@@ -579,24 +573,14 @@ export class SubAgentRunManager {
579
573
  await this.persist(record);
580
574
  }
581
575
  /**
582
- * Spec 058, D8: the run's channel left this desk, so the wake has no recipient. Settlement and the
583
- * task's settle record already happened; the wake is dropped (marker set, never replayed), and the
584
- * `work` ticket it would have redeemed is redeemed here via `redeemTicket`, so the suspended task
585
- * resumes as soon as its delivery channel is bound again.
576
+ * Spec 058, D8: the run's channel left this desk, so the chat wake has no recipient. Settlement
577
+ * already happened; the wake is dropped (marker set, never replayed).
586
578
  */
587
579
  async suppressWake(record) {
588
580
  log.logInfoEvent("subagent.wake.suppressed", "Completion wake dropped: channel not bound to the run's desk", {
589
581
  channelId: record.channelId,
590
- fields: { runId: record.runId, desk: this.target.desk, taskId: record.taskId },
582
+ fields: { runId: record.runId, desk: this.target.desk },
591
583
  });
592
- if (record.taskId) {
593
- await redeemTicket(this.target.deskDir, record.taskId, (ticket) => ticket.kind === "work").catch((error) => {
594
- log.logWarn("subagent.wake.redeem_failed", "Work ticket redeem for a dropped wake failed", {
595
- reason: errorMessage(error),
596
- fields: { runId: record.runId, taskId: record.taskId },
597
- });
598
- });
599
- }
600
584
  record.wakeEnqueued = true;
601
585
  await this.persist(record);
602
586
  }
@@ -637,7 +621,6 @@ export class SubAgentRunManager {
637
621
  // waiting for its one-shot deadline check.
638
622
  record.terminationReason = "cancelled";
639
623
  await this.persist(record).catch(() => undefined);
640
- await killProcessGroup(record.pid).catch(() => undefined);
641
624
  adoptedRecord = record;
642
625
  }
643
626
  else {
@@ -656,8 +639,7 @@ export class SubAgentRunManager {
656
639
  });
657
640
  if (!adoptedRecord)
658
641
  return status;
659
- this.clearExternalRecoveryTimer(runId);
660
- await this.reconcileExternalRun(adoptedRecord).catch((error) => {
642
+ await this.reconcileExternalRunAtDeadline(adoptedRecord).catch((error) => {
661
643
  log.logWarn("subagent.reconcile.failed", "Cancelled adopted run reconcile failed", {
662
644
  reason: errorMessage(error),
663
645
  fields: { runId },
@@ -750,6 +732,8 @@ export class SubAgentRunManager {
750
732
  fields: { runId: record?.runId },
751
733
  });
752
734
  });
735
+ if (record.status === "running" && record.runtime === "external")
736
+ this.recovery.add(record.runId);
753
737
  continue;
754
738
  }
755
739
  if (record.runtime === "internal" && record.status === "running") {
@@ -803,13 +787,13 @@ export class SubAgentRunManager {
803
787
  // Either an identity mismatch or an unavailable probe is settled as lost with the
804
788
  // uncertainty recorded, instead of silently degrading to an unprotected writer
805
789
  // (D10.1/D10.3).
806
- const processIdentity = record.pid ? await this.processIdentity(record) : "unknown";
790
+ const identity = record.pid ? await processIdentity(record) : "unknown";
807
791
  let processSafetyNote;
808
- if (processIdentity === "same") {
792
+ if (identity === "same") {
809
793
  await killProcessGroup(record.pid).catch(() => undefined);
810
794
  processSafetyNote = " The adopted process identity matched and its process group was signalled.";
811
795
  }
812
- else if (processIdentity === "different") {
796
+ else if (identity === "different") {
813
797
  processSafetyNote =
814
798
  " The persisted pid identity did not match the current process; no signal was sent.";
815
799
  }
@@ -853,7 +837,7 @@ export class SubAgentRunManager {
853
837
  });
854
838
  });
855
839
  if (record.status === "running")
856
- this.scheduleExternalRecovery(record);
840
+ this.recovery.add(record.runId);
857
841
  }
858
842
  if (isTerminal(record.status) && record.settledAt) {
859
843
  // A settled-but-unwoken record means the wake was lost between settlement and
@@ -873,160 +857,57 @@ export class SubAgentRunManager {
873
857
  }
874
858
  return restored;
875
859
  }
876
- /** Whether `record.pid` is still the same process that was launched, when that can be checked
877
- * at all (D10.3). A missing `pidStartedAt` (an older record, or a `ps` that failed once at
878
- * launch) means there is nothing to compare against — trust `isProcessAlive` alone rather
879
- * than manufacture a false negative. */
880
- async isSameProcess(record) {
881
- if (!record.pid)
882
- return false;
883
- if (!record.pidStartedAt)
884
- return true;
885
- const current = await readProcessStartTime(record.pid);
886
- return current === record.pidStartedAt;
887
- }
888
- async processIdentity(record) {
889
- if (!record.pid || !record.pidStartedAt)
890
- return "unknown";
891
- const current = await readProcessStartTime(record.pid);
892
- if (!current)
893
- return "unknown";
894
- return current === record.pidStartedAt ? "same" : "different";
860
+ /** The lane retries task receipts before it decides a wait has no result. */
861
+ async retryTaskSettlements() {
862
+ for (const record of this.runs.values()) {
863
+ if (!record.taskId || !record.settledAt || record.taskAccounted)
864
+ continue;
865
+ await this.queue.run(record.runId, async () => {
866
+ if (record.taskAccounted)
867
+ return;
868
+ const output = await readFile(join(record.artifactDir, "output.md"), "utf-8").catch(() => "");
869
+ await this.announce(record, output, Boolean(output));
870
+ });
871
+ }
895
872
  }
896
- /**
897
- * Restart reconciliation for an external run still marked `running` (D10.3), and the terminal
898
- * judgement `sweep()` uses once an adopted run's process is confirmed gone. Unlike internal
899
- * runs, a `detached` external process outlives the daemon, so the first move is a liveness
900
- * probe, not an automatic `lost`:
901
- *
902
- * - no `pid` at all: the intent was persisted but spawn was never confirmed — cannot prove it
903
- * ever started, so it is judged `lost` the same as an internal run (D1).
904
- * - `pid` alive under the same identity: genuinely still running. Left alone.
905
- * - `pid` gone (or reused by an unrelated process): the process finished, died, or was killed
906
- * while the daemon was down. `finalizeExternalRun` (spec 042 D1) parses whatever the process
907
- * actually wrote before applying `terminationReason` — the same sequence the live post-exit
908
- * path uses, so a reconciled run never loses usage, output, session id, or its verify verdict
909
- * just because the daemon happened to be down when the run finished.
910
- */
911
873
  async reconcileExternalRun(record) {
912
- if (!record.pid) {
913
- await this.settle(record.runId, {
914
- status: "lost",
915
- failureReason: "No pid was ever recorded for this run; it cannot be proven to have started.",
916
- usage: record.usage,
917
- usageKnown: record.usageKnown,
918
- costKnown: record.costKnown,
919
- turns: record.turns ?? 0,
920
- toolCalls: record.toolCalls ?? 0,
921
- durationMs: Date.now() - record.startedAt,
922
- durationEstimated: true,
923
- outputText: "",
924
- }, { announce: true });
925
- return;
926
- }
927
- if (isProcessAlive(record.pid) && (await this.isSameProcess(record))) {
928
- return; // Still genuinely running; nothing to reconcile yet.
929
- }
930
- if (!record.harness) {
931
- // Defensive only: external runs always get a harness at register() time (spec 040 D1).
932
- await this.settle(record.runId, {
933
- status: "failed",
934
- failureReason: "Run has no recorded harness; cannot judge it.",
935
- usage: record.usage,
936
- usageKnown: record.usageKnown,
937
- costKnown: record.costKnown,
938
- turns: record.turns ?? 0,
939
- toolCalls: record.toolCalls ?? 0,
940
- durationMs: Date.now() - record.startedAt,
941
- durationEstimated: true,
942
- outputText: "",
943
- }, { announce: true });
944
- return;
945
- }
946
- // Duration can only be estimated post-restart: the artifact file's own mtime is the closest
947
- // proxy for "when the process last wrote something" (D1); wall clock from the last known
948
- // process start is the fallback when the file is missing (e.g. already GC'd).
949
- const processStartedAt = record.processStartedAt ?? record.startedAt;
950
- let durationMs = Date.now() - processStartedAt;
951
- try {
952
- const eventsStat = await stat(join(record.artifactDir, "events.jsonl"));
953
- durationMs = eventsStat.mtimeMs - processStartedAt;
954
- }
955
- catch {
956
- // No events file (or already GC'd) — fall back to the wall-clock estimate above.
957
- }
958
- const maxWallTimeSec = record.maxWallTimeSec ??
959
- (record.deadlineAt ? Math.round((record.deadlineAt - record.startedAt) / 1000) : undefined);
960
- await finalizeExternalRun({
961
- harnessId: record.harness,
962
- purpose: record.purpose,
963
- workingDirectory: record.workingDirectory,
964
- artifactDir: record.artifactDir,
965
- exitCode: undefined,
966
- durationMs: Math.max(0, durationMs),
967
- durationEstimated: true,
968
- terminationReason: record.terminationReason,
969
- maxWallTimeSec,
970
- mutates: record.mutates,
971
- workspaceBaseline: record.workspaceBaseline,
972
- }, (settleInput, options) => this.settle(record.runId, settleInput, options), { announce: record.terminationReason !== "cancelled" });
874
+ await reconcileExternalRun(record, (id, input, options) => this.settle(id, input, options), () => !this.stopped && this.runs.get(record.runId) === record && record.status === "running");
973
875
  }
974
- /** Reconcile an adopted process once at restore and once at its persisted deadline. Probing
975
- * liveness before assigning a timeout lets a process that finished just before the deadline be
976
- * settled from its artifacts as a normal completion. */
977
876
  async reconcileExternalRunAtDeadline(record, now = Date.now()) {
978
- if (record.pid &&
979
- record.deadlineAt &&
980
- now >= record.deadlineAt &&
981
- record.terminationReason !== "timeout" &&
982
- isProcessAlive(record.pid) &&
983
- (await this.isSameProcess(record))) {
984
- await this.markTerminationReason(record.runId, "timeout");
985
- await killProcessGroup(record.pid).catch(() => undefined);
986
- }
987
- await this.reconcileExternalRun(record);
988
- }
989
- clearExternalRecoveryTimer(runId) {
990
- const timer = this.externalRecoveryTimers.get(runId);
991
- if (!timer)
992
- return;
993
- clearTimeout(timer);
994
- this.externalRecoveryTimers.delete(runId);
995
- }
996
- scheduleExternalRecovery(record) {
997
- if (this.stopped)
998
- return;
999
- if (!record.deadlineAt)
1000
- return;
1001
- this.clearExternalRecoveryTimer(record.runId);
1002
- const timer = setTimeout(() => {
1003
- this.externalRecoveryTimers.delete(record.runId);
1004
- const current = this.runs.get(record.runId);
1005
- if (!current || current.status !== "running")
877
+ await this.recoveryQueue.run(record.runId, async () => {
878
+ if (this.stopped || record.status !== "running")
879
+ return;
880
+ if (record.settlementPending && !record.settledAt) {
881
+ const pending = record.settlementPending;
882
+ const outputText = await readFile(join(record.artifactDir, "output.md"), "utf-8").catch(() => "");
883
+ if (!this.stopped)
884
+ await this.settle(record.runId, { ...pending, outputText }, { announce: pending.announce });
1006
885
  return;
1007
- // Timers can fire just before their wall-clock deadline. Re-arm rather than losing
1008
- // the only recovery check and leaving an adopted process running indefinitely.
1009
- if (current.deadlineAt && Date.now() < current.deadlineAt) {
1010
- this.scheduleExternalRecovery(current);
886
+ }
887
+ const identity = await processIdentity(record);
888
+ if (this.stopped || record.status !== "running")
1011
889
  return;
890
+ if (record.pid &&
891
+ isProcessAlive(record.pid) &&
892
+ identity === "same" &&
893
+ (record.terminationReason || (record.deadlineAt && now >= record.deadlineAt))) {
894
+ if (!record.terminationReason)
895
+ await this.markTerminationReason(record.runId, "timeout", true);
896
+ if (this.stopped || record.status !== "running")
897
+ return;
898
+ await killProcessGroup(record.pid);
1012
899
  }
1013
- void this.reconcileExternalRunAtDeadline(current).catch((error) => {
1014
- log.logWarn("subagent.reconcile.failed", "Adopted external run reconcile failed", {
1015
- reason: errorMessage(error),
1016
- fields: { runId: current.runId },
1017
- });
1018
- });
1019
- }, Math.max(0, record.deadlineAt - Date.now()));
1020
- timer.unref?.();
1021
- this.externalRecoveryTimers.set(record.runId, timer);
900
+ if (!this.stopped)
901
+ await this.reconcileExternalRun(record);
902
+ });
1022
903
  }
1023
904
  /**
1024
905
  * Daily retention GC. A settled run and all runtime-managed artifacts are deleted together once
1025
- * they are at least seven days old. Other files deliberately created by the delegated task are
906
+ * they are at least 30 days old. Other files deliberately created by the delegated task are
1026
907
  * not recursively removed from the artifact directory.
1027
908
  */
1028
909
  async collectGarbageIfExpired(record, now = Date.now()) {
1029
- if (!record.settledAt)
910
+ if (!record.settledAt || (record.taskId && !record.taskAccounted))
1030
911
  return;
1031
912
  if (now - record.settledAt >= RUN_RETENTION_MS) {
1032
913
  await this.forget(record);
@@ -0,0 +1,3 @@
1
+ import type { RunRecord, SettleInput } from "./run-record.js";
2
+ /** Map settled run facts to the task journal; the run manager owns acknowledgment and retries. */
3
+ export declare function creditTaskForRun(deskDir: string, record: RunRecord, input: Pick<SettleInput, "outputText" | "durationMs" | "usage" | "costKnown">, outputSaved: boolean, inline: boolean): Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { join } from "node:path";
2
+ import { logTaskSettlement } from "../tasks/bound-work.js";
3
+ import { WAKE_OUTPUT_TAIL_CHARS } from "./completion-wake.js";
4
+ /** Map settled run facts to the task journal; the run manager owns acknowledgment and retries. */
5
+ export async function creditTaskForRun(deskDir, record, input, outputSaved, inline) {
6
+ const taskId = record.taskId;
7
+ if (!taskId)
8
+ return;
9
+ await logTaskSettlement(deskDir, taskId, {
10
+ ref: record.runId,
11
+ item: record.item,
12
+ status: record.status,
13
+ verdict: record.purpose === "verify" ? record.verificationVerdict : undefined,
14
+ output: outputSaved ? join(record.artifactDir, "output.md") : undefined,
15
+ tail: input.outputText.slice(-WAKE_OUTPUT_TAIL_CHARS).trim() || undefined,
16
+ changed: record.workspaceSummary,
17
+ durationMs: input.durationMs,
18
+ ...(inline ? { inline: true } : {}),
19
+ }, { usd: input.usage.cost.total, estimated: false, known: input.costKnown });
20
+ }
@@ -57,7 +57,6 @@ export interface DelegationParams {
57
57
  task: string;
58
58
  workingDirectory?: string;
59
59
  purpose?: "work" | "verify";
60
- taskId?: string;
61
60
  item?: string;
62
61
  }
63
62
  export interface SubAgentWorker {
@@ -128,7 +127,7 @@ export interface SubAgentToolOptions {
128
127
  buildTools?: BuildSubagentTools;
129
128
  /** Test-only override for the D6 convergence-turn wall clock; defaults to CONVERGENCE_WALL_CLOCK_MS. */
130
129
  convergenceWallClockMs?: number;
131
- /** Test-only override for the D2 sync grace window; defaults to SYNC_GRACE_MS. */
130
+ /** Test-only override for the D2 sync grace window; defaults to CHAT_SYNC_GRACE_MS for chat; task dispatch never waits for the worker. */
132
131
  syncGraceMs?: number;
133
132
  /** Test-only override for the transient-error retry backoff base; defaults to RETRY_BASE_DELAY_MS. */
134
133
  retryBaseDelayMs?: number;
@@ -3,13 +3,17 @@ import { stat } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { promisify } from "node:util";
5
5
  const execFileAsync = promisify(execFile);
6
+ const GIT_STATUS_TIMEOUT_MS = 1_000;
6
7
  /** Past this many dirty paths a baseline is not worth persisting on every run record; the summary
7
8
  * then falls back to the raw status and says so. */
8
9
  const BASELINE_MAX_ENTRIES = 500;
9
10
  async function readPorcelain(workingDirectory) {
10
11
  try {
11
12
  const args = ["-C", workingDirectory, "status", "--porcelain=v1", "--untracked-files=all"];
12
- const { stdout } = await execFileAsync("git", args, { maxBuffer: 4 * 1024 * 1024 });
13
+ const { stdout } = await execFileAsync("git", args, {
14
+ maxBuffer: 4 * 1024 * 1024,
15
+ timeout: GIT_STATUS_TIMEOUT_MS,
16
+ });
13
17
  return stdout
14
18
  .split("\n")
15
19
  .map((line) => line.trimEnd())
@@ -0,0 +1,11 @@
1
+ import type { TaskArchiveOutcome, TaskFrontmatter } from "./frontmatter.js";
2
+ /** A current-format crash-recovery record, removed only after publication and source cleanup. */
3
+ export declare function taskArchiveCommitPath(deskDir: string, id: string): string;
4
+ export declare function isTaskArchiving(deskDir: string, id: string): boolean;
5
+ /** Snapshot once, publish all shards, then clean up. Ordinary I/O failures and SIGKILL use the same recovery path. */
6
+ export declare function commitTaskArchive(deskDir: string, id: string, document?: {
7
+ fields: TaskFrontmatter;
8
+ body: string;
9
+ }, outcome?: TaskArchiveOutcome, closedAt?: string): Promise<void>;
10
+ /** Only unfinished closes are enumerated, never the growing historical archive. */
11
+ export declare function recoverTaskArchives(deskDir: string): Promise<void>;