agentlife 2.6.17 → 2.6.18

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7527,31 +7527,43 @@ var PLUGIN_VERSION = (() => {
7527
7527
  } catch {}
7528
7528
  return "0.0.0";
7529
7529
  })();
7530
- var LATEST_CACHE_MS = 60 * 60 * 1000;
7530
+ var SOFT_TTL_MS = 5 * 60 * 1000;
7531
+ var HARD_FLOOR_MS = 30 * 1000;
7531
7532
  var cachedLatest = {
7532
7533
  version: null,
7533
7534
  fetchedAt: 0
7534
7535
  };
7535
- async function fetchNpmLatestVersion() {
7536
+ var inflightFetch = null;
7537
+ async function fetchNpmLatestVersion(force = false) {
7536
7538
  const now = Date.now();
7537
- if (cachedLatest.version && now - cachedLatest.fetchedAt < LATEST_CACHE_MS) {
7539
+ const sinceLast = now - cachedLatest.fetchedAt;
7540
+ const haveCache = cachedLatest.version !== null;
7541
+ if (inflightFetch)
7542
+ return inflightFetch;
7543
+ if (haveCache && sinceLast < HARD_FLOOR_MS)
7538
7544
  return cachedLatest.version;
7539
- }
7540
- try {
7541
- const res = await fetch("https://registry.npmjs.org/agentlife/latest", {
7542
- headers: { Accept: "application/json" },
7543
- signal: AbortSignal.timeout(5000)
7544
- });
7545
- if (!res.ok)
7545
+ if (haveCache && !force && sinceLast < SOFT_TTL_MS)
7546
+ return cachedLatest.version;
7547
+ inflightFetch = (async () => {
7548
+ try {
7549
+ const res = await fetch("https://registry.npmjs.org/agentlife/latest", {
7550
+ headers: { Accept: "application/json" },
7551
+ signal: AbortSignal.timeout(5000)
7552
+ });
7553
+ if (!res.ok)
7554
+ return cachedLatest.version;
7555
+ const data = await res.json();
7556
+ if (data.version) {
7557
+ cachedLatest = { version: data.version, fetchedAt: Date.now() };
7558
+ }
7546
7559
  return cachedLatest.version;
7547
- const data = await res.json();
7548
- if (data.version) {
7549
- cachedLatest = { version: data.version, fetchedAt: now };
7560
+ } catch {
7561
+ return cachedLatest.version;
7562
+ } finally {
7563
+ inflightFetch = null;
7550
7564
  }
7551
- return cachedLatest.version;
7552
- } catch {
7553
- return cachedLatest.version;
7554
- }
7565
+ })();
7566
+ return inflightFetch;
7555
7567
  }
7556
7568
  function pluginConfigPath() {
7557
7569
  return path13.join(os8.homedir(), ".openclaw", "agentlife", "plugin-config.json");
@@ -7572,8 +7584,9 @@ function registerAdminGateway(api, state2) {
7572
7584
  api.registerGatewayMethod("agentlife.version", ({ respond }) => {
7573
7585
  respond(true, { version: PLUGIN_VERSION });
7574
7586
  }, { scope: "operator.read" });
7575
- api.registerGatewayMethod("agentlife.latest_version", async ({ respond }) => {
7576
- const version = await fetchNpmLatestVersion();
7587
+ api.registerGatewayMethod("agentlife.latest_version", async ({ params, respond }) => {
7588
+ const force = params?.force === true;
7589
+ const version = await fetchNpmLatestVersion(force);
7577
7590
  respond(true, { version });
7578
7591
  }, { scope: "operator.read" });
7579
7592
  api.registerGatewayMethod("agentlife.quality", ({ respond }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlife",
3
- "version": "2.6.17",
3
+ "version": "2.6.18",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "bun build index.ts --outfile dist/index.js --target node --external openclaw/plugin-sdk",