@blockrun/clawrouter 0.12.103 → 0.12.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.103",
3
+ "version": "0.12.104",
4
4
  "description": "Smart LLM router — save 85% on inference costs. 55+ models (11 free), one wallet, x402 micropayments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -323,22 +323,58 @@ if [ -n "$CREDS_BACKUP" ] && [ -d "$CREDS_BACKUP" ]; then
323
323
  rm -rf "$(dirname "$CREDS_BACKUP")"
324
324
  fi
325
325
 
326
- # 6.1. Verify installation (check dist/ files exist)
326
+ # 6.1. Verify installation and force-update if openclaw installed a stale cached version
327
327
  echo "→ Verifying installation..."
328
328
  DIST_PATH="$PLUGIN_DIR/dist/index.js"
329
- if [ ! -f "$DIST_PATH" ]; then
330
- echo " ⚠️ dist/ files missing, clearing npm cache and retrying..."
331
- npm cache clean --force 2>/dev/null || true
332
- rm -rf "$PLUGIN_DIR"
333
- openclaw plugins install @blockrun/clawrouter
334
329
 
330
+ force_install_from_npm() {
331
+ local version="$1"
332
+ echo " → Force-fetching v${version} directly from npm registry..."
333
+ local TMPPACK
334
+ TMPPACK=$(mktemp -d)
335
+ if npm pack "@blockrun/clawrouter@${version}" --pack-destination "$TMPPACK" --prefer-online >/dev/null 2>&1; then
336
+ local TARBALL
337
+ TARBALL=$(ls "$TMPPACK"/blockrun-clawrouter-*.tgz 2>/dev/null | head -1)
338
+ if [ -n "$TARBALL" ]; then
339
+ rm -rf "$PLUGIN_DIR"
340
+ mkdir -p "$PLUGIN_DIR"
341
+ tar -xzf "$TARBALL" -C "$PLUGIN_DIR" --strip-components=1
342
+ rm -rf "$TMPPACK"
343
+ echo " ✓ Force-installed v${version} from npm registry"
344
+ return 0
345
+ fi
346
+ fi
347
+ rm -rf "$TMPPACK"
348
+ echo " ✗ Force install failed"
349
+ return 1
350
+ }
351
+
352
+ if [ ! -f "$DIST_PATH" ]; then
353
+ echo " ⚠️ dist/ files missing — openclaw install may have cached an old version"
354
+ LATEST_VER=$(npm view @blockrun/clawrouter@latest version 2>/dev/null || echo "")
355
+ if [ -n "$LATEST_VER" ]; then
356
+ force_install_from_npm "$LATEST_VER" || exit 1
357
+ else
358
+ echo " ❌ Cannot determine latest version — check npm registry connection"
359
+ exit 1
360
+ fi
335
361
  if [ ! -f "$DIST_PATH" ]; then
336
362
  echo " ❌ Installation failed - dist/index.js still missing"
337
363
  echo " Please report this issue at https://github.com/BlockRunAI/ClawRouter/issues"
338
364
  exit 1
339
365
  fi
366
+ else
367
+ # dist/ exists — verify we have the latest version (openclaw may have served cached old version)
368
+ INSTALLED_VER=$(node -e "try{const p=require('$PLUGIN_DIR/package.json');console.log(p.version);}catch{console.log('');}" 2>/dev/null || echo "")
369
+ LATEST_VER=$(npm view @blockrun/clawrouter@latest version 2>/dev/null || echo "")
370
+ if [ -n "$LATEST_VER" ] && [ -n "$INSTALLED_VER" ] && [ "$INSTALLED_VER" != "$LATEST_VER" ]; then
371
+ echo " ⚠️ openclaw installed v${INSTALLED_VER} (cached) but latest is v${LATEST_VER}"
372
+ force_install_from_npm "$LATEST_VER" || true
373
+ fi
340
374
  fi
341
- echo " ✓ dist/index.js verified"
375
+
376
+ INSTALLED_VER=$(node -e "try{const p=require('$PLUGIN_DIR/package.json');console.log(p.version);}catch{console.log('?');}" 2>/dev/null || echo "?")
377
+ echo " ✓ ClawRouter v${INSTALLED_VER} installed"
342
378
 
343
379
  # 6.1b. Ensure all dependencies are installed (Solana, x402, etc.)
344
380
  # openclaw's plugin installer may skip native deps like @solana/kit.
package/scripts/update.sh CHANGED
@@ -211,7 +211,41 @@ if [ -n "$CREDS_BACKUP" ] && [ -d "$CREDS_BACKUP" ]; then
211
211
  rm -rf "$(dirname "$CREDS_BACKUP")"
212
212
  fi
213
213
 
214
- # ── Step 4b: Ensure all dependencies are installed ────────────
214
+ # ── Step 4b: Verify version — force-update if openclaw served a stale cache ──
215
+ force_install_from_npm() {
216
+ local version="$1"
217
+ echo " → Force-fetching v${version} directly from npm registry..."
218
+ local TMPPACK
219
+ TMPPACK=$(mktemp -d)
220
+ if npm pack "@blockrun/clawrouter@${version}" --pack-destination "$TMPPACK" --prefer-online >/dev/null 2>&1; then
221
+ local TARBALL
222
+ TARBALL=$(ls "$TMPPACK"/blockrun-clawrouter-*.tgz 2>/dev/null | head -1)
223
+ if [ -n "$TARBALL" ]; then
224
+ rm -rf "$PLUGIN_DIR"
225
+ mkdir -p "$PLUGIN_DIR"
226
+ tar -xzf "$TARBALL" -C "$PLUGIN_DIR" --strip-components=1
227
+ rm -rf "$TMPPACK"
228
+ echo " ✓ Force-installed v${version} from npm registry"
229
+ return 0
230
+ fi
231
+ fi
232
+ rm -rf "$TMPPACK"
233
+ echo " ✗ Force install failed"
234
+ return 1
235
+ }
236
+
237
+ if [ -d "$PLUGIN_DIR" ] && [ -f "$PLUGIN_DIR/package.json" ]; then
238
+ INSTALLED_VER=$(node -e "try{const p=require('$PLUGIN_DIR/package.json');console.log(p.version);}catch{console.log('');}" 2>/dev/null || echo "")
239
+ LATEST_VER=$(npm view @blockrun/clawrouter@latest version 2>/dev/null || echo "")
240
+ if [ -n "$LATEST_VER" ] && [ -n "$INSTALLED_VER" ] && [ "$INSTALLED_VER" != "$LATEST_VER" ]; then
241
+ echo " ⚠️ openclaw installed v${INSTALLED_VER} (cached) but latest is v${LATEST_VER}"
242
+ force_install_from_npm "$LATEST_VER" || true
243
+ fi
244
+ INSTALLED_VER=$(node -e "try{const p=require('$PLUGIN_DIR/package.json');console.log(p.version);}catch{console.log('?');}" 2>/dev/null || echo "?")
245
+ echo " ✓ ClawRouter v${INSTALLED_VER} installed"
246
+ fi
247
+
248
+ # ── Step 4c: Ensure all dependencies are installed ────────────
215
249
  # openclaw's plugin installer may skip native/optional deps like @solana/kit.
216
250
  # Run npm install in the plugin directory to fill any gaps.
217
251
  if [ -d "$PLUGIN_DIR" ] && [ -f "$PLUGIN_DIR/package.json" ]; then