pi-subagents 0.87.0 → 0.88.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 (91) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-3CVOAS77.js → chunk-2DIEL4WG.js} +2 -2
  5. package/bundle/{chunk-PGU4TZV3.js → chunk-3DT5X2QC.js} +406 -447
  6. package/bundle/{chunk-SIAQXPJ4.js → chunk-3MFYKBKI.js} +18 -6
  7. package/bundle/{chunk-AIL46SZU.js → chunk-47GJDBIK.js} +6 -4
  8. package/bundle/{chunk-ESWW6XSX.js → chunk-47ZN7NKR.js} +1 -1
  9. package/bundle/{chunk-C3KWLXDH.js → chunk-4MVDMA5C.js} +9 -1
  10. package/bundle/{chunk-DGTZKYIE.js → chunk-4PM6RDE5.js} +42 -29
  11. package/bundle/{chunk-EYGBK6CE.js → chunk-4UGWHREQ.js} +45 -15
  12. package/bundle/{chunk-HDICKROY.js → chunk-6EUQPQY7.js} +31 -14
  13. package/bundle/{chunk-LFKMM3UH.js → chunk-6OWNDN7R.js} +2 -2
  14. package/bundle/{chunk-M2VBGET6.js → chunk-6PR44R7E.js} +7 -2
  15. package/bundle/{chunk-OOE3R7IQ.js → chunk-CKLZ5FGU.js} +2 -2
  16. package/bundle/{chunk-W52LJANO.js → chunk-CYKNHFXB.js} +1 -1
  17. package/bundle/{chunk-6O7YH2QV.js → chunk-GDR2ILWY.js} +1 -1
  18. package/bundle/{chunk-2D2DQGC2.js → chunk-IZEKQEY4.js} +9 -9
  19. package/bundle/{chunk-C5QWQSSM.js → chunk-KXW62VBU.js} +1 -1
  20. package/bundle/{chunk-BFF6YDK6.js → chunk-L4YY2TOE.js} +1 -1
  21. package/bundle/{chunk-JLDQ6YUR.js → chunk-MTPICU4A.js} +11 -11
  22. package/bundle/{chunk-YEXKJJVS.js → chunk-PJSOS2Q4.js} +4 -4
  23. package/bundle/{chunk-2NY5PCKQ.js → chunk-RHYVKQQL.js} +4 -4
  24. package/bundle/{chunk-XV7RTWTS.js → chunk-SVIXQDIV.js} +20 -5
  25. package/bundle/{chunk-OTLDAYEQ.js → chunk-UVDLJXL6.js} +14 -5
  26. package/bundle/{chunk-VFUFOZBU.js → chunk-W6HIYD2Z.js} +1 -1
  27. package/bundle/{chunk-OZCPYJEY.js → chunk-XAOHLFJO.js} +118 -42
  28. package/bundle/{chunk-USRX7QXD.js → chunk-XIA5GSEU.js} +2 -2
  29. package/bundle/chunk-YDZ7BZD5.js +523 -0
  30. package/bundle/{chunk-LZKVUWIY.js → chunk-YZPVALSQ.js} +30 -5
  31. package/bundle/control-channel.js +2 -2
  32. package/bundle/index.js +1 -1
  33. package/bundle/intercom-bridge.js +2 -2
  34. package/bundle/preflight.js +8 -8
  35. package/bundle/project-panes.js +3 -3
  36. package/docs/agents.md +1 -1
  37. package/docs/configuration.md +7 -3
  38. package/docs/observability.md +2 -0
  39. package/docs/tool-reference.md +4 -1
  40. package/package.json +2 -2
  41. package/skills/pi-subagents/SKILL.md +8 -2
  42. package/src/agents/agent-management.d.ts +1 -0
  43. package/src/agents/agent-management.js +12 -4
  44. package/src/agents/agents.d.ts +1 -0
  45. package/src/agents/agents.js +2 -2
  46. package/src/extension/config.d.ts +1 -0
  47. package/src/extension/config.js +6 -0
  48. package/src/extension/index.js +4 -3
  49. package/src/extension/schemas.d.ts +2 -0
  50. package/src/extension/schemas.js +1 -0
  51. package/src/extension/tool-activation.js +20 -3
  52. package/src/runs/background/async-resume.js +2 -1
  53. package/src/runs/background/async-retention.d.ts +0 -2
  54. package/src/runs/background/async-retention.js +11 -5
  55. package/src/runs/background/async-status.d.ts +2 -0
  56. package/src/runs/background/async-status.js +4 -0
  57. package/src/runs/background/run-child-session.d.ts +2 -2
  58. package/src/runs/background/run-child-session.js +4 -7
  59. package/src/runs/background/steering.d.ts +2 -11
  60. package/src/runs/background/steering.js +11 -6
  61. package/src/runs/background/subagent-runner.d.ts +0 -2
  62. package/src/runs/background/subagent-runner.js +73 -58
  63. package/src/runs/foreground/async-steering-action.js +24 -9
  64. package/src/runs/foreground/execution.js +32 -15
  65. package/src/runs/foreground/prompt-audit.js +1 -0
  66. package/src/runs/foreground/subagent-executor.d.ts +1 -8
  67. package/src/runs/foreground/subagent-executor.js +6 -15
  68. package/src/runs/shared/async-status-projection.d.ts +2 -0
  69. package/src/runs/shared/async-status-projection.js +10 -0
  70. package/src/runs/shared/child-session.js +21 -3
  71. package/src/runs/shared/mcp-config-sources.d.ts +2 -0
  72. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -2
  73. package/src/runs/shared/mcp-direct-tool-allowlist.js +21 -11
  74. package/src/runs/shared/subagent-prompt-runtime.js +14 -2
  75. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  76. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  77. package/src/shared/artifacts.d.ts +1 -0
  78. package/src/shared/artifacts.js +107 -9
  79. package/src/shared/reported-progress.d.ts +1 -0
  80. package/src/shared/reported-progress.js +12 -0
  81. package/src/shared/status-format.d.ts +1 -0
  82. package/src/shared/status-format.js +1 -1
  83. package/src/shared/types.d.ts +9 -0
  84. package/src/shared/utils.d.ts +3 -1
  85. package/src/shared/utils.js +4 -0
  86. package/src/tui/render.js +33 -2
  87. package/src/watchdog/permission-arbiter.js +1 -0
  88. package/src/watchdog/review.d.ts +0 -5
  89. package/src/watchdog/review.js +2 -1
  90. package/src/workflows/workflow-script-worker.js +3 -1
  91. package/bundle/chunk-XSDYTXHF.js +0 -242
