@nodaro/shared 3.24.0 → 3.25.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 +595 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +375 -48
- package/dist/index.d.ts +375 -48
- package/dist/index.js +553 -129
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/credit-identifiers.test.ts +19 -6
- package/src/__tests__/dialogue-capabilities.test.ts +3 -2
- package/src/__tests__/edit-plan-minute-ids.test.ts +82 -0
- package/src/__tests__/json-kinds.test.ts +179 -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__/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/credit-identifiers.ts +48 -37
- package/src/edit-plan-contract.ts +67 -1
- package/src/fan-out-rows.ts +2 -2
- package/src/index.ts +45 -1
- package/src/json-kinds.ts +188 -0
- package/src/model-catalog.ts +121 -8
- package/src/model-constants.ts +68 -42
- package/src/node-default-mappings.ts +1 -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/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.
|
|
@@ -490,6 +491,7 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
|
|
|
490
491
|
"nano-banana-pro",
|
|
491
492
|
"nano-banana-2",
|
|
492
493
|
"nano-banana-2-lite",
|
|
494
|
+
"nano-banana-2-1",
|
|
493
495
|
// T2I providers that auto-route to their i2i sibling when refs are attached
|
|
494
496
|
"gpt-image",
|
|
495
497
|
"gpt-image-2",
|
|
@@ -576,6 +578,7 @@ export const REF_IMAGE_MAX_LIMITS: Record<string, number> = {
|
|
|
576
578
|
"nano-banana-pro": 8,
|
|
577
579
|
"nano-banana-2": 4,
|
|
578
580
|
"nano-banana-2-lite": 10,
|
|
581
|
+
"nano-banana-2-1": 10,
|
|
579
582
|
"wan-2.7": 9,
|
|
580
583
|
// grok-2 reference chain consumes exactly one image (segment-map input).
|
|
581
584
|
"grok-2-i2i": 1,
|
|
@@ -655,6 +658,7 @@ export const VARIABLE_PRICING_MODELS: Record<string, "quality" | "resolution" |
|
|
|
655
658
|
"gpt-image-2-5-sunburst-i2i": "resolution",
|
|
656
659
|
"nano-banana-pro": "resolution",
|
|
657
660
|
"nano-banana-2": "resolution",
|
|
661
|
+
"nano-banana-2-1": "resolution",
|
|
658
662
|
"flux": "resolution",
|
|
659
663
|
"flux-flex": "resolution",
|
|
660
664
|
"flux-i2i": "resolution",
|
|
@@ -683,6 +687,7 @@ export const TWO_K_RESOLUTION_PROVIDERS = new Set(["flux", "flux-pro-i2i", "flux
|
|
|
683
687
|
// Models where both 2K and 4K resolutions trigger composite credit identifiers (1K is base)
|
|
684
688
|
export const RESOLUTION_2K_4K_TIERED_PROVIDERS = new Set([
|
|
685
689
|
"nano-banana-2",
|
|
690
|
+
"nano-banana-2-1",
|
|
686
691
|
"gpt-image-2",
|
|
687
692
|
"gpt-image-2-i2i",
|
|
688
693
|
"gpt-image-2-5-flare",
|
|
@@ -712,6 +717,7 @@ export const IMAGE_GEN_PROVIDERS = [
|
|
|
712
717
|
"nano-banana-pro",
|
|
713
718
|
"nano-banana-2",
|
|
714
719
|
"nano-banana-2-lite",
|
|
720
|
+
"nano-banana-2-1",
|
|
715
721
|
"grok",
|
|
716
722
|
"grok-2",
|
|
717
723
|
"gpt-image",
|
|
@@ -743,6 +749,7 @@ export const IMAGE_I2I_PROVIDERS = [
|
|
|
743
749
|
"nano-banana",
|
|
744
750
|
"nano-banana-2",
|
|
745
751
|
"nano-banana-2-lite",
|
|
752
|
+
"nano-banana-2-1",
|
|
746
753
|
"nano-banana-pro",
|
|
747
754
|
"grok-i2i",
|
|
748
755
|
"flux-i2i",
|
|
@@ -1216,6 +1223,7 @@ export type MotionTransferProviderType = typeof MOTION_TRANSFER_PROVIDERS[number
|
|
|
1216
1223
|
export const TTS_PROVIDERS = [
|
|
1217
1224
|
"elevenlabs-v3",
|
|
1218
1225
|
"elevenlabs-v4",
|
|
1226
|
+
"elevenlabs-v4-turbo",
|
|
1219
1227
|
"elevenlabs-turbo",
|
|
1220
1228
|
"elevenlabs-multilingual",
|
|
1221
1229
|
"elevenlabs",
|
|
@@ -1519,6 +1527,7 @@ export const IMAGE_MASK_MODE: Record<ImageGenProvider, ImageMaskMode> = {
|
|
|
1519
1527
|
"nano-banana-pro": "prompt",
|
|
1520
1528
|
"nano-banana-2": "prompt",
|
|
1521
1529
|
"nano-banana-2-lite": "prompt",
|
|
1530
|
+
"nano-banana-2-1": "prompt",
|
|
1522
1531
|
"gpt-image": "prompt",
|
|
1523
1532
|
"gpt-image-2": "prompt",
|
|
1524
1533
|
"gpt-image-2-5-flare": "prompt",
|
|
@@ -2703,57 +2712,74 @@ export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio
|
|
|
2703
2712
|
}
|
|
2704
2713
|
|
|
2705
2714
|
/**
|
|
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
|
-
|
|
2715
|
+
* @deprecated Read {@link pricedOutputDurationSec} (or the catalog's
|
|
2716
|
+
* `defaultDuration`). Kept only as a derived view of `MODEL_CATALOG` for
|
|
2717
|
+
* consumers of the published package that imported the old hand-kept map; no
|
|
2718
|
+
* pricing path reads it (`pricing-default-duration-guard.test.ts` fails the
|
|
2719
|
+
* build if one does).
|
|
2720
|
+
*/
|
|
2721
|
+
export const PRICING_DEFAULT_DURATION_SEC: Readonly<Record<string, number>> = Object.freeze(
|
|
2722
|
+
Object.fromEntries(
|
|
2723
|
+
Object.values(MODEL_CATALOG)
|
|
2724
|
+
.filter((e) => e.kind === "video" && typeof e.defaultDuration === "number")
|
|
2725
|
+
.map((e) => [e.id, e.defaultDuration as number]),
|
|
2726
|
+
),
|
|
2727
|
+
)
|
|
2728
|
+
|
|
2729
|
+
/**
|
|
2730
|
+
* The legal length nearest to `requested` — ties go to the earlier (shorter)
|
|
2731
|
+
* entry of the list. This is the SAME rule every video runner snaps a request
|
|
2732
|
+
* with (`snapToAllowedDuration` delegates here), so the length a request is
|
|
2733
|
+
* priced at and the length it renders can never be two different numbers.
|
|
2734
|
+
*/
|
|
2735
|
+
export function snapToNearestDuration(requested: number, allowed: readonly number[] | undefined): number {
|
|
2736
|
+
if (!allowed || allowed.length === 0) return requested
|
|
2737
|
+
if (allowed.includes(requested)) return requested
|
|
2738
|
+
return allowed.reduce((best, d) => (Math.abs(d - requested) < Math.abs(best - requested) ? d : best))
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
/**
|
|
2742
|
+
* The length a model renders when the request names none, from the model
|
|
2743
|
+
* catalog (`defaultDuration`); else its shortest legal length; else 5 for an id
|
|
2744
|
+
* the catalog does not list. A video model that is priced by length MUST
|
|
2745
|
+
* declare `defaultDuration` (`pricing-default-duration-sync.test.ts`).
|
|
2746
|
+
*/
|
|
2747
|
+
export function videoDefaultDurationSec(provider: string): number {
|
|
2748
|
+
const entry = MODEL_CATALOG[provider]
|
|
2749
|
+
if (typeof entry?.defaultDuration === "number") return entry.defaultDuration
|
|
2750
|
+
const shortest = entry?.durations?.length ? Math.min(...entry.durations) : undefined
|
|
2751
|
+
return shortest ?? 5
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
/**
|
|
2755
|
+
* The output seconds a video request is CHARGED at — the ONE funnel every
|
|
2756
|
+
* price path reads (the credit identifier's tier, the run reservation and
|
|
2757
|
+
* commit, the editor and server estimates, the Seedance and MiniMax
|
|
2758
|
+
* reference-video reservations and the Loop Trim refund).
|
|
2759
|
+
*
|
|
2760
|
+
* - no duration (or an unusable one) → the model's own default render length
|
|
2761
|
+
* (`MODEL_CATALOG[provider].defaultDuration`), never a global 5;
|
|
2762
|
+
* - a duration the model does not offer → the nearest one it does
|
|
2763
|
+
* ({@link snapToNearestDuration}, the runners' own rule), because that is the
|
|
2764
|
+
* length it renders;
|
|
2765
|
+
* - AUTO (`VIDEO_DURATION_AUTO`) → the model's longest clip: the model picks
|
|
2766
|
+
* the length, `commit_credits` refunds a surplus but never collects a
|
|
2767
|
+
* deficit, and the delivered clip is measured at settle time
|
|
2768
|
+
* (lib/seedance2-ref-video-settle.ts).
|
|
2769
|
+
*
|
|
2770
|
+
* A literal `?? 5` (or `?? 8`) at any pricing site re-opens the gap this closes;
|
|
2771
|
+
* `pricing-default-duration-guard.test.ts` fails the build on one.
|
|
2739
2772
|
*/
|
|
2740
2773
|
export function pricedOutputDurationSec(provider: string, requested: number | string | undefined): number {
|
|
2741
|
-
const fallback =
|
|
2774
|
+
const fallback = videoDefaultDurationSec(provider)
|
|
2742
2775
|
const parsed = typeof requested === "string" ? parseInt(requested, 10) : requested
|
|
2743
2776
|
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
2777
|
if (parsed <= 0) {
|
|
2752
2778
|
return isAutoVideoDuration(parsed) && supportsAutoVideoDuration(provider)
|
|
2753
2779
|
? maxVideoDurationSec(provider) ?? fallback
|
|
2754
2780
|
: fallback
|
|
2755
2781
|
}
|
|
2756
|
-
return parsed
|
|
2782
|
+
return snapToNearestDuration(parsed, MODEL_CATALOG[provider]?.durations)
|
|
2757
2783
|
}
|
|
2758
2784
|
|
|
2759
2785
|
/** 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" } },
|
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
|
|
|
@@ -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}$/
|