@flatkey-ai/cli 0.1.9 → 0.1.11

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +19 -20
  3. package/src/models.js +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkey-ai/cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
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
@@ -220,7 +220,7 @@ async function handleLogin(command, deps) {
220
220
  const deviceId = await ensureDeviceId({ configDir: deps.configDir });
221
221
  const version = await readPackageVersion();
222
222
  const env = deps.env ?? process.env;
223
- const consoleUrl = command.options.console_url ?? env.CONSOLE_ORIGIN;
223
+ const consoleUrl = firstNonEmpty(command.options.console_url, env.CONSOLE_ORIGIN);
224
224
  const authorization = await createDeviceAuthorization({
225
225
  consoleUrl,
226
226
  deviceId,
@@ -323,6 +323,10 @@ function formatAuthStatus(status) {
323
323
  return `Authenticated via ${status.source}: ${status.key}`;
324
324
  }
325
325
 
326
+ function firstNonEmpty(...values) {
327
+ return values.find((value) => typeof value === "string" && value.trim() !== "");
328
+ }
329
+
326
330
  async function handleLogout(command, deps = {}) {
327
331
  const { clearSavedApiKey } = await import("./config.js");
328
332
  const configPath = await clearSavedApiKey({ configDir: deps.configDir });
@@ -386,7 +390,7 @@ async function handleGenerate(command, deps) {
386
390
  const options = {
387
391
  ...command.options,
388
392
  apiKey,
389
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).ROUTER_ORIGIN,
393
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).ROUTER_ORIGIN),
390
394
  fetch: deps.fetch,
391
395
  };
392
396
  if (command.options.dry_run) {
@@ -468,7 +472,7 @@ async function handleVoices(command, deps) {
468
472
  });
469
473
  return getVoices({
470
474
  apiKey,
471
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).ROUTER_ORIGIN,
475
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).ROUTER_ORIGIN),
472
476
  fetch: deps.fetch,
473
477
  });
474
478
  }
@@ -520,7 +524,7 @@ async function handleUtility(command, deps) {
520
524
  });
521
525
  const options = {
522
526
  apiKey,
523
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).CONSOLE_ORIGIN,
527
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).CONSOLE_ORIGIN),
524
528
  fetch: deps.fetch,
525
529
  };
526
530
  return command.group === "credits" ? getCredits(options) : getStatus(options);
@@ -529,23 +533,18 @@ async function handleUtility(command, deps) {
529
533
  async function handleModels(command, deps) {
530
534
  const { resolveApiKey } = await import("./config.js");
531
535
  const { getModels } = await import("./api.js");
532
- const { getBundledModels, normalizeModels } = await import("./models.js");
536
+ const { normalizeModels } = await import("./models.js");
533
537
 
534
- try {
535
- const apiKey = await resolveApiKey({
536
- apiKey: command.options.api_key,
537
- env: deps.env ?? process.env,
538
- });
539
- const response = await getModels({
540
- apiKey,
541
- baseUrl: command.options.base_url ?? (deps.env ?? process.env).CONSOLE_ORIGIN,
542
- fetch: deps.fetch,
543
- });
544
- const models = normalizeModels(response, command.options.type);
545
- return { models: models.length ? models : getBundledModels(command.options.type) };
546
- } catch {
547
- return { models: getBundledModels(command.options.type) };
548
- }
538
+ const apiKey = await resolveApiKey({
539
+ apiKey: command.options.api_key,
540
+ env: deps.env ?? process.env,
541
+ });
542
+ const response = await getModels({
543
+ apiKey,
544
+ baseUrl: firstNonEmpty(command.options.base_url, (deps.env ?? process.env).CONSOLE_ORIGIN),
545
+ fetch: deps.fetch,
546
+ });
547
+ return { models: normalizeModels(response, command.options.type) };
549
548
  }
550
549
 
551
550
  function formatHuman(result) {
package/src/models.js CHANGED
@@ -1,24 +1,3 @@
1
- const BUNDLED_MODELS = [
2
- { id: "nano-banana-pro-preview", type: "image" },
3
- { id: "nano-banana-flash", type: "image" },
4
- { id: "gpt-image-2", type: "image" },
5
- { id: "veo-3", type: "video" },
6
- { id: "veo-3-fast", type: "video" },
7
- { id: "seedance2", type: "video" },
8
- { id: "gpt-5.5", type: "text" },
9
- { id: "eleven_multilingual_v2", type: "audio" },
10
- { id: "eleven_turbo_v2_5", type: "audio" },
11
- { id: "eleven_flash_v2_5", type: "audio" },
12
- { id: "sound-generation", type: "audio" },
13
- { id: "music", type: "audio" },
14
- ];
15
-
16
- export function getBundledModels(type) {
17
- return BUNDLED_MODELS
18
- .filter((model) => !type || model.type === type)
19
- .map((model) => ({ ...model, source: "bundled" }));
20
- }
21
-
22
1
  export function normalizeModels(response, type) {
23
2
  const rawModels = Array.isArray(response?.data)
24
3
  ? response.data