@xzzpig/pi-subagents 0.24.2 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bundle/agent-management.js +4 -4
  3. package/bundle/agents.js +3 -3
  4. package/bundle/child-tool-plan.js +2 -2
  5. package/bundle/chunk-34TUUBRN.js +1107 -0
  6. package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
  7. package/bundle/{chunk-XWWUDWUW.js → chunk-5YEOWNSD.js} +371 -135
  8. package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
  9. package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
  10. package/bundle/{chunk-4UH4WS4G.js → chunk-6MNRKUHY.js} +23 -12
  11. package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
  12. package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
  13. package/bundle/chunk-HXRB42AF.js +108 -0
  14. package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
  15. package/bundle/{chunk-CYY5UMJU.js → chunk-IJWITCC6.js} +411 -249
  16. package/bundle/{chunk-RU522D5W.js → chunk-IKFKH5EL.js} +369 -50
  17. package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
  18. package/bundle/{chunk-JEA2ZKUA.js → chunk-IUDEI6FJ.js} +35 -200
  19. package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
  20. package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
  21. package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
  22. package/bundle/{chunk-224WMDIV.js → chunk-KCJFGKVK.js} +350 -123
  23. package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
  24. package/bundle/chunk-LYKG4FKH.js +523 -0
  25. package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
  26. package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
  27. package/bundle/{chunk-BQ2OAB4Q.js → chunk-OSVXFWPG.js} +67 -30
  28. package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
  29. package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
  30. package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
  31. package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
  32. package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
  33. package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
  34. package/bundle/{chunk-O4D5PBVI.js → chunk-YWXILP5N.js} +3 -2
  35. package/bundle/control-channel.js +2 -2
  36. package/bundle/index.js +1 -1
  37. package/bundle/intercom-bridge.js +2 -2
  38. package/bundle/preflight.js +12 -10
  39. package/bundle/project-panes.js +3 -3
  40. package/bundle/workflow-resources.js +1 -1
  41. package/docs/agents.md +27 -6
  42. package/docs/configuration.md +20 -8
  43. package/docs/extension-api.md +18 -1
  44. package/docs/models.md +6 -2
  45. package/docs/observability.md +2 -0
  46. package/docs/tool-reference.md +7 -1
  47. package/docs/workflows.md +30 -2
  48. package/package.json +2 -2
  49. package/skills/pi-subagents/SKILL.md +15 -6
  50. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  51. package/src/agents/agent-management.d.ts +1 -0
  52. package/src/agents/agent-management.js +46 -18
  53. package/src/agents/agent-memory.d.ts +1 -4
  54. package/src/agents/agent-memory.js +1 -4
  55. package/src/agents/agent-serializer.d.ts +2 -0
  56. package/src/agents/agent-serializer.js +1 -1
  57. package/src/agents/agents.d.ts +2 -3
  58. package/src/agents/agents.js +46 -20
  59. package/src/agents/frontmatter.js +1 -8
  60. package/src/agents/global-npm-root.d.ts +1 -0
  61. package/src/agents/global-npm-root.js +11 -3
  62. package/src/agents/skills.d.ts +0 -3
  63. package/src/agents/skills.js +0 -3
  64. package/src/api/preflight.d.ts +3 -1
  65. package/src/api/preflight.js +2 -0
  66. package/src/extension/config.d.ts +1 -0
  67. package/src/extension/config.js +13 -1
  68. package/src/extension/herdr-pi-bridge.js +10 -2
  69. package/src/extension/index.d.ts +0 -13
  70. package/src/extension/index.js +51 -37
  71. package/src/extension/public-execution.d.ts +1 -0
  72. package/src/extension/public-execution.js +4 -0
  73. package/src/extension/reply-workflow-script.js +24 -4
  74. package/src/extension/schemas.d.ts +12 -3
  75. package/src/extension/schemas.js +7 -3
  76. package/src/extension/session-switch.d.ts +25 -0
  77. package/src/extension/session-switch.js +138 -0
  78. package/src/extension/subagent-guide.d.ts +1 -1
  79. package/src/extension/subagent-guide.js +1 -1
  80. package/src/extension/subagent-launch-tool.d.ts +25 -0
  81. package/src/extension/subagent-launch-tool.js +48 -0
  82. package/src/extension/tool-activation.js +55 -15
  83. package/src/extension/tool-description.d.ts +1 -1
  84. package/src/extension/tool-description.js +14 -8
  85. package/src/inspectors/herdr/actions.d.ts +0 -1
  86. package/src/inspectors/herdr/actions.js +0 -1
  87. package/src/inspectors/session-roots-codec.d.ts +0 -1
  88. package/src/inspectors/session-roots-codec.js +0 -1
  89. package/src/inspectors/tmux/actions.d.ts +0 -1
  90. package/src/inspectors/tmux/actions.js +0 -1
  91. package/src/integrations/herdr-status.js +3 -8
  92. package/src/intercom/native-supervisor-channel.js +65 -9
  93. package/src/runs/background/async-execution.d.ts +7 -10
  94. package/src/runs/background/async-execution.js +66 -29
  95. package/src/runs/background/async-job-tracker.js +12 -0
  96. package/src/runs/background/async-resume.d.ts +2 -1
  97. package/src/runs/background/async-resume.js +114 -40
  98. package/src/runs/background/async-retention.d.ts +0 -2
  99. package/src/runs/background/async-retention.js +17 -6
  100. package/src/runs/background/async-status.d.ts +2 -0
  101. package/src/runs/background/async-status.js +4 -0
  102. package/src/runs/background/auto-drain.js +2 -1
  103. package/src/runs/background/boot-id.d.ts +1 -3
  104. package/src/runs/background/boot-id.js +1 -3
  105. package/src/runs/background/completion-batcher.d.ts +3 -4
  106. package/src/runs/background/completion-batcher.js +2 -3
  107. package/src/runs/background/control-channel.d.ts +0 -6
  108. package/src/runs/background/control-channel.js +0 -6
  109. package/src/runs/background/fleet-view.js +2 -3
  110. package/src/runs/background/notify.d.ts +0 -2
  111. package/src/runs/background/notify.js +0 -2
  112. package/src/runs/background/result-watcher.d.ts +1 -0
  113. package/src/runs/background/result-watcher.js +59 -29
  114. package/src/runs/background/resume-guidance.js +4 -2
  115. package/src/runs/background/retained-children.js +2 -1
  116. package/src/runs/background/run-child-session.d.ts +2 -3
  117. package/src/runs/background/run-child-session.js +5 -8
  118. package/src/runs/background/run-status.js +9 -7
  119. package/src/runs/background/runner-aliases.js +15 -0
  120. package/src/runs/background/scheduled-runs.d.ts +3 -1
  121. package/src/runs/background/scheduled-runs.js +13 -16
  122. package/src/runs/background/steering.d.ts +2 -11
  123. package/src/runs/background/steering.js +11 -6
  124. package/src/runs/background/subagent-runner.d.ts +2 -6
  125. package/src/runs/background/subagent-runner.js +88 -70
  126. package/src/runs/background/subagent-wait.js +12 -15
  127. package/src/runs/background/wait-config.d.ts +2 -0
  128. package/src/runs/background/wait-config.js +17 -3
  129. package/src/runs/background/wait-subscriptions.js +124 -12
  130. package/src/runs/background/wait-tool.js +4 -2
  131. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  132. package/src/runs/background/workflow-terminal-proof.js +0 -1
  133. package/src/runs/foreground/async-steering-action.js +24 -9
  134. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  135. package/src/runs/foreground/async-stop-action.js +9 -1
  136. package/src/runs/foreground/execution.d.ts +0 -3
  137. package/src/runs/foreground/execution.js +56 -24
  138. package/src/runs/foreground/prompt-audit.js +1 -0
  139. package/src/runs/foreground/subagent-executor.d.ts +5 -10
  140. package/src/runs/foreground/subagent-executor.js +164 -49
  141. package/src/runs/shared/acceptance.js +69 -26
  142. package/src/runs/shared/async-status-projection.d.ts +2 -0
  143. package/src/runs/shared/async-status-projection.js +10 -0
  144. package/src/runs/shared/child-commands.js +15 -2
  145. package/src/runs/shared/child-hooks.d.ts +1 -7
  146. package/src/runs/shared/child-hooks.js +13 -5
  147. package/src/runs/shared/child-launch.js +6 -2
  148. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  149. package/src/runs/shared/child-session.d.ts +6 -5
  150. package/src/runs/shared/child-session.js +85 -38
  151. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  152. package/src/runs/shared/child-tool-plan.js +0 -1
  153. package/src/runs/shared/claude-code-adapter.js +11 -0
  154. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  155. package/src/runs/shared/external-cli-contract.js +18 -13
  156. package/src/runs/shared/external-cli-runner.js +26 -6
  157. package/src/runs/shared/herdr-connection.js +2 -1
  158. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  159. package/src/runs/shared/herdr-pane-host.js +17 -1
  160. package/src/runs/shared/herdr-placed-run.js +51 -24
  161. package/src/runs/shared/lane-metadata.d.ts +0 -1
  162. package/src/runs/shared/lane-metadata.js +0 -1
  163. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  164. package/src/runs/shared/mcp-config-sources.js +1 -1
  165. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  166. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  167. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  168. package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
  169. package/src/runs/shared/model-resolution.d.ts +20 -5
  170. package/src/runs/shared/model-resolution.js +55 -50
  171. package/src/runs/shared/model-scope.d.ts +1 -5
  172. package/src/runs/shared/model-scope.js +1 -5
  173. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  174. package/src/runs/shared/mutation-evidence.js +52 -7
  175. package/src/runs/shared/nested-events.d.ts +1 -0
  176. package/src/runs/shared/nested-events.js +1 -1
  177. package/src/runs/shared/parallel-utils.d.ts +0 -1
  178. package/src/runs/shared/permissions.js +5 -3
  179. package/src/runs/shared/placement-host.d.ts +5 -1
  180. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  181. package/src/runs/shared/rex-pane-host.js +0 -2
  182. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  183. package/src/runs/shared/run-launch-folder.js +21 -0
  184. package/src/runs/shared/runner-launcher.d.ts +12 -1
  185. package/src/runs/shared/runner-launcher.js +16 -0
  186. package/src/runs/shared/single-output.d.ts +3 -3
  187. package/src/runs/shared/single-output.js +5 -3
  188. package/src/runs/shared/structured-output.d.ts +8 -0
  189. package/src/runs/shared/structured-output.js +40 -5
  190. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  191. package/src/runs/shared/subagent-prompt-runtime.js +18 -4
  192. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  193. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  194. package/src/runs/shared/tool-timeout.js +2 -1
  195. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  196. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  197. package/src/runs/shared/worktree.d.ts +3 -0
  198. package/src/runs/shared/worktree.js +20 -0
  199. package/src/shared/artifacts.d.ts +1 -0
  200. package/src/shared/artifacts.js +132 -22
  201. package/src/shared/capacity-resilient-json.d.ts +1 -1
  202. package/src/shared/child-cache-retention.d.ts +1 -2
  203. package/src/shared/child-cache-retention.js +1 -2
  204. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  205. package/src/shared/fleet-transcript-reader.js +333 -0
  206. package/src/shared/formatters.d.ts +0 -18
  207. package/src/shared/formatters.js +0 -18
  208. package/src/shared/pruned-fork.js +2 -2
  209. package/src/shared/reported-progress.d.ts +1 -0
  210. package/src/shared/reported-progress.js +12 -0
  211. package/src/shared/session-succession.d.ts +16 -1
  212. package/src/shared/session-succession.js +41 -2
  213. package/src/shared/session-warnings.d.ts +7 -0
  214. package/src/shared/session-warnings.js +26 -0
  215. package/src/shared/settings.d.ts +0 -23
  216. package/src/shared/settings.js +3 -35
  217. package/src/shared/status-format.d.ts +1 -0
  218. package/src/shared/status-format.js +1 -1
  219. package/src/shared/types.d.ts +108 -59
  220. package/src/shared/types.js +0 -12
  221. package/src/shared/utils.d.ts +3 -15
  222. package/src/shared/utils.js +4 -22
  223. package/src/shared/wait-tool-name.d.ts +8 -0
  224. package/src/shared/wait-tool-name.js +13 -0
  225. package/src/slash/slash-commands.js +2 -1
  226. package/src/slash/subagent-cost.d.ts +3 -2
  227. package/src/slash/subagent-cost.js +22 -3
  228. package/src/slash/subagents-admin.js +0 -1
  229. package/src/tui/fleet-status.d.ts +0 -5
  230. package/src/tui/fleet-status.js +4 -24
  231. package/src/tui/fleet.js +6 -4
  232. package/src/tui/render.d.ts +0 -9
  233. package/src/tui/render.js +194 -68
  234. package/src/tui/subagent-messages.js +3 -2
  235. package/src/watchdog/model-selection.js +2 -2
  236. package/src/watchdog/permission-arbiter.js +1 -0
  237. package/src/watchdog/register-child.d.ts +2 -3
  238. package/src/watchdog/register-child.js +2 -3
  239. package/src/watchdog/review.d.ts +0 -5
  240. package/src/watchdog/review.js +4 -3
  241. package/src/watchdog/turn-delta.js +2 -1
  242. package/src/workflows/scripted-workflow.d.ts +2 -0
  243. package/src/workflows/scripted-workflow.js +344 -59
  244. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  245. package/src/workflows/structured-workflow-scripts.js +32 -11
  246. package/src/workflows/workflow-launch-record.d.ts +15 -6
  247. package/src/workflows/workflow-launch-record.js +30 -12
  248. package/src/workflows/workflow-receipt.js +36 -53
  249. package/src/workflows/workflow-resources.js +4 -4
  250. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  251. package/src/workflows/workflow-resume-claim.js +3 -3
  252. package/src/workflows/workflow-resume.d.ts +1 -1
  253. package/src/workflows/workflow-resume.js +13 -8
  254. package/src/workflows/workflow-script-worker.d.ts +13 -0
  255. package/src/workflows/workflow-script-worker.js +81 -0
  256. package/workflow-script-process.cjs +36 -0
  257. package/workflow-script-worker.cjs +4 -1
  258. package/bundle/chunk-U4ODUYAG.js +0 -235
