feat(v2.1.2): align with ClawX schema + config-server port fallback

Three changes for v2.1.2:

1. bootstrap-xiapan now writes "agents.defaults.model.primary/fallbacks"
   (uclaw-cloud/deepseek-v4-flash + 3 fallbacks) and an empty models[],
   matching the ClawX commercial schema. Lets OpenClaw runtime auto-discover
   models from /v1/models instead of hard-coding a list that drifts.

2. config-server tries ports 18788..18798 with EADDRINUSE fallback and
   persists the live port to data/.openclaw/runtime.json so future tooling
   can discover it. Fixes silent failure when a second portable instance
   started while 18788 was occupied.

3. u-claw-app/package.json version 2.0.0 -> 2.1.2 so .exe/.dmg filenames
   align with the release tag.
This commit is contained in:
hfshfg
2026-05-03 00:07:09 +08:00
parent 1f8224561b
commit cc2984234b
4 changed files with 130 additions and 21 deletions

View File

@@ -5,8 +5,10 @@ const path = require('path');
const { deflateSync } = require('zlib');
const crypto = require('crypto');
const PORT = 18788;
const PORT_RANGE_START = 18788;
const PORT_RANGE_END = 18798;
const CONFIG_PATH = path.join(__dirname, '../data/.openclaw/openclaw.json');
const RUNTIME_PATH = path.join(__dirname, '../data/.openclaw/runtime.json');
// ── WeChat Login State ──────────────────────────────────────────────────────
const DEFAULT_WECHAT_BASE_URL = 'https://ilinkai.weixin.qq.com';
@@ -500,8 +502,31 @@ const server = http.createServer((req, res) => {
}
});
server.listen(PORT, '127.0.0.1', () => {
console.log(`\n🦞 U-Claw Config Center`);
console.log(` http://127.0.0.1:${PORT}`);
console.log(`\n Config file: ${CONFIG_PATH}\n`);
});
function listenWithFallback(port) {
server.once('error', (err) => {
if (err && err.code === 'EADDRINUSE' && port < PORT_RANGE_END) {
console.log(` Port ${port} busy, trying ${port + 1}`);
setImmediate(() => listenWithFallback(port + 1));
return;
}
console.error(`Config server failed to bind: ${err && err.message ? err.message : err}`);
process.exit(1);
});
server.listen(port, '127.0.0.1', () => {
console.log(`\n🦞 U-Claw Config Center`);
console.log(` http://127.0.0.1:${port}`);
console.log(`\n Config file: ${CONFIG_PATH}\n`);
// Persist the live port so Config.html / launchers can discover it after restarts.
try {
fs.mkdirSync(path.dirname(RUNTIME_PATH), { recursive: true });
const existing = fs.existsSync(RUNTIME_PATH) ? JSON.parse(fs.readFileSync(RUNTIME_PATH, 'utf8')) : {};
existing.configServerPort = port;
existing.configServerUpdatedAt = new Date().toISOString();
fs.writeFileSync(RUNTIME_PATH, JSON.stringify(existing, null, 2));
} catch (err) {
console.warn(` Warning: could not write ${RUNTIME_PATH}: ${err.message}`);
}
});
}
listenWithFallback(PORT_RANGE_START);