brl-subagent 2.6.0 → 2.8.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/AGENT.md +3 -2
- package/README.md +31 -10
- package/package.json +8 -5
- package/src/concurrency.ts +25 -2
- package/src/dispatch-line.ts +144 -0
- package/src/engineering-bar.ts +69 -0
- package/src/event-bus.ts +10 -0
- package/src/git.ts +58 -1
- package/src/headstate.ts +471 -0
- package/src/history.ts +13 -1
- package/src/index.ts +1328 -947
- package/src/kill-escalation.ts +87 -7
- package/src/loader.ts +224 -0
- package/src/mode-prologue.ts +169 -0
- package/src/model-availability.ts +13 -1
- package/src/notify-completion.ts +146 -5
- package/src/params.ts +356 -66
- package/src/prelude.ts +356 -4
- package/src/presets.ts +127 -150
- package/src/project-flags.ts +58 -0
- package/src/recovery-engine.ts +10 -0
- package/src/recovery.ts +155 -19
- package/src/run-registry.ts +24 -1
- package/src/runner.ts +34 -4
- package/src/schema.ts +101 -55
- package/src/session-manager.ts +1549 -264
- package/src/state.ts +118 -16
- package/src/store-permissions.ts +98 -0
- package/src/templates.ts +92 -121
- package/src/transcript.ts +5 -2
- package/src/transport-retry.ts +90 -0
- package/src/tui-format.ts +174 -6
- package/src/tui.ts +284 -377
- package/src/types.ts +219 -25
- package/src/unit-run.ts +10 -1
- package/src/validate.ts +120 -0
package/src/tui.ts
CHANGED
|
@@ -21,13 +21,13 @@ import type {
|
|
|
21
21
|
TaskTemplate,
|
|
22
22
|
SubagentResult,
|
|
23
23
|
SubagentRun,
|
|
24
|
-
|
|
24
|
+
SubTaskResult,
|
|
25
25
|
MultiSubagentDetails,
|
|
26
26
|
ChainDetails,
|
|
27
27
|
ParallelDetails,
|
|
28
28
|
GraphDetails,
|
|
29
29
|
DelegateTaskDetails,
|
|
30
|
-
|
|
30
|
+
DelegateTaskParams,
|
|
31
31
|
ThinkingLevel,
|
|
32
32
|
UsageStats,
|
|
33
33
|
FileDiff,
|
|
@@ -67,7 +67,7 @@ import { collapseRunsForHistory, retryableRuns, sweepStaleLiveSubagents, type Se
|
|
|
67
67
|
import { getAgent } from "./session-manager";
|
|
68
68
|
import { visibleRunEntriesForSession } from "./recovery-surface";
|
|
69
69
|
import { computeSLAMetrics, computeCostTrend, formatSparkline } from "./metrics";
|
|
70
|
-
import { formatElapsed, formatOutcomeSymbol, liveRowName, liveSpinner, formatLiveRowDim, runHistoryStatus, runHistoryStatusLabel, buildRetryOfferMessage, runDisplayName, formatMenuValue, formatTemplateSummary, menuSection } from "./tui-format";
|
|
70
|
+
import { formatElapsed, formatOutcomeSymbol, liveRowName, liveSpinner, formatLiveRowDim, formatBudget, sortLiveSessions, runHistoryStatus, runHistoryStatusLabel, buildRetryOfferMessage, runDisplayName, formatMenuValue, formatTemplateSummary, menuSection } from "./tui-format";
|
|
71
71
|
import {
|
|
72
72
|
renderTranscriptMessages,
|
|
73
73
|
type TranscriptLineStyle,
|
|
@@ -466,11 +466,36 @@ export async function showSLAConfig(
|
|
|
466
466
|
onConfigChanged(ctx, `SLA tracking enabled with window size ${size}`);
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
+
/**
|
|
470
|
+
* D9: the one report "lines modal" — accent border, title, blank row, dim body
|
|
471
|
+
* lines, accent border. Closes on `q` or Escape. Presentation-only; every
|
|
472
|
+
* report screen routes through this so the chrome cannot drift between them.
|
|
473
|
+
*/
|
|
474
|
+
function showLinesModal(ctx: ExtensionContext, title: string, lines: string[]): void {
|
|
475
|
+
ctx.ui.custom((tui, theme, _kb, done) => {
|
|
476
|
+
const container = new Container();
|
|
477
|
+
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
478
|
+
container.addChild(new Text(theme.fg("accent", theme.bold(title)), 1, 0));
|
|
479
|
+
container.addChild(new Text("", 0, 0));
|
|
480
|
+
for (const line of lines) {
|
|
481
|
+
container.addChild(new Text(theme.fg("dim", line), 1, 0));
|
|
482
|
+
}
|
|
483
|
+
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
484
|
+
return {
|
|
485
|
+
render: (w: number) => container.render(w),
|
|
486
|
+
invalidate: () => container.invalidate(),
|
|
487
|
+
handleInput: (data: string) => {
|
|
488
|
+
if (data === "q" || data === "\x1b") done(undefined);
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
469
494
|
export async function showSLAStats(
|
|
470
495
|
ctx: ExtensionContext,
|
|
471
496
|
state: SessionState,
|
|
472
497
|
): Promise<void> {
|
|
473
|
-
const runs = state.
|
|
498
|
+
const runs = state.getLogicalRunEntries(ctx).slice(0, state.config.slaWindowSize);
|
|
474
499
|
if (runs.length === 0) {
|
|
475
500
|
ctx.ui.notify("No runs to analyze. Delegate a task first.", "info");
|
|
476
501
|
return;
|
|
@@ -503,23 +528,7 @@ export async function showSLAStats(
|
|
|
503
528
|
}
|
|
504
529
|
}
|
|
505
530
|
|
|
506
|
-
ctx
|
|
507
|
-
const container = new Container();
|
|
508
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
509
|
-
container.addChild(new Text(theme.fg("accent", theme.bold("SLA Statistics")), 1, 0));
|
|
510
|
-
container.addChild(new Text("", 0, 0));
|
|
511
|
-
for (const line of lines) {
|
|
512
|
-
container.addChild(new Text(theme.fg("dim", line), 1, 0));
|
|
513
|
-
}
|
|
514
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
515
|
-
return {
|
|
516
|
-
render: (w: number) => container.render(w),
|
|
517
|
-
invalidate: () => container.invalidate(),
|
|
518
|
-
handleInput: (data: string) => {
|
|
519
|
-
if (data === "q" || data === "\x1b") done(undefined);
|
|
520
|
-
},
|
|
521
|
-
};
|
|
522
|
-
});
|
|
531
|
+
showLinesModal(ctx, "SLA Statistics", lines);
|
|
523
532
|
}
|
|
524
533
|
|
|
525
534
|
// Preset management UI
|
|
@@ -533,7 +542,7 @@ export async function showFileAccessReport(
|
|
|
533
542
|
ctx: ExtensionContext,
|
|
534
543
|
state: SessionState,
|
|
535
544
|
): Promise<void> {
|
|
536
|
-
const runs = state.
|
|
545
|
+
const runs = state.getLogicalRunEntries(ctx);
|
|
537
546
|
if (runs.length === 0) {
|
|
538
547
|
ctx.ui.notify("No runs to analyze. Delegate a task first.", "info");
|
|
539
548
|
return;
|
|
@@ -561,30 +570,14 @@ export async function showFileAccessReport(
|
|
|
561
570
|
lines.push(` Runs: ${runIds.join(", ")}`);
|
|
562
571
|
}
|
|
563
572
|
|
|
564
|
-
ctx
|
|
565
|
-
const container = new Container();
|
|
566
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
567
|
-
container.addChild(new Text(theme.fg("accent", theme.bold("File Access Report")), 1, 0));
|
|
568
|
-
container.addChild(new Text("", 0, 0));
|
|
569
|
-
for (const line of lines) {
|
|
570
|
-
container.addChild(new Text(theme.fg("dim", line), 1, 0));
|
|
571
|
-
}
|
|
572
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
573
|
-
return {
|
|
574
|
-
render: (w: number) => container.render(w),
|
|
575
|
-
invalidate: () => container.invalidate(),
|
|
576
|
-
handleInput: (data: string) => {
|
|
577
|
-
if (data === "q" || data === "\x1b") done(undefined);
|
|
578
|
-
},
|
|
579
|
-
};
|
|
580
|
-
});
|
|
573
|
+
showLinesModal(ctx, "File Access Report", lines);
|
|
581
574
|
}
|
|
582
575
|
|
|
583
576
|
export async function showSecretsExposureReport(
|
|
584
577
|
ctx: ExtensionContext,
|
|
585
578
|
state: SessionState,
|
|
586
579
|
): Promise<void> {
|
|
587
|
-
const runs = state.
|
|
580
|
+
const runs = state.getLogicalRunEntries(ctx);
|
|
588
581
|
if (runs.length === 0) {
|
|
589
582
|
ctx.ui.notify("No runs to analyze. Delegate a task first.", "info");
|
|
590
583
|
return;
|
|
@@ -634,30 +627,14 @@ export async function showSecretsExposureReport(
|
|
|
634
627
|
}
|
|
635
628
|
}
|
|
636
629
|
|
|
637
|
-
ctx
|
|
638
|
-
const container = new Container();
|
|
639
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
640
|
-
container.addChild(new Text(theme.fg("accent", theme.bold("Secrets Exposure Report")), 1, 0));
|
|
641
|
-
container.addChild(new Text("", 0, 0));
|
|
642
|
-
for (const line of lines) {
|
|
643
|
-
container.addChild(new Text(theme.fg("dim", line), 1, 0));
|
|
644
|
-
}
|
|
645
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
646
|
-
return {
|
|
647
|
-
render: (w: number) => container.render(w),
|
|
648
|
-
invalidate: () => container.invalidate(),
|
|
649
|
-
handleInput: (data: string) => {
|
|
650
|
-
if (data === "q" || data === "\x1b") done(undefined);
|
|
651
|
-
},
|
|
652
|
-
};
|
|
653
|
-
});
|
|
630
|
+
showLinesModal(ctx, "Secrets Exposure Report", lines);
|
|
654
631
|
}
|
|
655
632
|
|
|
656
633
|
export async function showFullComplianceSummary(
|
|
657
634
|
ctx: ExtensionContext,
|
|
658
635
|
state: SessionState,
|
|
659
636
|
): Promise<void> {
|
|
660
|
-
const runs = state.
|
|
637
|
+
const runs = state.getLogicalRunEntries(ctx);
|
|
661
638
|
if (runs.length === 0) {
|
|
662
639
|
ctx.ui.notify("No runs to analyze. Delegate a task first.", "info");
|
|
663
640
|
return;
|
|
@@ -683,23 +660,7 @@ export async function showFullComplianceSummary(
|
|
|
683
660
|
` High Severity: ${summary.highSeverityFindings}`,
|
|
684
661
|
];
|
|
685
662
|
|
|
686
|
-
ctx
|
|
687
|
-
const container = new Container();
|
|
688
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
689
|
-
container.addChild(new Text(theme.fg("accent", theme.bold("Compliance Summary")), 1, 0));
|
|
690
|
-
container.addChild(new Text("", 0, 0));
|
|
691
|
-
for (const line of lines) {
|
|
692
|
-
container.addChild(new Text(theme.fg("dim", line), 1, 0));
|
|
693
|
-
}
|
|
694
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
695
|
-
return {
|
|
696
|
-
render: (w: number) => container.render(w),
|
|
697
|
-
invalidate: () => container.invalidate(),
|
|
698
|
-
handleInput: (data: string) => {
|
|
699
|
-
if (data === "q" || data === "\x1b") done(undefined);
|
|
700
|
-
},
|
|
701
|
-
};
|
|
702
|
-
});
|
|
663
|
+
showLinesModal(ctx, "Compliance Summary", lines);
|
|
703
664
|
}
|
|
704
665
|
|
|
705
666
|
export async function showComplianceMenu(
|
|
@@ -1281,35 +1242,12 @@ export async function showConfigMenu(
|
|
|
1281
1242
|
},
|
|
1282
1243
|
];
|
|
1283
1244
|
|
|
1284
|
-
const result = await
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
);
|
|
1291
|
-
|
|
1292
|
-
const selectList = new SelectList(
|
|
1293
|
-
items,
|
|
1294
|
-
Math.min(items.length, CONFIG_MENU_VIEWPORT),
|
|
1295
|
-
makeSelectListTheme(theme),
|
|
1296
|
-
);
|
|
1297
|
-
selectList.onSelect = (item) => done(item.value);
|
|
1298
|
-
selectList.onCancel = () => done(null);
|
|
1299
|
-
|
|
1300
|
-
container.addChild(selectList);
|
|
1301
|
-
container.addChild(new Text(theme.fg("dim", NAV_FOOTER), 1, 0));
|
|
1302
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
1303
|
-
|
|
1304
|
-
return {
|
|
1305
|
-
render: (w: number) => container.render(w),
|
|
1306
|
-
invalidate: () => container.invalidate(),
|
|
1307
|
-
handleInput: (data: string) => {
|
|
1308
|
-
selectList.handleInput(data);
|
|
1309
|
-
tui.requestRender();
|
|
1310
|
-
},
|
|
1311
|
-
};
|
|
1312
|
-
});
|
|
1245
|
+
const result = await showSelectList(
|
|
1246
|
+
ctx,
|
|
1247
|
+
"brl-subagent Configuration",
|
|
1248
|
+
items,
|
|
1249
|
+
CONFIG_MENU_VIEWPORT,
|
|
1250
|
+
);
|
|
1313
1251
|
|
|
1314
1252
|
if (!result || result === "__done__") return;
|
|
1315
1253
|
|
|
@@ -1331,7 +1269,7 @@ export async function showConfigMenu(
|
|
|
1331
1269
|
* run that exists only in the durable registry.
|
|
1332
1270
|
*/
|
|
1333
1271
|
function recoverableRunEntries(ctx: ExtensionContext, state: SessionState): SubagentRun[] {
|
|
1334
|
-
return visibleRunEntriesForSession(state.
|
|
1272
|
+
return visibleRunEntriesForSession(state.getLogicalRunEntries(ctx), getAgent);
|
|
1335
1273
|
}
|
|
1336
1274
|
|
|
1337
1275
|
export async function showRunHistory(
|
|
@@ -1620,6 +1558,11 @@ export async function showMonitor(
|
|
|
1620
1558
|
// Selected row index (0-based). Clamped to the map size on every
|
|
1621
1559
|
// render — entries can be swept while the monitor is open.
|
|
1622
1560
|
let selectedIndex = 0;
|
|
1561
|
+
// Issue #423: the id list from the LAST paint. Selection identity is an
|
|
1562
|
+
// index over what was RENDERED, not over the live map: a spawn or a
|
|
1563
|
+
// finalize between paint and Enter would otherwise shift the id list and
|
|
1564
|
+
// open an agent other than the highlighted row.
|
|
1565
|
+
let lastRenderedIds: string[] = [];
|
|
1623
1566
|
// Guards against stacking drill-in overlays on repeated Enter.
|
|
1624
1567
|
let detailOpen = false;
|
|
1625
1568
|
|
|
@@ -1629,13 +1572,17 @@ export async function showMonitor(
|
|
|
1629
1572
|
// render pass. Idempotent, so racing the poller is safe.
|
|
1630
1573
|
sweepStaleLiveSubagents(state, getAgent);
|
|
1631
1574
|
|
|
1575
|
+
// Issue #423: the shared display projection (settled ids out, deadline order).
|
|
1576
|
+
const entries = liveDisplayEntries(state);
|
|
1577
|
+
lastRenderedIds = entries.map(([id]) => id);
|
|
1578
|
+
|
|
1632
1579
|
const container = new Container();
|
|
1633
1580
|
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
1634
1581
|
container.addChild(
|
|
1635
1582
|
new Text(
|
|
1636
1583
|
theme.fg(
|
|
1637
1584
|
"accent",
|
|
1638
|
-
theme.bold(`Subagent Monitor (${
|
|
1585
|
+
theme.bold(`Subagent Monitor (${entries.length} active)`),
|
|
1639
1586
|
),
|
|
1640
1587
|
1,
|
|
1641
1588
|
0,
|
|
@@ -1646,14 +1593,14 @@ export async function showMonitor(
|
|
|
1646
1593
|
);
|
|
1647
1594
|
container.addChild(new Text("", 0, 0));
|
|
1648
1595
|
|
|
1649
|
-
const entries = Array.from(state.subagentSessions.entries());
|
|
1650
1596
|
const selIdx = Math.min(selectedIndex, Math.max(0, entries.length - 1));
|
|
1597
|
+
const now = Date.now();
|
|
1651
1598
|
|
|
1652
1599
|
let idx = 0;
|
|
1653
1600
|
for (const [id, session] of entries) {
|
|
1654
|
-
const elapsedStr = formatElapsed(
|
|
1601
|
+
const elapsedStr = formatElapsed(now - session.startedAt);
|
|
1655
1602
|
const name = liveRowName(session.label, session.task);
|
|
1656
|
-
const spinner = liveSpinner(
|
|
1603
|
+
const spinner = liveSpinner(now);
|
|
1657
1604
|
// Selection marker: a "›" prefix on the selected row only. The
|
|
1658
1605
|
// rest of the row (spinner/name/dim/muted lines) is unchanged.
|
|
1659
1606
|
const marker = idx === selIdx ? "› " : "";
|
|
@@ -1663,7 +1610,14 @@ export async function showMonitor(
|
|
|
1663
1610
|
theme.fg("accent", `${marker}${spinner} ${name}`) +
|
|
1664
1611
|
theme.fg(
|
|
1665
1612
|
"dim",
|
|
1666
|
-
formatLiveRowDim(
|
|
1613
|
+
formatLiveRowDim(
|
|
1614
|
+
id,
|
|
1615
|
+
session.usage,
|
|
1616
|
+
elapsedStr,
|
|
1617
|
+
// Issue #423: used / budget (percent left); `—` when the run has
|
|
1618
|
+
// no timer at all (a foreground run with no timeout).
|
|
1619
|
+
formatBudget(session.startedAt, session.deadlineAt, now),
|
|
1620
|
+
),
|
|
1667
1621
|
),
|
|
1668
1622
|
1,
|
|
1669
1623
|
0,
|
|
@@ -1714,15 +1668,17 @@ export async function showMonitor(
|
|
|
1714
1668
|
done();
|
|
1715
1669
|
return;
|
|
1716
1670
|
}
|
|
1717
|
-
// up / down: move the selection, wrapping like SelectList.
|
|
1671
|
+
// up / down: move the selection, wrapping like SelectList. The bound is
|
|
1672
|
+
// the list the LAST paint rendered (issue #423), so the highlight can
|
|
1673
|
+
// never run past a row the human cannot see.
|
|
1718
1674
|
if (_kb.matches(data, "tui.select.up")) {
|
|
1719
|
-
const count =
|
|
1675
|
+
const count = lastRenderedIds.length;
|
|
1720
1676
|
selectedIndex = count > 0 ? (selectedIndex - 1 + count) % count : 0;
|
|
1721
1677
|
tui.requestRender();
|
|
1722
1678
|
return;
|
|
1723
1679
|
}
|
|
1724
1680
|
if (_kb.matches(data, "tui.select.down")) {
|
|
1725
|
-
const count =
|
|
1681
|
+
const count = lastRenderedIds.length;
|
|
1726
1682
|
selectedIndex = count > 0 ? (selectedIndex + 1) % count : 0;
|
|
1727
1683
|
tui.requestRender();
|
|
1728
1684
|
return;
|
|
@@ -1730,9 +1686,11 @@ export async function showMonitor(
|
|
|
1730
1686
|
// enter: open the full-screen drill-in overlay for the selected agent.
|
|
1731
1687
|
// The overlay's done() returns to the list — the monitor stays open
|
|
1732
1688
|
// beneath it (fire-and-forget; handleInput is synchronous).
|
|
1689
|
+
// Issue #423: the id resolves against the RENDERED list, so a spawn or
|
|
1690
|
+
// a finalize between paint and Enter cannot open a different agent than
|
|
1691
|
+
// the highlighted row (a stale id falls through to the not-found path).
|
|
1733
1692
|
if (_kb.matches(data, "tui.select.confirm")) {
|
|
1734
|
-
const
|
|
1735
|
-
const id = ids[Math.min(selectedIndex, ids.length - 1)];
|
|
1693
|
+
const id = lastRenderedIds[selectedIndex];
|
|
1736
1694
|
if (id && !detailOpen) {
|
|
1737
1695
|
detailOpen = true;
|
|
1738
1696
|
showAgentDetail(ctx, state, id).finally(() => {
|
|
@@ -2044,7 +2002,7 @@ function compactDuration(ms: number): string {
|
|
|
2044
2002
|
/** The per-row live-session slice the Active Subagents panel renders. */
|
|
2045
2003
|
export type ActiveSubagentSlice = Pick<
|
|
2046
2004
|
LiveSubagent,
|
|
2047
|
-
"label" | "task" | "startedAt" | "usage"
|
|
2005
|
+
"label" | "task" | "startedAt" | "deadlineAt" | "usage"
|
|
2048
2006
|
>;
|
|
2049
2007
|
|
|
2050
2008
|
/** Panel 1 — header: the dashboard title plus the refresh stamp. */
|
|
@@ -2063,15 +2021,35 @@ export function renderDashboardHeader(theme: Theme, refreshStr: string): Compone
|
|
|
2063
2021
|
/**
|
|
2064
2022
|
* Panel 2 — active subagents: the live count in the title, one row per entry.
|
|
2065
2023
|
*
|
|
2066
|
-
*
|
|
2067
|
-
* and
|
|
2024
|
+
* Issue #423: the rows arrive as an ORDERED array (the call site filters
|
|
2025
|
+
* finalized ids and sorts by the soonest deadline) rather than the raw map, so
|
|
2026
|
+
* the panel cannot render a settled row or an order the monitor disagrees with,
|
|
2027
|
+
* and `activeCount` is the rendered length instead of `map.size` (which counted
|
|
2028
|
+
* finalized-but-lingering entries).
|
|
2029
|
+
*
|
|
2030
|
+
* `now` is injected (the composer passes the wall clock) so the spinner frame,
|
|
2031
|
+
* the elapsed suffix and the budget stay testable; it is sampled per render.
|
|
2068
2032
|
*/
|
|
2033
|
+
/**
|
|
2034
|
+
* Issue #423: the monitor and the dashboard render the same projection — settled
|
|
2035
|
+
* ids removed (a 3 s lingering row must not show a live deadline) and rows
|
|
2036
|
+
* ordered by the soonest deadline. One definition, so the surfaces cannot
|
|
2037
|
+
* disagree (review 425, DRY).
|
|
2038
|
+
*/
|
|
2039
|
+
export function liveDisplayEntries(state: SessionState): Array<[string, LiveSubagent]> {
|
|
2040
|
+
return sortLiveSessions(
|
|
2041
|
+
Array.from(state.subagentSessions.entries()).filter(
|
|
2042
|
+
([id]) => !state.isLiveEntryFinalized(id),
|
|
2043
|
+
),
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2069
2047
|
export function renderDashboardActivePanel(
|
|
2070
2048
|
theme: Theme,
|
|
2071
|
-
sessions:
|
|
2049
|
+
sessions: ReadonlyArray<readonly [string, ActiveSubagentSlice]>,
|
|
2072
2050
|
now: () => number = Date.now,
|
|
2073
2051
|
): Component[] {
|
|
2074
|
-
const activeCount = sessions.
|
|
2052
|
+
const activeCount = sessions.length;
|
|
2075
2053
|
const components: Component[] = [
|
|
2076
2054
|
new Text(
|
|
2077
2055
|
theme.fg("accent", theme.bold(`Active Subagents (${activeCount})`)),
|
|
@@ -2084,15 +2062,22 @@ export function renderDashboardActivePanel(
|
|
|
2084
2062
|
} else {
|
|
2085
2063
|
let idx = 0;
|
|
2086
2064
|
for (const [id, session] of sessions) {
|
|
2087
|
-
const
|
|
2065
|
+
const nowMs = now();
|
|
2066
|
+
const elapsedStr = formatElapsed(nowMs - session.startedAt);
|
|
2088
2067
|
const name = liveRowName(session.label, session.task);
|
|
2089
|
-
const spinner = liveSpinner(
|
|
2068
|
+
const spinner = liveSpinner(nowMs);
|
|
2090
2069
|
components.push(
|
|
2091
2070
|
new Text(
|
|
2092
2071
|
theme.fg("accent", ` ${spinner} ${name}`) +
|
|
2093
2072
|
theme.fg(
|
|
2094
2073
|
"dim",
|
|
2095
|
-
formatLiveRowDim(
|
|
2074
|
+
formatLiveRowDim(
|
|
2075
|
+
id,
|
|
2076
|
+
session.usage,
|
|
2077
|
+
elapsedStr,
|
|
2078
|
+
// Issue #423: used / budget (percent left); `—` when no timer.
|
|
2079
|
+
formatBudget(session.startedAt, session.deadlineAt, nowMs),
|
|
2080
|
+
),
|
|
2096
2081
|
),
|
|
2097
2082
|
1,
|
|
2098
2083
|
0,
|
|
@@ -2296,10 +2281,11 @@ export async function showDashboard(
|
|
|
2296
2281
|
append(renderDashboardHeader(theme, refreshStr));
|
|
2297
2282
|
|
|
2298
2283
|
// ---- Panel 2: Active subagents ----
|
|
2299
|
-
|
|
2284
|
+
// Issue #423: the panel takes the same ordered projection as the monitor.
|
|
2285
|
+
append(renderDashboardActivePanel(theme, liveDisplayEntries(state), Date.now));
|
|
2300
2286
|
|
|
2301
2287
|
// ---- Panel 3: SLA Summary ----
|
|
2302
|
-
const allRuns = state.
|
|
2288
|
+
const allRuns = state.getLogicalRunEntries(ctx);
|
|
2303
2289
|
const recentRuns = allRuns.slice(0, state.config.slaWindowSize || 50);
|
|
2304
2290
|
const metrics = recentRuns.length > 0 ? computeSLAMetrics(recentRuns) : null;
|
|
2305
2291
|
append(renderDashboardSlaPanel(theme, metrics, recentRuns.length));
|
|
@@ -2503,6 +2489,31 @@ function renderCollapsedText(
|
|
|
2503
2489
|
// Chain / parallel collapsed rendering
|
|
2504
2490
|
// ---------------------------------------------------------------------------
|
|
2505
2491
|
|
|
2492
|
+
/** One collapsed per-step line — shared by the chain and parallel summaries. */
|
|
2493
|
+
function renderCollapsedSubTask(
|
|
2494
|
+
r: SubTaskResult,
|
|
2495
|
+
theme: Theme,
|
|
2496
|
+
opts: { stepPrefix: boolean; emptyLabelSeparator: string },
|
|
2497
|
+
): string {
|
|
2498
|
+
const isErr = isSubagentError(r);
|
|
2499
|
+
const statusIcon = formatOutcomeSymbol(isErr ? "failure" : "success", theme);
|
|
2500
|
+
const stepNum =
|
|
2501
|
+
opts.stepPrefix && r.step !== undefined
|
|
2502
|
+
? theme.fg("muted", `${r.step}. `)
|
|
2503
|
+
: "";
|
|
2504
|
+
const label = r.label ? theme.fg("accent", r.label) : "";
|
|
2505
|
+
const output = getFinalOutput(r.messages);
|
|
2506
|
+
const preview = output.split("\n").slice(0, 2).join("\n");
|
|
2507
|
+
const sep = label ? ": " : opts.emptyLabelSeparator;
|
|
2508
|
+
let text = `\n${stepNum}${statusIcon} ${label}${sep}${theme.fg("toolOutput", preview)}`;
|
|
2509
|
+
if (r.errorMessage) {
|
|
2510
|
+
text += `\n ${theme.fg("error", r.errorMessage)}`;
|
|
2511
|
+
}
|
|
2512
|
+
const diffSummary = renderCollapsedDiffSummary(r.gitDiff, theme);
|
|
2513
|
+
if (diffSummary) text += `\n ${diffSummary}`;
|
|
2514
|
+
return text;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2506
2517
|
function renderCollapsedChain(
|
|
2507
2518
|
details: ChainDetails,
|
|
2508
2519
|
theme: Theme,
|
|
@@ -2513,21 +2524,10 @@ function renderCollapsedChain(
|
|
|
2513
2524
|
let text = `${icon} ${theme.fg("toolTitle", theme.bold("chain"))} ${theme.fg("muted", `${details.completedSteps}/${details.totalSteps} steps${stoppedEarly}`)}`;
|
|
2514
2525
|
|
|
2515
2526
|
for (const r of details.results) {
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
const label = r.label ? theme.fg("accent", r.label) : "";
|
|
2521
|
-
const output = getFinalOutput(r.messages);
|
|
2522
|
-
const preview = output.split("\n").slice(0, 2).join("\n");
|
|
2523
|
-
const sep = label ? ": " : "";
|
|
2524
|
-
text += `\n${stepNum}${statusIcon} ${label}${sep}${theme.fg("toolOutput", preview)}`;
|
|
2525
|
-
if (r.errorMessage) {
|
|
2526
|
-
text += `\n ${theme.fg("error", r.errorMessage)}`;
|
|
2527
|
-
}
|
|
2528
|
-
// P5: Collapsed diff file summary per step
|
|
2529
|
-
const diffSummary = renderCollapsedDiffSummary(r.gitDiff, theme);
|
|
2530
|
-
if (diffSummary) text += `\n ${diffSummary}`;
|
|
2527
|
+
text += renderCollapsedSubTask(r, theme, {
|
|
2528
|
+
stepPrefix: true,
|
|
2529
|
+
emptyLabelSeparator: "",
|
|
2530
|
+
});
|
|
2531
2531
|
}
|
|
2532
2532
|
|
|
2533
2533
|
text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
@@ -2542,19 +2542,10 @@ function renderCollapsedParallel(
|
|
|
2542
2542
|
let text = `${icon} ${theme.fg("toolTitle", theme.bold("parallel"))} ${theme.fg("muted", `${details.succeeded}/${details.failed}/${details.results.length} total`)}`;
|
|
2543
2543
|
|
|
2544
2544
|
for (const r of details.results) {
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
const preview = output.split("\n").slice(0, 2).join("\n");
|
|
2550
|
-
const sep = label ? ": " : " ";
|
|
2551
|
-
text += `\n${statusIcon} ${label}${sep}${theme.fg("toolOutput", preview)}`;
|
|
2552
|
-
if (r.errorMessage) {
|
|
2553
|
-
text += `\n ${theme.fg("error", r.errorMessage)}`;
|
|
2554
|
-
}
|
|
2555
|
-
// P5: Collapsed diff file summary per task
|
|
2556
|
-
const diffSummary = renderCollapsedDiffSummary(r.gitDiff, theme);
|
|
2557
|
-
if (diffSummary) text += `\n ${diffSummary}`;
|
|
2545
|
+
text += renderCollapsedSubTask(r, theme, {
|
|
2546
|
+
stepPrefix: false,
|
|
2547
|
+
emptyLabelSeparator: " ",
|
|
2548
|
+
});
|
|
2558
2549
|
}
|
|
2559
2550
|
|
|
2560
2551
|
text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
@@ -2565,76 +2556,74 @@ function renderCollapsedParallel(
|
|
|
2565
2556
|
// Chain / parallel expanded rendering
|
|
2566
2557
|
// ---------------------------------------------------------------------------
|
|
2567
2558
|
|
|
2568
|
-
|
|
2569
|
-
|
|
2559
|
+
type AggregatedTotals = Pick<
|
|
2560
|
+
MultiSubagentDetails,
|
|
2561
|
+
"totalInput" | "totalOutput" | "totalCost" | "totalTurns"
|
|
2562
|
+
>;
|
|
2563
|
+
|
|
2564
|
+
/** Add one expanded sub-task block (result header, task, output, diff, usage). */
|
|
2565
|
+
function addExpandedSubTask(
|
|
2566
|
+
container: Container,
|
|
2567
|
+
r: SubTaskResult,
|
|
2570
2568
|
theme: Theme,
|
|
2571
2569
|
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
const
|
|
2570
|
+
opts: { stepPrefix: boolean },
|
|
2571
|
+
): void {
|
|
2572
|
+
const isErr = isSubagentError(r);
|
|
2573
|
+
const statusIcon = formatOutcomeSymbol(isErr ? "failure" : "success", theme);
|
|
2574
|
+
const stepNum =
|
|
2575
|
+
opts.stepPrefix && r.step !== undefined ? `${r.step}. ` : "";
|
|
2576
|
+
const label = r.label ? `[${r.label}] ` : "";
|
|
2575
2577
|
container.addChild(
|
|
2576
2578
|
new Text(
|
|
2577
|
-
theme.fg("
|
|
2578
|
-
theme.fg(
|
|
2579
|
-
"muted",
|
|
2580
|
-
` ${details.completedSteps}/${details.totalSteps} steps${stoppedEarly}`,
|
|
2581
|
-
),
|
|
2579
|
+
`${statusIcon} ${stepNum}${theme.fg("toolTitle", theme.bold(label))}` +
|
|
2580
|
+
(r.model ? theme.fg("muted", ` (${r.model})`) : ""),
|
|
2582
2581
|
0,
|
|
2583
2582
|
0,
|
|
2584
2583
|
),
|
|
2585
2584
|
);
|
|
2586
|
-
container.addChild(
|
|
2585
|
+
container.addChild(
|
|
2586
|
+
new Text(theme.fg("dim", `Task: ${r.task.slice(0, 200)}`), 0, 0),
|
|
2587
|
+
);
|
|
2587
2588
|
|
|
2588
|
-
|
|
2589
|
-
const isErr = isSubagentError(r);
|
|
2590
|
-
const statusIcon = formatOutcomeSymbol(isErr ? "failure" : "success", theme);
|
|
2591
|
-
const stepNum = r.step !== undefined ? `${r.step}. ` : "";
|
|
2592
|
-
const label = r.label ? `[${r.label}] ` : "";
|
|
2589
|
+
if (isErr && r.errorMessage) {
|
|
2593
2590
|
container.addChild(
|
|
2594
|
-
new Text(
|
|
2595
|
-
`${statusIcon} ${stepNum}${theme.fg("toolTitle", theme.bold(label))}` +
|
|
2596
|
-
(r.model ? theme.fg("muted", ` (${r.model})`) : ""),
|
|
2597
|
-
0,
|
|
2598
|
-
0,
|
|
2599
|
-
),
|
|
2591
|
+
new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0),
|
|
2600
2592
|
);
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
const output = getFinalOutput(r.messages);
|
|
2596
|
+
if (output) {
|
|
2601
2597
|
container.addChild(
|
|
2602
|
-
new Text(theme.fg("
|
|
2598
|
+
new Text(theme.fg("muted", "\u2500\u2500\u2500 Output \u2500\u2500\u2500"), 0, 0),
|
|
2603
2599
|
);
|
|
2600
|
+
container.addChild(new Markdown(output.trim(), 0, 0, mdTheme));
|
|
2601
|
+
}
|
|
2604
2602
|
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0),
|
|
2608
|
-
);
|
|
2609
|
-
}
|
|
2610
|
-
|
|
2611
|
-
const output = getFinalOutput(r.messages);
|
|
2612
|
-
if (output) {
|
|
2613
|
-
container.addChild(
|
|
2614
|
-
new Text(theme.fg("muted", "\u2500\u2500\u2500 Output \u2500\u2500\u2500"), 0, 0),
|
|
2615
|
-
);
|
|
2616
|
-
container.addChild(new Markdown(output.trim(), 0, 0, mdTheme));
|
|
2617
|
-
}
|
|
2618
|
-
|
|
2619
|
-
// P5: Expanded diff section per step
|
|
2620
|
-
addExpandedDiffSection(container, r.gitDiff, theme);
|
|
2603
|
+
// P5: Expanded diff section per step/task
|
|
2604
|
+
addExpandedDiffSection(container, r.gitDiff, theme);
|
|
2621
2605
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
}
|
|
2626
|
-
container.addChild(new Spacer(1));
|
|
2606
|
+
const usageStr = formatUsageStats(r.usage, r.model);
|
|
2607
|
+
if (usageStr) {
|
|
2608
|
+
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
2627
2609
|
}
|
|
2610
|
+
container.addChild(new Spacer(1));
|
|
2611
|
+
}
|
|
2628
2612
|
|
|
2629
|
-
|
|
2613
|
+
/** Add the aggregated totals line shared by every multi-task mode. */
|
|
2614
|
+
function addAggregatedTotals(
|
|
2615
|
+
container: Container,
|
|
2616
|
+
totals: AggregatedTotals,
|
|
2617
|
+
theme: Theme,
|
|
2618
|
+
): void {
|
|
2630
2619
|
const aggUsage: UsageStats = {
|
|
2631
|
-
input:
|
|
2632
|
-
output:
|
|
2620
|
+
input: totals.totalInput,
|
|
2621
|
+
output: totals.totalOutput,
|
|
2633
2622
|
cacheRead: 0,
|
|
2634
2623
|
cacheWrite: 0,
|
|
2635
|
-
cost:
|
|
2624
|
+
cost: totals.totalCost,
|
|
2636
2625
|
contextTokens: 0,
|
|
2637
|
-
turns:
|
|
2626
|
+
turns: totals.totalTurns,
|
|
2638
2627
|
};
|
|
2639
2628
|
const aggStr = formatUsageStats(aggUsage);
|
|
2640
2629
|
if (aggStr) {
|
|
@@ -2642,87 +2631,63 @@ function renderExpandedChain(
|
|
|
2642
2631
|
new Text(theme.fg("dim", `Totals: ${aggStr}`), 0, 0),
|
|
2643
2632
|
);
|
|
2644
2633
|
}
|
|
2645
|
-
|
|
2646
|
-
return container;
|
|
2647
2634
|
}
|
|
2648
2635
|
|
|
2649
|
-
|
|
2650
|
-
|
|
2636
|
+
/**
|
|
2637
|
+
* Expanded chain/parallel view. The two modes differ only in their header and
|
|
2638
|
+
* per-step labelling, both supplied by the caller.
|
|
2639
|
+
*/
|
|
2640
|
+
function renderExpandedMulti(
|
|
2641
|
+
details: MultiSubagentDetails,
|
|
2642
|
+
header: string,
|
|
2651
2643
|
theme: Theme,
|
|
2652
2644
|
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2645
|
+
opts: { stepPrefix: boolean },
|
|
2653
2646
|
): Container {
|
|
2654
2647
|
const container = new Container();
|
|
2655
|
-
container.addChild(
|
|
2656
|
-
new Text(
|
|
2657
|
-
theme.fg("accent", theme.bold("Parallel")) +
|
|
2658
|
-
theme.fg(
|
|
2659
|
-
"muted",
|
|
2660
|
-
` ${details.succeeded} succeeded, ${details.failed} failed, ${details.results.length} total`,
|
|
2661
|
-
),
|
|
2662
|
-
0,
|
|
2663
|
-
0,
|
|
2664
|
-
),
|
|
2665
|
-
);
|
|
2648
|
+
container.addChild(new Text(header, 0, 0));
|
|
2666
2649
|
container.addChild(new Spacer(1));
|
|
2667
2650
|
|
|
2668
2651
|
for (const r of details.results) {
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
const label = r.label ? `[${r.label}] ` : "";
|
|
2672
|
-
container.addChild(
|
|
2673
|
-
new Text(
|
|
2674
|
-
`${statusIcon} ${theme.fg("toolTitle", theme.bold(label))}` +
|
|
2675
|
-
(r.model ? theme.fg("muted", ` (${r.model})`) : ""),
|
|
2676
|
-
0,
|
|
2677
|
-
0,
|
|
2678
|
-
),
|
|
2679
|
-
);
|
|
2680
|
-
container.addChild(
|
|
2681
|
-
new Text(theme.fg("dim", `Task: ${r.task.slice(0, 200)}`), 0, 0),
|
|
2682
|
-
);
|
|
2683
|
-
|
|
2684
|
-
if (isErr && r.errorMessage) {
|
|
2685
|
-
container.addChild(
|
|
2686
|
-
new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0),
|
|
2687
|
-
);
|
|
2688
|
-
}
|
|
2689
|
-
|
|
2690
|
-
const output = getFinalOutput(r.messages);
|
|
2691
|
-
if (output) {
|
|
2692
|
-
container.addChild(
|
|
2693
|
-
new Text(theme.fg("muted", "\u2500\u2500\u2500 Output \u2500\u2500\u2500"), 0, 0),
|
|
2694
|
-
);
|
|
2695
|
-
container.addChild(new Markdown(output.trim(), 0, 0, mdTheme));
|
|
2696
|
-
}
|
|
2652
|
+
addExpandedSubTask(container, r, theme, mdTheme, opts);
|
|
2653
|
+
}
|
|
2697
2654
|
|
|
2698
|
-
|
|
2699
|
-
addExpandedDiffSection(container, r.gitDiff, theme);
|
|
2655
|
+
addAggregatedTotals(container, details, theme);
|
|
2700
2656
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
2704
|
-
}
|
|
2705
|
-
container.addChild(new Spacer(1));
|
|
2706
|
-
}
|
|
2657
|
+
return container;
|
|
2658
|
+
}
|
|
2707
2659
|
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
if (aggStr) {
|
|
2720
|
-
container.addChild(
|
|
2721
|
-
new Text(theme.fg("dim", `Totals: ${aggStr}`), 0, 0),
|
|
2660
|
+
function renderExpandedChain(
|
|
2661
|
+
details: ChainDetails,
|
|
2662
|
+
theme: Theme,
|
|
2663
|
+
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2664
|
+
): Container {
|
|
2665
|
+
const stoppedEarly = details.stoppedEarly ? " (stopped early)" : "";
|
|
2666
|
+
const header =
|
|
2667
|
+
theme.fg("accent", theme.bold("Chain")) +
|
|
2668
|
+
theme.fg(
|
|
2669
|
+
"muted",
|
|
2670
|
+
` ${details.completedSteps}/${details.totalSteps} steps${stoppedEarly}`,
|
|
2722
2671
|
);
|
|
2723
|
-
|
|
2672
|
+
return renderExpandedMulti(details, header, theme, mdTheme, {
|
|
2673
|
+
stepPrefix: true,
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2724
2676
|
|
|
2725
|
-
|
|
2677
|
+
function renderExpandedParallel(
|
|
2678
|
+
details: ParallelDetails,
|
|
2679
|
+
theme: Theme,
|
|
2680
|
+
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2681
|
+
): Container {
|
|
2682
|
+
const header =
|
|
2683
|
+
theme.fg("accent", theme.bold("Parallel")) +
|
|
2684
|
+
theme.fg(
|
|
2685
|
+
"muted",
|
|
2686
|
+
` ${details.succeeded} succeeded, ${details.failed} failed, ${details.results.length} total`,
|
|
2687
|
+
);
|
|
2688
|
+
return renderExpandedMulti(details, header, theme, mdTheme, {
|
|
2689
|
+
stepPrefix: false,
|
|
2690
|
+
});
|
|
2726
2691
|
}
|
|
2727
2692
|
|
|
2728
2693
|
// ---------------------------------------------------------------------------
|
|
@@ -3102,62 +3067,11 @@ function renderExpandedGraph(
|
|
|
3102
3067
|
);
|
|
3103
3068
|
|
|
3104
3069
|
for (const r of wave.tasks) {
|
|
3105
|
-
|
|
3106
|
-
const statusIcon = formatOutcomeSymbol(isErr ? "failure" : "success", theme);
|
|
3107
|
-
const label = r.label ? `[${r.label}] ` : "";
|
|
3108
|
-
|
|
3109
|
-
container.addChild(
|
|
3110
|
-
new Text(
|
|
3111
|
-
`${statusIcon} ${theme.fg("toolTitle", theme.bold(label))}` +
|
|
3112
|
-
(r.model ? theme.fg("muted", ` (${r.model})`) : ""),
|
|
3113
|
-
0,
|
|
3114
|
-
0,
|
|
3115
|
-
),
|
|
3116
|
-
);
|
|
3117
|
-
container.addChild(
|
|
3118
|
-
new Text(theme.fg("dim", `Task: ${r.task.slice(0, 200)}`), 0, 0),
|
|
3119
|
-
);
|
|
3120
|
-
|
|
3121
|
-
if (isErr && r.errorMessage) {
|
|
3122
|
-
container.addChild(
|
|
3123
|
-
new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0),
|
|
3124
|
-
);
|
|
3125
|
-
}
|
|
3126
|
-
|
|
3127
|
-
const output = getFinalOutput(r.messages);
|
|
3128
|
-
if (output) {
|
|
3129
|
-
container.addChild(
|
|
3130
|
-
new Text(theme.fg("muted", "\u2500\u2500\u2500 Output \u2500\u2500\u2500"), 0, 0),
|
|
3131
|
-
);
|
|
3132
|
-
container.addChild(new Markdown(output.trim(), 0, 0, mdTheme));
|
|
3133
|
-
}
|
|
3134
|
-
|
|
3135
|
-
addExpandedDiffSection(container, r.gitDiff, theme);
|
|
3136
|
-
|
|
3137
|
-
const usageStr = formatUsageStats(r.usage, r.model);
|
|
3138
|
-
if (usageStr) {
|
|
3139
|
-
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
3140
|
-
}
|
|
3141
|
-
container.addChild(new Spacer(1));
|
|
3070
|
+
addExpandedSubTask(container, r, theme, mdTheme, { stepPrefix: false });
|
|
3142
3071
|
}
|
|
3143
3072
|
}
|
|
3144
3073
|
|
|
3145
|
-
|
|
3146
|
-
const aggUsage: UsageStats = {
|
|
3147
|
-
input: details.totalInput,
|
|
3148
|
-
output: details.totalOutput,
|
|
3149
|
-
cacheRead: 0,
|
|
3150
|
-
cacheWrite: 0,
|
|
3151
|
-
cost: details.totalCost,
|
|
3152
|
-
contextTokens: 0,
|
|
3153
|
-
turns: details.totalTurns,
|
|
3154
|
-
};
|
|
3155
|
-
const aggStr = formatUsageStats(aggUsage);
|
|
3156
|
-
if (aggStr) {
|
|
3157
|
-
container.addChild(
|
|
3158
|
-
new Text(theme.fg("dim", `Totals: ${aggStr}`), 0, 0),
|
|
3159
|
-
);
|
|
3160
|
-
}
|
|
3074
|
+
addAggregatedTotals(container, details, theme);
|
|
3161
3075
|
|
|
3162
3076
|
return container;
|
|
3163
3077
|
}
|
|
@@ -3166,74 +3080,67 @@ function renderExpandedGraph(
|
|
|
3166
3080
|
// Public rendering entry points (used by delegate_task tool)
|
|
3167
3081
|
// ---------------------------------------------------------------------------
|
|
3168
3082
|
|
|
3083
|
+
/**
|
|
3084
|
+
* Render the delegate_task call preview shared by graph / chain / parallel.
|
|
3085
|
+
* `items` are pre-resolved labels (plus an optional already-formatted suffix).
|
|
3086
|
+
*/
|
|
3087
|
+
function renderDelegatePreview(
|
|
3088
|
+
kind: string,
|
|
3089
|
+
noun: string,
|
|
3090
|
+
items: Array<{ label: string; suffix?: string }>,
|
|
3091
|
+
theme: Theme,
|
|
3092
|
+
): Text {
|
|
3093
|
+
const count = items.length;
|
|
3094
|
+
let text = `${theme.fg("accent", "delegate_task")} ${theme.fg("muted", `${kind} (${count} ${noun}${count > 1 ? "s" : ""})`)}`;
|
|
3095
|
+
const preview = items.slice(0, 3);
|
|
3096
|
+
for (let i = 0; i < preview.length; i++) {
|
|
3097
|
+
const item = preview[i];
|
|
3098
|
+
const suffix = item.suffix ? theme.fg("dim", item.suffix) : "";
|
|
3099
|
+
text += `\n${theme.fg("muted", `${i + 1}.`)} ${theme.fg("dim", item.label)}${suffix}`;
|
|
3100
|
+
}
|
|
3101
|
+
if (count > 3) {
|
|
3102
|
+
text += `\n${theme.fg("dim", `+${count - 3} more`)}`;
|
|
3103
|
+
}
|
|
3104
|
+
return new Text(text, 0, 0);
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3169
3107
|
export function renderDelegateCall(
|
|
3170
|
-
args:
|
|
3171
|
-
task?: string;
|
|
3172
|
-
label?: string;
|
|
3173
|
-
systemPrompt?: string;
|
|
3174
|
-
inheritSystemPrompt?: boolean;
|
|
3175
|
-
thinkingLevel?: string;
|
|
3176
|
-
outputFile?: string;
|
|
3177
|
-
timeout?: number;
|
|
3178
|
-
cwd?: string;
|
|
3179
|
-
tools?: string[];
|
|
3180
|
-
excludeTools?: string[];
|
|
3181
|
-
noBuiltinTools?: boolean;
|
|
3182
|
-
chain?: SubTaskParams[];
|
|
3183
|
-
tasks?: SubTaskParams[];
|
|
3184
|
-
graph?: GraphTask[];
|
|
3185
|
-
},
|
|
3108
|
+
args: DelegateTaskParams,
|
|
3186
3109
|
theme: Theme,
|
|
3187
3110
|
): Text {
|
|
3188
3111
|
// Graph mode
|
|
3189
3112
|
if (args.graph && args.graph.length > 0) {
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
text += `
|
|
3202
|
-
${theme.fg("dim", `+${n - 3} more`)}`;
|
|
3203
|
-
}
|
|
3204
|
-
return new Text(text, 0, 0);
|
|
3113
|
+
return renderDelegatePreview(
|
|
3114
|
+
"graph",
|
|
3115
|
+
"task",
|
|
3116
|
+
args.graph.map((t) => ({
|
|
3117
|
+
label: t.label || t.id,
|
|
3118
|
+
suffix: t.dependsOn?.length
|
|
3119
|
+
? ` [depends on: ${t.dependsOn.join(", ")}]`
|
|
3120
|
+
: undefined,
|
|
3121
|
+
})),
|
|
3122
|
+
theme,
|
|
3123
|
+
);
|
|
3205
3124
|
}
|
|
3206
3125
|
|
|
3207
3126
|
// Chain mode
|
|
3208
3127
|
if (args.chain && args.chain.length > 0) {
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
text += `\n${theme.fg("muted", `${i + 1}.`)} ${theme.fg("dim", label)}`;
|
|
3216
|
-
}
|
|
3217
|
-
if (n > 3) {
|
|
3218
|
-
text += `\n${theme.fg("dim", `+${n - 3} more`)}`;
|
|
3219
|
-
}
|
|
3220
|
-
return new Text(text, 0, 0);
|
|
3128
|
+
return renderDelegatePreview(
|
|
3129
|
+
"chain",
|
|
3130
|
+
"step",
|
|
3131
|
+
args.chain.map((s) => ({ label: s.label || s.task.slice(0, 60) })),
|
|
3132
|
+
theme,
|
|
3133
|
+
);
|
|
3221
3134
|
}
|
|
3222
3135
|
|
|
3223
3136
|
// Parallel mode
|
|
3224
3137
|
if (args.tasks && args.tasks.length > 0) {
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
text += `\n${theme.fg("muted", `${i + 1}.`)} ${theme.fg("dim", label)}`;
|
|
3232
|
-
}
|
|
3233
|
-
if (n > 3) {
|
|
3234
|
-
text += `\n${theme.fg("dim", `+${n - 3} more`)}`;
|
|
3235
|
-
}
|
|
3236
|
-
return new Text(text, 0, 0);
|
|
3138
|
+
return renderDelegatePreview(
|
|
3139
|
+
"parallel",
|
|
3140
|
+
"task",
|
|
3141
|
+
args.tasks.map((t) => ({ label: t.label || t.task.slice(0, 60) })),
|
|
3142
|
+
theme,
|
|
3143
|
+
);
|
|
3237
3144
|
}
|
|
3238
3145
|
|
|
3239
3146
|
// Single mode (original)
|