pi-subagents 0.88.1 → 0.89.1

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 (93) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
  5. package/bundle/{chunk-5EMPFFO4.js → chunk-4FFKVLBG.js} +4 -4
  6. package/bundle/{chunk-L4YY2TOE.js → chunk-5TXWZB73.js} +1 -1
  7. package/bundle/{chunk-ZJ2BT5TI.js → chunk-6D54VW3E.js} +56 -34
  8. package/bundle/{chunk-YDZ7BZD5.js → chunk-77VQEATI.js} +1 -1
  9. package/bundle/{chunk-7OX6O7DQ.js → chunk-BERAWSQQ.js} +5 -5
  10. package/bundle/{chunk-LV3CPYXJ.js → chunk-C22YEYFZ.js} +4 -4
  11. package/bundle/{chunk-VTUUOLM4.js → chunk-CASL47ST.js} +34 -5
  12. package/bundle/{chunk-YQSTGPEU.js → chunk-F6PTAPQ3.js} +75 -32
  13. package/bundle/{chunk-FLNDHNPE.js → chunk-IGZTXGPG.js} +98 -29
  14. package/bundle/{chunk-CPSUJHZE.js → chunk-KCDPTXHT.js} +39 -10
  15. package/bundle/{chunk-PCZEQQAQ.js → chunk-LUNVS6KP.js} +26 -15
  16. package/bundle/{chunk-4MVDMA5C.js → chunk-LWH7IGI3.js} +21 -7
  17. package/bundle/{chunk-DSHQWGHO.js → chunk-MIX3MCIF.js} +96 -96
  18. package/bundle/{chunk-2DIEL4WG.js → chunk-OUM6SEVD.js} +2 -2
  19. package/bundle/{chunk-XIA5GSEU.js → chunk-Q4VH72JI.js} +2 -2
  20. package/bundle/{chunk-D32H53HM.js → chunk-R3NH5XAL.js} +1 -1
  21. package/bundle/{chunk-6OWNDN7R.js → chunk-ROJH7KPK.js} +2 -2
  22. package/bundle/{chunk-4ZQBZDF3.js → chunk-SG3NCWZW.js} +86 -20
  23. package/bundle/{chunk-KXW62VBU.js → chunk-SWGB2P5J.js} +1 -1
  24. package/bundle/{chunk-N6TAAIB3.js → chunk-TDXVQPZW.js} +5 -5
  25. package/bundle/{chunk-6CG2VAG4.js → chunk-TRN65L4F.js} +1 -1
  26. package/bundle/{chunk-GDR2ILWY.js → chunk-TXC7WIPL.js} +51 -22
  27. package/bundle/{chunk-PYKBTBY6.js → chunk-URKQZHVH.js} +9 -9
  28. package/bundle/{chunk-W6HIYD2Z.js → chunk-UUW7P6KJ.js} +1 -1
  29. package/bundle/{chunk-CYKNHFXB.js → chunk-VEEUXJDO.js} +1 -1
  30. package/bundle/{chunk-47ZN7NKR.js → chunk-YJIU5WF4.js} +1 -1
  31. package/bundle/{chunk-RMZAAXIR.js → chunk-YLU5JFW2.js} +2 -2
  32. package/bundle/control-channel.js +2 -2
  33. package/bundle/index.js +2 -2
  34. package/bundle/intercom-bridge.js +2 -2
  35. package/bundle/preflight.js +8 -8
  36. package/bundle/project-panes.js +3 -3
  37. package/docs/agents.md +10 -4
  38. package/docs/configuration.md +2 -0
  39. package/docs/extension-api.md +1 -1
  40. package/docs/tool-reference.md +1 -1
  41. package/docs/workflows.md +5 -3
  42. package/package.json +1 -1
  43. package/src/extension/herdr-pi-bridge.js +79 -23
  44. package/src/extension/schemas.js +1 -1
  45. package/src/extension/subagent-options.js +5 -0
  46. package/src/intercom/result-intercom.js +3 -2
  47. package/src/runs/background/async-job-tracker.js +85 -9
  48. package/src/runs/background/async-status.d.ts +2 -0
  49. package/src/runs/background/async-status.js +8 -3
  50. package/src/runs/background/notify.d.ts +3 -0
  51. package/src/runs/background/notify.js +7 -2
  52. package/src/runs/background/run-status.js +3 -2
  53. package/src/runs/background/runner-child-launch.js +1 -0
  54. package/src/runs/background/subagent-runner.js +11 -8
  55. package/src/runs/foreground/execution.js +8 -7
  56. package/src/runs/foreground/subagent-executor.js +31 -5
  57. package/src/runs/shared/child-launch.d.ts +2 -0
  58. package/src/runs/shared/child-launch.js +1 -1
  59. package/src/runs/shared/child-session.d.ts +2 -1
  60. package/src/runs/shared/herdr-connection.d.ts +6 -0
  61. package/src/runs/shared/herdr-connection.js +11 -1
  62. package/src/runs/shared/herdr-machine.d.ts +2 -2
  63. package/src/runs/shared/herdr-machine.js +49 -22
  64. package/src/runs/shared/herdr-pane-host.d.ts +7 -19
  65. package/src/runs/shared/herdr-pane-host.js +48 -33
  66. package/src/runs/shared/herdr-pi-protocol.d.ts +1 -0
  67. package/src/runs/shared/herdr-pi-protocol.js +3 -2
  68. package/src/runs/shared/herdr-placed-run.d.ts +2 -12
  69. package/src/runs/shared/herdr-placed-run.js +10 -8
  70. package/src/runs/shared/kept-branch-text.d.ts +8 -0
  71. package/src/runs/shared/kept-branch-text.js +24 -0
  72. package/src/runs/shared/local-machine-access.d.ts +4 -1
  73. package/src/runs/shared/local-machine-access.js +6 -3
  74. package/src/runs/shared/mutation-evidence.d.ts +7 -1
  75. package/src/runs/shared/mutation-evidence.js +18 -2
  76. package/src/runs/shared/parallel-handoff.js +19 -7
  77. package/src/runs/shared/placed-run-owner.d.ts +4 -2
  78. package/src/runs/shared/placed-run-owner.js +15 -7
  79. package/src/runs/shared/rex-machine.d.ts +7 -3
  80. package/src/runs/shared/rex-machine.js +12 -9
  81. package/src/runs/shared/rex-pane-host.js +7 -27
  82. package/src/runs/shared/single-output.js +2 -2
  83. package/src/runs/shared/subagent-prompt-runtime.js +34 -0
  84. package/src/runs/shared/tool-availability.d.ts +4 -0
  85. package/src/runs/shared/tool-availability.js +7 -0
  86. package/src/runs/shared/worktree-cleanup-plan.js +2 -2
  87. package/src/runs/shared/worktree.d.ts +4 -14
  88. package/src/runs/shared/worktree.js +38 -8
  89. package/src/shared/types.d.ts +26 -2
  90. package/src/shared/utils.d.ts +2 -0
  91. package/src/shared/utils.js +9 -0
  92. package/src/workflows/workflow-child-summary.d.ts +2 -1
  93. package/src/workflows/workflow-child-summary.js +14 -6
