@bulolo/hermes-link 0.2.2 → 0.2.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.
@@ -3612,5 +3612,6 @@ export {
3612
3612
  readRecentGatewayLogEntries,
3613
3613
  bootstrapWithRelay,
3614
3614
  generateAppConnectToken,
3615
+ discoverRouteCandidates,
3615
3616
  startLinkService
3616
3617
  };
package/dist/cli/index.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  currentCliScriptPath,
9
9
  detectRuntimeEnvironment,
10
10
  disableAutostart,
11
+ discoverRouteCandidates,
11
12
  enableAutostart,
12
13
  ensureIdentity,
13
14
  generateAppConnectToken,
@@ -22,7 +23,7 @@ import {
22
23
  saveConfig,
23
24
  startLinkService,
24
25
  writeJsonFile
25
- } from "../chunk-QL5SEM7J.js";
26
+ } from "../chunk-YARHXGP4.js";
26
27
 
27
28
  // src/cli/index.ts
28
29
  import { mkdir as mkdir3 } from "fs/promises";
@@ -233,17 +234,29 @@ function pairingSessionPath(sessionId, paths) {
233
234
  }
234
235
  async function runPairingPreflight(options) {
235
236
  const token = await generateAppConnectToken(options.paths);
237
+ const routes = options.identity.link_id ? await discoverRouteCandidates({
238
+ port: options.config.port,
239
+ relayBaseUrl: options.config.relayBaseUrl,
240
+ linkId: options.identity.link_id,
241
+ installId: options.identity.install_id,
242
+ publicKeyPem: options.identity.public_key_pem,
243
+ configuredLanHost: options.config.lanHost
244
+ }).catch(() => null) : null;
236
245
  const localApiUrl = `http://127.0.0.1:${options.config.port}`;
246
+ const preferredUrls = (routes?.preferredUrls ?? []).filter(
247
+ (u) => !u.includes("/api/v1/relay/")
248
+ );
249
+ const bestUrl = preferredUrls[0] ?? localApiUrl;
237
250
  const sessionId = `ps_${token.token.slice(0, 16)}`;
238
251
  const session = {
239
252
  session_id: sessionId,
240
253
  code: token.token,
241
254
  link_id: options.identity.link_id ?? "",
242
255
  display_name: "Hermes Link",
243
- local_api_url: localApiUrl,
256
+ local_api_url: bestUrl,
244
257
  server_base_url: options.config.serverBaseUrl,
245
258
  relay_base_url: options.config.relayBaseUrl,
246
- preferred_urls: [localApiUrl],
259
+ preferred_urls: preferredUrls.length > 0 ? preferredUrls : [localApiUrl],
247
260
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
248
261
  expires_at: token.expiresAt
249
262
  };
@@ -254,7 +267,8 @@ async function runPairingPreflight(options) {
254
267
  installId: options.identity.install_id,
255
268
  connectToken: token.token,
256
269
  port: options.config.port,
257
- localApiUrl
270
+ localApiUrl: bestUrl,
271
+ preferredUrls: session.preferred_urls
258
272
  });
259
273
  if (options.openBrowser !== false) {
260
274
  await openSystemBrowser(pairingUrl).catch(() => void 0);
@@ -267,7 +281,8 @@ function buildPairingUrl(params) {
267
281
  install_id: params.installId,
268
282
  connect_token: params.connectToken,
269
283
  port: String(params.port),
270
- local_url: params.localApiUrl
284
+ local_url: params.localApiUrl,
285
+ preferred_urls: params.preferredUrls.join(",")
271
286
  });
272
287
  return `hermesapp://pair?${qs.toString()}`;
273
288
  }
package/dist/http/app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startLinkService
3
- } from "../chunk-QL5SEM7J.js";
3
+ } from "../chunk-YARHXGP4.js";
4
4
  export {
5
5
  startLinkService
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bulolo/hermes-link",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Hermes Link companion service and CLI for connecting hermes-agent through zhiji",
5
5
  "license": "MIT",
6
6
  "type": "module",