@@ -11,6 +11,7 @@ import { FileLeaseBusyError } from "../../shared/file-lease.js";
11
11
  import { recordWaitCompletion } from "./wait-completions.js";
12
12
  import { syncMissionFromAsyncCompletion } from "../../missions/lifecycle.js";
13
13
  import { acknowledgeMissionObserverSnapshot, missionObserverIndexPath, missionObserverResultCandidateFiles, promotePendingResultFile, readResultPayload, resultCandidateFilesForSession, resultPayloadPathForIndexedRun, resultPayloadPathForMissionObserverRun, resultPayloadPathForSessionRun, resultSnapshotReplaced, retireResultSnapshot, withResultRunLease, writeAsyncResultFile, writeResultIndexForData } from "./result-files.js";
14
+ import { reportSessionWarning } from "../../shared/session-warnings.js";
14
15
  const WATCHER_RESTART_DELAY_MS = 3000;
15
16
  const POLL_INTERVAL_MS = 3000;
16
17
  const HEALTHY_SCAN_INTERVAL_MS = 60_000;
@@ -47,16 +48,20 @@ function resultFileIdentity(raw, file) {
47
48
  runId: file.replace(/\.json$/i, ""),
48
49
  };
49
50
  }
50
- function sanitizeNestedResultChildren(value, resultPath, label) {
51
+ function reportResultWatcherWarning(state, message, error, key = message) {
52
+ const detail = error === undefined ? "" : `: ${error instanceof Error ? error.message : String(error)}`;
53
+ reportSessionWarning(state, `${message}${detail}`, key);
54
+ }
55
+ function sanitizeNestedResultChildren(state, value, resultPath, label) {
51
56
  if (value === undefined)
52
57
  return undefined;
53
58
  if (!Array.isArray(value)) {
54
- console.error(`Ignoring invalid nested children in subagent result file '${resultPath}' at ${label}: expected an array.`);
59
+ reportResultWatcherWarning(state, `Ignoring invalid nested children in subagent result file '${resultPath}' at ${label}: expected an array.`);
55
60
  return undefined;
56
61
  }
57
62
  const children = value.map((child) => sanitizeSummary(child)).filter((child) => Boolean(child));
58
63
  if (children.length !== value.length) {
59
- console.error(`Ignoring ${value.length - children.length} invalid nested child record(s) in subagent result file '${resultPath}' at ${label}.`);
64
+ reportResultWatcherWarning(state, `Ignoring ${value.length - children.length} invalid nested child record(s) in subagent result file '${resultPath}' at ${label}.`, undefined, `result-nested-records-invalid:${resultPath}:${label}`);
60
65
  }
61
66
  return children.length ? children : undefined;
62
67
  }
@@ -114,6 +119,8 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
114
119
  // Result file -> last logged mission-sync error. A failed sync is retried
115
120
  // every pass, so the same error is logged once per result file.
116
121
  const reportedMissionSyncFailures = new Map();
122
+ // reportedMissionSyncFailures decides when to report; each report gets its own key so the session warning dedupe never hides it.
123
+ let missionSyncReports = 0;
117
124
  let deliveryActive = true;
118
125
  let deliveryEpoch = 0;
119
126
  let resultScanTimer = null;
@@ -145,7 +152,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
145
152
  }
