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-JG4QKI5M.js → chunk-2IYBCYFU.js} +214 -97
- 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-XDQORLZ5.js → chunk-7ADDXUGF.js} +15 -6
- package/bundle/{chunk-PV63UFUR.js → chunk-7QA7ZA46.js} +183 -28
- package/bundle/{chunk-NKQ6JNAS.js → chunk-7ZUFN6ME.js} +2 -1
- package/bundle/{chunk-SSG7IEP5.js → chunk-A637IMAO.js} +2 -2
- package/bundle/{chunk-L3WFKBEI.js → chunk-BGXEAYUM.js} +247 -153
- package/bundle/{chunk-J5YL7LYR.js → chunk-BU6PFPVX.js} +59 -27
- package/bundle/{chunk-DZDETGRJ.js → chunk-BWC2LVII.js} +259 -216
- package/bundle/{chunk-CGN2TVE7.js → chunk-GJGTMLPE.js} +322 -18
- 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-235AWJUQ.js → chunk-O3YH7XIY.js} +324 -111
- package/bundle/{chunk-2DHZTCOL.js → chunk-PYOAIN3V.js} +2 -2
- package/bundle/{chunk-LNRJCP2Y.js → chunk-QGO6HXHG.js} +417 -242
- package/bundle/{chunk-VQVVHSY6.js → chunk-QM3JGE4W.js} +22 -11
- package/bundle/{chunk-2S4K53MV.js → chunk-S2Q75LP3.js} +1 -1
- package/bundle/{chunk-NENDSQUY.js → chunk-UR7OW5S7.js} +9 -6
- package/bundle/{chunk-AKOIVLA5.js → chunk-WN2E5XHN.js} +135 -77
- package/bundle/{chunk-2D52JFLF.js → chunk-YK3QYNLE.js} +41 -117
- package/bundle/{chunk-7BWGNDNK.js → chunk-ZJJCPV3L.js} +190 -1177
- 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 +23 -2
- package/docs/configuration.md +4 -4
- package/docs/extension-api.md +16 -1
- package/docs/tool-reference.md +2 -0
- package/docs/workflows.md +30 -2
- package/package.json +1 -1
- 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 +5 -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 +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 -9
- package/src/runs/background/async-execution.js +62 -27
- 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.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 +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 +3 -2
- package/src/runs/foreground/subagent-executor.js +107 -26
- 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 +85 -59
- 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
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rewriteSubagentPrompt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7ADDXUGF.js";
|
|
4
4
|
import {
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import
|
|
6
|
+
} from "./chunk-7ZUFN6ME.js";
|
|
7
|
+
import {
|
|
8
|
+
WATCHDOG_DIFF_TOOL_NAME,
|
|
9
|
+
captureWatchdogDiffBaseline,
|
|
10
|
+
createWatchdogDiffTool
|
|
11
|
+
} from "./chunk-ZJJCPV3L.js";
|
|
12
|
+
import "./chunk-BGXEAYUM.js";
|
|
13
|
+
import "./chunk-ZPY5QZCS.js";
|
|
8
14
|
import {
|
|
9
15
|
MODEL_ONLY_TOOL
|
|
10
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HXRB42AF.js";
|
|
11
17
|
import "./chunk-NF7IEKBH.js";
|
|
12
18
|
import {
|
|
13
19
|
appendAgentRefinementOverlay
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-LGINOOY5.js";
|
|
21
|
+
import "./chunk-GJGTMLPE.js";
|
|
16
22
|
import "./chunk-NIXWDZZV.js";
|
|
17
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-77ASNIEM.js";
|
|
18
24
|
import "./chunk-7F6RKT6W.js";
|
|
19
25
|
import {
|
|
20
26
|
assertNoToolModifierEntries
|
|
21
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-374MZFF4.js";
|
|
22
28
|
import "./chunk-CTPAE36Y.js";
|
|
23
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-GRJHIXYF.js";
|
|
24
30
|
import {
|
|
25
31
|
HERDR_PI_MAX_FRAME_BYTES,
|
|
26
32
|
HERDR_PI_PROTOCOL,
|
|
@@ -37,7 +43,7 @@ import {
|
|
|
37
43
|
discoverAgents,
|
|
38
44
|
resolveExistingReadPaths,
|
|
39
45
|
resolveSkills
|
|
40
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-QGO6HXHG.js";
|
|
41
47
|
import "./chunk-JEZOSEWG.js";
|
|
42
48
|
import "./chunk-YFCK7H2S.js";
|
|
43
49
|
import "./chunk-QXASAHIA.js";
|
|
@@ -240,9 +246,11 @@ ${resolvedSystemPrompt}` } : void 0;
|
|
|
240
246
|
const resolved = resolveRemoteHerdrResources(process.cwd(), { agent: resources.agent, ...resources.skills ? { skills: resources.skills } : {}, ...resources.toolCeiling ? { toolCeiling: resources.toolCeiling } : {}, ...resources.reads !== void 0 ? { reads: resources.reads } : {} }, context ? pi.getActiveTools() : []);
|
|
241
247
|
resolvedSystemPrompt = resolved.systemPrompt;
|
|
242
248
|
resolvedContextPolicy = resolved;
|
|
249
|
+
if (resolved.tools.includes(WATCHDOG_DIFF_TOOL_NAME) && !pi.getAllTools().some((tool) => tool.name === WATCHDOG_DIFF_TOOL_NAME)) pi.registerTool(createWatchdogDiffTool(captureWatchdogDiffBaseline(process.cwd()), { workingTreeAtLaunch: true }));
|
|
243
250
|
pi.setActiveTools(resolved.tools);
|
|
244
251
|
const acknowledged = context ? pi.getActiveTools() : [];
|
|
245
|
-
|
|
252
|
+
const missing = resolved.tools.filter((tool) => !acknowledged.includes(tool)), extra = acknowledged.filter((tool) => !resolved.tools.includes(tool));
|
|
253
|
+
if (missing.length || extra.length) throw new Error(`Remote Pi did not apply the resolved active-tool set exactly (${[...missing.length ? [`not available: ${missing.join(", ")}`] : [], ...extra.length ? [`unexpected: ${extra.join(", ")}`] : []].join("; ")}).`);
|
|
246
254
|
configured = true;
|
|
247
255
|
send({ type: "configured", requestId: frame.requestId, nativeSessionId, agent: resolved.agent, skills: resolved.skills, model: context?.model?.provider && context.model.id ? `${context.model.provider}/${context.model.id}` : void 0, tools: acknowledged });
|
|
248
256
|
continue;
|
|
@@ -258,9 +266,12 @@ ${resolvedSystemPrompt}` } : void 0;
|
|
|
258
266
|
send({ type: "prepared", requestId: frame.requestId, nativeSessionId });
|
|
259
267
|
}
|
|
260
268
|
} catch (error) {
|
|
269
|
+
context?.ui?.notify(`pi-subagents bridge: ${error.message}`, "error");
|
|
261
270
|
socket.destroy(error);
|
|
262
271
|
}
|
|
263
272
|
});
|
|
273
|
+
socket.on("error", () => {
|
|
274
|
+
});
|
|
264
275
|
socket.on("close", () => {
|
|
265
276
|
if (client === socket) client = void 0;
|
|
266
277
|
});
|
|
@@ -7,13 +7,15 @@ import {
|
|
|
7
7
|
formatNestedRunStatusLines,
|
|
8
8
|
isStoppableAsyncStatusStep,
|
|
9
9
|
listAsyncRuns,
|
|
10
|
-
ownsRun,
|
|
11
10
|
resolveAsyncStatusChild,
|
|
12
11
|
stopStoppableAsyncStatusChildren,
|
|
13
12
|
summarizeContextModes,
|
|
14
13
|
utf8Tail,
|
|
15
14
|
workflowPreflightLaneForRuntimeKey
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BGXEAYUM.js";
|
|
16
|
+
import {
|
|
17
|
+
ownsRun
|
|
18
|
+
} from "./chunk-HXRB42AF.js";
|
|
17
19
|
import {
|
|
18
20
|
assertSafeNestedId,
|
|
19
21
|
checkRecordedPidLiveness,
|
|
@@ -32,11 +34,11 @@ import {
|
|
|
32
34
|
updateActiveRunIndex,
|
|
33
35
|
validateModelResponseAliases,
|
|
34
36
|
writeAsyncResultFile
|
|
35
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-GJGTMLPE.js";
|
|
36
38
|
import {
|
|
37
39
|
deliverStopRequest,
|
|
38
40
|
stopInboxClosedPath
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-5H4BICQZ.js";
|
|
40
42
|
import {
|
|
41
43
|
SUBAGENT_STOPPED_MESSAGE,
|
|
42
44
|
formatDuration,
|
|
@@ -45,9 +47,10 @@ import {
|
|
|
45
47
|
readStatus,
|
|
46
48
|
shortenPath,
|
|
47
49
|
validateAcceptanceInput,
|
|
50
|
+
waitToolName,
|
|
48
51
|
writeAtomicJson,
|
|
49
52
|
writePrivateAtomicJson
|
|
50
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-QGO6HXHG.js";
|
|
51
54
|
import {
|
|
52
55
|
DIRS
|
|
53
56
|
} from "./chunk-JEZOSEWG.js";
|
|
@@ -403,7 +406,7 @@ function formatDetachedForegroundFleetLines(runs) {
|
|
|
403
406
|
const childSummary = detachedChildren.map((child) => `${fleetChildDisplayName(child)} #${child.index}`).join(", ");
|
|
404
407
|
lines.push(`- ${run.runId} | detached | ${run.mode}${childSummary ? ` | ${childSummary}` : ""}`);
|
|
405
408
|
lines.push(` status: subagent({ action: "status", id: "${run.runId}" })`);
|
|
406
|
-
lines.push(` recovery: reply to the supervisor request first, then wait with
|
|
409
|
+
lines.push(` recovery: reply to the supervisor request first, then wait with ${waitToolName()}({ id: "${run.runId}" }); do not resume or launch a replacement while any child remains detached.`);
|
|
407
410
|
}
|
|
408
411
|
return lines;
|
|
409
412
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildWorkflowChatProgressRows
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UR7OW5S7.js";
|
|
4
4
|
import {
|
|
5
5
|
aggregateStepStatus,
|
|
6
6
|
contextModeBadge,
|
|
@@ -17,21 +17,23 @@ import {
|
|
|
17
17
|
formatWorkflowPreflightPlanSummary,
|
|
18
18
|
formatWorkflowPreflightWarningSummary,
|
|
19
19
|
formatWorkflowPreflightWarnings,
|
|
20
|
-
isStaleExtensionContextError,
|
|
21
|
-
isUnboundExtensionRuntimeError,
|
|
22
|
-
ownerSessionIds,
|
|
23
20
|
projectAsyncStatusSnapshot,
|
|
24
21
|
projectAsyncWorkflowRows,
|
|
25
22
|
projectWorkflowChecklist,
|
|
26
|
-
withCachedUiContext,
|
|
27
23
|
workflowGraphStageNodes
|
|
28
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-BGXEAYUM.js";
|
|
25
|
+
import {
|
|
26
|
+
isStaleExtensionContextError,
|
|
27
|
+
isUnboundExtensionRuntimeError,
|
|
28
|
+
ownerSessionIds,
|
|
29
|
+
reportSessionWarning
|
|
30
|
+
} from "./chunk-HXRB42AF.js";
|
|
29
31
|
import {
|
|
30
32
|
flatToLogicalStepIndex,
|
|
31
33
|
formatWorkflowJsonPreview,
|
|
32
34
|
hostStepReportName,
|
|
33
35
|
hostStepVerdictLabel
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-GJGTMLPE.js";
|
|
35
37
|
import {
|
|
36
38
|
snapshotExternalRuns
|
|
37
39
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -49,7 +51,7 @@ import {
|
|
|
49
51
|
getSingleResultOutput,
|
|
50
52
|
shortenPath,
|
|
51
53
|
unresolvedChildWatchdogBlockers
|
|
52
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-QGO6HXHG.js";
|
|
53
55
|
import {
|
|
54
56
|
MAX_WIDGET_JOBS,
|
|
55
57
|
WIDGET_ANIMATION_INTERVAL_MS,
|
|
@@ -335,6 +337,27 @@ function compactTaskText(task, label) {
|
|
|
335
337
|
if (!normalized) return void 0;
|
|
336
338
|
return previewDisplayText(normalized, COMPACT_TASK_MAX_CHARS);
|
|
337
339
|
}
|
|
340
|
+
var EXPANDED_TASK_MAX_LINES = 8;
|
|
341
|
+
function expandedTaskLines(task, label, width) {
|
|
342
|
+
const taskText = task?.trim();
|
|
343
|
+
if (!taskText || taskText === PROMPT_REDACTED || width <= 0) return void 0;
|
|
344
|
+
const shown = truncateDisplayText(taskText, EXPANDED_TASK_MAX_LINES * width);
|
|
345
|
+
const labelText = label?.trim() && label.trim() !== PROMPT_REDACTED ? sanitizeDisplayText(label) : "";
|
|
346
|
+
const head = labelText && labelText !== sanitizeDisplayText(shown) ? `${labelText} \u2014 ` : "";
|
|
347
|
+
const lines = [];
|
|
348
|
+
for (const rawLine of `task: ${head}${shown}`.split("\n")) {
|
|
349
|
+
const content = sanitizeDisplayText(rawLine);
|
|
350
|
+
if (!content) {
|
|
351
|
+
if (lines.length > 0 && lines[lines.length - 1] !== "") lines.push("");
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const indent = rawLine.match(/^[ \t]*/)[0].replace(/\t/g, " ").slice(0, Math.floor(width / 2));
|
|
355
|
+
for (const part of wrapPlainText(content, width - indent.length)) lines.push(`${indent}${part}`);
|
|
356
|
+
if (lines.length > EXPANDED_TASK_MAX_LINES) break;
|
|
357
|
+
}
|
|
358
|
+
if (lines.length <= EXPANDED_TASK_MAX_LINES && shown.length === taskText.length) return lines;
|
|
359
|
+
return [...lines.slice(0, EXPANDED_TASK_MAX_LINES), "\u2026"];
|
|
360
|
+
}
|
|
338
361
|
var LANE_VALUE_MAX_CHARS = 48;
|
|
339
362
|
function boundedLaneValue(value, maxChars = LANE_VALUE_MAX_CHARS) {
|
|
340
363
|
if (!value?.trim() || value.trim() === PROMPT_REDACTED) return void 0;
|
|
@@ -722,6 +745,22 @@ function visibleWorkflowRows(rows) {
|
|
|
722
745
|
hiddenRows: rows.length - selected.size
|
|
723
746
|
};
|
|
724
747
|
}
|
|
748
|
+
function foldEarlierDoneLines(rows, cap, line, foldLine) {
|
|
749
|
+
if (rows.length <= cap) return rows.map(line);
|
|
750
|
+
const unfinished = rows.filter((row) => row.state !== "complete");
|
|
751
|
+
if (unfinished.length >= cap) return unfinished.map(line);
|
|
752
|
+
const hidden = rows.length - cap + 1;
|
|
753
|
+
const lines = [];
|
|
754
|
+
let skipped = 0;
|
|
755
|
+
for (const row of rows) {
|
|
756
|
+
if (skipped < hidden && row.state === "complete") {
|
|
757
|
+
if (++skipped === hidden) lines.push(foldLine(hidden));
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
lines.push(line(row));
|
|
761
|
+
}
|
|
762
|
+
return lines;
|
|
763
|
+
}
|
|
725
764
|
function snapshotNowForProgress(progress) {
|
|
726
765
|
if (progress.currentToolStartedAt !== void 0 && progress.durationMs !== void 0) return progress.currentToolStartedAt + progress.durationMs;
|
|
727
766
|
return progress.lastActivityAt;
|
|
@@ -1155,6 +1194,7 @@ function workflowChecklistItemLine(item, theme, indent, frame, includeError) {
|
|
|
1155
1194
|
return `${indent}${workflowChecklistGlyph(item, theme, frame)} ${theme.bold(identity || item.key)}${context}${state}${details ? ` ${theme.fg("dim", `\xB7 ${details}`)}` : ""}`;
|
|
1156
1195
|
}
|
|
1157
1196
|
var COLLAPSED_WORKFLOW_PHASE_LIMIT = 4;
|
|
1197
|
+
var EXPANDED_WIDGET_DONE_ITEMS = 4;
|
|
1158
1198
|
function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame, options = {}) {
|
|
1159
1199
|
if (!checklist?.total) return [];
|
|
1160
1200
|
const includeSummary = options.includeSummary ?? true;
|
|
@@ -1162,6 +1202,11 @@ function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame,
|
|
|
1162
1202
|
const includeBottleneckOutput = options.includeBottleneckOutput ?? expanded;
|
|
1163
1203
|
const includeItemErrors = options.includeItemErrors ?? true;
|
|
1164
1204
|
const lines = includeSummary ? [`${indent}${theme.fg("dim", `Checklist ${formatWorkflowChecklistSummary(checklist)}`)}`] : [];
|
|
1205
|
+
const bottleneck = formatWorkflowChecklistBottleneck(checklist.bottleneck, { includeOutput: includeBottleneckOutput, includeError: !expanded });
|
|
1206
|
+
const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
|
|
1207
|
+
const bottleneckLine = bottleneck ? `${indent}${theme.fg(tone, `bottleneck \xB7 ${bottleneck}`)}` : void 0;
|
|
1208
|
+
const liveExpanded = expanded && options.liveWidget === true;
|
|
1209
|
+
if (liveExpanded && bottleneckLine) lines.push(bottleneckLine);
|
|
1165
1210
|
const phases = !limitPhases || checklist.phases.length <= COLLAPSED_WORKFLOW_PHASE_LIMIT ? checklist.phases : checklist.phases.map((phase, index) => ({ phase, index })).sort((left, right) => Number(left.phase.state !== "running") - Number(right.phase.state !== "running") || Number(left.phase.state === "complete") - Number(right.phase.state === "complete") || left.index - right.index).slice(0, COLLAPSED_WORKFLOW_PHASE_LIMIT).sort((left, right) => left.index - right.index).map(({ phase }) => phase);
|
|
1166
1211
|
for (const phase of phases) {
|
|
1167
1212
|
const phaseItem = phase.items.find((item) => item.state === "running") ?? phase.items[0];
|
|
@@ -1174,16 +1219,13 @@ function workflowChecklistWidgetLines(checklist, theme, indent, expanded, frame,
|
|
|
1174
1219
|
}, theme, frame);
|
|
1175
1220
|
lines.push(`${indent}${glyph} ${theme.bold(formatWorkflowChecklistPhase(phase))}`);
|
|
1176
1221
|
if (expanded) {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1222
|
+
const items = [...phase.items].sort((left, right) => workflowChecklistItemPriority(left.state) - workflowChecklistItemPriority(right.state));
|
|
1223
|
+
const line = (item) => workflowChecklistItemLine(item, theme, `${indent} `, frame, includeItemErrors || item.kind === "host");
|
|
1224
|
+
const cap = liveExpanded ? items.filter((item) => item.state !== "complete").length + EXPANDED_WIDGET_DONE_ITEMS + 1 : items.length;
|
|
1225
|
+
lines.push(...foldEarlierDoneLines(items, cap, line, (hidden) => `${indent} ${theme.fg("dim", `\u2026 ${hidden} earlier done`)}`));
|
|
1180
1226
|
}
|
|
1181
1227
|
}
|
|
1182
|
-
|
|
1183
|
-
if (bottleneck) {
|
|
1184
|
-
const tone = checklist.bottleneck?.state === "blocked" || checklist.bottleneck?.state === "failed" ? "error" : checklist.bottleneck?.state === "running" ? "accent" : "warning";
|
|
1185
|
-
lines.push(`${indent}${theme.fg(tone, `bottleneck \xB7 ${bottleneck}`)}`);
|
|
1186
|
-
}
|
|
1228
|
+
if (!liveExpanded && bottleneckLine) lines.push(bottleneckLine);
|
|
1187
1229
|
return lines;
|
|
1188
1230
|
}
|
|
1189
1231
|
function compactWorkflowLaneState(items) {
|
|
@@ -1349,20 +1391,21 @@ function compactWorkflowHeaderLine(job, theme, width) {
|
|
|
1349
1391
|
if (width === void 0 || visibleWidth2(full) <= width) return full;
|
|
1350
1392
|
return `${theme.fg("toolTitle", themeBold(theme, `async workflow ${label}`))} ${theme.fg("dim", "\xB7 background")}`;
|
|
1351
1393
|
}
|
|
1352
|
-
function compactWorkflowWidgetBodyLines(job, theme, frame, projection) {
|
|
1394
|
+
function compactWorkflowWidgetBodyLines(job, theme, frame, projection, lineBudget) {
|
|
1353
1395
|
const rows = compactWorkflowLaneRows(job, projection.checklist);
|
|
1354
1396
|
const lines = [` ${compactWorkflowStats(job, rows, theme, projection)}`];
|
|
1355
1397
|
if (projection.inlineFleetCovered) return [...lines, ` ${theme.fg("dim", "Workflow children shown in Fleet roster")}`];
|
|
1398
|
+
const bottleneck = compactWorkflowBottleneck(rows, job);
|
|
1399
|
+
const hint = job.status === "running" || rows.some((row) => row.state === "running");
|
|
1356
1400
|
if (rows.length) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
}
|
|
1401
|
+
const shown = rows.filter((row) => !projection.materializedKeys?.has(row.key));
|
|
1402
|
+
const cap = lineBudget === void 0 ? shown.length : Math.max(1, lineBudget - lines.length - Number(Boolean(bottleneck)) - Number(hint));
|
|
1403
|
+
lines.push(...foldEarlierDoneLines(shown, cap, (row) => compactWorkflowLaneLine(row, theme, " ", frame), (hidden) => ` ${theme.fg("dim", `\u2026 ${hidden} earlier done`)}`));
|
|
1360
1404
|
} else {
|
|
1361
1405
|
lines.push(` ${theme.fg("dim", "\u25E6 waiting for workflow lanes")}`);
|
|
1362
1406
|
}
|
|
1363
|
-
const bottleneck = compactWorkflowBottleneck(rows, job);
|
|
1364
1407
|
if (bottleneck) lines.push(` ${theme.fg(bottleneck.tone, `bottleneck \xB7 ${bottleneck.text}`)}`);
|
|
1365
|
-
if (
|
|
1408
|
+
if (hint) lines.push(` ${theme.fg("accent", workflowDetailHintText())}`);
|
|
1366
1409
|
return lines;
|
|
1367
1410
|
}
|
|
1368
1411
|
function widgetStepActivity(step, snapshotNow) {
|
|
@@ -1378,14 +1421,14 @@ function widgetStepActivity(step, snapshotNow) {
|
|
|
1378
1421
|
if (activity) return activity;
|
|
1379
1422
|
return facts.join(" \xB7 ");
|
|
1380
1423
|
}
|
|
1381
|
-
function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1424
|
+
function widgetChainDetails(job, theme, expanded = false, width = getTermWidth(), frame, fullTask = false) {
|
|
1382
1425
|
if (!job.steps?.length) return [];
|
|
1383
1426
|
const total = job.chainStepCount ?? job.steps.length;
|
|
1384
1427
|
const lines = [];
|
|
1385
1428
|
for (const span of buildAsyncChainStepSpans(total, job.steps.length, job.parallelGroups)) {
|
|
1386
1429
|
const steps = job.steps.slice(span.start, span.start + span.count);
|
|
1387
1430
|
if (span.isParallel) {
|
|
1388
|
-
lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false));
|
|
1431
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, { steps, total: span.count, stepIndex: span.stepIndex, chainTotal: total }, expanded, width, frame, false, fullTask));
|
|
1389
1432
|
continue;
|
|
1390
1433
|
}
|
|
1391
1434
|
const step = steps[0];
|
|
@@ -1393,16 +1436,18 @@ function widgetChainDetails(job, theme, expanded = false, width = getTermWidth()
|
|
|
1393
1436
|
lines.push(` ${theme.fg("dim", `\u25E6 Step ${span.stepIndex + 1}/${total}: pending`)}`);
|
|
1394
1437
|
continue;
|
|
1395
1438
|
}
|
|
1396
|
-
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame));
|
|
1439
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width, frame, { fullTask }));
|
|
1397
1440
|
}
|
|
1398
1441
|
return lines;
|
|
1399
1442
|
}
|
|
1400
|
-
function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame) {
|
|
1443
|
+
function widgetParallelAgentDetails(job, theme, expanded = false, width = getTermWidth(), frame, fullTask = false) {
|
|
1401
1444
|
if (!job.steps?.length) return [];
|
|
1445
|
+
const taskLines = (step, indent) => expanded && fullTask && step.status === "running" ? (expandedTaskLines(step.description, step.label, width - indent.length - 4) ?? []).map((line) => `${indent}${theme.fg("dim", line)}`) : [];
|
|
1446
|
+
if (job.mode === "single") return job.steps.flatMap((step) => taskLines(step, " "));
|
|
1402
1447
|
if (job.mode !== "parallel" && job.mode !== "chain") return [];
|
|
1403
|
-
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
|
|
1448
|
+
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame, fullTask);
|
|
1404
1449
|
const group = activeParallelWidgetGroup(job);
|
|
1405
|
-
if (group) return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup));
|
|
1450
|
+
if (group) return parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup), fullTask);
|
|
1406
1451
|
const total = job.stepsTotal ?? job.steps.length;
|
|
1407
1452
|
const lines = [];
|
|
1408
1453
|
for (const [index, step] of job.steps.entries()) {
|
|
@@ -1414,6 +1459,7 @@ function widgetParallelAgentDetails(job, theme, expanded = false, width = getTer
|
|
|
1414
1459
|
const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
|
|
1415
1460
|
const thinking = childThinkingLevel(step);
|
|
1416
1461
|
lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame, thinking)} ${itemTitle} ${index + 1}/${total}: ${display} \xB7 ${widgetStepStatus(step.status, theme, thinking)}${modelDisplay}${activity ? ` \xB7 ${activity}` : ""}`)}`);
|
|
1462
|
+
lines.push(...taskLines(step, " "));
|
|
1417
1463
|
const lane = projectAsyncLane(job, step);
|
|
1418
1464
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
1419
1465
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 6)) lines.push(` ${nestedLine}`);
|
|
@@ -1538,7 +1584,7 @@ function parallelWidgetGroupHeader(group, theme, frame) {
|
|
|
1538
1584
|
const label = group.stepIndex !== void 0 && group.chainTotal !== void 0 ? `Step ${group.stepIndex + 1}/${group.chainTotal}: parallel group` : "parallel group";
|
|
1539
1585
|
return ` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(group.steps), frame)} ${themeBold(theme, label)} ${theme.fg("dim", "\xB7")} ${theme.fg("dim", formatParallelOutcome(group.steps, group.total))}`;
|
|
1540
1586
|
}
|
|
1541
|
-
function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive) {
|
|
1587
|
+
function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, prioritizeActive, fullTask = false) {
|
|
1542
1588
|
const lines = [parallelWidgetGroupHeader(group, theme, frame)];
|
|
1543
1589
|
const rows = parallelWidgetStepRows(group.steps, group.total, prioritizeActive);
|
|
1544
1590
|
for (const [rowIndex, row] of rows.entries()) {
|
|
@@ -1548,7 +1594,8 @@ function parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, p
|
|
|
1548
1594
|
rowIndent: " ",
|
|
1549
1595
|
detailIndent: " ",
|
|
1550
1596
|
rowMarker: marker,
|
|
1551
|
-
includeCurrentPath: true
|
|
1597
|
+
includeCurrentPath: true,
|
|
1598
|
+
fullTask
|
|
1552
1599
|
}));
|
|
1553
1600
|
}
|
|
1554
1601
|
for (let index = rows.length; index < group.total; index++) {
|
|
@@ -1951,7 +1998,9 @@ function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, tota
|
|
|
1951
1998
|
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame, thinking)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "\xB7")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`];
|
|
1952
1999
|
const lane = projectAsyncLane(job, step);
|
|
1953
2000
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
|
|
1954
|
-
const
|
|
2001
|
+
const fullTask = expanded && options?.fullTask && step.status === "running" ? expandedTaskLines(step.description, step.label, width - detailIndent.length - 4) : void 0;
|
|
2002
|
+
const task = fullTask ? void 0 : collapseDetails ? stepTaskSummary(step, displayName) : compactTaskText(step.description, step.label);
|
|
2003
|
+
for (const line of fullTask ?? []) lines.push(`${detailIndent}${theme.fg("dim", line)}`);
|
|
1955
2004
|
if (task) lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
|
|
1956
2005
|
const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
|
|
1957
2006
|
const currentPath = options?.includeCurrentPath && step.currentPath ? shortenPath(step.currentPath) : void 0;
|
|
@@ -2001,7 +2050,7 @@ function hostStepWidgetLines(job, theme, indent) {
|
|
|
2001
2050
|
if (rows.length > visible.length) lines.push(`${indent}${theme.fg("dim", `\u2026 +${rows.length - visible.length} host steps hidden`)}`);
|
|
2002
2051
|
return lines;
|
|
2003
2052
|
}
|
|
2004
|
-
function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2053
|
+
function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection = buildWorkflowWidgetProjection(job), fullTask = false) {
|
|
2005
2054
|
const steps = projection.steps.filter((step) => !projection.materializedKeys?.has(step.workflowKey ?? "") && !projection.materializedKeys?.has(step.runId ?? ""));
|
|
2006
2055
|
const checklist = widgetChecklistWithoutMaterializedChildren(projection);
|
|
2007
2056
|
if (!expanded && job.mode === "workflow") {
|
|
@@ -2011,21 +2060,21 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2011
2060
|
const lane = projectAsyncLane(job, laneStepForJob(job, steps));
|
|
2012
2061
|
return [
|
|
2013
2062
|
...expanded ? workflowPreflightLines(job) : [],
|
|
2014
|
-
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame),
|
|
2063
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { liveWidget: true }),
|
|
2015
2064
|
...lane ? formatLaneProjectionLines(lane, theme, " ") : [],
|
|
2016
2065
|
...hostStepWidgetLines(job, theme, " "),
|
|
2017
2066
|
` ${theme.fg("dim", `\u23BF ${widgetActivity(job)}`)}`,
|
|
2018
2067
|
...formatNestedWidgetLines(job.nestedChildren, theme, width, expanded, job.updatedAt, expanded ? 12 : 6).map((line) => ` ${line}`)
|
|
2019
2068
|
];
|
|
2020
2069
|
}
|
|
2021
|
-
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame);
|
|
2070
|
+
if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length) return widgetChainDetails(job, theme, expanded, width, frame, fullTask);
|
|
2022
2071
|
const lines = [
|
|
2023
2072
|
...expanded ? workflowPreflightLines(job) : [],
|
|
2024
|
-
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded })
|
|
2073
|
+
...workflowChecklistWidgetLines(checklist, theme, " ", expanded, frame, { includeItemErrors: !expanded, liveWidget: true })
|
|
2025
2074
|
];
|
|
2026
2075
|
const group = activeParallelWidgetGroup(job);
|
|
2027
2076
|
if (group) {
|
|
2028
|
-
lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup)));
|
|
2077
|
+
lines.push(...parallelWidgetGroupDetails(job, theme, group, expanded, width, frame, Boolean(job.activeParallelGroup), fullTask));
|
|
2029
2078
|
} else {
|
|
2030
2079
|
const { stageProgress, plannedKeys } = projection;
|
|
2031
2080
|
const total = job.mode === "chain" ? job.chainStepCount ?? job.stepsTotal ?? steps.length : stageProgress?.total ?? job.stepsTotal ?? steps.length;
|
|
@@ -2037,7 +2086,7 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2037
2086
|
const itemTitle = isPlannedStage ? "Stage" : "Step";
|
|
2038
2087
|
const displayIndex = isPlannedStage ? (step.index ?? index) + 1 : plannedKeys ? ++extraStepIndex : index + 1;
|
|
2039
2088
|
const displayTotal = isPlannedStage ? stageTotal : extraStepCount;
|
|
2040
|
-
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame));
|
|
2089
|
+
lines.push(...foregroundStyleWidgetStepLines(job, theme, step, itemTitle, displayIndex, displayTotal, expanded, width, frame, { fullTask }));
|
|
2041
2090
|
}
|
|
2042
2091
|
}
|
|
2043
2092
|
lines.push(...hostStepWidgetLines(job, theme, " "));
|
|
@@ -2048,8 +2097,8 @@ function foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projec
|
|
|
2048
2097
|
}
|
|
2049
2098
|
return lines;
|
|
2050
2099
|
}
|
|
2051
|
-
function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
2052
|
-
if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow") return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection)].map((line) => truncLine(line, width));
|
|
2100
|
+
function buildSingleWidgetLines(job, theme, width, expanded, frame, projection = buildWorkflowWidgetProjection(job), reservedLines = 0, fullTask = false) {
|
|
2101
|
+
if ((!expanded || projection.inlineFleetCovered) && job.mode === "workflow") return [compactWorkflowHeaderLine(job, theme, width), ...compactWorkflowWidgetBodyLines(job, theme, frame, projection, widgetLineBudget(expanded) - 1 - reservedLines)].map((line) => truncLine(line, width));
|
|
2053
2102
|
const stats = widgetStats(job, theme, projection, !expanded);
|
|
2054
2103
|
const count = job.mode === "workflow" ? projection.checklist?.total ?? projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length : job.mode === "chain" ? job.chainStepCount : projection.stageProgress?.total ?? job.stepsTotal ?? job.agents?.length ?? job.steps?.length;
|
|
2055
2104
|
const mode = widgetJobName(job);
|
|
@@ -2060,7 +2109,7 @@ function buildSingleWidgetLines(job, theme, width, expanded, frame, projection =
|
|
|
2060
2109
|
return [
|
|
2061
2110
|
`${theme.fg("toolTitle", themeBold(theme, title))} ${theme.fg("dim", "\xB7 background")}`,
|
|
2062
2111
|
...collapseDetails ? [] : [summary],
|
|
2063
|
-
...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection)
|
|
2112
|
+
...foregroundStyleWidgetDetails(job, theme, expanded, width, frame, projection, fullTask)
|
|
2064
2113
|
].map((line) => truncLine(line, width));
|
|
2065
2114
|
}
|
|
2066
2115
|
function compactSingleWidgetLines(job, theme, width, frame, projection = buildWorkflowWidgetProjection(job)) {
|
|
@@ -2283,9 +2332,9 @@ function buildProgressiveWidgetLines(jobs, theme, width, lockedRows, previousKey
|
|
|
2283
2332
|
const laneRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : void 0;
|
|
2284
2333
|
lines.push(progressiveJobLine(job, theme, width, frame, projection, laneRows));
|
|
2285
2334
|
if (!laneRows || projection.inlineFleetCovered) continue;
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2288
|
-
spareRows -=
|
|
2335
|
+
const laneLines = foldEarlierDoneLines(laneRows, spareRows, (row) => truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width), (hidden) => truncLine(` ${theme.fg("dim", `\u2026 ${hidden} earlier done`)}`, width)).slice(0, spareRows);
|
|
2336
|
+
lines.push(...laneLines);
|
|
2337
|
+
spareRows -= laneLines.length;
|
|
2289
2338
|
}
|
|
2290
2339
|
if (hiddenJobs.length > 0 && lines.length < rowCount) lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
|
|
2291
2340
|
const contentRows = Math.min(lines.length, rowCount);
|
|
@@ -2300,9 +2349,12 @@ function paddedWidgetLine(line, width) {
|
|
|
2300
2349
|
const text = ` ${truncLine(line, width - 2)} `;
|
|
2301
2350
|
return `${text}${" ".repeat(Math.max(0, width - visibleWidth2(text)))}`;
|
|
2302
2351
|
}
|
|
2352
|
+
function widgetLineBudget(expanded) {
|
|
2353
|
+
const rows = currentTerminalRows();
|
|
2354
|
+
return expanded ? Math.max(12, Math.min(24, Math.floor(rows * 0.55))) : collapsedWidgetLineBudget(rows);
|
|
2355
|
+
}
|
|
2303
2356
|
function fitWidgetLineBudget(lines, theme, width, expanded) {
|
|
2304
|
-
const
|
|
2305
|
-
const budget = expanded ? Math.max(12, Math.min(24, Math.floor(rows * 0.55))) : collapsedWidgetLineBudget(rows);
|
|
2357
|
+
const budget = widgetLineBudget(expanded);
|
|
2306
2358
|
if (lines.length <= budget) return lines;
|
|
2307
2359
|
const visibleLines = Math.max(1, budget - 1);
|
|
2308
2360
|
const hiddenCount = lines.length - visibleLines;
|
|
@@ -2416,7 +2468,7 @@ function widgetChecklistWithoutMaterializedChildren(projection) {
|
|
|
2416
2468
|
if (!checklist || !materializedKeys) return checklist;
|
|
2417
2469
|
return { ...checklist, phases: checklist.phases.map((phase) => ({ ...phase, items: phase.items.filter((item) => !materializedKeys.has(item.key)) })) };
|
|
2418
2470
|
}
|
|
2419
|
-
function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor) {
|
|
2471
|
+
function materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor, fullTask = false) {
|
|
2420
2472
|
const { children, inlineFleetCovered } = projectionFor(job);
|
|
2421
2473
|
if (inlineFleetCovered || !children?.length) return [];
|
|
2422
2474
|
const lines = [];
|
|
@@ -2427,8 +2479,8 @@ function materializedWidgetChildLines(job, theme, width, expanded, frame, projec
|
|
|
2427
2479
|
const identity = child.workflowKey ?? child.asyncId;
|
|
2428
2480
|
const stats = widgetStats(child, theme, projection, !expanded);
|
|
2429
2481
|
lines.push(` ${last ? "\u2514\u2500" : "\u251C\u2500"} ${theme.bold(identity)} ${widgetStatusGlyph(child, theme, frame)} ${themeBold(theme, widgetJobName(child))}${contextModeBadge(theme, child.context)}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`);
|
|
2430
|
-
for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection)) lines.push(` ${last ? " " : "\u2502 "}${detail}`);
|
|
2431
|
-
for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor)) lines.push(` ${detail}`);
|
|
2482
|
+
for (const detail of foregroundStyleWidgetDetails(child, theme, expanded, Math.max(0, width - 6), frame, projection, fullTask)) lines.push(` ${last ? " " : "\u2502 "}${detail}`);
|
|
2483
|
+
for (const detail of materializedWidgetChildLines(child, theme, Math.max(0, width - 4), expanded, frame, projectionFor, fullTask)) lines.push(` ${detail}`);
|
|
2432
2484
|
}
|
|
2433
2485
|
if (shown.length < children.length) lines.push(` +${children.length - shown.length} more workflow children`);
|
|
2434
2486
|
return lines;
|
|
@@ -2512,12 +2564,25 @@ function buildWidgetComponent(jobs, ui, initiallyCollapsed = false, layout) {
|
|
|
2512
2564
|
return component;
|
|
2513
2565
|
};
|
|
2514
2566
|
}
|
|
2567
|
+
function runningWidgetChildCount(jobs, projectionFor) {
|
|
2568
|
+
let running = 0;
|
|
2569
|
+
for (const job of jobs) {
|
|
2570
|
+
const { steps, materializedKeys, children } = projectionFor(job);
|
|
2571
|
+
if (!steps.length && job.status === "running") running++;
|
|
2572
|
+
for (const step of steps) {
|
|
2573
|
+
if (step.status === "running" && !materializedKeys?.has(step.workflowKey ?? "") && !materializedKeys?.has(step.runId ?? "")) running++;
|
|
2574
|
+
}
|
|
2575
|
+
if (children?.length) running += runningWidgetChildCount(children, projectionFor);
|
|
2576
|
+
}
|
|
2577
|
+
return running;
|
|
2578
|
+
}
|
|
2515
2579
|
function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), expanded = false, frame, projectionFor = workflowWidgetProjectionLookup()) {
|
|
2516
2580
|
if (jobs.length === 0) return [];
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2581
|
+
const fullTask = expanded && runningWidgetChildCount(jobs, projectionFor) === 1;
|
|
2582
|
+
if (jobs.length === 1) {
|
|
2583
|
+
const childLines = materializedWidgetChildLines(jobs[0], theme, width, expanded, frame, projectionFor, fullTask).map((line) => truncLine(line, width));
|
|
2584
|
+
return [...buildSingleWidgetLines(jobs[0], theme, width, expanded, frame, projectionFor(jobs[0]), childLines.length, fullTask), ...childLines];
|
|
2585
|
+
}
|
|
2521
2586
|
const running = jobs.filter((job) => job.status === "running");
|
|
2522
2587
|
const queued = jobs.filter((job) => job.status === "queued");
|
|
2523
2588
|
const finished = jobs.filter((job) => job.status !== "running" && job.status !== "queued");
|
|
@@ -2531,23 +2596,24 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
|
|
|
2531
2596
|
let hiddenFinished = 0;
|
|
2532
2597
|
let queuedSummaryShown = false;
|
|
2533
2598
|
let slots = MAX_WIDGET_JOBS;
|
|
2599
|
+
const compactCards = [];
|
|
2534
2600
|
const appendJob = (job) => {
|
|
2535
2601
|
const projection = projectionFor(job);
|
|
2536
2602
|
const compactWorkflow = (!expanded || projection.inlineFleetCovered) && job.mode === "workflow";
|
|
2537
2603
|
const stats = compactWorkflow ? "" : widgetStats(job, theme, projection, !expanded);
|
|
2538
|
-
const details = compactWorkflow ? [
|
|
2539
|
-
...compactWorkflowWidgetBodyLines(job, theme, frame, projection)
|
|
2540
|
-
] : [
|
|
2604
|
+
const details = compactWorkflow ? compactWorkflowWidgetBodyLines(job, theme, frame, projection) : [
|
|
2541
2605
|
` ${theme.fg("dim", `\u23BF ${widgetActivity(job)}`)}`,
|
|
2542
2606
|
...widgetLaneDetailLines(job, theme, projection),
|
|
2543
|
-
...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length }),
|
|
2544
|
-
...widgetParallelAgentDetails(job, theme, expanded, width, frame)
|
|
2607
|
+
...workflowChecklistWidgetLines(widgetChecklistWithoutMaterializedChildren(projection), theme, " ", expanded, frame, { includeItemErrors: !expanded || !job.steps?.length, liveWidget: true }),
|
|
2608
|
+
...widgetParallelAgentDetails(job, theme, expanded, width, frame, fullTask)
|
|
2545
2609
|
];
|
|
2546
|
-
|
|
2610
|
+
const item = [
|
|
2547
2611
|
compactWorkflow ? compactWorkflowHeaderLine(job, theme, width) : `${widgetStatusGlyph(job, theme, frame)} ${themeBold(theme, widgetJobName(job))}${contextModeBadge(theme, job.context)}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`,
|
|
2548
2612
|
...details,
|
|
2549
|
-
...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor)
|
|
2550
|
-
]
|
|
2613
|
+
...materializedWidgetChildLines(job, theme, width, expanded, frame, projectionFor, fullTask)
|
|
2614
|
+
];
|
|
2615
|
+
items.push(item);
|
|
2616
|
+
if (compactWorkflow) compactCards.push({ item, job, projection, bodyLength: details.length });
|
|
2551
2617
|
};
|
|
2552
2618
|
for (const job of running) {
|
|
2553
2619
|
if (slots <= 0) {
|
|
@@ -2579,6 +2645,13 @@ function buildWidgetLinesWithProjection(jobs, theme, width = getTermWidth(), exp
|
|
|
2579
2645
|
if (hiddenFinished > 0) parts.push(`${hiddenFinished} finished`);
|
|
2580
2646
|
items.push([theme.fg("dim", `+${hiddenTotal} more (${parts.join(", ")})`)]);
|
|
2581
2647
|
}
|
|
2648
|
+
let overflow = 1 + items.reduce((sum, item) => sum + item.length, 0) - widgetLineBudget(expanded);
|
|
2649
|
+
for (const card of compactCards) {
|
|
2650
|
+
if (overflow <= 0) break;
|
|
2651
|
+
const body = compactWorkflowWidgetBodyLines(card.job, theme, frame, card.projection, card.bodyLength - overflow);
|
|
2652
|
+
card.item.splice(1, card.bodyLength, ...body);
|
|
2653
|
+
overflow -= card.bodyLength - body.length;
|
|
2654
|
+
}
|
|
2582
2655
|
for (let i = 0; i < items.length; i++) {
|
|
2583
2656
|
const item = items[i];
|
|
2584
2657
|
const last = i === items.length - 1;
|
|
@@ -3462,20 +3535,6 @@ function projectPaneEntries(state) {
|
|
|
3462
3535
|
projectPane: pane
|
|
3463
3536
|
}));
|
|
3464
3537
|
}
|
|
3465
|
-
var reportedFleetWarnings = /* @__PURE__ */ new Set();
|
|
3466
|
-
function reportFleetWarning(state, message) {
|
|
3467
|
-
if (reportedFleetWarnings.has(message)) return;
|
|
3468
|
-
reportedFleetWarnings.add(message);
|
|
3469
|
-
const text = `[pi-subagents] ${message}`;
|
|
3470
|
-
const cached = state.lastUiContext;
|
|
3471
|
-
const notified = withCachedUiContext(cached, () => {
|
|
3472
|
-
if (state.lastUiContext === cached) state.lastUiContext = null;
|
|
3473
|
-
}, (ctx) => {
|
|
3474
|
-
ctx.ui.notify(text, "warning");
|
|
3475
|
-
return true;
|
|
3476
|
-
});
|
|
3477
|
-
if (!notified) console.warn(text);
|
|
3478
|
-
}
|
|
3479
3538
|
function collectFleetStatusEntries(state) {
|
|
3480
3539
|
const now = Date.now();
|
|
3481
3540
|
const entries = [];
|
|
@@ -3604,7 +3663,7 @@ function collectFleetStatusEntries(state) {
|
|
|
3604
3663
|
}
|
|
3605
3664
|
if (state.currentSessionId) {
|
|
3606
3665
|
try {
|
|
3607
|
-
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) =>
|
|
3666
|
+
for (const run of snapshotExternalRuns(state.currentSessionId, { ignoreMalformed: true, onMalformedRecord: (message) => reportSessionWarning(state, `Removed ${message}`) })) {
|
|
3608
3667
|
if (!isActiveState(run.state)) continue;
|
|
3609
3668
|
entries.push({
|
|
3610
3669
|
key: `external:${run.id}`,
|
|
@@ -3617,7 +3676,7 @@ function collectFleetStatusEntries(state) {
|
|
|
3617
3676
|
});
|
|
3618
3677
|
}
|
|
3619
3678
|
} catch (cause) {
|
|
3620
|
-
|
|
3679
|
+
reportSessionWarning(state, `Failed to inspect external jobs: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
3621
3680
|
}
|
|
3622
3681
|
}
|
|
3623
3682
|
entries.push(...projectPaneEntries(state));
|
|
@@ -4159,6 +4218,5 @@ export {
|
|
|
4159
4218
|
renderSubagentResult,
|
|
4160
4219
|
FLEET_STATUS_WIDGET_KEY,
|
|
4161
4220
|
resolveFleetViewPlacement,
|
|
4162
|
-
reportFleetWarning,
|
|
4163
4221
|
SubagentFleetStatus
|
|
4164
4222
|
};
|