@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
@@ -1,17 +1,38 @@
1
1
  /** The five UGC node types (Cloud only; served by a private plugin). */
2
2
  export const UGC_NODE_TYPES: ReadonlySet<string> = new Set(["ugc-creator", "ugc-script", "ugc-clips", "ugc-clip", "ugc-cards"])
3
3
 
4
+ /** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */
5
+ export const UGC_CREATOR_CANDIDATES_KEY = "candidates"
6
+
7
+ /** A run that would execute a UGC Creator whose options wait for the person's pick. */
8
+ export const UGC_PICK_FIRST_MESSAGE = "Pick a creator first."
9
+
4
10
  /**
5
11
  * Per UGC type, the node-data keys that are a RUN's state, never a choice. A
6
12
  * published app's snapshot is readable by every runner, so publishing strips
7
13
  * them (the last plan, the clip tickets, the publisher's kept creator).
14
+ *
15
+ * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its
16
+ * source: after a My photo run it IS the author's photo, and a creator switched
17
+ * to another source after such a run, or whose photo was removed, still holds it.
18
+ * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes
19
+ * as a run hands them on) are the author's renders: a published node starts empty.
20
+ *
21
+ * A published snapshot is stripped through `stripUgcPublishState`
22
+ * (@nodaro/render-rules), which also empties every run result a lane writes under
23
+ * a generic name, every node made from the UGC video, and every node on a path
24
+ * into a UGC Creator's photo input.
8
25
  */
9
26
  export const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {
10
- "ugc-creator": ["result", "keepResult", "ugcOutputs"],
11
- "ugc-script": ["result", "keepResult", "ugcOutputs"],
27
+ "ugc-creator": ["result", "keepResult", "ugcOutputs", UGC_CREATOR_CANDIDATES_KEY, "optionFailed", "generatedImageUrl"],
28
+ // `exampleLines`: a template's example run, shown until the node's own first script (display only).
29
+ "ugc-script": ["result", "keepResult", "ugcOutputs", "exampleLines"],
12
30
  "ugc-clips": ["result", "quote", "__listResults", "ugcOutputs"],
13
- "ugc-clip": ["warnings", "rerender", "__listResults", "__listResultMeta", "clipWarnings", "durationSec", "ugcOutputs"],
14
- "ugc-cards": ["result", "ugcOutputs"],
31
+ "ugc-clip": [
32
+ "warnings", "rerender", "rerenderPending", "__listResults", "__listResultMeta", "clipWarnings", "durationSec", "ugcOutputs",
33
+ "generatedVideoUrl", "generatedResults", "activeResultIndex",
34
+ ],
35
+ "ugc-cards": ["result", "ugcOutputs", "generatedText", "text"],
15
36
  }
16
37
 
17
38
  /**
@@ -31,13 +52,47 @@ export const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>>
31
52
 
32
53
  const KEEP_RESULT_TYPES: ReadonlySet<string> = new Set(["ugc-creator", "ugc-script"])
33
54
 
34
- /** A copy of `nodes` with every UGC node's run state removed (and `keepResult: false`). Other nodes are returned as they are. */
55
+ /** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */
56
+ export function ugcPickPending(data: unknown): boolean {
57
+ const candidates = data && typeof data === "object" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined
58
+ return Array.isArray(candidates) && candidates.length > 0
59
+ }
60
+
61
+ /**
62
+ * A run that would execute a UGC Creator whose options wait is refused ("Pick a creator first."),
63
+ * except that creator's own re-draw. One rule for the editor's check before a run and the
64
+ * orchestrator's.
65
+ */
66
+ export function ugcRunWaitsForPick(
67
+ runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,
68
+ opts: { readonly redrawId?: string } = {},
69
+ ): boolean {
70
+ return runNodes.some((n) => n.type === "ugc-creator" && n.id !== opts.redrawId && ugcPickPending(n.data))
71
+ }
72
+
73
+ /**
74
+ * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo
75
+ * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —
76
+ * but a runner gives their own photo (or the run is refused for want of one) and a template's
77
+ * cloner adds theirs.
78
+ */
79
+ export const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {
80
+ "ugc-creator": ["photoUrl"],
81
+ }
82
+
83
+ /**
84
+ * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own
85
+ * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a
86
+ * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),
87
+ * which starts here.
88
+ */
35
89
  export function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {
36
90
  return nodes.map((node) => {
37
91
  const type = typeof node.type === "string" ? node.type : ""
38
92
  if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== "object") return node
39
93
  const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }
40
94
  for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]
