@nodaro/shared 3.26.0 → 3.30.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 (43) hide show
  1. package/dist/index.cjs +726 -174
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +569 -34
  4. package/dist/index.d.ts +569 -34
  5. package/dist/index.js +667 -175
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/auto-aspect-source.test.ts +372 -0
  9. package/src/__tests__/camera-switch-contract.test.ts +10 -0
  10. package/src/__tests__/collections.test.ts +10 -0
  11. package/src/__tests__/edl.test.ts +319 -4
  12. package/src/__tests__/json-kinds.test.ts +11 -1
  13. package/src/__tests__/llm-models.test.ts +120 -8
  14. package/src/__tests__/pitch-tempo-pricing.test.ts +62 -0
  15. package/src/__tests__/render-nodes.test.ts +84 -5
  16. package/src/__tests__/transcribe-preflight.test.ts +5 -0
  17. package/src/__tests__/video-depth.test.ts +146 -0
  18. package/src/__tests__/video-mask.test.ts +77 -0
  19. package/src/camera-switch-contract.ts +9 -6
  20. package/src/collections.ts +72 -2
  21. package/src/credit-estimators/index.ts +10 -0
  22. package/src/credit-estimators/pitch-tempo.ts +68 -0
  23. package/src/credit-identifiers.ts +87 -19
  24. package/src/edl.ts +143 -23
  25. package/src/fan-out-rows.ts +3 -1
  26. package/src/i18n/camera-format.ko.ts +3 -3
  27. package/src/index.ts +35 -0
  28. package/src/json-kinds.ts +11 -6
  29. package/src/llm-models.ts +87 -2
  30. package/src/mask-composite.ts +108 -0
  31. package/src/model-catalog.ts +146 -4
  32. package/src/model-constants.ts +2 -1
  33. package/src/model-tree.ts +2 -0
  34. package/src/node-mappable-fields.ts +2 -0
  35. package/src/node-runtime-keys.ts +3 -0
  36. package/src/normalize-node-params.ts +47 -4
  37. package/src/pipeline-types.ts +16 -3
  38. package/src/presentation-utils.ts +3 -2
  39. package/src/producer-types.ts +13 -0
  40. package/src/render-nodes.ts +71 -6
  41. package/src/transcribe-preflight.ts +11 -10
  42. package/src/video-depth.ts +151 -0
  43. package/src/video-mask.ts +96 -0
