fix: enable proxy support to resolve (#1125)
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Pre-commit / pre-commit (push) Waiting to run
Test / Run Python Tests (push) Waiting to run

Co-authored-by: a7m-1st <Ahmed.jimi.awelkeir500@gmail.com>
Co-authored-by: Ahmed Awelkair A <108264625+a7m-1st@users.noreply.github.com>
This commit is contained in:
BitToby 2026-02-11 08:04:17 -03:00 committed by GitHub
parent ad44e59485
commit 53d88308df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 483 additions and 67 deletions

View file

@ -18,6 +18,7 @@ import log from 'electron-log';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { maskProxyUrl, readEnvValueWithPriority } from './envUtil';
export function getResourcePath() {
return path.join(app.getAppPath(), 'resources');
@ -33,6 +34,69 @@ export function getBackendPath() {
}
}
/**
* Get proxy environment variables with priority:
* 1. Process environment variables (inline/system)
* 2. .env.development file (development mode only)
* 3. Global ~/.eigent/.env config
*
* Returns an object with HTTP_PROXY, HTTPS_PROXY, NO_PROXY and lowercase variants
* if a proxy is configured, or an empty object if not.
* Supports separate HTTP and HTTPS proxy configurations.
*/
function getProxyEnvVars(): Record<string, string> {
// Check both uppercase and lowercase variants
const httpProxy =
readEnvValueWithPriority('HTTP_PROXY') ||
readEnvValueWithPriority('http_proxy');
const httpsProxy =
readEnvValueWithPriority('HTTPS_PROXY') ||
readEnvValueWithPriority('https_proxy');
// Return empty object if no proxy configured
if (!httpProxy && !httpsProxy) {
return {};
}
// Log configured proxies
if (httpProxy) {
log.info(
`[INSTALL SCRIPT] HTTP Proxy configured: ${maskProxyUrl(httpProxy)}`
);
}
if (httpsProxy) {
log.info(
`[INSTALL SCRIPT] HTTPS Proxy configured: ${maskProxyUrl(httpsProxy)}`
);
}
// Get NO_PROXY configuration (with default for local connections)
const noProxy = readEnvValueWithPriority('NO_PROXY') ||
readEnvValueWithPriority('no_proxy') ||
'localhost,127.0.0.1,.local';
// Return all variants (some tools need uppercase, others lowercase)
// Filter out undefined values
const result: Record<string, string> = {};
if (httpProxy) {
result.HTTP_PROXY = httpProxy;
result.http_proxy = httpProxy;
}
if (httpsProxy) {
result.HTTPS_PROXY = httpsProxy;
result.https_proxy = httpsProxy;
}
// Always set NO_PROXY when proxy is configured to avoid issues with local connections
result.NO_PROXY = noProxy;
result.no_proxy = noProxy;
return result;
}
export function runInstallScript(scriptPath: string): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
const installScriptPath = path.join(
@ -42,8 +106,15 @@ export function runInstallScript(scriptPath: string): Promise<boolean> {
);
log.info(`Running script at: ${installScriptPath}`);
// Get proxy configuration from global .env file
const proxyEnv = getProxyEnvVars();
const nodeProcess = spawn(process.execPath, [installScriptPath], {
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
env: {
...process.env,
...proxyEnv,
ELECTRON_RUN_AS_NODE: '1',
},
});
let stderrOutput = '';