@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
package/src/llm-models.ts CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  export type LlmTier = "economy" | "standard" | "premium"
17
17
  export type KieApiFormat = "chat-completions" | "messages" | "responses"
18
- export type LlmVendor = "anthropic" | "google" | "openai" | "xai"
18
+ export type LlmVendor = "anthropic" | "deepseek" | "google" | "moonshot" | "openai" | "xai"
19
19
 
20
20
  export const LLM_REASONING_EFFORTS = ["none", "low", "medium", "high", "xhigh", "max"] as const
21
21
  export type LlmReasoningEffort = (typeof LLM_REASONING_EFFORTS)[number]
@@ -92,6 +92,44 @@ export interface LlmModelDef {
92
92
  directReasoningEfforts?: readonly LlmReasoningEffort[]
93
93
  /** false = model rejects `temperature` (Claude 5-era, GPT-5.6). Absent = accepts. */
94
94
  supportsTemperature?: false
95
+ /**
96
+ * false = the model 400s on a FORCED `tool_choice` (`{ type: "tool" }` /
97
+ * `{ type: "any" }`) — Claude Sonnet 5.5 and Opus 5.5 (vendor docs: "not
98
+ * supported for this model"). Absent = forcing is accepted.
99
+ *
100
+ * Only meaningful with `structuredOutputMode: "anthropic-tool"`: such a model
101
+ * is asked with `tool_choice: auto` plus an instruction naming the tool, and
102
+ * the tool carries `strict: true` whenever its schema is expressible in the
103
+ * vendor's strict subset (`anthropicStrictToolSchema` in llm-client). The
104
+ * caller's Zod still validates every answer, so nothing the wire withholds is
105
+ * lost. Declared per model, never matched on a model name.
106
+ */
107
+ supportsForcedToolChoice?: false
108
+ /**
109
+ * true = the model binds each thinking block to the exact conversation prefix
110
+ * that produced it ("preserved thinking" — Claude Sonnet 5.5 / Opus 5.5 /
111
+ * Haiku 5.5):
112
+ * replaying a block after an earlier turn was edited, dropped or rebuilt is a
113
+ * 400 on accounts the vendor enforces. A caller that trims or rebuilds stored
114
+ * history between requests (the Workflow Copilot keeps a token budget by
115
+ * dropping its oldest turns) must strip thinking blocks from the turns it
116
+ * replays. Within one request's own tool loop the history only grows, so
117
+ * blocks produced there stay valid.
118
+ */
119
+ conversationBoundThinking?: true
120
+ /**
121
+ * true = this model's reasoning effort takes effect ONLY on the vendor's own
122
+ * API: the aggregator accepts the field and silently ignores it. Measured
123
+ * 2026-10-08 for the Claude family on KIE — `low`, `max` and no effort gave
124
+ * the same output length on a reasoning-heavy prompt, and no thinking block
125
+ * ever came back, even on Sonnet 4.6 at `max`.
126
+ *
127
+ * So an effort-bearing call on such a model is SERVED direct, and it bills
128
+ * as Advanced mode does — one rung up (decided 2026-10-08: "effort =
129
+ * Advanced"). {@link llmServesDirect} is the one place that decides it, for
130
+ * the credit identifier and the routing alike.
131
+ */
132
+ effortRequiresDirect?: true
95
133
  /** Claude-only: KIE is the preferred routing, direct Anthropic the fallback. */
96
134
  preferKie?: true
97
135
  /**
@@ -297,7 +335,8 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
297
335
  {
298
336
  id: "claude-haiku-4.5",
299
337
  displayName: "Claude Haiku 4.5",
300
- desc: "Fast economy, good reasoning",
338
+ // Demoted 2026-10-10 when claude-haiku-5.5 registered.
339
+ desc: "Previous Haiku, fast economy",
301
340
  tier: "economy",
302
341
  kieFormat: "messages",
303
342
  kieSlugOrModel: "claude-haiku-4-5",
@@ -306,6 +345,52 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
306
345
  supportsImages: true,
307
346
  maxOutputTokens: 8192,
308
347
  directFallbackModel: "claude-haiku-4-5-20251001",
348
+ // KIE-first since 2026-10-08 (a call is priced on the lane it runs on);
349
+ // KIE served it plain and with a tool on its streaming wire that day.
350
+ preferKie: true,
351
+ },
352
+ {
353
+ id: "claude-haiku-5.5",
354
+ displayName: "Claude Haiku 5.5",
355
+ desc: "Latest Haiku, fast and low-cost with reasoning",
356
+ tier: "economy",
357
+ kieFormat: "messages",
358
+ // KIE plain id on the Claude-native messages dialect
359
+ // (docs.kie.ai/market/claude/claude-haiku-5-5.md). Live-probed 2026-10-10
360
+ // on the streaming wire: plain, system prompt, base64 image, a forced tool
361
+ // and an auto + strict tool (both came back as a real tool_use block), and
362
+ // `max_tokens: 32768` were all served.
363
+ kieSlugOrModel: "claude-haiku-5-5",
364
+ vendor: "anthropic",
365
+ structuredOutputMode: "anthropic-tool",
366
+ // NO `supportsForcedToolChoice: false`, unlike Sonnet 5.5 / Opus 5.5: this
367
+ // model ACCEPTS a forced tool_choice (probed on Anthropic's API 2026-10-10).
368
+ // A forced call skips thinking (same usage with and without an effort), and
369
+ // an effort-bearing structured call is already sent the auto choice.
370
+ //
371
+ // A thinking block is valid only while everything before it is unchanged
372
+ // (vendor docs: the same history check the other 5.5 models run).
373
+ conversationBoundThinking: true,
374
+ supportsImages: true,
375
+ maxOutputTokens: 16384,
376
+ directFallbackModel: "claude-haiku-5-5",
377
+ // The first Haiku with effort levels. The vendor default is `medium`, where
378
+ // most of the family defaults to `high`.
379
+ reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
380
+ // KIE ignores effort on this slug too — measured 2026-10-10 on a
381
+ // reasoning-heavy prompt: none / low / max / KIE's own `thinkingFlag` gave
382
+ // 2,076 / 1,886 / 2,223 / 1,927 output tokens and no thinking block, while
383
+ // Anthropic's API gave 2,059 at low and 28,097 at max. An effort call runs
384
+ // direct and bills as Advanced.
385
+ effortRequiresDirect: true,
386
+ // Anthropic 400s a non-default sampling value ("`temperature` is deprecated
387
+ // for this model", probed 2026-10-10); KIE's proxy accepted temperature: 0.2.
388
+ supportsTemperature: false,
389
+ preferKie: true,
390
+ // Adaptive thinking runs when no thinking param is sent (vendor default),
391
+ // on BOTH lanes: a no-effort KIE call spent ~2,000 output tokens on a
392
+ // ~350-token answer and returned no thinking block.
393
+ thinkingDefaultOn: true,
309
394
  },
310
395
  {
311
396
  id: "claude-sonnet-4.6",
@@ -319,7 +404,12 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
319
404
  supportsImages: true,
320
405
  maxOutputTokens: 16384,
321
406
  directFallbackModel: "claude-sonnet-4-6",
407
+ // KIE-first since 2026-10-08 (a call is priced on the lane it runs on);
408
+ // KIE served it plain and with a tool on its streaming wire that day.
409
+ preferKie: true,
322
410
  reasoningEfforts: ["low", "medium", "high", "max"],
411
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
412
+ effortRequiresDirect: true,
323
413
  },
324
414
  {
325
415
  id: "gpt-5.2",
@@ -358,14 +448,14 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
358
448
  // text such as a name badge), which is exactly what video-analysis casts
359
449
  // identities from — so adding an entry here would silently move analysis to
360
450
  // the shallower lane. Don't. Full comparison lives with the analysis engine.
361
- // The ONE Gemini model routed direct-first. It is the premium/low-volume
362
- // tier (video-analysis `pro`, no LLM_FEATURE_DEFAULTS entry), so the ~4×
363
- // list-price premium lands on the smallest call volume — and it is where
364
- // the direct lane's capability wins actually matter: real `thinkingLevel`
365
- // control, native media ingestion, and a `responseJsonSchema` that honours
366
- // `additionalProperties` (KIE's `response_format` silently DROPS
451
+ // KIE-first since 2026-10-08 (decided: a call is priced on the lane it runs
452
+ // on, so the base premium price buys the KIE lane; the direct lane is
453
+ // Advanced mode, billed `premium-direct`). It was the one direct-first
454
+ // Gemini before. What the direct lane buys, now behind Advanced: real
455
+ // `thinkingLevel` control, native media ingestion, and a `responseJsonSchema`
456
+ // that honours `additionalProperties` (KIE's `response_format` silently DROPS
367
457
  // record/map-shaped fields — see the z.record rule in backend/CLAUDE.md).
368
- preferDirect: true,
458
+ // Video-analysis is unaffected: it pins `requireLane: "direct"` itself.
369
459
  // Reasons with no thinking param sent on both lanes — the proxied endpoint
370
460
  // DEFAULTS to "high" (above), and the direct lane reasons harder still.
371
461
  // Floored at its own 16384: its KIE fallback is not known to take more.
@@ -389,6 +479,8 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
389
479
  maxOutputTokens: 16384,
390
480
  directFallbackModel: "claude-opus-4-7",
391
481
  reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
482
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
483
+ effortRequiresDirect: true,
392
484
  supportsTemperature: false,
393
485
  preferKie: true,
394
486
  },
@@ -538,10 +630,76 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
538
630
  // why this is per-model and not a lane-wide flag.
539
631
  kieCollapseStream: true,
540
632
  },
633
+ // ── GPT-6 Luna / Sol / 6.1 Sol ────────────────────────────────────────────
634
+ // Same KIE endpoint and dialect as gpt-6-astra (codex/v1/responses; the doc
635
+ // pages differ only in the model name). Live-probed 2026-10-08, per model:
636
+ // `text.format` json_schema ENFORCED (echo `strict: true`, schema-valid
637
+ // reply), `temperature: 0.2` echoed back as 1 → silently ignored, no
638
+ // reasoning param → echo "medium" (reasons by default), and data-URI vision.
639
+ // Unlike astra, the NON-stream lane served them reliably — luna 10/10 and sol
640
+ // 10/10, 6.1 sol 8/8 at levels other than `none` (incl. 4 long structured
641
+ // calls each, 500–1,500 output tokens) — so none of them is collapsed:
642
+ // `credits_consumed` stays the real provider charge.
643
+ // Their ladder is WIDER than astra's doc-enum one: `none` and `max` were each
644
+ // sent and echoed back by the endpoint (6.1 sol excepted below).
645
+ {
646
+ id: "gpt-6-luna",
647
+ displayName: "GPT-6 Luna",
648
+ desc: "Fastest GPT-6, high-volume workloads",
649
+ tier: "economy",
650
+ kieFormat: "responses",
651
+ kieSlugOrModel: "gpt-6-luna",
652
+ vendor: "openai",
653
+ structuredOutputMode: "responses-json-schema",
654
+ supportsImages: true,
655
+ maxOutputTokens: 16384,
656
+ reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max"],
657
+ supportsTemperature: false,
658
+ thinkingDefaultOn: true,
659
+ },
660
+ {
661
+ id: "gpt-6-sol",
662
+ displayName: "GPT-6 Sol",
663
+ desc: "Strong GPT-6, deep reasoning at lower cost",
664
+ // Premium by decision (2026-10-08), not by unit cost — "Sol" is the
665
+ // deep-reasoning rung of the family, and gpt-5.6-sol bills premium too.
666
+ tier: "premium",
667
+ kieFormat: "responses",
668
+ kieSlugOrModel: "gpt-6-sol",
669
+ vendor: "openai",
670
+ structuredOutputMode: "responses-json-schema",
671
+ supportsImages: true,
672
+ maxOutputTokens: 16384,
673
+ reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max"],
674
+ supportsTemperature: false,
675
+ thinkingDefaultOn: true,
676
+ },
677
+ {
678
+ id: "gpt-6.1-sol",
679
+ displayName: "GPT-6.1 Sol",
680
+ // Measured slow: 30–76 s for 500–1,100 output tokens (2026-10-08), roughly
681
+ // twice gpt-6-sol on the same request — say so where the picker shows it.
682
+ desc: "Newest GPT-6 Sol, thorough but slower",
683
+ tier: "premium",
684
+ kieFormat: "responses",
685
+ kieSlugOrModel: "gpt-6-1-sol",
686
+ vendor: "openai",
687
+ structuredOutputMode: "responses-json-schema",
688
+ supportsImages: true,
689
+ maxOutputTokens: 16384,
690
+ // NO `none`: every probe at `reasoning.effort: none` failed (502, a 120 s
691
+ // timeout, 502, 429 — 0/4, 2026-10-08) while every other level answered,
692
+ // and the same request at `none` succeeded on luna and sol. Clamping maps a
693
+ // `none` request to nothing sent (Auto) rather than to a level that fails.
694
+ reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
695
+ supportsTemperature: false,
696
+ thinkingDefaultOn: true,
697
+ },
541
698
  {
542
699
  id: "grok-4.6",
543
700
  displayName: "Grok 4.6",
544
- desc: "xAI flagship, strong reasoning",
701
+ // Demoted 2026-10-08 when grok-4.7 registered — the flagship copy moved up.
702
+ desc: "Previous Grok, strong reasoning",
545
703
  tier: "standard",
546
704
  kieFormat: "responses",
547
705
  // KIE serves Grok on the responses dialect under its own family path —
@@ -567,10 +725,35 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
567
725
  // call needs output headroom, not just xhigh.
568
726
  thinkingDefaultOn: true,
569
727
  },
728
+ {
729
+ id: "grok-4.7",
730
+ displayName: "Grok 4.7",
731
+ desc: "xAI flagship, strong reasoning",
732
+ tier: "standard",
733
+ kieFormat: "responses",
734
+ // Same grok/v1/responses family path and wire as grok-4.6 (the KIE doc
735
+ // pages differ only in the model name). Live-probed 2026-10-08: non-stream
736
+ // 6/6, `text.format` json_schema enforced, data-URI vision, SSE deltas.
737
+ kieSlugOrModel: "grok-4-7",
738
+ vendor: "xai",
739
+ structuredOutputMode: "responses-json-schema",
740
+ supportsImages: true,
741
+ maxOutputTokens: 16384,
742
+ // 4.6's ladder. `none` is NOT honoured: the endpoint echoed it back as
743
+ // "minimal" and still reasoned (33 of 35 output tokens), so offering it
744
+ // would promise a lever the wire overrides.
745
+ reasoningEfforts: ["low", "medium", "high", "xhigh"],
746
+ // `temperature: 0.2` → echo stayed at the 0.7 default: ignored.
747
+ supportsTemperature: false,
748
+ // "Capital of France" with no reasoning param spent 310 of 311 output
749
+ // tokens reasoning.
750
+ thinkingDefaultOn: true,
751
+ },
570
752
  {
571
753
  id: "claude-sonnet-5",
572
754
  displayName: "Claude Sonnet 5",
573
- desc: "Near-Opus quality at Sonnet cost",
755
+ // Demoted 2026-10-08 when claude-sonnet-5.5 registered.
756
+ desc: "Previous Sonnet, near-Opus quality",
574
757
  tier: "standard",
575
758
  kieFormat: "messages",
576
759
  kieSlugOrModel: "claude-sonnet-5",
@@ -580,9 +763,43 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
580
763
  maxOutputTokens: 16384,
581
764
  directFallbackModel: "claude-sonnet-5",
582
765
  reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
766
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
767
+ effortRequiresDirect: true,
583
768
  supportsTemperature: false,
584
769
  preferKie: true,
585
770
  },
771
+ {
772
+ id: "claude-sonnet-5.5",
773
+ displayName: "Claude Sonnet 5.5",
774
+ desc: "Latest Sonnet, near-Opus quality at Sonnet cost",
775
+ tier: "standard",
776
+ kieFormat: "messages",
777
+ // KIE serves it on the Claude-native messages dialect under its plain id
778
+ // (docs.kie.ai/market/claude/claude-sonnet-5-5.md — the page is
779
+ // claude-opus-5's with the model name swapped). Live-probed 2026-10-08 on
780
+ // the streaming wire: plain, effort, and forced/auto+strict tool calls all
781
+ // answered.
782
+ kieSlugOrModel: "claude-sonnet-5-5",
783
+ vendor: "anthropic",
784
+ structuredOutputMode: "anthropic-tool",
785
+ // Anthropic 400s a forced tool_choice on this model. KIE's proxy happened
786
+ // to accept one in the probe, but the direct lane is where every
787
+ // effort-bearing and every streamed structured call goes.
788
+ supportsForcedToolChoice: false,
789
+ conversationBoundThinking: true,
790
+ supportsImages: true,
791
+ maxOutputTokens: 16384,
792
+ directFallbackModel: "claude-sonnet-5-5",
793
+ reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
794
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
795
+ effortRequiresDirect: true,
796
+ // Anthropic rejects non-default sampling values on this model (KIE's proxy
797
+ // accepted temperature: 0.2 in the probe; the direct lane is the contract).
798
+ supportsTemperature: false,
799
+ preferKie: true,
800
+ // Adaptive thinking runs when no thinking param is sent (vendor default).
801
+ thinkingDefaultOn: true,
802
+ },
586
803
  {
587
804
  id: "claude-opus-4.8",
588
805
  displayName: "Claude Opus 4.8",
@@ -596,13 +813,16 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
596
813
  maxOutputTokens: 16384,
597
814
  directFallbackModel: "claude-opus-4-8",
598
815
  reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
816
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
817
+ effortRequiresDirect: true,
599
818
  supportsTemperature: false,
600
819
  preferKie: true,
601
820
  },
602
821
  {
603
822
  id: "claude-opus-5",
604
823
  displayName: "Claude Opus 5",
605
- desc: "Latest Opus, deepest agentic reasoning",
824
+ // Demoted 2026-10-08 when claude-opus-5.5 registered.
825
+ desc: "Previous Opus, deep agentic reasoning",
606
826
  tier: "premium",
607
827
  kieFormat: "messages",
608
828
  // KIE serves Opus 5 on the Claude-native messages dialect under the plain
@@ -615,12 +835,44 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
615
835
  maxOutputTokens: 16384,
616
836
  directFallbackModel: "claude-opus-5",
617
837
  reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
838
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
839
+ effortRequiresDirect: true,
618
840
  supportsTemperature: false,
619
841
  preferKie: true,
620
842
  // Opus 5 reasons with NO thinking param sent (vendor default flipped from
621
843
  // Opus 4.8/4.7) — so every call needs output headroom, not just xhigh/max.
622
844
  thinkingDefaultOn: true,
623
845
  },
846
+ {
847
+ id: "claude-opus-5.5",
848
+ displayName: "Claude Opus 5.5",
849
+ // Positioned as Fable-class (decided 2026-10-08: offered wherever Fable is).
850
+ desc: "Latest Opus, frontier-class reasoning",
851
+ tier: "premium",
852
+ kieFormat: "messages",
853
+ // KIE plain id on the messages dialect (docs.kie.ai/market/claude/
854
+ // claude-opus-5-5 — claude-opus-5's page with the name swapped).
855
+ // Live-probed 2026-10-08 on the streaming wire (plain + effort); the KIE
856
+ // Claude lane was erroring for claude-opus-5 too during the tool probes.
857
+ kieSlugOrModel: "claude-opus-5-5",
858
+ vendor: "anthropic",
859
+ structuredOutputMode: "anthropic-tool",
860
+ // Forced tool_choice is a 400 on this model (vendor docs) — see the field.
861
+ supportsForcedToolChoice: false,
862
+ conversationBoundThinking: true,
863
+ supportsImages: true,
864
+ maxOutputTokens: 16384,
865
+ directFallbackModel: "claude-opus-5-5",
866
+ reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
867
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
868
+ effortRequiresDirect: true,
869
+ supportsTemperature: false,
870
+ preferKie: true,
871
+ // Thinking cannot be turned off on this model at all (`disabled` is a 400
872
+ // at every effort); with no effort sent it runs adaptive at the vendor's
873
+ // `medium` default. Nothing on our wire sends `disabled`.
874
+ thinkingDefaultOn: true,
875
+ },
624
876
  {
625
877
  id: "claude-fable-5",
626
878
  displayName: "Claude Fable 5",
@@ -634,8 +886,63 @@ export const LLM_MODELS: readonly LlmModelDef[] = [
634
886
  maxOutputTokens: 16384,
635
887
  directFallbackModel: "claude-fable-5",
636
888
  reasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
889
+ // KIE ignores Claude effort (measured 2026-10-08): an effort call runs direct and bills as Advanced.
890
+ effortRequiresDirect: true,
637
891
  supportsTemperature: false,
638
892
  preferKie: true,
893
+ // Thinking is always on (vendor docs: `disabled` is not supported), so it
894
+ // shares the output cap on every call.
895
+ thinkingDefaultOn: true,
896
+ },
897
+ // ── Moonshot / DeepSeek ───────────────────────────────────────────────────
898
+ // Both on KIE's THIRD responses family path, openai/v1/responses (llm-client
899
+ // derives it from `vendor`). KIE labels both pages "Chat only — not adapted
900
+ // for agent use": fine for single (structured) completions, so neither may
901
+ // back a tool-loop feature.
902
+ {
903
+ id: "kimi-k3",
904
+ displayName: "Kimi K3",
905
+ desc: "Moonshot flagship, 1M context, careful reasoning",
906
+ tier: "premium",
907
+ kieFormat: "responses",
908
+ kieSlugOrModel: "kimi-k3",
909
+ vendor: "moonshot",
910
+ // Live-probed 2026-10-08: `text.format` json_schema is ENFORCED — asked to
911
+ // answer "no json here" in plain prose, it returned schema-shaped JSON.
912
+ structuredOutputMode: "responses-json-schema",
913
+ supportsImages: true,
914
+ maxOutputTokens: 16384,
915
+ // KIE's documented enum. The endpoint accepted xhigh/none without error but
916
+ // never echoes an effort back, so nothing beyond the doc is verifiable.
917
+ reasoningEfforts: ["low", "medium", "high"],
918
+ // The doc lists no `temperature` field at all.
919
+ supportsTemperature: false,
920
+ // "Reasons by default" per KIE's doc (its usage reports no reasoning-token
921
+ // split, so this is the doc's word, not a measurement).
922
+ thinkingDefaultOn: true,
923
+ },
924
+ {
925
+ id: "deepseek-v4.1-flash",
926
+ displayName: "DeepSeek V4.1 Flash",
927
+ desc: "Very cheap and fast, solid reasoning",
928
+ tier: "economy",
929
+ kieFormat: "responses",
930
+ kieSlugOrModel: "deepseek-v4-1-flash",
931
+ vendor: "deepseek",
932
+ // Live-probed 2026-10-08: json_schema echoed `strict: true` and enforced.
933
+ structuredOutputMode: "responses-json-schema",
934
+ supportsImages: true,
935
+ // ADVISORY ONLY: KIE documents `max_output_tokens` as "not supported … no
936
+ // effect" on this model (a probe sending it was accepted and ignored), so
937
+ // neither this cap nor the reasoning floor binds its output length, and the
938
+ // `incomplete` cap-stop signal cannot fire from our own cap.
939
+ maxOutputTokens: 16384,
940
+ // The endpoint takes none/minimal/low/medium/high/xhigh/max; each of none,
941
+ // low and xhigh was echoed back. `minimal` is not in our ladder.
942
+ reasoningEfforts: ["none", "low", "medium", "high", "xhigh", "max"],
943
+ // Documented "not supported … no effect".
944
+ supportsTemperature: false,
945
+ thinkingDefaultOn: true,
639
946
  },
640
947
  ] as const
641
948
 
@@ -658,10 +965,12 @@ export const STRUCTURED_VISION_MODELS = LLM_MODELS.filter(
658
965
  * ship with its models silently sorted to the end of every menu unlabeled.
659
966
  * Alphabetical on purpose: stable, and no vendor-preference fights.
660
967
  */
661
- export const LLM_VENDOR_ORDER: readonly LlmVendor[] = ["anthropic", "google", "openai", "xai"]
968
+ export const LLM_VENDOR_ORDER: readonly LlmVendor[] = ["anthropic", "deepseek", "google", "moonshot", "openai", "xai"]
662
969
  export const LLM_VENDOR_LABELS: Record<LlmVendor, string> = {
663
970
  anthropic: "Anthropic",
971
+ deepseek: "DeepSeek",
664
972
  google: "Google",
973
+ moonshot: "Moonshot AI",
665
974
  openai: "OpenAI",
666
975
  xai: "xAI",
667
976
  }
@@ -763,7 +1072,9 @@ export const LLM_FEATURE_DEFAULTS: Record<LlmFeature, string> = {
763
1072
  // runs once per returned ad — volume, not depth. Must stay an image-capable
764
1073
  // structured-output model (STRUCTURED_VISION_MODELS); a registry test pins it.
765
1074
  "meta-ads-analysis": "gemini-3.6-flash",
766
- "describe-to-picker": "claude-opus-5",
1075
+ // Moved from claude-opus-5 on 2026-10-08 (decided: Opus 5.5 takes the Opus 5
1076
+ // defaults). Still an image-capable structured model — a registry test pins it.
1077
+ "describe-to-picker": "claude-opus-5.5",
767
1078
  "qa-check": "gemini-3.6-flash",
768
1079
  "generate-script": "gemini-3.6-flash",
769
1080
  "translate": "gemini-3.6-flash",
@@ -777,6 +1088,42 @@ export const LLM_FEATURE_DEFAULTS: Record<LlmFeature, string> = {
777
1088
  "content-ideas": "gemini-3.6-flash",
778
1089
  }
779
1090
 
1091
+ /**
1092
+ * Feature → the reasoning effort its DEFAULT model runs at when the caller
1093
+ * sends none. Read it through {@link defaultReasoningEffort}, never directly:
1094
+ * the effort belongs to the default model, so a call on any other model must
1095
+ * not pick it up.
1096
+ */
1097
+ export const LLM_FEATURE_DEFAULT_EFFORTS: Partial<Record<LlmFeature, LlmReasoningEffort>> = {
1098
+ // Decided 2026-10-09 from the picker bake-off v2: Opus 5.5 at `high` read
1099
+ // 4/4 portraits with the most attributes per image, ~9 s a read. Its effort
1100
+ // only takes effect on Anthropic's own API (`effortRequiresDirect`), so the
1101
+ // default analysis runs direct — and bills as such (`llmServesDirect`).
1102
+ "describe-to-picker": "high",
1103
+ }
1104
+
1105
+ /**
1106
+ * The reasoning effort a `feature` call runs at when the caller sends none:
1107
+ * the feature's default effort ({@link LLM_FEATURE_DEFAULT_EFFORTS}), but ONLY
1108
+ * while the call runs on the feature's default model — named, or omitted
1109
+ * (`undefined` / `""`) so the default model applies. A caller who picked
1110
+ * another model and no effort gets `undefined`: that model's Auto, as before.
1111
+ *
1112
+ * WHY only on the default model: the default effort is part of the default
1113
+ * model's recipe, not a global policy. Forcing `high` on a Gemini or GPT call
1114
+ * that never asked for it would change the timing of every existing workflow
1115
+ * that picked one (and, on a Claude model, its lane and its bill).
1116
+ *
1117
+ * The one place the route, the node's credit badge and its effort pickers
1118
+ * read, so what runs, what is billed and what is shown cannot disagree.
1119
+ */
1120
+ export function defaultReasoningEffort(feature: string, modelId?: string): LlmReasoningEffort | undefined {
1121
+ const effort = LLM_FEATURE_DEFAULT_EFFORTS[feature as LlmFeature]
1122
+ if (!effort) return undefined
1123
+ if (!modelId) return effort
1124
+ return getLlmModel(modelId)?.id === LLM_FEATURE_DEFAULTS[feature as LlmFeature] ? effort : undefined
1125
+ }
1126
+
780
1127
  /**
781
1128
  * Per-model multimodal input capabilities. Drives both frontend UI gating
782
1129
  * and backend route-level filtering for the LLM Chat node references.
@@ -806,6 +1153,7 @@ export const LLM_MODALITY_CAPS: Record<string, { image: boolean; video: boolean;
806
1153
  "gemini-3.8-flash": { image: true, video: false, audio: false },
807
1154
  "gemini-3.1-pro": { image: true, video: true, audio: true },
808
1155
  "claude-haiku-4.5": { image: true, video: false, audio: false },
1156
+ "claude-haiku-5.5": { image: true, video: false, audio: false },
809
1157
  "claude-sonnet-4.6": { image: true, video: false, audio: false },
810
1158
  "claude-opus-4.7": { image: true, video: false, audio: false },
811
1159
  "gpt-5.2": { image: true, video: false, audio: false },
@@ -816,11 +1164,21 @@ export const LLM_MODALITY_CAPS: Record<string, { image: boolean; video: boolean;
816
1164
  "gpt-5.6-sol": { image: true, video: false, audio: false },
817
1165
  // KIE's GPT-6 doc lists text + image + file inputs only — no video, no audio.
818
1166
  "gpt-6-astra": { image: true, video: false, audio: false },
1167
+ // Same KIE doc as astra: text + image + file inputs only.
1168
+ "gpt-6-luna": { image: true, video: false, audio: false },
1169
+ "gpt-6-sol": { image: true, video: false, audio: false },
1170
+ "gpt-6.1-sol": { image: true, video: false, audio: false },
819
1171
  "grok-4.6": { image: true, video: false, audio: false },
1172
+ "grok-4.7": { image: true, video: false, audio: false },
820
1173
  "claude-sonnet-5": { image: true, video: false, audio: false },
1174
+ "claude-sonnet-5.5": { image: true, video: false, audio: false },
821
1175
  "claude-opus-4.8": { image: true, video: false, audio: false },
822
1176
  "claude-opus-5": { image: true, video: false, audio: false },
1177
+ "claude-opus-5.5": { image: true, video: false, audio: false },
823
1178
  "claude-fable-5": { image: true, video: false, audio: false },
1179
+ // KIE documents text + image input only for both.
1180
+ "kimi-k3": { image: true, video: false, audio: false },
1181
+ "deepseek-v4.1-flash": { image: true, video: false, audio: false },
824
1182
  }
825
1183
 
826
1184
  /** Capability lookup with safe default — unknown models get image-only. */
@@ -971,13 +1329,59 @@ function bumpTier(tier: LlmTier): LlmTier {
971
1329
  * rather than on a hand-maintained model list.
972
1330
  */
973
1331
  export function supportsAdvancedMode(modelId: string | undefined): boolean {
974
- return Boolean(modelId && getLlmModel(modelId)?.directGeminiModel)
1332
+ const model = modelId ? getLlmModel(modelId) : undefined
1333
+ return Boolean(model?.directGeminiModel || model?.directFallbackModel)
975
1334
  }
976
1335
 
977
1336
  /** User-facing reason a model can't offer Advanced mode. Single-sourced so the
978
1337
  * config panel's disabled hint and the route's 400 say the same thing. */
979
1338
  export const ADVANCED_MODE_UNAVAILABLE_REASON =
980
- "Advanced mode is available on Gemini models — switch the model to enable it."
1339
+ "Advanced mode is available on Gemini and Claude models — switch the model to enable it."
1340
+
1341
+ /**
1342
+ * Is this call served on the vendor's own API — and therefore billed as such?
1343
+ *
1344
+ * The rule (decided 2026-10-08): a call is priced on the lane it runs on.
1345
+ * It runs direct when Advanced mode is on, or when it carries a reasoning
1346
+ * effort on a model whose effort only works there (`effortRequiresDirect` —
1347
+ * the Claude family). Everything else runs on the aggregator at its price,
1348
+ * falling back to the vendor's API only if the aggregator fails (at no extra
1349
+ * charge).
1350
+ *
1351
+ * The SINGLE decision both the credit identifier and the LLM client's routing
1352
+ * read, so what is billed and where it runs cannot disagree. Ignores a stale
1353
+ * `advancedMode` on a model with no direct lane, like the bump always has.
1354
+ */
1355
+ export function llmServesDirect(
1356
+ modelId: string | undefined,
1357
+ reasoningEffort?: string,
1358
+ advancedMode?: boolean,
1359
+ ): boolean {
1360
+ if (!supportsAdvancedMode(modelId)) return false
1361
+ if (advancedMode) return true
1362
+ return Boolean(
1363
+ getLlmModel(modelId!)?.effortRequiresDirect && effectiveReasoningEffort(modelId, reasoningEffort) !== undefined,
1364
+ )
1365
+ }
1366
+
1367
+ /**
1368
+ * The credit rungs an LLM feature bills on, cheapest first. `premium-direct` is
1369
+ * reached only by a premium model served direct (decided 2026-10-08): the bump
1370
+ * for running direct moves one rung on THIS ladder, so a premium model has
1371
+ * somewhere to go. The effort bump keeps the three-rung ladder.
1372
+ */
1373
+ export const LLM_CREDIT_RUNGS = ["economy", "standard", "premium", "premium-direct"] as const
1374
+ export type LlmCreditRung = (typeof LLM_CREDIT_RUNGS)[number]
1375
+
1376
+ /** The credit identifier for `feature` on one rung — the standard rung is the bare feature id. */
1377
+ export function llmCreditIdForRung(feature: string, rung: LlmCreditRung): string {
1378
+ return rung === "standard" ? feature : `${feature}:${rung}`
1379
+ }
1380
+
1381
+ /** Every credit identifier a tier-priced LLM feature can bill under, in rung order. */
1382
+ export function llmTierCreditIds(feature: string): string[] {
1383
+ return LLM_CREDIT_RUNGS.map((rung) => llmCreditIdForRung(feature, rung))
1384
+ }
981
1385
 
982
1386
  export function buildLlmCreditIdentifier(
983
1387
  feature: string,
@@ -989,14 +1393,20 @@ export function buildLlmCreditIdentifier(
989
1393
  let tier = getLlmTier(modelId)
990
1394
  const eff = effectiveReasoningEffort(modelId, reasoningEffort)
991
1395
  if (eff !== undefined && EFFORT_TIER_BUMP.has(eff)) tier = bumpTier(tier)
992
- // Advanced mode routes to the vendor's own API, which bills materially more
993
- // per token than the aggregator. It bumps INDEPENDENTLY of the effort bump —
994
- // the two are separate cost levers and genuinely stack, so a max-effort
995
- // advanced economy call lands at premium. The bump is ignored on a model that
996
- // can't run advanced at all, so a stale flag never inflates a bill.
997
- if (advancedMode && supportsAdvancedMode(modelId)) tier = bumpTier(tier)
998
- if (tier === "standard") return feature
999
- return `${feature}:${tier}`
1396
+ // A call served on the vendor's own API (Advanced mode, or an effort on a
1397
+ // model whose effort only works there — llmServesDirect) bills materially
1398
+ // more per token than the aggregator. It bumps INDEPENDENTLY of the effort
1399
+ // bump — the two are separate cost levers and genuinely stack, so a
1400
+ // max-effort advanced economy call lands at premium — and on the four-rung
1401
+ // ladder, so a premium model served direct lands at `premium-direct`. A stale
1402
+ // flag on a model with no direct lane never inflates a bill.
1403
+ const rung: LlmCreditRung = llmServesDirect(modelId, reasoningEffort, advancedMode) ? bumpToDirectRung(tier) : tier
1404
+ return llmCreditIdForRung(feature, rung)
1405
+ }
1406
+
1407
+ /** One rung up the four-rung ladder — the direct-lane bump. */
1408
+ function bumpToDirectRung(tier: LlmTier): LlmCreditRung {
1409
+ return tier === "premium" ? "premium-direct" : bumpTier(tier)
1000
1410
  }
1001
1411
 
1002
1412
  /**