feat: add gateway env vars option
This commit is contained in:
@@ -204,6 +204,7 @@ All options are set via **Settings → Apps/Add-ons → OpenClaw Assistant → C
|
|||||||
| `enable_openai_api` | bool | `false` | Enable the OpenAI-compatible `/v1/chat/completions` endpoint. Required for [Assist pipeline integration](#6c-assist-pipeline-integration-openai-api) |
|
| `enable_openai_api` | bool | `false` | Enable the OpenAI-compatible `/v1/chat/completions` endpoint. Required for [Assist pipeline integration](#6c-assist-pipeline-integration-openai-api) |
|
||||||
| `allow_insecure_auth` | bool | `false` | Allow HTTP (non-HTTPS) authentication on LAN. **Required** for browser access over plain HTTP |
|
| `allow_insecure_auth` | bool | `false` | Allow HTTP (non-HTTPS) authentication on LAN. **Required** for browser access over plain HTTP |
|
||||||
| `force_ipv4_dns` | bool | `false` | Force IPv4-first DNS ordering for Node network calls. Useful if IPv6 DNS resolves but IPv6 egress is broken (can affect Telegram API polling). |
|
| `force_ipv4_dns` | bool | `false` | Force IPv4-first DNS ordering for Node network calls. Useful if IPv6 DNS resolves but IPv6 egress is broken (can affect Telegram API polling). |
|
||||||
|
| `gateway_env_vars` | map(string) | `{}` | Environment variables exported to the gateway process at startup. Use YAML map format (for example `OPENAI_API_KEY: "sk-..."`). Limits: max 50 vars, key length 255, value length 10000. |
|
||||||
|
|
||||||
### Terminal
|
### Terminal
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
All notable changes to the OpenClaw Assistant Home Assistant Add-on will be documented in this file.
|
All notable changes to the OpenClaw Assistant Home Assistant Add-on will be documented in this file.
|
||||||
|
|
||||||
|
## [0.5.50] - 2026-02-23
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- New add-on option `gateway_env_vars` that accepts a YAML map; values are exported verbatim to the gateway process at startup with limits (50 vars, key ≤255 chars, value ≤10000 chars).
|
||||||
|
|
||||||
## [0.5.49] - 2026-02-22
|
## [0.5.49] - 2026-02-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: OpenClaw Assistant
|
name: OpenClaw Assistant
|
||||||
version: "0.5.49"
|
version: "0.5.50"
|
||||||
slug: openclaw_assistant
|
slug: openclaw_assistant
|
||||||
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
|
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
|
||||||
url: https://github.com/techartdev/OpenClawHomeAssistant
|
url: https://github.com/techartdev/OpenClawHomeAssistant
|
||||||
|
|||||||
@@ -151,17 +151,15 @@ export PATH="${PNPM_HOME}:${PATH}"
|
|||||||
# Export gateway environment variables from add-on config
|
# Export gateway environment variables from add-on config
|
||||||
# These are user-defined variables that should be available to the gateway process
|
# These are user-defined variables that should be available to the gateway process
|
||||||
if [ "$GW_ENV_VARS" != "{}" ] && [ -n "$GW_ENV_VARS" ]; then
|
if [ "$GW_ENV_VARS" != "{}" ] && [ -n "$GW_ENV_VARS" ]; then
|
||||||
|
if printf '%s' "$GW_ENV_VARS" | jq -e 'type == "object"' >/dev/null 2>&1; then
|
||||||
echo "INFO: Setting gateway environment variables from add-on config..."
|
echo "INFO: Setting gateway environment variables from add-on config..."
|
||||||
env_count=0
|
env_count=0
|
||||||
max_env_vars=50
|
max_env_vars=50
|
||||||
max_var_name_size=255
|
max_var_name_size=255
|
||||||
|
max_var_value_size=10000
|
||||||
|
|
||||||
# Parse JSON object and export each key=value pair
|
# Use null-delimited key/value pairs to preserve spaces and special chars.
|
||||||
while IFS='=' read -r key value; do
|
while IFS= read -r -d '' key && IFS= read -r -d '' value; do
|
||||||
# Skip empty lines and trim whitespace
|
|
||||||
key=$(echo "$key" | xargs)
|
|
||||||
value=$(echo "$value" | xargs)
|
|
||||||
|
|
||||||
if [ -z "$key" ]; then
|
if [ -z "$key" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -178,6 +176,12 @@ if [ "$GW_ENV_VARS" != "{}" ] && [ -n "$GW_ENV_VARS" ]; then
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Enforce max variable value length
|
||||||
|
if [ ${#value} -gt $max_var_value_size ]; then
|
||||||
|
echo "WARN: Environment variable value too long for '$key' (max $max_var_value_size chars, skip)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Enforce limit on number of variables
|
# Enforce limit on number of variables
|
||||||
if [ $env_count -ge $max_env_vars ]; then
|
if [ $env_count -ge $max_env_vars ]; then
|
||||||
echo "WARN: Maximum environment variables limit ($max_env_vars) reached (skip)"
|
echo "WARN: Maximum environment variables limit ($max_env_vars) reached (skip)"
|
||||||
@@ -187,11 +191,14 @@ if [ "$GW_ENV_VARS" != "{}" ] && [ -n "$GW_ENV_VARS" ]; then
|
|||||||
export "$key=$value"
|
export "$key=$value"
|
||||||
((env_count++))
|
((env_count++))
|
||||||
echo "INFO: Exported gateway env var: $key"
|
echo "INFO: Exported gateway env var: $key"
|
||||||
done < <(echo "$GW_ENV_VARS" | jq -r 'to_entries[] | "\(.key)=\(.value)"')
|
done < <(printf '%s' "$GW_ENV_VARS" | jq -j 'to_entries[] | .key, "\u0000", (.value | tostring), "\u0000"')
|
||||||
|
|
||||||
if [ $env_count -gt 0 ]; then
|
if [ $env_count -gt 0 ]; then
|
||||||
echo "INFO: Successfully exported $env_count gateway environment variable(s)"
|
echo "INFO: Successfully exported $env_count gateway environment variable(s)"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "WARN: Invalid gateway_env_vars format in add-on options (expected JSON object), skipping"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user