CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
proxy.ts38 linesDownload Raw Back to channel
1import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';2import { normalizeProxyUrl } from '@qwen-code/qwen-code-core';3 4/**5 * Resolve and apply proxy settings for channel service processes.6 *7 * The normal CLI path applies proxy via loadCliConfig -> Config constructor ->8 * setGlobalDispatcher, but channel runtimes do not call loadCliConfig. This9 * mirrors that resolution logic and also returns the resolved URL so channel10 * adapters can configure non-fetch HTTP clients.11 */12export function resolveProxy(13  cliProxy?: string,14  settingsProxy?: string,15): string | undefined {16  const proxyUrl = resolveProxyUrl(cliProxy, settingsProxy);17  if (proxyUrl) {18    setGlobalDispatcher(19      new EnvHttpProxyAgent({ httpProxy: proxyUrl, httpsProxy: proxyUrl }),20    );21  }22  return proxyUrl;23}24 25export function resolveProxyUrl(26  cliProxy?: string,27  settingsProxy?: string,28): string | undefined {29  return normalizeProxyUrl(30    cliProxy ||31      settingsProxy ||32      process.env['HTTPS_PROXY'] ||33      process.env['https_proxy'] ||34      process.env['HTTP_PROXY'] ||35      process.env['http_proxy'],36  );37}38 
basant307/AI_Governance_Project · CoolFace