@giladbarnea/pi-simple-team 1.0.43 → 1.0.45

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 CHANGED
@@ -69,7 +69,6 @@ interface TeammateState {
69
69
  rejectReady?: (error: Error) => void;
70
70
  alive: boolean;
71
71
  deliveryQueue: Promise<void>;
72
- stderr: string;
73
72
  }
74
73
 
75
74
  interface TeamState {
@@ -225,13 +224,22 @@ function enqueueDelivery(team: TeamState, from: string, recipient: TeammateState
225
224
  });
226
225
  }
227
226
 
227
+ /** @example resolveTeamIdentifier([{ id: "main-review", name: "review" }], "review")?.id // "main-review" */
228
+ function resolveTeamIdentifier<IdentifiedTeam extends { id?: string; name: string }>(
229
+ candidates: Iterable<IdentifiedTeam>,
230
+ teamIdentifier: string,
231
+ ): IdentifiedTeam | undefined {
232
+ const matches = [...candidates].filter((team) => team.id === teamIdentifier || team.name === teamIdentifier);
233
+ if (matches.length > 1) throw new Error(`Ambiguous team name: ${teamIdentifier}. Pass the persistent team ID.`);
234
+ return matches[0];
235
+ }
236
+
228
237
  function resolveTeam(owner: symbol, teamIdentifier?: string): TeamState {
229
238
  const ownedTeams = [...teams.values()].filter((team) => team.owner === owner);
230
239
  if (teamIdentifier) {
231
- const matches = ownedTeams.filter((team) => team.id === teamIdentifier || team.name === teamIdentifier);
232
- if (matches.length === 0) throw new Error(`Unknown team: ${teamIdentifier}`);
233
- if (matches.length > 1) throw new Error(`Ambiguous team name: ${teamIdentifier}. Pass the persistent team ID.`);
234
- return matches[0]!;
240
+ const team = resolveTeamIdentifier(ownedTeams, teamIdentifier);
241
+ if (!team) throw new Error(`Unknown team: ${teamIdentifier}`);
242
+ return team;
235
243
  }
236
244
 
237
245
  if (ownedTeams.length === 1) return ownedTeams[0];
@@ -344,7 +352,6 @@ function createTeammateState(team: TeamState, teammateSpec: TeammateSpec): Teamm
344
352
  rejectReady,
345
353
  alive: true,
346
354
  deliveryQueue: Promise.resolve(),
347
- stderr: "",
348
355
  };
349
356
  }
350
357
 
