@thermai/flightdeck-cli 0.1.0-pilot.5 → 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 +37 -12
- package/dist/index.js +96 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,13 +30,14 @@ backend is rejected before job submission; login and credential revocation do no
|
|
|
30
30
|
the accounting contract. See the
|
|
31
31
|
[operator rollout checklist](../docs/runbooks/customer-credits-rollout.md).
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
**`0.1.0-pilot.5`**, published on 21 September 2026, fixes result downloads redirected to signed object
|
|
34
34
|
storage ([#157](https://github.com/ThermAI-Group/thermai_flightdeck/issues/157))
|
|
35
35
|
and includes the merged GPU-recovery status display. Downloads validate the
|
|
36
36
|
accounting contract on Flightdeck's response, then fetch the authorized storage
|
|
37
|
-
object without forwarding the CLI credential.
|
|
38
|
-
|
|
39
|
-
|
|
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.
|
|
40
41
|
|
|
41
42
|
Members and organization administrators receive whole-credit balances,
|
|
42
43
|
estimates and actual customer charges, without provider-cost information.
|
|
@@ -73,15 +74,25 @@ test environment can be selected with `flightdeck login --api-url <HTTPS origin>
|
|
|
73
74
|
|
|
74
75
|
Login saves a scoped credential in `~/.flightdeck/config.json` with restrictive
|
|
75
76
|
permissions. Never share that file or include it in a workload bundle. Use
|
|
76
|
-
`flightdeck logout` to
|
|
77
|
-
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.
|
|
78
79
|
|
|
79
80
|
`--name` labels a credential, not a local account profile. There is one saved
|
|
80
81
|
login per OS user. If already logged in, use `whoami` to inspect it; `login`
|
|
81
82
|
refuses to replace it. Use a separate OS user to preserve an operator's working
|
|
82
83
|
credential, or explicitly choose logout/re-login on the same workstation.
|
|
83
|
-
Logging out
|
|
84
|
-
|
|
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.
|
|
85
96
|
|
|
86
97
|
## Pilot quick-start
|
|
87
98
|
|
|
@@ -189,10 +200,24 @@ new version. Older non-following clients still need upgrading for full paging.
|
|
|
189
200
|
|
|
190
201
|
The CLI exits with status 1 on command failure. Expected authentication,
|
|
191
202
|
network and HTTP failures have concise diagnostics instead of a Node stack.
|
|
192
|
-
An already-configured login leaves the saved credential unchanged
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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.
|
|
196
221
|
|
|
197
222
|
For unexpected faults, `flightdeck --debug <command>` adds allowlisted error
|
|
198
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
|
}
|
|
@@ -148,9 +173,53 @@ function saveConfig(config, path = CONFIG_PATH) {
|
|
|
148
173
|
}
|
|
149
174
|
}
|
|
150
175
|
function deleteConfig(path = CONFIG_PATH) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
+
}
|
|
154
223
|
}
|
|
155
224
|
function requestBody(body, headers) {
|
|
156
225
|
if (body instanceof FormData) return body;
|
|
@@ -188,6 +257,9 @@ async function authenticatedRequest(config, method, path, body, redirect = "foll
|
|
|
188
257
|
body: requestBody(body, headers),
|
|
189
258
|
redirect
|
|
190
259
|
});
|
|
260
|
+
if (response.status === 403) {
|
|
261
|
+
throw await suspensionError(response) ?? httpError("Access denied", response.status);
|
|
262
|
+
}
|
|
191
263
|
if (path !== "/auth/credential/revoke" && (response.ok || response.status === 402)) assertAccountingContract(response);
|
|
192
264
|
if (response.status === 409) {
|
|
193
265
|
const body2 = await response.clone().json().catch(() => ({}));
|
|
@@ -1221,6 +1293,8 @@ function sleep(milliseconds) {
|
|
|
1221
1293
|
return new Promise((resolve4) => setTimeout(resolve4, milliseconds));
|
|
1222
1294
|
}
|
|
1223
1295
|
async function loginFailure(response) {
|
|
1296
|
+
const suspended = await suspensionError(response);
|
|
1297
|
+
if (suspended) return suspended;
|
|
1224
1298
|
try {
|
|
1225
1299
|
const body = await response.json();
|
|
1226
1300
|
if (body.error === "device_authorization_denied") {
|
|
@@ -1275,23 +1349,27 @@ Verification code: ${authorization.user_code}`);
|
|
|
1275
1349
|
|
|
1276
1350
|
// src/commands/logout.ts
|
|
1277
1351
|
async function logout(options) {
|
|
1278
|
-
|
|
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) {
|
|
1279
1360
|
console.log("No local FlightDeck login was found.");
|
|
1280
1361
|
return;
|
|
1281
1362
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
}
|
|
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.");
|
|
1292
1372
|
}
|
|
1293
|
-
deleteConfig();
|
|
1294
|
-
console.log(options.local ? "Local login removed." : "Logged out and credential revoked.");
|
|
1295
1373
|
}
|
|
1296
1374
|
|
|
1297
1375
|
// src/commands/whoami.ts
|
|
@@ -1312,7 +1390,7 @@ async function balance() {
|
|
|
1312
1390
|
var program = new Command();
|
|
1313
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);
|
|
1314
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);
|
|
1315
|
-
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);
|
|
1316
1394
|
program.command("whoami").description("Show the current FlightDeck account").action(whoami);
|
|
1317
1395
|
program.command("balance").description("Show the current credit balance").action(balance);
|
|
1318
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);
|