pi-subagents 0.89.0 → 0.89.2

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 (79) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-TGABNSG5.js → chunk-2UCFLUE4.js} +64 -12
  5. package/bundle/{chunk-7W2IQFP4.js → chunk-464OJSDP.js} +4 -4
  6. package/bundle/{chunk-ETDE2VYK.js → chunk-4KQW5R6U.js} +2 -2
  7. package/bundle/{chunk-JRO2CU4D.js → chunk-5TXWZB73.js} +1 -1
  8. package/bundle/{chunk-7J4ZXMY7.js → chunk-72334PEI.js} +6 -4
  9. package/bundle/{chunk-CHEABMO2.js → chunk-76WVWEFE.js} +33 -24
  10. package/bundle/{chunk-S77ZKDLS.js → chunk-77VQEATI.js} +1 -1
  11. package/bundle/{chunk-HZDLR73C.js → chunk-AHGJSJYY.js} +4 -3
  12. package/bundle/{chunk-4ALRHKGE.js → chunk-DGLXVN3F.js} +1 -1
  13. package/bundle/{chunk-SLLZJ5EC.js → chunk-DHY5TY2Y.js} +237 -199
  14. package/bundle/{chunk-2I6YN6ET.js → chunk-DYBRIEIF.js} +8 -8
  15. package/bundle/{chunk-NQ26PJSQ.js → chunk-FF5K5HQU.js} +11 -6
  16. package/bundle/{chunk-HSHLPYCQ.js → chunk-FO2GIU5F.js} +27 -18
  17. package/bundle/{chunk-JFACGAJT.js → chunk-JEYG7CNC.js} +8 -4
  18. package/bundle/{chunk-X5ZOTDHO.js → chunk-KA4MKMYT.js} +11 -11
  19. package/bundle/{chunk-GHJ6BH5U.js → chunk-LWH7IGI3.js} +8 -0
  20. package/bundle/{chunk-AZW4HXNU.js → chunk-ME4IS3Y3.js} +99 -30
  21. package/bundle/{chunk-UQT2EQ4U.js → chunk-Q4VH72JI.js} +2 -2
  22. package/bundle/{chunk-443LPCRI.js → chunk-RHKIP45B.js} +6 -6
  23. package/bundle/{chunk-PPPAEFRA.js → chunk-ROJH7KPK.js} +2 -2
  24. package/bundle/{chunk-WW6GQBBS.js → chunk-SRCMJY4F.js} +4 -4
  25. package/bundle/{chunk-KOLLMZ2X.js → chunk-SWGB2P5J.js} +1 -1
  26. package/bundle/{chunk-ZSCIHMUI.js → chunk-TXC7WIPL.js} +3 -2
  27. package/bundle/{chunk-6JD4XCA4.js → chunk-U753SUBC.js} +14 -6
  28. package/bundle/{chunk-YX7R55CR.js → chunk-UBPAMRVL.js} +12 -12
  29. package/bundle/{chunk-A3INCQ6Z.js → chunk-UUW7P6KJ.js} +1 -1
  30. package/bundle/{chunk-EPMRDKQT.js → chunk-VEEUXJDO.js} +1 -1
  31. package/bundle/{chunk-NONHDYXE.js → chunk-YJIU5WF4.js} +1 -1
  32. package/bundle/control-channel.js +2 -2
  33. package/bundle/index.js +1 -1
  34. package/bundle/intercom-bridge.js +2 -2
  35. package/bundle/preflight.js +12 -10
  36. package/bundle/project-panes.js +4 -4
  37. package/docs/agents.md +2 -2
  38. package/docs/observability.md +3 -1
  39. package/docs/watchdog.md +3 -2
  40. package/package.json +1 -1
  41. package/src/api/preflight.d.ts +1 -0
  42. package/src/api/preflight.js +2 -1
  43. package/src/extension/herdr-pi-bridge.js +1 -1
  44. package/src/inspectors/herdr/project-panes.d.ts +2 -0
  45. package/src/inspectors/herdr/project-panes.js +7 -1
  46. package/src/inspectors/shell-command.d.ts +2 -1
  47. package/src/inspectors/shell-command.js +7 -5
  48. package/src/runs/background/active-async-capacity.js +2 -1
  49. package/src/runs/background/active-run-index.d.ts +1 -0
  50. package/src/runs/background/active-run-index.js +3 -0
  51. package/src/runs/background/async-execution.d.ts +2 -0
  52. package/src/runs/background/async-execution.js +3 -2
  53. package/src/runs/background/async-job-tracker.js +85 -9
  54. package/src/runs/background/async-status.d.ts +2 -0
  55. package/src/runs/background/async-status.js +8 -3
  56. package/src/runs/background/process-terminal.d.ts +6 -0
  57. package/src/runs/background/process-terminal.js +34 -2
  58. package/src/runs/background/run-status.js +2 -1
  59. package/src/runs/background/stale-run-reconciler.d.ts +8 -0
  60. package/src/runs/background/stale-run-reconciler.js +38 -8
  61. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  62. package/src/runs/background/workflow-terminal-proof.js +4 -4
  63. package/src/runs/foreground/execution.js +2 -2
  64. package/src/runs/foreground/subagent-executor.d.ts +2 -0
  65. package/src/runs/foreground/subagent-executor.js +10 -1
  66. package/src/runs/shared/herdr-machine.js +3 -1
  67. package/src/runs/shared/herdr-pane-host.js +10 -2
  68. package/src/runs/shared/mcp-config-sources.d.ts +1 -0
  69. package/src/runs/shared/mcp-config-sources.js +1 -1
  70. package/src/runs/shared/mcp-direct-tool-allowlist.js +1 -0
  71. package/src/runs/shared/subagent-prompt-runtime.js +6 -5
  72. package/src/shared/types.d.ts +2 -0
  73. package/src/shared/utils.d.ts +2 -0
  74. package/src/shared/utils.js +9 -0
  75. package/src/tui/fleet-transcript.js +21 -9
  76. package/src/watchdog/runtime.d.ts +4 -0
  77. package/src/watchdog/runtime.js +50 -12
  78. package/src/watchdog/turn-delta.d.ts +2 -0
  79. package/src/watchdog/turn-delta.js +21 -0
