refactor: update environment variable constants and usage in gateway
This commit is contained in:
parent
9a9c236537
commit
6dc5815d06
4 changed files with 16 additions and 12 deletions
|
|
@ -30,4 +30,8 @@ const (
|
||||||
// Used by the web launcher when spawning the gateway subprocess.
|
// Used by the web launcher when spawning the gateway subprocess.
|
||||||
// Default: resolved from the same directory as the current executable.
|
// Default: resolved from the same directory as the current executable.
|
||||||
EnvBinary = "PICOCLAW_BINARY"
|
EnvBinary = "PICOCLAW_BINARY"
|
||||||
|
|
||||||
|
// EnvGatewayHost overrides the host address for the gateway server.
|
||||||
|
// Default: "127.0.0.1"
|
||||||
|
EnvGatewayHost = "PICOCLAW_GATEWAY_HOST"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
package openclaw
|
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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -15,6 +10,11 @@ import (
|
||||||
"github.com/sipeed/picoclaw/pkg/migrate/internal"
|
"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{
|
var providerMapping = map[string]string{
|
||||||
"anthropic": "anthropic",
|
"anthropic": "anthropic",
|
||||||
"claude": "anthropic",
|
"claude": "anthropic",
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
package providers
|
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 (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -13,6 +8,11 @@ import (
|
||||||
"time"
|
"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.
|
// CodexCliAuth represents the ~/.codex/auth.json file structure.
|
||||||
type CodexCliAuth struct {
|
type CodexCliAuth struct {
|
||||||
Tokens struct {
|
Tokens struct {
|
||||||
|
|
|
||||||
|
|
@ -387,10 +387,10 @@ func (h *Handler) startGatewayLocked(initialStatus string, existingPid int) (int
|
||||||
// GetConfigPath() already reads, so the gateway sub-process uses the same
|
// GetConfigPath() already reads, so the gateway sub-process uses the same
|
||||||
// config file without requiring a --config flag on the gateway subcommand.
|
// config file without requiring a --config flag on the gateway subcommand.
|
||||||
if h.configPath != "" {
|
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 != "" {
|
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()
|
stdoutPipe, err := cmd.StdoutPipe()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue