@nodaro/shared 3.25.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.
Files changed (45) hide show
  1. package/dist/index.cjs +778 -169
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +427 -75
  4. package/dist/index.d.ts +427 -75
  5. package/dist/index.js +749 -170
  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__/condition-variables.test.ts +12 -0
  12. package/src/__tests__/content-recipe-ideas.test.ts +9 -4
  13. package/src/__tests__/credit-identifiers.test.ts +12 -0
  14. package/src/__tests__/edl.test.ts +319 -4
  15. package/src/__tests__/image-model-roles.test.ts +57 -0
  16. package/src/__tests__/image-ref-limit.test.ts +1 -0
  17. package/src/__tests__/json-kinds.test.ts +11 -1
  18. package/src/__tests__/llm-models.test.ts +253 -42
  19. package/src/__tests__/lone-media-url.test.ts +78 -0
  20. package/src/__tests__/prompt-length-limits.test.ts +2 -0
  21. package/src/__tests__/render-nodes.test.ts +46 -1
  22. package/src/__tests__/transcribe-preflight.test.ts +5 -0
  23. package/src/camera-switch-contract.ts +9 -6
  24. package/src/collections.ts +72 -2
  25. package/src/condition-variables.ts +3 -1
  26. package/src/content-recipe-ideas.ts +5 -2
  27. package/src/credit-identifiers.ts +56 -13
  28. package/src/edl.ts +143 -23
  29. package/src/fan-out-rows.ts +1 -1
  30. package/src/i18n/camera-format.ko.ts +3 -3
  31. package/src/image-model-roles.ts +62 -0
  32. package/src/index.ts +42 -0
  33. package/src/json-kinds.ts +11 -6
  34. package/src/llm-models.ts +434 -24
  35. package/src/lone-media-url.ts +57 -0
  36. package/src/model-catalog.ts +145 -9
  37. package/src/model-constants.ts +13 -2
  38. package/src/node-default-mappings.ts +3 -0
  39. package/src/node-runtime-keys.ts +3 -0
  40. package/src/normalize-node-params.ts +47 -4
  41. package/src/pipeline-types.ts +16 -3
  42. package/src/producer-types.ts +4 -0
  43. package/src/render-nodes.ts +58 -2
  44. package/src/settings-input.ts +2 -1
  45. package/src/transcribe-preflight.ts +11 -10
