{"version":3,"file":"warm-subagent-pool-instance.d.ts","sourceRoot":"","sources":["../../src/core/warm-subagent-pool-instance.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAO3D,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,GAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAO,GAAG,gBAAgB,CAY9G;AAED,oGAAoG;AACpG,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAGlE","sourcesContent":["/**\n * Process-wide WarmSubagentPool singleton + enablement gate.\n *\n * Mirrors subagent-pool-instance: one shared warm pool per process so worker\n * reuse and idle reclaim are coordinated across every dispatch. Created lazily on\n * first use and disposed on exit. Enablement is carried in the environment\n * (HOOCODE_WARM_SUBAGENTS) so it is set once at the root and is trivially\n * readable from the Task tool without threading a setting through every call.\n */\n\nimport type { Api, Model } from \"@kolisachint/hoocode-ai\";\nimport { getAgentDir } from \"../config.js\";\nimport { SettingsManager } from \"./settings-manager.js\";\nimport { WarmSubagentPool } from \"./warm-subagent-pool.js\";\n\n/** Set to \"1\" at the root when warm subagents are enabled (flag or setting). */\nexport const WARM_SUBAGENTS_ENV = \"HOOCODE_WARM_SUBAGENTS\";\n\nlet pool: WarmSubagentPool | undefined;\nlet override: WarmSubagentPool | undefined;\nlet exitHandlerRegistered = false;\nlet latestSkillPaths: string[] = [];\n\n/** Whether warm-subagent dispatch is enabled for this process. */\nexport function warmSubagentsEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env[WARM_SUBAGENTS_ENV] === \"1\";\n}\n\n/**\n * Get the shared warm pool for a working directory, creating it on first use.\n *\n * `availableModels` (the caller's `ModelRegistry.getAvailable()`) is snapshotted\n * on first creation and used to derive default model-category mappings for any\n * tier the user has not explicitly configured.\n */\nexport function getWarmSubagentPool(cwd: string, availableModels: readonly Model<Api>[] = []): WarmSubagentPool {\n\tif (override) return override;\n\tif (!pool) {\n\t\tconst settingsManager = SettingsManager.create(cwd, getAgentDir());\n\t\tconst settings = { ...settingsManager.getGlobalSettings(), ...settingsManager.getProjectSettings() };\n\t\tpool = new WarmSubagentPool(cwd, settings, latestSkillPaths, availableModels);\n\t\tif (!exitHandlerRegistered) {\n\t\t\texitHandlerRegistered = true;\n\t\t\tprocess.once(\"exit\", () => void pool?.dispose());\n\t\t}\n\t}\n\treturn pool;\n}\n\n/** Update the skill paths forwarded to new warm workers (kept in sync with the resource loader). */\nexport function updateWarmSubagentSkillPaths(paths: string[]): void {\n\tlatestSkillPaths = paths;\n\tpool?.updateSkillPaths(paths);\n}\n"]}