@xzzpig/pi-subagents 0.24.2 → 0.25.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 +37 -0
- package/bundle/agent-management.js +4 -4
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/chunk-34TUUBRN.js +1107 -0
- package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
- package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
- package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
- package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
- package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
- package/bundle/{chunk-RU522D5W.js → chunk-FQPV4O6C.js} +183 -28
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
- package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
- package/bundle/{chunk-CYY5UMJU.js → chunk-IXCEOEJT.js} +411 -249
- package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
- package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
- package/bundle/{chunk-224WMDIV.js → chunk-JUYNN63E.js} +350 -123
- package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
- package/bundle/{chunk-XWWUDWUW.js → chunk-KRNBJPZ2.js} +670 -400
- package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
- package/bundle/chunk-LYKG4FKH.js +523 -0
- package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
- package/bundle/{chunk-JEA2ZKUA.js → chunk-MMJQMPOK.js} +37 -165
- package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
- package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
- package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
- package/bundle/{chunk-4UH4WS4G.js → chunk-SNDCIJMK.js} +23 -12
- package/bundle/{chunk-O4D5PBVI.js → chunk-TM2K53NX.js} +3 -2
- package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
- package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
- package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
- package/bundle/{chunk-BQ2OAB4Q.js → chunk-WWDUNXSE.js} +67 -30
- package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +12 -10
- package/bundle/project-panes.js +3 -3
- package/bundle/workflow-resources.js +1 -1
- package/docs/agents.md +27 -6
- package/docs/configuration.md +20 -8
- package/docs/extension-api.md +18 -1
- package/docs/models.md +6 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +7 -1
- package/docs/workflows.md +30 -2
- package/package.json +2 -2
- package/skills/pi-subagents/SKILL.md +15 -6
- package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +46 -18
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.d.ts +2 -3
- package/src/agents/agents.js +46 -20
- 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/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/config.d.ts +1 -0
- package/src/extension/config.js +13 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +51 -37
- 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 +12 -3
- package/src/extension/schemas.js +7 -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 +55 -15
- package/src/extension/tool-description.d.ts +1 -1
- package/src/extension/tool-description.js +14 -8
- 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 +7 -10
- package/src/runs/background/async-execution.js +66 -29
- 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 +114 -40
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +17 -6
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- 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 +2 -3
- package/src/runs/background/run-child-session.js +5 -8
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- 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 +2 -6
- package/src/runs/background/subagent-runner.js +88 -70
- 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-subscriptions.js +124 -12
- 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/async-steering-action.js +24 -9
- package/src/runs/foreground/async-stop-action.d.ts +1 -1
- package/src/runs/foreground/async-stop-action.js +9 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +68 -84
- package/src/runs/foreground/fork-tool-result-handler.d.ts +60 -0
- package/src/runs/foreground/fork-tool-result-handler.js +83 -0
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +5 -10
- package/src/runs/foreground/subagent-executor.js +164 -49
- package/src/runs/shared/acceptance.js +69 -26
- 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-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 +6 -5
- package/src/runs/shared/child-session.js +85 -38
- 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-contract.d.ts +49 -0
- package/src/runs/shared/external-cli-contract.js +18 -13
- 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 +51 -24
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-config-sources.d.ts +4 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
- 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 +20 -5
- package/src/runs/shared/model-resolution.js +55 -50
- 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 +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +18 -4
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- 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/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +132 -22
- 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 +64 -0
- package/src/shared/fleet-transcript-reader.js +376 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/pruned-fork.js +2 -2
- package/src/shared/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- 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/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +108 -59
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +3 -15
- package/src/shared/utils.js +4 -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-native-transcript.js +1 -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 -57
- package/src/tui/fleet-transcript.js +4 -370
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +194 -68
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +4 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +344 -59
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- package/src/workflows/workflow-resources.js +4 -4
- package/src/workflows/workflow-resume-claim.d.ts +2 -0
- package/src/workflows/workflow-resume-claim.js +3 -3
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +13 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +81 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
- package/bundle/chunk-U4ODUYAG.js +0 -235
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLivePromptAudit,
|
|
3
3
|
handleInspectorAction,
|
|
4
|
+
objectValue,
|
|
4
5
|
readFleetTranscript,
|
|
5
6
|
readTranscriptRecords,
|
|
6
|
-
renderFleetTranscript,
|
|
7
7
|
resolveWorkflowForegroundSteeringTarget,
|
|
8
|
+
safeTranscriptEvent,
|
|
8
9
|
steerAsyncRun,
|
|
9
10
|
steerWorkflowForegroundTarget
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MMJQMPOK.js";
|
|
11
12
|
import {
|
|
12
13
|
FLEET_STATUS_WIDGET_KEY,
|
|
13
14
|
emitUiSpanSilent,
|
|
14
|
-
reportFleetWarning,
|
|
15
15
|
runningTone,
|
|
16
16
|
stepTaskSummary
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LZ3HBDTR.js";
|
|
18
18
|
import {
|
|
19
19
|
foregroundChildStateLabel,
|
|
20
20
|
formatAsyncRunTranscript,
|
|
21
21
|
stopAsyncRun
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ULGMXABL.js";
|
|
23
23
|
import "./chunk-7J4ZXMY7.js";
|
|
24
24
|
import {
|
|
25
25
|
contextModeBadge,
|
|
26
26
|
contextModeLabel,
|
|
27
27
|
decodeUtf8Tail,
|
|
28
28
|
listAsyncRuns
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import
|
|
29
|
+
} from "./chunk-DLVPMML3.js";
|
|
30
|
+
import {
|
|
31
|
+
reportSessionWarning
|
|
32
|
+
} from "./chunk-HXRB42AF.js";
|
|
33
|
+
import "./chunk-JH5H4CYJ.js";
|
|
31
34
|
import {
|
|
32
35
|
getArtifactPaths,
|
|
33
36
|
getArtifactsDir
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-
|
|
37
|
+
} from "./chunk-LYKG4FKH.js";
|
|
38
|
+
import "./chunk-LPJEKHOY.js";
|
|
36
39
|
import "./chunk-NIXWDZZV.js";
|
|
37
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-JAXVBXGF.js";
|
|
38
41
|
import "./chunk-BGIYHF2W.js";
|
|
39
42
|
import "./chunk-CTPAE36Y.js";
|
|
40
43
|
import {
|
|
@@ -48,12 +51,14 @@ import {
|
|
|
48
51
|
formatTokens,
|
|
49
52
|
readStatus,
|
|
50
53
|
shortenPath
|
|
51
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-XAC2XNAP.js";
|
|
52
55
|
import {
|
|
53
56
|
DIRS
|
|
54
57
|
} from "./chunk-UQDHXMUG.js";
|
|
55
58
|
import "./chunk-QXASAHIA.js";
|
|
56
|
-
import
|
|
59
|
+
import {
|
|
60
|
+
safeTerminalText
|
|
61
|
+
} from "./chunk-YFCK7H2S.js";
|
|
57
62
|
|
|
58
63
|
// src/tui/fleet.ts
|
|
59
64
|
import * as fs from "node:fs";
|
|
@@ -61,7 +66,7 @@ import * as path from "node:path";
|
|
|
61
66
|
import {
|
|
62
67
|
getMarkdownTheme
|
|
63
68
|
} from "@earendil-works/pi-coding-agent";
|
|
64
|
-
import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
69
|
+
import { matchesKey, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth2, wrapTextWithAnsi as wrapTextWithAnsi2 } from "@earendil-works/pi-tui";
|
|
65
70
|
|
|
66
71
|
// src/tui/fleet-layout.ts
|
|
67
72
|
function fleetLayout(width, rows, selected, items) {
|
|
@@ -143,6 +148,156 @@ function parseMouseWheelEvent(data) {
|
|
|
143
148
|
return void 0;
|
|
144
149
|
}
|
|
145
150
|
|
|
151
|
+
// src/tui/fleet-transcript.ts
|
|
152
|
+
import { getLanguageFromPath, highlightCode } from "@earendil-works/pi-coding-agent";
|
|
153
|
+
import { Markdown, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
154
|
+
var TOOL_PREVIEW_LINES = 7;
|
|
155
|
+
function statusGlyph(event, theme) {
|
|
156
|
+
if (event.status === "running") return theme.fg("warning", "\u25CF");
|
|
157
|
+
if (event.status === "error") return theme.fg("error", "\u2717");
|
|
158
|
+
return theme.fg("success", "\u2713");
|
|
159
|
+
}
|
|
160
|
+
function jsonScalar(value) {
|
|
161
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
162
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
163
|
+
return void 0;
|
|
164
|
+
}
|
|
165
|
+
function parseToolArgs(event) {
|
|
166
|
+
if (!event.argsPayload) return void 0;
|
|
167
|
+
try {
|
|
168
|
+
return objectValue(JSON.parse(event.argsPayload));
|
|
169
|
+
} catch {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function toolDuration(event) {
|
|
174
|
+
if (event.startedAt === void 0 || event.endedAt === void 0) return void 0;
|
|
175
|
+
return `${((event.endedAt - event.startedAt) / 1e3).toFixed(1)}s`;
|
|
176
|
+
}
|
|
177
|
+
function renderExpandedTool(event, width, theme) {
|
|
178
|
+
const lines = [];
|
|
179
|
+
const args = parseToolArgs(event);
|
|
180
|
+
const glyph = statusGlyph(event, theme);
|
|
181
|
+
const output = event.output ?? event.error;
|
|
182
|
+
const outputColor = event.status === "error" ? "error" : "toolOutput";
|
|
183
|
+
if (event.name === "bash") {
|
|
184
|
+
const command = jsonScalar(args?.command) ?? event.args ?? "(unknown command)";
|
|
185
|
+
lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`$ ${command}`))}`, width, theme));
|
|
186
|
+
if (output) {
|
|
187
|
+
for (const outputLine of output.replace(/\s+$/, "").split(/\r?\n/)) {
|
|
188
|
+
for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) {
|
|
189
|
+
lines.push(railLine(` ${wrapped}`, width, theme));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const duration = toolDuration(event);
|
|
194
|
+
if (duration) lines.push(railLine(theme.fg("dim", ` Took ${duration}`), width, theme));
|
|
195
|
+
return lines;
|
|
196
|
+
}
|
|
197
|
+
if (event.name === "read") {
|
|
198
|
+
const filePath = jsonScalar(args?.path ?? args?.file_path);
|
|
199
|
+
const language = filePath ? getLanguageFromPath(filePath) : void 0;
|
|
200
|
+
const rendered = !output ? [] : event.status === "error" ? output.split("\n").map((line) => theme.fg("error", line)) : language ? highlightCode(output, language) : output.split("\n");
|
|
201
|
+
lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(`read ${filePath ?? event.args ?? ""}`))}`, width, theme));
|
|
202
|
+
for (const line of rendered) {
|
|
203
|
+
for (const wrapped of renderWrapped(line, Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
|
|
204
|
+
}
|
|
205
|
+
return lines;
|
|
206
|
+
}
|
|
207
|
+
lines.push(railLine(`${glyph} ${theme.fg("toolTitle", theme.bold(event.name))}`, width, theme));
|
|
208
|
+
if (event.argsPayload) {
|
|
209
|
+
lines.push(railLine(theme.fg("dim", " args"), width, theme));
|
|
210
|
+
for (const argLine of event.argsPayload.split(/\r?\n/)) {
|
|
211
|
+
for (const wrapped of renderWrapped(theme.fg("muted", argLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (output) {
|
|
215
|
+
lines.push(railLine(theme.fg(event.status === "error" ? "error" : "dim", event.status === "error" ? " error" : " output"), width, theme));
|
|
216
|
+
for (const outputLine of output.split(/\r?\n/)) {
|
|
217
|
+
for (const wrapped of renderWrapped(theme.fg(outputColor, outputLine), Math.max(1, width - 4))) lines.push(railLine(` ${wrapped}`, width, theme));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return lines;
|
|
221
|
+
}
|
|
222
|
+
function bounded(text, width) {
|
|
223
|
+
return truncateToWidth(text, Math.max(0, width));
|
|
224
|
+
}
|
|
225
|
+
function railLine(content, width, theme) {
|
|
226
|
+
return bounded(`${theme.fg("borderMuted", "\u2502")} ${content}`, width);
|
|
227
|
+
}
|
|
228
|
+
function renderWrapped(text, width) {
|
|
229
|
+
return wrapTextWithAnsi(text, Math.max(1, width));
|
|
230
|
+
}
|
|
231
|
+
function renderFleetTranscript(transcript, width, theme, markdownTheme, options = {}) {
|
|
232
|
+
if (width <= 0) return [];
|
|
233
|
+
const lines = [];
|
|
234
|
+
if (transcript.truncated) lines.push(bounded(theme.fg("dim", "\u2191 Earlier activity omitted"), width));
|
|
235
|
+
if (transcript.warning) {
|
|
236
|
+
for (const line of renderWrapped(safeTerminalText(transcript.warning), Math.max(1, width - 2))) {
|
|
237
|
+
lines.push(bounded(`${theme.fg("warning", "!")} ${theme.fg("warning", line)}`, width));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
for (const rawEvent of transcript.events) {
|
|
241
|
+
const event = safeTranscriptEvent(rawEvent);
|
|
242
|
+
if (event.kind === "tool") {
|
|
243
|
+
if (options.expandedTools && (event.output || event.argsPayload || event.error)) {
|
|
244
|
+
lines.push(...renderExpandedTool(event, width, theme));
|
|
245
|
+
lines.push(railLine(theme.fg("dim", " x to collapse"), width, theme));
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const title = theme.fg("toolTitle", theme.bold(event.name));
|
|
249
|
+
const args = event.args ? ` ${theme.fg("dim", event.args)}` : "";
|
|
250
|
+
const suffix = event.status === "running" ? theme.fg("warning", " running") : "";
|
|
251
|
+
lines.push(bounded(`${theme.fg("borderMuted", "\u251C\u2500")} ${statusGlyph(event, theme)} ${title}${args}${suffix}`, width));
|
|
252
|
+
if (event.output && event.status !== "error" && event.name === "bash") {
|
|
253
|
+
const outputLines = event.output.replace(/\s+$/, "").split(/\r?\n/);
|
|
254
|
+
const visible = outputLines.slice(-TOOL_PREVIEW_LINES);
|
|
255
|
+
const hidden = Math.max(0, outputLines.length - visible.length);
|
|
256
|
+
for (const outputLine of visible) {
|
|
257
|
+
for (const wrapped of renderWrapped(theme.fg("toolOutput", outputLine), Math.max(1, width - 4))) {
|
|
258
|
+
lines.push(railLine(` ${wrapped}`, width, theme));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (hidden > 0) lines.push(railLine(theme.fg("dim", ` \u2026 ${hidden} earlier lines \xB7 x to expand`), width, theme));
|
|
262
|
+
const duration = toolDuration(event);
|
|
263
|
+
lines.push(railLine(theme.fg("dim", ` Took${duration ? ` ${duration}` : ""}`), width, theme));
|
|
264
|
+
} else if (event.output && event.status !== "error") {
|
|
265
|
+
const summary = truncateToWidth(event.output.replace(/\s+/g, " ").trim(), Math.max(1, width - 18), "\u2026");
|
|
266
|
+
if (summary) lines.push(railLine(theme.fg("dim", ` ${summary} \xB7 x to expand`), width, theme));
|
|
267
|
+
}
|
|
268
|
+
if (event.error) {
|
|
269
|
+
for (const errorLine of renderWrapped(event.error, Math.max(1, width - 4))) {
|
|
270
|
+
lines.push(railLine(theme.fg("error", ` ${errorLine}`), width, theme));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (event.kind === "notice") {
|
|
276
|
+
const color = event.tone === "error" ? "error" : event.tone === "warning" ? "warning" : "dim";
|
|
277
|
+
for (const noticeLine of renderWrapped(event.text, Math.max(1, width - 2))) {
|
|
278
|
+
lines.push(railLine(theme.fg(color, noticeLine), width, theme));
|
|
279
|
+
}
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const assistant = event.kind === "assistant";
|
|
283
|
+
const label = assistant ? "Assistant" : "Supervisor";
|
|
284
|
+
const marker = assistant ? theme.fg("accent", "\u25C6") : theme.fg("warning", "\u25C7");
|
|
285
|
+
const model = assistant && event.model ? theme.fg("dim", ` \xB7 ${event.model}`) : "";
|
|
286
|
+
lines.push(bounded(`${marker} ${theme.bold(label)}${model}`, width));
|
|
287
|
+
if (assistant) {
|
|
288
|
+
const rendered = new Markdown(event.text, 0, 0, markdownTheme).render(Math.max(1, width - 2));
|
|
289
|
+
for (const markdownLine of rendered) lines.push(railLine(markdownLine, width, theme));
|
|
290
|
+
} else {
|
|
291
|
+
for (const userLine of renderWrapped(event.text, Math.max(1, width - 2))) {
|
|
292
|
+
lines.push(railLine(userLine, width, theme));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
lines.push(theme.fg("borderMuted", "\u2502"));
|
|
296
|
+
}
|
|
297
|
+
while (lines.length > 0 && visibleWidth(lines.at(-1) ?? "") === 1) lines.pop();
|
|
298
|
+
return lines;
|
|
299
|
+
}
|
|
300
|
+
|
|
146
301
|
// src/tui/fleet-native-transcript.ts
|
|
147
302
|
var REQUIRED_NATIVE_EXPORTS = [
|
|
148
303
|
"createTranscriptState",
|
|
@@ -598,7 +753,7 @@ function collectFleetSnapshot(state, options = {}) {
|
|
|
598
753
|
entryLimit: MAX_FLEET_HISTORY_CANDIDATES,
|
|
599
754
|
resultsDir: options.resultsDir ?? DIRS.results,
|
|
600
755
|
reconcile: false,
|
|
601
|
-
onCorruptStatus: (warning) =>
|
|
756
|
+
onCorruptStatus: (warning) => reportSessionWarning(state, warning)
|
|
602
757
|
}).filter((run) => !trackedIds.has(run.id));
|
|
603
758
|
runs = [...trackedRuns, ...history];
|
|
604
759
|
} else {
|
|
@@ -612,7 +767,7 @@ function collectFleetSnapshot(state, options = {}) {
|
|
|
612
767
|
}
|
|
613
768
|
if (state.currentSessionId) {
|
|
614
769
|
try {
|
|
615
|
-
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) =>
|
|
770
|
+
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportSessionWarning(state, `Removed ${message}`) })) {
|
|
616
771
|
items.push({
|
|
617
772
|
key: `external:${run.id}`,
|
|
618
773
|
kind: "external",
|
|
@@ -679,7 +834,7 @@ function fleetItemThinkingLevel(item) {
|
|
|
679
834
|
return void 0;
|
|
680
835
|
}
|
|
681
836
|
}
|
|
682
|
-
function
|
|
837
|
+
function statusGlyph2(item, theme) {
|
|
683
838
|
if (item.state === "running") return runningTone(theme, fleetItemThinkingLevel(item))("\u25CF");
|
|
684
839
|
if (item.state === "queued" || item.state === "pending") return theme.fg("muted", "\u25E6");
|
|
685
840
|
if (item.state === "complete" || item.state === "completed") return theme.fg("success", "\u2713");
|
|
@@ -697,7 +852,7 @@ function promptAuditString(value) {
|
|
|
697
852
|
function authoredPromptSummary(text) {
|
|
698
853
|
if (typeof text !== "string") return void 0;
|
|
699
854
|
const summary = text.replace(/\s+/g, " ").trim();
|
|
700
|
-
return summary ?
|
|
855
|
+
return summary ? truncateToWidth2(summary, PROMPT_AUDIT_SUMMARY_WIDTH, "\u2026") : void 0;
|
|
701
856
|
}
|
|
702
857
|
function foregroundAuthoredPromptSummary(item, state) {
|
|
703
858
|
if (!state.currentSessionId || item.control.sessionId !== state.currentSessionId) return void 0;
|
|
@@ -1035,7 +1190,7 @@ function itemStats(item) {
|
|
|
1035
1190
|
}
|
|
1036
1191
|
function structuredHeader(item, width, theme, conversationState, promptSummary) {
|
|
1037
1192
|
const lines = [];
|
|
1038
|
-
lines.push(rightAligned(` ${
|
|
1193
|
+
lines.push(rightAligned(` ${statusGlyph2(item, theme)} ${theme.bold(item.agent)}`, theme.fg("dim", item.state), width));
|
|
1039
1194
|
const child = "index" in item && item.index !== void 0 ? ` \xB7 child ${item.index + 1}` : "";
|
|
1040
1195
|
const context = itemContext(item);
|
|
1041
1196
|
const identity = `${itemSource(item)} \xB7 ${item.runId.slice(0, 8)}${child} \xB7 ${itemMode(item)}${context ? ` ${context}` : ""}`;
|
|
@@ -1044,14 +1199,14 @@ function structuredHeader(item, width, theme, conversationState, promptSummary)
|
|
|
1044
1199
|
if (stats.length) lines.push(` ${theme.fg("muted", stats.join(" \xB7 "))}`);
|
|
1045
1200
|
if (promptSummary) lines.push(` ${theme.fg("muted", `Task: ${promptSummary}`)}`);
|
|
1046
1201
|
lines.push(`${theme.fg("accent", "Conversation")} ${theme.fg("dim", `\xB7 ${conversationState}`)}`);
|
|
1047
|
-
return lines.map((line) =>
|
|
1202
|
+
return lines.map((line) => truncateToWidth2(line, width));
|
|
1048
1203
|
}
|
|
1049
1204
|
function fit(text, width) {
|
|
1050
|
-
const clipped =
|
|
1051
|
-
return clipped + " ".repeat(Math.max(0, width -
|
|
1205
|
+
const clipped = truncateToWidth2(text, Math.max(0, width));
|
|
1206
|
+
return clipped + " ".repeat(Math.max(0, width - visibleWidth2(clipped)));
|
|
1052
1207
|
}
|
|
1053
1208
|
function rightAligned(left, right, width) {
|
|
1054
|
-
const rightWidth =
|
|
1209
|
+
const rightWidth = visibleWidth2(right);
|
|
1055
1210
|
const leftWidth = Math.max(0, width - rightWidth - 1);
|
|
1056
1211
|
return fit(left, leftWidth) + " ".repeat(Math.max(1, width - leftWidth - rightWidth)) + fit(right, rightWidth);
|
|
1057
1212
|
}
|
|
@@ -1568,7 +1723,7 @@ var SubagentFleetComponent = class {
|
|
|
1568
1723
|
const name = task && item.kind === "async" && item.step ? item.step.agent : item.agent;
|
|
1569
1724
|
const agent = index === this.selected ? this.theme.bold(name) : name;
|
|
1570
1725
|
const identity = task ?? item.runId.slice(0, 8);
|
|
1571
|
-
const left = `${marker} ${
|
|
1726
|
+
const left = `${marker} ${statusGlyph2(item, this.theme)} ${agent}${context} ${this.theme.fg("dim", `\xB7 ${identity}`)}`;
|
|
1572
1727
|
return rightAligned(left, this.theme.fg("dim", item.state), layout.roster.width);
|
|
1573
1728
|
});
|
|
1574
1729
|
}
|
|
@@ -1612,7 +1767,7 @@ var SubagentFleetComponent = class {
|
|
|
1612
1767
|
this.theme.fg("accent", viewLabel),
|
|
1613
1768
|
promptText
|
|
1614
1769
|
];
|
|
1615
|
-
const body = raw.filter((line) => line !== void 0).flatMap((line) =>
|
|
1770
|
+
const body = raw.filter((line) => line !== void 0).flatMap((line) => wrapTextWithAnsi2(line, Math.max(1, width)));
|
|
1616
1771
|
return { header: [], body: this.withActionLines(body) };
|
|
1617
1772
|
}
|
|
1618
1773
|
wrappedDetail(width) {
|
|
@@ -1637,7 +1792,7 @@ var SubagentFleetComponent = class {
|
|
|
1637
1792
|
const lines = [];
|
|
1638
1793
|
for (const line of raw) {
|
|
1639
1794
|
const styled = /^(Run|State|Mode|Source|Child|Agent|Model|Task):/.test(line) ? this.theme.bold(line) : /^(Transcript|Result transcript tail)/.test(line) ? this.theme.fg("accent", line) : /^(Output|Session|Transcript file|Artifacts):/.test(line) ? this.theme.fg("muted", line) : /^Transcript preview warning:/.test(line) ? this.theme.fg("warning", line) : line;
|
|
1640
|
-
const wrapped =
|
|
1795
|
+
const wrapped = wrapTextWithAnsi2(styled, Math.max(1, width));
|
|
1641
1796
|
lines.push(...wrapped.length ? wrapped : [""]);
|
|
1642
1797
|
}
|
|
1643
1798
|
return { header: [], body: this.withActionLines(lines) };
|
|
@@ -1645,7 +1800,7 @@ var SubagentFleetComponent = class {
|
|
|
1645
1800
|
render(width) {
|
|
1646
1801
|
const layout = fleetLayout(width, this.tui.terminal?.rows ?? 32, this.selected, this.snapshot.items);
|
|
1647
1802
|
this.renderedLayout = layout;
|
|
1648
|
-
if (!layout) return [
|
|
1803
|
+
if (!layout) return [truncateToWidth2("Subagent fleet needs at least 36 columns. Esc closes.", width)];
|
|
1649
1804
|
const innerWidth = width - 2;
|
|
1650
1805
|
const { bodyHeight } = layout;
|
|
1651
1806
|
const rosterWidth = layout.roster.width;
|
|
@@ -1662,7 +1817,7 @@ var SubagentFleetComponent = class {
|
|
|
1662
1817
|
const lines = [this.theme.fg("border", `\u256D${"\u2500".repeat(innerWidth)}\u256E`)];
|
|
1663
1818
|
const selected = this.snapshot.items[this.selected];
|
|
1664
1819
|
const title = selected?.kind === "external" ? ` ${this.theme.bold("Fleet inspector")} ${this.theme.fg("dim", "\xB7 external display-only")}` : ` ${this.theme.bold("Subagent fleet inspector")} ${this.theme.fg("dim", "\xB7 live controls")}`;
|
|
1665
|
-
const selectedStatus = selected ? `${
|
|
1820
|
+
const selectedStatus = selected ? `${statusGlyph2(selected, this.theme)} ${selected.agent} \xB7 ${selected.state} ` : this.theme.fg("dim", "no children ");
|
|
1666
1821
|
lines.push(this.theme.fg("border", "\u2502") + rightAligned(title, selectedStatus, innerWidth) + this.theme.fg("border", "\u2502"));
|
|
1667
1822
|
lines.push(this.theme.fg("border", `\u251C${"\u2500".repeat(rosterWidth)}\u252C${"\u2500".repeat(detailWidth)}\u2524`));
|
|
1668
1823
|
for (let index = 0; index < bodyHeight; index++) {
|
|
@@ -1675,7 +1830,7 @@ var SubagentFleetComponent = class {
|
|
|
1675
1830
|
const footer = this.promptAuditOpen ? ` j/k child \xB7 1/2/3 view \xB7 g redo with guidance \xB7 c copy \xB7 wheel \u2191\u2193 \xB7 Esc close Prompt Audit \xB7 ${position}` : selected?.kind === "external" ? ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} job \xB7 display-only \xB7 ${bindingLabel(this.keybindings, "refresh")} refresh \xB7 wheel \u2191\u2193 \xB7 ${bindingLabel(this.keybindings, "close")} close \xB7 ${position}` : ` ${bindingLabel(this.keybindings, "selectUp")}/${bindingLabel(this.keybindings, "selectDown")} agent \xB7 p Prompt Audit \xB7 ${bindingLabel(this.keybindings, "inspect")} Inspect \xB7 ${bindingLabel(this.keybindings, "steer")} steer \xB7 ${bindingLabel(this.keybindings, "stop")} stop \xB7 ${bindingLabel(this.keybindings, "toggleTools")} tools \xB7 ${bindingLabel(this.keybindings, "toggleThinking")} thinking \xB7 ${bindingLabel(this.keybindings, "toggleRenderer")} view \xB7 ${bindingLabel(this.keybindings, "refresh")} refresh \xB7 wheel \u2191\u2193 \xB7 ${bindingLabel(this.keybindings, "close")} close \xB7 ${position}`;
|
|
1676
1831
|
lines.push(this.theme.fg("border", "\u2502") + fit(this.theme.fg("dim", footer), innerWidth) + this.theme.fg("border", "\u2502"));
|
|
1677
1832
|
lines.push(this.theme.fg("border", `\u2570${"\u2500".repeat(innerWidth)}\u256F`));
|
|
1678
|
-
return lines.map((line) =>
|
|
1833
|
+
return lines.map((line) => truncateToWidth2(line, width));
|
|
1679
1834
|
}
|
|
1680
1835
|
invalidate() {
|
|
1681
1836
|
this.renderedLayout = void 0;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// src/shared/session-succession.ts
|
|
2
|
+
var SUCCESSION_KEY = /* @__PURE__ */ Symbol.for("pi-subagents.session-succession");
|
|
3
|
+
var MAX_INHERITED_SESSIONS = 8;
|
|
4
|
+
var MAX_RECORDED_SESSIONS = 64;
|
|
5
|
+
var KEPT_WORK_KEY = /* @__PURE__ */ Symbol.for("pi-subagents.sessions-keeping-work");
|
|
6
|
+
function successions() {
|
|
7
|
+
const runtime = globalThis;
|
|
8
|
+
runtime[SUCCESSION_KEY] ??= /* @__PURE__ */ new Map();
|
|
9
|
+
return runtime[SUCCESSION_KEY];
|
|
10
|
+
}
|
|
11
|
+
function keptWork() {
|
|
12
|
+
const runtime = globalThis;
|
|
13
|
+
runtime[KEPT_WORK_KEY] ??= /* @__PURE__ */ new Set();
|
|
14
|
+
return runtime[KEPT_WORK_KEY];
|
|
15
|
+
}
|
|
16
|
+
function keepSessionWork(sessionId) {
|
|
17
|
+
keptWork().delete(sessionId);
|
|
18
|
+
keptWork().add(sessionId);
|
|
19
|
+
while (keptWork().size > MAX_RECORDED_SESSIONS) keptWork().delete(keptWork().values().next().value);
|
|
20
|
+
}
|
|
21
|
+
function releaseSessionWork(sessionId) {
|
|
22
|
+
keptWork().delete(sessionId);
|
|
23
|
+
}
|
|
24
|
+
function recordSessionReplacement(sessionId, previousSessionId) {
|
|
25
|
+
const inherited = keptWork().has(previousSessionId) ? [] : [previousSessionId, ...successions().get(previousSessionId) ?? []];
|
|
26
|
+
const own = keptWork().has(sessionId) ? successions().get(sessionId) ?? [] : [];
|
|
27
|
+
const chain = [.../* @__PURE__ */ new Set([...inherited, ...own])].filter((id) => id !== sessionId);
|
|
28
|
+
successions().delete(sessionId);
|
|
29
|
+
successions().set(sessionId, chain.slice(0, MAX_INHERITED_SESSIONS));
|
|
30
|
+
while (successions().size > MAX_RECORDED_SESSIONS) successions().delete(successions().keys().next().value);
|
|
31
|
+
}
|
|
32
|
+
function recordSessionStart(sessionId, startup) {
|
|
33
|
+
if (startup) {
|
|
34
|
+
successions().delete(sessionId);
|
|
35
|
+
keptWork().delete(sessionId);
|
|
36
|
+
}
|
|
37
|
+
for (const [id, chain] of successions()) {
|
|
38
|
+
if (chain.includes(sessionId)) successions().set(id, chain.filter((inherited) => inherited !== sessionId));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function inheritedSessionIds(sessionId) {
|
|
42
|
+
return successions().get(sessionId) ?? [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/shared/extension-context.ts
|
|
46
|
+
var MODEL_ONLY_TOOL = { exposure: "model-only" };
|
|
47
|
+
function isStaleExtensionContextError(error) {
|
|
48
|
+
return error instanceof Error && /extension ctx is stale|extension context no longer active|stale after session replacement or reload/i.test(error.message);
|
|
49
|
+
}
|
|
50
|
+
function canRenderComponents(ctx) {
|
|
51
|
+
return ctx.mode === "tui" || process.env.PI_SUBAGENTS_COMPONENT_UI === "1";
|
|
52
|
+
}
|
|
53
|
+
function isUnboundExtensionRuntimeError(error) {
|
|
54
|
+
return error instanceof Error && /extension runtime not initialized/i.test(error.message);
|
|
55
|
+
}
|
|
56
|
+
function withCachedUiContext(ctx, onStale, run) {
|
|
57
|
+
if (!ctx) return void 0;
|
|
58
|
+
try {
|
|
59
|
+
if (!ctx.hasUI) return void 0;
|
|
60
|
+
return run(ctx);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (!isStaleExtensionContextError(error)) throw error;
|
|
63
|
+
onStale();
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/shared/session-warnings.ts
|
|
69
|
+
var reportedWarnings = /* @__PURE__ */ new WeakMap();
|
|
70
|
+
function reportSessionWarning(state, message, key = message) {
|
|
71
|
+
let reported = reportedWarnings.get(state);
|
|
72
|
+
if (!reported) reportedWarnings.set(state, reported = /* @__PURE__ */ new Set());
|
|
73
|
+
if (reported.has(key)) return;
|
|
74
|
+
reported.add(key);
|
|
75
|
+
const text = `[pi-subagents] ${message}`;
|
|
76
|
+
const cached = state.lastUiContext;
|
|
77
|
+
const notified = withCachedUiContext(cached, () => {
|
|
78
|
+
if (state.lastUiContext === cached) state.lastUiContext = null;
|
|
79
|
+
}, (ctx) => {
|
|
80
|
+
ctx.ui.notify(text, "warning");
|
|
81
|
+
return true;
|
|
82
|
+
});
|
|
83
|
+
if (!notified) console.warn(text);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/runs/shared/run-ownership.ts
|
|
87
|
+
function ownerSessionIds(sessionId) {
|
|
88
|
+
return /* @__PURE__ */ new Set([sessionId, ...inheritedSessionIds(sessionId)]);
|
|
89
|
+
}
|
|
90
|
+
function ownsRun(currentSessionId, runSessionId) {
|
|
91
|
+
return currentSessionId ? ownerSessionIds(currentSessionId).has(runSessionId) : false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
keepSessionWork,
|
|
96
|
+
releaseSessionWork,
|
|
97
|
+
recordSessionReplacement,
|
|
98
|
+
recordSessionStart,
|
|
99
|
+
inheritedSessionIds,
|
|
100
|
+
ownerSessionIds,
|
|
101
|
+
ownsRun,
|
|
102
|
+
MODEL_ONLY_TOOL,
|
|
103
|
+
isStaleExtensionContextError,
|
|
104
|
+
canRenderComponents,
|
|
105
|
+
isUnboundExtensionRuntimeError,
|
|
106
|
+
withCachedUiContext,
|
|
107
|
+
reportSessionWarning
|
|
108
|
+
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getProjectConfigDir,
|
|
10
10
|
validatePermissionProfileName,
|
|
11
11
|
validateSandboxProfileName
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XAC2XNAP.js";
|
|
13
13
|
import {
|
|
14
14
|
TEMP_ROOT_DIR
|
|
15
15
|
} from "./chunk-UQDHXMUG.js";
|
|
@@ -58,7 +58,7 @@ function isMcpServerDefinition(value) {
|
|
|
58
58
|
}
|
|
59
59
|
if (value.requestHeadersCommand !== void 0 && !isRequestHeadersCommand(value.requestHeadersCommand)) return false;
|
|
60
60
|
if (value.auth !== void 0 && value.auth !== "oauth" && value.auth !== "bearer" && value.auth !== false) return false;
|
|
61
|
-
return value.directTools === void 0 || typeof value.directTools === "boolean" || isStringArray(value.directTools);
|
|
61
|
+
return value.directTools === void 0 || typeof value.directTools === "boolean" || value.directTools === "search" || isStringArray(value.directTools);
|
|
62
62
|
}
|
|
63
63
|
function isRecord(value) {
|
|
64
64
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -355,7 +355,12 @@ function readJson(filePath) {
|
|
|
355
355
|
// src/runs/shared/mcp-direct-tool-grant.ts
|
|
356
356
|
var BUILTIN_TOOL_NAMES = /* @__PURE__ */ new Set(["read", "bash", "edit", "write", "grep", "find", "ls", "mcp"]);
|
|
357
357
|
function normalizeMcpDirectToolSelectors(selectors) {
|
|
358
|
-
return [...new Set((selectors ?? []).map(
|
|
358
|
+
return [...new Set((selectors ?? []).map(trimTrailingSlashes).filter(Boolean))];
|
|
359
|
+
}
|
|
360
|
+
function trimTrailingSlashes(selector) {
|
|
361
|
+
let end = selector.length;
|
|
362
|
+
while (end > 0 && selector[end - 1] === "/") end -= 1;
|
|
363
|
+
return selector.slice(0, end);
|
|
359
364
|
}
|
|
360
365
|
function parseMcpDirectToolSelectors(selectors) {
|
|
361
366
|
const servers = /* @__PURE__ */ new Set();
|
|
@@ -506,17 +511,20 @@ function resolveMcpDirectToolResolution(mcpDirectTools, cwd = process.cwd(), run
|
|
|
506
511
|
const runtimeSelectionServers = /* @__PURE__ */ new Set([...selectedServers, ...selectedTools.keys()]);
|
|
507
512
|
const runtimeServers = resolveRuntimeMcpServers(config, runtimeSelectionServers, runtimeSnapshotHost);
|
|
508
513
|
const resolvedConfig = Object.keys(runtimeServers).length > 0 ? mergeConfigs(config, { mcpServers: runtimeServers }) : config;
|
|
509
|
-
|
|
514
|
+
const enabledSelectors = selectors.filter((selector) => resolvedConfig.mcpServers[selector.split("/", 1)[0]]?.disabled !== true);
|
|
515
|
+
validateSelectedServerDefinitions(resolvedConfig, enabledSelectors);
|
|
510
516
|
const runtime = Object.keys(runtimeServers).length > 0 ? { mcpConfig: resolvedConfig, runtimeServerNames: Object.keys(runtimeServers) } : {};
|
|
517
|
+
if (enabledSelectors.length === 0) return { selections: [], unresolvedSelectors: [], ...runtime };
|
|
511
518
|
const cache = loadMetadataCache();
|
|
512
|
-
if (!cache) return { selections: [], unresolvedSelectors:
|
|
519
|
+
if (!cache) return { selections: [], unresolvedSelectors: enabledSelectors, ...runtime };
|
|
513
520
|
const validMetadata = {};
|
|
514
521
|
for (const [serverName, definition] of Object.entries(resolvedConfig.mcpServers)) {
|
|
522
|
+
if (definition.disabled === true) continue;
|
|
515
523
|
const serverCache = cache.servers[serverName];
|
|
516
524
|
if (isServerCacheValid(serverCache, definition)) validMetadata[serverName] = serverCache;
|
|
517
525
|
}
|
|
518
526
|
const grant = planMcpDirectToolGrant({
|
|
519
|
-
selectors,
|
|
527
|
+
selectors: enabledSelectors,
|
|
520
528
|
servers: resolvedConfig.mcpServers,
|
|
521
529
|
metadata: validMetadata,
|
|
522
530
|
toolPrefix: resolvedConfig.settings?.toolPrefix
|
|
@@ -702,10 +710,8 @@ function parseServerEntries(value) {
|
|
|
702
710
|
function parseSettings(value) {
|
|
703
711
|
if (!isRecord2(value)) return void 0;
|
|
704
712
|
const toolPrefix = value.toolPrefix === "server" || value.toolPrefix === "short" || value.toolPrefix === "none" || value.toolPrefix === "mcp" ? value.toolPrefix : void 0;
|
|
705
|
-
const directTools = typeof value.directTools === "boolean" ? value.directTools : void 0;
|
|
706
713
|
const settings = {
|
|
707
714
|
...toolPrefix ? { toolPrefix } : {},
|
|
708
|
-
...directTools !== void 0 ? { directTools } : {},
|
|
709
715
|
...value.agentPluginPaths !== void 0 ? { agentPluginPaths: value.agentPluginPaths } : {}
|
|
710
716
|
};
|
|
711
717
|
return Object.keys(settings).length ? settings : void 0;
|
|
@@ -713,11 +719,20 @@ function parseSettings(value) {
|
|
|
713
719
|
function mergeConfigs(base, next) {
|
|
714
720
|
const imports = [...base.imports ?? [], ...next.imports ?? []];
|
|
715
721
|
return {
|
|
716
|
-
mcpServers:
|
|
722
|
+
mcpServers: mergeServerDefinitions(base.mcpServers, next.mcpServers),
|
|
717
723
|
imports: imports.length ? [...new Set(imports)] : void 0,
|
|
718
724
|
settings: next.settings ? { ...base.settings, ...next.settings } : base.settings
|
|
719
725
|
};
|
|
720
726
|
}
|
|
727
|
+
function mergeServerDefinitions(base, next) {
|
|
728
|
+
const servers = { ...base };
|
|
729
|
+
for (const [name, definition] of Object.entries(next)) {
|
|
730
|
+
const previous = base[name];
|
|
731
|
+
if (previous && Object.keys(definition).every((key) => key === "disabled")) servers[name] = { ...previous, ...definition };
|
|
732
|
+
else servers[name] = previous?.disabled === void 0 ? definition : { disabled: previous.disabled, ...definition };
|
|
733
|
+
}
|
|
734
|
+
return servers;
|
|
735
|
+
}
|
|
721
736
|
function expandImports(config, cwd) {
|
|
722
737
|
if (!config.imports?.length) return config;
|
|
723
738
|
const importedServers = {};
|
|
@@ -737,7 +752,7 @@ function expandImports(config, cwd) {
|
|
|
737
752
|
return {
|
|
738
753
|
imports: config.imports,
|
|
739
754
|
settings: config.settings,
|
|
740
|
-
mcpServers:
|
|
755
|
+
mcpServers: mergeServerDefinitions(importedServers, config.mcpServers)
|
|
741
756
|
};
|
|
742
757
|
}
|
|
743
758
|
function resolveImportPath(importKind, cwd) {
|
|
@@ -804,7 +819,7 @@ function interpolateEnvRecord(values) {
|
|
|
804
819
|
return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, interpolateSecretExpression(value)]));
|
|
805
820
|
}
|
|
806
821
|
function interpolateEnvVars(value) {
|
|
807
|
-
return value.replace(/\$\{(\w+)
|
|
822
|
+
return value.replace(/\$\{(\w+)(?::-([^}]*))?\}/g, (_, name, fallback) => process.env[name] ?? fallback ?? "").replace(/\$env:(\w+)/g, (_, name) => process.env[name] ?? "").replace(/\{env:(\w+)\}/g, (_, name) => process.env[name] ?? "");
|
|
808
823
|
}
|
|
809
824
|
function interpolateSecretExpression(value) {
|
|
810
825
|
if (value.startsWith("!!")) return interpolateEnvVars(value.slice(1));
|
|
@@ -812,9 +827,9 @@ function interpolateSecretExpression(value) {
|
|
|
812
827
|
}
|
|
813
828
|
function getMissingEnvVars(value) {
|
|
814
829
|
const missing = /* @__PURE__ */ new Set();
|
|
815
|
-
for (const match of value.matchAll(/\$\{(\w+)
|
|
816
|
-
const name = match[1] ?? match[
|
|
817
|
-
if (name && process.env[name] === void 0) missing.add(name);
|
|
830
|
+
for (const match of value.matchAll(/\$\{(\w+)(:-[^}]*)?\}|\$env:(\w+)|\{env:(\w+)\}/g)) {
|
|
831
|
+
const name = match[1] ?? match[3] ?? match[4];
|
|
832
|
+
if (name && match[2] === void 0 && process.env[name] === void 0) missing.add(name);
|
|
818
833
|
}
|
|
819
834
|
return [...missing];
|
|
820
835
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
validatePermissionRules,
|
|
11
11
|
validateSandboxProfileName,
|
|
12
12
|
validateToolBudgetConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XAC2XNAP.js";
|
|
14
14
|
|
|
15
15
|
// src/agents/runtime-agent-registry.ts
|
|
16
16
|
var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";
|