pi-crew 0.2.8 → 0.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-crew",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
5
5
  "author": "baphuongna",
6
6
  "license": "MIT",
@@ -201,7 +201,7 @@ export async function handleRun(params: TeamToolParamsValue, ctx: TeamContext):
201
201
  ctx.onRunStarted?.(updatedManifest.runId);
202
202
  ctx.startForegroundRun(async (signal) => {
203
203
  try {
204
- await executeTeamRun({ manifest: executionManifest, tasks, team, workflow, agents, executeWorkers, limits: executedConfig.limits, runtime, runtimeConfig: executedConfig.runtime, parentContext: buildParentContext(ctx), parentModel: ctx.model, modelRegistry: ctx.modelRegistry, modelOverride: params.model, skillOverride, signal, reliability: executedConfig.reliability, metricRegistry: ctx.metricRegistry, onJsonEvent: ctx.onJsonEvent, workspaceId: ctx.cwd });
204
+ await executeTeamRun({ manifest: executionManifest, tasks, team, workflow, agents, executeWorkers, limits: executedConfig.limits, runtime, runtimeConfig: executedConfig.runtime, parentContext: buildParentContext(ctx), parentModel: ctx.model, modelRegistry: ctx.modelRegistry, modelOverride: params.model, skillOverride, signal, reliability: executedConfig.reliability, metricRegistry: ctx.metricRegistry, onJsonEvent: ctx.onJsonEvent, workspaceId: ctx.sessionId ?? ctx.cwd });
205
205
  } finally {
206
206
  unregisterActiveRun(updatedManifest.runId);
207
207
  }
@@ -237,7 +237,7 @@ export async function handleResume(params: TeamToolParamsValue, ctx: TeamContext
237
237
  if (replay.messages.length) appendEvent(runtimeManifest.eventsPath, { type: "mailbox.replayed", runId: runtimeManifest.runId, message: `Replayed ${replay.messages.length} pending inbox message(s).`, data: { messageIds: replay.messages.map((message) => message.id), taskIds: replay.messages.map((message) => message.taskId).filter(Boolean) } });
238
238
  const executeWorkers = runtime.kind !== "scaffold";
239
239
  const resumeSkillOverride = normalizeSkillOverride(params.skill) ?? runtimeManifest.skillOverride;
240
- const executed = await executeTeamRun({ manifest: runtimeManifest, tasks: resetTasks, team, workflow, agents, executeWorkers, limits: executedConfig.limits, runtime, runtimeConfig: executedConfig.runtime, parentContext: buildParentContext(ctx), parentModel: ctx.model, modelRegistry: ctx.modelRegistry, modelOverride: params.model, skillOverride: resumeSkillOverride, signal: ctx.signal, reliability: executedConfig.reliability, metricRegistry: ctx.metricRegistry, workspaceId: ctx.cwd });
240
+ const executed = await executeTeamRun({ manifest: runtimeManifest, tasks: resetTasks, team, workflow, agents, executeWorkers, limits: executedConfig.limits, runtime, runtimeConfig: executedConfig.runtime, parentContext: buildParentContext(ctx), parentModel: ctx.model, modelRegistry: ctx.modelRegistry, modelOverride: params.model, skillOverride: resumeSkillOverride, signal: ctx.signal, reliability: executedConfig.reliability, metricRegistry: ctx.metricRegistry, workspaceId: ctx.sessionId ?? ctx.cwd });
241
241
  return result([`Resumed run ${executed.manifest.runId}.`, `Status: ${executed.manifest.status}`, `Tasks: ${executed.tasks.length}`, `Artifacts: ${executed.manifest.artifactsRoot}`].join("\n"), { action: "resume", status: executed.manifest.status === "failed" ? "error" : "ok", runId: executed.manifest.runId, artifactsRoot: executed.manifest.artifactsRoot }, executed.manifest.status === "failed");
242
242
  });
243
243
  }
@@ -120,11 +120,18 @@ export interface SpawnBackgroundTeamRunResult {
120
120
  }
121
121
 
122
122
  export function buildBackgroundSpawnOptions(manifest: TeamRunManifest, logFd: number): SpawnOptions {
123
+ // NOTE: Do NOT set PI_CREW_PARENT_PID for the background runner.
124
+ // The background runner is a top-level worker spawned by the team tool.
125
+ // When the team tool finishes, its process exits, and the background runner
126
+ // would incorrectly detect a "dead parent" and self-terminate.
127
+ // Child workers spawned BY the background runner will have the background
128
+ // runner as their parent, so they correctly die when the runner exits.
129
+ const { PI_CREW_PARENT_PID: _, ...envWithoutParentPid } = process.env;
123
130
  return {
124
131
  cwd: manifest.cwd,
125
132
  detached: true,
126
133
  stdio: ["ignore", logFd, logFd],
127
- env: { ...process.env, PI_CREW_PARENT_PID: String(process.pid) },
134
+ env: envWithoutParentPid,
128
135
  windowsHide: true,
129
136
  };
130
137
  }
@@ -130,7 +130,9 @@ async function main(): Promise<void> {
130
130
  appendEvent(manifest.eventsPath, { type: "runtime.resolved", runId: manifest.runId, message: `Runtime resolved: ${runtime.kind} safety=${runtime.safety}`, data: { runtimeResolution, async: true } });
131
131
  if (runtime.safety === "blocked") throw new Error(runtime.reason ?? "Child worker execution is disabled; refusing to create no-op scaffold subagents.");
132
132
  const executeWorkers = runtime.kind !== "scaffold";
133
- const result = await executeTeamRun({ manifest, tasks, team, workflow, agents, executeWorkers, limits: runConfig.limits, runtime, runtimeConfig: runConfig.runtime, skillOverride: manifest.skillOverride, reliability: runConfig.reliability, workspaceId: manifest.cwd });
133
+ // Use ownerSessionId for workspaceId to ensure agents are only visible to the session that spawned them.
134
+ // manifest.cwd would cause cross-session visibility since all sessions share the same project directory.
135
+ const result = await executeTeamRun({ manifest, tasks, team, workflow, agents, executeWorkers, limits: runConfig.limits, runtime, runtimeConfig: runConfig.runtime, skillOverride: manifest.skillOverride, reliability: runConfig.reliability, workspaceId: manifest.ownerSessionId ?? manifest.cwd });
134
136
  manifest = result.manifest;
135
137
  tasks = result.tasks;
136
138
  appendEvent(manifest.eventsPath, { type: "async.completed", runId: manifest.runId, data: { status: manifest.status, tasks: tasks.length } });