package/src/llm-models.ts CHANGED
@@ -107,7 +107,8 @@ export interface LlmModelDef {
107
107
  supportsForcedToolChoice?: false
108
108
  /**
109
109
  * true = the model binds each thinking block to the exact conversation prefix
110
- * that produced it ("preserved thinking" — Claude Sonnet 5.5 / Opus 5.5):
110
+ * that produced it ("preserved thinking" — Claude Sonnet 5.5 / Opus 5.5 /
111
+ * Haiku 5.5):
111
112
  * replaying a block after an earlier turn was edited, dropped or rebuilt is a
112
113
  * 400 on accounts the vendor enforces. A caller that trims or rebuilds stored
113
114
  * history between requests (the Workflow Copilot keeps a token budget by
@@ -334,7 +335,8 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
334
335
  {
335
336
  id: "claude-haiku-4.5",
336
337
  displayName: "Claude Haiku 4.5",
337
- desc: "Fast economy, good reasoning",
338
+ // Demoted 2026-10-10 when claude-haiku-5.5 registered.
339
+ desc: "Previous Haiku, fast economy",
338
340
  tier: "economy",
339
341
  kieFormat: "messages",
340
342
  kieSlugOrModel: "claude-haiku-4-5",
@@ -347,6 +349,49 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
347
349
  // KIE served it plain and with a tool on its streaming wire that day.
348
350
  preferKie: true,
349
351
  },
352
+ {
353
+ id: "claude-haiku-5.5",
354
+ displayName: "Claude Haiku 5.5",
355
+ desc: "Latest Haiku, fast and low-cost with reasoning",
356
+ tier: "economy",
357
+ kieFormat: "messages",
358
+ // KIE plain id on the Claude-native messages dialect
359
+ // (docs.kie.ai/market/claude/claude-haiku-5-5.md). Live-probed 2026-10-10
360
+ // on the streaming wire: plain, system prompt, base64 image, a forced tool
361
+ // and an auto + strict tool (both came back as a real tool_use block), and
362
+ // `max_tokens: 32768` were all served.
363
+ kieSlugOrModel: "claude-haiku-5-5",
364
+ vendor: "anthropic",
365
+ structuredOutputMode: "anthropic-tool",
366
+ // NO `supportsForcedToolChoice: false`, unlike Sonnet 5.5 / Opus 5.5: this
367
+ // model ACCEPTS a forced tool_choice (probed on Anthropic's API 2026-10-10).
368
+ // A forced call skips thinking (same usage with and without an effort), and
369
+ // an effort-bearing structured call is already sent the auto choice.
370
+ //
371
+ // A thinking block is valid only while everything before it is unchanged
372
+ // (vendor docs: the same history check the other 5.5 models run).
373
+ conversationBoundThinking: true,
374
+ supportsImages: true,
375
+ maxOutputTokens: 16384,
376
+ directFallbackModel: "claude-haiku-5-5",
377
+ // The first Haiku with effort levels. The vendor default is `medium`, where
378
+ // most of the family defaults to `high`.
379
+ reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
380
+ // KIE ignores effort on this slug too — measured 2026-10-10 on a
381
+ // reasoning-heavy prompt: none / low / max / KIE's own `thinkingFlag` gave
382
+ // 2,076 / 1,886 / 2,223 / 1,927 output tokens and no thinking block, while
383
+ // Anthropic's API gave 2,059 at low and 28,097 at max. An effort call runs
384
+ // direct and bills as Advanced.
385
+ effortRequiresDirect: true,
386
+ // Anthropic 400s a non-default sampling value ("`temperature` is deprecated
387
+ // for this model", probed 2026-10-10); KIE's proxy accepted temperature: 0.2.
388
+ supportsTemperature: false,
389
+ preferKie: true,
390
+ // Adaptive thinking runs when no thinking param is sent (vendor default),
391
+ // on BOTH lanes: a no-effort KIE call spent ~2,000 output tokens on a
392
+ // ~350-token answer and returned no thinking block.
393
+ thinkingDefaultOn: true,
394
+ },
350
395
  {
351
396
  id: "claude-sonnet-4.6",
352
397
  displayName: "Claude Sonnet 4.6",
@@ -845,6 +890,9 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
845
890
  effortRequiresDirect: true,
846
891
  supportsTemperature: false,
847
892
  preferKie: true,
893
+ // Thinking is always on (vendor docs: `disabled` is not supported), so it
894
+ // shares the output cap on every call.
895
+ thinkingDefaultOn: true,
848
896
  },
849
897
  // ── Moonshot / DeepSeek ───────────────────────────────────────────────────
850
898
  // Both on KIE's THIRD responses family path, openai/v1/responses (llm-client
@@ -1040,6 +1088,42 @@ export const LLM_FEATURE_DEFAULTS: Record<LlmFeature, string> = {
1040
1088
  "content-ideas": "gemini-3.6-flash",
1041
1089
  }
1042
1090
 
1091
+ /**
1092
+ * Feature → the reasoning effort its DEFAULT model runs at when the caller
1093
+ * sends none. Read it through {@link defaultReasoningEffort}, never directly:
1094
+ * the effort belongs to the default model, so a call on any other model must
1095
+ * not pick it up.
1096
+ */
1097
+ export const LLM_FEATURE_DEFAULT_EFFORTS: Partial<Record<LlmFeature, LlmReasoningEffort>> = {
1098
+ // Decided 2026-10-09 from the picker bake-off v2: Opus 5.5 at `high` read
1099
+ // 4/4 portraits with the most attributes per image, ~9 s a read. Its effort
1100
+ // only takes effect on Anthropic's own API (`effortRequiresDirect`), so the
1101
+ // default analysis runs direct — and bills as such (`llmServesDirect`).
1102
+ "describe-to-picker": "high",
1103
+ }
1104
+
1105
+ /**
1106
+ * The reasoning effort a `feature` call runs at when the caller sends none:
1107
+ * the feature's default effort ({@link LLM_FEATURE_DEFAULT_EFFORTS}), but ONLY
1108
+ * while the call runs on the feature's default model — named, or omitted
1109
+ * (`undefined` / `""`) so the default model applies. A caller who picked
1110
+ * another model and no effort gets `undefined`: that model's Auto, as before.
1111
+ *
1112
+ * WHY only on the default model: the default effort is part of the default
1113
+ * model's recipe, not a global policy. Forcing `high` on a Gemini or GPT call
1114
+ * that never asked for it would change the timing of every existing workflow
1115
+ * that picked one (and, on a Claude model, its lane and its bill).
1116
+ *
1117
+ * The one place the route, the node's credit badge and its effort pickers
1118
+ * read, so what runs, what is billed and what is shown cannot disagree.
1119
+ */
1120
+ export function defaultReasoningEffort(feature: string, modelId?: string): LlmReasoningEffort | undefined {
1121
+ const effort = LLM_FEATURE_DEFAULT_EFFORTS[feature as LlmFeature]
1122
+ if (!effort) return undefined
1123
+ if (!modelId) return effort
1124
+ return getLlmModel(modelId)?.id === LLM_FEATURE_DEFAULTS[feature as LlmFeature] ? effort : undefined
1125
+ }
1126
+
1043
1127
  /**
1044
1128
  * Per-model multimodal input capabilities. Drives both frontend UI gating
1045
1129
  * and backend route-level filtering for the LLM Chat node references.
@@ -1069,6 +1153,7 @@ export const LLM_MODALITY_CAPS: Record<string, { image: boolean; video: boolean;
1069
1153
  "gemini-3.8-flash": { image: true, video: false, audio: false },
1070
1154
  "gemini-3.1-pro": { image: true, video: true, audio: true },
1071
1155
  "claude-haiku-4.5": { image: true, video: false, audio: false },
1156
+ "claude-haiku-5.5": { image: true, video: false, audio: false },
1072
1157
  "claude-sonnet-4.6": { image: true, video: false, audio: false },
1073
1158
  "claude-opus-4.7": { image: true, video: false, audio: false },
1074
1159
  "gpt-5.2": { image: true, video: false, audio: false },
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Mask Composite — place a foreground video over a background video through a
3
+ * mask video (white = keep the foreground, black = show the background). The
4
+ * wire contract of the `mask-composite` node, `POST /v1/mask-composite`, the
5
+ * `mask_composite` MCP verb, `client.media.maskComposite` and
6
+ * `nodaro media mask-composite`, defined ONCE. Pair it with Video Mask, whose
7
+ * output is exactly such a mask.
8
+ *
9
+ * The render follows the FOREGROUND: its size, frame rate and length. The
10
+ * background is fitted to that frame (`backgroundFit`) and loops when shorter;
11
+ * the mask is stretched to the frame and holds its last frame when shorter.
12
+ *
13
+ * Priced per started 5 seconds of the result (the foreground's length), like
14
+ * Trim / Loop / Combine Videos: the node's own `model_pricing` row is ONE unit
15
+ * (`maskCompositeUnits` counts them). Worked examples (repeated in
16
+ * docs/nodes/processing-video/mask-composite.md, at the 10-credit row):
17
+ * 3 s → 1 unit (10), 10 s → 2 units (20), 61 s → 13 units (130), 5 min → 60 units (600).
18
+ *
19
+ * Wire contract only — no I/O.
20
+ */
21
+
22
+ /** How the background is fitted to the foreground's frame. */
23
+ export const MASK_COMPOSITE_BACKGROUND_FITS = ["cover", "contain", "stretch"] as const
24
+ export type MaskCompositeBackgroundFit = (typeof MASK_COMPOSITE_BACKGROUND_FITS)[number]
25
+
26
+ /** Which sound the result carries. `mix` blends both tracks at equal level. */
27
+ export const MASK_COMPOSITE_AUDIO_SOURCES = ["foreground", "background", "mix", "none"] as const
28
+ export type MaskCompositeAudioSource = (typeof MASK_COMPOSITE_AUDIO_SOURCES)[number]
29
+
30
+ export const MASK_COMPOSITE_BOUNDS = {
31
+ /** Edge softening, pixels of blur radius on the mask (0 = hard edge). */
32
+ FEATHER_MIN: 0,
33
+ FEATHER_MAX: 20,
34
+ /** Grow (+) or shrink (−) the white region, pixels. */
35
+ GROW_MIN: -10,
36
+ GROW_MAX: 10,
37
+ /** The longest foreground a run accepts, seconds. */
38
+ MAX_DURATION_SEC: 300,
39
+ } as const
40
+
41
+ /** Seconds of result one pricing unit covers. */
42
+ export const MASK_COMPOSITE_UNIT_SEC = 5
43
+
44
+ /**
45
+ * Pricing units for a result `durationSec` long: one per started 5 seconds,
46
+ * at least one. An unknown length counts the longest result a run accepts
47
+ * (an upper bound — the pre-run quote for a clip whose length is not known
48
+ * yet; every run measures its foreground).
49
+ */
50
+ export function maskCompositeUnits(durationSec: number | null | undefined): number {
51
+ const sec =
52
+ typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0
53
+ ? Math.min(durationSec, MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC)
54
+ : MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC
55
+ // The epsilon absorbs float noise (a 10.0000001 s probe is 2 units, not 3).
56
+ return Math.max(1, Math.ceil(sec / MASK_COMPOSITE_UNIT_SEC - 1e-6))
57
+ }
58
+
59
+ export const MASK_COMPOSITE_DEFAULTS = {
60
+ invertMask: false,
61
+ feather: 2,
62
+ grow: 0,
63
+ backgroundFit: "cover" as MaskCompositeBackgroundFit,
64
+ audioSource: "foreground" as MaskCompositeAudioSource,
65
+ } as const
66
+
67
+ export interface MaskCompositeSettings {
68
+ readonly invertMask: boolean
69
+ readonly feather: number
70
+ readonly grow: number
71
+ readonly backgroundFit: MaskCompositeBackgroundFit
72
+ readonly audioSource: MaskCompositeAudioSource
73
+ }
74
+
75
+ const clampInt = (v: unknown, min: number, max: number, fallback: number): number =>
76
+ typeof v === "number" && Number.isFinite(v) ? Math.min(max, Math.max(min, Math.round(v))) : fallback
77
+
78
+ /**
79
+ * Node data (or any loose object) → settings every engine renders with.
80
+ * Unknown enum values fall back to the default and numbers are clamped, so a
81
+ * node written straight into workflow JSON renders the same as one set in the
82
+ * panel. The ONE normaliser both workflow engines and the worker call.
83
+ */
84
+ export function resolveMaskCompositeSettings(data: Readonly<Record<string, unknown>>): MaskCompositeSettings {
85
+ const d = MASK_COMPOSITE_DEFAULTS
86
+ const b = MASK_COMPOSITE_BOUNDS
87
+ return {
88
+ invertMask: typeof data.invertMask === "boolean" ? data.invertMask : d.invertMask,
89
+ feather: clampInt(data.feather, b.FEATHER_MIN, b.FEATHER_MAX, d.feather),
90
+ grow: clampInt(data.grow, b.GROW_MIN, b.GROW_MAX, d.grow),
91
+ backgroundFit: (MASK_COMPOSITE_BACKGROUND_FITS as readonly string[]).includes(data.backgroundFit as string)
92
+ ? (data.backgroundFit as MaskCompositeBackgroundFit)
93
+ : d.backgroundFit,
94
+ audioSource: (MASK_COMPOSITE_AUDIO_SOURCES as readonly string[]).includes(data.audioSource as string)
95
+ ? (data.audioSource as MaskCompositeAudioSource)
96
+ : d.audioSource,
97
+ }
98
+ }
99
+
100
+ /** `POST /v1/mask-composite` request body. */
101
+ export interface MaskCompositeRequest extends Partial<MaskCompositeSettings> {
102
+ /** The video whose white-masked region is kept (its size, rate and length lead). */
103
+ readonly foregroundUrl: string
104
+ /** The video shown where the mask is black. */
105
+ readonly backgroundUrl: string
106
+ /** The mask video — white = foreground (Video Mask's output). */
107
+ readonly maskUrl: string
108
+ }
@@ -48,6 +48,7 @@ export type ModelMode =
48
48
  | "motion-transfer"
49
49
  | "lip-sync"
50
50
  | "video-upscale"
51
+ | "video-depth"
51
52
  // audio
52
53
  | "tts"
53
54
  | "music"
@@ -344,7 +345,7 @@ const VIDEO_RATIOS_HVS = ["16:9", "9:16", "1:1"] as const
344
345
  const WAN_27_IMAGE_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "21:9", "8:1", "1:8"] as const
