@mycadet/cli 0.13.0-dev.202610221914.02130b1 → 0.13.0-dev.202610231952.fa65022
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/node_modules/@mycadet/assistant-api/events/conversation-error.ts +1 -1
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/cloud-credential.ts +5 -5
- package/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +6 -6
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/cloud-credential.ts +5 -5
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +6 -6
- package/node_modules/@mycadet/local-mode/src/__tests__/gateway-proxy.test.ts +1 -53
- package/node_modules/@mycadet/local-mode/src/__tests__/pair.test.ts +2 -1
- package/node_modules/@mycadet/local-mode/src/gateway-proxy.ts +17 -65
- package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +1 -5
- package/node_modules/@mycadet/local-mode/src/pair.ts +3 -5
- package/node_modules/@mycadet/service-contracts/src/cloud-credential.ts +5 -5
- package/node_modules/@mycadet/service-contracts/src/remote-web-pairing.ts +6 -6
- package/node_modules/@mycadet/shared/version.ts +15 -2
- package/package.json +1 -1
- package/src/__tests__/cloud-client.test.ts +0 -3
- package/src/__tests__/cloud-releases.test.ts +1 -29
- package/src/__tests__/ingress-config.test.ts +0 -14
- package/src/__tests__/ngrok-spawn.test.ts +0 -86
- package/src/__tests__/pair.test.ts +17 -340
- package/src/__tests__/wake.test.ts +9 -5
- package/src/commands/app.ts +1 -1
- package/src/commands/pair.ts +7 -54
- package/src/commands/retire.ts +1 -5
- package/src/commands/tunnel.ts +3 -58
- package/src/commands/upgrade.ts +3 -5
- package/src/lib/cloud-client.ts +6 -9
- package/src/lib/cloud-releases.ts +8 -42
- package/src/lib/ingress-config.ts +0 -8
- package/src/lib/lan-ip.ts +50 -0
- package/src/lib/local.ts +1 -50
- package/src/lib/nginx-ingress.ts +1 -1
- package/src/lib/runtime-url.ts +1 -1
- package/src/lib/terminal-client.ts +1 -1
- package/src/lib/tunnel.ts +19 -20
- package/src/lib/tunnels/ngrok.ts +13 -73
|
@@ -36,7 +36,7 @@ export const ConversationErrorCodeSchema = z.enum([
|
|
|
36
36
|
"PROVIDER_WEB_SEARCH",
|
|
37
37
|
"PROVIDER_NOT_CONFIGURED",
|
|
38
38
|
"PROVIDER_INVALID_KEY",
|
|
39
|
-
"
|
|
39
|
+
"CLOUD_KEY_INVALID",
|
|
40
40
|
"CONTEXT_TOO_LARGE",
|
|
41
41
|
"BUDGET_YIELD_UNRECOVERED",
|
|
42
42
|
"MAX_TOKENS_REACHED",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* credential still authenticates.
|
|
4
4
|
*
|
|
5
5
|
* The daemon route is the authoritative serving side:
|
|
6
|
-
* - `POST /v1/
|
|
6
|
+
* - `POST /v1/cloud/verify-credential`
|
|
7
7
|
* (`assistant/src/runtime/routes/cloud-routes.ts`)
|
|
8
8
|
*
|
|
9
9
|
* The daemon's platform client produces the verdict, the route reports it,
|
|
@@ -32,10 +32,10 @@ export type CloudCredentialVerificationStatus = z.infer<
|
|
|
32
32
|
typeof CloudCredentialVerificationStatusSchema
|
|
33
33
|
>;
|
|
34
34
|
|
|
35
|
-
/** `POST /v1/
|
|
36
|
-
export const
|
|
35
|
+
/** `POST /v1/cloud/verify-credential` response body. */
|
|
36
|
+
export const CloudVerifyCredentialResponseSchema = z.object({
|
|
37
37
|
status: CloudCredentialVerificationStatusSchema,
|
|
38
38
|
});
|
|
39
|
-
export type
|
|
40
|
-
typeof
|
|
39
|
+
export type CloudVerifyCredentialResponse = z.infer<
|
|
40
|
+
typeof CloudVerifyCredentialResponseSchema
|
|
41
41
|
>;
|
|
@@ -37,12 +37,6 @@
|
|
|
37
37
|
*/
|
|
38
38
|
export const REMOTE_WEB_PAIRING_CODE_TTL_MS = 10 * 60 * 1000;
|
|
39
39
|
|
|
40
|
-
/** `POST /v1/remote-web/pairing-challenge` request body. */
|
|
41
|
-
export interface RemoteWebPairingChallengeRequest {
|
|
42
|
-
/** Public https base URL the scanning device can reach the assistant at. */
|
|
43
|
-
publicBaseUrl: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
40
|
/** `POST /v1/remote-web/pairing-challenge` success response body (200). */
|
|
47
41
|
export interface RemoteWebPairingChallengeResponse {
|
|
48
42
|
/** Opaque secret the paired device exchanges for a token. */
|
|
@@ -51,6 +45,12 @@ export interface RemoteWebPairingChallengeResponse {
|
|
|
51
45
|
userCode: string;
|
|
52
46
|
/** URL the device opens to complete pairing. */
|
|
53
47
|
verificationUri: string;
|
|
48
|
+
/**
|
|
49
|
+
* The base URL the challenge was minted for (echoed into verificationUri).
|
|
50
|
+
* The gateway self-sources it — the request's own host through the trusted
|
|
51
|
+
* edge, else its recorded ingress URL; callers cannot request a URL.
|
|
52
|
+
*/
|
|
53
|
+
publicBaseUrl: string;
|
|
54
54
|
/** ISO-8601 instant the challenge expires. */
|
|
55
55
|
expiresAt: string;
|
|
56
56
|
/** Seconds until the challenge expires. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* credential still authenticates.
|
|
4
4
|
*
|
|
5
5
|
* The daemon route is the authoritative serving side:
|
|
6
|
-
* - `POST /v1/
|
|
6
|
+
* - `POST /v1/cloud/verify-credential`
|
|
7
7
|
* (`assistant/src/runtime/routes/cloud-routes.ts`)
|
|
8
8
|
*
|
|
9
9
|
* The daemon's platform client produces the verdict, the route reports it,
|
|
@@ -32,10 +32,10 @@ export type CloudCredentialVerificationStatus = z.infer<
|
|
|
32
32
|
typeof CloudCredentialVerificationStatusSchema
|
|
33
33
|
>;
|
|
34
34
|
|
|
35
|
-
/** `POST /v1/
|
|
36
|
-
export const
|
|
35
|
+
/** `POST /v1/cloud/verify-credential` response body. */
|
|
36
|
+
export const CloudVerifyCredentialResponseSchema = z.object({
|
|
37
37
|
status: CloudCredentialVerificationStatusSchema,
|
|
38
38
|
});
|
|
39
|
-
export type
|
|
40
|
-
typeof
|
|
39
|
+
export type CloudVerifyCredentialResponse = z.infer<
|
|
40
|
+
typeof CloudVerifyCredentialResponseSchema
|
|
41
41
|
>;
|
|
@@ -37,12 +37,6 @@
|
|
|
37
37
|
*/
|
|
38
38
|
export const REMOTE_WEB_PAIRING_CODE_TTL_MS = 10 * 60 * 1000;
|
|
39
39
|
|
|
40
|
-
/** `POST /v1/remote-web/pairing-challenge` request body. */
|
|
41
|
-
export interface RemoteWebPairingChallengeRequest {
|
|
42
|
-
/** Public https base URL the scanning device can reach the assistant at. */
|
|
43
|
-
publicBaseUrl: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
40
|
/** `POST /v1/remote-web/pairing-challenge` success response body (200). */
|
|
47
41
|
export interface RemoteWebPairingChallengeResponse {
|
|
48
42
|
/** Opaque secret the paired device exchanges for a token. */
|
|
@@ -51,6 +45,12 @@ export interface RemoteWebPairingChallengeResponse {
|
|
|
51
45
|
userCode: string;
|
|
52
46
|
/** URL the device opens to complete pairing. */
|
|
53
47
|
verificationUri: string;
|
|
48
|
+
/**
|
|
49
|
+
* The base URL the challenge was minted for (echoed into verificationUri).
|
|
50
|
+
* The gateway self-sources it — the request's own host through the trusted
|
|
51
|
+
* edge, else its recorded ingress URL; callers cannot request a URL.
|
|
52
|
+
*/
|
|
53
|
+
publicBaseUrl: string;
|
|
54
54
|
/** ISO-8601 instant the challenge expires. */
|
|
55
55
|
expiresAt: string;
|
|
56
56
|
/** Seconds until the challenge expires. */
|
|
@@ -38,7 +38,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
38
38
|
expect(parseAssistantGatewayUrl("/v1/assistants/abc-123")).toEqual({
|
|
39
39
|
match: true,
|
|
40
40
|
valid: true,
|
|
41
|
-
legacy: false,
|
|
42
41
|
target: {
|
|
43
42
|
assistantId: "abc-123",
|
|
44
43
|
path: "/v1/assistants/abc-123",
|
|
@@ -50,7 +49,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
50
49
|
).toEqual({
|
|
51
50
|
match: true,
|
|
52
51
|
valid: true,
|
|
53
|
-
legacy: false,
|
|
54
52
|
target: {
|
|
55
53
|
assistantId: "abc-123",
|
|
56
54
|
path: "/v1/assistants/abc-123/conversations",
|
|
@@ -63,7 +61,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
63
61
|
expect(parseAssistantGatewayUrl("/v1/assistants/abc-123/readyz")).toEqual({
|
|
64
62
|
match: true,
|
|
65
63
|
valid: true,
|
|
66
|
-
legacy: false,
|
|
67
64
|
target: { assistantId: "abc-123", path: "/readyz", search: "" },
|
|
68
65
|
});
|
|
69
66
|
});
|
|
@@ -74,7 +71,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
74
71
|
).toEqual({
|
|
75
72
|
match: true,
|
|
76
73
|
valid: true,
|
|
77
|
-
legacy: false,
|
|
78
74
|
target: {
|
|
79
75
|
assistantId: "abc-123",
|
|
80
76
|
path: "/v1/assistants/abc-123/messages",
|
|
@@ -89,7 +85,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
89
85
|
).toEqual({
|
|
90
86
|
match: true,
|
|
91
87
|
valid: true,
|
|
92
|
-
legacy: false,
|
|
93
88
|
target: {
|
|
94
89
|
assistantId: "abc-123",
|
|
95
90
|
path: "/v1/contacts/x",
|
|
@@ -101,7 +96,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
101
96
|
).toEqual({
|
|
102
97
|
match: true,
|
|
103
98
|
valid: true,
|
|
104
|
-
legacy: false,
|
|
105
99
|
target: {
|
|
106
100
|
assistantId: "abc-123",
|
|
107
101
|
path: "/v1/contact-channels/y",
|
|
@@ -110,24 +104,7 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
110
104
|
});
|
|
111
105
|
});
|
|
112
106
|
|
|
113
|
-
test("
|
|
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({
|
|
123
|
-
match: true,
|
|
124
|
-
valid: true,
|
|
125
|
-
legacy: true,
|
|
126
|
-
target: { assistantId: "abc-123", path: "/readyz", search: "" },
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test("rejects dot segments on both shapes (raw and percent-encoded)", () => {
|
|
107
|
+
test("rejects dot segments (raw and percent-encoded)", () => {
|
|
131
108
|
expect(parseAssistantGatewayUrl("/v1/assistants/../secret")).toMatchObject({
|
|
132
109
|
match: true,
|
|
133
110
|
valid: false,
|
|
@@ -135,10 +112,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
135
112
|
expect(
|
|
136
113
|
parseAssistantGatewayUrl("/v1/assistants/abc/%2e%2e/secret"),
|
|
137
114
|
).toMatchObject({ match: true, valid: false });
|
|
138
|
-
expect(parseAssistantGatewayUrl("/__gateway/abc/../secret")).toMatchObject({
|
|
139
|
-
match: true,
|
|
140
|
-
valid: false,
|
|
141
|
-
});
|
|
142
115
|
});
|
|
143
116
|
|
|
144
117
|
test("rejects malformed percent-encoding as an invalid parse", () => {
|
|
@@ -146,10 +119,6 @@ describe("parseAssistantGatewayUrl", () => {
|
|
|
146
119
|
match: true,
|
|
147
120
|
valid: false,
|
|
148
121
|
});
|
|
149
|
-
expect(parseAssistantGatewayUrl("/__gateway/%zz/v1")).toEqual({
|
|
150
|
-
match: true,
|
|
151
|
-
valid: false,
|
|
152
|
-
});
|
|
153
122
|
});
|
|
154
123
|
|
|
155
124
|
test("does not match unrelated paths", () => {
|
|
@@ -220,27 +189,6 @@ describe("resolveGatewayProxyTarget", () => {
|
|
|
220
189
|
resolveGatewayProxyTarget("/v1/assistants/zzz-999/x", targets({})),
|
|
221
190
|
).toEqual({ kind: "pass" });
|
|
222
191
|
});
|
|
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", () => {
|
|
237
|
-
expect(resolveGatewayProxyTarget("/__gateway/zzz-999/v1", entry)).toEqual(
|
|
238
|
-
rejection,
|
|
239
|
-
);
|
|
240
|
-
expect(
|
|
241
|
-
resolveGatewayProxyTarget("/__gateway/abc/../secret", entry),
|
|
242
|
-
).toEqual(rejection);
|
|
243
|
-
});
|
|
244
192
|
});
|
|
245
193
|
|
|
246
194
|
describe("gatewayTargetsFromLockfile", () => {
|
|
@@ -149,6 +149,7 @@ const challengeBody = (
|
|
|
149
149
|
): Record<string, unknown> => ({
|
|
150
150
|
deviceCode: "device-code-abc",
|
|
151
151
|
userCode: "ABCD-EFGH",
|
|
152
|
+
publicBaseUrl: "https://gw.example.com",
|
|
152
153
|
verificationUri: "https://gw.example.com/assistant/pair",
|
|
153
154
|
expiresAt: new Date(Date.now() + 600_000).toISOString(),
|
|
154
155
|
expiresInSeconds: 600,
|
|
@@ -720,7 +721,7 @@ describe("pairingStart", () => {
|
|
|
720
721
|
expect(fetchCalls).toEqual([
|
|
721
722
|
{
|
|
722
723
|
url: "https://gw.example.com/v1/remote-web/pairing-challenge",
|
|
723
|
-
body: {
|
|
724
|
+
body: {},
|
|
724
725
|
redirect: "error",
|
|
725
726
|
signal: expect.any(AbortSignal) as unknown as AbortSignal,
|
|
726
727
|
},
|
|
@@ -21,15 +21,8 @@ export { FLATTENED_FIRST_SEGMENTS };
|
|
|
21
21
|
* hatched gateways) or recorded remote `runtimeUrl` (imported pairings), so
|
|
22
22
|
* the renderer never encodes a port or a host and the local/paired split
|
|
23
23
|
* lives entirely host-side.
|
|
24
|
-
*
|
|
25
|
-
* The legacy `/assistant/__gateway/{assistantId}` prefix survives only as
|
|
26
|
-
* transport for the gateway's UNSCOPED routes (`/auth/token` mint, `/readyz`
|
|
27
|
-
* probes, the lifecycle trio) until they fold into `/v1` too; it forwards the
|
|
28
|
-
* tail after the prefix.
|
|
29
24
|
*/
|
|
30
25
|
const GATEWAY_PATTERN = /^\/v1\/assistants\/([^/?#]+)(?:\/(.*))?$/;
|
|
31
|
-
const LEGACY_GATEWAY_PATTERN =
|
|
32
|
-
/^(?:\/assistant)?\/__gateway\/([^/?#]+)(\/.*)?$/;
|
|
33
26
|
|
|
34
27
|
export interface GatewayTarget {
|
|
35
28
|
assistantId: string;
|
|
@@ -40,13 +33,7 @@ export interface GatewayTarget {
|
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
export type GatewayParseResult =
|
|
43
|
-
| {
|
|
44
|
-
match: true;
|
|
45
|
-
valid: true;
|
|
46
|
-
/** False for the scoped surface, true for the legacy prefix. */
|
|
47
|
-
legacy: boolean;
|
|
48
|
-
target: GatewayTarget;
|
|
49
|
-
}
|
|
36
|
+
| { match: true; valid: true; target: GatewayTarget }
|
|
50
37
|
| { match: true; valid: false }
|
|
51
38
|
| { match: false };
|
|
52
39
|
|
|
@@ -74,15 +61,11 @@ function hasDotSegment(path: string): boolean {
|
|
|
74
61
|
/**
|
|
75
62
|
* Parse an assistant gateway's data-plane URL given as `pathname + search` (a
|
|
76
63
|
* `#fragment` suffix is tolerated and dropped), so every host hands over the
|
|
77
|
-
* same shape and the decision is host-independent.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* so the gateway receives exactly what the SDK addressed;
|
|
83
|
-
* - the legacy `/assistant/__gateway/{assistantId}[/tail]` prefix (with or
|
|
84
|
-
* without the `/assistant` mount) — the forward path is the tail after
|
|
85
|
-
* the prefix, the transport for the gateway's unscoped routes.
|
|
64
|
+
* same shape and the decision is host-independent. The scoped SDK surface
|
|
65
|
+
* `/v1/assistants/{assistantId}[/rest]` parses: the forward path is the scoped
|
|
66
|
+
* path itself (flattened for the contact family; the `readyz` tail forwards
|
|
67
|
+
* to the gateway's root `/readyz`), so the gateway receives exactly what the
|
|
68
|
+
* SDK addressed.
|
|
86
69
|
*/
|
|
87
70
|
export function parseAssistantGatewayUrl(url: string): GatewayParseResult {
|
|
88
71
|
const delimiter = url.search(/[?#]/);
|
|
@@ -114,37 +97,10 @@ export function parseAssistantGatewayUrl(url: string): GatewayParseResult {
|
|
|
114
97
|
FLATTENED_FIRST_SEGMENTS.has(firstSegment)
|
|
115
98
|
? `/v1/${rest}`
|
|
116
99
|
: pathname;
|
|
117
|
-
return {
|
|
118
|
-
match: true,
|
|
119
|
-
valid: true,
|
|
120
|
-
legacy: false,
|
|
121
|
-
target: { assistantId, path, search },
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const legacy = LEGACY_GATEWAY_PATTERN.exec(pathname);
|
|
126
|
-
if (!legacy) {
|
|
127
|
-
return { match: false };
|
|
100
|
+
return { match: true, valid: true, target: { assistantId, path, search } };
|
|
128
101
|
}
|
|
129
102
|
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
assistantId = decodeURIComponent(legacy[1]!);
|
|
133
|
-
} catch {
|
|
134
|
-
return { match: true, valid: false };
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const path = legacy[2] || "/";
|
|
138
|
-
if (hasDotSegment(path)) {
|
|
139
|
-
return { match: true, valid: false };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
match: true,
|
|
144
|
-
valid: true,
|
|
145
|
-
legacy: true,
|
|
146
|
-
target: { assistantId, path, search },
|
|
147
|
-
};
|
|
103
|
+
return { match: false };
|
|
148
104
|
}
|
|
149
105
|
|
|
150
106
|
/**
|
|
@@ -164,15 +120,14 @@ export type GatewayEntryTarget =
|
|
|
164
120
|
* re-deriving the rules.
|
|
165
121
|
*
|
|
166
122
|
* - `pass` — not a gateway URL; the host serves it normally.
|
|
167
|
-
* - `reject` — a gateway URL whose id is malformed
|
|
168
|
-
* traversal attempt
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* `
|
|
174
|
-
*
|
|
175
|
-
* the status and message the host answers with.
|
|
123
|
+
* - `reject` — a gateway URL whose id is malformed or whose tail is a
|
|
124
|
+
* traversal attempt (the security boundary: the proxy only
|
|
125
|
+
* reaches gateways of assistants the user actually hatched
|
|
126
|
+
* or imported, never arbitrary loopback services or URLs).
|
|
127
|
+
* An unknown id is `pass` instead: cloud assistants' SDK
|
|
128
|
+
* routes and stale ids fall through to the host's generic
|
|
129
|
+
* `/v1` handling. Carries the status and message the host
|
|
130
|
+
* answers with.
|
|
176
131
|
* - `forward` — forward to the entry's resolved target, carrying the
|
|
177
132
|
* assistant id so the trusted host can resolve its bearer.
|
|
178
133
|
*/
|
|
@@ -216,10 +171,7 @@ export function resolveGatewayProxyTarget(
|
|
|
216
171
|
}
|
|
217
172
|
const target = getTargets().get(parsed.target.assistantId);
|
|
218
173
|
if (!target) {
|
|
219
|
-
|
|
220
|
-
return { kind: "pass" };
|
|
221
|
-
}
|
|
222
|
-
return GATEWAY_REJECTION;
|
|
174
|
+
return { kind: "pass" };
|
|
223
175
|
}
|
|
224
176
|
return {
|
|
225
177
|
kind: "forward",
|
|
@@ -124,7 +124,7 @@ export function isUsableRuntimeUrl(url: unknown): url is string {
|
|
|
124
124
|
/**
|
|
125
125
|
* First segments whose scoped `/v1/assistants/{id}/` prefix the gateway does
|
|
126
126
|
* not serve: the contact family lives on flat `/v1/...` control-plane routes
|
|
127
|
-
* (the shape the cloud's
|
|
127
|
+
* (the shape the cloud's runtime-proxy strip delivers). Every
|
|
128
128
|
* forwarder to the gateway — the scoped host proxy and the request
|
|
129
129
|
* interceptor's remote-ingress rewrite alike — flattens them to match.
|
|
130
130
|
*/
|
|
@@ -133,10 +133,6 @@ export const FLATTENED_FIRST_SEGMENTS = new Set<string>([
|
|
|
133
133
|
"contact-channels",
|
|
134
134
|
]);
|
|
135
135
|
|
|
136
|
-
export function gatewayProxyUrl(assistantId: string): string {
|
|
137
|
-
return `/assistant/__gateway/${encodeURIComponent(assistantId)}`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
136
|
/**
|
|
141
137
|
* User-facing hosting label for a paired entry: "Paired · <hostname>" when
|
|
142
138
|
* `runtimeUrl` names the remote host, plain "Paired" otherwise. Shared by the
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
tunnelProviderWebsiteName,
|
|
10
10
|
type PairingFailureReason,
|
|
11
11
|
type PublicBaseUrlRejection,
|
|
12
|
-
type RemoteWebPairingChallengeRequest,
|
|
13
12
|
type RemoteWebPairingChallengeResponse,
|
|
14
13
|
type RemoteWebPairingTokenPendingResponse,
|
|
15
14
|
type RemoteWebPairingTokenRequest,
|
|
@@ -907,9 +906,7 @@ export async function pairingStart(
|
|
|
907
906
|
const posted = await postPairingRequest(
|
|
908
907
|
parsed.publicBaseUrl,
|
|
909
908
|
PAIRING_CHALLENGE_PATH,
|
|
910
|
-
{
|
|
911
|
-
publicBaseUrl: parsed.publicBaseUrl,
|
|
912
|
-
} satisfies RemoteWebPairingChallengeRequest,
|
|
909
|
+
{},
|
|
913
910
|
);
|
|
914
911
|
if (!posted.ok) {
|
|
915
912
|
return posted.failure;
|
|
@@ -926,7 +923,8 @@ export async function pairingStart(
|
|
|
926
923
|
const challenge = posted.body;
|
|
927
924
|
return openPairingSession(
|
|
928
925
|
{
|
|
929
|
-
|
|
926
|
+
// The gateway self-sourced the URL; its echo is what it minted for.
|
|
927
|
+
publicBaseUrl: challenge.publicBaseUrl,
|
|
930
928
|
deviceCode: challenge.deviceCode,
|
|
931
929
|
deviceId,
|
|
932
930
|
// A challenge expires somewhere inside the code's own TTL, so that TTL
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* credential still authenticates.
|
|
4
4
|
*
|
|
5
5
|
* The daemon route is the authoritative serving side:
|
|
6
|
-
* - `POST /v1/
|
|
6
|
+
* - `POST /v1/cloud/verify-credential`
|
|
7
7
|
* (`assistant/src/runtime/routes/cloud-routes.ts`)
|
|
8
8
|
*
|
|
9
9
|
* The daemon's platform client produces the verdict, the route reports it,
|
|
@@ -32,10 +32,10 @@ export type CloudCredentialVerificationStatus = z.infer<
|
|
|
32
32
|
typeof CloudCredentialVerificationStatusSchema
|
|
33
33
|
>;
|
|
34
34
|
|
|
35
|
-
/** `POST /v1/
|
|
36
|
-
export const
|
|
35
|
+
/** `POST /v1/cloud/verify-credential` response body. */
|
|
36
|
+
export const CloudVerifyCredentialResponseSchema = z.object({
|
|
37
37
|
status: CloudCredentialVerificationStatusSchema,
|
|
38
38
|
});
|
|
39
|
-
export type
|
|
40
|
-
typeof
|
|
39
|
+
export type CloudVerifyCredentialResponse = z.infer<
|
|
40
|
+
typeof CloudVerifyCredentialResponseSchema
|
|
41
41
|
>;
|
|
@@ -37,12 +37,6 @@
|
|
|
37
37
|
*/
|
|
38
38
|
export const REMOTE_WEB_PAIRING_CODE_TTL_MS = 10 * 60 * 1000;
|
|
39
39
|
|
|
40
|
-
/** `POST /v1/remote-web/pairing-challenge` request body. */
|
|
41
|
-
export interface RemoteWebPairingChallengeRequest {
|
|
42
|
-
/** Public https base URL the scanning device can reach the assistant at. */
|
|
43
|
-
publicBaseUrl: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
40
|
/** `POST /v1/remote-web/pairing-challenge` success response body (200). */
|
|
47
41
|
export interface RemoteWebPairingChallengeResponse {
|
|
48
42
|
/** Opaque secret the paired device exchanges for a token. */
|
|
@@ -51,6 +45,12 @@ export interface RemoteWebPairingChallengeResponse {
|
|
|
51
45
|
userCode: string;
|
|
52
46
|
/** URL the device opens to complete pairing. */
|
|
53
47
|
verificationUri: string;
|
|
48
|
+
/**
|
|
49
|
+
* The base URL the challenge was minted for (echoed into verificationUri).
|
|
50
|
+
* The gateway self-sources it — the request's own host through the trusted
|
|
51
|
+
* edge, else its recorded ingress URL; callers cannot request a URL.
|
|
52
|
+
*/
|
|
53
|
+
publicBaseUrl: string;
|
|
54
54
|
/** ISO-8601 instant the challenge expires. */
|
|
55
55
|
expiresAt: string;
|
|
56
56
|
/** Seconds until the challenge expires. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The version string a source checkout reports for `--version`.
|
|
@@ -39,6 +40,18 @@ function isSourceCheckout(entryPath: string): boolean {
|
|
|
39
40
|
return entryPath.endsWith(".ts");
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* This module's own file path, in whichever runtime is asking. Node only has
|
|
45
|
+
* `import.meta.url` — and bundlers rewrite it back to this file's real path
|
|
46
|
+
* (electron-vite's config loader injects it per module; rollup shims it to
|
|
47
|
+
* `__filename` in CJS output), so the URL is the trustworthy source everywhere:
|
|
48
|
+
* Bun, Node, and bundled evaluation all resolve it to this file on disk.
|
|
49
|
+
*/
|
|
50
|
+
function moduleEntryPath(): string {
|
|
51
|
+
if (typeof import.meta.url === "string") return fileURLToPath(import.meta.url);
|
|
52
|
+
return import.meta.path;
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
function gitRepoRoot(entryPath: string): string | null {
|
|
43
56
|
let dir = dirname(entryPath);
|
|
44
57
|
for (;;) {
|
|
@@ -72,7 +85,7 @@ function headCommitTime(root: string): Date | null {
|
|
|
72
85
|
export function stampedVersion(
|
|
73
86
|
base: string,
|
|
74
87
|
now: Date = new Date(),
|
|
75
|
-
entryPath: string =
|
|
88
|
+
entryPath: string = moduleEntryPath(),
|
|
76
89
|
): string {
|
|
77
90
|
if (!isSourceCheckout(entryPath)) return base;
|
|
78
91
|
const root = gitRepoRoot(entryPath);
|
|
@@ -103,5 +116,5 @@ export function resolveVersion(packageRoot: string = process.cwd()): string {
|
|
|
103
116
|
}
|
|
104
117
|
if (!base) return "";
|
|
105
118
|
if ((process.env.CADET_ENVIRONMENT || "local") !== "local") return base;
|
|
106
|
-
return stampedVersion(base, new Date(),
|
|
119
|
+
return stampedVersion(base, new Date(), moduleEntryPath());
|
|
107
120
|
}
|
package/package.json
CHANGED
|
@@ -238,7 +238,6 @@ describe("fetchAssistantDetail / fetchUpgradeInProgress", () => {
|
|
|
238
238
|
test("fetchAssistantDetail maps fields", async () => {
|
|
239
239
|
const fetchMock = mockFetchJson({
|
|
240
240
|
current_release_version: "0.7.0",
|
|
241
|
-
release_channel: "preview",
|
|
242
241
|
});
|
|
243
242
|
const detail = await fetchAssistantDetail(
|
|
244
243
|
TOKEN,
|
|
@@ -247,7 +246,6 @@ describe("fetchAssistantDetail / fetchUpgradeInProgress", () => {
|
|
|
247
246
|
);
|
|
248
247
|
expect(detail).toEqual({
|
|
249
248
|
currentReleaseVersion: "0.7.0",
|
|
250
|
-
releaseChannel: "preview",
|
|
251
249
|
});
|
|
252
250
|
const url = String(fetchMock.mock.calls[0][0]);
|
|
253
251
|
expect(url).toBe(`${PLATFORM_URL}/v1/assistants/${ASSISTANT_ID}/`);
|
|
@@ -262,7 +260,6 @@ describe("fetchAssistantDetail / fetchUpgradeInProgress", () => {
|
|
|
262
260
|
);
|
|
263
261
|
expect(detail).toEqual({
|
|
264
262
|
currentReleaseVersion: null,
|
|
265
|
-
releaseChannel: "stable",
|
|
266
263
|
});
|
|
267
264
|
});
|
|
268
265
|
|
|
@@ -58,14 +58,6 @@ describe("fetchReleases", () => {
|
|
|
58
58
|
expect(url).toContain("limit=100");
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
test("passes the channel param when given", async () => {
|
|
62
|
-
const fetchMock = mockFetchJson([RELEASE]);
|
|
63
|
-
await fetchReleases({ channel: "preview" });
|
|
64
|
-
const url = String(fetchMock.mock.calls[0][0]);
|
|
65
|
-
expect(url).toContain("/v1/releases/?channel=preview");
|
|
66
|
-
expect(url).toContain("limit=100");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
61
|
test("uses the cloudUrl override over the resolved default", async () => {
|
|
70
62
|
const fetchMock = mockFetchJson([RELEASE]);
|
|
71
63
|
await fetchReleases({ cloudUrl: "https://other-platform.test" });
|
|
@@ -186,7 +178,7 @@ describe("version-shape helpers", () => {
|
|
|
186
178
|
});
|
|
187
179
|
|
|
188
180
|
describe("fetchLatestVersion", () => {
|
|
189
|
-
test("
|
|
181
|
+
test("requests stable releases", async () => {
|
|
190
182
|
const fetchMock = mockFetchJson([RELEASE]);
|
|
191
183
|
const version = await fetchLatestVersion();
|
|
192
184
|
expect(version).toBe("0.7.0");
|
|
@@ -194,20 +186,6 @@ describe("fetchLatestVersion", () => {
|
|
|
194
186
|
expect(url).toContain("stable=true");
|
|
195
187
|
expect(url).not.toContain("channel=");
|
|
196
188
|
});
|
|
197
|
-
|
|
198
|
-
test("requests the preview channel when asked", async () => {
|
|
199
|
-
const preview = { ...RELEASE, version: "0.8.0-preview.3" };
|
|
200
|
-
const fetchMock = mockFetchJson([preview]);
|
|
201
|
-
const version = await fetchLatestVersion("preview");
|
|
202
|
-
expect(version).toBe("0.8.0-preview.3");
|
|
203
|
-
const url = String(fetchMock.mock.calls[0][0]);
|
|
204
|
-
expect(url).toContain("channel=preview");
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test("returns null when the channel has no releases", async () => {
|
|
208
|
-
mockFetchJson([]);
|
|
209
|
-
expect(await fetchLatestVersion("preview")).toBeNull();
|
|
210
|
-
});
|
|
211
189
|
});
|
|
212
190
|
|
|
213
191
|
describe("stable release fallback", () => {
|
|
@@ -265,12 +243,6 @@ describe("stable release fallback", () => {
|
|
|
265
243
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
266
244
|
});
|
|
267
245
|
|
|
268
|
-
test("does not substitute stable for an unavailable preview channel", async () => {
|
|
269
|
-
const fetchMock = withGitHubFallback([], 503);
|
|
270
|
-
expect(await fetchLatestVersion("preview")).toBeNull();
|
|
271
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
246
|
test.each([
|
|
275
247
|
{ tag_name: "v0.13.0", draft: true, prerelease: false },
|
|
276
248
|
{ tag_name: "v0.13.0", draft: false, prerelease: true },
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
clearIngressUrl,
|
|
13
|
-
readIngressPublicBaseUrl,
|
|
14
13
|
saveIngressUrl,
|
|
15
14
|
savePairingTunnel,
|
|
16
15
|
} from "../lib/ingress-config.js";
|
|
@@ -29,19 +28,6 @@ afterEach(() => {
|
|
|
29
28
|
}
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
describe("readIngressPublicBaseUrl", () => {
|
|
33
|
-
test("reads back what saveIngressUrl saved", () => {
|
|
34
|
-
const ws = makeWorkspace();
|
|
35
|
-
expect(readIngressPublicBaseUrl(ws)).toBeNull();
|
|
36
|
-
|
|
37
|
-
saveIngressUrl(ws, "https://tunnel.example.ts.net");
|
|
38
|
-
|
|
39
|
-
expect(readIngressPublicBaseUrl(ws)).toBe("https://tunnel.example.ts.net");
|
|
40
|
-
clearIngressUrl(ws);
|
|
41
|
-
expect(readIngressPublicBaseUrl(ws)).toBeNull();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
31
|
describe("last-tunnel record", () => {
|
|
46
32
|
function readIngress(ws: string) {
|
|
47
33
|
const config = JSON.parse(readFileSync(join(ws, "config.json"), "utf-8"));
|