@giladbarnea/pi-simple-team 1.0.18 → 1.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/index.ts +27 -4
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface TeammateSpec {
|
|
|
45
45
|
prompt: string;
|
|
46
46
|
model: string;
|
|
47
47
|
thinking?: ThinkingLevel;
|
|
48
|
+
inheritContext?: boolean;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
type TeammateTransport = "rpc" | "herdr";
|
|
@@ -54,6 +55,7 @@ interface TeammateState {
|
|
|
54
55
|
prompt: string;
|
|
55
56
|
model: string;
|
|
56
57
|
thinking: ThinkingLevel;
|
|
58
|
+
inheritContext: boolean;
|
|
57
59
|
transport: TeammateTransport;
|
|
58
60
|
process?: ChildProcess;
|
|
59
61
|
paneId?: string;
|
|
@@ -75,6 +77,7 @@ interface TeamState {
|
|
|
75
77
|
name: string;
|
|
76
78
|
showOnHerdrPanes: boolean;
|
|
77
79
|
teamPrompt: string;
|
|
80
|
+
mainSessionFile?: string;
|
|
78
81
|
members: Map<string, TeammateState>;
|
|
79
82
|
statuses: Map<string, TeamStatus>;
|
|
80
83
|
created: string;
|
|
@@ -488,6 +491,7 @@ function createTeammateState(team: TeamState, teammateSpec: TeammateSpec): Teamm
|
|
|
488
491
|
prompt: teammateSpec.prompt,
|
|
489
492
|
model: teammateSpec.model,
|
|
490
493
|
thinking,
|
|
494
|
+
inheritContext: Boolean(teammateSpec.inheritContext),
|
|
491
495
|
transport: team.showOnHerdrPanes ? "herdr" : "rpc",
|
|
492
496
|
visibleReady,
|
|
493
497
|
resolveVisibleReady,
|
|
@@ -519,15 +523,17 @@ function appendSpawnLog(team: TeamState, teammate: TeammateState): void {
|
|
|
519
523
|
teammate: teammate.name,
|
|
520
524
|
direction: "runtime",
|
|
521
525
|
kind: "spawn",
|
|
522
|
-
summary: `spawned ${teammate.name} (model=${teammate.model}, thinking=${teammate.thinking})`,
|
|
523
|
-
details: { model: teammate.model, thinking: teammate.thinking, transport: teammate.transport, paneId: teammate.paneId },
|
|
526
|
+
summary: `spawned ${teammate.name} (model=${teammate.model}, thinking=${teammate.thinking}, context=${teammate.inheritContext ? "inherited" : "fresh"})`,
|
|
527
|
+
details: { model: teammate.model, thinking: teammate.thinking, inheritContext: teammate.inheritContext, transport: teammate.transport, paneId: teammate.paneId },
|
|
524
528
|
});
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
function attachRpcTeammate(team: TeamState, teammate: TeammateState, participants: string[]): void {
|
|
532
|
+
const sessionArgs = teammate.inheritContext ? ["--fork", team.mainSessionFile!] : [];
|
|
528
533
|
const args = [
|
|
529
534
|
"--mode",
|
|
530
535
|
"rpc",
|
|
536
|
+
...sessionArgs,
|
|
531
537
|
"-e",
|
|
532
538
|
teamLiteExtensionPath,
|
|
533
539
|
"--no-prompt-templates",
|
|
@@ -583,7 +589,19 @@ async function attachVisibleTeammate(team: TeamState, teammate: TeammateState, p
|
|
|
583
589
|
for (const [name, value] of Object.entries(environment)) {
|
|
584
590
|
if (value !== undefined) args.push("--env", `${name}=${value}`);
|
|
585
591
|
}
|
|
586
|
-
args.push(
|
|
592
|
+
args.push(
|
|
593
|
+
"--",
|
|
594
|
+
"pi",
|
|
595
|
+
...(teammate.inheritContext ? ["--fork", team.mainSessionFile!] : []),
|
|
596
|
+
"-e",
|
|
597
|
+
teamLiteExtensionPath,
|
|
598
|
+
"--model",
|
|
599
|
+
teammate.model,
|
|
600
|
+
"--thinking",
|
|
601
|
+
teammate.thinking,
|
|
602
|
+
"--system-prompt",
|
|
603
|
+
systemPrompt,
|
|
604
|
+
);
|
|
587
605
|
const result = await runCommand("herdr", args);
|
|
588
606
|
teammate.paneId = parseHerdrPaneId(result.stdout, teammate.name);
|
|
589
607
|
appendSpawnLog(team, teammate);
|
|
@@ -804,6 +822,7 @@ function teammateSchema(modelGuidance: string) {
|
|
|
804
822
|
prompt: Type.String({ description: "Individual teammate system prompt" }),
|
|
805
823
|
model: Type.String({ description: `Canonical provider/model id for this teammate. ${modelGuidance}` }),
|
|
806
824
|
thinking: Type.Optional(StringEnum(thinkingLevels, { description: "Thinking level for this teammate. Defaults to xhigh.", default: defaultThinkingLevel })),
|
|
825
|
+
inheritContext: Type.Optional(Type.Boolean({ description: "Start from a fork of main's persisted session. The fork is taken during asynchronous child startup. Defaults to false.", default: false })),
|
|
807
826
|
});
|
|
808
827
|
}
|
|
809
828
|
|
|
@@ -832,7 +851,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
832
851
|
defineTool({
|
|
833
852
|
name: "team_spawn",
|
|
834
853
|
label: "Team Spawn",
|
|
835
|
-
description: `Spawn a persistent team of Pi teammates with fresh context windows. If the user is interested, set \`showOnHerdrPanes\` to run each teammate in a visible Herdr pane. The main agent (you) is included automatically; do not specify it as a teammate. ${modelGuidance}`,
|
|
854
|
+
description: `Spawn a persistent team of Pi teammates. Teammates start with fresh context windows unless \`inheritContext\` is true. If the user is interested, set \`showOnHerdrPanes\` to run each teammate in a visible Herdr pane. The main agent (you) is included automatically; do not specify it as a teammate. ${modelGuidance}`,
|
|
836
855
|
promptSnippet: `Spawn persistent Pi teammates. ${modelGuidance} Unless required, don’t fill up your time by repeatedly busy-polling team information. Don’t bash sleep to wait for progress; instead, set your status to advertise that you are counting on teammates to send you important milestones or requests for help, and that otherwise you are staying idle. Send this actively to the team. Then end your turn by sending a simple message to the user, and finally stay put.`,
|
|
837
856
|
renderShell: "self",
|
|
838
857
|
renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context, sessionTeammateRoster),
|
|
@@ -856,6 +875,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
856
875
|
if (teammateNames.includes("main")) throw new Error('"main" is reserved');
|
|
857
876
|
|
|
858
877
|
validateTeammateModels(teammateSpecs, context.modelRegistry.getAvailable());
|
|
878
|
+
const inheritsMainContext = teammateSpecs.some((teammate) => Boolean(teammate.inheritContext));
|
|
879
|
+
const mainSessionFile = inheritsMainContext ? context.sessionManager.getSessionFile() : undefined;
|
|
880
|
+
if (inheritsMainContext && !mainSessionFile) throw new Error("inheritContext requires a persistent main session");
|
|
859
881
|
sessionTeammateRoster.push(...teammateNames.filter((teammateName) => !sessionTeammateRoster.includes(teammateName)));
|
|
860
882
|
await ensureCallbackServer();
|
|
861
883
|
|
|
@@ -865,6 +887,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
865
887
|
name: teamName,
|
|
866
888
|
showOnHerdrPanes,
|
|
867
889
|
teamPrompt: params.teamPrompt,
|
|
890
|
+
mainSessionFile,
|
|
868
891
|
members: new Map(),
|
|
869
892
|
statuses: new Map([["main", status("available", "Main agent")]]),
|
|
870
893
|
created: nowText(),
|