{"version":3,"file":"provider-env-C72pF4vP.mjs","names":[],"sources":["../node_modules/.pnpm/@earendil-works+pi-ai@0.84.1_ws@8.21.3_zod@4.4.3/node_modules/@earendil-works/pi-ai/dist/utils/provider-env.js"],"sourcesContent":["let procEnvCache = null;\n/**\n * Fallback for https://github.com/oven-sh/bun/issues/27802.\n * Bun compiled binaries can expose an empty process.env inside Linux sandboxes\n * even though /proc/self/environ contains the environment.\n *\n * This intentionally duplicates restoreSandboxEnv() in\n * packages/coding-agent/src/bun/restore-sandbox-env.ts. The ai package can be\n * used directly, without going through that entrypoint, so provider env lookup\n * must not depend on process.env having been patched.\n */\nfunction getBunSandboxEnvValue(name) {\n    if (typeof process === \"undefined\" || !process.versions?.bun || Object.keys(process.env).length > 0) {\n        return undefined;\n    }\n    if (procEnvCache === null) {\n        procEnvCache = new Map();\n        try {\n            const { readFileSync } = require(\"node:fs\");\n            const data = readFileSync(\"/proc/self/environ\", \"utf-8\");\n            for (const entry of data.split(\"\\0\")) {\n                const idx = entry.indexOf(\"=\");\n                if (idx > 0) {\n                    procEnvCache.set(entry.slice(0, idx), entry.slice(idx + 1));\n                }\n            }\n        }\n        catch {\n            // /proc/self/environ may not exist or may not be readable.\n        }\n    }\n    return procEnvCache.get(name);\n}\n/**\n * Resolve a provider env value from scoped overrides, normal process.env, then\n * the duplicated Bun sandbox fallback for direct pi-ai consumers.\n */\nexport function getProviderEnvValue(name, env) {\n    return (env?.[name] ||\n        (typeof process !== \"undefined\" ? process.env[name] : undefined) ||\n        getBunSandboxEnvValue(name) ||\n        undefined);\n}\n//# sourceMappingURL=provider-env.js.map"],"x_google_ignoreList":[0],"mappings":";;;AAAA,IAAI,eAAe;;;;;;;;;;;AAWnB,SAAS,sBAAsB,MAAM;CACjC,IAAI,OAAO,YAAY,eAAe,CAAC,QAAQ,UAAU,OAAO,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,SAAS,GAC9F;CAEJ,IAAI,iBAAiB,MAAM;EACvB,+BAAe,IAAI,IAAI;EACvB,IAAI;GACA,MAAM,EAAE,iBAAA,UAAyB,SAAS;GAC1C,MAAM,OAAO,aAAa,sBAAsB,OAAO;GACvD,KAAK,MAAM,SAAS,KAAK,MAAM,IAAI,GAAG;IAClC,MAAM,MAAM,MAAM,QAAQ,GAAG;IAC7B,IAAI,MAAM,GACN,aAAa,IAAI,MAAM,MAAM,GAAG,GAAG,GAAG,MAAM,MAAM,MAAM,CAAC,CAAC;GAElE;EACJ,QACM,CAEN;CACJ;CACA,OAAO,aAAa,IAAI,IAAI;AAChC;;;;;AAKA,SAAgB,oBAAoB,MAAM,KAAK;CAC3C,OAAQ,MAAM,UACT,OAAO,YAAY,cAAc,QAAQ,IAAI,QAAQ,KAAA,MACtD,sBAAsB,IAAI,KAC1B,KAAA;AACR"}