@@ -119,6 +119,15 @@ function isNotFoundError(error) {
119
119
  && "code" in error
120
120
  && error.code === "ENOENT";
121
121
  }
122
+ /** A `readStatus(asyncDir)` error caused by permissions on that run's own status file, which says nothing about whether its runner is alive. */
123
+ export function isStatusAccessError(error, asyncDir) {
124
+ const code = error?.cause?.code;
125
+ if (code !== "EACCES" && code !== "EPERM")
126
+ return false;
127
+ const message = error instanceof Error ? error.message : "";
128
+ const quotedPath = `'${path.join(asyncDir, "status.json")}':`;
129
+ return message.startsWith(`Failed to inspect async status file ${quotedPath}`) || message.startsWith(`Failed to read async status file ${quotedPath}`);
130
+ }
122
131
  export function readStatus(asyncDir) {
123
132
  if (Buffer.byteLength(path.basename(asyncDir), "utf-8") > 255) {
124
133
  return null;
@@ -14,10 +14,11 @@ export declare function workflowChildSummary(input: {
14
14
  steps?: NonNullable<AsyncStatus["steps"]>;
15
15
  /** In-memory snapshots from synchronous child callbacks, keyed by workflow key. */
16
16
  progress?: ReadonlyMap<string, WorkflowChildLiveProgress>;
17
- /** Agent and run id each child launched with, keyed by workflow key; known before an async child settles. */
17
+ /** Agent, run id and session file each child launched with, keyed by workflow key; known before an async child settles. */
18
18
  launches?: ReadonlyMap<string, {
19
19
  agent: string;
20
20
  runId?: string;
21
+ sessionFile?: string;
21
22
  }>;
22
23
  }): WorkflowChildSummary;
23
24
  export declare function parseWorkflowChildSummary(value: unknown): WorkflowChildSummary | undefined;
@@ -2,6 +2,8 @@ import { hashedSegment } from "../runs/background/index-segment.js";
2
2
  const KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
3
3
  const TERMINAL_STATES = new Set(["completed", "failed", "paused", "stopped", "rejected", "detached"]);
4
4
  const MAX_REQUIRED_ID_BYTES = 4_096;
5
+ /** Linux PATH_MAX: a longer session path cannot be opened anyway. */
6
+ const MAX_SESSION_FILE_BYTES = 4_096;
5
7
  const ACTIVITY_COUNTERS = ["currentToolStartedAt", "lastActivityAt", "durationMs", "toolCount", "turnCount", "tokens", "inputTokens", "outputTokens"];
6
8
  export function workflowChildProgress(progress) {
7
9
  return {
@@ -71,6 +73,7 @@ export function workflowChildSummary(input) {
71
73
  ...(bounded(entry.runId, 256) ? { runId: bounded(entry.runId, 256) } : {}),
72
74
  ...(previous?.agent ? { agent: previous.agent } : {}),
73
75
  ...(previous?.sessionName ? { sessionName: previous.sessionName } : {}),
76
+ ...(previous?.sessionFile ? { sessionFile: previous.sessionFile } : {}),
74
77
  ...(previous?.model ? { model: previous.model } : {}),
75
78
  ...(previous?.thinking ? { thinking: previous.thinking } : {}),
76
79
  });
@@ -94,6 +97,7 @@ export function workflowChildSummary(input) {
94
97
  ...(bounded(step.runId, 256) ? { runId: bounded(step.runId, 256) } : {}),
95
98
  ...(launchResolved && bounded(step.agent, 256) ? { agent: bounded(step.agent, 256) } : {}),
96
99
  ...(bounded(step.sessionName, 256) ? { sessionName: bounded(step.sessionName, 256) } : {}),
100
+ ...(bounded(step.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: step.sessionFile } : {}),
97
101
  ...(bounded(step.model, 256) ? { model: bounded(step.model, 256) } : {}),
98
102
  ...(bounded(step.thinking, 32) ? { thinking: bounded(step.thinking, 32) } : {}),
99
103
  });
@@ -109,6 +113,7 @@ export function workflowChildSummary(input) {
109
113
  ...(bounded(child.runId, 256) ? { runId: bounded(child.runId, 256) } : {}),
110
114
  ...(bounded(child.agent, 256) ? { agent: bounded(child.agent, 256) } : {}),
111
115
  ...(bounded(result?.sessionName, 256) ? { sessionName: bounded(result?.sessionName, 256) } : {}),
116
+ ...(bounded(result?.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: result?.sessionFile } : {}),
112
117
  ...(bounded(result?.model, 256) ? { model: bounded(result?.model, 256) } : {}),
113
118
  ...(bounded(result?.thinking, 32) ? { thinking: bounded(result?.thinking, 32) } : {}),
114
119
  });
@@ -121,12 +126,15 @@ export function workflowChildSummary(input) {
121
126
  }
122
127
  for (const [key, launch] of input.launches ?? []) {
123
128
  const row = rows.get(key);
124
- if (!row || row.state !== "running")
129
+ if (!row)
125
130
  continue;
131
+ const running = row.state === "running";
126
132
  rows.set(key, {
127
133
  ...row,
128
- ...(!row.runId && bounded(launch.runId, 256) ? { runId: launch.runId } : {}),
129
- ...(!row.agent && bounded(launch.agent, 256) ? { agent: launch.agent } : {}),
134
+ ...(running && !row.runId && bounded(launch.runId, 256) ? { runId: launch.runId } : {}),
135
+ ...(running && !row.agent && bounded(launch.agent, 256) ? { agent: launch.agent } : {}),
136
+ // Finished rows keep it too: live updates carry no child results, so this is a settled child's only transcript link until the workflow returns.
137
+ ...(!row.sessionFile && bounded(launch.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: launch.sessionFile } : {}),
130
138
  });
131
139
  }
132
140
  for (const [key, progress] of input.progress ?? []) {
@@ -169,21 +177,21 @@ export function parseWorkflowChildSummary(value) {
169
177
  if (!row || typeof row !== "object" || Array.isArray(row))
170
178
  throw new Error("workflowChildren child row is invalid.");
171
179
  const child = row;
172
- if (Object.keys(child).some((key) => !["childId", "runId", "agent", "sessionName", "model", "thinking", "state", "activity"].includes(key)))
180
+ if (Object.keys(child).some((key) => !["childId", "runId", "agent", "sessionName", "sessionFile", "model", "thinking", "state", "activity"].includes(key)))
173
181
  throw new Error("workflowChildren child row has unsupported fields.");
174
182
  if (typeof child.childId !== "string" || !KEY_PATTERN.test(child.childId))
175
183
  throw new Error("workflowChildren childId is invalid.");
176
184
  const state = child.state;
177
185
  if (state !== "pending" && state !== "running" && state !== "completed" && state !== "failed" && state !== "paused" && state !== "stopped" && state !== "rejected" && state !== "detached")
178
186
  throw new Error("workflowChildren child state is invalid.");
179
- for (const [field, maxBytes] of [["runId", 256], ["agent", 256], ["sessionName", 256], ["model", 256], ["thinking", 32]]) {
187
+ for (const [field, maxBytes] of [["runId", 256], ["agent", 256], ["sessionName", 256], ["sessionFile", MAX_SESSION_FILE_BYTES], ["model", 256], ["thinking", 32]]) {
180
188
  if (child[field] !== undefined && bounded(child[field], maxBytes) === undefined)
181
189
  throw new Error(`workflowChildren child ${field} is invalid.`);
182
190
  }
183
191
  const activity = parseActivity(child.activity);
184
192
  if (activity && state !== "running")
185
193
  throw new Error("workflowChildren child activity requires running state.");
186
- return { childId: child.childId, state, ...(activity ? { activity } : {}), ...(child.runId ? { runId: child.runId } : {}), ...(child.agent ? { agent: child.agent } : {}), ...(child.sessionName ? { sessionName: child.sessionName } : {}), ...(child.model ? { model: child.model } : {}), ...(child.thinking ? { thinking: child.thinking } : {}) };
194
+ return { childId: child.childId, state, ...(activity ? { activity } : {}), ...(child.runId ? { runId: child.runId } : {}), ...(child.agent ? { agent: child.agent } : {}), ...(child.sessionName ? { sessionName: child.sessionName } : {}), ...(child.sessionFile ? { sessionFile: child.sessionFile } : {}), ...(child.model ? { model: child.model } : {}), ...(child.thinking ? { thinking: child.thinking } : {}) };
187
195
  });
188
196
  if (new Set(children.map((child) => child.childId)).size !== children.length)
189
197
  throw new Error("workflowChildren has duplicate childId values.");