@giladbarnea/pi-simple-team 2.0.14 → 2.0.15

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.
Files changed (2) hide show
  1. package/index.ts +17 -9
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -5,7 +5,7 @@ import * as fs from "node:fs";
5
5
  import http from "node:http";
6
6
  import * as path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
- import { defineTool, type ContextUsage, type ExtensionAPI, getMarkdownTheme, getPackageDir } from "@earendil-works/pi-coding-agent";
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
10
  import { formatScopedModelGuidance, validateTeammateModels, type ModelReference } from "./model-preflight.ts";
11
11
  import { composeTeamBriefing } from "./team-briefing.ts";
@@ -1003,6 +1003,18 @@ export default function (pi: ExtensionAPI) {
1003
1003
  const owner = Symbol("pi-simple-team-owner");
1004
1004
  const reminderTimers = new Set<ReturnType<typeof setTimeout>>();
1005
1005
  const sessionTeammateRoster = childRuntimeConfig?.participants ?? [];
1006
+
1007
+ /** Current-project manifests that team_resume can select: all for main, only its own for a managing teammate. */
1008
+ function resumableTeamManifests(context: ExtensionContext, toolName: string): TeamManifest[] {
1009
+ const projectDirectory = context.sessionManager?.getCwd?.() ?? context.cwd;
1010
+ if (!projectDirectory) throw new Error(`${toolName} requires a project directory`);
1011
+ const managerSessionId = childRuntimeConfig ? context.sessionManager?.getSessionId?.() : undefined;
1012
+ if (childRuntimeConfig && !managerSessionId) throw new Error(`${toolName} requires a persistent managing teammate Pi session`);
1013
+ return listTeamManifests(projectDirectory).manifests.filter(
1014
+ (candidate) => !managerSessionId || candidate.originMainSessionId === managerSessionId,
1015
+ );
1016
+ }
1017
+
1006
1018
  pi.registerMessageRenderer(teamMessageType, (message, options, theme) => renderTeamMessage(message, options, theme, getMarkdownTheme(), sessionTeammateRoster));
1007
1019
 
1008
1020
  pi.registerCommand("team", {
@@ -1229,14 +1241,7 @@ export default function (pi: ExtensionAPI) {
1229
1241
  }, { additionalProperties: false }),
1230
1242
  async execute(_toolCallId, params, signal, _onUpdate, context) {
1231
1243
  signal?.throwIfAborted();
1232
- const rawProjectDirectory = context.sessionManager?.getCwd?.() ?? context.cwd;
1233
- if (!rawProjectDirectory) throw new Error("team_resume requires a project directory");
1234
- const managerSessionId = childRuntimeConfig ? context.sessionManager?.getSessionId?.() : undefined;
1235
- if (childRuntimeConfig && !managerSessionId) throw new Error("team_resume requires a persistent managing teammate Pi session");
1236
- const availableManifests = listTeamManifests(rawProjectDirectory).manifests.filter(
1237
- (candidate) => !managerSessionId || candidate.originMainSessionId === managerSessionId,
1238
- );
1239
- const manifest = resolveTeamIdentifier(availableManifests, params.team);
1244
+ const manifest = resolveTeamIdentifier(resumableTeamManifests(context, "team_resume"), params.team);
1240
1245
  if (!manifest) throw new Error(`Unknown current-project team: ${JSON.stringify(params.team)}. Call team_list and pass a listed teamId or unique teamName in the team parameter.`);
1241
1246
  const members = manifest.members;
1242
1247
  const requestedNames = resolveTeammates(members, params.teammates ?? members.map((member) => member.teammateId)).map((member) => member.name);
@@ -1339,6 +1344,9 @@ export default function (pi: ExtensionAPI) {
1339
1344
  }, { additionalProperties: false }),
1340
1345
  async execute(_toolCallId, params, signal, _onUpdate, context) {
1341
1346
  signal?.throwIfAborted();
1347
+ const ownsSelectedTeam = !params.team || resolveTeamIdentifier([...teams.values()].filter((team) => team.owner === owner), params.team);
1348
+ const stoppedTeam = ownsSelectedTeam ? undefined : resolveTeamIdentifier(resumableTeamManifests(context, "team_add_teammates").filter((manifest) => manifest.state === "dormant"), params.team!);
1349
+ if (stoppedTeam) throw new Error(`Team "${stoppedTeam.name}" (team ID: ${stoppedTeam.id}) is stopped. Resume it with team_resume before adding teammates.`);
1342
1350
  const team = resolveTeam(owner, params.team);
1343
1351
  if (!team || !team.manifest || !team.lease || team.manifest.state !== "active") {
1344
1352
  throw new Error(`team_add_teammates requires a running team owned by this main session: ${params.team}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",