@nodaro/shared 3.71.0 → 3.72.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/{chunk-M7LU4NTI.cjs → chunk-26GM45QE.cjs} +18 -2
- package/dist/chunk-26GM45QE.cjs.map +1 -0
- package/dist/{chunk-W4CJ2P3F.cjs → chunk-32QY5AIY.cjs} +8 -8
- package/dist/{chunk-W4CJ2P3F.cjs.map → chunk-32QY5AIY.cjs.map} +1 -1
- package/dist/{chunk-H52P7DD2.cjs → chunk-4BCODXK6.cjs} +61 -61
- package/dist/{chunk-H52P7DD2.cjs.map → chunk-4BCODXK6.cjs.map} +1 -1
- package/dist/{chunk-MN7BUGXF.cjs → chunk-5WXVPPRH.cjs} +7 -7
- package/dist/{chunk-MN7BUGXF.cjs.map → chunk-5WXVPPRH.cjs.map} +1 -1
- package/dist/{chunk-PPXUSZJU.js → chunk-7DMK7B3Q.js} +3 -3
- package/dist/{chunk-PPXUSZJU.js.map → chunk-7DMK7B3Q.js.map} +1 -1
- package/dist/{chunk-YHZUTPZL.cjs → chunk-AIPOZKQV.cjs} +12 -12
- package/dist/{chunk-YHZUTPZL.cjs.map → chunk-AIPOZKQV.cjs.map} +1 -1
- package/dist/{chunk-TOYWEF6E.cjs → chunk-AXDTMRWR.cjs} +14 -7
- package/dist/chunk-AXDTMRWR.cjs.map +1 -0
- package/dist/{chunk-VZIMLPDC.js → chunk-D5NRBVUH.js} +5 -5
- package/dist/{chunk-VZIMLPDC.js.map → chunk-D5NRBVUH.js.map} +1 -1
- package/dist/{chunk-6FUVGATF.js → chunk-D7DCDIMU.js} +3 -3
- package/dist/{chunk-6FUVGATF.js.map → chunk-D7DCDIMU.js.map} +1 -1
- package/dist/{chunk-QME5O4NG.js → chunk-EI4V43DI.js} +5 -5
- package/dist/{chunk-QME5O4NG.js.map → chunk-EI4V43DI.js.map} +1 -1
- package/dist/{chunk-F3XG5J5V.js → chunk-EOYQD6DU.js} +3 -3
- package/dist/{chunk-F3XG5J5V.js.map → chunk-EOYQD6DU.js.map} +1 -1
- package/dist/{chunk-XK75VOEH.js → chunk-GCOS7CFL.js} +4 -4
- package/dist/{chunk-XK75VOEH.js.map → chunk-GCOS7CFL.js.map} +1 -1
- package/dist/{chunk-4HV3LY4A.cjs → chunk-HJGL2UNQ.cjs} +78 -78
- package/dist/{chunk-4HV3LY4A.cjs.map → chunk-HJGL2UNQ.cjs.map} +1 -1
- package/dist/{chunk-MI4WEFJ4.cjs → chunk-HOQ4TLDW.cjs} +21 -21
- package/dist/{chunk-MI4WEFJ4.cjs.map → chunk-HOQ4TLDW.cjs.map} +1 -1
- package/dist/{chunk-WHK3HTFY.cjs → chunk-I2GFLOLD.cjs} +41 -41
- package/dist/{chunk-WHK3HTFY.cjs.map → chunk-I2GFLOLD.cjs.map} +1 -1
- package/dist/{chunk-BVP4M5AK.js → chunk-INJP7EFI.js} +8 -8
- package/dist/{chunk-BVP4M5AK.js.map → chunk-INJP7EFI.js.map} +1 -1
- package/dist/{chunk-NNCHSLFD.cjs → chunk-JUCWBIEE.cjs} +23 -23
- package/dist/{chunk-NNCHSLFD.cjs.map → chunk-JUCWBIEE.cjs.map} +1 -1
- package/dist/{chunk-SR7WH4FX.cjs → chunk-L2WHTUBA.cjs} +40 -34
- package/dist/chunk-L2WHTUBA.cjs.map +1 -0
- package/dist/{chunk-SHSDGAI4.js → chunk-LMBHF5TZ.js} +4 -4
- package/dist/{chunk-SHSDGAI4.js.map → chunk-LMBHF5TZ.js.map} +1 -1
- package/dist/{chunk-JPSKVBYB.js → chunk-LP5KZZAF.js} +3 -3
- package/dist/{chunk-JPSKVBYB.js.map → chunk-LP5KZZAF.js.map} +1 -1
- package/dist/{chunk-SAOIGWA2.js → chunk-M4MXK7RJ.js} +3 -3
- package/dist/{chunk-SAOIGWA2.js.map → chunk-M4MXK7RJ.js.map} +1 -1
- package/dist/{chunk-BO6IKV24.js → chunk-MR4KSZY3.js} +5 -5
- package/dist/{chunk-BO6IKV24.js.map → chunk-MR4KSZY3.js.map} +1 -1
- package/dist/{chunk-LBKMQAXD.cjs → chunk-NEBO32KZ.cjs} +9 -9
- package/dist/{chunk-LBKMQAXD.cjs.map → chunk-NEBO32KZ.cjs.map} +1 -1
- package/dist/{chunk-HUCGHMOI.cjs → chunk-NSKH5ULV.cjs} +17 -17
- package/dist/{chunk-HUCGHMOI.cjs.map → chunk-NSKH5ULV.cjs.map} +1 -1
- package/dist/{chunk-K5WRF2F3.cjs → chunk-OALWH5VV.cjs} +4 -4
- package/dist/{chunk-K5WRF2F3.cjs.map → chunk-OALWH5VV.cjs.map} +1 -1
- package/dist/{chunk-BQV6NV7E.js → chunk-OWNGS4DF.js} +3 -3
- package/dist/{chunk-BQV6NV7E.js.map → chunk-OWNGS4DF.js.map} +1 -1
- package/dist/{chunk-U6APV2PO.cjs → chunk-QFW25UCC.cjs} +5 -5
- package/dist/{chunk-U6APV2PO.cjs.map → chunk-QFW25UCC.cjs.map} +1 -1
- package/dist/{chunk-4A3ITJJB.cjs → chunk-QVRAPR4D.cjs} +6 -6
- package/dist/{chunk-4A3ITJJB.cjs.map → chunk-QVRAPR4D.cjs.map} +1 -1
- package/dist/{chunk-I4C6ZYU4.cjs → chunk-RMDTBXYT.cjs} +6 -6
- package/dist/{chunk-I4C6ZYU4.cjs.map → chunk-RMDTBXYT.cjs.map} +1 -1
- package/dist/{chunk-T4YYUI5Q.js → chunk-SXDLBXSB.js} +9 -5
- package/dist/chunk-SXDLBXSB.js.map +1 -0
- package/dist/{chunk-KD4UUCMW.js → chunk-U7PHAD2O.js} +5 -5
- package/dist/{chunk-KD4UUCMW.js.map → chunk-U7PHAD2O.js.map} +1 -1
- package/dist/{chunk-TADEEG5E.js → chunk-UC3CMPDN.js} +18 -3
- package/dist/chunk-UC3CMPDN.js.map +1 -0
- package/dist/{chunk-UJIPIVTB.cjs → chunk-UMUSJHH2.cjs} +48 -48
- package/dist/{chunk-UJIPIVTB.cjs.map → chunk-UMUSJHH2.cjs.map} +1 -1
- package/dist/{chunk-X3YRSRHP.js → chunk-VVLW63HD.js} +3 -3
- package/dist/{chunk-X3YRSRHP.js.map → chunk-VVLW63HD.js.map} +1 -1
- package/dist/{chunk-K2P7KOIT.js → chunk-WXJMPWYR.js} +9 -9
- package/dist/{chunk-K2P7KOIT.js.map → chunk-WXJMPWYR.js.map} +1 -1
- package/dist/{chunk-COA2OJIH.js → chunk-X7UDZGXW.js} +14 -7
- package/dist/chunk-X7UDZGXW.js.map +1 -0
- package/dist/{chunk-SZ7ALYPK.js → chunk-XEMEUKXK.js} +3 -3
- package/dist/{chunk-SZ7ALYPK.js.map → chunk-XEMEUKXK.js.map} +1 -1
- package/dist/{chunk-6PEWM2B3.cjs → chunk-YHDTBO45.cjs} +9 -9
- package/dist/{chunk-6PEWM2B3.cjs.map → chunk-YHDTBO45.cjs.map} +1 -1
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.js +7 -7
- package/dist/entries/credits.cjs +283 -283
- package/dist/entries/credits.d.cts +1 -1
- package/dist/entries/credits.d.ts +1 -1
- package/dist/entries/credits.js +9 -9
- package/dist/entries/i18n.cjs +15 -11
- package/dist/entries/i18n.d.cts +19 -1
- package/dist/entries/i18n.d.ts +19 -1
- package/dist/entries/i18n.js +1 -1
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/model-catalog.cjs +133 -133
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +412 -404
- package/dist/entries/models.d.cts +2 -2
- package/dist/entries/models.d.ts +2 -2
- package/dist/entries/models.js +5 -5
- package/dist/entries/nodes.cjs +212 -212
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +153 -153
- package/dist/entries/pipeline.d.cts +1 -1
- package/dist/entries/pipeline.d.ts +1 -1
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +152 -152
- package/dist/entries/video.js +6 -6
- package/dist/index.cjs +1445 -1433
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -19
- package/dist/{model-constants-CQr_d3Kw.d.cts → model-constants-C4RL9Xtn.d.cts} +20 -4
- package/dist/{model-constants-B5DNHIP8.d.ts → model-constants-kRg3YCIJ.d.ts} +20 -4
- package/dist/style.ar-4WUT56YH.js +63 -0
- package/dist/style.ar-4WUT56YH.js.map +1 -0
- package/dist/style.ar-ZRS6ZSSS.cjs +65 -0
- package/dist/style.ar-ZRS6ZSSS.cjs.map +1 -0
- package/dist/style.de-6543OVTB.cjs +65 -0
- package/dist/style.de-6543OVTB.cjs.map +1 -0
- package/dist/style.de-HQS4NOVN.js +63 -0
- package/dist/style.de-HQS4NOVN.js.map +1 -0
- package/dist/style.es-ADFPO6LM.cjs +65 -0
- package/dist/style.es-ADFPO6LM.cjs.map +1 -0
- package/dist/style.es-O4N36TIJ.js +63 -0
- package/dist/style.es-O4N36TIJ.js.map +1 -0
- package/dist/style.fr-A3ZO6BP3.cjs +65 -0
- package/dist/style.fr-A3ZO6BP3.cjs.map +1 -0
- package/dist/style.fr-XKYO3NOK.js +63 -0
- package/dist/style.fr-XKYO3NOK.js.map +1 -0
- package/dist/style.he-DI4PXGJG.cjs +65 -0
- package/dist/style.he-DI4PXGJG.cjs.map +1 -0
- package/dist/style.he-L4SD3G7D.js +63 -0
- package/dist/style.he-L4SD3G7D.js.map +1 -0
- package/dist/style.hi-K625E6UR.js +63 -0
- package/dist/style.hi-K625E6UR.js.map +1 -0
- package/dist/style.hi-LMDM6S3Q.cjs +65 -0
- package/dist/style.hi-LMDM6S3Q.cjs.map +1 -0
- package/dist/style.ja-3YGEMQKQ.js +63 -0
- package/dist/style.ja-3YGEMQKQ.js.map +1 -0
- package/dist/style.ja-QV4Z4B3Y.cjs +65 -0
- package/dist/style.ja-QV4Z4B3Y.cjs.map +1 -0
- package/dist/style.ko-KIKAE2WS.js +63 -0
- package/dist/style.ko-KIKAE2WS.js.map +1 -0
- package/dist/style.ko-WXYT3ZAL.cjs +65 -0
- package/dist/style.ko-WXYT3ZAL.cjs.map +1 -0
- package/dist/style.pt-BR-R6WOR67L.js +64 -0
- package/dist/style.pt-BR-R6WOR67L.js.map +1 -0
- package/dist/style.pt-BR-WWGO7RUX.cjs +66 -0
- package/dist/style.pt-BR-WWGO7RUX.cjs.map +1 -0
- package/dist/style.ru-UVLIITMR.js +63 -0
- package/dist/style.ru-UVLIITMR.js.map +1 -0
- package/dist/style.ru-ZCB4IUCW.cjs +65 -0
- package/dist/style.ru-ZCB4IUCW.cjs.map +1 -0
- package/dist/style.zh-CN-IFAAZ475.cjs +65 -0
- package/dist/style.zh-CN-IFAAZ475.cjs.map +1 -0
- package/dist/style.zh-CN-RQEZCV44.js +63 -0
- package/dist/style.zh-CN-RQEZCV44.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/normalize-node-params.test.ts +9 -2
- package/src/__tests__/style-sidecar-loaders.test.ts +29 -0
- package/src/__tests__/video-catalog-totality.test.ts +37 -5
- package/src/entries/i18n.ts +1 -0
- package/src/entries/models.ts +2 -0
- package/src/i18n/style-sidecar-loaders.ts +30 -0
- package/src/model-catalog.ts +15 -5
- package/src/model-constants.ts +24 -4
- package/dist/chunk-COA2OJIH.js.map +0 -1
- package/dist/chunk-M7LU4NTI.cjs.map +0 -1
- package/dist/chunk-SR7WH4FX.cjs.map +0 -1
- package/dist/chunk-T4YYUI5Q.js.map +0 -1
- package/dist/chunk-TADEEG5E.js.map +0 -1
- package/dist/chunk-TOYWEF6E.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":[],"mappings":";;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI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O,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-6FUVGATF.js","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/fan-out-meta.ts","../src/ugc-run-state.ts","../src/ugc-node-wires.ts"],"names":[],"mappings":";;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AACl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A,CAAQ,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,CAAO,SAAA,GAAY,EAAE,CAAA;AAAA,IACjF,WAAA,EAAa,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,MAAM,CAAA,GAAI,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,MAAA,EAAO,GAAI,kBAAkB,CAAA;AAAA,IACvF,MAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAI;AAAA,GACzB;AACF","file":"chunk-D7DCDIMU.js","sourcesContent":["/** One fan-out item's notes: its warnings and its real length (UGC Clip). */\nexport interface FanOutItemMeta { readonly warnings: readonly string[]; readonly durationSec: number | null }\n/** One row of UGC Cards' `notes` input. */\nexport interface ClipNote { readonly clip: number; readonly warnings: readonly string[]; readonly durationSec?: number }\n\nexport function fanOutItemMeta(output: { clipWarnings?: unknown; durationSec?: unknown } | null | undefined): FanOutItemMeta {\n const w = output?.clipWarnings\n const d = output?.durationSec\n return {\n warnings: Array.isArray(w) ? w.filter((x): x is string => typeof x === \"string\") : [],\n durationSec: typeof d === \"number\" && Number.isFinite(d) && d > 0 ? d : null,\n }\n}\n\n/** Row-aligned meta (or one single output) → the notes UGC Cards reads, clip numbers from 1. */\nexport function clipNotesFrom(meta: ReadonlyArray<FanOutItemMeta | null | undefined> | undefined, single?: FanOutItemMeta): ClipNote[] {\n const rows = meta && meta.length > 0 ? meta : single ? [single] : []\n return rows.map((m, i) => ({\n clip: i + 1,\n warnings: m?.warnings ?? [],\n ...(typeof m?.durationSec === \"number\" ? { durationSec: m.durationSec } : {}),\n }))\n}\n","/** The UGC node types (Cloud only; served by a private plugin). */\nexport const UGC_NODE_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\", \"ugc-clips\", \"ugc-clip\", \"ugc-cards\", \"ugc-finish-clips\"])\n\n/** UGC Creator: the node-data key that holds a round's passing candidates until the person picks one (run state). */\nexport const UGC_CREATOR_CANDIDATES_KEY = \"candidates\"\n\n/** A run that would execute a UGC Creator whose options wait for the person's pick. */\nexport const UGC_PICK_FIRST_MESSAGE = \"Pick a creator first.\"\n\n/**\n * Per UGC type, the node-data keys that are a RUN's state, never a choice. A\n * published app's snapshot is readable by every runner, so publishing strips\n * them (the last plan, the clip tickets, the publisher's kept creator).\n *\n * UGC Creator's image (`generatedImageUrl`) goes from every creator, whatever its\n * source: after a My photo run it IS the author's photo, and a creator switched\n * to another source after such a run, or whose photo was removed, still holds it.\n * UGC Clip's takes and UGC Cards' Notes (`generatedText`, and `text`, the Notes\n * as a run hands them on) are the author's renders: a published node starts empty.\n *\n * A published snapshot is stripped through `stripUgcPublishState`\n * (@nodaro/render-rules), which also empties every run result a lane writes under\n * a generic name, every node made from the UGC video, and every node on a path\n * into a UGC Creator's photo input.\n */\nexport const UGC_NODE_RUN_STATE_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"result\", \"keepResult\", \"ugcOutputs\", UGC_CREATOR_CANDIDATES_KEY, \"optionFailed\", \"generatedImageUrl\"],\n // `exampleLines`: a template's example run, shown until the node's own first script (display only).\n \"ugc-script\": [\"result\", \"keepResult\", \"ugcOutputs\", \"exampleLines\"],\n \"ugc-clips\": [\"result\", \"quote\", \"__listResults\", \"ugcOutputs\"],\n \"ugc-clip\": [\n \"warnings\", \"rerender\", \"rerenderPending\", \"__listResults\", \"__listResultMeta\", \"clipWarnings\", \"durationSec\", \"ugcOutputs\",\n \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\",\n ],\n \"ugc-cards\": [\"result\", \"ugcOutputs\", \"generatedText\", \"text\"],\n \"ugc-finish-clips\": [\"ugcOutputs\", \"__listResults\", \"__listResultMeta\", \"generatedVideoUrl\", \"generatedResults\", \"activeResultIndex\"],\n}\n\n/**\n * The ONLY UGC keys a run request's `inputOverrides` may set — an allow-list,\n * so a run-state field added later is locked without anyone listing it.\n *\n * No UGC type may gain a `LEGACY_EXPOSED_FIELD_KEYS` row: the lock reads the\n * stored key, before that table renames it.\n */\nexport const UGC_OVERRIDABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"source\", \"gender\", \"photoUrl\"],\n \"ugc-script\": [\"targetDurationSec\", \"language\"],\n \"ugc-clips\": [],\n \"ugc-clip\": [],\n \"ugc-cards\": [],\n \"ugc-finish-clips\": [],\n}\n\nconst KEEP_RESULT_TYPES: ReadonlySet<string> = new Set([\"ugc-creator\", \"ugc-script\"])\n\n/** UGC Creator holds options for the person to pick: the ones a run drew, or the ones a credits stop kept. */\nexport function ugcPickPending(data: unknown): boolean {\n const candidates = data && typeof data === \"object\" ? (data as Record<string, unknown>)[UGC_CREATOR_CANDIDATES_KEY] : undefined\n return Array.isArray(candidates) && candidates.length > 0\n}\n\n/**\n * A run that would execute a UGC Creator whose options wait is refused (\"Pick a creator first.\"),\n * except that creator's own re-draw. One rule for the editor's check before a run and the\n * orchestrator's.\n */\nexport function ugcRunWaitsForPick(\n runNodes: ReadonlyArray<{ readonly id: string; readonly type?: string | null; readonly data?: unknown }>,\n opts: { readonly redrawId?: string } = {},\n): boolean {\n return runNodes.some((n) => n.type === \"ugc-creator\" && n.id !== opts.redrawId && ugcPickPending(n.data))\n}\n\n/**\n * Per UGC type, the author's own content a published snapshot never carries: UGC Creator's photo\n * of a person (`photoUrl`). A choice, not run state — so it stays on the author's own workflow —\n * but a runner gives their own photo (or the run is refused for want of one) and a template's\n * cloner adds theirs.\n */\nexport const UGC_PUBLISH_PRIVATE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"photoUrl\"],\n}\n\n/**\n * The UGC types' own strip: a copy of `nodes` with every UGC node's run state and the author's own\n * photo removed (and `keepResult: false`). Other nodes are returned as they are. Publishing, a\n * share link's view and a viewer's run go through `stripUgcPublishState` (@nodaro/render-rules),\n * which starts here.\n */\nexport function stripUgcRunState<T extends { type?: unknown; data?: unknown }>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!UGC_NODE_TYPES.has(type) || !node.data || typeof node.data !== \"object\") return node\n const data: Record<string, unknown> = { ...(node.data as Record<string, unknown>) }\n for (const key of UGC_NODE_RUN_STATE_KEYS[type] ?? []) delete data[key]\n for (const key of UGC_PUBLISH_PRIVATE_FIELDS[type] ?? []) delete data[key]\n if (KEEP_RESULT_TYPES.has(type)) data.keepResult = false\n return { ...node, data }\n })\n}\n\n/** Every override entry that would set a non-overridable key on a UGC node, in node then key order. Pure. */\nexport function findUgcLockedFields(\n nodes: ReadonlyArray<{ id: string; type?: string }> | null | undefined,\n inputOverrides: Record<string, Record<string, unknown>> | null | undefined,\n): Array<{ nodeId: string; nodeType: string; field: string }> {\n if (!nodes || !inputOverrides) return []\n const found: Array<{ nodeId: string; nodeType: string; field: string }> = []\n for (const node of nodes) {\n const type = node?.type\n if (typeof type !== \"string\" || !UGC_NODE_TYPES.has(type)) continue\n const allowed = UGC_OVERRIDABLE_FIELDS[type] ?? []\n const fields = inputOverrides[node.id]\n if (!fields || typeof fields !== \"object\") continue\n for (const field of Object.keys(fields)) {\n if (!allowed.includes(field)) found.push({ nodeId: String(node.id), nodeType: type, field })\n }\n }\n return found\n}\n","/**\n * The UGC node wires: every request body the five UGC nodes send and every\n * output they hand on, as ONE pure implementation that both engines (the\n * workflow orchestrator and the editor) call, so the two can never disagree.\n *\n * Content-free. A creator record is read only for `v`, `gender` and\n * `identityImages`, a plan only for `v`, a clip ticket only for `v`, `index`\n * and `durationSec`; every other key is opaque and passes through as it came.\n * Every UGC-private JSON a node emits carries `v: 1`, and a wire with another\n * `v` is refused, never guessed at.\n */\nimport type { CaptionPlan } from \"./caption-plan.js\"\nimport { fanOutItemMeta, type ClipNote } from \"./fan-out-meta.js\"\nimport { DEFAULT_TRANSCRIBE_NODE_PROVIDER } from \"./model-constants.js\"\nimport { ugcPickPending } from \"./ugc-run-state.js\"\n\n/** A UGC call that reached a deployment without the UGC routes (the router's 404). */\nexport const UGC_NOT_SERVED_MESSAGE = \"UGC videos are a Nodaro Cloud feature and are not served on this deployment.\"\n/** A wire whose `v` this app does not read. */\nexport const UGC_VERSION_MESSAGE = \"This workflow was made with a newer version of the UGC nodes.\"\n/** An answer this app cannot run: a tool it does not know, or a shape it cannot read. */\nexport const UGC_NEWER_APP_MESSAGE = \"This step needs a newer app version.\"\n/** A creator pick whose options are gone (another run replaced them, or they were never this node's). */\nexport const UGC_PICK_GONE_MESSAGE = \"These creator options are no longer available. Run UGC Creator again.\"\n/** UGC Clips with no creator on its creator input (UGC Creator has not run, or waits for a pick). */\nexport const UGC_CREATOR_MISSING_MESSAGE = \"UGC Creator has no creator yet. Run it, or pick one of its options.\"\n/** UGC Script's target length in seconds when the node holds none: the node's default (the route requires a length). */\nexport const UGC_SCRIPT_DEFAULT_TARGET_SEC = 15\n/** The range of a UGC script's length, in whole seconds: the script route's, and a plan's own. */\nexport const UGC_SCRIPT_MIN_TARGET_SEC = 4\nexport const UGC_SCRIPT_MAX_TARGET_SEC = 300\n\nconst MINOR_AGE_MESSAGE = \"That age can't be used: UGC creators are adults only.\"\nconst NEEDS_GENDER = \"Choose woman or man.\"\nconst NEEDS_PHOTO = \"Connect or upload a photo of yourself.\"\nconst NEEDS_CATEGORY = \"Run UGC Script first, or pick a product category.\"\nconst NEEDS_SITE = \"Add the product name or website.\"\n/** The opening of the sentence UGC Clips fails with when the plugin refuses the script: \"<this> <each error and its fix>\". */\nexport const UGC_SCRIPT_NEEDS_CHANGES = \"The script needs changes:\"\nconst NEEDS_PLAN_OUT = \"Connect the Script (sized) output of UGC Clips.\"\nconst NEEDS_PLAN = \"Connect the Script output of UGC Script.\"\nconst NEEDS_TICKET = \"Connect the Clips output of UGC Clips.\"\nconst NEEDS_VIDEO = \"Connect the joined video.\"\nconst NEEDS_TRANSCRIPT = \"Connect the Transcript output of UGC Clips.\"\n/**\n * A run of a video whose clips are cut from one recorded speech, on a graph with no UGC Finish on this UGC\n * Clips' Script (sized) output: refused before anything is spent.\n */\nexport const UGC_NEEDS_FINISH_MESSAGE = \"Add a UGC Finish node after UGC Clip, and connect UGC Clips' Script (sized) output to it.\"\n/** UGC Finish with nothing on its clips input. */\nexport const UGC_FINISH_NEEDS_CLIPS_MESSAGE = \"Connect the Video output of UGC Clip.\"\n/** UGC Finish's job answered that a clip does not follow its speech (each clip checks itself first, so this is rare). */\nexport const UGC_FINISH_NOT_READY_MESSAGE = \"A clip did not follow its speech. Re-render it from the UGC Clip node and run again.\"\n/**\n * A video cut from one recorded speech whose clips, priced once the speech is split, would hold more\n * than the run was checked for before it started: the run stops at UGC Clips, before any clip renders.\n */\nexport const UGC_OVER_HOLD_MESSAGE =\n \"The clips for this recording would cost more than this run was checked for, so none was rendered. Run UGC Clips again to record the speech again.\"\n\n/**\n * Every fixed sentence a UGC node fails with, by id: the English both engines write on the node.\n * The editor shows each in the person's language by its id. Not listed: the sentence that opens\n * with `UGC_SCRIPT_NEEDS_CHANGES` (the plugin's own words finish it), a route's own message, and\n * \"UGC step failed (<status>)\".\n */\nexport const UGC_NODE_MESSAGES = Object.freeze({\n notServed: UGC_NOT_SERVED_MESSAGE,\n version: UGC_VERSION_MESSAGE,\n newerApp: UGC_NEWER_APP_MESSAGE,\n pickGone: UGC_PICK_GONE_MESSAGE,\n creatorMissing: UGC_CREATOR_MISSING_MESSAGE,\n minorAge: MINOR_AGE_MESSAGE,\n needsGender: NEEDS_GENDER,\n needsPhoto: NEEDS_PHOTO,\n needsCategory: NEEDS_CATEGORY,\n needsSite: NEEDS_SITE,\n needsPlanOut: NEEDS_PLAN_OUT,\n needsPlan: NEEDS_PLAN,\n needsTicket: NEEDS_TICKET,\n needsVideo: NEEDS_VIDEO,\n needsTranscript: NEEDS_TRANSCRIPT,\n needsFinish: UGC_NEEDS_FINISH_MESSAGE,\n finishNeedsClips: UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n finishNotReady: UGC_FINISH_NOT_READY_MESSAGE,\n overHold: UGC_OVER_HOLD_MESSAGE,\n} as const)\n\n/** The id of a fixed sentence a UGC node fails with (`UGC_NODE_MESSAGES`). */\nexport type UgcNodeMessageId = keyof typeof UGC_NODE_MESSAGES\n\n/** UGC Script's screenshot inputs, in card order. */\nexport const UGC_SCREENSHOT_HANDLES: readonly string[] = [\n \"screenshot\", \"screenshot2\", \"screenshot3\", \"screenshot4\", \"screenshot5\", \"screenshot6\", \"screenshot7\", \"screenshot8\",\n]\n\n/** Per UGC type, the output an edge with no source handle reads. */\nexport const UGC_PRIMARY_HANDLE: Readonly<Record<string, string>> = {\n \"ugc-creator\": \"creator\",\n \"ugc-script\": \"plan\",\n \"ugc-clips\": \"clips\",\n \"ugc-clip\": \"video-out\",\n \"ugc-cards\": \"layerPlan\",\n \"ugc-finish-clips\": \"video-out\",\n}\n\n/** A UGC node's outputs: handle id → the value that handle carries (a JSON string, text or a URL). */\nexport type UgcOutputs = Readonly<Record<string, string>>\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/**\n * The length a saved UGC plan was written to: its own `targetDurationSec`, a whole number of\n * seconds in the script's range. Besides the lines (the opening line, each beat's line, the\n * closing line), one of the two keys of a plan the app reads (the other: whether each beat carries\n * a screenshot, `ugcPlanScreenshotCount`): a script that hands on its saved plan is priced at the\n * plan's length, and shows it, never at the length setting, which may have changed since. Takes\n * the plan or its wire (a JSON string); undefined for anything that is not a plan carrying a length.\n */\nexport function ugcPlanLengthSec(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value) return undefined\n const sec = value.targetDurationSec\n return typeof sec === \"number\" && Number.isInteger(sec) && sec >= UGC_SCRIPT_MIN_TARGET_SEC && sec <= UGC_SCRIPT_MAX_TARGET_SEC ? sec : undefined\n}\n\n/**\n * How many of a saved UGC plan's beats carry a screenshot: the screenshot cards the plan was\n * written with. Read beat by beat: a beat carries one when its `screenshot` is an object, as the\n * plan's own screenshots are (whatever it names); a beat that is not an object, or whose screenshot\n * is anything else, carries none — and never makes the rest unreadable. A plan whose beats carry\n * none is a talking-head plan (0). Read, like its length, so a script that hands on its saved plan\n * is priced at the screenshots that plan holds, never at the script's wires, which may have changed\n * since. Takes the plan or its wire (a JSON string); undefined only for a plan with no beats to read\n * and for anything that is not a plan.\n */\nexport function ugcPlanScreenshotCount(plan: unknown): number | undefined {\n const value = savedPlanOf(plan)\n if (!value || !Array.isArray(value.beats)) return undefined\n return value.beats.filter((beat) => isObject(beat) && isObject(beat.screenshot)).length\n}\n\n/** A saved plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction savedPlanOf(plan: unknown): Obj | undefined {\n let value: unknown = plan\n if (typeof value === \"string\") {\n try {\n value = JSON.parse(value)\n } catch {\n return undefined\n }\n }\n return isObject(value) ? value : undefined\n}\n/** A string with something in it; an empty or blank field or input counts as absent. */\nconst filled = (x: unknown): string | undefined => (typeof x === \"string\" && x.trim() !== \"\" ? x : undefined)\n\n/**\n * What an edge from a UGC node reads, on both engines: the value of the pip it leaves — an edge\n * with no source handle reads the node's primary output — from the node's outputs by pip. Only a\n * pip the outputs hold as a string (\"\" included: an empty transcript is a value); an inherited\n * key or a non-string is no value.\n */\nexport function ugcPipValue(outputs: unknown, sourceType: string, sourceHandle?: string | null): string | undefined {\n const pip = sourceHandle || (Object.hasOwn(UGC_PRIMARY_HANDLE, sourceType) ? UGC_PRIMARY_HANDLE[sourceType] : undefined)\n if (pip === undefined || !isObject(outputs) || !Object.hasOwn(outputs, pip)) return undefined\n const value = outputs[pip]\n return typeof value === \"string\" ? value : undefined\n}\n\n/**\n * A UGC wire (a JSON string or an object) → its value when it is an object with `v: 1`.\n * Another `v` → the version message. Anything that is not a UGC wire at all (nothing\n * connected, not JSON, no `v`) → `unreadable`, which a node words as the input it needs.\n */\nexport function readUgcWire(raw: unknown, unreadable: string = UGC_VERSION_MESSAGE): { value: Record<string, unknown> } | { error: string } {\n let parsed: unknown = raw\n if (typeof raw === \"string\") {\n try {\n parsed = JSON.parse(raw)\n } catch {\n return { error: unreadable }\n }\n }\n if (!isObject(parsed) || parsed.v === undefined) return { error: unreadable }\n if (parsed.v !== 1) return { error: UGC_VERSION_MESSAGE }\n return { value: parsed }\n}\n\n/** The route's `{ error: { code, message } }` (or a framework error's top-level `message`). */\nfunction routeErrorOf(body: string): { code?: string; message?: string } {\n let parsed: unknown\n try {\n parsed = JSON.parse(body)\n } catch {\n return {}\n }\n if (!isObject(parsed)) return {}\n if (isObject(parsed.error)) {\n const { code, message } = parsed.error\n return { code: typeof code === \"string\" ? code : undefined, message: filled(message) }\n }\n return { message: filled(parsed.message) }\n}\n\n/**\n * A failed UGC call → the sentence the node fails with. A 404 that names no error code is\n * the router's (the route is not registered here) → the Cloud sentence; a route's own 404\n * names a code and keeps its message. `minor_age_refused` → the adults-only sentence. A 4xx\n * or 503 → the route's message. Anything else → \"UGC step failed (<status>)\".\n */\nexport function ugcFailure(status: number, body: string): string {\n const error = routeErrorOf(body)\n if (status === 404 && error.code === undefined) return UGC_NOT_SERVED_MESSAGE\n if (error.code === \"minor_age_refused\") return MINOR_AGE_MESSAGE\n if ((status === 503 || (status >= 400 && status < 500)) && error.message) return error.message\n return `UGC step failed (${status})`\n}\n\n// ── UGC Creator ──────────────────────────────────────────────────────────────\n\n/**\n * The pickers whose own set fields shape a sampled creator: the picker types UGC Creator's\n * `pickers` input takes (the route takes no other). One list for the editor's connection rule\n * and both engines' input resolvers.\n */\nexport const UGC_CREATOR_PICKER_TYPES: ReadonlySet<string> = new Set([\"person\", \"styling\", \"setting\", \"lighting\"])\n\n/** The UGC Creator node-data keys its request body reads. */\nexport interface UgcCreatorFields {\n readonly source?: string\n readonly gender?: string\n readonly photoUrl?: string\n readonly categoryOverride?: string\n readonly seed?: number\n readonly keepResult?: boolean\n readonly result?: Readonly<Record<string, unknown>>\n /** The options a draw left waiting for the pick (run state): read only for `previous`. */\n readonly candidates?: unknown\n}\n\n/** The traits of the latest creator the person saw: the first waiting option's, else the last result's (Keep off). */\nfunction previousTraits(data: UgcCreatorFields): unknown {\n if (ugcPickPending(data)) {\n const first: unknown = (data.candidates as readonly unknown[])[0]\n const record = isObject(first) ? first.record : undefined\n return isObject(record) ? record.traits : undefined\n }\n return !data.keepResult && isObject(data.result) ? data.result.traits : undefined\n}\n\n/** The wired pickers that set a field (their own fields, as the resolver read them); undefined when none did. */\nfunction setPickers(pickers: Record<string, Record<string, unknown>> | undefined): Record<string, Record<string, unknown>> | undefined {\n if (!pickers) return undefined\n const set = Object.entries(pickers).filter(([, fields]) => isObject(fields) && Object.keys(fields).length > 0)\n return set.length > 0 ? Object.fromEntries(set) : undefined\n}\n\n/**\n * The `/v1/ugc/creator` body. A photo: the wired photo, else the node's own. A sampled\n * creator: the product category (the node's override, else the wired one), the pickers that\n * set a field, the node's seed, and the traits of the latest creator the person saw as\n * `previous`, so the next one differs: the first option waiting for the pick, else — on a\n * re-run that does not keep the result — the last creator's. Refuses before any call.\n */\nexport function ugcCreatorBody(input: {\n data: UgcCreatorFields\n photoUrl?: string\n category?: string\n pickers?: Record<string, Record<string, unknown>>\n}): { body: Record<string, unknown> } | { error: string } {\n const { data } = input\n const gender = data.gender\n if (gender !== \"woman\" && gender !== \"man\") return { error: NEEDS_GENDER }\n if (data.source === \"photo\") {\n const imageUrl = filled(input.photoUrl) ?? filled(data.photoUrl)\n if (!imageUrl) return { error: NEEDS_PHOTO }\n return { body: { source: { kind: \"photo\", imageUrl, gender } } }\n }\n const productCategory = filled(data.categoryOverride) ?? filled(input.category)\n if (!productCategory) return { error: NEEDS_CATEGORY }\n const pickers = setPickers(input.pickers)\n const traits = previousTraits(data)\n return {\n body: {\n ...(typeof data.seed === \"number\" ? { seed: data.seed } : {}),\n source: {\n kind: \"sampled\",\n gender,\n productCategory,\n ...(pickers ? { pickers } : {}),\n ...(isObject(traits) ? { previous: traits } : {}),\n },\n },\n }\n}\n\n/**\n * The creator the node hands on: the record (`creator`, v1) and its first image (`image`).\n * `identityImages` are the images of the candidate the node hands on — the picked one where\n * a person picked. The record copies the listed fields only, so `candidates`, `fallback`,\n * `pick` and `image` never reach the `creator` wire.\n */\nexport function ugcCreatorOutputs(answer: Record<string, unknown>, identityImages: readonly string[]): { outputs: UgcOutputs; imageUrl: string; record: Record<string, unknown> } {\n const record: Record<string, unknown> = {\n v: 1,\n kind: answer.kind,\n gender: answer.gender,\n identityImages: [...identityImages],\n traits: answer.traits ?? null,\n seed: answer.seed ?? null,\n promptsVersion: answer.promptsVersion,\n productCategory: answer.productCategory ?? null,\n }\n const imageUrl = identityImages[0] ?? \"\"\n return { outputs: { creator: JSON.stringify(record), ...(imageUrl ? { image: imageUrl } : {}) }, imageUrl, record }\n}\n\n/** One builder call as the app runs it: `tool` and `args`, nothing else (a candidate's other keys, its model included, are never read). */\nexport interface UgcCreatorCall { readonly tool: string; readonly args: Readonly<Record<string, unknown>> }\n\n/** What a creator answer asks the node to render. */\nexport interface UgcCreatorCandidateCalls {\n /** Every candidate's image call, the primary first. One call (`image`) for an answer from before candidates; none for a photo. */\n readonly calls: readonly UgcCreatorCall[]\n /** The round's one moderation fallback: it runs once, and only when every candidate the run rendered was blocked. */\n readonly fallback: UgcCreatorCall | null\n /** \"user\": a person picks among `calls` where one can be asked; \"primary\": `calls[0]` alone; null: nothing to render (a photo). */\n readonly pick: \"user\" | \"primary\" | null\n}\n\nconst callOf = (raw: unknown): UgcCreatorCall | undefined => {\n if (!raw || typeof raw !== \"object\") return undefined\n const { tool, args } = raw as { tool?: unknown; args?: unknown }\n if (typeof tool !== \"string\" || !args || typeof args !== \"object\" || Array.isArray(args)) return undefined\n return { tool, args: args as Readonly<Record<string, unknown>> }\n}\nconst fallbackOf = (image: unknown): unknown => (image && typeof image === \"object\" ? (image as { fallback?: unknown }).fallback : undefined)\n\n/**\n * A `/v1/ugc/creator` answer's image calls. Content-free: reads `image` (`tool`, `args`,\n * `fallback`), `candidates[].tool|args`, `fallback` and `pick.how` — never a candidate's\n * model. An answer without `candidates` (an older builder) renders `image` alone, as before.\n */\nexport function ugcCreatorCandidates(answer: Readonly<Record<string, unknown>>): UgcCreatorCandidateCalls | { readonly error: string } {\n const listed = answer.candidates\n const noList = listed === undefined || listed === null || (Array.isArray(listed) && listed.length === 0)\n const noImage = answer.image === undefined || answer.image === null\n if (noList && noImage) return { calls: [], fallback: null, pick: null }\n if (noList) {\n const image = callOf(answer.image)\n if (!image) return { error: UGC_NEWER_APP_MESSAGE }\n return { calls: [image], fallback: callOf(fallbackOf(answer.image)) ?? null, pick: \"primary\" }\n }\n if (!Array.isArray(listed)) return { error: UGC_NEWER_APP_MESSAGE }\n const calls = listed.map(callOf)\n if (calls.some((c) => c === undefined)) return { error: UGC_NEWER_APP_MESSAGE }\n const how = (answer.pick as { how?: unknown } | null | undefined)?.how\n return {\n calls: calls as UgcCreatorCall[],\n fallback: callOf(answer.fallback) ?? callOf(fallbackOf(answer.image)) ?? null,\n pick: how === \"user\" && calls.length > 1 ? \"user\" : \"primary\",\n }\n}\n\n/** The calls a run renders: every candidate where a person is there to pick, else the primary alone. */\nexport function ugcCreatorCallsToRender(c: UgcCreatorCandidateCalls, opts: { readonly personPicks: boolean }): readonly UgcCreatorCall[] {\n return opts.personPicks && c.pick === \"user\" ? c.calls : c.calls.slice(0, 1)\n}\n\n/** One rendered candidate that passed its checks, kept on the node until the person picks (run state, never a wire). */\nexport interface UgcCreatorCandidate { readonly imageUrl: string; readonly record: Readonly<Record<string, unknown>> }\n\nexport function ugcCreatorCandidate(answer: Readonly<Record<string, unknown>>, images: readonly string[]): UgcCreatorCandidate {\n const out = ugcCreatorOutputs(answer as Record<string, unknown>, images)\n return { imageUrl: out.imageUrl, record: out.record }\n}\n\n/** A UGC Creator run output that waits for the person's pick: two or more options (`ugcCandidates`). */\nexport function ugcAwaitsPick(output: unknown): boolean {\n const candidates = isObject(output) ? output.ugcCandidates : undefined\n return Array.isArray(candidates) && candidates.length >= 2\n}\n\n/** The person's pick, read back from node data (untrusted): a stale index, a foreign list or another version is refused. */\nexport function ugcCreatorPick(candidates: unknown, index: number):\n { readonly result: Readonly<Record<string, unknown>>; readonly outputs: UgcOutputs; readonly imageUrl: string } | { readonly error: string } {\n const entry: unknown = Array.isArray(candidates) && Number.isInteger(index) && index >= 0 ? candidates[index] : undefined\n const imageUrl = (entry as { imageUrl?: unknown } | undefined)?.imageUrl\n const record = (entry as { record?: unknown } | undefined)?.record\n if (typeof imageUrl !== \"string\" || !record || typeof record !== \"object\" || Array.isArray(record)) return { error: UGC_PICK_GONE_MESSAGE }\n const r = record as Record<string, unknown>\n if (r.v !== 1) return { error: UGC_VERSION_MESSAGE }\n if (!Array.isArray(r.identityImages) || r.identityImages[0] !== imageUrl) return { error: UGC_PICK_GONE_MESSAGE }\n return { result: r, outputs: { creator: JSON.stringify(r), image: imageUrl }, imageUrl }\n}\n\n// ── UGC Script ───────────────────────────────────────────────────────────────\n\n/** The languages a UGC script can be written in: the node's choice (`UgcScriptData.language`). */\nexport const UGC_SCRIPT_LANGUAGES = [\"en\", \"he\"] as const\nexport type UgcScriptLanguage = (typeof UGC_SCRIPT_LANGUAGES)[number]\n\n/**\n * The `/v1/ugc/script` body: the product name or website (required), the screenshot slots\n * in card order with the empty ones dropped, the product image when set, the target length\n * (`UGC_SCRIPT_DEFAULT_TARGET_SEC` when the node holds no number), and the language (the\n * node's choice; English when it holds none or one this app does not know).\n */\nexport function ugcScriptBody(input: {\n site?: string\n screenshots: ReadonlyArray<string | undefined>\n productImage?: string\n targetDurationSec?: number\n language?: unknown\n}): { body: Record<string, unknown> } | { error: string } {\n const site = filled(input.site)?.trim()\n if (!site) return { error: NEEDS_SITE }\n const productImage = filled(input.productImage)\n return {\n body: {\n site,\n screenshots: input.screenshots.filter((s): s is string => filled(s) !== undefined),\n ...(productImage ? { productImage } : {}),\n targetDurationSec: typeof input.targetDurationSec === \"number\" ? input.targetDurationSec : UGC_SCRIPT_DEFAULT_TARGET_SEC,\n language: (UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(input.language) ? input.language : \"en\",\n },\n }\n}\n\n/** A finished UGC Script job → `plan` (the plan, v1) and `category` (text). */\nexport function ugcScriptOutputs(outputData: Record<string, unknown>): UgcOutputs {\n const plan = outputData.plan\n const category = filled(outputData.productCategory)\n return {\n ...(isObject(plan) ? { plan: JSON.stringify({ v: 1, ...plan }) } : {}),\n ...(category ? { category } : {}),\n }\n}\n\n/** UGC Script's last result, as the node holds it. */\nexport type UgcScriptResult = {\n plan: Record<string, unknown>\n productCategory: string\n warnings: unknown[]\n notes: string[]\n rounds: number\n}\n\n/** A finished UGC Script job → the node's `result`, written the same by both engines; none without a plan. */\nexport function ugcScriptResult(outputData: Readonly<Record<string, unknown>>): UgcScriptResult | undefined {\n const { plan, productCategory, warnings, notes, rounds } = outputData\n if (!isObject(plan)) return undefined\n return {\n plan,\n productCategory: filled(productCategory) ?? \"\",\n warnings: Array.isArray(warnings) ? [...warnings] : [],\n notes: Array.isArray(notes) ? notes.filter((n): n is string => typeof n === \"string\") : [],\n rounds: typeof rounds === \"number\" && Number.isFinite(rounds) ? rounds : 0,\n }\n}\n\n// ── Kept results ─────────────────────────────────────────────────────────────\n\n/**\n * What a UGC Creator or UGC Script with Keep on hands on instead of running: the outputs of\n * the result it holds. Null — the node runs — when Keep is off, when the result holds nothing\n * to hand on (a creator without its image, a script without its plan), and for a creator whose\n * options wait for a pick, whatever Keep says. The creator record goes on unread; whoever reads\n * it refuses another version.\n */\nexport function ugcKeptOutputs(type: \"ugc-creator\" | \"ugc-script\", data: Readonly<Record<string, unknown>>): UgcOutputs | null {\n if (type === \"ugc-creator\" && ugcPickPending(data)) return null\n const result = data.keepResult === true ? data.result : undefined\n if (!isObject(result)) return null\n if (type === \"ugc-creator\") {\n const image = Array.isArray(result.identityImages) ? filled(result.identityImages[0]) : undefined\n return image ? { creator: JSON.stringify(result), image } : null\n }\n if (type === \"ugc-script\") return isObject(result.plan) ? ugcScriptOutputs(result) : null\n return null\n}\n\n// ── UGC Clips ────────────────────────────────────────────────────────────────\n\n/** The `/v1/ugc/clips` canvas body: the plan, the creator's gender, traits and images, and the picked voice. */\nexport function ugcClipsBody(input: { planWire: unknown; creatorWire: unknown; voiceId?: string }): { body: Record<string, unknown> } | { error: string } {\n const plan = readUgcWire(input.planWire, NEEDS_PLAN)\n if (\"error\" in plan) return plan\n const creator = readUgcWire(input.creatorWire, UGC_CREATOR_MISSING_MESSAGE)\n if (\"error\" in creator) return creator\n const voiceId = filled(input.voiceId)\n return {\n body: {\n plan: plan.value,\n gender: creator.value.gender,\n traits: creator.value.traits ?? null,\n identityImages: creator.value.identityImages,\n surface: \"canvas\",\n ...(voiceId ? { voiceId } : {}),\n },\n }\n}\n\n/**\n * The `/v1/ugc/clips` answer → the tickets (one per clip, as JSON strings), `clips` (the\n * first), `plan-out` (`{ v: 1, plan, transcribeArgs }` for UGC Cards), `transcript`, whether\n * the plan has cards, and whether the clips go through UGC Finish's job (`finishes`: the plan-out\n * carries a finish call, which is what UGC Finish reads to run it). An answer with errors → \"The script needs changes: …\" with each\n * error and its fix; an answer without the parts UGC Cards needs fails here, before any clip\n * is paid for.\n */\nexport function ugcClipsOutputs(answer: Record<string, unknown>): { outputs: UgcOutputs; tickets: string[]; hasCards: boolean; finishes: boolean } | { error: string } {\n const errors = Array.isArray(answer.errors) ? answer.errors : []\n if (errors.length > 0) {\n const said = errors.flatMap((e) => (isObject(e) ? [filled(e.message), filled(e.fix)] : [])).filter((s): s is string => s !== undefined)\n return { error: said.length > 0 ? `${UGC_SCRIPT_NEEDS_CHANGES} ${said.join(\" \")}` : UGC_NEWER_APP_MESSAGE }\n }\n const { tickets, sizedPlan, transcript, speechCheckCall } = answer\n if (!Array.isArray(tickets) || tickets.length === 0 || !tickets.every(isObject) || !isObject(sizedPlan) || typeof transcript !== \"string\") {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n const wires = tickets.map((t) => JSON.stringify(t))\n // The speech check's arguments ride to UGC Cards' transcription unread (an answer without them: none).\n const transcribeArgs = isObject(speechCheckCall) && isObject(speechCheckCall.args) ? speechCheckCall.args : {}\n // A video cut from one recorded speech (the segmented lane) also hands UGC Finish its finish call's\n // arguments (the segments with their room), opaque; any other answer's plan-out is unchanged.\n const finish = isObject(answer.finish) && isObject(answer.finish.args) ? { finish: answer.finish.args } : {}\n return {\n outputs: { clips: wires[0]!, \"plan-out\": JSON.stringify({ v: 1, plan: sizedPlan, transcribeArgs, ...finish }), transcript },\n tickets: wires,\n hasCards: answer.hasCards === true,\n finishes: \"finish\" in finish,\n }\n}\n\n// ── UGC Clip ─────────────────────────────────────────────────────────────────\n\n/**\n * The `/v1/ugc/clip` body for one ticket: the ticket, `nonce` = how many times this clip was\n * re-rendered (`rerender[\"<clip number>\"]`, else 0) and `runKey` when one is given.\n */\nexport function ugcClipBody(input: { ticketWire: unknown; rerender?: Readonly<Record<string, number>>; runKey?: string }):\n { body: Record<string, unknown>; clipNumber: number; durationSec: number } | { error: string } {\n const read = readUgcWire(input.ticketWire, NEEDS_TICKET)\n if (\"error\" in read) return read\n const ticket = read.value\n const { index, durationSec } = ticket\n if (typeof index !== \"number\" || !Number.isInteger(index) || index < 0) return { error: NEEDS_TICKET }\n if (typeof durationSec !== \"number\" || !Number.isFinite(durationSec) || durationSec <= 0) return { error: NEEDS_TICKET }\n const clipNumber = index + 1\n const count = input.rerender?.[String(clipNumber)]\n const nonce = typeof count === \"number\" && Number.isInteger(count) && count >= 0 ? count : 0\n const runKey = filled(input.runKey)\n return { body: { ticket, nonce, ...(runKey ? { runKey } : {}) }, clipNumber, durationSec }\n}\n\n/**\n * A finished UGC Clip job (`{ videoUrl, durationSec, clipWarnings, … }`) → `video-out`, the\n * clip's real length (null when unknown) and its warnings ([] when it has none).\n */\nexport function ugcClipOutputs(outputData: Record<string, unknown>): { outputs: UgcOutputs; videoUrl: string; durationSec: number | null; clipWarnings: string[] } {\n const videoUrl = filled(outputData.videoUrl) ?? \"\"\n const meta = fanOutItemMeta(outputData)\n return { outputs: videoUrl ? { \"video-out\": videoUrl } : {}, videoUrl, durationSec: meta.durationSec, clipWarnings: [...meta.warnings] }\n}\n\n/**\n * What a list read (a Bundle edge, a fold) takes from a UGC Clip's saved data, on both engines:\n * its last fanned-out batch — one take per clip, in clip order — when its last run was one; else\n * exactly the take it shows (its active result, else its video). Never the earlier takes it keeps:\n * a video of one clip (one ticket, so no fan-out) would join every take. A single run clears the\n * batch (the editor's job patch), so a batch held is always the last run's. Undefined when it holds\n * no take at all.\n */\nexport function ugcClipSavedList(data: unknown): string[] | undefined {\n if (!isObject(data)) return undefined\n const batch = Array.isArray(data.__listResults) ? data.__listResults.filter((u): u is string => typeof u === \"string\" && u !== \"\") : []\n if (batch.length > 0) return batch\n const results = Array.isArray(data.generatedResults) ? data.generatedResults : []\n const index = typeof data.activeResultIndex === \"number\" && Number.isInteger(data.activeResultIndex) ? data.activeResultIndex : 0\n const active = results[index]\n const url = (isObject(active) ? filled(active.url) : undefined) ?? filled(data.generatedVideoUrl)\n return url ? [url] : undefined\n}\n\n// ── UGC Cards ────────────────────────────────────────────────────────────────\n\n/**\n * UGC Cards' two timing jobs on the joined video, and the plan they time. The plan input must\n * be UGC Clips' `{ v: 1, plan, transcribeArgs }`; anything else is refused before either job.\n * The transcription spreads `transcribeArgs` unread, then sets the node's own fields last, so\n * the wire can add a language but never change the provider or the word timings.\n */\nexport function ugcCardsJobs(input: { planOutWire: unknown; videoUrl?: string; transcript?: string }): {\n alignment: { path: \"/v1/forced-alignment\"; body: Record<string, unknown> }\n transcribe: { path: \"/v1/transcribe\"; body: Record<string, unknown> }\n plan: Record<string, unknown>\n} | { error: string } {\n const read = readUgcWire(input.planOutWire, NEEDS_PLAN_OUT)\n if (\"error\" in read) return read\n const { plan, transcribeArgs } = read.value\n if (!isObject(plan) || !isObject(transcribeArgs)) return { error: NEEDS_PLAN_OUT }\n const videoUrl = filled(input.videoUrl)\n if (!videoUrl) return { error: NEEDS_VIDEO }\n // An empty transcript is what UGC Clips said, not a missing input: it goes on as it came.\n const transcript = input.transcript\n if (typeof transcript !== \"string\") return { error: NEEDS_TRANSCRIPT }\n return {\n alignment: { path: \"/v1/forced-alignment\", body: { audioUrl: videoUrl, transcript } },\n transcribe: { path: \"/v1/transcribe\", body: { ...transcribeArgs, audioUrl: videoUrl, provider: DEFAULT_TRANSCRIBE_NODE_PROVIDER, wordTimestamps: true } },\n plan,\n }\n}\n\n/**\n * The `/v1/ugc/cards` canvas body: the plan, the video, whichever timing came back as a list,\n * the timing jobs that failed, and the clips' notes.\n */\nexport function ugcCardsBody(input: {\n plan: Record<string, unknown>\n videoUrl: string\n alignment?: unknown\n words?: unknown\n failed: ReadonlyArray<\"alignment\" | \"words\">\n clipNotes: ReadonlyArray<ClipNote>\n}): Record<string, unknown> {\n return {\n surface: \"canvas\",\n plan: input.plan,\n videoUrl: input.videoUrl,\n ...(Array.isArray(input.alignment) ? { alignment: input.alignment } : {}),\n ...(Array.isArray(input.words) ? { words: input.words } : {}),\n failed: [...input.failed],\n clipNotes: [...input.clipNotes],\n }\n}\n\n/** The caption plan when nothing could be timed: Add Captions renders no captions from it. */\nconst EMPTY_CAPTION_PLAN: CaptionPlan = { v: 1, hookText: \"\", hookEndMs: 0, bodyEndMs: 0, captions: [] }\n\n/** The `/v1/ugc/cards` answer → `layerPlan`, `captionPlan` (v1; the empty plan when untimed) and `report` (one line per sentence). */\nexport function ugcCardsOutputs(answer: Record<string, unknown>): UgcOutputs {\n const timing = answer.captionTiming\n const report = answer.report\n const lines = isObject(report) && Array.isArray(report.lines) ? report.lines.filter((l): l is string => typeof l === \"string\") : []\n return {\n layerPlan: JSON.stringify(Array.isArray(answer.layerPlan) ? answer.layerPlan : []),\n captionPlan: JSON.stringify(isObject(timing) ? { v: 1, ...timing } : EMPTY_CAPTION_PLAN),\n report: lines.join(\"\\n\"),\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UGC_PRIMARY_HANDLE } from './chunk-
|
|
1
|
+
import { UGC_PRIMARY_HANDLE } from './chunk-D7DCDIMU.js';
|
|
2
2
|
import { composeUnitSet, unitProducers, composeUnitRecord, unitFanOutEach, unitListPips } from './chunk-S6DXSQCV.js';
|
|
3
|
-
import { isSeedance2Provider, isMinimaxH3Provider, isWan3Provider, isKling4RunnerProvider, isViduQ4Provider, isGeminiOmniPerSecondProvider, isPixverseV6MaxProvider, PRICING_DEFAULT_RESOLUTION, isGeminiOmniProvider } from './chunk-
|
|
4
|
-
import { MODEL_CATALOG } from './chunk-
|
|
3
|
+
import { isSeedance2Provider, isMinimaxH3Provider, isWan3Provider, isKling4RunnerProvider, isViduQ4Provider, isGeminiOmniPerSecondProvider, isPixverseV6MaxProvider, PRICING_DEFAULT_RESOLUTION, isGeminiOmniProvider } from './chunk-SXDLBXSB.js';
|
|
4
|
+
import { MODEL_CATALOG } from './chunk-X7UDZGXW.js';
|
|
5
5
|
|
|
6
6
|
// src/producer-types.ts
|
|
7
7
|
var VIDEO_PRODUCER_TYPES = composeUnitSet("VIDEO_PRODUCER_TYPES", [
|
|
@@ -329,5 +329,5 @@ function uiDurationFill(provider) {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
export { AUDIO_PRODUCER_TYPES, DYNAMIC_PRODUCER_TYPES, FAN_IN_TARGETS, FAN_OUT_ALL_OR_NOTHING_TYPES, FAN_OUT_EACH_HANDLES, FAN_OUT_EACH_TYPES, IMAGE_PRODUCER_TYPES, LIST_OUTPUT_HANDLES, OWN_LIST_NODE_TYPES, VIDEO_PRODUCER_TYPES, defaultEdgeOutputMode, isFanInEdge, isFanInNodeType, isListOutputHandle, listResultsServeHandle, ownsItsList, uiAspectRatioFill, uiDurationFill, uiResolutionFill };
|
|
332
|
-
//# sourceMappingURL=chunk-
|
|
333
|
-
//# sourceMappingURL=chunk-
|
|
332
|
+
//# sourceMappingURL=chunk-EI4V43DI.js.map
|
|
333
|
+
//# sourceMappingURL=chunk-EI4V43DI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/producer-types.ts","../src/video-ui-defaults.ts"],"names":[],"mappings":";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F,EAAA,OAAO,MAAA;AACT;AAWO,SAAS,eAAe,QAAA,EAAsC;AACnE,EAAA,IAAI,cAAA,CAAe,QAAQ,CAAA,IAAK,gBAAA,CAAiB,QAAQ,CAAA,IAAK,sBAAA,CAAuB,QAAQ,CAAA,IAAK,uBAAA,CAAwB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC5I,EAAA,IAAI,oBAAA,CAAqB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT","file":"chunk-QME5O4NG.js","sourcesContent":["/**\n * Producer-type sets — single source of truth for the node types whose\n * primary output is a video URL, audio URL, etc.\n *\n * Consumed by:\n * - backend/src/services/workflow-engine/execution-graph.ts (orchestrator\n * dispatch + asset-type tagging in payload-builder, output-extractor,\n * inline-executor — re-exported there as VIDEO_SOURCE_TYPES /\n * AUDIO_SOURCE_TYPES for backwards compatibility).\n * - frontend/src/lib/generate-video-handles.ts (handle connection\n * validation on the Generate Video node).\n *\n * Lifting these here ensures the frontend handle validator can never reject\n * a connection from a node type that the backend would happily route at\n * execution time (the prior drift bug, see issue 1 of the Task 4.1 review).\n */\nimport { UGC_PRIMARY_HANDLE } from \"./ugc-node-wires.js\"\nimport { composeUnitRecord, composeUnitSet, unitFanOutEach, unitListPips, unitProducers } from \"./unit-contract-compose.js\"\n\n// Each producer set below is its hand-written members ∪ the node units\n// (tools/units/README.md) of that producer kind, from their generated contract\n// rows, in that order — a type in both throws at load (composeUnitSet).\n\n/**\n * Source node types whose primary output is a video URL.\n * Mirrors the backend execution-graph VIDEO_SOURCE_TYPES verbatim.\n */\nexport const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"VIDEO_PRODUCER_TYPES\", [\n \"image-to-video\",\n \"video-to-video\",\n \"switchx\", // Beeble SwitchX relight/composite\n \"text-to-video\",\n // Unified video node — emits videoUrl identically to i2v/t2v (its payload-builder\n // case dispatches dynamically to \"image-to-video\" or \"text-to-video\" jobName based\n // on whether a start frame is wired). Without this, getPrimaryOutput would fall\n // through to the imageUrl/videoUrl/audioUrl/text default and downstream consumers\n // could silently misroute the output.\n \"generate-video\",\n // Generate Video Pro — Seedance-2-family multi-segment stitch variant of\n // generate-video (same \"emits videoUrl\" contract; a trimmed provider +\n // handle set). Must mirror generate-video here or its output can't connect\n // downstream (the recurring \"cannot connect the outputs\" bug class).\n \"generate-video-pro\",\n // Edit Video Pro — Seedance-2-family span-replace sibling of generate-\n // video-pro (same \"emits videoUrl\" contract; source video + prompt in,\n // ONE video out). Must mirror generate-video-pro here or its output can't\n // connect downstream (the recurring \"cannot connect the outputs\" bug class).\n \"edit-video-pro\",\n \"upload-video\",\n \"youtube-video\",\n \"combine-videos\",\n \"lip-sync\",\n \"speech-to-video\",\n \"motion-transfer\",\n \"video-upscale\",\n \"video-depth\",\n \"extend-video\",\n // face-swap output is video (writes generatedVideoUrl, per-result `url`).\n // Frontend execution-graph already includes it in VIDEO_SOURCE_TYPES; this\n // entry brings the shared set in line so canvas typed-handle validation\n // doesn't reject face-swap → video-consumer edges that the orchestrator\n // would happily route at runtime.\n \"face-swap\",\n // Speaker View (C3.2): an EDL rendered with its speakers framed — one VIDEO\n // out (no audio-only render). Registered in RENDER_NODE_TYPES as well.\n \"speaker-view\",\n \"video-retake\",\n // video-sfx: adds an SFX track to a video → emits a video URL. Belongs here so\n // canvas handle validation accepts video-sfx → video-consumer edges and the\n // backend routes its output as video (it was previously relying on a fallback).\n \"video-sfx\",\n \"suno-music-video\",\n \"merge-video-audio\",\n // Replace Audio (Nodaro Cloud plugin): the video with its sound replaced → video.\n \"replace-audio\",\n \"add-captions\",\n \"resize-video\",\n \"social-media-format\",\n \"trim-video\",\n \"render-video\",\n \"speed-ramp\",\n \"loop-video\",\n \"fade-video\",\n // Video Mask emits its mask as a video; Mask Composite its composite.\n \"video-mask\",\n \"mask-composite\",\n \"transcode-video\",\n \"manual-edit\",\n // AI Avatar (HeyGen): avatar + voice/audio → video.\n \"ai-avatar\",\n // Cinematic Avatar (HeyGen cinematic_avatar): prompt + 1–3 avatar looks → video.\n \"cinematic-avatar\",\n // Assemble Narrated Video: fits N (clip, voice) blocks into one MP4 → video.\n \"assemble-narrated-video\",\n // Still to Video: one still image + one audio track → MP4 (local FFmpeg,\n // no provider). Emits generatedVideoUrl like every other ffmpeg video node.\n \"still-to-video\",\n // Slideshow: 2-100 stills + one optional audio track → MP4 (local FFmpeg,\n // no provider). Same contract; images arrive via the image-collage lane.\n \"slideshow\",\n // 3D Render Pro: authors a scene AND exports it in one operation, settling\n // with the standard `videoUrl` field. It is a video producer as much as it\n // is a composition producer — omitting it here is the \"cannot connect the\n // outputs\" bug, and its `composition` handle is typed separately.\n \"pro-3d-render\",\n // Video Overlay: timed image layers over a video in one local FFmpeg pass\n // (the base audio copied) — emits a video URL on `video-out`.\n \"video-overlay\",\n // UGC Clip: renders one clip of a UGC video from its ticket — emits a video\n // URL on `video-out` (one per fan-out iteration).\n \"ugc-clip\",\n // UGC Finish: the video's clips, finished, as one ordered list — a registered producer, so a\n // Bundle edge into Combine Videos routes each one as a video, in order.\n \"ugc-finish-clips\",\n], unitProducers(\"video\"))\n\n/**\n * Source node types whose output media-type cannot be classified\n * statically — iterators, dynamic dispatchers, sub-workflow wrappers.\n * The orchestrator decides their actual output type at execution time\n * based on what's wired upstream (loop iterates upstream column type;\n * sub-workflow emits its leaf node's type; adjust-volume passes through\n * video or audio based on its `lastInputType` runtime field;\n * voice-changer emits audio in audio mode, video+audio in video mode).\n *\n * Typed-handle validators (frontend/src/lib/{generate-image,generate-\n * video,ffmpeg}-handles.ts) must include these as acceptors on EVERY\n * media-typed input handle — otherwise the canvas validator hard-\n * rejects edges that the orchestrator would happily route at runtime.\n *\n * Lifted here from `frontend/src/lib/ffmpeg-handles.ts` (where the\n * escape hatch was first added) so the same set drives ALL handle\n * validators uniformly. Adding a new dynamic-output node type means\n * one edit here instead of N across sibling validator files.\n *\n * Intentionally OMITTED:\n * - `webhook-trigger` / `schedule-trigger` — their outputs are\n * user-defined JSON shapes, not media URLs. Accepting them as\n * media producers creates false-positive drops at the canvas\n * that fail at execution. Users wanting trigger → media flows\n * should wire through an upload node.\n */\nexport const DYNAMIC_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"DYNAMIC_PRODUCER_TYPES\", [\n \"list\",\n \"sub-workflow\",\n \"adjust-volume\",\n // Pitch & Tempo: audio in → audio out, video in → video out (picture\n // copied). Dual-mode like adjust-volume; stays in AUDIO_PRODUCER_TYPES as\n // its default.\n \"pitch-tempo\",\n // Dual-mode: audio in → audio out; video in → video out (+ revoiced audio).\n // Listed here so canvas validators accept its output on BOTH audio and video\n // input handles (it also stays in AUDIO_PRODUCER_TYPES as its default).\n \"voice-changer\",\n // voice-changer-pro (renamed from voice-recast in #3581) is a behavioral\n // twin of voice-changer — identical dual-mode output. Must mirror it in\n // EVERY producer set or its outputs can't connect (was the \"cannot connect\n // the outputs of voice-changer-pro\" bug). Guarded by producer-types.test.ts.\n \"voice-changer-pro\",\n // Dubbing joined the dual-mode family with the full-surface upgrade:\n // audio in → dubbed audio; video in (or a video sourceUrl) → dubbed VIDEO\n // (+ audio sidecar). Same wiring contract as voice-changer; stays in\n // AUDIO_PRODUCER_TYPES as its default. Explicitly asserted in\n // producer-types.test.ts (the suite does not fail on omission).\n \"dubbing\",\n \"reduce\",\n // Dual-output time chunker (UI label \"Split into Chunks\"; type id stays\n // \"split-media\"): video in → video chunks, audio in → audio chunks — two\n // independent lanes on two output handles. Like voice-changer, the canvas\n // validator only sees the source NODE type, not which handle a wire leaves,\n // so it lives here to be accepted on BOTH audio and video input handles. The\n // backend routes the correct lane by sourceHandle in getPrimaryOutput\n // (output-extractor.ts); the frontend does so in extractNodeOutput.\n \"split-media\",\n // apply-edl renders an EDL into ONE media output whose type is decided at\n // run time by the node's `output` setting (video OR audio) — so its static\n // medium is genuinely unknown and it belongs here, letting canvas validators\n // accept its default media handle on BOTH audio and video input handles. It\n // ALSO emits a fixed `json` handle (the remapped Transcript); that half lives\n // in JSON_PRODUCER_TYPES (frontend/src/lib/data-handles.ts). The FIRST node\n // with both a dynamic media handle and a fixed json handle. Because\n // getOutputType (presentation-utils.ts) deliberately returns \"data\" for\n // DYNAMIC members, apply-edl is ALSO added to the literal VIDEO_OUTPUT_TYPES\n // there so a published app renders the cut as video, mirroring the\n // voice-changer/dubbing precedent. Asserted in producer-types.test.ts (the\n // suite does not fail on omission).\n \"apply-edl\",\n], unitProducers(\"dynamic\"))\n\n/**\n * Source node types whose primary output is an audio URL.\n * Mirrors the backend execution-graph AUDIO_SOURCE_TYPES verbatim.\n */\nexport const AUDIO_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"AUDIO_PRODUCER_TYPES\", [\n \"text-to-speech\",\n \"text-to-audio\",\n \"generate-music\",\n \"upload-audio\",\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-separate\",\n \"audio-separation\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n \"trim-audio\",\n \"mix-audio\",\n \"combine-audio\",\n \"adjust-volume\",\n \"audio-fx\",\n \"pitch-tempo\",\n \"reference-audio\",\n \"audio-isolation\",\n \"text-to-dialogue\",\n \"voice-changer\",\n // Twin of voice-changer (see DYNAMIC_PRODUCER_TYPES note). Audio is its\n // default output mode; video mode is handled via DYNAMIC membership.\n \"voice-changer-pro\",\n \"dubbing\",\n \"voice-remix\",\n \"voice-design\",\n // Extract Audio: demuxes a video's audio track to a standalone MP3.\n \"extract-audio\",\n], unitProducers(\"audio\"))\n\n/**\n * Source node types whose output is an IMAGE URL — what feeds a References\n * input. ONE set for the canvas validators (`frontend/src/lib/\n * generate-image-handles.ts` re-exports it), the backend's Generate Image\n * handle migration and the MCP edge normalizer (`llm-chat`'s legacy `in`):\n * they used to keep separate copies, and the backend's lagged by eight types.\n */\nexport const IMAGE_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"IMAGE_PRODUCER_TYPES\", [\n \"upload-image\", \"generate-image\", \"edit-image\", \"image-to-image\", \"modify-image\", \"upscale-image\", \"remove-background\",\n // extract-frame produces a single still image extracted from a video source.\n \"extract-frame\",\n // generate-mask emits the source image AND a mask PNG; its `image` source\n // pip is the passthrough (the same image as the input).\n \"generate-mask\",\n // paint-mask emits the hand-painted mask PNG (a plain image at runtime).\n // Membership is what makes mask targets accept it — mask is an advisory\n // color, not a gated type.\n \"paint-mask\",\n // reference-sheet's `sheet` is one composited image and `panels` carries\n // clean reference images; both resolve to image URLs at runtime.\n \"reference-sheet\",\n // reference-board's `image` pip emits a real generated board image.\n \"reference-board\",\n // image-collage composites N images → ONE image.\n \"image-collage\",\n // image-overlay places layers on a base → ONE image.\n \"image-overlay\",\n // 3D Render Pro's `stills` handle carries one PNG per shot of the exported\n // composition (spread into referenceImageUrls like reference-sheet\n // `panels`). A validator sees only the source NODE type, so this also makes\n // its `video` pip droppable on an image input — the handle-blind trade\n // reference-sheet and split-media already make; the input resolvers route\n // by handle, so only `stills` becomes an image at runtime. Deliberately NOT\n // in IMAGE_SOURCE_TYPES on either engine: that set types the node's PRIMARY\n // asset, and 3D Render Pro's is the MP4.\n \"pro-3d-render\",\n], unitProducers(\"image\"))\n\n/**\n * Source node types whose primary output is a LIST that, by default, fans out\n * one downstream execution per element when an edge leaves them WITHOUT an\n * explicit `outputMode` (all other edges default to \"last\"). `selector` is\n * included because its picked/rest channels are lists too.\n *\n * Single source of truth for the fan-out \"each\" default, consumed by:\n * - backend/src/services/workflow-engine/input-resolver.ts (DEFAULT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/types.ts (FAN_OUT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/node-input-resolver.ts\n *\n * These three previously kept independent copies; the backend copy drifted\n * (missing the four list-transform types), so server-side workflow runs\n * silently dropped all-but-the-first item for filter-list / deduplicate /\n * merge-lists / sort-list sources while the canvas fanned out N ways. Lifting\n * the set here makes that drift impossible.\n */\nexport const FAN_OUT_EACH_TYPES: ReadonlySet<string> = new Set([\n \"list\",\n \"split-text\",\n \"filter-list\",\n \"deduplicate\",\n \"merge-lists\",\n \"sort-list\",\n \"selector\",\n // edit-plan `clips` mode emits a bare `Edl[]` on `data.generatedJson`, so an\n // edge leaving it defaults to \"each\" — one downstream execution (typically an\n // apply-edl render) per clip. The `tighten`/`chapters` modes emit an OBJECT,\n // for which the list extractors return undefined, so an \"each\" edge falls back\n // to the scalar `edl` value (no fan-out) — the same graceful degradation\n // web-scrape relies on. See `unwrapEditPlanOutput` in `edit-plan-contract.ts`.\n \"edit-plan\",\n // Content Ideas emits one creative brief per idea on `listResults`, so an\n // edge leaving it defaults to \"each\" — the node after it (typically\n // Generate Script) runs once per idea, on the server too.\n \"content-ideas\",\n])\n\n/**\n * Per-HANDLE \"each\" defaults, for a node whose outputs differ in kind: on the\n * `each` handles an edge without an explicit `outputMode` defaults to \"each\",\n * on its other handles to \"last\". `primary` is the handle an edge with no\n * `sourceHandle` reads (agent-written workflow JSON often omits it).\n *\n * The list an \"each\" edge reads is the node's per-iteration results\n * (`listResults`) — it exists only when the node itself ran once per item, so\n * after a single run the edge degrades to the single value, exactly like a\n * `FAN_OUT_EACH_TYPES` member with one item.\n *\n * Its hand-written rows ∪ the node units' rows (`contract.fanOutEach`,\n * generated/unit-contracts.ts); a type in both refuses to load.\n */\nexport const FAN_OUT_EACH_HANDLES: Readonly<Record<string, { readonly each: readonly string[]; readonly primary: string }>> = composeUnitRecord(\"FAN_OUT_EACH_HANDLES\", {\n // Camera Switch run once per clip (Edit Plan in clips mode): each clip's\n // switched EDL is its own Apply EDL render. Its transcript is the same for\n // every clip (the master clock, renamed), so that handle stays one value\n // (decided 2026-10-04).\n \"camera-switch\": { each: [\"edl\"], primary: \"edl\" },\n // UGC Clips: one ticket per clip on `clips` (each); `plan-out` and\n // `transcript` carry one value. Not a FAN_OUT_EACH_TYPES member — every\n // handle of such a member would fan out. Its one run writes the tickets as\n // its list (`listResults`, the editor's `__listResults`). The pip an edge\n // with no handle reads is the UGC wires' own (UGC_PRIMARY_HANDLE).\n \"ugc-clips\": { each: [\"clips\"], primary: UGC_PRIMARY_HANDLE[\"ugc-clips\"]! },\n // A node unit declares its row in unit.json (contract.fanOutEach); it is added after these.\n}, unitFanOutEach())\n\n/**\n * Fan-out nodes whose iterations must ALL succeed: one failed item fails the\n * node (today's rule tolerates a partial list). UGC Clip — a missing clip\n * silently drops a beat from the script (spec R17). Already-started items\n * finish and settle; their jobs are reused on the next run.\n */\nexport const FAN_OUT_ALL_OR_NOTHING_TYPES: ReadonlySet<string> = new Set([\"ugc-clip\"])\n\n/**\n * Nodes whose saved list is the list their last run PRODUCED — `__listResults`\n * (Extract Field's JSON value on `generatedJson`) — and never a history in\n * `generatedResults`: Extract Field, JSON Process and Site Capture. No run of the first two writes\n * one; earlier builds' server runs did (the run's text, the links of a list of\n * links), and both engines' list readers leave it out for these two (decided\n * 2026-10-05). Single source of truth for the backend engine and the editor.\n */\nexport const OWN_LIST_NODE_TYPES: ReadonlySet<string> = new Set([\n \"extract-field\",\n \"json-process\",\n // Site Capture: its stills, in page order — the last capture's, never every capture's (site-capture-node.ts).\n \"site-capture\",\n])\n\n/** Whether a node's saved list is its own `__listResults`, never a history. */\nexport function ownsItsList(nodeType: string | null | undefined): boolean {\n return typeof nodeType === \"string\" && OWN_LIST_NODE_TYPES.has(nodeType)\n}\n\n/**\n * The output pips that carry the LIST one run produced — several files on one\n * pip (a node unit's `handles.outputs[].list`: each layer of a split image). An\n * edge leaving one runs the next node once per item by default (\"each\"); a\n * Bundle hands the whole list to a node that takes several. Unlike\n * FAN_OUT_EACH_HANDLES, the list is what ONE run made on that pip, never the\n * node's per-iteration results. An edge naming no pip reads the node's primary\n * output, which is never a list pip (tools/units/json-output-rules.mjs).\n * Node units only (generated/unit-contracts.ts UNIT_LIST_PIPS).\n */\nexport const LIST_OUTPUT_HANDLES: Readonly<Record<string, readonly string[]>> = composeUnitRecord(\"LIST_OUTPUT_HANDLES\", {}, unitListPips())\n\n/** Whether an edge leaving `sourceHandle` of a `sourceType` node carries a list one run produced (LIST_OUTPUT_HANDLES). */\nexport function isListOutputHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n if (typeof sourceType !== \"string\" || typeof sourceHandle !== \"string\" || !Object.hasOwn(LIST_OUTPUT_HANDLES, sourceType)) return false\n return LIST_OUTPUT_HANDLES[sourceType]!.includes(sourceHandle)\n}\n\n/** The `outputMode` an edge has when none is set on it — the ONE rule both\n * engines, the credit estimate and the editor read. */\nexport function defaultEdgeOutputMode(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): \"each\" | \"last\" {\n if (typeof sourceType !== \"string\") return \"last\"\n if (FAN_OUT_EACH_TYPES.has(sourceType)) return \"each\"\n if (isListOutputHandle(sourceType, sourceHandle)) return \"each\"\n const entry = FAN_OUT_EACH_HANDLES[sourceType]\n if (!entry) return \"last\"\n return entry.each.includes(sourceHandle || entry.primary) ? \"each\" : \"last\"\n}\n\n/** Whether an edge from `sourceHandle` reads the node's per-iteration results\n * (`listResults` — each iteration's PRIMARY output). False on the other\n * handles of a `FAN_OUT_EACH_HANDLES` node: Camera Switch's transcript is one\n * value, never the list of switched EDLs, whatever mode its edge is set to. */\nexport function listResultsServeHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n const entry = typeof sourceType === \"string\" ? FAN_OUT_EACH_HANDLES[sourceType] : undefined\n return !entry || entry.each.includes(sourceHandle || entry.primary)\n}\n\n/**\n * FAN-IN targets: nodes that FOLD everything wired into them into ONE run,\n * instead of running once per upstream item. Keyed by node type; the value\n * names the target handles that fold (`\"*\"` = every handle). An edge into any\n * other handle of such a node is routed normally — Content Ideas folds its\n * recipes but reads its brand from a `field-brand` wire like any field.\n *\n * Single source of truth for both engines' input resolvers (the backend and\n * the editor each used to keep a private `new Set([\"reduce\"])`). A fan-in\n * node is never itself fanned out by an upstream list.\n */\nexport const FAN_IN_TARGETS: Readonly<Record<string, \"*\" | readonly string[]>> = {\n // Choose Best — every wire is a candidate.\n reduce: \"*\",\n // Content Ideas — one or more recipes, from several Content Recipe nodes\n // and/or one that ran once per post.\n \"content-ideas\": [\"recipes\"],\n // Telegram Reply — one message per run, whatever is wired into its text\n // input: a list (or a writer that ran once per item) arrives as one\n // message, never as a burst of sends to the owner's chat.\n \"telegram-account-send\": [\"in\"],\n // The list operators — they READ the whole list wired into them (their\n // executors collect every upstream item themselves) and emit a list. Run\n // once per item by an \"each\" wire (a Split Text, a List, a node that ran per\n // item), every iteration saw the same whole list and answered with its\n // first match: a Filter List fed 11 stories handed 11 copies of story one\n // downstream, and every paid stage after it ran 11 times on it\n // (2026-10-06). A list operator is never fanned out, on any wire.\n \"filter-list\": \"*\",\n deduplicate: \"*\",\n \"merge-lists\": \"*\",\n \"sort-list\": \"*\",\n selector: \"*\",\n // Speaker Frames on a clip pack (P3-24 (a), decided 2026-10-06): ONE run over\n // the union of the clips' spans — the pack's EDLs fold onto its `edl` wire\n // instead of running one detection job (and one minimum charge) per clip.\n \"speaker-frames\": [\"edl\"],\n // UGC Finish: ONE run over every clip of the video, in clip order — the finish plans its\n // cut and its sound over all of them at once, so it is never run once per clip.\n \"ugc-finish-clips\": [\"clips\"],\n}\n\nexport function isFanInNodeType(nodeType: string | undefined | null): boolean {\n return typeof nodeType === \"string\" && Object.prototype.hasOwnProperty.call(FAN_IN_TARGETS, nodeType)\n}\n\n/** True when an edge into `targetHandle` of a `targetType` node is folded.\n * An edge with NO target handle (workflow JSON written by an agent often\n * omits it) lands on the node's primary input, which is the folding one. */\nexport function isFanInEdge(targetType: string | undefined | null, targetHandle: string | null | undefined): boolean {\n if (!isFanInNodeType(targetType)) return false\n const spec = FAN_IN_TARGETS[targetType as string]!\n if (spec === \"*\") return true\n return targetHandle == null || targetHandle === \"\" || spec.includes(targetHandle)\n}\n","/**\n * UI-default fills for the unified video nodes — the ONE source of truth shared\n * by the backend DAG payload builder, the config-panel fail-safe snaps and the\n * node's hover/run strip.\n *\n * Several config panels RENDER a default without persisting it to node data, so\n * an untouched node submits `aspectRatio` / `resolution` undefined and the\n * enqueued job row (and the /v1/jobs echo) then disagrees with what actually\n * renders. Worse, the panels' generic snap writes `resolutions[0]` for a stale\n * value, which is the CHEAPEST tier under the repo's ascending-resolution\n * convention — not necessarily the tier the model renders and bills.\n *\n * These helpers were local to `backend/src/services/workflow-engine/payload-builder.ts`\n * until the Wan 3.0 launch gave the platform its first provider whose declared\n * billing default differs from `resolutions[0]`; three surfaces then had to\n * agree, so they live here.\n *\n * The resolution fill is per-family ON PURPOSE. Wan 3.0 (and Vidu Q4, whose\n * ascending list starts at 540p) reads its DECLARED\n * billing default (PRICING_DEFAULT_RESOLUTION = 720p) because its catalog list\n * is ascending, so an index-0 fill would write 480p — a tier both `runWan3`\n * (which renders 720P) and the credit identifier (which bills the 720p row)\n * disagree with. The Seedance family keeps its historical first-catalog-tier\n * fill, deliberately: switching it to PRICING_DEFAULT_RESOLUTION would reprice\n * live seedance-2-5 runs, whose declared default (720p) differs from the 480p\n * this has always filled. That 480p-fill vs 720p-billing-default divergence on\n * seedance-2-5 is a KNOWN pre-existing gap, out of scope here — do not \"align\"\n * the branches without repricing it deliberately.\n */\n\nimport {\n PRICING_DEFAULT_RESOLUTION,\n isSeedance2Provider,\n isMinimaxH3Provider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4RunnerProvider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isPixverseV6MaxProvider,\n} from \"./model-constants.js\"\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/** `adaptive` is the aspect default for Seedance 2, MiniMax H3 and Wan 3.0. */\nexport function uiAspectRatioFill(provider: string): string | undefined {\n if (isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider)) return \"adaptive\"\n // Kling 4.0 (and Flash): `auto` follows the materials (frames / references)\n // and renders 16:9 with none — KIE's own default when the field is omitted.\n // Flash's keyframe endpoint has no `auto`, but it runs only with a start\n // frame, where the ratio is never sent (the clip follows the frame).\n if (isKling4RunnerProvider(provider)) return \"auto\"\n return undefined\n}\n\n/** See the file docstring — per-family on purpose; never a generic\n * PRICING_DEFAULT_RESOLUTION read (that would reprice seedance-2-5). */\nexport function uiResolutionFill(provider: string): string | undefined {\n if (isWan3Provider(provider) || isViduQ4Provider(provider) || isKling4RunnerProvider(provider) || isGeminiOmniPerSecondProvider(provider) || isPixverseV6MaxProvider(provider)) return PRICING_DEFAULT_RESOLUTION[provider]\n if (isSeedance2Provider(provider)) return MODEL_CATALOG[provider]?.resolutions?.[0]\n return undefined\n}\n\n/**\n * Duration the node RENDERS and BILLS when `data.duration` is unset, for the\n * families whose credit identifier declares a duration fallback that is NOT\n * `durations[0]`. Wan 3.0's bare identifier is the 5s tier while its ladder\n * starts at 2s; Vidu Q4's is the 5s tier while its ladder starts at 3s;\n * PixVerse V6 Max's is the 5s tier while its ladder starts at 1s; the\n * Gemini Omni family's is the 8s tier while its ladder starts at 4s. Everyone else falls back to the first listed duration, so this returns\n * undefined and the caller keeps `durations[0]`.\n */\nexport function uiDurationFill(provider: string): number | undefined {\n if (isWan3Provider(provider) || isViduQ4Provider(provider) || isKling4RunnerProvider(provider) || isPixverseV6MaxProvider(provider)) return 5\n if (isGeminiOmniProvider(provider)) return 8\n return undefined\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/producer-types.ts","../src/video-ui-defaults.ts"],"names":[],"mappings":";;;;;;AA2BO,IAAM,oBAAA,GAA4C,eAAe,sBAAA,EAAwB;AAAA,EAC9F,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAA;AAAA,EACA,cAAA;AAAA,EAC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AA,OAAO,MAAA;AACT","file":"chunk-EI4V43DI.js","sourcesContent":["/**\n * Producer-type sets — single source of truth for the node types whose\n * primary output is a video URL, audio URL, etc.\n *\n * Consumed by:\n * - backend/src/services/workflow-engine/execution-graph.ts (orchestrator\n * dispatch + asset-type tagging in payload-builder, output-extractor,\n * inline-executor — re-exported there as VIDEO_SOURCE_TYPES /\n * AUDIO_SOURCE_TYPES for backwards compatibility).\n * - frontend/src/lib/generate-video-handles.ts (handle connection\n * validation on the Generate Video node).\n *\n * Lifting these here ensures the frontend handle validator can never reject\n * a connection from a node type that the backend would happily route at\n * execution time (the prior drift bug, see issue 1 of the Task 4.1 review).\n */\nimport { UGC_PRIMARY_HANDLE } from \"./ugc-node-wires.js\"\nimport { composeUnitRecord, composeUnitSet, unitFanOutEach, unitListPips, unitProducers } from \"./unit-contract-compose.js\"\n\n// Each producer set below is its hand-written members ∪ the node units\n// (tools/units/README.md) of that producer kind, from their generated contract\n// rows, in that order — a type in both throws at load (composeUnitSet).\n\n/**\n * Source node types whose primary output is a video URL.\n * Mirrors the backend execution-graph VIDEO_SOURCE_TYPES verbatim.\n */\nexport const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"VIDEO_PRODUCER_TYPES\", [\n \"image-to-video\",\n \"video-to-video\",\n \"switchx\", // Beeble SwitchX relight/composite\n \"text-to-video\",\n // Unified video node — emits videoUrl identically to i2v/t2v (its payload-builder\n // case dispatches dynamically to \"image-to-video\" or \"text-to-video\" jobName based\n // on whether a start frame is wired). Without this, getPrimaryOutput would fall\n // through to the imageUrl/videoUrl/audioUrl/text default and downstream consumers\n // could silently misroute the output.\n \"generate-video\",\n // Generate Video Pro — Seedance-2-family multi-segment stitch variant of\n // generate-video (same \"emits videoUrl\" contract; a trimmed provider +\n // handle set). Must mirror generate-video here or its output can't connect\n // downstream (the recurring \"cannot connect the outputs\" bug class).\n \"generate-video-pro\",\n // Edit Video Pro — Seedance-2-family span-replace sibling of generate-\n // video-pro (same \"emits videoUrl\" contract; source video + prompt in,\n // ONE video out). Must mirror generate-video-pro here or its output can't\n // connect downstream (the recurring \"cannot connect the outputs\" bug class).\n \"edit-video-pro\",\n \"upload-video\",\n \"youtube-video\",\n \"combine-videos\",\n \"lip-sync\",\n \"speech-to-video\",\n \"motion-transfer\",\n \"video-upscale\",\n \"video-depth\",\n \"extend-video\",\n // face-swap output is video (writes generatedVideoUrl, per-result `url`).\n // Frontend execution-graph already includes it in VIDEO_SOURCE_TYPES; this\n // entry brings the shared set in line so canvas typed-handle validation\n // doesn't reject face-swap → video-consumer edges that the orchestrator\n // would happily route at runtime.\n \"face-swap\",\n // Speaker View (C3.2): an EDL rendered with its speakers framed — one VIDEO\n // out (no audio-only render). Registered in RENDER_NODE_TYPES as well.\n \"speaker-view\",\n \"video-retake\",\n // video-sfx: adds an SFX track to a video → emits a video URL. Belongs here so\n // canvas handle validation accepts video-sfx → video-consumer edges and the\n // backend routes its output as video (it was previously relying on a fallback).\n \"video-sfx\",\n \"suno-music-video\",\n \"merge-video-audio\",\n // Replace Audio (Nodaro Cloud plugin): the video with its sound replaced → video.\n \"replace-audio\",\n \"add-captions\",\n \"resize-video\",\n \"social-media-format\",\n \"trim-video\",\n \"render-video\",\n \"speed-ramp\",\n \"loop-video\",\n \"fade-video\",\n // Video Mask emits its mask as a video; Mask Composite its composite.\n \"video-mask\",\n \"mask-composite\",\n \"transcode-video\",\n \"manual-edit\",\n // AI Avatar (HeyGen): avatar + voice/audio → video.\n \"ai-avatar\",\n // Cinematic Avatar (HeyGen cinematic_avatar): prompt + 1–3 avatar looks → video.\n \"cinematic-avatar\",\n // Assemble Narrated Video: fits N (clip, voice) blocks into one MP4 → video.\n \"assemble-narrated-video\",\n // Still to Video: one still image + one audio track → MP4 (local FFmpeg,\n // no provider). Emits generatedVideoUrl like every other ffmpeg video node.\n \"still-to-video\",\n // Slideshow: 2-100 stills + one optional audio track → MP4 (local FFmpeg,\n // no provider). Same contract; images arrive via the image-collage lane.\n \"slideshow\",\n // 3D Render Pro: authors a scene AND exports it in one operation, settling\n // with the standard `videoUrl` field. It is a video producer as much as it\n // is a composition producer — omitting it here is the \"cannot connect the\n // outputs\" bug, and its `composition` handle is typed separately.\n \"pro-3d-render\",\n // Video Overlay: timed image layers over a video in one local FFmpeg pass\n // (the base audio copied) — emits a video URL on `video-out`.\n \"video-overlay\",\n // UGC Clip: renders one clip of a UGC video from its ticket — emits a video\n // URL on `video-out` (one per fan-out iteration).\n \"ugc-clip\",\n // UGC Finish: the video's clips, finished, as one ordered list — a registered producer, so a\n // Bundle edge into Combine Videos routes each one as a video, in order.\n \"ugc-finish-clips\",\n], unitProducers(\"video\"))\n\n/**\n * Source node types whose output media-type cannot be classified\n * statically — iterators, dynamic dispatchers, sub-workflow wrappers.\n * The orchestrator decides their actual output type at execution time\n * based on what's wired upstream (loop iterates upstream column type;\n * sub-workflow emits its leaf node's type; adjust-volume passes through\n * video or audio based on its `lastInputType` runtime field;\n * voice-changer emits audio in audio mode, video+audio in video mode).\n *\n * Typed-handle validators (frontend/src/lib/{generate-image,generate-\n * video,ffmpeg}-handles.ts) must include these as acceptors on EVERY\n * media-typed input handle — otherwise the canvas validator hard-\n * rejects edges that the orchestrator would happily route at runtime.\n *\n * Lifted here from `frontend/src/lib/ffmpeg-handles.ts` (where the\n * escape hatch was first added) so the same set drives ALL handle\n * validators uniformly. Adding a new dynamic-output node type means\n * one edit here instead of N across sibling validator files.\n *\n * Intentionally OMITTED:\n * - `webhook-trigger` / `schedule-trigger` — their outputs are\n * user-defined JSON shapes, not media URLs. Accepting them as\n * media producers creates false-positive drops at the canvas\n * that fail at execution. Users wanting trigger → media flows\n * should wire through an upload node.\n */\nexport const DYNAMIC_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"DYNAMIC_PRODUCER_TYPES\", [\n \"list\",\n \"sub-workflow\",\n \"adjust-volume\",\n // Pitch & Tempo: audio in → audio out, video in → video out (picture\n // copied). Dual-mode like adjust-volume; stays in AUDIO_PRODUCER_TYPES as\n // its default.\n \"pitch-tempo\",\n // Dual-mode: audio in → audio out; video in → video out (+ revoiced audio).\n // Listed here so canvas validators accept its output on BOTH audio and video\n // input handles (it also stays in AUDIO_PRODUCER_TYPES as its default).\n \"voice-changer\",\n // voice-changer-pro (renamed from voice-recast in #3581) is a behavioral\n // twin of voice-changer — identical dual-mode output. Must mirror it in\n // EVERY producer set or its outputs can't connect (was the \"cannot connect\n // the outputs of voice-changer-pro\" bug). Guarded by producer-types.test.ts.\n \"voice-changer-pro\",\n // Dubbing joined the dual-mode family with the full-surface upgrade:\n // audio in → dubbed audio; video in (or a video sourceUrl) → dubbed VIDEO\n // (+ audio sidecar). Same wiring contract as voice-changer; stays in\n // AUDIO_PRODUCER_TYPES as its default. Explicitly asserted in\n // producer-types.test.ts (the suite does not fail on omission).\n \"dubbing\",\n \"reduce\",\n // Dual-output time chunker (UI label \"Split into Chunks\"; type id stays\n // \"split-media\"): video in → video chunks, audio in → audio chunks — two\n // independent lanes on two output handles. Like voice-changer, the canvas\n // validator only sees the source NODE type, not which handle a wire leaves,\n // so it lives here to be accepted on BOTH audio and video input handles. The\n // backend routes the correct lane by sourceHandle in getPrimaryOutput\n // (output-extractor.ts); the frontend does so in extractNodeOutput.\n \"split-media\",\n // apply-edl renders an EDL into ONE media output whose type is decided at\n // run time by the node's `output` setting (video OR audio) — so its static\n // medium is genuinely unknown and it belongs here, letting canvas validators\n // accept its default media handle on BOTH audio and video input handles. It\n // ALSO emits a fixed `json` handle (the remapped Transcript); that half lives\n // in JSON_PRODUCER_TYPES (frontend/src/lib/data-handles.ts). The FIRST node\n // with both a dynamic media handle and a fixed json handle. Because\n // getOutputType (presentation-utils.ts) deliberately returns \"data\" for\n // DYNAMIC members, apply-edl is ALSO added to the literal VIDEO_OUTPUT_TYPES\n // there so a published app renders the cut as video, mirroring the\n // voice-changer/dubbing precedent. Asserted in producer-types.test.ts (the\n // suite does not fail on omission).\n \"apply-edl\",\n], unitProducers(\"dynamic\"))\n\n/**\n * Source node types whose primary output is an audio URL.\n * Mirrors the backend execution-graph AUDIO_SOURCE_TYPES verbatim.\n */\nexport const AUDIO_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"AUDIO_PRODUCER_TYPES\", [\n \"text-to-speech\",\n \"text-to-audio\",\n \"generate-music\",\n \"upload-audio\",\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-separate\",\n \"audio-separation\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n \"trim-audio\",\n \"mix-audio\",\n \"combine-audio\",\n \"adjust-volume\",\n \"audio-fx\",\n \"pitch-tempo\",\n \"reference-audio\",\n \"audio-isolation\",\n \"text-to-dialogue\",\n \"voice-changer\",\n // Twin of voice-changer (see DYNAMIC_PRODUCER_TYPES note). Audio is its\n // default output mode; video mode is handled via DYNAMIC membership.\n \"voice-changer-pro\",\n \"dubbing\",\n \"voice-remix\",\n \"voice-design\",\n // Extract Audio: demuxes a video's audio track to a standalone MP3.\n \"extract-audio\",\n], unitProducers(\"audio\"))\n\n/**\n * Source node types whose output is an IMAGE URL — what feeds a References\n * input. ONE set for the canvas validators (`frontend/src/lib/\n * generate-image-handles.ts` re-exports it), the backend's Generate Image\n * handle migration and the MCP edge normalizer (`llm-chat`'s legacy `in`):\n * they used to keep separate copies, and the backend's lagged by eight types.\n */\nexport const IMAGE_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"IMAGE_PRODUCER_TYPES\", [\n \"upload-image\", \"generate-image\", \"edit-image\", \"image-to-image\", \"modify-image\", \"upscale-image\", \"remove-background\",\n // extract-frame produces a single still image extracted from a video source.\n \"extract-frame\",\n // generate-mask emits the source image AND a mask PNG; its `image` source\n // pip is the passthrough (the same image as the input).\n \"generate-mask\",\n // paint-mask emits the hand-painted mask PNG (a plain image at runtime).\n // Membership is what makes mask targets accept it — mask is an advisory\n // color, not a gated type.\n \"paint-mask\",\n // reference-sheet's `sheet` is one composited image and `panels` carries\n // clean reference images; both resolve to image URLs at runtime.\n \"reference-sheet\",\n // reference-board's `image` pip emits a real generated board image.\n \"reference-board\",\n // image-collage composites N images → ONE image.\n \"image-collage\",\n // image-overlay places layers on a base → ONE image.\n \"image-overlay\",\n // 3D Render Pro's `stills` handle carries one PNG per shot of the exported\n // composition (spread into referenceImageUrls like reference-sheet\n // `panels`). A validator sees only the source NODE type, so this also makes\n // its `video` pip droppable on an image input — the handle-blind trade\n // reference-sheet and split-media already make; the input resolvers route\n // by handle, so only `stills` becomes an image at runtime. Deliberately NOT\n // in IMAGE_SOURCE_TYPES on either engine: that set types the node's PRIMARY\n // asset, and 3D Render Pro's is the MP4.\n \"pro-3d-render\",\n], unitProducers(\"image\"))\n\n/**\n * Source node types whose primary output is a LIST that, by default, fans out\n * one downstream execution per element when an edge leaves them WITHOUT an\n * explicit `outputMode` (all other edges default to \"last\"). `selector` is\n * included because its picked/rest channels are lists too.\n *\n * Single source of truth for the fan-out \"each\" default, consumed by:\n * - backend/src/services/workflow-engine/input-resolver.ts (DEFAULT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/types.ts (FAN_OUT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/node-input-resolver.ts\n *\n * These three previously kept independent copies; the backend copy drifted\n * (missing the four list-transform types), so server-side workflow runs\n * silently dropped all-but-the-first item for filter-list / deduplicate /\n * merge-lists / sort-list sources while the canvas fanned out N ways. Lifting\n * the set here makes that drift impossible.\n */\nexport const FAN_OUT_EACH_TYPES: ReadonlySet<string> = new Set([\n \"list\",\n \"split-text\",\n \"filter-list\",\n \"deduplicate\",\n \"merge-lists\",\n \"sort-list\",\n \"selector\",\n // edit-plan `clips` mode emits a bare `Edl[]` on `data.generatedJson`, so an\n // edge leaving it defaults to \"each\" — one downstream execution (typically an\n // apply-edl render) per clip. The `tighten`/`chapters` modes emit an OBJECT,\n // for which the list extractors return undefined, so an \"each\" edge falls back\n // to the scalar `edl` value (no fan-out) — the same graceful degradation\n // web-scrape relies on. See `unwrapEditPlanOutput` in `edit-plan-contract.ts`.\n \"edit-plan\",\n // Content Ideas emits one creative brief per idea on `listResults`, so an\n // edge leaving it defaults to \"each\" — the node after it (typically\n // Generate Script) runs once per idea, on the server too.\n \"content-ideas\",\n])\n\n/**\n * Per-HANDLE \"each\" defaults, for a node whose outputs differ in kind: on the\n * `each` handles an edge without an explicit `outputMode` defaults to \"each\",\n * on its other handles to \"last\". `primary` is the handle an edge with no\n * `sourceHandle` reads (agent-written workflow JSON often omits it).\n *\n * The list an \"each\" edge reads is the node's per-iteration results\n * (`listResults`) — it exists only when the node itself ran once per item, so\n * after a single run the edge degrades to the single value, exactly like a\n * `FAN_OUT_EACH_TYPES` member with one item.\n *\n * Its hand-written rows ∪ the node units' rows (`contract.fanOutEach`,\n * generated/unit-contracts.ts); a type in both refuses to load.\n */\nexport const FAN_OUT_EACH_HANDLES: Readonly<Record<string, { readonly each: readonly string[]; readonly primary: string }>> = composeUnitRecord(\"FAN_OUT_EACH_HANDLES\", {\n // Camera Switch run once per clip (Edit Plan in clips mode): each clip's\n // switched EDL is its own Apply EDL render. Its transcript is the same for\n // every clip (the master clock, renamed), so that handle stays one value\n // (decided 2026-10-04).\n \"camera-switch\": { each: [\"edl\"], primary: \"edl\" },\n // UGC Clips: one ticket per clip on `clips` (each); `plan-out` and\n // `transcript` carry one value. Not a FAN_OUT_EACH_TYPES member — every\n // handle of such a member would fan out. Its one run writes the tickets as\n // its list (`listResults`, the editor's `__listResults`). The pip an edge\n // with no handle reads is the UGC wires' own (UGC_PRIMARY_HANDLE).\n \"ugc-clips\": { each: [\"clips\"], primary: UGC_PRIMARY_HANDLE[\"ugc-clips\"]! },\n // A node unit declares its row in unit.json (contract.fanOutEach); it is added after these.\n}, unitFanOutEach())\n\n/**\n * Fan-out nodes whose iterations must ALL succeed: one failed item fails the\n * node (today's rule tolerates a partial list). UGC Clip — a missing clip\n * silently drops a beat from the script (spec R17). Already-started items\n * finish and settle; their jobs are reused on the next run.\n */\nexport const FAN_OUT_ALL_OR_NOTHING_TYPES: ReadonlySet<string> = new Set([\"ugc-clip\"])\n\n/**\n * Nodes whose saved list is the list their last run PRODUCED — `__listResults`\n * (Extract Field's JSON value on `generatedJson`) — and never a history in\n * `generatedResults`: Extract Field, JSON Process and Site Capture. No run of the first two writes\n * one; earlier builds' server runs did (the run's text, the links of a list of\n * links), and both engines' list readers leave it out for these two (decided\n * 2026-10-05). Single source of truth for the backend engine and the editor.\n */\nexport const OWN_LIST_NODE_TYPES: ReadonlySet<string> = new Set([\n \"extract-field\",\n \"json-process\",\n // Site Capture: its stills, in page order — the last capture's, never every capture's (site-capture-node.ts).\n \"site-capture\",\n])\n\n/** Whether a node's saved list is its own `__listResults`, never a history. */\nexport function ownsItsList(nodeType: string | null | undefined): boolean {\n return typeof nodeType === \"string\" && OWN_LIST_NODE_TYPES.has(nodeType)\n}\n\n/**\n * The output pips that carry the LIST one run produced — several files on one\n * pip (a node unit's `handles.outputs[].list`: each layer of a split image). An\n * edge leaving one runs the next node once per item by default (\"each\"); a\n * Bundle hands the whole list to a node that takes several. Unlike\n * FAN_OUT_EACH_HANDLES, the list is what ONE run made on that pip, never the\n * node's per-iteration results. An edge naming no pip reads the node's primary\n * output, which is never a list pip (tools/units/json-output-rules.mjs).\n * Node units only (generated/unit-contracts.ts UNIT_LIST_PIPS).\n */\nexport const LIST_OUTPUT_HANDLES: Readonly<Record<string, readonly string[]>> = composeUnitRecord(\"LIST_OUTPUT_HANDLES\", {}, unitListPips())\n\n/** Whether an edge leaving `sourceHandle` of a `sourceType` node carries a list one run produced (LIST_OUTPUT_HANDLES). */\nexport function isListOutputHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n if (typeof sourceType !== \"string\" || typeof sourceHandle !== \"string\" || !Object.hasOwn(LIST_OUTPUT_HANDLES, sourceType)) return false\n return LIST_OUTPUT_HANDLES[sourceType]!.includes(sourceHandle)\n}\n\n/** The `outputMode` an edge has when none is set on it — the ONE rule both\n * engines, the credit estimate and the editor read. */\nexport function defaultEdgeOutputMode(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): \"each\" | \"last\" {\n if (typeof sourceType !== \"string\") return \"last\"\n if (FAN_OUT_EACH_TYPES.has(sourceType)) return \"each\"\n if (isListOutputHandle(sourceType, sourceHandle)) return \"each\"\n const entry = FAN_OUT_EACH_HANDLES[sourceType]\n if (!entry) return \"last\"\n return entry.each.includes(sourceHandle || entry.primary) ? \"each\" : \"last\"\n}\n\n/** Whether an edge from `sourceHandle` reads the node's per-iteration results\n * (`listResults` — each iteration's PRIMARY output). False on the other\n * handles of a `FAN_OUT_EACH_HANDLES` node: Camera Switch's transcript is one\n * value, never the list of switched EDLs, whatever mode its edge is set to. */\nexport function listResultsServeHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n const entry = typeof sourceType === \"string\" ? FAN_OUT_EACH_HANDLES[sourceType] : undefined\n return !entry || entry.each.includes(sourceHandle || entry.primary)\n}\n\n/**\n * FAN-IN targets: nodes that FOLD everything wired into them into ONE run,\n * instead of running once per upstream item. Keyed by node type; the value\n * names the target handles that fold (`\"*\"` = every handle). An edge into any\n * other handle of such a node is routed normally — Content Ideas folds its\n * recipes but reads its brand from a `field-brand` wire like any field.\n *\n * Single source of truth for both engines' input resolvers (the backend and\n * the editor each used to keep a private `new Set([\"reduce\"])`). A fan-in\n * node is never itself fanned out by an upstream list.\n */\nexport const FAN_IN_TARGETS: Readonly<Record<string, \"*\" | readonly string[]>> = {\n // Choose Best — every wire is a candidate.\n reduce: \"*\",\n // Content Ideas — one or more recipes, from several Content Recipe nodes\n // and/or one that ran once per post.\n \"content-ideas\": [\"recipes\"],\n // Telegram Reply — one message per run, whatever is wired into its text\n // input: a list (or a writer that ran once per item) arrives as one\n // message, never as a burst of sends to the owner's chat.\n \"telegram-account-send\": [\"in\"],\n // The list operators — they READ the whole list wired into them (their\n // executors collect every upstream item themselves) and emit a list. Run\n // once per item by an \"each\" wire (a Split Text, a List, a node that ran per\n // item), every iteration saw the same whole list and answered with its\n // first match: a Filter List fed 11 stories handed 11 copies of story one\n // downstream, and every paid stage after it ran 11 times on it\n // (2026-10-06). A list operator is never fanned out, on any wire.\n \"filter-list\": \"*\",\n deduplicate: \"*\",\n \"merge-lists\": \"*\",\n \"sort-list\": \"*\",\n selector: \"*\",\n // Speaker Frames on a clip pack (P3-24 (a), decided 2026-10-06): ONE run over\n // the union of the clips' spans — the pack's EDLs fold onto its `edl` wire\n // instead of running one detection job (and one minimum charge) per clip.\n \"speaker-frames\": [\"edl\"],\n // UGC Finish: ONE run over every clip of the video, in clip order — the finish plans its\n // cut and its sound over all of them at once, so it is never run once per clip.\n \"ugc-finish-clips\": [\"clips\"],\n}\n\nexport function isFanInNodeType(nodeType: string | undefined | null): boolean {\n return typeof nodeType === \"string\" && Object.prototype.hasOwnProperty.call(FAN_IN_TARGETS, nodeType)\n}\n\n/** True when an edge into `targetHandle` of a `targetType` node is folded.\n * An edge with NO target handle (workflow JSON written by an agent often\n * omits it) lands on the node's primary input, which is the folding one. */\nexport function isFanInEdge(targetType: string | undefined | null, targetHandle: string | null | undefined): boolean {\n if (!isFanInNodeType(targetType)) return false\n const spec = FAN_IN_TARGETS[targetType as string]!\n if (spec === \"*\") return true\n return targetHandle == null || targetHandle === \"\" || spec.includes(targetHandle)\n}\n","/**\n * UI-default fills for the unified video nodes — the ONE source of truth shared\n * by the backend DAG payload builder, the config-panel fail-safe snaps and the\n * node's hover/run strip.\n *\n * Several config panels RENDER a default without persisting it to node data, so\n * an untouched node submits `aspectRatio` / `resolution` undefined and the\n * enqueued job row (and the /v1/jobs echo) then disagrees with what actually\n * renders. Worse, the panels' generic snap writes `resolutions[0]` for a stale\n * value, which is the CHEAPEST tier under the repo's ascending-resolution\n * convention — not necessarily the tier the model renders and bills.\n *\n * These helpers were local to `backend/src/services/workflow-engine/payload-builder.ts`\n * until the Wan 3.0 launch gave the platform its first provider whose declared\n * billing default differs from `resolutions[0]`; three surfaces then had to\n * agree, so they live here.\n *\n * The resolution fill is per-family ON PURPOSE. Wan 3.0 (and Vidu Q4, whose\n * ascending list starts at 540p) reads its DECLARED\n * billing default (PRICING_DEFAULT_RESOLUTION = 720p) because its catalog list\n * is ascending, so an index-0 fill would write 480p — a tier both `runWan3`\n * (which renders 720P) and the credit identifier (which bills the 720p row)\n * disagree with. The Seedance family keeps its historical first-catalog-tier\n * fill, deliberately: switching it to PRICING_DEFAULT_RESOLUTION would reprice\n * live seedance-2-5 runs, whose declared default (720p) differs from the 480p\n * this has always filled. That 480p-fill vs 720p-billing-default divergence on\n * seedance-2-5 is a KNOWN pre-existing gap, out of scope here — do not \"align\"\n * the branches without repricing it deliberately.\n */\n\nimport {\n PRICING_DEFAULT_RESOLUTION,\n isSeedance2Provider,\n isMinimaxH3Provider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4RunnerProvider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isPixverseV6MaxProvider,\n} from \"./model-constants.js\"\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/** `adaptive` is the aspect default for Seedance 2, MiniMax H3 and Wan 3.0. */\nexport function uiAspectRatioFill(provider: string): string | undefined {\n if (isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider)) return \"adaptive\"\n // Kling 4.0 (and Flash): `auto` follows the materials (frames / references)\n // and renders 16:9 with none — KIE's own default when the field is omitted.\n // Flash's keyframe endpoint has no `auto`, but it runs only with a start\n // frame, where the ratio is never sent (the clip follows the frame).\n if (isKling4RunnerProvider(provider)) return \"auto\"\n return undefined\n}\n\n/** See the file docstring — per-family on purpose; never a generic\n * PRICING_DEFAULT_RESOLUTION read (that would reprice seedance-2-5). */\nexport function uiResolutionFill(provider: string): string | undefined {\n if (isWan3Provider(provider) || isViduQ4Provider(provider) || isKling4RunnerProvider(provider) || isGeminiOmniPerSecondProvider(provider) || isPixverseV6MaxProvider(provider)) return PRICING_DEFAULT_RESOLUTION[provider]\n if (isSeedance2Provider(provider)) return MODEL_CATALOG[provider]?.resolutions?.[0]\n return undefined\n}\n\n/**\n * Duration the node RENDERS and BILLS when `data.duration` is unset, for the\n * families whose credit identifier declares a duration fallback that is NOT\n * `durations[0]`. Wan 3.0's bare identifier is the 5s tier while its ladder\n * starts at 2s; Vidu Q4's is the 5s tier while its ladder starts at 3s;\n * PixVerse V6 Max's is the 5s tier while its ladder starts at 1s; the\n * Gemini Omni family's is the 8s tier while its ladder starts at 4s. Everyone else falls back to the first listed duration, so this returns\n * undefined and the caller keeps `durations[0]`.\n */\nexport function uiDurationFill(provider: string): number | undefined {\n if (isWan3Provider(provider) || isViduQ4Provider(provider) || isKling4RunnerProvider(provider) || isPixverseV6MaxProvider(provider)) return 5\n if (isGeminiOmniProvider(provider)) return 8\n return undefined\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MODEL_CATALOG, normalizeModelInput } from './chunk-
|
|
1
|
+
import { MODEL_CATALOG, normalizeModelInput } from './chunk-X7UDZGXW.js';
|
|
2
2
|
|
|
3
3
|
// src/image-model-roles.ts
|
|
4
4
|
var IMAGE_MODEL_ROLE_DEFAULTS = {
|
|
@@ -57,5 +57,5 @@ function normalizeVideoUpscaleResolution(provider, targetResolution) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export { IMAGE_MODEL_RATIO_FALLBACKS, IMAGE_MODEL_ROLE_DEFAULTS, VIDEO_UPSCALE_RESOLUTIONS, defaultImageModel, defaultImageModelForNode, imageModelDrawsRatio, normalizeVideoUpscaleResolution, videoUpscaleModelOf, videoUpscaleResolutionsFor };
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-EOYQD6DU.js.map
|
|
61
|
+
//# sourceMappingURL=chunk-EOYQD6DU.js.map
|
|
@@ -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AA,OAAO,UAAA,GAAa,EAAE,gBAAA,EAAkB,UAAA,CAAW,UAAA,EAAY,YAAW,GAAI,EAAE,gBAAA,EAAkB,UAAA,CAAW,UAAA,EAAW;AAC1H","file":"chunk-EOYQD6DU.js","sourcesContent":["import { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/**\n * The platform's answer to \"which image model, when the caller names none\".\n *\n * One table by ROLE, so every surface that picks for the user (node defaults,\n * route and workflow fallbacks, MCP tools, studios, pipelines) reads the same\n * model instead of keeping its own literal. Before this table those literals\n * had drifted apart: the Generate Image node started on Nano Banana Pro, the\n * routes fell back to the original Nano Banana, and MCP used Nano Banana 2.1.\n *\n * Decided on 2026-10-08 from a blind five-model comparison, quality\n * first and price second:\n * - characters, general text-to-image and video anchors on GPT Image 2;\n * - edits on the current GPT Image Flare (2.6 since 2026-11-09), which renders\n * at its default Medium when a run names no quality.\n * With reference images attached, GPT Image 2 runs as its i2i sibling (the\n * provider swaps it), so `character` covers identity-from-reference too.\n *\n * Nano Banana Pro is no longer a default. It remains a FALLBACK only: last in\n * the ratio chain below, the GPT-family safety-block retry, and the swimwear\n * dressing model.\n */\nexport const IMAGE_MODEL_ROLE_DEFAULTS = {\n character: \"gpt-image-2\",\n general: \"gpt-image-2\",\n anchor: \"gpt-image-2\",\n edit: \"gpt-image-2-6-flare-i2i\",\n} as const\n\nexport type ImageModelRole = keyof typeof IMAGE_MODEL_ROLE_DEFAULTS\n\n/**\n * Where a role's model goes when it cannot draw the requested aspect ratio.\n * GPT Image 2 draws only auto / 1:1 / 16:9 / 9:16 / 4:3 / 3:4, so 21:9, 3:2,\n * 2:3, 4:5, 5:4 and the other wide or in-between ratios move to GPT Image 2.6\n * Sunburst. GPT Image 2.5 Sunburst stays behind it for the ratios only 2.5\n * draws, and Nano Banana Pro comes last.\n */\nexport const IMAGE_MODEL_RATIO_FALLBACKS: Readonly<Record<ImageModelRole, readonly string[]>> = {\n character: [\"gpt-image-2-6-sunburst\", \"gpt-image-2-5-sunburst\", \"nano-banana-pro\"],\n general: [\"gpt-image-2-6-sunburst\", \"gpt-image-2-5-sunburst\", \"nano-banana-pro\"],\n anchor: [\"gpt-image-2-6-sunburst\", \"gpt-image-2-5-sunburst\", \"nano-banana-pro\"],\n edit: [\"gpt-image-2-6-sunburst-i2i\", \"gpt-image-2-5-sunburst-i2i\", \"nano-banana-pro\"],\n}\n\n/** True when the model's catalog entry lists the ratio (or no ratio was asked for). */\nexport function imageModelDrawsRatio(modelId: string, aspectRatio?: string | null): boolean {\n if (!aspectRatio) return true\n const ratios = MODEL_CATALOG[modelId]?.aspectRatios\n return ratios === undefined || ratios.includes(aspectRatio)\n}\n\n/**\n * The default image model for a role at the requested aspect ratio: the role's\n * model when it draws the ratio, else the first fallback that does, else the\n * role's model (whose own ratio normalization then snaps the ratio). Read from\n * the catalog, so widening a model's documented ratios moves this with it.\n */\nexport function defaultImageModel(role: ImageModelRole, aspectRatio?: string | null): string {\n const primary = IMAGE_MODEL_ROLE_DEFAULTS[role]\n if (imageModelDrawsRatio(primary, aspectRatio)) return primary\n return IMAGE_MODEL_RATIO_FALLBACKS[role].find((id) => imageModelDrawsRatio(id, aspectRatio)) ?? primary\n}\n\n/**\n * The model an image node that names none runs on, by node type: the same\n * default its route and its workflow branch apply. For the node types that\n * have one; undefined for any other.\n */\nexport function defaultImageModelForNode(nodeType: string, aspectRatio?: string | null): string | undefined {\n switch (nodeType) {\n case \"generate-image\":\n return defaultImageModel(\"general\", aspectRatio)\n case \"image-to-image\":\n case \"modify-image\":\n return defaultImageModel(\"edit\", aspectRatio)\n case \"reference-board\":\n return defaultImageModel(\"character\", aspectRatio)\n default:\n return undefined\n }\n}\n","/**\n * The Video Upscale node's target resolution, per provider, from the catalog.\n *\n * The node stores one `targetResolution` for every provider, and the providers\n * take different sets: Topaz 720p / 1080p / 4K (a short side, its own list in\n * `topaz-video.ts`), Nodaro Video Upscale 1080p / 2K / 4K (an output box), the\n * VEO and Seedance HD upscales none. For a provider whose catalog entry\n * declares its resolutions (`resolutions`, `defaultResolution`; today Nodaro\n * Video Upscale), this is the one coercion every lane applies — a node written\n * straight into workflow JSON, a request to the API and an MCP call never pass\n * through the editor's menus: a value it does not take becomes its default. A\n * provider whose entry declares none (Topaz included) is left alone: its run\n * reads the field by its own rules.\n */\nimport { MODEL_CATALOG, normalizeModelInput, type ModelInputAdjustment } from \"./model-catalog.js\"\n\n/**\n * Every target resolution some Video Upscale provider takes — Nodaro Video\n * Upscale's route schema and the MCP verb's enum. Which ones a provider takes:\n * its catalog entry's `resolutions` where it declares them\n * ({@link normalizeVideoUpscaleResolution}), else its own list (Topaz's).\n */\nexport const VIDEO_UPSCALE_RESOLUTIONS = [\"720p\", \"1080p\", \"2k\", \"4k\"] as const\nexport type VideoUpscaleResolution = (typeof VIDEO_UPSCALE_RESOLUTIONS)[number]\n\n/** The provider a Video Upscale node runs when it names none. */\nconst DEFAULT_VIDEO_UPSCALE_PROVIDER = \"topaz\"\n\n/**\n * Video Upscale's `provider` value as the catalog model it runs: its \"topaz\"\n * is the catalog's `topaz-video`; every other value is its own id.\n */\nexport function videoUpscaleModelOf(provider: string): string {\n return provider === \"topaz\" ? \"topaz-video\" : provider\n}\n\n/** The resolutions a Video Upscale provider's catalog entry declares, in its order; empty when it declares none (Topaz keeps its own list). */\nexport function videoUpscaleResolutionsFor(provider: string | undefined): readonly string[] {\n const id = videoUpscaleModelOf(provider || DEFAULT_VIDEO_UPSCALE_PROVIDER)\n return MODEL_CATALOG[id]?.resolutions ?? []\n}\n\nexport interface NormalizedVideoUpscaleResolution {\n /** The value to store and send: the one asked for, its canonical spelling, or the provider's default. */\n readonly targetResolution: string | undefined\n /** What changed, when anything did. */\n readonly adjustment?: ModelInputAdjustment\n}\n\n/**\n * `targetResolution` coerced to one `provider` takes. Unset stays unset (each\n * run applies its own default). A value the provider does not list becomes the\n * provider's `defaultResolution`, a spelling variant (\"2K\") its canonical form.\n * A provider with no resolution setting gets the value back unchanged; a value\n * that is not a string, or an empty one, reads as unset.\n */\nexport function normalizeVideoUpscaleResolution(\n provider: string | undefined,\n targetResolution: unknown,\n): NormalizedVideoUpscaleResolution {\n if (typeof targetResolution !== \"string\" || targetResolution === \"\") return { targetResolution: undefined }\n const id = videoUpscaleModelOf(provider || DEFAULT_VIDEO_UPSCALE_PROVIDER)\n if ((MODEL_CATALOG[id]?.resolutions ?? []).length === 0) return { targetResolution }\n const normalized = normalizeModelInput(id, { resolution: targetResolution })\n const adjustment = normalized.adjustments.find((a) => a.field === \"resolution\")\n return adjustment ? { targetResolution: normalized.resolution, adjustment } : { targetResolution: normalized.resolution }\n}\n"]}
|