@nodaro/shared 3.27.0 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/index.cjs +1050 -105
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +801 -46
  4. package/dist/index.d.ts +801 -46
  5. package/dist/index.js +950 -106
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/__tests__/entity-image-handle.test.ts +61 -1
  9. package/src/__tests__/json-kinds.test.ts +10 -0
  10. package/src/__tests__/model-seed-capability.test.ts +34 -0
  11. package/src/__tests__/node-preset-extract.test.ts +8 -0
  12. package/src/__tests__/node-run-routes.test.ts +63 -0
  13. package/src/__tests__/node-runtime-keys.test.ts +61 -0
  14. package/src/__tests__/pitch-tempo-pricing.test.ts +62 -0
  15. package/src/__tests__/presentation-utils.test.ts +14 -0
  16. package/src/__tests__/producer-types.test.ts +15 -0
  17. package/src/__tests__/render-nodes.test.ts +38 -4
  18. package/src/__tests__/seedance-draft.test.ts +74 -0
  19. package/src/__tests__/ugc-clip-saved-list.test.ts +19 -0
  20. package/src/__tests__/ugc-node-wires.test.ts +600 -0
  21. package/src/__tests__/ugc-run-state.test.ts +80 -3
  22. package/src/__tests__/video-depth.test.ts +146 -0
  23. package/src/__tests__/video-mask.test.ts +77 -0
  24. package/src/__tests__/workflow-export-strip.test.ts +14 -0
  25. package/src/credit-estimators/index.ts +10 -0
  26. package/src/credit-estimators/pitch-tempo.ts +68 -0
  27. package/src/credit-identifiers.ts +32 -7
  28. package/src/entity-image-handle.ts +48 -1
  29. package/src/fan-out-rows.ts +2 -0
  30. package/src/index.ts +15 -1
  31. package/src/json-kinds.ts +9 -0
  32. package/src/mask-composite.ts +108 -0
  33. package/src/model-catalog.ts +101 -2
  34. package/src/model-constants.ts +3 -0
  35. package/src/model-tree.ts +2 -0
  36. package/src/node-mappable-fields.ts +2 -0
  37. package/src/node-preset-export.ts +2 -2
  38. package/src/node-preset-extract.ts +6 -4
  39. package/src/node-run-routes.ts +76 -0
  40. package/src/node-runtime-keys.ts +42 -1
  41. package/src/presentation-utils.ts +6 -2
  42. package/src/producer-types.ts +19 -0
  43. package/src/render-nodes.ts +14 -5
  44. package/src/seedance-draft.ts +64 -0
  45. package/src/social-post.ts +13 -0
  46. package/src/ugc-node-wires.ts +623 -0
  47. package/src/ugc-run-state.ts +60 -5
  48. package/src/video-depth.ts +151 -0
  49. package/src/video-mask.ts +96 -0
  50. package/src/workflow-export.ts +3 -1
package/src/json-kinds.ts CHANGED
@@ -28,6 +28,7 @@
28
28
  * expects a Transcript, an `edl` pip an EDL.
29
29
  */
30
30
  import { RENDER_JSON_HANDLE, RENDER_NODE_TYPES, type RenderNodeDescriptor } from "./render-nodes.js"
31
+ import { UGC_PRIMARY_HANDLE } from "./ugc-node-wires.js"
31
32
 
32
33
  /** The two JSON shapes the platform's handle vocabulary tells apart. */
33
34
  export type JsonKind = "transcript" | "edl"
@@ -83,6 +84,14 @@ const JSON_OUTPUT_KINDS: Readonly<Record<string, JsonOutputs>> = Object.freeze({
83
84
  "competitor-read": { primary: "json", pips: { json: "other" } },
84
85
  // Describe to Picker: the picker values read off an image.
85
86
  "describe-to-picker": { primary: "picker-json", pips: { "picker-json": "other" } },
87
+ // The UGC video nodes: their own versioned JSON (a creator record, a plan, the
88
+ // clip tickets, the sized plan), and UGC Cards' layer plan and caption plan.
89
+ // Their text pips (category, transcript, report) are not JSON pips. The pip an
90
+ // edge with no `sourceHandle` reads is the UGC wires' own (UGC_PRIMARY_HANDLE).
91
+ "ugc-creator": { primary: UGC_PRIMARY_HANDLE["ugc-creator"], pips: { creator: "other" } },
92
+ "ugc-script": { primary: UGC_PRIMARY_HANDLE["ugc-script"], pips: { plan: "other" } },
93
+ "ugc-clips": { primary: UGC_PRIMARY_HANDLE["ugc-clips"], pips: { clips: "other", "plan-out": "other" } },
94
+ "ugc-cards": { primary: UGC_PRIMARY_HANDLE["ugc-cards"], pips: { layerPlan: "other", captionPlan: "other" } },
86
95
  })
87
96
 
