iosm-cli 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +43 -10
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-profiles.d.ts +2 -1
- package/dist/core/agent-profiles.d.ts.map +1 -1
- package/dist/core/agent-profiles.js +18 -5
- package/dist/core/agent-profiles.js.map +1 -1
- package/dist/core/agent-session.d.ts +7 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +64 -15
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agent-teams.d.ts.map +1 -1
- package/dist/core/agent-teams.js +90 -19
- package/dist/core/agent-teams.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +9 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/orchestration-limits.d.ts +6 -0
- package/dist/core/orchestration-limits.d.ts.map +1 -0
- package/dist/core/orchestration-limits.js +6 -0
- package/dist/core/orchestration-limits.js.map +1 -0
- package/dist/core/parallel-task-agent.d.ts +23 -1
- package/dist/core/parallel-task-agent.d.ts.map +1 -1
- package/dist/core/parallel-task-agent.js +110 -20
- package/dist/core/parallel-task-agent.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +34 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/shared-memory.d.ts +2 -2
- package/dist/core/shared-memory.d.ts.map +1 -1
- package/dist/core/shared-memory.js +220 -91
- package/dist/core/shared-memory.js.map +1 -1
- package/dist/core/singular.d.ts.map +1 -1
- package/dist/core/singular.js +3 -1
- package/dist/core/singular.js.map +1 -1
- package/dist/core/subagents.d.ts +1 -1
- package/dist/core/subagents.d.ts.map +1 -1
- package/dist/core/subagents.js +32 -10
- package/dist/core/subagents.js.map +1 -1
- package/dist/core/swarm/planner.d.ts.map +1 -1
- package/dist/core/swarm/planner.js +200 -12
- package/dist/core/swarm/planner.js.map +1 -1
- package/dist/core/swarm/scheduler.d.ts +2 -0
- package/dist/core/swarm/scheduler.d.ts.map +1 -1
- package/dist/core/swarm/scheduler.js +87 -6
- package/dist/core/swarm/scheduler.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/ast-grep.d.ts.map +1 -1
- package/dist/core/tools/ast-grep.js +2 -0
- package/dist/core/tools/ast-grep.js.map +1 -1
- package/dist/core/tools/edit.d.ts +8 -4
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +18 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +9 -7
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/shared-memory.d.ts.map +1 -1
- package/dist/core/tools/shared-memory.js +34 -6
- package/dist/core/tools/shared-memory.js.map +1 -1
- package/dist/core/tools/task.d.ts +10 -3
- package/dist/core/tools/task.d.ts.map +1 -1
- package/dist/core/tools/task.js +830 -184
- package/dist/core/tools/task.js.map +1 -1
- package/dist/core/tools/todo.d.ts +10 -10
- package/dist/core/tools/todo.d.ts.map +1 -1
- package/dist/core/tools/todo.js +135 -17
- package/dist/core/tools/todo.js.map +1 -1
- package/dist/core/tools/yq.d.ts.map +1 -1
- package/dist/core/tools/yq.js +2 -0
- package/dist/core/tools/yq.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +10 -9
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +22 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +957 -75
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/cli-reference.md +8 -0
- package/docs/configuration.md +5 -1
- package/docs/interactive-mode.md +7 -1
- package/docs/orchestration-and-subagents.md +5 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GAExB,MAAM,6BAA6B,CAAC;AAwDrC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;QACxB,WAAW,EAAE,yDAAyD;KACtE,CAAC;IACF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,mCAAmC;KAChD,CAAC;IACF,KAAK,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,oFAAoF;KACjG,CAAC,CACF;IACD,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EACV,4LAA4L;KAC7L,CAAC;IACF,GAAG,EAAE,IAAI,CAAC,QAAQ,CAC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yBAC7D,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;gBACL,OAAO;oBACN,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,mCAAmC,KAAK,oEAAoE;yBAClH;qBACD;oBACD,OAAO,EAAE;wBACR,OAAO,EAAE,gBAAgB;wBACzB,WAAW;wBACX,YAAY,EAAE,CAAC;wBACf,GAAG,EAAE,oBAAoB;wBACzB,KAAK,EAAE,cAAc,EAAE,IAAI;wBAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,SAAS;wBACrC,KAAK;wBACL,MAAM,EAAE,mBAAmB;wBAC3B,KAAK,EAAE,sBAAsB;wBAC7B,UAAU,EAAE,IAAI;wBAChB,oBAAoB,EAAE,gBAAgB;wBACtC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ;wBAC7B,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM;wBAC5C,gBAAgB,EAAE,cAAc,EAAE,gBAAgB;wBAClD,kBAAkB,EAAE,cAAc,EAAE,kBAAkB;wBACtD,iBAAiB,EAAE,cAAc,EAAE,iBAAiB;qBACpD;iBACD,CAAC;YACH,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,eAAe,EAAE,CAAC;YACvC,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;gBACvD,OAAO,EAAE,MAAM,CAAC,OAAO;aACvB,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { spawnSync } from \"node:child_process\";\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { getTeamRun, updateTeamTaskStatus } from \"../agent-teams.js\";\nimport {\n\tbuildRetrospectiveDirective,\n\tclassifyFailureCause,\n\tformatFailureCauseCounts,\n\tisRetrospectiveRetryable,\n\ttype FailureCause,\n} from \"../failure-retrospective.js\";\nimport type { SharedMemoryContext } from \"../shared-memory.js\";\nimport type { CustomSubagentDefinition } from \"../subagents.js\";\n\n/**\n * Callback type passed in from sdk.ts to avoid circular imports.\n * Spawns a sub-session and runs it to completion, returning the final text output.\n */\nexport type SubagentRunResult = {\n\toutput: string;\n\tsessionId?: string;\n\tstats?: {\n\t\ttoolCallsStarted: number;\n\t\ttoolCallsCompleted: number;\n\t\tassistantMessages: number;\n\t};\n};\n\nexport type TaskToolProgressPhase = \"queued\" | \"starting\" | \"running\" | \"responding\";\n\nexport type TaskDelegateProgressStatus = \"pending\" | \"running\" | \"done\" | \"failed\";\n\nexport interface TaskDelegateProgressItem {\n\tindex: number;\n\tdescription: string;\n\tprofile: string;\n\tstatus: TaskDelegateProgressStatus;\n}\n\nexport interface TaskToolProgress {\n\tkind: \"subagent_progress\";\n\tphase: TaskToolProgressPhase;\n\tmessage: string;\n\tcwd?: string;\n\tactiveTool?: string;\n\ttoolCallsStarted?: number;\n\ttoolCallsCompleted?: number;\n\tassistantMessages?: number;\n\tdelegateIndex?: number;\n\tdelegateTotal?: number;\n\tdelegateDescription?: string;\n\tdelegateProfile?: string;\n\tdelegateItems?: TaskDelegateProgressItem[];\n}\n\nexport type SubagentRunner = (options: {\n\tsystemPrompt: string;\n\ttools: string[];\n\tprompt: string;\n\tcwd: string;\n\tmodelOverride?: string;\n\tsharedMemoryContext?: SharedMemoryContext;\n\tsignal?: AbortSignal;\n\tonProgress?: (progress: TaskToolProgress) => void;\n}) => Promise<string | SubagentRunResult>;\n\nconst taskSchema = Type.Object({\n\tdescription: Type.String({\n\t\tdescription: \"Short 3-5 word description of what the subagent will do\",\n\t}),\n\tprompt: Type.String({\n\t\tdescription: \"Full task prompt for the subagent\",\n\t}),\n\tagent: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Optional custom subagent name loaded from .iosm/agents or global agents directory.\",\n\t\t}),\n\t),\n\tprofile: Type.String({\n\t\tdescription:\n\t\t\t\"Subagent capability profile. Recommended values: explore, plan, iosm, iosm_analyst, iosm_verifier, cycle_planner, full. For custom agents, pass the agent name via `agent`, not `profile`.\",\n\t}),\n\tcwd: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional working directory for this subagent. Relative paths are resolved from the current workspace.\",\n\t\t}),\n\t),\n\tlock_key: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional logical lock key for write serialization (e.g. src/api/**). Agents with the same lock key run write phases sequentially.\",\n\t\t}),\n\t),\n\trun_id: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional orchestration run id (from /orchestrate or /swarm). Use with task_id so the team board can track status. When omitted, task mode uses an internal run id for shared-memory collaboration within this task execution.\",\n\t\t}),\n\t),\n\ttask_id: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional orchestration task id (for example task_1). Use with run_id to update the team board. When omitted, task mode uses an internal task id so task-scoped shared memory still works.\",\n\t\t}),\n\t),\n\tmodel: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional model override for this subagent (for example anthropic/claude-sonnet-4 or model id).\",\n\t\t}),\n\t),\n\tbackground: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Run subagent in background and return immediately with run id. Use for detached async runs; orchestrated run_id/task_id calls execute foreground for deterministic coordination. Background mode is read-only policy by default.\",\n\t\t}),\n\t),\n\tisolation: Type.Optional(\n\t\tType.Union([Type.Literal(\"none\"), Type.Literal(\"worktree\")], {\n\t\t\tdescription:\n\t\t\t\t\"Optional isolation mode. Set to worktree to run this subagent in a temporary git worktree.\",\n\t\t}),\n\t),\n\tdelegate_parallel_hint: Type.Optional(\n\t\tType.Integer({\n\t\t\tminimum: 1,\n\t\t\tmaximum: 10,\n\t\t\tdescription:\n\t\t\t\t\"Optional hint for intra-task delegation fan-out. Higher value allows more delegated subtasks to run in parallel inside a single task execution.\",\n\t\t}),\n\t),\n});\n\nexport type TaskToolInput = Static<typeof taskSchema>;\n\n/** Details attached to the tool result for UI display */\nexport interface TaskToolDetails {\n\tprofile: string;\n\tdescription: string;\n\toutputLength: number;\n\tcwd: string;\n\tagent?: string;\n\tlockKey?: string;\n\trunId?: string;\n\ttaskId?: string;\n\tmodel?: string;\n\tsubagentSessionId?: string;\n\ttranscriptPath?: string;\n\tisolation?: \"none\" | \"worktree\";\n\tworktreePath?: string;\n\twaitMs?: number;\n\tbackground?: boolean;\n\tbackgroundStatusPath?: string;\n\ttoolCallsStarted?: number;\n\ttoolCallsCompleted?: number;\n\tassistantMessages?: number;\n\tdelegatedTasks?: number;\n\tdelegatedSucceeded?: number;\n\tdelegatedFailed?: number;\n\tretrospectiveAttempts?: number;\n\tretrospectiveRecovered?: number;\n\tfailureCauses?: Partial<Record<FailureCause, number>>;\n}\n\nexport interface TaskToolOptions {\n\tresolveCustomSubagent?: (name: string) => CustomSubagentDefinition | undefined;\n\tavailableCustomSubagents?: string[];\n\tavailableCustomSubagentHints?: Array<{ name: string; description: string }>;\n\t/** Returns pending live meta updates entered during an active run. */\n\tgetMetaMessages?: () => readonly string[];\n}\n\n/** Tool names available per profile */\nconst toolsByProfile: Record<string, string[]> = {\n\texplore: [\"read\", \"grep\", \"find\", \"ls\"],\n\tplan: [\"read\", \"bash\", \"grep\", \"find\", \"ls\"],\n\tiosm: [\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"],\n\tiosm_analyst: [\"read\", \"bash\", \"grep\", \"find\", \"ls\"],\n\tiosm_verifier: [\"read\", \"bash\", \"write\"],\n\tcycle_planner: [\"read\", \"bash\", \"write\"],\n\tfull: [\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"],\n};\n\n/** System prompt injected per profile */\nconst systemPromptByProfile: Record<string, string> = {\n\texplore:\n\t\t\"You are a fast read-only codebase explorer. Answer concisely. Never write or edit files.\",\n\tplan: \"You are a technical architect. Analyze the codebase and produce a clear implementation plan. Do not write or edit files.\",\n\tiosm: \"You are an IOSM execution agent. Use IOSM methodology and keep IOSM artifacts synchronized with implementation.\",\n\tiosm_analyst:\n\t\t\"You are an IOSM metrics analyst. Analyze .iosm/ artifacts and codebase metrics. Be precise and evidence-based.\",\n\tiosm_verifier:\n\t\t\"You are an IOSM verifier. Validate checks and update only required IOSM artifacts with deterministic reasoning.\",\n\tcycle_planner:\n\t\t\"You are an IOSM cycle planner. Propose and align cycle goals with measurable outcomes and concrete risks.\",\n\tfull: \"You are a software engineering agent. Execute the task end-to-end.\",\n};\n\nconst writeCapableProfiles = new Set([\"full\", \"iosm_verifier\", \"cycle_planner\"]);\nconst delegationTagName = \"delegate_task\";\n\ntype DelegationRequest = {\n\tdescription: string;\n\tprofile: string;\n\tagent?: string;\n\tprompt: string;\n\tcwd?: string;\n\tlockKey?: string;\n\tmodel?: string;\n\tisolation?: \"none\" | \"worktree\";\n\tdependsOn?: number[];\n};\n\ntype ParsedDelegationRequests = {\n\tcleanedOutput: string;\n\trequests: DelegationRequest[];\n\twarnings: string[];\n};\n\nclass Semaphore {\n\tprivate active = 0;\n\tprivate readonly queue: Array<() => void> = [];\n\n\tconstructor(private readonly limit: number) {}\n\n\tasync acquire(): Promise<() => void> {\n\t\tif (this.active < this.limit) {\n\t\t\tthis.active += 1;\n\t\t\treturn () => this.release();\n\t\t}\n\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tthis.queue.push(() => {\n\t\t\t\tthis.active += 1;\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\treturn () => this.release();\n\t}\n\n\tprivate release(): void {\n\t\tthis.active = Math.max(0, this.active - 1);\n\t\tconst next = this.queue.shift();\n\t\tif (next) {\n\t\t\tnext();\n\t\t}\n\t}\n\n\tisIdle(): boolean {\n\t\treturn this.active === 0 && this.queue.length === 0;\n\t}\n}\n\nclass Mutex {\n\tprivate locked = false;\n\tprivate readonly waiters: Array<() => void> = [];\n\n\tasync acquire(): Promise<() => void> {\n\t\tif (!this.locked) {\n\t\t\tthis.locked = true;\n\t\t\treturn () => this.release();\n\t\t}\n\n\t\tawait new Promise<void>((resolve) => this.waiters.push(resolve));\n\t\tthis.locked = true;\n\t\treturn () => this.release();\n\t}\n\n\tprivate release(): void {\n\t\tthis.locked = false;\n\t\tconst next = this.waiters.shift();\n\t\tif (next) {\n\t\t\tnext();\n\t\t}\n\t}\n\n\tisIdle(): boolean {\n\t\treturn !this.locked && this.waiters.length === 0;\n\t}\n}\n\nconst maxParallelFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_MAX_PARALLEL, 20, 1, 20);\nconst subagentSemaphore = new Semaphore(maxParallelFromEnv);\nconst maxDelegationDepthFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_MAX_DELEGATION_DEPTH, 1, 0, 3);\nconst maxDelegationsPerTaskFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_SUBAGENT_MAX_DELEGATIONS_PER_TASK,\n\t10,\n\t0,\n\t10,\n);\nconst maxDelegatedParallelFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_MAX_DELEGATE_PARALLEL, 10, 1, 10);\nconst emptyOutputRetriesFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_EMPTY_OUTPUT_RETRIES, 1, 0, 2);\nconst retrospectiveRetriesFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_RETRO_RETRIES, 1, 0, 1);\nconst orchestrationDependencyWaitTimeoutMsFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_ORCHESTRATION_DEPENDENCY_WAIT_TIMEOUT_MS,\n\t120_000,\n\t5_000,\n\t900_000,\n);\nconst orchestrationDependencyPollMsFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_ORCHESTRATION_DEPENDENCY_POLL_MS,\n\t150,\n\t50,\n\t2_000,\n);\nconst maxDelegatedOutputCharsFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_DELEGATED_OUTPUT_MAX_CHARS, 6000, 500, 20_000);\nconst maxMetaUpdatesPerCheckpoint = parseBoundedInt(process.env.IOSM_SUBAGENT_META_MAX_ITEMS, 5, 1, 20);\nconst maxMetaUpdateChars = parseBoundedInt(process.env.IOSM_SUBAGENT_META_MAX_CHARS, 600, 100, 4000);\nconst orchestrationSemaphores = new Map<string, Semaphore>();\nconst cwdWriteLocks = new Map<string, Mutex>();\n\nfunction parseBoundedInt(raw: string | undefined, fallback: number, min: number, max: number): number {\n\tconst parsed = raw ? Number.parseInt(raw, 10) : fallback;\n\tif (!Number.isInteger(parsed)) return fallback;\n\treturn Math.max(min, Math.min(max, parsed));\n}\n\nfunction shouldAutoDelegateByAgent(agentName: string | undefined): boolean {\n\tif (!agentName) return false;\n\tconst normalized = agentName.trim().toLowerCase();\n\treturn normalized.includes(\"orchestrator\");\n}\n\nfunction deriveAutoDelegateParallelHint(\n\tagentName: string | undefined,\n\tdescription: string,\n\tprompt: string,\n): number | undefined {\n\tif (!shouldAutoDelegateByAgent(agentName)) return undefined;\n\tconst text = `${description}\\n${prompt}`.trim();\n\tif (!text) return 1;\n\tconst normalized = text.replace(/\\s+/g, \" \").trim();\n\tconst words = normalized.length > 0 ? normalized.split(/\\s+/).length : 0;\n\tconst clauses = normalized\n\t\t.split(/[.;:,\\n]+/g)\n\t\t.map((item) => item.trim())\n\t\t.filter((item) => item.length > 0).length;\n\tconst pathLikeMatches = normalized.match(/\\b(?:[A-Za-z0-9_.-]+\\/)+[A-Za-z0-9_.-]+\\b/g) ?? [];\n\tconst fileLikeMatches = normalized.match(/\\b[A-Za-z0-9_.-]+\\.[A-Za-z0-9]{1,8}\\b/g) ?? [];\n\tconst listMarkers = text.match(/(?:^|\\n)\\s*(?:[-*]|\\d+[.)])\\s+/g)?.length ?? 0;\n\tconst hasCodeBlock = text.includes(\"```\");\n\n\tlet score = 0;\n\tif (words >= 40) {\n\t\tscore += 2;\n\t} else if (words >= 20) {\n\t\tscore += 1;\n\t}\n\tif (clauses >= 5) {\n\t\tscore += 2;\n\t} else if (clauses >= 3) {\n\t\tscore += 1;\n\t}\n\tif (listMarkers >= 2) {\n\t\tscore += 1;\n\t}\n\tconst referenceCount = pathLikeMatches.length + fileLikeMatches.length;\n\tif (referenceCount >= 3 || (referenceCount >= 1 && words >= 20)) {\n\t\tscore += 1;\n\t}\n\tif (hasCodeBlock) {\n\t\tscore += 1;\n\t}\n\n\tif (score >= 6) return 10;\n\tif (score >= 5) return 8;\n\tif (score >= 4) return 6;\n\tif (score >= 3) return 4;\n\tif (score >= 2) return 3;\n\tif (score >= 1) return 2;\n\treturn 1;\n}\n\nfunction normalizeSpacing(text: string): string {\n\treturn text.replace(/[ \\t]+\\n/g, \"\\n\").replace(/\\n{3,}/g, \"\\n\\n\").trim();\n}\n\nfunction cloneDelegateItems(items: TaskDelegateProgressItem[] | undefined): TaskDelegateProgressItem[] | undefined {\n\treturn items ? items.map((item) => ({ ...item })) : undefined;\n}\n\nfunction formatMetaCheckpoint(metaMessages: readonly string[] | undefined): {\n\tsection: string | undefined;\n\tappliedCount: number;\n} {\n\tif (!metaMessages || metaMessages.length === 0) {\n\t\treturn { section: undefined, appliedCount: 0 };\n\t}\n\tconst normalized = metaMessages\n\t\t.map((item) => item.replace(/\\s+/g, \" \").trim())\n\t\t.filter((item) => item.length > 0)\n\t\t.slice(-maxMetaUpdatesPerCheckpoint)\n\t\t.map((item) => (item.length > maxMetaUpdateChars ? `${item.slice(0, maxMetaUpdateChars - 3)}...` : item));\n\n\tif (normalized.length === 0) {\n\t\treturn { section: undefined, appliedCount: 0 };\n\t}\n\n\tconst lines = normalized.map((item, index) => `${index + 1}. ${item}`).join(\"\\n\");\n\treturn {\n\t\tsection: [\n\t\t\t\"[META_UPDATES]\",\n\t\t\t\"Live user updates captured during execution. Apply them in this subtask if relevant.\",\n\t\t\t\"If conflicts exist, prioritize later items.\",\n\t\t\tlines,\n\t\t\t\"[/META_UPDATES]\",\n\t\t].join(\"\\n\"),\n\t\tappliedCount: normalized.length,\n\t};\n}\n\nfunction isAbortError(error: unknown): boolean {\n\tif (error instanceof Error) {\n\t\treturn /aborted/i.test(error.message);\n\t}\n\tif (typeof error === \"string\") {\n\t\treturn /aborted/i.test(error);\n\t}\n\treturn false;\n}\n\nfunction mergeRunStats(\n\tbase: SubagentRunResult[\"stats\"] | undefined,\n\tnext: SubagentRunResult[\"stats\"] | undefined,\n): SubagentRunResult[\"stats\"] | undefined {\n\tif (!base && !next) return undefined;\n\treturn {\n\t\ttoolCallsStarted: (base?.toolCallsStarted ?? 0) + (next?.toolCallsStarted ?? 0),\n\t\ttoolCallsCompleted: (base?.toolCallsCompleted ?? 0) + (next?.toolCallsCompleted ?? 0),\n\t\tassistantMessages: (base?.assistantMessages ?? 0) + (next?.assistantMessages ?? 0),\n\t};\n}\n\nfunction buildDelegationProtocolPrompt(depthRemaining: number, maxDelegations: number): string {\n\tif (depthRemaining <= 0) {\n\t\treturn [\n\t\t\t`Delegation protocol: depth limit reached.`,\n\t\t\t`Do not emit <${delegationTagName}> blocks.`,\n\t\t].join(\"\\n\");\n\t}\n\treturn [\n\t\t`Delegation protocol (optional): if you discover concrete independent follow-ups, emit up to ${maxDelegations} XML block(s):`,\n\t\t`<${delegationTagName} profile=\"explore|plan|iosm|iosm_analyst|iosm_verifier|cycle_planner|full\" agent=\"optional custom subagent name\" description=\"short title\" cwd=\"optional relative path\" lock_key=\"optional lock key\" model=\"optional model override\" isolation=\"none|worktree\" depends_on=\"optional indices like 1|3\">`,\n\t\t\"Detailed delegated task prompt\",\n\t\t`</${delegationTagName}>`,\n\t\t`Only emit blocks when necessary. Keep normal analysis/answer text outside those blocks.`,\n\t\t`When shared_memory tools are available, exchange intermediate state through shared_memory_write/shared_memory_read instead of repeating large context.`,\n\t].join(\"\\n\");\n}\n\nfunction withDelegationPrompt(basePrompt: string, depthRemaining: number, maxDelegations: number): string {\n\tconst protocol = buildDelegationProtocolPrompt(depthRemaining, maxDelegations);\n\treturn `${basePrompt}\\n\\n${protocol}`;\n}\n\nfunction buildSharedMemoryGuidance(runId: string, taskId: string | undefined): string {\n\treturn [\n\t\t\"[SHARED_MEMORY]\",\n\t\t`run_id: ${runId}`,\n\t\t`task_id: ${taskId ?? \"(none)\"}`,\n\t\t\"Use shared_memory_write/shared_memory_read to exchange intermediate state across parallel agents and delegates.\",\n\t\t\"Guidelines:\",\n\t\t\"- Use scope=run for cross-agent data and scope=task for task-local notes.\",\n\t\t\"- Keep entries compact and key-based (for example: findings/auth, plan/step-1, risks/session).\",\n\t\t\"- Read before overwrite when collaborating on the same key.\",\n\t\t\"[/SHARED_MEMORY]\",\n\t].join(\"\\n\");\n}\n\nfunction parseDelegationRequests(output: string, maxRequests: number): ParsedDelegationRequests {\n\tconst requests: DelegationRequest[] = [];\n\tconst warnings: string[] = [];\n\tconst pattern = new RegExp(`<${delegationTagName}\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/${delegationTagName}>`, \"gi\");\n\n\tconst cleaned = output.replace(pattern, (_full, attrsRaw: string, bodyRaw: string) => {\n\t\tif (maxRequests <= 0) {\n\t\t\twarnings.push(`Ignored delegation block: max delegated tasks per run is 0.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tif (requests.length >= maxRequests) {\n\t\t\twarnings.push(`Ignored extra delegation block: max ${maxRequests} per run.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tconst attrs: Record<string, string> = {};\n\t\tfor (const match of attrsRaw.matchAll(/([A-Za-z_][A-Za-z0-9_-]*)=\"([^\"]*)\"/g)) {\n\t\t\tattrs[match[1].toLowerCase()] = match[2];\n\t\t}\n\n\t\tconst prompt = normalizeSpacing(bodyRaw ?? \"\");\n\t\tif (!prompt) {\n\t\t\twarnings.push(`Ignored delegation block with empty prompt.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tconst profile = (attrs.profile ?? \"explore\").trim();\n\t\tif (!(profile in toolsByProfile)) {\n\t\t\twarnings.push(`Ignored delegation block with unknown profile \"${profile}\".`);\n\t\t\treturn \"\";\n\t\t}\n\t\tconst isolationRaw = (attrs.isolation ?? \"\").trim().toLowerCase();\n\t\tconst isolation =\n\t\t\tisolationRaw === \"worktree\" ? \"worktree\" : isolationRaw === \"none\" ? \"none\" : undefined;\n\t\tif (isolationRaw && !isolation) {\n\t\t\twarnings.push(`Ignored invalid isolation value \"${attrs.isolation}\".`);\n\t\t\treturn \"\";\n\t\t}\n\n\t\trequests.push({\n\t\t\tdescription: (attrs.description ?? `delegated task ${requests.length + 1}`).trim(),\n\t\t\tprofile,\n\t\t\tagent: attrs.agent?.trim() || undefined,\n\t\t\tprompt,\n\t\t\tcwd: attrs.cwd?.trim() || undefined,\n\t\t\tlockKey: attrs.lock_key?.trim() || undefined,\n\t\t\tmodel: attrs.model?.trim() || undefined,\n\t\t\tisolation,\n\t\t\tdependsOn: attrs.depends_on\n\t\t\t\t? attrs.depends_on\n\t\t\t\t\t\t.split(/[|,]/)\n\t\t\t\t\t\t.map((token) => Number.parseInt(token.trim(), 10))\n\t\t\t\t\t\t.filter((value) => Number.isInteger(value) && value > 0)\n\t\t\t\t: undefined,\n\t\t});\n\t\treturn \"\";\n\t});\n\n\treturn {\n\t\trequests,\n\t\twarnings,\n\t\tcleanedOutput: normalizeSpacing(cleaned),\n\t};\n}\n\nfunction getCwdLockKey(cwd: string): string {\n\t// Normalize lock key to keep behavior consistent across path aliases.\n\treturn path.resolve(cwd).toLowerCase();\n}\n\nfunction getOrCreateWriteLock(cwd: string): Mutex {\n\tconst key = getCwdLockKey(cwd);\n\tconst existing = cwdWriteLocks.get(key);\n\tif (existing) return existing;\n\tconst created = new Mutex();\n\tcwdWriteLocks.set(key, created);\n\treturn created;\n}\n\nfunction cleanupWriteLock(lockKey: string | undefined): void {\n\tif (!lockKey) return;\n\tconst key = getCwdLockKey(lockKey);\n\tconst existing = cwdWriteLocks.get(key);\n\tif (!existing || !existing.isIdle()) return;\n\tcwdWriteLocks.delete(key);\n}\n\nfunction getRunParallelLimit(cwd: string, runId: string): number | undefined {\n\tconst teamRun = getTeamRun(cwd, runId);\n\tif (!teamRun) return undefined;\n\tif (teamRun.mode === \"sequential\") return 1;\n\tconst maxParallel = teamRun.maxParallel;\n\tif (!Number.isInteger(maxParallel) || !maxParallel || maxParallel < 1) {\n\t\treturn Math.max(1, Math.min(teamRun.agents, 20));\n\t}\n\treturn Math.max(1, Math.min(maxParallel, 20));\n}\n\nfunction getOrCreateOrchestrationSemaphore(cwd: string, runId: string): Semaphore | undefined {\n\tconst limit = getRunParallelLimit(cwd, runId);\n\tif (!limit || limit < 1) return undefined;\n\tconst key = `${path.resolve(cwd).toLowerCase()}::${runId}::${limit}`;\n\tconst existing = orchestrationSemaphores.get(key);\n\tif (existing) return existing;\n\tconst created = new Semaphore(limit);\n\torchestrationSemaphores.set(key, created);\n\treturn created;\n}\n\nfunction isTeamTaskTerminal(status: string | undefined): boolean {\n\treturn status === \"done\" || status === \"error\" || status === \"cancelled\";\n}\n\nfunction cleanupOrchestrationSemaphore(cwd: string, runId: string): void {\n\tconst prefix = `${path.resolve(cwd).toLowerCase()}::${runId}::`;\n\tconst run = getTeamRun(cwd, runId);\n\tconst canDeleteForRun = !run || run.tasks.every((task) => isTeamTaskTerminal(task.status));\n\tif (!canDeleteForRun) return;\n\tfor (const [key, semaphore] of orchestrationSemaphores.entries()) {\n\t\tif (!key.startsWith(prefix)) continue;\n\t\tif (!semaphore.isIdle()) continue;\n\t\torchestrationSemaphores.delete(key);\n\t}\n}\n\nfunction waitForWithAbort(ms: number, signal?: AbortSignal): Promise<void> {\n\tif (!signal) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\tif (signal.aborted) {\n\t\treturn Promise.reject(new Error(\"Operation aborted\"));\n\t}\n\treturn new Promise((resolve, reject) => {\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tconst onAbort = (): void => {\n\t\t\tclearTimeout(timer);\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\treject(new Error(\"Operation aborted\"));\n\t\t};\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nasync function waitForOrchestrationDependencies(input: {\n\tcwd: string;\n\trunId: string;\n\ttaskId: string;\n\tsignal?: AbortSignal;\n\tonWaiting?: (message: string) => void;\n}): Promise<void> {\n\tconst started = Date.now();\n\tlet lastWaiting = \"\";\n\twhile (true) {\n\t\tif (input.signal?.aborted) {\n\t\t\tthrow new Error(\"Operation aborted\");\n\t\t}\n\t\tconst run = getTeamRun(input.cwd, input.runId);\n\t\tif (!run) {\n\t\t\treturn;\n\t\t}\n\t\tconst current = run.tasks.find((task) => task.id === input.taskId);\n\t\tif (!current) {\n\t\t\tthrow new Error(`Orchestration metadata missing task ${input.taskId} in run ${input.runId}.`);\n\t\t}\n\t\tconst dependencies = current.dependsOn ?? [];\n\t\tif (dependencies.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tconst dependencyTasks = dependencies.map((id) => run.tasks.find((task) => task.id === id));\n\t\tconst missing = dependencyTasks\n\t\t\t.map((task, index) => (task ? undefined : dependencies[index]))\n\t\t\t.filter((value): value is string => typeof value === \"string\");\n\t\tif (missing.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Orchestration metadata invalid for ${input.taskId}: missing dependency task(s) ${missing.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tconst failed = dependencyTasks.filter(\n\t\t\t(task): task is NonNullable<typeof task> => !!task && (task.status === \"error\" || task.status === \"cancelled\"),\n\t\t);\n\t\tif (failed.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Blocked by failed dependency: ${failed.map((task) => `${task.id}=${task.status}`).join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tconst pending = dependencyTasks.filter(\n\t\t\t(task): task is NonNullable<typeof task> => !!task && task.status !== \"done\",\n\t\t);\n\t\tif (pending.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tconst waitedMs = Date.now() - started;\n\t\tif (waitedMs >= orchestrationDependencyWaitTimeoutMsFromEnv) {\n\t\t\tthrow new Error(\n\t\t\t\t`Timed out waiting for dependencies of ${input.taskId}: ${pending\n\t\t\t\t\t.map((task) => `${task.id}=${task.status}`)\n\t\t\t\t\t.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tconst waiting = pending.map((task) => `${task.id}=${task.status}`).join(\", \");\n\t\tif (waiting !== lastWaiting) {\n\t\t\tlastWaiting = waiting;\n\t\t\tinput.onWaiting?.(waiting);\n\t\t}\n\t\tawait waitForWithAbort(orchestrationDependencyPollMsFromEnv, input.signal);\n\t}\n}\n\nfunction persistSubagentTranscript(input: {\n\trootCwd: string;\n\trunId: string;\n\tdescription: string;\n\tprofile: string;\n\tagent?: string;\n\tlockKey?: string;\n\tmodel?: string;\n\tsubagentCwd: string;\n\tsessionId?: string;\n\tprompt: string;\n\toutput: string;\n\tisolation?: \"none\" | \"worktree\";\n\tworktreePath?: string;\n}): string | undefined {\n\ttry {\n\t\tconst dir = path.join(input.rootCwd, \".iosm\", \"subagents\", \"runs\");\n\t\tmkdirSync(dir, { recursive: true });\n\t\tconst filePath = path.join(dir, `${input.runId}.md`);\n\t\tconst lines = [\n\t\t\t\"---\",\n\t\t\t`run_id: ${input.runId}`,\n\t\t\t`profile: ${input.profile}`,\n\t\t\t`description: ${JSON.stringify(input.description)}`,\n\t\t\t`cwd: ${JSON.stringify(input.subagentCwd)}`,\n\t\t\t`agent: ${JSON.stringify(input.agent ?? \"\")}`,\n\t\t\t`lock_key: ${JSON.stringify(input.lockKey ?? \"\")}`,\n\t\t\t`model: ${JSON.stringify(input.model ?? \"\")}`,\n\t\t\t`session_id: ${JSON.stringify(input.sessionId ?? \"\")}`,\n\t\t\t`isolation: ${JSON.stringify(input.isolation ?? \"none\")}`,\n\t\t\t`worktree_path: ${JSON.stringify(input.worktreePath ?? \"\")}`,\n\t\t\t`created_at: ${new Date().toISOString()}`,\n\t\t\t\"---\",\n\t\t\t\"\",\n\t\t\t\"## Prompt\",\n\t\t\t\"\",\n\t\t\tinput.prompt,\n\t\t\t\"\",\n\t\t\t\"## Output\",\n\t\t\t\"\",\n\t\t\tinput.output,\n\t\t\t\"\",\n\t\t];\n\t\twriteFileSync(filePath, lines.join(\"\\n\"), \"utf8\");\n\t\treturn filePath;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ntype BackgroundRunStatus = {\n\trunId: string;\n\tstatus: \"queued\" | \"running\" | \"done\" | \"error\" | \"cancelled\";\n\tcreatedAt: string;\n\tstartedAt?: string;\n\tfinishedAt?: string;\n\tdescription: string;\n\tprofile: string;\n\tcwd: string;\n\tagent?: string;\n\tmodel?: string;\n\terror?: string;\n\ttranscriptPath?: string;\n};\n\nfunction writeBackgroundRunStatus(rootCwd: string, status: BackgroundRunStatus): string | undefined {\n\ttry {\n\t\tconst dir = path.join(rootCwd, \".iosm\", \"subagents\", \"background\");\n\t\tmkdirSync(dir, { recursive: true });\n\t\tconst filePath = path.join(dir, `${status.runId}.json`);\n\t\twriteFileSync(filePath, `${JSON.stringify(status, null, 2)}\\n`, \"utf8\");\n\t\treturn filePath;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction gitResult(args: string[], cwd: string): { ok: boolean; stdout: string } {\n\tconst result = spawnSync(\"git\", args, {\n\t\tcwd,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\treturn {\n\t\tok: result.status === 0,\n\t\tstdout: (result.stdout ?? \"\").trim(),\n\t};\n}\n\nfunction provisionWorktree(\n\trootCwd: string,\n\ttargetCwd: string,\n\trunId: string,\n): { runCwd: string; worktreePath?: string; cleanup: () => void } {\n\tconst insideRepo = gitResult([\"rev-parse\", \"--is-inside-work-tree\"], rootCwd);\n\tif (!insideRepo.ok || insideRepo.stdout !== \"true\") {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\tconst repoRootResult = gitResult([\"rev-parse\", \"--show-toplevel\"], rootCwd);\n\tif (!repoRootResult.ok || !repoRootResult.stdout) {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\n\tconst repoRoot = repoRootResult.stdout;\n\tconst relative = path.relative(repoRoot, targetCwd);\n\tif (relative.startsWith(\"..\")) {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\n\tconst worktreePath = path.join(rootCwd, \".iosm\", \"subagents\", \"worktrees\", runId);\n\tmkdirSync(path.dirname(worktreePath), { recursive: true });\n\tconst added = gitResult([\"worktree\", \"add\", \"--detach\", worktreePath], repoRoot);\n\tif (!added.ok) {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\n\tconst runCwd = path.resolve(worktreePath, relative);\n\tconst cleanup = (): void => {\n\t\ttry {\n\t\t\tgitResult([\"worktree\", \"remove\", \"--force\", worktreePath], repoRoot);\n\t\t} catch {\n\t\t\t// best effort\n\t\t}\n\t\ttry {\n\t\t\trmSync(worktreePath, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// best effort\n\t\t}\n\t};\n\n\treturn { runCwd, worktreePath, cleanup };\n}\n\n/**\n * Create the Task tool using the factory pattern.\n *\n * The `runner` callback is supplied by sdk.ts to avoid a circular import:\n * sdk.ts → task.ts (tool) would otherwise import sdk.ts again.\n *\n * @param cwd Working directory forwarded to the subagent.\n * @param runner Callback that creates and runs a sub-session.\n */\nexport function createTaskTool(\n\tcwd: string,\n\trunner: SubagentRunner,\n\toptions?: TaskToolOptions,\n): AgentTool<typeof taskSchema> {\n\tconst customAgentsSnippet =\n\t\toptions?.availableCustomSubagentHints && options.availableCustomSubagentHints.length > 0\n\t\t\t? ` Available custom agents: ${options.availableCustomSubagentHints\n\t\t\t\t\t.map((item) => `${item.name} (${item.description})`)\n\t\t\t\t\t.join(\", \")}.`\n\t\t\t: options?.availableCustomSubagents && options.availableCustomSubagents.length > 0\n\t\t\t\t? ` Available custom agents: ${options.availableCustomSubagents.join(\", \")}.`\n\t\t\t: \"\";\n\treturn {\n\t\tname: \"task\",\n\t\tlabel: \"task\",\n\t\tdescription:\n\t\t\t\"Launch a specialized subagent to handle a subtask in isolation. \" +\n\t\t\t\"Use for: codebase exploration (profile=explore), architectural planning (profile=plan), \" +\n\t\t\t\"IOSM artifact analysis (profile=iosm_analyst/iosm_verifier/cycle_planner), or end-to-end implementation (profile=full). \" +\n\t\t\t\"Set cwd to isolate subagents into different project areas when orchestrating parallel work. \" +\n\t\t\t\"The subagent runs to completion and returns its full text output. \" +\n\t\t\t\"It may request bounded follow-up delegation via <delegate_task> blocks that are executed by the parent task tool.\" +\n\t\t\tcustomAgentsSnippet,\n\t\tparameters: taskSchema,\n\t\texecute: async (\n\t\t\t_toolCallId: string,\n\t\t\t{\n\t\t\t\tdescription,\n\t\t\t\tprompt,\n\t\t\t\tagent: agentName,\n\t\t\t\tprofile,\n\t\t\t\tcwd: targetCwd,\n\t\t\t\tlock_key: lockKey,\n\t\t\t\trun_id: orchestrationRunId,\n\t\t\t\ttask_id: orchestrationTaskId,\n\t\t\t\tmodel: requestedModel,\n\t\t\t\tbackground,\n\t\t\t\tisolation,\n\t\t\t\tdelegate_parallel_hint: delegateParallelHint,\n\t\t\t}: TaskToolInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\tonUpdate?,\n\t\t) => {\n\t\t\tconst updateTrackedTaskStatus = (status: \"running\" | \"done\" | \"error\" | \"cancelled\"): void => {\n\t\t\t\tif (!orchestrationRunId || !orchestrationTaskId) return;\n\t\t\t\tupdateTeamTaskStatus({\n\t\t\t\t\tcwd,\n\t\t\t\t\trunId: orchestrationRunId,\n\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\tstatus,\n\t\t\t\t});\n\t\t\t};\n\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\tif (_signal?.aborted) {\n\t\t\t\t\tupdateTrackedTaskStatus(\"cancelled\");\n\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t\tconst runId = `subagent_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;\n\t\t\t\tconst sharedMemoryRunId = orchestrationRunId?.trim() || runId;\n\t\t\t\tconst sharedMemoryTaskId = orchestrationTaskId?.trim() || runId;\n\t\t\t\tconst availableCustomNames = options?.availableCustomSubagents ?? [];\n\t\t\t\tconst resolveCustom = (name: string | undefined): CustomSubagentDefinition | undefined => {\n\t\t\t\t\tif (!name || !options?.resolveCustomSubagent) return undefined;\n\t\t\t\t\treturn options.resolveCustomSubagent(name);\n\t\t\t\t};\n\n\t\t\t\tlet normalizedAgentName = agentName?.trim() || undefined;\n\t\t\t\tlet normalizedProfile = profile.trim().toLowerCase();\n\t\t\t\tif (!normalizedProfile) normalizedProfile = \"full\";\n\n\t\t\t\tlet customSubagent = resolveCustom(normalizedAgentName);\n\t\t\t\tif (normalizedAgentName && !customSubagent) {\n\t\t\t\t\tconst available =\n\t\t\t\t\t\tavailableCustomNames.length > 0 ? ` Available custom agents: ${availableCustomNames.join(\", \")}.` : \"\";\n\t\t\t\t\tthrow new Error(`Unknown subagent: ${normalizedAgentName}.${available}`);\n\t\t\t\t}\n\n\t\t\t\t// Recovery path: if model placed a custom agent name into `profile`, remap automatically.\n\t\t\t\tif (!customSubagent) {\n\t\t\t\t\tconst profileAsAgent = resolveCustom(normalizedProfile);\n\t\t\t\t\tif (profileAsAgent) {\n\t\t\t\t\t\tcustomSubagent = profileAsAgent;\n\t\t\t\t\t\tnormalizedAgentName = profileAsAgent.name;\n\t\t\t\t\t\tnormalizedProfile = (profileAsAgent.profile ?? \"full\").trim().toLowerCase();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!toolsByProfile[normalizedProfile]) {\n\t\t\t\t\tnormalizedProfile = \"full\";\n\t\t\t\t}\n\n\t\t\t\tconst effectiveProfile = customSubagent?.profile ?? normalizedProfile;\n\t\t\tlet tools = customSubagent?.tools\n\t\t\t\t? [...customSubagent.tools]\n\t\t\t\t: [...(toolsByProfile[effectiveProfile] ?? toolsByProfile.explore)];\n\t\t\tif (customSubagent?.disallowedTools?.length) {\n\t\t\t\tconst blocked = new Set(customSubagent.disallowedTools);\n\t\t\t\ttools = tools.filter((tool) => !blocked.has(tool));\n\t\t\t}\n\t\t\tconst delegationDepth = maxDelegationDepthFromEnv;\n\t\t\tconst requestedDelegateParallelHint =\n\t\t\t\ttypeof delegateParallelHint === \"number\" && Number.isInteger(delegateParallelHint)\n\t\t\t\t\t? Math.max(1, Math.min(10, delegateParallelHint))\n\t\t\t\t\t: undefined;\n\t\t\t\tconst autoDelegateParallelHint =\n\t\t\t\t\trequestedDelegateParallelHint === undefined\n\t\t\t\t\t\t? deriveAutoDelegateParallelHint(normalizedAgentName, description, prompt)\n\t\t\t\t\t\t: undefined;\n\t\t\tconst effectiveDelegateParallelHint = requestedDelegateParallelHint ?? autoDelegateParallelHint;\n\t\t\tconst effectiveMaxDelegations = Math.max(\n\t\t\t\t0,\n\t\t\t\tMath.min(maxDelegationsPerTaskFromEnv, effectiveDelegateParallelHint ?? maxDelegationsPerTaskFromEnv),\n\t\t\t);\n\t\t\tconst effectiveMaxDelegateParallel = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.min(maxDelegatedParallelFromEnv, effectiveDelegateParallelHint ?? maxDelegatedParallelFromEnv),\n\t\t\t);\n\t\t\tconst minDelegationsPreferred =\n\t\t\t\t(effectiveDelegateParallelHint ?? 0) >= 2 && effectiveMaxDelegations >= 2\n\t\t\t\t\t? Math.min(2, effectiveMaxDelegations)\n\t\t\t\t\t: 0;\n\t\t\tconst baseSystemPrompt =\n\t\t\t\tcustomSubagent?.systemPrompt ??\n\t\t\t\tsystemPromptByProfile[effectiveProfile] ??\n\t\t\t\tsystemPromptByProfile.full;\n\t\t\tconst systemPrompt = withDelegationPrompt(baseSystemPrompt, delegationDepth, effectiveMaxDelegations);\n\t\t\tconst promptWithInstructions =\n\t\t\t\tcustomSubagent?.instructions && customSubagent.instructions.trim().length > 0\n\t\t\t\t\t? `${customSubagent.instructions.trim()}\\n\\nUser task:\\n${prompt}`\n\t\t\t\t\t: prompt;\n\t\t\tconst effectiveModelOverride = requestedModel?.trim() || customSubagent?.model?.trim() || undefined;\n\t\t\tconst requestedBackground = background === true || customSubagent?.background === true;\n\t\t\tconst trackedOrchestrationRun =\n\t\t\t\torchestrationRunId && orchestrationTaskId ? getTeamRun(cwd, orchestrationRunId) : undefined;\n\t\t\t// Deterministic orchestration UX: run tracked team tasks in foreground so the parent turn\n\t\t\t// naturally waits for subagents and aggregates their outputs without ad-hoc polling.\n\t\t\tconst runInBackground = trackedOrchestrationRun ? false : requestedBackground;\n\t\t\tconst requestedSubagentCwd = targetCwd\n\t\t\t\t? path.resolve(cwd, targetCwd)\n\t\t\t\t: customSubagent?.cwd ?? cwd;\n\t\t\tif (!existsSync(requestedSubagentCwd) || !statSync(requestedSubagentCwd).isDirectory()) {\n\t\t\t\tthrow new Error(`Subagent cwd does not exist or is not a directory: ${requestedSubagentCwd}`);\n\t\t\t}\n\t\t\tif (runInBackground && writeCapableProfiles.has(effectiveProfile)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Background policy violation: profile \"${effectiveProfile}\" is write-capable. Use explore/plan/iosm_analyst for background mode.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst useWorktree = isolation === \"worktree\";\n\n\t\t\tconst queuedAt = Date.now();\n\t\t\tlet latestProgress: TaskToolProgress | undefined;\n\t\t\tconst emitProgress = (incoming: TaskToolProgress): void => {\n\t\t\t\tconst activeTool = \"activeTool\" in incoming ? incoming.activeTool : latestProgress?.activeTool;\n\t\t\t\tconst delegateIndex = \"delegateIndex\" in incoming ? incoming.delegateIndex : latestProgress?.delegateIndex;\n\t\t\t\tconst delegateTotal = \"delegateTotal\" in incoming ? incoming.delegateTotal : latestProgress?.delegateTotal;\n\t\t\t\tconst delegateDescription =\n\t\t\t\t\t\"delegateDescription\" in incoming ? incoming.delegateDescription : latestProgress?.delegateDescription;\n\t\t\t\tconst delegateProfile =\n\t\t\t\t\t\"delegateProfile\" in incoming ? incoming.delegateProfile : latestProgress?.delegateProfile;\n\t\t\t\tconst delegateItems =\n\t\t\t\t\t\"delegateItems\" in incoming\n\t\t\t\t\t\t? cloneDelegateItems(incoming.delegateItems)\n\t\t\t\t\t\t: cloneDelegateItems(latestProgress?.delegateItems);\n\t\t\t\tconst merged: TaskToolProgress = {\n\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\tphase: incoming.phase,\n\t\t\t\t\tmessage: incoming.message,\n\t\t\t\t\tcwd: incoming.cwd ?? latestProgress?.cwd ?? requestedSubagentCwd,\n\t\t\t\t\tactiveTool,\n\t\t\t\t\ttoolCallsStarted: incoming.toolCallsStarted ?? latestProgress?.toolCallsStarted,\n\t\t\t\t\ttoolCallsCompleted: incoming.toolCallsCompleted ?? latestProgress?.toolCallsCompleted,\n\t\t\t\t\tassistantMessages: incoming.assistantMessages ?? latestProgress?.assistantMessages,\n\t\t\t\t\tdelegateIndex,\n\t\t\t\t\tdelegateTotal,\n\t\t\t\t\tdelegateDescription,\n\t\t\t\t\tdelegateProfile,\n\t\t\t\t\tdelegateItems,\n\t\t\t\t};\n\t\t\t\tlatestProgress = merged;\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tonUpdate({\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: merged.message }],\n\t\t\t\t\tdetails: { progress: merged },\n\t\t\t\t});\n\t\t\t};\n\t\t\tthrowIfAborted();\n\t\t\temitProgress({\n\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\tphase: \"queued\",\n\t\t\t\tmessage: \"queued\",\n\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\ttoolCallsStarted: 0,\n\t\t\t\ttoolCallsCompleted: 0,\n\t\t\t\tassistantMessages: 0,\n\t\t\t});\n\n\t\t\tconst executeSubagent = async (): Promise<{ text: string; details: TaskToolDetails }> => {\n\t\t\t\tlet releaseRunSlot: (() => void) | undefined;\n\t\t\t\tlet releaseSlot: (() => void) | undefined;\n\t\t\t\tlet releaseWriteLock: (() => void) | undefined;\n\t\t\t\tlet releaseIsolation: (() => void) | undefined;\n\t\t\t\tconst explicitRootLockKey = lockKey?.trim();\n\t\t\t\tlet subagentCwd = requestedSubagentCwd;\n\t\t\t\tlet worktreePath: string | undefined;\n\t\t\t\tlet runStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tif (orchestrationRunId && orchestrationTaskId) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait waitForOrchestrationDependencies({\n\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\trunId: orchestrationRunId,\n\t\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\tonWaiting: (waiting) => {\n\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\tphase: \"queued\",\n\t\t\t\t\t\t\t\t\t\tmessage: `waiting for dependencies: ${waiting}`,\n\t\t\t\t\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\tupdateTrackedTaskStatus(\"cancelled\");\n\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\tupdateTrackedTaskStatus(\"error\");\n\t\t\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\t\t\t\tfailureCauses: { [cause]: 1 },\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tthrow Object.assign(new Error(`Subagent failed: ${message}`), { details });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tconst orchestrationSemaphore =\n\t\t\t\t\t\torchestrationRunId && orchestrationTaskId\n\t\t\t\t\t\t\t? getOrCreateOrchestrationSemaphore(cwd, orchestrationRunId)\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\tif (orchestrationSemaphore) {\n\t\t\t\t\t\treleaseRunSlot = await orchestrationSemaphore.acquire();\n\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t}\n\t\t\t\t\treleaseSlot = await subagentSemaphore.acquire();\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tupdateTrackedTaskStatus(\"running\");\n\t\t\t\t\tif (writeCapableProfiles.has(effectiveProfile)) {\n\t\t\t\t\t\t// Parallel orchestration should remain truly parallel by default.\n\t\t\t\t\t\t// Serialize write-capable agents only when an explicit lock_key is provided.\n\t\t\t\t\t\tif (explicitRootLockKey) {\n\t\t\t\t\t\t\tconst lock = getOrCreateWriteLock(explicitRootLockKey);\n\t\t\t\t\t\t\treleaseWriteLock = await lock.acquire();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (useWorktree) {\n\t\t\t\t\t\tconst isolated = provisionWorktree(cwd, requestedSubagentCwd, runId);\n\t\t\t\t\t\tsubagentCwd = isolated.runCwd;\n\t\t\t\t\t\tworktreePath = isolated.worktreePath;\n\t\t\t\t\t\treleaseIsolation = isolated.cleanup;\n\t\t\t\t\t}\n\t\t\t\t\temitProgress({\n\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\tphase: \"starting\",\n\t\t\t\t\t\tmessage: \"starting subagent\",\n\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t});\n\n\t\t\t\t\t\tlet output: string;\n\t\t\t\t\t\tlet subagentSessionId: string | undefined;\n\t\t\t\t\t\tlet delegatedTasks = 0;\n\t\t\t\t\t\tlet delegatedSucceeded = 0;\n\t\t\t\t\t\tlet delegatedFailed = 0;\n\t\t\t\t\t\tlet retrospectiveAttempts = 0;\n\t\t\t\t\t\tlet retrospectiveRecovered = 0;\n\t\t\t\t\t\tconst delegationWarnings: string[] = [];\n\t\t\t\t\t\tconst delegatedSections: Array<string | undefined> = [];\n\t\t\t\t\t\tconst failureCauses: Partial<Record<FailureCause, number>> = {};\n\t\t\t\t\t\tconst delegatedStats = {\n\t\t\t\t\t\t\ttoolCallsStarted: 0,\n\t\t\t\t\t\t\ttoolCallsCompleted: 0,\n\t\t\t\t\t\t\tassistantMessages: 0,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst recordFailureCause = (cause: FailureCause): void => {\n\t\t\t\t\t\t\tfailureCauses[cause] = (failureCauses[cause] ?? 0) + 1;\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst rootSharedMemoryContext: SharedMemoryContext = {\n\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\t\trunId: sharedMemoryRunId,\n\t\t\t\t\t\t\ttaskId: sharedMemoryTaskId,\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t};\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst runRootPass = async (runPrompt: string): Promise<{\n\t\t\t\t\t\t\t\toutput: string;\n\t\t\t\t\t\t\t\tsessionId?: string;\n\t\t\t\t\t\t\t\tstats?: SubagentRunResult[\"stats\"];\n\t\t\t\t\t\t\t}> => {\n\t\t\t\t\t\t\t\tlet emptyAttempt = 0;\n\t\t\t\t\t\t\t\tlet retrospectiveAttempt = 0;\n\t\t\t\t\t\t\t\tlet mergedStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\tlet sessionId: string | undefined;\n\t\t\t\t\t\t\t\tlet promptForAttempt = runPrompt;\n\t\t\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tconst result = await runner({\n\t\t\t\t\t\t\t\t\t\t\tsystemPrompt,\n\t\t\t\t\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\t\t\t\t\tprompt: promptForAttempt,\n\t\t\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\t\t\tmodelOverride: effectiveModelOverride,\n\t\t\t\t\t\t\t\t\t\t\tsharedMemoryContext: rootSharedMemoryContext,\n\t\t\t\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\t\t\t\tonProgress: (progress) => emitProgress(progress),\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\t\t\t\t\t\tlet attemptOutput: string;\n\t\t\t\t\t\t\t\t\t\tlet attemptStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\t\t\tif (typeof result === \"string\") {\n\t\t\t\t\t\t\t\t\t\t\tattemptOutput = result;\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tattemptOutput = result.output;\n\t\t\t\t\t\t\t\t\t\t\tattemptStats = result.stats;\n\t\t\t\t\t\t\t\t\t\t\tsessionId = result.sessionId ?? sessionId;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tmergedStats = mergeRunStats(mergedStats, attemptStats);\n\t\t\t\t\t\t\t\t\t\tif (attemptOutput.trim().length > 0) {\n\t\t\t\t\t\t\t\t\t\t\tif (retrospectiveAttempt > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tretrospectiveRecovered += 1;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\toutput: attemptOutput,\n\t\t\t\t\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t\t\t\t\t\tstats: mergedStats,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (emptyAttempt >= emptyOutputRetriesFromEnv) {\n\t\t\t\t\t\t\t\t\t\t\tconst totalAttempts = emptyAttempt + 1;\n\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t\t`Subagent returned empty output after ${totalAttempts} attempt${totalAttempts === 1 ? \"\" : \"s\"}.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\temptyAttempt += 1;\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\tmessage: `root subagent returned empty output; retry ${emptyAttempt}/${emptyOutputRetriesFromEnv}`,\n\t\t\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\t\trecordFailureCause(cause);\n\t\t\t\t\t\t\t\t\t\tconst canRetryRetrospective =\n\t\t\t\t\t\t\t\t\t\t\tretrospectiveAttempt < retrospectiveRetriesFromEnv && isRetrospectiveRetryable(cause);\n\t\t\t\t\t\t\t\t\t\tif (!canRetryRetrospective) {\n\t\t\t\t\t\t\t\t\t\t\tthrow Object.assign(new Error(message), { failureCause: cause as FailureCause });\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tretrospectiveAttempt += 1;\n\t\t\t\t\t\t\t\t\t\tretrospectiveAttempts += 1;\n\t\t\t\t\t\t\t\t\t\tconst directive = buildRetrospectiveDirective({\n\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t\terrorMessage: message,\n\t\t\t\t\t\t\t\t\t\t\tattempt: retrospectiveAttempt,\n\t\t\t\t\t\t\t\t\t\t\ttarget: \"root\",\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tpromptForAttempt = `${runPrompt}\\n\\n${directive}`;\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\tmessage: `root retrospective retry ${retrospectiveAttempt}/${retrospectiveRetriesFromEnv} (${cause})`,\n\t\t\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst rootMeta = formatMetaCheckpoint(options?.getMetaMessages?.());\n\t\t\t\t\t\t\tconst rootSharedMemoryGuidance = buildSharedMemoryGuidance(sharedMemoryRunId, sharedMemoryTaskId);\n\t\t\t\t\t\t\tconst rootPromptBase = `${promptWithInstructions}\\n\\n${rootSharedMemoryGuidance}`;\n\t\t\t\t\t\t\tconst rootPrompt =\n\t\t\t\t\t\t\t\trootMeta.section && rootMeta.appliedCount > 0\n\t\t\t\t\t\t\t\t\t? `${rootPromptBase}\\n\\n${rootMeta.section}`\n\t\t\t\t\t\t\t\t\t: rootPromptBase;\n\t\t\t\t\t\tif (rootMeta.appliedCount > 0) {\n\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage: `applied ${rootMeta.appliedCount} meta update(s) to root task`,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst firstPass = await runRootPass(rootPrompt);\n\t\t\t\t\t\toutput = firstPass.output;\n\t\t\t\t\t\tsubagentSessionId = firstPass.sessionId;\n\t\t\t\t\t\trunStats = firstPass.stats;\n\n\t\t\t\t\t\tlet parsedDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\tdelegationDepth > 0 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (minDelegationsPreferred > 0 && parsedDelegation.requests.length < minDelegationsPreferred) {\n\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage: `delegation preference unmet (${parsedDelegation.requests.length}/${minDelegationsPreferred}), retrying with stronger split guidance`,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst enforcedPrompt = [\n\t\t\t\t\t\t\t\trootPrompt,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\t\"[DELEGATION_ENFORCEMENT]\",\n\t\t\t\t\t\t\t\t`Prefer emitting at least ${minDelegationsPreferred} <delegate_task> blocks for independent sub-work when beneficial.`,\n\t\t\t\t\t\t\t\t`Target parallel fan-out: up to ${effectiveMaxDelegateParallel}.`,\n\t\t\t\t\t\t\t\t\"If decomposition is not beneficial, you may keep single-agent execution and optionally output one line:\",\n\t\t\t\t\t\t\t\t\"DELEGATION_IMPOSSIBLE: <reason>\",\n\t\t\t\t\t\t\t\t\"[/DELEGATION_ENFORCEMENT]\",\n\t\t\t\t\t\t\t].join(\"\\n\");\n\t\t\t\t\t\t\tconst secondPass = await runRootPass(enforcedPrompt);\n\t\t\t\t\t\t\toutput = secondPass.output;\n\t\t\t\t\t\t\tsubagentSessionId = secondPass.sessionId ?? subagentSessionId;\n\t\t\t\t\t\t\trunStats = secondPass.stats ?? runStats;\n\t\t\t\t\t\t\tparsedDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\t\tdelegationDepth > 0 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (minDelegationsPreferred > 0 && parsedDelegation.requests.length < minDelegationsPreferred) {\n\t\t\t\t\t\t\tconst impossibleReason =\n\t\t\t\t\t\t\t\toutput.match(/^\\s*DELEGATION_IMPOSSIBLE\\s*:\\s*(.+)$/im)?.[1]?.trim() ?? \"not provided\";\n\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t`Delegation fallback: kept single-agent execution (preferred >=${minDelegationsPreferred} delegates, got ${parsedDelegation.requests.length}). Reason: ${impossibleReason}.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\toutput = parsedDelegation.cleanedOutput;\n\t\t\t\t\t\tdelegationWarnings.push(...parsedDelegation.warnings);\n\t\t\t\t\t\tconst delegateTotal = parsedDelegation.requests.length;\n\t\t\t\t\t\tconst delegateItems: TaskDelegateProgressItem[] = parsedDelegation.requests.map((request, index) => ({\n\t\t\t\t\t\t\tindex: index + 1,\n\t\t\t\t\t\t\tdescription: request.description,\n\t\t\t\t\t\t\tprofile: request.profile,\n\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst normalizedDependsOn: number[][] = parsedDelegation.requests.map((request, index) => {\n\t\t\t\t\t\t\tconst current = index + 1;\n\t\t\t\t\t\t\tconst raw = request.dependsOn ?? [];\n\t\t\t\t\t\t\tconst unique = new Set<number>();\n\t\t\t\t\t\t\tfor (const dep of raw) {\n\t\t\t\t\t\t\t\tif (!Number.isInteger(dep) || dep <= 0 || dep > delegateTotal || dep === current) {\n\t\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t\t`Delegated task ${current} has invalid depends_on reference \"${dep}\" and it was ignored.`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tunique.add(dep);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn Array.from(unique).sort((a, b) => a - b);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tdelegatedTasks += delegateTotal;\n\t\t\t\t\t\tif (delegateTotal > 0) {\n\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\tmessage: `delegation scheduler: ${delegateTotal} task(s), max parallel ${Math.min(delegateTotal, effectiveMaxDelegateParallel)}`,\n\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst pendingIndices = new Set<number>(Array.from({ length: delegateTotal }, (_v, i) => i));\n\t\t\t\t\t\tconst runningDelegates = new Map<number, Promise<void>>();\n\t\t\t\t\t\tconst maxDelegateParallel = Math.max(1, Math.min(delegateTotal || 1, effectiveMaxDelegateParallel));\n\n\t\t\t\t\t\tconst statusOf = (idx: number): TaskDelegateProgressStatus =>\n\t\t\t\t\t\t\tdelegateItems[idx]?.status ?? \"pending\";\n\t\t\t\t\t\tconst formatDelegateTarget = (request: DelegationRequest): string => {\n\t\t\t\t\t\t\tconst agent = request.agent?.trim();\n\t\t\t\t\t\t\treturn agent ? `${agent}/${request.profile}` : request.profile;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst markDelegateFailed = (\n\t\t\t\t\t\t\t\tindex: number,\n\t\t\t\t\t\t\t\tmessage: string,\n\t\t\t\t\t\t\t\tdetails?: string,\n\t\t\t\t\t\t\t\tcause?: FailureCause,\n\t\t\t\t\t\t\t): void => {\n\t\t\t\t\t\t\t\tconst request = parsedDelegation.requests[index];\n\t\t\t\t\t\t\t\tif (delegateItems[index]) {\n\t\t\t\t\t\t\t\t\tdelegateItems[index].status = \"failed\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdelegatedFailed += 1;\n\t\t\t\t\t\t\t\tif (details) {\n\t\t\t\t\t\t\t\t\tdelegationWarnings.push(cause ? `${details} [cause=${cause}]` : details);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst causeLabel = cause ? ` [cause=${cause}]` : \"\";\n\t\t\t\t\t\t\t\tdelegatedSections[index] = `#### ${index + 1}. ${request.description} (${formatDelegateTarget(request)})\\nERROR${causeLabel}: ${message}`;\n\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\tdelegateProfile: request.profile,\n\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst runDelegate = async (index: number): Promise<void> => {\n\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\tconst request = parsedDelegation.requests[index];\n\t\t\t\t\t\t\tconst requestedChildAgent = request.agent?.trim() || undefined;\n\t\t\t\t\t\t\tconst childCustomSubagent = resolveCustom(requestedChildAgent);\n\t\t\t\t\t\t\tif (requestedChildAgent && !childCustomSubagent) {\n\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t`Delegated task \"${request.description}\" requested unknown agent \"${requestedChildAgent}\". Falling back to profile \"${request.profile}\".`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst childProfileRaw = childCustomSubagent?.profile ?? request.profile;\n\t\t\t\t\t\t\tconst normalizedChildProfile = childProfileRaw.trim().toLowerCase();\n\t\t\t\t\t\t\tconst childProfile =\n\t\t\t\t\t\t\t\tnormalizedChildProfile && toolsByProfile[normalizedChildProfile]\n\t\t\t\t\t\t\t\t\t? normalizedChildProfile\n\t\t\t\t\t\t\t\t\t: \"full\";\n\t\t\t\t\t\t\tconst childProfileLabel = childCustomSubagent?.name\n\t\t\t\t\t\t\t\t? `${childCustomSubagent.name}/${childProfile}`\n\t\t\t\t\t\t\t\t: childProfile;\n\t\t\t\t\t\t\tif (delegateItems[index]) {\n\t\t\t\t\t\t\t\tdelegateItems[index].status = \"running\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage: `delegating ${index + 1}/${delegateTotal}: ${request.description}`,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tlet childTools = childCustomSubagent?.tools\n\t\t\t\t\t\t\t\t? [...childCustomSubagent.tools]\n\t\t\t\t\t\t\t\t: [...(toolsByProfile[childProfile] ?? toolsByProfile.explore)];\n\t\t\t\t\t\t\tif (childCustomSubagent?.disallowedTools?.length) {\n\t\t\t\t\t\t\t\tconst blocked = new Set(childCustomSubagent.disallowedTools);\n\t\t\t\t\t\t\t\tchildTools = childTools.filter((tool) => !blocked.has(tool));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst childBaseSystemPrompt =\n\t\t\t\t\t\t\t\tchildCustomSubagent?.systemPrompt ??\n\t\t\t\t\t\t\t\tsystemPromptByProfile[childProfile] ??\n\t\t\t\t\t\t\t\tsystemPromptByProfile.full;\n\t\t\t\t\t\t\tconst childSystemPrompt = withDelegationPrompt(\n\t\t\t\t\t\t\t\tchildBaseSystemPrompt,\n\t\t\t\t\t\t\t\tMath.max(0, delegationDepth - 1),\n\t\t\t\t\t\t\t\teffectiveMaxDelegations,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst requestedChildCwd = request.cwd\n\t\t\t\t\t\t\t\t\t? path.resolve(subagentCwd, request.cwd)\n\t\t\t\t\t\t\t\t\t: childCustomSubagent?.cwd ?? subagentCwd;\n\t\t\t\t\t\t\t\tif (!existsSync(requestedChildCwd) || !statSync(requestedChildCwd).isDirectory()) {\n\t\t\t\t\t\t\t\t\trecordFailureCause(\"dependency_env\");\n\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} skipped: missing cwd`,\n\t\t\t\t\t\t\t\t\t\t`Delegated task \"${request.description}\" skipped: cwd does not exist (${requestedChildCwd}).`,\n\t\t\t\t\t\t\t\t\t\t\"dependency_env\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet childReleaseLock: (() => void) | undefined;\n\t\t\t\t\t\t\tlet childReleaseIsolation: (() => void) | undefined;\n\t\t\t\t\t\t\tconst explicitChildLock = request.lockKey?.trim();\n\t\t\t\t\t\t\tlet childCwd = requestedChildCwd;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\tif (writeCapableProfiles.has(childProfile) && explicitChildLock) {\n\t\t\t\t\t\t\t\t\tconst lock = getOrCreateWriteLock(explicitChildLock);\n\t\t\t\t\t\t\t\t\tchildReleaseLock = await lock.acquire();\n\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (request.isolation === \"worktree\") {\n\t\t\t\t\t\t\t\t\tconst isolated = provisionWorktree(cwd, requestedChildCwd, `${runId}_delegate_${index + 1}`);\n\t\t\t\t\t\t\t\t\tchildCwd = isolated.runCwd;\n\t\t\t\t\t\t\t\t\tchildReleaseIsolation = isolated.cleanup;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst delegateMeta = formatMetaCheckpoint(options?.getMetaMessages?.());\n\t\t\t\t\t\t\t\t\tconst childPromptWithInstructions =\n\t\t\t\t\t\t\t\t\t\tchildCustomSubagent?.instructions && childCustomSubagent.instructions.trim().length > 0\n\t\t\t\t\t\t\t\t\t\t\t? `${childCustomSubagent.instructions.trim()}\\n\\nUser task:\\n${request.prompt}`\n\t\t\t\t\t\t\t\t\t\t\t: request.prompt;\n\t\t\t\t\t\t\t\t\tconst delegateSharedMemoryGuidance = buildSharedMemoryGuidance(\n\t\t\t\t\t\t\t\t\t\tsharedMemoryRunId,\n\t\t\t\t\t\t\t\t\t\tsharedMemoryTaskId,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst delegatePromptBase = `${childPromptWithInstructions}\\n\\n${delegateSharedMemoryGuidance}`;\n\t\t\t\t\t\t\t\t\tconst delegatePrompt =\n\t\t\t\t\t\t\t\t\t\tdelegateMeta.section && delegateMeta.appliedCount > 0\n\t\t\t\t\t\t\t\t\t\t\t? `${delegatePromptBase}\\n\\n${delegateMeta.section}`\n\t\t\t\t\t\t\t\t\t\t\t: delegatePromptBase;\n\t\t\t\t\t\t\t\t\tif (delegateMeta.appliedCount > 0) {\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: applied ${delegateMeta.appliedCount} meta update(s)`,\n\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst childModelOverride = request.model?.trim() || childCustomSubagent?.model?.trim() || undefined;\n\t\t\t\t\t\t\t\t\tconst childSharedMemoryContext: SharedMemoryContext = {\n\t\t\t\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\t\t\t\t\trunId: sharedMemoryRunId,\n\t\t\t\t\t\t\t\t\t\ttaskId: sharedMemoryTaskId,\n\t\t\t\t\t\t\t\t\t\tdelegateId: String(index + 1),\n\t\t\t\t\t\t\t\t\t\tprofile: childProfile,\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tlet childOutput = \"\";\n\t\t\t\t\t\t\t\t\tlet childStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\t\tlet childEmptyAttempt = 0;\n\t\t\t\t\t\t\t\t\tlet childRetrospectiveAttempt = 0;\n\t\t\t\t\t\t\t\t\tlet childPromptForAttempt = delegatePrompt;\n\t\t\t\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tconst childResult = await runner({\n\t\t\t\t\t\t\t\t\t\t\t\tsystemPrompt: childSystemPrompt,\n\t\t\t\t\t\t\t\t\t\t\t\ttools: childTools,\n\t\t\t\t\t\t\t\t\t\t\t\tprompt: childPromptForAttempt,\n\t\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\tmodelOverride: childModelOverride,\n\t\t\t\t\t\t\t\t\t\t\t\tsharedMemoryContext: childSharedMemoryContext,\n\t\t\t\t\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\t\t\t\t\tonProgress: (progress) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: ${progress.message}`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcwd: progress.cwd ?? childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: progress.activeTool,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\t\t\t\tlet attemptOutput: string;\n\t\t\t\t\t\t\t\t\t\t\tlet attemptStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\t\t\t\tif (typeof childResult === \"string\") {\n\t\t\t\t\t\t\t\t\t\t\t\tattemptOutput = childResult;\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\tattemptOutput = childResult.output;\n\t\t\t\t\t\t\t\t\t\t\t\tattemptStats = childResult.stats;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tchildStats = mergeRunStats(childStats, attemptStats);\n\t\t\t\t\t\t\t\t\t\t\tif (attemptOutput.trim().length > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tchildOutput = attemptOutput;\n\t\t\t\t\t\t\t\t\t\t\t\tif (childRetrospectiveAttempt > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tretrospectiveRecovered += 1;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tif (childEmptyAttempt >= emptyOutputRetriesFromEnv) {\n\t\t\t\t\t\t\t\t\t\t\t\tconst totalAttempts = childEmptyAttempt + 1;\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} returned empty output after ${totalAttempts} attempt${totalAttempts === 1 ? \"\" : \"s\"}.`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tchildEmptyAttempt += 1;\n\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: empty output, retry ${childEmptyAttempt}/${emptyOutputRetriesFromEnv}`,\n\t\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\t\t\trecordFailureCause(cause);\n\t\t\t\t\t\t\t\t\t\t\tconst canRetryRetrospective =\n\t\t\t\t\t\t\t\t\t\t\t\tchildRetrospectiveAttempt < retrospectiveRetriesFromEnv &&\n\t\t\t\t\t\t\t\t\t\t\t\tisRetrospectiveRetryable(cause);\n\t\t\t\t\t\t\t\t\t\t\tif (!canRetryRetrospective) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow Object.assign(new Error(message), { failureCause: cause as FailureCause });\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tchildRetrospectiveAttempt += 1;\n\t\t\t\t\t\t\t\t\t\t\tretrospectiveAttempts += 1;\n\t\t\t\t\t\t\t\t\t\t\tconst directive = buildRetrospectiveDirective({\n\t\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t\t\terrorMessage: message,\n\t\t\t\t\t\t\t\t\t\t\t\tattempt: childRetrospectiveAttempt,\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: \"delegate\",\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\tchildPromptForAttempt = `${delegatePrompt}\\n\\n${directive}`;\n\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: retrospective retry ${childRetrospectiveAttempt}/${retrospectiveRetriesFromEnv} (${cause})`,\n\t\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst parsedChildDelegation = parseDelegationRequests(childOutput, 0);\n\t\t\t\t\t\t\t\tchildOutput = parsedChildDelegation.cleanedOutput;\n\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t...parsedChildDelegation.warnings.map((warning) => `Child ${index + 1}: ${warning}`),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdelegatedSucceeded += 1;\n\t\t\t\t\t\t\t\tif (delegateItems[index]) {\n\t\t\t\t\t\t\t\t\tdelegateItems[index].status = \"done\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdelegatedStats.toolCallsStarted += childStats?.toolCallsStarted ?? 0;\n\t\t\t\t\t\t\t\tdelegatedStats.toolCallsCompleted += childStats?.toolCallsCompleted ?? 0;\n\t\t\t\t\t\t\t\tdelegatedStats.assistantMessages += childStats?.assistantMessages ?? 0;\n\t\t\t\t\t\t\t\tconst normalizedChildOutput = childOutput.trim().length > 0 ? childOutput.trim() : \"(no output)\";\n\t\t\t\t\t\t\t\tconst childOutputExcerpt =\n\t\t\t\t\t\t\t\t\tnormalizedChildOutput.length > maxDelegatedOutputCharsFromEnv\n\t\t\t\t\t\t\t\t\t\t? `${normalizedChildOutput.slice(0, Math.max(1, maxDelegatedOutputCharsFromEnv - 3))}...`\n\t\t\t\t\t\t\t\t\t\t: normalizedChildOutput;\n\t\t\t\t\t\t\t\tdelegatedSections[index] =\n\t\t\t\t\t\t\t\t\t`#### ${index + 1}. ${request.description} (${childProfileLabel})\\n${childOutputExcerpt}`;\n\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal} done`,\n\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst classified =\n\t\t\t\t\t\t\t\t\t\terror && typeof error === \"object\" && \"failureCause\" in error\n\t\t\t\t\t\t\t\t\t\t\t? (error.failureCause as FailureCause)\n\t\t\t\t\t\t\t\t\t\t\t: classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\tif (!(error && typeof error === \"object\" && \"failureCause\" in error)) {\n\t\t\t\t\t\t\t\t\t\trecordFailureCause(classified);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} failed`,\n\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\tclassified,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\tchildReleaseIsolation?.();\n\t\t\t\t\t\t\t\tchildReleaseLock?.();\n\t\t\t\t\t\t\t\tcleanupWriteLock(explicitChildLock);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst resolveBlockedByFailedDependencies = (): boolean => {\n\t\t\t\t\t\t\tlet changed = false;\n\t\t\t\t\t\t\tfor (const index of Array.from(pendingIndices)) {\n\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[index] ?? [];\n\t\t\t\t\t\t\t\tif (deps.length === 0) continue;\n\t\t\t\t\t\t\t\tconst failedDep = deps.find((dep) => statusOf(dep - 1) === \"failed\");\n\t\t\t\t\t\t\t\tif (!failedDep) continue;\n\t\t\t\t\t\t\t\t\tpendingIndices.delete(index);\n\t\t\t\t\t\t\t\t\trecordFailureCause(\"logic_error\");\n\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} skipped: dependency ${failedDep} failed`,\n\t\t\t\t\t\t\t\t\t\t`Delegated task ${index + 1} skipped because dependency ${failedDep} failed.`,\n\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn changed;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst launchReadyDelegates = (): boolean => {\n\t\t\t\t\t\t\tlet launched = false;\n\t\t\t\t\t\t\twhile (runningDelegates.size < maxDelegateParallel) {\n\t\t\t\t\t\t\t\tlet nextIndex: number | undefined;\n\t\t\t\t\t\t\t\tfor (const index of pendingIndices) {\n\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[index] ?? [];\n\t\t\t\t\t\t\t\t\tconst allDone = deps.every((dep) => statusOf(dep - 1) === \"done\");\n\t\t\t\t\t\t\t\t\tif (allDone) {\n\t\t\t\t\t\t\t\t\t\tnextIndex = index;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (nextIndex === undefined) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpendingIndices.delete(nextIndex);\n\t\t\t\t\t\t\t\tconst promise = runDelegate(nextIndex).finally(() => {\n\t\t\t\t\t\t\t\t\trunningDelegates.delete(nextIndex);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\trunningDelegates.set(nextIndex, promise);\n\t\t\t\t\t\t\t\tlaunched = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn launched;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\twhile (pendingIndices.size > 0 || runningDelegates.size > 0) {\n\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\tconst changed = resolveBlockedByFailedDependencies();\n\t\t\t\t\t\t\tconst launched = launchReadyDelegates();\n\t\t\t\t\t\t\tif (runningDelegates.size === 0) {\n\t\t\t\t\t\t\t\tif (pendingIndices.size > 0 && !changed && !launched) {\n\t\t\t\t\t\t\t\t\t\tfor (const index of Array.from(pendingIndices)) {\n\t\t\t\t\t\t\t\t\t\t\tpendingIndices.delete(index);\n\t\t\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[index] ?? [];\n\t\t\t\t\t\t\t\t\t\t\trecordFailureCause(\"logic_error\");\n\t\t\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} blocked: unresolved depends_on`,\n\t\t\t\t\t\t\t\t\t\t\t\t`Delegated task ${index + 1} blocked by unresolved dependencies: ${deps.join(\", \") || \"unknown\"}.`,\n\t\t\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait Promise.race(Array.from(runningDelegates.values()));\n\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\trecordFailureCause(\"aborted\");\n\t\t\t\t\t\t\t\tconst hasFailureCauses = Object.keys(failureCauses).length > 0;\n\t\t\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\t\t\t\ttoolCallsStarted: runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted,\n\t\t\t\t\t\t\t\t\ttoolCallsCompleted: runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted,\n\t\t\t\t\t\t\t\t\tassistantMessages: runStats?.assistantMessages ?? latestProgress?.assistantMessages,\n\t\t\t\t\t\t\t\t\tdelegatedTasks: delegatedTasks > 0 ? delegatedTasks : undefined,\n\t\t\t\t\t\t\t\t\tdelegatedSucceeded: delegatedTasks > 0 ? delegatedSucceeded : undefined,\n\t\t\t\t\t\t\t\t\tdelegatedFailed: delegatedTasks > 0 ? delegatedFailed : undefined,\n\t\t\t\t\t\t\t\t\tretrospectiveAttempts: retrospectiveAttempts > 0 ? retrospectiveAttempts : undefined,\n\t\t\t\t\t\t\t\t\tretrospectiveRecovered: retrospectiveRecovered > 0 ? retrospectiveRecovered : undefined,\n\t\t\t\t\t\t\t\t\tfailureCauses: hasFailureCauses ? { ...failureCauses } : undefined,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tupdateTrackedTaskStatus(\"cancelled\");\n\t\t\t\t\t\t\t\tthrow Object.assign(new Error(\"Operation aborted\"), {\n\t\t\t\t\t\t\t\t\tdetails,\n\t\t\t\t\t\t\t\t\tfailureCause: \"aborted\" as FailureCause,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst classified =\n\t\t\t\t\t\t\t\terror && typeof error === \"object\" && \"failureCause\" in error\n\t\t\t\t\t\t\t\t\t? (error.failureCause as FailureCause)\n\t\t\t\t\t\t\t\t\t: classifyFailureCause(message);\n\t\t\t\t\t\t\tif (!(error && typeof error === \"object\" && \"failureCause\" in error)) {\n\t\t\t\t\t\t\t\trecordFailureCause(classified);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst hasFailureCauses = Object.keys(failureCauses).length > 0;\n\t\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\t\ttoolCallsStarted: runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted,\n\t\t\t\t\t\t\ttoolCallsCompleted: runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted,\n\t\t\t\t\t\t\t\tassistantMessages: runStats?.assistantMessages ?? latestProgress?.assistantMessages,\n\t\t\t\t\t\t\t\tdelegatedTasks: delegatedTasks > 0 ? delegatedTasks : undefined,\n\t\t\t\t\t\t\t\tdelegatedSucceeded: delegatedTasks > 0 ? delegatedSucceeded : undefined,\n\t\t\t\t\t\t\t\tdelegatedFailed: delegatedTasks > 0 ? delegatedFailed : undefined,\n\t\t\t\t\t\t\t\tretrospectiveAttempts: retrospectiveAttempts > 0 ? retrospectiveAttempts : undefined,\n\t\t\t\t\t\t\t\tretrospectiveRecovered: retrospectiveRecovered > 0 ? retrospectiveRecovered : undefined,\n\t\t\t\t\t\t\t\tfailureCauses: hasFailureCauses ? { ...failureCauses } : undefined,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\tupdateTrackedTaskStatus(\"error\");\n\t\t\t\t\t\tthrow Object.assign(new Error(`Subagent failed: ${message}`), { details });\n\t\t\t\t\t}\n\n\t\t\t\t\t\tconst normalizedOutput = output.trim().length > 0 ? output.trim() : \"(Subagent completed with no output)\";\n\t\t\t\t\t\tconst finalSections: string[] = [normalizedOutput];\n\t\t\t\t\t\tif (delegatedTasks > 0) {\n\t\t\t\t\t\t\tconst header = `### Delegated Subtasks (${delegatedSucceeded}/${delegatedTasks} done)`;\n\t\t\t\t\t\tconst delegatedBlocks = delegatedSections.filter(\n\t\t\t\t\t\t\t(section): section is string => typeof section === \"string\" && section.trim().length > 0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfinalSections.push([header, ...delegatedBlocks].join(\"\\n\\n\"));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (delegationWarnings.length > 0) {\n\t\t\t\t\t\t\tfinalSections.push(`### Delegation Notes\\n${delegationWarnings.map((w) => `- ${w}`).join(\"\\n\")}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst failureCauseSummary = formatFailureCauseCounts(failureCauses);\n\t\t\t\t\t\tif (retrospectiveAttempts > 0 || failureCauseSummary) {\n\t\t\t\t\t\t\tfinalSections.push(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"### Retrospective\",\n\t\t\t\t\t\t\t\t\t`- attempts: ${retrospectiveAttempts}`,\n\t\t\t\t\t\t\t\t\t`- recovered: ${retrospectiveRecovered}`,\n\t\t\t\t\t\t\t\t\t`- failure_causes: ${failureCauseSummary || \"none\"}`,\n\t\t\t\t\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst text = finalSections.join(\"\\n\\n\");\n\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\tphase: \"responding\",\n\t\t\t\t\t\t\tmessage: delegatedTasks > 0 ? \"aggregating delegated results\" : \"finalizing response\",\n\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\tdelegateIndex: undefined,\n\t\t\t\t\t\t\tdelegateTotal: undefined,\n\t\t\t\t\t\t\tdelegateDescription: undefined,\n\t\t\t\t\t\t\tdelegateProfile: undefined,\n\t\t\t\t\t\t\tdelegateItems: undefined,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst transcriptPath = persistSubagentTranscript({\n\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\tsubagentCwd,\n\t\t\t\t\t\tsessionId: subagentSessionId,\n\t\t\t\t\t\tprompt: promptWithInstructions,\n\t\t\t\t\t\toutput: text,\n\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst hasFailureCauses = Object.keys(failureCauses).length > 0;\n\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\toutputLength: text.length,\n\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\tsubagentSessionId,\n\t\t\t\t\t\ttranscriptPath,\n\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\ttoolCallsStarted:\n\t\t\t\t\t\t\ttypeof (runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted) === \"number\"\n\t\t\t\t\t\t\t\t? (runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted ?? 0) +\n\t\t\t\t\t\t\t\t\tdelegatedStats.toolCallsStarted\n\t\t\t\t\t\t\t\t: delegatedStats.toolCallsStarted > 0\n\t\t\t\t\t\t\t\t\t? delegatedStats.toolCallsStarted\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttoolCallsCompleted:\n\t\t\t\t\t\t\ttypeof (runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted) === \"number\"\n\t\t\t\t\t\t\t\t? (runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted ?? 0) +\n\t\t\t\t\t\t\t\t\tdelegatedStats.toolCallsCompleted\n\t\t\t\t\t\t\t\t: delegatedStats.toolCallsCompleted > 0\n\t\t\t\t\t\t\t\t\t? delegatedStats.toolCallsCompleted\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tassistantMessages:\n\t\t\t\t\t\t\ttypeof (runStats?.assistantMessages ?? latestProgress?.assistantMessages) === \"number\"\n\t\t\t\t\t\t\t\t? (runStats?.assistantMessages ?? latestProgress?.assistantMessages ?? 0) +\n\t\t\t\t\t\t\t\t\tdelegatedStats.assistantMessages\n\t\t\t\t\t\t\t\t: delegatedStats.assistantMessages > 0\n\t\t\t\t\t\t\t\t\t? delegatedStats.assistantMessages\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tdelegatedTasks: delegatedTasks > 0 ? delegatedTasks : undefined,\n\t\t\t\t\t\t\tdelegatedSucceeded: delegatedTasks > 0 ? delegatedSucceeded : undefined,\n\t\t\t\t\t\t\tdelegatedFailed: delegatedTasks > 0 ? delegatedFailed : undefined,\n\t\t\t\t\t\t\tretrospectiveAttempts: retrospectiveAttempts > 0 ? retrospectiveAttempts : undefined,\n\t\t\t\t\t\t\tretrospectiveRecovered: retrospectiveRecovered > 0 ? retrospectiveRecovered : undefined,\n\t\t\t\t\t\t\tfailureCauses: hasFailureCauses ? { ...failureCauses } : undefined,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tupdateTrackedTaskStatus(\"done\");\n\t\t\t\t\t\treturn { text, details };\n\t\t\t\t\t} finally {\n\t\t\t\t\treleaseIsolation?.();\n\t\t\t\t\treleaseWriteLock?.();\n\t\t\t\t\tcleanupWriteLock(explicitRootLockKey);\n\t\t\t\t\treleaseSlot?.();\n\t\t\t\t\treleaseRunSlot?.();\n\t\t\t\t\tif (orchestrationRunId) {\n\t\t\t\t\t\tcleanupOrchestrationSemaphore(cwd, orchestrationRunId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (runInBackground) {\n\t\t\t\tconst now = new Date().toISOString();\n\t\t\t\tconst queuedStatusPath = writeBackgroundRunStatus(cwd, {\n\t\t\t\t\trunId,\n\t\t\t\t\tstatus: \"queued\",\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tdescription,\n\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t});\n\t\t\t\tvoid (async () => {\n\t\t\t\t\twriteBackgroundRunStatus(cwd, {\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\tstartedAt: new Date().toISOString(),\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t});\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await executeSubagent();\n\t\t\t\t\t\twriteBackgroundRunStatus(cwd, {\n\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\tstatus: \"done\",\n\t\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\t\tfinishedAt: new Date().toISOString(),\n\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\tcwd: result.details.cwd,\n\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\ttranscriptPath: result.details.transcriptPath,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst aborted = isAbortError(error);\n\t\t\t\t\t\t\twriteBackgroundRunStatus(cwd, {\n\t\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\t\tstatus: aborted ? \"cancelled\" : \"error\",\n\t\t\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\t\t\tfinishedAt: new Date().toISOString(),\n\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `Started background subagent run ${runId}. Check .iosm/subagents/background and /subagent-runs for results.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\tbackground: true,\n\t\t\t\t\t\tbackgroundStatusPath: queuedStatusPath,\n\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\ttoolCallsStarted: latestProgress?.toolCallsStarted,\n\t\t\t\t\t\ttoolCallsCompleted: latestProgress?.toolCallsCompleted,\n\t\t\t\t\t\tassistantMessages: latestProgress?.assistantMessages,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst result = await executeSubagent();\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text: result.text }],\n\t\t\t\tdetails: result.details,\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/core/tools/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GAExB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,GACjC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,kBAAkB,GAElB,MAAM,sBAAsB,CAAC;AAyD9B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EACV,0GAA0G;KAC3G,CAAC,CACF;IACD,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EACV,oGAAoG;KACrG,CAAC,CACF;IACD,IAAI,EAAE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Sync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport { spawnSync } from \"node:child_process\";\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { getTeamRun, updateTeamTaskStatus } from \"../agent-teams.js\";\nimport {\n\tbuildRetrospectiveDirective,\n\tclassifyFailureCause,\n\tformatFailureCauseCounts,\n\tisRetrospectiveRetryable,\n\ttype FailureCause,\n} from \"../failure-retrospective.js\";\nimport {\n\tMAX_ORCHESTRATION_AGENTS,\n\tMAX_ORCHESTRATION_PARALLEL,\n\tMAX_SUBAGENT_DELEGATE_PARALLEL,\n\tMAX_SUBAGENT_DELEGATION_DEPTH,\n\tMAX_SUBAGENT_DELEGATIONS_PER_TASK,\n} from \"../orchestration-limits.js\";\nimport {\n\tAGENT_PROFILES,\n\tisReadOnlyProfileName,\n\tisValidProfileName,\n\ttype AgentProfileName,\n} from \"../agent-profiles.js\";\nimport type { SharedMemoryContext } from \"../shared-memory.js\";\nimport type { CustomSubagentDefinition } from \"../subagents.js\";\n\n/**\n * Callback type passed in from sdk.ts to avoid circular imports.\n * Spawns a sub-session and runs it to completion, returning the final text output.\n */\nexport type SubagentRunResult = {\n\toutput: string;\n\tsessionId?: string;\n\tstats?: {\n\t\ttoolCallsStarted: number;\n\t\ttoolCallsCompleted: number;\n\t\tassistantMessages: number;\n\t};\n};\n\nexport type TaskToolProgressPhase = \"queued\" | \"starting\" | \"running\" | \"responding\";\n\nexport type TaskDelegateProgressStatus = \"pending\" | \"running\" | \"done\" | \"failed\";\n\nexport interface TaskDelegateProgressItem {\n\tindex: number;\n\tdescription: string;\n\tprofile: string;\n\tstatus: TaskDelegateProgressStatus;\n}\n\nexport interface TaskToolProgress {\n\tkind: \"subagent_progress\";\n\tphase: TaskToolProgressPhase;\n\tmessage: string;\n\tcwd?: string;\n\tactiveTool?: string;\n\ttoolCallsStarted?: number;\n\ttoolCallsCompleted?: number;\n\tassistantMessages?: number;\n\tdelegateIndex?: number;\n\tdelegateTotal?: number;\n\tdelegateDescription?: string;\n\tdelegateProfile?: string;\n\tdelegateItems?: TaskDelegateProgressItem[];\n}\n\nexport type SubagentRunner = (options: {\n\tsystemPrompt: string;\n\tprofileName?: string;\n\ttools: string[];\n\tprompt: string;\n\tcwd: string;\n\tmodelOverride?: string;\n\tsharedMemoryContext?: SharedMemoryContext;\n\tsignal?: AbortSignal;\n\tonProgress?: (progress: TaskToolProgress) => void;\n}) => Promise<string | SubagentRunResult>;\n\nconst taskSchema = Type.Object({\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional short 3-5 word description of what the subagent will do. If omitted, it is derived from prompt.\",\n\t\t}),\n\t),\n\ttask: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Legacy alias for prompt. If provided, it is treated as the subagent prompt when prompt is omitted.\",\n\t\t}),\n\t),\n\targs: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Legacy alias for prompt used by some models. If provided, it is treated as the subagent prompt when prompt/task are omitted.\",\n\t\t}),\n\t),\n\tprompt: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional full task prompt for the subagent. If omitted, the description is used as the prompt.\",\n\t\t}),\n\t),\n\tagent: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Optional custom subagent name loaded from .iosm/agents or global agents directory.\",\n\t\t}),\n\t),\n\tprofile: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional subagent capability profile. Defaults to the current host profile when omitted (or full if host profile is unavailable). Recommended values: explore, plan, iosm, meta, iosm_analyst, iosm_verifier, cycle_planner, full. For custom agents, pass the agent name via `agent`, not `profile`.\",\n\t\t}),\n\t),\n\tcwd: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional working directory for this subagent. Relative paths are resolved from the current workspace.\",\n\t\t}),\n\t),\n\tlock_key: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional logical lock key for write serialization (e.g. src/api/**). Agents with the same lock key run write phases sequentially.\",\n\t\t}),\n\t),\n\trun_id: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional orchestration run id (from /orchestrate or /swarm). Use with task_id so the team board can track status. When omitted, task mode uses an internal run id for shared-memory collaboration within this task execution.\",\n\t\t}),\n\t),\n\ttask_id: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional orchestration task id (for example task_1). Use with run_id to update the team board. When omitted, task mode uses an internal task id so task-scoped shared memory still works.\",\n\t\t}),\n\t),\n\tmodel: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional model override for this subagent (for example anthropic/claude-sonnet-4 or model id).\",\n\t\t}),\n\t),\n\tbackground: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Run subagent in background and return immediately with run id. Use for detached async runs; orchestrated run_id/task_id calls execute foreground for deterministic coordination. Background mode is read-only policy by default.\",\n\t\t}),\n\t),\n\tisolation: Type.Optional(\n\t\tType.Union([Type.Literal(\"none\"), Type.Literal(\"worktree\")], {\n\t\t\tdescription:\n\t\t\t\t\"Optional isolation mode. Set to worktree to run this subagent in a temporary git worktree.\",\n\t\t}),\n\t),\n\tdelegate_parallel_hint: Type.Optional(\n\t\tType.Integer({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_SUBAGENT_DELEGATE_PARALLEL,\n\t\t\tdescription:\n\t\t\t\t\"Optional hint for intra-task delegation fan-out. Higher value allows more delegated subtasks to run in parallel inside a single task execution.\",\n\t\t}),\n\t),\n});\n\nexport type TaskToolInput = Static<typeof taskSchema>;\n\n/** Details attached to the tool result for UI display */\nexport interface TaskToolDetails {\n\tprofile: string;\n\tdescription: string;\n\toutputLength: number;\n\tcwd: string;\n\tagent?: string;\n\tlockKey?: string;\n\trunId?: string;\n\ttaskId?: string;\n\tmodel?: string;\n\tsubagentSessionId?: string;\n\ttranscriptPath?: string;\n\tisolation?: \"none\" | \"worktree\";\n\tworktreePath?: string;\n\twaitMs?: number;\n\tbackground?: boolean;\n\tbackgroundStatusPath?: string;\n\ttoolCallsStarted?: number;\n\ttoolCallsCompleted?: number;\n\tassistantMessages?: number;\n\tdelegatedTasks?: number;\n\tdelegatedSucceeded?: number;\n\tdelegatedFailed?: number;\n\tretrospectiveAttempts?: number;\n\tretrospectiveRecovered?: number;\n\tfailureCauses?: Partial<Record<FailureCause, number>>;\n}\n\nexport interface TaskToolOptions {\n\tresolveCustomSubagent?: (name: string) => CustomSubagentDefinition | undefined;\n\tavailableCustomSubagents?: string[];\n\tavailableCustomSubagentHints?: Array<{ name: string; description: string }>;\n\t/** Returns pending live meta updates entered during an active run. */\n\tgetMetaMessages?: () => readonly string[];\n\t/** Active profile of the host session that is invoking the task tool (static fallback). */\n\thostProfileName?: string;\n\t/** Returns active profile of the host session dynamically (preferred over static fallback when provided). */\n\tgetHostProfileName?: () => string | undefined;\n}\n\n/** Tool names available per profile (kept in sync with AGENT_PROFILES). */\nconst toolsByProfile: Record<AgentProfileName, string[]> = Object.values(AGENT_PROFILES).reduce(\n\t(acc, profile) => {\n\t\tacc[profile.name] = [...profile.tools];\n\t\treturn acc;\n\t},\n\t{} as Record<AgentProfileName, string[]>,\n);\n\n/** System prompt injected per profile */\nconst systemPromptByProfile: Record<string, string> = {\n\texplore:\n\t\t\"You are a fast read-only codebase explorer. Answer concisely. Never write or edit files.\",\n\tplan: \"You are a technical architect. Analyze the codebase and produce a clear implementation plan. Do not write or edit files.\",\n\tiosm: \"You are an IOSM execution agent. Use IOSM methodology and keep IOSM artifacts synchronized with implementation.\",\n\tmeta: \"You are a meta orchestration agent. Your main job is to maximize safe parallel execution through delegates, not to personally do most of the implementation. Start with bounded read-only recon, then form a concrete execution graph: subtasks, delegate subtasks, dependencies, lock domains, and verification steps. The parent agent remains responsible for orchestration and synthesis, so decompose work aggressively instead of collapsing complex work into one worker. For any non-trivial task, orchestration is required: after recon, launch multiple focused delegates instead of continuing manual implementation in the parent agent, avoid direct write/edit work in the parent agent before delegation unless the task is clearly trivial, and do not hand the whole task to one specialist child when independent workstreams exist. If a delegated workstream still contains multiple independent slices, split it again with nested <delegate_task> blocks. Default to aggressive safe parallelism. If the user requested a specific degree of parallelism, honor it when feasible or explain the exact blocker. Use shared_memory as the default coordination channel between delegates: use stable namespaced keys, prefer read-before-write, and use CAS (if_version) for contested updates; reserve append mode for timeline/log keys. When delegation is not used for non-trivial work, explain why in one line and include DELEGATION_IMPOSSIBLE. Enforce test verification for code changes, complete only after all delegated branches are resolved, and explicitly justify any no-code path where tests are skipped.\",\n\tiosm_analyst:\n\t\t\"You are an IOSM metrics analyst. Analyze .iosm/ artifacts and codebase metrics. Be precise and evidence-based.\",\n\tiosm_verifier:\n\t\t\"You are an IOSM verifier. Validate checks and update only required IOSM artifacts with deterministic reasoning.\",\n\tcycle_planner:\n\t\t\"You are an IOSM cycle planner. Propose and align cycle goals with measurable outcomes and concrete risks.\",\n\tfull: \"You are a software engineering agent. Execute the task end-to-end.\",\n};\n\nconst writeCapableTools = new Set([\"bash\", \"edit\", \"write\"]);\nconst backgroundUnsafeTools = new Set(writeCapableTools);\nconst writeCapableProfiles = new Set(\n\t(Object.keys(toolsByProfile) as AgentProfileName[]).filter((profileName) =>\n\t\ttoolsByProfile[profileName].some((tool) => writeCapableTools.has(tool)),\n\t),\n);\nconst backgroundSafeProfiles = (Object.keys(toolsByProfile) as AgentProfileName[]).filter((profileName) =>\n\ttoolsByProfile[profileName].every((tool) => !backgroundUnsafeTools.has(tool)),\n);\nconst delegationTagName = \"delegate_task\";\n\ntype DelegationRequest = {\n\tdescription: string;\n\tprofile: string;\n\tagent?: string;\n\tprompt: string;\n\tcwd?: string;\n\tlockKey?: string;\n\tmodel?: string;\n\tisolation?: \"none\" | \"worktree\";\n\tdependsOn?: number[];\n};\n\ntype ParsedDelegationRequests = {\n\tcleanedOutput: string;\n\trequests: DelegationRequest[];\n\twarnings: string[];\n};\n\nclass Semaphore {\n\tprivate active = 0;\n\tprivate readonly queue: Array<() => void> = [];\n\n\tconstructor(private readonly limit: number) {}\n\n\tasync acquire(): Promise<() => void> {\n\t\tif (this.active < this.limit) {\n\t\t\tthis.active += 1;\n\t\t\treturn () => this.release();\n\t\t}\n\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tthis.queue.push(() => {\n\t\t\t\tthis.active += 1;\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\n\t\treturn () => this.release();\n\t}\n\n\tprivate release(): void {\n\t\tthis.active = Math.max(0, this.active - 1);\n\t\tconst next = this.queue.shift();\n\t\tif (next) {\n\t\t\tnext();\n\t\t}\n\t}\n\n\tisIdle(): boolean {\n\t\treturn this.active === 0 && this.queue.length === 0;\n\t}\n}\n\nclass Mutex {\n\tprivate locked = false;\n\tprivate readonly waiters: Array<() => void> = [];\n\n\tasync acquire(): Promise<() => void> {\n\t\tif (!this.locked) {\n\t\t\tthis.locked = true;\n\t\t\treturn () => this.release();\n\t\t}\n\n\t\tawait new Promise<void>((resolve) => this.waiters.push(resolve));\n\t\tthis.locked = true;\n\t\treturn () => this.release();\n\t}\n\n\tprivate release(): void {\n\t\tthis.locked = false;\n\t\tconst next = this.waiters.shift();\n\t\tif (next) {\n\t\t\tnext();\n\t\t}\n\t}\n\n\tisIdle(): boolean {\n\t\treturn !this.locked && this.waiters.length === 0;\n\t}\n}\n\nconst maxParallelFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_SUBAGENT_MAX_PARALLEL,\n\tMAX_ORCHESTRATION_PARALLEL,\n\t1,\n\tMAX_ORCHESTRATION_PARALLEL,\n);\nconst subagentSemaphore = new Semaphore(maxParallelFromEnv);\nconst maxDelegationDepthFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_SUBAGENT_MAX_DELEGATION_DEPTH,\n\t2,\n\t0,\n\tMAX_SUBAGENT_DELEGATION_DEPTH,\n);\nconst maxDelegationsPerTaskFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_SUBAGENT_MAX_DELEGATIONS_PER_TASK,\n\tMAX_SUBAGENT_DELEGATIONS_PER_TASK,\n\t0,\n\tMAX_SUBAGENT_DELEGATIONS_PER_TASK,\n);\nconst maxDelegatedParallelFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_SUBAGENT_MAX_DELEGATE_PARALLEL,\n\tMAX_SUBAGENT_DELEGATE_PARALLEL,\n\t1,\n\tMAX_SUBAGENT_DELEGATE_PARALLEL,\n);\nconst emptyOutputRetriesFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_EMPTY_OUTPUT_RETRIES, 1, 0, 2);\nconst retrospectiveRetriesFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_RETRO_RETRIES, 1, 0, 1);\nconst orchestrationDependencyWaitTimeoutMsFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_ORCHESTRATION_DEPENDENCY_WAIT_TIMEOUT_MS,\n\t120_000,\n\t5_000,\n\t900_000,\n);\nconst orchestrationDependencyPollMsFromEnv = parseBoundedInt(\n\tprocess.env.IOSM_ORCHESTRATION_DEPENDENCY_POLL_MS,\n\t150,\n\t50,\n\t2_000,\n);\nconst maxDelegatedOutputCharsFromEnv = parseBoundedInt(process.env.IOSM_SUBAGENT_DELEGATED_OUTPUT_MAX_CHARS, 6000, 500, 20_000);\nconst maxMetaUpdatesPerCheckpoint = parseBoundedInt(process.env.IOSM_SUBAGENT_META_MAX_ITEMS, 5, 1, 20);\nconst maxMetaUpdateChars = parseBoundedInt(process.env.IOSM_SUBAGENT_META_MAX_CHARS, 600, 100, 4000);\nconst orchestrationSemaphores = new Map<string, Semaphore>();\nconst cwdWriteLocks = new Map<string, Mutex>();\n\nfunction parseBoundedInt(raw: string | undefined, fallback: number, min: number, max: number): number {\n\tconst parsed = raw ? Number.parseInt(raw, 10) : fallback;\n\tif (!Number.isInteger(parsed)) return fallback;\n\treturn Math.max(min, Math.min(max, parsed));\n}\n\nfunction shouldAutoDelegate(input: { profile?: string; agentName?: string; hostProfile?: string }): boolean {\n\tconst profile = input.profile?.trim().toLowerCase();\n\tif (profile === \"meta\") return true;\n\tconst hostProfile = input.hostProfile?.trim().toLowerCase();\n\tif (hostProfile === \"meta\") return true;\n\tconst agentName = input.agentName?.trim().toLowerCase();\n\treturn !!agentName && agentName.includes(\"orchestrator\");\n}\n\nfunction deriveAutoDelegateParallelHint(\n\tprofile: string | undefined,\n\tagentName: string | undefined,\n\thostProfile: string | undefined,\n\tdescription: string,\n\tprompt: string,\n): number | undefined {\n\tconst normalizedProfile = profile?.trim().toLowerCase();\n\tconst isMetaProfile = normalizedProfile === \"meta\";\n\tconst isMetaHost = hostProfile?.trim().toLowerCase() === \"meta\";\n\tif (!shouldAutoDelegate({ profile: normalizedProfile, agentName, hostProfile })) return undefined;\n\tconst text = `${description}\\n${prompt}`.trim();\n\tif (!text) return 1;\n\tconst normalized = text.replace(/\\s+/g, \" \").trim();\n\tconst words = normalized.length > 0 ? normalized.split(/\\s+/).length : 0;\n\tconst clauses = normalized\n\t\t.split(/[.;:,\\n]+/g)\n\t\t.map((item) => item.trim())\n\t\t.filter((item) => item.length > 0).length;\n\tconst pathLikeMatches = normalized.match(/\\b(?:[A-Za-z0-9_.-]+\\/)+[A-Za-z0-9_.-]+\\b/g) ?? [];\n\tconst fileLikeMatches = normalized.match(/\\b[A-Za-z0-9_.-]+\\.[A-Za-z0-9]{1,8}\\b/g) ?? [];\n\tconst listMarkers = text.match(/(?:^|\\n)\\s*(?:[-*]|\\d+[.)])\\s+/g)?.length ?? 0;\n\tconst hasCodeBlock = text.includes(\"```\");\n\tconst actionTokenMatches =\n\t\tnormalized.match(\n\t\t\t/\\b(?:audit|security|auth|rbac|sqli|sql|injection|fix|implement|refactor|migrat|harden|verify|test|scan|orchestrate|parallel|delegate|bug|vulnerab)\\w*/gi,\n\t\t) ?? [];\n\tconst strongActionSignal = new Set(actionTokenMatches.map((token) => token.toLowerCase())).size >= 2;\n\tconst metaOrchestratorContext = isMetaProfile || isMetaHost;\n\n\tlet score = 0;\n\tif (words >= 40) {\n\t\tscore += 2;\n\t} else if (words >= 20) {\n\t\tscore += 1;\n\t}\n\tif (clauses >= 5) {\n\t\tscore += 2;\n\t} else if (clauses >= 3) {\n\t\tscore += 1;\n\t}\n\tif (listMarkers >= 2) {\n\t\tscore += 1;\n\t}\n\tconst referenceCount = pathLikeMatches.length + fileLikeMatches.length;\n\tconst metaNonTrivialSignal =\n\t\twords >= 12 ||\n\t\tclauses >= 3 ||\n\t\tlistMarkers >= 1 ||\n\t\treferenceCount >= 1 ||\n\t\thasCodeBlock ||\n\t\t(strongActionSignal && words >= 4);\n\tif (referenceCount >= 3 || (referenceCount >= 1 && words >= 20)) {\n\t\tscore += 1;\n\t}\n\tif (hasCodeBlock) {\n\t\tscore += 1;\n\t}\n\tif (metaOrchestratorContext) {\n\t\t// In meta orchestration, require delegation pressure for non-trivial prompts\n\t\t// even when lexical scoring is still low.\n\t\tif (score === 0) {\n\t\t\tif (strongActionSignal && words >= 4) {\n\t\t\t\tscore = 1;\n\t\t\t} else if (metaNonTrivialSignal) {\n\t\t\t\tscore = 2;\n\t\t\t}\n\t\t} else if (score > 0) {\n\t\t\tscore += 1;\n\t\t}\n\t}\n\n\tif (score >= 6) return 10;\n\tif (score >= 5) return 8;\n\tif (score >= 4) return 6;\n\tif (score >= 3) return 4;\n\tif (score >= 2) return 3;\n\tif (score >= 1) return 2;\n\treturn 1;\n}\n\nfunction normalizeSpacing(text: string): string {\n\treturn text.replace(/[ \\t]+\\n/g, \"\\n\").replace(/\\n{3,}/g, \"\\n\\n\").trim();\n}\n\nfunction deriveTaskDescriptionFromPrompt(prompt: string): string {\n\tconst firstMeaningfulLine =\n\t\tprompt\n\t\t\t.split(\"\\n\")\n\t\t\t.map((line) => line.trim())\n\t\t\t.find((line) => line.length > 0) ?? \"Run subtask\";\n\tconst normalized = firstMeaningfulLine\n\t\t.replace(/^[-*]\\s+/, \"\")\n\t\t.replace(/^\\d+[.)]\\s+/, \"\")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\tif (normalized.length <= 80) {\n\t\treturn normalized;\n\t}\n\treturn `${normalized.slice(0, 77).trimEnd()}...`;\n}\n\nfunction normalizeTaskPayload(input: { description?: string; task?: string; args?: string; prompt?: string }): {\n\tdescription: string;\n\tprompt: string;\n} {\n\tconst rawDescription = input.description?.trim();\n\tconst rawTask = input.task?.trim();\n\tconst rawArgs = input.args?.trim();\n\tconst rawPrompt = input.prompt?.trim() || rawTask || rawArgs;\n\tif (rawDescription && rawPrompt) {\n\t\treturn { description: rawDescription, prompt: rawPrompt };\n\t}\n\tif (rawDescription) {\n\t\treturn { description: rawDescription, prompt: rawDescription };\n\t}\n\tif (rawPrompt) {\n\t\treturn {\n\t\t\tdescription: deriveTaskDescriptionFromPrompt(rawPrompt),\n\t\t\tprompt: rawPrompt,\n\t\t};\n\t}\n\tthrow new Error('Task tool requires at least one of \"description\", \"task\", \"args\", or \"prompt\".');\n}\n\nfunction cloneDelegateItems(items: TaskDelegateProgressItem[] | undefined): TaskDelegateProgressItem[] | undefined {\n\treturn items ? items.map((item) => ({ ...item })) : undefined;\n}\n\nfunction formatMetaCheckpoint(metaMessages: readonly string[] | undefined): {\n\tsection: string | undefined;\n\tappliedCount: number;\n} {\n\tif (!metaMessages || metaMessages.length === 0) {\n\t\treturn { section: undefined, appliedCount: 0 };\n\t}\n\tconst normalized = metaMessages\n\t\t.map((item) => item.replace(/\\s+/g, \" \").trim())\n\t\t.filter((item) => item.length > 0)\n\t\t.slice(-maxMetaUpdatesPerCheckpoint)\n\t\t.map((item) => (item.length > maxMetaUpdateChars ? `${item.slice(0, maxMetaUpdateChars - 3)}...` : item));\n\n\tif (normalized.length === 0) {\n\t\treturn { section: undefined, appliedCount: 0 };\n\t}\n\n\tconst lines = normalized.map((item, index) => `${index + 1}. ${item}`).join(\"\\n\");\n\treturn {\n\t\tsection: [\n\t\t\t\"[META_UPDATES]\",\n\t\t\t\"Live user updates captured during execution. Apply them in this subtask if relevant.\",\n\t\t\t\"If conflicts exist, prioritize later items.\",\n\t\t\tlines,\n\t\t\t\"[/META_UPDATES]\",\n\t\t].join(\"\\n\"),\n\t\tappliedCount: normalized.length,\n\t};\n}\n\nfunction isAbortError(error: unknown): boolean {\n\tif (error instanceof Error) {\n\t\treturn /aborted/i.test(error.message);\n\t}\n\tif (typeof error === \"string\") {\n\t\treturn /aborted/i.test(error);\n\t}\n\treturn false;\n}\n\nfunction mergeRunStats(\n\tbase: SubagentRunResult[\"stats\"] | undefined,\n\tnext: SubagentRunResult[\"stats\"] | undefined,\n): SubagentRunResult[\"stats\"] | undefined {\n\tif (!base && !next) return undefined;\n\treturn {\n\t\ttoolCallsStarted: (base?.toolCallsStarted ?? 0) + (next?.toolCallsStarted ?? 0),\n\t\ttoolCallsCompleted: (base?.toolCallsCompleted ?? 0) + (next?.toolCallsCompleted ?? 0),\n\t\tassistantMessages: (base?.assistantMessages ?? 0) + (next?.assistantMessages ?? 0),\n\t};\n}\n\nfunction buildDelegationProtocolPrompt(\n\tdepthRemaining: number,\n\tmaxDelegations: number,\n\tminDelegationsPreferred = 0,\n): string {\n\tif (depthRemaining <= 0) {\n\t\treturn [\n\t\t\t`Delegation protocol: depth limit reached.`,\n\t\t\t`Do not emit <${delegationTagName}> blocks.`,\n\t\t].join(\"\\n\");\n\t}\n\tif (minDelegationsPreferred > 0) {\n\t\tconst required = Math.min(Math.max(1, minDelegationsPreferred), maxDelegations);\n\t\treturn [\n\t\t\t`Delegation protocol (required for this run): emit at least ${required} XML block(s) when the assigned work still contains independent slices.`,\n\t\t\t`For broad audit, implementation, or verification tasks, split by subsystem, file family, or verification stream instead of producing one monolithic answer.`,\n\t\t\t`<${delegationTagName} profile=\"explore|plan|iosm|meta|iosm_analyst|iosm_verifier|cycle_planner|full\" agent=\"optional custom subagent name\" description=\"short title\" cwd=\"optional relative path\" lock_key=\"optional lock key\" model=\"optional model override\" isolation=\"none|worktree\" depends_on=\"optional indices like 1|3\">`,\n\t\t\t\"Detailed delegated task prompt\",\n\t\t\t`</${delegationTagName}>`,\n\t\t\t`Keep a brief coordinator note outside the blocks, but do not collapse the full workload into one monolithic answer.`,\n\t\t\t`If safe decomposition is truly impossible, output exactly one line: DELEGATION_IMPOSSIBLE: <precise reason>.`,\n\t\t\t`When shared_memory tools are available, exchange intermediate state through shared_memory_write/shared_memory_read instead of repeating large context.`,\n\t\t\t`Shared-memory protocol: use stable namespaced keys (findings/<stream>, plan/<stream>, risks/<stream>).`,\n\t\t\t`Use scope=run for cross-stream coordination, scope=task for local scratch state, read before overwrite, and use if_version for contested updates.`,\n\t\t\t`Reserve mode=append for timeline/log keys only; avoid append on canonical state keys.`,\n\t\t].join(\"\\n\");\n\t}\n\treturn [\n\t\t`Delegation protocol (optional): if you discover concrete independent follow-ups, emit up to ${maxDelegations} XML block(s):`,\n\t\t`<${delegationTagName} profile=\"explore|plan|iosm|meta|iosm_analyst|iosm_verifier|cycle_planner|full\" agent=\"optional custom subagent name\" description=\"short title\" cwd=\"optional relative path\" lock_key=\"optional lock key\" model=\"optional model override\" isolation=\"none|worktree\" depends_on=\"optional indices like 1|3\">`,\n\t\t\"Detailed delegated task prompt\",\n\t\t`</${delegationTagName}>`,\n\t\t`Only emit blocks when necessary. Keep normal analysis/answer text outside those blocks.`,\n\t\t`When shared_memory tools are available, exchange intermediate state through shared_memory_write/shared_memory_read instead of repeating large context.`,\n\t\t`Shared-memory protocol: prefer namespaced keys and read-before-write discipline; use CAS (if_version) on shared state updates.`,\n\t\t`Reserve mode=append for timeline/log keys only.`,\n\t].join(\"\\n\");\n}\n\nfunction truncateForDelegationContext(text: string, maxChars = 2200): string {\n\tconst normalized = normalizeSpacing(text);\n\tif (normalized.length <= maxChars) return normalized;\n\treturn `${normalized.slice(0, Math.max(100, maxChars - 3)).trimEnd()}...`;\n}\n\nfunction extractDelegationWorkstreams(text: string, maxItems: number): string[] {\n\tif (maxItems <= 0) return [];\n\tconst seen = new Set<string>();\n\tconst pushUnique = (raw: string): void => {\n\t\tconst cleaned = raw\n\t\t\t.replace(/^[-*]\\s+/, \"\")\n\t\t\t.replace(/^\\d+[.)]\\s+/, \"\")\n\t\t\t.replace(/\\s+/g, \" \")\n\t\t\t.trim();\n\t\tif (cleaned.length < 5) return;\n\t\tconst key = cleaned.toLowerCase();\n\t\tif (seen.has(key)) return;\n\t\tseen.add(key);\n\t};\n\n\tfor (const line of text.split(\"\\n\")) {\n\t\tif (!/^\\s*(?:[-*]|\\d+[.)])\\s+/.test(line)) continue;\n\t\tpushUnique(line);\n\t\tif (seen.size >= maxItems) break;\n\t}\n\n\tif (seen.size < maxItems) {\n\t\tconst fragments = text\n\t\t\t.split(/[\\n.;:]+/g)\n\t\t\t.map((fragment) => fragment.trim())\n\t\t\t.filter((fragment) => fragment.length >= 10)\n\t\t\t.slice(0, maxItems * 3);\n\t\tfor (const fragment of fragments) {\n\t\t\tpushUnique(fragment);\n\t\t\tif (seen.size >= maxItems) break;\n\t\t}\n\t}\n\n\treturn Array.from(seen).slice(0, maxItems);\n}\n\nfunction deriveAutoDelegateProfile(baseProfile: AgentProfileName, description: string, prompt: string): AgentProfileName {\n\tconst signal = `${description}\\n${prompt}`.toLowerCase();\n\tconst writeIntent = /\\b(?:implement|fix|patch|refactor|rewrite|edit|update|migrate|change|write|apply)\\b/.test(signal);\n\n\tif (baseProfile === \"full\") return writeIntent ? \"full\" : \"explore\";\n\tif (baseProfile === \"meta\") return writeIntent ? \"full\" : \"explore\";\n\tif (baseProfile === \"iosm\") return writeIntent ? \"full\" : \"explore\";\n\tif (baseProfile === \"iosm_verifier\") return \"iosm_verifier\";\n\tif (baseProfile === \"cycle_planner\") return \"cycle_planner\";\n\tif (baseProfile === \"plan\" || baseProfile === \"iosm_analyst\") return \"explore\";\n\treturn \"explore\";\n}\n\nfunction pickAutoDelegateAgent(workstream: string, availableCustomNames: readonly string[]): string | undefined {\n\tif (availableCustomNames.length === 0) return undefined;\n\tconst normalizedWorkstream = workstream.toLowerCase();\n\tconst names = availableCustomNames.map((name) => ({ raw: name, normalized: name.toLowerCase() }));\n\tconst findByHint = (hints: readonly string[]): string | undefined => {\n\t\tfor (const hint of hints) {\n\t\t\tconst exact = names.find((item) => item.normalized === hint);\n\t\t\tif (exact) return exact.raw;\n\t\t\tconst contains = names.find((item) => item.normalized.includes(hint));\n\t\t\tif (contains) return contains.raw;\n\t\t}\n\t\treturn undefined;\n\t};\n\n\tif (/\\b(?:test|qa|coverage|verification|regression)\\b/.test(normalizedWorkstream)) {\n\t\treturn findByHint([\"qa_test_engineer\", \"qa\", \"tester\", \"verification\"]);\n\t}\n\tif (/\\b(?:ui|ux|design|layout|accessibility)\\b/.test(normalizedWorkstream)) {\n\t\treturn findByHint([\"uiux_top_senior\", \"uiux\", \"ui\", \"ux\", \"design\"]);\n\t}\n\tif (/\\b(?:architecture|codebase|refactor|security|rbac|auth|database|api)\\b/.test(normalizedWorkstream)) {\n\t\treturn findByHint([\"codebase_auditor\", \"architect\", \"security\", \"backend\"]);\n\t}\n\n\treturn undefined;\n}\n\nfunction buildAutoDelegationPrompt(input: {\n\tstreamTitle: string;\n\trootDescription: string;\n\trootPrompt: string;\n\tordinal: number;\n\ttotal: number;\n}): string {\n\tconst objective = truncateForDelegationContext(`${input.rootDescription}\\n\\n${input.rootPrompt}`);\n\treturn normalizeSpacing([\n\t\t`Workstream ${input.ordinal}/${input.total}: ${input.streamTitle}`,\n\t\t\"Scope:\",\n\t\t`- Own this stream end-to-end and avoid duplicating sibling streams.`,\n\t\t`- Produce concrete findings/changes for this stream only.`,\n\t\t\"Coordinator objective:\",\n\t\tobjective,\n\t].join(\"\\n\"));\n}\n\nfunction synthesizeDelegationRequests(input: {\n\tdescription: string;\n\tprompt: string;\n\tbaseProfile: AgentProfileName;\n\tcurrentDelegates: number;\n\tminDelegationsPreferred: number;\n\tmaxDelegations: number;\n\tavailableCustomNames: readonly string[];\n}): DelegationRequest[] {\n\tconst desiredTotal = Math.max(0, Math.min(input.maxDelegations, input.minDelegationsPreferred));\n\tconst missing = Math.max(0, desiredTotal - input.currentDelegates);\n\tif (missing <= 0) return [];\n\n\tconst combined = `${input.description}\\n${input.prompt}`.trim();\n\tconst extracted = extractDelegationWorkstreams(combined, Math.max(missing, desiredTotal));\n\tconst fallbackByIndex = [\n\t\t\"Architecture and structure analysis\",\n\t\t\"Behavioral verification and tests\",\n\t\t\"Risk, regressions, and remediation\",\n\t\t\"Integration and dependency checks\",\n\t\t\"Delivery summary and rollout constraints\",\n\t];\n\tconst titles: string[] = [];\n\tfor (const stream of extracted) {\n\t\ttitles.push(stream);\n\t\tif (titles.length >= missing) break;\n\t}\n\tfor (let index = 0; titles.length < missing && index < fallbackByIndex.length; index += 1) {\n\t\ttitles.push(fallbackByIndex[index]!);\n\t}\n\twhile (titles.length < missing) {\n\t\ttitles.push(`Independent workstream ${titles.length + 1}`);\n\t}\n\n\tconst defaultProfile = deriveAutoDelegateProfile(input.baseProfile, input.description, input.prompt);\n\tconst synthesizedLockKey = writeCapableProfiles.has(defaultProfile) ? \"auto-synth-write-lock\" : undefined;\n\treturn titles.map((streamTitle, index) => ({\n\t\tdescription: `Auto: ${streamTitle}`,\n\t\tprofile: defaultProfile,\n\t\tagent: pickAutoDelegateAgent(streamTitle, input.availableCustomNames),\n\t\tprompt: buildAutoDelegationPrompt({\n\t\t\tstreamTitle,\n\t\t\trootDescription: input.description,\n\t\t\trootPrompt: input.prompt,\n\t\t\tordinal: input.currentDelegates + index + 1,\n\t\t\ttotal: input.currentDelegates + titles.length,\n\t\t}),\n\t\tcwd: undefined,\n\t\tlockKey: synthesizedLockKey,\n\t\tmodel: undefined,\n\t\tisolation: undefined,\n\t\tdependsOn: undefined,\n\t}));\n}\n\nfunction withDelegationPrompt(\n\tbasePrompt: string,\n\tdepthRemaining: number,\n\tmaxDelegations: number,\n\tminDelegationsPreferred = 0,\n): string {\n\tconst protocol = buildDelegationProtocolPrompt(depthRemaining, maxDelegations, minDelegationsPreferred);\n\treturn `${basePrompt}\\n\\n${protocol}`;\n}\n\nfunction withSubagentInstructions(basePrompt: string, instructions?: string): string {\n\tconst trimmed = instructions?.trim();\n\treturn trimmed ? `${basePrompt}\\n\\n${trimmed}` : basePrompt;\n}\n\nfunction buildSharedMemoryGuidance(runId: string, taskId: string | undefined): string {\n\treturn [\n\t\t\"[SHARED_MEMORY]\",\n\t\t`run_id: ${runId}`,\n\t\t`task_id: ${taskId ?? \"(none)\"}`,\n\t\t\"Use shared_memory_write/shared_memory_read to exchange intermediate state across parallel agents and delegates.\",\n\t\t\"Guidelines:\",\n\t\t\"- Use scope=run for cross-agent data and scope=task for task-local notes.\",\n\t\t\"- Keep entries compact and key-based (for example: findings/auth, plan/step-1, risks/session).\",\n\t\t\"- Prefer one canonical key per stream and deduplicate updates; avoid redundant writes in loops.\",\n\t\t\"- Read before overwrite when collaborating on the same key.\",\n\t\t\"- Use if_version CAS for contested updates on shared keys.\",\n\t\t\"- Use mode=append only for log/timeline keys; use mode=set for canonical state.\",\n\t\t\"[/SHARED_MEMORY]\",\n\t].join(\"\\n\");\n}\n\nfunction parseDelegationRequests(output: string, maxRequests: number): ParsedDelegationRequests {\n\tconst requests: DelegationRequest[] = [];\n\tconst warnings: string[] = [];\n\tconst pattern = new RegExp(`<${delegationTagName}\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/${delegationTagName}>`, \"gi\");\n\n\tconst cleaned = output.replace(pattern, (_full, attrsRaw: string, bodyRaw: string) => {\n\t\tif (maxRequests <= 0) {\n\t\t\twarnings.push(`Ignored delegation block: max delegated tasks per run is 0.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tif (requests.length >= maxRequests) {\n\t\t\twarnings.push(`Ignored extra delegation block: max ${maxRequests} per run.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tconst attrs: Record<string, string> = {};\n\t\tfor (const match of attrsRaw.matchAll(/([A-Za-z_][A-Za-z0-9_-]*)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/g)) {\n\t\t\tattrs[match[1].toLowerCase()] = (match[2] ?? match[3] ?? \"\").trim();\n\t\t}\n\n\t\tconst prompt = normalizeSpacing(bodyRaw ?? \"\");\n\t\tif (!prompt) {\n\t\t\twarnings.push(`Ignored delegation block with empty prompt.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tconst profileRaw = (attrs.profile ?? \"explore\").trim();\n\t\tif (!profileRaw) {\n\t\t\twarnings.push(`Ignored delegation block with empty profile.`);\n\t\t\treturn \"\";\n\t\t}\n\t\tconst normalizedProfile = profileRaw.toLowerCase();\n\t\tconst profile = isValidProfileName(normalizedProfile) ? normalizedProfile : profileRaw;\n\t\tconst isolationRaw = (attrs.isolation ?? \"\").trim().toLowerCase();\n\t\tconst isolation =\n\t\t\tisolationRaw === \"worktree\" ? \"worktree\" : isolationRaw === \"none\" ? \"none\" : undefined;\n\t\tif (isolationRaw && !isolation) {\n\t\t\twarnings.push(`Ignored invalid isolation value \"${attrs.isolation}\".`);\n\t\t\treturn \"\";\n\t\t}\n\n\t\trequests.push({\n\t\t\tdescription: (attrs.description ?? `delegated task ${requests.length + 1}`).trim(),\n\t\t\tprofile,\n\t\t\tagent: attrs.agent?.trim() || undefined,\n\t\t\tprompt,\n\t\t\tcwd: attrs.cwd?.trim() || undefined,\n\t\t\tlockKey: attrs.lock_key?.trim() || undefined,\n\t\t\tmodel: attrs.model?.trim() || undefined,\n\t\t\tisolation,\n\t\t\tdependsOn: attrs.depends_on\n\t\t\t\t? attrs.depends_on\n\t\t\t\t\t\t.split(/[|,]/)\n\t\t\t\t\t\t.map((token) => Number.parseInt(token.trim(), 10))\n\t\t\t\t\t\t.filter((value) => Number.isInteger(value) && value > 0)\n\t\t\t\t: undefined,\n\t\t});\n\t\treturn \"\";\n\t});\n\n\treturn {\n\t\trequests,\n\t\twarnings,\n\t\tcleanedOutput: normalizeSpacing(cleaned),\n\t};\n}\n\nfunction isBackgroundSafeToolset(tools: readonly string[]): boolean {\n\treturn tools.every((toolName) => !backgroundUnsafeTools.has(toolName));\n}\n\nfunction getCwdLockKey(cwd: string): string {\n\t// Normalize lock key to keep behavior consistent across path aliases.\n\treturn path.resolve(cwd).toLowerCase();\n}\n\nfunction getOrCreateWriteLock(cwd: string): Mutex {\n\tconst key = getCwdLockKey(cwd);\n\tconst existing = cwdWriteLocks.get(key);\n\tif (existing) return existing;\n\tconst created = new Mutex();\n\tcwdWriteLocks.set(key, created);\n\treturn created;\n}\n\nfunction cleanupWriteLock(lockKey: string | undefined): void {\n\tif (!lockKey) return;\n\tconst key = getCwdLockKey(lockKey);\n\tconst existing = cwdWriteLocks.get(key);\n\tif (!existing || !existing.isIdle()) return;\n\tcwdWriteLocks.delete(key);\n}\n\nfunction getRunParallelLimit(cwd: string, runId: string): number | undefined {\n\tconst teamRun = getTeamRun(cwd, runId);\n\tif (!teamRun) return undefined;\n\tif (teamRun.mode === \"sequential\") return 1;\n\tconst maxParallel = teamRun.maxParallel;\n\tif (!Number.isInteger(maxParallel) || !maxParallel || maxParallel < 1) {\n\t\treturn Math.max(1, Math.min(teamRun.agents, MAX_ORCHESTRATION_AGENTS));\n\t}\n\treturn Math.max(1, Math.min(maxParallel, MAX_ORCHESTRATION_PARALLEL));\n}\n\nfunction getOrCreateOrchestrationSemaphore(cwd: string, runId: string): Semaphore | undefined {\n\tconst limit = getRunParallelLimit(cwd, runId);\n\tif (!limit || limit < 1) return undefined;\n\tconst key = `${path.resolve(cwd).toLowerCase()}::${runId}::${limit}`;\n\tconst existing = orchestrationSemaphores.get(key);\n\tif (existing) return existing;\n\tconst created = new Semaphore(limit);\n\torchestrationSemaphores.set(key, created);\n\treturn created;\n}\n\nfunction isTeamTaskTerminal(status: string | undefined): boolean {\n\treturn status === \"done\" || status === \"error\" || status === \"cancelled\";\n}\n\nfunction cleanupOrchestrationSemaphore(cwd: string, runId: string): void {\n\tconst prefix = `${path.resolve(cwd).toLowerCase()}::${runId}::`;\n\tconst run = getTeamRun(cwd, runId);\n\tconst canDeleteForRun = !run || run.tasks.every((task) => isTeamTaskTerminal(task.status));\n\tif (!canDeleteForRun) return;\n\tfor (const [key, semaphore] of orchestrationSemaphores.entries()) {\n\t\tif (!key.startsWith(prefix)) continue;\n\t\tif (!semaphore.isIdle()) continue;\n\t\torchestrationSemaphores.delete(key);\n\t}\n}\n\nfunction waitForWithAbort(ms: number, signal?: AbortSignal): Promise<void> {\n\tif (!signal) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\tif (signal.aborted) {\n\t\treturn Promise.reject(new Error(\"Operation aborted\"));\n\t}\n\treturn new Promise((resolve, reject) => {\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tconst onAbort = (): void => {\n\t\t\tclearTimeout(timer);\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\treject(new Error(\"Operation aborted\"));\n\t\t};\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nasync function waitForOrchestrationDependencies(input: {\n\tcwd: string;\n\trunId: string;\n\ttaskId: string;\n\tsignal?: AbortSignal;\n\tonWaiting?: (message: string) => void;\n}): Promise<void> {\n\tconst started = Date.now();\n\tlet lastWaiting = \"\";\n\twhile (true) {\n\t\tif (input.signal?.aborted) {\n\t\t\tthrow new Error(\"Operation aborted\");\n\t\t}\n\t\tconst run = getTeamRun(input.cwd, input.runId);\n\t\tif (!run) {\n\t\t\treturn;\n\t\t}\n\t\tconst current = run.tasks.find((task) => task.id === input.taskId);\n\t\tif (!current) {\n\t\t\tthrow new Error(`Orchestration metadata missing task ${input.taskId} in run ${input.runId}.`);\n\t\t}\n\t\tconst dependencies = current.dependsOn ?? [];\n\t\tif (dependencies.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tconst dependencyTasks = dependencies.map((id) => run.tasks.find((task) => task.id === id));\n\t\tconst missing = dependencyTasks\n\t\t\t.map((task, index) => (task ? undefined : dependencies[index]))\n\t\t\t.filter((value): value is string => typeof value === \"string\");\n\t\tif (missing.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Orchestration metadata invalid for ${input.taskId}: missing dependency task(s) ${missing.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tconst failed = dependencyTasks.filter(\n\t\t\t(task): task is NonNullable<typeof task> => !!task && (task.status === \"error\" || task.status === \"cancelled\"),\n\t\t);\n\t\tif (failed.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Blocked by failed dependency: ${failed.map((task) => `${task.id}=${task.status}`).join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tconst pending = dependencyTasks.filter(\n\t\t\t(task): task is NonNullable<typeof task> => !!task && task.status !== \"done\",\n\t\t);\n\t\tif (pending.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tconst waitedMs = Date.now() - started;\n\t\tif (waitedMs >= orchestrationDependencyWaitTimeoutMsFromEnv) {\n\t\t\tthrow new Error(\n\t\t\t\t`Timed out waiting for dependencies of ${input.taskId}: ${pending\n\t\t\t\t\t.map((task) => `${task.id}=${task.status}`)\n\t\t\t\t\t.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t\tconst waiting = pending.map((task) => `${task.id}=${task.status}`).join(\", \");\n\t\tif (waiting !== lastWaiting) {\n\t\t\tlastWaiting = waiting;\n\t\t\tinput.onWaiting?.(waiting);\n\t\t}\n\t\tawait waitForWithAbort(orchestrationDependencyPollMsFromEnv, input.signal);\n\t}\n}\n\nfunction persistSubagentTranscript(input: {\n\trootCwd: string;\n\trunId: string;\n\tdescription: string;\n\tprofile: string;\n\tagent?: string;\n\tlockKey?: string;\n\tmodel?: string;\n\tsubagentCwd: string;\n\tsessionId?: string;\n\tprompt: string;\n\toutput: string;\n\tisolation?: \"none\" | \"worktree\";\n\tworktreePath?: string;\n}): string | undefined {\n\ttry {\n\t\tconst dir = path.join(input.rootCwd, \".iosm\", \"subagents\", \"runs\");\n\t\tmkdirSync(dir, { recursive: true });\n\t\tconst filePath = path.join(dir, `${input.runId}.md`);\n\t\tconst lines = [\n\t\t\t\"---\",\n\t\t\t`run_id: ${input.runId}`,\n\t\t\t`profile: ${input.profile}`,\n\t\t\t`description: ${JSON.stringify(input.description)}`,\n\t\t\t`cwd: ${JSON.stringify(input.subagentCwd)}`,\n\t\t\t`agent: ${JSON.stringify(input.agent ?? \"\")}`,\n\t\t\t`lock_key: ${JSON.stringify(input.lockKey ?? \"\")}`,\n\t\t\t`model: ${JSON.stringify(input.model ?? \"\")}`,\n\t\t\t`session_id: ${JSON.stringify(input.sessionId ?? \"\")}`,\n\t\t\t`isolation: ${JSON.stringify(input.isolation ?? \"none\")}`,\n\t\t\t`worktree_path: ${JSON.stringify(input.worktreePath ?? \"\")}`,\n\t\t\t`created_at: ${new Date().toISOString()}`,\n\t\t\t\"---\",\n\t\t\t\"\",\n\t\t\t\"## Prompt\",\n\t\t\t\"\",\n\t\t\tinput.prompt,\n\t\t\t\"\",\n\t\t\t\"## Output\",\n\t\t\t\"\",\n\t\t\tinput.output,\n\t\t\t\"\",\n\t\t];\n\t\twriteFileSync(filePath, lines.join(\"\\n\"), \"utf8\");\n\t\treturn filePath;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ntype BackgroundRunStatus = {\n\trunId: string;\n\tstatus: \"queued\" | \"running\" | \"done\" | \"error\" | \"cancelled\";\n\tcreatedAt: string;\n\tstartedAt?: string;\n\tfinishedAt?: string;\n\tdescription: string;\n\tprofile: string;\n\tcwd: string;\n\tagent?: string;\n\tmodel?: string;\n\terror?: string;\n\ttranscriptPath?: string;\n};\n\nfunction writeBackgroundRunStatus(rootCwd: string, status: BackgroundRunStatus): string | undefined {\n\ttry {\n\t\tconst dir = path.join(rootCwd, \".iosm\", \"subagents\", \"background\");\n\t\tmkdirSync(dir, { recursive: true });\n\t\tconst filePath = path.join(dir, `${status.runId}.json`);\n\t\twriteFileSync(filePath, `${JSON.stringify(status, null, 2)}\\n`, \"utf8\");\n\t\treturn filePath;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction gitResult(args: string[], cwd: string): { ok: boolean; stdout: string } {\n\tconst result = spawnSync(\"git\", args, {\n\t\tcwd,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\treturn {\n\t\tok: result.status === 0,\n\t\tstdout: (result.stdout ?? \"\").trim(),\n\t};\n}\n\nfunction provisionWorktree(\n\trootCwd: string,\n\ttargetCwd: string,\n\trunId: string,\n): { runCwd: string; worktreePath?: string; cleanup: () => void } {\n\tconst insideRepo = gitResult([\"rev-parse\", \"--is-inside-work-tree\"], rootCwd);\n\tif (!insideRepo.ok || insideRepo.stdout !== \"true\") {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\tconst repoRootResult = gitResult([\"rev-parse\", \"--show-toplevel\"], rootCwd);\n\tif (!repoRootResult.ok || !repoRootResult.stdout) {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\n\tconst repoRoot = repoRootResult.stdout;\n\tconst relative = path.relative(repoRoot, targetCwd);\n\tif (relative.startsWith(\"..\")) {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\n\tconst worktreePath = path.join(rootCwd, \".iosm\", \"subagents\", \"worktrees\", runId);\n\tmkdirSync(path.dirname(worktreePath), { recursive: true });\n\tconst added = gitResult([\"worktree\", \"add\", \"--detach\", worktreePath], repoRoot);\n\tif (!added.ok) {\n\t\treturn { runCwd: targetCwd, cleanup: () => {} };\n\t}\n\n\tconst runCwd = path.resolve(worktreePath, relative);\n\tconst cleanup = (): void => {\n\t\ttry {\n\t\t\tgitResult([\"worktree\", \"remove\", \"--force\", worktreePath], repoRoot);\n\t\t} catch {\n\t\t\t// best effort\n\t\t}\n\t\ttry {\n\t\t\trmSync(worktreePath, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// best effort\n\t\t}\n\t};\n\n\treturn { runCwd, worktreePath, cleanup };\n}\n\n/**\n * Create the Task tool using the factory pattern.\n *\n * The `runner` callback is supplied by sdk.ts to avoid a circular import:\n * sdk.ts → task.ts (tool) would otherwise import sdk.ts again.\n *\n * @param cwd Working directory forwarded to the subagent.\n * @param runner Callback that creates and runs a sub-session.\n */\nexport function createTaskTool(\n\tcwd: string,\n\trunner: SubagentRunner,\n\toptions?: TaskToolOptions,\n): AgentTool<typeof taskSchema> {\n\tconst customAgentsSnippet =\n\t\toptions?.availableCustomSubagentHints && options.availableCustomSubagentHints.length > 0\n\t\t\t? ` Available custom agents: ${options.availableCustomSubagentHints\n\t\t\t\t\t.map((item) => `${item.name} (${item.description})`)\n\t\t\t\t\t.join(\", \")}.`\n\t\t\t: options?.availableCustomSubagents && options.availableCustomSubagents.length > 0\n\t\t\t\t? ` Available custom agents: ${options.availableCustomSubagents.join(\", \")}.`\n\t\t\t: \"\";\n\treturn {\n\t\tname: \"task\",\n\t\tlabel: \"task\",\n\t\tdescription:\n\t\t\t\"Launch a specialized subagent to handle a subtask in isolation. \" +\n\t\t\t\"Use for: codebase exploration (profile=explore), architectural planning (profile=plan), \" +\n\t\t\t\"IOSM artifact analysis (profile=iosm_analyst/iosm_verifier/cycle_planner), orchestration-first execution (profile=meta), or end-to-end implementation (profile=full). \" +\n\t\t\t\"Set cwd to isolate subagents into different project areas when orchestrating parallel work. \" +\n\t\t\t\"The subagent runs to completion and returns its full text output. \" +\n\t\t\t\"It may request bounded follow-up delegation via <delegate_task> blocks that are executed by the parent task tool.\" +\n\t\t\tcustomAgentsSnippet,\n\t\tparameters: taskSchema,\n\t\texecute: async (\n\t\t\t_toolCallId: string,\n\t\t\t{\n\t\t\t\tdescription: rawDescription,\n\t\t\t\ttask: rawTask,\n\t\t\t\targs: rawArgs,\n\t\t\t\tprompt: rawPrompt,\n\t\t\t\tagent: agentName,\n\t\t\t\tprofile,\n\t\t\t\tcwd: targetCwd,\n\t\t\t\tlock_key: lockKey,\n\t\t\t\trun_id: orchestrationRunId,\n\t\t\t\ttask_id: orchestrationTaskId,\n\t\t\t\tmodel: requestedModel,\n\t\t\t\tbackground,\n\t\t\t\tisolation,\n\t\t\t\tdelegate_parallel_hint: delegateParallelHint,\n\t\t\t}: TaskToolInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\tonUpdate?,\n\t\t) => {\n\t\t\tconst updateTrackedTaskStatus = (status: \"running\" | \"done\" | \"error\" | \"cancelled\"): void => {\n\t\t\t\tif (!orchestrationRunId || !orchestrationTaskId) return;\n\t\t\t\tupdateTeamTaskStatus({\n\t\t\t\t\tcwd,\n\t\t\t\t\trunId: orchestrationRunId,\n\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\tstatus,\n\t\t\t\t});\n\t\t\t};\n\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\tif (_signal?.aborted) {\n\t\t\t\t\tupdateTrackedTaskStatus(\"cancelled\");\n\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst { description, prompt } = normalizeTaskPayload({\n\t\t\t\tdescription: rawDescription,\n\t\t\t\ttask: rawTask,\n\t\t\t\targs: rawArgs,\n\t\t\t\tprompt: rawPrompt,\n\t\t\t});\n\n\t\t\t\tconst runId = `subagent_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;\n\t\t\t\tconst sharedMemoryRunId = orchestrationRunId?.trim() || runId;\n\t\t\t\tconst sharedMemoryTaskId = orchestrationTaskId?.trim() || runId;\n\t\t\t\tconst availableCustomNames = options?.availableCustomSubagents ?? [];\n\t\t\t\tconst resolveCustom = (name: string | undefined): CustomSubagentDefinition | undefined => {\n\t\t\t\t\tif (!name || !options?.resolveCustomSubagent) return undefined;\n\t\t\t\t\tconst trimmed = name.trim();\n\t\t\t\t\tif (!trimmed) return undefined;\n\t\t\t\t\tconst resolved = options.resolveCustomSubagent(trimmed);\n\t\t\t\t\tif (resolved) return resolved;\n\t\t\t\t\tconst lowered = trimmed.toLowerCase();\n\t\t\t\t\tif (lowered !== trimmed) {\n\t\t\t\t\t\treturn options.resolveCustomSubagent(lowered);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t};\n\n\t\t\t\t\tlet normalizedAgentName = agentName?.trim() || undefined;\n\t\t\t\t\tlet customSubagent = resolveCustom(normalizedAgentName);\n\t\t\t\t\tconst requestedProfileRaw = profile?.trim() || undefined;\n\t\t\t\t\tconst normalizedHostProfile =\n\t\t\t\t\t\toptions?.getHostProfileName?.()?.trim().toLowerCase() ?? options?.hostProfileName?.trim().toLowerCase();\n\t\t\t\t\tconst hostProfileFallback =\n\t\t\t\t\t\tnormalizedHostProfile && isValidProfileName(normalizedHostProfile) ? normalizedHostProfile : \"full\";\n\t\t\t\t\tlet normalizedProfile =\n\t\t\t\t\t\trequestedProfileRaw?.toLowerCase() ||\n\t\t\t\t\t\tcustomSubagent?.profile?.trim().toLowerCase() ||\n\t\t\t\t\t\thostProfileFallback;\n\n\t\t\t\tif (normalizedAgentName && !customSubagent) {\n\t\t\t\t\tconst available =\n\t\t\t\t\t\tavailableCustomNames.length > 0 ? ` Available custom agents: ${availableCustomNames.join(\", \")}.` : \"\";\n\t\t\t\t\tthrow new Error(`Unknown subagent: ${normalizedAgentName}.${available}`);\n\t\t\t\t}\n\n\t\t\t\t\t// Recovery path: if model placed a custom agent name into `profile`, remap automatically.\n\t\t\t\t\tif (!customSubagent) {\n\t\t\t\t\t\tconst profileAsAgent = resolveCustom(normalizedProfile);\n\t\t\t\t\t\tif (profileAsAgent) {\n\t\t\t\t\t\tcustomSubagent = profileAsAgent;\n\t\t\t\t\t\tnormalizedAgentName = profileAsAgent.name;\n\t\t\t\t\t\t\tnormalizedProfile = (profileAsAgent.profile ?? \"full\").trim().toLowerCase();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!customSubagent && !isValidProfileName(normalizedProfile)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Unknown profile \"${requestedProfileRaw ?? normalizedProfile}\". Valid profiles: ${Object.keys(\n\t\t\t\t\t\t\t\ttoolsByProfile,\n\t\t\t\t\t\t\t).join(\", \")}.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\tconst effectiveProfileCandidate = (customSubagent?.profile ?? normalizedProfile).trim().toLowerCase();\n\t\t\t\tif (!isValidProfileName(effectiveProfileCandidate)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Invalid resolved profile \"${effectiveProfileCandidate}\". Valid profiles: ${Object.keys(\n\t\t\t\t\t\t\ttoolsByProfile,\n\t\t\t\t\t\t).join(\", \")}.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t\tconst effectiveProfile = effectiveProfileCandidate as AgentProfileName;\n\t\t\t\tlet tools = customSubagent?.tools\n\t\t\t\t\t? [...customSubagent.tools]\n\t\t\t\t\t: [...toolsByProfile[effectiveProfile]];\n\t\t\t\tif (customSubagent?.disallowedTools?.length) {\n\t\t\t\t\tconst blocked = new Set(customSubagent.disallowedTools);\n\t\t\t\t\ttools = tools.filter((tool) => !blocked.has(tool));\n\t\t\t\t}\n\t\t\t\t\tif (isReadOnlyProfileName(normalizedHostProfile) && tools.some((tool) => writeCapableTools.has(tool))) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Host profile \"${normalizedHostProfile}\" is read-only. Switch to full/meta/iosm to launch write-capable subtasks.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\tconst delegationDepth = maxDelegationDepthFromEnv;\n\t\t\t\t\tconst requestedDelegateParallelHint =\n\t\t\t\t\t\ttypeof delegateParallelHint === \"number\" && Number.isInteger(delegateParallelHint)\n\t\t\t\t\t\t\t? Math.max(1, Math.min(MAX_SUBAGENT_DELEGATE_PARALLEL, delegateParallelHint))\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\tconst autoDelegateParallelHint =\n\t\t\t\t\trequestedDelegateParallelHint === undefined\n\t\t\t\t\t\t? deriveAutoDelegateParallelHint(\n\t\t\t\t\t\t\t\teffectiveProfile,\n\t\t\t\t\t\t\t\tnormalizedAgentName,\n\t\t\t\t\t\t\t\tnormalizedHostProfile,\n\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tlet effectiveDelegateParallelHint = requestedDelegateParallelHint ?? autoDelegateParallelHint;\n\t\t\t\tconst effectiveDelegationDepth =\n\t\t\t\t\teffectiveProfile === \"meta\" || normalizedHostProfile === \"meta\" || normalizedAgentName?.toLowerCase().includes(\"orchestrator\")\n\t\t\t\t\t\t? Math.max(delegationDepth, 2)\n\t\t\t\t\t\t: delegationDepth;\n\t\t\t\tconst orchestratedRunContext = !!(orchestrationRunId && orchestrationTaskId);\n\t\t\t\tconst strictDelegationContract =\n\t\t\t\t\teffectiveProfile === \"meta\" ||\n\t\t\t\t\tnormalizedHostProfile === \"meta\" ||\n\t\t\t\t\tnormalizedAgentName?.toLowerCase().includes(\"orchestrator\") ||\n\t\t\t\t\t(orchestratedRunContext && (effectiveDelegateParallelHint ?? 0) >= 2);\n\t\t\t\tlet effectiveMaxDelegations = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\tMath.min(maxDelegationsPerTaskFromEnv, effectiveDelegateParallelHint ?? maxDelegationsPerTaskFromEnv),\n\t\t\t\t);\n\t\t\t\tlet effectiveMaxDelegateParallel = Math.max(\n\t\t\t\t\t1,\n\t\t\t\t\tMath.min(maxDelegatedParallelFromEnv, effectiveDelegateParallelHint ?? maxDelegatedParallelFromEnv),\n\t\t\t\t);\n\t\t\t\tconst isMetaDelegationContext = effectiveProfile === \"meta\" || normalizedHostProfile === \"meta\";\n\t\t\t\tconst preferredDelegationFloorBase = isMetaDelegationContext ? 3 : 2;\n\t\t\t\tconst preferredDelegationFloorMin = isMetaDelegationContext ? 2 : 1;\n\t\t\t\tconst metaDelegationCapacityFloor = 3;\n\t\t\t\tconst preferredDelegationFloor = Math.max(\n\t\t\t\t\tpreferredDelegationFloorMin,\n\t\t\t\t\tMath.min(preferredDelegationFloorBase, effectiveDelegateParallelHint ?? preferredDelegationFloorBase),\n\t\t\t\t);\n\t\t\t\tconst applyMetaDelegationFloor =\n\t\t\t\t\trequestedDelegateParallelHint === undefined &&\n\t\t\t\t\t(effectiveProfile === \"meta\" || normalizedHostProfile === \"meta\");\n\t\t\t\tif (applyMetaDelegationFloor) {\n\t\t\t\t\teffectiveMaxDelegations = Math.max(\n\t\t\t\t\t\teffectiveMaxDelegations,\n\t\t\t\t\t\tMath.min(maxDelegationsPerTaskFromEnv, metaDelegationCapacityFloor),\n\t\t\t\t\t);\n\t\t\t\t\teffectiveMaxDelegateParallel = Math.max(\n\t\t\t\t\t\teffectiveMaxDelegateParallel,\n\t\t\t\t\t\tMath.min(maxDelegatedParallelFromEnv, preferredDelegationFloor),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst minDelegationsPreferred =\n\t\t\t\t\t(effectiveDelegateParallelHint ?? 0) >= 2 && effectiveMaxDelegations >= 2\n\t\t\t\t\t\t? Math.min(preferredDelegationFloor, effectiveMaxDelegations, effectiveDelegateParallelHint ?? preferredDelegationFloor)\n\t\t\t\t\t\t: 0;\n\t\t\tconst baseSystemPrompt = withSubagentInstructions(\n\t\t\t\tcustomSubagent?.systemPrompt ??\n\t\t\t\t\tsystemPromptByProfile[effectiveProfile] ??\n\t\t\t\t\tsystemPromptByProfile.full,\n\t\t\t\tcustomSubagent?.instructions,\n\t\t\t);\n\t\t\tconst systemPrompt = withDelegationPrompt(\n\t\t\t\tbaseSystemPrompt,\n\t\t\t\teffectiveDelegationDepth,\n\t\t\t\teffectiveMaxDelegations,\n\t\t\t\tminDelegationsPreferred,\n\t\t\t);\n\t\t\tconst promptWithInstructions = prompt;\n\t\t\tconst effectiveModelOverride = requestedModel?.trim() || customSubagent?.model?.trim() || undefined;\n\t\t\tconst requestedBackground = background === true || customSubagent?.background === true;\n\t\t\tconst trackedOrchestrationRun =\n\t\t\t\torchestrationRunId && orchestrationTaskId ? getTeamRun(cwd, orchestrationRunId) : undefined;\n\t\t\t// Deterministic orchestration UX: run tracked team tasks in foreground so the parent turn\n\t\t\t// naturally waits for subagents and aggregates their outputs without ad-hoc polling.\n\t\t\tconst runInBackground = trackedOrchestrationRun ? false : requestedBackground;\n\t\t\tconst requestedSubagentCwd = targetCwd\n\t\t\t\t? path.resolve(cwd, targetCwd)\n\t\t\t\t: customSubagent?.cwd ?? cwd;\n\t\t\tif (!existsSync(requestedSubagentCwd) || !statSync(requestedSubagentCwd).isDirectory()) {\n\t\t\t\tthrow new Error(`Subagent cwd does not exist or is not a directory: ${requestedSubagentCwd}`);\n\t\t\t}\n\t\t\tif (runInBackground && !isBackgroundSafeToolset(tools)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Background policy violation: profile \"${effectiveProfile}\" has mutable tools (${tools\n\t\t\t\t\t\t.filter((toolName) => backgroundUnsafeTools.has(toolName))\n\t\t\t\t\t\t.join(\", \")}). Background mode requires read-only toolsets. Safe baseline profiles: ${backgroundSafeProfiles.join(\", \")}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst useWorktree = isolation === \"worktree\";\n\n\t\t\tconst queuedAt = Date.now();\n\t\t\tlet latestProgress: TaskToolProgress | undefined;\n\t\t\tconst emitProgress = (incoming: TaskToolProgress): void => {\n\t\t\t\tconst activeTool = \"activeTool\" in incoming ? incoming.activeTool : latestProgress?.activeTool;\n\t\t\t\tconst delegateIndex = \"delegateIndex\" in incoming ? incoming.delegateIndex : latestProgress?.delegateIndex;\n\t\t\t\tconst delegateTotal = \"delegateTotal\" in incoming ? incoming.delegateTotal : latestProgress?.delegateTotal;\n\t\t\t\tconst delegateDescription =\n\t\t\t\t\t\"delegateDescription\" in incoming ? incoming.delegateDescription : latestProgress?.delegateDescription;\n\t\t\t\tconst delegateProfile =\n\t\t\t\t\t\"delegateProfile\" in incoming ? incoming.delegateProfile : latestProgress?.delegateProfile;\n\t\t\t\tconst delegateItems =\n\t\t\t\t\t\"delegateItems\" in incoming\n\t\t\t\t\t\t? cloneDelegateItems(incoming.delegateItems)\n\t\t\t\t\t\t: cloneDelegateItems(latestProgress?.delegateItems);\n\t\t\t\tconst merged: TaskToolProgress = {\n\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\tphase: incoming.phase,\n\t\t\t\t\tmessage: incoming.message,\n\t\t\t\t\tcwd: incoming.cwd ?? latestProgress?.cwd ?? requestedSubagentCwd,\n\t\t\t\t\tactiveTool,\n\t\t\t\t\ttoolCallsStarted: incoming.toolCallsStarted ?? latestProgress?.toolCallsStarted,\n\t\t\t\t\ttoolCallsCompleted: incoming.toolCallsCompleted ?? latestProgress?.toolCallsCompleted,\n\t\t\t\t\tassistantMessages: incoming.assistantMessages ?? latestProgress?.assistantMessages,\n\t\t\t\t\tdelegateIndex,\n\t\t\t\t\tdelegateTotal,\n\t\t\t\t\tdelegateDescription,\n\t\t\t\t\tdelegateProfile,\n\t\t\t\t\tdelegateItems,\n\t\t\t\t};\n\t\t\t\tlatestProgress = merged;\n\t\t\t\tif (!onUpdate) return;\n\t\t\t\tonUpdate({\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: merged.message }],\n\t\t\t\t\tdetails: { progress: merged },\n\t\t\t\t});\n\t\t\t};\n\t\t\tthrowIfAborted();\n\t\t\temitProgress({\n\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\tphase: \"queued\",\n\t\t\t\tmessage: \"queued\",\n\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\ttoolCallsStarted: 0,\n\t\t\t\ttoolCallsCompleted: 0,\n\t\t\t\tassistantMessages: 0,\n\t\t\t});\n\n\t\t\t\tconst executeSubagent = async (): Promise<{ text: string; details: TaskToolDetails }> => {\n\t\t\t\t\tlet releaseRunSlot: (() => void) | undefined;\n\t\t\t\t\tlet releaseSlot: (() => void) | undefined;\n\t\t\t\t\tlet releaseWriteLock: (() => void) | undefined;\n\t\t\t\t\tlet releaseIsolation: (() => void) | undefined;\n\t\t\t\t\tconst explicitRootLockKey = lockKey?.trim();\n\t\t\t\t\tlet subagentCwd = requestedSubagentCwd;\n\t\t\t\t\tlet worktreePath: string | undefined;\n\t\t\t\t\tlet runStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\tconst heldWriteLocks = new Map<string, { count: number; release: () => void }>();\n\t\t\t\t\tconst acquireLocalWriteLock = async (rawLockKey: string | undefined): Promise<(() => void) | undefined> => {\n\t\t\t\t\t\tconst trimmed = rawLockKey?.trim();\n\t\t\t\t\t\tif (!trimmed) return undefined;\n\t\t\t\t\t\tconst normalizedKey = getCwdLockKey(trimmed);\n\t\t\t\t\t\tconst existing = heldWriteLocks.get(normalizedKey);\n\t\t\t\t\t\tif (existing) {\n\t\t\t\t\t\t\texisting.count += 1;\n\t\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\t\tconst current = heldWriteLocks.get(normalizedKey);\n\t\t\t\t\t\t\t\tif (!current) return;\n\t\t\t\t\t\t\t\tcurrent.count -= 1;\n\t\t\t\t\t\t\t\tif (current.count <= 0) {\n\t\t\t\t\t\t\t\t\theldWriteLocks.delete(normalizedKey);\n\t\t\t\t\t\t\t\t\tcurrent.release();\n\t\t\t\t\t\t\t\t\tcleanupWriteLock(trimmed);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst lock = getOrCreateWriteLock(trimmed);\n\t\t\t\t\t\tconst release = await lock.acquire();\n\t\t\t\t\t\theldWriteLocks.set(normalizedKey, { count: 1, release });\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tconst current = heldWriteLocks.get(normalizedKey);\n\t\t\t\t\t\t\tif (!current) return;\n\t\t\t\t\t\t\tcurrent.count -= 1;\n\t\t\t\t\t\t\tif (current.count <= 0) {\n\t\t\t\t\t\t\t\theldWriteLocks.delete(normalizedKey);\n\t\t\t\t\t\t\t\tcurrent.release();\n\t\t\t\t\t\t\t\tcleanupWriteLock(trimmed);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t\ttry {\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tif (orchestrationRunId && orchestrationTaskId) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait waitForOrchestrationDependencies({\n\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\trunId: orchestrationRunId,\n\t\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\tonWaiting: (waiting) => {\n\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\tphase: \"queued\",\n\t\t\t\t\t\t\t\t\t\tmessage: `waiting for dependencies: ${waiting}`,\n\t\t\t\t\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\tupdateTrackedTaskStatus(\"cancelled\");\n\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\tupdateTrackedTaskStatus(\"error\");\n\t\t\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\t\t\t\tfailureCauses: { [cause]: 1 },\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tthrow Object.assign(new Error(`Subagent failed: ${message}`), { details });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tconst orchestrationSemaphore =\n\t\t\t\t\t\torchestrationRunId && orchestrationTaskId\n\t\t\t\t\t\t\t? getOrCreateOrchestrationSemaphore(cwd, orchestrationRunId)\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\tif (orchestrationSemaphore) {\n\t\t\t\t\t\treleaseRunSlot = await orchestrationSemaphore.acquire();\n\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t}\n\t\t\t\t\treleaseSlot = await subagentSemaphore.acquire();\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tupdateTrackedTaskStatus(\"running\");\n\t\t\t\t\t\tif (writeCapableProfiles.has(effectiveProfile)) {\n\t\t\t\t\t\t\t// Parallel orchestration should remain truly parallel by default.\n\t\t\t\t\t\t\t// Serialize write-capable agents only when an explicit lock_key is provided.\n\t\t\t\t\t\t\tif (explicitRootLockKey) {\n\t\t\t\t\t\t\t\treleaseWriteLock = await acquireLocalWriteLock(explicitRootLockKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tif (useWorktree) {\n\t\t\t\t\t\tconst isolated = provisionWorktree(cwd, requestedSubagentCwd, runId);\n\t\t\t\t\t\tsubagentCwd = isolated.runCwd;\n\t\t\t\t\t\tworktreePath = isolated.worktreePath;\n\t\t\t\t\t\treleaseIsolation = isolated.cleanup;\n\t\t\t\t\t}\n\t\t\t\t\temitProgress({\n\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\tphase: \"starting\",\n\t\t\t\t\t\tmessage: \"starting subagent\",\n\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t});\n\n\t\t\t\t\t\tlet output: string;\n\t\t\t\t\t\tlet subagentSessionId: string | undefined;\n\t\t\t\t\t\tlet delegatedTasks = 0;\n\t\t\t\t\t\tlet delegatedSucceeded = 0;\n\t\t\t\t\t\tlet delegatedFailed = 0;\n\t\t\t\t\t\tlet retrospectiveAttempts = 0;\n\t\t\t\t\t\tlet retrospectiveRecovered = 0;\n\t\t\t\t\t\tconst delegationWarnings: string[] = [];\n\t\t\t\t\t\tconst delegatedSections: Array<string | undefined> = [];\n\t\t\t\t\t\tconst failureCauses: Partial<Record<FailureCause, number>> = {};\n\t\t\t\t\t\tconst delegatedStats = {\n\t\t\t\t\t\t\ttoolCallsStarted: 0,\n\t\t\t\t\t\t\ttoolCallsCompleted: 0,\n\t\t\t\t\t\t\tassistantMessages: 0,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst recordFailureCause = (cause: FailureCause): void => {\n\t\t\t\t\t\t\tfailureCauses[cause] = (failureCauses[cause] ?? 0) + 1;\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst rootSharedMemoryContext: SharedMemoryContext = {\n\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\t\trunId: sharedMemoryRunId,\n\t\t\t\t\t\t\ttaskId: sharedMemoryTaskId,\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t};\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst runRootPass = async (runPrompt: string): Promise<{\n\t\t\t\t\t\t\t\toutput: string;\n\t\t\t\t\t\t\t\tsessionId?: string;\n\t\t\t\t\t\t\t\tstats?: SubagentRunResult[\"stats\"];\n\t\t\t\t\t\t\t}> => {\n\t\t\t\t\t\t\t\tlet emptyAttempt = 0;\n\t\t\t\t\t\t\t\tlet retrospectiveAttempt = 0;\n\t\t\t\t\t\t\t\tlet mergedStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\tlet sessionId: string | undefined;\n\t\t\t\t\t\t\t\tlet promptForAttempt = runPrompt;\n\t\t\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tconst result = await runner({\n\t\t\t\t\t\t\t\t\t\t\tsystemPrompt,\n\t\t\t\t\t\t\t\t\t\t\tprofileName: effectiveProfile,\n\t\t\t\t\t\t\t\t\t\t\ttools,\n\t\t\t\t\t\t\t\t\t\t\tprompt: promptForAttempt,\n\t\t\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\t\t\tmodelOverride: effectiveModelOverride,\n\t\t\t\t\t\t\t\t\t\t\tsharedMemoryContext: rootSharedMemoryContext,\n\t\t\t\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\t\t\t\tonProgress: (progress) => emitProgress(progress),\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\t\t\t\t\t\tlet attemptOutput: string;\n\t\t\t\t\t\t\t\t\t\tlet attemptStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\t\t\tif (typeof result === \"string\") {\n\t\t\t\t\t\t\t\t\t\t\tattemptOutput = result;\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tattemptOutput = result.output;\n\t\t\t\t\t\t\t\t\t\t\tattemptStats = result.stats;\n\t\t\t\t\t\t\t\t\t\t\tsessionId = result.sessionId ?? sessionId;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tmergedStats = mergeRunStats(mergedStats, attemptStats);\n\t\t\t\t\t\t\t\t\t\tif (attemptOutput.trim().length > 0) {\n\t\t\t\t\t\t\t\t\t\t\tif (retrospectiveAttempt > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tretrospectiveRecovered += 1;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\toutput: attemptOutput,\n\t\t\t\t\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t\t\t\t\t\tstats: mergedStats,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (emptyAttempt >= emptyOutputRetriesFromEnv) {\n\t\t\t\t\t\t\t\t\t\t\tconst totalAttempts = emptyAttempt + 1;\n\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t\t`Subagent returned empty output after ${totalAttempts} attempt${totalAttempts === 1 ? \"\" : \"s\"}.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\temptyAttempt += 1;\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\tmessage: `root subagent returned empty output; retry ${emptyAttempt}/${emptyOutputRetriesFromEnv}`,\n\t\t\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\t\trecordFailureCause(cause);\n\t\t\t\t\t\t\t\t\t\tconst canRetryRetrospective =\n\t\t\t\t\t\t\t\t\t\t\tretrospectiveAttempt < retrospectiveRetriesFromEnv && isRetrospectiveRetryable(cause);\n\t\t\t\t\t\t\t\t\t\tif (!canRetryRetrospective) {\n\t\t\t\t\t\t\t\t\t\t\tthrow Object.assign(new Error(message), { failureCause: cause as FailureCause });\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tretrospectiveAttempt += 1;\n\t\t\t\t\t\t\t\t\t\tretrospectiveAttempts += 1;\n\t\t\t\t\t\t\t\t\t\tconst directive = buildRetrospectiveDirective({\n\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t\terrorMessage: message,\n\t\t\t\t\t\t\t\t\t\t\tattempt: retrospectiveAttempt,\n\t\t\t\t\t\t\t\t\t\t\ttarget: \"root\",\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tpromptForAttempt = `${runPrompt}\\n\\n${directive}`;\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\tmessage: `root retrospective retry ${retrospectiveAttempt}/${retrospectiveRetriesFromEnv} (${cause})`,\n\t\t\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst rootMeta = formatMetaCheckpoint(options?.getMetaMessages?.());\n\t\t\t\t\t\t\tconst rootSharedMemoryGuidance = buildSharedMemoryGuidance(sharedMemoryRunId, sharedMemoryTaskId);\n\t\t\t\t\t\t\tconst rootPromptBase = `${promptWithInstructions}\\n\\n${rootSharedMemoryGuidance}`;\n\t\t\t\t\t\t\tconst rootPrompt =\n\t\t\t\t\t\t\t\trootMeta.section && rootMeta.appliedCount > 0\n\t\t\t\t\t\t\t\t\t? `${rootPromptBase}\\n\\n${rootMeta.section}`\n\t\t\t\t\t\t\t\t\t: rootPromptBase;\n\t\t\t\t\t\tif (rootMeta.appliedCount > 0) {\n\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage: `applied ${rootMeta.appliedCount} meta update(s) to root task`,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst firstPass = await runRootPass(rootPrompt);\n\t\t\t\t\t\toutput = firstPass.output;\n\t\t\t\t\t\tsubagentSessionId = firstPass.sessionId;\n\t\t\t\t\t\trunStats = firstPass.stats;\n\n\t\t\t\t\t\tlet parsedDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\teffectiveDelegationDepth > 0 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (minDelegationsPreferred > 0 && parsedDelegation.requests.length < minDelegationsPreferred) {\n\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage: `delegation preference unmet (${parsedDelegation.requests.length}/${minDelegationsPreferred}), retrying with stronger split guidance`,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst enforcedPrompt = [\n\t\t\t\t\t\t\t\trootPrompt,\n\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\t\"[DELEGATION_ENFORCEMENT]\",\n\t\t\t\t\t\t\t\t`Prefer emitting at least ${minDelegationsPreferred} <delegate_task> blocks for independent sub-work when beneficial.`,\n\t\t\t\t\t\t\t\t`Target parallel fan-out: up to ${effectiveMaxDelegateParallel}.`,\n\t\t\t\t\t\t\t\t\"If decomposition is not beneficial, you may keep single-agent execution and optionally output one line:\",\n\t\t\t\t\t\t\t\t\"DELEGATION_IMPOSSIBLE: <reason>\",\n\t\t\t\t\t\t\t\t\"[/DELEGATION_ENFORCEMENT]\",\n\t\t\t\t\t\t\t].join(\"\\n\");\n\t\t\t\t\t\t\tconst secondPass = await runRootPass(enforcedPrompt);\n\t\t\t\t\t\t\toutput = secondPass.output;\n\t\t\t\t\t\t\tsubagentSessionId = secondPass.sessionId ?? subagentSessionId;\n\t\t\t\t\t\t\trunStats = secondPass.stats ?? runStats;\n\t\t\t\t\t\t\t\tparsedDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\t\t\toutput,\n\t\t\t\t\t\t\t\t\teffectiveDelegationDepth > 0 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tminDelegationsPreferred > 0 &&\n\t\t\t\t\t\t\tparsedDelegation.requests.length === 0 &&\n\t\t\t\t\t\t\tstrictDelegationContract\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst impossibleMatch = output.match(/^\\s*DELEGATION_IMPOSSIBLE\\s*:\\s*(.+)$/im);\n\t\t\t\t\t\t\tif (!impossibleMatch) {\n\t\t\t\t\t\t\t\tconst synthesizedRequests = synthesizeDelegationRequests({\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\t\t\tbaseProfile: effectiveProfile,\n\t\t\t\t\t\t\t\t\tcurrentDelegates: parsedDelegation.requests.length,\n\t\t\t\t\t\t\t\t\tminDelegationsPreferred,\n\t\t\t\t\t\t\t\t\tmaxDelegations: effectiveMaxDelegations,\n\t\t\t\t\t\t\t\t\tavailableCustomNames,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (synthesizedRequests.length > 0) {\n\t\t\t\t\t\t\t\t\tparsedDelegation.requests.push(...synthesizedRequests);\n\t\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t\t`Delegation auto-fanout: synthesized ${synthesizedRequests.length} delegate(s) to satisfy parallelism contract.`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (minDelegationsPreferred > 0 && parsedDelegation.requests.length < minDelegationsPreferred) {\n\t\t\t\t\t\t\tconst impossibleMatch = output.match(/^\\s*DELEGATION_IMPOSSIBLE\\s*:\\s*(.+)$/im);\n\t\t\t\t\t\t\tconst impossibleReason = impossibleMatch?.[1]?.trim() ?? \"not provided\";\n\t\t\t\t\t\t\tif (strictDelegationContract && parsedDelegation.requests.length === 0 && !impossibleMatch) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Delegation contract violated: expected >=${minDelegationsPreferred} delegates, got ${parsedDelegation.requests.length}. ` +\n\t\t\t\t\t\t\t\t\t\t`Provide nested <delegate_task> fan-out or an explicit \"DELEGATION_IMPOSSIBLE: <reason>\" line.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t`Delegation fallback: kept single-agent execution (preferred >=${minDelegationsPreferred} delegates, got ${parsedDelegation.requests.length}). Reason: ${impossibleReason}.`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\toutput = parsedDelegation.cleanedOutput;\n\t\t\t\t\t\tdelegationWarnings.push(...parsedDelegation.warnings);\n\t\t\t\t\t\tconst delegateTotal = parsedDelegation.requests.length;\n\t\t\t\t\t\tconst delegateItems: TaskDelegateProgressItem[] = parsedDelegation.requests.map((request, index) => ({\n\t\t\t\t\t\t\tindex: index + 1,\n\t\t\t\t\t\t\tdescription: request.description,\n\t\t\t\t\t\t\tprofile: request.profile,\n\t\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tconst normalizedDependsOn: number[][] = parsedDelegation.requests.map((request, index) => {\n\t\t\t\t\t\t\tconst current = index + 1;\n\t\t\t\t\t\t\tconst raw = request.dependsOn ?? [];\n\t\t\t\t\t\t\tconst unique = new Set<number>();\n\t\t\t\t\t\t\tfor (const dep of raw) {\n\t\t\t\t\t\t\t\tif (!Number.isInteger(dep) || dep <= 0 || dep > delegateTotal || dep === current) {\n\t\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t\t`Delegated task ${current} has invalid depends_on reference \"${dep}\" and it was ignored.`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tunique.add(dep);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn Array.from(unique).sort((a, b) => a - b);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tdelegatedTasks += delegateTotal;\n\t\t\t\t\t\tif (delegateTotal > 0) {\n\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\tmessage: `delegation scheduler: ${delegateTotal} task(s), max parallel ${Math.min(delegateTotal, effectiveMaxDelegateParallel)}`,\n\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst pendingIndices = new Set<number>(Array.from({ length: delegateTotal }, (_v, i) => i));\n\t\t\t\t\t\tconst runningDelegates = new Map<number, Promise<void>>();\n\t\t\t\t\t\tconst maxDelegateParallel = Math.max(1, Math.min(delegateTotal || 1, effectiveMaxDelegateParallel));\n\n\t\t\t\t\t\tconst statusOf = (idx: number): TaskDelegateProgressStatus =>\n\t\t\t\t\t\t\tdelegateItems[idx]?.status ?? \"pending\";\n\t\t\t\t\t\tconst formatDelegateTarget = (request: DelegationRequest): string => {\n\t\t\t\t\t\t\tconst agent = request.agent?.trim();\n\t\t\t\t\t\t\treturn agent ? `${agent}/${request.profile}` : request.profile;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst markDelegateFailed = (\n\t\t\t\t\t\t\t\tindex: number,\n\t\t\t\t\t\t\t\tmessage: string,\n\t\t\t\t\t\t\t\tdetails?: string,\n\t\t\t\t\t\t\t\tcause?: FailureCause,\n\t\t\t\t\t\t\t): void => {\n\t\t\t\t\t\t\t\tconst request = parsedDelegation.requests[index];\n\t\t\t\t\t\t\t\tif (delegateItems[index]) {\n\t\t\t\t\t\t\t\t\tdelegateItems[index].status = \"failed\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdelegatedFailed += 1;\n\t\t\t\t\t\t\t\tif (details) {\n\t\t\t\t\t\t\t\t\tdelegationWarnings.push(cause ? `${details} [cause=${cause}]` : details);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst causeLabel = cause ? ` [cause=${cause}]` : \"\";\n\t\t\t\t\t\t\t\tdelegatedSections[index] = `#### ${index + 1}. ${request.description} (${formatDelegateTarget(request)})\\nERROR${causeLabel}: ${message}`;\n\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\tdelegateProfile: request.profile,\n\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst executeNestedDelegates = async (\n\t\t\t\t\t\t\t\trequests: DelegationRequest[],\n\t\t\t\t\t\t\t\tparentCwd: string,\n\t\t\t\t\t\t\t\tdepthRemaining: number,\n\t\t\t\t\t\t\t\tlineage: string,\n\t\t\t\t\t\t\t): Promise<{\n\t\t\t\t\t\t\t\tsections: string[];\n\t\t\t\t\t\t\t\twarnings: string[];\n\t\t\t\t\t\t\t}> => {\n\t\t\t\t\t\t\t\tif (requests.length === 0 || depthRemaining <= 0) {\n\t\t\t\t\t\t\t\t\treturn { sections: [], warnings: [] };\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst nestedWarnings: string[] = [];\n\t\t\t\t\t\t\t\tconst sectionsByIndex: Array<string | undefined> = new Array(requests.length);\n\t\t\t\t\t\t\t\tconst statuses: TaskDelegateProgressStatus[] = Array.from(\n\t\t\t\t\t\t\t\t\t{ length: requests.length },\n\t\t\t\t\t\t\t\t\t() => \"pending\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst totalNested = requests.length;\n\t\t\t\t\t\t\t\tconst normalizedDependsOn: number[][] = requests.map((request, index) => {\n\t\t\t\t\t\t\t\t\tconst current = index + 1;\n\t\t\t\t\t\t\t\t\tconst raw = request.dependsOn ?? [];\n\t\t\t\t\t\t\t\t\tconst unique = new Set<number>();\n\t\t\t\t\t\t\t\t\tfor (const dep of raw) {\n\t\t\t\t\t\t\t\t\t\tif (!Number.isInteger(dep) || dep <= 0 || dep > totalNested || dep === current) {\n\t\t\t\t\t\t\t\t\t\t\tnestedWarnings.push(\n\t\t\t\t\t\t\t\t\t\t\t\t`Nested delegated task ${lineage}${current} has invalid depends_on reference \"${dep}\" and it was ignored.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tunique.add(dep);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn Array.from(unique).sort((a, b) => a - b);\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tconst statusOf = (index: number): TaskDelegateProgressStatus => statuses[index] ?? \"pending\";\n\t\t\t\t\t\t\t\tconst markNestedFailed = (\n\t\t\t\t\t\t\t\t\tnestedIndex: number,\n\t\t\t\t\t\t\t\t\trequestLabel: string,\n\t\t\t\t\t\t\t\t\tnestedRequest: DelegationRequest,\n\t\t\t\t\t\t\t\t\tnestedProfileLabel: string,\n\t\t\t\t\t\t\t\t\tmessage: string,\n\t\t\t\t\t\t\t\t\tcause: FailureCause,\n\t\t\t\t\t\t\t\t): void => {\n\t\t\t\t\t\t\t\t\tstatuses[nestedIndex] = \"failed\";\n\t\t\t\t\t\t\t\t\trecordFailureCause(cause);\n\t\t\t\t\t\t\t\t\tdelegatedTasks += 1;\n\t\t\t\t\t\t\t\t\tdelegatedFailed += 1;\n\t\t\t\t\t\t\t\t\tsectionsByIndex[nestedIndex] =\n\t\t\t\t\t\t\t\t\t\t`###### ${requestLabel}. ${nestedRequest.description} (${nestedProfileLabel})\\nERROR [cause=${cause}]: ${message}`;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tconst runNestedDelegate = async (nestedIndex: number): Promise<void> => {\n\t\t\t\t\t\t\t\t\tconst nestedRequest = requests[nestedIndex]!;\n\t\t\t\t\t\t\t\t\tconst requestLabel = `${lineage}${nestedIndex + 1}`;\n\t\t\t\t\t\t\t\t\tstatuses[nestedIndex] = \"running\";\n\t\t\t\t\t\t\t\t\tlet requestedNestedAgent = nestedRequest.agent?.trim() || undefined;\n\t\t\t\t\t\t\t\t\tlet nestedCustomSubagent = resolveCustom(requestedNestedAgent);\n\t\t\t\t\t\t\t\t\tif (!nestedCustomSubagent && !requestedNestedAgent) {\n\t\t\t\t\t\t\t\t\t\tconst profileAsAgent = resolveCustom(nestedRequest.profile);\n\t\t\t\t\t\t\t\t\t\tif (profileAsAgent) {\n\t\t\t\t\t\t\t\t\t\t\tnestedCustomSubagent = profileAsAgent;\n\t\t\t\t\t\t\t\t\t\t\trequestedNestedAgent = profileAsAgent.name;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (requestedNestedAgent && !nestedCustomSubagent) {\n\t\t\t\t\t\t\t\t\t\tnestedWarnings.push(\n\t\t\t\t\t\t\t\t\t\t\t`Nested delegated task \"${nestedRequest.description}\" requested unknown agent \"${requestedNestedAgent}\". Falling back to profile \"${nestedRequest.profile}\".`,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst nestedProfileCandidate = (nestedCustomSubagent?.profile ?? nestedRequest.profile).trim();\n\t\t\t\t\t\t\t\t\tconst normalizedNestedProfile = nestedProfileCandidate.toLowerCase();\n\t\t\t\t\t\t\t\t\tif (!isValidProfileName(normalizedNestedProfile)) {\n\t\t\t\t\t\t\t\t\t\tmarkNestedFailed(\n\t\t\t\t\t\t\t\t\t\t\tnestedIndex,\n\t\t\t\t\t\t\t\t\t\t\trequestLabel,\n\t\t\t\t\t\t\t\t\t\t\tnestedRequest,\n\t\t\t\t\t\t\t\t\t\t\tnestedProfileCandidate || \"unknown\",\n\t\t\t\t\t\t\t\t\t\t\t`nested delegate skipped: unknown profile \"${nestedProfileCandidate || nestedRequest.profile}\"`,\n\t\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst nestedProfile = normalizedNestedProfile as AgentProfileName;\n\t\t\t\t\t\t\t\t\tconst nestedProfileLabel = nestedCustomSubagent?.name\n\t\t\t\t\t\t\t\t\t\t? `${nestedCustomSubagent.name}/${nestedProfile}`\n\t\t\t\t\t\t\t\t\t\t: nestedProfile;\n\t\t\t\t\t\t\t\t\tlet nestedTools = nestedCustomSubagent?.tools\n\t\t\t\t\t\t\t\t\t\t? [...nestedCustomSubagent.tools]\n\t\t\t\t\t\t\t\t\t\t: [...toolsByProfile[nestedProfile]];\n\t\t\t\t\t\t\t\t\tif (nestedCustomSubagent?.disallowedTools?.length) {\n\t\t\t\t\t\t\t\t\t\tconst blocked = new Set(nestedCustomSubagent.disallowedTools);\n\t\t\t\t\t\t\t\t\t\tnestedTools = nestedTools.filter((tool) => !blocked.has(tool));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst nestedBaseSystemPrompt = withSubagentInstructions(\n\t\t\t\t\t\t\t\t\t\tnestedCustomSubagent?.systemPrompt ??\n\t\t\t\t\t\t\t\t\t\t\tsystemPromptByProfile[nestedProfile] ??\n\t\t\t\t\t\t\t\t\t\t\tsystemPromptByProfile.full,\n\t\t\t\t\t\t\t\t\t\tnestedCustomSubagent?.instructions,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst nestedSystemPrompt = withDelegationPrompt(\n\t\t\t\t\t\t\t\t\t\tnestedBaseSystemPrompt,\n\t\t\t\t\t\t\t\t\t\tMath.max(0, depthRemaining - 1),\n\t\t\t\t\t\t\t\t\t\teffectiveMaxDelegations,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst requestedNestedCwd = nestedRequest.cwd\n\t\t\t\t\t\t\t\t\t\t? path.resolve(parentCwd, nestedRequest.cwd)\n\t\t\t\t\t\t\t\t\t\t: nestedCustomSubagent?.cwd ?? parentCwd;\n\t\t\t\t\t\t\t\t\tif (!existsSync(requestedNestedCwd) || !statSync(requestedNestedCwd).isDirectory()) {\n\t\t\t\t\t\t\t\t\t\tmarkNestedFailed(\n\t\t\t\t\t\t\t\t\t\t\tnestedIndex,\n\t\t\t\t\t\t\t\t\t\t\trequestLabel,\n\t\t\t\t\t\t\t\t\t\t\tnestedRequest,\n\t\t\t\t\t\t\t\t\t\t\tnestedProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\"nested delegate skipped: missing cwd\",\n\t\t\t\t\t\t\t\t\t\t\t\"dependency_env\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tlet nestedReleaseLock: (() => void) | undefined;\n\t\t\t\t\t\t\t\t\t\tlet nestedReleaseIsolation: (() => void) | undefined;\n\t\t\t\t\t\t\t\t\t\tlet nestedCwd = requestedNestedCwd;\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tif (writeCapableProfiles.has(nestedProfile) && nestedRequest.lockKey?.trim()) {\n\t\t\t\t\t\t\t\t\t\t\t\tnestedReleaseLock = await acquireLocalWriteLock(nestedRequest.lockKey.trim());\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (nestedRequest.isolation === \"worktree\") {\n\t\t\t\t\t\t\t\t\t\t\tconst isolated = provisionWorktree(\n\t\t\t\t\t\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\t\t\t\t\t\trequestedNestedCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t`${runId}_nested_${requestLabel.replace(/\\./g, \"_\")}`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tnestedCwd = isolated.runCwd;\n\t\t\t\t\t\t\t\t\t\t\tnestedReleaseIsolation = isolated.cleanup;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tconst nestedPromptWithInstructions = nestedRequest.prompt;\n\t\t\t\t\t\t\t\t\t\tconst nestedSharedMemoryGuidance = buildSharedMemoryGuidance(\n\t\t\t\t\t\t\t\t\t\t\tsharedMemoryRunId,\n\t\t\t\t\t\t\t\t\t\t\tsharedMemoryTaskId,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tconst nestedPrompt = `${nestedPromptWithInstructions}\\n\\n${nestedSharedMemoryGuidance}`;\n\t\t\t\t\t\t\t\t\t\tconst nestedModelOverride =\n\t\t\t\t\t\t\t\t\t\t\tnestedRequest.model?.trim() || nestedCustomSubagent?.model?.trim() || undefined;\n\t\t\t\t\t\t\t\t\t\tconst nestedSharedMemoryContext: SharedMemoryContext = {\n\t\t\t\t\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\t\t\t\t\t\trunId: sharedMemoryRunId,\n\t\t\t\t\t\t\t\t\t\t\ttaskId: sharedMemoryTaskId,\n\t\t\t\t\t\t\t\t\t\t\tdelegateId: requestLabel,\n\t\t\t\t\t\t\t\t\t\t\tprofile: nestedProfile,\n\t\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\t\tconst nestedResult = await runner({\n\t\t\t\t\t\t\t\t\t\t\tsystemPrompt: nestedSystemPrompt,\n\t\t\t\t\t\t\t\t\t\t\tprofileName: nestedProfile,\n\t\t\t\t\t\t\t\t\t\t\ttools: nestedTools,\n\t\t\t\t\t\t\t\t\t\t\tprompt: nestedPrompt,\n\t\t\t\t\t\t\t\t\t\t\tcwd: nestedCwd,\n\t\t\t\t\t\t\t\t\t\t\tmodelOverride: nestedModelOverride,\n\t\t\t\t\t\t\t\t\t\t\tsharedMemoryContext: nestedSharedMemoryContext,\n\t\t\t\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\t\t\t\tonProgress: (progress) => {\n\t\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${requestLabel}: ${progress.message}`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcwd: progress.cwd ?? nestedCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: progress.activeTool,\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\n\t\t\t\t\t\t\t\t\t\tlet nestedOutput = typeof nestedResult === \"string\" ? nestedResult : nestedResult.output;\n\t\t\t\t\t\t\t\t\t\tconst nestedStats = typeof nestedResult === \"string\" ? undefined : nestedResult.stats;\n\t\t\t\t\t\t\t\t\t\tdelegatedTasks += 1;\n\t\t\t\t\t\t\t\t\t\tdelegatedSucceeded += 1;\n\t\t\t\t\t\t\t\t\t\tstatuses[nestedIndex] = \"done\";\n\t\t\t\t\t\t\t\t\t\tdelegatedStats.toolCallsStarted += nestedStats?.toolCallsStarted ?? 0;\n\t\t\t\t\t\t\t\t\t\tdelegatedStats.toolCallsCompleted += nestedStats?.toolCallsCompleted ?? 0;\n\t\t\t\t\t\t\t\t\t\tdelegatedStats.assistantMessages += nestedStats?.assistantMessages ?? 0;\n\n\t\t\t\t\t\t\t\t\t\tconst parsedNestedDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\t\t\t\t\tnestedOutput,\n\t\t\t\t\t\t\t\t\t\t\tdepthRemaining > 1 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tnestedOutput = parsedNestedDelegation.cleanedOutput;\n\t\t\t\t\t\t\t\t\t\tnestedWarnings.push(\n\t\t\t\t\t\t\t\t\t\t\t...parsedNestedDelegation.warnings.map(\n\t\t\t\t\t\t\t\t\t\t\t\t(warning) => `Nested child ${requestLabel}: ${warning}`,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\tlet nestedSection = `###### ${requestLabel}. ${nestedRequest.description} (${nestedProfileLabel})\\n${\n\t\t\t\t\t\t\t\t\t\t\tnestedOutput.trim() || \"(no output)\"\n\t\t\t\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t\t\t\t\tif (parsedNestedDelegation.requests.length > 0 && depthRemaining > 1) {\n\t\t\t\t\t\t\t\t\t\t\tconst deeper = await executeNestedDelegates(\n\t\t\t\t\t\t\t\t\t\t\t\tparsedNestedDelegation.requests,\n\t\t\t\t\t\t\t\t\t\t\t\tnestedCwd,\n\t\t\t\t\t\t\t\t\t\t\t\tdepthRemaining - 1,\n\t\t\t\t\t\t\t\t\t\t\t\t`${requestLabel}.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tnestedWarnings.push(...deeper.warnings);\n\t\t\t\t\t\t\t\t\t\t\tif (deeper.sections.length > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tnestedSection = `${nestedSection}\\n\\n##### Nested Delegated Subtasks\\n\\n${deeper.sections.join(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"\\n\\n\",\n\t\t\t\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tsectionsByIndex[nestedIndex] = nestedSection;\n\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\t\tmarkNestedFailed(\n\t\t\t\t\t\t\t\t\t\t\tnestedIndex,\n\t\t\t\t\t\t\t\t\t\t\trequestLabel,\n\t\t\t\t\t\t\t\t\t\t\tnestedRequest,\n\t\t\t\t\t\t\t\t\t\t\tnestedProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\t\t\t\tnestedReleaseIsolation?.();\n\t\t\t\t\t\t\t\t\t\t\tnestedReleaseLock?.();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tconst pendingIndices = new Set<number>(Array.from({ length: totalNested }, (_v, i) => i));\n\t\t\t\t\t\t\t\tconst runningNested = new Map<number, Promise<void>>();\n\t\t\t\t\t\t\t\tconst maxNestedParallel = Math.max(\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\tMath.min(totalNested, effectiveMaxDelegateParallel),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst resolveBlockedByFailedDependencies = (): boolean => {\n\t\t\t\t\t\t\t\t\tlet changed = false;\n\t\t\t\t\t\t\t\t\tfor (const nestedIndex of Array.from(pendingIndices)) {\n\t\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[nestedIndex] ?? [];\n\t\t\t\t\t\t\t\t\t\tif (deps.length === 0) continue;\n\t\t\t\t\t\t\t\t\t\tconst failedDep = deps.find((dep) => statusOf(dep - 1) === \"failed\");\n\t\t\t\t\t\t\t\t\t\tif (!failedDep) continue;\n\t\t\t\t\t\t\t\t\t\tpendingIndices.delete(nestedIndex);\n\t\t\t\t\t\t\t\t\t\tconst nestedRequest = requests[nestedIndex]!;\n\t\t\t\t\t\t\t\t\t\tconst requestLabel = `${lineage}${nestedIndex + 1}`;\n\t\t\t\t\t\t\t\t\t\tmarkNestedFailed(\n\t\t\t\t\t\t\t\t\t\t\tnestedIndex,\n\t\t\t\t\t\t\t\t\t\t\trequestLabel,\n\t\t\t\t\t\t\t\t\t\t\tnestedRequest,\n\t\t\t\t\t\t\t\t\t\t\tnestedRequest.profile,\n\t\t\t\t\t\t\t\t\t\t\t`nested delegate skipped: dependency ${lineage}${failedDep} failed`,\n\t\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn changed;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tconst launchReadyNested = (): boolean => {\n\t\t\t\t\t\t\t\t\tlet launched = false;\n\t\t\t\t\t\t\t\t\twhile (runningNested.size < maxNestedParallel) {\n\t\t\t\t\t\t\t\t\t\tlet nextIndex: number | undefined;\n\t\t\t\t\t\t\t\t\t\tfor (const nestedIndex of pendingIndices) {\n\t\t\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[nestedIndex] ?? [];\n\t\t\t\t\t\t\t\t\t\t\tconst allDone = deps.every((dep) => statusOf(dep - 1) === \"done\");\n\t\t\t\t\t\t\t\t\t\t\tif (allDone) {\n\t\t\t\t\t\t\t\t\t\t\t\tnextIndex = nestedIndex;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (nextIndex === undefined) break;\n\t\t\t\t\t\t\t\t\t\tpendingIndices.delete(nextIndex);\n\t\t\t\t\t\t\t\t\t\tconst promise = runNestedDelegate(nextIndex).finally(() => {\n\t\t\t\t\t\t\t\t\t\t\trunningNested.delete(nextIndex);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\trunningNested.set(nextIndex, promise);\n\t\t\t\t\t\t\t\t\t\tlaunched = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn launched;\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\twhile (pendingIndices.size > 0 || runningNested.size > 0) {\n\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\t\tconst changed = resolveBlockedByFailedDependencies();\n\t\t\t\t\t\t\t\t\tconst launched = launchReadyNested();\n\t\t\t\t\t\t\t\t\tif (runningNested.size === 0) {\n\t\t\t\t\t\t\t\t\t\tif (pendingIndices.size > 0 && !changed && !launched) {\n\t\t\t\t\t\t\t\t\t\t\tfor (const nestedIndex of Array.from(pendingIndices)) {\n\t\t\t\t\t\t\t\t\t\t\t\tpendingIndices.delete(nestedIndex);\n\t\t\t\t\t\t\t\t\t\t\t\tconst nestedRequest = requests[nestedIndex]!;\n\t\t\t\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[nestedIndex] ?? [];\n\t\t\t\t\t\t\t\t\t\t\t\tconst requestLabel = `${lineage}${nestedIndex + 1}`;\n\t\t\t\t\t\t\t\t\t\t\t\tmarkNestedFailed(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnestedIndex,\n\t\t\t\t\t\t\t\t\t\t\t\t\trequestLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnestedRequest,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnestedRequest.profile,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`nested delegate blocked: unresolved depends_on (${deps.join(\", \") || \"unknown\"})`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait Promise.race(Array.from(runningNested.values()));\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst sections = sectionsByIndex.filter(\n\t\t\t\t\t\t\t\t\t(section): section is string => typeof section === \"string\" && section.trim().length > 0,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn { sections, warnings: nestedWarnings };\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tconst runDelegate = async (index: number): Promise<void> => {\n\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\tconst request = parsedDelegation.requests[index];\n\t\t\t\t\t\t\tlet requestedChildAgent = request.agent?.trim() || undefined;\n\t\t\t\t\t\t\tlet childCustomSubagent = resolveCustom(requestedChildAgent);\n\t\t\t\t\t\t\tif (!childCustomSubagent && !requestedChildAgent) {\n\t\t\t\t\t\t\t\tconst profileAsAgent = resolveCustom(request.profile);\n\t\t\t\t\t\t\t\tif (profileAsAgent) {\n\t\t\t\t\t\t\t\t\tchildCustomSubagent = profileAsAgent;\n\t\t\t\t\t\t\t\t\trequestedChildAgent = profileAsAgent.name;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (requestedChildAgent && !childCustomSubagent) {\n\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t`Delegated task \"${request.description}\" requested unknown agent \"${requestedChildAgent}\". Falling back to profile \"${request.profile}\".`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst childProfileRaw = (childCustomSubagent?.profile ?? request.profile).trim();\n\t\t\t\t\t\t\tconst normalizedChildProfile = childProfileRaw.toLowerCase();\n\t\t\t\t\t\t\tif (!isValidProfileName(normalizedChildProfile)) {\n\t\t\t\t\t\t\t\trecordFailureCause(\"logic_error\");\n\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} skipped: unknown profile \"${childProfileRaw || request.profile}\"`,\n\t\t\t\t\t\t\t\t\t`Delegated task \"${request.description}\" requested unknown profile \"${childProfileRaw || request.profile}\".`,\n\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst childProfile = normalizedChildProfile as AgentProfileName;\n\t\t\t\t\t\t\tconst childProfileLabel = childCustomSubagent?.name\n\t\t\t\t\t\t\t\t? `${childCustomSubagent.name}/${childProfile}`\n\t\t\t\t\t\t\t\t: childProfile;\n\t\t\t\t\t\t\tif (delegateItems[index]) {\n\t\t\t\t\t\t\t\tdelegateItems[index].status = \"running\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\tmessage: `delegating ${index + 1}/${delegateTotal}: ${request.description}`,\n\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tlet childTools = childCustomSubagent?.tools\n\t\t\t\t\t\t\t\t? [...childCustomSubagent.tools]\n\t\t\t\t\t\t\t\t: [...toolsByProfile[childProfile]];\n\t\t\t\t\t\t\tif (childCustomSubagent?.disallowedTools?.length) {\n\t\t\t\t\t\t\t\tconst blocked = new Set(childCustomSubagent.disallowedTools);\n\t\t\t\t\t\t\t\tchildTools = childTools.filter((tool) => !blocked.has(tool));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst childBaseSystemPrompt = withSubagentInstructions(\n\t\t\t\t\t\t\t\tchildCustomSubagent?.systemPrompt ??\n\t\t\t\t\t\t\t\t\tsystemPromptByProfile[childProfile] ??\n\t\t\t\t\t\t\t\t\tsystemPromptByProfile.full,\n\t\t\t\t\t\t\t\tchildCustomSubagent?.instructions,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst childAutoDelegateParallelHint = deriveAutoDelegateParallelHint(\n\t\t\t\t\t\t\t\tchildProfile,\n\t\t\t\t\t\t\t\trequestedChildAgent,\n\t\t\t\t\t\t\t\tnormalizedHostProfile,\n\t\t\t\t\t\t\t\trequest.description,\n\t\t\t\t\t\t\t\trequest.prompt,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst childMinDelegationsPreferred =\n\t\t\t\t\t\t\t\tMath.max(0, effectiveDelegationDepth - 1) > 0 &&\n\t\t\t\t\t\t\t\t(childAutoDelegateParallelHint ?? 0) >= 2\n\t\t\t\t\t\t\t\t\t? Math.min(\n\t\t\t\t\t\t\t\t\t\t\tpreferredDelegationFloor,\n\t\t\t\t\t\t\t\t\t\t\teffectiveMaxDelegations,\n\t\t\t\t\t\t\t\t\t\t\tchildAutoDelegateParallelHint ?? preferredDelegationFloor,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\tconst childSystemPrompt = withDelegationPrompt(\n\t\t\t\t\t\t\t\tchildBaseSystemPrompt,\n\t\t\t\t\t\t\t\tMath.max(0, effectiveDelegationDepth - 1),\n\t\t\t\t\t\t\t\teffectiveMaxDelegations,\n\t\t\t\t\t\t\t\tchildMinDelegationsPreferred,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst requestedChildCwd = request.cwd\n\t\t\t\t\t\t\t\t\t? path.resolve(subagentCwd, request.cwd)\n\t\t\t\t\t\t\t\t\t: childCustomSubagent?.cwd ?? subagentCwd;\n\t\t\t\t\t\t\t\tif (!existsSync(requestedChildCwd) || !statSync(requestedChildCwd).isDirectory()) {\n\t\t\t\t\t\t\t\t\trecordFailureCause(\"dependency_env\");\n\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} skipped: missing cwd`,\n\t\t\t\t\t\t\t\t\t\t`Delegated task \"${request.description}\" skipped: cwd does not exist (${requestedChildCwd}).`,\n\t\t\t\t\t\t\t\t\t\t\"dependency_env\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tlet childReleaseLock: (() => void) | undefined;\n\t\t\t\t\t\t\t\tlet childReleaseIsolation: (() => void) | undefined;\n\t\t\t\t\t\t\t\tconst explicitChildLock = request.lockKey?.trim();\n\t\t\t\t\t\t\t\tlet childCwd = requestedChildCwd;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\t\tif (writeCapableProfiles.has(childProfile) && explicitChildLock) {\n\t\t\t\t\t\t\t\t\t\tchildReleaseLock = await acquireLocalWriteLock(explicitChildLock);\n\t\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (request.isolation === \"worktree\") {\n\t\t\t\t\t\t\t\t\tconst isolated = provisionWorktree(cwd, requestedChildCwd, `${runId}_delegate_${index + 1}`);\n\t\t\t\t\t\t\t\t\tchildCwd = isolated.runCwd;\n\t\t\t\t\t\t\t\t\tchildReleaseIsolation = isolated.cleanup;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst delegateMeta = formatMetaCheckpoint(options?.getMetaMessages?.());\n\t\t\t\t\t\t\t\t\tconst childPromptWithInstructions = request.prompt;\n\t\t\t\t\t\t\t\t\tconst delegateSharedMemoryGuidance = buildSharedMemoryGuidance(\n\t\t\t\t\t\t\t\t\t\tsharedMemoryRunId,\n\t\t\t\t\t\t\t\t\t\tsharedMemoryTaskId,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst delegatePromptBase = `${childPromptWithInstructions}\\n\\n${delegateSharedMemoryGuidance}`;\n\t\t\t\t\t\t\t\t\tconst delegatePrompt =\n\t\t\t\t\t\t\t\t\t\tdelegateMeta.section && delegateMeta.appliedCount > 0\n\t\t\t\t\t\t\t\t\t\t\t? `${delegatePromptBase}\\n\\n${delegateMeta.section}`\n\t\t\t\t\t\t\t\t\t\t\t: delegatePromptBase;\n\t\t\t\t\t\t\t\t\tif (delegateMeta.appliedCount > 0) {\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: applied ${delegateMeta.appliedCount} meta update(s)`,\n\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst childModelOverride = request.model?.trim() || childCustomSubagent?.model?.trim() || undefined;\n\t\t\t\t\t\t\t\t\tconst childSharedMemoryContext: SharedMemoryContext = {\n\t\t\t\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\t\t\t\t\trunId: sharedMemoryRunId,\n\t\t\t\t\t\t\t\t\t\ttaskId: sharedMemoryTaskId,\n\t\t\t\t\t\t\t\t\t\tdelegateId: String(index + 1),\n\t\t\t\t\t\t\t\t\t\tprofile: childProfile,\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tlet childOutput = \"\";\n\t\t\t\t\t\t\t\t\tlet childStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\t\tconst runChildPass = async (runPrompt: string): Promise<string> => {\n\t\t\t\t\t\t\t\t\t\tlet childEmptyAttempt = 0;\n\t\t\t\t\t\t\t\t\t\tlet childRetrospectiveAttempt = 0;\n\t\t\t\t\t\t\t\t\t\tlet childPromptForAttempt = runPrompt;\n\t\t\t\t\t\t\t\t\t\twhile (true) {\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\tconst childResult = await runner({\n\t\t\t\t\t\t\t\t\t\t\t\t\tsystemPrompt: childSystemPrompt,\n\t\t\t\t\t\t\t\t\t\t\t\t\tprofileName: childProfile,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttools: childTools,\n\t\t\t\t\t\t\t\t\t\t\t\t\tprompt: childPromptForAttempt,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t\tmodelOverride: childModelOverride,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsharedMemoryContext: childSharedMemoryContext,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsignal: _signal,\n\t\t\t\t\t\t\t\t\t\t\t\t\tonProgress: (progress) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: ${progress.message}`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcwd: progress.cwd ?? childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: progress.activeTool,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\t\t\t\t\t\tlet attemptOutput: string;\n\t\t\t\t\t\t\t\t\t\t\t\tlet attemptStats: SubagentRunResult[\"stats\"] | undefined;\n\t\t\t\t\t\t\t\t\t\t\t\tif (typeof childResult === \"string\") {\n\t\t\t\t\t\t\t\t\t\t\t\t\tattemptOutput = childResult;\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\tattemptOutput = childResult.output;\n\t\t\t\t\t\t\t\t\t\t\t\t\tattemptStats = childResult.stats;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tchildStats = mergeRunStats(childStats, attemptStats);\n\t\t\t\t\t\t\t\t\t\t\t\tif (attemptOutput.trim().length > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (childRetrospectiveAttempt > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tretrospectiveRecovered += 1;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn attemptOutput;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tif (childEmptyAttempt >= emptyOutputRetriesFromEnv) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tconst totalAttempts = childEmptyAttempt + 1;\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} returned empty output after ${totalAttempts} attempt${totalAttempts === 1 ? \"\" : \"s\"}.`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tchildEmptyAttempt += 1;\n\t\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: empty output, retry ${childEmptyAttempt}/${emptyOutputRetriesFromEnv}`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\t\t\t\tconst cause = classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\t\t\t\trecordFailureCause(cause);\n\t\t\t\t\t\t\t\t\t\t\t\tconst canRetryRetrospective =\n\t\t\t\t\t\t\t\t\t\t\t\t\tchildRetrospectiveAttempt < retrospectiveRetriesFromEnv &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tisRetrospectiveRetryable(cause);\n\t\t\t\t\t\t\t\t\t\t\t\tif (!canRetryRetrospective) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrow Object.assign(new Error(message), { failureCause: cause as FailureCause });\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tchildRetrospectiveAttempt += 1;\n\t\t\t\t\t\t\t\t\t\t\t\tretrospectiveAttempts += 1;\n\t\t\t\t\t\t\t\t\t\t\t\tconst directive = buildRetrospectiveDirective({\n\t\t\t\t\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t\t\t\t\t\terrorMessage: message,\n\t\t\t\t\t\t\t\t\t\t\t\t\tattempt: childRetrospectiveAttempt,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttarget: \"delegate\",\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\tchildPromptForAttempt = `${runPrompt}\\n\\n${directive}`;\n\t\t\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: retrospective retry ${childRetrospectiveAttempt}/${retrospectiveRetriesFromEnv} (${cause})`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\tchildOutput = await runChildPass(delegatePrompt);\n\t\t\t\t\t\t\t\t\tlet parsedChildDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\t\t\t\tchildOutput,\n\t\t\t\t\t\t\t\t\t\teffectiveDelegationDepth > 1 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tchildMinDelegationsPreferred > 0 &&\n\t\t\t\t\t\t\t\t\t\tparsedChildDelegation.requests.length < childMinDelegationsPreferred\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal}: nested delegation preference unmet (${parsedChildDelegation.requests.length}/${childMinDelegationsPreferred}), retrying with stronger split guidance`,\n\t\t\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tconst enforcedChildPrompt = [\n\t\t\t\t\t\t\t\t\t\t\tdelegatePrompt,\n\t\t\t\t\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t\t\t\t\t\t\"[DELEGATION_ENFORCEMENT]\",\n\t\t\t\t\t\t\t\t\t\t\t`This delegated workstream must emit at least ${childMinDelegationsPreferred} <delegate_task> blocks for independent sub-work when beneficial.`,\n\t\t\t\t\t\t\t\t\t\t\t`Target parallel fan-out: up to ${Math.min(effectiveMaxDelegateParallel, effectiveMaxDelegations)}.`,\n\t\t\t\t\t\t\t\t\t\t\t\"For broad audits or implementations, split by subsystem / file cluster / verification stream instead of doing everything in one pass.\",\n\t\t\t\t\t\t\t\t\t\t\t\"If safe decomposition is impossible, output exactly one line:\",\n\t\t\t\t\t\t\t\t\t\t\t\"DELEGATION_IMPOSSIBLE: <reason>\",\n\t\t\t\t\t\t\t\t\t\t\t\"[/DELEGATION_ENFORCEMENT]\",\n\t\t\t\t\t\t\t\t\t\t].join(\"\\n\");\n\t\t\t\t\t\t\t\t\t\tchildOutput = await runChildPass(enforcedChildPrompt);\n\t\t\t\t\t\t\t\t\t\tparsedChildDelegation = parseDelegationRequests(\n\t\t\t\t\t\t\t\t\t\t\tchildOutput,\n\t\t\t\t\t\t\t\t\t\t\teffectiveDelegationDepth > 1 ? effectiveMaxDelegations : 0,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tchildMinDelegationsPreferred > 0 &&\n\t\t\t\t\t\t\t\t\t\tparsedChildDelegation.requests.length === 0 &&\n\t\t\t\t\t\t\t\t\t\tstrictDelegationContract\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst impossibleMatch = childOutput.match(/^\\s*DELEGATION_IMPOSSIBLE\\s*:\\s*(.+)$/im);\n\t\t\t\t\t\t\t\t\t\tif (!impossibleMatch) {\n\t\t\t\t\t\t\t\t\t\t\tconst synthesizedChildRequests = synthesizeDelegationRequests({\n\t\t\t\t\t\t\t\t\t\t\t\tdescription: request.description,\n\t\t\t\t\t\t\t\t\t\t\t\tprompt: request.prompt,\n\t\t\t\t\t\t\t\t\t\t\t\tbaseProfile: childProfile,\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentDelegates: parsedChildDelegation.requests.length,\n\t\t\t\t\t\t\t\t\t\t\t\tminDelegationsPreferred: childMinDelegationsPreferred,\n\t\t\t\t\t\t\t\t\t\t\t\tmaxDelegations: effectiveMaxDelegations,\n\t\t\t\t\t\t\t\t\t\t\t\tavailableCustomNames,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\tif (synthesizedChildRequests.length > 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tparsedChildDelegation.requests.push(...synthesizedChildRequests);\n\t\t\t\t\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`Child ${index + 1}: delegation auto-fanout synthesized ${synthesizedChildRequests.length} nested delegate(s).`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tchildMinDelegationsPreferred > 0 &&\n\t\t\t\t\t\t\t\t\t\t\tparsedChildDelegation.requests.length < childMinDelegationsPreferred\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tconst impossibleMatch = childOutput.match(/^\\s*DELEGATION_IMPOSSIBLE\\s*:\\s*(.+)$/im);\n\t\t\t\t\t\t\t\t\t\t\tconst impossibleReason = impossibleMatch?.[1]?.trim() ?? \"not provided\";\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\tstrictDelegationContract &&\n\t\t\t\t\t\t\t\t\t\t\t\tparsedChildDelegation.requests.length === 0 &&\n\t\t\t\t\t\t\t\t\t\t\t\t!impossibleMatch\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`Delegation contract violated for child ${index + 1}: expected >=${childMinDelegationsPreferred} nested delegates, got ${parsedChildDelegation.requests.length}. ` +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`Provide nested <delegate_task> fan-out or \"DELEGATION_IMPOSSIBLE: <reason>\".`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t\t\t\t`Child ${index + 1}: delegation fallback (preferred >=${childMinDelegationsPreferred}, got ${parsedChildDelegation.requests.length}). Reason: ${impossibleReason}.`,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchildOutput = parsedChildDelegation.cleanedOutput;\n\t\t\t\t\t\t\t\tdelegationWarnings.push(\n\t\t\t\t\t\t\t\t\t...parsedChildDelegation.warnings.map((warning) => `Child ${index + 1}: ${warning}`),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tlet nestedSection = \"\";\n\t\t\t\t\t\t\t\tif (parsedChildDelegation.requests.length > 0 && effectiveDelegationDepth > 1) {\n\t\t\t\t\t\t\t\t\tconst nested = await executeNestedDelegates(\n\t\t\t\t\t\t\t\t\t\tparsedChildDelegation.requests,\n\t\t\t\t\t\t\t\t\t\tchildCwd,\n\t\t\t\t\t\t\t\t\t\teffectiveDelegationDepth - 1,\n\t\t\t\t\t\t\t\t\t\t`${index + 1}.`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tdelegationWarnings.push(...nested.warnings);\n\t\t\t\t\t\t\t\t\tif (nested.sections.length > 0) {\n\t\t\t\t\t\t\t\t\t\tnestedSection = `\\n\\n##### Nested Delegated Subtasks\\n\\n${nested.sections.join(\"\\n\\n\")}`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdelegatedSucceeded += 1;\n\t\t\t\t\t\t\t\tif (delegateItems[index]) {\n\t\t\t\t\t\t\t\t\tdelegateItems[index].status = \"done\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdelegatedStats.toolCallsStarted += childStats?.toolCallsStarted ?? 0;\n\t\t\t\t\t\t\t\tdelegatedStats.toolCallsCompleted += childStats?.toolCallsCompleted ?? 0;\n\t\t\t\t\t\t\t\tdelegatedStats.assistantMessages += childStats?.assistantMessages ?? 0;\n\t\t\t\t\t\t\t\tconst normalizedChildOutput = childOutput.trim().length > 0 ? childOutput.trim() : \"(no output)\";\n\t\t\t\t\t\t\t\tconst childOutputExcerpt =\n\t\t\t\t\t\t\t\t\tnormalizedChildOutput.length > maxDelegatedOutputCharsFromEnv\n\t\t\t\t\t\t\t\t\t\t? `${normalizedChildOutput.slice(0, Math.max(1, maxDelegatedOutputCharsFromEnv - 3))}...`\n\t\t\t\t\t\t\t\t\t\t: normalizedChildOutput;\n\t\t\t\t\t\t\t\tdelegatedSections[index] =\n\t\t\t\t\t\t\t\t\t`#### ${index + 1}. ${request.description} (${childProfileLabel})\\n${childOutputExcerpt}${nestedSection}`;\n\t\t\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\t\t\tphase: \"running\",\n\t\t\t\t\t\t\t\t\tmessage: `delegate ${index + 1}/${delegateTotal} done`,\n\t\t\t\t\t\t\t\t\tcwd: childCwd,\n\t\t\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\t\t\tdelegateIndex: index + 1,\n\t\t\t\t\t\t\t\t\tdelegateTotal,\n\t\t\t\t\t\t\t\t\tdelegateDescription: request.description,\n\t\t\t\t\t\t\t\t\tdelegateProfile: childProfileLabel,\n\t\t\t\t\t\t\t\t\tdelegateItems,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Operation aborted\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst classified =\n\t\t\t\t\t\t\t\t\t\terror && typeof error === \"object\" && \"failureCause\" in error\n\t\t\t\t\t\t\t\t\t\t\t? (error.failureCause as FailureCause)\n\t\t\t\t\t\t\t\t\t\t\t: classifyFailureCause(message);\n\t\t\t\t\t\t\t\t\tif (!(error && typeof error === \"object\" && \"failureCause\" in error)) {\n\t\t\t\t\t\t\t\t\t\trecordFailureCause(classified);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} failed`,\n\t\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\tclassified,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\t\tchildReleaseIsolation?.();\n\t\t\t\t\t\t\t\t\tchildReleaseLock?.();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst resolveBlockedByFailedDependencies = (): boolean => {\n\t\t\t\t\t\t\tlet changed = false;\n\t\t\t\t\t\t\tfor (const index of Array.from(pendingIndices)) {\n\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[index] ?? [];\n\t\t\t\t\t\t\t\tif (deps.length === 0) continue;\n\t\t\t\t\t\t\t\tconst failedDep = deps.find((dep) => statusOf(dep - 1) === \"failed\");\n\t\t\t\t\t\t\t\tif (!failedDep) continue;\n\t\t\t\t\t\t\t\t\tpendingIndices.delete(index);\n\t\t\t\t\t\t\t\t\trecordFailureCause(\"logic_error\");\n\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} skipped: dependency ${failedDep} failed`,\n\t\t\t\t\t\t\t\t\t\t`Delegated task ${index + 1} skipped because dependency ${failedDep} failed.`,\n\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn changed;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst launchReadyDelegates = (): boolean => {\n\t\t\t\t\t\t\tlet launched = false;\n\t\t\t\t\t\t\twhile (runningDelegates.size < maxDelegateParallel) {\n\t\t\t\t\t\t\t\tlet nextIndex: number | undefined;\n\t\t\t\t\t\t\t\tfor (const index of pendingIndices) {\n\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[index] ?? [];\n\t\t\t\t\t\t\t\t\tconst allDone = deps.every((dep) => statusOf(dep - 1) === \"done\");\n\t\t\t\t\t\t\t\t\tif (allDone) {\n\t\t\t\t\t\t\t\t\t\tnextIndex = index;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (nextIndex === undefined) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpendingIndices.delete(nextIndex);\n\t\t\t\t\t\t\t\tconst promise = runDelegate(nextIndex).finally(() => {\n\t\t\t\t\t\t\t\t\trunningDelegates.delete(nextIndex);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\trunningDelegates.set(nextIndex, promise);\n\t\t\t\t\t\t\t\tlaunched = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn launched;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\twhile (pendingIndices.size > 0 || runningDelegates.size > 0) {\n\t\t\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\t\t\tconst changed = resolveBlockedByFailedDependencies();\n\t\t\t\t\t\t\tconst launched = launchReadyDelegates();\n\t\t\t\t\t\t\tif (runningDelegates.size === 0) {\n\t\t\t\t\t\t\t\tif (pendingIndices.size > 0 && !changed && !launched) {\n\t\t\t\t\t\t\t\t\t\tfor (const index of Array.from(pendingIndices)) {\n\t\t\t\t\t\t\t\t\t\t\tpendingIndices.delete(index);\n\t\t\t\t\t\t\t\t\t\t\tconst deps = normalizedDependsOn[index] ?? [];\n\t\t\t\t\t\t\t\t\t\t\trecordFailureCause(\"logic_error\");\n\t\t\t\t\t\t\t\t\t\t\tmarkDelegateFailed(\n\t\t\t\t\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\t\t\t\t\t`delegate ${index + 1}/${delegateTotal} blocked: unresolved depends_on`,\n\t\t\t\t\t\t\t\t\t\t\t\t`Delegated task ${index + 1} blocked by unresolved dependencies: ${deps.join(\", \") || \"unknown\"}.`,\n\t\t\t\t\t\t\t\t\t\t\t\t\"logic_error\",\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait Promise.race(Array.from(runningDelegates.values()));\n\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\t\tif (_signal?.aborted || isAbortError(error)) {\n\t\t\t\t\t\t\t\trecordFailureCause(\"aborted\");\n\t\t\t\t\t\t\t\tconst hasFailureCauses = Object.keys(failureCauses).length > 0;\n\t\t\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\t\t\t\ttoolCallsStarted: runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted,\n\t\t\t\t\t\t\t\t\ttoolCallsCompleted: runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted,\n\t\t\t\t\t\t\t\t\tassistantMessages: runStats?.assistantMessages ?? latestProgress?.assistantMessages,\n\t\t\t\t\t\t\t\t\tdelegatedTasks: delegatedTasks > 0 ? delegatedTasks : undefined,\n\t\t\t\t\t\t\t\t\tdelegatedSucceeded: delegatedTasks > 0 ? delegatedSucceeded : undefined,\n\t\t\t\t\t\t\t\t\tdelegatedFailed: delegatedTasks > 0 ? delegatedFailed : undefined,\n\t\t\t\t\t\t\t\t\tretrospectiveAttempts: retrospectiveAttempts > 0 ? retrospectiveAttempts : undefined,\n\t\t\t\t\t\t\t\t\tretrospectiveRecovered: retrospectiveRecovered > 0 ? retrospectiveRecovered : undefined,\n\t\t\t\t\t\t\t\t\tfailureCauses: hasFailureCauses ? { ...failureCauses } : undefined,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tupdateTrackedTaskStatus(\"cancelled\");\n\t\t\t\t\t\t\t\tthrow Object.assign(new Error(\"Operation aborted\"), {\n\t\t\t\t\t\t\t\t\tdetails,\n\t\t\t\t\t\t\t\t\tfailureCause: \"aborted\" as FailureCause,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst classified =\n\t\t\t\t\t\t\t\terror && typeof error === \"object\" && \"failureCause\" in error\n\t\t\t\t\t\t\t\t\t? (error.failureCause as FailureCause)\n\t\t\t\t\t\t\t\t\t: classifyFailureCause(message);\n\t\t\t\t\t\t\tif (!(error && typeof error === \"object\" && \"failureCause\" in error)) {\n\t\t\t\t\t\t\t\trecordFailureCause(classified);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst hasFailureCauses = Object.keys(failureCauses).length > 0;\n\t\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\t\ttoolCallsStarted: runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted,\n\t\t\t\t\t\t\ttoolCallsCompleted: runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted,\n\t\t\t\t\t\t\t\tassistantMessages: runStats?.assistantMessages ?? latestProgress?.assistantMessages,\n\t\t\t\t\t\t\t\tdelegatedTasks: delegatedTasks > 0 ? delegatedTasks : undefined,\n\t\t\t\t\t\t\t\tdelegatedSucceeded: delegatedTasks > 0 ? delegatedSucceeded : undefined,\n\t\t\t\t\t\t\t\tdelegatedFailed: delegatedTasks > 0 ? delegatedFailed : undefined,\n\t\t\t\t\t\t\t\tretrospectiveAttempts: retrospectiveAttempts > 0 ? retrospectiveAttempts : undefined,\n\t\t\t\t\t\t\t\tretrospectiveRecovered: retrospectiveRecovered > 0 ? retrospectiveRecovered : undefined,\n\t\t\t\t\t\t\t\tfailureCauses: hasFailureCauses ? { ...failureCauses } : undefined,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\tupdateTrackedTaskStatus(\"error\");\n\t\t\t\t\t\tthrow Object.assign(new Error(`Subagent failed: ${message}`), { details });\n\t\t\t\t\t}\n\n\t\t\t\t\t\tconst normalizedOutput = output.trim().length > 0 ? output.trim() : \"(Subagent completed with no output)\";\n\t\t\t\t\t\tconst finalSections: string[] = [normalizedOutput];\n\t\t\t\t\t\tif (delegatedTasks > 0) {\n\t\t\t\t\t\t\tconst header = `### Delegated Subtasks (${delegatedSucceeded}/${delegatedTasks} done)`;\n\t\t\t\t\t\tconst delegatedBlocks = delegatedSections.filter(\n\t\t\t\t\t\t\t(section): section is string => typeof section === \"string\" && section.trim().length > 0,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfinalSections.push([header, ...delegatedBlocks].join(\"\\n\\n\"));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (delegationWarnings.length > 0) {\n\t\t\t\t\t\t\tfinalSections.push(`### Delegation Notes\\n${delegationWarnings.map((w) => `- ${w}`).join(\"\\n\")}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst failureCauseSummary = formatFailureCauseCounts(failureCauses);\n\t\t\t\t\t\tif (retrospectiveAttempts > 0 || failureCauseSummary) {\n\t\t\t\t\t\t\tfinalSections.push(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\"### Retrospective\",\n\t\t\t\t\t\t\t\t\t`- attempts: ${retrospectiveAttempts}`,\n\t\t\t\t\t\t\t\t\t`- recovered: ${retrospectiveRecovered}`,\n\t\t\t\t\t\t\t\t\t`- failure_causes: ${failureCauseSummary || \"none\"}`,\n\t\t\t\t\t\t\t\t].join(\"\\n\"),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst text = finalSections.join(\"\\n\\n\");\n\t\t\t\t\t\temitProgress({\n\t\t\t\t\t\t\tkind: \"subagent_progress\",\n\t\t\t\t\t\t\tphase: \"responding\",\n\t\t\t\t\t\t\tmessage: delegatedTasks > 0 ? \"aggregating delegated results\" : \"finalizing response\",\n\t\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\t\tactiveTool: undefined,\n\t\t\t\t\t\t\tdelegateIndex: undefined,\n\t\t\t\t\t\t\tdelegateTotal: undefined,\n\t\t\t\t\t\t\tdelegateDescription: undefined,\n\t\t\t\t\t\t\tdelegateProfile: undefined,\n\t\t\t\t\t\t\tdelegateItems: undefined,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst transcriptPath = persistSubagentTranscript({\n\t\t\t\t\t\t\trootCwd: cwd,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\tsubagentCwd,\n\t\t\t\t\t\tsessionId: subagentSessionId,\n\t\t\t\t\t\tprompt: promptWithInstructions,\n\t\t\t\t\t\toutput: text,\n\t\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst hasFailureCauses = Object.keys(failureCauses).length > 0;\n\t\t\t\t\t\tconst details: TaskToolDetails = {\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\toutputLength: text.length,\n\t\t\t\t\t\tcwd: subagentCwd,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\tsubagentSessionId,\n\t\t\t\t\t\ttranscriptPath,\n\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\tworktreePath,\n\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\tbackground: runInBackground,\n\t\t\t\t\t\ttoolCallsStarted:\n\t\t\t\t\t\t\ttypeof (runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted) === \"number\"\n\t\t\t\t\t\t\t\t? (runStats?.toolCallsStarted ?? latestProgress?.toolCallsStarted ?? 0) +\n\t\t\t\t\t\t\t\t\tdelegatedStats.toolCallsStarted\n\t\t\t\t\t\t\t\t: delegatedStats.toolCallsStarted > 0\n\t\t\t\t\t\t\t\t\t? delegatedStats.toolCallsStarted\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\ttoolCallsCompleted:\n\t\t\t\t\t\t\ttypeof (runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted) === \"number\"\n\t\t\t\t\t\t\t\t? (runStats?.toolCallsCompleted ?? latestProgress?.toolCallsCompleted ?? 0) +\n\t\t\t\t\t\t\t\t\tdelegatedStats.toolCallsCompleted\n\t\t\t\t\t\t\t\t: delegatedStats.toolCallsCompleted > 0\n\t\t\t\t\t\t\t\t\t? delegatedStats.toolCallsCompleted\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tassistantMessages:\n\t\t\t\t\t\t\ttypeof (runStats?.assistantMessages ?? latestProgress?.assistantMessages) === \"number\"\n\t\t\t\t\t\t\t\t? (runStats?.assistantMessages ?? latestProgress?.assistantMessages ?? 0) +\n\t\t\t\t\t\t\t\t\tdelegatedStats.assistantMessages\n\t\t\t\t\t\t\t\t: delegatedStats.assistantMessages > 0\n\t\t\t\t\t\t\t\t\t? delegatedStats.assistantMessages\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\tdelegatedTasks: delegatedTasks > 0 ? delegatedTasks : undefined,\n\t\t\t\t\t\t\tdelegatedSucceeded: delegatedTasks > 0 ? delegatedSucceeded : undefined,\n\t\t\t\t\t\t\tdelegatedFailed: delegatedTasks > 0 ? delegatedFailed : undefined,\n\t\t\t\t\t\t\tretrospectiveAttempts: retrospectiveAttempts > 0 ? retrospectiveAttempts : undefined,\n\t\t\t\t\t\t\tretrospectiveRecovered: retrospectiveRecovered > 0 ? retrospectiveRecovered : undefined,\n\t\t\t\t\t\t\tfailureCauses: hasFailureCauses ? { ...failureCauses } : undefined,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tupdateTrackedTaskStatus(\"done\");\n\t\t\t\t\t\treturn { text, details };\n\t\t\t\t\t} finally {\n\t\t\t\t\t\treleaseIsolation?.();\n\t\t\t\t\t\treleaseWriteLock?.();\n\t\t\t\t\t\treleaseSlot?.();\n\t\t\t\t\t\treleaseRunSlot?.();\n\t\t\t\t\t\tif (orchestrationRunId) {\n\t\t\t\t\t\tcleanupOrchestrationSemaphore(cwd, orchestrationRunId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (runInBackground) {\n\t\t\t\tconst now = new Date().toISOString();\n\t\t\t\tconst queuedStatusPath = writeBackgroundRunStatus(cwd, {\n\t\t\t\t\trunId,\n\t\t\t\t\tstatus: \"queued\",\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tdescription,\n\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t});\n\t\t\t\tvoid (async () => {\n\t\t\t\t\twriteBackgroundRunStatus(cwd, {\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\tstartedAt: new Date().toISOString(),\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t});\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await executeSubagent();\n\t\t\t\t\t\twriteBackgroundRunStatus(cwd, {\n\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\tstatus: \"done\",\n\t\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\t\tfinishedAt: new Date().toISOString(),\n\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\tcwd: result.details.cwd,\n\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\ttranscriptPath: result.details.transcriptPath,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst aborted = isAbortError(error);\n\t\t\t\t\t\t\twriteBackgroundRunStatus(cwd, {\n\t\t\t\t\t\t\t\trunId,\n\t\t\t\t\t\t\t\tstatus: aborted ? \"cancelled\" : \"error\",\n\t\t\t\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\t\t\t\tfinishedAt: new Date().toISOString(),\n\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `Started background subagent run ${runId}. Check .iosm/subagents/background and /subagent-runs for results.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tprofile: effectiveProfile,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\toutputLength: 0,\n\t\t\t\t\t\tcwd: requestedSubagentCwd,\n\t\t\t\t\t\tagent: customSubagent?.name,\n\t\t\t\t\t\tlockKey: lockKey?.trim() || undefined,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\ttaskId: orchestrationTaskId,\n\t\t\t\t\t\tmodel: effectiveModelOverride,\n\t\t\t\t\t\tbackground: true,\n\t\t\t\t\t\tbackgroundStatusPath: queuedStatusPath,\n\t\t\t\t\t\twaitMs: Date.now() - queuedAt,\n\t\t\t\t\t\tisolation: useWorktree ? \"worktree\" : \"none\",\n\t\t\t\t\t\ttoolCallsStarted: latestProgress?.toolCallsStarted,\n\t\t\t\t\t\ttoolCallsCompleted: latestProgress?.toolCallsCompleted,\n\t\t\t\t\t\tassistantMessages: latestProgress?.assistantMessages,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst result = await executeSubagent();\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text: result.text }],\n\t\t\t\tdetails: result.details,\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|