@nodaro/shared 3.38.0 → 3.40.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-AQA6YXY5.cjs → chunk-25PAKSMK.cjs} +50 -38
- package/dist/chunk-25PAKSMK.cjs.map +1 -0
- package/dist/{chunk-5OED47LE.js → chunk-2BJADMEX.js} +3 -3
- package/dist/{chunk-5OED47LE.js.map → chunk-2BJADMEX.js.map} +1 -1
- package/dist/{chunk-YNJ44IAL.cjs → chunk-4IWVZR44.cjs} +5 -5
- package/dist/{chunk-YNJ44IAL.cjs.map → chunk-4IWVZR44.cjs.map} +1 -1
- package/dist/{chunk-33QG2DOW.cjs → chunk-4LKEOIOT.cjs} +6 -6
- package/dist/{chunk-33QG2DOW.cjs.map → chunk-4LKEOIOT.cjs.map} +1 -1
- package/dist/{chunk-ZG4XSEZV.js → chunk-5CKTBGB6.js} +71 -2
- package/dist/chunk-5CKTBGB6.js.map +1 -0
- package/dist/{chunk-BDSFMY4X.js → chunk-5J5L26IZ.js} +5 -5
- package/dist/{chunk-BDSFMY4X.js.map → chunk-5J5L26IZ.js.map} +1 -1
- package/dist/{chunk-VRLRPGO7.js → chunk-A4NDZBSJ.js} +93 -11
- package/dist/chunk-A4NDZBSJ.js.map +1 -0
- package/dist/{chunk-KOP7UTQR.cjs → chunk-ADYPAGQF.cjs} +71 -2
- package/dist/chunk-ADYPAGQF.cjs.map +1 -0
- package/dist/{chunk-HABDAHZR.cjs → chunk-BOUEGYGI.cjs} +118 -28
- package/dist/chunk-BOUEGYGI.cjs.map +1 -0
- package/dist/{chunk-JLKZEKQ3.cjs → chunk-BWQRAQUD.cjs} +43 -43
- package/dist/{chunk-JLKZEKQ3.cjs.map → chunk-BWQRAQUD.cjs.map} +1 -1
- package/dist/{chunk-MSIIC6MY.cjs → chunk-DJIRIBKX.cjs} +4 -4
- package/dist/{chunk-MSIIC6MY.cjs.map → chunk-DJIRIBKX.cjs.map} +1 -1
- package/dist/{chunk-XA53RUSD.js → chunk-E4MLBJKG.js} +8 -8
- package/dist/{chunk-XA53RUSD.js.map → chunk-E4MLBJKG.js.map} +1 -1
- package/dist/chunk-FVZMFDRO.js +23 -0
- package/dist/chunk-FVZMFDRO.js.map +1 -0
- package/dist/{chunk-DKTRVOU5.js → chunk-GNY2S63W.js} +4 -4
- package/dist/{chunk-DKTRVOU5.js.map → chunk-GNY2S63W.js.map} +1 -1
- package/dist/{chunk-YHCG3HOR.js → chunk-GXTWKAJF.js} +3 -3
- package/dist/{chunk-YHCG3HOR.js.map → chunk-GXTWKAJF.js.map} +1 -1
- package/dist/{chunk-DE3PEIIP.cjs → chunk-IKCFSNNH.cjs} +21 -21
- package/dist/{chunk-DE3PEIIP.cjs.map → chunk-IKCFSNNH.cjs.map} +1 -1
- package/dist/{chunk-BYP62B7F.cjs → chunk-JN3V33AN.cjs} +6 -6
- package/dist/{chunk-BYP62B7F.cjs.map → chunk-JN3V33AN.cjs.map} +1 -1
- package/dist/{chunk-QXTCIJP5.js → chunk-LOTL72UI.js} +3 -3
- package/dist/{chunk-QXTCIJP5.js.map → chunk-LOTL72UI.js.map} +1 -1
- package/dist/{chunk-7QITUDRT.js → chunk-MLB6YNLS.js} +4 -4
- package/dist/{chunk-7QITUDRT.js.map → chunk-MLB6YNLS.js.map} +1 -1
- package/dist/{chunk-JABZNRXL.cjs → chunk-N2KG5AMQ.cjs} +4 -4
- package/dist/{chunk-JABZNRXL.cjs.map → chunk-N2KG5AMQ.cjs.map} +1 -1
- package/dist/{chunk-THGNDVVH.js → chunk-NRSYWQKM.js} +16 -4
- package/dist/chunk-NRSYWQKM.js.map +1 -0
- package/dist/{chunk-IIGKJYWL.js → chunk-PYDZ7ZGH.js} +3 -3
- package/dist/{chunk-IIGKJYWL.js.map → chunk-PYDZ7ZGH.js.map} +1 -1
- package/dist/{chunk-ENFBA33M.cjs → chunk-RLVZ3RLE.cjs} +8 -8
- package/dist/{chunk-ENFBA33M.cjs.map → chunk-RLVZ3RLE.cjs.map} +1 -1
- package/dist/{chunk-JMUHMLJP.js → chunk-SYUY7GNT.js} +7 -5
- package/dist/chunk-SYUY7GNT.js.map +1 -0
- package/dist/{chunk-VRUN5TG2.cjs → chunk-TUUEQ2WR.cjs} +8 -8
- package/dist/{chunk-VRUN5TG2.cjs.map → chunk-TUUEQ2WR.cjs.map} +1 -1
- package/dist/{chunk-HZ46RDLD.cjs → chunk-VNC5DNIQ.cjs} +11 -11
- package/dist/{chunk-HZ46RDLD.cjs.map → chunk-VNC5DNIQ.cjs.map} +1 -1
- package/dist/{chunk-MSDECC3A.cjs → chunk-VSDJCJKP.cjs} +44 -42
- package/dist/chunk-VSDJCJKP.cjs.map +1 -0
- package/dist/{chunk-GW54ANCH.js → chunk-X7IRSO4L.js} +3 -3
- package/dist/{chunk-GW54ANCH.js.map → chunk-X7IRSO4L.js.map} +1 -1
- package/dist/chunk-XOZIHGR5.cjs +27 -0
- package/dist/chunk-XOZIHGR5.cjs.map +1 -0
- package/dist/{chunk-YSEM7JDE.cjs → chunk-YEET2QGF.cjs} +4 -4
- package/dist/{chunk-YSEM7JDE.cjs.map → chunk-YEET2QGF.cjs.map} +1 -1
- package/dist/{chunk-CMH2ACOX.js → chunk-YEZ2YUKK.js} +3 -3
- package/dist/{chunk-CMH2ACOX.js.map → chunk-YEZ2YUKK.js.map} +1 -1
- package/dist/{chunk-SPP6HQMM.js → chunk-YX5FW7ON.js} +39 -5
- package/dist/chunk-YX5FW7ON.js.map +1 -0
- package/dist/{chunk-75ZMA34U.cjs → chunk-ZAOBNW6Y.cjs} +47 -11
- package/dist/chunk-ZAOBNW6Y.cjs.map +1 -0
- package/dist/{chunk-AZBIXGM5.js → chunk-ZXIP5T5V.js} +3 -3
- package/dist/{chunk-AZBIXGM5.js.map → chunk-ZXIP5T5V.js.map} +1 -1
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.js +7 -7
- package/dist/entries/credits.cjs +150 -150
- package/dist/entries/credits.d.cts +1 -1
- package/dist/entries/credits.d.ts +1 -1
- package/dist/entries/credits.js +7 -7
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/model-catalog.cjs +66 -66
- package/dist/entries/model-catalog.d.cts +2 -2
- package/dist/entries/model-catalog.d.ts +2 -2
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +261 -229
- package/dist/entries/models.d.cts +17 -3
- package/dist/entries/models.d.ts +17 -3
- package/dist/entries/models.js +4 -4
- package/dist/entries/nodes.cjs +206 -206
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +149 -149
- 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 +123 -115
- package/dist/entries/video.d.cts +26 -1
- package/dist/entries/video.d.ts +26 -1
- package/dist/entries/video.js +4 -4
- package/dist/index.cjs +1044 -1004
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -17
- package/dist/{model-catalog-I48SvalA.d.ts → model-catalog-dQPdLltX.d.cts} +11 -0
- package/dist/{model-catalog-I48SvalA.d.cts → model-catalog-dQPdLltX.d.ts} +11 -0
- package/dist/{model-constants-C43YS07I.d.ts → model-constants-B5ka4TQr.d.cts} +61 -6
- package/dist/{model-constants-C43YS07I.d.cts → model-constants-B5ka4TQr.d.ts} +61 -6
- package/package.json +1 -1
- package/src/__tests__/cast-swap-limits.test.ts +9 -0
- package/src/__tests__/gvp-supported-providers.test.ts +8 -1
- package/src/__tests__/kling4-catalog.test.ts +129 -0
- package/src/__tests__/video-character-refs.test.ts +3 -2
- package/src/cast-swap-limits.ts +9 -0
- package/src/credit-identifiers.ts +6 -0
- package/src/entries/models.ts +8 -0
- package/src/entries/video.ts +2 -0
- package/src/model-catalog.ts +82 -0
- package/src/model-constants.ts +151 -3
- package/src/node-default-mappings.ts +3 -0
- package/src/video-character-refs.ts +67 -0
- package/src/video-ui-defaults.ts +8 -5
- package/dist/chunk-75ZMA34U.cjs.map +0 -1
- package/dist/chunk-AQA6YXY5.cjs.map +0 -1
- package/dist/chunk-HABDAHZR.cjs.map +0 -1
- package/dist/chunk-JMUHMLJP.js.map +0 -1
- package/dist/chunk-KOP7UTQR.cjs.map +0 -1
- package/dist/chunk-MSDECC3A.cjs.map +0 -1
- package/dist/chunk-SPP6HQMM.js.map +0 -1
- package/dist/chunk-THGNDVVH.js.map +0 -1
- package/dist/chunk-VRLRPGO7.js.map +0 -1
- package/dist/chunk-W4GABGRD.js +0 -21
- package/dist/chunk-W4GABGRD.js.map +0 -1
- package/dist/chunk-XJ3HJSO5.cjs +0 -25
- package/dist/chunk-XJ3HJSO5.cjs.map +0 -1
- package/dist/chunk-ZG4XSEZV.js.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":["DEFAULT_TRANSCRIBE_NODE_PROVIDER"],"mappings":";;;;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,WAAA;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAAA,IACpF,WAAA,EAAa,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI;AAAA,GAC1E;AACF;AAGO,SAAS,aAAA,CA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face 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":["DEFAULT_TRANSCRIBE_NODE_PROVIDER"],"mappings":";;;;;AAKO,SAAS,eAAe,MAAA,EAA8F;AAC3H,EAAA,MAAM,IAAI,MAAA,EAAQ,YAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,WAAA;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAmB,OAAO,CAAA,KAAM,QAAQ,IAAI,EAAC;AAAA,IACpF,WAAA,EAAa,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,CAAA,GAAI,CAA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AMQ.cjs","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
1
|
import { VIDEO_DEPTH_PROVIDERS } from './chunk-3RYKIUAE.js';
|
|
2
2
|
import { LLM_MODEL_IDS } from './chunk-2BHOAYZW.js';
|
|
3
|
-
import { IMAGE_GEN_PROVIDERS, IMAGE_I2I_PROVIDERS, TEXT_TO_VIDEO_PROVIDERS, IMAGE_TO_VIDEO_PROVIDERS, VOICE_DESIGN_MODELS, TTS_PROVIDERS, LIP_SYNC_PROVIDERS, VIDEO_GEN_PROVIDERS, UPSCALE_IMAGE_PROVIDERS, IMAGE_EDIT_PROVIDERS, VIDEO_UPSCALE_PROVIDERS, MODIFY_IMAGE_PROVIDERS, VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, FACE_SWAP_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS } from './chunk-
|
|
4
|
-
import { MODEL_CATALOG } from './chunk-
|
|
3
|
+
import { IMAGE_GEN_PROVIDERS, IMAGE_I2I_PROVIDERS, TEXT_TO_VIDEO_PROVIDERS, IMAGE_TO_VIDEO_PROVIDERS, VOICE_DESIGN_MODELS, TTS_PROVIDERS, LIP_SYNC_PROVIDERS, VIDEO_GEN_PROVIDERS, UPSCALE_IMAGE_PROVIDERS, IMAGE_EDIT_PROVIDERS, VIDEO_UPSCALE_PROVIDERS, MODIFY_IMAGE_PROVIDERS, VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, FACE_SWAP_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS } from './chunk-A4NDZBSJ.js';
|
|
4
|
+
import { MODEL_CATALOG } from './chunk-5CKTBGB6.js';
|
|
5
5
|
|
|
6
6
|
// src/cast-swap-limits.ts
|
|
7
7
|
var CAST_SWAP_POST_PROMPT_MAX = 4e3;
|
|
@@ -21,8 +21,17 @@ var CAST_SWAP_FACE_MASKING_BOUNDS = {
|
|
|
21
21
|
threshold: [0.05, 0.95]
|
|
22
22
|
};
|
|
23
23
|
var CAST_SWAP_FACE_MASKING_DEFAULTS = {
|
|
24
|
+
/** What covers a masked face: a blur (`"depth"`, a depth-color view of it, is the other fill). */
|
|
25
|
+
fill: "blur",
|
|
24
26
|
minFaceHeightPct: 15,
|
|
25
27
|
maxFaceHeightPct: 0,
|
|
28
|
+
/**
|
|
29
|
+
* The frame margins when `zone` is left out: a face centred in the outer 10 %
|
|
30
|
+
* at the left or right is not masked (people walking in at the edge). An
|
|
31
|
+
* explicit `zone: null`, or all four margins 0, means no margins.
|
|
32
|
+
*/
|
|
33
|
+
zone: { leftPct: 10, rightPct: 10, topPct: 0, bottomPct: 0 },
|
|
34
|
+
/** A margin left out of a `zone` that is given. */
|
|
26
35
|
zonePct: 0,
|
|
27
36
|
blurStrengthPct: 2,
|
|
28
37
|
threshold: 0.5
|
|
@@ -172,6 +181,9 @@ var QUALITY_MAP = {
|
|
|
172
181
|
// Vidu Q4 — five tiers; the quality rungs stop at 1080p so "high" never
|
|
173
182
|
// lands on the 2k/4k ladder (4k is closed to the free tier).
|
|
174
183
|
"vidu-q4": { field: "resolution", values: { low: "540p", mid: "720p", high: "1080p" } },
|
|
184
|
+
// Kling 4.0 — two tiers on both endpoints.
|
|
185
|
+
"kling-4": { field: "resolution", values: { low: "720p", mid: "720p", high: "1080p" } },
|
|
186
|
+
"kling-4-keyframes": { field: "resolution", values: { low: "720p", mid: "720p", high: "1080p" } },
|
|
175
187
|
"wan-2.7-i2v": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
176
188
|
"wan-2.7-t2v": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
177
189
|
"happyhorse": { field: "resolution", values: { low: "720p", mid: "1080p", high: "1080p" } },
|
|
@@ -428,5 +440,5 @@ function buildModelTree() {
|
|
|
428
440
|
}
|
|
429
441
|
|
|
430
442
|
export { CAST_SWAP_FACE_MASKING_BOUNDS, CAST_SWAP_FACE_MASKING_DEFAULTS, CAST_SWAP_POST_PROMPT_MAX, CHARACTER_LORA_TRAINING_JOB_TYPE, DEFAULT_VOICE_CHANGER_MODEL, FLUX_LORA_CHARACTER_MODEL_ID, GEMINI_OMNI_VOICE_PRESETS, GEMINI_OMNI_VOICE_PRESET_IDS, NODE_DEFAULT_TYPES, PROVIDER_DIRECTIVE_DEFAULTS, SUNO_TRACK_SOURCE_TYPES, TREND_PROMPT_LIMITS, TTS_NEIGHBOUR_TEXT_MAX_CHARS, VOICE_CHANGER_MODELS, VOICE_CHANGER_MODEL_IDS, buildModelTree, deriveLinkedFields, extractCharacterLoraFields, getTargetField, getValidValues, mapAspectRatio, mapQuality, mapShotIntentToProviderDirectives, modelToNodeTarget, normalizeTtsNeighbourText, searchModelVariants, selectLoraRoutingForMentions, supportedDefaultDimensions, validateProviderForNodeType };
|
|
431
|
-
//# sourceMappingURL=chunk-
|
|
432
|
-
//# sourceMappingURL=chunk-
|
|
443
|
+
//# sourceMappingURL=chunk-NRSYWQKM.js.map
|
|
444
|
+
//# sourceMappingURL=chunk-NRSYWQKM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cast-swap-limits.ts","../src/gemini-omni-voices.ts","../src/node-default-mappings.ts","../src/tts-neighbour-text.ts","../src/provider-directive-defaults.ts","../src/lora-routing.ts","../src/suno-track-sources.ts","../src/voice-changer-models.ts","../src/model-tree.ts"],"names":[],"mappings":";;;;;;AAQO,IAAM,yBAAA,GAA4B;AAkBlC,IAAM,mBAAA,GAAsB;AAAA,EACjC,cAAA,EAAgB,GAAA;AAAA,EAChB,YAAA,EAAc,GAAA;AAAA,EACd,UAAA,EAAY,GAAA;AAAA,EACZ,iBAAA,EAAmB;AACrB;AAGO,IAAM,6BAAA,GAAgC;AAAA;AAAA,EAE3C,aAAA,EAAe,CAAC,CAAA,EAAG,GAAG,CAAA;AAAA;AAAA,EAEtB,OAAA,EAAS,CAAC,CAAA,EAAG,EAAE,CAAA;AAAA;AAAA,EAEf,eAAA,EAAiB,CAAC,GAAA,EAAK,CAAC,CAAA;AAAA,EACxB,SAAA,EAAW,CAAC,IAAA,EAAM,IAAI;AACxB;AAGO,IAAM,+BAAA,GAAkC;AAAA;AAAA,EAE7C,IAAA,EAAM,MAAA;AAAA,EACN,gBAAA,EAAkB,EAAA;AAAA,EAClB,gBAAA,EAAkB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,IAAA,EAAM,EAAE,OAAA,EAAS,EAAA,EAAI,UAAU,EAAA,E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c,CAAA,CAAE,MAAM,CAAC,CAAA;AAC/E","file":"chunk-NRSYWQKM.js","sourcesContent":["/**\n * Cast Swap's input limits, and what a trend built on it may put in its\n * prompts. One definition read by the server (which enforces them) and by\n * every screen that edits them (which holds Save before a refusal), so the two\n * cannot drift apart.\n */\n\n/** The longest `postPrompt` Cast Swap takes. */\nexport const CAST_SWAP_POST_PROMPT_MAX = 4000\n\n/**\n * A trend's prompt limits.\n *\n * - `trendPromptMax` / `prePromptMax`: the longest prompt a trend version may\n * store.\n * - `detailsMax`: the longest details a user may add to a run. They follow the\n * trend prompt in Cast Swap's `postPrompt`, after a blank line, so a new\n * trend prompt is held to `CAST_SWAP_POST_PROMPT_MAX − 2 − detailsMax`.\n * - `engineTextReserve`: the room kept for the text Cast Swap writes around a\n * trend's prompts in the prompt it builds, at its longest (a block for each\n * of the 13 roles a run allows with 200-character role names, five\n * 500-character reference lines, the keep, mask and edit lines and the\n * header: about 16,100 characters, rounded up so a small wording change does\n * not need this moved). The pre prompt, the trend prompt and the details\n * share what is left of Seedance 2.5's prompt cap.\n */\nexport const TREND_PROMPT_LIMITS = {\n trendPromptMax: 3000,\n prePromptMax: 3000,\n detailsMax: 1000,\n engineTextReserve: 17_000,\n} as const\n\n/** Cast Swap's `faceMasking` bounds, each `[min, max]` inclusive. */\nexport const CAST_SWAP_FACE_MASKING_BOUNDS = {\n /** `minFaceHeightPct` and `maxFaceHeightPct`, % of the frame's height (max 0 = no limit). */\n faceHeightPct: [0, 100],\n /** Each `zone` margin, % of the frame. */\n zonePct: [0, 49],\n /** % of the frame's width. */\n blurStrengthPct: [0.1, 5],\n threshold: [0.05, 0.95],\n} as const satisfies Record<string, readonly [number, number]>\n\n/** What Cast Swap uses for a `faceMasking` setting left out. */\nexport const CAST_SWAP_FACE_MASKING_DEFAULTS = {\n /** What covers a masked face: a blur (`\"depth\"`, a depth-color view of it, is the other fill). */\n fill: \"blur\",\n minFaceHeightPct: 15,\n maxFaceHeightPct: 0,\n /**\n * The frame margins when `zone` is left out: a face centred in the outer 10 %\n * at the left or right is not masked (people walking in at the edge). An\n * explicit `zone: null`, or all four margins 0, means no margins.\n */\n zone: { leftPct: 10, rightPct: 10, topPct: 0, bottomPct: 0 },\n /** A margin left out of a `zone` that is given. */\n zonePct: 0,\n blurStrengthPct: 2,\n threshold: 0.5,\n} as const\n","/**\n * The 30 preset voices Gemini Omni's audio-persona endpoint accepts, with the\n * style labels its documentation gives each one. DATA, so the API docs, the MCP\n * tool text and any client picker list them from one place instead of copying a\n * table that drifts.\n *\n * A preset is the BASE voice; a persona is that voice plus a free-text\n * description (timbre, pace, emotion) and an example line. Pinning a persona to a\n * character is what keeps one voice across separate clips.\n */\nexport interface GeminiOmniVoicePreset {\n id: string\n gender: \"female\" | \"male\" | \"genderless\"\n /** The documented character of the voice (\"soft\", \"raspy\", \"intellectual\"…). */\n style: string\n /** The documented pitch band (\"low\", \"mid-low\", \"mid\", \"mid-high\", \"high\"; \"younger\" for fenrir). */\n pitch: string\n}\n\nexport const GEMINI_OMNI_VOICE_PRESETS = [\n { id: \"achernar\", gender: \"female\", style: \"soft\", pitch: \"high\" },\n { id: \"achird\", gender: \"male\", style: \"friendly\", pitch: \"mid\" },\n { id: \"algenib\", gender: \"male\", style: \"raspy\", pitch: \"low\" },\n { id: \"algieba\", gender: \"male\", style: \"easygoing\", pitch: \"mid-low\" },\n { id: \"alnilam\", gender: \"male\", style: \"steady\", pitch: \"mid-low\" },\n { id: \"aoede\", gender: \"female\", style: \"brisk\", pitch: \"mid\" },\n { id: \"autonoe\", gender: \"female\", style: \"bright\", pitch: \"mid\" },\n { id: \"callirrhoe\", gender: \"female\", style: \"easygoing\", pitch: \"mid\" },\n { id: \"charon\", gender: \"male\", style: \"intellectual\", pitch: \"low\" },\n { id: \"despina\", gender: \"female\", style: \"smooth\", pitch: \"mid\" },\n { id: \"enceladus\", gender: \"male\", style: \"breathy\", pitch: \"low\" },\n { id: \"erinome\", gender: \"female\", style: \"clear\", pitch: \"mid\" },\n { id: \"fenrir\", gender: \"male\", style: \"lively\", pitch: \"younger\" },\n { id: \"gacrux\", gender: \"female\", style: \"mature\", pitch: \"mid\" },\n { id: \"iapetus\", gender: \"male\", style: \"clear\", pitch: \"mid-low\" },\n { id: \"kore\", gender: \"female\", style: \"capable\", pitch: \"mid\" },\n { id: \"laomedeia\", gender: \"female\", style: \"cheerful\", pitch: \"mid-high\" },\n { id: \"leda\", gender: \"female\", style: \"young\", pitch: \"mid-high\" },\n { id: \"orus\", gender: \"male\", style: \"steady\", pitch: \"mid-low\" },\n { id: \"puck\", gender: \"male\", style: \"cheerful\", pitch: \"mid\" },\n { id: \"pulcherrima\", gender: \"genderless\", style: \"forward\", pitch: \"mid-high\" },\n { id: \"rasalgethi\", gender: \"male\", style: \"intellectual\", pitch: \"mid\" },\n { id: \"sadachbia\", gender: \"male\", style: \"vivid\", pitch: \"low\" },\n { id: \"sadaltager\", gender: \"male\", style: \"knowledgeable\", pitch: \"mid\" },\n { id: \"schedar\", gender: \"male\", style: \"smooth\", pitch: \"mid-low\" },\n { id: \"sulafat\", gender: \"female\", style: \"warm\", pitch: \"mid\" },\n { id: \"umbriel\", gender: \"male\", style: \"smooth\", pitch: \"low\" },\n { id: \"vindemiatrix\", gender: \"female\", style: \"gentle\", pitch: \"mid\" },\n { id: \"zephyr\", gender: \"female\", style: \"bright\", pitch: \"mid-high\" },\n { id: \"zubenelgenubi\", gender: \"male\", style: \"casual\", pitch: \"mid-low\" },\n] as const satisfies readonly GeminiOmniVoicePreset[]\n\nexport type GeminiOmniVoicePresetId = (typeof GEMINI_OMNI_VOICE_PRESETS)[number][\"id\"]\n\n/** The preset ids as a non-empty tuple — what `z.enum(...)` takes. */\nexport const GEMINI_OMNI_VOICE_PRESET_IDS = GEMINI_OMNI_VOICE_PRESETS.map((v) => v.id) as unknown as readonly [\n GeminiOmniVoicePresetId,\n ...GeminiOmniVoicePresetId[],\n]\n","import {\n IMAGE_GEN_PROVIDERS,\n IMAGE_I2I_PROVIDERS,\n IMAGE_EDIT_PROVIDERS,\n UPSCALE_IMAGE_PROVIDERS,\n TEXT_TO_VIDEO_PROVIDERS,\n IMAGE_TO_VIDEO_PROVIDERS,\n VIDEO_GEN_PROVIDERS,\n LIP_SYNC_PROVIDERS,\n TTS_PROVIDERS,\n VOICE_DESIGN_MODELS,\n} from \"./model-constants.js\"\nimport { LLM_MODEL_IDS } from \"./llm-models.js\"\n\n// ──────────────────────────────────────────────────────────────────────────\n// Types\n// ──────────────────────────────────────────────────────────────────────────\n\nexport type QualityLevel = \"low\" | \"mid\" | \"high\"\nexport type SemanticAspectRatio = \"auto\" | \"1:1\" | \"4:3\" | \"3:4\" | \"16:9\" | \"9:16\"\n\nexport const NODE_DEFAULT_TYPES = [\n // Image\n \"generate-image\",\n \"image-to-image\",\n \"edit-image\",\n \"upscale-image\",\n // Video\n \"text-to-video\",\n \"image-to-video\",\n \"generate-video\",\n // Composition\n \"lip-sync\",\n // Audio / Music\n \"text-to-speech\",\n \"generate-music\",\n \"voice-design\",\n // LLM-driven\n \"ai-writer\",\n \"llm-chat\",\n \"lottie-overlay\",\n \"3d-title\",\n \"motion-graphics\",\n \"image-to-text\",\n \"qa-check\",\n] as const\n\nexport type NodeDefaultType = (typeof NODE_DEFAULT_TYPES)[number]\n\nexport const QUALITY_LEVELS: readonly QualityLevel[] = [\"low\", \"mid\", \"high\"] as const\nexport const SEMANTIC_ASPECT_RATIOS: readonly SemanticAspectRatio[] = [\n \"auto\",\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n] as const\n\n// ──────────────────────────────────────────────────────────────────────────\n// Per-node-type registry\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Per-node-type metadata: which field on the node carries the admin-set value,\n * the valid value set, and which optional dimensions apply.\n *\n * `field` distinguishes nodes that use `data.provider` (image/video/audio)\n * from nodes that use `data.model` (LLM nodes, voice-design).\n */\ninterface NodeTypeMeta {\n field: \"provider\" | \"model\"\n validValues: readonly string[]\n hasQuality: boolean\n hasAspectRatio: boolean\n}\n\n// Music providers per the runtime: enum currently only lists \"minimax\", but\n// `generate-music.defaultData.provider` is \"suno\" with a separate `modelVersion`.\n// Until that mismatch is fixed, accept both values for admin defaults.\nconst MUSIC_PROVIDERS_FOR_VALIDATION = [\"suno\", \"minimax\"] as const\n\nconst META: Record<NodeDefaultType, NodeTypeMeta> = {\n \"generate-image\": { field: \"provider\", validValues: IMAGE_GEN_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"image-to-image\": { field: \"provider\", validValues: IMAGE_I2I_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"edit-image\": { field: \"provider\", validValues: IMAGE_EDIT_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"upscale-image\": { field: \"provider\", validValues: UPSCALE_IMAGE_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"text-to-video\": { field: \"provider\", validValues: TEXT_TO_VIDEO_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"image-to-video\": { field: \"provider\", validValues: IMAGE_TO_VIDEO_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"generate-video\": { field: \"provider\", validValues: VIDEO_GEN_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"lip-sync\": { field: \"provider\", validValues: LIP_SYNC_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"text-to-speech\": { field: \"provider\", validValues: TTS_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"generate-music\": { field: \"provider\", validValues: MUSIC_PROVIDERS_FOR_VALIDATION, hasQuality: false, hasAspectRatio: false },\n \"voice-design\": { field: \"model\", validValues: VOICE_DESIGN_MODELS, hasQuality: false, hasAspectRatio: false },\n \"ai-writer\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"llm-chat\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"lottie-overlay\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"3d-title\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"motion-graphics\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"image-to-text\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"qa-check\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n}\n\nexport function getTargetField(nodeType: NodeDefaultType): \"provider\" | \"model\" {\n return META[nodeType].field\n}\n\nexport function getValidValues(nodeType: NodeDefaultType): readonly string[] {\n return META[nodeType].validValues\n}\n\nexport function supportedDefaultDimensions(nodeType: NodeDefaultType): {\n quality: boolean\n aspectRatio: boolean\n} {\n const m = META[nodeType]\n return { quality: m.hasQuality, aspectRatio: m.hasAspectRatio }\n}\n\nexport function validateProviderForNodeType(\n nodeType: NodeDefaultType,\n value: string,\n): string | null {\n const valid = META[nodeType].validValues\n if (!valid.includes(value)) {\n return `value \"${value}\" is not valid for node type \"${nodeType}\"`\n }\n return null\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Semantic mappings — quality + aspect ratio per provider\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Each provider stores its quality lever on a different field of node data:\n * - `resolution` (1K/2K/4K, 720p/1080p, …) — most image + video providers\n * - `quality` (medium/high, basic/high) — gpt-image, seedream\n *\n * Mapping a semantic level (low/mid/high) to a concrete value is meaningless\n * without knowing WHICH field it belongs to, because writing \"medium\" into\n * `resolution` (or \"2K\" into `quality`) trips the route's Zod enum at\n * generate-time. Each entry pairs the field with the per-level values built\n * from frontend/src/components/editor/config-panels/model-options.ts.\n *\n * Providers absent from this table return `undefined` from `mapQuality`,\n * letting the caller fall back to the factory default value.\n *\n * When a provider has fewer than 3 levels, semantic levels collapse onto\n * the closest concrete value (e.g. gpt-image only has medium/high → low maps\n * to medium).\n */\nexport type QualityField = \"resolution\" | \"quality\"\n\ninterface QualityMapping {\n field: QualityField\n values: Partial<Record<QualityLevel, string>>\n}\n\nconst QUALITY_MAP: Record<string, QualityMapping> = {\n // Image gen — resolution-style (1K/2K/4K)\n \"nano-banana-pro\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"nano-banana-2\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"nano-banana-2-1\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"flux\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-flex\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-pro-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"gpt-image-2\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-flare\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-flare-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-sunburst\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-sunburst-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n // Image gen — quality-style (medium/high or basic/high)\n \"gpt-image\": { field: \"quality\", values: { low: \"medium\", mid: \"medium\", high: \"high\" } },\n \"gpt-image-i2i\": { field: \"quality\", values: { low: \"medium\", mid: \"medium\", high: \"high\" } },\n \"seedream\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-edit\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-lite\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-lite-i2i\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-pro\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-pro-i2i\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n // Seedream 5 Flash's lever is size (sent as KIE `size`), flat-priced — resolution-style.\n \"seedream-5-flash\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"seedream-5-flash-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n // Video gen — resolution-style (720p/1080p)\n \"veo3\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"veo3.1\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling-3.0\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"seedance-2\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"seedance-2-fast\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n \"seedance-2-mini\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n // Seedance 2.5 spans 480p/720p/1080p on KIE (1080p accepted since the\n // 2026-08-17 re-probe; 4k still rejected), so each quality rung gets its own tier.\n \"seedance-2-5\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // Wan 3.0 family — 480p / 720p / 1080p (lowercase catalog spellings; the\n // uppercase KIE wire form is produced only by normalizeWan3Resolution).\n \"wan-3\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n \"wan-3-prime\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // Vidu Q4 — five tiers; the quality rungs stop at 1080p so \"high\" never\n // lands on the 2k/4k ladder (4k is closed to the free tier).\n \"vidu-q4\": { field: \"resolution\", values: { low: \"540p\", mid: \"720p\", high: \"1080p\" } },\n // Kling 4.0 — two tiers on both endpoints.\n \"kling-4\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"1080p\" } },\n \"kling-4-keyframes\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"1080p\" } },\n \"wan-2.7-i2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"wan-2.7-t2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-i2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-ref2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-edit\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling-3-omni\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"wan-videoedit\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n // Lightricks LTX 2.3 — 1080p / 2k / 4k (lowercase, matching VIDEO_RESOLUTION_OPTIONS).\n // `field: \"resolution\"` is mandatory — see Provider Enum Sync pitfall 4.\n \"ltx-2.3-pro\": { field: \"resolution\", values: { low: \"1080p\", mid: \"2k\", high: \"4k\" } },\n \"ltx-2.3-fast\": { field: \"resolution\", values: { low: \"1080p\", mid: \"2k\", high: \"4k\" } },\n \"gemini-omni-video\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n \"gemini-omni-flash\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n // Grok Imagine Video 1.5 — only 480p/720p (no 1080p tier); high clamps to 720p.\n \"grok-imagine-video-1.5\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n // Replicate Flux 2 family — MP-based resolution (matching IMAGE_RESOLUTION_OPTIONS[\"flux-2-*\"]).\n // `field: \"resolution\"` is mandatory — see Provider Enum Sync pitfall 4.\n // mid = provider default: 1 MP for Klein, 2 MP for Pro/Max.\n \"flux-2-klein\": { field: \"resolution\", values: { low: \"0.5 MP\", mid: \"1 MP\", high: \"2 MP\" } },\n \"flux-2-pro\": { field: \"resolution\", values: { low: \"1 MP\", mid: \"2 MP\", high: \"4 MP\" } },\n \"flux-2-max\": { field: \"resolution\", values: { low: \"1 MP\", mid: \"2 MP\", high: \"4 MP\" } },\n}\n\nconst ASPECT_PASSTHROUGH_PROVIDERS = new Set([\n ...IMAGE_GEN_PROVIDERS,\n ...IMAGE_I2I_PROVIDERS,\n ...TEXT_TO_VIDEO_PROVIDERS,\n ...IMAGE_TO_VIDEO_PROVIDERS,\n])\n\nexport interface MappedQuality {\n field: QualityField\n value: string\n}\n\nexport function mapQuality(provider: string, level: QualityLevel): MappedQuality | undefined {\n const m = QUALITY_MAP[provider]\n const value = m?.values[level]\n return value === undefined ? undefined : { field: m!.field, value }\n}\n\nexport function mapAspectRatio(\n provider: string,\n ratio: SemanticAspectRatio,\n): string | undefined {\n if (ratio === \"auto\") return undefined\n if (!ASPECT_PASSTHROUGH_PROVIDERS.has(provider as never)) return ratio\n return ratio\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Linked field derivation\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * When admin sets `provider` for a node that has linked fields (e.g.\n * generate-image stores both `provider` AND `model`), derive the linked\n * fields so the resolver writes a coherent snapshot.\n *\n * For unmapped providers, returns `{}` — the runtime config panel applies\n * its own defaulting when needed.\n */\nconst GENERATE_IMAGE_PROVIDER_TO_MODEL: Record<string, string> = {\n \"nano-banana\": \"gemini-2.5-flash-image\",\n \"nano-banana-pro\": \"gemini-2.5-flash-image\",\n \"nano-banana-2\": \"gemini-2.5-flash-image\",\n \"nano-banana-2-lite\": \"gemini-3.1-flash-lite-image\",\n}\n\nexport function deriveLinkedFields(\n nodeType: NodeDefaultType,\n value: string,\n): Record<string, unknown> {\n if (nodeType === \"generate-image\") {\n const model = GENERATE_IMAGE_PROVIDER_TO_MODEL[value]\n return model ? { model } : {}\n }\n return {}\n}\n","/**\n * The neighbour-text rule of Text to Speech — what is spoken just BEFORE and just AFTER a clip in the finished\n * piece — in ONE place, so the editor's run, the provider exits and the REST route cannot drift: a request that\n * the editor sends must be one the route accepts.\n *\n * A string is trimmed; an empty one, or anything that is not a string, is ABSENT. Over the cap the value is\n * TRIMMED, never rejected, by every sender and exit: previous text keeps its LAST characters (what leads into\n * the clip), next text its FIRST (what the clip leads into). The REST route is the one place that rejects an\n * over-cap value — measured on the trimmed text, for a model that stitches only. Whether a model takes the\n * fields at all is its sheet (`ttsSupportsStitching`), never decided here.\n */\n\n/**\n * The most characters of context sent on each side. ElevenLabs documents no limit for the text-to-speech\n * endpoint's fields; this bounds what we send (and what the vendor may count) to about two sentences' worth of\n * run-in and run-out — enough to carry intonation across a cut.\n */\nexport const TTS_NEIGHBOUR_TEXT_MAX_CHARS = 1000\n\n/** The normalised pair: only non-empty strings within the cap; a side that was unusable is not a key. */\nexport interface TtsNeighbourText {\n previousText?: string\n nextText?: string\n}\n\nfunction usableText(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined\n const trimmed = value.trim()\n return trimmed ? trimmed : undefined\n}\n\n/** `previousText` / `nextText` of `options`, normalised. Other keys are not carried over; the input is never mutated. */\nexport function normalizeTtsNeighbourText(\n options: Readonly<{ previousText?: unknown; nextText?: unknown }> | undefined,\n): TtsNeighbourText {\n const out: TtsNeighbourText = {}\n const previous = usableText(options?.previousText)\n if (previous !== undefined) {\n out.previousText = previous.length > TTS_NEIGHBOUR_TEXT_MAX_CHARS ? previous.slice(-TTS_NEIGHBOUR_TEXT_MAX_CHARS) : previous\n }\n const next = usableText(options?.nextText)\n if (next !== undefined) {\n out.nextText = next.length > TTS_NEIGHBOUR_TEXT_MAX_CHARS ? next.slice(0, TTS_NEIGHBOUR_TEXT_MAX_CHARS) : next\n }\n return out\n}\n","import type { ShotSpec } from \"./scene-node-types.js\"\n\n/**\n * Provider-specific directive defaults. Architecture spec §5.14.\n *\n * Each video model can have side-effects the user usually wants (Seedance baking in\n * ambient music, VEO supporting loop seeds, etc.). The engine applies these defaults\n * at provider-call time, allowing them to be overridden by the Scene Director's\n * `shot_intent` field (provider-neutral) which we map below.\n *\n * Keys are canonical provider identifiers (matching VIDEO_MODEL_CAPS in\n * model-constants.ts). Non-canonical keys would silently break downstream\n * route validation + payload building.\n */\nexport const PROVIDER_DIRECTIVE_DEFAULTS = {\n seedance: { multishot: true, disable_internal_music: true, allow_sfx: true },\n \"seedance-2\": { multishot: true, disable_internal_music: true, allow_sfx: true },\n veo3: { reference_count: \"auto\" as const },\n \"veo3.1\": { reference_count: \"auto\" as const },\n kling: { reference_count: \"auto\" as const },\n \"kling-3-omni\": { reference_count: \"auto\" as const },\n \"kling-turbo\": { reference_count: \"auto\" as const },\n hailuo: {} as Record<string, never>,\n \"hailuo-2.3-pro\": {} as Record<string, never>,\n \"hailuo-standard\": {} as Record<string, never>,\n minimax: {} as Record<string, never>,\n // MiniMax Hailuo 3 — multimodal like seedance-2 but no verified directive\n // semantics yet; empty until probed (NOTE: never match `minimax-h3` with a\n // startsWith(\"seedance\") / startsWith(\"minimax\") prefix check — exact keys only).\n \"minimax-h3\": {} as Record<string, never>,\n \"bytedance-lite\": {} as Record<string, never>,\n} as const\n\n/**\n * Maps a Scene Director's provider-neutral shot_intent to provider-specific directives.\n * Architecture spec §5.14 mapping table.\n *\n * Unknown providers fall through to an empty object — the directive degrades to a text\n * hint in the motion_prompt (Scene Director includes it there as a fallback when\n * `needs_music_suppression: true`).\n */\nexport function mapShotIntentToProviderDirectives(\n provider: string,\n shotIntent: ShotSpec[\"shot_intent\"],\n): Record<string, unknown> {\n const directives: Record<string, unknown> = {\n ...(PROVIDER_DIRECTIVE_DEFAULTS[provider as keyof typeof PROVIDER_DIRECTIVE_DEFAULTS] ?? {}),\n }\n\n if (shotIntent.needs_multishot_reference) {\n if (provider.startsWith(\"seedance\")) {\n directives.multishot = true\n }\n // VEO + Kling: accepts reference_images array — engine attaches the refs separately.\n // Hailuo: only 1 ref — silently ignored at engine layer.\n }\n\n if (shotIntent.is_loopable) {\n if (provider.startsWith(\"veo\")) {\n directives.loop_seed = \"stable\"\n }\n // Other providers: no native loop_seed → degrade to motion_prompt frame-matching hint.\n }\n\n if (shotIntent.needs_music_suppression) {\n if (provider.startsWith(\"seedance\")) {\n directives.disable_internal_music = true\n }\n // VEO / Kling / Hailuo don't bake in music; no directive needed.\n }\n\n return directives\n}\n","/**\n * Character LoRA routing decision + identifier constants.\n *\n * Shared between backend (orchestrator's payload-builder) and frontend\n * (single-node Run's execute-node). MUST agree byte-for-byte — the backend\n * stamps the credit identifier and worker payload off this decision, the\n * frontend stamps the `_internalLora` body hint off it. Mismatches would\n * silently degrade trained-character generations to ref injection.\n */\n\n/**\n * Synthetic Replicate model id selected by the orchestrator (and the\n * single-node Run pre-Zod swap) when a single trained `@character` mention\n * is detected. Routes through `black-forest-labs/flux-dev-lora` with the\n * character's trained version under `extraParams.lora_version`. Never\n * appears in user-facing dropdowns.\n */\nexport const FLUX_LORA_CHARACTER_MODEL_ID = \"flux-lora-character\" as const\n\n/**\n * `jobs.job_type` discriminator + credit identifier for character LoRA\n * training jobs. Used for `STATIC_CREDIT_COSTS`/`model_pricing` lookup,\n * `creditGuard` reservation, refund flow, and webhook job lookup.\n */\nexport const CHARACTER_LORA_TRAINING_JOB_TYPE = \"character-lora-training\" as const\n\n/**\n * The three LoRA fields read off `CharacterNodeData` and stamped onto every\n * `ConnectedReference` produced from a wired character. Shared between the\n * backend's `expandWiredCharacterRefs` and the frontend's\n * `expandCharacterNodeIntoRefs` so both sides emit the same three fields\n * without copy-paste drift.\n */\nexport interface CharacterLoraFields {\n readonly loraReplicateVersion: string | null\n readonly loraTriggerWord: string | null\n readonly loraTrainingStatus: string | null\n}\n\n/**\n * Extract the three LoRA fields from a character node's `data`, normalized\n * to `null` for missing/undefined values so downstream type-checks (e.g.\n * `selectLoraRoutingForMentions`'s `=== \"succeeded\"`) are deterministic.\n */\nexport function extractCharacterLoraFields(charData: {\n loraReplicateVersion?: string | null\n loraTriggerWord?: string | null\n loraTrainingStatus?: string | null\n}): CharacterLoraFields {\n return {\n loraReplicateVersion: charData.loraReplicateVersion ?? null,\n loraTriggerWord: charData.loraTriggerWord ?? null,\n loraTrainingStatus: charData.loraTrainingStatus ?? null,\n }\n}\n\nexport interface LoraRouting {\n readonly characterSlug: string\n readonly triggerWord: string\n readonly loraVersion: string\n}\n\nexport interface LoraEligibleRef {\n readonly characterSlug?: string\n readonly loraReplicateVersion?: string | null\n readonly loraTriggerWord?: string | null\n readonly loraTrainingStatus?: string | null\n}\n\n/**\n * Returns a LoraRouting iff EXACTLY ONE distinct character is mentioned AND\n * that character has a successful LoRA. Returns null otherwise → caller\n * falls back to ref injection. Multi-character LoRA composition is Phase 2.\n */\nexport function selectLoraRoutingForMentions(\n refs: readonly LoraEligibleRef[],\n): LoraRouting | null {\n const distinct = new Set(refs.map((r) => r.characterSlug).filter(Boolean))\n if (distinct.size !== 1) return null\n const slug = [...distinct][0]!\n const match = refs.find((r) => r.characterSlug === slug)\n if (\n !match ||\n !match.loraReplicateVersion ||\n !match.loraTriggerWord ||\n match.loraTrainingStatus !== \"succeeded\"\n ) {\n return null\n }\n return {\n characterSlug: slug,\n triggerWord: match.loraTriggerWord,\n loraVersion: match.loraReplicateVersion,\n }\n}\n","/**\n * Node types whose output carries Suno chaining ids (`sunoTrackId` /\n * `sunoTaskId`) for a downstream Suno node (extend / separate / replace /\n * add-vocals / …) to chain off.\n *\n * One set for the three readers — the canvas resolver, the orchestrator\n * resolver, and the config panels' \"Inherited\" hint (#819). They used to keep\n * their own copies and drifted: the canvas read ids off a `suno-separate`\n * (whose output is stems, not a track) while the orchestrator ignored it, so\n * the same graph resolved on one path and not the other. Structural\n * vocabulary only — node type names, no prompt content.\n */\nexport const SUNO_TRACK_SOURCE_TYPES: ReadonlySet<string> = new Set([\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n])\n","/**\n * ElevenLabs speech-to-speech (voice changer) models — single source of truth\n * for the Voice Changer node's model picker (frontend config panel) AND the\n * `/v1/voice-changer` route Zod enum (backend). Lifting the list here keeps the\n * dropdown and the validation enum from ever drifting apart.\n *\n * These are the two `model_id` values ElevenLabs' `/v1/speech-to-speech/{voiceId}`\n * endpoint accepts with `can_do_voice_conversion`. ElevenLabs' own docs\n * recommend Multilingual v2 even for English source audio (it often\n * outperforms the English-only model), and it's required for non-English\n * audio (e.g. Hebrew), so it's the default — English v2 stays selectable.\n */\nexport const VOICE_CHANGER_MODELS = [\n {\n value: \"eleven_multilingual_sts_v2\",\n label: \"Multilingual v2\",\n desc: \"29 languages; preserves emotion, cadence & timing. Default — ElevenLabs recommends this even for English audio.\",\n },\n {\n value: \"eleven_english_sts_v2\",\n label: \"English v2\",\n desc: \"English-optimized speech-to-speech.\",\n },\n] as const\n\nexport type VoiceChangerModel = (typeof VOICE_CHANGER_MODELS)[number][\"value\"]\n\n/** Plain id list for the route's `z.enum(...)`. */\nexport const VOICE_CHANGER_MODEL_IDS: VoiceChangerModel[] = VOICE_CHANGER_MODELS.map(\n (m) => m.value,\n)\n\n/** ElevenLabs recommends Multilingual v2 even for English source audio (it\n * often outperforms the English-only model), and it's required for\n * non-English audio — so it's the default. English v2 remains selectable. */\nexport const DEFAULT_VOICE_CHANGER_MODEL: VoiceChangerModel = \"eleven_multilingual_sts_v2\"\n","/**\n * Models-tab data source: maps each catalog model to the node it creates\n * (`modelToNodeTarget`) and groups node-creatable models into product lines\n * (`buildModelTree`). Consumed by the add-node popup's Models tab. Pure — derives\n * everything from `MODEL_CATALOG` + the provider enums, so models added to the\n * catalog/enums flow through automatically.\n */\nimport { MODEL_CATALOG, type ModelKind, type ModelMode } from \"./model-catalog.js\"\nimport {\n IMAGE_GEN_PROVIDERS, VIDEO_GEN_PROVIDERS, IMAGE_TO_VIDEO_PROVIDERS, TEXT_TO_VIDEO_PROVIDERS,\n UPSCALE_IMAGE_PROVIDERS, VIDEO_UPSCALE_PROVIDERS, MODIFY_IMAGE_PROVIDERS, IMAGE_EDIT_PROVIDERS,\n VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, LIP_SYNC_PROVIDERS,\n FACE_SWAP_PROVIDERS, TTS_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS,\n} from \"./model-constants.js\"\nimport { VIDEO_DEPTH_PROVIDERS } from \"./video-depth.js\"\n\nexport interface ModelNodeTarget {\n nodeType: string\n field?: \"provider\" | \"model\"\n value?: string\n}\nexport interface ModelTreeVariant extends ModelNodeTarget {\n id: string\n label: string\n kind: ModelKind\n}\nexport interface ModelTreeLine {\n series: string\n family: string\n kind: ModelKind\n models: ModelTreeVariant[]\n}\n\n// A model id that is a valid provider-enum value gets a node + provider preset.\nconst ENUM_TARGETS: ReadonlyArray<readonly [readonly string[], string]> = [\n [IMAGE_GEN_PROVIDERS, \"generate-image\"],\n [VIDEO_GEN_PROVIDERS, \"generate-video\"],\n [IMAGE_TO_VIDEO_PROVIDERS, \"generate-video\"],\n [TEXT_TO_VIDEO_PROVIDERS, \"generate-video\"],\n [UPSCALE_IMAGE_PROVIDERS, \"upscale-image\"],\n [VIDEO_UPSCALE_PROVIDERS, \"video-upscale\"],\n [VIDEO_DEPTH_PROVIDERS, \"video-depth\"],\n [MODIFY_IMAGE_PROVIDERS, \"modify-image\"],\n [IMAGE_EDIT_PROVIDERS, \"modify-image\"],\n [VIDEO_TO_VIDEO_PROVIDERS, \"video-to-video\"],\n [EXTEND_VIDEO_PROVIDERS, \"extend-video\"],\n [MOTION_TRANSFER_PROVIDERS, \"motion-transfer\"],\n [LIP_SYNC_PROVIDERS, \"lip-sync\"],\n [FACE_SWAP_PROVIDERS, \"face-swap\"],\n [TTS_PROVIDERS, \"text-to-speech\"],\n // A dialogue model's id is the node's `provider`: without this row the Models\n // tab would create a BARE dialogue node, which runs as the default (v3) whatever\n // the user picked.\n [DIALOGUE_PROVIDERS, \"text-to-dialogue\"],\n [TEXT_TO_AUDIO_PROVIDERS, \"text-to-audio\"],\n [TRANSCRIBE_PROVIDERS, \"transcribe\"],\n [MUSIC_PROVIDERS, \"suno-generate\"],\n]\n\n// Fallback by the catalog's own `modes`, for models whose id is NOT a provider-enum\n// value — single-provider utility nodes (voice-design, dubbing, …) and catalog models\n// that no node exposes as a provider option. These create a bare node of the right\n// type (no provider preset — the user picks the model inside the node).\nconst MODE_TO_NODE: Readonly<Partial<Record<ModelMode, string>>> = {\n \"t2i\": \"generate-image\", \"i2i\": \"modify-image\", \"edit\": \"modify-image\", \"remove-bg\": \"modify-image\",\n \"t2v\": \"generate-video\", \"i2v\": \"generate-video\", \"v2v\": \"video-to-video\", \"extend\": \"extend-video\",\n \"upscale\": \"upscale-image\", \"video-upscale\": \"video-upscale\", \"motion-transfer\": \"motion-transfer\",\n \"lip-sync\": \"lip-sync\", \"tts\": \"text-to-speech\", \"sfx\": \"text-to-audio\",\n \"music\": \"suno-generate\", \"voice-design\": \"voice-design\", \"voice-changer\": \"voice-changer\",\n \"isolation\": \"audio-isolation\", \"dubbing\": \"dubbing\", \"forced-alignment\": \"forced-alignment\", \"stt\": \"transcribe\",\n \"dialogue\": \"text-to-dialogue\",\n \"video-analysis\": \"video-analysis\",\n}\n\nexport function modelToNodeTarget(modelId: string): ModelNodeTarget | null {\n const entry = MODEL_CATALOG[modelId]\n if (!entry) return null\n // Resolve the target node: a valid provider-enum value wins, else the catalog's modes.\n const enumMatch = ENUM_TARGETS.find(([providers]) => providers.includes(modelId))\n const nodeType = enumMatch?.[1] ?? entry.modes.map((m) => MODE_TO_NODE[m]).find(Boolean)\n if (!nodeType) return null\n // suno-generate stores its model in `data.model` (a V-code carried on the catalog\n // entry as `dataValue`), not as a `provider` id. Every other node takes a `provider`\n // preset when the id is a valid enum value, and a bare node otherwise.\n if (nodeType === \"suno-generate\") {\n return entry.dataValue ? { nodeType, field: \"model\", value: entry.dataValue } : { nodeType }\n }\n return enumMatch ? { nodeType, field: \"provider\", value: modelId } : { nodeType }\n}\n\n/**\n * Flat, query-filtered model variants for the add-node search. The single source\n * of truth shared by the Models tab/category browser and every tab's search\n * (image/video/audio narrow by `kind`; models/all/common pass no kind). Filters\n * by label/id substring; a blank query returns `[]`. Derived from\n * `buildModelTree`, so only node-creatable models appear and new catalog entries\n * flow through automatically.\n */\n// MODEL_CATALOG + the provider enums are static module constants, so the tree\n// never changes at runtime — build it once and reuse for every search keystroke.\nlet _modelTree: ModelTreeLine[] | null = null\nfunction getModelTree(): ModelTreeLine[] {\n return (_modelTree ??= buildModelTree())\n}\n\nexport function searchModelVariants(query: string, kind?: ModelKind): ModelTreeVariant[] {\n const q = query.trim().toLowerCase()\n if (!q) return []\n return getModelTree()\n .flatMap((l) => l.models)\n .filter((m) => (!kind || m.kind === kind) && (m.label.toLowerCase().includes(q) || m.id.toLowerCase().includes(q)))\n}\n\nexport function buildModelTree(): ModelTreeLine[] {\n const bySeries = new Map<string, ModelTreeLine>()\n for (const entry of Object.values(MODEL_CATALOG)) {\n const target = modelToNodeTarget(entry.id)\n if (!target || !entry.series) continue\n let line = bySeries.get(entry.series)\n if (!line) {\n line = { series: entry.series, family: entry.family, kind: entry.kind, models: [] }\n bySeries.set(entry.series, line)\n }\n line.models.push({ id: entry.id, label: entry.label, kind: entry.kind, ...target })\n }\n return [...bySeries.values()].sort((a, b) => a.series.localeCompare(b.series))\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getModel } from './chunk-
|
|
1
|
+
import { getModel } from './chunk-5CKTBGB6.js';
|
|
2
2
|
|
|
3
3
|
// src/safety-retry-policy.ts
|
|
4
4
|
function safetyRetryPolicy(modelId) {
|
|
@@ -13,5 +13,5 @@ function safetyRetryPolicy(modelId) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export { safetyRetryPolicy };
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-PYDZ7ZGH.js.map
|
|
17
|
+
//# sourceMappingURL=chunk-PYDZ7ZGH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/safety-retry-policy.ts"],"names":[],"mappings":";;;AA0BO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQ,SAAS,OAAO,CAAA;AAC9B,EAAA,MAAM,eAAe,KAAA,EAAO,YAAA;AAC5B,EAAA,IAAI,CAAC,YAAA,EAAc,UAAA,EAAY,OAAO,EAAE,aAAa,CAAA,EAAE;AAEvD,EAAA,MAAM,WAAW,YAAA,CAAa,QAAA;AAC9B,EAAA,IAAI,QAAA,IAAY,QAAA,CAAS,QAAQ,CAAA,EAAG;AAClC,IAAA,OAAO,EAAE,WAAA,EAAa,CAAA,EAAG,QAAA,EAAS;AAAA,EACpC;AACA,EAAA,OAAO,EAAE,aAAa,CAAA,EAAE;AAC1B","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/safety-retry-policy.ts"],"names":[],"mappings":";;;AA0BO,SAAS,kBAAkB,OAAA,EAAoC;AACpE,EAAA,MAAM,KAAA,GAAQ,SAAS,OAAO,CAAA;AAC9B,EAAA,MAAM,eAAe,KAAA,EAAO,YAAA;AAC5B,EAAA,IAAI,CAAC,YAAA,EAAc,UAAA,EAAY,OAAO,EAAE,aAAa,CAAA,EAAE;AAEvD,EAAA,MAAM,WAAW,YAAA,CAAa,QAAA;AAC9B,EAAA,IAAI,QAAA,IAAY,QAAA,CAAS,QAAQ,CAAA,EAAG;AAClC,IAAA,OAAO,EAAE,WAAA,EAAa,CAAA,EAAG,QAAA,EAAS;AAAA,EACpC;AACA,EAAA,OAAO,EAAE,aAAa,CAAA,EAAE;AAC1B","file":"chunk-PYDZ7ZGH.js","sourcesContent":["import { getModel } from \"./model-catalog.js\"\n\n/**\n * Retry/fallback behavior derived from a catalog entry's `safetyFilter`\n * flag (see `ModelCatalogEntry.safetyFilter` in `model-catalog.ts`).\n */\nexport interface SafetyRetryPolicy {\n /** 2 when the model declares `safetyFilter.stochastic`, else 1. */\n maxAttempts: 1 | 2\n /**\n * Catalog model id to offer when the retry also blocks. Only present\n * when the entry declares one AND it resolves to a real catalog entry.\n */\n fallback?: string\n}\n\n/**\n * The provider's safety filter is known to be non-deterministic on some\n * catalog models — a benign prompt can trip it once and pass on an\n * identical retry. For those models the platform retries a blocked\n * request once (`maxAttempts: 2`) before giving up; `fallback` names the\n * catalog model to offer the user when the retry also blocks.\n *\n * Every model not flagged this way — including an unrecognized id —\n * gets a single attempt and no fallback.\n */\nexport function safetyRetryPolicy(modelId: string): SafetyRetryPolicy {\n const entry = getModel(modelId)\n const safetyFilter = entry?.safetyFilter\n if (!safetyFilter?.stochastic) return { maxAttempts: 1 }\n\n const fallback = safetyFilter.fallback\n if (fallback && getModel(fallback)) {\n return { maxAttempts: 2, fallback }\n }\n return { maxAttempts: 2 }\n}\n"]}
|