{"version":3,"file":"wait-config.d.ts","sourceRoot":"","sources":["../../../../src/runs/background/wait-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,OAAO,CAAC;CACjB;AAyBD,wBAAgB,qBAAqB,CACpC,MAAM,CAAC,EAAE,cAAc,EACvB,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACnD,sBAAsB,CAIxB","sourcesContent":["import type { WaitToolConfig } from \"../../shared/types.ts\";\n\nexport const WAIT_TOOL_ENABLED_ENV = \"PI_SUBAGENT_WAIT_TOOL_ENABLED\";\n\nexport interface ResolvedWaitToolConfig {\n\tenabled: boolean;\n}\n\nconst TRUE_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\", \"enabled\"]);\nconst FALSE_VALUES = new Set([\"0\", \"false\", \"no\", \"off\", \"disabled\"]);\n\nfunction environmentValue(value: string | undefined): boolean | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = value.trim().toLowerCase();\n\tif (TRUE_VALUES.has(normalized)) return true;\n\tif (FALSE_VALUES.has(normalized)) return false;\n\tthrow new Error(`${WAIT_TOOL_ENABLED_ENV} must be one of true/false, 1/0, yes/no, on/off, or enabled/disabled.`);\n}\n\nfunction configuredValue(config: unknown): boolean | undefined {\n\tif (config === undefined) return undefined;\n\tif (typeof config === \"boolean\") return config;\n\tif (!config || typeof config !== \"object\" || Array.isArray(config)) {\n\t\tthrow new Error(\"config.waitTool must be a boolean or an object with optional enabled boolean.\");\n\t}\n\tconst enabled = (config as { enabled?: unknown }).enabled;\n\tif (enabled === undefined) return undefined;\n\tif (typeof enabled !== \"boolean\") throw new Error(\"config.waitTool.enabled must be a boolean.\");\n\treturn enabled;\n}\n\nexport function resolveWaitToolConfig(\n\tconfig?: WaitToolConfig,\n\tenv: Record<string, string | undefined> = process.env,\n): ResolvedWaitToolConfig {\n\treturn {\n\t\tenabled: environmentValue(env[WAIT_TOOL_ENABLED_ENV]) ?? configuredValue(config) ?? true,\n\t};\n}\n"]}