fix: 修复 QQ Bot 配置后 Gateway 无法启动的问题
1. 清除旧版 "agent" 废弃键 — 保存 channel 配置时自动删除旧的 agent 键, 防止 OpenClaw 报 "agent.* was moved" 错误(前端 + 服务端双重防御) 2. Dashboard URL 动态端口探测 — 将硬编码 18789 改为扫描 18789-18799, 解决端口被占用时打不开 Dashboard 的问题 3. 安装脚本配置格式升级 — install.sh / install.ps1 / install-silent.ps1 生成的 openclaw.json 从旧的 "agent" 格式迁移到 "agents.defaults.model.primary" 4. 文档示例同步更新 — CLAUDE.md / cloud.html / guide.html 中的配置示例 影响文件: 14 个(portable/, install/, website/, u-claw-app/, usb-release/) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -520,31 +520,46 @@ if ($hasConfig) {
|
||||
|
||||
# Write config
|
||||
if ($cfg.provider -eq "custom" -and $cfg.baseUrl) {
|
||||
$providerName = "custom"
|
||||
$configJson = @"
|
||||
{
|
||||
"gateway": {
|
||||
"mode": "local",
|
||||
"auth": { "token": "uclaw" }
|
||||
},
|
||||
"agent": {
|
||||
"model": "$($cfg.model)",
|
||||
"apiKey": "$apiKey",
|
||||
"baseUrl": "$($cfg.baseUrl)"
|
||||
}
|
||||
"models": {
|
||||
"mode": "merge",
|
||||
"providers": {
|
||||
"$providerName": {
|
||||
"baseUrl": "$($cfg.baseUrl)",
|
||||
"apiKey": "$apiKey",
|
||||
"api": "openai-completions",
|
||||
"models": [{ "id": "$($cfg.model)" }]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": { "defaults": { "model": { "primary": "$providerName/$($cfg.model)" } } }
|
||||
}
|
||||
"@
|
||||
} else {
|
||||
$providerName = $cfg.provider
|
||||
$configJson = @"
|
||||
{
|
||||
"gateway": {
|
||||
"mode": "local",
|
||||
"auth": { "token": "uclaw" }
|
||||
},
|
||||
"agent": {
|
||||
"model": "$($cfg.model)",
|
||||
"apiKey": "$apiKey",
|
||||
"provider": "$($cfg.provider)"
|
||||
}
|
||||
"models": {
|
||||
"mode": "merge",
|
||||
"providers": {
|
||||
"$providerName": {
|
||||
"apiKey": "$apiKey",
|
||||
"api": "$(if ($providerName -eq 'anthropic') {'anthropic'} else {'openai-completions'})",
|
||||
"models": [{ "id": "$($cfg.model)" }]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": { "defaults": { "model": { "primary": "$providerName/$($cfg.model)" } } }
|
||||
}
|
||||
"@
|
||||
}
|
||||
|
||||
@@ -887,11 +887,18 @@ else
|
||||
"mode": "local",
|
||||
"auth": { "token": "uclaw" }
|
||||
},
|
||||
"agent": {
|
||||
"model": "$MODEL_NAME",
|
||||
"apiKey": "$API_KEY",
|
||||
"baseUrl": "$BASE_URL"
|
||||
}
|
||||
"models": {
|
||||
"mode": "merge",
|
||||
"providers": {
|
||||
"custom": {
|
||||
"baseUrl": "$BASE_URL",
|
||||
"apiKey": "$API_KEY",
|
||||
"api": "openai-completions",
|
||||
"models": [{ "id": "$MODEL_NAME" }]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": { "defaults": { "model": { "primary": "custom/$MODEL_NAME" } } }
|
||||
}
|
||||
CFGEOF
|
||||
elif [ "$PROVIDER" = "anthropic" ]; then
|
||||
@@ -901,11 +908,17 @@ CFGEOF
|
||||
"mode": "local",
|
||||
"auth": { "token": "uclaw" }
|
||||
},
|
||||
"agent": {
|
||||
"model": "$MODEL_NAME",
|
||||
"apiKey": "$API_KEY",
|
||||
"provider": "anthropic"
|
||||
}
|
||||
"models": {
|
||||
"mode": "merge",
|
||||
"providers": {
|
||||
"anthropic": {
|
||||
"apiKey": "$API_KEY",
|
||||
"api": "anthropic",
|
||||
"models": [{ "id": "$MODEL_NAME" }]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": { "defaults": { "model": { "primary": "anthropic/$MODEL_NAME" } } }
|
||||
}
|
||||
CFGEOF
|
||||
elif [ "$PROVIDER" = "openai" ]; then
|
||||
@@ -915,11 +928,17 @@ CFGEOF
|
||||
"mode": "local",
|
||||
"auth": { "token": "uclaw" }
|
||||
},
|
||||
"agent": {
|
||||
"model": "$MODEL_NAME",
|
||||
"apiKey": "$API_KEY",
|
||||
"provider": "openai"
|
||||
}
|
||||
"models": {
|
||||
"mode": "merge",
|
||||
"providers": {
|
||||
"openai": {
|
||||
"apiKey": "$API_KEY",
|
||||
"api": "openai-completions",
|
||||
"models": [{ "id": "$MODEL_NAME" }]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": { "defaults": { "model": { "primary": "openai/$MODEL_NAME" } } }
|
||||
}
|
||||
CFGEOF
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user