@nodaro/shared 3.14.0 → 3.18.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 (153) hide show
  1. package/dist/index.cjs +1679 -81
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1822 -49
  4. package/dist/index.d.ts +1822 -49
  5. package/dist/index.js +1491 -82
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/apply-edl-credit-id.test.ts +25 -0
  9. package/src/__tests__/camera-switch-contract.test.ts +98 -0
  10. package/src/__tests__/competitors.test.ts +49 -0
  11. package/src/__tests__/content-recipe-ideas.test.ts +96 -0
  12. package/src/__tests__/edl-multicam.test.ts +192 -0
  13. package/src/__tests__/exposed-field-keys.test.ts +78 -0
  14. package/src/__tests__/instagram-scrape.test.ts +62 -0
  15. package/src/__tests__/llm-models.test.ts +5 -2
  16. package/src/__tests__/music-provider.test.ts +17 -0
  17. package/src/__tests__/node-runtime-keys.test.ts +11 -0
  18. package/src/__tests__/parameter-node-value.test.ts +2 -1
  19. package/src/__tests__/per-unit-video-pricing.test.ts +97 -0
  20. package/src/__tests__/producer-types.test.ts +35 -0
  21. package/src/__tests__/saved-posts.test.ts +37 -0
  22. package/src/__tests__/script-settings.test.ts +61 -0
  23. package/src/__tests__/settings-input.test.ts +252 -0
  24. package/src/__tests__/social-search.test.ts +243 -0
  25. package/src/__tests__/studio-sequence-owner.test.ts +356 -0
  26. package/src/__tests__/studio-take-voice.test.ts +200 -0
  27. package/src/__tests__/studio-transient.test.ts +71 -0
  28. package/src/__tests__/sub-gates.test.ts +21 -0
  29. package/src/__tests__/telegram-account-trigger.test.ts +120 -0
  30. package/src/__tests__/text-to-audio-pricing.test.ts +71 -0
  31. package/src/__tests__/tts-capabilities.test.ts +237 -0
  32. package/src/__tests__/video-analysis-pricing.test.ts +27 -13
  33. package/src/__tests__/video-link.test.ts +2 -2
  34. package/src/__tests__/video-utils.test.ts +89 -83
  35. package/src/__tests__/workflow-export-strip.test.ts +37 -0
  36. package/src/camera-switch-contract.ts +166 -0
  37. package/src/catalog-projection.ts +7 -0
  38. package/src/competitors.ts +430 -0
  39. package/src/content-recipe-ideas.ts +69 -0
  40. package/src/credit-estimators/index.ts +21 -0
  41. package/src/credit-estimators/ltx-extend.ts +33 -0
  42. package/src/credit-estimators/ltx-retake.ts +30 -0
  43. package/src/credit-estimators/text-to-audio.ts +58 -0
  44. package/src/credit-estimators/video-sfx.ts +41 -0
  45. package/src/credit-estimators/video-utils.ts +38 -24
  46. package/src/credit-identifiers.ts +22 -0
  47. package/src/edl-multicam.ts +220 -0
  48. package/src/exposed-field-keys.ts +49 -0
  49. package/src/fan-out-rows.ts +7 -2
  50. package/src/i18n/action-fx.ko.ts +18 -18
  51. package/src/i18n/action-fx.pt-BR.ts +66 -66
  52. package/src/i18n/aesthetic.ko.ts +49 -49
  53. package/src/i18n/aesthetic.pt-BR.ts +14 -14
  54. package/src/i18n/animals.ko.ts +126 -126
  55. package/src/i18n/animals.pt-BR.ts +33 -33
  56. package/src/i18n/atmosphere.ko.ts +37 -37
  57. package/src/i18n/atmosphere.pt-BR.ts +29 -29
  58. package/src/i18n/backdrop.ko.ts +40 -40
  59. package/src/i18n/backdrop.pt-BR.ts +38 -38
  60. package/src/i18n/camera-format.ko.ts +31 -31
  61. package/src/i18n/camera-format.pt-BR.ts +12 -12
  62. package/src/i18n/camera-motions.ko.ts +66 -66
  63. package/src/i18n/camera-motions.pt-BR.ts +51 -51
  64. package/src/i18n/character-fx.ko.ts +19 -19
  65. package/src/i18n/character-fx.pt-BR.ts +64 -52
  66. package/src/i18n/character-motion.ko.ts +164 -164
  67. package/src/i18n/character-motion.pt-BR.ts +867 -858
  68. package/src/i18n/color-look.ko.ts +41 -41
  69. package/src/i18n/color-look.pt-BR.ts +23 -23
  70. package/src/i18n/composition-effects.ko.ts +18 -18
  71. package/src/i18n/composition-effects.pt-BR.ts +17 -17
  72. package/src/i18n/era.ko.ts +28 -28
  73. package/src/i18n/era.pt-BR.ts +20 -20
  74. package/src/i18n/exposure-settings.ko.ts +20 -20
  75. package/src/i18n/exposure-settings.pt-BR.ts +3 -3
  76. package/src/i18n/framing.ko.ts +66 -66
  77. package/src/i18n/framing.pt-BR.ts +50 -50
  78. package/src/i18n/furniture.ko.ts +78 -78
  79. package/src/i18n/furniture.pt-BR.ts +46 -46
  80. package/src/i18n/held-prop.ko.ts +60 -60
  81. package/src/i18n/held-prop.pt-BR.ts +30 -30
  82. package/src/i18n/instrumentation.ko.ts +62 -62
  83. package/src/i18n/instrumentation.pt-BR.ts +64 -64
  84. package/src/i18n/lens.ko.ts +16 -16
  85. package/src/i18n/lens.pt-BR.ts +5 -5
  86. package/src/i18n/lighting.ko.ts +68 -68
  87. package/src/i18n/lighting.pt-BR.ts +43 -43
  88. package/src/i18n/loop-subject.ko.ts +1 -1
  89. package/src/i18n/loop-subject.pt-BR.ts +31 -31
  90. package/src/i18n/materials.ko.ts +66 -66
  91. package/src/i18n/materials.pt-BR.ts +22 -22
  92. package/src/i18n/mood.ko.ts +50 -50
  93. package/src/i18n/mood.pt-BR.ts +12 -12
  94. package/src/i18n/music-genre.ko.ts +28 -28
  95. package/src/i18n/music-genre.pt-BR.ts +50 -50
  96. package/src/i18n/music-mood.ko.ts +27 -27
  97. package/src/i18n/music-mood.pt-BR.ts +20 -20
  98. package/src/i18n/person.ko.ts +396 -396
  99. package/src/i18n/person.pt-BR.ts +237 -237
  100. package/src/i18n/photo-genre.ko.ts +46 -46
  101. package/src/i18n/photo-genre.pt-BR.ts +32 -32
  102. package/src/i18n/photographer.ko.ts +63 -63
  103. package/src/i18n/photographer.pt-BR.ts +15 -15
  104. package/src/i18n/pose.ko.ts +81 -81
  105. package/src/i18n/pose.pt-BR.ts +65 -65
  106. package/src/i18n/post-process-effects.ko.ts +18 -18
  107. package/src/i18n/post-process-effects.pt-BR.ts +18 -18
  108. package/src/i18n/render-quality.ko.ts +24 -24
  109. package/src/i18n/render-quality.pt-BR.ts +12 -12
  110. package/src/i18n/setting.ko.ts +64 -64
  111. package/src/i18n/setting.pt-BR.ts +41 -41
  112. package/src/i18n/style.ko.ts +49 -49
  113. package/src/i18n/style.pt-BR.ts +19 -19
  114. package/src/i18n/styling.ko.ts +265 -265
  115. package/src/i18n/styling.pt-BR.ts +141 -141
  116. package/src/i18n/temporal.ko.ts +18 -18
  117. package/src/i18n/temporal.pt-BR.ts +12 -12
  118. package/src/i18n/transitions.ko.ts +14 -14
  119. package/src/i18n/transitions.pt-BR.ts +83 -71
  120. package/src/i18n/vehicles.ko.ts +107 -107
  121. package/src/i18n/vehicles.pt-BR.ts +55 -55
  122. package/src/i18n/voice-character.ko.ts +19 -19
  123. package/src/i18n/voice-character.pt-BR.ts +19 -19
  124. package/src/i18n/voice-delivery.ko.ts +22 -22
  125. package/src/i18n/voice-delivery.pt-BR.ts +22 -22
  126. package/src/i18n/weapons.ko.ts +85 -85
  127. package/src/i18n/weapons.pt-BR.ts +46 -46
  128. package/src/index.ts +236 -1
  129. package/src/instagram-scrape.ts +91 -16
  130. package/src/llm-models.ts +11 -0
  131. package/src/model-catalog.ts +151 -16
  132. package/src/model-constants.ts +54 -16
  133. package/src/node-mappable-fields.ts +21 -5
  134. package/src/node-runtime-keys.ts +45 -0
  135. package/src/oauth-scopes.ts +28 -0
  136. package/src/parameter-node-value.ts +13 -5
  137. package/src/pipeline-defaults.ts +14 -0
  138. package/src/pipeline-state-types.ts +14 -0
  139. package/src/presentation-utils.ts +5 -1
  140. package/src/producer-types.ts +85 -0
  141. package/src/recast-segment-packs.ts +13 -0
  142. package/src/resolve-field-mappings.ts +15 -5
  143. package/src/saved-posts.ts +106 -0
  144. package/src/script-settings.ts +70 -0
  145. package/src/settings-input.ts +366 -0
  146. package/src/social-search.ts +467 -0
  147. package/src/studio-transient.ts +479 -7
  148. package/src/telegram-account-send.ts +32 -0
  149. package/src/telegram-account-trigger.ts +108 -0
  150. package/src/tts-capabilities.ts +75 -0
  151. package/src/video-analysis-pricing.ts +17 -6
  152. package/src/video-link.ts +16 -4
  153. package/src/workflow-export.ts +7 -0
