@vicary/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-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
  8. package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
  9. package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
  10. package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
  11. package/bundle/{chunk-DD22RXYJ.js → chunk-AOSILI5R.js} +200 -64
  12. package/bundle/{chunk-WHC2XHGF.js → chunk-BW5JLKIU.js} +174 -56
  13. package/bundle/{chunk-7ZUFN6ME.js → chunk-CKLZ5FGU.js} +2 -2
  14. package/bundle/{chunk-ZPY5QZCS.js → chunk-CYKNHFXB.js} +1 -1
  15. package/bundle/{chunk-YK3QYNLE.js → chunk-GDR2ILWY.js} +1 -1
  16. package/bundle/{chunk-7QA7ZA46.js → chunk-IZEKQEY4.js} +9 -9
  17. package/bundle/{chunk-CJHFDQFJ.js → chunk-JYHTDTOZ.js} +10 -6
  18. package/bundle/{chunk-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
  19. package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
  20. package/bundle/{chunk-2DITXA3H.js → chunk-NVGQE2H2.js} +12 -12
  21. package/bundle/{chunk-BU6PFPVX.js → chunk-PJSOS2Q4.js} +12 -7
  22. package/bundle/{chunk-UR7OW5S7.js → chunk-RHYVKQQL.js} +11 -5
  23. package/bundle/{chunk-BGXEAYUM.js → chunk-SVIXQDIV.js} +20 -5
  24. package/bundle/{chunk-GLVJMI6R.js → chunk-TDJKY2NE.js} +14 -5
  25. package/bundle/{chunk-XOFYXQKZ.js → chunk-V7SZMS6W.js} +2 -2
  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-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
  29. package/bundle/{chunk-QFLPV64W.js → chunk-XZXYPZUT.js} +46 -32
  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 +14 -4
  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 +3 -3
  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 +9 -0
  56. package/src/extension/config.js +13 -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-GLVJMI6R.js";
6
+ } from "./chunk-TDJKY2NE.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-DD22RXYJ.js";
122
+ } from "./chunk-AOSILI5R.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-CJHFDQFJ.js";
135
+ } from "./chunk-JYHTDTOZ.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-XOFYXQKZ.js";
237
+ } from "./chunk-V7SZMS6W.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 {
@@ -2330,7 +2336,7 @@ function buildAsyncRunnerSteps(id, params) {
2330
2336
  ctx.currentModel,
2331
2337
  availableModels,
2332
2338
  a.modelProvider ?? ctx.currentModelProvider,
2333
- { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" }
2339
+ { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited", knownProviders: ctx.knownProviders }
2334
2340
  );
2335
2341
  const thinkingOverride = flatIndex === void 0 ? void 0 : thinkingOverridesByFlatIndex?.[flatIndex];
2336
2342
  let claudeCodeOverride;
@@ -2374,7 +2380,8 @@ function buildAsyncRunnerSteps(id, params) {
2374
2380
  const modelEvidence = resolveModelSelection(primaryModel, availableModels, a.modelProvider ?? ctx.currentModelProvider, {
2375
2381
  scope: modelScopes,
2376
2382
  primaryModelFromParent,
2377
- origin: modelOrigin
2383
+ origin: modelOrigin,
2384
+ knownProviders: ctx.knownProviders
2378
2385
  });
2379
2386
  requestedModel = modelEvidence.requestedModel;
2380
2387
  selectedModel = applyThinkingSuffix(modelEvidence.model, effectiveThinking, thinkingOverride !== void 0);
@@ -3108,7 +3115,7 @@ function executeAsyncSingle(id, params) {
3108
3115
  ctx.currentModel,
3109
3116
  availableModels,
3110
3117
  ctx.currentModelProvider,
3111
- { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" }
3118
+ { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited", knownProviders: ctx.knownProviders }
3112
3119
  );
3113
3120
  } catch (error) {
3114
3121
  return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
@@ -3169,7 +3176,8 @@ function executeAsyncSingle(id, params) {
3169
3176
  const modelEvidence = resolveModelSelection(primaryModel, availableModels, agentConfig.modelProvider ?? ctx.currentModelProvider, {
3170
3177
  scope: modelScopes,
3171
3178
  primaryModelFromParent: modelOrigin === "inherited",
3172
- origin: modelOrigin
3179
+ origin: modelOrigin,
3180
+ knownProviders: ctx.knownProviders
3173
3181
  });
3174
3182
  requestedModel = modelEvidence.requestedModel;
3175
3183
  selectedModel = applyThinkingSuffix(modelEvidence.model, effectiveThinking, params.thinkingOverride !== void 0);
@@ -4125,6 +4133,17 @@ function createChildTranscriptWriter(input) {
4125
4133
  };
4126
4134
  }
4127
4135
 
4136
+ // src/shared/reported-progress.ts
4137
+ var MAX_REPORTED_PROGRESS_LENGTH = 512;
4138
+ function extractReportedProgress(toolName, args) {
4139
+ if (toolName !== "contact_supervisor" || typeof args !== "object" || args === null) return void 0;
4140
+ const call = args;
4141
+ if (call.reason !== "progress_update" || typeof call.message !== "string") return void 0;
4142
+ const firstLine = call.message.split(/\r?\n/, 1)[0] ?? "";
4143
+ const sanitized = sanitizeDisplayText(firstLine).replace(/^(?:progress|update):\s*/i, "");
4144
+ return sanitized ? sanitized.slice(0, MAX_REPORTED_PROGRESS_LENGTH) : void 0;
4145
+ }
4146
+
4128
4147
  // src/runs/shared/partial-output.ts
4129
4148
  function isAssistant(message) {
4130
4149
  return !!message && typeof message === "object" && message.role === "assistant";
@@ -5120,6 +5139,59 @@ function reconcileAttemptUsage(live, messages, baseline) {
5120
5139
  return reconciled;
5121
5140
  }
5122
5141
 
5142
+ // src/runs/shared/supervisor-wait-timer.ts
5143
+ function isBlockingSupervisorTool(toolName, args) {
5144
+ if (!args || typeof args !== "object") return false;
5145
+ const call = args;
5146
+ if (toolName === "contact_supervisor") return call.reason === "need_decision" || call.reason === "interview_request";
5147
+ return toolName === "intercom" && call.action === "ask";
5148
+ }
5149
+ function startPausableTimer(delayMs, onFire) {
5150
+ let remaining = Math.max(0, delayMs);
5151
+ let runningSince;
5152
+ let timer;
5153
+ let done = false;
5154
+ const pausedBy = /* @__PURE__ */ new Set();
5155
+ const remainingMs = () => runningSince === void 0 ? remaining : Math.max(0, remaining - (performance.now() - runningSince));
5156
+ const run = () => {
5157
+ runningSince = performance.now();
5158
+ timer = setTimeout(() => {
5159
+ done = true;
5160
+ runningSince = void 0;
5161
+ remaining = 0;
5162
+ onFire();
5163
+ }, remaining);
5164
+ timer.unref?.();
5165
+ };
5166
+ const stop = () => {
5167
+ clearTimeout(timer);
5168
+ remaining = remainingMs();
5169
+ runningSince = void 0;
5170
+ };
5171
+ run();
5172
+ return {
5173
+ pause(key) {
5174
+ if (done) return;
5175
+ if (pausedBy.size === 0) stop();
5176
+ pausedBy.add(key);
5177
+ },
5178
+ resume(key) {
5179
+ if (done || !pausedBy.delete(key) || pausedBy.size > 0) return;
5180
+ run();
5181
+ },
5182
+ remainingMs,
5183
+ clear() {
5184
+ done = true;
5185
+ stop();
5186
+ }
5187
+ };
5188
+ }
5189
+ function pauseForSupervisorWait(timer, event) {
5190
+ if (!timer || typeof event.toolCallId !== "string") return;
5191
+ if (event.type === "tool_execution_start" && isBlockingSupervisorTool(event.toolName, event.args)) timer.pause(event.toolCallId);
5192
+ else if (event.type === "tool_execution_end") timer.resume(event.toolCallId);
5193
+ }
5194
+
5123
5195
  // src/runs/foreground/execution.ts
5124
5196
  var artifactOutputByResult = /* @__PURE__ */ new WeakMap();
5125
5197
  var acceptanceOutputByResult = /* @__PURE__ */ new WeakMap();
@@ -5268,6 +5340,8 @@ function captureStructuredDelegationProgressState(progress, result2) {
5268
5340
  recentOutput: [...progress.recentOutput],
5269
5341
  recentTools: progress.recentTools.slice(-MAX_STREAMED_RECENT_TOOLS).map(({ tool, args }) => ({ tool, args })),
5270
5342
  activityState: progress.activityState,
5343
+ progressText: progress.progressText,
5344
+ progressUpdatedAt: progress.progressUpdatedAt,
5271
5345
  model: progress.model ?? result2.model,
5272
5346
  toolCount: progress.toolCount,
5273
5347
  tokens: progress.tokens,
@@ -5275,7 +5349,7 @@ function captureStructuredDelegationProgressState(progress, result2) {
5275
5349
  };
5276
5350
  }
5277
5351
  function structuredDelegationProgressChanged(previous, progress, result2) {
5278
- 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;
5352
+ 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;
5279
5353
  for (let index = 0; index < progress.recentOutput.length; index++) {
5280
5354
  if (previous.recentOutput[index] !== progress.recentOutput[index]) return true;
5281
5355
  }
@@ -5293,6 +5367,7 @@ function isCompleteUsageCounter(value) {
5293
5367
  }
5294
5368
  var STOPPED_BEFORE_COMPLETION_ERROR = "Subagent stopped before completion.";
5295
5369
  var AFTER_COMPACTION_SETTLEMENT = /* @__PURE__ */ Symbol("afterCompactionSettlement");
5370
+ var REMAINING_TIMEOUT_MS = /* @__PURE__ */ Symbol("remainingTimeoutMs");
5296
5371
  async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared) {
5297
5372
  const effectiveThinking = options.thinkingOverride ?? agent.thinking;
5298
5373
  const modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== void 0);
@@ -5478,6 +5553,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5478
5553
  let toolAvailabilityError;
5479
5554
  let abortedBySignal = options.signal?.aborted === true;
5480
5555
  let afterCompactionSettlement = false;
5556
+ let remainingTimeoutMs;
5481
5557
  if (options.workflowChildPermitLaunch) {
5482
5558
  const permitError = consumeWorkflowChildPermit(options.workflowChildPermitLaunch.permit, {
5483
5559
  workflowRunId: options.workflowChildPermitLaunch.workflowRunId,
@@ -5519,7 +5595,8 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5519
5595
  let timeoutHardFinishTimer;
5520
5596
  const clearTimeoutTimers = () => {
5521
5597
  if (timeoutTimer) {
5522
- clearTimeout(timeoutTimer);
5598
+ remainingTimeoutMs = timeoutTimer.remainingMs();
5599
+ timeoutTimer.clear();
5523
5600
  timeoutTimer = void 0;
5524
5601
  }
5525
5602
  if (timeoutHardFinishTimer) {
@@ -5977,6 +6054,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5977
6054
  progress.durationMs = now - startTime;
5978
6055
  progress.lastActivityAt = now;
5979
6056
  updateActivityState(now);
6057
+ pauseForSupervisorWait(timeoutTimer, evt);
5980
6058
  if (evt.type === "tool_execution_start") {
5981
6059
  const toolArgs = evt.args && typeof evt.args === "object" && !Array.isArray(evt.args) ? evt.args : {};
5982
6060
  const activeTool = evt.toolName !== void 0 ? recordActiveToolCall(evt, toolArgs, now) : void 0;
@@ -5993,7 +6071,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
5993
6071
  result2.toolBudget = toolBudgetState(options.toolBudget, progress.toolCount, result2.toolBudget?.blockedTool);
5994
6072
  }
5995
6073
  const mutates = isMutatingTool(evt.toolName, toolArgs, agent.mutationTools);
5996
- pendingToolResult = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now };
6074
+ pendingToolResult = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now, progressText: extractReportedProgress(evt.toolName ?? "", evt.args) };
5997
6075
  if (typeof evt.toolCallId === "string" && evt.toolCallId) pendingToolResultsByCallId.set(evt.toolCallId, pendingToolResult);
5998
6076
  fireUpdate();
5999
6077
  }
@@ -6083,6 +6161,10 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6083
6161
  );
6084
6162
  }
6085
6163
  appendRecentOutput(progress, resultText.split("\n").slice(-10));
6164
+ if (evt.message.isError !== true && resultToolName === toolSnapshot?.tool && toolSnapshot?.progressText) {
6165
+ progress.progressText = toolSnapshot.progressText;
6166
+ progress.progressUpdatedAt = now;
6167
+ }
6086
6168
  if (toolSnapshot?.mutates && !budgetBlocked && didMutatingToolFail(evt.message)) {
6087
6169
  recordMutatingFailure(mutatingFailures, {
6088
6170
  tool: toolSnapshot.tool,
@@ -6121,7 +6203,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6121
6203
  activityTimer.unref?.();
6122
6204
  }
6123
6205
  if (attemptTimeout) {
6124
- timeoutTimer = setTimeout(() => {
6206
+ timeoutTimer = startPausableTimer(attemptTimeout.remainingMs, () => {
6125
6207
  if (sessionSettled || lifecycleFinished || interruptedByControl || result2.timedOut) return;
6126
6208
  result2.timedOut = true;
6127
6209
  timeoutCause = attemptTimeout.message;
@@ -6138,8 +6220,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6138
6220
  settle(void 0, true);
6139
6221
  }, 4e3);
6140
6222
  timeoutHardFinishTimer.unref?.();
6141
- }, attemptTimeout.remainingMs);
6142
- timeoutTimer.unref?.();
6223
+ });
6143
6224
  }
6144
6225
  let toolTimeoutSequence = 0;
6145
6226
  const activeToolTimeouts = /* @__PURE__ */ new Map();
@@ -6167,7 +6248,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6167
6248
  };
6168
6249
  const terminateForToolTimeout = (message) => {
6169
6250
  if (sessionSettled || lifecycleFinished || interruptedByControl || result2.timedOut) return;
6170
- clearTimeout(timeoutTimer);
6251
+ timeoutTimer?.clear();
6171
6252
  result2.timedOut = true;
6172
6253
  timeoutCause = message;
6173
6254
  result2.error = message;
@@ -6186,9 +6267,6 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
6186
6267
  const armToolTimeout = (event) => {
6187
6268
  const timeoutForTool = effectiveToolTimeoutMs(event.toolName, options.toolTimeoutMs);
6188
6269
  if (timeoutForTool === void 0) return;
6189
- const elapsed = Date.now() - startTime;
6190
- const runRemaining = attemptTimeout ? Math.max(0, attemptTimeout.remainingMs - elapsed) : void 0;
6191
- if (runRemaining !== void 0 && timeoutForTool >= runRemaining) return;
6192
6270
  const key = toolTimeoutCallKey(event, ++toolTimeoutSequence);
6193
6271
  const toolName = event.toolName;
6194
6272
  const timer = setTimeout(() => {
@@ -6306,12 +6384,12 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6306
6384
  const steer = created.steer.bind(created);
6307
6385
  const followUp = created.followUp.bind(created);
6308
6386
  created.steer = async (text) => {
6387
+ await steer(text);
6309
6388
  if (cleanTerminalAssistantStopReceived || agentSettledReceived) queuedDrainHold = true;
6310
- return steer(text);
6311
6389
  };
6312
6390
  created.followUp = async (text) => {
6391
+ await followUp(text);
6313
6392
  if (cleanTerminalAssistantStopReceived || agentSettledReceived) queuedDrainHold = true;
6314
- return followUp(text);
6315
6393
  };
6316
6394
  created.detached = detached;
6317
6395
  unsubscribe = created.subscribe((event) => processEvent(event));
@@ -6342,9 +6420,8 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6342
6420
  result2.exitCode = exitCode;
6343
6421
  result2.providerDiagnostics = clearProviderRetry(result2.providerDiagnostics);
6344
6422
  progress.providerDiagnostics = result2.providerDiagnostics;
6345
- if (afterCompactionSettlement) {
6346
- result2[AFTER_COMPACTION_SETTLEMENT] = true;
6347
- }
6423
+ if (afterCompactionSettlement) result2[AFTER_COMPACTION_SETTLEMENT] = true;
6424
+ result2[REMAINING_TIMEOUT_MS] = remainingTimeoutMs;
6348
6425
  if (interruptedByControl) {
6349
6426
  result2.exitCode = 0;
6350
6427
  result2.interrupted = true;
@@ -6399,6 +6476,9 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
6399
6476
  } else if (errInfo.hasError) {
6400
6477
  result2.exitCode = errInfo.exitCode ?? 1;
6401
6478
  result2.error = errInfo.details ? `${errInfo.errorType} failed (exit ${errInfo.exitCode}): ${errInfo.details}` : `${errInfo.errorType} failed with exit code ${errInfo.exitCode}`;
6479
+ } else if (!validatedStructuredOutput && getTerminalAssistantStopReason(messages) === "length") {
6480
+ result2.exitCode = 1;
6481
+ result2.error = TRUNCATED_RESPONSE_ERROR;
6402
6482
  }
6403
6483
  }
6404
6484
  progress.status = result2.exitCode === 0 ? "completed" : "failed";
@@ -6651,7 +6731,8 @@ ${acceptancePrompt}` : task;
6651
6731
  {
6652
6732
  scope: options.modelScope,
6653
6733
  primaryModelFromParent: options.modelOverrideFromParent,
6654
- origin: options.modelOrigin ?? (options.modelOverrideFromParent ? "inherited" : "configured")
6734
+ origin: options.modelOrigin ?? (options.modelOverrideFromParent ? "inherited" : "configured"),
6735
+ knownProviders: options.knownProviders
6655
6736
  }
6656
6737
  );
6657
6738
  try {
@@ -6799,6 +6880,8 @@ ${PROMPT_REDACTED}; live Prompt Audit only.
6799
6880
  });
6800
6881
  if (recovery.action === "resume") {
6801
6882
  recoveryPrompt = recovery.prompt;
6883
+ const remainingMs = attemptResult[REMAINING_TIMEOUT_MS];
6884
+ if (remainingMs !== void 0) attemptOptions.deadlineAt = Date.now() + remainingMs;
6802
6885
  attemptNotes.push("[abort-recovery] compaction abort after useful progress; resuming the retained child session once on the same model.");
6803
6886
  continue;
6804
6887
  }
@@ -7557,7 +7640,7 @@ async function createPrunedForkSessionWriter(ctx, config, signal) {
7557
7640
  };
7558
7641
  if (!config.model?.trim()) throw new Error("Pruned fork context requires config.forkContext.model.");
7559
7642
  const available = ctx.modelRegistry.getAvailable();
7560
- const resolved = resolveModelCandidate(config.model.trim(), available.map(toModelInfo), ctx.model?.provider);
7643
+ const resolved = resolveModelCandidate(config.model.trim(), available.map(toModelInfo), ctx.model?.provider, knownModelProviders(ctx.modelRegistry));
7561
7644
  if (!resolved) throw new Error(`Pruned fork model '${config.model}' did not match exactly one available model.`);
7562
7645
  const { baseModel } = splitKnownThinkingSuffix(resolved);
7563
7646
  const named = splitProviderModel(baseModel);
@@ -10335,7 +10418,7 @@ function resolveForegroundResumeTarget(params, state, options = {}) {
10335
10418
  if (!child.sessionFile) throw new Error(`Foreground run '${run.runId}' child ${index} does not have a persisted session file to resume from.`);
10336
10419
  if (path18.extname(child.sessionFile) !== ".jsonl") throw new Error(`Foreground run '${run.runId}' child ${index} session file must be a .jsonl file: ${child.sessionFile}`);
10337
10420
  const sessionFile = path18.resolve(child.sessionFile);
10338
- if (!fs20.existsSync(sessionFile)) throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}`);
10421
+ if (!fs20.existsSync(sessionFile)) throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}${missingForkCopyNote(sessionFile)}`);
10339
10422
  return {
10340
10423
  runId: run.runId,
10341
10424
  mode: run.mode,
@@ -10661,6 +10744,7 @@ function appendStepToAsyncChain(input) {
10661
10744
  parentProviderRegistry: input.ctx.modelRegistry,
10662
10745
  currentModel: parentModel,
10663
10746
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
10747
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
10664
10748
  modelScope: discoveredForAppend.modelScope,
10665
10749
  modelResponseAliases: input.deps.config.modelResponseAliases,
10666
10750
  interactive: input.ctx.hasUI,
@@ -10776,7 +10860,7 @@ function validateNestedSessionFile(run, trustedSessionRoots2, resolveSource, vis
10776
10860
  if (path18.extname(sessionFile) !== ".jsonl") throw new Error(`Nested run '${run.id}' session file must be a .jsonl file: ${sessionFile}`);
10777
10861
  const resolved = path18.resolve(sessionFile);
10778
10862
  if (!path18.isAbsolute(sessionFile)) throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
10779
- if (!fs20.existsSync(resolved)) throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}`);
10863
+ if (!fs20.existsSync(resolved)) throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}${missingForkCopyNote(resolved)}`);
10780
10864
  const stat = fs20.lstatSync(resolved);
10781
10865
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
10782
10866
  const realSessionFile = fs20.realpathSync(resolved);
@@ -11064,6 +11148,7 @@ async function resumeExternalJobFollowUp(input) {
11064
11148
  parentProviderRegistry: input.ctx.modelRegistry,
11065
11149
  currentModel: parentModel,
11066
11150
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
11151
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
11067
11152
  modelScope: input.modelScope,
11068
11153
  modelResponseAliases: input.deps.config.modelResponseAliases,
11069
11154
  interactive: input.ctx.hasUI,
@@ -11342,6 +11427,7 @@ async function resumeAsyncRun(input) {
11342
11427
  parentProviderRegistry: input.ctx.modelRegistry,
11343
11428
  currentModel: parentModel2,
11344
11429
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
11430
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
11345
11431
  modelScope,
11346
11432
  modelResponseAliases: input.deps.config.modelResponseAliases,
11347
11433
  runnerLaunchers: input.deps.config.runnerLaunchers,
@@ -11467,6 +11553,7 @@ async function resumeAsyncRun(input) {
11467
11553
  parentProviderRegistry: input.ctx.modelRegistry,
11468
11554
  currentModel: parentModel,
11469
11555
  scopedModelIds: scopedModelIdsFromContext(input.ctx),
11556
+ knownProviders: knownModelProviders(input.ctx.modelRegistry),
11470
11557
  modelScope,
11471
11558
  // Absence in the retained contract is meaningful; never acquire current aliases.
11472
11559
  modelResponseAliases: recoveryDescriptor ? recoveryDescriptor.modelResponseAliases : foregroundContract?.modelResponseAliases,
@@ -12091,10 +12178,6 @@ var MAX_TIMER_DELAY_MS = 2147483647;
12091
12178
  function timerDelayOverflowError(name, value) {
12092
12179
  return typeof value === "number" && value > MAX_TIMER_DELAY_MS ? `${name} must be a positive integer no larger than ${MAX_TIMER_DELAY_MS}.` : void 0;
12093
12180
  }
12094
- function resolveConfigDefaultTimeoutMs(raw) {
12095
- if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > MAX_TIMER_DELAY_MS) return void 0;
12096
- return raw;
12097
- }
12098
12181
  function resolveForegroundTimeout(params, defaultTimeoutMs) {
12099
12182
  const rawTimeout = params.timeoutMs;
12100
12183
  const rawMaxRuntime = params.maxRuntimeMs;
@@ -12235,7 +12318,7 @@ function resolveStaticLaunchSummary(input) {
12235
12318
  input.parentModel,
12236
12319
  input.availableModels,
12237
12320
  agentConfig?.modelProvider ?? input.currentProvider,
12238
- modelScopes.length === 0 ? {} : { scope: modelScopes }
12321
+ { scope: modelScopes, knownProviders: input.knownProviders }
12239
12322
  );
12240
12323
  const thinkingOverride = externalRunner ? void 0 : input.thinkingOverrideForTask();
12241
12324
  const thinking = externalRunner ? void 0 : resolveEffectiveThinking(model, thinkingOverride ?? agentConfig?.thinking);
@@ -12254,6 +12337,7 @@ function collectStaticLaunchSummaries(input) {
12254
12337
  parentModel: input.parentModel,
12255
12338
  scopedModelIds: input.scopedModelIds,
12256
12339
  availableModels: input.availableModels,
12340
+ knownProviders: input.knownProviders,
12257
12341
  currentProvider: input.currentProvider,
12258
12342
  modelScope: input.modelScope,
12259
12343
  thinkingOverrideForTask: input.thinkingOverrideForTask
@@ -12527,6 +12611,7 @@ async function runAsyncPath(data, deps) {
12527
12611
  parentProviderRegistry: ctx.modelRegistry,
12528
12612
  currentModel: parentModel,
12529
12613
  scopedModelIds: data.scopedModelIds,
12614
+ knownProviders: knownModelProviders(ctx.modelRegistry),
12530
12615
  modelScope: data.modelScope,
12531
12616
  modelResponseAliases: deps.config.modelResponseAliases,
12532
12617
  runnerLaunchers: deps.config.runnerLaunchers,
@@ -12567,8 +12652,9 @@ async function runAsyncPath(data, deps) {
12567
12652
  parentModel
12568
12653
  });
12569
12654
  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, {
12570
- ...modelScopes.length === 0 ? {} : { scope: modelScopes },
12571
- source: modelOrigin === "explicit" ? "explicit" : "inherited"
12655
+ scope: modelScopes,
12656
+ source: modelOrigin === "explicit" ? "explicit" : "inherited",
12657
+ knownProviders: asyncCtx.knownProviders
12572
12658
  });
12573
12659
  const modelOverrideFromParent = modelOrigin === "inherited";
12574
12660
  const launchRuleError = applyWatchdogLaunchRules({ cwd: effectiveCwd, agent: a.name, model: modelOverride ?? (parentModel && `${parentModel.provider}/${parentModel.id}`), warn: (violation) => deps.watchdog?.displayRuleWarning(violation) });
@@ -12981,6 +13067,7 @@ async function runSinglePath(data, deps) {
12981
13067
  const parentModel = data.parentModel;
12982
13068
  const currentProvider = parentModel?.provider;
12983
13069
  const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
13070
+ const knownProviders = knownModelProviders(ctx.modelRegistry);
12984
13071
  const modelScopes = resolveModelScopesForAgent(data.modelScope, agentConfig.name, parentModel, data.scopedModelIds);
12985
13072
  let task = typeof params.task === "string" ? params.task : "";
12986
13073
  const modelOrigin = resolveModelOrigin({
@@ -12996,8 +13083,9 @@ async function runSinglePath(data, deps) {
12996
13083
  availableModels,
12997
13084
  agentConfig.modelProvider ?? currentProvider,
12998
13085
  {
12999
- ...modelScopes.length === 0 ? {} : { scope: modelScopes },
13000
- source: modelOrigin === "explicit" ? "explicit" : "inherited"
13086
+ scope: modelScopes,
13087
+ source: modelOrigin === "explicit" ? "explicit" : "inherited",
13088
+ knownProviders
13001
13089
  }
13002
13090
  );
13003
13091
  const modelOverrideFromParent = modelOrigin === "inherited";
@@ -13254,6 +13342,7 @@ async function runSinglePath(data, deps) {
13254
13342
  thinkingCeiling: agentConfig.maxThinking,
13255
13343
  extensionBindings: params.extensionBindings,
13256
13344
  availableModels,
13345
+ knownProviders,
13257
13346
  modelResponseAliases,
13258
13347
  preferredModelProvider: currentProvider,
13259
13348
  modelScope: modelScopes,
@@ -14307,6 +14396,7 @@ function createSubagentExecutor(deps) {
14307
14396
  const controller = new AbortController();
14308
14397
  deps2.state.workflowControllers ??= /* @__PURE__ */ new Map();
14309
14398
  deps2.state.workflowChildStops ??= /* @__PURE__ */ new Map();
14399
+ deps2.state.workflowDrains ??= /* @__PURE__ */ new Map();
14310
14400
  deps2.state.workflowControllers.set(workflowRunId, controller);
14311
14401
  workflowCapacity?.markWorkflowStarted();
14312
14402
  if (workflowCapacity) deps2.state.activeAsyncCapacity = getActiveAsyncCapacitySnapshot(currentSessionId, resolveMaxActiveAsyncRunsPerSession(deps2.config.maxActiveAsyncRunsPerSession), { liveWorkflowRunIds: new Set(deps2.state.workflowControllers.keys()), abandonedSlotReleaseAfterMs: resolveAbandonedSlotReleaseAfterMs(deps2.config.capacity?.abandonedSlotReleaseAfterMs) });
@@ -14830,6 +14920,30 @@ Parent action: ${STATUS_ACTION}`,
14830
14920
  if (stop) deps2.state.workflowChildStops?.set(workflowRunId, stop);
14831
14921
  else deps2.state.workflowChildStops?.delete(workflowRunId);
14832
14922
  },
14923
+ registerDrain: (drain) => {
14924
+ if (!drain) deps2.state.workflowDrains?.delete(workflowRunId);
14925
+ else deps2.state.workflowDrains?.set(workflowRunId, () => {
14926
+ if (workflowRunEvidence.drainRequestedAt === void 0) {
14927
+ const previousWorkflow = status.workflow;
14928
+ workflowRunEvidence.drainRequestedAt = Date.now();
14929
+ status.workflow = { ...previousWorkflow ?? { trace: [], emits: [], console: [] }, drainRequestedAt: workflowRunEvidence.drainRequestedAt };
14930
+ let saved = false;
14931
+ try {
14932
+ persist();
14933
+ saved = runPersistence.pendingCount() === 0;
14934
+ } catch (error) {
14935
+ console.error(`Failed to save the drain request for async workflow '${workflowRunId}':`, error);
14936
+ }
14937
+ if (!saved) {
14938
+ delete workflowRunEvidence.drainRequestedAt;
14939
+ status.workflow = previousWorkflow;
14940
+ persist({ tolerateStatusWriteFailure: true });
14941
+ return { ok: false };
14942
+ }
14943
+ }
14944
+ return { ok: true, started: drain(() => queueMicrotask(() => controller.abort(new Error("Workflow drained: started children finished; no new children were started.")))) };
14945
+ });
14946
+ },
14833
14947
  ...workflowState2 ? { state: workflowState2 } : {},
14834
14948
  onTrace: updateTrace,
14835
14949
  onChildSettled: (notification) => {
@@ -14977,6 +15091,8 @@ Parent action: ${COMPLETION_ACTION}` : content,
14977
15091
  step2.currentToolArgs = progress.currentToolArgs;
14978
15092
  step2.currentToolStartedAt = progress.currentToolStartedAt;
14979
15093
  step2.currentPath = progress.currentPath;
15094
+ step2.progressText = progress.progressText;
15095
+ step2.progressUpdatedAt = progress.progressUpdatedAt;
14980
15096
  step2.recentTools = progress.recentTools.map((tool) => ({ ...tool }));
14981
15097
  step2.recentOutput = [...progress.recentOutput];
14982
15098
  step2.turnCount = progress.turnCount;
@@ -15937,6 +16053,7 @@ ${item.text}` } : item)
15937
16053
  }
15938
16054
  if (action === "stop") {
15939
16055
  const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
16056
+ 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: [] } };
15940
16057
  const workflowRunId = targetRunId && paramsWithResolvedCwd.childId !== void 0 ? resolveLiveWorkflowRunId(deps2, targetRunId) : void 0;
