@giladbarnea/pi-simple-team 2.0.10 → 2.0.12

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/child-tools.ts CHANGED
@@ -65,8 +65,13 @@ function readRequiredChildRuntimeConfig(): ChildRuntimeConfig {
65
65
  };
66
66
  }
67
67
 
68
+ /**
69
+ * Main marks only the process it starts with PI_SIMPLE_TEAM_CHILD=1. That process claims the teammate identity for its PID, which
70
+ * survives Pi's in-process reloads and session replacements. Subprocesses inherit the environment, not the claim, so they run as main.
71
+ */
68
72
  export function readChildRuntimeConfig(): ChildRuntimeConfig | undefined {
69
- if (process.env.PI_SIMPLE_TEAM_CHILD !== "1") return undefined;
73
+ if (process.env.PI_SIMPLE_TEAM_CHILD === "1") process.env.PI_SIMPLE_TEAM_CHILD = String(process.pid);
74
+ if (process.env.PI_SIMPLE_TEAM_CHILD !== String(process.pid)) return undefined;
70
75
  return readRequiredChildRuntimeConfig();
71
76
  }
72
77
 
package/index.ts CHANGED
@@ -494,13 +494,21 @@ interface ChildStartOptions {
494
494
  signal?: AbortSignal;
495
495
  }
496
496
 
497
+ /**
498
+ * Resume lets Pi restore the session's model. It passes the saved thinking level because Pi records `--thinking` only in a new session, so a fork keeps main's level.
499
+ * @example launchSettingArguments({ model: "openai-codex/gpt-6-luna", thinking: "xhigh" }, { sessionFile: "/sessions/a.jsonl" }) // ["--thinking", "xhigh"]
500
+ */
501
+ function launchSettingArguments(teammate: Pick<TeammateState, "model" | "thinking">, options: ChildStartOptions): string[] {
502
+ const thinkingArguments = ["--thinking", teammate.thinking];
503
+ return options.sessionFile ? thinkingArguments : ["--model", teammate.model, ...thinkingArguments];
504
+ }
505
+
497
506
  function attachRpcTeammate(team: TeamState, teammate: TeammateState, participants: string[], options: ChildStartOptions): void {
498
507
  const sessionArgs = options.sessionFile
499
508
  ? ["--session", options.sessionFile]
500
509
  : teammate.forkContext && !options.restartEmpty
501
510
  ? ["--fork", team.mainSessionFile!]
502
511
  : [];
503
- const modelArgs = options.sessionFile ? [] : ["--model", teammate.model, "--thinking", teammate.thinking];
504
512
  const args = [
505
513
  "--mode",
506
514
  "rpc",
@@ -511,7 +519,7 @@ function attachRpcTeammate(team: TeamState, teammate: TeammateState, participant
511
519
  ...teammate.extensionPaths.flatMap(extensionPath => ["-e", extensionPath]),
512
520
  "--no-prompt-templates",
513
521
  "--no-themes",
514
- ...modelArgs,
522
+ ...launchSettingArguments(teammate, options),
515
523
  ];
516
524
  const proc = childProcess.spawn(team.parentPiExecutable, args, {
517
525
  cwd: team.projectDirectory ?? process.cwd(),
@@ -559,7 +567,6 @@ async function attachHerdrTeammate(
559
567
  : teammate.forkContext && !options.restartEmpty
560
568
  ? ["--fork", team.mainSessionFile!]
561
569
  : [];
562
- const modelArgs = options.sessionFile ? [] : ["--model", teammate.model, "--thinking", teammate.thinking];
563
570
  const args = ["pane", "split", "--pane", herdrParentPaneId, "--direction", "right", "--no-focus", "--cwd", team.projectDirectory ?? process.cwd()];
564
571
  for (const [name, value] of Object.entries(environment)) {
565
572
  if (value !== undefined) args.push("--env", `${name}=${value}`);
@@ -574,7 +581,7 @@ async function attachHerdrTeammate(
574
581
  "-e",
575
582
  teamLiteExtensionPath,
576
583
  ...teammate.extensionPaths.flatMap(extensionPath => ["-e", extensionPath]),
577
- ...modelArgs,
584
+ ...launchSettingArguments(teammate, options),
578
585
  ].map(shellQuote).join(" ");
579
586
  await runCommand("herdr", ["pane", "run", teammate.paneId, command]);
580
587
  appendSpawnLog(team, teammate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",