@mycadet/cli 0.13.0-dev.202610211419.6a397d7 → 0.13.0-dev.202610221419.8e700c5

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 (82) hide show
  1. package/node_modules/@mycadet/assistant-api/index.ts +0 -2
  2. package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +2 -2
  3. package/node_modules/@mycadet/assistant-api/surfaces.ts +0 -43
  4. package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +2 -2
  5. package/node_modules/@mycadet/local-mode/src/__tests__/gateway-proxy.test.ts +176 -57
  6. package/node_modules/@mycadet/local-mode/src/__tests__/guardian-token.test.ts +2 -2
  7. package/node_modules/@mycadet/local-mode/src/__tests__/pair.test.ts +127 -285
  8. package/node_modules/@mycadet/local-mode/src/__tests__/status.test.ts +1 -1
  9. package/node_modules/@mycadet/local-mode/src/__tests__/unpair.test.ts +26 -48
  10. package/node_modules/@mycadet/local-mode/src/gateway-proxy.ts +112 -66
  11. package/node_modules/@mycadet/local-mode/src/guardian-token.ts +0 -11
  12. package/node_modules/@mycadet/local-mode/src/index.ts +3 -2
  13. package/node_modules/@mycadet/local-mode/src/lockfile-contract.test.ts +121 -83
  14. package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +185 -111
  15. package/node_modules/@mycadet/local-mode/src/lockfile.test.ts +45 -105
  16. package/node_modules/@mycadet/local-mode/src/lockfile.ts +44 -47
  17. package/node_modules/@mycadet/local-mode/src/pair.ts +16 -92
  18. package/node_modules/@mycadet/local-mode/src/status.ts +1 -1
  19. package/node_modules/@mycadet/local-mode/src/unpair.ts +5 -14
  20. package/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +2 -2
  21. package/package.json +2 -2
  22. package/src/__tests__/app-command.test.ts +6 -6
  23. package/src/__tests__/app-tunnel-status.test.ts +98 -0
  24. package/src/__tests__/assistant-client-refresh.test.ts +1 -2
  25. package/src/__tests__/assistant-config.test.ts +1 -351
  26. package/src/__tests__/backup.test.ts +1 -8
  27. package/src/__tests__/client-token.test.ts +1 -53
  28. package/src/__tests__/client-tui-refresh.test.ts +14 -13
  29. package/src/__tests__/connect-import.test.ts +0 -2
  30. package/src/__tests__/devices.test.ts +1 -2
  31. package/src/__tests__/ensure-binary.test.ts +6 -6
  32. package/src/__tests__/gateway-token.test.ts +0 -2
  33. package/src/__tests__/ingress-config.test.ts +9 -95
  34. package/src/__tests__/multi-local.test.ts +8 -5
  35. package/src/__tests__/nginx-ingress.test.ts +25 -31
  36. package/src/__tests__/ngrok-spawn.test.ts +2 -1
  37. package/src/__tests__/pair.test.ts +0 -44
  38. package/src/__tests__/ps-cloud-status.test.ts +6 -2
  39. package/src/__tests__/root-backup-docker.test.ts +51 -2
  40. package/src/__tests__/root-process-lockfile.test.ts +0 -15
  41. package/src/__tests__/sleep.test.ts +0 -39
  42. package/src/__tests__/tailscale.test.ts +48 -79
  43. package/src/__tests__/teleport.test.ts +1 -1
  44. package/src/__tests__/tui-midsession-refresh.test.ts +7 -5
  45. package/src/__tests__/tunnel-stop.test.ts +2 -25
  46. package/src/__tests__/tunnel.test.ts +271 -25
  47. package/src/__tests__/wake.test.ts +157 -140
  48. package/src/commands/app.ts +10 -5
  49. package/src/commands/client.ts +3 -1269
  50. package/src/commands/completions.ts +2 -2
  51. package/src/commands/devices.ts +1 -12
  52. package/src/commands/logs.ts +2 -111
  53. package/src/commands/pair.ts +5 -51
  54. package/src/commands/ps.ts +19 -54
  55. package/src/commands/restore.ts +1 -4
  56. package/src/commands/retire.ts +4 -35
  57. package/src/commands/sleep.ts +5 -11
  58. package/src/commands/terminal.ts +1 -30
  59. package/src/commands/tunnel.ts +25 -23
  60. package/src/commands/uninstall.ts +4 -2
  61. package/src/commands/upgrade.ts +20 -11
  62. package/src/commands/wake.ts +6 -12
  63. package/src/components/DefaultMainScreen.tsx +5 -5
  64. package/src/lib/assistant-config.ts +53 -325
  65. package/src/lib/detached-process.ts +3 -3
  66. package/src/lib/ensure-binary.ts +1 -1
  67. package/src/lib/exec-apple-container.ts +1 -1
  68. package/src/lib/ingress-config.ts +15 -51
  69. package/src/lib/nginx-ingress.ts +11 -21
  70. package/src/lib/retire-apple-container.ts +1 -1
  71. package/src/lib/root-backup.ts +50 -1
  72. package/src/lib/ssh-apple-container.ts +1 -1
  73. package/src/lib/tunnel.ts +127 -106
  74. package/src/lib/tunnels/cloudflare.ts +2 -3
  75. package/src/lib/tunnels/ngrok.ts +14 -4
  76. package/src/lib/tunnels/process-lifecycle.ts +1 -5
  77. package/src/lib/tunnels/tailscale.ts +50 -38
  78. package/node_modules/@mycadet/assistant-api/surfaces-oauth-connect.test.ts +0 -96
  79. package/src/__tests__/client-web-config.test.ts +0 -37
  80. package/src/__tests__/paired-lifecycle.test.ts +0 -115
  81. package/src/lib/aws.ts +0 -90
  82. package/src/lib/gcp.ts +0 -102
