pi-subagents 0.86.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 (122) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-PYOAIN3V.js → chunk-2DIEL4WG.js} +2 -2
  5. package/bundle/{chunk-GJGTMLPE.js → chunk-3DT5X2QC.js} +483 -477
  6. package/bundle/{chunk-374MZFF4.js → chunk-3MFYKBKI.js} +23 -13
  7. package/bundle/{chunk-ZJJCPV3L.js → chunk-47GJDBIK.js} +10 -6
  8. package/bundle/{chunk-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
  9. package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
  10. package/bundle/{chunk-O3YH7XIY.js → chunk-4PM6RDE5.js} +46 -32
  11. package/bundle/{chunk-BWC2LVII.js → chunk-4UGWHREQ.js} +200 -64
  12. package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
  13. package/bundle/{chunk-A637IMAO.js → chunk-6OWNDN7R.js} +2 -2
  14. package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
  15. package/bundle/{chunk-7ZUFN6ME.js → chunk-CKLZ5FGU.js} +2 -2
  16. package/bundle/{chunk-ZPY5QZCS.js → chunk-CYKNHFXB.js} +1 -1
  17. package/bundle/{chunk-YK3QYNLE.js → chunk-GDR2ILWY.js} +1 -1
  18. package/bundle/{chunk-7QA7ZA46.js → chunk-IZEKQEY4.js} +9 -9
  19. package/bundle/{chunk-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
  20. package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
  21. package/bundle/{chunk-QM3JGE4W.js → chunk-MTPICU4A.js} +12 -12
  22. package/bundle/{chunk-BU6PFPVX.js → chunk-PJSOS2Q4.js} +12 -7
  23. package/bundle/{chunk-UR7OW5S7.js → chunk-RHYVKQQL.js} +11 -5
  24. package/bundle/{chunk-BGXEAYUM.js → chunk-SVIXQDIV.js} +20 -5
  25. package/bundle/{chunk-7ADDXUGF.js → chunk-UVDLJXL6.js} +14 -5
  26. package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
  27. package/bundle/{chunk-5H4BICQZ.js → chunk-W6HIYD2Z.js} +1 -1
  28. package/bundle/{chunk-2IYBCYFU.js → chunk-XAOHLFJO.js} +174 -56
  29. package/bundle/{chunk-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
  30. package/bundle/chunk-YDZ7BZD5.js +523 -0
  31. package/bundle/{chunk-WN2E5XHN.js → chunk-YZPVALSQ.js} +30 -5
  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 +3 -3
  37. package/bundle/workflow-resources.js +1 -1
  38. package/docs/agents.md +4 -4
  39. package/docs/configuration.md +17 -5
  40. package/docs/extension-api.md +2 -0
  41. package/docs/models.md +6 -2
  42. package/docs/observability.md +2 -0
  43. package/docs/tool-reference.md +5 -1
  44. package/package.json +2 -2
  45. package/skills/pi-subagents/SKILL.md +15 -6
  46. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  47. package/src/agents/agent-management.d.ts +1 -0
  48. package/src/agents/agent-management.js +22 -10
  49. package/src/agents/agent-serializer.d.ts +2 -0
  50. package/src/agents/agent-serializer.js +1 -1
  51. package/src/agents/agents.d.ts +1 -0
  52. package/src/agents/agents.js +39 -14
  53. package/src/api/preflight.d.ts +3 -1
  54. package/src/api/preflight.js +2 -0
  55. package/src/extension/config.d.ts +1 -0
  56. package/src/extension/config.js +6 -0
  57. package/src/extension/index.js +8 -5
  58. package/src/extension/schemas.d.ts +4 -0
  59. package/src/extension/schemas.js +2 -0
  60. package/src/extension/tool-activation.js +20 -3
  61. package/src/runs/background/async-execution.d.ts +2 -1
  62. package/src/runs/background/async-execution.js +4 -2
  63. package/src/runs/background/async-resume.js +2 -1
  64. package/src/runs/background/async-retention.d.ts +0 -2
  65. package/src/runs/background/async-retention.js +11 -5
  66. package/src/runs/background/async-status.d.ts +2 -0
  67. package/src/runs/background/async-status.js +4 -0
  68. package/src/runs/background/run-child-session.d.ts +2 -2
  69. package/src/runs/background/run-child-session.js +4 -7
  70. package/src/runs/background/runner-aliases.js +15 -0
  71. package/src/runs/background/steering.d.ts +2 -11
  72. package/src/runs/background/steering.js +11 -6
  73. package/src/runs/background/subagent-runner.d.ts +0 -2
  74. package/src/runs/background/subagent-runner.js +73 -58
  75. package/src/runs/background/wait-subscriptions.js +124 -12
  76. package/src/runs/foreground/async-steering-action.js +24 -9
  77. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  78. package/src/runs/foreground/async-stop-action.js +9 -1
  79. package/src/runs/foreground/execution.js +33 -15
  80. package/src/runs/foreground/prompt-audit.js +1 -0
  81. package/src/runs/foreground/subagent-executor.d.ts +2 -8
  82. package/src/runs/foreground/subagent-executor.js +57 -23
  83. package/src/runs/shared/async-status-projection.d.ts +2 -0
  84. package/src/runs/shared/async-status-projection.js +10 -0
  85. package/src/runs/shared/child-session.d.ts +5 -4
  86. package/src/runs/shared/child-session.js +64 -36
  87. package/src/runs/shared/herdr-placed-run.js +3 -2
  88. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  89. package/src/runs/shared/mcp-config-sources.js +1 -1
  90. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  91. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  92. package/src/runs/shared/model-resolution.d.ts +19 -4
  93. package/src/runs/shared/model-resolution.js +50 -51
  94. package/src/runs/shared/subagent-prompt-runtime.js +14 -2
  95. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  96. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  97. package/src/shared/artifacts.d.ts +1 -0
  98. package/src/shared/artifacts.js +132 -22
  99. package/src/shared/pruned-fork.js +2 -2
  100. package/src/shared/reported-progress.d.ts +1 -0
  101. package/src/shared/reported-progress.js +12 -0
  102. package/src/shared/status-format.d.ts +1 -0
  103. package/src/shared/status-format.js +1 -1
  104. package/src/shared/types.d.ts +23 -0
  105. package/src/shared/utils.d.ts +3 -1
  106. package/src/shared/utils.js +4 -0
  107. package/src/tui/render.js +33 -2
  108. package/src/watchdog/model-selection.js +2 -2
  109. package/src/watchdog/permission-arbiter.js +1 -0
  110. package/src/watchdog/review.d.ts +0 -5
  111. package/src/watchdog/review.js +4 -3
  112. package/src/workflows/scripted-workflow.d.ts +2 -0
  113. package/src/workflows/scripted-workflow.js +103 -39
  114. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  115. package/src/workflows/structured-workflow-scripts.js +32 -11
  116. package/src/workflows/workflow-resources.js +4 -4
  117. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  118. package/src/workflows/workflow-resume-claim.js +1 -1
  119. package/src/workflows/workflow-resume.d.ts +1 -1
  120. package/src/workflows/workflow-resume.js +3 -1
  121. package/src/workflows/workflow-script-worker.js +3 -1
  122. package/bundle/chunk-GRJHIXYF.js +0 -235
@@ -3,7 +3,7 @@ import {
3
3
  projectRuntimeAcknowledgedExtensions,
4
4
  registerSubagentPromptBoundary,
5
5
  registerSubagentPromptRuntime
6
- } from "./chunk-7ADDXUGF.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-3RKFH2UZ.js";
28
+ } from "./chunk-6EUQPQY7.js";
29
29
  import {
30
30
  PLACED_RESTORE_UNSUPPORTED,
31
31
  formatHerdrMachineRunnerUnsupported,
32
32
  resolveMachinePlacement
33
- } from "./chunk-YK3QYNLE.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-BWC2LVII.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-ZJJCPV3L.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-UR7OW5S7.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-BGXEAYUM.js";
209
+ } from "./chunk-SVIXQDIV.js";
210
210
  import {
211
211
  NATIVE_SUPERVISOR_TOOL_NAME,
212
212
  createNativeSupervisorChannel,
213
213
  resolveSupervisorChannelDir
214
- } from "./chunk-ZPY5QZCS.js";
214
+ } from "./chunk-CYKNHFXB.js";
215
215
  import {
216
216
  MODEL_ONLY_TOOL,
217
217
  inheritedSessionIds,
@@ -228,16 +228,16 @@ import {
228
228
  resolveStructuredWorkflowResource,
229
229
  resolveWorkflowResource,
230
230
  validateWorkflowChildPermitRoot
231
- } from "./chunk-NF7IEKBH.js";
231
+ } from "./chunk-W2BZS6UC.js";
232
232
  import {
233
233
  buildEffectiveSystemPrompt,
234
234
  canPreferFork,
235
235
  createForkContextResolver,
236
236
  resolveSubagentLaunchContext
237
- } from "./chunk-A637IMAO.js";
237
+ } from "./chunk-6OWNDN7R.js";
238
238
  import {
239
239
  handleRefinementAction
240
- } from "./chunk-LGINOOY5.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-6VD7BGIC.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-GJGTMLPE.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-5H4BICQZ.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-77ASNIEM.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-374MZFF4.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-PYOAIN3V.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-GRJHIXYF.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-NAFLUJ26.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,
@@ -485,6 +489,7 @@ import {
485
489
  isSettlementFatalOutputError,
486
490
  isStorageCapacityError,
487
491
  isToolBudgetBlockedMessage,
492
+ knownModelProviders,
488
493
  normalizeAcceptanceInput,
489
494
  normalizeExtensionBindings,
490
495
  normalizeExternalCliRunnerStatus,
@@ -550,7 +555,7 @@ import {
550
555
  writeAtomicJson,
551
556
  writeInitialProgressFile,
552
557
  writePrivateAtomicJson
553
- } from "./chunk-QGO6HXHG.js";
558
+ } from "./chunk-4MVDMA5C.js";
554
559
  import {
555
560
  CHAIN_RUNS_DIR,
556
561
  DEFAULT_ARTIFACT_CONFIG,
@@ -581,7 +586,8 @@ import {
581
586
  wrapForkTask
582
587
  } from "./chunk-JEZOSEWG.js";
583
588
  import {
584
- safeTerminalText
589
+ safeTerminalText,
590
+ sanitizeDisplayText
585
591
  } from "./chunk-YFCK7H2S.js";
586
592
  import "./chunk-62OCY2S4.js";
587
593
  import {
@@ -2331,7 +2337,7 @@ function buildAsyncRunnerSteps(id, params) {
2331
2337
  ctx.currentModel,
2332
2338
  availableModels,
2333
2339
  a.modelProvider ?? ctx.currentModelProvider,
2334
- { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" }
2340
+ { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited", knownProviders: ctx.knownProviders }
2335
2341
  );
2336
2342
  const thinkingOverride = flatIndex === void 0 ? void 0 : thinkingOverridesByFlatIndex?.[flatIndex];
2337
2343
  let claudeCodeOverride;
@@ -2375,7 +2381,8 @@ function buildAsyncRunnerSteps(id, params) {
2375
2381
  const modelEvidence = resolveModelSelection(primaryModel, availableModels, a.modelProvider ?? ctx.currentModelProvider, {
2376
2382
  scope: modelScopes,
2377
2383
  primaryModelFromParent,
2378
- origin: modelOrigin
2384
+ origin: modelOrigin,
2385
+ knownProviders: ctx.knownProviders
2379
2386
  });
2380
2387
  requestedModel = modelEvidence.requestedModel;
2381
2388
  selectedModel = applyThinkingSuffix(modelEvidence.model, effectiveThinking, thinkingOverride !== void 0);
@@ -3109,7 +3116,7 @@ function executeAsyncSingle(id, params) {
3109
3116
  ctx.currentModel,
3110
3117
  availableModels,
3111
3118
  ctx.currentModelProvider,
3112
- { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" }
3119
+ { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited", knownProviders: ctx.knownProviders }
3113
3120
  );
3114
3121
  } catch (error) {
3115
3122
  return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
@@ -3170,7 +3177,8 @@ function executeAsyncSingle(id, params) {
3170
3177
  const modelEvidence = resolveModelSelection(primaryModel, availableModels, agentConfig.modelProvider ?? ctx.currentModelProvider, {
3171
3178
  scope: modelScopes,
3172
3179
  primaryModelFromParent: modelOrigin === "inherited",
3173
- origin: modelOrigin
3180
+ origin: modelOrigin,
3181
+ knownProviders: ctx.knownProviders
3174
3182
  });
3175
3183
  requestedModel = modelEvidence.requestedModel;
3176
3184
  selectedModel = applyThinkingSuffix(modelEvidence.model, effectiveThinking, params.thinkingOverride !== void 0);
@@ -4126,6 +4134,17 @@ function createChildTranscriptWriter(input) {
4126
4134
  };
4127
4135
  }
4128
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
+
4129
4148
  // src/runs/shared/partial-output.ts
4130
4149
  function isAssistant(message) {
4131
4150
  return !!message && typeof message === "object" && message.role === "assistant";
@@ -5121,6 +5140,59 @@ function reconcileAttemptUsage(live, messages, baseline) {
5121
5140
  return reconciled;
5122
5141
  }
5123
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
+
5124
5196
  // src/runs/foreground/execution.ts
5125
5197
  var artifactOutputByResult = /* @__PURE__ */ new WeakMap();
5126
5198
  var acceptanceOutputByResult = /* @__PURE__ */ new WeakMap();
@@ -5269,6 +5341,8 @@ function captureStructuredDelegationProgressState(progress, result2) {
5269
5341
  recentOutput: [...progress.recentOutput],
5270
5342
  recentTools: progress.recentTools.slice(-MAX_STREAMED_RECENT_TOOLS).map(({ tool, args }) => ({ tool, args })),
5271
5343
  activityState: progress.activityState,
5344
+ progressText: progress.progressText,
5345
+ progressUpdatedAt: progress.progressUpdatedAt,
5272
5346
  model: progress.model ?? result2.model,
5273
5347
  toolCount: progress.toolCount,
5274
5348
  tokens: progress.tokens,
@@ -5276,7 +5350,7 @@ function captureStructuredDelegationProgressState(progress, result2) {
5276
5350
  };
5277
5351
  }
5278
5352
  function structuredDelegationProgressChanged(previous, progress, result2) {
5279
- 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;
5280
5354
  for (let index = 0; index < progress.recentOutput.length; index++) {
5281
5355
  if (previous.recentOutput[index] !== progress.recentOutput[index]) return true;
5282
5356
  }
@@ -5294,6 +5368,7 @@ function isCompleteUsageCounter(value) {
5294
5368
  }
5295
5369
  var STOPPED_BEFORE_COMPLETION_ERROR = "Subagent stopped before completion.";
5296
5370
  var AFTER_COMPACTION_SETTLEMENT = /* @__PURE__ */ Symbol("afterCompactionSettlement");
5371
+ var REMAINING_TIMEOUT_MS = /* @__PURE__ */ Symbol("remainingTimeoutMs");
5297
5372
  async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared) {
5298
5373
  const effectiveThinking = options.thinkingOverride ?? agent.thinking;
5299
5374
  const modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== void 0);
@@ -5479,6 +5554,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5479
5554
  let toolAvailabilityError;
5480
5555
  let abortedBySignal = options.signal?.aborted === true;
5481
5556
  let afterCompactionSettlement = false;
5557
+ let remainingTimeoutMs;
5482
5558
  if (options.workflowChildPermitLaunch) {
5483
5559
  const permitError = consumeWorkflowChildPermit(options.workflowChildPermitLaunch.permit, {
5484
5560
  workflowRunId: options.workflowChildPermitLaunch.workflowRunId,
@@ -5520,7 +5596,8 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5520
5596
  let timeoutHardFinishTimer;
5521
5597
  const clearTimeoutTimers = () => {
5522
5598
  if (timeoutTimer) {
5523
- clearTimeout(timeoutTimer);
5599
+ remainingTimeoutMs = timeoutTimer.remainingMs();
5600
+ timeoutTimer.clear();
5524
5601
  timeoutTimer = void 0;
5525
5602
  }
5526
5603
  if (timeoutHardFinishTimer) {
@@ -5978,6 +6055,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5978
6055
  progress.durationMs = now - startTime;
5979
6056
  progress.lastActivityAt = now;
5980
6057
  updateActivityState(now);
6058
+ pauseForSupervisorWait(timeoutTimer, evt);
5981
6059
  if (evt.type === "tool_execution_start") {
5982
6060
  const toolArgs = evt.args && typeof evt.args === "object" && !Array.isArray(evt.args) ? evt.args : {};
5983
6061
  const activeTool = evt.toolName !== void 0 ? recordActiveToolCall(evt, toolArgs, now) : void 0;
@@ -5994,7 +6072,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5994
6072
  result2.toolBudget = toolBudgetState(options.toolBudget, progress.toolCount, result2.toolBudget?.blockedTool);
5995
6073
  }
5996
6074
  const mutates = isMutatingTool(evt.toolName, toolArgs, agent.mutationTools);
5997
- 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) };
5998
6076
  if (typeof evt.toolCallId === "string" && evt.toolCallId) pendingToolResultsByCallId.set(evt.toolCallId, pendingToolResult);
5999
6077
  fireUpdate();
6000
6078
  }
@@ -6084,6 +6162,10 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6084
6162
  );
6085
6163
  }
6086
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
+ }
6087
6169
  if (toolSnapshot?.mutates && !budgetBlocked && didMutatingToolFail(evt.message)) {
6088
6170
  recordMutatingFailure(mutatingFailures, {
6089
6171
  tool: toolSnapshot.tool,
@@ -6122,7 +6204,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6122
6204
  activityTimer.unref?.();
6123
6205
  }
6124
6206
  if (attemptTimeout) {
6125
- timeoutTimer = setTimeout(() => {
6207
+ timeoutTimer = startPausableTimer(attemptTimeout.remainingMs, () => {
6126
6208
  if (sessionSettled || lifecycleFinished || interruptedByControl || result2.timedOut) return;
6127
6209
  result2.timedOut = true;
6128
6210
  timeoutCause = attemptTimeout.message;
@@ -6139,8 +6221,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6139
6221
  settle(void 0, true);
6140
6222
  }, 4e3);
6141
6223
  timeoutHardFinishTimer.unref?.();
6142
- }, attemptTimeout.remainingMs);
6143
- timeoutTimer.unref?.();
6224
+ });
6144
6225
  }
6145
6226
  let toolTimeoutSequence = 0;
6146
6227
  const activeToolTimeouts = /* @__PURE__ */ new Map();
@@ -6168,7 +6249,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6168
6249
  };
6169
6250
  const terminateForToolTimeout = (message) => {
6170
6251
  if (sessionSettled || lifecycleFinished || interruptedByControl || result2.timedOut) return;
6171
- clearTimeout(timeoutTimer);
6252
+ timeoutTimer?.clear();
6172
6253
  result2.timedOut = true;
6173
6254
  timeoutCause = message;
6174
6255
  result2.error = message;
@@ -6187,9 +6268,6 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6187
6268
  const armToolTimeout = (event) => {
6188
6269
  const timeoutForTool = effectiveToolTimeoutMs(event.toolName, options.toolTimeoutMs);
6189
6270
  if (timeoutForTool === void 0) return;
6190
- const elapsed = Date.now() - startTime;
6191
- const runRemaining = attemptTimeout ? Math.max(0, attemptTimeout.remainingMs - elapsed) : void 0;
6192
- if (runRemaining !== void 0 && timeoutForTool >= runRemaining) return;
6193
6271
  const key = toolTimeoutCallKey(event, ++toolTimeoutSequence);
6194
6272
  const toolName = event.toolName;
6195
6273
  const timer = setTimeout(() => {
@@ -6307,12 +6385,12 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6307
6385
  const steer = created.steer.bind(created);
6308
6386
  const followUp = created.followUp.bind(created);
6309
6387
  created.steer = async (text) => {
6388
+ await steer(text);
6310
6389
  if (cleanTerminalAssistantStopReceived || agentSettledReceived) queuedDrainHold = true;
6311
- return steer(text);
6312
6390
  };
6313
6391
  created.followUp = async (text) => {
6392
+ await followUp(text);
6314
6393
  if (cleanTerminalAssistantStopReceived || agentSettledReceived) queuedDrainHold = true;
6315
- return followUp(text);
6316
6394
  };
6317
6395
  created.detached = detached;
6318
6396
  unsubscribe = created.subscribe((event) => processEvent(event));
@@ -6343,9 +6421,8 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6343
6421
  result2.exitCode = exitCode;
6344
6422
  result2.providerDiagnostics = clearProviderRetry(result2.providerDiagnostics);
6345
6423
  progress.providerDiagnostics = result2.providerDiagnostics;
6346
- if (afterCompactionSettlement) {
6347
- result2[AFTER_COMPACTION_SETTLEMENT] = true;
6348
- }
6424
+ if (afterCompactionSettlement) result2[AFTER_COMPACTION_SETTLEMENT] = true;
6425
+ result2[REMAINING_TIMEOUT_MS] = remainingTimeoutMs;
6349
6426
  if (interruptedByControl) {
6350
6427
  result2.exitCode = 0;
6351
6428
  result2.interrupted = true;
@@ -6400,6 +6477,9 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6400
6477
  } else if (errInfo.hasError) {
6401
6478
  result2.exitCode = errInfo.exitCode ?? 1;
6402
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;
6403
6483
  }
6404
6484
  }
6405
6485
  progress.status = result2.exitCode === 0 ? "completed" : "failed";
@@ -6652,7 +6732,8 @@ ${acceptancePrompt}` : task;
6652
6732
  {
6653
6733
  scope: options.modelScope,
6654
6734
  primaryModelFromParent: options.modelOverrideFromParent,
6655
- origin: options.modelOrigin ?? (options.modelOverrideFromParent ? "inherited" : "configured")
6735
+ origin: options.modelOrigin ?? (options.modelOverrideFromParent ? "inherited" : "configured"),
6736
+ knownProviders: options.knownProviders
6656
6737
  }
6657
6738
  );
6658
6739
  try {
@@ -6800,6 +6881,8 @@ ${PROMPT_REDACTED}; live Prompt Audit only.
6800
6881
  });
6801
6882
  if (recovery.action === "resume") {
6802
6883
  recoveryPrompt = recovery.prompt;
6884
+ const remainingMs = attemptResult[REMAINING_TIMEOUT_MS];
6885
+ if (remainingMs !== void 0) attemptOptions.deadlineAt = Date.now() + remainingMs;
6803
6886
  attemptNotes.push("[abort-recovery] compaction abort after useful progress; resuming the retained child session once on the same model.");
6804
6887
  continue;
6805
6888
  }
@@ -7558,7 +7641,7 @@ async function createPrunedForkSessionWriter(ctx, config, signal) {
7558
7641
  };
7559
7642
  if (!config.model?.trim()) throw new Error("Pruned fork context requires config.forkContext.model.");
7560
7643
  const available = ctx.modelRegistry.getAvailable();
7561
- const resolved = resolveModelCandidate(config.model.trim(), available.map(toModelInfo), ctx.model?.provider);
7644
+ const resolved = resolveModelCandidate(config.model.trim(), available.map(toModelInfo), ctx.model?.provider, knownModelProviders(ctx.modelRegistry));
7562
7645
  if (!resolved) throw new Error(`Pruned fork model '${config.model}' did not match exactly one available model.`);
7563
7646
  const { baseModel } = splitKnownThinkingSuffix(resolved);
7564
7647
  const named = splitProviderModel(baseModel);
@@ -10336,7 +10419,7 @@ function resolveForegroundResumeTarget(params, state, options = {}) {
10336
10419
  if (!child.sessionFile) throw new Error(`Foreground run '${run.runId}' child ${index} does not have a persisted session file to resume from.`);
10337
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}`);
10338
10421
  const sessionFile = path18.resolve(child.sessionFile);
10339
- 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)}`);
10340
10423
  return {
10341
10424
  runId: run.runId,
10342
10425
  mode: run.mode,
@@ -10662,6 +10745,7 @@ function appendStepToAsyncChain(input) {
10662
10745
  parentProviderRegistry: input.ctx.modelRegistry,
10663
10746
  currentModel: parentModel,
10664
10747
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
10748
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
10665
10749
  modelScope: discoveredForAppend.modelScope,
10666
10750
  modelResponseAliases: input.deps.config.modelResponseAliases,
10667
10751
  interactive: input.ctx.hasUI,
@@ -10777,7 +10861,7 @@ function validateNestedSessionFile(run, trustedSessionRoots2, resolveSource, vis
10777
10861
  if (path18.extname(sessionFile) !== ".jsonl") throw new Error(`Nested run '${run.id}' session file must be a .jsonl file: ${sessionFile}`);
10778
10862
  const resolved = path18.resolve(sessionFile);
10779
10863
  if (!path18.isAbsolute(sessionFile)) throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
10780
- 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)}`);
10781
10865
  const stat = fs20.lstatSync(resolved);
10782
10866
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
10783
10867
  const realSessionFile = fs20.realpathSync(resolved);
@@ -11065,6 +11149,7 @@ async function resumeExternalJobFollowUp(input) {
11065
11149
  parentProviderRegistry: input.ctx.modelRegistry,
11066
11150
  currentModel: parentModel,
11067
11151
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
11152
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
11068
11153
  modelScope: input.modelScope,
11069
11154
  modelResponseAliases: input.deps.config.modelResponseAliases,
11070
11155
  interactive: input.ctx.hasUI,
@@ -11343,6 +11428,7 @@ async function resumeAsyncRun(input) {
11343
11428
  parentProviderRegistry: input.ctx.modelRegistry,
11344
11429
  currentModel: parentModel2,
11345
11430
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
11431
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
11346
11432
  modelScope,
11347
11433
  modelResponseAliases: input.deps.config.modelResponseAliases,
11348
11434
  runnerLaunchers: input.deps.config.runnerLaunchers,
@@ -11468,6 +11554,7 @@ async function resumeAsyncRun(input) {
11468
11554
  parentProviderRegistry: input.ctx.modelRegistry,
11469
11555
  currentModel: parentModel,
11470
11556
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
11557
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
11471
11558
  modelScope,
11472
11559
  // Absence in the retained contract is meaningful; never acquire current aliases.
11473
11560
  modelResponseAliases: recoveryDescriptor ? recoveryDescriptor.modelResponseAliases : foregroundContract?.modelResponseAliases,
@@ -12093,10 +12180,6 @@ var MAX_TIMER_DELAY_MS = 2147483647;
12093
12180
  function timerDelayOverflowError(name, value) {
12094
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;
12095
12182
  }
12096
- function resolveConfigDefaultTimeoutMs(raw) {
12097
- if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > MAX_TIMER_DELAY_MS) return void 0;
12098
- return raw;
12099
- }
12100
12183
  function resolveForegroundTimeout(params, defaultTimeoutMs) {
12101
12184
  const rawTimeout = params.timeoutMs;
12102
12185
  const rawMaxRuntime = params.maxRuntimeMs;
@@ -12239,7 +12322,7 @@ function resolveStaticLaunchSummary(input) {
12239
12322
  input.parentModel,
12240
12323
  input.availableModels,
12241
12324
  agentConfig?.modelProvider ?? input.currentProvider,
12242
- modelScopes.length === 0 ? {} : { scope: modelScopes }
12325
+ { scope: modelScopes, knownProviders: input.knownProviders }
12243
12326
  );
12244
12327
  const thinkingOverride = externalRunner ? void 0 : input.thinkingOverrideForTask();
12245
12328
  const thinking = externalRunner ? void 0 : resolveEffectiveThinking(model, thinkingOverride ?? agentConfig?.thinking);
@@ -12258,6 +12341,7 @@ function collectStaticLaunchSummaries(input) {
12258
12341
  parentModel: input.parentModel,
12259
12342
  scopedModelIds: input.scopedModelIds,
12260
12343
  availableModels: input.availableModels,
12344
+ knownProviders: input.knownProviders,
12261
12345
  currentProvider: input.currentProvider,
12262
12346
  modelScope: input.modelScope,
12263
12347
  thinkingOverrideForTask: input.thinkingOverrideForTask
@@ -12531,6 +12615,7 @@ async function runAsyncPath(data, deps) {
12531
12615
  parentProviderRegistry: ctx.modelRegistry,
12532
12616
  currentModel: parentModel,
12533
12617
  scopedModelIds: data.scopedModelIds,
12618
+ knownProviders: knownModelProviders(ctx.modelRegistry),
12534
12619
  modelScope: data.modelScope,
12535
12620
  modelResponseAliases: deps.config.modelResponseAliases,
12536
12621
  runnerLaunchers: deps.config.runnerLaunchers,
@@ -12571,8 +12656,9 @@ async function runAsyncPath(data, deps) {
12571
12656
  parentModel
12572
12657
  });
12573
12658
  const modelOverride = a.runner?.type === "external-cli" || a.runner?.type === "external-job" ? params.model ?? (externalRunnerWithoutExplicitModel ? void 0 : a.model) : resolveEffectiveSubagentModel(params.model, a.model, parentModel, availableModels, a.modelProvider ?? currentProvider, {
12574
- ...modelScopes.length === 0 ? {} : { scope: modelScopes },
12575
- source: modelOrigin === "explicit" ? "explicit" : "inherited"
12659
+ scope: modelScopes,
12660
+ source: modelOrigin === "explicit" ? "explicit" : "inherited",
12661
+ knownProviders: asyncCtx.knownProviders
12576
12662
  });
12577
12663
  const modelOverrideFromParent = modelOrigin === "inherited";
12578
12664
  const launchRuleError = applyWatchdogLaunchRules({ cwd: effectiveCwd, agent: a.name, model: modelOverride ?? (parentModel && `${parentModel.provider}/${parentModel.id}`), warn: (violation) => deps.watchdog?.displayRuleWarning(violation) });
@@ -12985,6 +13071,7 @@ async function runSinglePath(data, deps) {
12985
13071
  const parentModel = data.parentModel;
12986
13072
  const currentProvider = parentModel?.provider;
12987
13073
  const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
13074
+ const knownProviders = knownModelProviders(ctx.modelRegistry);
12988
13075
  const modelScopes = resolveModelScopesForAgent(data.modelScope, agentConfig.name, parentModel, data.scopedModelIds);
12989
13076
  let task = typeof params.task === "string" ? params.task : "";
12990
13077
  const modelOrigin = resolveModelOrigin({
@@ -13000,8 +13087,9 @@ async function runSinglePath(data, deps) {
13000
13087
  availableModels,
13001
13088
  agentConfig.modelProvider ?? currentProvider,
13002
13089
  {
13003
- ...modelScopes.length === 0 ? {} : { scope: modelScopes },
13004
- source: modelOrigin === "explicit" ? "explicit" : "inherited"
13090
+ scope: modelScopes,
13091
+ source: modelOrigin === "explicit" ? "explicit" : "inherited",
13092
+ knownProviders
13005
13093
  }
13006
13094
  );
13007
13095
  const modelOverrideFromParent = modelOrigin === "inherited";
@@ -13258,6 +13346,7 @@ async function runSinglePath(data, deps) {
13258
13346
  thinkingCeiling: agentConfig.maxThinking,
13259
13347
  extensionBindings: params.extensionBindings,
13260
13348
  availableModels,
13349
+ knownProviders,
13261
13350
  modelResponseAliases,
13262
13351
  preferredModelProvider: currentProvider,
13263
13352
  modelScope: modelScopes,
@@ -14311,6 +14400,7 @@ function createSubagentExecutor(deps) {
14311
14400
  const controller = new AbortController();
14312
14401
  deps2.state.workflowControllers ??= /* @__PURE__ */ new Map();
14313
14402
  deps2.state.workflowChildStops ??= /* @__PURE__ */ new Map();
14403
+ deps2.state.workflowDrains ??= /* @__PURE__ */ new Map();
14314
14404
  deps2.state.workflowControllers.set(workflowRunId, controller);
14315
14405
  workflowCapacity?.markWorkflowStarted();
14316
14406
  if (workflowCapacity) deps2.state.activeAsyncCapacity = getActiveAsyncCapacitySnapshot(currentSessionId, resolveMaxActiveAsyncRunsPerSession(deps2.config.maxActiveAsyncRunsPerSession), { liveWorkflowRunIds: new Set(deps2.state.workflowControllers.keys()), abandonedSlotReleaseAfterMs: resolveAbandonedSlotReleaseAfterMs(deps2.config.capacity?.abandonedSlotReleaseAfterMs) });
@@ -14834,6 +14924,30 @@ Parent action: ${STATUS_ACTION}`,
14834
14924
  if (stop) deps2.state.workflowChildStops?.set(workflowRunId, stop);
14835
14925
  else deps2.state.workflowChildStops?.delete(workflowRunId);
14836
14926
  },
14927
+ registerDrain: (drain) => {
14928
+ if (!drain) deps2.state.workflowDrains?.delete(workflowRunId);
14929
+ else deps2.state.workflowDrains?.set(workflowRunId, () => {
14930
+ if (workflowRunEvidence.drainRequestedAt === void 0) {
14931
+ const previousWorkflow = status.workflow;
14932
+ workflowRunEvidence.drainRequestedAt = Date.now();
14933
+ status.workflow = { ...previousWorkflow ?? { trace: [], emits: [], console: [] }, drainRequestedAt: workflowRunEvidence.drainRequestedAt };
14934
+ let saved = false;
14935
+ try {
14936
+ persist();
14937
+ saved = runPersistence.pendingCount() === 0;
14938
+ } catch (error) {
14939
+ console.error(`Failed to save the drain request for async workflow '${workflowRunId}':`, error);
14940
+ }
14941
+ if (!saved) {
14942
+ delete workflowRunEvidence.drainRequestedAt;
14943
+ status.workflow = previousWorkflow;
14944
+ persist({ tolerateStatusWriteFailure: true });
14945
+ return { ok: false };
14946
+ }
14947
+ }
14948
+ return { ok: true, started: drain(() => queueMicrotask(() => controller.abort(new Error("Workflow drained: started children finished; no new children were started.")))) };
14949
+ });
14950
+ },
14837
14951
  ...workflowState2 ? { state: workflowState2 } : {},
14838
14952
  onTrace: updateTrace,
14839
14953
  onChildSettled: (notification) => {
@@ -14981,6 +15095,8 @@ Parent action: ${COMPLETION_ACTION}` : content,
14981
15095
  step2.currentToolArgs = progress.currentToolArgs;
14982
15096
  step2.currentToolStartedAt = progress.currentToolStartedAt;
14983
15097
  step2.currentPath = progress.currentPath;
15098
+ step2.progressText = progress.progressText;
15099
+ step2.progressUpdatedAt = progress.progressUpdatedAt;
14984
15100
  step2.recentTools = progress.recentTools.map((tool) => ({ ...tool }));
14985
15101
  step2.recentOutput = [...progress.recentOutput];
14986
15102
  step2.turnCount = progress.turnCount;
@@ -15941,6 +16057,7 @@ ${item.text}` } : item)
15941
16057
  }
15942
16058
  if (action === "stop") {
15943
16059
  const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
16060
+ if (paramsWithResolvedCwd.drain && paramsWithResolvedCwd.childId !== void 0) return { content: [{ type: "text", text: "action='stop' drain applies to a whole workflow; omit childId." }], isError: true, details: { mode: "management", results: [] } };
15944
16061
  const workflowRunId = targetRunId && paramsWithResolvedCwd.childId !== void 0 ? resolveLiveWorkflowRunId(deps2, targetRunId) : void 0;
15945
16062
  if (workflowRunId && paramsWithResolvedCwd.childId !== void 0) {
15946
16063
  const stopChild = deps2.state.workflowChildStops?.get(workflowRunId);
@@ -15980,7 +16097,7 @@ ${item.text}` } : item)
15980
16097
  if (paramsWithResolvedCwd.dir) {
15981
16098
  try {
15982
16099
  const location = resolveAsyncRunLocation(paramsWithResolvedCwd, DIRS.async, DIRS.results);
15983
- const stopResult2 = stopAsyncRun(deps2.state, location.resolvedId ?? targetRunId ?? path18.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps2.kill, location, paramsWithResolvedCwd.childId);
16100
+ const stopResult2 = stopAsyncRun(deps2.state, location.resolvedId ?? targetRunId ?? path18.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps2.kill, location, paramsWithResolvedCwd.childId, paramsWithResolvedCwd.drain);
15984
16101
  return stopResult2 ?? { content: [{ type: "text", text: `No running or queued async run was found for '${targetRunId ?? paramsWithResolvedCwd.dir}'.` }], isError: true, details: { mode: "management", results: [] } };
15985
16102
  } catch (error) {
15986
16103
  const text = error instanceof Error ? error.message : String(error);
@@ -16001,7 +16118,8 @@ ${item.text}` } : item)
16001
16118
  resolved?.kind === "async" ? resolved.id : targetRunId,
16002
16119
  deps2.kill,
16003
16120
  resolved?.kind === "async" ? resolved.location : void 0,
16004
- paramsWithResolvedCwd.childId
16121
+ paramsWithResolvedCwd.childId,
16122
+ paramsWithResolvedCwd.drain
16005
16123
  );
16006
16124
  if (stopResult) return stopResult;
16007
16125
  return {
@@ -16491,6 +16609,7 @@ ${item.text}` } : item)
16491
16609
  parentModel: requestParentModel,
16492
16610
  scopedModelIds: scopedModelIdsFromContext(ctx),
16493
16611
  availableModels: ctx.modelRegistry.getAvailable().map(toModelInfo),
16612
+ knownProviders: knownModelProviders(ctx.modelRegistry),
16494
16613
  currentProvider: requestParentModel?.provider,
16495
16614
  modelScope,
16496
16615
  thinkingOverrideForTask,
@@ -16766,7 +16885,6 @@ export {
16766
16885
  promptAuditRedoParams,
16767
16886
  readNestedRecoveryDescriptor,
16768
16887
  removeForegroundControlIfIdle,
16769
- resolveConfigDefaultTimeoutMs,
16770
16888
  resolveForegroundTimeout,
16771
16889
  resolveRevivalControlConfig,
16772
16890
  resolveSingleAgentLaunchTimeout,