146
153
  catch (error) {
147
154
  if (!isAbsentResultCandidate(error))
148
- console.error(`Failed to inspect subagent result file '${publicResultPath(file)}':`, error);
155
+ reportResultWatcherWarning(state, `Failed to inspect subagent result file '${publicResultPath(file)}'`, error);
149
156
  return false;
150
157
  }
151
158
  };
@@ -187,7 +194,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
187
194
  if (isAccessDenied(error))
188
195
  throw error;
189
196
  if (!isAbsentResultCandidate(error))
190
- console.error(`Failed to inspect subagent result file '${resultPath}':`, error);
197
+ reportResultWatcherWarning(state, `Failed to inspect subagent result file '${resultPath}'`, error);
191
198
  return undefined;
192
199
  }
193
200
  };
@@ -211,7 +218,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
211
218
  if (isAccessDenied(error))
212
219
  throw error;
213
220
  if (!isAbsentResultCandidate(error))
214
- console.error(`Failed to inspect subagent result file '${resultPath}':`, error);
221
+ reportResultWatcherWarning(state, `Failed to inspect subagent result file '${resultPath}'`, error);
215
222
  return undefined;
216
223
  }
217
224
  };
@@ -220,7 +227,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
220
227
  return new Set(deps.observedCompletionRunIds?.() ?? []);
221
228
  }
222
229
  catch (error) {
223
- console.error("Failed to inspect observed subagent completion ids:", error);
230
+ reportResultWatcherWarning(state, "Failed to inspect observed subagent completion ids", error);
224
231
  return new Set();
225
232
  }
226
233
  };
@@ -253,7 +260,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
253
260
  if (isAbsentResultCandidate(error))
254
261
  return;
255
262
  if (!(error instanceof FileLeaseBusyError))
256
- console.error(`Failed to remove delivered subagent result '${publicResultPath(file)}'; will retry:`, error);
263
+ reportResultWatcherWarning(state, `Failed to remove delivered subagent result '${publicResultPath(file)}'; will retry`, error);
257
264
  scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
258
265
  }
259
266
  };
@@ -272,7 +279,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
272
279
  catch (error) {
273
280
  if (!isAccessDenied(error))
274
281
  throw error;
275
- console.error(`Failed to inspect subagent result file '${publicResultPath(file)}'; will retry:`, error);
282
+ reportResultWatcherWarning(state, `Failed to inspect subagent result file '${publicResultPath(file)}'; will retry`, error);
276
283
  scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
277
284
  return;
278
285
  }
@@ -330,7 +337,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
330
337
  catch (error) {
331
338
  if (isAccessDenied(error))
332
339
  throw error;
333
- console.error(`Failed to re-read subagent result file '${publicResultPath(file)}':`, error);
340
+ reportResultWatcherWarning(state, `Failed to re-read subagent result file '${publicResultPath(file)}'`, error);
334
341
  }
335
342
  identityCache.delete(file);
336
343
  rereadReplacedPayload = true;
@@ -346,7 +353,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
346
353
  const message = error instanceof Error ? error.message : String(error);
347
354
  if (reportedMissionSyncFailures.get(file) !== message) {
348
355
  reportedMissionSyncFailures.set(file, message);
349
- console.error(`Mission completion sync failed for '${resultPath}':`, error);
356
+ reportResultWatcherWarning(state, `Mission completion sync failed for '${resultPath}'`, error, `result-mission-sync-failed:${++missionSyncReports}`);
350
357
  }
