@nodaro/shared 3.62.0 → 3.63.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-6CSXMWL4.cjs → chunk-2PU3AGGS.cjs} +27 -4
- package/dist/chunk-2PU3AGGS.cjs.map +1 -0
- package/dist/{chunk-CC4V2B7S.js → chunk-34QLPTSA.js} +3 -3
- package/dist/{chunk-CC4V2B7S.js.map → chunk-34QLPTSA.js.map} +1 -1
- package/dist/{chunk-G4U3HW6W.js → chunk-3K24DWOH.js} +3 -3
- package/dist/{chunk-G4U3HW6W.js.map → chunk-3K24DWOH.js.map} +1 -1
- package/dist/{chunk-GSFB537T.js → chunk-4DVWXEB6.js} +23 -4
- package/dist/chunk-4DVWXEB6.js.map +1 -0
- package/dist/{chunk-ZES6EZC4.js → chunk-4MMZD63H.js} +3 -3
- package/dist/{chunk-ZES6EZC4.js.map → chunk-4MMZD63H.js.map} +1 -1
- package/dist/{chunk-N7OUQK7E.cjs → chunk-63H4C56Q.cjs} +8 -8
- package/dist/{chunk-N7OUQK7E.cjs.map → chunk-63H4C56Q.cjs.map} +1 -1
- package/dist/{chunk-2D5LQFV4.cjs → chunk-6BZC2ZHC.cjs} +9 -9
- package/dist/{chunk-2D5LQFV4.cjs.map → chunk-6BZC2ZHC.cjs.map} +1 -1
- package/dist/{chunk-3OYO3XCC.js → chunk-6M563QE6.js} +71 -9
- package/dist/chunk-6M563QE6.js.map +1 -0
- package/dist/{chunk-IDTKF5EX.cjs → chunk-6TGB7ECA.cjs} +7 -7
- package/dist/{chunk-IDTKF5EX.cjs.map → chunk-6TGB7ECA.cjs.map} +1 -1
- package/dist/{chunk-2HZGDZZN.cjs → chunk-6XUG4L7X.cjs} +6 -6
- package/dist/{chunk-2HZGDZZN.cjs.map → chunk-6XUG4L7X.cjs.map} +1 -1
- package/dist/{chunk-CIPPPT7E.cjs → chunk-77WU3V3J.cjs} +6 -6
- package/dist/{chunk-CIPPPT7E.cjs.map → chunk-77WU3V3J.cjs.map} +1 -1
- package/dist/{chunk-C7POAYFE.js → chunk-AE3AAJ4O.js} +3 -3
- package/dist/{chunk-C7POAYFE.js.map → chunk-AE3AAJ4O.js.map} +1 -1
- package/dist/{chunk-NGKKNSK6.js → chunk-BMJVKYVB.js} +36 -15
- package/dist/chunk-BMJVKYVB.js.map +1 -0
- package/dist/{chunk-YCXRSWCQ.js → chunk-CZ5IQB3L.js} +3 -3
- package/dist/{chunk-YCXRSWCQ.js.map → chunk-CZ5IQB3L.js.map} +1 -1
- package/dist/{chunk-E2HZTGYX.js → chunk-EPXGG27L.js} +7 -7
- package/dist/chunk-EPXGG27L.js.map +1 -0
- package/dist/{chunk-3M4BNKFJ.cjs → chunk-F6WGGYQW.cjs} +167 -3
- package/dist/chunk-F6WGGYQW.cjs.map +1 -0
- package/dist/{chunk-7FCTCWHD.js → chunk-FXGNRYQQ.js} +3 -3
- package/dist/{chunk-7FCTCWHD.js.map → chunk-FXGNRYQQ.js.map} +1 -1
- package/dist/{chunk-QWYFHQYK.cjs → chunk-GMBDLNLD.cjs} +86 -62
- package/dist/chunk-GMBDLNLD.cjs.map +1 -0
- package/dist/{chunk-KJSRPHJ2.cjs → chunk-GSKLPI3J.cjs} +100 -46
- package/dist/chunk-GSKLPI3J.cjs.map +1 -0
- package/dist/{chunk-S5TMRJMX.js → chunk-HBXF6RUU.js} +4 -4
- package/dist/{chunk-S5TMRJMX.js.map → chunk-HBXF6RUU.js.map} +1 -1
- package/dist/{chunk-S24ZBUB4.js → chunk-HWQ2SYNA.js} +6 -32
- package/dist/chunk-HWQ2SYNA.js.map +1 -0
- package/dist/{chunk-JJNNM23P.js → chunk-IY3Y462W.js} +3 -3
- package/dist/{chunk-JJNNM23P.js.map → chunk-IY3Y462W.js.map} +1 -1
- package/dist/{chunk-JZGZ26YB.js → chunk-KCZHQH2O.js} +4 -4
- package/dist/{chunk-JZGZ26YB.js.map → chunk-KCZHQH2O.js.map} +1 -1
- package/dist/{chunk-FVII3KHN.js → chunk-KMGCHV6O.js} +163 -4
- package/dist/chunk-KMGCHV6O.js.map +1 -0
- package/dist/{chunk-4ZEFP2FQ.cjs → chunk-L2TVY6XN.cjs} +4 -4
- package/dist/{chunk-4ZEFP2FQ.cjs.map → chunk-L2TVY6XN.cjs.map} +1 -1
- package/dist/{chunk-TRVWMKNE.cjs → chunk-LH72PQO2.cjs} +204 -52
- package/dist/chunk-LH72PQO2.cjs.map +1 -0
- package/dist/{chunk-HRY7KGAE.cjs → chunk-LMAQUR55.cjs} +6 -6
- package/dist/{chunk-HRY7KGAE.cjs.map → chunk-LMAQUR55.cjs.map} +1 -1
- package/dist/{chunk-MYJQELFN.cjs → chunk-M5OCFGHF.cjs} +254 -7
- package/dist/chunk-M5OCFGHF.cjs.map +1 -0
- package/dist/{chunk-I2RQB7VG.js → chunk-MD4XHED4.js} +3 -3
- package/dist/{chunk-I2RQB7VG.js.map → chunk-MD4XHED4.js.map} +1 -1
- package/dist/{chunk-6G7NN4S4.js → chunk-NIAFR5EE.js} +2 -2
- package/dist/chunk-NIAFR5EE.js.map +1 -0
- package/dist/{chunk-CF4S4N5X.js → chunk-O2QOBA6Q.js} +2 -2
- package/dist/{chunk-CF4S4N5X.js.map → chunk-O2QOBA6Q.js.map} +1 -1
- package/dist/{chunk-4GGLKRYI.cjs → chunk-O6TBB4IF.cjs} +2 -2
- package/dist/{chunk-4GGLKRYI.cjs.map → chunk-O6TBB4IF.cjs.map} +1 -1
- package/dist/{chunk-UDDVDQMF.js → chunk-OV3JTKBY.js} +166 -25
- package/dist/chunk-OV3JTKBY.js.map +1 -0
- package/dist/{chunk-5YYN5X57.js → chunk-PSKZKLDG.js} +252 -8
- package/dist/chunk-PSKZKLDG.js.map +1 -0
- package/dist/{chunk-IWWVPR3W.cjs → chunk-TM5JYSJF.cjs} +95 -19
- package/dist/chunk-TM5JYSJF.cjs.map +1 -0
- package/dist/{chunk-G3KVK7OU.cjs → chunk-V5EEQR2U.cjs} +21 -21
- package/dist/{chunk-G3KVK7OU.cjs.map → chunk-V5EEQR2U.cjs.map} +1 -1
- package/dist/{chunk-AOJ6B7K4.cjs → chunk-WZVIBAKN.cjs} +12 -12
- package/dist/chunk-WZVIBAKN.cjs.map +1 -0
- package/dist/{chunk-5M43XMRB.cjs → chunk-X5BAFW3Q.cjs} +8 -8
- package/dist/{chunk-5M43XMRB.cjs.map → chunk-X5BAFW3Q.cjs.map} +1 -1
- package/dist/{chunk-SYWR5G3T.js → chunk-XBTYGQ6Z.js} +51 -7
- package/dist/chunk-XBTYGQ6Z.js.map +1 -0
- package/dist/{chunk-AFYTX4AI.cjs → chunk-XGGZWA4A.cjs} +107 -50
- package/dist/chunk-XGGZWA4A.cjs.map +1 -0
- package/dist/{chunk-VACPZPUA.cjs → chunk-XGVJGNZW.cjs} +5 -5
- package/dist/{chunk-VACPZPUA.cjs.map → chunk-XGVJGNZW.cjs.map} +1 -1
- package/dist/{chunk-2W745U4A.cjs → chunk-Y35JQPT6.cjs} +42 -70
- package/dist/chunk-Y35JQPT6.cjs.map +1 -0
- package/dist/{chunk-KYMHFVAZ.cjs → chunk-Y4GCJJPF.cjs} +2 -2
- package/dist/chunk-Y4GCJJPF.cjs.map +1 -0
- package/dist/{chunk-PTD6EDUU.js → chunk-YUER7TJG.js} +3 -3
- package/dist/{chunk-PTD6EDUU.js.map → chunk-YUER7TJG.js.map} +1 -1
- package/dist/{chunk-Y6X7UJSD.js → chunk-YX6TFX7H.js} +66 -14
- package/dist/chunk-YX6TFX7H.js.map +1 -0
- package/dist/{chunk-TWF2OSH4.cjs → chunk-ZPE2ZTJ4.cjs} +4 -4
- package/dist/{chunk-TWF2OSH4.cjs.map → chunk-ZPE2ZTJ4.cjs.map} +1 -1
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.js +7 -7
- package/dist/entries/credits.cjs +237 -169
- package/dist/entries/credits.d.cts +163 -16
- package/dist/entries/credits.d.ts +163 -16
- package/dist/entries/credits.js +10 -10
- package/dist/entries/llm-models.cjs +77 -57
- package/dist/entries/llm-models.d.cts +85 -6
- package/dist/entries/llm-models.d.ts +85 -6
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +63 -63
- package/dist/entries/media.d.cts +8 -0
- package/dist/entries/media.d.ts +8 -0
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +121 -105
- package/dist/entries/model-catalog.d.cts +48 -18
- package/dist/entries/model-catalog.d.ts +48 -18
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +418 -322
- package/dist/entries/models.d.cts +71 -5
- package/dist/entries/models.d.ts +71 -5
- package/dist/entries/models.js +5 -5
- package/dist/entries/nodes.cjs +216 -208
- package/dist/entries/nodes.d.cts +22 -6
- package/dist/entries/nodes.d.ts +22 -6
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +152 -152
- package/dist/entries/pipeline.d.cts +3 -3
- package/dist/entries/pipeline.d.ts +3 -3
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/runtime-config.cjs +29 -29
- package/dist/entries/runtime-config.d.cts +10 -7
- package/dist/entries/runtime-config.d.ts +10 -7
- package/dist/entries/runtime-config.js +1 -1
- package/dist/entries/social.cjs +177 -177
- package/dist/entries/social.js +2 -2
- package/dist/entries/types.d.cts +8 -0
- package/dist/entries/types.d.ts +8 -0
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +154 -150
- package/dist/entries/video.d.cts +11 -2
- package/dist/entries/video.d.ts +11 -2
- package/dist/entries/video.js +6 -6
- package/dist/entries/workflow.d.cts +1 -1
- package/dist/entries/workflow.d.ts +1 -1
- package/dist/index.cjs +1727 -1515
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +23 -23
- package/dist/{model-catalog-CCEcv08q.d.cts → model-catalog-C_Eo35tL.d.cts} +30 -0
- package/dist/{model-catalog-CCEcv08q.d.ts → model-catalog-C_Eo35tL.d.ts} +30 -0
- package/dist/{model-constants-Cf3zaITt.d.cts → model-constants-Bg4ccSQb.d.ts} +138 -25
- package/dist/{model-constants-B88p6XR0.d.ts → model-constants-DWcxOmaY.d.cts} +138 -25
- package/package.json +1 -1
- package/src/__tests__/credit-identifiers.test.ts +29 -0
- package/src/__tests__/extend-providers.test.ts +106 -26
- package/src/__tests__/gvp-supported-providers.test.ts +27 -2
- package/src/__tests__/lip-sync-audio-rate.test.ts +74 -0
- package/src/__tests__/lip-sync-levers.test.ts +31 -0
- package/src/__tests__/llm-models.test.ts +132 -3
- package/src/__tests__/llm-price-key.test.ts +152 -1
- package/src/__tests__/nemotron-transcribe-pricing.test.ts +61 -0
- package/src/__tests__/normalize-node-params.test.ts +25 -0
- package/src/__tests__/pixverse-v6-max-catalog.test.ts +271 -0
- package/src/__tests__/prompt-length-limits.test.ts +4 -0
- package/src/__tests__/seedance-task-type.test.ts +13 -3
- package/src/__tests__/transcribe-capabilities.test.ts +39 -2
- package/src/__tests__/transcribe-preflight.test.ts +50 -1
- package/src/__tests__/video-audio-capability.test.ts +35 -6
- package/src/__tests__/video-resolution-billed-as-named.test.ts +30 -0
- package/src/__tests__/video-upscale-params.test.ts +62 -0
- package/src/catalog-projection.ts +8 -0
- package/src/credit-estimators/index.ts +10 -0
- package/src/credit-estimators/nemotron-transcribe.ts +87 -0
- package/src/credit-identifiers.ts +109 -35
- package/src/entries/credits.ts +12 -1
- package/src/entries/llm-models.ts +6 -0
- package/src/entries/model-catalog.ts +9 -0
- package/src/entries/models.ts +35 -0
- package/src/entries/nodes.ts +2 -0
- package/src/entries/video.ts +1 -1
- package/src/freecut-protocol.ts +8 -0
- package/src/lip-sync-levers.ts +56 -0
- package/src/lip-sync-pricing.ts +91 -1
- package/src/llm-models.ts +249 -4
- package/src/model-catalog.ts +250 -4
- package/src/model-constants.ts +277 -30
- package/src/model-tree.ts +2 -1
- package/src/nodaro-video-upscale.ts +48 -0
- package/src/node-default-mappings.ts +3 -0
- package/src/normalize-node-params.ts +49 -1
- package/src/runtime-config/contract.ts +10 -7
- package/src/seedance-draft.ts +2 -1
- package/src/transcribe-preflight.ts +58 -7
- package/src/video-duration.ts +9 -0
- package/src/video-ui-defaults.ts +5 -3
- package/src/video-upscale-params.ts +67 -0
- package/dist/chunk-2W745U4A.cjs.map +0 -1
- package/dist/chunk-3M4BNKFJ.cjs.map +0 -1
- package/dist/chunk-3OYO3XCC.js.map +0 -1
- package/dist/chunk-5YYN5X57.js.map +0 -1
- package/dist/chunk-6CSXMWL4.cjs.map +0 -1
- package/dist/chunk-6G7NN4S4.js.map +0 -1
- package/dist/chunk-AFYTX4AI.cjs.map +0 -1
- package/dist/chunk-AOJ6B7K4.cjs.map +0 -1
- package/dist/chunk-E2HZTGYX.js.map +0 -1
- package/dist/chunk-FVII3KHN.js.map +0 -1
- package/dist/chunk-GSFB537T.js.map +0 -1
- package/dist/chunk-IWWVPR3W.cjs.map +0 -1
- package/dist/chunk-KJSRPHJ2.cjs.map +0 -1
- package/dist/chunk-KYMHFVAZ.cjs.map +0 -1
- package/dist/chunk-MYJQELFN.cjs.map +0 -1
- package/dist/chunk-NGKKNSK6.js.map +0 -1
- package/dist/chunk-QWYFHQYK.cjs.map +0 -1
- package/dist/chunk-S24ZBUB4.js.map +0 -1
- package/dist/chunk-SYWR5G3T.js.map +0 -1
- package/dist/chunk-TRVWMKNE.cjs.map +0 -1
- package/dist/chunk-UDDVDQMF.js.map +0 -1
- package/dist/chunk-Y6X7UJSD.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker-restrictions.ts","../src/component-types.ts","../src/oauth-scopes.ts","../src/recast-segment-packs.ts","../src/template-categories.ts"],"names":["INPUT_FIELD_MAP","canonicalExposedFieldKey"],"mappings":";;;;;AAYA,IAAM,QAAA,GAAW,CAAC,CAAA,KAAA,CACf,KAAA,CAAM,QAAQ,CAAC,CAAA,GAAI,CAAA,GAAI,CAAC,CAAC,CAA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AA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,OAAA,CAAQ,IAAI,KAAK,CAAA;AACvD;AAGO,SAAS,wBAAwB,KAAA,EAAgE;AACtG,EAAA,IAAI,KAAA,IAAS,MAAM,OAAO,MAAA;AAC1B,EAAA,IAAI,kBAAA,CAAmB,KAAK,CAAA,EAAG,OAAO,KAAA;AACtC,EAAA,OAAO,2BAA2B,KAAK,CAAA;AACzC;AAGO,SAAS,0BAA0B,KAAA,EAAoD;AAC5F,EAAA,OAAO,uBAAA,CAAwB,KAAK,CAAA,IAAK,yBAAA;AAC3C;AAOO,SAAS,6BAA6B,QAAA,EAAsC;AACjF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,IAAA,CAAK,0BAA0B,CAAA,CAAE,MAAA,CAAO,CAAC,KAAA,KAAU,0BAAA,CAA2B,KAAK,CAAA,KAAM,QAAQ,CAAA;AACvH,EAAA,OAAO,CAAC,QAAA,EAAU,GAAG,MAAM,CAAA;AAC7B","file":"chunk-CIPPPT7E.cjs","sourcesContent":["import { canonicalExposedFieldKey } from \"./exposed-field-keys.js\"\nimport { INPUT_FIELD_MAP } from \"./presentation-utils.js\"\n\n/** What an app's picker card may restrict (stored in `presentationSettings.cardMeta[nodeId]`). */\nexport interface PickerCardRestrictions {\n readonly pickerAllowedValues?: readonly string[]\n readonly pickerAllowedValuesByField?: Readonly<Record<string, readonly string[]>>\n}\n\n// Every submitted value is checked, whatever its type — a number or object where a\n// catalog id belongs must be refused, not skipped. An unset / cleared pick (\"\" , null)\n// is no selection and passes (the node falls back to its default).\nconst valuesOf = (v: unknown): string[] =>\n (Array.isArray(v) ? v : [v]).filter((x) => x !== undefined && x !== null && x !== \"\").map(String)\n\n/**\n * The first submitted picker value an app's card restrictions forbid, as the\n * runner's 400 text; null when all pass. Runs on every app run — `run_app`,\n * the SDK and a hand-built body included — so a restriction is never UI-only.\n * A submitted key is read through `canonicalExposedFieldKey`, so a legacy\n * spelling cannot slip past a restriction written against the current field.\n */\nexport function findRestrictedPickerValue(input: {\n readonly cardMeta: Readonly<Record<string, PickerCardRestrictions | undefined>> | undefined\n readonly nodes: ReadonlyArray<{ readonly id: string; readonly type?: string }>\n readonly inputValues: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined\n}): string | null {\n if (!input.cardMeta || !input.inputValues) return null\n for (const node of input.nodes) {\n const meta = input.cardMeta[node.id]\n const submitted = input.inputValues[node.id]\n if (!meta || !submitted) continue\n const rules: Array<[string, readonly string[]]> = []\n const rep = node.type ? INPUT_FIELD_MAP[node.type]?.key : undefined\n if (rep && meta.pickerAllowedValues && meta.pickerAllowedValues.length > 0) rules.push([rep, meta.pickerAllowedValues])\n for (const [field, allowed] of Object.entries(meta.pickerAllowedValuesByField ?? {})) {\n if (allowed.length > 0) rules.push([field, allowed])\n }\n for (const [field, allowed] of rules) {\n for (const [key, raw] of Object.entries(submitted)) {\n if (canonicalExposedFieldKey(node.type, key) !== field) continue\n for (const value of valuesOf(raw)) {\n if (!allowed.includes(value)) return `Invalid value for ${field}: ${value}. Allowed: ${allowed.join(\", \")}`\n }\n }\n }\n }\n return null\n}\n","import { INPUT_FIELD_MAP as PRESENTATION_INPUT_MAP } from \"./presentation-utils.js\"\n\nexport interface ComponentHandle {\n id: string\n name: string\n type: \"image\" | \"video\" | \"audio\" | \"text\"\n required: boolean\n mediaPreview?: boolean\n fieldKey: string\n}\n\nexport interface ExposedSetting {\n nodeId: string\n field: string\n label: string\n type: \"select\" | \"text\" | \"number\" | \"toggle\" | \"aspect-ratio\"\n allowedValues?: unknown[]\n /** Full option list with labels for select fields (preferred over allowedValues). */\n options?: Array<{ value: string; label: string }>\n defaultValue: unknown\n /**\n * Set when the setting is one of the node's quick settings (the editor's bottom-bar levers): the node type,\n * so the consuming workflow can render the same control, and the node's own lever values its choices depend\n * on (its model, Draft, …), so the control offers what that model takes. Never prompts or results.\n */\n quick?: {\n nodeType: string\n context?: Record<string, string | number | boolean>\n }\n}\n\nexport interface ComponentMetadata {\n inputs: ComponentHandle[]\n outputs: ComponentHandle[]\n exposedSettings: ExposedSetting[]\n}\n\n/** Maps input node types to their data field key for inputOverrides (derived from presentation-utils) */\nexport const INPUT_FIELD_MAP: Record<string, string> = Object.fromEntries(\n Object.entries(PRESENTATION_INPUT_MAP).map(([k, v]) => [k, v.key]),\n)\n\n/** Separator used in component handle ids that target a specific port on a sub-workflow-input / sub-workflow-output node. */\nexport const HANDLE_PORT_SEPARATOR = \"::\"\n\n/**\n * Split a component handle id of the form `nodeId` or `nodeId::portId`.\n * Returns the literal nodeId when no separator is present.\n */\nexport function parseHandleId(handleId: string): { nodeId: string; portId?: string } {\n const sep = handleId.indexOf(HANDLE_PORT_SEPARATOR)\n if (sep < 0) return { nodeId: handleId }\n const portId = handleId.slice(sep + HANDLE_PORT_SEPARATOR.length)\n return { nodeId: handleId.slice(0, sep), portId: portId || undefined }\n}\n\n/**\n * Apply a value for a component input handle to the inputOverrides map.\n *\n * - Plain handles (id = nodeId) write to `inputOverrides[nodeId][fieldKey]`,\n * which the orchestrator shallow-merges into `node.data` at execution.\n * - Compound handles (id = nodeId::portId) write into\n * `inputOverrides[nodeId].__injectedPortValues[portId]`, the slot that\n * sub-workflow-input nodes read at runtime via output-extractor.\n *\n * Mutates the map in place so multi-port accumulation merges correctly when\n * iterating handles in a loop.\n */\nexport function applyHandleInputOverride(\n inputOverrides: Record<string, Record<string, unknown>>,\n handle: { id: string; fieldKey: string },\n value: unknown,\n): void {\n const { nodeId, portId } = parseHandleId(handle.id)\n if (portId) {\n const existing = (inputOverrides[nodeId]?.__injectedPortValues as Record<string, unknown> | undefined) ?? {}\n inputOverrides[nodeId] = {\n ...inputOverrides[nodeId],\n __injectedPortValues: { ...existing, [portId]: value },\n }\n } else {\n inputOverrides[nodeId] = { ...inputOverrides[nodeId], [handle.fieldKey]: value }\n }\n}\n\n/**\n * Has a value already been recorded for this handle in the inputOverrides map?\n * Used to skip fallback wiring when an upstream connection already supplied\n * the input.\n */\nexport function isHandleInputWired(\n inputOverrides: Record<string, Record<string, unknown>>,\n handle: { id: string; fieldKey: string },\n): boolean {\n const { nodeId, portId } = parseHandleId(handle.id)\n if (portId) {\n const injected = inputOverrides[nodeId]?.__injectedPortValues as Record<string, unknown> | undefined\n return injected?.[portId] !== undefined\n }\n return inputOverrides[nodeId]?.[handle.fieldKey] !== undefined\n}\n\n/** Maps output media types to NodeOutput field keys */\nexport const OUTPUT_FIELD_MAP: Record<string, string> = {\n image: \"imageUrl\",\n video: \"videoUrl\",\n audio: \"audioUrl\",\n text: \"text\",\n}\n\n/**\n * Merge exposed settings into inputOverrides format.\n * exposedSettings is keyed by \"nodeId:field\" -> value on the component node data.\n *\n * Connected inputs (already present in inputOverrides) always take priority\n * over exposed settings for the same node+field combination. This ensures\n * that mandatory upstream wires are never silently overwritten by stale\n * default / user-configured exposed-setting values.\n */\nexport function mergeExposedSettings(\n inputOverrides: Record<string, Record<string, unknown>>,\n exposedSettings: Record<string, unknown>,\n metadata: ComponentMetadata,\n): Record<string, Record<string, unknown>> {\n const merged = { ...inputOverrides }\n for (const setting of metadata.exposedSettings) {\n const key = `${setting.nodeId}:${setting.field}`\n const value = exposedSettings[key]\n if (value !== undefined) {\n // Skip if a connected input already provided this field\n if (merged[setting.nodeId]?.[setting.field] !== undefined) continue\n merged[setting.nodeId] = { ...merged[setting.nodeId], [setting.field]: value }\n }\n }\n return merged\n}\n","/**\n * The OAuth scopes a Nodaro token can carry — part of the public API contract\n * (published in the authorization server's `scopes_supported`, requested by\n * developer apps, typed in `@nodaro/sdk`). The server validates against this\n * list and the SDK types against it, so the two cannot drift.\n *\n * A scope in this list is published and handed to any Dynamic Client\n * Registration client that asks for everything, so add one in the same change\n * that makes something check it (see backend/src/lib/scopes.ts).\n */\nexport const OAUTH_SCOPES = [\n \"workflows:read\",\n \"workflows:write\",\n \"workflows:execute\",\n \"jobs:read\",\n \"assets:read\",\n \"assets:write\",\n \"credits:read\",\n \"apps:read\",\n \"pipelines:read\",\n \"pipelines:execute\",\n \"pipelines:approve\",\n \"presets:read\",\n \"workspaces:read\",\n \"workspaces:write\",\n] as const\n\nexport type OAuthScope = (typeof OAUTH_SCOPES)[number]\n","/**\n * How a recast render packs scenes into parts — the values `segmentSec` takes\n * on `POST /v1/recast`, `/v1/recast/estimate` and `/v1/recast/:id/start`. A\n * name, not seconds, despite the field's name:\n *\n * - `\"scenes-max\"` (Long): whole scenes grouped into as few parts as fit, the\n * fewest seams.\n * - `\"scenes\"` (Short): whole scenes in shorter parts.\n * - `\"max\"`: the longest parts the model allows, not grouped by scene.\n */\nexport const RECAST_SEGMENT_PACKS = [\"max\", \"scenes-max\", \"scenes\"] as const\n\nexport type RecastSegmentPack = (typeof RECAST_SEGMENT_PACKS)[number]\n","/**\n * The use cases a marketplace template is filed under — exactly one each.\n * Shared by the publish/browse routes (the `category` enum), the Templates\n * page (tiles, URL filter, labels) and the publish dialog, so the list can\n * only change in one place. Labels live with the frontend's i18n\n * (`lib/template-categories.ts`), keyed by these values.\n */\nexport const TEMPLATE_CATEGORIES = [\n \"product-imagery\",\n \"static-ads\",\n \"user-generated-content\",\n \"video-ads\",\n \"brand-assets\",\n \"automations\",\n \"campaign-concepts\",\n \"social-creatives\",\n // Workflows an AI agent built through the MCP server, kept whole so every step can be opened and changed.\n \"mcp\",\n] as const\n\nexport type TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number]\n\n/** Where a template with no usable category is filed: the plain \"it is a workflow\" bucket. */\nexport const DEFAULT_TEMPLATE_CATEGORY: TemplateCategory = \"automations\"\n\n/**\n * The categories templates were filed under before September 2026, each\n * read as its new home. Migration 423 rewrites the rows with the same map;\n * this keeps an old link (`?category=video-production`), a cached card and a\n * row the migration has not reached yet resolving in the meantime.\n */\nexport const LEGACY_TEMPLATE_CATEGORIES: Readonly<Record<string, TemplateCategory>> = {\n \"image-generation\": \"product-imagery\",\n \"video-production\": \"video-ads\",\n \"audio-music\": \"social-creatives\",\n \"content-writing\": \"campaign-concepts\",\n \"social-media\": \"social-creatives\",\n \"data-processing\": \"automations\",\n \"multi-step\": \"automations\",\n other: \"automations\",\n}\n\nconst CURRENT = new Set<string>(TEMPLATE_CATEGORIES)\n\nexport function isTemplateCategory(value: unknown): value is TemplateCategory {\n return typeof value === \"string\" && CURRENT.has(value)\n}\n\n/** A current category as is, a legacy one as its new home, anything else as undefined. */\nexport function resolveTemplateCategory(value: string | null | undefined): TemplateCategory | undefined {\n if (value == null) return undefined\n if (isTemplateCategory(value)) return value\n return LEGACY_TEMPLATE_CATEGORIES[value]\n}\n\n/** The category a stored row reads as: resolved, else the default bucket. */\nexport function normalizeTemplateCategory(value: string | null | undefined): TemplateCategory {\n return resolveTemplateCategory(value) ?? DEFAULT_TEMPLATE_CATEGORY\n}\n\n/**\n * Every stored value that reads as `category` — the value itself and the\n * legacy ones that map to it — so a database filter matches rows the\n * migration has not rewritten yet.\n */\nexport function templateCategoryStoredValues(category: TemplateCategory): string[] {\n const legacy = Object.keys(LEGACY_TEMPLATE_CATEGORIES).filter((value) => LEGACY_TEMPLATE_CATEGORIES[value] === category)\n return [category, ...legacy]\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/picker-restrictions.ts","../src/component-types.ts","../src/oauth-scopes.ts","../src/recast-segment-packs.ts","../src/template-categories.ts"],"names":["INPUT_FIELD_MAP","canonicalExposedFieldKey"],"mappings":";;;;;AAYA,IAAM,QAAA,GAAW,CAAC,CAAA,KAAA,CACf,KAAA,CAAM,QAAQ,CAAC,CAAA,GAAI,CAAA,GAAI,CAAC,CAAC,CAAA,EAAG,OAAO,CAAC,CAAA,KAAM,MAAM,MAAA,IAAa,CAAA,KAAM,QAAQ,CAAA,KAAM,EAAE,CAAA,CAAE,GAAA,CAAI,MAAM,CAAA;AAS3F,SAAS,0BAA0B,KAAA,EAIxB;AAChB,EAAA,IAAI,CAAC,KAAA,CAAM,QAAA,IAAY,CAAC,KAAA,CAAM,aAAa,OAAO,IAAA;AAClD,EAAA,KAAA,MAAW,IAAA,IAAQ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,0BAA0B,KAAA,EAAoD;AAC5F,EAAA,OAAO,uBAAA,CAAwB,KAAK,CAAA,IAAK,yBAAA;AAC3C;AAOO,SAAS,6BAA6B,QAAA,EAAsC;AACjF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,IAAA,CAAK,0BAA0B,CAAA,CAAE,MAAA,CAAO,CAAC,KAAA,KAAU,0BAAA,CAA2B,KAAK,CAAA,KAAM,QAAQ,CAAA;AACvH,EAAA,OAAO,CAAC,QAAA,EAAU,GAAG,MAAM,CAAA;AAC7B","file":"chunk-77WU3V3J.cjs","sourcesContent":["import { canonicalExposedFieldKey } from \"./exposed-field-keys.js\"\nimport { INPUT_FIELD_MAP } from \"./presentation-utils.js\"\n\n/** What an app's picker card may restrict (stored in `presentationSettings.cardMeta[nodeId]`). */\nexport interface PickerCardRestrictions {\n readonly pickerAllowedValues?: readonly string[]\n readonly pickerAllowedValuesByField?: Readonly<Record<string, readonly string[]>>\n}\n\n// Every submitted value is checked, whatever its type — a number or object where a\n// catalog id belongs must be refused, not skipped. An unset / cleared pick (\"\" , null)\n// is no selection and passes (the node falls back to its default).\nconst valuesOf = (v: unknown): string[] =>\n (Array.isArray(v) ? v : [v]).filter((x) => x !== undefined && x !== null && x !== \"\").map(String)\n\n/**\n * The first submitted picker value an app's card restrictions forbid, as the\n * runner's 400 text; null when all pass. Runs on every app run — `run_app`,\n * the SDK and a hand-built body included — so a restriction is never UI-only.\n * A submitted key is read through `canonicalExposedFieldKey`, so a legacy\n * spelling cannot slip past a restriction written against the current field.\n */\nexport function findRestrictedPickerValue(input: {\n readonly cardMeta: Readonly<Record<string, PickerCardRestrictions | undefined>> | undefined\n readonly nodes: ReadonlyArray<{ readonly id: string; readonly type?: string }>\n readonly inputValues: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined\n}): string | null {\n if (!input.cardMeta || !input.inputValues) return null\n for (const node of input.nodes) {\n const meta = input.cardMeta[node.id]\n const submitted = input.inputValues[node.id]\n if (!meta || !submitted) continue\n const rules: Array<[string, readonly string[]]> = []\n const rep = node.type ? INPUT_FIELD_MAP[node.type]?.key : undefined\n if (rep && meta.pickerAllowedValues && meta.pickerAllowedValues.length > 0) rules.push([rep, meta.pickerAllowedValues])\n for (const [field, allowed] of Object.entries(meta.pickerAllowedValuesByField ?? {})) {\n if (allowed.length > 0) rules.push([field, allowed])\n }\n for (const [field, allowed] of rules) {\n for (const [key, raw] of Object.entries(submitted)) {\n if (canonicalExposedFieldKey(node.type, key) !== field) continue\n for (const value of valuesOf(raw)) {\n if (!allowed.includes(value)) return `Invalid value for ${field}: ${value}. Allowed: ${allowed.join(\", \")}`\n }\n }\n }\n }\n return null\n}\n","import { INPUT_FIELD_MAP as PRESENTATION_INPUT_MAP } from \"./presentation-utils.js\"\n\nexport interface ComponentHandle {\n id: string\n name: string\n type: \"image\" | \"video\" | \"audio\" | \"text\"\n required: boolean\n mediaPreview?: boolean\n fieldKey: string\n}\n\nexport interface ExposedSetting {\n nodeId: string\n field: string\n label: string\n type: \"select\" | \"text\" | \"number\" | \"toggle\" | \"aspect-ratio\"\n allowedValues?: unknown[]\n /** Full option list with labels for select fields (preferred over allowedValues). */\n options?: Array<{ value: string; label: string }>\n defaultValue: unknown\n /**\n * Set when the setting is one of the node's quick settings (the editor's bottom-bar levers): the node type,\n * so the consuming workflow can render the same control, and the node's own lever values its choices depend\n * on (its model, Draft, …), so the control offers what that model takes. Never prompts or results.\n */\n quick?: {\n nodeType: string\n context?: Record<string, string | number | boolean>\n }\n}\n\nexport interface ComponentMetadata {\n inputs: ComponentHandle[]\n outputs: ComponentHandle[]\n exposedSettings: ExposedSetting[]\n}\n\n/** Maps input node types to their data field key for inputOverrides (derived from presentation-utils) */\nexport const INPUT_FIELD_MAP: Record<string, string> = Object.fromEntries(\n Object.entries(PRESENTATION_INPUT_MAP).map(([k, v]) => [k, v.key]),\n)\n\n/** Separator used in component handle ids that target a specific port on a sub-workflow-input / sub-workflow-output node. */\nexport const HANDLE_PORT_SEPARATOR = \"::\"\n\n/**\n * Split a component handle id of the form `nodeId` or `nodeId::portId`.\n * Returns the literal nodeId when no separator is present.\n */\nexport function parseHandleId(handleId: string): { nodeId: string; portId?: string } {\n const sep = handleId.indexOf(HANDLE_PORT_SEPARATOR)\n if (sep < 0) return { nodeId: handleId }\n const portId = handleId.slice(sep + HANDLE_PORT_SEPARATOR.length)\n return { nodeId: handleId.slice(0, sep), portId: portId || undefined }\n}\n\n/**\n * Apply a value for a component input handle to the inputOverrides map.\n *\n * - Plain handles (id = nodeId) write to `inputOverrides[nodeId][fieldKey]`,\n * which the orchestrator shallow-merges into `node.data` at execution.\n * - Compound handles (id = nodeId::portId) write into\n * `inputOverrides[nodeId].__injectedPortValues[portId]`, the slot that\n * sub-workflow-input nodes read at runtime via output-extractor.\n *\n * Mutates the map in place so multi-port accumulation merges correctly when\n * iterating handles in a loop.\n */\nexport function applyHandleInputOverride(\n inputOverrides: Record<string, Record<string, unknown>>,\n handle: { id: string; fieldKey: string },\n value: unknown,\n): void {\n const { nodeId, portId } = parseHandleId(handle.id)\n if (portId) {\n const existing = (inputOverrides[nodeId]?.__injectedPortValues as Record<string, unknown> | undefined) ?? {}\n inputOverrides[nodeId] = {\n ...inputOverrides[nodeId],\n __injectedPortValues: { ...existing, [portId]: value },\n }\n } else {\n inputOverrides[nodeId] = { ...inputOverrides[nodeId], [handle.fieldKey]: value }\n }\n}\n\n/**\n * Has a value already been recorded for this handle in the inputOverrides map?\n * Used to skip fallback wiring when an upstream connection already supplied\n * the input.\n */\nexport function isHandleInputWired(\n inputOverrides: Record<string, Record<string, unknown>>,\n handle: { id: string; fieldKey: string },\n): boolean {\n const { nodeId, portId } = parseHandleId(handle.id)\n if (portId) {\n const injected = inputOverrides[nodeId]?.__injectedPortValues as Record<string, unknown> | undefined\n return injected?.[portId] !== undefined\n }\n return inputOverrides[nodeId]?.[handle.fieldKey] !== undefined\n}\n\n/** Maps output media types to NodeOutput field keys */\nexport const OUTPUT_FIELD_MAP: Record<string, string> = {\n image: \"imageUrl\",\n video: \"videoUrl\",\n audio: \"audioUrl\",\n text: \"text\",\n}\n\n/**\n * Merge exposed settings into inputOverrides format.\n * exposedSettings is keyed by \"nodeId:field\" -> value on the component node data.\n *\n * Connected inputs (already present in inputOverrides) always take priority\n * over exposed settings for the same node+field combination. This ensures\n * that mandatory upstream wires are never silently overwritten by stale\n * default / user-configured exposed-setting values.\n */\nexport function mergeExposedSettings(\n inputOverrides: Record<string, Record<string, unknown>>,\n exposedSettings: Record<string, unknown>,\n metadata: ComponentMetadata,\n): Record<string, Record<string, unknown>> {\n const merged = { ...inputOverrides }\n for (const setting of metadata.exposedSettings) {\n const key = `${setting.nodeId}:${setting.field}`\n const value = exposedSettings[key]\n if (value !== undefined) {\n // Skip if a connected input already provided this field\n if (merged[setting.nodeId]?.[setting.field] !== undefined) continue\n merged[setting.nodeId] = { ...merged[setting.nodeId], [setting.field]: value }\n }\n }\n return merged\n}\n","/**\n * The OAuth scopes a Nodaro token can carry — part of the public API contract\n * (published in the authorization server's `scopes_supported`, requested by\n * developer apps, typed in `@nodaro/sdk`). The server validates against this\n * list and the SDK types against it, so the two cannot drift.\n *\n * A scope in this list is published and handed to any Dynamic Client\n * Registration client that asks for everything, so add one in the same change\n * that makes something check it (see backend/src/lib/scopes.ts).\n */\nexport const OAUTH_SCOPES = [\n \"workflows:read\",\n \"workflows:write\",\n \"workflows:execute\",\n \"jobs:read\",\n \"assets:read\",\n \"assets:write\",\n \"credits:read\",\n \"apps:read\",\n \"pipelines:read\",\n \"pipelines:execute\",\n \"pipelines:approve\",\n \"presets:read\",\n \"workspaces:read\",\n \"workspaces:write\",\n] as const\n\nexport type OAuthScope = (typeof OAUTH_SCOPES)[number]\n","/**\n * How a recast render packs scenes into parts — the values `segmentSec` takes\n * on `POST /v1/recast`, `/v1/recast/estimate` and `/v1/recast/:id/start`. A\n * name, not seconds, despite the field's name:\n *\n * - `\"scenes-max\"` (Long): whole scenes grouped into as few parts as fit, the\n * fewest seams.\n * - `\"scenes\"` (Short): whole scenes in shorter parts.\n * - `\"max\"`: the longest parts the model allows, not grouped by scene.\n */\nexport const RECAST_SEGMENT_PACKS = [\"max\", \"scenes-max\", \"scenes\"] as const\n\nexport type RecastSegmentPack = (typeof RECAST_SEGMENT_PACKS)[number]\n","/**\n * The use cases a marketplace template is filed under — exactly one each.\n * Shared by the publish/browse routes (the `category` enum), the Templates\n * page (tiles, URL filter, labels) and the publish dialog, so the list can\n * only change in one place. Labels live with the frontend's i18n\n * (`lib/template-categories.ts`), keyed by these values.\n */\nexport const TEMPLATE_CATEGORIES = [\n \"product-imagery\",\n \"static-ads\",\n \"user-generated-content\",\n \"video-ads\",\n \"brand-assets\",\n \"automations\",\n \"campaign-concepts\",\n \"social-creatives\",\n // Workflows an AI agent built through the MCP server, kept whole so every step can be opened and changed.\n \"mcp\",\n] as const\n\nexport type TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number]\n\n/** Where a template with no usable category is filed: the plain \"it is a workflow\" bucket. */\nexport const DEFAULT_TEMPLATE_CATEGORY: TemplateCategory = \"automations\"\n\n/**\n * The categories templates were filed under before September 2026, each\n * read as its new home. Migration 423 rewrites the rows with the same map;\n * this keeps an old link (`?category=video-production`), a cached card and a\n * row the migration has not reached yet resolving in the meantime.\n */\nexport const LEGACY_TEMPLATE_CATEGORIES: Readonly<Record<string, TemplateCategory>> = {\n \"image-generation\": \"product-imagery\",\n \"video-production\": \"video-ads\",\n \"audio-music\": \"social-creatives\",\n \"content-writing\": \"campaign-concepts\",\n \"social-media\": \"social-creatives\",\n \"data-processing\": \"automations\",\n \"multi-step\": \"automations\",\n other: \"automations\",\n}\n\nconst CURRENT = new Set<string>(TEMPLATE_CATEGORIES)\n\nexport function isTemplateCategory(value: unknown): value is TemplateCategory {\n return typeof value === \"string\" && CURRENT.has(value)\n}\n\n/** A current category as is, a legacy one as its new home, anything else as undefined. */\nexport function resolveTemplateCategory(value: string | null | undefined): TemplateCategory | undefined {\n if (value == null) return undefined\n if (isTemplateCategory(value)) return value\n return LEGACY_TEMPLATE_CATEGORIES[value]\n}\n\n/** The category a stored row reads as: resolved, else the default bucket. */\nexport function normalizeTemplateCategory(value: string | null | undefined): TemplateCategory {\n return resolveTemplateCategory(value) ?? DEFAULT_TEMPLATE_CATEGORY\n}\n\n/**\n * Every stored value that reads as `category` — the value itself and the\n * legacy ones that map to it — so a database filter matches rows the\n * migration has not rewritten yet.\n */\nexport function templateCategoryStoredValues(category: TemplateCategory): string[] {\n const legacy = Object.keys(LEGACY_TEMPLATE_CATEGORIES).filter((value) => LEGACY_TEMPLATE_CATEGORIES[value] === category)\n return [category, ...legacy]\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UGC_NEWER_APP_MESSAGE, ugcPlanLengthSec, UGC_SCRIPT_LANGUAGES, ugcPlanScreenshotCount, UGC_OVER_HOLD_MESSAGE, UGC_FINISH_NEEDS_CLIPS_MESSAGE, readUgcWire, UGC_NODE_MESSAGES, UGC_FINISH_NOT_READY_MESSAGE, UGC_NEEDS_FINISH_MESSAGE } from './chunk-
|
|
1
|
+
import { UGC_NEWER_APP_MESSAGE, ugcPlanLengthSec, UGC_SCRIPT_LANGUAGES, ugcPlanScreenshotCount, UGC_OVER_HOLD_MESSAGE, UGC_FINISH_NEEDS_CLIPS_MESSAGE, readUgcWire, UGC_NODE_MESSAGES, UGC_FINISH_NOT_READY_MESSAGE, UGC_NEEDS_FINISH_MESSAGE } from './chunk-MD4XHED4.js';
|
|
2
2
|
|
|
3
3
|
// src/ugc-call-body.ts
|
|
4
4
|
var pick = (a, from, to) => a[from] !== void 0 && a[from] !== null ? { [to]: a[from] } : {};
|
|
@@ -177,5 +177,5 @@ function ugcLaneNeedsFinish(edges, nodes, clipsId) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
export { UGC_FINISH_CLIPS_TYPE, UGC_PRELUDE_ROUTES, UGC_PRELUDE_STEPS, ugcCallToRouteBody, ugcClipsPhase, ugcClipsPhase2Body, ugcFinishOutputs, ugcFinishPlan, ugcFinishWired, ugcLaneNeedsFinish, ugcPrelude, ugcPreludeOutput, ugcRenderHoldBody, ugcRenderHoldVerdict, ugcRunEstimateInput };
|
|
180
|
-
//# sourceMappingURL=chunk-
|
|
181
|
-
//# sourceMappingURL=chunk-
|
|
180
|
+
//# sourceMappingURL=chunk-AE3AAJ4O.js.map
|
|
181
|
+
//# sourceMappingURL=chunk-AE3AAJ4O.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ugc-call-body.ts","../src/ugc-lane-wires.ts"],"names":["pick"],"mappings":";;;AAkBA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAsC,IAAA,EAAc,OAChE,CAAA,CAAE,IAAI,MAAM,MAAA,IAAa,CAAA,CAAE,IAAI,CAAA,KAAM,IAAA,GAAO,EAAE,CAAC,EAAE,GAAG,CAAA,CAAE,IAAI,CAAA,EAAE,GAAI,EAAC;AAGnE,SAAS,UAAU,CAAA,EAA+D;AAChF,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,CAAA,EAAG,UAAA,EAAY,UAAU,CAAA;AAAA,IACjC,GAAG,IAAA,CAAK,CAAA,EAAG,kBAAA,EAAoB,iBAAiB,CAAA;AAAA,IAChD,GAAI,EAAE,aAAA,KAAkB,IAAA,GAAO,EAAE,YAAA,EAAc,IAAA,KAAS,EAAC;AAAA,IACzD,GAAG,IAAA,CAAK,CAAA,EAAG,aAAA,EAAe,aAAa,CAAA;AAAA,IACvC,GAAG,IAAA,CAAK,CAAA,EAAG,YAAA,EAAc,WAAW;AAAA,GACtC;AACF;AAEO,SAAS,kBAAA,CACd,IAAA,EACA,IAAA,GAAoC,EAAC,EACkB;AACvD,EAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,CAAK,IAAA,EAAK;AACrD,EAAA,IAAI,KAAK,QAAA,EAAU;AACjB,IAAA,IAAI,CAAC,KAAK,KAAA,EAAO,OAAO,EAAE,K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,GAAO,wBAAA;AACxD","file":"chunk-C7POAYFE.js","sourcesContent":["/**\n * A UGC builder call `{ tool, args }` (MCP argument names) → the REST body of\n * the public route that tool dispatches to. The builder sets every price lever;\n * this adds none — its one addition is the image of a call that needs the\n * previous step's image (`imageArg`, or the photo of `image_to_text`). A tool\n * it does not know → undefined, so an app older than the builder fails plainly\n * instead of guessing. Kept equal to the MCP verbs by ugc-call-body-parity.test.ts.\n */\nexport interface UgcToolCall {\n readonly tool: string\n readonly args: Readonly<Record<string, unknown>>\n readonly imageArg?: string\n}\nexport type UgcRouteBody = {\n readonly path: \"/v1/generate-image\" | \"/v1/image-to-image\" | \"/v1/image-to-text/describe\"\n readonly body: Record<string, unknown>\n}\n\nconst pick = (a: Readonly<Record<string, unknown>>, from: string, to: string): Record<string, unknown> =>\n a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {}\n\n/** The LLM levers image_to_text forwards (the verb's llmPayloadFields). */\nfunction llmFields(a: Readonly<Record<string, unknown>>): Record<string, unknown> {\n return {\n ...pick(a, \"llmModel\", \"llmModel\"),\n ...pick(a, \"reasoning_effort\", \"reasoningEffort\"),\n ...(a.advanced_mode === true ? { advancedMode: true } : {}),\n ...pick(a, \"temperature\", \"temperature\"),\n ...pick(a, \"max_tokens\", \"maxTokens\"),\n }\n}\n\nexport function ugcCallToRouteBody(\n call: UgcToolCall,\n opts: { readonly image?: string } = {},\n): UgcRouteBody | { readonly error: string } | undefined {\n const args: Record<string, unknown> = { ...call.args }\n if (call.imageArg) {\n if (!opts.image) return { error: `${call.tool} needs the previous step's image` }\n args[call.imageArg] = opts.image\n }\n switch (call.tool) {\n case \"generate_image\":\n return {\n path: \"/v1/generate-image\",\n body: {\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n },\n }\n case \"image_to_image\":\n return {\n path: \"/v1/image-to-image\",\n body: {\n ...pick(args, \"image_url\", \"imageUrl\"),\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"strength\", \"strength\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n ...pick(args, \"seed\", \"seed\"),\n },\n }\n case \"image_to_text\": {\n const image = opts.image ?? (typeof args.image_url === \"string\" ? args.image_url : undefined)\n if (!image) return { error: \"image_to_text needs an image\" }\n return {\n path: \"/v1/image-to-text/describe\",\n body: {\n imageUrl: image,\n ...pick(args, \"detail_level\", \"detailLevel\"),\n ...pick(args, \"custom_prompt\", \"customPrompt\"),\n ...llmFields(args),\n },\n }\n }\n default:\n return undefined\n }\n}\n","/**\n * The UGC wires of a language whose clips are cut from one recorded speech (the\n * segmented lane): UGC Clips' prelude (record the speech, time its words, split\n * it at its pauses, then ask for the clips again with the segments) and UGC\n * Finish (lay the speech back over the rendered clips and trim the dead air,\n * as one job over all of them). One pure implementation both engines call, as\n * the rest of the UGC wires (`ugc-node-wires.ts`).\n *\n * Content-free: an answer is read only for `phase`, its three calls' `tool`\n * and `args` (argument names, never their meaning), the `finish` call's\n * `args`, and a finished job's clip list. Which language takes this lane, which\n * voice speaks and what the calls say are the builder's.\n */\nimport {\n UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n UGC_FINISH_NOT_READY_MESSAGE,\n UGC_NEEDS_FINISH_MESSAGE,\n UGC_NEWER_APP_MESSAGE,\n UGC_NODE_MESSAGES,\n UGC_OVER_HOLD_MESSAGE,\n UGC_SCRIPT_LANGUAGES,\n readUgcWire,\n ugcPlanLengthSec,\n ugcPlanScreenshotCount,\n} from \"./ugc-node-wires.js\"\nimport type { FanOutItemMeta } from \"./fan-out-meta.js\"\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/** UGC Finish's node type. Not the plugin job it runs (`ugc-finish`): a price, a dispatch or a reconcile keyed on a type never confuses the two. */\nexport const UGC_FINISH_CLIPS_TYPE = \"ugc-finish-clips\"\n\n/** The child steps of UGC Clips' prelude, in run order: each is a job of its own, keyed by its step. */\nexport const UGC_PRELUDE_STEPS = [\"speech\", \"alignment\", \"split\"] as const\nexport type UgcPreludeStep = (typeof UGC_PRELUDE_STEPS)[number]\n\n/** The public route each prelude step runs on, and the node type its job is read as. */\nexport const UGC_PRELUDE_ROUTES: Readonly<Record<UgcPreludeStep, { readonly path: string; readonly jobType: string }>> = {\n speech: { path: \"/v1/text-to-speech\", jobType: \"text-to-speech\" },\n alignment: { path: \"/v1/forced-alignment\", jobType: \"forced-alignment\" },\n split: { path: \"/v1/ugc/segments\", jobType: \"ugc-segments\" },\n}\n\n/** The `/v1/ugc/clips` answer's phase: 1 = the prelude must run first, 2 = the clips; null = an answer with no phase (one call, as English). */\nexport function ugcClipsPhase(answer: Readonly<Obj>): 1 | 2 | null {\n return answer.phase === 1 ? 1 : answer.phase === 2 ? 2 : null\n}\n\nconst callOf = (raw: unknown, tool: string): Obj | undefined => {\n if (!isObject(raw) || raw.tool !== tool || !isObject(raw.args)) return undefined\n return raw.args\n}\nconst pick = (a: Readonly<Obj>, from: string, to: string): Obj => (a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {})\n\n/** What the prelude runs: the speech's route body, and the two that need the step before them. */\nexport interface UgcPrelude {\n readonly speech: Obj\n readonly alignment: (audioUrl: string) => Obj\n readonly split: (audioUrl: string, alignment: unknown) => Obj\n}\n\n/**\n * A phase-1 answer's three calls (`speech`, `align`, `split`, MCP argument names) → the REST bodies of\n * the public routes their MCP tools dispatch to: `generate_speech` → `/v1/text-to-speech` (text, voice,\n * voice type, model as provider, language code, as the verb maps them), `forced_alignment` →\n * `/v1/forced-alignment` (the transcript, with the speech's audio), `ugc_split_speech` →\n * `/v1/ugc/segments` (the plan, with the speech's audio and its word timings). A call that is missing\n * or names another tool → the newer-app sentence: the app never guesses.\n */\nexport function ugcPrelude(answer: Readonly<Obj>): UgcPrelude | { readonly error: string } {\n const speech = callOf(answer.speech, \"generate_speech\")\n const align = callOf(answer.align, \"forced_alignment\")\n const split = callOf(answer.split, \"ugc_split_speech\")\n if (!speech || !align || !split || typeof speech.text !== \"string\" || !isObject(split.plan)) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n speech: {\n text: speech.text,\n ...pick(speech, \"voice_id\", \"voice\"),\n ...pick(speech, \"voice_type\", \"voiceType\"),\n ...pick(speech, \"model\", \"provider\"),\n ...pick(speech, \"language_code\", \"languageCode\"),\n },\n alignment: (audioUrl) => ({ ...pick(align, \"transcript\", \"transcript\"), audioUrl }),\n split: (audioUrl, alignment) => ({ plan: split.plan, audioUrl, alignment }),\n }\n}\n\n/** The finished speech job's audio, its word timings and its segments, as their jobs write them. */\nexport function ugcPreludeOutput(step: UgcPreludeStep, output: Readonly<Obj> | undefined): { value: unknown } | { error: string } {\n const value = step === \"speech\" ? output?.audioUrl : step === \"alignment\" ? output?.alignment : output?.segments\n const ok = step === \"speech\" ? typeof value === \"string\" && value !== \"\" : Array.isArray(value) && value.length > 0\n return ok ? { value } : { error: UGC_NEWER_APP_MESSAGE }\n}\n\n/** The second `/v1/ugc/clips` call: the first call's body with the segments the split returned. */\nexport function ugcClipsPhase2Body(body: Readonly<Obj>, segments: readonly unknown[]): Obj {\n return { ...body, segments: [...segments] }\n}\n\n// ── The hold check once the speech is split ──────────────────────────────────\n\n/** The estimate input of a video cut from one recorded speech, as the hold check names it (`runEstimate`). */\nexport interface UgcRunEstimateInput {\n readonly targetDurationSec: number\n readonly screenshotCount: number\n readonly source: \"sampled\"\n readonly language: string\n}\n\n/**\n * The estimate input of the video a UGC Clips run belongs to, read from the plan the node was sent: its\n * length, its screenshot cards and its language — the reading a kept plan is priced with. Read on a\n * phase-1 answer, before the prelude spends anything, so a plan the check cannot read refuses the run\n * while nothing is paid. The creator's source prices no clip, so it is not read. A plan without a length,\n * or without a language this lane takes → the newer-app sentence: the check never guesses.\n */\nexport function ugcRunEstimateInput(plan: unknown): { runEstimate: UgcRunEstimateInput } | { error: string } {\n const targetDurationSec = ugcPlanLengthSec(plan)\n const language = planOf(plan)?.language\n if (targetDurationSec === undefined || typeof language !== \"string\" || language === \"en\" || !(UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(language)) {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n return { runEstimate: { targetDurationSec, screenshotCount: ugcPlanScreenshotCount(plan) ?? 0, source: \"sampled\", language } }\n}\n\n/**\n * The quote that checks a video cut from one recorded speech before any of its clips renders: the clips\n * the second `/v1/ugc/clips` call handed on, priced as the UGC Clips quote prices them (`tickets`,\n * `hasCards`, `finishes`), with `runEstimate` (`ugcRunEstimateInput`). The route then also answers\n * `runHold`, the most the video's estimate holds for the clips and the steps after them, which the run's\n * balance was checked against before it started (`ugcRenderHoldVerdict`). No clips → the newer-app sentence.\n */\nexport function ugcRenderHoldBody(input: { runEstimate: UgcRunEstimateInput; tickets: unknown; hasCards: boolean; finishes: boolean }): { path: \"/v1/ugc/quote\"; body: Obj } | { error: string } {\n if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n path: \"/v1/ugc/quote\",\n body: {\n tickets: [...input.tickets],\n hasCards: input.hasCards,\n ...(input.finishes ? { finishes: true } : {}),\n runEstimate: { ...input.runEstimate },\n },\n }\n}\n\n/** A plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction planOf(plan: unknown): Obj | undefined {\n if (typeof plan !== \"string\") return isObject(plan) ? plan : undefined\n try {\n const parsed: unknown = JSON.parse(plan)\n return isObject(parsed) ? parsed : undefined\n } catch {\n return undefined\n }\n}\n\nconst isCredits = (x: unknown): x is number => typeof x === \"number\" && Number.isFinite(x) && x >= 0\n\n/**\n * The hold check's answer → go on, or stop before any clip renders: the clips and the steps after them\n * (`ceiling`, each clip at its hold) over what the run was checked for (`runHold`) → the over-hold\n * sentence. An answer without both figures stops too (the newer-app sentence): a clip never renders\n * on a figure nobody checked.\n */\nexport function ugcRenderHoldVerdict(answer: unknown): { readonly ok: true } | { readonly error: string } {\n if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: UGC_NEWER_APP_MESSAGE }\n return answer.ceiling > answer.runHold ? { error: UGC_OVER_HOLD_MESSAGE } : { ok: true }\n}\n\n// ── UGC Finish ───────────────────────────────────────────────────────────────\n\n/** What UGC Finish does with the clips it was handed. */\nexport type UgcFinishPlan =\n /** No finish call on the plan (English): the clips go on as they came, no call, no job. */\n | { readonly kind: \"pass\"; readonly clips: readonly string[] }\n /** The finish job's body: the segments with their room, one roll per clip, in order. */\n | { readonly kind: \"job\"; readonly path: \"/v1/ugc/finish\"; readonly body: Obj }\n\n/**\n * UGC Finish's input → what it does. The `plan` input is UGC Clips' Script (sized) output; a plan\n * carrying `finish` (the segmented lane) asks for the finish job over the clips, in order; any other\n * plan passes the clips through. Clips are the fan-in list (`inputs.inputs`), in clip order.\n */\nexport function ugcFinishPlan(input: { planOutWire: unknown; clipUrls: readonly unknown[] }): UgcFinishPlan | { readonly error: string } {\n const clips = input.clipUrls.filter((u): u is string => typeof u === \"string\" && u !== \"\")\n if (clips.length === 0) return { error: UGC_FINISH_NEEDS_CLIPS_MESSAGE }\n const read = readUgcWire(input.planOutWire, UGC_NODE_MESSAGES.needsPlanOut)\n if (\"error\" in read) return read\n const finish = read.value.finish\n if (finish === undefined) return { kind: \"pass\", clips }\n if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n if (finish.segments.length !== clips.length) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n kind: \"job\",\n path: \"/v1/ugc/finish\",\n body: { segments: finish.segments, clips: clips.map((url, i) => ({ clip: i + 1, rolls: [url] })) },\n }\n}\n\n/** A finished clip, as UGC Finish hands it on: its URL and the notes its downstream nodes read. */\nexport interface UgcFinishedClip { readonly url: string; readonly meta: FanOutItemMeta }\n\n/**\n * A finished `ugc-finish` job → the finished clips in clip order, each with its real length. `ready: false`\n * (a clip that does not follow its speech) → the not-ready sentence: the node fails, never hands on a\n * partial list. A dry finish's warning rides every clip's notes.\n */\nexport function ugcFinishOutputs(output: Readonly<Obj> | undefined): { clips: UgcFinishedClip[] } | { error: string } {\n if (!output) return { error: UGC_NEWER_APP_MESSAGE }\n if (output.ready === false) return { error: UGC_FINISH_NOT_READY_MESSAGE }\n if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n const warnings = Array.isArray(output.warnings)\n ? output.warnings.flatMap((w) => (isObject(w) && typeof w.code === \"string\" ? [w.code] : typeof w === \"string\" ? [w] : []))\n : []\n const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip))\n if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== \"string\" || r.url === \"\")) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n clips: rows.map((r) => ({\n url: r.url as string,\n meta: { warnings, durationSec: typeof r.sec === \"number\" && Number.isFinite(r.sec) && r.sec > 0 ? r.sec : null },\n })),\n }\n}\n\n/**\n * Whether a UGC Finish reads this UGC Clips node's Script (sized) output: the graph can finish a video\n * whose clips are cut from one recorded speech. Read before the prelude spends anything.\n */\nexport function ugcFinishWired(\n edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly sourceHandle?: string | null; readonly targetHandle?: string | null }>,\n nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string | null }>,\n clipsId: string,\n): boolean {\n const finishIds = new Set(nodes.filter((n) => n.type === UGC_FINISH_CLIPS_TYPE && typeof n.id === \"string\").map((n) => n.id as string))\n return edges.some((e) => e.source === clipsId && e.sourceHandle === \"plan-out\" && e.target !== undefined && finishIds.has(e.target) && (e.targetHandle ?? \"\") === \"plan\")\n}\n\n/** UGC Clips' refusal before its prelude: the sentence when no UGC Finish reads its Script (sized) output, else null. */\nexport function ugcLaneNeedsFinish(\n edges: Parameters<typeof ugcFinishWired>[0],\n nodes: Parameters<typeof ugcFinishWired>[1],\n clipsId: string,\n): string | null {\n return ugcFinishWired(edges, nodes, clipsId) ? null : UGC_NEEDS_FINISH_MESSAGE\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/ugc-call-body.ts","../src/ugc-lane-wires.ts"],"names":["pick"],"mappings":";;;AAkBA,IAAM,IAAA,GAAO,CAAC,CAAA,EAAsC,IAAA,EAAc,OAChE,CAAA,CAAE,IAAI,MAAM,MAAA,IAAa,CAAA,CAAE,IAAI,CAAA,KAAM,IAAA,GAAO,EAAE,CAAC,EAAE,GAAG,CAAA,CAAE,IAAI,CAAA,EAAE,GAAI,EAAC;AAGnE,SAAS,UAAU,CAAA,EAA+D;AAChF,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CAAK,CAAA,EAAG,UAAA,EAAY,UAAU,CAAA;AAAA,IACjC,GAAG,IAAA,CAAK,CAAA,EAAG,kBAAA,EAAoB,iBAAiB,CAAA;AAAA,IAChD,GAAI,EAAE,aAAA,KAAkB,IAAA,GAAO,EAAE,YAAA,EAAc,IAAA,KAAS,EAAC;AAAA,IACzD,GAAG,IAAA,CAAK,CAAA,EAAG,aAAA,EAAe,aAAa,CAAA;AAAA,IACvC,GAAG,IAAA,CAAK,CAAA,EAAG,YAAA,EAAc,WAAW;AAAA,GACtC;AACF;AAEO,SAAS,kBAAA,CACd,IAAA,EACA,IAAA,GAAoC,EAAC,EACkB;AACvD,EAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,IAAA,CAAK,IAAA,EAAK;AACrD,EAAA,IAAI,KAAK,QAAA,EAAU;AACjB,IAAA,IAAI,CAAC,KAAK,KAAA,EAAO,OAAO,EAAE,KAAA,EAAO,CAAA,EAAG,IAA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k-AE3AAJ4O.js","sourcesContent":["/**\n * A UGC builder call `{ tool, args }` (MCP argument names) → the REST body of\n * the public route that tool dispatches to. The builder sets every price lever;\n * this adds none — its one addition is the image of a call that needs the\n * previous step's image (`imageArg`, or the photo of `image_to_text`). A tool\n * it does not know → undefined, so an app older than the builder fails plainly\n * instead of guessing. Kept equal to the MCP verbs by ugc-call-body-parity.test.ts.\n */\nexport interface UgcToolCall {\n readonly tool: string\n readonly args: Readonly<Record<string, unknown>>\n readonly imageArg?: string\n}\nexport type UgcRouteBody = {\n readonly path: \"/v1/generate-image\" | \"/v1/image-to-image\" | \"/v1/image-to-text/describe\"\n readonly body: Record<string, unknown>\n}\n\nconst pick = (a: Readonly<Record<string, unknown>>, from: string, to: string): Record<string, unknown> =>\n a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {}\n\n/** The LLM levers image_to_text forwards (the verb's llmPayloadFields). */\nfunction llmFields(a: Readonly<Record<string, unknown>>): Record<string, unknown> {\n return {\n ...pick(a, \"llmModel\", \"llmModel\"),\n ...pick(a, \"reasoning_effort\", \"reasoningEffort\"),\n ...(a.advanced_mode === true ? { advancedMode: true } : {}),\n ...pick(a, \"temperature\", \"temperature\"),\n ...pick(a, \"max_tokens\", \"maxTokens\"),\n }\n}\n\nexport function ugcCallToRouteBody(\n call: UgcToolCall,\n opts: { readonly image?: string } = {},\n): UgcRouteBody | { readonly error: string } | undefined {\n const args: Record<string, unknown> = { ...call.args }\n if (call.imageArg) {\n if (!opts.image) return { error: `${call.tool} needs the previous step's image` }\n args[call.imageArg] = opts.image\n }\n switch (call.tool) {\n case \"generate_image\":\n return {\n path: \"/v1/generate-image\",\n body: {\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n },\n }\n case \"image_to_image\":\n return {\n path: \"/v1/image-to-image\",\n body: {\n ...pick(args, \"image_url\", \"imageUrl\"),\n ...pick(args, \"prompt\", \"prompt\"),\n ...pick(args, \"model\", \"provider\"),\n ...pick(args, \"resolution\", \"resolution\"),\n ...pick(args, \"quality\", \"quality\"),\n ...pick(args, \"strength\", \"strength\"),\n ...pick(args, \"aspect_ratio\", \"aspectRatio\"),\n ...pick(args, \"negative_prompt\", \"negativePrompt\"),\n ...pick(args, \"seed\", \"seed\"),\n },\n }\n case \"image_to_text\": {\n const image = opts.image ?? (typeof args.image_url === \"string\" ? args.image_url : undefined)\n if (!image) return { error: \"image_to_text needs an image\" }\n return {\n path: \"/v1/image-to-text/describe\",\n body: {\n imageUrl: image,\n ...pick(args, \"detail_level\", \"detailLevel\"),\n ...pick(args, \"custom_prompt\", \"customPrompt\"),\n ...llmFields(args),\n },\n }\n }\n default:\n return undefined\n }\n}\n","/**\n * The UGC wires of a language whose clips are cut from one recorded speech (the\n * segmented lane): UGC Clips' prelude (record the speech, time its words, split\n * it at its pauses, then ask for the clips again with the segments) and UGC\n * Finish (lay the speech back over the rendered clips and trim the dead air,\n * as one job over all of them). One pure implementation both engines call, as\n * the rest of the UGC wires (`ugc-node-wires.ts`).\n *\n * Content-free: an answer is read only for `phase`, its three calls' `tool`\n * and `args` (argument names, never their meaning), the `finish` call's\n * `args`, and a finished job's clip list. Which language takes this lane, which\n * voice speaks and what the calls say are the builder's.\n */\nimport {\n UGC_FINISH_NEEDS_CLIPS_MESSAGE,\n UGC_FINISH_NOT_READY_MESSAGE,\n UGC_NEEDS_FINISH_MESSAGE,\n UGC_NEWER_APP_MESSAGE,\n UGC_NODE_MESSAGES,\n UGC_OVER_HOLD_MESSAGE,\n UGC_SCRIPT_LANGUAGES,\n readUgcWire,\n ugcPlanLengthSec,\n ugcPlanScreenshotCount,\n} from \"./ugc-node-wires.js\"\nimport type { FanOutItemMeta } from \"./fan-out-meta.js\"\n\ntype Obj = Record<string, unknown>\nconst isObject = (x: unknown): x is Obj => !!x && typeof x === \"object\" && !Array.isArray(x)\n\n/** UGC Finish's node type. Not the plugin job it runs (`ugc-finish`): a price, a dispatch or a reconcile keyed on a type never confuses the two. */\nexport const UGC_FINISH_CLIPS_TYPE = \"ugc-finish-clips\"\n\n/** The child steps of UGC Clips' prelude, in run order: each is a job of its own, keyed by its step. */\nexport const UGC_PRELUDE_STEPS = [\"speech\", \"alignment\", \"split\"] as const\nexport type UgcPreludeStep = (typeof UGC_PRELUDE_STEPS)[number]\n\n/** The public route each prelude step runs on, and the node type its job is read as. */\nexport const UGC_PRELUDE_ROUTES: Readonly<Record<UgcPreludeStep, { readonly path: string; readonly jobType: string }>> = {\n speech: { path: \"/v1/text-to-speech\", jobType: \"text-to-speech\" },\n alignment: { path: \"/v1/forced-alignment\", jobType: \"forced-alignment\" },\n split: { path: \"/v1/ugc/segments\", jobType: \"ugc-segments\" },\n}\n\n/** The `/v1/ugc/clips` answer's phase: 1 = the prelude must run first, 2 = the clips; null = an answer with no phase (one call, as English). */\nexport function ugcClipsPhase(answer: Readonly<Obj>): 1 | 2 | null {\n return answer.phase === 1 ? 1 : answer.phase === 2 ? 2 : null\n}\n\nconst callOf = (raw: unknown, tool: string): Obj | undefined => {\n if (!isObject(raw) || raw.tool !== tool || !isObject(raw.args)) return undefined\n return raw.args\n}\nconst pick = (a: Readonly<Obj>, from: string, to: string): Obj => (a[from] !== undefined && a[from] !== null ? { [to]: a[from] } : {})\n\n/** What the prelude runs: the speech's route body, and the two that need the step before them. */\nexport interface UgcPrelude {\n readonly speech: Obj\n readonly alignment: (audioUrl: string) => Obj\n readonly split: (audioUrl: string, alignment: unknown) => Obj\n}\n\n/**\n * A phase-1 answer's three calls (`speech`, `align`, `split`, MCP argument names) → the REST bodies of\n * the public routes their MCP tools dispatch to: `generate_speech` → `/v1/text-to-speech` (text, voice,\n * voice type, model as provider, language code, as the verb maps them), `forced_alignment` →\n * `/v1/forced-alignment` (the transcript, with the speech's audio), `ugc_split_speech` →\n * `/v1/ugc/segments` (the plan, with the speech's audio and its word timings). A call that is missing\n * or names another tool → the newer-app sentence: the app never guesses.\n */\nexport function ugcPrelude(answer: Readonly<Obj>): UgcPrelude | { readonly error: string } {\n const speech = callOf(answer.speech, \"generate_speech\")\n const align = callOf(answer.align, \"forced_alignment\")\n const split = callOf(answer.split, \"ugc_split_speech\")\n if (!speech || !align || !split || typeof speech.text !== \"string\" || !isObject(split.plan)) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n speech: {\n text: speech.text,\n ...pick(speech, \"voice_id\", \"voice\"),\n ...pick(speech, \"voice_type\", \"voiceType\"),\n ...pick(speech, \"model\", \"provider\"),\n ...pick(speech, \"language_code\", \"languageCode\"),\n },\n alignment: (audioUrl) => ({ ...pick(align, \"transcript\", \"transcript\"), audioUrl }),\n split: (audioUrl, alignment) => ({ plan: split.plan, audioUrl, alignment }),\n }\n}\n\n/** The finished speech job's audio, its word timings and its segments, as their jobs write them. */\nexport function ugcPreludeOutput(step: UgcPreludeStep, output: Readonly<Obj> | undefined): { value: unknown } | { error: string } {\n const value = step === \"speech\" ? output?.audioUrl : step === \"alignment\" ? output?.alignment : output?.segments\n const ok = step === \"speech\" ? typeof value === \"string\" && value !== \"\" : Array.isArray(value) && value.length > 0\n return ok ? { value } : { error: UGC_NEWER_APP_MESSAGE }\n}\n\n/** The second `/v1/ugc/clips` call: the first call's body with the segments the split returned. */\nexport function ugcClipsPhase2Body(body: Readonly<Obj>, segments: readonly unknown[]): Obj {\n return { ...body, segments: [...segments] }\n}\n\n// ── The hold check once the speech is split ──────────────────────────────────\n\n/** The estimate input of a video cut from one recorded speech, as the hold check names it (`runEstimate`). */\nexport interface UgcRunEstimateInput {\n readonly targetDurationSec: number\n readonly screenshotCount: number\n readonly source: \"sampled\"\n readonly language: string\n}\n\n/**\n * The estimate input of the video a UGC Clips run belongs to, read from the plan the node was sent: its\n * length, its screenshot cards and its language — the reading a kept plan is priced with. Read on a\n * phase-1 answer, before the prelude spends anything, so a plan the check cannot read refuses the run\n * while nothing is paid. The creator's source prices no clip, so it is not read. A plan without a length,\n * or without a language this lane takes → the newer-app sentence: the check never guesses.\n */\nexport function ugcRunEstimateInput(plan: unknown): { runEstimate: UgcRunEstimateInput } | { error: string } {\n const targetDurationSec = ugcPlanLengthSec(plan)\n const language = planOf(plan)?.language\n if (targetDurationSec === undefined || typeof language !== \"string\" || language === \"en\" || !(UGC_SCRIPT_LANGUAGES as readonly unknown[]).includes(language)) {\n return { error: UGC_NEWER_APP_MESSAGE }\n }\n return { runEstimate: { targetDurationSec, screenshotCount: ugcPlanScreenshotCount(plan) ?? 0, source: \"sampled\", language } }\n}\n\n/**\n * The quote that checks a video cut from one recorded speech before any of its clips renders: the clips\n * the second `/v1/ugc/clips` call handed on, priced as the UGC Clips quote prices them (`tickets`,\n * `hasCards`, `finishes`), with `runEstimate` (`ugcRunEstimateInput`). The route then also answers\n * `runHold`, the most the video's estimate holds for the clips and the steps after them, which the run's\n * balance was checked against before it started (`ugcRenderHoldVerdict`). No clips → the newer-app sentence.\n */\nexport function ugcRenderHoldBody(input: { runEstimate: UgcRunEstimateInput; tickets: unknown; hasCards: boolean; finishes: boolean }): { path: \"/v1/ugc/quote\"; body: Obj } | { error: string } {\n if (!Array.isArray(input.tickets) || input.tickets.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n path: \"/v1/ugc/quote\",\n body: {\n tickets: [...input.tickets],\n hasCards: input.hasCards,\n ...(input.finishes ? { finishes: true } : {}),\n runEstimate: { ...input.runEstimate },\n },\n }\n}\n\n/** A plan, or its wire (a JSON string), as an object; undefined for anything else. */\nfunction planOf(plan: unknown): Obj | undefined {\n if (typeof plan !== \"string\") return isObject(plan) ? plan : undefined\n try {\n const parsed: unknown = JSON.parse(plan)\n return isObject(parsed) ? parsed : undefined\n } catch {\n return undefined\n }\n}\n\nconst isCredits = (x: unknown): x is number => typeof x === \"number\" && Number.isFinite(x) && x >= 0\n\n/**\n * The hold check's answer → go on, or stop before any clip renders: the clips and the steps after them\n * (`ceiling`, each clip at its hold) over what the run was checked for (`runHold`) → the over-hold\n * sentence. An answer without both figures stops too (the newer-app sentence): a clip never renders\n * on a figure nobody checked.\n */\nexport function ugcRenderHoldVerdict(answer: unknown): { readonly ok: true } | { readonly error: string } {\n if (!isObject(answer) || !isCredits(answer.ceiling) || !isCredits(answer.runHold)) return { error: UGC_NEWER_APP_MESSAGE }\n return answer.ceiling > answer.runHold ? { error: UGC_OVER_HOLD_MESSAGE } : { ok: true }\n}\n\n// ── UGC Finish ───────────────────────────────────────────────────────────────\n\n/** What UGC Finish does with the clips it was handed. */\nexport type UgcFinishPlan =\n /** No finish call on the plan (English): the clips go on as they came, no call, no job. */\n | { readonly kind: \"pass\"; readonly clips: readonly string[] }\n /** The finish job's body: the segments with their room, one roll per clip, in order. */\n | { readonly kind: \"job\"; readonly path: \"/v1/ugc/finish\"; readonly body: Obj }\n\n/**\n * UGC Finish's input → what it does. The `plan` input is UGC Clips' Script (sized) output; a plan\n * carrying `finish` (the segmented lane) asks for the finish job over the clips, in order; any other\n * plan passes the clips through. Clips are the fan-in list (`inputs.inputs`), in clip order.\n */\nexport function ugcFinishPlan(input: { planOutWire: unknown; clipUrls: readonly unknown[] }): UgcFinishPlan | { readonly error: string } {\n const clips = input.clipUrls.filter((u): u is string => typeof u === \"string\" && u !== \"\")\n if (clips.length === 0) return { error: UGC_FINISH_NEEDS_CLIPS_MESSAGE }\n const read = readUgcWire(input.planOutWire, UGC_NODE_MESSAGES.needsPlanOut)\n if (\"error\" in read) return read\n const finish = read.value.finish\n if (finish === undefined) return { kind: \"pass\", clips }\n if (!isObject(finish) || !Array.isArray(finish.segments) || finish.segments.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n if (finish.segments.length !== clips.length) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n kind: \"job\",\n path: \"/v1/ugc/finish\",\n body: { segments: finish.segments, clips: clips.map((url, i) => ({ clip: i + 1, rolls: [url] })) },\n }\n}\n\n/** A finished clip, as UGC Finish hands it on: its URL and the notes its downstream nodes read. */\nexport interface UgcFinishedClip { readonly url: string; readonly meta: FanOutItemMeta }\n\n/**\n * A finished `ugc-finish` job → the finished clips in clip order, each with its real length. `ready: false`\n * (a clip that does not follow its speech) → the not-ready sentence: the node fails, never hands on a\n * partial list. A dry finish's warning rides every clip's notes.\n */\nexport function ugcFinishOutputs(output: Readonly<Obj> | undefined): { clips: UgcFinishedClip[] } | { error: string } {\n if (!output) return { error: UGC_NEWER_APP_MESSAGE }\n if (output.ready === false) return { error: UGC_FINISH_NOT_READY_MESSAGE }\n if (output.ready !== true || !Array.isArray(output.clips) || output.clips.length === 0) return { error: UGC_NEWER_APP_MESSAGE }\n const warnings = Array.isArray(output.warnings)\n ? output.warnings.flatMap((w) => (isObject(w) && typeof w.code === \"string\" ? [w.code] : typeof w === \"string\" ? [w] : []))\n : []\n const rows = [...output.clips].filter(isObject).sort((a, b) => Number(a.clip) - Number(b.clip))\n if (rows.length !== output.clips.length || rows.some((r, i) => r.clip !== i + 1 || typeof r.url !== \"string\" || r.url === \"\")) return { error: UGC_NEWER_APP_MESSAGE }\n return {\n clips: rows.map((r) => ({\n url: r.url as string,\n meta: { warnings, durationSec: typeof r.sec === \"number\" && Number.isFinite(r.sec) && r.sec > 0 ? r.sec : null },\n })),\n }\n}\n\n/**\n * Whether a UGC Finish reads this UGC Clips node's Script (sized) output: the graph can finish a video\n * whose clips are cut from one recorded speech. Read before the prelude spends anything.\n */\nexport function ugcFinishWired(\n edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly sourceHandle?: string | null; readonly targetHandle?: string | null }>,\n nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string | null }>,\n clipsId: string,\n): boolean {\n const finishIds = new Set(nodes.filter((n) => n.type === UGC_FINISH_CLIPS_TYPE && typeof n.id === \"string\").map((n) => n.id as string))\n return edges.some((e) => e.source === clipsId && e.sourceHandle === \"plan-out\" && e.target !== undefined && finishIds.has(e.target) && (e.targetHandle ?? \"\") === \"plan\")\n}\n\n/** UGC Clips' refusal before its prelude: the sentence when no UGC Finish reads its Script (sized) output, else null. */\nexport function ugcLaneNeedsFinish(\n edges: Parameters<typeof ugcFinishWired>[0],\n nodes: Parameters<typeof ugcFinishWired>[1],\n clipsId: string,\n): string | null {\n return ugcFinishWired(edges, nodes, clipsId) ? null : UGC_NEEDS_FINISH_MESSAGE\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { uiResolutionFill } from './chunk-
|
|
1
|
+
import { uiResolutionFill } from './chunk-EPXGG27L.js';
|
|
2
2
|
import { isGptImage26Tiered, GPT_IMAGE_2_6_QUALITIES, GPT_IMAGE_2_6_DEFAULT_QUALITY, GPT_IMAGE_2_6_RESOLUTIONS, GPT_IMAGE_2_6_DEFAULT_RESOLUTION, isGptImage26I2i, gptImage26PricedFormat, GPT_IMAGE_2_6_MAX_INPUT_IMAGES } from './chunk-RGNHHIMN.js';
|
|
3
|
-
import { HIGH_QUALITY_PROVIDERS, TWO_K_RESOLUTION_PROVIDERS, RESOLUTION_2K_4K_TIERED_PROVIDERS, IDEOGRAM_PROVIDERS, T2I_TO_I2I_VARIANT, canonicalVideoProvider,
|
|
4
|
-
import { isFlux2Model, isMinimaxH3Image, minimaxH3ImageCreditId, isSeedream55, normalizeModelInput, MODEL_CATALOG, normalizeVideoRequestParams, VIDEO_DURATION_AUTO, autoAspectNeedsSourceImage, FLUX2_RES_MP, defaultResolutionFor, seedream55Resolution, isSeedream55I2i, SEEDREAM_5_5_I2I, SEEDREAM_5_5_MAX_INPUT_IMAGES } from './chunk-
|
|
3
|
+
import { HIGH_QUALITY_PROVIDERS, TWO_K_RESOLUTION_PROVIDERS, RESOLUTION_2K_4K_TIERED_PROVIDERS, IDEOGRAM_PROVIDERS, T2I_TO_I2I_VARIANT, canonicalVideoProvider, isTailExtendProvider, DURATION_PRICED_PROVIDERS, isVeoProvider, VEO_RESOLUTION_TIERED_PROVIDERS, isGeminiOmniProvider, isGeminiOmniPerSecondProvider, pricedOutputDurationSec, VIDEO_DURATION_TIERS, MODE_ADDON_PROVIDERS, RESOLUTION_VIDEO_REF_PRICING, PRICING_DEFAULT_RESOLUTION, RESOLUTION_DURATION_PRICING, VIDEO_REF_RATE_PROVIDERS, isMinimaxH3Provider, normalizeMinimaxH3Resolution, AUDIO_ADDON_PROVIDERS, videoAudioPricedOn, MOTION_DURATION_TIERS, snapToNearestDuration, isWan3Provider, normalizeWan3Resolution, isViduQ4Provider, normalizeViduQ4Resolution, isKling4Provider, normalizeKling4Resolution, isKling4FlashProvider, KLING_4_FLASH_RESOLUTION, isGrokVideo15Provider, normalizeGrokVideo15Resolution, isPixverseV6MaxProvider, normalizePixverseV6MaxQuality } from './chunk-OV3JTKBY.js';
|
|
4
|
+
import { isFlux2Model, isMinimaxH3Image, minimaxH3ImageCreditId, isSeedream55, normalizeModelInput, MODEL_CATALOG, normalizeVideoRequestParams, VIDEO_DURATION_AUTO, autoAspectNeedsSourceImage, FLUX2_RES_MP, defaultResolutionFor, seedream55Resolution, isSeedream55I2i, SEEDREAM_5_5_I2I, SEEDREAM_5_5_MAX_INPUT_IMAGES } from './chunk-PSKZKLDG.js';
|
|
5
5
|
|
|
6
6
|
// src/credit-identifiers.ts
|
|
7
7
|
function flux2MegapixelTier(model, resolution) {
|
|
@@ -149,11 +149,13 @@ function wireNormalizedResolution(provider, resolution) {
|
|
|
149
149
|
if (isKling4Provider(provider)) return normalizeKling4Resolution(resolution);
|
|
150
150
|
if (isKling4FlashProvider(provider)) return KLING_4_FLASH_RESOLUTION;
|
|
151
151
|
if (isGrokVideo15Provider(provider)) return normalizeGrokVideo15Resolution(resolution);
|
|
152
|
+
if (isPixverseV6MaxProvider(provider)) return normalizePixverseV6MaxQuality(resolution);
|
|
152
153
|
return resolution;
|
|
153
154
|
}
|
|
154
155
|
function buildVideoCreditModelIdentifier(rawProvider, duration, sound, nodeType, mode, resolution, hasVideoRef) {
|
|
156
|
+
const audio = typeof sound === "object" && sound !== null ? sound : { sound };
|
|
155
157
|
const provider = canonicalVideoProvider(rawProvider);
|
|
156
|
-
if (
|
|
158
|
+
if (isTailExtendProvider(provider)) return tailExtendCreditId(provider, duration, resolution);
|
|
157
159
|
let effectiveProvider = provider;
|
|
158
160
|
if (nodeType === "text-to-video") {
|
|
159
161
|
const override = T2V_CREDIT_OVERRIDES[provider];
|
|
@@ -189,10 +191,6 @@ function buildVideoCreditModelIdentifier(rawProvider, duration, sound, nodeType,
|
|
|
189
191
|
if (!tiers) return effectiveProvider;
|
|
190
192
|
const tier = tiers.find((t) => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1];
|
|
191
193
|
let identifier = `${effectiveProvider}:${tier.suffix}`;
|
|
192
|
-
const soundOn = sound ?? getVideoAudioCapability(effectiveProvider).defaultOn === true;
|
|
193
|
-
if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && soundOn) {
|
|
194
|
-
identifier += ":audio";
|
|
195
|
-
}
|
|
196
194
|
if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === "high" || mode === "pro")) {
|
|
197
195
|
identifier += ":high";
|
|
198
196
|
}
|
|
@@ -216,6 +214,9 @@ function buildVideoCreditModelIdentifier(rawProvider, duration, sound, nodeType,
|
|
|
216
214
|
if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === "768P") {
|
|
217
215
|
identifier += ":768p";
|
|
218
216
|
}
|
|
217
|
+
if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && videoAudioPricedOn(effectiveProvider, audio)) {
|
|
218
|
+
identifier += ":audio";
|
|
219
|
+
}
|
|
219
220
|
return identifier;
|
|
220
221
|
}
|
|
221
222
|
function videoGenerationCreditId(args) {
|
|
@@ -226,7 +227,7 @@ function videoGenerationCreditId(args) {
|
|
|
226
227
|
return buildVideoCreditModelIdentifier(
|
|
227
228
|
args.provider,
|
|
228
229
|
args.duration,
|
|
229
|
-
args.sound,
|
|
230
|
+
{ sound: args.sound, generateAudio: args.generateAudio },
|
|
230
231
|
args.nodeType ?? "image-to-video",
|
|
231
232
|
args.mode,
|
|
232
233
|
resolution,
|
|
@@ -243,12 +244,18 @@ function seedanceVideoEditCreditId(provider, resolution, draft) {
|
|
|
243
244
|
hasVideoRef: true
|
|
244
245
|
});
|
|
245
246
|
}
|
|
246
|
-
var
|
|
247
|
+
var TAIL_EXTEND_DEFAULT_RESOLUTION = "720p";
|
|
248
|
+
function tailExtendResolution(provider, resolution) {
|
|
249
|
+
return typeof resolution === "string" && MODEL_CATALOG[provider]?.resolutions?.includes(resolution) ? resolution : TAIL_EXTEND_DEFAULT_RESOLUTION;
|
|
250
|
+
}
|
|
251
|
+
function tailExtendCreditId(provider, duration, resolution) {
|
|
252
|
+
return `${provider}:${pricedOutputDurationSec(provider, duration)}s:${tailExtendResolution(provider, resolution)}`;
|
|
253
|
+
}
|
|
247
254
|
function seedanceExtendResolution(provider, resolution) {
|
|
248
|
-
return
|
|
255
|
+
return tailExtendResolution(provider, resolution);
|
|
249
256
|
}
|
|
250
257
|
function seedanceExtendCreditId(provider, duration, resolution) {
|
|
251
|
-
return
|
|
258
|
+
return tailExtendCreditId(provider, duration, resolution);
|
|
252
259
|
}
|
|
253
260
|
function pricedVideoSelection(opts) {
|
|
254
261
|
const adjustments = [];
|
|
@@ -270,6 +277,20 @@ function pricedVideoSelection(opts) {
|
|
|
270
277
|
return { resolution, duration, adjustments };
|
|
271
278
|
}
|
|
272
279
|
function buildMotionCreditModelIdentifier(provider, resolution, videoDuration) {
|
|
280
|
+
return motionCreditIdentifier(provider, motionTransferResolution(provider, resolution).resolution, videoDuration);
|
|
281
|
+
}
|
|
282
|
+
function motionModelOf(provider) {
|
|
283
|
+
return motionCreditIdentifier(provider, "720p").split(":")[0];
|
|
284
|
+
}
|
|
285
|
+
var MOTION_MODELS_SENT_AS_NAMED = /* @__PURE__ */ new Set(["motion-transfer", "kling-3.0-motion"]);
|
|
286
|
+
function motionTransferResolution(provider, resolution) {
|
|
287
|
+
const model = motionModelOf(provider);
|
|
288
|
+
if (MOTION_MODELS_SENT_AS_NAMED.has(model)) return { resolution, adjustments: [] };
|
|
289
|
+
const normalized = normalizeModelInput(model, { resolution });
|
|
290
|
+
if (normalized.resolution === void 0) return { resolution, adjustments: [] };
|
|
291
|
+
return { resolution: normalized.resolution, adjustments: normalized.adjustments };
|
|
292
|
+
}
|
|
293
|
+
function motionCreditIdentifier(provider, resolution, videoDuration) {
|
|
273
294
|
if (provider === "wan-animate-move" || provider === "wan-animate-replace") {
|
|
274
295
|
if (resolution === "580p" || resolution === "720p") {
|
|
275
296
|
return `${provider}:${resolution}`;
|
|
@@ -329,6 +350,6 @@ var SUNO_VERSION_CREDIT_KEYS = {
|
|
|
329
350
|
V5: "suno-v5"
|
|
330
351
|
};
|
|
331
352
|
|
|
332
|
-
export { SPEAKER_VIEW_CREDIT_IDS, SPEAKER_VIEW_PRICE_TIERS, SUNO_SELECT_OPERATIONS, SUNO_VERSION_CREDIT_KEYS, SUNO_VERSION_PRICED_OPERATIONS, applyEdlCreditId, buildCreditModelIdentifier, buildMotionCreditModelIdentifier, buildVideoCreditModelIdentifier, imageFormatInputOf, imageGenAutoAspectNeedsSourceImage, normalizedImageGenModelId, pricedVideoSelection, resolveImageGenCreditIdentifier, resolveNormalizedImageGen, seedanceExtendCreditId, seedanceExtendResolution, seedanceVideoEditCreditId, speakerViewCreditId, speedRampCreditId, sunoCreditType, videoGenerationCreditId };
|
|
333
|
-
//# sourceMappingURL=chunk-
|
|
334
|
-
//# sourceMappingURL=chunk-
|
|
353
|
+
export { SPEAKER_VIEW_CREDIT_IDS, SPEAKER_VIEW_PRICE_TIERS, SUNO_SELECT_OPERATIONS, SUNO_VERSION_CREDIT_KEYS, SUNO_VERSION_PRICED_OPERATIONS, applyEdlCreditId, buildCreditModelIdentifier, buildMotionCreditModelIdentifier, buildVideoCreditModelIdentifier, imageFormatInputOf, imageGenAutoAspectNeedsSourceImage, motionTransferResolution, normalizedImageGenModelId, pricedVideoSelection, resolveImageGenCreditIdentifier, resolveNormalizedImageGen, seedanceExtendCreditId, seedanceExtendResolution, seedanceVideoEditCreditId, speakerViewCreditId, speedRampCreditId, sunoCreditType, tailExtendCreditId, tailExtendResolution, videoGenerationCreditId };
|
|
354
|
+
//# sourceMappingURL=chunk-BMJVKYVB.js.map
|
|
355
|
+
//# sourceMappingURL=chunk-BMJVKYVB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/credit-identifiers.ts"],"names":[],"mappings":";;;;;;AAkGA,SAAS,kBAAA,CAAmB,OAAmB,UAAA,EAA6B;AAC1E,EAAA,MAAM,IAAA,GAAO,CAAC,CAAA,KAAc,CAAA,CAAE,QAAQ,SAAA,EAAW,EAAE,EAAE,IAAA,EAAK;AAC1D,EAAA,MAAM,MAAM,OAAO,UAAA,KAAe,QAAA,GAAW,IAAA,CAAK,UAAU,CAAA,GAAI,EAAA;AAChE,EAAA,IAAI,GAAA,KAAQ,IAAI,OAAO,GAAA;AAIvB,EAAA,MAAM,IAAA,GAAO,YAAA,CAAa,IAAA,CAAK,CAAC,CAAA,KAAM,OAAO,CAAC,CAAA,KAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAC/D,EAAA,OAAO,IAAA,IAAQ,IAAA,CAAK,oBAAA,CAAqB,KAAK,KAAK,MAAM,CAAA;AAC3D;AAoBA,SAAS,kBAAA,CACP,QAAA,EACA,OAAA,EACA,UAAA,EACA,qBACA,WAAA,EACQ;AACR,EAAA,MAAM,IAAK,uBAAA,CAA8C,QAAA,CAAS,OAAA,IAAW,EAAE,IAAI,OAAA,GAAU,6BAAA;AAC7F,EAAA,MAAM,IAAK,yBAAA,CAAgD,QAAA,CAAS,UAAA,IAAc,EAAE,IAAI,UAAA,GAAa,gCAAA;AACrG,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,mBAAA,IAAuB,CAAC,CAAA;AAClD,EAAA,MAAM,KAAA,GAAQ,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,GAA6D;AAAA,EACxE,EAAA,EAAI,SAAA;AAAA,EACJ,OAAA,EAAS,cAAA;AAAA,EACT,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM,WAAA;AAAA,EACN,EAAA,EAAI;AACN","file":"chunk-BMJVKYVB.js","sourcesContent":["/**\n * Build composite credit model identifiers for variable pricing.\n * Shared between frontend and backend.\n */\n\nimport {\n HIGH_QUALITY_PROVIDERS,\n TWO_K_RESOLUTION_PROVIDERS,\n RESOLUTION_2K_4K_TIERED_PROVIDERS,\n IDEOGRAM_PROVIDERS,\n DURATION_PRICED_PROVIDERS,\n AUDIO_ADDON_PROVIDERS,\n MODE_ADDON_PROVIDERS,\n RESOLUTION_VIDEO_REF_PRICING,\n RESOLUTION_DURATION_PRICING,\n VEO_RESOLUTION_TIERED_PROVIDERS,\n VIDEO_DURATION_TIERS,\n pricedOutputDurationSec,\n snapToNearestDuration,\n PRICING_DEFAULT_RESOLUTION,\n MOTION_DURATION_TIERS,\n T2I_TO_I2I_VARIANT,\n isVeoProvider,\n isMinimaxH3Provider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4Provider,\n normalizeKling4Resolution,\n isKling4FlashProvider,\n KLING_4_FLASH_RESOLUTION,\n isGrokVideo15Provider,\n normalizeGrokVideo15Resolution,\n isPixverseV6MaxProvider,\n normalizePixverseV6MaxQuality,\n VIDEO_REF_RATE_PROVIDERS,\n normalizeMinimaxH3Resolution,\n normalizeWan3Resolution,\n normalizeViduQ4Resolution,\n videoAudioPricedOn,\n type VideoAudioRequest,\n canonicalVideoProvider,\n isTailExtendProvider,\n type SeedanceExtendProvider,\n type TailExtendProvider,\n} from \"./model-constants.js\"\nimport { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from \"./flux2-pricing.js\"\nimport {\n GPT_IMAGE_2_6_DEFAULT_QUALITY,\n GPT_IMAGE_2_6_DEFAULT_RESOLUTION,\n GPT_IMAGE_2_6_MAX_INPUT_IMAGES,\n GPT_IMAGE_2_6_QUALITIES,\n GPT_IMAGE_2_6_RESOLUTIONS,\n gptImage26PricedFormat,\n isGptImage26I2i,\n isGptImage26Tiered,\n type GptImage26TieredModel,\n type ImageFormatLevers,\n} from \"./gpt-image-2-6.js\"\nimport { isMinimaxH3Image, minimaxH3ImageCreditId } from \"./minimax-h3-image.js\"\nimport {\n SEEDREAM_5_5_I2I,\n SEEDREAM_5_5_MAX_INPUT_IMAGES,\n isSeedream55,\n isSeedream55I2i,\n seedream55Resolution,\n type Seedream55Model,\n} from \"./seedream-5-5.js\"\nimport { VIDEO_DURATION_AUTO } from \"./video-duration-auto.js\"\nimport { uiResolutionFill } from \"./video-ui-defaults.js\"\nimport { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from \"./model-catalog.js\"\n\n/**\n * The megapixel tier a Flux 2 credit identifier is keyed on, for ANY incoming\n * `resolution` value.\n *\n * Flux 2 is the only family whose identifier INTERPOLATES the resolution\n * instead of matching it against a known set, and its callers are not\n * guaranteed to hand it a Flux 2 value:\n * - the multi-provider cost preview prices one node's data against EVERY\n * selected provider (`frontend/src/ee/hooks/use-providers-credits-sum.ts`),\n * so a node whose `resolution` is \"2K\" (the flux / nano-banana-pro value\n * space) reaches this branch verbatim;\n * - node data written straight into workflow JSON by an agent, an import or\n * a template never ran the config panel's provider-change fail-safe.\n * Interpolating that produced the off-grid id `flux-2-pro:2KMP:0ref`, which no\n * pricing row can answer — every cost badge 503'd `price_not_configured`\n * (18 production app-reports, 2026-09-07..14).\n *\n * A value off the grid snaps to the model's DEFAULT tier — the same `preferred`\n * value `normalizeModelInput` uses — so the preview asks for exactly the id the\n * route will reserve (both routes and the orchestrator normalize through\n * `resolveNormalizedImageGen` first, which makes this snap a no-op for them).\n * An ABSENT resolution keeps its long-standing meaning (\"this caller has no\n * resolution dimension at all\") and stays on 1 MP rather than moving to the\n * model default, which would silently re-price every resolution-less node.\n */\nfunction flux2MegapixelTier(model: Flux2Model, resolution?: string): string {\n const bare = (v: string) => v.replace(/\\s*MP$/i, \"\").trim()\n const raw = typeof resolution === \"string\" ? bare(resolution) : \"\"\n if (raw === \"\") return \"1\"\n // Numeric match so \"2.0\"/\" 2 MP\" land on the same grid point as \"2\", and the\n // GRID's own spelling is what gets emitted — returning the caller's \"2.0\"\n // would build \":2.0MP:\", another id no pricing row carries.\n const tier = FLUX2_RES_MP.find((t) => Number(t) === Number(raw))\n return tier ?? bare(defaultResolutionFor(model) ?? \"1 MP\")\n}\n\n/**\n * The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,\n * and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.\n * PNG, JPEG and WebP cost the same, so they share those ids. Only a format that\n * prices differently adds a part of its own:\n * - a GIF takes no size (it is 512 pixels a frame) and is priced by its band\n * of frames: `<id>:<quality>:gif-<band>`, on an edit `…:gif-<band>:<N>ref`\n * (`gpt-image-2-6-flare:medium:gif-9-12`);\n * - an SVG is priced at its size and its level of detail:\n * `<id>:<quality>:<size>:svg-<level>`, on an edit `…:svg-<level>:<N>ref`\n * (`gpt-image-2-6-flare-i2i:high:2K:svg-detailed:3ref`).\n *\n * A value off the grid (a stored node, the multi-provider preview pricing one\n * node's data against every model) lands on the default rather than building\n * an id no row answers. A text-to-image id sent input images runs on the edit\n * endpoint, so a caller that does not swap the model first (the entity routes,\n * a pipeline pin) is priced there too. An edit always has at least its source.\n */\nfunction gptImage26CreditId(\n provider: GptImage26TieredModel,\n quality: string | undefined,\n resolution: string | undefined,\n referenceImageCount: number | undefined,\n imageFormat: ImageFormatLevers | undefined,\n): string {\n const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? \"\") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY\n const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? \"\") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION\n const images = Math.trunc(referenceImageCount ?? 0)\n const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider\n const format = gptImage26PricedFormat(imageFormat)\n const base = format?.kind === \"gif\"\n ? `${model}:${q}:gif-${format.band}`\n : format?.kind === \"svg\"\n ? `${model}:${q}:${r}:svg-${format.level}`\n : `${model}:${q}:${r}`\n if (!isGptImage26I2i(model)) return base\n return `${base}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`\n}\n\n/**\n * The price id of a Seedream 5.5 run: `seedream-5-5:<size>`, and on an edit\n * `seedream-5-5-i2i:<size>:<N>ref`, N being the input images (1 to 10). Each\n * size has its own id, 1K and 1.5K at the same price.\n *\n * A size off its list (a stored node, the multi-provider preview pricing one\n * node's data against every model) or none lands on the default, 2K, which is\n * what the provider renders with none. A text-to-image id sent input images\n * runs on the edit endpoint (the provider swaps it), so a caller that does not\n * swap the model first (the entity routes, a pipeline pin) is priced there too.\n * An edit always has at least its source, and is priced for at most the images\n * the provider takes (what a request holds past it is not sent).\n */\nfunction seedream55CreditId(\n provider: Seedream55Model,\n resolution: string | undefined,\n referenceImageCount: number | undefined,\n): string {\n const size = seedream55Resolution(resolution)\n const images = Math.trunc(referenceImageCount ?? 0)\n const model = !isSeedream55I2i(provider) && images > 0 ? SEEDREAM_5_5_I2I : provider\n if (!isSeedream55I2i(model)) return `${model}:${size}`\n return `${model}:${size}:${Math.min(Math.max(1, images), SEEDREAM_5_5_MAX_INPUT_IMAGES)}ref`\n}\n\n/**\n * Compute composite model identifier for variable credit pricing.\n * Examples: \"gpt-image:high\", \"flux:2K\", \"nano-banana-pro:4K\", \"ideogram:TURBO\",\n * \"flux-2-pro:2MP\", \"flux-2-max:2MP:1ref\" (Flux 2 — billed per megapixel).\n *\n * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output\n * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.\n * For video models, uses duration/sound params when the model has variable pricing.\n */\nexport function buildCreditModelIdentifier(\n provider: string,\n quality?: string,\n resolution?: string,\n renderingSpeed?: string,\n targetResolution?: string,\n referenceImageCount?: number,\n /** The output format, a GIF's frames and an SVG's level: read only by a model whose price depends on them (GPT Image 2.6). */\n imageFormat?: ImageFormatLevers,\n): string {\n // Flux 2 family: billed per output megapixel AND per reference image (each\n // ref counts as input megapixels). Resolution arrives as \"N MP\" strings (the\n // UI value space); strip the unit. ALL three models encode the ref count\n // (capped at 8): Pro/Klein i2i always carry the source image as a ref and\n // their cost formula charges per input MP, so the reserved identifier must\n // reflect refs (there is no metered true-up to correct an under-reserved tier).\n if (isFlux2Model(provider)) {\n return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`\n }\n if (isGptImage26Tiered(provider)) {\n return gptImage26CreditId(provider, quality, resolution, referenceImageCount, imageFormat)\n }\n // MiniMax H3 Image: by size, and on an edit by its reference images\n // (`minimax-h3-image:2K`, `minimax-h3-image-i2i:4K:3ref`).\n if (isMinimaxH3Image(provider)) {\n return minimaxH3ImageCreditId(provider, resolution, referenceImageCount)\n }\n if (isSeedream55(provider)) {\n return seedream55CreditId(provider, resolution, referenceImageCount)\n }\n if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === \"high\") {\n return `${provider}:high`\n }\n if (TWO_K_RESOLUTION_PROVIDERS.has(provider) && resolution === \"2K\") {\n return `${provider}:2K`\n }\n if (provider === \"nano-banana-pro\" && resolution === \"4K\") {\n return `${provider}:4K`\n }\n if (RESOLUTION_2K_4K_TIERED_PROVIDERS.has(provider) && (resolution === \"2K\" || resolution === \"4K\")) {\n return `${provider}:${resolution}`\n }\n // Topaz Image Upscale: 2K is default (no suffix), 4K/8K get composite identifiers\n if (provider === \"topaz-image-upscale\" && targetResolution && targetResolution !== \"2K\") {\n return `${provider}:${targetResolution}`\n }\n if (IDEOGRAM_PROVIDERS.has(provider)) {\n if (renderingSpeed === \"TURBO\") return `${provider}:TURBO`\n if (renderingSpeed === \"QUALITY\") return `${provider}:QUALITY`\n }\n return provider\n}\n\n/**\n * An image request's catalog-snapped parameters PLUS the credit identifier\n * priced off them.\n *\n * `adjustments` is the disclosure channel: every lever this changed, why, and\n * to what. Routes return it in the 200 body so a caller learns their value was\n * corrected instead of silently getting something else.\n */\nexport interface NormalizedImageGen {\n /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */\n identifier: string\n /** The catalog model id the params were snapped against (post T2I→I2I swap). */\n modelId: string\n aspectRatio?: string\n resolution?: string\n quality?: string\n background?: string\n /** The file the run writes (`outputFormat`); undefined is PNG. */\n outputFormat?: string\n /** A GIF's frames and the time each shows (ms); set only for a GIF. */\n gifFrames?: number\n gifFrameDurationMs?: number\n /** An SVG's level of detail; set only for an SVG. */\n svgLevel?: string\n /** Empty when the caller's values were already valid for `modelId`. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The catalog model `resolveNormalizedImageGen` snaps against: the provider\n * (Nano Banana when none is named), or — with `swapToI2i` and references\n * attached — its i2i sibling, the model the generate-image route and the\n * workflow payload builder then send. That sibling has its OWN catalog entry\n * and lever lists. Exported so a caller that has to decide something about\n * those lists before the snap (whether a photo's size is worth reading) asks\n * about the same model the snap will use.\n */\nexport function normalizedImageGenModelId(opts: {\n provider: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n const provider = typeof opts.provider === \"string\" && opts.provider.length > 0 ? opts.provider : \"nano-banana\"\n return opts.swapToI2i && opts.refCount > 0 ? (T2I_TO_I2I_VARIANT[provider] ?? provider) : provider\n}\n\n/**\n * Whether \"auto\" on a Generate Image request can need its photo's size: the\n * model the snap runs against (`normalizedImageGenModelId` with the swap on)\n * has no native auto. Given the ASSEMBLED reference count, it asks about exactly\n * that model; without one — a write boundary, or a run before its references\n * assemble — about both the provider and its i2i sibling, since references may\n * yet attach.\n */\nexport function imageGenAutoAspectNeedsSourceImage(opts: {\n provider: unknown\n aspectRatio: unknown\n refCount?: number\n}): boolean {\n const asks = (refCount: number) =>\n autoAspectNeedsSourceImage(normalizedImageGenModelId({ provider: opts.provider, refCount, swapToI2i: true }), opts.aspectRatio)\n return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)\n}\n\n/**\n * The output-format levers of a request body or a node's data, typed for\n * `normalizeModelInput`: a non-string format or level is no value, and a GIF's\n * numbers may arrive as numeric strings (a form field, a FieldMapping).\n */\nexport function imageFormatInputOf(source: object): { outputFormat?: string; gifFrames?: number; gifFrameDurationMs?: number; svgLevel?: string } {\n const record = source as Record<string, unknown>\n const str = (v: unknown): string | undefined => (typeof v === \"string\" && v.length > 0 ? v : undefined)\n const num = (v: unknown): number | undefined => {\n const n = typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" ? Number(v) : Number.NaN\n return Number.isFinite(n) ? n : undefined\n }\n return {\n outputFormat: str(record.outputFormat),\n gifFrames: num(record.gifFrames),\n gifFrameDurationMs: num(record.gifFrameDurationMs),\n svgLevel: str(record.svgLevel),\n }\n}\n\n/**\n * Snap an image request's catalog-governed levers to a combination the model\n * actually accepts, and price the credit identifier off the SNAPPED values.\n *\n * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute\n * their credit identifier TWICE — once in the `creditGuard` preHandler (the\n * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a\n * dedicated test asserts the two stay byte-identical (see\n * `backend/src/routes/__tests__/generate-image.test.ts`, \"CHECK === DEBIT\").\n * `resolution` and `quality` are pricing dimensions, so a snap applied at only\n * one of those sites breaks that invariant, and `commit_credits` never collects\n * an upward delta — the reserve IS the charge. Putting the snap inside the\n * primitive makes CHECK, DEBIT and the workflow orchestrator agree by\n * construction rather than by everyone remembering to call a normalizer.\n *\n * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a\n * caller can put a number or an object in `resolution`. Non-strings become\n * `undefined` rather than reaching `normalizeModelInput` as a lie.\n *\n * Unknown model ids pass through untouched (same contract as\n * `normalizeModelInput`) — the route's provider enum is the gate for those.\n *\n * `sourceImage` is the size of the photo the request transforms or is drawn\n * from (an image-to-image / edit source, or Generate Image's first wired\n * reference). It decides \"auto\" on a model without a native auto, and the\n * ratio is not a pricing dimension on any such model (pinned across the catalog\n * by `auto-aspect-source.test.ts`). With `masked` on a model whose masked edit\n * follows its photo (`maskEditMatchesSource`) it also decides the SIZE, a\n * pricing dimension: the CHECK and the DEBIT must then both be given it (the\n * image-to-image route reads it once, before its credit check).\n */\nexport function resolveNormalizedImageGen(opts: {\n provider: string | undefined\n aspectRatio?: unknown\n quality?: unknown\n resolution?: unknown\n renderingSpeed?: unknown\n /** Does not price on its own, but a transparent background can move the size. */\n background?: unknown\n /** The file the run writes, and a GIF's frames and speed or an SVG's level: a GIF and an SVG price differently. */\n outputFormat?: unknown\n gifFrames?: unknown\n gifFrameDurationMs?: unknown\n svgLevel?: unknown\n refCount: number\n swapToI2i?: boolean\n sourceImage?: SourceImageSize\n /** The request carries an inpainting mask: on a model whose masked edit follows its photo, the photo's size decides the ratio and the priced size. */\n masked?: boolean\n}): NormalizedImageGen {\n const str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v.length > 0 ? v : undefined\n\n const modelId = normalizedImageGenModelId(opts)\n\n const n = normalizeModelInput(\n modelId,\n {\n aspectRatio: str(opts.aspectRatio),\n resolution: str(opts.resolution),\n quality: str(opts.quality),\n background: str(opts.background),\n ...imageFormatInputOf(opts),\n },\n { sourceImage: opts.sourceImage, masked: opts.masked },\n )\n\n return {\n identifier: buildCreditModelIdentifier(\n modelId,\n n.quality,\n n.resolution,\n str(opts.renderingSpeed),\n undefined,\n opts.refCount,\n { outputFormat: n.outputFormat, gifFrames: n.gifFrames, svgLevel: n.svgLevel },\n ),\n modelId,\n aspectRatio: n.aspectRatio,\n resolution: n.resolution,\n quality: n.quality,\n background: n.background,\n outputFormat: n.outputFormat,\n gifFrames: n.gifFrames,\n gifFrameDurationMs: n.gifFrameDurationMs,\n svgLevel: n.svgLevel,\n adjustments: n.adjustments,\n }\n}\n\n/**\n * Reference-aware image-generation credit identifier — the SINGLE source of\n * truth shared by the single-node routes (`/v1/generate-image`,\n * `/v1/image-to-image`) and the workflow orchestrator\n * (`payload-builder.ts`). It centralises the two pricing dimensions that must\n * match across both paths or a Flux 2 generation is billed the wrong tier\n * (Flux 2 commits non-metered / has no upward true-up, so the reserved\n * identifier IS the final charge):\n * - `refCount`: the number of reference images sent to the provider (Flux 2\n * bills per ref). generate-image passes the assembled count (0 for pure\n * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.\n * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i\n * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id\n * matches the variant actually invoked. image-to-image is already an i2i\n * provider → pass `false`.\n *\n * The LoRA short-circuit (`flux-lora-character`) stays at the call site because\n * the routing decision needs a DB lookup the routes/orchestrator own.\n */\nexport function resolveImageGenCreditIdentifier(opts: {\n provider: string | undefined\n quality?: string\n resolution?: string\n renderingSpeed?: string\n outputFormat?: unknown\n gifFrames?: unknown\n svgLevel?: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n return resolveNormalizedImageGen(opts).identifier\n}\n\n// T2V-specific credit overrides: some providers have different costs for T2V\n// vs I2V/V2V due to different default resolutions or colliding with image model names.\nconst T2V_CREDIT_OVERRIDES: Record<string, string> = {\n \"grok\": \"grok-i2v\", // T2V grok, same as I2V grok (not image grok = 4 cr)\n \"wan\": \"wan-t2v\", // T2V wan 1080p = (V2V wan 720p = 70 cr)\n \"wan-turbo\": \"wan-turbo-t2v\", // T2V wan-turbo 720p = (I2V wan-turbo 480p = 40 cr)\n}\n\n/**\n * Compute composite model identifier for video models with duration/audio-based pricing.\n * Examples: \"kling-3.0:5s\", \"kling-3.0:10s:audio\", \"seedance-2:8s:720p-ref\"\n *\n * @param provider - Video model key (e.g., \"kling-3.0\")\n * @param duration - Video duration in seconds\n * @param sound - The request's audio: its `sound` flag, or the whole audio\n * request (`{ sound, generateAudio }`) — read through `videoAudioIntent`, the\n * same reading the provider runner sends the model's switch from\n * @param nodeType - Node type for T2V-specific cost overrides\n * @param mode - Quality variant that affects pricing\n * @param resolution - Output resolution (used by Seedance 2 for 480p/720p pricing)\n * @param hasVideoRef - Whether a reference video is connected (Seedance 2 uses a lower per-second rate when true)\n */\n/**\n * LTX 2.3 (Lightricks via Replicate) credit tiers: priced by\n * (resolution-band × duration-seconds). Keys mirror STATIC_CREDIT_COSTS /\n * model_pricing EXACTLY (lowercase band + raw seconds + \"s\"), e.g.\n * \"ltx-2.3-pro:1080p:6s\". This map is the source of truth for the nearest-tier\n * snap below, so an off-catalog (resolution, duration) from a direct API/SDK\n * call maps to a SEEDED price instead of hard-failing (price_not_configured\n * 503). Pro: 6/8/10s at every band. Fast: up to 20s at 1080p, 6/8/10s at 2k/4k.\n */\nconst LTX_DURATION_TIERS: Record<string, Record<string, number[]>> = {\n \"ltx-2.3-pro\": { \"1080p\": [6, 8, 10], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n \"ltx-2.3-fast\": { \"1080p\": [6, 8, 10, 12, 14, 16, 18, 20], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n}\n\n/**\n * The (band, duration) tier the LTX pricing ladder charges for a request, or\n * `undefined` for a non-LTX provider. Extracted so\n * `buildVideoCreditModelIdentifier` and `pricedVideoSelection` read the ladder\n * ONCE — the routes must send the tier they reserved, and a second copy of this\n * math is exactly how the two drift apart.\n *\n * An unknown/absent band falls back to 1080p (LTX's own default, and the band\n * `snapLtxInput` snaps to at the Replicate call), and an off-tier duration\n * snaps to the NEAREST seeded one so the emitted composite always prices.\n */\nfunction ltxPricedTier(\n provider: string,\n resolution?: string,\n duration?: number | string,\n): { band: string; duration: number } | undefined {\n const bands = LTX_DURATION_TIERS[provider]\n if (!bands) return undefined\n const band = bands[String(resolution)] ? String(resolution) : \"1080p\"\n const allowed = bands[band]!\n // The model's own default (catalog `defaultDuration`) when unset, then the\n // nearest rung of THIS band's ladder — the length LTX renders.\n const dur = snapToNearestDuration(pricedOutputDurationSec(provider, duration), allowed)\n return { band, duration: dur }\n}\n\n/**\n * The resolution a provider whose runner NORMALIZES the lever actually renders,\n * in the lowercase spelling of its credit composites — billing collapses\n * through the very normalizer the runner sends, so render == billed for every\n * spelling. `undefined` passes through untouched for every other provider.\n */\nfunction wireNormalizedResolution(provider: string, resolution: string | undefined): string | undefined {\n if (isWan3Provider(provider)) return normalizeWan3Resolution(resolution).toLowerCase()\n if (isViduQ4Provider(provider)) return normalizeViduQ4Resolution(resolution)\n if (isKling4Provider(provider)) return normalizeKling4Resolution(resolution)\n // Kling 4.0 Flash renders 720p whatever it is asked (its runner sends 720p).\n if (isKling4FlashProvider(provider)) return KLING_4_FLASH_RESOLUTION\n if (isGrokVideo15Provider(provider)) return normalizeGrokVideo15Resolution(resolution)\n if (isPixverseV6MaxProvider(provider)) return normalizePixverseV6MaxQuality(resolution)\n return resolution\n}\n\nexport function buildVideoCreditModelIdentifier(\n rawProvider: string,\n duration?: number | string,\n sound?: boolean | VideoAudioRequest,\n nodeType?: \"image-to-video\" | \"text-to-video\",\n mode?: string,\n resolution?: string,\n hasVideoRef?: boolean,\n): string {\n const audio: VideoAudioRequest = typeof sound === \"object\" && sound !== null ? sound : { sound }\n // A retired model (RETIRED_VIDEO_PROVIDERS) is priced as the model it runs as.\n const provider = canonicalVideoProvider(rawProvider) as string\n // A tail-recipe Extend Video provider (Seedance 2.5 / 2.0, Kling 4) is\n // priced on its own rows — the one builder every surface that prices an\n // extend reads.\n if (isTailExtendProvider(provider)) return tailExtendCreditId(provider, duration, resolution)\n // T2V overrides: some providers have different base costs for text-to-video\n let effectiveProvider = provider\n if (nodeType === \"text-to-video\") {\n const override = T2V_CREDIT_OVERRIDES[provider]\n if (override) {\n // If override target also has duration pricing, use it as effective provider\n if (DURATION_PRICED_PROVIDERS.has(override)) {\n effectiveProvider = override\n } else {\n return override\n }\n }\n }\n\n // VEO 3.x resolution-tiered pricing: 720p is the base (no suffix), 1080p gets\n // \":1080p\" (Fast/Lite only), and 4K gets \":4k\" for ALL three tiers — direct-4K\n // generation chains KIE's get-4k-video off the base generation (the base runs\n // at 1080p). Duration is fixed at 8s for VEO so the duration-tier path below\n // does not apply.\n if (isVeoProvider(effectiveProvider)) {\n if (resolution === \"4k\") return `${effectiveProvider}:4k`\n // 1080p tier is Fast/Lite only (Quality has no 1080p surcharge).\n if (resolution === \"1080p\" && VEO_RESOLUTION_TIERED_PROVIDERS.has(effectiveProvider)) return `${effectiveProvider}:1080p`\n return effectiveProvider\n }\n\n // Gemini Omni family (gemini-omni-video + gemini-omni-flash): priced by\n // (resolution-band × duration), with a flat per-generation rate when a source\n // video is supplied (V2V). Lowercase \"4k\". The prefix is TEMPLATED from the\n // provider id, so a further Omni SKU needs no edit here — it only has to join\n // GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT\n // in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.\n // A per-second SKU (Omni Flash 1.2) prices on the `:<N>s:<res>` ladder below.\n if (isGeminiOmniProvider(effectiveProvider) && !isGeminiOmniPerSecondProvider(effectiveProvider)) {\n if (hasVideoRef) {\n return resolution === \"4k\" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`\n }\n // The rendered length through the catalog funnel (nearest legal tier, the\n // model's own default when unset) so the composite is always a SEEDED one.\n const d = pricedOutputDurationSec(effectiveProvider, duration)\n return resolution === \"4k\" ? `${effectiveProvider}:4k:${d}` : `${effectiveProvider}:${d}`\n }\n\n // LTX 2.3: priced by (resolution-band × duration-seconds). The RESERVE must be\n // the correct composite — commit_credits (migration 176) only refunds a surplus\n // (actual < reserved) and NEVER collects an upward delta, so an under-reserved\n // LTX run (the bare-id default = cheapest 1080p:6s tier) stays under-charged\n // even with meteredCost:true. Snap to a seeded tier so the id always prices.\n const ltxTier = ltxPricedTier(effectiveProvider, resolution, duration)\n if (ltxTier) {\n return `${effectiveProvider}:${ltxTier.band}:${ltxTier.duration}s`\n }\n\n if (!DURATION_PRICED_PROVIDERS.has(effectiveProvider)) {\n return effectiveProvider\n }\n\n // A named-provider request with NO duration renders the model's own default\n // (kie/models.ts extraParams), so price that default — not the global 5s —\n // for providers whose per-second tiers wouldn't snap 5 up to it\n // (minimax-h3, seedance-2-5). One helper, shared with the dynamic\n // reference-video reservations, so the tier and the scaled reserve agree.\n const durationSec = pricedOutputDurationSec(effectiveProvider, duration)\n const tiers = VIDEO_DURATION_TIERS[effectiveProvider]\n if (!tiers) return effectiveProvider\n\n // Find the matching duration tier\n const tier = tiers.find(t => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1]\n let identifier = `${effectiveProvider}:${tier.suffix}`\n\n // Append mode suffix for providers with quality-tiered pricing\n // \"high\" comes from I2V videoSize field, \"pro\" comes from T2V mode field\n if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === \"high\" || mode === \"pro\")) {\n identifier += \":high\"\n }\n\n // Seedance 2.0 family: per-second billing with resolution + video-ref dimensions.\n // KIE accepts 480p / 720p / 1080p natively; per-second rates rise non-linearly\n // so each tier gets its own composite identifier.\n if (RESOLUTION_VIDEO_REF_PRICING.has(effectiveProvider)) {\n // Clamp to the model's catalog resolutions (single source of truth): e.g.\n // seedance-2-mini exposes only 480p/720p, so a stale/explicit 1080p (or 4k)\n // maps to its top priced tier instead of emitting an unpriced composite\n // (which the hard-fail credit guard would 503 on at runtime).\n const supported = MODEL_CATALOG[effectiveProvider]?.resolutions ?? [\"480p\", \"720p\", \"1080p\"]\n // An OMITTED resolution renders the model's KIE-side default, so price that\n // default rather than the cheapest tier — otherwise an intent-less request\n // reserves 480p against a 720p render and commit_credits (refund-only) can\n // never collect the delta. Providers without an entry keep the historical\n // 480p fallback, so this cannot reprice anything already live.\n const requested = resolution ?? PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const want = requested === \"4k\" ? \"4k\" : requested === \"1080p\" ? \"1080p\" : requested === \"720p\" ? \"720p\" : \"480p\"\n // Unsupported (e.g. a stale 1080p on seedance-2-mini) clamps to the model's\n // top priced tier so the emitted composite is always seeded.\n const res = supported.includes(want) ? want : (supported[supported.length - 1] ?? \"480p\")\n identifier += `:${res}`\n if (hasVideoRef) identifier += \"-ref\"\n }\n\n // Duration × resolution pricing without a -ref dimension. Resolutions\n // outside the provider's priced tiers (or undefined) collapse to the first\n // (default) tier so the emitted composite is always seeded — the hard-fail\n // guard fuzzes the whole resolution space.\n const resTiers = RESOLUTION_DURATION_PRICING[effectiveProvider]\n if (resTiers) {\n // The \"default tier\" is the provider's DECLARED default when it has one\n // (PRICING_DEFAULT_RESOLUTION — wan-3 renders 720p, not the cheapest tier),\n // otherwise the first listed tier. Declaring it explicitly means a cosmetic\n // reorder of the tier list can never reprice a live model, and an OMITTED\n // *or* unsupported resolution both land on what actually renders instead of\n // on the cheapest row (commit_credits refunds a surplus but can never\n // collect a shortfall). Behaviour-neutral for every member without a\n // declared default.\n const declaredDefault = PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const fallback = declaredDefault && resTiers.includes(declaredDefault) ? declaredDefault : resTiers[0]!\n // Wan 3.0 renders through `normalizeWan3Resolution`, which is CASE-INSENSITIVE\n // (\"1080P\" — KIE's own OpenAPI enum spelling, and the natural value for an\n // integrator reading the provider docs — renders 1080P). The tier list here is\n // lowercase and `Array.includes` is case-sensitive, so without this the render\n // path and the billing path disagree: \"1080P\" rendered the top tier and billed\n // the 720p row, a shortfall `commit_credits` (refund-only) can never collect.\n // Collapsing through the SAME normalizer the runner uses makes render == billed\n // by construction for every spelling, including garbage (→ the declared 720p).\n // Scoped to the families whose runner normalizes on purpose (Wan 3.0, Vidu\n // Q4, Kling 4.0, Grok Imagine Video 1.5, PixVerse V6 Max): the other RESOLUTION_DURATION_PRICING members pass `resolution` to\n // their wire verbatim, so case-folding their billing without probing their\n // wire would reprice live models.\n const requested = wireNormalizedResolution(effectiveProvider, resolution)\n const res = requested && resTiers.includes(requested) ? requested : fallback\n identifier += `:${res}`\n // A reference VIDEO bills at its own per-second rate (Kling 4.0).\n if (hasVideoRef && VIDEO_REF_RATE_PROVIDERS.has(effectiveProvider)) identifier += \"-ref\"\n }\n\n // MiniMax Hailuo 3 (768P lever, 2026-08-03): bare duration composites stay\n // the 2K (default) rate — byte-identical to the pre-lever seeded rows, so\n // existing workflows and admin overrides keep their ids — and only a\n // verified 768P selection appends \":768p\". normalizeMinimaxH3Resolution\n // collapses anything else to 2K, matching what KIE renders for an\n // omitted/unknown value, so billing can never undercut the render.\n if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === \"768P\") {\n identifier += \":768p\"\n }\n\n // Append the audio suffix LAST, after every other dimension\n // (`kling-3.0:10s:audio`, `pixverse-v6-max:5s:720p:audio`). The request's\n // audio is read by `videoAudioIntent` — the reading `applyVideoAudioToggle`\n // sends the model's switch from — and with no intent falls back to the\n // model's own default (capability `defaultOn` — kling-3.0 and PixVerse V6 Max\n // generate audio unless explicitly disabled), so a request is billed for the\n // audio it actually produces.\n if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && videoAudioPricedOn(effectiveProvider, audio)) {\n identifier += \":audio\"\n }\n\n return identifier\n}\n\n/**\n * The credit identifier a video GENERATION node is quoted at — Generate Video\n * (and the legacy Image/Text to Video nodes) and the Video to Video Seedance\n * edit lane, on every surface that quotes one: the node's cost pill, the\n * editor's run estimate, the prompt modal and the backend pre-run estimator.\n *\n * It applies the request levers the run applies BEFORE it prices\n * (payload-builder's `resolveVideoRequestNorm`): the model's UI resolution fill\n * when the node names none (`uiResolutionFill` — what the run sends), then the\n * catalog normalizer `normalizeVideoRequestParams`, which also owns the Seedance\n * Draft rule (a draft is priced AND sent at 480p whatever resolution came with\n * it). Without that, a node with no resolution was quoted at the identifier's\n * own default band (720p on Seedance 2.5) while the run sent and reserved 480p.\n *\n * `hasVideoRef` must come from the GRAPH (a wired reference-video edge, e.g.\n * `countRefModalityEdges(edges, id, \"video\") > 0`), never node data: nothing\n * writes `referenceVideoUrls` into a video node, so reading it there always\n * quoted the plain ladder for a run that reserves on the `-ref` one.\n */\nexport function videoGenerationCreditId(args: {\n provider: string\n duration?: number | string\n sound?: boolean\n /** The request's `generateAudio`, read after `sound` where the model reads it (`videoAudioIntent`). */\n generateAudio?: boolean\n nodeType?: \"image-to-video\" | \"text-to-video\"\n mode?: string\n resolution?: string\n draft?: boolean\n hasVideoRef?: boolean\n}): string {\n const { resolution } = normalizeVideoRequestParams(args.provider, {\n resolution: args.resolution ?? uiResolutionFill(args.provider),\n draft: args.draft === true,\n })\n return buildVideoCreditModelIdentifier(\n args.provider,\n args.duration,\n { sound: args.sound, generateAudio: args.generateAudio },\n args.nodeType ?? \"image-to-video\",\n args.mode,\n resolution,\n args.hasVideoRef === true,\n )\n}\n\n/**\n * The credit identifier a Video to Video node's Seedance EDIT lane reserves\n * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit\n * shape with the source clip as reference video 1 — so it prices on the\n * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the\n * measured settlement refunds down to what was actually delivered.\n *\n * A thin call into {@link videoGenerationCreditId}, so a Generate Video node\n * making the same KIE call (Seedance, Auto, a wired reference video) is quoted\n * the same id. FOUR surfaces must agree on it exactly: the orchestrator's\n * reservation (payload-builder.ts), the backend pre-run estimator\n * (ee/billing/credits.ts), the node's cost pill, and the frontend run-level\n * estimate (config-panels/helpers.ts). A quote that disagrees with the reserve\n * is the documented `price_not_configured` / blank-pill trap.\n *\n * `resolution` is the node's one `v2vResolution` field; when unset the model's\n * own UI fill is priced, which is what the lane will send. `draft` is the\n * node's Seedance Draft toggle (priced at 480p).\n */\nexport function seedanceVideoEditCreditId(provider: string, resolution?: string, draft?: boolean): string {\n return videoGenerationCreditId({\n provider,\n duration: VIDEO_DURATION_AUTO,\n nodeType: \"text-to-video\",\n resolution,\n draft,\n hasVideoRef: true,\n })\n}\n\n/** The resolution a tail-recipe extend that names none, or one it does not offer, is priced and run at (every one offers it). */\nconst TAIL_EXTEND_DEFAULT_RESOLUTION = \"720p\"\n\n/**\n * The resolution a tail-recipe Extend Video run (Seedance 2.5 / 2.0, Kling 4)\n * is priced at, and so the one it must render at: the requested one when it is\n * among the provider's catalog `resolutions`, else 720p (also when none is\n * named). The workflow run queues it and the worker holds the job to it, so a\n * stored or sent resolution the model does not offer (`4k`, or `480p` on Kling\n * 4) can never render above, or bill apart from, the row it reserved.\n */\nexport function tailExtendResolution(provider: TailExtendProvider, resolution?: unknown): string {\n return typeof resolution === \"string\" && MODEL_CATALOG[provider]?.resolutions?.includes(resolution)\n ? resolution\n : TAIL_EXTEND_DEFAULT_RESOLUTION\n}\n\n/**\n * The credit identifier one tail-recipe Extend Video run is priced at — the\n * one builder every surface that prices it reads (the route's guard and\n * reservation, the workflow reservation and estimate, the editor), so none of\n * them can name a different row.\n *\n * The seconds added snap into the provider's catalog `durations` (its catalog\n * `defaultDuration` when unset, through {@link pricedOutputDurationSec}); the\n * resolution is {@link tailExtendResolution}'s. Each provider has its own\n * rows, one per second of its window and resolution: `<provider>:<N>s:<res>`\n * (`seedance-2-5-extend` 4–30 s, `seedance-2-0-extend` 4–15 s, both at\n * 480p / 720p / 1080p; `kling-4-extend` 3–30 s at 720p / 1080p).\n *\n * A retired id (`seedance-2-extend`) is not a {@link TailExtendProvider}:\n * pass a stored or sent provider through `canonicalVideoProvider` first.\n */\nexport function tailExtendCreditId(\n provider: TailExtendProvider,\n duration?: number | string,\n resolution?: string,\n): string {\n return `${provider}:${pricedOutputDurationSec(provider, duration)}s:${tailExtendResolution(provider, resolution)}`\n}\n\n/** @deprecated Use {@link tailExtendResolution}, which also answers for Kling 4 Extend. */\nexport function seedanceExtendResolution(provider: SeedanceExtendProvider, resolution?: unknown): string {\n return tailExtendResolution(provider, resolution)\n}\n\n/** @deprecated Use {@link tailExtendCreditId}, which also answers for Kling 4 Extend. */\nexport function seedanceExtendCreditId(\n provider: SeedanceExtendProvider,\n duration?: number | string,\n resolution?: string,\n): string {\n return tailExtendCreditId(provider, duration, resolution)\n}\n\n/** What the video credit identifier PRICES for a request, for the levers whose\n * priced value must also be the value we SEND. */\nexport interface PricedVideoSelection {\n /** The resolution band the reservation is priced at when the request omitted\n * one — and only where the platform DECLARES that band as the provider's own\n * default. `undefined` means \"leave `resolution` exactly as the request had\n * it\": either the caller supplied one, or the provider's real default is not\n * known to be the band the identifier assumes. */\n resolution?: string\n /** The length the reservation is priced at and the wire carries, for a\n * provider whose price follows the clip length (LTX's seeded tier, the KIE\n * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:\n * their duration passes through. */\n duration?: number\n /** Non-empty only for a lever the caller ASKED for and did not get (a 7s\n * request snapped to the 6s tier). Filling an omitted lever is a disclosure of\n * the price already being charged, not a correction, so it reports nothing. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The other half of the video money path: `normalizeVideoRequestParams` snaps a\n * value the CATALOG governs; this returns the value the PRICE ladder governs.\n *\n * Two defects it closes, both of the same shape — the identifier prices one\n * thing and the wire carries another, and `commit_credits` (migration 176) only\n * ever refunds a surplus, so the reservation is the final charge:\n *\n * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted\n * `resolution` as a concrete band (LTX → 1080p; a\n * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving\n * the key unset then lets the provider pick — documented for the KIE members\n * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on\n * Replicate. Sending the band we priced makes the two agree by construction.\n *\n * The fill is deliberately limited to providers with a DECLARED default.\n * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the\n * cheapest tier for a resolution-priced provider with no\n * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified\n * provider default: seedance-2 / -fast / -mini pin `resolution: \"720p\"`\n * KIE-side while the identifier prices 480p, so filling 480p would downgrade\n * the render to match a price we already know is wrong. That mismatch is a\n * pre-existing identifier bug and is fixed by seeding the row, not here.\n *\n * 2. **Duration.** Every provider whose price follows the clip length is\n * charged at the length it RENDERS: its own default when the request named\n * none (catalog `defaultDuration`), the nearest length it offers otherwise\n * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is\n * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;\n * sending 7s would bill six and render seven. The same value is returned for\n * the other length-priced providers (the KIE ladders, Gemini Omni), so what\n * is priced is what is sent. Auto (-1) is the model's call and is untouched.\n *\n * Pure, and IDEMPOTENT against the identifier: feeding its output back in\n * cannot move the reserved tier. `video-request-normalize.test.ts` proves that\n * over every provider × resolution × duration.\n */\nexport function pricedVideoSelection(opts: {\n provider: string\n resolution?: string\n duration?: number | string\n}): PricedVideoSelection {\n const adjustments: ModelInputAdjustment[] = []\n const ltx = ltxPricedTier(opts.provider, opts.resolution, opts.duration)\n\n // The band the request will be priced AND rendered at. An explicit value\n // always wins — this only ever fills an omission.\n const resolution = opts.resolution\n ?? (ltx ? ltx.band : PRICING_DEFAULT_RESOLUTION[opts.provider])\n\n const requested = typeof opts.duration === \"string\" ? parseInt(opts.duration, 10) : opts.duration\n const asked = requested !== undefined && !Number.isNaN(requested)\n\n // Every provider whose price follows the clip length sends the length it is\n // CHARGED at (the catalog funnel: its own default when unset, the nearest\n // legal length otherwise). Auto (-1) is the model's call and is left alone.\n const lengthPriced = !!ltx || DURATION_PRICED_PROVIDERS.has(opts.provider) || isGeminiOmniProvider(opts.provider)\n if (!lengthPriced || (!ltx && asked && requested! <= 0)) return { resolution, adjustments }\n\n const duration = ltx ? ltx.duration : pricedOutputDurationSec(opts.provider, opts.duration)\n if (asked && requested !== duration) {\n adjustments.push({\n field: \"duration\",\n from: requested!,\n to: duration,\n reason: ltx\n ? `LTX renders ${ltx.band} in ${ltx.duration}s steps — using ${ltx.duration}s instead of ${requested}s.`\n : `${opts.provider} renders ${duration}s clips at the nearest length it offers — using ${duration}s instead of ${requested}s.`,\n })\n }\n return { resolution, duration, adjustments }\n}\n\n/**\n * Compute composite model identifier for motion control with duration-tiered pricing.\n * Examples: \"kling-3.0-motion:10s\", \"kling-3.0-motion:1080p:15s\", \"motion-transfer:5s\"\n *\n * Wan Animate providers use resolution-tiered pricing (not per-second):\n * \"wan-animate-move\" (480p default), \"wan-animate-move:580p\", \"wan-animate-move:720p\"\n *\n * @param provider - Motion control provider key (\"kling\" for 2.6, \"kling-3.0\", \"wan-animate-move\", \"wan-animate-replace\")\n * @param resolution - \"720p\" or \"1080p\" (Kling), \"480p\" or \"580p\" or \"720p\" (Wan Animate); a size the\n * model does not have is priced as the size it runs at (`motionTransferResolution`: Wan Animate's 1080p as 720p)\n * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)\n */\nexport function buildMotionCreditModelIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n return motionCreditIdentifier(provider, motionTransferResolution(provider, resolution).resolution, videoDuration)\n}\n\n/** The catalog model a Motion Transfer option runs: the base of the id it is billed under. */\nfunction motionModelOf(provider: string): string {\n return motionCreditIdentifier(provider, \"720p\").split(\":\")[0]!\n}\n\n/**\n * Motion models still SENT at a size their catalog entry does not list, as\n * before Wan Animate had entries: Kling 2.6 and Kling 3.0 Motion Control\n * (720p and 1080p). Their price is the same either way (any size but 1080p is\n * charged on the 720p rows), and Kling 3.0's provider already sends such a\n * size as 720p; whether Kling 2.6 should too is not decided. Only shrinks.\n */\nconst MOTION_MODELS_SENT_AS_NAMED: ReadonlySet<string> = new Set([\"motion-transfer\", \"kling-3.0-motion\"])\n\n/** The size a Motion Transfer run is sent and charged at, and what moved. */\nexport interface MotionTransferResolution {\n resolution: string\n /** Empty when the size it names is the one it runs at. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The size a Motion Transfer run is sent and charged at (decided 2026-11-12):\n * the size it names, held to the catalog entry of the model its option runs\n * (`normalizeModelInput`), so a size that model does not have moves to the\n * entry's `defaultResolution` — a Wan Animate request at 1080p runs, and is\n * charged, as 720p. The route, the workflow build, the MCP workflow writes and\n * every price (through `buildMotionCreditModelIdentifier`) read this one rule.\n */\nexport function motionTransferResolution(provider: string, resolution: string): MotionTransferResolution {\n const model = motionModelOf(provider)\n if (MOTION_MODELS_SENT_AS_NAMED.has(model)) return { resolution, adjustments: [] }\n const normalized = normalizeModelInput(model, { resolution })\n if (normalized.resolution === undefined) return { resolution, adjustments: [] }\n return { resolution: normalized.resolution, adjustments: normalized.adjustments }\n}\n\nfunction motionCreditIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n // Wan Animate providers use resolution-tiered pricing (not duration-based)\n if (provider === \"wan-animate-move\" || provider === \"wan-animate-replace\") {\n // 480p is the default (base identifier), 580p and 720p get composite suffix\n if (resolution === \"580p\" || resolution === \"720p\") {\n return `${provider}:${resolution}`\n }\n return provider\n }\n\n const raw = videoDuration ?? 10\n const durationSec = Math.floor(Number.isNaN(raw) ? 10 : raw) // default 10s; floor to match KIE per-second billing\n const tier = MOTION_DURATION_TIERS.find(t => durationSec <= t.maxSeconds)\n ?? MOTION_DURATION_TIERS[MOTION_DURATION_TIERS.length - 1]\n\n const base = provider === \"kling-3.0\" ? \"kling-3.0-motion\" : \"motion-transfer\"\n const resSuffix = resolution === \"1080p\" ? \":1080p\" : \"\"\n return `${base}${resSuffix}:${tier.suffix}`\n}\n\n/**\n * The Suno operations whose credit key depends on the model VERSION.\n *\n * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard\n * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts\n * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat\n * per-operation key and ignores the version the node carries — mashup (:648),\n * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),\n * replace-section (:710), style-boost (:771), convert-wav (:962),\n * lyrics (:482), music-video (:594), voice (:1218).\n *\n * Anything that QUOTES a Suno price — a dropdown row, a node badge, the\n * workflow-credit estimator — must follow the same split, or it displays a\n * credit key the route never charges.\n */\nexport const SUNO_VERSION_PRICED_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n] as const\n\n/**\n * The seven Suno operations that appear behind a select/dropdown UI (model\n * pickers, node badges, the credit estimator) — the three version-priced\n * operations above, plus the four flat-key operations exercised by\n * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the\n * model dropdowns, node badges) can iterate or count it without redeclaring\n * the list and drifting from this one.\n */\nexport const SUNO_SELECT_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-upload-extend\",\n] as const\n\n/**\n * Adjust Speed's price id: motion-compensated (\"smooth\") interpolation is its\n * own, dearer tier. The route, the workflow run, and the editor's badge and\n * run estimate all price through this, so none of them can quote the fast tier\n * for a smooth run.\n */\nexport function speedRampCreditId(quality: unknown): \"speed-ramp\" | \"speed-ramp:smooth\" {\n return quality === \"smooth\" ? \"speed-ramp:smooth\" : \"speed-ramp\"\n}\n\n/**\n * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,\n * cheaper per-output-minute row; a `final` render keeps the bare id. One id per\n * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything\n * that is not exactly \"proxy\" is the final, as the route and the node default\n * it. The route, the workflow run, and the editor's badge and run estimate all\n * price through this; the job itself is always named `apply-edl`.\n */\nexport function applyEdlCreditId(quality: unknown): \"apply-edl\" | \"apply-edl:proxy\" {\n return quality === \"proxy\" ? \"apply-edl:proxy\" : \"apply-edl\"\n}\n\n/**\n * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by\n * how many speakers it composites at once. `standard` — at most two tiles on\n * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which\n * tier a render is in is the render rule's to say (the app's\n * `@nodaro/render-rules`), never this vocabulary's.\n */\nexport const SPEAKER_VIEW_PRICE_TIERS = [\"standard\", \"complex\"] as const\nexport type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number]\n\nexport type SpeakerViewCreditId = \"speaker-view\" | \"speaker-view:proxy\" | \"speaker-view:complex\" | \"speaker-view:complex:proxy\"\n\n/** Every id `speakerViewCreditId` can name. */\nexport const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[] = Object.freeze([\n \"speaker-view\",\n \"speaker-view:proxy\",\n \"speaker-view:complex\",\n \"speaker-view:complex:proxy\",\n] as const)\n\n/**\n * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers\n * decided 2026-10-10): a Preview (`quality` \"proxy\") reserves on its own row,\n * anything else on the final's, and each in its price tier — `standard` on\n * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /\n * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent\n * included) names the `complex` row: a caller that cannot tell quotes high,\n * never low. The job is always named `speaker-view`; only its credit id\n * follows the quality and the tier.\n */\nexport function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId {\n const proxy = quality === \"proxy\"\n if (tier === \"standard\") return proxy ? \"speaker-view:proxy\" : \"speaker-view\"\n return proxy ? \"speaker-view:complex:proxy\" : \"speaker-view:complex\"\n}\n\n/**\n * OUR Nodaro credit key for a Suno operation, given the model version and the\n * operation (which is also the node type and the BullMQ job name).\n *\n * This is the single source of truth for the Suno pricing contract, shared by\n * the reservation path (routes/suno.ts creditGuard), the egress seam\n * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),\n * both workflow-credit estimators (ee/billing/credits.ts and the frontend\n * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno\n * node badges. It is a billing key — NEVER a KIE provider id — which is what\n * satisfies the B3 egress invariant.\n *\n * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no\n * entry (V4 / V4_5 / V4_5ALL / V4_5PLUS) falls back to the operation key, and a\n * non-version-priced operation is returned unchanged.\n */\nexport function sunoCreditType(model: string | undefined, operation: string): string {\n if (!(SUNO_VERSION_PRICED_OPERATIONS as readonly string[]).includes(operation)) {\n return operation\n }\n return (model && SUNO_VERSION_CREDIT_KEYS[model]) || operation\n}\n\n/**\n * Suno version → Nodaro credit key for the version-priced operations. One row\n * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`\n * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version\n * without touching code. Every ACTIVE version MUST have a row here — guarded\n * by `__tests__/suno-credit-type.test.ts` (a new active version with no key\n * would silently bill at the operation key).\n */\nexport const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>> = {\n V6: \"suno-v6\",\n V6_WILD: \"suno-v6_wild\",\n V6_MINI: \"suno-v6_mini\",\n V5_5: \"suno-v5_5\",\n V5: \"suno-v5\",\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isGptImage26Tiered, isGptImage26I2i, GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES } from './chunk-RGNHHIMN.js';
|
|
2
|
-
import { isMinimaxH3Image, isSeedream55, isMinimaxH3ImageI2i, isSeedream55I2i, getModel } from './chunk-
|
|
2
|
+
import { isMinimaxH3Image, isSeedream55, isMinimaxH3ImageI2i, isSeedream55I2i, getModel } from './chunk-PSKZKLDG.js';
|
|
3
3
|
|
|
4
4
|
// src/input-image-pricing.ts
|
|
5
5
|
function isPricedPerInputImage(model) {
|
|
@@ -38,5 +38,5 @@ function safetyRetryPolicy(modelId) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export { isPricedPerInputImage, isPricedPerInputImageEdit, pricedEstimatedImages, pricedSentImages, safetyRetryPolicy };
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
41
|
+
//# sourceMappingURL=chunk-CZ5IQB3L.js.map
|
|
42
|
+
//# sourceMappingURL=chunk-CZ5IQB3L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/input-image-pricing.ts","../src/safety-retry-policy.ts"],"names":[],"mappings":";;;;AAeO,SAAS,sBAAsB,KAAA,EAAyB;AAC7D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,KAAa,kBAAA,CAA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,CAAK,cAAc,IAC1B,WAAA,IACC,cAAA,CAAe,IAAA,CAAK,SAAS,IAAI,kCAAA,GAAqC,CAAA,CAAA,IACtE,yBAAA,CAA0B,KAAK,IAAI,CAAA,GAAI,CAAA,CAAA;AAE5C;;;ACjDO,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-CZ5IQB3L.js","sourcesContent":["/**\n * The image models whose price depends on how many input images a run sends:\n * GPT Image 2.6 Flare and Sunburst, MiniMax H3 Image and Seedream 5.5. Every place that\n * prices a run counts those images through here, so a model that joins\n * `isPricedPerInputImage` is counted on every path at once.\n */\nimport {\n GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES,\n isGptImage26I2i,\n isGptImage26Tiered,\n} from \"./gpt-image-2-6.js\"\nimport { isMinimaxH3Image, isMinimaxH3ImageI2i } from \"./minimax-h3-image.js\"\nimport { isSeedream55, isSeedream55I2i } from \"./seedream-5-5.js\"\n\n/** True for a model whose price counts the input images a run sends. */\nexport function isPricedPerInputImage(model: unknown): boolean {\n return typeof model === \"string\" && (isGptImage26Tiered(model) || isMinimaxH3Image(model) || isSeedream55(model))\n}\n\n/** True for the edit id of such a model: it always sends at least its source. */\nexport function isPricedPerInputImageEdit(model: unknown): boolean {\n return typeof model === \"string\" && (isGptImage26I2i(model) || isMinimaxH3ImageI2i(model) || isSeedream55I2i(model))\n}\n\n/**\n * The images a Generate Image run sends its provider: its references and, when\n * it edits a base image, that image too (the worker puts it first, unless it is\n * already one of the references). Counted only on a model priced per input\n * image; any other model is priced on its references alone, as before.\n */\nexport function pricedSentImages(\n provider: string | undefined,\n references: readonly string[],\n baseImageUrl: unknown,\n): number {\n const countsBase =\n isPricedPerInputImage(provider) &&\n typeof baseImageUrl === \"string\" &&\n baseImageUrl.length > 0 &&\n !references.includes(baseImageUrl)\n return references.length + (countsBase ? 1 : 0)\n}\n\nfunction namesMoodboard(direction: unknown): boolean {\n if (direction === null || typeof direction !== \"object\") return false\n const style = (direction as Record<string, unknown>).style\n return (Array.isArray(style) ? style : [style]).some(\n (value) => typeof value === \"string\" && value.startsWith(\"moodboard:\"),\n )\n}\n\n/**\n * The input images a workflow estimate counts for one node on a model priced\n * per input image: every list on the node, its source or base image, what is\n * wired in, a moodboard its direction names (at the most a moodboard holds),\n * and an edit model's own source. An estimate may over-quote, never under.\n */\nexport function pricedEstimatedImages(\n model: string,\n data: Record<string, unknown>,\n wiredImages: number,\n): number {\n const listed = (v: unknown) => (Array.isArray(v) ? v.length : 0)\n const single = (v: unknown) => (typeof v === \"string\" && v.length > 0 ? 1 : 0)\n return (\n listed(data.referenceImageUrls) +\n listed(data.characterDefinitionIds) +\n listed(data.extraRefs) +\n single(data.referenceImageUrl) +\n single(data.baseImageUrl) +\n single(data.sourceImageUrl) +\n wiredImages +\n (namesMoodboard(data.direction) ? GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES : 0) +\n (isPricedPerInputImageEdit(model) ? 1 : 0)\n )\n}\n","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"]}
|