15941
16058
  if (workflowRunId && paramsWithResolvedCwd.childId !== void 0) {
15942
16059
  const stopChild = deps2.state.workflowChildStops?.get(workflowRunId);
@@ -15976,7 +16093,7 @@ ${item.text}` } : item)
15976
16093
  if (paramsWithResolvedCwd.dir) {
15977
16094
  try {
15978
16095
  const location = resolveAsyncRunLocation(paramsWithResolvedCwd, DIRS.async, DIRS.results);
15979
- const stopResult2 = stopAsyncRun(deps2.state, location.resolvedId ?? targetRunId ?? path18.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps2.kill, location, paramsWithResolvedCwd.childId);
16096
+ const stopResult2 = stopAsyncRun(deps2.state, location.resolvedId ?? targetRunId ?? path18.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps2.kill, location, paramsWithResolvedCwd.childId, paramsWithResolvedCwd.drain);
15980
16097
  return stopResult2 ?? { content: [{ type: "text", text: `No running or queued async run was found for '${targetRunId ?? paramsWithResolvedCwd.dir}'.` }], isError: true, details: { mode: "management", results: [] } };
15981
16098
  } catch (error) {
15982
16099
  const text = error instanceof Error ? error.message : String(error);
@@ -15997,7 +16114,8 @@ ${item.text}` } : item)
15997
16114
  resolved?.kind === "async" ? resolved.id : targetRunId,
