@nodaro/shared 3.26.0 → 3.27.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.
package/src/json-kinds.ts CHANGED
@@ -14,7 +14,8 @@
14
14
  * Output kinds are DATA, never a list of node names:
15
15
  * - a render node's `json` pip answers its registry `jsonKind`
16
16
  * (`RENDER_NODE_TYPES`), so a render registered later — Speaker View, whose
17
- * json is an EDL — is covered by its own registry entry;
17
+ * json is an EDL — is covered by its own registry entry; its transcript pip
18
+ * (`transcriptOutput`, Speaker View's `transcript`) is a Transcript;
18
19
  * - the other JSON producers declare a kind per output pip in
19
20
  * `JSON_OUTPUT_KINDS` below. EVERY node with a JSON output declares one
20
21
  * (decided 2026-10-08): `transcript`, `edl`, or `other` for JSON that is
@@ -26,7 +27,7 @@
26
27
  * Input kinds follow the platform's handle vocabulary: a `transcript` pip
27
28
  * expects a Transcript, an `edl` pip an EDL.
28
29
  */
29
- import { RENDER_NODE_TYPES, type RenderNodeDescriptor } from "./render-nodes.js"
30
+ import { RENDER_JSON_HANDLE, RENDER_NODE_TYPES, type RenderNodeDescriptor } from "./render-nodes.js"
30
31
 
31
32
  /** The two JSON shapes the platform's handle vocabulary tells apart. */
32
33
  export type JsonKind = "transcript" | "edl"
@@ -52,6 +53,9 @@ const JSON_OUTPUT_KINDS: Readonly<Record<string, JsonOutputs>> = Object.freeze({
52
53
  transcribe: { primary: "json", pips: { json: "transcript" } },
53
54
  // Camera Switch: the switched edit and the renamed (still a Transcript) transcript.
54
55
  "camera-switch": { primary: "edl", pips: { edl: "edl", transcript: "transcript" } },
56
+ // Speaker Frames: the stored track file's descriptor (P3-22) — neither a
57
+ // Transcript nor an EDL, read by Speaker View's `tracks` input (P3.9).
58
+ "speaker-frames": { primary: "tracks", pips: { tracks: "other" } },
55
59
  // Text to Dialogue: the Transcript built from the model's own word timings (its default read is the audio).
56
60
  "text-to-dialogue": { pips: { json: "transcript" } },
57
61
 
@@ -81,9 +85,6 @@ const JSON_OUTPUT_KINDS: Readonly<Record<string, JsonOutputs>> = Object.freeze({
81
85
  "describe-to-picker": { primary: "picker-json", pips: { "picker-json": "other" } },
82
86
  })
83
87
 
84
- /** The pip a render's order reads/writes its json on. */
85
- const RENDER_JSON_PIP = "json"
86
-
87
88
  /** The input pips whose kind is fixed by the handle vocabulary. */
88
89
  const JSON_INPUT_KINDS: Readonly<Record<string, JsonKind>> = Object.freeze({
89
90
  transcript: "transcript",
@@ -107,7 +108,11 @@ export function declaredJsonOutput(
107
108
  ): JsonOutputDeclaration | undefined {
108
109
  if (typeof nodeType !== "string") return undefined
109
110
  const render = own(renders, nodeType)
110
- if (render) return (sourceHandle ?? RENDER_JSON_PIP) === RENDER_JSON_PIP ? render.jsonKind : undefined
111
+ if (render) {
112
+ const pip = sourceHandle ?? RENDER_JSON_HANDLE
113
+ if (pip === RENDER_JSON_HANDLE) return render.jsonKind
114
+ return pip === render.transcriptOutput.handle ? "transcript" : undefined
115
+ }
111
116
  const outputs = own(JSON_OUTPUT_KINDS, nodeType)
112
117
  if (!outputs) return undefined
113
118
  const pip = sourceHandle ?? outputs.primary
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 },
@@ -344,7 +344,7 @@ const VIDEO_RATIOS_HVS = ["16:9", "9:16", "1:1"] as const
344
344
  const WAN_27_IMAGE_RATIOS = ["1:1", "16:9", "9:16", "4:3", "3:4", "21:9", "8:1", "1:8"] as const
345
345
  const VIDEO_RATIOS_HVS345 = ["16:9", "9:16", "1:1", "4:3", "3:4"] as const
346
346
  // 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
347
+ // (docs.kie.ai/market/bytedance/seedance-2); MiniMax H3 shares the same
348
348
  // seven-ratio set (t2v enum + r2v adaptive default per docs.kie.ai/market/minimax-h3).
349
349
  // Kept separate from HVS so the
350
350
  // wider set can't leak to models that don't support it.
@@ -1270,7 +1270,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1270
1270
  defaultDuration: 5,
1271
1271
  pricing: [{ identifier: "minimax", credits: 143, note: "5s, 1080p" }],
1272
1272
  },
1273
- // MiniMax Hailuo 3 (KIE "minimax-h3") — t2v / i2v (first and/or last frame) /
1273
+ // MiniMax H3 (KIE "minimax-h3") — t2v / i2v (first and/or last frame) /
1274
1274
  // reference-to-video (9 images / 3 videos ≤15s total / 3 audios ≤15s total;
1275
1275
  // audio refs require an image or video ref alongside). Two-rate resolution
1276
1276
  // lever (768P added 2026-08-03): 2K (KIE default) at 36.5 KIE cr/s, 768P at
@@ -1288,7 +1288,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1288
1288
  family: "MiniMax",
1289
1289
  label: "minimax-h3",
1290
1290
  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.",
1291
+ 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
1292
  useCases: ["premium", "narrative"],
1293
1293
  features: ["end-frame", "audio", "reference-image", "video-reference"],
1294
1294
  aspectRatios: VIDEO_RATIOS_SEEDANCE_2,
@@ -3281,6 +3281,88 @@ export interface NormalizedModelInput {
3281
3281
  adjustments: ModelInputAdjustment[]
3282
3282
  }
3283
3283
 
3284
+ /** A source image's pixel size as it is DISPLAYED (EXIF orientation applied). */
3285
+ export interface SourceImageSize {
3286
+ width: number
3287
+ height: number
3288
+ }
3289
+
3290
+ /** What a request knows beyond its own levers. */
3291
+ export interface ModelInputContext {
3292
+ /**
3293
+ * The image an image-to-image or edit request transforms. Only read to
3294
+ * resolve "auto" on a model without a native auto; absent or unusable means
3295
+ * the size is unknown and "auto" snaps the way it always has.
3296
+ */
3297
+ sourceImage?: SourceImageSize
3298
+ }
3299
+
3300
+ /** True for the "auto" aspect token in any case or padding. */
3301
+ export function isAutoAspectToken(value: unknown): boolean {
3302
+ return typeof value === "string" && value.trim().toLowerCase() === "auto"
3303
+ }
3304
+
3305
+ function usableSize(size: SourceImageSize | undefined): size is SourceImageSize {
3306
+ return (
3307
+ size !== undefined &&
3308
+ Number.isFinite(size.width) && size.width > 0 &&
3309
+ Number.isFinite(size.height) && size.height > 0
3310
+ )
3311
+ }
3312
+
3313
+ /**
3314
+ * Log-space distances closer than this are a tie. Mirror pairs that are
3315
+ * mathematically equidistant (4:3 and 3:4 from a square) differ in the last
3316
+ * bit once `Math.log` rounds them, so an exact comparison would let rounding,
3317
+ * not the catalog's order, pick between them. Real catalog ratios sit at least
3318
+ * ~1e-2 apart, far above this.
3319
+ *
3320
+ * Source-size path ONLY. The ratio-TOKEN fit (`nearestAspectRatio` behind
3321
+ * `fitAspectRatioToModel`) keeps its strict comparison on purpose: it mirrors
3322
+ * the video adapters' `snapAspectRatioToken` exactly (pinned by
3323
+ * `video-normalizer-totality.test.ts`), and a request must snap to one ratio
3324
+ * whichever door it came through.
3325
+ */
3326
+ const ASPECT_TIE_EPSILON = 1e-9
3327
+
3328
+ /**
3329
+ * The ratio in `ratios` nearest a `sourceWidth` x `sourceHeight` image:
3330
+ * minimises |ln(w/h) - ln(rw/rh)|, so a portrait and its landscape mirror are
3331
+ * equally far from a square. Entries that are not ratios ("auto", "adaptive",
3332
+ * "match_input_image") are skipped, and a tie goes to the ratio listed first
3333
+ * (`ASPECT_TIE_EPSILON`). `undefined` for unusable dimensions or a list
3334
+ * without a single ratio.
3335
+ */
3336
+ export function nearestCatalogAspectRatio(
3337
+ sourceWidth: number,
3338
+ sourceHeight: number,
3339
+ ratios: readonly string[],
3340
+ ): string | undefined {
3341
+ if (!usableSize({ width: sourceWidth, height: sourceHeight })) return undefined
3342
+ const target = Math.log(sourceWidth / sourceHeight)
3343
+ let best: string | undefined
3344
+ let bestDist = Infinity
3345
+ for (const ratio of ratios) {
3346
+ const [rw, rh] = ratio.split(":").map(Number)
3347
+ if (!rw || !rh || rw < 0 || rh < 0) continue
3348
+ const dist = Math.abs(Math.log(rw / rh) - target)
3349
+ if (dist < bestDist - ASPECT_TIE_EPSILON) { bestDist = dist; best = ratio }
3350
+ }
3351
+ return best
3352
+ }
3353
+
3354
+ /**
3355
+ * True when `aspectRatio` is "auto" and `modelId`'s catalog ratio list does not
3356
+ * carry "auto" — the one case where the source image's size decides the ratio.
3357
+ * A caller that has to fetch the size asks this first, so a request that will
3358
+ * not use it never pays for the read.
3359
+ */
3360
+ export function autoAspectNeedsSourceImage(modelId: string | undefined, aspectRatio: unknown): boolean {
3361
+ if (!modelId || !isAutoAspectToken(aspectRatio)) return false
3362
+ const ratios = MODEL_CATALOG[modelId]?.aspectRatios
3363
+ return ratios !== undefined && ratios.length > 0 && !ratios.some(isAutoAspectToken)
3364
+ }
3365
+
3284
3366
  /**
3285
3367
  * Coerce a model's parameters into a combination the model actually accepts.
3286
3368
  *
@@ -3295,6 +3377,10 @@ export interface NormalizedModelInput {
3295
3377
  *
3296
3378
  * Rules, mirroring the config panels' provider-change snap:
3297
3379
  * - Model has no such lever → drop the value (sending it 400s upstream).
3380
+ * - "auto" on a model whose list lacks it, with a known `context.sourceImage`
3381
+ * → the listed ratio nearest the source's shape (`nearestCatalogAspectRatio`).
3382
+ * "auto" asks to keep the source photo's shape; the first listed ratio
3383
+ * would reframe every source of another shape.
3298
3384
  * - Value outside the model's allow-list → snap to the model's default
3299
3385
  * (`defaultResolutionFor`) or the first valid option.
3300
3386
  * - Then apply cross-field constraints that only hold for certain models.
@@ -3313,6 +3399,7 @@ export function normalizeModelInput(
3313
3399
  quality?: string
3314
3400
  duration?: number
3315
3401
  },
3402
+ context: ModelInputContext = {},
3316
3403
  ): NormalizedModelInput {
3317
3404
  const m = MODEL_CATALOG[modelId]
3318
3405
  const adjustments: ModelInputAdjustment[] = []
@@ -3355,7 +3442,22 @@ export function normalizeModelInput(
3355
3442
  return next
3356
3443
  }
3357
3444
 
3358
- out.aspectRatio = snap("aspectRatio", input.aspectRatio, m.aspectRatios)
3445
+ const sourceRatio =
3446
+ autoAspectNeedsSourceImage(modelId, input.aspectRatio) && usableSize(context.sourceImage)
3447
+ ? nearestCatalogAspectRatio(context.sourceImage.width, context.sourceImage.height, m.aspectRatios ?? [])
3448
+ : undefined
3449
+ if (sourceRatio !== undefined && input.aspectRatio !== undefined) {
3450
+ const { width, height } = context.sourceImage!
3451
+ adjustments.push({
3452
+ field: "aspectRatio",
3453
+ from: input.aspectRatio,
3454
+ to: sourceRatio,
3455
+ reason: `${m.label} has no "auto" aspect ratio — using "${sourceRatio}", the supported ratio closest to the source image's shape (${width}x${height}).`,
3456
+ })
3457
+ out.aspectRatio = sourceRatio
3458
+ } else {
3459
+ out.aspectRatio = snap("aspectRatio", input.aspectRatio, m.aspectRatios)
3460
+ }
3359
3461
  out.resolution = snap(
3360
3462
  "resolution",
3361
3463
  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
@@ -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>`)
@@ -386,6 +386,10 @@ export const FAN_IN_TARGETS: Readonly<Record<string, "*" | readonly string[]>> =
386
386
  "merge-lists": "*",
387
387
  "sort-list": "*",
388
388
  selector: "*",
389
+ // Speaker Frames on a clip pack (P3-24 (a), decided 2026-10-06): ONE run over
390
+ // the union of the clips' spans — the pack's EDLs fold onto its `edl` wire
391
+ // instead of running one detection job (and one minimum charge) per clip.
392
+ "speaker-frames": ["edl"],
389
393
  }
390
394
 
391
395
  export function isFanInNodeType(nodeType: string | undefined | null): boolean {
@@ -27,6 +27,21 @@ export type RenderClockSource = "input" | "output-json"
27
27
  * on as one (Add Captions, the word-timing preflight). */
28
28
  export type RenderJsonKind = "transcript" | "edl"
29
29
 
30
+ /** Where a render's wired transcript, remapped through its cut, comes out
31
+ * (Apply EDL's on its `json`; Speaker View's on its own `transcript` pip,
32
+ * decided 2026-10-08). */
33
+ export interface RenderTranscriptOutput {
34
+ /** The output pip — also the key it rides on the job's `output_data` and on
35
+ * a run's node output. */
36
+ readonly handle: string
37
+ /** The saved node-data field that holds it (the landed take's). */
38
+ readonly dataField: string
39
+ }
40
+
41
+ /** The pip a render's `json` output (its `jsonKind`) comes out on, and its key
42
+ * on the job's `output_data`. */
43
+ export const RENDER_JSON_HANDLE = "json"
44
+
30
45
  export interface RenderNodeDescriptor {
31
46
  /** The medium the render's order asks for (its node data, or its job's
32
47
  * `input_data`) — before any output exists to say. */
@@ -42,6 +57,9 @@ export interface RenderNodeDescriptor {
42
57
  * (TA6, decided 2026-10-04). */
43
58
  readonly latestBatch: boolean
44
59
  readonly jsonKind: RenderJsonKind
60
+ /** Where its remapped transcript comes out. On the `json` pip exactly when
61
+ * `jsonKind` is `transcript` (a guard test holds the two together). */
62
+ readonly transcriptOutput: RenderTranscriptOutput
45
63
  }
46
64
 
47
65
  type Data = Readonly<Record<string, unknown>>
@@ -49,7 +67,8 @@ type Data = Readonly<Record<string, unknown>>
49
67
  /** Its `output` setting, video when absent. */
50
68
  const outputSettingMedium = (data: Data): RenderMedium => (data.output === "audio" ? "audio" : "video")
51
69
 
52
- const descriptor = (d: RenderNodeDescriptor): RenderNodeDescriptor => Object.freeze({ ...d })
70
+ const descriptor = (d: RenderNodeDescriptor): RenderNodeDescriptor =>
71
+ Object.freeze({ ...d, transcriptOutput: Object.freeze({ ...d.transcriptOutput }) })
53
72
 
54
73
  export const RENDER_NODE_TYPES: Readonly<Record<string, RenderNodeDescriptor>> = Object.freeze({
55
74
  "apply-edl": descriptor({
@@ -59,10 +78,13 @@ export const RENDER_NODE_TYPES: Readonly<Record<string, RenderNodeDescriptor>> =
59
78
  ownerOnlyListing: true,
60
79
  latestBatch: true,
61
80
  jsonKind: "transcript",
81
+ transcriptOutput: { handle: RENDER_JSON_HANDLE, dataField: "generatedJson" },
62
82
  }),
63
83
  // Speaker View (C3.2): video only; its `json` is the EDL as it drew it (the
64
84
  // turns split, the layouts written), so a player maps the output clock
65
- // through THAT, and Add Captions never takes it for a Transcript.
85
+ // through THAT, and Add Captions never takes it for a Transcript. The wired
86
+ // transcript, remapped through that same drawn edit, comes out on its own
87
+ // `transcript` pip (decided 2026-10-08) — what a caption step reads.
66
88
  "speaker-view": descriptor({
67
89
  mediumOf: () => "video",
68
90
  creditId: (quality) => speakerViewCreditId(quality),
@@ -70,6 +92,7 @@ export const RENDER_NODE_TYPES: Readonly<Record<string, RenderNodeDescriptor>> =
70
92
  ownerOnlyListing: true,
71
93
  latestBatch: true,
72
94
  jsonKind: "edl",
95
+ transcriptOutput: { handle: "transcript", dataField: "generatedTranscript" },
73
96
  }),
74
97
  })
75
98
 
@@ -97,6 +120,39 @@ export function rendersTranscriptJson(type: unknown): boolean {
97
120
  return renderNodeOf(type)?.jsonKind === "transcript"
98
121
  }
99
122
 
123
+ /** Where a render's remapped transcript comes out; `undefined` for any other
124
+ * node type. */
125
+ export function renderTranscriptOutputOf(type: unknown): RenderTranscriptOutput | undefined {
126
+ return renderNodeOf(type)?.transcriptOutput
127
+ }
128
+
129
+ /** Is `handle` one of a render's data pips — its `json` or its transcript —
130
+ * rather than its media? Every other pip of a render (the default included)
131
+ * is the rendered media. `false` for any other node type. */
132
+ export function isRenderDataHandle(type: unknown, handle: unknown): boolean {
133
+ const d = renderNodeOf(type)
134
+ if (!d || typeof handle !== "string") return false
135
+ return handle === RENDER_JSON_HANDLE || handle === d.transcriptOutput.handle
136
+ }
137
+
138
+ /** One json output a render lands on its node: its key on the job's
139
+ * `output_data` (and on a run's node output) and its saved node-data field. */
140
+ export interface RenderSavedJsonOutput {
141
+ readonly outputKey: string
142
+ readonly dataField: string
143
+ }
144
+
145
+ /** The json outputs a render lands on its node, `json` first, each once — what
146
+ * every lane that lands a take (or picks one) writes or restores. Empty for
147
+ * any other node type. */
148
+ export function renderSavedJsonOutputs(type: unknown): readonly RenderSavedJsonOutput[] {
149
+ const d = renderNodeOf(type)
150
+ if (!d) return []
151
+ const json: RenderSavedJsonOutput = { outputKey: RENDER_JSON_HANDLE, dataField: "generatedJson" }
152
+ const t = d.transcriptOutput
153
+ return t.handle === RENDER_JSON_HANDLE ? [json] : [json, { outputKey: t.handle, dataField: t.dataField }]
154
+ }
155
+
100
156
  /** The render job types that list in their owner's own views only. */
101
157
  export const OWNER_ONLY_LISTING_RENDER_TYPES: readonly string[] = Object.freeze(
102
158
  RENDER_NODE_TYPE_IDS.filter((t) => RENDER_NODE_TYPES[t]!.ownerOnlyListing),
@@ -3,7 +3,7 @@ import {
3
3
  transcribeLaneSupportsWordTimestamps,
4
4
  transcribeProvidersWithWordTimestamps,
5
5
  } from "./model-constants.js"
6
- import { rendersTranscriptJson } from "./render-nodes.js"
6
+ import { renderTranscriptOutputOf } from "./render-nodes.js"
7
7
 
8
8
  /**
9
9
  * Pre-run checks for the transcribe → captions chain.
@@ -47,14 +47,12 @@ export interface WordlessTranscriptFeed {
47
47
  // Handle ids (generated map: backend/src/lib/mcp/generated/node-handles.ts).
48
48
  const TRANSCRIBE_JSON_OUT = "json"
49
49
  const TRANSCRIPT_IN = "transcript"
50
- /** A render's `json` output — handed on as a Transcript only by a render whose
51
- * `jsonKind` is `transcript` (Apply EDL's is; an EDL-emitting render's is not). */
52
- const RENDER_JSON_OUT = "json"
53
50
 
54
51
  /**
55
52
  * Every transcribe node on a word-INCAPABLE lane whose `json` output reaches an
56
53
  * add-captions `transcript` input — directly, or through apply-edl, which remaps
57
- * the transcript and re-emits it on its own `json` handle. add-captions rejects a
54
+ * the transcript and re-emits it on its own `json` handle (or any render, by
55
+ * its registry `transcriptOutput`: Speaker View's `transcript`). add-captions rejects a
58
56
  * transcript with no words, so such a run can only fail, after paying for the
59
57
  * transcription. Skipped nodes are ignored on both ends.
60
58
  *
@@ -77,8 +75,8 @@ export function findWordlessTranscriptFeeds(
77
75
  const refusal = transcribeWordTimestampsRefusal(provider)
78
76
  if (!refusal) continue
79
77
 
80
- // Walk the transcript's path: transcribe.json → [render.transcript → render.json]* → add-captions.transcript,
81
- // through every render whose json is a Transcript (RENDER_NODE_TYPES jsonKind)
78
+ // Walk the transcript's path: transcribe.json → [render.transcript → its transcript output]* → add-captions.transcript,
79
+ // out of every render on the pip its registry names (RENDER_NODE_TYPES transcriptOutput)
82
80
  const seen = new Set<string>()
83
81
  const frontier: Array<{ id: string; outHandle: string }> = [{ id: node.id, outHandle: TRANSCRIBE_JSON_OUT }]
84
82
  while (frontier.length > 0) {
@@ -94,9 +92,12 @@ export function findWordlessTranscriptFeeds(
94
92
  provider,
95
93
  message: `Captions need word timings, but ${refusal}.`,
96
94
  })
97
- } else if (rendersTranscriptJson(target!.type) && !seen.has(target!.id)) {
98
- seen.add(target!.id)
99
- frontier.push({ id: target!.id, outHandle: RENDER_JSON_OUT })
95
+ } else if (!seen.has(target!.id)) {
96
+ const remapped = renderTranscriptOutputOf(target!.type)
97
+ if (remapped) {
98
+ seen.add(target!.id)
99
+ frontier.push({ id: target!.id, outHandle: remapped.handle })
100
+ }
100
101
  }
101
102
  }
102
103
  }