@@ -14,20 +14,20 @@ import {
14
14
  resolveCurrentSessionId,
15
15
  resolveWatchdogReviewModel,
16
16
  startWatchdogDiffBaselineCapture
17
- } from "./chunk-TGABNSG5.js";
17
+ } from "./chunk-2UCFLUE4.js";
18
18
  import {
19
19
  agentStreamOptions,
20
20
  opencodeSessionHeaders
21
- } from "./chunk-6JD4XCA4.js";
21
+ } from "./chunk-U753SUBC.js";
22
22
  import {
23
23
  registerNativeSupervisorClient
24
- } from "./chunk-EPMRDKQT.js";
24
+ } from "./chunk-VEEUXJDO.js";
25
25
  import {
26
26
  MODEL_ONLY_TOOL
27
27
  } from "./chunk-HXRB42AF.js";
28
28
  import {
29
29
  inheritedNestedRouteOf
30
- } from "./chunk-SLLZJ5EC.js";
30
+ } from "./chunk-DHY5TY2Y.js";
31
31
  import {
32
32
  CHILD_WATCHDOG_STATUS_EVENT,
33
33
  DEFAULT_WAIT_TOOL_NAME,
@@ -46,7 +46,7 @@ import {
46
46
  toolBudgetSoftNudge,
47
47
  validateAcceptanceReport,
48
48
  validateStructuredOutputValue
49
- } from "./chunk-GHJ6BH5U.js";
49
+ } from "./chunk-LWH7IGI3.js";
50
50
  import {
51
51
  INTERCOM_SESSION_IDENTITY_EVENT
52
52
  } from "./chunk-JEZOSEWG.js";
