@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.
- package/dist/index.cjs +1086 -257
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +531 -97
- package/dist/index.d.ts +531 -97
- package/dist/index.js +1034 -258
- 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 +31 -6
- package/src/__tests__/dialogue-capabilities.test.ts +3 -2
- package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
- package/src/__tests__/image-model-roles.test.ts +57 -0
- package/src/__tests__/image-ref-limit.test.ts +1 -0
- package/src/__tests__/json-kinds.test.ts +179 -0
- package/src/__tests__/llm-models.test.ts +136 -37
- package/src/__tests__/lone-media-url.test.ts +78 -0
- package/src/__tests__/presentation-utils.test.ts +1 -0
- package/src/__tests__/preview-gate.test.ts +2 -2
- package/src/__tests__/pricing-default-duration.test.ts +56 -15
- package/src/__tests__/private-host.test.ts +24 -0
- package/src/__tests__/prompt-length-limits.test.ts +2 -0
- package/src/__tests__/render-nodes.test.ts +22 -3
- package/src/__tests__/tts-capabilities.test.ts +61 -1
- package/src/__tests__/video-link-input.test.ts +148 -0
- package/src/__tests__/video-link-needs.test.ts +67 -0
- package/src/__tests__/video-request-normalize.test.ts +18 -3
- package/src/condition-variables.ts +3 -1
- package/src/content-recipe-ideas.ts +5 -2
- package/src/credit-identifiers.ts +48 -37
- package/src/edit-plan-contract.ts +67 -1
- package/src/fan-out-rows.ts +2 -2
- package/src/image-model-roles.ts +62 -0
- package/src/index.ts +59 -1
- package/src/json-kinds.ts +188 -0
- package/src/llm-models.ts +348 -23
- package/src/lone-media-url.ts +57 -0
- package/src/model-catalog.ts +160 -13
- package/src/model-constants.ts +79 -43
- package/src/node-default-mappings.ts +4 -0
- package/src/pipeline-types.ts +13 -2
- package/src/presentation-utils.ts +8 -1
- package/src/private-host.ts +91 -0
- package/src/producer-types.ts +3 -0
- package/src/render-nodes.ts +12 -1
- package/src/scene-node-types.ts +17 -5
- package/src/settings-input.ts +2 -1
- package/src/social-post-readers.ts +37 -0
- package/src/video-link.ts +238 -0
- package/src/voices.ts +16 -9
package/src/model-constants.ts
CHANGED
|
@@ -78,6 +78,7 @@ export const MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
|
|
|
78
78
|
// ── higher than the 5000 default ──
|
|
79
79
|
"nano-banana-2": 20000, // docs.kie.ai/market/google/nano-banana-2
|
|
80
80
|
"nano-banana-2-lite": 20000, // docs.kie.ai/market/google/nano-banana-2-lite
|
|
81
|
+
"nano-banana-2-1": 20000, // docs.kie.ai/market/google/nanobanana-2-1
|
|
81
82
|
"nano-banana-pro": 20000, // docs.kie.ai/market/google/pro-image-to-image
|
|
82
83
|
"gpt-image-2-i2i": 20000, // docs.kie.ai/market/gpt/gpt-image-2-image-to-image
|
|
83
84
|
// GPT Image 2.5 — all four lanes document a 20000-char prompt ceiling.
|
|
@@ -101,7 +102,9 @@ export const MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
|
|
|
101
102
|
// verified == 5000 default (no entry needed): imagen4(-fast/-ultra), nano-banana,
|
|
102
103
|
// nano-banana-edit, flux, flux-flex, gpt-image-2, ideogram-v3/-edit/-remix,
|
|
103
104
|
// grok, qwen-i2i, seedream-5-pro, seedream-5-pro-i2i
|
|
104
|
-
// (docs.kie.ai/market/seedream/5-pro-text-to-image + 5-pro-image-to-image)
|
|
105
|
+
// (docs.kie.ai/market/seedream/5-pro-text-to-image + 5-pro-image-to-image),
|
|
106
|
+
// seedream-5-flash, seedream-5-flash-i2i (both "4–5000 characters";
|
|
107
|
+
// docs.kie.ai/market/seedream/5-flash-text-to-image + 5-flash-image-to-image).
|
|
105
108
|
// grok-i2i: doc states 390000 (78× its t2i sibling) — treated as a KIE schema
|
|
106
109
|
// typo and left at the 5000 default per the sanity-cap decision.
|
|
107
110
|
// UNVERIFIED (no limit stated in schema) → 5000 default: flux-kontext(-max)
|
|
@@ -490,6 +493,7 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
|
|
|
490
493
|
"nano-banana-pro",
|
|
491
494
|
"nano-banana-2",
|
|
492
495
|
"nano-banana-2-lite",
|
|
496
|
+
"nano-banana-2-1",
|
|
493
497
|
// T2I providers that auto-route to their i2i sibling when refs are attached
|
|
494
498
|
"gpt-image",
|
|
495
499
|
"gpt-image-2",
|
|
@@ -501,6 +505,7 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
|
|
|
501
505
|
"seedream",
|
|
502
506
|
"seedream-5-lite",
|
|
503
507
|
"seedream-5-pro",
|
|
508
|
+
"seedream-5-flash",
|
|
504
509
|
"flux",
|
|
505
510
|
"flux-flex",
|
|
506
511
|
// Image editing / image-to-image (reference = source image)
|
|
@@ -521,6 +526,7 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
|
|
|
521
526
|
"seedream-edit",
|
|
522
527
|
"seedream-5-lite-i2i",
|
|
523
528
|
"seedream-5-pro-i2i",
|
|
529
|
+
"seedream-5-flash-i2i",
|
|
524
530
|
"grok-i2i",
|
|
525
531
|
// Upscale / background ops (source acts as the reference)
|
|
526
532
|
"recraft-remove-bg",
|
|
@@ -556,6 +562,7 @@ export const T2I_TO_I2I_VARIANT: Record<string, string> = {
|
|
|
556
562
|
"seedream": "seedream-edit",
|
|
557
563
|
"seedream-5-lite": "seedream-5-lite-i2i",
|
|
558
564
|
"seedream-5-pro": "seedream-5-pro-i2i",
|
|
565
|
+
"seedream-5-flash": "seedream-5-flash-i2i",
|
|
559
566
|
"flux": "flux-pro-i2i",
|
|
560
567
|
"flux-flex": "flux-i2i",
|
|
561
568
|
}
|
|
@@ -576,6 +583,7 @@ export const REF_IMAGE_MAX_LIMITS: Record<string, number> = {
|
|
|
576
583
|
"nano-banana-pro": 8,
|
|
577
584
|
"nano-banana-2": 4,
|
|
578
585
|
"nano-banana-2-lite": 10,
|
|
586
|
+
"nano-banana-2-1": 10,
|
|
579
587
|
"wan-2.7": 9,
|
|
580
588
|
// grok-2 reference chain consumes exactly one image (segment-map input).
|
|
581
589
|
"grok-2-i2i": 1,
|
|
@@ -590,6 +598,8 @@ export const REF_IMAGE_MAX_LIMITS: Record<string, number> = {
|
|
|
590
598
|
"seedream-edit": 16,
|
|
591
599
|
"seedream-5-lite-i2i": 16,
|
|
592
600
|
"seedream-5-pro-i2i": 16,
|
|
601
|
+
// Flash takes at most 10 `image_urls` (docs.kie.ai/market/seedream/5-flash-image-to-image) — not the family's 16.
|
|
602
|
+
"seedream-5-flash-i2i": 10,
|
|
593
603
|
// Single-source i2i (one input image)
|
|
594
604
|
"flux-kontext": 1,
|
|
595
605
|
"flux-kontext-max": 1,
|
|
@@ -655,6 +665,7 @@ export const VARIABLE_PRICING_MODELS: Record<string, "quality" | "resolution" |
|
|
|
655
665
|
"gpt-image-2-5-sunburst-i2i": "resolution",
|
|
656
666
|
"nano-banana-pro": "resolution",
|
|
657
667
|
"nano-banana-2": "resolution",
|
|
668
|
+
"nano-banana-2-1": "resolution",
|
|
658
669
|
"flux": "resolution",
|
|
659
670
|
"flux-flex": "resolution",
|
|
660
671
|
"flux-i2i": "resolution",
|
|
@@ -683,6 +694,7 @@ export const TWO_K_RESOLUTION_PROVIDERS = new Set(["flux", "flux-pro-i2i", "flux
|
|
|
683
694
|
// Models where both 2K and 4K resolutions trigger composite credit identifiers (1K is base)
|
|
684
695
|
export const RESOLUTION_2K_4K_TIERED_PROVIDERS = new Set([
|
|
685
696
|
"nano-banana-2",
|
|
697
|
+
"nano-banana-2-1",
|
|
686
698
|
"gpt-image-2",
|
|
687
699
|
"gpt-image-2-i2i",
|
|
688
700
|
"gpt-image-2-5-flare",
|
|
@@ -712,6 +724,7 @@ export const IMAGE_GEN_PROVIDERS = [
|
|
|
712
724
|
"nano-banana-pro",
|
|
713
725
|
"nano-banana-2",
|
|
714
726
|
"nano-banana-2-lite",
|
|
727
|
+
"nano-banana-2-1",
|
|
715
728
|
"grok",
|
|
716
729
|
"grok-2",
|
|
717
730
|
"gpt-image",
|
|
@@ -726,6 +739,7 @@ export const IMAGE_GEN_PROVIDERS = [
|
|
|
726
739
|
"seedream",
|
|
727
740
|
"seedream-5-lite",
|
|
728
741
|
"seedream-5-pro",
|
|
742
|
+
"seedream-5-flash",
|
|
729
743
|
"flux-flex",
|
|
730
744
|
"flux-kontext",
|
|
731
745
|
"flux-kontext-max",
|
|
@@ -743,6 +757,7 @@ export const IMAGE_I2I_PROVIDERS = [
|
|
|
743
757
|
"nano-banana",
|
|
744
758
|
"nano-banana-2",
|
|
745
759
|
"nano-banana-2-lite",
|
|
760
|
+
"nano-banana-2-1",
|
|
746
761
|
"nano-banana-pro",
|
|
747
762
|
"grok-i2i",
|
|
748
763
|
"flux-i2i",
|
|
@@ -759,6 +774,7 @@ export const IMAGE_I2I_PROVIDERS = [
|
|
|
759
774
|
"seedream-edit",
|
|
760
775
|
"seedream-5-lite-i2i",
|
|
761
776
|
"seedream-5-pro-i2i",
|
|
777
|
+
"seedream-5-flash-i2i",
|
|
762
778
|
"flux-kontext",
|
|
763
779
|
"flux-kontext-max",
|
|
764
780
|
// Replicate Open (uncensored) — multi-image Kontext via Replicate
|
|
@@ -1216,6 +1232,7 @@ export type MotionTransferProviderType = typeof MOTION_TRANSFER_PROVIDERS[number
|
|
|
1216
1232
|
export const TTS_PROVIDERS = [
|
|
1217
1233
|
"elevenlabs-v3",
|
|
1218
1234
|
"elevenlabs-v4",
|
|
1235
|
+
"elevenlabs-v4-turbo",
|
|
1219
1236
|
"elevenlabs-turbo",
|
|
1220
1237
|
"elevenlabs-multilingual",
|
|
1221
1238
|
"elevenlabs",
|
|
@@ -1519,6 +1536,7 @@ export const IMAGE_MASK_MODE: Record<ImageGenProvider, ImageMaskMode> = {
|
|
|
1519
1536
|
"nano-banana-pro": "prompt",
|
|
1520
1537
|
"nano-banana-2": "prompt",
|
|
1521
1538
|
"nano-banana-2-lite": "prompt",
|
|
1539
|
+
"nano-banana-2-1": "prompt",
|
|
1522
1540
|
"gpt-image": "prompt",
|
|
1523
1541
|
"gpt-image-2": "prompt",
|
|
1524
1542
|
"gpt-image-2-5-flare": "prompt",
|
|
@@ -1526,6 +1544,7 @@ export const IMAGE_MASK_MODE: Record<ImageGenProvider, ImageMaskMode> = {
|
|
|
1526
1544
|
"seedream": "prompt",
|
|
1527
1545
|
"seedream-5-lite": "prompt",
|
|
1528
1546
|
"seedream-5-pro": "prompt",
|
|
1547
|
+
"seedream-5-flash": "prompt",
|
|
1529
1548
|
"qwen": "prompt",
|
|
1530
1549
|
"flux-kontext": "prompt",
|
|
1531
1550
|
"flux-kontext-max": "prompt",
|
|
@@ -2703,57 +2722,74 @@ export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio
|
|
|
2703
2722
|
}
|
|
2704
2723
|
|
|
2705
2724
|
/**
|
|
2706
|
-
*
|
|
2707
|
-
* `
|
|
2708
|
-
*
|
|
2709
|
-
*
|
|
2710
|
-
*
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
*
|
|
2734
|
-
*
|
|
2735
|
-
*
|
|
2736
|
-
*
|
|
2737
|
-
|
|
2738
|
-
|
|
2725
|
+
* @deprecated Read {@link pricedOutputDurationSec} (or the catalog's
|
|
2726
|
+
* `defaultDuration`). Kept only as a derived view of `MODEL_CATALOG` for
|
|
2727
|
+
* consumers of the published package that imported the old hand-kept map; no
|
|
2728
|
+
* pricing path reads it (`pricing-default-duration-guard.test.ts` fails the
|
|
2729
|
+
* build if one does).
|
|
2730
|
+
*/
|
|
2731
|
+
export const PRICING_DEFAULT_DURATION_SEC: Readonly<Record<string, number>> = Object.freeze(
|
|
2732
|
+
Object.fromEntries(
|
|
2733
|
+
Object.values(MODEL_CATALOG)
|
|
2734
|
+
.filter((e) => e.kind === "video" && typeof e.defaultDuration === "number")
|
|
2735
|
+
.map((e) => [e.id, e.defaultDuration as number]),
|
|
2736
|
+
),
|
|
2737
|
+
)
|
|
2738
|
+
|
|
2739
|
+
/**
|
|
2740
|
+
* The legal length nearest to `requested` — ties go to the earlier (shorter)
|
|
2741
|
+
* entry of the list. This is the SAME rule every video runner snaps a request
|
|
2742
|
+
* with (`snapToAllowedDuration` delegates here), so the length a request is
|
|
2743
|
+
* priced at and the length it renders can never be two different numbers.
|
|
2744
|
+
*/
|
|
2745
|
+
export function snapToNearestDuration(requested: number, allowed: readonly number[] | undefined): number {
|
|
2746
|
+
if (!allowed || allowed.length === 0) return requested
|
|
2747
|
+
if (allowed.includes(requested)) return requested
|
|
2748
|
+
return allowed.reduce((best, d) => (Math.abs(d - requested) < Math.abs(best - requested) ? d : best))
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
/**
|
|
2752
|
+
* The length a model renders when the request names none, from the model
|
|
2753
|
+
* catalog (`defaultDuration`); else its shortest legal length; else 5 for an id
|
|
2754
|
+
* the catalog does not list. A video model that is priced by length MUST
|
|
2755
|
+
* declare `defaultDuration` (`pricing-default-duration-sync.test.ts`).
|
|
2756
|
+
*/
|
|
2757
|
+
export function videoDefaultDurationSec(provider: string): number {
|
|
2758
|
+
const entry = MODEL_CATALOG[provider]
|
|
2759
|
+
if (typeof entry?.defaultDuration === "number") return entry.defaultDuration
|
|
2760
|
+
const shortest = entry?.durations?.length ? Math.min(...entry.durations) : undefined
|
|
2761
|
+
return shortest ?? 5
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
/**
|
|
2765
|
+
* The output seconds a video request is CHARGED at — the ONE funnel every
|
|
2766
|
+
* price path reads (the credit identifier's tier, the run reservation and
|
|
2767
|
+
* commit, the editor and server estimates, the Seedance and MiniMax
|
|
2768
|
+
* reference-video reservations and the Loop Trim refund).
|
|
2769
|
+
*
|
|
2770
|
+
* - no duration (or an unusable one) → the model's own default render length
|
|
2771
|
+
* (`MODEL_CATALOG[provider].defaultDuration`), never a global 5;
|
|
2772
|
+
* - a duration the model does not offer → the nearest one it does
|
|
2773
|
+
* ({@link snapToNearestDuration}, the runners' own rule), because that is the
|
|
2774
|
+
* length it renders;
|
|
2775
|
+
* - AUTO (`VIDEO_DURATION_AUTO`) → the model's longest clip: the model picks
|
|
2776
|
+
* the length, `commit_credits` refunds a surplus but never collects a
|
|
2777
|
+
* deficit, and the delivered clip is measured at settle time
|
|
2778
|
+
* (lib/seedance2-ref-video-settle.ts).
|
|
2779
|
+
*
|
|
2780
|
+
* A literal `?? 5` (or `?? 8`) at any pricing site re-opens the gap this closes;
|
|
2781
|
+
* `pricing-default-duration-guard.test.ts` fails the build on one.
|
|
2739
2782
|
*/
|
|
2740
2783
|
export function pricedOutputDurationSec(provider: string, requested: number | string | undefined): number {
|
|
2741
|
-
const fallback =
|
|
2784
|
+
const fallback = videoDefaultDurationSec(provider)
|
|
2742
2785
|
const parsed = typeof requested === "string" ? parseInt(requested, 10) : requested
|
|
2743
2786
|
if (parsed === undefined || Number.isNaN(parsed)) return fallback
|
|
2744
|
-
// AUTO (`VIDEO_DURATION_AUTO`): the model picks the length, so the only
|
|
2745
|
-
// safe price is the LONGEST it can render — `commit_credits` refunds a surplus
|
|
2746
|
-
// but never collects a deficit, and the delivered clip is measured at settle
|
|
2747
|
-
// time (lib/seedance2-ref-video-settle.ts). Living HERE, the one source every
|
|
2748
|
-
// tier and every scaled reservation reads, a new pricing call site reserves
|
|
2749
|
-
// the ceiling by default instead of having to remember to. Any other
|
|
2750
|
-
// non-positive value is nonsense and prices at the render default.
|
|
2751
2787
|
if (parsed <= 0) {
|
|
2752
2788
|
return isAutoVideoDuration(parsed) && supportsAutoVideoDuration(provider)
|
|
2753
2789
|
? maxVideoDurationSec(provider) ?? fallback
|
|
2754
2790
|
: fallback
|
|
2755
2791
|
}
|
|
2756
|
-
return parsed
|
|
2792
|
+
return snapToNearestDuration(parsed, MODEL_CATALOG[provider]?.durations)
|
|
2757
2793
|
}
|
|
2758
2794
|
|
|
2759
2795
|
/** Models that accept `VIDEO_DURATION_AUTO` — a catalog capability (docs.kie.ai:
|
|
@@ -161,6 +161,7 @@ const QUALITY_MAP: Record<string, QualityMapping> = {
|
|
|
161
161
|
// Image gen — resolution-style (1K/2K/4K)
|
|
162
162
|
"nano-banana-pro": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
|
|
163
163
|
"nano-banana-2": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
|
|
164
|
+
"nano-banana-2-1": { field: "resolution", values: { low: "1K", mid: "2K", high: "4K" } },
|
|
164
165
|
"flux": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
165
166
|
"flux-flex": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
166
167
|
"flux-i2i": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
@@ -180,6 +181,9 @@ const QUALITY_MAP: Record<string, QualityMapping> = {
|
|
|
180
181
|
"seedream-5-lite-i2i": { field: "quality", values: { low: "basic", mid: "basic", high: "high" } },
|
|
181
182
|
"seedream-5-pro": { field: "quality", values: { low: "basic", mid: "basic", high: "high" } },
|
|
182
183
|
"seedream-5-pro-i2i": { field: "quality", values: { low: "basic", mid: "basic", high: "high" } },
|
|
184
|
+
// Seedream 5 Flash's lever is size (sent as KIE `size`), flat-priced — resolution-style.
|
|
185
|
+
"seedream-5-flash": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
186
|
+
"seedream-5-flash-i2i": { field: "resolution", values: { low: "1K", mid: "2K", high: "2K" } },
|
|
183
187
|
// Video gen — resolution-style (720p/1080p)
|
|
184
188
|
"veo3": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
185
189
|
"veo3.1": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
package/src/pipeline-types.ts
CHANGED
|
@@ -50,7 +50,7 @@ const PipelineModelStageEnum = z.enum(PIPELINE_MODEL_STAGES)
|
|
|
50
50
|
export const PIPELINE_PINNABLE_IMAGE_MODELS = [
|
|
51
51
|
"nano-banana",
|
|
52
52
|
"nano-banana-pro",
|
|
53
|
-
"nano-banana-2",
|
|
53
|
+
"nano-banana-2-1",
|
|
54
54
|
"flux",
|
|
55
55
|
"gpt-image",
|
|
56
56
|
"gpt-image-2",
|
|
@@ -59,6 +59,17 @@ export const PIPELINE_PINNABLE_IMAGE_MODELS = [
|
|
|
59
59
|
] as const
|
|
60
60
|
export type PipelinePinnableImageModel = (typeof PIPELINE_PINNABLE_IMAGE_MODELS)[number]
|
|
61
61
|
|
|
62
|
+
// Image models no longer OFFERED as a pin but still honoured when a saved
|
|
63
|
+
// pipeline names one: Nano Banana 2.1 replaced Nano Banana 2 in the picker
|
|
64
|
+
// (decided 2026-10-08), and a pipeline pinned to NB2 before that keeps its pin.
|
|
65
|
+
export const PIPELINE_LEGACY_PINNED_IMAGE_MODELS = ["nano-banana-2"] as const
|
|
66
|
+
|
|
67
|
+
/** Every image model a pipeline's config may name: the offered pins plus the legacy ones. */
|
|
68
|
+
export const PIPELINE_ACCEPTED_IMAGE_MODELS = [
|
|
69
|
+
...PIPELINE_PINNABLE_IMAGE_MODELS,
|
|
70
|
+
...PIPELINE_LEGACY_PINNED_IMAGE_MODELS,
|
|
71
|
+
] as const
|
|
72
|
+
|
|
62
73
|
export const PIPELINE_PINNABLE_VIDEO_MODELS = [
|
|
63
74
|
"kling-turbo",
|
|
64
75
|
"kling",
|
|
@@ -91,7 +102,7 @@ export const PIPELINE_PINNABLE_SCRIPT_LLMS = [
|
|
|
91
102
|
] as const
|
|
92
103
|
export type PipelinePinnableScriptLlm = (typeof PIPELINE_PINNABLE_SCRIPT_LLMS)[number]
|
|
93
104
|
|
|
94
|
-
const ImageModelEnum = z.enum(
|
|
105
|
+
const ImageModelEnum = z.enum(PIPELINE_ACCEPTED_IMAGE_MODELS)
|
|
95
106
|
const VideoModelEnum = z.enum(PIPELINE_PINNABLE_VIDEO_MODELS)
|
|
96
107
|
const ScriptLlmEnum = z.enum(PIPELINE_PINNABLE_SCRIPT_LLMS)
|
|
97
108
|
|
|
@@ -8,6 +8,7 @@ import type { PresentationItem } from "./presentation-types.js"
|
|
|
8
8
|
import { AUDIO_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from "./producer-types.js"
|
|
9
9
|
import { canonicalizeOverrideKeys } from "./exposed-field-keys.js"
|
|
10
10
|
import { RENDER_NODE_TYPE_IDS } from "./render-nodes.js"
|
|
11
|
+
import { dropStaleVideoLinkFields } from "./video-link.js"
|
|
11
12
|
|
|
12
13
|
// ---------------------------------------------------------------------------
|
|
13
14
|
// Node type sets
|
|
@@ -35,6 +36,7 @@ export const INPUT_NODE_TYPES = new Set([
|
|
|
35
36
|
"action-fx",
|
|
36
37
|
"temporal",
|
|
37
38
|
"reference-audio",
|
|
39
|
+
"youtube-video",
|
|
38
40
|
])
|
|
39
41
|
|
|
40
42
|
const TRIGGER_NODE_TYPES = new Set([
|
|
@@ -346,6 +348,8 @@ export const INPUT_FIELD_MAP: Record<string, InputFieldSchema> = {
|
|
|
346
348
|
"upload-video": { key: "url", type: "video-url" },
|
|
347
349
|
"upload-audio": { key: "url", type: "audio-url" },
|
|
348
350
|
"reference-audio": { key: "extractedAudioUrl", type: "audio-url" },
|
|
351
|
+
// A LINK, not an upload (rule: `videoLinkInputProblem`, video-link.ts); still a `video-url` media input.
|
|
352
|
+
"youtube-video": { key: "youtubeUrl", type: "video-url" },
|
|
349
353
|
// --- Classic parameters ---
|
|
350
354
|
"provider": { key: "provider", type: "select" },
|
|
351
355
|
"style-guide": { key: "text", type: "text" }, // reads data.text (was wrongly "styleGuide")
|
|
@@ -450,7 +454,10 @@ export function mergeNodeInputOverrides(
|
|
|
450
454
|
data: Record<string, unknown>,
|
|
451
455
|
overrides: Record<string, unknown>,
|
|
452
456
|
): Record<string, unknown> {
|
|
453
|
-
const
|
|
457
|
+
const incoming = canonicalizeOverrideKeys(nodeType, overrides)
|
|
458
|
+
// A Video URL node on a new link sheds what was fetched for the old one.
|
|
459
|
+
const base = nodeType === "youtube-video" ? dropStaleVideoLinkFields(data, incoming) : data
|
|
460
|
+
const merged: Record<string, unknown> = { ...base, ...incoming }
|
|
454
461
|
const schema = nodeType ? INPUT_FIELD_MAP[nodeType] : undefined
|
|
455
462
|
if (
|
|
456
463
|
schema &&
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which hosts a server-side fetch must never be pointed at: loopback, private,
|
|
3
|
+
* link-local, cloud-metadata, multicast and reserved addresses. Pure and
|
|
4
|
+
* dependency-free, so the server's SSRF gates (`safeFetch`, `safeUrlSchema`) and
|
|
5
|
+
* the app runner's link card judge a host with the SAME rule — a link the card
|
|
6
|
+
* accepts is not one the server then refuses for its address.
|
|
7
|
+
*
|
|
8
|
+
* Literal hosts only. A name that RESOLVES to a private address is caught where
|
|
9
|
+
* the connection is made (`safeFetch` re-validates the resolved IP); nothing
|
|
10
|
+
* here does DNS.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* True if the IP belongs to a range we refuse to connect to from server-side
|
|
15
|
+
* fetches. Covers IPv4 loopback/private/link-local/cloud-metadata/multicast
|
|
16
|
+
* and the equivalent IPv6 classes (including IPv4-mapped IPv6 embeddings).
|
|
17
|
+
*/
|
|
18
|
+
export function isPrivateOrReservedIP(ip: string): boolean {
|
|
19
|
+
const v4 = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
|
|
20
|
+
if (v4) {
|
|
21
|
+
const a = Number(v4[1])
|
|
22
|
+
const b = Number(v4[2])
|
|
23
|
+
if (a === 0) return true // 0.0.0.0/8 "this network"
|
|
24
|
+
if (a === 127) return true // 127.0.0.0/8 loopback
|
|
25
|
+
if (a === 10) return true // 10.0.0.0/8 private
|
|
26
|
+
if (a === 172 && b >= 16 && b <= 31) return true // 172.16.0.0/12 private
|
|
27
|
+
if (a === 192 && b === 168) return true // 192.168.0.0/16 private
|
|
28
|
+
if (a === 169 && b === 254) return true // 169.254.0.0/16 link-local + AWS/GCP metadata
|
|
29
|
+
if (a === 100 && b >= 64 && b <= 127) return true // 100.64.0.0/10 CGN
|
|
30
|
+
if (a === 198 && (b === 18 || b === 19)) return true // 198.18.0.0/15 benchmarking
|
|
31
|
+
if (a >= 224) return true // 224.0.0.0/4 multicast + 240.0.0.0/4 reserved + 255.255.255.255
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
// IPv6. Hostnames from URL parsing come without brackets.
|
|
35
|
+
const lower = ip.toLowerCase()
|
|
36
|
+
if (lower === "::" || lower === "::1") return true // unspecified / loopback
|
|
37
|
+
if (lower.startsWith("fe80:") || lower.startsWith("fe80::")) return true // link-local fe80::/10
|
|
38
|
+
if (/^f[cd]/.test(lower)) return true // unique-local fc00::/7
|
|
39
|
+
if (lower.startsWith("ff")) return true // multicast ff00::/8
|
|
40
|
+
if (lower.startsWith("::ffff:")) {
|
|
41
|
+
// IPv4-mapped IPv6. WHATWG URL parsing normalises the dotted-quad tail
|
|
42
|
+
// into two hex quads (`::ffff:127.0.0.1` → `::ffff:7f00:1`), so handle
|
|
43
|
+
// both forms.
|
|
44
|
+
const tail = lower.slice(7)
|
|
45
|
+
if (tail.includes(".")) {
|
|
46
|
+
return isPrivateOrReservedIP(tail)
|
|
47
|
+
}
|
|
48
|
+
const parts = tail.split(":")
|
|
49
|
+
if (parts.length === 2) {
|
|
50
|
+
const hi = parseInt(parts[0] || "0", 16)
|
|
51
|
+
const lo = parseInt(parts[1] || "0", 16)
|
|
52
|
+
if (Number.isFinite(hi) && Number.isFinite(lo)) {
|
|
53
|
+
const ipv4 = `${(hi >> 8) & 0xff}.${hi & 0xff}.${(lo >> 8) & 0xff}.${lo & 0xff}`
|
|
54
|
+
return isPrivateOrReservedIP(ipv4)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Unrecognisable mapped form — fail closed, treat as reserved.
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
if (lower.startsWith("::") && lower !== "::" && lower !== "::1") {
|
|
61
|
+
// IPv4-compatible IPv6 (deprecated ::/96): the low 32 bits are an IPv4.
|
|
62
|
+
// WHATWG URL parsing presents `::127.0.0.1` as EITHER a dotted tail or two
|
|
63
|
+
// hex quads (`::7f00:1`), exactly like the ::ffff: case above — handle both,
|
|
64
|
+
// or the canonical hex form silently fails open.
|
|
65
|
+
const tail = lower.slice(2)
|
|
66
|
+
if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(tail)) {
|
|
67
|
+
return isPrivateOrReservedIP(tail)
|
|
68
|
+
}
|
|
69
|
+
const parts = tail.split(":")
|
|
70
|
+
if (parts.length === 2 && /^[0-9a-f]{1,4}$/.test(parts[0]) && /^[0-9a-f]{1,4}$/.test(parts[1])) {
|
|
71
|
+
const hi = parseInt(parts[0], 16)
|
|
72
|
+
const lo = parseInt(parts[1], 16)
|
|
73
|
+
if (Number.isFinite(hi) && Number.isFinite(lo)) {
|
|
74
|
+
return isPrivateOrReservedIP(`${(hi >> 8) & 0xff}.${hi & 0xff}.${(lo >> 8) & 0xff}.${lo & 0xff}`)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* True when a URL hostname (as `new URL(...).hostname` gives it, IPv6 still in
|
|
83
|
+
* brackets) names this machine or a private/reserved IP literal. WHATWG parsing
|
|
84
|
+
* has already folded decimal, octal and hex IPv4 spellings (`2130706433`,
|
|
85
|
+
* `0x7f.1`) into dotted form, so those are caught as IP literals.
|
|
86
|
+
*/
|
|
87
|
+
export function isLocalOrPrivateHostname(hostname: string): boolean {
|
|
88
|
+
const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "")
|
|
89
|
+
if (host === "localhost" || host.endsWith(".localhost")) return true
|
|
90
|
+
return isPrivateOrReservedIP(host)
|
|
91
|
+
}
|
package/src/producer-types.ts
CHANGED
|
@@ -54,6 +54,9 @@ export const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = new Set([
|
|
|
54
54
|
// doesn't reject face-swap → video-consumer edges that the orchestrator
|
|
55
55
|
// would happily route at runtime.
|
|
56
56
|
"face-swap",
|
|
57
|
+
// Speaker View (C3.2): an EDL rendered with its speakers framed — one VIDEO
|
|
58
|
+
// out (no audio-only render). Registered in RENDER_NODE_TYPES as well.
|
|
59
|
+
"speaker-view",
|
|
57
60
|
"video-retake",
|
|
58
61
|
// video-sfx: adds an SFX track to a video → emits a video URL. Belongs here so
|
|
59
62
|
// canvas handle validation accepts video-sfx → video-consumer edges and the
|
package/src/render-nodes.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* (by quality or otherwise — only its credit id changes), so the same key
|
|
16
16
|
* answers for `node.type` and for `jobs.job_type`.
|
|
17
17
|
*/
|
|
18
|
-
import { applyEdlCreditId } from "./credit-identifiers.js"
|
|
18
|
+
import { applyEdlCreditId, speakerViewCreditId } from "./credit-identifiers.js"
|
|
19
19
|
import type { RenderMedium } from "./render-output.js"
|
|
20
20
|
|
|
21
21
|
/** Where a render's player maps the output clock back to the master clock
|
|
@@ -60,6 +60,17 @@ export const RENDER_NODE_TYPES: Readonly<Record<string, RenderNodeDescriptor>> =
|
|
|
60
60
|
latestBatch: true,
|
|
61
61
|
jsonKind: "transcript",
|
|
62
62
|
}),
|
|
63
|
+
// Speaker View (C3.2): video only; its `json` is the EDL as it drew it (the
|
|
64
|
+
// turns split, the layouts written), so a player maps the output clock
|
|
65
|
+
// through THAT, and Add Captions never takes it for a Transcript.
|
|
66
|
+
"speaker-view": descriptor({
|
|
67
|
+
mediumOf: () => "video",
|
|
68
|
+
creditId: (quality) => speakerViewCreditId(quality),
|
|
69
|
+
clockMapFrom: "output-json",
|
|
70
|
+
ownerOnlyListing: true,
|
|
71
|
+
latestBatch: true,
|
|
72
|
+
jsonKind: "edl",
|
|
73
|
+
}),
|
|
63
74
|
})
|
|
64
75
|
|
|
65
76
|
/** Every render node type, in registry order. */
|
package/src/scene-node-types.ts
CHANGED
|
@@ -20,6 +20,16 @@ export const TransitionTypeSchema = z.enum([
|
|
|
20
20
|
])
|
|
21
21
|
export type TransitionType = z.infer<typeof TransitionTypeSchema>
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Tags a ShotSpec field that only a render or the user writes — measured
|
|
25
|
+
* audio, the Editor LLM's cut, the dialogue no-cut zone, an accepted
|
|
26
|
+
* match-cut break — and never the plan. Fields named for a url or an asset id
|
|
27
|
+
* need no tag (their name already says so). A custom registry, not `.meta()`,
|
|
28
|
+
* so the tag never appears in a JSON schema rendered from ShotSpecSchema.
|
|
29
|
+
*/
|
|
30
|
+
export const sceneRenderStateRegistry = z.registry<{ render_state: true }>()
|
|
31
|
+
const RENDER_STATE = { render_state: true } as const
|
|
32
|
+
|
|
23
33
|
/**
|
|
24
34
|
* ShotSpec — one shot inside a SceneNodeData.
|
|
25
35
|
* Mirrors Architecture §6.9.1 + v4.1 Method-2/3/5/7/8/10 field additions.
|
|
@@ -130,7 +140,7 @@ export const ShotSpecSchema = z.object({
|
|
|
130
140
|
// Phase 1D.1 Method 7 — set true when the user accepts a MatchCutCritic
|
|
131
141
|
// 'break' verdict for this shot's pair. Stage 6 reads this to know the
|
|
132
142
|
// break is resolved and the scene can advance to Stage 7.
|
|
133
|
-
accepted_match_cut_break: z.boolean().optional(),
|
|
143
|
+
accepted_match_cut_break: z.boolean().optional().register(sceneRenderStateRegistry, RENDER_STATE),
|
|
134
144
|
|
|
135
145
|
// ─── Phase 1C.2 — dialogue + editor cut metadata ───────────────────────────
|
|
136
146
|
// All optional; planning-time ShotSpec carries none of these. Populated by
|
|
@@ -139,12 +149,12 @@ export const ShotSpecSchema = z.object({
|
|
|
139
149
|
// True when `dialogue_line` is non-null AND the speech generator produced
|
|
140
150
|
// an audio track. The Editor LLM uses this to gate cut-in / cut-out into
|
|
141
151
|
// the dialogue_no_cut_zone (Method 5.13.1 — never trim a syllable).
|
|
142
|
-
has_dialogue: z.boolean().default(false),
|
|
152
|
+
has_dialogue: z.boolean().default(false).register(sceneRenderStateRegistry, RENDER_STATE),
|
|
143
153
|
|
|
144
154
|
// Measured length of the per-shot speech audio (Stage 7 step 4 writes this).
|
|
145
155
|
// Separate from `duration_seconds` (the planning intent) — the actual
|
|
146
156
|
// recording can run longer/shorter than the spec.
|
|
147
|
-
actual_audio_duration_sec: z.number().optional(),
|
|
157
|
+
actual_audio_duration_sec: z.number().optional().register(sceneRenderStateRegistry, RENDER_STATE),
|
|
148
158
|
|
|
149
159
|
// Inclusive [start, end] window (seconds, relative to the shot's video clip)
|
|
150
160
|
// during which the Editor LLM MUST NOT cut. Computed from
|
|
@@ -153,7 +163,8 @@ export const ShotSpecSchema = z.object({
|
|
|
153
163
|
dialogue_no_cut_zone: z
|
|
154
164
|
.object({ start: z.number(), end: z.number() })
|
|
155
165
|
.nullable()
|
|
156
|
-
.optional()
|
|
166
|
+
.optional()
|
|
167
|
+
.register(sceneRenderStateRegistry, RENDER_STATE),
|
|
157
168
|
|
|
158
169
|
// Editor LLM output (Phase 1C.2). Populated by the Editor LLM stage; the
|
|
159
170
|
// silent-cut-preview sub-gate may patch it via user-applied overrides.
|
|
@@ -166,7 +177,8 @@ export const ShotSpecSchema = z.object({
|
|
|
166
177
|
transition_duration_sec: z.number().min(0).max(2).optional(),
|
|
167
178
|
beat_snap_seconds: z.number().nullable().optional(),
|
|
168
179
|
})
|
|
169
|
-
.optional()
|
|
180
|
+
.optional()
|
|
181
|
+
.register(sceneRenderStateRegistry, RENDER_STATE),
|
|
170
182
|
})
|
|
171
183
|
export type ShotSpec = z.infer<typeof ShotSpecSchema>
|
|
172
184
|
|
package/src/settings-input.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IMAGE_MODEL_ROLE_DEFAULTS } from "./image-model-roles.js"
|
|
1
2
|
/**
|
|
2
3
|
* The "Settings" input: ONE input handle on a generation node that takes the
|
|
3
4
|
* Generation Settings nodes. Aspect Ratio, Duration and Provider set the
|
|
@@ -107,7 +108,7 @@ const SETTINGS_CONSUMERS: Readonly<Record<string, SettingsConsumer>> = {
|
|
|
107
108
|
models: IMAGE_GEN_PROVIDERS,
|
|
108
109
|
// The node's own default (NODE_DEFINITIONS) — only used to fit a wired
|
|
109
110
|
// ratio when the node names no model.
|
|
110
|
-
defaultModel:
|
|
111
|
+
defaultModel: IMAGE_MODEL_ROLE_DEFAULTS.general,
|
|
111
112
|
modelList: "providers",
|
|
112
113
|
},
|
|
113
114
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read Inspiration and Read Competitor — the nodes that read posts the person
|
|
3
|
+
* already has (the Inspiration library; a tracked brand's scans) and emit them
|
|
4
|
+
* the way Social Search does: `json` the posts (`SocialPost[]`), `text` their
|
|
5
|
+
* digest (`socialPostsDigest`), one list item per post. Both engines' output
|
|
6
|
+
* branches read this ONE list, so a new reader is routed like the rest.
|
|
7
|
+
*
|
|
8
|
+
* The routes behind them (`/v1/inspiration-read`, `/v1/competitor-read`) are
|
|
9
|
+
* free: they read what the account already holds.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const INSPIRATION_READ_NODE_TYPE = "inspiration-read" as const
|
|
13
|
+
export const COMPETITOR_READ_NODE_TYPE = "competitor-read" as const
|
|
14
|
+
|
|
15
|
+
export const SOCIAL_POST_READER_NODE_TYPES: ReadonlySet<string> = new Set([INSPIRATION_READ_NODE_TYPE, COMPETITOR_READ_NODE_TYPE])
|
|
16
|
+
|
|
17
|
+
export function isSocialPostReaderNodeType(type: unknown): boolean {
|
|
18
|
+
return typeof type === "string" && SOCIAL_POST_READER_NODE_TYPES.has(type)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The most posts one run reads. */
|
|
22
|
+
export const SOCIAL_READ_LIMIT_MAX = 100
|
|
23
|
+
export const SOCIAL_READ_DEFAULT_LIMIT = 20
|
|
24
|
+
/** A window in hours reaches back at most 30 days; in days, at most a year (Competitors keep at most twelve months of scans). */
|
|
25
|
+
export const SOCIAL_READ_WINDOW_HOURS_MAX = 720
|
|
26
|
+
export const SOCIAL_READ_WINDOW_DAYS_MAX = 365
|
|
27
|
+
|
|
28
|
+
/** `window`: the last N hours or days. `day`: one calendar day in the node's timezone. */
|
|
29
|
+
export const SOCIAL_READ_PERIODS = ["window", "day"] as const
|
|
30
|
+
export type SocialReadPeriod = (typeof SOCIAL_READ_PERIODS)[number]
|
|
31
|
+
|
|
32
|
+
/** Which of a brand's posts Read Competitor reads: its own, posts about it, or both. */
|
|
33
|
+
export const COMPETITOR_READ_ROLES = ["own", "about", "all"] as const
|
|
34
|
+
export type CompetitorReadRole = (typeof COMPETITOR_READ_ROLES)[number]
|
|
35
|
+
|
|
36
|
+
/** A calendar day as the node stores it. */
|
|
37
|
+
export const SOCIAL_READ_DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/
|