pi-subagents 0.89.1 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/bundle/agents.js +4 -4
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-SG3NCWZW.js → chunk-2LEBXCLU.js} +29 -19
- package/bundle/{chunk-UUW7P6KJ.js → chunk-37EJGDYO.js} +2 -2
- package/bundle/{chunk-IGZTXGPG.js → chunk-4DA22WRU.js} +59 -30
- package/bundle/{chunk-77VQEATI.js → chunk-5J2RTMKW.js} +2 -2
- package/bundle/{chunk-7J4ZXMY7.js → chunk-72334PEI.js} +6 -4
- package/bundle/{chunk-F6PTAPQ3.js → chunk-7HPZIT4W.js} +13 -13
- package/bundle/{chunk-SWGB2P5J.js → chunk-7Y4IJMCW.js} +1 -1
- package/bundle/{chunk-TRN65L4F.js → chunk-ACTHBJUI.js} +1 -1
- package/bundle/{chunk-6D54VW3E.js → chunk-AJWRYQPH.js} +145 -76
- package/bundle/{chunk-TXC7WIPL.js → chunk-C45WQQZX.js} +1 -1
- package/bundle/{chunk-YJIU5WF4.js → chunk-CPWZN5KM.js} +1 -1
- package/bundle/{chunk-BERAWSQQ.js → chunk-DNJ2GHSI.js} +7 -7
- package/bundle/{chunk-CASL47ST.js → chunk-EBGTTJKP.js} +6 -6
- package/bundle/{chunk-LWH7IGI3.js → chunk-F4NSLXB2.js} +8 -6
- package/bundle/{chunk-URKQZHVH.js → chunk-G43SW4BT.js} +29 -19
- package/bundle/{chunk-Q4VH72JI.js → chunk-KNVQTRSY.js} +2 -2
- package/bundle/{chunk-5TXWZB73.js → chunk-P2M6RIVX.js} +1 -1
- package/bundle/{chunk-ROJH7KPK.js → chunk-PSB3VLMH.js} +2 -2
- package/bundle/{chunk-VEEUXJDO.js → chunk-PTN7XAXI.js} +2 -2
- package/bundle/{chunk-TDXVQPZW.js → chunk-RIBMW6V3.js} +69 -15
- package/bundle/{chunk-KCDPTXHT.js → chunk-SIB2GQHL.js} +238 -200
- package/bundle/{chunk-JEZOSEWG.js → chunk-SRWJIAIP.js} +2 -0
- package/bundle/{chunk-OUM6SEVD.js → chunk-UC22RDXP.js} +8 -4
- package/bundle/{chunk-W2BZS6UC.js → chunk-VMJGZHUL.js} +9 -5
- package/bundle/{chunk-MIX3MCIF.js → chunk-WANQBKAZ.js} +12 -7
- package/bundle/{chunk-LUNVS6KP.js → chunk-WHHRG32M.js} +27 -20
- package/bundle/{chunk-C22YEYFZ.js → chunk-XIQKWTFY.js} +5 -5
- package/bundle/{chunk-YLU5JFW2.js → chunk-XYIVVS3A.js} +7 -3
- package/bundle/{chunk-R3NH5XAL.js → chunk-YVDKGAEO.js} +5 -4
- package/bundle/{chunk-4FFKVLBG.js → chunk-ZWGOHOGI.js} +5 -5
- package/bundle/control-channel.js +3 -3
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +3 -3
- package/bundle/preflight.js +13 -11
- package/bundle/project-panes.js +5 -5
- package/bundle/shared-types.js +1 -1
- package/bundle/workflow-resources.js +1 -1
- package/docs/configuration.md +12 -3
- package/docs/models.md +1 -1
- package/docs/observability.md +10 -2
- package/docs/tool-reference.md +5 -2
- package/docs/watchdog.md +3 -2
- package/docs/workflows.md +1 -1
- package/package.json +1 -1
- package/skills/pi-subagents/SKILL.md +1 -1
- package/src/agents/agents.d.ts +2 -0
- package/src/agents/agents.js +4 -0
- package/src/api/preflight.d.ts +1 -0
- package/src/api/preflight.js +2 -1
- package/src/extension/config.js +3 -0
- package/src/extension/public-execution.js +4 -2
- package/src/extension/reply-workflow-script.js +10 -1
- package/src/extension/schemas.d.ts +1 -0
- package/src/extension/schemas.js +2 -0
- package/src/extension/subagent-options.d.ts +2 -0
- package/src/extension/subagent-options.js +10 -4
- package/src/inspectors/herdr/project-panes.d.ts +2 -0
- package/src/inspectors/herdr/project-panes.js +7 -1
- package/src/inspectors/shell-command.d.ts +2 -1
- package/src/inspectors/shell-command.js +7 -5
- package/src/runs/background/active-async-capacity.js +2 -1
- package/src/runs/background/active-run-index.d.ts +1 -0
- package/src/runs/background/active-run-index.js +3 -0
- package/src/runs/background/async-execution.d.ts +2 -0
- package/src/runs/background/async-execution.js +6 -3
- package/src/runs/background/async-retention.js +48 -12
- package/src/runs/background/async-status.js +32 -17
- package/src/runs/background/process-terminal.d.ts +6 -0
- package/src/runs/background/process-terminal.js +34 -2
- package/src/runs/background/retained-children.js +1 -1
- package/src/runs/background/run-status.js +2 -1
- package/src/runs/background/stale-run-reconciler.d.ts +8 -0
- package/src/runs/background/stale-run-reconciler.js +38 -8
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +4 -4
- package/src/runs/foreground/execution.js +7 -9
- package/src/runs/foreground/subagent-executor.d.ts +2 -0
- package/src/runs/foreground/subagent-executor.js +129 -45
- package/src/runs/shared/fast-mode-extension.d.ts +2 -1
- package/src/runs/shared/fast-mode-extension.js +5 -3
- package/src/runs/shared/herdr-pane-host.js +10 -2
- package/src/runs/shared/mcp-config-sources.d.ts +1 -0
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js +1 -0
- package/src/shared/capacity-resilient-json.d.ts +7 -3
- package/src/shared/capacity-resilient-json.js +8 -6
- package/src/shared/disabled-features.d.ts +4 -0
- package/src/shared/disabled-features.js +1 -0
- package/src/shared/types.d.ts +19 -0
- package/src/shared/types.js +2 -0
- package/src/tui/fleet-transcript.js +21 -9
- package/src/tui/fleet.js +1 -0
- package/src/watchdog/runtime.d.ts +4 -0
- package/src/watchdog/runtime.js +50 -12
- package/src/watchdog/turn-delta.d.ts +2 -0
- package/src/watchdog/turn-delta.js +21 -0
- package/src/workflows/structured-workflow-scripts.js +6 -4
- package/src/workflows/workflow-resources.js +4 -2
- package/src/workflows/workflow-revival.d.ts +6 -0
- package/src/workflows/workflow-revival.js +1 -1
|
@@ -39,8 +39,17 @@ function renderExpandedTool(event, width, theme) {
|
|
|
39
39
|
const output = event.output ?? event.error;
|
|
40
40
|
const outputColor = event.status === "error" ? "error" : "toolOutput";
|
|
41
41
|
if (event.name === "bash") {
|
|
42
|
-
const command = jsonScalar(args?.command)
|
|
43
|
-
|
|
42
|
+
const command = jsonScalar(args?.command);
|
|
43
|
+
let first = true;
|
|
44
|
+
for (const commandLine of (command ?? event.args ?? "(unknown command)").split(/\r?\n/)) {
|
|
45
|
+
for (const wrapped of renderWrapped(theme.fg("toolTitle", theme.bold(first ? `$ ${commandLine}` : commandLine)), Math.max(1, width - 4))) {
|
|
46
|
+
lines.push(railLine(`${first ? glyph : " "} ${wrapped}`, width, theme));
|
|
47
|
+
first = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// An unparseable payload was cut at the transcript size cap; show it raw so its truncation marker is visible.
|
|
51
|
+
if (command === undefined && !args && event.argsPayload)
|
|
52
|
+
lines.push(...renderArgsPayload(event.argsPayload, width, theme));
|
|
44
53
|
if (output) {
|
|
45
54
|
for (const outputLine of output.replace(/\s+$/, "").split(/\r?\n/)) {
|
|
46
55
|
for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) {
|
|
@@ -71,13 +80,8 @@ function renderExpandedTool(event, width, theme) {
|
|
|
71
80
|
return lines;
|
|
72
81
|
}
|
|
73
82
|
lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(event.name))}`, width, theme));
|
|
74
|
-
if (event.argsPayload)
|
|
75
|
-
lines.push(
|
|
76
|
-
for (const argLine of event.argsPayload.split(/\r?\n/)) {
|
|
77
|
-
for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4)))
|
|
78
|
-
lines.push(railLine(` ${wrapped}`, width, theme));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
83
|
+
if (event.argsPayload)
|
|
84
|
+
lines.push(...renderArgsPayload(event.argsPayload, width, theme));
|
|
81
85
|
if (output) {
|
|
82
86
|
lines.push(railLine(theme.fg(event.status === "error" ? "error" : "dim", event.status === "error" ? " error" : " output"), width, theme));
|
|
83
87
|
for (const outputLine of output.split(/\r?\n/)) {
|
|
@@ -90,6 +94,14 @@ function renderExpandedTool(event, width, theme) {
|
|
|
90
94
|
function bounded(text, width) {
|
|
91
95
|
return truncateToWidth(text, Math.max(0, width));
|
|
92
96
|
}
|
|
97
|
+
function renderArgsPayload(payload, width, theme) {
|
|
98
|
+
const lines = [railLine(theme.fg("dim", " args"), width, theme)];
|
|
99
|
+
for (const argLine of payload.split(/\r?\n/)) {
|
|
100
|
+
for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4)))
|
|
101
|
+
lines.push(railLine(` ${wrapped}`, width, theme));
|
|
102
|
+
}
|
|
103
|
+
return lines;
|
|
104
|
+
}
|
|
93
105
|
function railLine(content, width, theme) {
|
|
94
106
|
return bounded(`${theme.fg("borderMuted", "│")} ${content}`, width);
|
|
95
107
|
}
|
package/src/tui/fleet.js
CHANGED
|
@@ -224,6 +224,7 @@ export function collectFleetSnapshot(state, options = {}) {
|
|
|
224
224
|
entryLimit: MAX_FLEET_HISTORY_CANDIDATES,
|
|
225
225
|
resultsDir: options.resultsDir ?? DIRS.results,
|
|
226
226
|
reconcile: false,
|
|
227
|
+
includeNested: false,
|
|
227
228
|
onCorruptStatus: (warning) => reportSessionWarning(state, warning),
|
|
228
229
|
}).filter((run) => !trackedIds.has(run.id));
|
|
229
230
|
runs = [...trackedRuns, ...history];
|
|
@@ -92,6 +92,7 @@ export declare class MainWatchdogRuntime {
|
|
|
92
92
|
private status;
|
|
93
93
|
private pendingDeltas;
|
|
94
94
|
private pendingDeltaChars;
|
|
95
|
+
private omittedDeltaChars;
|
|
95
96
|
private guard;
|
|
96
97
|
private guardMaxWarnings;
|
|
97
98
|
private epoch;
|
|
@@ -130,6 +131,7 @@ export declare class MainWatchdogRuntime {
|
|
|
130
131
|
private activityTail;
|
|
131
132
|
private activityPending;
|
|
132
133
|
private activityReviewUsed;
|
|
134
|
+
private supervisorReplies;
|
|
133
135
|
constructor(options?: MainWatchdogRuntimeOptions);
|
|
134
136
|
bindSession(ctx: ContextLike): void;
|
|
135
137
|
refreshConfig(cwd?: string): WatchdogSettingsResult;
|
|
@@ -182,7 +184,9 @@ export declare class MainWatchdogRuntime {
|
|
|
182
184
|
private collectLspDiagnostics;
|
|
183
185
|
private lspSnapshot;
|
|
184
186
|
private appendBoundedDelta;
|
|
187
|
+
private retainSupervisorReplies;
|
|
185
188
|
private buildReviewInput;
|
|
189
|
+
private boundDeltaInput;
|
|
186
190
|
private scopeBlock;
|
|
187
191
|
private clearPendingDeltas;
|
|
188
192
|
private clearActivity;
|
package/src/watchdog/runtime.js
CHANGED
|
@@ -5,13 +5,15 @@ import { collectWatchdogLspDiagnostics, formatWatchdogLspDiagnosticsBlock, Watch
|
|
|
5
5
|
import { ruleViolationWarning } from "./rules.js";
|
|
6
6
|
import { WatchdogScopeArtifact } from "./scope.js";
|
|
7
7
|
import { resolveWatchdogConfig } from "./settings.js";
|
|
8
|
-
import { formatWatchdogOrchestrationActivity, formatWatchdogTurnDelta } from "./turn-delta.js";
|
|
8
|
+
import { formatWatchdogOrchestrationActivity, formatWatchdogSupervisorReplies, formatWatchdogTurnDelta } from "./turn-delta.js";
|
|
9
9
|
import { WATCHDOG_WARNING_IMPORTANCES, } from "./types.js";
|
|
10
10
|
import { normalizeWatchdogWarningDetails } from "./warning-format.js";
|
|
11
11
|
const DEFAULT_REVIEW = () => ({ warnings: [] });
|
|
12
12
|
const MAX_REVIEW_INPUT_CHARS = 24_000;
|
|
13
13
|
const REVIEW_INPUT_HEAD_CHARS = 6_000;
|
|
14
14
|
const REVIEW_DELTA_SEPARATOR = "\n\n---\n\n";
|
|
15
|
+
const MAX_SUPERVISOR_REPLY_CHARS = 3_000;
|
|
16
|
+
const MAX_SUPERVISOR_REPLIES_CHARS = 6_000;
|
|
15
17
|
export function boundWatchdogReviewText(text, cap = MAX_REVIEW_INPUT_CHARS) {
|
|
16
18
|
if (text.length <= cap)
|
|
17
19
|
return text;
|
|
@@ -19,6 +21,13 @@ export function boundWatchdogReviewText(text, cap = MAX_REVIEW_INPUT_CHARS) {
|
|
|
19
21
|
const marker = `\n\n[... about ${text.length - cap} characters omitted ...]\n\n`;
|
|
20
22
|
return `${text.slice(0, head)}${marker}${text.slice(text.length - (cap - head - marker.length))}`;
|
|
21
23
|
}
|
|
24
|
+
// The reviewer must not read missing text as proof that an instruction or authorization never happened.
|
|
25
|
+
function omittedDeltaNote(chars) {
|
|
26
|
+
return `[Parts of this run's turn delta omitted: about ${chars} characters are not shown, to fit the review input limit. Do not report an instruction, authorization, or action as absent unless the supplied evidence shows it; it may be in an omitted part.]`;
|
|
27
|
+
}
|
|
28
|
+
const OMITTED_NOTE_RESERVE = omittedDeltaNote(Number.MAX_SAFE_INTEGER).length + 2;
|
|
29
|
+
// Retained delta leaves room for the note, so a note never forces a second cut of the delta.
|
|
30
|
+
const MAX_RETAINED_DELTA_CHARS = MAX_REVIEW_INPUT_CHARS - OMITTED_NOTE_RESERVE;
|
|
22
31
|
function errorMessage(error) {
|
|
23
32
|
return error instanceof Error ? error.message : String(error);
|
|
24
33
|
}
|
|
@@ -52,6 +61,7 @@ export class MainWatchdogRuntime {
|
|
|
52
61
|
status = "idle";
|
|
53
62
|
pendingDeltas = [];
|
|
54
63
|
pendingDeltaChars = 0;
|
|
64
|
+
omittedDeltaChars = 0;
|
|
55
65
|
guard = new WatchdogEmissionGuard();
|
|
56
66
|
guardMaxWarnings = null;
|
|
57
67
|
epoch = 0;
|
|
@@ -90,6 +100,7 @@ export class MainWatchdogRuntime {
|
|
|
90
100
|
activityTail = "";
|
|
91
101
|
activityPending = false;
|
|
92
102
|
activityReviewUsed = false;
|
|
103
|
+
supervisorReplies = [];
|
|
93
104
|
constructor(options = {}) {
|
|
94
105
|
this.cwd = options.cwd ?? process.cwd();
|
|
95
106
|
this.resolveConfig = options.resolveConfig ?? resolveWatchdogConfig;
|
|
@@ -201,8 +212,10 @@ export class MainWatchdogRuntime {
|
|
|
201
212
|
this.lspLedger.reset();
|
|
202
213
|
this.lastLspSnapshot = undefined;
|
|
203
214
|
}
|
|
204
|
-
if (options.clearScope)
|
|
215
|
+
if (options.clearScope) {
|
|
205
216
|
this.scope.reset();
|
|
217
|
+
this.supervisorReplies = [];
|
|
218
|
+
}
|
|
206
219
|
if (options.clearScope || options.clearActivity)
|
|
207
220
|
this.clearActivity();
|
|
208
221
|
if (options.clearReviewInputSignature)
|
|
@@ -229,6 +242,7 @@ export class MainWatchdogRuntime {
|
|
|
229
242
|
this.lastLspSnapshot = undefined;
|
|
230
243
|
this.lspLedger.reset();
|
|
231
244
|
this.scope.reset();
|
|
245
|
+
this.supervisorReplies = [];
|
|
232
246
|
this.observedRepoEditThisTurn = false;
|
|
233
247
|
this.toolResultsThisRun = 0;
|
|
234
248
|
this.midRunReviewing = false;
|
|
@@ -267,6 +281,7 @@ export class MainWatchdogRuntime {
|
|
|
267
281
|
this.activityPending = true;
|
|
268
282
|
}
|
|
269
283
|
}
|
|
284
|
+
this.retainSupervisorReplies(event);
|
|
270
285
|
this.observedRepoEditThisTurn ||= eventIndicatesRepoEdit(event);
|
|
271
286
|
const delta = formatWatchdogTurnDelta({
|
|
272
287
|
includeUserPrompt: this.includeUserPromptInNextDelta,
|
|
@@ -779,16 +794,28 @@ export class MainWatchdogRuntime {
|
|
|
779
794
|
let entry = delta.trim();
|
|
780
795
|
if (!entry)
|
|
781
796
|
return;
|
|
782
|
-
if (entry.length >
|
|
783
|
-
entry
|
|
797
|
+
if (entry.length > MAX_RETAINED_DELTA_CHARS) {
|
|
798
|
+
this.omittedDeltaChars += entry.length - MAX_RETAINED_DELTA_CHARS;
|
|
799
|
+
entry = boundWatchdogReviewText(entry, MAX_RETAINED_DELTA_CHARS);
|
|
800
|
+
}
|
|
784
801
|
this.pendingDeltas.push(entry);
|
|
785
802
|
this.pendingDeltaChars += entry.length;
|
|
786
|
-
while (this.pendingDeltas.length > 1 && this.pendingDeltaChars + (this.pendingDeltas.length - 1) * REVIEW_DELTA_SEPARATOR.length >
|
|
803
|
+
while (this.pendingDeltas.length > 1 && this.pendingDeltaChars + (this.pendingDeltas.length - 1) * REVIEW_DELTA_SEPARATOR.length > MAX_RETAINED_DELTA_CHARS) {
|
|
787
804
|
const removed = this.pendingDeltas.shift();
|
|
788
|
-
if (removed)
|
|
805
|
+
if (removed) {
|
|
789
806
|
this.pendingDeltaChars -= removed.length;
|
|
807
|
+
this.omittedDeltaChars += removed.length;
|
|
808
|
+
}
|
|
790
809
|
}
|
|
791
810
|
}
|
|
811
|
+
// Kept outside the rolling delta so a long run cannot push the supervisor's instruction out of the review input.
|
|
812
|
+
retainSupervisorReplies(event) {
|
|
813
|
+
for (const reply of formatWatchdogSupervisorReplies(event))
|
|
814
|
+
this.supervisorReplies.push(boundWatchdogReviewText(reply, MAX_SUPERVISOR_REPLY_CHARS));
|
|
815
|
+
let total = this.supervisorReplies.reduce((sum, reply) => sum + reply.length, 0);
|
|
816
|
+
while (this.supervisorReplies.length > 1 && total > MAX_SUPERVISOR_REPLIES_CHARS)
|
|
817
|
+
total -= this.supervisorReplies.shift().length;
|
|
818
|
+
}
|
|
792
819
|
buildReviewInput(changeSignature, lspBlock = "") {
|
|
793
820
|
const input = this.pendingDeltas.join(REVIEW_DELTA_SEPARATOR);
|
|
794
821
|
const scopeBlock = this.scopeBlock();
|
|
@@ -796,25 +823,36 @@ export class MainWatchdogRuntime {
|
|
|
796
823
|
? ["Changed repo paths: every dirty path in the working tree. Authorship is not verified; a path may predate this session or come from another session.", ...changeSignature.changedPaths.slice(0, 200).map((file) => `- ${file}`)].join("\n")
|
|
797
824
|
: "";
|
|
798
825
|
const activity = this.activityTail ? `Recent delivered orchestration activity (oldest first; bounded observations, not a task board; waits/holds are not evidence of neglect):\n${this.activityTail}` : "";
|
|
826
|
+
const supervisor = this.configResult.config.scope.enabled && this.supervisorReplies.length
|
|
827
|
+
? `Supervisor replies this agent received through contact_supervisor (oldest first; the orchestrator's answers to this agent's questions, which can authorize or redirect its work):\n${this.supervisorReplies.join(REVIEW_DELTA_SEPARATOR)}`
|
|
828
|
+
: "";
|
|
799
829
|
const contextPieces = [scopeBlock, changes, lspBlock, activity].filter(Boolean);
|
|
800
|
-
if (!contextPieces.length)
|
|
801
|
-
return
|
|
830
|
+
if (!contextPieces.length && !supervisor)
|
|
831
|
+
return this.boundDeltaInput(input, MAX_REVIEW_INPUT_CHARS);
|
|
802
832
|
const maxContextLength = Math.floor(MAX_REVIEW_INPUT_CHARS / 2);
|
|
803
833
|
const maxPieceLength = Math.max(1_000, Math.floor(maxContextLength / contextPieces.length));
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
834
|
+
// Supervisor replies are already bounded to whole entries at retention; a second head+tail cut would drop whole replies.
|
|
835
|
+
const boundedContext = [...contextPieces.map((piece) => piece.length > maxPieceLength
|
|
836
|
+
? piece === activity ? boundWatchdogReviewText(piece, maxPieceLength) : `${piece.slice(0, maxPieceLength - 6)}\n- ...`
|
|
837
|
+
: piece), supervisor].filter(Boolean).join(REVIEW_DELTA_SEPARATOR);
|
|
807
838
|
const separatorLength = input ? REVIEW_DELTA_SEPARATOR.length : 0;
|
|
808
839
|
const inputBudget = MAX_REVIEW_INPUT_CHARS - boundedContext.length - separatorLength;
|
|
809
|
-
const boundedInput = inputBudget <= 0 ? "" :
|
|
840
|
+
const boundedInput = inputBudget <= 0 ? "" : this.boundDeltaInput(input, inputBudget);
|
|
810
841
|
return [boundedContext, boundedInput].filter(Boolean).join(REVIEW_DELTA_SEPARATOR);
|
|
811
842
|
}
|
|
843
|
+
boundDeltaInput(input, cap) {
|
|
844
|
+
if (!input || (this.omittedDeltaChars === 0 && input.length <= cap))
|
|
845
|
+
return input;
|
|
846
|
+
const bodyCap = cap - OMITTED_NOTE_RESERVE;
|
|
847
|
+
return `${omittedDeltaNote(this.omittedDeltaChars + Math.max(0, input.length - bodyCap))}\n\n${boundWatchdogReviewText(input, bodyCap)}`;
|
|
848
|
+
}
|
|
812
849
|
scopeBlock() {
|
|
813
850
|
return this.configResult.config.scope.enabled ? this.scope.render() : "";
|
|
814
851
|
}
|
|
815
852
|
clearPendingDeltas() {
|
|
816
853
|
this.pendingDeltas = [];
|
|
817
854
|
this.pendingDeltaChars = 0;
|
|
855
|
+
this.omittedDeltaChars = 0;
|
|
818
856
|
}
|
|
819
857
|
clearActivity() {
|
|
820
858
|
if (!this.activityTail)
|
|
@@ -13,3 +13,5 @@ export declare function formatWatchdogReviewMessage(message: unknown, options?:
|
|
|
13
13
|
export declare function formatWatchdogTurnDelta(input: WatchdogTurnDeltaInput): string;
|
|
14
14
|
/** Only completed, exactly paired native orchestration calls are activity evidence. */
|
|
15
15
|
export declare function formatWatchdogOrchestrationActivity(event: unknown): string;
|
|
16
|
+
/** A supervisor reply arrives as a tool result, never as a user prompt, so scope alone never records it. */
|
|
17
|
+
export declare function formatWatchdogSupervisorReplies(event: unknown): string[];
|
|
@@ -187,3 +187,24 @@ export function formatWatchdogOrchestrationActivity(event) {
|
|
|
187
187
|
}
|
|
188
188
|
return sections.join("\n\n");
|
|
189
189
|
}
|
|
190
|
+
/** A supervisor reply arrives as a tool result, never as a user prompt, so scope alone never records it. */
|
|
191
|
+
export function formatWatchdogSupervisorReplies(event) {
|
|
192
|
+
const turn = event;
|
|
193
|
+
if (turn?.type !== "turn_end" || !Array.isArray(turn.message?.content) || !Array.isArray(turn.toolResults))
|
|
194
|
+
return [];
|
|
195
|
+
const entries = [];
|
|
196
|
+
for (const call of turn.message.content) {
|
|
197
|
+
if (call?.type !== "toolCall" || call.name !== "contact_supervisor" || typeof call.id !== "string")
|
|
198
|
+
continue;
|
|
199
|
+
const args = call.arguments;
|
|
200
|
+
if (!args || typeof args !== "object" || !["need_decision", "interview_request"].includes(args.reason))
|
|
201
|
+
continue;
|
|
202
|
+
const result = turn.toolResults.find((value) => {
|
|
203
|
+
const result = value;
|
|
204
|
+
return result?.role === "toolResult" && result.toolCallId === call.id && result.toolName === call.name && result.isError !== true && !result.error;
|
|
205
|
+
});
|
|
206
|
+
if (result)
|
|
207
|
+
entries.push([formatToolCall(call.name, args), formatWatchdogReviewMessage(result) ?? ""].join("\n\n"));
|
|
208
|
+
}
|
|
209
|
+
return entries;
|
|
210
|
+
}
|
|
@@ -7,6 +7,8 @@ const OUTPUT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
|
7
7
|
const PLACEHOLDER_PATTERN = /\{(?:task|previous|outputs\.([A-Za-z_][A-Za-z0-9_]*))\}/g;
|
|
8
8
|
/** Optional per-child launch fields copied verbatim onto the generated runs.all item. */
|
|
9
9
|
const CHILD_FIELDS = ["cwd", "model"];
|
|
10
|
+
/** tasks items also take a label, which names the child the way a runs.all item's label does. */
|
|
11
|
+
const TASK_FIELDS = [...CHILD_FIELDS, "label"];
|
|
10
12
|
// Outer subagent-call controls that default onto every workflow child (docs/workflows.md); output gets its own advice.
|
|
11
13
|
const SHARED_CHILD_CONTROLS = new Set(["worktree", "baseRef", "context", "skill", "fast", "agentScope", "outputMode", "outputSchema", "agentContract", "acceptance", "gate", "toolBudget", "toolTimeoutMs", "control"]);
|
|
12
14
|
// runs.run/runs.all child fields whose outer-call form is missing or means something else (async and timeoutMs apply to the workflow).
|
|
@@ -87,9 +89,9 @@ function compileTemplate(template, scope) {
|
|
|
87
89
|
function prelude(originalTask) {
|
|
88
90
|
return originalTask === undefined ? [SETTLE_HELPER] : [SETTLE_HELPER, `const originalTask = ${JSON.stringify(originalTask)};`];
|
|
89
91
|
}
|
|
90
|
-
function childFields(record, path) {
|
|
92
|
+
function childFields(record, path, allowed = CHILD_FIELDS) {
|
|
91
93
|
const fields = {};
|
|
92
|
-
for (const field of
|
|
94
|
+
for (const field of allowed) {
|
|
93
95
|
if (record[field] !== undefined)
|
|
94
96
|
fields[field] = nonEmptyString(record[field], `${path}.${field}`);
|
|
95
97
|
}
|
|
@@ -119,7 +121,7 @@ function buildTasksScript(steps, originalTask, scripts) {
|
|
|
119
121
|
throw new Error("tasks must be a non-empty array of { agent, task } items.");
|
|
120
122
|
const children = steps.map((item, index) => {
|
|
121
123
|
const path = `tasks[${index}]`;
|
|
122
|
-
const record = exactFields(item, path, ["agent", "task", ...
|
|
124
|
+
const record = exactFields(item, path, ["agent", "task", ...TASK_FIELDS], "Each tasks item accepts agent and task, plus optional cwd, model and label.", scripts);
|
|
123
125
|
const agent = nonEmptyString(record.agent, `${path}.agent`);
|
|
124
126
|
const task = nonEmptyString(record.task, `${path}.task`);
|
|
125
127
|
const taskExpression = compileTemplate(task, {
|
|
@@ -128,7 +130,7 @@ function buildTasksScript(steps, originalTask, scripts) {
|
|
|
128
130
|
previous: { unavailable: "tasks items may only use {task}." },
|
|
129
131
|
outputsUnavailable: "tasks items may only use {task}.",
|
|
130
132
|
});
|
|
131
|
-
return { key: `task-${index + 1}`, agent, taskExpression, fields: childFields(record, path) };
|
|
133
|
+
return { key: `task-${index + 1}`, agent, taskExpression, fields: childFields(record, path, TASK_FIELDS) };
|
|
132
134
|
});
|
|
133
135
|
return [
|
|
134
136
|
...prelude(originalTask),
|
|
@@ -151,8 +151,10 @@ function resolveRunCi(args) {
|
|
|
151
151
|
}
|
|
152
152
|
function resolveParallel(args) {
|
|
153
153
|
const unsupported = Object.keys(args).filter((key) => key !== "tasks");
|
|
154
|
-
if (unsupported.length > 0)
|
|
155
|
-
|
|
154
|
+
if (unsupported.length > 0) {
|
|
155
|
+
const concurrencyAdvice = unsupported.includes("concurrency") ? " To cap how many run at once, pass globalConcurrencyLimit at the top level, alongside workflow and args." : "";
|
|
156
|
+
return { error: `workflow 'parallel' args contain unsupported fields: ${unsupported.join(", ")}. Pass args.tasks: [{ agent, task, cwd?, model?, label? }, ...].${concurrencyAdvice} ${unsupportedChildFieldAdvice(unsupported, true)}` };
|
|
157
|
+
}
|
|
156
158
|
try {
|
|
157
159
|
return { script: buildStructuredWorkflowScript("tasks", args.tasks, undefined, true) };
|
|
158
160
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { AsyncStatus } from "../shared/types.ts";
|
|
2
2
|
import type { WorkflowScriptChildResult } from "./scripted-workflow.ts";
|
|
3
|
+
/**
|
|
4
|
+
* A top-level resume of a failed async workflow child starts a detached run. These records
|
|
5
|
+
* link that run back to its workflow key without writing the workflow's own status or receipt.
|
|
6
|
+
* The source run is terminal, so the live workflow host never writes its directory.
|
|
7
|
+
*/
|
|
8
|
+
export declare const REVIVAL_LINK_FILE = "workflow-revival.json";
|
|
3
9
|
/** The same link, kept in the revived run's directory so reviving it again keeps the key. */
|
|
4
10
|
export declare const REVIVAL_ORIGIN_FILE = "workflow-revival-origin.json";
|
|
5
11
|
export interface WorkflowKeyRevival {
|
|
@@ -7,7 +7,7 @@ import { readStatus } from "../shared/utils.js";
|
|
|
7
7
|
* link that run back to its workflow key without writing the workflow's own status or receipt.
|
|
8
8
|
* The source run is terminal, so the live workflow host never writes its directory.
|
|
9
9
|
*/
|
|
10
|
-
const REVIVAL_LINK_FILE = "workflow-revival.json";
|
|
10
|
+
export const REVIVAL_LINK_FILE = "workflow-revival.json";
|
|
11
11
|
/** The same link, kept in the revived run's directory so reviving it again keeps the key. */
|
|
12
12
|
export const REVIVAL_ORIGIN_FILE = "workflow-revival-origin.json";
|
|
13
13
|
/** Recording refuses a deeper link, so readers bounded by this always reach the chain's end. */
|