brl-subagent 2.6.0 → 2.7.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 +2 -1
- package/README.md +16 -3
- package/package.json +4 -1
- package/src/dispatch-line.ts +144 -0
- package/src/history.ts +13 -1
- package/src/index.ts +542 -709
- package/src/loader.ts +178 -0
- package/src/mode-prologue.ts +169 -0
- package/src/model-availability.ts +13 -1
- package/src/params.ts +179 -62
- package/src/prelude.ts +279 -3
- package/src/presets.ts +56 -148
- package/src/project-flags.ts +58 -0
- package/src/run-registry.ts +4 -1
- package/src/schema.ts +67 -51
- package/src/session-manager.ts +790 -91
- package/src/store-permissions.ts +98 -0
- package/src/templates.ts +65 -121
- package/src/transcript.ts +5 -2
- package/src/transport-retry.ts +90 -0
- package/src/tui.ts +210 -351
- package/src/types.ts +42 -23
- package/src/validate.ts +41 -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,
|
|
@@ -466,6 +466,31 @@ 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,
|
|
@@ -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
|
|
@@ -561,23 +570,7 @@ 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(
|
|
@@ -634,23 +627,7 @@ 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(
|
|
@@ -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
|
|
|
@@ -2503,6 +2441,31 @@ function renderCollapsedText(
|
|
|
2503
2441
|
// Chain / parallel collapsed rendering
|
|
2504
2442
|
// ---------------------------------------------------------------------------
|
|
2505
2443
|
|
|
2444
|
+
/** One collapsed per-step line — shared by the chain and parallel summaries. */
|
|
2445
|
+
function renderCollapsedSubTask(
|
|
2446
|
+
r: SubTaskResult,
|
|
2447
|
+
theme: Theme,
|
|
2448
|
+
opts: { stepPrefix: boolean; emptyLabelSeparator: string },
|
|
2449
|
+
): string {
|
|
2450
|
+
const isErr = isSubagentError(r);
|
|
2451
|
+
const statusIcon = formatOutcomeSymbol(isErr ? "failure" : "success", theme);
|
|
2452
|
+
const stepNum =
|
|
2453
|
+
opts.stepPrefix && r.step !== undefined
|
|
2454
|
+
? theme.fg("muted", `${r.step}. `)
|
|
2455
|
+
: "";
|
|
2456
|
+
const label = r.label ? theme.fg("accent", r.label) : "";
|
|
2457
|
+
const output = getFinalOutput(r.messages);
|
|
2458
|
+
const preview = output.split("\n").slice(0, 2).join("\n");
|
|
2459
|
+
const sep = label ? ": " : opts.emptyLabelSeparator;
|
|
2460
|
+
let text = `\n${stepNum}${statusIcon} ${label}${sep}${theme.fg("toolOutput", preview)}`;
|
|
2461
|
+
if (r.errorMessage) {
|
|
2462
|
+
text += `\n ${theme.fg("error", r.errorMessage)}`;
|
|
2463
|
+
}
|
|
2464
|
+
const diffSummary = renderCollapsedDiffSummary(r.gitDiff, theme);
|
|
2465
|
+
if (diffSummary) text += `\n ${diffSummary}`;
|
|
2466
|
+
return text;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2506
2469
|
function renderCollapsedChain(
|
|
2507
2470
|
details: ChainDetails,
|
|
2508
2471
|
theme: Theme,
|
|
@@ -2513,21 +2476,10 @@ function renderCollapsedChain(
|
|
|
2513
2476
|
let text = `${icon} ${theme.fg("toolTitle", theme.bold("chain"))} ${theme.fg("muted", `${details.completedSteps}/${details.totalSteps} steps${stoppedEarly}`)}`;
|
|
2514
2477
|
|
|
2515
2478
|
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}`;
|
|
2479
|
+
text += renderCollapsedSubTask(r, theme, {
|
|
2480
|
+
stepPrefix: true,
|
|
2481
|
+
emptyLabelSeparator: "",
|
|
2482
|
+
});
|
|
2531
2483
|
}
|
|
2532
2484
|
|
|
2533
2485
|
text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
@@ -2542,19 +2494,10 @@ function renderCollapsedParallel(
|
|
|
2542
2494
|
let text = `${icon} ${theme.fg("toolTitle", theme.bold("parallel"))} ${theme.fg("muted", `${details.succeeded}/${details.failed}/${details.results.length} total`)}`;
|
|
2543
2495
|
|
|
2544
2496
|
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}`;
|
|
2497
|
+
text += renderCollapsedSubTask(r, theme, {
|
|
2498
|
+
stepPrefix: false,
|
|
2499
|
+
emptyLabelSeparator: " ",
|
|
2500
|
+
});
|
|
2558
2501
|
}
|
|
2559
2502
|
|
|
2560
2503
|
text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
@@ -2565,76 +2508,74 @@ function renderCollapsedParallel(
|
|
|
2565
2508
|
// Chain / parallel expanded rendering
|
|
2566
2509
|
// ---------------------------------------------------------------------------
|
|
2567
2510
|
|
|
2568
|
-
|
|
2569
|
-
|
|
2511
|
+
type AggregatedTotals = Pick<
|
|
2512
|
+
MultiSubagentDetails,
|
|
2513
|
+
"totalInput" | "totalOutput" | "totalCost" | "totalTurns"
|
|
2514
|
+
>;
|
|
2515
|
+
|
|
2516
|
+
/** Add one expanded sub-task block (result header, task, output, diff, usage). */
|
|
2517
|
+
function addExpandedSubTask(
|
|
2518
|
+
container: Container,
|
|
2519
|
+
r: SubTaskResult,
|
|
2570
2520
|
theme: Theme,
|
|
2571
2521
|
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
const
|
|
2522
|
+
opts: { stepPrefix: boolean },
|
|
2523
|
+
): void {
|
|
2524
|
+
const isErr = isSubagentError(r);
|
|
2525
|
+
const statusIcon = formatOutcomeSymbol(isErr ? "failure" : "success", theme);
|
|
2526
|
+
const stepNum =
|
|
2527
|
+
opts.stepPrefix && r.step !== undefined ? `${r.step}. ` : "";
|
|
2528
|
+
const label = r.label ? `[${r.label}] ` : "";
|
|
2575
2529
|
container.addChild(
|
|
2576
2530
|
new Text(
|
|
2577
|
-
theme.fg("
|
|
2578
|
-
theme.fg(
|
|
2579
|
-
"muted",
|
|
2580
|
-
` ${details.completedSteps}/${details.totalSteps} steps${stoppedEarly}`,
|
|
2581
|
-
),
|
|
2531
|
+
`${statusIcon} ${stepNum}${theme.fg("toolTitle", theme.bold(label))}` +
|
|
2532
|
+
(r.model ? theme.fg("muted", ` (${r.model})`) : ""),
|
|
2582
2533
|
0,
|
|
2583
2534
|
0,
|
|
2584
2535
|
),
|
|
2585
2536
|
);
|
|
2586
|
-
container.addChild(
|
|
2537
|
+
container.addChild(
|
|
2538
|
+
new Text(theme.fg("dim", `Task: ${r.task.slice(0, 200)}`), 0, 0),
|
|
2539
|
+
);
|
|
2587
2540
|
|
|
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}] ` : "";
|
|
2541
|
+
if (isErr && r.errorMessage) {
|
|
2593
2542
|
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
|
-
),
|
|
2543
|
+
new Text(theme.fg("error", `Error: ${r.errorMessage}`), 0, 0),
|
|
2600
2544
|
);
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
const output = getFinalOutput(r.messages);
|
|
2548
|
+
if (output) {
|
|
2601
2549
|
container.addChild(
|
|
2602
|
-
new Text(theme.fg("
|
|
2550
|
+
new Text(theme.fg("muted", "\u2500\u2500\u2500 Output \u2500\u2500\u2500"), 0, 0),
|
|
2603
2551
|
);
|
|
2552
|
+
container.addChild(new Markdown(output.trim(), 0, 0, mdTheme));
|
|
2553
|
+
}
|
|
2604
2554
|
|
|
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);
|
|
2555
|
+
// P5: Expanded diff section per step/task
|
|
2556
|
+
addExpandedDiffSection(container, r.gitDiff, theme);
|
|
2621
2557
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
}
|
|
2626
|
-
container.addChild(new Spacer(1));
|
|
2558
|
+
const usageStr = formatUsageStats(r.usage, r.model);
|
|
2559
|
+
if (usageStr) {
|
|
2560
|
+
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
2627
2561
|
}
|
|
2562
|
+
container.addChild(new Spacer(1));
|
|
2563
|
+
}
|
|
2628
2564
|
|
|
2629
|
-
|
|
2565
|
+
/** Add the aggregated totals line shared by every multi-task mode. */
|
|
2566
|
+
function addAggregatedTotals(
|
|
2567
|
+
container: Container,
|
|
2568
|
+
totals: AggregatedTotals,
|
|
2569
|
+
theme: Theme,
|
|
2570
|
+
): void {
|
|
2630
2571
|
const aggUsage: UsageStats = {
|
|
2631
|
-
input:
|
|
2632
|
-
output:
|
|
2572
|
+
input: totals.totalInput,
|
|
2573
|
+
output: totals.totalOutput,
|
|
2633
2574
|
cacheRead: 0,
|
|
2634
2575
|
cacheWrite: 0,
|
|
2635
|
-
cost:
|
|
2576
|
+
cost: totals.totalCost,
|
|
2636
2577
|
contextTokens: 0,
|
|
2637
|
-
turns:
|
|
2578
|
+
turns: totals.totalTurns,
|
|
2638
2579
|
};
|
|
2639
2580
|
const aggStr = formatUsageStats(aggUsage);
|
|
2640
2581
|
if (aggStr) {
|
|
@@ -2642,87 +2583,63 @@ function renderExpandedChain(
|
|
|
2642
2583
|
new Text(theme.fg("dim", `Totals: ${aggStr}`), 0, 0),
|
|
2643
2584
|
);
|
|
2644
2585
|
}
|
|
2645
|
-
|
|
2646
|
-
return container;
|
|
2647
2586
|
}
|
|
2648
2587
|
|
|
2649
|
-
|
|
2650
|
-
|
|
2588
|
+
/**
|
|
2589
|
+
* Expanded chain/parallel view. The two modes differ only in their header and
|
|
2590
|
+
* per-step labelling, both supplied by the caller.
|
|
2591
|
+
*/
|
|
2592
|
+
function renderExpandedMulti(
|
|
2593
|
+
details: MultiSubagentDetails,
|
|
2594
|
+
header: string,
|
|
2651
2595
|
theme: Theme,
|
|
2652
2596
|
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2597
|
+
opts: { stepPrefix: boolean },
|
|
2653
2598
|
): Container {
|
|
2654
2599
|
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
|
-
);
|
|
2600
|
+
container.addChild(new Text(header, 0, 0));
|
|
2666
2601
|
container.addChild(new Spacer(1));
|
|
2667
2602
|
|
|
2668
2603
|
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
|
-
}
|
|
2604
|
+
addExpandedSubTask(container, r, theme, mdTheme, opts);
|
|
2605
|
+
}
|
|
2697
2606
|
|
|
2698
|
-
|
|
2699
|
-
addExpandedDiffSection(container, r.gitDiff, theme);
|
|
2607
|
+
addAggregatedTotals(container, details, theme);
|
|
2700
2608
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
2704
|
-
}
|
|
2705
|
-
container.addChild(new Spacer(1));
|
|
2706
|
-
}
|
|
2609
|
+
return container;
|
|
2610
|
+
}
|
|
2707
2611
|
|
|
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),
|
|
2612
|
+
function renderExpandedChain(
|
|
2613
|
+
details: ChainDetails,
|
|
2614
|
+
theme: Theme,
|
|
2615
|
+
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2616
|
+
): Container {
|
|
2617
|
+
const stoppedEarly = details.stoppedEarly ? " (stopped early)" : "";
|
|
2618
|
+
const header =
|
|
2619
|
+
theme.fg("accent", theme.bold("Chain")) +
|
|
2620
|
+
theme.fg(
|
|
2621
|
+
"muted",
|
|
2622
|
+
` ${details.completedSteps}/${details.totalSteps} steps${stoppedEarly}`,
|
|
2722
2623
|
);
|
|
2723
|
-
|
|
2624
|
+
return renderExpandedMulti(details, header, theme, mdTheme, {
|
|
2625
|
+
stepPrefix: true,
|
|
2626
|
+
});
|
|
2627
|
+
}
|
|
2724
2628
|
|
|
2725
|
-
|
|
2629
|
+
function renderExpandedParallel(
|
|
2630
|
+
details: ParallelDetails,
|
|
2631
|
+
theme: Theme,
|
|
2632
|
+
mdTheme: ReturnType<typeof getMarkdownTheme>,
|
|
2633
|
+
): Container {
|
|
2634
|
+
const header =
|
|
2635
|
+
theme.fg("accent", theme.bold("Parallel")) +
|
|
2636
|
+
theme.fg(
|
|
2637
|
+
"muted",
|
|
2638
|
+
` ${details.succeeded} succeeded, ${details.failed} failed, ${details.results.length} total`,
|
|
2639
|
+
);
|
|
2640
|
+
return renderExpandedMulti(details, header, theme, mdTheme, {
|
|
2641
|
+
stepPrefix: false,
|
|
2642
|
+
});
|
|
2726
2643
|
}
|
|
2727
2644
|
|
|
2728
2645
|
// ---------------------------------------------------------------------------
|
|
@@ -3102,62 +3019,11 @@ function renderExpandedGraph(
|
|
|
3102
3019
|
);
|
|
3103
3020
|
|
|
3104
3021
|
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));
|
|
3022
|
+
addExpandedSubTask(container, r, theme, mdTheme, { stepPrefix: false });
|
|
3142
3023
|
}
|
|
3143
3024
|
}
|
|
3144
3025
|
|
|
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
|
-
}
|
|
3026
|
+
addAggregatedTotals(container, details, theme);
|
|
3161
3027
|
|
|
3162
3028
|
return container;
|
|
3163
3029
|
}
|
|
@@ -3166,74 +3032,67 @@ function renderExpandedGraph(
|
|
|
3166
3032
|
// Public rendering entry points (used by delegate_task tool)
|
|
3167
3033
|
// ---------------------------------------------------------------------------
|
|
3168
3034
|
|
|
3035
|
+
/**
|
|
3036
|
+
* Render the delegate_task call preview shared by graph / chain / parallel.
|
|
3037
|
+
* `items` are pre-resolved labels (plus an optional already-formatted suffix).
|
|
3038
|
+
*/
|
|
3039
|
+
function renderDelegatePreview(
|
|
3040
|
+
kind: string,
|
|
3041
|
+
noun: string,
|
|
3042
|
+
items: Array<{ label: string; suffix?: string }>,
|
|
3043
|
+
theme: Theme,
|
|
3044
|
+
): Text {
|
|
3045
|
+
const count = items.length;
|
|
3046
|
+
let text = `${theme.fg("accent", "delegate_task")} ${theme.fg("muted", `${kind} (${count} ${noun}${count > 1 ? "s" : ""})`)}`;
|
|
3047
|
+
const preview = items.slice(0, 3);
|
|
3048
|
+
for (let i = 0; i < preview.length; i++) {
|
|
3049
|
+
const item = preview[i];
|
|
3050
|
+
const suffix = item.suffix ? theme.fg("dim", item.suffix) : "";
|
|
3051
|
+
text += `\n${theme.fg("muted", `${i + 1}.`)} ${theme.fg("dim", item.label)}${suffix}`;
|
|
3052
|
+
}
|
|
3053
|
+
if (count > 3) {
|
|
3054
|
+
text += `\n${theme.fg("dim", `+${count - 3} more`)}`;
|
|
3055
|
+
}
|
|
3056
|
+
return new Text(text, 0, 0);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3169
3059
|
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
|
-
},
|
|
3060
|
+
args: DelegateTaskParams,
|
|
3186
3061
|
theme: Theme,
|
|
3187
3062
|
): Text {
|
|
3188
3063
|
// Graph mode
|
|
3189
3064
|
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);
|
|
3065
|
+
return renderDelegatePreview(
|
|
3066
|
+
"graph",
|
|
3067
|
+
"task",
|
|
3068
|
+
args.graph.map((t) => ({
|
|
3069
|
+
label: t.label || t.id,
|
|
3070
|
+
suffix: t.dependsOn?.length
|
|
3071
|
+
? ` [depends on: ${t.dependsOn.join(", ")}]`
|
|
3072
|
+
: undefined,
|
|
3073
|
+
})),
|
|
3074
|
+
theme,
|
|
3075
|
+
);
|
|
3205
3076
|
}
|
|
3206
3077
|
|
|
3207
3078
|
// Chain mode
|
|
3208
3079
|
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);
|
|
3080
|
+
return renderDelegatePreview(
|
|
3081
|
+
"chain",
|
|
3082
|
+
"step",
|
|
3083
|
+
args.chain.map((s) => ({ label: s.label || s.task.slice(0, 60) })),
|
|
3084
|
+
theme,
|
|
3085
|
+
);
|
|
3221
3086
|
}
|
|
3222
3087
|
|
|
3223
3088
|
// Parallel mode
|
|
3224
3089
|
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);
|
|
3090
|
+
return renderDelegatePreview(
|
|
3091
|
+
"parallel",
|
|
3092
|
+
"task",
|
|
3093
|
+
args.tasks.map((t) => ({ label: t.label || t.task.slice(0, 60) })),
|
|
3094
|
+
theme,
|
|
3095
|
+
);
|
|
3237
3096
|
}
|
|
3238
3097
|
|
|
3239
3098
|
// Single mode (original)
|