紧急修复:mode 字段位置错误导致 Gateway 无法启动 (v0.4.6)

根因:openclaw.json 的 mode 属于 gateway 对象内部,不是顶层字段。
OpenClaw zod-schema 对顶层 mode 报 Unrecognized key 错误。

修复:
- config.rs init_openclaw_config: mode 移入 gateway 对象
- dev-api.js init_openclaw_config: 同上
- dashboard.js 自愈: config.mode → config.gateway.mode
- dashboard.js 自愈: 自动删除旧版错误的顶层 mode 字段
- setup.js 安装流程: config.mode → config.gateway.mode
This commit is contained in:
晴天
2026-03-05 23:41:55 +08:00
parent 8ba25a25e0
commit b4e959ec99
12 changed files with 175 additions and 39 deletions

View File

@@ -79,7 +79,10 @@ async function loadDashboardData(page) {
// 自愈:补全关键默认值
if (config) {
let patched = false
if (!config.mode) { config.mode = 'local'; patched = true }
if (!config.gateway) config.gateway = {}
if (!config.gateway.mode) { config.gateway.mode = 'local'; patched = true }
// 修复旧版错误mode 不应在顶层OpenClaw 不认识)
if (config.mode) { delete config.mode; patched = true }
if (!config.tools || config.tools.profile !== 'full') {
config.tools = { profile: 'full', sessions: { visibility: 'all' }, ...(config.tools || {}) }
config.tools.profile = 'full'

View File

@@ -326,8 +326,9 @@ function bindEvents(page, nodeOk) {
const config = await api.readOpenclawConfig()
if (config) {
let patched = false
if (!config.mode) {
config.mode = 'local'
if (!config.gateway) config.gateway = {}
if (!config.gateway.mode) {
config.gateway.mode = 'local'
patched = true
modal.appendLog('✅ 已设置 Gateway 运行模式为 local')
}