@flatkey-ai/cli 0.1.8 → 0.1.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkey-ai/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Flatkey media generation CLI for image, video, audio, credits, status, and models.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -219,7 +219,8 @@ async function handleLogin(command, deps) {
219
219
  const { createDeviceAuthorization, pollDeviceAuthorization } = await import("./api.js");
220
220
  const deviceId = await ensureDeviceId({ configDir: deps.configDir });
221
221
  const version = await readPackageVersion();
222
- const consoleUrl = command.options.console_url;
222
+ const env = deps.env ?? process.env;
223
+ const consoleUrl = firstNonEmpty(command.options.console_url, env.CONSOLE_ORIGIN);
223
224
  const authorization = await createDeviceAuthorization({
224
225
  consoleUrl,
225
226
  deviceId,
@@ -322,6 +323,10 @@ function formatAuthStatus(status) {
322
323
  return `Authenticated via ${status.source}: ${status.key}`;
323
324
  }
324
325
 
326
+ function firstNonEmpty(...values) {
327
+ return values.find((value) => typeof value === "string" && value.trim() !== "");
328
+ }
329
+
325
330
  async function handleLogout(command, deps = {}) {
326
331
  const { clearSavedApiKey } = await import("./config.js");
327
332
  const configPath = await clearSavedApiKey({ configDir: deps.configDir });
@@ -385,7 +390,7 @@ async function handleGenerate(command, deps) {
385
390
  const options = {
386
391
  ...command.options,
387
392
  apiKey,
388
- baseUrl: command.options.base_url,
393
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).ROUTER_ORIGIN),
389
394
  fetch: deps.fetch,
390
395
  };
391
396
  if (command.options.dry_run) {
@@ -467,7 +472,7 @@ async function handleVoices(command, deps) {
467
472
  });
468
473
  return getVoices({
469
474
  apiKey,
470
- baseUrl: command.options.base_url,
475
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).ROUTER_ORIGIN),
471
476
  fetch: deps.fetch,
472
477
  });
473
478
  }
@@ -519,7 +524,7 @@ async function handleUtility(command, deps) {
519
524
  });
520
525
  const options = {
521
526
  apiKey,
522
- baseUrl: command.options.base_url,
527
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).CONSOLE_ORIGIN),
523
528
  fetch: deps.fetch,
524
529
  };
525
530
  return command.group === "credits" ? getCredits(options) : getStatus(options);
@@ -537,7 +542,7 @@ async function handleModels(command, deps) {
537
542
  });
538
543
  const response = await getModels({
539
544
  apiKey,
540
- baseUrl: command.options.base_url,
545
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).CONSOLE_ORIGIN),
541
546
  fetch: deps.fetch,
542
547
  });
543
548
  const models = normalizeModels(response, command.options.type);
package/src/help.js CHANGED
@@ -31,6 +31,8 @@ Commands:
31
31
 
32
32
  Environment:
33
33
  - FLATKEY_API_KEY: Flatkey API key.
34
+ - ROUTER_ORIGIN: Override generation router origin, e.g. staging router.
35
+ - CONSOLE_ORIGIN: Override console API origin, e.g. staging console.
34
36
  - Default router: https://router.flatkey.ai
35
37
 
36
38
  Recovery:
@@ -65,6 +67,10 @@ Global options:
65
67
  --json Print machine-readable JSON
66
68
  --output, -o <file> Write generated output to a local file
67
69
  --base-url <url> Override Flatkey router URL
70
+
71
+ Environment:
72
+ ROUTER_ORIGIN Override generation router origin
73
+ CONSOLE_ORIGIN Override console API origin
68
74
  --console-url <url> Override Flatkey console URL for login
69
75
 
70
76
  Video options: