From c3ba720d0b8cc0a57b00011d298afedd54f168fe Mon Sep 17 00:00:00 2001 From: macm1 Date: Sun, 22 Feb 2026 19:51:17 +0300 Subject: [PATCH] added proxy support --- openclaw_assistant/CHANGELOG.md | 1 + openclaw_assistant/Dockerfile | 3 ++- openclaw_assistant/openclaw-proxy-shim.cjs | 29 ++++++++++++++++++++++ openclaw_assistant/run.sh | 14 +++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 openclaw_assistant/openclaw-proxy-shim.cjs diff --git a/openclaw_assistant/CHANGELOG.md b/openclaw_assistant/CHANGELOG.md index f83f53e..0f6693c 100644 --- a/openclaw_assistant/CHANGELOG.md +++ b/openclaw_assistant/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the OpenClaw Assistant Home Assistant Add-on will be docu ### Changed - Bump OpenClaw to 2026.2.21-2. - Add Home Assistant `share` and `media` mounts to the add-on (`map: share:rw, media:rw`). +- Keep official OpenClaw npm release and add startup proxy shim for `HTTP_PROXY/HTTPS_PROXY` support in undici fetch. ## [0.5.47] - 2026-02-21 diff --git a/openclaw_assistant/Dockerfile b/openclaw_assistant/Dockerfile index 94b8382..74ee807 100644 --- a/openclaw_assistant/Dockerfile +++ b/openclaw_assistant/Dockerfile @@ -100,7 +100,7 @@ RUN if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then \ fi USER root -# Install OpenClaw globally +# Install OpenClaw globally (official npm release) RUN npm config set fund false && npm config set audit false \ && npm install -g openclaw@2026.2.21-2 @@ -124,6 +124,7 @@ fi EOF COPY run.sh /run.sh COPY oc_config_helper.py /oc_config_helper.py +COPY openclaw-proxy-shim.cjs /usr/local/lib/openclaw-proxy-shim.cjs COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl COPY landing.html.tpl /etc/nginx/landing.html.tpl RUN chmod +x /run.sh /oc_config_helper.py \ diff --git a/openclaw_assistant/openclaw-proxy-shim.cjs b/openclaw_assistant/openclaw-proxy-shim.cjs new file mode 100644 index 0000000..ee5d463 --- /dev/null +++ b/openclaw_assistant/openclaw-proxy-shim.cjs @@ -0,0 +1,29 @@ +"use strict"; + +/** + * Enable HTTP(S) proxy support for Node/undici before OpenClaw initializes. + * We load undici from OpenClaw's own node_modules path to avoid relying on + * global module resolution from this shim's location. + */ +(function applyProxyFromEnv() { + const hasProxyEnv = + !!process.env.HTTPS_PROXY || + !!process.env.HTTP_PROXY || + !!process.env.https_proxy || + !!process.env.http_proxy; + + if (!hasProxyEnv) { + return; + } + + try { + const path = require("node:path"); + const globalModulesRoot = + process.env.OPENCLAW_GLOBAL_NODE_MODULES || "/usr/lib/node_modules"; + const undiciPath = path.join(globalModulesRoot, "openclaw", "node_modules", "undici"); + const { EnvHttpProxyAgent, setGlobalDispatcher } = require(undiciPath); + setGlobalDispatcher(new EnvHttpProxyAgent()); + } catch (_err) { + // Keep startup resilient if module layout changes in future releases. + } +})(); diff --git a/openclaw_assistant/run.sh b/openclaw_assistant/run.sh index 3f259a9..c017d65 100644 --- a/openclaw_assistant/run.sh +++ b/openclaw_assistant/run.sh @@ -347,6 +347,20 @@ else echo "INFO: Run 'openclaw onboard' first, then restart the add-on" fi +# ------------------------------------------------------------------------------ +# Proxy shim for undici/OpenClaw startup +# Keep official OpenClaw npm release while enabling HTTP(S)_PROXY support. +# ------------------------------------------------------------------------------ +OPENCLAW_GLOBAL_NODE_MODULES="$(HOME=/root npm root -g 2>/dev/null || true)" +if [ -f /usr/local/lib/openclaw-proxy-shim.cjs ]; then + if [ -n "${NODE_OPTIONS:-}" ]; then + export NODE_OPTIONS="--require /usr/local/lib/openclaw-proxy-shim.cjs ${NODE_OPTIONS}" + else + export NODE_OPTIONS="--require /usr/local/lib/openclaw-proxy-shim.cjs" + fi + export OPENCLAW_GLOBAL_NODE_MODULES +fi + echo "Starting OpenClaw Assistant gateway (openclaw)..." openclaw gateway run & GW_PID=$!