Skip to content

Commit 642d1bf

Browse files
committed
fix: move baseUrl fix before openclaw plugins install, bump v0.12.100
The baseUrl/apiKey repair must run BEFORE `openclaw plugins install` because the install command validates the config and fails if baseUrl is undefined. Moved the fix to run right after config cleanup in both update.sh and reinstall.sh.
1 parent 81152fc commit 642d1bf

3 files changed

Lines changed: 68 additions & 91 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blockrun/clawrouter",
3-
"version": "0.12.99",
3+
"version": "0.12.100",
44
"description": "Smart LLM router — save 85% on inference costs. 55+ models (11 free), one wallet, x402 micropayments.",
55
"type": "module",
66
"main": "dist/index.js",

scripts/reinstall.sh

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,52 @@ if (fs.existsSync(configPath)) {
256256
}
257257
"
258258

259+
# 5b. Ensure provider baseUrl is set (must happen BEFORE openclaw plugins install,
260+
# which validates the config and fails if baseUrl is missing)
261+
echo "→ Verifying provider config..."
262+
node -e "
263+
const os = require('os');
264+
const fs = require('fs');
265+
const path = require('path');
266+
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
267+
268+
if (!fs.existsSync(configPath)) {
269+
console.log(' No config file found, skipping');
270+
process.exit(0);
271+
}
272+
273+
try {
274+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
275+
const provider = config?.models?.providers?.blockrun;
276+
if (!provider) {
277+
console.log(' No blockrun provider found, skipping');
278+
process.exit(0);
279+
}
280+
281+
let changed = false;
282+
if (!provider.baseUrl) {
283+
provider.baseUrl = 'http://127.0.0.1:8402/v1';
284+
changed = true;
285+
console.log(' Fixed missing baseUrl');
286+
}
287+
if (!provider.apiKey) {
288+
provider.apiKey = 'x402-proxy-handles-auth';
289+
changed = true;
290+
console.log(' Fixed missing apiKey');
291+
}
292+
293+
if (changed) {
294+
const tmpPath = configPath + '.tmp.' + process.pid;
295+
fs.writeFileSync(tmpPath, JSON.stringify(config, null, 2));
296+
fs.renameSync(tmpPath, configPath);
297+
} else {
298+
console.log(' Provider config OK');
299+
}
300+
} catch (err) {
301+
console.log(' Skipped: ' + err.message);
302+
}
303+
"
304+
259305
# 6. Install plugin (config is ready, but no allow list yet to avoid validation error)
260306
# Back up OpenClaw credentials (channels, WhatsApp/Telegram state) before plugin install
261307
CREDS_DIR="$HOME/.openclaw/credentials"
@@ -437,51 +483,6 @@ if (fs.existsSync(configPath)) {
437483
}
438484
"
439485

440-
# 8. Ensure provider baseUrl is set (prevents "baseUrl: undefined" on gateway restart)
441-
echo "→ Verifying provider config..."
442-
node -e "
443-
const os = require('os');
444-
const fs = require('fs');
445-
const path = require('path');
446-
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
447-
448-
if (!fs.existsSync(configPath)) {
449-
console.log(' No config file found, skipping');
450-
process.exit(0);
451-
}
452-
453-
try {
454-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
455-
const provider = config?.models?.providers?.blockrun;
456-
if (!provider) {
457-
console.log(' No blockrun provider found, skipping');
458-
process.exit(0);
459-
}
460-
461-
let changed = false;
462-
if (!provider.baseUrl) {
463-
provider.baseUrl = 'http://127.0.0.1:8402/v1';
464-
changed = true;
465-
console.log(' Fixed missing baseUrl');
466-
}
467-
if (!provider.apiKey) {
468-
provider.apiKey = 'x402-proxy-handles-auth';
469-
changed = true;
470-
console.log(' Fixed missing apiKey');
471-
}
472-
473-
if (changed) {
474-
const tmpPath = configPath + '.tmp.' + process.pid;
475-
fs.writeFileSync(tmpPath, JSON.stringify(config, null, 2));
476-
fs.renameSync(tmpPath, configPath);
477-
} else {
478-
console.log(' Provider config OK');
479-
}
480-
} catch (err) {
481-
console.log(' Skipped: ' + err.message);
482-
}
483-
"
484-
485486
# Final: verify wallet survived reinstall
486487
echo "→ Verifying wallet integrity..."
487488
if [ -f "$WALLET_FILE" ]; then

