@vicary/pi-subagents 0.88.0 → 0.89.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 +54 -1
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-6EUQPQY7.js → chunk-443LPCRI.js} +5 -5
- package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
- package/bundle/{chunk-CKLZ5FGU.js → chunk-4ALRHKGE.js} +1 -1
- package/bundle/{chunk-SVIXQDIV.js → chunk-6JD4XCA4.js} +77 -19
- package/bundle/{chunk-XZXYPZUT.js → chunk-7JLNWAMO.js} +54 -36
- package/bundle/{chunk-RHYVKQQL.js → chunk-7W2IQFP4.js} +4 -4
- package/bundle/{chunk-W6HIYD2Z.js → chunk-A3INCQ6Z.js} +1 -1
- package/bundle/{chunk-JYHTDTOZ.js → chunk-CFIYO2IV.js} +5 -5
- package/bundle/{chunk-CYKNHFXB.js → chunk-EPMRDKQT.js} +1 -1
- package/bundle/{chunk-6PR44R7E.js → chunk-ETDE2VYK.js} +2 -2
- package/bundle/{chunk-4MVDMA5C.js → chunk-GHJ6BH5U.js} +13 -7
- package/bundle/{chunk-IZEKQEY4.js → chunk-HSHLPYCQ.js} +27 -10
- package/bundle/{chunk-3MFYKBKI.js → chunk-HZDLR73C.js} +4 -4
- package/bundle/{chunk-2DIEL4WG.js → chunk-JFACGAJT.js} +2 -2
- package/bundle/{chunk-L4YY2TOE.js → chunk-JRO2CU4D.js} +1 -1
- package/bundle/{chunk-KXW62VBU.js → chunk-KOLLMZ2X.js} +1 -1
- package/bundle/{chunk-TDJKY2NE.js → chunk-LEPIY76E.js} +34 -5
- package/bundle/{chunk-BW5JLKIU.js → chunk-MJHQIUU7.js} +68 -41
- package/bundle/{chunk-47ZN7NKR.js → chunk-NONHDYXE.js} +1 -1
- package/bundle/{chunk-PJSOS2Q4.js → chunk-NQ26PJSQ.js} +96 -96
- package/bundle/{chunk-AOSILI5R.js → chunk-OVBUEVOT.js} +95 -49
- package/bundle/{chunk-NVGQE2H2.js → chunk-PFZZMVD5.js} +75 -32
- package/bundle/{chunk-YDZ7BZD5.js → chunk-S77ZKDLS.js} +1 -1
- package/bundle/{chunk-3DT5X2QC.js → chunk-SLLZJ5EC.js} +50 -18
- package/bundle/{chunk-V7SZMS6W.js → chunk-SWL2EITY.js} +2 -2
- package/bundle/{chunk-XIA5GSEU.js → chunk-UQT2EQ4U.js} +2 -2
- package/bundle/{chunk-YZPVALSQ.js → chunk-WW6GQBBS.js} +4 -4
- package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
- package/bundle/{chunk-GDR2ILWY.js → chunk-ZSCIHMUI.js} +50 -22
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +2 -2
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +9 -9
- package/bundle/project-panes.js +3 -3
- package/bundle/required-child-extensions.js +1 -1
- package/docs/agents.md +14 -6
- package/docs/configuration.md +2 -0
- package/docs/extension-api.md +1 -1
- package/docs/tool-reference.md +1 -1
- package/docs/workflows.md +8 -4
- package/package.json +2 -2
- package/src/extension/herdr-pi-bridge.js +78 -22
- package/src/extension/index.d.ts +1 -1
- package/src/extension/index.js +43 -20
- package/src/extension/schemas.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +6 -2
- package/src/extension/subagent-launch-tool.js +13 -9
- package/src/extension/subagent-options.js +5 -0
- package/src/intercom/result-intercom.js +3 -2
- package/src/runs/background/notify.d.ts +3 -0
- package/src/runs/background/notify.js +7 -2
- package/src/runs/background/run-status.js +3 -2
- package/src/runs/background/runner-child-launch.js +1 -0
- package/src/runs/background/stale-run-reconciler.js +17 -8
- package/src/runs/background/subagent-runner.js +11 -8
- package/src/runs/foreground/execution.js +8 -7
- package/src/runs/foreground/subagent-executor.js +42 -11
- package/src/runs/shared/child-launch.d.ts +2 -0
- package/src/runs/shared/child-launch.js +7 -4
- package/src/runs/shared/child-session.d.ts +3 -2
- package/src/runs/shared/child-session.js +3 -27
- package/src/runs/shared/herdr-connection.d.ts +6 -0
- package/src/runs/shared/herdr-connection.js +11 -1
- package/src/runs/shared/herdr-machine.d.ts +2 -2
- package/src/runs/shared/herdr-machine.js +47 -22
- package/src/runs/shared/herdr-pane-host.d.ts +7 -19
- package/src/runs/shared/herdr-pane-host.js +48 -33
- package/src/runs/shared/herdr-pi-protocol.d.ts +1 -0
- package/src/runs/shared/herdr-pi-protocol.js +3 -2
- package/src/runs/shared/herdr-placed-run.d.ts +2 -12
- package/src/runs/shared/herdr-placed-run.js +10 -8
- package/src/runs/shared/kept-branch-text.d.ts +8 -0
- package/src/runs/shared/kept-branch-text.js +24 -0
- package/src/runs/shared/local-machine-access.d.ts +4 -1
- package/src/runs/shared/local-machine-access.js +6 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +5 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +5 -4
- package/src/runs/shared/mutation-evidence.d.ts +7 -1
- package/src/runs/shared/mutation-evidence.js +18 -2
- package/src/runs/shared/parallel-handoff.js +19 -7
- package/src/runs/shared/placed-run-owner.d.ts +4 -2
- package/src/runs/shared/placed-run-owner.js +15 -7
- package/src/runs/shared/rex-machine.d.ts +7 -3
- package/src/runs/shared/rex-machine.js +12 -9
- package/src/runs/shared/rex-pane-host.js +7 -27
- package/src/runs/shared/single-output.js +2 -2
- package/src/runs/shared/subagent-prompt-runtime.js +33 -0
- package/src/runs/shared/tool-availability.d.ts +4 -0
- package/src/runs/shared/tool-availability.js +7 -0
- package/src/runs/shared/worktree-cleanup-plan.js +2 -2
- package/src/runs/shared/worktree.d.ts +4 -14
- package/src/runs/shared/worktree.js +38 -8
- package/src/shared/compaction-interruption.d.ts +9 -0
- package/src/shared/compaction-interruption.js +47 -0
- package/src/shared/parent-wake.d.ts +3 -2
- package/src/shared/parent-wake.js +14 -3
- package/src/shared/required-child-extensions.d.ts +2 -0
- package/src/shared/required-child-extensions.js +27 -0
- package/src/shared/types.d.ts +26 -2
- package/src/tui/fleet.d.ts +7 -2
- package/src/tui/fleet.js +22 -0
- package/src/workflows/workflow-child-summary.d.ts +2 -1
- package/src/workflows/workflow-child-summary.js +14 -6
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
resolveCurrentSessionId,
|
|
15
15
|
resolveWatchdogReviewModel,
|
|
16
16
|
startWatchdogDiffBaselineCapture
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-CFIYO2IV.js";
|
|
18
18
|
import {
|
|
19
19
|
agentStreamOptions,
|
|
20
20
|
opencodeSessionHeaders
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-6JD4XCA4.js";
|
|
22
22
|
import {
|
|
23
23
|
registerNativeSupervisorClient
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-EPMRDKQT.js";
|
|
25
25
|
import {
|
|
26
26
|
MODEL_ONLY_TOOL
|
|
27
27
|
} from "./chunk-HXRB42AF.js";
|
|
28
28
|
import {
|
|
29
29
|
inheritedNestedRouteOf
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-SLLZJ5EC.js";
|
|
31
31
|
import {
|
|
32
32
|
CHILD_WATCHDOG_STATUS_EVENT,
|
|
33
33
|
DEFAULT_WAIT_TOOL_NAME,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
toolBudgetSoftNudge,
|
|
47
47
|
validateAcceptanceReport,
|
|
48
48
|
validateStructuredOutputValue
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
50
50
|
import {
|
|
51
51
|
INTERCOM_SESSION_IDENTITY_EVENT
|
|
52
52
|
} from "./chunk-JEZOSEWG.js";
|
|
@@ -84,6 +84,13 @@ function projectRuntimeAcknowledgedExtensions(ids) {
|
|
|
84
84
|
// src/runs/shared/tool-availability.ts
|
|
85
85
|
function formatChildToolDiagnostic(diagnostic, options = {}) {
|
|
86
86
|
const subject = diagnostic.agent ? `Agent '${diagnostic.agent}'` : "Subagent";
|
|
87
|
+
if (diagnostic.undeclared?.length) {
|
|
88
|
+
const uncallable = diagnostic.uncallable?.length ? ` and added ${diagnostic.uncallable.join(", ")}, which this child cannot call` : "";
|
|
89
|
+
return [
|
|
90
|
+
`${subject} declares tools: ${diagnostic.required.join(", ")}, but an extension loaded in this child replaced the tools sent to the model: it left out ${diagnostic.undeclared.join(", ")}${uncallable}.`,
|
|
91
|
+
"The `tools` field is a strict allowlist. Set `extensions: []` or list only the extensions this child needs, or omit `tools` to use that extension's tool surface."
|
|
92
|
+
].join("\n");
|
|
93
|
+
}
|
|
87
94
|
if (options.host === "parent") {
|
|
88
95
|
return [
|
|
89
96
|
`${subject} ran as a foreground child, which never loads the parent's ambient extensions, and these child tools were unavailable: ${diagnostic.missing.join(", ")}.`,
|
|
@@ -533,7 +540,29 @@ function filterChildPromptOptions(options, inherited) {
|
|
|
533
540
|
function rewritesChildPrompt(config) {
|
|
534
541
|
return config.inheritProjectContext !== void 0 || config.inheritGlobalContext !== void 0 || config.inheritSkills !== void 0 || Boolean(config.fanoutChild);
|
|
535
542
|
}
|
|
543
|
+
function registerDeclaredToolCheck(pi, config, required) {
|
|
544
|
+
pi.on("context_with_system", (event, ctx) => {
|
|
545
|
+
const declared = new Set(getCurrentTools(event.messages).map((tool) => tool.name));
|
|
546
|
+
if (required.every((name) => declared.has(name))) return void 0;
|
|
547
|
+
const registered = new Set(pi.getAllTools().map((tool) => tool.name));
|
|
548
|
+
const undeclared = required.filter((name) => registered.has(name) && !declared.has(name));
|
|
549
|
+
if (undeclared.length === 0) return void 0;
|
|
550
|
+
const active = new Set(pi.getActiveTools());
|
|
551
|
+
const uncallable = config.forkCacheKey ? [] : [...declared].filter((name) => !active.has(name));
|
|
552
|
+
config.toolDiagnostic?.({
|
|
553
|
+
...config.agent ? { agent: config.agent } : {},
|
|
554
|
+
required: [...required],
|
|
555
|
+
available: [...registered],
|
|
556
|
+
missing: [],
|
|
557
|
+
undeclared,
|
|
558
|
+
...uncallable.length > 0 ? { uncallable } : {}
|
|
559
|
+
});
|
|
560
|
+
ctx.abort();
|
|
561
|
+
return void 0;
|
|
562
|
+
});
|
|
563
|
+
}
|
|
536
564
|
function registerSubagentPromptBoundary(pi, config) {
|
|
565
|
+
if (config.requiredTools) registerDeclaredToolCheck(pi, config, config.requiredTools);
|
|
537
566
|
if (!rewritesChildPrompt(config)) return;
|
|
538
567
|
if (config.forkCacheKey) return;
|
|
539
568
|
pi.on("before_agent_start", (event) => {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
projectRuntimeAcknowledgedExtensions,
|
|
4
4
|
registerSubagentPromptBoundary,
|
|
5
5
|
registerSubagentPromptRuntime
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LEPIY76E.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-443LPCRI.js";
|
|
29
29
|
import {
|
|
30
30
|
PLACED_RESTORE_UNSUPPORTED,
|
|
31
31
|
formatHerdrMachineRunnerUnsupported,
|
|
32
32
|
resolveMachinePlacement
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ZSCIHMUI.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-
|
|
122
|
+
} from "./chunk-OVBUEVOT.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-
|
|
135
|
+
} from "./chunk-CFIYO2IV.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-
|
|
148
|
+
} from "./chunk-7W2IQFP4.js";
|
|
149
149
|
import {
|
|
150
150
|
RunFanoutLimitError,
|
|
151
151
|
annotateWorkflowPreflightTrace,
|
|
@@ -165,6 +165,7 @@ import {
|
|
|
165
165
|
formatAsyncRunProgressLabel,
|
|
166
166
|
formatNestedRunStatusLines,
|
|
167
167
|
formatParallelHandoffError,
|
|
168
|
+
formatParallelHandoffLines,
|
|
168
169
|
formatParallelHandoffReference,
|
|
169
170
|
formatRunFanoutBudget,
|
|
170
171
|
formatStoredParallelHandoffCleanup,
|
|
@@ -191,6 +192,8 @@ import {
|
|
|
191
192
|
recordParallelHandoffMerge,
|
|
192
193
|
recordParallelHandoffSupersession,
|
|
193
194
|
recoveryDescriptorPath,
|
|
195
|
+
remoteMutationEvidence,
|
|
196
|
+
remoteMutationSnapshot,
|
|
194
197
|
resolveAsyncResumeTarget,
|
|
195
198
|
resolveAsyncRunLocation,
|
|
196
199
|
resolveAsyncStatusChild,
|
|
@@ -206,12 +209,12 @@ import {
|
|
|
206
209
|
writeRunFanoutBudgetDescriptor,
|
|
207
210
|
writeWorkflowLaunchRecord,
|
|
208
211
|
writeWorktreeSetupHandoff
|
|
209
|
-
} from "./chunk-
|
|
212
|
+
} from "./chunk-6JD4XCA4.js";
|
|
210
213
|
import {
|
|
211
214
|
NATIVE_SUPERVISOR_TOOL_NAME,
|
|
212
215
|
createNativeSupervisorChannel,
|
|
213
216
|
resolveSupervisorChannelDir
|
|
214
|
-
} from "./chunk-
|
|
217
|
+
} from "./chunk-EPMRDKQT.js";
|
|
215
218
|
import {
|
|
216
219
|
MODEL_ONLY_TOOL,
|
|
217
220
|
inheritedSessionIds,
|
|
@@ -234,10 +237,10 @@ import {
|
|
|
234
237
|
canPreferFork,
|
|
235
238
|
createForkContextResolver,
|
|
236
239
|
resolveSubagentLaunchContext
|
|
237
|
-
} from "./chunk-
|
|
240
|
+
} from "./chunk-SWL2EITY.js";
|
|
238
241
|
import {
|
|
239
242
|
handleRefinementAction
|
|
240
|
-
} from "./chunk-
|
|
243
|
+
} from "./chunk-UQT2EQ4U.js";
|
|
241
244
|
import {
|
|
242
245
|
ActiveAsyncCapacityError,
|
|
243
246
|
acquireActiveAsyncCapacity,
|
|
@@ -253,7 +256,7 @@ import {
|
|
|
253
256
|
resolveDisabledFeatureSurface,
|
|
254
257
|
resolveMaxActiveAsyncRunsPerSession,
|
|
255
258
|
transferActiveAsyncCapacity
|
|
256
|
-
} from "./chunk-
|
|
259
|
+
} from "./chunk-ETDE2VYK.js";
|
|
257
260
|
import {
|
|
258
261
|
DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS,
|
|
259
262
|
MACHINE_DIFF_OPTIONS,
|
|
@@ -290,6 +293,7 @@ import {
|
|
|
290
293
|
inheritedNestedParentAddressOf,
|
|
291
294
|
inheritedNestedRouteOf,
|
|
292
295
|
initializeProcessTerminal,
|
|
296
|
+
isWorktreeCleanupTaskDone,
|
|
293
297
|
lookupRunnerLauncher,
|
|
294
298
|
missionAcceptanceStatus,
|
|
295
299
|
nestedResultsPath,
|
|
@@ -339,7 +343,7 @@ import {
|
|
|
339
343
|
writeNestedControlRequest,
|
|
340
344
|
writeNestedControlResult,
|
|
341
345
|
writeNestedEvent
|
|
342
|
-
} from "./chunk-
|
|
346
|
+
} from "./chunk-SLLZJ5EC.js";
|
|
343
347
|
import {
|
|
344
348
|
closeSteerInbox,
|
|
345
349
|
consumeSteerRequests,
|
|
@@ -347,7 +351,7 @@ import {
|
|
|
347
351
|
readRevivalBriefs,
|
|
348
352
|
requestAsyncSteer,
|
|
349
353
|
watchAsyncControlInbox
|
|
350
|
-
} from "./chunk-
|
|
354
|
+
} from "./chunk-A3INCQ6Z.js";
|
|
351
355
|
import "./chunk-NIXWDZZV.js";
|
|
352
356
|
import {
|
|
353
357
|
INTERCOM_BRIDGE_MARKER,
|
|
@@ -356,7 +360,7 @@ import {
|
|
|
356
360
|
resolveIntercomBridge,
|
|
357
361
|
resolveIntercomSessionTarget,
|
|
358
362
|
resolveSubagentIntercomTarget
|
|
359
|
-
} from "./chunk-
|
|
363
|
+
} from "./chunk-NONHDYXE.js";
|
|
360
364
|
import {
|
|
361
365
|
agentDefinitionDigest,
|
|
362
366
|
resolveLaunchBinding,
|
|
@@ -371,18 +375,19 @@ import {
|
|
|
371
375
|
resolvePiLaunchToolPlan,
|
|
372
376
|
resolveRuntimeModulePath,
|
|
373
377
|
supervisorChannelDir
|
|
374
|
-
} from "./chunk-
|
|
378
|
+
} from "./chunk-HZDLR73C.js";
|
|
375
379
|
import {
|
|
376
380
|
assertRequiredChildExtensionsAdmitted,
|
|
381
|
+
createRequiredChildExtensionIdentity,
|
|
377
382
|
hasMandatoryRequiredChildExtensions,
|
|
378
383
|
readRetainedRequiredChildExtensions,
|
|
379
384
|
resolveRequiredChildExtensions,
|
|
380
385
|
writeRetainedRequiredChildExtensions
|
|
381
|
-
} from "./chunk-
|
|
386
|
+
} from "./chunk-YARY7JWU.js";
|
|
382
387
|
import {
|
|
383
388
|
HERDR_PROJECT_PANE_ACTIONS,
|
|
384
389
|
handleHerdrProjectPaneAction
|
|
385
|
-
} from "./chunk-
|
|
390
|
+
} from "./chunk-JFACGAJT.js";
|
|
386
391
|
import "./chunk-7J4ZXMY7.js";
|
|
387
392
|
import {
|
|
388
393
|
PROJECT_SUBAGENTS_RELATIVE_DIR,
|
|
@@ -396,12 +401,12 @@ import {
|
|
|
396
401
|
missingForkCopyNote,
|
|
397
402
|
writeArtifact,
|
|
398
403
|
writeMetadata
|
|
399
|
-
} from "./chunk-
|
|
404
|
+
} from "./chunk-S77ZKDLS.js";
|
|
400
405
|
import "./chunk-XA3DY6UG.js";
|
|
401
406
|
import {
|
|
402
407
|
getExternalJobProvider
|
|
403
408
|
} from "./chunk-YYREO77V.js";
|
|
404
|
-
import "./chunk-
|
|
409
|
+
import "./chunk-KOLLMZ2X.js";
|
|
405
410
|
import {
|
|
406
411
|
ChainOutputValidationError,
|
|
407
412
|
DEFAULT_WAIT_TOOL_NAME,
|
|
@@ -448,6 +453,7 @@ import {
|
|
|
448
453
|
discoverAgentsAll,
|
|
449
454
|
discoverAvailableSkills,
|
|
450
455
|
editDistance,
|
|
456
|
+
editsLocalDisk,
|
|
451
457
|
encodeExtensionBindings,
|
|
452
458
|
evaluateAcceptance,
|
|
453
459
|
externalCliReceiptMetadata,
|
|
@@ -485,7 +491,6 @@ import {
|
|
|
485
491
|
isDynamicRunnerGroup,
|
|
486
492
|
isParallelGroup,
|
|
487
493
|
isParallelStep,
|
|
488
|
-
isRexLocalMachine,
|
|
489
494
|
isSettlementFatalOutputError,
|
|
490
495
|
isStorageCapacityError,
|
|
491
496
|
isToolBudgetBlockedMessage,
|
|
@@ -555,7 +560,7 @@ import {
|
|
|
555
560
|
writeAtomicJson,
|
|
556
561
|
writeInitialProgressFile,
|
|
557
562
|
writePrivateAtomicJson
|
|
558
|
-
} from "./chunk-
|
|
563
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
559
564
|
import {
|
|
560
565
|
CHAIN_RUNS_DIR,
|
|
561
566
|
DEFAULT_ARTIFACT_CONFIG,
|
|
@@ -1226,7 +1231,8 @@ function childProcessEnv(input, toolPlan) {
|
|
|
1226
1231
|
else if (!toolPlan.capabilityCeiling && input.mcpDirectTools?.length) env[MCP_DIRECT_TOOLS_ENV] = input.mcpDirectTools.join(",");
|
|
1227
1232
|
else if (toolPlan.capabilityCeiling && toolPlan.effectiveMcpSelections.length && !toolPlan.capabilityCeiling.denyExtensions) {
|
|
1228
1233
|
env[MCP_DIRECT_TOOLS_ENV] = toolPlan.effectiveMcpSelections.map((selection) => selection.selector).join(",");
|
|
1229
|
-
} else env[MCP_DIRECT_TOOLS_ENV] =
|
|
1234
|
+
} else if (input.tools === void 0 && !toolPlan.capabilityCeiling) env[MCP_DIRECT_TOOLS_ENV] = void 0;
|
|
1235
|
+
else env[MCP_DIRECT_TOOLS_ENV] = "__none__";
|
|
1230
1236
|
return env;
|
|
1231
1237
|
}
|
|
1232
1238
|
function childStorage(input) {
|
|
@@ -1268,7 +1274,8 @@ function buildInProcessChildLaunch(input) {
|
|
|
1268
1274
|
runtimeSnapshotHost: input.runtimeSnapshotHost
|
|
1269
1275
|
});
|
|
1270
1276
|
if (input.host === "parent" && input.runtimeSnapshotHost && toolPlan.builtinMcpTools?.length) {
|
|
1271
|
-
const
|
|
1277
|
+
const requiredExtensionIdentity = createRequiredChildExtensionIdentity(toolPlan.requiredExtensions.map(({ path: path19 }) => path19));
|
|
1278
|
+
const servers = extensionOnlyMcpServers(toolPlan.effectiveMcpSelections, input.runtimeSnapshotHost, input.cwd, input.projectTrusted !== false, (extensionPath) => requiredExtensionIdentity(extensionPath) !== void 0);
|
|
1272
1279
|
if (servers.length) throw new Error(`Agent '${input.childAgentName}' selects MCP tools from servers that extensions registered (${servers.join(", ")}). Only background children (async: true) load those extensions; run the agent in the background or add the server to the global mcp.json or a trusted project's .pi/mcp.json.`);
|
|
1273
1280
|
}
|
|
1274
1281
|
toolPlan.capabilityCeiling = intersectSubagentCapabilityCeilings(toolPlan.capabilityCeiling, agentCapabilityCeiling);
|
|
@@ -1367,7 +1374,7 @@ ${input.systemPrompt}` : void 0;
|
|
|
1367
1374
|
cwd: input.cwd,
|
|
1368
1375
|
...input.machine ? { machine: input.machine } : {},
|
|
1369
1376
|
...input.projectTrusted !== void 0 ? { projectTrusted: input.projectTrusted } : {},
|
|
1370
|
-
...input.machine ? { remoteResources: { agent: input.childAgentName, ...input.remoteSkillNames ? { skills: input.remoteSkillNames } : {}, ...input.remoteReads !== void 0 ? { reads: input.remoteReads } : {}, ...toolPlan.explicitToolAllowlist ? { toolCeiling: [...toolPlan.effectiveToolAllowlist] } : toolPlan.capabilityCeiling?.allowedTools ? { toolCeiling: [...toolPlan.capabilityCeiling.allowedTools] } : {} } } : {},
|
|
1377
|
+
...input.machine ? { remoteResources: { agent: input.childAgentName, ...input.remoteSkillNames ? { skills: input.remoteSkillNames } : {}, ...input.remoteReads !== void 0 ? { reads: input.remoteReads } : {}, ...toolPlan.explicitToolAllowlist ? { toolCeiling: [...toolPlan.effectiveToolAllowlist] } : toolPlan.capabilityCeiling?.allowedTools ? { toolCeiling: [...toolPlan.capabilityCeiling.allowedTools] } : {}, ...input.acceptancePrompt ? { acceptancePrompt: input.acceptancePrompt } : {} } } : {},
|
|
1371
1378
|
storage: childStorage(input),
|
|
1372
1379
|
...input.parentSessionFile ? { parentSessionFile: input.parentSessionFile } : {},
|
|
1373
1380
|
...input.model ? { model: input.model } : {},
|
|
@@ -5389,6 +5396,7 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
|
|
|
5389
5396
|
machine: options.machine,
|
|
5390
5397
|
remoteSkillNames: options.skills ?? agent.skills,
|
|
5391
5398
|
remoteReads: options.remoteReads,
|
|
5399
|
+
acceptancePrompt: shared.acceptancePrompt,
|
|
5392
5400
|
extensionBindings: options.extensionBindings,
|
|
5393
5401
|
requiredExtensions: options.requiredExtensions,
|
|
5394
5402
|
sessionEnabled: shared.sessionEnabled,
|
|
@@ -5507,6 +5515,7 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
|
|
|
5507
5515
|
index: options.index ?? 0,
|
|
5508
5516
|
agent: agent.name,
|
|
5509
5517
|
...childSessionName ? { sessionName: childSessionName } : {},
|
|
5518
|
+
...options.sessionFile ? { sessionFile: options.sessionFile } : {},
|
|
5510
5519
|
status: "running",
|
|
5511
5520
|
task,
|
|
5512
5521
|
skills: shared.resolvedSkillNames,
|
|
@@ -5546,8 +5555,8 @@ ${shared.acceptancePrompt}` : shared.systemPrompt,
|
|
|
5546
5555
|
};
|
|
5547
5556
|
return result2;
|
|
5548
5557
|
}
|
|
5549
|
-
const mutationCwd =
|
|
5550
|
-
const mutationSnapshot = options.machine && !
|
|
5558
|
+
const mutationCwd = editsLocalDisk(options.machine) ? options.machine.cwd : options.cwd ?? runtimeCwd;
|
|
5559
|
+
const mutationSnapshot = options.machine && !editsLocalDisk(options.machine) ? remoteMutationSnapshot(mutationCwd) : snapshotTrackedMutations(mutationCwd);
|
|
5551
5560
|
let structuredOutputToolInvoked = false;
|
|
5552
5561
|
let structuredOutputMessageStartIndex;
|
|
5553
5562
|
let toolAvailabilityError;
|
|
@@ -6495,8 +6504,7 @@ ${formatInheritedProviderDiagnostic({ agent: agent.name, model: launch.session.m
|
|
|
6495
6504
|
tokens: progress.tokens,
|
|
6496
6505
|
durationMs: progress.durationMs
|
|
6497
6506
|
};
|
|
6498
|
-
const
|
|
6499
|
-
const mutationEvidence = result2.nativeMachine && !isRexLocalMachine(options.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...remoteGitChanged === void 0 ? { unavailable: "Remote Git before/after evidence was incomplete." } : {} } : await collectTrackedMutationEvidence(mutationSnapshot, mutationCwd);
|
|
6507
|
+
const mutationEvidence = result2.nativeMachine && !editsLocalDisk(options.machine) ? remoteMutationEvidence(result2.nativeMachine) : await collectTrackedMutationEvidence(mutationSnapshot, mutationCwd);
|
|
6500
6508
|
const acceptanceOutput = getFinalOutput(result2.messages ?? []);
|
|
6501
6509
|
const structuredText = result2.structuredOutput === void 0 ? void 0 : JSON.stringify(result2.structuredOutput, null, 2);
|
|
6502
6510
|
let fullOutput = stripAcceptanceReport(acceptanceOutput);
|
|
@@ -6588,7 +6596,7 @@ function writeStructuredOutputArtifacts(runtime, value, acceptanceReport) {
|
|
|
6588
6596
|
}
|
|
6589
6597
|
async function runSyncCompletionInner(runtimeCwd, agents, agentName, task, options) {
|
|
6590
6598
|
const effectiveCwd = options.cwd ?? runtimeCwd;
|
|
6591
|
-
const cwdError = options.machine && !
|
|
6599
|
+
const cwdError = options.machine && !editsLocalDisk(options.machine) ? void 0 : preflightLaunchCwd(options.requestedCwd ?? effectiveCwd, effectiveCwd);
|
|
6592
6600
|
if (cwdError) {
|
|
6593
6601
|
return redactResultPrompt(withRunContext({
|
|
6594
6602
|
index: options.index ?? 0,
|
|
@@ -8922,7 +8930,7 @@ Extensions denied: ${status.capabilityCeiling.denyExtensions ? "yes" : "no"} (so
|
|
|
8922
8930
|
status.turnBudget ? `Turn budget: ${status.turnBudget.turnCount}/${status.turnBudget.maxTurns}+${status.turnBudget.graceTurns} (${status.turnBudget.outcome})` : void 0,
|
|
8923
8931
|
`Dir: ${asyncDir}`,
|
|
8924
8932
|
outputPath ? `Output: ${outputPath}` : void 0,
|
|
8925
|
-
status.parallelHandoff ?
|
|
8933
|
+
...status.parallelHandoff ? formatParallelHandoffLines(status.parallelHandoff.path, status.parallelHandoff.keptBranches) : [],
|
|
8926
8934
|
reconciliation.message ? `Diagnosis: ${reconciliation.message}` : void 0,
|
|
8927
8935
|
reconciliation.resultPath && fs17.existsSync(reconciliation.resultPath) ? `Result: ${reconciliation.resultPath}` : void 0
|
|
8928
8936
|
].filter((line) => Boolean(line));
|
|
@@ -9058,7 +9066,7 @@ Extensions denied: ${status.capabilityCeiling.denyExtensions ? "yes" : "no"} (so
|
|
|
9058
9066
|
const status = data.state === "stopped" || data.stopped === true || childStatuses.includes("stopped") ? "stopped" : data.success ? "complete" : data.state === "paused" || data.exitCode === 0 ? "paused" : "failed";
|
|
9059
9067
|
const runId = data.runId ?? data.id ?? resolvedId;
|
|
9060
9068
|
const lines = [`Run: ${runId}`, data.toolCallId ? `Tool call: ${data.toolCallId}` : void 0, `State: ${status}`, `Result: ${resultPath}`].filter((line) => Boolean(line));
|
|
9061
|
-
if (data.parallelHandoff?.path) lines.push(
|
|
9069
|
+
if (data.parallelHandoff?.path) lines.push(...formatParallelHandoffLines(data.parallelHandoff.path, data.parallelHandoff.keptBranches));
|
|
9062
9070
|
const receipt = data.workflowReceipt;
|
|
9063
9071
|
const receiptPath = receipt && typeof receipt === "object" && !Array.isArray(receipt) ? receipt.path : void 0;
|
|
9064
9072
|
const workflowReceiptPath2 = typeof receiptPath === "string" && receiptPath ? receiptPath : void 0;
|
|
@@ -9646,7 +9654,7 @@ function buildUnknownGitEntry(input) {
|
|
|
9646
9654
|
return blockedEntry(entry, "unknown", "unknown", "no matching extension-owned handoff metadata was found");
|
|
9647
9655
|
}
|
|
9648
9656
|
function buildMissingMetadataEntry(input) {
|
|
9649
|
-
if (input.record.task
|
|
9657
|
+
if (isWorktreeCleanupTaskDone(input.record.task)) return void 0;
|
|
9650
9658
|
const pathValue = metadataRecordPath(input.record);
|
|
9651
9659
|
const entry = buildEntryBase({ path: pathValue, branch: input.record.task.branch, source: "metadata", metadata: input.record, targetHead: input.targetHead });
|
|
9652
9660
|
return blockedEntry(entry, "stale", "unknown", "handoff metadata records a worktree that is not present in Git worktree state");
|
|
@@ -12800,6 +12808,16 @@ function writeWorkflowAggregateOutput(outputPath, text, producedChildOutputPaths
|
|
|
12800
12808
|
${error instanceof Error ? error.message : String(error)}`;
|
|
12801
12809
|
}
|
|
12802
12810
|
}
|
|
12811
|
+
function removeEarlierWorkflowOutput(outputPath) {
|
|
12812
|
+
if (!outputPath) return void 0;
|
|
12813
|
+
try {
|
|
12814
|
+
fs20.rmSync(outputPath, { force: true });
|
|
12815
|
+
return void 0;
|
|
12816
|
+
} catch (error) {
|
|
12817
|
+
return `Output file error: ${outputPath}
|
|
12818
|
+
${error instanceof Error ? error.message : String(error)}`;
|
|
12819
|
+
}
|
|
12820
|
+
}
|
|
12803
12821
|
function appendWorkflowOutputWarning(text, warning) {
|
|
12804
12822
|
return warning ? `${text}
|
|
12805
12823
|
|
|
@@ -14901,6 +14919,7 @@ Parent action: ${STATUS_ACTION}`,
|
|
|
14901
14919
|
step.async = runId2 !== void 0 && path18.basename(runId2) === runId2 && fs20.existsSync(path18.join(path18.dirname(asyncDir), runId2));
|
|
14902
14920
|
persist({ tolerateStatusWriteFailure: true });
|
|
14903
14921
|
};
|
|
14922
|
+
const earlierOutputWarning2 = workflowReuseSource ? void 0 : removeEarlierWorkflowOutput(workflowAggregateOutputPath2);
|
|
14904
14923
|
try {
|
|
14905
14924
|
const workflow = await runWorkflowScript({
|
|
14906
14925
|
script: workflowScript,
|
|
@@ -15061,8 +15080,9 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15061
15080
|
inheritedNestedRoute(deps2)?.rootRunId
|
|
15062
15081
|
);
|
|
15063
15082
|
preparedChildParams = childRequest;
|
|
15064
|
-
const
|
|
15065
|
-
if (
|
|
15083
|
+
const approval = await approveWorkflowChildLaunch(ctx, () => workflowChildLaunchArgs(workflowRunId, key, childRequest, childParams.agent, parentCwd, discoverWorkflowAgents), workflowSignal);
|
|
15084
|
+
if ("refusal" in approval) return buildRequestedModeError(childRequest, approval.refusal);
|
|
15085
|
+
if (approval.task !== void 0 && childRequest.action !== "resume") childRequest.task = approval.task;
|
|
15066
15086
|
if (workflowUsageBudget.budget) workflowOwnedUsageBudgets.set(childRequest, workflowUsageBudget.budget);
|
|
15067
15087
|
if (workflowRequiredExtensions) workflowRetainedRequiredExtensions.set(childRequest, workflowRequiredExtensions);
|
|
15068
15088
|
workflowLaunchObservers.set(childRequest, (launch) => {
|
|
@@ -15208,7 +15228,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15208
15228
|
}
|
|
15209
15229
|
const errorPreview = status.error && status.error.length > 1e3 ? `${status.error.slice(0, 1e3)}\u2026 (truncated; full error: ${statusPath} (error))` : status.error;
|
|
15210
15230
|
const terminalSummary = `${status.state === "complete" ? "Workflow completed after detached child finished." : errorPreview ?? (pauseForDetached ? "Workflow paused." : "Workflow failed.")}${stopCause ? ` ${WORKFLOW_RUNTIME_REPLACED_STOP_NOTICE}` : ""}${workflowOutputPathMappingSummary2(partial.children)}${finalPreflightWarnings.length ? ` ${finalPreflightWarnings.join(" ")}` : ""}`;
|
|
15211
|
-
const outputWarning = writeWorkflowAggregateOutput(workflowAggregateOutputPath2, terminalSummary, producedChildOutputPaths2);
|
|
15231
|
+
const outputWarning = status.state === "complete" ? writeWorkflowAggregateOutput(workflowAggregateOutputPath2, terminalSummary, producedChildOutputPaths2) : earlierOutputWarning2;
|
|
15212
15232
|
const resultSummary = appendWorkflowOutputWarning(terminalSummary, outputWarning);
|
|
15213
15233
|
const receiptState = status.state === "complete" ? "complete" : status.state === "paused" ? "paused" : status.state === "stopped" ? "stopped" : "failed";
|
|
15214
15234
|
const terminalOutcome = workflowFailureTerminalOutcome(error, partial.children, usageBudgetState(workflowUsageBudget.budget, sumResultsCost(workflowResults2)));
|
|
@@ -15284,6 +15304,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15284
15304
|
const liveWorkflowChildren = workflowChildSummary({ parentToolCallId: _id, workflowRunId: foregroundWorkflowRunId, workflowState: "running", inventoryComplete: false, trace: liveWorkflow.trace, progress: childProgress, launches: childLaunches });
|
|
15285
15305
|
onUpdate?.(workflowProgressUpdate(foregroundWorkflowRunId, chatProgress, liveWorkflow, liveWorkflowChildren, workflowPreflight));
|
|
15286
15306
|
};
|
|
15307
|
+
const earlierOutputWarning = removeEarlierWorkflowOutput(workflowAggregateOutputPath);
|
|
15287
15308
|
try {
|
|
15288
15309
|
const workflow = await runWorkflowScript({
|
|
15289
15310
|
script: requestParams.workflowScript,
|
|
@@ -15348,8 +15369,9 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15348
15369
|
inheritedNestedRoute(deps2)?.rootRunId
|
|
15349
15370
|
);
|
|
15350
15371
|
preparedChildParams = childRequest;
|
|
15351
|
-
const
|
|
15352
|
-
if (
|
|
15372
|
+
const approval = await approveWorkflowChildLaunch(ctx, () => workflowChildLaunchArgs(foregroundWorkflowRunId, key, childRequest, childParams.agent, ctx.cwd, discoverWorkflowAgents), workflowSignal);
|
|
15373
|
+
if ("refusal" in approval) return buildRequestedModeError(childRequest, approval.refusal);
|
|
15374
|
+
if (approval.task !== void 0 && childRequest.action !== "resume") childRequest.task = approval.task;
|
|
15353
15375
|
if (workflowUsageBudget.budget) workflowOwnedUsageBudgets.set(childRequest, workflowUsageBudget.budget);
|
|
15354
15376
|
if (workflowRequiredExtensions) workflowRetainedRequiredExtensions.set(childRequest, workflowRequiredExtensions);
|
|
15355
15377
|
if (delegatedWorkflowPermit) {
|
|
@@ -15364,7 +15386,11 @@ Parent action: ${COMPLETION_ACTION}` : content,
|
|
|
15364
15386
|
(deps2.state.blockingWorkflowChildren ??= /* @__PURE__ */ new Set()).add(launch.runId);
|
|
15365
15387
|
blockingWorkflowChildren.add(launch.runId);
|
|
15366
15388
|
}
|
|
15367
|
-
childLaunches.set(key, {
|
|
15389
|
+
childLaunches.set(key, {
|
|
15390
|
+
agent: launch.agent,
|
|
15391
|
+
...launch.runId ? { runId: launch.runId } : {},
|
|
15392
|
+
...launch.sessionFile ? { sessionFile: launch.sessionFile } : {}
|
|
15393
|
+
});
|
|
15368
15394
|
try {
|
|
15369
15395
|
sendWorkflowProgress();
|
|
15370
15396
|
} catch (error) {
|
|
@@ -15457,7 +15483,7 @@ ${workflow.console.map((entry) => `[${entry.level}] ${entry.text}`).join("\n")}`
|
|
|
15457
15483
|
const finalPreflightTrace = annotateWorkflowPreflightTrace(partial.trace, workflowPreflight);
|
|
15458
15484
|
const trace = finalPreflightTrace.map((entry) => ({ line: `- ${entry.operation} ${entry.key}: ${entry.state}${entry.runId ? ` (${entry.runId})` : ""}${entry.warning ? ` \u2014 ${entry.warning}` : ""}`, error: entry.error }));
|
|
15459
15485
|
const outputMappings = workflowOutputPathMappingSummary2(partial.children).trim();
|
|
15460
|
-
const displayText = formatWorkflowResultText({
|
|
15486
|
+
const displayText = appendWorkflowOutputWarning(formatWorkflowResultText({
|
|
15461
15487
|
head: workflowPreflight ? [formatWorkflowPreflight(workflowPreflight)] : [],
|
|
15462
15488
|
script: [
|
|
15463
15489
|
`Workflow failed: ${text}`,
|
|
@@ -15472,10 +15498,11 @@ ${partial.console.map((entry) => `[${entry.level}] ${entry.text}`).join("\n")}`]
|
|
|
15472
15498
|
...outputMappings ? [outputMappings] : []
|
|
15473
15499
|
],
|
|
15474
15500
|
maxOutput: requestParams.maxOutput,
|
|
15475
|
-
|
|
15501
|
+
// A failed workflow's text never goes to the declared output file; truncated text goes to the full-result file.
|
|
15502
|
+
aggregateOutputPath: void 0,
|
|
15476
15503
|
fullResultPath: workflowFullResultPath,
|
|
15477
15504
|
producedChildOutputPaths
|
|
15478
|
-
});
|
|
15505
|
+
}), earlierOutputWarning);
|
|
15479
15506
|
const workflowChildren = workflowChildSummary({ parentToolCallId: _id, workflowRunId: foregroundWorkflowRunId, workflowState: "failed", inventoryComplete: true, trace: partial.trace, children: partial.children });
|
|
15480
15507
|
const terminalOutcome = workflowFailureTerminalOutcome(error, partial.children, usageBudgetState(workflowUsageBudget.budget, sumResultsCost(workflowResults)));
|
|
15481
15508
|
const receipt = terminalWorkflowReceipt(foregroundWorkflowRunId, "failed", partial.children, workflowChildren, terminalOutcome, [...workflowHostSteps.values()], workflowResource?.provenance, workflowArgsDigest);
|