@@ -3,7 +3,7 @@ import {
3
3
  projectRuntimeAcknowledgedExtensions,
4
4
  registerSubagentPromptBoundary,
5
5
  registerSubagentPromptRuntime
6
- } from "./chunk-OTLDAYEQ.js";
6
+ } from "./chunk-UVDLJXL6.js";
7
7
  import {
8
8
  INSPECTOR_ACTIONS,
9
9
  canQueueRetainedAsyncFollowUp,
@@ -25,12 +25,12 @@ import {
25
25
  updateSteeringTarget,
26
26
  waitForSteeringAction,
27
27
  workflowAsyncChildSteeringGuidance
28
- } from "./chunk-HDICKROY.js";
28
+ } from "./chunk-6EUQPQY7.js";
29
29
  import {
30
30
  PLACED_RESTORE_UNSUPPORTED,
31
31
  formatHerdrMachineRunnerUnsupported,
32
32
  resolveMachinePlacement
33
- } from "./chunk-6O7YH2QV.js";
33
+ } from "./chunk-GDR2ILWY.js";
34
34
  import {
35
35
  COMPLETION_ACTION,
36
36
  DEFAULT_CONTROL_CONFIG,
@@ -119,7 +119,7 @@ import {
119
119
  workflowScriptDigest,
120
120
  workflowStopCause,
121
121
  writeWorkflowReceipt
122
- } from "./chunk-EYGBK6CE.js";
122
+ } from "./chunk-4UGWHREQ.js";
123
123
  import {
124
124
  SUBAGENT_PARENT_SESSION_ENV,
125
125
  applyWatchdogLaunchRules,
@@ -132,7 +132,7 @@ import {
132
132
  resolveWatchdogConfig,
133
133
  sendRuleViolationWarning,
134
134
  writeWatchdogModelSettings
135
- } from "./chunk-AIL46SZU.js";
135
+ } from "./chunk-47GJDBIK.js";
136
136
  import {
137
137
  MAX_REMEMBERED_FOREGROUND_RUNS,
138
138
  discardRunningForegroundRun,
@@ -145,7 +145,7 @@ import {
145
145
  resolveSubagentRunId,
146
146
  resolveWorkflowChatProgress,
147
147
  stopAsyncRun
148
- } from "./chunk-2NY5PCKQ.js";
148
+ } from "./chunk-RHYVKQQL.js";
149
149
  import {
150
150
  RunFanoutLimitError,
151
151
  annotateWorkflowPreflightTrace,
@@ -206,12 +206,12 @@ import {
206
206
  writeRunFanoutBudgetDescriptor,
207
207
  writeWorkflowLaunchRecord,
208
208
  writeWorktreeSetupHandoff
209
- } from "./chunk-XV7RTWTS.js";
209
+ } from "./chunk-SVIXQDIV.js";
210
210
  import {
211
211
  NATIVE_SUPERVISOR_TOOL_NAME,
212
212
  createNativeSupervisorChannel,
213
213
  resolveSupervisorChannelDir
214
- } from "./chunk-W52LJANO.js";
214
+ } from "./chunk-CYKNHFXB.js";
215
215
  import {
216
216
  MODEL_ONLY_TOOL,
217
217
  inheritedSessionIds,
@@ -234,10 +234,10 @@ import {
234
234
  canPreferFork,
235
235
  createForkContextResolver,
236
236
  resolveSubagentLaunchContext
237
- } from "./chunk-LFKMM3UH.js";
237
+ } from "./chunk-6OWNDN7R.js";
238
238
  import {
239
239
  handleRefinementAction
240
- } from "./chunk-USRX7QXD.js";
240
+ } from "./chunk-XIA5GSEU.js";
241
241
  import {
242
242
  ActiveAsyncCapacityError,
243
243
  acquireActiveAsyncCapacity,
@@ -249,10 +249,11 @@ import {
249
249
  loadConfig,
250
250
  resolveAbandonedSlotReleaseAfterMs,
251
251
  resolveAsyncByDefault,
252
+ resolveConfigDefaultTimeoutMs,
252
253
  resolveDisabledFeatureSurface,
253
254
  resolveMaxActiveAsyncRunsPerSession,
254
255
  transferActiveAsyncCapacity
255
- } from "./chunk-M2VBGET6.js";
256
+ } from "./chunk-6PR44R7E.js";
256
257
  import {
257
258
  DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS,
258
259
  MACHINE_DIFF_OPTIONS,
@@ -338,7 +339,7 @@ import {
338
339
  writeNestedControlRequest,
339
340
  writeNestedControlResult,
340
341
  writeNestedEvent
341
- } from "./chunk-PGU4TZV3.js";
342
+ } from "./chunk-3DT5X2QC.js";
342
343
  import {
343
344
  closeSteerInbox,
344
345
  consumeSteerRequests,
@@ -346,7 +347,7 @@ import {
346
347
  readRevivalBriefs,
347
348
  requestAsyncSteer,
348
349
  watchAsyncControlInbox
349
- } from "./chunk-VFUFOZBU.js";
350
+ } from "./chunk-W6HIYD2Z.js";
350
351
  import "./chunk-NIXWDZZV.js";