@@ -74,12 +74,48 @@ export type ModelMode =
74
74
  export interface PriceVariant {
75
75
  /** Composite identifier as it appears in `STATIC_CREDIT_COSTS`. */
76
76
  identifier: string
77
- /** Credits charged at reservation. */
77
+ /** The catalog's list price in credits. `GET /v1/models` and the MCP
78
+ * `list_models` tool serve the price a run is charged on the instance,
79
+ * which may differ. */
78
80
  credits: number
79
81
  /** Short human-readable note describing this variant ("1K default", "4K", "with audio"). */
80
82
  note?: string
81
83
  }
82
84
 
85
+ /** A voice-setting lever a speech model honours. */
86
+ export type TtsSettingLever = "stability" | "similarity" | "style" | "speed" | "speakerBoost"
87
+
88
+ /**
89
+ * What a speech model (text-to-speech or dialogue) accepts. The ONE source for
90
+ * every "does this model do X" decision on the text-to-speech lane — tag
91
+ * stripping, which voice settings are sent and shown, the language picker, the
92
+ * per-request character cap. Never compare a provider id by hand; read the sheet
93
+ * through the helpers in `tts-capabilities.ts`.
94
+ *
95
+ * The dialogue model carries a sheet for its own lane too, but until that lane
96
+ * is moved onto it only `maxChars` and `languages` of that sheet are read:
97
+ * editing its other fields changes no dialogue request.
98
+ */
99
+ export interface TtsCapabilities {
100
+ /** Inline `[audio tags]` are performed. false ⇒ strip them before sending (the model reads them aloud). */
101
+ audioTags: boolean
102
+ /** SSML `<break time="…"/>` tags are honoured. */
103
+ ssmlBreaks: boolean
104
+ /** Voice settings the model honours. A lever not listed is never sent and never shown. */
105
+ levers: readonly TtsSettingLever[]
106
+ /** The request may carry a language code. false ⇒ the field is omitted. */
107
+ languageCode: boolean
108
+ /**
109
+ * Per-request character cap (the total across lines for a dialogue model).
110
+ * `getMaxTtsChars` reads it by exact id and answers {@link TTS_TEXT_MAX}'s 5,000 for
111
+ * the legacy alias and for ids with no sheet, while the sheet lookups answer
112
+ * with the cap of the model such a request actually runs as (turbo's 40,000).
113
+ */
114
+ maxChars: number
115
+ /** Languages offered in pickers (ISO 639-1; `fil` has no two-letter code). A curated list, not the vendor's full one. */
116
+ languages: readonly string[]
117
+ }
118
+
83
119
  export interface ModelCatalogEntry {
84
120
  id: string
85
121
  kind: ModelKind
@@ -187,6 +223,11 @@ export interface ModelCatalogEntry {
187
223
  * the catalog model to offer when it blocks again.
188
224
  */
189
225
  safetyFilter?: { stochastic: true; fallback?: string }
226
+ /**
227
+ * Capability sheet of a speech model. REQUIRED on every entry whose `modes`
228
+ * include "tts" or "dialogue" — `tts-capabilities.test.ts` fails otherwise.
229
+ */
230
+ tts?: TtsCapabilities
190
231
  }
191
232
 
192
233
  /**
@@ -1249,7 +1290,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1249
1290
  resolutions: ["720p", "1080p", "4k"],
1250
1291
  pricing: [
1251
1292
  { identifier: "veo3", credits: 1000, note: "4/6/8s with audio (flat per-generation)" },
1252
- { identifier: "veo3:4k", credits: 930, note: "4K (base 1080p → get-4k-video)" },
1293
+ { identifier: "veo3:4k", credits: 1300, note: "4K (base 1080p → get-4k-video)" },
1253
1294
  ],
1254
1295
  featured: true,
1255
1296
  },
@@ -2282,9 +2323,9 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2282
2323
  kind: "video",
2283
2324
  modes: ["video-analysis"] as const,
2284
2325
  family: "Nodaro",
2285
- label: "Video Analysis (Fast — legacy)",
2326
+ label: "Video Analysis (Fast)",
2286
2327
  series: "Video Analysis",
2287
- description: "Legacy fast-tier analysis model (pre-2026-07). Kept so stored raw-model configs keep running and keep pricing under their own identifier; new fast-tier runs use the current fast model.",
2328
+ description: "Analyze a video into a structured shot list (scenes, camera, audio) — fast, economy tier. Billed per duration bucket.",
2288
2329
  useCases: ["video-analysis", "shot-list", "fast"],
2289
2330
  pricing: [
2290
2331
  { identifier: "video-analysis:gemini-3-flash", credits: 849, note: "10-min ceiling (no duration given)" },
@@ -2299,9 +2340,9 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2299
2340
  kind: "video",
2300
2341
  modes: ["video-analysis"] as const,
2301
2342
  family: "Nodaro",
2302
- label: "Video Analysis (Fast)",
2343
+ label: "Video Analysis (Fast — legacy)",
2303
2344
  series: "Video Analysis",
2304
- description: "Analyze a video into a structured shot list (scenes, camera, audio) — fast, economy tier. Billed per duration bucket.",
2345
+ description: "Legacy fast-tier analysis model (backed the fast tier from 2026-07 until 2026-07-29). Kept so stored raw-model configs keep running and keep pricing under their own identifier; new fast-tier runs use the current fast model.",
2305
2346
  useCases: ["video-analysis", "shot-list", "fast"],
2306
2347
  pricing: [
2307
2348
  { identifier: "video-analysis:gemini-3.6-flash", credits: 995, note: "10-min ceiling (no duration given)" },
@@ -2419,6 +2460,20 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2419
2460
  // =============================================================================
2420
2461
  // AUDIO MODELS
2421
2462
  // =============================================================================
2463
+ // Languages each speech model is offered in. The three lists nest: Multilingual
2464
+ // v2 ⊂ Flash v2.5 ⊂ v3.
2465
+ const TTS_LANGS_MULTILINGUAL_V2 = [
2466
+ "en", "ja", "zh", "de", "hi", "fr", "ko", "pt", "it", "es", "id", "nl", "tr", "fil", "pl",
2467
+ "sv", "bg", "ro", "ar", "cs", "el", "fi", "hr", "ms", "sk", "da", "ta", "uk", "ru",
2468
+ ] as const
2469
+ const TTS_LANGS_FLASH_V25 = [...TTS_LANGS_MULTILINGUAL_V2, "hu", "no", "vi"] as const
2470
+ const TTS_LANGS_V3 = [
2471
+ ...TTS_LANGS_FLASH_V25,
2472
+ "he", "th", "bn", "ur", "fa", "sr", "lt", "lv", "et", "ka", "is", "ca", "af", "sw",
2473
+ ] as const
2474
+ // Every lever the v2 families are sent today.
2475
+ const TTS_LEVERS_V2 = ["stability", "similarity", "style", "speed", "speakerBoost"] as const
2476
+
2422
2477
  const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2423
2478
  // ── ElevenLabs TTS ──
2424
2479
  "elevenlabs-v3": {
@@ -2428,11 +2483,42 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2428
2483
  family: "ElevenLabs",
2429
2484
  label: "ElevenLabs v3",
2430
2485
  series: "ElevenLabs",
2431
- description: "Latest ElevenLabs TTS — supports [audio tags] for emotion / pacing. Direct API.",
2486
+ description: "Expressive ElevenLabs TTS — supports [audio tags] for emotion / pacing. Direct API.",
2432
2487
  useCases: ["tts", "voice-over", "narration", "expressive"],
2433
2488
  features: ["audio-tags", "voice-cloning"],
2434
2489
  pricing: [{ identifier: "elevenlabs-v3", credits: 30 }],
2435
2490
  featured: true,
2491
+ tts: {
2492
+ audioTags: true,
2493
+ ssmlBreaks: false,
2494
+ levers: ["stability"],
2495
+ languageCode: true,
2496
+ maxChars: 5000, // official cap (probed: 5,200 chars accepted; keep the clamp)
2497
+ languages: TTS_LANGS_V3,
2498
+ },
2499
+ },
2500
+ "elevenlabs-v4": {
2501
+ id: "elevenlabs-v4",
2502
+ kind: "audio",
2503
+ modes: ["tts"] as const,
2504
+ family: "ElevenLabs",
2505
+ label: "ElevenLabs v4",
2506
+ series: "ElevenLabs",
2507
+ description: "Newest ElevenLabs TTS — [audio tags], stability and similarity control, up to 10,000 characters per request. Direct API.",
2508
+ useCases: ["tts", "voice-over", "narration", "expressive", "long-form"],
2509
+ features: ["audio-tags", "voice-cloning"],
2510
+ pricing: [{ identifier: "elevenlabs-v4", credits: 30 }],
2511
+ tts: {
2512
+ audioTags: true,
2513
+ ssmlBreaks: false,
2514
+ levers: ["stability", "similarity"],
2515
+ languageCode: true,
2516
+ maxChars: 10000,
2517
+ // The curated picker, the same 46 as v3. The model itself lists 85
2518
+ // (it adds e.g. Cantonese, Maltese, Mongolian, Burmese, Uzbek); widening
2519
+ // the picker is its own change — it needs a name and a translation per language.
2520
+ languages: TTS_LANGS_V3,
2521
+ },
2436
2522
  },
2437
2523
  "elevenlabs-turbo": {
2438
2524
  id: "elevenlabs-turbo",
@@ -2444,6 +2530,14 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2444
2530
  description: "Fast, cheap ElevenLabs TTS via the direct ElevenLabs API. Good for narration.",
2445
2531
  useCases: ["tts", "narration", "fast"],
2446
2532
  pricing: [{ identifier: "elevenlabs-turbo", credits: 15, note: "per 1K chars" }],
2533
+ tts: {
2534
+ audioTags: false,
2535
+ ssmlBreaks: true,
2536
+ levers: TTS_LEVERS_V2,
2537
+ languageCode: true,
2538
+ maxChars: 40000, // == eleven_flash_v2_5 (functionally equivalent)
2539
+ languages: TTS_LANGS_FLASH_V25,
2540
+ },
2447
2541
  },
2448
2542
  "elevenlabs-multilingual": {
2449
2543
  id: "elevenlabs-multilingual",
@@ -2455,6 +2549,15 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2455
2549
  description: "Multi-language ElevenLabs TTS via the direct ElevenLabs API.",
2456
2550
  useCases: ["tts", "multilingual"],
2457
2551
  pricing: [{ identifier: "elevenlabs-multilingual", credits: 30, note: "per 1K chars" }],
2552
+ tts: {
2553
+ audioTags: false,
2554
+ ssmlBreaks: true,
2555
+ levers: TTS_LEVERS_V2,
2556
+ // The API reference: "This parameter is not supported for multilingual_v2 models."
2557
+ languageCode: false,
2558
+ maxChars: 10000,
2559
+ languages: TTS_LANGS_MULTILINGUAL_V2,
2560
+ },
2458
2561
  },
2459
2562
  "elevenlabs-dialogue": {
2460
2563
  id: "elevenlabs-dialogue",
@@ -2470,6 +2573,16 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2470
2573
  useCases: ["tts", "dialogue", "multi-speaker"],
2471
2574
  features: ["audio-tags", "voice-cloning"],
2472
2575
  pricing: [{ identifier: "elevenlabs-dialogue", credits: 25, note: "per 1K chars" }],
2576
+ tts: {
2577
+ audioTags: true,
2578
+ ssmlBreaks: false,
2579
+ levers: ["stability"],
2580
+ languageCode: true,
2581
+ // Total across lines. The documented 2,000 is a recommendation, not a
2582
+ // limit (2,500 and 5,000 both probed 200); capped like v3, the model underneath.
2583
+ maxChars: 5000,
2584
+ languages: TTS_LANGS_V3,
2585
+ },
2473
2586
  },
2474
2587
 
2475
2588
  // ── ElevenLabs voice utilities ──
@@ -2587,7 +2700,15 @@ const AUDIO_MODELS: Record<string, ModelCatalogEntry> = {
2587
2700
  series: "ElevenLabs",
2588
2701
  description: "Generate short sound effects from a text prompt.",
2589
2702
  useCases: ["sfx", "ambient"],
2590
- pricing: [{ identifier: "elevenlabs-sfx", credits: 3, note: "~5s clip" }],
2703
+ // Priced per whole second asked for (`elevenlabs-sfx:<n>s`, 1–30 s, rounded
2704
+ // up — textToAudioCreditId); representative rows, every second has its own.
2705
+ // First row = the default variant (a request with no duration bills 5 s).
2706
+ pricing: [
2707
+ { identifier: "elevenlabs-sfx:5s", credits: 5, note: "5s — also the price when no duration is set; 1 credit per second, rounded up" },
2708
+ { identifier: "elevenlabs-sfx:1s", credits: 1, note: "1s (min)" },
2709
+ { identifier: "elevenlabs-sfx:10s", credits: 10, note: "10s" },
2710
+ { identifier: "elevenlabs-sfx:30s", credits: 30, note: "30s (max)" },
2711
+ ],
2591
2712
  },
2592
2713
 
2593
2714
  // ── Suno music ──
@@ -3084,6 +3205,23 @@ function nearestAspectRatio(token: string, allowed: readonly string[]): string |
3084
3205
  return best
3085
3206
  }
3086
3207
 
3208
+ /**
3209
+ * `ratio` as `modelId` renders it: the catalog's own spelling when the model
3210
+ * lists it (any case), else the nearest ratio it lists (log space — a portrait
3211
+ * request stays portrait). "auto" / "adaptive", an empty token, a model without
3212
+ * a ratio list and an unknown model pass through unchanged. The ONE fitting
3213
+ * rule: the video lane's normalizer applies it, and so does a node's Settings
3214
+ * input for a wired Aspect Ratio (settings-input.ts), image models included.
3215
+ */
3216
+ export function fitAspectRatioToModel(modelId: string, ratio: string): string {
3217
+ const token = ratio.trim()
3218
+ const allowed = MODEL_CATALOG[modelId]?.aspectRatios
3219
+ if (!allowed?.length || token === "" || PASSTHROUGH_ASPECT_TOKENS.has(token.toLowerCase())) return token
3220
+ const exact = allowed.find((a) => a === token) ?? allowed.find((a) => a.toLowerCase() === token.toLowerCase())
3221
+ if (exact !== undefined) return exact
3222
+ return nearestAspectRatio(token, allowed.filter((a) => !PASSTHROUGH_ASPECT_TOKENS.has(a.toLowerCase()))) ?? allowed[0]!
3223
+ }
3224
+
3087
3225
  /**
3088
3226
  * Read a catalog lever off an UNVALIDATED input as a trimmed string.
3089
3227
  *
@@ -3162,18 +3300,15 @@ export function normalizeVideoRequestParams(
3162
3300
  if (!m) return out
3163
3301
 
3164
3302
  if (m.aspectRatios?.length && aspect && !PASSTHROUGH_ASPECT_TOKENS.has(aspect.toLowerCase())) {
3165
- const allowed = m.aspectRatios
3166
- const exact = allowed.find((a) => a === aspect) ?? allowed.find((a) => a.toLowerCase() === aspect.toLowerCase())
3167
- if (exact !== undefined) {
3168
- out.aspectRatio = exact
3169
- } else {
3170
- const next = nearestAspectRatio(aspect, allowed.filter((a) => !PASSTHROUGH_ASPECT_TOKENS.has(a.toLowerCase()))) ?? allowed[0]!
3303
+ const next = fitAspectRatioToModel(modelId, aspect)
3304
+ // A case-only difference is the same ratio canonicalised, not a correction.
3305
+ if (next.toLowerCase() !== aspect.toLowerCase()) {
3171
3306
  out.adjustments.push({
3172
3307
  field: "aspectRatio", from: aspect, to: next,
3173
- reason: `${m.label} does not support aspect ratio "${aspect}" — using "${next}" instead. Supported: ${allowed.join(", ")}.`,
3308
+ reason: `${m.label} does not support aspect ratio "${aspect}" — using "${next}" instead. Supported: ${m.aspectRatios.join(", ")}.`,
3174
3309
  })
3175
- out.aspectRatio = next
3176
3310
  }
3311
+ out.aspectRatio = next
3177
3312
  }
3178
3313
 
3179
3314
  if (m.resolutions?.length && res) {
@@ -286,28 +286,29 @@ export function getMaxNegativePromptChars(provider: string | undefined): number
286
286
  return (provider && MAX_NEGATIVE_PROMPT_CHARS_BY_PROVIDER[provider]) || NEGATIVE_PROMPT_MAX
287
287
  }
288
288
 
289
- /** Default TTS text cap (legacy `elevenlabs`) when no per-model override. */
289
+ /** What {@link getMaxTtsChars} answers for an id with no entry of its own: the legacy `elevenlabs` alias (which runs as turbo — pass `canonicalTtsProvider(id)` to get that model's cap), a missing id and an unknown id. */
290
290
  export const TTS_TEXT_MAX = 5000
291
291
 
292
292
  /**
293
- * Per-model Text-to-Speech character cap (PER REQUEST), from official ElevenLabs
294
- * docs. turbo/multilingual accept FAR more than the old flat 5000; v3 matches
295
- * the official 5000 (probed live 2026-08-30: 4,500 AND 5,200 chars both
296
- * returned 200 — the old "API hard-limits v3 at 3000" report no longer holds).
297
- * Dialogue's documented 2,000 is a recommendation, not a limit (2,500 and
298
- * 5,000 total chars both probed 200); we cap at 5000 like v3 — same model
299
- * underneath. Absent → {@link TTS_TEXT_MAX}.
293
+ * Per-model Text-to-Speech character cap (PER REQUEST). DERIVED from each
294
+ * speech model's capability sheet (`tts.maxChars` in `MODEL_CATALOG`) — set the
295
+ * cap there, never here. Absent → {@link TTS_TEXT_MAX}.
300
296
  */
301
- export const MAX_TTS_CHARS_BY_PROVIDER: Record<string, number> = {
302
- "elevenlabs-turbo": 40000, // == eleven_flash_v2_5 (functionally equivalent)
303
- "elevenlabs-multilingual": 10000, // eleven_multilingual_v2
304
- "elevenlabs-v3": 5000, // official cap (probed: 5,200 chars accepted; keep the clamp)
305
- "elevenlabs-dialogue": 5000, // total across lines; ≤2,000 recommended for best quality
306
- }
297
+ export const MAX_TTS_CHARS_BY_PROVIDER: Record<string, number> = Object.fromEntries(
298
+ Object.values(MODEL_CATALOG)
299
+ .filter((m) => m.tts !== undefined)
300
+ .map((m) => [m.id, m.tts!.maxChars]),
301
+ )
307
302
 
308
- /** Max TTS text length (chars) for a provider: verified override, else {@link TTS_TEXT_MAX}. */
303
+ /**
304
+ * Max TTS text length (chars) for a provider: verified override, else
305
+ * {@link TTS_TEXT_MAX}. The legacy `elevenlabs` alias has no entry of its own
306
+ * (callers that mean the model it runs as pass `canonicalTtsProvider(id)`), and
307
+ * an id named like an inherited object member (`constructor`) is just unknown.
308
+ */
309
309
  export function getMaxTtsChars(provider: string | undefined): number {
310
- return (provider && MAX_TTS_CHARS_BY_PROVIDER[provider]) || TTS_TEXT_MAX
310
+ const cap = provider && Object.hasOwn(MAX_TTS_CHARS_BY_PROVIDER, provider) ? MAX_TTS_CHARS_BY_PROVIDER[provider] : undefined
311
+ return cap || TTS_TEXT_MAX
311
312
  }
312
313
 
313
314
  /**
@@ -1214,6 +1215,7 @@ export type MotionTransferProviderType = typeof MOTION_TRANSFER_PROVIDERS[number
1214
1215
  /** Text-to-speech providers */
1215
1216
  export const TTS_PROVIDERS = [
1216
1217
  "elevenlabs-v3",
1218
+ "elevenlabs-v4",
1217
1219
  "elevenlabs-turbo",
1218
1220
  "elevenlabs-multilingual",
1219
1221
  "elevenlabs",
@@ -1228,6 +1230,14 @@ export const TEXT_TO_AUDIO_PROVIDERS = [
1228
1230
  ] as const
1229
1231
  export type TextToAudioProvider = typeof TEXT_TO_AUDIO_PROVIDERS[number]
1230
1232
 
1233
+ /**
1234
+ * The Text to Audio engine used when a request names none — the route's
1235
+ * credit reservation, the worker, the orchestrator payload and the editor's
1236
+ * node default all read THIS, so they can never disagree about which model
1237
+ * ran and which one was billed.
1238
+ */
1239
+ export const DEFAULT_TEXT_TO_AUDIO_PROVIDER: TextToAudioProvider = "elevenlabs-sfx"
1240
+
1231
1241
  /** Music generation providers */
1232
1242
  export const MUSIC_PROVIDERS = [
1233
1243
  // Replicate disabled
@@ -1244,6 +1254,34 @@ export const MUSIC_PROVIDERS = [
1244
1254
  ] as const
1245
1255
  export type MusicProvider = typeof MUSIC_PROVIDERS[number]
1246
1256
 
1257
+ /** The model a Generate Music node runs when its data names none it offers. */
1258
+ export const DEFAULT_MUSIC_PROVIDER: MusicProvider = "minimax"
1259
+
1260
+ /** Each music model's name as the node shows it. The catalog's "minimax" is the
1261
+ * MiniMax VIDEO model, so its label cannot stand in. */
1262
+ export const MUSIC_PROVIDER_LABELS: Readonly<Record<MusicProvider, string>> = {
1263
+ minimax: "MiniMax Music",
1264
+ }
1265
+
1266
+ /**
1267
+ * The credit id every Generate Music run reserves on — the route's guard and
1268
+ * the orchestrator's payload both use it, whatever the model. The estimates
1269
+ * and the node's price read it too: the model id would price the MiniMax VIDEO
1270
+ * model that shares the name ("minimax").
1271
+ */
1272
+ export const MUSIC_CREDIT_ID = "generate-music"
1273
+
1274
+ /**
1275
+ * The music model a Generate Music node runs: its `provider` when the node
1276
+ * offers it, else the default. Nodes saved with a model that is gone ("suno",
1277
+ * "musicgen", "lyria", "bark" — or the "suno" new nodes started on) run the
1278
+ * default instead of failing validation. Coerces rather than rejects, like
1279
+ * `normalizeModelInput`: the only model to fall back to is the one there is.
1280
+ */
1281
+ export function resolveMusicProvider(value: unknown): MusicProvider {
1282
+ return (MUSIC_PROVIDERS as readonly unknown[]).includes(value) ? (value as MusicProvider) : DEFAULT_MUSIC_PROVIDER
1283
+ }
1284
+
1247
1285
  /**
1248
1286
  * Transcription providers a caller may name — on `/v1/transcribe`, the SDK/CLI
1249
1287
  * and the canvas Transcribe node. All three lanes are served on cloud again
@@ -1,3 +1,5 @@
1
+ import { settingsInputFields } from "./settings-input.js"
2
+
1
3
  /**
2
4
  * Per-node-type list of field names eligible for fieldMappings resolution.
3
5
  * Text fields also participate in {} injection when the resolver sees a
@@ -5,7 +7,8 @@
5
7
  * mapped source's value verbatim.
6
8
  */
7
9
  export const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {
8
- "generate-image": ["prompt", "style", "negativePrompt"],
10
+ // + the fields its Settings input sets (settings-input.ts).
11
+ "generate-image": ["prompt", "style", "negativePrompt", ...settingsInputFields("generate-image")],
9
12
  "edit-image": ["prompt", "style", "negativePrompt"],
10
13
  "image-to-image": ["prompt", "style", "negativePrompt"],
11
14
  "modify-image": ["prompt", "style", "negativePrompt"],
@@ -14,10 +17,13 @@ export const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> =
14
17
  // Unified t2v/i2v node — replaced the two deprecated keys above (kept only
15
18
  // for back-compat with un-migrated workflow JSON). Mirrors text-to-video so
16
19
  // fieldMappings/{} injection AND missing-ref detection work on the live node.
17
- "generate-video": ["prompt", "negativePrompt"],
20
+ // + the fields its Settings input sets (settings-input.ts): a Generation
21
+ // Settings node wired there overrides the node's own aspect ratio, duration
22
+ // and model at run time, through the same resolver as a field mapping.
23
+ "generate-video": ["prompt", "negativePrompt", ...settingsInputFields("generate-video")],
18
24
  // Trimmed multi-segment stitch variant of generate-video — prompt only, no
19
- // negativePrompt field on the node.
20
- "generate-video-pro": ["prompt"],
25
+ // negativePrompt field on the node; + the fields its Settings input sets.
26
+ "generate-video-pro": ["prompt", ...settingsInputFields("generate-video-pro")],
21
27
  // Span-replace sibling of generate-video-pro — prompt only, no
22
28
  // negativePrompt field on the node.
23
29
  "edit-video-pro": ["prompt"],
@@ -48,7 +54,9 @@ export const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> =
48
54
  "edit-3d-scene": ["editPrompt"],
49
55
  "pro-3d-render": ["scenePrompt"],
50
56
  "motion-graphics": ["motionPrompt"],
51
- "generate-script": ["styleGuide"],
57
+ // Every field the panel offers a source for. Numbers arrive as text from a
58
+ // Scene Count / Duration node; readScriptSettings coerces them on both engines.
59
+ "generate-script": ["styleGuide", "tone", "sceneCount", "targetLength"],
52
60
  "speech-to-video": ["prompt", "negativePrompt"],
53
61
  "extend-video": ["prompt"],
54
62
  "motion-transfer": ["prompt"],
@@ -71,6 +79,14 @@ export const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> =
71
79
  "web-scrape": ["query", "url", "target"],
72
80
  "meta-ads-scrape": ["query", "pageUrls"],
73
81
  "instagram-scrape": ["targets"],
82
+ // Content Recipe's material arrives on its `in` wire and the post link on
83
+ // its `link` wire (a Video URL node's page link) — only the focus is a field.
84
+ "content-recipe": ["focus"],
85
+ // Content Ideas folds its recipes on the `recipes` wire (FAN_IN_TARGETS);
86
+ // the brand profile and the language are fields a Text node can feed.
87
+ "content-ideas": ["brand", "language"],
88
+ // Social Search: the keyword or account a Text node (or a List item) feeds.
89
+ "social-search": ["query"],
74
90
  }
75
91
 
76
92
  /** suno-generate secondary text fields exposed as `field-<key>` canvas handles. */
@@ -28,6 +28,10 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
28
28
  // below. Without the transient half, a flip into review marks a passive tab
29
29
  // dirty and a preset captures "awaiting review".
30
30
  "jobAwaitingReview",
31
+ // The editor cannot reach the server to read this node's job. The job keeps
32
+ // running and the watch keeps polling. Pure run state, cleared by the next
33
+ // check that gets through, so it is ALSO in TRANSIENT_RUNTIME_KEYS below.
34
+ "jobConnectionLost",
31
35
  "isStreaming",
32
36
  "generatedImageUrl",
33
37
  "generatedVideoUrl",
@@ -47,6 +51,11 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
47
51
  // List fan-out window flag (abandon-guard exemption). Set/cleared by
48
52
  // executeNodeForList — purely execution-related, never user-edited.
49
53
  "__listRunning",
54
+ // One token per paid run still out on this node that no executor mark
55
+ // covers (the editor's `withRunInFlight`, around each paid call outside the
56
+ // executors). Purely execution-related, never user-edited; also in
57
+ // TRANSIENT_RUNTIME_KEYS.
58
+ "__runsInFlight",
50
59
  // Selector node dual-channel outputs (picked + rest). Server-side execution
51
60
  // output, not user-edited config.
52
61
  "pickedResults",
@@ -86,12 +95,40 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
86
95
  "webhookSuccess",
87
96
  "webhookStatusCode",
88
97
  "webhookResponseBody",
98
+ // Content Ideas: one creative brief per idea (the node's list output — kept
99
+ // out of __listResults, which would clone the node). And the non-fatal notes
100
+ // a Content Recipe / Content Ideas run returns ("read the first of 3 posts").
101
+ // Both are RESULTS: they persist, and a preset, a template or a run-only
102
+ // patch must never treat them as config.
103
+ "ideaBriefs",
104
+ "runWarnings",
105
+ // Content Ideas: the own brand whose results the last run leaned on — a
106
+ // RESULT naming the runner's brand, so a template or a preset never carries it.
107
+ "brandLessons",
108
+ // Social Search: every post the last search found (the picker's grid), the
109
+ // ids a person picked from them, and the run's non-fatal notes ("only part
110
+ // of the results loaded"). All RESULTS: a template, a preset or a run-only
111
+ // patch must never carry yesterday's posts or picks as configuration.
112
+ "searchResults",
113
+ "pickedIds",
114
+ "searchWarnings",
89
115
  // When the editor's "Clear results" last emptied this node (ISO time). Not a
90
116
  // result and not config: bookkeeping that tells the load-time recovery lanes
91
117
  // "this node is empty ON PURPOSE" — without it, every reload reads an empty
92
118
  // node as "ran while the editor was closed" and paints the last run back.
93
119
  // Persisted (never transient): the reload is exactly when it is read.
94
120
  "resultsClearedAt",
121
+ // The id of the trigger-started run whose results this node shows (the
122
+ // editor paints a Telegram run onto the canvas). Bookkeeping, not a result
123
+ // and not config: it stops a reload from painting the same run again over
124
+ // edits made since. Persisted for the same reason as resultsClearedAt.
125
+ "resultsRunId",
126
+ // When that run ended the node (beside resultsRunId): the editor's reopen
127
+ // keeps a result a NEWER run left even when its own run listing cannot see
128
+ // that run. Bookkeeping, persisted for the same reason.
129
+ "resultsRunEndedAt",
130
+ // A trigger's last run values (also in TRANSIENT_RUNTIME_KEYS: never saved).
131
+ "__triggerData",
95
132
  ])
96
133
 
97
134
  /**
@@ -115,11 +152,15 @@ export const TRANSIENT_RUNTIME_KEYS: ReadonlySet<string> = new Set([
115
152
  "currentJobId",
116
153
  "currentJobProgress",
117
154
  "jobAwaitingReview",
155
+ "jobConnectionLost",
118
156
  "isStreaming",
119
157
  "subWorkflowProgress",
120
158
  "__listTotal",
121
159
  "__listCompleted",
122
160
  "__listRunning",
161
+ // A paid run still out, held by the editor tab that started it. Never
162
+ // saved, so a reload, which has no such run, starts without one.
163
+ "__runsInFlight",
123
164
  "_upstreamRefresh",
124
165
  "__upstreamCount",
125
166
  // Video URL node download ticks. They used to dirty the workflow twice a
@@ -128,6 +169,10 @@ export const TRANSIENT_RUNTIME_KEYS: ReadonlySet<string> = new Set([
128
169
  // `downloadStatus` + `downloadId`; the percent is re-read from the server.
129
170
  "downloadPercent",
130
171
  "downloadPhase",
172
+ // A trigger's last run values, shown in the editor after a run (a webhook's
173
+ // body, a Telegram message and its post). Never saved: the workflow is not
174
+ // where a message's content is kept — runs are, under their retention.
175
+ "__triggerData",
131
176
  ])
132
177
 
133
178
  /**
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The OAuth scopes a Nodaro token can carry — part of the public API contract
3
+ * (published in the authorization server's `scopes_supported`, requested by
4
+ * developer apps, typed in `@nodaro/sdk`). The server validates against this
5
+ * list and the SDK types against it, so the two cannot drift.
6
+ *
7
+ * A scope in this list is published and handed to any Dynamic Client
8
+ * Registration client that asks for everything, so add one in the same change
9
+ * that makes something check it (see backend/src/lib/scopes.ts).
10
+ */
11
+ export const OAUTH_SCOPES = [
12
+ "workflows:read",
13
+ "workflows:write",
14
+ "workflows:execute",
15
+ "jobs:read",
16
+ "assets:read",
17
+ "assets:write",
18
+ "credits:read",
19
+ "apps:read",
20
+ "pipelines:read",
21
+ "pipelines:execute",
22
+ "pipelines:approve",
23
+ "presets:read",
24
+ "workspaces:read",
25
+ "workspaces:write",
26
+ ] as const
27
+
28
+ export type OAuthScope = (typeof OAUTH_SCOPES)[number]
@@ -51,6 +51,10 @@ export const PARAMETER_NODE_TYPES: ReadonlySet<string> = new Set([
51
51
  "scene-count",
52
52
  "duration",
53
53
  "aspect-ratio",
54
+ // Generation Settings "Provider": a model id read from data at run time, like
55
+ // duration / aspect-ratio (it used to be only a SKIP node, so a server run
56
+ // could not read it at all).
57
+ "provider",
54
58
  "music-genre",
55
59
  "music-mood",
56
60
  "instrumentation",
@@ -61,8 +65,8 @@ export const PARAMETER_NODE_TYPES: ReadonlySet<string> = new Set([
61
65
  /**
62
66
  * Parameter types that intentionally produce NO prompt hint from
63
67
  * `getParameterPromptHint` (in `@nodaro/prompts`). They carry pure runtime
64
- * parameters — counts, durations, aspect ratios, legacy motion intensity —
65
- * consumed by the executor directly, never appended to a downstream prompt.
68
+ * parameters — counts, durations, aspect ratios, a model id — consumed by the
69
+ * executor directly, never appended to a downstream prompt.
66
70
  *
67
71
  * Consumers that treat "parameter node" as "text producer" (the `{Label}`
68
72
  * auto-fill in `main-text-handle.ts`, ref-map builders) must exclude these:
@@ -72,15 +76,16 @@ export const PARAMETER_NODE_TYPES: ReadonlySet<string> = new Set([
72
76
  * `main-text-handle.test.ts` (members are not text-producing).
73
77
  */
74
78
  export const HINT_EXEMPT_PARAMETER_TYPES: ReadonlySet<string> = new Set([
75
- "motion",
76
79
  "scene-count",
77
80
  "duration",
78
81
  "aspect-ratio",
82
+ "provider",
79
83
  ])
80
84
 
81
85
  /**
82
- * Parameter pickers whose fragment only makes sense in MOTION — a camera move,
83
- * a transition, a timeline, a character effect or a character movement. Every
86
+ * Parameter nodes whose fragment only makes sense in MOTION — a camera move,
87
+ * a transition, a timeline, a character effect, a character movement or the
88
+ * shot's motion intensity (the Motion node). Every
84
89
  * still-image consumer (generate-image, edit-image, image-to-image,
85
90
  * modify-image, location) excludes these on BOTH executors and in the add-node
86
91
  * popup. One set instead of three hand-synced copies: `STILL_IMAGE_EXCLUDE_TYPES`
@@ -93,6 +98,7 @@ export const VIDEO_ONLY_PARAMETER_NODE_TYPES: ReadonlySet<string> = new Set([
93
98
  "transition",
94
99
  "character-fx",
95
100
  "character-motion",
101
+ "motion",
96
102
  ])
97
103
 
98
104
  /**
@@ -357,6 +363,8 @@ export function getParameterValue(
357
363
  return data.seconds != null ? String(data.seconds) : undefined
358
364
  case "aspect-ratio":
359
365
  return trim(data.ratio)
366
+ case "provider":
367
+ return trim(data.provider)
360
368
  default:
361
369
  return undefined
362
370
  }
@@ -227,6 +227,20 @@ export function clearImageCriticMetadata(
227
227
  export const VIDEO_CRITIC_FRAME_MODES = ["first_last", "first_middle_last", "five_evenly"] as const
228
228
  export type VideoCriticFrameMode = (typeof VIDEO_CRITIC_FRAME_MODES)[number]
229
229
 
230
+ /**
231
+ * Credits the pipeline's upfront estimate reserves per shot for the Video
232
+ * Critic, by frame mode — a worst case; what goes unused is refunded when the
233
+ * pipeline completes. The config panel quotes these as "up to N credits per
234
+ * shot". The server derives its reservation separately, and a test there
235
+ * fails when the two disagree (they drifted ten-fold across a credit
236
+ * re-denomination while the panel still read ~2 / ~3 / ~4).
237
+ */
238
+ export const VIDEO_CRITIC_RESERVED_CREDITS_PER_SHOT: Readonly<Record<VideoCriticFrameMode, number>> = {
239
+ first_last: 20,
240
+ first_middle_last: 30,
241
+ five_evenly: 40,
242
+ }
243
+
230
244
  /** Cap=1 retry per shot — cost-aware (every retry is a full paid video
231
245
  * generation, the priciest step in the loop). */
232
246
  export const VIDEO_CRITIC_MAX_RETRIES = 1
@@ -133,6 +133,20 @@ export const SubGateNameSchema = z.enum([
133
133
  ])
134
134
  export type SubGateName = z.infer<typeof SubGateNameSchema>
135
135
 
136
+ /**
137
+ * The sub-gates `POST /v1/pipelines/:id/sub-gates/:gate/{approve,reject}`
138
+ * resolves: Stage 7's (`animate_audio_edit`). `match_cut_break_pending` is not
139
+ * one of them — it clears per shot, one break at a time, through
140
+ * `POST /v1/pipelines/:id/entities/:sceneId/helpers/accept_match_cut_break`
141
+ * (`MATCH_CUT_BREAK_GATE`).
142
+ */
143
+ export const ANIMATE_SUB_GATES = ["silent_cut_preview", "dialogue_recheck"] as const satisfies readonly SubGateName[]
144
+ export const AnimateSubGateSchema = z.enum(ANIMATE_SUB_GATES)
145
+ export type AnimateSubGate = (typeof ANIMATE_SUB_GATES)[number]
146
+
147
+ /** Stage 6's sub-gate, cleared by accepting each flagged break (see {@link ANIMATE_SUB_GATES}). */
148
+ export const MATCH_CUT_BREAK_GATE = "match_cut_break_pending" satisfies SubGateName
149
+
136
150
  /**
137
151
  * Phase 1C.2 — emitted when Stage 6 (scene_images) or Stage 7
138
152
  * (animate_audio_edit) pauses at a sub-gate. Carries an optional `payload`