15998
16115
  deps2.kill,
15999
16116
  resolved?.kind === "async" ? resolved.location : void 0,
16000
- paramsWithResolvedCwd.childId
16117
+ paramsWithResolvedCwd.childId,
16118
+ paramsWithResolvedCwd.drain
16001
16119
  );
16002
16120
  if (stopResult) return stopResult;
16003
16121
  return {
@@ -16489,6 +16607,7 @@ ${item.text}` } : item)
16489
16607
  parentModel: requestParentModel,
16490
16608
  scopedModelIds: scopedModelIdsFromContext(ctx),
16491
16609
  availableModels: ctx.modelRegistry.getAvailable().map(toModelInfo),
16610
+ knownProviders: knownModelProviders(ctx.modelRegistry),
16492
16611
  currentProvider: requestParentModel?.provider,
16493
16612
  modelScope,
16494
16613
  thinkingOverrideForTask,
@@ -16762,7 +16881,6 @@ export {
16762
16881
  promptAuditRedoParams,
16763
16882
  readNestedRecoveryDescriptor,
16764
16883
  removeForegroundControlIfIdle,
16765
- resolveConfigDefaultTimeoutMs,
16766
16884
  resolveForegroundTimeout,
16767
16885
  resolveRevivalControlConfig,
16768
16886
  resolveSingleAgentLaunchTimeout,