pi-crew 0.2.10 → 0.2.11

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.10",
3
+ "version": "0.2.11",
4
4
  "description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
5
5
  "author": "baphuongna",
6
6
  "license": "MIT",
@@ -3,6 +3,7 @@ import { Type } from "@sinclair/typebox";
3
3
  import type { TeamToolParamsValue } from "../../schema/team-tool-schema.ts";
4
4
  // Lazy-loaded: team-tool.ts pulls in entire runtime chain.
5
5
  import type { handleTeamTool as HandleTeamToolFn } from "../team-tool.ts";
6
+ import { withSessionId } from "../team-tool/context.ts";
6
7
  let _cachedHandleTeamTool: typeof HandleTeamToolFn | undefined;
7
8
  async function handleTeamTool(params: Parameters<typeof HandleTeamToolFn>[0], ctx: Parameters<typeof HandleTeamToolFn>[1]): Promise<Awaited<ReturnType<typeof HandleTeamToolFn>>> {
8
9
  if (!_cachedHandleTeamTool) {
@@ -63,7 +64,10 @@ export function registerSubagentTools(pi: ExtensionAPI, subagentManager: Subagen
63
64
  const spawnOptions = __test__subagentSpawnParams(params as Record<string, unknown>, ctx);
64
65
  spawnOptions.ownerSessionGeneration = options.ownerSessionGeneration?.();
65
66
  if (!spawnOptions.prompt.trim()) return subagentToolResult(t("agent.requiresPrompt"), {}, true);
66
- const runner = async (currentOptions: SubagentSpawnOptions, childSignal?: AbortSignal) => handleTeamTool({ action: "run", agent: currentOptions.type, goal: currentOptions.prompt, model: currentOptions.model, skill: currentOptions.skill, async: currentOptions.background, config: currentOptions.maxTurns ? { runtime: { maxTurns: currentOptions.maxTurns } } : undefined } as TeamToolParamsValue, { ...ctx, signal: childSignal, ...(options.startForegroundRun ? { startForegroundRun: (runRunner: (sig?: AbortSignal) => Promise<void>, runId?: string) => options.startForegroundRun!(ctx, runRunner, runId) } : {}) });
67
+ // Extract sessionId from sessionManager.getSessionId() so team runs created
68
+ // by the Agent tool have proper session ownership for isolation.
69
+ const ctxWithSession = withSessionId(ctx);
70
+ const runner = async (currentOptions: SubagentSpawnOptions, childSignal?: AbortSignal) => handleTeamTool({ action: "run", agent: currentOptions.type, goal: currentOptions.prompt, model: currentOptions.model, skill: currentOptions.skill, async: currentOptions.background, config: currentOptions.maxTurns ? { runtime: { maxTurns: currentOptions.maxTurns } } : undefined } as TeamToolParamsValue, { ...ctxWithSession, signal: childSignal, ...(options.startForegroundRun ? { startForegroundRun: (runRunner: (sig?: AbortSignal) => Promise<void>, runId?: string) => options.startForegroundRun!(ctxWithSession, runRunner, runId) } : {}) });
67
71
  const record = subagentManager.spawn(spawnOptions, runner, spawnOptions.background ? undefined : signal);
68
72
  if (spawnOptions.background || record.status === "queued") {
69
73
  // Phase 1.1a: Terminate turn for background queued — no LLM follow-up needed.