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.
- package/dist/index.js +39 -11
- 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
|
|
2179
|
-
|
|
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
|
-
|
|
2208
|
+
url = `ws://${lanIp ?? "127.0.0.1"}:${port}`;
|
|
2183
2209
|
} else {
|
|
2184
|
-
|
|
2210
|
+
url = `ws://127.0.0.1:${port}`;
|
|
2185
2211
|
}
|
|
2186
|
-
const payload = JSON.stringify({ url
|
|
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[
|
|
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("
|
|
2211
|
-
console.log("
|
|
2212
|
-
console.log("
|
|
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
|
}
|