diff --git a/README.md b/README.md index 796c496..e643504 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,8 @@ The controller also accepts an OpenShell config-file form at `~/.config/openshel Those values are translated into `OPENSHELL_GATEWAY_HOST`, `OPENSHELL_GATEWAY_PORT`, and `OPENSHELL_GATEWAY_URL` for controller-launched OpenShell/NemoClaw child processes. +When the host shell has `HTTP_PROXY`/`HTTPS_PROXY` set, controller-launched OpenShell/NemoClaw commands also augment `NO_PROXY`/`no_proxy` for loopback, container-host aliases, and `inference.local`. This mirrors NemoClaw's current host-subprocess proxy bypass behavior and avoids routing local gateway or managed inference traffic through a workstation proxy. + ## Security Limitations This is not production hardened. diff --git a/app/lib/hostCommands.ts b/app/lib/hostCommands.ts index 9e826ea..ffaff99 100644 --- a/app/lib/hostCommands.ts +++ b/app/lib/hostCommands.ts @@ -124,6 +124,39 @@ function stringConfigValue(value: unknown) { return undefined } +function proxyBypassEnv() { + const hasProxy = Boolean(process.env.HTTP_PROXY || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.https_proxy) + if (!hasProxy) return {} + + const requiredBypasses = [ + "localhost", + "127.0.0.1", + "host.docker.internal", + "host.containers.internal", + "::1", + "0.0.0.0", + "inference.local", + ] + + const extend = (value: string | undefined) => { + const parts = (value || "") + .split(",") + .map((entry) => entry.trim()) + .filter(Boolean) + + for (const host of requiredBypasses) { + if (!parts.includes(host)) parts.push(host) + } + + return parts.join(",") + } + + return { + NO_PROXY: extend(process.env.NO_PROXY), + no_proxy: extend(process.env.no_proxy), + } +} + function readOpenShellGatewayAddressConfig() { const configDir = OPENSHELL_XDG_CONFIG_HOME ? path.join(OPENSHELL_XDG_CONFIG_HOME, "openshell") : "" const candidates = unique([ @@ -173,6 +206,7 @@ export function hostCommandEnv(extra: Record = {}) { ...(OPENSHELL_HOME ? { HOME: OPENSHELL_HOME } : {}), ...(OPENSHELL_XDG_CONFIG_HOME ? { XDG_CONFIG_HOME: OPENSHELL_XDG_CONFIG_HOME } : {}), ...openshellGatewayAddressEnv(), + ...proxyBypassEnv(), PATH: HOST_PATH, NO_COLOR: "1", CLICOLOR: "0", diff --git a/tests/portable-install-check.mjs b/tests/portable-install-check.mjs index 4ddfa8b..a1652d9 100644 --- a/tests/portable-install-check.mjs +++ b/tests/portable-install-check.mjs @@ -75,6 +75,9 @@ assert.match(versionedInstallSource, /NVIDIA_API_KEY="\$\{NVIDIA_API_KEY:-\}"/, assert.match(hostCommandsSource, /export const HOST_PATH/, 'host command resolution must centralize PATH construction') assert.match(hostCommandsSource, /OPENSHELL_CONTROL_VENV/, 'host command resolution must include the installer-managed virtual environment') +assert.match(hostCommandsSource, /function proxyBypassEnv\(\)/, 'host command env must augment NO_PROXY for controller-launched OpenShell/NemoClaw subprocesses') +assert.match(hostCommandsSource, /"inference\.local"/, 'host command env must bypass host HTTP proxies for OpenShell-managed inference.local') +assert.match(hostCommandsSource, /\.\.\.proxyBypassEnv\(\)/, 'host command env must apply proxy bypasses before launching host commands') assert.match(hostCommandsSource, /\.venv\/bin/, 'host command resolution must include the default project virtual environment') assert.match(hostCommandsSource, /\.nemoclaw\/source\/bin\/nemoclaw\.js/, 'host command resolution must support standard ~/.nemoclaw installs') assert.match(hostCommandsSource, /\.nemoclaw\/source\/scripts\/setup\.sh/, 'host command resolution must support legacy ~/.nemoclaw setup workflows')