@vicary/pi-subagents 0.87.0 → 0.88.1
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 +50 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-3CVOAS77.js → chunk-2DIEL4WG.js} +2 -2
- package/bundle/{chunk-75LVXBSA.js → chunk-2HKPEANZ.js} +114 -49
- package/bundle/{chunk-ESWW6XSX.js → chunk-47ZN7NKR.js} +1 -1
- package/bundle/{chunk-C3KWLXDH.js → chunk-4MVDMA5C.js} +9 -1
- package/bundle/{chunk-XV7RTWTS.js → chunk-4ZQBZDF3.js} +21 -6
- package/bundle/{chunk-LZKVUWIY.js → chunk-5EMPFFO4.js} +30 -5
- package/bundle/{chunk-OOE3R7IQ.js → chunk-6CG2VAG4.js} +2 -2
- package/bundle/{chunk-HDICKROY.js → chunk-7OX6O7DQ.js} +31 -14
- package/bundle/{chunk-Z4TR7MK6.js → chunk-AZPP3G4N.js} +14 -5
- package/bundle/{chunk-PUSTU4Q7.js → chunk-BKISQ5CJ.js} +130 -49
- package/bundle/{chunk-NMYBVCGP.js → chunk-CGWNA6EJ.js} +75 -44
- package/bundle/{chunk-PGU4TZV3.js → chunk-CPSUJHZE.js} +417 -455
- package/bundle/{chunk-W52LJANO.js → chunk-CYKNHFXB.js} +1 -1
- package/bundle/{chunk-SIAQXPJ4.js → chunk-D32H53HM.js} +21 -9
- package/bundle/{chunk-YEXKJJVS.js → chunk-DSHQWGHO.js} +4 -4
- package/bundle/{chunk-6O7YH2QV.js → chunk-GDR2ILWY.js} +1 -1
- package/bundle/{chunk-O7A26O6B.js → chunk-IYT7X46U.js} +6 -4
- package/bundle/{chunk-NJTSXIMG.js → chunk-JQTHG2ID.js} +12 -12
- package/bundle/{chunk-C5QWQSSM.js → chunk-KXW62VBU.js} +1 -1
- package/bundle/{chunk-BFF6YDK6.js → chunk-L4YY2TOE.js} +1 -1
- package/bundle/{chunk-2NY5PCKQ.js → chunk-LV3CPYXJ.js} +4 -4
- package/bundle/{chunk-2D2DQGC2.js → chunk-PYKBTBY6.js} +27 -10
- package/bundle/{chunk-M2VBGET6.js → chunk-RMZAAXIR.js} +7 -2
- package/bundle/{chunk-HTI7DD5D.js → chunk-V7SZMS6W.js} +2 -2
- package/bundle/{chunk-VFUFOZBU.js → chunk-W6HIYD2Z.js} +1 -1
- package/bundle/{chunk-USRX7QXD.js → chunk-XIA5GSEU.js} +2 -2
- package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
- package/bundle/chunk-YDZ7BZD5.js +523 -0
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- 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 +4 -2
- package/docs/configuration.md +4 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +4 -1
- package/docs/workflows.md +3 -1
- package/package.json +3 -3
- package/skills/pi-subagents/SKILL.md +8 -2
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +12 -4
- package/src/agents/agents.d.ts +1 -0
- package/src/agents/agents.js +2 -2
- package/src/extension/config.d.ts +9 -0
- package/src/extension/config.js +13 -0
- package/src/extension/index.d.ts +1 -1
- package/src/extension/index.js +47 -23
- package/src/extension/schemas.d.ts +2 -0
- package/src/extension/schemas.js +1 -0
- package/src/extension/subagent-launch-tool.d.ts +6 -2
- package/src/extension/subagent-launch-tool.js +13 -9
- package/src/extension/tool-activation.js +20 -3
- package/src/runs/background/async-resume.js +2 -1
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +11 -5
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/run-child-session.d.ts +2 -2
- package/src/runs/background/run-child-session.js +4 -7
- package/src/runs/background/stale-run-reconciler.js +17 -8
- package/src/runs/background/steering.d.ts +2 -11
- package/src/runs/background/steering.js +11 -6
- package/src/runs/background/subagent-runner.d.ts +0 -2
- package/src/runs/background/subagent-runner.js +73 -58
- package/src/runs/foreground/async-steering-action.js +24 -9
- package/src/runs/foreground/execution.js +32 -15
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +1 -8
- package/src/runs/foreground/subagent-executor.js +17 -21
- package/src/runs/shared/async-status-projection.d.ts +2 -0
- package/src/runs/shared/async-status-projection.js +10 -0
- package/src/runs/shared/child-launch.js +6 -3
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +24 -30
- package/src/runs/shared/mcp-config-sources.d.ts +2 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +5 -5
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -15
- package/src/runs/shared/subagent-prompt-runtime.js +14 -2
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +107 -9
- 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/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- package/src/shared/required-child-extensions.d.ts +2 -0
- package/src/shared/required-child-extensions.js +27 -0
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +9 -0
- package/src/shared/utils.d.ts +3 -1
- package/src/shared/utils.js +4 -0
- package/src/tui/fleet.d.ts +7 -2
- package/src/tui/fleet.js +22 -0
- package/src/tui/render.js +33 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +2 -1
- package/src/workflows/workflow-script-worker.js +3 -1
- package/bundle/chunk-XSDYTXHF.js +0 -242
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildWorkflowChatProgressRows
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LV3CPYXJ.js";
|
|
4
4
|
import {
|
|
5
5
|
aggregateStepStatus,
|
|
6
6
|
contextModeBadge,
|
|
7
7
|
contextModeLabel,
|
|
8
8
|
contextModePrefix,
|
|
9
|
+
formatActivityAge,
|
|
9
10
|
formatActivityLabel,
|
|
10
11
|
formatAgentRunningLabel,
|
|
11
12
|
formatNestedAggregate,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
projectAsyncWorkflowRows,
|
|
22
23
|
projectWorkflowChecklist,
|
|
23
24
|
workflowGraphStageNodes
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
25
26
|
import {
|
|
26
27
|
isStaleExtensionContextError,
|
|
27
28
|
isUnboundExtensionRuntimeError,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
formatWorkflowJsonPreview,
|
|
34
35
|
hostStepReportName,
|
|
35
36
|
hostStepVerdictLabel
|
|
36
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-CPSUJHZE.js";
|
|
37
38
|
import {
|
|
38
39
|
snapshotExternalRuns
|
|
39
40
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -51,7 +52,7 @@ import {
|
|
|
51
52
|
getSingleResultOutput,
|
|
52
53
|
shortenPath,
|
|
53
54
|
unresolvedChildWatchdogBlockers
|
|
54
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-4MVDMA5C.js";
|
|
55
56
|
import {
|
|
56
57
|
MAX_WIDGET_JOBS,
|
|
57
58
|
WIDGET_ANIMATION_INTERVAL_MS,
|
|
@@ -636,6 +637,16 @@ function workflowLabelForResult(details, resultIndex) {
|
|
|
636
637
|
};
|
|
637
638
|
return details.workflowGraph ? visit(details.workflowGraph.nodes) : void 0;
|
|
638
639
|
}
|
|
640
|
+
function reportedProgressRow(progress, theme, indent, width) {
|
|
641
|
+
const text = progress.progressText?.trim();
|
|
642
|
+
if (!text) return void 0;
|
|
643
|
+
let updated = "";
|
|
644
|
+
if (progress.progressUpdatedAt !== void 0) {
|
|
645
|
+
const age = formatActivityAge(Math.max(0, Date.now() - progress.progressUpdatedAt));
|
|
646
|
+
updated = age === "now" ? " \xB7 updated now" : ` \xB7 updated ${age} ago`;
|
|
647
|
+
}
|
|
648
|
+
return truncLine(theme.fg("dim", `${indent}progress: ${sanitizeDisplayText(text)}${updated}`), width);
|
|
649
|
+
}
|
|
639
650
|
function foregroundProgressForResult(details, resultIndex) {
|
|
640
651
|
const result = details.results[resultIndex];
|
|
641
652
|
if (result?.progress) return result.progress;
|
|
@@ -907,6 +918,8 @@ function widgetStepRenderKey(step, index, expanded = false) {
|
|
|
907
918
|
step.workflowKey,
|
|
908
919
|
step.phase,
|
|
909
920
|
step.label,
|
|
921
|
+
step.progressText,
|
|
922
|
+
step.progressUpdatedAt,
|
|
910
923
|
step.status,
|
|
911
924
|
step.activityState,
|
|
912
925
|
step.lastActivityAt,
|
|
@@ -2002,6 +2015,8 @@ function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, tota
|
|
|
2002
2015
|
const task = fullTask ? void 0 : collapseDetails ? stepTaskSummary(step, displayName) : compactTaskText(step.description, step.label);
|
|
2003
2016
|
for (const line of fullTask ?? []) lines.push(`${detailIndent}${theme.fg("dim", line)}`);
|
|
2004
2017
|
if (task) lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
|
|
2018
|
+
const progressRow = step.status === "running" ? reportedProgressRow(step, theme, detailIndent, width - 4) : void 0;
|
|
2019
|
+
if (progressRow) lines.push(progressRow);
|
|
2005
2020
|
const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
|
|
2006
2021
|
const currentPath = options?.includeCurrentPath && step.currentPath ? shortenPath(step.currentPath) : void 0;
|
|
2007
2022
|
const activityWithPath = currentPath && activity && !activity.includes(currentPath) ? `${activity} \xB7 ${currentPath}` : activity ?? currentPath;
|
|
@@ -2126,12 +2141,14 @@ function compactSingleWidgetLines(job, theme, width, frame, projection = buildWo
|
|
|
2126
2141
|
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2127
2142
|
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2128
2143
|
const stepStats = widgetStepStats(theme, step, job.updatedAt);
|
|
2129
|
-
const activitySuffix = activity ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", activity)}` : "";
|
|
2130
2144
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2131
2145
|
const task = compactTaskText(step.description, step.label);
|
|
2132
2146
|
const taskSuffix = task ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2147
|
+
const activitySuffix = activity ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", activity)}` : "";
|
|
2133
2148
|
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
2134
2149
|
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame, thinking)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "\xB7")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "\xB7")} ${stepStats}` : ""}`);
|
|
2150
|
+
const progressRow = step.status === "running" ? reportedProgressRow(step, theme, " ", width) : void 0;
|
|
2151
|
+
if (progressRow) lines.push(progressRow);
|
|
2135
2152
|
const lane = projectAsyncLane(job, step);
|
|
2136
2153
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
2137
2154
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, false, job.updatedAt, 6)) lines.push(` ${nestedLine}`);
|
|
@@ -2699,6 +2716,8 @@ function renderSingleCompact(d, r, theme, layout, frame, foregroundDetachShortcu
|
|
|
2699
2716
|
if (isRunning && r.progress) {
|
|
2700
2717
|
const task = compactTaskText(r.task);
|
|
2701
2718
|
if (task) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2719
|
+
const reportedRow = reportedProgressRow(r.progress, theme, detailIndent, width);
|
|
2720
|
+
if (reportedRow) c.addChild(new Text(reportedRow, 0, 0));
|
|
2702
2721
|
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
2703
2722
|
const activity = compactCurrentActivity(r.progress);
|
|
2704
2723
|
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}\u23BF ${activity}`), width), 0, 0));
|
|
@@ -2936,6 +2955,8 @@ function renderMultiCompact(d, theme, layout, frame) {
|
|
|
2936
2955
|
const task = compactTaskText(r.task, workflowLabelForResult(d, i));
|
|
2937
2956
|
if (task) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2938
2957
|
}
|
|
2958
|
+
const reportedRow = rRunning && progressFromArray ? reportedProgressRow(progressFromArray, theme, detailIndent, width) : void 0;
|
|
2959
|
+
if (reportedRow) c.addChild(new Text(reportedRow, 0, 0));
|
|
2939
2960
|
if (rRunning && rProg && "status" in rProg) {
|
|
2940
2961
|
const liveProgress = rProg;
|
|
2941
2962
|
const activity = compactCurrentActivity(liveProgress);
|
|
@@ -3034,6 +3055,8 @@ function renderSubagentResult(result, options, theme, frame, rendererConfig, for
|
|
|
3034
3055
|
c2.addChild(new Text(fit2(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` \u23BF ${resultStatusLine(r, output)}`)), 0, 0));
|
|
3035
3056
|
}
|
|
3036
3057
|
if (isRunning && r.progress) {
|
|
3058
|
+
const reportedRow = reportedProgressRow(r.progress, theme, " ", w2);
|
|
3059
|
+
if (reportedRow) c2.addChild(new Text(fit2(reportedRow), 0, 0));
|
|
3037
3060
|
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
3038
3061
|
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w2, true, progressSnapshotNow, 12)) {
|
|
3039
3062
|
c2.addChild(new Text(fit2(` ${nestedLine}`), 0, 0));
|
|
@@ -3202,6 +3225,8 @@ function renderSubagentResult(result, options, theme, frame, rendererConfig, for
|
|
|
3202
3225
|
const taskMaxLen = Math.max(20, w - 12);
|
|
3203
3226
|
const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
|
|
3204
3227
|
c.addChild(new Text(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
|
|
3228
|
+
const reportedRow = rRunning && progressFromArray ? reportedProgressRow(progressFromArray, theme, " ", w) : void 0;
|
|
3229
|
+
if (reportedRow) c.addChild(new Text(fit(reportedRow), 0, 0));
|
|
3205
3230
|
const outputTarget = extractOutputTarget(r.task);
|
|
3206
3231
|
if (outputTarget) {
|
|
3207
3232
|
c.addChild(new Text(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "pi-subagents",
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.88.1",
|
|
5
5
|
private: true,
|
|
6
6
|
description: "Pi extension for single-agent delegation and scripted multi-agent workflows",
|
|
7
7
|
author: "Nico Bailon",
|
|
@@ -108,7 +108,7 @@ var package_default = {
|
|
|
108
108
|
"@js-temporal/polyfill": "0.5.1",
|
|
109
109
|
acorn: "8.18.0",
|
|
110
110
|
jiti: "2.7.0",
|
|
111
|
-
undici: "8.12.
|
|
111
|
+
undici: "8.12.4",
|
|
112
112
|
yaml: "2.8.3"
|
|
113
113
|
},
|
|
114
114
|
devDependencies: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isTrustedRecordedSessionFile,
|
|
3
3
|
resolveSubagentRunId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LV3CPYXJ.js";
|
|
5
5
|
import {
|
|
6
6
|
agentStreamOptions,
|
|
7
7
|
opencodeSessionHeaders,
|
|
8
8
|
resolveAsyncResumeTarget
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
10
10
|
import {
|
|
11
11
|
ownsRun
|
|
12
12
|
} from "./chunk-HXRB42AF.js";
|
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
reconcileAsyncRun,
|
|
19
19
|
resolveAuthorityDecision,
|
|
20
20
|
resolveMissionStoreLocation
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-CPSUJHZE.js";
|
|
22
22
|
import {
|
|
23
23
|
deliverInterruptRequest,
|
|
24
24
|
queueRevivalBrief,
|
|
25
25
|
requestAsyncSteer
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-W6HIYD2Z.js";
|
|
27
27
|
import {
|
|
28
28
|
formatShellCommand
|
|
29
29
|
} from "./chunk-7J4ZXMY7.js";
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
tryLease,
|
|
35
35
|
writeAtomicJson,
|
|
36
36
|
writePrivateAtomicJson
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-4MVDMA5C.js";
|
|
38
38
|
import {
|
|
39
39
|
DIRS
|
|
40
40
|
} from "./chunk-JEZOSEWG.js";
|
|
@@ -76,7 +76,7 @@ function recordSteeringRequest(status, input) {
|
|
|
76
76
|
requestedAt: input.requestedAt,
|
|
77
77
|
...input.source ? { source: input.source } : {},
|
|
78
78
|
messagePreview: steeringMessagePreview(input.message),
|
|
79
|
-
targets: input.targets.map((target) => ({ index: target.index, state: target.state, ...target.reason ? { reason: target.reason } : {} }))
|
|
79
|
+
targets: input.targets.map((target) => ({ index: target.index, state: target.state, ...target.reason ? { reason: target.reason } : {}, ...target.failureKind ? { failureKind: target.failureKind } : {} }))
|
|
80
80
|
};
|
|
81
81
|
status.requested++;
|
|
82
82
|
status.lastRequestedAt = input.requestedAt;
|
|
@@ -95,6 +95,8 @@ function updateSteeringTarget(status, requestId, index, state, now, fields = {})
|
|
|
95
95
|
const request = status.recent.find((candidate) => candidate.id === requestId);
|
|
96
96
|
const target = request?.targets.find((candidate) => candidate.index === index);
|
|
97
97
|
if (!target) return void 0;
|
|
98
|
+
if (state !== "failed") delete target.failureKind;
|
|
99
|
+
else if (fields.failureKind) target.failureKind = fields.failureKind;
|
|
98
100
|
if (state === "late" && target.state === "recovered") {
|
|
99
101
|
if (target.lateDeliveredAt === void 0) {
|
|
100
102
|
target.lateDeliveredAt = now;
|
|
@@ -144,6 +146,7 @@ function actionResultFromSteeringStatus(status, sourceRunId, requestId, replacem
|
|
|
144
146
|
...target.deliveredAt !== void 0 ? { deliveredAt: target.deliveredAt } : {},
|
|
145
147
|
...target.lateDeliveredAt !== void 0 ? { lateDeliveredAt: target.lateDeliveredAt } : {},
|
|
146
148
|
...target.reason ? { reason: target.reason } : {},
|
|
149
|
+
...target.failureKind ? { failureKind: target.failureKind } : {},
|
|
147
150
|
...target.replacementRunId ? { replacementRunId: target.replacementRunId } : {}
|
|
148
151
|
}));
|
|
149
152
|
const states = targets.map((target) => target.state);
|
|
@@ -240,6 +243,9 @@ function steerTargetsAccepted(result2) {
|
|
|
240
243
|
const targets = result2?.targets ?? [];
|
|
241
244
|
return targets.length > 0 && targets.every((target) => target.state === "queued" || target.state === "delivered");
|
|
242
245
|
}
|
|
246
|
+
function steerTargetsRejected(result2) {
|
|
247
|
+
return result2?.targets.some((target) => target.state === "failed" && target.failureKind === "rejected") === true;
|
|
248
|
+
}
|
|
243
249
|
function canQueueRetainedAsyncFollowUp(status, index) {
|
|
244
250
|
const steps = status.steps ?? [];
|
|
245
251
|
return status.state === "complete" && Boolean(status.parentWorkflowRunId) && steps.length === 1 && (steps[0]?.status === "complete" || steps[0]?.status === "completed") && Boolean(steps[0]?.sessionFile ?? status.sessionFile) && (index === void 0 || index === 0);
|
|
@@ -377,8 +383,10 @@ ${replies}` }],
|
|
|
377
383
|
if (input.signal?.aborted) {
|
|
378
384
|
return { content: [{ type: "text", text: steeringReceipt(input.message, `Steering pending for async run ${status.runId} (request ${requestId}); caller aborted before recovery.`) }], details: { mode: "management", results: [], steering: result2 } };
|
|
379
385
|
}
|
|
386
|
+
const projected = (current) => current?.steering ? actionResultFromSteeringStatus(current.steering, status.runId, requestId) : void 0;
|
|
387
|
+
const rejected = () => new Error(`Child rejected the guidance; continue it with action "resume" and id "${status.runId}".`);
|
|
380
388
|
const finalStatus = readStatus(asyncDir);
|
|
381
|
-
const finalResult =
|
|
389
|
+
const finalResult = projected(finalStatus);
|
|
382
390
|
const acceptedReply = (accepted) => {
|
|
383
391
|
const acceptedState = accepted.state === "delivered" ? "delivered" : "queued";
|
|
384
392
|
return { content: [{ type: "text", text: steeringReceipt(input.message, `Steering ${acceptedState} for async run ${status.runId} (request ${requestId}).`) }], details: { mode: "management", results: [], steering: accepted } };
|
|
@@ -386,7 +394,7 @@ ${replies}` }],
|
|
|
386
394
|
if (finalResult && steerTargetsAccepted(finalResult)) return acceptedReply(finalResult);
|
|
387
395
|
const running = (finalStatus?.steps ?? status.steps ?? []).filter((step) => step.status === "running");
|
|
388
396
|
const recoveryAllowed = (input.mode ?? "steer") === "steer" && status.mode === "single" && status.isNested !== true && running.length === 1 && Boolean(finalStatus?.steering) && (input.index === void 0 || input.index === 0);
|
|
389
|
-
if (recoveryAllowed && finalResult?.state !== "scheduled" && input.recover) {
|
|
397
|
+
if (recoveryAllowed && finalResult?.state !== "scheduled" && !steerTargetsRejected(finalResult) && input.recover) {
|
|
390
398
|
const appendSteeringNotice = (state, message) => {
|
|
391
399
|
try {
|
|
392
400
|
fs2.appendFileSync(path2.join(asyncDir, "events.jsonl"), `${JSON.stringify({ type: "subagent.steering.notice", ts: Date.now(), runId: status.runId, requestId, state, message, ...status.sessionId ? { currentSessionId: status.sessionId } : {} })}
|
|
@@ -395,18 +403,18 @@ ${replies}` }],
|
|
|
395
403
|
}
|
|
396
404
|
};
|
|
397
405
|
try {
|
|
398
|
-
const
|
|
399
|
-
const latestResult = latest?.steering ? actionResultFromSteeringStatus(latest.steering, status.runId, requestId) : void 0;
|
|
406
|
+
const latestResult = projected(readStatus(asyncDir));
|
|
400
407
|
if (latestResult && steerTargetsAccepted(latestResult)) return acceptedReply(latestResult);
|
|
408
|
+
if (steerTargetsRejected(latestResult)) throw rejected();
|
|
401
409
|
const committedAt = Date.now();
|
|
402
410
|
input.onBeforeRecoveryClaim?.(requestId, committedAt);
|
|
403
411
|
const { claimPath, markerPath } = claimSteeringRecovery(asyncDir, { requestId, sourceRunId: status.runId, committedAt });
|
|
404
412
|
input.onRecoveryCommitted?.(requestId, committedAt);
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
if (preCommitResult && preCommitResult.targets.length > 0 && preCommitResult.targets.every((target) => target.state === "queued" || target.deliveredAt !== void 0 && target.deliveredAt <= committedAt)) {
|
|
413
|
+
const preCommitResult = projected(readStatus(asyncDir));
|
|
414
|
+
if (preCommitResult && (steerTargetsRejected(preCommitResult) || preCommitResult.targets.length > 0 && preCommitResult.targets.every((target) => target.state === "queued" || target.deliveredAt !== void 0 && target.deliveredAt <= committedAt))) {
|
|
408
415
|
fs2.rmSync(markerPath, { force: true });
|
|
409
416
|
fs2.rmSync(claimPath, { force: true });
|
|
417
|
+
if (steerTargetsRejected(preCommitResult)) throw rejected();
|
|
410
418
|
return acceptedReply(preCommitResult);
|
|
411
419
|
}
|
|
412
420
|
try {
|
|
@@ -424,6 +432,10 @@ ${replies}` }],
|
|
|
424
432
|
if (input.signal?.aborted) break;
|
|
425
433
|
const candidate = readStatus(asyncDir);
|
|
426
434
|
lastObservedState = candidate?.state;
|
|
435
|
+
if (steerTargetsRejected(projected(candidate))) {
|
|
436
|
+
fs2.rmSync(claimPath, { force: true });
|
|
437
|
+
throw rejected();
|
|
438
|
+
}
|
|
427
439
|
if (candidate?.state === "paused" && candidate.endedAt !== void 0) {
|
|
428
440
|
paused = candidate;
|
|
429
441
|
break;
|
|
@@ -447,6 +459,10 @@ ${replies}` }],
|
|
|
447
459
|
if (recoveryTarget.kind !== "revive" || !recoveryTarget.sessionFile) throw new Error("Source run has no valid persisted child session; it remains paused and requires a new run.");
|
|
448
460
|
if (!recoveryTarget.recoveryDescriptor) throw new Error("Source run has no private recovery descriptor; it remains paused and is not safely resumable.");
|
|
449
461
|
const limits = remainingSteeringRecoveryLimits(recoveryTarget.recoveryDescriptor, paused);
|
|
462
|
+
if (steerTargetsRejected(projected(readStatus(asyncDir)))) {
|
|
463
|
+
fs2.rmSync(claimPath, { force: true });
|
|
464
|
+
throw rejected();
|
|
465
|
+
}
|
|
450
466
|
const revived = await input.recover(limits);
|
|
451
467
|
if (revived.isError || !revived.details.asyncId) throw new Error(revived.content[0]?.type === "text" ? revived.content[0].text : "Replacement launch failed; source run remains paused.");
|
|
452
468
|
const targetIndex = input.index ?? paused.steering?.recent.find((request) => request.id === requestId)?.targets[0]?.index ?? status.steps?.findIndex((step) => step.status === "running") ?? -1;
|
|
@@ -470,7 +486,7 @@ ${replies}` }],
|
|
|
470
486
|
failedStatus.activityState = "needs_attention";
|
|
471
487
|
writeAtomicJson(path2.join(asyncDir, "status.json"), failedStatus);
|
|
472
488
|
}
|
|
473
|
-
const failed =
|
|
489
|
+
const failed = projected(failedStatus);
|
|
474
490
|
appendSteeringNotice("failed", `Steering failed for run ${status.runId}: ${reason}`);
|
|
475
491
|
return { content: [{ type: "text", text: steeringReceipt(input.message, `Steering failed for async run ${status.runId} (request ${requestId}): ${reason}`) }], isError: true, details: { mode: "management", results: [], steering: failed ?? { requestId, state: "failed", sourceRunId: status.runId, deliveryStatus: "queued", targets: [{ index: input.index ?? 0, state: "failed", reason }] } } };
|
|
476
492
|
}
|
|
@@ -1085,6 +1101,7 @@ async function rewritePromptWithGuidance(input) {
|
|
|
1085
1101
|
});
|
|
1086
1102
|
const ctxThinking = input.ctx.getThinkingLevel?.();
|
|
1087
1103
|
const agent = new Agent({
|
|
1104
|
+
sessionId,
|
|
1088
1105
|
initialState: {
|
|
1089
1106
|
systemPrompt: [
|
|
1090
1107
|
"Rewrite one subagent authored task from Prompt Audit context.",
|
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
resolveCurrentSessionId,
|
|
15
15
|
resolveWatchdogReviewModel,
|
|
16
16
|
startWatchdogDiffBaselineCapture
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-IYT7X46U.js";
|
|
18
18
|
import {
|
|
19
19
|
agentStreamOptions,
|
|
20
20
|
opencodeSessionHeaders
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-4ZQBZDF3.js";
|
|
22
22
|
import {
|
|
23
23
|
registerNativeSupervisorClient
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-CYKNHFXB.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-CPSUJHZE.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-4MVDMA5C.js";
|
|
50
50
|
import {
|
|
51
51
|
INTERCOM_SESSION_IDENTITY_EVENT
|
|
52
52
|
} from "./chunk-JEZOSEWG.js";
|
|
@@ -295,6 +295,7 @@ function createWatchdogPermissionArbiter(options = {}) {
|
|
|
295
295
|
].join("\n");
|
|
296
296
|
const tools = [tool];
|
|
297
297
|
agent = new Agent({
|
|
298
|
+
sessionId,
|
|
298
299
|
initialState: {
|
|
299
300
|
systemPrompt,
|
|
300
301
|
model: selection.model,
|
|
@@ -584,6 +585,11 @@ function modelBefore(messages, forkedAt) {
|
|
|
584
585
|
return void 0;
|
|
585
586
|
}
|
|
586
587
|
var LOADOUT_SECTIONS = /* @__PURE__ */ new Set(["tools", "rules", "docs", "skills", "advertised_subagents", "mcp_servers", "project_context"]);
|
|
588
|
+
function projectInstructionBlocks(section) {
|
|
589
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
590
|
+
for (const match of (section ?? "").matchAll(/<project_instructions\s+path=(["'])(.*?)\1\s*>[\s\S]*?<\/project_instructions>/gi)) blocks.set(match[2], match[0]);
|
|
591
|
+
return blocks;
|
|
592
|
+
}
|
|
587
593
|
function forkInstructions(input) {
|
|
588
594
|
const parent = getCurrentSystemMessage(input.parent);
|
|
589
595
|
const child = getCurrentSystemMessage(input.child);
|
|
@@ -596,6 +602,9 @@ function forkInstructions(input) {
|
|
|
596
602
|
for (const [name, value] of Object.entries(child?.sections ?? {})) {
|
|
597
603
|
if (!LOADOUT_SECTIONS.has(name) && value && parent?.sections?.[name] !== value) parts.push(value);
|
|
598
604
|
}
|
|
605
|
+
const parentFiles = projectInstructionBlocks(parent?.sections?.project_context);
|
|
606
|
+
const missingFiles = [...projectInstructionBlocks(child?.sections?.project_context)].filter(([filePath]) => !parentFiles.has(filePath)).map(([, block]) => block);
|
|
607
|
+
if (missingFiles.length > 0) parts.push(["Project instructions for your working folder, which the parent's prompt does not include:", ...missingFiles].join("\n\n"));
|
|
599
608
|
if (input.boundary) parts.push(input.boundary);
|
|
600
609
|
return `<subagent_instructions>
|
|
601
610
|
${parts.join("\n\n")}
|