@nodaro/shared 3.58.0 → 3.60.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 (172) hide show
  1. package/dist/{chunk-OWNPYQSH.cjs → chunk-4GGLKRYI.cjs} +16 -3
  2. package/dist/chunk-4GGLKRYI.cjs.map +1 -0
  3. package/dist/{chunk-5PJC4ZWO.cjs → chunk-5G23AJBU.cjs} +6 -6
  4. package/dist/{chunk-5PJC4ZWO.cjs.map → chunk-5G23AJBU.cjs.map} +1 -1
  5. package/dist/{chunk-IKOKRJDI.cjs → chunk-5HK5Z5OB.cjs} +4 -4
  6. package/dist/{chunk-IKOKRJDI.cjs.map → chunk-5HK5Z5OB.cjs.map} +1 -1
  7. package/dist/{chunk-WLFT5UVV.cjs → chunk-5Y42RIGY.cjs} +8 -8
  8. package/dist/{chunk-WLFT5UVV.cjs.map → chunk-5Y42RIGY.cjs.map} +1 -1
  9. package/dist/{chunk-L26G7B27.js → chunk-6AJOTEVC.js} +3 -3
  10. package/dist/{chunk-L26G7B27.js.map → chunk-6AJOTEVC.js.map} +1 -1
  11. package/dist/{chunk-OMUYZKRB.js → chunk-6Q6SI7AG.js} +3 -3
  12. package/dist/{chunk-OMUYZKRB.js.map → chunk-6Q6SI7AG.js.map} +1 -1
  13. package/dist/{chunk-4ZZ6SVIQ.cjs → chunk-A6HRY3WF.cjs} +269 -37
  14. package/dist/chunk-A6HRY3WF.cjs.map +1 -0
  15. package/dist/{chunk-ZX6RRM6R.cjs → chunk-AXT7YNOR.cjs} +51 -51
  16. package/dist/{chunk-ZX6RRM6R.cjs.map → chunk-AXT7YNOR.cjs.map} +1 -1
  17. package/dist/{chunk-ODTZV3BW.js → chunk-AZGONXWV.js} +4 -4
  18. package/dist/{chunk-ODTZV3BW.js.map → chunk-AZGONXWV.js.map} +1 -1
  19. package/dist/{chunk-S5VBJJUT.cjs → chunk-BDXXOEBZ.cjs} +80 -57
  20. package/dist/chunk-BDXXOEBZ.cjs.map +1 -0
  21. package/dist/{chunk-QPBBIRLF.cjs → chunk-BGIJO5V4.cjs} +39 -39
  22. package/dist/{chunk-QPBBIRLF.cjs.map → chunk-BGIJO5V4.cjs.map} +1 -1
  23. package/dist/{chunk-NZRG5CXQ.cjs → chunk-BLJUCPMV.cjs} +5 -2
  24. package/dist/chunk-BLJUCPMV.cjs.map +1 -0
  25. package/dist/{chunk-KYHDKKUJ.cjs → chunk-BXNPO3PL.cjs} +8 -8
  26. package/dist/{chunk-KYHDKKUJ.cjs.map → chunk-BXNPO3PL.cjs.map} +1 -1
  27. package/dist/{chunk-S7FCFQ6X.js → chunk-CF4S4N5X.js} +16 -4
  28. package/dist/chunk-CF4S4N5X.js.map +1 -0
  29. package/dist/{chunk-4UUX62S3.cjs → chunk-CIOXUPCJ.cjs} +12 -12
  30. package/dist/{chunk-4UUX62S3.cjs.map → chunk-CIOXUPCJ.cjs.map} +1 -1
  31. package/dist/{chunk-5UVBFY2G.cjs → chunk-DQIJPDHC.cjs} +11 -11
  32. package/dist/{chunk-5UVBFY2G.cjs.map → chunk-DQIJPDHC.cjs.map} +1 -1
  33. package/dist/{chunk-UMPZR56R.js → chunk-DS2TOM32.js} +3 -3
  34. package/dist/{chunk-UMPZR56R.js.map → chunk-DS2TOM32.js.map} +1 -1
  35. package/dist/{chunk-K6UMB37V.js → chunk-EN2YI5TV.js} +3 -3
  36. package/dist/{chunk-K6UMB37V.js.map → chunk-EN2YI5TV.js.map} +1 -1
  37. package/dist/{chunk-SEQ5L72K.js → chunk-G6GMY5BC.js} +21 -4
  38. package/dist/chunk-G6GMY5BC.js.map +1 -0
  39. package/dist/chunk-G7ZYZQKO.cjs +27 -0
  40. package/dist/{chunk-QCW6J6BQ.cjs.map → chunk-G7ZYZQKO.cjs.map} +1 -1
  41. package/dist/{chunk-WBERPAXE.cjs → chunk-GNPJ2JLE.cjs} +6 -6
  42. package/dist/{chunk-WBERPAXE.cjs.map → chunk-GNPJ2JLE.cjs.map} +1 -1
  43. package/dist/{chunk-VZXRDSWA.cjs → chunk-GWBQ3GPO.cjs} +43 -21
  44. package/dist/chunk-GWBQ3GPO.cjs.map +1 -0
  45. package/dist/{chunk-DCP7JFSE.cjs → chunk-HDHLZK7C.cjs} +5 -5
  46. package/dist/{chunk-DCP7JFSE.cjs.map → chunk-HDHLZK7C.cjs.map} +1 -1
  47. package/dist/{chunk-QVPIO2NU.cjs → chunk-HNEF2N5C.cjs} +5 -5
  48. package/dist/{chunk-QVPIO2NU.cjs.map → chunk-HNEF2N5C.cjs.map} +1 -1
  49. package/dist/{chunk-7JM5EZF3.cjs → chunk-HOKWJXHA.cjs} +13 -13
  50. package/dist/{chunk-7JM5EZF3.cjs.map → chunk-HOKWJXHA.cjs.map} +1 -1
  51. package/dist/{chunk-FVKCNAEQ.js → chunk-HP3YIWNJ.js} +9 -4
  52. package/dist/chunk-HP3YIWNJ.js.map +1 -0
  53. package/dist/{chunk-UJJUX6NW.cjs → chunk-HW6TLOK4.cjs} +9 -3
  54. package/dist/chunk-HW6TLOK4.cjs.map +1 -0
  55. package/dist/{chunk-A5ESI2NY.js → chunk-ICDLYU4I.js} +9 -9
  56. package/dist/{chunk-A5ESI2NY.js.map → chunk-ICDLYU4I.js.map} +1 -1
  57. package/dist/{chunk-JUEFRVHZ.js → chunk-IV6IDECY.js} +4 -4
  58. package/dist/{chunk-JUEFRVHZ.js.map → chunk-IV6IDECY.js.map} +1 -1
  59. package/dist/{chunk-HEUWAIXG.js → chunk-JKZVRKN3.js} +36 -14
  60. package/dist/chunk-JKZVRKN3.js.map +1 -0
  61. package/dist/{chunk-ZMH56CLL.js → chunk-KJZVQIN4.js} +3 -3
  62. package/dist/{chunk-ZMH56CLL.js.map → chunk-KJZVQIN4.js.map} +1 -1
  63. package/dist/{chunk-6CYS7VRH.js → chunk-KOLC7AF2.js} +262 -38
  64. package/dist/chunk-KOLC7AF2.js.map +1 -0
  65. package/dist/{chunk-CNSRCZYY.js → chunk-LN3EVFRS.js} +5 -5
  66. package/dist/{chunk-CNSRCZYY.js.map → chunk-LN3EVFRS.js.map} +1 -1
  67. package/dist/{chunk-DC2QPACA.js → chunk-MHY47BLL.js} +4 -4
  68. package/dist/{chunk-DC2QPACA.js.map → chunk-MHY47BLL.js.map} +1 -1
  69. package/dist/{chunk-AWS4BWEC.js → chunk-Q6IES3U2.js} +5 -2
  70. package/dist/chunk-Q6IES3U2.js.map +1 -0
  71. package/dist/{chunk-PK4ZR2SK.cjs → chunk-RRPPXZ36.cjs} +4 -4
  72. package/dist/{chunk-PK4ZR2SK.cjs.map → chunk-RRPPXZ36.cjs.map} +1 -1
  73. package/dist/{chunk-6TFWFYYI.js → chunk-SCYBGTX6.js} +3 -3
  74. package/dist/{chunk-6TFWFYYI.js.map → chunk-SCYBGTX6.js.map} +1 -1
  75. package/dist/{chunk-I7NG2D6X.cjs → chunk-SKFJIFEV.cjs} +21 -21
  76. package/dist/{chunk-I7NG2D6X.cjs.map → chunk-SKFJIFEV.cjs.map} +1 -1
  77. package/dist/{chunk-VVGSIWNL.js → chunk-TZ42IVSF.js} +4 -4
  78. package/dist/{chunk-VVGSIWNL.js.map → chunk-TZ42IVSF.js.map} +1 -1
  79. package/dist/{chunk-IQBIH3AE.js → chunk-URLDVK67.js} +3 -3
  80. package/dist/{chunk-IQBIH3AE.js.map → chunk-URLDVK67.js.map} +1 -1
  81. package/dist/{chunk-IOET54EV.js → chunk-VB2ARGQ6.js} +35 -3
  82. package/dist/chunk-VB2ARGQ6.js.map +1 -0
  83. package/dist/{chunk-BSENM6HM.js → chunk-VYQ25YQF.js} +3 -3
  84. package/dist/{chunk-BSENM6HM.js.map → chunk-VYQ25YQF.js.map} +1 -1
  85. package/dist/{chunk-QSWUSXRL.cjs → chunk-WGKAOUEQ.cjs} +41 -2
  86. package/dist/chunk-WGKAOUEQ.cjs.map +1 -0
  87. package/dist/{chunk-M7SMSAOU.js → chunk-YHVEZVAO.js} +4 -4
  88. package/dist/{chunk-M7SMSAOU.js.map → chunk-YHVEZVAO.js.map} +1 -1
  89. package/dist/entries/apps.cjs +43 -43
  90. package/dist/entries/apps.js +8 -8
  91. package/dist/entries/credits.cjs +155 -151
  92. package/dist/entries/credits.d.cts +32 -3
  93. package/dist/entries/credits.d.ts +32 -3
  94. package/dist/entries/credits.js +8 -8
  95. package/dist/entries/edl.cjs +63 -59
  96. package/dist/entries/edl.d.cts +15 -1
  97. package/dist/entries/edl.d.ts +15 -1
  98. package/dist/entries/edl.js +1 -1
  99. package/dist/entries/llm-models.d.cts +1 -1
  100. package/dist/entries/llm-models.d.ts +1 -1
  101. package/dist/entries/model-catalog.cjs +144 -84
  102. package/dist/entries/model-catalog.d.cts +4 -47
  103. package/dist/entries/model-catalog.d.ts +4 -47
  104. package/dist/entries/model-catalog.js +5 -5
  105. package/dist/entries/models.cjs +308 -288
  106. package/dist/entries/models.d.cts +3 -3
  107. package/dist/entries/models.d.ts +3 -3
  108. package/dist/entries/models.js +4 -4
  109. package/dist/entries/nodes.cjs +208 -208
  110. package/dist/entries/nodes.d.cts +1 -1
  111. package/dist/entries/nodes.d.ts +1 -1
  112. package/dist/entries/nodes.js +10 -10
  113. package/dist/entries/pipeline.cjs +152 -152
  114. package/dist/entries/pipeline.d.cts +1 -1
  115. package/dist/entries/pipeline.d.ts +1 -1
  116. package/dist/entries/pipeline.js +3 -3
  117. package/dist/entries/runtime-config.cjs +32 -28
  118. package/dist/entries/runtime-config.d.cts +24 -2
  119. package/dist/entries/runtime-config.d.ts +24 -2
  120. package/dist/entries/runtime-config.js +1 -1
  121. package/dist/entries/ugc.cjs +71 -71
  122. package/dist/entries/ugc.js +4 -4
  123. package/dist/entries/video.cjs +117 -117
  124. package/dist/entries/video.js +4 -4
  125. package/dist/entries/workflow.cjs +147 -147
  126. package/dist/entries/workflow.d.cts +8 -0
  127. package/dist/entries/workflow.d.ts +8 -0
  128. package/dist/entries/workflow.js +2 -2
  129. package/dist/gpt-image-2-6-BeZdT-pW.d.cts +98 -0
  130. package/dist/gpt-image-2-6-BeZdT-pW.d.ts +98 -0
  131. package/dist/index.cjs +1412 -1320
  132. package/dist/index.d.cts +7 -6
  133. package/dist/index.d.ts +7 -6
  134. package/dist/index.js +22 -22
  135. package/dist/{model-catalog-CCsA1isC.d.ts → model-catalog-D6Es7VG-.d.cts} +59 -3
  136. package/dist/{model-catalog-CCsA1isC.d.cts → model-catalog-D6Es7VG-.d.ts} +59 -3
  137. package/dist/{model-constants-BtXkUsX3.d.cts → model-constants-22k3fjp1.d.cts} +22 -1
  138. package/dist/{model-constants-BtXkUsX3.d.ts → model-constants-22k3fjp1.d.ts} +22 -1
  139. package/package.json +1 -1
  140. package/src/__tests__/camera-switch-contract.test.ts +12 -3
  141. package/src/__tests__/credit-identifiers.test.ts +18 -9
  142. package/src/__tests__/gpt-image-2-6-formats.test.ts +171 -0
  143. package/src/__tests__/gpt-image-2-size-rules.test.ts +80 -0
  144. package/src/__tests__/normalize-model-input.test.ts +10 -10
  145. package/src/__tests__/runtime-config.test.ts +28 -0
  146. package/src/camera-switch-contract.ts +13 -1
  147. package/src/credit-identifiers.ts +63 -3
  148. package/src/entries/credits.ts +1 -0
  149. package/src/entries/model-catalog.ts +17 -0
  150. package/src/entries/models.ts +7 -0
  151. package/src/entries/runtime-config.ts +1 -0
  152. package/src/gpt-image-2-6.ts +72 -0
  153. package/src/model-catalog.ts +350 -40
  154. package/src/model-constants.ts +40 -0
  155. package/src/node-execution-state.ts +8 -0
  156. package/src/node-runtime-keys.ts +3 -0
  157. package/src/runtime-config/contract.ts +34 -0
  158. package/dist/chunk-4ZZ6SVIQ.cjs.map +0 -1
  159. package/dist/chunk-6CYS7VRH.js.map +0 -1
  160. package/dist/chunk-AWS4BWEC.js.map +0 -1
  161. package/dist/chunk-FVKCNAEQ.js.map +0 -1
  162. package/dist/chunk-HEUWAIXG.js.map +0 -1
  163. package/dist/chunk-IOET54EV.js.map +0 -1
  164. package/dist/chunk-NZRG5CXQ.cjs.map +0 -1
  165. package/dist/chunk-OWNPYQSH.cjs.map +0 -1
  166. package/dist/chunk-QCW6J6BQ.cjs +0 -27
  167. package/dist/chunk-QSWUSXRL.cjs.map +0 -1
  168. package/dist/chunk-S5VBJJUT.cjs.map +0 -1
  169. package/dist/chunk-S7FCFQ6X.js.map +0 -1
  170. package/dist/chunk-SEQ5L72K.js.map +0 -1
  171. package/dist/chunk-UJJUX6NW.cjs.map +0 -1
  172. package/dist/chunk-VZXRDSWA.cjs.map +0 -1
