@nodaro/shared 3.24.0 → 3.26.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 (50) hide show
  1. package/dist/index.cjs +1086 -257
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +531 -97
  4. package/dist/index.d.ts +531 -97
  5. package/dist/index.js +1034 -258
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/condition-variables.test.ts +12 -0
  9. package/src/__tests__/content-recipe-ideas.test.ts +9 -4
  10. package/src/__tests__/credit-identifiers.test.ts +31 -6
  11. package/src/__tests__/dialogue-capabilities.test.ts +3 -2
  12. package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
  13. package/src/__tests__/image-model-roles.test.ts +57 -0
  14. package/src/__tests__/image-ref-limit.test.ts +1 -0
  15. package/src/__tests__/json-kinds.test.ts +179 -0
  16. package/src/__tests__/llm-models.test.ts +136 -37
  17. package/src/__tests__/lone-media-url.test.ts +78 -0
  18. package/src/__tests__/presentation-utils.test.ts +1 -0
  19. package/src/__tests__/preview-gate.test.ts +2 -2
  20. package/src/__tests__/pricing-default-duration.test.ts +56 -15
  21. package/src/__tests__/private-host.test.ts +24 -0
  22. package/src/__tests__/prompt-length-limits.test.ts +2 -0
  23. package/src/__tests__/render-nodes.test.ts +22 -3
  24. package/src/__tests__/tts-capabilities.test.ts +61 -1
  25. package/src/__tests__/video-link-input.test.ts +148 -0
  26. package/src/__tests__/video-link-needs.test.ts +67 -0
  27. package/src/__tests__/video-request-normalize.test.ts +18 -3
  28. package/src/condition-variables.ts +3 -1
  29. package/src/content-recipe-ideas.ts +5 -2
  30. package/src/credit-identifiers.ts +48 -37
  31. package/src/edit-plan-contract.ts +67 -1
  32. package/src/fan-out-rows.ts +2 -2
  33. package/src/image-model-roles.ts +62 -0
  34. package/src/index.ts +59 -1
  35. package/src/json-kinds.ts +188 -0
  36. package/src/llm-models.ts +348 -23
  37. package/src/lone-media-url.ts +57 -0
  38. package/src/model-catalog.ts +160 -13
  39. package/src/model-constants.ts +79 -43
  40. package/src/node-default-mappings.ts +4 -0
  41. package/src/pipeline-types.ts +13 -2
  42. package/src/presentation-utils.ts +8 -1
  43. package/src/private-host.ts +91 -0
  44. package/src/producer-types.ts +3 -0
  45. package/src/render-nodes.ts +12 -1
  46. package/src/scene-node-types.ts +17 -5
  47. package/src/settings-input.ts +2 -1
  48. package/src/social-post-readers.ts +37 -0
  49. package/src/video-link.ts +238 -0
  50. package/src/voices.ts +16 -9
@@ -20,6 +20,9 @@ import {
20
20
  orderedLlmModels,
21
21
  REASONING_OUTPUT_FLOOR,
22
22
  reasoningOutputFloor,
23
+ llmServesDirect,
24
+ llmTierCreditIds,
25
+ LLM_CREDIT_RUNGS,
23
26
  } from "../llm-models.js"
24
27
  import type { LlmModelDef, LlmTier, LlmFeature } from "../llm-models.js"
25
28
  import { PIPELINE_PINNABLE_SCRIPT_LLMS } from "../pipeline-types.js"
@@ -49,11 +52,19 @@ const EXPECTED_MODEL_IDS = [
49
52
  "gpt-5.6-terra",
50
53
  "gpt-5.6-sol",
51
54
  "gpt-6-astra",
55
+ "gpt-6-luna",
56
+ "gpt-6-sol",
57
+ "gpt-6.1-sol",
52
58
  "grok-4.6",
59
+ "grok-4.7",
53
60
  "claude-sonnet-5",
61
+ "claude-sonnet-5.5",
54
62
  "claude-opus-4.8",
55
63
  "claude-opus-5",
64
+ "claude-opus-5.5",
56
65
  "claude-fable-5",
66
+ "kimi-k3",
67
+ "deepseek-v4.1-flash",
57
68
  ]
58
69
 
59
70
  // ---------------------------------------------------------------------------
@@ -98,14 +109,14 @@ describe("LLM_MODELS data integrity", () => {
98
109
  expect(new Set(ids).size).toBe(ids.length)
99
110
  })
100
111
 
