@mycadet/cli 0.13.0-dev.202610221419.8e700c5 → 0.13.0-dev.202610221914.02130b1

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 (41) hide show
  1. package/node_modules/@mycadet/local-mode/src/gateway-bearer.test.ts +157 -0
  2. package/node_modules/@mycadet/local-mode/src/gateway-bearer.ts +133 -0
  3. package/node_modules/@mycadet/local-mode/src/index.ts +5 -0
  4. package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +0 -1
  5. package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +0 -5
  6. package/node_modules/@mycadet/local-mode/src/lockfile.test.ts +0 -1
  7. package/node_modules/@mycadet/local-mode/src/status.ts +0 -1
  8. package/package.json +1 -1
  9. package/src/__tests__/assistant-client-cloud-auth.test.ts +2 -19
  10. package/src/__tests__/assistant-config.test.ts +0 -12
  11. package/src/__tests__/devices.test.ts +15 -9
  12. package/src/__tests__/gateway-token.test.ts +0 -2
  13. package/src/__tests__/ingress-config.test.ts +0 -34
  14. package/src/__tests__/pair.test.ts +103 -190
  15. package/src/__tests__/retire.test.ts +1 -4
  16. package/src/__tests__/setup.test.ts +23 -4
  17. package/src/__tests__/sleep.test.ts +9 -2
  18. package/src/__tests__/upgrade-local.test.ts +9 -6
  19. package/src/commands/client.ts +16 -15
  20. package/src/commands/debug.ts +2 -2
  21. package/src/commands/devices.ts +9 -10
  22. package/src/commands/gateway/token.ts +2 -1
  23. package/src/commands/logs.ts +2 -2
  24. package/src/commands/pair.ts +41 -69
  25. package/src/commands/ps.ts +11 -11
  26. package/src/commands/retire.ts +6 -6
  27. package/src/commands/setup.ts +3 -2
  28. package/src/commands/sleep.ts +2 -1
  29. package/src/commands/terminal.ts +2 -2
  30. package/src/commands/upgrade.ts +1 -5
  31. package/src/commands/use.ts +3 -3
  32. package/src/index.ts +2 -2
  33. package/src/lib/assistant-client.ts +6 -30
  34. package/src/lib/assistant-config.ts +9 -14
  35. package/src/lib/hatch-local.ts +0 -3
  36. package/src/lib/ingress-config.ts +0 -25
  37. package/src/lib/live-voice/connection.ts +6 -5
  38. package/src/lib/nginx-ingress.ts +2 -2
  39. package/src/lib/runtime-url.ts +19 -17
  40. package/src/lib/tunnel.ts +10 -10
  41. package/src/lib/tunnels/gateway-notify.ts +3 -3
