pi-subagents 0.89.1 → 0.90.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.
- package/CHANGELOG.md +48 -0
- package/bundle/agents.js +4 -4
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-SG3NCWZW.js → chunk-2LEBXCLU.js} +29 -19
- package/bundle/{chunk-UUW7P6KJ.js → chunk-37EJGDYO.js} +2 -2
- package/bundle/{chunk-IGZTXGPG.js → chunk-4DA22WRU.js} +59 -30
- package/bundle/{chunk-77VQEATI.js → chunk-5J2RTMKW.js} +2 -2
- package/bundle/{chunk-7J4ZXMY7.js → chunk-72334PEI.js} +6 -4
- package/bundle/{chunk-F6PTAPQ3.js → chunk-7HPZIT4W.js} +13 -13
- package/bundle/{chunk-SWGB2P5J.js → chunk-7Y4IJMCW.js} +1 -1
- package/bundle/{chunk-TRN65L4F.js → chunk-ACTHBJUI.js} +1 -1
- package/bundle/{chunk-6D54VW3E.js → chunk-AJWRYQPH.js} +145 -76
- package/bundle/{chunk-TXC7WIPL.js → chunk-C45WQQZX.js} +1 -1
- package/bundle/{chunk-YJIU5WF4.js → chunk-CPWZN5KM.js} +1 -1
- package/bundle/{chunk-BERAWSQQ.js → chunk-DNJ2GHSI.js} +7 -7
- package/bundle/{chunk-CASL47ST.js → chunk-EBGTTJKP.js} +6 -6
- package/bundle/{chunk-LWH7IGI3.js → chunk-F4NSLXB2.js} +8 -6
- package/bundle/{chunk-URKQZHVH.js → chunk-G43SW4BT.js} +29 -19
- package/bundle/{chunk-Q4VH72JI.js → chunk-KNVQTRSY.js} +2 -2
- package/bundle/{chunk-5TXWZB73.js → chunk-P2M6RIVX.js} +1 -1
- package/bundle/{chunk-ROJH7KPK.js → chunk-PSB3VLMH.js} +2 -2
- package/bundle/{chunk-VEEUXJDO.js → chunk-PTN7XAXI.js} +2 -2
- package/bundle/{chunk-TDXVQPZW.js → chunk-RIBMW6V3.js} +69 -15
- package/bundle/{chunk-KCDPTXHT.js → chunk-SIB2GQHL.js} +238 -200
- package/bundle/{chunk-JEZOSEWG.js → chunk-SRWJIAIP.js} +2 -0
- package/bundle/{chunk-OUM6SEVD.js → chunk-UC22RDXP.js} +8 -4
- package/bundle/{chunk-W2BZS6UC.js → chunk-VMJGZHUL.js} +9 -5
- package/bundle/{chunk-MIX3MCIF.js → chunk-WANQBKAZ.js} +12 -7
- package/bundle/{chunk-LUNVS6KP.js → chunk-WHHRG32M.js} +27 -20
- package/bundle/{chunk-C22YEYFZ.js → chunk-XIQKWTFY.js} +5 -5
- package/bundle/{chunk-YLU5JFW2.js → chunk-XYIVVS3A.js} +7 -3
- package/bundle/{chunk-R3NH5XAL.js → chunk-YVDKGAEO.js} +5 -4
- package/bundle/{chunk-4FFKVLBG.js → chunk-ZWGOHOGI.js} +5 -5
- package/bundle/control-channel.js +3 -3
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +3 -3
- package/bundle/preflight.js +13 -11
- package/bundle/project-panes.js +5 -5
- package/bundle/shared-types.js +1 -1
- package/bundle/workflow-resources.js +1 -1
- package/docs/configuration.md +12 -3
- package/docs/models.md +1 -1
- package/docs/observability.md +10 -2
- package/docs/tool-reference.md +5 -2
- package/docs/watchdog.md +3 -2
- package/docs/workflows.md +1 -1
- package/package.json +1 -1
- package/skills/pi-subagents/SKILL.md +1 -1
- package/src/agents/agents.d.ts +2 -0
- package/src/agents/agents.js +4 -0
- package/src/api/preflight.d.ts +1 -0
- package/src/api/preflight.js +2 -1
- package/src/extension/config.js +3 -0
- package/src/extension/public-execution.js +4 -2
- package/src/extension/reply-workflow-script.js +10 -1
- package/src/extension/schemas.d.ts +1 -0
- package/src/extension/schemas.js +2 -0
- package/src/extension/subagent-options.d.ts +2 -0
- package/src/extension/subagent-options.js +10 -4
- package/src/inspectors/herdr/project-panes.d.ts +2 -0
- package/src/inspectors/herdr/project-panes.js +7 -1
- package/src/inspectors/shell-command.d.ts +2 -1
- package/src/inspectors/shell-command.js +7 -5
- package/src/runs/background/active-async-capacity.js +2 -1
- package/src/runs/background/active-run-index.d.ts +1 -0
- package/src/runs/background/active-run-index.js +3 -0
- package/src/runs/background/async-execution.d.ts +2 -0
- package/src/runs/background/async-execution.js +6 -3
- package/src/runs/background/async-retention.js +48 -12
- package/src/runs/background/async-status.js +32 -17
- package/src/runs/background/process-terminal.d.ts +6 -0
- package/src/runs/background/process-terminal.js +34 -2
- package/src/runs/background/retained-children.js +1 -1
- package/src/runs/background/run-status.js +2 -1
- package/src/runs/background/stale-run-reconciler.d.ts +8 -0
- package/src/runs/background/stale-run-reconciler.js +38 -8
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +4 -4
- package/src/runs/foreground/execution.js +7 -9
- package/src/runs/foreground/subagent-executor.d.ts +2 -0
- package/src/runs/foreground/subagent-executor.js +129 -45
- package/src/runs/shared/fast-mode-extension.d.ts +2 -1
- package/src/runs/shared/fast-mode-extension.js +5 -3
- package/src/runs/shared/herdr-pane-host.js +10 -2
- package/src/runs/shared/mcp-config-sources.d.ts +1 -0
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js +1 -0
- package/src/shared/capacity-resilient-json.d.ts +7 -3
- package/src/shared/capacity-resilient-json.js +8 -6
- package/src/shared/disabled-features.d.ts +4 -0
- package/src/shared/disabled-features.js +1 -0
- package/src/shared/types.d.ts +19 -0
- package/src/shared/types.js +2 -0
- package/src/tui/fleet-transcript.js +21 -9
- package/src/tui/fleet.js +1 -0
- package/src/watchdog/runtime.d.ts +4 -0
- package/src/watchdog/runtime.js +50 -12
- package/src/watchdog/turn-delta.d.ts +2 -0
- package/src/watchdog/turn-delta.js +21 -0
- package/src/workflows/structured-workflow-scripts.js +6 -4
- package/src/workflows/workflow-resources.js +4 -2
- package/src/workflows/workflow-revival.d.ts +6 -0
- package/src/workflows/workflow-revival.js +1 -1
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
projectRuntimeAcknowledgedExtensions,
|
|
4
4
|
registerSubagentPromptBoundary,
|
|
5
5
|
registerSubagentPromptRuntime
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EBGTTJKP.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-
|
|
28
|
+
} from "./chunk-DNJ2GHSI.js";
|
|
29
29
|
import {
|
|
30
30
|
PLACED_RESTORE_UNSUPPORTED,
|
|
31
31
|
formatHerdrMachineRunnerUnsupported,
|
|
32
32
|
resolveMachinePlacement
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-C45WQQZX.js";
|
|
34
34
|
import {
|
|
35
35
|
COMPLETION_ACTION,
|
|
36
36
|
DEFAULT_CONTROL_CONFIG,
|
|
@@ -77,6 +77,7 @@ import {
|
|
|
77
77
|
incrementalChildCompletionTriggersTurn,
|
|
78
78
|
isOrdinaryToolForMidToolExit,
|
|
79
79
|
isScheduledRunAction,
|
|
80
|
+
isUnsetPlaceholder,
|
|
80
81
|
isWorkflowScriptPath,
|
|
81
82
|
listRetainedChildren,
|
|
82
83
|
manualWorkflowResumeRefusalText,
|
|
@@ -119,7 +120,7 @@ import {
|
|
|
119
120
|
workflowScriptDigest,
|
|
120
121
|
workflowStopCause,
|
|
121
122
|
writeWorkflowReceipt
|
|
122
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-WHHRG32M.js";
|
|
123
124
|
import {
|
|
124
125
|
SUBAGENT_PARENT_SESSION_ENV,
|
|
125
126
|
applyWatchdogLaunchRules,
|
|
@@ -132,7 +133,7 @@ import {
|
|
|
132
133
|
resolveWatchdogConfig,
|
|
133
134
|
sendRuleViolationWarning,
|
|
134
135
|
writeWatchdogModelSettings
|
|
135
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-RIBMW6V3.js";
|
|
136
137
|
import {
|
|
137
138
|
MAX_REMEMBERED_FOREGROUND_RUNS,
|
|
138
139
|
discardRunningForegroundRun,
|
|
@@ -145,7 +146,7 @@ import {
|
|
|
145
146
|
resolveSubagentRunId,
|
|
146
147
|
resolveWorkflowChatProgress,
|
|
147
148
|
stopAsyncRun
|
|
148
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-XIQKWTFY.js";
|
|
149
150
|
import {
|
|
150
151
|
RunFanoutLimitError,
|
|
151
152
|
annotateWorkflowPreflightTrace,
|
|
@@ -209,12 +210,12 @@ import {
|
|
|
209
210
|
writeRunFanoutBudgetDescriptor,
|
|
210
211
|
writeWorkflowLaunchRecord,
|
|
211
212
|
writeWorktreeSetupHandoff
|
|
212
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-2LEBXCLU.js";
|
|
213
214
|
import {
|
|
214
215
|
NATIVE_SUPERVISOR_TOOL_NAME,
|
|
215
216
|
createNativeSupervisorChannel,
|
|
216
217
|
resolveSupervisorChannelDir
|
|
217
|
-
} from "./chunk-
|
|
218
|
+
} from "./chunk-PTN7XAXI.js";
|
|
218
219
|
import {
|
|
219
220
|
MODEL_ONLY_TOOL,
|
|
220
221
|
inheritedSessionIds,
|
|
@@ -231,16 +232,16 @@ import {
|
|
|
231
232
|
resolveStructuredWorkflowResource,
|
|
232
233
|
resolveWorkflowResource,
|
|
233
234
|
validateWorkflowChildPermitRoot
|
|
234
|
-
} from "./chunk-
|
|
235
|
+
} from "./chunk-VMJGZHUL.js";
|
|
235
236
|
import {
|
|
236
237
|
buildEffectiveSystemPrompt,
|
|
237
238
|
canPreferFork,
|
|
238
239
|
createForkContextResolver,
|
|
239
240
|
resolveSubagentLaunchContext
|
|
240
|
-
} from "./chunk-
|
|
241
|
+
} from "./chunk-PSB3VLMH.js";
|
|
241
242
|
import {
|
|
242
243
|
handleRefinementAction
|
|
243
|
-
} from "./chunk-
|
|
244
|
+
} from "./chunk-KNVQTRSY.js";
|
|
244
245
|
import {
|
|
245
246
|
ActiveAsyncCapacityError,
|
|
246
247
|
acquireActiveAsyncCapacity,
|
|
@@ -256,7 +257,7 @@ import {
|
|
|
256
257
|
resolveDisabledFeatureSurface,
|
|
257
258
|
resolveMaxActiveAsyncRunsPerSession,
|
|
258
259
|
transferActiveAsyncCapacity
|
|
259
|
-
} from "./chunk-
|
|
260
|
+
} from "./chunk-XYIVVS3A.js";
|
|
260
261
|
import {
|
|
261
262
|
DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS,
|
|
262
263
|
MACHINE_DIFF_OPTIONS,
|
|
@@ -329,6 +330,7 @@ import {
|
|
|
329
330
|
sanitizeProcessTerminal,
|
|
330
331
|
shouldDeferWorktreeCwd,
|
|
331
332
|
snapshotNestedEventFiles,
|
|
333
|
+
unobservedRunnerExitPath,
|
|
332
334
|
updateActiveRunIndex,
|
|
333
335
|
updateForegroundNestedProjection,
|
|
334
336
|
updateMission,
|
|
@@ -343,7 +345,7 @@ import {
|
|
|
343
345
|
writeNestedControlRequest,
|
|
344
346
|
writeNestedControlResult,
|
|
345
347
|
writeNestedEvent
|
|
346
|
-
} from "./chunk-
|
|
348
|
+
} from "./chunk-SIB2GQHL.js";
|
|
347
349
|
import {
|
|
348
350
|
closeSteerInbox,
|
|
349
351
|
consumeSteerRequests,
|
|
@@ -351,7 +353,7 @@ import {
|
|
|
351
353
|
readRevivalBriefs,
|
|
352
354
|
requestAsyncSteer,
|
|
353
355
|
watchAsyncControlInbox
|
|
354
|
-
} from "./chunk-
|
|
356
|
+
} from "./chunk-37EJGDYO.js";
|
|
355
357
|
import "./chunk-NIXWDZZV.js";
|
|
356
358
|
import {
|
|
357
359
|
INTERCOM_BRIDGE_MARKER,
|
|
@@ -360,7 +362,7 @@ import {
|
|
|
360
362
|
resolveIntercomBridge,
|
|
361
363
|
resolveIntercomSessionTarget,
|
|
362
364
|
resolveSubagentIntercomTarget
|
|
363
|
-
} from "./chunk-
|
|
365
|
+
} from "./chunk-CPWZN5KM.js";
|
|
364
366
|
import {
|
|
365
367
|
agentDefinitionDigest,
|
|
366
368
|
resolveLaunchBinding,
|
|
@@ -375,7 +377,7 @@ import {
|
|
|
375
377
|
resolvePiLaunchToolPlan,
|
|
376
378
|
resolveRuntimeModulePath,
|
|
377
379
|
supervisorChannelDir
|
|
378
|
-
} from "./chunk-
|
|
380
|
+
} from "./chunk-YVDKGAEO.js";
|
|
379
381
|
import {
|
|
380
382
|
assertRequiredChildExtensionsAdmitted,
|
|
381
383
|
createRequiredChildExtensionIdentity,
|
|
@@ -387,8 +389,8 @@ import {
|
|
|
387
389
|
import {
|
|
388
390
|
HERDR_PROJECT_PANE_ACTIONS,
|
|
389
391
|
handleHerdrProjectPaneAction
|
|
390
|
-
} from "./chunk-
|
|
391
|
-
import "./chunk-
|
|
392
|
+
} from "./chunk-UC22RDXP.js";
|
|
393
|
+
import "./chunk-72334PEI.js";
|
|
392
394
|
import {
|
|
393
395
|
PROJECT_SUBAGENTS_RELATIVE_DIR,
|
|
394
396
|
appendJsonl,
|
|
@@ -401,12 +403,12 @@ import {
|
|
|
401
403
|
missingForkCopyNote,
|
|
402
404
|
writeArtifact,
|
|
403
405
|
writeMetadata
|
|
404
|
-
} from "./chunk-
|
|
406
|
+
} from "./chunk-5J2RTMKW.js";
|
|
405
407
|
import "./chunk-XA3DY6UG.js";
|
|
406
408
|
import {
|
|
407
409
|
getExternalJobProvider
|
|
408
410
|
} from "./chunk-YYREO77V.js";
|
|
409
|
-
import "./chunk-
|
|
411
|
+
import "./chunk-7Y4IJMCW.js";
|
|
410
412
|
import {
|
|
411
413
|
ChainOutputValidationError,
|
|
412
414
|
DEFAULT_WAIT_TOOL_NAME,
|
|
@@ -426,6 +428,7 @@ import {
|
|
|
426
428
|
acceptChildWatchdogEvent,
|
|
427
429
|
acceptanceFailureMessage,
|
|
428
430
|
acceptanceHasTypedVerify,
|
|
431
|
+
agentRunDescription,
|
|
429
432
|
applyChildWatchdogMessage,
|
|
430
433
|
assertClaudeCodeModelScope,
|
|
431
434
|
assertJsonSchemaObject,
|
|
@@ -491,6 +494,7 @@ import {
|
|
|
491
494
|
isDynamicRunnerGroup,
|
|
492
495
|
isParallelGroup,
|
|
493
496
|
isParallelStep,
|
|
497
|
+
isRetryableFileSystemError,
|
|
494
498
|
isSettlementFatalOutputError,
|
|
495
499
|
isStorageCapacityError,
|
|
496
500
|
isToolBudgetBlockedMessage,
|
|
@@ -560,7 +564,7 @@ import {
|
|
|
560
564
|
writeAtomicJson,
|
|
561
565
|
writeInitialProgressFile,
|
|
562
566
|
writePrivateAtomicJson
|
|
563
|
-
} from "./chunk-
|
|
567
|
+
} from "./chunk-F4NSLXB2.js";
|
|
564
568
|
import {
|
|
565
569
|
CHAIN_RUNS_DIR,
|
|
566
570
|
DEFAULT_ARTIFACT_CONFIG,
|
|
@@ -578,6 +582,7 @@ import {
|
|
|
578
582
|
SUBAGENT_FOREGROUND_COMPLETE_EVENT,
|
|
579
583
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
580
584
|
SUBAGENT_PROCESS_TERMINAL_EVENT,
|
|
585
|
+
TASK_SUBAGENT_LIFECYCLE_EVENT,
|
|
581
586
|
TEMP_ROOT_DIR,
|
|
582
587
|
checkSubagentDepth,
|
|
583
588
|
getAsyncConfigPath,
|
|
@@ -589,7 +594,7 @@ import {
|
|
|
589
594
|
resolveMaxSubagentSpawnsPerSession,
|
|
590
595
|
truncateOutput,
|
|
591
596
|
wrapForkTask
|
|
592
|
-
} from "./chunk-
|
|
597
|
+
} from "./chunk-SRWJIAIP.js";
|
|
593
598
|
import {
|
|
594
599
|
safeTerminalText,
|
|
595
600
|
sanitizeDisplayText
|
|
@@ -613,11 +618,13 @@ var defaultTimerApi = {
|
|
|
613
618
|
};
|
|
614
619
|
function createCapacityResilientJsonWriter(options = {}) {
|
|
615
620
|
const defaultWrite = options.write ?? writeAtomicJson;
|
|
621
|
+
const retryWrite = options.retryWrite ?? defaultWrite;
|
|
616
622
|
const keepAlive = options.keepAlive ?? false;
|
|
617
623
|
const retryDelayMs = options.retryDelayMs ?? 1e3;
|
|
618
624
|
const timerApi = options.timerApi ?? defaultTimerApi;
|
|
619
625
|
const onError = options.onError ?? ((error, filePath) => console.error(`Failed to persist JSON '${filePath}':`, error));
|
|
620
626
|
const onSuccess = options.onSuccess;
|
|
627
|
+
const shouldDefer = options.shouldDefer ?? isStorageCapacityError;
|
|
621
628
|
const reportError = (error, filePath) => {
|
|
622
629
|
try {
|
|
623
630
|
onError(error, filePath);
|
|
@@ -645,7 +652,7 @@ function createCapacityResilientJsonWriter(options = {}) {
|
|
|
645
652
|
pending.delete(filePath);
|
|
646
653
|
notifySuccess(filePath, entry.payload);
|
|
647
654
|
} catch (error) {
|
|
648
|
-
if (
|
|
655
|
+
if (shouldDefer(error, filePath)) continue;
|
|
649
656
|
pending.delete(filePath);
|
|
650
657
|
reportError(error, filePath);
|
|
651
658
|
}
|
|
@@ -663,8 +670,8 @@ function createCapacityResilientJsonWriter(options = {}) {
|
|
|
663
670
|
pending.delete(filePath);
|
|
664
671
|
notifySuccess(filePath, payload);
|
|
665
672
|
} catch (error) {
|
|
666
|
-
if (!
|
|
667
|
-
pending.set(filePath, { payload, write: writeOperation });
|
|
673
|
+
if (!shouldDefer(error, filePath)) throw error;
|
|
674
|
+
pending.set(filePath, { payload, write: writeOperation === defaultWrite ? retryWrite : writeOperation });
|
|
668
675
|
scheduleRetry();
|
|
669
676
|
}
|
|
670
677
|
},
|
|
@@ -1083,12 +1090,13 @@ function registerFanoutChildSubagentExtension(pi, childConfig) {
|
|
|
1083
1090
|
}
|
|
1084
1091
|
|
|
1085
1092
|
// src/runs/shared/fast-mode-extension.ts
|
|
1086
|
-
function rewriteFastModeProviderRequest(event) {
|
|
1093
|
+
function rewriteFastModeProviderRequest(event, serviceTier) {
|
|
1087
1094
|
if (!event.payload || typeof event.payload !== "object" || Array.isArray(event.payload)) return event.payload;
|
|
1088
|
-
return { ...event.payload, service_tier:
|
|
1095
|
+
return { ...event.payload, service_tier: serviceTier };
|
|
1089
1096
|
}
|
|
1090
1097
|
function registerSubagentFastModeExtension(pi) {
|
|
1091
|
-
|
|
1098
|
+
const serviceTier = loadConfig().fastServiceTier ?? "priority";
|
|
1099
|
+
pi.on("before_provider_request", (event) => rewriteFastModeProviderRequest(event, serviceTier));
|
|
1092
1100
|
}
|
|
1093
1101
|
|
|
1094
1102
|
// src/runs/shared/child-hooks.ts
|
|
@@ -2931,6 +2939,7 @@ function executeAsyncChain(id, params) {
|
|
|
2931
2939
|
completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
|
|
2932
2940
|
mode: resultMode,
|
|
2933
2941
|
agent: firstAgents[0],
|
|
2942
|
+
description: agentRunDescription(firstAgents[0], agents.find((candidate) => candidate.name === firstAgents[0])),
|
|
2934
2943
|
agents: flatAgents,
|
|
2935
2944
|
task: firstTask?.trim() ? PROMPT_REDACTED : void 0,
|
|
2936
2945
|
goal: workflowGoal?.trim() ? PROMPT_REDACTED : void 0,
|
|
@@ -3330,6 +3339,7 @@ function executeAsyncSingle(id, params) {
|
|
|
3330
3339
|
...capabilityCeiling ? { capabilityCeiling } : {},
|
|
3331
3340
|
agent,
|
|
3332
3341
|
task: taskText,
|
|
3342
|
+
...params.label ? { label: params.label } : {},
|
|
3333
3343
|
...agentConfig.runner ? { runner: agentConfig.runner } : {},
|
|
3334
3344
|
...singleClaudeCodeOverride ? { claudeCodeOverrideArgs: singleClaudeCodeOverride.args } : {},
|
|
3335
3345
|
...machine ? { machine } : {},
|
|
@@ -3453,7 +3463,7 @@ function executeAsyncSingle(id, params) {
|
|
|
3453
3463
|
chainStepCount: 1,
|
|
3454
3464
|
...lane ? { lane } : {},
|
|
3455
3465
|
...launcher ? { launcher } : {},
|
|
3456
|
-
steps: [{ agent, status: "pending", ...lane ? { lane } : {}, ...model ? { model } : {}, ...contextLimit !== void 0 ? { contextLimit } : {} }]
|
|
3466
|
+
steps: [{ agent, status: "pending", ...params.label ? { label: params.label } : {}, ...lane ? { lane } : {}, ...model ? { model } : {}, ...contextLimit !== void 0 ? { contextLimit } : {} }]
|
|
3457
3467
|
},
|
|
3458
3468
|
path5.join(asyncDir, "status.json"),
|
|
3459
3469
|
launchParentSessionId,
|
|
@@ -3523,6 +3533,7 @@ function executeAsyncSingle(id, params) {
|
|
|
3523
3533
|
mode: "single",
|
|
3524
3534
|
...params.toolCallId ? { toolCallId: params.toolCallId } : {},
|
|
3525
3535
|
agent,
|
|
3536
|
+
description: agentRunDescription(agent, agentConfig, params.label),
|
|
3526
3537
|
task: task?.trim() ? PROMPT_REDACTED : void 0,
|
|
3527
3538
|
goal: (params.goal ?? task).trim() ? PROMPT_REDACTED : void 0,
|
|
3528
3539
|
cwd: runnerCwd,
|
|
@@ -3866,8 +3877,13 @@ function earlierTurnHasJsBlock(branch, callIndex) {
|
|
|
3866
3877
|
}
|
|
3867
3878
|
return false;
|
|
3868
3879
|
}
|
|
3880
|
+
function hasOptionsScript(options) {
|
|
3881
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) return false;
|
|
3882
|
+
const script = options.script;
|
|
3883
|
+
return script !== void 0 && !isUnsetPlaceholder(script);
|
|
3884
|
+
}
|
|
3869
3885
|
function scriptFromReply(content, earlierBlock) {
|
|
3870
|
-
const replyCalls = content.filter((block) => block.type === "toolCall" && block.name === "subagent" && (block.arguments?.workflow === true || block.arguments?.workflow === "true")).length;
|
|
3886
|
+
const replyCalls = content.filter((block) => block.type === "toolCall" && block.name === "subagent" && (block.arguments?.workflow === true || block.arguments?.workflow === "true") && !hasOptionsScript(block.arguments?.options)).length;
|
|
3871
3887
|
if (replyCalls > 1) return { error: `This reply has ${replyCalls} subagent calls with workflow: true; a reply can carry only one. Pass other scripts as workflow file paths.` };
|
|
3872
3888
|
if (!content.some((block) => block.type === "text")) {
|
|
3873
3889
|
if (earlierBlock()) return { error: "The assistant message that issued this call has no text. A ```js block is in an earlier message of this turn, but workflow: true reads only the message that issues the call. Pass that script's source as options: { script: \"...\" } in place of workflow: true, with the call's other fields unchanged, or write the block and the call in one message." };
|
|
@@ -5374,15 +5390,14 @@ function isCompleteUsageCounter(value) {
|
|
|
5374
5390
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
5375
5391
|
}
|
|
5376
5392
|
var STOPPED_BEFORE_COMPLETION_ERROR = "Subagent stopped before completion.";
|
|
5377
|
-
var
|
|
5378
|
-
var REMAINING_TIMEOUT_MS = /* @__PURE__ */ Symbol("remainingTimeoutMs");
|
|
5393
|
+
var attemptRecoveryState = /* @__PURE__ */ new WeakMap();
|
|
5379
5394
|
async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared) {
|
|
5380
5395
|
const effectiveThinking = options.thinkingOverride ?? agent.thinking;
|
|
5381
5396
|
const modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== void 0);
|
|
5382
5397
|
assertThinkingWithinCeiling({ model: modelArg, configThinking: effectiveThinking, ceiling: options.thinkingCeiling, agent: agent.name, runId: options.runId });
|
|
5383
5398
|
const expectedModelForVerification = shared.verifyModel ? modelArg : void 0;
|
|
5384
5399
|
const resolvedThinking = resolveEffectiveThinking(modelArg, effectiveThinking);
|
|
5385
|
-
const childSessionName = deriveChildSessionName({ agent: agent.name, task: shared.originalTask ?? task });
|
|
5400
|
+
const childSessionName = deriveChildSessionName({ agent: agent.name, task: shared.originalTask ?? task, label: options.label });
|
|
5386
5401
|
const watchdogConfig = resolveWatchdogConfig(options.cwd ?? runtimeCwd);
|
|
5387
5402
|
const childWatchdog = watchdogConfig.ok ? resolveChildWatchdogConfig({
|
|
5388
5403
|
config: watchdogConfig.config,
|
|
@@ -6430,8 +6445,7 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
|
|
|
6430
6445
|
result2.exitCode = exitCode;
|
|
6431
6446
|
result2.providerDiagnostics = clearProviderRetry(result2.providerDiagnostics);
|
|
6432
6447
|
progress.providerDiagnostics = result2.providerDiagnostics;
|
|
6433
|
-
|
|
6434
|
-
result2[REMAINING_TIMEOUT_MS] = remainingTimeoutMs;
|
|
6448
|
+
attemptRecoveryState.set(result2, { afterCompactionSettlement, remainingTimeoutMs });
|
|
6435
6449
|
if (interruptedByControl) {
|
|
6436
6450
|
result2.exitCode = 0;
|
|
6437
6451
|
result2.interrupted = true;
|
|
@@ -6613,7 +6627,7 @@ async function runSyncCompletionInner(runtimeCwd, agents, agentName, task, optio
|
|
|
6613
6627
|
...options,
|
|
6614
6628
|
capabilityCeiling: intersectSubagentCapabilityCeilings(options.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(options.parentSessionId), options.childRuntime?.capabilityCeiling)
|
|
6615
6629
|
};
|
|
6616
|
-
const childSessionName = deriveChildSessionName({ agent: agentName, task });
|
|
6630
|
+
const childSessionName = deriveChildSessionName({ agent: agentName, task, label: options.label });
|
|
6617
6631
|
const agent = agents.find((a) => a.name === agentName);
|
|
6618
6632
|
if (!agent) {
|
|
6619
6633
|
const diagnosticContext = options.unknownAgentDiagnosticContext ?? unknownAgentDiagnosticContext(discoverAgents(path10.resolve(options.cwd ?? runtimeCwd), "both"));
|
|
@@ -6885,11 +6899,11 @@ ${PROMPT_REDACTED}; live Prompt Audit only.
|
|
|
6885
6899
|
structuredOutputFailed: attemptResult.structuredOutputFailed,
|
|
6886
6900
|
acceptanceFailed: false,
|
|
6887
6901
|
currentTool: attemptResult.progress?.currentTool,
|
|
6888
|
-
afterCompactionSettlement: attemptResult
|
|
6902
|
+
afterCompactionSettlement: attemptRecoveryState.get(attemptResult)?.afterCompactionSettlement
|
|
6889
6903
|
});
|
|
6890
6904
|
if (recovery.action === "resume") {
|
|
6891
6905
|
recoveryPrompt = recovery.prompt;
|
|
6892
|
-
const remainingMs = attemptResult
|
|
6906
|
+
const remainingMs = attemptRecoveryState.get(attemptResult)?.remainingTimeoutMs;
|
|
6893
6907
|
if (remainingMs !== void 0) attemptOptions.deadlineAt = Date.now() + remainingMs;
|
|
6894
6908
|
attemptNotes.push("[abort-recovery] compaction abort after useful progress; resuming the retained child session once on the same model.");
|
|
6895
6909
|
continue;
|
|
@@ -8451,6 +8465,7 @@ function formatRunLifecycleDebug(input) {
|
|
|
8451
8465
|
`Status file: ${path15.join(asyncDir, "status.json")}`,
|
|
8452
8466
|
status.workflowReceiptPath ? `Workflow receipt: ${status.workflowReceiptPath}` : void 0,
|
|
8453
8467
|
`Process terminal file: ${path15.join(asyncDir, "process-terminal.json")}`,
|
|
8468
|
+
`Unobserved runner exit file: ${unobservedRunnerExitPath(asyncDir)}`,
|
|
8454
8469
|
`Session: ${status.sessionId ?? "unknown"}`,
|
|
8455
8470
|
`State: ${status.state}`,
|
|
8456
8471
|
`Mode: ${status.mode}`,
|
|
@@ -10263,6 +10278,20 @@ function rememberedForegroundChild(input, result2, index, status, updatedAt) {
|
|
|
10263
10278
|
...result2.capabilityAudit ? { capabilityAudit: result2.capabilityAudit } : {}
|
|
10264
10279
|
};
|
|
10265
10280
|
}
|
|
10281
|
+
function foregroundStatusInput(result2) {
|
|
10282
|
+
return omitUndefinedProperties({
|
|
10283
|
+
exitCode: result2.exitCode,
|
|
10284
|
+
interrupted: result2.interrupted,
|
|
10285
|
+
detached: result2.detached,
|
|
10286
|
+
processSignal: result2.processSignal,
|
|
10287
|
+
timedOut: result2.timedOut,
|
|
10288
|
+
stopped: result2.stopped,
|
|
10289
|
+
turnBudgetExceeded: result2.turnBudgetExceeded
|
|
10290
|
+
});
|
|
10291
|
+
}
|
|
10292
|
+
function foregroundExecutionStatus(result2) {
|
|
10293
|
+
return resolveSubagentResultStatus(foregroundStatusInput(result2));
|
|
10294
|
+
}
|
|
10266
10295
|
function rememberForegroundRun(state, input) {
|
|
10267
10296
|
state.foregroundRuns ??= /* @__PURE__ */ new Map();
|
|
10268
10297
|
const previous = state.foregroundRuns.get(input.runId);
|
|
@@ -10274,15 +10303,7 @@ function rememberForegroundRun(state, input) {
|
|
|
10274
10303
|
...input.sessionId ? { sessionId: input.sessionId } : {},
|
|
10275
10304
|
updatedAt,
|
|
10276
10305
|
children: input.results.map((result2, index) => {
|
|
10277
|
-
const child = rememberedForegroundChild(input, result2, index,
|
|
10278
|
-
exitCode: result2.exitCode,
|
|
10279
|
-
interrupted: result2.interrupted,
|
|
10280
|
-
detached: result2.detached,
|
|
10281
|
-
processSignal: result2.processSignal,
|
|
10282
|
-
timedOut: result2.timedOut,
|
|
10283
|
-
stopped: result2.stopped,
|
|
10284
|
-
turnBudgetExceeded: result2.turnBudgetExceeded
|
|
10285
|
-
})), updatedAt);
|
|
10306
|
+
const child = rememberedForegroundChild(input, result2, index, foregroundExecutionStatus(result2), updatedAt);
|
|
10286
10307
|
const recovered = previous?.children[index];
|
|
10287
10308
|
return child.status === "detached" && recovered && recovered.status !== "detached" ? recovered : child;
|
|
10288
10309
|
})
|
|
@@ -10507,6 +10528,21 @@ function resolveResumeTarget(params, state, options = {}) {
|
|
|
10507
10528
|
if (asyncError) throw asyncError;
|
|
10508
10529
|
throw new Error("Run not found. Provide id or runId.");
|
|
10509
10530
|
}
|
|
10531
|
+
function foregroundLifecycleStatus(status) {
|
|
10532
|
+
if (status === "completed") return "completed";
|
|
10533
|
+
return status === "stopped" || status === "paused" ? "aborted" : "failed";
|
|
10534
|
+
}
|
|
10535
|
+
function emitForegroundLifecycle(pi, input) {
|
|
10536
|
+
const payload = { id: input.runId, status: input.status, agent: input.agent, description: input.description, mode: "foreground" };
|
|
10537
|
+
if (input.status !== "started") payload.success = input.status === "completed";
|
|
10538
|
+
if (input.parentWorkflowRunId) payload.parentWorkflowRunId = input.parentWorkflowRunId;
|
|
10539
|
+
if (input.workflowKey) payload.workflowKey = input.workflowKey;
|
|
10540
|
+
try {
|
|
10541
|
+
pi.events.emit(TASK_SUBAGENT_LIFECYCLE_EVENT, payload);
|
|
10542
|
+
} catch (error) {
|
|
10543
|
+
if (!isStaleExtensionContextError2(error)) console.error("Failed to emit foreground lifecycle event:", error);
|
|
10544
|
+
}
|
|
10545
|
+
}
|
|
10510
10546
|
function isStaleExtensionContextError2(error) {
|
|
10511
10547
|
if (!(error instanceof Error)) return false;
|
|
10512
10548
|
return /extension ctx is stale|stale after session replacement or reload/i.test(error.message);
|
|
@@ -11515,6 +11551,10 @@ async function resumeAsyncRun(input) {
|
|
|
11515
11551
|
if (agentConfig.launcher !== void 0 && !lookupRunnerLauncher(input.deps.config.runnerLaunchers, agentConfig.launcher)) {
|
|
11516
11552
|
return { content: [{ type: "text", text: `Cannot resume: run '${target.runId}' uses launcher '${agentConfig.launcher}', which is no longer defined in runnerLaunchers in the user subagent config.` }], isError: true, details: { mode: "management", results: [] } };
|
|
11517
11553
|
}
|
|
11554
|
+
const restoredShareDisabledBy = resolveDisabledFeatureSurface(input.deps.config).params.get("share");
|
|
11555
|
+
if (recoveryDescriptor?.share === true && restoredShareDisabledBy !== void 0) {
|
|
11556
|
+
return { content: [{ type: "text", text: `Cannot resume: run '${target.runId}' was launched with share enabled, which config ${restoredShareDisabledBy} now disables. Re-enable session sharing to resume it.` }], isError: true, details: { mode: "management", results: [] } };
|
|
11557
|
+
}
|
|
11518
11558
|
const runId = randomUUID5();
|
|
11519
11559
|
const topLevelResume = depth === 0 && !inheritedNestedRoute(input.deps) && !input.params.workflowParentRunId;
|
|
11520
11560
|
let activeAsyncCapacity;
|
|
@@ -11752,16 +11792,10 @@ function createForegroundControlNotifier(data, deps) {
|
|
|
11752
11792
|
};
|
|
11753
11793
|
}
|
|
11754
11794
|
function foregroundResultIntercomStatus(result2) {
|
|
11755
|
-
return resolveSubagentResultStatus(
|
|
11756
|
-
|
|
11757
|
-
...result2.acceptance?.status === "rejected" ? { success: false } : {}
|
|
11758
|
-
|
|
11759
|
-
detached: result2.detached,
|
|
11760
|
-
processSignal: result2.processSignal,
|
|
11761
|
-
timedOut: result2.timedOut,
|
|
11762
|
-
stopped: result2.stopped,
|
|
11763
|
-
turnBudgetExceeded: result2.turnBudgetExceeded
|
|
11764
|
-
}));
|
|
11795
|
+
return resolveSubagentResultStatus({
|
|
11796
|
+
...foregroundStatusInput(result2),
|
|
11797
|
+
...result2.acceptance?.status === "rejected" ? { success: false } : {}
|
|
11798
|
+
});
|
|
11765
11799
|
}
|
|
11766
11800
|
function shouldSuppressRoutineResultIntercom(input) {
|
|
11767
11801
|
return input.suppressRoutineResultIntercom === true && input.results.length > 0 && input.results.every((result2) => foregroundResultIntercomStatus(result2) === "completed");
|
|
@@ -12581,6 +12615,9 @@ async function waitForWorkflowAsyncSingleResult(params, launchResult, options) {
|
|
|
12581
12615
|
})).finally(stopListener.remove);
|
|
12582
12616
|
return importWorkflowAwaitedChildResult(completed, { runId: options.runId, asyncDir, resultPath, task: options.task, parentWorkflowRunId: params.workflowParentRunId, details: launchResult.details, state: options.state, pi: options.pi });
|
|
12583
12617
|
}
|
|
12618
|
+
function launchLabel(label) {
|
|
12619
|
+
return typeof label === "string" && label.trim() ? label.trim() : void 0;
|
|
12620
|
+
}
|
|
12584
12621
|
async function runAsyncPath(data, deps) {
|
|
12585
12622
|
const {
|
|
12586
12623
|
params,
|
|
@@ -12736,6 +12773,7 @@ async function runAsyncPath(data, deps) {
|
|
|
12736
12773
|
runFanoutBudget: data.runFanoutBudget,
|
|
12737
12774
|
parentWorkflowRunId: params.workflowParentRunId,
|
|
12738
12775
|
workflowKey: params.workflowKey,
|
|
12776
|
+
label: launchLabel(params.label),
|
|
12739
12777
|
lane: params.lane,
|
|
12740
12778
|
workflowAwaitAsync: params.workflowAwaitAsync
|
|
12741
12779
|
}));
|
|
@@ -12828,6 +12866,8 @@ function appendWorkflowOutputWarning(text, warning) {
|
|
|
12828
12866
|
${warning}` : text;
|
|
12829
12867
|
}
|
|
12830
12868
|
var WORKFLOW_TRACE_ERROR_MAX_CHARS = 500;
|
|
12869
|
+
var WORKFLOW_STATUS_LOCK_RETRY_WINDOW_MS = 6e4;
|
|
12870
|
+
var writeAtomicJsonWithoutLockWaits = createAtomicJsonWriter({ retryRenameErrors: false });
|
|
12831
12871
|
function formatWorkflowResultText(input) {
|
|
12832
12872
|
const traceSection = (error) => input.trace.length > 0 ? [`Call trace:
|
|
12833
12873
|
${input.trace.map((entry) => `${entry.line}${entry.error ? ` \u2014 ${error(entry.error)}` : ""}`).join("\n")}`] : [];
|
|
@@ -13242,7 +13282,7 @@ async function runSinglePath(data, deps) {
|
|
|
13242
13282
|
cwd: singleCwd,
|
|
13243
13283
|
outputPath,
|
|
13244
13284
|
rerun: { params: { ...params, task: authoredTask, async: params.async ?? false } },
|
|
13245
|
-
description: foregroundControl.description,
|
|
13285
|
+
description: launchLabel(params.label) ?? foregroundControl.description,
|
|
13246
13286
|
...modelOverride ? { model: modelOverride } : {},
|
|
13247
13287
|
...thinking ? { thinking } : {},
|
|
13248
13288
|
interrupt: () => {
|
|
@@ -13286,6 +13326,13 @@ async function runSinglePath(data, deps) {
|
|
|
13286
13326
|
const detachedWorkflowChild = params.workflowAwaitDetached === true ? new Promise((resolve9) => {
|
|
13287
13327
|
resolveDetachedWorkflowChild = resolve9;
|
|
13288
13328
|
}) : void 0;
|
|
13329
|
+
const lifecycleBase = {
|
|
13330
|
+
runId,
|
|
13331
|
+
agent: params.agent,
|
|
13332
|
+
description: agentRunDescription(params.agent, agents.find((candidate) => candidate.name === params.agent), launchLabel(params.label)),
|
|
13333
|
+
parentWorkflowRunId: params.workflowParentRunId ?? foregroundControl?.parentWorkflowRunId,
|
|
13334
|
+
workflowKey: params.workflowKey
|
|
13335
|
+
};
|
|
13289
13336
|
try {
|
|
13290
13337
|
const childSessionFile = sessionFileForTask(params.agent, 0, modelOverride, modelOverrideFromParent, modelOrigin);
|
|
13291
13338
|
rememberRunningForegroundRun({
|
|
@@ -13309,6 +13356,7 @@ async function runSinglePath(data, deps) {
|
|
|
13309
13356
|
}),
|
|
13310
13357
|
parentWorkflowRunId: params.workflowParentRunId ?? foregroundControl?.parentWorkflowRunId
|
|
13311
13358
|
});
|
|
13359
|
+
emitForegroundLifecycle(deps.pi, { ...lifecycleBase, status: "started" });
|
|
13312
13360
|
const launched = await runSync(ctx.cwd, agents, params.agent, task, compactOptional({
|
|
13313
13361
|
machine: foregroundMachine,
|
|
13314
13362
|
parentProviderRegistry: ctx.modelRegistry,
|
|
@@ -13329,6 +13377,7 @@ async function runSinglePath(data, deps) {
|
|
|
13329
13377
|
runFanoutBudget: params.runFanoutAdmitted ? data.runFanoutBudget : { ...data.runFanoutBudget, parentPath: `${data.runFanoutBudget.parentPath ? `${data.runFanoutBudget.parentPath}/` : ""}single` },
|
|
13330
13378
|
cwd: singleCwd,
|
|
13331
13379
|
requestedCwd: data.requestedCwd,
|
|
13380
|
+
label: launchLabel(params.label),
|
|
13332
13381
|
signal,
|
|
13333
13382
|
abortedAsStopped: params.workflowParentRunId !== void 0,
|
|
13334
13383
|
interruptSignal: interruptController.signal,
|
|
@@ -13384,6 +13433,7 @@ async function runSinglePath(data, deps) {
|
|
|
13384
13433
|
resolveDetachedWorkflowChild(result2);
|
|
13385
13434
|
return;
|
|
13386
13435
|
}
|
|
13436
|
+
emitForegroundLifecycle(deps.pi, { ...lifecycleBase, status: foregroundLifecycleStatus(foregroundResultIntercomStatus(result2)) });
|
|
13387
13437
|
try {
|
|
13388
13438
|
if (worktreeSetup) {
|
|
13389
13439
|
try {
|
|
@@ -13439,7 +13489,9 @@ async function runSinglePath(data, deps) {
|
|
|
13439
13489
|
};
|
|
13440
13490
|
}
|
|
13441
13491
|
r = launched.detached && detachedWorkflowChild ? await detachedWorkflowChild : launched;
|
|
13492
|
+
if (!r.detached) emitForegroundLifecycle(deps.pi, { ...lifecycleBase, status: foregroundLifecycleStatus(foregroundExecutionStatus(r)) });
|
|
13442
13493
|
} catch (error) {
|
|
13494
|
+
emitForegroundLifecycle(deps.pi, { ...lifecycleBase, status: "failed" });
|
|
13443
13495
|
discardRunningRecord();
|
|
13444
13496
|
await cleanupSingleWorktree();
|
|
13445
13497
|
throw error;
|
|
@@ -13977,6 +14029,9 @@ function prepareWorkflowLaunchParams(workflowDefaults, childParams, parentWorkfl
|
|
|
13977
14029
|
...options.suppressRoutineResultIntercom ? { suppressRoutineResultIntercom: true } : {},
|
|
13978
14030
|
...capabilityCeiling ? { capabilityCeiling } : {}
|
|
13979
14031
|
};
|
|
14032
|
+
const label = typeof childParams.label === "string" ? childParams.label.trim() : "";
|
|
14033
|
+
if (label) launchParams.label = label;
|
|
14034
|
+
else delete launchParams.label;
|
|
13980
14035
|
if (launchParams.extensionBindings !== void 0) launchParams.extensionBindings = normalizeExtensionBindings(launchParams.extensionBindings).value;
|
|
13981
14036
|
const normalizedGate = normalizeGateParams(launchParams);
|
|
13982
14037
|
if (!normalizedGate.ok) throw new Error(normalizedGate.error);
|
|
@@ -14502,10 +14557,34 @@ Parent action: ${STATUS_ACTION}`,
|
|
|
14502
14557
|
const pendingWorkflowChildAnnouncements = /* @__PURE__ */ new Map();
|
|
14503
14558
|
let announcePersistedWorkflowChildren = () => {
|
|
14504
14559
|
};
|
|
14560
|
+
let statusPersistenceDegraded = false;
|
|
14561
|
+
let statusLockedSince;
|
|
14562
|
+
const reportStatusWriteFailure = (error) => {
|
|
14563
|
+
const message = `Failed to persist async workflow state ${statusPath}: ${error instanceof Error ? error.message : String(error)}`;
|
|
14564
|
+
console.error(message, error);
|
|
14565
|
+
if (statusPersistenceDegraded) return;
|
|
14566
|
+
statusPersistenceDegraded = true;
|
|
14567
|
+
try {
|
|
14568
|
+
appendWorkflowEvent({ type: "subagent.workflow.status_write_failed", error: message });
|
|
14569
|
+
} catch (eventError) {
|
|
14570
|
+
console.error(`Failed to record degraded status persistence for '${statusPath}':`, eventError);
|
|
14571
|
+
}
|
|
14572
|
+
};
|
|
14573
|
+
const shouldDeferRunWrite = (error, filePath) => {
|
|
14574
|
+
if (isStorageCapacityError(error)) return true;
|
|
14575
|
+
if (filePath !== statusPath || !isRetryableFileSystemError(error)) return false;
|
|
14576
|
+
statusLockedSince ??= Date.now();
|
|
14577
|
+
if (Date.now() - statusLockedSince >= WORKFLOW_STATUS_LOCK_RETRY_WINDOW_MS) return false;
|
|
14578
|
+
if (!statusPersistenceDegraded) reportStatusWriteFailure(error);
|
|
14579
|
+
return true;
|
|
14580
|
+
};
|
|
14505
14581
|
const runPersistence = createCapacityResilientJsonWriter({
|
|
14506
14582
|
keepAlive: true,
|
|
14583
|
+
shouldDefer: shouldDeferRunWrite,
|
|
14507
14584
|
onSuccess: (filePath, payload) => {
|
|
14508
14585
|
if (filePath === statusPath) {
|
|
14586
|
+
statusPersistenceDegraded = false;
|
|
14587
|
+
statusLockedSince = void 0;
|
|
14509
14588
|
announcePersistedWorkflowChildren();
|
|
14510
14589
|
queueActiveRunIndex(payload);
|
|
14511
14590
|
}
|
|
@@ -14515,11 +14594,11 @@ Parent action: ${STATUS_ACTION}`,
|
|
|
14515
14594
|
if (filePath === resultPath) settleResultPublication?.(reportResultWriteFailure(error));
|
|
14516
14595
|
else console.error(`Failed to persist async workflow state '${filePath}':`, error);
|
|
14517
14596
|
},
|
|
14518
|
-
write: (filePath, payload) => filePath === resultPath ? writeAsyncResultFile(filePath, payload) : writeAtomicJson(filePath, payload)
|
|
14597
|
+
write: (filePath, payload) => filePath === resultPath ? writeAsyncResultFile(filePath, payload) : writeAtomicJson(filePath, payload),
|
|
14598
|
+
retryWrite: (filePath, payload) => filePath === resultPath ? writeAsyncResultFile(filePath, payload) : writeAtomicJsonWithoutLockWaits(filePath, payload)
|
|
14519
14599
|
});
|
|
14520
14600
|
let initialPersistenceComplete = false;
|
|
14521
14601
|
let persistClosed = false;
|
|
14522
|
-
let statusPersistenceDegraded = false;
|
|
14523
14602
|
const persist = (options = {}) => {
|
|
14524
14603
|
if (persistClosed) return;
|
|
14525
14604
|
const liveJob = deps2.state.asyncJobs.get(workflowRunId);
|
|
@@ -14534,18 +14613,8 @@ Parent action: ${STATUS_ACTION}`,
|
|
|
14534
14613
|
} else if (options.tolerateStatusWriteFailure) {
|
|
14535
14614
|
try {
|
|
14536
14615
|
runPersistence.write(statusPath, { ...status });
|
|
14537
|
-
if (runPersistence.pendingCount() === 0) statusPersistenceDegraded = false;
|
|
14538
14616
|
} catch (error) {
|
|
14539
|
-
|
|
14540
|
-
console.error(message, error);
|
|
14541
|
-
if (!statusPersistenceDegraded) {
|
|
14542
|
-
statusPersistenceDegraded = true;
|
|
14543
|
-
try {
|
|
14544
|
-
appendWorkflowEvent({ type: "subagent.workflow.status_write_failed", error: message });
|
|
14545
|
-
} catch (eventError) {
|
|
14546
|
-
console.error(`Failed to record degraded status persistence for '${statusPath}':`, eventError);
|
|
14547
|
-
}
|
|
14548
|
-
}
|
|
14617
|
+
reportStatusWriteFailure(error);
|
|
14549
14618
|
}
|
|
14550
14619
|
} else {
|
|
14551
14620
|
runPersistence.write(statusPath, { ...status });
|
|
@@ -14764,7 +14833,7 @@ Parent action: ${STATUS_ACTION}`,
|
|
|
14764
14833
|
} catch (error) {
|
|
14765
14834
|
appendWorkflowEvent({ type: "subagent.workflow.steer_inbox_unavailable", phase: "close", error: error instanceof Error ? error.message : String(error) });
|
|
14766
14835
|
}
|
|
14767
|
-
persist();
|
|
14836
|
+
persist({ tolerateStatusWriteFailure: true });
|
|
14768
14837
|
};
|
|
14769
14838
|
void Promise.resolve().then(async () => {
|
|
14770
14839
|
const workflowDeadlineAt2 = timeout === void 0 ? void 0 : Date.now() + timeout;
|
|
@@ -15196,7 +15265,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15196
15265
|
}
|
|
15197
15266
|
if (!writeWorkflowResult({ id: workflowRunId, runId: workflowRunId, toolCallId, agent: "workflow", mode: "workflow", success: true, state: "complete", summary: resultSummary, output: resultSummary, workflowChildren, results: workflowResultChildren2(workflow.children, status, false), workflow: status.workflow, ...workflowCapabilityCeiling2 ? { admissionCapabilityCeiling: workflowCapabilityCeiling2 } : {}, ...workflowReceipt ? { workflowReceipt } : {}, asyncDir, cwd: workflowCwd, sessionId: currentSessionId, completionOwnerId, ...requestParams.scheduleOrigin ? { scheduleOrigin: requestParams.scheduleOrigin } : {}, timestamp: Date.now(), durationMs: Date.now() - startedAt })) return;
|
|
15198
15267
|
if (pendingResultPublication && !await pendingResultPublication) return;
|
|
15199
|
-
persist();
|
|
15268
|
+
persist({ tolerateStatusWriteFailure: true });
|
|
15200
15269
|
deps2.refreshResultDelivery?.();
|
|
15201
15270
|
persistClosed = true;
|
|
15202
15271
|
appendWorkflowEvent({ type: "subagent.workflow.completed", state: status.state, ...workflowArgsDigest ? { argsDigest: workflowArgsDigest } : {}, ...status.error ? { error: status.error } : {} });
|
|
@@ -15247,7 +15316,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15247
15316
|
}
|
|
15248
15317
|
if (!writeWorkflowResult({ id: workflowRunId, runId: workflowRunId, toolCallId, agent: "workflow", mode: "workflow", success: status.state === "complete", state: status.state, summary: resultSummary, error: status.state === "complete" ? void 0 : status.error, stopped: status.stopped, activityState: status.activityState, workflowChildren, ...terminalOutcome ? { terminalOutcome } : {}, results: workflowResultChildren2(partial.children, status, true), workflow: status.workflow, ...workflowCapabilityCeiling2 ? { admissionCapabilityCeiling: workflowCapabilityCeiling2 } : {}, ...workflowReceipt ? { workflowReceipt } : {}, asyncDir, cwd: workflowCwd, sessionId: currentSessionId, completionOwnerId, ...requestParams.scheduleOrigin ? { scheduleOrigin: requestParams.scheduleOrigin } : {}, timestamp: Date.now(), durationMs: Date.now() - startedAt })) return;
|
|
15249
15318
|
if (pendingResultPublication && !await pendingResultPublication) return;
|
|
15250
|
-
persist();
|
|
15319
|
+
persist({ tolerateStatusWriteFailure: true });
|
|
15251
15320
|
deps2.refreshResultDelivery?.();
|
|
15252
15321
|
persistClosed = true;
|
|
15253
15322
|
appendWorkflowEvent({ type: "subagent.workflow.completed", state: status.state, ...workflowArgsDigest ? { argsDigest: workflowArgsDigest } : {}, ...terminalOutcome ? { terminalOutcome } : {}, ...status.error ? { error: status.error } : {}, ...status.activityState ? { activityState: status.activityState } : {} });
|
|
@@ -16411,7 +16480,7 @@ ${item.text}` } : item)
|
|
|
16411
16480
|
if (error instanceof RunFanoutLimitError) return runFanoutErrorResult(error, foregroundMode);
|
|
16412
16481
|
return buildRequestedModeError(effectiveParams, error instanceof Error ? error.message : String(error));
|
|
16413
16482
|
}
|
|
16414
|
-
const nestedRoute = inheritedNestedRouteValue ?? createNestedRoute(runId);
|
|
16483
|
+
const nestedRoute = inheritedNestedRouteValue ?? createNestedRoute(effectiveAsync ? asyncRunId : runId);
|
|
16415
16484
|
const artifactConfig = omitUndefinedProperties({
|
|
16416
16485
|
...DEFAULT_ARTIFACT_CONFIG,
|
|
16417
16486
|
enabled: effectiveParams.artifacts !== false,
|
|
@@ -16705,7 +16774,7 @@ ${item.text}` } : item)
|
|
|
16705
16774
|
}
|
|
16706
16775
|
if (workflowLaunchObserver) {
|
|
16707
16776
|
const singleTask = hasTasks && effectiveParams.tasks?.length === 1 ? effectiveParams.tasks[0] : void 0;
|
|
16708
|
-
const singleSessionName = hasSingle ? deriveChildSessionName({ agent: effectiveParams.agent, task: effectiveParams.task }) : singleTask ? deriveChildSessionName({ agent: singleTask.agent, task: singleTask.task }) : void 0;
|
|
16777
|
+
const singleSessionName = hasSingle ? deriveChildSessionName({ agent: effectiveParams.agent, task: effectiveParams.task, label: effectiveParams.label }) : singleTask ? deriveChildSessionName({ agent: singleTask.agent, task: singleTask.task }) : void 0;
|
|
16709
16778
|
const launch = hasSingle ? { agent: effectiveParams.agent, ...singleSessionName ? { sessionName: singleSessionName } : {}, sessionFile: childSessionFileForTask(effectiveParams.agent, 0, effectiveParams.model), async: effectiveAsync, runId: effectiveAsync ? asyncRunId : runId } : singleTask ? { agent: singleTask.agent, ...singleSessionName ? { sessionName: singleSessionName } : {}, sessionFile: childSessionFileForTask(singleTask.agent, 0, singleTask.model), async: effectiveAsync, runId: effectiveAsync ? asyncRunId : runId } : void 0;
|
|
16710
16779
|
if (launch) {
|
|
16711
16780
|
workflowLaunchObservers.delete(params);
|