@@ -407,7 +414,6 @@ function attachRpcTeammate(team: TeamState, teammate: TeammateState, participant
407
414
 
408
415
  proc.stderr?.on("data", (chunk: Buffer | string) => {
409
416
  const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
410
- teammate.stderr += text;
411
417
  appendTeamLog(team, { team: team.name, teammate: teammate.name, direction: "runtime", kind: "stderr", summary: preview(text) });
412
418
  });
413
419
  proc.on("exit", (code, signal) => {
@@ -1073,7 +1079,7 @@ export default function (pi: ExtensionAPI) {
1073
1079
  renderCall: (args, theme, context) => renderTeamToolCall("team_resume", args, theme, context, sessionTeammateRoster),
1074
1080
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_resume", result, options, theme, context, undefined, sessionTeammateRoster),
1075
1081
  parameters: Type.Object({
1076
- team: Type.String({ description: "Persistent team ID" }),
1082
+ team: Type.String({ description: "Team name or persistent ID" }),
1077
1083
  teammates: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "Stopped teammate names. Omit to resume all stopped teammates." })),
1078
1084
  showOnHerdrPanes: Type.Optional(Type.Boolean({ default: false, description: "Resume selected teammates in visible Herdr panes. Defaults to RPC." })),
1079
1085
  }),
@@ -1082,9 +1088,10 @@ export default function (pi: ExtensionAPI) {
1082
1088
  if (!rawProjectDirectory) throw new Error("team_resume requires a project directory");
1083
1089
  const managerSessionId = childRuntimeConfig ? context.sessionManager?.getSessionId?.() : undefined;
1084
1090
  if (childRuntimeConfig && !managerSessionId) throw new Error("team_resume requires a persistent overseeing teammate session");
1085
- const manifest = listTeamManifests(rawProjectDirectory).find(
1086
- (candidate) => candidate.id === params.team && (!managerSessionId || candidate.originMainSessionId === managerSessionId),
1091
+ const availableManifests = listTeamManifests(rawProjectDirectory).filter(
1092
+ (candidate) => !managerSessionId || candidate.originMainSessionId === managerSessionId,
1087
1093
  );
1094
+ const manifest = resolveTeamIdentifier(availableManifests, params.team);
1088
1095
  if (!manifest) throw new Error(`Unknown current-project team: ${params.team}`);
1089
1096
  const requestedNames = params.teammates?.map(compactName) ?? manifest.members.map((member) => member.name);
1090
1097
  const duplicateNames = requestedNames.filter((name, index) => requestedNames.indexOf(name) !== index);
@@ -1183,11 +1190,14 @@ export default function (pi: ExtensionAPI) {
1183
1190
  renderCall: (args, theme, context) => renderTeamToolCall("team_add", args, theme, context, sessionTeammateRoster),
1184
1191
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_add", result, options, theme, context, undefined, sessionTeammateRoster),
1185
1192
  parameters: Type.Object({
1186
- team: Type.String({ description: "Persistent team ID" }),
1193
+ team: Type.String({ description: "Team name or persistent ID" }),
1187
1194
  teammates: Type.Array(teammateSchema(""), { minItems: 1, description: "New teammates to add" }),
1188
1195
  }),
1189
1196
  async execute(_toolCallId, params, _signal, _onUpdate, context) {
1190
- const team = [...teams.values()].find((candidate) => candidate.id === params.team && candidate.owner === owner);
1197
+ const team = resolveTeamIdentifier(
1198
+ [...teams.values()].filter((candidate) => candidate.owner === owner),
1199
+ params.team,
1200
+ );
1191
1201
  if (!team || !team.manifest || !team.lease || team.manifest.state !== "active") {
1192
1202
  throw new Error(`team_add requires a running team owned by this main session: ${params.team}`);
1193
1203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -155,10 +155,6 @@ export function treeStyle(cwd?: string): TreeStyle {
155
155
  return settingEnum("treeStyle", ["unicode", "ascii"] as const, "unicode", cwd);
156
156
  }
157
157
 
158
- export function pendingStatusAnimation(cwd?: string): boolean {
159
- return settingBoolean("pendingStatusAnimation", false, cwd);
160
- }
161
-
162
158
  export function diffBackgroundEnabled(cwd?: string): boolean {
163
159
  return settingBoolean("diffBackgrounds", true, cwd);
164
160
  }
@@ -5,7 +5,7 @@ import { pathToFileURL } from "node:url";
5
5
 
6
6
  import { stableRenderWidth, stripAnsi } from "./ansi.js";
7
7
  import { glyphs, truncateText } from "./glyphs.js";
8
- import { pendingStatusAnimation, settingNumber, stackToolCalls } from "./settings.js";
8
+ import { settingNumber, stackToolCalls } from "./settings.js";
9
9
  import { stackPrefix, toolLabel, treeConnector, type TreeBranch } from "./theme.js";
10
10
 
11
11
  export class TruncatedLines {
@@ -122,67 +122,9 @@ export function readResultSummary(result: any, args: any, theme: any): string {
122
122
  return summary;
123
123
  }
124
124
 
125
- interface BlinkEntry {
126
- invalidate: () => void;
127
- }
128
-
129
- const blinkEntries = new Map<unknown, BlinkEntry>();
130
- let blinkTimer: ReturnType<typeof setInterval> | undefined;
131
-
132
- function blinkKey(context: any): unknown {
133
- return context?.toolCallId ?? context?.id ?? context;
134
- }
135
-
136
- function startBlinkTimer(): void {
137
- if (blinkTimer) return;
138
- blinkTimer = setInterval(() => {
139
- for (const entry of blinkEntries.values()) {
140
- try {
141
- entry.invalidate();
142
- } catch {
143
- // Rendering invalidation is best-effort only.
144
- }
145
- }
146
- if (blinkEntries.size === 0 && blinkTimer) {
147
- clearInterval(blinkTimer);
148
- blinkTimer = undefined;
149
- }
150
- }, 450);
151
- blinkTimer.unref?.();
152
- }
153
-
154
- function trackBlink(context: any): void {
155
- const key = blinkKey(context);
156
- if (!key || typeof context?.invalidate !== "function") return;
157
- blinkEntries.set(key, { invalidate: () => context.invalidate() });
158
- startBlinkTimer();
159
- }
160
-
161
- export function clearBlink(context: any): void {
162
- const key = blinkKey(context);
163
- if (key) blinkEntries.delete(key);
164
- if (blinkEntries.size === 0 && blinkTimer) {
165
- clearInterval(blinkTimer);
166
- blinkTimer = undefined;
167
- }
168
- }
169
-
170
- export function blinkingPrefix(theme: any, context: any, cwd?: string): string {
171
- trackBlink(context);
172
- const on = Math.floor(Date.now() / 450) % 2 === 0;
173
- const g = glyphs(context?.cwd ?? cwd);
174
- return theme.fg(on ? "success" : "muted", on ? g.bullet : g.emptyBullet);
175
- }
176
-
177
- export function pendingStatusPrefix(theme: any, context: any, cwd?: string): string {
178
- if (pendingStatusAnimation(context?.cwd ?? cwd)) return blinkingPrefix(theme, context, cwd);
179
- clearBlink(context);
180
- return theme.fg("warning", glyphs(context?.cwd ?? cwd).bullet);
181
- }
182
-
183
125
  export function renderPendingCall(call: string, theme: any, context: any, cwd?: string): TruncatedLines | ReturnType<typeof makeEmpty> {
184
126
  if (!context?.executionStarted || !context?.isPartial || stackToolCalls(context?.cwd ?? cwd)) return makeEmpty();
185
- return makeTruncatedLines(`${pendingStatusPrefix(theme, context, cwd)}${call}`);
127
+ return makeTruncatedLines(`${theme.fg("warning", glyphs(context?.cwd ?? cwd).bullet)}${call}`);
186
128
  }
187
129
 
188
130
  export function renderPendingDetail(text: string, theme: any, cwd?: string): TruncatedLines {