95
+ for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]
41
96
  if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false
42
97
  return { ...node, data }
43
98
  })
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Video Depth — the one contract every layer reads: which providers exist and
3
+ * which lane serves each, which optional levers a provider honours, how long a
4
+ * clip may be, and which price row a run is charged from.
5
+ *
6
+ * Colormaps: fal renders every `VIDEO_DEPTH_COLORMAPS` entry natively. The
7
+ * Replicate model's native output is inferno-colorized, so it offers only
8
+ * `inferno` (passed through as-is) and `grayscale`, which a worker ffmpeg pass
9
+ * produces from the inferno output (`videoDepthNeedsGrayscalePass`).
10
+ *
11
+ * Price rows are `model_pricing` rows (`<provider>:<n>s`); the credit amounts
12
+ * live there, never here. Worked examples (repeated in
13
+ * docs/nodes/processing-video/video-depth.md):
14
+ * 5 s → `:15s`, 15 s → `:15s`, 15.01 s → `:30s`, 61 s → `:120s`.
15
+ */
16
+
17
+ export const VIDEO_DEPTH_PROVIDERS = ["video-depth-anything", "depth-anything-frames"] as const
18
+ export type VideoDepthProvider = (typeof VIDEO_DEPTH_PROVIDERS)[number]
19
+
20
+ export const FAL_VIDEO_DEPTH_PROVIDERS: ReadonlySet<string> = new Set(["video-depth-anything"])
21
+ export const REPLICATE_VIDEO_DEPTH_PROVIDERS: ReadonlySet<string> = new Set(["depth-anything-frames"])
22
+
23
+ /**
24
+ * The provider a run uses: `raw` when it is a Video Depth provider, else the
25
+ * default (the first entry). Raw workflow JSON or a FieldMapping can carry any
26
+ * value; the dispatch, the model deny and the price row all read this one
27
+ * resolution, so an unknown id never reaches a price row or slips the deny.
28
+ */
29
+ export function resolveVideoDepthProvider(raw: unknown): VideoDepthProvider {
30
+ return typeof raw === "string" && (VIDEO_DEPTH_PROVIDERS as readonly string[]).includes(raw)
31
+ ? (raw as VideoDepthProvider)
32
+ : VIDEO_DEPTH_PROVIDERS[0]
33
+ }
34
+
35
+ export const VIDEO_DEPTH_MODEL_SIZES = ["small", "base", "large"] as const
36
+ export type VideoDepthModelSize = (typeof VIDEO_DEPTH_MODEL_SIZES)[number]
37
+
38
+ /** The model size a run uses: `raw` when it is one, else `large` (the providers index lookup tables with it). */
39
+ export function resolveVideoDepthModelSize(raw: unknown): VideoDepthModelSize {
40
+ return typeof raw === "string" && (VIDEO_DEPTH_MODEL_SIZES as readonly string[]).includes(raw)
41
+ ? (raw as VideoDepthModelSize)
42
+ : "large"
43
+ }
44
+ export const VIDEO_DEPTH_COLORMAPS = ["grayscale", "turbo", "inferno", "magma", "viridis"] as const
45
+ export type VideoDepthColormap = (typeof VIDEO_DEPTH_COLORMAPS)[number]
46
+ export const VIDEO_DEPTH_RESOLUTIONS = ["auto", "360p", "480p", "720p", "1080p"] as const
47
+ export type VideoDepthResolution = (typeof VIDEO_DEPTH_RESOLUTIONS)[number]
48
+
49
+ export type VideoDepthLever = "colormap" | "resolution" | "sideBySide"
50
+ const ALL_LEVERS: ReadonlySet<VideoDepthLever> = new Set(["colormap", "resolution", "sideBySide"])
51
+ const COLORMAP_ONLY: ReadonlySet<VideoDepthLever> = new Set(["colormap"])
52
+ const NO_LEVERS: ReadonlySet<VideoDepthLever> = new Set()
53
+
54
+ /** The optional levers `provider` honours. A lever absent here is dropped, never sent. */
55
+ export function videoDepthLevers(provider: string): ReadonlySet<VideoDepthLever> {
56
+ if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return ALL_LEVERS
57
+ if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) return COLORMAP_ONLY
58
+ return NO_LEVERS
59
+ }
60
+
61
+ const REPLICATE_COLORMAPS: readonly VideoDepthColormap[] = ["grayscale", "inferno"]
62
+
63
+ /** The colormaps `provider` can deliver, in display order; empty when it has no colormap lever. */
64
+ export function videoDepthColormaps(provider: string): readonly VideoDepthColormap[] {
65
+ if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return VIDEO_DEPTH_COLORMAPS
66
+ if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) return REPLICATE_COLORMAPS
67
+ return []
68
+ }
69
+
70
+ /** The colormap a run uses: the requested one when `provider` offers it, else `grayscale`; `undefined` when the provider has no colormap lever. Coerces, never throws. */
71
+ export function resolveVideoDepthColormap(provider: string, requested: unknown): VideoDepthColormap | undefined {
72
+ if (!videoDepthLevers(provider).has("colormap")) return undefined
73
+ const offered = videoDepthColormaps(provider)
74
+ return typeof requested === "string" && (offered as readonly string[]).includes(requested)
75
+ ? (requested as VideoDepthColormap)
76
+ : "grayscale"
77
+ }
78
+
79
+ /** True when the worker must turn the Replicate model's native inferno output into grayscale with ffmpeg. */
80
+ export function videoDepthNeedsGrayscalePass(provider: string, colormap: VideoDepthColormap | undefined): boolean {
81
+ return REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider) && resolveVideoDepthColormap(provider, colormap) === "grayscale"
82
+ }
83
+
84
+ export const VIDEO_DEPTH_LIMITS = {
85
+ /** fal `max_frames` ceiling. */
86
+ FAL_MAX_FRAMES: 2400,
87
+ /** Longest clip the fal lane accepts, whatever its frame rate: the top price bucket (a low-fps clip under the frame limit can otherwise run past every price row). */
88
+ FAL_MAX_SECONDS: 300,
89
+ /** Frame rate assumed when the clip reports none (variable-rate or missing). */
90
+ ASSUMED_FPS: 30,
91
+ /** Longest clip the Replicate lane accepts. */
92
+ REPLICATE_MAX_SECONDS: 80,
93
+ } as const
94
+
95
+ const fmt = (n: number): string => n.toLocaleString("en-US")
96
+
97
+ /** Refuse a clip the provider cannot take — run BEFORE any credit reservation. */
98
+ export function checkVideoDepthLength(
99
+ provider: string,
100
+ probe: { durationSec: number; fps?: number },
101
+ ): { ok: true } | { ok: false; message: string } {
102
+ if (REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)) {
103
+ if (probe.durationSec <= VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS) return { ok: true }
104
+ return {
105
+ ok: false,
106
+ message: `Video is ${Math.ceil(probe.durationSec)} s. This provider accepts at most ${VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS} s.`,
107
+ }
108
+ }
109
+ if (probe.durationSec > VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS) {
110
+ return {
111
+ ok: false,
112
+ message: `Video is ${Math.ceil(probe.durationSec)} s. This provider accepts at most ${VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS} s. Trim the clip and run again.`,
113
+ }
114
+ }
115
+ const assumed = !(typeof probe.fps === "number" && probe.fps > 0)
116
+ const fps = assumed ? VIDEO_DEPTH_LIMITS.ASSUMED_FPS : (probe.fps as number)
117
+ const frames = Math.ceil(probe.durationSec * fps - 1e-9)
118
+ if (frames <= VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES) return { ok: true }
119
+ const maxSec = Math.floor(VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES / fps)
120
+ return {
121
+ ok: false,
122
+ message:
123
+ `Video is ${fmt(frames)} frames; the limit is ${fmt(VIDEO_DEPTH_LIMITS.FAL_MAX_FRAMES)} ` +
124
+ `(about ${maxSec} s at ${Math.round(fps)} fps${assumed ? ", assumed 30 fps because the clip reports no frame rate" : ""}). Trim the clip and run again.`,
125
+ }
126
+ }
127
+
128
+ export const VIDEO_DEPTH_BUCKETS = [15, 30, 60, 120, 300] as const
129
+
130
+ /** The longest clip `provider` accepts (`checkVideoDepthLength`); the fal limit for anything else. */
131
+ function videoDepthMaxSeconds(provider: string): number {
132
+ return REPLICATE_VIDEO_DEPTH_PROVIDERS.has(provider)
133
+ ? VIDEO_DEPTH_LIMITS.REPLICATE_MAX_SECONDS
134
+ : VIDEO_DEPTH_LIMITS.FAL_MAX_SECONDS
135
+ }
136
+
137
+ /**
138
+ * The price row for a clip of `durationSec`. Unknown, non-positive or longer
139
+ * than the provider accepts → the provider's highest REACHABLE row: the
140
+ * smallest bucket at or above its longest clip (Replicate 80 s → `:120s`,
141
+ * fal 300 s → `:300s`) — the most a run on it can be charged, never a row a
142
+ * run could not reach.
143
+ */
144
+ export function videoDepthCreditId(provider: string, durationSec: number | null | undefined): string {
145
+ const top = VIDEO_DEPTH_BUCKETS[VIDEO_DEPTH_BUCKETS.length - 1]
146
+ const maxSec = videoDepthMaxSeconds(provider)
147
+ const reachableCeiling = VIDEO_DEPTH_BUCKETS.find((b) => b >= maxSec) ?? top
148
+ const known = typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0 && durationSec <= maxSec
149
+ const bucket = known ? (VIDEO_DEPTH_BUCKETS.find((b) => durationSec <= b) ?? top) : reachableCeiling
150
+ return `${provider}:${bucket}s`
151
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Video Mask — text-prompted video segmentation (SAM 3.1 / SAM 3). The wire contract of
3
+ * the `video-mask` node, `POST /v1/video-mask`, the `video_mask` MCP verb,
4
+ * `client.media.videoMask` and `nodaro media video-mask`, defined ONCE:
5
+ * - every bound the route schema, the node panel and the MCP verb read;
6
+ * - `videoMaskBilledSeconds`: the length a run is priced at — the clip's
7
+ * length at the 30 fps basis, so a 60 fps clip is priced at twice its
8
+ * length (the segmentation works per FRAME);
9
+ * - `videoMaskCreditId`: which price row (`model_pricing`) that length is
10
+ * charged from. The credit amounts live in the rows, never here.
11
+ *
12
+ * Worked examples (repeated in docs/nodes/ai-video/video-mask.md):
13
+ * 4 s at 30 fps → `sam-3.1-video:5s`, 12 s at 24 fps → `sam-3.1-video:15s`,
14
+ * 10 s at 60 fps (priced as 20 s) → `sam-3.1-video:30s`, 45 s at 30 fps → `sam-3.1-video:60s`,
15
+ * 100 s at 30 fps → `sam-3.1-video:120s`, 4 min at 30 fps on SAM 3 → `sam-3-video:240s`.
16
+ *
17
+ * Wire contract only — no I/O.
18
+ */
19
+
20
+ /** Segmentation models a Video Mask run can use. SAM 3.1 (the default)
21
+ * tracks several objects in one pass and runs faster; SAM 3 costs half. */
22
+ export const VIDEO_MASK_PROVIDERS = ["sam-3.1", "sam-3"] as const
23
+ export type VideoMaskProvider = (typeof VIDEO_MASK_PROVIDERS)[number]
24
+ export const DEFAULT_VIDEO_MASK_PROVIDER: VideoMaskProvider = "sam-3.1"
25
+
26
+ /** A new Video Mask node's settings — spread into its node definition. */
27
+ export const VIDEO_MASK_DEFAULTS = {
28
+ threshold: 0.5,
29
+ provider: "sam-3.1" as VideoMaskProvider,
30
+ } as const
31
+
32
+ export const VIDEO_MASK_LIMITS = {
33
+ /** The longest input clip a run accepts, in seconds of PRICED length (see `videoMaskBilledSeconds`). */
34
+ MAX_BILLED_SEC: 300,
35
+ /** Frame rate the price rows assume. A faster clip is priced proportionally longer. */
36
+ FPS_BASIS: 30,
37
+ /** Subject description length cap. */
38
+ PROMPT_MAX_LENGTH: 500,
39
+ /** Detection confidence bounds (the model's own range, narrowed to useful values). */
40
+ THRESHOLD_MIN: 0.05,
41
+ THRESHOLD_MAX: 0.95,
42
+ THRESHOLD_STEP: 0.05,
43
+ /** Default detection confidence. Lower finds more (and less precise) regions. */
44
+ THRESHOLD_DEFAULT: VIDEO_MASK_DEFAULTS.threshold,
45
+ } as const
46
+
47
+ const VIDEO_MASK_BUCKETS_SEC = [5, 10, 15, 30, 60, 90, 120, 180, 240, 300] as const
48
+
49
+ /** Every price row a provider can be charged from, smallest first. */
50
+ export function videoMaskCreditIds(provider: VideoMaskProvider = DEFAULT_VIDEO_MASK_PROVIDER): string[] {
51
+ return VIDEO_MASK_BUCKETS_SEC.map((sec) => `${provider}-video:${sec}s`)
52
+ }
53
+
54
+ /**
55
+ * The length a clip is priced at: its duration at the 30 fps basis. A clip
56
+ * at or under 30 fps is priced at its own length; a 60 fps clip at twice it.
57
+ * An unknown frame rate counts as the basis.
58
+ */
59
+ export function videoMaskBilledSeconds(durationSec: number, fps?: number | null): number {
60
+ const rate = typeof fps === "number" && Number.isFinite(fps) && fps > 0 ? fps : VIDEO_MASK_LIMITS.FPS_BASIS
61
+ return durationSec * Math.max(1, rate / VIDEO_MASK_LIMITS.FPS_BASIS)
62
+ }
63
+
64
+ /**
65
+ * The price row for a clip priced at `billedSec` seconds. An unknown or
66
+ * non-positive length prices the LONGEST row (a clip the route could not
67
+ * measure is refused, so this is only the pre-run quote for a clip whose
68
+ * length is not known yet); anything past the cap prices the last row.
69
+ */
70
+ export function videoMaskCreditId(
71
+ billedSec: number | null | undefined,
72
+ provider: VideoMaskProvider = DEFAULT_VIDEO_MASK_PROVIDER,
73
+ ): string {
74
+ const ids = videoMaskCreditIds(provider)
75
+ if (typeof billedSec !== "number" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!
76
+ const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => billedSec <= b)
77
+ return ids[i === -1 ? ids.length - 1 : i]!
78
+ }
79
+
80
+ /** Narrow an arbitrary value to a known provider, falling back to the default. */
81
+ export function resolveVideoMaskProvider(value: unknown): VideoMaskProvider {
82
+ return (VIDEO_MASK_PROVIDERS as readonly string[]).includes(value as string)
83
+ ? (value as VideoMaskProvider)
84
+ : DEFAULT_VIDEO_MASK_PROVIDER
85
+ }
86
+
87
+ /** `POST /v1/video-mask` request body. */
88
+ export interface VideoMaskRequest {
89
+ /** The clip to segment. */
90
+ readonly videoUrl: string
91
+ /** What to track: a short noun phrase; separate several with commas. */
92
+ readonly prompt: string
93
+ /** Detection confidence, `VIDEO_MASK_LIMITS.THRESHOLD_MIN`–`THRESHOLD_MAX` (default 0.5). */
94
+ readonly threshold?: number
95
+ readonly provider?: VideoMaskProvider
96
+ }
@@ -1,5 +1,5 @@
1
1
  import type { GenericNode, GenericEdge } from "./types.js"
2
- import { EXECUTION_DATA_KEYS } from "./node-runtime-keys.js"
2
+ import { EXECUTION_DATA_KEYS, NODE_TYPE_EXECUTION_DATA_KEYS } from "./node-runtime-keys.js"
3
3
  import { SOCIAL_POST_NODE_TYPES } from "./social-post.js"
4
4
 
5
5
  /** A named media variant (expression, pose, angle, etc.) produced during entity generation. */
@@ -264,6 +264,8 @@ export function stripExportContent(nodes: GenericNode[]): GenericNode[] {
264
264
  return stripUnownedRefs(nodes).map((node) => {
265
265
  const data = { ...(node.data as Record<string, unknown>) }
266
266
  for (const field of GENERATED_FIELDS) delete data[field]
267
+ // A type's own run results under generic names (UGC Clips' `quote`, …): stripped from that type only.
268
+ for (const field of NODE_TYPE_EXECUTION_DATA_KEYS[node.type] ?? []) delete data[field]
267
269
  const extras = NODE_EXTRA_FIELDS[node.type] ?? []
268
270
  for (const field of extras) delete data[field]
269
271
  return { ...node, data }