101
- it("has 6 economy, 5 standard, 9 premium models", () => {
112
+ it("has 8 economy, 7 standard, 13 premium models", () => {
102
113
  const tierCounts: Record<LlmTier, number> = { economy: 0, standard: 0, premium: 0 }
103
114
  for (const model of LLM_MODELS) {
104
115
  tierCounts[model.tier]++
105
116
  }
106
- expect(tierCounts.economy).toBe(6)
107
- expect(tierCounts.standard).toBe(5)
108
- expect(tierCounts.premium).toBe(9)
117
+ expect(tierCounts.economy).toBe(8)
118
+ expect(tierCounts.standard).toBe(7)
119
+ expect(tierCounts.premium).toBe(13)
109
120
  })
110
121
 
111
122
  it("all three kieFormats are represented", () => {
@@ -115,8 +126,9 @@ describe("LLM_MODELS data integrity", () => {
115
126
  expect(formats).toContain("responses")
116
127
  })
117
128
 
118
- it("all four vendors are represented", () => {
129
+ it("every vendor in LLM_VENDOR_ORDER is represented", () => {
119
130
  const vendors = new Set(LLM_MODELS.map((m) => m.vendor))
131
+ for (const v of LLM_VENDOR_ORDER) expect(vendors).toContain(v)
120
132
  expect(vendors).toContain("anthropic")
121
133
  expect(vendors).toContain("google")
122
134
  expect(vendors).toContain("openai")
@@ -429,11 +441,11 @@ describe("LLM_FEATURE_DEFAULTS", () => {
429
441
  expect(getLlmTier(LLM_FEATURE_DEFAULTS["ai-writer"])).toBe("standard")
430
442
  })
431
443
 
432
- it('"describe-to-picker" defaults to "claude-opus-5" (premium vision)', () => {
433
- expect(LLM_FEATURE_DEFAULTS["describe-to-picker"]).toBe("claude-opus-5")
444
+ it('"describe-to-picker" defaults to "claude-opus-5.5" (premium vision)', () => {
445
+ expect(LLM_FEATURE_DEFAULTS["describe-to-picker"]).toBe("claude-opus-5.5")
434
446
  expect(getLlmTier(LLM_FEATURE_DEFAULTS["describe-to-picker"])).toBe("premium")
435
447
  // The default MUST be an accepted analyzer model (vision + structured output).
436
- expect(STRUCTURED_VISION_MODELS.map((m) => m.id)).toContain("claude-opus-5")
448
+ expect(STRUCTURED_VISION_MODELS.map((m) => m.id)).toContain("claude-opus-5.5")
437
449
  })
438
450
 
439
451
  it('"generate-script" defaults to "gemini-3.6-flash" (economy)', () => {
@@ -511,6 +523,16 @@ describe("STRUCTURED_VISION_MODELS", () => {
511
523
  "gpt-6-astra",
512
524
  // responses-format Grok — vision + text.format live-verified 2026-08-18.
513
525
  "grok-4.6",
526
+ // 2026-10-08 additions — vision (data URI) + text.format json_schema
527
+ // live-probed per model; the two Claude 5.5s via auto + strict tool.
528
+ "gpt-6-luna",
529
+ "gpt-6-sol",
530
+ "gpt-6.1-sol",
531
+ "grok-4.7",
532
+ "claude-sonnet-5.5",
533
+ "claude-opus-5.5",
534
+ "kimi-k3",
535
+ "deepseek-v4.1-flash",
514
536
  ].sort(),
515
537
  )
516
538
  })
@@ -821,11 +843,15 @@ describe("buildLlmCreditIdentifier effort bump (xhigh/max only)", () => {
821
843
  it("premium + max stays premium", () => {
822
844
  expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.6-sol", "max")).toBe("llm-chat:premium")
823
845
  })
824
- it("high never bumps", () => {
825
- expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5", "high")).toBe("llm-chat")
846
+ it("high never bumps for the effort itself", () => {
847
+ // A model whose effort works on the aggregator: no bump at all.
848
+ expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.6-terra", "high")).toBe("llm-chat")
849
+ // Claude: `high` adds no EFFORT bump, but any effort runs direct (+1 rung).
850
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5", "high")).toBe("llm-chat:premium")
826
851
  })
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")
852
+ it("clamp on a partial-list standard model never bumps for effort (sonnet-4.6 @ xhigh → high)", () => {
853
+ // Clamped to `high`: no effort bump; the direct bump alone lands premium.
854
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-4.6", "xhigh")).toBe("llm-chat:premium")
829
855
  })
830
856
  it("bump uses the CLAMPED effort (xhigh on a low/medium/high model clamps to high → no bump)", () => {
831
857
  expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.4", "xhigh")).toBe("llm-chat:premium")
@@ -881,9 +907,9 @@ describe("direct-vendor lane declarations", () => {
881
907
  })
882
908
 
883
909
  describe("advanced mode", () => {
884
- it("is available exactly on models with a direct Gemini lane", () => {
910
+ it("is available exactly on models with a direct lane (Gemini or Anthropic)", () => {
885
911
  for (const m of LLM_MODELS) {
886
- expect(supportsAdvancedMode(m.id), m.id).toBe(Boolean(m.directGeminiModel))
912
+ expect(supportsAdvancedMode(m.id), m.id).toBe(Boolean(m.directGeminiModel || m.directFallbackModel))
887
913
  }
888
914
  })
889
915
 
@@ -912,35 +938,30 @@ describe("advanced mode", () => {
912
938
  }
913
939
  })
914
940
 
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
- }
941
+ it("the effort and direct bumps stack — the UI copy says so", () => {
942
+ // `EFFORT_LABELS` (reasoning-effort-select.tsx) says xhigh/max "may bill one
943
+ // tier up", and the Claude hint under the picker says any effort runs direct
944
+ // and bills one tier more. Both apply to a Claude xhigh/max call (decided
945
+ // 2026-10-08: effort = Advanced, and the two bumps stack as Advanced's did).
946
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5.5", "low")).toBe("llm-chat:premium")
947
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-sonnet-5.5", "xhigh")).toBe("llm-chat:premium-direct")
948
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-haiku-4.5", "xhigh")).toBe("llm-chat:economy") // no ladder
932
949
  })
933
950
 
934
- it("never bumps past premium", () => {
935
- expect(buildLlmCreditIdentifier("llm-chat", "gemini-3.1-pro", "max", true)).toBe("llm-chat:premium")
951
+ it("a premium model served direct lands on premium-direct, and nothing goes past it", () => {
952
+ expect(buildLlmCreditIdentifier("llm-chat", "gemini-3.1-pro", "max", true)).toBe("llm-chat:premium-direct")
953
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-5.5", "max", true)).toBe("llm-chat:premium-direct")
954
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-5.5", "medium")).toBe("llm-chat:premium-direct")
955
+ // No effort, no Advanced: a premium Claude runs on the aggregator at premium.
956
+ expect(buildLlmCreditIdentifier("llm-chat", "claude-opus-5.5")).toBe("llm-chat:premium")
936
957
  })
937
958
 
938
959
  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.
960
+ // gpt-5.2 / kimi-k3 have no direct lane — a stale advancedMode flag must not inflate them.
940
961
  expect(buildLlmCreditIdentifier("llm-chat", "gpt-5.2", undefined, true))
941
962
  .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"))
963
+ expect(buildLlmCreditIdentifier("llm-chat", "kimi-k3", "high", true))
964
+ .toBe(buildLlmCreditIdentifier("llm-chat", "kimi-k3", "high"))
944
965
  })
945
966
 
946
967
  it("back-compat: omitting the 4th arg is identical to before for every model", () => {
@@ -1039,7 +1060,7 @@ describe("groupLlmModelsByVendor / orderedLlmModels", () => {
1039
1060
  const groups = groupLlmModelsByVendor(LLM_MODELS.filter((m) => m.vendor === "xai"))
1040
1061
  expect(groups).toHaveLength(1)
1041
1062
  expect(groups[0].label).toBe("xAI")
1042
- expect(groups[0].models.map((m) => m.id)).toEqual(["grok-4.6"])
1063
+ expect(groups[0].models.map((m) => m.id)).toEqual(["grok-4.6", "grok-4.7"])
1043
1064
  })
1044
1065
 
1045
1066
  it("does not mutate the registry (registry order is load-bearing for LLM_MODEL_IDS)", () => {
@@ -1049,9 +1070,87 @@ describe("groupLlmModelsByVendor / orderedLlmModels", () => {
1049
1070
  expect(LLM_MODELS.map((m) => m.id)).toEqual(before)
1050
1071
  })
1051
1072
 
1073
+ it("orders the new vendors alphabetically with their labels", () => {
1074
+ expect(LLM_VENDOR_ORDER).toEqual(["anthropic", "deepseek", "google", "moonshot", "openai", "xai"])
1075
+ expect(LLM_VENDOR_LABELS.deepseek).toBe("DeepSeek")
1076
+ expect(LLM_VENDOR_LABELS.moonshot).toBe("Moonshot AI")
1077
+ })
1078
+
1052
1079
  it("orderedLlmModels is the flattened grouping", () => {
1053
1080
  expect(orderedLlmModels().map((m) => m.id)).toEqual(
1054
1081
  groupLlmModelsByVendor().flatMap((g) => g.models.map((m) => m.id)),
1055
1082
  )
1056
1083
  })
1057
1084
  })
1085
+
1086
+ // ---------------------------------------------------------------------------
1087
+ // Forced tool choice + conversation-bound thinking (Claude 5.5 generation)
1088
+ // ---------------------------------------------------------------------------
1089
+ describe("supportsForcedToolChoice / conversationBoundThinking", () => {
1090
+ it("are declared exactly on the Claude 5.5 models", () => {
1091
+ const noForce = LLM_MODELS.filter((m) => m.supportsForcedToolChoice === false).map((m) => m.id)
1092
+ const bound = LLM_MODELS.filter((m) => m.conversationBoundThinking).map((m) => m.id)
1093
+ expect(noForce.sort()).toEqual(["claude-opus-5.5", "claude-sonnet-5.5"])
1094
+ expect(bound.sort()).toEqual(["claude-opus-5.5", "claude-sonnet-5.5"])
1095
+ })
1096
+
1097
+ it("only an anthropic-tool model can decline a forced tool choice (the flag has no reader elsewhere)", () => {
1098
+ for (const m of LLM_MODELS.filter((x) => x.supportsForcedToolChoice === false)) {
1099
+ expect(m.structuredOutputMode).toBe("anthropic-tool")
1100
+ }
1101
+ })
1102
+
1103
+ it("never offers `none` where the endpoint was measured to fail or override it", () => {
1104
+ expect(getLlmModel("gpt-6.1-sol")?.reasoningEfforts).not.toContain("none")
1105
+ expect(getLlmModel("grok-4.7")?.reasoningEfforts).not.toContain("none")
1106
+ })
1107
+
1108
+ // The film pipeline's callLLM (backend/src/ee/pipelines/llms/call-llm.ts) still
1109
+ // sends a FORCED tool_choice on the raw Anthropic SDK, and it is reachable only
1110
+ // through PIPELINE_PINNABLE_SCRIPT_LLMS. A model that 400s on forcing must not
1111
+ // join that list until callLLM reads `supportsForcedToolChoice`.
1112
+ it("no pipeline-pinnable script LLM rejects a forced tool choice", () => {
1113
+ for (const id of PIPELINE_PINNABLE_SCRIPT_LLMS) {
1114
+ expect(getLlmModel(id)?.supportsForcedToolChoice, id).not.toBe(false)
1115
+ }
1116
+ })
1117
+
1118
+ it("resolves the KIE / Anthropic dash-form ids of the new models", () => {
1119
+ expect(getLlmModel("claude-opus-5-5")?.id).toBe("claude-opus-5.5")
1120
+ expect(getLlmModel("claude-sonnet-5-5")?.id).toBe("claude-sonnet-5.5")
1121
+ expect(getLlmModel("gpt-6-1-sol")?.id).toBe("gpt-6.1-sol")
1122
+ expect(getLlmModel("deepseek-v4-1-flash")?.id).toBe("deepseek-v4.1-flash")
1123
+ expect(getLlmModel("grok-4-7")?.id).toBe("grok-4.7")
1124
+ })
1125
+ })
1126
+
1127
+ describe("llmServesDirect (decided 2026-10-08: priced on the lane it runs on)", () => {
1128
+ it("Advanced mode serves direct on any model with a direct lane", () => {
1129
+ expect(llmServesDirect("gemini-3.6-flash", undefined, true)).toBe(true)
1130
+ expect(llmServesDirect("claude-haiku-4.5", undefined, true)).toBe(true)
1131
+ expect(llmServesDirect("gpt-6-sol", "high", true)).toBe(false)
1132
+ })
1133
+ it("an effort serves direct only where the aggregator ignores it (Claude)", () => {
1134
+ expect(llmServesDirect("claude-opus-5.5", "low")).toBe(true)
1135
+ expect(llmServesDirect("gemini-3.6-flash", "high")).toBe(false)
1136
+ expect(llmServesDirect("gpt-6-sol", "max")).toBe(false)
1137
+ // Haiku has no effort ladder: an effort clamps to nothing, so it stays on KIE.
1138
+ expect(llmServesDirect("claude-haiku-4.5", "high")).toBe(false)
1139
+ })
1140
+ it("no effort and no Advanced: every model runs on the aggregator", () => {
1141
+ for (const m of LLM_MODELS) expect(llmServesDirect(m.id), m.id).toBe(false)
1142
+ })
1143
+ it("every Claude model with an effort ladder declares effortRequiresDirect, and is KIE-first", () => {
1144
+ for (const m of LLM_MODELS.filter((x) => x.vendor === "anthropic")) {
1145
+ expect(m.preferKie, m.id).toBe(true)
1146
+ expect(Boolean(m.effortRequiresDirect), m.id).toBe(Boolean(m.reasoningEfforts?.length))
1147
+ }
1148
+ })
1149
+ it("no model is direct-first any more", () => {
1150
+ expect(LLM_MODELS.filter((m) => m.preferDirect).map((m) => m.id)).toEqual([])
1151
+ })
1152
+ it("llmTierCreditIds lists the four rungs in order", () => {
1153
+ expect(llmTierCreditIds("llm-chat")).toEqual(["llm-chat:economy", "llm-chat", "llm-chat:premium", "llm-chat:premium-direct"])
1154
+ expect(LLM_CREDIT_RUNGS).toEqual(["economy", "standard", "premium", "premium-direct"])
1155
+ })
1156
+ })
@@ -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
+ })
@@ -60,6 +60,7 @@ describe("INPUT_NODE_TYPES", () => {
60
60
  "atmosphere",
61
61
  "action-fx",
62
62
  "temporal",
63
+ "youtube-video",
63
64
  ]
64
65
 
65
66
  it("contains all expected types", () => {
@@ -51,8 +51,8 @@ function tighten(quality: "proxy" | "final" | undefined) {
51
51
  }
52
52
 
53
53
  describe("PREVIEW_RENDER_NODE_TYPES", () => {
54
- it("names the render nodes a run can stop at (apply-edl; speaker-view joins when it lands)", () => {
55
- expect([...PREVIEW_RENDER_NODE_TYPES]).toEqual(["apply-edl"])
54
+ it("names the render nodes a run can stop at (apply-edl and speaker-view)", () => {
55
+ expect([...PREVIEW_RENDER_NODE_TYPES]).toEqual(["apply-edl", "speaker-view"])
56
56
  })
57
57
  })
58
58
 
@@ -1,39 +1,69 @@
1
1
  import { describe, it, expect } from "vitest"
2
- import { PRICING_DEFAULT_DURATION_SEC, pricedOutputDurationSec } from "../model-constants.js"
2
+ import { MODEL_CATALOG } from "../model-catalog.js"
3
+ import { pricedOutputDurationSec, snapToNearestDuration, videoDefaultDurationSec } from "../model-constants.js"
3
4
  import { buildVideoCreditModelIdentifier } from "../credit-identifiers.js"
4
5
 
5
6
  /**
6
- * #1397: a request that names a provider but omits `duration` renders the
7
- * provider's OWN default, so it must be priced — identifier tier AND every
8
- * reservation that scales by output seconds — at that default, never at a
9
- * literal 5. `pricedOutputDurationSec` is the one source both read.
7
+ * A video request that names no duration is CHARGED for the length the model
8
+ * renders by default (catalog `defaultDuration`), never for a global 5 s; one
9
+ * that names a length the model does not offer is charged for the nearest length
10
+ * it does (the runners' own snap rule). `pricedOutputDurationSec` is the one
11
+ * funnel every price path reads.
10
12
  */
11
13
  describe("pricedOutputDurationSec", () => {
12
- it("the requested duration wins, as a number or a numeric string", () => {
14
+ it("an offered duration wins, as a number or a numeric string", () => {
13
15
  expect(pricedOutputDurationSec("seedance-2-5", 12)).toBe(12)
14
16
  expect(pricedOutputDurationSec("seedance-2-5", "12")).toBe(12)
15
17
  expect(pricedOutputDurationSec("minimax-h3", 4)).toBe(4)
16
18
  })
17
19
 
18
- it("an omitted duration prices the provider's declared default render length", () => {
20
+ it("an omitted duration is the model's catalog default render length", () => {
21
+ expect(pricedOutputDurationSec("seedance-2", undefined)).toBe(8)
22
+ expect(pricedOutputDurationSec("seedance-2-fast", undefined)).toBe(8)
23
+ expect(pricedOutputDurationSec("seedance-2-mini", undefined)).toBe(8)
19
24
  expect(pricedOutputDurationSec("seedance-2-5", undefined)).toBe(8)
25
+ expect(pricedOutputDurationSec("grok-i2v", undefined)).toBe(6)
20
26
  expect(pricedOutputDurationSec("grok-imagine-video-1.5", undefined)).toBe(8)
21
27
  expect(pricedOutputDurationSec("minimax-h3", undefined)).toBe(6)
22
- expect(PRICING_DEFAULT_DURATION_SEC["seedance-2-5"]).toBe(8)
28
+ expect(pricedOutputDurationSec("hailuo-2.3-pro", undefined)).toBe(6)
29
+ expect(pricedOutputDurationSec("kling", undefined)).toBe(5)
30
+ expect(pricedOutputDurationSec("ltx-2.3-pro", undefined)).toBe(6)
23
31
  })
24
32
 
25
- it("a provider with no declared default keeps the historical 5s fallback", () => {
26
- expect(pricedOutputDurationSec("seedance-2", undefined)).toBe(5)
27
- expect(pricedOutputDurationSec("kling", undefined)).toBe(5)
33
+ it("an unparseable duration is priced the same way", () => {
34
+ expect(pricedOutputDurationSec("seedance-2", "abc")).toBe(8)
35
+ expect(pricedOutputDurationSec("grok-i2v", "abc")).toBe(6)
28
36
  })
29
37
 
30
- it("an unparseable duration falls back the same way", () => {
31
- expect(pricedOutputDurationSec("seedance-2-5", "abc")).toBe(8)
32
- expect(pricedOutputDurationSec("seedance-2", "abc")).toBe(5)
38
+ it("a length the model does not offer is charged as the nearest one it does (a tie goes shorter)", () => {
39
+ expect(pricedOutputDurationSec("kling", 7)).toBe(5)
40
+ expect(pricedOutputDurationSec("kling", 8)).toBe(10)
41
+ expect(pricedOutputDurationSec("grok-i2v", 8)).toBe(6)
42
+ expect(pricedOutputDurationSec("grok-i2v", 15)).toBe(10)
43
+ expect(pricedOutputDurationSec("seedance", 6)).toBe(4)
44
+ expect(pricedOutputDurationSec("seedance", 10)).toBe(8)
33
45
  })
34
46
 
35
- it("the identifier tier for an omitted duration is the default's tier, not the 5s one (seedance-2-5)", () => {
47
+ it("snapToNearestDuration is the runners' rule: offered values pass, ties go to the earlier entry", () => {
48
+ expect(snapToNearestDuration(5, [4, 8, 12])).toBe(4)
49
+ expect(snapToNearestDuration(6, [4, 8, 12])).toBe(4)
50
+ expect(snapToNearestDuration(7, [4, 8, 12])).toBe(8)
51
+ expect(snapToNearestDuration(9, undefined)).toBe(9)
52
+ expect(snapToNearestDuration(9, [])).toBe(9)
53
+ })
54
+
55
+ it("every default is a length the model offers", () => {
56
+ for (const e of Object.values(MODEL_CATALOG)) {
57
+ if (e.defaultDuration === undefined) continue
58
+ expect(e.durations, `${e.id} declares defaultDuration but no durations`).toBeDefined()
59
+ expect(e.durations, `${e.id}: defaultDuration ${e.defaultDuration}`).toContain(e.defaultDuration)
60
+ expect(videoDefaultDurationSec(e.id)).toBe(e.defaultDuration)
61
+ }
62
+ })
63
+
64
+ it("an unset duration prices the SAME tier as that default sent explicitly (worked examples)", () => {
36
65
  for (const nodeType of ["image-to-video", "text-to-video"] as const) {
66
+ expect(buildVideoCreditModelIdentifier("seedance-2", undefined, undefined, nodeType, undefined, "720p")).toBe("seedance-2:8s:720p")
37
67
  expect(buildVideoCreditModelIdentifier("seedance-2-5", undefined, undefined, nodeType, undefined, "720p")).toBe(
38
68
  buildVideoCreditModelIdentifier("seedance-2-5", 8, undefined, nodeType, undefined, "720p"),
39
69
  )
@@ -41,5 +71,16 @@ describe("pricedOutputDurationSec", () => {
41
71
  "seedance-2-5:8s:720p-ref",
42
72
  )
43
73
  }
74
+ expect(buildVideoCreditModelIdentifier("grok-i2v", undefined, undefined, "image-to-video")).toBe("grok-i2v:6s")
75
+ expect(buildVideoCreditModelIdentifier("ltx-2.3-fast", undefined)).toBe("ltx-2.3-fast:1080p:6s")
76
+ expect(buildVideoCreditModelIdentifier("gemini-omni-video", undefined)).toBe("gemini-omni-video:8")
77
+ expect(buildVideoCreditModelIdentifier("gemini-omni-video", 7)).toBe("gemini-omni-video:6")
78
+ })
79
+
80
+ it("a snapped length is charged as the tier it renders (worked examples)", () => {
81
+ expect(buildVideoCreditModelIdentifier("kling", 7)).toBe("kling:5s")
82
+ expect(buildVideoCreditModelIdentifier("kling", 8)).toBe("kling:10s")
83
+ expect(buildVideoCreditModelIdentifier("ltx-2.3-pro", 7)).toBe("ltx-2.3-pro:1080p:6s")
84
+ expect(buildVideoCreditModelIdentifier("ltx-2.3-fast", 14, undefined, undefined, undefined, "2k")).toBe("ltx-2.3-fast:2k:10s")
44
85
  })
45
86
  })
@@ -0,0 +1,24 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import { isLocalOrPrivateHostname, isPrivateOrReservedIP } from "../private-host.js"
3
+
4
+ describe("isPrivateOrReservedIP", () => {
5
+ it("refuses loopback, private, link-local, CGN, multicast and mapped addresses", () => {
6
+ for (const ip of ["0.0.0.0", "127.0.0.1", "10.1.2.3", "172.16.0.1", "172.31.255.255", "192.168.0.1", "169.254.169.254", "100.64.0.1", "198.18.0.1", "224.0.0.1", "255.255.255.255", "::", "::1", "fe80::1", "fd00::1", "ff02::1", "::ffff:127.0.0.1", "::ffff:7f00:1", "::7f00:1"]) {
7
+ expect(isPrivateOrReservedIP(ip), ip).toBe(true)
8
+ }
9
+ })
10
+ it("passes public addresses", () => {
11
+ for (const ip of ["8.8.8.8", "93.184.216.34", "172.32.0.1", "2606:4700::1"]) expect(isPrivateOrReservedIP(ip), ip).toBe(false)
12
+ })
13
+ })
14
+
15
+ describe("isLocalOrPrivateHostname", () => {
16
+ it("reads a URL hostname the way the server's SSRF schema does", () => {
17
+ for (const host of ["localhost", "LOCALHOST", "localhost.", "app.localhost", "[::1]", "[fe80::1]", "127.0.0.1", "192.168.1.5"]) {
18
+ expect(isLocalOrPrivateHostname(host), host).toBe(true)
19
+ }
20
+ for (const host of ["cdn.example.com", "youtube.com", "93.184.216.34", "[2606:4700::1]", "localhost.example.com", "notlocalhost"]) {
21
+ expect(isLocalOrPrivateHostname(host), host).toBe(false)
22
+ }
23
+ })
24
+ })
@@ -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)
@@ -7,6 +7,7 @@ import {
7
7
  OWNER_ONLY_LISTING_RENDER_TYPES,
8
8
  PREVIEW_RENDER_NODE_TYPES,
9
9
  applyEdlCreditId,
10
+ speakerViewCreditId,
10
11
  isRenderNodeType,
11
12
  renderNodeOf,
12
13
  rendersLatestBatch,
@@ -14,9 +15,27 @@ import {
14
15
  } from "../index.js"
15
16
 
16
17
  describe("RENDER_NODE_TYPES — one render-node registry (SV18)", () => {
17
- it("holds Apply EDL, and only it, until Speaker View registers", () => {
18
- expect(Object.keys(RENDER_NODE_TYPES)).toEqual(["apply-edl"])
19
- expect(RENDER_NODE_TYPE_IDS).toEqual(["apply-edl"])
18
+ it("holds Apply EDL and Speaker View", () => {
19
+ expect(Object.keys(RENDER_NODE_TYPES)).toEqual(["apply-edl", "speaker-view"])
20
+ expect(RENDER_NODE_TYPE_IDS).toEqual(["apply-edl", "speaker-view"])
21
+ })
22
+
23
+ it("describes Speaker View: video only, mapped through the EDL it emits, a json that is an EDL (C3.2)", () => {
24
+ const d = renderNodeOf("speaker-view")!
25
+ expect(d.clockMapFrom).toBe("output-json")
26
+ expect(d.ownerOnlyListing).toBe(true)
27
+ expect(d.latestBatch).toBe(true)
28
+ expect(d.jsonKind).toBe("edl")
29
+ expect(d.mediumOf({ output: "audio" })).toBe("video")
30
+ expect(d.mediumOf({})).toBe("video")
31
+ expect(rendersTranscriptJson("speaker-view")).toBe(false)
32
+ })
33
+
34
+ it("prices a Preview on its own row and everything else on the final's", () => {
35
+ const d = renderNodeOf("speaker-view")!
36
+ expect(d.creditId("proxy")).toBe("speaker-view:proxy")
37
+ for (const q of ["final", undefined, null, "", "high", 3]) expect(d.creditId(q)).toBe("speaker-view")
38
+ expect(speakerViewCreditId("proxy")).toBe("speaker-view:proxy")
20
39
  })
21
40
 
22
41
  it("describes Apply EDL exactly as its hard-coded sites behaved", () => {
@@ -57,7 +57,7 @@ describe("speech-model capability sheets — totality", () => {
57
57
  }
58
58
  })
59
59
 
60
- it("every sheet says whether the model returns timings, and all six speech models do", () => {
60
+ it("every sheet says whether the model returns timings, and all seven speech models do", () => {
61
61
  const yes = Object.values(MODEL_CATALOG).filter((m) => m.tts?.timestamps === true).map((m) => m.id).sort()
62
62
  for (const m of Object.values(MODEL_CATALOG)) {
63
63
  if (!m.tts) continue
@@ -65,6 +65,7 @@ describe("speech-model capability sheets — totality", () => {
65
65
  }
66
66
  // Measured 2026-10-04 (v4) and 2026-10-06 (the rest): /with-timestamps answers 200 on every
67
67
  // speech model at the same character cost. A new model joins this list only once it is measured.
68
+ // v4 Turbo measured 2026-10-07: with-timestamps 200 at equal character-cost.
68
69
  expect(yes).toEqual([
69
70
  "elevenlabs-dialogue",
70
71
  "elevenlabs-dialogue-v4",
@@ -72,6 +73,7 @@ describe("speech-model capability sheets — totality", () => {
72
73
  "elevenlabs-turbo",
73
74
  "elevenlabs-v3",
74
75
  "elevenlabs-v4",
76
+ "elevenlabs-v4-turbo",
75
77
  ])
76
78
  })
77
79
  })
@@ -263,6 +265,64 @@ describe("elevenlabs-v4 — added beside v3", () => {
263
265
  })
264
266
  })
265
267
 
268
+ describe("elevenlabs-v4-turbo — the fast v4, added beside v4 (decided 2026-10-06)", () => {
269
+ it("is a text-to-speech provider, in the catalog, listed after v3 and before Turbo v2.5", () => {
270
+ expect(TTS_PROVIDERS).toContain("elevenlabs-v4-turbo")
271
+ expect(MODEL_CATALOG["elevenlabs-v4-turbo"]?.modes).toContain("tts")
272
+ const order = TTS_PROVIDERS.filter((id) => ["elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"].includes(id))
273
+ expect(order).toEqual(["elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"])
274
+ })
275
+
276
+ it("the sheet: tags, no SSML, stability + similarity, language code, v4's curated 46 languages, the cap", () => {
277
+ const c = getTtsCapabilities("elevenlabs-v4-turbo")
278
+ expect(c.audioTags).toBe(true)
279
+ expect(c.ssmlBreaks).toBe(false)
280
+ expect(c.levers).toEqual(["stability", "similarity"])
281
+ expect(c.languageCode).toBe(true)
282
+ expect(c.languages).toEqual(getTtsCapabilities("elevenlabs-v4").languages)
283
+ expect(c.maxChars).toBe(10000) // measured 2026-10-07: the vendor declares 10,000; live, 10,000 AND 10,001 both returned 200 — the declared (smaller) figure is the clamp
284
+ expect(getMaxTtsChars("elevenlabs-v4-turbo")).toBe(c.maxChars)
285
+ })
286
+
287
+ it("stitching and timestamps are the probe's values, declared, never undefined", () => {
288
+ const c = getTtsCapabilities("elevenlabs-v4-turbo")
289
+ expect(c.stitching).toBe(true) // measured 2026-10-07: neighbour-text 200 at the plain call's character-cost
290
+ expect(c.timestamps).toBe(true) // measured 2026-10-07: with-timestamps 200 at equal character-cost
291
+ expect(ttsSupportsStitching("elevenlabs-v4-turbo")).toBe(c.stitching)
292
+ expect(ttsSupportsTimestamps("elevenlabs-v4-turbo")).toBe(c.timestamps)
293
+ })
294
+
295
+ it("keeps [audio tags], has no SSML breaks, honours similarity but not speed, style or speaker boost", () => {
296
+ expect(ttsSupportsAudioTags("elevenlabs-v4-turbo")).toBe(true)
297
+ expect(ttsSupportsSsmlBreaks("elevenlabs-v4-turbo")).toBe(false)
298
+ expect(ttsHasLever("elevenlabs-v4-turbo", "similarity")).toBe(true)
299
+ for (const lever of ["speed", "style", "speakerBoost"] as const) expect(ttsHasLever("elevenlabs-v4-turbo", lever), lever).toBe(false)
300
+ })
301
+
302
+ it("its flat row is 15 with no note — Turbo v2.5 parity — beside a 2-credit per-100-characters row; it is not featured", () => {
303
+ expect(MODEL_CATALOG["elevenlabs-v4-turbo"]!.pricing).toEqual([
304
+ { identifier: "elevenlabs-v4-turbo", credits: 15 },
305
+ { identifier: "elevenlabs-v4-turbo:per-100-chars", credits: 2, note: SPEECH_UNIT_PRICE_NOTE },
306
+ ])
307
+ expect(MODEL_CATALOG["elevenlabs-v4-turbo"]!.featured).toBeUndefined()
308
+ expect(MODEL_CATALOG["elevenlabs-turbo"]!.pricing[0]!.credits).toBe(15)
309
+ })
310
+
311
+ it("every existing speech sheet is exactly what it was", () => {
312
+ expect(getTtsCapabilities("elevenlabs-v4").maxChars).toBe(10000)
313
+ expect(getTtsCapabilities("elevenlabs-v3").maxChars).toBe(5000)
314
+ expect(getTtsCapabilities("elevenlabs-turbo").maxChars).toBe(40000)
315
+ expect(getTtsCapabilities("elevenlabs-multilingual").maxChars).toBe(10000)
316
+ expect(TTS_PROVIDERS.filter((id) => id !== "elevenlabs-v4-turbo")).toEqual(["elevenlabs-v3", "elevenlabs-v4", "elevenlabs-turbo", "elevenlabs-multilingual", "elevenlabs"])
317
+ })
318
+
319
+ it("the narration recommendation keeps v4 first and places v4 Turbo after v3, before Turbo v2.5", async () => {
320
+ const { MODEL_RECOMMENDATIONS } = await import("../model-catalog.js")
321
+ const narration = MODEL_RECOMMENDATIONS.find((r) => r.intent === "voice over / narration")
322
+ expect(narration?.modelIds).toEqual(["elevenlabs-v4", "elevenlabs-v3", "elevenlabs-v4-turbo", "elevenlabs-turbo"])
323
+ })
324
+ })
325
+
266
326
  describe("ttsSupportsTimestamps", () => {
267
327
  it("answers for the model the request runs as", () => {
268
328
  expect(ttsSupportsTimestamps("elevenlabs-v4")).toBe(true)