@@ -0,0 +1,157 @@
1
+ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
2
+
3
+ import {
4
+ clearLoopbackGatewayBearerCache,
5
+ loopbackGatewayBearer,
6
+ } from "./gateway-bearer";
7
+ import type { TokenResult } from "./guardian-token";
8
+
9
+ const realFetch = globalThis.fetch;
10
+
11
+ let leaseResult: TokenResult = { ok: true, accessToken: "guardian-tok" };
12
+ let mintResponses: Response[] = [];
13
+ let mintCalls: Array<{ url: string; init?: RequestInit }> = [];
14
+
15
+ const lease = mock(async (): Promise<TokenResult> => leaseResult);
16
+
17
+ // The mint fetch is the I/O seam: recorded and answered per test.
18
+ globalThis.fetch = (async (
19
+ input: RequestInfo | URL,
20
+ init?: RequestInit,
21
+ ): Promise<Response> => {
22
+ mintCalls.push({ url: String(input), init });
23
+ const response = mintResponses.shift();
24
+ if (!response) {
25
+ throw new TypeError("no scripted mint response");
26
+ }
27
+ return response;
28
+ }) as unknown as typeof fetch;
29
+
30
+ const mintOk = (token = "minted-bearer", expiresAt?: number) =>
31
+ new Response(
32
+ JSON.stringify({
33
+ token,
34
+ expiresAt: expiresAt ?? Math.floor(Date.now() / 1000) + 3600,
35
+ }),
36
+ { headers: { "content-type": "application/json" } },
37
+ );
38
+
39
+ beforeEach(() => {
40
+ clearLoopbackGatewayBearerCache();
41
+ lease.mockClear();
42
+ leaseResult = { ok: true, accessToken: "guardian-tok" };
43
+ mintCalls = [];
44
+ mintResponses = [mintOk()];
45
+ });
46
+
47
+ afterEach(() => {
48
+ clearLoopbackGatewayBearerCache();
49
+ });
50
+
51
+ describe("loopbackGatewayBearer", () => {
52
+ test("mints against the loopback gateway with the guardian lease", async () => {
53
+ const bearer = await loopbackGatewayBearer(8080, lease);
54
+
55
+ expect(bearer).toBe("minted-bearer");
56
+ expect(mintCalls).toHaveLength(1);
57
+ expect(mintCalls[0].url).toBe("http://127.0.0.1:8080/auth/token");
58
+ expect(mintCalls[0].init?.method).toBe("POST");
59
+ const headers = new Headers(mintCalls[0].init?.headers);
60
+ // The mint route is Origin-gated (a CSRF defense for browsers); the
61
+ // server-to-server hop presents the loopback web origin it dials.
62
+ expect(headers.get("origin")).toBe("http://127.0.0.1:8080");
63
+ expect(headers.get("authorization")).toBe("Bearer guardian-tok");
64
+ });
65
+
66
+ test("caches the mint per port so a burst shares one lease", async () => {
67
+ await loopbackGatewayBearer(8080, lease);
68
+ const again = await loopbackGatewayBearer(8080, lease);
69
+
70
+ expect(again).toBe("minted-bearer");
71
+ expect(mintCalls).toHaveLength(1);
72
+ expect(lease).toHaveBeenCalledTimes(1);
73
+ });
74
+
75
+ test("ports cache independently", async () => {
76
+ mintResponses = [mintOk("bearer-8080"), mintOk("bearer-8081")];
77
+ await loopbackGatewayBearer(8080, lease);
78
+ const other = await loopbackGatewayBearer(8081, lease);
79
+
80
+ expect(other).toBe("bearer-8081");
81
+ expect(mintCalls).toHaveLength(2);
82
+ });
83
+
84
+ test("a bearer inside the freshness margin is reused; an expired one re-mints", async () => {
85
+ // Expired an hour ago: the first call must mint.
86
+ mintResponses = [
87
+ mintOk("stale-bearer", Math.floor(Date.now() / 1000) - 3600),
88
+ ];
89
+ const stale = await loopbackGatewayBearer(8080, lease);
90
+ expect(stale).toBe("stale-bearer");
91
+
92
+ // Within the margin (expires in 30s): the cached mint is reused.
93
+ mintResponses = [
94
+ mintOk("fresh-bearer", Math.floor(Date.now() / 1000) + 30),
95
+ ];
96
+ const fresh = await loopbackGatewayBearer(8080, lease, { forceMint: true });
97
+ expect(fresh).toBe("fresh-bearer");
98
+
99
+ // The margin itself (60s) keeps a 90s-lived bearer cacheable.
100
+ mintResponses = [
101
+ mintOk("margin-bearer", Math.floor(Date.now() / 1000) + 90),
102
+ ];
103
+ await loopbackGatewayBearer(8080, lease, { forceMint: true });
104
+ const cached = await loopbackGatewayBearer(8080, lease);
105
+ expect(cached).toBe("margin-bearer");
106
+ expect(mintCalls).toHaveLength(3);
107
+ });
108
+
109
+ test("forceMint skips the cache and replaces it", async () => {
110
+ await loopbackGatewayBearer(8080, lease);
111
+ mintResponses = [mintOk("rotated-bearer")];
112
+
113
+ const rotated = await loopbackGatewayBearer(8080, lease, {
114
+ forceMint: true,
115
+ });
116
+
117
+ expect(rotated).toBe("rotated-bearer");
118
+ expect(mintCalls).toHaveLength(2);
119
+ });
120
+
121
+ test("a failed guardian lease yields no bearer", async () => {
122
+ leaseResult = { ok: false, status: 404, error: "Guardian token not found" };
123
+
124
+ const bearer = await loopbackGatewayBearer(8080, lease);
125
+
126
+ expect(bearer).toBeNull();
127
+ expect(mintCalls).toHaveLength(0);
128
+ });
129
+
130
+ test("a rejected mint yields no bearer", async () => {
131
+ mintResponses = [new Response("Unauthorized", { status: 401 })];
132
+
133
+ const bearer = await loopbackGatewayBearer(8080, lease);
134
+
135
+ expect(bearer).toBeNull();
136
+ });
137
+
138
+ test("a malformed mint body yields no bearer", async () => {
139
+ mintResponses = [
140
+ new Response(JSON.stringify({ token: 5 }), { status: 200 }),
141
+ ];
142
+
143
+ const bearer = await loopbackGatewayBearer(8080, lease);
144
+
145
+ expect(bearer).toBeNull();
146
+ });
147
+
148
+ test("a thrown lease yields no bearer", async () => {
149
+ const throwingLease = mock(async (): Promise<TokenResult> => {
150
+ throw new Error("host down");
151
+ });
152
+
153
+ const bearer = await loopbackGatewayBearer(8080, throwingLease);
154
+
155
+ expect(bearer).toBeNull();
156
+ });
157
+ });
@@ -0,0 +1,133 @@
1
+ import type { TokenResult } from "./guardian-token";
2
+
3
+ /**
4
+ * Host-side custody of the local gateway bearer.
5
+ *
6
+ * The desktop main process and the dev-server middleware are the trusted
7
+ * hosts of the local data plane: each can read the on-disk guardian token
8
+ * (via {@link GuardianTokenLease}) and mint a gateway actor bearer against
9
+ * the loopback gateway's `/auth/token`. Minting here keeps both the
10
+ * guardian token and the minted bearer out of the renderer — the browser
11
+ * never sees either credential, so nothing token-shaped lands in
12
+ * localStorage.
13
+ *
14
+ * The minted bearer is cached per gateway port with the same 60-second
15
+ * expiry margin the client previously applied to its own mint, so a burst
16
+ * of forwarded requests shares one mint instead of paying the guardian
17
+ * lease per request.
18
+ */
19
+
20
+ /** The loopback gateway's `/auth/token` mint response. */
21
+ interface MintedGatewayBearer {
22
+ token: string;
23
+ expiresAtEpochSeconds: number;
24
+ }
25
+
26
+ /**
27
+ * Lease the guardian access token from the trusted host's disk/CLI
28
+ * machinery. Mirrors the never-reject contract of the host credential
29
+ * routes: a failure resolves with the structured result rather than
30
+ * throwing.
31
+ */
32
+ export type GuardianTokenLease = () => Promise<TokenResult>;
33
+
34
+ const FRESHNESS_MARGIN_SECONDS = 60;
35
+
36
+ const bearerCache = new Map<number, MintedGatewayBearer>();
37
+
38
+ function isFresh(bearer: MintedGatewayBearer): boolean {
39
+ return (
40
+ Date.now() / 1000 < bearer.expiresAtEpochSeconds - FRESHNESS_MARGIN_SECONDS
41
+ );
42
+ }
43
+
44
+ /** @internal Exposed for test teardown only: the cache is module state. */
45
+ export function clearLoopbackGatewayBearerCache(): void {
46
+ bearerCache.clear();
47
+ }
48
+
49
+ async function mintBearer(
50
+ port: number,
51
+ leaseGuardianToken: GuardianTokenLease,
52
+ fetcher: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>,
53
+ ): Promise<MintedGatewayBearer | null> {
54
+ let guardianToken: string;
55
+ try {
56
+ const lease = await leaseGuardianToken();
57
+ if (!lease.ok) {
58
+ return null;
59
+ }
60
+ guardianToken = lease.accessToken;
61
+ } catch {
62
+ return null;
63
+ }
64
+ try {
65
+ // The mint route is loopback-peer-gated and Origin-gated (a CSRF
66
+ // defense for browsers); this server-to-server hop presents the same
67
+ // loopback web origin the desktop forward's rewrite already produced.
68
+ const response = await fetcher(`http://127.0.0.1:${port}/auth/token`, {
69
+ method: "POST",
70
+ headers: {
71
+ origin: `http://127.0.0.1:${port}`,
72
+ authorization: `Bearer ${guardianToken}`,
73
+ },
74
+ });
75
+ if (!response.ok) {
76
+ return null;
77
+ }
78
+ const body = (await response.json().catch(() => null)) as {
79
+ token?: unknown;
80
+ expiresAt?: unknown;
81
+ } | null;
82
+ if (
83
+ typeof body?.token !== "string" ||
84
+ typeof body.expiresAt !== "number" ||
85
+ !Number.isFinite(body.expiresAt)
86
+ ) {
87
+ return null;
88
+ }
89
+ return { token: body.token, expiresAtEpochSeconds: body.expiresAt };
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+
95
+ export interface LoopbackGatewayBearerOptions {
96
+ /** Skip the cache and mint fresh — the 401 re-mint path. */
97
+ forceMint?: boolean;
98
+ /**
99
+ * Injectable for tests; defaults to the global fetch. A plain callable —
100
+ * the Electron forward threads its own recorded fetcher through.
101
+ */
102
+ fetcher?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
103
+ }
104
+
105
+ /**
106
+ * A bearer for forwarded requests to the loopback gateway on `port`, minted
107
+ * host-side and cached until near expiry. `null` when the guardian lease or
108
+ * the mint fails — callers forward without a bearer and the gateway's own
109
+ * response (401 on protected routes, an unauthenticated `readyz`) surfaces
110
+ * the truth.
111
+ */
112
+ export async function loopbackGatewayBearer(
113
+ port: number,
114
+ leaseGuardianToken: GuardianTokenLease,
115
+ options: LoopbackGatewayBearerOptions = {},
116
+ ): Promise<string | null> {
117
+ if (!options.forceMint) {
118
+ const cached = bearerCache.get(port);
119
+ if (cached && isFresh(cached)) {
120
+ return cached.token;
121
+ }
122
+ }
123
+ const minted = await mintBearer(
124
+ port,
125
+ leaseGuardianToken,
126
+ options.fetcher ?? fetch,
127
+ );
128
+ if (!minted) {
129
+ return null;
130
+ }
131
+ bearerCache.set(port, minted);
132
+ return minted.token;
133
+ }
@@ -131,6 +131,11 @@ export {
131
131
  sanitizePairedForwardHeaders,
132
132
  FLATTENED_FIRST_SEGMENTS,
133
133
  } from "./gateway-proxy";
134
+ export {
135
+ loopbackGatewayBearer,
136
+ clearLoopbackGatewayBearerCache,
137
+ } from "./gateway-bearer";
138
+ export type { GuardianTokenLease } from "./gateway-bearer";
134
139
  export type {
135
140
  GatewayTarget,
136
141
  GatewayParseResult,
@@ -78,7 +78,6 @@ describe("parseLockfile", () => {
78
78
  {
79
79
  assistantId: "asst_1",
80
80
  cloud: "local",
81
- localUrl: "http://127.0.0.1:7777",
82
81
  },
83
82
  ]);
84
83
  });
@@ -263,11 +263,6 @@ export const LockfileAssistantSchema = z.object({
263
263
  /** Platform organization UUID used for a self-hosted local assistant registration. */
264
264
  cloudOrganizationId: z.string().optional(),
265
265
  resources: LocalAssistantResourcesSchema.optional(),
266
- /**
267
- * Loopback URL for same-machine health checks (e.g. `http://127.0.0.1:7831`).
268
- * Avoids mDNS resolution issues when the machine checks its own gateway.
269
- */
270
- localUrl: z.string().optional(),
271
266
  /** Helper token for cloud assistants' API bearer; host-only secret. */
272
267
  bearerToken: z.string().optional(),
273
268
  /** PID of the file watcher process for docker instances hatched with --watch. */
@@ -83,7 +83,6 @@ describe("getLockfileData", () => {
83
83
  {
84
84
  assistantId: "asst_legacy",
85
85
  cloud: "local",
86
- localUrl: "http://127.0.0.1:7777",
87
86
  },
88
87
  ]);
89
88
  expect(result.data.activeAssistant).toBe("asst_legacy");
@@ -321,7 +321,6 @@ function resolveStatusResources(
321
321
  ports.daemon,
322
322
  gatewayPort:
323
323
  firstNumber(entry.resources?.gatewayPort, rawResources?.gatewayPort) ??
324
- parsePortFromUrl(rawEntry?.localUrl) ??
325
324
  parsePortFromUrl(rawEntry?.runtimeUrl ?? entry.runtimeUrl) ??
326
325
  ports.gateway,
327
326
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/cli",
3
- "version": "0.13.0-dev.202610221419.8e700c5",
3
+ "version": "0.13.0-dev.202610221914.02130b1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vargasjr-dev/mycadet-temp.git"
@@ -166,30 +166,13 @@ describe("AssistantClient cloud-managed auth", () => {
166
166
  expect(calls).toHaveLength(0);
167
167
  });
168
168
 
169
- test("refuses to send cloud credentials to a runtimeUrl override", async () => {
170
- seedCloud("sess-tok-4");
171
- const calls = stubFetch(() => new Response("", { status: 200 }));
172
-
173
- expect(
174
- () =>
175
- new AssistantClient({
176
- assistantId: ASSISTANT_ID,
177
- runtimeUrl: "https://attacker.example.com",
178
- }),
179
- ).toThrow("Refusing to send cloud credentials");
180
- expect(calls).toHaveLength(0);
181
- });
182
-
183
- test("allows a runtimeUrl override that matches the entry's platform host", async () => {
169
+ test("dials the entry's recorded cloud host", async () => {
184
170
  seedCloud("sess-tok-5");
185
171
  stubFetch((url) =>
186
172
  isOrgFetch(url) ? orgResponse() : new Response("", { status: 200 }),
187
173
  );
188
174
 
189
- const client = new AssistantClient({
190
- assistantId: ASSISTANT_ID,
191
- runtimeUrl: `${PLATFORM_URL}/`, // trailing slash must not count as a mismatch
192
- });
175
+ const client = new AssistantClient({ assistantId: ASSISTANT_ID });
193
176
 
194
177
  expect(client.runtimeUrl).toBe(PLATFORM_URL);
195
178
  expect((await client.get("/healthz/")).status).toBe(200);
@@ -27,7 +27,6 @@ import {
27
27
  loadLatestAssistant,
28
28
  findAssistantByName,
29
29
  formatAssistantLookupError,
30
- formatAssistantReference,
31
30
  getAssistantDisplayName,
32
31
  lookupAssistantByIdentifier,
33
32
  removeAssistantEntry,
@@ -217,17 +216,6 @@ describe("assistant-config", () => {
217
216
  );
218
217
  });
219
218
 
220
- test("formatAssistantReference includes distinct display name and id", () => {
221
- expect(
222
- formatAssistantReference(
223
- makeEntry("assistant-1", undefined, { name: "Alice" }),
224
- ),
225
- ).toBe("Alice (assistant-1)");
226
- expect(formatAssistantReference(makeEntry("assistant-2"))).toBe(
227
- "assistant-2",
228
- );
229
- });
230
-
231
219
  test("findAssistantByName returns null for non-existent name", () => {
232
220
  writeLockfile({ assistants: [makeEntry("alpha")] });
233
221
  expect(findAssistantByName("missing")).toBeNull();
@@ -178,13 +178,19 @@ describe("cadet devices", () => {
178
178
  rmSync(testDir, { recursive: true, force: true });
179
179
  });
180
180
 
181
- function seedLocal(id: string, localUrl = "http://127.0.0.1:7830"): void {
181
+ function seedLocal(id: string, gatewayPort = 7830): void {
182
182
  saveAssistantEntry({
183
183
  assistantId: id,
184
184
  name: id,
185
185
  runtimeUrl: "http://127.0.0.1:7830",
186
- localUrl,
187
186
  cloud: "local",
187
+ resources: {
188
+ instanceDir: testDir,
189
+ gatewayPort,
190
+ daemonPort: 8501,
191
+ qdrantPort: 9001,
192
+ cesPort: 9002,
193
+ },
188
194
  });
189
195
  }
190
196
 
@@ -197,7 +203,7 @@ describe("cadet devices", () => {
197
203
  });
198
204
 
199
205
  test("lists active devices over loopback with no browser/proxy headers", async () => {
200
- seedLocal("list-host", "http://127.0.0.1:7833");
206
+ seedLocal("list-host", 7833);
201
207
  stubFetch((url) => {
202
208
  if (url.endsWith("/v1/devices")) {
203
209
  return jsonResponse({
@@ -258,7 +264,7 @@ describe("cadet devices", () => {
258
264
  }
259
265
 
260
266
  test("labels this machine's own host credential in the human list", async () => {
261
- seedLocal("host-label", "http://127.0.0.1:7837");
267
+ seedLocal("host-label");
262
268
  stubFetch((url) =>
263
269
  url.endsWith("/v1/devices")
264
270
  ? jsonResponse({
@@ -298,7 +304,7 @@ describe("cadet devices", () => {
298
304
  });
299
305
 
300
306
  test("list --json marks only the host credential with isCurrentHost", async () => {
301
- seedLocal("host-json", "http://127.0.0.1:7838");
307
+ seedLocal("host-json", 7838);
302
308
  const hostRecord = {
303
309
  hashedDeviceId: hostHash(),
304
310
  platform: "cli",
@@ -333,7 +339,7 @@ describe("cadet devices", () => {
333
339
  });
334
340
 
335
341
  test("revoking the host credential warns on stderr but proceeds", async () => {
336
- seedLocal("host-revoke", "http://127.0.0.1:7839");
342
+ seedLocal("host-revoke", 7839);
337
343
  stubFetch((url) =>
338
344
  url.endsWith("/v1/devices/revoke")
339
345
  ? jsonResponse({ revoked: true })
@@ -369,7 +375,7 @@ describe("cadet devices", () => {
369
375
  });
370
376
 
371
377
  test("revoke posts the hashedDeviceId with --yes (no prompt)", async () => {
372
- seedLocal("revoke-host", "http://127.0.0.1:7834");
378
+ seedLocal("revoke-host", 7834);
373
379
  stubFetch((url) => {
374
380
  if (url.endsWith("/v1/devices/revoke")) {
375
381
  return jsonResponse({ revoked: true, hashedDeviceId: "hashAAA111" });
@@ -437,7 +443,7 @@ describe("cadet devices", () => {
437
443
  });
438
444
 
439
445
  test("list --json emits a single JSON document and no human text", async () => {
440
- seedLocal("json-host", "http://127.0.0.1:7835");
446
+ seedLocal("json-host");
441
447
  const records = [
442
448
  {
443
449
  hashedDeviceId: "hashAAA111",
@@ -479,7 +485,7 @@ describe("cadet devices", () => {
479
485
  });
480
486
 
481
487
  test("revoke --json --yes emits one JSON line; identity preamble on stderr", async () => {
482
- seedLocal("json-revoke-host", "http://127.0.0.1:7836");
488
+ seedLocal("json-revoke-host");
483
489
  stubFetch((url) =>
484
490
  url.endsWith("/v1/devices/revoke")
485
491
  ? jsonResponse({ revoked: true, hashedDeviceId: "hashAAA111" })
@@ -49,7 +49,6 @@ function seedLocalEntry(overrides: Record<string, unknown> = {}): void {
49
49
  assistantId: "px",
50
50
  name: "Prime Quail",
51
51
  runtimeUrl: "http://127.0.0.1:7830",
52
- localUrl: "http://127.0.0.1:7830",
53
52
  cloud: "local",
54
53
  ...overrides,
55
54
  });
@@ -181,7 +180,6 @@ describe("gateway token command", () => {
181
180
  assistantId: "py",
182
181
  name: "Other Box",
183
182
  runtimeUrl: "http://127.0.0.1:7831",
184
- localUrl: "http://127.0.0.1:7831",
185
183
  cloud: "local",
186
184
  });
187
185
  setActiveAssistant("py");
@@ -8,12 +8,9 @@ import {
8
8
  TUNNEL_PROVIDERS,
9
9
  } from "@mycadet/service-contracts/ingress";
10
10
 
11
- import type { AssistantEntry } from "../lib/assistant-config.js";
12
-
13
11
  import {
14
12
  clearIngressUrl,
15
13
  readIngressPublicBaseUrl,
16
- parseGatewayPortFromEntryUrls,
17
14
  saveIngressUrl,
18
15
  savePairingTunnel,
19
16
  } from "../lib/ingress-config.js";
@@ -199,34 +196,3 @@ describe("pairing-tunnel record", () => {
199
196
  });
200
197
  });
201
198
  });
202
-
203
- describe("parseGatewayPortFromEntryUrls", () => {
204
- test("prefers the loopback localUrl over runtimeUrl", () => {
205
- expect(
206
- parseGatewayPortFromEntryUrls({
207
- assistantId: "a",
208
- localUrl: "http://127.0.0.1:7830",
209
- runtimeUrl: "https://stale-tunnel.ngrok-free.dev",
210
- } as AssistantEntry),
211
- ).toBe(7830);
212
- });
213
-
214
- test("falls back to runtimeUrl when localUrl is absent", () => {
215
- expect(
216
- parseGatewayPortFromEntryUrls({
217
- assistantId: "a",
218
- runtimeUrl: "http://localhost:9123",
219
- } as AssistantEntry),
220
- ).toBe(9123);
221
- });
222
-
223
- test("is undefined when neither URL carries an explicit port", () => {
224
- expect(
225
- parseGatewayPortFromEntryUrls({
226
- assistantId: "a",
227
- runtimeUrl: "https://runtime.example.com/a",
228
- } as AssistantEntry),
229
- ).toBeUndefined();
230
- expect(parseGatewayPortFromEntryUrls(undefined)).toBeUndefined();
231
- });
232
- });