@giladbarnea/pi-simple-team 1.0.4 → 1.0.6
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/index.ts +13 -12
- package/package.json +1 -1
- package/render.ts +61 -42
package/index.ts
CHANGED
|
@@ -559,7 +559,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
const owner = Symbol("pi-simple-team-owner");
|
|
562
|
-
|
|
562
|
+
const sessionTeammateRoster: string[] = [];
|
|
563
|
+
pi.registerMessageRenderer(teamMessageType, (message, _options, theme) => renderTeamMessage(message, theme, getMarkdownTheme(), sessionTeammateRoster));
|
|
563
564
|
|
|
564
565
|
pi.on("session_shutdown", async () => {
|
|
565
566
|
for (const team of [...teams.values()]) {
|
|
@@ -576,8 +577,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
576
577
|
description: "Spawn a persistent team of RPC Pi teammates with fresh context windows. The main agent (you) is included automatically; do not specify it as a teammate.",
|
|
577
578
|
promptSnippet: "Spawn persistent RPC Pi teammate processes. Currently, manually ‘starting’ the teammates is required after spawn. Unless required, don’t fill up your time by repeatedly busy-polling team information. Don’t bash sleep to wait for progress; instead, set your status to advertise that you are counting on teammates to send you a message updating important milestones or request for help, and that otherwise you are staying idle; Send this actively to the team; Then end your turn by sending a simple message to the user, and finally stay put.",
|
|
578
579
|
renderShell: "self",
|
|
579
|
-
renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context),
|
|
580
|
-
renderResult: (result, options, theme, context) => renderTeamToolResult("team_spawn", result, options, theme, context),
|
|
580
|
+
renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context, sessionTeammateRoster),
|
|
581
|
+
renderResult: (result, options, theme, context) => renderTeamToolResult("team_spawn", result, options, theme, context, undefined, sessionTeammateRoster),
|
|
581
582
|
parameters: Type.Object({
|
|
582
583
|
team: Type.String({ description: "Team name" }),
|
|
583
584
|
teamPrompt: Type.String({ description: "Common team system prompt" }),
|
|
@@ -594,6 +595,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
594
595
|
if (teammateNames.includes("main")) throw new Error('"main" is reserved');
|
|
595
596
|
|
|
596
597
|
await validateTeammateModels(teammateSpecs);
|
|
598
|
+
sessionTeammateRoster.push(...teammateNames.filter((teammateName) => !sessionTeammateRoster.includes(teammateName)));
|
|
597
599
|
await ensureCallbackServer();
|
|
598
600
|
|
|
599
601
|
const team: TeamState = {
|
|
@@ -620,7 +622,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
620
622
|
closeCallbackServerIfUnused();
|
|
621
623
|
throw error;
|
|
622
624
|
}
|
|
623
|
-
|
|
624
625
|
return toolResult({
|
|
625
626
|
accepted: true,
|
|
626
627
|
team: team.name,
|
|
@@ -638,8 +639,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
638
639
|
description: "Send a message from main to teammate(s). Fire-and-forget; does not wait for replies. Teammates will send you messages as they deem appropriate by way of push.",
|
|
639
640
|
promptSnippet: "Send a message from main to teammate(s)",
|
|
640
641
|
renderShell: "self",
|
|
641
|
-
renderCall: (args, theme, context) => renderTeamToolCall("teamsend", args, theme, context),
|
|
642
|
-
renderResult: (result, options, theme, context) => renderTeamToolResult("teamsend", result, options, theme, context, getMarkdownTheme()),
|
|
642
|
+
renderCall: (args, theme, context) => renderTeamToolCall("teamsend", args, theme, context, sessionTeammateRoster),
|
|
643
|
+
renderResult: (result, options, theme, context) => renderTeamToolResult("teamsend", result, options, theme, context, getMarkdownTheme(), sessionTeammateRoster),
|
|
643
644
|
parameters: Type.Object({
|
|
644
645
|
team: Type.Optional(Type.String({ description: "Team name; optional only when exactly one team exists" })),
|
|
645
646
|
to: Type.Array(Type.String(), { description: "Recipient teammate names" }),
|
|
@@ -663,8 +664,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
663
664
|
description: "Set main's status for a team and/or read team statuses.",
|
|
664
665
|
promptSnippet: "Set/read team status maps",
|
|
665
666
|
renderShell: "self",
|
|
666
|
-
renderCall: (args, theme, context) => renderTeamToolCall("teamstatus", args, theme, context),
|
|
667
|
-
renderResult: (result, options, theme, context) => renderTeamToolResult("teamstatus", result, options, theme, context),
|
|
667
|
+
renderCall: (args, theme, context) => renderTeamToolCall("teamstatus", args, theme, context, sessionTeammateRoster),
|
|
668
|
+
renderResult: (result, options, theme, context) => renderTeamToolResult("teamstatus", result, options, theme, context, undefined, sessionTeammateRoster),
|
|
668
669
|
parameters: Type.Object({
|
|
669
670
|
team: Type.Optional(Type.String({ description: "Team name; optional for listing all statuses or when exactly one team exists" })),
|
|
670
671
|
// TODO: make gerund and phrase optionality a XOR.
|
|
@@ -691,8 +692,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
691
692
|
description: "Inspect a compact, paged, filterable event log for a pi-simple-team team.",
|
|
692
693
|
promptSnippet: "Inspect team event log",
|
|
693
694
|
renderShell: "self",
|
|
694
|
-
renderCall: (args, theme, context) => renderTeamToolCall("teamlog", args, theme, context),
|
|
695
|
-
renderResult: (result, options, theme, context) => renderTeamToolResult("teamlog", result, options, theme, context),
|
|
695
|
+
renderCall: (args, theme, context) => renderTeamToolCall("teamlog", args, theme, context, sessionTeammateRoster),
|
|
696
|
+
renderResult: (result, options, theme, context) => renderTeamToolResult("teamlog", result, options, theme, context, undefined, sessionTeammateRoster),
|
|
696
697
|
parameters: Type.Object({
|
|
697
698
|
team: Type.Optional(Type.String({ description: "Team name; optional only when exactly one team exists" })),
|
|
698
699
|
teammate: Type.Optional(Type.String({ description: "Filter to one teammate name" })),
|
|
@@ -743,8 +744,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
743
744
|
description: "Stop a team and kill its teammate processes.",
|
|
744
745
|
promptSnippet: "Stop a team and kill its teammate processes",
|
|
745
746
|
renderShell: "self",
|
|
746
|
-
renderCall: (args, theme, context) => renderTeamToolCall("team_shutdown", args, theme, context),
|
|
747
|
-
renderResult: (result, options, theme, context) => renderTeamToolResult("team_shutdown", result, options, theme, context),
|
|
747
|
+
renderCall: (args, theme, context) => renderTeamToolCall("team_shutdown", args, theme, context, sessionTeammateRoster),
|
|
748
|
+
renderResult: (result, options, theme, context) => renderTeamToolResult("team_shutdown", result, options, theme, context, undefined, sessionTeammateRoster),
|
|
748
749
|
parameters: Type.Object({
|
|
749
750
|
team: Type.Optional(Type.String({ description: "Team name; optional only when exactly one team exists" })),
|
|
750
751
|
}),
|
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -64,6 +64,10 @@ function wrapTeamLine(line: TeamLine, width: number): string[] {
|
|
|
64
64
|
return parts.map((part) => `${line.prefix}${part}`.trimEnd());
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
function clipToWidth(line: string, width: number): string {
|
|
68
|
+
return truncateToWidth(line, Math.max(1, width), glyphs().ellipsis);
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
/** Clips each logical line to the render width (collapsed) or wraps it (expanded). */
|
|
68
72
|
export class TeamLines {
|
|
69
73
|
private cachedWidth?: number;
|
|
@@ -84,7 +88,7 @@ export class TeamLines {
|
|
|
84
88
|
const targetWidth = Math.max(1, stableRenderWidth(width));
|
|
85
89
|
this.cachedLines =
|
|
86
90
|
this.mode === "clip"
|
|
87
|
-
? this.lines.map((line) =>
|
|
91
|
+
? this.lines.map((line) => clipToWidth(teamLineText(line), targetWidth))
|
|
88
92
|
: this.lines.flatMap((line) => wrapTeamLine(line, targetWidth));
|
|
89
93
|
this.cachedWidth = width;
|
|
90
94
|
return this.cachedLines;
|
|
@@ -147,7 +151,7 @@ export function statusWordToken(word: string): string {
|
|
|
147
151
|
return STATUS_WORD_TOKENS[word.trim().toLowerCase()] ?? "accent";
|
|
148
152
|
}
|
|
149
153
|
|
|
150
|
-
function memberRows(theme: ThemeLike, statuses: Record<string, TeamStatusView>, indent = ""): string[] {
|
|
154
|
+
function memberRows(theme: ThemeLike, statuses: Record<string, TeamStatusView>, roster: string[], indent = ""): string[] {
|
|
151
155
|
const names = Object.keys(statuses);
|
|
152
156
|
const nameWidth = Math.max(...names.map((name) => name.length));
|
|
153
157
|
const wordWidth = Math.max(...names.map((name) => statuses[name]!.word.length));
|
|
@@ -155,25 +159,25 @@ function memberRows(theme: ThemeLike, statuses: Record<string, TeamStatusView>,
|
|
|
155
159
|
const entry = statuses[name]!;
|
|
156
160
|
const branch = index === names.length - 1 ? "└" : "├";
|
|
157
161
|
const tail = statLine(theme, [entry.phrase, theme.fg("dim", entry.updated)]);
|
|
158
|
-
return `${indent}${treeConnector(theme, branch)}${theme.fg(
|
|
162
|
+
return `${indent}${treeConnector(theme, branch)}${theme.fg(actorHueToken(name, roster), padVisible(name, nameWidth))} ${theme.fg(statusWordToken(entry.word), padVisible(entry.word, wordWidth))} ${tail}`;
|
|
159
163
|
});
|
|
160
164
|
}
|
|
161
165
|
|
|
162
|
-
export function teamStatusLines(theme: ThemeLike, team: string, statuses: Record<string, TeamStatusView
|
|
166
|
+
export function teamStatusLines(theme: ThemeLike, team: string, statuses: Record<string, TeamStatusView>, roster: string[] = []): string[] {
|
|
163
167
|
const members = Object.values(statuses);
|
|
164
168
|
const workingCount = members.filter((member) => statusWordToken(member.word) === "success").length;
|
|
165
169
|
const stats = [theme.fg("muted", plural(members.length, "member"))];
|
|
166
170
|
if (workingCount > 0) stats.push(theme.fg("success", `${workingCount} working`));
|
|
167
|
-
return [headerLine(theme, "Team Status", theme.fg("accent", team), stats), ...memberRows(theme, statuses)];
|
|
171
|
+
return [headerLine(theme, "Team Status", theme.fg("accent", team), stats), ...memberRows(theme, statuses, roster)];
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
export function allTeamsStatusLines(theme: ThemeLike, teams: Record<string, Record<string, TeamStatusView
|
|
174
|
+
export function allTeamsStatusLines(theme: ThemeLike, teams: Record<string, Record<string, TeamStatusView>>, roster: string[] = []): string[] {
|
|
171
175
|
const teamNames = Object.keys(teams);
|
|
172
176
|
const lines = [headerLine(theme, "Team Status", theme.fg("muted", plural(teamNames.length, "team")))];
|
|
173
177
|
teamNames.forEach((teamName, index) => {
|
|
174
178
|
const branch = index === teamNames.length - 1 ? "└" : "├";
|
|
175
179
|
lines.push(`${treeConnector(theme, branch)}${theme.fg("accent", teamName)}`);
|
|
176
|
-
lines.push(...memberRows(theme, teams[teamName]!, treeStem(theme, branch)));
|
|
180
|
+
lines.push(...memberRows(theme, teams[teamName]!, roster, treeStem(theme, branch)));
|
|
177
181
|
});
|
|
178
182
|
return lines;
|
|
179
183
|
}
|
|
@@ -184,13 +188,13 @@ interface TeammateSpecView {
|
|
|
184
188
|
thinking?: string;
|
|
185
189
|
}
|
|
186
190
|
|
|
187
|
-
export function teamSpawnLines(theme: ThemeLike, team: string, teammates: TeammateSpecView[]): string[] {
|
|
191
|
+
export function teamSpawnLines(theme: ThemeLike, team: string, teammates: TeammateSpecView[], roster: string[] = []): string[] {
|
|
188
192
|
const header = headerLine(theme, "Team Spawn", theme.fg("accent", team), [theme.fg("muted", plural(teammates.length, "teammate"))]);
|
|
189
193
|
const nameWidth = Math.max(...teammates.map((teammate) => teammate.name.length));
|
|
190
194
|
const rows = teammates.map((teammate, index) => {
|
|
191
195
|
const branch = index === teammates.length - 1 ? "└" : "├";
|
|
192
196
|
const spec = statLine(theme, [theme.fg("muted", teammate.model), theme.fg("dim", teammate.thinking ?? "")]);
|
|
193
|
-
return `${treeConnector(theme, branch)}${theme.fg(
|
|
197
|
+
return `${treeConnector(theme, branch)}${theme.fg(actorHueToken(teammate.name, roster), padVisible(teammate.name, nameWidth))} ${spec}`;
|
|
194
198
|
});
|
|
195
199
|
return [header, ...rows];
|
|
196
200
|
}
|
|
@@ -208,24 +212,29 @@ function quotedBody(theme: ThemeLike, message: string, options: { lineLimit: num
|
|
|
208
212
|
|
|
209
213
|
const SEND_PREVIEW_LINES = 3;
|
|
210
214
|
|
|
211
|
-
function
|
|
212
|
-
return
|
|
215
|
+
function actorList(theme: ThemeLike, names: string[], roster: string[], separator: string): string {
|
|
216
|
+
return names.map((name) => theme.fg(actorHueToken(name, roster), name)).join(theme.fg("muted", separator));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function sendTarget(theme: ThemeLike, to: string[], roster: string[] = []): string {
|
|
220
|
+
const recipients = actorList(theme, to, roster, ", ");
|
|
221
|
+
return `${theme.fg("muted", `${glyphs().arrow} `)}${recipients}`;
|
|
213
222
|
}
|
|
214
223
|
|
|
215
224
|
function sendStats(theme: ThemeLike, message: string, interrupt: boolean): string[] {
|
|
216
225
|
return [interrupt ? theme.fg("warning", "interrupt") : "", theme.fg("muted", formatCharCount(message.length))];
|
|
217
226
|
}
|
|
218
227
|
|
|
219
|
-
export function teamSendLines(theme: ThemeLike, options: { to: string[]; message: string; interrupt: boolean; expanded: boolean }): TeamLine[] {
|
|
220
|
-
const header = headerLine(theme, "Team Send", sendTarget(theme, options.to), sendStats(theme, options.message, options.interrupt));
|
|
228
|
+
export function teamSendLines(theme: ThemeLike, options: { to: string[]; message: string; interrupt: boolean; expanded: boolean }, roster: string[] = []): TeamLine[] {
|
|
229
|
+
const header = headerLine(theme, "Team Send", sendTarget(theme, options.to, roster), sendStats(theme, options.message, options.interrupt));
|
|
221
230
|
const lineLimit = options.expanded ? Number.POSITIVE_INFINITY : SEND_PREVIEW_LINES;
|
|
222
231
|
return [header, ...quotedBody(theme, options.message, { lineLimit, barToken: "muted" })];
|
|
223
232
|
}
|
|
224
233
|
|
|
225
|
-
export function teamShutdownLines(theme: ThemeLike, team: string, teammates: string[]): string[] {
|
|
234
|
+
export function teamShutdownLines(theme: ThemeLike, team: string, teammates: string[], roster: string[] = []): string[] {
|
|
226
235
|
const header = headerLine(theme, "Team Shutdown", theme.fg("accent", team), [theme.fg("muted", `${plural(teammates.length, "teammate")} stopped`)]);
|
|
227
236
|
if (teammates.length === 0) return [header];
|
|
228
|
-
return [header, `${treeConnector(theme, "└")}${theme
|
|
237
|
+
return [header, `${treeConnector(theme, "└")}${actorList(theme, teammates, roster, glyphs().dot)}`];
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
const TEAMMATE_HUE_TOKENS = ["mdCode", "customMessageLabel", "mdHeading"] as const;
|
|
@@ -470,7 +479,7 @@ function actionRows(theme: ThemeLike, actions: LogAction[], roster: string[], ha
|
|
|
470
479
|
});
|
|
471
480
|
}
|
|
472
481
|
|
|
473
|
-
function filterStats(theme: ThemeLike, filters: Record<string, unknown
|
|
482
|
+
function filterStats(theme: ThemeLike, filters: Record<string, unknown>, roster: string[]): string[] {
|
|
474
483
|
const stats: string[] = [];
|
|
475
484
|
for (const [key, value] of Object.entries(filters)) {
|
|
476
485
|
if (typeof value !== "string" || !value) continue;
|
|
@@ -479,6 +488,10 @@ function filterStats(theme: ThemeLike, filters: Record<string, unknown>): string
|
|
|
479
488
|
stats.push(theme.fg("borderMuted", `since ${Number.isFinite(parsed) ? timeOfDay(parsed) : value}`));
|
|
480
489
|
continue;
|
|
481
490
|
}
|
|
491
|
+
if (key === "teammate") {
|
|
492
|
+
stats.push(`${theme.fg("borderMuted", "teammate=")}${theme.fg(actorHueToken(value, roster), value)}`);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
482
495
|
stats.push(theme.fg("borderMuted", `${key}=${value}`));
|
|
483
496
|
}
|
|
484
497
|
return stats;
|
|
@@ -490,7 +503,7 @@ export function teamLogLines(theme: ThemeLike, view: TeamLogRenderView): string[
|
|
|
490
503
|
const stats = [
|
|
491
504
|
theme.fg("muted", plural(actions.length, "action")),
|
|
492
505
|
theme.fg("muted", view.returned === view.totalMatched ? plural(view.returned, "event") : `${view.returned} of ${view.totalMatched} events`),
|
|
493
|
-
...filterStats(theme, view.filters ?? {}),
|
|
506
|
+
...filterStats(theme, view.filters ?? {}, view.roster ?? []),
|
|
494
507
|
];
|
|
495
508
|
const header = headerLine(theme, "Team Log", theme.fg("accent", view.team), stats);
|
|
496
509
|
if (view.entries.length === 0) return [header, `${treeConnector(theme, "└")}${theme.fg("muted", "no matching events")}`];
|
|
@@ -502,22 +515,22 @@ export function teamLogLines(theme: ThemeLike, view: TeamLogRenderView): string[
|
|
|
502
515
|
return [header, ...rows, ...(footer ? [footer] : [])];
|
|
503
516
|
}
|
|
504
517
|
|
|
505
|
-
export function teamMessageLines(theme: ThemeLike, details: TeamMessageDetails): TeamLine[] {
|
|
518
|
+
export function teamMessageLines(theme: ThemeLike, details: TeamMessageDetails, roster: string[] = []): TeamLine[] {
|
|
506
519
|
const g = glyphs();
|
|
507
520
|
const header = [
|
|
508
521
|
theme.fg("accent", `${g.diamond} `),
|
|
509
|
-
theme.fg(
|
|
522
|
+
theme.fg(actorHueToken(details.from, roster), theme.bold(details.from)),
|
|
510
523
|
theme.fg("muted", ` ${g.arrow} main`),
|
|
511
524
|
theme.fg("dim", `${g.dot}${details.team}${g.dot}${details.sentAt}`),
|
|
512
525
|
].join("");
|
|
513
526
|
return [header, ...quotedBody(theme, details.message, { lineLimit: Number.POSITIVE_INFINITY, barToken: "accent" })];
|
|
514
527
|
}
|
|
515
528
|
|
|
516
|
-
function teamMessageHeader(theme: ThemeLike, details: TeamMessageDetails): string {
|
|
529
|
+
function teamMessageHeader(theme: ThemeLike, details: TeamMessageDetails, roster: string[]): string {
|
|
517
530
|
const g = glyphs();
|
|
518
531
|
return [
|
|
519
532
|
theme.fg("accent", `${g.diamond} `),
|
|
520
|
-
theme.fg(
|
|
533
|
+
theme.fg(actorHueToken(details.from, roster), theme.bold(details.from)),
|
|
521
534
|
theme.fg("muted", ` ${g.arrow} main`),
|
|
522
535
|
theme.fg("dim", `${g.dot}${details.team}${g.dot}${details.sentAt}`),
|
|
523
536
|
].join("");
|
|
@@ -545,17 +558,18 @@ class TeamSendView {
|
|
|
545
558
|
}
|
|
546
559
|
|
|
547
560
|
render(width: number): string[] {
|
|
561
|
+
const header = clipToWidth(this.headerStr, width);
|
|
548
562
|
const bodyWidth = Math.max(10, width - this.barWidth);
|
|
549
563
|
const bodyLines = this.md.render(bodyWidth);
|
|
550
564
|
const barred = bodyLines.map((line) => `${this.barStr}${line}`);
|
|
551
|
-
if (this.expanded) return [
|
|
565
|
+
if (this.expanded) return [header, ...barred];
|
|
552
566
|
const shown = barred.slice(0, SEND_PREVIEW_LINES);
|
|
553
567
|
const hidden = barred.length - SEND_PREVIEW_LINES;
|
|
554
568
|
if (hidden > 0) {
|
|
555
569
|
const g = glyphs();
|
|
556
570
|
shown.push(`${this.barStr}${this.theme.fg("dim", `${g.ellipsis} ${hidden} more line${hidden === 1 ? "" : "s"}${g.dot}ctrl+o to expand`)}`);
|
|
557
571
|
}
|
|
558
|
-
return [
|
|
572
|
+
return [header, ...shown];
|
|
559
573
|
}
|
|
560
574
|
}
|
|
561
575
|
|
|
@@ -579,7 +593,7 @@ class TeamMessageView {
|
|
|
579
593
|
render(width: number): string[] {
|
|
580
594
|
const bodyWidth = Math.max(10, width - this.barWidth);
|
|
581
595
|
const bodyLines = this.md.render(bodyWidth);
|
|
582
|
-
return [this.headerLine, ...bodyLines.map((line) => `${this.barStr}${line}`)];
|
|
596
|
+
return [clipToWidth(this.headerLine, width), ...bodyLines.map((line) => `${this.barStr}${line}`)];
|
|
583
597
|
}
|
|
584
598
|
}
|
|
585
599
|
|
|
@@ -587,14 +601,14 @@ function accentTeam(theme: ThemeLike, team: unknown): string {
|
|
|
587
601
|
return typeof team === "string" && team ? theme.fg("accent", team) : "";
|
|
588
602
|
}
|
|
589
603
|
|
|
590
|
-
function callBodyFor(tool: TeamToolName, theme: ThemeLike, args: Record<string, unknown
|
|
604
|
+
function callBodyFor(tool: TeamToolName, theme: ThemeLike, args: Record<string, unknown>, roster: string[]): string {
|
|
591
605
|
if (tool === "team_spawn") {
|
|
592
606
|
const teammates = (args.teammates ?? []) as unknown[];
|
|
593
607
|
return callBody(theme, "Team Spawn", accentTeam(theme, args.team), [theme.fg("muted", plural(teammates.length, "teammate"))]);
|
|
594
608
|
}
|
|
595
609
|
if (tool === "teamsend") {
|
|
596
610
|
const message = String(args.message ?? "");
|
|
597
|
-
return callBody(theme, "Team Send", sendTarget(theme, (args.to ?? []) as string[]), sendStats(theme, message, Boolean(args.interrupt)));
|
|
611
|
+
return callBody(theme, "Team Send", sendTarget(theme, (args.to ?? []) as string[], roster), sendStats(theme, message, Boolean(args.interrupt)));
|
|
598
612
|
}
|
|
599
613
|
if (tool === "teamstatus") {
|
|
600
614
|
const target = accentTeam(theme, args.team) || theme.fg("muted", "all teams");
|
|
@@ -604,15 +618,19 @@ function callBodyFor(tool: TeamToolName, theme: ThemeLike, args: Record<string,
|
|
|
604
618
|
if (tool === "teamlog") {
|
|
605
619
|
const filterStats = ["teammate", "kind", "search", "since", "cursor"]
|
|
606
620
|
.filter((key) => typeof args[key] === "string" && args[key])
|
|
607
|
-
.map((key) =>
|
|
621
|
+
.map((key) => {
|
|
622
|
+
const value = String(args[key]);
|
|
623
|
+
if (key === "teammate") return `${theme.fg("dim", "teammate=")}${theme.fg(actorHueToken(value, roster), value)}`;
|
|
624
|
+
return theme.fg("dim", `${key}=${value}`);
|
|
625
|
+
});
|
|
608
626
|
return callBody(theme, "Team Log", accentTeam(theme, args.team), filterStats);
|
|
609
627
|
}
|
|
610
628
|
return callBody(theme, "Team Shutdown", accentTeam(theme, args.team));
|
|
611
629
|
}
|
|
612
630
|
|
|
613
|
-
function resultLinesFor(tool: TeamToolName, theme: ThemeLike, args: Record<string, unknown>, details: Record<string, unknown>, expanded: boolean): TeamLine[] {
|
|
631
|
+
function resultLinesFor(tool: TeamToolName, theme: ThemeLike, args: Record<string, unknown>, details: Record<string, unknown>, expanded: boolean, roster: string[]): TeamLine[] {
|
|
614
632
|
if (tool === "team_spawn") {
|
|
615
|
-
return teamSpawnLines(theme, String(details.team), (args.teammates ?? []) as TeammateSpecView[]);
|
|
633
|
+
return teamSpawnLines(theme, String(details.team), (args.teammates ?? []) as TeammateSpecView[], roster);
|
|
616
634
|
}
|
|
617
635
|
if (tool === "teamsend") {
|
|
618
636
|
return teamSendLines(theme, {
|
|
@@ -620,17 +638,17 @@ function resultLinesFor(tool: TeamToolName, theme: ThemeLike, args: Record<strin
|
|
|
620
638
|
message: String(args.message ?? ""),
|
|
621
639
|
interrupt: Boolean(details.interrupt),
|
|
622
640
|
expanded,
|
|
623
|
-
});
|
|
641
|
+
}, roster);
|
|
624
642
|
}
|
|
625
643
|
if (tool === "teamstatus") {
|
|
626
|
-
if (details.teams) return allTeamsStatusLines(theme, details.teams as Record<string, Record<string, TeamStatusView
|
|
627
|
-
return teamStatusLines(theme, String(details.team), details.status as Record<string, TeamStatusView
|
|
644
|
+
if (details.teams) return allTeamsStatusLines(theme, details.teams as Record<string, Record<string, TeamStatusView>>, roster);
|
|
645
|
+
return teamStatusLines(theme, String(details.team), details.status as Record<string, TeamStatusView>, roster);
|
|
628
646
|
}
|
|
629
647
|
if (tool === "teamlog") {
|
|
630
648
|
const filters = (details.filters ?? {}) as Record<string, unknown>;
|
|
631
649
|
return teamLogLines(theme, {
|
|
632
650
|
team: String(details.team),
|
|
633
|
-
roster: (details.roster ?? []) as string[],
|
|
651
|
+
roster: roster.length > 0 ? roster : (details.roster ?? []) as string[],
|
|
634
652
|
entries: (details.entries ?? []) as TeamLogEntry[],
|
|
635
653
|
totalMatched: Number(details.totalMatched ?? 0),
|
|
636
654
|
returned: Number(details.returned ?? 0),
|
|
@@ -638,11 +656,11 @@ function resultLinesFor(tool: TeamToolName, theme: ThemeLike, args: Record<strin
|
|
|
638
656
|
filters: { teammate: filters.teammate, kind: filters.kind, search: filters.search, since: filters.since },
|
|
639
657
|
});
|
|
640
658
|
}
|
|
641
|
-
return teamShutdownLines(theme, String(details.team), (details.teammates ?? []) as string[]);
|
|
659
|
+
return teamShutdownLines(theme, String(details.team), (details.teammates ?? []) as string[], roster);
|
|
642
660
|
}
|
|
643
661
|
|
|
644
|
-
export function renderTeamToolCall(tool: TeamToolName, args: Record<string, unknown>, theme: ThemeLike, context: ToolRenderContextLike) {
|
|
645
|
-
return renderPendingCall(callBodyFor(tool, theme, args ?? {}), theme, context, context?.cwd);
|
|
662
|
+
export function renderTeamToolCall(tool: TeamToolName, args: Record<string, unknown>, theme: ThemeLike, context: ToolRenderContextLike, roster: string[] = []) {
|
|
663
|
+
return renderPendingCall(callBodyFor(tool, theme, args ?? {}, roster), theme, context, context?.cwd);
|
|
646
664
|
}
|
|
647
665
|
|
|
648
666
|
export function renderTeamToolResult(
|
|
@@ -652,28 +670,29 @@ export function renderTeamToolResult(
|
|
|
652
670
|
theme: ThemeLike,
|
|
653
671
|
context: ToolRenderContextLike,
|
|
654
672
|
markdownTheme?: MarkdownTheme,
|
|
673
|
+
roster: string[] = [],
|
|
655
674
|
): TeamSendView | TeamLines {
|
|
656
675
|
const args = context?.args ?? {};
|
|
657
676
|
if (context?.isError || result?.isError) {
|
|
658
|
-
return new TeamLines(errorLines(theme, callBodyFor(tool, theme, args), textContent(result)), options.expanded ? "wrap" : "clip");
|
|
677
|
+
return new TeamLines(errorLines(theme, callBodyFor(tool, theme, args, roster), textContent(result)), options.expanded ? "wrap" : "clip");
|
|
659
678
|
}
|
|
660
679
|
const details = (result?.details ?? {}) as Record<string, unknown>;
|
|
661
680
|
if (markdownTheme && tool === "teamsend") {
|
|
662
681
|
const message = String(args.message ?? "");
|
|
663
|
-
const header = headerLine(theme, "Team Send", sendTarget(theme, (details.to ?? []) as string[]), sendStats(theme, message, Boolean(details.interrupt)));
|
|
682
|
+
const header = headerLine(theme, "Team Send", sendTarget(theme, (details.to ?? []) as string[], roster), sendStats(theme, message, Boolean(details.interrupt)));
|
|
664
683
|
const bar = ` ${theme.fg("muted", glyphs().codeBar)} `;
|
|
665
684
|
return new TeamSendView(header, message, bar, markdownTheme, options.expanded, theme);
|
|
666
685
|
}
|
|
667
|
-
return new TeamLines(resultLinesFor(tool, theme, args, details, options.expanded), options.expanded ? "wrap" : "clip");
|
|
686
|
+
return new TeamLines(resultLinesFor(tool, theme, args, details, options.expanded, roster), options.expanded ? "wrap" : "clip");
|
|
668
687
|
}
|
|
669
688
|
|
|
670
|
-
export function renderTeamMessage(message: { details?: unknown }, theme: ThemeLike, markdownTheme?: MarkdownTheme): TeamMessageView | TeamLines | undefined {
|
|
689
|
+
export function renderTeamMessage(message: { details?: unknown }, theme: ThemeLike, markdownTheme?: MarkdownTheme, roster: string[] = []): TeamMessageView | TeamLines | undefined {
|
|
671
690
|
const details = message.details as TeamMessageDetails | undefined;
|
|
672
691
|
if (!details?.from || !details?.team || typeof details.message !== "string") return undefined;
|
|
673
692
|
if (markdownTheme) {
|
|
674
693
|
const g = glyphs();
|
|
675
694
|
const bar = ` ${theme.fg("accent", g.codeBar)} `;
|
|
676
|
-
return new TeamMessageView(teamMessageHeader(theme, details), details.message, bar, markdownTheme);
|
|
695
|
+
return new TeamMessageView(teamMessageHeader(theme, details, roster), details.message, bar, markdownTheme);
|
|
677
696
|
}
|
|
678
|
-
return new TeamLines(teamMessageLines(theme, details), "wrap");
|
|
697
|
+
return new TeamLines(teamMessageLines(theme, details, roster), "wrap");
|
|
679
698
|
}
|