345
346
  const VIDEO_RATIOS_HVS345 = ["16:9", "9:16", "1:1", "4:3", "3:4"] as const
346
347
  // Seedance 2.x only — KIE accepts the full fixed-ratio set incl. 21:9
347
- // (docs.kie.ai/market/bytedance/seedance-2); MiniMax Hailuo 3 shares the same
348
+ // (docs.kie.ai/market/bytedance/seedance-2); MiniMax H3 shares the same
348
349
  // seven-ratio set (t2v enum + r2v adaptive default per docs.kie.ai/market/minimax-h3).
349
350
  // Kept separate from HVS so the
350
351
  // wider set can't leak to models that don't support it.
@@ -1270,7 +1271,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1270
1271
  defaultDuration: 5,
1271
1272
  pricing: [{ identifier: "minimax", credits: 143, note: "5s, 1080p" }],
1272
1273
  },
1273
- // MiniMax Hailuo 3 (KIE "minimax-h3") — t2v / i2v (first and/or last frame) /
1274
+ // MiniMax H3 (KIE "minimax-h3") — t2v / i2v (first and/or last frame) /
1274
1275
  // reference-to-video (9 images / 3 videos ≤15s total / 3 audios ≤15s total;
1275
1276
  // audio refs require an image or video ref alongside). Two-rate resolution