@@ -544,10 +544,10 @@ function registerDeclaredToolCheck(pi, config, required) {
544
544
  pi.on("context_with_system", (event, ctx) => {
545
545
  const declared = new Set(getCurrentTools(event.messages).map((tool) => tool.name));
546
546
  if (required.every((name) => declared.has(name))) return void 0;
547
- const registered = new Set(pi.getAllTools().map((tool) => tool.name));
548
- const undeclared = required.filter((name) => registered.has(name) && !declared.has(name));
549
- if (undeclared.length === 0) return void 0;
550
547
  const active = new Set(pi.getActiveTools());
548
+ const undeclared = required.filter((name) => active.has(name) && !declared.has(name));
549
+ if (undeclared.length === 0) return void 0;
550
+ const registered = new Set(pi.getAllTools().map((tool) => tool.name));
551
551
  const uncallable = config.forkCacheKey ? [] : [...declared].filter((name) => !active.has(name));
552
552
  config.toolDiagnostic?.({
553
553
  ...config.agent ? { agent: config.agent } : {},
@@ -7,13 +7,13 @@ import {
7
7
  runBoundedCommand,
8
8
  shellScriptCommand,
9
9
  sshMachineAccess
10
- } from "./chunk-ZSCIHMUI.js";
10
+ } from "./chunk-TXC7WIPL.js";
11
11
  import {
12
12
  package_default
13
- } from "./chunk-4ALRHKGE.js";
13
+ } from "./chunk-DGLXVN3F.js";
14
14
  import {
15
15
  ensureSupervisorChannelDir
16
- } from "./chunk-EPMRDKQT.js";
16
+ } from "./chunk-VEEUXJDO.js";
17
17
  import "./chunk-HXRB42AF.js";
18
18
  import "./chunk-NIXWDZZV.js";
19
19
  import {
@@ -39,7 +39,7 @@ import {
39
39
  resolveRexBinary,
40
40
  rexCommandEnv,
41
41
  rexGlobalArgs
42
- } from "./chunk-GHJ6BH5U.js";
42
+ } from "./chunk-LWH7IGI3.js";
43
43
  import "./chunk-JEZOSEWG.js";
44
44
  import "./chunk-YFCK7H2S.js";
45
45
  import "./chunk-QXASAHIA.js";
@@ -517,14 +517,19 @@ var herdrPaneHost = {
517
517
  return { owned, terminalId };
518
518
  },
519
519
  async prompt(connection, identity, text, options = {}) {
520
- const clock = options.clock ?? { now: () => Date.now(), wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) }, deadline = clock.now() + (options.timeoutMs ?? 5e3), pollMs = options.pollMs ?? 100;
520
+ const clock = options.clock ?? { now: () => Date.now(), wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) }, deadline = clock.now() + (options.timeoutMs ?? 2e4), pollMs = options.pollMs ?? 100;
521
521
  for (; ; ) {
522
522
  try {
523
523
  await connection.client.call("agent.prompt", { target: identity.agentName, text });
524
524
  return;
525
525
  } catch (error) {
526
526
  if (!(error instanceof Error) || !error.message.includes("is not an active named agent") || clock.now() >= deadline) throw error;
527
- await clock.wait(Math.min(pollMs, deadline - clock.now()));
527
+ const remainingMs = deadline - clock.now();
528
+ try {
529
+ await connection.client.call("agent.wait", { target: identity.agentName, until: ["idle", "done"], timeout_ms: remainingMs }, remainingMs + 5e3);
530
+ } catch {
531
+ }
532
+ await clock.wait(Math.min(pollMs, Math.max(0, deadline - clock.now())));
528
533
  if (options.stopped?.()) throw new Error("Remote Pi prompt was not sent because the run was stopped.", { cause: error });
529
534
  }
530
535
  }
@@ -7,37 +7,37 @@ import {
7
7
  safeTranscriptEvent,
8
8
  steerAsyncRun,
9
9
  steerWorkflowForegroundTarget
10
- } from "./chunk-443LPCRI.js";
10
+ } from "./chunk-RHKIP45B.js";
11
11
  import {
12
12
  FLEET_STATUS_WIDGET_KEY,
13
13
  runningTone,
14
14
  stepTaskSummary
15
- } from "./chunk-WW6GQBBS.js";
15
+ } from "./chunk-SRCMJY4F.js";
16
16
  import {
17
17
  foregroundChildStateLabel,
18
18
  formatAsyncRunTranscript,
19
19
  stopAsyncRun
20
- } from "./chunk-7W2IQFP4.js";
20
+ } from "./chunk-464OJSDP.js";
21
21
  import {
22
22
  contextModeBadge,
23
23
  contextModeLabel,
24
24
  decodeUtf8Tail,
25
25
  listAsyncRuns
26
- } from "./chunk-6JD4XCA4.js";
26
+ } from "./chunk-U753SUBC.js";
27
27
  import {
28
28
  reportSessionWarning
29
29
  } from "./chunk-HXRB42AF.js";
30
- import "./chunk-SLLZJ5EC.js";
31
- import "./chunk-A3INCQ6Z.js";
30
+ import "./chunk-DHY5TY2Y.js";
31
+ import "./chunk-UUW7P6KJ.js";
32
32
  import "./chunk-NIXWDZZV.js";
33
- import "./chunk-NONHDYXE.js";
33
+ import "./chunk-YJIU5WF4.js";
34
34
  import "./chunk-7F6RKT6W.js";
35
35
  import "./chunk-YARY7JWU.js";
36
- import "./chunk-7J4ZXMY7.js";
36
+ import "./chunk-72334PEI.js";
37
37
  import {
38
38
  getArtifactPaths,
39
39
  getArtifactsDir
40
- } from "./chunk-S77ZKDLS.js";
40
+ } from "./chunk-77VQEATI.js";
41
41
  import {
42
42
  snapshotExternalRuns
43
43
  } from "./chunk-UKG4V45O.js";
@@ -49,7 +49,7 @@ import {
49
49
  formatTokens,
50
50
  readStatus,
51
51
  shortenPath
52
- } from "./chunk-GHJ6BH5U.js";
52
+ } from "./chunk-LWH7IGI3.js";
53
53
  import {
54
54
  DIRS
55
55
  } from "./chunk-JEZOSEWG.js";
@@ -154,8 +154,15 @@ function renderExpandedTool(event, width, theme) {
154
154
  const output = event.output ?? event.error;
155
155
  const outputColor = event.status === "error" ? "error" : "toolOutput";
156
156
  if (event.name === "bash") {
157
- const command = jsonScalar(args?.command) ?? event.args ?? "(unknown command)";
158
- lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`$ ${command}`))}`, width, theme));
157
+ const command = jsonScalar(args?.command);
158
+ let first = true;
159
+ for (const commandLine of (command ?? event.args ?? "(unknown command)").split(/\r?\n/)) {
160
+ for (const wrapped of renderWrapped(theme.fg("toolTitle", theme.bold(first ? `$ ${commandLine}` : commandLine)), Math.max(1, width - 4))) {
161
+ lines.push(railLine(`${first ? glyph : " "} ${wrapped}`, width, theme));
162
+ first = false;
163
+ }
164
+ }
165
+ if (command === void 0 && !args && event.argsPayload) lines.push(...renderArgsPayload(event.argsPayload, width, theme));
159
166
  if (output) {
160
167
  for (const outputLine of output.replace(/\s+$/, "").split(/\r?\n/)) {
161
168
  for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) {
@@ -178,12 +185,7 @@ function renderExpandedTool(event, width, theme) {
178
185
  return lines;
179
186
  }
180
187
  lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(event.name))}`, width, theme));
