@thermai/flightdeck-cli 0.1.0-pilot.4 → 0.1.0-pilot.6
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 +48 -16
- package/dist/index.js +142 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,17 +20,25 @@ 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
|
+
**`0.1.0-pilot.5`**, published on 21 September 2026, 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. Anonymous Node 22 installation
|
|
38
|
+
and a live result download passed; `next` selects this version. Upgrade from
|
|
39
|
+
pilot.4 before downloading results. Future releases still require an approved
|
|
40
|
+
versioned GitHub Release; merging alone does not publish.
|
|
41
|
+
|
|
34
42
|
Members and organization administrators receive whole-credit balances,
|
|
35
43
|
estimates and actual customer charges, without provider-cost information.
|
|
36
44
|
Platform administrators retain their authorized monetary API fields. Credits
|
|
@@ -66,15 +74,25 @@ test environment can be selected with `flightdeck login --api-url <HTTPS origin>
|
|
|
66
74
|
|
|
67
75
|
Login saves a scoped credential in `~/.flightdeck/config.json` with restrictive
|
|
68
76
|
permissions. Never share that file or include it in a workload bundle. Use
|
|
69
|
-
`flightdeck logout` to
|
|
70
|
-
credential management can revoke an individual workstation as well.
|
|
77
|
+
`flightdeck logout` to remove the local login and attempt server revocation.
|
|
78
|
+
Portal credential management can revoke an individual workstation as well.
|
|
71
79
|
|
|
72
80
|
`--name` labels a credential, not a local account profile. There is one saved
|
|
73
81
|
login per OS user. If already logged in, use `whoami` to inspect it; `login`
|
|
74
82
|
refuses to replace it. Use a separate OS user to preserve an operator's working
|
|
75
83
|
credential, or explicitly choose logout/re-login on the same workstation.
|
|
76
|
-
Logging out
|
|
77
|
-
|
|
84
|
+
Logging out removes the saved credential; it does not delete the account or its
|
|
85
|
+
roles. A later login creates a new credential. Check the separate revocation
|
|
86
|
+
result: other copies may remain valid if server revocation was not confirmed.
|
|
87
|
+
|
|
88
|
+
The next CLI release also explains `account_suspended`, `membership_suspended`
|
|
89
|
+
and `organization_suspended` denials during device login and authenticated
|
|
90
|
+
commands. Contact your organization administrator; organization suspension may
|
|
91
|
+
need ThermAI support. These are access restrictions, not a missing local login
|
|
92
|
+
or a request for additional credential scopes. Other 403 responses retain
|
|
93
|
+
generic permissions guidance. Commands still exit nonzero and do not print
|
|
94
|
+
server-supplied messages or stack traces. Published pilot.5 does **not** yet
|
|
95
|
+
include these messages; merging the change does not publish a CLI release.
|
|
78
96
|
|
|
79
97
|
## Pilot quick-start
|
|
80
98
|
|
|
@@ -182,10 +200,24 @@ new version. Older non-following clients still need upgrading for full paging.
|
|
|
182
200
|
|
|
183
201
|
The CLI exits with status 1 on command failure. Expected authentication,
|
|
184
202
|
network and HTTP failures have concise diagnostics instead of a Node stack.
|
|
185
|
-
An already-configured login leaves the saved credential unchanged
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
203
|
+
An already-configured login leaves the saved credential unchanged.
|
|
204
|
+
|
|
205
|
+
**Next-release logout behavior (#143):** remove the local file first, then make
|
|
206
|
+
one best-effort server revocation request with a three-second deadline, including
|
|
207
|
+
the response body. Offline, suspended, failed or malformed API responses cannot
|
|
208
|
+
retain or restore the local login. Local success exits 0; a warning separately
|
|
209
|
+
states when remote revocation was not confirmed and other copies may remain
|
|
210
|
+
valid. Use portal credential management or contact your organization admin.
|
|
211
|
+
Failed local deletion exits 1, reports the problem and makes no API request.
|
|
212
|
+
Missing local login is a successful no-op; malformed config is removed without
|
|
213
|
+
trusting its contents for a request. No credential recovery/retry file is saved.
|
|
214
|
+
`logout --local` removes only the local copy and makes no network request.
|
|
215
|
+
|
|
216
|
+
This change is not in the published `0.1.0-pilot.5` package. Until the next
|
|
217
|
+
approved release, use `flightdeck logout --local` if ordinary logout is blocked;
|
|
218
|
+
it does not revoke remote access. A new backend release is also needed to permit
|
|
219
|
+
a valid named credential to revoke itself while its account or organization is
|
|
220
|
+
suspended. These changes do not permit ordinary access under suspension.
|
|
189
221
|
|
|
190
222
|
For unexpected faults, `flightdeck --debug <command>` adds allowlisted error
|
|
191
223
|
types/codes and bundled CLI line locations, not raw stacks or error bodies.
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,32 @@ var CliError = class extends Error {
|
|
|
31
31
|
this.name = "CliError";
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
function
|
|
34
|
+
function suspensionMessage(status2, code) {
|
|
35
|
+
if (status2 !== 403) return void 0;
|
|
36
|
+
switch (code) {
|
|
37
|
+
case "account_suspended":
|
|
38
|
+
return "This account is suspended. Contact your organization administrator.";
|
|
39
|
+
case "membership_suspended":
|
|
40
|
+
return "Your membership in this organization is suspended. Contact your organization administrator.";
|
|
41
|
+
case "organization_suspended":
|
|
42
|
+
return "This organization is suspended. Contact your organization administrator or ThermAI support.";
|
|
43
|
+
default:
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function suspensionError(response) {
|
|
48
|
+
if (response.status !== 403) return void 0;
|
|
49
|
+
try {
|
|
50
|
+
const body = await response.clone().json();
|
|
51
|
+
const code = body && typeof body === "object" && !Array.isArray(body) ? body.error : void 0;
|
|
52
|
+
if (suspensionMessage(response.status, code)) return httpError("Access denied", response.status, code);
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
function httpError(action, status2, code) {
|
|
58
|
+
const suspension = suspensionMessage(status2, code);
|
|
59
|
+
if (suspension) return new CliError(`${action} (HTTP ${status2}). ${suspension}`);
|
|
35
60
|
const guidance = status2 === 401 ? " Check the account with flightdeck whoami; sign in again if the credential expired or was revoked." : status2 === 403 ? " Check the account permissions and requested credential scopes." : status2 === 429 ? " Wait briefly before retrying." : "";
|
|
36
61
|
return new CliError(`${action} (HTTP ${status2}).${guidance}`);
|
|
37
62
|
}
|
|
@@ -75,6 +100,10 @@ var DEFAULT_API_URL = "https://api.flightdeck.thermai.uk";
|
|
|
75
100
|
var CONFIG_PATH = join(homedir(), ".flightdeck", "config.json");
|
|
76
101
|
var ACCOUNTING_HEADER = "X-Flightdeck-Accounting";
|
|
77
102
|
var ACCOUNTING_CONTRACT = "credits-v1";
|
|
103
|
+
var ARTIFACT_REDIRECTS = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
104
|
+
function isLoopback(url) {
|
|
105
|
+
return ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
106
|
+
}
|
|
78
107
|
function normalizeApiUrl(value) {
|
|
79
108
|
let url;
|
|
80
109
|
try {
|
|
@@ -82,8 +111,7 @@ function normalizeApiUrl(value) {
|
|
|
82
111
|
} catch {
|
|
83
112
|
throw new CliError("Invalid FlightDeck API URL. Use an HTTPS URL.");
|
|
84
113
|
}
|
|
85
|
-
|
|
86
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && localHost)) {
|
|
114
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback(url))) {
|
|
87
115
|
throw new CliError("FlightDeck API URLs must use HTTPS (HTTP is allowed only for localhost)");
|
|
88
116
|
}
|
|
89
117
|
if (url.username || url.password || url.search || url.hash) {
|
|
@@ -145,9 +173,53 @@ function saveConfig(config, path = CONFIG_PATH) {
|
|
|
145
173
|
}
|
|
146
174
|
}
|
|
147
175
|
function deleteConfig(path = CONFIG_PATH) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
176
|
+
try {
|
|
177
|
+
unlinkSync(path);
|
|
178
|
+
return true;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error.code === "ENOENT") return false;
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function revokeCurrentCredential(config) {
|
|
185
|
+
const controller = new AbortController();
|
|
186
|
+
let timer;
|
|
187
|
+
const deadline = new Promise((resolve4) => {
|
|
188
|
+
timer = setTimeout(() => {
|
|
189
|
+
controller.abort();
|
|
190
|
+
resolve4("unconfirmed");
|
|
191
|
+
}, 3e3);
|
|
192
|
+
});
|
|
193
|
+
const revoke = async () => {
|
|
194
|
+
try {
|
|
195
|
+
const response = await fetch(endpoint(config.api_url, "/auth/credential/revoke"), {
|
|
196
|
+
method: "POST",
|
|
197
|
+
headers: { Authorization: `Bearer ${config.api_key}`, [ACCOUNTING_HEADER]: ACCOUNTING_CONTRACT },
|
|
198
|
+
credentials: "omit",
|
|
199
|
+
redirect: "error",
|
|
200
|
+
signal: controller.signal
|
|
201
|
+
});
|
|
202
|
+
if (response.status === 204) return "revoked";
|
|
203
|
+
if (response.status !== 200 && response.status !== 401) {
|
|
204
|
+
void response.body?.cancel().catch(() => {
|
|
205
|
+
});
|
|
206
|
+
return "unconfirmed";
|
|
207
|
+
}
|
|
208
|
+
const body = await response.json();
|
|
209
|
+
if (body && typeof body === "object") {
|
|
210
|
+
if (response.status === 200 && body.ok === true) return "revoked";
|
|
211
|
+
if (response.status === 401 && config.api_key.startsWith("fd_k_") && body.error === "unauthorized") return "invalid";
|
|
212
|
+
}
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
return "unconfirmed";
|
|
216
|
+
};
|
|
217
|
+
try {
|
|
218
|
+
return await Promise.race([revoke(), deadline]);
|
|
219
|
+
} finally {
|
|
220
|
+
clearTimeout(timer);
|
|
221
|
+
controller.abort();
|
|
222
|
+
}
|
|
151
223
|
}
|
|
152
224
|
function requestBody(body, headers) {
|
|
153
225
|
if (body instanceof FormData) return body;
|
|
@@ -167,7 +239,9 @@ async function publicApiRequest(apiUrl, method, path, body) {
|
|
|
167
239
|
});
|
|
168
240
|
}
|
|
169
241
|
async function apiRequest(method, path, body) {
|
|
170
|
-
|
|
242
|
+
return authenticatedRequest(loadConfig(), method, path, body);
|
|
243
|
+
}
|
|
244
|
+
async function authenticatedRequest(config, method, path, body, redirect = "follow") {
|
|
171
245
|
const headers = {
|
|
172
246
|
Authorization: `Bearer ${config.api_key}`,
|
|
173
247
|
[ACCOUNTING_HEADER]: ACCOUNTING_CONTRACT
|
|
@@ -180,8 +254,12 @@ async function apiRequest(method, path, body) {
|
|
|
180
254
|
const response = await request(endpoint(config.api_url, path), {
|
|
181
255
|
method,
|
|
182
256
|
headers,
|
|
183
|
-
body: requestBody(body, headers)
|
|
257
|
+
body: requestBody(body, headers),
|
|
258
|
+
redirect
|
|
184
259
|
});
|
|
260
|
+
if (response.status === 403) {
|
|
261
|
+
throw await suspensionError(response) ?? httpError("Access denied", response.status);
|
|
262
|
+
}
|
|
185
263
|
if (path !== "/auth/credential/revoke" && (response.ok || response.status === 402)) assertAccountingContract(response);
|
|
186
264
|
if (response.status === 409) {
|
|
187
265
|
const body2 = await response.clone().json().catch(() => ({}));
|
|
@@ -189,6 +267,31 @@ async function apiRequest(method, path, body) {
|
|
|
189
267
|
}
|
|
190
268
|
return response;
|
|
191
269
|
}
|
|
270
|
+
async function artifactRequest(flightId, artifactId) {
|
|
271
|
+
const config = loadConfig();
|
|
272
|
+
const path = `/flights/${encodeURIComponent(flightId)}/outputs/${encodeURIComponent(artifactId)}`;
|
|
273
|
+
const response = await authenticatedRequest(config, "GET", path, void 0, "manual");
|
|
274
|
+
if (!ARTIFACT_REDIRECTS.has(response.status)) return response;
|
|
275
|
+
const location = response.headers.get("Location");
|
|
276
|
+
await response.body?.cancel();
|
|
277
|
+
assertAccountingContract(response);
|
|
278
|
+
let target;
|
|
279
|
+
try {
|
|
280
|
+
target = new URL(location ?? "");
|
|
281
|
+
const api = new URL(normalizeApiUrl(config.api_url));
|
|
282
|
+
const localStorage = api.protocol === "http:" && isLoopback(api) && target.protocol === "http:" && isLoopback(target);
|
|
283
|
+
if (target.protocol !== "https:" && !localStorage || target.username || target.password || target.hash) {
|
|
284
|
+
throw new Error("invalid storage destination");
|
|
285
|
+
}
|
|
286
|
+
} catch {
|
|
287
|
+
throw new CliError("The Flightdeck API returned an invalid or unsafe storage URL. Contact your ThermAI operator.");
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
return await fetch(target.href, { method: "GET", credentials: "omit", redirect: "error" });
|
|
291
|
+
} catch (cause) {
|
|
292
|
+
throw new CliError("Could not download output from storage. Retry flightdeck download to obtain a fresh link.", { cause });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
192
295
|
function assertAccountingContract(response) {
|
|
193
296
|
if (response.headers.get(ACCOUNTING_HEADER) !== ACCOUNTING_CONTRACT) {
|
|
194
297
|
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 +1071,14 @@ ${submitted.length} submitted, ${failures} failed.`);
|
|
|
968
1071
|
return { submitted, failures };
|
|
969
1072
|
}
|
|
970
1073
|
|
|
1074
|
+
// src/recovery-status.ts
|
|
1075
|
+
function recoveryStatusLine(value) {
|
|
1076
|
+
if (!value || typeof value !== "object") return null;
|
|
1077
|
+
const recovery = value;
|
|
1078
|
+
if (!recovery.phase || !["collecting", "cleanup", "queued", "replacement", "finished"].includes(recovery.phase)) return null;
|
|
1079
|
+
return ` Recovery: ${recovery.phase} (replacement ${recovery.replacement_authorized ? 1 : 0} of ${recovery.retry_limit ?? 1} authorized)`;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
971
1082
|
// src/commands/status.ts
|
|
972
1083
|
async function status(flightId) {
|
|
973
1084
|
const response = await apiRequest("GET", `/flights/${flightId}`);
|
|
@@ -976,6 +1087,8 @@ async function status(flightId) {
|
|
|
976
1087
|
console.log(`Flight: ${body.flight_id}`);
|
|
977
1088
|
console.log(` Name: ${body.name}`);
|
|
978
1089
|
console.log(` Status: ${body.status}`);
|
|
1090
|
+
const recovery = recoveryStatusLine(body.recovery);
|
|
1091
|
+
if (recovery) console.log(recovery);
|
|
979
1092
|
console.log(` Image: ${body.image}`);
|
|
980
1093
|
console.log(` GPU: ${body.gpu_type ?? "any"} x${body.gpu_count}`);
|
|
981
1094
|
if (body.queued_at) console.log(` Queued: ${body.queued_at}`);
|
|
@@ -1064,7 +1177,7 @@ async function download(flightId, options) {
|
|
|
1064
1177
|
const root = resolve3(options.outputDir);
|
|
1065
1178
|
await mkdir(root, { recursive: true });
|
|
1066
1179
|
for (const output of manifest.outputs ?? []) {
|
|
1067
|
-
const response = await
|
|
1180
|
+
const response = await artifactRequest(flightId, output.artifact_id);
|
|
1068
1181
|
if (!response.ok) throw httpError("Unable to download output", response.status);
|
|
1069
1182
|
const target = join3(root, basename(output.filename));
|
|
1070
1183
|
await writeFile(target, Buffer.from(await response.arrayBuffer()), { flag: "wx" });
|
|
@@ -1180,6 +1293,8 @@ function sleep(milliseconds) {
|
|
|
1180
1293
|
return new Promise((resolve4) => setTimeout(resolve4, milliseconds));
|
|
1181
1294
|
}
|
|
1182
1295
|
async function loginFailure(response) {
|
|
1296
|
+
const suspended = await suspensionError(response);
|
|
1297
|
+
if (suspended) return suspended;
|
|
1183
1298
|
try {
|
|
1184
1299
|
const body = await response.json();
|
|
1185
1300
|
if (body.error === "device_authorization_denied") {
|
|
@@ -1234,23 +1349,27 @@ Verification code: ${authorization.user_code}`);
|
|
|
1234
1349
|
|
|
1235
1350
|
// src/commands/logout.ts
|
|
1236
1351
|
async function logout(options) {
|
|
1237
|
-
|
|
1352
|
+
const config = options.local ? null : readConfig();
|
|
1353
|
+
let removed;
|
|
1354
|
+
try {
|
|
1355
|
+
removed = deleteConfig();
|
|
1356
|
+
} catch (cause) {
|
|
1357
|
+
throw new CliError("Could not remove the local login. Local logout was not completed; check file permissions and retry flightdeck logout.", { cause });
|
|
1358
|
+
}
|
|
1359
|
+
if (!removed) {
|
|
1238
1360
|
console.log("No local FlightDeck login was found.");
|
|
1239
1361
|
return;
|
|
1240
1362
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
}
|
|
1363
|
+
console.log("Local login removed.");
|
|
1364
|
+
if (options.local) return;
|
|
1365
|
+
const result = config ? await revokeCurrentCredential(config) : "unconfirmed";
|
|
1366
|
+
if (result === "revoked") {
|
|
1367
|
+
console.log("Server credential revoked.");
|
|
1368
|
+
} else if (result === "invalid") {
|
|
1369
|
+
console.log("Server reports this credential is already invalid.");
|
|
1370
|
+
} else {
|
|
1371
|
+
console.error("Warning: Server revocation was not confirmed; other copies of this credential may remain valid. Use portal credential management or contact your organization admin.");
|
|
1251
1372
|
}
|
|
1252
|
-
deleteConfig();
|
|
1253
|
-
console.log(options.local ? "Local login removed." : "Logged out and credential revoked.");
|
|
1254
1373
|
}
|
|
1255
1374
|
|
|
1256
1375
|
// src/commands/whoami.ts
|
|
@@ -1271,7 +1390,7 @@ async function balance() {
|
|
|
1271
1390
|
var program = new Command();
|
|
1272
1391
|
program.name("flightdeck").description("FlightDeck CLI \u2014 submit GPU compute jobs").option("--debug", "include safe error type/code and CLI frame diagnostics (no raw stack or credentials)").version(JSON.parse(readFileSync4(new URL("../package.json", import.meta.url), "utf8")).version);
|
|
1273
1392
|
program.command("login").description("Log in through the FlightDeck portal").option("--api-url <url>", "FlightDeck API URL", DEFAULT_API_URL).option("--name <name>", "name for this CLI credential", "flightdeck-cli").action(login);
|
|
1274
|
-
program.command("logout").description("
|
|
1393
|
+
program.command("logout").description("Remove the local login and attempt server credential revocation").option("--local", "remove the local login without revoking the credential").action(logout);
|
|
1275
1394
|
program.command("whoami").description("Show the current FlightDeck account").action(whoami);
|
|
1276
1395
|
program.command("balance").description("Show the current credit balance").action(balance);
|
|
1277
1396
|
program.command("submit").description("Submit a job from local files").argument("<entrypoint>", 'command to run (e.g. "python train.py --epochs 50")').option("-n, --name <name>", "job name", "cli-job").option("-f, --files <glob...>", "files to include (default: current directory)").option("-r, --requirements <file>", "pip requirements file", "requirements.txt").option("--gpu <type>", "GPU type (e.g. A100, H100)").option("--gpu-count <n>", "number of GPUs", "1").option("--time <duration>", "max duration (e.g. 1h, 30m, 3600s)", "1h").option("--base-image <image>", "override base Docker image").option("--provider <id>", "pin the flight to one compute provider (default: operator's order)").option("-e, --env <vars...>", "environment variables (KEY=VALUE)").action(submit);
|