agentlife 2.6.14 → 2.6.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.
Files changed (2) hide show
  1. package/dist/index.js +62 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
  // index.ts
5
5
  import { homedir as homedir14 } from "node:os";
6
6
  import * as path17 from "node:path";
7
- import { existsSync as existsSync6 } from "node:fs";
7
+ import { existsSync as existsSync7 } from "node:fs";
8
8
 
9
9
  // db.ts
10
10
  import * as fsSync from "node:fs";
@@ -5517,6 +5517,8 @@ function persistTunnel(info) {
5517
5517
  }
5518
5518
  async function provisionTunnel(identity) {
5519
5519
  const url = `${API_BASE}/api/v1/devices/provision`;
5520
+ const abort = new AbortController;
5521
+ const timeoutId = setTimeout(() => abort.abort(), 20000);
5520
5522
  try {
5521
5523
  const response = await fetch(url, {
5522
5524
  method: "POST",
@@ -5524,7 +5526,8 @@ async function provisionTunnel(identity) {
5524
5526
  body: JSON.stringify({
5525
5527
  deviceId: identity.deviceId,
5526
5528
  deviceSecret: identity.deviceSecret
5527
- })
5529
+ }),
5530
+ signal: abort.signal
5528
5531
  });
5529
5532
  if (!response.ok) {
5530
5533
  const body = await response.text();
@@ -5550,8 +5553,15 @@ async function provisionTunnel(identity) {
5550
5553
  provisionedAt: Date.now()
5551
5554
  };
5552
5555
  } catch (err) {
5553
- console.warn(`[cloudflared-supervisor] provision network error: ${err?.message ?? err}`);
5556
+ const aborted = err?.name === "AbortError";
5557
+ if (aborted) {
5558
+ console.warn(`[cloudflared-supervisor] provision request timed out after 20s — ` + `will retry on next pair request`);
5559
+ } else {
5560
+ console.warn(`[cloudflared-supervisor] provision network error: ${err?.message ?? err}`);
5561
+ }
5554
5562
  return null;
5563
+ } finally {
5564
+ clearTimeout(timeoutId);
5555
5565
  }
5556
5566
  }
5557
5567
  function ensureCloudflaredBinary() {
@@ -7486,6 +7496,47 @@ import * as fs14 from "node:fs/promises";
7486
7496
  import * as fsSync4 from "node:fs";
7487
7497
  import * as os8 from "node:os";
7488
7498
  import * as path13 from "node:path";
7499
+ var __dirname = "/Users/acv/IdeaProjects/AgentLife/plugin/gateway";
7500
+ var PLUGIN_VERSION = (() => {
7501
+ try {
7502
+ const candidates = [
7503
+ path13.join(__dirname, "..", "package.json"),
7504
+ path13.join(__dirname, "..", "..", "package.json")
7505
+ ];
7506
+ for (const p of candidates) {
7507
+ if (fsSync4.existsSync(p)) {
7508
+ return JSON.parse(fsSync4.readFileSync(p, "utf-8")).version ?? "0.0.0";
7509
+ }
7510
+ }
7511
+ } catch {}
7512
+ return "0.0.0";
7513
+ })();
7514
+ var LATEST_CACHE_MS = 60 * 60 * 1000;
7515
+ var cachedLatest = {
7516
+ version: null,
7517
+ fetchedAt: 0
7518
+ };
7519
+ async function fetchNpmLatestVersion() {
7520
+ const now = Date.now();
7521
+ if (cachedLatest.version && now - cachedLatest.fetchedAt < LATEST_CACHE_MS) {
7522
+ return cachedLatest.version;
7523
+ }
7524
+ try {
7525
+ const res = await fetch("https://registry.npmjs.org/agentlife/latest", {
7526
+ headers: { Accept: "application/json" },
7527
+ signal: AbortSignal.timeout(5000)
7528
+ });
7529
+ if (!res.ok)
7530
+ return cachedLatest.version;
7531
+ const data = await res.json();
7532
+ if (data.version) {
7533
+ cachedLatest = { version: data.version, fetchedAt: now };
7534
+ }
7535
+ return cachedLatest.version;
7536
+ } catch {
7537
+ return cachedLatest.version;
7538
+ }
7539
+ }
7489
7540
  function pluginConfigPath() {
7490
7541
  return path13.join(os8.homedir(), ".openclaw", "agentlife", "plugin-config.json");
7491
7542
  }
@@ -7502,6 +7553,13 @@ function writePluginConfig(config2) {
7502
7553
  fsSync4.writeFileSync(pluginConfigPath(), JSON.stringify(config2, null, 2));
7503
7554
  }
7504
7555
  function registerAdminGateway(api, state2) {
7556
+ api.registerGatewayMethod("agentlife.version", ({ respond }) => {
7557
+ respond(true, { version: PLUGIN_VERSION });
7558
+ }, { scope: "operator.read" });
7559
+ api.registerGatewayMethod("agentlife.latest_version", async ({ respond }) => {
7560
+ const version = await fetchNpmLatestVersion();
7561
+ respond(true, { version });
7562
+ }, { scope: "operator.read" });
7505
7563
  api.registerGatewayMethod("agentlife.quality", ({ respond }) => {
7506
7564
  try {
7507
7565
  const db = getOrCreateHistoryDb(state2);
@@ -8584,7 +8642,7 @@ function register(api) {
8584
8642
  currentState = state2;
8585
8643
  api.registerChannel({ plugin: createAgentlifeChannel(state2.channelState) });
8586
8644
  console.log("[agentlife] channel registered, session format: %s", buildAgentSessionKey("example"));
8587
- if (existsSync6(fallbackDir)) {
8645
+ if (existsSync7(fallbackDir)) {
8588
8646
  try {
8589
8647
  const db = getOrCreateHistoryDb(state2);
8590
8648
  state2.surfaceIndex = new SurfaceIndex(db);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlife",
3
- "version": "2.6.14",
3
+ "version": "2.6.16",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "bun build index.ts --outfile dist/index.js --target node --external openclaw/plugin-sdk",