agentlife 1.1.1 → 1.1.3

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 +39 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2164,6 +2164,29 @@ import * as fsSync2 from "node:fs";
2164
2164
  import { createRequire as createRequire3 } from "node:module";
2165
2165
  import * as os2 from "node:os";
2166
2166
  import * as path6 from "node:path";
2167
+ async function detectTunnelUrl(port) {
2168
+ try {
2169
+ const cfgPath = path6.join(os2.homedir(), ".cloudflared", "config.yml");
2170
+ if (!fsSync2.existsSync(cfgPath))
2171
+ return null;
2172
+ const cfg = fsSync2.readFileSync(cfgPath, "utf-8");
2173
+ const lines = cfg.split(`
2174
+ `);
2175
+ for (let i = 0;i < lines.length; i++) {
2176
+ const hostMatch = lines[i].match(/hostname:\s*(.+)/);
2177
+ if (hostMatch) {
2178
+ const nextLine = lines[i + 1] || "";
2179
+ const svcMatch = nextLine.match(/service:\s*http:\/\/localhost:(\d+)/);
2180
+ if (svcMatch && parseInt(svcMatch[1]) === port) {
2181
+ return `wss://${hostMatch[1].trim()}`;
2182
+ }
2183
+ }
2184
+ }
2185
+ return null;
2186
+ } catch {
2187
+ return null;
2188
+ }
2189
+ }
2167
2190
  function registerPairingServices(api) {
2168
2191
  api.registerService({
2169
2192
  id: "agentlife-pairing-qr",
@@ -2175,15 +2198,18 @@ function registerPairingServices(api) {
2175
2198
  const token = cfg.gateway?.auth?.token;
2176
2199
  if (!token)
2177
2200
  return;
2178
- let host;
2179
- if (bind === "lan" || bind === "auto" || bind === "custom") {
2201
+ let url;
2202
+ const tunnelUrl = await detectTunnelUrl(port);
2203
+ if (tunnelUrl) {
2204
+ url = tunnelUrl;
2205
+ } else if (bind === "lan" || bind === "auto" || bind === "custom") {
2180
2206
  const nets = os2.networkInterfaces();
2181
2207
  const lanIp = Object.values(nets).flat().find((n) => n && !n.internal && n.family === "IPv4")?.address;
2182
- host = lanIp ?? "127.0.0.1";
2208
+ url = `ws://${lanIp ?? "127.0.0.1"}:${port}`;
2183
2209
  } else {
2184
- host = "127.0.0.1";
2210
+ url = `ws://127.0.0.1:${port}`;
2185
2211
  }
2186
- const payload = JSON.stringify({ url: `ws://${host}:${port}`, token });
2212
+ const payload = JSON.stringify({ url, token });
2187
2213
  const setupCode = Buffer.from(payload).toString("base64");
2188
2214
  let qrTerminal = null;
2189
2215
  try {
@@ -2192,8 +2218,7 @@ function registerPairingServices(api) {
2192
2218
  qrTerminal = mainRequire("qrcode-terminal");
2193
2219
  } catch {}
2194
2220
  console.log(`
2195
- \x1B[36m[agentlife]\x1B[0m \x1B[1mPairing QR\x1B[0m`);
2196
- console.log(`Scan this with the Agent Life app to connect.
2221
+ \x1B[36m[agentlife]\x1B[0m \x1B[1mPlugin installed — get the app to see your dashboard.\x1B[0m
2197
2222
  `);
2198
2223
  if (qrTerminal?.generate) {
2199
2224
  qrTerminal.generate(setupCode, { small: true }, (qr) => {
@@ -2207,10 +2232,13 @@ Setup code: ${setupCode}
2207
2232
  console.log(`Run 'openclaw qr' for a scannable QR code.
2208
2233
  `);
2209
2234
  }
2210
- console.log(" Download the app:");
2211
- console.log(" iOS: https://agentlife.app/ios");
2212
- console.log(" Android: https://agentlife.app/android");
2213
- console.log("");
2235
+ console.log(" \x1B[32mMac:\x1B[0m https://agentlife.app/desktop");
2236
+ console.log(" \x1B[32miOS:\x1B[0m https://agentlife.app/ios");
2237
+ console.log(" \x1B[32mAndroid:\x1B[0m https://agentlife.app/android");
2238
+ console.log(` \x1B[2mBrowser:\x1B[0m http://localhost:${port}/agentlife/`);
2239
+ console.log(`
2240
+ Scan the QR from the mobile app to connect.
2241
+ `);
2214
2242
  } catch (err) {
2215
2243
  console.warn("[agentlife] QR generation skipped:", err?.message);
2216
2244
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlife",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "bun build index.ts --outfile dist/index.js --target node --external openclaw/plugin-sdk",