pi-subagents 0.84.0 → 0.85.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 +62 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-235AWJUQ.js → chunk-3UZ5FVVJ.js} +310 -101
- package/bundle/{chunk-F4ASL6OV.js → chunk-7MAE3DJV.js} +1 -1
- package/bundle/{chunk-4E7BKDTX.js → chunk-CS4O36CZ.js} +11 -156
- package/bundle/{chunk-VQVVHSY6.js → chunk-DV2NCNPR.js} +22 -11
- package/bundle/{chunk-G2Z6ZH26.js → chunk-GCSLVFCX.js} +1 -1
- package/bundle/{chunk-2S4K53MV.js → chunk-H2NLFTC5.js} +1 -1
- package/bundle/{chunk-NKQ6JNAS.js → chunk-HFTBF7SG.js} +2 -1
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-7BWGNDNK.js → chunk-IQIWF2VX.js} +190 -1177
- package/bundle/{chunk-XDQORLZ5.js → chunk-JNXT3MPI.js} +15 -6
- package/bundle/{chunk-J5YL7LYR.js → chunk-JO67XSKD.js} +59 -27
- package/bundle/{chunk-JG4QKI5M.js → chunk-JWYG26RE.js} +209 -93
- package/bundle/{chunk-C5P5CHYK.js → chunk-KDMFBYFM.js} +1 -1
- package/bundle/{chunk-V2BZYLEP.js → chunk-KEY3UQMQ.js} +7 -2
- package/bundle/{chunk-NENDSQUY.js → chunk-KZ34KQQH.js} +9 -6
- package/bundle/{chunk-AKOIVLA5.js → chunk-L2ENOFVZ.js} +76 -58
- package/bundle/{chunk-CGN2TVE7.js → chunk-LGMILZNE.js} +322 -18
- package/bundle/{chunk-L3WFKBEI.js → chunk-LTPH2DXH.js} +247 -153
- package/bundle/{chunk-2D52JFLF.js → chunk-N7B2KD74.js} +41 -117
- package/bundle/{chunk-PV63UFUR.js → chunk-O7CPL6H4.js} +183 -28
- package/bundle/{chunk-D3JAFGMO.js → chunk-PHZP3KHB.js} +1 -1
- package/bundle/{chunk-2DHZTCOL.js → chunk-PVIVCDG2.js} +2 -2
- package/bundle/{chunk-LFDBD4PW.js → chunk-QO75KJBT.js} +2 -2
- package/bundle/{chunk-SSG7IEP5.js → chunk-RQAUNAWG.js} +2 -2
- package/bundle/{chunk-PALJGGYC.js → chunk-RV5OGHLO.js} +6 -3
- package/bundle/chunk-T5V5BRCL.js +1067 -0
- package/bundle/{chunk-LNRJCP2Y.js → chunk-UX4SCV5N.js} +337 -207
- package/bundle/{chunk-DZDETGRJ.js → chunk-WOVMHDES.js} +231 -182
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +17 -2
- package/docs/configuration.md +2 -2
- package/docs/extension-api.md +16 -1
- package/docs/workflows.md +30 -2
- package/package.json +1 -1
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +5 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +25 -11
- package/src/extension/tool-description.js +6 -0
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +5 -9
- package/src/runs/background/async-execution.js +62 -27
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +4 -3
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +9 -6
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +3 -2
- package/src/runs/foreground/subagent-executor.js +107 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +30 -2
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +28 -11
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +81 -47
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
|
@@ -93,6 +93,10 @@ export function parseScheduleInterval(every) {
|
|
|
93
93
|
function timestamp(value) {
|
|
94
94
|
return new Date(value).toISOString();
|
|
95
95
|
}
|
|
96
|
+
/** One-line message for a caught value; a stack trace is never useful in a session warning. */
|
|
97
|
+
function errorText(error) {
|
|
98
|
+
return error instanceof Error ? error.message : String(error);
|
|
99
|
+
}
|
|
96
100
|
function validateScheduleId(id) {
|
|
97
101
|
if (!SCHEDULE_ID.test(id))
|
|
98
102
|
throw new Error("Schedule id must be 1-64 characters and contain only letters, numbers, '.', '_', or '-'.");
|
|
@@ -311,7 +315,8 @@ function parseSchedule(value, file) {
|
|
|
311
315
|
throw new Error(`Schedule record '${file}' has an invalid one-shot trigger.`);
|
|
312
316
|
}
|
|
313
317
|
else if (record.trigger.kind === "interval") {
|
|
314
|
-
|
|
318
|
+
// A paused interval record may omit nextRunAt; resuming it supplies one.
|
|
319
|
+
if (typeof record.trigger.every !== "string" || typeof record.trigger.everyMs !== "number" || typeof record.trigger.anchorAt !== "string" || ((!record.paused || record.trigger.nextRunAt !== undefined) && typeof record.trigger.nextRunAt !== "string"))
|
|
315
320
|
throw new Error(`Schedule record '${file}' has an invalid interval trigger.`);
|
|
316
321
|
}
|
|
317
322
|
else if (record.trigger.kind === "calendar") {
|
|
@@ -524,25 +529,12 @@ function snapshotContext(ctx, cwd) {
|
|
|
524
529
|
});
|
|
525
530
|
return { ...ctx, cwd, sessionManager };
|
|
526
531
|
}
|
|
527
|
-
/**
|
|
528
|
-
* 规范化会话文件路径, 兼容 Windows 路径大小写差异.
|
|
529
|
-
*
|
|
530
|
-
* @param value 会话文件路径
|
|
531
|
-
* @returns 规范化后的路径, 空值时返回 undefined
|
|
532
|
-
*/
|
|
533
532
|
function normalizedSessionFile(value) {
|
|
534
533
|
if (!value || !value.trim())
|
|
535
534
|
return undefined;
|
|
536
535
|
const normalized = path.normalize(path.resolve(value));
|
|
537
536
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
538
537
|
}
|
|
539
|
-
/**
|
|
540
|
-
* 判断 Schedule 是否属于当前 Pi 会话.
|
|
541
|
-
*
|
|
542
|
-
* @param schedule Schedule 记录
|
|
543
|
-
* @param ctx 当前 Pi 会话上下文
|
|
544
|
-
* @returns 是否允许当前会话执行该 Schedule
|
|
545
|
-
*/
|
|
546
538
|
function scheduleBelongsToSession(schedule, ctx) {
|
|
547
539
|
if (schedule.sessionOnly !== true)
|
|
548
540
|
return true;
|
|
@@ -631,7 +623,7 @@ export class ScheduledRunManager {
|
|
|
631
623
|
ids = store.ids();
|
|
632
624
|
}
|
|
633
625
|
catch (error) {
|
|
634
|
-
|
|
626
|
+
this.deps.reportWarning?.(`Failed to inspect schedule store '${store.root}': ${errorText(error)}`, `schedule-store:${store.root}:${errorText(error)}`);
|
|
635
627
|
continue;
|
|
636
628
|
}
|
|
637
629
|
for (const id of ids) {
|
|
@@ -646,7 +638,8 @@ export class ScheduledRunManager {
|
|
|
646
638
|
return;
|
|
647
639
|
}
|
|
648
640
|
catch (error) {
|
|
649
|
-
|
|
641
|
+
// Runs on every async completion, so the key holds no error text: one warning per record.
|
|
642
|
+
this.deps.reportWarning?.(`Failed to inspect schedule '${id}' in '${store.root}': ${errorText(error)}`, `schedule-record:${store.root}:${id}`);
|
|
650
643
|
}
|
|
651
644
|
}
|
|
652
645
|
}
|
|
@@ -748,6 +741,10 @@ export class ScheduledRunManager {
|
|
|
748
741
|
if (schedule.paused === paused)
|
|
749
742
|
return textResult(`Schedule ${schedule.id} is already ${paused ? "paused" : "active"}.`, [schedule]);
|
|
750
743
|
schedule.paused = paused;
|
|
744
|
+
// A record paused without a next run must get one back here, or resuming would leave a
|
|
745
|
+
// schedule that is active and never fires.
|
|
746
|
+
if (!paused && schedule.trigger.kind === "interval" && schedule.trigger.nextRunAt === undefined)
|
|
747
|
+
schedule.trigger.nextRunAt = timestamp(this.now() + schedule.trigger.everyMs);
|
|
751
748
|
schedule.updatedAt = timestamp(this.now());
|
|
752
749
|
this.requireStore().write(schedule);
|
|
753
750
|
this.requireStore().appendEvent(schedule, paused ? "schedule.paused" : "schedule.resumed");
|
|
@@ -70,9 +70,10 @@ export interface SubagentRunConfig {
|
|
|
70
70
|
revivalLeaseToken?: string;
|
|
71
71
|
/** Global cap on simultaneously-running subagent tasks within this run. */
|
|
72
72
|
globalConcurrencyLimit?: number;
|
|
73
|
+
/** The parent's config.waitTool.name, when not bg_wait; this process and its children use it. */
|
|
74
|
+
waitToolName?: string;
|
|
73
75
|
capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
|
|
74
76
|
runFanoutBudget?: RunFanoutBudgetDescriptor;
|
|
75
|
-
/** Builtin tool names the host runtime provides; used to intersect agent-declared tools. */
|
|
76
77
|
launchContractDigest?: string;
|
|
77
78
|
launchResolvedExtensions?: LaunchResolvedChildExtensions;
|
|
78
79
|
runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensions;
|
|
@@ -117,7 +118,6 @@ interface StepResult {
|
|
|
117
118
|
nativeMachine?: import("../../shared/types.ts").SingleResult["nativeMachine"];
|
|
118
119
|
thinking?: string;
|
|
119
120
|
requestedModel?: string;
|
|
120
|
-
/** True when the dispatch failed because the input exceeded the model's context window. */
|
|
121
121
|
contextOverflow?: boolean;
|
|
122
122
|
totalCost?: CostSummary;
|
|
123
123
|
artifactPaths?: ArtifactPaths;
|
|
@@ -142,7 +142,6 @@ interface StepResult {
|
|
|
142
142
|
externalProcess?: ExternalProcessStatus;
|
|
143
143
|
externalJob?: ExternalJobStatus;
|
|
144
144
|
}
|
|
145
|
-
/** Context for running a single step */
|
|
146
145
|
interface SingleStepContext {
|
|
147
146
|
previousOutput: string;
|
|
148
147
|
outputs?: ChainOutputMap;
|
|
@@ -158,7 +157,6 @@ interface SingleStepContext {
|
|
|
158
157
|
outputFile: string;
|
|
159
158
|
transcriptPath?: string;
|
|
160
159
|
piPackageRoot?: string;
|
|
161
|
-
/** Factory the runner creates this step's child session through. */
|
|
162
160
|
childSessions: ChildSessionFactory;
|
|
163
161
|
/** The launching executor's own child runtime; nested route, depth, and ceilings come from here. */
|
|
164
162
|
inheritedChildRuntime?: InheritedChildRuntime;
|
|
@@ -81,6 +81,7 @@ import { isRexLocalMachine } from "../shared/rex-machine.js";
|
|
|
81
81
|
import { HerdrExternalNeedsAttentionError, createHerdrExternalAdapter, prepareInternalHerdrExternalAdapter } from "../shared/herdr-external-adapters.js";
|
|
82
82
|
import { runExternalJob } from "../shared/external-job-runner.js";
|
|
83
83
|
import { createOrcaProgressTab } from "../shared/orca-progress-tabs.js";
|
|
84
|
+
import { setWaitToolName } from "../../shared/wait-tool-name.js";
|
|
84
85
|
import { acceptChildWatchdogEvent, applyChildWatchdogMessage, isChildWatchdogStatusEvent, resolveChildWatchdogConfig, } from "../../watchdog/child-status.js";
|
|
85
86
|
const INTERCOM_DETACH_RECEIPT = "Detached for intercom coordination before task completion.";
|
|
86
87
|
// This process hosts child sessions. An ambient copy of pi-subagents loaded
|
|
@@ -767,7 +768,8 @@ export async function runSingleStepInner(step, ctx) {
|
|
|
767
768
|
});
|
|
768
769
|
}
|
|
769
770
|
const effectiveCwd = step.cwd ?? ctx.cwd;
|
|
770
|
-
|
|
771
|
+
// A placed child's cwd is a directory on its machine; only machine 'local' shares this disk.
|
|
772
|
+
const cwdError = step.machine && !isRexLocalMachine(step.machine) ? undefined : preflightLaunchCwd(step.requestedCwd ?? effectiveCwd, effectiveCwd);
|
|
771
773
|
if (cwdError)
|
|
772
774
|
return { agent: step.agent, output: cwdError, error: cwdError, exitCode: 1, context: step.context };
|
|
773
775
|
if (step.context === "fork" && step.sessionFile && fs.existsSync(step.sessionFile)) {
|
|
@@ -787,7 +789,7 @@ export async function runSingleStepInner(step, ctx) {
|
|
|
787
789
|
let actualLaunchContractDigest = step.launchContractDigest;
|
|
788
790
|
// A machine 'local' child edits this disk, so its local Git evidence is authoritative, as for an unplaced run.
|
|
789
791
|
const mutationSnapshot = step.machine && !isRexLocalMachine(step.machine) ? { source: "tracked-files", trackedOnly: true, cwd: step.cwd ?? ctx.cwd, dirtyFiles: [], fingerprints: {}, unavailable: "Local Git evidence is not authoritative for a pane-native remote run." } : snapshotTrackedMutations(step.cwd ?? ctx.cwd);
|
|
790
|
-
let finalMutationEvidence = collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
|
|
792
|
+
let finalMutationEvidence = await collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
|
|
791
793
|
let contextOverflow = false;
|
|
792
794
|
let launchWarningsEmitted = false;
|
|
793
795
|
const aggregateUsage = emptyUsage();
|
|
@@ -1010,7 +1012,7 @@ export async function runSingleStepInner(step, ctx) {
|
|
|
1010
1012
|
? formatEmptyTerminalAssistantResponseError(run.messages)
|
|
1011
1013
|
: undefined;
|
|
1012
1014
|
const remoteGitChanged = run.nativeMachine?.initialGit && run.nativeMachine.finalGit ? run.nativeMachine.initialGit.head !== run.nativeMachine.finalGit.head || run.nativeMachine.initialGit.dirty !== run.nativeMachine.finalGit.dirty : undefined;
|
|
1013
|
-
const mutationEvidence = run.nativeMachine && !isRexLocalMachine(step.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...(remoteGitChanged === undefined ? { unavailable: "Remote Git before/after evidence was incomplete." } : {}) } : collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
|
|
1015
|
+
const mutationEvidence = run.nativeMachine && !isRexLocalMachine(step.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...(remoteGitChanged === undefined ? { unavailable: "Remote Git before/after evidence was incomplete." } : {}) } : await collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
|
|
1014
1016
|
finalMutationEvidence = mutationEvidence;
|
|
1015
1017
|
const mutationAttemptObserved = run.observedMutationAttempt === true || mutationEvidence.attemptedMutation === true;
|
|
1016
1018
|
// Validated structured output is persistable file content even when the final text is only
|
|
@@ -1511,6 +1513,8 @@ async function runSingleStepWithTimeout(step, ctx, parentDeadlineAt) {
|
|
|
1511
1513
|
}
|
|
1512
1514
|
export async function runSubagent(config, childSessions) {
|
|
1513
1515
|
const { id, steps, resultPath, cwd, placeholder, taskIndex, totalTasks, maxOutput, artifactsDir, artifactConfig } = config;
|
|
1516
|
+
if (config.waitToolName)
|
|
1517
|
+
setWaitToolName(config.waitToolName);
|
|
1514
1518
|
const globalSemaphore = new Semaphore(config.globalConcurrencyLimit ?? DEFAULT_GLOBAL_CONCURRENCY_LIMIT);
|
|
1515
1519
|
let previousOutput = "";
|
|
1516
1520
|
const outputs = {};
|
|
@@ -2705,7 +2709,7 @@ export async function runSubagent(config, childSessions) {
|
|
|
2705
2709
|
statusPayload.lastUpdate = now;
|
|
2706
2710
|
writeStatusPayload();
|
|
2707
2711
|
};
|
|
2708
|
-
//
|
|
2712
|
+
// The sequential and both parallel paths share it.
|
|
2709
2713
|
const recordStepResult = (fi, singleResult, startedAt, endedAt, recordLaunchContractDigest = false) => {
|
|
2710
2714
|
const step = requiredStatusStep(statusPayload, fi);
|
|
2711
2715
|
const childStopped = singleResult.stopped === true;
|
|
@@ -2754,7 +2758,6 @@ export async function runSubagent(config, childSessions) {
|
|
|
2754
2758
|
if (singleResult.capabilityAudit)
|
|
2755
2759
|
statusPayload.capabilityAudit = singleResult.capabilityAudit;
|
|
2756
2760
|
};
|
|
2757
|
-
// Adds a parallel child's cost to the in-flight usage ledger.
|
|
2758
2761
|
const addParallelUsageCost = (totalCost) => {
|
|
2759
2762
|
if (!totalCost)
|
|
2760
2763
|
return;
|
|
@@ -3424,7 +3427,7 @@ export async function runSubagent(config, childSessions) {
|
|
|
3424
3427
|
? path.join(path.dirname(step.parallel.outputPath), `dynamic-${stepIndex}`, `${itemIndex}-${step.parallel.agent}`, path.basename(step.parallel.outputPath))
|
|
3425
3428
|
: step.parallel.outputPath;
|
|
3426
3429
|
const taskText = task.task ?? step.parallel.task;
|
|
3427
|
-
const materializedTask = step.parallel.namespaceOutputPath ? injectSingleOutputInstruction(taskText, outputPath, step.parallel) : taskText;
|
|
3430
|
+
const materializedTask = step.parallel.namespaceOutputPath ? injectSingleOutputInstruction(taskText, outputPath, step.parallel, step.parallel.machine) : taskText;
|
|
3428
3431
|
const sessionName = deriveChildSessionName({ agent: step.parallel.agent, task: taskText, label: task.label ?? step.parallel.label });
|
|
3429
3432
|
return omitUndefinedProperties({
|
|
3430
3433
|
...step.parallel,
|
|
@@ -48,13 +48,12 @@ import { toAgentToolUsage } from "../../shared/utils.js";
|
|
|
48
48
|
import { collectWaitCompletions } from "./wait-completions.js";
|
|
49
49
|
import { formatResumeFirstFailedRunsNote } from "./resume-guidance.js";
|
|
50
50
|
import { formatTimeoutRecoveryLines } from "../shared/mutation-evidence.js";
|
|
51
|
+
import { waitToolName } from "../../shared/wait-tool-name.js";
|
|
51
52
|
export { WAIT_TOOL_DEFAULT_TIMEOUT_MS_ENV, WAIT_TOOL_ENABLED_ENV, resolveWaitToolConfig } from "./wait-config.js";
|
|
52
|
-
/** States that mean a run is still in flight (not yet resolved). */
|
|
53
53
|
const ACTIVE_STATES = ["queued", "running"];
|
|
54
|
-
const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
54
|
+
const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
55
55
|
const MIN_POLL_INTERVAL_MS = 250;
|
|
56
56
|
const DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
57
|
-
/** Bus channels that indicate a run changed state or needs attention. */
|
|
58
57
|
const WAKE_CHANNELS = [
|
|
59
58
|
INTERCOM_DETACH_REQUEST_EVENT,
|
|
60
59
|
SUBAGENT_ASYNC_COMPLETE_EVENT,
|
|
@@ -167,9 +166,8 @@ function foregroundChildrenNeedingAttention(run, indices) {
|
|
|
167
166
|
}
|
|
168
167
|
function formatForegroundAttention(run, children, elapsedMs) {
|
|
169
168
|
const childList = children.map((child) => `${child.agent}${child.index !== undefined ? `#${child.index}` : ""}`).join(", ");
|
|
170
|
-
return result(`Waited ${formatDuration(elapsedMs)} for remembered detached foreground run "${run.runId}"; attention required. ${children.length} child run(s) need attention: ${childList}. Reply to any pending supervisor request, then call
|
|
169
|
+
return result(`Waited ${formatDuration(elapsedMs)} for remembered detached foreground run "${run.runId}"; attention required. ${children.length} child run(s) need attention: ${childList}. Reply to any pending supervisor request, then call ${waitToolName()}({ id: "${run.runId}" }) again or inspect status; do not resume or launch a replacement while it remains detached.`);
|
|
171
170
|
}
|
|
172
|
-
/** A running run that has flagged it needs the parent's attention. */
|
|
173
171
|
function needsAttention(run) {
|
|
174
172
|
return run.activityState === "needs_attention" || run.steps.some((step) => step.activityState === "needs_attention");
|
|
175
173
|
}
|
|
@@ -184,7 +182,7 @@ function backgroundWorkIdentity(item) {
|
|
|
184
182
|
export function backgroundWorkForSession(deps, nowMs) {
|
|
185
183
|
const sessionId = deps.state.currentSessionId;
|
|
186
184
|
if (!sessionId)
|
|
187
|
-
throw new Error(
|
|
185
|
+
throw new Error(`${waitToolName()} requires an active session identity to scope background work safely.`);
|
|
188
186
|
// Providers may key items by the session file path or by getSessionId(); accept both.
|
|
189
187
|
const piSessionId = deps.state.supervisorOwnerSessionId;
|
|
190
188
|
const sessionIds = piSessionId ? [sessionId, piSessionId] : [sessionId];
|
|
@@ -216,7 +214,6 @@ function runsForSession(params, deps, activeOnly = true) {
|
|
|
216
214
|
function activeRunsForSession(params, deps) {
|
|
217
215
|
return runsForSession(params, deps);
|
|
218
216
|
}
|
|
219
|
-
/** Runs (from the initial set) currently flagged needs_attention, for reporting. */
|
|
220
217
|
function attentionRunsForSession(params, deps, initialIds) {
|
|
221
218
|
return activeRunsForSession(params, deps).filter((run) => needsAttention(run) && initialIds.has(run.id));
|
|
222
219
|
}
|
|
@@ -497,7 +494,7 @@ async function waitForDetachedForegroundRun(run, signal, deps, startedAt, now, p
|
|
|
497
494
|
return result(`Wait aborted after ${formatDuration(now() - startedAt)}. Remembered foreground run "${run.runId}" remains detached. Reply to any pending supervisor request before resuming or launching a replacement.`, true);
|
|
498
495
|
}
|
|
499
496
|
if (now() - startedAt >= timeoutMs) {
|
|
500
|
-
return windowElapsedResult(`Wait window elapsed after ${formatDuration(timeoutMs)} with remembered foreground run "${run.runId}" still detached. Reply to any pending supervisor request, then call
|
|
497
|
+
return windowElapsedResult(`Wait window elapsed after ${formatDuration(timeoutMs)} with remembered foreground run "${run.runId}" still detached. Reply to any pending supervisor request, then call ${waitToolName()}({ id: "${run.runId}" }) again or inspect status; do not resume or launch a replacement while it remains detached.`, [run.runId]);
|
|
501
498
|
}
|
|
502
499
|
await waitForWake(pollIntervalMs, wake, deps);
|
|
503
500
|
}
|
|
@@ -531,10 +528,10 @@ async function waitForSessionDetachedForegroundRuns(runs, signal, deps, startedA
|
|
|
531
528
|
*/
|
|
532
529
|
export async function waitForSubagents(params, signal, deps) {
|
|
533
530
|
if (deps.enabled === false) {
|
|
534
|
-
return result(
|
|
531
|
+
return result(`${waitToolName()} is disabled by config.waitTool or PI_SUBAGENT_WAIT_TOOL_ENABLED; returning immediately without blocking background work. Active work keeps going, and you can inspect subagents with subagent({ action: \"status\" }) or rely on completion notifications.`);
|
|
535
532
|
}
|
|
536
533
|
if (!deps.state.currentSessionId) {
|
|
537
|
-
return result(
|
|
534
|
+
return result(`${waitToolName()} requires an active session identity to scope background work safely.`, true);
|
|
538
535
|
}
|
|
539
536
|
const now = deps.now ?? Date.now;
|
|
540
537
|
const pollIntervalMs = Math.max(MIN_POLL_INTERVAL_MS, deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
|
|
@@ -588,7 +585,7 @@ export async function waitForSubagents(params, signal, deps) {
|
|
|
588
585
|
}
|
|
589
586
|
if (selected && params.nonBlocking) {
|
|
590
587
|
if (!deps.subscribe) {
|
|
591
|
-
return result(
|
|
588
|
+
return result(`Non-blocking wait subscriptions require a long-lived interactive subagent runtime; this runtime can only use blocking ${waitToolName()} calls.`, true);
|
|
592
589
|
}
|
|
593
590
|
try {
|
|
594
591
|
const registration = deps.subscribe({ targetKind: selected.kind, runId: selected.id, requestedId: params.id, timeoutMs });
|
|
@@ -663,7 +660,7 @@ export async function waitForSubagents(params, signal, deps) {
|
|
|
663
660
|
return result(`Wait aborted after ${formatDuration(now() - startedAt)}. Still active: ${stillActive}.`, true);
|
|
664
661
|
}
|
|
665
662
|
if (now() - startedAt >= timeoutMs) {
|
|
666
|
-
return windowElapsedResult(`Wait window elapsed after ${formatDuration(timeoutMs)} with ${activeInitialRuns.length} async run(s) and ${activeInitialProviderItems.length} provider item(s) still active: ${stillActive}. The work keeps going; call
|
|
663
|
+
return windowElapsedResult(`Wait window elapsed after ${formatDuration(timeoutMs)} with ${activeInitialRuns.length} async run(s) and ${activeInitialProviderItems.length} provider item(s) still active: ${stillActive}. The work keeps going; call ${waitToolName()} again or inspect subagent status.`, activeInitialRuns.map((run) => run.id), activeInitialProviderItems);
|
|
667
664
|
}
|
|
668
665
|
try {
|
|
669
666
|
await waitForWake(pollIntervalMs, wake, deps);
|
|
@@ -674,7 +671,7 @@ export async function waitForSubagents(params, signal, deps) {
|
|
|
674
671
|
providerSnapshot = params.id ? providerSnapshot : backgroundWorkForSession(deps, now());
|
|
675
672
|
for (const provider of initialProviderNames) {
|
|
676
673
|
if (!providerSnapshot.providers.includes(provider)) {
|
|
677
|
-
return result(`Background-work provider '${provider}' disappeared while
|
|
674
|
+
return result(`Background-work provider '${provider}' disappeared while ${waitToolName()} was tracking its active work; completion cannot be confirmed.`, true);
|
|
678
675
|
}
|
|
679
676
|
}
|
|
680
677
|
providerActive = providerSnapshot.items;
|
|
@@ -713,7 +710,7 @@ export async function waitForSubagents(params, signal, deps) {
|
|
|
713
710
|
// Only when watchdog attention alone ended the wait: stopOnAttention: false would have kept blocking.
|
|
714
711
|
const keepWaitingHint = stopOnAttention && supervisorAttentionHint === ""
|
|
715
712
|
&& (waitForAll || finishedAsyncCount + providerFinishedCount === 0)
|
|
716
|
-
?
|
|
713
|
+
? ` These runs are still running and none is waiting on a supervisor reply. To keep waiting through this kind of attention, call ${waitToolName()} again with stopOnAttention: false; supervisor requests still end that wait.`
|
|
717
714
|
: "";
|
|
718
715
|
const attentionNote = relevantAttention.length > 0
|
|
719
716
|
? ` ${relevantAttention.length} run(s) need attention: ${relevantAttention.map((run) => run.id).join(", ")} —${supervisorAttentionHint} inspect with subagent({ action: "status" }) then steer a top-level live async child, resume a paused/completed/failed child, or interrupt explicitly.${keepWaitingHint}`
|
|
@@ -745,7 +742,7 @@ export async function waitForSubagents(params, signal, deps) {
|
|
|
745
742
|
const finishedCount = finishedAsyncCount + providerFinishedCount;
|
|
746
743
|
const subject = initialProviderIds.size === 0 ? "run(s)" : "item(s)";
|
|
747
744
|
const remainder = stillRunning > 0
|
|
748
|
-
? ` ${stillRunning} ${subject} still in flight — call
|
|
745
|
+
? ` ${stillRunning} ${subject} still in flight — call ${waitToolName()} again to catch the next one.`
|
|
749
746
|
: relevantAttention.length > 0
|
|
750
747
|
? " No other work is waitable until attention is handled."
|
|
751
748
|
: initialProviderIds.size === 0 ? " No runs remain in flight." : " No work remains in flight.";
|
|
@@ -4,5 +4,7 @@ export declare const WAIT_TOOL_DEFAULT_TIMEOUT_MS_ENV = "PI_SUBAGENT_WAIT_TOOL_D
|
|
|
4
4
|
export interface ResolvedWaitToolConfig {
|
|
5
5
|
enabled: boolean;
|
|
6
6
|
defaultTimeoutMs?: number;
|
|
7
|
+
/** Set only when it differs from bg_wait, so default launch configs are unchanged. */
|
|
8
|
+
name?: string;
|
|
7
9
|
}
|
|
8
10
|
export declare function resolveWaitToolConfig(config?: WaitToolConfig, env?: Record<string, string | undefined>): ResolvedWaitToolConfig;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_WAIT_TOOL_NAME } from "../../shared/wait-tool-name.js";
|
|
1
2
|
export const WAIT_TOOL_ENABLED_ENV = "PI_SUBAGENT_WAIT_TOOL_ENABLED";
|
|
2
3
|
export const WAIT_TOOL_DEFAULT_TIMEOUT_MS_ENV = "PI_SUBAGENT_WAIT_TOOL_DEFAULT_TIMEOUT_MS";
|
|
4
|
+
const WAIT_TOOL_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
5
|
+
// Tools pi-subagents itself registers; a wait tool under one of these names would collide with it.
|
|
6
|
+
const RESERVED_TOOL_NAMES = new Set(["subagent", "subagents_enable", "subagent_supervisor", "contact_supervisor", "intercom", "structured_output", "subagent_launch", "subagent_command", "watchdog_diff", "watchdog_ask", "watchdog_warn", "watchdog_permission_decision"]);
|
|
3
7
|
const TRUE_VALUES = new Set(["1", "true", "yes", "on", "enabled"]);
|
|
4
8
|
const FALSE_VALUES = new Set(["0", "false", "no", "off", "disabled"]);
|
|
5
9
|
function environmentValue(value) {
|
|
@@ -26,15 +30,24 @@ function configuredValue(config) {
|
|
|
26
30
|
if (typeof config === "boolean")
|
|
27
31
|
return { enabled: config };
|
|
28
32
|
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
29
|
-
throw new Error("config.waitTool must be a boolean or an object with optional enabled and
|
|
33
|
+
throw new Error("config.waitTool must be a boolean or an object with optional enabled, defaultTimeoutMs and name values.");
|
|
30
34
|
}
|
|
31
|
-
const { enabled, defaultTimeoutMs } = config;
|
|
35
|
+
const { enabled, defaultTimeoutMs, name } = config;
|
|
32
36
|
if (enabled !== undefined && typeof enabled !== "boolean")
|
|
33
37
|
throw new Error("config.waitTool.enabled must be a boolean.");
|
|
34
38
|
if (defaultTimeoutMs !== undefined && (!Number.isInteger(defaultTimeoutMs) || defaultTimeoutMs < 1)) {
|
|
35
39
|
throw new Error("config.waitTool.defaultTimeoutMs must be a positive integer.");
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
if (name !== undefined && (typeof name !== "string" || !WAIT_TOOL_NAME_PATTERN.test(name))) {
|
|
42
|
+
throw new Error("config.waitTool.name must start with a letter and contain only letters, digits and underscores (at most 64 characters).");
|
|
43
|
+
}
|
|
44
|
+
if (typeof name === "string" && RESERVED_TOOL_NAMES.has(name))
|
|
45
|
+
throw new Error(`config.waitTool.name "${name}" is already a pi-subagents tool.`);
|
|
46
|
+
return {
|
|
47
|
+
enabled,
|
|
48
|
+
...(defaultTimeoutMs !== undefined ? { defaultTimeoutMs: defaultTimeoutMs } : {}),
|
|
49
|
+
...(name !== undefined && name !== DEFAULT_WAIT_TOOL_NAME ? { name } : {}),
|
|
50
|
+
};
|
|
38
51
|
}
|
|
39
52
|
export function resolveWaitToolConfig(config, env = process.env) {
|
|
40
53
|
const configured = configuredValue(config);
|
|
@@ -42,5 +55,6 @@ export function resolveWaitToolConfig(config, env = process.env) {
|
|
|
42
55
|
return {
|
|
43
56
|
enabled: environmentValue(env[WAIT_TOOL_ENABLED_ENV]) ?? configured.enabled ?? true,
|
|
44
57
|
...(envDefaultTimeoutMs ?? configured.defaultTimeoutMs !== undefined ? { defaultTimeoutMs: envDefaultTimeoutMs ?? configured.defaultTimeoutMs } : {}),
|
|
58
|
+
...(configured.name ? { name: configured.name } : {}),
|
|
45
59
|
};
|
|
46
60
|
}
|
|
@@ -2,8 +2,10 @@ import { SubagentWaitParams } from "../../extension/schemas.js";
|
|
|
2
2
|
import { resolveWaitToolConfig, waitForSubagents } from "./subagent-wait.js";
|
|
3
3
|
import { finalizeToolResult } from "../../extension/tool-result.js";
|
|
4
4
|
import { registerPinnedTool } from "../../extension/declaration-pinning.js";
|
|
5
|
+
import { waitToolName } from "../../shared/wait-tool-name.js";
|
|
5
6
|
export function registerWaitTool(pi, state, enabled = resolveWaitToolConfig().enabled, subscriptions, defaultTimeoutMs, child, hasPendingSupervisorRequest) {
|
|
6
|
-
const
|
|
7
|
+
const name = waitToolName();
|
|
8
|
+
const description = `Wait for background work, then return. ${child ? `This child runtime has no native completion notifier: use blocking ${name} to collect your owned descendants this turn and read their result references; agent_end draining does not synthesize results.` : `Ordinary async subagent runs already wake this session natively; use ${name} only for provider, detached, or other background work without native notification, when a same-turn result is needed.`}
|
|
7
9
|
{} — first active run or provider item to finish or need attention.
|
|
8
10
|
{all:true} — all work active at call time.
|
|
9
11
|
{id} — one run; a finished async run returns its result references.
|
|
@@ -38,7 +40,7 @@ Timeout or a user message ends the wait without error; work keeps running.${enab
|
|
|
38
40
|
}
|
|
39
41
|
};
|
|
40
42
|
const primaryTool = {
|
|
41
|
-
name
|
|
43
|
+
name,
|
|
42
44
|
label: "Background Wait",
|
|
43
45
|
description,
|
|
44
46
|
parameters: SubagentWaitParams,
|
|
@@ -11,7 +11,6 @@ export declare function readWorkflowChildRunModel(workflowAsyncDir: string, step
|
|
|
11
11
|
model?: string;
|
|
12
12
|
thinking?: string;
|
|
13
13
|
} | undefined;
|
|
14
|
-
/** Fill a workflow child roster row from the child's own reported model. */
|
|
15
14
|
export declare function withWorkflowChildRunModel<T extends {
|
|
16
15
|
runId?: string;
|
|
17
16
|
model?: string;
|
|
@@ -24,7 +24,6 @@ export function readWorkflowChildRunModel(workflowAsyncDir, step) {
|
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
/** Fill a workflow child roster row from the child's own reported model. */
|
|
28
27
|
export function withWorkflowChildRunModel(workflowAsyncDir, child) {
|
|
29
28
|
if (child.model && child.thinking)
|
|
30
29
|
return child;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core execution logic for running subagents
|
|
3
|
-
*/
|
|
4
1
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
5
2
|
import * as path from "node:path";
|
|
6
3
|
import { discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext } from "../../agents/agents.js";
|
|
@@ -876,12 +873,25 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
|
|
|
876
873
|
toolAttentionTarget.attentionEmitted = true;
|
|
877
874
|
const durationMs = Math.max(0, now - toolAttentionTarget.startedAt);
|
|
878
875
|
const toolCallId = toolAttentionTarget.key.startsWith("id:") ? toolAttentionTarget.key.slice(3) : undefined;
|
|
876
|
+
let hasCommandController = false;
|
|
877
|
+
// Runs from the 1 s activity timer, where a throw reaches Pi's uncaughtException handler and exits Pi.
|
|
878
|
+
if (toolCallId)
|
|
879
|
+
try {
|
|
880
|
+
hasCommandController = retainsChildCommand(supervisorChannelDir(options.runId, agent.name, options.index ?? 0), toolCallId);
|
|
881
|
+
}
|
|
882
|
+
catch (error) {
|
|
883
|
+
const message = `Could not read the command state of ${agent.name}; its command controls are not offered: ${error instanceof Error ? error.message : String(error)}`;
|
|
884
|
+
if (options.onWarning)
|
|
885
|
+
options.onWarning(message, "child-command-state");
|
|
886
|
+
else
|
|
887
|
+
console.warn(`[pi-subagents] ${message}`);
|
|
888
|
+
}
|
|
879
889
|
return emitNeedsAttention(now, {
|
|
880
890
|
message: `${agent.name} has had tool '${toolAttentionTarget.tool}' open for ${Math.floor(durationMs / 1000)}s`,
|
|
881
891
|
reason: "tool_open_threshold",
|
|
882
892
|
currentTool: toolAttentionTarget.tool,
|
|
883
893
|
toolCallId,
|
|
884
|
-
hasCommandController
|
|
894
|
+
hasCommandController,
|
|
885
895
|
currentPath: toolAttentionTarget.path,
|
|
886
896
|
currentToolDurationMs: durationMs,
|
|
887
897
|
});
|
|
@@ -1552,7 +1562,7 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
|
|
|
1552
1562
|
durationMs: progress.durationMs,
|
|
1553
1563
|
};
|
|
1554
1564
|
const remoteGitChanged = result.nativeMachine?.initialGit && result.nativeMachine.finalGit ? result.nativeMachine.initialGit.head !== result.nativeMachine.finalGit.head || result.nativeMachine.initialGit.dirty !== result.nativeMachine.finalGit.dirty : undefined;
|
|
1555
|
-
const mutationEvidence = result.nativeMachine && !isRexLocalMachine(options.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...(remoteGitChanged === undefined ? { unavailable: "Remote Git before/after evidence was incomplete." } : {}) } : collectTrackedMutationEvidence(mutationSnapshot, mutationCwd);
|
|
1565
|
+
const mutationEvidence = result.nativeMachine && !isRexLocalMachine(options.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...(remoteGitChanged === undefined ? { unavailable: "Remote Git before/after evidence was incomplete." } : {}) } : await collectTrackedMutationEvidence(mutationSnapshot, mutationCwd);
|
|
1556
1566
|
const acceptanceOutput = getFinalOutput(result.messages ?? []);
|
|
1557
1567
|
const structuredText = result.structuredOutput === undefined ? undefined : JSON.stringify(result.structuredOutput, null, 2);
|
|
1558
1568
|
let fullOutput = stripAcceptanceReport(acceptanceOutput);
|
|
@@ -1652,12 +1662,10 @@ function writeStructuredOutputArtifacts(runtime, value, acceptanceReport) {
|
|
|
1652
1662
|
// The captured value is already on the result; the file is observability only.
|
|
1653
1663
|
}
|
|
1654
1664
|
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Run a subagent synchronously (blocking until complete)
|
|
1657
|
-
*/
|
|
1658
1665
|
async function runSyncCompletionInner(runtimeCwd, agents, agentName, task, options) {
|
|
1659
1666
|
const effectiveCwd = options.cwd ?? runtimeCwd;
|
|
1660
|
-
|
|
1667
|
+
// A placed child's cwd is a directory on its machine; only machine 'local' shares this disk.
|
|
1668
|
+
const cwdError = options.machine && !isRexLocalMachine(options.machine) ? undefined : preflightLaunchCwd(options.requestedCwd ?? effectiveCwd, effectiveCwd);
|
|
1661
1669
|
if (cwdError) {
|
|
1662
1670
|
return redactResultPrompt(withRunContext({
|
|
1663
1671
|
index: options.index ?? 0,
|
|
@@ -16,7 +16,7 @@ import type { ChildRuntimeConfig } from "../shared/child-runtime-config.ts";
|
|
|
16
16
|
import { type MissionLaunchBinding } from "../../missions/lifecycle.ts";
|
|
17
17
|
import { type WorkflowSteerOptions, type WorkflowSteerResult } from "../../workflows/scripted-workflow.ts";
|
|
18
18
|
import { type PreparedWorkflowResume, type WorkflowResumeRefusalReason } from "../../workflows/workflow-resume.ts";
|
|
19
|
-
import { type AcceptanceInput, type AgentContract, type ControlConfig, type Details, type ExtensionConfig, type IntercomBridgeConfig, type JsonSchemaObject, type MaxOutputConfig, type ResolvedControlConfig, type RunFanoutBudgetDescriptor, type SteeringRecoveryDescriptor, type SingleResult, type ToolBudgetConfig, type UsageBudgetConfig, type SubagentState, type ScheduleOrigin } from "../../shared/types.ts";
|
|
19
|
+
import { type AcceptanceInput, type AgentContract, type ControlConfig, type Details, type ExtensionConfig, type IntercomBridgeConfig, type JsonSchemaObject, type MaxOutputConfig, type ResolvedControlConfig, type RunFanoutBudgetDescriptor, type SteeringRecoveryDescriptor, type SingleResult, type ToolBudgetConfig, type UsageBudgetConfig, type SubagentState, type ScheduleOrigin, type RequiredRunnerLauncher } from "../../shared/types.ts";
|
|
20
20
|
export declare function unknownSubagentActionMessage(action: string, disabled?: DisabledFeatureSurface): string;
|
|
21
21
|
interface TaskParam {
|
|
22
22
|
agent: string;
|
|
@@ -121,6 +121,7 @@ export interface SubagentParamsLike {
|
|
|
121
121
|
machine?: string;
|
|
122
122
|
/** Internal: the typed cwd when a machine is set, kept as a remote path and never resolved locally. */
|
|
123
123
|
machineCwd?: string;
|
|
124
|
+
requireLauncher?: RequiredRunnerLauncher;
|
|
124
125
|
maxOutput?: MaxOutputConfig;
|
|
125
126
|
artifacts?: boolean;
|
|
126
127
|
includeProgress?: boolean;
|
|
@@ -204,7 +205,7 @@ interface ExecutorDeps {
|
|
|
204
205
|
}
|
|
205
206
|
export declare function removeForegroundControlIfIdle(state: SubagentState, runId: string, trackRetainedNestedRoute?: (rootRunId: string) => void): boolean;
|
|
206
207
|
export declare function promptAuditRedoParams(value: unknown, rewrittenTask: string): SubagentParamsLike;
|
|
207
|
-
export declare function readNestedRecoveryDescriptor(
|
|
208
|
+
export declare function readNestedRecoveryDescriptor(rootRunId: string, runId: string, agent: string): SteeringRecoveryDescriptor | undefined;
|
|
208
209
|
export declare function foregroundResultIntercomStatus(result: SingleResult): ReturnType<typeof resolveSubagentResultStatus>;
|
|
209
210
|
export declare function shouldSuppressRoutineResultIntercom(input: {
|
|
210
211
|
suppressRoutineResultIntercom?: boolean;
|