@nodaro/shared 3.25.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.
- package/dist/index.cjs +476 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -53
- package/dist/index.d.ts +160 -53
- package/dist/index.js +467 -115
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/condition-variables.test.ts +12 -0
- package/src/__tests__/content-recipe-ideas.test.ts +9 -4
- package/src/__tests__/credit-identifiers.test.ts +12 -0
- package/src/__tests__/image-model-roles.test.ts +57 -0
- package/src/__tests__/image-ref-limit.test.ts +1 -0
- package/src/__tests__/llm-models.test.ts +136 -37
- package/src/__tests__/lone-media-url.test.ts +78 -0
- package/src/__tests__/prompt-length-limits.test.ts +2 -0
- package/src/condition-variables.ts +3 -1
- package/src/content-recipe-ideas.ts +5 -2
- package/src/image-model-roles.ts +62 -0
- package/src/index.ts +14 -0
- package/src/llm-models.ts +348 -23
- package/src/lone-media-url.ts +57 -0
- package/src/model-catalog.ts +39 -5
- package/src/model-constants.ts +11 -1
- package/src/node-default-mappings.ts +3 -0
- package/src/settings-input.ts +2 -1
package/package.json
CHANGED
|
@@ -87,6 +87,18 @@ describe("buildConditionVariables", () => {
|
|
|
87
87
|
expect(map.has("Missing")).toBe(false)
|
|
88
88
|
})
|
|
89
89
|
|
|
90
|
+
it("trims the surrounding whitespace of a variable — a model's answer ends with a newline", () => {
|
|
91
|
+
// A Generate Text answer ("<id>\n") wired to Variables must still EQUAL the
|
|
92
|
+
// field it is compared with; the newline is the model's, not the value's.
|
|
93
|
+
const answer = node("a", "llm-chat", "Pick", { text: " 11111111-1111-4111-8111-111111111111\n" })
|
|
94
|
+
const blank = node("b", "llm-chat", "Blank", { text: " \n " })
|
|
95
|
+
const filter = node("f", "filter-list", "Filter")
|
|
96
|
+
const edges: E[] = [edge("a", "f", "variables", "text"), edge("b", "f", "variables", "text")]
|
|
97
|
+
const map = buildConditionVariables("f", edges, [answer, blank, filter], extract)
|
|
98
|
+
expect(map.get("Pick")).toBe("11111111-1111-4111-8111-111111111111")
|
|
99
|
+
expect(map.has("Blank")).toBe(false)
|
|
100
|
+
})
|
|
101
|
+
|
|
90
102
|
it("ignores edges targeting other nodes", () => {
|
|
91
103
|
const tp = node("a", "text-prompt", "Ref", { text: "x" })
|
|
92
104
|
const other = node("o", "filter-list", "Other")
|
|
@@ -34,8 +34,11 @@ describe("content recipe / ideas pricing", () => {
|
|
|
34
34
|
expect(contentIdeasCreditId(6, "claude-sonnet-4.6")).toBe("content-ideas:10")
|
|
35
35
|
expect(contentIdeasCreditId(10)).toBe("content-ideas:10:economy")
|
|
36
36
|
expect(contentIdeasCreditId(10, "claude-opus-5")).toBe("content-ideas:10:premium")
|
|
37
|
-
// an xhigh/max effort bumps one tier, as for every LLM node
|
|
38
|
-
|
|
37
|
+
// an xhigh/max effort bumps one tier, as for every LLM node — and on a
|
|
38
|
+
// Claude model any effort also runs direct (+1 rung, decided 2026-10-08):
|
|
39
|
+
// sonnet-4.6 tops out at `max`, so standard → premium → premium-direct.
|
|
40
|
+
expect(contentIdeasCreditId(3, "claude-sonnet-4.6", "max")).toBe("content-ideas:premium-direct")
|
|
41
|
+
expect(contentIdeasCreditId(3, "gpt-5.6-terra", "max")).toBe("content-ideas:premium")
|
|
39
42
|
})
|
|
40
43
|
|
|
41
44
|
it("count: numbers only, clamped to 1..10", () => {
|
|
@@ -49,8 +52,10 @@ describe("content recipe / ideas pricing", () => {
|
|
|
49
52
|
it("every id a run can bill is listed", () => {
|
|
50
53
|
const reachable = new Set<string>()
|
|
51
54
|
for (const model of [undefined, "claude-sonnet-4.6", "claude-opus-5"]) {
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
for (const effort of [undefined, "high"]) {
|
|
56
|
+
reachable.add(contentRecipeCreditId(model, effort))
|
|
57
|
+
for (const count of [1, 5, 6, 10]) reachable.add(contentIdeasCreditId(count, model, effort))
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
expect([...reachable].sort()).toEqual([...CONTENT_RECIPE_IDEAS_CREDIT_IDS].sort())
|
|
56
61
|
})
|
|
@@ -114,6 +114,18 @@ describe("buildCreditModelIdentifier", () => {
|
|
|
114
114
|
})
|
|
115
115
|
})
|
|
116
116
|
|
|
117
|
+
// --- seedream-5-flash ---
|
|
118
|
+
describe("seedream-5-flash", () => {
|
|
119
|
+
it("is flat-priced: every size and a stray quality bill the bare id", () => {
|
|
120
|
+
for (const provider of ["seedream-5-flash", "seedream-5-flash-i2i"]) {
|
|
121
|
+
for (const resolution of [undefined, "1K", "2K"]) {
|
|
122
|
+
expect(buildCreditModelIdentifier(provider, undefined, resolution)).toBe(provider)
|
|
123
|
+
expect(buildCreditModelIdentifier(provider, "high", resolution)).toBe(provider)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
117
129
|
// --- topaz-image-upscale ---
|
|
118
130
|
describe("topaz-image-upscale", () => {
|
|
119
131
|
it('targetResolution="4K" returns composite identifier', () => {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest"
|
|
2
|
+
import { MODEL_CATALOG } from "../model-catalog.js"
|
|
3
|
+
import {
|
|
4
|
+
IMAGE_MODEL_ROLE_DEFAULTS,
|
|
5
|
+
IMAGE_MODEL_RATIO_FALLBACKS,
|
|
6
|
+
defaultImageModel,
|
|
7
|
+
imageModelDrawsRatio,
|
|
8
|
+
} from "../image-model-roles.js"
|
|
9
|
+
|
|
10
|
+
describe("image model role defaults (decided 2026-10-08)", () => {
|
|
11
|
+
it("pins the decided models", () => {
|
|
12
|
+
expect(IMAGE_MODEL_ROLE_DEFAULTS).toEqual({
|
|
13
|
+
character: "gpt-image-2",
|
|
14
|
+
general: "gpt-image-2",
|
|
15
|
+
anchor: "gpt-image-2",
|
|
16
|
+
edit: "gpt-image-2-5-flare-i2i",
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it("names only catalog models", () => {
|
|
21
|
+
for (const id of [...Object.values(IMAGE_MODEL_ROLE_DEFAULTS), ...Object.values(IMAGE_MODEL_RATIO_FALLBACKS).flat()]) {
|
|
22
|
+
expect(MODEL_CATALOG[id], id).toBeDefined()
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it("never defaults to Nano Banana Pro except as the last ratio fallback", () => {
|
|
27
|
+
expect(Object.values(IMAGE_MODEL_ROLE_DEFAULTS)).not.toContain("nano-banana-pro")
|
|
28
|
+
for (const chain of Object.values(IMAGE_MODEL_RATIO_FALLBACKS)) expect(chain.at(-1)).toBe("nano-banana-pro")
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it("keeps the role model for ratios it draws, and for no ratio", () => {
|
|
32
|
+
for (const r of [undefined, null, "", "auto", "1:1", "16:9", "9:16", "4:3", "3:4"]) {
|
|
33
|
+
expect(defaultImageModel("general", r)).toBe("gpt-image-2")
|
|
34
|
+
}
|
|
35
|
+
expect(defaultImageModel("edit", "16:9")).toBe("gpt-image-2-5-flare-i2i")
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("moves wide and in-between ratios to Sunburst, and 4:5 / 5:4 to Nano Banana Pro", () => {
|
|
39
|
+
for (const r of ["21:9", "3:2", "2:3", "27:16", "9:8"]) {
|
|
40
|
+
expect(defaultImageModel("character", r)).toBe("gpt-image-2-5-sunburst")
|
|
41
|
+
expect(defaultImageModel("anchor", r)).toBe("gpt-image-2-5-sunburst")
|
|
42
|
+
}
|
|
43
|
+
for (const r of ["4:5", "5:4"]) {
|
|
44
|
+
expect(defaultImageModel("general", r)).toBe("nano-banana-pro")
|
|
45
|
+
expect(defaultImageModel("edit", r)).toBe("nano-banana-pro")
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("falls back to the role model when nothing draws the ratio", () => {
|
|
50
|
+
expect(defaultImageModel("general", "7:1")).toBe("gpt-image-2")
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it("reads ratios from the catalog", () => {
|
|
54
|
+
expect(imageModelDrawsRatio("gpt-image-2", "21:9")).toBe(false)
|
|
55
|
+
expect(imageModelDrawsRatio("gpt-image-2-5-sunburst", "21:9")).toBe(true)
|
|
56
|
+
})
|
|
57
|
+
})
|
|
@@ -17,6 +17,7 @@ describe("imageReferenceLimit", () => {
|
|
|
17
17
|
"gpt-image-2": 16, // → gpt-image-2-i2i
|
|
18
18
|
"seedream-5-lite": 16, // → seedream-5-lite-i2i
|
|
19
19
|
"seedream-5-pro": 16, // → seedream-5-pro-i2i
|
|
20
|
+
"seedream-5-flash": 10, // → seedream-5-flash-i2i (schema maxItems 10, not the family's 16)
|
|
20
21
|
"nano-banana-2": 4,
|
|
21
22
|
"nano-banana-2-lite": 10, // schema maxItems (image_urls)
|
|
22
23
|
flux: 4, // → flux-pro-i2i
|
|
@@ -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
|
|
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(
|
|
107
|
-
expect(tierCounts.standard).toBe(
|
|
108
|
-
expect(tierCounts.premium).toBe(
|
|
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("
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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("
|
|
916
|
-
// `EFFORT_LABELS`
|
|
917
|
-
//
|
|
918
|
-
//
|
|
919
|
-
//
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
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("
|
|
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
|
|
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", "
|
|
943
|
-
.toBe(buildLlmCreditIdentifier("llm-chat", "
|
|
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
|
+
})
|
|
@@ -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)
|
|
@@ -42,7 +42,9 @@ export function buildConditionVariables<
|
|
|
42
42
|
if (edge.targetHandle !== VARIABLES_HANDLE_ID) continue
|
|
43
43
|
const src = nodes.find((n) => n.id === edge.source)
|
|
44
44
|
if (!src) continue
|
|
45
|
-
|
|
45
|
+
// Surrounding whitespace is never part of a variable: a model's answer
|
|
46
|
+
// ("<id>\n") must still equal the field it is compared with.
|
|
47
|
+
const output = extractOutput(src)?.trim()
|
|
46
48
|
if (output === undefined || output === "") continue
|
|
47
49
|
const label = (src.data.label as string) || src.type || src.id
|
|
48
50
|
pairs.push({ label, output })
|
|
@@ -8,8 +8,8 @@ import { buildLlmCreditIdentifier, getLlmModel, LLM_FEATURE_DEFAULTS } from "./l
|
|
|
8
8
|
* the cloud plugin that runs the nodes computes the same ids.
|
|
9
9
|
*
|
|
10
10
|
* Content Ideas is charged per batch of up to five ideas: a run of 1–5 ideas
|
|
11
|
-
* bills `content-ideas[:economy|:premium]`, a run of 6–10 bills
|
|
12
|
-
* `content-ideas:10[:economy|:premium]`, priced at two batches.
|
|
11
|
+
* bills `content-ideas[:economy|:premium|:premium-direct]`, a run of 6–10 bills
|
|
12
|
+
* `content-ideas:10[:economy|:premium|:premium-direct]`, priced at two batches.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
export const CONTENT_IDEAS_MAX_COUNT = 10
|
|
@@ -60,10 +60,13 @@ export const CONTENT_RECIPE_IDEAS_CREDIT_IDS = [
|
|
|
60
60
|
"content-recipe:economy",
|
|
61
61
|
"content-recipe",
|
|
62
62
|
"content-recipe:premium",
|
|
63
|
+
"content-recipe:premium-direct",
|
|
63
64
|
"content-ideas:economy",
|
|
64
65
|
"content-ideas",
|
|
65
66
|
"content-ideas:premium",
|
|
67
|
+
"content-ideas:premium-direct",
|
|
66
68
|
"content-ideas:10:economy",
|
|
67
69
|
"content-ideas:10",
|
|
68
70
|
"content-ideas:10:premium",
|
|
71
|
+
"content-ideas:10:premium-direct",
|
|
69
72
|
] as const
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { MODEL_CATALOG } from "./model-catalog.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The platform's answer to "which image model, when the caller names none".
|
|
5
|
+
*
|
|
6
|
+
* One table by ROLE, so every surface that picks for the user (node defaults,
|
|
7
|
+
* route and workflow fallbacks, MCP tools, studios, pipelines) reads the same
|
|
8
|
+
* model instead of keeping its own literal. Before this table those literals
|
|
9
|
+
* had drifted apart: the Generate Image node started on Nano Banana Pro, the
|
|
10
|
+
* routes fell back to the original Nano Banana, and MCP used Nano Banana 2.1.
|
|
11
|
+
*
|
|
12
|
+
* Decided on 2026-10-08 from a blind five-model comparison, quality
|
|
13
|
+
* first and price second:
|
|
14
|
+
* - characters, general text-to-image and video anchors on GPT Image 2;
|
|
15
|
+
* - edits on GPT Image 2.5 Flare.
|
|
16
|
+
* With reference images attached, GPT Image 2 runs as its i2i sibling (the
|
|
17
|
+
* provider swaps it), so `character` covers identity-from-reference too.
|
|
18
|
+
*
|
|
19
|
+
* Nano Banana Pro is no longer a default. It remains a FALLBACK only: last in
|
|
20
|
+
* the ratio chain below (it is the one model here that draws 4:5 and 5:4), the
|
|
21
|
+
* GPT-family safety-block retry, and the swimwear dressing model.
|
|
22
|
+
*/
|
|
23
|
+
export const IMAGE_MODEL_ROLE_DEFAULTS = {
|
|
24
|
+
character: "gpt-image-2",
|
|
25
|
+
general: "gpt-image-2",
|
|
26
|
+
anchor: "gpt-image-2",
|
|
27
|
+
edit: "gpt-image-2-5-flare-i2i",
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
export type ImageModelRole = keyof typeof IMAGE_MODEL_ROLE_DEFAULTS
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Where a role's model goes when it cannot draw the requested aspect ratio.
|
|
34
|
+
* GPT Image 2 draws only auto / 1:1 / 16:9 / 9:16 / 4:3 / 3:4, so 21:9, 3:2,
|
|
35
|
+
* 2:3 and the other wide or in-between ratios move to GPT Image 2.5 Sunburst,
|
|
36
|
+
* and 4:5 / 5:4 (which neither GPT generation draws) to Nano Banana Pro.
|
|
37
|
+
*/
|
|
38
|
+
export const IMAGE_MODEL_RATIO_FALLBACKS: Readonly<Record<ImageModelRole, readonly string[]>> = {
|
|
39
|
+
character: ["gpt-image-2-5-sunburst", "nano-banana-pro"],
|
|
40
|
+
general: ["gpt-image-2-5-sunburst", "nano-banana-pro"],
|
|
41
|
+
anchor: ["gpt-image-2-5-sunburst", "nano-banana-pro"],
|
|
42
|
+
edit: ["gpt-image-2-5-sunburst-i2i", "nano-banana-pro"],
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True when the model's catalog entry lists the ratio (or no ratio was asked for). */
|
|
46
|
+
export function imageModelDrawsRatio(modelId: string, aspectRatio?: string | null): boolean {
|
|
47
|
+
if (!aspectRatio) return true
|
|
48
|
+
const ratios = MODEL_CATALOG[modelId]?.aspectRatios
|
|
49
|
+
return ratios === undefined || ratios.includes(aspectRatio)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The default image model for a role at the requested aspect ratio: the role's
|
|
54
|
+
* model when it draws the ratio, else the first fallback that does, else the
|
|
55
|
+
* role's model (whose own ratio normalization then snaps the ratio). Read from
|
|
56
|
+
* the catalog, so widening a model's documented ratios moves this with it.
|
|
57
|
+
*/
|
|
58
|
+
export function defaultImageModel(role: ImageModelRole, aspectRatio?: string | null): string {
|
|
59
|
+
const primary = IMAGE_MODEL_ROLE_DEFAULTS[role]
|
|
60
|
+
if (imageModelDrawsRatio(primary, aspectRatio)) return primary
|
|
61
|
+
return IMAGE_MODEL_RATIO_FALLBACKS[role].find((id) => imageModelDrawsRatio(id, aspectRatio)) ?? primary
|
|
62
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -410,6 +410,11 @@ export {
|
|
|
410
410
|
buildLlmCreditIdentifier,
|
|
411
411
|
resolveLlmCreditId,
|
|
412
412
|
supportsAdvancedMode,
|
|
413
|
+
llmServesDirect,
|
|
414
|
+
LLM_CREDIT_RUNGS,
|
|
415
|
+
type LlmCreditRung,
|
|
416
|
+
llmCreditIdForRung,
|
|
417
|
+
llmTierCreditIds,
|
|
413
418
|
availableReasoningEfforts,
|
|
414
419
|
LLM_ROUTE_DEFAULTS,
|
|
415
420
|
llmRouteDefaults,
|
|
@@ -1336,6 +1341,13 @@ export {
|
|
|
1336
1341
|
// Per-model safety-filter retry/fallback policy (derives from
|
|
1337
1342
|
// `ModelCatalogEntry.safetyFilter` above).
|
|
1338
1343
|
export { safetyRetryPolicy } from "./safety-retry-policy.js"
|
|
1344
|
+
export {
|
|
1345
|
+
IMAGE_MODEL_ROLE_DEFAULTS,
|
|
1346
|
+
IMAGE_MODEL_RATIO_FALLBACKS,
|
|
1347
|
+
defaultImageModel,
|
|
1348
|
+
imageModelDrawsRatio,
|
|
1349
|
+
} from "./image-model-roles.js"
|
|
1350
|
+
export type { ImageModelRole } from "./image-model-roles.js"
|
|
1339
1351
|
export type { SafetyRetryPolicy } from "./safety-retry-policy.js"
|
|
1340
1352
|
|
|
1341
1353
|
export {
|
|
@@ -1567,6 +1579,8 @@ export {
|
|
|
1567
1579
|
|
|
1568
1580
|
export * from "./fan-out-meta.js"
|
|
1569
1581
|
|
|
1582
|
+
export { loneMediaUrlKind, isLoneMediaLinkSource } from "./lone-media-url.js"
|
|
1583
|
+
export type { LoneMediaUrlKind } from "./lone-media-url.js"
|
|
1570
1584
|
export { SUNO_TRACK_SOURCE_TYPES } from "./suno-track-sources.js"
|
|
1571
1585
|
|
|
1572
1586
|
export { isPrivateOrReservedIP, isLocalOrPrivateHostname } from "./private-host.js"
|