scripts/update.sh

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,27 @@ try {
169169
}
170170
"
171171

172+
# ── Step 3b: Ensure baseUrl is set (must happen BEFORE install, which validates config) ──
173+
echo "→ Verifying provider config..."
174+
node -e "
175+
const fs = require('fs');
176+
const configPath = '$CONFIG_PATH';
177+
if (!fs.existsSync(configPath)) { console.log(' No config, skipping'); process.exit(0); }
178+
try {
179+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
180+
const provider = config?.models?.providers?.blockrun;
181+
if (!provider) { console.log(' No blockrun provider, skipping'); process.exit(0); }
182+
let changed = false;
183+
if (!provider.baseUrl) { provider.baseUrl = 'http://127.0.0.1:8402/v1'; changed = true; console.log(' Fixed missing baseUrl'); }
184+
if (!provider.apiKey) { provider.apiKey = 'x402-proxy-handles-auth'; changed = true; console.log(' Fixed missing apiKey'); }
185+
if (changed) {
186+
const tmp = configPath + '.tmp.' + process.pid;
187+
fs.writeFileSync(tmp, JSON.stringify(config, null, 2));
188+
fs.renameSync(tmp, configPath);
189+
} else { console.log(' Provider config OK'); }
190+
} catch (err) { console.log(' Skipped: ' + err.message); }
191+
"
192+
172193
# ── Step 4: Install latest version ─────────────────────────────
173194
# Back up OpenClaw credentials (channels, WhatsApp/Telegram state) before plugin install
174195
CREDS_DIR="$HOME/.openclaw/credentials"
@@ -350,51 +371,6 @@ try {
350371
}
351372
"
352373

353-
# ── Step 9: Ensure baseUrl is set ─────────────────────────────
354-
echo "→ Verifying provider config..."
355-
node -e "
356-
const os = require('os');
357-
const fs = require('fs');
358-
const path = require('path');
359-
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
360-
361-
if (!fs.existsSync(configPath)) {
362-
console.log(' No config file found, skipping');
363-
process.exit(0);
364-
}
365-
366-
try {
367-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
368-
const provider = config?.models?.providers?.blockrun;
369-
if (!provider) {
370-
console.log(' No blockrun provider found, skipping');
371-
process.exit(0);
372-
}
373-
374-
let changed = false;
375-
if (!provider.baseUrl) {
376-
provider.baseUrl = 'http://127.0.0.1:8402/v1';
377-
changed = true;
378-
console.log(' Fixed missing baseUrl');
379-
}
380-
if (!provider.apiKey) {
381-
provider.apiKey = 'x402-proxy-handles-auth';
382-
changed = true;
383-
console.log(' Fixed missing apiKey');
384-
}
385-
386-
if (changed) {
387-
const tmpPath = configPath + '.tmp.' + process.pid;
388-
fs.writeFileSync(tmpPath, JSON.stringify(config, null, 2));
389-
fs.renameSync(tmpPath, configPath);
390-
} else {
391-
console.log(' Provider config OK');
392-
}
393-
} catch (err) {
394-
console.log(' Skipped: ' + err.message);
395-
}
396-
"
397-
398374
# ── Summary ─────────────────────────────────────────────────────
399375
echo ""
400376
echo "✓ ClawRouter updated successfully!"

0 commit comments

Comments
 (0)