@songtonyli/dsh-cli 0.1.84 → 0.1.85
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/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-client-modules/lib/index.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-experimental-tool-agent-team/README.i18n.yaml +14 -14
- package/node_modules/@deepseek-ai/dsh-experimental-tool-agent-team/README.md +7 -7
- package/node_modules/@deepseek-ai/dsh-experimental-tool-agent-team/README.zh.md +7 -7
- package/node_modules/@deepseek-ai/dsh-experimental-tool-agent-team/lib/index.js +28 -4
- package/node_modules/@deepseek-ai/dsh-subagent/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-subagent/README.md +3 -3
- package/node_modules/@deepseek-ai/dsh-subagent/README.zh.md +3 -3
- package/node_modules/@deepseek-ai/dsh-subagent/lib/index.js +8 -5
- package/node_modules/@deepseek-ai/dsh-subagent/lib/types/child-agent.js +9 -4
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +10 -10
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +16 -11
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +16 -11
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +1938 -1409
- package/package.json +1 -1
|
@@ -172,7 +172,7 @@ const NAMED = "Esc|Enter|Tab|Space|PgUp|PgDn|Home|End";
|
|
|
172
172
|
/** One arrow, or a pair drawn as one token such as `↑↓`. */
|
|
173
173
|
const ARROWS = "[↑↓←→]{1,2}";
|
|
174
174
|
/** The single-character keys a legend names, and the `jk` pair the reader draws as one token. */
|
|
175
|
-
const CHARACTERS = String.raw`jk|[
|
|
175
|
+
const CHARACTERS = String.raw`jk|[EIqbf?/@[\]]`;
|
|
176
176
|
/** A key token starts the text or follows whitespace or an opening parenthesis. */
|
|
177
177
|
const BEFORE = String.raw`(?<=^|[\s(])`;
|
|
178
178
|
/** A key token ends the text or precedes whitespace or closing punctuation. */
|
|
@@ -211,7 +211,7 @@ const CTRL_LETTER = /^Ctrl\+([A-Z])$/u;
|
|
|
211
211
|
/** One arrow, shifted or not. */
|
|
212
212
|
const ARROW_KEY = /^(Shift\+)?([↑↓←→])$/u;
|
|
213
213
|
/** A single-character key, which sends itself. */
|
|
214
|
-
const CHARACTER_KEY = /^[
|
|
214
|
+
const CHARACTER_KEY = /^[jkEIqbf?/@[\]]$/u;
|
|
215
215
|
/** Offset between an uppercase letter's code and the control code `Ctrl` with it sends. */
|
|
216
216
|
const CONTROL_OFFSET = 64;
|
|
217
217
|
/**
|
|
@@ -523,499 +523,285 @@ function cursorTo(row) {
|
|
|
523
523
|
return `\u001b[${String(row + 1)};1H`;
|
|
524
524
|
}
|
|
525
525
|
//#endregion
|
|
526
|
-
//#region lib/types/team-
|
|
526
|
+
//#region lib/types/team-intro.js
|
|
527
527
|
/**
|
|
528
|
-
*
|
|
528
|
+
* The empty-session card that says Agent Teams is on, what it does, which
|
|
529
|
+
* commands show the team, and how to turn it off.
|
|
529
530
|
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
* teammate's transcript; this page is the exchange between them.
|
|
534
|
-
* @module @deepseek-ai/dsh-tui-app/team-play
|
|
531
|
+
* Static text: the card draws the same lines at every frame, so it needs no
|
|
532
|
+
* spinner tick and has no reduced-motion variant.
|
|
533
|
+
* @module @deepseek-ai/dsh-tui-app/team-intro
|
|
535
534
|
*/
|
|
536
|
-
/** What the start card and
|
|
537
|
-
const TEAM_ON_LINE = "Agent Teams is on
|
|
538
|
-
/**
|
|
535
|
+
/** What the start card and the header call the feature. */
|
|
536
|
+
const TEAM_ON_LINE = "Agent Teams is on";
|
|
537
|
+
/** What the lead and its teammates do, in one sentence. */
|
|
538
|
+
const TEAM_EXPLAIN_LINE = "The lead plans the work and delegates independent subtasks to teammates, each with one role.";
|
|
539
|
+
/** Disable command printed on the start card. */
|
|
539
540
|
const TEAM_OFF_COMMAND = "/plugins disable @deepseek-ai/dsh-experimental-agent-team-profile";
|
|
540
|
-
/** What the start card
|
|
541
|
-
const
|
|
542
|
-
/**
|
|
543
|
-
const
|
|
544
|
-
/**
|
|
545
|
-
|
|
546
|
-
* Three beats: the lead spawns a reviewer, asks for the diff, and gets an answer.
|
|
547
|
-
*/
|
|
548
|
-
const SHOWCASE_BEATS = [
|
|
549
|
-
{
|
|
550
|
-
from: "lead",
|
|
551
|
-
to: "reviewer",
|
|
552
|
-
kind: "spawn",
|
|
553
|
-
text: "spawn reviewer"
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
from: "lead",
|
|
557
|
-
to: "reviewer",
|
|
558
|
-
kind: "message",
|
|
559
|
-
text: "check the diff"
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
from: "reviewer",
|
|
563
|
-
to: "lead",
|
|
564
|
-
kind: "message",
|
|
565
|
-
text: "the diff is consistent"
|
|
566
|
-
}
|
|
567
|
-
];
|
|
541
|
+
/** What the start card says about turning the feature off. */
|
|
542
|
+
const TEAM_OFF_LINE = "Turn it off, then start dsh tui again:";
|
|
543
|
+
/** The commands the start card names, with what each shows. */
|
|
544
|
+
const TEAM_COMMAND_LINES = [["/team-play", "live team room: roles, current work, tasks, and messages"], ["/team", "roster and shared task board"]];
|
|
545
|
+
/** Columns the command column takes, so the summaries line up. */
|
|
546
|
+
const COMMAND_COLUMNS = 13;
|
|
568
547
|
/**
|
|
569
|
-
*
|
|
570
|
-
* @param
|
|
571
|
-
* @
|
|
572
|
-
* @returns the marker's cell, 0 at the sender.
|
|
548
|
+
* Whether `service` is the Agent Teams service this terminal can read.
|
|
549
|
+
* @param service - the value of `ctx.get('agentTeams')`, absent when the bundle is off.
|
|
550
|
+
* @returns true when the value exposes `listMembers`.
|
|
573
551
|
*/
|
|
574
|
-
function
|
|
575
|
-
|
|
576
|
-
const wrapped = (phase % 8 + 8) % 8;
|
|
577
|
-
return Math.round(wrapped / 7 * span);
|
|
552
|
+
function agentTeamsMounted(service) {
|
|
553
|
+
return typeof service === "object" && service !== null && "listMembers" in service && typeof service.listMembers === "function";
|
|
578
554
|
}
|
|
579
555
|
/**
|
|
580
|
-
* The
|
|
581
|
-
* @param
|
|
582
|
-
* @
|
|
583
|
-
* @param phase - the marker's step.
|
|
584
|
-
* @returns the three pieces.
|
|
556
|
+
* The start card's lines.
|
|
557
|
+
* @param draw - the palette and the width.
|
|
558
|
+
* @returns one line per row, each fitting `draw.width`.
|
|
585
559
|
*/
|
|
586
|
-
function
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
return
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
560
|
+
function teamIntroLines(draw) {
|
|
561
|
+
const width = Math.max(draw.width, 1);
|
|
562
|
+
const fit = (line) => truncateToWidth(line, width, "…");
|
|
563
|
+
const palette = draw.palette;
|
|
564
|
+
return [
|
|
565
|
+
fit(palette.bold(palette.accent(TEAM_ON_LINE))),
|
|
566
|
+
fit(TEAM_EXPLAIN_LINE),
|
|
567
|
+
...TEAM_COMMAND_LINES.map(([command, summary]) => fit(`${palette.accent(command.padEnd(COMMAND_COLUMNS))}${palette.dim(summary)}`)),
|
|
568
|
+
fit(palette.dim(TEAM_OFF_LINE)),
|
|
569
|
+
fit(palette.warning(TEAM_OFF_COMMAND))
|
|
570
|
+
];
|
|
595
571
|
}
|
|
596
572
|
/**
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* A tool call plays when its name is in `toolNames`, the names the Agent
|
|
600
|
-
* Teams plugin currently scopes onto this agent, or when `toolNames` is
|
|
601
|
-
* omitted and the arguments name a person or a task. Every `team/` event
|
|
602
|
-
* plays, including types a later plugin release adds. A user message plays
|
|
603
|
-
* when its source is `agent-message` or its text begins `Team message from`.
|
|
604
|
-
* Malformed tool arguments still name the tool when it is in `toolNames`.
|
|
605
|
-
* @param events - the log events, oldest first.
|
|
606
|
-
* @param speaker - the name of the session that logged the events.
|
|
607
|
-
* @param toolNames - tool names scoped by the plugin. Omitted reads exchanges from call arguments.
|
|
608
|
-
* @returns the exchanges in log order.
|
|
573
|
+
* The start card mounted in an empty root transcript while Agent Teams is on.
|
|
609
574
|
*/
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
575
|
+
var TeamIntro = class {
|
|
576
|
+
palette;
|
|
577
|
+
/**
|
|
578
|
+
* @param palette - the palette the card is styled with.
|
|
579
|
+
*/
|
|
580
|
+
constructor(palette) {
|
|
581
|
+
this.palette = palette;
|
|
615
582
|
}
|
|
616
|
-
|
|
617
|
-
|
|
583
|
+
invalidate() {}
|
|
584
|
+
/**
|
|
585
|
+
* Draw the card.
|
|
586
|
+
* @param width - the columns the card fits.
|
|
587
|
+
* @returns the card's lines.
|
|
588
|
+
*/
|
|
589
|
+
render(width) {
|
|
590
|
+
return teamIntroLines({
|
|
591
|
+
palette: this.palette,
|
|
592
|
+
width
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region lib/types/motion.js
|
|
618
598
|
/**
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
599
|
+
* Chrome motion: the brief lift a docked surface draws when the keyboard
|
|
600
|
+
* lands on it or the mark it holds moves.
|
|
601
|
+
*
|
|
602
|
+
* Pure. A motion is a clock plus a three-level intensity ramp, so nothing
|
|
603
|
+
* here queries a terminal, builds a color, or arms a timer: the application
|
|
604
|
+
* reads {@link Motion.level} and {@link Motion.progress} while it renders and
|
|
605
|
+
* drops the motion once it settles. Every motion is a {@link RegisteredFade},
|
|
606
|
+
* so it rides the one fade tick the application already arms for streamed
|
|
607
|
+
* text and disarms with it - an idle session runs no timer for motion.
|
|
608
|
+
*
|
|
609
|
+
* Two rules hold for every call site. A motion changes what a line is drawn
|
|
610
|
+
* with, never how many lines a docked component returns, because each docked
|
|
611
|
+
* row raises the renderer's repaint boundary for good (`./screen.ts`). And a
|
|
612
|
+
* settled motion draws exactly what the surface draws at rest, so a terminal
|
|
613
|
+
* that runs no motion at all - reduced motion, a disabled palette, no color -
|
|
614
|
+
* loses nothing but the lift.
|
|
615
|
+
* @module @deepseek-ai/dsh-tui-app/motion
|
|
622
616
|
*/
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
const beats = options.beats.length > 0 ? options.beats : SHOWCASE_BEATS;
|
|
628
|
-
const index = (options.beat % beats.length + beats.length) % beats.length;
|
|
629
|
-
const current = beats[index];
|
|
630
|
-
if (current === void 0) return Array.from({ length: options.rows }, () => "");
|
|
631
|
-
const notice = options.example ? "example · this session has no teammate messages yet" : `${String(beats.length)} ${beats.length === 1 ? "interaction" : "interactions"}`;
|
|
632
|
-
const legend = options.paused ? "Esc closes ← → step Space pauses paused" : "Esc closes ← → step Space pauses";
|
|
633
|
-
const lines = [
|
|
634
|
-
fit(`${palette.bold(palette.accent("team play"))} ${palette.dim(TEAM_ON_LINE)}`),
|
|
635
|
-
fit(palette.warning(TEAM_OFF_COMMAND)),
|
|
636
|
-
fit(paintKeys(palette, legend)),
|
|
637
|
-
fit(palette.dim(notice)),
|
|
638
|
-
""
|
|
639
|
-
];
|
|
640
|
-
for (const [offset, beat] of beats.entries()) {
|
|
641
|
-
if (lines.length >= options.rows - 1) break;
|
|
642
|
-
const settled = offset !== index;
|
|
643
|
-
const phase = settled ? 7 : options.phase;
|
|
644
|
-
lines.push(fit(paintLane$1(palette, beat, phase, settled)));
|
|
645
|
-
lines.push(fit(palette.dim(` ${beat.kind} ${beat.text}`)));
|
|
646
|
-
}
|
|
647
|
-
if (!lines.some((line) => line.includes(current.text)) && lines.length < options.rows) {
|
|
648
|
-
lines.push(fit(paintLane$1(palette, current, options.phase, false)));
|
|
649
|
-
lines.push(fit(palette.dim(` ${current.kind} ${current.text}`)));
|
|
650
|
-
}
|
|
651
|
-
while (lines.length < options.rows) lines.push("");
|
|
652
|
-
return lines.slice(0, options.rows);
|
|
653
|
-
}
|
|
617
|
+
/** Share of a motion drawn at its peak. */
|
|
618
|
+
const PEAK_SHARE = 1 / 3;
|
|
619
|
+
/** Share of a motion drawn lifted, the peak included. */
|
|
620
|
+
const LIFTED_SHARE = 2 / 3;
|
|
654
621
|
/**
|
|
655
|
-
*
|
|
622
|
+
* One chrome motion: how far through it the clock is, and how far above its
|
|
623
|
+
* settled drawing the surface it belongs to is drawn right now.
|
|
656
624
|
*/
|
|
657
|
-
var
|
|
625
|
+
var Motion = class {
|
|
658
626
|
options;
|
|
659
|
-
/**
|
|
660
|
-
beat = 0;
|
|
661
|
-
/** The marker's step along the current beat. */
|
|
662
|
-
phase = 0;
|
|
663
|
-
/** Whether Space has paused the play. */
|
|
664
|
-
paused = false;
|
|
665
|
-
/**
|
|
666
|
-
* @param options - the palette, the log, and whether motion is reduced.
|
|
667
|
-
*/
|
|
627
|
+
/** @param options - the start, the length, the period, and the clock. */
|
|
668
628
|
constructor(options) {
|
|
669
629
|
this.options = options;
|
|
670
630
|
}
|
|
671
|
-
/**
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
631
|
+
/**
|
|
632
|
+
* How far through the motion the clock is.
|
|
633
|
+
* @returns a fraction from 0 at the start to 1 once it has run its ticks;
|
|
634
|
+
* 1 at once for a motion with no length at all.
|
|
635
|
+
*/
|
|
636
|
+
progress() {
|
|
637
|
+
const { startedAt, ticks, stepMs, now } = this.options;
|
|
638
|
+
const span = ticks * stepMs;
|
|
639
|
+
if (span <= 0) return 1;
|
|
640
|
+
return Math.min(1, Math.max(0, (now() - startedAt) / span));
|
|
679
641
|
}
|
|
680
642
|
/**
|
|
681
|
-
*
|
|
682
|
-
* @
|
|
683
|
-
*
|
|
643
|
+
* How far above its settled drawing the surface is right now.
|
|
644
|
+
* @returns the peak for the first third of the motion, the lifted level for
|
|
645
|
+
* the second, and the settled level for the rest.
|
|
684
646
|
*/
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
const count = Math.max(this.options.beats().length, 1);
|
|
692
|
-
if (matchesKey(data, "right")) {
|
|
693
|
-
this.beat = (this.beat + 1) % count;
|
|
694
|
-
this.phase = 7;
|
|
695
|
-
this.paused = true;
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
if (matchesKey(data, "left")) {
|
|
699
|
-
this.beat = (this.beat - 1 + count) % count;
|
|
700
|
-
this.phase = 7;
|
|
701
|
-
this.paused = true;
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
647
|
+
level() {
|
|
648
|
+
const progress = this.progress();
|
|
649
|
+
if (progress < PEAK_SHARE) return 2;
|
|
650
|
+
if (progress < LIFTED_SHARE) return 1;
|
|
651
|
+
return 0;
|
|
704
652
|
}
|
|
705
653
|
/**
|
|
706
|
-
*
|
|
707
|
-
* @
|
|
708
|
-
*
|
|
709
|
-
* @returns the frame.
|
|
654
|
+
* Whether the motion still needs another repaint.
|
|
655
|
+
* @returns true until it has run its ticks; the last periods draw the
|
|
656
|
+
* settled level, which is what a reveal still grows through.
|
|
710
657
|
*/
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
return teamPlayLines({
|
|
714
|
-
palette: this.options.palette,
|
|
715
|
-
beats: beats.length > 0 ? beats : SHOWCASE_BEATS,
|
|
716
|
-
beat: this.beat,
|
|
717
|
-
phase: this.options.reducedMotion ? 7 : this.phase,
|
|
718
|
-
example: beats.length === 0 || this.options.example(),
|
|
719
|
-
paused: this.paused,
|
|
720
|
-
width,
|
|
721
|
-
rows: Math.max(rows, 1)
|
|
722
|
-
});
|
|
658
|
+
needsRepaint() {
|
|
659
|
+
return this.progress() < 1;
|
|
723
660
|
}
|
|
724
661
|
};
|
|
725
662
|
/**
|
|
726
|
-
*
|
|
727
|
-
* @param
|
|
728
|
-
* @param
|
|
729
|
-
*
|
|
663
|
+
* Lift one piece of chrome by a motion level.
|
|
664
|
+
* @param palette - the palette the lift is drawn with.
|
|
665
|
+
* @param text - the surface's own settled drawing of that piece, styling
|
|
666
|
+
* included; the settled level hands it straight back.
|
|
667
|
+
* @param level - how far above that drawing to lift it.
|
|
668
|
+
* @returns the text at the peak, lifted, or exactly as it settles.
|
|
730
669
|
*/
|
|
731
|
-
function
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
670
|
+
function pulse(palette, text, level) {
|
|
671
|
+
switch (level) {
|
|
672
|
+
case 2: return palette.bold(palette.accent(text));
|
|
673
|
+
case 1: return palette.accent(text);
|
|
674
|
+
case 0: return text;
|
|
675
|
+
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
676
|
+
default: return assertNever(level, "tui motion level");
|
|
677
|
+
}
|
|
735
678
|
}
|
|
679
|
+
/** Columns the ` ─ ` between the chip and the title takes. */
|
|
680
|
+
const CHIP_MARGIN = 3;
|
|
681
|
+
/** What opens a top rule. */
|
|
682
|
+
const TOP_LEFT = "╭";
|
|
683
|
+
/** What closes a top rule. */
|
|
684
|
+
const TOP_RIGHT = "╮";
|
|
685
|
+
/** What opens a bottom rule. */
|
|
686
|
+
const BOTTOM_LEFT = "╰";
|
|
687
|
+
/** What closes a bottom rule. */
|
|
688
|
+
const BOTTOM_RIGHT = "╯";
|
|
689
|
+
/** What opens a rule drawn between two parts of one frame. */
|
|
690
|
+
const LEGEND_LEFT = "├";
|
|
691
|
+
/** What closes a rule drawn between two parts of one frame. */
|
|
692
|
+
const LEGEND_RIGHT = "┤";
|
|
693
|
+
/** What a rule fills the width between its texts with. */
|
|
694
|
+
const FILL = "─";
|
|
695
|
+
/** The border drawn on each side of a body row. */
|
|
696
|
+
const SIDE$1 = "│";
|
|
697
|
+
/** What separates the chip from the title on a top rule. */
|
|
698
|
+
const CHIP_JOIN = ` ${FILL} `;
|
|
699
|
+
/** The mark the chip opens with, the one inverse block this surface draws. */
|
|
700
|
+
const CHIP_MARK = "●";
|
|
701
|
+
/** What ends a line the width cut short; one column, so the mark itself fits. */
|
|
702
|
+
const ELLIPSIS$5 = "…";
|
|
736
703
|
/**
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
* @param
|
|
740
|
-
* @param
|
|
741
|
-
* @returns the
|
|
704
|
+
* The chip that names the active mode: the one inverse block this surface
|
|
705
|
+
* draws, so a mode change is visible at a glance.
|
|
706
|
+
* @param palette - the palette the chip is styled with.
|
|
707
|
+
* @param text - the mode's name, as it is drawn.
|
|
708
|
+
* @returns the chip, padded by one space on each side.
|
|
742
709
|
*/
|
|
743
|
-
function
|
|
744
|
-
|
|
745
|
-
const name = typeof call?.name === "string" ? call.name : void 0;
|
|
746
|
-
if (name === void 0) return void 0;
|
|
747
|
-
const args = argumentsOf(call?.arguments);
|
|
748
|
-
const scoped = toolNames !== void 0 && toolNames.has(name);
|
|
749
|
-
const summary = summarizeCall(name, args);
|
|
750
|
-
if (!scoped && !summary.addressed) return void 0;
|
|
751
|
-
return {
|
|
752
|
-
from: speaker,
|
|
753
|
-
to: summary.to,
|
|
754
|
-
kind: summary.kind,
|
|
755
|
-
text: summary.text
|
|
756
|
-
};
|
|
710
|
+
function chip(palette, text) {
|
|
711
|
+
return palette.inverse(palette.accent(` ${CHIP_MARK} ${text} `));
|
|
757
712
|
}
|
|
758
713
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* @param name - the tool name.
|
|
764
|
-
* @param args - parsed arguments, omitted when they were not a JSON object.
|
|
765
|
-
* @returns the lane fields, and whether the arguments themselves name an exchange.
|
|
714
|
+
* Columns a rule leaves its own text.
|
|
715
|
+
* @param width - the width the rule fits.
|
|
716
|
+
* @param chipText - the chip a top rule opens with; omitted for a rule with none.
|
|
717
|
+
* @returns the columns the title, the legend, and the readout share; at least 1.
|
|
766
718
|
*/
|
|
767
|
-
function
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
const prompt = text(args?.prompt);
|
|
771
|
-
const message = text(args?.message);
|
|
772
|
-
const subject = text(args?.subject);
|
|
773
|
-
const action = text(args?.action);
|
|
774
|
-
const addressed = target !== void 0 || teammate !== void 0 || message !== void 0 || prompt !== void 0 || subject !== void 0 || action !== void 0;
|
|
775
|
-
if (subject !== void 0 || action !== void 0) {
|
|
776
|
-
const caption = subject !== void 0 && action !== void 0 ? `${action} ${subject}` : subject ?? action ?? name;
|
|
777
|
-
return {
|
|
778
|
-
addressed,
|
|
779
|
-
to: target ?? "board",
|
|
780
|
-
kind: "task",
|
|
781
|
-
text: caption
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
if (prompt !== void 0 && target === void 0) return {
|
|
785
|
-
addressed,
|
|
786
|
-
to: teammate ?? "team",
|
|
787
|
-
kind: "spawn",
|
|
788
|
-
text: prompt
|
|
789
|
-
};
|
|
790
|
-
if (message !== void 0 || target !== void 0) return {
|
|
791
|
-
addressed,
|
|
792
|
-
to: target ?? teammate ?? "team",
|
|
793
|
-
kind: "message",
|
|
794
|
-
text: message ?? name
|
|
795
|
-
};
|
|
796
|
-
const extra = args === void 0 ? void 0 : Object.entries(args).find((entry) => typeof entry[1] === "string");
|
|
797
|
-
return {
|
|
798
|
-
addressed,
|
|
799
|
-
to: "team",
|
|
800
|
-
kind: "message",
|
|
801
|
-
text: extra === void 0 ? name : `${extra[0]}: ${extra[1]}`
|
|
802
|
-
};
|
|
719
|
+
function ruleRoom(width, chipText = "") {
|
|
720
|
+
const chipColumns = chipText === "" ? 0 : visibleWidth(chipText) + CHIP_MARGIN;
|
|
721
|
+
return Math.max(1, width - 4 - chipColumns);
|
|
803
722
|
}
|
|
804
723
|
/**
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
* @param
|
|
808
|
-
* @
|
|
809
|
-
*
|
|
810
|
-
* @returns the exchange.
|
|
811
|
-
*/
|
|
812
|
-
function beatFromTeam(type, data, speaker) {
|
|
813
|
-
const label = type.slice(5);
|
|
814
|
-
const root = fields(data) ?? {};
|
|
815
|
-
const nested = fields(root.member) ?? fields(root.task) ?? fields(root.message) ?? root;
|
|
816
|
-
if (root.member !== void 0) {
|
|
817
|
-
const name = text(nested.name);
|
|
818
|
-
if (name === void 0) return {
|
|
819
|
-
from: speaker,
|
|
820
|
-
to: "team",
|
|
821
|
-
kind: "spawn",
|
|
822
|
-
text: label
|
|
823
|
-
};
|
|
824
|
-
return {
|
|
825
|
-
from: speaker,
|
|
826
|
-
to: name,
|
|
827
|
-
kind: "spawn",
|
|
828
|
-
text: text(nested.error) ?? text(nested.phase) ?? label
|
|
829
|
-
};
|
|
830
|
-
}
|
|
831
|
-
if (root.task !== void 0) {
|
|
832
|
-
const subject = text(nested.subject);
|
|
833
|
-
const status = text(nested.status);
|
|
834
|
-
return {
|
|
835
|
-
from: speaker,
|
|
836
|
-
to: "board",
|
|
837
|
-
kind: "task",
|
|
838
|
-
text: subject !== void 0 && status !== void 0 ? `${status} ${subject}` : subject ?? status ?? label
|
|
839
|
-
};
|
|
840
|
-
}
|
|
841
|
-
const who = text(nested.name) ?? text(nested.senderName) ?? text(nested.subject) ?? "team";
|
|
842
|
-
const first = Object.values(nested).find((value) => typeof value === "string" && value.trim() !== "");
|
|
843
|
-
return {
|
|
844
|
-
from: speaker,
|
|
845
|
-
to: who,
|
|
846
|
-
kind: "message",
|
|
847
|
-
text: text(nested.phase) ?? text(nested.status) ?? text(nested.message) ?? text(nested.text) ?? first ?? label
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* A received team message as an exchange aimed at `speaker`.
|
|
852
|
-
* @param data - the user-message data.
|
|
853
|
-
* @param speaker - the session that received the message.
|
|
854
|
-
* @returns the exchange, or undefined when the text is not a team message.
|
|
855
|
-
*/
|
|
856
|
-
function beatFromUser(data, speaker) {
|
|
857
|
-
const message = fields(fields(data)?.message);
|
|
858
|
-
const content = message?.content;
|
|
859
|
-
if (!Array.isArray(content)) return void 0;
|
|
860
|
-
const parts = [];
|
|
861
|
-
for (const block of content) {
|
|
862
|
-
const row = fields(block);
|
|
863
|
-
if (row?.type === "text" && typeof row.text === "string") parts.push(row.text);
|
|
864
|
-
}
|
|
865
|
-
const body = parts.join("");
|
|
866
|
-
const matched = /^Team message from ([^:]+):\s*([\s\S]*)$/u.exec(body);
|
|
867
|
-
const named = matched?.[1]?.trim();
|
|
868
|
-
const said = matched?.[2]?.trim();
|
|
869
|
-
if (named !== void 0 && named !== "" && said !== void 0 && said !== "") return {
|
|
870
|
-
from: named,
|
|
871
|
-
to: speaker,
|
|
872
|
-
kind: "message",
|
|
873
|
-
text: said
|
|
874
|
-
};
|
|
875
|
-
const source = fields(message?.source);
|
|
876
|
-
if (source?.kind === "agent-message" && body !== "") return {
|
|
877
|
-
from: text(source.senderName) ?? "teammate",
|
|
878
|
-
to: speaker,
|
|
879
|
-
kind: "message",
|
|
880
|
-
text: body
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Parse tool arguments, skipping text that is not a JSON object.
|
|
885
|
-
* @param value - the arguments string a tool call logged.
|
|
886
|
-
* @returns the object, or undefined when it is missing or not an object.
|
|
887
|
-
*/
|
|
888
|
-
function argumentsOf(value) {
|
|
889
|
-
if (typeof value !== "string") return void 0;
|
|
890
|
-
try {
|
|
891
|
-
return fields(JSON.parse(value));
|
|
892
|
-
} catch (error) {
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* A nonempty string field.
|
|
898
|
-
* @param value - the candidate.
|
|
899
|
-
* @returns the string, or undefined when it is blank or not a string.
|
|
724
|
+
* The widest legend a width can hold.
|
|
725
|
+
* @param steps - the declared steps, widest first.
|
|
726
|
+
* @param width - the columns the legend has.
|
|
727
|
+
* @returns the first step that fits, and the last step when none does — a
|
|
728
|
+
* surface that names no way back would be worse than one cut short.
|
|
900
729
|
*/
|
|
901
|
-
function
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
730
|
+
function fitLegend(steps, width) {
|
|
731
|
+
for (const step of steps) if (visibleWidth(step) <= width) return step;
|
|
732
|
+
return steps.at(-1) ?? "";
|
|
905
733
|
}
|
|
906
734
|
/**
|
|
907
|
-
*
|
|
908
|
-
* @param
|
|
909
|
-
* @
|
|
735
|
+
* One rule of a frame.
|
|
736
|
+
* @param open - the opening glyph.
|
|
737
|
+
* @param close - the closing glyph.
|
|
738
|
+
* @param parts - the texts, the width, the palette, and the tone.
|
|
739
|
+
* @param chipText - the chip the rule opens with; empty for a rule with none.
|
|
740
|
+
* @returns the line, exactly `width` columns while the closing glyph fits.
|
|
910
741
|
*/
|
|
911
|
-
function
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
742
|
+
function rule(open, close, parts, chipText) {
|
|
743
|
+
const width = Math.max(1, parts.width);
|
|
744
|
+
const { palette, level = 0 } = parts;
|
|
745
|
+
const paint = parts.tone === "focus" ? (text) => pulse(palette, palette.accent(text), level) : palette.dim;
|
|
746
|
+
const leading = [chipText, parts.left ?? ""].filter((text) => text !== "").join(paint(CHIP_JOIN));
|
|
747
|
+
const head = leading === "" ? paint(open) : `${paint(open)} ${leading} `;
|
|
748
|
+
const right = parts.right ?? "";
|
|
749
|
+
const tail = right === "" ? paint(close) : ` ${right} ${paint(close)}`;
|
|
750
|
+
const room = width - visibleWidth(tail);
|
|
751
|
+
const cut = room >= 1 ? truncateToWidth(head, room, ELLIPSIS$5) : "";
|
|
752
|
+
return truncateToWidth(`${cut}${paint(FILL.repeat(Math.max(0, width - visibleWidth(cut) - visibleWidth(tail))))}${tail}`, width, ELLIPSIS$5);
|
|
916
753
|
}
|
|
917
754
|
/**
|
|
918
|
-
*
|
|
919
|
-
*
|
|
920
|
-
*
|
|
921
|
-
* @
|
|
922
|
-
* @param phase - the marker's step.
|
|
923
|
-
* @param settled - draw the lane dim instead of coloring the names.
|
|
924
|
-
* @returns the colored lane.
|
|
755
|
+
* The rule a framed surface opens with.
|
|
756
|
+
* @param parts - the chip, the title, an optional readout, the width, the
|
|
757
|
+
* palette, and the tone.
|
|
758
|
+
* @returns the line, exactly `width` columns.
|
|
925
759
|
*/
|
|
926
|
-
function
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
760
|
+
function topRule(parts) {
|
|
761
|
+
const { chip: chipText, title, ...rest } = parts;
|
|
762
|
+
return rule(TOP_LEFT, TOP_RIGHT, {
|
|
763
|
+
...rest,
|
|
764
|
+
left: title ?? ""
|
|
765
|
+
}, chipText ?? "");
|
|
930
766
|
}
|
|
931
|
-
//#endregion
|
|
932
|
-
//#region lib/types/team-intro.js
|
|
933
767
|
/**
|
|
934
|
-
* The
|
|
935
|
-
*
|
|
936
|
-
*
|
|
937
|
-
* Pure aside from the component's frame counter. The application advances
|
|
938
|
-
* that counter on the spinner tick; reduced motion draws every beat settled.
|
|
939
|
-
* @module @deepseek-ai/dsh-tui-app/team-intro
|
|
940
|
-
*/
|
|
941
|
-
/**
|
|
942
|
-
* Whether `service` is the Agent Teams service this terminal can read.
|
|
943
|
-
* @param service - the value of `ctx.get('agentTeams')`, absent when the bundle is off.
|
|
944
|
-
* @returns true when the value exposes `listMembers`.
|
|
768
|
+
* The rule a framed surface ends with, which carries its legend.
|
|
769
|
+
* @param parts - the legend, an optional readout, the width, the palette, and the tone.
|
|
770
|
+
* @returns the line, exactly `width` columns.
|
|
945
771
|
*/
|
|
946
|
-
function
|
|
947
|
-
return
|
|
772
|
+
function bottomRule(parts) {
|
|
773
|
+
return rule(BOTTOM_LEFT, BOTTOM_RIGHT, parts, "");
|
|
948
774
|
}
|
|
949
775
|
/**
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
* @
|
|
776
|
+
* A rule drawn between two parts of one frame, for the legend of a surface
|
|
777
|
+
* that goes on below it.
|
|
778
|
+
* @param parts - the legend, an optional readout, the width, the palette, and the tone.
|
|
779
|
+
* @returns the line, exactly `width` columns.
|
|
953
780
|
*/
|
|
954
|
-
function
|
|
955
|
-
|
|
956
|
-
const fit = (line) => truncateToWidth(line, width, "…");
|
|
957
|
-
const palette = draw.palette;
|
|
958
|
-
const lines = [
|
|
959
|
-
fit(palette.bold(palette.accent(TEAM_ON_LINE))),
|
|
960
|
-
fit(palette.dim("Turn it off, then start dsh tui again:")),
|
|
961
|
-
fit(palette.warning(TEAM_OFF_COMMAND)),
|
|
962
|
-
fit(palette.dim(TEAM_PLAY_LINE)),
|
|
963
|
-
""
|
|
964
|
-
];
|
|
965
|
-
const playing = SHOWCASE_BEATS[Math.floor(draw.frame / 8) % SHOWCASE_BEATS.length] ?? SHOWCASE_BEATS[0];
|
|
966
|
-
const beats = draw.reducedMotion || playing === void 0 ? SHOWCASE_BEATS : [playing];
|
|
967
|
-
for (const beat of beats) {
|
|
968
|
-
const phase = draw.reducedMotion ? 7 : draw.frame % 8;
|
|
969
|
-
lines.push(fit(paintLane(palette, beat, phase)));
|
|
970
|
-
lines.push(fit(palette.dim(` ${beat.text}`)));
|
|
971
|
-
}
|
|
972
|
-
return lines;
|
|
781
|
+
function legendRule(parts) {
|
|
782
|
+
return rule(LEGEND_LEFT, LEGEND_RIGHT, parts, "");
|
|
973
783
|
}
|
|
974
784
|
/**
|
|
975
|
-
* One
|
|
976
|
-
*
|
|
977
|
-
* @
|
|
978
|
-
*
|
|
979
|
-
* @
|
|
785
|
+
* One row inside a frame, closed on both sides: the content is padded to the
|
|
786
|
+
* room between the borders, so a frame reads as one box however short its
|
|
787
|
+
* rows are. Content wrapped at {@link BODY_MARGIN} columns less than the width
|
|
788
|
+
* is drawn whole; anything wider is cut.
|
|
789
|
+
* @param content - the row, already styled and already wrapped.
|
|
790
|
+
* @param width - the columns the line must fit.
|
|
791
|
+
* @param palette - the palette the borders are styled with.
|
|
792
|
+
* @param tone - which role those borders take.
|
|
793
|
+
* @param level - how far above its settled drawing the borders are lifted, so
|
|
794
|
+
* the whole outline of a frame moves as one; `0` draws the settled borders.
|
|
795
|
+
* @returns the line, exactly `width` columns while both borders fit.
|
|
980
796
|
*/
|
|
981
|
-
function
|
|
982
|
-
const
|
|
983
|
-
|
|
797
|
+
function bodyLine(content, width, palette, tone, level = 0) {
|
|
798
|
+
const border = tone === "focus" ? pulse(palette, palette.accent(SIDE$1), level) : palette.dim(SIDE$1);
|
|
799
|
+
const columns = Math.max(1, width);
|
|
800
|
+
const room = columns - 4;
|
|
801
|
+
if (room < 1) return truncateToWidth(`${border} ${content}`, columns, ELLIPSIS$5);
|
|
802
|
+
const cut = truncateToWidth(content, room, ELLIPSIS$5);
|
|
803
|
+
return `${border} ${cut}${" ".repeat(Math.max(0, room - visibleWidth(cut)))} ${border}`;
|
|
984
804
|
}
|
|
985
|
-
/**
|
|
986
|
-
* The start card mounted in an empty root transcript while Agent Teams is on.
|
|
987
|
-
*/
|
|
988
|
-
var TeamIntro = class {
|
|
989
|
-
palette;
|
|
990
|
-
reducedMotion;
|
|
991
|
-
frame = 0;
|
|
992
|
-
/**
|
|
993
|
-
* @param palette - the palette the card is styled with.
|
|
994
|
-
* @param reducedMotion - draw the storyboard settled instead of stepping it.
|
|
995
|
-
*/
|
|
996
|
-
constructor(palette, reducedMotion) {
|
|
997
|
-
this.palette = palette;
|
|
998
|
-
this.reducedMotion = reducedMotion;
|
|
999
|
-
}
|
|
1000
|
-
/** Step the showcase to its next frame. A reduced-motion card stays settled. */
|
|
1001
|
-
advance() {
|
|
1002
|
-
if (!this.reducedMotion) this.frame += 1;
|
|
1003
|
-
}
|
|
1004
|
-
invalidate() {}
|
|
1005
|
-
/**
|
|
1006
|
-
* Draw the card.
|
|
1007
|
-
* @param width - the columns the card fits.
|
|
1008
|
-
* @returns the card's lines.
|
|
1009
|
-
*/
|
|
1010
|
-
render(width) {
|
|
1011
|
-
return teamIntroLines({
|
|
1012
|
-
palette: this.palette,
|
|
1013
|
-
frame: this.frame,
|
|
1014
|
-
width,
|
|
1015
|
-
reducedMotion: this.reducedMotion
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
805
|
//#endregion
|
|
1020
806
|
//#region lib/types/team.js
|
|
1021
807
|
/**
|
|
@@ -1148,6 +934,43 @@ function teamToolRows(visible, globalNames = /* @__PURE__ */ new Set()) {
|
|
|
1148
934
|
return typeof description === "string" && description !== "" ? `${tool.name} ${description}` : tool.name;
|
|
1149
935
|
}).sort((left, right) => left.localeCompare(right));
|
|
1150
936
|
}
|
|
937
|
+
/** What the lead's role reads as; the lead plans the work and delegates subtasks. */
|
|
938
|
+
const LEAD_ROLE_TEXT = "orchestrator";
|
|
939
|
+
/**
|
|
940
|
+
* The role a roster row plays, as the terminal names it.
|
|
941
|
+
* @param member - the roster row.
|
|
942
|
+
* @returns the lead's {@link LEAD_ROLE_TEXT}, a teammate's description (the responsibility
|
|
943
|
+
* the lead gave it), or `teammate` when it has none.
|
|
944
|
+
*/
|
|
945
|
+
function memberRoleText(member) {
|
|
946
|
+
if (member.role === "lead") return LEAD_ROLE_TEXT;
|
|
947
|
+
const description = member.description?.trim();
|
|
948
|
+
return description === void 0 || description === "" ? "teammate" : description;
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* A member's role on one line.
|
|
952
|
+
* @param member - the roster row.
|
|
953
|
+
* @returns {@link memberRoleText} with every run of whitespace, line breaks included, collapsed to one space.
|
|
954
|
+
*/
|
|
955
|
+
function roleOneLine(member) {
|
|
956
|
+
return memberRoleText(member).replace(/\s+/gu, " ");
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* How the activity board labels a roster member.
|
|
960
|
+
* @param member - the roster row.
|
|
961
|
+
* @returns `<name> · <role>`; the board cuts it to its own width.
|
|
962
|
+
*/
|
|
963
|
+
function memberLabel(member) {
|
|
964
|
+
return `${member.name} · ${roleOneLine(member)}`;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* What the header and the view banner call an open teammate session.
|
|
968
|
+
* @param member - the teammate's roster row.
|
|
969
|
+
* @returns `teammate <name> · <role>`, with the role cut to {@link TEAMMATE_TITLE_ROLE_COLUMNS} columns and `…`.
|
|
970
|
+
*/
|
|
971
|
+
function teammateViewTitle(member) {
|
|
972
|
+
return `teammate ${member.name} · ${truncateToWidth(roleOneLine(member), 28, "…")}`;
|
|
973
|
+
}
|
|
1151
974
|
/**
|
|
1152
975
|
* Whether `Enter` opens this member as a continuable session.
|
|
1153
976
|
* @param member - the roster row.
|
|
@@ -1171,7 +994,7 @@ function memberDescription(member) {
|
|
|
1171
994
|
* @param member - the roster row.
|
|
1172
995
|
* @returns the detail page lines.
|
|
1173
996
|
*/
|
|
1174
|
-
function memberLines(member) {
|
|
997
|
+
function memberLines$1(member) {
|
|
1175
998
|
const lines = [
|
|
1176
999
|
member.name,
|
|
1177
1000
|
member.role,
|
|
@@ -1190,7 +1013,7 @@ function memberLines(member) {
|
|
|
1190
1013
|
* @param task - the task row.
|
|
1191
1014
|
* @returns the detail page lines.
|
|
1192
1015
|
*/
|
|
1193
|
-
function taskLines(task) {
|
|
1016
|
+
function taskLines$1(task) {
|
|
1194
1017
|
return [
|
|
1195
1018
|
task.id,
|
|
1196
1019
|
String(task.revision),
|
|
@@ -1254,7 +1077,7 @@ function teamBrowseRows(members, tasks) {
|
|
|
1254
1077
|
description: memberDescription(member)
|
|
1255
1078
|
},
|
|
1256
1079
|
heading: member.name,
|
|
1257
|
-
lines: memberLines(member),
|
|
1080
|
+
lines: memberLines$1(member),
|
|
1258
1081
|
...enterable ? { choice: teammateChoice(member) } : {}
|
|
1259
1082
|
};
|
|
1260
1083
|
});
|
|
@@ -1269,821 +1092,915 @@ function teamBrowseRows(members, tasks) {
|
|
|
1269
1092
|
description: `${task.status} · ${owner} · ${readiness}`
|
|
1270
1093
|
},
|
|
1271
1094
|
heading: task.subject,
|
|
1272
|
-
lines: taskLines(task)
|
|
1095
|
+
lines: taskLines$1(task)
|
|
1273
1096
|
});
|
|
1274
1097
|
}
|
|
1275
1098
|
return rows;
|
|
1276
1099
|
}
|
|
1277
1100
|
//#endregion
|
|
1278
|
-
//#region lib/types/
|
|
1101
|
+
//#region lib/types/team-play.js
|
|
1279
1102
|
/**
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
1283
|
-
* Pure. A motion is a clock plus a three-level intensity ramp, so nothing
|
|
1284
|
-
* here queries a terminal, builds a color, or arms a timer: the application
|
|
1285
|
-
* reads {@link Motion.level} and {@link Motion.progress} while it renders and
|
|
1286
|
-
* drops the motion once it settles. Every motion is a {@link RegisteredFade},
|
|
1287
|
-
* so it rides the one fade tick the application already arms for streamed
|
|
1288
|
-
* text and disarms with it - an idle session runs no timer for motion.
|
|
1103
|
+
* The team room: one alternate-screen page that shows every member of the
|
|
1104
|
+
* Agent Team with the role it plays and what it is doing now, the shared task
|
|
1105
|
+
* board, and the exchanges the bound session logged.
|
|
1289
1106
|
*
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
* @module @deepseek-ai/dsh-tui-app/motion
|
|
1107
|
+
* The application supplies the reads on every key and frame: the roster and
|
|
1108
|
+
* the tasks from the Agent Teams service, the exchanges from the bound
|
|
1109
|
+
* session's log, and what each child last narrated. `Enter` hands the
|
|
1110
|
+
* selected teammate's session back to the application, which opens it the
|
|
1111
|
+
* way `/team` does. Pure aside from the key state of {@link TeamPlay}.
|
|
1112
|
+
* @module @deepseek-ai/dsh-tui-app/team-play
|
|
1297
1113
|
*/
|
|
1298
|
-
/** Share of a motion drawn at its peak. */
|
|
1299
|
-
const PEAK_SHARE = 1 / 3;
|
|
1300
|
-
/** Share of a motion drawn lifted, the peak included. */
|
|
1301
|
-
const LIFTED_SHARE = 2 / 3;
|
|
1302
1114
|
/**
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
1115
|
+
* The page's legend in declared degradation steps, widest first. The page
|
|
1116
|
+
* is not a focus region, so it names its keys here the way the reader does.
|
|
1305
1117
|
*/
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1118
|
+
const TEAM_PLAY_HINTS = [
|
|
1119
|
+
"↑↓ member · Enter opens · f filters messages · PgUp PgDn scroll · Esc q closes",
|
|
1120
|
+
"↑↓ member · Enter opens · f filters · PgUp PgDn scroll · Esc closes",
|
|
1121
|
+
"↑↓ member · Enter opens · f filters · Esc closes",
|
|
1122
|
+
"↑↓ · Enter · f · Esc closes",
|
|
1123
|
+
"Esc q closes"
|
|
1124
|
+
];
|
|
1125
|
+
/** Drawn under the lead while the team has no teammate. */
|
|
1126
|
+
const TEAM_PLAY_EMPTY_HINT = "No teammates yet — ask for work that splits into independent parts and the lead will delegate it.";
|
|
1127
|
+
/** Rows above the first section: the heading, then the legend or a notice. */
|
|
1128
|
+
const HEADER_ROWS = 2;
|
|
1129
|
+
/** The `Members`, `Tasks`, and `Messages` title rows. */
|
|
1130
|
+
const SECTION_TITLES = 3;
|
|
1131
|
+
/** Rows the exchanges keep while members and tasks share what is left. */
|
|
1132
|
+
const MIN_MESSAGE_ROWS = 3;
|
|
1133
|
+
/** Lines the empty-team hint wraps to at most. */
|
|
1134
|
+
const HINT_MAX_LINES = 3;
|
|
1135
|
+
/** Columns a member name keeps at most. */
|
|
1136
|
+
const NAME_MAX_COLUMNS = 16;
|
|
1137
|
+
/** Columns a member name keeps at least, so short names still line the roles up. */
|
|
1138
|
+
const NAME_MIN_COLUMNS = 4;
|
|
1139
|
+
/** Share of the row beyond the name that a role may take. */
|
|
1140
|
+
const ROLE_SHARE = .4;
|
|
1141
|
+
/** Columns an owner name keeps at most in a task row. */
|
|
1142
|
+
const OWNER_MAX_COLUMNS = 16;
|
|
1143
|
+
/** Columns a task row spends beside the id, the subject, and the owner: the indent, the glyph, and the spaces around it. */
|
|
1144
|
+
const TASK_LEAD_COLUMNS = 5;
|
|
1145
|
+
/** Columns a task subject keeps however narrow the row is. */
|
|
1146
|
+
const MIN_SUBJECT_COLUMNS = 8;
|
|
1147
|
+
/** What a task without an owner names as its owner. */
|
|
1148
|
+
const UNOWNED = "unowned";
|
|
1149
|
+
/** What a session id that the roster does not list is called in a message row. */
|
|
1150
|
+
const UNKNOWN_MEMBER = "teammate";
|
|
1151
|
+
/** The text of a peer message that has no text block. */
|
|
1152
|
+
const NON_TEXT_MESSAGE = "(non-text message)";
|
|
1153
|
+
/** Fields of a `team/` record that hold an id, which no row uses as its text. */
|
|
1154
|
+
const IDENTIFIER_FIELDS = new Set([
|
|
1155
|
+
"id",
|
|
1156
|
+
"teamId",
|
|
1157
|
+
"messageId",
|
|
1158
|
+
"senderId",
|
|
1159
|
+
"targetId",
|
|
1160
|
+
"ownerId"
|
|
1161
|
+
]);
|
|
1162
|
+
/** The marker, its space, the status glyph, and its space. */
|
|
1163
|
+
const MEMBER_LEAD_COLUMNS = 4;
|
|
1164
|
+
/** Columns between two cells of one row. */
|
|
1165
|
+
const GAP = " ";
|
|
1166
|
+
/** Glyph of each member status; a running member animates instead while motion is on. */
|
|
1167
|
+
const MEMBER_GLYPH = {
|
|
1168
|
+
running: "●",
|
|
1169
|
+
inactive: "○",
|
|
1170
|
+
provisioning: "◌",
|
|
1171
|
+
failed: "✗"
|
|
1172
|
+
};
|
|
1173
|
+
/** Glyph of each task status; a deleted task is never drawn. */
|
|
1174
|
+
const TASK_GLYPH = {
|
|
1175
|
+
pending: "○",
|
|
1176
|
+
in_progress: "◐",
|
|
1177
|
+
completed: "✓",
|
|
1178
|
+
deleted: "✗"
|
|
1179
|
+
};
|
|
1180
|
+
/**
|
|
1181
|
+
* Exchanges recorded in one session log.
|
|
1182
|
+
*
|
|
1183
|
+
* A tool call is listed when its name is in `toolNames`, the names the Agent
|
|
1184
|
+
* Teams plugin currently scopes onto this agent, or when `toolNames` is
|
|
1185
|
+
* omitted and the arguments name a person or a task. Malformed tool arguments
|
|
1186
|
+
* still name the tool when it is in `toolNames`. A user message is listed
|
|
1187
|
+
* when its source is `agent-message` or its text begins `Team message from`.
|
|
1188
|
+
*
|
|
1189
|
+
* The Team Lead's `team/` records are authoritative, so they replace the rows
|
|
1190
|
+
* the same exchange would add from tool calls and received messages:
|
|
1191
|
+
* - `team/message/queued` is one message from its sender to its target; its
|
|
1192
|
+
* text blocks, whitespace collapsed, are the text. While the log has one,
|
|
1193
|
+
* `message` rows from tool calls and user messages are dropped.
|
|
1194
|
+
* `team/message/delivered` is a receipt and adds no row.
|
|
1195
|
+
* - `team/member` adds one spawn row per member, from its first record, unless
|
|
1196
|
+
* a spawn tool call for that name already did. A `failed` phase or an `error`
|
|
1197
|
+
* adds `<member> → <speaker>` with `failed: <error>`. Later phases add nothing.
|
|
1198
|
+
* - `team/task` adds one row per revision that changes the status or the owner,
|
|
1199
|
+
* captioned `<status> <subject>` to `board` from the owner, else from `speaker`.
|
|
1200
|
+
* Identical consecutive task records collapse. While the log has one,
|
|
1201
|
+
* `task` rows from tool calls are dropped.
|
|
1202
|
+
* - Any other `team/` type, including types a later plugin release adds, is
|
|
1203
|
+
* listed with the first string field that does not hold an id.
|
|
1204
|
+
*
|
|
1205
|
+
* A teammate's own log has no `team/` records, so its tool calls and received
|
|
1206
|
+
* messages are all listed.
|
|
1207
|
+
* @param events - the log events, oldest first.
|
|
1208
|
+
* @param speaker - the name of the session that logged the events.
|
|
1209
|
+
* @param toolNames - tool names scoped by the plugin. Omitted reads exchanges from call arguments.
|
|
1210
|
+
* @param names - member names by session id. An id missing from it reads `teammate`.
|
|
1211
|
+
* @returns the exchanges in log order.
|
|
1212
|
+
*/
|
|
1213
|
+
function beatsFromEvents(events, speaker, toolNames, names = /* @__PURE__ */ new Map()) {
|
|
1214
|
+
const calls = events.map((event) => event.type === "tool/call" ? beatFromCall(event.data, speaker, toolNames) : void 0);
|
|
1215
|
+
const spawnCalls = /* @__PURE__ */ new Set();
|
|
1216
|
+
for (const call of calls) if (call?.kind === "spawn") spawnCalls.add(call.to);
|
|
1217
|
+
const reading = {
|
|
1218
|
+
speaker,
|
|
1219
|
+
names,
|
|
1220
|
+
spawnCalls,
|
|
1221
|
+
peersRecorded: events.some((event) => event.type === "team/message/queued"),
|
|
1222
|
+
tasksRecorded: events.some((event) => event.type === "team/task"),
|
|
1223
|
+
members: /* @__PURE__ */ new Set(),
|
|
1224
|
+
taskStages: /* @__PURE__ */ new Map()
|
|
1225
|
+
};
|
|
1226
|
+
const beats = [];
|
|
1227
|
+
for (const [index, event] of events.entries()) for (const beat of beatsFromEvent(event, calls[index], reading)) {
|
|
1228
|
+
if (event.type === "team/task" && sameRow(beats.at(-1), beat)) continue;
|
|
1229
|
+
beats.push(beat);
|
|
1230
|
+
}
|
|
1231
|
+
return beats;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Draw the team room.
|
|
1235
|
+
*
|
|
1236
|
+
* Rows go to the heading and the legend first. Members and tasks keep what
|
|
1237
|
+
* they need up to {@link TEAM_PLAY_MAX_MEMBERS} and {@link TEAM_PLAY_MAX_TASKS}
|
|
1238
|
+
* rows, giving way to the exchanges, which keep at least a few rows and take
|
|
1239
|
+
* everything that is left. A section cut short ends in `+<n> more`; the
|
|
1240
|
+
* member list scrolls to keep the selected member in view.
|
|
1241
|
+
* @param draw - the reads, the key state, and the screen size.
|
|
1242
|
+
* @returns the lines, the clamped scroll offset, and the page size.
|
|
1243
|
+
*/
|
|
1244
|
+
function teamRoomFrame(draw) {
|
|
1245
|
+
const width = Math.max(draw.width, 1);
|
|
1246
|
+
const rows = Math.max(draw.rows, 1);
|
|
1247
|
+
const { palette, source } = draw;
|
|
1248
|
+
const fit = (line) => truncateToWidth(line, width, "…");
|
|
1249
|
+
const tasks = source.tasks.filter((task) => task.status !== "deleted");
|
|
1250
|
+
const selectedIndex = Math.max(source.members.findIndex((member) => member.id === draw.selected), 0);
|
|
1251
|
+
const selected = source.members[selectedIndex];
|
|
1252
|
+
const hint = source.members.some((member) => member.role === "teammate") ? [] : wrapTextWithAnsi(TEAM_PLAY_EMPTY_HINT, Math.max(width - 2, 1)).slice(0, HINT_MAX_LINES);
|
|
1253
|
+
const room = Math.max(rows - HEADER_ROWS, 0) - SECTION_TITLES - MIN_MESSAGE_ROWS - hint.length;
|
|
1254
|
+
const wantedMembers = Math.min(source.members.length, 8);
|
|
1255
|
+
const wantedTasks = Math.min(Math.max(tasks.length, 1), 8);
|
|
1256
|
+
const taskRows = clamp$1(room - wantedMembers, Math.min(wantedTasks, 2), wantedTasks);
|
|
1257
|
+
const memberRows = clamp$1(room - taskRows, Math.min(wantedMembers, 2), wantedMembers);
|
|
1258
|
+
const members = memberLines(draw, source.members, selectedIndex, memberRows);
|
|
1259
|
+
const lines = [
|
|
1260
|
+
fit(heading$1(palette, source.members, tasks)),
|
|
1261
|
+
fit(draw.notice === void 0 ? paintKeys(palette, fitLegend(TEAM_PLAY_HINTS, width)) : palette.warning(draw.notice)),
|
|
1262
|
+
fit(palette.heading("Members")),
|
|
1263
|
+
...members.lines.map(fit),
|
|
1264
|
+
...hint.map((line) => fit(palette.dim(` ${line}`))),
|
|
1265
|
+
fit(palette.heading("Tasks")),
|
|
1266
|
+
...taskLines(palette, tasks, taskRows, width).map(fit)
|
|
1267
|
+
];
|
|
1268
|
+
const focus = draw.filtered ? selected : void 0;
|
|
1269
|
+
const shown = focus === void 0 ? source.beats : source.beats.filter((beat) => involves(beat, focus.name));
|
|
1270
|
+
const messageRows = Math.max(rows - lines.length - 1, 0);
|
|
1271
|
+
const back = clamp$1(draw.back, 0, Math.max(shown.length - messageRows, 0));
|
|
1272
|
+
const end = shown.length - back;
|
|
1273
|
+
const start = Math.max(end - messageRows, 0);
|
|
1274
|
+
lines.push(fit(messagesTitle(palette, shown.length, {
|
|
1275
|
+
focus: focus?.name,
|
|
1276
|
+
earlier: start,
|
|
1277
|
+
later: back
|
|
1278
|
+
})));
|
|
1279
|
+
if (shown.length === 0) {
|
|
1280
|
+
const empty = focus === void 0 ? "No messages yet." : `No exchanges with ${focus.name} yet.`;
|
|
1281
|
+
lines.push(fit(palette.dim(` ${empty}`)));
|
|
1282
|
+
}
|
|
1283
|
+
for (const beat of shown.slice(start, end)) lines.push(fit(beatLine(palette, beat)));
|
|
1284
|
+
while (lines.length < rows) lines.push("");
|
|
1285
|
+
return {
|
|
1286
|
+
lines: lines.slice(0, rows),
|
|
1287
|
+
back,
|
|
1288
|
+
page: Math.max(messageRows - 1, 1),
|
|
1289
|
+
animated: members.animated
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* The page that shows the team on the alternate screen.
|
|
1294
|
+
*/
|
|
1295
|
+
var TeamPlay = class {
|
|
1296
|
+
options;
|
|
1297
|
+
selected;
|
|
1298
|
+
filtered = false;
|
|
1299
|
+
back = 0;
|
|
1300
|
+
page = 1;
|
|
1301
|
+
animated = false;
|
|
1302
|
+
notice;
|
|
1303
|
+
/**
|
|
1304
|
+
* @param options - the palette and the reads the application supplies.
|
|
1327
1305
|
*/
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
if (progress < PEAK_SHARE) return 2;
|
|
1331
|
-
if (progress < LIFTED_SHARE) return 1;
|
|
1332
|
-
return 0;
|
|
1306
|
+
constructor(options) {
|
|
1307
|
+
this.options = options;
|
|
1333
1308
|
}
|
|
1334
1309
|
/**
|
|
1335
|
-
* Whether the
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
1310
|
+
* Whether the last frame drew a spinner, so the application keeps its tick
|
|
1311
|
+
* running only while a member works.
|
|
1312
|
+
* @returns true while a running member animates.
|
|
1338
1313
|
*/
|
|
1339
|
-
|
|
1340
|
-
return this.
|
|
1314
|
+
animates() {
|
|
1315
|
+
return this.animated;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Answer one key. Any key takes down the notice the previous key raised.
|
|
1319
|
+
* @param data - the raw key bytes.
|
|
1320
|
+
* @returns what the application should do, or undefined when the page handled the key itself.
|
|
1321
|
+
*/
|
|
1322
|
+
handleInput(data) {
|
|
1323
|
+
this.notice = void 0;
|
|
1324
|
+
if (matchesKey(data, "escape") || data === "q") return { kind: "close" };
|
|
1325
|
+
if (data === "f") {
|
|
1326
|
+
this.filtered = !this.filtered;
|
|
1327
|
+
this.back = 0;
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
if (matchesKey(data, "pageUp")) {
|
|
1331
|
+
this.back += this.page;
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
if (matchesKey(data, "pageDown")) {
|
|
1335
|
+
this.back = Math.max(this.back - this.page, 0);
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
const step = matchesKey(data, "up") ? -1 : matchesKey(data, "down") ? 1 : 0;
|
|
1339
|
+
if (step !== 0) {
|
|
1340
|
+
this.select(step);
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
return matchesKey(data, "enter") ? this.open() : void 0;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Draw the page.
|
|
1347
|
+
* @param width - the terminal columns.
|
|
1348
|
+
* @param rows - the terminal rows; the page returns this many lines.
|
|
1349
|
+
* @returns the frame.
|
|
1350
|
+
*/
|
|
1351
|
+
render(width, rows) {
|
|
1352
|
+
const frame = teamRoomFrame({
|
|
1353
|
+
palette: this.options.palette,
|
|
1354
|
+
source: this.options.source(),
|
|
1355
|
+
selected: this.selected,
|
|
1356
|
+
filtered: this.filtered,
|
|
1357
|
+
back: this.back,
|
|
1358
|
+
notice: this.notice,
|
|
1359
|
+
width,
|
|
1360
|
+
rows
|
|
1361
|
+
});
|
|
1362
|
+
this.back = frame.back;
|
|
1363
|
+
this.page = frame.page;
|
|
1364
|
+
this.animated = frame.animated;
|
|
1365
|
+
return frame.lines;
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Move the selection and show the exchanges from the newest again.
|
|
1369
|
+
* @param step - -1 for the member above, 1 for the member below.
|
|
1370
|
+
*/
|
|
1371
|
+
select(step) {
|
|
1372
|
+
const members = this.options.source().members;
|
|
1373
|
+
const index = Math.max(members.findIndex((member) => member.id === this.selected), 0);
|
|
1374
|
+
this.selected = members[clamp$1(index + step, 0, members.length - 1)]?.id;
|
|
1375
|
+
this.back = 0;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Open the selected member as `/team` does, or say why nothing opens.
|
|
1379
|
+
* @returns the open action for a running or inactive teammate, otherwise undefined with the notice raised.
|
|
1380
|
+
*/
|
|
1381
|
+
open() {
|
|
1382
|
+
const members = this.options.source().members;
|
|
1383
|
+
const member = members.find((candidate) => candidate.id === this.selected) ?? members[0];
|
|
1384
|
+
if (member === void 0) return void 0;
|
|
1385
|
+
const entry = teamBrowseRows([member], [])[0];
|
|
1386
|
+
if (entry?.choice !== void 0) return {
|
|
1387
|
+
kind: "open",
|
|
1388
|
+
entry,
|
|
1389
|
+
choice: entry.choice
|
|
1390
|
+
};
|
|
1391
|
+
this.notice = unopenable(member);
|
|
1341
1392
|
}
|
|
1342
1393
|
};
|
|
1343
1394
|
/**
|
|
1344
|
-
*
|
|
1345
|
-
* @param
|
|
1346
|
-
* @
|
|
1347
|
-
* included; the settled level hands it straight back.
|
|
1348
|
-
* @param level - how far above that drawing to lift it.
|
|
1349
|
-
* @returns the text at the peak, lifted, or exactly as it settles.
|
|
1395
|
+
* Why `Enter` opens no session for a member.
|
|
1396
|
+
* @param member - the lead, a provisioning member, or a failed member.
|
|
1397
|
+
* @returns the one-line notice.
|
|
1350
1398
|
*/
|
|
1351
|
-
function
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
case 1: return palette.accent(text);
|
|
1355
|
-
case 0: return text;
|
|
1356
|
-
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
1357
|
-
default: return assertNever(level, "tui motion level");
|
|
1358
|
-
}
|
|
1399
|
+
function unopenable(member) {
|
|
1400
|
+
if (member.role === "lead") return "the lead has no teammate session to open";
|
|
1401
|
+
return member.status === "provisioning" ? `${member.name} is still being created` : `${member.name} failed to start; /team lists its diagnostics`;
|
|
1359
1402
|
}
|
|
1360
|
-
/** Columns the ` ─ ` between the chip and the title takes. */
|
|
1361
|
-
const CHIP_MARGIN = 3;
|
|
1362
|
-
/** What opens a top rule. */
|
|
1363
|
-
const TOP_LEFT = "╭";
|
|
1364
|
-
/** What closes a top rule. */
|
|
1365
|
-
const TOP_RIGHT = "╮";
|
|
1366
|
-
/** What opens a bottom rule. */
|
|
1367
|
-
const BOTTOM_LEFT = "╰";
|
|
1368
|
-
/** What closes a bottom rule. */
|
|
1369
|
-
const BOTTOM_RIGHT = "╯";
|
|
1370
|
-
/** What opens a rule drawn between two parts of one frame. */
|
|
1371
|
-
const LEGEND_LEFT = "├";
|
|
1372
|
-
/** What closes a rule drawn between two parts of one frame. */
|
|
1373
|
-
const LEGEND_RIGHT = "┤";
|
|
1374
|
-
/** What a rule fills the width between its texts with. */
|
|
1375
|
-
const FILL = "─";
|
|
1376
|
-
/** The border drawn on each side of a body row. */
|
|
1377
|
-
const SIDE$1 = "│";
|
|
1378
|
-
/** What separates the chip from the title on a top rule. */
|
|
1379
|
-
const CHIP_JOIN = ` ${FILL} `;
|
|
1380
|
-
/** The mark the chip opens with, the one inverse block this surface draws. */
|
|
1381
|
-
const CHIP_MARK = "●";
|
|
1382
|
-
/** What ends a line the width cut short; one column, so the mark itself fits. */
|
|
1383
|
-
const ELLIPSIS$5 = "…";
|
|
1384
1403
|
/**
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
* @param
|
|
1388
|
-
* @param
|
|
1389
|
-
* @returns
|
|
1404
|
+
* Keep a number inside a range.
|
|
1405
|
+
* @param value - the number.
|
|
1406
|
+
* @param low - the smallest allowed value.
|
|
1407
|
+
* @param high - the largest allowed value; a range that ends below `low` yields `high`.
|
|
1408
|
+
* @returns `value` limited to the range.
|
|
1390
1409
|
*/
|
|
1391
|
-
function
|
|
1392
|
-
return
|
|
1410
|
+
function clamp$1(value, low, high) {
|
|
1411
|
+
return Math.min(Math.max(value, low), high);
|
|
1393
1412
|
}
|
|
1394
1413
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
* @param
|
|
1397
|
-
* @param
|
|
1398
|
-
* @
|
|
1414
|
+
* The heading row: the page name and the team's counts.
|
|
1415
|
+
* @param palette - the palette.
|
|
1416
|
+
* @param members - the roster.
|
|
1417
|
+
* @param tasks - the tasks that are not deleted.
|
|
1418
|
+
* @returns `team play · <n> teammates · <n> working · tasks <done>/<total> done`.
|
|
1419
|
+
*/
|
|
1420
|
+
function heading$1(palette, members, tasks) {
|
|
1421
|
+
const teammates = members.filter((member) => member.role === "teammate");
|
|
1422
|
+
const working = teammates.filter((member) => member.status === "running").length;
|
|
1423
|
+
const done = tasks.filter((task) => task.status === "completed").length;
|
|
1424
|
+
const counts = [
|
|
1425
|
+
`${String(teammates.length)} ${teammates.length === 1 ? "teammate" : "teammates"}`,
|
|
1426
|
+
`${String(working)} working`,
|
|
1427
|
+
`tasks ${String(done)}/${String(tasks.length)} done`
|
|
1428
|
+
].join(" · ");
|
|
1429
|
+
return `${palette.bold(palette.accent("team play"))} ${palette.dim(`· ${counts}`)}`;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* The member rows of one frame.
|
|
1433
|
+
* @param draw - the frame being drawn.
|
|
1434
|
+
* @param members - the roster.
|
|
1435
|
+
* @param selectedIndex - the selected row.
|
|
1436
|
+
* @param allowed - rows the section may take, the `+<n> more` row included.
|
|
1437
|
+
* @returns the lines and whether a running member drew a spinner frame.
|
|
1438
|
+
*/
|
|
1439
|
+
function memberLines(draw, members, selectedIndex, allowed) {
|
|
1440
|
+
const { palette, source } = draw;
|
|
1441
|
+
const view = rowWindow(members.length, allowed, selectedIndex);
|
|
1442
|
+
const names = members.map((member) => visibleWidth(member.name));
|
|
1443
|
+
const nameWidth = clamp$1(Math.max(...names, 0), NAME_MIN_COLUMNS, NAME_MAX_COLUMNS);
|
|
1444
|
+
const rest = Math.max(draw.width - MEMBER_LEAD_COLUMNS - nameWidth - 2, 0);
|
|
1445
|
+
const roles = members.map((member) => visibleWidth(memberRoleText(member)));
|
|
1446
|
+
const roleWidth = Math.min(Math.max(...roles, 0), Math.floor(rest * ROLE_SHARE));
|
|
1447
|
+
let animated = false;
|
|
1448
|
+
const lines = [];
|
|
1449
|
+
for (const [offset, member] of members.slice(view.start, view.start + view.count).entries()) {
|
|
1450
|
+
const index = view.start + offset;
|
|
1451
|
+
const frame = member.status === "running" ? source.spinner(index) : void 0;
|
|
1452
|
+
if (frame !== void 0) animated = true;
|
|
1453
|
+
const work = currentWork(member, source);
|
|
1454
|
+
const name = truncateToWidth(member.name, nameWidth, "…", true);
|
|
1455
|
+
const picked = index === selectedIndex;
|
|
1456
|
+
lines.push([
|
|
1457
|
+
picked ? palette.accent("▸") : " ",
|
|
1458
|
+
" ",
|
|
1459
|
+
paintStatus(palette, member.status, frame ?? MEMBER_GLYPH[member.status]),
|
|
1460
|
+
" ",
|
|
1461
|
+
picked ? palette.bold(palette.accent(name)) : palette.bold(name),
|
|
1462
|
+
GAP,
|
|
1463
|
+
palette.dim(truncateToWidth(memberRoleText(member), roleWidth, "…", true)),
|
|
1464
|
+
GAP,
|
|
1465
|
+
work.task ? work.text : palette.dim(work.text)
|
|
1466
|
+
].join(""));
|
|
1467
|
+
}
|
|
1468
|
+
if (view.hidden > 0) lines.push(palette.dim(` +${String(view.hidden)} more`));
|
|
1469
|
+
return {
|
|
1470
|
+
lines,
|
|
1471
|
+
animated
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* What a member is doing: the subject of the in-progress task it owns, else
|
|
1476
|
+
* its last narration, else its status word.
|
|
1477
|
+
* @param member - the roster row.
|
|
1478
|
+
* @param source - the reads of this frame.
|
|
1479
|
+
* @returns the text, and whether it is a task subject.
|
|
1480
|
+
*/
|
|
1481
|
+
function currentWork(member, source) {
|
|
1482
|
+
const owned = source.tasks.find((task) => task.status === "in_progress" && task.ownerName === member.name);
|
|
1483
|
+
if (owned !== void 0) return {
|
|
1484
|
+
text: owned.subject,
|
|
1485
|
+
task: true
|
|
1486
|
+
};
|
|
1487
|
+
const note = source.note(member.id);
|
|
1488
|
+
return {
|
|
1489
|
+
text: note === void 0 || note === "" ? member.status : note,
|
|
1490
|
+
task: false
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Color a member's status glyph.
|
|
1495
|
+
* @param palette - the palette.
|
|
1496
|
+
* @param status - the member's status.
|
|
1497
|
+
* @param glyph - the glyph to draw, the current spinner frame for a running member.
|
|
1498
|
+
* @returns the colored glyph.
|
|
1399
1499
|
*/
|
|
1400
|
-
function
|
|
1401
|
-
|
|
1402
|
-
|
|
1500
|
+
function paintStatus(palette, status, glyph) {
|
|
1501
|
+
if (status === "running") return palette.warning(glyph);
|
|
1502
|
+
if (status === "failed") return palette.error(glyph);
|
|
1503
|
+
return palette.dim(glyph);
|
|
1403
1504
|
}
|
|
1404
1505
|
/**
|
|
1405
|
-
* The
|
|
1406
|
-
* @param
|
|
1407
|
-
* @param
|
|
1408
|
-
* @
|
|
1409
|
-
*
|
|
1506
|
+
* The task rows of one frame.
|
|
1507
|
+
* @param palette - the palette.
|
|
1508
|
+
* @param tasks - the tasks that are not deleted.
|
|
1509
|
+
* @param allowed - rows the section may take, the `+<n> more` row included.
|
|
1510
|
+
* @param width - the columns the rows fit.
|
|
1511
|
+
* @returns the lines, or one placeholder line when there is no task.
|
|
1512
|
+
*/
|
|
1513
|
+
function taskLines(palette, tasks, allowed, width) {
|
|
1514
|
+
if (tasks.length === 0) return [palette.dim(" No tasks yet.")];
|
|
1515
|
+
const view = rowWindow(tasks.length, allowed, 0);
|
|
1516
|
+
const shown = tasks.slice(view.start, view.start + view.count);
|
|
1517
|
+
const blockers = shown.map((task) => task.blockedBy.length === 0 ? "" : `blocked by ${task.blockedBy.map((id) => `#${id}`).join(", ")}`);
|
|
1518
|
+
const idWidth = Math.max(...shown.map((task) => visibleWidth(`#${task.id}`)));
|
|
1519
|
+
const ownerWidth = Math.min(Math.max(...shown.map((task) => visibleWidth(task.ownerName ?? UNOWNED))), OWNER_MAX_COLUMNS);
|
|
1520
|
+
const blockedWidth = Math.max(...blockers.map((text) => text === "" ? 0 : 2 + visibleWidth(text)));
|
|
1521
|
+
const subjectRoom = Math.max(width - TASK_LEAD_COLUMNS - idWidth - 2 - ownerWidth - blockedWidth, MIN_SUBJECT_COLUMNS);
|
|
1522
|
+
const subjectWidth = Math.min(Math.max(...shown.map((task) => visibleWidth(task.subject))), subjectRoom);
|
|
1523
|
+
const lines = shown.map((task, index) => {
|
|
1524
|
+
const blocked = blockers[index];
|
|
1525
|
+
const owner = truncateToWidth(task.ownerName ?? UNOWNED, ownerWidth, "…", blocked !== "");
|
|
1526
|
+
const subject = truncateToWidth(task.subject, subjectWidth, "…", true);
|
|
1527
|
+
return [
|
|
1528
|
+
" ",
|
|
1529
|
+
palette.dim(truncateToWidth(`#${task.id}`, idWidth, "…", true)),
|
|
1530
|
+
" ",
|
|
1531
|
+
paintTaskGlyph(palette, task.status),
|
|
1532
|
+
" ",
|
|
1533
|
+
task.status === "completed" ? palette.dim(subject) : subject,
|
|
1534
|
+
GAP,
|
|
1535
|
+
palette.dim(owner),
|
|
1536
|
+
blocked === "" ? "" : `${GAP}${palette.warning(blocked)}`
|
|
1537
|
+
].join("");
|
|
1538
|
+
});
|
|
1539
|
+
if (view.hidden > 0) lines.push(palette.dim(` +${String(view.hidden)} more`));
|
|
1540
|
+
return lines;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Color a task's status glyph.
|
|
1544
|
+
* @param palette - the palette.
|
|
1545
|
+
* @param status - the task's status.
|
|
1546
|
+
* @returns the colored glyph.
|
|
1410
1547
|
*/
|
|
1411
|
-
function
|
|
1412
|
-
|
|
1413
|
-
|
|
1548
|
+
function paintTaskGlyph(palette, status) {
|
|
1549
|
+
const glyph = TASK_GLYPH[status];
|
|
1550
|
+
if (status === "completed") return palette.success(glyph);
|
|
1551
|
+
if (status === "in_progress") return palette.warning(glyph);
|
|
1552
|
+
return palette.dim(glyph);
|
|
1414
1553
|
}
|
|
1415
1554
|
/**
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1420
|
-
* @param
|
|
1421
|
-
* @
|
|
1555
|
+
* The slice of a list one section shows.
|
|
1556
|
+
*
|
|
1557
|
+
* A list that fits shows every item. A longer list shows `allowed - 1` items
|
|
1558
|
+
* around the selection and gives the last row to the `+<n> more` count.
|
|
1559
|
+
* @param total - items in the list.
|
|
1560
|
+
* @param allowed - rows the section may take.
|
|
1561
|
+
* @param selected - the item to keep in view.
|
|
1562
|
+
* @returns the first shown index, how many are shown, and how many the rows leave out.
|
|
1563
|
+
*/
|
|
1564
|
+
function rowWindow(total, allowed, selected) {
|
|
1565
|
+
if (total <= allowed) return {
|
|
1566
|
+
start: 0,
|
|
1567
|
+
count: total,
|
|
1568
|
+
hidden: 0
|
|
1569
|
+
};
|
|
1570
|
+
const count = Math.max(allowed - 1, 1);
|
|
1571
|
+
return {
|
|
1572
|
+
start: clamp$1(selected - Math.floor(count / 2), 0, total - count),
|
|
1573
|
+
count,
|
|
1574
|
+
hidden: total - count
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Whether an exchange has a member on either end.
|
|
1579
|
+
* @param beat - the exchange.
|
|
1580
|
+
* @param name - the member's name.
|
|
1581
|
+
* @returns true when the sender or the receiver is `name`, ignoring case.
|
|
1422
1582
|
*/
|
|
1423
|
-
function
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
const paint = parts.tone === "focus" ? (text) => pulse(palette, palette.accent(text), level) : palette.dim;
|
|
1427
|
-
const leading = [chipText, parts.left ?? ""].filter((text) => text !== "").join(paint(CHIP_JOIN));
|
|
1428
|
-
const head = leading === "" ? paint(open) : `${paint(open)} ${leading} `;
|
|
1429
|
-
const right = parts.right ?? "";
|
|
1430
|
-
const tail = right === "" ? paint(close) : ` ${right} ${paint(close)}`;
|
|
1431
|
-
const room = width - visibleWidth(tail);
|
|
1432
|
-
const cut = room >= 1 ? truncateToWidth(head, room, ELLIPSIS$5) : "";
|
|
1433
|
-
return truncateToWidth(`${cut}${paint(FILL.repeat(Math.max(0, width - visibleWidth(cut) - visibleWidth(tail))))}${tail}`, width, ELLIPSIS$5);
|
|
1583
|
+
function involves(beat, name) {
|
|
1584
|
+
const wanted = name.toLowerCase();
|
|
1585
|
+
return beat.from.toLowerCase() === wanted || beat.to.toLowerCase() === wanted;
|
|
1434
1586
|
}
|
|
1435
1587
|
/**
|
|
1436
|
-
* The
|
|
1437
|
-
* @param
|
|
1438
|
-
*
|
|
1439
|
-
* @
|
|
1588
|
+
* The `Messages` title with its counts.
|
|
1589
|
+
* @param palette - the palette.
|
|
1590
|
+
* @param total - exchanges after any filter.
|
|
1591
|
+
* @param place - the member the list is narrowed to, and how many exchanges lie above and below the view.
|
|
1592
|
+
* @returns the title row.
|
|
1440
1593
|
*/
|
|
1441
|
-
function
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
}
|
|
1594
|
+
function messagesTitle(palette, total, place) {
|
|
1595
|
+
const facts = [String(total)];
|
|
1596
|
+
if (place.focus !== void 0) facts.unshift(`with ${place.focus}`);
|
|
1597
|
+
if (place.earlier > 0) facts.push(`${String(place.earlier)} earlier`);
|
|
1598
|
+
if (place.later > 0) facts.push(`${String(place.later)} later`);
|
|
1599
|
+
return `${palette.heading("Messages")} ${palette.dim(`· ${facts.join(" · ")}`)}`;
|
|
1447
1600
|
}
|
|
1448
1601
|
/**
|
|
1449
|
-
*
|
|
1450
|
-
* @param
|
|
1451
|
-
* @
|
|
1602
|
+
* One exchange as a single line.
|
|
1603
|
+
* @param palette - the palette.
|
|
1604
|
+
* @param beat - the exchange.
|
|
1605
|
+
* @returns `<from> → <to> <kind>: <text>` with the text on one line.
|
|
1452
1606
|
*/
|
|
1453
|
-
function
|
|
1454
|
-
|
|
1607
|
+
function beatLine(palette, beat) {
|
|
1608
|
+
const text = beat.text.replace(/\s+/gu, " ");
|
|
1609
|
+
return ` ${palette.accent(beat.from)} ${palette.dim("→")} ${palette.success(beat.to)}${GAP}${palette.dim(`${beat.kind}:`)} ${text}`;
|
|
1455
1610
|
}
|
|
1456
1611
|
/**
|
|
1457
|
-
*
|
|
1458
|
-
*
|
|
1459
|
-
* @param
|
|
1460
|
-
* @
|
|
1612
|
+
* The rows one event adds.
|
|
1613
|
+
* @param event - the log event.
|
|
1614
|
+
* @param call - the row `event` adds as a tool call, if any.
|
|
1615
|
+
* @param reading - the log-wide facts and the state of the pass.
|
|
1616
|
+
* @returns no row for an event that is not an exchange or that a `team/` record already lists.
|
|
1461
1617
|
*/
|
|
1462
|
-
function
|
|
1463
|
-
return
|
|
1618
|
+
function beatsFromEvent(event, call, reading) {
|
|
1619
|
+
if (event.type === "tool/call") return call === void 0 || supersededCall(call, reading) ? [] : [call];
|
|
1620
|
+
if (event.type.startsWith("team/")) return beatsFromTeam(event.type, event.data, reading);
|
|
1621
|
+
if (event.type !== "user/message" || reading.peersRecorded) return [];
|
|
1622
|
+
const received = beatFromUser(event.data, reading.speaker);
|
|
1623
|
+
return received === void 0 ? [] : [received];
|
|
1464
1624
|
}
|
|
1465
1625
|
/**
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
* @param content - the row, already styled and already wrapped.
|
|
1471
|
-
* @param width - the columns the line must fit.
|
|
1472
|
-
* @param palette - the palette the borders are styled with.
|
|
1473
|
-
* @param tone - which role those borders take.
|
|
1474
|
-
* @param level - how far above its settled drawing the borders are lifted, so
|
|
1475
|
-
* the whole outline of a frame moves as one; `0` draws the settled borders.
|
|
1476
|
-
* @returns the line, exactly `width` columns while both borders fit.
|
|
1626
|
+
* Whether the log's `team/` records list the exchange a tool call made.
|
|
1627
|
+
* @param call - the row the call adds.
|
|
1628
|
+
* @param reading - the log-wide facts.
|
|
1629
|
+
* @returns true for a message or task call while the matching record type is in the log.
|
|
1477
1630
|
*/
|
|
1478
|
-
function
|
|
1479
|
-
|
|
1480
|
-
const columns = Math.max(1, width);
|
|
1481
|
-
const room = columns - 4;
|
|
1482
|
-
if (room < 1) return truncateToWidth(`${border} ${content}`, columns, ELLIPSIS$5);
|
|
1483
|
-
const cut = truncateToWidth(content, room, ELLIPSIS$5);
|
|
1484
|
-
return `${border} ${cut}${" ".repeat(Math.max(0, room - visibleWidth(cut)))} ${border}`;
|
|
1631
|
+
function supersededCall(call, reading) {
|
|
1632
|
+
return call.kind === "message" && reading.peersRecorded || call.kind === "task" && reading.tasksRecorded;
|
|
1485
1633
|
}
|
|
1486
|
-
//#endregion
|
|
1487
|
-
//#region lib/types/keys.js
|
|
1488
1634
|
/**
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
* reserves, and the lines `/help` lists per region.
|
|
1494
|
-
*
|
|
1495
|
-
* Pure. It reads key bytes and returns actions, so the application owns every
|
|
1496
|
-
* effect and the whole map is decided without a terminal, a palette, or a
|
|
1497
|
-
* clock.
|
|
1498
|
-
* @module @deepseek-ai/dsh-tui-app/keys
|
|
1635
|
+
* Whether two rows read the same.
|
|
1636
|
+
* @param previous - the row before, if any.
|
|
1637
|
+
* @param beat - the next row.
|
|
1638
|
+
* @returns true when both rows have the same sender, receiver, kind, and text.
|
|
1499
1639
|
*/
|
|
1500
|
-
|
|
1501
|
-
|
|
1640
|
+
function sameRow(previous, beat) {
|
|
1641
|
+
return previous?.from === beat.from && previous.to === beat.to && previous.kind === beat.kind && previous.text === beat.text;
|
|
1642
|
+
}
|
|
1502
1643
|
/**
|
|
1503
|
-
* The
|
|
1504
|
-
* @param
|
|
1505
|
-
* @
|
|
1644
|
+
* The member a session id names.
|
|
1645
|
+
* @param id - the session id, if the record has one.
|
|
1646
|
+
* @param names - member names by session id.
|
|
1647
|
+
* @returns the name, or undefined when `id` is absent or not in `names`.
|
|
1506
1648
|
*/
|
|
1507
|
-
function
|
|
1508
|
-
|
|
1509
|
-
if (kitty !== void 0) return kitty;
|
|
1510
|
-
return CONTROL_CHARACTERS.test(data) ? void 0 : data;
|
|
1649
|
+
function knownName(id, names) {
|
|
1650
|
+
return id === void 0 ? void 0 : names.get(id);
|
|
1511
1651
|
}
|
|
1512
1652
|
/**
|
|
1513
|
-
* The
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
* The editor draws no legend of its own: the unfocused status bar names the
|
|
1518
|
-
* keys that leave it.
|
|
1653
|
+
* The member a session id names.
|
|
1654
|
+
* @param id - the session id, if the record has one.
|
|
1655
|
+
* @param names - member names by session id.
|
|
1656
|
+
* @returns the name, or `teammate` when `id` is absent or not in `names`.
|
|
1519
1657
|
*/
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
"↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input",
|
|
1524
|
-
"↑↓ ←→ · Space folds · Esc input",
|
|
1525
|
-
"Esc input"
|
|
1526
|
-
],
|
|
1527
|
-
queue: [
|
|
1528
|
-
"↑↓ select · Enter steer · E edit · I inject · Esc input",
|
|
1529
|
-
"↑↓ · Enter steer · E edit · Esc input",
|
|
1530
|
-
"Esc input"
|
|
1531
|
-
],
|
|
1532
|
-
panel: [
|
|
1533
|
-
"↑↓ children · Enter opens · Tab regions · Esc input",
|
|
1534
|
-
"↑↓ children · Esc input",
|
|
1535
|
-
"Esc input"
|
|
1536
|
-
],
|
|
1537
|
-
bar: [
|
|
1538
|
-
"←→ segments · Enter details · Tab regions · Esc input",
|
|
1539
|
-
"←→ segments · Esc input",
|
|
1540
|
-
"Esc input"
|
|
1541
|
-
]
|
|
1542
|
-
};
|
|
1658
|
+
function memberName(id, names) {
|
|
1659
|
+
return knownName(id, names) ?? UNKNOWN_MEMBER;
|
|
1660
|
+
}
|
|
1543
1661
|
/**
|
|
1544
|
-
*
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1662
|
+
* One tool call as an exchange.
|
|
1663
|
+
* @param data - the tool-call data.
|
|
1664
|
+
* @param speaker - the caller.
|
|
1665
|
+
* @param toolNames - names the plugin currently scopes onto the agent. When set, only those calls play.
|
|
1666
|
+
* @returns the exchange, or undefined when the call is not one this page plays.
|
|
1548
1667
|
*/
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
"
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
}
|
|
1564
|
-
/** The two keys that leave the input when no follow-up waits. */
|
|
1565
|
-
const ENTRY_KEYS = "Shift+↑ read · Shift+↓ status";
|
|
1566
|
-
/** The same pair while follow-ups wait: Shift+↑ selects one instead of reading. */
|
|
1567
|
-
const QUEUE_ENTRY_KEYS = "Shift+↑ select · Shift+↓ status";
|
|
1668
|
+
function beatFromCall(data, speaker, toolNames) {
|
|
1669
|
+
const call = fields(data);
|
|
1670
|
+
const name = typeof call?.name === "string" ? call.name : void 0;
|
|
1671
|
+
if (name === void 0) return void 0;
|
|
1672
|
+
const args = argumentsOf(call?.arguments);
|
|
1673
|
+
const scoped = toolNames !== void 0 && toolNames.has(name);
|
|
1674
|
+
const summary = summarizeCall(name, args);
|
|
1675
|
+
if (!scoped && !summary.addressed) return void 0;
|
|
1676
|
+
return {
|
|
1677
|
+
from: speaker,
|
|
1678
|
+
to: summary.to,
|
|
1679
|
+
kind: summary.kind,
|
|
1680
|
+
text: summary.text
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1568
1683
|
/**
|
|
1569
|
-
* The
|
|
1570
|
-
*
|
|
1571
|
-
*
|
|
1684
|
+
* The receiver, the caption, and the kind of one tool call.
|
|
1685
|
+
* Argument keys are the ones a coordination call uses; a plugin tool with
|
|
1686
|
+
* other string fields still captions itself with the first of those fields
|
|
1687
|
+
* when the tool name is in the scoped set.
|
|
1688
|
+
* @param name - the tool name.
|
|
1689
|
+
* @param args - parsed arguments, omitted when they were not a JSON object.
|
|
1690
|
+
* @returns the lane fields, and whether the arguments themselves name an exchange.
|
|
1572
1691
|
*/
|
|
1573
|
-
|
|
1692
|
+
function summarizeCall(name, args) {
|
|
1693
|
+
const target = text(args?.target);
|
|
1694
|
+
const teammate = text(args?.name);
|
|
1695
|
+
const prompt = text(args?.prompt);
|
|
1696
|
+
const message = text(args?.message);
|
|
1697
|
+
const subject = text(args?.subject);
|
|
1698
|
+
const action = text(args?.action);
|
|
1699
|
+
const addressed = target !== void 0 || teammate !== void 0 || message !== void 0 || prompt !== void 0 || subject !== void 0 || action !== void 0;
|
|
1700
|
+
if (subject !== void 0 || action !== void 0) {
|
|
1701
|
+
const caption = [action, subject].filter((part) => part !== void 0).join(" ");
|
|
1702
|
+
return {
|
|
1703
|
+
addressed,
|
|
1704
|
+
to: target ?? "board",
|
|
1705
|
+
kind: "task",
|
|
1706
|
+
text: caption
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
if (prompt !== void 0 && target === void 0) return {
|
|
1710
|
+
addressed,
|
|
1711
|
+
to: teammate ?? "team",
|
|
1712
|
+
kind: "spawn",
|
|
1713
|
+
text: prompt
|
|
1714
|
+
};
|
|
1715
|
+
if (message !== void 0 || target !== void 0) return {
|
|
1716
|
+
addressed,
|
|
1717
|
+
to: target ?? teammate ?? "team",
|
|
1718
|
+
kind: "message",
|
|
1719
|
+
text: message ?? name
|
|
1720
|
+
};
|
|
1721
|
+
const extra = args === void 0 ? void 0 : Object.entries(args).find((entry) => typeof entry[1] === "string");
|
|
1722
|
+
return {
|
|
1723
|
+
addressed,
|
|
1724
|
+
to: "team",
|
|
1725
|
+
kind: "message",
|
|
1726
|
+
text: extra === void 0 ? name : `${extra[0]}: ${extra[1]}`
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1574
1729
|
/**
|
|
1575
|
-
* The
|
|
1576
|
-
*
|
|
1577
|
-
*
|
|
1578
|
-
*
|
|
1579
|
-
* @param
|
|
1580
|
-
* @
|
|
1730
|
+
* The rows one `team/` event adds. Member, task, and message records keep
|
|
1731
|
+
* their lane; any other team event is listed with the first string it carries
|
|
1732
|
+
* that is not an id, or the event type.
|
|
1733
|
+
* @param type - the event type, including the `team/` prefix.
|
|
1734
|
+
* @param data - the event data.
|
|
1735
|
+
* @param reading - the log-wide facts and the state of the pass.
|
|
1736
|
+
* @returns the rows; none for a delivery receipt or a repeated member or task state.
|
|
1581
1737
|
*/
|
|
1582
|
-
function
|
|
1583
|
-
|
|
1738
|
+
function beatsFromTeam(type, data, reading) {
|
|
1739
|
+
const label = type.slice(5);
|
|
1740
|
+
const root = fields(data) ?? {};
|
|
1741
|
+
switch (type) {
|
|
1742
|
+
case "team/member": return memberBeats(root, label, reading);
|
|
1743
|
+
case "team/task": return taskBeats(root, label, reading);
|
|
1744
|
+
case "team/message/queued": return [queuedBeat(root, reading)];
|
|
1745
|
+
case "team/message/delivered": return [];
|
|
1746
|
+
default: return [futureBeat(root, label, reading.speaker)];
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* The rows one `team/member` record adds.
|
|
1751
|
+
* @param root - the record data.
|
|
1752
|
+
* @param label - the event type without the `team/` prefix.
|
|
1753
|
+
* @param reading - the log-wide facts and the state of the pass.
|
|
1754
|
+
* @returns the spawn row when this is the member's first record and no spawn
|
|
1755
|
+
* tool call lists the member, then the failure row when the record is failed
|
|
1756
|
+
* or carries an error.
|
|
1757
|
+
*/
|
|
1758
|
+
function memberBeats(root, label, reading) {
|
|
1759
|
+
const member = fields(root.member) ?? {};
|
|
1760
|
+
const id = text(member.id);
|
|
1761
|
+
const name = text(member.name) ?? memberName(id, reading.names);
|
|
1762
|
+
const phase = text(member.phase);
|
|
1763
|
+
const error = text(member.error);
|
|
1764
|
+
const key = id ?? name;
|
|
1765
|
+
const first = !reading.members.has(key);
|
|
1766
|
+
reading.members.add(key);
|
|
1767
|
+
const beats = [];
|
|
1768
|
+
if (first && !reading.spawnCalls.has(name)) beats.push({
|
|
1769
|
+
from: reading.speaker,
|
|
1770
|
+
to: name,
|
|
1771
|
+
kind: "spawn",
|
|
1772
|
+
text: phase ?? label
|
|
1773
|
+
});
|
|
1774
|
+
if (phase === "failed" || error !== void 0) beats.push({
|
|
1775
|
+
from: name,
|
|
1776
|
+
to: reading.speaker,
|
|
1777
|
+
kind: "spawn",
|
|
1778
|
+
text: error === void 0 ? "failed" : `failed: ${error}`
|
|
1779
|
+
});
|
|
1780
|
+
return beats;
|
|
1584
1781
|
}
|
|
1585
|
-
entryHints();
|
|
1586
1782
|
/**
|
|
1587
|
-
* The
|
|
1588
|
-
* @param
|
|
1589
|
-
* @
|
|
1590
|
-
*
|
|
1783
|
+
* The row one `team/task` record adds.
|
|
1784
|
+
* @param root - the record data.
|
|
1785
|
+
* @param label - the event type without the `team/` prefix.
|
|
1786
|
+
* @param reading - the log-wide facts and the state of the pass.
|
|
1787
|
+
* @returns the row, from the owner when the roster names it, else from the
|
|
1788
|
+
* speaker; none when the revision keeps the task's status and owner.
|
|
1789
|
+
*/
|
|
1790
|
+
function taskBeats(root, label, reading) {
|
|
1791
|
+
const task = fields(root.task) ?? {};
|
|
1792
|
+
const id = text(task.id);
|
|
1793
|
+
const status = text(task.status);
|
|
1794
|
+
const subject = text(task.subject);
|
|
1795
|
+
const ownerId = text(task.ownerId);
|
|
1796
|
+
const stage = `${status ?? ""}/${ownerId ?? ""}`;
|
|
1797
|
+
if (id !== void 0) {
|
|
1798
|
+
if (reading.taskStages.get(id) === stage) return [];
|
|
1799
|
+
reading.taskStages.set(id, stage);
|
|
1800
|
+
}
|
|
1801
|
+
const caption = subject !== void 0 && status !== void 0 ? `${status} ${subject}` : subject ?? status ?? label;
|
|
1802
|
+
return [{
|
|
1803
|
+
from: knownName(ownerId, reading.names) ?? reading.speaker,
|
|
1804
|
+
to: "board",
|
|
1805
|
+
kind: "task",
|
|
1806
|
+
text: caption
|
|
1807
|
+
}];
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* The row one `team/message/queued` record adds.
|
|
1811
|
+
* @param root - the record data.
|
|
1812
|
+
* @param reading - the log-wide facts.
|
|
1813
|
+
* @returns the message from its sender to its target, with the text blocks of its content on one line.
|
|
1591
1814
|
*/
|
|
1592
|
-
function
|
|
1593
|
-
|
|
1815
|
+
function queuedBeat(root, reading) {
|
|
1816
|
+
const message = fields(root.message) ?? {};
|
|
1817
|
+
const said = textBlocks(message.content).join(" ").replace(/\s+/gu, " ").trim();
|
|
1818
|
+
return {
|
|
1819
|
+
from: text(message.senderName) ?? memberName(text(message.senderId), reading.names),
|
|
1820
|
+
to: memberName(text(message.targetId), reading.names),
|
|
1821
|
+
kind: "message",
|
|
1822
|
+
text: said === "" ? NON_TEXT_MESSAGE : said
|
|
1823
|
+
};
|
|
1594
1824
|
}
|
|
1595
1825
|
/**
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1601
|
-
* package README carries every binding.
|
|
1826
|
+
* The row for a `team/` event type that this page does not know.
|
|
1827
|
+
* @param root - the event data.
|
|
1828
|
+
* @param label - the event type without the `team/` prefix.
|
|
1829
|
+
* @param speaker - the session that logged the event.
|
|
1830
|
+
* @returns a message row captioned with the first string field that does not hold an id, else the label.
|
|
1602
1831
|
*/
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
"Esc arms the stop · Esc again stops the turn · Esc cancels a running /compact",
|
|
1615
|
-
"Ctrl+C clears the input, twice quits · Ctrl+D quits an empty input"
|
|
1616
|
-
],
|
|
1617
|
-
transcript: [widestHint("transcript"), "Shift+↑↓ blocks · PgUp PgDn turns · Home End ends · Tab regions · Enter reads"],
|
|
1618
|
-
queue: [widestHint("queue")],
|
|
1619
|
-
panel: [widestHint("panel")],
|
|
1620
|
-
bar: [widestHint("bar")]
|
|
1621
|
-
};
|
|
1622
|
-
/** `Escape`, which every region answers. */
|
|
1623
|
-
const ESCAPE = { kind: "escape" };
|
|
1624
|
-
/** `Ctrl+O`, which every region answers. */
|
|
1625
|
-
const FOLD_ALL = { kind: "fold-all" };
|
|
1626
|
-
/** `Ctrl+G`, which every region answers. */
|
|
1627
|
-
const READER = { kind: "reader" };
|
|
1628
|
-
/** `Enter` on the held section, row, or segment. */
|
|
1629
|
-
const OPEN = { kind: "open" };
|
|
1832
|
+
function futureBeat(root, label, speaker) {
|
|
1833
|
+
const nested = fields(root.member) ?? fields(root.task) ?? fields(root.message) ?? root;
|
|
1834
|
+
const who = text(nested.name) ?? text(nested.senderName) ?? text(nested.subject) ?? "team";
|
|
1835
|
+
const first = Object.entries(nested).find((entry) => !IDENTIFIER_FIELDS.has(entry[0]) && typeof entry[1] === "string" && entry[1].trim() !== "")?.[1];
|
|
1836
|
+
return {
|
|
1837
|
+
from: speaker,
|
|
1838
|
+
to: who,
|
|
1839
|
+
kind: "message",
|
|
1840
|
+
text: text(nested.phase) ?? text(nested.status) ?? text(nested.message) ?? text(nested.text) ?? first ?? label
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1630
1843
|
/**
|
|
1631
|
-
*
|
|
1632
|
-
*
|
|
1633
|
-
*
|
|
1634
|
-
* mean the same thing everywhere and are answered first. Everything else is
|
|
1635
|
-
* the region's own.
|
|
1636
|
-
* @param region - the region holding the keyboard.
|
|
1637
|
-
* @param data - the raw key bytes.
|
|
1638
|
-
* @returns the action to apply, or undefined when this region claims nothing
|
|
1639
|
-
* for the key: the editor lets pi-tui's own editor have it, and a docked
|
|
1640
|
-
* region consumes it without effect.
|
|
1844
|
+
* The text blocks of message content.
|
|
1845
|
+
* @param content - the logged content blocks.
|
|
1846
|
+
* @returns the text of each text block in order; none when `content` is not an array.
|
|
1641
1847
|
*/
|
|
1642
|
-
function
|
|
1643
|
-
if (
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
if (matchesKey(data, "ctrl+p")) return { kind: "parent" };
|
|
1649
|
-
if (matchesKey(data, "ctrl+l")) return { kind: "redraw" };
|
|
1650
|
-
switch (region) {
|
|
1651
|
-
case "editor": return editorKey(data);
|
|
1652
|
-
case "transcript": return transcriptKey(data);
|
|
1653
|
-
case "queue": return queueKey(data);
|
|
1654
|
-
case "panel": return panelKey(data);
|
|
1655
|
-
case "bar": return barKey(data);
|
|
1656
|
-
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
1657
|
-
default: return assertNever(region, "tui focus region");
|
|
1848
|
+
function textBlocks(content) {
|
|
1849
|
+
if (!Array.isArray(content)) return [];
|
|
1850
|
+
const parts = [];
|
|
1851
|
+
for (const block of content) {
|
|
1852
|
+
const row = fields(block);
|
|
1853
|
+
if (row?.type === "text" && typeof row.text === "string") parts.push(row.text);
|
|
1658
1854
|
}
|
|
1855
|
+
return parts;
|
|
1659
1856
|
}
|
|
1660
1857
|
/**
|
|
1661
|
-
*
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
* the
|
|
1665
|
-
* follow-up first, and reaches the editor's history when none is taken.
|
|
1666
|
-
* @param data - the raw key bytes.
|
|
1667
|
-
* @returns the action, or undefined for every key pi-tui's editor owns.
|
|
1858
|
+
* A received team message as an exchange aimed at `speaker`.
|
|
1859
|
+
* @param data - the user-message data.
|
|
1860
|
+
* @param speaker - the session that received the message.
|
|
1861
|
+
* @returns the exchange, or undefined when the text is not a team message.
|
|
1668
1862
|
*/
|
|
1669
|
-
function
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1863
|
+
function beatFromUser(data, speaker) {
|
|
1864
|
+
const message = fields(fields(data)?.message);
|
|
1865
|
+
const body = textBlocks(message?.content).join("");
|
|
1866
|
+
const matched = /^Team message from ([^:]+):\s*([\s\S]*)$/u.exec(body);
|
|
1867
|
+
const named = matched?.[1]?.trim();
|
|
1868
|
+
const said = matched?.[2]?.trim();
|
|
1869
|
+
if (named !== void 0 && named !== "" && said !== void 0 && said !== "") return {
|
|
1870
|
+
from: named,
|
|
1871
|
+
to: speaker,
|
|
1872
|
+
kind: "message",
|
|
1873
|
+
text: said
|
|
1674
1874
|
};
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1875
|
+
const source = fields(message?.source);
|
|
1876
|
+
if (source?.kind === "agent-message" && body !== "") return {
|
|
1877
|
+
from: text(source.senderName) ?? "teammate",
|
|
1878
|
+
to: speaker,
|
|
1879
|
+
kind: "message",
|
|
1880
|
+
text: body
|
|
1678
1881
|
};
|
|
1679
|
-
if (matchesKey(data, "ctrl+s")) return { kind: "steer" };
|
|
1680
|
-
if (matchesKey(data, "shift+tab")) return { kind: "effort" };
|
|
1681
|
-
if (data === "?") return { kind: "help" };
|
|
1682
1882
|
}
|
|
1683
1883
|
/**
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1686
|
-
*
|
|
1884
|
+
* Parse tool arguments, skipping text that is not a JSON object.
|
|
1885
|
+
* @param value - the arguments string a tool call logged.
|
|
1886
|
+
* @returns the object, or undefined when it is missing or not an object.
|
|
1687
1887
|
*/
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
{
|
|
1695
|
-
key: "down",
|
|
1696
|
-
axis: "section",
|
|
1697
|
-
to: "next"
|
|
1698
|
-
},
|
|
1699
|
-
{
|
|
1700
|
-
key: "shift+up",
|
|
1701
|
-
axis: "block",
|
|
1702
|
-
to: "previous"
|
|
1703
|
-
},
|
|
1704
|
-
{
|
|
1705
|
-
key: "shift+down",
|
|
1706
|
-
axis: "block",
|
|
1707
|
-
to: "next"
|
|
1708
|
-
},
|
|
1709
|
-
{
|
|
1710
|
-
key: "pageUp",
|
|
1711
|
-
axis: "turn",
|
|
1712
|
-
to: "previous"
|
|
1713
|
-
},
|
|
1714
|
-
{
|
|
1715
|
-
key: "pageDown",
|
|
1716
|
-
axis: "turn",
|
|
1717
|
-
to: "next"
|
|
1718
|
-
},
|
|
1719
|
-
{
|
|
1720
|
-
key: "home",
|
|
1721
|
-
axis: "section",
|
|
1722
|
-
to: "first"
|
|
1723
|
-
},
|
|
1724
|
-
{
|
|
1725
|
-
key: "end",
|
|
1726
|
-
axis: "section",
|
|
1727
|
-
to: "last"
|
|
1728
|
-
},
|
|
1729
|
-
{
|
|
1730
|
-
key: "left",
|
|
1731
|
-
axis: "part",
|
|
1732
|
-
to: "previous"
|
|
1733
|
-
},
|
|
1734
|
-
{
|
|
1735
|
-
key: "right",
|
|
1736
|
-
axis: "part",
|
|
1737
|
-
to: "next"
|
|
1738
|
-
},
|
|
1739
|
-
{
|
|
1740
|
-
key: "shift+left",
|
|
1741
|
-
axis: "part",
|
|
1742
|
-
to: "first"
|
|
1743
|
-
},
|
|
1744
|
-
{
|
|
1745
|
-
key: "shift+right",
|
|
1746
|
-
axis: "part",
|
|
1747
|
-
to: "last"
|
|
1748
|
-
}
|
|
1749
|
-
];
|
|
1750
|
-
/** The pending-prompt panel's movement keys. */
|
|
1751
|
-
const QUEUE_MOVES = [
|
|
1752
|
-
{
|
|
1753
|
-
key: "up",
|
|
1754
|
-
axis: "prompt",
|
|
1755
|
-
to: "previous"
|
|
1756
|
-
},
|
|
1757
|
-
{
|
|
1758
|
-
key: "down",
|
|
1759
|
-
axis: "prompt",
|
|
1760
|
-
to: "next"
|
|
1761
|
-
},
|
|
1762
|
-
{
|
|
1763
|
-
key: "home",
|
|
1764
|
-
axis: "prompt",
|
|
1765
|
-
to: "first"
|
|
1766
|
-
},
|
|
1767
|
-
{
|
|
1768
|
-
key: "end",
|
|
1769
|
-
axis: "prompt",
|
|
1770
|
-
to: "last"
|
|
1888
|
+
function argumentsOf(value) {
|
|
1889
|
+
if (typeof value !== "string") return void 0;
|
|
1890
|
+
try {
|
|
1891
|
+
return fields(JSON.parse(value));
|
|
1892
|
+
} catch (error) {
|
|
1893
|
+
return;
|
|
1771
1894
|
}
|
|
1772
|
-
|
|
1895
|
+
}
|
|
1773
1896
|
/**
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1897
|
+
* A nonempty string field.
|
|
1898
|
+
* @param value - the candidate.
|
|
1899
|
+
* @returns the string, or undefined when it is blank or not a string.
|
|
1776
1900
|
*/
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
},
|
|
1783
|
-
{
|
|
1784
|
-
key: "down",
|
|
1785
|
-
axis: "row",
|
|
1786
|
-
to: "next"
|
|
1787
|
-
},
|
|
1788
|
-
{
|
|
1789
|
-
key: "shift+up",
|
|
1790
|
-
axis: "row",
|
|
1791
|
-
to: "first"
|
|
1792
|
-
},
|
|
1793
|
-
{
|
|
1794
|
-
key: "home",
|
|
1795
|
-
axis: "row",
|
|
1796
|
-
to: "first"
|
|
1797
|
-
},
|
|
1798
|
-
{
|
|
1799
|
-
key: "pageUp",
|
|
1800
|
-
axis: "row",
|
|
1801
|
-
to: "first"
|
|
1802
|
-
},
|
|
1803
|
-
{
|
|
1804
|
-
key: "shift+down",
|
|
1805
|
-
axis: "row",
|
|
1806
|
-
to: "last"
|
|
1807
|
-
},
|
|
1808
|
-
{
|
|
1809
|
-
key: "end",
|
|
1810
|
-
axis: "row",
|
|
1811
|
-
to: "last"
|
|
1812
|
-
},
|
|
1813
|
-
{
|
|
1814
|
-
key: "pageDown",
|
|
1815
|
-
axis: "row",
|
|
1816
|
-
to: "last"
|
|
1817
|
-
}
|
|
1818
|
-
];
|
|
1819
|
-
/** The status bar's movement keys, along its one axis of segments. */
|
|
1820
|
-
const BAR_MOVES = [
|
|
1821
|
-
{
|
|
1822
|
-
key: "left",
|
|
1823
|
-
axis: "segment",
|
|
1824
|
-
to: "previous"
|
|
1825
|
-
},
|
|
1826
|
-
{
|
|
1827
|
-
key: "right",
|
|
1828
|
-
axis: "segment",
|
|
1829
|
-
to: "next"
|
|
1830
|
-
},
|
|
1831
|
-
{
|
|
1832
|
-
key: "shift+left",
|
|
1833
|
-
axis: "segment",
|
|
1834
|
-
to: "first"
|
|
1835
|
-
},
|
|
1836
|
-
{
|
|
1837
|
-
key: "home",
|
|
1838
|
-
axis: "segment",
|
|
1839
|
-
to: "first"
|
|
1840
|
-
},
|
|
1841
|
-
{
|
|
1842
|
-
key: "pageUp",
|
|
1843
|
-
axis: "segment",
|
|
1844
|
-
to: "first"
|
|
1845
|
-
},
|
|
1846
|
-
{
|
|
1847
|
-
key: "shift+right",
|
|
1848
|
-
axis: "segment",
|
|
1849
|
-
to: "last"
|
|
1850
|
-
},
|
|
1851
|
-
{
|
|
1852
|
-
key: "end",
|
|
1853
|
-
axis: "segment",
|
|
1854
|
-
to: "last"
|
|
1855
|
-
},
|
|
1856
|
-
{
|
|
1857
|
-
key: "pageDown",
|
|
1858
|
-
axis: "segment",
|
|
1859
|
-
to: "last"
|
|
1860
|
-
}
|
|
1861
|
-
];
|
|
1901
|
+
function text(value) {
|
|
1902
|
+
if (typeof value !== "string") return void 0;
|
|
1903
|
+
const trimmed = value.trim();
|
|
1904
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
1905
|
+
}
|
|
1862
1906
|
/**
|
|
1863
|
-
*
|
|
1864
|
-
* @param
|
|
1865
|
-
* @
|
|
1866
|
-
* @returns the movement action, or undefined when the table has no binding for the key.
|
|
1907
|
+
* The own fields of a plain object.
|
|
1908
|
+
* @param value - the candidate.
|
|
1909
|
+
* @returns those fields, or undefined for anything that is not a plain object.
|
|
1867
1910
|
*/
|
|
1868
|
-
function
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
to: binding.to
|
|
1874
|
-
};
|
|
1911
|
+
function fields(value) {
|
|
1912
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
1913
|
+
const out = {};
|
|
1914
|
+
for (const [key, field] of Object.entries(value)) out[key] = field;
|
|
1915
|
+
return out;
|
|
1875
1916
|
}
|
|
1917
|
+
//#endregion
|
|
1918
|
+
//#region lib/types/team-panel.js
|
|
1876
1919
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
*
|
|
1880
|
-
*
|
|
1920
|
+
* The docked Agent Teams summary between the editor and the status bar: the
|
|
1921
|
+
* roster and the shared tasks become one dim line.
|
|
1922
|
+
*
|
|
1923
|
+
* The line is the only team summary on the main page. The subagent panel does
|
|
1924
|
+
* not list or count teammates, and the activity board labels a teammate by name
|
|
1925
|
+
* and role. The line names the teammates whose turn is running, so it is also
|
|
1926
|
+
* the live indicator. It is drawn while a teammate or a shared task that is not
|
|
1927
|
+
* deleted exists, and the app never gives it the keyboard. Everything here is
|
|
1928
|
+
* pure — no Context, no services, no clock.
|
|
1929
|
+
* @module @deepseek-ai/dsh-tui-app/team-panel
|
|
1881
1930
|
*/
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
kind: "cycle",
|
|
1889
|
-
step: -1
|
|
1890
|
-
};
|
|
1891
|
-
}
|
|
1931
|
+
/** Drawn when the user forces the panel on and the roster has nothing to list. */
|
|
1932
|
+
const TEAM_PANEL_EMPTY = "team · no teammates or shared tasks yet";
|
|
1933
|
+
/** What separates two facts inside the line. */
|
|
1934
|
+
const SEPARATOR$5 = " · ";
|
|
1935
|
+
/** The command the line points at; it plays the exchanges between the lead and its teammates. */
|
|
1936
|
+
const TEAM_PLAY_HINT = "/team-play";
|
|
1892
1937
|
/**
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
* @param data - the raw key bytes.
|
|
1897
|
-
* @returns the action, or undefined for a key the transcript consumes without effect.
|
|
1938
|
+
* Tasks the summary counts.
|
|
1939
|
+
* @param tasks - the roster's tasks, deleted rows included.
|
|
1940
|
+
* @returns the tasks whose status is not `deleted`, in input order.
|
|
1898
1941
|
*/
|
|
1899
|
-
function
|
|
1900
|
-
|
|
1901
|
-
if (move !== void 0) return move;
|
|
1902
|
-
if (matchesKey(data, "enter")) return OPEN;
|
|
1903
|
-
if (matchesKey(data, "space")) return { kind: "fold" };
|
|
1904
|
-
return cycleKey(data) ?? typeKey(data);
|
|
1942
|
+
function liveTasks(tasks) {
|
|
1943
|
+
return tasks.filter((task) => task.status !== "deleted");
|
|
1905
1944
|
}
|
|
1906
1945
|
/**
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
* @
|
|
1946
|
+
* The ways the running teammates can be named, longest first: every name, then
|
|
1947
|
+
* fewer names ended by `+<n>` for the ones left out, then only their number.
|
|
1948
|
+
* @param names - the names of the teammates whose status is `running`, in roster order.
|
|
1949
|
+
* @returns one candidate per step, or `undefined` alone when no teammate is running, which leaves the segment out.
|
|
1910
1950
|
*/
|
|
1911
|
-
function
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
action: "steer"
|
|
1921
|
-
};
|
|
1922
|
-
if (data === "i" || data === "I") return {
|
|
1923
|
-
kind: "queue",
|
|
1924
|
-
action: "inject"
|
|
1925
|
-
};
|
|
1926
|
-
if (data === "e" || data === "E") return {
|
|
1927
|
-
kind: "queue",
|
|
1928
|
-
action: "edit"
|
|
1929
|
-
};
|
|
1930
|
-
return cycleKey(data) ?? typeKey(data);
|
|
1931
|
-
}
|
|
1932
|
-
/**
|
|
1933
|
-
* What one key means while the subagent panel holds the keyboard.
|
|
1934
|
-
* @param data - the raw key bytes.
|
|
1935
|
-
* @returns the action, or undefined for a key the panel consumes without effect.
|
|
1936
|
-
*/
|
|
1937
|
-
function panelKey(data) {
|
|
1938
|
-
const move = moveKey(data, PANEL_MOVES);
|
|
1939
|
-
if (move !== void 0) return move;
|
|
1940
|
-
if (matchesKey(data, "enter") || matchesKey(data, "right")) return OPEN;
|
|
1941
|
-
return cycleKey(data) ?? typeKey(data);
|
|
1942
|
-
}
|
|
1943
|
-
/**
|
|
1944
|
-
* What one key means while the status bar holds the keyboard. The bar is the
|
|
1945
|
-
* bottom of the stack, so `Up` leaves it and `Down` does nothing.
|
|
1946
|
-
* @param data - the raw key bytes.
|
|
1947
|
-
* @returns the action, or undefined for a key the bar consumes without effect.
|
|
1948
|
-
*/
|
|
1949
|
-
function barKey(data) {
|
|
1950
|
-
const move = moveKey(data, BAR_MOVES);
|
|
1951
|
-
if (move !== void 0) return move;
|
|
1952
|
-
if (matchesKey(data, "up")) return {
|
|
1953
|
-
kind: "leave",
|
|
1954
|
-
direction: "up"
|
|
1955
|
-
};
|
|
1956
|
-
if (matchesKey(data, "shift+up")) return {
|
|
1957
|
-
kind: "focus",
|
|
1958
|
-
region: "transcript"
|
|
1959
|
-
};
|
|
1960
|
-
if (matchesKey(data, "shift+down")) return {
|
|
1961
|
-
kind: "focus",
|
|
1962
|
-
region: "bar"
|
|
1963
|
-
};
|
|
1964
|
-
if (matchesKey(data, "enter")) return OPEN;
|
|
1965
|
-
return cycleKey(data) ?? typeKey(data);
|
|
1966
|
-
}
|
|
1967
|
-
/**
|
|
1968
|
-
* The printable law: a key that types something hands the keyboard back to
|
|
1969
|
-
* the editor and lands at its caret.
|
|
1970
|
-
* @param data - the raw key bytes.
|
|
1971
|
-
* @returns the typing action, or undefined for a key that types nothing.
|
|
1972
|
-
*/
|
|
1973
|
-
function typeKey(data) {
|
|
1974
|
-
const text = typedText(data);
|
|
1975
|
-
return text === void 0 ? void 0 : {
|
|
1976
|
-
kind: "type",
|
|
1977
|
-
text
|
|
1978
|
-
};
|
|
1979
|
-
}
|
|
1980
|
-
/** Drawn when the user forces the panel on and the roster has nothing to list. */
|
|
1981
|
-
const TEAM_PANEL_EMPTY = "team · no teammates or shared tasks yet";
|
|
1982
|
-
/** What separates two facts inside one row. */
|
|
1983
|
-
const SEPARATOR$6 = " · ";
|
|
1984
|
-
/**
|
|
1985
|
-
* Tasks the summary and the focused rows count.
|
|
1986
|
-
* @param tasks - the roster's tasks, deleted rows included.
|
|
1987
|
-
* @returns the tasks whose status is not `deleted`, in input order.
|
|
1988
|
-
*/
|
|
1989
|
-
function liveTasks(tasks) {
|
|
1990
|
-
return tasks.filter((task) => task.status !== "deleted");
|
|
1991
|
-
}
|
|
1992
|
-
/**
|
|
1993
|
-
* Whether the roster has anything the summary lists.
|
|
1994
|
-
* @param members - the roster rows.
|
|
1995
|
-
* @param tasks - the non-deleted tasks.
|
|
1996
|
-
* @returns true when a teammate or a live task exists.
|
|
1997
|
-
*/
|
|
1998
|
-
function hasContent(members, tasks) {
|
|
1999
|
-
return members.some((member) => member.role === "teammate") || tasks.length > 0;
|
|
2000
|
-
}
|
|
2001
|
-
/**
|
|
2002
|
-
* One member as a focused row.
|
|
2003
|
-
* @param member - the roster row.
|
|
2004
|
-
* @returns `name · role · status`, plus ` · model` when a model is present.
|
|
2005
|
-
*/
|
|
2006
|
-
function memberLine(member) {
|
|
2007
|
-
const parts = [
|
|
2008
|
-
member.name,
|
|
2009
|
-
member.role,
|
|
2010
|
-
member.status
|
|
2011
|
-
];
|
|
2012
|
-
if (member.model !== void 0) parts.push(member.model);
|
|
2013
|
-
return parts.join(SEPARATOR$6);
|
|
2014
|
-
}
|
|
2015
|
-
/**
|
|
2016
|
-
* One task as a focused row.
|
|
2017
|
-
* @param task - a non-deleted task.
|
|
2018
|
-
* @returns `subject · status · owner|unowned · ready|blocked`.
|
|
2019
|
-
*/
|
|
2020
|
-
function taskLine(task) {
|
|
2021
|
-
const owner = task.ownerName ?? "unowned";
|
|
2022
|
-
return [
|
|
2023
|
-
task.subject,
|
|
2024
|
-
task.status,
|
|
2025
|
-
owner,
|
|
2026
|
-
task.ready ? "ready" : "blocked"
|
|
2027
|
-
].join(SEPARATOR$6);
|
|
2028
|
-
}
|
|
2029
|
-
/**
|
|
2030
|
-
* The unfocused summary.
|
|
2031
|
-
* @param view - the draw.
|
|
2032
|
-
* @returns `team · <n> members · <running> running · <tasks> tasks`.
|
|
2033
|
-
*/
|
|
2034
|
-
function summaryLine(view) {
|
|
2035
|
-
return `team · ${String(view.memberCount)} members · ${String(view.running)} running · ${String(view.taskCount)} tasks`;
|
|
1951
|
+
function workingSegments(names) {
|
|
1952
|
+
if (names.length === 0) return [void 0];
|
|
1953
|
+
const segments = [];
|
|
1954
|
+
for (let shown = names.length; shown >= 1; shown--) {
|
|
1955
|
+
const rest = names.length - shown;
|
|
1956
|
+
segments.push(`working: ${names.slice(0, shown).join(", ")}${rest === 0 ? "" : ` +${String(rest)}`}`);
|
|
1957
|
+
}
|
|
1958
|
+
segments.push(`${String(names.length)} working`);
|
|
1959
|
+
return segments;
|
|
2036
1960
|
}
|
|
2037
1961
|
/**
|
|
2038
|
-
*
|
|
2039
|
-
*
|
|
2040
|
-
*
|
|
2041
|
-
*
|
|
2042
|
-
* @
|
|
2043
|
-
*
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
const
|
|
2048
|
-
const
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
hidden: listed.length - rows.length,
|
|
2063
|
-
memberCount,
|
|
2064
|
-
running,
|
|
2065
|
-
taskCount,
|
|
2066
|
-
shown: true
|
|
2067
|
-
};
|
|
1962
|
+
* The summary text.
|
|
1963
|
+
* @param teammates - the roster rows whose role is `teammate`.
|
|
1964
|
+
* @param tasks - the tasks that are not deleted.
|
|
1965
|
+
* @param width - columns the text should fit.
|
|
1966
|
+
* @returns `team · <n> teammates · working: <names> · tasks <completed>/<total> done · /team-play`
|
|
1967
|
+
* with the `working` segment left out while nobody runs. The first segment step that fits
|
|
1968
|
+
* `width` is used, and the shortest one when none does.
|
|
1969
|
+
*/
|
|
1970
|
+
function summaryText(teammates, tasks, width) {
|
|
1971
|
+
const completed = tasks.filter((task) => task.status === "completed").length;
|
|
1972
|
+
const count = `${String(teammates.length)} ${teammates.length === 1 ? "teammate" : "teammates"}`;
|
|
1973
|
+
const running = teammates.filter((member) => member.status === "running").map((member) => member.name);
|
|
1974
|
+
let text = "";
|
|
1975
|
+
for (const segment of workingSegments(running)) {
|
|
1976
|
+
text = [
|
|
1977
|
+
"team",
|
|
1978
|
+
count,
|
|
1979
|
+
...segment === void 0 ? [] : [segment],
|
|
1980
|
+
`tasks ${String(completed)}/${String(tasks.length)} done`,
|
|
1981
|
+
TEAM_PLAY_HINT
|
|
1982
|
+
].join(SEPARATOR$5);
|
|
1983
|
+
if (visibleWidth(text) <= width) break;
|
|
1984
|
+
}
|
|
1985
|
+
return text;
|
|
2068
1986
|
}
|
|
2069
1987
|
/**
|
|
2070
1988
|
* The one-line summary the app mounts. `hidden` draws nothing. `forced`
|
|
2071
1989
|
* draws {@link TEAM_PANEL_EMPTY} when the roster has no teammate and no task
|
|
2072
|
-
* that is not deleted. Otherwise the line counts
|
|
2073
|
-
* ones, and the tasks
|
|
2074
|
-
*
|
|
1990
|
+
* that is not deleted. Otherwise the line counts the teammates (the lead is
|
|
1991
|
+
* not one), names the running ones, and counts the completed tasks among the
|
|
1992
|
+
* tasks that are not deleted. A line wider than `width` drops names from the
|
|
1993
|
+
* running list first, then ends with `…`.
|
|
1994
|
+
* @param inputs - the roster, the tasks, the width, and whether the line is hidden or forced.
|
|
2075
1995
|
* @param palette - the palette the line is dimmed with.
|
|
2076
1996
|
* @returns the summary line, or `''` when the slot should stay empty.
|
|
2077
1997
|
*/
|
|
2078
1998
|
function teamPanelLine(inputs, palette) {
|
|
2079
1999
|
if (inputs.hidden === true) return "";
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
});
|
|
2085
|
-
if (!view.shown) return inputs.forced === true ? palette.dim(TEAM_PANEL_EMPTY) : "";
|
|
2086
|
-
return palette.dim(summaryLine(view));
|
|
2000
|
+
const teammates = inputs.members.filter((member) => member.role === "teammate");
|
|
2001
|
+
const tasks = liveTasks(inputs.tasks);
|
|
2002
|
+
const text = teammates.length === 0 && tasks.length === 0 ? inputs.forced === true ? TEAM_PANEL_EMPTY : "" : summaryText(teammates, tasks, inputs.width);
|
|
2003
|
+
return text === "" ? "" : palette.dim(truncateToWidth(text, inputs.width, "…"));
|
|
2087
2004
|
}
|
|
2088
2005
|
//#endregion
|
|
2089
2006
|
//#region lib/types/diff.js
|
|
@@ -3049,7 +2966,7 @@ function commandOf(args) {
|
|
|
3049
2966
|
/* v8 ignore next -- a live owned job settles before it can leave the registry */
|
|
3050
2967
|
function ignoreGone(_gone) {}
|
|
3051
2968
|
/** What separates two facts on one line. */
|
|
3052
|
-
const SEPARATOR$
|
|
2969
|
+
const SEPARATOR$4 = " · ";
|
|
3053
2970
|
/** The key the running spinner names while a foreground call can be moved. */
|
|
3054
2971
|
const BACKGROUND_KEY_HINT = "Ctrl+B background";
|
|
3055
2972
|
/** What the `/jobs` picker says between its heading and its rows. */
|
|
@@ -3083,8 +3000,8 @@ function renderJobsLine(jobs, render) {
|
|
|
3083
3000
|
const live = jobs.filter(isLive);
|
|
3084
3001
|
if (live.length === 0) return "";
|
|
3085
3002
|
const { palette } = render;
|
|
3086
|
-
const text = [`${String(live.length)} in background`, ...live.map((job) => `${job.id} ${oneLine(job.label)} ${jobElapsed(job, render.now)}`)].join(SEPARATOR$
|
|
3087
|
-
const tail = `${SEPARATOR$
|
|
3003
|
+
const text = [`${String(live.length)} in background`, ...live.map((job) => `${job.id} ${oneLine(job.label)} ${jobElapsed(job, render.now)}`)].join(SEPARATOR$4);
|
|
3004
|
+
const tail = `${SEPARATOR$4}/jobs`;
|
|
3088
3005
|
const room = Math.max(1, render.width - 2 - tail.length);
|
|
3089
3006
|
return `${palette.accent("◇")} ${palette.dim(`${truncateToWidth(text, room, "…")}${tail}`)}`;
|
|
3090
3007
|
}
|
|
@@ -3102,7 +3019,7 @@ function jobChoice(job, now) {
|
|
|
3102
3019
|
job.status,
|
|
3103
3020
|
jobElapsed(job, now),
|
|
3104
3021
|
oneLine(job.label)
|
|
3105
|
-
].join(SEPARATOR$
|
|
3022
|
+
].join(SEPARATOR$4)
|
|
3106
3023
|
};
|
|
3107
3024
|
}
|
|
3108
3025
|
/**
|
|
@@ -3119,7 +3036,7 @@ function jobDetailRows(job, chunks, now) {
|
|
|
3119
3036
|
job.status,
|
|
3120
3037
|
...job.detail === void 0 ? [] : [job.detail],
|
|
3121
3038
|
jobElapsed(job, now)
|
|
3122
|
-
].join(SEPARATOR$
|
|
3039
|
+
].join(SEPARATOR$4),
|
|
3123
3040
|
job.label,
|
|
3124
3041
|
`started ${formatTimestamp(job.startedAt)} UTC`
|
|
3125
3042
|
];
|
|
@@ -3144,7 +3061,7 @@ function jobDetailRows(job, chunks, now) {
|
|
|
3144
3061
|
function settledToast(job, notified) {
|
|
3145
3062
|
const parts = [`◇ ${job.id} ${job.status}`, oneLine(job.label)];
|
|
3146
3063
|
if (notified) parts.push("agent notified");
|
|
3147
|
-
return parts.join(SEPARATOR$
|
|
3064
|
+
return parts.join(SEPARATOR$4);
|
|
3148
3065
|
}
|
|
3149
3066
|
/**
|
|
3150
3067
|
* A label on one line.
|
|
@@ -9082,81 +8999,575 @@ const SEARCH_ROUTE_ITEMS = [{
|
|
|
9082
8999
|
description: `Search through OpenRouter with ${OPENROUTER_KEY_REF} and deepseek/deepseek-v4-flash-0731`
|
|
9083
9000
|
}];
|
|
9084
9001
|
/**
|
|
9085
|
-
* The route the stored search settings resolve to.
|
|
9086
|
-
* @param ctx - plugin context carrying the optional settings service.
|
|
9087
|
-
* @returns `openrouter` when the resolved endpoint is OpenRouter's, otherwise `deepseek`.
|
|
9088
|
-
* @throws {Error} when no settings service is mounted or the namespace is not registered.
|
|
9002
|
+
* The route the stored search settings resolve to.
|
|
9003
|
+
* @param ctx - plugin context carrying the optional settings service.
|
|
9004
|
+
* @returns `openrouter` when the resolved endpoint is OpenRouter's, otherwise `deepseek`.
|
|
9005
|
+
* @throws {Error} when no settings service is mounted or the namespace is not registered.
|
|
9006
|
+
*/
|
|
9007
|
+
function currentSearchRoute(ctx) {
|
|
9008
|
+
const { baseURL } = settingValue(ctx, SEARCH_NAMESPACE);
|
|
9009
|
+
return baseURL?.startsWith(OPENROUTER_BASE_URL) === true ? "openrouter" : "deepseek";
|
|
9010
|
+
}
|
|
9011
|
+
/**
|
|
9012
|
+
* Select a search route by writing the provider's settings.
|
|
9013
|
+
* @param ctx - plugin context carrying the optional settings service.
|
|
9014
|
+
* @param route - the route to select; `deepseek` clears the namespace's user overrides.
|
|
9015
|
+
* @param model - the OpenRouter model for `openrouter`; defaults to {@link OPENROUTER_SEARCH_MODEL}.
|
|
9016
|
+
* @returns a confirmation row.
|
|
9017
|
+
* @throws {Error} when no settings service is mounted or the namespace is not registered.
|
|
9018
|
+
*/
|
|
9019
|
+
async function applySearchRoute(ctx, route, model) {
|
|
9020
|
+
if (route === "deepseek") {
|
|
9021
|
+
await resetSetting(ctx, SEARCH_NAMESPACE);
|
|
9022
|
+
return "web search: DeepSeek";
|
|
9023
|
+
}
|
|
9024
|
+
const chosen = model ?? "deepseek/deepseek-v4-flash-0731";
|
|
9025
|
+
await setSetting(ctx, SEARCH_NAMESPACE, "baseURL", OPENROUTER_BASE_URL);
|
|
9026
|
+
await setSetting(ctx, SEARCH_NAMESPACE, "apiKeyEnv", OPENROUTER_KEY_REF);
|
|
9027
|
+
await setSetting(ctx, SEARCH_NAMESPACE, "model", chosen);
|
|
9028
|
+
return `web search: OpenRouter ${chosen}`;
|
|
9029
|
+
}
|
|
9030
|
+
//#endregion
|
|
9031
|
+
//#region lib/types/permission.js
|
|
9032
|
+
/**
|
|
9033
|
+
* Permission-preset rows and labels shared by `/permission` and the
|
|
9034
|
+
* permission status-bar hint.
|
|
9035
|
+
* @module @deepseek-ai/dsh-tui-app/permission
|
|
9036
|
+
*/
|
|
9037
|
+
/**
|
|
9038
|
+
* The display name of one preset.
|
|
9039
|
+
* @param options - the process catalog.
|
|
9040
|
+
* @param preset - the selected preset, including a derived `custom` value.
|
|
9041
|
+
* @returns the catalog label, or the raw id when the catalog no longer lists it.
|
|
9042
|
+
*/
|
|
9043
|
+
function permissionName(options, preset) {
|
|
9044
|
+
return options.find((option) => option.value === preset)?.name ?? preset;
|
|
9045
|
+
}
|
|
9046
|
+
/**
|
|
9047
|
+
* Picker rows for the process catalog, in contribution order.
|
|
9048
|
+
* @param options - the selectable presets.
|
|
9049
|
+
* @returns the rows.
|
|
9050
|
+
*/
|
|
9051
|
+
function permissionItems(options) {
|
|
9052
|
+
return options.map((option) => ({
|
|
9053
|
+
value: option.value,
|
|
9054
|
+
label: option.name,
|
|
9055
|
+
...option.description === void 0 ? {} : { description: option.description }
|
|
9056
|
+
}));
|
|
9057
|
+
}
|
|
9058
|
+
/**
|
|
9059
|
+
* The dim row under the picker heading.
|
|
9060
|
+
* @param options - the process catalog.
|
|
9061
|
+
* @param preset - the preset in force.
|
|
9062
|
+
* @returns one row naming the preset in force and how to dismiss the picker.
|
|
9063
|
+
*/
|
|
9064
|
+
function permissionHint(options, preset) {
|
|
9065
|
+
return `current: ${permissionName(options, preset)} · Esc keeps it`;
|
|
9066
|
+
}
|
|
9067
|
+
/**
|
|
9068
|
+
* The preset a typed `/permission` argument names. Matching is without case
|
|
9069
|
+
* so a typed id can follow the catalog's own casing.
|
|
9070
|
+
* @param options - the process catalog.
|
|
9071
|
+
* @param typed - the argument, matched against catalog values.
|
|
9072
|
+
* @returns the catalog value, or null when nothing matches.
|
|
9073
|
+
*/
|
|
9074
|
+
function matchPermission(options, typed) {
|
|
9075
|
+
const wanted = typed.toLowerCase();
|
|
9076
|
+
return options.find((option) => option.value.toLowerCase() === wanted)?.value ?? null;
|
|
9077
|
+
}
|
|
9078
|
+
//#endregion
|
|
9079
|
+
//#region lib/types/keys.js
|
|
9080
|
+
/**
|
|
9081
|
+
* The key model: which action one press names in the region that holds the
|
|
9082
|
+
* keyboard, what one press types, how long a focus handoff silences the
|
|
9083
|
+
* editor's `Escape`, and the words every surface uses to name a key - the
|
|
9084
|
+
* legend each region degrades through, the entry keys the status bar
|
|
9085
|
+
* reserves, and the lines `/help` lists per region.
|
|
9086
|
+
*
|
|
9087
|
+
* Pure. It reads key bytes and returns actions, so the application owns every
|
|
9088
|
+
* effect and the whole map is decided without a terminal, a palette, or a
|
|
9089
|
+
* clock.
|
|
9090
|
+
* @module @deepseek-ai/dsh-tui-app/keys
|
|
9091
|
+
*/
|
|
9092
|
+
/** Characters a typed key never carries: C0 controls, DEL, and C1 controls. */
|
|
9093
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/u;
|
|
9094
|
+
/**
|
|
9095
|
+
* The text one key press types.
|
|
9096
|
+
* @param data - the bytes the terminal sent.
|
|
9097
|
+
* @returns the characters to type, or undefined for control keys and escape sequences.
|
|
9098
|
+
*/
|
|
9099
|
+
function typedText(data) {
|
|
9100
|
+
const kitty = decodeKittyPrintable(data);
|
|
9101
|
+
if (kitty !== void 0) return kitty;
|
|
9102
|
+
return CONTROL_CHARACTERS.test(data) ? void 0 : data;
|
|
9103
|
+
}
|
|
9104
|
+
/**
|
|
9105
|
+
* The legend of each region, in declared degradation steps: the widest first,
|
|
9106
|
+
* every next one narrower, the last the shortest form that still names the way
|
|
9107
|
+
* back to the input. One grammar throughout - the keys the region answers,
|
|
9108
|
+
* then where `Esc` goes - so a legend is read the same way on every surface.
|
|
9109
|
+
* The editor draws no legend of its own: the unfocused status bar names the
|
|
9110
|
+
* keys that leave it.
|
|
9111
|
+
*/
|
|
9112
|
+
const HINTS = {
|
|
9113
|
+
editor: [],
|
|
9114
|
+
transcript: [
|
|
9115
|
+
"↑↓ sections · ←→ parts · Space folds · Ctrl+G reader · Esc input",
|
|
9116
|
+
"↑↓ ←→ · Space folds · Esc input",
|
|
9117
|
+
"Esc input"
|
|
9118
|
+
],
|
|
9119
|
+
queue: [
|
|
9120
|
+
"↑↓ select · Enter steer · E edit · I inject · Esc input",
|
|
9121
|
+
"↑↓ · Enter steer · E edit · Esc input",
|
|
9122
|
+
"Esc input"
|
|
9123
|
+
],
|
|
9124
|
+
panel: [
|
|
9125
|
+
"↑↓ children · Enter opens · Tab regions · Esc input",
|
|
9126
|
+
"↑↓ children · Esc input",
|
|
9127
|
+
"Esc input"
|
|
9128
|
+
],
|
|
9129
|
+
bar: [
|
|
9130
|
+
"←→ segments · Enter details · Tab regions · Esc input",
|
|
9131
|
+
"←→ segments · Esc input",
|
|
9132
|
+
"Esc input"
|
|
9133
|
+
]
|
|
9134
|
+
};
|
|
9135
|
+
/**
|
|
9136
|
+
* The regions in the order `/help` lists them: the input first, because it is
|
|
9137
|
+
* where every other region is reached from and returned to. The screen stacks
|
|
9138
|
+
* them in another order, which {@link FocusRegion} states and the `Tab` walk
|
|
9139
|
+
* follows over the regions drawn right now.
|
|
9140
|
+
*/
|
|
9141
|
+
const FOCUS_REGIONS = [
|
|
9142
|
+
"editor",
|
|
9143
|
+
"transcript",
|
|
9144
|
+
"queue",
|
|
9145
|
+
"panel",
|
|
9146
|
+
"bar"
|
|
9147
|
+
];
|
|
9148
|
+
/** What each region is called where it is named rather than drawn. */
|
|
9149
|
+
const REGION_LABELS = {
|
|
9150
|
+
editor: "input",
|
|
9151
|
+
transcript: "conversation",
|
|
9152
|
+
queue: "follow-ups",
|
|
9153
|
+
panel: "subagent panel",
|
|
9154
|
+
bar: "status bar"
|
|
9155
|
+
};
|
|
9156
|
+
/** The two keys that leave the input when no follow-up waits. */
|
|
9157
|
+
const ENTRY_KEYS = "Shift+↑ read · Shift+↓ status";
|
|
9158
|
+
/** The same pair while follow-ups wait: Shift+↑ selects one instead of reading. */
|
|
9159
|
+
const QUEUE_ENTRY_KEYS = "Shift+↑ select · Shift+↓ status";
|
|
9160
|
+
/**
|
|
9161
|
+
* The keys the unfocused follow-ups list names: ↑ on an empty input revises
|
|
9162
|
+
* the newest follow-up, and Shift+↑ is the direction out of the input toward
|
|
9163
|
+
* whatever sits above it.
|
|
9164
|
+
*/
|
|
9165
|
+
const QUEUE_ENTRY_HINT = "↑ edit · Shift+↑ select";
|
|
9166
|
+
/**
|
|
9167
|
+
* The entry keys the unfocused status bar reserves before any fact is placed,
|
|
9168
|
+
* in declared degradation steps. Both directions are named: reaching the
|
|
9169
|
+
* conversation or a waiting follow-up, and reaching the bar, are the two
|
|
9170
|
+
* ways out of the input, and a key nobody can see is a key nobody presses.
|
|
9171
|
+
* @param drawn - whether follow-ups sit above the editor, which Shift+↑ enters.
|
|
9172
|
+
* @returns the widest pair first, then the compact form.
|
|
9173
|
+
*/
|
|
9174
|
+
function entryHints(drawn = {}) {
|
|
9175
|
+
return [drawn.queue === true ? QUEUE_ENTRY_KEYS : ENTRY_KEYS, "Shift+↑↓ nav"];
|
|
9176
|
+
}
|
|
9177
|
+
entryHints();
|
|
9178
|
+
/**
|
|
9179
|
+
* The widest legend step of one region.
|
|
9180
|
+
* @param region - the region holding the keyboard.
|
|
9181
|
+
* @returns the step a surface draws when the width holds it, and the empty
|
|
9182
|
+
* string for the editor, which draws no legend.
|
|
9183
|
+
*/
|
|
9184
|
+
function widestHint(region) {
|
|
9185
|
+
return HINTS[region][0] ?? "";
|
|
9186
|
+
}
|
|
9187
|
+
/**
|
|
9188
|
+
* What `/help` lists per region: the legend the region draws, then the coarse
|
|
9189
|
+
* keys no legend has room for. The legends are read from {@link HINTS} rather
|
|
9190
|
+
* than written again, so a surface and `/help` can never name a key
|
|
9191
|
+
* differently. The editor draws no legend, so its own keys are listed here and
|
|
9192
|
+
* nowhere else. This is the screen's summary, not the complete map; the
|
|
9193
|
+
* package README carries every binding.
|
|
9194
|
+
*/
|
|
9195
|
+
const KEY_LINES = {
|
|
9196
|
+
editor: [
|
|
9197
|
+
"Enter sends · Shift+Enter newline · ↑↓ history · Ctrl+S steers",
|
|
9198
|
+
"Shift+Tab effort list · Shift+←→ words",
|
|
9199
|
+
"@ completes paths and sessions · / completes commands · Tab takes one",
|
|
9200
|
+
"!cmd runs here · the next prompt can read it · !!cmd stays local",
|
|
9201
|
+
`${ENTRY_KEYS} · Ctrl+G reader`,
|
|
9202
|
+
"While follow-ups wait: ↑ on an empty input edits the newest · Shift+↑ selects one",
|
|
9203
|
+
"Ctrl+O folds every tool card and context row",
|
|
9204
|
+
"Ctrl+T todos · Ctrl+P parent session · Ctrl+L redraw · ? keys",
|
|
9205
|
+
"Ctrl+B moves running tool calls to the background · /jobs lists them",
|
|
9206
|
+
"Esc arms the stop · Esc again stops the turn · Esc cancels a running /compact",
|
|
9207
|
+
"Ctrl+C clears the input, twice quits · Ctrl+D quits an empty input"
|
|
9208
|
+
],
|
|
9209
|
+
transcript: [widestHint("transcript"), "Shift+↑↓ blocks · PgUp PgDn turns · Home End ends · Tab regions · Enter reads"],
|
|
9210
|
+
queue: [widestHint("queue")],
|
|
9211
|
+
panel: [widestHint("panel")],
|
|
9212
|
+
bar: [widestHint("bar")]
|
|
9213
|
+
};
|
|
9214
|
+
/** `Escape`, which every region answers. */
|
|
9215
|
+
const ESCAPE = { kind: "escape" };
|
|
9216
|
+
/** `Ctrl+O`, which every region answers. */
|
|
9217
|
+
const FOLD_ALL = { kind: "fold-all" };
|
|
9218
|
+
/** `Ctrl+G`, which every region answers. */
|
|
9219
|
+
const READER = { kind: "reader" };
|
|
9220
|
+
/** `Enter` on the held section, row, or segment. */
|
|
9221
|
+
const OPEN = { kind: "open" };
|
|
9222
|
+
/**
|
|
9223
|
+
* What one key press means where the keyboard is.
|
|
9224
|
+
*
|
|
9225
|
+
* `Escape`, `Ctrl+O`, `Ctrl+G`, `Ctrl+B`, `Ctrl+T`, `Ctrl+P`, and `Ctrl+L`
|
|
9226
|
+
* mean the same thing everywhere and are answered first. Everything else is
|
|
9227
|
+
* the region's own.
|
|
9228
|
+
* @param region - the region holding the keyboard.
|
|
9229
|
+
* @param data - the raw key bytes.
|
|
9230
|
+
* @returns the action to apply, or undefined when this region claims nothing
|
|
9231
|
+
* for the key: the editor lets pi-tui's own editor have it, and a docked
|
|
9232
|
+
* region consumes it without effect.
|
|
9233
|
+
*/
|
|
9234
|
+
function resolveKey(region, data) {
|
|
9235
|
+
if (matchesKey(data, "escape")) return ESCAPE;
|
|
9236
|
+
if (matchesKey(data, "ctrl+o")) return FOLD_ALL;
|
|
9237
|
+
if (matchesKey(data, "ctrl+g")) return READER;
|
|
9238
|
+
if (matchesKey(data, "ctrl+b")) return { kind: "background" };
|
|
9239
|
+
if (matchesKey(data, "ctrl+t")) return { kind: "todos" };
|
|
9240
|
+
if (matchesKey(data, "ctrl+p")) return { kind: "parent" };
|
|
9241
|
+
if (matchesKey(data, "ctrl+l")) return { kind: "redraw" };
|
|
9242
|
+
switch (region) {
|
|
9243
|
+
case "editor": return editorKey(data);
|
|
9244
|
+
case "transcript": return transcriptKey(data);
|
|
9245
|
+
case "queue": return queueKey(data);
|
|
9246
|
+
case "panel": return panelKey(data);
|
|
9247
|
+
case "bar": return barKey(data);
|
|
9248
|
+
/* v8 ignore next 2 -- closed-union exhaustiveness guard */
|
|
9249
|
+
default: return assertNever(region, "tui focus region");
|
|
9250
|
+
}
|
|
9251
|
+
}
|
|
9252
|
+
/**
|
|
9253
|
+
* What one key means while the editor holds the keyboard. Shift+Up and
|
|
9254
|
+
* Shift+Down leave along the stack: the application lands on the first
|
|
9255
|
+
* drawn region in that direction — follow-ups or the conversation above,
|
|
9256
|
+
* the subagent panel or the status bar below. `Up` is offered to the newest
|
|
9257
|
+
* follow-up first, and reaches the editor's history when none is taken.
|
|
9258
|
+
* @param data - the raw key bytes.
|
|
9259
|
+
* @returns the action, or undefined for every key pi-tui's editor owns.
|
|
9260
|
+
*/
|
|
9261
|
+
function editorKey(data) {
|
|
9262
|
+
if (matchesKey(data, "up")) return { kind: "edit-latest" };
|
|
9263
|
+
if (matchesKey(data, "shift+up")) return {
|
|
9264
|
+
kind: "leave",
|
|
9265
|
+
direction: "up"
|
|
9266
|
+
};
|
|
9267
|
+
if (matchesKey(data, "shift+down")) return {
|
|
9268
|
+
kind: "leave",
|
|
9269
|
+
direction: "down"
|
|
9270
|
+
};
|
|
9271
|
+
if (matchesKey(data, "ctrl+s")) return { kind: "steer" };
|
|
9272
|
+
if (matchesKey(data, "shift+tab")) return { kind: "effort" };
|
|
9273
|
+
if (data === "?") return { kind: "help" };
|
|
9274
|
+
}
|
|
9275
|
+
/**
|
|
9276
|
+
* The transcript's movement keys: the arrows step one section and one part,
|
|
9277
|
+
* the shift arrows a whole block and the ends of the held block, `PageUp` and
|
|
9278
|
+
* `PageDown` a turn, and `Home` and `End` the ends of the transcript.
|
|
9279
|
+
*/
|
|
9280
|
+
const TRANSCRIPT_MOVES = [
|
|
9281
|
+
{
|
|
9282
|
+
key: "up",
|
|
9283
|
+
axis: "section",
|
|
9284
|
+
to: "previous"
|
|
9285
|
+
},
|
|
9286
|
+
{
|
|
9287
|
+
key: "down",
|
|
9288
|
+
axis: "section",
|
|
9289
|
+
to: "next"
|
|
9290
|
+
},
|
|
9291
|
+
{
|
|
9292
|
+
key: "shift+up",
|
|
9293
|
+
axis: "block",
|
|
9294
|
+
to: "previous"
|
|
9295
|
+
},
|
|
9296
|
+
{
|
|
9297
|
+
key: "shift+down",
|
|
9298
|
+
axis: "block",
|
|
9299
|
+
to: "next"
|
|
9300
|
+
},
|
|
9301
|
+
{
|
|
9302
|
+
key: "pageUp",
|
|
9303
|
+
axis: "turn",
|
|
9304
|
+
to: "previous"
|
|
9305
|
+
},
|
|
9306
|
+
{
|
|
9307
|
+
key: "pageDown",
|
|
9308
|
+
axis: "turn",
|
|
9309
|
+
to: "next"
|
|
9310
|
+
},
|
|
9311
|
+
{
|
|
9312
|
+
key: "home",
|
|
9313
|
+
axis: "section",
|
|
9314
|
+
to: "first"
|
|
9315
|
+
},
|
|
9316
|
+
{
|
|
9317
|
+
key: "end",
|
|
9318
|
+
axis: "section",
|
|
9319
|
+
to: "last"
|
|
9320
|
+
},
|
|
9321
|
+
{
|
|
9322
|
+
key: "left",
|
|
9323
|
+
axis: "part",
|
|
9324
|
+
to: "previous"
|
|
9325
|
+
},
|
|
9326
|
+
{
|
|
9327
|
+
key: "right",
|
|
9328
|
+
axis: "part",
|
|
9329
|
+
to: "next"
|
|
9330
|
+
},
|
|
9331
|
+
{
|
|
9332
|
+
key: "shift+left",
|
|
9333
|
+
axis: "part",
|
|
9334
|
+
to: "first"
|
|
9335
|
+
},
|
|
9336
|
+
{
|
|
9337
|
+
key: "shift+right",
|
|
9338
|
+
axis: "part",
|
|
9339
|
+
to: "last"
|
|
9340
|
+
}
|
|
9341
|
+
];
|
|
9342
|
+
/** The pending-prompt panel's movement keys. */
|
|
9343
|
+
const QUEUE_MOVES = [
|
|
9344
|
+
{
|
|
9345
|
+
key: "up",
|
|
9346
|
+
axis: "prompt",
|
|
9347
|
+
to: "previous"
|
|
9348
|
+
},
|
|
9349
|
+
{
|
|
9350
|
+
key: "down",
|
|
9351
|
+
axis: "prompt",
|
|
9352
|
+
to: "next"
|
|
9353
|
+
},
|
|
9354
|
+
{
|
|
9355
|
+
key: "home",
|
|
9356
|
+
axis: "prompt",
|
|
9357
|
+
to: "first"
|
|
9358
|
+
},
|
|
9359
|
+
{
|
|
9360
|
+
key: "end",
|
|
9361
|
+
axis: "prompt",
|
|
9362
|
+
to: "last"
|
|
9363
|
+
}
|
|
9364
|
+
];
|
|
9365
|
+
/**
|
|
9366
|
+
* The subagent panel's movement keys. The panel lists at most six rows, so
|
|
9367
|
+
* every coarse key means the same thing there: its first row or its last.
|
|
9368
|
+
*/
|
|
9369
|
+
const PANEL_MOVES = [
|
|
9370
|
+
{
|
|
9371
|
+
key: "up",
|
|
9372
|
+
axis: "row",
|
|
9373
|
+
to: "previous"
|
|
9374
|
+
},
|
|
9375
|
+
{
|
|
9376
|
+
key: "down",
|
|
9377
|
+
axis: "row",
|
|
9378
|
+
to: "next"
|
|
9379
|
+
},
|
|
9380
|
+
{
|
|
9381
|
+
key: "shift+up",
|
|
9382
|
+
axis: "row",
|
|
9383
|
+
to: "first"
|
|
9384
|
+
},
|
|
9385
|
+
{
|
|
9386
|
+
key: "home",
|
|
9387
|
+
axis: "row",
|
|
9388
|
+
to: "first"
|
|
9389
|
+
},
|
|
9390
|
+
{
|
|
9391
|
+
key: "pageUp",
|
|
9392
|
+
axis: "row",
|
|
9393
|
+
to: "first"
|
|
9394
|
+
},
|
|
9395
|
+
{
|
|
9396
|
+
key: "shift+down",
|
|
9397
|
+
axis: "row",
|
|
9398
|
+
to: "last"
|
|
9399
|
+
},
|
|
9400
|
+
{
|
|
9401
|
+
key: "end",
|
|
9402
|
+
axis: "row",
|
|
9403
|
+
to: "last"
|
|
9404
|
+
},
|
|
9405
|
+
{
|
|
9406
|
+
key: "pageDown",
|
|
9407
|
+
axis: "row",
|
|
9408
|
+
to: "last"
|
|
9409
|
+
}
|
|
9410
|
+
];
|
|
9411
|
+
/** The status bar's movement keys, along its one axis of segments. */
|
|
9412
|
+
const BAR_MOVES = [
|
|
9413
|
+
{
|
|
9414
|
+
key: "left",
|
|
9415
|
+
axis: "segment",
|
|
9416
|
+
to: "previous"
|
|
9417
|
+
},
|
|
9418
|
+
{
|
|
9419
|
+
key: "right",
|
|
9420
|
+
axis: "segment",
|
|
9421
|
+
to: "next"
|
|
9422
|
+
},
|
|
9423
|
+
{
|
|
9424
|
+
key: "shift+left",
|
|
9425
|
+
axis: "segment",
|
|
9426
|
+
to: "first"
|
|
9427
|
+
},
|
|
9428
|
+
{
|
|
9429
|
+
key: "home",
|
|
9430
|
+
axis: "segment",
|
|
9431
|
+
to: "first"
|
|
9432
|
+
},
|
|
9433
|
+
{
|
|
9434
|
+
key: "pageUp",
|
|
9435
|
+
axis: "segment",
|
|
9436
|
+
to: "first"
|
|
9437
|
+
},
|
|
9438
|
+
{
|
|
9439
|
+
key: "shift+right",
|
|
9440
|
+
axis: "segment",
|
|
9441
|
+
to: "last"
|
|
9442
|
+
},
|
|
9443
|
+
{
|
|
9444
|
+
key: "end",
|
|
9445
|
+
axis: "segment",
|
|
9446
|
+
to: "last"
|
|
9447
|
+
},
|
|
9448
|
+
{
|
|
9449
|
+
key: "pageDown",
|
|
9450
|
+
axis: "segment",
|
|
9451
|
+
to: "last"
|
|
9452
|
+
}
|
|
9453
|
+
];
|
|
9454
|
+
/**
|
|
9455
|
+
* What one press moves, in one region's table.
|
|
9456
|
+
* @param data - the raw key bytes.
|
|
9457
|
+
* @param bindings - the region's movement keys.
|
|
9458
|
+
* @returns the movement action, or undefined when the table has no binding for the key.
|
|
9089
9459
|
*/
|
|
9090
|
-
function
|
|
9091
|
-
const
|
|
9092
|
-
return
|
|
9460
|
+
function moveKey(data, bindings) {
|
|
9461
|
+
const binding = bindings.find((candidate) => matchesKey(data, candidate.key));
|
|
9462
|
+
return binding === void 0 ? void 0 : {
|
|
9463
|
+
kind: "move",
|
|
9464
|
+
axis: binding.axis,
|
|
9465
|
+
to: binding.to
|
|
9466
|
+
};
|
|
9093
9467
|
}
|
|
9094
9468
|
/**
|
|
9095
|
-
*
|
|
9096
|
-
*
|
|
9097
|
-
* @param
|
|
9098
|
-
* @
|
|
9099
|
-
* @returns a confirmation row.
|
|
9100
|
-
* @throws {Error} when no settings service is mounted or the namespace is not registered.
|
|
9469
|
+
* `Tab` and `Shift+Tab`, which every region under the editor reads as the
|
|
9470
|
+
* walk between the regions that are drawn.
|
|
9471
|
+
* @param data - the raw key bytes.
|
|
9472
|
+
* @returns the cycling action, or undefined for any other key.
|
|
9101
9473
|
*/
|
|
9102
|
-
|
|
9103
|
-
if (
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
}
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
return `web search: OpenRouter ${chosen}`;
|
|
9474
|
+
function cycleKey(data) {
|
|
9475
|
+
if (matchesKey(data, "tab")) return {
|
|
9476
|
+
kind: "cycle",
|
|
9477
|
+
step: 1
|
|
9478
|
+
};
|
|
9479
|
+
if (matchesKey(data, "shift+tab")) return {
|
|
9480
|
+
kind: "cycle",
|
|
9481
|
+
step: -1
|
|
9482
|
+
};
|
|
9112
9483
|
}
|
|
9113
|
-
//#endregion
|
|
9114
|
-
//#region lib/types/permission.js
|
|
9115
9484
|
/**
|
|
9116
|
-
*
|
|
9117
|
-
*
|
|
9118
|
-
*
|
|
9485
|
+
* What one key means while the transcript holds the keyboard. `Space` is the
|
|
9486
|
+
* one printable key the transcript keeps for itself: folding the held block is
|
|
9487
|
+
* its primary verb, and a leading space would be trimmed off a prompt anyway.
|
|
9488
|
+
* @param data - the raw key bytes.
|
|
9489
|
+
* @returns the action, or undefined for a key the transcript consumes without effect.
|
|
9119
9490
|
*/
|
|
9491
|
+
function transcriptKey(data) {
|
|
9492
|
+
const move = moveKey(data, TRANSCRIPT_MOVES);
|
|
9493
|
+
if (move !== void 0) return move;
|
|
9494
|
+
if (matchesKey(data, "enter")) return OPEN;
|
|
9495
|
+
if (matchesKey(data, "space")) return { kind: "fold" };
|
|
9496
|
+
return cycleKey(data) ?? typeKey(data);
|
|
9497
|
+
}
|
|
9120
9498
|
/**
|
|
9121
|
-
*
|
|
9122
|
-
* @param
|
|
9123
|
-
* @
|
|
9124
|
-
* @returns the catalog label, or the raw id when the catalog no longer lists it.
|
|
9499
|
+
* What one key means while the follow-ups panel holds the keyboard.
|
|
9500
|
+
* @param data - the raw key bytes.
|
|
9501
|
+
* @returns the action, or undefined for a key the panel consumes without effect.
|
|
9125
9502
|
*/
|
|
9126
|
-
function
|
|
9127
|
-
|
|
9503
|
+
function queueKey(data) {
|
|
9504
|
+
const move = moveKey(data, QUEUE_MOVES);
|
|
9505
|
+
if (move !== void 0) return move;
|
|
9506
|
+
if (matchesKey(data, "enter")) return {
|
|
9507
|
+
kind: "queue",
|
|
9508
|
+
action: "steer"
|
|
9509
|
+
};
|
|
9510
|
+
if (data === "s" || data === "S") return {
|
|
9511
|
+
kind: "queue",
|
|
9512
|
+
action: "steer"
|
|
9513
|
+
};
|
|
9514
|
+
if (data === "i" || data === "I") return {
|
|
9515
|
+
kind: "queue",
|
|
9516
|
+
action: "inject"
|
|
9517
|
+
};
|
|
9518
|
+
if (data === "e" || data === "E") return {
|
|
9519
|
+
kind: "queue",
|
|
9520
|
+
action: "edit"
|
|
9521
|
+
};
|
|
9522
|
+
return cycleKey(data) ?? typeKey(data);
|
|
9128
9523
|
}
|
|
9129
9524
|
/**
|
|
9130
|
-
*
|
|
9131
|
-
* @param
|
|
9132
|
-
* @returns the
|
|
9525
|
+
* What one key means while the subagent panel holds the keyboard.
|
|
9526
|
+
* @param data - the raw key bytes.
|
|
9527
|
+
* @returns the action, or undefined for a key the panel consumes without effect.
|
|
9133
9528
|
*/
|
|
9134
|
-
function
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
}));
|
|
9529
|
+
function panelKey(data) {
|
|
9530
|
+
const move = moveKey(data, PANEL_MOVES);
|
|
9531
|
+
if (move !== void 0) return move;
|
|
9532
|
+
if (matchesKey(data, "enter") || matchesKey(data, "right")) return OPEN;
|
|
9533
|
+
return cycleKey(data) ?? typeKey(data);
|
|
9140
9534
|
}
|
|
9141
9535
|
/**
|
|
9142
|
-
*
|
|
9143
|
-
*
|
|
9144
|
-
* @param
|
|
9145
|
-
* @returns
|
|
9536
|
+
* What one key means while the status bar holds the keyboard. The bar is the
|
|
9537
|
+
* bottom of the stack, so `Up` leaves it and `Down` does nothing.
|
|
9538
|
+
* @param data - the raw key bytes.
|
|
9539
|
+
* @returns the action, or undefined for a key the bar consumes without effect.
|
|
9146
9540
|
*/
|
|
9147
|
-
function
|
|
9148
|
-
|
|
9541
|
+
function barKey(data) {
|
|
9542
|
+
const move = moveKey(data, BAR_MOVES);
|
|
9543
|
+
if (move !== void 0) return move;
|
|
9544
|
+
if (matchesKey(data, "up")) return {
|
|
9545
|
+
kind: "leave",
|
|
9546
|
+
direction: "up"
|
|
9547
|
+
};
|
|
9548
|
+
if (matchesKey(data, "shift+up")) return {
|
|
9549
|
+
kind: "focus",
|
|
9550
|
+
region: "transcript"
|
|
9551
|
+
};
|
|
9552
|
+
if (matchesKey(data, "shift+down")) return {
|
|
9553
|
+
kind: "focus",
|
|
9554
|
+
region: "bar"
|
|
9555
|
+
};
|
|
9556
|
+
if (matchesKey(data, "enter")) return OPEN;
|
|
9557
|
+
return cycleKey(data) ?? typeKey(data);
|
|
9149
9558
|
}
|
|
9150
9559
|
/**
|
|
9151
|
-
* The
|
|
9152
|
-
*
|
|
9153
|
-
* @param
|
|
9154
|
-
* @
|
|
9155
|
-
* @returns the catalog value, or null when nothing matches.
|
|
9560
|
+
* The printable law: a key that types something hands the keyboard back to
|
|
9561
|
+
* the editor and lands at its caret.
|
|
9562
|
+
* @param data - the raw key bytes.
|
|
9563
|
+
* @returns the typing action, or undefined for a key that types nothing.
|
|
9156
9564
|
*/
|
|
9157
|
-
function
|
|
9158
|
-
const
|
|
9159
|
-
return
|
|
9565
|
+
function typeKey(data) {
|
|
9566
|
+
const text = typedText(data);
|
|
9567
|
+
return text === void 0 ? void 0 : {
|
|
9568
|
+
kind: "type",
|
|
9569
|
+
text
|
|
9570
|
+
};
|
|
9160
9571
|
}
|
|
9161
9572
|
//#endregion
|
|
9162
9573
|
//#region lib/types/prompts.js
|
|
@@ -10148,7 +10559,7 @@ var ViewBanner = class {
|
|
|
10148
10559
|
/** What the chip names this mode. */
|
|
10149
10560
|
const READ_CHIP = "READ";
|
|
10150
10561
|
/** What separates two labels of the parts strip. */
|
|
10151
|
-
const SEPARATOR$
|
|
10562
|
+
const SEPARATOR$3 = " · ";
|
|
10152
10563
|
/** What the heading appends while the focused block lies outside the repaint window. */
|
|
10153
10564
|
const OFF_SCREEN = " · off screen";
|
|
10154
10565
|
/** Opens the numbered parts strip, so Left/Right read as a walk along this row. */
|
|
@@ -10223,7 +10634,7 @@ function partsStrip(parts, palette, width) {
|
|
|
10223
10634
|
const text = `${String(index + 1)} ${part.label}`;
|
|
10224
10635
|
return part.focused ? palette.accent(`[${text}]`) : palette.dim(text);
|
|
10225
10636
|
});
|
|
10226
|
-
const sep = palette.dim(SEPARATOR$
|
|
10637
|
+
const sep = palette.dim(SEPARATOR$3);
|
|
10227
10638
|
const indent = palette.dim(" ");
|
|
10228
10639
|
const end = palette.dim(STRIP_END);
|
|
10229
10640
|
const indentWidth = visibleWidth(" ");
|
|
@@ -10242,7 +10653,7 @@ function partsStrip(parts, palette, width) {
|
|
|
10242
10653
|
if (token === void 0) continue;
|
|
10243
10654
|
const extra = index === tokens.length - 1 ? endWidth : 0;
|
|
10244
10655
|
let leading = index === 0 || current === indent ? "" : sep;
|
|
10245
|
-
let leadingWidth = leading === "" ? 0 : visibleWidth(SEPARATOR$
|
|
10656
|
+
let leadingWidth = leading === "" ? 0 : visibleWidth(SEPARATOR$3);
|
|
10246
10657
|
const tokenWidth = visibleWidth(token);
|
|
10247
10658
|
if (used + leadingWidth + tokenWidth + extra > width && used > indentWidth) {
|
|
10248
10659
|
startLine();
|
|
@@ -10324,7 +10735,7 @@ var InspectorPane = class {
|
|
|
10324
10735
|
* @module @deepseek-ai/dsh-tui-app/navigation
|
|
10325
10736
|
*/
|
|
10326
10737
|
/** What separates two facts inside one heading. */
|
|
10327
|
-
const SEPARATOR$
|
|
10738
|
+
const SEPARATOR$2 = " · ";
|
|
10328
10739
|
/**
|
|
10329
10740
|
* Whether one transcript child is navigable.
|
|
10330
10741
|
* @param child - a child of the transcript container.
|
|
@@ -10678,7 +11089,7 @@ function subjectOf(block, part) {
|
|
|
10678
11089
|
* @returns the label, e.g. `bash git status · result`.
|
|
10679
11090
|
*/
|
|
10680
11091
|
function sectionLabel(block, part) {
|
|
10681
|
-
return subjectOf(block, part).join(SEPARATOR$
|
|
11092
|
+
return subjectOf(block, part).join(SEPARATOR$2);
|
|
10682
11093
|
}
|
|
10683
11094
|
/**
|
|
10684
11095
|
* The inspector heading of the held section: its position in the transcript,
|
|
@@ -10695,7 +11106,7 @@ function sectionHeading(cursor, blocks) {
|
|
|
10695
11106
|
`${String(cursor.block + 1)}/${String(blocks.length)}`,
|
|
10696
11107
|
`turn ${String(block.turn)}`,
|
|
10697
11108
|
sectionLabel(block, part)
|
|
10698
|
-
].join(SEPARATOR$
|
|
11109
|
+
].join(SEPARATOR$2);
|
|
10699
11110
|
}
|
|
10700
11111
|
/**
|
|
10701
11112
|
* The parts strip of the held block.
|
|
@@ -11125,7 +11536,7 @@ function plural$1(count, noun) {
|
|
|
11125
11536
|
/** The segment focus enters the bar on; `buildFooterSegments` always emits it first. */
|
|
11126
11537
|
const FIRST_FOOTER_SEGMENT = "model";
|
|
11127
11538
|
/** What separates two segments, and two parts inside a hint line. */
|
|
11128
|
-
const SEPARATOR$
|
|
11539
|
+
const SEPARATOR$1 = " · ";
|
|
11129
11540
|
/**
|
|
11130
11541
|
* Longest workspace label the bar draws in full. A wider path keeps its last
|
|
11131
11542
|
* two segments behind `…/` so one long project path cannot crowd out the
|
|
@@ -11276,7 +11687,7 @@ function buildFooterSegments(inputs) {
|
|
|
11276
11687
|
`turn ${String(turn.number)}`,
|
|
11277
11688
|
`started: ${formatTimestamp(turn.startedAt)}`,
|
|
11278
11689
|
`elapsed: ${turn.elapsed}`,
|
|
11279
|
-
`queued: ${String(turn.queuedNextTurn)} for the next turn${SEPARATOR$
|
|
11690
|
+
`queued: ${String(turn.queuedNextTurn)} for the next turn${SEPARATOR$1}${String(turn.queuedNextStep)} for the next step`
|
|
11280
11691
|
])
|
|
11281
11692
|
});
|
|
11282
11693
|
if (inputs.usage !== "") segments.push({
|
|
@@ -11312,7 +11723,7 @@ function buildFooterSegments(inputs) {
|
|
|
11312
11723
|
if (inputs.attachments.length > 0) segments.push({
|
|
11313
11724
|
id: "attachments",
|
|
11314
11725
|
label: `${String(inputs.attachments.length)} attached`,
|
|
11315
|
-
detail: printed([...inputs.attachments.map((attachment) => `${attachment.kind}: ${attachment.name}`), `/attach <path> adds one${SEPARATOR$
|
|
11726
|
+
detail: printed([...inputs.attachments.map((attachment) => `${attachment.kind}: ${attachment.name}`), `/attach <path> adds one${SEPARATOR$1}/attach clear drops them all`])
|
|
11316
11727
|
});
|
|
11317
11728
|
return segments;
|
|
11318
11729
|
}
|
|
@@ -11403,7 +11814,7 @@ function middleFacts(facts, hidden, room) {
|
|
|
11403
11814
|
const drawn = [];
|
|
11404
11815
|
let used = 0;
|
|
11405
11816
|
for (const label of facts) {
|
|
11406
|
-
const cost = visibleWidth(SEPARATOR$
|
|
11817
|
+
const cost = visibleWidth(SEPARATOR$1) + visibleWidth(label);
|
|
11407
11818
|
if (used + cost > room) break;
|
|
11408
11819
|
used += cost;
|
|
11409
11820
|
drawn.push(label);
|
|
@@ -11411,9 +11822,9 @@ function middleFacts(facts, hidden, room) {
|
|
|
11411
11822
|
let folded = hidden + facts.length - drawn.length;
|
|
11412
11823
|
if (folded === 0) return drawn;
|
|
11413
11824
|
const token = () => `+${String(folded)}`;
|
|
11414
|
-
const fits = () => used + visibleWidth(SEPARATOR$
|
|
11825
|
+
const fits = () => used + visibleWidth(SEPARATOR$1) + visibleWidth(token()) <= room;
|
|
11415
11826
|
while (!fits() && drawn.length > 0) {
|
|
11416
|
-
used -= visibleWidth(SEPARATOR$
|
|
11827
|
+
used -= visibleWidth(SEPARATOR$1) + visibleWidth(drawn.pop());
|
|
11417
11828
|
folded += 1;
|
|
11418
11829
|
}
|
|
11419
11830
|
if (fits()) drawn.push(token());
|
|
@@ -11441,7 +11852,7 @@ function unfocusedLine(segments, palette, width, queue) {
|
|
|
11441
11852
|
return palette.dim(segment.label);
|
|
11442
11853
|
});
|
|
11443
11854
|
const drawn = middleFacts(facts, rest.length - facts.length, width - visibleWidth(model) - reserved);
|
|
11444
|
-
const left = [model === "" ? "" : palette.model(model), ...drawn].filter((token) => token !== "").join(palette.dim(SEPARATOR$
|
|
11855
|
+
const left = [model === "" ? "" : palette.model(model), ...drawn].filter((token) => token !== "").join(palette.dim(SEPARATOR$1));
|
|
11445
11856
|
if (hint === "") return fitLine(left, width);
|
|
11446
11857
|
return fitLine(`${left}${" ".repeat(Math.max(1, width - visibleWidth(left) - visibleWidth(hint)))}${paintKeys(palette, hint, palette.link)}`, width);
|
|
11447
11858
|
}
|
|
@@ -11468,7 +11879,7 @@ function expansionBody(segment) {
|
|
|
11468
11879
|
function expansionLine(segment, palette, width) {
|
|
11469
11880
|
const body = expansionBody(segment);
|
|
11470
11881
|
const legend = paintKeys(palette, fitLegend(HINTS.bar, width));
|
|
11471
|
-
const suffix = body === "" ? legend : `${palette.dim(SEPARATOR$
|
|
11882
|
+
const suffix = body === "" ? legend : `${palette.dim(SEPARATOR$1)}${legend}`;
|
|
11472
11883
|
const prefix = palette.dim(body);
|
|
11473
11884
|
const rest = width - visibleWidth(suffix);
|
|
11474
11885
|
if (rest < 1) return fitLine(`${prefix}${suffix}`, width);
|
|
@@ -11517,8 +11928,8 @@ function fitSelected(text, room) {
|
|
|
11517
11928
|
*/
|
|
11518
11929
|
function focusedWindow(rest, held, palette, room, level) {
|
|
11519
11930
|
if (rest.length === 0) return "";
|
|
11520
|
-
const sep = palette.dim(SEPARATOR$
|
|
11521
|
-
const sepWidth = visibleWidth(SEPARATOR$
|
|
11931
|
+
const sep = palette.dim(SEPARATOR$1);
|
|
11932
|
+
const sepWidth = visibleWidth(SEPARATOR$1);
|
|
11522
11933
|
const selected = Math.max(0, held);
|
|
11523
11934
|
const budget = room - sepWidth;
|
|
11524
11935
|
const cap = budget - (selected < rest.length - 1 ? WINDOW_MARK_WIDTH : 0);
|
|
@@ -11589,20 +12000,39 @@ var FooterBar = class {
|
|
|
11589
12000
|
});
|
|
11590
12001
|
}
|
|
11591
12002
|
};
|
|
11592
|
-
/**
|
|
11593
|
-
const
|
|
12003
|
+
/** Narration characters kept per child; the row cuts it to its width again. */
|
|
12004
|
+
const NARRATION_MAX_CHARS = 240;
|
|
12005
|
+
/** What separates a descendant's label from what it said. */
|
|
12006
|
+
const NOTE_SEPARATOR = " › ";
|
|
12007
|
+
/** Share of the row a descendant's label may take when it also draws a note. */
|
|
12008
|
+
const LABEL_SHARE = .4;
|
|
12009
|
+
/** Columns a label keeps however narrow the row is. */
|
|
12010
|
+
const LABEL_MIN_COLUMNS = 12;
|
|
12011
|
+
/** Fewest columns a note is worth drawing in; a narrower row draws the label alone. */
|
|
12012
|
+
const NOTE_MIN_COLUMNS = 6;
|
|
12013
|
+
/** Glyph a settled descendant row leads with, by outcome. */
|
|
12014
|
+
const SUBAGENT_SETTLED_GLYPH = {
|
|
12015
|
+
done: "✓",
|
|
12016
|
+
stopped: "✗"
|
|
12017
|
+
};
|
|
11594
12018
|
/**
|
|
11595
12019
|
* Build one board draw: todos in write order cut to
|
|
11596
|
-
* {@link ACTIVITY_BOARD_MAX_TODOS}, plus the
|
|
11597
|
-
*
|
|
11598
|
-
* @
|
|
12020
|
+
* {@link ACTIVITY_BOARD_MAX_TODOS}, plus the descendants, running before
|
|
12021
|
+
* settled and each group in first-seen order, cut to
|
|
12022
|
+
* {@link ACTIVITY_BOARD_MAX_SUBAGENTS}.
|
|
12023
|
+
* @param inputs - the current list and the descendants the turn has seen.
|
|
12024
|
+
* @returns the drawn rows and the count of each kind they left out.
|
|
11599
12025
|
*/
|
|
11600
12026
|
function activityBoardView(inputs) {
|
|
11601
12027
|
const todos = inputs.todos.slice(0, 4).map(rowOf$1);
|
|
12028
|
+
const children = inputs.subagents ?? [];
|
|
12029
|
+
const ordered = [...children.filter((child) => child.state === "running"), ...children.filter((child) => child.state !== "running")];
|
|
12030
|
+
const subagents = ordered.slice(0, 3);
|
|
11602
12031
|
return {
|
|
11603
12032
|
todos,
|
|
11604
12033
|
hidden: inputs.todos.length - todos.length,
|
|
11605
|
-
|
|
12034
|
+
subagents,
|
|
12035
|
+
hiddenSubagents: ordered.length - subagents.length
|
|
11606
12036
|
};
|
|
11607
12037
|
}
|
|
11608
12038
|
/**
|
|
@@ -11618,27 +12048,16 @@ function rowOf$1(item) {
|
|
|
11618
12048
|
};
|
|
11619
12049
|
}
|
|
11620
12050
|
/**
|
|
11621
|
-
*
|
|
11622
|
-
*
|
|
11623
|
-
*
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
const parts = [line.label, line.status];
|
|
11627
|
-
if (line.summary !== void 0 && line.summary !== "") parts.push(line.summary);
|
|
11628
|
-
return parts.join(SEPARATOR$1);
|
|
11629
|
-
}
|
|
11630
|
-
/**
|
|
11631
|
-
* The status and summary one tool result draws on the descendant line.
|
|
11632
|
-
* @param firstRow - the first presented result row, when the result had one.
|
|
11633
|
-
* @param isError - whether the result is an error.
|
|
11634
|
-
* @returns `error` plus the row, the row alone, or `done` when the result had no row.
|
|
12051
|
+
* What a child said it is doing, from one of its assistant messages: the last
|
|
12052
|
+
* sentence of its text, without markdown or code blocks, on one line.
|
|
12053
|
+
* Reasoning is not narration, so the caller passes text blocks only.
|
|
12054
|
+
* @param text - the message's text blocks joined.
|
|
12055
|
+
* @returns the sentence, or undefined when the text holds no prose to show.
|
|
11635
12056
|
*/
|
|
11636
|
-
function
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
};
|
|
11641
|
-
return { status: firstRow === void 0 || firstRow === "" ? "done" : firstRow };
|
|
12057
|
+
function activityNarration(text) {
|
|
12058
|
+
const narration = (text.replace(/```[\s\S]*?(?:```|$)/gu, "\n").replace(/!?\[([^\]]*)\]\([^)]*\)/gu, "$1").replace(/^\s{0,3}(?:#{1,6}|>|[-*+]|\d+[.)])\s+/gmu, "").replace(/\*\*|__|~~|`/gu, "").split("\n").map((row) => row.trim()).findLast((row) => row !== "")?.split(/(?<=[.!?])\s+/u).findLast((part) => part.trim() !== ""))?.replace(/\s+/gu, " ").trim();
|
|
12059
|
+
if (narration === void 0 || narration === "") return void 0;
|
|
12060
|
+
return narration.length > NARRATION_MAX_CHARS ? `${narration.slice(0, NARRATION_MAX_CHARS - 1)}…` : narration;
|
|
11642
12061
|
}
|
|
11643
12062
|
/**
|
|
11644
12063
|
* The status word a child `turn/end` draws: the existing notice, or `done`.
|
|
@@ -11657,13 +12076,22 @@ function spinningTodos(view) {
|
|
|
11657
12076
|
return view.todos.filter((row) => row.status === "in_progress").map((row) => row.content);
|
|
11658
12077
|
}
|
|
11659
12078
|
/**
|
|
12079
|
+
* The descendant rows of one board draw that a spinner animates.
|
|
12080
|
+
* @param view - the rows one draw produced.
|
|
12081
|
+
* @returns the session id of every drawn running descendant, in draw order.
|
|
12082
|
+
*/
|
|
12083
|
+
function spinningSubagents(view) {
|
|
12084
|
+
return view.subagents.filter((child) => child.state === "running").map((child) => child.id);
|
|
12085
|
+
}
|
|
12086
|
+
/**
|
|
11660
12087
|
* Render the board. Todo rows lead with status-colored glyphs, an in-progress
|
|
11661
12088
|
* one with its spinner frame when one is given; completed content is dim and
|
|
11662
12089
|
* scratched out. A list past the cap ends on `+<n> more`.
|
|
11663
|
-
* The descendant
|
|
11664
|
-
*
|
|
12090
|
+
* The descendant rows are last, each with its own glyph, label, and note, and
|
|
12091
|
+
* a descendant list past the cap ends on its own `+<n> more`. An empty view
|
|
12092
|
+
* returns the empty string so the slot can unmount.
|
|
11665
12093
|
* @param view - the rows one draw produced.
|
|
11666
|
-
* @param render - the palette
|
|
12094
|
+
* @param render - the palette, the fades still moving, and the width.
|
|
11667
12095
|
* @returns the board text, or the empty string when nothing is drawn.
|
|
11668
12096
|
*/
|
|
11669
12097
|
function renderActivityBoard(view, render) {
|
|
@@ -11676,10 +12104,34 @@ function renderActivityBoard(view, render) {
|
|
|
11676
12104
|
lines.push(fadedLine(`${paint(glyph)} ${content}`, render.todoFades?.get(row.content)));
|
|
11677
12105
|
}
|
|
11678
12106
|
if (view.hidden > 0) lines.push(palette.dim(`+${String(view.hidden)} more`));
|
|
11679
|
-
|
|
12107
|
+
for (const child of view.subagents) lines.push(fadedLine(subagentLine(child, render), render.subagentFades?.get(child.id)));
|
|
12108
|
+
if (view.hiddenSubagents > 0) lines.push(palette.dim(`+${String(view.hiddenSubagents)} more subagents`));
|
|
11680
12109
|
return lines.join("\n");
|
|
11681
12110
|
}
|
|
11682
12111
|
/**
|
|
12112
|
+
* One descendant as a row that fits one terminal line: glyph, the label cut
|
|
12113
|
+
* to its share of the row, and the note in the room that is left.
|
|
12114
|
+
* @param child - the descendant row.
|
|
12115
|
+
* @param render - the palette, the running spinner frames, and the width.
|
|
12116
|
+
* @returns the styled row.
|
|
12117
|
+
*/
|
|
12118
|
+
function subagentLine(child, render) {
|
|
12119
|
+
const { palette } = render;
|
|
12120
|
+
const settled = child.state !== "running";
|
|
12121
|
+
const glyph = child.state === "running" ? palette.warning(render.subagentSpinners?.get(child.id) ?? TODO_GLYPH.in_progress) : child.state === "done" ? palette.success(SUBAGENT_SETTLED_GLYPH.done) : palette.error(SUBAGENT_SETTLED_GLYPH.stopped);
|
|
12122
|
+
const paintLabel = (text) => settled ? palette.dim(text) : text;
|
|
12123
|
+
const room = Math.max(0, render.width - 2);
|
|
12124
|
+
const note = child.note;
|
|
12125
|
+
const noteless = `${glyph} ${paintLabel(truncateToWidth(child.label, room, "…"))}`;
|
|
12126
|
+
if (note === void 0 || note === "") return noteless;
|
|
12127
|
+
const label = truncateToWidth(child.label, Math.max(LABEL_MIN_COLUMNS, Math.floor(room * LABEL_SHARE)), "…");
|
|
12128
|
+
const noteRoom = room - visibleWidth(label) - visibleWidth(NOTE_SEPARATOR);
|
|
12129
|
+
if (noteRoom < NOTE_MIN_COLUMNS) return noteless;
|
|
12130
|
+
const shown = truncateToWidth(note, noteRoom, "…");
|
|
12131
|
+
const paintNote = child.state === "stopped" ? palette.error : settled ? palette.dim : (text) => text;
|
|
12132
|
+
return `${glyph} ${paintLabel(label)}${palette.dim(NOTE_SEPARATOR)}${paintNote(shown)}`;
|
|
12133
|
+
}
|
|
12134
|
+
/**
|
|
11683
12135
|
* Draw one row at the mix its fade reports.
|
|
11684
12136
|
* @param text - the settled row.
|
|
11685
12137
|
* @param fade - the row's fade; absent for a row that never faded.
|
|
@@ -15242,7 +15694,7 @@ const LOCAL_COMMANDS = [
|
|
|
15242
15694
|
},
|
|
15243
15695
|
{
|
|
15244
15696
|
name: "team-play",
|
|
15245
|
-
description: "
|
|
15697
|
+
description: "Open the team room: each member's role and current work, the shared tasks, and the messages between them (Enter opens a teammate, f filters, Esc closes)"
|
|
15246
15698
|
},
|
|
15247
15699
|
{
|
|
15248
15700
|
name: "team",
|
|
@@ -15441,12 +15893,10 @@ var TuiApp = class {
|
|
|
15441
15893
|
activityTodoStatus = /* @__PURE__ */ new Map();
|
|
15442
15894
|
/** Fades of todo rows that are still moving, keyed by content. */
|
|
15443
15895
|
activityTodoFades = /* @__PURE__ */ new Map();
|
|
15444
|
-
/**
|
|
15445
|
-
|
|
15446
|
-
/**
|
|
15447
|
-
|
|
15448
|
-
/** The last descendant `tool/call` the board saw, for presenting its result. */
|
|
15449
|
-
activityChildCall;
|
|
15896
|
+
/** Descendant rows the activity board draws for the open turn, in first-seen order. */
|
|
15897
|
+
activitySubagents = /* @__PURE__ */ new Map();
|
|
15898
|
+
/** Fades of descendant rows that are still moving, keyed by child session id. */
|
|
15899
|
+
activitySubagentFades = /* @__PURE__ */ new Map();
|
|
15450
15900
|
/** The turn the last logged `turn/start` opened; 0 before the first one. */
|
|
15451
15901
|
turn = 0;
|
|
15452
15902
|
/** Whether a nonempty system prompt has already been drawn in this transcript. */
|
|
@@ -15472,7 +15922,7 @@ var TuiApp = class {
|
|
|
15472
15922
|
barSelection = FIRST_FOOTER_SEGMENT;
|
|
15473
15923
|
/** The descendant listing the last reconcile produced, in pre-order. */
|
|
15474
15924
|
subagentEntries = [];
|
|
15475
|
-
/** Lifecycle
|
|
15925
|
+
/** Lifecycle activity held until a fresh catalog confirms the named descendant. */
|
|
15476
15926
|
pendingSubagentActivity = /* @__PURE__ */ new Map();
|
|
15477
15927
|
/** The rows of the last panel draw. */
|
|
15478
15928
|
panelView = EMPTY_PANEL_VIEW;
|
|
@@ -15509,6 +15959,11 @@ var TuiApp = class {
|
|
|
15509
15959
|
*/
|
|
15510
15960
|
boardSpinners = /* @__PURE__ */ new Map();
|
|
15511
15961
|
/**
|
|
15962
|
+
* The phase each running descendant row the activity board last drew spins
|
|
15963
|
+
* at, by child session id; a row keeps its phase while the child runs.
|
|
15964
|
+
*/
|
|
15965
|
+
boardChildSpinners = /* @__PURE__ */ new Map();
|
|
15966
|
+
/**
|
|
15512
15967
|
* Whether the open turn has committed an assistant message, after which a
|
|
15513
15968
|
* user prompt reaching the log was steered or injected rather than opening
|
|
15514
15969
|
* the turn.
|
|
@@ -15534,11 +15989,11 @@ var TuiApp = class {
|
|
|
15534
15989
|
reader;
|
|
15535
15990
|
/** The empty-session card shown while Agent Teams is mounted. */
|
|
15536
15991
|
teamIntro;
|
|
15537
|
-
/** The
|
|
15992
|
+
/** The team room on the alternate screen, while one is open. */
|
|
15538
15993
|
teamPlay;
|
|
15539
15994
|
/**
|
|
15540
15995
|
* Team-relevant events of the bound session: the history at bind, then
|
|
15541
|
-
* events that arrive after it. `/team-play`
|
|
15996
|
+
* events that arrive after it. `/team-play` lists the exchanges in this log.
|
|
15542
15997
|
*/
|
|
15543
15998
|
teamLog = [];
|
|
15544
15999
|
/** Set while a paint of the open reader is already queued for this turn of the loop. */
|
|
@@ -15763,11 +16218,14 @@ var TuiApp = class {
|
|
|
15763
16218
|
}), ctx.on("subagent/start", (info) => {
|
|
15764
16219
|
this.markSubagentsStale();
|
|
15765
16220
|
this.refreshWorkflowChildLinks();
|
|
15766
|
-
this.noteSubagentActivity(info.id, "running");
|
|
16221
|
+
this.noteSubagentActivity(info.id, { state: "running" });
|
|
15767
16222
|
}), ctx.on("subagent/end", (info) => {
|
|
15768
16223
|
this.markSubagentsStale();
|
|
15769
16224
|
this.refreshWorkflowChildLinks();
|
|
15770
|
-
this.noteSubagentActivity(info.id,
|
|
16225
|
+
this.noteSubagentActivity(info.id, {
|
|
16226
|
+
state: info.stopReason === "completed" ? "done" : "stopped",
|
|
16227
|
+
note: info.stopReason === "completed" ? "done" : info.stopReason
|
|
16228
|
+
});
|
|
15771
16229
|
}), ctx.on("agent/inbox/inserted", ({ agent: subject }) => {
|
|
15772
16230
|
if (subject === this.agent) this.refreshQueue();
|
|
15773
16231
|
}), ctx.on("agent/inbox/claimed", ({ agent: subject }) => {
|
|
@@ -16013,7 +16471,7 @@ var TuiApp = class {
|
|
|
16013
16471
|
this.refreshWorkflowChildLinks();
|
|
16014
16472
|
if (reading) this.notice(READER_GONE);
|
|
16015
16473
|
this.refreshHeader();
|
|
16016
|
-
this.banner.setViews(this.viewLabels, this.asides.has(next) ? BTW_VIEW_TITLE : this.readOnlyViews.has(next) ? ONE_SHOT_VIEW_TITLE :
|
|
16474
|
+
this.banner.setViews(this.viewLabels, this.asides.has(next) ? BTW_VIEW_TITLE : this.readOnlyViews.has(next) ? ONE_SHOT_VIEW_TITLE : this.openTeammateTitle());
|
|
16017
16475
|
this.refreshQueue();
|
|
16018
16476
|
this.refreshFooter();
|
|
16019
16477
|
this.refreshSubagentPanel();
|
|
@@ -16280,26 +16738,41 @@ var TuiApp = class {
|
|
|
16280
16738
|
const title = this.deps.ctx.get("sessionTitle")?.get(session)?.title;
|
|
16281
16739
|
const name = title === void 0 ? `session ${session.id}` : `${title} ${palette.dim(`(${session.id})`)}`;
|
|
16282
16740
|
const teamsOn = this.parents.length === 0 && agentTeamsMounted(this.deps.ctx.get("agentTeams"));
|
|
16283
|
-
const
|
|
16741
|
+
const teammate = this.openTeammateTitle();
|
|
16742
|
+
const trail = this.parents.length === 0 ? palette.dim(teamsOn ? "· Agent Teams on · /team-play · /help" : "· /help for commands") : this.asides.has(this.bound) ? `${palette.accent(`◆ ${BTW_VIEW_TITLE}`)} ${paintKeys(palette, "· Ctrl+P ends it and returns")}` : teammate === void 0 ? `${palette.accent(`◆ subagent view ${"›".repeat(this.parents.length)}`)} ${paintKeys(palette, "· Ctrl+P returns")}` : `${palette.accent(`◆ ${teammate}`)} ${paintKeys(palette, "· Ctrl+P returns")}`;
|
|
16284
16743
|
this.header.setText(`${palette.bold(palette.accent("dsh"))} ${palette.dim("·")} ${name} ${trail}`);
|
|
16285
16744
|
this.tui.requestRender();
|
|
16286
16745
|
}
|
|
16287
16746
|
/**
|
|
16288
|
-
*
|
|
16289
|
-
*
|
|
16747
|
+
* What the open view calls the bound session when the team roster lists it
|
|
16748
|
+
* as a teammate.
|
|
16749
|
+
* @returns `teammate <name> · <role>`, or undefined for any other session.
|
|
16750
|
+
*/
|
|
16751
|
+
openTeammateTitle() {
|
|
16752
|
+
const id = this.agent.session.id;
|
|
16753
|
+
const member = this.teamMembers().find((row) => row.role === "teammate" && row.id === id);
|
|
16754
|
+
return member === void 0 ? void 0 : teammateViewTitle(member);
|
|
16755
|
+
}
|
|
16756
|
+
/**
|
|
16757
|
+
* What the team room draws right now: the roster and the shared tasks from
|
|
16758
|
+
* the service, the exchanges the bound session logged, and what each child
|
|
16759
|
+
* last narrated. A roster the service cannot read yields no members.
|
|
16760
|
+
* @returns the reads for one key or frame.
|
|
16290
16761
|
*/
|
|
16291
|
-
|
|
16762
|
+
teamRoomSource() {
|
|
16763
|
+
const snapshot = readTeam(this.deps.ctx.get("agentTeams"), this.agent);
|
|
16764
|
+
const members = snapshot.kind === "team" ? snapshot.members : [];
|
|
16292
16765
|
const names = this.scopedTeamToolNames();
|
|
16293
|
-
const
|
|
16294
|
-
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16301
|
-
|
|
16302
|
-
|
|
16766
|
+
const speaker = members.find((row) => row.id === this.agent.session.id)?.name ?? "lead";
|
|
16767
|
+
return {
|
|
16768
|
+
members,
|
|
16769
|
+
tasks: snapshot.kind === "team" ? snapshot.tasks : [],
|
|
16770
|
+
beats: beatsFromEvents(this.teamLog.map((event) => ({
|
|
16771
|
+
type: event.type,
|
|
16772
|
+
data: event.data
|
|
16773
|
+
})), speaker, names.size > 0 ? names : void 0, new Map(members.map((row) => [row.id, row.name]))),
|
|
16774
|
+
note: (id) => this.activitySubagents.get(SessionId(id))?.note,
|
|
16775
|
+
spinner: (slot) => this.deps.reducedMotion ? void 0 : spinnerFrame(TOOL_SPINNERS.subagent, this.deps.now(), this.deps.spinnerMs, slot % 8)
|
|
16303
16776
|
};
|
|
16304
16777
|
}
|
|
16305
16778
|
/**
|
|
@@ -16309,24 +16782,19 @@ var TuiApp = class {
|
|
|
16309
16782
|
mountTeamIntro() {
|
|
16310
16783
|
if (this.parents.length > 0 || !agentTeamsMounted(this.deps.ctx.get("agentTeams"))) return;
|
|
16311
16784
|
if (this.teamLog.some((event) => event.type === "user/message" || event.type === "tool/call" || event.type === "assistant/message")) return;
|
|
16312
|
-
this.teamIntro = new TeamIntro(this.deps.palette
|
|
16785
|
+
this.teamIntro = new TeamIntro(this.deps.palette);
|
|
16313
16786
|
this.chat.addChild(this.teamIntro);
|
|
16314
|
-
this.updateSpinTicker();
|
|
16315
16787
|
this.tui.requestRender();
|
|
16316
16788
|
}
|
|
16317
|
-
/** Open the
|
|
16789
|
+
/** Open the team room on the alternate screen. */
|
|
16318
16790
|
openTeamPlay() {
|
|
16319
|
-
if (
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
}
|
|
16323
|
-
if (this.reader !== void 0) this.dropReader();
|
|
16791
|
+
if (this.loadedTeam() === void 0) return;
|
|
16792
|
+
this.dropReader();
|
|
16793
|
+
/* v8 ignore next -- the open room consumes every key, so no second /team-play reaches here */
|
|
16324
16794
|
if (this.teamPlay !== void 0) return;
|
|
16325
16795
|
this.teamPlay = new TeamPlay({
|
|
16326
16796
|
palette: this.deps.palette,
|
|
16327
|
-
|
|
16328
|
-
beats: () => this.teamBeats().beats,
|
|
16329
|
-
example: () => this.teamBeats().example
|
|
16797
|
+
source: () => this.teamRoomSource()
|
|
16330
16798
|
});
|
|
16331
16799
|
this.tui.renderNow();
|
|
16332
16800
|
this.tui.suspend(() => {
|
|
@@ -16336,16 +16804,40 @@ var TuiApp = class {
|
|
|
16336
16804
|
this.paintTeamPlay();
|
|
16337
16805
|
this.updateSpinTicker();
|
|
16338
16806
|
}
|
|
16339
|
-
/** Draw the open
|
|
16807
|
+
/** Draw the open team room. */
|
|
16340
16808
|
paintTeamPlay() {
|
|
16341
16809
|
const play = this.teamPlay;
|
|
16342
16810
|
if (play === void 0 || !this.readerScreen.active) return;
|
|
16343
16811
|
const rows = Math.max(1, this.deps.terminal.rows);
|
|
16344
16812
|
this.readerScreen.paint(play.render(this.deps.terminal.columns, rows));
|
|
16345
16813
|
}
|
|
16346
|
-
/**
|
|
16347
|
-
|
|
16814
|
+
/**
|
|
16815
|
+
* Draw the open team room after the team changed, and keep the spinner tick
|
|
16816
|
+
* running exactly while a member works. A room that is not open is left alone.
|
|
16817
|
+
*/
|
|
16818
|
+
repaintTeamPlay() {
|
|
16348
16819
|
if (this.teamPlay === void 0) return;
|
|
16820
|
+
this.paintTeamPlay();
|
|
16821
|
+
this.updateSpinTicker();
|
|
16822
|
+
}
|
|
16823
|
+
/**
|
|
16824
|
+
* Answer one key while the team room holds the terminal: `Ctrl+C` and the
|
|
16825
|
+
* room's own close keys give the conversation its screen back, and `Enter`
|
|
16826
|
+
* on a teammate leaves the room for that teammate's session.
|
|
16827
|
+
* @param play - the open room.
|
|
16828
|
+
* @param data - the raw key bytes.
|
|
16829
|
+
*/
|
|
16830
|
+
onTeamPlayKey(play, data) {
|
|
16831
|
+
const action = matchesKey(data, "ctrl+c") ? { kind: "close" } : play.handleInput(data);
|
|
16832
|
+
if (action === void 0) {
|
|
16833
|
+
this.paintTeamPlay();
|
|
16834
|
+
return;
|
|
16835
|
+
}
|
|
16836
|
+
this.closeTeamPlay();
|
|
16837
|
+
if (action.kind === "open") this.navigate("teammate session", () => this.enterSubagent(action.choice, this.teamBrowseEntry(action.entry)));
|
|
16838
|
+
}
|
|
16839
|
+
/** Leave the team room and give the conversation its screen back. */
|
|
16840
|
+
closeTeamPlay() {
|
|
16349
16841
|
this.teamPlay = void 0;
|
|
16350
16842
|
this.readerScreen.leave();
|
|
16351
16843
|
this.tui.resume();
|
|
@@ -16354,8 +16846,8 @@ var TuiApp = class {
|
|
|
16354
16846
|
this.tui.requestRender();
|
|
16355
16847
|
}
|
|
16356
16848
|
/**
|
|
16357
|
-
* Take the
|
|
16358
|
-
*
|
|
16849
|
+
* Take the team room down without moving focus, for a session switch or a
|
|
16850
|
+
* quit. A room that is not open is left alone.
|
|
16359
16851
|
*/
|
|
16360
16852
|
dropTeamPlay() {
|
|
16361
16853
|
if (this.teamPlay === void 0) return;
|
|
@@ -16417,24 +16909,29 @@ var TuiApp = class {
|
|
|
16417
16909
|
}
|
|
16418
16910
|
/**
|
|
16419
16911
|
* Redraw the activity board above the editor from the open turn's todos and
|
|
16420
|
-
* the
|
|
16912
|
+
* the descendants it has seen. The slot is mounted exactly while a row
|
|
16421
16913
|
* draws, so the editor sits directly under follow-ups or the conversation
|
|
16422
16914
|
* the rest of the time.
|
|
16423
16915
|
*/
|
|
16424
16916
|
refreshActivityBoard() {
|
|
16425
16917
|
const view = activityBoardView({
|
|
16426
16918
|
todos: this.activityTodos,
|
|
16427
|
-
|
|
16919
|
+
subagents: [...this.activitySubagents.values()]
|
|
16428
16920
|
});
|
|
16429
|
-
this.syncBoardSpinners(this.deps.reducedMotion ? [] : spinningTodos(view));
|
|
16921
|
+
this.syncBoardSpinners(this.deps.reducedMotion ? [] : spinningTodos(view), this.deps.reducedMotion ? [] : spinningSubagents(view));
|
|
16430
16922
|
const now = this.deps.now();
|
|
16923
|
+
const frame = (phase) => spinnerFrame(TOOL_SPINNERS.todo, now, this.deps.spinnerMs, phase);
|
|
16431
16924
|
const spinners = /* @__PURE__ */ new Map();
|
|
16432
|
-
for (const [content, phase] of this.boardSpinners) spinners.set(content,
|
|
16925
|
+
for (const [content, phase] of this.boardSpinners) spinners.set(content, frame(phase));
|
|
16926
|
+
const subagentSpinners = /* @__PURE__ */ new Map();
|
|
16927
|
+
for (const [id, phase] of this.boardChildSpinners) subagentSpinners.set(id, frame(phase));
|
|
16433
16928
|
const text = renderActivityBoard(view, {
|
|
16434
16929
|
palette: this.deps.palette,
|
|
16435
16930
|
todoFades: this.activityTodoFades,
|
|
16436
|
-
|
|
16437
|
-
spinners
|
|
16931
|
+
subagentFades: this.activitySubagentFades,
|
|
16932
|
+
spinners,
|
|
16933
|
+
subagentSpinners,
|
|
16934
|
+
width: this.contentWidth()
|
|
16438
16935
|
});
|
|
16439
16936
|
this.updateSpinTicker();
|
|
16440
16937
|
const mounted = this.activitySlot.children.length > 0;
|
|
@@ -16447,17 +16944,25 @@ var TuiApp = class {
|
|
|
16447
16944
|
this.tui.requestRender();
|
|
16448
16945
|
}
|
|
16449
16946
|
/**
|
|
16450
|
-
* Keep the phase of each in-progress todo row
|
|
16451
|
-
* rest, and stagger a row that starts
|
|
16452
|
-
* indicator on screen.
|
|
16453
|
-
* @param contents - the content of each in-progress row the board draws now.
|
|
16947
|
+
* Keep the phase of each in-progress todo row and each running descendant
|
|
16948
|
+
* row that still spins, drop the rest, and stagger a row that starts
|
|
16949
|
+
* spinning against every other tool indicator on screen.
|
|
16950
|
+
* @param contents - the content of each in-progress todo row the board draws now.
|
|
16951
|
+
* @param children - the session id of each running descendant row the board draws now.
|
|
16454
16952
|
*/
|
|
16455
|
-
syncBoardSpinners(contents) {
|
|
16456
|
-
|
|
16457
|
-
|
|
16458
|
-
|
|
16459
|
-
|
|
16460
|
-
|
|
16953
|
+
syncBoardSpinners(contents, children) {
|
|
16954
|
+
this.keepSpinnerPhases(this.boardSpinners, contents);
|
|
16955
|
+
this.keepSpinnerPhases(this.boardChildSpinners, children);
|
|
16956
|
+
}
|
|
16957
|
+
/**
|
|
16958
|
+
* Keep the phases of the rows in `keys`, drop the others, and give each new
|
|
16959
|
+
* row a phase that differs from every spinner already drawn.
|
|
16960
|
+
* @param phases - the phase map of one kind of board row.
|
|
16961
|
+
* @param keys - the rows of that kind that spin now.
|
|
16962
|
+
*/
|
|
16963
|
+
keepSpinnerPhases(phases, keys) {
|
|
16964
|
+
for (const key of phases.keys()) if (!keys.includes(key)) phases.delete(key);
|
|
16965
|
+
for (const key of keys) if (!phases.has(key)) phases.set(key, staggerPhase(this.spinningPhases("todo")));
|
|
16461
16966
|
}
|
|
16462
16967
|
/**
|
|
16463
16968
|
* Replace the board's todos from the same `todos` projection `/todos` reads
|
|
@@ -16484,29 +16989,48 @@ var TuiApp = class {
|
|
|
16484
16989
|
this.refreshActivityBoard();
|
|
16485
16990
|
}
|
|
16486
16991
|
/**
|
|
16487
|
-
* Replace
|
|
16488
|
-
*
|
|
16489
|
-
|
|
16490
|
-
|
|
16491
|
-
|
|
16492
|
-
|
|
16493
|
-
|
|
16494
|
-
|
|
16495
|
-
|
|
16992
|
+
* Replace one descendant's row, fading it when its text changed. A new
|
|
16993
|
+
* descendant takes the place after the rows already drawn.
|
|
16994
|
+
* @param id - the descendant session id.
|
|
16995
|
+
* @param activity - the row's state and note.
|
|
16996
|
+
*/
|
|
16997
|
+
setActivitySubagent(id, activity) {
|
|
16998
|
+
const previous = this.activitySubagents.get(id);
|
|
16999
|
+
const next = {
|
|
17000
|
+
id,
|
|
17001
|
+
label: this.activityLabelFor(id),
|
|
17002
|
+
state: activity.state,
|
|
17003
|
+
...activity.note === void 0 ? {} : { note: activity.note }
|
|
17004
|
+
};
|
|
17005
|
+
this.activitySubagents.set(id, next);
|
|
17006
|
+
if (previous?.label !== next.label || previous.state !== next.state || previous.note !== next.note) {
|
|
17007
|
+
this.activitySubagentFades.delete(id);
|
|
16496
17008
|
this.fadeBlock((fade) => {
|
|
16497
|
-
this.
|
|
17009
|
+
this.activitySubagentFades.set(id, fade);
|
|
16498
17010
|
});
|
|
16499
17011
|
}
|
|
16500
17012
|
this.refreshActivityBoard();
|
|
16501
17013
|
}
|
|
17014
|
+
/**
|
|
17015
|
+
* Relabel the board's descendant rows from the current roster, so a member
|
|
17016
|
+
* that joined after its row was drawn stops drawing under its listing label.
|
|
17017
|
+
*/
|
|
17018
|
+
relabelActivityBoard() {
|
|
17019
|
+
for (const [id, row] of this.activitySubagents) {
|
|
17020
|
+
if (this.activityLabelFor(id) === row.label) continue;
|
|
17021
|
+
this.setActivitySubagent(id, {
|
|
17022
|
+
state: row.state,
|
|
17023
|
+
...row.note === void 0 ? {} : { note: row.note }
|
|
17024
|
+
});
|
|
17025
|
+
}
|
|
17026
|
+
}
|
|
16502
17027
|
/** Drop the open-turn board so bind and turn edges leave no stale rows. */
|
|
16503
17028
|
clearActivityBoard() {
|
|
16504
17029
|
this.activityTodos = [];
|
|
16505
17030
|
this.activityTodoStatus = /* @__PURE__ */ new Map();
|
|
16506
17031
|
this.activityTodoFades = /* @__PURE__ */ new Map();
|
|
16507
|
-
this.
|
|
16508
|
-
this.
|
|
16509
|
-
this.activityChildCall = void 0;
|
|
17032
|
+
this.activitySubagents = /* @__PURE__ */ new Map();
|
|
17033
|
+
this.activitySubagentFades = /* @__PURE__ */ new Map();
|
|
16510
17034
|
this.pendingSubagentActivity.clear();
|
|
16511
17035
|
this.refreshActivityBoard();
|
|
16512
17036
|
}
|
|
@@ -16515,7 +17039,7 @@ var TuiApp = class {
|
|
|
16515
17039
|
* session. Session lineage also represents ordinary forks, so it cannot
|
|
16516
17040
|
* establish subagent membership.
|
|
16517
17041
|
* @param id - the session id a lifecycle event named.
|
|
16518
|
-
* @returns true when the activity board may show that child's
|
|
17042
|
+
* @returns true when the activity board may show that child's row.
|
|
16519
17043
|
*/
|
|
16520
17044
|
isBoundDescendantId(id) {
|
|
16521
17045
|
return this.subagentEntries.some((entry) => entry.id === id);
|
|
@@ -16529,76 +17053,64 @@ var TuiApp = class {
|
|
|
16529
17053
|
return this.isBoundDescendantId(session.id);
|
|
16530
17054
|
}
|
|
16531
17055
|
/**
|
|
16532
|
-
* The
|
|
16533
|
-
*
|
|
17056
|
+
* The board's label for a descendant: `<name> · <role>` for a team roster
|
|
17057
|
+
* member, else the listing label, or its session id when the listing has
|
|
17058
|
+
* not named it. External work has no local Session, so the line says so.
|
|
16534
17059
|
* @param id - the descendant session id.
|
|
16535
17060
|
* @returns the board's label for that child.
|
|
16536
17061
|
*/
|
|
16537
17062
|
activityLabelFor(id) {
|
|
17063
|
+
const member = this.teamMembers().find((row) => row.id === id);
|
|
17064
|
+
if (member !== void 0) return memberLabel(member);
|
|
16538
17065
|
const entry = this.subagentEntries.find((candidate) => candidate.id === id);
|
|
16539
17066
|
if (entry?.kind !== "child") return id;
|
|
16540
17067
|
const label = entry.label ?? id;
|
|
16541
17068
|
return entry.mode === "external" ? `${label} (external task)` : label;
|
|
16542
17069
|
}
|
|
16543
17070
|
/**
|
|
16544
|
-
* Draw a lifecycle
|
|
17071
|
+
* Draw a lifecycle edge once a catalog confirms its descendant membership.
|
|
16545
17072
|
* @param id - child identity carried by the lifecycle edge.
|
|
16546
|
-
* @param
|
|
17073
|
+
* @param activity - the row the edge's start or end gives the activity board.
|
|
16547
17074
|
*/
|
|
16548
|
-
noteSubagentActivity(id,
|
|
16549
|
-
this.pendingSubagentActivity.set(id,
|
|
17075
|
+
noteSubagentActivity(id, activity) {
|
|
17076
|
+
this.pendingSubagentActivity.set(id, activity);
|
|
16550
17077
|
this.flushPendingSubagentActivity();
|
|
16551
17078
|
}
|
|
16552
|
-
/** Apply pending lifecycle
|
|
17079
|
+
/** Apply pending lifecycle activity only to ids the current catalog owns. */
|
|
16553
17080
|
flushPendingSubagentActivity() {
|
|
16554
17081
|
for (const [id, activity] of this.pendingSubagentActivity) {
|
|
16555
17082
|
if (!this.isBoundDescendantId(id)) continue;
|
|
16556
|
-
this.setActivitySubagent(
|
|
16557
|
-
label: this.activityLabelFor(id),
|
|
16558
|
-
status: activity.status
|
|
16559
|
-
});
|
|
17083
|
+
this.setActivitySubagent(id, activity);
|
|
16560
17084
|
this.pendingSubagentActivity.delete(id);
|
|
16561
17085
|
}
|
|
16562
17086
|
}
|
|
16563
17087
|
/**
|
|
16564
|
-
*
|
|
16565
|
-
*
|
|
17088
|
+
* Update a descendant's row from its session events: a turn opens it, an
|
|
17089
|
+
* assistant message's last sentence becomes its note, and a turn end
|
|
17090
|
+
* settles it. Tool calls and results, reasoning, and a message without
|
|
17091
|
+
* text leave the note alone, so a child that has not spoken draws its label
|
|
17092
|
+
* alone.
|
|
16566
17093
|
* @param session - the descendant that logged `event`.
|
|
16567
17094
|
* @param event - the durable event.
|
|
16568
17095
|
*/
|
|
16569
17096
|
onDescendantActivity(session, event) {
|
|
16570
17097
|
switch (event.type) {
|
|
16571
|
-
case "
|
|
16572
|
-
|
|
16573
|
-
const args = parseArguments(argumentsJson);
|
|
16574
|
-
this.activityChildCall = {
|
|
16575
|
-
name,
|
|
16576
|
-
args
|
|
16577
|
-
};
|
|
16578
|
-
const view = args === void 0 ? void 0 : this.presentCall(name, args);
|
|
16579
|
-
const title = view === void 0 ? void 0 : cardHeadline(name, view.title);
|
|
16580
|
-
this.setActivitySubagent({
|
|
16581
|
-
label: this.activityLabelFor(session.id),
|
|
16582
|
-
status: callingActivity(name),
|
|
16583
|
-
...title === void 0 ? {} : { summary: title }
|
|
16584
|
-
});
|
|
17098
|
+
case "turn/start":
|
|
17099
|
+
this.setActivitySubagent(session.id, { state: "running" });
|
|
16585
17100
|
return;
|
|
16586
|
-
|
|
16587
|
-
|
|
16588
|
-
|
|
16589
|
-
|
|
16590
|
-
|
|
16591
|
-
const view = this.presentResult(call?.name ?? "", call?.args, result.content, result.isError === true, event.data.meta);
|
|
16592
|
-
this.setActivitySubagent({
|
|
16593
|
-
label: this.activityLabelFor(session.id),
|
|
16594
|
-
...activityResultParts(toolResultBody(view, result.content).lines[0], result.isError === true)
|
|
17101
|
+
case "assistant/message": {
|
|
17102
|
+
const narration = activityNarration(event.data.message.content.filter((block) => block.type === "text").map((block) => block.text).join(""));
|
|
17103
|
+
if (narration !== void 0) this.setActivitySubagent(session.id, {
|
|
17104
|
+
state: "running",
|
|
17105
|
+
note: narration
|
|
16595
17106
|
});
|
|
17107
|
+
else if (this.activitySubagents.get(session.id)?.state !== "running") this.setActivitySubagent(session.id, { state: "running" });
|
|
16596
17108
|
return;
|
|
16597
17109
|
}
|
|
16598
17110
|
case "turn/end":
|
|
16599
|
-
this.setActivitySubagent({
|
|
16600
|
-
|
|
16601
|
-
|
|
17111
|
+
this.setActivitySubagent(session.id, {
|
|
17112
|
+
state: event.data.reason.kind === "completed" ? "done" : "stopped",
|
|
17113
|
+
note: activityTurnEndStatus(event.data.reason)
|
|
16602
17114
|
});
|
|
16603
17115
|
return;
|
|
16604
17116
|
default: return;
|
|
@@ -16617,12 +17129,15 @@ var TuiApp = class {
|
|
|
16617
17129
|
* Redraw the panel from the last listing and a fresh sample of the live
|
|
16618
17130
|
* facts. The panel is mounted exactly while it has a row, so the last
|
|
16619
17131
|
* resident child leaving takes the panel with it — and the keyboard back to
|
|
16620
|
-
* the editor when the panel held it.
|
|
17132
|
+
* the editor when the panel held it. Team roster members are not rows: the
|
|
17133
|
+
* team line and the activity board account for them.
|
|
16621
17134
|
*/
|
|
16622
17135
|
refreshSubagentPanel() {
|
|
17136
|
+
const members = new Set(this.teamMembers().map((member) => member.id));
|
|
17137
|
+
const entries = this.subagentEntries.filter((entry) => !members.has(entry.id));
|
|
16623
17138
|
const view = subagentPanelView({
|
|
16624
|
-
entries
|
|
16625
|
-
facts: this.subagentFacts(),
|
|
17139
|
+
entries,
|
|
17140
|
+
facts: this.subagentFacts(entries),
|
|
16626
17141
|
now: this.deps.now()
|
|
16627
17142
|
});
|
|
16628
17143
|
this.panelView = view;
|
|
@@ -16651,10 +17166,10 @@ var TuiApp = class {
|
|
|
16651
17166
|
this.tui.requestRender();
|
|
16652
17167
|
}
|
|
16653
17168
|
/**
|
|
16654
|
-
* Redraw the team summary from the optional service. `auto` draws the
|
|
16655
|
-
*
|
|
16656
|
-
*
|
|
16657
|
-
*
|
|
17169
|
+
* Redraw the team summary from the optional service. `auto` draws the line
|
|
17170
|
+
* only when a teammate or a shared task exists, `on` forces the line, and
|
|
17171
|
+
* `off` hides it. The summary stays ahead of the subagent panel when both
|
|
17172
|
+
* are mounted.
|
|
16658
17173
|
*/
|
|
16659
17174
|
refreshTeamPanel() {
|
|
16660
17175
|
const snapshot = readTeam(this.deps.ctx.get("agentTeams"), this.agent);
|
|
@@ -16662,12 +17177,31 @@ var TuiApp = class {
|
|
|
16662
17177
|
this.mountTeamLine(teamPanelLine({
|
|
16663
17178
|
members: roster === void 0 ? [] : roster.members,
|
|
16664
17179
|
tasks: roster === void 0 ? [] : roster.tasks,
|
|
17180
|
+
width: this.contentWidth(),
|
|
16665
17181
|
hidden: this.teamPanelMode === "off",
|
|
16666
17182
|
forced: this.teamPanelMode === "on"
|
|
16667
17183
|
}, this.deps.palette));
|
|
16668
17184
|
this.tui.requestRender();
|
|
16669
17185
|
}
|
|
16670
17186
|
/**
|
|
17187
|
+
* Redraw every surface that reads the team roster after a `team/` event:
|
|
17188
|
+
* the summary, the subagent panel that leaves members out, and the board
|
|
17189
|
+
* labels of members that joined after their rows were drawn.
|
|
17190
|
+
*/
|
|
17191
|
+
refreshTeamSurfaces() {
|
|
17192
|
+
this.refreshTeamPanel();
|
|
17193
|
+
this.refreshSubagentPanel();
|
|
17194
|
+
this.relabelActivityBoard();
|
|
17195
|
+
}
|
|
17196
|
+
/**
|
|
17197
|
+
* The roster rows of the bound session's team.
|
|
17198
|
+
* @returns the members, the lead included; empty when Agent Teams is absent or the bound session is not on a team.
|
|
17199
|
+
*/
|
|
17200
|
+
teamMembers() {
|
|
17201
|
+
const snapshot = readTeam(this.deps.ctx.get("agentTeams"), this.agent);
|
|
17202
|
+
return snapshot.kind === "team" ? snapshot.members : [];
|
|
17203
|
+
}
|
|
17204
|
+
/**
|
|
16671
17205
|
* Mount or clear the team summary without touching the subagent panel.
|
|
16672
17206
|
* An empty line removes only the summary. A new line is inserted ahead of
|
|
16673
17207
|
* the subagent panel when that panel is already mounted.
|
|
@@ -16758,7 +17292,8 @@ var TuiApp = class {
|
|
|
16758
17292
|
else if (argument === "") {
|
|
16759
17293
|
const showing = this.teamPanelMode === "on" || this.teamPanelMode === "auto" && teamPanelLine({
|
|
16760
17294
|
members: snapshot.members,
|
|
16761
|
-
tasks: snapshot.tasks
|
|
17295
|
+
tasks: snapshot.tasks,
|
|
17296
|
+
width: this.contentWidth()
|
|
16762
17297
|
}, this.deps.palette) !== "";
|
|
16763
17298
|
this.teamPanelMode = showing ? "off" : "on";
|
|
16764
17299
|
} else {
|
|
@@ -16772,14 +17307,15 @@ var TuiApp = class {
|
|
|
16772
17307
|
* its Agent is running a turn, and one projection read for its timing and
|
|
16773
17308
|
* token totals. Both reads are synchronous and touch no session log; a
|
|
16774
17309
|
* child with no live Agent here contributes no facts.
|
|
17310
|
+
* @param entries - the listing entries the panel draws from.
|
|
16775
17311
|
* @returns the facts by child session id.
|
|
16776
17312
|
*/
|
|
16777
|
-
subagentFacts() {
|
|
17313
|
+
subagentFacts(entries) {
|
|
16778
17314
|
const facts = /* @__PURE__ */ new Map();
|
|
16779
17315
|
const { ctx } = this.deps;
|
|
16780
17316
|
const agents = ctx.get("agents");
|
|
16781
17317
|
const projections = ctx.get("sessionProjections");
|
|
16782
|
-
for (const entry of
|
|
17318
|
+
for (const entry of entries) {
|
|
16783
17319
|
const child = agents?.get(entry.id);
|
|
16784
17320
|
if (child === void 0) continue;
|
|
16785
17321
|
const live = { running: child.status === "running" };
|
|
@@ -17513,8 +18049,7 @@ var TuiApp = class {
|
|
|
17513
18049
|
return { consume: true };
|
|
17514
18050
|
}
|
|
17515
18051
|
if (this.teamPlay !== void 0 && this.readerScreen.active) {
|
|
17516
|
-
|
|
17517
|
-
else this.paintTeamPlay();
|
|
18052
|
+
this.onTeamPlayKey(this.teamPlay, data);
|
|
17518
18053
|
return { consume: true };
|
|
17519
18054
|
}
|
|
17520
18055
|
const reading = this.reader;
|
|
@@ -19513,15 +20048,15 @@ var TuiApp = class {
|
|
|
19513
20048
|
}
|
|
19514
20049
|
/**
|
|
19515
20050
|
* The phases of the indicators of `family` spinning right now: running
|
|
19516
|
-
* cards of that family, and the activity board's in-progress todo rows
|
|
19517
|
-
* when `family` is `todo`.
|
|
20051
|
+
* cards of that family, and the activity board's in-progress todo rows and
|
|
20052
|
+
* running descendant rows when `family` is `todo`.
|
|
19518
20053
|
* @param family - the animation those indicators draw.
|
|
19519
20054
|
* @returns one phase per spinning indicator of that family.
|
|
19520
20055
|
*/
|
|
19521
20056
|
spinningPhases(family) {
|
|
19522
20057
|
const phases = [];
|
|
19523
20058
|
for (const [block, phase] of this.spinners) if (block.spinning() && toolFamily(block.name) === family) phases.push(phase);
|
|
19524
|
-
if (family === "todo") phases.push(...this.boardSpinners.values());
|
|
20059
|
+
if (family === "todo") phases.push(...this.boardSpinners.values(), ...this.boardChildSpinners.values());
|
|
19525
20060
|
return phases;
|
|
19526
20061
|
}
|
|
19527
20062
|
/**
|
|
@@ -19538,8 +20073,8 @@ var TuiApp = class {
|
|
|
19538
20073
|
* stopped app runs none.
|
|
19539
20074
|
*/
|
|
19540
20075
|
updateSpinTicker() {
|
|
19541
|
-
const spinning = this.streaming?.spinning() === true || this.spinners.size > 0 || this.boardSpinners.size > 0 || this.workflowSpinners.size > 0;
|
|
19542
|
-
const teamMotion =
|
|
20076
|
+
const spinning = this.streaming?.spinning() === true || this.spinners.size > 0 || this.boardSpinners.size > 0 || this.boardChildSpinners.size > 0 || this.workflowSpinners.size > 0;
|
|
20077
|
+
const teamMotion = this.teamPlay?.animates() === true;
|
|
19543
20078
|
if (!this.stopped && (this.loaderAnimates() || spinning || teamMotion)) {
|
|
19544
20079
|
this.spinTicker ??= this.deps.tick(() => {
|
|
19545
20080
|
this.onSpinTick();
|
|
@@ -19561,15 +20096,8 @@ var TuiApp = class {
|
|
|
19561
20096
|
for (const block of this.spinners.keys()) if (!block.spinning()) this.spinners.delete(block);
|
|
19562
20097
|
for (const block of this.workflowSpinners) if (!block.spinning()) this.workflowSpinners.delete(block);
|
|
19563
20098
|
if (this.loaderAnimates()) this.refreshLoader();
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
this.tui.requestRender();
|
|
19567
|
-
}
|
|
19568
|
-
if (this.teamPlay !== void 0) {
|
|
19569
|
-
this.teamPlay.advance();
|
|
19570
|
-
this.paintTeamPlay();
|
|
19571
|
-
}
|
|
19572
|
-
if (this.boardSpinners.size > 0) this.refreshActivityBoard();
|
|
20099
|
+
this.paintTeamPlay();
|
|
20100
|
+
if (this.boardSpinners.size > 0 || this.boardChildSpinners.size > 0) this.refreshActivityBoard();
|
|
19573
20101
|
else if (this.streaming?.spinning() === true || this.spinners.size > 0 || this.workflowSpinners.size > 0) this.tui.requestRender();
|
|
19574
20102
|
this.updateSpinTicker();
|
|
19575
20103
|
}
|
|
@@ -19848,16 +20376,17 @@ var TuiApp = class {
|
|
|
19848
20376
|
onSessionEvent(session, event) {
|
|
19849
20377
|
if (!this.replaying && session === this.agent.session) {
|
|
19850
20378
|
this.teamLog.push(event);
|
|
19851
|
-
|
|
20379
|
+
this.repaintTeamPlay();
|
|
19852
20380
|
}
|
|
19853
20381
|
if (session !== this.agent.session) {
|
|
19854
20382
|
this.markSubagentsStale();
|
|
19855
20383
|
if (this.isBoundDescendant(session)) this.onDescendantActivity(session, event);
|
|
20384
|
+
this.repaintTeamPlay();
|
|
19856
20385
|
return;
|
|
19857
20386
|
}
|
|
19858
20387
|
this.pacer?.flush();
|
|
19859
20388
|
const loggedType = event.type;
|
|
19860
|
-
if (isTeamPanelEvent(loggedType)) this.
|
|
20389
|
+
if (isTeamPanelEvent(loggedType)) this.refreshTeamSurfaces();
|
|
19861
20390
|
const compaction = this.compactions.observe(event, this.turn);
|
|
19862
20391
|
if (compaction !== void 0) this.showCompaction(compaction);
|
|
19863
20392
|
switch (event.type) {
|