@thermai/flightdeck-cli 0.1.0-pilot.4 → 0.1.0-pilot.5
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/README.md +15 -8
- package/dist/index.js +46 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,17 +20,24 @@ availability does not open partner onboarding.
|
|
|
20
20
|
|
|
21
21
|
**`0.1.0-pilot.3`** was published through GitHub Actions on 8 September 2026,
|
|
22
22
|
including complete log pagination and concise authentication errors. Its
|
|
23
|
-
anonymous Node 22 install and packaged dry run passed
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
advertising `X-Flightdeck-Accounting: credits-v1`.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
rejected before job submission; login and credential revocation do not require
|
|
23
|
+
anonymous Node 22 install and packaged dry run passed. Use the operator-approved
|
|
24
|
+
exact version for a recorded rehearsal.
|
|
25
|
+
|
|
26
|
+
**`0.1.0-pilot.4`**, published on 20 September 2026, adds customer credits and
|
|
27
|
+
requires a backend advertising `X-Flightdeck-Accounting: credits-v1`. Upgrade
|
|
28
|
+
with the install command below before accessing account/job data. An incompatible
|
|
29
|
+
backend is rejected before job submission; login and credential revocation do not require
|
|
31
30
|
the accounting contract. See the
|
|
32
31
|
[operator rollout checklist](../docs/runbooks/customer-credits-rollout.md).
|
|
33
32
|
|
|
33
|
+
**Candidate `0.1.0-pilot.5`** fixes result downloads redirected to signed object
|
|
34
|
+
storage ([#157](https://github.com/ThermAI-Group/thermai_flightdeck/issues/157))
|
|
35
|
+
and includes the merged GPU-recovery status display. Downloads validate the
|
|
36
|
+
accounting contract on Flightdeck's response, then fetch the authorized storage
|
|
37
|
+
object without forwarding the CLI credential. This candidate is not published
|
|
38
|
+
by merging; an approved versioned GitHub Release is still required. Until that
|
|
39
|
+
release is verified, the published pilot.4 download regression remains open.
|
|
40
|
+
|
|
34
41
|
Members and organization administrators receive whole-credit balances,
|
|
35
42
|
estimates and actual customer charges, without provider-cost information.
|
|
36
43
|
Platform administrators retain their authorized monetary API fields. Credits
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,10 @@ var DEFAULT_API_URL = "https://api.flightdeck.thermai.uk";
|
|
|
75
75
|
var CONFIG_PATH = join(homedir(), ".flightdeck", "config.json");
|
|
76
76
|
var ACCOUNTING_HEADER = "X-Flightdeck-Accounting";
|
|
77
77
|
var ACCOUNTING_CONTRACT = "credits-v1";
|
|
78
|
+
var ARTIFACT_REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
79
|
+
function isLoopback(url) {
|
|
80
|
+
return ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
81
|
+
}
|
|
78
82
|
function normalizeApiUrl(value) {
|
|
79
83
|
let url;
|
|
80
84
|
try {
|
|
@@ -82,8 +86,7 @@ function normalizeApiUrl(value) {
|
|
|
82
86
|
} catch {
|
|
83
87
|
throw new CliError("Invalid FlightDeck API URL. Use an HTTPS URL.");
|
|
84
88
|
}
|
|
85
|
-
|
|
86
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && localHost)) {
|
|
89
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback(url))) {
|
|
87
90
|
throw new CliError("FlightDeck API URLs must use HTTPS (HTTP is allowed only for localhost)");
|
|
88
91
|
}
|
|
89
92
|
if (url.username || url.password || url.search || url.hash) {
|
|
@@ -167,7 +170,9 @@ async function publicApiRequest(apiUrl, method, path, body) {
|
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
172
|
async function apiRequest(method, path, body) {
|
|
170
|
-
|
|
173
|
+
return authenticatedRequest(loadConfig(), method, path, body);
|
|
174
|
+
}
|
|
175
|
+
async function authenticatedRequest(config, method, path, body, redirect = "follow") {
|
|
171
176
|
const headers = {
|
|
172
177
|
Authorization: `Bearer ${config.api_key}`,
|
|
173
178
|
[ACCOUNTING_HEADER]: ACCOUNTING_CONTRACT
|
|
@@ -180,7 +185,8 @@ async function apiRequest(method, path, body) {
|
|
|
180
185
|
const response = await request(endpoint(config.api_url, path), {
|
|
181
186
|
method,
|
|
182
187
|
headers,
|
|
183
|
-
body: requestBody(body, headers)
|
|
188
|
+
body: requestBody(body, headers),
|
|
189
|
+
redirect
|
|
184
190
|
});
|
|
185
191
|
if (path !== "/auth/credential/revoke" && (response.ok || response.status === 402)) assertAccountingContract(response);
|
|
186
192
|
if (response.status === 409) {
|
|
@@ -189,6 +195,31 @@ async function apiRequest(method, path, body) {
|
|
|
189
195
|
}
|
|
190
196
|
return response;
|
|
191
197
|
}
|
|
198
|
+
async function artifactRequest(flightId, artifactId) {
|
|
199
|
+
const config = loadConfig();
|
|
200
|
+
const path = `/flights/${encodeURIComponent(flightId)}/outputs/${encodeURIComponent(artifactId)}`;
|
|
201
|
+
const response = await authenticatedRequest(config, "GET", path, void 0, "manual");
|
|
202
|
+
if (!ARTIFACT_REDIRECTS.has(response.status)) return response;
|
|
203
|
+
const location = response.headers.get("Location");
|
|
204
|
+
await response.body?.cancel();
|
|
205
|
+
assertAccountingContract(response);
|
|
206
|
+
let target;
|
|
207
|
+
try {
|
|
208
|
+
target = new URL(location ?? "");
|
|
209
|
+
const api = new URL(normalizeApiUrl(config.api_url));
|
|
210
|
+
const localStorage = api.protocol === "http:" && isLoopback(api) && target.protocol === "http:" && isLoopback(target);
|
|
211
|
+
if (target.protocol !== "https:" && !localStorage || target.username || target.password || target.hash) {
|
|
212
|
+
throw new Error("invalid storage destination");
|
|
213
|
+
}
|
|
214
|
+
} catch {
|
|
215
|
+
throw new CliError("The Flightdeck API returned an invalid or unsafe storage URL. Contact your ThermAI operator.");
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
return await fetch(target.href, { method: "GET", credentials: "omit", redirect: "error" });
|
|
219
|
+
} catch (cause) {
|
|
220
|
+
throw new CliError("Could not download output from storage. Retry flightdeck download to obtain a fresh link.", { cause });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
192
223
|
function assertAccountingContract(response) {
|
|
193
224
|
if (response.headers.get(ACCOUNTING_HEADER) !== ACCOUNTING_CONTRACT) {
|
|
194
225
|
throw new CliError("The API does not support this CLI's credits contract yet. Contact your ThermAI operator. No accounting amounts were displayed.");
|
|
@@ -968,6 +999,14 @@ ${submitted.length} submitted, ${failures} failed.`);
|
|
|
968
999
|
return { submitted, failures };
|
|
969
1000
|
}
|
|
970
1001
|
|
|
1002
|
+
// src/recovery-status.ts
|
|
1003
|
+
function recoveryStatusLine(value) {
|
|
1004
|
+
if (!value || typeof value !== "object") return null;
|
|
1005
|
+
const recovery = value;
|
|
1006
|
+
if (!recovery.phase || !["collecting", "cleanup", "queued", "replacement", "finished"].includes(recovery.phase)) return null;
|
|
1007
|
+
return ` Recovery: ${recovery.phase} (replacement ${recovery.replacement_authorized ? 1 : 0} of ${recovery.retry_limit ?? 1} authorized)`;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
971
1010
|
// src/commands/status.ts
|
|
972
1011
|
async function status(flightId) {
|
|
973
1012
|
const response = await apiRequest("GET", `/flights/${flightId}`);
|
|
@@ -976,6 +1015,8 @@ async function status(flightId) {
|
|
|
976
1015
|
console.log(`Flight: ${body.flight_id}`);
|
|
977
1016
|
console.log(` Name: ${body.name}`);
|
|
978
1017
|
console.log(` Status: ${body.status}`);
|
|
1018
|
+
const recovery = recoveryStatusLine(body.recovery);
|
|
1019
|
+
if (recovery) console.log(recovery);
|
|
979
1020
|
console.log(` Image: ${body.image}`);
|
|
980
1021
|
console.log(` GPU: ${body.gpu_type ?? "any"} x${body.gpu_count}`);
|
|
981
1022
|
if (body.queued_at) console.log(` Queued: ${body.queued_at}`);
|
|
@@ -1064,7 +1105,7 @@ async function download(flightId, options) {
|
|
|
1064
1105
|
const root = resolve3(options.outputDir);
|
|
1065
1106
|
await mkdir(root, { recursive: true });
|
|
1066
1107
|
for (const output of manifest.outputs ?? []) {
|
|
1067
|
-
const response = await
|
|
1108
|
+
const response = await artifactRequest(flightId, output.artifact_id);
|
|
1068
1109
|
if (!response.ok) throw httpError("Unable to download output", response.status);
|
|
1069
1110
|
const target = join3(root, basename(output.filename));
|
|
1070
1111
|
await writeFile(target, Buffer.from(await response.arrayBuffer()), { flag: "wx" });
|