diff --git a/lib/client.js b/lib/client.js index c30a510..3da76e8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -391,6 +391,25 @@ class ClawClient { led.status.setApps(); led.display.showTime(); log.info('clawd', `已激活 claw_id = ${this._cfg.claw_id}`); + this._configureOpenClaw(this._cfg.claw_id); + } + } + + // ── OpenClaw 配置 ──────────────────────────────────────────────────────────── + + _configureOpenClaw(clawId) { + try { + const origins = JSON.stringify([ + 'http://0.0.0.0:18789', + `https://${clawId}.claw.cutos.ai`, + ]); + execFileSync('openclaw', ['config', 'set', 'gateway.controlUi.allowedOrigins', origins], { + timeout: 5000, + stdio: 'ignore', + }); + log.info('clawd', `openclaw allowedOrigins 已配置: ${clawId}.claw.cutos.ai`); + } catch (e) { + log.warn('clawd', `openclaw 配置失败(可能未安装): ${e.message}`); } }