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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isTrustedRecordedSessionFile,
|
|
3
3
|
resolveSubagentRunId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XIQKWTFY.js";
|
|
5
5
|
import {
|
|
6
6
|
agentStreamOptions,
|
|
7
7
|
opencodeSessionHeaders,
|
|
8
8
|
resolveAsyncResumeTarget
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2LEBXCLU.js";
|
|
10
10
|
import {
|
|
11
11
|
ownsRun
|
|
12
12
|
} from "./chunk-HXRB42AF.js";
|
|
@@ -18,15 +18,15 @@ import {
|
|
|
18
18
|
reconcileAsyncRun,
|
|
19
19
|
resolveAuthorityDecision,
|
|
20
20
|
resolveMissionStoreLocation
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SIB2GQHL.js";
|
|
22
22
|
import {
|
|
23
23
|
deliverInterruptRequest,
|
|
24
24
|
queueRevivalBrief,
|
|
25
25
|
requestAsyncSteer
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-37EJGDYO.js";
|
|
27
27
|
import {
|
|
28
28
|
formatShellCommand
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-72334PEI.js";
|
|
30
30
|
import {
|
|
31
31
|
readStatus,
|
|
32
32
|
redactSecretValues,
|
|
@@ -34,10 +34,10 @@ import {
|
|
|
34
34
|
tryLease,
|
|
35
35
|
writeAtomicJson,
|
|
36
36
|
writePrivateAtomicJson
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-F4NSLXB2.js";
|
|
38
38
|
import {
|
|
39
39
|
DIRS
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-SRWJIAIP.js";
|
|
41
41
|
import {
|
|
42
42
|
previewDisplayText,
|
|
43
43
|
safeTerminalText
|
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
resolveCurrentSessionId,
|
|
15
15
|
resolveWatchdogReviewModel,
|
|
16
16
|
startWatchdogDiffBaselineCapture
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-RIBMW6V3.js";
|
|
18
18
|
import {
|
|
19
19
|
agentStreamOptions,
|
|
20
20
|
opencodeSessionHeaders
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2LEBXCLU.js";
|
|
22
22
|
import {
|
|
23
23
|
registerNativeSupervisorClient
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-PTN7XAXI.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-SIB2GQHL.js";
|
|
31
31
|
import {
|
|
32
32
|
CHILD_WATCHDOG_STATUS_EVENT,
|
|
33
33
|
DEFAULT_WAIT_TOOL_NAME,
|
|
@@ -46,10 +46,10 @@ import {
|
|
|
46
46
|
toolBudgetSoftNudge,
|
|
47
47
|
validateAcceptanceReport,
|
|
48
48
|
validateStructuredOutputValue
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-F4NSLXB2.js";
|
|
50
50
|
import {
|
|
51
51
|
INTERCOM_SESSION_IDENTITY_EVENT
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-SRWJIAIP.js";
|
|
53
53
|
|
|
54
54
|
// src/runs/shared/subagent-prompt-runtime.ts
|
|
55
55
|
import { createHash } from "node:crypto";
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CHAIN_RUNS_DIR,
|
|
3
3
|
RUNNER_LAUNCHER_NAME_PATTERN,
|
|
4
4
|
RUNNER_LAUNCHER_NAME_RULE
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SRWJIAIP.js";
|
|
6
6
|
import {
|
|
7
7
|
previewDisplayText,
|
|
8
8
|
sanitizeDisplayText,
|
|
@@ -12,11 +12,6 @@ import {
|
|
|
12
12
|
normalizeCapabilityCeilingAllowedAgents
|
|
13
13
|
} from "./chunk-QXASAHIA.js";
|
|
14
14
|
|
|
15
|
-
// src/shared/atomic-json.ts
|
|
16
|
-
import { createHash } from "node:crypto";
|
|
17
|
-
import * as fs from "node:fs";
|
|
18
|
-
import * as path from "node:path";
|
|
19
|
-
|
|
20
15
|
// src/shared/file-system-retry.ts
|
|
21
16
|
var WAIT_BUFFER = typeof SharedArrayBuffer !== "undefined" ? new SharedArrayBuffer(4) : void 0;
|
|
22
17
|
var WAIT_VIEW = WAIT_BUFFER ? new Int32Array(WAIT_BUFFER) : void 0;
|
|
@@ -75,6 +70,9 @@ function runFileSystemOperationWithRetry(operation, options = {}) {
|
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
// src/shared/atomic-json.ts
|
|
73
|
+
import { createHash } from "node:crypto";
|
|
74
|
+
import * as fs from "node:fs";
|
|
75
|
+
import * as path from "node:path";
|
|
78
76
|
var MAX_PATH_COMPONENT_BYTES = 255;
|
|
79
77
|
function renameWithRetry(fsImpl, sourcePath, targetPath, retryDelaysMs, wait) {
|
|
80
78
|
runFileSystemOperationWithRetry(() => {
|
|
@@ -4385,6 +4383,9 @@ function formatAvailableAgentLines(agents) {
|
|
|
4385
4383
|
if (sorted.length > MAX_LISTED_AGENTS) lines.push(`+${sorted.length - MAX_LISTED_AGENTS} more; {action:"list", options:{search:"<term>"}}`);
|
|
4386
4384
|
return lines.length ? lines : ["- (none)"];
|
|
4387
4385
|
}
|
|
4386
|
+
function agentRunDescription(agentName, agent, label) {
|
|
4387
|
+
return label ?? (agent?.description?.trim() || agentName);
|
|
4388
|
+
}
|
|
4388
4389
|
function suggestAgentName(name, agents) {
|
|
4389
4390
|
return closestMatch(name.trim(), new Set(agents.flatMap((agent) => [agent.name, ...agent.localName ? [agent.localName] : [], ...agent.aliases ?? []])));
|
|
4390
4391
|
}
|
|
@@ -8851,6 +8852,7 @@ export {
|
|
|
8851
8852
|
unknownAgentDiagnosticContext,
|
|
8852
8853
|
MAX_LISTED_AGENTS,
|
|
8853
8854
|
formatAvailableAgentLines,
|
|
8855
|
+
agentRunDescription,
|
|
8854
8856
|
suggestAgentName,
|
|
8855
8857
|
formatUnknownAgentError,
|
|
8856
8858
|
resolveAgentName,
|
|
@@ -7,37 +7,37 @@ import {
|
|
|
7
7
|
safeTranscriptEvent,
|
|
8
8
|
steerAsyncRun,
|
|
9
9
|
steerWorkflowForegroundTarget
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DNJ2GHSI.js";
|
|
11
11
|
import {
|
|
12
12
|
FLEET_STATUS_WIDGET_KEY,
|
|
13
13
|
runningTone,
|
|
14
14
|
stepTaskSummary
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZWGOHOGI.js";
|
|
16
16
|
import {
|
|
17
17
|
foregroundChildStateLabel,
|
|
18
18
|
formatAsyncRunTranscript,
|
|
19
19
|
stopAsyncRun
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XIQKWTFY.js";
|
|
21
21
|
import {
|
|
22
22
|
contextModeBadge,
|
|
23
23
|
contextModeLabel,
|
|
24
24
|
decodeUtf8Tail,
|
|
25
25
|
listAsyncRuns
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2LEBXCLU.js";
|
|
27
27
|
import {
|
|
28
28
|
reportSessionWarning
|
|
29
29
|
} from "./chunk-HXRB42AF.js";
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-SIB2GQHL.js";
|
|
31
|
+
import "./chunk-37EJGDYO.js";
|
|
32
32
|
import "./chunk-NIXWDZZV.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-CPWZN5KM.js";
|
|
34
34
|
import "./chunk-7F6RKT6W.js";
|
|
35
35
|
import "./chunk-YARY7JWU.js";
|
|
36
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-72334PEI.js";
|
|
37
37
|
import {
|
|
38
38
|
getArtifactPaths,
|
|
39
39
|
getArtifactsDir
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-5J2RTMKW.js";
|
|
41
41
|
import {
|
|
42
42
|
snapshotExternalRuns
|
|
43
43
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -49,10 +49,10 @@ import {
|
|
|
49
49
|
formatTokens,
|
|
50
50
|
readStatus,
|
|
51
51
|
shortenPath
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-F4NSLXB2.js";
|
|
53
53
|
import {
|
|
54
54
|
DIRS
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-SRWJIAIP.js";
|
|
56
56
|
import {
|
|
57
57
|
safeTerminalText
|
|
58
58
|
} from "./chunk-YFCK7H2S.js";
|
|
@@ -154,8 +154,15 @@ function renderExpandedTool(event, width, theme) {
|
|
|
154
154
|
const output = event.output ?? event.error;
|
|
155
155
|
const outputColor = event.status === "error" ? "error" : "toolOutput";
|
|
156
156
|
if (event.name === "bash") {
|
|
157
|
-
const command = jsonScalar(args?.command)
|
|
158
|
-
|
|
157
|
+
const command = jsonScalar(args?.command);
|
|
158
|
+
let first = true;
|
|
159
|
+
for (const commandLine of (command ?? event.args ?? "(unknown command)").split(/\r?\n/)) {
|
|
160
|
+
for (const wrapped of renderWrapped(theme.fg("toolTitle", theme.bold(first ? `$ ${commandLine}` : commandLine)), Math.max(1, width - 4))) {
|
|
161
|
+
lines.push(railLine(`${first ? glyph : " "} ${wrapped}`, width, theme));
|
|
162
|
+
first = false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (command === void 0 && !args && event.argsPayload) lines.push(...renderArgsPayload(event.argsPayload, width, theme));
|
|
159
166
|
if (output) {
|
|
160
167
|
for (const outputLine of output.replace(/\s+$/, "").split(/\r?\n/)) {
|
|
161
168
|
for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) {
|
|
@@ -178,12 +185,7 @@ function renderExpandedTool(event, width, theme) {
|
|
|
178
185
|
return lines;
|
|
179
186
|
}
|
|
180
187
|
lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(event.name))}`, width, theme));
|
|
181
|
-
if (event.argsPayload)
|
|
182
|
-
lines.push(railLine(theme.fg("dim", " args"), width, theme));
|
|
183
|
-
for (const argLine of event.argsPayload.split(/\r?\n/)) {
|
|
184
|
-
for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
188
|
+
if (event.argsPayload) lines.push(...renderArgsPayload(event.argsPayload, width, theme));
|
|
187
189
|
if (output) {
|
|
188
190
|
lines.push(railLine(theme.fg(event.status === "error" ? "error" : "dim", event.status === "error" ? " error" : " output"), width, theme));
|
|
189
191
|
for (const outputLine of output.split(/\r?\n/)) {
|
|
@@ -195,6 +197,13 @@ function renderExpandedTool(event, width, theme) {
|
|
|
195
197
|
function bounded(text, width) {
|
|
196
198
|
return truncateToWidth(text, Math.max(0, width));
|
|
197
199
|
}
|
|
200
|
+
function renderArgsPayload(payload, width, theme) {
|
|
201
|
+
const lines = [railLine(theme.fg("dim", " args"), width, theme)];
|
|
202
|
+
for (const argLine of payload.split(/\r?\n/)) {
|
|
203
|
+
for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
|
|
204
|
+
}
|
|
205
|
+
return lines;
|
|
206
|
+
}
|
|
198
207
|
function railLine(content, width, theme) {
|
|
199
208
|
return bounded(`${theme.fg("borderMuted", "\u2502")} ${content}`, width);
|
|
200
209
|
}
|
|
@@ -458,6 +467,7 @@ function collectFleetSnapshot(state, options = {}) {
|
|
|
458
467
|
entryLimit: MAX_FLEET_HISTORY_CANDIDATES,
|
|
459
468
|
resultsDir: options.resultsDir ?? DIRS.results,
|
|
460
469
|
reconcile: false,
|
|
470
|
+
includeNested: false,
|
|
461
471
|
onCorruptStatus: (warning) => reportSessionWarning(state, warning)
|
|
462
472
|
}).filter((run) => !trackedIds.has(run.id));
|
|
463
473
|
runs = [...trackedRuns, ...history];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectSubagentsDir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5J2RTMKW.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverAgents,
|
|
6
6
|
formatUnknownAgentError,
|
|
7
7
|
resolveAgentName,
|
|
8
8
|
unknownAgentDiagnosticContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F4NSLXB2.js";
|
|
10
10
|
|
|
11
11
|
// src/agents/agent-refinements.ts
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendAgentRefinementOverlay
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KNVQTRSY.js";
|
|
4
4
|
import {
|
|
5
5
|
buildAgentMemoryInjection,
|
|
6
6
|
buildSkillInjection
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-F4NSLXB2.js";
|
|
8
8
|
|
|
9
9
|
// src/runs/shared/effective-system-prompt.ts
|
|
10
10
|
function appendSection(prompt, section) {
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
readStatus,
|
|
12
12
|
writeAtomicJson,
|
|
13
13
|
writePrivateAtomicJson
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-F4NSLXB2.js";
|
|
15
15
|
import {
|
|
16
16
|
ASYNC_DIR,
|
|
17
17
|
INTERCOM_DETACH_REQUEST_EVENT,
|
|
18
18
|
POLL_INTERVAL_MS,
|
|
19
19
|
TEMP_ROOT_DIR
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-SRWJIAIP.js";
|
|
21
21
|
|
|
22
22
|
// src/intercom/native-supervisor-channel.ts
|
|
23
23
|
import { randomUUID } from "node:crypto";
|
|
@@ -8,23 +8,23 @@ import {
|
|
|
8
8
|
projectTimeoutRecovery,
|
|
9
9
|
readAsyncRecoveryDescriptor,
|
|
10
10
|
utf8Tail
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2LEBXCLU.js";
|
|
12
12
|
import {
|
|
13
13
|
MAX_ARGS_BYTES,
|
|
14
14
|
MAX_ARGS_DEPTH,
|
|
15
15
|
MAX_ARGS_FIELDS,
|
|
16
16
|
MAX_ARGS_ITEMS
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VMJGZHUL.js";
|
|
18
18
|
import {
|
|
19
19
|
fallbackResultPayloadPathForSessionRun,
|
|
20
20
|
nestedRunScope,
|
|
21
21
|
resultFilePath,
|
|
22
22
|
resultPayloadMatchesSessionRun,
|
|
23
23
|
resultPayloadPathForSessionRun
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-SIB2GQHL.js";
|
|
25
25
|
import {
|
|
26
26
|
PROJECT_SUBAGENTS_RELATIVE_DIR
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-5J2RTMKW.js";
|
|
28
28
|
import {
|
|
29
29
|
listBackgroundWorkWakeChannels,
|
|
30
30
|
snapshotBackgroundWork
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
waitToolName,
|
|
51
51
|
withSettingsFileLease,
|
|
52
52
|
writePrivateAtomicJson
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-F4NSLXB2.js";
|
|
54
54
|
import {
|
|
55
55
|
DIRS,
|
|
56
56
|
INTERCOM_DETACH_REQUEST_EVENT,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
SUBAGENT_CONTROL_INTERCOM_EVENT,
|
|
61
61
|
SUBAGENT_FOREGROUND_COMPLETE_EVENT,
|
|
62
62
|
SUBAGENT_RESULT_INTERCOM_EVENT
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-SRWJIAIP.js";
|
|
64
64
|
|
|
65
65
|
// src/shared/session-identity.ts
|
|
66
66
|
import * as fs from "node:fs";
|
|
@@ -960,7 +960,9 @@ var ModelTopLevelProperties = {
|
|
|
960
960
|
action,
|
|
961
961
|
id,
|
|
962
962
|
message,
|
|
963
|
-
options: Type2.Optional(Type2.Unsafe({ type: "object", additionalProperties: true, description: "Every field not listed here, such as acceptance, timeoutMs, context, view and index; guide tool-reference/parameter-reference." }))
|
|
963
|
+
options: Type2.Optional(Type2.Unsafe({ type: "object", additionalProperties: true, description: "Every field not listed here, such as acceptance, timeoutMs, context, view and index; guide tool-reference/parameter-reference." })),
|
|
964
|
+
// Appended after options so the earlier fields keep their order.
|
|
965
|
+
label: Type2.Optional(Type2.String({ minLength: 1, maxLength: 80, description: "2-4 words on what it does; appears wherever the run is listed." }))
|
|
964
966
|
};
|
|
965
967
|
var SubagentParams = keepTopLevelParameterDescriptions(Type2.Object(ModelTopLevelProperties));
|
|
966
968
|
var StructuredTask = { type: "object", properties: { agent: { type: "string", minLength: 1 }, task: { type: "string" }, cwd: { type: "string" }, model: { type: "string" } }, required: ["agent", "task"], additionalProperties: false };
|
|
@@ -3364,12 +3366,30 @@ function formatWatchdogOrchestrationActivity(event) {
|
|
|
3364
3366
|
}
|
|
3365
3367
|
return sections.join("\n\n");
|
|
3366
3368
|
}
|
|
3369
|
+
function formatWatchdogSupervisorReplies(event) {
|
|
3370
|
+
const turn = event;
|
|
3371
|
+
if (turn?.type !== "turn_end" || !Array.isArray(turn.message?.content) || !Array.isArray(turn.toolResults)) return [];
|
|
3372
|
+
const entries = [];
|
|
3373
|
+
for (const call of turn.message.content) {
|
|
3374
|
+
if (call?.type !== "toolCall" || call.name !== "contact_supervisor" || typeof call.id !== "string") continue;
|
|
3375
|
+
const args2 = call.arguments;
|
|
3376
|
+
if (!args2 || typeof args2 !== "object" || !["need_decision", "interview_request"].includes(args2.reason)) continue;
|
|
3377
|
+
const result2 = turn.toolResults.find((value) => {
|
|
3378
|
+
const result3 = value;
|
|
3379
|
+
return result3?.role === "toolResult" && result3.toolCallId === call.id && result3.toolName === call.name && result3.isError !== true && !result3.error;
|
|
3380
|
+
});
|
|
3381
|
+
if (result2) entries.push([formatToolCall(call.name, args2), formatWatchdogReviewMessage(result2) ?? ""].join("\n\n"));
|
|
3382
|
+
}
|
|
3383
|
+
return entries;
|
|
3384
|
+
}
|
|
3367
3385
|
|
|
3368
3386
|
// src/watchdog/runtime.ts
|
|
3369
3387
|
var DEFAULT_REVIEW = () => ({ warnings: [] });
|
|
3370
3388
|
var MAX_REVIEW_INPUT_CHARS = 24e3;
|
|
3371
3389
|
var REVIEW_INPUT_HEAD_CHARS = 6e3;
|
|
3372
3390
|
var REVIEW_DELTA_SEPARATOR = "\n\n---\n\n";
|
|
3391
|
+
var MAX_SUPERVISOR_REPLY_CHARS = 3e3;
|
|
3392
|
+
var MAX_SUPERVISOR_REPLIES_CHARS = 6e3;
|
|
3373
3393
|
function boundWatchdogReviewText(text, cap = MAX_REVIEW_INPUT_CHARS) {
|
|
3374
3394
|
if (text.length <= cap) return text;
|
|
3375
3395
|
const head = Math.min(REVIEW_INPUT_HEAD_CHARS, Math.floor(cap / 4));
|
|
@@ -3380,6 +3400,11 @@ function boundWatchdogReviewText(text, cap = MAX_REVIEW_INPUT_CHARS) {
|
|
|
3380
3400
|
`;
|
|
3381
3401
|
return `${text.slice(0, head)}${marker}${text.slice(text.length - (cap - head - marker.length))}`;
|
|
3382
3402
|
}
|
|
3403
|
+
function omittedDeltaNote(chars) {
|
|
3404
|
+
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.]`;
|
|
3405
|
+
}
|
|
3406
|
+
var OMITTED_NOTE_RESERVE = omittedDeltaNote(Number.MAX_SAFE_INTEGER).length + 2;
|
|
3407
|
+
var MAX_RETAINED_DELTA_CHARS = MAX_REVIEW_INPUT_CHARS - OMITTED_NOTE_RESERVE;
|
|
3383
3408
|
function errorMessage2(error) {
|
|
3384
3409
|
return error instanceof Error ? error.message : String(error);
|
|
3385
3410
|
}
|
|
@@ -3411,6 +3436,7 @@ var MainWatchdogRuntime = class {
|
|
|
3411
3436
|
status = "idle";
|
|
3412
3437
|
pendingDeltas = [];
|
|
3413
3438
|
pendingDeltaChars = 0;
|
|
3439
|
+
omittedDeltaChars = 0;
|
|
3414
3440
|
guard = new WatchdogEmissionGuard();
|
|
3415
3441
|
guardMaxWarnings = null;
|
|
3416
3442
|
epoch = 0;
|
|
@@ -3449,6 +3475,7 @@ var MainWatchdogRuntime = class {
|
|
|
3449
3475
|
activityTail = "";
|
|
3450
3476
|
activityPending = false;
|
|
3451
3477
|
activityReviewUsed = false;
|
|
3478
|
+
supervisorReplies = [];
|
|
3452
3479
|
constructor(options = {}) {
|
|
3453
3480
|
this.cwd = options.cwd ?? process.cwd();
|
|
3454
3481
|
this.resolveConfig = options.resolveConfig ?? resolveWatchdogConfig;
|
|
@@ -3551,7 +3578,10 @@ var MainWatchdogRuntime = class {
|
|
|
3551
3578
|
this.lspLedger.reset();
|
|
3552
3579
|
this.lastLspSnapshot = void 0;
|
|
3553
3580
|
}
|
|
3554
|
-
if (options.clearScope)
|
|
3581
|
+
if (options.clearScope) {
|
|
3582
|
+
this.scope.reset();
|
|
3583
|
+
this.supervisorReplies = [];
|
|
3584
|
+
}
|
|
3555
3585
|
if (options.clearScope || options.clearActivity) this.clearActivity();
|
|
3556
3586
|
if (options.clearReviewInputSignature) this.lastReviewInputSignature = void 0;
|
|
3557
3587
|
if (options.resetChangeSignature) this.resetRepoChangeBaseline({ reviewed: true });
|
|
@@ -3575,6 +3605,7 @@ var MainWatchdogRuntime = class {
|
|
|
3575
3605
|
this.lastLspSnapshot = void 0;
|
|
3576
3606
|
this.lspLedger.reset();
|
|
3577
3607
|
this.scope.reset();
|
|
3608
|
+
this.supervisorReplies = [];
|
|
3578
3609
|
this.observedRepoEditThisTurn = false;
|
|
3579
3610
|
this.toolResultsThisRun = 0;
|
|
3580
3611
|
this.midRunReviewing = false;
|
|
@@ -3609,6 +3640,7 @@ var MainWatchdogRuntime = class {
|
|
|
3609
3640
|
this.activityPending = true;
|
|
3610
3641
|
}
|
|
3611
3642
|
}
|
|
3643
|
+
this.retainSupervisorReplies(event);
|
|
3612
3644
|
this.observedRepoEditThisTurn ||= eventIndicatesRepoEdit(event);
|
|
3613
3645
|
const delta = formatWatchdogTurnDelta({
|
|
3614
3646
|
includeUserPrompt: this.includeUserPromptInNextDelta,
|
|
@@ -4056,37 +4088,59 @@ var MainWatchdogRuntime = class {
|
|
|
4056
4088
|
appendBoundedDelta(delta) {
|
|
4057
4089
|
let entry = delta.trim();
|
|
4058
4090
|
if (!entry) return;
|
|
4059
|
-
if (entry.length >
|
|
4091
|
+
if (entry.length > MAX_RETAINED_DELTA_CHARS) {
|
|
4092
|
+
this.omittedDeltaChars += entry.length - MAX_RETAINED_DELTA_CHARS;
|
|
4093
|
+
entry = boundWatchdogReviewText(entry, MAX_RETAINED_DELTA_CHARS);
|
|
4094
|
+
}
|
|
4060
4095
|
this.pendingDeltas.push(entry);
|
|
4061
4096
|
this.pendingDeltaChars += entry.length;
|
|
4062
|
-
while (this.pendingDeltas.length > 1 && this.pendingDeltaChars + (this.pendingDeltas.length - 1) * REVIEW_DELTA_SEPARATOR.length >
|
|
4097
|
+
while (this.pendingDeltas.length > 1 && this.pendingDeltaChars + (this.pendingDeltas.length - 1) * REVIEW_DELTA_SEPARATOR.length > MAX_RETAINED_DELTA_CHARS) {
|
|
4063
4098
|
const removed = this.pendingDeltas.shift();
|
|
4064
|
-
if (removed)
|
|
4099
|
+
if (removed) {
|
|
4100
|
+
this.pendingDeltaChars -= removed.length;
|
|
4101
|
+
this.omittedDeltaChars += removed.length;
|
|
4102
|
+
}
|
|
4065
4103
|
}
|
|
4066
4104
|
}
|
|
4105
|
+
// Kept outside the rolling delta so a long run cannot push the supervisor's instruction out of the review input.
|
|
4106
|
+
retainSupervisorReplies(event) {
|
|
4107
|
+
for (const reply of formatWatchdogSupervisorReplies(event)) this.supervisorReplies.push(boundWatchdogReviewText(reply, MAX_SUPERVISOR_REPLY_CHARS));
|
|
4108
|
+
let total = this.supervisorReplies.reduce((sum, reply) => sum + reply.length, 0);
|
|
4109
|
+
while (this.supervisorReplies.length > 1 && total > MAX_SUPERVISOR_REPLIES_CHARS) total -= this.supervisorReplies.shift().length;
|
|
4110
|
+
}
|
|
4067
4111
|
buildReviewInput(changeSignature, lspBlock = "") {
|
|
4068
4112
|
const input = this.pendingDeltas.join(REVIEW_DELTA_SEPARATOR);
|
|
4069
4113
|
const scopeBlock = this.scopeBlock();
|
|
4070
4114
|
const changes = changeSignature?.changedPaths.length ? ["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") : "";
|
|
4071
4115
|
const activity = this.activityTail ? `Recent delivered orchestration activity (oldest first; bounded observations, not a task board; waits/holds are not evidence of neglect):
|
|
4072
4116
|
${this.activityTail}` : "";
|
|
4117
|
+
const supervisor = this.configResult.config.scope.enabled && this.supervisorReplies.length ? `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):
|
|
4118
|
+
${this.supervisorReplies.join(REVIEW_DELTA_SEPARATOR)}` : "";
|
|
4073
4119
|
const contextPieces = [scopeBlock, changes, lspBlock, activity].filter(Boolean);
|
|
4074
|
-
if (!contextPieces.length) return
|
|
4120
|
+
if (!contextPieces.length && !supervisor) return this.boundDeltaInput(input, MAX_REVIEW_INPUT_CHARS);
|
|
4075
4121
|
const maxContextLength = Math.floor(MAX_REVIEW_INPUT_CHARS / 2);
|
|
4076
4122
|
const maxPieceLength = Math.max(1e3, Math.floor(maxContextLength / contextPieces.length));
|
|
4077
|
-
const boundedContext = contextPieces.map((piece) => piece.length > maxPieceLength ? piece === activity ? boundWatchdogReviewText(piece, maxPieceLength) : `${piece.slice(0, maxPieceLength - 6)}
|
|
4078
|
-
- ...` : piece).join(REVIEW_DELTA_SEPARATOR);
|
|
4123
|
+
const boundedContext = [...contextPieces.map((piece) => piece.length > maxPieceLength ? piece === activity ? boundWatchdogReviewText(piece, maxPieceLength) : `${piece.slice(0, maxPieceLength - 6)}
|
|
4124
|
+
- ...` : piece), supervisor].filter(Boolean).join(REVIEW_DELTA_SEPARATOR);
|
|
4079
4125
|
const separatorLength = input ? REVIEW_DELTA_SEPARATOR.length : 0;
|
|
4080
4126
|
const inputBudget = MAX_REVIEW_INPUT_CHARS - boundedContext.length - separatorLength;
|
|
4081
|
-
const boundedInput = inputBudget <= 0 ? "" :
|
|
4127
|
+
const boundedInput = inputBudget <= 0 ? "" : this.boundDeltaInput(input, inputBudget);
|
|
4082
4128
|
return [boundedContext, boundedInput].filter(Boolean).join(REVIEW_DELTA_SEPARATOR);
|
|
4083
4129
|
}
|
|
4130
|
+
boundDeltaInput(input, cap) {
|
|
4131
|
+
if (!input || this.omittedDeltaChars === 0 && input.length <= cap) return input;
|
|
4132
|
+
const bodyCap = cap - OMITTED_NOTE_RESERVE;
|
|
4133
|
+
return `${omittedDeltaNote(this.omittedDeltaChars + Math.max(0, input.length - bodyCap))}
|
|
4134
|
+
|
|
4135
|
+
${boundWatchdogReviewText(input, bodyCap)}`;
|
|
4136
|
+
}
|
|
4084
4137
|
scopeBlock() {
|
|
4085
4138
|
return this.configResult.config.scope.enabled ? this.scope.render() : "";
|
|
4086
4139
|
}
|
|
4087
4140
|
clearPendingDeltas() {
|
|
4088
4141
|
this.pendingDeltas = [];
|
|
4089
4142
|
this.pendingDeltaChars = 0;
|
|
4143
|
+
this.omittedDeltaChars = 0;
|
|
4090
4144
|
}
|
|
4091
4145
|
clearActivity() {
|
|
4092
4146
|
if (!this.activityTail) return;
|