修复字段

This commit is contained in:
user123
2026-01-30 18:41:42 +08:00
parent a965a0d773
commit 1b31743d79
4 changed files with 37 additions and 8 deletions

View File

@@ -161,10 +161,11 @@ configure_openclaw() {
cat > "${CONFIG_FILE}" <<EOF cat > "${CONFIG_FILE}" <<EOF
{ {
"gateway": { "gateway": {
"mode": "token", "mode": "local",
"bind": "loopback", "bind": "loopback",
"port": 18789, "port": 18789,
"auth": { "auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}" "token": "${GATEWAY_TOKEN}"
} }
}, },
@@ -205,10 +206,11 @@ EOF
cat > "${CONFIG_FILE}" <<EOF cat > "${CONFIG_FILE}" <<EOF
{ {
"gateway": { "gateway": {
"mode": "token", "mode": "local",
"bind": "loopback", "bind": "loopback",
"port": 18789, "port": 18789,
"auth": { "auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}" "token": "${GATEWAY_TOKEN}"
} }
}, },

View File

@@ -130,6 +130,14 @@ configure_openclaw() {
fi fi
log_info "开始配置 OpenClaw..." log_info "开始配置 OpenClaw..."
mkdir -p "${CONFIG_DIR}" mkdir -p "${CONFIG_DIR}"
# 生成随机 Token
if command -v openssl >/dev/null 2>&1; then
GATEWAY_TOKEN=$(openssl rand -hex 16)
else
GATEWAY_TOKEN=$(date +%s%N | sha256sum | head -c 32)
fi
echo -e "${CYAN}请选择 API 类型:${PLAIN}" echo -e "${CYAN}请选择 API 类型:${PLAIN}"
echo "1. Anthropic 官方 API" echo "1. Anthropic 官方 API"
echo "2. OpenAI 兼容 API (中转站/其他模型)" echo "2. OpenAI 兼容 API (中转站/其他模型)"
@@ -149,7 +157,11 @@ configure_openclaw() {
"gateway": { "gateway": {
"mode": "local", "mode": "local",
"bind": "loopback", "bind": "loopback",
"port": 18789 "port": 18789,
"auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}"
}
}, },
"env": { "env": {
"ANTHROPIC_API_KEY": "${api_key}" "ANTHROPIC_API_KEY": "${api_key}"
@@ -186,7 +198,11 @@ EOF
"gateway": { "gateway": {
"mode": "local", "mode": "local",
"bind": "loopback", "bind": "loopback",
"port": 18789 "port": 18789,
"auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}"
}
}, },
"env": { "env": {
"ANTHROPIC_API_KEY": "${api_key}" "ANTHROPIC_API_KEY": "${api_key}"
@@ -222,7 +238,11 @@ EOF
"gateway": { "gateway": {
"mode": "local", "mode": "local",
"bind": "loopback", "bind": "loopback",
"port": 18789 "port": 18789,
"auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}"
}
}, },
"agents": { "agents": {
"defaults": { "defaults": {
@@ -283,7 +303,11 @@ EOF
"gateway": { "gateway": {
"mode": "local", "mode": "local",
"bind": "loopback", "bind": "loopback",
"port": 18789 "port": 18789,
"auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}"
}
}, },
"agents": { "agents": {
"defaults": { "defaults": {
@@ -335,7 +359,9 @@ EOF
fi fi
fi fi
log_info "配置文件已生成: ${CONFIG_FILE}" log_info "配置文件已生成: ${CONFIG_FILE}"
log_info "配置文件绝对路径: ${CONFIG_FILE}" echo -e "${GREEN}配置文件绝对路径: ${CONFIG_FILE}${PLAIN}"
echo -e "${GREEN}Gateway Token: ${GATEWAY_TOKEN}${PLAIN}"
echo -e "${YELLOW}请妥善保存此 Token用于远程连接 Gateway。${PLAIN}"
} }
setup_launchd() { setup_launchd() {

Binary file not shown.

View File

@@ -945,10 +945,11 @@ func GenerateAndWriteConfig(opts ConfigOptions) error {
config := OpenclawConfig{ config := OpenclawConfig{
Gateway: GatewayConfig{ Gateway: GatewayConfig{
Mode: "token", Mode: "local",
Bind: "loopback", Bind: "loopback",
Port: 18789, Port: 18789,
Auth: &AuthConfig{ Auth: &AuthConfig{
Mode: "token",
Token: token, Token: token,
}, },
}, },