@giladbarnea/pi-simple-team 2.0.17 → 2.0.19
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 +2 -2
- package/child-tools.ts +11 -0
- package/index.ts +21 -7
- package/model-names.ts +20 -0
- package/package.json +1 -1
- package/render.ts +10 -7
- package/team-briefing.ts +1 -0
- package/team-selection.ts +39 -3
- package/teamlog.ts +11 -0
- package/teammate-facts.ts +3 -2
package/README.md
CHANGED
|
@@ -239,7 +239,7 @@ Spawn, resume, and add return the complete roster. Results distinguish a live ru
|
|
|
239
239
|
|
|
240
240
|
Set `showOnHerdrPane: true` on individual teammates to open their panes. An explicit `showOnHerdrPanes` value on spawn overrides all individual settings.
|
|
241
241
|
|
|
242
|
-
`extensionPaths` lists trusted, existing absolute extension paths for one teammate. RPC and Herdr launches load them alongside the team runtime, and resume keeps them.
|
|
242
|
+
`extensionPaths` lists trusted, existing absolute extension paths for one teammate. RPC and Herdr launches load them alongside the team runtime and the extensions a plain `pi` launch in the project discovers, and resume keeps them. The parent's own command-line `-e` extensions and `--no-extensions` are not inherited. An `extensionPaths` entry at a different path from a discovered copy of the same extension stops teammate startup when that extension registers tools or flags. The same path, or a symlink to it, loads once. These modules run with the same permissions as Pi.
|
|
243
243
|
|
|
244
244
|
Message tools return `published: true` when the extension accepts a message for delivery. If delivery later fails, the sender receives the error automatically.
|
|
245
245
|
|
|
@@ -263,7 +263,7 @@ Message tools return `published: true` when the extension accepts a message for
|
|
|
263
263
|
- [x] Resume all or selected teammates from a dormant team.
|
|
264
264
|
- [x] Add teammates after a team has spawned.
|
|
265
265
|
- [x] Let opted-in teammates create and manage teams of their own.
|
|
266
|
-
- [
|
|
266
|
+
- [ ] Remove teammates from a team.
|
|
267
267
|
- [ ] Main triggers `/compact` on select teammate.
|
|
268
268
|
- [ ] Teammates auto-reminded to hand off on low context.
|
|
269
269
|
|
package/child-tools.ts
CHANGED
|
@@ -65,6 +65,17 @@ function readRequiredChildRuntimeConfig(): ChildRuntimeConfig {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A teammate process inherits discovered extensions, so it can also discover an installed copy of this package at another path.
|
|
70
|
+
* Only the copy main passed as PI_SIMPLE_TEAM_RUNTIME_PATH registers; another copy stays inert so their tools cannot conflict.
|
|
71
|
+
* Simulated teammates without that variable load every copy.
|
|
72
|
+
*/
|
|
73
|
+
export function isInertTeamCopy(extensionPath: string): boolean {
|
|
74
|
+
const runtimePath = process.env.PI_SIMPLE_TEAM_RUNTIME_PATH;
|
|
75
|
+
const teammateProcess = process.env.PI_SIMPLE_TEAM_CHILD === "1" || process.env.PI_SIMPLE_TEAM_CHILD === String(process.pid);
|
|
76
|
+
return teammateProcess && runtimePath !== undefined && runtimePath !== extensionPath;
|
|
77
|
+
}
|
|
78
|
+
|
|
68
79
|
/**
|
|
69
80
|
* Main marks only the process it starts with PI_SIMPLE_TEAM_CHILD=1. That process claims the teammate identity for its PID, which
|
|
70
81
|
* survives Pi's in-process reloads and session replacements. Subprocesses inherit the environment, not the claim, so they run as main.
|
package/index.ts
CHANGED
|
@@ -7,10 +7,11 @@ import * as path from "node:path";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { defineTool, type ContextUsage, type ExtensionAPI, type ExtensionContext, getMarkdownTheme, getPackageDir } from "@earendil-works/pi-coding-agent";
|
|
9
9
|
import { formatContextWindowReport, requireKnownContextUsage, type KnownContextUsage } from "./context-window.ts";
|
|
10
|
+
import { useModelNames } from "./model-names.ts";
|
|
10
11
|
import { formatScopedModelGuidance, validateTeammateModels, type ModelReference } from "./model-preflight.ts";
|
|
11
12
|
import { composeTeamBriefing } from "./team-briefing.ts";
|
|
12
13
|
import { composeResumptionMessage } from "./resume-message.ts";
|
|
13
|
-
import { callParent, readChildRuntimeConfig, registerChildTools } from "./child-tools.ts";
|
|
14
|
+
import { callParent, isInertTeamCopy, readChildRuntimeConfig, registerChildTools } from "./child-tools.ts";
|
|
14
15
|
import {
|
|
15
16
|
canonicalProjectDirectory,
|
|
16
17
|
claimTeamLease,
|
|
@@ -29,7 +30,7 @@ import { renderReminderToolCall, renderReminderToolResult, renderTeamMessage, re
|
|
|
29
30
|
import { openTeamOverview, type TeamSnapshot } from "./team-ui.ts";
|
|
30
31
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
31
32
|
import { Type } from "typebox";
|
|
32
|
-
import { resolveTargets, resolveTeammates, interruptedTeammateIds, targetDescription, interruptDescription, type SelectableTeam } from "./team-selection.ts";
|
|
33
|
+
import { resolveTargets, resolveTeammates, interruptedTeammateIds, findUnknownTarget, unknownTargetMessage, targetDescription, interruptDescription, type DormantTeammateMatch, type SelectableTeam } from "./team-selection.ts";
|
|
33
34
|
import type { Teammate, TeammateRecord, ThinkingLevel } from "./teammate.ts";
|
|
34
35
|
|
|
35
36
|
type JsonRecord = Record<string, unknown>;
|
|
@@ -514,6 +515,7 @@ function createTeammateState(teammateSpec: Teammate): TeammateState {
|
|
|
514
515
|
function childEnvironmentOverrides(team: TeamState, teammate: TeammateState, participants: string[]): Record<string, string> {
|
|
515
516
|
return {
|
|
516
517
|
PI_SIMPLE_TEAM_CHILD: "1",
|
|
518
|
+
PI_SIMPLE_TEAM_RUNTIME_PATH: teamLiteExtensionPath,
|
|
517
519
|
PI_SIMPLE_TEAM_CALLBACK_URL: callbackUrl,
|
|
518
520
|
PI_SIMPLE_TEAM_CALLBACK_TOKEN: callbackToken,
|
|
519
521
|
PI_SIMPLE_TEAM_TEAM: team.id ?? team.name,
|
|
@@ -560,7 +562,6 @@ function attachRpcTeammate(team: TeamState, teammate: TeammateState, participant
|
|
|
560
562
|
"--mode",
|
|
561
563
|
"rpc",
|
|
562
564
|
...sessionArgs,
|
|
563
|
-
"--no-extensions",
|
|
564
565
|
"-e",
|
|
565
566
|
teamLiteExtensionPath,
|
|
566
567
|
...teammate.extensionPaths.flatMap(extensionPath => ["-e", extensionPath]),
|
|
@@ -625,7 +626,6 @@ async function attachHerdrTeammate(
|
|
|
625
626
|
const command = [
|
|
626
627
|
...team.parentPiCommand,
|
|
627
628
|
...sessionArgs,
|
|
628
|
-
"--no-extensions",
|
|
629
629
|
"-e",
|
|
630
630
|
teamLiteExtensionPath,
|
|
631
631
|
...teammate.extensionPaths.flatMap(extensionPath => ["-e", extensionPath]),
|
|
@@ -995,7 +995,7 @@ function teammateSchema(modelGuidance: string) {
|
|
|
995
995
|
forkContext: Type.Optional(Type.Boolean({ description: "Start as a fork of your context window rather than fresh. Defaults to false.", default: false })),
|
|
996
996
|
canManageOwnTeams: Type.Optional(Type.Boolean({ description: "Allow this teammate to create and manage teams of its own. Defaults to false.", default: false })),
|
|
997
997
|
showOnHerdrPane: Type.Optional(Type.Boolean({ description: "Open a visible Herdr pane for this teammate. Defaults to false.", default: false })),
|
|
998
|
-
extensionPaths: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true, description: "Trusted extension files or directories to load alongside the team runtime. Use existing absolute paths. Saved for later resume; discovered extensions
|
|
998
|
+
extensionPaths: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true, description: "Trusted extension files or directories to load alongside the team runtime. Use existing absolute paths. Saved for later resume; discovered extensions also load." })),
|
|
999
999
|
}, { additionalProperties: false });
|
|
1000
1000
|
}
|
|
1001
1001
|
|
|
@@ -1061,6 +1061,7 @@ function piCommand(entry: string, runtime: string, packageDirectory: string): st
|
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
1063
1063
|
export default function (pi: ExtensionAPI) {
|
|
1064
|
+
if (isInertTeamCopy(teamLiteExtensionPath)) return;
|
|
1064
1065
|
const childRuntimeConfig = readChildRuntimeConfig();
|
|
1065
1066
|
if (childRuntimeConfig) {
|
|
1066
1067
|
registerChildTools(pi, childRuntimeConfig);
|
|
@@ -1083,6 +1084,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
1083
1084
|
);
|
|
1084
1085
|
}
|
|
1085
1086
|
|
|
1087
|
+
/** Stored dormant teammates of resumable current-project teams whose name or session ID is `identifier`. */
|
|
1088
|
+
function dormantTeammateMatches(context: ExtensionContext, identifier: string): DormantTeammateMatch[] {
|
|
1089
|
+
const name = identifier.trim();
|
|
1090
|
+
return resumableTeamManifests(context, "team_send_message")
|
|
1091
|
+
.filter((manifest) => manifest.state === "dormant")
|
|
1092
|
+
.flatMap((manifest) => manifest.members
|
|
1093
|
+
.filter((member) => member.name === name || member.teammateId === name)
|
|
1094
|
+
.map((member) => ({ teamId: manifest.id, teammateId: member.teammateId })));
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1086
1097
|
pi.registerMessageRenderer(teamMessageType, (message, options, theme) => renderTeamMessage(message, options, theme, getMarkdownTheme(), sessionTeammateRoster));
|
|
1087
1098
|
|
|
1088
1099
|
pi.registerCommand("team", {
|
|
@@ -1102,13 +1113,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
1102
1113
|
});
|
|
1103
1114
|
|
|
1104
1115
|
pi.on("session_start", (_event, context) => {
|
|
1116
|
+
useModelNames(context.modelRegistry);
|
|
1105
1117
|
const scopedModels = (context as typeof context & { scopedModels?: ReadonlyArray<{ model: ModelReference }> }).scopedModels ?? [];
|
|
1106
1118
|
const modelGuidance = formatScopedModelGuidance(scopedModels.map(({ model }) => model));
|
|
1107
1119
|
pi.registerTool(
|
|
1108
1120
|
defineTool({
|
|
1109
1121
|
name: "team_spawn",
|
|
1110
1122
|
label: "Team Spawn",
|
|
1111
|
-
description: "Spawn a versatile team of agents. You are automatically part of the team as main. Do not include yourself in teammates. Use `team_resume` to continue an existing team, or `team_add_teammates` to grow one.",
|
|
1123
|
+
description: "Spawn a versatile team of agents. It can also be used as a regular background agent spawn in a one-person team. You are automatically part of the team as main. Do not include yourself in teammates. Use `team_resume` to continue an existing team, or `team_add_teammates` to grow one.",
|
|
1112
1124
|
renderShell: "self",
|
|
1113
1125
|
renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context, sessionTeammateRoster),
|
|
1114
1126
|
renderResult: (result, options, theme, context) => renderTeamToolResult("team_spawn", result, options, theme, context, getMarkdownTheme(), sessionTeammateRoster),
|
|
@@ -1494,9 +1506,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1494
1506
|
message: Type.String({ description: "Message to send" }),
|
|
1495
1507
|
interrupt: Type.Optional(Type.Union([Type.Boolean(), Type.Array(Type.String({ minLength: 1 }))], { description: interruptDescription })),
|
|
1496
1508
|
}, { additionalProperties: false }),
|
|
1497
|
-
async execute(_toolCallId, params, signal) {
|
|
1509
|
+
async execute(_toolCallId, params, signal, _onUpdate, context) {
|
|
1498
1510
|
const parent = childRuntimeConfig ? await callParent(childRuntimeConfig, "team_context", {}, signal) as unknown as SelectableTeam : undefined;
|
|
1499
1511
|
const candidates = [...ownedTargetTeams(owner), ...(parent ? [parent] : [])];
|
|
1512
|
+
const unknownTarget = findUnknownTarget(candidates, params.targets);
|
|
1513
|
+
if (unknownTarget !== undefined) throw new Error(unknownTargetMessage(unknownTarget, candidates, dormantTeammateMatches(context, unknownTarget)));
|
|
1500
1514
|
const selections = resolveTargets(candidates, params.targets);
|
|
1501
1515
|
const interrupted = interruptedTeammateIds(candidates, selections, params.interrupt);
|
|
1502
1516
|
const statuses: JsonRecord[] = [];
|
package/model-names.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModelRegistry } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
type ModelNameSource = Pick<ModelRegistry, "find">;
|
|
4
|
+
|
|
5
|
+
let modelNameSource: ModelNameSource | undefined;
|
|
6
|
+
|
|
7
|
+
/** Team screens read model names from the session's Pi model registry, which session_start provides. */
|
|
8
|
+
export function useModelNames(registry: ModelNameSource): void {
|
|
9
|
+
modelNameSource = registry;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Pi's name for a "provider/id" model, for human-facing team screens only: the user's models.json name, else the built-in name.
|
|
14
|
+
* Undefined when Pi does not know the model or no session has started.
|
|
15
|
+
* @example piModelName("anthropic/claude-opus-5-5") // "opus" under a models.json name override
|
|
16
|
+
*/
|
|
17
|
+
export function piModelName(model: string): string | undefined {
|
|
18
|
+
const slash = model.indexOf("/");
|
|
19
|
+
return modelNameSource?.find(model.slice(0, slash), model.slice(slash + 1))?.name;
|
|
20
|
+
}
|
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { padVisible, stableRenderWidth, visibleLength } from "./render-support/a
|
|
|
4
4
|
import { glyphs } from "./render-support/glyphs.ts";
|
|
5
5
|
import { stackPrefix, toolLabel, treeConnector, treeStem } from "./render-support/theme.ts";
|
|
6
6
|
import { commandExit, plural, renderPendingCall, textContent } from "./render-support/text.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { piModelName } from "./model-names.ts";
|
|
8
|
+
import { futureTime, logRowTime, monthDay, relativeTime, timeOfDay, type TeamLogEntry } from "./teamlog.ts";
|
|
8
9
|
import { actorHueToken, DIM_SGR_CLOSE, DIM_SGR_OPEN, FactTable, inlineFact, statusWordToken, type FactRow, type TeammateView } from "./teammate-facts.ts";
|
|
9
10
|
|
|
10
11
|
export { actorHueToken, statusWordToken, type TeammateView };
|
|
@@ -570,7 +571,7 @@ export function foldLogEntries(entries: TeamLogEntry[]): LogAction[] {
|
|
|
570
571
|
icon: "diamond",
|
|
571
572
|
iconToken: "borderMuted",
|
|
572
573
|
action: "spawn",
|
|
573
|
-
details: [textDetail(typeof details.model === "string" ? details.model : ""), textDetail(typeof details.thinking === "string" ? details.thinking : "")],
|
|
574
|
+
details: [textDetail(typeof details.model === "string" ? piModelName(details.model) ?? details.model : ""), textDetail(typeof details.thinking === "string" ? details.thinking : "")],
|
|
574
575
|
});
|
|
575
576
|
continue;
|
|
576
577
|
}
|
|
@@ -604,8 +605,8 @@ function renderLogDetail(theme: ThemeLike, detail: LogDetail, roster: string[]):
|
|
|
604
605
|
|
|
605
606
|
const LOG_ROW_INDENT = " ";
|
|
606
607
|
|
|
607
|
-
function logChrome(theme: ThemeLike, sequence: number, seqWidth: number,
|
|
608
|
-
return theme.fg("borderMuted", `${LOG_ROW_INDENT}${padVisible(`#${sequence}`, seqWidth)} ${
|
|
608
|
+
function logChrome(theme: ThemeLike, sequence: number, seqWidth: number, time: string, timeWidth: number): string {
|
|
609
|
+
return theme.fg("borderMuted", `${LOG_ROW_INDENT}${padVisible(`#${sequence}`, seqWidth)} ${padVisible(time, timeWidth)}`);
|
|
609
610
|
}
|
|
610
611
|
|
|
611
612
|
function sameLocalDay(a: number, b: number): boolean {
|
|
@@ -617,17 +618,19 @@ function dayDividerLine(theme: ThemeLike, epochMilliseconds: number): string {
|
|
|
617
618
|
return `${LOG_ROW_INDENT}${theme.fg("borderMuted", `${rule.repeat(2)} ${monthDay(epochMilliseconds)} ${rule.repeat(30)}`)}`;
|
|
618
619
|
}
|
|
619
620
|
|
|
620
|
-
/** Log rows
|
|
621
|
+
/** Log rows show short relative time under an hour and absolute HH:MM:SS after; day dividers carry the date whenever a row is not from "today". */
|
|
621
622
|
function actionRows(theme: ThemeLike, actions: LogAction[], roster: string[], nowMilliseconds: number): string[] {
|
|
622
623
|
const g = glyphs();
|
|
623
624
|
const seqWidth = Math.max(...actions.map((action) => `#${action.sequence}`.length));
|
|
625
|
+
const times = actions.map((action) => logRowTime(action.epochMilliseconds, nowMilliseconds));
|
|
626
|
+
const timeWidth = Math.max(...times.map((time) => time.length));
|
|
624
627
|
const whoWidth = Math.max(...actions.map((action) => action.who.length));
|
|
625
628
|
const actionWidth = Math.max(...actions.map((action) => action.action.length));
|
|
626
629
|
const iconWidth = Math.max(...actions.map((action) => visibleLength(logIconGlyph(action.icon))));
|
|
627
630
|
const rows: string[] = [];
|
|
628
631
|
let previousWho: string | undefined;
|
|
629
632
|
let previousEpoch = nowMilliseconds;
|
|
630
|
-
for (const action of actions) {
|
|
633
|
+
for (const [index, action] of actions.entries()) {
|
|
631
634
|
if (!sameLocalDay(action.epochMilliseconds, previousEpoch)) {
|
|
632
635
|
rows.push(dayDividerLine(theme, action.epochMilliseconds));
|
|
633
636
|
previousWho = undefined;
|
|
@@ -643,7 +646,7 @@ function actionRows(theme: ThemeLike, actions: LogAction[], roster: string[], no
|
|
|
643
646
|
.filter((detail) => detail.style !== "text" || detail.text.length > 0)
|
|
644
647
|
.map((detail) => renderLogDetail(theme, detail, roster))
|
|
645
648
|
.join(dot);
|
|
646
|
-
rows.push(`${logChrome(theme, action.sequence, seqWidth,
|
|
649
|
+
rows.push(`${logChrome(theme, action.sequence, seqWidth, times[index]!, timeWidth)} ${whoStyled} ${icon} ${actionName}${detailText ? `${dot}${detailText}` : ""}`);
|
|
647
650
|
}
|
|
648
651
|
return rows;
|
|
649
652
|
}
|
package/team-briefing.ts
CHANGED
|
@@ -12,6 +12,7 @@ export function composeTeamBriefing(
|
|
|
12
12
|
`<your-specific-system-message>\n${teammatePrompt.trim()}\n</your-specific-system-message>`,
|
|
13
13
|
`You are ${teammateName}, a teammate on team ${teamName}.`,
|
|
14
14
|
"Work on your current team assignment. Treat inherited conversation as background for this assignment.",
|
|
15
|
+
"Do not use tools meant for interaction with a human.",
|
|
15
16
|
`Participants: main, ${participants.join(", ")}.`,
|
|
16
17
|
"Use team_send_message to talk to teammates, send_main_message to talk to the main agent, and team_status to set/read public statuses.",
|
|
17
18
|
"The main agent is the current coordinator. Use the team tools and available session history to share relevant context.",
|
package/team-selection.ts
CHANGED
|
@@ -10,6 +10,11 @@ export interface TeamSelection {
|
|
|
10
10
|
wholeTeam: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface DormantTeammateMatch {
|
|
14
|
+
teamId: string;
|
|
15
|
+
teammateId: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
export const targetDescription = "Team or teammate names or IDs. A team selects all its teammates. Names must be unique in your available teams. Use IDs to resolve duplicate names. Overlapping selections count once.";
|
|
14
19
|
export const interruptDescription = "True interrupts all selected recipients. A list uses the same names or IDs as targets and must select only message recipients. False or omitted interrupts none.";
|
|
15
20
|
|
|
@@ -28,12 +33,43 @@ export function resolveTeammates<Member extends { name: string; teammateId: stri
|
|
|
28
33
|
return [...new Set(identifiers.map((identifier) => resolveNamedId(candidates, identifier, "teammates").teammate))];
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const candidates = teams.flatMap((team) => [
|
|
36
|
+
function targetCandidates(teams: readonly SelectableTeam[]) {
|
|
37
|
+
return teams.flatMap((team) => [
|
|
34
38
|
{ name: team.teamName, id: team.teamId, team, teammate: undefined },
|
|
35
39
|
...team.teammates.map((teammate) => ({ name: teammate.name, id: teammate.teammateId, team, teammate })),
|
|
36
40
|
]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @example findUnknownTarget([{ teamName: "review", teamId: "team-1", teammates: [] }], ["review", "scout"]) // "scout" */
|
|
44
|
+
export function findUnknownTarget(teams: readonly SelectableTeam[], identifiers: readonly string[]): string | undefined {
|
|
45
|
+
const candidates = targetCandidates(teams);
|
|
46
|
+
return identifiers.find((identifier) => !candidates.some((candidate) => candidate.id === identifier.trim() || candidate.name === identifier.trim()));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Recovery guidance for a target that matches no available team or teammate, given the stored dormant teammates it matches.
|
|
51
|
+
* @example unknownTargetMessage("scout", [], [{ teamId: "team-1", teammateId: "session-1" }]).split("\n")[1] // "Team: team-1"
|
|
52
|
+
*/
|
|
53
|
+
export function unknownTargetMessage(identifier: string, teams: readonly SelectableTeam[], dormantMatches: readonly DormantTeammateMatch[]): string {
|
|
54
|
+
const name = JSON.stringify(identifier);
|
|
55
|
+
if (dormantMatches.length === 1) return [
|
|
56
|
+
`Teammate ${name} belongs to a dormant team.`,
|
|
57
|
+
`Team: ${dormantMatches[0].teamId}`,
|
|
58
|
+
`Teammate: ${dormantMatches[0].teammateId}`,
|
|
59
|
+
"Resume this teammate with team_resume, then retry team_send_message.",
|
|
60
|
+
].join("\n");
|
|
61
|
+
if (dormantMatches.length > 1) return [
|
|
62
|
+
`Teammate ${name} matches more than one dormant teammate. Choose one:`,
|
|
63
|
+
...dormantMatches.map((match) => `Team: ${match.teamId}, Teammate: ${match.teammateId}`),
|
|
64
|
+
"Resume the intended teammate with team_resume, then retry team_send_message.",
|
|
65
|
+
].join("\n");
|
|
66
|
+
const choices = targetCandidates(teams).map(({ name, id }) => ({ name, id }));
|
|
67
|
+
return `Unknown target ${name}. Available choices: ${JSON.stringify(choices)}. No active target matches. Use team_list to find active or dormant teams; resume the intended teammate before retrying.`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @example resolveTargets([{ teamName: "review", teamId: "team-1", teammates: [{ name: "scout", teammateId: "session-1" }] }], ["review", "session-1"])[0].teammates.length // 1 */
|
|
71
|
+
export function resolveTargets(teams: readonly SelectableTeam[], identifiers: readonly string[]): TeamSelection[] {
|
|
72
|
+
const candidates = targetCandidates(teams);
|
|
37
73
|
const selected = new Map<string, TeamSelection>();
|
|
38
74
|
for (const identifier of identifiers) {
|
|
39
75
|
const match = resolveNamedId(candidates, identifier, "targets");
|
package/teamlog.ts
CHANGED
|
@@ -106,6 +106,17 @@ export function relativeTime(epochMilliseconds: number, nowMilliseconds: number)
|
|
|
106
106
|
return `${formatElapsed(elapsed)} ago`;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Log row time: short elapsed time under an hour, absolute time of day from then on.
|
|
111
|
+
* logRowTime(now - 44 * 60_000, now) === "44m"; logRowTime(now - 20_000, now) === "now"; logRowTime(now - 3_600_000, now) === timeOfDay(now - 3_600_000)
|
|
112
|
+
*/
|
|
113
|
+
export function logRowTime(epochMilliseconds: number, nowMilliseconds: number): string {
|
|
114
|
+
const elapsed = Math.max(0, nowMilliseconds - epochMilliseconds);
|
|
115
|
+
if (elapsed >= HOUR_MILLISECONDS) return timeOfDay(epochMilliseconds);
|
|
116
|
+
if (elapsed < MINUTE_MILLISECONDS) return "now";
|
|
117
|
+
return formatElapsed(elapsed);
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
/**
|
|
110
121
|
* futureTime(now + 20 * 86_400_000, now) === "in 2w"
|
|
111
122
|
*/
|
package/teammate-facts.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
|
3
3
|
import { padVisible } from "./render-support/ansi.ts";
|
|
4
4
|
import { glyphs, glyphStyle } from "./render-support/glyphs.ts";
|
|
5
5
|
import { contextGauge, contextHeat, type HeatTheme } from "./render-support/heat.ts";
|
|
6
|
+
import { piModelName } from "./model-names.ts";
|
|
6
7
|
|
|
7
8
|
export interface FactTheme extends HeatTheme {
|
|
8
9
|
bold(text: string): string;
|
|
@@ -111,8 +112,8 @@ const LADDERS: Record<FactKey, Ladder> = {
|
|
|
111
112
|
},
|
|
112
113
|
status: { full: (row, paint) => (row.status ? paint.theme.fg(statusWordToken(row.status), row.status) : "") },
|
|
113
114
|
model: {
|
|
114
|
-
full: (row, paint) => (row.model ? paint.theme.fg("muted", row.model) : ""),
|
|
115
|
-
short: (row, paint) => (row.model ? paint.theme.fg("muted", modelTail(row.model)) : ""),
|
|
115
|
+
full: (row, paint) => (row.model ? paint.theme.fg("muted", piModelName(row.model) ?? row.model) : ""),
|
|
116
|
+
short: (row, paint) => (row.model ? paint.theme.fg("muted", piModelName(row.model) ?? modelTail(row.model)) : ""),
|
|
116
117
|
},
|
|
117
118
|
context: { full: context("context"), short: context("ctx"), bare: context("ctx", false), icon: context("") },
|
|
118
119
|
fork: flag("forkContext", { full: "⑂ fork", short: "⑂ fork", bare: "fork", icon: "⑂" }),
|