181
- if (event.argsPayload) {
182
- lines.push(railLine(theme.fg("dim", " args"), width, theme));
183
- for (const argLine of event.argsPayload.split(/\r?\n/)) {
184
- for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
185
- }
186
- }
188
+ if (event.argsPayload) lines.push(...renderArgsPayload(event.argsPayload, width, theme));
187
189
  if (output) {
188
190
  lines.push(railLine(theme.fg(event.status === "error" ? "error" : "dim", event.status === "error" ? " error" : " output"), width, theme));
189
191
  for (const outputLine of output.split(/\r?\n/)) {
@@ -195,6 +197,13 @@ function renderExpandedTool(event, width, theme) {
195
197
  function bounded(text, width) {
196
198
  return truncateToWidth(text, Math.max(0, width));
197
199
  }
200
+ function renderArgsPayload(payload, width, theme) {
201
+ const lines = [railLine(theme.fg("dim", " args"), width, theme)];
202
+ for (const argLine of payload.split(/\r?\n/)) {
203
+ for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
204
+ }
205
+ return lines;
206
+ }
198
207
  function railLine(content, width, theme) {
199
208
  return bounded(`${theme.fg("borderMuted", "\u2502")} ${content}`, width);
200
209
  }
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  formatShellCommand
3
- } from "./chunk-7J4ZXMY7.js";
3
+ } from "./chunk-72334PEI.js";
4
4
  import {
5
5
  getProjectSubagentsDir
6
- } from "./chunk-S77ZKDLS.js";
6
+ } from "./chunk-77VQEATI.js";
7
7
  import {
8
8
  getPiSpawnCommand,
9
9
  writeAtomicJson
10
- } from "./chunk-GHJ6BH5U.js";
10
+ } from "./chunk-LWH7IGI3.js";
11
11
 
12
12
  // src/inspectors/herdr/project-panes.ts
13
13
  import * as fs from "node:fs";
@@ -389,10 +389,14 @@ async function inspectPane(client, paneId, signal) {
389
389
  if (!runtime) return projectPaneError("INVALID_PANE_RESPONSE", `Herdr pane get returned no pane runtime for '${paneId}'.`, { details: live.data });
390
390
  return { ok: true, data: runtime };
391
391
  }
392
+ function projectPaneShellFlavor(platform, shell) {
393
+ if (platform !== "win32") return "auto";
394
+ return /(^|[\\/])(bash|zsh|sh|dash|ksh)(\.exe)?$/i.test(shell ?? "") ? "posix" : "auto";
395
+ }
392
396
  function projectPaneCommand(message) {
393
397
  const args = message?.trim() ? [message.trim()] : [];
394
398
  const command = getPiSpawnCommand(args);
395
- return formatShellCommand(command.command, command.args);
399
+ return formatShellCommand(command.command, command.args, process.platform, projectPaneShellFlavor(process.platform, process.env.SHELL));
396
400
  }
397
401
  function canonicalRuntimePath(value) {
398
402
  if (!value) return void 0;
@@ -11,10 +11,10 @@ import {
11
11
  startWatchdogDiffBaselineCapture,
12
12
  writeUserWatchdogEnabled,
13
13
  writeWatchdogModelSettings
14
- } from "./chunk-TGABNSG5.js";
14
+ } from "./chunk-2UCFLUE4.js";
15
15
  import {
16
16
  resolveGitRepositoryIdentity
17
- } from "./chunk-7W2IQFP4.js";
17
+ } from "./chunk-464OJSDP.js";
18
18
  import {
19
19
  formatParallelHandoffLines,
20
20
  listAsyncRuns,
@@ -25,7 +25,7 @@ import {
25
25
  readKeptBranches,
26
26
  readWorkflowLaunchRecord,
27
27
  resolveRetainedWorktreeCwd
28
- } from "./chunk-6JD4XCA4.js";
28
+ } from "./chunk-U753SUBC.js";
29
29
  import {
30
30
  ownsRun
31
31
  } from "./chunk-HXRB42AF.js";
@@ -57,24 +57,24 @@ import {
57
57
  resolveMissionStoreLocation,
58
58
  validateMissionId,
59
59
  workflowRunParamsFingerprint
60
- } from "./chunk-SLLZJ5EC.js";
60
+ } from "./chunk-DHY5TY2Y.js";
61
61
  import {
62
62
  requestAsyncCommand,
63
63
  watchAsyncControlInbox
64
- } from "./chunk-A3INCQ6Z.js";
64
+ } from "./chunk-UUW7P6KJ.js";
65
65
  import {
66
66
  supervisorChannelDir
67
- } from "./chunk-HZDLR73C.js";
67
+ } from "./chunk-AHGJSJYY.js";
68
68
  import {
69
69
  createRequiredChildExtensionIdentity
70
70
  } from "./chunk-YARY7JWU.js";
