@vicary/pi-subagents 0.84.0 → 0.86.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 +83 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-VQVVHSY6.js → chunk-2DITXA3H.js} +22 -11
- package/bundle/{chunk-V2BZYLEP.js → chunk-374MZFF4.js} +7 -2
- package/bundle/{chunk-4E7BKDTX.js → chunk-3RKFH2UZ.js} +11 -156
- package/bundle/{chunk-F4ASL6OV.js → chunk-5H4BICQZ.js} +1 -1
- package/bundle/{chunk-PALJGGYC.js → chunk-6VD7BGIC.js} +6 -3
- package/bundle/{chunk-C5P5CHYK.js → chunk-77ASNIEM.js} +1 -1
- package/bundle/{chunk-PV63UFUR.js → chunk-7QA7ZA46.js} +183 -28
- package/bundle/{chunk-NKQ6JNAS.js → chunk-7ZUFN6ME.js} +2 -1
- package/bundle/{chunk-L3WFKBEI.js → chunk-BGXEAYUM.js} +247 -153
- package/bundle/{chunk-J5YL7LYR.js → chunk-BU6PFPVX.js} +59 -27
- package/bundle/{chunk-7BWGNDNK.js → chunk-CJHFDQFJ.js} +196 -1183
- package/bundle/{chunk-DZDETGRJ.js → chunk-DD22RXYJ.js} +259 -216
- package/bundle/{chunk-CGN2TVE7.js → chunk-GJGTMLPE.js} +322 -18
- package/bundle/{chunk-XDQORLZ5.js → chunk-GLVJMI6R.js} +15 -6
- package/bundle/{chunk-D3JAFGMO.js → chunk-GRJHIXYF.js} +1 -1
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-LFDBD4PW.js → chunk-LGINOOY5.js} +2 -2
- package/bundle/{chunk-G2Z6ZH26.js → chunk-NAFLUJ26.js} +1 -1
- package/bundle/{chunk-2DHZTCOL.js → chunk-PYOAIN3V.js} +2 -2
- package/bundle/{chunk-RSLHTEQV.js → chunk-QFLPV64W.js} +324 -111
- package/bundle/{chunk-LNRJCP2Y.js → chunk-QGO6HXHG.js} +417 -242
- package/bundle/{chunk-2S4K53MV.js → chunk-S2Q75LP3.js} +1 -1
- package/bundle/{chunk-NENDSQUY.js → chunk-UR7OW5S7.js} +9 -6
- package/bundle/{chunk-RWPNQZHS.js → chunk-WHC2XHGF.js} +217 -106
- package/bundle/{chunk-AKOIVLA5.js → chunk-WN2E5XHN.js} +135 -77
- package/bundle/{chunk-4NIY3BE6.js → chunk-XOFYXQKZ.js} +2 -2
- package/bundle/{chunk-2D52JFLF.js → chunk-YK3QYNLE.js} +41 -117
- package/bundle/chunk-ZPY5QZCS.js +1067 -0
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +24 -3
- package/docs/configuration.md +9 -9
- package/docs/extension-api.md +16 -1
- package/docs/observability.md +1 -1
- package/docs/tool-reference.md +3 -1
- package/docs/workflows.md +31 -3
- package/package.json +2 -2
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +6 -4
- 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 +35 -12
- 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 +5 -10
- package/src/runs/background/async-execution.js +63 -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 +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.d.ts +0 -1
- package/src/runs/background/auto-drain.js +7 -6
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +15 -12
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +7 -8
- package/src/runs/foreground/subagent-executor.js +113 -44
- package/src/runs/shared/acceptance.js +69 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-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 +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +90 -65
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +161 -66
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
|
@@ -22,6 +22,7 @@ import { SUBAGENT_GUIDE_TOPICS } from "../extension/subagent-guide.js";
|
|
|
22
22
|
import { getInspectorPlugins } from "../inspectors/plugins.js";
|
|
23
23
|
import { applySlashUpdate, buildSlashInitialResult, failSlashResult, finalizeSlashResult, } from "./slash-live-state.js";
|
|
24
24
|
import { SLASH_RESULT_TYPE, SLASH_TEXT_RESULT_TYPE, SLASH_TEXT_VIEW_ONLY_DETAILS, SLASH_SUBAGENT_CANCEL_EVENT, SLASH_SUBAGENT_REQUEST_EVENT, SLASH_SUBAGENT_RESPONSE_EVENT, SLASH_SUBAGENT_STARTED_EVENT, SLASH_SUBAGENT_UPDATE_EVENT, DIRS, } from "../shared/types.js";
|
|
25
|
+
import { waitToolName } from "../shared/wait-tool-name.js";
|
|
25
26
|
const parseInlineConfig = (raw) => {
|
|
26
27
|
const config = {};
|
|
27
28
|
for (const part of raw.split(",")) {
|
|
@@ -729,7 +730,7 @@ export function registerSlashCommands(pi, state, options = {}) {
|
|
|
729
730
|
ctx.ui.notify(`Foreground run ${control.runId} is not currently detachable.`, "info");
|
|
730
731
|
return;
|
|
731
732
|
}
|
|
732
|
-
sendSlashText(pi, `Detached foreground run ${control.runId} without terminating its child. Use subagent({ action: "status", id: ${JSON.stringify(control.runId)} }) or
|
|
733
|
+
sendSlashText(pi, `Detached foreground run ${control.runId} without terminating its child. Use subagent({ action: "status", id: ${JSON.stringify(control.runId)} }) or ${waitToolName()}({ id: ${JSON.stringify(control.runId)} }) to recover the eventual result. This does not daemonize the process or guarantee survival across Pi reload/restart.`);
|
|
733
734
|
};
|
|
734
735
|
pi.registerCommand("subagents-detach", {
|
|
735
736
|
description: "Detach the active foreground single-subagent run without terminating it",
|
|
@@ -21,8 +21,9 @@ export declare const SUBAGENT_COST_REPORT_VERSION: 1;
|
|
|
21
21
|
/**
|
|
22
22
|
* Collect parent and child usage for the current session branch. Foreground
|
|
23
23
|
* children come from persisted `subagent`/`bg_wait` tool-result details; async
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* runs come from those results and `subagent-notify` completions. Async workflow
|
|
25
|
+
* children are resolved through receipts, and other async runs through their
|
|
26
|
+
* status steps, then artifact metadata.
|
|
26
27
|
*/
|
|
27
28
|
export declare function collectSubagentCost(ctx: ExtensionContext, state: Pick<SubagentState, "baseCwd" | "artifactDirPreference">): SubagentCostReport;
|
|
28
29
|
/** The `/subagent-cost` text rendering of a collected report. */
|
|
@@ -6,6 +6,7 @@ import { DIRS, SLASH_RESULT_TYPE } from "../shared/types.js";
|
|
|
6
6
|
import { readStatus } from "../shared/utils.js";
|
|
7
7
|
import { readWorkflowReceipt } from "../workflows/workflow-receipt.js";
|
|
8
8
|
import { resolveSlashMessageDetails } from "./slash-live-state.js";
|
|
9
|
+
import { DEFAULT_WAIT_TOOL_NAME, waitToolName } from "../shared/wait-tool-name.js";
|
|
9
10
|
export const SUBAGENT_COST_REPORT_VERSION = 1;
|
|
10
11
|
function emptyUsage() {
|
|
11
12
|
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
|
|
@@ -95,10 +96,25 @@ function detailsFromSessionEntry(entry) {
|
|
|
95
96
|
if (record.type !== "message" || !record.message || typeof record.message !== "object")
|
|
96
97
|
return undefined;
|
|
97
98
|
const message = record.message;
|
|
98
|
-
|
|
99
|
+
// Results saved before a waitTool.name rename carry bg_wait; another extension's bg_wait results fail isSubagentDetails.
|
|
100
|
+
if (message.role !== "toolResult" || (message.toolName !== "subagent" && message.toolName !== waitToolName() && message.toolName !== DEFAULT_WAIT_TOOL_NAME))
|
|
99
101
|
return undefined;
|
|
100
102
|
return isSubagentDetails(message.details) ? message.details : undefined;
|
|
101
103
|
}
|
|
104
|
+
/** Background runs a `subagent-notify` completion reports; an RPC `spawn` launch has no tool result, so this is its only record. */
|
|
105
|
+
function notifiedAsyncRuns(entry) {
|
|
106
|
+
if (!entry || typeof entry !== "object")
|
|
107
|
+
return [];
|
|
108
|
+
const record = entry;
|
|
109
|
+
if (record.type !== "custom_message" || record.customType !== "subagent-notify")
|
|
110
|
+
return [];
|
|
111
|
+
const runs = record.details?.runs;
|
|
112
|
+
if (!Array.isArray(runs))
|
|
113
|
+
return [];
|
|
114
|
+
return runs.flatMap((run) =>
|
|
115
|
+
// A detached foreground task keeps no async status directory to read usage from.
|
|
116
|
+
run && typeof run.runId === "string" && run.source !== "foreground" ? [{ runId: run.runId, workflow: run.workflowRunId === run.runId }] : []);
|
|
117
|
+
}
|
|
102
118
|
function metadataUsage(artifactsDirs, input, indexes = [0, undefined]) {
|
|
103
119
|
if (!/^[A-Za-z0-9._-]+$/.test(input.runId))
|
|
104
120
|
return undefined;
|
|
@@ -126,8 +142,9 @@ function metadataUsage(artifactsDirs, input, indexes = [0, undefined]) {
|
|
|
126
142
|
/**
|
|
127
143
|
* Collect parent and child usage for the current session branch. Foreground
|
|
128
144
|
* children come from persisted `subagent`/`bg_wait` tool-result details; async
|
|
129
|
-
*
|
|
130
|
-
*
|
|
145
|
+
* runs come from those results and `subagent-notify` completions. Async workflow
|
|
146
|
+
* children are resolved through receipts, and other async runs through their
|
|
147
|
+
* status steps, then artifact metadata.
|
|
131
148
|
*/
|
|
132
149
|
export function collectSubagentCost(ctx, state) {
|
|
133
150
|
const parent = emptyUsage();
|
|
@@ -163,6 +180,8 @@ export function collectSubagentCost(ctx, state) {
|
|
|
163
180
|
const parentUsage = assistantUsageFromMessage(message) ?? compactionUsageFromEntry(entry);
|
|
164
181
|
if (parentUsage)
|
|
165
182
|
addUsage(parent, parentUsage);
|
|
183
|
+
for (const run of notifiedAsyncRuns(entry))
|
|
184
|
+
(run.workflow ? workflowRunIds : asyncRunIds).add(run.runId);
|
|
166
185
|
const details = detailsFromSessionEntry(entry);
|
|
167
186
|
if (!details)
|
|
168
187
|
continue;
|
|
@@ -442,7 +442,6 @@ export async function openSubagentsAdmin(pi, ctx, args = "") {
|
|
|
442
442
|
sendAdminMessage(pi, message);
|
|
443
443
|
}
|
|
444
444
|
else if (action === "Show details") {
|
|
445
|
-
// Full metadata is now opt-in (previously always posted to the thread).
|
|
446
445
|
sendAdminMessage(pi, metadataFor(agent));
|
|
447
446
|
}
|
|
448
447
|
}
|
|
@@ -34,11 +34,6 @@ export interface FleetStatusOptions {
|
|
|
34
34
|
export declare function resolveFleetViewPlacement(value: unknown): FleetViewPlacement;
|
|
35
35
|
export declare function formatFleetElapsed(ms: number): string;
|
|
36
36
|
export declare function formatFleetTokens(count: number, window?: number, windowCount?: number): string;
|
|
37
|
-
/**
|
|
38
|
-
* Reports a Fleet problem once per process. Fleet refreshes on a timer, and console output while the TUI owns
|
|
39
|
-
* the terminal is drawn over the editor, so an interactive session gets one TUI warning instead.
|
|
40
|
-
*/
|
|
41
|
-
export declare function reportFleetWarning(state: SubagentState, message: string): void;
|
|
42
37
|
export declare function collectFleetStatusEntries(state: SubagentState): FleetStatusEntry[];
|
|
43
38
|
export declare class SubagentFleetStatus {
|
|
44
39
|
private ctx;
|
package/src/tui/fleet-status.js
CHANGED
|
@@ -5,7 +5,8 @@ import { projectAsyncWorkflowRows } from "../runs/shared/async-status-projection
|
|
|
5
5
|
import { contextModeLabel } from "../runs/shared/context-mode.js";
|
|
6
6
|
import { formatWorkflowJsonPreview } from "../workflows/scripted-workflow.js";
|
|
7
7
|
import { hostStepReportName, hostStepVerdictLabel } from "../runs/shared/host-step-status.js";
|
|
8
|
-
import { isStaleExtensionContextError
|
|
8
|
+
import { isStaleExtensionContextError } from "../shared/extension-context.js";
|
|
9
|
+
import { reportSessionWarning } from "../shared/session-warnings.js";
|
|
9
10
|
import { inlineWorkflowRenderKey } from "./render.js";
|
|
10
11
|
import { runningTone } from "./running-tone.js";
|
|
11
12
|
import { childThinkingLevel } from "../shared/model-info.js";
|
|
@@ -318,27 +319,6 @@ function projectPaneEntries(state) {
|
|
|
318
319
|
projectPane: pane,
|
|
319
320
|
}));
|
|
320
321
|
}
|
|
321
|
-
const reportedFleetWarnings = new Set();
|
|
322
|
-
/**
|
|
323
|
-
* Reports a Fleet problem once per process. Fleet refreshes on a timer, and console output while the TUI owns
|
|
324
|
-
* the terminal is drawn over the editor, so an interactive session gets one TUI warning instead.
|
|
325
|
-
*/
|
|
326
|
-
export function reportFleetWarning(state, message) {
|
|
327
|
-
if (reportedFleetWarnings.has(message))
|
|
328
|
-
return;
|
|
329
|
-
reportedFleetWarnings.add(message);
|
|
330
|
-
const text = `[pi-subagents] ${message}`;
|
|
331
|
-
const cached = state.lastUiContext;
|
|
332
|
-
const notified = withCachedUiContext(cached, () => {
|
|
333
|
-
if (state.lastUiContext === cached)
|
|
334
|
-
state.lastUiContext = null;
|
|
335
|
-
}, (ctx) => {
|
|
336
|
-
ctx.ui.notify(text, "warning");
|
|
337
|
-
return true;
|
|
338
|
-
});
|
|
339
|
-
if (!notified)
|
|
340
|
-
console.warn(text);
|
|
341
|
-
}
|
|
342
322
|
export function collectFleetStatusEntries(state) {
|
|
343
323
|
const now = Date.now();
|
|
344
324
|
const entries = [];
|
|
@@ -486,7 +466,7 @@ export function collectFleetStatusEntries(state) {
|
|
|
486
466
|
}
|
|
487
467
|
if (state.currentSessionId) {
|
|
488
468
|
try {
|
|
489
|
-
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) =>
|
|
469
|
+
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportSessionWarning(state, `Removed ${message}`) })) {
|
|
490
470
|
if (!isActiveState(run.state))
|
|
491
471
|
continue;
|
|
492
472
|
entries.push({
|
|
@@ -501,7 +481,7 @@ export function collectFleetStatusEntries(state) {
|
|
|
501
481
|
}
|
|
502
482
|
}
|
|
503
483
|
catch (cause) {
|
|
504
|
-
|
|
484
|
+
reportSessionWarning(state, `Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
505
485
|
}
|
|
506
486
|
}
|
|
507
487
|
entries.push(...projectPaneEntries(state));
|
|
@@ -1,50 +1,7 @@
|
|
|
1
1
|
import { type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { type MarkdownTheme } from "@earendil-works/pi-tui";
|
|
3
|
+
import { type FleetTranscript } from "../shared/fleet-transcript-reader.ts";
|
|
3
4
|
type Theme = ExtensionContext["ui"]["theme"];
|
|
4
|
-
export type FleetTranscriptEvent = {
|
|
5
|
-
kind: "assistant";
|
|
6
|
-
text: string;
|
|
7
|
-
model?: string;
|
|
8
|
-
timestamp?: number;
|
|
9
|
-
} | {
|
|
10
|
-
kind: "user";
|
|
11
|
-
text: string;
|
|
12
|
-
timestamp?: number;
|
|
13
|
-
} | {
|
|
14
|
-
kind: "tool";
|
|
15
|
-
toolCallId?: string;
|
|
16
|
-
name: string;
|
|
17
|
-
args?: string;
|
|
18
|
-
argsPayload?: string;
|
|
19
|
-
output?: string;
|
|
20
|
-
outputTruncated?: boolean;
|
|
21
|
-
status: "running" | "complete" | "error";
|
|
22
|
-
error?: string;
|
|
23
|
-
startedAt?: number;
|
|
24
|
-
endedAt?: number;
|
|
25
|
-
timestamp?: number;
|
|
26
|
-
} | {
|
|
27
|
-
kind: "notice";
|
|
28
|
-
text: string;
|
|
29
|
-
tone: "muted" | "warning" | "error";
|
|
30
|
-
timestamp?: number;
|
|
31
|
-
};
|
|
32
|
-
export interface FleetTranscript {
|
|
33
|
-
path: string;
|
|
34
|
-
events: FleetTranscriptEvent[];
|
|
35
|
-
truncated: boolean;
|
|
36
|
-
warning?: string;
|
|
37
|
-
/** The path was refused or the file could not be read, as opposed to a read that only skipped records. */
|
|
38
|
-
readFailed?: true;
|
|
39
|
-
}
|
|
40
|
-
interface FleetTranscriptReadOptions {
|
|
41
|
-
trustedRoots: string[];
|
|
42
|
-
trustedFiles?: string[];
|
|
43
|
-
trustedFileRoot?: string;
|
|
44
|
-
maxRecords?: number;
|
|
45
|
-
maxBytes?: number;
|
|
46
|
-
}
|
|
47
|
-
export declare function readFleetTranscript(filePath: string, options: FleetTranscriptReadOptions): FleetTranscript;
|
|
48
5
|
export declare function renderFleetTranscript(transcript: FleetTranscript, width: number, theme: Theme, markdownTheme: MarkdownTheme, options?: {
|
|
49
6
|
expandedTools?: boolean;
|
|
50
7
|
}): string[];
|
|
@@ -1,334 +1,8 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
1
|
import { getLanguageFromPath, highlightCode } from "@earendil-works/pi-coding-agent";
|
|
4
2
|
import { Markdown, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
5
3
|
import { safeTerminalText as safeDisplayText } from "../shared/display-text.js";
|
|
6
|
-
import {
|
|
7
|
-
const DEFAULT_MAX_RECORDS = 240;
|
|
8
|
-
const DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
|
|
9
|
-
const MAX_MESSAGE_CHARS = 64 * 1024;
|
|
4
|
+
import { objectValue, safeTranscriptEvent } from "../shared/fleet-transcript-reader.js";
|
|
10
5
|
const TOOL_PREVIEW_LINES = 7;
|
|
11
|
-
function sanitizeJsonDisplayValue(value) {
|
|
12
|
-
if (typeof value === "string") {
|
|
13
|
-
const safe = safeDisplayText(value);
|
|
14
|
-
return { value: safe, changed: safe !== value };
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
const sanitized = value.map(sanitizeJsonDisplayValue);
|
|
18
|
-
return {
|
|
19
|
-
value: sanitized.map((entry) => entry.value),
|
|
20
|
-
changed: sanitized.some((entry) => entry.changed),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (value && typeof value === "object") {
|
|
24
|
-
let changed = false;
|
|
25
|
-
const sanitized = Object.create(null);
|
|
26
|
-
for (const [key, nested] of Object.entries(value)) {
|
|
27
|
-
const safeKey = safeDisplayText(key);
|
|
28
|
-
const safeValue = sanitizeJsonDisplayValue(nested);
|
|
29
|
-
sanitized[safeKey] = safeValue.value;
|
|
30
|
-
changed ||= safeKey !== key || safeValue.changed;
|
|
31
|
-
}
|
|
32
|
-
return { value: changed ? sanitized : value, changed };
|
|
33
|
-
}
|
|
34
|
-
return { value, changed: false };
|
|
35
|
-
}
|
|
36
|
-
function safeToolArgsPayload(payload) {
|
|
37
|
-
try {
|
|
38
|
-
const sanitized = sanitizeJsonDisplayValue(JSON.parse(payload));
|
|
39
|
-
return sanitized.changed ? JSON.stringify(sanitized.value) : safeDisplayText(payload);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return safeDisplayText(payload);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function objectValue(value) {
|
|
46
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
47
|
-
? value
|
|
48
|
-
: undefined;
|
|
49
|
-
}
|
|
50
|
-
function stringValue(value) {
|
|
51
|
-
return typeof value === "string" && value.trim() ? value : undefined;
|
|
52
|
-
}
|
|
53
|
-
function numberValue(value) {
|
|
54
|
-
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
55
|
-
}
|
|
56
|
-
function pathWithin(base, candidate) {
|
|
57
|
-
const resolvedBase = path.resolve(base);
|
|
58
|
-
const resolvedCandidate = path.resolve(candidate);
|
|
59
|
-
return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path.sep}`);
|
|
60
|
-
}
|
|
61
|
-
function errorMessage(error) {
|
|
62
|
-
return error instanceof Error ? error.message : String(error);
|
|
63
|
-
}
|
|
64
|
-
function isNotFoundError(error) {
|
|
65
|
-
return Boolean(objectValue(error)?.code === "ENOENT");
|
|
66
|
-
}
|
|
67
|
-
function validateTranscriptPath(filePath, trustedRoots, trustedFiles = [], trustedFileRoot) {
|
|
68
|
-
if (trustedRoots.length === 0 && (!trustedFileRoot || trustedFiles.length === 0))
|
|
69
|
-
return { warning: `Transcript preview has no trusted root: ${filePath}` };
|
|
70
|
-
const resolvedPath = path.resolve(filePath);
|
|
71
|
-
const recordedCandidate = trustedFileRoot
|
|
72
|
-
&& pathWithin(trustedFileRoot, resolvedPath)
|
|
73
|
-
&& trustedFiles.some((file) => path.resolve(file) === resolvedPath);
|
|
74
|
-
if (!trustedRoots.some((root) => pathWithin(root, resolvedPath)) && !recordedCandidate) {
|
|
75
|
-
return { warning: `Transcript is outside trusted roots: ${filePath}` };
|
|
76
|
-
}
|
|
77
|
-
let stat;
|
|
78
|
-
try {
|
|
79
|
-
stat = fs.lstatSync(resolvedPath);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
if (isNotFoundError(error))
|
|
83
|
-
return {};
|
|
84
|
-
return { warning: `Transcript could not be inspected: ${errorMessage(error)}` };
|
|
85
|
-
}
|
|
86
|
-
if (stat.isSymbolicLink())
|
|
87
|
-
return { warning: `Transcript preview refused a symlink: ${filePath}` };
|
|
88
|
-
if (!stat.isFile())
|
|
89
|
-
return { warning: `Transcript path is not a file: ${filePath}` };
|
|
90
|
-
try {
|
|
91
|
-
const realPath = fs.realpathSync(resolvedPath);
|
|
92
|
-
const realRoots = trustedRoots
|
|
93
|
-
.filter((root) => fs.existsSync(root))
|
|
94
|
-
.map((root) => fs.realpathSync(root));
|
|
95
|
-
if (!realRoots.some((root) => pathWithin(root, realPath)) && !isTrustedRecordedSessionFile(realPath, trustedFiles, trustedFileRoot)) {
|
|
96
|
-
return { warning: `Transcript resolves outside trusted roots: ${filePath}` };
|
|
97
|
-
}
|
|
98
|
-
return { resolvedPath: realPath };
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
return { warning: `Transcript path could not be resolved: ${errorMessage(error)}` };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function isCompleteRecord(line) {
|
|
105
|
-
if (!line?.trim())
|
|
106
|
-
return false;
|
|
107
|
-
try {
|
|
108
|
-
return objectValue(JSON.parse(line)) !== undefined;
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function readTailLines(filePath, maxBytes) {
|
|
115
|
-
let fd;
|
|
116
|
-
try {
|
|
117
|
-
const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
|
|
118
|
-
fd = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow);
|
|
119
|
-
const stat = fs.fstatSync(fd);
|
|
120
|
-
if (!stat.isFile())
|
|
121
|
-
return { lines: [], truncated: false, warning: `Transcript path is not a file: ${filePath}` };
|
|
122
|
-
if (stat.size === 0)
|
|
123
|
-
return { lines: [], truncated: false };
|
|
124
|
-
const bytesToRead = Math.min(stat.size, maxBytes);
|
|
125
|
-
const start = stat.size - bytesToRead;
|
|
126
|
-
const buffer = Buffer.alloc(bytesToRead);
|
|
127
|
-
const bytesRead = fs.readSync(fd, buffer, 0, bytesToRead, start);
|
|
128
|
-
const content = buffer.subarray(0, bytesRead).toString("utf-8");
|
|
129
|
-
const endsWithNewline = content.endsWith("\n");
|
|
130
|
-
let lines = content.split(/\r?\n/);
|
|
131
|
-
if (start > 0 && lines.length > 0)
|
|
132
|
-
lines = lines.slice(1);
|
|
133
|
-
if (lines.at(-1) === "")
|
|
134
|
-
lines = lines.slice(0, -1);
|
|
135
|
-
else if (!endsWithNewline && !isCompleteRecord(lines.at(-1)))
|
|
136
|
-
lines = lines.slice(0, -1);
|
|
137
|
-
return { lines, truncated: start > 0 };
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
return { lines: [], truncated: false, warning: `Transcript could not be read: ${errorMessage(error)}` };
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
if (fd !== undefined)
|
|
144
|
-
fs.closeSync(fd);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function clipMessage(text) {
|
|
148
|
-
if (text.length <= MAX_MESSAGE_CHARS)
|
|
149
|
-
return text;
|
|
150
|
-
return `${text.slice(0, MAX_MESSAGE_CHARS)}\n\n… message truncated`;
|
|
151
|
-
}
|
|
152
|
-
function safeTranscriptEvent(event) {
|
|
153
|
-
if (event.kind === "assistant") {
|
|
154
|
-
return {
|
|
155
|
-
...event,
|
|
156
|
-
text: safeDisplayText(event.text),
|
|
157
|
-
...(event.model ? { model: safeDisplayText(event.model) } : {}),
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
if (event.kind === "user" || event.kind === "notice") {
|
|
161
|
-
return { ...event, text: safeDisplayText(event.text) };
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
...event,
|
|
165
|
-
name: safeDisplayText(event.name),
|
|
166
|
-
...(event.args !== undefined ? { args: safeDisplayText(event.args) } : {}),
|
|
167
|
-
...(event.argsPayload !== undefined ? { argsPayload: safeToolArgsPayload(event.argsPayload) } : {}),
|
|
168
|
-
...(event.output !== undefined ? { output: safeDisplayText(event.output) } : {}),
|
|
169
|
-
...(event.error !== undefined ? { error: safeDisplayText(event.error) } : {}),
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function findTool(events, toolCallId, name) {
|
|
173
|
-
if (toolCallId) {
|
|
174
|
-
for (let index = events.length - 1; index >= 0; index--) {
|
|
175
|
-
const event = events[index];
|
|
176
|
-
if (event?.kind === "tool" && event.toolCallId === toolCallId)
|
|
177
|
-
return event;
|
|
178
|
-
}
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
for (let index = events.length - 1; index >= 0; index--) {
|
|
182
|
-
const event = events[index];
|
|
183
|
-
if (event?.kind !== "tool")
|
|
184
|
-
continue;
|
|
185
|
-
const tool = event;
|
|
186
|
-
if ((!name || tool.name === name) && !tool.resultSeen)
|
|
187
|
-
return tool;
|
|
188
|
-
}
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
function appendTextEvent(events, kind, text, metadata) {
|
|
192
|
-
const clipped = clipMessage(text.trim());
|
|
193
|
-
if (!clipped)
|
|
194
|
-
return;
|
|
195
|
-
const previous = events.at(-1);
|
|
196
|
-
if (previous?.kind === kind && previous.text === clipped)
|
|
197
|
-
return;
|
|
198
|
-
events.push({ kind, text: clipped, ...metadata });
|
|
199
|
-
}
|
|
200
|
-
function parseTranscriptLines(lines, conversationStarted = false) {
|
|
201
|
-
const events = [];
|
|
202
|
-
let malformed = 0;
|
|
203
|
-
let explicitTruncation = false;
|
|
204
|
-
let assistantSeen = conversationStarted;
|
|
205
|
-
for (const line of lines) {
|
|
206
|
-
if (!line.trim())
|
|
207
|
-
continue;
|
|
208
|
-
let record;
|
|
209
|
-
try {
|
|
210
|
-
record = objectValue(JSON.parse(line));
|
|
211
|
-
}
|
|
212
|
-
catch {
|
|
213
|
-
malformed++;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
if (!record) {
|
|
217
|
-
malformed++;
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
const recordType = stringValue(record.recordType);
|
|
221
|
-
const timestamp = numberValue(record.ts);
|
|
222
|
-
if (recordType === "truncated") {
|
|
223
|
-
explicitTruncation = true;
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (recordType === "tool_start") {
|
|
227
|
-
const name = stringValue(record.toolName) ?? "tool";
|
|
228
|
-
events.push({
|
|
229
|
-
kind: "tool",
|
|
230
|
-
...(stringValue(record.toolCallId) ? { toolCallId: stringValue(record.toolCallId) } : {}),
|
|
231
|
-
name,
|
|
232
|
-
...(stringValue(record.argsPreview) ? { args: stringValue(record.argsPreview) } : {}),
|
|
233
|
-
...(stringValue(record.argsPayload) ? { argsPayload: stringValue(record.argsPayload) } : {}),
|
|
234
|
-
status: "running",
|
|
235
|
-
...(timestamp !== undefined ? { timestamp, startedAt: timestamp } : {}),
|
|
236
|
-
});
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (recordType === "tool_end") {
|
|
240
|
-
const tool = findTool(events, stringValue(record.toolCallId), stringValue(record.toolName));
|
|
241
|
-
if (tool && !tool.resultSeen)
|
|
242
|
-
tool.status = record.isError === true ? "error" : "complete";
|
|
243
|
-
if (tool && timestamp !== undefined && tool.endedAt === undefined)
|
|
244
|
-
tool.endedAt = timestamp;
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (recordType === "stderr") {
|
|
248
|
-
const text = stringValue(record.text);
|
|
249
|
-
if (text)
|
|
250
|
-
events.push({ kind: "notice", text: clipMessage(text), tone: "error", ...(timestamp !== undefined ? { timestamp } : {}) });
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
if (recordType !== "message")
|
|
254
|
-
continue;
|
|
255
|
-
const message = objectValue(record.message);
|
|
256
|
-
const role = stringValue(record.role) ?? stringValue(message?.role);
|
|
257
|
-
const text = stringValue(record.text) ?? stringValue(message?.text) ?? stringValue(message?.content);
|
|
258
|
-
if (role === "toolResult" || role === "tool_result") {
|
|
259
|
-
const toolCallId = stringValue(record.toolCallId) ?? stringValue(message?.toolCallId);
|
|
260
|
-
const name = stringValue(record.toolName) ?? stringValue(message?.toolName) ?? "tool";
|
|
261
|
-
const failed = record.isError === true || message?.isError === true;
|
|
262
|
-
let tool = findTool(events, toolCallId, name);
|
|
263
|
-
if (!tool) {
|
|
264
|
-
tool = {
|
|
265
|
-
kind: "tool",
|
|
266
|
-
...(toolCallId ? { toolCallId } : {}),
|
|
267
|
-
name,
|
|
268
|
-
status: failed ? "error" : "complete",
|
|
269
|
-
...(timestamp !== undefined ? { timestamp } : {}),
|
|
270
|
-
};
|
|
271
|
-
events.push(tool);
|
|
272
|
-
}
|
|
273
|
-
if (!tool.resultSeen) {
|
|
274
|
-
tool.resultSeen = true;
|
|
275
|
-
tool.status = failed ? "error" : "complete";
|
|
276
|
-
if (timestamp !== undefined && tool.endedAt === undefined)
|
|
277
|
-
tool.endedAt = timestamp;
|
|
278
|
-
if (text && (!failed || tool.output === undefined)) {
|
|
279
|
-
tool.output = clipMessage(text);
|
|
280
|
-
tool.outputTruncated = record.outputTruncated === true || text.includes("… payload truncated") || text.includes("[Showing lines");
|
|
281
|
-
}
|
|
282
|
-
if (failed && text)
|
|
283
|
-
tool.error = clipMessage(text.split(/\r?\n/).find((candidate) => candidate.trim()) ?? text);
|
|
284
|
-
}
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
if (role === "assistant") {
|
|
288
|
-
assistantSeen = true;
|
|
289
|
-
// The transcript writer records the assistant message's provider-local id, which can itself contain a slash.
|
|
290
|
-
const rawModel = stringValue(record.model) ?? stringValue(message?.model);
|
|
291
|
-
const provider = stringValue(message?.provider);
|
|
292
|
-
const model = rawModel && provider ? `${provider}/${rawModel}` : rawModel;
|
|
293
|
-
if (text)
|
|
294
|
-
appendTextEvent(events, "assistant", text, {
|
|
295
|
-
...(model ? { model } : {}),
|
|
296
|
-
...(timestamp !== undefined ? { timestamp } : {}),
|
|
297
|
-
});
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
if (role === "user" && assistantSeen && text) {
|
|
301
|
-
appendTextEvent(events, "user", text, timestamp !== undefined ? { timestamp } : {});
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
for (const event of events) {
|
|
305
|
-
if (event.kind === "tool")
|
|
306
|
-
delete event.resultSeen;
|
|
307
|
-
}
|
|
308
|
-
return { events: events.map(safeTranscriptEvent), malformed, explicitTruncation };
|
|
309
|
-
}
|
|
310
|
-
export function readFleetTranscript(filePath, options) {
|
|
311
|
-
const validated = validateTranscriptPath(filePath, options.trustedRoots, options.trustedFiles, options.trustedFileRoot);
|
|
312
|
-
if (!validated.resolvedPath) {
|
|
313
|
-
return { path: filePath, events: [], truncated: false, readFailed: true, ...(validated.warning ? { warning: safeDisplayText(validated.warning) } : {}) };
|
|
314
|
-
}
|
|
315
|
-
const maxRecords = Math.max(1, options.maxRecords ?? DEFAULT_MAX_RECORDS);
|
|
316
|
-
const tail = readTailLines(validated.resolvedPath, Math.max(1024, options.maxBytes ?? DEFAULT_MAX_BYTES));
|
|
317
|
-
const recordsOmitted = tail.truncated || tail.lines.length > maxRecords;
|
|
318
|
-
const selectedLines = tail.lines.slice(-maxRecords);
|
|
319
|
-
const parsed = parseTranscriptLines(selectedLines, recordsOmitted);
|
|
320
|
-
const warnings = [
|
|
321
|
-
tail.warning,
|
|
322
|
-
parsed.malformed > 0 ? `Skipped ${parsed.malformed} malformed transcript record${parsed.malformed === 1 ? "" : "s"}.` : undefined,
|
|
323
|
-
].filter((value) => Boolean(value));
|
|
324
|
-
return {
|
|
325
|
-
path: filePath,
|
|
326
|
-
events: parsed.events,
|
|
327
|
-
truncated: tail.truncated || tail.lines.length > maxRecords || parsed.explicitTruncation,
|
|
328
|
-
...(tail.warning ? { readFailed: true } : {}),
|
|
329
|
-
...(warnings.length ? { warning: safeDisplayText(warnings.join(" ")) } : {}),
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
6
|
function statusGlyph(event, theme) {
|
|
333
7
|
if (event.status === "running")
|
|
334
8
|
return theme.fg("warning", "●");
|
package/src/tui/fleet.js
CHANGED
|
@@ -17,9 +17,11 @@ import { stopAsyncRun } from "../runs/foreground/async-stop-action.js";
|
|
|
17
17
|
import { resolveWorkflowForegroundSteeringTarget, steerWorkflowForegroundTarget } from "../runs/foreground/workflow-foreground-steering.js";
|
|
18
18
|
import { contextModeBadge, contextModeLabel } from "../runs/shared/context-mode.js";
|
|
19
19
|
import { foregroundChildStateLabel } from "../runs/foreground/foreground-history.js";
|
|
20
|
-
import { FLEET_STATUS_WIDGET_KEY
|
|
20
|
+
import { FLEET_STATUS_WIDGET_KEY } from "./fleet-status.js";
|
|
21
|
+
import { reportSessionWarning } from "../shared/session-warnings.js";
|
|
21
22
|
import { stepTaskSummary } from "./render.js";
|
|
22
|
-
import {
|
|
23
|
+
import { renderFleetTranscript } from "./fleet-transcript.js";
|
|
24
|
+
import { readFleetTranscript } from "../shared/fleet-transcript-reader.js";
|
|
23
25
|
import { runningTone } from "./running-tone.js";
|
|
24
26
|
import { childThinkingLevel } from "../shared/model-info.js";
|
|
25
27
|
import { handleInspectorAction } from "../inspectors/actions.js";
|
|
@@ -222,7 +224,7 @@ export function collectFleetSnapshot(state, options = {}) {
|
|
|
222
224
|
entryLimit: MAX_FLEET_HISTORY_CANDIDATES,
|
|
223
225
|
resultsDir: options.resultsDir ?? DIRS.results,
|
|
224
226
|
reconcile: false,
|
|
225
|
-
onCorruptStatus: (warning) =>
|
|
227
|
+
onCorruptStatus: (warning) => reportSessionWarning(state, warning),
|
|
226
228
|
}).filter((run) => !trackedIds.has(run.id));
|
|
227
229
|
runs = [...trackedRuns, ...history];
|
|
228
230
|
}
|
|
@@ -238,7 +240,7 @@ export function collectFleetSnapshot(state, options = {}) {
|
|
|
238
240
|
}
|
|
239
241
|
if (state.currentSessionId) {
|
|
240
242
|
try {
|
|
241
|
-
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) =>
|
|
243
|
+
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportSessionWarning(state, `Removed ${message}`) })) {
|
|
242
244
|
items.push({
|
|
243
245
|
key: `external:${run.id}`,
|
|
244
246
|
kind: "external",
|
package/src/tui/render.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rendering functions for subagent results
|
|
3
|
-
*/
|
|
4
1
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
5
2
|
import { type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
3
|
import { type Component } from "@earendil-works/pi-tui";
|
|
@@ -50,16 +47,10 @@ export declare function inlineWorkflowRenderKey(job: AsyncJobState, children: As
|
|
|
50
47
|
/** Presentation-only coverage from the mounted inline Fleet roster, never configuration. */
|
|
51
48
|
export declare function setInlineWorkflowCoverage(ui: ExtensionContext["ui"], coverage: ReadonlyMap<string, string>): void;
|
|
52
49
|
export declare function buildWidgetLines(jobs: AsyncJobState[], theme: Theme, width?: number, expanded?: boolean, frame?: number): string[];
|
|
53
|
-
/**
|
|
54
|
-
* Render the async jobs widget
|
|
55
|
-
*/
|
|
56
50
|
export declare function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[], initiallyCollapsed?: boolean, layout?: AsyncWidgetLayout): void;
|
|
57
51
|
export declare function renderSubagentSummary(result: AgentToolResult<Details>, options: {
|
|
58
52
|
isPartial?: boolean;
|
|
59
53
|
}, theme: Theme): Component;
|
|
60
|
-
/**
|
|
61
|
-
* Render a subagent result
|
|
62
|
-
*/
|
|
63
54
|
export declare function renderSubagentResult(result: AgentToolResult<Details>, options: {
|
|
64
55
|
expanded: boolean;
|
|
65
56
|
}, theme: Theme, frame?: number, rendererConfig?: MainWindowRendererConfig, foregroundDetachShortcut?: string): Component;
|