@nodaro/shared 3.57.0 → 3.59.0

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 (145) hide show
  1. package/dist/{chunk-3SH5ZUNJ.js → chunk-2S7YYCRT.js} +4 -4
  2. package/dist/{chunk-3SH5ZUNJ.js.map → chunk-2S7YYCRT.js.map} +1 -1
  3. package/dist/{chunk-IQS3WQXQ.js → chunk-2VQHPILW.js} +55 -24
  4. package/dist/chunk-2VQHPILW.js.map +1 -0
  5. package/dist/{chunk-D56ALOLY.js → chunk-3R2KVYXN.js} +3 -3
  6. package/dist/{chunk-D56ALOLY.js.map → chunk-3R2KVYXN.js.map} +1 -1
  7. package/dist/{chunk-OWNPYQSH.cjs → chunk-4GGLKRYI.cjs} +16 -3
  8. package/dist/chunk-4GGLKRYI.cjs.map +1 -0
  9. package/dist/{chunk-ALVO5Q36.cjs → chunk-62RC6K62.cjs} +4 -4
  10. package/dist/{chunk-ALVO5Q36.cjs.map → chunk-62RC6K62.cjs.map} +1 -1
  11. package/dist/chunk-6VXDW2U3.cjs +27 -0
  12. package/dist/{chunk-RKTWLAJO.cjs.map → chunk-6VXDW2U3.cjs.map} +1 -1
  13. package/dist/{chunk-S7FCFQ6X.js → chunk-CF4S4N5X.js} +16 -4
  14. package/dist/chunk-CF4S4N5X.js.map +1 -0
  15. package/dist/{chunk-NJTLBZIP.cjs → chunk-D574HZ35.cjs} +43 -43
  16. package/dist/{chunk-NJTLBZIP.cjs.map → chunk-D574HZ35.cjs.map} +1 -1
  17. package/dist/{chunk-P5KH7GAI.cjs → chunk-DKZGLIFW.cjs} +4 -4
  18. package/dist/{chunk-P5KH7GAI.cjs.map → chunk-DKZGLIFW.cjs.map} +1 -1
  19. package/dist/{chunk-6NZWWMVY.js → chunk-EO4W4MA3.js} +4 -4
  20. package/dist/{chunk-6NZWWMVY.js.map → chunk-EO4W4MA3.js.map} +1 -1
  21. package/dist/{chunk-INGQNLY4.js → chunk-FHCMYGBV.js} +3 -3
  22. package/dist/{chunk-INGQNLY4.js.map → chunk-FHCMYGBV.js.map} +1 -1
  23. package/dist/{chunk-QTTVIQJP.js → chunk-FJCRWDU5.js} +4 -4
  24. package/dist/{chunk-QTTVIQJP.js.map → chunk-FJCRWDU5.js.map} +1 -1
  25. package/dist/{chunk-FVKCNAEQ.js → chunk-HP3YIWNJ.js} +9 -4
  26. package/dist/chunk-HP3YIWNJ.js.map +1 -0
  27. package/dist/{chunk-UJJUX6NW.cjs → chunk-HW6TLOK4.cjs} +9 -3
  28. package/dist/chunk-HW6TLOK4.cjs.map +1 -0
  29. package/dist/{chunk-ZPPFPQPO.js → chunk-IP7QOHWQ.js} +5 -5
  30. package/dist/{chunk-ZPPFPQPO.js.map → chunk-IP7QOHWQ.js.map} +1 -1
  31. package/dist/{chunk-2LWHRJPB.cjs → chunk-K4L4G76I.cjs} +21 -21
  32. package/dist/{chunk-2LWHRJPB.cjs.map → chunk-K4L4G76I.cjs.map} +1 -1
  33. package/dist/{chunk-C3E6UZS4.js → chunk-MTXVODG3.js} +3 -3
  34. package/dist/{chunk-C3E6UZS4.js.map → chunk-MTXVODG3.js.map} +1 -1
  35. package/dist/{chunk-5SXI7IYW.cjs → chunk-NHZWVKGV.cjs} +8 -8
  36. package/dist/{chunk-5SXI7IYW.cjs.map → chunk-NHZWVKGV.cjs.map} +1 -1
  37. package/dist/{chunk-D5J332XS.cjs → chunk-NSZTHJZJ.cjs} +39 -39
  38. package/dist/{chunk-D5J332XS.cjs.map → chunk-NSZTHJZJ.cjs.map} +1 -1
  39. package/dist/{chunk-BH2IDJVO.cjs → chunk-OFL4UH6L.cjs} +46 -46
  40. package/dist/{chunk-BH2IDJVO.cjs.map → chunk-OFL4UH6L.cjs.map} +1 -1
  41. package/dist/{chunk-UFB36LWU.js → chunk-ORJ5HQAB.js} +4 -4
  42. package/dist/{chunk-UFB36LWU.js.map → chunk-ORJ5HQAB.js.map} +1 -1
  43. package/dist/{chunk-ASSJKIZO.cjs → chunk-P7KSB5T6.cjs} +5 -5
  44. package/dist/{chunk-ASSJKIZO.cjs.map → chunk-P7KSB5T6.cjs.map} +1 -1
  45. package/dist/{chunk-R3OIZ2BM.cjs → chunk-PEATSEAD.cjs} +6 -6
  46. package/dist/{chunk-R3OIZ2BM.cjs.map → chunk-PEATSEAD.cjs.map} +1 -1
  47. package/dist/{chunk-QMP3W5GA.js → chunk-PIEMWFSJ.js} +3 -3
  48. package/dist/{chunk-QMP3W5GA.js.map → chunk-PIEMWFSJ.js.map} +1 -1
  49. package/dist/{chunk-MBKJ7IBS.js → chunk-PIX4OCCQ.js} +5 -5
  50. package/dist/{chunk-MBKJ7IBS.js.map → chunk-PIX4OCCQ.js.map} +1 -1
  51. package/dist/{chunk-O33WVAYQ.cjs → chunk-QE7W4YIK.cjs} +6 -6
  52. package/dist/{chunk-O33WVAYQ.cjs.map → chunk-QE7W4YIK.cjs.map} +1 -1
  53. package/dist/{chunk-FFW2HTR2.cjs → chunk-QLLR7GUY.cjs} +5 -5
  54. package/dist/{chunk-FFW2HTR2.cjs.map → chunk-QLLR7GUY.cjs.map} +1 -1
  55. package/dist/{chunk-2LRBQOKA.js → chunk-RGBNOCIO.js} +8 -8
  56. package/dist/{chunk-2LRBQOKA.js.map → chunk-RGBNOCIO.js.map} +1 -1
  57. package/dist/{chunk-OHQBQOGH.cjs → chunk-RSXQOFM7.cjs} +8 -8
  58. package/dist/{chunk-OHQBQOGH.cjs.map → chunk-RSXQOFM7.cjs.map} +1 -1
  59. package/dist/{chunk-SWPTF7QJ.js → chunk-TA7ODVYJ.js} +4 -4
  60. package/dist/{chunk-SWPTF7QJ.js.map → chunk-TA7ODVYJ.js.map} +1 -1
  61. package/dist/{chunk-ZSTL4JEJ.cjs → chunk-UPD7W2KJ.cjs} +12 -12
  62. package/dist/{chunk-ZSTL4JEJ.cjs.map → chunk-UPD7W2KJ.cjs.map} +1 -1
  63. package/dist/{chunk-JYNW4QK7.cjs → chunk-V3NONYLA.cjs} +56 -23
  64. package/dist/chunk-V3NONYLA.cjs.map +1 -0
  65. package/dist/{chunk-4KKFO6YR.cjs → chunk-VLQW4CVW.cjs} +25 -21
  66. package/dist/chunk-VLQW4CVW.cjs.map +1 -0
  67. package/dist/{chunk-EXCZD5ZY.js → chunk-VOZI5F7V.js} +3 -3
  68. package/dist/{chunk-EXCZD5ZY.js.map → chunk-VOZI5F7V.js.map} +1 -1
  69. package/dist/{chunk-ZLSPGMES.cjs → chunk-YE4EDT57.cjs} +11 -11
  70. package/dist/{chunk-ZLSPGMES.cjs.map → chunk-YE4EDT57.cjs.map} +1 -1
  71. package/dist/{chunk-BBMK5XNO.js → chunk-YSEJOJNQ.js} +3 -3
  72. package/dist/{chunk-BBMK5XNO.js.map → chunk-YSEJOJNQ.js.map} +1 -1
  73. package/dist/{chunk-R5GOPHYB.js → chunk-ZU56AMFK.js} +6 -4
  74. package/dist/chunk-ZU56AMFK.js.map +1 -0
  75. package/dist/{chunk-KZTXGMVH.js → chunk-ZVUVSD5X.js} +3 -3
  76. package/dist/{chunk-KZTXGMVH.js.map → chunk-ZVUVSD5X.js.map} +1 -1
  77. package/dist/entries/apps.cjs +42 -42
  78. package/dist/entries/apps.js +7 -7
  79. package/dist/entries/credits.cjs +150 -150
  80. package/dist/entries/credits.d.cts +1 -1
  81. package/dist/entries/credits.d.ts +1 -1
  82. package/dist/entries/credits.js +7 -7
  83. package/dist/entries/edl.cjs +63 -59
  84. package/dist/entries/edl.d.cts +15 -1
  85. package/dist/entries/edl.d.ts +15 -1
  86. package/dist/entries/edl.js +1 -1
  87. package/dist/entries/llm-models.d.cts +1 -1
  88. package/dist/entries/llm-models.d.ts +1 -1
  89. package/dist/entries/model-catalog.cjs +76 -68
  90. package/dist/entries/model-catalog.d.cts +2 -2
  91. package/dist/entries/model-catalog.d.ts +2 -2
  92. package/dist/entries/model-catalog.js +4 -4
  93. package/dist/entries/models.cjs +295 -287
  94. package/dist/entries/models.d.cts +3 -3
  95. package/dist/entries/models.d.ts +3 -3
  96. package/dist/entries/models.js +4 -4
  97. package/dist/entries/nodes.cjs +206 -206
  98. package/dist/entries/nodes.d.cts +1 -1
  99. package/dist/entries/nodes.d.ts +1 -1
  100. package/dist/entries/nodes.js +8 -8
  101. package/dist/entries/pipeline.cjs +152 -152
  102. package/dist/entries/pipeline.d.cts +1 -1
  103. package/dist/entries/pipeline.d.ts +1 -1
  104. package/dist/entries/pipeline.js +3 -3
  105. package/dist/entries/runtime-config.cjs +32 -28
  106. package/dist/entries/runtime-config.d.cts +24 -2
  107. package/dist/entries/runtime-config.d.ts +24 -2
  108. package/dist/entries/runtime-config.js +1 -1
  109. package/dist/entries/ugc.cjs +71 -71
  110. package/dist/entries/ugc.js +4 -4
  111. package/dist/entries/video.cjs +117 -117
  112. package/dist/entries/video.js +4 -4
  113. package/dist/index.cjs +1180 -1156
  114. package/dist/index.d.cts +4 -4
  115. package/dist/index.d.ts +4 -4
  116. package/dist/index.js +19 -19
  117. package/dist/{model-catalog-CwkG9xi-.d.cts → model-catalog-QJ_AO9l0.d.cts} +54 -12
  118. package/dist/{model-catalog-CwkG9xi-.d.ts → model-catalog-QJ_AO9l0.d.ts} +54 -12
  119. package/dist/{model-constants-BbsZSVTA.d.cts → model-constants-BwBdh6Rn.d.cts} +20 -2
  120. package/dist/{model-constants-BbsZSVTA.d.ts → model-constants-BwBdh6Rn.d.ts} +20 -2
  121. package/package.json +1 -1
  122. package/src/__tests__/auto-aspect-source.test.ts +93 -0
  123. package/src/__tests__/camera-switch-contract.test.ts +12 -3
  124. package/src/__tests__/credit-identifiers.test.ts +18 -9
  125. package/src/__tests__/gpt-image-2-size-rules.test.ts +80 -0
  126. package/src/__tests__/normalize-model-input.test.ts +65 -11
  127. package/src/__tests__/resolutions-by-aspect-ratio.test.ts +134 -0
  128. package/src/__tests__/runtime-config.test.ts +28 -0
  129. package/src/__tests__/video-frame-slot.test.ts +5 -0
  130. package/src/camera-switch-contract.ts +13 -1
  131. package/src/entries/model-catalog.ts +2 -0
  132. package/src/entries/models.ts +2 -0
  133. package/src/entries/runtime-config.ts +1 -0
  134. package/src/model-catalog.ts +131 -39
  135. package/src/model-constants.ts +21 -1
  136. package/src/runtime-config/contract.ts +34 -0
  137. package/dist/chunk-4KKFO6YR.cjs.map +0 -1
  138. package/dist/chunk-FVKCNAEQ.js.map +0 -1
  139. package/dist/chunk-IQS3WQXQ.js.map +0 -1
  140. package/dist/chunk-JYNW4QK7.cjs.map +0 -1
  141. package/dist/chunk-OWNPYQSH.cjs.map +0 -1
  142. package/dist/chunk-R5GOPHYB.js.map +0 -1
  143. package/dist/chunk-RKTWLAJO.cjs +0 -27
  144. package/dist/chunk-S7FCFQ6X.js.map +0 -1
  145. package/dist/chunk-UJJUX6NW.cjs.map +0 -1