@@ -936,8 +936,6 @@ export {
936
936
  ListSurfaceDataSchema,
937
937
  MODEL_INVOKABLE_SURFACE_TYPES,
938
938
  normalizeCopyBlockShowData,
939
- type OAuthConnectSurfaceData,
940
- OAuthConnectSurfaceDataSchema,
941
939
  SURFACE_DATA_SCHEMAS,
942
940
  SURFACE_TYPES,
943
941
  type SurfaceData,
@@ -101,14 +101,14 @@ export interface RemoteWebPairingRequestSummary {
101
101
  /**
102
102
  * Client IP of the mint request: the loopback/host address when minted
103
103
  * locally, or the edge-observed client address when the mint arrived
104
- * through the nginx tunnel edge (which stamps it via `proxy_set_header`,
104
+ * through the nginx app server (which stamps it via `proxy_set_header`,
105
105
  * so a remote client cannot smuggle a value).
106
106
  */
107
107
  requesterIp: string;
108
108
  /** User-Agent header of the mint request, or null when absent. */
109
109
  requesterUserAgent: string | null;
110
110
  /**
111
- * Whether the mint arrived through the public tunnel edge rather than the
111
+ * Whether the mint arrived through the public app server rather than the
112
112
  * host itself.
113
113
  */
114
114
  viaEdgeProxy: boolean;
@@ -263,45 +263,6 @@ export const ChoiceSurfaceDataSchema = z.object({
263
263
  });
264
264
  export type ChoiceSurfaceData = z.infer<typeof ChoiceSurfaceDataSchema>;
265
265
 
266
- /**
267
- * Requested OAuth scopes for an `oauth_connect` surface.
268
- *
269
- * Unlike `FileUploadAcceptedTypesSchema`, a bare string is NOT split on
270
- * commas: OAuth scopes are opaque URIs, so only arrays are accepted.
271
- * Entries are stringified and trimmed, blanks are dropped, and an empty
272
- * result or any non-array value collapses to `undefined` (use defaults).
273
- */
274
- const RequestedScopesSchema = z.preprocess(
275
- (value) => (Array.isArray(value) ? cleanedStringEntries(value) : undefined),
276
- z.array(z.string()).optional(),
277
- );
278
-
279
- export const OAuthConnectSurfaceDataSchema = z.object({
280
- /** OAuth provider key from the cloud provider catalog, e.g. "google". */
281
- providerKey: z
282
- .preprocess(
283
- (value) => (typeof value === "string" ? value.trim() : value),
284
- z.string(),
285
- )
286
- .catch(""),
287
- /**
288
- * Optional OAuth scopes to request for the cloud connection. A full
289
- * replacement set: when present, the cloud uses exactly these scopes
290
- * instead of its defaults (it does not merge). Omit to use the cloud's
291
- * default scopes for the provider.
292
- */
293
- requestedScopes: RequestedScopesSchema,
294
- /** Optional display label. The client falls back to the provider catalog. */
295
- displayName: tolerantString(),
296
- /** Optional helper text. The client falls back to the provider catalog. */
297
- description: tolerantString(),
298
- /** Optional provider logo URL. The client falls back to the provider catalog. */
299
- logoUrl: z.string().nullable().optional().catch(undefined),
300
- });
301
- export type OAuthConnectSurfaceData = z.infer<
302
- typeof OAuthConnectSurfaceDataSchema
303
- >;
304
-
305
266
  export const FormFieldSchema = z.object({
306
267
  id: z.string().catch(""),
307
268
  type: z
@@ -691,7 +652,6 @@ export const SURFACE_TYPES = [
691
652
  "channel_setup",
692
653
  "choice",
693
654
  "copy_block",
694
- "oauth_connect",
695
655
  "form",
696
656
  "list",
697
657
  "table",
@@ -754,7 +714,6 @@ export type SurfaceData =
754
714
  | CardSurfaceData
755
715
  | ChoiceSurfaceData
756
716
  | CopyBlockSurfaceData
757
- | OAuthConnectSurfaceData
758
717
  | FormSurfaceData
759
718
  | ListSurfaceData
760
719
  | TableSurfaceData
@@ -786,7 +745,6 @@ export interface SurfaceDataByType {
786
745
  channel_setup: Record<string, unknown>;
787
746
  choice: ChoiceSurfaceData;
788
747
  copy_block: CopyBlockSurfaceData;
789
- oauth_connect: OAuthConnectSurfaceData;
790
748
  form: FormSurfaceData;
791
749
  list: ListSurfaceData;
792
750
  table: TableSurfaceData;
@@ -820,7 +778,6 @@ export const SURFACE_DATA_SCHEMAS: {
820
778
  channel_setup: z.record(z.string(), z.unknown()),
821
779
  choice: ChoiceSurfaceDataSchema,
822
780
  copy_block: CopyBlockSurfaceDataSchema,
823
- oauth_connect: OAuthConnectSurfaceDataSchema,
824
781
  form: FormSurfaceDataSchema,
825
782
  list: ListSurfaceDataSchema,
826
783
  table: TableSurfaceDataSchema,
@@ -101,14 +101,14 @@ export interface RemoteWebPairingRequestSummary {
101
101
  /**
102
102
  * Client IP of the mint request: the loopback/host address when minted
103
103
  * locally, or the edge-observed client address when the mint arrived
104
- * through the nginx tunnel edge (which stamps it via `proxy_set_header`,
104
+ * through the nginx app server (which stamps it via `proxy_set_header`,
105
105
  * so a remote client cannot smuggle a value).
106
106
  */
107
107
  requesterIp: string;
108
108
  /** User-Agent header of the mint request, or null when absent. */
109
109
  requesterUserAgent: string | null;
110
110
  /**
111
- * Whether the mint arrived through the public tunnel edge rather than the
111
+ * Whether the mint arrived through the public app server rather than the
112
112
  * host itself.
113
113
  */
114
114
  viaEdgeProxy: boolean;
@@ -19,80 +19,133 @@ const rejection = {
19
19
  } as const;
20
20
 
21
21
  const loopback = (port: number) => ({ kind: "loopback", port }) as const;
22
- const remote = (runtimeUrl: string) => ({ kind: "remote", runtimeUrl }) as const;
22
+ const remote = (runtimeUrl: string) =>
23
+ ({ kind: "remote", runtimeUrl }) as const;
23
24
 
24
25
  const targets =
25
- (map: Record<string, { kind: "loopback"; port: number } | { kind: "remote"; runtimeUrl: string }>) =>
26
+ (
27
+ map: Record<
28
+ string,
29
+ | { kind: "loopback"; port: number }
30
+ | { kind: "remote"; runtimeUrl: string }
31
+ >,
32
+ ) =>
26
33
  () =>
27
34
  new Map(Object.entries(map));
28
35
 
29
36
  describe("parseAssistantGatewayUrl", () => {
30
- test("parses the unified id-keyed path", () => {
37
+ test("parses the scoped SDK surface and forwards the full path", () => {
38
+ expect(parseAssistantGatewayUrl("/v1/assistants/abc-123")).toEqual({
39
+ match: true,
40
+ valid: true,
41
+ legacy: false,
42
+ target: {
43
+ assistantId: "abc-123",
44
+ path: "/v1/assistants/abc-123",
45
+ search: "",
46
+ },
47
+ });
31
48
  expect(
32
- parseAssistantGatewayUrl("/__gateway/abc-123/v1/assistants"),
49
+ parseAssistantGatewayUrl("/v1/assistants/abc-123/conversations"),
33
50
  ).toEqual({
34
51
  match: true,
35
52
  valid: true,
36
- target: { assistantId: "abc-123", path: "/v1/assistants", search: "" },
53
+ legacy: false,
54
+ target: {
55
+ assistantId: "abc-123",
56
+ path: "/v1/assistants/abc-123/conversations",
57
+ search: "",
58
+ },
37
59
  });
38
60
  });
39
61
 
40
- test("accepts the renderer's `/assistant` mount prefix", () => {
41
- expect(
42
- parseAssistantGatewayUrl("/assistant/__gateway/abc-123/auth/token"),
43
- ).toEqual({
62
+ test("forwards the scoped readyz tail to the gateway's root probe", () => {
63
+ expect(parseAssistantGatewayUrl("/v1/assistants/abc-123/readyz")).toEqual({
44
64
  match: true,
45
65
  valid: true,
46
- target: { assistantId: "abc-123", path: "/auth/token", search: "" },
66
+ legacy: false,
67
+ target: { assistantId: "abc-123", path: "/readyz", search: "" },
47
68
  });
48
69
  });
49
70
 
50
- test("accepts the deprecated `-paired` alias with identical semantics", () => {
71
+ test("preserves the query and drops the fragment on the scoped surface", () => {
51
72
  expect(
52
- parseAssistantGatewayUrl("/assistant/__gateway-paired/abc-123/v1"),
53
- ).toEqual(
54
- parseAssistantGatewayUrl("/assistant/__gateway/abc-123/v1"),
55
- );
56
- expect(parseAssistantGatewayUrl("/__gateway-paired/abc-123")).toEqual({
73
+ parseAssistantGatewayUrl("/v1/assistants/abc-123/messages?x=1#frag"),
74
+ ).toEqual({
57
75
  match: true,
58
76
  valid: true,
59
- target: { assistantId: "abc-123", path: "/", search: "" },
77
+ legacy: false,
78
+ target: {
79
+ assistantId: "abc-123",
80
+ path: "/v1/assistants/abc-123/messages",
81
+ search: "?x=1",
82
+ },
60
83
  });
61
84
  });
62
85
 
63
- test("preserves the query and drops the fragment", () => {
86
+ test("flattens the contact family to the gateway's flat routes", () => {
64
87
  expect(
65
- parseAssistantGatewayUrl("/__gateway/abc-123/v1/messages?x=1#frag"),
88
+ parseAssistantGatewayUrl("/v1/assistants/abc-123/contacts/x"),
66
89
  ).toEqual({
67
90
  match: true,
68
91
  valid: true,
92
+ legacy: false,
69
93
  target: {
70
94
  assistantId: "abc-123",
71
- path: "/v1/messages",
72
- search: "?x=1",
95
+ path: "/v1/contacts/x",
96
+ search: "",
97
+ },
98
+ });
99
+ expect(
100
+ parseAssistantGatewayUrl("/v1/assistants/abc-123/contact-channels/y?z=1"),
101
+ ).toEqual({
102
+ match: true,
103
+ valid: true,
104
+ legacy: false,
105
+ target: {
106
+ assistantId: "abc-123",
107
+ path: "/v1/contact-channels/y",
108
+ search: "?z=1",
73
109
  },
74
110
  });
75
111
  });
76
112
 
77
- test("decodes a percent-encoded id", () => {
78
- expect(parseAssistantGatewayUrl("/__gateway/a%20b/v1")).toEqual({
113
+ test("parses the legacy unscoped prefix and forwards the tail", () => {
114
+ expect(parseAssistantGatewayUrl("/__gateway/abc-123/auth/token")).toEqual({
115
+ match: true,
116
+ valid: true,
117
+ legacy: true,
118
+ target: { assistantId: "abc-123", path: "/auth/token", search: "" },
119
+ });
120
+ expect(
121
+ parseAssistantGatewayUrl("/assistant/__gateway/abc-123/readyz"),
122
+ ).toEqual({
79
123
  match: true,
80
124
  valid: true,
81
- target: { assistantId: "a b", path: "/v1", search: "" },
125
+ legacy: true,
126
+ target: { assistantId: "abc-123", path: "/readyz", search: "" },
82
127
  });
83
128
  });
84
129
 
85
- test("rejects dot-segment tails (raw and percent-encoded)", () => {
86
- expect(parseAssistantGatewayUrl("/__gateway/abc/../secret")).toMatchObject({
130
+ test("rejects dot segments on both shapes (raw and percent-encoded)", () => {
131
+ expect(parseAssistantGatewayUrl("/v1/assistants/../secret")).toMatchObject({
87
132
  match: true,
88
133
  valid: false,
89
134
  });
90
135
  expect(
91
- parseAssistantGatewayUrl("/__gateway/abc/%2e%2e/secret"),
136
+ parseAssistantGatewayUrl("/v1/assistants/abc/%2e%2e/secret"),
92
137
  ).toMatchObject({ match: true, valid: false });
138
+ expect(parseAssistantGatewayUrl("/__gateway/abc/../secret")).toMatchObject({
139
+ match: true,
140
+ valid: false,
141
+ });
93
142
  });
94
143
 
95
144
  test("rejects malformed percent-encoding as an invalid parse", () => {
145
+ expect(parseAssistantGatewayUrl("/v1/assistants/%zz/x")).toEqual({
146
+ match: true,
147
+ valid: false,
148
+ });
96
149
  expect(parseAssistantGatewayUrl("/__gateway/%zz/v1")).toEqual({
97
150
  match: true,
98
151
  valid: false,
@@ -122,37 +175,71 @@ describe("resolveGatewayProxyTarget", () => {
122
175
  ).toEqual({ kind: "pass" });
123
176
  });
124
177
 
125
- test("forwards an active loopback id to its port target", () => {
178
+ test("forwards a scoped path for an active loopback id to its port", () => {
126
179
  expect(
127
- resolveGatewayProxyTarget("/__gateway/abc-123/v1/assistants", entry),
180
+ resolveGatewayProxyTarget("/v1/assistants/abc-123/conversations", entry),
128
181
  ).toEqual({
129
182
  kind: "forward",
130
183
  assistantId: "abc-123",
131
- path: "/v1/assistants",
184
+ path: "/v1/assistants/abc-123/conversations",
132
185
  search: "",
133
186
  target: loopback(8080),
134
187
  });
135
188
  });
136
189
 
137
- test("forwards an imported pairing to its recorded runtimeUrl", () => {
190
+ test("forwards a scoped path for an imported pairing to its runtimeUrl", () => {
138
191
  expect(
139
- resolveGatewayProxyTarget("/__gateway/def-456/v1/messages?x=1", entry),
192
+ resolveGatewayProxyTarget("/v1/assistants/def-456/messages?x=1", entry),
140
193
  ).toEqual({
141
194
  kind: "forward",
142
195
  assistantId: "def-456",
143
- path: "/v1/messages",
196
+ path: "/v1/assistants/def-456/messages",
144
197
  search: "?x=1",
145
198
  target: remote("https://gw.example.com"),
146
199
  });
147
200
  });
148
201
 
149
- test("rejects an id that is not active in the lockfile", () => {
202
+ test("flattens the contact family in the forward path", () => {
203
+ expect(
204
+ resolveGatewayProxyTarget("/v1/assistants/abc-123/contacts/x", entry),
205
+ ).toEqual({
206
+ kind: "forward",
207
+ assistantId: "abc-123",
208
+ path: "/v1/contacts/x",
209
+ search: "",
210
+ target: loopback(8080),
211
+ });
212
+ });
213
+
214
+ test("passes an unknown id on the scoped surface through", () => {
215
+ // Cloud assistants and stale ids ride the host's generic /v1 handling.
216
+ expect(
217
+ resolveGatewayProxyTarget("/v1/assistants/zzz-999/messages", entry),
218
+ ).toEqual({ kind: "pass" });
219
+ expect(
220
+ resolveGatewayProxyTarget("/v1/assistants/zzz-999/x", targets({})),
221
+ ).toEqual({ kind: "pass" });
222
+ });
223
+
224
+ test("forwards the legacy prefix for unscoped gateway routes", () => {
225
+ expect(
226
+ resolveGatewayProxyTarget("/__gateway/abc-123/auth/token", entry),
227
+ ).toEqual({
228
+ kind: "forward",
229
+ assistantId: "abc-123",
230
+ path: "/auth/token",
231
+ search: "",
232
+ target: loopback(8080),
233
+ });
234
+ });
235
+
236
+ test("rejects an unknown id on the legacy prefix", () => {
150
237
  expect(resolveGatewayProxyTarget("/__gateway/zzz-999/v1", entry)).toEqual(
151
238
  rejection,
152
239
  );
153
- expect(resolveGatewayProxyTarget("/__gateway/abc/../secret", entry)).toEqual(
154
- rejection,
155
- );
240
+ expect(
241
+ resolveGatewayProxyTarget("/__gateway/abc/../secret", entry),
242
+ ).toEqual(rejection);
156
243
  });
157
244
  });
158
245
 
@@ -161,20 +248,22 @@ describe("gatewayTargetsFromLockfile", () => {
161
248
  expect(
162
249
  gatewayTargetsFromLockfile({
163
250
  assistants: [
164
- { assistantId: "abc-123", cloud: "paired", runtimeUrl: "https://gw.example.com" },
251
+ {
252
+ assistantId: "abc-123",
253
+ paired: true,
254
+ runtimeUrl: "https://gw.example.com",
255
+ },
165
256
  ],
166
257
  }),
167
- ).toEqual(
168
- targets({ "abc-123": remote("https://gw.example.com") })(),
169
- );
258
+ ).toEqual(targets({ "abc-123": remote("https://gw.example.com") })());
170
259
  });
171
260
 
172
261
  test("omits a paired entry whose runtimeUrl is unusable", () => {
173
262
  expect(
174
263
  gatewayTargetsFromLockfile({
175
264
  assistants: [
176
- { assistantId: "abc-123", cloud: "paired", runtimeUrl: "not a url" },
177
- { assistantId: "def-456", cloud: "paired" },
265
+ { assistantId: "abc-123", paired: true, runtimeUrl: "not a url" },
266
+ { assistantId: "def-456", paired: true },
178
267
  ],
179
268
  }),
180
269
  ).toEqual(new Map());
@@ -187,7 +276,7 @@ describe("gatewayTargetsFromLockfile", () => {
187
276
  {
188
277
  assistantId: "abc-123",
189
278
  cloud: "local",
190
- resources: { gatewayPort: 8080 },
279
+ resources: { gatewayPort: 8080, daemonPort: 8501 },
191
280
  },
192
281
  ],
193
282
  }),
@@ -208,7 +297,10 @@ describe("gatewayTargetsFromLockfile", () => {
208
297
  ).toEqual(new Map([["abc-123", loopback(9000)]]));
209
298
  });
210
299
 
211
- test("omits a local entry whose runtimeUrl is remote", () => {
300
+ test("resolves a loopback-cloud entry whose runtimeUrl is remote as paired", () => {
301
+ // Paired-ness derives from the addressing (no stored flag): a
302
+ // loopback-gateway cloud whose runtimeUrl points off-machine is a
303
+ // connect import, so it targets that remote runtimeUrl.
212
304
  expect(
213
305
  gatewayTargetsFromLockfile({
214
306
  assistants: [
@@ -219,7 +311,14 @@ describe("gatewayTargetsFromLockfile", () => {
219
311
  },
220
312
  ],
221
313
  }),
222
- ).toEqual(new Map());
314
+ ).toEqual(
315
+ new Map([
316
+ [
317
+ "abc-123",
318
+ { kind: "remote", runtimeUrl: "https://elsewhere.example.com" },
319
+ ],
320
+ ]),
321
+ );
223
322
  });
224
323
 
225
324
  test("omits ports outside the 1024-65535 proxy range", () => {
@@ -229,7 +328,7 @@ describe("gatewayTargetsFromLockfile", () => {
229
328
  {
230
329
  assistantId: "abc-123",
231
330
  cloud: "local",
232
- resources: { gatewayPort: 80 },
331
+ resources: { gatewayPort: 80, daemonPort: 8501 },
233
332
  },
234
333
  {
235
334
  assistantId: "def-456",
@@ -245,16 +344,36 @@ describe("gatewayTargetsFromLockfile", () => {
245
344
  expect(
246
345
  gatewayTargetsFromLockfile({
247
346
  assistants: [
248
- { assistantId: "a", cloud: "cadet" },
347
+ { assistantId: "a", cloud: "cloud" },
249
348
  { assistantId: "b", cloud: "apple-container" },
250
- { assistantId: "c", cloud: "gcp", runtimeUrl: "https://gw.example.com" },
251
- { assistantId: "d", cloud: "aws", runtimeUrl: "https://gw.example.com" },
252
- { assistantId: "e", cloud: "custom", runtimeUrl: "https://gw.example.com" },
349
+ // A retired spelling parses as "local": loopback-gated, and with no
350
+ // loopback port it is omitted.
351
+ { assistantId: "d", cloud: "gcp" },
253
352
  ],
254
353
  }),
255
354
  ).toEqual(new Map());
256
355
  });
257
356
 
357
+ test("a custom entry's off-machine runtimeUrl is targetable by addressing", () => {
358
+ // Targeting keys on the addressing alone: an entry whose runtimeUrl
359
+ // points off this machine resolves as remote, whatever its cloud says.
360
+ expect(
361
+ gatewayTargetsFromLockfile({
362
+ assistants: [
363
+ {
364
+ assistantId: "c",
365
+ cloud: "custom",
366
+ runtimeUrl: "https://gw.example.com",
367
+ },
368
+ ],
369
+ }),
370
+ ).toEqual(
371
+ new Map([
372
+ ["c", { kind: "remote", runtimeUrl: "https://gw.example.com" }],
373
+ ]),
374
+ );
375
+ });
376
+
258
377
  test("tolerates malformed entries", () => {
259
378
  expect(
260
379
  gatewayTargetsFromLockfile({
@@ -262,11 +381,11 @@ describe("gatewayTargetsFromLockfile", () => {
262
381
  null,
263
382
  42,
264
383
  { noId: true },
265
- { assistantId: "", cloud: "paired" },
384
+ { assistantId: "", paired: true },
266
385
  {
267
386
  assistantId: "abc-123",
268
387
  cloud: "local",
269
- resources: { gatewayPort: 8080 },
388
+ resources: { gatewayPort: 8080, daemonPort: 8501 },
270
389
  },
271
390
  ],
272
391
  }),
@@ -285,11 +404,11 @@ describe("readGatewayTargets", () => {
285
404
  {
286
405
  assistantId: "abc-123",
287
406
  cloud: "local",
288
- resources: { gatewayPort: 8080 },
407
+ resources: { gatewayPort: 8080, daemonPort: 8501 },
289
408
  },
290
409
  {
291
410
  assistantId: "def-456",
292
- cloud: "paired",
411
+ paired: true,
293
412
  runtimeUrl: "https://gw.example.com",
294
413
  },
295
414
  ],
@@ -316,7 +435,7 @@ describe("readGatewayTargets", () => {
316
435
  {
317
436
  assistantId: "abc-123",
318
437
  cloud: "local",
319
- resources: { gatewayPort: 8080 },
438
+ resources: { gatewayPort: 8080, daemonPort: 8501 },
320
439
  },
321
440
  ],
322
441
  }),
@@ -337,7 +456,7 @@ describe("readGatewayTargets", () => {
337
456
  {
338
457
  assistantId: "abc-123",
339
458
  cloud: "local",
340
- resources: { gatewayPort: 8080 },
459
+ resources: { gatewayPort: 8080, daemonPort: 8501 },
341
460
  },
342
461
  ],
343
462
  }),
@@ -10,10 +10,10 @@ import {
10
10
  PAIRED_GUARDIAN_TARGET_MISMATCH_ERROR,
11
11
  PAIRED_GUARDIAN_TOKEN_HOST_ONLY_ERROR,
12
12
  isConfidentialRefreshUrl,
13
- isLoopbackUrl,
14
13
  saveGuardianToken,
15
14
  type GuardianTokenData,
16
15
  } from "../guardian-token";
16
+ import { isLoopbackPublicUrl } from "@mycadet/service-contracts/remote-web-pairing";
17
17
  import type { CliInvocation } from "../util";
18
18
 
19
19
  // An invocation that would fail loudly if any tested branch spawned the CLI.
@@ -278,7 +278,7 @@ describe("isConfidentialRefreshUrl", () => {
278
278
  // The pairing side still refuses it as loopback: a name that might be
279
279
  // local is refused by the guards that refuse loopback and denied by the
280
280
  // guards that reward it.
281
- expect(isLoopbackUrl(url)).toBe(true);
281
+ expect(isLoopbackPublicUrl(url)).toBe(true);
282
282
  }
283
283
  });
284
284