1276
1277
  // lever (768P added 2026-08-03): 2K (KIE default) at 36.5 KIE cr/s, 768P at
@@ -1288,7 +1289,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1288
1289
  family: "MiniMax",
1289
1290
  label: "minimax-h3",
1290
1291
  series: "Hailuo",
1291
- description: "MiniMax Hailuo 3 — premium multimodal tier: first/last frame + image/video/audio references, native audio, 2K (default) or 768P output, 4-15s per-second pricing.",
1292
+ description: "MiniMax H3 — premium multimodal tier: first/last frame + image/video/audio references, native audio, 2K (default) or 768P output, 4-15s per-second pricing.",
1292
1293
  useCases: ["premium", "narrative"],
1293
1294
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1294
1295
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
@@ -2450,6 +2451,45 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2450
2451
  { identifier: "volcengine-lipsync:300s", credits: 6000, note: "5-min ceiling" },
2451
2452
  ],
2452
2453
  },
2454
+ // ── Video Depth ── (video-depth node; billed per duration bucket via
2455
+ // videoDepthCreditId in video-depth.ts — `<provider>:<bucket>s`, bare row =
2456
+ // the 300 s ceiling, same shape as volcengine-lipsync.)
2457
+ "video-depth-anything": {
2458
+ id: "video-depth-anything",
2459
+ kind: "video",
2460
+ modes: ["video-depth"] as const,
2461
+ family: "Depth Anything",
2462
+ label: "Video Depth Anything",
2463
+ series: "Depth Anything",
2464
+ description: "Temporally consistent depth video from any clip. Grayscale or colormapped, up to 2,400 frames or 300 seconds.",
2465
+ useCases: ["depth", "video-to-video", "compositing"],
2466
+ pricing: [
2467
+ { identifier: "video-depth-anything", credits: 6000, note: "5-min ceiling (no duration given)" },
2468
+ { identifier: "video-depth-anything:15s", credits: 300 },
2469
+ { identifier: "video-depth-anything:30s", credits: 600 },
2470
+ { identifier: "video-depth-anything:60s", credits: 1200 },
2471
+ { identifier: "video-depth-anything:120s", credits: 2400 },
2472
+ { identifier: "video-depth-anything:300s", credits: 6000, note: "5-min ceiling" },
2473
+ ],
2474
+ },
2475
+ "depth-anything-frames": {
2476
+ id: "depth-anything-frames",
2477
+ kind: "video",
2478
+ modes: ["video-depth"] as const,
2479
+ family: "Depth Anything",
2480
+ label: "Depth Anything (per frame)",
2481
+ series: "Depth Anything",
2482
+ description: "Depth Anything v1 run on each frame. Grayscale or inferno colormap; may flicker between frames. Up to 80 s.",
2483
+ useCases: ["depth", "video-to-video"],
2484
+ pricing: [
2485
+ { identifier: "depth-anything-frames", credits: 600, note: "5-min ceiling (no duration given)" },
2486
+ { identifier: "depth-anything-frames:15s", credits: 30 },
2487
+ { identifier: "depth-anything-frames:30s", credits: 60 },
2488
+ { identifier: "depth-anything-frames:60s", credits: 120 },
2489
+ { identifier: "depth-anything-frames:120s", credits: 240 },
2490
+ { identifier: "depth-anything-frames:300s", credits: 600, note: "5-min ceiling" },
2491
+ ],
2492
+ },
2453
2493
  // ── Gemini video analysis ── (Gemini-only; billed per duration bucket — the
