@agimon-ai/doompi-team 0.0.1-alpha.77 → 0.0.1-alpha.78
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.
|
@@ -498,7 +498,7 @@ var SpawnPlanner = class {
|
|
|
498
498
|
systemPromptMode: agentConfig.systemPromptMode,
|
|
499
499
|
...agentConfig.extensions ? { extensions: agentConfig.extensions } : {},
|
|
500
500
|
...agentConfig.subagentOnlyExtensions ? { subagentOnlyExtensions: agentConfig.subagentOnlyExtensions } : {},
|
|
501
|
-
...agentConfig.tools ? { tools: agentConfig.tools } : {},
|
|
501
|
+
...agentConfig.tools ? { tools: [.../* @__PURE__ */ new Set([...agentConfig.tools, ...capabilityCeiling?.requiredTools ?? []])] } : {},
|
|
502
502
|
...excludeTools ? { excludeTools } : {},
|
|
503
503
|
...agentConfig.skills ? { skills: agentConfig.skills } : {},
|
|
504
504
|
...agentConfig.mcpDirectTools ? { mcpDirectTools: agentConfig.mcpDirectTools } : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fs","isPiRuntime","selectAvailableModel","SubagentCapabilityPolicyStore","DoomTeamExpectedError","resolveActiveTeamPackageConfig","resolveActiveTeamModelSpecs","path","canonicalizeDiscoveryCwd","buildSkillInjection","resolveCurrentSubagentDepth","preflightSubagentDepth","claimAgentIdentity","roleFromAgent","resolveRuntimeTable","resolveRuntimeLaunch","runWithConcurrency"],"sources":["../../../../src/services/spawnPlan/index.ts"],"sourcesContent":["/**\n * Turns `subagent` tool params into a resolved sequence of\n * `AsyncSubagentSpawner.spawn()` calls: SINGLE (one child), PARALLEL (N\n * children, bounded by `concurrency`).\n *\n * WHY THIS IS NEW LOGIC, NOT COMPOSITION:\n * `AsyncSubagentSpawner` is deliberately a per-child primitive -\n * `childIndex`/`fanout` arrive as inputs it does not derive (see that\n * module's header). Nothing else in this package decides \"how many\n * children, in what order, at what `childIndex`\" from a `subagent` tool\n * call. That decision is this file's job.\n *\n * PREFLIGHT, ALL-OR-NOTHING:\n * `resolveCurrentSubagentDepth`/`preflightSubagentDepth` run once, before\n * anything spawns. A depth refusal throws - a declared plan that cannot run\n * at all should produce one clear refusal, not a partial fan-out.\n * `AgentDiscoveryService.find` resolves and validates every child's agent\n * name up front too, for the same reason: a typo'd agent name is a\n * preflight failure named at the tool boundary, not a spawn error surfacing\n * deep inside one child while its siblings are already running.\n *\n * ONCE THE BATCH HAS STARTED, PER-CHILD FAILURE IS A RESULT, NOT AN\n * EXCEPTION:\n * `runWithConcurrency` never lets one child's rejection abort its siblings,\n * matching `failFast` being opt-in in the schema, not the default. Every\n * child gets an outcome - `{runId, pid}` on success, `{error}` on failure -\n * and the caller (`subagentTool.ts`) decides how to report a mixed batch.\n *\n * WHAT THIS DOES NOT WIRE YET, AND WHY - FLAGGED, NOT SILENTLY GUESSED:\n * - `maxSubagentSpawnsPerSession` (`spawn-budget.ts`) is NOT enforced here.\n * `preflightSpawnBudget` needs a durable, session-scoped `SpawnBudgetStore`\n * that accumulates spend ACROSS separate tool calls in the same session;\n * inventing a fresh store per call would never track real spend and would\n * be worse than not checking at all (false confidence). Wiring this needs\n * a real session-scoped store owned by a lifecycle-bound service - a\n * follow-up, not guessed here.\n * - Fork context is resolved here and requires a captured persisted Pi source;\n * unavailable or non-Pi fork requests fail closed rather than becoming fresh\n * launches.\n * - Per-task overrides with no direct `BuildPiArgsInput` field confirmed yet\n * (`skill`, `toolBudget`, `turnBudget`, `outputSchema`/structured output,\n * `acceptance`, `output`/`outputMode`) are not mapped into `piArgs` for\n * v1. Each child still gets its resolved `AgentConfig`'s own defaults\n * (`systemPromptMode`, `inheritProjectContext`, `inheritSkills`,\n * `systemPrompt`) - not nothing, just not every param override yet.\n *\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type {\n DoomChildSessionScope,\n DoomChildSessionSource,\n DoomChildSessionServiceProvider,\n DoomChildSessionTerminalPiForkSource,\n DoomChildSessionV4ForkSource,\n} from '@agimon-ai/doompi-core/child';\nimport type { SessionManager } from '@earendil-works/pi-coding-agent';\n\nimport type { InlineAgent } from '../../schemas/subagentTool';\nimport {\n type ResolvedSubagentCapabilityCeiling,\n SubagentCapabilityPolicyStore,\n} from '../../schemas/team/capabilityCeiling';\nimport type { AgentConfig, AgentScope, AgentDiscoveryContract } from '../../types/agent';\nimport { PI_RUNTIME_NAME } from '../../types/environment';\nimport { type AdmissionGateContract, type AdmissionTicket, DEFAULT_ADMISSION_TIMEOUT_MS } from '../admissionGate';\nimport { resolveActiveTeamModelSpecs, resolveActiveTeamPackageConfig } from '../agentDiscovery';\nimport { adoptAgentIdentity, type AgentIdentity, claimAgentIdentity, roleFromAgent } from '../agentIdentity';\nimport { canonicalizeDiscoveryCwd } from '../agentProjectRoot';\nimport { buildSkillInjection, type SkillDiscoveryContract } from '../agentSkills';\nimport type {\n AsyncSubagentSpawnInput,\n AsyncSubagentSpawnResult,\n AsyncSubagentSpawnerContract,\n} from '../asyncExecution';\nimport type { ExtensionConfig } from '../config';\nimport { preflightSubagentDepth, resolveCurrentSubagentDepth } from '../depthGuard';\nimport { DoomTeamExpectedError } from '../errors';\nimport type { McpDirectToolResolver } from '../mcpDirectToolAllowlist';\nimport { type AvailableModelInfo, type ParentModel, selectAvailableModel } from '../modelFallback';\nimport type { NativeRunCoordinatorContract } from '../nativeRunCoordinator';\nimport type { NativeTeamChannelContract } from '../nativeTeamChannel';\nimport { isPiRuntime, type RuntimeTable, resolveRuntimeLaunch, resolveRuntimeTable } from '../runtimeRegistry';\nimport { type ConcurrencyEventReporter, runWithConcurrency } from '../runWithConcurrency';\n\nconst CONTEXT_FRESH = 'fresh' as const;\nconst CONTEXT_FORK = 'fork' as const;\nconst PI_RUNTIME_REQUIREMENT = `runtime \"${PI_RUNTIME_NAME}\"`;\n\ntype SessionForkCaptureMode = 'tool' | 'settled';\n\nexport interface SessionForkSource {\n readonly sessionFile?: string;\n readonly leafId: string;\n readonly terminalSource: DoomChildSessionTerminalPiForkSource;\n}\n\nexport type SessionForkSourceManager = Pick<\n SessionManager,\n 'getSessionFile' | 'getSessionId' | 'getLeafId' | 'getLeafEntry' | 'getHeader' | 'getBranch'\n>;\n\nfunction readableSessionFile(sessionFile: string | undefined): sessionFile is string {\n if (!sessionFile?.trim()) return false;\n try {\n fs.accessSync(sessionFile, fs.constants.R_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Why a capture reports a reason instead of a bare `undefined`.\n *\n * Five distinct conditions used to collapse into one `undefined`, and the\n * caller then asserted a cause it had never tested. That is how a missing\n * `captureForkSource` on the headless facet spent a long time looking like a\n * session-format problem. The reason is carried to the throw site so the error\n * names the condition that actually fired.\n */\nexport type ForkCaptureFailure = 'no-leaf' | 'no-header' | 'unsupported-version' | 'branch-mismatch' | 'no-session-id';\n\nexport type ForkCaptureResult =\n | { readonly ok: true; readonly source: SessionForkSource }\n | { readonly ok: false; readonly reason: ForkCaptureFailure };\n\n/** Either host's capture output, plus the absent case when no capture is installed. */\nexport type ParentForkCapture = ForkCaptureResult | DoomChildSessionV4ForkSource | undefined;\n\nconst FORK_FAILURE_TEXT: Record<ForkCaptureFailure | 'no-capture-installed', string> = {\n 'no-capture-installed': 'this host installed no fork-source capture',\n 'no-leaf': 'the parent session has no entry to branch from',\n 'no-header': 'the parent session has no readable header',\n 'unsupported-version': 'the parent session format cannot be forked',\n 'branch-mismatch': 'the parent branch did not resolve to its own leaf',\n 'no-session-id': 'the parent session has no identity',\n};\n\nexport function describeForkFailure(reason: ForkCaptureFailure | 'no-capture-installed' | undefined): string {\n return reason ? FORK_FAILURE_TEXT[reason] : 'the parent session has no capturable branch';\n}\n\n/**\n * Map a captured parent branch onto the spawn request's fork fields.\n *\n * `parentSessionFile` and `parentLeafId` describe a terminal Pi capture only. A\n * v4 source already carries its own file and branch, so flattening it into\n * those fields would describe it in the wrong vocabulary and lose the branch.\n */\nexport function forkRequestFields(\n captured: ParentForkCapture,\n): Pick<SpawnPlanRequest, 'parentForkSource' | 'parentSessionFile' | 'parentLeafId' | 'parentForkFailure'> {\n if (!captured) return { parentForkFailure: 'no-capture-installed' };\n if ('kind' in captured) return { parentForkSource: captured };\n if (!captured.ok) return { parentForkFailure: captured.reason };\n const { source } = captured;\n return {\n parentForkSource: source.terminalSource,\n ...(source.sessionFile ? { parentSessionFile: source.sessionFile } : {}),\n parentLeafId: source.leafId,\n };\n}\n\n/** Capture an immutable parent branch while excluding an assistant turn whose tool is still executing. */\nexport function captureSessionForkSource(\n manager: SessionForkSourceManager,\n mode: SessionForkCaptureMode,\n): ForkCaptureResult {\n const leaf = manager.getLeafEntry();\n const leafId =\n mode === 'tool' && leaf?.type === 'message' && leaf.message.role === 'assistant'\n ? leaf.parentId\n : (leaf?.id ?? manager.getLeafId());\n const header = manager.getHeader();\n if (!leafId) return { ok: false, reason: 'no-leaf' };\n if (header?.type !== 'session') return { ok: false, reason: 'no-header' };\n if (header.version !== 3) return { ok: false, reason: 'unsupported-version' };\n\n const branch = manager.getBranch(leafId);\n if (branch.at(-1)?.id !== leafId) return { ok: false, reason: 'branch-mismatch' };\n const sourceSessionId = manager.getSessionId();\n if (!sourceSessionId.trim()) return { ok: false, reason: 'no-session-id' };\n const terminalSource: DoomChildSessionTerminalPiForkSource = Object.freeze({\n kind: 'terminal-pi-fork',\n sourceSessionId,\n sourceLeafId: leafId,\n snapshotJsonl: `${[header, ...branch].map((record) => JSON.stringify(record)).join('\\n')}\\n`,\n });\n const sessionFile = manager.getSessionFile();\n return {\n ok: true,\n source: {\n leafId,\n terminalSource,\n ...(readableSessionFile(sessionFile) ? { sessionFile } : {}),\n },\n };\n}\n\nexport interface SpawnPlanTaskInput {\n agent: string;\n inlineAgent?: InlineAgent;\n task?: string;\n cwd?: string;\n model?: string;\n runtime?: string;\n context?: typeof CONTEXT_FRESH | typeof CONTEXT_FORK;\n /** An existing child transcript to continue instead of starting fresh. */\n sessionFile?: string;\n /** An identity inherited by a restore. Absent for a fresh run, which mints one. */\n identity?: string;\n}\n\ntype ExecutableAgentConfig = Pick<\n AgentConfig,\n | 'name'\n | 'defaultContext'\n | 'defaultReads'\n | 'extensions'\n | 'fallbackModels'\n | 'inheritProjectContext'\n | 'inheritSkills'\n | 'mcpDirectTools'\n | 'model'\n | 'modelSource'\n | 'runtime'\n | 'skills'\n | 'skillPath'\n | 'subagentOnlyExtensions'\n | 'systemPrompt'\n | 'systemPromptMode'\n | 'thinking'\n | 'tools'\n>;\n\nfunction resolveEffectiveContext(\n taskInput: SpawnPlanTaskInput,\n agent: Pick<ExecutableAgentConfig, 'defaultContext'>,\n): typeof CONTEXT_FRESH | typeof CONTEXT_FORK {\n return taskInput.sessionFile ? CONTEXT_FRESH : (taskInput.context ?? agent.defaultContext ?? CONTEXT_FRESH);\n}\n\nexport interface SpawnPlanRequest {\n /** SINGLE mode: exactly one child. Mutually exclusive with `tasks`. */\n single?: SpawnPlanTaskInput;\n /** PARALLEL mode: N children, fanned out. Mutually exclusive with `single`. */\n tasks?: SpawnPlanTaskInput[];\n /** Max children in flight at once for PARALLEL mode. Ignored for SINGLE. Defaults to `config.parallel.concurrency` or 4. */\n concurrency?: number;\n /** Fallback cwd for any task that omits its own. */\n cwd: string;\n agentScope: AgentScope;\n /** Explicit owner scope forwarded to every child runtime. */\n sessionScope: DoomChildSessionScope;\n /** Environment admitted to this parent session, forwarded only to native children. */\n environment?: Readonly<Record<string, string | undefined>>;\n /** Parent identity retained for delegation correlation. */\n parentSessionId?: string;\n /** Immutable parent branch used by native fork children. */\n parentForkSource?: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource;\n /** Why no parent branch was captured, so a refused fork can name its cause. */\n parentForkFailure?: ForkCaptureFailure | 'no-capture-installed';\n /** External-runtime parent source fields. */\n parentSessionFile?: string;\n parentLeafId?: string;\n artifacts?: boolean;\n /** Authenticated models reported by the live parent host. Undefined for callers without a host context. */\n availableModels?: AvailableModelInfo[];\n /** The live parent model, forwarded only for Pi child selection. */\n parentModel?: ParentModel;\n /** Overrides `resolveCurrentSubagentDepth()`'s own env read - a test seam, not a runtime path. */\n currentDepth?: number;\n /** Which runtime executes every child of this request. Defaults per agent, then to `pi`. */\n runtime?: string;\n /** Stable Pi tool-call identity used to correlate this batch. */\n operationId?: string;\n /** Run ids persisted by the operation journal before any process starts. */\n preallocatedRunIds?: string[];\n}\n\n/** Everything one child spawn needs. An object because this reached ten positional parameters. */\ninterface SpawnOneChildInput {\n runId: string;\n operationId?: string;\n agentConfig: ExecutableAgentConfig;\n identity: AgentIdentity;\n excludeTools?: string[];\n teamPackageModels?: string[];\n capabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n taskInput: SpawnPlanTaskInput;\n childIndex: number;\n fanout: boolean;\n fallbackCwd: string;\n parentSessionId: string | undefined;\n parentForkSource: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource | undefined;\n sessionScope: DoomChildSessionScope;\n environment: Readonly<Record<string, string | undefined>>;\n parentSessionFile: string | undefined;\n maxLiveRuns: number;\n admissionTimeoutMs: number;\n handshakeTimeoutMs: number | undefined;\n artifacts: boolean | undefined;\n artifactDir: ExtensionConfig['artifactDir'];\n availableModels: AvailableModelInfo[] | undefined;\n parentModel: ParentModel | undefined;\n runtime: string | undefined;\n runtimes: RuntimeTable;\n skillProjectionCache: Map<string, ChildSkillProjection>;\n}\n\nexport interface SpawnPlanChildOutcome {\n agent: string;\n task: string;\n /** This spawn's position among its siblings. Always 0 for SINGLE mode. */\n childIndex: number;\n runId?: string;\n /** The generated addressable identity, for example `alan-reviewer-3`. */\n identity?: string;\n /** True when this run came from a one-shot inline agent definition. */\n inline?: boolean;\n pid?: number;\n error?: string;\n warning?: string;\n}\n\nexport interface SpawnPlanResult {\n outcomes: SpawnPlanChildOutcome[];\n}\n\nconst DEFAULT_PARALLEL_CONCURRENCY = 4;\n/**\n * Hard ceiling on how many children one PARALLEL call may DECLARE.\n *\n * `concurrency` does NOT bound this, and cannot: `spawnOneChild` resolves as\n * soon as its child confirms it started, and the child then runs detached. So\n * `runWithConcurrency` throttles how fast children are STARTED, not how many\n * are running - `{tasks: [8], concurrency: 4}` ends up with eight live model\n * processes, not four. 8 matches the sibling implementation's\n * `PI_TEAM_MATE_MAX_PARALLEL`.\n *\n * This is a per-call declaration limit and nothing more. What actually bounds\n * live children across concurrent calls is `AdmissionGate`\n * (`runs/shared/admissionGate.ts`), which every spawn passes through.\n */\nconst DEFAULT_PARALLEL_MAX_TASKS = 8;\n/**\n * Process-wide ceiling on children ALIVE at once.\n *\n * Defaulted to `DEFAULT_PARALLEL_MAX_TASKS` so a single call's width is\n * exactly what it was before the gate existed; the only behaviour that\n * changes is that a second overlapping call now queues instead of stacking\n * another full batch on the machine. Raise or lower it with\n * `parallel.maxLiveRuns` in the subagent config, and bound the queue wait with\n * `parallel.admissionTimeoutMs`. It is deliberately NOT derived from the host's\n * cores or memory: a number measured on one machine is not a default.\n */\nconst DEFAULT_MAX_LIVE_RUNS = DEFAULT_PARALLEL_MAX_TASKS;\nconst INLINE_AGENT_TOOLS = ['read', 'grep', 'find', 'ls'] as const;\n\nfunction appendPromptSection(prompt: string, section: string): string {\n if (!section) return prompt;\n return prompt ? `${prompt}\\n\\n${section}` : section;\n}\n\nfunction bestEffortRuntimeWarnings(\n runtime: string,\n agentConfig: ExecutableAgentConfig,\n excludeTools: string[] | undefined,\n): string[] {\n if (isPiRuntime(runtime)) return [];\n\n const warnings = [`Runtime '${runtime}' does not load Pi child extensions or hooks; launched best effort.`];\n const unsupportedResources = [\n ...(agentConfig.tools !== undefined || agentConfig.mcpDirectTools?.length ? ['tools'] : []),\n ...(agentConfig.skills?.length || agentConfig.skillPath?.length ? ['skills'] : []),\n ...(agentConfig.extensions !== undefined || agentConfig.subagentOnlyExtensions?.length ? ['extensions'] : []),\n ];\n if (unsupportedResources.length > 0) {\n warnings.push(\n `Doom Team cannot project or enforce configured Pi ${unsupportedResources.join(', ')} on runtime '${runtime}'.`,\n );\n }\n if (agentConfig.skills?.length) {\n warnings.push(`Configured skills were not injected: ${agentConfig.skills.join(', ')}.`);\n }\n if (excludeTools?.length) {\n warnings.push(\n `Runtime '${runtime}' cannot enforce Team package tool exclusions; launched best effort for: ${excludeTools.join(', ')}.`,\n );\n }\n return warnings;\n}\n\ninterface ChildSkillProjection {\n systemPrompt: string;\n requireReadTool: boolean;\n warnings: string[];\n}\n\ninterface ResolvedModelSelection {\n primaryModel: string | undefined;\n fallbackModels: string[];\n model: string | undefined;\n}\n\nfunction resolvedModelSelection(\n taskInput: SpawnPlanTaskInput,\n agentConfig: Pick<ExecutableAgentConfig, 'model' | 'modelSource' | 'fallbackModels'>,\n runtime: string,\n parentModel: ParentModel | undefined,\n availableModels: AvailableModelInfo[] | undefined,\n teamPackageModels: string[] | undefined,\n): ResolvedModelSelection {\n const parentModelId =\n isPiRuntime(runtime) && parentModel && availableModels !== undefined\n ? `${parentModel.provider}/${parentModel.id}`\n : undefined;\n const agentModels = [\n ...(agentConfig.modelSource?.scope === 'package' ? [] : [agentConfig.model]),\n ...(agentConfig.fallbackModels ?? []),\n ];\n const ordered = isPiRuntime(runtime)\n ? [taskInput.model, ...agentModels, ...(teamPackageModels ?? []), parentModelId]\n : [taskInput.model, ...agentModels, ...(teamPackageModels ?? [])];\n const candidates = ordered.filter((candidate): candidate is string => Boolean(candidate?.trim()));\n const [primaryModel, ...fallbackModels] = candidates;\n return {\n primaryModel,\n fallbackModels,\n model: selectAvailableModel(primaryModel, fallbackModels, availableModels),\n };\n}\n\nexport interface SpawnPlannerContract {\n /**\n * Resolves the plan and spawns every child. Throws on any PREFLIGHT\n * failure (bad request shape, depth exceeded, unknown agent) before\n * anything spawns. Never throws for an individual child's spawn failure\n * once the batch has started - that is a `{error}` outcome instead.\n */\n spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult>;\n}\n\nconst ERROR_CODE_AGENT_NOT_FOUND = 'agent_not_found' as const;\nconst ERROR_CODE_INVALID_REQUEST = 'invalid_request' as const;\nconst ERROR_CODE_MODEL_UNAVAILABLE = 'model_unavailable' as const;\nconst ERROR_CODE_OPERATION_CONFLICT = 'operation_conflict' as const;\nconst ERROR_CODE_RUNTIME_UNAVAILABLE = 'runtime_unavailable' as const;\nconst ERROR_CODE_UNSUPPORTED_CONTEXT = 'unsupported_context' as const;\nconst ERROR_CODE_UNSUPPORTED_OPERATION = 'unsupported_operation' as const;\n\nexport class SpawnPlanner implements SpawnPlannerContract {\n constructor(\n private readonly agents: AgentDiscoveryContract,\n private readonly spawner: AsyncSubagentSpawnerContract,\n private readonly policies: SubagentCapabilityPolicyStore = new SubagentCapabilityPolicyStore(),\n private readonly skills?: SkillDiscoveryContract,\n private readonly reportConcurrencyEvent?: ConcurrencyEventReporter,\n _mcpToolResolver?: McpDirectToolResolver,\n private readonly admission?: AdmissionGateContract,\n private readonly childSessions?: DoomChildSessionServiceProvider,\n private readonly nativeRuns?: NativeRunCoordinatorContract,\n private readonly teamChannel?: Pick<NativeTeamChannelContract, 'createNativeChildIntercom'>,\n ) {}\n\n protected generateRunId(): string {\n return crypto.randomUUID();\n }\n\n protected validateCwd(cwd: string): void {\n let stat: fs.Stats;\n try {\n stat = fs.statSync(cwd);\n } catch {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' does not exist.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n if (!stat.isDirectory()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' is not a directory.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n }\n\n protected resolveTeamPackageExcludeTools(): string[] | undefined {\n return resolveActiveTeamPackageConfig()?.config.excludeTools;\n }\n\n protected resolveTeamPackageModels(): string[] | undefined {\n return resolveActiveTeamModelSpecs();\n }\n\n protected executableAvailable(command: string): boolean {\n if (path.isAbsolute(command) || command.includes(path.sep)) {\n try {\n fs.accessSync(command, fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n }\n return (process.env.PATH ?? '')\n .split(path.delimiter)\n .filter(Boolean)\n .some((directory) => {\n try {\n fs.accessSync(path.join(directory, command), fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n });\n }\n\n private resolveTaskList(request: SpawnPlanRequest): SpawnPlanTaskInput[] {\n const hasSingle = request.single !== undefined;\n const hasTasks = request.tasks !== undefined;\n if (hasSingle === hasTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires exactly one of internal single or tasks representations.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n if (hasSingle) return [request.single!];\n if (!request.tasks || request.tasks.length === 0) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires at least one entry in its requests collection.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n return request.tasks;\n }\n\n private resolveAgentOrThrow(name: string, cwd: string, scope: AgentScope) {\n const resolved = this.agents.find(cwd, scope, name);\n if (!resolved) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_AGENT_NOT_FOUND,\n `Unknown agent '${name}'.`,\n false,\n 'Call subagent({\"action\":\"agents\"}) and retry with an exact name.',\n );\n }\n return resolved;\n }\n\n private resolveExecutableAgent(taskInput: SpawnPlanTaskInput, cwd: string, scope: AgentScope): ExecutableAgentConfig {\n if (!taskInput.inlineAgent) return this.resolveAgentOrThrow(taskInput.agent, cwd, scope);\n return {\n name: taskInput.agent.trim(),\n systemPromptMode: 'append',\n inheritProjectContext: true,\n inheritSkills: false,\n systemPrompt: taskInput.inlineAgent.systemPrompt.trim(),\n tools: [...INLINE_AGENT_TOOLS],\n defaultContext: CONTEXT_FRESH,\n runtime: PI_RUNTIME_NAME,\n };\n }\n\n private projectDefaultReads(\n defaultReads: string[] | undefined,\n childCwd: string,\n agentName: string,\n ): ChildSkillProjection {\n if (!defaultReads?.length) return { systemPrompt: '', requireReadTool: false, warnings: [] };\n\n const seen = new Set<string>();\n const readablePaths: string[] = [];\n const missingPaths: string[] = [];\n for (const configuredPath of defaultReads) {\n const trimmed = configuredPath.trim();\n if (!trimmed) continue;\n const resolvedPath = path.isAbsolute(trimmed) ? path.normalize(trimmed) : path.resolve(childCwd, trimmed);\n const identity = canonicalizeDiscoveryCwd(resolvedPath);\n if (seen.has(identity)) continue;\n seen.add(identity);\n try {\n if (fs.statSync(resolvedPath).isFile()) readablePaths.push(resolvedPath);\n else missingPaths.push(resolvedPath);\n } catch {\n missingPaths.push(resolvedPath);\n }\n }\n\n const systemPrompt =\n readablePaths.length > 0\n ? [\n 'Read these configured paths before broad repository discovery:',\n ...readablePaths.map((readPath) => `- ${readPath}`),\n 'If a listed path does not provide enough context, name the concrete missing dependency before searching narrowly for it.',\n ].join('\\n')\n : '';\n return {\n systemPrompt,\n requireReadTool: readablePaths.length > 0,\n warnings:\n missingPaths.length > 0\n ? [`Agent '${agentName}' could not read optional default paths: ${missingPaths.join(', ')}.`]\n : [],\n };\n }\n\n private projectConfiguredSkills(\n agentConfig: ExecutableAgentConfig,\n childCwd: string,\n requestCwd: string,\n runtime: string,\n cache: Map<string, ChildSkillProjection>,\n ): ChildSkillProjection {\n const cacheKey = JSON.stringify([\n canonicalizeDiscoveryCwd(childCwd),\n canonicalizeDiscoveryCwd(requestCwd),\n runtime,\n agentConfig.name,\n agentConfig.systemPrompt,\n agentConfig.skills ?? [],\n agentConfig.skillPath ?? [],\n agentConfig.defaultReads ?? [],\n ]);\n const cached = cache.get(cacheKey);\n if (cached) return cached;\n\n if (!isPiRuntime(runtime)) {\n const projection = { systemPrompt: agentConfig.systemPrompt, requireReadTool: false, warnings: [] };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n const defaultReads = this.projectDefaultReads(agentConfig.defaultReads, childCwd, agentConfig.name);\n let skillInjection = '';\n let skillWarnings: string[] = [];\n if (agentConfig.skills?.length) {\n if (!this.skills) throw new Error('Skill discovery is unavailable for configured child skills.');\n const resolution = this.skills.resolveSkillsWithFallback(\n agentConfig.skills,\n childCwd,\n requestCwd,\n agentConfig.skillPath,\n requestCwd,\n );\n skillInjection = buildSkillInjection(resolution.resolved);\n skillWarnings =\n resolution.missing.length > 0\n ? [\n `Agent '${agentConfig.name}' could not resolve configured skills: ${resolution.missing.join(', ')}; launched with resolved skills only.`,\n ]\n : [];\n }\n\n const projection = {\n systemPrompt: appendPromptSection(\n appendPromptSection(agentConfig.systemPrompt, skillInjection),\n defaultReads.systemPrompt,\n ),\n requireReadTool: skillInjection.length > 0 || defaultReads.requireReadTool,\n warnings: [...skillWarnings, ...defaultReads.warnings],\n };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n /**\n * Spawns exactly one child and returns its outcome. Shared by `spawn()`\n * (SINGLE/PARALLEL) and `spawnChain()`'s per-step/per-parallel-group-child\n * calls, so the `AsyncSubagentSpawnInput` mapping exists in exactly one\n * place. Never throws - a spawn failure becomes an `{error}` outcome, per\n * the \"preflight throws, per-child failure does not\" split documented in\n * the module header.\n */\n private async spawnOneChild(input: SpawnOneChildInput): Promise<SpawnPlanChildOutcome> {\n const {\n runId,\n operationId,\n agentConfig,\n identity,\n capabilityCeiling,\n excludeTools,\n teamPackageModels,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd,\n parentSessionId,\n parentForkSource,\n sessionScope,\n environment,\n parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs,\n artifacts,\n artifactDir,\n availableModels,\n parentModel,\n runtime,\n runtimes,\n skillProjectionCache,\n } = input;\n const cwd = taskInput.cwd ?? fallbackCwd;\n const task = taskInput.task ?? '';\n const effectiveContext = resolveEffectiveContext(taskInput, agentConfig);\n const effectiveRuntime = taskInput.runtime ?? runtime ?? agentConfig.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agentConfig,\n effectiveRuntime,\n parentModel,\n availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && availableModels !== undefined && !modelSelection.model) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: `No authenticated model is available for '${agentConfig.name}'. Checked: ${[\n modelSelection.primaryModel,\n ...modelSelection.fallbackModels,\n ].join(', ')}.`,\n };\n }\n\n let skillProjection: ChildSkillProjection;\n try {\n skillProjection = this.projectConfiguredSkills(\n agentConfig,\n cwd,\n fallbackCwd,\n effectiveRuntime,\n skillProjectionCache,\n );\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n const warnings = [\n ...skillProjection.warnings,\n ...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools),\n ];\n const warning = warnings.length > 0 ? warnings.join(' ') : undefined;\n\n // Persist every Pi child's own transcript so a later explicit restore can\n // continue it. External runtimes retain their existing session behavior.\n const spawnInput: AsyncSubagentSpawnInput = {\n runId,\n ...(operationId ? { operationId } : {}),\n agent: agentConfig.name,\n ...(taskInput.inlineAgent ? { inlineAgent: taskInput.inlineAgent } : {}),\n task,\n cwd,\n environment,\n childIndex,\n fanout,\n sessionScope,\n ...(parentSessionFile ? { parentSessionFile } : {}),\n piArgs: {\n ...(taskInput.sessionFile ? { sessionFile: taskInput.sessionFile } : {}),\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(effectiveContext === CONTEXT_FORK && parentSessionId ? { parentSessionId } : {}),\n },\n ...(handshakeTimeoutMs !== undefined ? { handshakeTimeoutMs } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(artifactDir !== undefined ? { artifactDir } : {}),\n // Per-call `runtime` wins over the agent's own default, matching how\n // `model` and `context` already resolve.\n runtime: effectiveRuntime,\n runtimes,\n };\n\n const admission = this.admission;\n if (!admission) throw new Error('Doom Team spawn admission is not configured.');\n let ticket: AdmissionTicket;\n try {\n ticket = await admission.admit({\n sessionScope,\n maxLiveRuns,\n timeoutMs: admissionTimeoutMs,\n ...(this.reportConcurrencyEvent ? { report: this.reportConcurrencyEvent } : {}),\n });\n } catch (error) {\n return {\n agent: agentConfig.name,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n }\n\n try {\n if (isPiRuntime(effectiveRuntime)) {\n if (!this.nativeRuns || !this.childSessions?.get())\n throw new Error('The native Team run coordinator is unavailable.');\n const scope = sessionScope;\n const source: DoomChildSessionSource = taskInput.sessionFile\n ? { kind: 'v4-restore', sessionFile: taskInput.sessionFile }\n : effectiveContext === CONTEXT_FORK\n ? (parentForkSource ??\n (() => {\n throw new Error('Native fork input requires an immutable terminal Pi snapshot.');\n })())\n : { kind: 'fresh' };\n const intercom = this.teamChannel?.createNativeChildIntercom({\n rootSessionId: scope.rootSessionId,\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n runId,\n childIndex,\n task: { id: runId, subject: task },\n });\n let child: Awaited<ReturnType<NativeRunCoordinatorContract['start']>>;\n try {\n child = await this.nativeRuns.start(\n parentSessionId ?? scope.rootSessionId,\n {\n runId,\n parentSessionId: parentSessionId ?? scope.rootSessionId,\n scope,\n source,\n agent: agentConfig.name,\n task,\n cwd,\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(typeof agentConfig.thinking === 'string' ? { thinking: agentConfig.thinking } : {}),\n ...(skillProjection.systemPrompt ? { systemPrompt: skillProjection.systemPrompt } : {}),\n systemPromptMode: agentConfig.systemPromptMode,\n ...(agentConfig.extensions ? { extensions: agentConfig.extensions } : {}),\n ...(agentConfig.subagentOnlyExtensions\n ? { subagentOnlyExtensions: agentConfig.subagentOnlyExtensions }\n : {}),\n ...(agentConfig.tools ? { tools: agentConfig.tools } : {}),\n ...(excludeTools ? { excludeTools } : {}),\n ...(agentConfig.skills ? { skills: agentConfig.skills } : {}),\n ...(agentConfig.mcpDirectTools ? { mcpDirectTools: agentConfig.mcpDirectTools } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(intercom ? { intercom } : {}),\n environment,\n },\n // Carried beside the core child request rather than inside it, so a\n // Team-only concept does not widen the shared child contract.\n { identity: identity.identity, inline: identity.inline },\n );\n } catch (error) {\n intercom?.dispose?.();\n throw error;\n }\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: child.runId,\n ...(warning ? { warning } : {}),\n };\n }\n const result: AsyncSubagentSpawnResult = await this.spawner.spawn(spawnInput);\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: result.runId,\n pid: result.pid,\n ...(warning ? { warning } : {}),\n };\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n } finally {\n // Once spawn resolves, direct child events make the run visible to the\n // injected live counter, so only the reservation is released here.\n ticket.release();\n }\n }\n\n async spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult> {\n const tasks = this.resolveTaskList(request);\n const fanout = tasks.length > 1;\n const teamPackageExcludeTools = this.resolveTeamPackageExcludeTools();\n const teamPackageModels = this.resolveTeamPackageModels();\n const capabilityCeiling = this.policies.resolve();\n\n // PREFLIGHT - all before any spawn call, so a declared plan that cannot\n // run at all produces one refusal, not a partial fan-out.\n const currentDepth = request.currentDepth ?? resolveCurrentSubagentDepth();\n const depthCheck = preflightSubagentDepth(currentDepth, config);\n if (depthCheck.error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n depthCheck.error,\n false,\n 'Give each child a self-contained task within the Team package policy.',\n );\n }\n\n const maxTasks = config.parallel?.maxTasks ?? DEFAULT_PARALLEL_MAX_TASKS;\n if (tasks.length > maxTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run requested ${tasks.length} tasks, but at most ${maxTasks} may be declared in one call. Concurrency throttles how fast they start, not how many run.`,\n false,\n 'Send at most that many requests in this call and wait for them, or raise parallel.maxTasks in the subagent config. Splitting the same width across extra calls does not raise the live-child ceiling.',\n );\n }\n\n for (const taskInput of tasks) {\n if (!taskInput.task?.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run request for '${taskInput.agent}' requires a nonblank task.`,\n false,\n 'Provide a self-contained nonblank task.',\n );\n }\n if (taskInput.inlineAgent && !taskInput.inlineAgent.systemPrompt.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Inline agent '${taskInput.agent}' requires a nonblank system prompt.`,\n false,\n 'Provide a focused read-only exploration role.',\n );\n }\n }\n\n const resolvedAgentCache = new Map<string, ExecutableAgentConfig>();\n const resolvedAgents = tasks.map((taskInput) => {\n if (taskInput.inlineAgent) {\n return this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n }\n const cacheKey = [\n request.agentScope,\n canonicalizeDiscoveryCwd(taskInput.cwd ?? request.cwd),\n taskInput.agent,\n ].join('\\0');\n const cached = resolvedAgentCache.get(cacheKey);\n if (cached) return cached;\n const resolved = this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n resolvedAgentCache.set(cacheKey, resolved);\n return resolved;\n });\n for (const [index, taskInput] of tasks.entries()) {\n const effectiveContext = resolveEffectiveContext(taskInput, resolvedAgents[index]!);\n const runtime = taskInput.runtime ?? request.runtime ?? resolvedAgents[index]!.runtime ?? PI_RUNTIME_NAME;\n if (effectiveContext === CONTEXT_FORK) {\n if (!isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context requires ${PI_RUNTIME_REQUIREMENT} for '${taskInput.agent}'.`,\n false,\n 'Use a Pi agent for fork context or explicitly request a fresh run.',\n );\n }\n if (!request.parentForkSource) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context is unavailable for '${taskInput.agent}': ${describeForkFailure(request.parentForkFailure)}.`,\n false,\n 'Use an active Pi session with a completed parent turn or explicitly request a fresh run.',\n );\n }\n }\n }\n\n if (request.preallocatedRunIds && request.preallocatedRunIds.length !== tasks.length) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_OPERATION_CONFLICT,\n 'The operation journal run-id count does not match the request count.',\n false,\n 'Submit the run as a new tool call.',\n );\n }\n const runIds = request.preallocatedRunIds ?? tasks.map(() => this.generateRunId());\n // Minted here because this is the one funnel every spawn path reaches, and\n // because the inline flag and the resolved agent name are both in hand. A\n // restore carries its identity in, and repoints the existing claim rather\n // than burning a second number on the same logical agent.\n const identities = tasks.map((taskInput, index) => {\n const inline = taskInput.inlineAgent !== undefined;\n if (!taskInput.identity) {\n return claimAgentIdentity(request.sessionScope, {\n agent: resolvedAgents[index]!.name,\n inline,\n runId: runIds[index]!,\n });\n }\n adoptAgentIdentity(request.sessionScope, taskInput.identity, runIds[index]!);\n return {\n identity: taskInput.identity,\n name: '',\n role: roleFromAgent(resolvedAgents[index]!.name),\n number: 0,\n inline,\n persisted: true,\n };\n });\n const runtimes = resolveRuntimeTable(config.runtimes);\n for (const [index, taskInput] of tasks.entries()) {\n const agent = resolvedAgents[index]!;\n const cwd = taskInput.cwd ?? request.cwd;\n this.validateCwd(cwd);\n const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agent,\n runtime,\n request.parentModel,\n request.availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && request.availableModels !== undefined && !modelSelection.model) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_MODEL_UNAVAILABLE,\n `No authenticated model is available for '${agent.name}'.`,\n false,\n 'Authenticate the requested model or choose an available model.',\n );\n }\n if (taskInput.inlineAgent && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Inline agent '${taskInput.agent}' requires ${PI_RUNTIME_REQUIREMENT} to enforce its read-only tools.`,\n false,\n 'Remove the runtime override or use a discovered external-runtime agent without inlineAgent.',\n );\n }\n if (capabilityCeiling && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Runtime '${runtime}' cannot enforce the active capability ceiling.`,\n false,\n `Use ${PI_RUNTIME_REQUIREMENT} while plan mode or another capability ceiling is active.`,\n );\n }\n if (!isPiRuntime(runtime)) {\n let command: string;\n try {\n command = resolveRuntimeLaunch(runtime, runtimes, { prompt: taskInput.task ?? '', cwd }).command;\n } catch (error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n error instanceof Error ? error.message : String(error),\n false,\n `Configure a valid external runtime or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n if (!this.executableAvailable(command)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n `Executable '${command}' for runtime '${runtime}' is unavailable.`,\n false,\n `Install the executable, configure its absolute path, or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n }\n }\n const concurrency = fanout\n ? (request.concurrency ?? config.parallel?.concurrency ?? DEFAULT_PARALLEL_CONCURRENCY)\n : 1;\n const maxLiveRuns = Math.max(1, config.parallel?.maxLiveRuns ?? DEFAULT_MAX_LIVE_RUNS);\n const admissionTimeoutMs = config.parallel?.admissionTimeoutMs ?? DEFAULT_ADMISSION_TIMEOUT_MS;\n\n const skillProjectionCache = new Map<string, ChildSkillProjection>();\n const factories = tasks.map(\n (taskInput, childIndex) => () =>\n this.spawnOneChild({\n runId: runIds[childIndex]!,\n operationId: request.operationId,\n agentConfig: resolvedAgents[childIndex]!,\n identity: identities[childIndex]!,\n excludeTools: teamPackageExcludeTools,\n teamPackageModels,\n capabilityCeiling,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd: request.cwd,\n parentSessionId: request.parentSessionId,\n parentForkSource: request.parentForkSource,\n sessionScope: request.sessionScope,\n environment: request.environment ?? {},\n parentSessionFile: request.parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs: config.handshakeTimeoutMs,\n artifacts: request.artifacts,\n artifactDir: config.artifactDir,\n availableModels: request.availableModels,\n parentModel: request.parentModel,\n runtime: request.runtime,\n runtimes,\n skillProjectionCache,\n }),\n );\n\n const settled = await runWithConcurrency(factories, concurrency, this.reportConcurrencyEvent);\n // `spawnOneChild` never rejects (it catches its own spawn failure into\n // an `{error}` outcome), so `runWithConcurrency` never sees a rejection\n // here - this unwrap is defensive, not a real branch.\n const outcomes = settled.map((outcome, index) =>\n outcome.status === 'fulfilled'\n ? outcome.value\n : {\n agent: resolvedAgents[index]!.name,\n identity: identities[index]!.identity,\n inline: identities[index]!.inline,\n task: tasks[index]!.task ?? '',\n childIndex: index,\n error: outcome.reason instanceof Error ? outcome.reason.message : String(outcome.reason),\n },\n );\n\n return { outcomes };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAe/B,SAAS,oBAAoB,aAAwD;CACnF,IAAI,CAAC,aAAa,KAAK,GAAG,OAAO;CACjC,IAAI;EACF,QAAG,WAAW,aAAaA,QAAG,UAAU,IAAI;EAC5C,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAoBA,MAAM,oBAAiF;CACrF,wBAAwB;CACxB,WAAW;CACX,aAAa;CACb,uBAAuB;CACvB,mBAAmB;CACnB,iBAAiB;AACnB;AAEA,SAAgB,oBAAoB,QAAyE;CAC3G,OAAO,SAAS,kBAAkB,UAAU;AAC9C;;;;;;;;AASA,SAAgB,kBACd,UACyG;CACzG,IAAI,CAAC,UAAU,OAAO,EAAE,mBAAmB,uBAAuB;CAClE,IAAI,UAAU,UAAU,OAAO,EAAE,kBAAk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EACF;EACA,MAAM,cAAc,SACf,QAAQ,eAAe,OAAO,UAAU,eAAe,+BACxD;EACJ,MAAM,cAAc,KAAK,IAAI,GAAG,OAAO,UAAU,eAAe,qBAAqB;EACrF,MAAM,qBAAqB,OAAO,UAAU,sBAAA;EAE5C,MAAM,uCAAuB,IAAI,IAAkC;EACnE,MAAM,YAAY,MAAM,KACrB,WAAW,qBACV,KAAK,cAAc;GACjB,OAAO,OAAO;GACd,aAAa,QAAQ;GACrB,aAAa,eAAe;GAC5B,UAAU,WAAW;GACrB,cAAc;GACd;GACA;GACA;GACA;GACA;GACA,aAAa,QAAQ;GACrB,iBAAiB,QAAQ;GACzB,kBAAkB,QAAQ;GAC1B,cAAc,QAAQ;GACtB,aAAa,QAAQ,eAAe,CAAC;GACrC,mBAAmB,QAAQ;GAC3B;GACA;GACA,oBAAoB,OAAO;GAC3B,WAAW,QAAQ;GACnB,aAAa,OAAO;GACpB,iBAAiB,QAAQ;GACzB,aAAa,QAAQ;GACrB,SAAS,QAAQ;GACjB;GACA;EACF,CAAC,CACL;EAmBA,OAAO,EAAE,WAbQ,MAJKY,gBAAAA,mBAAmB,WAAW,aAAa,KAAK,sBAAsB,EAAA,CAInE,KAAK,SAAS,UACrC,QAAQ,WAAW,cACf,QAAQ,QACR;GACE,OAAO,eAAe,MAAM,CAAE;GAC9B,UAAU,WAAW,MAAM,CAAE;GAC7B,QAAQ,WAAW,MAAM,CAAE;GAC3B,MAAM,MAAM,MAAM,CAAE,QAAQ;GAC5B,YAAY;GACZ,OAAO,QAAQ,kBAAkB,QAAQ,QAAQ,OAAO,UAAU,OAAO,QAAQ,MAAM;EACzF,CAGU,EAAE;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fs","isPiRuntime","selectAvailableModel","SubagentCapabilityPolicyStore","DoomTeamExpectedError","resolveActiveTeamPackageConfig","resolveActiveTeamModelSpecs","path","canonicalizeDiscoveryCwd","buildSkillInjection","resolveCurrentSubagentDepth","preflightSubagentDepth","claimAgentIdentity","roleFromAgent","resolveRuntimeTable","resolveRuntimeLaunch","runWithConcurrency"],"sources":["../../../../src/services/spawnPlan/index.ts"],"sourcesContent":["/**\n * Turns `subagent` tool params into a resolved sequence of\n * `AsyncSubagentSpawner.spawn()` calls: SINGLE (one child), PARALLEL (N\n * children, bounded by `concurrency`).\n *\n * WHY THIS IS NEW LOGIC, NOT COMPOSITION:\n * `AsyncSubagentSpawner` is deliberately a per-child primitive -\n * `childIndex`/`fanout` arrive as inputs it does not derive (see that\n * module's header). Nothing else in this package decides \"how many\n * children, in what order, at what `childIndex`\" from a `subagent` tool\n * call. That decision is this file's job.\n *\n * PREFLIGHT, ALL-OR-NOTHING:\n * `resolveCurrentSubagentDepth`/`preflightSubagentDepth` run once, before\n * anything spawns. A depth refusal throws - a declared plan that cannot run\n * at all should produce one clear refusal, not a partial fan-out.\n * `AgentDiscoveryService.find` resolves and validates every child's agent\n * name up front too, for the same reason: a typo'd agent name is a\n * preflight failure named at the tool boundary, not a spawn error surfacing\n * deep inside one child while its siblings are already running.\n *\n * ONCE THE BATCH HAS STARTED, PER-CHILD FAILURE IS A RESULT, NOT AN\n * EXCEPTION:\n * `runWithConcurrency` never lets one child's rejection abort its siblings,\n * matching `failFast` being opt-in in the schema, not the default. Every\n * child gets an outcome - `{runId, pid}` on success, `{error}` on failure -\n * and the caller (`subagentTool.ts`) decides how to report a mixed batch.\n *\n * WHAT THIS DOES NOT WIRE YET, AND WHY - FLAGGED, NOT SILENTLY GUESSED:\n * - `maxSubagentSpawnsPerSession` (`spawn-budget.ts`) is NOT enforced here.\n * `preflightSpawnBudget` needs a durable, session-scoped `SpawnBudgetStore`\n * that accumulates spend ACROSS separate tool calls in the same session;\n * inventing a fresh store per call would never track real spend and would\n * be worse than not checking at all (false confidence). Wiring this needs\n * a real session-scoped store owned by a lifecycle-bound service - a\n * follow-up, not guessed here.\n * - Fork context is resolved here and requires a captured persisted Pi source;\n * unavailable or non-Pi fork requests fail closed rather than becoming fresh\n * launches.\n * - Per-task overrides with no direct `BuildPiArgsInput` field confirmed yet\n * (`skill`, `toolBudget`, `turnBudget`, `outputSchema`/structured output,\n * `acceptance`, `output`/`outputMode`) are not mapped into `piArgs` for\n * v1. Each child still gets its resolved `AgentConfig`'s own defaults\n * (`systemPromptMode`, `inheritProjectContext`, `inheritSkills`,\n * `systemPrompt`) - not nothing, just not every param override yet.\n *\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type {\n DoomChildSessionScope,\n DoomChildSessionSource,\n DoomChildSessionServiceProvider,\n DoomChildSessionTerminalPiForkSource,\n DoomChildSessionV4ForkSource,\n} from '@agimon-ai/doompi-core/child';\nimport type { SessionManager } from '@earendil-works/pi-coding-agent';\n\nimport type { InlineAgent } from '../../schemas/subagentTool';\nimport {\n type ResolvedSubagentCapabilityCeiling,\n SubagentCapabilityPolicyStore,\n} from '../../schemas/team/capabilityCeiling';\nimport type { AgentConfig, AgentScope, AgentDiscoveryContract } from '../../types/agent';\nimport { PI_RUNTIME_NAME } from '../../types/environment';\nimport { type AdmissionGateContract, type AdmissionTicket, DEFAULT_ADMISSION_TIMEOUT_MS } from '../admissionGate';\nimport { resolveActiveTeamModelSpecs, resolveActiveTeamPackageConfig } from '../agentDiscovery';\nimport { adoptAgentIdentity, type AgentIdentity, claimAgentIdentity, roleFromAgent } from '../agentIdentity';\nimport { canonicalizeDiscoveryCwd } from '../agentProjectRoot';\nimport { buildSkillInjection, type SkillDiscoveryContract } from '../agentSkills';\nimport type {\n AsyncSubagentSpawnInput,\n AsyncSubagentSpawnResult,\n AsyncSubagentSpawnerContract,\n} from '../asyncExecution';\nimport type { ExtensionConfig } from '../config';\nimport { preflightSubagentDepth, resolveCurrentSubagentDepth } from '../depthGuard';\nimport { DoomTeamExpectedError } from '../errors';\nimport type { McpDirectToolResolver } from '../mcpDirectToolAllowlist';\nimport { type AvailableModelInfo, type ParentModel, selectAvailableModel } from '../modelFallback';\nimport type { NativeRunCoordinatorContract } from '../nativeRunCoordinator';\nimport type { NativeTeamChannelContract } from '../nativeTeamChannel';\nimport { isPiRuntime, type RuntimeTable, resolveRuntimeLaunch, resolveRuntimeTable } from '../runtimeRegistry';\nimport { type ConcurrencyEventReporter, runWithConcurrency } from '../runWithConcurrency';\n\nconst CONTEXT_FRESH = 'fresh' as const;\nconst CONTEXT_FORK = 'fork' as const;\nconst PI_RUNTIME_REQUIREMENT = `runtime \"${PI_RUNTIME_NAME}\"`;\n\ntype SessionForkCaptureMode = 'tool' | 'settled';\n\nexport interface SessionForkSource {\n readonly sessionFile?: string;\n readonly leafId: string;\n readonly terminalSource: DoomChildSessionTerminalPiForkSource;\n}\n\nexport type SessionForkSourceManager = Pick<\n SessionManager,\n 'getSessionFile' | 'getSessionId' | 'getLeafId' | 'getLeafEntry' | 'getHeader' | 'getBranch'\n>;\n\nfunction readableSessionFile(sessionFile: string | undefined): sessionFile is string {\n if (!sessionFile?.trim()) return false;\n try {\n fs.accessSync(sessionFile, fs.constants.R_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Why a capture reports a reason instead of a bare `undefined`.\n *\n * Five distinct conditions used to collapse into one `undefined`, and the\n * caller then asserted a cause it had never tested. That is how a missing\n * `captureForkSource` on the headless facet spent a long time looking like a\n * session-format problem. The reason is carried to the throw site so the error\n * names the condition that actually fired.\n */\nexport type ForkCaptureFailure = 'no-leaf' | 'no-header' | 'unsupported-version' | 'branch-mismatch' | 'no-session-id';\n\nexport type ForkCaptureResult =\n | { readonly ok: true; readonly source: SessionForkSource }\n | { readonly ok: false; readonly reason: ForkCaptureFailure };\n\n/** Either host's capture output, plus the absent case when no capture is installed. */\nexport type ParentForkCapture = ForkCaptureResult | DoomChildSessionV4ForkSource | undefined;\n\nconst FORK_FAILURE_TEXT: Record<ForkCaptureFailure | 'no-capture-installed', string> = {\n 'no-capture-installed': 'this host installed no fork-source capture',\n 'no-leaf': 'the parent session has no entry to branch from',\n 'no-header': 'the parent session has no readable header',\n 'unsupported-version': 'the parent session format cannot be forked',\n 'branch-mismatch': 'the parent branch did not resolve to its own leaf',\n 'no-session-id': 'the parent session has no identity',\n};\n\nexport function describeForkFailure(reason: ForkCaptureFailure | 'no-capture-installed' | undefined): string {\n return reason ? FORK_FAILURE_TEXT[reason] : 'the parent session has no capturable branch';\n}\n\n/**\n * Map a captured parent branch onto the spawn request's fork fields.\n *\n * `parentSessionFile` and `parentLeafId` describe a terminal Pi capture only. A\n * v4 source already carries its own file and branch, so flattening it into\n * those fields would describe it in the wrong vocabulary and lose the branch.\n */\nexport function forkRequestFields(\n captured: ParentForkCapture,\n): Pick<SpawnPlanRequest, 'parentForkSource' | 'parentSessionFile' | 'parentLeafId' | 'parentForkFailure'> {\n if (!captured) return { parentForkFailure: 'no-capture-installed' };\n if ('kind' in captured) return { parentForkSource: captured };\n if (!captured.ok) return { parentForkFailure: captured.reason };\n const { source } = captured;\n return {\n parentForkSource: source.terminalSource,\n ...(source.sessionFile ? { parentSessionFile: source.sessionFile } : {}),\n parentLeafId: source.leafId,\n };\n}\n\n/** Capture an immutable parent branch while excluding an assistant turn whose tool is still executing. */\nexport function captureSessionForkSource(\n manager: SessionForkSourceManager,\n mode: SessionForkCaptureMode,\n): ForkCaptureResult {\n const leaf = manager.getLeafEntry();\n const leafId =\n mode === 'tool' && leaf?.type === 'message' && leaf.message.role === 'assistant'\n ? leaf.parentId\n : (leaf?.id ?? manager.getLeafId());\n const header = manager.getHeader();\n if (!leafId) return { ok: false, reason: 'no-leaf' };\n if (header?.type !== 'session') return { ok: false, reason: 'no-header' };\n if (header.version !== 3) return { ok: false, reason: 'unsupported-version' };\n\n const branch = manager.getBranch(leafId);\n if (branch.at(-1)?.id !== leafId) return { ok: false, reason: 'branch-mismatch' };\n const sourceSessionId = manager.getSessionId();\n if (!sourceSessionId.trim()) return { ok: false, reason: 'no-session-id' };\n const terminalSource: DoomChildSessionTerminalPiForkSource = Object.freeze({\n kind: 'terminal-pi-fork',\n sourceSessionId,\n sourceLeafId: leafId,\n snapshotJsonl: `${[header, ...branch].map((record) => JSON.stringify(record)).join('\\n')}\\n`,\n });\n const sessionFile = manager.getSessionFile();\n return {\n ok: true,\n source: {\n leafId,\n terminalSource,\n ...(readableSessionFile(sessionFile) ? { sessionFile } : {}),\n },\n };\n}\n\nexport interface SpawnPlanTaskInput {\n agent: string;\n inlineAgent?: InlineAgent;\n task?: string;\n cwd?: string;\n model?: string;\n runtime?: string;\n context?: typeof CONTEXT_FRESH | typeof CONTEXT_FORK;\n /** An existing child transcript to continue instead of starting fresh. */\n sessionFile?: string;\n /** An identity inherited by a restore. Absent for a fresh run, which mints one. */\n identity?: string;\n}\n\ntype ExecutableAgentConfig = Pick<\n AgentConfig,\n | 'name'\n | 'defaultContext'\n | 'defaultReads'\n | 'extensions'\n | 'fallbackModels'\n | 'inheritProjectContext'\n | 'inheritSkills'\n | 'mcpDirectTools'\n | 'model'\n | 'modelSource'\n | 'runtime'\n | 'skills'\n | 'skillPath'\n | 'subagentOnlyExtensions'\n | 'systemPrompt'\n | 'systemPromptMode'\n | 'thinking'\n | 'tools'\n>;\n\nfunction resolveEffectiveContext(\n taskInput: SpawnPlanTaskInput,\n agent: Pick<ExecutableAgentConfig, 'defaultContext'>,\n): typeof CONTEXT_FRESH | typeof CONTEXT_FORK {\n return taskInput.sessionFile ? CONTEXT_FRESH : (taskInput.context ?? agent.defaultContext ?? CONTEXT_FRESH);\n}\n\nexport interface SpawnPlanRequest {\n /** SINGLE mode: exactly one child. Mutually exclusive with `tasks`. */\n single?: SpawnPlanTaskInput;\n /** PARALLEL mode: N children, fanned out. Mutually exclusive with `single`. */\n tasks?: SpawnPlanTaskInput[];\n /** Max children in flight at once for PARALLEL mode. Ignored for SINGLE. Defaults to `config.parallel.concurrency` or 4. */\n concurrency?: number;\n /** Fallback cwd for any task that omits its own. */\n cwd: string;\n agentScope: AgentScope;\n /** Explicit owner scope forwarded to every child runtime. */\n sessionScope: DoomChildSessionScope;\n /** Environment admitted to this parent session, forwarded only to native children. */\n environment?: Readonly<Record<string, string | undefined>>;\n /** Parent identity retained for delegation correlation. */\n parentSessionId?: string;\n /** Immutable parent branch used by native fork children. */\n parentForkSource?: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource;\n /** Why no parent branch was captured, so a refused fork can name its cause. */\n parentForkFailure?: ForkCaptureFailure | 'no-capture-installed';\n /** External-runtime parent source fields. */\n parentSessionFile?: string;\n parentLeafId?: string;\n artifacts?: boolean;\n /** Authenticated models reported by the live parent host. Undefined for callers without a host context. */\n availableModels?: AvailableModelInfo[];\n /** The live parent model, forwarded only for Pi child selection. */\n parentModel?: ParentModel;\n /** Overrides `resolveCurrentSubagentDepth()`'s own env read - a test seam, not a runtime path. */\n currentDepth?: number;\n /** Which runtime executes every child of this request. Defaults per agent, then to `pi`. */\n runtime?: string;\n /** Stable Pi tool-call identity used to correlate this batch. */\n operationId?: string;\n /** Run ids persisted by the operation journal before any process starts. */\n preallocatedRunIds?: string[];\n}\n\n/** Everything one child spawn needs. An object because this reached ten positional parameters. */\ninterface SpawnOneChildInput {\n runId: string;\n operationId?: string;\n agentConfig: ExecutableAgentConfig;\n identity: AgentIdentity;\n excludeTools?: string[];\n teamPackageModels?: string[];\n capabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n taskInput: SpawnPlanTaskInput;\n childIndex: number;\n fanout: boolean;\n fallbackCwd: string;\n parentSessionId: string | undefined;\n parentForkSource: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource | undefined;\n sessionScope: DoomChildSessionScope;\n environment: Readonly<Record<string, string | undefined>>;\n parentSessionFile: string | undefined;\n maxLiveRuns: number;\n admissionTimeoutMs: number;\n handshakeTimeoutMs: number | undefined;\n artifacts: boolean | undefined;\n artifactDir: ExtensionConfig['artifactDir'];\n availableModels: AvailableModelInfo[] | undefined;\n parentModel: ParentModel | undefined;\n runtime: string | undefined;\n runtimes: RuntimeTable;\n skillProjectionCache: Map<string, ChildSkillProjection>;\n}\n\nexport interface SpawnPlanChildOutcome {\n agent: string;\n task: string;\n /** This spawn's position among its siblings. Always 0 for SINGLE mode. */\n childIndex: number;\n runId?: string;\n /** The generated addressable identity, for example `alan-reviewer-3`. */\n identity?: string;\n /** True when this run came from a one-shot inline agent definition. */\n inline?: boolean;\n pid?: number;\n error?: string;\n warning?: string;\n}\n\nexport interface SpawnPlanResult {\n outcomes: SpawnPlanChildOutcome[];\n}\n\nconst DEFAULT_PARALLEL_CONCURRENCY = 4;\n/**\n * Hard ceiling on how many children one PARALLEL call may DECLARE.\n *\n * `concurrency` does NOT bound this, and cannot: `spawnOneChild` resolves as\n * soon as its child confirms it started, and the child then runs detached. So\n * `runWithConcurrency` throttles how fast children are STARTED, not how many\n * are running - `{tasks: [8], concurrency: 4}` ends up with eight live model\n * processes, not four. 8 matches the sibling implementation's\n * `PI_TEAM_MATE_MAX_PARALLEL`.\n *\n * This is a per-call declaration limit and nothing more. What actually bounds\n * live children across concurrent calls is `AdmissionGate`\n * (`runs/shared/admissionGate.ts`), which every spawn passes through.\n */\nconst DEFAULT_PARALLEL_MAX_TASKS = 8;\n/**\n * Process-wide ceiling on children ALIVE at once.\n *\n * Defaulted to `DEFAULT_PARALLEL_MAX_TASKS` so a single call's width is\n * exactly what it was before the gate existed; the only behaviour that\n * changes is that a second overlapping call now queues instead of stacking\n * another full batch on the machine. Raise or lower it with\n * `parallel.maxLiveRuns` in the subagent config, and bound the queue wait with\n * `parallel.admissionTimeoutMs`. It is deliberately NOT derived from the host's\n * cores or memory: a number measured on one machine is not a default.\n */\nconst DEFAULT_MAX_LIVE_RUNS = DEFAULT_PARALLEL_MAX_TASKS;\nconst INLINE_AGENT_TOOLS = ['read', 'grep', 'find', 'ls'] as const;\n\nfunction appendPromptSection(prompt: string, section: string): string {\n if (!section) return prompt;\n return prompt ? `${prompt}\\n\\n${section}` : section;\n}\n\nfunction bestEffortRuntimeWarnings(\n runtime: string,\n agentConfig: ExecutableAgentConfig,\n excludeTools: string[] | undefined,\n): string[] {\n if (isPiRuntime(runtime)) return [];\n\n const warnings = [`Runtime '${runtime}' does not load Pi child extensions or hooks; launched best effort.`];\n const unsupportedResources = [\n ...(agentConfig.tools !== undefined || agentConfig.mcpDirectTools?.length ? ['tools'] : []),\n ...(agentConfig.skills?.length || agentConfig.skillPath?.length ? ['skills'] : []),\n ...(agentConfig.extensions !== undefined || agentConfig.subagentOnlyExtensions?.length ? ['extensions'] : []),\n ];\n if (unsupportedResources.length > 0) {\n warnings.push(\n `Doom Team cannot project or enforce configured Pi ${unsupportedResources.join(', ')} on runtime '${runtime}'.`,\n );\n }\n if (agentConfig.skills?.length) {\n warnings.push(`Configured skills were not injected: ${agentConfig.skills.join(', ')}.`);\n }\n if (excludeTools?.length) {\n warnings.push(\n `Runtime '${runtime}' cannot enforce Team package tool exclusions; launched best effort for: ${excludeTools.join(', ')}.`,\n );\n }\n return warnings;\n}\n\ninterface ChildSkillProjection {\n systemPrompt: string;\n requireReadTool: boolean;\n warnings: string[];\n}\n\ninterface ResolvedModelSelection {\n primaryModel: string | undefined;\n fallbackModels: string[];\n model: string | undefined;\n}\n\nfunction resolvedModelSelection(\n taskInput: SpawnPlanTaskInput,\n agentConfig: Pick<ExecutableAgentConfig, 'model' | 'modelSource' | 'fallbackModels'>,\n runtime: string,\n parentModel: ParentModel | undefined,\n availableModels: AvailableModelInfo[] | undefined,\n teamPackageModels: string[] | undefined,\n): ResolvedModelSelection {\n const parentModelId =\n isPiRuntime(runtime) && parentModel && availableModels !== undefined\n ? `${parentModel.provider}/${parentModel.id}`\n : undefined;\n const agentModels = [\n ...(agentConfig.modelSource?.scope === 'package' ? [] : [agentConfig.model]),\n ...(agentConfig.fallbackModels ?? []),\n ];\n const ordered = isPiRuntime(runtime)\n ? [taskInput.model, ...agentModels, ...(teamPackageModels ?? []), parentModelId]\n : [taskInput.model, ...agentModels, ...(teamPackageModels ?? [])];\n const candidates = ordered.filter((candidate): candidate is string => Boolean(candidate?.trim()));\n const [primaryModel, ...fallbackModels] = candidates;\n return {\n primaryModel,\n fallbackModels,\n model: selectAvailableModel(primaryModel, fallbackModels, availableModels),\n };\n}\n\nexport interface SpawnPlannerContract {\n /**\n * Resolves the plan and spawns every child. Throws on any PREFLIGHT\n * failure (bad request shape, depth exceeded, unknown agent) before\n * anything spawns. Never throws for an individual child's spawn failure\n * once the batch has started - that is a `{error}` outcome instead.\n */\n spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult>;\n}\n\nconst ERROR_CODE_AGENT_NOT_FOUND = 'agent_not_found' as const;\nconst ERROR_CODE_INVALID_REQUEST = 'invalid_request' as const;\nconst ERROR_CODE_MODEL_UNAVAILABLE = 'model_unavailable' as const;\nconst ERROR_CODE_OPERATION_CONFLICT = 'operation_conflict' as const;\nconst ERROR_CODE_RUNTIME_UNAVAILABLE = 'runtime_unavailable' as const;\nconst ERROR_CODE_UNSUPPORTED_CONTEXT = 'unsupported_context' as const;\nconst ERROR_CODE_UNSUPPORTED_OPERATION = 'unsupported_operation' as const;\n\nexport class SpawnPlanner implements SpawnPlannerContract {\n constructor(\n private readonly agents: AgentDiscoveryContract,\n private readonly spawner: AsyncSubagentSpawnerContract,\n private readonly policies: SubagentCapabilityPolicyStore = new SubagentCapabilityPolicyStore(),\n private readonly skills?: SkillDiscoveryContract,\n private readonly reportConcurrencyEvent?: ConcurrencyEventReporter,\n _mcpToolResolver?: McpDirectToolResolver,\n private readonly admission?: AdmissionGateContract,\n private readonly childSessions?: DoomChildSessionServiceProvider,\n private readonly nativeRuns?: NativeRunCoordinatorContract,\n private readonly teamChannel?: Pick<NativeTeamChannelContract, 'createNativeChildIntercom'>,\n ) {}\n\n protected generateRunId(): string {\n return crypto.randomUUID();\n }\n\n protected validateCwd(cwd: string): void {\n let stat: fs.Stats;\n try {\n stat = fs.statSync(cwd);\n } catch {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' does not exist.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n if (!stat.isDirectory()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' is not a directory.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n }\n\n protected resolveTeamPackageExcludeTools(): string[] | undefined {\n return resolveActiveTeamPackageConfig()?.config.excludeTools;\n }\n\n protected resolveTeamPackageModels(): string[] | undefined {\n return resolveActiveTeamModelSpecs();\n }\n\n protected executableAvailable(command: string): boolean {\n if (path.isAbsolute(command) || command.includes(path.sep)) {\n try {\n fs.accessSync(command, fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n }\n return (process.env.PATH ?? '')\n .split(path.delimiter)\n .filter(Boolean)\n .some((directory) => {\n try {\n fs.accessSync(path.join(directory, command), fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n });\n }\n\n private resolveTaskList(request: SpawnPlanRequest): SpawnPlanTaskInput[] {\n const hasSingle = request.single !== undefined;\n const hasTasks = request.tasks !== undefined;\n if (hasSingle === hasTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires exactly one of internal single or tasks representations.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n if (hasSingle) return [request.single!];\n if (!request.tasks || request.tasks.length === 0) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires at least one entry in its requests collection.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n return request.tasks;\n }\n\n private resolveAgentOrThrow(name: string, cwd: string, scope: AgentScope) {\n const resolved = this.agents.find(cwd, scope, name);\n if (!resolved) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_AGENT_NOT_FOUND,\n `Unknown agent '${name}'.`,\n false,\n 'Call subagent({\"action\":\"agents\"}) and retry with an exact name.',\n );\n }\n return resolved;\n }\n\n private resolveExecutableAgent(taskInput: SpawnPlanTaskInput, cwd: string, scope: AgentScope): ExecutableAgentConfig {\n if (!taskInput.inlineAgent) return this.resolveAgentOrThrow(taskInput.agent, cwd, scope);\n return {\n name: taskInput.agent.trim(),\n systemPromptMode: 'append',\n inheritProjectContext: true,\n inheritSkills: false,\n systemPrompt: taskInput.inlineAgent.systemPrompt.trim(),\n tools: [...INLINE_AGENT_TOOLS],\n defaultContext: CONTEXT_FRESH,\n runtime: PI_RUNTIME_NAME,\n };\n }\n\n private projectDefaultReads(\n defaultReads: string[] | undefined,\n childCwd: string,\n agentName: string,\n ): ChildSkillProjection {\n if (!defaultReads?.length) return { systemPrompt: '', requireReadTool: false, warnings: [] };\n\n const seen = new Set<string>();\n const readablePaths: string[] = [];\n const missingPaths: string[] = [];\n for (const configuredPath of defaultReads) {\n const trimmed = configuredPath.trim();\n if (!trimmed) continue;\n const resolvedPath = path.isAbsolute(trimmed) ? path.normalize(trimmed) : path.resolve(childCwd, trimmed);\n const identity = canonicalizeDiscoveryCwd(resolvedPath);\n if (seen.has(identity)) continue;\n seen.add(identity);\n try {\n if (fs.statSync(resolvedPath).isFile()) readablePaths.push(resolvedPath);\n else missingPaths.push(resolvedPath);\n } catch {\n missingPaths.push(resolvedPath);\n }\n }\n\n const systemPrompt =\n readablePaths.length > 0\n ? [\n 'Read these configured paths before broad repository discovery:',\n ...readablePaths.map((readPath) => `- ${readPath}`),\n 'If a listed path does not provide enough context, name the concrete missing dependency before searching narrowly for it.',\n ].join('\\n')\n : '';\n return {\n systemPrompt,\n requireReadTool: readablePaths.length > 0,\n warnings:\n missingPaths.length > 0\n ? [`Agent '${agentName}' could not read optional default paths: ${missingPaths.join(', ')}.`]\n : [],\n };\n }\n\n private projectConfiguredSkills(\n agentConfig: ExecutableAgentConfig,\n childCwd: string,\n requestCwd: string,\n runtime: string,\n cache: Map<string, ChildSkillProjection>,\n ): ChildSkillProjection {\n const cacheKey = JSON.stringify([\n canonicalizeDiscoveryCwd(childCwd),\n canonicalizeDiscoveryCwd(requestCwd),\n runtime,\n agentConfig.name,\n agentConfig.systemPrompt,\n agentConfig.skills ?? [],\n agentConfig.skillPath ?? [],\n agentConfig.defaultReads ?? [],\n ]);\n const cached = cache.get(cacheKey);\n if (cached) return cached;\n\n if (!isPiRuntime(runtime)) {\n const projection = { systemPrompt: agentConfig.systemPrompt, requireReadTool: false, warnings: [] };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n const defaultReads = this.projectDefaultReads(agentConfig.defaultReads, childCwd, agentConfig.name);\n let skillInjection = '';\n let skillWarnings: string[] = [];\n if (agentConfig.skills?.length) {\n if (!this.skills) throw new Error('Skill discovery is unavailable for configured child skills.');\n const resolution = this.skills.resolveSkillsWithFallback(\n agentConfig.skills,\n childCwd,\n requestCwd,\n agentConfig.skillPath,\n requestCwd,\n );\n skillInjection = buildSkillInjection(resolution.resolved);\n skillWarnings =\n resolution.missing.length > 0\n ? [\n `Agent '${agentConfig.name}' could not resolve configured skills: ${resolution.missing.join(', ')}; launched with resolved skills only.`,\n ]\n : [];\n }\n\n const projection = {\n systemPrompt: appendPromptSection(\n appendPromptSection(agentConfig.systemPrompt, skillInjection),\n defaultReads.systemPrompt,\n ),\n requireReadTool: skillInjection.length > 0 || defaultReads.requireReadTool,\n warnings: [...skillWarnings, ...defaultReads.warnings],\n };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n /**\n * Spawns exactly one child and returns its outcome. Shared by `spawn()`\n * (SINGLE/PARALLEL) and `spawnChain()`'s per-step/per-parallel-group-child\n * calls, so the `AsyncSubagentSpawnInput` mapping exists in exactly one\n * place. Never throws - a spawn failure becomes an `{error}` outcome, per\n * the \"preflight throws, per-child failure does not\" split documented in\n * the module header.\n */\n private async spawnOneChild(input: SpawnOneChildInput): Promise<SpawnPlanChildOutcome> {\n const {\n runId,\n operationId,\n agentConfig,\n identity,\n capabilityCeiling,\n excludeTools,\n teamPackageModels,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd,\n parentSessionId,\n parentForkSource,\n sessionScope,\n environment,\n parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs,\n artifacts,\n artifactDir,\n availableModels,\n parentModel,\n runtime,\n runtimes,\n skillProjectionCache,\n } = input;\n const cwd = taskInput.cwd ?? fallbackCwd;\n const task = taskInput.task ?? '';\n const effectiveContext = resolveEffectiveContext(taskInput, agentConfig);\n const effectiveRuntime = taskInput.runtime ?? runtime ?? agentConfig.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agentConfig,\n effectiveRuntime,\n parentModel,\n availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && availableModels !== undefined && !modelSelection.model) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: `No authenticated model is available for '${agentConfig.name}'. Checked: ${[\n modelSelection.primaryModel,\n ...modelSelection.fallbackModels,\n ].join(', ')}.`,\n };\n }\n\n let skillProjection: ChildSkillProjection;\n try {\n skillProjection = this.projectConfiguredSkills(\n agentConfig,\n cwd,\n fallbackCwd,\n effectiveRuntime,\n skillProjectionCache,\n );\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n const warnings = [\n ...skillProjection.warnings,\n ...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools),\n ];\n const warning = warnings.length > 0 ? warnings.join(' ') : undefined;\n\n // Persist every Pi child's own transcript so a later explicit restore can\n // continue it. External runtimes retain their existing session behavior.\n const spawnInput: AsyncSubagentSpawnInput = {\n runId,\n ...(operationId ? { operationId } : {}),\n agent: agentConfig.name,\n ...(taskInput.inlineAgent ? { inlineAgent: taskInput.inlineAgent } : {}),\n task,\n cwd,\n environment,\n childIndex,\n fanout,\n sessionScope,\n ...(parentSessionFile ? { parentSessionFile } : {}),\n piArgs: {\n ...(taskInput.sessionFile ? { sessionFile: taskInput.sessionFile } : {}),\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(effectiveContext === CONTEXT_FORK && parentSessionId ? { parentSessionId } : {}),\n },\n ...(handshakeTimeoutMs !== undefined ? { handshakeTimeoutMs } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(artifactDir !== undefined ? { artifactDir } : {}),\n // Per-call `runtime` wins over the agent's own default, matching how\n // `model` and `context` already resolve.\n runtime: effectiveRuntime,\n runtimes,\n };\n\n const admission = this.admission;\n if (!admission) throw new Error('Doom Team spawn admission is not configured.');\n let ticket: AdmissionTicket;\n try {\n ticket = await admission.admit({\n sessionScope,\n maxLiveRuns,\n timeoutMs: admissionTimeoutMs,\n ...(this.reportConcurrencyEvent ? { report: this.reportConcurrencyEvent } : {}),\n });\n } catch (error) {\n return {\n agent: agentConfig.name,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n }\n\n try {\n if (isPiRuntime(effectiveRuntime)) {\n if (!this.nativeRuns || !this.childSessions?.get())\n throw new Error('The native Team run coordinator is unavailable.');\n const scope = sessionScope;\n const source: DoomChildSessionSource = taskInput.sessionFile\n ? { kind: 'v4-restore', sessionFile: taskInput.sessionFile }\n : effectiveContext === CONTEXT_FORK\n ? (parentForkSource ??\n (() => {\n throw new Error('Native fork input requires an immutable terminal Pi snapshot.');\n })())\n : { kind: 'fresh' };\n const intercom = this.teamChannel?.createNativeChildIntercom({\n rootSessionId: scope.rootSessionId,\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n runId,\n childIndex,\n task: { id: runId, subject: task },\n });\n let child: Awaited<ReturnType<NativeRunCoordinatorContract['start']>>;\n try {\n child = await this.nativeRuns.start(\n parentSessionId ?? scope.rootSessionId,\n {\n runId,\n parentSessionId: parentSessionId ?? scope.rootSessionId,\n scope,\n source,\n agent: agentConfig.name,\n task,\n cwd,\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(typeof agentConfig.thinking === 'string' ? { thinking: agentConfig.thinking } : {}),\n ...(skillProjection.systemPrompt ? { systemPrompt: skillProjection.systemPrompt } : {}),\n systemPromptMode: agentConfig.systemPromptMode,\n ...(agentConfig.extensions ? { extensions: agentConfig.extensions } : {}),\n ...(agentConfig.subagentOnlyExtensions\n ? { subagentOnlyExtensions: agentConfig.subagentOnlyExtensions }\n : {}),\n ...(agentConfig.tools\n ? { tools: [...new Set([...agentConfig.tools, ...(capabilityCeiling?.requiredTools ?? [])])] }\n : {}),\n ...(excludeTools ? { excludeTools } : {}),\n ...(agentConfig.skills ? { skills: agentConfig.skills } : {}),\n ...(agentConfig.mcpDirectTools ? { mcpDirectTools: agentConfig.mcpDirectTools } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(intercom ? { intercom } : {}),\n environment,\n },\n // Carried beside the core child request rather than inside it, so a\n // Team-only concept does not widen the shared child contract.\n { identity: identity.identity, inline: identity.inline },\n );\n } catch (error) {\n intercom?.dispose?.();\n throw error;\n }\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: child.runId,\n ...(warning ? { warning } : {}),\n };\n }\n const result: AsyncSubagentSpawnResult = await this.spawner.spawn(spawnInput);\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: result.runId,\n pid: result.pid,\n ...(warning ? { warning } : {}),\n };\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n } finally {\n // Once spawn resolves, direct child events make the run visible to the\n // injected live counter, so only the reservation is released here.\n ticket.release();\n }\n }\n\n async spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult> {\n const tasks = this.resolveTaskList(request);\n const fanout = tasks.length > 1;\n const teamPackageExcludeTools = this.resolveTeamPackageExcludeTools();\n const teamPackageModels = this.resolveTeamPackageModels();\n const capabilityCeiling = this.policies.resolve();\n\n // PREFLIGHT - all before any spawn call, so a declared plan that cannot\n // run at all produces one refusal, not a partial fan-out.\n const currentDepth = request.currentDepth ?? resolveCurrentSubagentDepth();\n const depthCheck = preflightSubagentDepth(currentDepth, config);\n if (depthCheck.error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n depthCheck.error,\n false,\n 'Give each child a self-contained task within the Team package policy.',\n );\n }\n\n const maxTasks = config.parallel?.maxTasks ?? DEFAULT_PARALLEL_MAX_TASKS;\n if (tasks.length > maxTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run requested ${tasks.length} tasks, but at most ${maxTasks} may be declared in one call. Concurrency throttles how fast they start, not how many run.`,\n false,\n 'Send at most that many requests in this call and wait for them, or raise parallel.maxTasks in the subagent config. Splitting the same width across extra calls does not raise the live-child ceiling.',\n );\n }\n\n for (const taskInput of tasks) {\n if (!taskInput.task?.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run request for '${taskInput.agent}' requires a nonblank task.`,\n false,\n 'Provide a self-contained nonblank task.',\n );\n }\n if (taskInput.inlineAgent && !taskInput.inlineAgent.systemPrompt.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Inline agent '${taskInput.agent}' requires a nonblank system prompt.`,\n false,\n 'Provide a focused read-only exploration role.',\n );\n }\n }\n\n const resolvedAgentCache = new Map<string, ExecutableAgentConfig>();\n const resolvedAgents = tasks.map((taskInput) => {\n if (taskInput.inlineAgent) {\n return this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n }\n const cacheKey = [\n request.agentScope,\n canonicalizeDiscoveryCwd(taskInput.cwd ?? request.cwd),\n taskInput.agent,\n ].join('\\0');\n const cached = resolvedAgentCache.get(cacheKey);\n if (cached) return cached;\n const resolved = this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n resolvedAgentCache.set(cacheKey, resolved);\n return resolved;\n });\n for (const [index, taskInput] of tasks.entries()) {\n const effectiveContext = resolveEffectiveContext(taskInput, resolvedAgents[index]!);\n const runtime = taskInput.runtime ?? request.runtime ?? resolvedAgents[index]!.runtime ?? PI_RUNTIME_NAME;\n if (effectiveContext === CONTEXT_FORK) {\n if (!isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context requires ${PI_RUNTIME_REQUIREMENT} for '${taskInput.agent}'.`,\n false,\n 'Use a Pi agent for fork context or explicitly request a fresh run.',\n );\n }\n if (!request.parentForkSource) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context is unavailable for '${taskInput.agent}': ${describeForkFailure(request.parentForkFailure)}.`,\n false,\n 'Use an active Pi session with a completed parent turn or explicitly request a fresh run.',\n );\n }\n }\n }\n\n if (request.preallocatedRunIds && request.preallocatedRunIds.length !== tasks.length) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_OPERATION_CONFLICT,\n 'The operation journal run-id count does not match the request count.',\n false,\n 'Submit the run as a new tool call.',\n );\n }\n const runIds = request.preallocatedRunIds ?? tasks.map(() => this.generateRunId());\n // Minted here because this is the one funnel every spawn path reaches, and\n // because the inline flag and the resolved agent name are both in hand. A\n // restore carries its identity in, and repoints the existing claim rather\n // than burning a second number on the same logical agent.\n const identities = tasks.map((taskInput, index) => {\n const inline = taskInput.inlineAgent !== undefined;\n if (!taskInput.identity) {\n return claimAgentIdentity(request.sessionScope, {\n agent: resolvedAgents[index]!.name,\n inline,\n runId: runIds[index]!,\n });\n }\n adoptAgentIdentity(request.sessionScope, taskInput.identity, runIds[index]!);\n return {\n identity: taskInput.identity,\n name: '',\n role: roleFromAgent(resolvedAgents[index]!.name),\n number: 0,\n inline,\n persisted: true,\n };\n });\n const runtimes = resolveRuntimeTable(config.runtimes);\n for (const [index, taskInput] of tasks.entries()) {\n const agent = resolvedAgents[index]!;\n const cwd = taskInput.cwd ?? request.cwd;\n this.validateCwd(cwd);\n const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agent,\n runtime,\n request.parentModel,\n request.availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && request.availableModels !== undefined && !modelSelection.model) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_MODEL_UNAVAILABLE,\n `No authenticated model is available for '${agent.name}'.`,\n false,\n 'Authenticate the requested model or choose an available model.',\n );\n }\n if (taskInput.inlineAgent && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Inline agent '${taskInput.agent}' requires ${PI_RUNTIME_REQUIREMENT} to enforce its read-only tools.`,\n false,\n 'Remove the runtime override or use a discovered external-runtime agent without inlineAgent.',\n );\n }\n if (capabilityCeiling && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Runtime '${runtime}' cannot enforce the active capability ceiling.`,\n false,\n `Use ${PI_RUNTIME_REQUIREMENT} while plan mode or another capability ceiling is active.`,\n );\n }\n if (!isPiRuntime(runtime)) {\n let command: string;\n try {\n command = resolveRuntimeLaunch(runtime, runtimes, { prompt: taskInput.task ?? '', cwd }).command;\n } catch (error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n error instanceof Error ? error.message : String(error),\n false,\n `Configure a valid external runtime or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n if (!this.executableAvailable(command)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n `Executable '${command}' for runtime '${runtime}' is unavailable.`,\n false,\n `Install the executable, configure its absolute path, or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n }\n }\n const concurrency = fanout\n ? (request.concurrency ?? config.parallel?.concurrency ?? DEFAULT_PARALLEL_CONCURRENCY)\n : 1;\n const maxLiveRuns = Math.max(1, config.parallel?.maxLiveRuns ?? DEFAULT_MAX_LIVE_RUNS);\n const admissionTimeoutMs = config.parallel?.admissionTimeoutMs ?? DEFAULT_ADMISSION_TIMEOUT_MS;\n\n const skillProjectionCache = new Map<string, ChildSkillProjection>();\n const factories = tasks.map(\n (taskInput, childIndex) => () =>\n this.spawnOneChild({\n runId: runIds[childIndex]!,\n operationId: request.operationId,\n agentConfig: resolvedAgents[childIndex]!,\n identity: identities[childIndex]!,\n excludeTools: teamPackageExcludeTools,\n teamPackageModels,\n capabilityCeiling,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd: request.cwd,\n parentSessionId: request.parentSessionId,\n parentForkSource: request.parentForkSource,\n sessionScope: request.sessionScope,\n environment: request.environment ?? {},\n parentSessionFile: request.parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs: config.handshakeTimeoutMs,\n artifacts: request.artifacts,\n artifactDir: config.artifactDir,\n availableModels: request.availableModels,\n parentModel: request.parentModel,\n runtime: request.runtime,\n runtimes,\n skillProjectionCache,\n }),\n );\n\n const settled = await runWithConcurrency(factories, concurrency, this.reportConcurrencyEvent);\n // `spawnOneChild` never rejects (it catches its own spawn failure into\n // an `{error}` outcome), so `runWithConcurrency` never sees a rejection\n // here - this unwrap is defensive, not a real branch.\n const outcomes = settled.map((outcome, index) =>\n outcome.status === 'fulfilled'\n ? outcome.value\n : {\n agent: resolvedAgents[index]!.name,\n identity: identities[index]!.identity,\n inline: identities[index]!.inline,\n task: tasks[index]!.task ?? '',\n childIndex: index,\n error: outcome.reason instanceof Error ? outcome.reason.message : String(outcome.reason),\n },\n );\n\n return { outcomes };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAe/B,SAAS,oBAAoB,aAAwD;CACnF,IA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B,WAAW,aAAa,KAAK,sBAAsB,EAAA,CAInE,KAAK,SAAS,UACrC,QAAQ,WAAW,cACf,QAAQ,QACR;GACE,OAAO,eAAe,MAAM,CAAE;GAC9B,UAAU,WAAW,MAAM,CAAE;GAC7B,QAAQ,WAAW,MAAM,CAAE;GAC3B,MAAM,MAAM,MAAM,CAAE,QAAQ;GAC5B,YAAY;GACZ,OAAO,QAAQ,kBAAkB,QAAQ,QAAQ,OAAO,UAAU,OAAO,QAAQ,MAAM;EACzF,CAGU,EAAE;CACpB;AACF"}
|
|
@@ -495,7 +495,7 @@ var SpawnPlanner = class {
|
|
|
495
495
|
systemPromptMode: agentConfig.systemPromptMode,
|
|
496
496
|
...agentConfig.extensions ? { extensions: agentConfig.extensions } : {},
|
|
497
497
|
...agentConfig.subagentOnlyExtensions ? { subagentOnlyExtensions: agentConfig.subagentOnlyExtensions } : {},
|
|
498
|
-
...agentConfig.tools ? { tools: agentConfig.tools } : {},
|
|
498
|
+
...agentConfig.tools ? { tools: [.../* @__PURE__ */ new Set([...agentConfig.tools, ...capabilityCeiling?.requiredTools ?? []])] } : {},
|
|
499
499
|
...excludeTools ? { excludeTools } : {},
|
|
500
500
|
...agentConfig.skills ? { skills: agentConfig.skills } : {},
|
|
501
501
|
...agentConfig.mcpDirectTools ? { mcpDirectTools: agentConfig.mcpDirectTools } : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/spawnPlan/index.ts"],"sourcesContent":["/**\n * Turns `subagent` tool params into a resolved sequence of\n * `AsyncSubagentSpawner.spawn()` calls: SINGLE (one child), PARALLEL (N\n * children, bounded by `concurrency`).\n *\n * WHY THIS IS NEW LOGIC, NOT COMPOSITION:\n * `AsyncSubagentSpawner` is deliberately a per-child primitive -\n * `childIndex`/`fanout` arrive as inputs it does not derive (see that\n * module's header). Nothing else in this package decides \"how many\n * children, in what order, at what `childIndex`\" from a `subagent` tool\n * call. That decision is this file's job.\n *\n * PREFLIGHT, ALL-OR-NOTHING:\n * `resolveCurrentSubagentDepth`/`preflightSubagentDepth` run once, before\n * anything spawns. A depth refusal throws - a declared plan that cannot run\n * at all should produce one clear refusal, not a partial fan-out.\n * `AgentDiscoveryService.find` resolves and validates every child's agent\n * name up front too, for the same reason: a typo'd agent name is a\n * preflight failure named at the tool boundary, not a spawn error surfacing\n * deep inside one child while its siblings are already running.\n *\n * ONCE THE BATCH HAS STARTED, PER-CHILD FAILURE IS A RESULT, NOT AN\n * EXCEPTION:\n * `runWithConcurrency` never lets one child's rejection abort its siblings,\n * matching `failFast` being opt-in in the schema, not the default. Every\n * child gets an outcome - `{runId, pid}` on success, `{error}` on failure -\n * and the caller (`subagentTool.ts`) decides how to report a mixed batch.\n *\n * WHAT THIS DOES NOT WIRE YET, AND WHY - FLAGGED, NOT SILENTLY GUESSED:\n * - `maxSubagentSpawnsPerSession` (`spawn-budget.ts`) is NOT enforced here.\n * `preflightSpawnBudget` needs a durable, session-scoped `SpawnBudgetStore`\n * that accumulates spend ACROSS separate tool calls in the same session;\n * inventing a fresh store per call would never track real spend and would\n * be worse than not checking at all (false confidence). Wiring this needs\n * a real session-scoped store owned by a lifecycle-bound service - a\n * follow-up, not guessed here.\n * - Fork context is resolved here and requires a captured persisted Pi source;\n * unavailable or non-Pi fork requests fail closed rather than becoming fresh\n * launches.\n * - Per-task overrides with no direct `BuildPiArgsInput` field confirmed yet\n * (`skill`, `toolBudget`, `turnBudget`, `outputSchema`/structured output,\n * `acceptance`, `output`/`outputMode`) are not mapped into `piArgs` for\n * v1. Each child still gets its resolved `AgentConfig`'s own defaults\n * (`systemPromptMode`, `inheritProjectContext`, `inheritSkills`,\n * `systemPrompt`) - not nothing, just not every param override yet.\n *\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type {\n DoomChildSessionScope,\n DoomChildSessionSource,\n DoomChildSessionServiceProvider,\n DoomChildSessionTerminalPiForkSource,\n DoomChildSessionV4ForkSource,\n} from '@agimon-ai/doompi-core/child';\nimport type { SessionManager } from '@earendil-works/pi-coding-agent';\n\nimport type { InlineAgent } from '../../schemas/subagentTool';\nimport {\n type ResolvedSubagentCapabilityCeiling,\n SubagentCapabilityPolicyStore,\n} from '../../schemas/team/capabilityCeiling';\nimport type { AgentConfig, AgentScope, AgentDiscoveryContract } from '../../types/agent';\nimport { PI_RUNTIME_NAME } from '../../types/environment';\nimport { type AdmissionGateContract, type AdmissionTicket, DEFAULT_ADMISSION_TIMEOUT_MS } from '../admissionGate';\nimport { resolveActiveTeamModelSpecs, resolveActiveTeamPackageConfig } from '../agentDiscovery';\nimport { adoptAgentIdentity, type AgentIdentity, claimAgentIdentity, roleFromAgent } from '../agentIdentity';\nimport { canonicalizeDiscoveryCwd } from '../agentProjectRoot';\nimport { buildSkillInjection, type SkillDiscoveryContract } from '../agentSkills';\nimport type {\n AsyncSubagentSpawnInput,\n AsyncSubagentSpawnResult,\n AsyncSubagentSpawnerContract,\n} from '../asyncExecution';\nimport type { ExtensionConfig } from '../config';\nimport { preflightSubagentDepth, resolveCurrentSubagentDepth } from '../depthGuard';\nimport { DoomTeamExpectedError } from '../errors';\nimport type { McpDirectToolResolver } from '../mcpDirectToolAllowlist';\nimport { type AvailableModelInfo, type ParentModel, selectAvailableModel } from '../modelFallback';\nimport type { NativeRunCoordinatorContract } from '../nativeRunCoordinator';\nimport type { NativeTeamChannelContract } from '../nativeTeamChannel';\nimport { isPiRuntime, type RuntimeTable, resolveRuntimeLaunch, resolveRuntimeTable } from '../runtimeRegistry';\nimport { type ConcurrencyEventReporter, runWithConcurrency } from '../runWithConcurrency';\n\nconst CONTEXT_FRESH = 'fresh' as const;\nconst CONTEXT_FORK = 'fork' as const;\nconst PI_RUNTIME_REQUIREMENT = `runtime \"${PI_RUNTIME_NAME}\"`;\n\ntype SessionForkCaptureMode = 'tool' | 'settled';\n\nexport interface SessionForkSource {\n readonly sessionFile?: string;\n readonly leafId: string;\n readonly terminalSource: DoomChildSessionTerminalPiForkSource;\n}\n\nexport type SessionForkSourceManager = Pick<\n SessionManager,\n 'getSessionFile' | 'getSessionId' | 'getLeafId' | 'getLeafEntry' | 'getHeader' | 'getBranch'\n>;\n\nfunction readableSessionFile(sessionFile: string | undefined): sessionFile is string {\n if (!sessionFile?.trim()) return false;\n try {\n fs.accessSync(sessionFile, fs.constants.R_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Why a capture reports a reason instead of a bare `undefined`.\n *\n * Five distinct conditions used to collapse into one `undefined`, and the\n * caller then asserted a cause it had never tested. That is how a missing\n * `captureForkSource` on the headless facet spent a long time looking like a\n * session-format problem. The reason is carried to the throw site so the error\n * names the condition that actually fired.\n */\nexport type ForkCaptureFailure = 'no-leaf' | 'no-header' | 'unsupported-version' | 'branch-mismatch' | 'no-session-id';\n\nexport type ForkCaptureResult =\n | { readonly ok: true; readonly source: SessionForkSource }\n | { readonly ok: false; readonly reason: ForkCaptureFailure };\n\n/** Either host's capture output, plus the absent case when no capture is installed. */\nexport type ParentForkCapture = ForkCaptureResult | DoomChildSessionV4ForkSource | undefined;\n\nconst FORK_FAILURE_TEXT: Record<ForkCaptureFailure | 'no-capture-installed', string> = {\n 'no-capture-installed': 'this host installed no fork-source capture',\n 'no-leaf': 'the parent session has no entry to branch from',\n 'no-header': 'the parent session has no readable header',\n 'unsupported-version': 'the parent session format cannot be forked',\n 'branch-mismatch': 'the parent branch did not resolve to its own leaf',\n 'no-session-id': 'the parent session has no identity',\n};\n\nexport function describeForkFailure(reason: ForkCaptureFailure | 'no-capture-installed' | undefined): string {\n return reason ? FORK_FAILURE_TEXT[reason] : 'the parent session has no capturable branch';\n}\n\n/**\n * Map a captured parent branch onto the spawn request's fork fields.\n *\n * `parentSessionFile` and `parentLeafId` describe a terminal Pi capture only. A\n * v4 source already carries its own file and branch, so flattening it into\n * those fields would describe it in the wrong vocabulary and lose the branch.\n */\nexport function forkRequestFields(\n captured: ParentForkCapture,\n): Pick<SpawnPlanRequest, 'parentForkSource' | 'parentSessionFile' | 'parentLeafId' | 'parentForkFailure'> {\n if (!captured) return { parentForkFailure: 'no-capture-installed' };\n if ('kind' in captured) return { parentForkSource: captured };\n if (!captured.ok) return { parentForkFailure: captured.reason };\n const { source } = captured;\n return {\n parentForkSource: source.terminalSource,\n ...(source.sessionFile ? { parentSessionFile: source.sessionFile } : {}),\n parentLeafId: source.leafId,\n };\n}\n\n/** Capture an immutable parent branch while excluding an assistant turn whose tool is still executing. */\nexport function captureSessionForkSource(\n manager: SessionForkSourceManager,\n mode: SessionForkCaptureMode,\n): ForkCaptureResult {\n const leaf = manager.getLeafEntry();\n const leafId =\n mode === 'tool' && leaf?.type === 'message' && leaf.message.role === 'assistant'\n ? leaf.parentId\n : (leaf?.id ?? manager.getLeafId());\n const header = manager.getHeader();\n if (!leafId) return { ok: false, reason: 'no-leaf' };\n if (header?.type !== 'session') return { ok: false, reason: 'no-header' };\n if (header.version !== 3) return { ok: false, reason: 'unsupported-version' };\n\n const branch = manager.getBranch(leafId);\n if (branch.at(-1)?.id !== leafId) return { ok: false, reason: 'branch-mismatch' };\n const sourceSessionId = manager.getSessionId();\n if (!sourceSessionId.trim()) return { ok: false, reason: 'no-session-id' };\n const terminalSource: DoomChildSessionTerminalPiForkSource = Object.freeze({\n kind: 'terminal-pi-fork',\n sourceSessionId,\n sourceLeafId: leafId,\n snapshotJsonl: `${[header, ...branch].map((record) => JSON.stringify(record)).join('\\n')}\\n`,\n });\n const sessionFile = manager.getSessionFile();\n return {\n ok: true,\n source: {\n leafId,\n terminalSource,\n ...(readableSessionFile(sessionFile) ? { sessionFile } : {}),\n },\n };\n}\n\nexport interface SpawnPlanTaskInput {\n agent: string;\n inlineAgent?: InlineAgent;\n task?: string;\n cwd?: string;\n model?: string;\n runtime?: string;\n context?: typeof CONTEXT_FRESH | typeof CONTEXT_FORK;\n /** An existing child transcript to continue instead of starting fresh. */\n sessionFile?: string;\n /** An identity inherited by a restore. Absent for a fresh run, which mints one. */\n identity?: string;\n}\n\ntype ExecutableAgentConfig = Pick<\n AgentConfig,\n | 'name'\n | 'defaultContext'\n | 'defaultReads'\n | 'extensions'\n | 'fallbackModels'\n | 'inheritProjectContext'\n | 'inheritSkills'\n | 'mcpDirectTools'\n | 'model'\n | 'modelSource'\n | 'runtime'\n | 'skills'\n | 'skillPath'\n | 'subagentOnlyExtensions'\n | 'systemPrompt'\n | 'systemPromptMode'\n | 'thinking'\n | 'tools'\n>;\n\nfunction resolveEffectiveContext(\n taskInput: SpawnPlanTaskInput,\n agent: Pick<ExecutableAgentConfig, 'defaultContext'>,\n): typeof CONTEXT_FRESH | typeof CONTEXT_FORK {\n return taskInput.sessionFile ? CONTEXT_FRESH : (taskInput.context ?? agent.defaultContext ?? CONTEXT_FRESH);\n}\n\nexport interface SpawnPlanRequest {\n /** SINGLE mode: exactly one child. Mutually exclusive with `tasks`. */\n single?: SpawnPlanTaskInput;\n /** PARALLEL mode: N children, fanned out. Mutually exclusive with `single`. */\n tasks?: SpawnPlanTaskInput[];\n /** Max children in flight at once for PARALLEL mode. Ignored for SINGLE. Defaults to `config.parallel.concurrency` or 4. */\n concurrency?: number;\n /** Fallback cwd for any task that omits its own. */\n cwd: string;\n agentScope: AgentScope;\n /** Explicit owner scope forwarded to every child runtime. */\n sessionScope: DoomChildSessionScope;\n /** Environment admitted to this parent session, forwarded only to native children. */\n environment?: Readonly<Record<string, string | undefined>>;\n /** Parent identity retained for delegation correlation. */\n parentSessionId?: string;\n /** Immutable parent branch used by native fork children. */\n parentForkSource?: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource;\n /** Why no parent branch was captured, so a refused fork can name its cause. */\n parentForkFailure?: ForkCaptureFailure | 'no-capture-installed';\n /** External-runtime parent source fields. */\n parentSessionFile?: string;\n parentLeafId?: string;\n artifacts?: boolean;\n /** Authenticated models reported by the live parent host. Undefined for callers without a host context. */\n availableModels?: AvailableModelInfo[];\n /** The live parent model, forwarded only for Pi child selection. */\n parentModel?: ParentModel;\n /** Overrides `resolveCurrentSubagentDepth()`'s own env read - a test seam, not a runtime path. */\n currentDepth?: number;\n /** Which runtime executes every child of this request. Defaults per agent, then to `pi`. */\n runtime?: string;\n /** Stable Pi tool-call identity used to correlate this batch. */\n operationId?: string;\n /** Run ids persisted by the operation journal before any process starts. */\n preallocatedRunIds?: string[];\n}\n\n/** Everything one child spawn needs. An object because this reached ten positional parameters. */\ninterface SpawnOneChildInput {\n runId: string;\n operationId?: string;\n agentConfig: ExecutableAgentConfig;\n identity: AgentIdentity;\n excludeTools?: string[];\n teamPackageModels?: string[];\n capabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n taskInput: SpawnPlanTaskInput;\n childIndex: number;\n fanout: boolean;\n fallbackCwd: string;\n parentSessionId: string | undefined;\n parentForkSource: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource | undefined;\n sessionScope: DoomChildSessionScope;\n environment: Readonly<Record<string, string | undefined>>;\n parentSessionFile: string | undefined;\n maxLiveRuns: number;\n admissionTimeoutMs: number;\n handshakeTimeoutMs: number | undefined;\n artifacts: boolean | undefined;\n artifactDir: ExtensionConfig['artifactDir'];\n availableModels: AvailableModelInfo[] | undefined;\n parentModel: ParentModel | undefined;\n runtime: string | undefined;\n runtimes: RuntimeTable;\n skillProjectionCache: Map<string, ChildSkillProjection>;\n}\n\nexport interface SpawnPlanChildOutcome {\n agent: string;\n task: string;\n /** This spawn's position among its siblings. Always 0 for SINGLE mode. */\n childIndex: number;\n runId?: string;\n /** The generated addressable identity, for example `alan-reviewer-3`. */\n identity?: string;\n /** True when this run came from a one-shot inline agent definition. */\n inline?: boolean;\n pid?: number;\n error?: string;\n warning?: string;\n}\n\nexport interface SpawnPlanResult {\n outcomes: SpawnPlanChildOutcome[];\n}\n\nconst DEFAULT_PARALLEL_CONCURRENCY = 4;\n/**\n * Hard ceiling on how many children one PARALLEL call may DECLARE.\n *\n * `concurrency` does NOT bound this, and cannot: `spawnOneChild` resolves as\n * soon as its child confirms it started, and the child then runs detached. So\n * `runWithConcurrency` throttles how fast children are STARTED, not how many\n * are running - `{tasks: [8], concurrency: 4}` ends up with eight live model\n * processes, not four. 8 matches the sibling implementation's\n * `PI_TEAM_MATE_MAX_PARALLEL`.\n *\n * This is a per-call declaration limit and nothing more. What actually bounds\n * live children across concurrent calls is `AdmissionGate`\n * (`runs/shared/admissionGate.ts`), which every spawn passes through.\n */\nconst DEFAULT_PARALLEL_MAX_TASKS = 8;\n/**\n * Process-wide ceiling on children ALIVE at once.\n *\n * Defaulted to `DEFAULT_PARALLEL_MAX_TASKS` so a single call's width is\n * exactly what it was before the gate existed; the only behaviour that\n * changes is that a second overlapping call now queues instead of stacking\n * another full batch on the machine. Raise or lower it with\n * `parallel.maxLiveRuns` in the subagent config, and bound the queue wait with\n * `parallel.admissionTimeoutMs`. It is deliberately NOT derived from the host's\n * cores or memory: a number measured on one machine is not a default.\n */\nconst DEFAULT_MAX_LIVE_RUNS = DEFAULT_PARALLEL_MAX_TASKS;\nconst INLINE_AGENT_TOOLS = ['read', 'grep', 'find', 'ls'] as const;\n\nfunction appendPromptSection(prompt: string, section: string): string {\n if (!section) return prompt;\n return prompt ? `${prompt}\\n\\n${section}` : section;\n}\n\nfunction bestEffortRuntimeWarnings(\n runtime: string,\n agentConfig: ExecutableAgentConfig,\n excludeTools: string[] | undefined,\n): string[] {\n if (isPiRuntime(runtime)) return [];\n\n const warnings = [`Runtime '${runtime}' does not load Pi child extensions or hooks; launched best effort.`];\n const unsupportedResources = [\n ...(agentConfig.tools !== undefined || agentConfig.mcpDirectTools?.length ? ['tools'] : []),\n ...(agentConfig.skills?.length || agentConfig.skillPath?.length ? ['skills'] : []),\n ...(agentConfig.extensions !== undefined || agentConfig.subagentOnlyExtensions?.length ? ['extensions'] : []),\n ];\n if (unsupportedResources.length > 0) {\n warnings.push(\n `Doom Team cannot project or enforce configured Pi ${unsupportedResources.join(', ')} on runtime '${runtime}'.`,\n );\n }\n if (agentConfig.skills?.length) {\n warnings.push(`Configured skills were not injected: ${agentConfig.skills.join(', ')}.`);\n }\n if (excludeTools?.length) {\n warnings.push(\n `Runtime '${runtime}' cannot enforce Team package tool exclusions; launched best effort for: ${excludeTools.join(', ')}.`,\n );\n }\n return warnings;\n}\n\ninterface ChildSkillProjection {\n systemPrompt: string;\n requireReadTool: boolean;\n warnings: string[];\n}\n\ninterface ResolvedModelSelection {\n primaryModel: string | undefined;\n fallbackModels: string[];\n model: string | undefined;\n}\n\nfunction resolvedModelSelection(\n taskInput: SpawnPlanTaskInput,\n agentConfig: Pick<ExecutableAgentConfig, 'model' | 'modelSource' | 'fallbackModels'>,\n runtime: string,\n parentModel: ParentModel | undefined,\n availableModels: AvailableModelInfo[] | undefined,\n teamPackageModels: string[] | undefined,\n): ResolvedModelSelection {\n const parentModelId =\n isPiRuntime(runtime) && parentModel && availableModels !== undefined\n ? `${parentModel.provider}/${parentModel.id}`\n : undefined;\n const agentModels = [\n ...(agentConfig.modelSource?.scope === 'package' ? [] : [agentConfig.model]),\n ...(agentConfig.fallbackModels ?? []),\n ];\n const ordered = isPiRuntime(runtime)\n ? [taskInput.model, ...agentModels, ...(teamPackageModels ?? []), parentModelId]\n : [taskInput.model, ...agentModels, ...(teamPackageModels ?? [])];\n const candidates = ordered.filter((candidate): candidate is string => Boolean(candidate?.trim()));\n const [primaryModel, ...fallbackModels] = candidates;\n return {\n primaryModel,\n fallbackModels,\n model: selectAvailableModel(primaryModel, fallbackModels, availableModels),\n };\n}\n\nexport interface SpawnPlannerContract {\n /**\n * Resolves the plan and spawns every child. Throws on any PREFLIGHT\n * failure (bad request shape, depth exceeded, unknown agent) before\n * anything spawns. Never throws for an individual child's spawn failure\n * once the batch has started - that is a `{error}` outcome instead.\n */\n spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult>;\n}\n\nconst ERROR_CODE_AGENT_NOT_FOUND = 'agent_not_found' as const;\nconst ERROR_CODE_INVALID_REQUEST = 'invalid_request' as const;\nconst ERROR_CODE_MODEL_UNAVAILABLE = 'model_unavailable' as const;\nconst ERROR_CODE_OPERATION_CONFLICT = 'operation_conflict' as const;\nconst ERROR_CODE_RUNTIME_UNAVAILABLE = 'runtime_unavailable' as const;\nconst ERROR_CODE_UNSUPPORTED_CONTEXT = 'unsupported_context' as const;\nconst ERROR_CODE_UNSUPPORTED_OPERATION = 'unsupported_operation' as const;\n\nexport class SpawnPlanner implements SpawnPlannerContract {\n constructor(\n private readonly agents: AgentDiscoveryContract,\n private readonly spawner: AsyncSubagentSpawnerContract,\n private readonly policies: SubagentCapabilityPolicyStore = new SubagentCapabilityPolicyStore(),\n private readonly skills?: SkillDiscoveryContract,\n private readonly reportConcurrencyEvent?: ConcurrencyEventReporter,\n _mcpToolResolver?: McpDirectToolResolver,\n private readonly admission?: AdmissionGateContract,\n private readonly childSessions?: DoomChildSessionServiceProvider,\n private readonly nativeRuns?: NativeRunCoordinatorContract,\n private readonly teamChannel?: Pick<NativeTeamChannelContract, 'createNativeChildIntercom'>,\n ) {}\n\n protected generateRunId(): string {\n return crypto.randomUUID();\n }\n\n protected validateCwd(cwd: string): void {\n let stat: fs.Stats;\n try {\n stat = fs.statSync(cwd);\n } catch {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' does not exist.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n if (!stat.isDirectory()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' is not a directory.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n }\n\n protected resolveTeamPackageExcludeTools(): string[] | undefined {\n return resolveActiveTeamPackageConfig()?.config.excludeTools;\n }\n\n protected resolveTeamPackageModels(): string[] | undefined {\n return resolveActiveTeamModelSpecs();\n }\n\n protected executableAvailable(command: string): boolean {\n if (path.isAbsolute(command) || command.includes(path.sep)) {\n try {\n fs.accessSync(command, fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n }\n return (process.env.PATH ?? '')\n .split(path.delimiter)\n .filter(Boolean)\n .some((directory) => {\n try {\n fs.accessSync(path.join(directory, command), fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n });\n }\n\n private resolveTaskList(request: SpawnPlanRequest): SpawnPlanTaskInput[] {\n const hasSingle = request.single !== undefined;\n const hasTasks = request.tasks !== undefined;\n if (hasSingle === hasTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires exactly one of internal single or tasks representations.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n if (hasSingle) return [request.single!];\n if (!request.tasks || request.tasks.length === 0) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires at least one entry in its requests collection.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n return request.tasks;\n }\n\n private resolveAgentOrThrow(name: string, cwd: string, scope: AgentScope) {\n const resolved = this.agents.find(cwd, scope, name);\n if (!resolved) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_AGENT_NOT_FOUND,\n `Unknown agent '${name}'.`,\n false,\n 'Call subagent({\"action\":\"agents\"}) and retry with an exact name.',\n );\n }\n return resolved;\n }\n\n private resolveExecutableAgent(taskInput: SpawnPlanTaskInput, cwd: string, scope: AgentScope): ExecutableAgentConfig {\n if (!taskInput.inlineAgent) return this.resolveAgentOrThrow(taskInput.agent, cwd, scope);\n return {\n name: taskInput.agent.trim(),\n systemPromptMode: 'append',\n inheritProjectContext: true,\n inheritSkills: false,\n systemPrompt: taskInput.inlineAgent.systemPrompt.trim(),\n tools: [...INLINE_AGENT_TOOLS],\n defaultContext: CONTEXT_FRESH,\n runtime: PI_RUNTIME_NAME,\n };\n }\n\n private projectDefaultReads(\n defaultReads: string[] | undefined,\n childCwd: string,\n agentName: string,\n ): ChildSkillProjection {\n if (!defaultReads?.length) return { systemPrompt: '', requireReadTool: false, warnings: [] };\n\n const seen = new Set<string>();\n const readablePaths: string[] = [];\n const missingPaths: string[] = [];\n for (const configuredPath of defaultReads) {\n const trimmed = configuredPath.trim();\n if (!trimmed) continue;\n const resolvedPath = path.isAbsolute(trimmed) ? path.normalize(trimmed) : path.resolve(childCwd, trimmed);\n const identity = canonicalizeDiscoveryCwd(resolvedPath);\n if (seen.has(identity)) continue;\n seen.add(identity);\n try {\n if (fs.statSync(resolvedPath).isFile()) readablePaths.push(resolvedPath);\n else missingPaths.push(resolvedPath);\n } catch {\n missingPaths.push(resolvedPath);\n }\n }\n\n const systemPrompt =\n readablePaths.length > 0\n ? [\n 'Read these configured paths before broad repository discovery:',\n ...readablePaths.map((readPath) => `- ${readPath}`),\n 'If a listed path does not provide enough context, name the concrete missing dependency before searching narrowly for it.',\n ].join('\\n')\n : '';\n return {\n systemPrompt,\n requireReadTool: readablePaths.length > 0,\n warnings:\n missingPaths.length > 0\n ? [`Agent '${agentName}' could not read optional default paths: ${missingPaths.join(', ')}.`]\n : [],\n };\n }\n\n private projectConfiguredSkills(\n agentConfig: ExecutableAgentConfig,\n childCwd: string,\n requestCwd: string,\n runtime: string,\n cache: Map<string, ChildSkillProjection>,\n ): ChildSkillProjection {\n const cacheKey = JSON.stringify([\n canonicalizeDiscoveryCwd(childCwd),\n canonicalizeDiscoveryCwd(requestCwd),\n runtime,\n agentConfig.name,\n agentConfig.systemPrompt,\n agentConfig.skills ?? [],\n agentConfig.skillPath ?? [],\n agentConfig.defaultReads ?? [],\n ]);\n const cached = cache.get(cacheKey);\n if (cached) return cached;\n\n if (!isPiRuntime(runtime)) {\n const projection = { systemPrompt: agentConfig.systemPrompt, requireReadTool: false, warnings: [] };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n const defaultReads = this.projectDefaultReads(agentConfig.defaultReads, childCwd, agentConfig.name);\n let skillInjection = '';\n let skillWarnings: string[] = [];\n if (agentConfig.skills?.length) {\n if (!this.skills) throw new Error('Skill discovery is unavailable for configured child skills.');\n const resolution = this.skills.resolveSkillsWithFallback(\n agentConfig.skills,\n childCwd,\n requestCwd,\n agentConfig.skillPath,\n requestCwd,\n );\n skillInjection = buildSkillInjection(resolution.resolved);\n skillWarnings =\n resolution.missing.length > 0\n ? [\n `Agent '${agentConfig.name}' could not resolve configured skills: ${resolution.missing.join(', ')}; launched with resolved skills only.`,\n ]\n : [];\n }\n\n const projection = {\n systemPrompt: appendPromptSection(\n appendPromptSection(agentConfig.systemPrompt, skillInjection),\n defaultReads.systemPrompt,\n ),\n requireReadTool: skillInjection.length > 0 || defaultReads.requireReadTool,\n warnings: [...skillWarnings, ...defaultReads.warnings],\n };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n /**\n * Spawns exactly one child and returns its outcome. Shared by `spawn()`\n * (SINGLE/PARALLEL) and `spawnChain()`'s per-step/per-parallel-group-child\n * calls, so the `AsyncSubagentSpawnInput` mapping exists in exactly one\n * place. Never throws - a spawn failure becomes an `{error}` outcome, per\n * the \"preflight throws, per-child failure does not\" split documented in\n * the module header.\n */\n private async spawnOneChild(input: SpawnOneChildInput): Promise<SpawnPlanChildOutcome> {\n const {\n runId,\n operationId,\n agentConfig,\n identity,\n capabilityCeiling,\n excludeTools,\n teamPackageModels,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd,\n parentSessionId,\n parentForkSource,\n sessionScope,\n environment,\n parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs,\n artifacts,\n artifactDir,\n availableModels,\n parentModel,\n runtime,\n runtimes,\n skillProjectionCache,\n } = input;\n const cwd = taskInput.cwd ?? fallbackCwd;\n const task = taskInput.task ?? '';\n const effectiveContext = resolveEffectiveContext(taskInput, agentConfig);\n const effectiveRuntime = taskInput.runtime ?? runtime ?? agentConfig.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agentConfig,\n effectiveRuntime,\n parentModel,\n availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && availableModels !== undefined && !modelSelection.model) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: `No authenticated model is available for '${agentConfig.name}'. Checked: ${[\n modelSelection.primaryModel,\n ...modelSelection.fallbackModels,\n ].join(', ')}.`,\n };\n }\n\n let skillProjection: ChildSkillProjection;\n try {\n skillProjection = this.projectConfiguredSkills(\n agentConfig,\n cwd,\n fallbackCwd,\n effectiveRuntime,\n skillProjectionCache,\n );\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n const warnings = [\n ...skillProjection.warnings,\n ...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools),\n ];\n const warning = warnings.length > 0 ? warnings.join(' ') : undefined;\n\n // Persist every Pi child's own transcript so a later explicit restore can\n // continue it. External runtimes retain their existing session behavior.\n const spawnInput: AsyncSubagentSpawnInput = {\n runId,\n ...(operationId ? { operationId } : {}),\n agent: agentConfig.name,\n ...(taskInput.inlineAgent ? { inlineAgent: taskInput.inlineAgent } : {}),\n task,\n cwd,\n environment,\n childIndex,\n fanout,\n sessionScope,\n ...(parentSessionFile ? { parentSessionFile } : {}),\n piArgs: {\n ...(taskInput.sessionFile ? { sessionFile: taskInput.sessionFile } : {}),\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(effectiveContext === CONTEXT_FORK && parentSessionId ? { parentSessionId } : {}),\n },\n ...(handshakeTimeoutMs !== undefined ? { handshakeTimeoutMs } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(artifactDir !== undefined ? { artifactDir } : {}),\n // Per-call `runtime` wins over the agent's own default, matching how\n // `model` and `context` already resolve.\n runtime: effectiveRuntime,\n runtimes,\n };\n\n const admission = this.admission;\n if (!admission) throw new Error('Doom Team spawn admission is not configured.');\n let ticket: AdmissionTicket;\n try {\n ticket = await admission.admit({\n sessionScope,\n maxLiveRuns,\n timeoutMs: admissionTimeoutMs,\n ...(this.reportConcurrencyEvent ? { report: this.reportConcurrencyEvent } : {}),\n });\n } catch (error) {\n return {\n agent: agentConfig.name,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n }\n\n try {\n if (isPiRuntime(effectiveRuntime)) {\n if (!this.nativeRuns || !this.childSessions?.get())\n throw new Error('The native Team run coordinator is unavailable.');\n const scope = sessionScope;\n const source: DoomChildSessionSource = taskInput.sessionFile\n ? { kind: 'v4-restore', sessionFile: taskInput.sessionFile }\n : effectiveContext === CONTEXT_FORK\n ? (parentForkSource ??\n (() => {\n throw new Error('Native fork input requires an immutable terminal Pi snapshot.');\n })())\n : { kind: 'fresh' };\n const intercom = this.teamChannel?.createNativeChildIntercom({\n rootSessionId: scope.rootSessionId,\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n runId,\n childIndex,\n task: { id: runId, subject: task },\n });\n let child: Awaited<ReturnType<NativeRunCoordinatorContract['start']>>;\n try {\n child = await this.nativeRuns.start(\n parentSessionId ?? scope.rootSessionId,\n {\n runId,\n parentSessionId: parentSessionId ?? scope.rootSessionId,\n scope,\n source,\n agent: agentConfig.name,\n task,\n cwd,\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(typeof agentConfig.thinking === 'string' ? { thinking: agentConfig.thinking } : {}),\n ...(skillProjection.systemPrompt ? { systemPrompt: skillProjection.systemPrompt } : {}),\n systemPromptMode: agentConfig.systemPromptMode,\n ...(agentConfig.extensions ? { extensions: agentConfig.extensions } : {}),\n ...(agentConfig.subagentOnlyExtensions\n ? { subagentOnlyExtensions: agentConfig.subagentOnlyExtensions }\n : {}),\n ...(agentConfig.tools ? { tools: agentConfig.tools } : {}),\n ...(excludeTools ? { excludeTools } : {}),\n ...(agentConfig.skills ? { skills: agentConfig.skills } : {}),\n ...(agentConfig.mcpDirectTools ? { mcpDirectTools: agentConfig.mcpDirectTools } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(intercom ? { intercom } : {}),\n environment,\n },\n // Carried beside the core child request rather than inside it, so a\n // Team-only concept does not widen the shared child contract.\n { identity: identity.identity, inline: identity.inline },\n );\n } catch (error) {\n intercom?.dispose?.();\n throw error;\n }\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: child.runId,\n ...(warning ? { warning } : {}),\n };\n }\n const result: AsyncSubagentSpawnResult = await this.spawner.spawn(spawnInput);\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: result.runId,\n pid: result.pid,\n ...(warning ? { warning } : {}),\n };\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n } finally {\n // Once spawn resolves, direct child events make the run visible to the\n // injected live counter, so only the reservation is released here.\n ticket.release();\n }\n }\n\n async spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult> {\n const tasks = this.resolveTaskList(request);\n const fanout = tasks.length > 1;\n const teamPackageExcludeTools = this.resolveTeamPackageExcludeTools();\n const teamPackageModels = this.resolveTeamPackageModels();\n const capabilityCeiling = this.policies.resolve();\n\n // PREFLIGHT - all before any spawn call, so a declared plan that cannot\n // run at all produces one refusal, not a partial fan-out.\n const currentDepth = request.currentDepth ?? resolveCurrentSubagentDepth();\n const depthCheck = preflightSubagentDepth(currentDepth, config);\n if (depthCheck.error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n depthCheck.error,\n false,\n 'Give each child a self-contained task within the Team package policy.',\n );\n }\n\n const maxTasks = config.parallel?.maxTasks ?? DEFAULT_PARALLEL_MAX_TASKS;\n if (tasks.length > maxTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run requested ${tasks.length} tasks, but at most ${maxTasks} may be declared in one call. Concurrency throttles how fast they start, not how many run.`,\n false,\n 'Send at most that many requests in this call and wait for them, or raise parallel.maxTasks in the subagent config. Splitting the same width across extra calls does not raise the live-child ceiling.',\n );\n }\n\n for (const taskInput of tasks) {\n if (!taskInput.task?.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run request for '${taskInput.agent}' requires a nonblank task.`,\n false,\n 'Provide a self-contained nonblank task.',\n );\n }\n if (taskInput.inlineAgent && !taskInput.inlineAgent.systemPrompt.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Inline agent '${taskInput.agent}' requires a nonblank system prompt.`,\n false,\n 'Provide a focused read-only exploration role.',\n );\n }\n }\n\n const resolvedAgentCache = new Map<string, ExecutableAgentConfig>();\n const resolvedAgents = tasks.map((taskInput) => {\n if (taskInput.inlineAgent) {\n return this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n }\n const cacheKey = [\n request.agentScope,\n canonicalizeDiscoveryCwd(taskInput.cwd ?? request.cwd),\n taskInput.agent,\n ].join('\\0');\n const cached = resolvedAgentCache.get(cacheKey);\n if (cached) return cached;\n const resolved = this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n resolvedAgentCache.set(cacheKey, resolved);\n return resolved;\n });\n for (const [index, taskInput] of tasks.entries()) {\n const effectiveContext = resolveEffectiveContext(taskInput, resolvedAgents[index]!);\n const runtime = taskInput.runtime ?? request.runtime ?? resolvedAgents[index]!.runtime ?? PI_RUNTIME_NAME;\n if (effectiveContext === CONTEXT_FORK) {\n if (!isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context requires ${PI_RUNTIME_REQUIREMENT} for '${taskInput.agent}'.`,\n false,\n 'Use a Pi agent for fork context or explicitly request a fresh run.',\n );\n }\n if (!request.parentForkSource) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context is unavailable for '${taskInput.agent}': ${describeForkFailure(request.parentForkFailure)}.`,\n false,\n 'Use an active Pi session with a completed parent turn or explicitly request a fresh run.',\n );\n }\n }\n }\n\n if (request.preallocatedRunIds && request.preallocatedRunIds.length !== tasks.length) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_OPERATION_CONFLICT,\n 'The operation journal run-id count does not match the request count.',\n false,\n 'Submit the run as a new tool call.',\n );\n }\n const runIds = request.preallocatedRunIds ?? tasks.map(() => this.generateRunId());\n // Minted here because this is the one funnel every spawn path reaches, and\n // because the inline flag and the resolved agent name are both in hand. A\n // restore carries its identity in, and repoints the existing claim rather\n // than burning a second number on the same logical agent.\n const identities = tasks.map((taskInput, index) => {\n const inline = taskInput.inlineAgent !== undefined;\n if (!taskInput.identity) {\n return claimAgentIdentity(request.sessionScope, {\n agent: resolvedAgents[index]!.name,\n inline,\n runId: runIds[index]!,\n });\n }\n adoptAgentIdentity(request.sessionScope, taskInput.identity, runIds[index]!);\n return {\n identity: taskInput.identity,\n name: '',\n role: roleFromAgent(resolvedAgents[index]!.name),\n number: 0,\n inline,\n persisted: true,\n };\n });\n const runtimes = resolveRuntimeTable(config.runtimes);\n for (const [index, taskInput] of tasks.entries()) {\n const agent = resolvedAgents[index]!;\n const cwd = taskInput.cwd ?? request.cwd;\n this.validateCwd(cwd);\n const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agent,\n runtime,\n request.parentModel,\n request.availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && request.availableModels !== undefined && !modelSelection.model) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_MODEL_UNAVAILABLE,\n `No authenticated model is available for '${agent.name}'.`,\n false,\n 'Authenticate the requested model or choose an available model.',\n );\n }\n if (taskInput.inlineAgent && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Inline agent '${taskInput.agent}' requires ${PI_RUNTIME_REQUIREMENT} to enforce its read-only tools.`,\n false,\n 'Remove the runtime override or use a discovered external-runtime agent without inlineAgent.',\n );\n }\n if (capabilityCeiling && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Runtime '${runtime}' cannot enforce the active capability ceiling.`,\n false,\n `Use ${PI_RUNTIME_REQUIREMENT} while plan mode or another capability ceiling is active.`,\n );\n }\n if (!isPiRuntime(runtime)) {\n let command: string;\n try {\n command = resolveRuntimeLaunch(runtime, runtimes, { prompt: taskInput.task ?? '', cwd }).command;\n } catch (error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n error instanceof Error ? error.message : String(error),\n false,\n `Configure a valid external runtime or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n if (!this.executableAvailable(command)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n `Executable '${command}' for runtime '${runtime}' is unavailable.`,\n false,\n `Install the executable, configure its absolute path, or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n }\n }\n const concurrency = fanout\n ? (request.concurrency ?? config.parallel?.concurrency ?? DEFAULT_PARALLEL_CONCURRENCY)\n : 1;\n const maxLiveRuns = Math.max(1, config.parallel?.maxLiveRuns ?? DEFAULT_MAX_LIVE_RUNS);\n const admissionTimeoutMs = config.parallel?.admissionTimeoutMs ?? DEFAULT_ADMISSION_TIMEOUT_MS;\n\n const skillProjectionCache = new Map<string, ChildSkillProjection>();\n const factories = tasks.map(\n (taskInput, childIndex) => () =>\n this.spawnOneChild({\n runId: runIds[childIndex]!,\n operationId: request.operationId,\n agentConfig: resolvedAgents[childIndex]!,\n identity: identities[childIndex]!,\n excludeTools: teamPackageExcludeTools,\n teamPackageModels,\n capabilityCeiling,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd: request.cwd,\n parentSessionId: request.parentSessionId,\n parentForkSource: request.parentForkSource,\n sessionScope: request.sessionScope,\n environment: request.environment ?? {},\n parentSessionFile: request.parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs: config.handshakeTimeoutMs,\n artifacts: request.artifacts,\n artifactDir: config.artifactDir,\n availableModels: request.availableModels,\n parentModel: request.parentModel,\n runtime: request.runtime,\n runtimes,\n skillProjectionCache,\n }),\n );\n\n const settled = await runWithConcurrency(factories, concurrency, this.reportConcurrencyEvent);\n // `spawnOneChild` never rejects (it catches its own spawn failure into\n // an `{error}` outcome), so `runWithConcurrency` never sees a rejection\n // here - this unwrap is defensive, not a real branch.\n const outcomes = settled.map((outcome, index) =>\n outcome.status === 'fulfilled'\n ? outcome.value\n : {\n agent: resolvedAgents[index]!.name,\n identity: identities[index]!.identity,\n inline: identities[index]!.inline,\n task: tasks[index]!.task ?? '',\n childIndex: index,\n error: outcome.reason instanceof Error ? outcome.reason.message : String(outcome.reason),\n },\n );\n\n return { outcomes };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAe/B,SAAS,oBAAoB,aAAwD;CACnF,IAAI,CAAC,aAAa,KAAK,GAAG,OAAO;CACjC,IAAI;EACF,GAAG,WAAW,aAAa,GAAG,UAAU,IAAI;EAC5C,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAoBA,MAAM,oBAAiF;CACrF,wBAAwB;CACxB,WAAW;CACX,aAAa;CACb,uBAAuB;CACvB,mBAAmB;CACnB,iBAAiB;AACnB;AAEA,SAAgB,oBAAoB,QAAyE;CAC3G,OAAO,SAAS,kBAAkB,UAAU;AAC9C;;;;;;;;AASA,SAAgB,kBACd,UACyG;CACzG,IAAI,CAAC,UAAU,OAAO,EAAE,mBAAmB,uBAAuB;CAClE,IAAI,UAAU,UAAU,OAAO,EAAE,kBAAkB,SAAS;CAC5D,I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,QAAQ;GAC1B,cAAc,QAAQ;GACtB,aAAa,QAAQ,eAAe,CAAC;GACrC,mBAAmB,QAAQ;GAC3B;GACA;GACA,oBAAoB,OAAO;GAC3B,WAAW,QAAQ;GACnB,aAAa,OAAO;GACpB,iBAAiB,QAAQ;GACzB,aAAa,QAAQ;GACrB,SAAS,QAAQ;GACjB;GACA;EACF,CAAC,CACL;EAmBA,OAAO,EAAE,WAbQ,MAJK,mBAAmB,WAAW,aAAa,KAAK,sBAAsB,EAAA,CAInE,KAAK,SAAS,UACrC,QAAQ,WAAW,cACf,QAAQ,QACR;GACE,OAAO,eAAe,MAAM,CAAE;GAC9B,UAAU,WAAW,MAAM,CAAE;GAC7B,QAAQ,WAAW,MAAM,CAAE;GAC3B,MAAM,MAAM,MAAM,CAAE,QAAQ;GAC5B,YAAY;GACZ,OAAO,QAAQ,kBAAkB,QAAQ,QAAQ,OAAO,UAAU,OAAO,QAAQ,MAAM;EACzF,CAGU,EAAE;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/spawnPlan/index.ts"],"sourcesContent":["/**\n * Turns `subagent` tool params into a resolved sequence of\n * `AsyncSubagentSpawner.spawn()` calls: SINGLE (one child), PARALLEL (N\n * children, bounded by `concurrency`).\n *\n * WHY THIS IS NEW LOGIC, NOT COMPOSITION:\n * `AsyncSubagentSpawner` is deliberately a per-child primitive -\n * `childIndex`/`fanout` arrive as inputs it does not derive (see that\n * module's header). Nothing else in this package decides \"how many\n * children, in what order, at what `childIndex`\" from a `subagent` tool\n * call. That decision is this file's job.\n *\n * PREFLIGHT, ALL-OR-NOTHING:\n * `resolveCurrentSubagentDepth`/`preflightSubagentDepth` run once, before\n * anything spawns. A depth refusal throws - a declared plan that cannot run\n * at all should produce one clear refusal, not a partial fan-out.\n * `AgentDiscoveryService.find` resolves and validates every child's agent\n * name up front too, for the same reason: a typo'd agent name is a\n * preflight failure named at the tool boundary, not a spawn error surfacing\n * deep inside one child while its siblings are already running.\n *\n * ONCE THE BATCH HAS STARTED, PER-CHILD FAILURE IS A RESULT, NOT AN\n * EXCEPTION:\n * `runWithConcurrency` never lets one child's rejection abort its siblings,\n * matching `failFast` being opt-in in the schema, not the default. Every\n * child gets an outcome - `{runId, pid}` on success, `{error}` on failure -\n * and the caller (`subagentTool.ts`) decides how to report a mixed batch.\n *\n * WHAT THIS DOES NOT WIRE YET, AND WHY - FLAGGED, NOT SILENTLY GUESSED:\n * - `maxSubagentSpawnsPerSession` (`spawn-budget.ts`) is NOT enforced here.\n * `preflightSpawnBudget` needs a durable, session-scoped `SpawnBudgetStore`\n * that accumulates spend ACROSS separate tool calls in the same session;\n * inventing a fresh store per call would never track real spend and would\n * be worse than not checking at all (false confidence). Wiring this needs\n * a real session-scoped store owned by a lifecycle-bound service - a\n * follow-up, not guessed here.\n * - Fork context is resolved here and requires a captured persisted Pi source;\n * unavailable or non-Pi fork requests fail closed rather than becoming fresh\n * launches.\n * - Per-task overrides with no direct `BuildPiArgsInput` field confirmed yet\n * (`skill`, `toolBudget`, `turnBudget`, `outputSchema`/structured output,\n * `acceptance`, `output`/`outputMode`) are not mapped into `piArgs` for\n * v1. Each child still gets its resolved `AgentConfig`'s own defaults\n * (`systemPromptMode`, `inheritProjectContext`, `inheritSkills`,\n * `systemPrompt`) - not nothing, just not every param override yet.\n *\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type {\n DoomChildSessionScope,\n DoomChildSessionSource,\n DoomChildSessionServiceProvider,\n DoomChildSessionTerminalPiForkSource,\n DoomChildSessionV4ForkSource,\n} from '@agimon-ai/doompi-core/child';\nimport type { SessionManager } from '@earendil-works/pi-coding-agent';\n\nimport type { InlineAgent } from '../../schemas/subagentTool';\nimport {\n type ResolvedSubagentCapabilityCeiling,\n SubagentCapabilityPolicyStore,\n} from '../../schemas/team/capabilityCeiling';\nimport type { AgentConfig, AgentScope, AgentDiscoveryContract } from '../../types/agent';\nimport { PI_RUNTIME_NAME } from '../../types/environment';\nimport { type AdmissionGateContract, type AdmissionTicket, DEFAULT_ADMISSION_TIMEOUT_MS } from '../admissionGate';\nimport { resolveActiveTeamModelSpecs, resolveActiveTeamPackageConfig } from '../agentDiscovery';\nimport { adoptAgentIdentity, type AgentIdentity, claimAgentIdentity, roleFromAgent } from '../agentIdentity';\nimport { canonicalizeDiscoveryCwd } from '../agentProjectRoot';\nimport { buildSkillInjection, type SkillDiscoveryContract } from '../agentSkills';\nimport type {\n AsyncSubagentSpawnInput,\n AsyncSubagentSpawnResult,\n AsyncSubagentSpawnerContract,\n} from '../asyncExecution';\nimport type { ExtensionConfig } from '../config';\nimport { preflightSubagentDepth, resolveCurrentSubagentDepth } from '../depthGuard';\nimport { DoomTeamExpectedError } from '../errors';\nimport type { McpDirectToolResolver } from '../mcpDirectToolAllowlist';\nimport { type AvailableModelInfo, type ParentModel, selectAvailableModel } from '../modelFallback';\nimport type { NativeRunCoordinatorContract } from '../nativeRunCoordinator';\nimport type { NativeTeamChannelContract } from '../nativeTeamChannel';\nimport { isPiRuntime, type RuntimeTable, resolveRuntimeLaunch, resolveRuntimeTable } from '../runtimeRegistry';\nimport { type ConcurrencyEventReporter, runWithConcurrency } from '../runWithConcurrency';\n\nconst CONTEXT_FRESH = 'fresh' as const;\nconst CONTEXT_FORK = 'fork' as const;\nconst PI_RUNTIME_REQUIREMENT = `runtime \"${PI_RUNTIME_NAME}\"`;\n\ntype SessionForkCaptureMode = 'tool' | 'settled';\n\nexport interface SessionForkSource {\n readonly sessionFile?: string;\n readonly leafId: string;\n readonly terminalSource: DoomChildSessionTerminalPiForkSource;\n}\n\nexport type SessionForkSourceManager = Pick<\n SessionManager,\n 'getSessionFile' | 'getSessionId' | 'getLeafId' | 'getLeafEntry' | 'getHeader' | 'getBranch'\n>;\n\nfunction readableSessionFile(sessionFile: string | undefined): sessionFile is string {\n if (!sessionFile?.trim()) return false;\n try {\n fs.accessSync(sessionFile, fs.constants.R_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Why a capture reports a reason instead of a bare `undefined`.\n *\n * Five distinct conditions used to collapse into one `undefined`, and the\n * caller then asserted a cause it had never tested. That is how a missing\n * `captureForkSource` on the headless facet spent a long time looking like a\n * session-format problem. The reason is carried to the throw site so the error\n * names the condition that actually fired.\n */\nexport type ForkCaptureFailure = 'no-leaf' | 'no-header' | 'unsupported-version' | 'branch-mismatch' | 'no-session-id';\n\nexport type ForkCaptureResult =\n | { readonly ok: true; readonly source: SessionForkSource }\n | { readonly ok: false; readonly reason: ForkCaptureFailure };\n\n/** Either host's capture output, plus the absent case when no capture is installed. */\nexport type ParentForkCapture = ForkCaptureResult | DoomChildSessionV4ForkSource | undefined;\n\nconst FORK_FAILURE_TEXT: Record<ForkCaptureFailure | 'no-capture-installed', string> = {\n 'no-capture-installed': 'this host installed no fork-source capture',\n 'no-leaf': 'the parent session has no entry to branch from',\n 'no-header': 'the parent session has no readable header',\n 'unsupported-version': 'the parent session format cannot be forked',\n 'branch-mismatch': 'the parent branch did not resolve to its own leaf',\n 'no-session-id': 'the parent session has no identity',\n};\n\nexport function describeForkFailure(reason: ForkCaptureFailure | 'no-capture-installed' | undefined): string {\n return reason ? FORK_FAILURE_TEXT[reason] : 'the parent session has no capturable branch';\n}\n\n/**\n * Map a captured parent branch onto the spawn request's fork fields.\n *\n * `parentSessionFile` and `parentLeafId` describe a terminal Pi capture only. A\n * v4 source already carries its own file and branch, so flattening it into\n * those fields would describe it in the wrong vocabulary and lose the branch.\n */\nexport function forkRequestFields(\n captured: ParentForkCapture,\n): Pick<SpawnPlanRequest, 'parentForkSource' | 'parentSessionFile' | 'parentLeafId' | 'parentForkFailure'> {\n if (!captured) return { parentForkFailure: 'no-capture-installed' };\n if ('kind' in captured) return { parentForkSource: captured };\n if (!captured.ok) return { parentForkFailure: captured.reason };\n const { source } = captured;\n return {\n parentForkSource: source.terminalSource,\n ...(source.sessionFile ? { parentSessionFile: source.sessionFile } : {}),\n parentLeafId: source.leafId,\n };\n}\n\n/** Capture an immutable parent branch while excluding an assistant turn whose tool is still executing. */\nexport function captureSessionForkSource(\n manager: SessionForkSourceManager,\n mode: SessionForkCaptureMode,\n): ForkCaptureResult {\n const leaf = manager.getLeafEntry();\n const leafId =\n mode === 'tool' && leaf?.type === 'message' && leaf.message.role === 'assistant'\n ? leaf.parentId\n : (leaf?.id ?? manager.getLeafId());\n const header = manager.getHeader();\n if (!leafId) return { ok: false, reason: 'no-leaf' };\n if (header?.type !== 'session') return { ok: false, reason: 'no-header' };\n if (header.version !== 3) return { ok: false, reason: 'unsupported-version' };\n\n const branch = manager.getBranch(leafId);\n if (branch.at(-1)?.id !== leafId) return { ok: false, reason: 'branch-mismatch' };\n const sourceSessionId = manager.getSessionId();\n if (!sourceSessionId.trim()) return { ok: false, reason: 'no-session-id' };\n const terminalSource: DoomChildSessionTerminalPiForkSource = Object.freeze({\n kind: 'terminal-pi-fork',\n sourceSessionId,\n sourceLeafId: leafId,\n snapshotJsonl: `${[header, ...branch].map((record) => JSON.stringify(record)).join('\\n')}\\n`,\n });\n const sessionFile = manager.getSessionFile();\n return {\n ok: true,\n source: {\n leafId,\n terminalSource,\n ...(readableSessionFile(sessionFile) ? { sessionFile } : {}),\n },\n };\n}\n\nexport interface SpawnPlanTaskInput {\n agent: string;\n inlineAgent?: InlineAgent;\n task?: string;\n cwd?: string;\n model?: string;\n runtime?: string;\n context?: typeof CONTEXT_FRESH | typeof CONTEXT_FORK;\n /** An existing child transcript to continue instead of starting fresh. */\n sessionFile?: string;\n /** An identity inherited by a restore. Absent for a fresh run, which mints one. */\n identity?: string;\n}\n\ntype ExecutableAgentConfig = Pick<\n AgentConfig,\n | 'name'\n | 'defaultContext'\n | 'defaultReads'\n | 'extensions'\n | 'fallbackModels'\n | 'inheritProjectContext'\n | 'inheritSkills'\n | 'mcpDirectTools'\n | 'model'\n | 'modelSource'\n | 'runtime'\n | 'skills'\n | 'skillPath'\n | 'subagentOnlyExtensions'\n | 'systemPrompt'\n | 'systemPromptMode'\n | 'thinking'\n | 'tools'\n>;\n\nfunction resolveEffectiveContext(\n taskInput: SpawnPlanTaskInput,\n agent: Pick<ExecutableAgentConfig, 'defaultContext'>,\n): typeof CONTEXT_FRESH | typeof CONTEXT_FORK {\n return taskInput.sessionFile ? CONTEXT_FRESH : (taskInput.context ?? agent.defaultContext ?? CONTEXT_FRESH);\n}\n\nexport interface SpawnPlanRequest {\n /** SINGLE mode: exactly one child. Mutually exclusive with `tasks`. */\n single?: SpawnPlanTaskInput;\n /** PARALLEL mode: N children, fanned out. Mutually exclusive with `single`. */\n tasks?: SpawnPlanTaskInput[];\n /** Max children in flight at once for PARALLEL mode. Ignored for SINGLE. Defaults to `config.parallel.concurrency` or 4. */\n concurrency?: number;\n /** Fallback cwd for any task that omits its own. */\n cwd: string;\n agentScope: AgentScope;\n /** Explicit owner scope forwarded to every child runtime. */\n sessionScope: DoomChildSessionScope;\n /** Environment admitted to this parent session, forwarded only to native children. */\n environment?: Readonly<Record<string, string | undefined>>;\n /** Parent identity retained for delegation correlation. */\n parentSessionId?: string;\n /** Immutable parent branch used by native fork children. */\n parentForkSource?: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource;\n /** Why no parent branch was captured, so a refused fork can name its cause. */\n parentForkFailure?: ForkCaptureFailure | 'no-capture-installed';\n /** External-runtime parent source fields. */\n parentSessionFile?: string;\n parentLeafId?: string;\n artifacts?: boolean;\n /** Authenticated models reported by the live parent host. Undefined for callers without a host context. */\n availableModels?: AvailableModelInfo[];\n /** The live parent model, forwarded only for Pi child selection. */\n parentModel?: ParentModel;\n /** Overrides `resolveCurrentSubagentDepth()`'s own env read - a test seam, not a runtime path. */\n currentDepth?: number;\n /** Which runtime executes every child of this request. Defaults per agent, then to `pi`. */\n runtime?: string;\n /** Stable Pi tool-call identity used to correlate this batch. */\n operationId?: string;\n /** Run ids persisted by the operation journal before any process starts. */\n preallocatedRunIds?: string[];\n}\n\n/** Everything one child spawn needs. An object because this reached ten positional parameters. */\ninterface SpawnOneChildInput {\n runId: string;\n operationId?: string;\n agentConfig: ExecutableAgentConfig;\n identity: AgentIdentity;\n excludeTools?: string[];\n teamPackageModels?: string[];\n capabilityCeiling?: ResolvedSubagentCapabilityCeiling;\n taskInput: SpawnPlanTaskInput;\n childIndex: number;\n fanout: boolean;\n fallbackCwd: string;\n parentSessionId: string | undefined;\n parentForkSource: DoomChildSessionTerminalPiForkSource | DoomChildSessionV4ForkSource | undefined;\n sessionScope: DoomChildSessionScope;\n environment: Readonly<Record<string, string | undefined>>;\n parentSessionFile: string | undefined;\n maxLiveRuns: number;\n admissionTimeoutMs: number;\n handshakeTimeoutMs: number | undefined;\n artifacts: boolean | undefined;\n artifactDir: ExtensionConfig['artifactDir'];\n availableModels: AvailableModelInfo[] | undefined;\n parentModel: ParentModel | undefined;\n runtime: string | undefined;\n runtimes: RuntimeTable;\n skillProjectionCache: Map<string, ChildSkillProjection>;\n}\n\nexport interface SpawnPlanChildOutcome {\n agent: string;\n task: string;\n /** This spawn's position among its siblings. Always 0 for SINGLE mode. */\n childIndex: number;\n runId?: string;\n /** The generated addressable identity, for example `alan-reviewer-3`. */\n identity?: string;\n /** True when this run came from a one-shot inline agent definition. */\n inline?: boolean;\n pid?: number;\n error?: string;\n warning?: string;\n}\n\nexport interface SpawnPlanResult {\n outcomes: SpawnPlanChildOutcome[];\n}\n\nconst DEFAULT_PARALLEL_CONCURRENCY = 4;\n/**\n * Hard ceiling on how many children one PARALLEL call may DECLARE.\n *\n * `concurrency` does NOT bound this, and cannot: `spawnOneChild` resolves as\n * soon as its child confirms it started, and the child then runs detached. So\n * `runWithConcurrency` throttles how fast children are STARTED, not how many\n * are running - `{tasks: [8], concurrency: 4}` ends up with eight live model\n * processes, not four. 8 matches the sibling implementation's\n * `PI_TEAM_MATE_MAX_PARALLEL`.\n *\n * This is a per-call declaration limit and nothing more. What actually bounds\n * live children across concurrent calls is `AdmissionGate`\n * (`runs/shared/admissionGate.ts`), which every spawn passes through.\n */\nconst DEFAULT_PARALLEL_MAX_TASKS = 8;\n/**\n * Process-wide ceiling on children ALIVE at once.\n *\n * Defaulted to `DEFAULT_PARALLEL_MAX_TASKS` so a single call's width is\n * exactly what it was before the gate existed; the only behaviour that\n * changes is that a second overlapping call now queues instead of stacking\n * another full batch on the machine. Raise or lower it with\n * `parallel.maxLiveRuns` in the subagent config, and bound the queue wait with\n * `parallel.admissionTimeoutMs`. It is deliberately NOT derived from the host's\n * cores or memory: a number measured on one machine is not a default.\n */\nconst DEFAULT_MAX_LIVE_RUNS = DEFAULT_PARALLEL_MAX_TASKS;\nconst INLINE_AGENT_TOOLS = ['read', 'grep', 'find', 'ls'] as const;\n\nfunction appendPromptSection(prompt: string, section: string): string {\n if (!section) return prompt;\n return prompt ? `${prompt}\\n\\n${section}` : section;\n}\n\nfunction bestEffortRuntimeWarnings(\n runtime: string,\n agentConfig: ExecutableAgentConfig,\n excludeTools: string[] | undefined,\n): string[] {\n if (isPiRuntime(runtime)) return [];\n\n const warnings = [`Runtime '${runtime}' does not load Pi child extensions or hooks; launched best effort.`];\n const unsupportedResources = [\n ...(agentConfig.tools !== undefined || agentConfig.mcpDirectTools?.length ? ['tools'] : []),\n ...(agentConfig.skills?.length || agentConfig.skillPath?.length ? ['skills'] : []),\n ...(agentConfig.extensions !== undefined || agentConfig.subagentOnlyExtensions?.length ? ['extensions'] : []),\n ];\n if (unsupportedResources.length > 0) {\n warnings.push(\n `Doom Team cannot project or enforce configured Pi ${unsupportedResources.join(', ')} on runtime '${runtime}'.`,\n );\n }\n if (agentConfig.skills?.length) {\n warnings.push(`Configured skills were not injected: ${agentConfig.skills.join(', ')}.`);\n }\n if (excludeTools?.length) {\n warnings.push(\n `Runtime '${runtime}' cannot enforce Team package tool exclusions; launched best effort for: ${excludeTools.join(', ')}.`,\n );\n }\n return warnings;\n}\n\ninterface ChildSkillProjection {\n systemPrompt: string;\n requireReadTool: boolean;\n warnings: string[];\n}\n\ninterface ResolvedModelSelection {\n primaryModel: string | undefined;\n fallbackModels: string[];\n model: string | undefined;\n}\n\nfunction resolvedModelSelection(\n taskInput: SpawnPlanTaskInput,\n agentConfig: Pick<ExecutableAgentConfig, 'model' | 'modelSource' | 'fallbackModels'>,\n runtime: string,\n parentModel: ParentModel | undefined,\n availableModels: AvailableModelInfo[] | undefined,\n teamPackageModels: string[] | undefined,\n): ResolvedModelSelection {\n const parentModelId =\n isPiRuntime(runtime) && parentModel && availableModels !== undefined\n ? `${parentModel.provider}/${parentModel.id}`\n : undefined;\n const agentModels = [\n ...(agentConfig.modelSource?.scope === 'package' ? [] : [agentConfig.model]),\n ...(agentConfig.fallbackModels ?? []),\n ];\n const ordered = isPiRuntime(runtime)\n ? [taskInput.model, ...agentModels, ...(teamPackageModels ?? []), parentModelId]\n : [taskInput.model, ...agentModels, ...(teamPackageModels ?? [])];\n const candidates = ordered.filter((candidate): candidate is string => Boolean(candidate?.trim()));\n const [primaryModel, ...fallbackModels] = candidates;\n return {\n primaryModel,\n fallbackModels,\n model: selectAvailableModel(primaryModel, fallbackModels, availableModels),\n };\n}\n\nexport interface SpawnPlannerContract {\n /**\n * Resolves the plan and spawns every child. Throws on any PREFLIGHT\n * failure (bad request shape, depth exceeded, unknown agent) before\n * anything spawns. Never throws for an individual child's spawn failure\n * once the batch has started - that is a `{error}` outcome instead.\n */\n spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult>;\n}\n\nconst ERROR_CODE_AGENT_NOT_FOUND = 'agent_not_found' as const;\nconst ERROR_CODE_INVALID_REQUEST = 'invalid_request' as const;\nconst ERROR_CODE_MODEL_UNAVAILABLE = 'model_unavailable' as const;\nconst ERROR_CODE_OPERATION_CONFLICT = 'operation_conflict' as const;\nconst ERROR_CODE_RUNTIME_UNAVAILABLE = 'runtime_unavailable' as const;\nconst ERROR_CODE_UNSUPPORTED_CONTEXT = 'unsupported_context' as const;\nconst ERROR_CODE_UNSUPPORTED_OPERATION = 'unsupported_operation' as const;\n\nexport class SpawnPlanner implements SpawnPlannerContract {\n constructor(\n private readonly agents: AgentDiscoveryContract,\n private readonly spawner: AsyncSubagentSpawnerContract,\n private readonly policies: SubagentCapabilityPolicyStore = new SubagentCapabilityPolicyStore(),\n private readonly skills?: SkillDiscoveryContract,\n private readonly reportConcurrencyEvent?: ConcurrencyEventReporter,\n _mcpToolResolver?: McpDirectToolResolver,\n private readonly admission?: AdmissionGateContract,\n private readonly childSessions?: DoomChildSessionServiceProvider,\n private readonly nativeRuns?: NativeRunCoordinatorContract,\n private readonly teamChannel?: Pick<NativeTeamChannelContract, 'createNativeChildIntercom'>,\n ) {}\n\n protected generateRunId(): string {\n return crypto.randomUUID();\n }\n\n protected validateCwd(cwd: string): void {\n let stat: fs.Stats;\n try {\n stat = fs.statSync(cwd);\n } catch {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' does not exist.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n if (!stat.isDirectory()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Working directory '${cwd}' is not a directory.`,\n false,\n 'Retry with an existing directory.',\n );\n }\n }\n\n protected resolveTeamPackageExcludeTools(): string[] | undefined {\n return resolveActiveTeamPackageConfig()?.config.excludeTools;\n }\n\n protected resolveTeamPackageModels(): string[] | undefined {\n return resolveActiveTeamModelSpecs();\n }\n\n protected executableAvailable(command: string): boolean {\n if (path.isAbsolute(command) || command.includes(path.sep)) {\n try {\n fs.accessSync(command, fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n }\n return (process.env.PATH ?? '')\n .split(path.delimiter)\n .filter(Boolean)\n .some((directory) => {\n try {\n fs.accessSync(path.join(directory, command), fs.constants.X_OK);\n return true;\n } catch {\n return false;\n }\n });\n }\n\n private resolveTaskList(request: SpawnPlanRequest): SpawnPlanTaskInput[] {\n const hasSingle = request.single !== undefined;\n const hasTasks = request.tasks !== undefined;\n if (hasSingle === hasTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires exactly one of internal single or tasks representations.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n if (hasSingle) return [request.single!];\n if (!request.tasks || request.tasks.length === 0) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n 'A run requires at least one entry in its requests collection.',\n false,\n 'Submit a non-empty requests array.',\n );\n }\n return request.tasks;\n }\n\n private resolveAgentOrThrow(name: string, cwd: string, scope: AgentScope) {\n const resolved = this.agents.find(cwd, scope, name);\n if (!resolved) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_AGENT_NOT_FOUND,\n `Unknown agent '${name}'.`,\n false,\n 'Call subagent({\"action\":\"agents\"}) and retry with an exact name.',\n );\n }\n return resolved;\n }\n\n private resolveExecutableAgent(taskInput: SpawnPlanTaskInput, cwd: string, scope: AgentScope): ExecutableAgentConfig {\n if (!taskInput.inlineAgent) return this.resolveAgentOrThrow(taskInput.agent, cwd, scope);\n return {\n name: taskInput.agent.trim(),\n systemPromptMode: 'append',\n inheritProjectContext: true,\n inheritSkills: false,\n systemPrompt: taskInput.inlineAgent.systemPrompt.trim(),\n tools: [...INLINE_AGENT_TOOLS],\n defaultContext: CONTEXT_FRESH,\n runtime: PI_RUNTIME_NAME,\n };\n }\n\n private projectDefaultReads(\n defaultReads: string[] | undefined,\n childCwd: string,\n agentName: string,\n ): ChildSkillProjection {\n if (!defaultReads?.length) return { systemPrompt: '', requireReadTool: false, warnings: [] };\n\n const seen = new Set<string>();\n const readablePaths: string[] = [];\n const missingPaths: string[] = [];\n for (const configuredPath of defaultReads) {\n const trimmed = configuredPath.trim();\n if (!trimmed) continue;\n const resolvedPath = path.isAbsolute(trimmed) ? path.normalize(trimmed) : path.resolve(childCwd, trimmed);\n const identity = canonicalizeDiscoveryCwd(resolvedPath);\n if (seen.has(identity)) continue;\n seen.add(identity);\n try {\n if (fs.statSync(resolvedPath).isFile()) readablePaths.push(resolvedPath);\n else missingPaths.push(resolvedPath);\n } catch {\n missingPaths.push(resolvedPath);\n }\n }\n\n const systemPrompt =\n readablePaths.length > 0\n ? [\n 'Read these configured paths before broad repository discovery:',\n ...readablePaths.map((readPath) => `- ${readPath}`),\n 'If a listed path does not provide enough context, name the concrete missing dependency before searching narrowly for it.',\n ].join('\\n')\n : '';\n return {\n systemPrompt,\n requireReadTool: readablePaths.length > 0,\n warnings:\n missingPaths.length > 0\n ? [`Agent '${agentName}' could not read optional default paths: ${missingPaths.join(', ')}.`]\n : [],\n };\n }\n\n private projectConfiguredSkills(\n agentConfig: ExecutableAgentConfig,\n childCwd: string,\n requestCwd: string,\n runtime: string,\n cache: Map<string, ChildSkillProjection>,\n ): ChildSkillProjection {\n const cacheKey = JSON.stringify([\n canonicalizeDiscoveryCwd(childCwd),\n canonicalizeDiscoveryCwd(requestCwd),\n runtime,\n agentConfig.name,\n agentConfig.systemPrompt,\n agentConfig.skills ?? [],\n agentConfig.skillPath ?? [],\n agentConfig.defaultReads ?? [],\n ]);\n const cached = cache.get(cacheKey);\n if (cached) return cached;\n\n if (!isPiRuntime(runtime)) {\n const projection = { systemPrompt: agentConfig.systemPrompt, requireReadTool: false, warnings: [] };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n const defaultReads = this.projectDefaultReads(agentConfig.defaultReads, childCwd, agentConfig.name);\n let skillInjection = '';\n let skillWarnings: string[] = [];\n if (agentConfig.skills?.length) {\n if (!this.skills) throw new Error('Skill discovery is unavailable for configured child skills.');\n const resolution = this.skills.resolveSkillsWithFallback(\n agentConfig.skills,\n childCwd,\n requestCwd,\n agentConfig.skillPath,\n requestCwd,\n );\n skillInjection = buildSkillInjection(resolution.resolved);\n skillWarnings =\n resolution.missing.length > 0\n ? [\n `Agent '${agentConfig.name}' could not resolve configured skills: ${resolution.missing.join(', ')}; launched with resolved skills only.`,\n ]\n : [];\n }\n\n const projection = {\n systemPrompt: appendPromptSection(\n appendPromptSection(agentConfig.systemPrompt, skillInjection),\n defaultReads.systemPrompt,\n ),\n requireReadTool: skillInjection.length > 0 || defaultReads.requireReadTool,\n warnings: [...skillWarnings, ...defaultReads.warnings],\n };\n cache.set(cacheKey, projection);\n return projection;\n }\n\n /**\n * Spawns exactly one child and returns its outcome. Shared by `spawn()`\n * (SINGLE/PARALLEL) and `spawnChain()`'s per-step/per-parallel-group-child\n * calls, so the `AsyncSubagentSpawnInput` mapping exists in exactly one\n * place. Never throws - a spawn failure becomes an `{error}` outcome, per\n * the \"preflight throws, per-child failure does not\" split documented in\n * the module header.\n */\n private async spawnOneChild(input: SpawnOneChildInput): Promise<SpawnPlanChildOutcome> {\n const {\n runId,\n operationId,\n agentConfig,\n identity,\n capabilityCeiling,\n excludeTools,\n teamPackageModels,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd,\n parentSessionId,\n parentForkSource,\n sessionScope,\n environment,\n parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs,\n artifacts,\n artifactDir,\n availableModels,\n parentModel,\n runtime,\n runtimes,\n skillProjectionCache,\n } = input;\n const cwd = taskInput.cwd ?? fallbackCwd;\n const task = taskInput.task ?? '';\n const effectiveContext = resolveEffectiveContext(taskInput, agentConfig);\n const effectiveRuntime = taskInput.runtime ?? runtime ?? agentConfig.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agentConfig,\n effectiveRuntime,\n parentModel,\n availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && availableModels !== undefined && !modelSelection.model) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: `No authenticated model is available for '${agentConfig.name}'. Checked: ${[\n modelSelection.primaryModel,\n ...modelSelection.fallbackModels,\n ].join(', ')}.`,\n };\n }\n\n let skillProjection: ChildSkillProjection;\n try {\n skillProjection = this.projectConfiguredSkills(\n agentConfig,\n cwd,\n fallbackCwd,\n effectiveRuntime,\n skillProjectionCache,\n );\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n const warnings = [\n ...skillProjection.warnings,\n ...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools),\n ];\n const warning = warnings.length > 0 ? warnings.join(' ') : undefined;\n\n // Persist every Pi child's own transcript so a later explicit restore can\n // continue it. External runtimes retain their existing session behavior.\n const spawnInput: AsyncSubagentSpawnInput = {\n runId,\n ...(operationId ? { operationId } : {}),\n agent: agentConfig.name,\n ...(taskInput.inlineAgent ? { inlineAgent: taskInput.inlineAgent } : {}),\n task,\n cwd,\n environment,\n childIndex,\n fanout,\n sessionScope,\n ...(parentSessionFile ? { parentSessionFile } : {}),\n piArgs: {\n ...(taskInput.sessionFile ? { sessionFile: taskInput.sessionFile } : {}),\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(effectiveContext === CONTEXT_FORK && parentSessionId ? { parentSessionId } : {}),\n },\n ...(handshakeTimeoutMs !== undefined ? { handshakeTimeoutMs } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(artifactDir !== undefined ? { artifactDir } : {}),\n // Per-call `runtime` wins over the agent's own default, matching how\n // `model` and `context` already resolve.\n runtime: effectiveRuntime,\n runtimes,\n };\n\n const admission = this.admission;\n if (!admission) throw new Error('Doom Team spawn admission is not configured.');\n let ticket: AdmissionTicket;\n try {\n ticket = await admission.admit({\n sessionScope,\n maxLiveRuns,\n timeoutMs: admissionTimeoutMs,\n ...(this.reportConcurrencyEvent ? { report: this.reportConcurrencyEvent } : {}),\n });\n } catch (error) {\n return {\n agent: agentConfig.name,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n }\n\n try {\n if (isPiRuntime(effectiveRuntime)) {\n if (!this.nativeRuns || !this.childSessions?.get())\n throw new Error('The native Team run coordinator is unavailable.');\n const scope = sessionScope;\n const source: DoomChildSessionSource = taskInput.sessionFile\n ? { kind: 'v4-restore', sessionFile: taskInput.sessionFile }\n : effectiveContext === CONTEXT_FORK\n ? (parentForkSource ??\n (() => {\n throw new Error('Native fork input requires an immutable terminal Pi snapshot.');\n })())\n : { kind: 'fresh' };\n const intercom = this.teamChannel?.createNativeChildIntercom({\n rootSessionId: scope.rootSessionId,\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n runId,\n childIndex,\n task: { id: runId, subject: task },\n });\n let child: Awaited<ReturnType<NativeRunCoordinatorContract['start']>>;\n try {\n child = await this.nativeRuns.start(\n parentSessionId ?? scope.rootSessionId,\n {\n runId,\n parentSessionId: parentSessionId ?? scope.rootSessionId,\n scope,\n source,\n agent: agentConfig.name,\n task,\n cwd,\n ...(modelSelection.model ? { model: modelSelection.model } : {}),\n ...(typeof agentConfig.thinking === 'string' ? { thinking: agentConfig.thinking } : {}),\n ...(skillProjection.systemPrompt ? { systemPrompt: skillProjection.systemPrompt } : {}),\n systemPromptMode: agentConfig.systemPromptMode,\n ...(agentConfig.extensions ? { extensions: agentConfig.extensions } : {}),\n ...(agentConfig.subagentOnlyExtensions\n ? { subagentOnlyExtensions: agentConfig.subagentOnlyExtensions }\n : {}),\n ...(agentConfig.tools\n ? { tools: [...new Set([...agentConfig.tools, ...(capabilityCeiling?.requiredTools ?? [])])] }\n : {}),\n ...(excludeTools ? { excludeTools } : {}),\n ...(agentConfig.skills ? { skills: agentConfig.skills } : {}),\n ...(agentConfig.mcpDirectTools ? { mcpDirectTools: agentConfig.mcpDirectTools } : {}),\n ...(capabilityCeiling ? { capabilityCeiling } : {}),\n ...(intercom ? { intercom } : {}),\n environment,\n },\n // Carried beside the core child request rather than inside it, so a\n // Team-only concept does not widen the shared child contract.\n { identity: identity.identity, inline: identity.inline },\n );\n } catch (error) {\n intercom?.dispose?.();\n throw error;\n }\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: child.runId,\n ...(warning ? { warning } : {}),\n };\n }\n const result: AsyncSubagentSpawnResult = await this.spawner.spawn(spawnInput);\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n runId: result.runId,\n pid: result.pid,\n ...(warning ? { warning } : {}),\n };\n } catch (error) {\n return {\n agent: agentConfig.name,\n identity: identity.identity,\n inline: identity.inline,\n task,\n childIndex,\n error: error instanceof Error ? error.message : String(error),\n ...(warning ? { warning } : {}),\n };\n } finally {\n // Once spawn resolves, direct child events make the run visible to the\n // injected live counter, so only the reservation is released here.\n ticket.release();\n }\n }\n\n async spawn(request: SpawnPlanRequest, config: ExtensionConfig): Promise<SpawnPlanResult> {\n const tasks = this.resolveTaskList(request);\n const fanout = tasks.length > 1;\n const teamPackageExcludeTools = this.resolveTeamPackageExcludeTools();\n const teamPackageModels = this.resolveTeamPackageModels();\n const capabilityCeiling = this.policies.resolve();\n\n // PREFLIGHT - all before any spawn call, so a declared plan that cannot\n // run at all produces one refusal, not a partial fan-out.\n const currentDepth = request.currentDepth ?? resolveCurrentSubagentDepth();\n const depthCheck = preflightSubagentDepth(currentDepth, config);\n if (depthCheck.error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n depthCheck.error,\n false,\n 'Give each child a self-contained task within the Team package policy.',\n );\n }\n\n const maxTasks = config.parallel?.maxTasks ?? DEFAULT_PARALLEL_MAX_TASKS;\n if (tasks.length > maxTasks) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run requested ${tasks.length} tasks, but at most ${maxTasks} may be declared in one call. Concurrency throttles how fast they start, not how many run.`,\n false,\n 'Send at most that many requests in this call and wait for them, or raise parallel.maxTasks in the subagent config. Splitting the same width across extra calls does not raise the live-child ceiling.',\n );\n }\n\n for (const taskInput of tasks) {\n if (!taskInput.task?.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Run request for '${taskInput.agent}' requires a nonblank task.`,\n false,\n 'Provide a self-contained nonblank task.',\n );\n }\n if (taskInput.inlineAgent && !taskInput.inlineAgent.systemPrompt.trim()) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_INVALID_REQUEST,\n `Inline agent '${taskInput.agent}' requires a nonblank system prompt.`,\n false,\n 'Provide a focused read-only exploration role.',\n );\n }\n }\n\n const resolvedAgentCache = new Map<string, ExecutableAgentConfig>();\n const resolvedAgents = tasks.map((taskInput) => {\n if (taskInput.inlineAgent) {\n return this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n }\n const cacheKey = [\n request.agentScope,\n canonicalizeDiscoveryCwd(taskInput.cwd ?? request.cwd),\n taskInput.agent,\n ].join('\\0');\n const cached = resolvedAgentCache.get(cacheKey);\n if (cached) return cached;\n const resolved = this.resolveExecutableAgent(taskInput, taskInput.cwd ?? request.cwd, request.agentScope);\n resolvedAgentCache.set(cacheKey, resolved);\n return resolved;\n });\n for (const [index, taskInput] of tasks.entries()) {\n const effectiveContext = resolveEffectiveContext(taskInput, resolvedAgents[index]!);\n const runtime = taskInput.runtime ?? request.runtime ?? resolvedAgents[index]!.runtime ?? PI_RUNTIME_NAME;\n if (effectiveContext === CONTEXT_FORK) {\n if (!isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context requires ${PI_RUNTIME_REQUIREMENT} for '${taskInput.agent}'.`,\n false,\n 'Use a Pi agent for fork context or explicitly request a fresh run.',\n );\n }\n if (!request.parentForkSource) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_CONTEXT,\n `Fork context is unavailable for '${taskInput.agent}': ${describeForkFailure(request.parentForkFailure)}.`,\n false,\n 'Use an active Pi session with a completed parent turn or explicitly request a fresh run.',\n );\n }\n }\n }\n\n if (request.preallocatedRunIds && request.preallocatedRunIds.length !== tasks.length) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_OPERATION_CONFLICT,\n 'The operation journal run-id count does not match the request count.',\n false,\n 'Submit the run as a new tool call.',\n );\n }\n const runIds = request.preallocatedRunIds ?? tasks.map(() => this.generateRunId());\n // Minted here because this is the one funnel every spawn path reaches, and\n // because the inline flag and the resolved agent name are both in hand. A\n // restore carries its identity in, and repoints the existing claim rather\n // than burning a second number on the same logical agent.\n const identities = tasks.map((taskInput, index) => {\n const inline = taskInput.inlineAgent !== undefined;\n if (!taskInput.identity) {\n return claimAgentIdentity(request.sessionScope, {\n agent: resolvedAgents[index]!.name,\n inline,\n runId: runIds[index]!,\n });\n }\n adoptAgentIdentity(request.sessionScope, taskInput.identity, runIds[index]!);\n return {\n identity: taskInput.identity,\n name: '',\n role: roleFromAgent(resolvedAgents[index]!.name),\n number: 0,\n inline,\n persisted: true,\n };\n });\n const runtimes = resolveRuntimeTable(config.runtimes);\n for (const [index, taskInput] of tasks.entries()) {\n const agent = resolvedAgents[index]!;\n const cwd = taskInput.cwd ?? request.cwd;\n this.validateCwd(cwd);\n const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? PI_RUNTIME_NAME;\n const modelSelection = resolvedModelSelection(\n taskInput,\n agent,\n runtime,\n request.parentModel,\n request.availableModels,\n teamPackageModels,\n );\n if (modelSelection.primaryModel && request.availableModels !== undefined && !modelSelection.model) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_MODEL_UNAVAILABLE,\n `No authenticated model is available for '${agent.name}'.`,\n false,\n 'Authenticate the requested model or choose an available model.',\n );\n }\n if (taskInput.inlineAgent && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Inline agent '${taskInput.agent}' requires ${PI_RUNTIME_REQUIREMENT} to enforce its read-only tools.`,\n false,\n 'Remove the runtime override or use a discovered external-runtime agent without inlineAgent.',\n );\n }\n if (capabilityCeiling && !isPiRuntime(runtime)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_UNSUPPORTED_OPERATION,\n `Runtime '${runtime}' cannot enforce the active capability ceiling.`,\n false,\n `Use ${PI_RUNTIME_REQUIREMENT} while plan mode or another capability ceiling is active.`,\n );\n }\n if (!isPiRuntime(runtime)) {\n let command: string;\n try {\n command = resolveRuntimeLaunch(runtime, runtimes, { prompt: taskInput.task ?? '', cwd }).command;\n } catch (error) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n error instanceof Error ? error.message : String(error),\n false,\n `Configure a valid external runtime or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n if (!this.executableAvailable(command)) {\n throw new DoomTeamExpectedError(\n ERROR_CODE_RUNTIME_UNAVAILABLE,\n `Executable '${command}' for runtime '${runtime}' is unavailable.`,\n false,\n `Install the executable, configure its absolute path, or use ${PI_RUNTIME_REQUIREMENT}.`,\n );\n }\n }\n }\n const concurrency = fanout\n ? (request.concurrency ?? config.parallel?.concurrency ?? DEFAULT_PARALLEL_CONCURRENCY)\n : 1;\n const maxLiveRuns = Math.max(1, config.parallel?.maxLiveRuns ?? DEFAULT_MAX_LIVE_RUNS);\n const admissionTimeoutMs = config.parallel?.admissionTimeoutMs ?? DEFAULT_ADMISSION_TIMEOUT_MS;\n\n const skillProjectionCache = new Map<string, ChildSkillProjection>();\n const factories = tasks.map(\n (taskInput, childIndex) => () =>\n this.spawnOneChild({\n runId: runIds[childIndex]!,\n operationId: request.operationId,\n agentConfig: resolvedAgents[childIndex]!,\n identity: identities[childIndex]!,\n excludeTools: teamPackageExcludeTools,\n teamPackageModels,\n capabilityCeiling,\n taskInput,\n childIndex,\n fanout,\n fallbackCwd: request.cwd,\n parentSessionId: request.parentSessionId,\n parentForkSource: request.parentForkSource,\n sessionScope: request.sessionScope,\n environment: request.environment ?? {},\n parentSessionFile: request.parentSessionFile,\n maxLiveRuns,\n admissionTimeoutMs,\n handshakeTimeoutMs: config.handshakeTimeoutMs,\n artifacts: request.artifacts,\n artifactDir: config.artifactDir,\n availableModels: request.availableModels,\n parentModel: request.parentModel,\n runtime: request.runtime,\n runtimes,\n skillProjectionCache,\n }),\n );\n\n const settled = await runWithConcurrency(factories, concurrency, this.reportConcurrencyEvent);\n // `spawnOneChild` never rejects (it catches its own spawn failure into\n // an `{error}` outcome), so `runWithConcurrency` never sees a rejection\n // here - this unwrap is defensive, not a real branch.\n const outcomes = settled.map((outcome, index) =>\n outcome.status === 'fulfilled'\n ? outcome.value\n : {\n agent: resolvedAgents[index]!.name,\n identity: identities[index]!.identity,\n inline: identities[index]!.inline,\n task: tasks[index]!.task ?? '',\n childIndex: index,\n error: outcome.reason instanceof Error ? outcome.reason.message : String(outcome.reason),\n },\n );\n\n return { outcomes };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAe/B,SAAS,oBAAoB,aAAwD;CACnF,IAAI,CAAC,aAAa,KAAK,GAAG,OAAO;CACjC,IAAI;EACF,GAAG,WAAW,aAAa,GAAG,UAAU,IAAI;EAC5C,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAoBA,MAAM,oBAAiF;CACrF,wBAAwB;CACxB,WAAW;CACX,aAAa;CACb,uBAAuB;CACvB,mBAAmB;CACnB,iBAAiB;AACnB;AAEA,SAAgB,oBAAoB,QAAyE;CAC3G,OAAO,SAAS,kBAAkB,UAAU;AAC9C;;;;;;;;AASA,SAAgB,kBACd,UACyG;CACzG,IAAI,CAAC,UAAU,OAAO,EAAE,mBAAmB,uBAAuB;CAClE,IAAI,UAAU,UAAU,OAAO,EAAE,kBAAkB,SAAS;CAC5D,IAAI,CAAC,SAAS,IAAI,OAAO,EAAE,mBAAmB,SAAS,OAAO;CAC9D,MAAM,EAAE,WAAW;CACnB,OAAO;EACL,kBAAkB,OAAO;EACzB,GAAI,OAAO,cAAc,EAAE,mBAAmB,OAAO,YAAY,IAAI,CAAC;EACtE,cAAc,OAAO;CACvB;A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O;GAC3B,WAAW,QAAQ;GACnB,aAAa,OAAO;GACpB,iBAAiB,QAAQ;GACzB,aAAa,QAAQ;GACrB,SAAS,QAAQ;GACjB;GACA;EACF,CAAC,CACL;EAmBA,OAAO,EAAE,WAbQ,MAJK,mBAAmB,WAAW,aAAa,KAAK,sBAAsB,EAAA,CAInE,KAAK,SAAS,UACrC,QAAQ,WAAW,cACf,QAAQ,QACR;GACE,OAAO,eAAe,MAAM,CAAE;GAC9B,UAAU,WAAW,MAAM,CAAE;GAC7B,QAAQ,WAAW,MAAM,CAAE;GAC3B,MAAM,MAAM,MAAM,CAAE,QAAQ;GAC5B,YAAY;GACZ,OAAO,QAAQ,kBAAkB,QAAQ,QAAQ,OAAO,UAAU,OAAO,QAAQ,MAAM;EACzF,CAGU,EAAE;CACpB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/doompi-team",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.78",
|
|
4
4
|
"description": "Asynchronous named subagents, team runs, intercom, and model policy for Pi coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-team",
|
|
@@ -124,24 +124,24 @@
|
|
|
124
124
|
"registry": "https://registry.npmjs.org/"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@agimon-ai/doompi-cache": "0.0.1-alpha.
|
|
128
|
-
"@agimon-ai/doompi-config": "0.0.1-alpha.
|
|
129
|
-
"@agimon-ai/doompi-core": "0.0.1-alpha.
|
|
130
|
-
"@agimon-ai/doompi-session": "0.0.1-alpha.
|
|
131
|
-
"@agimon-ai/doompi-telemetry": "0.0.1-alpha.
|
|
132
|
-
"@agimon-ai/doompi-ui": "0.0.1-alpha.
|
|
133
|
-
"@agimon-ai/doompi-web-components": "0.0.1-alpha.
|
|
134
|
-
"@agimon-ai/doompi-web-security": "0.0.1-alpha.
|
|
127
|
+
"@agimon-ai/doompi-cache": "0.0.1-alpha.44",
|
|
128
|
+
"@agimon-ai/doompi-config": "0.0.1-alpha.77",
|
|
129
|
+
"@agimon-ai/doompi-core": "0.0.1-alpha.78",
|
|
130
|
+
"@agimon-ai/doompi-session": "0.0.1-alpha.2",
|
|
131
|
+
"@agimon-ai/doompi-telemetry": "0.0.1-alpha.75",
|
|
132
|
+
"@agimon-ai/doompi-ui": "0.0.1-alpha.78",
|
|
133
|
+
"@agimon-ai/doompi-web-components": "0.0.1-alpha.36",
|
|
134
|
+
"@agimon-ai/doompi-web-security": "0.0.1-alpha.38",
|
|
135
135
|
"@deepseek-ai/cordis": "4.0.2",
|
|
136
136
|
"typebox": "1.3.30",
|
|
137
137
|
"yaml": "2.9.0"
|
|
138
138
|
},
|
|
139
139
|
"devDependencies": {
|
|
140
|
-
"@agimon-ai/doompi-build": "0.0.1-alpha.
|
|
141
|
-
"@earendil-works/pi-agent-core": "0.
|
|
142
|
-
"@earendil-works/pi-ai": "0.
|
|
143
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
144
|
-
"@earendil-works/pi-tui": "0.
|
|
140
|
+
"@agimon-ai/doompi-build": "0.0.1-alpha.7",
|
|
141
|
+
"@earendil-works/pi-agent-core": "0.86.0",
|
|
142
|
+
"@earendil-works/pi-ai": "0.86.0",
|
|
143
|
+
"@earendil-works/pi-coding-agent": "0.86.0",
|
|
144
|
+
"@earendil-works/pi-tui": "0.86.0",
|
|
145
145
|
"@tanstack/react-store": "0.11.1",
|
|
146
146
|
"@tanstack/store": "0.11.1",
|
|
147
147
|
"@types/node": "26.5.1",
|
|
@@ -153,10 +153,10 @@
|
|
|
153
153
|
"vitest": "5.0.0"
|
|
154
154
|
},
|
|
155
155
|
"peerDependencies": {
|
|
156
|
-
"@earendil-works/pi-agent-core": "0.
|
|
157
|
-
"@earendil-works/pi-ai": "0.
|
|
158
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
159
|
-
"@earendil-works/pi-tui": "0.
|
|
156
|
+
"@earendil-works/pi-agent-core": "0.86.0",
|
|
157
|
+
"@earendil-works/pi-ai": "0.86.0",
|
|
158
|
+
"@earendil-works/pi-coding-agent": "0.86.0",
|
|
159
|
+
"@earendil-works/pi-tui": "0.86.0"
|
|
160
160
|
},
|
|
161
161
|
"peerDependenciesMeta": {
|
|
162
162
|
"@earendil-works/pi-agent-core": {
|