@mycadet/cli 0.13.0-dev.202610231403.3079a3f β 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/local-mode/src/__tests__/gateway-proxy.test.ts +1 -53
- package/node_modules/@mycadet/local-mode/src/gateway-proxy.ts +17 -65
- package/node_modules/@mycadet/local-mode/src/lockfile-contract.ts +1 -1
- 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/commands/upgrade.ts +3 -5
- package/src/lib/cloud-client.ts +2 -5
- package/src/lib/cloud-releases.ts +8 -42
- package/src/lib/terminal-client.ts +1 -1
|
@@ -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", () => {
|
|
@@ -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
|
*/
|
|
@@ -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 },
|
package/src/commands/upgrade.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
sleepContainers,
|
|
27
27
|
} from "../lib/docker";
|
|
28
28
|
import {
|
|
29
|
-
|
|
29
|
+
fetchLatestVersion,
|
|
30
30
|
fetchReleases,
|
|
31
31
|
resolveImageRefs,
|
|
32
32
|
} from "../lib/cloud-releases";
|
|
@@ -1124,11 +1124,9 @@ async function upgradePlatform(
|
|
|
1124
1124
|
const currentVersion =
|
|
1125
1125
|
health.version ?? assistantDetail?.currentReleaseVersion ?? undefined;
|
|
1126
1126
|
|
|
1127
|
-
const releaseChannel = assistantDetail?.releaseChannel ?? "stable";
|
|
1128
1127
|
// Target the same platform as the detail/health/POST calls β the entry's
|
|
1129
1128
|
// platform may differ from the active lockfile default.
|
|
1130
1129
|
const releases = await fetchReleases({
|
|
1131
|
-
channel: releaseChannel,
|
|
1132
1130
|
cloudUrl: entry.runtimeUrl,
|
|
1133
1131
|
});
|
|
1134
1132
|
|
|
@@ -1139,7 +1137,7 @@ async function upgradePlatform(
|
|
|
1139
1137
|
});
|
|
1140
1138
|
|
|
1141
1139
|
if (resolution.kind === "version-not-found") {
|
|
1142
|
-
const msg = `Version ${version} not found in Cadet Cloud releases
|
|
1140
|
+
const msg = `Version ${version} not found in Cadet Cloud releases.`;
|
|
1143
1141
|
console.error(msg);
|
|
1144
1142
|
emitCliError("MISSING_VERSION", msg);
|
|
1145
1143
|
process.exit(1);
|
|
@@ -1385,7 +1383,7 @@ async function upgradeFinalize(
|
|
|
1385
1383
|
*/
|
|
1386
1384
|
async function resolveLatestStableTag(): Promise<string> {
|
|
1387
1385
|
console.log("π Fetching latest stable release...");
|
|
1388
|
-
const latestVersion = await
|
|
1386
|
+
const latestVersion = await fetchLatestVersion();
|
|
1389
1387
|
if (!latestVersion) {
|
|
1390
1388
|
console.error(
|
|
1391
1389
|
"Error: Could not determine the latest stable release from Cadet Cloud or GitHub Releases.",
|
package/src/lib/cloud-client.ts
CHANGED
|
@@ -249,9 +249,8 @@ const SecretReadResponseSchema = z
|
|
|
249
249
|
})
|
|
250
250
|
.catch({ found: false });
|
|
251
251
|
|
|
252
|
-
const
|
|
252
|
+
const AssistantDetailResponseSchema = z.object({
|
|
253
253
|
current_release_version: z.string().nullable().optional(),
|
|
254
|
-
release_channel: z.string().optional(),
|
|
255
254
|
});
|
|
256
255
|
|
|
257
256
|
const OrganizationListResponseSchema = z.object({
|
|
@@ -756,7 +755,6 @@ export async function fetchCloudAssistants(
|
|
|
756
755
|
|
|
757
756
|
export interface CloudAssistantDetail {
|
|
758
757
|
currentReleaseVersion: string | null;
|
|
759
|
-
releaseChannel: "stable" | "preview";
|
|
760
758
|
}
|
|
761
759
|
|
|
762
760
|
/**
|
|
@@ -780,13 +778,12 @@ export async function fetchAssistantDetail(
|
|
|
780
778
|
|
|
781
779
|
if (!response.ok) return null;
|
|
782
780
|
|
|
783
|
-
const parsed =
|
|
781
|
+
const parsed = AssistantDetailResponseSchema.safeParse(
|
|
784
782
|
await response.json(),
|
|
785
783
|
);
|
|
786
784
|
const body = parsed.success ? parsed.data : {};
|
|
787
785
|
return {
|
|
788
786
|
currentReleaseVersion: body.current_release_version ?? null,
|
|
789
|
-
releaseChannel: body.release_channel === "preview" ? "preview" : "stable",
|
|
790
787
|
};
|
|
791
788
|
} catch {
|
|
792
789
|
return null;
|
|
@@ -6,25 +6,6 @@ import { dockerhubImages } from "./docker.js";
|
|
|
6
6
|
import type { ServiceName } from "./docker.js";
|
|
7
7
|
import { loopbackSafeFetch } from "./loopback-fetch.js";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Release channel to resolve releases for. `stable` is the default and maps
|
|
11
|
-
* to the server's `stable=true` filter. `preview` opts into the Cadet
|
|
12
|
-
* Cloud's preview channel β the newest release regardless of stability β
|
|
13
|
-
* used by callers (e.g. managed-assistant upgrades) that want the latest
|
|
14
|
-
* preview release.
|
|
15
|
-
*/
|
|
16
|
-
export type ReleaseChannel = "stable" | "preview";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Map a channel to `fetchReleases` options. `stable` passes no `channel`
|
|
20
|
-
* param so the server keeps its `stable=true` default (we don't rely on an
|
|
21
|
-
* unverified `channel=stable` filter); `preview` requests the preview
|
|
22
|
-
* channel explicitly.
|
|
23
|
-
*/
|
|
24
|
-
function releasesOptsFor(channel: ReleaseChannel): { channel?: "preview" } {
|
|
25
|
-
return channel === "preview" ? { channel: "preview" } : {};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
9
|
const ReleaseListItemSchema = z.object({
|
|
29
10
|
version: z.string().min(1),
|
|
30
11
|
is_stable: z.boolean().optional(),
|
|
@@ -69,22 +50,20 @@ async function fetchLatestGitHubStableVersion(): Promise<string | null> {
|
|
|
69
50
|
const RELEASES_FETCH_LIMIT = 100;
|
|
70
51
|
|
|
71
52
|
/**
|
|
72
|
-
* Fetch the releases list from Cadet Cloud
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
53
|
+
* Fetch the releases list from Cadet Cloud (stable releases β the server's
|
|
54
|
+
* `stable=true` default). `cloudUrl` overrides the lockfile/env-resolved
|
|
55
|
+
* default β pass the target assistant's platform URL when it may differ
|
|
56
|
+
* from the active one.
|
|
76
57
|
* Returns `null` when Cadet Cloud is unreachable or responds non-OK β
|
|
77
58
|
* distinct from `[]` (it answered, no releases).
|
|
78
59
|
*/
|
|
79
60
|
export async function fetchReleases(opts?: {
|
|
80
|
-
channel?: "stable" | "preview";
|
|
81
61
|
cloudUrl?: string;
|
|
82
62
|
}): Promise<ReleaseListItem[] | null> {
|
|
83
63
|
try {
|
|
84
64
|
const cloudUrl = opts?.cloudUrl || getCloudUrl();
|
|
85
|
-
const filter = opts?.channel ? `channel=${opts.channel}` : "stable=true";
|
|
86
65
|
const response = await loopbackSafeFetch(
|
|
87
|
-
`${cloudUrl}/v1/releases
|
|
66
|
+
`${cloudUrl}/v1/releases/?stable=true&limit=${RELEASES_FETCH_LIMIT}`,
|
|
88
67
|
{ signal: AbortSignal.timeout(10_000) },
|
|
89
68
|
);
|
|
90
69
|
if (!response.ok) {
|
|
@@ -104,15 +83,10 @@ export async function fetchReleases(opts?: {
|
|
|
104
83
|
* for stable releases when the cloud has no usable result.
|
|
105
84
|
* Returns the version string (e.g. "0.7.0") or null if unavailable.
|
|
106
85
|
* The releases endpoint returns entries ordered newest-first, so the first
|
|
107
|
-
* entry is the latest
|
|
86
|
+
* stable entry is the latest.
|
|
108
87
|
*/
|
|
109
|
-
export async function fetchLatestVersion(
|
|
110
|
-
|
|
111
|
-
): Promise<string | null> {
|
|
112
|
-
const releases = await fetchReleases(releasesOptsFor(channel));
|
|
113
|
-
if (channel === "preview") {
|
|
114
|
-
return releases?.[0]?.version ?? null;
|
|
115
|
-
}
|
|
88
|
+
export async function fetchLatestVersion(): Promise<string | null> {
|
|
89
|
+
const releases = await fetchReleases();
|
|
116
90
|
const latest = releases?.find(
|
|
117
91
|
(release) =>
|
|
118
92
|
release.is_stable !== false && STABLE_VERSION.test(release.version),
|
|
@@ -120,14 +94,6 @@ export async function fetchLatestVersion(
|
|
|
120
94
|
return latest?.version ?? fetchLatestGitHubStableVersion();
|
|
121
95
|
}
|
|
122
96
|
|
|
123
|
-
/**
|
|
124
|
-
* Fetch the latest stable release version. Thin back-compat wrapper around
|
|
125
|
-
* {@link fetchLatestVersion} for existing callers.
|
|
126
|
-
*/
|
|
127
|
-
export async function fetchLatestStableVersion(): Promise<string | null> {
|
|
128
|
-
return fetchLatestVersion("stable");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
97
|
/**
|
|
132
98
|
* Image refs for a target version: the tag is the target version exactly as
|
|
133
99
|
* the release workflows push it β bare ("0.12.8", "0.12.8-devβ¦"); a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform terminal API client.
|
|
3
3
|
*
|
|
4
|
-
* Wraps the
|
|
4
|
+
* Wraps the cloud terminal session endpoints that proxy through vembda to
|
|
5
5
|
* open K8s exec streams into cloud assistant containers. Same transport
|
|
6
6
|
* the web UI's xterm.js terminal uses.
|
|
7
7
|
*/
|