@@ -42,9 +42,11 @@ import {
42
42
  GPT_IMAGE_2_6_MAX_INPUT_IMAGES,
43
43
  GPT_IMAGE_2_6_QUALITIES,
44
44
  GPT_IMAGE_2_6_RESOLUTIONS,
45
+ gptImage26PricedFormat,
45
46
  isGptImage26I2i,
46
47
  isGptImage26Tiered,
47
48
  type GptImage26TieredModel,
49
+ type ImageFormatLevers,
48
50
  } from "./gpt-image-2-6.js"
49
51
  import { VIDEO_DURATION_AUTO } from "./video-duration-auto.js"
50
52
  import { uiResolutionFill } from "./video-ui-defaults.js"
@@ -89,6 +91,14 @@ function flux2MegapixelTier(model: Flux2Model, resolution?: string): string {
89
91
  /**
90
92
  * The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,
91
93
  * and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.
94
+ * PNG, JPEG and WebP cost the same, so they share those ids. Only a format that
95
+ * prices differently adds a part of its own:
96
+ * - a GIF takes no size (it is 512 pixels a frame) and is priced by its band
97
+ * of frames: `<id>:<quality>:gif-<band>`, on an edit `…:gif-<band>:<N>ref`
98
+ * (`gpt-image-2-6-flare:medium:gif-9-12`);
99
+ * - an SVG is priced at its size and its level of detail:
100
+ * `<id>:<quality>:<size>:svg-<level>`, on an edit `…:svg-<level>:<N>ref`
101
+ * (`gpt-image-2-6-flare-i2i:high:2K:svg-detailed:3ref`).
92
102
  *
93
103
  * A value off the grid (a stored node, the multi-provider preview pricing one
94
104
  * node's data against every model) lands on the default rather than building
@@ -101,13 +111,20 @@ function gptImage26CreditId(
101
111
  quality: string | undefined,
102
112
  resolution: string | undefined,
103
113
  referenceImageCount: number | undefined,
114
+ imageFormat: ImageFormatLevers | undefined,
104
115
  ): string {
105
116
  const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? "") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY
106
117
  const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? "") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION
107
118
  const images = Math.trunc(referenceImageCount ?? 0)
108
119
  const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider
109
- if (!isGptImage26I2i(model)) return `${model}:${q}:${r}`
110
- return `${model}:${q}:${r}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`
120
+ const format = gptImage26PricedFormat(imageFormat)
121
+ const base = format?.kind === "gif"
122
+ ? `${model}:${q}:gif-${format.band}`
123
+ : format?.kind === "svg"
124
+ ? `${model}:${q}:${r}:svg-${format.level}`
125
+ : `${model}:${q}:${r}`
126
+ if (!isGptImage26I2i(model)) return base
127
+ return `${base}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`
111
128
  }
112
129
 
113
130
  /**
@@ -126,6 +143,8 @@ export function buildCreditModelIdentifier(
126
143
  renderingSpeed?: string,
127
144
  targetResolution?: string,
128
145
  referenceImageCount?: number,
146
+ /** The output format, a GIF's frames and an SVG's level: read only by a model whose price depends on them (GPT Image 2.6). */
147
+ imageFormat?: ImageFormatLevers,
129
148
  ): string {
130
149
  // Flux 2 family: billed per output megapixel AND per reference image (each
131
150
  // ref counts as input megapixels). Resolution arrives as "N MP" strings (the
@@ -137,7 +156,7 @@ export function buildCreditModelIdentifier(
137
156
  return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`
138
157
  }
139
158
  if (isGptImage26Tiered(provider)) {
140
- return gptImage26CreditId(provider, quality, resolution, referenceImageCount)
159
+ return gptImage26CreditId(provider, quality, resolution, referenceImageCount, imageFormat)
141
160
  }
142
161
  if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === "high") {
143
162
  return `${provider}:high`
@@ -179,6 +198,13 @@ export interface NormalizedImageGen {
179
198
  resolution?: string
180
199
  quality?: string
181
200
  background?: string
201
+ /** The file the run writes (`outputFormat`); undefined is PNG. */
202
+ outputFormat?: string
203
+ /** A GIF's frames and the time each shows (ms); set only for a GIF. */
204
+ gifFrames?: number
205
+ gifFrameDurationMs?: number
206
+ /** An SVG's level of detail; set only for an SVG. */
207
+ svgLevel?: string
182
208
  /** Empty when the caller's values were already valid for `modelId`. */
183
209
  adjustments: ModelInputAdjustment[]
184
210
  }
@@ -219,6 +245,26 @@ export function imageGenAutoAspectNeedsSourceImage(opts: {
219
245
  return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)
220
246
  }
221
247
 
248
+ /**
249
+ * The output-format levers of a request body or a node's data, typed for
250
+ * `normalizeModelInput`: a non-string format or level is no value, and a GIF's
251
+ * numbers may arrive as numeric strings (a form field, a FieldMapping).
252
+ */
253
+ export function imageFormatInputOf(source: object): { outputFormat?: string; gifFrames?: number; gifFrameDurationMs?: number; svgLevel?: string } {
254
+ const record = source as Record<string, unknown>
255
+ const str = (v: unknown): string | undefined => (typeof v === "string" && v.length > 0 ? v : undefined)
256
+ const num = (v: unknown): number | undefined => {
257
+ const n = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v) : Number.NaN
258
+ return Number.isFinite(n) ? n : undefined
259
+ }
260
+ return {
261
+ outputFormat: str(record.outputFormat),
262
+ gifFrames: num(record.gifFrames),
263
+ gifFrameDurationMs: num(record.gifFrameDurationMs),
264
+ svgLevel: str(record.svgLevel),
265
+ }
266
+ }
267
+
222
268
  /**
223
269
  * Snap an image request's catalog-governed levers to a combination the model
224
270
  * actually accepts, and price the credit identifier off the SNAPPED values.
@@ -256,6 +302,11 @@ export function resolveNormalizedImageGen(opts: {
256
302
  renderingSpeed?: unknown
257
303
  /** Does not price on its own, but a transparent background can move the size. */
258
304
  background?: unknown
305
+ /** The file the run writes, and a GIF's frames and speed or an SVG's level: a GIF and an SVG price differently. */
306
+ outputFormat?: unknown
307
+ gifFrames?: unknown
308
+ gifFrameDurationMs?: unknown
309
+ svgLevel?: unknown
259
310
  refCount: number
260
311
  swapToI2i?: boolean
261
312
  sourceImage?: SourceImageSize
@@ -272,6 +323,7 @@ export function resolveNormalizedImageGen(opts: {
272
323
  resolution: str(opts.resolution),
273
324
  quality: str(opts.quality),
274
325
  background: str(opts.background),
326
+ ...imageFormatInputOf(opts),
275
327
  },
276
328
  { sourceImage: opts.sourceImage },
277
329
  )
@@ -284,12 +336,17 @@ export function resolveNormalizedImageGen(opts: {
284
336
  str(opts.renderingSpeed),
285
337
  undefined,
286
338
  opts.refCount,
339
+ { outputFormat: n.outputFormat, gifFrames: n.gifFrames, svgLevel: n.svgLevel },
287
340
  ),
288
341
  modelId,
289
342
  aspectRatio: n.aspectRatio,
290
343
  resolution: n.resolution,
291
344
  quality: n.quality,
292
345
  background: n.background,
346
+ outputFormat: n.outputFormat,
347
+ gifFrames: n.gifFrames,
348
+ gifFrameDurationMs: n.gifFrameDurationMs,
349
+ svgLevel: n.svgLevel,
293
350
  adjustments: n.adjustments,
294
351
  }
295
352
  }
@@ -318,6 +375,9 @@ export function resolveImageGenCreditIdentifier(opts: {
318
375
  quality?: string
319
376
  resolution?: string
320
377
  renderingSpeed?: string
378
+ outputFormat?: unknown
379
+ gifFrames?: unknown
380
+ svgLevel?: unknown
321
381
  refCount: number
322
382
  swapToI2i?: boolean
323
383
  }): string {
@@ -19,6 +19,7 @@ export {
19
19
  buildCreditModelIdentifier,
20
20
  resolveImageGenCreditIdentifier,
21
21
  resolveNormalizedImageGen,
22
+ imageFormatInputOf,
22
23
  normalizedImageGenModelId,
23
24
  imageGenAutoAspectNeedsSourceImage,
24
25
  buildVideoCreditModelIdentifier,
@@ -10,18 +10,26 @@ export { isFlux2Model, FLUX2_RES_MP } from "../flux2-pricing.js"
10
10
  export {
11
11
  GPT_IMAGE_2_6_DEFAULT_QUALITY,
12
12
  GPT_IMAGE_2_6_DEFAULT_RESOLUTION,
13
+ GPT_IMAGE_2_6_DEFAULT_SVG_LEVEL,
14
+ GPT_IMAGE_2_6_GIF_BANDS,
15
+ GPT_IMAGE_2_6_GIF_DEFAULT_FRAMES,
13
16
  GPT_IMAGE_2_6_MAX_INPUT_IMAGES,
14
17
  GPT_IMAGE_2_6_METERED_QUALITY,
15
18
  GPT_IMAGE_2_6_QUALITIES,
16
19
  GPT_IMAGE_2_6_RESOLUTIONS,
20
+ GPT_IMAGE_2_6_SVG_LEVELS,
17
21
  GPT_IMAGE_2_6_TIERED_I2I,
18
22
  GPT_IMAGE_2_6_TIERED_T2I,
19
23
  gptImage26EstimatedImages,
24
+ gptImage26GifBand,
25
+ gptImage26PricedFormat,
26
+ imageFormatLeversOf,
20
27
  gptImage26SentImages,
21
28
  isGptImage26AutoRun,
22
29
  isGptImage26I2i,
23
30
  isGptImage26Tiered,
24
31
  } from "../gpt-image-2-6.js"
32
+ export type { GptImage26GifBand, GptImage26PricedFormat, GptImage26SvgLevel, ImageFormatLevers } from "../gpt-image-2-6.js"
25
33
  export type { Flux2Model } from "../flux2-pricing.js"
26
34
  // Model catalog (single source of truth for MCP `list_models` and the
27
35
  // frontend config-panel registries).
@@ -53,6 +61,14 @@ export {
53
61
  aspectRatioOptionsByKind,
54
62
  qualityOptionsByKind,
55
63
  backgroundOptionsByKind,
64
+ outputFormatOptionsByKind,
65
+ svgLevelOptionsByKind,
66
+ IMAGE_OUTPUT_FORMAT_LABELS,
67
+ IMAGE_SVG_LEVEL_LABELS,
68
+ IMAGE_GIF_FRAME_SIZE,
69
+ TRANSPARENT_OUTPUT_FORMATS,
70
+ MASKLESS_OUTPUT_FORMATS,
71
+ MODEL_INPUT_ADJUSTMENT_FIELDS,
56
72
  creditRangesAll,
57
73
  modelIdsByKindMode,
58
74
  buildModelMenu,
@@ -80,6 +96,7 @@ export type {
80
96
  LabeledOption,
81
97
  ModelMenuOption,
82
98
  ModelInputAdjustment,
99
+ ModelInputAdjustmentField,
83
100
  NormalizedModelInput,
84
101
  ModelInputContext,
85
102
  SourceImageSize,
@@ -12,6 +12,10 @@ export {
12
12
  IMAGE_RESOLUTION_VALUES,
13
13
  IMAGE_QUALITY_VALUES,
14
14
  IMAGE_BACKGROUND_VALUES,
15
+ IMAGE_OUTPUT_FORMAT_VALUES,
16
+ IMAGE_OUTPUT_FORMAT_MIME,
17
+ IMAGE_OUTPUT_FORMAT_EXT,
18
+ IMAGE_SVG_LEVEL_VALUES,
15
19
  IMAGE_RENDERING_SPEED_VALUES,
16
20
  IMAGE_EDIT_TARGET_RESOLUTION_VALUES,
17
21
  MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER,
@@ -73,6 +77,7 @@ export {
73
77
  SEEDANCE_VIDEO_EDIT_PROVIDERS,
74
78
  isSeedanceVideoEditProvider,
75
79
  VIDEO_TO_VIDEO_NODE_PROVIDERS,
80
+ DEFAULT_VIDEO_TO_VIDEO_PROVIDER,
76
81
  SEEDANCE_VIDEO_EDIT_SHAPE,
77
82
  FACE_SWAP_PROVIDERS,
78
83
  VIDEO_UPSCALE_PROVIDERS,
@@ -251,6 +256,8 @@ export type {
251
256
  ImageResolution,
252
257
  ImageQuality,
253
258
  ImageBackground,
259
+ ImageOutputFormat,
260
+ ImageSvgLevel,
254
261
  ImageRenderingSpeed,
255
262
  ImageEditTargetResolution,
256
263
  TaskChainedEditProvider,
@@ -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,
@@ -29,6 +29,78 @@ export const GPT_IMAGE_2_6_DEFAULT_RESOLUTION: GptImage26Resolution = "1K"
29
29
  /** The most input images an edit is priced for (`REF_IMAGE_MAX_LIMITS`). */
30
30
  export const GPT_IMAGE_2_6_MAX_INPUT_IMAGES = 16
31
31
 
32
+ /**
33
+ * A GIF is priced by quality and by how many frames it has, in three bands:
34
+ * KIE draws every frame of a GIF on one sheet, and the frames of a band share a
35
+ * sheet size. Its price does not depend on the ratio or size (a GIF is always
36
+ * square, 512 pixels a frame). Ten to twelve frames take nine's price, so the
37
+ * bands rise in order.
38
+ */
39
+ export const GPT_IMAGE_2_6_GIF_BANDS = [
40
+ { id: "2-8", min: 2, max: 8 },
41
+ { id: "9-12", min: 9, max: 12 },
42
+ { id: "13-16", min: 13, max: 16 },
43
+ ] as const
44
+ export type GptImage26GifBand = (typeof GPT_IMAGE_2_6_GIF_BANDS)[number]["id"]
45
+ /** The frames a GIF has when none are asked for (KIE's own default). */
46
+ export const GPT_IMAGE_2_6_GIF_DEFAULT_FRAMES = 9
47
+
48
+ /**
49
+ * The band a GIF of `frames` frames is priced in. A value that is not a whole
50
+ * number of frames, or is off the range, lands where the run lands: no value is
51
+ * the default nine frames, others are rounded and kept inside 2 to 16.
52
+ */
53
+ export function gptImage26GifBand(frames: unknown): GptImage26GifBand {
54
+ // A numeric string counts as its number, as the run reads it (a form field, a FieldMapping).
55
+ const asked = typeof frames === "number" ? frames : typeof frames === "string" && frames.trim() !== "" ? Number(frames) : Number.NaN
56
+ const n = Number.isFinite(asked) ? Math.round(asked) : GPT_IMAGE_2_6_GIF_DEFAULT_FRAMES
57
+ const first = GPT_IMAGE_2_6_GIF_BANDS[0]
58
+ const last = GPT_IMAGE_2_6_GIF_BANDS[GPT_IMAGE_2_6_GIF_BANDS.length - 1]!
59
+ const clamped = Math.min(Math.max(n, first.min), last.max)
60
+ return (GPT_IMAGE_2_6_GIF_BANDS.find((b) => clamped >= b.min && clamped <= b.max) ?? first).id
61
+ }
62
+
63
+ /**
64
+ * An SVG is drawn at one of three levels of detail (Standard, Detailed, Max),
65
+ * each priced as the same image in PNG plus a fixed amount for the drawing.
66
+ */
67
+ export const GPT_IMAGE_2_6_SVG_LEVELS = ["standard", "detailed", "max"] as const
68
+ export type GptImage26SvgLevel = (typeof GPT_IMAGE_2_6_SVG_LEVELS)[number]
69
+ export const GPT_IMAGE_2_6_DEFAULT_SVG_LEVEL: GptImage26SvgLevel = "standard"
70
+
71
+ /** The format part of a GPT Image 2.6 price: a GIF's band, an SVG's level, or none (PNG, JPEG and WebP cost the same). */
72
+ export type GptImage26PricedFormat =
73
+ | { readonly kind: "gif"; readonly band: GptImage26GifBand }
74
+ | { readonly kind: "svg"; readonly level: GptImage26SvgLevel }
75
+
76
+ /** The levers a format is priced from, as a request or a node carries them (unchecked). */
77
+ export interface ImageFormatLevers {
78
+ outputFormat?: unknown
79
+ gifFrames?: unknown
80
+ svgLevel?: unknown
81
+ }
82
+
83
+ /** The format levers of a request body or a node's data, for a price. */
84
+ export function imageFormatLeversOf(record: Record<string, unknown> | undefined): ImageFormatLevers {
85
+ return { outputFormat: record?.outputFormat, gifFrames: record?.gifFrames, svgLevel: record?.svgLevel }
86
+ }
87
+
88
+ /** Read in any case, as the catalog snap reads it (`normalizeModelInput`). */
89
+ function lowered(value: unknown): string | undefined {
90
+ return typeof value === "string" ? value.trim().toLowerCase() : undefined
91
+ }
92
+
93
+ export function gptImage26PricedFormat(levers: ImageFormatLevers | undefined): GptImage26PricedFormat | undefined {
94
+ const format = lowered(levers?.outputFormat)
95
+ if (format === "gif") return { kind: "gif", band: gptImage26GifBand(levers?.gifFrames) }
96
+ if (format === "svg") {
97
+ const asked = lowered(levers?.svgLevel)
98
+ const level = GPT_IMAGE_2_6_SVG_LEVELS.find((l) => l === asked) ?? GPT_IMAGE_2_6_DEFAULT_SVG_LEVEL
99
+ return { kind: "svg", level }
100
+ }
101
+ return undefined
102
+ }
103
+
32
104
  export function isGptImage26I2i(model: string): boolean {
33
105
  return (GPT_IMAGE_2_6_TIERED_I2I as readonly string[]).includes(model)
34
106
  }