@giladbarnea/pi-simple-team 2.0.1 → 2.0.2

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 CHANGED
@@ -230,6 +230,8 @@ Spawn, resume, and add return the complete roster. Results distinguish a live ru
230
230
 
231
231
  Set `showOnHerdrPane: true` on individual teammates to open their panes. An explicit `showOnHerdrPanes` value on spawn overrides all individual settings.
232
232
 
233
+ `extensionPaths` lists trusted, existing absolute extension paths for one teammate. RPC and Herdr launches load them alongside the team runtime, and resume keeps them. Discovered extensions remain disabled. These modules run with the same permissions as Pi.
234
+
233
235
  Message tools return `published: true` when the extension accepts a message for delivery. If delivery later fails, the sender receives the error automatically.
234
236
 
235
237
 
package/child-tools.ts CHANGED
@@ -258,7 +258,7 @@ function startChildRuntime(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
258
258
  }
259
259
 
260
260
  export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
261
- pi.registerMessageRenderer(teamMessageType, (message, _options, theme) => renderTeamMessage(message, theme, getMarkdownTheme(), config.participants));
261
+ pi.registerMessageRenderer(teamMessageType, (message, options, theme) => renderTeamMessage(message, options, theme, getMarkdownTheme(), config.participants));
262
262
  const startupRosterInstruction = `Participants: main, ${config.participants.join(", ")}.`;
