From 6dc5815d060e621c58d0b007368cf78487cba8a9 Mon Sep 17 00:00:00 2001 From: dev-miro26 Date: Wed, 18 Mar 2026 08:40:16 +0000 Subject: [PATCH] refactor: update environment variable constants and usage in gateway --- pkg/config/envkeys.go | 4 ++++ pkg/migrate/sources/openclaw/openclaw_handler.go | 10 +++++----- pkg/providers/codex_cli_credentials.go | 10 +++++----- web/backend/api/gateway.go | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/config/envkeys.go b/pkg/config/envkeys.go index 6c160d80e..b04ff19f5 100644 --- a/pkg/config/envkeys.go +++ b/pkg/config/envkeys.go @@ -30,4 +30,8 @@ const ( // Used by the web launcher when spawning the gateway subprocess. // Default: resolved from the same directory as the current executable. EnvBinary = "PICOCLAW_BINARY" + + // EnvGatewayHost overrides the host address for the gateway server. + // Default: "127.0.0.1" + EnvGatewayHost = "PICOCLAW_GATEWAY_HOST" ) diff --git a/pkg/migrate/sources/openclaw/openclaw_handler.go b/pkg/migrate/sources/openclaw/openclaw_handler.go index 006de409e..5e5241268 100644 --- a/pkg/migrate/sources/openclaw/openclaw_handler.go +++ b/pkg/migrate/sources/openclaw/openclaw_handler.go @@ -1,10 +1,5 @@ package openclaw -// OpenclawHomeEnvVar is the environment variable that overrides the source -// openclaw home directory when migrating from openclaw to picoclaw. -// Default: ~/.openclaw -const OpenclawHomeEnvVar = "OPENCLAW_HOME" - import ( "fmt" "os" @@ -15,6 +10,11 @@ import ( "github.com/sipeed/picoclaw/pkg/migrate/internal" ) +// OpenclawHomeEnvVar is the environment variable that overrides the source +// openclaw home directory when migrating from openclaw to picoclaw. +// Default: ~/.openclaw +const OpenclawHomeEnvVar = "OPENCLAW_HOME" + var providerMapping = map[string]string{ "anthropic": "anthropic", "claude": "anthropic", diff --git a/pkg/providers/codex_cli_credentials.go b/pkg/providers/codex_cli_credentials.go index 7d39b6d26..c5b25f040 100644 --- a/pkg/providers/codex_cli_credentials.go +++ b/pkg/providers/codex_cli_credentials.go @@ -1,10 +1,5 @@ package providers -// CodexHomeEnvVar is the environment variable that overrides the Codex CLI -// home directory when resolving the codex auth.json credentials file. -// Default: ~/.codex -const CodexHomeEnvVar = "CODEX_HOME" - import ( "encoding/json" "fmt" @@ -13,6 +8,11 @@ import ( "time" ) +// CodexHomeEnvVar is the environment variable that overrides the Codex CLI +// home directory when resolving the codex auth.json credentials file. +// Default: ~/.codex +const CodexHomeEnvVar = "CODEX_HOME" + // CodexCliAuth represents the ~/.codex/auth.json file structure. type CodexCliAuth struct { Tokens struct { diff --git a/web/backend/api/gateway.go b/web/backend/api/gateway.go index 098e2babe..f454630aa 100644 --- a/web/backend/api/gateway.go +++ b/web/backend/api/gateway.go @@ -387,10 +387,10 @@ func (h *Handler) startGatewayLocked(initialStatus string, existingPid int) (int // GetConfigPath() already reads, so the gateway sub-process uses the same // config file without requiring a --config flag on the gateway subcommand. if h.configPath != "" { - cmd.Env = append(cmd.Env, "PICOCLAW_CONFIG="+h.configPath) + cmd.Env = append(cmd.Env, config.EnvConfig+"="+h.configPath) } if host := h.gatewayHostOverride(); host != "" { - cmd.Env = append(cmd.Env, "PICOCLAW_GATEWAY_HOST="+host) + cmd.Env = append(cmd.Env, config.EnvGatewayHost+"="+host) } stdoutPipe, err := cmd.StdoutPipe()