71
71
  import {
72
72
  createHerdrClient,
73
73
  detectHerdr
74
- } from "./chunk-JFACGAJT.js";
74
+ } from "./chunk-JEYG7CNC.js";
75
75
  import {
76
76
  getProjectSubagentsDir
77
- } from "./chunk-S77ZKDLS.js";
77
+ } from "./chunk-77VQEATI.js";
78
78
  import {
79
79
  ExternalJobProviderError,
80
80
  getExternalJobProvider,
@@ -84,7 +84,7 @@ import {
84
84
  } from "./chunk-YYREO77V.js";
85
85
  import {
86
86
  mergeRuntimeAgents
87
- } from "./chunk-KOLLMZ2X.js";
87
+ } from "./chunk-SWGB2P5J.js";
88
88
  import {
89
89
  CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL,
90
90
  EXTERNAL_CLI_ADAPTER_SAFETY,
@@ -145,7 +145,7 @@ import {
145
145
  withFileLease,
146
146
  writeAtomicJson,
147
147
  writePrivateAtomicJson
148
- } from "./chunk-GHJ6BH5U.js";
148
+ } from "./chunk-LWH7IGI3.js";
149
149
  import {
150
150
  DIRS,
151
151
  INTERCOM_DETACH_REQUEST_EVENT,
@@ -7888,7 +7888,7 @@ function childSessionFactory() {
7888
7888
  }
7889
7889
  function createLazyPlacementFactory(local) {
7890
7890
  let placed;
7891
- const factory = async () => placed ??= (await import("./chunk-NQ26PJSQ.js")).createPlacementAwareChildSessionFactory(local);
7891
+ const factory = async () => placed ??= (await import("./chunk-FF5K5HQU.js")).createPlacementAwareChildSessionFactory(local);
7892
7892
  return {
7893
7893
  async create(launch) {
7894
7894
  return launch.machine ? (await factory()).create(launch) : local.create(launch);
@@ -7664,6 +7664,13 @@ function resolveChildCwd(baseCwd, childCwd) {
7664
7664
  function isNotFoundError(error) {
7665
7665
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
7666
7666
  }
7667
+ function isStatusAccessError(error, asyncDir) {
7668
+ const code = error?.cause?.code;
7669
+ if (code !== "EACCES" && code !== "EPERM") return false;
7670
+ const message = error instanceof Error ? error.message : "";
7671
+ const quotedPath = `'${path16.join(asyncDir, "status.json")}':`;
7672
+ return message.startsWith(`Failed to inspect async status file ${quotedPath}`) || message.startsWith(`Failed to read async status file ${quotedPath}`);
7673
+ }
7667
7674
  function readStatus(asyncDir) {
7668
7675
  if (Buffer.byteLength(path16.basename(asyncDir), "utf-8") > 255) {
7669
7676
  return null;
@@ -8720,6 +8727,7 @@ export {
8720
8727
  getProjectConfigDir,
8721
8728
  getAgentDir,
8722
8729
  resolveChildCwd,
8730
+ isStatusAccessError,
8723
8731
  readStatus,
8724
8732
  findLatestSessionFile,
8725
8733
  assistantMessageError,
@@ -10,10 +10,10 @@ import {
10
10
  setInlineWorkflowCoverage,
11
11
  setMainThinkingLevelSource,
12
12
  widgetRenderKey
13
- } from "./chunk-WW6GQBBS.js";
13
+ } from "./chunk-SRCMJY4F.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-4ALRHKGE.js";
16
+ } from "./chunk-DGLXVN3F.js";
17
17
  import {
18
18
  EXTERNAL_JOB_BRIDGE_REQUEST_DIR,
19
19
  REVIVAL_ORIGIN_FILE,
@@ -66,7 +66,7 @@ import {
66
66
  takeCompactionAbort,
67
67
  workflowResumeClaimState,
68
68
  workflowResumeRefusal
69
- } from "./chunk-X5ZOTDHO.js";
69
+ } from "./chunk-KA4MKMYT.js";
70
70
  import {
71
71
  SUBAGENT_CHILD_ENV,
72
72
  SUBAGENT_PARENT_SESSION_ENV,
@@ -86,14 +86,14 @@ import {
86
86
  resolvePiSessionId,
87
87
  resolveWaitToolConfig,
88
88
  setDeclarationPinning
89
- } from "./chunk-TGABNSG5.js";
89
+ } from "./chunk-2UCFLUE4.js";
90
90
  import {
91
91
  deliverAsyncRunStop,
92
92
  ownerConfirmedDead,
93
93
  readSessionMessagesTail,
94
94
  resolveSubagentRunId,
95
95
  restoreForegroundRunHistory
96
- } from "./chunk-7W2IQFP4.js";
96
+ } from "./chunk-464OJSDP.js";
97
97
  import {
98
98
  ASYNC_STATUS_SNAPSHOT_KIND,
99
99
  ASYNC_STATUS_SNAPSHOT_VERSION,
@@ -108,8 +108,9 @@ import {
108
108
  resolveAsyncRunLocation,
109
109
  resolveAsyncStatusChild,
110
110
  runLaunchDir,
111
- stopStoppableAsyncStatusChildren
112
- } from "./chunk-6JD4XCA4.js";
111
+ stopStoppableAsyncStatusChildren,
112
+ summarizeAsyncStatus
113
+ } from "./chunk-U753SUBC.js";
113
114
  import {
114
115
  CONTACT_SUPERVISOR_TOOL_NAME,
115
116
  NATIVE_SUPERVISOR_TOOL_NAME,
@@ -119,7 +120,7 @@ import {
119
120
  parseSupervisorReplyData,
120
121
  parseSupervisorRequestDetails,
121
122
  topLevelSupervisorTool
122
- } from "./chunk-EPMRDKQT.js";
123
+ } from "./chunk-VEEUXJDO.js";
123
124
  import {
124
125
  MODEL_ONLY_TOOL,
125
126
  canRenderComponents,
@@ -145,7 +146,7 @@ import {
145
146
  resolveDisabledFeatureSurface,
146
147
  resolveMaxActiveAsyncRunsPerSession,
147
148
  resolveScheduledStoreRoot
148
- } from "./chunk-ETDE2VYK.js";
149
+ } from "./chunk-4KQW5R6U.js";
149
150
  import {
150
151
  ACTIVE_RUN_INDEX_DIR,
151
152
  MissionNotFoundError,
@@ -196,28 +197,28 @@ import {
196
197
  withWorkflowChildRunModel,
197
198
  writeAsyncResultFile,
198
199
  writeResultIndexForData
199
- } from "./chunk-SLLZJ5EC.js";
200
- import "./chunk-A3INCQ6Z.js";
200
+ } from "./chunk-DHY5TY2Y.js";
201
+ import "./chunk-UUW7P6KJ.js";
201
202
  import {
202
203
  shouldUseNativeFsWatch
203
204
  } from "./chunk-NIXWDZZV.js";
204
205
  import {
205
206
  validateIntercomBridgeConfig
206
- } from "./chunk-NONHDYXE.js";
207
+ } from "./chunk-YJIU5WF4.js";
207
208
  import "./chunk-7F6RKT6W.js";
208
- import "./chunk-HZDLR73C.js";
209
+ import "./chunk-AHGJSJYY.js";
209
210
  import "./chunk-YARY7JWU.js";
210
211
  import {
211
212
  listHerdrProjectPaneRoots,
212
213
  restoreHerdrProjectPaneSnapshots
213
- } from "./chunk-JFACGAJT.js";
214
- import "./chunk-7J4ZXMY7.js";
214
+ } from "./chunk-JEYG7CNC.js";
215
+ import "./chunk-72334PEI.js";
215
216
  import {
216
217
  cleanupAllArtifactDirs,
217
218
  cleanupOldArtifacts,
218
219
  getArtifactPaths,
219
220
  getArtifactsDir
220
- } from "./chunk-S77ZKDLS.js";
221
+ } from "./chunk-77VQEATI.js";
221
222
  import {
222
223
  listBackgroundWorkProviders
223
224
  } from "./chunk-XA3DY6UG.js";
@@ -225,12 +226,12 @@ import "./chunk-YYREO77V.js";
225
226
  import "./chunk-UKG4V45O.js";
226
227
  import {
227
228
  registerRuntimeAgentEventListener
228
- } from "./chunk-JRO2CU4D.js";
229
+ } from "./chunk-5TXWZB73.js";
229
230
  import {
230
231
  clearRuntimeAgentsForPi,
231
232
  listRuntimeAgentConfigs,
232
233
  mergeRuntimeAgents
233
- } from "./chunk-KOLLMZ2X.js";
234
+ } from "./chunk-SWGB2P5J.js";
234
235
  import {
235
236
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
236
237
  DEFAULT_WAIT_TOOL_NAME,
@@ -253,6 +254,7 @@ import {
253
254
  getPiSpawnCommand,
254
255
  getProjectConfigDir,
255
256
  getSupportedThinkingLevels,
257
+ isStatusAccessError,
256
258
  mergeBuiltinAgentOverride,
257
259
  parseFrontmatter,
258
260
  readStatus,
@@ -273,7 +275,7 @@ import {
273
275
  waitToolName,
274
276
  withSettingsFileLease,
275
277
  writeAtomicJson
276
- } from "./chunk-GHJ6BH5U.js";
278
+ } from "./chunk-LWH7IGI3.js";
277
279
  import {
278
280
  DEFAULT_ARTIFACT_CONFIG,
279
281
  DIRS,
@@ -597,6 +599,8 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
597
599
  const runningJobIds = /* @__PURE__ */ new Set();
598
600
  const externalJobBridgeRuns = /* @__PURE__ */ new Set();
599
601
  const terminalPublications = /* @__PURE__ */ new Map();
602
+ const unreadableStatusRuns = /* @__PURE__ */ new Set();
603
+ const unverifiedRuns = /* @__PURE__ */ new Set();
600
604
  const supervisorNoticeTimers = /* @__PURE__ */ new Map();
601
605
  let rootWatcher;
602
606
  let nextLivenessAt = Date.now() + livenessIntervalMs;
@@ -919,9 +923,47 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
919
923
  runningJobIds.delete(asyncId);
920
924
  externalJobBridgeRuns.delete(asyncId);
921
925
  terminalPublications.delete(asyncId);
926
+ unreadableStatusRuns.delete(asyncId);
927
+ unverifiedRuns.delete(asyncId);
922
928
  clearSupervisorNotices(asyncId);
923
929
  };
930
+ const forgetJob = (asyncId) => {
931
+ cancelCleanup(asyncId);
932
+ closeJobWatcher(asyncId);
933
+ state.asyncJobs.delete(asyncId);
934
+ state.fleetJobs?.delete(asyncId);
935
+ options.onJobCleanup?.(asyncId);
936
+ };
924
937
  const refreshJob = (job) => {
938
+ if (unverifiedRuns.has(job.asyncId)) {
939
+ let stored = null;
940
+ let summary;
941
+ try {
942
+ stored = readStatus(job.asyncDir);
943
+ if (stored) summary = summarizeAsyncStatus(job.asyncDir, stored);
944
+ } catch (error) {
945
+ if (isStatusAccessError(error, job.asyncDir)) return false;
946
+ console.error(`[pi-subagents] Dropping restored async run '${job.asyncId}' at '${path2.join(job.asyncDir, "status.json")}': ${error instanceof Error ? error.message : String(error)}.`);
947
+ }
948
+ const owners = state.currentSessionId ? ownerSessionIds(state.currentSessionId) : void 0;
949
+ if (!stored || !summary || owners && !owners.has(stored.sessionId)) {
950
+ forgetJob(job.asyncId);
951
+ return true;
952
+ }
953
+ let restored;
954
+ try {
955
+ restored = summaryToJob(summary);
956
+ } catch (error) {
957
+ if (!unreadableStatusRuns.has(job.asyncId)) {
958
+ unreadableStatusRuns.add(job.asyncId);
959
+ console.error(`Cannot read async control events for '${job.asyncDir}'; keeping it as running until they are readable:`, error);
960
+ }
961
+ return false;
962
+ }
963
+ Object.assign(job, restored, { status: job.status, controlEventCursor: job.controlEventCursor ?? restored.controlEventCursor });
964
+ rememberFleetJob(state, job);
965
+ unverifiedRuns.delete(job.asyncId);
966
+ }
925
967
  const widgetExpanded = withLastUiContext((ctx) => ctx.ui.getToolsExpanded?.() ?? false) ?? false;
926
968
  const widgetStateBefore = widgetRenderKey(job, widgetExpanded);
927
969
  let nestedRefreshFailed = false;
@@ -967,6 +1009,7 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
967
1009
  }
968
1010
  });