263
263
  pi.on("before_agent_start", async (event, context) => {
264
264
  const teamContext = await callParent(config, "team_context", {}, context.signal);
package/index.ts CHANGED
@@ -48,6 +48,7 @@ interface TeammateState {
48
48
  thinking: ThinkingLevel;
49
49
  inheritMainContext: boolean;
50
50
  canManageOwnTeams: boolean;
51
+ extensionPaths: string[];
51
52
  transport: TeammateTransport;
52
53
  sessionId?: string;
53
54
  sessionFile?: string;
@@ -138,14 +139,16 @@ function teammateRecord(teammate: TeammateState): TeammateRecord {
138
139
  canManageOwnTeams: teammate.canManageOwnTeams,
139
140
  showOnHerdrPane: teammate.transport === "herdr",
140
141
  sessionFile: teammate.sessionFile!,
142
+ ...(teammate.extensionPaths.length > 0 ? { extensionPaths: teammate.extensionPaths } : {}),
141
143
  };
142
144
  }
143
145
 
144
146
  /** @example lifecycleInstruction(true).includes("idle") // true */
145
147
  function lifecycleInstruction(startIdle: boolean): string {
148
+ const reminderOffer = "Ask the user whether to schedule recurring team progress checks, and at which interval. Suggest an interval proportional to the task: every 30-60 minutes for a multi-hour task, or every 15 minutes for a task of 1 hour or less. If they agree, use `schedule_reminder`. After each check, schedule the next while the team needs oversight.";
146
149
  const nextAction = startIdle
147
- ? "No teammates have active work. Use team_send_message to start idle teammates, or team_resume for stopped teammates."
148
- : "Teammates will message you with milestones or requests for help. Avoid repeated status polling and shell sleeps. Set your status to explain what you expect from them. If you have no independent work, tell the user and end your turn. Ask the user whether to schedule progress checks every 15 minutes. If they agree, use schedule_reminder. After each check, schedule the next while the team needs oversight.";
150
+ ? `All teammates are currently idle. Use \`team_send_message\` to start idle teammates, or \`team_resume\` for stopped teammates. After the team starts work: ${reminderOffer}`
151
+ : `Teammates will message you with milestones or requests for help. Avoid repeated status polling and shell sleeps. Set your status to explain what you expect from them. If you have no independent work, tell the user and end your turn. ${reminderOffer}`;
149
152
  return `${bundledSkillsInstruction}\n\n${nextAction}`;
150
153
  }
151
154
 
@@ -412,6 +415,10 @@ function logStatusDeclaration(team: TeamState, participant: string, word?: strin
412
415
  function createTeammateState(teammateSpec: Teammate): TeammateState {
413
416
  const teammateName = compactName(teammateSpec.name);
414
417
  const thinking = teammateSpec.thinking ?? defaultThinkingLevel;
418
+ const extensionPaths = teammateSpec.extensionPaths ?? [];
419
+ for (const extensionPath of extensionPaths) {
420
+ if (!path.isAbsolute(extensionPath) || !fs.existsSync(extensionPath)) throw new Error(`Teammate extension must be an existing absolute path: ${extensionPath}`);
421
+ }
415
422
  let resolveReady: (() => void) | undefined;
416
423
  let rejectReady: ((error: Error) => void) | undefined;
417
424
  const ready = new Promise<void>((resolve, reject) => {
@@ -426,6 +433,7 @@ function createTeammateState(teammateSpec: Teammate): TeammateState {
426
433
  thinking,
427
434
  inheritMainContext: Boolean(teammateSpec.inheritMainContext),
428
435
  canManageOwnTeams: Boolean(teammateSpec.canManageOwnTeams),
436
+ extensionPaths,
429
437
  transport: teammateSpec.showOnHerdrPane ? "herdr" : "rpc",
430
438
  sessionMaterialized: false,
431
439
  ready,
@@ -482,6 +490,7 @@ function attachRpcTeammate(team: TeamState, teammate: TeammateState, participant
482
490
  "--no-extensions",
483
491
  "-e",
484
492
  teamLiteExtensionPath,
493
+ ...teammate.extensionPaths.flatMap(extensionPath => ["-e", extensionPath]),
485
494
  "--no-prompt-templates",
486
495
  "--no-themes",
487
496
  ...modelArgs,
@@ -549,6 +558,7 @@ async function attachHerdrTeammate(
549
558
  "--no-extensions",
550
559
  "-e",
551
560
  teamLiteExtensionPath,
561
+ ...teammate.extensionPaths.flatMap(extensionPath => ["-e", extensionPath]),
552
562
  ...modelArgs,
553
563
  "--system-prompt",
554
564
  systemPrompt,
@@ -880,6 +890,7 @@ function teammateSchema(modelGuidance: string) {
880
890
  inheritMainContext: Type.Optional(Type.Boolean({ description: "Start with a clone of your context window rather than start fresh. Defaults to false.", default: false })),
881
891
  canManageOwnTeams: Type.Optional(Type.Boolean({ description: "Allow this teammate to create and manage teams of its own. Defaults to false.", default: false })),
882
892
  showOnHerdrPane: Type.Optional(Type.Boolean({ description: "Open a visible Herdr pane for this teammate. Defaults to false.", default: false })),
893
+ 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 stay disabled." })),
883
894
  }, { additionalProperties: false });
884
895
  }
885
896
 
@@ -943,7 +954,7 @@ export default function (pi: ExtensionAPI) {
943
954
  const owner = Symbol("pi-simple-team-owner");
944
955
  const reminderTimers = new Set<ReturnType<typeof setTimeout>>();
945
956
  const sessionTeammateRoster = childRuntimeConfig?.participants ?? [];
946
- pi.registerMessageRenderer(teamMessageType, (message, _options, theme) => renderTeamMessage(message, theme, getMarkdownTheme(), sessionTeammateRoster));
957
+ pi.registerMessageRenderer(teamMessageType, (message, options, theme) => renderTeamMessage(message, options, theme, getMarkdownTheme(), sessionTeammateRoster));
947
958
 
948
959
  pi.registerCommand("team", {
949
960
  description: "Open a read-only team overview",
@@ -968,8 +979,7 @@ export default function (pi: ExtensionAPI) {
968
979
  defineTool({
969
980
  name: "team_spawn",
970
981
  label: "Team Spawn",
971
- description: "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.",
972
- promptSnippet: "Spawn a versatile team of agents.",
982
+ 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.",
973
983
  renderShell: "self",
974
984
  renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context, sessionTeammateRoster),
975
985
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_spawn", result, options, theme, context, undefined, sessionTeammateRoster),
@@ -1263,7 +1273,6 @@ export default function (pi: ExtensionAPI) {
1263
1273
  name: "team_add_teammates",
1264
1274
  label: "Team Add",
1265
1275
  description: "Add teammates to an active team you own. Existing teammates continue their work.",
1266
- promptSnippet: "Add new teammates to a running team",
1267
1276
  renderShell: "self",
1268
1277
  renderCall: (args, theme, context) => renderTeamToolCall("team_add_teammates", args, theme, context, sessionTeammateRoster),
1269
1278
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_add_teammates", result, options, theme, context, undefined, sessionTeammateRoster),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",
package/render.ts CHANGED
@@ -308,14 +308,19 @@ export function teamListLines(theme: ThemeLike, teamViews: TeamListTeamView[], r
308
308
  return [header, ...rows];
309
309
  }
310
310
 
311
- function quotedBody(theme: ThemeLike, message: string, options: { lineLimit: number; barToken: string }): TeamLine[] {
311
+ /** The dim "N more lines · ctrl+o to expand" footer under a collapsed body. */
312
+ function expandHint(theme: ThemeLike, hidden: number): string {
312
313
  const g = glyphs();
313
- const bar = ` ${theme.fg(options.barToken, g.codeBar)} `;
314
+ return theme.fg("dim", `${g.ellipsis} ${hidden} more line${hidden === 1 ? "" : "s"}${g.dot}ctrl+o to expand`);
315
+ }
316
+
317
+ function quotedBody(theme: ThemeLike, message: string, options: { lineLimit: number; barToken: string }): TeamLine[] {
318
+ const bar = ` ${theme.fg(options.barToken, glyphs().codeBar)} `;
314
319
  const lines = message.replace(/\r\n/g, "\n").split("\n");
315
320
  const shown = lines.slice(0, options.lineLimit);
316
321
  const body: TeamLine[] = shown.map((line) => ({ prefix: bar, text: line }));
317
322
  const hidden = lines.length - shown.length;
318
- if (hidden > 0) body.push({ prefix: bar, text: theme.fg("dim", `${g.ellipsis} ${hidden} more line${hidden === 1 ? "" : "s"}${g.dot}ctrl+o to expand`) });
323
+ if (hidden > 0) body.push({ prefix: bar, text: expandHint(theme, hidden) });
319
324
  return body;
320
325
  }
321
326
 
@@ -339,8 +344,12 @@ function hasInterruption(interrupt: unknown): boolean {
339
344
  return interrupt === true || (Array.isArray(interrupt) && interrupt.length > 0);
340
345
  }
341
346
 
347
+ function teamSendHeader(theme: ThemeLike, targets: string[], message: string, interrupt: boolean, roster: string[]): string {
348
+ return headerLine(theme, "Team Send", sendTarget(theme, targets, roster), sendStats(theme, message, interrupt));
349
+ }
350
+
342
351
  export function teamSendLines(theme: ThemeLike, options: { targets: string[]; message: string; interrupt: boolean; expanded: boolean }, roster: string[] = []): TeamLine[] {
343
- const header = headerLine(theme, "Team Send", sendTarget(theme, options.targets, roster), sendStats(theme, options.message, options.interrupt));
352
+ const header = teamSendHeader(theme, options.targets, options.message, options.interrupt, roster);
344
353
  const lineLimit = options.expanded ? Number.POSITIVE_INFINITY : SEND_PREVIEW_LINES;
345
354
  return [header, ...quotedBody(theme, options.message, { lineLimit, barToken: "muted" })];
346
355
  }
@@ -662,8 +671,8 @@ export function teamLogLines(theme: ThemeLike, view: TeamLogRenderView): string[
662
671
  return [header, ...rows, ...(footer ? [footer] : [])];
663
672
  }
664
673
 
665
- export function teamMessageLines(theme: ThemeLike, details: TeamMessageDetails, roster: string[] = []): TeamLine[] {
666
- return [teamMessageHeader(theme, details, roster), ...quotedBody(theme, details.message, { lineLimit: Number.POSITIVE_INFINITY, barToken: "accent" })];
674
+ export function teamMessageLines(theme: ThemeLike, details: TeamMessageDetails, roster: string[] = [], lineLimit = Number.POSITIVE_INFINITY): TeamLine[] {
675
+ return [teamMessageHeader(theme, details, roster), ...quotedBody(theme, details.message, { lineLimit, barToken: "accent" })];
667
676
  }
668
677
 
669
678
  function teamMessageHeader(theme: ThemeLike, details: TeamMessageDetails, roster: string[]): string {
@@ -676,23 +685,23 @@ function teamMessageHeader(theme: ThemeLike, details: TeamMessageDetails, roster
676
685
  ].join("");
677
686
  }
678
687
 
679
- class TeamSendView {
688
+ /** A header over a quote-barred Markdown body, previewing SEND_PREVIEW_LINES body lines unless expanded. */
689
+ class QuotedMarkdownView {
680
690
  private md: Markdown;
681
- private headerStr: string;
682
- private barStr: string;
683
691
  private barWidth: number;
684
- private expanded: boolean;
685
- private theme: ThemeLike;
686
692
  private cachedWidth?: number;
687
693
  private cachedLines?: string[];
688
694
 
689
- constructor(headerStr: string, messageText: string, barStr: string, mdTheme: MarkdownTheme, expanded: boolean, theme: ThemeLike) {
690
- this.headerStr = headerStr;
691
- this.barStr = barStr;
695
+ constructor(
696
+ private readonly headerStr: string,
697
+ messageText: string,
698
+ private readonly barStr: string,
699
+ mdTheme: MarkdownTheme,
700
+ private readonly expanded: boolean,
701
+ private readonly theme: ThemeLike,
702
+ ) {
692
703
  this.barWidth = visibleLength(barStr);
693
704
  this.md = new Markdown(messageText, 0, 0, mdTheme);
694
- this.expanded = expanded;
695
- this.theme = theme;
696
705
  }
697
706
 
698
707
  invalidate(): void {
@@ -705,56 +714,16 @@ class TeamSendView {
705
714
  if (this.cachedLines && this.cachedWidth === width) return this.cachedLines;
706
715
  const header = clipToWidth(this.headerStr, width);
707
716
  const bodyWidth = Math.max(1, width - this.barWidth);
708
- const bodyLines = this.md.render(bodyWidth);
709
- const barred = bodyLines.map((line) => clipToWidth(`${this.barStr}${line}`, width));
710
- if (this.expanded) {
711
- this.cachedLines = [header, ...barred];
712
- this.cachedWidth = width;
713
- return this.cachedLines;
714
- }
715
- const shown = barred.slice(0, SEND_PREVIEW_LINES);
716
- const hidden = barred.length - SEND_PREVIEW_LINES;
717
- if (hidden > 0) {
718
- const g = glyphs();
719
- shown.push(clipToWidth(`${this.barStr}${this.theme.fg("dim", `${g.ellipsis} ${hidden} more line${hidden === 1 ? "" : "s"}${g.dot}ctrl+o to expand`)}`, width));
720
- }
717
+ const barred = this.md.render(bodyWidth).map((line) => clipToWidth(`${this.barStr}${line}`, width));
718
+ const shown = this.expanded ? barred : barred.slice(0, SEND_PREVIEW_LINES);
719
+ const hidden = barred.length - shown.length;
720
+ if (hidden > 0) shown.push(clipToWidth(`${this.barStr}${expandHint(this.theme, hidden)}`, width));
721
721
  this.cachedLines = [header, ...shown];
722
722
  this.cachedWidth = width;
723
723
  return this.cachedLines;
724
724
  }
725
725
  }
726
726
 
727
- class TeamMessageView {
728
- private md: Markdown;
729
- private headerLine: string;
730
- private barStr: string;
731
- private barWidth: number;
732
- private cachedWidth?: number;
733
- private cachedLines?: string[];
734
-
735
- constructor(headerLine: string, messageText: string, barStr: string, mdTheme: MarkdownTheme) {
736
- this.headerLine = headerLine;
737
- this.barStr = barStr;
738
- this.barWidth = visibleLength(barStr);
739
- this.md = new Markdown(messageText, 0, 0, mdTheme);
740
- }
741
-
742
- invalidate(): void {
743
- this.md.invalidate();
744
- this.cachedWidth = undefined;
745
- this.cachedLines = undefined;
746
- }
747
-
748
- render(width: number): string[] {
749
- if (this.cachedLines && this.cachedWidth === width) return this.cachedLines;
750
- const bodyWidth = Math.max(1, width - this.barWidth);
751
- const bodyLines = this.md.render(bodyWidth);
752
- this.cachedLines = [clipToWidth(this.headerLine, width), ...bodyLines.map((line) => clipToWidth(`${this.barStr}${line}`, width))];
753
- this.cachedWidth = width;
754
- return this.cachedLines;
755
- }
756
- }
757
-
758
727
  function accentTeam(theme: ThemeLike, team: unknown): string {
759
728
  return typeof team === "string" && team ? theme.fg("accent", team) : "";
760
729
  }
@@ -859,7 +828,7 @@ export function renderTeamToolResult(
859
828
  context: ToolRenderContextLike,
860
829
  markdownTheme?: MarkdownTheme,
861
830
  roster: string[] = [],
862
- ): TeamSendView | TeamLines {
831
+ ): QuotedMarkdownView | TeamLines {
863
832
  const args = (context?.args ?? {}) as Record<string, unknown>;
864
833
  if (context?.isError || result?.isError) {
865
834
  return new TeamLines(errorLines(theme, callBodyFor(tool, theme, args, roster), textContent(result)), options.expanded ? "wrap" : "clip");
@@ -867,9 +836,9 @@ export function renderTeamToolResult(
867
836
  const details = (result?.details ?? {}) as Record<string, unknown>;
868
837
  if (markdownTheme && tool === "team_send_message") {
869
838
  const message = String(args.message ?? "");
870
- const header = headerLine(theme, "Team Send", sendTarget(theme, (args.targets ?? []) as string[], roster), sendStats(theme, message, hasInterruption(args.interrupt)));
839
+ const header = teamSendHeader(theme, (args.targets ?? []) as string[], message, hasInterruption(args.interrupt), roster);
871
840
  const bar = ` ${theme.fg("muted", glyphs().codeBar)} `;
872
- return new TeamSendView(header, message, bar, markdownTheme, options.expanded, theme);
841
+ return new QuotedMarkdownView(header, message, bar, markdownTheme, options.expanded, theme);
873
842
  }
874
843
  return new TeamLines(resultLinesFor(tool, theme, args, details, options.expanded, roster), options.expanded ? "wrap" : "clip");
875
844
  }
@@ -898,13 +867,13 @@ export function renderReminderToolResult(
898
867
  );
899
868
  }
900
869
 
901
- export function renderTeamMessage(message: { details?: unknown }, theme: ThemeLike, markdownTheme?: MarkdownTheme, roster: string[] = []): TeamMessageView | TeamLines | undefined {
870
+ export function renderTeamMessage(message: { details?: unknown }, options: { expanded: boolean }, theme: ThemeLike, markdownTheme?: MarkdownTheme, roster: string[] = []): QuotedMarkdownView | TeamLines | undefined {
902
871
  const details = message.details as TeamMessageDetails | undefined;
903
872
  if (!details?.from || !details?.team || typeof details.message !== "string") return undefined;
904
873
  if (markdownTheme) {
905
- const g = glyphs();
906
- const bar = ` ${theme.fg("accent", g.codeBar)} `;
907
- return new TeamMessageView(teamMessageHeader(theme, details, roster), details.message, bar, markdownTheme);
874
+ const bar = ` ${theme.fg("accent", glyphs().codeBar)} `;
875
+ return new QuotedMarkdownView(teamMessageHeader(theme, details, roster), details.message, bar, markdownTheme, options.expanded, theme);
908
876
  }
909
- return new TeamLines(teamMessageLines(theme, details, roster), "wrap");
877
+ const lineLimit = options.expanded ? Number.POSITIVE_INFINITY : SEND_PREVIEW_LINES;
878
+ return new TeamLines(teamMessageLines(theme, details, roster, lineLimit), options.expanded ? "wrap" : "clip");
910
879
  }
package/team-registry.ts CHANGED
@@ -76,7 +76,8 @@ function isManifestMember(value: unknown): value is TeamManifestMember {
76
76
  typeof member.active === "boolean" &&
77
77
  typeof member.teammateId === "string" &&
78
78
  typeof member.sessionFile === "string" &&
79
- typeof member.sessionMaterialized === "boolean"
79
+ typeof member.sessionMaterialized === "boolean" &&
80
+ (member.extensionPaths === undefined || (Array.isArray(member.extensionPaths) && member.extensionPaths.every((value) => typeof value === "string" && path.isAbsolute(value))))
80
81
  );
81
82
  }
82
83
 
package/teammate.ts CHANGED
@@ -8,9 +8,11 @@ export interface Teammate {
8
8
  inheritMainContext?: boolean;
9
9
  canManageOwnTeams?: boolean;
10
10
  showOnHerdrPane?: boolean;
11
+ extensionPaths?: string[];
11
12
  }
12
13
 
13
- export type TeammateRecord = Required<Teammate> & {
14
+ export type TeammateRecord = Required<Omit<Teammate, "extensionPaths">> & {
15
+ extensionPaths?: string[];
14
16
  teammateId: string;
15
17
  sessionFile: string;
16
18
  live: boolean;