@clawlabz/clawnetwork 0.1.15 → 0.1.16

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
@@ -2396,25 +2396,39 @@ export default function register(api: OpenClawApi) {
2396
2396
  if (state.running) {
2397
2397
  api.logger?.info?.(`[clawnetwork] node already running (pid=${state.pid})`)
2398
2398
 
2399
- // Check if running binary is outdated — if so, stop + upgrade + restart
2399
+ // Check if a newer binary is available on GitHub — if so, download + restart
2400
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)
2401
+ try {
2402
+ const binary = findBinary()
2403
+ const runningVersion = binary ? getBinaryVersion(binary) : null
2404
+ if (runningVersion) {
2405
+ // Fetch latest version from GitHub
2406
+ let latestVersion: string | null = null
2408
2407
  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)
2408
+ const res = await fetch(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`)
2409
+ if (res.ok) {
2410
+ const data = await res.json() as Record<string, unknown>
2411
+ if (typeof data.tag_name === 'string') latestVersion = data.tag_name.replace(/^v/, '')
2412
+ }
2413
+ } catch { /* network error, skip */ }
2414
+
2415
+ if (latestVersion && isVersionOlder(runningVersion, latestVersion)) {
2416
+ api.logger?.info?.(`[clawnetwork] node ${runningVersion} → ${latestVersion} available, upgrading...`)
2417
+ stopNodeProcess(api)
2418
+ await sleep(3_000)
2419
+ try {
2420
+ const newBinary = await downloadBinary(api)
2421
+ initNode(newBinary, cfg.network, api)
2422
+ startNodeProcess(newBinary, cfg, api)
2423
+ api.logger?.info?.(`[clawnetwork] node upgraded to ${latestVersion} and restarted`)
2424
+ } catch (e: unknown) {
2425
+ api.logger?.warn?.(`[clawnetwork] auto-upgrade failed: ${(e as Error).message}, restarting old binary`)
2426
+ startNodeProcess(binary, cfg, api)
2427
+ }
2416
2428
  }
2417
2429
  }
2430
+ } catch (e: unknown) {
2431
+ api.logger?.warn?.(`[clawnetwork] upgrade check failed: ${(e as Error).message}`)
2418
2432
  }
2419
2433
  }
2420
2434
 
@@ -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.15",
5
+ "version": "0.1.16",
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.15",
3
+ "version": "0.1.16",
4
4
  "description": "Run a ClawNetwork blockchain node inside OpenClaw. Every agent is a blockchain node.",
5
5
  "type": "module",
6
6
  "license": "MIT",