351
358
  }
352
359
  try {
@@ -354,7 +361,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
354
361
  }
355
362
  catch (error) {
356
363
  observerSucceeded = false;
357
- console.error(`Completion observer failed for '${resultPath}':`, error);
364
+ reportResultWatcherWarning(state, `Completion observer failed for '${resultPath}'`, error);
358
365
  }
359
366
  if (observerSucceeded) {
360
367
  try {
@@ -364,7 +371,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
364
371
  catch (error) {
365
372
  observerSucceeded = false;
366
373
  if (!(error instanceof FileLeaseBusyError))
367
- console.error(`Failed to acknowledge the mission observer for '${resultPath}'; will retry:`, error);
374
+ reportResultWatcherWarning(state, `Failed to acknowledge the mission observer for '${resultPath}'; will retry`, error);
368
375
  }
369
376
  }
370
377
  const epoch = deliveryEpoch;
@@ -377,13 +384,13 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
377
384
  sessionId,
378
385
  });
379
386
  const hasExplicitNestedChildren = data.nestedChildren !== undefined;
380
- let nestedChildren = compactNestedResultChildren(sanitizeNestedResultChildren(data.nestedChildren, resultPath, "nestedChildren"));
387
+ let nestedChildren = compactNestedResultChildren(sanitizeNestedResultChildren(state, data.nestedChildren, resultPath, "nestedChildren"));
381
388
  if (!nestedChildren?.length && !hasExplicitNestedChildren) {
382
389
  try {
383
390
  nestedChildren = compactNestedResultChildren(projectNestedRegistryForRoot(runId)?.children);
384
391
  }
385
392
  catch (error) {
386
- console.error(`Failed to enrich subagent result file '${resultPath}' with nested registry children; will retry later:`, error);
393
+ reportResultWatcherWarning(state, `Failed to enrich subagent result file '${resultPath}' with nested registry children; will retry later`, error);
387
394
  scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
388
395
  return;
389
396
  }
@@ -424,7 +431,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
424
431
  ? `${result.error}${hasRealOutput ? `\n\nOutput:\n${baseOutput}` : ""}`
425
432
  : output;
426
433
  const sessionPath = result.sessionFile ?? (resultChildren.length === 1 ? data.sessionFile : undefined);
427
- const childNestedChildren = sanitizeNestedResultChildren(result.children, resultPath, `results[${index}].children`);
434
+ const childNestedChildren = sanitizeNestedResultChildren(state, result.children, resultPath, `results[${index}].children`);
428
435
  const childState = result.state === "running" || result.state === "queued" || result.state === "paused" || result.state === "stopped"
429
436
  ? result.state
430
437
  : result.stopped === true
@@ -493,7 +500,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
493
500
  if (!ownsCompletion(sessionId, completionOwnerId, epoch))
494
501
  return;
495
502
  if (!intercomDelivered)
496
- console.error(`Subagent async grouped result intercom delivery was not acknowledged for '${resultPath}'.`);
503
+ reportResultWatcherWarning(state, `Subagent async grouped result intercom delivery was not acknowledged for '${resultPath}'.`);
497
504
  }
498
505
  const delivery = notifier.deliver({
499
506
  ...data,
@@ -539,7 +546,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
539
546
  ({ data, read } = marked);
540
547
  }
541
548
  catch (error) {
542
- console.error(`Failed to mark subagent result notification delivered for '${resultPath}'; will retry:`, error);
549
+ reportResultWatcherWarning(state, `Failed to mark subagent result notification delivered for '${resultPath}'; will retry`, error);
543
550
  scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
544
551
  return;
545
552
  }
@@ -566,7 +573,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
566
573
  });
567
574
  }
568
575
  catch (error) {
569
- console.error(`Completion observer failed for '${resultPath}':`, error);
576
+ reportResultWatcherWarning(state, `Completion observer failed for '${resultPath}'`, error);
570
577
  }
571
578
  if (!observerSucceeded) {
572
579
  scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
@@ -582,11 +589,11 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
582
589
  }
583
590
  catch (error) {
584
591
  if (isAccessDenied(error)) {
585
- console.error(`Failed to process subagent result file '${resultPath}'; will retry:`, error);
592
+ reportResultWatcherWarning(state, `Failed to process subagent result file '${resultPath}'; will retry`, error);
586
593
  scheduleResult(file, triggerTurn, RETRY_DELAY_MS);
587
594
  }
588
595
  else if (!isNotFound(error))
589
- console.error(`Failed to process subagent result file '${resultPath}':`, error);
596
+ reportResultWatcherWarning(state, `Failed to process subagent result file '${resultPath}'`, error);
590
597
  }
591
598
  finally {
592
599
  processing.delete(file);
@@ -615,7 +622,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
615
622
  // session transcript.
616
623
  if (resultScanLogging === "activity" && stats.files === 0 && stats.scheduled === 0)
617
624
  return;
618
- console.error(`Subagent result scan inspected ${stats.files} indexed result file(s), scheduled ${stats.scheduled} in ${elapsed}ms (${resultsDir}).`);
625
+ reportSessionWarning(state, `Subagent result scan inspected ${stats.files} indexed result file(s), scheduled ${stats.scheduled} in ${elapsed}ms (${resultsDir}).`, "slow-result-scan");
619
626
  };
620
627
  const indexedResultCandidates = (observed) => {
621
628
  const files = new Set();
@@ -652,10 +659,33 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
652
659
  }
653
660
  catch (error) {
654
661
  if (!isNotFound(error))
655
- console.error(`Failed to scan subagent result index in '${resultsDir}':`, error);
662
+ reportResultWatcherWarning(state, `Failed to scan subagent result index in '${resultsDir}'`, error);
656
663
  }
657
664
  return files;
658
665
  };
666
+ const hasPendingResults = () => eligibleResultFiles().some((file) => {
667
+ const payloadPath = resultPayloadPath(file);
668
+ if (!payloadPath)
669
+ return false;
670
+ let raw;
671
+ try {
672
+ raw = fsApi.readFileSync(payloadPath, "utf-8");
673
+ }
674
+ catch (error) {
675
+ // Removed since the scan means delivered; an unreadable file is still owed to someone, so the switch asks.
676
+ return !isNotFound(error);
677
+ }
678
+ const identity = resultFileIdentity(raw, file);
679
+ if (!identity.sessionId || !ownsResult(identity.sessionId, deliveryOwnerId(identity.sessionId, identity.completionOwnerId, identity.completionOwnerProcess, identity.parentWorkflowRunId)))
680
+ return false;
681
+ try {
682
+ return !hasDeliveredNotification(parseResult(raw));
683
+ }
684
+ catch {
685
+ // A partial write is retried by the watcher; until then it counts as undelivered.
686
+ return true;
687
+ }
688
+ });
659
689
  const primeExistingResults = (options = {}) => {
660
690
  const triggerTurn = options.triggerTurn !== false;
661
691
  for (const file of eligibleResultFiles())
@@ -689,7 +719,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
689
719
  return deps.hasDeliveryDemand?.() === true;
690
720
  }
