@nodaro/shared 3.59.0 → 3.60.1
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-QE7W4YIK.cjs → chunk-5G23AJBU.cjs} +6 -6
- package/dist/{chunk-QE7W4YIK.cjs.map → chunk-5G23AJBU.cjs.map} +1 -1
- package/dist/{chunk-DKZGLIFW.cjs → chunk-5HK5Z5OB.cjs} +4 -4
- package/dist/{chunk-DKZGLIFW.cjs.map → chunk-5HK5Z5OB.cjs.map} +1 -1
- package/dist/{chunk-RSXQOFM7.cjs → chunk-5Y42RIGY.cjs} +8 -8
- package/dist/{chunk-RSXQOFM7.cjs.map → chunk-5Y42RIGY.cjs.map} +1 -1
- package/dist/{chunk-FHCMYGBV.js → chunk-6AJOTEVC.js} +3 -3
- package/dist/{chunk-FHCMYGBV.js.map → chunk-6AJOTEVC.js.map} +1 -1
- package/dist/{chunk-ZVUVSD5X.js → chunk-6Q6SI7AG.js} +3 -3
- package/dist/{chunk-ZVUVSD5X.js.map → chunk-6Q6SI7AG.js.map} +1 -1
- package/dist/{chunk-V3NONYLA.cjs → chunk-A6HRY3WF.cjs} +269 -18
- package/dist/chunk-A6HRY3WF.cjs.map +1 -0
- package/dist/{chunk-D574HZ35.cjs → chunk-AXT7YNOR.cjs} +51 -51
- package/dist/{chunk-D574HZ35.cjs.map → chunk-AXT7YNOR.cjs.map} +1 -1
- package/dist/{chunk-TA7ODVYJ.js → chunk-AZGONXWV.js} +4 -4
- package/dist/{chunk-TA7ODVYJ.js.map → chunk-AZGONXWV.js.map} +1 -1
- package/dist/{chunk-OFL4UH6L.cjs → chunk-BDXXOEBZ.cjs} +80 -57
- package/dist/chunk-BDXXOEBZ.cjs.map +1 -0
- package/dist/{chunk-NZRG5CXQ.cjs → chunk-BLJUCPMV.cjs} +5 -2
- package/dist/chunk-BLJUCPMV.cjs.map +1 -0
- package/dist/{chunk-NHZWVKGV.cjs → chunk-BXNPO3PL.cjs} +8 -8
- package/dist/{chunk-NHZWVKGV.cjs.map → chunk-BXNPO3PL.cjs.map} +1 -1
- package/dist/{chunk-UPD7W2KJ.cjs → chunk-CIOXUPCJ.cjs} +12 -12
- package/dist/{chunk-UPD7W2KJ.cjs.map → chunk-CIOXUPCJ.cjs.map} +1 -1
- package/dist/{chunk-YE4EDT57.cjs → chunk-DQIJPDHC.cjs} +11 -11
- package/dist/{chunk-YE4EDT57.cjs.map → chunk-DQIJPDHC.cjs.map} +1 -1
- package/dist/{chunk-UMPZR56R.js → chunk-DS2TOM32.js} +3 -3
- package/dist/{chunk-UMPZR56R.js.map → chunk-DS2TOM32.js.map} +1 -1
- package/dist/{chunk-YSEJOJNQ.js → chunk-EN2YI5TV.js} +3 -3
- package/dist/{chunk-YSEJOJNQ.js.map → chunk-EN2YI5TV.js.map} +1 -1
- package/dist/{chunk-ZU56AMFK.js → chunk-G6GMY5BC.js} +20 -4
- package/dist/chunk-G6GMY5BC.js.map +1 -0
- package/dist/chunk-G7ZYZQKO.cjs +27 -0
- package/dist/{chunk-6VXDW2U3.cjs.map → chunk-G7ZYZQKO.cjs.map} +1 -1
- package/dist/{chunk-PEATSEAD.cjs → chunk-GNPJ2JLE.cjs} +6 -6
- package/dist/{chunk-PEATSEAD.cjs.map → chunk-GNPJ2JLE.cjs.map} +1 -1
- package/dist/{chunk-VLQW4CVW.cjs → chunk-GWBQ3GPO.cjs} +41 -21
- package/dist/chunk-GWBQ3GPO.cjs.map +1 -0
- package/dist/{chunk-P7KSB5T6.cjs → chunk-HDHLZK7C.cjs} +5 -5
- package/dist/{chunk-P7KSB5T6.cjs.map → chunk-HDHLZK7C.cjs.map} +1 -1
- package/dist/{chunk-QLLR7GUY.cjs → chunk-HNEF2N5C.cjs} +5 -5
- package/dist/{chunk-QLLR7GUY.cjs.map → chunk-HNEF2N5C.cjs.map} +1 -1
- package/dist/{chunk-7JM5EZF3.cjs → chunk-HOKWJXHA.cjs} +13 -13
- package/dist/{chunk-7JM5EZF3.cjs.map → chunk-HOKWJXHA.cjs.map} +1 -1
- package/dist/{chunk-2S7YYCRT.js → chunk-HYBACFYW.js} +4 -4
- package/dist/chunk-HYBACFYW.js.map +1 -0
- package/dist/{chunk-RGBNOCIO.js → chunk-ICDLYU4I.js} +9 -9
- package/dist/{chunk-RGBNOCIO.js.map → chunk-ICDLYU4I.js.map} +1 -1
- package/dist/{chunk-FJCRWDU5.js → chunk-IV6IDECY.js} +4 -4
- package/dist/{chunk-FJCRWDU5.js.map → chunk-IV6IDECY.js.map} +1 -1
- package/dist/{chunk-PIX4OCCQ.js → chunk-JKZVRKN3.js} +36 -14
- package/dist/chunk-JKZVRKN3.js.map +1 -0
- package/dist/{chunk-MTXVODG3.js → chunk-KJZVQIN4.js} +3 -3
- package/dist/{chunk-MTXVODG3.js.map → chunk-KJZVQIN4.js.map} +1 -1
- package/dist/{chunk-2VQHPILW.js → chunk-KOLC7AF2.js} +262 -19
- package/dist/chunk-KOLC7AF2.js.map +1 -0
- package/dist/{chunk-IP7QOHWQ.js → chunk-LN3EVFRS.js} +5 -5
- package/dist/{chunk-IP7QOHWQ.js.map → chunk-LN3EVFRS.js.map} +1 -1
- package/dist/{chunk-EO4W4MA3.js → chunk-MHY47BLL.js} +4 -4
- package/dist/{chunk-EO4W4MA3.js.map → chunk-MHY47BLL.js.map} +1 -1
- package/dist/{chunk-AWS4BWEC.js → chunk-Q6IES3U2.js} +5 -2
- package/dist/chunk-Q6IES3U2.js.map +1 -0
- package/dist/{chunk-62RC6K62.cjs → chunk-RRPPXZ36.cjs} +4 -4
- package/dist/{chunk-62RC6K62.cjs.map → chunk-RRPPXZ36.cjs.map} +1 -1
- package/dist/{chunk-3R2KVYXN.js → chunk-SCYBGTX6.js} +3 -3
- package/dist/{chunk-3R2KVYXN.js.map → chunk-SCYBGTX6.js.map} +1 -1
- package/dist/{chunk-K4L4G76I.cjs → chunk-SKFJIFEV.cjs} +21 -21
- package/dist/{chunk-K4L4G76I.cjs.map → chunk-SKFJIFEV.cjs.map} +1 -1
- package/dist/{chunk-PIEMWFSJ.js → chunk-URLDVK67.js} +3 -3
- package/dist/{chunk-PIEMWFSJ.js.map → chunk-URLDVK67.js.map} +1 -1
- package/dist/{chunk-IOET54EV.js → chunk-VB2ARGQ6.js} +35 -3
- package/dist/chunk-VB2ARGQ6.js.map +1 -0
- package/dist/{chunk-VOZI5F7V.js → chunk-VYQ25YQF.js} +3 -3
- package/dist/{chunk-VOZI5F7V.js.map → chunk-VYQ25YQF.js.map} +1 -1
- package/dist/{chunk-NSZTHJZJ.cjs → chunk-W4M7TNXG.cjs} +39 -39
- package/dist/chunk-W4M7TNXG.cjs.map +1 -0
- package/dist/{chunk-QSWUSXRL.cjs → chunk-WGKAOUEQ.cjs} +41 -2
- package/dist/chunk-WGKAOUEQ.cjs.map +1 -0
- package/dist/{chunk-ORJ5HQAB.js → chunk-YHVEZVAO.js} +4 -4
- package/dist/{chunk-ORJ5HQAB.js.map → chunk-YHVEZVAO.js.map} +1 -1
- package/dist/entries/apps.cjs +43 -43
- package/dist/entries/apps.js +8 -8
- package/dist/entries/credits.cjs +155 -151
- package/dist/entries/credits.d.cts +32 -3
- package/dist/entries/credits.d.ts +32 -3
- package/dist/entries/credits.js +8 -8
- package/dist/entries/llm-models.d.cts +1 -1
- package/dist/entries/llm-models.d.ts +1 -1
- package/dist/entries/model-catalog.cjs +144 -84
- package/dist/entries/model-catalog.d.cts +4 -47
- package/dist/entries/model-catalog.d.ts +4 -47
- package/dist/entries/model-catalog.js +5 -5
- package/dist/entries/models.cjs +305 -289
- package/dist/entries/models.d.cts +5 -4
- package/dist/entries/models.d.ts +5 -4
- package/dist/entries/models.js +4 -4
- package/dist/entries/nodes.cjs +208 -208
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +10 -10
- package/dist/entries/pipeline.cjs +152 -152
- package/dist/entries/pipeline.d.cts +1 -1
- package/dist/entries/pipeline.d.ts +1 -1
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +117 -117
- package/dist/entries/video.js +4 -4
- package/dist/entries/workflow.cjs +147 -147
- package/dist/entries/workflow.d.cts +8 -0
- package/dist/entries/workflow.d.ts +8 -0
- package/dist/entries/workflow.js +2 -2
- package/dist/gpt-image-2-6-BeZdT-pW.d.cts +98 -0
- package/dist/gpt-image-2-6-BeZdT-pW.d.ts +98 -0
- package/dist/index.cjs +1314 -1234
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +20 -20
- package/dist/{model-catalog-QJ_AO9l0.d.cts → model-catalog-D6Es7VG-.d.cts} +56 -2
- package/dist/{model-catalog-QJ_AO9l0.d.ts → model-catalog-D6Es7VG-.d.ts} +56 -2
- package/dist/{model-constants-BwBdh6Rn.d.ts → model-constants-22k3fjp1.d.cts} +16 -1
- package/dist/{model-constants-BwBdh6Rn.d.cts → model-constants-22k3fjp1.d.ts} +16 -1
- package/package.json +1 -1
- package/src/__tests__/gpt-image-2-6-formats.test.ts +171 -0
- package/src/cast-swap-limits.ts +2 -1
- package/src/credit-identifiers.ts +63 -3
- package/src/entries/credits.ts +1 -0
- package/src/entries/model-catalog.ts +17 -0
- package/src/entries/models.ts +6 -0
- package/src/gpt-image-2-6.ts +72 -0
- package/src/model-catalog.ts +336 -13
- package/src/model-constants.ts +33 -0
- package/src/node-execution-state.ts +8 -0
- package/src/node-runtime-keys.ts +3 -0
- package/dist/chunk-2S7YYCRT.js.map +0 -1
- package/dist/chunk-2VQHPILW.js.map +0 -1
- package/dist/chunk-6VXDW2U3.cjs +0 -27
- package/dist/chunk-AWS4BWEC.js.map +0 -1
- package/dist/chunk-IOET54EV.js.map +0 -1
- package/dist/chunk-NSZTHJZJ.cjs.map +0 -1
- package/dist/chunk-NZRG5CXQ.cjs.map +0 -1
- package/dist/chunk-OFL4UH6L.cjs.map +0 -1
- package/dist/chunk-PIX4OCCQ.js.map +0 -1
- package/dist/chunk-QSWUSXRL.cjs.map +0 -1
- package/dist/chunk-V3NONYLA.cjs.map +0 -1
- package/dist/chunk-VLQW4CVW.cjs.map +0 -1
- package/dist/chunk-ZU56AMFK.js.map +0 -1
package/dist/chunk-6VXDW2U3.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkVLQW4CVW_cjs = require('./chunk-VLQW4CVW.cjs');
|
|
4
|
-
var chunkV3NONYLA_cjs = require('./chunk-V3NONYLA.cjs');
|
|
5
|
-
|
|
6
|
-
// src/video-ui-defaults.ts
|
|
7
|
-
function uiAspectRatioFill(provider) {
|
|
8
|
-
if (chunkVLQW4CVW_cjs.isSeedance2Provider(provider) || chunkVLQW4CVW_cjs.isMinimaxH3Provider(provider) || chunkVLQW4CVW_cjs.isWan3Provider(provider)) return "adaptive";
|
|
9
|
-
if (chunkVLQW4CVW_cjs.isKling4Provider(provider)) return "auto";
|
|
10
|
-
return void 0;
|
|
11
|
-
}
|
|
12
|
-
function uiResolutionFill(provider) {
|
|
13
|
-
if (chunkVLQW4CVW_cjs.isWan3Provider(provider) || chunkVLQW4CVW_cjs.isViduQ4Provider(provider) || chunkVLQW4CVW_cjs.isKling4Provider(provider) || chunkVLQW4CVW_cjs.isGeminiOmniPerSecondProvider(provider)) return chunkVLQW4CVW_cjs.PRICING_DEFAULT_RESOLUTION[provider];
|
|
14
|
-
if (chunkVLQW4CVW_cjs.isSeedance2Provider(provider)) return chunkV3NONYLA_cjs.MODEL_CATALOG[provider]?.resolutions?.[0];
|
|
15
|
-
return void 0;
|
|
16
|
-
}
|
|
17
|
-
function uiDurationFill(provider) {
|
|
18
|
-
if (chunkVLQW4CVW_cjs.isWan3Provider(provider) || chunkVLQW4CVW_cjs.isViduQ4Provider(provider) || chunkVLQW4CVW_cjs.isKling4Provider(provider)) return 5;
|
|
19
|
-
if (chunkVLQW4CVW_cjs.isGeminiOmniProvider(provider)) return 8;
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.uiAspectRatioFill = uiAspectRatioFill;
|
|
24
|
-
exports.uiDurationFill = uiDurationFill;
|
|
25
|
-
exports.uiResolutionFill = uiResolutionFill;
|
|
26
|
-
//# sourceMappingURL=chunk-6VXDW2U3.cjs.map
|
|
27
|
-
//# sourceMappingURL=chunk-6VXDW2U3.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/node-refs.ts","../src/trigger-feeds.ts","../src/node-runtime-keys.ts","../src/json-path.ts","../src/filter-condition.ts","../src/selector.ts"],"names":[],"mappings":";;;AAMO,IAAM,gBAAA,GAAmB;AAGzB,IAAM,sBAAA,uBAA6B,GAAA,CAAI;AAAA,EAC5C,MAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAC;AAUM,SAAS,aAAa,GAAA,EAAwD;AACnF,EAAA,MAAM,CAAA,GAAI,GAAA,CAAI,OAAA,CAAQ,IAAI,CAAA;AAC1B,EAAA,IAAI,CAAA,KAAM,IAAI,OAAO,EAAE,MAAM,GAAA,CAAI,IAAA,EAAK,EAAG,QAAA,EAAU,IAAA,EAAK;AACxD,EAAA,OAAO,EAAE,IAAA,EAAM,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,IAAA,EAAK,EAAG,QAAA,EAAU,IAAI,KAAA,CAAM,CAAA,GAAI,CAAC,CAAA,CAAE,MAAK,EAAE;AAC3E;AAYO,SAAS,iBAAiB,KAAA,EAAuB;AACtD,EAAA,OAAO,KAAA,CAAM,IAAA,EAAK,CAAE,WAAA,EAAY;AAClC;AAcO,SAAS,2BACX,KAAA,EACU;AACb,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,OAAO,IAA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GAAe,eAAA,CAAgB,CAAA,EAAG,SAAS,CAAA;AACjD,IAAA,OAAO,uBAAA,CAAwB,cAAc,WAAW,CAAA;AAAA,EAC1D,CAAA;AACA,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,aAAA,EAAe,OAAA,CAAQ,MAAA,CAAO,aAAa,CAAA;AAAA,IAC3C,cAAA,EAAgB,OAAA,CAAQ,MAAA,CAAO,cAAc,CAAA;AAAA,IAC7C,aAAA,EAAe,OAAA,CAAQ,MAAA,CAAO,aAAa,CAAA;AAAA,IAC3C,IAAA,EAAM,OAAA,CAAQ,MAAA,CAAO,IAAI;AAAA,GAC3B;AACF","file":"chunk-AWS4BWEC.js","sourcesContent":["/**\n * Node reference pattern and resolution for {Node Label} template syntax.\n * Shared between frontend and backend.\n */\n\n/** Matches {Node Label} references in text. */\nexport const NODE_REF_PATTERN = /\\{([^}]+)\\}/g\n\n/** Reserved template variable names that should NOT be resolved as node refs */\nexport const RESERVED_TEMPLATE_VARS = new Set([\n \"name\",\n \"description\",\n \"userPrompt\",\n \"assetDescriptions\",\n \"outputCount\",\n])\n\n/**\n * Split a `{...}` token body into its node name and optional fallback. Splits on the FIRST `||`\n * (a fallback may itself contain `||`); both sides are trimmed. `fallback` is null when there is\n * no `||`, preserving the legacy \"leave the literal token\" behavior.\n * \"person || man\" -> { name: \"person\", fallback: \"man\" }\n * \"person || \" -> { name: \"person\", fallback: \"\" } (resolves to empty when absent)\n * \"person\" -> { name: \"person\", fallback: null } (literal {person} when absent)\n */\nexport function parseNodeRef(raw: string): { name: string; fallback: string | null } {\n const i = raw.indexOf(\"||\")\n if (i === -1) return { name: raw.trim(), fallback: null }\n return { name: raw.slice(0, i).trim(), fallback: raw.slice(i + 2).trim() }\n}\n\n/**\n * Canonical form of a node-name variable: trimmed + lowercased. Node-name\n * variables are CASE-INSENSITIVE with lowercase as canonical, so nodes labeled\n * `TEXt`, `TEXT`, `text` all feed the one `{text}` variable and `{TEXT}` /\n * `{Text}` / `{text}` in a prompt all resolve to it.\n *\n * Reserved template vars (RESERVED_TEMPLATE_VARS, e.g. `userPrompt`) are matched\n * case-sensitively on the ORIGINAL token BEFORE canonicalization, so `{userPrompt}`\n * stays a reserved token rather than becoming a `userprompt` node ref.\n */\nexport function canonicalVarName(label: string): string {\n return label.trim().toLowerCase()\n}\n\n/**\n * The distinct `{label}` names referenced across the given texts. Mirrors the\n * canvas-side `referencedRefs`: strips the `|| fallback`, and ignores empty\n * tokens, image-ref tokens (`{image:N}`), and RESERVED_TEMPLATE_VARS. Used to\n * SUPPRESS auto-injection of a connected node the author already placed\n * explicitly via `{label}` (so it isn't injected twice). `matchAll` over the\n * global pattern does not mutate its lastIndex, so sharing the constant is safe.\n *\n * Deliberately NOT `REF_TOKEN_NAMESPACE_PREFIXES`: widening this changes\n * run-time auto-injection on BOTH engines (follow-up ticket), not just the\n * editor.\n */\nexport function extractReferencedLabels(\n ...texts: ReadonlyArray<string | undefined | null>\n): Set<string> {\n const refs = new Set<string>()\n for (const text of texts) {\n if (typeof text !== \"string\" || text.length === 0) continue\n for (const m of text.matchAll(NODE_REF_PATTERN)) {\n const { name } = parseNodeRef(m[1] ?? \"\")\n if (name === \"\" || name.startsWith(\"image:\") || RESERVED_TEMPLATE_VARS.has(name)) continue\n refs.add(canonicalVarName(name)) // case-insensitive: {Foo} suppresses a `foo` node\n }\n }\n return refs\n}\n\n/** Handle → combine-order category for same-label `{label}` merging. Lower wins\n * first: prompt (0) → elements (1) → look family (2). Other handles are -1\n * (not combinable — they keep the per-engine last-wins/suffix behavior). */\nexport const REF_HANDLE_CATEGORY: Readonly<Record<string, number>> = {\n prompt: 0,\n elements: 1,\n look: 2,\n cinematography: 2,\n style: 2,\n}\n\n/** Combine-order category for a direct-parent edge's `targetHandle`; -1 when the\n * handle isn't one of the combinable prompt/elements/look handles. */\nexport function refHandleCategory(targetHandle: string | null | undefined): number {\n if (targetHandle != null && Object.prototype.hasOwnProperty.call(REF_HANDLE_CATEGORY, targetHandle)) {\n return REF_HANDLE_CATEGORY[targetHandle]\n }\n return -1\n}\n\n/**\n * Reference-handle id → resolved-input key. The SINGLE SOURCE OF TRUTH for which\n * `targetHandle` ids carry image / video / audio reference inputs. Shared by the\n * backend input-resolver (routes the wired URL into the matching\n * `referenceImageUrls` / `referenceVideoUrls` / `referenceAudioUrls` slot) AND\n * the positional `{image:N}` / `{video:N}` / `{audio:N}` body-token COUNTS in the\n * FE preview (`video-prompt-assembly.ts`), FE run (`execute-node.ts`), and BE\n * payload-builder.\n *\n * Two handle families map to the same keys:\n * - Legacy / i2v single-name ids (`references` / `reference-videos` /\n * `reference-audio`) — kept for un-migrated workflows.\n * - Canonical typed-handle ids the modern Generate Video node exposes\n * (`imageReferences` / `videoReferences` / `audioReferences`) — share the\n * resolved-input keys with the legacy ids so consumer code never forks.\n */\nexport const REFERENCE_HANDLE_MAP: Record<string, \"referenceImageUrls\" | \"referenceVideoUrls\" | \"referenceAudioUrls\"> = {\n // Legacy / i2v single-name handle ids (kept for un-migrated workflows)\n \"references\": \"referenceImageUrls\",\n \"reference-videos\": \"referenceVideoUrls\",\n \"reference-audio\": \"referenceAudioUrls\",\n // New canonical typed-handle ids (Generate Video) — share the resolved-input\n // keys with the legacy ids so payload-builder code doesn't fork.\n \"imageReferences\": \"referenceImageUrls\",\n \"videoReferences\": \"referenceVideoUrls\",\n \"audioReferences\": \"referenceAudioUrls\",\n}\n\n/** The three reference modalities a reference handle can carry. */\nexport type ReferenceModality = \"image\" | \"video\" | \"audio\"\n\n/**\n * The reference MODALITY a `targetHandle` carries, or null when the handle is\n * not a reference handle. Resolves BOTH the legacy single-name ids and the\n * canonical Generate Video ids (via REFERENCE_HANDLE_MAP), so positional\n * `{image:N}` / `{video:N}` / `{audio:N}` token counts cover every handle alias\n * — without this, the generate-video `imageReferences` handle was silently\n * uncounted and `{image:N}` tokens dropped to bare labels on the only creatable\n * video node.\n */\nexport function referenceModalityForHandle(targetHandle: string | null | undefined): ReferenceModality | null {\n if (targetHandle == null) return null\n const key = REFERENCE_HANDLE_MAP[targetHandle]\n return key === \"referenceImageUrls\" ? \"image\" : key === \"referenceVideoUrls\" ? \"video\" : key === \"referenceAudioUrls\" ? \"audio\" : null\n}\n\n/**\n * Frame target handles (start / end keyframes). An image wired into one of these\n * is a KEYFRAME, not an `{image:N}` reference: the backend appends frames at the\n * TAIL of `reference_image_urls` (`resolveSeedance2Inputs`), never numbered. The\n * editor MUST therefore exclude them from `{image:N}` numbering so editor token N\n * equals the worker reference slot N.\n *\n * The SINGLE source of truth for \"is this a frame handle,\" shared by the\n * config-panel autocomplete (`video-configs.tsx`) AND the inline/modal builder\n * (`connected-references.ts`) — without ONE definition those two surfaces drifted\n * and the inline editor numbered the frame as `{image:1}` (the C1 bug). Frames\n * are deliberately NOT in `REFERENCE_HANDLE_MAP`: they carry no reference\n * modality, so `referenceModalityForHandle` already returns `null` for them on\n * the count side — this set is the exclusion lever for the EDITOR-numbering side.\n */\nexport const FRAME_TARGET_HANDLES: ReadonlySet<string> = new Set([\"startFrame\", \"endFrame\"])\n\n/**\n * Minimal structural edge shape {@link countRefModalityEdges} reads — only the\n * two fields the count needs. Both the FE `WorkflowEdge` (xyflow `Edge`, whose\n * `target` is a non-null string) and the BE `SimpleEdge` satisfy it.\n */\nexport interface RefModalityEdge {\n target?: string | null\n targetHandle?: string | null\n}\n\n/**\n * Count the reference-handle edges of a given reference MODALITY wired into a\n * node — the ONE positional `{image:N}` / `{video:N}` / `{audio:N}` counter\n * shared by the FE preview (`video-prompt-assembly.ts`), the FE run\n * (`execute-node.ts`), and the BE orchestrator (`payload-builder.ts`). Counting\n * via `referenceModalityForHandle` (not a single handle string) covers BOTH the\n * legacy single-name ids (`references` / `reference-videos` / `reference-audio`)\n * AND the canonical Generate Video ids (`imageReferences` / `videoReferences` /\n * `audioReferences`), so editor token N maps 1:1 to the worker\n * `referenceImageUrls` / `referenceVideoUrls` / `referenceAudioUrls` slot N on\n * every handle alias. This is the EDGE count (not the resolved/list-expanded URL\n * count) so all three paths stay byte-identical; the edge-vs-resolved divergence\n * for a reference edge that fans out to >1 URL (a List producer) is a shared,\n * documented v1 limitation.\n */\nexport function countRefModalityEdges(\n edges: ReadonlyArray<RefModalityEdge>,\n nodeId: string,\n modality: ReferenceModality,\n): number {\n let n = 0\n for (const e of edges) {\n if (e.target === nodeId && referenceModalityForHandle(e.targetHandle) === modality) n += 1\n }\n return n\n}\n\n/**\n * The wires that bring a node the images a run sends, besides its own source:\n * its reference images, each identity node on the `assets` handle (one image at\n * least), and every `image` wire after the first (the first is the source, which\n * an edit's estimate counts itself). For a model priced per input image.\n */\nexport function countImageInputEdges(edges: ReadonlyArray<RefModalityEdge>, nodeId: string): number {\n const onHandle = (handle: string) => edges.filter((e) => e.target === nodeId && e.targetHandle === handle).length\n return countRefModalityEdges(edges, nodeId, \"image\") + onHandle(\"assets\") + Math.max(0, onHandle(\"image\") - 1)\n}\n\n/** A candidate contribution to the `{label}` map: the node's label, its resolved\n * output, and its direct-parent handle category (-1 = not combinable / deeper). */\nexport interface RefCandidate {\n label: string\n output: string\n category: number\n}\n\n/**\n * Same-label COMBINE: when ≥2 direct-parent candidates (category ≥ 0) share a\n * label, `{label}` resolves to their values joined by \", \" ordered prompt →\n * elements → look, and within a category by candidate (edge) order. Returns a\n * Map of ONLY the combined labels; the caller fills the rest with its own\n * (FE suffix / BE last-wins) logic, skipping any label present here. Shared so\n * the frontend executor and backend orchestrator never drift.\n */\nexport function combineSameLabelRefs(candidates: ReadonlyArray<RefCandidate>): Map<string, string> {\n const byLabel = new Map<string, RefCandidate[]>()\n for (const c of candidates) {\n if (c.category < 0) continue\n const key = canonicalVarName(c.label) // TEXt + TEXT + text collapse into one {text}\n const arr = byLabel.get(key)\n if (arr) arr.push(c)\n else byLabel.set(key, [c])\n }\n const combined = new Map<string, string>()\n for (const [label, group] of byLabel) {\n if (group.length < 2) continue\n const ordered = group\n .map((c, i) => ({ c, i }))\n .sort((a, b) => a.c.category - b.c.category || a.i - b.i)\n .map((x) => x.c.output)\n combined.set(label, ordered.join(\", \"))\n }\n return combined\n}\n\n/**\n * Resolve {Node Label} references in text by replacing them with actual node outputs.\n * Skips reserved template variables used by applyTemplate().\n * Iterates until stable to handle nested refs (e.g. {List} → {Animal1} → \"dog\").\n */\nexport function resolveNodeRefs(\n text: string,\n labelToOutput: ReadonlyMap<string, string>,\n): string {\n const MAX_PASSES = 10\n let result = text\n for (let i = 0; i < MAX_PASSES; i++) {\n const next = result.replace(NODE_REF_PATTERN, (match, raw: string) => {\n const { name, fallback } = parseNodeRef(raw)\n if (RESERVED_TEMPLATE_VARS.has(name)) return match\n // Node-name vars are case-insensitive: try the literal key first (keeps\n // original-cased maps like condition-variables working), then the\n // lowercase-canonical key (node-ref maps are canonical-keyed).\n const output = labelToOutput.get(name) ?? labelToOutput.get(canonicalVarName(name))\n if (output !== undefined) return output // connected, non-empty output → its value\n if (fallback !== null) return fallback // absent/empty + fallback → default (\"\" for {name || })\n return match // absent + no || → literal {name}\n })\n if (next === result) break\n result = next\n }\n return result\n}\n\n/**\n * Token namespaces that are NOT node-label references. `{image:1:face}` is the\n * unified-reference grammar, `{slot:x}` is recast's, `{video:N}`/`{audio:N}`\n * are reference handles, and `{ref:<id>}` is the id-addressed reference form —\n * all five are substituted by their own resolvers (`resolveReferenceTokens`,\n * `resolveRefIdTokens`, the recast slot pass), not by resolveNodeRefs. Before\n * this list existed, only `image:` was excluded, so `{video:1}` classified as a\n * MISSING node ref.\n *\n * Compared against the LOWERCASED token name: `REFERENCE_TOKEN_RE` is `/gi` and\n * `REF_ID_TOKEN_RE` spells `[rR][eE][fF]`, so `{Image:1}` / `{Ref:x}` really do\n * resolve downstream and must never read as a missing node ref.\n */\nexport const REF_TOKEN_NAMESPACE_PREFIXES: readonly string[] = [\n \"image:\", \"video:\", \"audio:\", \"slot:\", \"ref:\",\n]\n\nexport type RefTokenKind = \"wired\" | \"reserved\" | \"missing\" | \"skip\" | \"unknown\"\n\n/**\n * Classify a parsed `{...}` token name against the resolvable label set.\n * `resolvable === null` means the caller has no ref data at all — such tokens\n * classify `unknown` and must render like wired, so \"no data\" never\n * masquerades as \"nothing wired\".\n *\n * Single source of truth for the editor decoration, the missing-refs chip\n * (frontend/src/lib/prompt-ref-scan.ts delegates here) and the execution\n * engine's dispatch guard.\n */\nexport function classifyRefToken(\n name: string,\n resolvable: ReadonlySet<string> | null,\n): RefTokenKind {\n const lower = name.toLowerCase()\n if (name === \"\" || REF_TOKEN_NAMESPACE_PREFIXES.some((p) => lower.startsWith(p))) return \"skip\"\n if (RESERVED_TEMPLATE_VARS.has(name)) return \"reserved\"\n if (resolvable === null) return \"unknown\"\n return resolvable.has(canonicalVarName(name)) ? \"wired\" : \"missing\"\n}\n\n/**\n * The `{Label}` tokens in `text` that `resolveNodeRefs` would leave LITERAL and\n * that no upstream node can explain — i.e. exactly what would reach a provider\n * as the characters `{Label}`. Evidence for why this matters: `{Describe Image}`\n * ×2 (gpt-image-2) and `{gravity flip}` / `{rewind}` (seedance-2-5) in the\n * 2026-09-01 app-reports export.\n *\n * `resolvable` — labels with a value in the ref map (canonical/lowercase).\n * `known` — canonical labels of the nodes the caller considers to EXIST\n * (no state requirement; the backend passes every node in the\n * run's graph).\n *\n * A token whose label is in `known` but not `resolvable` PASSES: the node\n * exists and simply produced nothing, which is the caller's to substitute (the\n * backend resolves it to empty text), not this function's to refuse. A token\n * with an explicit `|| fallback` passes too — the fallback is substituted.\n * Returns original-cased names, de-duplicated by canonical form, for the\n * user-facing message.\n */\nexport function unresolvedRefTokens(\n text: string,\n opts: { resolvable: ReadonlySet<string>; known: ReadonlySet<string> },\n): string[] {\n if (typeof text !== \"string\" || text.length === 0) return []\n const seen = new Set<string>()\n const out: string[] = []\n for (const m of text.matchAll(NODE_REF_PATTERN)) {\n const { name, fallback } = parseNodeRef(m[1] ?? \"\")\n if (fallback !== null) continue\n if (classifyRefToken(name, opts.resolvable) !== \"missing\") continue\n const canon = canonicalVarName(name)\n if (opts.known.has(canon) || seen.has(canon)) continue\n seen.add(canon)\n out.push(name)\n }\n return out\n}\n","/**\n * Every way one node FEEDS another — the ONE definition the server's run\n * scope (`triggerRunScope`) and the editor's \"is this trigger wired?\" read\n * from, so the card can never say \"the branch\" while the server runs the\n * whole workflow, or the other way round:\n *\n * - a drawn edge whose two ends are both on the graph (a delta that deleted a\n * node leaves its edges behind; those feed nothing);\n * - Group membership: a node inside a Group feeds the group (`parentId`),\n * the way the engine orders a group after its members;\n * - a field mapping: `data.fieldMappings[field].sourceNodeId` feeds the node\n * that carries the mapping, even after the edge it was made from is gone.\n */\n\nexport interface FeedNode {\n readonly id: string\n readonly parentId?: string | null\n readonly data?: unknown\n}\n\nexport interface FeedEdge {\n readonly source: string\n readonly target: string\n}\n\nexport interface FeedMaps {\n /** node id → the ids it feeds */\n readonly children: ReadonlyMap<string, ReadonlyArray<string>>\n /** node id → the ids that feed it */\n readonly parents: ReadonlyMap<string, ReadonlyArray<string>>\n}\n\nexport function buildFeedMaps(nodes: ReadonlyArray<FeedNode>, edges: ReadonlyArray<FeedEdge>): FeedMaps {\n const live = new Set(nodes.map((n) => n.id))\n const children = new Map<string, string[]>()\n const parents = new Map<string, string[]>()\n const feeds = (source: string, target: string) => {\n if (!live.has(source) || !live.has(target) || source === target) return\n children.set(source, [...(children.get(source) ?? []), target])\n parents.set(target, [...(parents.get(target) ?? []), source])\n }\n for (const edge of edges) feeds(edge.source, edge.target)\n for (const n of nodes) {\n if (typeof n.parentId === \"string\" && n.parentId) feeds(n.id, n.parentId)\n const mappings = (n.data as { fieldMappings?: unknown } | null | undefined)?.fieldMappings\n if (mappings && typeof mappings === \"object\") {\n for (const mapping of Object.values(mappings as Record<string, unknown>)) {\n const sourceNodeId = (mapping as { sourceNodeId?: unknown } | null)?.sourceNodeId\n if (typeof sourceNodeId === \"string\" && sourceNodeId) feeds(sourceNodeId, n.id)\n }\n }\n }\n return { children, parents }\n}\n\n/** Does this node feed anything? A trigger that does not runs the whole workflow. */\nexport function nodeFeedsAnything(nodes: ReadonlyArray<FeedNode>, edges: ReadonlyArray<FeedEdge>, nodeId: string): boolean {\n return (buildFeedMaps(nodes, edges).children.get(nodeId) ?? []).length > 0\n}\n","import { SUNO_SEPARATE_META_FIELDS, SUNO_SEPARATE_RESULT_FIELDS } from \"./suno-separate.js\"\n\n/**\n * Field names on a node's `data` that hold runtime / result / transient execution\n * state (job ids, progress, generated outputs, fan-out bookkeeping). These are NEVER\n * part of a node's reusable configuration.\n *\n * Single source of truth, consumed by:\n * - the workflow store's undo logic (execution-only updates skip undo capture, so job\n * polling does not pollute undo history or flip `isDirty`)\n * - the node-preset extractor (presets must never capture runtime state)\n * - the backend defensive strip on preset writes\n *\n * When adding a new runtime/result field to a node's data, add its key here — or, when it is a\n * generic name only one node type writes as a result, to that type's row of\n * NODE_TYPE_EXECUTION_DATA_KEYS (read through `isExecutionDataKey` / `executionDataKeysOf`).\n */\nexport const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([\n \"executionStatus\",\n \"currentJobId\",\n \"currentJobProgress\",\n \"errorMessage\",\n // Structured detail alongside errorMessage for a safety-filter block\n // (see `JobErrorHint` in the app's frontend/src/types/nodes.ts). Same\n // lifecycle as errorMessage: a RESULT the user expects to survive reload,\n // never user-edited config.\n \"errorHint\",\n // A job policy registered by the deployment held this node's result for a\n // human reviewer (`jobs.status = \"pending_review\"`). Pure run state, like\n // executionStatus: the node is still \"running\" and the flag disappears the\n // moment the review resolves — so it is ALSO in TRANSIENT_RUNTIME_KEYS\n // below. Without the transient half, a flip into review marks a passive tab\n // dirty and a preset captures \"awaiting review\".\n \"jobAwaitingReview\",\n // The editor cannot reach the server to read this node's job. The job keeps\n // running and the watch keeps polling. Pure run state, cleared by the next\n // check that gets through, so it is ALSO in TRANSIENT_RUNTIME_KEYS below.\n \"jobConnectionLost\",\n // Where this node's job stands in line while it waits for a free slot\n // (the job read's `queue` field), shown by the editor's queue badge. Pure run\n // state, replaced on each read and cleared once the job leaves `queued`, so\n // it is ALSO in TRANSIENT_RUNTIME_KEYS below: a badge never marks the\n // workflow dirty and is never saved.\n \"queueInfo\",\n \"isStreaming\",\n \"generatedImageUrl\",\n \"generatedVideoUrl\",\n \"generatedAudioUrl\",\n \"generatedText\",\n \"generatedScript\",\n \"generatedItems\",\n \"generatedResults\",\n \"activeResultIndex\",\n \"sourceImageUrl\",\n \"__listTotal\",\n \"__listCompleted\",\n \"__listResults\",\n // Row-aligned twin of __listResults (Extract Field, List output) — read only\n // by the fan-out so two lists cut from one array pair by row.\n \"__alignedListResults\",\n // A render's fan-out row stamps, row-aligned with __listResults: each row's\n // take identity, and the clip every row was sent for (a failed row too).\n \"__listResultStamps\",\n // List fan-out window flag (abandon-guard exemption). Set/cleared by\n // executeNodeForList — purely execution-related, never user-edited.\n \"__listRunning\",\n // Why the last server run skipped this node (`empty_input`): a chip on the\n // card for the run that just ended, never a saved result — also in\n // TRANSIENT_RUNTIME_KEYS below.\n \"__runSkipReason\",\n // One token per paid run still out on this node that no executor mark\n // covers (the editor's `withRunInFlight`, around each paid call outside the\n // executors). Purely execution-related, never user-edited; also in\n // TRANSIENT_RUNTIME_KEYS.\n \"__runsInFlight\",\n // Selector node dual-channel outputs (picked + rest). Server-side execution\n // output, not user-edited config.\n \"pickedResults\",\n \"restResults\",\n \"__pickedResults\",\n \"__restResults\",\n \"__pickedTotal\",\n \"__restTotal\",\n \"generatedJson\",\n // A render's remapped transcript on its own pip (Speaker View's\n // `transcript`, RENDER_NODE_TYPES transcriptOutput) — run-result data.\n \"generatedTranscript\",\n // Edit Plan: a person's review of the plan (`EditedEdl`, edit-plan-review.ts),\n // kept beside `generatedJson` and fingerprinted against it. Run-result data\n // (TA14, decided 2026-10-04): out of undo, presets, templates and exports,\n // and Clear results wipes it. Persisted — never transient.\n \"editedEdl\",\n \"subWorkflowProgress\",\n \"outputResults\",\n \"shots\",\n \"result\",\n \"processedResult\",\n \"activeRoutes\",\n \"routeOutputs\",\n \"_upstreamRefresh\",\n \"zoom\",\n // Character LoRA training status fields — written every 8s while training.\n \"loraReplicateVersion\",\n \"loraTriggerWord\",\n \"loraTrainingStatus\",\n // Collect (fan-in) execution snapshot.\n \"lastInputs\",\n \"lastMeta\",\n \"__upstreamCount\",\n // Video URL node — the download's live percent/phase, written on every\n // progress tick (~2/s). Pure run-state; also in TRANSIENT_RUNTIME_KEYS below.\n \"downloadPercent\",\n \"downloadPhase\",\n // Webhook Output's delivery receipt. A webhook target may reflect the\n // request back (httpbin, RequestBin, an API that 400s with \"headers\n // received: …\"), so `webhookResponseBody` can carry whatever the request\n // carried — with an attached credential, the secret itself. Listing the three\n // here is what keeps the receipt out of template exports (GENERATED_FIELDS\n // derives from this set), out of node presets, and out of undo history.\n \"webhookSuccess\",\n \"webhookStatusCode\",\n \"webhookResponseBody\",\n // Content Ideas: one creative brief per idea (the node's list output — kept\n // out of __listResults, which would clone the node). And the non-fatal notes\n // a Content Recipe / Content Ideas run returns (\"read the first of 3 posts\").\n // Both are RESULTS: they persist, and a preset, a template or a run-only\n // patch must never treat them as config.\n \"ideaBriefs\",\n \"runWarnings\",\n // Content Ideas: the own brand whose results the last run leaned on — a\n // RESULT naming the runner's brand, so a template or a preset never carries it.\n \"brandLessons\",\n // Social Search: every post the last search found (the picker's grid), the\n // ids a person picked from them, and the run's non-fatal notes (\"only part\n // of the results loaded\"). All RESULTS: a template, a preset or a run-only\n // patch must never carry yesterday's posts or picks as configuration.\n \"searchResults\",\n \"pickedIds\",\n \"searchWarnings\",\n // Save to Collection: how the last run ended for this node (inserted /\n // duplicate / replayed) and how many old records the cap evicted. RESULTS of\n // a run — Clear results wipes them, and a template, a preset or a run-only\n // patch never carries them as configuration.\n \"lastOutcome\",\n \"lastEvicted\",\n // When the editor's \"Clear results\" last emptied this node (ISO time). Not a\n // result and not config: bookkeeping that tells the load-time recovery lanes\n // \"this node is empty ON PURPOSE\" — without it, every reload reads an empty\n // node as \"ran while the editor was closed\" and paints the last run back.\n // Persisted (never transient): the reload is exactly when it is read.\n \"resultsClearedAt\",\n // The id of the trigger-started run whose results this node shows (the\n // editor paints a Telegram run onto the canvas). Bookkeeping, not a result\n // and not config: it stops a reload from painting the same run again over\n // edits made since. Persisted for the same reason as resultsClearedAt.\n \"resultsRunId\",\n // When that run ended the node (beside resultsRunId): the editor's reopen\n // keeps a result a NEWER run left even when its own run listing cannot see\n // that run. Bookkeeping, persisted for the same reason.\n \"resultsRunEndedAt\",\n // A trigger's last run values (also in TRANSIENT_RUNTIME_KEYS: never saved).\n \"__triggerData\",\n // A fan-out's notes rows, every fan-out's (row-aligned with __listResults):\n // a row's warnings and length. A RESULT: persisted.\n \"__listResultMeta\",\n // A use-case node's continuation of one of its runs (Tighten Episode): set\n // for ONE run only, as that run's input override (an app's or the editor's\n // Render final, the canvas Continue's run option). Never saved — also in\n // TRANSIENT_RUNTIME_KEYS — so a saved one can never turn a later plain run\n // into a continuation of an old run.\n \"useCaseContinue\",\n // The content rights confirmation a run fetches a Video URL node's link\n // under: that run's input override alone, never saved (also transient).\n \"rightsConfirmationId\",\n])\n\n/**\n * Run results a node type writes under a GENERIC name — `quote`, `durationSec`,\n * `candidates` — that are execution data on THAT type only. Another node may\n * keep a setting under the same name; filing these globally would misfile it\n * (out of undo, presets, templates and the copilot's view). Same lifecycle as\n * the global results: persisted, and a run writing them is never an undo step.\n *\n * UGC video (Nodaro Cloud): the outputs a node hands on (`ugcOutputs`), UGC\n * Creator's options of a draw and their note, UGC Clips' quote, and UGC Clip's\n * warnings, length and Re-render marks (`rerenderPending`: the clips pressed for\n * Re-render that no run has rendered yet — run bookkeeping; the press itself,\n * `rerender`, is a choice).\n *\n * Suno Separate: every stem / take URL a run writes and the run's facts (its\n * engine, a Demucs fallback's refusal and reason, its mode) — not `stemName`,\n * the node's instrument setting that the run only echoes back.\n */\nexport const NODE_TYPE_EXECUTION_DATA_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"ugcOutputs\", \"candidates\", \"optionFailed\"],\n \"ugc-script\": [\"ugcOutputs\"],\n \"ugc-clips\": [\"ugcOutputs\", \"quote\"],\n \"ugc-clip\": [\"ugcOutputs\", \"clipWarnings\", \"durationSec\", \"rerenderPending\"],\n \"ugc-cards\": [\"ugcOutputs\"],\n \"suno-separate\": [...SUNO_SEPARATE_RESULT_FIELDS, ...SUNO_SEPARATE_META_FIELDS.filter((key) => key !== \"stemName\")],\n}\n\n/** Is `key` execution data (run state or a run's result) on a node of `type`: global, or that type's own? */\nexport function isExecutionDataKey(key: string, type: string | null | undefined): boolean {\n if (EXECUTION_DATA_KEYS.has(key)) return true\n return typeof type === \"string\" && Object.hasOwn(NODE_TYPE_EXECUTION_DATA_KEYS, type) && NODE_TYPE_EXECUTION_DATA_KEYS[type]!.includes(key)\n}\n\nconst EXECUTION_DATA_KEYS_BY_TYPE = new Map<string, ReadonlySet<string>>(\n Object.entries(NODE_TYPE_EXECUTION_DATA_KEYS).map(([type, keys]) => [type, new Set([...EXECUTION_DATA_KEYS, ...keys])]),\n)\n\n/** Every execution-data key on a node of `type`, as one set: the global ones, plus the type's own. */\nexport function executionDataKeysOf(type: string | null | undefined): ReadonlySet<string> {\n return (typeof type === \"string\" ? EXECUTION_DATA_KEYS_BY_TYPE.get(type) : undefined) ?? EXECUTION_DATA_KEYS\n}\n\n/**\n * The PURE RUN-STATE subset of EXECUTION_DATA_KEYS: per-tick values (status\n * flips, job ids, progress counters, fan-out bookkeeping) that must NEITHER\n * mark the workflow dirty NOR be persisted in the save payload. Everything\n * else in EXECUTION_DATA_KEYS is a RESULT the user expects to survive reload\n * (generated URLs/results, errorMessage, LoRA outputs, collect snapshots).\n *\n * Why this split exists: writing these keys used to set `isDirty`, so job\n * polling phantom-dirtied passive tabs → spurious autosaves → false\n * \"changed in another tab\" banners → the remote-ahead latch froze autosave\n * (the \"not saved for a long time\" report). Consumed by the workflow\n * store's dirty decision and the save-payload sanitizer below.\n *\n * Invariant (guarded by node-runtime-keys.test.ts): subset of\n * EXECUTION_DATA_KEYS — anything transient is also undo-exempt.\n */\nexport const TRANSIENT_RUNTIME_KEYS: ReadonlySet<string> = new Set([\n \"executionStatus\",\n \"currentJobId\",\n \"currentJobProgress\",\n \"jobAwaitingReview\",\n \"jobConnectionLost\",\n \"queueInfo\",\n \"isStreaming\",\n \"subWorkflowProgress\",\n \"__listTotal\",\n \"__listCompleted\",\n \"__listRunning\",\n \"__runSkipReason\",\n // A paid run still out, held by the editor tab that started it. Never\n // saved, so a reload, which has no such run, starts without one.\n \"__runsInFlight\",\n \"_upstreamRefresh\",\n \"__upstreamCount\",\n // Video URL node download ticks. They used to dirty the workflow twice a\n // second for the length of the download — the same phantom-save chain the\n // job-progress keys above were moved here to stop. What SURVIVES a reload is\n // `downloadStatus` + `downloadId`; the percent is re-read from the server.\n \"downloadPercent\",\n \"downloadPhase\",\n // A trigger's last run values, shown in the editor after a run (a webhook's\n // body, a Telegram message and its post). Never saved: the workflow is not\n // where a message's content is kept — runs are, under their retention.\n \"__triggerData\",\n // A use-case node's continuation: one run's override, never config (above).\n \"useCaseContinue\",\n // The content rights confirmation a run fetches a Video URL node's link\n // under: one run's override (RUN_ONLY_NODE_FIELDS), never config.\n \"rightsConfirmationId\",\n])\n\n/**\n * Pure save-payload sanitizer: returns new node objects with the transient\n * run-state keys removed from `data`. Nodes without transient keys (or\n * without `data`) are returned by reference — cheap for the common case.\n */\nexport function stripTransientRuntimeData<\n T extends { data?: Record<string, unknown> | undefined },\n>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const data = node.data\n if (!data) return node\n let hasTransient = false\n for (const key of TRANSIENT_RUNTIME_KEYS) {\n if (key in data) {\n hasTransient = true\n break\n }\n }\n if (!hasTransient) return node\n const cleaned: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(data)) {\n if (!TRANSIENT_RUNTIME_KEYS.has(key)) cleaned[key] = value\n }\n return { ...node, data: cleaned }\n })\n}\n","/**\n * Evaluate a dot-notation path against a JSON value.\n *\n * Auto-iterates arrays at any depth: if the current value is an array,\n * the evaluator iterates and applies the remaining path to each element,\n * flattening results. This lets simple paths like \"caption\" work on a\n * top-level array and \"pages.markdown\" work on a nested array without\n * any wildcard syntax.\n *\n * Returns an array of values. Missing properties are skipped (empty for\n * that branch). Null/undefined leaf values are included — callers coerce.\n * Empty path returns `[value]` (a single-element array wrapping the\n * value) when the value is scalar/object, or the array elements flat\n * when the root is an array.\n */\nexport function evaluateJsonPath(value: unknown, path: string): unknown[] {\n const segments = path.length === 0 ? [] : path.split(\".\")\n return walk(value, segments, 0)\n}\n\n/**\n * Coerce an array of unknown values (typically from evaluateJsonPath) to\n * strings, skipping null/undefined. Primitives are stringified; objects\n * are JSON-encoded.\n */\nexport function stringifyPathResults(raw: unknown[]): string[] {\n const out: string[] = []\n for (const v of raw) {\n if (v === null || v === undefined) continue\n if (typeof v === \"string\") out.push(v)\n else if (typeof v === \"number\" || typeof v === \"boolean\") out.push(String(v))\n else out.push(JSON.stringify(v))\n }\n return out\n}\n\nfunction walk(value: unknown, segments: string[], offset: number): unknown[] {\n if (Array.isArray(value)) {\n const results: unknown[] = []\n for (const item of value) {\n for (const v of walk(item, segments, offset)) results.push(v)\n }\n return results\n }\n if (offset >= segments.length) return [value]\n if (value !== null && typeof value === \"object\") {\n const head = segments[offset]\n if (!Object.hasOwn(value as object, head)) return []\n return walk((value as Record<string, unknown>)[head], segments, offset + 1)\n }\n return []\n}\n","/** Pure condition evaluator shared by filter-list and router (conditional mode). */\n\nimport { evaluateJsonPath } from \"./json-path.js\"\nimport { resolveNodeRefs } from \"./node-refs.js\"\n\nexport type FilterListOperator =\n | \">\" | \"<\" | \">=\" | \"<=\"\n | \"=\" | \"!=\"\n | \"contains\" | \"not_contains\"\n | \"starts_with\" | \"ends_with\" | \"regex\"\n | \"exists\" | \"not_exists\"\n\nexport interface FilterListCondition {\n id?: string\n field?: string\n operator: FilterListOperator\n value?: string\n valueType?: \"static\" | \"variable\"\n /** UI-only hint on the config panel — irrelevant to evaluation. */\n mode?: \"dropdown\" | \"custom\"\n}\n\n/** AND/OR condition bundle used by the router's conditional mode. When a\n * group matches, every routeId is added to activeRoutes. Multiple groups\n * union (deduped). */\nexport interface RouterConditionGroup {\n id?: string\n conditions?: FilterListCondition[]\n conditionLogic?: \"AND\" | \"OR\"\n routeIds?: string[]\n}\n\n/**\n * Options for `evaluateCondition` / `evaluateConditionGroup`.\n */\nexport interface EvaluateConditionOptions {\n /** When `false`, text operators (`contains`, `not_contains`, `starts_with`,\n * `ends_with`, `=`, `!=`) compare case-insensitively using case-folded\n * string equality.\n *\n * Note: `=` and `!=` lose their default numeric-coercion semantics under\n * `caseSensitive: false`. Under the default (case-sensitive), `1 == \"1.0\"`\n * via `valuesEqual`; under `caseSensitive: false`, comparison is pure\n * case-folded string equality, so `\"1\" !== \"1.0\"`.\n *\n * Default (when undefined): `true` (case-sensitive) — preserves existing\n * behavior for all callers.\n *\n * Non-text operators (`>`, `<`, `>=`, `<=`, `exists`, `not_exists`,\n * `regex`) are unaffected by this flag. */\n caseSensitive?: boolean\n /** Label→output map for `{Node Label}` refs inside condition values.\n * Populated from a filter-list / router node's `\"variables\"` target\n * handle. Resolved via `resolveNodeRefs` — unknown labels preserve\n * the original `{...}` text, so JSON-literal values stay intact. */\n variables?: ReadonlyMap<string, string>\n}\n\nexport function tryParseJson(item: unknown): unknown {\n if (typeof item !== \"string\") return item\n const trimmed = item.trim()\n if (!trimmed) return item\n const first = trimmed[0]\n if (first !== \"{\" && first !== \"[\" && first !== \"\\\"\" && !/^-?\\d/.test(trimmed) && trimmed !== \"true\" && trimmed !== \"false\" && trimmed !== \"null\") {\n return item\n }\n try { return JSON.parse(trimmed) } catch { return item }\n}\n\nconst HOUR_MS = 60 * 60 * 1000\nconst DAY_MS = 24 * HOUR_MS\nconst WEEK_MS = 7 * DAY_MS\n\n/** Resolve a relative-window token like `last_N_hours:3` to an ISO timestamp\n * N units before `Date.now()`. Returns undefined for malformed tokens. */\nexport function resolveRelativeWindowToken(key: string): string | undefined {\n const m = /^last_N_(hours|days|weeks):(-?\\d+)$/.exec(key)\n if (!m) return undefined\n const n = parseInt(m[2], 10)\n if (!Number.isFinite(n)) return undefined\n const unitMs = m[1] === \"hours\" ? HOUR_MS : m[1] === \"days\" ? DAY_MS : WEEK_MS\n return new Date(Date.now() - n * unitMs).toISOString()\n}\n\n/**\n * Substitute `{{...}}` template tokens — `{{now}}`, `{{trigger.<path>}}`,\n * and relative-window tokens (`{{last_N_hours:N}}` / days / weeks). Reused\n * by `resolveConditionValue` (filter-list / router) and `resolveSelectorRefs`\n * (selector node) so token semantics stay identical across the workflow-engine\n * ref-resolution surface.\n *\n * Pure: returns a new string. Strings with no `{{...}}` tokens pass through\n * unchanged.\n */\nexport function substituteTriggerTokens(\n raw: string,\n triggerData?: Record<string, unknown>,\n): string {\n if (!/\\{\\{/.test(raw)) return raw\n return raw.replace(/\\{\\{\\s*([^}]+?)\\s*\\}\\}/g, (_m, expr) => {\n const key = String(expr).trim()\n if (key === \"now\") return new Date().toISOString()\n if (key === \"trigger.last_triggered_at\") {\n const v = triggerData?.last_triggered_at\n return v == null ? \"\" : String(v)\n }\n if (key.startsWith(\"trigger.\")) {\n const path = key.slice(\"trigger.\".length)\n const v = triggerData?.[path]\n return v == null ? \"\" : String(v)\n }\n const relative = resolveRelativeWindowToken(key)\n if (relative !== undefined) return relative\n return \"\"\n })\n}\n\nexport function resolveConditionValue(\n raw: string,\n valueType: string | undefined,\n triggerData?: Record<string, unknown>,\n variables?: ReadonlyMap<string, string>,\n): string {\n let value = raw\n if (variables && variables.size > 0) {\n value = resolveNodeRefs(value, variables)\n }\n const hasTemplate = /\\{\\{/.test(value)\n if (valueType !== \"variable\" && !hasTemplate) return value\n return substituteTriggerTokens(value, triggerData)\n}\n\nfunction asComparableNumber(v: unknown): number {\n if (typeof v === \"number\") return v\n if (typeof v === \"boolean\") return v ? 1 : 0\n if (typeof v === \"string\") {\n const trimmed = v.trim()\n if (trimmed === \"\") return NaN\n const n = Number(trimmed)\n if (!isNaN(n)) return n\n const d = Date.parse(trimmed)\n if (!isNaN(d)) return d\n }\n return NaN\n}\n\n// Numeric-first ordering compare used by >, <, >=, <=. Falls back to\n// localeCompare when either side can't be parsed as a number.\nfunction compareValues(a: unknown, b: unknown): number {\n const na = asComparableNumber(a)\n const nb = asComparableNumber(b)\n if (!isNaN(na) && !isNaN(nb)) return na - nb\n return String(a ?? \"\").localeCompare(String(b ?? \"\"))\n}\n\n// Numeric-first equality used by = and !=. So \"432\" == 432, and 432 == \"432\".\n// Falls back to strict string equality (null/undefined coerced to \"\") so\n// alpha values still work.\nfunction valuesEqual(a: unknown, b: unknown): boolean {\n const na = asComparableNumber(a)\n const nb = asComparableNumber(b)\n if (!isNaN(na) && !isNaN(nb)) return na === nb\n return String(a ?? \"\") === String(b ?? \"\")\n}\n\nfunction applyCase(s: string, caseSensitive: boolean): string {\n return caseSensitive ? s : s.toLowerCase()\n}\n\nexport function evaluateCondition(\n parsedItem: unknown,\n rawItem: string,\n condition: FilterListCondition,\n triggerData?: Record<string, unknown>,\n options?: EvaluateConditionOptions,\n): boolean {\n const path = (condition.field ?? \"\").trim()\n let fieldValue: unknown\n if (path === \"\") {\n fieldValue = parsedItem ?? rawItem\n } else {\n const matches = evaluateJsonPath(parsedItem ?? rawItem, path)\n fieldValue = matches.length > 0 ? matches[0] : undefined\n }\n\n const targetStr = resolveConditionValue(condition.value ?? \"\", condition.valueType, triggerData, options?.variables)\n // Default to case-sensitive when the flag is not explicitly set. This\n // preserves existing behavior for Router conditional mode and legacy\n // Filter List nodes that don't carry the new `caseSensitive` field.\n const cs = options?.caseSensitive ?? true\n const fieldStr = String(fieldValue ?? \"\")\n\n switch (condition.operator) {\n case \"exists\":\n return fieldValue !== undefined && fieldValue !== null\n case \"not_exists\":\n return fieldValue === undefined || fieldValue === null\n case \"contains\":\n return applyCase(fieldStr, cs).includes(applyCase(targetStr, cs))\n case \"not_contains\":\n return !applyCase(fieldStr, cs).includes(applyCase(targetStr, cs))\n case \"starts_with\":\n return applyCase(fieldStr, cs).startsWith(applyCase(targetStr, cs))\n case \"ends_with\":\n return applyCase(fieldStr, cs).endsWith(applyCase(targetStr, cs))\n case \"regex\": {\n if (!targetStr) return false\n try {\n return new RegExp(targetStr).test(fieldStr)\n } catch {\n return false\n }\n }\n case \"=\":\n return cs\n ? valuesEqual(fieldValue, targetStr)\n : applyCase(fieldStr, false) === applyCase(targetStr, false)\n case \"!=\":\n return cs\n ? !valuesEqual(fieldValue, targetStr)\n : applyCase(fieldStr, false) !== applyCase(targetStr, false)\n case \">\":\n return compareValues(fieldValue, targetStr) > 0\n case \"<\":\n return compareValues(fieldValue, targetStr) < 0\n case \">=\":\n return compareValues(fieldValue, targetStr) >= 0\n case \"<=\":\n return compareValues(fieldValue, targetStr) <= 0\n default:\n return false\n }\n}\n\n/** Evaluate a single AND/OR-joined group against one item. Empty condition\n * list evaluates to `true` — typical when the user has just added a group\n * and hasn't configured any conditions yet. */\nexport function evaluateConditionGroup(\n parsedItem: unknown,\n rawItem: string,\n conditions: readonly FilterListCondition[],\n logic: \"AND\" | \"OR\",\n triggerData?: Record<string, unknown>,\n options?: EvaluateConditionOptions,\n): boolean {\n const effective = conditions.filter((c) => c && c.operator)\n if (effective.length === 0) return true\n const results = effective.map((c) => evaluateCondition(parsedItem, rawItem, c, triggerData, options))\n return logic === \"OR\" ? results.some(Boolean) : results.every(Boolean)\n}\n","/**\n * Edge range utilities for resolving 1-based index expressions\n * and applying range/step slicing to output lists.\n *\n * Used by both frontend DAG executor and backend orchestrator\n * to support edge-level range, step, and item selection.\n */\n\nimport { evaluateCondition, substituteTriggerTokens, tryParseJson } from \"./filter-condition.js\"\nimport { resolveNodeRefs } from \"./node-refs.js\"\n\n/** Selector tab on an edge — \"range\" (from/to/step) or \"list\" (expression). */\nexport type SelectorMode = \"range\" | \"list\"\n\n/** Per-edge output mode controlling how upstream results reach downstream. */\nexport type OutputMode = \"last\" | \"each\" | \"all\" | \"item\"\n\n/** Edge-data fields consumed by selectListItems / isDefaultSelectorConfig. */\nexport type SelectorFields = {\n selectorMode?: SelectorMode\n listExpression?: string\n rangeFrom?: string\n rangeTo?: string\n rangeStep?: number\n}\n\n/** Full selector mode set — extends the edge-selector modes with new operators. */\nexport type FullSelectorMode =\n | \"item\"\n | \"range\"\n | \"list\"\n | \"random\"\n | \"modulo\"\n | \"predicate\"\n | \"named-key\"\n\n/** Operator set for predicate mode — reused from filter-list. */\nexport type SelectorPredicateOp =\n | \">\" | \"<\" | \">=\" | \"<=\"\n | \"=\" | \"!=\"\n | \"contains\" | \"not_contains\"\n | \"starts_with\" | \"ends_with\"\n | \"regex\"\n | \"exists\" | \"not_exists\"\n\n/** Config consumed by `runSelector` and `resolveSelectorRefs`. */\nexport type SelectorConfig = {\n mode: FullSelectorMode\n // item\n itemIndex?: string\n // range\n rangeFrom?: string\n rangeTo?: string\n rangeStep?: number\n // list\n listExpression?: string\n // random\n seed?: string\n randomCount?: number\n // modulo\n moduloDivisor?: string\n // predicate\n predicateField?: string\n predicateOp?: SelectorPredicateOp\n predicateValue?: string\n predicateMatch?: \"first\" | \"all\"\n predicateCaseSensitive?: boolean\n // named-key\n namedKeyField?: string\n namedKeyValue?: string\n}\n\n/** Result of a selector run. `picked ∪ rest = items`, `picked ∩ rest = ∅`. */\nexport type SelectorResult = { picked: string[]; rest: string[] }\n\n/**\n * Resolves a 1-based index expression to a 0-based array index.\n *\n * Supported expressions:\n * - \"1\", \"2\", ... — absolute 1-based index\n * - \"last\" — last element\n * - \"last-1\", \"last-2\", ... — relative from end\n *\n * Out-of-bounds values are clamped. Malformed input falls back to `defaultExpr`.\n */\nexport function resolveIndex(\n expr: string,\n listLength: number,\n defaultExpr: string = \"1\",\n): number {\n if (listLength <= 0) return 0\n\n const trimmed = expr.trim()\n let index: number\n\n if (trimmed === \"last\") {\n index = listLength - 1\n } else if (trimmed.startsWith(\"last-\")) {\n const offset = parseInt(trimmed.slice(5), 10)\n if (isNaN(offset) || offset < 0) return resolveIndex(defaultExpr === expr ? \"1\" : defaultExpr, listLength)\n index = listLength - 1 - offset\n } else {\n const n = parseInt(trimmed, 10)\n if (isNaN(n)) return resolveIndex(defaultExpr === expr ? \"1\" : defaultExpr, listLength)\n index = n - 1\n }\n\n return Math.max(0, Math.min(index, listLength - 1))\n}\n\n/**\n * Applies range and step slicing to a list of strings.\n *\n * `from` and `to` are 1-based index expressions (see `resolveIndex`).\n * `step` controls iteration direction and stride:\n * - positive step: forward iteration (from must be <= to)\n * - negative step: reverse iteration (from must be >= to)\n * - step 0 is treated as step 1\n *\n * Returns empty array if direction mismatches (e.g., from < to with negative step).\n */\nexport function applyRange(\n list: string[],\n from?: string,\n to?: string,\n step?: number,\n): string[] {\n if (list.length === 0) return []\n\n const fromIdx = resolveIndex(from ?? \"1\", list.length, \"1\")\n const toIdx = resolveIndex(to ?? \"last\", list.length, \"last\")\n const effectiveStep = step === 0 || step === undefined ? 1 : step\n\n if (effectiveStep > 0 && fromIdx > toIdx) return []\n if (effectiveStep < 0 && fromIdx < toIdx) return []\n\n const result: string[] = []\n if (effectiveStep > 0) {\n for (let i = fromIdx; i <= toIdx; i += effectiveStep) result.push(list[i])\n } else {\n for (let i = fromIdx; i >= toIdx; i += effectiveStep) result.push(list[i])\n }\n return result\n}\n\n/**\n * Migrates legacy `item:N` (0-based) outputMode to structured format.\n *\n * Legacy: `{ outputMode: \"item:0\" }` — 0-based index baked into mode string\n * New: `{ outputMode: \"item\", itemIndex: \"1\" }` — 1-based expression\n *\n * Returns the data unchanged if not a legacy item mode.\n */\nexport function migrateEdgeOutputMode(\n data: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n if (!data) return data\n\n const mode = data.outputMode as string | undefined\n if (!mode || !mode.startsWith(\"item:\")) return data\n\n const idx = parseInt(mode.split(\":\")[1], 10)\n return {\n ...data,\n outputMode: \"item\",\n itemIndex: String(isNaN(idx) ? 1 : idx + 1),\n }\n}\n\n/**\n * Builds the edge range label shown as a pill on the edge.\n * Examples:\n * - \"2..last-1 +2\" — range with step 2\n * - \"last..1 -1\" — reversed\n * - \"3\" — item mode, index 3\n * - undefined — \"last\" mode has no label\n */\nexport function buildRangeLabel(\n mode: string,\n rangeFrom?: string,\n rangeTo?: string,\n rangeStep?: number,\n itemIndex?: string,\n selectorMode?: SelectorMode,\n listExpression?: string,\n): string | undefined {\n return buildItemLabel(mode, rangeFrom, rangeTo, rangeStep, itemIndex, selectorMode, listExpression)\n}\n\n/** Internal: builds the item-side label (range / list / item / each). Mode \"last\" returns undefined. */\nfunction buildItemLabel(\n mode: string,\n rangeFrom?: string,\n rangeTo?: string,\n rangeStep?: number,\n itemIndex?: string,\n selectorMode?: SelectorMode,\n listExpression?: string,\n): string | undefined {\n if (mode === \"last\") return undefined\n\n if ((mode === \"each\" || mode === \"all\") && selectorMode === \"list\") {\n const trimmed = (listExpression ?? \"\").trim()\n if (trimmed === \"\") return undefined\n return truncateLabel(trimmed, 18)\n }\n\n if (mode === \"item\") return itemIndex || undefined\n\n const from = rangeFrom ?? \"1\"\n const to = rangeTo ?? \"last\"\n const step = rangeStep ?? 1\n const isDefaultRange = from === \"1\" && to === \"last\"\n const isDefaultStep = step === 1\n if (isDefaultRange && isDefaultStep) return undefined\n\n let label = `${from}..${to}`\n if ((mode === \"each\" || mode === \"all\") && !isDefaultStep) {\n label += step > 0 ? ` +${step}` : ` ${step}`\n }\n return label\n}\n\nfunction truncateLabel(s: string, maxLen: number): string {\n if (s.length <= maxLen) return s\n return s.slice(0, maxLen) + \"…\"\n}\n\n/**\n * Validates a list expression without resolving indices.\n * Used for live UI validation in the List tab input.\n *\n * Returns { ok: true } for empty/whitespace input — matches the\n * \"empty = all items\" runtime semantics.\n */\nexport function parseListExpression(\n expr: string,\n): { ok: true } | { ok: false; error: string } {\n const result = parseListTerms(expr.trim())\n return result.ok ? { ok: true } : { ok: false, error: result.error }\n}\n\n/** Internal: validates a single index token (\"1\", \"last\", \"last-3\"). */\nfunction isValidIndexToken(token: string): boolean {\n if (token === \"last\") return true\n if (/^[1-9]\\d*$/.test(token)) return true\n const m = /^last-(\\d+)$/.exec(token)\n if (m) return !isNaN(parseInt(m[1], 10))\n return false\n}\n\n/**\n * Parses a list expression and returns 0-based indices into the list,\n * in user-specified order. Preserves duplicates.\n *\n * Supported syntax:\n * <expr> := <term> (\",\" <term>)*\n * <term> := <index> | <index> \"..\" <index> (\":\" <step>)?\n * <index> := <number> | \"last\" | \"last-\" <number>\n * <step> := integer (0 coerced to 1)\n *\n * Clamps out-of-bounds indices. Malformed input logs a warning and\n * returns [0..listLength-1] (matches applyRange leniency).\n */\nexport function resolveListExpression(expr: string, listLength: number): number[] {\n if (listLength <= 0) return []\n const result = parseListTerms(expr.trim())\n if (!result.ok) {\n console.warn(\"[edge-range] invalid list expression:\", expr, \"—\", result.error)\n return indexRange(0, listLength - 1, 1)\n }\n if (result.terms.length === 0) return indexRange(0, listLength - 1, 1)\n\n const out: number[] = []\n for (const term of result.terms) {\n if (term.kind === \"index\") {\n out.push(resolveIndex(term.token, listLength))\n } else {\n const from = resolveIndex(term.from, listLength)\n const to = resolveIndex(term.to, listLength)\n for (const idx of indexRange(from, to, term.step)) out.push(idx)\n }\n }\n return out\n}\n\n/** Internal: inclusive index range with step. Returns [] if direction mismatches. */\nfunction indexRange(from: number, to: number, step: number): number[] {\n const out: number[] = []\n if (step > 0) {\n if (from > to) return []\n for (let i = from; i <= to; i += step) out.push(i)\n } else {\n if (from < to) return []\n for (let i = from; i >= to; i += step) out.push(i)\n }\n return out\n}\n\n/**\n * Dispatches to either applyRange() or resolveListExpression() based on\n * edgeData.selectorMode. Returns a new string[] containing the selected\n * subset of items — or `items` unchanged when the edge has no filter.\n */\nexport function selectListItems(\n items: string[],\n edgeData: SelectorFields | undefined,\n): string[] {\n if (items.length === 0) return []\n if (isDefaultSelectorConfig(edgeData)) return items\n if (edgeData?.selectorMode === \"list\") {\n const indices = resolveListExpression(edgeData.listExpression ?? \"\", items.length)\n return indices.map((i) => items[i])\n }\n return applyRange(items, edgeData?.rangeFrom, edgeData?.rangeTo, edgeData?.rangeStep)\n}\n\n/**\n * Returns true when edge data carries no active filter — empty/whitespace list\n * expression in list mode, or defaults (1..last, step 1) in range mode.\n * Callers can skip filtering entirely when this returns true.\n */\nexport function isDefaultSelectorConfig(edgeData: SelectorFields | undefined): boolean {\n if (!edgeData) return true\n if (edgeData.selectorMode === \"list\") {\n return ((edgeData.listExpression ?? \"\").trim()) === \"\"\n }\n const { from, to, step } = canonicalRange(edgeData)\n return from === \"1\" && to === \"last\" && step === 1\n}\n\nexport function describeEdgeBehavior(\n edgeData:\n | {\n outputMode?: string\n selectorMode?: SelectorMode\n listExpression?: string\n rangeFrom?: string\n rangeTo?: string\n rangeStep?: number\n itemIndex?: string\n }\n | undefined,\n): string {\n const mode = edgeData?.outputMode\n return buildBaseSentence(edgeData, mode)\n}\n\nfunction buildBaseSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n mode: string | undefined,\n): string {\n if (mode === \"last\") return \"Passes the selected result.\"\n if (mode === \"item\") return buildItemSentence(edgeData)\n if (mode === \"each\") return buildEachSentence(edgeData)\n if (mode === \"all\") return buildAllSentence(edgeData)\n return \"Passes all items at once.\"\n}\n\nfunction buildItemSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): string {\n const canonical = canonicalItemIndex(edgeData?.itemIndex)\n return `Passes only ${itemModeForm(canonical)}.`\n}\n\nfunction buildEachSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): string {\n if (isDefaultSelectorConfig(edgeData)) return \"Runs the next node one by one, per item.\"\n if (edgeData?.selectorMode === \"list\") {\n const result = parseListTerms((edgeData.listExpression ?? \"\").trim())\n if (!result.ok) return \"Runs the next node one by one, per item.\"\n }\n const phrase = buildSelectionPhrase(edgeData)\n if (phrase.kind === \"empty-result\") {\n return \"Nothing selected — the next node won't run.\"\n }\n if (phrase.kind === \"single-index\") {\n return `Runs the next node only on ${phrase.itemModeForm}.`\n }\n return `Runs the next node once for ${phrase.text}.`\n}\n\nfunction buildAllSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): string {\n if (isDefaultSelectorConfig(edgeData)) return \"Passes all items at once.\"\n if (edgeData?.selectorMode === \"list\") {\n const result = parseListTerms((edgeData.listExpression ?? \"\").trim())\n if (!result.ok) return \"Passes all items at once.\"\n }\n const phrase = buildSelectionPhrase(edgeData)\n if (phrase.kind === \"empty-result\") {\n return \"Nothing selected — the next node will get an empty bundle.\"\n }\n if (phrase.kind === \"single-index\") {\n return `Passes only ${phrase.itemModeForm}.`\n }\n return `Passes ${phrase.text} at once.`\n}\n\ntype CanonicalRange = { from: string; to: string; step: number }\n\nfunction canonicalItemIndex(raw: string | undefined): string {\n const trimmed = (raw ?? \"\").trim()\n if (trimmed === \"\") return \"1\"\n if (!isValidIndexToken(trimmed)) return \"1\"\n return trimmed\n}\n\nfunction canonicalRange(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): CanonicalRange {\n const from = ((edgeData?.rangeFrom ?? \"\").trim() || \"1\")\n const to = ((edgeData?.rangeTo ?? \"\").trim() || \"last\")\n const rawStep = edgeData?.rangeStep\n const step = rawStep === undefined || rawStep === 0 ? 1 : rawStep\n return { from, to, step }\n}\n\n\nfunction itemModeForm(canonical: string): string {\n if (canonical === \"1\") return \"the first item\"\n if (/^\\d+$/.test(canonical)) return `item ${canonical}`\n if (canonical === \"last\" || canonical === \"last-0\") return \"the last item\"\n const m = /^last-(\\d+)$/.exec(canonical)\n if (m) {\n const n = parseInt(m[1], 10)\n if (n === 1) return \"the second-to-last item\"\n if (n === 2) return \"the third-to-last item\"\n if (n === 3) return \"the fourth-to-last item\"\n return `the ${ordinal(n + 1)}-from-last item`\n }\n return \"the first item\"\n}\n\nfunction compactForm(canonical: string): string {\n if (/^\\d+$/.test(canonical)) return canonical\n if (canonical === \"last\" || canonical === \"last-0\") return \"the last one\"\n const m = /^last-(\\d+)$/.exec(canonical)\n if (m) {\n const n = parseInt(m[1], 10)\n if (n === 1) return \"the second-to-last\"\n if (n === 2) return \"the third-to-last\"\n if (n === 3) return \"the fourth-to-last\"\n return `the ${ordinal(n + 1)}-from-last`\n }\n return canonical\n}\n\nfunction ordinal(n: number): string {\n const absN = Math.abs(n)\n const lastTwo = absN % 100\n if (lastTwo >= 11 && lastTwo <= 13) return `${n}th`\n switch (absN % 10) {\n case 1: return `${n}st`\n case 2: return `${n}nd`\n case 3: return `${n}rd`\n default: return `${n}th`\n }\n}\n\ntype SelectionPhrase =\n | { kind: \"items\"; text: string }\n | { kind: \"single-index\"; itemModeForm: string }\n | { kind: \"empty-result\" }\n\nfunction buildSelectionPhrase(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): SelectionPhrase {\n if (edgeData?.selectorMode === \"list\") {\n return buildListSelectionPhrase((edgeData.listExpression ?? \"\").trim())\n }\n return buildRangeSelectionPhrase(canonicalRange(edgeData))\n}\n\nfunction indexKind(token: string): \"concrete\" | \"relative\" | \"invalid\" {\n if (/^[1-9]\\d*$/.test(token)) return \"concrete\"\n if (token === \"last\" || /^last-\\d+$/.test(token)) return \"relative\"\n return \"invalid\"\n}\n\nfunction relativeOffset(token: string): number {\n if (token === \"last\") return 0\n const m = /^last-(\\d+)$/.exec(token)\n return m ? parseInt(m[1], 10) : 0\n}\n\nfunction compareTokens(a: string, b: string): -1 | 0 | 1 | \"indeterminate\" {\n const ka = indexKind(a)\n const kb = indexKind(b)\n if (ka !== kb) return \"indeterminate\"\n if (ka === \"concrete\") {\n const na = parseInt(a, 10)\n const nb = parseInt(b, 10)\n return na < nb ? -1 : na > nb ? 1 : 0\n }\n if (ka === \"relative\") {\n const oa = relativeOffset(a)\n const ob = relativeOffset(b)\n return oa < ob ? 1 : oa > ob ? -1 : 0\n }\n return \"indeterminate\"\n}\n\nfunction buildRangeSelectionPhrase(r: CanonicalRange): SelectionPhrase {\n const { from, to, step } = r\n\n const cmp = compareTokens(from, to)\n if (cmp !== \"indeterminate\") {\n if (step > 0 && cmp === 1) return { kind: \"empty-result\" }\n if (step < 0 && cmp === -1) return { kind: \"empty-result\" }\n }\n\n if (cmp === 0) {\n return { kind: \"single-index\", itemModeForm: itemModeForm(from) }\n }\n\n const absStep = Math.abs(step)\n if (step === -1 && from === \"last\" && to === \"1\") {\n return { kind: \"items\", text: \"all items in reverse order\" }\n }\n\n let text = `items ${compactForm(from)} through ${compactForm(to)}`\n if (absStep === 1 && step < 0) {\n text += \" in reverse order\"\n } else if (absStep > 1 && step > 0) {\n text += ` (every ${ordinal(absStep)} item)`\n } else if (absStep > 1 && step < 0) {\n text += ` (every ${ordinal(absStep)} item, in reverse)`\n }\n return { kind: \"items\", text }\n}\n\ntype ListTerm =\n | { kind: \"index\"; token: string }\n | { kind: \"range\"; from: string; to: string; step: number }\n\ntype ParseResult =\n | { ok: true; terms: ListTerm[] }\n | { ok: false; error: string }\n\n/**\n * Core list-expression parser. Returns structured terms on success or a\n * specific error message on failure. Empty input → zero terms (not an error).\n * Error messages are surfaced unchanged in the edge-config tooltip, so they\n * must stay stable:\n * - \"Empty item between commas\"\n * - \"Invalid index: <token>\"\n * - \"Range missing endpoint: <term>\"\n * - \"Step must be an integer\"\n */\nfunction parseListTerms(expr: string): ParseResult {\n if (expr === \"\") return { ok: true, terms: [] }\n const terms: ListTerm[] = []\n const raw = expr.split(\",\")\n for (const rawTerm of raw) {\n const term = rawTerm.trim()\n if (term === \"\") return { ok: false, error: \"Empty item between commas\" }\n const rangeIdx = term.indexOf(\"..\")\n if (rangeIdx === -1) {\n if (!isValidIndexToken(term)) return { ok: false, error: `Invalid index: ${term}` }\n terms.push({ kind: \"index\", token: term })\n continue\n }\n const left = term.slice(0, rangeIdx).trim()\n const rightWithStep = term.slice(rangeIdx + 2).trim()\n if (left === \"\" || rightWithStep === \"\") {\n return { ok: false, error: `Range missing endpoint: ${term}` }\n }\n const colonIdx = rightWithStep.indexOf(\":\")\n const right = colonIdx === -1 ? rightWithStep : rightWithStep.slice(0, colonIdx).trim()\n const stepStr = colonIdx === -1 ? null : rightWithStep.slice(colonIdx + 1).trim()\n if (right === \"\") return { ok: false, error: `Range missing endpoint: ${term}` }\n if (!isValidIndexToken(left)) return { ok: false, error: `Invalid index: ${left}` }\n if (!isValidIndexToken(right)) return { ok: false, error: `Invalid index: ${right}` }\n let step = 1\n if (stepStr !== null) {\n if (!/^-?\\d+$/.test(stepStr)) return { ok: false, error: \"Step must be an integer\" }\n const parsed = parseInt(stepStr, 10)\n step = parsed === 0 ? 1 : parsed\n }\n terms.push({ kind: \"range\", from: left, to: right, step })\n }\n return { ok: true, terms }\n}\n\nfunction buildListSelectionPhrase(expr: string): SelectionPhrase {\n const result = parseListTerms(expr)\n if (!result.ok) return { kind: \"empty-result\" }\n if (result.terms.length === 0) return { kind: \"items\", text: \"items\" } // unreachable via callers; default-config catches empty\n\n const normalized = result.terms.map<ListTerm>((t) => {\n if (t.kind === \"range\") {\n const cmp = compareTokens(t.from, t.to)\n if (cmp === 0) return { kind: \"index\", token: t.from }\n }\n return t\n })\n\n if (normalized.length === 1 && normalized[0].kind === \"index\") {\n return { kind: \"single-index\", itemModeForm: itemModeForm(normalized[0].token) }\n }\n\n const rendered = normalized.map((t) => {\n if (t.kind === \"index\") return compactForm(t.token)\n let text = `${compactForm(t.from)} through ${compactForm(t.to)}`\n const absStep = Math.abs(t.step)\n if (absStep === 1 && t.step < 0) {\n if (t.from === \"last\" && t.to === \"1\") return \"all items in reverse\"\n text += \" in reverse\"\n } else if (absStep > 1 && t.step > 0) {\n text += ` (every ${ordinal(absStep)})`\n } else if (absStep > 1 && t.step < 0) {\n text += ` (every ${ordinal(absStep)}, in reverse)`\n }\n return text\n })\n\n let joined: string\n if (rendered.length === 1) {\n joined = rendered[0]\n } else if (rendered.length === 2) {\n joined = `${rendered[0]} and ${rendered[1]}`\n } else {\n const head = rendered.slice(0, -1).join(\", \")\n joined = `${head}, and ${rendered[rendered.length - 1]}`\n }\n return { kind: \"items\", text: `items ${joined}` }\n}\n\n/**\n * Run the selector against `items`. Returns the picked subset plus the\n * complement (`rest`). For modes that pick by index, `rest` is computed by\n * index exclusion (not value) so duplicate items are handled correctly.\n */\nexport function runSelector(items: string[], config: SelectorConfig): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n\n switch (config.mode) {\n case \"item\": {\n const idx = resolveIndex(config.itemIndex ?? \"1\", items.length, \"1\")\n return splitByIndices(items, [idx])\n }\n case \"range\": {\n const indices = applyRangeIndices(items.length, config.rangeFrom, config.rangeTo, config.rangeStep)\n return splitByIndices(items, indices)\n }\n case \"list\": {\n const indices = resolveListExpression(config.listExpression ?? \"\", items.length)\n return splitByIndices(items, indices)\n }\n case \"random\":\n return selectRandom(items, config.randomCount ?? 1, config.seed)\n case \"modulo\":\n return selectByModulo(items, config.moduloDivisor)\n case \"predicate\":\n return selectByPredicate(items, config)\n case \"named-key\":\n return selectByNamedKey(items, config.namedKeyField, config.namedKeyValue)\n default:\n return { picked: [], rest: items.slice() }\n }\n}\n\n/**\n * Partition `items` into picked (indices ∈ pickedIndices, in their original\n * order in the source list) and rest (everything else). Deduplicates\n * `pickedIndices` so passing the same index twice doesn't double-count.\n */\nfunction splitByIndices(items: string[], pickedIndices: number[]): SelectorResult {\n const pickedSet = new Set(pickedIndices.filter((i) => i >= 0 && i < items.length))\n const picked: string[] = []\n const rest: string[] = []\n for (let i = 0; i < items.length; i++) {\n if (pickedSet.has(i)) picked.push(items[i])\n else rest.push(items[i])\n }\n return { picked, rest }\n}\n\n/**\n * Returns the indices that `applyRange` would pick. Extracted so `runSelector`\n * range mode can compute the exact picked-index set (`items.indexOf(value)`\n * would return the wrong duplicate when the list contains repeated values).\n */\nexport function applyRangeIndices(\n length: number,\n from?: string,\n to?: string,\n step?: number,\n): number[] {\n if (length === 0) return []\n const fromIdx = resolveIndex(from ?? \"1\", length, \"1\")\n const toIdx = resolveIndex(to ?? \"last\", length, \"last\")\n const effectiveStep = step === 0 || step === undefined ? 1 : step\n if (effectiveStep > 0 && fromIdx > toIdx) return []\n if (effectiveStep < 0 && fromIdx < toIdx) return []\n const result: number[] = []\n if (effectiveStep > 0) {\n for (let i = fromIdx; i <= toIdx; i += effectiveStep) result.push(i)\n } else {\n for (let i = fromIdx; i >= toIdx; i += effectiveStep) result.push(i)\n }\n return result\n}\n\n/** mulberry32 PRNG — deterministic given a seed (any 32-bit signed integer).\n *\n * TWIN WARNING: backend/src/providers/video/audio-fx.ts carries its own\n * private mulberry32 (cosmetically different — `>>> 0` seed masking — but the\n * same sequence). The two are deliberately INDEPENDENT and both frozen: the\n * audio-fx copy seeds every reverb impulse response that the committed\n * characterization goldens (and every customer's rendered reverb waveform)\n * are pinned to. Do NOT \"deduplicate\" them into one shared export or \"sync\"\n * one to match the other — a change to either sequence is a silent behavior\n * change in its domain. */\nfunction mulberry32(seed: number): () => number {\n let a = seed | 0\n return () => {\n a = (a + 0x6D2B79F5) | 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** Hash a seed string to a 32-bit integer (FNV-1a variant). */\nfunction hashSeed(s: string): number {\n let h = 2166136261 | 0\n for (let i = 0; i < s.length; i++) {\n h ^= s.charCodeAt(i)\n h = Math.imul(h, 16777619)\n }\n return h\n}\n\n/**\n * Pick `count` items uniformly at random without replacement.\n * If `seed` is non-empty, the PRNG is seeded deterministically.\n * Otherwise `Math.random` is used (fresh randomness per call).\n */\nexport function selectRandom(items: string[], count: number, seed?: string): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n const k = Math.max(0, Math.min(count, items.length))\n const rand = seed && seed.length > 0 ? mulberry32(hashSeed(seed)) : Math.random\n // Partial Fisher-Yates: shuffle the first k positions, pick those indices.\n const indices = items.map((_, i) => i)\n for (let i = 0; i < k; i++) {\n const j = i + Math.floor(rand() * (indices.length - i))\n ;[indices[i], indices[j]] = [indices[j], indices[i]]\n }\n return splitByIndices(items, indices.slice(0, k))\n}\n\n/**\n * Pick a single item at `divisor % items.length`. Non-numeric `divisor`\n * falls back to index 0. Caller is responsible for resolving any\n * `{NodeLabel}` template refs in `divisor` BEFORE calling this — see\n * `resolveSelectorRefs`.\n */\nexport function selectByModulo(items: string[], divisor: string | undefined): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n const n = divisor ? Number.parseInt(divisor.trim(), 10) : NaN\n const safeN = Number.isFinite(n) ? n : 0\n const idx = ((safeN % items.length) + items.length) % items.length\n return splitByIndices(items, [idx])\n}\n\n/**\n * Pick items whose parsed JSON satisfies the predicate. `match: \"first\"`\n * (default) stops at the first hit; `\"all\"` collects every hit.\n *\n * Reuses the filter-list condition evaluator so operator semantics\n * (numeric coercion on `=`/`!=`, locale-aware ordering, case-sensitive\n * text ops) stay identical to the Filter List node.\n */\nexport function selectByPredicate(\n items: string[],\n config: SelectorConfig,\n): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n // Default operator to \"=\" so the UI's visual default (selector-config.tsx\n // shows `op={config.predicateOp ?? \"=\"}`) matches runtime; first-time\n // predicate use without explicitly setting an operator used to silently\n // return picked=[].\n // predicateField is intentionally allowed to be empty/undefined —\n // evaluateCondition treats an empty path as \"compare against the whole\n // item\" (filter-condition.ts:161), matching the UI placeholder hint\n // \"blank = whole item\" on the field input.\n const op = config.predicateOp ?? \"=\"\n // Pass caseSensitive explicitly. evaluateCondition defaults undefined to\n // `true` (case-sensitive) to preserve legacy callers, but the selector\n // UI checkbox shows unchecked by default — so undefined config must map\n // to case-INsensitive at runtime to match what the user sees.\n const opts = { caseSensitive: config.predicateCaseSensitive ?? false }\n const matchAll = config.predicateMatch === \"all\"\n const cond = {\n id: \"selector-predicate\",\n field: config.predicateField ?? \"\",\n operator: op,\n value: config.predicateValue ?? \"\",\n valueType: \"static\" as const,\n }\n const matchedIndices: number[] = []\n for (let i = 0; i < items.length; i++) {\n const parsed = tryParseJson(items[i])\n const hit = evaluateCondition(parsed, items[i], cond, undefined, opts)\n if (hit) {\n matchedIndices.push(i)\n if (!matchAll) break\n }\n }\n return splitByIndices(items, matchedIndices)\n}\n\n/**\n * Shortcut for `predicate(op=\"=\", match=\"first\")` — pick the first item\n * whose `field` strictly equals `value`. Implemented as a thin wrapper\n * so the UI can offer a 2-field form (\"look up by name\") instead of the\n * full 4-field predicate form.\n */\nexport function selectByNamedKey(\n items: string[],\n field: string | undefined,\n value: string | undefined,\n): SelectorResult {\n return selectByPredicate(items, {\n mode: \"predicate\",\n predicateField: field,\n predicateOp: \"=\",\n predicateValue: value,\n predicateMatch: \"first\",\n })\n}\n\n/**\n * Returns a new SelectorConfig with `{NodeLabel}` refs and `{{trigger.*}}` /\n * `{{now}}` / `{{last_N_*:N}}` template tokens resolved in the four\n * template-aware fields: moduloDivisor, predicateValue, namedKeyValue, seed.\n * All other fields are passed through unchanged. Callers must build\n * `variables` via `buildConditionVariables` (or equivalent) BEFORE calling.\n *\n * Other selector fields (itemIndex, range/list expressions, randomCount, etc.)\n * are treated as literals — they have their own selector-lib syntax and are\n * not resolved against the variable space.\n *\n * Token resolution matches `resolveConditionValue` exactly (both reuse\n * `substituteTriggerTokens`) so the selector's `{{trigger.foo}}` semantics\n * stay in lockstep with filter-list / router conditions.\n *\n * Pure: returns a new object; the input config is not mutated.\n */\nexport function resolveSelectorRefs(\n config: SelectorConfig,\n triggerData: Record<string, unknown> | undefined,\n variables: ReadonlyMap<string, string>,\n): SelectorConfig {\n const resolve = (v: string | undefined): string | undefined => {\n if (v == null) return v\n const refsResolved = resolveNodeRefs(v, variables)\n return substituteTriggerTokens(refsResolved, triggerData)\n }\n return {\n ...config,\n moduloDivisor: resolve(config.moduloDivisor),\n predicateValue: resolve(config.predicateValue),\n namedKeyValue: resolve(config.namedKeyValue),\n seed: resolve(config.seed),\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gpt-image-2-6.ts"],"names":[],"mappings":";AASO,IAAM,wBAAA,GAA2B,CA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CAAQ,MAAM,OAAA,CAAQ,KAAK,IAAI,KAAA,GAAQ,CAAC,KAAK,CAAA,EAAG,IAAA;AAAA,IAC9C,CAAC,KAAA,KAAU,OAAO,UAAU,QAAA,IAAY,KAAA,CAAM,WAAW,YAAY;AAAA,GACvE;AACF;AAQO,SAAS,yBAAA,CACd,KAAA,EACA,IAAA,EACA,WAAA,EACQ;AACR,EAAA,MAAM,MAAA,GAAS,CAAC,CAAA,KAAgB,KAAA,CAAM,QAAQ,CAAC,CAAA,GAAI,EAAE,MAAA,GAAS,CAAA;AAC9D,EAAA,MAAM,MAAA,GAAS,CAAC,CAAA,KAAgB,OAAO,MAAM,QAAA,IAAY,CAAA,CAAE,MAAA,GAAS,CAAA,GAAI,CAAA,GAAI,CAAA;AAC5E,EAAA,OACE,MAAA,CAAO,IAAA,CAAK,kBAAkB,CAAA,GAC9B,OAAO,IAAA,CAAK,sBAAsB,CAAA,GAClC,MAAA,CAAO,KAAK,SAAS,CAAA,GACrB,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,GAC7B,MAAA,CAAO,IAAA,CAAK,YAAY,CAAA,GACxB,MAAA,CAAO,IAAA,CAAK,cAAc,IAC1B,WAAA,IACC,cAAA,CAAe,IAAA,CAAK,SAAS,IAAI,kCAAA,GAAqC,CAAA,CAAA,IACtE,eAAA,CAAgB,KAAK,IAAI,CAAA,GAAI,CAAA,CAAA;AAElC","file":"chunk-IOET54EV.js","sourcesContent":["/**\n * What makes GPT Image 2.6 Flare and Sunburst price differently from every\n * other image model: a quality setting AND a size, and on an edit the number of\n * input images as well. Economy is a flat price and is not listed here.\n *\n * Only the ids and levers live in this published package. The rates and the\n * formula are `backend/src/ee/billing/gpt-image-2-6-pricing.ts`.\n */\n\nexport const GPT_IMAGE_2_6_TIERED_T2I = [\"gpt-image-2-6-flare\", \"gpt-image-2-6-sunburst\"] as const\nexport const GPT_IMAGE_2_6_TIERED_I2I = [\"gpt-image-2-6-flare-i2i\", \"gpt-image-2-6-sunburst-i2i\"] as const\nexport type GptImage26TieredModel =\n | (typeof GPT_IMAGE_2_6_TIERED_T2I)[number]\n | (typeof GPT_IMAGE_2_6_TIERED_I2I)[number]\n\nexport const GPT_IMAGE_2_6_QUALITIES = [\"auto\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const\nexport type GptImage26Quality = (typeof GPT_IMAGE_2_6_QUALITIES)[number]\n/**\n * The quality whose price is known only after the run: KIE picks the level. It\n * is reserved at the Max row and settled on what KIE really billed; every other\n * quality keeps its fixed row.\n */\nexport const GPT_IMAGE_2_6_METERED_QUALITY: GptImage26Quality = \"auto\"\nexport const GPT_IMAGE_2_6_RESOLUTIONS = [\"1K\", \"2K\", \"4K\"] as const\nexport type GptImage26Resolution = (typeof GPT_IMAGE_2_6_RESOLUTIONS)[number]\n\nexport const GPT_IMAGE_2_6_DEFAULT_QUALITY: GptImage26Quality = \"medium\"\nexport const GPT_IMAGE_2_6_DEFAULT_RESOLUTION: GptImage26Resolution = \"1K\"\n/** The most input images an edit is priced for (`REF_IMAGE_MAX_LIMITS`). */\nexport const GPT_IMAGE_2_6_MAX_INPUT_IMAGES = 16\n\nexport function isGptImage26I2i(model: string): boolean {\n return (GPT_IMAGE_2_6_TIERED_I2I as readonly string[]).includes(model)\n}\n\nexport function isGptImage26Tiered(model: string): model is GptImage26TieredModel {\n return isGptImage26I2i(model) || (GPT_IMAGE_2_6_TIERED_T2I as readonly string[]).includes(model)\n}\n\n/** True for a run whose charge is settled on KIE's own bill: Flare or Sunburst at quality Auto. */\nexport function isGptImage26AutoRun(provider: unknown, quality: unknown): boolean {\n return typeof provider === \"string\" && isGptImage26Tiered(provider) && quality === GPT_IMAGE_2_6_METERED_QUALITY\n}\n\n/**\n * The images a Generate Image run sends to KIE on GPT Image 2.6: its references\n * and, when it edits a base image, that image too (the worker puts it first,\n * unless it is already one of the references). Any other model is priced on its\n * references alone.\n */\nexport function gptImage26SentImages(\n provider: string | undefined,\n references: readonly string[],\n baseImageUrl: unknown,\n): number {\n const countsBase =\n provider !== undefined &&\n isGptImage26Tiered(provider) &&\n typeof baseImageUrl === \"string\" &&\n baseImageUrl.length > 0 &&\n !references.includes(baseImageUrl)\n return references.length + (countsBase ? 1 : 0)\n}\n\n/**\n * The most pictures a saved moodboard holds. A run sends them as references in\n * the seats the node's own images leave free. An estimate cannot read the\n * moodboard, so it counts this many.\n */\nexport const GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES = 12\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, and an image-to-image model's own\n * source. An estimate may over-quote, never under.\n */\nexport function gptImage26EstimatedImages(\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 (isGptImage26I2i(model) ? 1 : 0)\n )\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cast-swap-limits.ts","../src/gemini-omni-voices.ts","../src/node-default-mappings.ts","../src/tts-neighbour-text.ts","../src/provider-directive-defaults.ts","../src/lora-routing.ts","../src/suno-track-sources.ts","../src/voice-changer-models.ts","../src/model-tree.ts","../src/topaz-video.ts","../src/audio-soundtrack.ts"],"names":["IMAGE_GEN_PROVIDERS","IMAGE_I2I_PROVIDERS","IMAGE_EDIT_PROVIDERS","UPSCALE_IMAGE_PROVIDERS","TEXT_TO_VIDEO_PROVIDERS","IMAGE_TO_VIDEO_PROVIDERS","VIDEO_GEN_PROVIDERS","LIP_SYNC_PROVIDERS","TTS_PROVIDERS","VOICE_DESIGN_MODELS","LLM_MODEL_IDS","VIDEO_UPSCALE_PROVIDERS","VIDEO_DEPTH_PROVIDERS","MODIFY_IMAGE_PROVIDERS","VIDEO_TO_VIDEO_PROVIDERS","EXTEND_VIDEO_PROVIDERS","MOTION_TRANSFER_PROVIDERS","FACE_SWAP_PROVIDERS","DIALOGUE_PROVIDERS","TEXT_TO_AUDIO_PROVIDERS","TRANSCRIBE_PROVIDERS","MUSIC_PROVIDERS","MODEL_CATALOG","hasFeature"],"mappings":";;;;;;;;AAQO,IAAM,yBAAA,GAA4B;AAkBlC,IAAM,mBAAA,GAAsB;AAAA,EACjC,cAAA,EAAgB,GAAA;AAAA,EAChB,YAAA,EAAc,GAAA;AAAA,EACd,UAAA,EAAY,GAAA;AAAA,EACZ,iBAAA,EAAmB;AACrB;AAGO,IAAM,6BAAA,GAAgC;AAAA;AAAA,EAE3C,aAAA,EAAe,CAAC,CAAA,EAAG,GAAG,CAAA;AAAA;AAAA,EAEtB,OAAA,EAAS,CAAC,CAAA,EAAG,EAAE,CAAA;AAAA;AAAA,EAEf,eAAA,EAAiB,CAAC,GAAA,EAAK,CAAC,CAAA;AAAA,EACxB,SAAA,EAAW,CAAC,IAAA,EAAM,IAAI;AACxB;AAaO,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,MAAA,EAAQ,MAAM;AAU3D,IAAM,gBAAA,GAAmB,CAAC,SAAA,EAAW,QAAQ;AAK7C,IAAM,+BAAA,GAAkC;AAAA;AAAA,EAE7C,MAAA,EAAQ,MAAA;AAAA;AAAA,EAER,IAAA,EAAM,MAAA;AAAA,EACN,gBAAA,EAAkB,EAAA;AAAA,EAClB,gBAAA,EAAkB,CAAA;AAAA;AAAA;AAAA;A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OAAO,MAAM,CAAA;AACvB,IAAA,IAAI,CAAA,KAAM,GAAG,OAAO,KAAA;AACpB,IAAA,OAAO,CAAA,GAAI,CAAA,GAAI,CAAA,OAAA,EAAU,CAAA,GAAI,CAAC,CAAA,CAAA,GAAK,KAAA;AAAA,EACrC,CAAC,CAAA;AACD,EAAA,MAAM,IAAA,GACJ,GAAG,KAAK,CAAA,sKAAA,CAAA;AAEV,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,IAAA,EAAK,GAAI,GAAG,IAAI;AAAA,EAAK,OAAO,CAAA,CAAA,GAAK,IAAA;AAC1D,EAAA,OAAO,QAAA,CAAS,MAAA,IAAU,QAAA,GAAW,QAAA,GAAW,OAAA;AAClD","file":"chunk-NSZTHJZJ.cjs","sourcesContent":["/**\n * Cast Swap's input limits, and what a trend built on it may put in its\n * prompts. One definition read by the server (which enforces them) and by\n * every screen that edits them (which holds Save before a refusal), so the two\n * cannot drift apart.\n */\n\n/** The longest `postPrompt` Cast Swap takes. */\nexport const CAST_SWAP_POST_PROMPT_MAX = 4000\n\n/**\n * A trend's prompt limits.\n *\n * - `trendPromptMax` / `prePromptMax`: the longest prompt a trend version may\n * store.\n * - `detailsMax`: the longest details a user may add to a run. They follow the\n * trend prompt in Cast Swap's `postPrompt`, after a blank line, so a new\n * trend prompt is held to `CAST_SWAP_POST_PROMPT_MAX − 2 − detailsMax`.\n * - `engineTextReserve`: the room kept for the text Cast Swap writes around a\n * trend's prompts in the prompt it builds, at its longest (a block for each\n * of the 13 roles a run allows with 200-character role names, five\n * 500-character reference lines, the keep, mask and edit lines and the\n * header: about 16,100 characters, rounded up so a small wording change does\n * not need this moved). The pre prompt, the trend prompt and the details\n * share what is left of Seedance 2.5's prompt cap.\n */\nexport const TREND_PROMPT_LIMITS = {\n trendPromptMax: 3000,\n prePromptMax: 3000,\n detailsMax: 1000,\n engineTextReserve: 17_000,\n} as const\n\n/** Cast Swap's `faceMasking` bounds, each `[min, max]` inclusive. */\nexport const CAST_SWAP_FACE_MASKING_BOUNDS = {\n /** `minFaceHeightPct` and `maxFaceHeightPct`, % of the frame's height (max 0 = no limit). */\n faceHeightPct: [0, 100],\n /** Each `zone` margin, % of the frame. */\n zonePct: [0, 49],\n /** % of the frame's width. */\n blurStrengthPct: [0.1, 5],\n threshold: [0.05, 0.95],\n} as const satisfies Record<string, readonly [number, number]>\n\n/**\n * What a Cast Swap face mask covers (`faceMasking.target`):\n *\n * - `\"head\"` (the default): the whole head, hair included, and people seen\n * from behind or turned away, with a bigger mask.\n * - `\"face\"`: the face only; the hair, and a person turned away, stay visible.\n * - `\"body\"`: the whole person. A face mask that takes it hides everyone in\n * the clip, body and head (the biggest mask); a trend clip that keeps its\n * people as they are (the rest of the frame prepared) keeps them whole. A\n * clip made into depth as a whole takes no target.\n */\nexport const CAST_SWAP_FACE_MASK_TARGETS = [\"face\", \"head\", \"body\"] as const\n\nexport type CastSwapFaceMaskTarget = (typeof CAST_SWAP_FACE_MASK_TARGETS)[number]\n\n/**\n * How a direct Nodaro Motion run follows its clip (`style`, a public run\n * field): `\"precise\"` (the default) follows the clip exactly; `\"motion\"`\n * follows only the clip's movement and takes every look from the photos. A\n * trend run ignores it (its trend decides).\n */\nexport const CAST_SWAP_STYLES = [\"precise\", \"motion\"] as const\n\nexport type CastSwapStyle = (typeof CAST_SWAP_STYLES)[number]\n\n/** What Cast Swap uses for a `faceMasking` setting left out. */\nexport const CAST_SWAP_FACE_MASKING_DEFAULTS = {\n /** What a mask covers: the whole head (`CAST_SWAP_FACE_MASK_TARGETS`). */\n target: \"head\",\n /** What covers a masked face: a blur (`\"depth\"`, a depth-color view of it, is the other fill). */\n fill: \"blur\",\n minFaceHeightPct: 15,\n maxFaceHeightPct: 0,\n /**\n * The frame margins when `zone` is left out: a face centred in the outer 10 %\n * at the left or right is not masked (people walking in at the edge). An\n * explicit `zone: null`, or all four margins 0, means no margins.\n */\n zone: { leftPct: 10, rightPct: 10, topPct: 0, bottomPct: 0 },\n /** A margin left out of a `zone` that is given. */\n zonePct: 0,\n blurStrengthPct: 2,\n threshold: 0.5,\n} as const\n\n/**\n * The video engines Cast Swap runs on. A run or estimate that leaves `engine`\n * out runs on `CAST_SWAP_ENGINE_WHEN_OMITTED`, so callers that predate the\n * choice keep what they had.\n */\nexport const CAST_SWAP_ENGINES = [\"seedance-2-5\", \"kling-4\"] as const\n\nexport type CastSwapEngine = (typeof CAST_SWAP_ENGINES)[number]\n\n/** The engine of a run, estimate or trend that names none. */\nexport const CAST_SWAP_ENGINE_WHEN_OMITTED: CastSwapEngine = \"seedance-2-5\"\n\n/**\n * Nodaro Motion — what people see of Cast Swap. Its two engines' PUBLIC ids,\n * the only ones documented and returned (a trend's `engine`, a run record, a\n * quote): `\"motion-prism\"` (Nodaro Motion Prism) and `\"motion-pulse\"` (Nodaro\n * Motion Pulse).\n *\n * `CAST_SWAP_ENGINES` stays the INTERNAL vocabulary: what a stored trend\n * version names, and what the platform sends the Cast Swap engine (which takes\n * it in every version). A public id is mapped to it at every boundary that\n * reads one (`castSwapEngineFrom`), and back at every boundary a person reads\n * (`nodaroMotionEngineOf`). The engines' earlier public ids\n * (`NODARO_MOTION_LEGACY_ENGINES`) are read the same way and never returned.\n */\nexport const NODARO_MOTION_ENGINES = [\"motion-prism\", \"motion-pulse\"] as const\n\nexport type NodaroMotionEngine = (typeof NODARO_MOTION_ENGINES)[number]\n\n/**\n * The public ids the engines had before (renamed 2026-10-26), each with the\n * id it became. Still read wherever an engine is read — a request, a stored\n * run, an engine's declared engines, an admin setting's keys — and never\n * returned or documented.\n */\nexport const NODARO_MOTION_LEGACY_ENGINES = {\n \"motion-pro\": \"motion-prism\",\n \"motion-lite\": \"motion-pulse\",\n} as const satisfies Record<string, NodaroMotionEngine>\n\nexport type NodaroMotionLegacyEngine = keyof typeof NODARO_MOTION_LEGACY_ENGINES\n\n/** Each public id's earlier id (the inverse of `NODARO_MOTION_LEGACY_ENGINES`). */\nexport const NODARO_MOTION_LEGACY_ENGINE_OF = {\n \"motion-prism\": \"motion-pro\",\n \"motion-pulse\": \"motion-lite\",\n} as const satisfies Record<NodaroMotionEngine, NodaroMotionLegacyEngine>\n\n/**\n * Each public engine's name, as people read it. The earlier ids are keys too,\n * each answering the name of the engine it became, so code written against\n * them keeps reading a name (never undefined); iterate `NODARO_MOTION_ENGINES`,\n * not these keys.\n */\nexport const NODARO_MOTION_ENGINE_NAMES = {\n \"motion-prism\": \"Nodaro Motion Prism\",\n \"motion-pulse\": \"Nodaro Motion Pulse\",\n \"motion-pro\": \"Nodaro Motion Prism\",\n \"motion-lite\": \"Nodaro Motion Pulse\",\n} as const satisfies Record<NodaroMotionEngine | NodaroMotionLegacyEngine, string>\n\n/**\n * The internal engine each public id runs on (and the inverse, below). The\n * earlier ids are keys too, as in `NODARO_MOTION_ENGINE_NAMES`.\n */\nexport const CAST_SWAP_ENGINE_OF_NODARO_MOTION = {\n \"motion-prism\": \"seedance-2-5\",\n \"motion-pulse\": \"kling-4\",\n \"motion-pro\": \"seedance-2-5\",\n \"motion-lite\": \"kling-4\",\n} as const satisfies Record<NodaroMotionEngine | NodaroMotionLegacyEngine, CastSwapEngine>\n\n/** The public id of each internal engine. */\nexport const NODARO_MOTION_ENGINE_OF_CAST_SWAP = {\n \"seedance-2-5\": \"motion-prism\",\n \"kling-4\": \"motion-pulse\",\n} as const satisfies Record<CastSwapEngine, NodaroMotionEngine>\n\n/** The public id of an internal engine. */\nexport function nodaroMotionEngineOf(engine: CastSwapEngine): NodaroMotionEngine {\n return NODARO_MOTION_ENGINE_OF_CAST_SWAP[engine]\n}\n\n/** The name people read for an internal engine (\"Nodaro Motion Prism\" / \"Nodaro Motion Pulse\"). */\nexport function nodaroMotionEngineName(engine: CastSwapEngine): string {\n return NODARO_MOTION_ENGINE_NAMES[nodaroMotionEngineOf(engine)]\n}\n\n/**\n * The internal engine a value names, in any vocabulary: a public id\n * (`\"motion-prism\"`, `\"motion-pulse\"`), an earlier public id (`\"motion-pro\"`,\n * `\"motion-lite\"`) or an internal one (`\"seedance-2-5\"`, `\"kling-4\"`), the\n * last two still accepted from older clients, older engines and stored data.\n * Undefined for anything else.\n */\nexport function castSwapEngineFrom(value: unknown): CastSwapEngine | undefined {\n if (typeof value !== \"string\") return undefined\n // Its keys are the current and the earlier public ids.\n if (Object.hasOwn(CAST_SWAP_ENGINE_OF_NODARO_MOTION, value)) {\n return CAST_SWAP_ENGINE_OF_NODARO_MOTION[value as NodaroMotionEngine | NodaroMotionLegacyEngine]\n }\n return (CAST_SWAP_ENGINES as readonly string[]).includes(value) ? (value as CastSwapEngine) : undefined\n}\n\n/** The public id a value names, in any vocabulary (`castSwapEngineFrom`); undefined for anything else. */\nexport function nodaroMotionEngineFrom(value: unknown): NodaroMotionEngine | undefined {\n const engine = castSwapEngineFrom(value)\n return engine ? nodaroMotionEngineOf(engine) : undefined\n}\n\n/**\n * Every engine id a request may name: the public ids, then the earlier public\n * ids and the internal ones (still accepted, never documented).\n */\nexport const CAST_SWAP_ENGINE_IDS_ACCEPTED = [\n ...NODARO_MOTION_ENGINES,\n \"motion-pro\",\n \"motion-lite\",\n ...CAST_SWAP_ENGINES,\n] as const satisfies readonly (NodaroMotionEngine | NodaroMotionLegacyEngine | CastSwapEngine)[]\n\n/**\n * The resolutions each engine renders, the default first. Seedance 2.5's 480p\n * is its draft (`draft` is 480p only); Kling 4 has no draft and no 480p.\n */\nexport const CAST_SWAP_RESOLUTIONS_BY_ENGINE = {\n \"seedance-2-5\": [\"480p\", \"720p\", \"1080p\"],\n \"kling-4\": [\"720p\", \"1080p\"],\n} as const satisfies Record<CastSwapEngine, readonly (\"480p\" | \"720p\" | \"1080p\")[]>\n\n/** Whether an engine renders drafts (Seedance 2.5's 480p draft; Kling 4 has none). */\nexport function castSwapEngineHasDraft(engine: CastSwapEngine): boolean {\n return engine === \"seedance-2-5\"\n}\n\n/**\n * Where a Kling 4 run cuts the clip to whole seconds (Kling renders whole\n * seconds, and asked for more than the clip it stretches the motion; Seedance\n * 2.5 ignores it): `\"cut-end\"` (the default) drops the fraction of a second at\n * the clip's end, `\"cut-start\"` at its start.\n */\nexport const CAST_SWAP_KLING_LENGTHS = [\"cut-end\", \"cut-start\"] as const\n\nexport type CastSwapKlingLength = (typeof CAST_SWAP_KLING_LENGTHS)[number]\n\n/** The `klingLength` of a run or trend that names none. */\nexport const CAST_SWAP_KLING_LENGTH_WHEN_OMITTED: CastSwapKlingLength = \"cut-end\"\n\n/**\n * The most images one Kling 4 Cast Swap run sends, across every role and fixed\n * reference (a role with prepared references counts its one prepared\n * picture). Over it the route answers `too_many_images`.\n */\nexport const CAST_SWAP_KLING_MAX_IMAGES = 10\n","/**\n * The 30 preset voices Gemini Omni's audio-persona endpoint accepts, with the\n * style labels its documentation gives each one. DATA, so the API docs, the MCP\n * tool text and any client picker list them from one place instead of copying a\n * table that drifts.\n *\n * A preset is the BASE voice; a persona is that voice plus a free-text\n * description (timbre, pace, emotion) and an example line. Pinning a persona to a\n * character is what keeps one voice across separate clips.\n */\nexport interface GeminiOmniVoicePreset {\n id: string\n gender: \"female\" | \"male\" | \"genderless\"\n /** The documented character of the voice (\"soft\", \"raspy\", \"intellectual\"…). */\n style: string\n /** The documented pitch band (\"low\", \"mid-low\", \"mid\", \"mid-high\", \"high\"; \"younger\" for fenrir). */\n pitch: string\n}\n\nexport const GEMINI_OMNI_VOICE_PRESETS = [\n { id: \"achernar\", gender: \"female\", style: \"soft\", pitch: \"high\" },\n { id: \"achird\", gender: \"male\", style: \"friendly\", pitch: \"mid\" },\n { id: \"algenib\", gender: \"male\", style: \"raspy\", pitch: \"low\" },\n { id: \"algieba\", gender: \"male\", style: \"easygoing\", pitch: \"mid-low\" },\n { id: \"alnilam\", gender: \"male\", style: \"steady\", pitch: \"mid-low\" },\n { id: \"aoede\", gender: \"female\", style: \"brisk\", pitch: \"mid\" },\n { id: \"autonoe\", gender: \"female\", style: \"bright\", pitch: \"mid\" },\n { id: \"callirrhoe\", gender: \"female\", style: \"easygoing\", pitch: \"mid\" },\n { id: \"charon\", gender: \"male\", style: \"intellectual\", pitch: \"low\" },\n { id: \"despina\", gender: \"female\", style: \"smooth\", pitch: \"mid\" },\n { id: \"enceladus\", gender: \"male\", style: \"breathy\", pitch: \"low\" },\n { id: \"erinome\", gender: \"female\", style: \"clear\", pitch: \"mid\" },\n { id: \"fenrir\", gender: \"male\", style: \"lively\", pitch: \"younger\" },\n { id: \"gacrux\", gender: \"female\", style: \"mature\", pitch: \"mid\" },\n { id: \"iapetus\", gender: \"male\", style: \"clear\", pitch: \"mid-low\" },\n { id: \"kore\", gender: \"female\", style: \"capable\", pitch: \"mid\" },\n { id: \"laomedeia\", gender: \"female\", style: \"cheerful\", pitch: \"mid-high\" },\n { id: \"leda\", gender: \"female\", style: \"young\", pitch: \"mid-high\" },\n { id: \"orus\", gender: \"male\", style: \"steady\", pitch: \"mid-low\" },\n { id: \"puck\", gender: \"male\", style: \"cheerful\", pitch: \"mid\" },\n { id: \"pulcherrima\", gender: \"genderless\", style: \"forward\", pitch: \"mid-high\" },\n { id: \"rasalgethi\", gender: \"male\", style: \"intellectual\", pitch: \"mid\" },\n { id: \"sadachbia\", gender: \"male\", style: \"vivid\", pitch: \"low\" },\n { id: \"sadaltager\", gender: \"male\", style: \"knowledgeable\", pitch: \"mid\" },\n { id: \"schedar\", gender: \"male\", style: \"smooth\", pitch: \"mid-low\" },\n { id: \"sulafat\", gender: \"female\", style: \"warm\", pitch: \"mid\" },\n { id: \"umbriel\", gender: \"male\", style: \"smooth\", pitch: \"low\" },\n { id: \"vindemiatrix\", gender: \"female\", style: \"gentle\", pitch: \"mid\" },\n { id: \"zephyr\", gender: \"female\", style: \"bright\", pitch: \"mid-high\" },\n { id: \"zubenelgenubi\", gender: \"male\", style: \"casual\", pitch: \"mid-low\" },\n] as const satisfies readonly GeminiOmniVoicePreset[]\n\nexport type GeminiOmniVoicePresetId = (typeof GEMINI_OMNI_VOICE_PRESETS)[number][\"id\"]\n\n/** The preset ids as a non-empty tuple — what `z.enum(...)` takes. */\nexport const GEMINI_OMNI_VOICE_PRESET_IDS = GEMINI_OMNI_VOICE_PRESETS.map((v) => v.id) as unknown as readonly [\n GeminiOmniVoicePresetId,\n ...GeminiOmniVoicePresetId[],\n]\n","import {\n IMAGE_GEN_PROVIDERS,\n IMAGE_I2I_PROVIDERS,\n IMAGE_EDIT_PROVIDERS,\n UPSCALE_IMAGE_PROVIDERS,\n TEXT_TO_VIDEO_PROVIDERS,\n IMAGE_TO_VIDEO_PROVIDERS,\n VIDEO_GEN_PROVIDERS,\n LIP_SYNC_PROVIDERS,\n TTS_PROVIDERS,\n VOICE_DESIGN_MODELS,\n} from \"./model-constants.js\"\nimport { LLM_MODEL_IDS } from \"./llm-models.js\"\n\n// ──────────────────────────────────────────────────────────────────────────\n// Types\n// ──────────────────────────────────────────────────────────────────────────\n\nexport type QualityLevel = \"low\" | \"mid\" | \"high\"\nexport type SemanticAspectRatio = \"auto\" | \"1:1\" | \"4:3\" | \"3:4\" | \"16:9\" | \"9:16\"\n\nexport const NODE_DEFAULT_TYPES = [\n // Image\n \"generate-image\",\n \"image-to-image\",\n \"edit-image\",\n \"upscale-image\",\n // Video\n \"text-to-video\",\n \"image-to-video\",\n \"generate-video\",\n // Composition\n \"lip-sync\",\n // Audio / Music\n \"text-to-speech\",\n \"generate-music\",\n \"voice-design\",\n // LLM-driven\n \"ai-writer\",\n \"llm-chat\",\n \"lottie-overlay\",\n \"3d-title\",\n \"motion-graphics\",\n \"image-to-text\",\n \"qa-check\",\n] as const\n\nexport type NodeDefaultType = (typeof NODE_DEFAULT_TYPES)[number]\n\nexport const QUALITY_LEVELS: readonly QualityLevel[] = [\"low\", \"mid\", \"high\"] as const\nexport const SEMANTIC_ASPECT_RATIOS: readonly SemanticAspectRatio[] = [\n \"auto\",\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n] as const\n\n// ──────────────────────────────────────────────────────────────────────────\n// Per-node-type registry\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Per-node-type metadata: which field on the node carries the admin-set value,\n * the valid value set, and which optional dimensions apply.\n *\n * `field` distinguishes nodes that use `data.provider` (image/video/audio)\n * from nodes that use `data.model` (LLM nodes, voice-design).\n */\ninterface NodeTypeMeta {\n field: \"provider\" | \"model\"\n validValues: readonly string[]\n hasQuality: boolean\n hasAspectRatio: boolean\n}\n\n// Music providers per the runtime: enum currently only lists \"minimax\", but\n// `generate-music.defaultData.provider` is \"suno\" with a separate `modelVersion`.\n// Until that mismatch is fixed, accept both values for admin defaults.\nconst MUSIC_PROVIDERS_FOR_VALIDATION = [\"suno\", \"minimax\"] as const\n\nconst META: Record<NodeDefaultType, NodeTypeMeta> = {\n \"generate-image\": { field: \"provider\", validValues: IMAGE_GEN_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"image-to-image\": { field: \"provider\", validValues: IMAGE_I2I_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"edit-image\": { field: \"provider\", validValues: IMAGE_EDIT_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"upscale-image\": { field: \"provider\", validValues: UPSCALE_IMAGE_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"text-to-video\": { field: \"provider\", validValues: TEXT_TO_VIDEO_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"image-to-video\": { field: \"provider\", validValues: IMAGE_TO_VIDEO_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"generate-video\": { field: \"provider\", validValues: VIDEO_GEN_PROVIDERS, hasQuality: true, hasAspectRatio: true },\n \"lip-sync\": { field: \"provider\", validValues: LIP_SYNC_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"text-to-speech\": { field: \"provider\", validValues: TTS_PROVIDERS, hasQuality: false, hasAspectRatio: false },\n \"generate-music\": { field: \"provider\", validValues: MUSIC_PROVIDERS_FOR_VALIDATION, hasQuality: false, hasAspectRatio: false },\n \"voice-design\": { field: \"model\", validValues: VOICE_DESIGN_MODELS, hasQuality: false, hasAspectRatio: false },\n \"ai-writer\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"llm-chat\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"lottie-overlay\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"3d-title\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"motion-graphics\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"image-to-text\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n \"qa-check\": { field: \"model\", validValues: LLM_MODEL_IDS, hasQuality: false, hasAspectRatio: false },\n}\n\nexport function getTargetField(nodeType: NodeDefaultType): \"provider\" | \"model\" {\n return META[nodeType].field\n}\n\nexport function getValidValues(nodeType: NodeDefaultType): readonly string[] {\n return META[nodeType].validValues\n}\n\nexport function supportedDefaultDimensions(nodeType: NodeDefaultType): {\n quality: boolean\n aspectRatio: boolean\n} {\n const m = META[nodeType]\n return { quality: m.hasQuality, aspectRatio: m.hasAspectRatio }\n}\n\nexport function validateProviderForNodeType(\n nodeType: NodeDefaultType,\n value: string,\n): string | null {\n const valid = META[nodeType].validValues\n if (!valid.includes(value)) {\n return `value \"${value}\" is not valid for node type \"${nodeType}\"`\n }\n return null\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Semantic mappings — quality + aspect ratio per provider\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * Each provider stores its quality lever on a different field of node data:\n * - `resolution` (1K/2K/4K, 720p/1080p, …) — most image + video providers\n * - `quality` (medium/high, basic/high) — gpt-image, seedream\n *\n * Mapping a semantic level (low/mid/high) to a concrete value is meaningless\n * without knowing WHICH field it belongs to, because writing \"medium\" into\n * `resolution` (or \"2K\" into `quality`) trips the route's Zod enum at\n * generate-time. Each entry pairs the field with the per-level values built\n * from frontend/src/components/editor/config-panels/model-options.ts.\n *\n * Providers absent from this table return `undefined` from `mapQuality`,\n * letting the caller fall back to the factory default value.\n *\n * When a provider has fewer than 3 levels, semantic levels collapse onto\n * the closest concrete value (e.g. gpt-image only has medium/high → low maps\n * to medium).\n */\nexport type QualityField = \"resolution\" | \"quality\"\n\ninterface QualityMapping {\n field: QualityField\n values: Partial<Record<QualityLevel, string>>\n}\n\nconst QUALITY_MAP: Record<string, QualityMapping> = {\n // Image gen — resolution-style (1K/2K/4K)\n \"nano-banana-pro\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"nano-banana-2\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"nano-banana-2-1\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"flux\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-flex\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"flux-pro-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"gpt-image-2\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-flare\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-flare-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-sunburst\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-5-sunburst-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-flare\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-flare-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-sunburst\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n \"gpt-image-2-6-sunburst-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"4K\" } },\n // Image gen — quality-style (medium/high or basic/high)\n \"gpt-image\": { field: \"quality\", values: { low: \"medium\", mid: \"medium\", high: \"high\" } },\n \"gpt-image-i2i\": { field: \"quality\", values: { low: \"medium\", mid: \"medium\", high: \"high\" } },\n \"seedream\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-edit\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-lite\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-lite-i2i\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-pro\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n \"seedream-5-pro-i2i\": { field: \"quality\", values: { low: \"basic\", mid: \"basic\", high: \"high\" } },\n // Seedream 5 Flash's lever is size (sent as KIE `size`), flat-priced — resolution-style.\n \"seedream-5-flash\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n \"seedream-5-flash-i2i\": { field: \"resolution\", values: { low: \"1K\", mid: \"2K\", high: \"2K\" } },\n // Video gen — resolution-style (720p/1080p)\n \"veo3\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"veo3.1\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling-3.0\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"seedance-2\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"seedance-2-fast\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n \"seedance-2-mini\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n // Seedance 2.5 spans 480p/720p/1080p on KIE (1080p accepted since the\n // 2026-08-17 re-probe; 4k still rejected), so each quality rung gets its own tier.\n \"seedance-2-5\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // Wan 3.0 family — 480p / 720p / 1080p (lowercase catalog spellings; the\n // uppercase KIE wire form is produced only by normalizeWan3Resolution).\n \"wan-3\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n \"wan-3-prime\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"1080p\" } },\n // Vidu Q4 — five tiers; the quality rungs stop at 1080p so \"high\" never\n // lands on the 2k/4k ladder (4k is closed to the free tier).\n \"vidu-q4\": { field: \"resolution\", values: { low: \"540p\", mid: \"720p\", high: \"1080p\" } },\n // Kling 4.0 — two tiers on both endpoints.\n \"kling-4\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"1080p\" } },\n \"kling-4-keyframes\": { field: \"resolution\", values: { low: \"720p\", mid: \"720p\", high: \"1080p\" } },\n \"wan-2.7-i2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"wan-2.7-t2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-i2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-ref2v\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"happyhorse-edit\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"kling-3-omni\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n \"wan-videoedit\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"1080p\" } },\n // Lightricks LTX 2.3 — 1080p / 2k / 4k (lowercase, matching VIDEO_RESOLUTION_OPTIONS).\n // `field: \"resolution\"` is mandatory — see Provider Enum Sync pitfall 4.\n \"ltx-2.3-pro\": { field: \"resolution\", values: { low: \"1080p\", mid: \"2k\", high: \"4k\" } },\n \"ltx-2.3-fast\": { field: \"resolution\", values: { low: \"1080p\", mid: \"2k\", high: \"4k\" } },\n \"gemini-omni-video\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n \"gemini-omni-flash\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n \"gemini-omni-flash-1-2\": { field: \"resolution\", values: { low: \"720p\", mid: \"1080p\", high: \"4k\" } },\n // Grok Imagine Video 1.5 — only 480p/720p (no 1080p tier); high clamps to 720p.\n \"grok-imagine-video-1.5\": { field: \"resolution\", values: { low: \"480p\", mid: \"720p\", high: \"720p\" } },\n // Replicate Flux 2 family — MP-based resolution (matching IMAGE_RESOLUTION_OPTIONS[\"flux-2-*\"]).\n // `field: \"resolution\"` is mandatory — see Provider Enum Sync pitfall 4.\n // mid = provider default: 1 MP for Klein, 2 MP for Pro/Max.\n \"flux-2-klein\": { field: \"resolution\", values: { low: \"0.5 MP\", mid: \"1 MP\", high: \"2 MP\" } },\n \"flux-2-pro\": { field: \"resolution\", values: { low: \"1 MP\", mid: \"2 MP\", high: \"4 MP\" } },\n \"flux-2-max\": { field: \"resolution\", values: { low: \"1 MP\", mid: \"2 MP\", high: \"4 MP\" } },\n}\n\nconst ASPECT_PASSTHROUGH_PROVIDERS = new Set([\n ...IMAGE_GEN_PROVIDERS,\n ...IMAGE_I2I_PROVIDERS,\n ...TEXT_TO_VIDEO_PROVIDERS,\n ...IMAGE_TO_VIDEO_PROVIDERS,\n])\n\nexport interface MappedQuality {\n field: QualityField\n value: string\n}\n\nexport function mapQuality(provider: string, level: QualityLevel): MappedQuality | undefined {\n const m = QUALITY_MAP[provider]\n const value = m?.values[level]\n return value === undefined ? undefined : { field: m!.field, value }\n}\n\nexport function mapAspectRatio(\n provider: string,\n ratio: SemanticAspectRatio,\n): string | undefined {\n if (ratio === \"auto\") return undefined\n if (!ASPECT_PASSTHROUGH_PROVIDERS.has(provider as never)) return ratio\n return ratio\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Linked field derivation\n// ──────────────────────────────────────────────────────────────────────────\n\n/**\n * When admin sets `provider` for a node that has linked fields (e.g.\n * generate-image stores both `provider` AND `model`), derive the linked\n * fields so the resolver writes a coherent snapshot.\n *\n * For unmapped providers, returns `{}` — the runtime config panel applies\n * its own defaulting when needed.\n */\nconst GENERATE_IMAGE_PROVIDER_TO_MODEL: Record<string, string> = {\n \"nano-banana\": \"gemini-2.5-flash-image\",\n \"nano-banana-pro\": \"gemini-2.5-flash-image\",\n \"nano-banana-2\": \"gemini-2.5-flash-image\",\n \"nano-banana-2-lite\": \"gemini-3.1-flash-lite-image\",\n}\n\nexport function deriveLinkedFields(\n nodeType: NodeDefaultType,\n value: string,\n): Record<string, unknown> {\n if (nodeType === \"generate-image\") {\n const model = GENERATE_IMAGE_PROVIDER_TO_MODEL[value]\n return model ? { model } : {}\n }\n return {}\n}\n","/**\n * The neighbour-text rule of Text to Speech — what is spoken just BEFORE and just AFTER a clip in the finished\n * piece — in ONE place, so the editor's run, the provider exits and the REST route cannot drift: a request that\n * the editor sends must be one the route accepts.\n *\n * A string is trimmed; an empty one, or anything that is not a string, is ABSENT. Over the cap the value is\n * TRIMMED, never rejected, by every sender and exit: previous text keeps its LAST characters (what leads into\n * the clip), next text its FIRST (what the clip leads into). The REST route is the one place that rejects an\n * over-cap value — measured on the trimmed text, for a model that stitches only. Whether a model takes the\n * fields at all is its sheet (`ttsSupportsStitching`), never decided here.\n */\n\n/**\n * The most characters of context sent on each side. ElevenLabs documents no limit for the text-to-speech\n * endpoint's fields; this bounds what we send (and what the vendor may count) to about two sentences' worth of\n * run-in and run-out — enough to carry intonation across a cut.\n */\nexport const TTS_NEIGHBOUR_TEXT_MAX_CHARS = 1000\n\n/** The normalised pair: only non-empty strings within the cap; a side that was unusable is not a key. */\nexport interface TtsNeighbourText {\n previousText?: string\n nextText?: string\n}\n\nfunction usableText(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined\n const trimmed = value.trim()\n return trimmed ? trimmed : undefined\n}\n\n/** `previousText` / `nextText` of `options`, normalised. Other keys are not carried over; the input is never mutated. */\nexport function normalizeTtsNeighbourText(\n options: Readonly<{ previousText?: unknown; nextText?: unknown }> | undefined,\n): TtsNeighbourText {\n const out: TtsNeighbourText = {}\n const previous = usableText(options?.previousText)\n if (previous !== undefined) {\n out.previousText = previous.length > TTS_NEIGHBOUR_TEXT_MAX_CHARS ? previous.slice(-TTS_NEIGHBOUR_TEXT_MAX_CHARS) : previous\n }\n const next = usableText(options?.nextText)\n if (next !== undefined) {\n out.nextText = next.length > TTS_NEIGHBOUR_TEXT_MAX_CHARS ? next.slice(0, TTS_NEIGHBOUR_TEXT_MAX_CHARS) : next\n }\n return out\n}\n","import type { ShotSpec } from \"./scene-node-types.js\"\n\n/**\n * Provider-specific directive defaults. Architecture spec §5.14.\n *\n * Each video model can have side-effects the user usually wants (Seedance baking in\n * ambient music, VEO supporting loop seeds, etc.). The engine applies these defaults\n * at provider-call time, allowing them to be overridden by the Scene Director's\n * `shot_intent` field (provider-neutral) which we map below.\n *\n * Keys are canonical provider identifiers (matching VIDEO_MODEL_CAPS in\n * model-constants.ts). Non-canonical keys would silently break downstream\n * route validation + payload building.\n */\nexport const PROVIDER_DIRECTIVE_DEFAULTS = {\n \"seedance-2\": { multishot: true, disable_internal_music: true, allow_sfx: true },\n veo3: { reference_count: \"auto\" as const },\n \"veo3.1\": { reference_count: \"auto\" as const },\n kling: { reference_count: \"auto\" as const },\n \"kling-3-omni\": { reference_count: \"auto\" as const },\n \"kling-turbo\": { reference_count: \"auto\" as const },\n hailuo: {} as Record<string, never>,\n \"hailuo-2.3-pro\": {} as Record<string, never>,\n \"hailuo-standard\": {} as Record<string, never>,\n minimax: {} as Record<string, never>,\n // MiniMax Hailuo 3 — multimodal like seedance-2 but no verified directive\n // semantics yet; empty until probed (NOTE: never match `minimax-h3` with a\n // startsWith(\"seedance\") / startsWith(\"minimax\") prefix check — exact keys only).\n \"minimax-h3\": {} as Record<string, never>,\n \"bytedance-lite\": {} as Record<string, never>,\n} as const\n\n/**\n * Maps a Scene Director's provider-neutral shot_intent to provider-specific directives.\n * Architecture spec §5.14 mapping table.\n *\n * Unknown providers fall through to an empty object — the directive degrades to a text\n * hint in the motion_prompt (Scene Director includes it there as a fallback when\n * `needs_music_suppression: true`).\n */\nexport function mapShotIntentToProviderDirectives(\n provider: string,\n shotIntent: ShotSpec[\"shot_intent\"],\n): Record<string, unknown> {\n const directives: Record<string, unknown> = {\n ...(PROVIDER_DIRECTIVE_DEFAULTS[provider as keyof typeof PROVIDER_DIRECTIVE_DEFAULTS] ?? {}),\n }\n\n if (shotIntent.needs_multishot_reference) {\n if (provider.startsWith(\"seedance\")) {\n directives.multishot = true\n }\n // VEO + Kling: accepts reference_images array — engine attaches the refs separately.\n // Hailuo: only 1 ref — silently ignored at engine layer.\n }\n\n if (shotIntent.is_loopable) {\n if (provider.startsWith(\"veo\")) {\n directives.loop_seed = \"stable\"\n }\n // Other providers: no native loop_seed → degrade to motion_prompt frame-matching hint.\n }\n\n if (shotIntent.needs_music_suppression) {\n if (provider.startsWith(\"seedance\")) {\n directives.disable_internal_music = true\n }\n // VEO / Kling / Hailuo don't bake in music; no directive needed.\n }\n\n return directives\n}\n","/**\n * Character LoRA routing decision + identifier constants.\n *\n * Shared between backend (orchestrator's payload-builder) and frontend\n * (single-node Run's execute-node). MUST agree byte-for-byte — the backend\n * stamps the credit identifier and worker payload off this decision, the\n * frontend stamps the `_internalLora` body hint off it. Mismatches would\n * silently degrade trained-character generations to ref injection.\n */\n\n/**\n * Synthetic Replicate model id selected by the orchestrator (and the\n * single-node Run pre-Zod swap) when a single trained `@character` mention\n * is detected. Routes through `black-forest-labs/flux-dev-lora` with the\n * character's trained version under `extraParams.lora_version`. Never\n * appears in user-facing dropdowns.\n */\nexport const FLUX_LORA_CHARACTER_MODEL_ID = \"flux-lora-character\" as const\n\n/**\n * `jobs.job_type` discriminator + credit identifier for character LoRA\n * training jobs. Used for `STATIC_CREDIT_COSTS`/`model_pricing` lookup,\n * `creditGuard` reservation, refund flow, and webhook job lookup.\n */\nexport const CHARACTER_LORA_TRAINING_JOB_TYPE = \"character-lora-training\" as const\n\n/**\n * The three LoRA fields read off `CharacterNodeData` and stamped onto every\n * `ConnectedReference` produced from a wired character. Shared between the\n * backend's `expandWiredCharacterRefs` and the frontend's\n * `expandCharacterNodeIntoRefs` so both sides emit the same three fields\n * without copy-paste drift.\n */\nexport interface CharacterLoraFields {\n readonly loraReplicateVersion: string | null\n readonly loraTriggerWord: string | null\n readonly loraTrainingStatus: string | null\n}\n\n/**\n * Extract the three LoRA fields from a character node's `data`, normalized\n * to `null` for missing/undefined values so downstream type-checks (e.g.\n * `selectLoraRoutingForMentions`'s `=== \"succeeded\"`) are deterministic.\n */\nexport function extractCharacterLoraFields(charData: {\n loraReplicateVersion?: string | null\n loraTriggerWord?: string | null\n loraTrainingStatus?: string | null\n}): CharacterLoraFields {\n return {\n loraReplicateVersion: charData.loraReplicateVersion ?? null,\n loraTriggerWord: charData.loraTriggerWord ?? null,\n loraTrainingStatus: charData.loraTrainingStatus ?? null,\n }\n}\n\nexport interface LoraRouting {\n readonly characterSlug: string\n readonly triggerWord: string\n readonly loraVersion: string\n}\n\nexport interface LoraEligibleRef {\n readonly characterSlug?: string\n readonly loraReplicateVersion?: string | null\n readonly loraTriggerWord?: string | null\n readonly loraTrainingStatus?: string | null\n}\n\n/**\n * Returns a LoraRouting iff EXACTLY ONE distinct character is mentioned AND\n * that character has a successful LoRA. Returns null otherwise → caller\n * falls back to ref injection. Multi-character LoRA composition is Phase 2.\n */\nexport function selectLoraRoutingForMentions(\n refs: readonly LoraEligibleRef[],\n): LoraRouting | null {\n const distinct = new Set(refs.map((r) => r.characterSlug).filter(Boolean))\n if (distinct.size !== 1) return null\n const slug = [...distinct][0]!\n const match = refs.find((r) => r.characterSlug === slug)\n if (\n !match ||\n !match.loraReplicateVersion ||\n !match.loraTriggerWord ||\n match.loraTrainingStatus !== \"succeeded\"\n ) {\n return null\n }\n return {\n characterSlug: slug,\n triggerWord: match.loraTriggerWord,\n loraVersion: match.loraReplicateVersion,\n }\n}\n","/**\n * Node types whose output carries Suno chaining ids (`sunoTrackId` /\n * `sunoTaskId`) for a downstream Suno node (extend / separate / replace /\n * add-vocals / …) to chain off.\n *\n * One set for the three readers — the canvas resolver, the orchestrator\n * resolver, and the config panels' \"Inherited\" hint (#819). They used to keep\n * their own copies and drifted: the canvas read ids off a `suno-separate`\n * (whose output is stems, not a track) while the orchestrator ignored it, so\n * the same graph resolved on one path and not the other. Structural\n * vocabulary only — node type names, no prompt content.\n */\nexport const SUNO_TRACK_SOURCE_TYPES: ReadonlySet<string> = new Set([\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n])\n","/**\n * ElevenLabs speech-to-speech (voice changer) models — single source of truth\n * for the Voice Changer node's model picker (frontend config panel) AND the\n * `/v1/voice-changer` route Zod enum (backend). Lifting the list here keeps the\n * dropdown and the validation enum from ever drifting apart.\n *\n * These are the two `model_id` values ElevenLabs' `/v1/speech-to-speech/{voiceId}`\n * endpoint accepts with `can_do_voice_conversion`. ElevenLabs' own docs\n * recommend Multilingual v2 even for English source audio (it often\n * outperforms the English-only model), and it's required for non-English\n * audio (e.g. Hebrew), so it's the default — English v2 stays selectable.\n */\nexport const VOICE_CHANGER_MODELS = [\n {\n value: \"eleven_multilingual_sts_v2\",\n label: \"Multilingual v2\",\n desc: \"29 languages; preserves emotion, cadence & timing. Default — ElevenLabs recommends this even for English audio.\",\n },\n {\n value: \"eleven_english_sts_v2\",\n label: \"English v2\",\n desc: \"English-optimized speech-to-speech.\",\n },\n] as const\n\nexport type VoiceChangerModel = (typeof VOICE_CHANGER_MODELS)[number][\"value\"]\n\n/** Plain id list for the route's `z.enum(...)`. */\nexport const VOICE_CHANGER_MODEL_IDS: VoiceChangerModel[] = VOICE_CHANGER_MODELS.map(\n (m) => m.value,\n)\n\n/** ElevenLabs recommends Multilingual v2 even for English source audio (it\n * often outperforms the English-only model), and it's required for\n * non-English audio — so it's the default. English v2 remains selectable. */\nexport const DEFAULT_VOICE_CHANGER_MODEL: VoiceChangerModel = \"eleven_multilingual_sts_v2\"\n","/**\n * Models-tab data source: maps each catalog model to the node it creates\n * (`modelToNodeTarget`) and groups node-creatable models into product lines\n * (`buildModelTree`). Consumed by the add-node popup's Models tab. Pure — derives\n * everything from `MODEL_CATALOG` + the provider enums, so models added to the\n * catalog/enums flow through automatically.\n */\nimport { MODEL_CATALOG, type ModelKind, type ModelMode } from \"./model-catalog.js\"\nimport {\n IMAGE_GEN_PROVIDERS, VIDEO_GEN_PROVIDERS, IMAGE_TO_VIDEO_PROVIDERS, TEXT_TO_VIDEO_PROVIDERS,\n UPSCALE_IMAGE_PROVIDERS, VIDEO_UPSCALE_PROVIDERS, MODIFY_IMAGE_PROVIDERS, IMAGE_EDIT_PROVIDERS,\n VIDEO_TO_VIDEO_PROVIDERS, EXTEND_VIDEO_PROVIDERS, MOTION_TRANSFER_PROVIDERS, LIP_SYNC_PROVIDERS,\n FACE_SWAP_PROVIDERS, TTS_PROVIDERS, DIALOGUE_PROVIDERS, TEXT_TO_AUDIO_PROVIDERS, TRANSCRIBE_PROVIDERS, MUSIC_PROVIDERS,\n} from \"./model-constants.js\"\nimport { VIDEO_DEPTH_PROVIDERS } from \"./video-depth.js\"\n\nexport interface ModelNodeTarget {\n nodeType: string\n field?: \"provider\" | \"model\"\n value?: string\n}\nexport interface ModelTreeVariant extends ModelNodeTarget {\n id: string\n label: string\n kind: ModelKind\n}\nexport interface ModelTreeLine {\n series: string\n family: string\n kind: ModelKind\n models: ModelTreeVariant[]\n}\n\n// A model id that is a valid provider-enum value gets a node + provider preset.\nconst ENUM_TARGETS: ReadonlyArray<readonly [readonly string[], string]> = [\n [IMAGE_GEN_PROVIDERS, \"generate-image\"],\n [VIDEO_GEN_PROVIDERS, \"generate-video\"],\n [IMAGE_TO_VIDEO_PROVIDERS, \"generate-video\"],\n [TEXT_TO_VIDEO_PROVIDERS, \"generate-video\"],\n [UPSCALE_IMAGE_PROVIDERS, \"upscale-image\"],\n [VIDEO_UPSCALE_PROVIDERS, \"video-upscale\"],\n [VIDEO_DEPTH_PROVIDERS, \"video-depth\"],\n [MODIFY_IMAGE_PROVIDERS, \"modify-image\"],\n [IMAGE_EDIT_PROVIDERS, \"modify-image\"],\n [VIDEO_TO_VIDEO_PROVIDERS, \"video-to-video\"],\n [EXTEND_VIDEO_PROVIDERS, \"extend-video\"],\n [MOTION_TRANSFER_PROVIDERS, \"motion-transfer\"],\n [LIP_SYNC_PROVIDERS, \"lip-sync\"],\n [FACE_SWAP_PROVIDERS, \"face-swap\"],\n [TTS_PROVIDERS, \"text-to-speech\"],\n // A dialogue model's id is the node's `provider`: without this row the Models\n // tab would create a BARE dialogue node, which runs as the default (v3) whatever\n // the user picked.\n [DIALOGUE_PROVIDERS, \"text-to-dialogue\"],\n [TEXT_TO_AUDIO_PROVIDERS, \"text-to-audio\"],\n [TRANSCRIBE_PROVIDERS, \"transcribe\"],\n [MUSIC_PROVIDERS, \"suno-generate\"],\n]\n\n// Fallback by the catalog's own `modes`, for models whose id is NOT a provider-enum\n// value — single-provider utility nodes (voice-design, dubbing, …) and catalog models\n// that no node exposes as a provider option. These create a bare node of the right\n// type (no provider preset — the user picks the model inside the node).\nconst MODE_TO_NODE: Readonly<Partial<Record<ModelMode, string>>> = {\n \"t2i\": \"generate-image\", \"i2i\": \"modify-image\", \"edit\": \"modify-image\", \"remove-bg\": \"modify-image\",\n \"t2v\": \"generate-video\", \"i2v\": \"generate-video\", \"v2v\": \"video-to-video\", \"extend\": \"extend-video\",\n \"upscale\": \"upscale-image\", \"video-upscale\": \"video-upscale\", \"motion-transfer\": \"motion-transfer\",\n \"lip-sync\": \"lip-sync\", \"tts\": \"text-to-speech\", \"sfx\": \"text-to-audio\",\n \"music\": \"suno-generate\", \"voice-design\": \"voice-design\", \"voice-changer\": \"voice-changer\",\n \"isolation\": \"audio-isolation\", \"dubbing\": \"dubbing\", \"forced-alignment\": \"forced-alignment\", \"stt\": \"transcribe\",\n \"dialogue\": \"text-to-dialogue\",\n \"video-analysis\": \"video-analysis\",\n}\n\nexport function modelToNodeTarget(modelId: string): ModelNodeTarget | null {\n const entry = MODEL_CATALOG[modelId]\n if (!entry) return null\n // Resolve the target node: a valid provider-enum value wins, else the catalog's modes.\n const enumMatch = ENUM_TARGETS.find(([providers]) => providers.includes(modelId))\n const nodeType = enumMatch?.[1] ?? entry.modes.map((m) => MODE_TO_NODE[m]).find(Boolean)\n if (!nodeType) return null\n // suno-generate stores its model in `data.model` (a V-code carried on the catalog\n // entry as `dataValue`), not as a `provider` id. Every other node takes a `provider`\n // preset when the id is a valid enum value, and a bare node otherwise.\n if (nodeType === \"suno-generate\") {\n return entry.dataValue ? { nodeType, field: \"model\", value: entry.dataValue } : { nodeType }\n }\n return enumMatch ? { nodeType, field: \"provider\", value: modelId } : { nodeType }\n}\n\n/**\n * Flat, query-filtered model variants for the add-node search. The single source\n * of truth shared by the Models tab/category browser and every tab's search\n * (image/video/audio narrow by `kind`; models/all/common pass no kind). Filters\n * by label/id substring; a blank query returns `[]`. Derived from\n * `buildModelTree`, so only node-creatable models appear and new catalog entries\n * flow through automatically.\n */\n// MODEL_CATALOG + the provider enums are static module constants, so the tree\n// never changes at runtime — build it once and reuse for every search keystroke.\nlet _modelTree: ModelTreeLine[] | null = null\nfunction getModelTree(): ModelTreeLine[] {\n return (_modelTree ??= buildModelTree())\n}\n\nexport function searchModelVariants(query: string, kind?: ModelKind): ModelTreeVariant[] {\n const q = query.trim().toLowerCase()\n if (!q) return []\n return getModelTree()\n .flatMap((l) => l.models)\n .filter((m) => (!kind || m.kind === kind) && (m.label.toLowerCase().includes(q) || m.id.toLowerCase().includes(q)))\n}\n\nexport function buildModelTree(): ModelTreeLine[] {\n const bySeries = new Map<string, ModelTreeLine>()\n for (const entry of Object.values(MODEL_CATALOG)) {\n const target = modelToNodeTarget(entry.id)\n if (!target || !entry.series) continue\n let line = bySeries.get(entry.series)\n if (!line) {\n line = { series: entry.series, family: entry.family, kind: entry.kind, models: [] }\n bySeries.set(entry.series, line)\n }\n line.models.push({ id: entry.id, label: entry.label, kind: entry.kind, ...target })\n }\n return [...bySeries.values()].sort((a, b) => a.series.localeCompare(b.series))\n}\n","/**\n * Topaz video upscale — the lever a caller sets and the target it resolves to.\n *\n * Topaz takes an absolute TARGET, never a factor: a resolution (720p, 1080p or\n * 4K — the short side of the frame; a portrait clip keeps its orientation) and\n * an output frame rate (15–60 fps; frames it has to invent are interpolated).\n * The editor used to send a 1×/2×/4× factor, which saved workflows, older API\n * callers and private plugins still do, so a factor is still accepted and is\n * mapped onto the target here: factor × the source's short side, snapped to\n * the nearest target.\n *\n * One resolver for every lane (route, workflow run, plugin toolkit), so the\n * target a run is priced at is the one sent.\n */\n\nexport const TOPAZ_VIDEO_RESOLUTIONS = [\"720p\", \"1080p\", \"4k\"] as const\nexport type TopazVideoResolution = (typeof TOPAZ_VIDEO_RESOLUTIONS)[number]\n\nexport const TOPAZ_VIDEO_DEFAULT_RESOLUTION: TopazVideoResolution = \"1080p\"\n\n/** The short side, in pixels, of each target resolution. */\nexport const TOPAZ_VIDEO_SHORT_SIDE: Readonly<Record<TopazVideoResolution, number>> = {\n \"720p\": 720,\n \"1080p\": 1080,\n \"4k\": 2160,\n}\n\nexport const TOPAZ_VIDEO_FPS_MIN = 15\nexport const TOPAZ_VIDEO_FPS_MAX = 60\n/** The frame rates the editor offers beside \"same as source\". */\nexport const TOPAZ_VIDEO_FPS_CHOICES = [24, 25, 30, 50, 60] as const\n/** The rate used when neither the caller nor the source names one. */\nexport const TOPAZ_VIDEO_FALLBACK_FPS = 30\n\nexport function isTopazVideoResolution(v: unknown): v is TopazVideoResolution {\n return typeof v === \"string\" && (TOPAZ_VIDEO_RESOLUTIONS as readonly string[]).includes(v)\n}\n\n/**\n * The target whose short side is nearest `shortSide` px (4K above it, 720p\n * below; a tie takes the larger). A legacy factor lands here: a 720p clip at\n * 2× (1440 px) renders at 1080p, a 1080p clip at 2× at 4K.\n */\nexport function topazVideoResolutionNearest(shortSide: number): TopazVideoResolution {\n let best: TopazVideoResolution = TOPAZ_VIDEO_RESOLUTIONS[0]\n for (const r of TOPAZ_VIDEO_RESOLUTIONS) {\n if (Math.abs(TOPAZ_VIDEO_SHORT_SIDE[r] - shortSide) <= Math.abs(TOPAZ_VIDEO_SHORT_SIDE[best] - shortSide)) best = r\n }\n return best\n}\n\nexport function clampTopazVideoFps(fps: number): number {\n return Math.min(TOPAZ_VIDEO_FPS_MAX, Math.max(TOPAZ_VIDEO_FPS_MIN, Math.round(fps)))\n}\n\nexport interface TopazVideoSource {\n width: number\n height: number\n /** The source's own frame rate; absent when it has none (variable or unreadable). */\n fps?: number\n}\n\nexport interface TopazVideoTargetInput {\n targetResolution?: string | null\n /** Output frame rate; absent (or \"source\") = the source's own rate. */\n targetFps?: number | string | null\n /** Legacy relative lever (\"1\" | \"2\" | \"4\"): read only when no `targetResolution` is set. */\n upscaleFactor?: string | null\n source?: TopazVideoSource\n}\n\nexport interface TopazVideoTarget {\n resolution: TopazVideoResolution\n fps: number\n /** What was read in place of what was asked, for the job log. Empty when the request was taken as sent. */\n adjustments: string[]\n}\n\nconst LEGACY_FACTORS: Readonly<Record<string, number>> = { \"1\": 1, \"2\": 2, \"4\": 4 }\n\n/**\n * The target a Topaz video upscale renders at. `targetResolution` wins; else a\n * legacy factor over the source's short side; else 1080p. `targetFps` is\n * clamped to 15–60; absent, the source's rate (clamped), else 30.\n */\nexport function resolveTopazVideoTarget(input: TopazVideoTargetInput): TopazVideoTarget {\n const adjustments: string[] = []\n const shortSide = input.source ? Math.min(input.source.width, input.source.height) : undefined\n\n let resolution: TopazVideoResolution\n if (isTopazVideoResolution(input.targetResolution)) {\n resolution = input.targetResolution\n } else {\n if (input.targetResolution != null && input.targetResolution !== \"\") {\n adjustments.push(`targetResolution \"${input.targetResolution}\" is not one of ${TOPAZ_VIDEO_RESOLUTIONS.join(\", \")}`)\n }\n const factor = typeof input.upscaleFactor === \"string\" ? LEGACY_FACTORS[input.upscaleFactor.trim()] : undefined\n if (factor !== undefined && shortSide !== undefined) {\n resolution = topazVideoResolutionNearest(shortSide * factor)\n adjustments.push(`upscaleFactor ${factor}× of a ${shortSide}px short side → ${resolution}`)\n } else {\n resolution = TOPAZ_VIDEO_DEFAULT_RESOLUTION\n if (factor !== undefined) adjustments.push(`upscaleFactor ${factor}× with no readable source size → ${resolution}`)\n }\n }\n\n const asked = typeof input.targetFps === \"number\"\n ? input.targetFps\n : typeof input.targetFps === \"string\" && input.targetFps.trim() !== \"\" && input.targetFps !== \"source\"\n ? Number(input.targetFps)\n : undefined\n let fps: number\n if (asked !== undefined && Number.isFinite(asked)) {\n fps = clampTopazVideoFps(asked)\n if (fps !== asked) adjustments.push(`targetFps ${asked} → ${fps}`)\n } else if (input.source?.fps !== undefined && Number.isFinite(input.source.fps) && input.source.fps > 0) {\n fps = clampTopazVideoFps(input.source.fps)\n } else {\n fps = TOPAZ_VIDEO_FALLBACK_FPS\n }\n\n return { resolution, fps, adjustments }\n}\n\n/**\n * The output frame size a target renders a source at: the short side at the\n * target, the long side scaled by the source's aspect, both even. Without a\n * source, a 16:9 frame.\n */\nexport function topazVideoOutputSize(\n resolution: TopazVideoResolution,\n source?: Pick<TopazVideoSource, \"width\" | \"height\">,\n): { width: number; height: number } {\n const short = TOPAZ_VIDEO_SHORT_SIDE[resolution]\n const ratio = source && source.width > 0 && source.height > 0\n ? Math.max(source.width, source.height) / Math.min(source.width, source.height)\n : 16 / 9\n const long = Math.round((short * ratio) / 2) * 2\n const portrait = source ? source.height > source.width : false\n return portrait ? { width: short, height: long } : { width: long, height: short }\n}\n","import { hasFeature } from \"./model-catalog.js\"\n\n/**\n * Audio soundtrack: a video model whose reference audio clips are VOICE samples\n * (catalog feature `voice-references`, Kling 4.0) cannot play a clip as it is —\n * but it keeps a reference VIDEO's own sound when asked (`keep_original_sound`).\n * A model declaring `audio-soundtrack` therefore plays the FIRST reference audio\n * clip as the result's soundtrack: the platform turns that clip into a short\n * reference video (one still frame carrying the audio) and sends it with the\n * video's sound kept, so the people in the scene perform to the exact track.\n * Any further clips stay voice samples.\n *\n * On by default (`audioSoundtrack` unset = on); a caller turns it off with\n * `audioSoundtrack: false`. The clip then IS a reference video everywhere a run\n * is checked or priced — the reference-video price, the 5-clip and 30-second\n * caps — because the request carries it as one before any of those run.\n */\n\n/** The shortest reference video Kling 4.0 accepts; a shorter clip is padded with silence. */\nexport const AUDIO_SOUNDTRACK_MIN_SEC = 2\n\n/** The soundtrack clip's frame rate: its length is a whole number of these frames. */\nexport const AUDIO_SOUNDTRACK_FPS = 24\n\n/** Whether this run plays its first reference audio clip as the soundtrack. */\nexport function audioSoundtrackActive(args: {\n provider: string | undefined\n /** The node / request lever; unset = on. */\n audioSoundtrack: boolean | undefined\n /** How many reference audio clips the run carries (or has wired). */\n audioRefCount: number\n}): boolean {\n return (\n !!args.provider &&\n hasFeature(args.provider, \"audio-soundtrack\") &&\n args.audioSoundtrack !== false &&\n args.audioRefCount > 0\n )\n}\n\n/**\n * The length of the soundtrack clip a run sends: the audio's own length, at\n * least {@link AUDIO_SOUNDTRACK_MIN_SEC} (padded with silence) and at most the\n * clip being made (the rest of a longer track is not played), on whole frames\n * of {@link AUDIO_SOUNDTRACK_FPS} — the length the rendered file measures, so\n * the quote, the estimate and the run's own reservation all read one number.\n * An audio whose length is unknown counts as the whole clip — the longest it\n * can be, so a price built from it is never below the run's.\n */\nexport function audioSoundtrackClipSec(audioSec: number, outputSec: number): number {\n const sec = !Number.isFinite(audioSec) || audioSec <= 0 ? outputSec : Math.min(outputSec, Math.max(AUDIO_SOUNDTRACK_MIN_SEC, audioSec))\n return Math.round(sec * AUDIO_SOUNDTRACK_FPS) / AUDIO_SOUNDTRACK_FPS\n}\n\n/**\n * The prompt for a soundtrack run: the soundtrack clip is reference video\n * `@video_<videoNumber>` (after the caller's own clips), so a mention of the\n * first audio clip (`@audio_1`) now names it, and the remaining audio clips\n * move down one (`@audio_2` → `@audio_1`). A sentence before the prompt says\n * what that clip is for, when it fits within `maxChars` (the model's prompt\n * limit) — a prompt already near the limit keeps only the renaming.\n */\nexport function audioSoundtrackPrompt(prompt: string, videoNumber: number, maxChars = Number.POSITIVE_INFINITY): string {\n const video = `@video_${videoNumber}`\n const renamed = prompt.replace(/@audio_(\\d+)(?![\\w一-龥])/g, (whole, digits: string) => {\n const n = Number(digits)\n if (n === 1) return video\n return n > 1 ? `@audio_${n - 1}` : whole\n })\n const lead =\n `${video} is the soundtrack: the people in the scene perform to this exact audio, ` +\n \"their lips in sync with any singing or speech. Take only its sound, nothing from its picture.\"\n const withLead = renamed.trim() ? `${lead}\\n${renamed}` : lead\n return withLead.length <= maxChars ? withLead : renamed\n}\n"]}
|