@nodaro/shared 3.33.0 → 3.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CK3GK34R.js → chunk-2HIDE3QV.js} +9 -3
- package/dist/chunk-2HIDE3QV.js.map +1 -0
- package/dist/{chunk-WDIBOWAA.js → chunk-2HVFF5SS.js} +6 -6
- package/dist/chunk-2HVFF5SS.js.map +1 -0
- package/dist/{chunk-PVJBAPYJ.js → chunk-56VQ7V3V.js} +8 -5
- package/dist/chunk-56VQ7V3V.js.map +1 -0
- package/dist/{chunk-Z2OL5AJD.cjs → chunk-6F6GGX2W.cjs} +4 -3
- package/dist/chunk-6F6GGX2W.cjs.map +1 -0
- package/dist/{chunk-HKFMXNVQ.cjs → chunk-75ZMA34U.cjs} +11 -11
- package/dist/{chunk-HKFMXNVQ.cjs.map → chunk-75ZMA34U.cjs.map} +1 -1
- package/dist/{chunk-6WZ2VN7V.js → chunk-7AB3AE5L.js} +6 -6
- package/dist/{chunk-6WZ2VN7V.js.map → chunk-7AB3AE5L.js.map} +1 -1
- package/dist/{chunk-VXPLKQWY.cjs → chunk-7VQPHLZ5.cjs} +30 -40
- package/dist/chunk-7VQPHLZ5.cjs.map +1 -0
- package/dist/{chunk-BG5D5CZ6.js → chunk-ANOQWAMU.js} +23 -6
- package/dist/chunk-ANOQWAMU.js.map +1 -0
- package/dist/{chunk-PRYE7AZQ.cjs → chunk-AWWOQH46.cjs} +7 -7
- package/dist/chunk-AWWOQH46.cjs.map +1 -0
- package/dist/{chunk-PXFQVLBX.js → chunk-AXUW64ZY.js} +26 -36
- package/dist/chunk-AXUW64ZY.js.map +1 -0
- package/dist/{chunk-FT5CF6IA.js → chunk-AZBIXGM5.js} +3 -3
- package/dist/{chunk-FT5CF6IA.js.map → chunk-AZBIXGM5.js.map} +1 -1
- package/dist/{chunk-D6GNRSCV.cjs → chunk-BBLE4UTG.cjs} +23 -6
- package/dist/chunk-BBLE4UTG.cjs.map +1 -0
- package/dist/{chunk-HUR6ZJ7S.cjs → chunk-BSQCKTXH.cjs} +6 -6
- package/dist/{chunk-HUR6ZJ7S.cjs.map → chunk-BSQCKTXH.cjs.map} +1 -1
- package/dist/{chunk-HGC5JNVA.cjs → chunk-BVVKMQKR.cjs} +9 -2
- package/dist/chunk-BVVKMQKR.cjs.map +1 -0
- package/dist/{chunk-SAW5OK36.cjs → chunk-BYP62B7F.cjs} +6 -6
- package/dist/{chunk-SAW5OK36.cjs.map → chunk-BYP62B7F.cjs.map} +1 -1
- package/dist/{chunk-YYV35XOS.js → chunk-C4R7BTBQ.js} +4 -3
- package/dist/chunk-C4R7BTBQ.js.map +1 -0
- package/dist/{chunk-UCFWI6D4.js → chunk-CMH2ACOX.js} +3 -3
- package/dist/{chunk-UCFWI6D4.js.map → chunk-CMH2ACOX.js.map} +1 -1
- package/dist/{chunk-WD6HJRBG.cjs → chunk-DE3PEIIP.cjs} +21 -21
- package/dist/{chunk-WD6HJRBG.cjs.map → chunk-DE3PEIIP.cjs.map} +1 -1
- package/dist/{chunk-SFW3UB2P.js → chunk-DKTRVOU5.js} +4 -4
- package/dist/{chunk-SFW3UB2P.js.map → chunk-DKTRVOU5.js.map} +1 -1
- package/dist/{chunk-YBPBK5KI.js → chunk-FKQJYMCO.js} +97 -23
- package/dist/chunk-FKQJYMCO.js.map +1 -0
- package/dist/{chunk-ZDFHA2EC.js → chunk-FVKCNAEQ.js} +51 -7
- package/dist/chunk-FVKCNAEQ.js.map +1 -0
- package/dist/{chunk-OZSACQ2V.js → chunk-GW54ANCH.js} +3 -3
- package/dist/{chunk-OZSACQ2V.js.map → chunk-GW54ANCH.js.map} +1 -1
- package/dist/chunk-GZH2SIOF.cjs +99 -0
- package/dist/chunk-GZH2SIOF.cjs.map +1 -0
- package/dist/{chunk-M7GQBRZU.cjs → chunk-HABDAHZR.cjs} +153 -24
- package/dist/chunk-HABDAHZR.cjs.map +1 -0
- package/dist/{chunk-CUH22J4D.js → chunk-IIGKJYWL.js} +3 -3
- package/dist/{chunk-CUH22J4D.js.map → chunk-IIGKJYWL.js.map} +1 -1
- package/dist/{chunk-JL4C5VJ7.cjs → chunk-J65CAOUV.cjs} +14 -2
- package/dist/chunk-J65CAOUV.cjs.map +1 -0
- package/dist/{chunk-HRXEZ3SX.cjs → chunk-JABZNRXL.cjs} +4 -4
- package/dist/{chunk-HRXEZ3SX.cjs.map → chunk-JABZNRXL.cjs.map} +1 -1
- package/dist/{chunk-5RYLK3MQ.js → chunk-JMUHMLJP.js} +11 -6
- package/dist/chunk-JMUHMLJP.js.map +1 -0
- package/dist/{chunk-K3LLGRK7.cjs → chunk-KOP7UTQR.cjs} +72 -15
- package/dist/chunk-KOP7UTQR.cjs.map +1 -0
- package/dist/{chunk-HC7VKIV5.cjs → chunk-LT5IJO4Y.cjs} +49 -46
- package/dist/chunk-LT5IJO4Y.cjs.map +1 -0
- package/dist/{chunk-VA42637J.cjs → chunk-MSDECC3A.cjs} +46 -41
- package/dist/chunk-MSDECC3A.cjs.map +1 -0
- package/dist/{chunk-JFS3NWZ5.cjs → chunk-MSIIC6MY.cjs} +7 -4
- package/dist/chunk-MSIIC6MY.cjs.map +1 -0
- package/dist/{chunk-D26ENTN2.cjs → chunk-NITAUX3A.cjs} +80 -52
- package/dist/chunk-NITAUX3A.cjs.map +1 -0
- package/dist/{chunk-23FJQTEA.js → chunk-NTHRTRQK.js} +38 -15
- package/dist/chunk-NTHRTRQK.js.map +1 -0
- package/dist/{chunk-OTATNBMD.js → chunk-NYMOHNYV.js} +3 -3
- package/dist/{chunk-OTATNBMD.js.map → chunk-NYMOHNYV.js.map} +1 -1
- package/dist/{chunk-PQHS255G.js → chunk-OHSIVNJO.js} +3 -3
- package/dist/chunk-OHSIVNJO.js.map +1 -0
- package/dist/{chunk-7Z5LUTGU.js → chunk-QXTCIJP5.js} +6 -3
- package/dist/{chunk-JFS3NWZ5.cjs.map → chunk-QXTCIJP5.js.map} +1 -1
- package/dist/{chunk-5PC6JBGJ.cjs → chunk-R2VF5NQG.cjs} +3 -3
- package/dist/chunk-R2VF5NQG.cjs.map +1 -0
- package/dist/{chunk-UTQSSKSG.js → chunk-SPP6HQMM.js} +4 -4
- package/dist/{chunk-UTQSSKSG.js.map → chunk-SPP6HQMM.js.map} +1 -1
- package/dist/chunk-TCBHVIMD.js +89 -0
- package/dist/chunk-TCBHVIMD.js.map +1 -0
- package/dist/{chunk-SES6GDBQ.cjs → chunk-UJJUX6NW.cjs} +59 -8
- package/dist/chunk-UJJUX6NW.cjs.map +1 -0
- package/dist/{chunk-ZRL2UFTH.cjs → chunk-V3N56Z2S.cjs} +101 -22
- package/dist/chunk-V3N56Z2S.cjs.map +1 -0
- package/dist/{chunk-PHZ23DP3.js → chunk-VRLRPGO7.js} +125 -12
- package/dist/chunk-VRLRPGO7.js.map +1 -0
- package/dist/{chunk-WKOIGLQX.cjs → chunk-VRUN5TG2.cjs} +8 -8
- package/dist/{chunk-WKOIGLQX.cjs.map → chunk-VRUN5TG2.cjs.map} +1 -1
- package/dist/{chunk-QA3MVQ32.js → chunk-W4GABGRD.js} +6 -6
- package/dist/chunk-W4GABGRD.js.map +1 -0
- package/dist/{chunk-M36G6SRP.js → chunk-WXNQMJ67.js} +14 -3
- package/dist/chunk-WXNQMJ67.js.map +1 -0
- package/dist/chunk-XJ3HJSO5.cjs +25 -0
- package/dist/chunk-XJ3HJSO5.cjs.map +1 -0
- package/dist/{chunk-XGFTL5XY.js → chunk-YHCG3HOR.js} +3 -3
- package/dist/{chunk-XGFTL5XY.js.map → chunk-YHCG3HOR.js.map} +1 -1
- package/dist/{chunk-VNQRI2RO.cjs → chunk-YN6AXDN5.cjs} +16 -16
- package/dist/{chunk-VNQRI2RO.cjs.map → chunk-YN6AXDN5.cjs.map} +1 -1
- package/dist/{chunk-2NQLSLSN.cjs → chunk-YNJ44IAL.cjs} +5 -5
- package/dist/{chunk-2NQLSLSN.cjs.map → chunk-YNJ44IAL.cjs.map} +1 -1
- package/dist/{chunk-ZL7UM6PU.cjs → chunk-YSEM7JDE.cjs} +4 -4
- package/dist/{chunk-ZL7UM6PU.cjs.map → chunk-YSEM7JDE.cjs.map} +1 -1
- package/dist/{chunk-ZO5PBBFX.js → chunk-ZG4XSEZV.js} +72 -15
- package/dist/chunk-ZG4XSEZV.js.map +1 -0
- package/dist/entries/apps.cjs +43 -42
- package/dist/entries/apps.d.cts +2 -2
- package/dist/entries/apps.d.ts +2 -2
- package/dist/entries/apps.js +8 -7
- package/dist/entries/catalogs.d.cts +1 -1
- package/dist/entries/catalogs.d.ts +1 -1
- package/dist/entries/credits.cjs +153 -153
- package/dist/entries/credits.d.cts +1 -1
- package/dist/entries/credits.d.ts +1 -1
- package/dist/entries/credits.js +8 -8
- package/dist/entries/edl.cjs +130 -102
- package/dist/entries/edl.d.cts +74 -3
- package/dist/entries/edl.d.ts +74 -3
- package/dist/entries/edl.js +2 -2
- package/dist/entries/entities.cjs +126 -122
- package/dist/entries/entities.d.cts +2 -2
- package/dist/entries/entities.d.ts +2 -2
- package/dist/entries/entities.js +1 -1
- package/dist/entries/i18n.cjs +11 -11
- package/dist/entries/i18n.d.cts +2 -2
- package/dist/entries/i18n.d.ts +2 -2
- package/dist/entries/i18n.js +1 -1
- package/dist/entries/llm-models.cjs +63 -43
- package/dist/entries/llm-models.d.cts +71 -4
- package/dist/entries/llm-models.d.ts +71 -4
- package/dist/entries/llm-models.js +1 -1
- package/dist/entries/media.cjs +45 -41
- package/dist/entries/media.d.cts +39 -1
- package/dist/entries/media.d.ts +39 -1
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +66 -66
- package/dist/entries/model-catalog.d.cts +2 -2
- package/dist/entries/model-catalog.d.ts +2 -2
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +274 -210
- package/dist/entries/models.d.cts +3 -3
- package/dist/entries/models.d.ts +3 -3
- package/dist/entries/models.js +5 -5
- package/dist/entries/nodes.cjs +222 -201
- package/dist/entries/nodes.d.cts +48 -8
- package/dist/entries/nodes.d.ts +48 -8
- package/dist/entries/nodes.js +10 -9
- package/dist/entries/pipeline.cjs +149 -149
- package/dist/entries/pipeline.d.cts +8 -4
- package/dist/entries/pipeline.d.ts +8 -4
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/social.cjs +174 -174
- package/dist/entries/social.d.cts +13 -5
- package/dist/entries/social.d.ts +13 -5
- package/dist/entries/social.js +2 -2
- package/dist/entries/types.d.cts +1 -1
- package/dist/entries/types.d.ts +1 -1
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +115 -115
- package/dist/entries/video.d.cts +4 -3
- package/dist/entries/video.d.ts +4 -3
- package/dist/entries/video.js +4 -4
- package/dist/entries/workflow.cjs +96 -95
- package/dist/entries/workflow.d.cts +7 -18
- package/dist/entries/workflow.d.ts +7 -18
- package/dist/entries/workflow.js +2 -1
- package/dist/index.cjs +1708 -1567
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +26 -25
- package/dist/{model-catalog-V-ZNzRSd.d.ts → model-catalog-I48SvalA.d.cts} +25 -0
- package/dist/{model-catalog-V-ZNzRSd.d.cts → model-catalog-I48SvalA.d.ts} +25 -0
- package/dist/{presentation-utils-D0kxsWf9.d.cts → presentation-utils-A4i92SYo.d.cts} +1 -1
- package/dist/{presentation-utils-pZwlEAzo.d.ts → presentation-utils-DjdPtM9k.d.ts} +1 -1
- package/dist/{scene-node-types-C3kl_zyK.d.ts → scene-node-types-Cvbtf-0a.d.cts} +147 -6
- package/dist/{scene-node-types-C3kl_zyK.d.cts → scene-node-types-Cvbtf-0a.d.ts} +147 -6
- package/dist/{types-DffyGSy5.d.cts → types-CU6SQnMS.d.cts} +0 -5
- package/dist/{types-DffyGSy5.d.ts → types-CU6SQnMS.d.ts} +0 -5
- package/dist/{types-BRlFPEru.d.ts → types-DzUBR7yr.d.cts} +8 -1
- package/dist/{types-BRlFPEru.d.cts → types-DzUBR7yr.d.ts} +8 -1
- package/package.json +1 -1
- package/src/__tests__/camera-switch-contract.test.ts +33 -1
- package/src/__tests__/character-mention-slug.test.ts +0 -8
- package/src/__tests__/effective-tier.test.ts +3 -14
- package/src/__tests__/fixtures/camera-switch-speaker-map-parity.json +178 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +21 -0
- package/src/__tests__/fixtures/speaker-map-camera-ids.json +26 -0
- package/src/__tests__/gvp-supported-providers.test.ts +1 -0
- package/src/__tests__/i18n-locale-completeness.test.ts +38 -3
- package/src/__tests__/llm-models.test.ts +200 -20
- package/src/__tests__/node-preset-extract.test.ts +10 -0
- package/src/__tests__/preview-gate-use-case.test.ts +16 -1
- package/src/__tests__/producer-types.test.ts +19 -0
- package/src/__tests__/run-continuation.test.ts +4 -1
- package/src/__tests__/speaker-map-contract.test.ts +48 -0
- package/src/__tests__/unit-contract-compose.test.ts +129 -0
- package/src/__tests__/unit-contracts.test.ts +134 -0
- package/src/__tests__/use-case-types.test.ts +33 -0
- package/src/__tests__/video-catalog-totality.test.ts +15 -1
- package/src/__tests__/video-collapse-parity.test.ts +10 -0
- package/src/__tests__/video-frame-slot.test.ts +85 -0
- package/src/__tests__/video-mode-aliases.test.ts +1 -0
- package/src/__tests__/video-reference-only.test.ts +117 -0
- package/src/__tests__/vidu-q4-catalog.test.ts +230 -0
- package/src/camera-switch-contract.ts +36 -2
- package/src/credit-identifiers.ts +19 -6
- package/src/entity-asset-types.ts +13 -0
- package/src/entries/edl.ts +2 -0
- package/src/entries/llm-models.ts +5 -0
- package/src/entries/media.ts +1 -0
- package/src/entries/models.ts +25 -0
- package/src/entries/nodes.ts +5 -1
- package/src/fan-out-rows.ts +36 -3
- package/src/generate-mask.ts +40 -0
- package/src/generated/unit-contracts.ts +58 -0
- package/src/i18n/types.ts +13 -2
- package/src/json-kinds.ts +24 -4
- package/src/llm-models.ts +184 -31
- package/src/meta-ads-scrape.ts +16 -8
- package/src/model-catalog.ts +91 -13
- package/src/model-constants.ts +260 -5
- package/src/node-default-mappings.ts +3 -0
- package/src/node-preset-extract.ts +8 -0
- package/src/pipeline-types.ts +3 -0
- package/src/presentation-utils.ts +12 -12
- package/src/preview-gate.ts +4 -2
- package/src/producer-types.ts +19 -19
- package/src/run-continuation.ts +26 -4
- package/src/speaker-layouts.ts +8 -3
- package/src/speaker-map-contract.ts +77 -0
- package/src/unit-contract-compose.ts +55 -0
- package/src/use-case-types.ts +19 -0
- package/src/video-ui-defaults.ts +7 -5
- package/dist/chunk-23FJQTEA.js.map +0 -1
- package/dist/chunk-5PC6JBGJ.cjs.map +0 -1
- package/dist/chunk-5RYLK3MQ.js.map +0 -1
- package/dist/chunk-7Z5LUTGU.js.map +0 -1
- package/dist/chunk-BG5D5CZ6.js.map +0 -1
- package/dist/chunk-CK3GK34R.js.map +0 -1
- package/dist/chunk-D26ENTN2.cjs.map +0 -1
- package/dist/chunk-D6GNRSCV.cjs.map +0 -1
- package/dist/chunk-HC7VKIV5.cjs.map +0 -1
- package/dist/chunk-HGC5JNVA.cjs.map +0 -1
- package/dist/chunk-JL4C5VJ7.cjs.map +0 -1
- package/dist/chunk-K3LLGRK7.cjs.map +0 -1
- package/dist/chunk-M36G6SRP.js.map +0 -1
- package/dist/chunk-M7GQBRZU.cjs.map +0 -1
- package/dist/chunk-PHZ23DP3.js.map +0 -1
- package/dist/chunk-PQHS255G.js.map +0 -1
- package/dist/chunk-PRYE7AZQ.cjs.map +0 -1
- package/dist/chunk-PVJBAPYJ.js.map +0 -1
- package/dist/chunk-PXFQVLBX.js.map +0 -1
- package/dist/chunk-QA3MVQ32.js.map +0 -1
- package/dist/chunk-SES6GDBQ.cjs.map +0 -1
- package/dist/chunk-TU33KYKW.cjs +0 -25
- package/dist/chunk-TU33KYKW.cjs.map +0 -1
- package/dist/chunk-VA42637J.cjs.map +0 -1
- package/dist/chunk-VXPLKQWY.cjs.map +0 -1
- package/dist/chunk-WDIBOWAA.js.map +0 -1
- package/dist/chunk-YBPBK5KI.js.map +0 -1
- package/dist/chunk-YYV35XOS.js.map +0 -1
- package/dist/chunk-Z2OL5AJD.cjs.map +0 -1
- package/dist/chunk-ZDFHA2EC.js.map +0 -1
- package/dist/chunk-ZO5PBBFX.js.map +0 -1
- package/dist/chunk-ZRL2UFTH.cjs.map +0 -1
- package/src/__tests__/__snapshots__/prompt-builder-segments.test.ts.snap +0 -65
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/producer-types.ts","../src/exposed-field-keys.ts","../src/render-nodes.ts","../src/presentation-utils.ts"],"names":["url","text"],"mappings":";;;;;AAsBO,IAAM,oBAAA,uBAAgD,GAAA,CAAI;AAAA,EAC/D,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAA;AAAA;AAAA;AAAA,EAGA,cAAA;AAAA,EACA,cAAA;AAAA;AAAA;AAAA;AAAA,EAIA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,qBAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA;AAAA,EAEA,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA;AAAA,EAEA,cAAA;AAAA;AAAA,EAEA,WAAA;AAAA;AAAA,EAEA,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AO,KAAK,IAAI,CAAA;AAAA,IAClB;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AAGO,SAAS,cAAc,IAAA,EAAgC;AAC5D,EAAA,OAAO,IAAA,CAAK,IAAA,KAAS,MAAA,GAAS,IAAA,CAAK,SAAS,IAAA,CAAK,EAAA;AACnD;AAGO,SAAS,kBAAA,CACd,OACA,OAAA,EACoB;AACpB,EAAA,OAAO,KAAA,CACJ,MAAA,CAAO,CAAC,IAAA,KAAS;AAChB,IAAA,IAAI,IAAA,CAAK,IAAA,KAAS,MAAA,IAAU,IAAA,CAAK,IAAA,KAAS,OAAA,IAAW,IAAA,CAAK,IAAA,KAAS,QAAA,EAAU,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAK,MAAM,CAAA;AAC3G,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,CAAA,CACA,GAAA,CAAI,CAAC,IAAA,KAAS;AACb,IAAA,IAAI,IAAA,CAAK,SAAS,OAAA,EAAS;AACzB,MAAA,OAAO,EAAE,GAAG,IAAA,EAAM,KAAA,EAAO,mBAAmB,IAAA,CAAK,KAAA,EAAO,OAAO,CAAA,EAAE;AAAA,IACnE;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,CAAA;AACL","file":"chunk-PXFQVLBX.js","sourcesContent":["/**\n * Producer-type sets — single source of truth for the node types whose\n * primary output is a video URL, audio URL, etc.\n *\n * Consumed by:\n * - backend/src/services/workflow-engine/execution-graph.ts (orchestrator\n * dispatch + asset-type tagging in payload-builder, output-extractor,\n * inline-executor — re-exported there as VIDEO_SOURCE_TYPES /\n * AUDIO_SOURCE_TYPES for backwards compatibility).\n * - frontend/src/lib/generate-video-handles.ts (handle connection\n * validation on the Generate Video node).\n *\n * Lifting these here ensures the frontend handle validator can never reject\n * a connection from a node type that the backend would happily route at\n * execution time (the prior drift bug, see issue 1 of the Task 4.1 review).\n */\nimport { UGC_PRIMARY_HANDLE } from \"./ugc-node-wires.js\"\n\n/**\n * Source node types whose primary output is a video URL.\n * Mirrors the backend execution-graph VIDEO_SOURCE_TYPES verbatim.\n */\nexport const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = new Set([\n \"image-to-video\",\n \"video-to-video\",\n \"switchx\", // Beeble SwitchX relight/composite\n \"text-to-video\",\n // Unified video node — emits videoUrl identically to i2v/t2v (its payload-builder\n // case dispatches dynamically to \"image-to-video\" or \"text-to-video\" jobName based\n // on whether a start frame is wired). Without this, getPrimaryOutput would fall\n // through to the imageUrl/videoUrl/audioUrl/text default and downstream consumers\n // could silently misroute the output.\n \"generate-video\",\n // Generate Video Pro — Seedance-2-family multi-segment stitch variant of\n // generate-video (same \"emits videoUrl\" contract; a trimmed provider +\n // handle set). Must mirror generate-video here or its output can't connect\n // downstream (the recurring \"cannot connect the outputs\" bug class).\n \"generate-video-pro\",\n // Edit Video Pro — Seedance-2-family span-replace sibling of generate-\n // video-pro (same \"emits videoUrl\" contract; source video + prompt in,\n // ONE video out). Must mirror generate-video-pro here or its output can't\n // connect downstream (the recurring \"cannot connect the outputs\" bug class).\n \"edit-video-pro\",\n \"upload-video\",\n \"youtube-video\",\n \"combine-videos\",\n \"lip-sync\",\n \"speech-to-video\",\n \"motion-transfer\",\n \"video-upscale\",\n \"video-depth\",\n \"extend-video\",\n // face-swap output is video (writes generatedVideoUrl, per-result `url`).\n // Frontend execution-graph already includes it in VIDEO_SOURCE_TYPES; this\n // entry brings the shared set in line so canvas typed-handle validation\n // doesn't reject face-swap → video-consumer edges that the orchestrator\n // would happily route at runtime.\n \"face-swap\",\n // Speaker View (C3.2): an EDL rendered with its speakers framed — one VIDEO\n // out (no audio-only render). Registered in RENDER_NODE_TYPES as well.\n \"speaker-view\",\n \"video-retake\",\n // video-sfx: adds an SFX track to a video → emits a video URL. Belongs here so\n // canvas handle validation accepts video-sfx → video-consumer edges and the\n // backend routes its output as video (it was previously relying on a fallback).\n \"video-sfx\",\n \"suno-music-video\",\n \"merge-video-audio\",\n \"add-captions\",\n \"resize-video\",\n \"social-media-format\",\n \"trim-video\",\n \"render-video\",\n \"speed-ramp\",\n \"loop-video\",\n \"fade-video\",\n // Video Mask emits its mask as a video; Mask Composite its composite.\n \"video-mask\",\n \"mask-composite\",\n \"transcode-video\",\n \"manual-edit\",\n // Remove Audio: strips the audio track, emits a silent video.\n \"remove-audio\",\n // AI Avatar (HeyGen): avatar + voice/audio → video.\n \"ai-avatar\",\n // Cinematic Avatar (HeyGen cinematic_avatar): prompt + 1–3 avatar looks → video.\n \"cinematic-avatar\",\n // Assemble Narrated Video: fits N (clip, voice) blocks into one MP4 → video.\n \"assemble-narrated-video\",\n // Still to Video: one still image + one audio track → MP4 (local FFmpeg,\n // no provider). Emits generatedVideoUrl like every other ffmpeg video node.\n \"still-to-video\",\n // Slideshow: 2-100 stills + one optional audio track → MP4 (local FFmpeg,\n // no provider). Same contract; images arrive via the image-collage lane.\n \"slideshow\",\n // GIF to Video: animated GIF → H.264 MP4 (local FFmpeg, no provider).\n // Emits generatedVideoUrl so it connects to any downstream video consumer\n // (e.g. a Seedance video-reference input) by an ordinary edge.\n \"gif-to-video\",\n // 3D Render Pro: authors a scene AND exports it in one operation, settling\n // with the standard `videoUrl` field. It is a video producer as much as it\n // is a composition producer — omitting it here is the \"cannot connect the\n // outputs\" bug, and its `composition` handle is typed separately.\n \"pro-3d-render\",\n // Video Overlay: timed image layers over a video in one local FFmpeg pass\n // (the base audio copied) — emits a video URL on `video-out`.\n \"video-overlay\",\n // UGC Clip: renders one clip of a UGC video from its ticket — emits a video\n // URL on `video-out` (one per fan-out iteration).\n \"ugc-clip\",\n // UGC Finish: the video's clips, finished, as one ordered list — a registered producer, so a\n // Bundle edge into Combine Videos routes each one as a video, in order.\n \"ugc-finish-clips\",\n])\n\n/**\n * Source node types whose output media-type cannot be classified\n * statically — iterators, dynamic dispatchers, sub-workflow wrappers.\n * The orchestrator decides their actual output type at execution time\n * based on what's wired upstream (loop iterates upstream column type;\n * sub-workflow emits its leaf node's type; adjust-volume passes through\n * video or audio based on its `lastInputType` runtime field;\n * voice-changer emits audio in audio mode, video+audio in video mode).\n *\n * Typed-handle validators (frontend/src/lib/{generate-image,generate-\n * video,ffmpeg}-handles.ts) must include these as acceptors on EVERY\n * media-typed input handle — otherwise the canvas validator hard-\n * rejects edges that the orchestrator would happily route at runtime.\n *\n * Lifted here from `frontend/src/lib/ffmpeg-handles.ts` (where the\n * escape hatch was first added) so the same set drives ALL handle\n * validators uniformly. Adding a new dynamic-output node type means\n * one edit here instead of N across sibling validator files.\n *\n * Intentionally OMITTED:\n * - `webhook-trigger` / `schedule-trigger` — their outputs are\n * user-defined JSON shapes, not media URLs. Accepting them as\n * media producers creates false-positive drops at the canvas\n * that fail at execution. Users wanting trigger → media flows\n * should wire through an upload node.\n */\nexport const DYNAMIC_PRODUCER_TYPES: ReadonlySet<string> = new Set([\n \"list\",\n \"sub-workflow\",\n \"adjust-volume\",\n // Pitch & Tempo: audio in → audio out, video in → video out (picture\n // copied). Dual-mode like adjust-volume; stays in AUDIO_PRODUCER_TYPES as\n // its default.\n \"pitch-tempo\",\n // Dual-mode: audio in → audio out; video in → video out (+ revoiced audio).\n // Listed here so canvas validators accept its output on BOTH audio and video\n // input handles (it also stays in AUDIO_PRODUCER_TYPES as its default).\n \"voice-changer\",\n // voice-changer-pro (renamed from voice-recast in #3581) is a behavioral\n // twin of voice-changer — identical dual-mode output. Must mirror it in\n // EVERY producer set or its outputs can't connect (was the \"cannot connect\n // the outputs of voice-changer-pro\" bug). Guarded by producer-types.test.ts.\n \"voice-changer-pro\",\n // Dubbing joined the dual-mode family with the full-surface upgrade:\n // audio in → dubbed audio; video in (or a video sourceUrl) → dubbed VIDEO\n // (+ audio sidecar). Same wiring contract as voice-changer; stays in\n // AUDIO_PRODUCER_TYPES as its default. Explicitly asserted in\n // producer-types.test.ts (the suite does not fail on omission).\n \"dubbing\",\n \"reduce\",\n // Dual-output time chunker (UI label \"Split into Chunks\"; type id stays\n // \"split-media\"): video in → video chunks, audio in → audio chunks — two\n // independent lanes on two output handles. Like voice-changer, the canvas\n // validator only sees the source NODE type, not which handle a wire leaves,\n // so it lives here to be accepted on BOTH audio and video input handles. The\n // backend routes the correct lane by sourceHandle in getPrimaryOutput\n // (output-extractor.ts); the frontend does so in extractNodeOutput.\n \"split-media\",\n // apply-edl renders an EDL into ONE media output whose type is decided at\n // run time by the node's `output` setting (video OR audio) — so its static\n // medium is genuinely unknown and it belongs here, letting canvas validators\n // accept its default media handle on BOTH audio and video input handles. It\n // ALSO emits a fixed `json` handle (the remapped Transcript); that half lives\n // in JSON_PRODUCER_TYPES (frontend/src/lib/data-handles.ts). The FIRST node\n // with both a dynamic media handle and a fixed json handle. Because\n // getOutputType (presentation-utils.ts) deliberately returns \"data\" for\n // DYNAMIC members, apply-edl is ALSO added to the literal VIDEO_OUTPUT_TYPES\n // there so a published app renders the cut as video, mirroring the\n // voice-changer/dubbing precedent. Asserted in producer-types.test.ts (the\n // suite does not fail on omission).\n \"apply-edl\",\n // Tighten Episode (podcast use-case node): the episode is video OR audio by\n // its `output` setting (an audio recording forces audio) — runtime-decided.\n \"tighten-episode\",\n])\n\n/**\n * Source node types whose primary output is an audio URL.\n * Mirrors the backend execution-graph AUDIO_SOURCE_TYPES verbatim.\n */\nexport const AUDIO_PRODUCER_TYPES: ReadonlySet<string> = new Set([\n \"text-to-speech\",\n \"text-to-audio\",\n \"generate-music\",\n \"upload-audio\",\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-separate\",\n \"audio-separation\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n \"trim-audio\",\n \"mix-audio\",\n \"combine-audio\",\n \"adjust-volume\",\n \"audio-fx\",\n \"pitch-tempo\",\n \"reference-audio\",\n \"audio-isolation\",\n \"text-to-dialogue\",\n \"voice-changer\",\n // Twin of voice-changer (see DYNAMIC_PRODUCER_TYPES note). Audio is its\n // default output mode; video mode is handled via DYNAMIC membership.\n \"voice-changer-pro\",\n \"dubbing\",\n \"voice-remix\",\n \"voice-design\",\n // Extract Audio: demuxes a video's audio track to a standalone MP3.\n \"extract-audio\",\n])\n\n/**\n * Source node types whose output is an IMAGE URL — what feeds a References\n * input. ONE set for the canvas validators (`frontend/src/lib/\n * generate-image-handles.ts` re-exports it), the backend's Generate Image\n * handle migration and the MCP edge normalizer (`llm-chat`'s legacy `in`):\n * they used to keep separate copies, and the backend's lagged by eight types.\n */\nexport const IMAGE_PRODUCER_TYPES: ReadonlySet<string> = new Set([\n \"upload-image\", \"generate-image\", \"edit-image\", \"image-to-image\", \"modify-image\", \"upscale-image\", \"remove-background\",\n // extract-frame produces a single still image extracted from a video source.\n \"extract-frame\",\n // generate-mask emits the source image AND a mask PNG; its `image` source\n // pip is the passthrough (the same image as the input).\n \"generate-mask\",\n // paint-mask emits the hand-painted mask PNG (a plain image at runtime).\n // Membership is what makes mask targets accept it — mask is an advisory\n // color, not a gated type.\n \"paint-mask\",\n // reference-sheet's `sheet` is one composited image and `panels` carries\n // clean reference images; both resolve to image URLs at runtime.\n \"reference-sheet\",\n // reference-board's `image` pip emits a real generated board image.\n \"reference-board\",\n // image-collage composites N images → ONE image.\n \"image-collage\",\n // image-overlay places layers on a base → ONE image.\n \"image-overlay\",\n // 3D Render Pro's `stills` handle carries one PNG per shot of the exported\n // composition (spread into referenceImageUrls like reference-sheet\n // `panels`). A validator sees only the source NODE type, so this also makes\n // its `video` pip droppable on an image input — the handle-blind trade\n // reference-sheet and split-media already make; the input resolvers route\n // by handle, so only `stills` becomes an image at runtime. Deliberately NOT\n // in IMAGE_SOURCE_TYPES on either engine: that set types the node's PRIMARY\n // asset, and 3D Render Pro's is the MP4.\n \"pro-3d-render\",\n])\n\n/**\n * Source node types whose primary output is a LIST that, by default, fans out\n * one downstream execution per element when an edge leaves them WITHOUT an\n * explicit `outputMode` (all other edges default to \"last\"). `selector` is\n * included because its picked/rest channels are lists too.\n *\n * Single source of truth for the fan-out \"each\" default, consumed by:\n * - backend/src/services/workflow-engine/input-resolver.ts (DEFAULT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/types.ts (FAN_OUT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/node-input-resolver.ts\n *\n * These three previously kept independent copies; the backend copy drifted\n * (missing the four list-transform types), so server-side workflow runs\n * silently dropped all-but-the-first item for filter-list / deduplicate /\n * merge-lists / sort-list sources while the canvas fanned out N ways. Lifting\n * the set here makes that drift impossible.\n */\nexport const FAN_OUT_EACH_TYPES: ReadonlySet<string> = new Set([\n \"list\",\n \"split-text\",\n \"filter-list\",\n \"deduplicate\",\n \"merge-lists\",\n \"sort-list\",\n \"selector\",\n // edit-plan `clips` mode emits a bare `Edl[]` on `data.generatedJson`, so an\n // edge leaving it defaults to \"each\" — one downstream execution (typically an\n // apply-edl render) per clip. The `tighten`/`chapters` modes emit an OBJECT,\n // for which the list extractors return undefined, so an \"each\" edge falls back\n // to the scalar `edl` value (no fan-out) — the same graceful degradation\n // web-scrape relies on. See `unwrapEditPlanOutput` in `edit-plan-contract.ts`.\n \"edit-plan\",\n // Content Ideas emits one creative brief per idea on `listResults`, so an\n // edge leaving it defaults to \"each\" — the node after it (typically\n // Generate Script) runs once per idea, on the server too.\n \"content-ideas\",\n])\n\n/**\n * Per-HANDLE \"each\" defaults, for a node whose outputs differ in kind: on the\n * `each` handles an edge without an explicit `outputMode` defaults to \"each\",\n * on its other handles to \"last\". `primary` is the handle an edge with no\n * `sourceHandle` reads (agent-written workflow JSON often omits it).\n *\n * The list an \"each\" edge reads is the node's per-iteration results\n * (`listResults`) — it exists only when the node itself ran once per item, so\n * after a single run the edge degrades to the single value, exactly like a\n * `FAN_OUT_EACH_TYPES` member with one item.\n */\nexport const FAN_OUT_EACH_HANDLES: Readonly<Record<string, { readonly each: readonly string[]; readonly primary: string }>> = {\n // Camera Switch run once per clip (Edit Plan in clips mode): each clip's\n // switched EDL is its own Apply EDL render. Its transcript is the same for\n // every clip (the master clock, renamed), so that handle stays one value\n // (decided 2026-10-04).\n \"camera-switch\": { each: [\"edl\"], primary: \"edl\" },\n // UGC Clips: one ticket per clip on `clips` (each); `plan-out` and\n // `transcript` carry one value. Not a FAN_OUT_EACH_TYPES member — every\n // handle of such a member would fan out. Its one run writes the tickets as\n // its list (`listResults`, the editor's `__listResults`). The pip an edge\n // with no handle reads is the UGC wires' own (UGC_PRIMARY_HANDLE).\n \"ugc-clips\": { each: [\"clips\"], primary: UGC_PRIMARY_HANDLE[\"ugc-clips\"]! },\n}\n\n/**\n * Fan-out nodes whose iterations must ALL succeed: one failed item fails the\n * node (today's rule tolerates a partial list). UGC Clip — a missing clip\n * silently drops a beat from the script (spec R17). Already-started items\n * finish and settle; their jobs are reused on the next run.\n */\nexport const FAN_OUT_ALL_OR_NOTHING_TYPES: ReadonlySet<string> = new Set([\"ugc-clip\"])\n\n/**\n * Nodes whose saved list is the list their last run PRODUCED — `__listResults`\n * (Extract Field's JSON value on `generatedJson`) — and never a history in\n * `generatedResults`: Extract Field, JSON Process and Site Capture. No run of the first two writes\n * one; earlier builds' server runs did (the run's text, the links of a list of\n * links), and both engines' list readers leave it out for these two (decided\n * 2026-10-05). Single source of truth for the backend engine and the editor.\n */\nexport const OWN_LIST_NODE_TYPES: ReadonlySet<string> = new Set([\n \"extract-field\",\n \"json-process\",\n // Site Capture: its stills, in page order — the last capture's, never every capture's (site-capture-node.ts).\n \"site-capture\",\n])\n\n/** Whether a node's saved list is its own `__listResults`, never a history. */\nexport function ownsItsList(nodeType: string | null | undefined): boolean {\n return typeof nodeType === \"string\" && OWN_LIST_NODE_TYPES.has(nodeType)\n}\n\n/** The `outputMode` an edge has when none is set on it — the ONE rule both\n * engines, the credit estimate and the editor read. */\nexport function defaultEdgeOutputMode(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): \"each\" | \"last\" {\n if (typeof sourceType !== \"string\") return \"last\"\n if (FAN_OUT_EACH_TYPES.has(sourceType)) return \"each\"\n const entry = FAN_OUT_EACH_HANDLES[sourceType]\n if (!entry) return \"last\"\n return entry.each.includes(sourceHandle || entry.primary) ? \"each\" : \"last\"\n}\n\n/** Whether an edge from `sourceHandle` reads the node's per-iteration results\n * (`listResults` — each iteration's PRIMARY output). False on the other\n * handles of a `FAN_OUT_EACH_HANDLES` node: Camera Switch's transcript is one\n * value, never the list of switched EDLs, whatever mode its edge is set to. */\nexport function listResultsServeHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n const entry = typeof sourceType === \"string\" ? FAN_OUT_EACH_HANDLES[sourceType] : undefined\n return !entry || entry.each.includes(sourceHandle || entry.primary)\n}\n\n/**\n * FAN-IN targets: nodes that FOLD everything wired into them into ONE run,\n * instead of running once per upstream item. Keyed by node type; the value\n * names the target handles that fold (`\"*\"` = every handle). An edge into any\n * other handle of such a node is routed normally — Content Ideas folds its\n * recipes but reads its brand from a `field-brand` wire like any field.\n *\n * Single source of truth for both engines' input resolvers (the backend and\n * the editor each used to keep a private `new Set([\"reduce\"])`). A fan-in\n * node is never itself fanned out by an upstream list.\n */\nexport const FAN_IN_TARGETS: Readonly<Record<string, \"*\" | readonly string[]>> = {\n // Choose Best — every wire is a candidate.\n reduce: \"*\",\n // Content Ideas — one or more recipes, from several Content Recipe nodes\n // and/or one that ran once per post.\n \"content-ideas\": [\"recipes\"],\n // Telegram Reply — one message per run, whatever is wired into its text\n // input: a list (or a writer that ran once per item) arrives as one\n // message, never as a burst of sends to the owner's chat.\n \"telegram-account-send\": [\"in\"],\n // The list operators — they READ the whole list wired into them (their\n // executors collect every upstream item themselves) and emit a list. Run\n // once per item by an \"each\" wire (a Split Text, a List, a node that ran per\n // item), every iteration saw the same whole list and answered with its\n // first match: a Filter List fed 11 stories handed 11 copies of story one\n // downstream, and every paid stage after it ran 11 times on it\n // (2026-10-06). A list operator is never fanned out, on any wire.\n \"filter-list\": \"*\",\n deduplicate: \"*\",\n \"merge-lists\": \"*\",\n \"sort-list\": \"*\",\n selector: \"*\",\n // Speaker Frames on a clip pack (P3-24 (a), decided 2026-10-06): ONE run over\n // the union of the clips' spans — the pack's EDLs fold onto its `edl` wire\n // instead of running one detection job (and one minimum charge) per clip.\n \"speaker-frames\": [\"edl\"],\n // UGC Finish: ONE run over every clip of the video, in clip order — the finish plans its\n // cut and its sound over all of them at once, so it is never run once per clip.\n \"ugc-finish-clips\": [\"clips\"],\n}\n\nexport function isFanInNodeType(nodeType: string | undefined | null): boolean {\n return typeof nodeType === \"string\" && Object.prototype.hasOwnProperty.call(FAN_IN_TARGETS, nodeType)\n}\n\n/** True when an edge into `targetHandle` of a `targetType` node is folded.\n * An edge with NO target handle (workflow JSON written by an agent often\n * omits it) lands on the node's primary input, which is the folding one. */\nexport function isFanInEdge(targetType: string | undefined | null, targetHandle: string | null | undefined): boolean {\n if (!isFanInNodeType(targetType)) return false\n const spec = FAN_IN_TARGETS[targetType as string]!\n if (spec === \"*\") return true\n return targetHandle == null || targetHandle === \"\" || spec.includes(targetHandle)\n}\n","/**\n * Exposed-field keys that were renamed to the node's real data field.\n *\n * A published app stores which fields it exposes as `{ type: \"field\", nodeId, field }` items in its\n * immutable snapshot settings, and external callers send `inputOverrides[nodeId][field]` with that same\n * string — it is part of the public wire contract (docs/embed-app-guide.md). Renaming a descriptor's key\n * must not strand the apps already published with the old spelling: they keep that string forever, so every\n * place that turns a stored key into a node-data key — or compares it with a descriptor key — goes through\n * `canonicalExposedFieldKey`.\n *\n * CLOSED LIST. A row needs a spelling that was published (a card that existed in apps) and a target the\n * node's descriptor now declares (the frontend guard `exposable-field-keys.test.ts` checks both). Only list a\n * field whose card cannot carry `allowedValues` (slider / toggle / text / color): the server validates\n * `allowedValues` against the stored key (backend routes/app-runner.ts `validateRestrictedFields`). Never list\n * a field of an outbound node type: the run-request override lock (backend lib/input-override-lock.ts) reads\n * the stored key, before this table renames it.\n */\nexport const LEGACY_EXPOSED_FIELD_KEYS: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n // Published as the Text to Speech slider's key. The node's data field, and every runner, route and config\n // panel, has always been `similarityBoost` — so the slider moved nothing.\n \"text-to-speech\": { similarity: \"similarityBoost\" },\n}\n\n/** The node-data key an exposed field's stored key stands for. Unknown node types and keys pass through. */\nexport function canonicalExposedFieldKey(nodeType: string | undefined, key: string): string {\n if (typeof nodeType !== \"string\" || !Object.hasOwn(LEGACY_EXPOSED_FIELD_KEYS, nodeType)) return key\n const renames = LEGACY_EXPOSED_FIELD_KEYS[nodeType]!\n return Object.hasOwn(renames, key) ? renames[key]! : key\n}\n\n/**\n * The override map with every legacy spelling replaced by its current key. When the caller sent both\n * spellings the current one wins (it is their current intent) and the legacy key is dropped — a dead key\n * is never written to node data. Returns the same object when nothing renames; never mutates.\n */\nexport function canonicalizeOverrideKeys(\n nodeType: string | undefined,\n overrides: Record<string, unknown>,\n): Record<string, unknown> {\n let out: Record<string, unknown> | undefined\n for (const key of Object.keys(overrides)) {\n const current = canonicalExposedFieldKey(nodeType, key)\n if (current === key) continue\n out ??= { ...overrides }\n delete out[key]\n if (!Object.hasOwn(overrides, current)) out[current] = overrides[key]\n }\n return out ?? overrides\n}\n","/**\n * The render-node registry (SV18, decided 2026-10-06): every node type that\n * turns an EDL into a finished file, and how each one behaves wherever the\n * platform gives a render its meaning — review and the Preview label, privacy,\n * the latest-batch reader, the owner-only listings, and what its `json` handle\n * carries.\n *\n * ONE registry, read by both engines, the editor, the listings and MCP, so a\n * second render (Speaker View) joins by adding one entry — never by finding\n * every `=== \"apply-edl\"`. The backend census test\n * (`render-node-census.test.ts`) fails a new `apply-edl` literal at any site\n * that is not pure registration of that node.\n *\n * The key is the node type AND the job name: a render's job is never renamed\n * (by quality or otherwise — only its credit id changes), so the same key\n * answers for `node.type` and for `jobs.job_type`.\n */\nimport { applyEdlCreditId, speakerViewCreditId, SPEAKER_VIEW_CREDIT_IDS } from \"./credit-identifiers.js\"\nimport type { RenderMedium } from \"./render-output.js\"\n\n/** Where a render's player maps the output clock back to the master clock\n * from: the EDL it was given (`input_data.edl`), or the EDL it emitted on its\n * `json` output (a render that rewrites its EDL, e.g. by splitting turns). */\nexport type RenderClockSource = \"input\" | \"output-json\"\n\n/** What a render's `json` output handle carries. Only a `transcript` is handed\n * on as one (Add Captions, the word-timing preflight). */\nexport type RenderJsonKind = \"transcript\" | \"edl\"\n\n/** Where a render's wired transcript, remapped through its cut, comes out\n * (Apply EDL's on its `json`; Speaker View's on its own `transcript` pip,\n * decided 2026-10-08). */\nexport interface RenderTranscriptOutput {\n /** The output pip — also the key it rides on the job's `output_data` and on\n * a run's node output. */\n readonly handle: string\n /** The saved node-data field that holds it (the landed take's). */\n readonly dataField: string\n}\n\n/** The pip a render's `json` output (its `jsonKind`) comes out on, and its key\n * on the job's `output_data`. */\nexport const RENDER_JSON_HANDLE = \"json\"\n\nexport interface RenderNodeDescriptor {\n /** The medium the render's order asks for (its node data, or its job's\n * `input_data`) — before any output exists to say. */\n readonly mediumOf: (data: Readonly<Record<string, unknown>>) => RenderMedium\n /** The credit id a render reserves on — a per-OUTPUT-MINUTE row: every\n * render is charged its row × the minutes it renders. Chosen from the\n * render's `quality` and `output` (as its node data or its job's request\n * carries them) and, for a render priced in tiers, the `priceTier` the\n * render rule judged it to be in (Speaker View's, decided 2026-10-10). A\n * tiered render given no tier names its dearer row. */\n readonly creditId: (quality: unknown, output?: unknown, priceTier?: unknown) => string\n /** Every id `creditId` can name (each must have a price row). */\n readonly creditIds: readonly string[]\n readonly clockMapFrom: RenderClockSource\n /** Listed in its owner's own views only, never in a public one (decided\n * 2026-10-06): a Preview is private, and a public final would be exposure\n * nobody decided. */\n readonly ownerOnlyListing: boolean\n /** An `each` wire reads its LATEST batch only, never its accumulated history\n * (TA6, decided 2026-10-04). */\n readonly latestBatch: boolean\n readonly jsonKind: RenderJsonKind\n /** Where its remapped transcript comes out. On the `json` pip exactly when\n * `jsonKind` is `transcript` (a guard test holds the two together). */\n readonly transcriptOutput: RenderTranscriptOutput\n}\n\ntype Data = Readonly<Record<string, unknown>>\n\n/** Its `output` setting, video when absent. */\nconst outputSettingMedium = (data: Data): RenderMedium => (data.output === \"audio\" ? \"audio\" : \"video\")\n\nconst descriptor = (d: RenderNodeDescriptor): RenderNodeDescriptor =>\n Object.freeze({ ...d, creditIds: Object.freeze([...d.creditIds]), transcriptOutput: Object.freeze({ ...d.transcriptOutput }) })\n\nexport const RENDER_NODE_TYPES: Readonly<Record<string, RenderNodeDescriptor>> = Object.freeze({\n \"apply-edl\": descriptor({\n mediumOf: outputSettingMedium,\n creditId: (quality) => applyEdlCreditId(quality),\n creditIds: [\"apply-edl\", \"apply-edl:proxy\"],\n clockMapFrom: \"input\",\n ownerOnlyListing: true,\n latestBatch: true,\n jsonKind: \"transcript\",\n transcriptOutput: { handle: RENDER_JSON_HANDLE, dataField: \"generatedJson\" },\n }),\n // Speaker View (C3.2): video only; its `json` is the EDL as it drew it (the\n // turns split, the layouts written), so a player maps the output clock\n // through THAT, and Add Captions never takes it for a Transcript. The wired\n // transcript, remapped through that same drawn edit, comes out on its own\n // `transcript` pip (decided 2026-10-08) — what a caption step reads.\n \"speaker-view\": descriptor({\n mediumOf: () => \"video\",\n creditId: (quality, _output, priceTier) => speakerViewCreditId(quality, priceTier),\n creditIds: SPEAKER_VIEW_CREDIT_IDS,\n clockMapFrom: \"output-json\",\n ownerOnlyListing: true,\n latestBatch: true,\n jsonKind: \"edl\",\n transcriptOutput: { handle: \"transcript\", dataField: \"generatedTranscript\" },\n }),\n})\n\n/** Every render node type, in registry order. */\nexport const RENDER_NODE_TYPE_IDS: readonly string[] = Object.freeze(Object.keys(RENDER_NODE_TYPES))\n\n/** The descriptor of a render node type (or job name); `undefined` for any\n * other value. Own keys only, so `\"constructor\"` is not a render. */\nexport function renderNodeOf(type: unknown): RenderNodeDescriptor | undefined {\n return typeof type === \"string\" && Object.hasOwn(RENDER_NODE_TYPES, type) ? RENDER_NODE_TYPES[type] : undefined\n}\n\n/** Is this node type (or job name) a render? */\nexport function isRenderNodeType(type: unknown): type is string {\n return renderNodeOf(type) !== undefined\n}\n\n/** Does an `each` wire from this node read its latest batch only? */\nexport function rendersLatestBatch(type: unknown): boolean {\n return renderNodeOf(type)?.latestBatch === true\n}\n\n/** Is this node a render whose `json` output is a Transcript? */\nexport function rendersTranscriptJson(type: unknown): boolean {\n return renderNodeOf(type)?.jsonKind === \"transcript\"\n}\n\n/** Where a render's remapped transcript comes out; `undefined` for any other\n * node type. */\nexport function renderTranscriptOutputOf(type: unknown): RenderTranscriptOutput | undefined {\n return renderNodeOf(type)?.transcriptOutput\n}\n\n/** Is `handle` one of a render's data pips — its `json` or its transcript —\n * rather than its media? Every other pip of a render (the default included)\n * is the rendered media. `false` for any other node type. */\nexport function isRenderDataHandle(type: unknown, handle: unknown): boolean {\n const d = renderNodeOf(type)\n if (!d || typeof handle !== \"string\") return false\n return handle === RENDER_JSON_HANDLE || handle === d.transcriptOutput.handle\n}\n\n/** One json output a render lands on its node: its key on the job's\n * `output_data` (and on a run's node output) and its saved node-data field. */\nexport interface RenderSavedJsonOutput {\n readonly outputKey: string\n readonly dataField: string\n}\n\n/** The json outputs a render lands on its node, `json` first, each once — what\n * every lane that lands a take (or picks one) writes or restores. Empty for\n * any other node type. */\nexport function renderSavedJsonOutputs(type: unknown): readonly RenderSavedJsonOutput[] {\n const d = renderNodeOf(type)\n if (!d) return []\n const json: RenderSavedJsonOutput = { outputKey: RENDER_JSON_HANDLE, dataField: \"generatedJson\" }\n const t = d.transcriptOutput\n return t.handle === RENDER_JSON_HANDLE ? [json] : [json, { outputKey: t.handle, dataField: t.dataField }]\n}\n\n/** The render job types that list in their owner's own views only. */\nexport const OWNER_ONLY_LISTING_RENDER_TYPES: readonly string[] = Object.freeze(\n RENDER_NODE_TYPE_IDS.filter((t) => RENDER_NODE_TYPES[t]!.ownerOnlyListing),\n)\n","/**\n * Presentation / API utilities — pure logic, no React deps.\n * Shared between frontend (presentation mode) and backend (API schema generation).\n */\n\nimport type { GenericNode, GenericEdge } from \"./types.js\"\nimport type { PresentationItem } from \"./presentation-types.js\"\nimport { AUDIO_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from \"./producer-types.js\"\nimport { canonicalizeOverrideKeys } from \"./exposed-field-keys.js\"\nimport { RENDER_NODE_TYPE_IDS } from \"./render-nodes.js\"\nimport { dropStaleVideoLinkFields } from \"./video-link.js\"\n\n// ---------------------------------------------------------------------------\n// Node type sets\n// ---------------------------------------------------------------------------\n\nexport const INPUT_NODE_TYPES = new Set([\n \"text-prompt\",\n \"upload-image\",\n \"upload-video\",\n \"upload-audio\",\n \"tone\",\n \"style-guide\",\n \"provider\",\n \"scene-count\",\n \"duration\",\n \"aspect-ratio\",\n \"motion\",\n \"camera-motion\",\n \"framing\",\n \"lens\",\n \"camera-format\",\n \"lighting\",\n \"color-look\",\n \"atmosphere\",\n \"action-fx\",\n \"temporal\",\n \"reference-audio\",\n \"youtube-video\",\n])\n\nconst TRIGGER_NODE_TYPES = new Set([\n \"webhook-trigger\",\n \"schedule-trigger\",\n])\n\nconst ALWAYS_EXCLUDED_TYPES = new Set([\n \"sticky-note\",\n \"webhook-trigger\",\n \"schedule-trigger\",\n \"sub-workflow-input\",\n \"sub-workflow-output\",\n])\n\nconst NON_OUTPUT_TYPES = new Set([\n \"text-prompt\",\n \"list\",\n \"upload-image\",\n \"upload-video\",\n \"upload-audio\",\n \"reference-audio\",\n \"rss-feed\",\n \"youtube-video\",\n \"tone\",\n \"style-guide\",\n \"provider\",\n \"scene-count\",\n \"duration\",\n \"aspect-ratio\",\n \"motion\",\n \"camera-motion\",\n \"framing\",\n \"lens\",\n \"camera-format\",\n \"lighting\",\n \"color-look\",\n \"atmosphere\",\n \"action-fx\",\n \"temporal\",\n \"sticky-note\",\n \"sub-workflow-input\",\n \"sub-workflow-output\",\n \"webhook-trigger\",\n \"schedule-trigger\",\n \"combine-text\",\n \"split-text\",\n \"save-to-storage\",\n \"webhook-output\",\n \"component\",\n])\n\n/**\n * Node types that count as an output even when something is wired to their\n * output handle (the legacy `presentationVisible` rule below).\n *\n * A hand-kept list, and one the platform has outgrown: it is unioned at the use\n * site with the producer vocabularies the canvas validators already maintain\n * (see `isMediaProducingType`), so a new media node is covered by the set it\n * must join anyway rather than by remembering to edit this one.\n */\nconst MEDIA_PRODUCING_TYPES = new Set([\n \"generate-image\",\n \"edit-image\",\n \"image-to-image\",\n \"image-to-video\",\n \"text-to-video\",\n \"video-to-video\",\n \"text-to-speech\",\n \"generate-music\",\n \"text-to-audio\",\n \"generate-script\",\n \"ai-writer\",\n \"llm-chat\",\n \"render-video\",\n \"video-composer\",\n \"after-effects\",\n \"lottie-overlay\",\n \"3d-title\",\n \"motion-graphics\",\n \"composite\",\n \"text-to-dialogue\",\n \"voice-changer\",\n \"dubbing\",\n \"voice-remix\",\n \"voice-design\",\n \"extend-video\",\n \"lip-sync\",\n \"motion-transfer\",\n \"video-upscale\",\n \"video-depth\",\n])\n\n// Output type categorizations\nconst IMAGE_OUTPUT_TYPES = new Set([\n \"generate-image\", \"edit-image\", \"image-to-image\",\n \"upload-image\",\n])\n\n/**\n * Video-output types NOT already declared by `VIDEO_PRODUCER_TYPES` — the two\n * are unioned in `getOutputType`, which is where the reading order (and the\n * reason the literal sets win) is documented.\n */\nconst VIDEO_OUTPUT_TYPES = new Set([\n \"image-to-video\", \"text-to-video\", \"video-to-video\", \"extend-video\",\n \"render-video\", \"video-composer\", \"after-effects\", \"lottie-overlay\",\n \"3d-title\", \"motion-graphics\", \"composite\",\n \"combine-videos\", \"merge-video-audio\", \"resize-video\", \"trim-video\",\n \"speed-ramp\", \"loop-video\", \"fade-video\", \"transcode-video\",\n \"upload-video\",\n \"lip-sync\", \"motion-transfer\", \"video-upscale\", \"video-depth\", \"add-captions\",\n \"social-media-format\",\n // A render (Apply EDL) renders an EDL into video OR audio. Its medium is\n // decided at run time (DYNAMIC_PRODUCER_TYPES), so getOutputType would answer\n // \"data\" and a published app would render the cut as a JSON blob. Declaring\n // every render here — as the voice-changer/dubbing precedent does for their\n // default medium — makes the classifier answer \"video\" (the common case; an\n // audio-only cut still plays in a video element). Asserted in\n // producer-types.test.ts.\n ...RENDER_NODE_TYPE_IDS,\n // Tighten Episode: a published app shows the episode as media, never as data\n // (it is not a render, so RENDER_NODE_TYPE_IDS does not bring it).\n \"tighten-episode\",\n])\n\nconst AUDIO_OUTPUT_TYPES = new Set([\n \"text-to-speech\", \"generate-music\", \"text-to-audio\",\n \"text-to-dialogue\", \"voice-changer\", \"dubbing\", \"voice-remix\",\n \"voice-design\", \"mix-audio\", \"adjust-volume\", \"audio-fx\", \"pitch-tempo\", \"trim-audio\",\n \"audio-isolation\",\n \"audio-separation\",\n \"upload-audio\",\n])\n\nconst TEXT_OUTPUT_TYPES = new Set([\n \"generate-script\", \"ai-writer\", \"llm-chat\", \"transcribe\", \"image-to-text\", \"qa-check\",\n \"text-prompt\",\n // UGC Cards' output card is its Notes: a run hands it on as the node's text\n // (`output.text`, `generatedText` on the canvas).\n \"ugc-cards\",\n])\n\n// ---------------------------------------------------------------------------\n// Output type enum\n// ---------------------------------------------------------------------------\n\nexport type OutputType = \"image\" | \"video\" | \"audio\" | \"text\" | \"data\"\n\n// ---------------------------------------------------------------------------\n// Core functions\n// ---------------------------------------------------------------------------\n\n/** Get nodes that act as user inputs (text prompts, uploads, parameters). */\nexport function getInputNodes<T extends GenericNode>(nodes: T[], curatedOnly = true): T[] {\n return nodes.filter((n) => {\n if (!n.type || ALWAYS_EXCLUDED_TYPES.has(n.type)) return false\n if (n.hidden) return false\n if (curatedOnly) {\n // New explicit flag\n if (n.data.presentationInput === true) return true\n // Backwards compat: old flag on input-type nodes\n if (n.data.presentationVisible === true && INPUT_NODE_TYPES.has(n.type)) return true\n return false\n }\n return true\n })\n}\n\n/** Get leaf/media-producing nodes that represent workflow outputs. */\nexport function getOutputNodes<T extends GenericNode>(\n nodes: T[],\n edges: GenericEdge[],\n curatedOnly = true,\n): T[] {\n const nodesWithOutgoing = new Set(edges.map((e) => e.source))\n\n return nodes.filter((n) => {\n if (!n.type || ALWAYS_EXCLUDED_TYPES.has(n.type)) return false\n if (n.hidden) return false\n if (curatedOnly) {\n // New explicit flag\n if (n.data.presentationOutput === true) return true\n // Backwards compat: old flag on output-eligible nodes\n if (n.data.presentationVisible === true) {\n if (NON_OUTPUT_TYPES.has(n.type)) return false\n return !nodesWithOutgoing.has(n.id) || isMediaProducingType(n.type)\n }\n return false\n }\n return true\n })\n}\n\n/**\n * Map node type to its output media type.\n *\n * The four literal sets above are read FIRST and win: they are the presentation\n * classifier's own opinion, including for dual-mode nodes whose default medium\n * is not their handle set (voice-changer and dubbing are audio here even though\n * they can emit video).\n *\n * Anything they do not name falls through to the producer vocabularies the\n * canvas validators and the orchestrator already maintain\n * (`packages/shared/src/producer-types.ts`). Those sets are what a new media\n * node MUST join for its outputs to connect at all, so deriving the tail from\n * them is what stops this map from silently drifting behind the node catalogue\n * — which it had (3D Render Pro, Generate Video, Generate Video Pro and a dozen\n * ffmpeg nodes all read as `\"data\"`, so a published app rendered them as a JSON\n * blob and `/v1` app schemas declared the wrong output type).\n *\n * `DYNAMIC_PRODUCER_TYPES` is deliberately NOT consulted: a node whose medium\n * is decided at run time has no static answer, and `\"data\"` is the honest one.\n */\nexport function getOutputType(nodeType: string | undefined): OutputType {\n if (!nodeType) return \"data\"\n if (IMAGE_OUTPUT_TYPES.has(nodeType)) return \"image\"\n if (VIDEO_OUTPUT_TYPES.has(nodeType)) return \"video\"\n if (AUDIO_OUTPUT_TYPES.has(nodeType)) return \"audio\"\n if (TEXT_OUTPUT_TYPES.has(nodeType)) return \"text\"\n if (VIDEO_PRODUCER_TYPES.has(nodeType)) return \"video\"\n if (AUDIO_PRODUCER_TYPES.has(nodeType)) return \"audio\"\n return \"data\"\n}\n\n/**\n * Whether a node produces media of its own — the test the legacy\n * `presentationVisible` rule uses to keep a media node as an OUTPUT even when\n * it also feeds something downstream.\n *\n * Same union, same reason as `getOutputType`: the hand-kept list plus the\n * producer vocabularies. Text producers stay where the literal list put them\n * (`generate-script`, `ai-writer`, `llm-chat` are members; `transcribe` and\n * `qa-check` are not) — this is about media, not about every node with a value.\n */\nfunction isMediaProducingType(nodeType: string): boolean {\n if (MEDIA_PRODUCING_TYPES.has(nodeType)) return true\n const output = getOutputType(nodeType)\n return output === \"image\" || output === \"video\" || output === \"audio\"\n}\n\n/** Extract the result URL or text from a node's data. */\nexport function getNodeResult(\n nodeData: Record<string, unknown>,\n): { url?: string; text?: string } {\n // Preview node: extract first visible item from previewItems\n const previewItems = nodeData.previewItems as\n | Array<{ type: string; value: string; visible?: boolean }>\n | undefined\n if (previewItems && previewItems.length > 0) {\n const first = previewItems.find((item) => item.visible !== false) ?? previewItems[0]\n if (first) {\n if (first.type === \"image\" || first.type === \"video\" || first.type === \"audio\") {\n return { url: first.value }\n }\n return { text: first.value }\n }\n }\n\n const results = nodeData.generatedResults as\n | Array<Record<string, unknown>>\n | undefined\n\n if (results && results.length > 0) {\n const idx = (nodeData.activeResultIndex as number) ?? 0\n const active = results[idx] ?? results[0]\n const url = (active?.url ?? active?.imageUrl ?? active?.videoUrl ?? active?.audioUrl) as\n | string\n | undefined\n const text = (active?.text ?? active?.script) as string | undefined\n return { url, text }\n }\n\n // Fallback to individual generated fields\n const url = (nodeData.generatedImageUrl ??\n nodeData.generatedVideoUrl ??\n nodeData.generatedAudioUrl) as string | undefined\n const text = (nodeData.generatedScript ?? nodeData.generatedText) as\n | string\n | undefined\n\n return { url, text }\n}\n\n/** Human-readable label for a node. */\nexport function getNodeLabel(node: GenericNode): string {\n return (\n (node.data.label as string) ||\n node.type?.replace(/-/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase()) ||\n \"Node\"\n )\n}\n\n// ---------------------------------------------------------------------------\n// Input field schema (for API schema generation)\n// ---------------------------------------------------------------------------\n\nexport interface InputFieldSchema {\n key: string\n type: \"text\" | \"image-url\" | \"video-url\" | \"audio-url\" | \"select\" | \"number\"\n options?: string[]\n}\n\n// Override field per input-node type. The `key` for a parameter-picker MUST be\n// the field that `getParameterValue()` (parameter-node-value.ts) actually reads\n// — for multi-dimension pickers, its FIRST per-dimension field (the\n// \"representative key\"). A mismatch silently drops the curated app/MCP/SDK input\n// (the override lands on a field nothing reads). This map is the single source\n// of truth for app-input override fields (consumed by extract-app-inputs.ts,\n// api-tokens.ts, and the app-runner). Its parity with getParameterValue is\n// guarded by input-field-map-parity.test.ts so the two can't drift.\nexport const INPUT_FIELD_MAP: Record<string, InputFieldSchema> = {\n // --- Source / upload nodes (not parameter pickers) ---\n \"text-prompt\": { key: \"text\", type: \"text\" },\n \"upload-image\": { key: \"url\", type: \"image-url\" },\n \"upload-video\": { key: \"url\", type: \"video-url\" },\n \"upload-audio\": { key: \"url\", type: \"audio-url\" },\n \"reference-audio\": { key: \"extractedAudioUrl\", type: \"audio-url\" },\n // A LINK, not an upload (rule: `videoLinkInputProblem`, video-link.ts); still a `video-url` media input.\n \"youtube-video\": { key: \"youtubeUrl\", type: \"video-url\" },\n // --- Classic parameters ---\n \"provider\": { key: \"provider\", type: \"select\" },\n \"style-guide\": { key: \"text\", type: \"text\" }, // reads data.text (was wrongly \"styleGuide\")\n \"scene-count\": { key: \"count\", type: \"number\" },\n \"duration\": { key: \"seconds\", type: \"number\" }, // reads data.seconds (was wrongly \"duration\")\n \"aspect-ratio\": { key: \"ratio\", type: \"select\" }, // reads data.ratio (was wrongly \"aspectRatio\")\n // --- Single-field parameter pickers ---\n \"tone\": { key: \"tone\", type: \"select\" },\n \"motion\": { key: \"motion\", type: \"select\" },\n \"camera-motion\": { key: \"cameraMotion\", type: \"select\" },\n \"lens\": { key: \"lens\", type: \"select\" },\n \"camera-format\": { key: \"cameraFormat\", type: \"select\" },\n \"color-look\": { key: \"colorLook\", type: \"select\" },\n \"atmosphere\": { key: \"atmosphere\", type: \"select\" },\n \"style\": { key: \"style\", type: \"select\" },\n \"setting\": { key: \"setting\", type: \"select\" },\n \"mood\": { key: \"mood\", type: \"select\" },\n \"photographer\": { key: \"photographer\", type: \"select\" },\n \"aesthetic\": { key: \"aesthetic\", type: \"select\" },\n \"era\": { key: \"era\", type: \"select\" },\n \"material\": { key: \"material\", type: \"select\" },\n \"animal\": { key: \"animal\", type: \"select\" },\n \"vehicle\": { key: \"vehicle\", type: \"select\" },\n \"weapon\": { key: \"weapon\", type: \"select\" },\n \"furniture\": { key: \"furniture\", type: \"select\" },\n \"photo-genre\": { key: \"photoGenre\", type: \"select\" },\n \"backdrop\": { key: \"backdrop\", type: \"select\" },\n \"held-prop\": { key: \"heldProp\", type: \"select\" },\n \"render-quality\": { key: \"renderQuality\", type: \"select\" },\n \"composition-effects\": { key: \"compositionEffect\", type: \"select\" },\n \"post-process-effects\": { key: \"postProcess\", type: \"select\" },\n \"action-fx\": { key: \"actionFx\", type: \"select\" },\n \"character-fx\": { key: \"characterFx\", type: \"select\" },\n \"character-motion\": { key: \"characterMotion\", type: \"select\" },\n \"transition\": { key: \"transition\", type: \"select\" },\n \"loop-subject\": { key: \"loopSubject\", type: \"select\" },\n // --- Multi-dimension pickers: representative (first) field. Overriding only\n // sets that dimension; full hint composition runs in the executors. ---\n \"framing\": { key: \"shotSize\", type: \"select\" },\n \"lighting\": { key: \"timeOfDay\", type: \"select\" },\n \"temporal\": { key: \"temporalSpeed\", type: \"select\" },\n \"person\": { key: \"type\", type: \"select\" },\n \"pose\": { key: \"pose\", type: \"select\" },\n \"styling\": { key: \"makeup\", type: \"select\" },\n \"exposure-settings\": { key: \"aperture\", type: \"select\" },\n \"music-genre\": { key: \"subgenre\", type: \"select\" },\n \"music-mood\": { key: \"emotion\", type: \"select\" },\n \"instrumentation\": { key: \"production\", type: \"select\" },\n \"voice-character\": { key: \"timbre\", type: \"select\" },\n \"voice-delivery\": { key: \"archetype\", type: \"select\" },\n // --- UGC (Cloud) ---\n \"ugc-creator\": { key: \"source\", type: \"select\" },\n}\n\n/**\n * Extra API-settable keys for node types whose card writes more than one field\n * (INPUT_FIELD_MAP is one key per node type). Read by extract-app-inputs and the\n * app runner; every key here must be in UGC_OVERRIDABLE_FIELDS for a UGC type.\n */\nexport const INPUT_FIELD_EXTRA_KEYS: Readonly<Record<string, readonly InputFieldSchema[]>> = {\n \"ugc-creator\": [{ key: \"gender\", type: \"select\" }, { key: \"photoUrl\", type: \"image-url\" }],\n // The script's language: changes together with UGC_OVERRIDABLE_FIELDS[\"ugc-script\"] and UgcScriptData.language.\n \"ugc-script\": [{ key: \"language\", type: \"select\" }],\n}\n\n/** The extra override fields of a node type (none for most types). */\nexport function getInputFieldExtraKeys(nodeType: string): readonly InputFieldSchema[] {\n return Object.hasOwn(INPUT_FIELD_EXTRA_KEYS, nodeType) ? INPUT_FIELD_EXTRA_KEYS[nodeType]! : []\n}\n\n/** Get the overridable field schema for an input node type. */\nexport function getInputFieldSchema(nodeType: string): InputFieldSchema | undefined {\n return INPUT_FIELD_MAP[nodeType]\n}\n\nconst MEDIA_INPUT_FIELD_TYPES: ReadonlySet<InputFieldSchema[\"type\"]> = new Set([\n \"image-url\",\n \"video-url\",\n \"audio-url\",\n])\n\n/**\n * Shallow-merge run-time input overrides (a published app's inputs, an API-token\n * run, MCP `run_app` / `run_workflow` inputs, a wired component handle) over a\n * node's SAVED data — the one merge every such lane must use.\n *\n * `metadata` holds facts measured FROM the node's media (its length, its\n * dimensions). When an override swaps that media — the node's primary input\n * field is a media url (`INPUT_FIELD_MAP`) and the override changes it — the\n * snapshot's facts describe a file that is no longer there, so they are dropped\n * unless the override supplies its own. Left behind, a publisher's\n * `metadata.durationSeconds` outranks the run's own transcript as Edit Plan's\n * duration basis and under-buckets a caller's longer episode: an estimate that\n * passes the balance precheck for a run the reserve then refuses.\n *\n * Schema-driven on purpose: a new media input node is covered by its\n * `INPUT_FIELD_MAP` row, with no list to remember here.\n *\n * An override sent under a renamed exposed-field key (an app published before\n * the rename) lands on the node's current field — `canonicalizeOverrideKeys`.\n *\n * An override of `null` clears the field: the merged node has no such key.\n */\nexport function mergeNodeInputOverrides(\n nodeType: string | undefined,\n data: Record<string, unknown>,\n overrides: Record<string, unknown>,\n): Record<string, unknown> {\n const incoming = canonicalizeOverrideKeys(nodeType, overrides)\n // A Video URL node on a new link sheds what was fetched for the old one.\n const base = nodeType === \"youtube-video\" ? dropStaleVideoLinkFields(data, incoming) : data\n const merged: Record<string, unknown> = { ...base, ...incoming }\n // A null override CLEARS the field: the run has no value there, neither null nor the saved one. JSON cannot\n // carry `undefined`, so this is how a run says \"unset\" (an app card clearing a lever the chosen model lacks).\n for (const [key, value] of Object.entries(incoming)) {\n if (value === null) delete merged[key]\n }\n const schema = nodeType ? INPUT_FIELD_MAP[nodeType] : undefined\n if (\n schema &&\n MEDIA_INPUT_FIELD_TYPES.has(schema.type) &&\n schema.key in overrides &&\n overrides[schema.key] !== data[schema.key] &&\n !(\"metadata\" in overrides)\n ) {\n delete merged.metadata\n }\n return merged\n}\n\n// ---------------------------------------------------------------------------\n// Migration & validation helpers (PresentationItem)\n// ---------------------------------------------------------------------------\n\n/** Migrate a legacy string[] order to PresentationItem[]. */\nexport function migrateToItems(order: string[] | undefined): PresentationItem[] | undefined {\n if (!order) return undefined\n return order.map((nodeId) => ({ type: \"node\" as const, nodeId }))\n}\n\n/** Strip nested groups — groups may only contain non-group items. */\nexport function validateNoNestedGroups(items: PresentationItem[]): PresentationItem[] {\n return items.map((item) => {\n if (item.type === \"group\") {\n return { ...item, items: item.items.filter((child) => child.type !== \"group\") }\n }\n return item\n })\n}\n\n/** Recursively flatten all items, unwrapping groups. */\nexport function flattenItems(items: PresentationItem[]): PresentationItem[] {\n const result: PresentationItem[] = []\n for (const item of items) {\n if (item.type === \"group\") {\n result.push(...flattenItems(item.items))\n } else {\n result.push(item)\n }\n }\n return result\n}\n\n/** Get the sortable/unique ID for a PresentationItem. */\nexport function getItemSortId(item: PresentationItem): string {\n return item.type === \"node\" ? item.nodeId : item.id\n}\n\n/** Remove items whose nodeId no longer exists in the workflow. */\nexport function cleanOrphanedItems(\n items: PresentationItem[],\n nodeIds: Set<string>\n): PresentationItem[] {\n return items\n .filter((item) => {\n if (item.type === \"node\" || item.type === \"field\" || item.type === \"output\") return nodeIds.has(item.nodeId)\n return true\n })\n .map((item) => {\n if (item.type === \"group\") {\n return { ...item, items: cleanOrphanedItems(item.items, nodeIds) }\n }\n return item\n })\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/video-ui-defaults.ts"],"names":[],"mappings":";;;;AAuCO,SAAS,kBAAkB,QAAA,EAAsC;AACtE,EAAA,OAAO,mBAAA,CAAoB,QAAQ,CAAA,IAAK,mBAAA,CAAoB,QAAQ,CAAA,IAAK,cAAA,CAAe,QAAQ,CAAA,GAC5F,UAAA,GACA,MAAA;AACN;AAIO,SAAS,iBAAiB,QAAA,EAAsC;AACrE,EAAA,IAAI,cAAA,CAAe,QAAQ,CAAA,EAAG,OAAO,2BAA2B,QAAQ,CAAA;AACxE,EAAA,IAAI,mBAAA,CAAoB,QAAQ,CAAA,EAAG,OAAO,cAAc,QAAQ,CAAA,EAAG,cAAc,CAAC,CAAA;AAClF,EAAA,OAAO,MAAA;AACT;AAUO,SAAS,eAAe,QAAA,EAAsC;AACnE,EAAA,IAAI,cAAA,CAAe,QAAQ,CAAA,EAAG,OAAO,CAAA;AACrC,EAAA,IAAI,oBAAA,CAAqB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT","file":"chunk-QA3MVQ32.js","sourcesContent":["/**\n * UI-default fills for the unified video nodes — the ONE source of truth shared\n * by the backend DAG payload builder, the config-panel fail-safe snaps and the\n * node's hover/run strip.\n *\n * Several config panels RENDER a default without persisting it to node data, so\n * an untouched node submits `aspectRatio` / `resolution` undefined and the\n * enqueued job row (and the /v1/jobs echo) then disagrees with what actually\n * renders. Worse, the panels' generic snap writes `resolutions[0]` for a stale\n * value, which is the CHEAPEST tier under the repo's ascending-resolution\n * convention — not necessarily the tier the model renders and bills.\n *\n * These helpers were local to `backend/src/services/workflow-engine/payload-builder.ts`\n * until the Wan 3.0 launch gave the platform its first provider whose declared\n * billing default differs from `resolutions[0]`; three surfaces then had to\n * agree, so they live here.\n *\n * The resolution fill is per-family ON PURPOSE. Wan 3.0 reads its DECLARED\n * billing default (PRICING_DEFAULT_RESOLUTION = 720p) because its catalog list\n * is ascending, so an index-0 fill would write 480p — a tier both `runWan3`\n * (which renders 720P) and the credit identifier (which bills the 720p row)\n * disagree with. The Seedance family keeps its historical first-catalog-tier\n * fill, deliberately: switching it to PRICING_DEFAULT_RESOLUTION would reprice\n * live seedance-2-5 runs, whose declared default (720p) differs from the 480p\n * this has always filled. That 480p-fill vs 720p-billing-default divergence on\n * seedance-2-5 is a KNOWN pre-existing gap, out of scope here — do not \"align\"\n * the branches without repricing it deliberately.\n */\n\nimport {\n PRICING_DEFAULT_RESOLUTION,\n isSeedance2Provider,\n isMinimaxH3Provider,\n isWan3Provider,\n isGeminiOmniProvider,\n} from \"./model-constants.js\"\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/** `adaptive` is the aspect default for Seedance 2, MiniMax H3 and Wan 3.0. */\nexport function uiAspectRatioFill(provider: string): string | undefined {\n return isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider)\n ? \"adaptive\"\n : undefined\n}\n\n/** See the file docstring — per-family on purpose; never a generic\n * PRICING_DEFAULT_RESOLUTION read (that would reprice seedance-2-5). */\nexport function uiResolutionFill(provider: string): string | undefined {\n if (isWan3Provider(provider)) return PRICING_DEFAULT_RESOLUTION[provider]\n if (isSeedance2Provider(provider)) return MODEL_CATALOG[provider]?.resolutions?.[0]\n return undefined\n}\n\n/**\n * Duration the node RENDERS and BILLS when `data.duration` is unset, for the\n * families whose credit identifier declares a duration fallback that is NOT\n * `durations[0]`. Wan 3.0's bare identifier is the 5s tier while its ladder\n * starts at 2s; the Gemini Omni family's is the 8s tier while its ladder starts\n * at 4s. Everyone else falls back to the first listed duration, so this returns\n * undefined and the caller keeps `durations[0]`.\n */\nexport function uiDurationFill(provider: string): number | undefined {\n if (isWan3Provider(provider)) return 5\n if (isGeminiOmniProvider(provider)) return 8\n return undefined\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/audio-crossfade-curves.ts","../src/smart-cut-windows.ts","../src/speaker-tracks.ts","../src/camera-switch-contract.ts","../src/edit-plan-contract.ts"],"names":["normalizeTranscript","num","EDL_VERSION"],"mappings":";;;;;AAkBO,IAAM,sBAAA,GAAyD;AAAA,EACpE;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,QAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,eAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,4BACX,sBAAA,CAAuB,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE;AAEjC,IAAM,gCAAA,GAAmC;AAEhD,IAAM,eAAyD,IAAI,GAAA;AAAA,EACjE,sBAAA,CAAuB,IAAI,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,EAAA,EAAI,CAAC,CAAC;AAC7C,CAAA;AAEO,SAAS,uBAAuB,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M,OAAA,CAAQ,CAAA,CAAE,QAAQ,CAAA,EAAG,OAAO,EAAE,OAAA,EAASC,6BAAA,EAAa,QAAA,EAAU,CAAA,CAAE,QAAA,EAAS;AAEnF,EAAA,MAAM,EAAE,cAAA,EAAgB,eAAA,EAAiB,GAAG,MAAK,GAAI,CAAA;AACrD,EAAA,OAAO,IAAA;AACT","file":"chunk-SES6GDBQ.cjs","sourcesContent":["/**\n * Curated subset of FFmpeg `acrossfade=curve=...` options for combine-videos\n * audio crossfades. We expose 5 well-understood presets out of the ~21 raw\n * curves FFmpeg supports; the rest are either visually indistinguishable to\n * non-audio-engineers or rarely useful in this context.\n *\n * Default `linear` matches today's behavior — adding this catalog is a pure\n * additive change for existing workflows.\n */\n\nexport interface AudioCrossfadeCurve {\n readonly id: string\n /** FFmpeg `acrossfade=curve=...` name. */\n readonly ffmpeg: string\n readonly label: string\n readonly description: string\n}\n\nexport const AUDIO_CROSSFADE_CURVES: readonly AudioCrossfadeCurve[] = [\n {\n id: \"linear\",\n ffmpeg: \"tri\",\n label: \"Linear\",\n description: \"Straight-line fade. Default; predictable but can dip in the middle for music.\",\n },\n {\n id: \"equal-power\",\n ffmpeg: \"qsin\",\n label: \"Equal Power\",\n description: \"Quarter-sine. Keeps perceived loudness roughly constant across the crossfade — best for music.\",\n },\n {\n id: \"smooth\",\n ffmpeg: \"hsin\",\n label: \"Smooth (Sine)\",\n description: \"Half-sine. Gentler than equal-power; good for dialogue and ambient.\",\n },\n {\n id: \"logarithmic\",\n ffmpeg: \"log\",\n label: \"Logarithmic\",\n description: \"Compensates for the ear's logarithmic loudness response. Long, slow tails.\",\n },\n {\n id: \"exponential\",\n ffmpeg: \"exp\",\n label: \"Exponential\",\n description: \"Sharp out / slow in (or vice versa). Punchy — good for impact moments.\",\n },\n]\n\nexport const AUDIO_CROSSFADE_CURVE_IDS: readonly string[] =\n AUDIO_CROSSFADE_CURVES.map((c) => c.id)\n\nexport const DEFAULT_AUDIO_CROSSFADE_CURVE_ID = \"linear\"\n\nconst CURVES_BY_ID: ReadonlyMap<string, AudioCrossfadeCurve> = new Map(\n AUDIO_CROSSFADE_CURVES.map((c) => [c.id, c]),\n)\n\nexport function getAudioCrossfadeCurve(id: string): AudioCrossfadeCurve | undefined {\n return CURVES_BY_ID.get(id)\n}\n\n/**\n * Resolve a curve id to its FFmpeg `acrossfade=curve=` name. Unknown ids fall\n * back to `tri` (linear) — this matches the route's Zod default so callers\n * downstream of validation never see undefined.\n */\nexport function resolveAudioCrossfadeCurve(id: string | undefined): string {\n if (!id) return \"tri\"\n return CURVES_BY_ID.get(id)?.ffmpeg ?? \"tri\"\n}\n","/**\n * Smart-cut SEARCH WINDOWS — the shared bound + clamp for the\n * `smartCutFramesPrev` / `smartCutFramesNext` of BOTH smart-cut nodes:\n * generate-video-pro (segment boundaries) and combine-videos (clip joins).\n *\n * They bound how much of each side of a boundary the engine considers when\n * it places the cut: N frames from the end of a segment and M from the start\n * of the next. Absent → the engine's own default, byte-identical to the\n * behavior before they were exposed. A boundary the engine cannot resolve\n * inside the window falls back to the fixed freeze-trims; recast pins 24/24.\n *\n * Why a shared clamp: the config panel, the canvas node (single-node Run) and\n * the orchestrator (workflow Run) are three independent writers/send paths into\n * the same route, whose Zod schema REJECTS out-of-range values (its `.min()` /\n * `.max()` are these very constants). Deriving all of them from this one\n * function means a stale, imported or hand-edited node value degrades to a\n * legal request instead of 400-ing an entire run — and the paths cannot drift\n * apart. An `<input type=\"number\" max={…}>` is not a substitute: the browser\n * does not stop a typed or pasted value from reaching React's onChange.\n */\n\n/** Widest window we accept anywhere — the UI's `max`, the clamp's ceiling and\n * `/v1/combine-videos`' own Zod `.max()` (the generate-video-pro engine route\n * itself accepts up to 48). Past this, added frames only cost search time and\n * invite a false match. */\nexport const SMART_CUT_WINDOW_MAX = 24\n/** Narrowest meaningful window — one frame each side. */\nexport const SMART_CUT_WINDOW_MIN = 1\n/** The engine's default when the field is absent. Documented here so the UI\n * can show it as the placeholder without hardcoding a second copy. */\nexport const SMART_CUT_WINDOW_DEFAULT = 8\n\n/**\n * Narrow an arbitrary node value to a legal window, or `undefined` to mean\n * \"let the engine use its default\". Non-numbers, NaN, and non-integers all\n * collapse to `undefined` rather than to a guessed number: a malformed value\n * should fall back to the proven default, not silently pick a different\n * search width than the user asked for.\n */\nexport function clampSmartCutWindow(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const n = Math.round(value)\n if (n < SMART_CUT_WINDOW_MIN) return SMART_CUT_WINDOW_MIN\n if (n > SMART_CUT_WINDOW_MAX) return SMART_CUT_WINDOW_MAX\n return n\n}\n","import type { Edl, EdlSource, EdlValidation } from \"./edl.js\"\n\n/**\n * Speaker tracks — where each speaker's face is, over time, per camera.\n *\n * WHY THIS EXISTS\n * A face-tracking analysis node samples each camera an edit shows, finds the\n * faces, links them into tracks and labels each track with a speaker. Its\n * result feeds the framing rung `resolveEdlSegmentSlots` reserves for a\n * per-segment resolver (D20, edl-multicam.ts). This module is the wire shape\n * of that result plus the pure functions that read it: structural vocabulary\n * only — no detector, no linking or attribution rule, no framing or follow\n * math, no thresholds. That is why it lives in the Apache-licensed\n * `@nodaro/shared` (the public contract: the API response, the SDK type and\n * the MCP output). Every published version is an irrevocable grant, so every\n * later field is optional and additive.\n *\n * TWO SHAPES, ONE PROJECTION\n * - `SpeakerTrackSet` — the full set, boxes included. At a long multi-camera\n * edit it is megabytes of JSON, so it is stored as a JSON artifact (the\n * versioned box body), never inline in a job row or a node's data.\n * - `SpeakerTrackSetDescriptor` — what the node outputs: the same set with\n * every box removed (a `boxCount` per track instead) plus the artifact's\n * `url`, `sha256` and `bytes`. Consumers fetch the body by URL, check the\n * hash, run `normalizeSpeakerTracks` + `validateSpeakerTracks` on it, and\n * can confirm it is the body the descriptor names with\n * `describeSpeakerTracks(body, artifact)` deep-equal to the descriptor.\n *\n * CLOCK (D19)\n * Boxes are per SOURCE and on that source's own clock (`clock: \"source\"`), in\n * integer ms. A consumer maps to the master clock through the EDL source's\n * offset: `masterMs = ms + offsetMs` (`remapMsThroughEdl(edl, ms, sourceId)`).\n * Nothing here applies the offset, and nothing ever rescales a time (no\n * seconds→ms guessing — an implausible value is a validation error).\n *\n * GEOMETRY\n * Box coordinates are fractions 0..1 of `frame`: the display-oriented frame\n * (after rotation, square pixels) the producer sampled.\n *\n * SAMPLING\n * `sampledSpans` say what was looked at. No box for a track outside them means\n * \"not sampled\"; inside them it means \"no face there\". Spans are half-open\n * `[startMs, endMs)`, like EDL segments.\n */\n\nexport const SPEAKER_TRACKS_VERSION = 1 as const\n\n/** How a track got its speaker. Open: a newer producer may add a method, which\n * an older validator reports as a WARNING, never an issue. */\nexport const SPEAKER_TRACK_ATTRIBUTION_METHODS = [\"source-map\", \"region\", \"mouth-motion\", \"manual\"] as const\nexport type SpeakerTrackAttributionMethod = (typeof SPEAKER_TRACK_ATTRIBUTION_METHODS)[number]\nconst KNOWN_METHODS: ReadonlySet<string> = new Set(SPEAKER_TRACK_ATTRIBUTION_METHODS)\n\n/** Default hard cap on boxes per source. The longest edit the platform plans\n * for (180 minutes) sampled at 2 per second is 21,600 samples per source; the\n * cap leaves room for several faces in every sample. Override per call with\n * `maxBoxesPerSource`. */\nexport const SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE = 100_000\n/** Default hard cap on the serialized size of a track set (UTF-8 bytes of its\n * JSON), so no consumer ever loads an unbounded body. Override per call with\n * `maxBytes`. */\nexport const SPEAKER_TRACKS_MAX_BYTES = 64 * 1024 * 1024\n\n/** One detection. `ms` on the source clock; x/y/w/h fractions 0..1 of the frame. */\nexport interface SpeakerTrackBox {\n readonly ms: number\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n /** Detector confidence 0..1, when the detector reports one. */\n readonly score?: number\n}\n\nexport interface SpeakerTrackAttribution {\n /** Known: `SPEAKER_TRACK_ATTRIBUTION_METHODS`. */\n readonly method: SpeakerTrackAttributionMethod | (string & {})\n /** 0..1. */\n readonly confidence: number\n /** The transcript's own label for this speaker, kept beside the display name\n * in `speaker` so a later rename re-maps instead of orphaning the track. */\n readonly rawSpeaker?: string\n}\n\n/** What a track says about itself, without its boxes. */\nexport interface SpeakerTrackHeader {\n /** Unique in the whole set, e.g. \"wide/t3\". */\n readonly id: string\n /** A label in the edit's speaker space. Absent = unattributed. */\n readonly speaker?: string\n readonly attribution?: SpeakerTrackAttribution\n}\n\nexport interface SpeakerTrack extends SpeakerTrackHeader {\n /** Strictly increasing `ms`, each inside one of the source's `sampledSpans`. */\n readonly boxes: readonly SpeakerTrackBox[]\n}\n\nexport interface SpeakerTrackSummary extends SpeakerTrackHeader {\n readonly boxCount: number\n}\n\nexport interface SpeakerTrackSpan {\n readonly startMs: number\n /** Exclusive, > startMs. */\n readonly endMs: number\n}\n\ninterface SpeakerTrackSourceFields {\n /** `EdlSource.id` of a video source. */\n readonly sourceId: string\n /** Boxes, spans and cuts are ms on this SOURCE's own clock (D19). */\n readonly clock: \"source\"\n /** The display-oriented frame (after rotation, square pixels), in pixels, that box fractions refer to. */\n readonly frame: { readonly w: number; readonly h: number }\n /** What was sampled: sorted, non-overlapping, half-open. */\n readonly sampledSpans: readonly SpeakerTrackSpan[]\n /** Source-clock ms of detected scene changes, ascending. No track spans one. */\n readonly cuts?: readonly number[]\n}\n\nexport interface SpeakerTrackSource extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrack[]\n}\n\nexport interface SpeakerTrackSourceSummary extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrackSummary[]\n}\n\ninterface SpeakerTrackSetFields {\n readonly version: 1\n /** Samples per second the producer looked at. */\n readonly sampleFps: number\n /** Informational: which detector produced the boxes, e.g. \"example:face-detector\". */\n readonly detector: { readonly id: string; readonly version?: string }\n}\n\n/** The full set — the versioned box body, stored as a JSON artifact. */\nexport interface SpeakerTrackSet extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSource[]\n}\n\n/** What the analysis node outputs: the set without its boxes, plus where the body is. */\nexport interface SpeakerTrackSetDescriptor extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSourceSummary[]\n /** Where the `SpeakerTrackSet` body is stored. */\n readonly url: string\n /** SHA-256 of the stored body's bytes, 64 lowercase hex characters. */\n readonly sha256: string\n /** Size of the stored body in bytes. */\n readonly bytes: number\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Normalization (coerce, never reject — and never reinterpret)\n// ─────────────────────────────────────────────────────────────────────────\n\nconst isObj = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\nconst isNum = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v)\nconst num = (v: unknown, fallback = 0): number => (isNum(v) ? v : fallback)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v))\n/** A readonly array field of a value that may have skipped normalization. */\nconst arr = <T,>(v: readonly T[] | undefined): readonly T[] => (Array.isArray(v) ? v : [])\n/** Integer ms; never -0 (JSON cannot carry it, so a round trip would differ). */\nconst int = (v: number): number => {\n const r = Math.round(v)\n return r === 0 ? 0 : r\n}\n\n/** One axis of a detection, cropped to the frame: the visible part of\n * `[p, p+s]` within `[0, 1]`, or undefined when none of it is visible. An\n * in-frame axis is returned untouched (so a second pass cannot drift by a\n * float ulp); an overhanging one becomes the intersection, whichever edge it\n * crosses, so its centre only ever moves toward the visible part. */\nfunction cropAxis(p: number, s: number): readonly [number, number] | undefined {\n if (!(s > 0)) return undefined\n if (p >= 0 && p + s <= 1) return [p, s]\n const lo = clamp01(p)\n const hi = clamp01(p + s)\n return hi > lo ? [lo, hi - lo] : undefined\n}\n\nfunction normalizeBox(raw: unknown): SpeakerTrackBox | undefined {\n if (!isObj(raw)) return undefined\n if (![raw.ms, raw.x, raw.y, raw.w, raw.h].every(isNum)) return undefined\n // A detection is cropped to the frame, never moved: a face at the frame edge\n // keeps only its visible part, and one entirely off-frame is dropped. This is\n // deliberately NOT `normalizeRegion`'s clamp-then-shrink (edl.ts), which is\n // fine for a region a user draws but would shift a left/top overhang and turn\n // an off-frame detection into an in-frame face.\n const xs = cropAxis(raw.x as number, raw.w as number)\n const ys = cropAxis(raw.y as number, raw.h as number)\n if (!xs || !ys) return undefined\n const [x, w] = xs\n const [y, h] = ys\n return { ms: int(raw.ms as number), x, y, w, h, ...(isNum(raw.score) ? { score: clamp01(raw.score) } : {}) }\n}\n\nfunction normalizeSpans(raw: unknown): SpeakerTrackSpan[] {\n if (!Array.isArray(raw)) return []\n const spans = raw\n .filter(isObj)\n .filter((s) => isNum(s.startMs) && isNum(s.endMs))\n .map((s) => ({ startMs: int(s.startMs as number), endMs: int(s.endMs as number) }))\n .filter((s) => s.endMs > s.startMs)\n .sort((a, b) => a.startMs - b.startMs || a.endMs - b.endMs)\n const merged: SpeakerTrackSpan[] = []\n for (const s of spans) {\n const last = merged[merged.length - 1]\n if (last && s.startMs <= last.endMs) merged[merged.length - 1] = { startMs: last.startMs, endMs: Math.max(last.endMs, s.endMs) }\n else merged.push(s)\n }\n return merged\n}\n\nfunction normalizeCuts(raw: unknown): number[] {\n if (!Array.isArray(raw)) return []\n const sorted = raw.filter(isNum).map(int).sort((a, b) => a - b)\n return sorted.filter((c, i) => i === 0 || c !== sorted[i - 1])\n}\n\nfunction normalizeAttribution(raw: unknown): SpeakerTrackAttribution | undefined {\n if (!isObj(raw)) return undefined\n const method = str(raw.method)\n if (!method) return undefined\n const rawSpeaker = str(raw.rawSpeaker)\n return { method, confidence: clamp01(num(raw.confidence)), ...(rawSpeaker ? { rawSpeaker } : {}) }\n}\n\nfunction normalizeHeader(raw: Record<string, unknown>, fallbackId: string): SpeakerTrackHeader {\n const speaker = str(raw.speaker)\n const attribution = normalizeAttribution(raw.attribution)\n return {\n id: str(raw.id) || fallbackId,\n ...(speaker ? { speaker } : {}),\n ...(attribution ? { attribution } : {}),\n }\n}\n\nfunction normalizeSetFields(o: Record<string, unknown>): SpeakerTrackSetFields {\n const detector = isObj(o.detector) ? o.detector : {}\n const detectorVersion = str(detector.version)\n return {\n // Only an ABSENT version defaults to 1. Any present value — another\n // number, \"2\", null — is kept as is so validate refuses it rather than\n // reading a newer (or broken) body as this one.\n version: (o.version === undefined ? SPEAKER_TRACKS_VERSION : o.version) as 1,\n sampleFps: num(o.sampleFps),\n detector: { id: str(detector.id) ?? \"\", ...(detectorVersion ? { version: detectorVersion } : {}) },\n }\n}\n\nfunction normalizeSources<T>(\n raw: unknown,\n track: (t: Record<string, unknown>, fallbackId: string) => T,\n): Array<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> {\n if (!Array.isArray(raw)) return []\n return raw.map((r) => {\n const s = isObj(r) ? r : {}\n const sourceId = str(s.sourceId) ?? \"\"\n const frame = isObj(s.frame) ? s.frame : {}\n const cuts = normalizeCuts(s.cuts)\n const tracks = Array.isArray(s.tracks) ? s.tracks.map((t, k) => track(isObj(t) ? t : {}, `${sourceId}/t${k + 1}`)) : []\n return {\n sourceId,\n // A clock other than \"source\" cannot be repaired: boxes on another clock\n // would land offsetMs away from their frame. Keep it for validate to refuse.\n clock: (typeof s.clock === \"string\" ? s.clock : \"source\") as \"source\",\n frame: { w: int(num(frame.w)), h: int(num(frame.h)) },\n sampledSpans: normalizeSpans(s.sampledSpans),\n tracks,\n ...(cuts.length > 0 ? { cuts } : {}),\n }\n })\n}\n\n/**\n * Coerce an unknown value into a well-formed `SpeakerTrackSet` (the box body):\n * drop unknown keys and malformed boxes, crop every box to the frame (an\n * entirely off-frame box is dropped, an overhang keeps its visible part), clamp\n * scores and confidences to 0..1, round every time to integer ms, sort each\n * track's boxes by time (box order IS time, unlike EDL segment order), sort and\n * merge sampled spans, sort and de-duplicate cuts.\n *\n * It never repairs what would change meaning: a box outside every sampled\n * span, two boxes at one instant, a track across a cut, another version or\n * another clock all survive for `validateSpeakerTracks` to report.\n */\nexport function normalizeSpeakerTracks(input: unknown): SpeakerTrackSet {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => {\n const boxes = Array.isArray(t.boxes) ? t.boxes.map(normalizeBox).filter((b): b is SpeakerTrackBox => b !== undefined) : []\n return { ...normalizeHeader(t, fallbackId), boxes: [...boxes].sort((a, b) => a.ms - b.ms) }\n }),\n }\n}\n\n/** Coerce an unknown value into a `SpeakerTrackSetDescriptor`, by the same rules\n * as `normalizeSpeakerTracks`; a missing or broken `boxCount` becomes 0. */\nexport function normalizeSpeakerTrackSetDescriptor(input: unknown): SpeakerTrackSetDescriptor {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => ({\n ...normalizeHeader(t, fallbackId),\n boxCount: Math.max(0, int(num(t.boxCount))),\n })),\n url: str(o.url) ?? \"\",\n sha256: str(o.sha256) ?? \"\",\n bytes: int(num(o.bytes)),\n }\n}\n\n/** The descriptor of a (normalized) set stored at `artifact.url`: every box\n * removed, a `boxCount` per track. Pure; the caller hashes and stores the body. */\nexport function describeSpeakerTracks(\n set: SpeakerTrackSet,\n artifact: { readonly url: string; readonly sha256: string; readonly bytes: number },\n): SpeakerTrackSetDescriptor {\n return {\n version: set.version,\n sampleFps: set.sampleFps,\n detector: { ...set.detector },\n sources: set.sources.map((s) => ({\n sourceId: s.sourceId,\n clock: s.clock,\n frame: { ...s.frame },\n sampledSpans: s.sampledSpans.map((sp) => ({ ...sp })),\n tracks: s.tracks.map((t) => ({\n id: t.id,\n ...(t.speaker !== undefined ? { speaker: t.speaker } : {}),\n ...(t.attribution ? { attribution: { ...t.attribution } } : {}),\n boxCount: t.boxes.length,\n })),\n ...(s.cuts && s.cuts.length > 0 ? { cuts: [...s.cuts] } : {}),\n })),\n url: artifact.url,\n sha256: artifact.sha256,\n bytes: artifact.bytes,\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The edit's speaker space\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The speaker labels an edit uses: the union of `sources[].speakers`,\n * `segments[].speaker` and `segments[].layout.slots[].speaker`, over every EDL\n * given (a clip pack), sorted by code unit. Tracks must be labelled in this\n * space, or no track ever matches a segment's speaker. */\nexport function edlSpeakerSpace(edl: Edl | readonly Edl[]): string[] {\n const out = new Set<string>()\n const add = (v: unknown) => {\n if (typeof v === \"string\" && v) out.add(v)\n }\n for (const e of edlList(edl)) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n for (const sp of Array.isArray(s?.speakers) ? s.speakers : []) add(sp)\n }\n for (const seg of Array.isArray(e.segments) ? e.segments : []) {\n add(seg?.speaker)\n for (const slot of Array.isArray(seg?.layout?.slots) ? seg.layout!.slots! : []) add(slot?.speaker)\n }\n }\n return [...out].sort()\n}\n\nfunction edlList(edl: Edl | readonly Edl[] | undefined): readonly Edl[] {\n if (!edl) return []\n const all: readonly unknown[] = Array.isArray(edl) ? edl : [edl]\n return all.filter((e): e is Edl => isObj(e))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface SpeakerTracksValidateOptions {\n /** The edit the tracks are for — one EDL, or every clip of a pack. When given,\n * every source must resolve to one of its video sources, and attributed\n * speakers must be in its speaker space (`edlSpeakerSpace`). */\n readonly edl?: Edl | readonly Edl[]\n /** Default `SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE`. */\n readonly maxBoxesPerSource?: number\n /** Default `SPEAKER_TRACKS_MAX_BYTES`. */\n readonly maxBytes?: number\n /** `validateSpeakerTracks` only: the body's known size in bytes (e.g. the\n * fetched length), so a large body is not serialized again to measure it. */\n readonly serializedBytes?: number\n}\n\nconst SHA256_HEX = /^[0-9a-f]{64}$/\n\ntype Findings = { issues: string[]; warnings: string[] }\n\n/** The rules shared by the body and the descriptor. `perTrack` adds the body's\n * box rules and returns the track's box count. */\nfunction validateCommon<T extends SpeakerTrackHeader>(\n set: SpeakerTrackSetFields & { readonly sources: ReadonlyArray<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> },\n opts: SpeakerTracksValidateOptions,\n perTrack: (track: T, source: SpeakerTrackSourceFields, f: Findings) => number,\n): Findings {\n const f: Findings = { issues: [], warnings: [] }\n const { issues, warnings } = f\n const sources = arr(set.sources)\n const maxBoxes = opts.maxBoxesPerSource ?? SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE\n\n if (set.version !== SPEAKER_TRACKS_VERSION) issues.push(`version must be ${SPEAKER_TRACKS_VERSION}`)\n if (!(isNum(set.sampleFps) && set.sampleFps > 0)) issues.push(\"sampleFps must be a finite number > 0\")\n\n const edls = edlList(opts.edl)\n const edlSources = new Map<string, EdlSource>()\n for (const e of edls) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n if (s && typeof s.id === \"string\" && !edlSources.has(s.id)) edlSources.set(s.id, s)\n }\n }\n\n const sourceIds = new Set<string>()\n const trackIds = new Set<string>()\n sources.forEach((s, i) => {\n const sid = s.sourceId\n const at = `source \"${sid}\"`\n if (!sid) issues.push(`source[${i}]: sourceId is empty`)\n else if (sourceIds.has(sid)) issues.push(`duplicate source id \"${sid}\"`)\n sourceIds.add(sid)\n if (sid && edls.length > 0) {\n const es = edlSources.get(sid)\n if (!es) issues.push(`${at}: not a source of the EDL`)\n else if (es.kind !== \"video\") issues.push(`${at}: the EDL source is kind:\"${es.kind}\", tracks need a video source`)\n }\n if (s.clock !== \"source\") issues.push(`${at}: clock must be \"source\"`)\n if (!(isObj(s.frame) && isNum(s.frame.w) && isNum(s.frame.h) && s.frame.w > 0 && s.frame.h > 0)) {\n issues.push(`${at}: frame w/h must be positive`)\n }\n\n const spans = arr<SpeakerTrackSpan>(s.sampledSpans)\n spans.forEach((sp, j) => {\n const startMs: unknown = sp?.startMs\n const endMs: unknown = sp?.endMs\n if (!(isNum(startMs) && isNum(endMs) && endMs > startMs)) {\n issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not positive`)\n return\n }\n if (!(Number.isInteger(startMs) && Number.isInteger(endMs))) issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not integer ms`)\n if (startMs < 0) issues.push(`${at}: sampledSpans[${j}] starts before 0`)\n const prevEnd: unknown = spans[j - 1]?.endMs\n if (j > 0 && isNum(prevEnd) && startMs < prevEnd) {\n issues.push(`${at}: sampledSpans must be sorted and non-overlapping (span ${j})`)\n }\n })\n\n const cuts = s.cuts\n if (cuts !== undefined) {\n const okCuts = Array.isArray(cuts) && cuts.every((c, k) => Number.isInteger(c) && c >= 0 && (k === 0 || c > cuts[k - 1]))\n if (!okCuts) issues.push(`${at}: cuts must be ascending non-negative ms`)\n }\n\n let boxes = 0\n const tracks = arr<T>(s.tracks)\n tracks.forEach((t, k) => {\n if (!t?.id) issues.push(`${at} track[${k}]: id is empty`)\n else if (trackIds.has(t.id)) issues.push(`duplicate track id \"${t.id}\"`)\n if (t?.id) trackIds.add(t.id)\n const a = t?.attribution\n if (a) {\n if (!(isNum(a.confidence) && a.confidence >= 0 && a.confidence <= 1)) {\n issues.push(`track \"${t.id}\": attribution.confidence=${a.confidence} out of 0..1`)\n }\n if (!KNOWN_METHODS.has(a.method)) {\n warnings.push(`track \"${t.id}\": unknown attribution method \"${a.method}\" (known: ${SPEAKER_TRACK_ATTRIBUTION_METHODS.join(\", \")})`)\n }\n }\n boxes += perTrack(t, s, f)\n })\n if (boxes > maxBoxes) issues.push(`${at}: ${boxes} boxes is over the cap of ${maxBoxes}`)\n })\n\n // The speaker name space: labels from the raw transcript against an edit\n // that uses display names (or the reverse) match nothing, and every slot\n // would silently fall back to static framing.\n if (edls.length > 0) {\n const space = edlSpeakerSpace(edls)\n const attributed = sources.flatMap((s) => (Array.isArray(s.tracks) ? s.tracks : [])).filter((t) => !!t?.speaker)\n if (space.length > 0 && attributed.length > 0) {\n const inSpace = new Set(space)\n const matches = (t: T) => inSpace.has(t.speaker!) || (!!t.attribution?.rawSpeaker && inSpace.has(t.attribution.rawSpeaker))\n if (!attributed.some(matches)) {\n const labels = [...new Set(attributed.map((t) => t.speaker!))].sort()\n issues.push(\n `no tracked speaker is in the edit's speaker set: the tracks are labelled ${labels.map((l) => `\"${l}\"`).join(\", \")}` +\n ` and the edit uses ${space.map((l) => `\"${l}\"`).join(\", \")} — wire Speaker Frames to the same transcript as Camera Switch`,\n )\n } else {\n for (const t of attributed) {\n if (!matches(t)) warnings.push(`track \"${t.id}\": speaker \"${t.speaker}\" is not in the edit's speaker set`)\n }\n }\n }\n }\n return f\n}\n\n/** Per-box findings listed per track and rule before the rest are summarized\n * in one line, and the most issues a validation lists before one truncation\n * line. A systematic producer bug (a clock off by `offsetMs`, say) puts EVERY\n * box out of span; the refusal must stay readable wherever it is shown. */\nconst BOX_FINDINGS_PER_RULE = 5\nconst MAX_LISTED_FINDINGS = 100\n\n/** A per-box finding: the rule (what the per-track summary line counts, as\n * \"N more boxes <rule>\") and the message for one box. */\ntype BoxFinding = readonly [rule: string, message: string]\n\nfunction boxIssues(b: SpeakerTrackBox, at: string): BoxFinding[] {\n const out: BoxFinding[] = []\n for (const k of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const v = b?.[k]\n if (!isNum(v) || v < 0 || v > 1) out.push([`with ${k} out of 0..1`, `${at}: ${k}=${v} out of 0..1`])\n }\n if (out.length > 0) return out\n // The same edge tolerance as validateEdl's regions, so the two never disagree.\n if (b.w <= 0 || b.h <= 0) out.push([\"with a non-positive w/h\", `${at}: non-positive w/h`])\n if (b.x + b.w > 1 + 1e-9) out.push([\"extending past the right edge\", `${at}: extends past the right edge (x+w>1)`])\n if (b.y + b.h > 1 + 1e-9) out.push([\"extending past the bottom edge\", `${at}: extends past the bottom edge (y+h>1)`])\n if (b.score !== undefined && !(isNum(b.score) && b.score >= 0 && b.score <= 1)) out.push([\"with a score out of 0..1\", `${at}: score=${b.score} out of 0..1`])\n return out\n}\n\n/** Cap a findings list at `MAX_LISTED_FINDINGS`, ending in one line that counts\n * the rest. Never empties a non-empty list, so `ok` is unchanged. */\nfunction capListed(list: readonly string[], noun: \"issues\" | \"warnings\"): string[] {\n if (list.length <= MAX_LISTED_FINDINGS) return [...list]\n return [...list.slice(0, MAX_LISTED_FINDINGS), `${list.length - MAX_LISTED_FINDINGS} more ${noun} not listed`]\n}\n\n/** Is `ms` inside one of `spans` (sorted, half-open)? Binary search. */\nfunction inSpans(spans: readonly SpeakerTrackSpan[], ms: number): boolean {\n let lo = 0\n let hi = spans.length - 1\n while (lo <= hi) {\n const mid = (lo + hi) >> 1\n const sp = spans[mid]\n if (ms < sp.startMs) hi = mid - 1\n else if (ms >= sp.endMs) lo = mid + 1\n else return true\n }\n return false\n}\n\n/**\n * Structural validation of a track set (the box body). Normalization is\n * `normalizeSpeakerTracks`'s job; this reports what is still wrong after it.\n * Issues are facts intrinsic to the set (or to the set against the EDL);\n * warnings are judgements an older validator must not turn into a refusal\n * (an unknown attribution method, one stray speaker label).\n *\n * Rules: version; a positive sample rate; unique source ids that resolve to\n * the EDL's video sources; the source clock; a positive frame; sorted,\n * non-overlapping, positive, integer-ms spans; ascending integer cuts; unique\n * track ids; every box in-frame, at an integer ms, strictly after the previous\n * one and inside a sampled span; no track across a cut; the speaker name\n * space; the box and byte caps.\n *\n * The listing is bounded: per track, the first few boxes breaking each rule\n * are listed and the rest counted in one line; past a fixed total, one line\n * counts the issues (or warnings) not listed. `ok` counts every finding.\n */\nexport function validateSpeakerTracks(set: SpeakerTrackSet, opts: SpeakerTracksValidateOptions = {}): EdlValidation {\n const safe = isObj(set) ? set : ({} as SpeakerTrackSet)\n const f = validateCommon(safe, opts, (t, source, { issues }) => {\n const boxes = Array.isArray(t?.boxes) ? t.boxes : []\n const spans = Array.isArray(source.sampledSpans) ? source.sampledSpans : []\n let first = Infinity\n let last = -Infinity\n // The first few findings of each rule are listed; the rest are counted.\n const seen = new Map<string, number>()\n const report = ([rule, message]: BoxFinding) => {\n const n = (seen.get(rule) ?? 0) + 1\n seen.set(rule, n)\n if (n <= BOX_FINDINGS_PER_RULE) issues.push(message)\n }\n const outside = `outside every sampled span of source \"${source.sourceId}\"`\n boxes.forEach((b, j) => {\n const at = `track \"${t.id}\" box[${j}]`\n boxIssues(b, at).forEach(report)\n if (!isNum(b?.ms)) {\n report([\"whose ms is not a number\", `${at}: ms is not a number`])\n return\n }\n if (!Number.isInteger(b.ms)) report([\"whose ms is not an integer\", `${at}: ms ${b.ms} is not an integer`])\n const prev = boxes[j - 1]?.ms\n if (j > 0 && isNum(prev) && !(b.ms > prev)) report([\"not after the previous box\", `${at}: ms ${b.ms} is not after the previous box (${prev})`])\n if (!inSpans(spans, b.ms)) report([outside, `${at}: ms ${b.ms} is ${outside}`])\n first = Math.min(first, b.ms)\n last = Math.max(last, b.ms)\n })\n for (const [rule, n] of seen) {\n if (n > BOX_FINDINGS_PER_RULE) issues.push(`track \"${t.id}\": ${n - BOX_FINDINGS_PER_RULE} more boxes ${rule}`)\n }\n const cut = (Array.isArray(source.cuts) ? source.cuts : []).find((c) => first < c && c <= last)\n if (cut !== undefined) issues.push(`track \"${t.id}\": spans the cut at ${cut} ms (boxes ${first}..${last})`)\n return boxes.length\n })\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n const bytes = opts.serializedBytes ?? new TextEncoder().encode(JSON.stringify(safe)).length\n if (bytes > maxBytes) f.issues.push(`the track set is ${bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n\n/**\n * Structural validation of a descriptor (the node's output): the same rules as\n * `validateSpeakerTracks` minus the per-box ones (it has no boxes; `boxCount`\n * feeds the per-source cap), plus a non-empty `url`, a well-formed `sha256`\n * and a positive `bytes` within the byte cap.\n */\nexport function validateSpeakerTrackSetDescriptor(\n d: SpeakerTrackSetDescriptor,\n opts: Omit<SpeakerTracksValidateOptions, \"serializedBytes\"> = {},\n): EdlValidation {\n const safe = isObj(d) ? d : ({} as SpeakerTrackSetDescriptor)\n const f = validateCommon(safe, opts, (t, _source, { issues }) => {\n if (!(Number.isInteger(t?.boxCount) && t.boxCount >= 0)) {\n issues.push(`track \"${t?.id}\": boxCount must be a non-negative integer`)\n return 0\n }\n return t.boxCount\n })\n if (!(typeof safe.url === \"string\" && safe.url.trim())) f.issues.push(\"url is empty\")\n if (!(typeof safe.sha256 === \"string\" && SHA256_HEX.test(safe.sha256))) f.issues.push(\"sha256 must be 64 lowercase hex characters\")\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n if (!(Number.isInteger(safe.bytes) && safe.bytes > 0)) f.issues.push(\"bytes must be a positive integer\")\n else if (safe.bytes > maxBytes) f.issues.push(`the track set is ${safe.bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n","/**\n * camera-switch (podcast B5, decided 2026-10-03) — the structural pieces every\n * caller shares: the canvas engines, the editor, MCP and the SDK. WHO is on\n * screen is decided by the Cloud plugin; these only read the inputs it needs\n * and pre-fill the speaker table. Pure, no I/O.\n */\nimport { normalizeTranscript } from \"./edl.js\"\n\n/** The settings and their decided defaults (the plugin holds its own copy, D13). */\nexport const CAMERA_SWITCH_DEFAULTS = Object.freeze({\n /** The shortest shot; a shorter turn (an interjection) holds the shot. */\n minShotMs: 2_500,\n /** Cut this long before the new speaker starts. */\n leadMs: 200,\n /** With a `wide` camera: break to it after this long on one camera. */\n maxShotMs: 20_000,\n /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */\n wideEvery: 0,\n /** Overlapping speech → a side-by-side / stacked layout hint. */\n layoutHints: false,\n})\n\n/** The flat credit id and price (decided 2026-10-03). */\nexport const CAMERA_SWITCH_CREDIT_ID = \"camera-switch\"\n\nconst parseMaybe = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\n\n/** Distinct speaker labels of a transcript (an object or its JSON string), in\n * order of first appearance in time. Read through `normalizeTranscript`\n * (decided 2026-10-08) — the Cloud plugin's reading — so a broken word (no\n * usable time) names no speaker here either; a zero-width word is a point\n * and does. Empty → camera-switch refuses before charging. */\nexport function transcriptSpeakerLabels(transcript: unknown): string[] {\n const parsed = parseMaybe(transcript)\n if (!parsed || typeof parsed !== \"object\") return []\n const seen = new Set<string>()\n for (const w of normalizeTranscript(parsed).words) {\n if (w.speaker && !seen.has(w.speaker)) seen.add(w.speaker)\n }\n return [...seen]\n}\n\n/** The cameras a speaker can be given: an EDL's video sources in order,\n * without the `wide` / `screen` angles (those are not anyone's close-up). */\nexport function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: string }> {\n const sources = (parseMaybe(edl) as { sources?: unknown } | null | undefined)?.sources\n if (!Array.isArray(sources)) return []\n return sources\n .filter((s): s is { id: string; kind?: string; role?: string } => !!s && typeof (s as { id?: unknown }).id === \"string\")\n .filter((s) => s.kind !== \"audio\" && s.role !== \"wide\" && s.role !== \"screen\" && s.role !== \"master-audio\")\n .map((s) => ({ id: s.id, ...(s.role ? { role: s.role } : {}) }))\n}\n\n/** The settings' accepted ranges — exactly the Cloud route's (it answers 400\n * outside them), so every caller clamps to the same numbers before sending. */\nexport const CAMERA_SWITCH_BOUNDS = Object.freeze({\n minShotMs: Object.freeze({ min: 500, max: 60_000 }),\n leadMs: Object.freeze({ min: 0, max: 5_000 }),\n maxShotMs: Object.freeze({ min: 0, max: 600_000 }),\n wideEvery: Object.freeze({ min: 0, max: 20 }),\n})\n\n/** The longest display name a speaker can be given. */\nexport const CAMERA_SWITCH_NAME_MAX = 80\n\nexport type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS\n\n/** A setting as a whole number inside its range; undefined when unset. */\nexport function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const { min, max } = CAMERA_SWITCH_BOUNDS[key]\n return Math.min(max, Math.max(min, Math.round(value)))\n}\n\n/** Display names trimmed, empty ones dropped, each cut to\n * `CAMERA_SWITCH_NAME_MAX` characters. */\nexport function cleanSpeakerNames(raw: unknown): Record<string, string> {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return {}\n const out: Record<string, string> = {}\n for (const [label, name] of Object.entries(raw as Record<string, unknown>)) {\n const trimmed = typeof name === \"string\" ? name.trim() : \"\"\n if (label && trimmed) out[label] = trimmed.slice(0, CAMERA_SWITCH_NAME_MAX)\n }\n return out\n}\n\n/** Why camera-switch would refuse this edit (the route's 400 `invalid_edl`),\n * or null. One edit (an object or its JSON string) on the master clock, with\n * sources and at least one segment of numeric inMs < outMs; a clip SET is\n * refused — on the canvas each clip fans out to its own run. */\nexport function cameraSwitchEdlProblem(edl: unknown): string | null {\n const v = parseMaybe(edl) as Record<string, unknown> | null | undefined\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return \"camera-switch: `edl` must be one edit (an EDL object).\"\n if (Array.isArray(v.clips)) return \"camera-switch: `edl` is a clip set — pass one clip's EDL (a clip set fans out one run per clip on the canvas).\"\n if (!Array.isArray(v.sources) || !Array.isArray(v.segments)) return \"camera-switch: `edl` needs `sources` and `segments`.\"\n if (v.segments.length === 0) return \"camera-switch: `edl` has no segments.\"\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n for (const [i, row] of (v.segments as unknown[]).entries()) {\n const seg = row as { inMs?: unknown; outMs?: unknown } | null\n const inMs = num(seg?.inMs), outMs = num(seg?.outMs)\n if (inMs === undefined || outMs === undefined || !(outMs > inMs)) return `camera-switch: segment ${i} needs a numeric inMs < outMs.`\n }\n if (v.clock === \"output\") return \"camera-switch: the edit must be on the master clock (an edit-plan EDL), not a rendered output's.\"\n return null\n}\n\n/** The speaker table pre-filled by order (decided 2026-10-03): speaker 1 →\n * camera 1, speaker 2 → camera 2 … A speaker past the last camera stays\n * unmapped (the wide shows them, else any camera with picture). `existing`\n * entries are kept as the person set them — an explicit `\"\"` means \"no\n * camera of their own\" and is SENT as `\"\"`, so it also beats a source whose\n * `speakers` list names them. */\nexport function defaultSpeakerMap(\n labels: readonly string[],\n cameraIds: readonly string[],\n existing: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n const out: Record<string, string> = {}\n labels.forEach((label, i) => {\n if (Object.prototype.hasOwnProperty.call(existing, label)) {\n const kept = existing[label]\n if (typeof kept === \"string\") out[label] = kept\n return\n }\n if (i < cameraIds.length) out[label] = cameraIds[i]!\n })\n return out\n}\n\n/** What a Camera Switch node sends besides its two inputs — ONE funnel for the\n * canvas executor and the orchestrator, so both send the same clamped\n * settings and the same pre-filled speaker table. */\nexport interface CameraSwitchNodeSettings {\n readonly speakerMap?: Readonly<Record<string, string>>\n readonly speakerNames?: Readonly<Record<string, string>>\n readonly minShotMs?: number\n readonly leadMs?: number\n readonly maxShotMs?: number\n readonly wideEvery?: number\n readonly layoutHints?: boolean\n}\nexport function cameraSwitchSettingsPayload(\n data: CameraSwitchNodeSettings,\n edl: unknown,\n transcript: unknown,\n): {\n speakerMap: Record<string, string>\n speakerNames: Record<string, string>\n minShotMs?: number\n leadMs?: number\n maxShotMs?: number\n wideEvery?: number\n layoutHints: boolean\n} {\n const existing = data.speakerMap && typeof data.speakerMap === \"object\" ? data.speakerMap : {}\n const out: ReturnType<typeof cameraSwitchSettingsPayload> = {\n speakerMap: defaultSpeakerMap(transcriptSpeakerLabels(transcript), cameraSwitchCameras(edl).map((c) => c.id), existing),\n speakerNames: cleanSpeakerNames(data.speakerNames),\n layoutHints: data.layoutHints === true,\n }\n for (const key of Object.keys(CAMERA_SWITCH_BOUNDS) as CameraSwitchNumericSetting[]) {\n const v = clampCameraSwitchSetting(key, data[key])\n if (v !== undefined) out[key] = v\n }\n return out\n}\n","/**\n * The edit-plan node's credit-id scheme and output unwrap — split out of\n * `edl.ts` (which keeps the EDL shape itself) so that module stays within the\n * file-size cap. Re-exported from the package index, so importers of\n * `@nodaro/shared` are unaffected.\n */\nimport { EDL_VERSION } from \"./edl.js\"\n\n// ─────────────────────────────────────────────────────────────────────────\n// edit-plan credit-id scheme (STRUCTURE only — the per-mode/tier/bucket credit\n// VALUES live app-side in backend/ee/billing/credits.ts + migration 432, since\n// they are probe-set placeholders and the DB row wins at runtime). Lives HERE\n// so BOTH core payload-builder and ee credits.ts read one id builder — core\n// may not import ee (check-ee-imports), the same reason buildVideoAnalysisCreditId\n// is shared. Mirrors the plugin's own (D13-local) pricing.ts scheme.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** `trailer` (Track D1): one short teaser EDL built from the strongest moments,\n * priced like `clips` (the per-minute rate plus the clips flat). */\nexport type EditPlanMode = \"tighten\" | \"clips\" | \"chapters\" | \"trailer\"\nexport type EditPlanTier = \"economy\" | \"standard\" | \"premium\"\nexport const EDIT_PLAN_MODES: readonly EditPlanMode[] = [\"tighten\", \"clips\", \"chapters\", \"trailer\"]\nexport const EDIT_PLAN_TIERS: readonly EditPlanTier[] = [\"economy\", \"standard\", \"premium\"]\n/** The coarse duration ladder (MINUTES) a probed source duration rounds UP to;\n * the composite credit id carries the bucket. 4 modes × 3 tiers × 6 buckets =\n * 72 composites (+ the bare `edit-plan`). */\nexport const EDIT_PLAN_BUCKET_MINUTES: readonly number[] = [15, 30, 60, 90, 120, 180]\n/** Hard duration cap (design §7.4). */\nexport const EDIT_PLAN_MAX_MINUTES = 180\n/** `clips` mode: how many clips a plan returns when the caller names no count,\n * and the most it may be asked for. One source for the credit estimate, the\n * orchestrated payload clamp and the request schema. */\nexport const EDIT_PLAN_DEFAULT_CLIP_COUNT = 8\nexport const EDIT_PLAN_MAX_CLIP_COUNT = 50\n\n/** Clamp a requested clip count into `[1, EDIT_PLAN_MAX_CLIP_COUNT]`; `undefined`\n * for anything that is not a positive number (the planner then uses its default). */\nexport function clampEditPlanClipCount(count: unknown): number | undefined {\n if (typeof count !== \"number\" || !Number.isFinite(count) || count <= 0) return undefined\n return Math.min(EDIT_PLAN_MAX_CLIP_COUNT, Math.max(1, Math.floor(count)))\n}\n/** The bare estimator / DB-down fallback id. */\nexport const EDIT_PLAN_BASE_CREDIT_ID = \"edit-plan\"\n\n/** Round a source duration (seconds) UP to the smallest covering ladder bucket\n * (capped at the max), in minutes. `undefined` / non-finite → the ceiling\n * bucket (the safe over-reserve direction). */\nexport function editPlanBucketMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n const mins = Math.max(1, Math.ceil(secs / 60))\n const capped = Math.min(mins, EDIT_PLAN_MAX_MINUTES)\n for (const b of EDIT_PLAN_BUCKET_MINUTES) if (capped <= b) return b\n return EDIT_PLAN_BUCKET_MINUTES[EDIT_PLAN_BUCKET_MINUTES.length - 1]!\n}\n\n/** `edit-plan:<mode>:<tier>:<bucket>m`. `durationSec` undefined → the ceiling\n * bucket. Single source of truth for the composite id shape. */\nexport function buildEditPlanCreditId(mode: EditPlanMode, tier: EditPlanTier, durationSec?: number): string {\n return editPlanMinutesCreditId(mode, tier, editPlanBucketMinutes(durationSec))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Per started minute (decided 2026-10-07). A plugin that declares\n// `supports().editPlanPerMinute` reserves `edit-plan:<mode>:<tier>:<N>m` with\n// N = the started minutes of the source (1..180), priced flat + rate × N from\n// ONE rate row and ONE flat row per mode × tier. The step ids above have the\n// same shape (N = a step), so one parser reads both, and the plugin's money\n// gate (`:(\\d+)m$`) accepts both.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Started minutes of a source (seconds): ceil(sec / 60), at least 1, capped at\n * the maximum. `undefined` / non-finite → the maximum (over-reserve direction). */\nexport function editPlanStartedMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n return Math.min(EDIT_PLAN_MAX_MINUTES, Math.max(1, Math.ceil(secs / 60)))\n}\n\n/** `edit-plan:<mode>:<tier>:<N>m` for N minutes (a started-minute count or a step). */\nexport function editPlanMinutesCreditId(mode: EditPlanMode, tier: EditPlanTier, minutes: number): string {\n return `edit-plan:${mode}:${tier}:${minutes}m`\n}\n\n/** The id a run of this mode/tier on a source of `durationSec` reserves: per\n * started minute when the plugin charges that way (`perMinute`), else the step\n * the length rounds up to. An unknown length → the 180-minute maximum either way. */\nexport function editPlanReserveCreditId(\n mode: EditPlanMode,\n tier: EditPlanTier,\n durationSec: number | undefined,\n perMinute: boolean,\n): string {\n return perMinute\n ? editPlanMinutesCreditId(mode, tier, editPlanStartedMinutes(durationSec))\n : buildEditPlanCreditId(mode, tier, durationSec)\n}\n\n/** The rate row: credits per started source minute for a mode/tier. Never reserved. */\nexport function editPlanRateCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:per-minute`\n}\n\n/** The flat row: credits once per plan for a mode/tier (0 for tighten and chapters). Never reserved. */\nexport function editPlanFlatCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:flat`\n}\n\n/** The mode, tier and minutes of an `edit-plan:<mode>:<tier>:<N>m` id (1 ≤ N ≤\n * the maximum), or `undefined` for anything else (the bare id, a rate or flat\n * row, an unknown mode or tier). */\nexport function parseEditPlanMinutesCreditId(\n id: string,\n): { mode: EditPlanMode; tier: EditPlanTier; minutes: number } | undefined {\n const m = /^edit-plan:([a-z]+):([a-z]+):(\\d+)m$/.exec(id)\n if (!m) return undefined\n const mode = parseEditPlanMode(m[1])\n const tier = (EDIT_PLAN_TIERS as readonly string[]).includes(m[2]!) ? (m[2] as EditPlanTier) : undefined\n const minutes = Number(m[3])\n if (!mode || !tier || !Number.isInteger(minutes) || minutes < 1 || minutes > EDIT_PLAN_MAX_MINUTES) return undefined\n return { mode, tier, minutes }\n}\n\n/** flat + rate × N, rounded up, at least 1 credit — what an\n * `edit-plan:<mode>:<tier>:<N>m` id costs from its two rows (the plugin's formula). */\nexport function editPlanMinutesBaseCredits(flat: number, rate: number, minutes: number): number {\n return Math.max(1, Math.ceil(flat + rate * minutes))\n}\n\n/** Narrow an arbitrary value to a known edit-plan mode, defaulting to \"tighten\".\n * For display and estimates only: anything that DISPATCHES a plan must use\n * {@link parseEditPlanMode} and refuse an unknown mode, or that mode is planned\n * (and charged) as tighten. */\nexport function asEditPlanMode(v: unknown): EditPlanMode {\n return parseEditPlanMode(v) ?? \"tighten\"\n}\n\n/** The strict sibling of {@link asEditPlanMode}: the mode when `v` is exactly a\n * known edit-plan mode, otherwise `undefined` — never a substitute. */\nexport function parseEditPlanMode(v: unknown): EditPlanMode | undefined {\n return typeof v === \"string\" && (EDIT_PLAN_MODES as readonly string[]).includes(v) ? (v as EditPlanMode) : undefined\n}\n\n/** Narrow an arbitrary value to a known edit-plan tier, defaulting to \"standard\". */\nexport function asEditPlanTier(v: unknown): EditPlanTier {\n return v === \"economy\" || v === \"premium\" ? v : \"standard\"\n}\n\n/**\n * Unwrap an `edit-plan` job's `output_data` into the value stored on the node's\n * `data.generatedJson`, which every output extractor then reads. This is the ONE\n * place the modes are normalized (the same rule on both engines and every\n * result-application site, so audit-dag parity can't drift):\n * - `clips` → the BARE `Edl[]` (T5: the `list` fan-out reads `Array.isArray`\n * on `generatedJson`; each element becomes one JSON-stringified\n * item a downstream `edl` input `normalizeEdl`-parses).\n * - `chapters` → the `{ version, chapters }` object.\n * - `tighten` / `trailer` → the `Edl` object at top level.\n *\n * The cloud relay object-spreads `output_data` and adds `viaNodaroCloud: true`;\n * that key (and any other bookkeeping) is stripped here. The unwrap lives HERE —\n * NEVER in `output_data` — because a bare array written into `output_data` would\n * be corrupted into numeric keys by the relay's object-spread (see `EdlClipSet`).\n */\nexport function unwrapEditPlanOutput(outputData: unknown): unknown {\n if (!outputData || typeof outputData !== \"object\") return outputData\n const o = outputData as Record<string, unknown>\n // clips: EdlClipSet { version, clips: Edl[] } → the bare Edl[].\n if (Array.isArray(o.clips)) return o.clips\n // chapters: { version, chapters: [...] } → the object, minus bookkeeping.\n if (Array.isArray(o.chapters)) return { version: EDL_VERSION, chapters: o.chapters }\n // tighten / trailer: the Edl object at top level → drop the relay's viaNodaroCloud.\n const { viaNodaroCloud: _viaNodaroCloud, ...rest } = o\n return rest\n}\n"]}
|
package/dist/chunk-TU33KYKW.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkM7GQBRZU_cjs = require('./chunk-M7GQBRZU.cjs');
|
|
4
|
-
var chunkK3LLGRK7_cjs = require('./chunk-K3LLGRK7.cjs');
|
|
5
|
-
|
|
6
|
-
// src/video-ui-defaults.ts
|
|
7
|
-
function uiAspectRatioFill(provider) {
|
|
8
|
-
return chunkM7GQBRZU_cjs.isSeedance2Provider(provider) || chunkM7GQBRZU_cjs.isMinimaxH3Provider(provider) || chunkM7GQBRZU_cjs.isWan3Provider(provider) ? "adaptive" : void 0;
|
|
9
|
-
}
|
|
10
|
-
function uiResolutionFill(provider) {
|
|
11
|
-
if (chunkM7GQBRZU_cjs.isWan3Provider(provider)) return chunkM7GQBRZU_cjs.PRICING_DEFAULT_RESOLUTION[provider];
|
|
12
|
-
if (chunkM7GQBRZU_cjs.isSeedance2Provider(provider)) return chunkK3LLGRK7_cjs.MODEL_CATALOG[provider]?.resolutions?.[0];
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
function uiDurationFill(provider) {
|
|
16
|
-
if (chunkM7GQBRZU_cjs.isWan3Provider(provider)) return 5;
|
|
17
|
-
if (chunkM7GQBRZU_cjs.isGeminiOmniProvider(provider)) return 8;
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.uiAspectRatioFill = uiAspectRatioFill;
|
|
22
|
-
exports.uiDurationFill = uiDurationFill;
|
|
23
|
-
exports.uiResolutionFill = uiResolutionFill;
|
|
24
|
-
//# sourceMappingURL=chunk-TU33KYKW.cjs.map
|
|
25
|
-
//# sourceMappingURL=chunk-TU33KYKW.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/video-ui-defaults.ts"],"names":["isSeedance2Provider","isMinimaxH3Provider","isWan3Provider","PRICING_DEFAULT_RESOLUTION","MODEL_CATALOG","isGeminiOmniProvider"],"mappings":";;;;;;AAuCO,SAAS,kBAAkB,QAAA,EAAsC;AACtE,EAAA,OAAOA,qCAAA,CAAoB,QAAQ,CAAA,IAAKC,qCAAA,CAAoB,QAAQ,CAAA,IAAKC,gCAAA,CAAe,QAAQ,CAAA,GAC5F,UAAA,GACA,MAAA;AACN;AAIO,SAAS,iBAAiB,QAAA,EAAsC;AACrE,EAAA,IAAIA,gCAAA,CAAe,QAAQ,CAAA,EAAG,OAAOC,6CAA2B,QAAQ,CAAA;AACxE,EAAA,IAAIH,qCAAA,CAAoB,QAAQ,CAAA,EAAG,OAAOI,gCAAc,QAAQ,CAAA,EAAG,cAAc,CAAC,CAAA;AAClF,EAAA,OAAO,MAAA;AACT;AAUO,SAAS,eAAe,QAAA,EAAsC;AACnE,EAAA,IAAIF,gCAAA,CAAe,QAAQ,CAAA,EAAG,OAAO,CAAA;AACrC,EAAA,IAAIG,sCAAA,CAAqB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT","file":"chunk-TU33KYKW.cjs","sourcesContent":["/**\n * UI-default fills for the unified video nodes — the ONE source of truth shared\n * by the backend DAG payload builder, the config-panel fail-safe snaps and the\n * node's hover/run strip.\n *\n * Several config panels RENDER a default without persisting it to node data, so\n * an untouched node submits `aspectRatio` / `resolution` undefined and the\n * enqueued job row (and the /v1/jobs echo) then disagrees with what actually\n * renders. Worse, the panels' generic snap writes `resolutions[0]` for a stale\n * value, which is the CHEAPEST tier under the repo's ascending-resolution\n * convention — not necessarily the tier the model renders and bills.\n *\n * These helpers were local to `backend/src/services/workflow-engine/payload-builder.ts`\n * until the Wan 3.0 launch gave the platform its first provider whose declared\n * billing default differs from `resolutions[0]`; three surfaces then had to\n * agree, so they live here.\n *\n * The resolution fill is per-family ON PURPOSE. Wan 3.0 reads its DECLARED\n * billing default (PRICING_DEFAULT_RESOLUTION = 720p) because its catalog list\n * is ascending, so an index-0 fill would write 480p — a tier both `runWan3`\n * (which renders 720P) and the credit identifier (which bills the 720p row)\n * disagree with. The Seedance family keeps its historical first-catalog-tier\n * fill, deliberately: switching it to PRICING_DEFAULT_RESOLUTION would reprice\n * live seedance-2-5 runs, whose declared default (720p) differs from the 480p\n * this has always filled. That 480p-fill vs 720p-billing-default divergence on\n * seedance-2-5 is a KNOWN pre-existing gap, out of scope here — do not \"align\"\n * the branches without repricing it deliberately.\n */\n\nimport {\n PRICING_DEFAULT_RESOLUTION,\n isSeedance2Provider,\n isMinimaxH3Provider,\n isWan3Provider,\n isGeminiOmniProvider,\n} from \"./model-constants.js\"\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/** `adaptive` is the aspect default for Seedance 2, MiniMax H3 and Wan 3.0. */\nexport function uiAspectRatioFill(provider: string): string | undefined {\n return isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider)\n ? \"adaptive\"\n : undefined\n}\n\n/** See the file docstring — per-family on purpose; never a generic\n * PRICING_DEFAULT_RESOLUTION read (that would reprice seedance-2-5). */\nexport function uiResolutionFill(provider: string): string | undefined {\n if (isWan3Provider(provider)) return PRICING_DEFAULT_RESOLUTION[provider]\n if (isSeedance2Provider(provider)) return MODEL_CATALOG[provider]?.resolutions?.[0]\n return undefined\n}\n\n/**\n * Duration the node RENDERS and BILLS when `data.duration` is unset, for the\n * families whose credit identifier declares a duration fallback that is NOT\n * `durations[0]`. Wan 3.0's bare identifier is the 5s tier while its ladder\n * starts at 2s; the Gemini Omni family's is the 8s tier while its ladder starts\n * at 4s. Everyone else falls back to the first listed duration, so this returns\n * undefined and the caller keeps `durations[0]`.\n */\nexport function uiDurationFill(provider: string): number | undefined {\n if (isWan3Provider(provider)) return 5\n if (isGeminiOmniProvider(provider)) return 8\n return undefined\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/credit-identifiers.ts"],"names":["FLUX2_RES_MP","defaultResolutionFor","isFlux2Model","HIGH_QUALITY_PROVIDERS","TWO_K_RESOLUTION_PROVIDERS","RESOLUTION_2K_4K_TIERED_PROVIDERS","IDEOGRAM_PROVIDERS","T2I_TO_I2I_VARIANT","autoAspectNeedsSourceImage","normalizeModelInput","snapToNearestDuration","pricedOutputDurationSec","DURATION_PRICED_PROVIDERS","isVeoProvider","VEO_RESOLUTION_TIERED_PROVIDERS","isGeminiOmniProvider","VIDEO_DURATION_TIERS","getVideoAudioCapability","AUDIO_ADDON_PROVIDERS","MODE_ADDON_PROVIDERS","RESOLUTION_VIDEO_REF_PRICING","MODEL_CATALOG","PRICING_DEFAULT_RESOLUTION","RESOLUTION_DURATION_PRICING","isWan3Provider","normalizeWan3Resolution","isMinimaxH3Provider","normalizeMinimaxH3Resolution","normalizeVideoRequestParams","uiResolutionFill","VIDEO_DURATION_AUTO","MOTION_DURATION_TIERS"],"mappings":";;;;;;;AA4DA,SAAS,kBAAA,CAAmB,OAAmB,UAAA,EAA6B;AAC1E,EAAA,MAAM,IAAA,GAAO,CAAC,CAAA,KAAc,CAAA,CAAE,QAAQ,SAAA,EAAW,EAAE,EAAE,IAAA,EAAK;AAC1D,EAAA,MAAM,MAAM,OAAO,UAAA,KAAe,QAAA,GAAW,IAAA,CAAK,UAAU,CAAA,GAAI,EAAA;AAChE,EAAA,IAAI,GAAA,KAAQ,IAAI,OAAO,GAAA;AAIvB,EAAA,MAAM,IAAA,GAAOA,8BAAA,CAAa,IAAA,CAAK,CAAC,CAAA,KAAM,OAAO,CAAC,CAAA,KAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAC/D,EAAA,OAAO,IAAA,IAAQ,IAAA,CAAKC,sCAAA,CAAqB,KAAK,KAAK,MAAM,CAAA;AAC3D;AAWO,SAAS,2BACd,QAAA,EACA,OAAA,EACA,UAAA,EACA,cAAA,EACA,kBACA,mBAAA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sB,YAAA;AACtD;AAUO,SAAS,iBAAiB,OAAA,EAAmD;AAClF,EAAA,OAAO,OAAA,KAAY,UAAU,iBAAA,GAAoB,WAAA;AACnD;AASO,IAAM,wBAAA,GAA2B,CAAC,UAAA,EAAY,SAAS;AAMvD,IAAM,uBAAA,GAA0D,OAAO,MAAA,CAAO;AAAA,EACnF,cAAA;AAAA,EACA,oBAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF,CAAU;AAYH,SAAS,mBAAA,CAAoB,SAAkB,IAAA,EAAqC;AACzF,EAAA,MAAM,QAAQ,OAAA,KAAY,OAAA;AAC1B,EAAA,IAAI,IAAA,KAAS,UAAA,EAAY,OAAO,KAAA,GAAQ,oBAAA,GAAuB,cAAA;AAC/D,EAAA,OAAO,QAAQ,4BAAA,GAA+B,sBAAA;AAChD;AAkBO,SAAS,cAAA,CAAe,OAA2B,SAAA,EAA2B;AACnF,EAAA,IAAI,CAAE,8BAAA,CAAqD,QAAA,CAAS,SAAS,CAAA,EAAG;AAC9E,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAQ,KAAA,IAAS,wBAAA,CAAyB,KAAK,CAAA,IAAM,SAAA;AACvD;AAUO,IAAM,wBAAA,GAA6D;AAAA,EACxE,EAAA,EAAI,SAAA;AAAA,EACJ,OAAA,EAAS,cAAA;AAAA,EACT,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM,WAAA;AAAA,EACN,EAAA,EAAI;AACN","file":"chunk-VA42637J.cjs","sourcesContent":["/**\n * Build composite credit model identifiers for variable pricing.\n * Shared between frontend and backend.\n */\n\nimport {\n HIGH_QUALITY_PROVIDERS,\n TWO_K_RESOLUTION_PROVIDERS,\n RESOLUTION_2K_4K_TIERED_PROVIDERS,\n IDEOGRAM_PROVIDERS,\n DURATION_PRICED_PROVIDERS,\n AUDIO_ADDON_PROVIDERS,\n MODE_ADDON_PROVIDERS,\n RESOLUTION_VIDEO_REF_PRICING,\n RESOLUTION_DURATION_PRICING,\n VEO_RESOLUTION_TIERED_PROVIDERS,\n VIDEO_DURATION_TIERS,\n pricedOutputDurationSec,\n snapToNearestDuration,\n PRICING_DEFAULT_RESOLUTION,\n MOTION_DURATION_TIERS,\n T2I_TO_I2I_VARIANT,\n isVeoProvider,\n isMinimaxH3Provider,\n isGeminiOmniProvider,\n isWan3Provider,\n normalizeMinimaxH3Resolution,\n normalizeWan3Resolution,\n getVideoAudioCapability,\n} from \"./model-constants.js\"\nimport { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from \"./flux2-pricing.js\"\nimport { VIDEO_DURATION_AUTO } from \"./video-duration-auto.js\"\nimport { uiResolutionFill } from \"./video-ui-defaults.js\"\nimport { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from \"./model-catalog.js\"\n\n/**\n * The megapixel tier a Flux 2 credit identifier is keyed on, for ANY incoming\n * `resolution` value.\n *\n * Flux 2 is the only family whose identifier INTERPOLATES the resolution\n * instead of matching it against a known set, and its callers are not\n * guaranteed to hand it a Flux 2 value:\n * - the multi-provider cost preview prices one node's data against EVERY\n * selected provider (`frontend/src/ee/hooks/use-providers-credits-sum.ts`),\n * so a node whose `resolution` is \"2K\" (the flux / nano-banana-pro value\n * space) reaches this branch verbatim;\n * - node data written straight into workflow JSON by an agent, an import or\n * a template never ran the config panel's provider-change fail-safe.\n * Interpolating that produced the off-grid id `flux-2-pro:2KMP:0ref`, which no\n * pricing row can answer — every cost badge 503'd `price_not_configured`\n * (18 production app-reports, 2026-09-07..14).\n *\n * A value off the grid snaps to the model's DEFAULT tier — the same `preferred`\n * value `normalizeModelInput` uses — so the preview asks for exactly the id the\n * route will reserve (both routes and the orchestrator normalize through\n * `resolveNormalizedImageGen` first, which makes this snap a no-op for them).\n * An ABSENT resolution keeps its long-standing meaning (\"this caller has no\n * resolution dimension at all\") and stays on 1 MP rather than moving to the\n * model default, which would silently re-price every resolution-less node.\n */\nfunction flux2MegapixelTier(model: Flux2Model, resolution?: string): string {\n const bare = (v: string) => v.replace(/\\s*MP$/i, \"\").trim()\n const raw = typeof resolution === \"string\" ? bare(resolution) : \"\"\n if (raw === \"\") return \"1\"\n // Numeric match so \"2.0\"/\" 2 MP\" land on the same grid point as \"2\", and the\n // GRID's own spelling is what gets emitted — returning the caller's \"2.0\"\n // would build \":2.0MP:\", another id no pricing row carries.\n const tier = FLUX2_RES_MP.find((t) => Number(t) === Number(raw))\n return tier ?? bare(defaultResolutionFor(model) ?? \"1 MP\")\n}\n\n/**\n * Compute composite model identifier for variable credit pricing.\n * Examples: \"gpt-image:high\", \"flux:2K\", \"nano-banana-pro:4K\", \"ideogram:TURBO\",\n * \"flux-2-pro:2MP\", \"flux-2-max:2MP:1ref\" (Flux 2 — billed per megapixel).\n *\n * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output\n * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.\n * For video models, uses duration/sound params when the model has variable pricing.\n */\nexport function buildCreditModelIdentifier(\n provider: string,\n quality?: string,\n resolution?: string,\n renderingSpeed?: string,\n targetResolution?: string,\n referenceImageCount?: number,\n): string {\n // Flux 2 family: billed per output megapixel AND per reference image (each\n // ref counts as input megapixels). Resolution arrives as \"N MP\" strings (the\n // UI value space); strip the unit. ALL three models encode the ref count\n // (capped at 8): Pro/Klein i2i always carry the source image as a ref and\n // their cost formula charges per input MP, so the reserved identifier must\n // reflect refs (there is no metered true-up to correct an under-reserved tier).\n if (isFlux2Model(provider)) {\n return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`\n }\n if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === \"high\") {\n return `${provider}:high`\n }\n if (TWO_K_RESOLUTION_PROVIDERS.has(provider) && resolution === \"2K\") {\n return `${provider}:2K`\n }\n if (provider === \"nano-banana-pro\" && resolution === \"4K\") {\n return `${provider}:4K`\n }\n if (RESOLUTION_2K_4K_TIERED_PROVIDERS.has(provider) && (resolution === \"2K\" || resolution === \"4K\")) {\n return `${provider}:${resolution}`\n }\n // Topaz Image Upscale: 2K is default (no suffix), 4K/8K get composite identifiers\n if (provider === \"topaz-image-upscale\" && targetResolution && targetResolution !== \"2K\") {\n return `${provider}:${targetResolution}`\n }\n if (IDEOGRAM_PROVIDERS.has(provider)) {\n if (renderingSpeed === \"TURBO\") return `${provider}:TURBO`\n if (renderingSpeed === \"QUALITY\") return `${provider}:QUALITY`\n }\n return provider\n}\n\n/**\n * An image request's catalog-snapped parameters PLUS the credit identifier\n * priced off them.\n *\n * `adjustments` is the disclosure channel: every lever this changed, why, and\n * to what. Routes return it in the 200 body so a caller learns their value was\n * corrected instead of silently getting something else.\n */\nexport interface NormalizedImageGen {\n /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */\n identifier: string\n /** The catalog model id the params were snapped against (post T2I→I2I swap). */\n modelId: string\n aspectRatio?: string\n resolution?: string\n quality?: string\n /** Empty when the caller's values were already valid for `modelId`. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The catalog model `resolveNormalizedImageGen` snaps against: the provider\n * (Nano Banana when none is named), or — with `swapToI2i` and references\n * attached — its i2i sibling, the model the generate-image route and the\n * workflow payload builder then send. That sibling has its OWN catalog entry\n * and lever lists. Exported so a caller that has to decide something about\n * those lists before the snap (whether a photo's size is worth reading) asks\n * about the same model the snap will use.\n */\nexport function normalizedImageGenModelId(opts: {\n provider: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n const provider = typeof opts.provider === \"string\" && opts.provider.length > 0 ? opts.provider : \"nano-banana\"\n return opts.swapToI2i && opts.refCount > 0 ? (T2I_TO_I2I_VARIANT[provider] ?? provider) : provider\n}\n\n/**\n * Whether \"auto\" on a Generate Image request can need its photo's size: the\n * model the snap runs against (`normalizedImageGenModelId` with the swap on)\n * has no native auto. Given the ASSEMBLED reference count, it asks about exactly\n * that model; without one — a write boundary, or a run before its references\n * assemble — about both the provider and its i2i sibling, since references may\n * yet attach.\n */\nexport function imageGenAutoAspectNeedsSourceImage(opts: {\n provider: unknown\n aspectRatio: unknown\n refCount?: number\n}): boolean {\n const asks = (refCount: number) =>\n autoAspectNeedsSourceImage(normalizedImageGenModelId({ provider: opts.provider, refCount, swapToI2i: true }), opts.aspectRatio)\n return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)\n}\n\n/**\n * Snap an image request's catalog-governed levers to a combination the model\n * actually accepts, and price the credit identifier off the SNAPPED values.\n *\n * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute\n * their credit identifier TWICE — once in the `creditGuard` preHandler (the\n * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a\n * dedicated test asserts the two stay byte-identical (see\n * `backend/src/routes/__tests__/generate-image.test.ts`, \"CHECK === DEBIT\").\n * `resolution` and `quality` are pricing dimensions, so a snap applied at only\n * one of those sites breaks that invariant, and `commit_credits` never collects\n * an upward delta — the reserve IS the charge. Putting the snap inside the\n * primitive makes CHECK, DEBIT and the workflow orchestrator agree by\n * construction rather than by everyone remembering to call a normalizer.\n *\n * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a\n * caller can put a number or an object in `resolution`. Non-strings become\n * `undefined` rather than reaching `normalizeModelInput` as a lie.\n *\n * Unknown model ids pass through untouched (same contract as\n * `normalizeModelInput`) — the route's provider enum is the gate for those.\n *\n * `sourceImage` is the size of the photo the request transforms or is drawn\n * from (an image-to-image / edit source, or Generate Image's first wired\n * reference). It only decides \"auto\" on a model without a native auto, and the\n * ratio is not a pricing dimension on any such model (pinned across the catalog\n * by `auto-aspect-source.test.ts`), so a CHECK that runs before the size is\n * known prices the same identifier as the DEBIT that knows it.\n */\nexport function resolveNormalizedImageGen(opts: {\n provider: string | undefined\n aspectRatio?: unknown\n quality?: unknown\n resolution?: unknown\n renderingSpeed?: unknown\n refCount: number\n swapToI2i?: boolean\n sourceImage?: SourceImageSize\n}): NormalizedImageGen {\n const str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v.length > 0 ? v : undefined\n\n const modelId = normalizedImageGenModelId(opts)\n\n const n = normalizeModelInput(\n modelId,\n {\n aspectRatio: str(opts.aspectRatio),\n resolution: str(opts.resolution),\n quality: str(opts.quality),\n },\n { sourceImage: opts.sourceImage },\n )\n\n return {\n identifier: buildCreditModelIdentifier(\n modelId,\n n.quality,\n n.resolution,\n str(opts.renderingSpeed),\n undefined,\n opts.refCount,\n ),\n modelId,\n aspectRatio: n.aspectRatio,\n resolution: n.resolution,\n quality: n.quality,\n adjustments: n.adjustments,\n }\n}\n\n/**\n * Reference-aware image-generation credit identifier — the SINGLE source of\n * truth shared by the single-node routes (`/v1/generate-image`,\n * `/v1/image-to-image`) and the workflow orchestrator\n * (`payload-builder.ts`). It centralises the two pricing dimensions that must\n * match across both paths or a Flux 2 generation is billed the wrong tier\n * (Flux 2 commits non-metered / has no upward true-up, so the reserved\n * identifier IS the final charge):\n * - `refCount`: the number of reference images sent to the provider (Flux 2\n * bills per ref). generate-image passes the assembled count (0 for pure\n * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.\n * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i\n * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id\n * matches the variant actually invoked. image-to-image is already an i2i\n * provider → pass `false`.\n *\n * The LoRA short-circuit (`flux-lora-character`) stays at the call site because\n * the routing decision needs a DB lookup the routes/orchestrator own.\n */\nexport function resolveImageGenCreditIdentifier(opts: {\n provider: string | undefined\n quality?: string\n resolution?: string\n renderingSpeed?: string\n refCount: number\n swapToI2i?: boolean\n}): string {\n return resolveNormalizedImageGen(opts).identifier\n}\n\n// T2V-specific credit overrides: some providers have different costs for T2V\n// vs I2V/V2V due to different default resolutions or colliding with image model names.\nconst T2V_CREDIT_OVERRIDES: Record<string, string> = {\n \"grok\": \"grok-i2v\", // T2V grok, same as I2V grok (not image grok = 4 cr)\n \"wan\": \"wan-t2v\", // T2V wan 1080p = (V2V wan 720p = 70 cr)\n \"wan-turbo\": \"wan-turbo-t2v\", // T2V wan-turbo 720p = (I2V wan-turbo 480p = 40 cr)\n}\n\n/**\n * Compute composite model identifier for video models with duration/audio-based pricing.\n * Examples: \"kling-3.0:5s\", \"kling-3.0:10s:audio\", \"seedance-2:8s:720p-ref\"\n *\n * @param provider - Video model key (e.g., \"kling-3.0\")\n * @param duration - Video duration in seconds\n * @param sound - Whether audio/sound is enabled\n * @param nodeType - Node type for T2V-specific cost overrides\n * @param mode - Quality variant that affects pricing\n * @param resolution - Output resolution (used by Seedance 2 for 480p/720p pricing)\n * @param hasVideoRef - Whether a reference video is connected (Seedance 2 uses a lower per-second rate when true)\n */\n/**\n * LTX 2.3 (Lightricks via Replicate) credit tiers: priced by\n * (resolution-band × duration-seconds). Keys mirror STATIC_CREDIT_COSTS /\n * model_pricing EXACTLY (lowercase band + raw seconds + \"s\"), e.g.\n * \"ltx-2.3-pro:1080p:6s\". This map is the source of truth for the nearest-tier\n * snap below, so an off-catalog (resolution, duration) from a direct API/SDK\n * call maps to a SEEDED price instead of hard-failing (price_not_configured\n * 503). Pro: 6/8/10s at every band. Fast: up to 20s at 1080p, 6/8/10s at 2k/4k.\n */\nconst LTX_DURATION_TIERS: Record<string, Record<string, number[]>> = {\n \"ltx-2.3-pro\": { \"1080p\": [6, 8, 10], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n \"ltx-2.3-fast\": { \"1080p\": [6, 8, 10, 12, 14, 16, 18, 20], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n}\n\n/**\n * The (band, duration) tier the LTX pricing ladder charges for a request, or\n * `undefined` for a non-LTX provider. Extracted so\n * `buildVideoCreditModelIdentifier` and `pricedVideoSelection` read the ladder\n * ONCE — the routes must send the tier they reserved, and a second copy of this\n * math is exactly how the two drift apart.\n *\n * An unknown/absent band falls back to 1080p (LTX's own default, and the band\n * `snapLtxInput` snaps to at the Replicate call), and an off-tier duration\n * snaps to the NEAREST seeded one so the emitted composite always prices.\n */\nfunction ltxPricedTier(\n provider: string,\n resolution?: string,\n duration?: number | string,\n): { band: string; duration: number } | undefined {\n const bands = LTX_DURATION_TIERS[provider]\n if (!bands) return undefined\n const band = bands[String(resolution)] ? String(resolution) : \"1080p\"\n const allowed = bands[band]!\n // The model's own default (catalog `defaultDuration`) when unset, then the\n // nearest rung of THIS band's ladder — the length LTX renders.\n const dur = snapToNearestDuration(pricedOutputDurationSec(provider, duration), allowed)\n return { band, duration: dur }\n}\n\nexport function buildVideoCreditModelIdentifier(\n provider: string,\n duration?: number | string,\n sound?: boolean,\n nodeType?: \"image-to-video\" | \"text-to-video\",\n mode?: string,\n resolution?: string,\n hasVideoRef?: boolean,\n): string {\n // T2V overrides: some providers have different base costs for text-to-video\n let effectiveProvider = provider\n if (nodeType === \"text-to-video\") {\n const override = T2V_CREDIT_OVERRIDES[provider]\n if (override) {\n // If override target also has duration pricing, use it as effective provider\n if (DURATION_PRICED_PROVIDERS.has(override)) {\n effectiveProvider = override\n } else {\n return override\n }\n }\n }\n\n // VEO 3.x resolution-tiered pricing: 720p is the base (no suffix), 1080p gets\n // \":1080p\" (Fast/Lite only), and 4K gets \":4k\" for ALL three tiers — direct-4K\n // generation chains KIE's get-4k-video off the base generation (the base runs\n // at 1080p). Duration is fixed at 8s for VEO so the duration-tier path below\n // does not apply.\n if (isVeoProvider(effectiveProvider)) {\n if (resolution === \"4k\") return `${effectiveProvider}:4k`\n // 1080p tier is Fast/Lite only (Quality has no 1080p surcharge).\n if (resolution === \"1080p\" && VEO_RESOLUTION_TIERED_PROVIDERS.has(effectiveProvider)) return `${effectiveProvider}:1080p`\n return effectiveProvider\n }\n\n // Gemini Omni family (gemini-omni-video + gemini-omni-flash): priced by\n // (resolution-band × duration), with a flat per-generation rate when a source\n // video is supplied (V2V). Lowercase \"4k\". The prefix is TEMPLATED from the\n // provider id, so a further Omni SKU needs no edit here — it only has to join\n // GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT\n // in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.\n if (isGeminiOmniProvider(effectiveProvider)) {\n if (hasVideoRef) {\n return resolution === \"4k\" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`\n }\n // The rendered length through the catalog funnel (nearest legal tier, the\n // model's own default when unset) so the composite is always a SEEDED one.\n const d = pricedOutputDurationSec(effectiveProvider, duration)\n return resolution === \"4k\" ? `${effectiveProvider}:4k:${d}` : `${effectiveProvider}:${d}`\n }\n\n // LTX 2.3: priced by (resolution-band × duration-seconds). The RESERVE must be\n // the correct composite — commit_credits (migration 176) only refunds a surplus\n // (actual < reserved) and NEVER collects an upward delta, so an under-reserved\n // LTX run (the bare-id default = cheapest 1080p:6s tier) stays under-charged\n // even with meteredCost:true. Snap to a seeded tier so the id always prices.\n const ltxTier = ltxPricedTier(effectiveProvider, resolution, duration)\n if (ltxTier) {\n return `${effectiveProvider}:${ltxTier.band}:${ltxTier.duration}s`\n }\n\n if (!DURATION_PRICED_PROVIDERS.has(effectiveProvider)) {\n return effectiveProvider\n }\n\n // A named-provider request with NO duration renders the model's own default\n // (kie/models.ts extraParams), so price that default — not the global 5s —\n // for providers whose per-second tiers wouldn't snap 5 up to it\n // (minimax-h3, seedance-2-5). One helper, shared with the dynamic\n // reference-video reservations, so the tier and the scaled reserve agree.\n const durationSec = pricedOutputDurationSec(effectiveProvider, duration)\n const tiers = VIDEO_DURATION_TIERS[effectiveProvider]\n if (!tiers) return effectiveProvider\n\n // Find the matching duration tier\n const tier = tiers.find(t => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1]\n let identifier = `${effectiveProvider}:${tier.suffix}`\n\n // Append audio suffix if applicable. When the caller expressed no intent\n // (sound === undefined), fall back to the model's own default (capability\n // `defaultOn` — kling-3.0 generates audio unless explicitly disabled), so an\n // intent-less request is billed for the audio it actually produces instead\n // of reserving the cheaper no-audio tier against an audio-on generation.\n const soundOn = sound ?? (getVideoAudioCapability(effectiveProvider).defaultOn === true)\n if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && soundOn) {\n identifier += \":audio\"\n }\n\n // Append mode suffix for providers with quality-tiered pricing\n // \"high\" comes from I2V videoSize field, \"pro\" comes from T2V mode field\n if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === \"high\" || mode === \"pro\")) {\n identifier += \":high\"\n }\n\n // Seedance 2.0 family: per-second billing with resolution + video-ref dimensions.\n // KIE accepts 480p / 720p / 1080p natively; per-second rates rise non-linearly\n // so each tier gets its own composite identifier.\n if (RESOLUTION_VIDEO_REF_PRICING.has(effectiveProvider)) {\n // Clamp to the model's catalog resolutions (single source of truth): e.g.\n // seedance-2-mini exposes only 480p/720p, so a stale/explicit 1080p (or 4k)\n // maps to its top priced tier instead of emitting an unpriced composite\n // (which the hard-fail credit guard would 503 on at runtime).\n const supported = MODEL_CATALOG[effectiveProvider]?.resolutions ?? [\"480p\", \"720p\", \"1080p\"]\n // An OMITTED resolution renders the model's KIE-side default, so price that\n // default rather than the cheapest tier — otherwise an intent-less request\n // reserves 480p against a 720p render and commit_credits (refund-only) can\n // never collect the delta. Providers without an entry keep the historical\n // 480p fallback, so this cannot reprice anything already live.\n const requested = resolution ?? PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const want = requested === \"4k\" ? \"4k\" : requested === \"1080p\" ? \"1080p\" : requested === \"720p\" ? \"720p\" : \"480p\"\n // Unsupported (e.g. a stale 1080p on seedance-2-mini) clamps to the model's\n // top priced tier so the emitted composite is always seeded.\n const res = supported.includes(want) ? want : (supported[supported.length - 1] ?? \"480p\")\n identifier += `:${res}`\n if (hasVideoRef) identifier += \"-ref\"\n }\n\n // Duration × resolution pricing without a -ref dimension. Resolutions\n // outside the provider's priced tiers (or undefined) collapse to the first\n // (default) tier so the emitted composite is always seeded — the hard-fail\n // guard fuzzes the whole resolution space.\n const resTiers = RESOLUTION_DURATION_PRICING[effectiveProvider]\n if (resTiers) {\n // The \"default tier\" is the provider's DECLARED default when it has one\n // (PRICING_DEFAULT_RESOLUTION — wan-3 renders 720p, not the cheapest tier),\n // otherwise the first listed tier. Declaring it explicitly means a cosmetic\n // reorder of the tier list can never reprice a live model, and an OMITTED\n // *or* unsupported resolution both land on what actually renders instead of\n // on the cheapest row (commit_credits refunds a surplus but can never\n // collect a shortfall). Behaviour-neutral for every member without a\n // declared default.\n const declaredDefault = PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const fallback = declaredDefault && resTiers.includes(declaredDefault) ? declaredDefault : resTiers[0]!\n // Wan 3.0 renders through `normalizeWan3Resolution`, which is CASE-INSENSITIVE\n // (\"1080P\" — KIE's own OpenAPI enum spelling, and the natural value for an\n // integrator reading the provider docs — renders 1080P). The tier list here is\n // lowercase and `Array.includes` is case-sensitive, so without this the render\n // path and the billing path disagree: \"1080P\" rendered the top tier and billed\n // the 720p row, a shortfall `commit_credits` (refund-only) can never collect.\n // Collapsing through the SAME normalizer the runner uses makes render == billed\n // by construction for every spelling, including garbage (→ the declared 720p).\n // Scoped to the wan family on purpose: the other RESOLUTION_DURATION_PRICING\n // members pass `resolution` to their wire verbatim, so case-folding their\n // billing without probing their wire would reprice live models.\n const requested = isWan3Provider(effectiveProvider)\n ? normalizeWan3Resolution(resolution).toLowerCase()\n : resolution\n const res = requested && resTiers.includes(requested) ? requested : fallback\n identifier += `:${res}`\n }\n\n // MiniMax Hailuo 3 (768P lever, 2026-08-03): bare duration composites stay\n // the 2K (default) rate — byte-identical to the pre-lever seeded rows, so\n // existing workflows and admin overrides keep their ids — and only a\n // verified 768P selection appends \":768p\". normalizeMinimaxH3Resolution\n // collapses anything else to 2K, matching what KIE renders for an\n // omitted/unknown value, so billing can never undercut the render.\n if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === \"768P\") {\n identifier += \":768p\"\n }\n\n return identifier\n}\n\n/**\n * The credit identifier a video GENERATION node is quoted at — Generate Video\n * (and the legacy Image/Text to Video nodes) and the Video to Video Seedance\n * edit lane, on every surface that quotes one: the node's cost pill, the\n * editor's run estimate, the prompt modal and the backend pre-run estimator.\n *\n * It applies the request levers the run applies BEFORE it prices\n * (payload-builder's `resolveVideoRequestNorm`): the model's UI resolution fill\n * when the node names none (`uiResolutionFill` — what the run sends), then the\n * catalog normalizer `normalizeVideoRequestParams`, which also owns the Seedance\n * Draft rule (a draft is priced AND sent at 480p whatever resolution came with\n * it). Without that, a node with no resolution was quoted at the identifier's\n * own default band (720p on Seedance 2.5) while the run sent and reserved 480p.\n *\n * `hasVideoRef` must come from the GRAPH (a wired reference-video edge, e.g.\n * `countRefModalityEdges(edges, id, \"video\") > 0`), never node data: nothing\n * writes `referenceVideoUrls` into a video node, so reading it there always\n * quoted the plain ladder for a run that reserves on the `-ref` one.\n */\nexport function videoGenerationCreditId(args: {\n provider: string\n duration?: number | string\n sound?: boolean\n nodeType?: \"image-to-video\" | \"text-to-video\"\n mode?: string\n resolution?: string\n draft?: boolean\n hasVideoRef?: boolean\n}): string {\n const { resolution } = normalizeVideoRequestParams(args.provider, {\n resolution: args.resolution ?? uiResolutionFill(args.provider),\n draft: args.draft === true,\n })\n return buildVideoCreditModelIdentifier(\n args.provider,\n args.duration,\n args.sound,\n args.nodeType ?? \"image-to-video\",\n args.mode,\n resolution,\n args.hasVideoRef === true,\n )\n}\n\n/**\n * The credit identifier a Video to Video node's Seedance EDIT lane reserves\n * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit\n * shape with the source clip as reference video 1 — so it prices on the\n * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the\n * measured settlement refunds down to what was actually delivered.\n *\n * A thin call into {@link videoGenerationCreditId}, so a Generate Video node\n * making the same KIE call (Seedance, Auto, a wired reference video) is quoted\n * the same id. FOUR surfaces must agree on it exactly: the orchestrator's\n * reservation (payload-builder.ts), the backend pre-run estimator\n * (ee/billing/credits.ts), the node's cost pill, and the frontend run-level\n * estimate (config-panels/helpers.ts). A quote that disagrees with the reserve\n * is the documented `price_not_configured` / blank-pill trap.\n *\n * `resolution` is the node's one `v2vResolution` field; when unset the model's\n * own UI fill is priced, which is what the lane will send. `draft` is the\n * node's Seedance Draft toggle (priced at 480p).\n */\nexport function seedanceVideoEditCreditId(provider: string, resolution?: string, draft?: boolean): string {\n return videoGenerationCreditId({\n provider,\n duration: VIDEO_DURATION_AUTO,\n nodeType: \"text-to-video\",\n resolution,\n draft,\n hasVideoRef: true,\n })\n}\n\n/** What the video credit identifier PRICES for a request, for the levers whose\n * priced value must also be the value we SEND. */\nexport interface PricedVideoSelection {\n /** The resolution band the reservation is priced at when the request omitted\n * one — and only where the platform DECLARES that band as the provider's own\n * default. `undefined` means \"leave `resolution` exactly as the request had\n * it\": either the caller supplied one, or the provider's real default is not\n * known to be the band the identifier assumes. */\n resolution?: string\n /** The length the reservation is priced at and the wire carries, for a\n * provider whose price follows the clip length (LTX's seeded tier, the KIE\n * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:\n * their duration passes through. */\n duration?: number\n /** Non-empty only for a lever the caller ASKED for and did not get (a 7s\n * request snapped to the 6s tier). Filling an omitted lever is a disclosure of\n * the price already being charged, not a correction, so it reports nothing. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The other half of the video money path: `normalizeVideoRequestParams` snaps a\n * value the CATALOG governs; this returns the value the PRICE ladder governs.\n *\n * Two defects it closes, both of the same shape — the identifier prices one\n * thing and the wire carries another, and `commit_credits` (migration 176) only\n * ever refunds a surplus, so the reservation is the final charge:\n *\n * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted\n * `resolution` as a concrete band (LTX → 1080p; a\n * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving\n * the key unset then lets the provider pick — documented for the KIE members\n * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on\n * Replicate. Sending the band we priced makes the two agree by construction.\n *\n * The fill is deliberately limited to providers with a DECLARED default.\n * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the\n * cheapest tier for a resolution-priced provider with no\n * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified\n * provider default: seedance-2 / -fast / -mini pin `resolution: \"720p\"`\n * KIE-side while the identifier prices 480p, so filling 480p would downgrade\n * the render to match a price we already know is wrong. That mismatch is a\n * pre-existing identifier bug and is fixed by seeding the row, not here.\n *\n * 2. **Duration.** Every provider whose price follows the clip length is\n * charged at the length it RENDERS: its own default when the request named\n * none (catalog `defaultDuration`), the nearest length it offers otherwise\n * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is\n * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;\n * sending 7s would bill six and render seven. The same value is returned for\n * the other length-priced providers (the KIE ladders, Gemini Omni), so what\n * is priced is what is sent. Auto (-1) is the model's call and is untouched.\n *\n * Pure, and IDEMPOTENT against the identifier: feeding its output back in\n * cannot move the reserved tier. `video-request-normalize.test.ts` proves that\n * over every provider × resolution × duration.\n */\nexport function pricedVideoSelection(opts: {\n provider: string\n resolution?: string\n duration?: number | string\n}): PricedVideoSelection {\n const adjustments: ModelInputAdjustment[] = []\n const ltx = ltxPricedTier(opts.provider, opts.resolution, opts.duration)\n\n // The band the request will be priced AND rendered at. An explicit value\n // always wins — this only ever fills an omission.\n const resolution = opts.resolution\n ?? (ltx ? ltx.band : PRICING_DEFAULT_RESOLUTION[opts.provider])\n\n const requested = typeof opts.duration === \"string\" ? parseInt(opts.duration, 10) : opts.duration\n const asked = requested !== undefined && !Number.isNaN(requested)\n\n // Every provider whose price follows the clip length sends the length it is\n // CHARGED at (the catalog funnel: its own default when unset, the nearest\n // legal length otherwise). Auto (-1) is the model's call and is left alone.\n const lengthPriced = !!ltx || DURATION_PRICED_PROVIDERS.has(opts.provider) || isGeminiOmniProvider(opts.provider)\n if (!lengthPriced || (!ltx && asked && requested! <= 0)) return { resolution, adjustments }\n\n const duration = ltx ? ltx.duration : pricedOutputDurationSec(opts.provider, opts.duration)\n if (asked && requested !== duration) {\n adjustments.push({\n field: \"duration\",\n from: requested!,\n to: duration,\n reason: ltx\n ? `LTX renders ${ltx.band} in ${ltx.duration}s steps — using ${ltx.duration}s instead of ${requested}s.`\n : `${opts.provider} renders ${duration}s clips at the nearest length it offers — using ${duration}s instead of ${requested}s.`,\n })\n }\n return { resolution, duration, adjustments }\n}\n\n/**\n * Compute composite model identifier for motion control with duration-tiered pricing.\n * Examples: \"kling-3.0-motion:10s\", \"kling-3.0-motion:1080p:15s\", \"motion-transfer:5s\"\n *\n * Wan Animate providers use resolution-tiered pricing (not per-second):\n * \"wan-animate-move\" (480p default), \"wan-animate-move:580p\", \"wan-animate-move:720p\"\n *\n * @param provider - Motion control provider key (\"kling\" for 2.6, \"kling-3.0\", \"wan-animate-move\", \"wan-animate-replace\")\n * @param resolution - \"720p\" or \"1080p\" (Kling), \"480p\" or \"580p\" or \"720p\" (Wan Animate)\n * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)\n */\nexport function buildMotionCreditModelIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n // Wan Animate providers use resolution-tiered pricing (not duration-based)\n if (provider === \"wan-animate-move\" || provider === \"wan-animate-replace\") {\n // 480p is the default (base identifier), 580p and 720p get composite suffix\n if (resolution === \"580p\" || resolution === \"720p\") {\n return `${provider}:${resolution}`\n }\n return provider\n }\n\n const raw = videoDuration ?? 10\n const durationSec = Math.floor(Number.isNaN(raw) ? 10 : raw) // default 10s; floor to match KIE per-second billing\n const tier = MOTION_DURATION_TIERS.find(t => durationSec <= t.maxSeconds)\n ?? MOTION_DURATION_TIERS[MOTION_DURATION_TIERS.length - 1]\n\n const base = provider === \"kling-3.0\" ? \"kling-3.0-motion\" : \"motion-transfer\"\n const resSuffix = resolution === \"1080p\" ? \":1080p\" : \"\"\n return `${base}${resSuffix}:${tier.suffix}`\n}\n\n/**\n * The Suno operations whose credit key depends on the model VERSION.\n *\n * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard\n * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts\n * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat\n * per-operation key and ignores the version the node carries — mashup (:648),\n * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),\n * replace-section (:710), style-boost (:771), convert-wav (:962),\n * lyrics (:482), music-video (:594), voice (:1218).\n *\n * Anything that QUOTES a Suno price — a dropdown row, a node badge, the\n * workflow-credit estimator — must follow the same split, or it displays a\n * credit key the route never charges.\n */\nexport const SUNO_VERSION_PRICED_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n] as const\n\n/**\n * The seven Suno operations that appear behind a select/dropdown UI (model\n * pickers, node badges, the credit estimator) — the three version-priced\n * operations above, plus the four flat-key operations exercised by\n * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the\n * model dropdowns, node badges) can iterate or count it without redeclaring\n * the list and drifting from this one.\n */\nexport const SUNO_SELECT_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-upload-extend\",\n] as const\n\n/**\n * Adjust Speed's price id: motion-compensated (\"smooth\") interpolation is its\n * own, dearer tier. The route, the workflow run, and the editor's badge and\n * run estimate all price through this, so none of them can quote the fast tier\n * for a smooth run.\n */\nexport function speedRampCreditId(quality: unknown): \"speed-ramp\" | \"speed-ramp:smooth\" {\n return quality === \"smooth\" ? \"speed-ramp:smooth\" : \"speed-ramp\"\n}\n\n/**\n * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,\n * cheaper per-output-minute row; a `final` render keeps the bare id. One id per\n * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything\n * that is not exactly \"proxy\" is the final, as the route and the node default\n * it. The route, the workflow run, and the editor's badge and run estimate all\n * price through this; the job itself is always named `apply-edl`.\n */\nexport function applyEdlCreditId(quality: unknown): \"apply-edl\" | \"apply-edl:proxy\" {\n return quality === \"proxy\" ? \"apply-edl:proxy\" : \"apply-edl\"\n}\n\n/**\n * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by\n * how many speakers it composites at once. `standard` — at most two tiles on\n * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which\n * tier a render is in is the render rule's to say (the app's\n * `@nodaro/render-rules`), never this vocabulary's.\n */\nexport const SPEAKER_VIEW_PRICE_TIERS = [\"standard\", \"complex\"] as const\nexport type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number]\n\nexport type SpeakerViewCreditId = \"speaker-view\" | \"speaker-view:proxy\" | \"speaker-view:complex\" | \"speaker-view:complex:proxy\"\n\n/** Every id `speakerViewCreditId` can name. */\nexport const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[] = Object.freeze([\n \"speaker-view\",\n \"speaker-view:proxy\",\n \"speaker-view:complex\",\n \"speaker-view:complex:proxy\",\n] as const)\n\n/**\n * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers\n * decided 2026-10-10): a Preview (`quality` \"proxy\") reserves on its own row,\n * anything else on the final's, and each in its price tier — `standard` on\n * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /\n * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent\n * included) names the `complex` row: a caller that cannot tell quotes high,\n * never low. The job is always named `speaker-view`; only its credit id\n * follows the quality and the tier.\n */\nexport function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId {\n const proxy = quality === \"proxy\"\n if (tier === \"standard\") return proxy ? \"speaker-view:proxy\" : \"speaker-view\"\n return proxy ? \"speaker-view:complex:proxy\" : \"speaker-view:complex\"\n}\n\n/**\n * OUR Nodaro credit key for a Suno operation, given the model version and the\n * operation (which is also the node type and the BullMQ job name).\n *\n * This is the single source of truth for the Suno pricing contract, shared by\n * the reservation path (routes/suno.ts creditGuard), the egress seam\n * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),\n * both workflow-credit estimators (ee/billing/credits.ts and the frontend\n * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno\n * node badges. It is a billing key — NEVER a KIE provider id — which is what\n * satisfies the B3 egress invariant.\n *\n * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no\n * entry (V4 / V4_5 / V4_5ALL / V4_5PLUS) falls back to the operation key, and a\n * non-version-priced operation is returned unchanged.\n */\nexport function sunoCreditType(model: string | undefined, operation: string): string {\n if (!(SUNO_VERSION_PRICED_OPERATIONS as readonly string[]).includes(operation)) {\n return operation\n }\n return (model && SUNO_VERSION_CREDIT_KEYS[model]) || operation\n}\n\n/**\n * Suno version → Nodaro credit key for the version-priced operations. One row\n * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`\n * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version\n * without touching code. Every ACTIVE version MUST have a row here — guarded\n * by `__tests__/suno-credit-type.test.ts` (a new active version with no key\n * would silently bill at the operation key).\n */\nexport const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>> = {\n V6: \"suno-v6\",\n V6_WILD: \"suno-v6_wild\",\n V6_MINI: \"suno-v6_mini\",\n V5_5: \"suno-v5_5\",\n V5: \"suno-v5\",\n}\n"]}
|