88
97
  /** The input pips whose kind is fixed by the handle vocabulary. */
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Mask Composite — place a foreground video over a background video through a
3
+ * mask video (white = keep the foreground, black = show the background). The
4
+ * wire contract of the `mask-composite` node, `POST /v1/mask-composite`, the
5
+ * `mask_composite` MCP verb, `client.media.maskComposite` and
6
+ * `nodaro media mask-composite`, defined ONCE. Pair it with Video Mask, whose
7
+ * output is exactly such a mask.
8
+ *
9
+ * The render follows the FOREGROUND: its size, frame rate and length. The
10
+ * background is fitted to that frame (`backgroundFit`) and loops when shorter;
11
+ * the mask is stretched to the frame and holds its last frame when shorter.
12
+ *
13
+ * Priced per started 5 seconds of the result (the foreground's length), like
14
+ * Trim / Loop / Combine Videos: the node's own `model_pricing` row is ONE unit
15
+ * (`maskCompositeUnits` counts them). Worked examples (repeated in
16
+ * docs/nodes/processing-video/mask-composite.md, at the 10-credit row):
17
+ * 3 s → 1 unit (10), 10 s → 2 units (20), 61 s → 13 units (130), 5 min → 60 units (600).
18
+ *
19
+ * Wire contract only — no I/O.
20
+ */
21
+
22
+ /** How the background is fitted to the foreground's frame. */
23
+ export const MASK_COMPOSITE_BACKGROUND_FITS = ["cover", "contain", "stretch"] as const
24
+ export type MaskCompositeBackgroundFit = (typeof MASK_COMPOSITE_BACKGROUND_FITS)[number]
25
+
26
+ /** Which sound the result carries. `mix` blends both tracks at equal level. */
27
+ export const MASK_COMPOSITE_AUDIO_SOURCES = ["foreground", "background", "mix", "none"] as const
28
+ export type MaskCompositeAudioSource = (typeof MASK_COMPOSITE_AUDIO_SOURCES)[number]
29
+
30
+ export const MASK_COMPOSITE_BOUNDS = {
31
+ /** Edge softening, pixels of blur radius on the mask (0 = hard edge). */
32
+ FEATHER_MIN: 0,
33
+ FEATHER_MAX: 20,
34
+ /** Grow (+) or shrink (−) the white region, pixels. */
35
+ GROW_MIN: -10,
36
+ GROW_MAX: 10,
37
+ /** The longest foreground a run accepts, seconds. */
38
+ MAX_DURATION_SEC: 300,
39
+ } as const
40
+
41
+ /** Seconds of result one pricing unit covers. */
42
+ export const MASK_COMPOSITE_UNIT_SEC = 5
43
+
44
+ /**
45
+ * Pricing units for a result `durationSec` long: one per started 5 seconds,
46
+ * at least one. An unknown length counts the longest result a run accepts
47
+ * (an upper bound — the pre-run quote for a clip whose length is not known
48
+ * yet; every run measures its foreground).
49
+ */
50
+ export function maskCompositeUnits(durationSec: number | null | undefined): number {
51
+ const sec =
52
+ typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0
53
+ ? Math.min(durationSec, MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC)
54
+ : MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC
55
+ // The epsilon absorbs float noise (a 10.0000001 s probe is 2 units, not 3).
56
+ return Math.max(1, Math.ceil(sec / MASK_COMPOSITE_UNIT_SEC - 1e-6))
57
+ }
58
+
59
+ export const MASK_COMPOSITE_DEFAULTS = {
60
+ invertMask: false,
61
+ feather: 2,
62
+ grow: 0,
63
+ backgroundFit: "cover" as MaskCompositeBackgroundFit,
64
+ audioSource: "foreground" as MaskCompositeAudioSource,
65
+ } as const
66
+
67
+ export interface MaskCompositeSettings {
68
+ readonly invertMask: boolean
69
+ readonly feather: number
70
+ readonly grow: number
71
+ readonly backgroundFit: MaskCompositeBackgroundFit
72
+ readonly audioSource: MaskCompositeAudioSource
73
+ }
74
+
75
+ const clampInt = (v: unknown, min: number, max: number, fallback: number): number =>
76
+ typeof v === "number" && Number.isFinite(v) ? Math.min(max, Math.max(min, Math.round(v))) : fallback
77
+
78
+ /**
79
+ * Node data (or any loose object) → settings every engine renders with.
80
+ * Unknown enum values fall back to the default and numbers are clamped, so a
81
+ * node written straight into workflow JSON renders the same as one set in the
82
+ * panel. The ONE normaliser both workflow engines and the worker call.
83
+ */
84
+ export function resolveMaskCompositeSettings(data: Readonly<Record<string, unknown>>): MaskCompositeSettings {
85
+ const d = MASK_COMPOSITE_DEFAULTS
86
+ const b = MASK_COMPOSITE_BOUNDS
87
+ return {
88
+ invertMask: typeof data.invertMask === "boolean" ? data.invertMask : d.invertMask,
89
+ feather: clampInt(data.feather, b.FEATHER_MIN, b.FEATHER_MAX, d.feather),
90
+ grow: clampInt(data.grow, b.GROW_MIN, b.GROW_MAX, d.grow),
91
+ backgroundFit: (MASK_COMPOSITE_BACKGROUND_FITS as readonly string[]).includes(data.backgroundFit as string)
92
+ ? (data.backgroundFit as MaskCompositeBackgroundFit)
93
+ : d.backgroundFit,
94
+ audioSource: (MASK_COMPOSITE_AUDIO_SOURCES as readonly string[]).includes(data.audioSource as string)
95
+ ? (data.audioSource as MaskCompositeAudioSource)
96
+ : d.audioSource,
97
+ }
98
+ }
99
+
100
+ /** `POST /v1/mask-composite` request body. */
101
+ export interface MaskCompositeRequest extends Partial<MaskCompositeSettings> {
102
+ /** The video whose white-masked region is kept (its size, rate and length lead). */
103
+ readonly foregroundUrl: string
104
+ /** The video shown where the mask is black. */
105
+ readonly backgroundUrl: string
106
+ /** The mask video — white = foreground (Video Mask's output). */
107
+ readonly maskUrl: string
108
+ }
@@ -28,6 +28,7 @@
28
28
  * `docs/choosing-models.md` guide. CI (`gen:skills:check`) fails on drift.
29
29
  */
30
30
 
31
+ import { isSeedanceDraftCapable, SEEDANCE_DRAFT_RESOLUTION } from "./seedance-draft.js"
31
32
  import { isFlux2Model } from "./flux2-pricing.js"
32
33
  import { isAutoVideoDuration } from "./video-duration-auto.js"
33
34
 
@@ -48,6 +49,7 @@ export type ModelMode =
48
49
  | "motion-transfer"
49
50
  | "lip-sync"
50
51
  | "video-upscale"
52
+ | "video-depth"
51
53
  // audio
52
54
  | "tts"
53
55
  | "music"
@@ -236,6 +238,15 @@ export interface ModelCatalogEntry {
236
238
  * the longest clip and settled on the delivered one.
237
239
  */
238
240
  autoDuration?: boolean
241
+ /**
242
+ * The model takes NO seed: its provider schema has none, so a seed the
243
+ * request carries is dropped before the provider call and repeat runs vary.
244
+ * Absent means a seed is forwarded as usual. Read through
245
+ * {@link modelTakesSeed} — the editor hides its Seed field off it and clears
246
+ * a stale `data.seed` when the provider switches. Pinned to the KIE configs'
247
+ * `omitSeed` in both directions by `seed-capability-parity.test.ts`.
248
+ */
249
+ noSeed?: boolean
239
250
  pricing: readonly PriceVariant[]
240
251
  /** Editorial highlight — "best in tier". Surfaces in MCP output as a ⭐. */
241
252
  featured?: boolean
@@ -1775,6 +1786,8 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
1775
1786
  defaultDuration: 8,
1776
1787
  autoDuration: true,
1777
1788
  resolutions: ["480p", "720p", "1080p"],
1789
+ // KIE refuses a seed on Seedance 2.5 (422) — the provider config omits it.
1790
+ noSeed: true,
1778
1791
  pricing: [
1779
1792
  { identifier: "seedance-2-5", credits: 1260, note: "default 8s 720p — see :Ns:res variants for exact" },
1780
1793
  { identifier: "seedance-2-5:8s:480p", credits: 560, note: "8s 480p" },
@@ -2092,6 +2105,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2092
2105
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2093
2106
  defaultDuration: 5,
2094
2107
  resolutions: ["720p", "1080p"],
2108
+ noSeed: true, // HappyHorse 1.1 dropped `seed` from its schema
2095
2109
  pricing: [
2096
2110
  { identifier: "happyhorse", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
2097
2111
  ],
@@ -2108,6 +2122,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2108
2122
  durations: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
2109
2123
  defaultDuration: 5,
2110
2124
  resolutions: ["720p", "1080p"],
2125
+ noSeed: true, // HappyHorse 1.1 dropped `seed` from its schema
2111
2126
  pricing: [
2112
2127
  { identifier: "happyhorse-i2v", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
2113
2128
  ],
@@ -2126,6 +2141,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2126
2141
  defaultDuration: 5,
2127
2142
  resolutions: ["720p", "1080p"],
2128
2143
  features: ["reference-image"],
2144
+ noSeed: true, // HappyHorse 1.1 dropped `seed` from its schema
2129
2145
  pricing: [
2130
2146
  { identifier: "happyhorse-ref2v", credits: 282, note: "5s 720p default — per-second: ~5.7 cr/s @720p, ~7.3 cr/s @1080p" },
2131
2147
  ],
@@ -2291,6 +2307,27 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2291
2307
  useCases: ["upscale", "high-res"],
2292
2308
  pricing: [{ identifier: "veo-4k", credits: 380 }],
2293
2309
  },
2310
+ // Seedance 2.5 Draft finalize (seedance-draft.ts): re-renders a Seedance 2.5
2311
+ // DRAFT as the same take at 1080p. Priced per output second of the draft; a
2312
+ // draft made with a reference VIDEO bills its `-ref` rate on input + output
2313
+ // seconds. Only works on a completed Seedance 2.5 draft.
2314
+ "seedance-2-5-hd": {
2315
+ id: "seedance-2-5-hd",
2316
+ kind: "video",
2317
+ modes: ["video-upscale"] as const,
2318
+ family: "Bytedance",
2319
+ label: "Seedance 2.5 HD (from draft)",
2320
+ series: "Seedance",
2321
+ description: "Finalize a Seedance 2.5 draft: the same take, frame for frame, re-rendered at 1080p.",
2322
+ useCases: ["upscale", "high-res"],
2323
+ pricing: [
2324
+ { identifier: "seedance-2-5-hd", credits: 3160, note: "default 8s — see :Ns variants for exact" },
2325
+ { identifier: "seedance-2-5-hd:4s", credits: 1580, note: "4s draft" },
2326
+ { identifier: "seedance-2-5-hd:8s", credits: 3160, note: "8s draft" },
2327
+ { identifier: "seedance-2-5-hd:30s", credits: 11850, note: "30s draft (max)" },
2328
+ { identifier: "seedance-2-5-hd:8s-ref", credits: 1900, note: "per-second rate of a draft made with a reference video; billed on input + output seconds" },
2329
+ ],
2330
+ },
2294
2331
  "topaz-video": {
2295
2332
  id: "topaz-video",
2296
2333
  kind: "video",
@@ -2450,6 +2487,45 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2450
2487
  { identifier: "volcengine-lipsync:300s", credits: 6000, note: "5-min ceiling" },
2451
2488
  ],
2452
2489
  },
2490
+ // ── Video Depth ── (video-depth node; billed per duration bucket via
2491
+ // videoDepthCreditId in video-depth.ts — `<provider>:<bucket>s`, bare row =
2492
+ // the 300 s ceiling, same shape as volcengine-lipsync.)
2493
+ "video-depth-anything": {
2494
+ id: "video-depth-anything",
2495
+ kind: "video",
2496
+ modes: ["video-depth"] as const,
2497
+ family: "Depth Anything",
2498
+ label: "Video Depth Anything",
2499
+ series: "Depth Anything",
2500
+ description: "Temporally consistent depth video from any clip. Grayscale or colormapped, up to 2,400 frames or 300 seconds.",
2501
+ useCases: ["depth", "video-to-video", "compositing"],
2502
+ pricing: [
2503
+ { identifier: "video-depth-anything", credits: 6000, note: "5-min ceiling (no duration given)" },
2504
+ { identifier: "video-depth-anything:15s", credits: 300 },
2505
+ { identifier: "video-depth-anything:30s", credits: 600 },
2506
+ { identifier: "video-depth-anything:60s", credits: 1200 },
2507
+ { identifier: "video-depth-anything:120s", credits: 2400 },
2508
+ { identifier: "video-depth-anything:300s", credits: 6000, note: "5-min ceiling" },
2509
+ ],
2510
+ },
2511
+ "depth-anything-frames": {
2512
+ id: "depth-anything-frames",
2513
+ kind: "video",
2514
+ modes: ["video-depth"] as const,
2515
+ family: "Depth Anything",
2516
+ label: "Depth Anything (per frame)",
2517
+ series: "Depth Anything",
2518
+ description: "Depth Anything v1 run on each frame. Grayscale or inferno colormap; may flicker between frames. Up to 80 s.",
2519
+ useCases: ["depth", "video-to-video"],
2520
+ pricing: [
2521
+ { identifier: "depth-anything-frames", credits: 600, note: "5-min ceiling (no duration given)" },
2522
+ { identifier: "depth-anything-frames:15s", credits: 30 },
2523
+ { identifier: "depth-anything-frames:30s", credits: 60 },
2524
+ { identifier: "depth-anything-frames:60s", credits: 120 },
2525
+ { identifier: "depth-anything-frames:120s", credits: 240 },
2526
+ { identifier: "depth-anything-frames:300s", credits: 600, note: "5-min ceiling" },
2527
+ ],
2528
+ },
2453
2529
  // ── Gemini video analysis ── (Gemini-only; billed per duration bucket — the
2454
2530
  // structural credit formula lives in video-analysis-pricing.ts. Composite id
2455
2531
  // shape `video-analysis:<model>:<bucket>s` mirrors volcengine-lipsync: bare
@@ -3645,7 +3721,7 @@ export interface NormalizedVideoRequest {
3645
3721
  */
3646
3722
  export function normalizeVideoRequestParams(
3647
3723
  modelId: string,
3648
- input: { aspectRatio?: string; resolution?: string },
3724
+ input: { aspectRatio?: string; resolution?: string; draft?: boolean },
3649
3725
  ): NormalizedVideoRequest {
3650
3726
  const m = MODEL_CATALOG[modelId]
3651
3727
  // Seeded from the COERCED tokens, never the raw input: this function's own
@@ -3654,8 +3730,21 @@ export function normalizeVideoRequestParams(
3654
3730
  // `1080` or `[]` verbatim would break that promise at exactly the sites that
3655
3731
  // must agree on one value.
3656
3732
  const aspect = readOptionToken(input.aspectRatio)
3657
- const res = readOptionToken(input.resolution)
3733
+ const requestedRes = readOptionToken(input.resolution)
3734
+ // Seedance Draft renders at 480p only (the provider rejects anything else),
3735
+ // so a draft is PRICED and SENT at 480p whatever resolution came with it — an
3736
+ // agent, an import or a FieldMapping can pair `draft` with 720p, and the
3737
+ // reservation must not follow the stale value. An omitted resolution is a
3738
+ // fill, not a correction, so it reports nothing.
3739
+ const draft = input.draft === true && isSeedanceDraftCapable(modelId)
3740
+ const res = draft ? SEEDANCE_DRAFT_RESOLUTION : requestedRes
3658
3741
  const out: NormalizedVideoRequest = { aspectRatio: aspect, resolution: res, adjustments: [] }
3742
+ if (draft && requestedRes !== undefined && requestedRes.toLowerCase() !== SEEDANCE_DRAFT_RESOLUTION) {
3743
+ out.adjustments.push({
3744
+ field: "resolution", from: requestedRes, to: SEEDANCE_DRAFT_RESOLUTION,
3745
+ reason: `A Seedance draft renders at ${SEEDANCE_DRAFT_RESOLUTION} only — using "${SEEDANCE_DRAFT_RESOLUTION}" instead of "${requestedRes}". Finalize the draft to get the same take at 1080p.`,
3746
+ })
3747
+ }
3659
3748
  if (!m) return out
3660
3749
 
3661
3750
  if (m.aspectRatios?.length && aspect && !PASSTHROUGH_ASPECT_TOKENS.has(aspect.toLowerCase())) {
@@ -3789,6 +3878,16 @@ export function hasFeature(modelId: string, feature: string): boolean {
3789
3878
  return MODEL_CATALOG[modelId]?.features?.includes(feature) ?? false
3790
3879
  }
3791
3880
 
3881
+ /**
3882
+ * Whether a seed on this model does anything — false only for a catalog entry
3883
+ * that declares `noSeed`. An unknown or missing id answers true, so a surface
3884
+ * never hides a Seed field for a model it knows nothing about.
3885
+ */
3886
+ export function modelTakesSeed(modelId: string | undefined): boolean {
3887
+ if (!modelId) return true
3888
+ return MODEL_CATALOG[modelId]?.noSeed !== true
3889
+ }
3890
+
3792
3891
  /**
3793
3892
  * All ids in the catalog whose `features` includes the given flag. Used by
3794
3893
  * frontend to build PROVIDERS_WITH_END_FRAME / PROVIDERS_WITH_REFERENCES
@@ -1107,6 +1107,9 @@ export const VIDEO_UPSCALE_PROVIDERS = [
1107
1107
  "topaz",
1108
1108
  "veo-1080p",
1109
1109
  "veo-4k",
1110
+ // Seedance 2.5 Draft finalize: re-renders a Seedance 2.5 DRAFT (by its task
1111
+ // id) as the same take at 1080p. See seedance-draft.ts.
1112
+ "seedance-2-5-hd",
1110
1113
  ] as const
1111
1114
  export type VideoUpscaleProvider = typeof VIDEO_UPSCALE_PROVIDERS[number]
1112
1115
 
package/src/model-tree.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, LIP_SYNC_PROVIDERS,
13
13
  FACE_SWAP_PROVIDERS, TTS_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS,
14
14
  } from "./model-constants.js"
15
+ import { VIDEO_DEPTH_PROVIDERS } from "./video-depth.js"
15
16
 
16
17
  export interface ModelNodeTarget {
17
18
  nodeType: string
@@ -38,6 +39,7 @@ const ENUM_TARGETS: ReadonlyArray<readonly [readonly string[], string]> = [
38
39
  [TEXT_TO_VIDEO_PROVIDERS, "generate-video"],
39
40
  [UPSCALE_IMAGE_PROVIDERS, "upscale-image"],
40
41
  [VIDEO_UPSCALE_PROVIDERS, "video-upscale"],
42
+ [VIDEO_DEPTH_PROVIDERS, "video-depth"],
41
43
  [MODIFY_IMAGE_PROVIDERS, "modify-image"],
42
44
  [IMAGE_EDIT_PROVIDERS, "modify-image"],
43
45
  [VIDEO_TO_VIDEO_PROVIDERS, "video-to-video"],
@@ -27,6 +27,8 @@ export const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> =
27
27
  // Span-replace sibling of generate-video-pro — prompt only, no
28
28
  // negativePrompt field on the node.
29
29
  "edit-video-pro": ["prompt"],
30
+ // The subject to track — a {Label} reference or a mapping writes it.
31
+ "video-mask": ["prompt"],
30
32
  "video-analysis": ["analysisFocus", "youtubeUrl"],
31
33
  "video-to-video": ["prompt"],
32
34
  // + the two neighbour-text fields (continuity across clips): a wired Text node can feed
@@ -39,7 +39,7 @@ export function buildNodePresetExport(
39
39
  kind: NODE_PRESET_EXPORT_KIND,
40
40
  version: 1,
41
41
  exportedAt: exportedAtIso,
42
- presets: presets.map((p) => ({ ...p, data: extractPresetData(p.data) })),
42
+ presets: presets.map((p) => ({ ...p, data: extractPresetData(p.data, p.nodeType) })),
43
43
  }
44
44
  }
45
45
 
@@ -51,6 +51,6 @@ export function parseNodePresetExport(input: unknown): NodePresetExport {
51
51
  const parsed = envelopeSchema.parse(input)
52
52
  return {
53
53
  ...parsed,
54
- presets: parsed.presets.map((p) => ({ ...p, data: extractPresetData(p.data) })),
54
+ presets: parsed.presets.map((p) => ({ ...p, data: extractPresetData(p.data, p.nodeType) })),
55
55
  }
56
56
  }
@@ -1,4 +1,4 @@
1
- import { EXECUTION_DATA_KEYS } from "./node-runtime-keys.js"
1
+ import { isExecutionDataKey } from "./node-runtime-keys.js"
2
2
  import { COMPOSER_PLAN_FIELDS } from "./model-constants.js"
3
3
  import { PROMPT_PREFIX_KEY, PROMPT_SUFFIX_KEY } from "./prompt-affixes.js"
4
4
 
@@ -172,15 +172,17 @@ export const PRESET_EXCLUDED_KEYS: ReadonlySet<string> = new Set([
172
172
 
173
173
  /**
174
174
  * Capture a node's reusable configuration from its `data`: a shallow copy minus runtime/result
175
- * state (EXECUTION_DATA_KEYS) and graph/identity fields (PRESET_EXCLUDED_KEYS). Pure; never mutates
176
- * the input. Node-type-agnostic — the node type is stored alongside the result by the caller.
175
+ * state (`isExecutionDataKey`: the global keys, plus the node type's own when `nodeType` is given)
176
+ * and graph/identity fields (PRESET_EXCLUDED_KEYS). Pure; never mutates the input. The node type is
177
+ * stored alongside the result by the caller.
177
178
  */
178
179
  export function extractPresetData(
179
180
  data: Readonly<Record<string, unknown>>,
181
+ nodeType?: string,
180
182
  ): Record<string, unknown> {
181
183
  const out: Record<string, unknown> = {}
182
184
  for (const key of Object.keys(data)) {
183
- if (EXECUTION_DATA_KEYS.has(key)) continue
185
+ if (isExecutionDataKey(key, nodeType)) continue
184
186
  if (PRESET_EXCLUDED_KEYS.has(key)) continue
185
187
  out[key] = data[key]
186
188
  }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The REST route that runs one node type on its own: `POST /v1/<type>` by
3
+ * convention, or the route listed here.
4
+ *
5
+ * Part of the public API contract: `@nodaro/sdk`'s `nodes.run(type)` posts to
6
+ * the route this resolves, and the platform's workflow engine calls the same
7
+ * routes for the node types it runs over HTTP, so the two cannot disagree.
8
+ */
9
+ import { SOCIAL_POST_NODE_TYPES } from "./social-post.js"
10
+
11
+ const SOCIAL_PUBLISH_ROUTE = "/v1/social/publish"
12
+
13
+ /** Node types whose run route is NOT `POST /v1/<type>`. */
14
+ export const NODE_RUN_ROUTES: Readonly<Record<string, string>> = Object.freeze({
15
+ "generate-3d-scene": "/v1/3d-scene/generate",
16
+ "edit-3d-scene": "/v1/3d-scene/edit",
17
+ "ai-writer": "/v1/ai-writer/generate",
18
+ "llm-chat": "/v1/llm-chat/generate",
19
+ "video-composer": "/v1/scene-graph/generate",
20
+ "after-effects": "/v1/after-effects/generate",
21
+ "lottie-overlay": "/v1/lottie-overlay/generate",
22
+ "3d-title": "/v1/3d-title/generate",
23
+ "motion-graphics": "/v1/motion-graphics/generate",
24
+ "image-to-text": "/v1/image-to-text/describe",
25
+ "telegram-channel-feed": "/v1/telegram-channel/fetch",
26
+ "suno-generate": "/v1/suno/generate",
27
+ "suno-cover": "/v1/suno/cover",
28
+ "suno-extend": "/v1/suno/extend",
29
+ "suno-lyrics": "/v1/suno/lyrics",
30
+ "suno-separate": "/v1/suno/separate",
31
+ "suno-music-video": "/v1/suno/music-video",
32
+ "suno-mashup": "/v1/suno/mashup",
33
+ "suno-replace-section": "/v1/suno/replace-section",
34
+ "suno-style-boost": "/v1/suno/style-boost",
35
+ "suno-add-instrumental": "/v1/suno/add-instrumental",
36
+ "suno-add-vocals": "/v1/suno/add-vocals",
37
+ "suno-convert-wav": "/v1/suno/convert-wav",
38
+ "suno-upload-extend": "/v1/suno/upload-extend",
39
+ "suno-voice": "/v1/suno/voice/generate",
40
+ // The UGC nodes' routes, served by the Nodaro Cloud plugin.
41
+ "ugc-creator": "/v1/ugc/creator",
42
+ "ugc-script": "/v1/ugc/script",
43
+ "ugc-clips": "/v1/ugc/clips",
44
+ "ugc-clip": "/v1/ugc/clip",
45
+ "ugc-cards": "/v1/ugc/cards",
46
+ // Every social post node publishes through the one route; the body's
47
+ // `platform` says where (SOCIAL_POST_NODE_PLATFORM).
48
+ ...Object.fromEntries([...SOCIAL_POST_NODE_TYPES].map((type) => [type, SOCIAL_PUBLISH_ROUTE])),
49
+ })
50
+
51
+ /**
52
+ * Node types with no route that runs them on their own, each with what to run
53
+ * instead. They run inside the editor or a workflow, or through a sibling
54
+ * route that takes a differently shaped body.
55
+ */
56
+ export const NODE_TYPES_WITHOUT_RUN_ROUTE: Readonly<Record<string, string>> = Object.freeze({
57
+ "modify-image": 'run "image-to-image" instead (or "edit-image" for the nano-banana-edit provider)',
58
+ "upscale-image": 'run "edit-image" with an upscale provider instead (e.g. provider "recraft-upscale")',
59
+ "remove-background": 'run "edit-image" with provider "recraft-remove-bg" instead',
60
+ "image-to-video": 'run "generate-video" with a start frame instead',
61
+ composite: "it runs only as part of a workflow (client.workflows.run)",
62
+ "manual-edit": "it opens the in-browser editor and runs only inside a workflow",
63
+ "paint-mask": "it is painted in the editor and never runs; use its mask output inside a workflow",
64
+ scene: "it is run by the pipeline orchestrator (client.pipelines)",
65
+ "generative-pipeline": "it is run by the pipeline orchestrator (client.pipelines)",
66
+ })
67
+
68
+ /**
69
+ * The route that runs `type` on its own, or null when it has none (see
70
+ * {@link NODE_TYPES_WITHOUT_RUN_ROUTE} for what to run instead).
71
+ */
72
+ export function nodeRunRoute(type: string): string | null {
73
+ if (Object.prototype.hasOwnProperty.call(NODE_TYPES_WITHOUT_RUN_ROUTE, type)) return null
74
+ if (Object.prototype.hasOwnProperty.call(NODE_RUN_ROUTES, type)) return NODE_RUN_ROUTES[type]!
75
+ return `/v1/${encodeURIComponent(type)}`
76
+ }
@@ -9,7 +9,9 @@
9
9
  * - the node-preset extractor (presets must never capture runtime state)
10
10
  * - the backend defensive strip on preset writes
11
11
  *
12
- * When adding a new runtime/result field to a node's data, add its key here.
12
+ * When adding a new runtime/result field to a node's data, add its key here — or, when it is a
13
+ * generic name only one node type writes as a result, to that type's row of
14
+ * NODE_TYPE_EXECUTION_DATA_KEYS (read through `isExecutionDataKey` / `executionDataKeysOf`).
13
15
  */
14
16
  export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
15
17
  "executionStatus",
@@ -150,8 +152,47 @@ export const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([
150
152
  "resultsRunEndedAt",
151
153
  // A trigger's last run values (also in TRANSIENT_RUNTIME_KEYS: never saved).
152
154
  "__triggerData",
155
+ // A fan-out's notes rows, every fan-out's (row-aligned with __listResults):
156
+ // a row's warnings and length. A RESULT: persisted.
157
+ "__listResultMeta",
153
158
  ])
154
159
 
160
+ /**
161
+ * Run results a node type writes under a GENERIC name — `quote`, `durationSec`,
162
+ * `candidates` — that are execution data on THAT type only. Another node may
163
+ * keep a setting under the same name; filing these globally would misfile it
164
+ * (out of undo, presets, templates and the copilot's view). Same lifecycle as
165
+ * the global results: persisted, and a run writing them is never an undo step.
166
+ *
167
+ * UGC video (Nodaro Cloud): the outputs a node hands on (`ugcOutputs`), UGC
168
+ * Creator's options of a draw and their note, UGC Clips' quote, and UGC Clip's
169
+ * warnings, length and Re-render marks (`rerenderPending`: the clips pressed for
170
+ * Re-render that no run has rendered yet — run bookkeeping; the press itself,
171
+ * `rerender`, is a choice).
172
+ */
173
+ export const NODE_TYPE_EXECUTION_DATA_KEYS: Readonly<Record<string, readonly string[]>> = {
174
+ "ugc-creator": ["ugcOutputs", "candidates", "optionFailed"],
175
+ "ugc-script": ["ugcOutputs"],
176
+ "ugc-clips": ["ugcOutputs", "quote"],
177
+ "ugc-clip": ["ugcOutputs", "clipWarnings", "durationSec", "rerenderPending"],
178
+ "ugc-cards": ["ugcOutputs"],
179
+ }
180
+
181
+ /** Is `key` execution data (run state or a run's result) on a node of `type`: global, or that type's own? */
182
+ export function isExecutionDataKey(key: string, type: string | null | undefined): boolean {
183
+ if (EXECUTION_DATA_KEYS.has(key)) return true
184
+ return typeof type === "string" && Object.hasOwn(NODE_TYPE_EXECUTION_DATA_KEYS, type) && NODE_TYPE_EXECUTION_DATA_KEYS[type]!.includes(key)
185
+ }
186
+
187
+ const EXECUTION_DATA_KEYS_BY_TYPE = new Map<string, ReadonlySet<string>>(
188
+ Object.entries(NODE_TYPE_EXECUTION_DATA_KEYS).map(([type, keys]) => [type, new Set([...EXECUTION_DATA_KEYS, ...keys])]),
189
+ )
190
+
191
+ /** Every execution-data key on a node of `type`, as one set: the global ones, plus the type's own. */
192
+ export function executionDataKeysOf(type: string | null | undefined): ReadonlySet<string> {
193
+ return (typeof type === "string" ? EXECUTION_DATA_KEYS_BY_TYPE.get(type) : undefined) ?? EXECUTION_DATA_KEYS
194
+ }
195
+
155
196
  /**
156
197
  * The PURE RUN-STATE subset of EXECUTION_DATA_KEYS: per-tick values (status
157
198
  * flips, job ids, progress counters, fan-out bookkeeping) that must NEITHER
@@ -127,6 +127,7 @@ const MEDIA_PRODUCING_TYPES = new Set([
127
127
  "lip-sync",
128
128
  "motion-transfer",
129
129
  "video-upscale",
130
+ "video-depth",
130
131
  ])
131
132
 
132
133
  // Output type categorizations
@@ -147,7 +148,7 @@ const VIDEO_OUTPUT_TYPES = new Set([
147
148
  "combine-videos", "merge-video-audio", "resize-video", "trim-video",
148
149
  "speed-ramp", "loop-video", "fade-video", "transcode-video",
149
150
  "upload-video",
150
- "lip-sync", "motion-transfer", "video-upscale", "add-captions",
151
+ "lip-sync", "motion-transfer", "video-upscale", "video-depth", "add-captions",
151
152
  "social-media-format",
152
153
  // A render (Apply EDL) renders an EDL into video OR audio. Its medium is
153
154
  // decided at run time (DYNAMIC_PRODUCER_TYPES), so getOutputType would answer
@@ -162,7 +163,7 @@ const VIDEO_OUTPUT_TYPES = new Set([
162
163
  const AUDIO_OUTPUT_TYPES = new Set([
163
164
  "text-to-speech", "generate-music", "text-to-audio",
164
165
  "text-to-dialogue", "voice-changer", "dubbing", "voice-remix",
165
- "voice-design", "mix-audio", "adjust-volume", "audio-fx", "trim-audio",
166
+ "voice-design", "mix-audio", "adjust-volume", "audio-fx", "pitch-tempo", "trim-audio",
166
167
  "audio-isolation",
167
168
  "audio-separation",
168
169
  "upload-audio",
@@ -171,6 +172,9 @@ const AUDIO_OUTPUT_TYPES = new Set([
171
172
  const TEXT_OUTPUT_TYPES = new Set([
172
173
  "generate-script", "ai-writer", "llm-chat", "transcribe", "image-to-text", "qa-check",
173
174
  "text-prompt",
175
+ // UGC Cards' output card is its Notes: a run hands it on as the node's text
176
+ // (`output.text`, `generatedText` on the canvas).
177
+ "ugc-cards",
174
178
  ])
175
179
 
176
180
  // ---------------------------------------------------------------------------
@@ -14,6 +14,7 @@
14
14
  * a connection from a node type that the backend would happily route at
15
15
  * execution time (the prior drift bug, see issue 1 of the Task 4.1 review).
16
16
  */
17
+ import { UGC_PRIMARY_HANDLE } from "./ugc-node-wires.js"
17
18
 
18
19
  /**
19
20
  * Source node types whose primary output is a video URL.
@@ -47,6 +48,7 @@ export const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = new Set([
47
48
  "speech-to-video",
48
49
  "motion-transfer",
49
50
  "video-upscale",
51
+ "video-depth",
50
52
  "extend-video",
51
53
  // face-swap output is video (writes generatedVideoUrl, per-result `url`).
52
54
  // Frontend execution-graph already includes it in VIDEO_SOURCE_TYPES; this
@@ -72,6 +74,9 @@ export const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = new Set([
72
74
  "speed-ramp",
73
75
  "loop-video",
74
76
  "fade-video",
77
+ // Video Mask emits its mask as a video; Mask Composite its composite.
78
+ "video-mask",
79
+ "mask-composite",
75
80
  "transcode-video",
76
81
  "manual-edit",
77
82
  // Remove Audio: strips the audio track, emits a silent video.
@@ -100,6 +105,9 @@ export const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = new Set([
100
105
  // Video Overlay: timed image layers over a video in one local FFmpeg pass
101
106
  // (the base audio copied) — emits a video URL on `video-out`.
102
107
  "video-overlay",
108
+ // UGC Clip: renders one clip of a UGC video from its ticket — emits a video
109
+ // URL on `video-out` (one per fan-out iteration).
110
+ "ugc-clip",
103
111
  ])
104
112
 
105
113
  /**
@@ -132,6 +140,10 @@ export const DYNAMIC_PRODUCER_TYPES: ReadonlySet<string> = new Set([
132
140
  "list",
133
141
  "sub-workflow",
134
142
  "adjust-volume",
143
+ // Pitch & Tempo: audio in → audio out, video in → video out (picture
144
+ // copied). Dual-mode like adjust-volume; stays in AUDIO_PRODUCER_TYPES as
145
+ // its default.
146
+ "pitch-tempo",
135
147
  // Dual-mode: audio in → audio out; video in → video out (+ revoiced audio).
136
148
  // Listed here so canvas validators accept its output on BOTH audio and video
137
149
  // input handles (it also stays in AUDIO_PRODUCER_TYPES as its default).
@@ -196,6 +208,7 @@ export const AUDIO_PRODUCER_TYPES: ReadonlySet<string> = new Set([
196
208
  "combine-audio",
197
209
  "adjust-volume",
198
210
  "audio-fx",
211
+ "pitch-tempo",
199
212
  "reference-audio",
200
213
  "audio-isolation",
201
214
  "text-to-dialogue",
@@ -303,6 +316,12 @@ export const FAN_OUT_EACH_HANDLES: Readonly<Record<string, { readonly each: read
303
316
  // every clip (the master clock, renamed), so that handle stays one value
304
317
  // (decided 2026-10-04).
305
318
  "camera-switch": { each: ["edl"], primary: "edl" },
319
+ // UGC Clips: one ticket per clip on `clips` (each); `plan-out` and
320
+ // `transcript` carry one value. Not a FAN_OUT_EACH_TYPES member — every
321
+ // handle of such a member would fan out. Its one run writes the tickets as
322
+ // its list (`listResults`, the editor's `__listResults`). The pip an edge
323
+ // with no handle reads is the UGC wires' own (UGC_PRIMARY_HANDLE).
324
+ "ugc-clips": { each: ["clips"], primary: UGC_PRIMARY_HANDLE["ugc-clips"]! },
306
325
  }
307
326
 
308
327
  /**