969
1011
  const status = reconciliation.status ?? readStatus(job.asyncDir);
1012
+ unreadableStatusRuns.delete(job.asyncId);
970
1013
  if (!bridgeAlreadyRequired) {
971
1014
  const bridgeEligibility = externalJobBridgeEligibility(status?.steps);
972
1015
  if (bridgeEligibility === "required") externalJobBridgeRuns.add(job.asyncId);
@@ -1075,6 +1118,13 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
1075
1118
  console.error(`Failed to service external job bridge for '${job.asyncDir}':`, bridgeError);
1076
1119
  }
1077
1120
  }
1121
+ if (isStatusAccessError(error, job.asyncDir)) {
1122
+ if (!unreadableStatusRuns.has(job.asyncId)) {
1123
+ unreadableStatusRuns.add(job.asyncId);
1124
+ console.error(`Cannot read async status for '${job.asyncDir}'; keeping its last known state until it is readable:`, error);
1125
+ }
1126
+ return widgetRenderKey(job, widgetExpanded) !== widgetStateBefore;
1127
+ }
1078
1128
  if (job.status !== "failed") {
1079
1129
  console.error(`Failed to read async status for '${job.asyncDir}':`, error);
1080
1130
  job.status = "failed";
@@ -1192,11 +1242,7 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
1192
1242
  const owners = state.currentSessionId ? ownerSessionIds(state.currentSessionId) : void 0;
1193
1243
  for (const job of state.asyncJobs.values()) {
1194
1244
  if (owners && job.sessionId !== void 0 && !owners.has(job.sessionId)) {
1195
- cancelCleanup(job.asyncId);
1196
- closeJobWatcher(job.asyncId);
1197
- state.asyncJobs.delete(job.asyncId);
1198
- state.fleetJobs?.delete(job.asyncId);
1199
- options.onJobCleanup?.(job.asyncId);
1245
+ forgetJob(job.asyncId);
1200
1246
  widgetChanged = true;
1201
1247
  continue;
1202
1248
  }
@@ -1305,6 +1351,8 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
1305
1351
  runningJobIds.clear();
1306
1352
  externalJobBridgeRuns.clear();
1307
1353
  terminalPublications.clear();
1354
+ unreadableStatusRuns.clear();
1355
+ unverifiedRuns.clear();
1308
1356
  clearSupervisorNotices();
1309
1357
  };
1310
1358
  const resetJobs = (ctx) => {
@@ -1328,8 +1376,17 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
1328
1376
  state.statusProjectionSessionId = null;
1329
1377
  if (!state.currentSessionId) return;
1330
1378
  let runs;
1379
+ const unreadable = [];
1331
1380
  try {
1332
- runs = listAsyncRuns(asyncDirRoot, { states: ["queued", "running"], sessionId: state.currentSessionId, resultsDir, kill: options.kill, now: options.now, adoptCompletionOwnerId: state.completionOwnerId }, observeStatus);
1381
+ runs = listAsyncRuns(asyncDirRoot, {
1382
+ states: ["queued", "running"],
1383
+ sessionId: state.currentSessionId,
1384
+ resultsDir,
1385
+ kill: options.kill,
1386
+ now: options.now,
1387
+ adoptCompletionOwnerId: state.completionOwnerId,
1388
+ onUnreadableActiveRun: (runId, asyncDir) => unreadable.push({ runId, asyncDir })
1389
+ }, observeStatus);
1333
1390
  } catch (error) {
1334
1391
  console.error(`Failed to restore active async jobs from '${asyncDirRoot}':`, error);
1335
1392
  return;
@@ -1341,8 +1398,20 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
1341
1398
  rememberFleetJob(state, job);
1342
1399
  watchJob(job);
1343
1400
  }
1401
+ for (const { runId, asyncDir } of unreadable) {
1402
+ if (state.asyncJobs.has(runId)) continue;
1403
+ const job = { asyncId: runId, asyncDir, status: "running", sessionId: state.currentSessionId, updatedAt: Date.now() };
1404
+ try {
1405
+ job.controlEventCursor = restoredControlEventCursor(asyncDir);
1406
+ } catch {
1407
+ }
1408
+ state.asyncJobs.set(runId, job);
1409
+ runningJobIds.add(runId);
1410
+ unverifiedRuns.add(runId);
1411
+ watchJob(job);
1412
+ }
1344
1413
  state.statusProjectionSessionId = state.currentSessionId;
1345
- if (runs.length === 0) return;
1414
+ if (runs.length === 0 && unreadable.length === 0) return;
1346
1415
  ensurePoller();
1347
1416
  rerenderLastWidget();
1348
1417
  };
@@ -5370,7 +5439,7 @@ function registerSlashCommands(pi, state, options = {}) {
5370
5439
  }
5371
5440
  fleetOpen = true;
5372
5441
  try {
5373
- const { openSubagentFleet } = await import("./chunk-HSHLPYCQ.js");
5442
+ const { openSubagentFleet } = await import("./chunk-FO2GIU5F.js");
5374
5443
  await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: () => getInspectorPlugins(pi), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
5375
5444
  } finally {
5376
5445
  fleetOpen = false;
@@ -8784,7 +8853,7 @@ function registerSubagentExtension(pi) {
8784
8853
  const ctx = withLastUiContext((current) => current);
8785
8854
  if (!ctx) return;
8786
8855
  try {
8787
- const { openSubagentFleet } = await import("./chunk-HSHLPYCQ.js");
8856
+ const { openSubagentFleet } = await import("./chunk-FO2GIU5F.js");
8788
8857
  await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings, inspectorPlugins: () => getInspectorPlugins(pi) });
8789
8858
  } catch (error) {
8790
8859
  if (isStaleExtensionContextError(error)) {
@@ -8993,7 +9062,7 @@ function registerSubagentExtension(pi) {
8993
9062
  let executor;
8994
9063
  let executorPromise;
8995
9064
  let executorModulePromise;
8996
- const loadExecutorModule = () => executorModulePromise ??= import("./chunk-CHEABMO2.js");
9065
+ const loadExecutorModule = () => executorModulePromise ??= import("./chunk-76WVWEFE.js");
8997
9066
  const getExecutor = () => {
8998
9067
  executorPromise ??= loadExecutorModule().then(({ createSubagentExecutor }) => {
8999
9068
  executor = createSubagentExecutor(executorDeps);
@@ -9007,7 +9076,7 @@ function registerSubagentExtension(pi) {
9007
9076
  modulePreloadTimer = setTimeout(() => {
9008
9077
  loadExecutorModule().catch(() => {
9009
9078
  });
9010
- if (fleetViewEnabled) import("./chunk-HSHLPYCQ.js").catch(() => {
9079
+ if (fleetViewEnabled) import("./chunk-FO2GIU5F.js").catch(() => {
9011
9080
  });
9012
9081
  }, MODULE_PRELOAD_DELAY_MS);
9013
9082
  modulePreloadTimer.unref?.();
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getProjectSubagentsDir
3
- } from "./chunk-S77ZKDLS.js";
3
+ } from "./chunk-77VQEATI.js";
4
4
  import {
5
5
  discoverAgents,
6
6
  formatUnknownAgentError,
7
7
  resolveAgentName,
8
8
  unknownAgentDiagnosticContext
9
- } from "./chunk-GHJ6BH5U.js";
9
+ } from "./chunk-LWH7IGI3.js";
10
10
 
11
11
  // src/agents/agent-refinements.ts
12
12
  import { createHash, randomUUID } from "node:crypto";