2454
2494
  // structural credit formula lives in video-analysis-pricing.ts. Composite id
2455
2495
  // shape `video-analysis:<model>:<bucket>s` mirrors volcengine-lipsync: bare
@@ -3281,6 +3321,88 @@ export interface NormalizedModelInput {
3281
3321
  adjustments: ModelInputAdjustment[]
3282
3322
  }
3283
3323
 
3324
+ /** A source image's pixel size as it is DISPLAYED (EXIF orientation applied). */
3325
+ export interface SourceImageSize {
3326
+ width: number
3327
+ height: number
3328
+ }
3329
+
3330
+ /** What a request knows beyond its own levers. */
3331
+ export interface ModelInputContext {
3332
+ /**
3333
+ * The image an image-to-image or edit request transforms. Only read to
3334
+ * resolve "auto" on a model without a native auto; absent or unusable means
3335
+ * the size is unknown and "auto" snaps the way it always has.
3336
+ */
3337
+ sourceImage?: SourceImageSize
3338
+ }
3339
+
3340
+ /** True for the "auto" aspect token in any case or padding. */
3341
+ export function isAutoAspectToken(value: unknown): boolean {
3342
+ return typeof value === "string" && value.trim().toLowerCase() === "auto"
3343
+ }
3344
+
3345
+ function usableSize(size: SourceImageSize | undefined): size is SourceImageSize {
3346
+ return (
3347
+ size !== undefined &&
3348
+ Number.isFinite(size.width) && size.width > 0 &&
3349
+ Number.isFinite(size.height) && size.height > 0
3350
+ )
3351
+ }
3352
+
3353
+ /**
3354
+ * Log-space distances closer than this are a tie. Mirror pairs that are
3355
+ * mathematically equidistant (4:3 and 3:4 from a square) differ in the last
3356
+ * bit once `Math.log` rounds them, so an exact comparison would let rounding,
3357
+ * not the catalog's order, pick between them. Real catalog ratios sit at least
3358
+ * ~1e-2 apart, far above this.
3359
+ *
3360
+ * Source-size path ONLY. The ratio-TOKEN fit (`nearestAspectRatio` behind
3361
+ * `fitAspectRatioToModel`) keeps its strict comparison on purpose: it mirrors
3362
+ * the video adapters' `snapAspectRatioToken` exactly (pinned by
3363
+ * `video-normalizer-totality.test.ts`), and a request must snap to one ratio
3364
+ * whichever door it came through.
3365
+ */
3366
+ const ASPECT_TIE_EPSILON = 1e-9
3367
+
3368
+ /**
3369
+ * The ratio in `ratios` nearest a `sourceWidth` x `sourceHeight` image:
3370
+ * minimises |ln(w/h) - ln(rw/rh)|, so a portrait and its landscape mirror are
3371
+ * equally far from a square. Entries that are not ratios ("auto", "adaptive",
3372
+ * "match_input_image") are skipped, and a tie goes to the ratio listed first
3373
+ * (`ASPECT_TIE_EPSILON`). `undefined` for unusable dimensions or a list
3374
+ * without a single ratio.
3375
+ */
3376
+ export function nearestCatalogAspectRatio(
3377
+ sourceWidth: number,
3378
+ sourceHeight: number,
3379
+ ratios: readonly string[],
3380
+ ): string | undefined {
3381
+ if (!usableSize({ width: sourceWidth, height: sourceHeight })) return undefined
3382
+ const target = Math.log(sourceWidth / sourceHeight)
3383
+ let best: string | undefined
3384
+ let bestDist = Infinity
3385
+ for (const ratio of ratios) {
3386
+ const [rw, rh] = ratio.split(":").map(Number)
3387
+ if (!rw || !rh || rw < 0 || rh < 0) continue
3388
+ const dist = Math.abs(Math.log(rw / rh) - target)
3389
+ if (dist < bestDist - ASPECT_TIE_EPSILON) { bestDist = dist; best = ratio }
3390
+ }
3391
+ return best
3392
+ }
3393
+
3394
+ /**
3395
+ * True when `aspectRatio` is "auto" and `modelId`'s catalog ratio list does not
3396
+ * carry "auto" — the one case where the source image's size decides the ratio.
3397
+ * A caller that has to fetch the size asks this first, so a request that will
3398
+ * not use it never pays for the read.
3399
+ */
3400
+ export function autoAspectNeedsSourceImage(modelId: string | undefined, aspectRatio: unknown): boolean {
3401
+ if (!modelId || !isAutoAspectToken(aspectRatio)) return false
3402
+ const ratios = MODEL_CATALOG[modelId]?.aspectRatios
3403
+ return ratios !== undefined && ratios.length > 0 && !ratios.some(isAutoAspectToken)
3404
+ }
3405
+
3284
3406
  /**
3285
3407
  * Coerce a model's parameters into a combination the model actually accepts.
3286
3408
  *
@@ -3295,6 +3417,10 @@ export interface NormalizedModelInput {
3295
3417
  *
3296
3418
  * Rules, mirroring the config panels' provider-change snap:
3297
3419
  * - Model has no such lever → drop the value (sending it 400s upstream).
3420
+ * - "auto" on a model whose list lacks it, with a known `context.sourceImage`
3421
+ * → the listed ratio nearest the source's shape (`nearestCatalogAspectRatio`).
3422
+ * "auto" asks to keep the source photo's shape; the first listed ratio
3423
+ * would reframe every source of another shape.
3298
3424
  * - Value outside the model's allow-list → snap to the model's default
3299
3425
  * (`defaultResolutionFor`) or the first valid option.
3300
3426
  * - Then apply cross-field constraints that only hold for certain models.
@@ -3313,6 +3439,7 @@ export function normalizeModelInput(
3313
3439
  quality?: string
3314
3440
  duration?: number
3315
3441
  },
3442
+ context: ModelInputContext = {},
3316
3443
  ): NormalizedModelInput {
3317
3444
  const m = MODEL_CATALOG[modelId]
3318
3445
  const adjustments: ModelInputAdjustment[] = []
@@ -3355,7 +3482,22 @@ export function normalizeModelInput(
3355
3482
  return next
3356
3483
  }
3357
3484
 
3358
- out.aspectRatio = snap("aspectRatio", input.aspectRatio, m.aspectRatios)
3485
+ const sourceRatio =
3486
+ autoAspectNeedsSourceImage(modelId, input.aspectRatio) && usableSize(context.sourceImage)
3487
+ ? nearestCatalogAspectRatio(context.sourceImage.width, context.sourceImage.height, m.aspectRatios ?? [])
3488
+ : undefined
3489
+ if (sourceRatio !== undefined && input.aspectRatio !== undefined) {
3490
+ const { width, height } = context.sourceImage!
3491
+ adjustments.push({
3492
+ field: "aspectRatio",
3493
+ from: input.aspectRatio,
3494
+ to: sourceRatio,
3495
+ reason: `${m.label} has no "auto" aspect ratio — using "${sourceRatio}", the supported ratio closest to the source image's shape (${width}x${height}).`,
3496
+ })
3497
+ out.aspectRatio = sourceRatio
3498
+ } else {
3499
+ out.aspectRatio = snap("aspectRatio", input.aspectRatio, m.aspectRatios)
3500
+ }
3359
3501
  out.resolution = snap(
3360
3502
  "resolution",
3361
3503
  input.resolution,
@@ -640,7 +640,8 @@ export const DEFAULT_REF_IMAGE_MAX = 4
640
640
  * route silently routes to the i2i sibling ({@link T2I_TO_I2I_VARIANT}) —
641
641
  * the endpoint that actually consumes refs — so the advertised cap is the
642
642
  * SIBLING's (grok→grok-i2i = 1, gpt-image-2→gpt-image-2-i2i = 16), never the
643
- * t2i id's absent default. Mirrors the route's `resolveEffectiveProvider`.
643
+ * t2i id's absent default. Mirrors the swap `resolveNormalizedImageGen`
644
+ * makes for the route and the workflow run alike.
644
645
  * 2. {@link REF_IMAGE_MAX_LIMITS} is the PRODUCT/UI cap, which may be
645
646
  * intentionally TIGHTER than the raw provider schema (e.g. flux-2-pro = 4
646
647
  * here though the BFL schema accepts 8; flux-2-klein = 1 though the array
package/src/model-tree.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, LIP_SYNC_PROVIDERS,
13
13
  FACE_SWAP_PROVIDERS, TTS_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS,
14
14
  } from "./model-constants.js"
15
+ import { VIDEO_DEPTH_PROVIDERS } from "./video-depth.js"
15
16
 
16
17
  export interface ModelNodeTarget {
17
18
  nodeType: string
@@ -38,6 +39,7 @@ const ENUM_TARGETS: ReadonlyArray<readonly [readonly string[], string]> = [
38
39
  [TEXT_TO_VIDEO_PROVIDERS, "generate-video"],
39
40
  [UPSCALE_IMAGE_PROVIDERS, "upscale-image"],
40
41
  [VIDEO_UPSCALE_PROVIDERS, "video-upscale"],
42
+ [VIDEO_DEPTH_PROVIDERS, "video-depth"],
41
43
  [MODIFY_IMAGE_PROVIDERS, "modify-image"],
42
44
  [IMAGE_EDIT_PROVIDERS, "modify-image"],
43
45
  [VIDEO_TO_VIDEO_PROVIDERS, "video-to-video"],
@@ -27,6 +27,8 @@ export const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> =
27
27
  // Span-replace sibling of generate-video-pro — prompt only, no
28
28
  // negativePrompt field on the node.
29
29
  "edit-video-pro": ["prompt"],
30
+ // The subject to track — a {Label} reference or a mapping writes it.
31
+ "video-mask": ["prompt"],
30
32
  "video-analysis": ["analysisFocus", "youtubeUrl"],
31
33
  "video-to-video": ["prompt"],
32
34
  // + the two neighbour-text fields (continuity across clips): a wired Text node can feed
@@ -72,6 +72,9 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
72
72
  "__pickedTotal",
73
73
  "__restTotal",
74
74
  "generatedJson",
75
+ // A render's remapped transcript on its own pip (Speaker View's
76
+ // `transcript`, RENDER_NODE_TYPES transcriptOutput) — run-result data.
77
+ "generatedTranscript",
75
78
  // Edit Plan: a person's review of the plan (`EditedEdl`, edit-plan-review.ts),
76
79
  // kept beside `generatedJson` and fingerprinted against it. Run-result data
77
80
  // (TA14, decided 2026-10-04): out of undo, presets, templates and exports,
@@ -20,7 +20,8 @@
20
20
  * is covered without touching this file.
21
21
  */
