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BAAmB,GAAG,sBAAsB,GAAG,eAAe,GAAG,0BAA0B,CAC3F,GACC,+BAA+B,CAiBjC;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,GAAG,SAAS,CA8CrE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,GAAG,gBAAgB,CAsH7F;AAOD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CAqNtE;AAED,eAAO,MAAM,kBAAkB,2BAAqB,CAAC;AAErD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAOvE","sourcesContent":["import { createHash } from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { THINKING_LEVELS } from \"../../shared/model-info.ts\";\nimport {\n\ttype JsonSchemaObject,\n\ttype LaunchResolvedChildExtensionsV1,\n\ttype ResolvedToolBudget,\n\tTEMP_ROOT_DIR,\n} from \"../../shared/types.ts\";\nimport { getAgentDir, PI_CODING_AGENT_PACKAGE_ROOT_ENV } from \"../../shared/utils.ts\";\nimport {\n\tCHILD_WATCHDOG_CONFIG_ENV,\n\ttype ChildWatchdogConfig,\n\tencodeChildWatchdogConfig,\n} from \"../../watchdog/child-status.ts\";\nimport { WAIT_TOOL_ENABLED_ENV } from \"../background/wait-config.ts\";\nimport {\n\tcapabilityCeilingAgentRestrictionSources,\n\tdecodeSubagentCapabilityCeiling,\n\tencodeSubagentCapabilityCeiling,\n\tintersectSubagentCapabilityCeilings,\n\tisAgentAllowedByCapabilityCeiling,\n\ttype ResolvedSubagentCapabilityCeiling,\n\tSUBAGENT_CAPABILITY_CEILING_ENV,\n\ttype SubagentCapabilityAudit,\n} from \"./capability-ceiling.ts\";\nimport { type ResolvedMcpDirectToolSelection, resolveMcpDirectToolSelections } from \"./mcp-direct-tool-allowlist.ts\";\nimport { encodeNestedPathEnv, type NestedPathEntry, parseNestedPathEnv } from \"./nested-path.ts\";\nimport {\n\tencodePermissionRules,\n\tPERMISSION_AUDIT_PATH_ENV,\n\tPERMISSION_POLICY_ENV,\n\ttype PermissionRules,\n} from \"./permissions.ts\";\nimport { resolvePiPackageRoot } from \"./pi-spawn.ts\";\nimport { RUNTIME_EXTENSION_ACK_PATH_ENV } from \"./runtime-acknowledged-extensions.ts\";\nimport { STRUCTURED_OUTPUT_CAPTURE_ENV, STRUCTURED_OUTPUT_SCHEMA_ENV } from \"./structured-output.ts\";\nimport {\n\tCHILD_TOOL_DIAGNOSTIC_PATH_ENV,\n\tMCP_DIRECT_CHILD_TOOLS_ENV,\n\tREQUIRED_CHILD_TOOLS_ENV,\n} from \"./tool-availability.ts\";\nimport { encodeToolBudgetEnv, TOOL_BUDGET_ENV, TOOL_BUDGET_ZERO_AUTH_ENV } from \"./tool-budget.ts\";\n\nconst TASK_ARG_LIMIT = 8000;\nconst MAX_LAUNCH_RESOLVED_EXTENSION_IDS = 32;\nconst PROMPT_RUNTIME_EXTENSION_PATH = path.join(\n\tpath.dirname(fileURLToPath(import.meta.url)),\n\t\"subagent-prompt-runtime.ts\",\n);\nconst FANOUT_CHILD_EXTENSION_PATH = path.join(\n\tpath.dirname(fileURLToPath(import.meta.url)),\n\t\"..\",\n\t\"..\",\n\t\"extension\",\n\t\"fanout-child.ts\",\n);\nexport const SUBAGENT_CHILD_ENV = \"PI_SUBAGENT_CHILD\";\nexport const SUBAGENT_ORCHESTRATOR_TARGET_ENV = \"PI_SUBAGENT_ORCHESTRATOR_TARGET\";\nexport const SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV = \"PI_SUBAGENT_ORCHESTRATOR_SESSION_ID\";\nexport const SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV = \"PI_SUBAGENT_SUPERVISOR_CHANNEL_DIR\";\nexport const SUBAGENT_RUN_ID_ENV = \"PI_SUBAGENT_RUN_ID\";\nexport const SUBAGENT_CHILD_AGENT_ENV = \"PI_SUBAGENT_CHILD_AGENT\";\nexport const SUBAGENT_CHILD_INDEX_ENV = \"PI_SUBAGENT_CHILD_INDEX\";\nexport const SUBAGENT_FANOUT_CHILD_ENV = \"PI_SUBAGENT_FANOUT_CHILD\";\nexport const SUBAGENT_PARENT_EVENT_SINK_ENV = \"PI_SUBAGENT_PARENT_EVENT_SINK\";\nexport const SUBAGENT_PARENT_CONTROL_INBOX_ENV = \"PI_SUBAGENT_PARENT_CONTROL_INBOX\";\nexport const SUBAGENT_PARENT_ROOT_RUN_ID_ENV = \"PI_SUBAGENT_PARENT_ROOT_RUN_ID\";\nexport const SUBAGENT_PARENT_RUN_ID_ENV = \"PI_SUBAGENT_PARENT_RUN_ID\";\nexport const SUBAGENT_PARENT_CHILD_INDEX_ENV = \"PI_SUBAGENT_PARENT_CHILD_INDEX\";\nexport const SUBAGENT_PARENT_DEPTH_ENV = \"PI_SUBAGENT_PARENT_DEPTH\";\nexport const SUBAGENT_PARENT_PATH_ENV = \"PI_SUBAGENT_PARENT_PATH\";\nexport const SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV = \"PI_SUBAGENT_PARENT_CAPABILITY_TOKEN\";\nexport const SUBAGENT_PARENT_SESSION_ENV = \"PI_SUBAGENT_PARENT_SESSION\";\nexport const SUBAGENT_STEER_INBOX_ENV = \"PI_SUBAGENT_STEER_INBOX\";\nexport const SUBAGENT_STEER_CAPABILITY_ENV = \"PI_SUBAGENT_STEER_CAPABILITY\";\nexport const SUBAGENT_STEER_ACK_DIR_ENV = \"PI_SUBAGENT_STEER_ACK_DIR\";\nexport const PI_INTERCOM_STABLE_ID_ENV = \"PI_INTERCOM_STABLE_ID\";\nexport const PI_INTERCOM_SESSION_ID_ENV = \"PI_INTERCOM_SESSION_ID\";\n\nexport interface BuildPiArgsInput {\n\tparentSessionId?: string;\n\tbaseArgs: string[];\n\ttask: string;\n\tsessionEnabled: boolean;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tmodel?: string;\n\tthinking?: string | false;\n\tsystemPromptMode?: \"append\" | \"replace\";\n\tinheritProjectContext: boolean;\n\tinheritSkills: boolean;\n\trequireReadTool?: boolean;\n\ttools?: string[];\n\textensions?: string[];\n\tsubagentOnlyExtensions?: string[];\n\tsystemPrompt?: string | null;\n\tmcpDirectTools?: string[];\n\tcwd?: string;\n\tpromptFileStem?: string;\n\tintercomSessionName?: string;\n\torchestratorIntercomTarget?: string;\n\trunId?: string;\n\tchildAgentName?: string;\n\tchildIndex?: number;\n\tparentEventSink?: string;\n\tparentControlInbox?: string;\n\tparentRootRunId?: string;\n\tparentRunId?: string;\n\tparentChildIndex?: number;\n\tparentDepth?: number;\n\tparentPath?: NestedPathEntry[];\n\tparentCapabilityToken?: string;\n\tsteerInboxDir?: string;\n\tsteerCapabilityPath?: string;\n\tsteerAckDir?: string;\n\tstructuredOutput?: {\n\t\tschema: JsonSchemaObject;\n\t\tschemaPath: string;\n\t\toutputPath: string;\n\t};\n\ttoolBudget?: ResolvedToolBudget;\n\tallowZeroToolBudget?: boolean;\n\tpermissionRules?: PermissionRules;\n\tpermissionAuditPath?: string;\n\tchildWatchdog?: ChildWatchdogConfig;\n\twaitToolEnabled?: boolean;\n\tcapabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n}\n\nexport interface BuildPiArgsResult {\n\targs: string[];\n\tenv: Record<string, string | undefined>;\n\ttempDir?: string;\n\ttoolDiagnosticPath?: string;\n\truntimeAcknowledgedExtensionsPath?: string;\n\tcapabilityAudit?: SubagentCapabilityAudit;\n}\n\nfunction sanitizeSupervisorChannelSegment(value: string): string {\n\treturn (\n\t\tvalue\n\t\t\t.trim()\n\t\t\t.replace(/[^A-Za-z0-9._-]+/g, \"-\")\n\t\t\t.replace(/^-+|-+$/g, \"\") || \"unknown\"\n\t);\n}\n\nfunction supervisorChannelDir(runId: string, agent: string, childIndex: number): string {\n\treturn path.join(\n\t\tTEMP_ROOT_DIR,\n\t\t\"supervisor-channels\",\n\t\t`${sanitizeSupervisorChannelSegment(runId)}-${sanitizeSupervisorChannelSegment(agent)}-${childIndex}`,\n\t);\n}\n\nexport function applyThinkingSuffix(\n\tmodel: string | undefined,\n\tthinking: string | false | undefined,\n\treplaceExisting = false,\n): string | undefined {\n\tif (!model || !thinking) return model;\n\tconst colonIdx = model.lastIndexOf(\":\");\n\tif (colonIdx !== -1 && THINKING_LEVELS.some((level) => level === model.substring(colonIdx + 1))) {\n\t\treturn replaceExisting ? `${model.slice(0, colonIdx)}:${thinking}` : model;\n\t}\n\treturn `${model}:${thinking}`;\n}\n\nexport interface ResolvePiLaunchToolPlanInput {\n\ttools?: string[];\n\textensions?: string[];\n\tsubagentOnlyExtensions?: string[];\n\tmcpDirectTools?: string[];\n\tcwd?: string;\n\trequireReadTool?: boolean;\n\tstructuredOutput?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tschema: JsonSchemaObject;\n\t\t\t\tschemaPath: string;\n\t\t\t\toutputPath: string;\n\t\t  };\n\tcapabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n\tinheritedCapabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n\tagentName?: string;\n}\n\nexport interface PiLaunchToolPlan {\n\tcapabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n\trequestedBuiltinTools: string[];\n\tdeclaredBuiltinTools: string[];\n\ttoolExtensionPaths: string[];\n\tresolvedMcpSelections: ResolvedMcpDirectToolSelection[];\n\teffectiveMcpSelections: ResolvedMcpDirectToolSelection[];\n\teffectiveMcpTools: string[];\n\texplicitToolAllowlist: boolean;\n\tinternalTools: string[];\n\teffectiveToolAllowlist: string[];\n\trequiredChildTools: string[];\n\tfanoutAuthorized: boolean;\n\truntimeExtensions: string[];\n\tconfiguredExtensions: string[];\n\textensionArgs: string[];\n\tdisableAmbientExtensions: boolean;\n\tcapabilityAudit?: SubagentCapabilityAudit;\n}\n\nfunction extensionIdentifier(value: string): string {\n\treturn `sha256:${createHash(\"sha256\").update(path.normalize(value.trim())).digest(\"hex\").slice(0, 16)}`;\n}\n\nfunction boundedExtensionIdentifiers(values: string[]): {\n\tids: string[];\n\tomitted: number;\n} {\n\tconst ids = [...new Set(values.map(extensionIdentifier))];\n\treturn {\n\t\tids: ids.slice(0, MAX_LAUNCH_RESOLVED_EXTENSION_IDS),\n\t\tomitted: Math.max(0, ids.length - MAX_LAUNCH_RESOLVED_EXTENSION_IDS),\n\t};\n}\n\nexport function projectLaunchResolvedChildExtensions(\n\ttoolPlan: Pick<\n\t\tPiLaunchToolPlan,\n\t\t\"runtimeExtensions\" | \"configuredExtensions\" | \"extensionArgs\" | \"disableAmbientExtensions\"\n\t>,\n): LaunchResolvedChildExtensionsV1 {\n\tconst runtime = boundedExtensionIdentifiers(toolPlan.runtimeExtensions);\n\tconst configured = boundedExtensionIdentifiers(toolPlan.configuredExtensions);\n\tconst effective = boundedExtensionIdentifiers(toolPlan.extensionArgs);\n\treturn {\n\t\tversion: 1,\n\t\tsource: \"launch-resolved\",\n\t\tdisableAmbientExtensions: toolPlan.disableAmbientExtensions,\n\t\truntime: runtime.ids,\n\t\tconfigured: configured.ids,\n\t\teffective: effective.ids,\n\t\tomitted: {\n\t\t\truntime: runtime.omitted,\n\t\t\tconfigured: configured.omitted,\n\t\t\teffective: effective.omitted,\n\t\t},\n\t};\n}\n\n/**\n * Resolve the permission-system extension entry point when installed.\n * Returns the absolute path to the extension's main module, or undefined\n * when the package is not installed. Callers can check `autoInject` config\n * to decide whether to include it in child processes.\n */\nexport function resolvePermissionSystemExtension(): string | undefined {\n\tconst agentDir = getAgentDir();\n\tconst candidates = [\n\t\t// npm-scoped package (most common)\n\t\tpath.join(agentDir, \"npm\", \"node_modules\", \"@gotgenes\", \"pi-permission-system\"),\n\t\t// direct extension directory (some layouts)\n\t\tpath.join(agentDir, \"extensions\", \"pi-permission-system\"),\n\t];\n\tconst errors: Error[] = [];\n\tfor (const extDir of candidates) {\n\t\tif (!fs.existsSync(extDir)) continue;\n\t\tconst pkgPath = path.join(extDir, \"package.json\");\n\t\tif (!fs.existsSync(pkgPath)) {\n\t\t\terrors.push(new Error(`Permission-system package manifest is missing at ${pkgPath}.`));\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tlet pkg: { pi?: { extensions?: string[] } };\n\t\t\tconst parsed: unknown = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n\t\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\t\tthrow new Error(\"manifest root must be an object\");\n\t\t\t}\n\t\t\tpkg = parsed as typeof pkg;\n\t\t\tconst extensions = pkg.pi?.extensions;\n\t\t\tconst entry = Array.isArray(extensions) ? extensions[0] : undefined;\n\t\t\tif (typeof entry !== \"string\" || !entry.trim()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Permission-system package manifest at ${pkgPath} must declare pi.extensions[0] as a non-empty string.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst resolved = path.resolve(extDir, entry);\n\t\t\tif (fs.existsSync(resolved)) return resolved;\n\t\t\tthrow new Error(\n\t\t\t\t`Permission-system extension entry ${JSON.stringify(entry)} in ${pkgPath} does not exist at ${resolved}.`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\terrors.push(\n\t\t\t\tmessage.startsWith(\"Permission-system\")\n\t\t\t\t\t? new Error(message)\n\t\t\t\t\t: new Error(`Cannot read permission-system package manifest at ${pkgPath}: ${message}`),\n\t\t\t);\n\t\t}\n\t}\n\tif (errors.length > 0) throw errors[0]!;\n\treturn undefined;\n}\n\nexport function resolvePiLaunchToolPlan(input: ResolvePiLaunchToolPlanInput): PiLaunchToolPlan {\n\tconst capabilityCeiling = intersectSubagentCapabilityCeilings(\n\t\tinput.capabilityCeiling,\n\t\tinput.inheritedCapabilityCeiling,\n\t);\n\tconst allowedToolSet =\n\t\tcapabilityCeiling?.allowedTools === undefined ? undefined : new Set(capabilityCeiling.allowedTools);\n\tconst requestedBuiltinTools =\n\t\tinput.tools?.filter((tool) => !(tool.includes(\"/\") || tool.endsWith(\".ts\") || tool.endsWith(\".js\"))) ?? [];\n\tif (input.requireReadTool && allowedToolSet && !allowedToolSet.has(\"read\")) {\n\t\tthrow new Error(\n\t\t\t`Capability ceiling from ${capabilityCeiling?.sources.join(\", \") || \"unknown source\"} excludes required tool 'read' for lazy skill loading.`,\n\t\t);\n\t}\n\tconst declaredBuiltinTools =\n\t\tinput.tools === undefined\n\t\t\t? allowedToolSet\n\t\t\t\t? [...allowedToolSet]\n\t\t\t\t: []\n\t\t\t: (input.requireReadTool &&\n\t\t\t\trequestedBuiltinTools.length > 0 &&\n\t\t\t\t!requestedBuiltinTools.includes(\"read\") &&\n\t\t\t\t!allowedToolSet\n\t\t\t\t\t? [\"read\", ...requestedBuiltinTools]\n\t\t\t\t\t: requestedBuiltinTools\n\t\t\t\t).filter((tool) => !allowedToolSet || allowedToolSet.has(tool));\n\tconst fanoutAuthorized = declaredBuiltinTools.includes(\"subagent\");\n\tconst toolExtensionPaths: string[] = capabilityCeiling?.denyExtensions\n\t\t? []\n\t\t: (input.tools ?? []).filter(\n\t\t\t\t(tool) =>\n\t\t\t\t\t!requestedBuiltinTools.includes(tool) &&\n\t\t\t\t\t(tool.includes(\"/\") || tool.endsWith(\".ts\") || tool.endsWith(\".js\")),\n\t\t\t);\n\tconst resolvedMcpSelections = capabilityCeiling?.denyExtensions\n\t\t? []\n\t\t: resolveMcpDirectToolSelections(input.mcpDirectTools, input.cwd);\n\tconst effectiveMcpSelections = resolvedMcpSelections.filter(\n\t\t(selection) => !allowedToolSet || allowedToolSet.has(selection.name),\n\t);\n\tconst effectiveMcpTools = effectiveMcpSelections.map((selection) => selection.name);\n\tconst explicitToolAllowlist =\n\t\tinput.tools !== undefined || (input.mcpDirectTools?.length ?? 0) > 0 || allowedToolSet !== undefined;\n\tconst internalTools = input.structuredOutput ? [\"structured_output\"] : [];\n\tconst effectiveToolAllowlist = [...new Set([...declaredBuiltinTools, ...effectiveMcpTools, ...internalTools])];\n\tconst requiredChildTools = explicitToolAllowlist\n\t\t? [\n\t\t\t\t...new Set([\n\t\t\t\t\t...(input.tools !== undefined ? declaredBuiltinTools : []),\n\t\t\t\t\t...(input.mcpDirectTools?.length ? effectiveMcpTools : []),\n\t\t\t\t\t...internalTools,\n\t\t\t\t]),\n\t\t\t]\n\t\t: [];\n\tconst permSystemExt = capabilityCeiling?.denyExtensions ? undefined : resolvePermissionSystemExtension();\n\tconst runtimeExtensions = [\n\t\tPROMPT_RUNTIME_EXTENSION_PATH,\n\t\t...(fanoutAuthorized ? [FANOUT_CHILD_EXTENSION_PATH] : []),\n\t\t...(permSystemExt ? [permSystemExt] : []),\n\t];\n\tconst disableAmbientExtensions = capabilityCeiling?.denyExtensions === true || input.extensions !== undefined;\n\tconst configuredExtensions = capabilityCeiling?.denyExtensions\n\t\t? []\n\t\t: [...toolExtensionPaths, ...(input.extensions ?? []), ...(input.subagentOnlyExtensions ?? [])];\n\tconst extensionArgs = disableAmbientExtensions\n\t\t? [...new Set([...runtimeExtensions, ...configuredExtensions])]\n\t\t: [...new Set([...runtimeExtensions, ...toolExtensionPaths, ...(input.subagentOnlyExtensions ?? [])])];\n\tconst requestedToolNames =\n\t\tinput.tools !== undefined\n\t\t\t? [...new Set([...requestedBuiltinTools, ...resolvedMcpSelections.map((selection) => selection.name)])]\n\t\t\t: undefined;\n\tconst capabilityAudit = capabilityCeiling\n\t\t? ({\n\t\t\t\tceiling: capabilityCeiling,\n\t\t\t\t...(requestedToolNames ? { requestedTools: requestedToolNames } : {}),\n\t\t\t\teffectiveTools: effectiveToolAllowlist,\n\t\t\t\tremovedTools: requestedToolNames?.filter((tool) => !effectiveToolAllowlist.includes(tool)) ?? [],\n\t\t\t\tinternalTools,\n\t\t\t\textensionsDenied: capabilityCeiling.denyExtensions,\n\t\t\t\tremovedExtensionCount: capabilityCeiling.denyExtensions\n\t\t\t\t\t? (input.extensions?.length ?? 0) +\n\t\t\t\t\t\t(input.subagentOnlyExtensions?.length ?? 0) +\n\t\t\t\t\t\t(input.tools ?? []).filter(\n\t\t\t\t\t\t\t(tool) => tool.includes(\"/\") || tool.endsWith(\".ts\") || tool.endsWith(\".js\"),\n\t\t\t\t\t\t).length\n\t\t\t\t\t: 0,\n\t\t\t\trequestedMcpToolCount: input.mcpDirectTools?.length ?? 0,\n\t\t\t\teffectiveMcpTools,\n\t\t\t\tagentAllowed:\n\t\t\t\t\tinput.agentName === undefined\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: isAgentAllowedByCapabilityCeiling(input.agentName, capabilityCeiling),\n\t\t\t\t...(capabilityCeilingAgentRestrictionSources(capabilityCeiling)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tagentRestrictionSources: capabilityCeilingAgentRestrictionSources(capabilityCeiling),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t} satisfies SubagentCapabilityAudit)\n\t\t: undefined;\n\treturn {\n\t\t...(capabilityCeiling ? { capabilityCeiling } : {}),\n\t\trequestedBuiltinTools,\n\t\tdeclaredBuiltinTools,\n\t\ttoolExtensionPaths,\n\t\tresolvedMcpSelections,\n\t\teffectiveMcpSelections,\n\t\teffectiveMcpTools,\n\t\texplicitToolAllowlist,\n\t\tinternalTools,\n\t\teffectiveToolAllowlist,\n\t\trequiredChildTools,\n\t\tfanoutAuthorized,\n\t\truntimeExtensions,\n\t\tconfiguredExtensions,\n\t\textensionArgs,\n\t\tdisableAmbientExtensions,\n\t\t...(capabilityAudit ? { capabilityAudit } : {}),\n\t};\n}\n\n/** Escape XML-significant characters in a string for safe attribute interpolation. */\nfunction escapeXmlAttr(value: string): string {\n\treturn value.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n}\n\nexport function buildPiArgs(input: BuildPiArgsInput): BuildPiArgsResult {\n\tconst args = [...input.baseArgs];\n\n\tif (input.sessionFile) {\n\t\tfs.mkdirSync(path.dirname(input.sessionFile), { recursive: true });\n\t\targs.push(\"--session\", input.sessionFile);\n\t} else {\n\t\tif (!input.sessionEnabled) {\n\t\t\targs.push(\"--no-session\");\n\t\t}\n\t\tif (input.sessionDir) {\n\t\t\tfs.mkdirSync(input.sessionDir, { recursive: true });\n\t\t\targs.push(\"--session-dir\", input.sessionDir);\n\t\t}\n\t}\n\n\tconst modelArg = applyThinkingSuffix(input.model, input.thinking);\n\tif (modelArg) {\n\t\targs.push(\"--model\", modelArg);\n\t}\n\n\tconst toolPlan = resolvePiLaunchToolPlan({\n\t\ttools: input.tools,\n\t\textensions: input.extensions,\n\t\tsubagentOnlyExtensions: input.subagentOnlyExtensions,\n\t\tmcpDirectTools: input.mcpDirectTools,\n\t\tcwd: input.cwd,\n\t\trequireReadTool: input.requireReadTool,\n\t\tstructuredOutput: input.structuredOutput,\n\t\tcapabilityCeiling: input.capabilityCeiling,\n\t\tinheritedCapabilityCeiling: decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]),\n\t\tagentName: input.childAgentName,\n\t});\n\tif (toolPlan.explicitToolAllowlist) {\n\t\targs.push(toolPlan.effectiveToolAllowlist.length > 0 ? \"--tools\" : \"--no-tools\");\n\t\tif (toolPlan.effectiveToolAllowlist.length > 0) args.push(toolPlan.effectiveToolAllowlist.join(\",\"));\n\t}\n\tif (toolPlan.disableAmbientExtensions) {\n\t\targs.push(\"--no-extensions\");\n\t}\n\tfor (const extPath of toolPlan.extensionArgs) args.push(\"--extension\", extPath);\n\n\tif (!input.inheritProjectContext) {\n\t\targs.push(\"--no-context-files\");\n\t}\n\tif (!input.inheritSkills) {\n\t\targs.push(\"--no-skills\");\n\t}\n\n\tlet tempDir: string | undefined;\n\tif (input.systemPrompt !== undefined && input.systemPrompt !== null) {\n\t\ttempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"pi-subagent-\"));\n\t\tconst stem = (input.promptFileStem ?? \"prompt\").replace(/[^\\w.-]/g, \"_\");\n\t\tconst promptPath = path.join(tempDir, `${stem}.md`);\n\t\t// Inject <active_agent> tag so @gotgenes/pi-permission-system can\n\t\t// resolve per-agent policy inside the child session.\n\t\tconst taggedPrompt = input.childAgentName\n\t\t\t? `<active_agent name=\"${escapeXmlAttr(input.childAgentName)}\"/>\\n\\n${input.systemPrompt}`\n\t\t\t: input.systemPrompt;\n\t\tfs.writeFileSync(promptPath, taggedPrompt, { mode: 0o600 });\n\t\targs.push(input.systemPromptMode === \"replace\" ? \"--system-prompt\" : \"--append-system-prompt\", promptPath);\n\t}\n\n\tif (input.task.length > TASK_ARG_LIMIT) {\n\t\tif (!tempDir) {\n\t\t\ttempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"pi-subagent-\"));\n\t\t}\n\t\tconst taskFilePath = path.join(tempDir, \"task.md\");\n\t\tfs.writeFileSync(taskFilePath, `Task: ${input.task}`, { mode: 0o600 });\n\t\targs.push(`@${taskFilePath}`);\n\t} else {\n\t\targs.push(`Task: ${input.task}`);\n\t}\n\n\tconst env: Record<string, string | undefined> = {};\n\tconst piPackageRoot = process.env[PI_CODING_AGENT_PACKAGE_ROOT_ENV] ?? resolvePiPackageRoot();\n\tif (piPackageRoot) env[PI_CODING_AGENT_PACKAGE_ROOT_ENV] = piPackageRoot;\n\tif (!tempDir) tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"pi-subagent-\"));\n\tconst runtimeAcknowledgedExtensionsPath = path.join(tempDir, \"runtime-acknowledged-extensions.json\");\n\tenv[RUNTIME_EXTENSION_ACK_PATH_ENV] = runtimeAcknowledgedExtensionsPath;\n\tlet toolDiagnosticPath: string | undefined;\n\tif (toolPlan.requiredChildTools.length > 0) {\n\t\tif (!tempDir) tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"pi-subagent-\"));\n\t\ttoolDiagnosticPath = path.join(tempDir, \"tool-diagnostic.json\");\n\t\tenv[REQUIRED_CHILD_TOOLS_ENV] = JSON.stringify(toolPlan.requiredChildTools);\n\t\tenv[CHILD_TOOL_DIAGNOSTIC_PATH_ENV] = toolDiagnosticPath;\n\t}\n\tenv[MCP_DIRECT_CHILD_TOOLS_ENV] =\n\t\ttoolPlan.effectiveMcpTools.length > 0 ? JSON.stringify(toolPlan.effectiveMcpTools) : undefined;\n\tenv[SUBAGENT_CHILD_ENV] = \"1\";\n\tenv[SUBAGENT_FANOUT_CHILD_ENV] = toolPlan.fanoutAuthorized ? \"1\" : \"0\";\n\tif (input.waitToolEnabled !== undefined) {\n\t\tenv[WAIT_TOOL_ENABLED_ENV] = input.waitToolEnabled ? \"true\" : \"false\";\n\t}\n\tconst inheritedNestedRoute = Boolean(\n\t\tprocess.env[SUBAGENT_PARENT_EVENT_SINK_ENV] &&\n\t\t\tprocess.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] &&\n\t\t\tprocess.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV],\n\t);\n\tconst parentRunId =\n\t\tinput.parentRunId ??\n\t\tinput.runId ??\n\t\t(inheritedNestedRoute ? process.env[SUBAGENT_RUN_ID_ENV] : undefined) ??\n\t\tprocess.env[SUBAGENT_PARENT_RUN_ID_ENV] ??\n\t\t\"\";\n\tconst parentChildIndex =\n\t\tinput.parentChildIndex !== undefined\n\t\t\t? String(input.parentChildIndex)\n\t\t\t: input.childIndex !== undefined\n\t\t\t\t? String(input.childIndex)\n\t\t\t\t: (process.env[SUBAGENT_PARENT_CHILD_INDEX_ENV] ?? \"\");\n\tconst inheritedDepth = Number(process.env[SUBAGENT_PARENT_DEPTH_ENV]);\n\tconst parentDepth =\n\t\tinput.parentDepth ?? (inheritedNestedRoute && Number.isFinite(inheritedDepth) ? inheritedDepth + 1 : 1);\n\tconst parentPath = input.parentPath ?? [\n\t\t...parseNestedPathEnv(process.env[SUBAGENT_PARENT_PATH_ENV]),\n\t\t...(parentRunId\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\trunId: parentRunId,\n\t\t\t\t\t\t...(parentChildIndex && /^\\d+$/.test(parentChildIndex)\n\t\t\t\t\t\t\t? { stepIndex: Number(parentChildIndex) }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t...(input.childAgentName ? { agent: input.childAgentName } : {}),\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: []),\n\t];\n\tenv[SUBAGENT_PARENT_EVENT_SINK_ENV] = toolPlan.fanoutAuthorized\n\t\t? (input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? \"\")\n\t\t: \"\";\n\tenv[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = toolPlan.fanoutAuthorized\n\t\t? (input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? \"\")\n\t\t: \"\";\n\tenv[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = toolPlan.fanoutAuthorized\n\t\t? (input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? \"\")\n\t\t: \"\";\n\tenv[SUBAGENT_PARENT_RUN_ID_ENV] = toolPlan.fanoutAuthorized ? parentRunId : \"\";\n\tenv[SUBAGENT_PARENT_CHILD_INDEX_ENV] = toolPlan.fanoutAuthorized ? parentChildIndex : \"\";\n\tenv[SUBAGENT_PARENT_DEPTH_ENV] = toolPlan.fanoutAuthorized ? String(parentDepth) : \"\";\n\tenv[SUBAGENT_PARENT_PATH_ENV] = toolPlan.fanoutAuthorized ? encodeNestedPathEnv(parentPath) : \"\";\n\tenv[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = toolPlan.fanoutAuthorized\n\t\t? (input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? \"\")\n\t\t: \"\";\n\tenv.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? \"1\" : \"0\";\n\tenv.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? \"1\" : \"0\";\n\tenv[PI_INTERCOM_STABLE_ID_ENV] = input.intercomSessionName || undefined;\n\tenv[PI_INTERCOM_SESSION_ID_ENV] = undefined;\n\tif (input.intercomSessionName) {\n\t\tenv.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName;\n\t}\n\tif (input.orchestratorIntercomTarget) {\n\t\tenv[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget;\n\t}\n\tif (input.parentSessionId) {\n\t\tenv[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId;\n\t}\n\tconst encodedPermissionRules = encodePermissionRules(input.permissionRules);\n\tif (input.orchestratorIntercomTarget && input.parentSessionId && input.runId && input.childAgentName) {\n\t\tconst childIndex = input.childIndex ?? 0;\n\t\tconst channelDir = supervisorChannelDir(input.runId, input.childAgentName, childIndex);\n\t\tfs.mkdirSync(path.join(channelDir, \"requests\"), { recursive: true });\n\t\tfs.mkdirSync(path.join(channelDir, \"replies\"), { recursive: true });\n\t\tenv[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir;\n\t}\n\tif (encodedPermissionRules)\n\t\tenv[PERMISSION_AUDIT_PATH_ENV] = input.permissionAuditPath ?? path.join(tempDir, \"permission-audit.jsonl\");\n\tif (input.runId) {\n\t\tenv[SUBAGENT_RUN_ID_ENV] = input.runId;\n\t}\n\tif (input.childAgentName) {\n\t\tenv[SUBAGENT_CHILD_AGENT_ENV] = input.childAgentName;\n\t}\n\tif (input.childIndex !== undefined) {\n\t\tenv[SUBAGENT_CHILD_INDEX_ENV] = String(input.childIndex);\n\t}\n\tif (!toolPlan.capabilityCeiling && input.mcpDirectTools?.length)\n\t\tenv.MCP_DIRECT_TOOLS = input.mcpDirectTools.join(\",\");\n\telse if (\n\t\ttoolPlan.capabilityCeiling &&\n\t\ttoolPlan.effectiveMcpSelections.length &&\n\t\t!toolPlan.capabilityCeiling.denyExtensions\n\t)\n\t\tenv.MCP_DIRECT_TOOLS = toolPlan.effectiveMcpSelections.map((selection) => selection.selector).join(\",\");\n\telse env.MCP_DIRECT_TOOLS = \"__none__\";\n\tconst encodedCapabilityCeiling = encodeSubagentCapabilityCeiling(toolPlan.capabilityCeiling);\n\tif (encodedCapabilityCeiling) env[SUBAGENT_CAPABILITY_CEILING_ENV] = encodedCapabilityCeiling;\n\tif (encodedPermissionRules) env[PERMISSION_POLICY_ENV] = encodedPermissionRules;\n\tif (input.structuredOutput) {\n\t\tenv[STRUCTURED_OUTPUT_CAPTURE_ENV] = input.structuredOutput.outputPath;\n\t\tenv[STRUCTURED_OUTPUT_SCHEMA_ENV] = input.structuredOutput.schemaPath;\n\t}\n\tif (input.steerInboxDir) {\n\t\tenv[SUBAGENT_STEER_INBOX_ENV] = input.steerInboxDir;\n\t}\n\tif (input.steerCapabilityPath) env[SUBAGENT_STEER_CAPABILITY_ENV] = input.steerCapabilityPath;\n\tif (input.steerAckDir) env[SUBAGENT_STEER_ACK_DIR_ENV] = input.steerAckDir;\n\tconst encodedToolBudget = encodeToolBudgetEnv(input.toolBudget);\n\tif (encodedToolBudget) env[TOOL_BUDGET_ENV] = encodedToolBudget;\n\tenv[TOOL_BUDGET_ZERO_AUTH_ENV] = input.allowZeroToolBudget ? \"1\" : undefined;\n\tconst encodedChildWatchdog = encodeChildWatchdogConfig(input.childWatchdog);\n\tif (encodedChildWatchdog) env[CHILD_WATCHDOG_CONFIG_ENV] = encodedChildWatchdog;\n\n\tenv[SUBAGENT_PARENT_SESSION_ENV] = input.parentSessionId ?? process.env[SUBAGENT_PARENT_SESSION_ENV] ?? \"\";\n\n\treturn {\n\t\targs,\n\t\tenv,\n\t\ttempDir,\n\t\ttoolDiagnosticPath,\n\t\truntimeAcknowledgedExtensionsPath,\n\t\tcapabilityAudit: toolPlan.capabilityAudit,\n\t};\n}\n\nexport const parseParentPathEnv = parseNestedPathEnv;\n\nexport function cleanupTempDir(tempDir: string | null | undefined): void {\n\tif (!tempDir) return;\n\ttry {\n\t\tfs.rmSync(tempDir, { recursive: true, force: true });\n\t} catch {\n\t\t// Temp cleanup is best effort.\n\t}\n}\n"]}