()
| 81 | } |
| 82 | |
| 83 | function _codexConfigExpectsProxy() { |
| 84 | const file = _codexConfigPath(); |
| 85 | if (!file || !fs.existsSync(file)) return false; |
| 86 | let selectedProvider = null; |
| 87 | let section = ''; |
| 88 | const providerUrls = {}; |
| 89 | try { |
| 90 | const content = fs.readFileSync(file, 'utf8'); |
| 91 | for (const line of content.split(/\r?\n/)) { |
| 92 | const clean = _stripTomlComment(line); |
| 93 | if (!clean) continue; |
| 94 | const sectionMatch = clean.match(/^\[([^\]]+)\]$/); |
| 95 | if (sectionMatch) { |
| 96 | section = sectionMatch[1].trim(); |
| 97 | continue; |
| 98 | } |
| 99 | const kv = clean.match(/^([A-Za-z0-9_.-]+)\s*=\s*([\s\S]+)$/); |
| 100 | if (!kv) continue; |
| 101 | const key = kv[1].trim(); |
| 102 | const value = _tomlStringValue(kv[2]); |
| 103 | if (!section && key === 'model_provider') { |
| 104 | selectedProvider = value; |
| 105 | continue; |
| 106 | } |
| 107 | const providerMatch = section.match(/^model_providers\.([A-Za-z0-9_.-]+)$/); |
| 108 | if (providerMatch && key === 'base_url') { |
| 109 | providerUrls[providerMatch[1]] = value; |
| 110 | continue; |
| 111 | } |
| 112 | if (!section && key === 'base_url' && _isLoopbackProxyUrl(value)) return true; |
| 113 | } |
| 114 | } catch { |
| 115 | return false; |
| 116 | } |
| 117 | if (selectedProvider && _isLoopbackProxyUrl(providerUrls[selectedProvider])) return true; |
| 118 | return Object.keys(providerUrls).some(name => |
| 119 | /(?:evomap|proxy)/i.test(name) && _isLoopbackProxyUrl(providerUrls[name]) |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | function _proxyExpected() { |
| 124 | if (String(process.env.EVOMAP_PROXY || '').trim() === '1') return true; |
no test coverage detected