@@ -75,6 +75,11 @@ describe("videoProviderReferenceSyntax", () => {
75
75
  expect(videoProviderReferenceSyntax("happyhorse-ref2v")).toBe("[Image N]")
76
76
  })
77
77
 
78
+ it("names Gemini Omni Flash 1.2's images in plain words", () => {
79
+ expect(videoProviderReferenceSyntax("gemini-omni-flash-1-2")).toBe("image N")
80
+ expect(videoProviderReferenceSyntax("gemini-omni-flash")).toBe("@image_N")
81
+ })
82
+
78
83
  it("is declared only on reference-capable video models", () => {
79
84
  for (const m of Object.values(MODEL_CATALOG)) {
80
85
  if (!m.referenceSyntax) continue
@@ -13,6 +13,9 @@ export const CAMERA_SWITCH_DEFAULTS = Object.freeze({
13
13
  minShotMs: 2_500,
14
14
  /** Cut this long before the new speaker starts. */
15
15
  leadMs: 200,
16
+ /** Delay each cut by this long — `leadMs`'s counterpart. A route setting
17
+ * only: no node carries it (`CAMERA_SWITCH_NODE_SETTINGS`). */
18
+ lagMs: 0,
16
19
  /** With a `wide` camera: break to it after this long on one camera. */
17
20
  maxShotMs: 20_000,
18
21
  /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */
@@ -60,6 +63,7 @@ export function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: st
60
63
  export const CAMERA_SWITCH_BOUNDS = Object.freeze({
61
64
  minShotMs: Object.freeze({ min: 500, max: 60_000 }),
62
65
  leadMs: Object.freeze({ min: 0, max: 5_000 }),
66
+ lagMs: Object.freeze({ min: 0, max: 5_000 }),
63
67
  maxShotMs: Object.freeze({ min: 0, max: 600_000 }),
64
68
  wideEvery: Object.freeze({ min: 0, max: 20 }),
65
69
  })
@@ -69,6 +73,14 @@ export const CAMERA_SWITCH_NAME_MAX = 80
69
73
 
70
74
  export type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS
71
75
 
76
+ /**
77
+ * The numeric settings a Camera Switch NODE carries (its data, which the
78
+ * canvas and the server's executor send through `cameraSwitchSettingsPayload`).
79
+ * `lagMs` is a setting of the route alone — the API, the SDK and the CLI send
80
+ * it; no node does — so it is not one of them.
81
+ */
82
+ export const CAMERA_SWITCH_NODE_SETTINGS = Object.freeze(["minShotMs", "leadMs", "maxShotMs", "wideEvery"] as const satisfies readonly CameraSwitchNumericSetting[])
83
+
72
84
  /** A setting as a whole number inside its range; undefined when unset. */
73
85
  export function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {
74
86
  if (typeof value !== "number" || !Number.isFinite(value)) return undefined
@@ -195,7 +207,7 @@ export function cameraSwitchSettingsPayload(
195
207
  speakerNames: cleanSpeakerNames(data.speakerNames),
196
208
  layoutHints: data.layoutHints === true,
197
209
  }
198
- for (const key of Object.keys(CAMERA_SWITCH_BOUNDS) as CameraSwitchNumericSetting[]) {
210
+ for (const key of CAMERA_SWITCH_NODE_SETTINGS) {
199
211
  const v = clampCameraSwitchSetting(key, data[key])
200
212
  if (v !== undefined) out[key] = v
201
213
  }
@@ -63,6 +63,8 @@ export {
63
63
  nearestCatalogAspectRatio,
64
64
  autoAspectNeedsSourceImage,
65
65
  isAutoAspectToken,
66
+ resolutionsAtAspectRatio,
67
+ resolutionAtAspectRatio,
66
68
  } from "../model-catalog.js"
67
69
  export type {
68
70
  NormalizedVideoRequest,
@@ -18,6 +18,7 @@ export {
18
18
  getMaxImagePromptChars,
19
19
  PROMPT_HARD_CEILING,
20
20
  LLM_TEXT_INPUT_MAX,
21
+ LLM_STRUCTURED_SYSTEM_MAX,
21
22
  MAX_VIDEO_PROMPT_CHARS_BY_PROVIDER,
22
23
  getMaxVideoPromptChars,
23
24
  NEGATIVE_PROMPT_MAX,
@@ -72,6 +73,7 @@ export {
72
73
  SEEDANCE_VIDEO_EDIT_PROVIDERS,
73
74
  isSeedanceVideoEditProvider,
74
75
  VIDEO_TO_VIDEO_NODE_PROVIDERS,
76
+ DEFAULT_VIDEO_TO_VIDEO_PROVIDER,
75
77
  SEEDANCE_VIDEO_EDIT_SHAPE,
76
78
  FACE_SWAP_PROVIDERS,
77
79
  VIDEO_UPSCALE_PROVIDERS,
@@ -26,6 +26,7 @@ export {
26
26
  isBrandLogoRef,
27
27
  isSameSitePath,
28
28
  isHttpsOrigin,
29
+ isLegacyUiHost,
29
30
  resolveRuntimeApiBase,
30
31
  resolveRuntimeSupabaseUrl,
31
32
  parseRuntimeSurface,
@@ -312,10 +312,31 @@ export interface ModelCatalogEntry {
312
312
  * Declared only where the provider documents its own form: Grok Imagine's
313
313
  * `@image(n)` (docs.kie.ai/market/grok-imagine/image-to-video) and
314
314
  * HappyHorse's `[Image N]` (docs.kie.ai/market/happyhorse-1-1/reference-to-video).
315
+ * Gemini Omni Flash 1.2 documents none and is written plain `image N`, the
316
+ * form of KIE's own example; beside references its frames only guide the
317
+ * clip, in either wording.
315
318
  */
316
- referenceSyntax?: "@image(n)" | "[Image N]"
319
+ referenceSyntax?: "@image(n)" | "[Image N]" | "image N"
317
320
  aspectRatios?: readonly string[]
321
+ /**
322
+ * The model lists "auto", but its own auto does not keep the photo's shape
323
+ * (GPT Image 2.6 renders a portrait square). "auto" with a photo is then
324
+ * resolved as on a model without a native auto: to the listed ratio nearest
325
+ * the photo (`autoAspectNeedsSourceImage`, `normalizeModelInput`). With no
326
+ * photo, or one whose size cannot be read, the model's own "auto" is sent,
327
+ * as before. "auto" stays in `aspectRatios`, so every menu still offers it.
328
+ */
329
+ autoAspectFromSourceImage?: true
318
330
  resolutions?: readonly string[]
331
+ /**
332
+ * The aspect ratios at which this model renders fewer sizes than
333
+ * `resolutions`: each one names the sizes it renders, in the catalog's own
334
+ * spelling. A ratio not listed renders every entry of `resolutions`.
335
+ * `normalizeModelInput` moves a size such a ratio does not render to the
336
+ * largest one it does at or below it, and says so, before the run is priced;
337
+ * a menu reads the sizes on offer with `resolutionsAtAspectRatio`.
338
+ */
339
+ resolutionsByAspectRatio?: Readonly<Record<string, readonly string[]>>
319
340
  /** The resolution a caller who names none lands on when it is not the
320
341
  * cheapest entry (see `defaultResolutionFor`). */
321
342
  defaultResolution?: string
@@ -479,18 +500,32 @@ const FLUX_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"] as const
479
500
  const KONTEXT_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "21:9"] as const
480
501
  const GROK_RATIOS = ["1:1", "16:9", "9:16", "3:2", "2:3"] as const
481
502
  const GPT_IMAGE_RATIOS = ["1:1", "3:2", "2:3"] as const
503
+ // GPT Image 2 (text-to-image and image-to-image) renders every one of these
504
+ // ratios at 1K, 2K and 4K, "auto" and 1:1 included (checked 2026-11-10: 1:1 at
505
+ // 4K came back 2880x2880, "auto" at 2K 2048x2048, and an edit at "auto" and 2K
506
+ // kept a 768x1024 photo's shape at 1536x2048), so it declares no
507
+ // `resolutionsByAspectRatio`. The provider's docs limit 2K and 4K only at ratios
508
+ // it does not offer here (5:4, 4:5, 3:1, 1:3, 9:21).
482
509
  const GPT_IMAGE_2_RATIOS = ["auto", "1:1", "16:9", "9:16", "4:3", "3:4"] as const
483
510
  // GPT Image 2.5 (Flare + Sunburst) widen the set to thirteen — the GPT Image 2
484
511
  // six plus 3:2/2:3, ultra-wide 21:9/27:16, ultra-tall 16:27 and near-square
485
- // 9:8/8:9 (docs.kie.ai/market/gpt/gpt-image-2-5-*). Unlike GPT Image 2, the 2.5
486
- // docs state NO aspect-ratio x resolution restriction, so no cross-field
487
- // constraint is registered for these ids in normalizeModelInput below.
512
+ // 9:8/8:9 (docs.kie.ai/market/gpt/gpt-image-2-5-*).
488
513
  const GPT_IMAGE_2_5_RATIOS = [
489
514
  "auto", "1:1", "3:2", "2:3", "4:3", "3:4", "16:9", "9:16",
490
515
  "21:9", "27:16", "16:27", "9:8", "8:9",
491
516
  ] as const
517
+ // GPT Image 2.5 renders 27:16, 16:27, 9:8 and 8:9 at 1K only; 2K and 4K are for
518
+ // its other ratios (the aspect_ratio field of every 2.5 page: Flare and
519
+ // Sunburst, text-to-image and image-to-image). `normalizeModelInput` moves a
520
+ // larger size there to 1K before the run is priced.
521
+ const GPT_IMAGE_2_5_RESOLUTIONS_BY_RATIO = {
522
+ "27:16": ["1K"], "16:27": ["1K"], "9:8": ["1K"], "8:9": ["1K"],
523
+ } as const
492
524
  // GPT Image 2.6 Flare and Sunburst: auto plus fifteen ratios, Economy a shorter
493
- // list of its own (docs.kie.ai/market/gpt/gpt-image-2-6-*).
525
+ // list of its own (docs.kie.ai/market/gpt/gpt-image-2-6-*). Every 2.6 entry
526
+ // carries `autoAspectFromSourceImage`: 2.6's own auto renders a portrait photo
527
+ // square (measured 2026-11-10: 768x1024 in, 1024x1024 out; 2.5's auto kept
528
+ // it at 3:4), so "auto" with a photo is sent as the ratio nearest the photo.
494
529
  const GPT_IMAGE_2_6_RATIOS = [
495
530
  "auto", "1:1", "3:2", "2:3", "4:3", "3:4", "5:4", "4:5", "16:9", "9:16",
496
531
  "2:1", "1:2", "21:9", "9:21", "3:1", "1:3",
@@ -926,6 +961,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
926
961
  features: ["reference-image"],
927
962
  aspectRatios: GPT_IMAGE_2_5_RATIOS,
928
963
  resolutions: ["1K", "2K", "4K"],
964
+ resolutionsByAspectRatio: GPT_IMAGE_2_5_RESOLUTIONS_BY_RATIO,
929
965
  backgrounds: GPT_IMAGE_BACKGROUNDS,
930
966
  transparentResolution: "1K",
931
967
  backgroundOnlyAtTransparentResolution: true,
@@ -954,6 +990,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
954
990
  features: ["reference-image"],
955
991
  aspectRatios: GPT_IMAGE_2_5_RATIOS,
956
992
  resolutions: ["1K", "2K", "4K"],
993
+ resolutionsByAspectRatio: GPT_IMAGE_2_5_RESOLUTIONS_BY_RATIO,
957
994
  backgrounds: GPT_IMAGE_BACKGROUNDS,
958
995
  transparentResolution: "1K",
959
996
  backgroundOnlyAtTransparentResolution: true,
@@ -982,6 +1019,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
982
1019
  features: ["reference-image"],
983
1020
  aspectRatios: GPT_IMAGE_2_5_RATIOS,
984
1021
  resolutions: ["1K", "2K", "4K"],
1022
+ resolutionsByAspectRatio: GPT_IMAGE_2_5_RESOLUTIONS_BY_RATIO,
985
1023
  backgrounds: GPT_IMAGE_BACKGROUNDS,
986
1024
  transparentResolution: "1K",
987
1025
  backgroundOnlyAtTransparentResolution: true,
@@ -1010,6 +1048,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1010
1048
  features: ["reference-image"],
1011
1049
  aspectRatios: GPT_IMAGE_2_5_RATIOS,
1012
1050
  resolutions: ["1K", "2K", "4K"],
1051
+ resolutionsByAspectRatio: GPT_IMAGE_2_5_RESOLUTIONS_BY_RATIO,
1013
1052
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1014
1053
  transparentResolution: "1K",
1015
1054
  backgroundOnlyAtTransparentResolution: true,
@@ -1037,6 +1076,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1037
1076
  useCases: ["typography", "high-res", "general", "draft"],
1038
1077
  features: ["reference-image"],
1039
1078
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
1079
+ autoAspectFromSourceImage: true,
1040
1080
  resolutions: ["1K", "2K", "4K"],
1041
1081
  qualities: ["auto", "low", "medium", "high", "xhigh", "max"],
1042
1082
  defaultQuality: "medium",
@@ -1078,6 +1118,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1078
1118
  useCases: ["edit", "high-res"],
1079
1119
  features: ["reference-image"],
1080
1120
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
1121
+ autoAspectFromSourceImage: true,
1081
1122
  resolutions: ["1K", "2K", "4K"],
1082
1123
  qualities: ["auto", "low", "medium", "high", "xhigh", "max"],
1083
1124
  defaultQuality: "medium",
@@ -1106,6 +1147,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1106
1147
  useCases: ["typography", "high-res", "general"],
1107
1148
  features: ["reference-image"],
1108
1149
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
1150
+ autoAspectFromSourceImage: true,
1109
1151
  resolutions: ["1K", "2K", "4K"],
1110
1152
  qualities: ["auto", "low", "medium", "high", "xhigh", "max"],
1111
1153
  defaultQuality: "medium",
@@ -1147,6 +1189,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1147
1189
  useCases: ["edit", "high-res"],
1148
1190
  features: ["reference-image"],
1149
1191
  aspectRatios: GPT_IMAGE_2_6_RATIOS,
1192
+ autoAspectFromSourceImage: true,
1150
1193
  resolutions: ["1K", "2K", "4K"],
1151
1194
  qualities: ["auto", "low", "medium", "high", "xhigh", "max"],
1152
1195
  defaultQuality: "medium",
@@ -1181,6 +1224,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1181
1224
  useCases: ["general", "draft"],
1182
1225
  features: ["reference-image"],
1183
1226
  aspectRatios: GPT_IMAGE_2_6_ECONOMY_RATIOS,
1227
+ autoAspectFromSourceImage: true,
1184
1228
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1185
1229
  pricing: [{ identifier: "gpt-image-2-6-economy", credits: 13, note: "1K flat" }],
1186
1230
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
@@ -1199,6 +1243,7 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
1199
1243
  useCases: ["edit", "draft"],
1200
1244
  features: ["reference-image"],
1201
1245
  aspectRatios: GPT_IMAGE_2_6_ECONOMY_RATIOS,
1246
+ autoAspectFromSourceImage: true,
1202
1247
  backgrounds: GPT_IMAGE_BACKGROUNDS,
1203
1248
  pricing: [{ identifier: "gpt-image-2-6-economy-i2i", credits: 13, note: "1K flat" }],
1204
1249
  valueLabels: GPT_IMAGE_2_6_VALUE_LABELS,
@@ -1940,6 +1985,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1940
1985
  description: "Google Gemini Omni Flash 1.2 — 3–15s video with native sound, from 360p to 4K: from text, up to 6 reference images, exact first and last frames, or a video edit. Priced per second.",
1941
1986
  useCases: ["cinematic", "fast"],
1942
1987
  features: ["audio", "reference-image", "reference-to-video", "end-frame"],
1988
+ referenceSyntax: "image N",
1943
1989
  aspectRatios: ["16:9", "9:16", "auto"],
1944
1990
  resolutions: ["360p", "720p", "1080p", "4k"],
1945
1991
  defaultResolution: "720p",
@@ -4004,8 +4050,9 @@ export interface SourceImageSize {
4004
4050
  export interface ModelInputContext {
4005
4051
  /**
4006
4052
  * The image an image-to-image or edit request transforms. Only read to
4007
- * resolve "auto" on a model without a native auto; absent or unusable means
4008
- * the size is unknown and "auto" snaps the way it always has.
4053
+ * resolve "auto" on a model without a native auto, or whose own auto does
4054
+ * not keep the photo's shape (`autoAspectFromSourceImage`); absent or
4055
+ * unusable means the size is unknown and "auto" snaps the way it always has.
4009
4056
  */
4010
4057
  sourceImage?: SourceImageSize
4011
4058
  }
@@ -4066,14 +4113,59 @@ export function nearestCatalogAspectRatio(
4066
4113
 
4067
4114
  /**
4068
4115
  * True when `aspectRatio` is "auto" and `modelId`'s catalog ratio list does not
4069
- * carry "auto" — the one case where the source image's size decides the ratio.
4070
- * A caller that has to fetch the size asks this first, so a request that will
4071
- * not use it never pays for the read.
4116
+ * carry "auto", or carries it but the model's own auto does not keep the
4117
+ * photo's shape (`autoAspectFromSourceImage`) — the cases where the source
4118
+ * image's size decides the ratio. A caller that has to fetch the size asks
4119
+ * this first, so a request that will not use it never pays for the read.
4072
4120
  */
4073
4121
  export function autoAspectNeedsSourceImage(modelId: string | undefined, aspectRatio: unknown): boolean {
4074
4122
  if (!modelId || !isAutoAspectToken(aspectRatio)) return false
4075
- const ratios = MODEL_CATALOG[modelId]?.aspectRatios
4076
- return ratios !== undefined && ratios.length > 0 && !ratios.some(isAutoAspectToken)
4123
+ const entry = MODEL_CATALOG[modelId]
4124
+ const ratios = entry?.aspectRatios
4125
+ if (ratios === undefined || ratios.length === 0) return false
4126
+ return entry?.autoAspectFromSourceImage === true || !ratios.some(isAutoAspectToken)
4127
+ }
4128
+
4129
+ /**
4130
+ * The sizes `modelId` renders at `aspectRatio`, in the catalog's order: its
4131
+ * `resolutions`, narrowed where `resolutionsByAspectRatio` lists that ratio.
4132
+ * `undefined` for an unknown model or one with no size setting. What a menu
4133
+ * offers once a ratio is chosen.
4134
+ */
4135
+ export function resolutionsAtAspectRatio(modelId: string, aspectRatio: unknown): readonly string[] | undefined {
4136
+ const m = MODEL_CATALOG[modelId]
4137
+ const all = m?.resolutions
4138
+ if (!all || all.length === 0) return undefined
4139
+ const byRatio = m.resolutionsByAspectRatio
4140
+ const ratio = typeof aspectRatio === "string" ? aspectRatio.trim() : undefined
4141
+ // Own keys only: a ratio such as "constructor" must not read the prototype.
4142
+ const only = byRatio && ratio !== undefined && Object.prototype.hasOwnProperty.call(byRatio, ratio)
4143
+ ? byRatio[ratio]
4144
+ : undefined
4145
+ return only ? all.filter((r) => only.includes(r)) : all
4146
+ }
4147
+
4148
+ /**
4149
+ * The size `modelId` renders `resolution` at, at `aspectRatio`: the same size
4150
+ * where that ratio renders it (or the model limits no ratio), else the largest
4151
+ * size the ratio renders at or below it, else its smallest. A size the model
4152
+ * does not list comes back as it is: snapping the lever itself is
4153
+ * `normalizeModelInput`'s. A route that prices a run without that function
4154
+ * prices and sends the size this returns, so the two agree.
4155
+ */
4156
+ export function resolutionAtAspectRatio(
4157
+ modelId: string,
4158
+ aspectRatio: unknown,
4159
+ resolution: string | undefined,
4160
+ ): string | undefined {
4161
+ if (resolution === undefined) return undefined
4162
+ const all = MODEL_CATALOG[modelId]?.resolutions
4163
+ const offered = resolutionsAtAspectRatio(modelId, aspectRatio)
4164
+ if (!all || !offered || offered.length === 0 || offered.includes(resolution)) return resolution
4165
+ const at = all.indexOf(resolution)
4166
+ if (at < 0) return resolution
4167
+ const atOrBelow = offered.filter((r) => all.indexOf(r) <= at)
4168
+ return atOrBelow.length > 0 ? atOrBelow[atOrBelow.length - 1]! : offered[0]!
4077
4169
  }
4078
4170
 
4079
4171
  /**
@@ -4090,13 +4182,16 @@ export function autoAspectNeedsSourceImage(modelId: string | undefined, aspectRa
4090
4182
  *
4091
4183
  * Rules, mirroring the config panels' provider-change snap:
4092
4184
  * - Model has no such lever → drop the value (sending it 400s upstream).
4093
- * - "auto" on a model whose list lacks it, with a known `context.sourceImage`
4094
- * → the listed ratio nearest the source's shape (`nearestCatalogAspectRatio`).
4095
- * "auto" asks to keep the source photo's shape; the first listed ratio
4096
- * would reframe every source of another shape.
4185
+ * - "auto" on a model whose list lacks it, or whose own auto does not keep
4186
+ * the photo's shape (`autoAspectFromSourceImage`), with a known
4187
+ * `context.sourceImage` → the listed ratio nearest the source's shape
4188
+ * (`nearestCatalogAspectRatio`). "auto" asks to keep the source photo's
4189
+ * shape; the first listed ratio would reframe every source of another shape.
4097
4190
  * - Value outside the model's allow-list → snap to the model's default
4098
4191
  * (`defaultResolutionFor`) or the first valid option.
4099
- * - Then apply cross-field constraints that only hold for certain models.
4192
+ * - Then apply the cross-field constraints the catalog declares: a size the
4193
+ * ratio does not render (`resolutionsByAspectRatio`), and the size a
4194
+ * background setting renders at (`transparentResolution`).
4100
4195
  *
4101
4196
  * Unknown model ids pass through untouched — the route's Zod model enum is the
4102
4197
  * right gate for those, exactly as in `validateModelInput`.
@@ -4162,11 +4257,14 @@ export function normalizeModelInput(
4162
4257
  : undefined
4163
4258
  if (sourceRatio !== undefined && input.aspectRatio !== undefined) {
4164
4259
  const { width, height } = context.sourceImage!
4260
+ const why = m.autoAspectFromSourceImage === true
4261
+ ? `${m.label}'s own "auto" does not keep the photo's shape`
4262
+ : `${m.label} has no "auto" aspect ratio`
4165
4263
  adjustments.push({
4166
4264
  field: "aspectRatio",
4167
4265
  from: input.aspectRatio,
4168
4266
  to: sourceRatio,
4169
- reason: `${m.label} has no "auto" aspect ratio — using "${sourceRatio}", the supported ratio closest to the source image's shape (${width}x${height}).`,
4267
+ reason: `${why} — using "${sourceRatio}", the supported ratio closest to the source image's shape (${width}x${height}).`,
4170
4268
  })
4171
4269
  out.aspectRatio = sourceRatio
4172
4270
  } else {
@@ -4185,27 +4283,21 @@ export function normalizeModelInput(
4185
4283
  ? input.duration
4186
4284
  : snap("duration", input.duration, m.durations)
4187
4285
 
4188
- // Cross-field constraints — a pair that is individually valid but jointly
4189
- // rejected upstream. GPT Image 2 (per docs.kie.ai): `auto` requires 1K, and
4190
- // 1:1 cannot go to 4K. Applied last so it sees the already-snapped values.
4191
- if (modelId === "gpt-image-2" || modelId === "gpt-image-2-i2i") {
4192
- if (out.aspectRatio === "auto" && out.resolution !== undefined && out.resolution !== "1K") {
4193
- adjustments.push({
4194
- field: "resolution",
4195
- from: out.resolution,
4196
- to: "1K",
4197
- reason: `${m.label} only renders 1K at the "auto" aspect ratio.`,
4198
- })
4199
- out.resolution = "1K"
4200
- } else if (out.aspectRatio === "1:1" && out.resolution === "4K") {
4201
- adjustments.push({
4202
- field: "resolution",
4203
- from: "4K",
4204
- to: "2K",
4205
- reason: `${m.label} cannot render 4K at a 1:1 aspect ratio.`,
4206
- })
4207
- out.resolution = "2K"
4208
- }
4286
+ // A size the chosen ratio does not render (`resolutionsByAspectRatio`: GPT
4287
+ // Image 2.5's four 1K-only ratios) moves to the largest one it does at or
4288
+ // below it. After the snaps above, so it sees the
4289
+ // ratio and size as they will be sent; before the background rules below,
4290
+ // which read the size this leaves, and before any price is built.
4291
+ const sized = resolutionAtAspectRatio(modelId, out.aspectRatio, out.resolution)
4292
+ if (out.resolution !== undefined && sized !== undefined && sized !== out.resolution) {
4293
+ const offered = resolutionsAtAspectRatio(modelId, out.aspectRatio) ?? [sized]
4294
+ adjustments.push({
4295
+ field: "resolution",
4296
+ from: out.resolution,
4297
+ to: sized,
4298
+ reason: `${m.label} only renders ${offered.join(" or ")} at the "${out.aspectRatio}" aspect ratio.`,
4299
+ })
4300
+ out.resolution = sized
4209
4301
  }
4210
4302
 
4211
4303
  // A transparent background only renders at the size the provider allows it.
@@ -226,6 +226,19 @@ export const PROMPT_HARD_CEILING = 30000
226
226
  */
227
227
  export const LLM_TEXT_INPUT_MAX = 100_000
228
228
 
229
+ /**
230
+ * Ceiling for the `system` prompt of the structured-output routes
231
+ * (`POST /v1/llm/structured` and `POST /v1/llm/structured/jobs`). A client
232
+ * that has the model write in its own vocabulary sends that vocabulary as the
233
+ * system prompt, and it grows with the client's catalogs (Nodaro Studio's
234
+ * production format is close to 100,000 chars), so this is twice
235
+ * {@link LLM_TEXT_INPUT_MAX}. The routes' `input`, and every other LLM text
236
+ * field, stay at LLM_TEXT_INPUT_MAX. 200,000 chars is roughly 50,000 to
237
+ * 100,000 tokens, and a body at both ceilings still fits the API's 1 MB
238
+ * request limit.
239
+ */
240
+ export const LLM_STRUCTURED_SYSTEM_MAX = 200_000
241
+
229
242
  /**
230
243
  * Per-provider maximum VIDEO prompt length (chars), VERIFIED against each model's
231
244
  * official docs.kie.ai schema (2026-06). Absent → {@link VIDEO_PROMPT_MAX} (8000)
@@ -1194,7 +1207,7 @@ export function resolveVideoModeForInputs(
1194
1207
  }
1195
1208
 
1196
1209
  /** The prompt syntax a video provider addresses its images in, by array order. */
1197
- export type VideoReferenceSyntax = "@image_N" | "@image(n)" | "[Image N]"
1210
+ export type VideoReferenceSyntax = "@image_N" | "@image(n)" | "[Image N]" | "image N"
1198
1211
 
1199
1212
  /**
1200
1213
  * The syntax this video model's frame / identity binding sentences are written
@@ -1312,6 +1325,13 @@ export function isSeedanceVideoEditProvider(provider: string | undefined): provi
1312
1325
  export const VIDEO_TO_VIDEO_NODE_PROVIDERS = [...VIDEO_TO_VIDEO_PROVIDERS, ...SEEDANCE_VIDEO_EDIT_PROVIDERS] as const
1313
1326
  export type VideoToVideoNodeProvider = typeof VIDEO_TO_VIDEO_NODE_PROVIDERS[number]
1314
1327
 
1328
+ /**
1329
+ * The model a Video to Video request or node that names none runs on: the
1330
+ * route's and the worker's default, and what the node's model menu shows for an
1331
+ * unset model. One constant, so the server and the editor cannot disagree.
1332
+ */
1333
+ export const DEFAULT_VIDEO_TO_VIDEO_PROVIDER: VideoToVideoNodeProvider = "wan"
1334
+
1315
1335
  /**
1316
1336
  * The request shape Seedance edit mode requires, sent UP FRONT by the Video to
1317
1337
  * Video node: the output takes the source clip's own ratio and length
@@ -29,6 +29,9 @@ export const RUNTIME_CONFIG_KEYS = Object.freeze([
29
29
  "moderation",
30
30
  "previewStopRule",
31
31
  "mediaOrigin",
32
+ "flowUiOrigin",
33
+ "legacyUiHosts",
34
+ "linkOrigin",
32
35
  ] as const)
33
36
  export type RuntimeConfigKey = (typeof RUNTIME_CONFIG_KEYS)[number]
34
37
 
@@ -138,6 +141,20 @@ export interface NodaroRuntimeConfig {
138
141
  * beyond its own site.
139
142
  */
140
143
  readonly mediaOrigin?: string
144
+ /**
145
+ * The https origin the app's own pages live on, when this deployment moved
146
+ * them to a host of their own. A page on it calls the API same-origin.
147
+ * Absent: the deployment has one host.
148
+ */
149
+ readonly flowUiOrigin?: string
150
+ /** The hosts the app's pages moved away from (with `flowUiOrigin`): a navigation on one goes to the page's home. */
151
+ readonly legacyUiHosts?: readonly string[]
152
+ /**
153
+ * The https origin developer-facing links name (published apps, embeds, API
154
+ * examples) when the app's pages live elsewhere. Absent: the page's own
155
+ * origin, as ever.
156
+ */
157
+ readonly linkOrigin?: string
141
158
  }
142
159
 
143
160
  // ── Rules shared by the platform and its readers ─────────────────────────────
@@ -262,6 +279,17 @@ export function surfaceUnitLabel(labels: Readonly<Record<string, string>> | unde
262
279
  return typeof word === "string" && word.length > 0 ? word : single
263
280
  }
264
281
 
282
+ /**
283
+ * A host the app's pages move away from, on a deployment that moved them to a
284
+ * host of their own (`LEGACY_UI_HOSTS`, `legacyUiHosts`): a bare host name in
285
+ * lower case, with no scheme, port, path or space. The one rule for it: the
286
+ * server refuses to start on an entry that is not one, and a reader of
287
+ * /config.js drops it.
288
+ */
289
+ export function isLegacyUiHost(value: unknown): value is string {
290
+ return typeof value === "string" && /^[a-z0-9.-]+$/.test(value)
291
+ }
292
+
265
293
  /**
266
294
  * An https origin, spelled exactly as a browser spells one
267
295
  * (`https://media.example.com`, a port only when it is not 443): what
@@ -479,6 +507,12 @@ export function parseRuntimeConfig(raw: unknown): NodaroRuntimeConfig {
479
507
  if (isRecord(raw.moderation) && raw.moderation.uploadImage === true) out.moderation = { uploadImage: true }
480
508
  if (raw.previewStopRule === true) out.previewStopRule = true
481
509
  if (isHttpsOrigin(raw.mediaOrigin)) out.mediaOrigin = raw.mediaOrigin
510
+ if (isHttpsOrigin(raw.flowUiOrigin)) out.flowUiOrigin = raw.flowUiOrigin
511
+ if (Array.isArray(raw.legacyUiHosts)) {
512
+ const hosts = raw.legacyUiHosts.filter(isLegacyUiHost)
513
+ if (hosts.length > 0) out.legacyUiHosts = hosts
514
+ }
515
+ if (isHttpsOrigin(raw.linkOrigin)) out.linkOrigin = raw.linkOrigin
482
516
  return out
483
517
  }
484
518