691
721
  catch (error) {
692
- console.error("Failed to inspect subagent result delivery demand:", error);
722
+ reportResultWatcherWarning(state, "Failed to inspect subagent result delivery demand", error);
693
723
  return false;
694
724
  }
695
725
  };
@@ -718,7 +748,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
718
748
  clearResultScan();
719
749
  if (state.watcherRestartTimer)
720
750
  return;
721
- console.error(`Subagent result watcher for '${resultsDir}' fell back to polling because native fs.watch is unavailable (${errorCode(reason) ?? "unknown error"}).`);
751
+ reportResultWatcherWarning(state, `Subagent result watcher for '${resultsDir}' fell back to polling because native fs.watch is unavailable (${errorCode(reason) ?? "unknown error"}).`, undefined, `result-poll-fallback:${resultsDir}`);
722
752
  primeExistingResults();
723
753
  state.watcherRestartTimer = timers.setInterval(primeExistingResults, POLL_INTERVAL_MS);
724
754
  state.watcherRestartTimer.unref?.();
@@ -736,7 +766,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
736
766
  catch (error) {
737
767
  if (shouldPoll(error))
738
768
  return startPolling(error);
739
- console.error(`Failed to restart subagent result watcher for '${resultsDir}':`, error);
769
+ reportResultWatcherWarning(state, `Failed to restart subagent result watcher for '${resultsDir}'`, error);
740
770
  scheduleRestart();
741
771
  }
742
772
  }, WATCHER_RESTART_DELAY_MS);