22
22
 
23
- import { normalizeModelInput, type ModelInputAdjustment } from "./model-catalog.js"
23
+ import { autoAspectNeedsSourceImage, normalizeModelInput, type ModelInputAdjustment } from "./model-catalog.js"
24
+ import { imageGenAutoAspectNeedsSourceImage } from "./credit-identifiers.js"
24
25
 
25
26
  /**
26
27
  * Node types whose `data` carries catalog-governed model parameters under the
@@ -44,6 +45,35 @@ export const MODEL_PARAM_NODE_TYPES: ReadonlySet<string> = new Set([
44
45
  "edit-image",
45
46
  ])
46
47
 
48
+ /**
49
+ * The image node types that transform a SOURCE image (their required `image`
50
+ * input). On these "auto" means "keep the source photo's shape", and the run
51
+ * resolves it against that image — natively on a model that lists "auto", else
52
+ * to the model's nearest listed ratio (`normalizeModelInput`'s `sourceImage`).
53
+ *
54
+ * `generate-image` is absent: its photo is optional, and it is the first image
55
+ * its references ASSEMBLE to, not a node input — see
56
+ * `AUTO_ASPECT_AT_RUN_NODE_TYPES`.
57
+ */
58
+ export const SOURCE_IMAGE_NODE_TYPES: ReadonlySet<string> = new Set([
59
+ "image-to-image",
60
+ "modify-image",
61
+ "edit-image",
62
+ ])
63
+
64
+ /**
65
+ * The node types whose "auto" aspect ratio the RUN resolves against a photo,
66
+ * so a write boundary (which has no photo) keeps it: the source-image types,
67
+ * plus `generate-image`, whose photo is the first reference the run assembles
68
+ * (or its inpaint / refine base). A Generate Image run with no photo snaps
69
+ * "auto" exactly as this boundary used to — the value that reaches a provider
70
+ * never changes there.
71
+ */
72
+ export const AUTO_ASPECT_AT_RUN_NODE_TYPES: ReadonlySet<string> = new Set([
73
+ ...SOURCE_IMAGE_NODE_TYPES,
74
+ "generate-image",
75
+ ])
76
+
47
77
  export interface NodeParamAdjustment extends ModelInputAdjustment {
48
78
  nodeId: string
49
79
  provider: string
@@ -97,12 +127,25 @@ export function normalizeNodeModelParams<T extends NodeLike>(
97
127
  : undefined
98
128
  if (!provider) return node
99
129
 
130
+ // A write boundary has no photo, so "auto" on a node the run resolves it for
131
+ // is left for the run to resolve against the photo — snapping it here would
132
+ // discard the very request ("keep my photo's shape") the run can honour. It
133
+ // is stored in its canonical spelling, the one the image routes' ratio enum
134
+ // accepts. A Generate Image run snaps against its model's i2i sibling once
135
+ // references attach, and this boundary cannot count them (wired ones come
136
+ // from edges), so it asks about both.
137
+ const deferAuto = AUTO_ASPECT_AT_RUN_NODE_TYPES.has(type) && (
138
+ type === "generate-image"
139
+ ? imageGenAutoAspectNeedsSourceImage({ provider, aspectRatio: d.aspectRatio })
140
+ : autoAspectNeedsSourceImage(provider, d.aspectRatio)
141
+ )
100
142
  const normalized = normalizeModelInput(provider, {
101
- aspectRatio: typeof d.aspectRatio === "string" ? d.aspectRatio : undefined,
143
+ aspectRatio: !deferAuto && typeof d.aspectRatio === "string" ? d.aspectRatio : undefined,
102
144
  resolution: typeof d.resolution === "string" ? d.resolution : undefined,
103
145
  quality: typeof d.quality === "string" ? d.quality : undefined,
104
146
  })
105
- if (normalized.adjustments.length === 0) return node
147
+ const respell = deferAuto && d.aspectRatio !== "auto"
148
+ if (normalized.adjustments.length === 0 && !respell) return node
106
149
 
107
150
  const nodeId = typeof node.id === "string" ? node.id : "(unknown node)"
108
151
  for (const adj of normalized.adjustments) {
@@ -116,7 +159,7 @@ export function normalizeNodeModelParams<T extends NodeLike>(
116
159
  ...node,
117
160
  data: {
118
161
  ...d,
119
- aspectRatio: normalized.aspectRatio,
162
+ aspectRatio: deferAuto ? "auto" : normalized.aspectRatio,
120
163
  resolution: normalized.resolution,
121
164
  quality: normalized.quality,
122
165
  },
@@ -95,16 +95,29 @@ export type PipelinePinnableVideoModel = (typeof PIPELINE_PINNABLE_VIDEO_MODELS)
95
95
  // the upfront credit reservation. Adding GPT/Gemini support requires routing
96
96
  // through `lib/llm-client.ts` first; until then, keep this list tight.
97
97
  export const PIPELINE_PINNABLE_SCRIPT_LLMS = [
98
- "claude-haiku-4-5",
98
+ "claude-haiku-5-5",
99
99
  "claude-sonnet-4-6",
100
100
  "claude-opus-4-7",
101
101
  "claude-opus-5",
102
102
  ] as const
103
- export type PipelinePinnableScriptLlm = (typeof PIPELINE_PINNABLE_SCRIPT_LLMS)[number]
103
+
104
+ // Script LLMs no longer OFFERED as a pin but still honoured when a saved
105
+ // pipeline names one: Claude Haiku 5.5 replaced Claude Haiku 4.5 in the picker
106
+ // (decided 2026-10-10), and a pipeline pinned to Haiku 4.5 before that keeps
107
+ // its pin.
108
+ export const PIPELINE_LEGACY_PINNED_SCRIPT_LLMS = ["claude-haiku-4-5"] as const
109
+
110
+ /** Every script LLM a pipeline's config may name: the offered pins plus the legacy ones. */
111
+ export const PIPELINE_ACCEPTED_SCRIPT_LLMS = [
112
+ ...PIPELINE_PINNABLE_SCRIPT_LLMS,
113
+ ...PIPELINE_LEGACY_PINNED_SCRIPT_LLMS,
114
+ ] as const
115
+ /** A script LLM a pipeline config may carry — an offered pin or a legacy one a saved pipeline still names. */
116
+ export type PipelinePinnableScriptLlm = (typeof PIPELINE_ACCEPTED_SCRIPT_LLMS)[number]
104
117
 
105
118
  const ImageModelEnum = z.enum(PIPELINE_ACCEPTED_IMAGE_MODELS)
106
119
  const VideoModelEnum = z.enum(PIPELINE_PINNABLE_VIDEO_MODELS)
107
- const ScriptLlmEnum = z.enum(PIPELINE_PINNABLE_SCRIPT_LLMS)
120
+ const ScriptLlmEnum = z.enum(PIPELINE_ACCEPTED_SCRIPT_LLMS)
108
121
 
109
122
  // Per-stage override map. Each stage key maps to a model id valid for its
110
123
  // kind. Defined as a discriminated shape (instead of `Record<stage, string>`)
@@ -127,6 +127,7 @@ const MEDIA_PRODUCING_TYPES = new Set([
127
127
  "lip-sync",
128
128
  "motion-transfer",
129
129
  "video-upscale",
130
+ "video-depth",
130
131
  ])
131
132
 
132
133
  // Output type categorizations
@@ -147,7 +148,7 @@ const VIDEO_OUTPUT_TYPES = new Set([
147
148
  "combine-videos", "merge-video-audio", "resize-video", "trim-video",
148
149
  "speed-ramp", "loop-video", "fade-video", "transcode-video",
149
150
  "upload-video",
150
- "lip-sync", "motion-transfer", "video-upscale", "add-captions",
151
+ "lip-sync", "motion-transfer", "video-upscale", "video-depth", "add-captions",
151
152
  "social-media-format",
152
153
  // A render (Apply EDL) renders an EDL into video OR audio. Its medium is
153
154
  // decided at run time (DYNAMIC_PRODUCER_TYPES), so getOutputType would answer
@@ -162,7 +163,7 @@ const VIDEO_OUTPUT_TYPES = new Set([
162
163
  const AUDIO_OUTPUT_TYPES = new Set([
163
164
  "text-to-speech", "generate-music", "text-to-audio",
164
165
  "text-to-dialogue", "voice-changer", "dubbing", "voice-remix",
165
- "voice-design", "mix-audio", "adjust-volume", "audio-fx", "trim-audio",
166
+ "voice-design", "mix-audio", "adjust-volume", "audio-fx", "pitch-tempo", "trim-audio",
166
167
  "audio-isolation",
167
168
  "audio-separation",
168
169
  "upload-audio",