@flatkey-ai/cli 0.2.3 → 0.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkey-ai/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
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
@@ -1,4 +1,5 @@
1
1
  import { join } from "node:path";
2
+ import { DEFAULT_BASE_URL } from "./api.js";
2
3
 
3
4
  const COMMANDS = new Set([
4
5
  "audio",
@@ -502,7 +503,7 @@ async function handleGenerate(command, deps) {
502
503
  const options = {
503
504
  ...command.options,
504
505
  apiKey,
505
- baseUrl: routerOrigin,
506
+ baseUrl: routerOrigin ?? DEFAULT_BASE_URL,
506
507
  tempMediaBaseUrl: tempMediaBaseUrl ?? DEFAULT_CONSOLE_URL,
507
508
  env: deps.env ?? process.env,
508
509
  fetch: deps.fetch,
@@ -636,7 +637,8 @@ async function waitForVideoResult(response, options) {
636
637
 
637
638
  while (Date.now() <= deadline) {
638
639
  last = await options.getVideo(options, taskId);
639
- if (hasArtifact(last) || isVideoDone(last)) return last;
640
+ if (hasArtifact(last)) return last;
641
+ if (isVideoDone(last)) return withVideoContentFallback(last, options, taskId);
640
642
  if (isVideoFailed(last)) {
641
643
  const message = last?.error?.message ?? last?.message ?? `Video generation failed: ${taskId}`;
642
644
  throw new Error(message);
@@ -647,6 +649,18 @@ async function waitForVideoResult(response, options) {
647
649
  throw new Error(`Video task still processing after ${Math.round(timeoutMs / 1000)}s: ${taskId}`);
648
650
  }
649
651
 
652
+ function withVideoContentFallback(response, options, taskId) {
653
+ const baseUrl = String(options.baseUrl ?? "").replace(/\/$/, "");
654
+ if (!baseUrl || !taskId) return response;
655
+ return {
656
+ ...response,
657
+ metadata: {
658
+ ...(response.metadata ?? {}),
659
+ url: `${baseUrl}/v1/videos/${encodeURIComponent(taskId)}/content`,
660
+ },
661
+ };
662
+ }
663
+
650
664
  function hasArtifact(response) {
651
665
  return Boolean(
652
666
  response?.metadata?.url