@@ -779,7 +809,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
779
809
  state.watcher.on("error", (error) => {
780
810
  if (shouldPoll(error))
781
811
  return startPolling(error);
782
- console.error(`Subagent result watcher failed for '${resultsDir}':`, error);
812
+ reportResultWatcherWarning(state, `Subagent result watcher failed for '${resultsDir}'`, error);
783
813
  state.watcher?.close();
784
814
  state.watcher = null;
785
815
  scheduleRestart();
@@ -791,7 +821,7 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
791
821
  catch (error) {
792
822
  if (shouldPoll(error))
793
823
  return startPolling(error);
794
- console.error(`Failed to start subagent result watcher for '${resultsDir}':`, error);
824
+ reportResultWatcherWarning(state, `Failed to start subagent result watcher for '${resultsDir}'`, error);
795
825
  state.watcher = null;
796
826
  scheduleRestart();
797
827
  }
@@ -815,5 +845,5 @@ export function createResultWatcher(pi, state, resultsDir, completionTtlMs, deps
815
845
  processing.clear();
816
846
  identityCache.clear();
817
847
  };
818
- return { startResultWatcher, transitionResultDelivery, primeExistingResults, deliverPendingResults, stopResultWatcher, refreshResultDelivery: () => { primeExistingResults(); startDemandPolling(); } };
848
+ return { startResultWatcher, transitionResultDelivery, primeExistingResults, deliverPendingResults, hasPendingResults, stopResultWatcher, refreshResultDelivery: () => { primeExistingResults(); startDemandPolling(); } };
819
849
  }
@@ -1,6 +1,8 @@
1
1
  import * as fs from "node:fs";
2
+ import * as path from "node:path";
2
3
  import { readAsyncRecoveryDescriptor } from "./async-resume.js";
3
4
  import { errorWithoutReplyText } from "../shared/model-resolution.js";
5
+ import { waitToolName } from "../../shared/wait-tool-name.js";
4
6
  const INTERCOM_DETACH_ERROR = "detached for intercom coordination";
5
7
  function isIntercomDetached(run) {
6
8
  return run.steps.some((step) => step.execution?.status === "detached"
@@ -10,7 +12,7 @@ function isIntercomDetached(run) {
10
12
  function formatIntercomDetachGuidance(run) {
11
13
  if (!isIntercomDetached(run))
12
14
  return undefined;
13
- return `Run "${run.id}" detached for intercom coordination. Reply to the supervisor request first, then wait with bg_wait({ id: "${run.id}" }). Use subagent({ action: "status", id: "${run.id}" }) to recover the result; do not resume or launch a replacement while it remains detached.`;
15
+ return `Run "${run.id}" detached for intercom coordination. Reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${run.id}" }). Use subagent({ action: "status", id: "${run.id}" }) to recover the result; do not resume or launch a replacement while it remains detached.`;
14
16
  }
15
17
  export function formatAsyncReviveCommand(run) {
16
18
  const step = run.steps.find((candidate) => candidate.status === "failed");
@@ -18,7 +20,7 @@ export function formatAsyncReviveCommand(run) {
18
20
  if (!step || !sessionFile || !fs.existsSync(sessionFile))
19
21
  return undefined;
20
22
  try {
21
- const descriptor = readAsyncRecoveryDescriptor(run.asyncDir);
23
+ const descriptor = readAsyncRecoveryDescriptor(path.dirname(run.asyncDir), path.basename(run.asyncDir));
22
24
  if (!descriptor || descriptor.sourceRunId !== run.id || descriptor.agent !== step.agent)
23
25
  return undefined;
24
26
  }
@@ -1,4 +1,5 @@
1
1
  import * as fs from "node:fs";
2
+ import * as path from "node:path";
2
3
  import { listAsyncRuns } from "./async-status.js";
3
4
  import { readAsyncRecoveryDescriptor } from "./async-resume.js";
4
5
  import { parallelHandoffPath, resolveRetainedWorktreeCwd } from "../shared/parallel-handoff.js";
@@ -39,7 +40,7 @@ function childResumability(run, step) {
39
40
  return session;
40
41
  let recoveryDescriptor;
41
42
  try {
42
- recoveryDescriptor = readAsyncRecoveryDescriptor(run.asyncDir);
43
+ recoveryDescriptor = readAsyncRecoveryDescriptor(path.dirname(run.asyncDir), path.basename(run.asyncDir));
43
44
  if (!recoveryDescriptor)
44
45
  return { state: "not-resumable", reason: "missing recovery descriptor" };
45
46
  if (recoveryDescriptor.sourceRunId !== run.id)
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { Message } from "@earendil-works/pi-ai";
9
9
  import type { ChildTranscriptWriter } from "../../shared/child-transcript.ts";
10
- import type { EffectsProjection, RuntimeAcknowledgedChildExtensions, SubagentOutputState, ToolBudgetState, Usage } from "../../shared/types.ts";
10
+ import type { EffectsProjection, RuntimeAcknowledgedChildExtensions, SteeringFailureKind, SubagentOutputState, ToolBudgetState, Usage } from "../../shared/types.ts";
11
11
  import { type ChildWatchdogConfig, type ChildWatchdogStateSnapshot, type ChildWatchdogStatusEvent } from "../../watchdog/child-status.ts";
12
12
  import { type InProcessChildLaunch } from "../shared/child-launch.ts";
13
13
  import { type ChildSessionFactory } from "../shared/child-session.ts";
@@ -42,9 +42,9 @@ export interface ChildEvent {
42
42
  args?: Record<string, unknown>;
43
43
  willRetry?: unknown;
44
44
  }
45
- /** Outcome of handing a steer request to a live child session. */
46
45
  export interface SteerDelivery {
47
46
  state: "delivered" | "queued" | "failed";
47
+ failureKind?: SteeringFailureKind;
48
48
  deliveryStatus?: SteerDeliveryStatus;
49
49
  message: string;
50
50
  }
@@ -74,7 +74,6 @@ export interface RunChildSessionInput {
74
74
  onContextWindow?: (contextWindow: number) => void;
75
75
  transcriptWriter?: ChildTranscriptWriter;
76
76
  toolTimeoutMs?: number;
77
- runDeadlineAt?: number;
78
77
  expectedModelForVerification?: string;
79
78
  modelVerificationRegistry?: Array<{
80
79
  provider: string;
@@ -297,9 +297,6 @@ export function runChildSession(input) {
297
297
  const timeoutForTool = effectiveToolTimeoutMs(event.toolName, input.toolTimeoutMs);
298
298
  if (timeoutForTool === undefined)
299
299
  return;
300
- const runRemaining = input.runDeadlineAt === undefined ? undefined : Math.max(0, input.runDeadlineAt - Date.now());
301
- if (runRemaining !== undefined && timeoutForTool >= runRemaining)
302
- return;
303
300
  const key = toolTimeoutCallKey(event, ++toolTimeoutSequence);
304
301
  const toolName = event.toolName;
305
302
  const timer = setTimeout(() => {
@@ -480,12 +477,12 @@ export function runChildSession(input) {
480
477
  await Promise.resolve().then(() => session?.dispose()).catch(() => undefined);
481
478
  return commandError;
482
479
  };
483
- /** The child run ended (or was forced to end); fold in the outcome once the child's shutdown work is done. */
484
480
  const failUnconsumedSteers = () => {
485
481
  for (const entry of acceptedSteers.splice(0)) {
486
- input.onSteerOutcome?.(entry.request, { state: "failed", message: unconsumedSteerReason(entry.request.mode) });
482
+ input.onSteerOutcome?.(entry.request, { state: "failed", failureKind: "unconsumed", message: unconsumedSteerReason(entry.request.mode) });
487
483
  }
488
484
  };
485
+ /** The child run ended (or was forced to end); fold in the outcome once the child's shutdown work is done. */
489
486
  const settle = (promptError, forced = false) => {
490
487
  if (settled)
491
488
  return;
@@ -603,14 +600,14 @@ export function runChildSession(input) {
603
600
  const steer = created.steer.bind(created);
604
601
  const followUp = created.followUp.bind(created);
605
602
  created.steer = async (text) => {
603
+ await steer(text);
606
604
  if (cleanTerminalAssistantStopReceived || agentSettledReceived)
607
605
  queuedDrainHold = true;
608
- return steer(text);
609
606
  };
610
607
  created.followUp = async (text) => {
608
+ await followUp(text);
611
609
  if (cleanTerminalAssistantStopReceived || agentSettledReceived)
612
610
  queuedDrainHold = true;
613
- return followUp(text);
614
611
  };
615
612
  unsubscribe = created.subscribe(processEvent);
616
613
  input.registerWatchdogStatus?.((event) => processEvent(event));
@@ -634,7 +631,7 @@ export function runChildSession(input) {
634
631
  const index = acceptedSteers.indexOf(accepted);
635
632
  if (index >= 0)
636
633
  acceptedSteers.splice(index, 1);
637
- return { state: "failed", message: steerError instanceof Error ? steerError.message : String(steerError) };
634
+ return { state: "failed", failureKind: "rejected", message: steerError instanceof Error ? steerError.message : String(steerError) };
638
635
  }
639
636
  return queued;
640
637
  });
@@ -2,7 +2,7 @@ import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import { safeTerminalText } from "../../shared/display-text.js";
4
4
  import { getArtifactPaths, getArtifactsDir } from "../../shared/artifacts.js";
5
- import { readFleetTranscript } from "../../tui/fleet-transcript.js";
5
+ import { readFleetTranscript } from "../../shared/fleet-transcript-reader.js";
6
6
  import { formatAsyncRunList, formatAsyncRunOutputPath, formatAsyncRunProgressLabel, formatWorkflowStageLine, listAsyncRuns } from "./async-status.js";
7
7
  import { formatAsyncResultTranscript, formatAsyncRunTranscript, formatNestedRunTranscript, inspectSubagentFleet } from "./fleet-view.js";
8
8
  import { formatNestedRunStatusLines } from "../shared/nested-render.js";
@@ -37,6 +37,7 @@ import { formatWorkflowKeyRevival, projectWorkflowKeyRevival } from "../../workf
37
37
  import { capSummaryOutputs } from "../shared/single-output.js";
38
38
  import { ownsRun } from "../shared/run-ownership.js";
39
39
  import { foregroundChildStateLabel } from "../foreground/foreground-history.js";
40
+ import { waitToolName } from "../../shared/wait-tool-name.js";
40
41
  /** A step whose structured output has a path line needs only a short inline preview. */
41
42
  const STRUCTURED_PREVIEW_WITH_PATH_CHARS = 500;
42
43
  function formatProcessTerminal(value) {
@@ -119,7 +120,7 @@ function formatResumeGuidance(runId, children, fallbackSessionFile, options = {}
119
120
  const resumableWorkflowChildren = workflowChildren.filter(({ child }) => !(child.status === "paused" && child.activityState === "needs_attention"));
120
121
  if (workflowChildren.length > 0) {
121
122
  return [
122
- ...supervisorDetachedWorkflowChildren.map(({ child }) => `Recovery workflow child${typeof child.workflowKey === "string" && child.workflowKey.trim() ? ` '${child.workflowKey}'` : ""}: reply to the supervisor request first, then wait with bg_wait({ id: "${child.runId}" }). Use subagent({ action: "status", id: "${child.runId}" }) to recover the result; do not resume or launch a replacement while it remains detached.`),
123
+ ...supervisorDetachedWorkflowChildren.map(({ child }) => `Recovery workflow child${typeof child.workflowKey === "string" && child.workflowKey.trim() ? ` '${child.workflowKey}'` : ""}: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${child.runId}" }). Use subagent({ action: "status", id: "${child.runId}" }) to recover the result; do not resume or launch a replacement while it remains detached.`),
123
124
  ...resumableWorkflowChildren.map(({ child }) => `Revive workflow child${typeof child.workflowKey === "string" && child.workflowKey.trim() ? ` '${child.workflowKey}'` : ""}: subagent({ action: "resume", id: "${child.runId}", message: "..." })`),
124
125
  ].join("\n");
125
126
  }
@@ -230,7 +231,7 @@ function formatRememberedForegroundStatus(run) {
230
231
  const detached = run.children.some((child) => child.status === "detached");
231
232
  const resumable = run.children.find((child) => hasExistingSessionFile(child.sessionFile));
232
233
  if (detached) {
233
- lines.push(`Recovery: reply to the supervisor request first, then wait with bg_wait({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
234
+ lines.push(`Recovery: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
234
235
  }
235
236
  else if (resumable) {
236
237
  lines.push(run.children.length === 1
@@ -673,14 +674,15 @@ export function inspectSubagentStatus(params, deps = {}) {
673
674
  lines.push(` Runner: external-cli (${runner.command}${runner.args.length ? ` ${runner.args.join(" ")}` : ""})`);
674
675
  lines.push(` Adapter: ${runner.adapter.id} v${runner.adapter.version} (${runner.adapter.executionMode})`);
675
676
  if (runner.safety) {
677
+ const safetyLabel = " Safety (adapter profile, not measured):";
676
678
  if ("approvalPolicy" in runner.safety)
677
- lines.push(` Safety: ${"access" in runner.safety ? `access=${runner.safety.access}, ` : ""}sandbox=${runner.safety.sandbox}, approval=${runner.safety.approvalPolicy}, ephemeral=${runner.safety.ephemeral}`);
679
+ lines.push(`${safetyLabel} ${"access" in runner.safety ? `access=${runner.safety.access}, ` : ""}sandbox=${runner.safety.sandbox}, approval=${runner.safety.approvalPolicy}, ephemeral=${runner.safety.ephemeral}`);
678
680
  else if ("mode" in runner.safety)
679
- lines.push(` Safety: access=${runner.safety.access}, auth=${runner.safety.authentication}, mode=${runner.safety.mode}, sandbox=${runner.safety.sandbox}, workspaceTrust=${runner.safety.workspaceTrust}, sessionReuse=${runner.safety.sessionReuse}`);
681
+ lines.push(`${safetyLabel} access=${runner.safety.access}, auth=${runner.safety.authentication}, mode=${runner.safety.mode}, sandbox=${runner.safety.sandbox}, workspaceTrust=${runner.safety.workspaceTrust}, sessionReuse=${runner.safety.sessionReuse}`);
680
682
  else if ("authentication" in runner.safety)
681
- lines.push(` Safety: access=${runner.safety.access}, auth=${runner.safety.authentication}, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, settingsTrust=${runner.safety.userSettingsTrust}, persistence=${runner.safety.sessionPersistence}`);
683
+ lines.push(`${safetyLabel} access=${runner.safety.access}, auth=${runner.safety.authentication}, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, settingsTrust=${runner.safety.userSettingsTrust}, persistence=${runner.safety.sessionPersistence}`);
682
684
  else
683
- lines.push(` Safety: access=read-only, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, persistence=${runner.safety.sessionPersistence}`);
685
+ lines.push(`${safetyLabel} access=read-only, permission=${runner.safety.permissionMode}, tools=${runner.safety.tools}, mcp=${runner.safety.mcp}, settings=${runner.safety.settingSources}, persistence=${runner.safety.sessionPersistence}`);
684
686
  }
685
687
  lines.push(` Capabilities: stop=${runner.capabilities.stop}, steer=false, resume=false, structuredOutput=false, toolEvents=false, supervisor=unsupported, forkContext=false, extensionBindings=false`);
686
688
  lines.push(` Unsupported steer: ${runner.unsupportedReasons.steer}`);
@@ -33,6 +33,7 @@ const CHORD_PEER_ALIASES = [
33
33
  { specifier: "@earendil-works/chord", pkg: "@earendil-works/chord", subpath: "." },
34
34
  { specifier: "@earendil-works/chord/context", pkg: "@earendil-works/chord", subpath: "./context" },
35
35
  ];
36
+ const SCHEMA_PACKAGE = "@earendil-works/pi-schema";
36
37
  function readManifest(packageDir) {
37
38
  try {
38
39
  return JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
@@ -187,5 +188,19 @@ export function resolveHostPeerAliases(piPackageRoot) {
187
188
  if (pkg !== CHORD_PACKAGE || chordRequired)
188
189
  missing.push(specifier);
189
190
  }
191
+ // Pi 1.5+ pi-ai imports pi-schema; without it a child dies after its launch was accepted. pi-ai's
192
+ // own import already reaches the right copy, so this is only a presence check, never an alias:
193
+ // an alias would also redirect extensions that ship their own copy.
194
+ const piAiDir = findPeerPackageDir(piPackageRoot, "@earendil-works/pi-ai", hostManifest?.name);
195
+ const piAiManifest = piAiDir ? readManifest(piAiDir) : undefined;
196
+ if (piAiDir && piAiManifest && declaresDependency(piAiManifest, SCHEMA_PACKAGE)) {
197
+ // Resolve from pi-ai's real path, as Node does, so nested, hoisted and pnpm-sibling copies count.
198
+ const schemaDir = findPeerPackageDir(fs.realpathSync(piAiDir), SCHEMA_PACKAGE, undefined);
199
+ for (const subpath of [".", "./formats"]) {
200
+ const target = schemaDir ? resolvePackageSubpath(schemaDir, subpath) : undefined;
201
+ if (!target || !fs.existsSync(target))
202
+ missing.push(subpath === "." ? SCHEMA_PACKAGE : `${SCHEMA_PACKAGE}/formats`);
203
+ }
204
+ }
190
205
  return { aliases, missing };
191
206
  }
@@ -17,7 +17,7 @@ export type ScheduleTrigger = {
17
17
  every: string;
18
18
  everyMs: number;
19
19
  anchorAt: string;
20
- nextRunAt: string;
20
+ nextRunAt?: string;
21
21
  } | CalendarTrigger;
22
22
  export type ScheduleTarget = {
23
23
  workflowScript: string;
@@ -66,6 +66,8 @@ type ScheduledRunManagerDeps = {
66
66
  resolveCapabilityCeiling?: (sessionId: string) => ResolvedSubagentCapabilityCeiling | undefined;
67
67
  timers?: ScheduledRunTimers;
68
68
  kill?: (pid: number, signal?: NodeJS.Signals | 0) => boolean;
69
+ /** Shows a warning once per key without drawing over the editor. */
70
+ reportWarning?: (message: string, key: string) => void;
69
71
  };
70
72
  export declare function isScheduledRunAction(action: unknown): action is ScheduledRunAction;
71
73
  export declare function scheduledRunsEnabled(config: ExtensionConfig): boolean;
@@ -93,6 +93,10 @@ export function parseScheduleInterval(every) {
93
93
  function timestamp(value) {
94
94
  return new Date(value).toISOString();
95
95
  }
96
+ /** One-line message for a caught value; a stack trace is never useful in a session warning. */
97
+ function errorText(error) {
98
+ return error instanceof Error ? error.message : String(error);
99
+ }
96
100
  function validateScheduleId(id) {
97
101
  if (!SCHEDULE_ID.test(id))
98
102
  throw new Error("Schedule id must be 1-64 characters and contain only letters, numbers, '.', '_', or '-'.");
@@ -311,7 +315,8 @@ function parseSchedule(value, file) {
311
315
  throw new Error(`Schedule record '${file}' has an invalid one-shot trigger.`);
312
316
  }
313
317
  else if (record.trigger.kind === "interval") {
314
- if (typeof record.trigger.every !== "string" || typeof record.trigger.everyMs !== "number" || typeof record.trigger.anchorAt !== "string" || typeof record.trigger.nextRunAt !== "string")
318
+ // A paused interval record may omit nextRunAt; resuming it supplies one.
319
+ if (typeof record.trigger.every !== "string" || typeof record.trigger.everyMs !== "number" || typeof record.trigger.anchorAt !== "string" || ((!record.paused || record.trigger.nextRunAt !== undefined) && typeof record.trigger.nextRunAt !== "string"))
315
320
  throw new Error(`Schedule record '${file}' has an invalid interval trigger.`);
316
321
  }
317
322
  else if (record.trigger.kind === "calendar") {
@@ -524,25 +529,12 @@ function snapshotContext(ctx, cwd) {
524
529
  });
525
530
  return { ...ctx, cwd, sessionManager };
526
531
  }
527
- /**
528
- * 规范化会话文件路径, 兼容 Windows 路径大小写差异.
529
- *
530
- * @param value 会话文件路径
531
- * @returns 规范化后的路径, 空值时返回 undefined
532
- */
533
532
  function normalizedSessionFile(value) {
534
533
  if (!value || !value.trim())
535
534
  return undefined;
536
535
  const normalized = path.normalize(path.resolve(value));
537
536
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
538
537
  }
539
- /**
540
- * 判断 Schedule 是否属于当前 Pi 会话.
541
- *
542
- * @param schedule Schedule 记录
543
- * @param ctx 当前 Pi 会话上下文
544
- * @returns 是否允许当前会话执行该 Schedule
545
- */
546
538
  function scheduleBelongsToSession(schedule, ctx) {
547
539
  if (schedule.sessionOnly !== true)
548
540
  return true;
@@ -631,7 +623,7 @@ export class ScheduledRunManager {
631
623
  ids = store.ids();
632
624
  }
633
625
  catch (error) {
634
- console.error(`Failed to inspect schedule store '${store.root}' during async completion:`, error);
626
+ this.deps.reportWarning?.(`Failed to inspect schedule store '${store.root}': ${errorText(error)}`, `schedule-store:${store.root}:${errorText(error)}`);
635
627
  continue;
636
628
  }
637
629
  for (const id of ids) {
@@ -646,7 +638,8 @@ export class ScheduledRunManager {
646
638
  return;
647
639
  }
648
640
  catch (error) {
649
- console.error(`Failed to inspect schedule '${id}' in '${store.root}' during async completion:`, error);
641
+ // Runs on every async completion, so the key holds no error text: one warning per record.
642
+ this.deps.reportWarning?.(`Failed to inspect schedule '${id}' in '${store.root}': ${errorText(error)}`, `schedule-record:${store.root}:${id}`);
650
643
  }
651
644
  }
652
645
  }
@@ -748,6 +741,10 @@ export class ScheduledRunManager {
748
741
  if (schedule.paused === paused)
749
742
  return textResult(`Schedule ${schedule.id} is already ${paused ? "paused" : "active"}.`, [schedule]);
750
743
  schedule.paused = paused;
744
+ // A record paused without a next run must get one back here, or resuming would leave a
745
+ // schedule that is active and never fires.
746
+ if (!paused && schedule.trigger.kind === "interval" && schedule.trigger.nextRunAt === undefined)
747
+ schedule.trigger.nextRunAt = timestamp(this.now() + schedule.trigger.everyMs);
751
748
  schedule.updatedAt = timestamp(this.now());
752
749
  this.requireStore().write(schedule);
753
750
  this.requireStore().appendEvent(schedule, paused ? "schedule.paused" : "schedule.resumed");
@@ -1,7 +1,5 @@
1
1
  import type { AsyncStatus, ResolvedToolBudget, SteerActionResult, SteeringRecoveryDescriptor, SteeringRequestStatus, SteeringStatus, SteeringTargetState, SteeringTargetStatus } from "../../shared/types.ts";
2
2
  import type { SteerDeliveryMode } from "./control-channel.ts";
3
- export declare const MAX_STEERING_REQUESTS = 20;
4
- export declare const STEERING_MESSAGE_PREVIEW_LIMIT = 160;
5
3
  export declare function steeringMessagePreview(message: string): string;
6
4
  /** FIFO match of one accepted steer to an emitted user message; equal text claims the oldest entry. */
7
5
  export declare function takeMatchingAcceptedSteer<T extends {
@@ -17,16 +15,10 @@ export declare function recordSteeringRequest(status: SteeringStatus, input: {
17
15
  requestedAt: number;
18
16
  source?: string;
19
17
  message: string;
20
- targets: Array<{
21
- index: number;
22
- state: SteeringTargetState;
23
- reason?: string;
24
- }>;
18
+ targets: Array<Pick<SteeringTargetStatus, "index" | "state" | "reason" | "failureKind">>;
25
19
  }): SteeringRequestStatus;
26
- export declare function updateSteeringTarget(status: SteeringStatus, requestId: string, index: number, state: SteeringTargetState, now: number, fields?: Pick<SteeringTargetStatus, "reason" | "replacementRunId">): SteeringTargetStatus | undefined;
27
- export declare function findSteeringRequest(status: SteeringStatus, requestId: string): SteeringRequestStatus | undefined;
20
+ export declare function updateSteeringTarget(status: SteeringStatus, requestId: string, index: number, state: SteeringTargetState, now: number, fields?: Pick<SteeringTargetStatus, "reason" | "replacementRunId" | "failureKind">): SteeringTargetStatus | undefined;
28
21
  export declare function actionResultFromSteeringStatus(status: SteeringStatus, sourceRunId: string, requestId: string, replacementRunId?: string): SteerActionResult | undefined;
29
- export declare function steeringActionIsTerminal(result: SteerActionResult | undefined): boolean;
30
22
  export declare function terminalSteeringNoticeState(status: SteeringStatus, requestId: string): "failed" | "partial" | undefined;
31
23
  export declare function claimSteeringRecovery(asyncDir: string, input: {
32
24
  requestId: string;
@@ -36,7 +28,6 @@ export declare function claimSteeringRecovery(asyncDir: string, input: {
36
28
  claimPath: string;
37
29
  markerPath: string;
38
30
  };
39
- export declare function readSteeringStatus(asyncDir: string): SteeringStatus | undefined;
40
31
  export declare function remainingSteeringRecoveryLimits(descriptor: Pick<SteeringRecoveryDescriptor, "absoluteDeadlineAt" | "initialToolBudget">, status: Pick<AsyncStatus, "toolBudget" | "toolCount">, now?: number): {
41
32
  timeoutMs?: number;
42
33
  absoluteDeadlineAt?: number;