351
352
  import {
352
353
  INTERCOM_BRIDGE_MARKER,
@@ -355,7 +356,7 @@ import {
355
356
  resolveIntercomBridge,
356
357
  resolveIntercomSessionTarget,
357
358
  resolveSubagentIntercomTarget
358
- } from "./chunk-ESWW6XSX.js";
359
+ } from "./chunk-47ZN7NKR.js";
359
360
  import {
360
361
  agentDefinitionDigest,
361
362
  resolveLaunchBinding,
@@ -370,7 +371,7 @@ import {
370
371
  resolvePiLaunchToolPlan,
371
372
  resolveRuntimeModulePath,
372
373
  supervisorChannelDir
373
- } from "./chunk-SIAQXPJ4.js";
374
+ } from "./chunk-3MFYKBKI.js";
374
375
  import {
375
376
  assertRequiredChildExtensionsAdmitted,
376
377
  hasMandatoryRequiredChildExtensions,
@@ -381,7 +382,7 @@ import {
381
382
  import {
382
383
  HERDR_PROJECT_PANE_ACTIONS,
383
384
  handleHerdrProjectPaneAction
384
- } from "./chunk-3CVOAS77.js";
385
+ } from "./chunk-2DIEL4WG.js";
385
386
  import "./chunk-7J4ZXMY7.js";
386
387
  import {
387
388
  PROJECT_SUBAGENTS_RELATIVE_DIR,
@@ -392,14 +393,15 @@ import {
392
393
  getArtifactsDir,
393
394
  getProjectArtifactPackagingWarning,
394
395
  getProjectSubagentsDir,
396
+ missingForkCopyNote,
395
397
  writeArtifact,
396
398
  writeMetadata
397
- } from "./chunk-XSDYTXHF.js";
399
+ } from "./chunk-YDZ7BZD5.js";
398
400
  import "./chunk-XA3DY6UG.js";
399
401
  import {
400
402
  getExternalJobProvider
401
403
  } from "./chunk-YYREO77V.js";
402
- import "./chunk-C5QWQSSM.js";
404
+ import "./chunk-KXW62VBU.js";
403
405
  import {
404
406
  ChainOutputValidationError,
405
407
  DEFAULT_WAIT_TOOL_NAME,
@@ -414,6 +416,7 @@ import {
414
416
  SUBAGENT_STOPPED_MESSAGE,
415
417
  SUBAGENT_TIMED_OUT_MESSAGE,
416
418
  THINKING_LEVELS,
419
+ TRUNCATED_RESPONSE_ERROR,
417
420
  TYPED_VERIFY_OUTPUT_SCHEMA_CONFLICT,
418
421
  acceptChildWatchdogEvent,
419
422
  acceptanceFailureMessage,
@@ -467,6 +470,7 @@ import {
467
470
  getFinalOutput,
468
471
  getSingleResultOutput,
469
472
  getStepAgents,
473
+ getTerminalAssistantStopReason,
470
474
  hasEmptyTerminalAssistantResponse,
471
475
  hasSingleAdjacentTransposition,
472
476
  hasSingleOutputChangedSinceSnapshot,
@@ -551,7 +555,7 @@ import {
551
555
  writeAtomicJson,
552
556
  writeInitialProgressFile,
553
557
  writePrivateAtomicJson
554
- } from "./chunk-C3KWLXDH.js";
558
+ } from "./chunk-4MVDMA5C.js";
555
559
  import {
556
560
  CHAIN_RUNS_DIR,
557
561
  DEFAULT_ARTIFACT_CONFIG,
@@ -582,7 +586,8 @@ import {
582
586
  wrapForkTask
583
587
  } from "./chunk-JEZOSEWG.js";
584
588
  import {
585
- safeTerminalText
589
+ safeTerminalText,
590
+ sanitizeDisplayText
586
591
  } from "./chunk-YFCK7H2S.js";
587
592
  import "./chunk-62OCY2S4.js";
588
593
  import {
@@ -4129,6 +4134,17 @@ function createChildTranscriptWriter(input) {
4129
4134
  };
4130
4135
  }
4131
4136
 
4137
+ // src/shared/reported-progress.ts
4138
+ var MAX_REPORTED_PROGRESS_LENGTH = 512;
4139
+ function extractReportedProgress(toolName, args) {
4140
+ if (toolName !== "contact_supervisor" || typeof args !== "object" || args === null) return void 0;
4141
+ const call = args;
4142
+ if (call.reason !== "progress_update" || typeof call.message !== "string") return void 0;
4143
+ const firstLine = call.message.split(/\r?\n/, 1)[0] ?? "";
4144
+ const sanitized = sanitizeDisplayText(firstLine).replace(/^(?:progress|update):\s*/i, "");
4145
+ return sanitized ? sanitized.slice(0, MAX_REPORTED_PROGRESS_LENGTH) : void 0;
4146
+ }
4147
+
4132
4148
  // src/runs/shared/partial-output.ts
4133
4149
  function isAssistant(message) {
4134
4150
  return !!message && typeof message === "object" && message.role === "assistant";
@@ -5124,6 +5140,59 @@ function reconcileAttemptUsage(live, messages, baseline) {
5124
5140
  return reconciled;
5125
5141
  }
5126
5142
 
5143
+ // src/runs/shared/supervisor-wait-timer.ts
5144
+ function isBlockingSupervisorTool(toolName, args) {
5145
+ if (!args || typeof args !== "object") return false;
5146
+ const call = args;
5147
+ if (toolName === "contact_supervisor") return call.reason === "need_decision" || call.reason === "interview_request";
5148
+ return toolName === "intercom" && call.action === "ask";
5149
+ }
5150
+ function startPausableTimer(delayMs, onFire) {
5151
+ let remaining = Math.max(0, delayMs);
5152
+ let runningSince;
5153
+ let timer;
5154
+ let done = false;
5155
+ const pausedBy = /* @__PURE__ */ new Set();
5156
+ const remainingMs = () => runningSince === void 0 ? remaining : Math.max(0, remaining - (performance.now() - runningSince));
5157
+ const run = () => {
5158
+ runningSince = performance.now();
5159
+ timer = setTimeout(() => {
5160
+ done = true;
5161
+ runningSince = void 0;
5162
+ remaining = 0;
5163
+ onFire();
5164
+ }, remaining);
5165
+ timer.unref?.();
5166
+ };
5167
+ const stop = () => {
5168
+ clearTimeout(timer);
5169
+ remaining = remainingMs();
5170
+ runningSince = void 0;
5171
+ };
5172
+ run();
5173
+ return {
5174
+ pause(key) {
5175
+ if (done) return;
5176
+ if (pausedBy.size === 0) stop();
5177
+ pausedBy.add(key);
5178
+ },
5179
+ resume(key) {
5180
+ if (done || !pausedBy.delete(key) || pausedBy.size > 0) return;
5181
+ run();
5182
+ },
5183
+ remainingMs,
5184
+ clear() {
5185
+ done = true;
5186
+ stop();
5187
+ }
5188
+ };
5189
+ }
5190
+ function pauseForSupervisorWait(timer, event) {
5191
+ if (!timer || typeof event.toolCallId !== "string") return;
5192
+ if (event.type === "tool_execution_start" && isBlockingSupervisorTool(event.toolName, event.args)) timer.pause(event.toolCallId);
5193
+ else if (event.type === "tool_execution_end") timer.resume(event.toolCallId);
5194
+ }
5195
+
5127
5196
  // src/runs/foreground/execution.ts
5128
5197
  var artifactOutputByResult = /* @__PURE__ */ new WeakMap();
5129
5198
  var acceptanceOutputByResult = /* @__PURE__ */ new WeakMap();
@@ -5272,6 +5341,8 @@ function captureStructuredDelegationProgressState(progress, result2) {
5272
5341
  recentOutput: [...progress.recentOutput],
5273
5342
  recentTools: progress.recentTools.slice(-MAX_STREAMED_RECENT_TOOLS).map(({ tool, args }) => ({ tool, args })),
5274
5343
  activityState: progress.activityState,
5344
+ progressText: progress.progressText,
5345
+ progressUpdatedAt: progress.progressUpdatedAt,
5275
5346
  model: progress.model ?? result2.model,
5276
5347
  toolCount: progress.toolCount,
5277
5348
  tokens: progress.tokens,
@@ -5279,7 +5350,7 @@ function captureStructuredDelegationProgressState(progress, result2) {
5279
5350
  };
5280
5351
  }
5281
5352
  function structuredDelegationProgressChanged(previous, progress, result2) {
5282
- if (previous.providerDiagnostics !== progress.providerDiagnostics || previous.currentTool !== progress.currentTool || previous.currentToolArgs !== progress.currentToolArgs || previous.activityState !== progress.activityState || previous.model !== (progress.model ?? result2.model) || previous.toolCount !== progress.toolCount || previous.tokens !== progress.tokens || previous.turnCount !== progress.turnCount || previous.recentOutput.length !== progress.recentOutput.length) return true;
5353
+ if (previous.providerDiagnostics !== progress.providerDiagnostics || previous.currentTool !== progress.currentTool || previous.currentToolArgs !== progress.currentToolArgs || previous.activityState !== progress.activityState || previous.progressText !== progress.progressText || previous.progressUpdatedAt !== progress.progressUpdatedAt || previous.model !== (progress.model ?? result2.model) || previous.toolCount !== progress.toolCount || previous.tokens !== progress.tokens || previous.turnCount !== progress.turnCount || previous.recentOutput.length !== progress.recentOutput.length) return true;
5283
5354
  for (let index = 0; index < progress.recentOutput.length; index++) {
5284
5355
  if (previous.recentOutput[index] !== progress.recentOutput[index]) return true;
5285
5356
  }
@@ -5297,6 +5368,7 @@ function isCompleteUsageCounter(value) {
5297
5368
  }
5298
5369
  var STOPPED_BEFORE_COMPLETION_ERROR = "Subagent stopped before completion.";
5299
5370
  var AFTER_COMPACTION_SETTLEMENT = /* @__PURE__ */ Symbol("afterCompactionSettlement");
5371
+ var REMAINING_TIMEOUT_MS = /* @__PURE__ */ Symbol("remainingTimeoutMs");
5300
5372
  async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared) {
5301
5373
  const effectiveThinking = options.thinkingOverride ?? agent.thinking;
5302
5374
  const modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== void 0);
@@ -5482,6 +5554,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5482
5554
  let toolAvailabilityError;
5483
5555
  let abortedBySignal = options.signal?.aborted === true;
5484
5556
  let afterCompactionSettlement = false;
5557
+ let remainingTimeoutMs;
5485
5558
  if (options.workflowChildPermitLaunch) {
5486
5559
  const permitError = consumeWorkflowChildPermit(options.workflowChildPermitLaunch.permit, {
5487
5560
  workflowRunId: options.workflowChildPermitLaunch.workflowRunId,
@@ -5523,7 +5596,8 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5523
5596
  let timeoutHardFinishTimer;
5524
5597
  const clearTimeoutTimers = () => {
5525
5598
  if (timeoutTimer) {
5526
- clearTimeout(timeoutTimer);
5599
+ remainingTimeoutMs = timeoutTimer.remainingMs();
5600
+ timeoutTimer.clear();
5527
5601
  timeoutTimer = void 0;
5528
5602
  }
5529
5603
  if (timeoutHardFinishTimer) {
@@ -5981,6 +6055,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5981
6055
  progress.durationMs = now - startTime;
5982
6056
  progress.lastActivityAt = now;
5983
6057
  updateActivityState(now);
6058
+ pauseForSupervisorWait(timeoutTimer, evt);
5984
6059
  if (evt.type === "tool_execution_start") {
5985
6060
  const toolArgs = evt.args && typeof evt.args === "object" && !Array.isArray(evt.args) ? evt.args : {};
5986
6061
  const activeTool = evt.toolName !== void 0 ? recordActiveToolCall(evt, toolArgs, now) : void 0;
@@ -5997,7 +6072,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5997
6072
  result2.toolBudget = toolBudgetState(options.toolBudget, progress.toolCount, result2.toolBudget?.blockedTool);
5998
6073
  }
5999
6074
  const mutates = isMutatingTool(evt.toolName, toolArgs, agent.mutationTools);
6000
- pendingToolResult = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now };
6075
+ pendingToolResult = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now, progressText: extractReportedProgress(evt.toolName ?? "", evt.args) };
6001
6076
  if (typeof evt.toolCallId === "string" && evt.toolCallId) pendingToolResultsByCallId.set(evt.toolCallId, pendingToolResult);
6002
6077
  fireUpdate();
6003
6078
  }
@@ -6087,6 +6162,10 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6087
6162
  );
6088
6163
  }
6089
6164
  appendRecentOutput(progress, resultText.split("\n").slice(-10));
6165
+ if (evt.message.isError !== true && resultToolName === toolSnapshot?.tool && toolSnapshot?.progressText) {
6166
+ progress.progressText = toolSnapshot.progressText;
6167
+ progress.progressUpdatedAt = now;
6168
+ }
6090
6169
  if (toolSnapshot?.mutates && !budgetBlocked && didMutatingToolFail(evt.message)) {
6091
6170
  recordMutatingFailure(mutatingFailures, {
6092
6171
  tool: toolSnapshot.tool,
@@ -6125,7 +6204,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6125
6204
  activityTimer.unref?.();
6126
6205
  }
6127
6206
  if (attemptTimeout) {
6128
- timeoutTimer = setTimeout(() => {
6207
+ timeoutTimer = startPausableTimer(attemptTimeout.remainingMs, () => {
6129
6208
  if (sessionSettled || lifecycleFinished || interruptedByControl || result2.timedOut) return;
6130
6209
  result2.timedOut = true;
6131
6210
  timeoutCause = attemptTimeout.message;
@@ -6142,8 +6221,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6142
6221
  settle(void 0, true);
6143
6222
  }, 4e3);
6144
6223
  timeoutHardFinishTimer.unref?.();
6145
- }, attemptTimeout.remainingMs);
6146
- timeoutTimer.unref?.();
6224
+ });
6147
6225
  }
6148
6226
  let toolTimeoutSequence = 0;
6149
6227
  const activeToolTimeouts = /* @__PURE__ */ new Map();
@@ -6171,7 +6249,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6171
6249
  };
6172
6250
  const terminateForToolTimeout = (message) => {
6173
6251
  if (sessionSettled || lifecycleFinished || interruptedByControl || result2.timedOut) return;
6174
- clearTimeout(timeoutTimer);
6252
+ timeoutTimer?.clear();
6175
6253
  result2.timedOut = true;
6176
6254
  timeoutCause = message;
6177
6255
  result2.error = message;
@@ -6190,9 +6268,6 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6190
6268
  const armToolTimeout = (event) => {
6191
6269
  const timeoutForTool = effectiveToolTimeoutMs(event.toolName, options.toolTimeoutMs);
6192
6270
  if (timeoutForTool === void 0) return;
6193
- const elapsed = Date.now() - startTime;
6194
- const runRemaining = attemptTimeout ? Math.max(0, attemptTimeout.remainingMs - elapsed) : void 0;
6195
- if (runRemaining !== void 0 && timeoutForTool >= runRemaining) return;
6196
6271
  const key = toolTimeoutCallKey(event, ++toolTimeoutSequence);
6197
6272
  const toolName = event.toolName;
6198
6273
  const timer = setTimeout(() => {
@@ -6310,12 +6385,12 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6310
6385
  const steer = created.steer.bind(created);
6311
6386
  const followUp = created.followUp.bind(created);
6312
6387
  created.steer = async (text) => {
6388
+ await steer(text);
6313
6389
  if (cleanTerminalAssistantStopReceived || agentSettledReceived) queuedDrainHold = true;
6314
- return steer(text);
6315
6390
  };
6316
6391
  created.followUp = async (text) => {
6392
+ await followUp(text);
6317
6393
  if (cleanTerminalAssistantStopReceived || agentSettledReceived) queuedDrainHold = true;
6318
- return followUp(text);
6319
6394
  };
6320
6395
  created.detached = detached;
6321
6396
  unsubscribe = created.subscribe((event) => processEvent(event));
@@ -6346,9 +6421,8 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6346
6421
  result2.exitCode = exitCode;
6347
6422
  result2.providerDiagnostics = clearProviderRetry(result2.providerDiagnostics);
6348
6423
  progress.providerDiagnostics = result2.providerDiagnostics;
6349
- if (afterCompactionSettlement) {
6350
- result2[AFTER_COMPACTION_SETTLEMENT] = true;
6351
- }
6424
+ if (afterCompactionSettlement) result2[AFTER_COMPACTION_SETTLEMENT] = true;
6425
+ result2[REMAINING_TIMEOUT_MS] = remainingTimeoutMs;
6352
6426
  if (interruptedByControl) {
6353
6427
  result2.exitCode = 0;
6354
6428
  result2.interrupted = true;
@@ -6403,6 +6477,9 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6403
6477
  } else if (errInfo.hasError) {
6404
6478
  result2.exitCode = errInfo.exitCode ?? 1;
6405
6479
  result2.error = errInfo.details ? `${errInfo.errorType} failed (exit ${errInfo.exitCode}): ${errInfo.details}` : `${errInfo.errorType} failed with exit code ${errInfo.exitCode}`;
6480
+ } else if (!validatedStructuredOutput && getTerminalAssistantStopReason(messages) === "length") {
6481
+ result2.exitCode = 1;
6482
+ result2.error = TRUNCATED_RESPONSE_ERROR;
6406
6483
  }
6407
6484
  }
6408
6485
  progress.status = result2.exitCode === 0 ? "completed" : "failed";
@@ -6804,6 +6881,8 @@ ${PROMPT_REDACTED}; live Prompt Audit only.
6804
6881
  });
6805
6882
  if (recovery.action === "resume") {
6806
6883
  recoveryPrompt = recovery.prompt;
6884
+ const remainingMs = attemptResult[REMAINING_TIMEOUT_MS];
6885
+ if (remainingMs !== void 0) attemptOptions.deadlineAt = Date.now() + remainingMs;
6807
6886
  attemptNotes.push("[abort-recovery] compaction abort after useful progress; resuming the retained child session once on the same model.");
6808
6887
  continue;
6809
6888
  }
@@ -10340,7 +10419,7 @@ function resolveForegroundResumeTarget(params, state, options = {}) {
10340
10419
  if (!child.sessionFile) throw new Error(`Foreground run '${run.runId}' child ${index} does not have a persisted session file to resume from.`);
10341
10420
  if (path18.extname(child.sessionFile) !== ".jsonl") throw new Error(`Foreground run '${run.runId}' child ${index} session file must be a .jsonl file: ${child.sessionFile}`);
10342
10421
  const sessionFile = path18.resolve(child.sessionFile);
10343
- if (!fs20.existsSync(sessionFile)) throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}`);
10422
+ if (!fs20.existsSync(sessionFile)) throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}${missingForkCopyNote(sessionFile)}`);
10344
10423
  return {
10345
10424
  runId: run.runId,
10346
10425
  mode: run.mode,
@@ -10782,7 +10861,7 @@ function validateNestedSessionFile(run, trustedSessionRoots2, resolveSource, vis
10782
10861
  if (path18.extname(sessionFile) !== ".jsonl") throw new Error(`Nested run '${run.id}' session file must be a .jsonl file: ${sessionFile}`);
10783
10862
  const resolved = path18.resolve(sessionFile);
10784
10863
  if (!path18.isAbsolute(sessionFile)) throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
10785
- if (!fs20.existsSync(resolved)) throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}`);
10864
+ if (!fs20.existsSync(resolved)) throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}${missingForkCopyNote(resolved)}`);
10786
10865
  const stat = fs20.lstatSync(resolved);
10787
10866
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
10788
10867
  const realSessionFile = fs20.realpathSync(resolved);
@@ -12101,10 +12180,6 @@ var MAX_TIMER_DELAY_MS = 2147483647;
12101
12180
  function timerDelayOverflowError(name, value) {
12102
12181
  return typeof value === "number" && value > MAX_TIMER_DELAY_MS ? `${name} must be a positive integer no larger than ${MAX_TIMER_DELAY_MS}.` : void 0;
12103
12182
  }
12104
- function resolveConfigDefaultTimeoutMs(raw) {
12105
- if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > MAX_TIMER_DELAY_MS) return void 0;
12106
- return raw;
12107
- }
12108
12183
  function resolveForegroundTimeout(params, defaultTimeoutMs) {
12109
12184
  const rawTimeout = params.timeoutMs;
12110
12185
  const rawMaxRuntime = params.maxRuntimeMs;
@@ -15020,6 +15095,8 @@ Parent action: ${COMPLETION_ACTION}` : content,
15020
15095
  step2.currentToolArgs = progress.currentToolArgs;
15021
15096
  step2.currentToolStartedAt = progress.currentToolStartedAt;
15022
15097
  step2.currentPath = progress.currentPath;
15098
+ step2.progressText = progress.progressText;
15099
+ step2.progressUpdatedAt = progress.progressUpdatedAt;
15023
15100
  step2.recentTools = progress.recentTools.map((tool) => ({ ...tool }));
15024
15101
  step2.recentOutput = [...progress.recentOutput];
15025
15102
  step2.turnCount = progress.turnCount;
@@ -16808,7 +16885,6 @@ export {
16808
16885
  promptAuditRedoParams,
16809
16886
  readNestedRecoveryDescriptor,
16810
16887
  removeForegroundControlIfIdle,
16811
- resolveConfigDefaultTimeoutMs,
16812
16888
  resolveForegroundTimeout,
16813
16889
  resolveRevivalControlConfig,
16814
16890
  resolveSingleAgentLaunchTimeout,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getProjectSubagentsDir
3
- } from "./chunk-XSDYTXHF.js";
3
+ } from "./chunk-YDZ7BZD5.js";
4
4
  import {
5
5
  discoverAgents,
6
6
  formatUnknownAgentError,
7
7
  resolveAgentName,
8
8
  unknownAgentDiagnosticContext
9
- } from "./chunk-C3KWLXDH.js";
9
+ } from "./chunk-4MVDMA5C.js";
10
10
 
11
11
  // src/agents/agent-refinements.ts
12
12
  import { createHash, randomUUID } from "node:crypto";