@@ -2,6 +2,8 @@ import {
2
2
  LLM_MODELS,
3
3
  LLM_MODEL_IDS,
4
4
  LLM_FEATURE_DEFAULTS,
5
+ LLM_FEATURE_DEFAULT_EFFORTS,
6
+ defaultReasoningEffort,
5
7
  STRUCTURED_VISION_MODELS,
6
8
  LLM_REASONING_EFFORTS,
7
9
  getLlmModel,
@@ -20,9 +22,12 @@ import {
20
22
  orderedLlmModels,
21
23
  REASONING_OUTPUT_FLOOR,
22
24
  reasoningOutputFloor,
25
+ llmServesDirect,
26
+ llmTierCreditIds,
27
+ LLM_CREDIT_RUNGS,
23
28
  } from "../llm-models.js"
24
29
  import type { LlmModelDef, LlmTier, LlmFeature } from "../llm-models.js"
25
- import { PIPELINE_PINNABLE_SCRIPT_LLMS } from "../pipeline-types.js"
30
+ import { PIPELINE_ACCEPTED_SCRIPT_LLMS, PIPELINE_LEGACY_PINNED_SCRIPT_LLMS, PIPELINE_PINNABLE_SCRIPT_LLMS, PipelineConfigSchema } from "../pipeline-types.js"
26
31
 
27
32
  // The provider-$ per-token rate table and `calculateLlmCost` moved to
28
33
  // backend/src/lib/pricing/llm-cost.ts (S5) — its tests live in
@@ -39,6 +44,7 @@ const EXPECTED_MODEL_IDS = [
39
44
  "gemini-3.7-flash",
40
45
  "gemini-3.8-flash",
41
46
  "claude-haiku-4.5",
47
+ "claude-haiku-5.5",
42
48
  "claude-sonnet-4.6",
43
49
  "gpt-5.2",
44
50
  "gemini-3.1-pro",
@@ -49,11 +55,19 @@ const EXPECTED_MODEL_IDS = [
49
55
  "gpt-5.6-terra",
50
56
  "gpt-5.6-sol",
51
57
  "gpt-6-astra",
58
+ "gpt-6-luna",
59
+ "gpt-6-sol",
60
+ "gpt-6.1-sol",
52
61
  "grok-4.6",
62
+ "grok-4.7",
53
63
  "claude-sonnet-5",
64
+ "claude-sonnet-5.5",
54
65
  "claude-opus-4.8",
55
66
  "claude-opus-5",
67
+ "claude-opus-5.5",
56
68
  "claude-fable-5",
69
+ "kimi-k3",
70
+ "deepseek-v4.1-flash",
57
71
  ]
58
72
 
59
73
  // ---------------------------------------------------------------------------
@@ -98,14 +112,14 @@ describe("LLM_MODELS data integrity", () => {
98
112
  expect(new Set(ids).size).toBe(ids.length)
99
113
  })
100
114
 
101
- it("has 6 economy, 5 standard, 9 premium models", () => {
115
+ it("has 8 economy, 7 standard, 13 premium models", () => {
102
116
  const tierCounts: Record<LlmTier, number> = { economy: 0, standard: 0, premium: 0 }
103
117
  for (const model of LLM_MODELS) {
104
118
  tierCounts[model.tier]++
105
119
  }
106
- expect(tierCounts.economy).toBe(6)
107
- expect(tierCounts.standard).toBe(5)
108
- expect(tierCounts.premium).toBe(9)
120
+ expect(tierCounts.economy).toBe(9)
121
+ expect(tierCounts.standard).toBe(7)
122
+ expect(tierCounts.premium).toBe(13)
109
123
  })
110
124
 
111
125
  it("all three kieFormats are represented", () => {
@@ -115,8 +129,9 @@ describe("LLM_MODELS data integrity", () => {
115
129
  expect(formats).toContain("responses")
116
130
  })
117
131
 
118
- it("all four vendors are represented", () => {
132
+ it("every vendor in LLM_VENDOR_ORDER is represented", () => {
119
133
  const vendors = new Set(LLM_MODELS.map((m) => m.vendor))
134
+ for (const v of LLM_VENDOR_ORDER) expect(vendors).toContain(v)
120
135
  expect(vendors).toContain("anthropic")
121
136
  expect(vendors).toContain("google")
122
137
  expect(vendors).toContain("openai")
@@ -163,12 +178,24 @@ describe("getLlmModel", () => {
163
178
  expect(getLlmModel("claude-haiku-4-5")?.id).toBe("claude-haiku-4.5")
164
179
  })
165
180
 
166
- it("resolves every PIPELINE_PINNABLE_SCRIPT_LLMS member (the film pipeline's pin surface)", () => {
167
- for (const id of PIPELINE_PINNABLE_SCRIPT_LLMS) {
181
+ it("resolves every script LLM a pipeline config may name (the film pipeline's pin surface)", () => {
182
+ for (const id of PIPELINE_ACCEPTED_SCRIPT_LLMS) {
168
183
  expect(getLlmModel(id), `pinnable script llm ${id} must resolve`).toBeDefined()
169
184
  }
170
185
  })
171
186
 
187
+ it("Claude Haiku 5.5 is the offered Haiku pin; a saved Haiku 4.5 pin is still accepted", () => {
188
+ expect(PIPELINE_PINNABLE_SCRIPT_LLMS).toContain("claude-haiku-5-5")
189
+ expect(PIPELINE_PINNABLE_SCRIPT_LLMS).not.toContain("claude-haiku-4-5")
190
+ expect(PIPELINE_LEGACY_PINNED_SCRIPT_LLMS).toEqual(["claude-haiku-4-5"])
191
+ expect(getLlmModel("claude-haiku-5-5")?.id).toBe("claude-haiku-5.5")
192
+ for (const id of ["claude-haiku-5-5", "claude-haiku-4-5"] as const) {
193
+ expect(PipelineConfigSchema.safeParse({ script_llm: id }).success, id).toBe(true)
194
+ expect(PipelineConfigSchema.safeParse({ stage_models: { script_llm: id } }).success, `stage ${id}`).toBe(true)
195
+ }
196
+ expect(PipelineConfigSchema.safeParse({ script_llm: "claude-haiku-3" }).success).toBe(false)
197
+ })
198
+
172
199
  it("resolves provider slugs as historical aliases", () => {
173
200
  const dated = LLM_MODELS.find((m) => m.directFallbackModel && m.directFallbackModel !== m.id)
174
201
  if (dated) expect(getLlmModel(dated.directFallbackModel!)?.id).toBe(dated.id)
@@ -227,6 +254,7 @@ describe("getLlmTier", () => {
227
254
  it.each([
228
255
  ["gemini-3-flash", "economy"],
229
256
  ["claude-haiku-4.5", "economy"],
257
+ ["claude-haiku-5.5", "economy"],
230
258
  ] as const)("%s -> %s", (id, expected) => {
231
259
  expect(getLlmTier(id)).toBe(expected)
232
260
  })
@@ -429,11 +457,11 @@ describe("LLM_FEATURE_DEFAULTS", () => {
429
457
  expect(getLlmTier(LLM_FEATURE_DEFAULTS["ai-writer"])).toBe("standard")
430
458
  })
431
459
 
432
- it('"describe-to-picker" defaults to "claude-opus-5" (premium vision)', () => {
433
- expect(LLM_FEATURE_DEFAULTS["describe-to-picker"]).toBe("claude-opus-5")
460
+ it('"describe-to-picker" defaults to "claude-opus-5.5" (premium vision)', () => {
461
+ expect(LLM_FEATURE_DEFAULTS["describe-to-picker"]).toBe("claude-opus-5.5")
434
462
  expect(getLlmTier(LLM_FEATURE_DEFAULTS["describe-to-picker"])).toBe("premium")
435
463
  // The default MUST be an accepted analyzer model (vision + structured output).
436
- expect(STRUCTURED_VISION_MODELS.map((m) => m.id)).toContain("claude-opus-5")
464
+ expect(STRUCTURED_VISION_MODELS.map((m) => m.id)).toContain("claude-opus-5.5")
437
465
  })
438
466
 
439
467
  it('"generate-script" defaults to "gemini-3.6-flash" (economy)', () => {
@@ -464,6 +492,52 @@ describe("LLM_FEATURE_DEFAULTS", () => {
464
492
  })
465
493
  })
466
494
 
495
+ // ---------------------------------------------------------------------------
496
+ // defaultReasoningEffort — a feature's default effort rides its default model
497
+ // ---------------------------------------------------------------------------
498
+ describe("defaultReasoningEffort", () => {
499
+ it('"describe-to-picker" runs at "high" on its default model, named or omitted (decided 2026-10-09)', () => {
500
+ expect(defaultReasoningEffort("describe-to-picker", undefined)).toBe("high")
501
+ expect(defaultReasoningEffort("describe-to-picker", "claude-opus-5.5")).toBe("high")
502
+ // An unset model in node data can be "" — the same "use the default" the
503
+ // `llmModel || LLM_FEATURE_DEFAULTS[…]` reads give it.
504
+ expect(defaultReasoningEffort("describe-to-picker", "")).toBe("high")
505
+ })
506
+
507
+ it("names the default model by any of its accepted ids", () => {
508
+ // The dash alias getLlmModel resolves to the canonical claude-opus-5.5.
509
+ expect(defaultReasoningEffort("describe-to-picker", "claude-opus-5-5")).toBe("high")
510
+ })
511
+
512
+ it("a caller who picked another model and no effort keeps that model's Auto", () => {
513
+ expect(defaultReasoningEffort("describe-to-picker", "gemini-3.8-flash")).toBeUndefined()
514
+ expect(defaultReasoningEffort("describe-to-picker", "claude-opus-5")).toBeUndefined()
515
+ })
516
+
517
+ it("a feature with no default effort, or an unknown feature, has none", () => {
518
+ expect(defaultReasoningEffort("llm-chat", undefined)).toBeUndefined()
519
+ expect(defaultReasoningEffort("llm-chat", LLM_FEATURE_DEFAULTS["llm-chat"])).toBeUndefined()
520
+ expect(defaultReasoningEffort("no-such-feature", undefined)).toBeUndefined()
521
+ })
522
+
523
+ it("every declared default effort is a level its default model offers, on the aggregator lane and direct", () => {
524
+ // The effort pickers show this level as selected — one the model does not
525
+ // offer would leave them blank (and the quick strip's fail-safe snapping).
526
+ for (const [feature, effort] of Object.entries(LLM_FEATURE_DEFAULT_EFFORTS)) {
527
+ const model = LLM_FEATURE_DEFAULTS[feature as LlmFeature]
528
+ expect(availableReasoningEfforts(model), feature).toContain(effort)
529
+ expect(availableReasoningEfforts(model, true), feature).toContain(effort)
530
+ }
531
+ })
532
+
533
+ it("the describe-to-picker default runs and bills direct: Opus 5.5's effort only works on Anthropic's API", () => {
534
+ const model = LLM_FEATURE_DEFAULTS["describe-to-picker"]
535
+ const effort = defaultReasoningEffort("describe-to-picker", model)
536
+ expect(llmServesDirect(model, effort)).toBe(true)
537
+ expect(buildLlmCreditIdentifier("describe-to-picker", model, effort)).toBe("describe-to-picker:premium-direct")
538
+ })
539
+ })
540
+
467
541
  // ---------------------------------------------------------------------------
468
542
  // motionGraphicsFeature
469
543
  // ---------------------------------------------------------------------------
@@ -488,6 +562,8 @@ describe("STRUCTURED_VISION_MODELS", () => {
488
562
  expect(ids).toEqual(
489
563
  [
490
564
  "claude-haiku-4.5",
565
+ // Vision + a forced tool both live-probed 2026-10-10 (KIE and direct).
566
+ "claude-haiku-5.5",
491
567
  "claude-opus-4.7",
492
568
  "claude-sonnet-4.6",
493
569
  "gemini-3-flash",
@@ -511,6 +587,16 @@ describe("STRUCTURED_VISION_MODELS", () => {
511
587
  "gpt-6-astra",
512
588
  // responses-format Grok — vision + text.format live-verified 2026-08-18.
513
589
  "grok-4.6",
590
+ // 2026-10-08 additions — vision (data URI) + text.format json_schema
591
+ // live-probed per model; the two Claude 5.5s via auto + strict tool.
592
+ "gpt-6-luna",
593
+ "gpt-6-sol",
594
+ "gpt-6.1-sol",
595
+ "grok-4.7",
596
+ "claude-sonnet-5.5",
597
+ "claude-opus-5.5",
598
+ "kimi-k3",
599
+ "deepseek-v4.1-flash",
514
600
  ].sort(),
515
601
  )
516
602
  })
@@ -575,6 +661,41 @@ describe("reasoning effort registry", () => {
575
661
  expect(m?.thinkingDefaultOn).toBe(true)
576
662
  })
577
663
 
664
+ it("claude-haiku-5.5 is the economy Claude with an effort ladder that reasons by default", () => {
665
+ const m = getLlmModel("claude-haiku-5.5")!
666
+ expect(m.tier).toBe("economy")
667
+ expect(m.kieFormat).toBe("messages")
668
+ expect(m.kieSlugOrModel).toBe("claude-haiku-5-5")
669
+ expect(m.directFallbackModel).toBe("claude-haiku-5-5")
670
+ expect(m.reasoningEfforts).toEqual(["low", "medium", "high", "xhigh", "max"])
671
+ expect(m.effortRequiresDirect).toBe(true)
672
+ expect(m.preferKie).toBe(true)
673
+ // Anthropic 400s `temperature` on this model (probed 2026-10-10).
674
+ expect(m.supportsTemperature).toBe(false)
675
+ // Load-bearing: measured 2026-10-10, a no-effort call spent ~2,000 output
676
+ // tokens on a ~350-token answer on BOTH lanes. Unflagged, a node's small
677
+ // cap (qa-check's 1,024) is eaten by reasoning and the answer is cut.
678
+ expect(m.thinkingDefaultOn).toBe(true)
679
+ expect(reasoningOutputFloor(m)).toBe(REASONING_OUTPUT_FLOOR)
680
+ expect(getLlmModalityCaps(m.id)).toEqual({ image: true, video: false, audio: false })
681
+ // Haiku 4.5 stays as it was: no ladder, no default reasoning, its own cap.
682
+ const old = getLlmModel("claude-haiku-4.5")!
683
+ expect(old.reasoningEfforts).toBeUndefined()
684
+ expect(old.thinkingDefaultOn).toBeUndefined()
685
+ expect(old.maxOutputTokens).toBe(8192)
686
+ })
687
+
688
+ it("every model whose thinking cannot be turned off carries thinkingDefaultOn", () => {
689
+ // Vendor docs: Claude Fable 5 always has thinking enabled, and Claude Opus
690
+ // 5.5 rejects `disabled` at every effort. Nothing in the registry says
691
+ // "cannot be turned off", so the list is pinned here. Consumers floor
692
+ // max_tokens off this flag; unflagged, such a model's reasoning shares the
693
+ // plain 16384 cap with its answer on every call.
694
+ for (const id of ["claude-fable-5", "claude-opus-5.5"]) {
695
+ expect(getLlmModel(id)?.thinkingDefaultOn, id).toBe(true)
696
+ }
697
+ })
698
+
578
699
  it("thinkingDefaultOn is set only where the vendor default actually reasons", () => {
579
700
  // Opus 4.8 / 4.7 and Sonnet 5 do NOT reason when `thinking` is omitted —
580
701
  // flagging them would inflate every call's cap for no reason.
@@ -821,11 +942,15 @@ describe("buildLlmCreditIdentifier effort bump (xhigh/max only)", () => {
821
942
  it("premium + max stays premium", () => {
822
943
  expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.6-sol", "max")).toBe("llm-chat:premium")
823
944
  })
824
- it("high never bumps", () => {
825
- expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5", "high")).toBe("llm-chat")
945
+ it("high never bumps for the effort itself", () => {
946
+ // A model whose effort works on the aggregator: no bump at all.
947
+ expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.6-terra", "high")).toBe("llm-chat")
948
+ // Claude: `high` adds no EFFORT bump, but any effort runs direct (+1 rung).
949
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5", "high")).toBe("llm-chat:premium")
826
950
  })
827
- it("clamp on a partial-list standard model never bumps (sonnet-4.6 @ xhigh → high)", () => {
828
- expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-4.6", "xhigh")).toBe("llm-chat")
951
+ it("clamp on a partial-list standard model never bumps for effort (sonnet-4.6 @ xhigh → high)", () => {
952
+ // Clamped to `high`: no effort bump; the direct bump alone lands premium.
953
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-4.6", "xhigh")).toBe("llm-chat:premium")
829
954
  })
830
955
  it("bump uses the CLAMPED effort (xhigh on a low/medium/high model clamps to high → no bump)", () => {
831
956
  expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.4", "xhigh")).toBe("llm-chat:premium")
@@ -881,9 +1006,9 @@ describe("direct-vendor lane declarations", () => {
881
1006
  })
882
1007
 
883
1008
  describe("advanced mode", () => {
884
- it("is available exactly on models with a direct Gemini lane", () => {
1009
+ it("is available exactly on models with a direct lane (Gemini or Anthropic)", () => {
885
1010
  for (const m of LLM_MODELS) {
886
- expect(supportsAdvancedMode(m.id), m.id).toBe(Boolean(m.directGeminiModel))
1011
+ expect(supportsAdvancedMode(m.id), m.id).toBe(Boolean(m.directGeminiModel || m.directFallbackModel))
887
1012
  }
888
1013
  })
889
1014
 
@@ -912,35 +1037,38 @@ describe("advanced mode", () => {
912
1037
  }
913
1038
  })
914
1039
 
915
- it("no advanced-capable model declares xhigh/max — the UI copy depends on it", () => {
916
- // `EFFORT_LABELS` in reasoning-effort-select.tsx labels xhigh/max "may bill
917
- // one tier up" and its comment explains that the effort bump and the
918
- // advanced bump can never both apply, because Advanced is Gemini-only and
919
- // no Gemini model reaches xhigh/max. That was a note asking a future reader
920
- // to remember; this is the check that fails instead.
921
- //
922
- // If this ever goes red, the two bumps CAN stack: reword the labels to say
923
- // so and revisit whether a double bump is the price we want.
924
- for (const m of LLM_MODELS) {
925
- if (!supportsAdvancedMode(m.id)) continue
926
- const levels = [...(m.reasoningEfforts ?? []), ...(m.directReasoningEfforts ?? [])]
927
- expect(levels, `${m.id} can run advanced AND declares a tier-bumping effort`)
928
- .not.toEqual(expect.arrayContaining(["xhigh"]))
929
- expect(levels, `${m.id} can run advanced AND declares a tier-bumping effort`)
930
- .not.toEqual(expect.arrayContaining(["max"]))
931
- }
932
- })
933
-
934
- it("never bumps past premium", () => {
935
- expect(buildLlmCreditIdentifier("llm-chat", "gemini-3.1-pro", "max", true)).toBe("llm-chat:premium")
1040
+ it("the effort and direct bumps stack — the UI copy says so", () => {
1041
+ // `EFFORT_LABELS` (reasoning-effort-select.tsx) says xhigh/max "may bill one
1042
+ // tier up", and the Claude hint under the picker says any effort runs direct
1043
+ // and bills one tier more. Both apply to a Claude xhigh/max call (decided
1044
+ // 2026-10-08: effort = Advanced, and the two bumps stack as Advanced's did).
1045
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5.5", "low")).toBe("llm-chat:premium")
1046
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5.5", "xhigh")).toBe("llm-chat:premium-direct")
1047
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-4.5", "xhigh")).toBe("llm-chat:economy") // no ladder
1048
+ // Haiku 5.5 is the economy Claude WITH a ladder: no effort stays economy on
1049
+ // KIE, any effort runs direct (one rung), and xhigh/max stack the effort bump.
1050
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-5.5")).toBe("llm-chat:economy")
1051
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-5.5", "low")).toBe("llm-chat")
1052
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-5.5", "high")).toBe("llm-chat")
1053
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-5.5", "xhigh")).toBe("llm-chat:premium")
1054
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-5.5", "max")).toBe("llm-chat:premium")
1055
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-5.5", undefined, true)).toBe("llm-chat")
1056
+ })
1057
+
1058
+ it("a premium model served direct lands on premium-direct, and nothing goes past it", () => {
1059
+ expect(buildLlmCreditIdentifier("llm-chat", "gemini-3.1-pro", "max", true)).toBe("llm-chat:premium-direct")
1060
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-5.5", "max", true)).toBe("llm-chat:premium-direct")
1061
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-5.5", "medium")).toBe("llm-chat:premium-direct")
1062
+ // No effort, no Advanced: a premium Claude runs on the aggregator at premium.
1063
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-5.5")).toBe("llm-chat:premium")
936
1064
  })
937
1065
 
938
1066
  it("ignores the flag on a model that cannot run advanced (no silent overcharge)", () => {
939
- // gpt-5.2 has no direct lane — a stale advancedMode flag must not inflate it.
1067
+ // gpt-5.2 / kimi-k3 have no direct lane — a stale advancedMode flag must not inflate them.
940
1068
  expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.2", undefined, true))
941
1069
  .toBe(buildLlmCreditIdentifier("llm-chat", "gpt-5.2"))
942
- expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-4.7", undefined, true))
943
- .toBe(buildLlmCreditIdentifier("llm-chat", "claude-opus-4.7"))
1070
+ expect(buildLlmCreditIdentifier("llm-chat", "kimi-k3", "high", true))
1071
+ .toBe(buildLlmCreditIdentifier("llm-chat", "kimi-k3", "high"))
944
1072
  })
945
1073
 
946
1074
  it("back-compat: omitting the 4th arg is identical to before for every model", () => {
@@ -1039,7 +1167,7 @@ describe("groupLlmModelsByVendor / orderedLlmModels", () => {
1039
1167
  const groups = groupLlmModelsByVendor(LLM_MODELS.filter((m) => m.vendor === "xai"))
1040
1168
  expect(groups).toHaveLength(1)
1041
1169
  expect(groups[0].label).toBe("xAI")
1042
- expect(groups[0].models.map((m) => m.id)).toEqual(["grok-4.6"])
1170
+ expect(groups[0].models.map((m) => m.id)).toEqual(["grok-4.6", "grok-4.7"])
1043
1171
  })
1044
1172
 
1045
1173
  it("does not mutate the registry (registry order is load-bearing for LLM_MODEL_IDS)", () => {
@@ -1049,9 +1177,92 @@ describe("groupLlmModelsByVendor / orderedLlmModels", () => {
1049
1177
  expect(LLM_MODELS.map((m) => m.id)).toEqual(before)
1050
1178
  })
1051
1179
 
1180
+ it("orders the new vendors alphabetically with their labels", () => {
1181
+ expect(LLM_VENDOR_ORDER).toEqual(["anthropic", "deepseek", "google", "moonshot", "openai", "xai"])
1182
+ expect(LLM_VENDOR_LABELS.deepseek).toBe("DeepSeek")
1183
+ expect(LLM_VENDOR_LABELS.moonshot).toBe("Moonshot AI")
1184
+ })
1185
+
1052
1186
  it("orderedLlmModels is the flattened grouping", () => {
1053
1187
  expect(orderedLlmModels().map((m) => m.id)).toEqual(
1054
1188
  groupLlmModelsByVendor().flatMap((g) => g.models.map((m) => m.id)),
1055
1189
  )
1056
1190
  })
1057
1191
  })
1192
+
1193
+ // ---------------------------------------------------------------------------
1194
+ // Forced tool choice + conversation-bound thinking (Claude 5.5 generation)
1195
+ // ---------------------------------------------------------------------------
1196
+ describe("supportsForcedToolChoice / conversationBoundThinking", () => {
1197
+ it("are declared exactly on the Claude 5.5 models — Haiku 5.5 binds its thinking but still takes a forced tool", () => {
1198
+ const noForce = LLM_MODELS.filter((m) => m.supportsForcedToolChoice === false).map((m) => m.id)
1199
+ const bound = LLM_MODELS.filter((m) => m.conversationBoundThinking).map((m) => m.id)
1200
+ // Haiku 5.5 is NOT here: Anthropic's API served it a forced tool_choice
1201
+ // (probed 2026-10-10), where Sonnet 5.5 and Opus 5.5 answer 400.
1202
+ expect(noForce.sort()).toEqual(["claude-opus-5.5", "claude-sonnet-5.5"])
1203
+ expect(bound.sort()).toEqual(["claude-haiku-5.5", "claude-opus-5.5", "claude-sonnet-5.5"])
1204
+ })
1205
+
1206
+ it("only an anthropic-tool model can decline a forced tool choice (the flag has no reader elsewhere)", () => {
1207
+ for (const m of LLM_MODELS.filter((x) => x.supportsForcedToolChoice === false)) {
1208
+ expect(m.structuredOutputMode).toBe("anthropic-tool")
1209
+ }
1210
+ })
1211
+
1212
+ it("never offers `none` where the endpoint was measured to fail or override it", () => {
1213
+ expect(getLlmModel("gpt-6.1-sol")?.reasoningEfforts).not.toContain("none")
1214
+ expect(getLlmModel("grok-4.7")?.reasoningEfforts).not.toContain("none")
1215
+ })
1216
+
1217
+ // The film pipeline's callLLM (backend/src/ee/pipelines/llms/call-llm.ts) still
1218
+ // sends a FORCED tool_choice on the raw Anthropic SDK, and it is reachable only
1219
+ // through PIPELINE_PINNABLE_SCRIPT_LLMS. A model that 400s on forcing must not
1220
+ // join that list until callLLM reads `supportsForcedToolChoice`.
1221
+ it("no pipeline-pinnable script LLM rejects a forced tool choice", () => {
1222
+ for (const id of PIPELINE_ACCEPTED_SCRIPT_LLMS) {
1223
+ expect(getLlmModel(id)?.supportsForcedToolChoice, id).not.toBe(false)
1224
+ }
1225
+ })
1226
+
1227
+ it("resolves the KIE / Anthropic dash-form ids of the new models", () => {
1228
+ expect(getLlmModel("claude-opus-5-5")?.id).toBe("claude-opus-5.5")
1229
+ expect(getLlmModel("claude-sonnet-5-5")?.id).toBe("claude-sonnet-5.5")
1230
+ expect(getLlmModel("claude-haiku-5-5")?.id).toBe("claude-haiku-5.5")
1231
+ expect(getLlmModel("gpt-6-1-sol")?.id).toBe("gpt-6.1-sol")
1232
+ expect(getLlmModel("deepseek-v4-1-flash")?.id).toBe("deepseek-v4.1-flash")
1233
+ expect(getLlmModel("grok-4-7")?.id).toBe("grok-4.7")
1234
+ })
1235
+ })
1236
+
1237
+ describe("llmServesDirect (decided 2026-10-08: priced on the lane it runs on)", () => {
1238
+ it("Advanced mode serves direct on any model with a direct lane", () => {
1239
+ expect(llmServesDirect("gemini-3.6-flash", undefined, true)).toBe(true)
1240
+ expect(llmServesDirect("claude-haiku-4.5", undefined, true)).toBe(true)
1241
+ expect(llmServesDirect("gpt-6-sol", "high", true)).toBe(false)
1242
+ })
1243
+ it("an effort serves direct only where the aggregator ignores it (Claude)", () => {
1244
+ expect(llmServesDirect("claude-opus-5.5", "low")).toBe(true)
1245
+ expect(llmServesDirect("gemini-3.6-flash", "high")).toBe(false)
1246
+ expect(llmServesDirect("gpt-6-sol", "max")).toBe(false)
1247
+ // Haiku 4.5 has no effort ladder: an effort clamps to nothing, so it stays on KIE.
1248
+ expect(llmServesDirect("claude-haiku-4.5", "high")).toBe(false)
1249
+ // Haiku 5.5 has one, and KIE ignores it like every other Claude effort.
1250
+ expect(llmServesDirect("claude-haiku-5.5", "low")).toBe(true)
1251
+ })
1252
+ it("no effort and no Advanced: every model runs on the aggregator", () => {
1253
+ for (const m of LLM_MODELS) expect(llmServesDirect(m.id), m.id).toBe(false)
1254
+ })
1255
+ it("every Claude model with an effort ladder declares effortRequiresDirect, and is KIE-first", () => {
1256
+ for (const m of LLM_MODELS.filter((x) => x.vendor === "anthropic")) {
1257
+ expect(m.preferKie, m.id).toBe(true)
1258
+ expect(Boolean(m.effortRequiresDirect), m.id).toBe(Boolean(m.reasoningEfforts?.length))
1259
+ }
1260
+ })
1261
+ it("no model is direct-first any more", () => {
1262
+ expect(LLM_MODELS.filter((m) => m.preferDirect).map((m) => m.id)).toEqual([])
1263
+ })
1264
+ it("llmTierCreditIds lists the four rungs in order", () => {
1265
+ expect(llmTierCreditIds("llm-chat")).toEqual(["llm-chat:economy", "llm-chat", "llm-chat:premium", "llm-chat:premium-direct"])
1266
+ expect(LLM_CREDIT_RUNGS).toEqual(["economy", "standard", "premium", "premium-direct"])
1267
+ })
1268
+ })
@@ -0,0 +1,78 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { loneMediaUrlKind, isLoneMediaLinkSource } from "../lone-media-url.js"
3
+ import { IMAGE_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES, AUDIO_PRODUCER_TYPES, DYNAMIC_PRODUCER_TYPES } from "../producer-types.js"
4
+
5
+ describe("loneMediaUrlKind — one media link, and nothing else", () => {
6
+ it("reads the file name from the path, token or poster query included", () => {
7
+ expect(loneMediaUrlKind("https://cdn4.telesco.pe/file/abc.jpg?token=xyz")).toBe("image")
8
+ expect(loneMediaUrlKind(" https://media.nodaro.ai/images/9b1c.png \n")).toBe("image")
9
+ expect(loneMediaUrlKind("https://cdn.example/x.JPG")).toBe("image")
10
+ expect(loneMediaUrlKind("https://cdn.example/a.webp")).toBe("image")
11
+ expect(loneMediaUrlKind("https://cdn.example/a.gif")).toBe("image")
12
+ expect(loneMediaUrlKind("https://cdn4.telesco.pe/file/clip.mp4?poster=x.jpg")).toBe("video")
13
+ expect(loneMediaUrlKind("https://cdn.example/v/clip.mov")).toBe("video")
14
+ expect(loneMediaUrlKind("https://cdn.example/v/clip.webm")).toBe("video")
15
+ })
16
+
17
+ it("a page link is not a medium, even when its host or query looks like a file name", () => {
18
+ for (const link of [
19
+ "https://t.me/somechannel/123",
20
+ "https://www.movistar.es/news/ai",
21
+ "https://www.webmd.com/news/story",
22
+ "https://www.avid.com/pro-tools",
23
+ "https://www.gifs.com/trending",
24
+ "https://www.svgrepo.com/",
25
+ "https://site.com/page?img=a.png",
26
+ "https://site.com/podcast.mp3?cover=art.jpg",
27
+ "https://en.wikipedia.org/wiki/File:Example.jpg/",
28
+ ]) {
29
+ expect(loneMediaUrlKind(link), link).toBeNull()
30
+ }
31
+ })
32
+
33
+ it("a format the platforms do not post stays text", () => {
34
+ for (const link of ["https://cdn.example/a.avif", "https://cdn.example/a.heic", "https://cdn.example/a.svg", "https://cdn.example/a.bmp", "https://cdn.example/a.mp3"]) {
35
+ expect(loneMediaUrlKind(link), link).toBeNull()
36
+ }
37
+ })
38
+
39
+ it("anything that is not exactly one link is text", () => {
40
+ for (const value of [
41
+ "",
42
+ " ",
43
+ "Seedance 2 is out https://example.com/demo.png",
44
+ "https://example.com/demo.png looks amazing",
45
+ "https://a.example/x.png,https://b.example/y.png",
46
+ "https://a.example/x.png\nhttps://b.example/y.png",
47
+ '["https://a.example/x.png"]',
48
+ '{"url":"https://a.example/x.png"}',
49
+ "data:image/png;base64,iVBORw0KGgo=",
50
+ "ftp://a.example/x.png",
51
+ "cdn.example/x.png",
52
+ "https://cdn.example/x.png.",
53
+ ]) {
54
+ expect(loneMediaUrlKind(value), JSON.stringify(value)).toBeNull()
55
+ }
56
+ })
57
+ })
58
+
59
+ describe("isLoneMediaLinkSource — the sources whose wire a social post reads as text", () => {
60
+ it("covers the text-shaped nodes", () => {
61
+ for (const type of ["extract-field", "llm-chat", "combine-text", "split-text", "text-prompt", "json-process", "filter-list", "selector", "router", "collection-read", "webhook-trigger"]) {
62
+ expect(isLoneMediaLinkSource(type), type).toBe(true)
63
+ }
64
+ })
65
+
66
+ it("excludes every declared media producer, every dynamic producer, the message triggers and the entities", () => {
67
+ for (const type of [...IMAGE_PRODUCER_TYPES, ...VIDEO_PRODUCER_TYPES, ...AUDIO_PRODUCER_TYPES, ...DYNAMIC_PRODUCER_TYPES]) {
68
+ expect(isLoneMediaLinkSource(type), type).toBe(false)
69
+ }
70
+ // A Telegram message's one wire carries its caption AND its photo; the
71
+ // engines route both from the message — the wire's value is never a lone link.
72
+ for (const type of ["character", "object", "creature", "location", "face", "list", "upload-image", "generate-image", "extract-frame", "upload-video", "text-to-speech", "telegram-trigger", "telegram-account-trigger"]) {
73
+ expect(isLoneMediaLinkSource(type), type).toBe(false)
74
+ }
75
+ expect(isLoneMediaLinkSource(undefined)).toBe(false)
76
+ expect(isLoneMediaLinkSource("")).toBe(false)
77
+ })
78
+ })
@@ -54,6 +54,8 @@ describe("per-model prompt length limits", () => {
54
54
  expect(getMaxImagePromptChars("imagen4")).toBe(IMAGE_PROMPT_MAX)
55
55
  expect(getMaxImagePromptChars("seedream-5-pro")).toBe(IMAGE_PROMPT_MAX) // verified 5000 in KIE schema
56
56
  expect(getMaxImagePromptChars("seedream-5-pro-i2i")).toBe(IMAGE_PROMPT_MAX) // verified 5000 in KIE schema
57
+ expect(getMaxImagePromptChars("seedream-5-flash")).toBe(IMAGE_PROMPT_MAX) // verified 5000 in KIE schema
58
+ expect(getMaxImagePromptChars("seedream-5-flash-i2i")).toBe(IMAGE_PROMPT_MAX) // verified 5000 in KIE schema
57
59
  expect(getMaxImagePromptChars("grok-i2i")).toBe(IMAGE_PROMPT_MAX) // 390000 doc = sanity-capped
58
60
  expect(getMaxImagePromptChars("flux-kontext")).toBe(IMAGE_PROMPT_MAX) // UNVERIFIED
59
61
  expect(getMaxImagePromptChars(undefined)).toBe(IMAGE_PROMPT_MAX)
@@ -12,6 +12,10 @@ import {
12
12
  renderNodeOf,
13
13
  rendersLatestBatch,
14
14
  rendersTranscriptJson,
15
+ RENDER_JSON_HANDLE,
16
+ renderTranscriptOutputOf,
17
+ isRenderDataHandle,
18
+ renderSavedJsonOutputs,
15
19
  } from "../index.js"
16
20
 
17
21
  describe("RENDER_NODE_TYPES — one render-node registry (SV18)", () => {
@@ -85,8 +89,49 @@ describe("RENDER_NODE_TYPES — one render-node registry (SV18)", () => {
85
89
  expect(rendersTranscriptJson("transcribe")).toBe(false)
86
90
  })
87
91
 
92
+ describe("the transcript output: where a render's wired transcript, remapped through its cut, comes out (decided 2026-10-08)", () => {
93
+ it("Apply EDL's rides its `json` pip and `generatedJson`; Speaker View's its own `transcript` pip and `generatedTranscript`", () => {
94
+ expect(RENDER_JSON_HANDLE).toBe("json")
95
+ expect(renderTranscriptOutputOf("apply-edl")).toEqual({ handle: "json", dataField: "generatedJson" })
96
+ expect(renderTranscriptOutputOf("speaker-view")).toEqual({ handle: "transcript", dataField: "generatedTranscript" })
97
+ for (const t of ["camera-switch", "transcribe", "constructor", undefined, null]) expect(renderTranscriptOutputOf(t)).toBeUndefined()
98
+ })
99
+
100
+ it("a render's json is its transcript exactly when its transcript output IS the json pip — the two descriptions never disagree", () => {
101
+ for (const [t, d] of Object.entries(RENDER_NODE_TYPES)) {
102
+ const onJson = d.transcriptOutput.handle === RENDER_JSON_HANDLE
103
+ expect(d.jsonKind === "transcript", t).toBe(onJson)
104
+ expect(d.transcriptOutput.dataField === "generatedJson", t).toBe(onJson)
105
+ }
106
+ })
107
+
108
+ it("tells a render's data pips (json, transcript) from its media pip", () => {
109
+ expect(isRenderDataHandle("apply-edl", "json")).toBe(true)
110
+ expect(isRenderDataHandle("apply-edl", "media")).toBe(false)
111
+ expect(isRenderDataHandle("apply-edl", "transcript")).toBe(false)
112
+ expect(isRenderDataHandle("apply-edl", undefined)).toBe(false)
113
+ expect(isRenderDataHandle("speaker-view", "json")).toBe(true)
114
+ expect(isRenderDataHandle("speaker-view", "transcript")).toBe(true)
115
+ expect(isRenderDataHandle("speaker-view", "video")).toBe(false)
116
+ expect(isRenderDataHandle("speaker-view", null)).toBe(false)
117
+ expect(isRenderDataHandle("camera-switch", "transcript")).toBe(false)
118
+ })
119
+
120
+ it("lists the json outputs a render lands on its node, json first, each once", () => {
121
+ expect(renderSavedJsonOutputs("apply-edl")).toEqual([{ outputKey: "json", dataField: "generatedJson" }])
122
+ expect(renderSavedJsonOutputs("speaker-view")).toEqual([
123
+ { outputKey: "json", dataField: "generatedJson" },
124
+ { outputKey: "transcript", dataField: "generatedTranscript" },
125
+ ])
126
+ expect(renderSavedJsonOutputs("camera-switch")).toEqual([])
127
+ })
128
+ })
129
+
88
130
  it("is frozen: no consumer can register a render at run time", () => {
89
131
  expect(Object.isFrozen(RENDER_NODE_TYPES)).toBe(true)
90
- for (const d of Object.values(RENDER_NODE_TYPES)) expect(Object.isFrozen(d)).toBe(true)
132
+ for (const d of Object.values(RENDER_NODE_TYPES)) {
133
+ expect(Object.isFrozen(d)).toBe(true)
134
+ expect(Object.isFrozen(d.transcriptOutput)).toBe(true)
135
+ }
91
136
  })
92
137
  })
@@ -37,6 +37,11 @@ describe("findWordlessTranscriptFeeds", () => {
37
37
  )
38
38
  expect(hits.map((h) => h.consumerNodeId)).toEqual(["c"])
39
39
  })
40
+ it("follows the transcript THROUGH speaker-view (transcript in → its own transcript out, decided 2026-10-08), never its EDL json", () => {
41
+ const nodes = [n("t", "transcribe", { provider: "whisper" }), n("sv", "speaker-view"), n("c", "add-captions")]
42
+ expect(findWordlessTranscriptFeeds(nodes, [e("t", "json", "sv", "transcript"), e("sv", "transcript", "c", "transcript")]).map((h) => h.consumerNodeId)).toEqual(["c"])
43
+ expect(findWordlessTranscriptFeeds(nodes, [e("t", "json", "sv", "transcript"), e("sv", "json", "c", "transcript")])).toEqual([])
44
+ })
40
45
  it("does NOT flag a word-capable lane, the text handle, or a non-caption consumer", () => {
41
46
  const nodes = [n("ok", "transcribe", { provider: "elevenlabs-stt" }), n("w", "transcribe", { provider: "whisper" }), n("c", "add-captions"), n("p", "edit-plan")]
42
47
  expect(findWordlessTranscriptFeeds(nodes, [e("ok", "json", "c", "transcript")])).toEqual([])
@@ -4,6 +4,7 @@
4
4
  * screen is decided by the Cloud plugin; these only read the inputs it needs
5
5
  * and pre-fill the speaker table. Pure, no I/O.
6
6
  */
7
+ import { normalizeTranscript } from "./edl.js"
7
8
 
8
9
  /** The settings and their decided defaults (the plugin holds its own copy, D13). */
9
10
  export const CAMERA_SWITCH_DEFAULTS = Object.freeze({
@@ -28,14 +29,16 @@ const parseMaybe = (raw: unknown): unknown => {
28
29
  }
29
30
 
30
31
  /** Distinct speaker labels of a transcript (an object or its JSON string), in
31
- * order of first appearance. Empty → camera-switch refuses before charging. */
32
+ * order of first appearance in time. Read through `normalizeTranscript`
33
+ * (decided 2026-10-08) — the Cloud plugin's reading — so a broken word (no
34
+ * usable time) names no speaker here either; a zero-width word is a point
35
+ * and does. Empty → camera-switch refuses before charging. */
32
36
  export function transcriptSpeakerLabels(transcript: unknown): string[] {
33
- const words = (parseMaybe(transcript) as { words?: unknown } | null | undefined)?.words
34
- if (!Array.isArray(words)) return []
37
+ const parsed = parseMaybe(transcript)
38
+ if (!parsed || typeof parsed !== "object") return []
35
39
  const seen = new Set<string>()
36
- for (const w of words) {
37
- const s = (w as { speaker?: unknown } | null)?.speaker
38
- if (typeof s === "string" && s && !seen.has(s)) seen.add(s)
40
+ for (const w of normalizeTranscript(parsed).words) {
41
+ if (w.speaker && !seen.has(w.speaker)) seen.add(w.speaker)
39
42
  }
40
43
  return [...seen]
41
44
  }