@giladbarnea/pi-simple-team 2.0.28 → 2.0.30

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 +9 -5
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -129,6 +129,7 @@ const teamLiteExtensionPath = fileURLToPath(import.meta.url);
129
129
  const thinkingLevels = ["low", "medium", "high", "xhigh", "max"] as const;
130
130
  const defaultThinkingLevel = "xhigh" satisfies ThinkingLevel;
131
131
  const deliveryTimeoutMilliseconds = 30_000;
132
+ const onlySenderSelectedError = "These targets select no teammate other than yourself. Use send_main_message to message main.";
132
133
  const defaultRpcShutdownGraceMilliseconds = 1_000;
133
134
  /** Time for main's own shutdown to mark its teams before an exit notice is sent, for signals that reach main and its teammates together. */
134
135
  const exitNoticeGraceMilliseconds = 2_000;
@@ -1338,9 +1339,9 @@ async function handleCallbackRequest(request: http.IncomingMessage, response: ht
1338
1339
  const selections = resolveTargets(candidates, args.targets as string[]);
1339
1340
  const message = String(args.message ?? "");
1340
1341
  const interrupted = interruptedTeammateIds(candidates, selections, args.interrupt as boolean | string[] | undefined);
1341
- for (const selection of selections) {
1342
- for (const recipient of selection.teammates) enqueueDelivery(team, from, team.members.get(recipient.name)!, message, interrupted.has(recipient.teammateId));
1343
- }
1342
+ const recipients = selections.flatMap((selection) => selection.teammates).filter((recipient) => recipient.name !== from);
1343
+ if (recipients.length === 0) throw new Error(onlySenderSelectedError);
1344
+ for (const recipient of recipients) enqueueDelivery(team, from, team.members.get(recipient.name)!, message, interrupted.has(recipient.teammateId));
1344
1345
  writeJson(response, 200, { published: true, teams: [{ ...teamIdentity(team), status: formatStatus(team) }], instruction: "Do not wait for replies. Teammates will message you back." });
1345
1346
  return;
1346
1347
  }
@@ -2167,12 +2168,15 @@ export default function (pi: ExtensionAPI) {
2167
2168
  const candidates = [...ownedTargetTeams(owner), ...(parent ? [parent] : [])];
2168
2169
  const unknownTarget = findUnknownTarget(candidates, params.targets);
2169
2170
  if (unknownTarget !== undefined) throw new Error(unknownTargetMessage(unknownTarget, candidates, dormantTeammateMatches(context, unknownTarget)));
2170
- const selections = resolveTargets(candidates, params.targets);
2171
- const interrupted = interruptedTeammateIds(candidates, selections, params.interrupt);
2171
+ const selected = resolveTargets(candidates, params.targets);
2172
+ const interrupted = interruptedTeammateIds(candidates, selected, params.interrupt);
2173
+ const selections = selected.map((selection) => selection.team === parent ? { ...selection, teammates: selection.teammates.filter((teammate) => teammate.name !== childRuntimeConfig!.teammateName) } : selection);
2174
+ if (selected.some((selection) => selection.team === parent) && selections.every((selection) => selection.teammates.length === 0)) throw new Error(onlySenderSelectedError);
2172
2175
  const statuses: JsonRecord[] = [];
2173
2176
  const recipients: Array<{ name: string; contextPercent?: number }> = [];
2174
2177
  for (const selection of selections) {
2175
2178
  if (selection.team === parent) {
2179
+ if (selection.teammates.length === 0) continue;
2176
2180
  const result = await callParent(childRuntimeConfig!, "team_send_message", {
2177
2181
  targets: selection.teammates.map((teammate) => teammate.teammateId), message: params.message,
2178
2182
  interrupt: selection.teammates.filter((teammate) => interrupted.has(teammate.teammateId)).map((teammate) => teammate.teammateId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "2.0.28",
3
+ "version": "2.0.30",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",