@clawlabz/clawnetwork 0.1.13 → 0.1.15

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/index.ts CHANGED
@@ -1902,14 +1902,11 @@ tryListen(0);
1902
1902
  `
1903
1903
 
1904
1904
  function startUiServer(cfg: PluginConfig, api: OpenClawApi): string | null {
1905
- // Check if already running
1906
- const existing = getDashboardUrl()
1907
- if (existing) {
1908
- api.logger?.info?.(`[clawnetwork] dashboard already running: ${existing}`)
1909
- return existing
1910
- }
1905
+ // Always kill old UI server and restart with fresh code.
1906
+ // The UI server is a detached process that survives gateway restarts,
1907
+ // so we must replace it to pick up plugin updates.
1908
+ stopUiServer()
1911
1909
 
1912
- // Write the standalone UI server script to a temp file and fork it
1913
1910
  const scriptPath = path.join(WORKSPACE_DIR, 'ui-server.js')
1914
1911
  ensureDir(WORKSPACE_DIR)
1915
1912
 
@@ -2397,11 +2394,32 @@ export default function register(api: OpenClawApi) {
2397
2394
  // Check if already running (e.g. from a previous detached start)
2398
2395
  const state = isNodeRunning()
2399
2396
  if (state.running) {
2400
- api.logger?.info?.(`[clawnetwork] node already running (pid=${state.pid}), skipping node start`)
2397
+ api.logger?.info?.(`[clawnetwork] node already running (pid=${state.pid})`)
2398
+
2399
+ // Check if running binary is outdated — if so, stop + upgrade + restart
2400
+ if (cfg.autoDownload) {
2401
+ const binary = findBinary()
2402
+ if (binary) {
2403
+ const cv = getBinaryVersion(binary)
2404
+ if (cv && isVersionOlder(cv, MIN_NODE_VERSION)) {
2405
+ api.logger?.info?.(`[clawnetwork] running node ${cv} outdated (need >=${MIN_NODE_VERSION}), upgrading...`)
2406
+ stopNodeProcess(api)
2407
+ await sleep(3_000)
2408
+ try {
2409
+ const newBinary = await downloadBinary(api)
2410
+ initNode(newBinary, cfg.network, api)
2411
+ startNodeProcess(newBinary, cfg, api)
2412
+ api.logger?.info?.(`[clawnetwork] node upgraded and restarted`)
2413
+ } catch (e: unknown) {
2414
+ api.logger?.warn?.(`[clawnetwork] auto-upgrade failed: ${(e as Error).message}, restarting old binary`)
2415
+ startNodeProcess(binary, cfg, api)
2416
+ }
2417
+ }
2418
+ }
2419
+ }
2420
+
2401
2421
  startHealthCheck(cfg, api)
2402
- // Start UI dashboard (may have been lost on gateway restart)
2403
2422
  startUiServer(cfg, api)
2404
- // Still need to ensure heartbeat loop is running (may have been lost on gateway restart)
2405
2423
  const wallet = ensureWallet(cfg.network, api)
2406
2424
  await sleep(5_000)
2407
2425
  await autoRegisterMiner(cfg, wallet, api)
@@ -2,7 +2,7 @@
2
2
  "id": "clawnetwork",
3
3
  "name": "ClawNetwork Node",
4
4
  "description": "Run a ClawNetwork blockchain node inside OpenClaw. Every agent is a node.",
5
- "version": "0.1.13",
5
+ "version": "0.1.15",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawlabz/clawnetwork",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Run a ClawNetwork blockchain node inside OpenClaw. Every agent is a blockchain node.",
5
5
  "type": "module",
6
6
  "license": "MIT",