@thermai/flightdeck-cli 0.1.0-pilot.3 → 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 +32 -9
- package/dist/index.js +70 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,10 +18,31 @@ Proprietary terms in `LICENSE` permit redistribution of unchanged official
|
|
|
18
18
|
releases. Internal service qualification is still in progress; package
|
|
19
19
|
availability does not open partner onboarding.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
**`0.1.0-pilot.3`** was published through GitHub Actions on 8 September 2026,
|
|
22
|
+
including complete log pagination and concise authentication errors. Its
|
|
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
|
|
30
|
+
the accounting contract. See the
|
|
31
|
+
[operator rollout checklist](../docs/runbooks/customer-credits-rollout.md).
|
|
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
|
+
|
|
41
|
+
Members and organization administrators receive whole-credit balances,
|
|
42
|
+
estimates and actual customer charges, without provider-cost information.
|
|
43
|
+
Platform administrators retain their authorized monetary API fields. Credits
|
|
44
|
+
are not GPU-hours; consumption depends on the selected hardware/provider and
|
|
45
|
+
the accepted job pricing. Existing limits and customer charge caps still apply.
|
|
25
46
|
|
|
26
47
|
## Installation and login
|
|
27
48
|
|
|
@@ -57,8 +78,10 @@ credential management can revoke an individual workstation as well.
|
|
|
57
78
|
|
|
58
79
|
`--name` labels a credential, not a local account profile. There is one saved
|
|
59
80
|
login per OS user. If already logged in, use `whoami` to inspect it; `login`
|
|
60
|
-
refuses to replace it.
|
|
61
|
-
|
|
81
|
+
refuses to replace it. Use a separate OS user to preserve an operator's working
|
|
82
|
+
credential, or explicitly choose logout/re-login on the same workstation.
|
|
83
|
+
Logging out revokes that saved CLI credential; it does not delete the account or
|
|
84
|
+
its roles. A later login creates a new credential.
|
|
62
85
|
|
|
63
86
|
## Pilot quick-start
|
|
64
87
|
|
|
@@ -148,7 +171,7 @@ agreed pilot handoff; this client does not promise unattended support.
|
|
|
148
171
|
|
|
149
172
|
### Reading logs completely
|
|
150
173
|
|
|
151
|
-
|
|
174
|
+
From `0.1.0-pilot.3` (containing the #99 pagination fix), `flightdeck logs`
|
|
152
175
|
drains all pages in the current stored-log snapshot, then returns. For a running
|
|
153
176
|
job it may append one current live tail after the stored pages. `--follow`
|
|
154
177
|
drains those pages immediately, then polls every two seconds until the job is
|
|
@@ -158,13 +181,13 @@ the beginning; stdout/stderr retain their respective output streams.
|
|
|
158
181
|
**Rollout order:** deploy and verify the pagination-capable backend before
|
|
159
182
|
releasing/upgrading this CLI. A backend without the `has_more` response field
|
|
160
183
|
produces an explicit compatibility error and exit status 1, not a silently
|
|
161
|
-
partial read.
|
|
184
|
+
partial read. Older `0.1.0-pilot.2` installations do not contain this fix;
|
|
162
185
|
merging source alone neither replaces that immutable package nor publishes a
|
|
163
186
|
new version. Older non-following clients still need upgrading for full paging.
|
|
164
187
|
|
|
165
188
|
### Error handling and support
|
|
166
189
|
|
|
167
|
-
The
|
|
190
|
+
The CLI exits with status 1 on command failure. Expected authentication,
|
|
168
191
|
network and HTTP failures have concise diagnostics instead of a Node stack.
|
|
169
192
|
An already-configured login leaves the saved credential unchanged; a failed
|
|
170
193
|
logout/revocation retains it so you can retry. `logout --local` deliberately
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,12 @@ Diagnostic: ${details.join("; ") || "unknown error type"}`;
|
|
|
73
73
|
// src/client.ts
|
|
74
74
|
var DEFAULT_API_URL = "https://api.flightdeck.thermai.uk";
|
|
75
75
|
var CONFIG_PATH = join(homedir(), ".flightdeck", "config.json");
|
|
76
|
+
var ACCOUNTING_HEADER = "X-Flightdeck-Accounting";
|
|
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
|
+
}
|
|
76
82
|
function normalizeApiUrl(value) {
|
|
77
83
|
let url;
|
|
78
84
|
try {
|
|
@@ -80,8 +86,7 @@ function normalizeApiUrl(value) {
|
|
|
80
86
|
} catch {
|
|
81
87
|
throw new CliError("Invalid FlightDeck API URL. Use an HTTPS URL.");
|
|
82
88
|
}
|
|
83
|
-
|
|
84
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && localHost)) {
|
|
89
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback(url))) {
|
|
85
90
|
throw new CliError("FlightDeck API URLs must use HTTPS (HTTP is allowed only for localhost)");
|
|
86
91
|
}
|
|
87
92
|
if (url.username || url.password || url.search || url.hash) {
|
|
@@ -165,15 +170,60 @@ async function publicApiRequest(apiUrl, method, path, body) {
|
|
|
165
170
|
});
|
|
166
171
|
}
|
|
167
172
|
async function apiRequest(method, path, body) {
|
|
168
|
-
|
|
173
|
+
return authenticatedRequest(loadConfig(), method, path, body);
|
|
174
|
+
}
|
|
175
|
+
async function authenticatedRequest(config, method, path, body, redirect = "follow") {
|
|
169
176
|
const headers = {
|
|
170
|
-
Authorization: `Bearer ${config.api_key}
|
|
177
|
+
Authorization: `Bearer ${config.api_key}`,
|
|
178
|
+
[ACCOUNTING_HEADER]: ACCOUNTING_CONTRACT
|
|
171
179
|
};
|
|
172
|
-
|
|
180
|
+
if (method === "POST" && (path === "/jobs/submit" || path === "/flights")) {
|
|
181
|
+
const health = await request(endpoint(config.api_url, "/health"), { method: "GET" });
|
|
182
|
+
assertAccountingContract(health);
|
|
183
|
+
if (!health.ok) throw new CliError("The Flightdeck API is not ready. No job was submitted.");
|
|
184
|
+
}
|
|
185
|
+
const response = await request(endpoint(config.api_url, path), {
|
|
173
186
|
method,
|
|
174
187
|
headers,
|
|
175
|
-
body: requestBody(body, headers)
|
|
188
|
+
body: requestBody(body, headers),
|
|
189
|
+
redirect
|
|
176
190
|
});
|
|
191
|
+
if (path !== "/auth/credential/revoke" && (response.ok || response.status === 402)) assertAccountingContract(response);
|
|
192
|
+
if (response.status === 409) {
|
|
193
|
+
const body2 = await response.clone().json().catch(() => ({}));
|
|
194
|
+
if (body2.error === "accounting_client_upgrade_required") throw new CliError("Update the Flightdeck CLI to use credits accounting.");
|
|
195
|
+
}
|
|
196
|
+
return response;
|
|
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
|
+
}
|
|
223
|
+
function assertAccountingContract(response) {
|
|
224
|
+
if (response.headers.get(ACCOUNTING_HEADER) !== ACCOUNTING_CONTRACT) {
|
|
225
|
+
throw new CliError("The API does not support this CLI's credits contract yet. Contact your ThermAI operator. No accounting amounts were displayed.");
|
|
226
|
+
}
|
|
177
227
|
}
|
|
178
228
|
async function request(url, options) {
|
|
179
229
|
try {
|
|
@@ -356,7 +406,7 @@ async function submit(entrypoint, options) {
|
|
|
356
406
|
Flight submitted successfully!`);
|
|
357
407
|
console.log(` Flight ID: ${body.flight_id}`);
|
|
358
408
|
console.log(` Status: ${body.status}`);
|
|
359
|
-
console.log(` Est.
|
|
409
|
+
console.log(` Est. credits: ${body.estimated_credits}`);
|
|
360
410
|
console.log(` Queue position: ${body.position_in_queue}`);
|
|
361
411
|
console.log(`
|
|
362
412
|
Track with: flightdeck status ${body.flight_id}`);
|
|
@@ -949,6 +999,14 @@ ${submitted.length} submitted, ${failures} failed.`);
|
|
|
949
999
|
return { submitted, failures };
|
|
950
1000
|
}
|
|
951
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
|
+
|
|
952
1010
|
// src/commands/status.ts
|
|
953
1011
|
async function status(flightId) {
|
|
954
1012
|
const response = await apiRequest("GET", `/flights/${flightId}`);
|
|
@@ -957,6 +1015,8 @@ async function status(flightId) {
|
|
|
957
1015
|
console.log(`Flight: ${body.flight_id}`);
|
|
958
1016
|
console.log(` Name: ${body.name}`);
|
|
959
1017
|
console.log(` Status: ${body.status}`);
|
|
1018
|
+
const recovery = recoveryStatusLine(body.recovery);
|
|
1019
|
+
if (recovery) console.log(recovery);
|
|
960
1020
|
console.log(` Image: ${body.image}`);
|
|
961
1021
|
console.log(` GPU: ${body.gpu_type ?? "any"} x${body.gpu_count}`);
|
|
962
1022
|
if (body.queued_at) console.log(` Queued: ${body.queued_at}`);
|
|
@@ -964,7 +1024,8 @@ async function status(flightId) {
|
|
|
964
1024
|
if (body.completed_at) console.log(` Finished: ${body.completed_at}`);
|
|
965
1025
|
if (body.exit_code != null) console.log(` Exit: ${body.exit_code}`);
|
|
966
1026
|
if (body.error_message) console.log(` Error: ${body.error_message}`);
|
|
967
|
-
if (body.
|
|
1027
|
+
if (body.charge_credits != null) console.log(` Charged: ${body.charge_credits} credits`);
|
|
1028
|
+
if (body.cost_pence != null) console.log(` Provider cost: ${body.cost_pence}p`);
|
|
968
1029
|
}
|
|
969
1030
|
|
|
970
1031
|
// src/log-reader.ts
|
|
@@ -1044,7 +1105,7 @@ async function download(flightId, options) {
|
|
|
1044
1105
|
const root = resolve3(options.outputDir);
|
|
1045
1106
|
await mkdir(root, { recursive: true });
|
|
1046
1107
|
for (const output of manifest.outputs ?? []) {
|
|
1047
|
-
const response = await
|
|
1108
|
+
const response = await artifactRequest(flightId, output.artifact_id);
|
|
1048
1109
|
if (!response.ok) throw httpError("Unable to download output", response.status);
|
|
1049
1110
|
const target = join3(root, basename(output.filename));
|
|
1050
1111
|
await writeFile(target, Buffer.from(await response.arrayBuffer()), { flag: "wx" });
|