@nodaro/shared 3.33.0 → 3.35.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.
Files changed (265) hide show
  1. package/dist/{chunk-2NQLSLSN.cjs → chunk-24ZKPE33.cjs} +5 -5
  2. package/dist/{chunk-2NQLSLSN.cjs.map → chunk-24ZKPE33.cjs.map} +1 -1
  3. package/dist/{chunk-CK3GK34R.js → chunk-2HIDE3QV.js} +9 -3
  4. package/dist/chunk-2HIDE3QV.js.map +1 -0
  5. package/dist/{chunk-WDIBOWAA.js → chunk-2HVFF5SS.js} +6 -6
  6. package/dist/chunk-2HVFF5SS.js.map +1 -0
  7. package/dist/{chunk-FT5CF6IA.js → chunk-2QWNPYDG.js} +3 -3
  8. package/dist/{chunk-FT5CF6IA.js.map → chunk-2QWNPYDG.js.map} +1 -1
  9. package/dist/{chunk-M7GQBRZU.cjs → chunk-3YG3MYDE.cjs} +153 -24
  10. package/dist/chunk-3YG3MYDE.cjs.map +1 -0
  11. package/dist/{chunk-VNQRI2RO.cjs → chunk-5VNBQ4QK.cjs} +16 -16
  12. package/dist/{chunk-VNQRI2RO.cjs.map → chunk-5VNBQ4QK.cjs.map} +1 -1
  13. package/dist/{chunk-K3LLGRK7.cjs → chunk-5ZCXWA7J.cjs} +59 -15
  14. package/dist/chunk-5ZCXWA7J.cjs.map +1 -0
  15. package/dist/{chunk-Z2OL5AJD.cjs → chunk-6F6GGX2W.cjs} +4 -3
  16. package/dist/chunk-6F6GGX2W.cjs.map +1 -0
  17. package/dist/{chunk-D26ENTN2.cjs → chunk-72IFMNJE.cjs} +80 -52
  18. package/dist/chunk-72IFMNJE.cjs.map +1 -0
  19. package/dist/{chunk-SAW5OK36.cjs → chunk-A5Z3IMSJ.cjs} +6 -6
  20. package/dist/{chunk-SAW5OK36.cjs.map → chunk-A5Z3IMSJ.cjs.map} +1 -1
  21. package/dist/{chunk-VA42637J.cjs → chunk-AGEZY4LL.cjs} +46 -41
  22. package/dist/chunk-AGEZY4LL.cjs.map +1 -0
  23. package/dist/{chunk-BG5D5CZ6.js → chunk-ANOQWAMU.js} +23 -6
  24. package/dist/chunk-ANOQWAMU.js.map +1 -0
  25. package/dist/{chunk-PRYE7AZQ.cjs → chunk-AWWOQH46.cjs} +7 -7
  26. package/dist/chunk-AWWOQH46.cjs.map +1 -0
  27. package/dist/{chunk-JFS3NWZ5.cjs → chunk-B7WJJHJS.cjs} +7 -4
  28. package/dist/chunk-B7WJJHJS.cjs.map +1 -0
  29. package/dist/{chunk-D6GNRSCV.cjs → chunk-BBLE4UTG.cjs} +23 -6
  30. package/dist/chunk-BBLE4UTG.cjs.map +1 -0
  31. package/dist/{chunk-HGC5JNVA.cjs → chunk-BVVKMQKR.cjs} +9 -2
  32. package/dist/chunk-BVVKMQKR.cjs.map +1 -0
  33. package/dist/{chunk-YYV35XOS.js → chunk-C4R7BTBQ.js} +4 -3
  34. package/dist/chunk-C4R7BTBQ.js.map +1 -0
  35. package/dist/{chunk-PXFQVLBX.js → chunk-ETXUOETU.js} +26 -36
  36. package/dist/chunk-ETXUOETU.js.map +1 -0
  37. package/dist/{chunk-HKFMXNVQ.cjs → chunk-F4ZT5X2S.cjs} +11 -11
  38. package/dist/{chunk-HKFMXNVQ.cjs.map → chunk-F4ZT5X2S.cjs.map} +1 -1
  39. package/dist/{chunk-YBPBK5KI.js → chunk-FKQJYMCO.js} +97 -23
  40. package/dist/chunk-FKQJYMCO.js.map +1 -0
  41. package/dist/{chunk-ZDFHA2EC.js → chunk-FVKCNAEQ.js} +51 -7
  42. package/dist/chunk-FVKCNAEQ.js.map +1 -0
  43. package/dist/{chunk-ZL7UM6PU.cjs → chunk-GHBXS5RT.cjs} +4 -4
  44. package/dist/{chunk-ZL7UM6PU.cjs.map → chunk-GHBXS5RT.cjs.map} +1 -1
  45. package/dist/{chunk-ZO5PBBFX.js → chunk-GKJRNIP4.js} +59 -15
  46. package/dist/chunk-GKJRNIP4.js.map +1 -0
  47. package/dist/{chunk-UCFWI6D4.js → chunk-GRIMIJJ3.js} +3 -3
  48. package/dist/{chunk-UCFWI6D4.js.map → chunk-GRIMIJJ3.js.map} +1 -1
  49. package/dist/{chunk-5RYLK3MQ.js → chunk-GVHBHUFV.js} +11 -6
  50. package/dist/chunk-GVHBHUFV.js.map +1 -0
  51. package/dist/chunk-GZH2SIOF.cjs +99 -0
  52. package/dist/chunk-GZH2SIOF.cjs.map +1 -0
  53. package/dist/{chunk-SFW3UB2P.js → chunk-IJNQYMN7.js} +4 -4
  54. package/dist/{chunk-SFW3UB2P.js.map → chunk-IJNQYMN7.js.map} +1 -1
  55. package/dist/{chunk-HC7VKIV5.cjs → chunk-IRUPCNW2.cjs} +49 -46
  56. package/dist/chunk-IRUPCNW2.cjs.map +1 -0
  57. package/dist/{chunk-JL4C5VJ7.cjs → chunk-J65CAOUV.cjs} +14 -2
  58. package/dist/chunk-J65CAOUV.cjs.map +1 -0
  59. package/dist/{chunk-23FJQTEA.js → chunk-LJMNCSDG.js} +38 -15
  60. package/dist/chunk-LJMNCSDG.js.map +1 -0
  61. package/dist/{chunk-PVJBAPYJ.js → chunk-MEN7VLQ5.js} +8 -5
  62. package/dist/chunk-MEN7VLQ5.js.map +1 -0
  63. package/dist/{chunk-PHZ23DP3.js → chunk-MUA5L25B.js} +125 -12
  64. package/dist/chunk-MUA5L25B.js.map +1 -0
  65. package/dist/{chunk-WD6HJRBG.cjs → chunk-NWXB4F6D.cjs} +21 -21
  66. package/dist/{chunk-WD6HJRBG.cjs.map → chunk-NWXB4F6D.cjs.map} +1 -1
  67. package/dist/{chunk-PQHS255G.js → chunk-OHSIVNJO.js} +3 -3
  68. package/dist/chunk-OHSIVNJO.js.map +1 -0
  69. package/dist/{chunk-XGFTL5XY.js → chunk-PVVO23LZ.js} +3 -3
  70. package/dist/{chunk-XGFTL5XY.js.map → chunk-PVVO23LZ.js.map} +1 -1
  71. package/dist/{chunk-CUH22J4D.js → chunk-Q4ZXDDWA.js} +3 -3
  72. package/dist/{chunk-CUH22J4D.js.map → chunk-Q4ZXDDWA.js.map} +1 -1
  73. package/dist/{chunk-WKOIGLQX.cjs → chunk-QIIG2QDP.cjs} +8 -8
  74. package/dist/{chunk-WKOIGLQX.cjs.map → chunk-QIIG2QDP.cjs.map} +1 -1
  75. package/dist/{chunk-QA3MVQ32.js → chunk-QXW6O56Z.js} +6 -6
  76. package/dist/chunk-QXW6O56Z.js.map +1 -0
  77. package/dist/{chunk-5PC6JBGJ.cjs → chunk-R2VF5NQG.cjs} +3 -3
  78. package/dist/chunk-R2VF5NQG.cjs.map +1 -0
  79. package/dist/{chunk-7Z5LUTGU.js → chunk-RRI5YBUK.js} +6 -3
  80. package/dist/{chunk-JFS3NWZ5.cjs.map → chunk-RRI5YBUK.js.map} +1 -1
  81. package/dist/{chunk-HUR6ZJ7S.cjs → chunk-RUKFN3LJ.cjs} +6 -6
  82. package/dist/{chunk-HUR6ZJ7S.cjs.map → chunk-RUKFN3LJ.cjs.map} +1 -1
  83. package/dist/chunk-TCBHVIMD.js +89 -0
  84. package/dist/chunk-TCBHVIMD.js.map +1 -0
  85. package/dist/{chunk-SES6GDBQ.cjs → chunk-UJJUX6NW.cjs} +59 -8
  86. package/dist/chunk-UJJUX6NW.cjs.map +1 -0
  87. package/dist/{chunk-ZRL2UFTH.cjs → chunk-V3N56Z2S.cjs} +101 -22
  88. package/dist/chunk-V3N56Z2S.cjs.map +1 -0
  89. package/dist/{chunk-6WZ2VN7V.js → chunk-W36WCZS2.js} +6 -6
  90. package/dist/{chunk-6WZ2VN7V.js.map → chunk-W36WCZS2.js.map} +1 -1
  91. package/dist/{chunk-M36G6SRP.js → chunk-WXNQMJ67.js} +14 -3
  92. package/dist/chunk-WXNQMJ67.js.map +1 -0
  93. package/dist/{chunk-VXPLKQWY.cjs → chunk-XE5PE54B.cjs} +30 -40
  94. package/dist/chunk-XE5PE54B.cjs.map +1 -0
  95. package/dist/{chunk-OZSACQ2V.js → chunk-XJOBMAWW.js} +3 -3
  96. package/dist/{chunk-OZSACQ2V.js.map → chunk-XJOBMAWW.js.map} +1 -1
  97. package/dist/{chunk-OTATNBMD.js → chunk-XS7FI4JA.js} +3 -3
  98. package/dist/{chunk-OTATNBMD.js.map → chunk-XS7FI4JA.js.map} +1 -1
  99. package/dist/{chunk-HRXEZ3SX.cjs → chunk-YD3JA36S.cjs} +4 -4
  100. package/dist/{chunk-HRXEZ3SX.cjs.map → chunk-YD3JA36S.cjs.map} +1 -1
  101. package/dist/chunk-YYODFQEU.cjs +25 -0
  102. package/dist/chunk-YYODFQEU.cjs.map +1 -0
  103. package/dist/{chunk-UTQSSKSG.js → chunk-ZXBSARZX.js} +4 -4
  104. package/dist/{chunk-UTQSSKSG.js.map → chunk-ZXBSARZX.js.map} +1 -1
  105. package/dist/entries/apps.cjs +43 -42
  106. package/dist/entries/apps.d.cts +2 -2
  107. package/dist/entries/apps.d.ts +2 -2
  108. package/dist/entries/apps.js +8 -7
  109. package/dist/entries/catalogs.d.cts +1 -1
  110. package/dist/entries/catalogs.d.ts +1 -1
  111. package/dist/entries/credits.cjs +153 -153
  112. package/dist/entries/credits.d.cts +1 -1
  113. package/dist/entries/credits.d.ts +1 -1
  114. package/dist/entries/credits.js +8 -8
  115. package/dist/entries/edl.cjs +130 -102
  116. package/dist/entries/edl.d.cts +74 -3
  117. package/dist/entries/edl.d.ts +74 -3
  118. package/dist/entries/edl.js +2 -2
  119. package/dist/entries/entities.cjs +126 -122
  120. package/dist/entries/entities.d.cts +2 -2
  121. package/dist/entries/entities.d.ts +2 -2
  122. package/dist/entries/entities.js +1 -1
  123. package/dist/entries/i18n.cjs +11 -11
  124. package/dist/entries/i18n.d.cts +2 -2
  125. package/dist/entries/i18n.d.ts +2 -2
  126. package/dist/entries/i18n.js +1 -1
  127. package/dist/entries/llm-models.cjs +63 -43
  128. package/dist/entries/llm-models.d.cts +71 -4
  129. package/dist/entries/llm-models.d.ts +71 -4
  130. package/dist/entries/llm-models.js +1 -1
  131. package/dist/entries/media.cjs +45 -41
  132. package/dist/entries/media.d.cts +39 -1
  133. package/dist/entries/media.d.ts +39 -1
  134. package/dist/entries/media.js +1 -1
  135. package/dist/entries/model-catalog.cjs +66 -66
  136. package/dist/entries/model-catalog.d.cts +2 -2
  137. package/dist/entries/model-catalog.d.ts +2 -2
  138. package/dist/entries/model-catalog.js +4 -4
  139. package/dist/entries/models.cjs +274 -210
  140. package/dist/entries/models.d.cts +3 -3
  141. package/dist/entries/models.d.ts +3 -3
  142. package/dist/entries/models.js +5 -5
  143. package/dist/entries/nodes.cjs +222 -201
  144. package/dist/entries/nodes.d.cts +48 -8
  145. package/dist/entries/nodes.d.ts +48 -8
  146. package/dist/entries/nodes.js +10 -9
  147. package/dist/entries/pipeline.cjs +149 -149
  148. package/dist/entries/pipeline.d.cts +8 -4
  149. package/dist/entries/pipeline.d.ts +8 -4
  150. package/dist/entries/pipeline.js +3 -3
  151. package/dist/entries/social.cjs +174 -174
  152. package/dist/entries/social.d.cts +13 -5
  153. package/dist/entries/social.d.ts +13 -5
  154. package/dist/entries/social.js +2 -2
  155. package/dist/entries/types.d.cts +1 -1
  156. package/dist/entries/types.d.ts +1 -1
  157. package/dist/entries/ugc.cjs +71 -71
  158. package/dist/entries/ugc.js +4 -4
  159. package/dist/entries/video.cjs +115 -115
  160. package/dist/entries/video.d.cts +4 -3
  161. package/dist/entries/video.d.ts +4 -3
  162. package/dist/entries/video.js +4 -4
  163. package/dist/entries/workflow.cjs +96 -95
  164. package/dist/entries/workflow.d.cts +7 -18
  165. package/dist/entries/workflow.d.ts +7 -18
  166. package/dist/entries/workflow.js +2 -1
  167. package/dist/index.cjs +1708 -1567
  168. package/dist/index.d.cts +9 -9
  169. package/dist/index.d.ts +9 -9
  170. package/dist/index.js +26 -25
  171. package/dist/{model-catalog-V-ZNzRSd.d.ts → model-catalog-VIHGmQL2.d.cts} +22 -0
  172. package/dist/{model-catalog-V-ZNzRSd.d.cts → model-catalog-VIHGmQL2.d.ts} +22 -0
  173. package/dist/{presentation-utils-D0kxsWf9.d.cts → presentation-utils-A4i92SYo.d.cts} +1 -1
  174. package/dist/{presentation-utils-pZwlEAzo.d.ts → presentation-utils-DjdPtM9k.d.ts} +1 -1
  175. package/dist/{scene-node-types-C3kl_zyK.d.ts → scene-node-types-Cvbtf-0a.d.cts} +147 -6
  176. package/dist/{scene-node-types-C3kl_zyK.d.cts → scene-node-types-Cvbtf-0a.d.ts} +147 -6
  177. package/dist/{types-DffyGSy5.d.cts → types-CU6SQnMS.d.cts} +0 -5
  178. package/dist/{types-DffyGSy5.d.ts → types-CU6SQnMS.d.ts} +0 -5
  179. package/dist/{types-BRlFPEru.d.ts → types-DzUBR7yr.d.cts} +8 -1
  180. package/dist/{types-BRlFPEru.d.cts → types-DzUBR7yr.d.ts} +8 -1
  181. package/package.json +1 -1
  182. package/src/__tests__/camera-switch-contract.test.ts +33 -1
  183. package/src/__tests__/character-mention-slug.test.ts +0 -8
  184. package/src/__tests__/effective-tier.test.ts +3 -14
  185. package/src/__tests__/fixtures/camera-switch-speaker-map-parity.json +178 -0
  186. package/src/__tests__/fixtures/root-exports.baseline.json +21 -0
  187. package/src/__tests__/fixtures/speaker-map-camera-ids.json +26 -0
  188. package/src/__tests__/gvp-supported-providers.test.ts +1 -0
  189. package/src/__tests__/i18n-locale-completeness.test.ts +38 -3
  190. package/src/__tests__/llm-models.test.ts +200 -20
  191. package/src/__tests__/node-preset-extract.test.ts +10 -0
  192. package/src/__tests__/preview-gate-use-case.test.ts +16 -1
  193. package/src/__tests__/producer-types.test.ts +19 -0
  194. package/src/__tests__/run-continuation.test.ts +4 -1
  195. package/src/__tests__/speaker-map-contract.test.ts +48 -0
  196. package/src/__tests__/unit-contract-compose.test.ts +129 -0
  197. package/src/__tests__/unit-contracts.test.ts +134 -0
  198. package/src/__tests__/use-case-types.test.ts +33 -0
  199. package/src/__tests__/video-collapse-parity.test.ts +10 -0
  200. package/src/__tests__/video-frame-slot.test.ts +85 -0
  201. package/src/__tests__/video-mode-aliases.test.ts +1 -0
  202. package/src/__tests__/video-reference-only.test.ts +117 -0
  203. package/src/__tests__/vidu-q4-catalog.test.ts +230 -0
  204. package/src/camera-switch-contract.ts +36 -2
  205. package/src/credit-identifiers.ts +19 -6
  206. package/src/entity-asset-types.ts +13 -0
  207. package/src/entries/edl.ts +2 -0
  208. package/src/entries/llm-models.ts +5 -0
  209. package/src/entries/media.ts +1 -0
  210. package/src/entries/models.ts +25 -0
  211. package/src/entries/nodes.ts +5 -1
  212. package/src/fan-out-rows.ts +36 -3
  213. package/src/generate-mask.ts +40 -0
  214. package/src/generated/unit-contracts.ts +58 -0
  215. package/src/i18n/types.ts +13 -2
  216. package/src/json-kinds.ts +24 -4
  217. package/src/llm-models.ts +184 -31
  218. package/src/meta-ads-scrape.ts +16 -8
  219. package/src/model-catalog.ts +78 -13
  220. package/src/model-constants.ts +260 -5
  221. package/src/node-default-mappings.ts +3 -0
  222. package/src/node-preset-extract.ts +8 -0
  223. package/src/pipeline-types.ts +3 -0
  224. package/src/presentation-utils.ts +12 -12
  225. package/src/preview-gate.ts +4 -2
  226. package/src/producer-types.ts +19 -19
  227. package/src/run-continuation.ts +26 -4
  228. package/src/speaker-layouts.ts +8 -3
  229. package/src/speaker-map-contract.ts +77 -0
  230. package/src/unit-contract-compose.ts +55 -0
  231. package/src/use-case-types.ts +19 -0
  232. package/src/video-ui-defaults.ts +7 -5
  233. package/dist/chunk-23FJQTEA.js.map +0 -1
  234. package/dist/chunk-5PC6JBGJ.cjs.map +0 -1
  235. package/dist/chunk-5RYLK3MQ.js.map +0 -1
  236. package/dist/chunk-7Z5LUTGU.js.map +0 -1
  237. package/dist/chunk-BG5D5CZ6.js.map +0 -1
  238. package/dist/chunk-CK3GK34R.js.map +0 -1
  239. package/dist/chunk-D26ENTN2.cjs.map +0 -1
  240. package/dist/chunk-D6GNRSCV.cjs.map +0 -1
  241. package/dist/chunk-HC7VKIV5.cjs.map +0 -1
  242. package/dist/chunk-HGC5JNVA.cjs.map +0 -1
  243. package/dist/chunk-JL4C5VJ7.cjs.map +0 -1
  244. package/dist/chunk-K3LLGRK7.cjs.map +0 -1
  245. package/dist/chunk-M36G6SRP.js.map +0 -1
  246. package/dist/chunk-M7GQBRZU.cjs.map +0 -1
  247. package/dist/chunk-PHZ23DP3.js.map +0 -1
  248. package/dist/chunk-PQHS255G.js.map +0 -1
  249. package/dist/chunk-PRYE7AZQ.cjs.map +0 -1
  250. package/dist/chunk-PVJBAPYJ.js.map +0 -1
  251. package/dist/chunk-PXFQVLBX.js.map +0 -1
  252. package/dist/chunk-QA3MVQ32.js.map +0 -1
  253. package/dist/chunk-SES6GDBQ.cjs.map +0 -1
  254. package/dist/chunk-TU33KYKW.cjs +0 -25
  255. package/dist/chunk-TU33KYKW.cjs.map +0 -1
  256. package/dist/chunk-VA42637J.cjs.map +0 -1
  257. package/dist/chunk-VXPLKQWY.cjs.map +0 -1
  258. package/dist/chunk-WDIBOWAA.js.map +0 -1
  259. package/dist/chunk-YBPBK5KI.js.map +0 -1
  260. package/dist/chunk-YYV35XOS.js.map +0 -1
  261. package/dist/chunk-Z2OL5AJD.cjs.map +0 -1
  262. package/dist/chunk-ZDFHA2EC.js.map +0 -1
  263. package/dist/chunk-ZO5PBBFX.js.map +0 -1
  264. package/dist/chunk-ZRL2UFTH.cjs.map +0 -1
  265. package/src/__tests__/__snapshots__/prompt-builder-segments.test.ts.snap +0 -65
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-run-routes.ts","../src/settings-input.ts","../src/node-mappable-fields.ts","../src/script-settings.ts","../src/json-kinds.ts","../src/preview-gate.ts","../src/use-case-types.ts","../src/run-continuation.ts","../src/render-final.ts","../src/lone-media-url.ts","../src/collections.ts","../src/node-pass-through.ts","../src/transcribe-preflight.ts","../src/normalize-node-params.ts","../src/prompt-affixes.ts","../src/node-preset-extract.ts","../src/node-preset-export.ts","../src/render-output.ts","../src/handle-aliases.ts","../src/site-capture-node.ts"],"names":["SOCIAL_POST_NODE_TYPES","VIDEO_GEN_PROVIDERS","DEFAULT_VIDEO_PROVIDER","GVP_SUPPORTED_PROVIDERS","GVP_DEFAULT_PROVIDER","IMAGE_GEN_PROVIDERS","IMAGE_MODEL_ROLE_DEFAULTS","MODEL_CATALOG","isAutoVideoDuration","fitAspectRatioToModel","getParameterValue","LLM_TEXT_INPUT_MAX","resolveNodeRefs","UGC_PRIMARY_HANDLE","unitJsonPips","RENDER_NODE_TYPES","pip","RENDER_JSON_HANDLE","RENDER_NODE_TYPE_IDS","unitReviewHolds","defaultEdgeOutputMode","buildFeedMaps","mergeNodeInputOverrides","UNIT_USE_CASE_TYPES","IMAGE_PRODUCER_TYPES","VIDEO_PRODUCER_TYPES","AUDIO_PRODUCER_TYPES","DYNAMIC_PRODUCER_TYPES","ENTITY_NODE_KINDS","str","text","DEFAULT_TRANSCRIBE_NODE_PROVIDER","transcribeLaneSupportsWordTimestamps","transcribeProvidersWithWordTimestamps","renderTranscriptOutputOf","imageGenAutoAspectNeedsSourceImage","autoAspectNeedsSourceImage","normalizeModelInput","COMPOSER_PLAN_FIELDS","isExecutionDataKey","z","own","normalizeEdl","TELEPORT_TYPES","outputModeOf","resolveIndex","selectListItems","editPlanBasis"],"mappings":";;;;;;;;;;;;;;;;;AAUA,IAAM,oBAAA,GAAuB,oBAAA;AAGtB,IAAM,eAAA,GAAoD,OAAO,MAAA,CAAO;AAAA,EAC7E,mBAAA,EAAqB,uBAAA;AAAA,EACrB,eAAA,EAAiB,mBAAA;AAAA,EACjB,WAAA,EAAa,wBAAA;AAAA,EACb,UAAA,EAAY,uBAAA;AAAA,EACZ,gBAAA,EAAkB,0BAAA;AAAA,EAClB,eAAA,EAAiB,4BAAA;AAAA,EACjB,gBAAA,EAAkB,6BAAA;AAAA,EAClB,UAAA,EAAY,uBAAA;AAAA,EACZ,iBAAA,EAAmB,8BAAA;AAAA,EACnB,eAAA,EAAiB,4BAAA;AAAA,EACjB,uBAAA,EAAyB,4BAAA;AAAA,EACzB,e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,QAAA,KAAa,QAAA,GAAW,EAAE,QAAA,GAAW;AAAA,GAC1D,CAAE,EACD,IAAA,CAAK,CAAC,GAAG,CAAA,KAAM,CAAA,CAAE,KAAA,GAAQ,CAAA,CAAE,KAAK,CAAA;AACrC;AAGO,SAAS,qBAAqB,MAAA,EAA2B;AAC9D,EAAA,OAAO,kBAAkB,MAAM,CAAA,CAAE,IAAI,CAAC,CAAA,KAAM,EAAE,GAAG,CAAA;AACnD;AAOO,SAAS,uBAAuB,MAAA,EAAgG;AACrI,EAAA,IAAI,CAAC,MAAA,IAAU,OAAO,MAAA,KAAW,QAAA,IAAY,MAAM,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,EAAC;AAC5E,EAAA,MAAM,IAAA,GAAO,qBAAqB,MAAM,CAAA;AACxC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,MAAA;AAAA,IACN,GAAI,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,EAAE,QAAA,EAAU,IAAA,CAAK,CAAC,CAAA,EAAG,WAAA,EAAa,IAAA,EAAK,GAAI;AAAC,GACpE;AACF","file":"chunk-72IFMNJE.cjs","sourcesContent":["/**\n * The REST route that runs one node type on its own: `POST /v1/<type>` by\n * convention, or the route listed here.\n *\n * Part of the public API contract: `@nodaro/sdk`'s `nodes.run(type)` posts to\n * the route this resolves, and the platform's workflow engine calls the same\n * routes for the node types it runs over HTTP, so the two cannot disagree.\n */\nimport { SOCIAL_POST_NODE_TYPES } from \"./social-post.js\"\n\nconst SOCIAL_PUBLISH_ROUTE = \"/v1/social/publish\"\n\n/** Node types whose run route is NOT `POST /v1/<type>`. */\nexport const NODE_RUN_ROUTES: Readonly<Record<string, string>> = Object.freeze({\n \"generate-3d-scene\": \"/v1/3d-scene/generate\",\n \"edit-3d-scene\": \"/v1/3d-scene/edit\",\n \"ai-writer\": \"/v1/ai-writer/generate\",\n \"llm-chat\": \"/v1/llm-chat/generate\",\n \"video-composer\": \"/v1/scene-graph/generate\",\n \"after-effects\": \"/v1/after-effects/generate\",\n \"lottie-overlay\": \"/v1/lottie-overlay/generate\",\n \"3d-title\": \"/v1/3d-title/generate\",\n \"motion-graphics\": \"/v1/motion-graphics/generate\",\n \"image-to-text\": \"/v1/image-to-text/describe\",\n \"telegram-channel-feed\": \"/v1/telegram-channel/fetch\",\n \"suno-generate\": \"/v1/suno/generate\",\n \"suno-cover\": \"/v1/suno/cover\",\n \"suno-extend\": \"/v1/suno/extend\",\n \"suno-lyrics\": \"/v1/suno/lyrics\",\n \"suno-separate\": \"/v1/suno/separate\",\n \"suno-music-video\": \"/v1/suno/music-video\",\n \"suno-mashup\": \"/v1/suno/mashup\",\n \"suno-replace-section\": \"/v1/suno/replace-section\",\n \"suno-style-boost\": \"/v1/suno/style-boost\",\n \"suno-add-instrumental\": \"/v1/suno/add-instrumental\",\n \"suno-add-vocals\": \"/v1/suno/add-vocals\",\n \"suno-convert-wav\": \"/v1/suno/convert-wav\",\n \"suno-upload-extend\": \"/v1/suno/upload-extend\",\n \"suno-voice\": \"/v1/suno/voice/generate\",\n // The UGC nodes' routes, served by the Nodaro Cloud plugin.\n \"ugc-creator\": \"/v1/ugc/creator\",\n \"ugc-script\": \"/v1/ugc/script\",\n \"ugc-clips\": \"/v1/ugc/clips\",\n \"ugc-clip\": \"/v1/ugc/clip\",\n \"ugc-cards\": \"/v1/ugc/cards\",\n // UGC Finish: the finish job over a speech-first video's clips (an English video passes through with no call).\n \"ugc-finish-clips\": \"/v1/ugc/finish\",\n // Every social post node publishes through the one route; the body's\n // `platform` says where (SOCIAL_POST_NODE_PLATFORM).\n ...Object.fromEntries([...SOCIAL_POST_NODE_TYPES].map((type) => [type, SOCIAL_PUBLISH_ROUTE])),\n})\n\n/**\n * Node types with no route that runs them on their own, each with what to run\n * instead. They run inside the editor or a workflow, or through a sibling\n * route that takes a differently shaped body.\n */\nexport const NODE_TYPES_WITHOUT_RUN_ROUTE: Readonly<Record<string, string>> = Object.freeze({\n \"modify-image\": 'run \"image-to-image\" instead (or \"edit-image\" for the nano-banana-edit provider)',\n \"upscale-image\": 'run \"edit-image\" with an upscale provider instead (e.g. provider \"recraft-upscale\")',\n \"remove-background\": 'run \"edit-image\" with provider \"recraft-remove-bg\" instead',\n \"image-to-video\": 'run \"generate-video\" with a start frame instead',\n composite: \"it runs only as part of a workflow (client.workflows.run)\",\n \"manual-edit\": \"it opens the in-browser editor and runs only inside a workflow\",\n \"paint-mask\": \"it is painted in the editor and never runs; use its mask output inside a workflow\",\n scene: \"it is run by the pipeline orchestrator (client.pipelines)\",\n \"generative-pipeline\": \"it is run by the pipeline orchestrator (client.pipelines)\",\n})\n\n/**\n * The route that runs `type` on its own, or null when it has none (see\n * {@link NODE_TYPES_WITHOUT_RUN_ROUTE} for what to run instead).\n */\nexport function nodeRunRoute(type: string): string | null {\n if (Object.prototype.hasOwnProperty.call(NODE_TYPES_WITHOUT_RUN_ROUTE, type)) return null\n if (Object.prototype.hasOwnProperty.call(NODE_RUN_ROUTES, type)) return NODE_RUN_ROUTES[type]!\n return `/v1/${encodeURIComponent(type)}`\n}\n","import { IMAGE_MODEL_ROLE_DEFAULTS } from \"./image-model-roles.js\"\n/**\n * The \"Settings\" input: ONE input handle on a generation node that takes the\n * Generation Settings nodes. Aspect Ratio, Duration and Provider set the\n * consumer's own field; Motion adds a clause to its prompt. The editor shows it\n * as a single pip, with the connected values listed inside the node.\n *\n * Every reader goes through this module, so they cannot disagree about what a\n * node runs with: both run engines (their field-mapping wrappers ask\n * `settingsSourceForField` which wired node sets a field, then\n * `applySettingsInput` fits the values to the model), and the readers that\n * run before any resolver — the workflow estimate, the node's chips and its\n * settings panel — through `resolveWiredSettings`. A new setting or consumer\n * is one row here.\n */\n\nimport { MODEL_CATALOG, fitAspectRatioToModel } from \"./model-catalog.js\"\nimport { DEFAULT_VIDEO_PROVIDER, GVP_DEFAULT_PROVIDER, GVP_SUPPORTED_PROVIDERS, IMAGE_GEN_PROVIDERS, VIDEO_GEN_PROVIDERS } from \"./model-constants.js\"\nimport { getParameterValue } from \"./parameter-node-value.js\"\nimport { isAutoVideoDuration } from \"./video-duration-auto.js\"\n\n/** The handle id of the Settings input. */\nexport const SETTINGS_INPUT_HANDLE = \"settings\"\n\n/** A Generation Settings node type → the consumer data field it sets. */\nexport const SETTINGS_SOURCE_FIELDS = {\n \"aspect-ratio\": \"aspectRatio\",\n duration: \"duration\",\n provider: \"provider\",\n} as const\n\n/**\n * Generation Settings nodes a Settings input takes as a prompt CLAUSE rather\n * than a field: Motion (how much the shot moves). Each engine's hint collector\n * adds its clause beside the Look family's, under the same Inject Look switch\n * (`isSettingsHintEdge`).\n */\nexport const SETTINGS_HINT_SOURCES = [\"motion\"] as const\n\nexport type SettingsFieldSourceType = keyof typeof SETTINGS_SOURCE_FIELDS\nexport type SettingsHintSourceType = (typeof SETTINGS_HINT_SOURCES)[number]\nexport type SettingsSourceType = SettingsFieldSourceType | SettingsHintSourceType\nexport type SettingsField = (typeof SETTINGS_SOURCE_FIELDS)[SettingsFieldSourceType]\n\n/** Every Generation Settings node type a Settings input can take. */\nexport const SETTINGS_SOURCE_TYPES: readonly SettingsSourceType[] = [\n ...(Object.keys(SETTINGS_SOURCE_FIELDS) as SettingsFieldSourceType[]),\n ...SETTINGS_HINT_SOURCES,\n]\n\n/** The consumer field a setting sets; none for a prompt-clause setting. */\nfunction fieldOf(sourceType: SettingsSourceType): SettingsField | undefined {\n return Object.prototype.hasOwnProperty.call(SETTINGS_SOURCE_FIELDS, sourceType)\n ? SETTINGS_SOURCE_FIELDS[sourceType as SettingsFieldSourceType]\n : undefined\n}\n\n/**\n * A node with a Settings input:\n * - `accepts`: the settings it takes, in the order its chips show them;\n * - `models`: the models a wired Provider may name — a Provider node can hold\n * any category's model, and this node runs only these;\n * - `defaultModel`: the model it renders with when its data names none;\n * - `duration` (when it takes one): how it takes a wired Duration. \"model\"\n * fits the length to one the model renders (a Duration node holds a\n * script's length, 60 s by default, while one clip is 4–30 s). \"total\"\n * keeps it: Generate Video Pro stitches segments to reach the requested\n * total, and its engine clamps that total to the range the model's segment\n * lengths allow;\n * - `modelList`: the field holding the node's several models, when it can run\n * more than one per run (Generate Image's `providers`, one image each). A\n * wired Provider sets THE model, so the list becomes that one model.\n *\n * A wired Aspect Ratio is fitted to the model by `fitAspectRatioToModel`, the\n * rule the video lane's normalizer applies (and a still-valid ratio passes\n * every later normalizer unchanged), so the node shows the ratio it runs with.\n */\ninterface SettingsConsumer {\n readonly accepts: readonly SettingsSourceType[]\n readonly models: readonly string[]\n readonly defaultModel: string\n readonly duration?: \"model\" | \"total\"\n readonly modelList?: string\n}\n\n// Motion is a video-only clause (VIDEO_ONLY_PARAMETER_NODE_TYPES).\nconst VIDEO_SETTINGS: readonly SettingsSourceType[] = [\"aspect-ratio\", \"duration\", \"provider\", \"motion\"]\n\nconst SETTINGS_CONSUMERS: Readonly<Record<string, SettingsConsumer>> = {\n \"generate-video\": {\n accepts: VIDEO_SETTINGS,\n models: VIDEO_GEN_PROVIDERS,\n defaultModel: DEFAULT_VIDEO_PROVIDER,\n duration: \"model\",\n },\n // Generate Video Pro has Generate Video's handles by construction\n // (generate-video-pro-handles.ts re-exports them), so it takes the same\n // settings; its own models and its own duration rule.\n \"generate-video-pro\": {\n accepts: VIDEO_SETTINGS,\n models: GVP_SUPPORTED_PROVIDERS,\n defaultModel: GVP_DEFAULT_PROVIDER,\n duration: \"total\",\n },\n // A still image has no length, so no Duration.\n \"generate-image\": {\n accepts: [\"aspect-ratio\", \"provider\"],\n models: IMAGE_GEN_PROVIDERS,\n // The node's own default (NODE_DEFINITIONS) — only used to fit a wired\n // ratio when the node names no model.\n defaultModel: IMAGE_MODEL_ROLE_DEFAULTS.general,\n modelList: \"providers\",\n },\n}\n\n/** The consumers that have a Settings input, and the settings each accepts. */\nexport const SETTINGS_INPUT_CONSUMERS: Readonly<Record<string, readonly SettingsSourceType[]>> = Object.fromEntries(\n Object.entries(SETTINGS_CONSUMERS).map(([type, consumer]) => [type, consumer.accepts]),\n)\n\nexport function isSettingsSourceType(type: string | undefined | null): type is SettingsSourceType {\n return typeof type === \"string\" && (SETTINGS_SOURCE_TYPES as readonly string[]).includes(type)\n}\n\n/** Whether a Generation Settings node adds a prompt clause rather than setting a field. */\nexport function isSettingsHintSource(type: string | undefined | null): type is SettingsHintSourceType {\n return typeof type === \"string\" && (SETTINGS_HINT_SOURCES as readonly string[]).includes(type)\n}\n\n/** Whether `consumerType`'s Settings input takes a `sourceType` node. */\nexport function settingsInputAccepts(consumerType: string, sourceType: string): boolean {\n return (SETTINGS_INPUT_CONSUMERS[consumerType] ?? []).some((t) => t === sourceType)\n}\n\n/** The consumer fields a Settings input can set, for `NODE_MAPPABLE_FIELDS`. */\nexport function settingsInputFields(consumerType: string): SettingsField[] {\n return (SETTINGS_INPUT_CONSUMERS[consumerType] ?? []).flatMap((t) => {\n const field = fieldOf(t)\n return field ? [field] : []\n })\n}\n\n/** The models a wired Provider may name on `consumerType` (empty for a non-consumer). */\nexport function settingsProviderModels(consumerType: string): readonly string[] {\n return SETTINGS_CONSUMERS[consumerType]?.models ?? []\n}\n\ninterface SettingsEdge {\n readonly source: string\n readonly target: string\n readonly targetHandle?: string | null\n}\n\n/**\n * The `sourceType` node wired into `consumerId`'s Settings input, or\n * undefined. When two nodes of one kind are wired, the LAST edge wins — the\n * same rule as every other single-value input.\n */\nexport function settingsSourceForType(\n consumerId: string,\n consumerType: string,\n sourceType: SettingsSourceType,\n edges: ReadonlyArray<SettingsEdge>,\n typeOf: (nodeId: string) => string | undefined | null,\n): string | undefined {\n if (!settingsInputAccepts(consumerType, sourceType)) return undefined\n let found: string | undefined\n for (const edge of edges) {\n if (edge.target !== consumerId || edge.targetHandle !== SETTINGS_INPUT_HANDLE) continue\n if (typeOf(edge.source) === sourceType) found = edge.source\n }\n return found\n}\n\n/** The node wired into `consumerId`'s Settings input that sets `field`, or undefined (last edge wins). */\nexport function settingsSourceForField(\n consumerId: string,\n consumerType: string,\n field: string,\n edges: ReadonlyArray<SettingsEdge>,\n typeOf: (nodeId: string) => string | undefined | null,\n): string | undefined {\n const sourceType = (SETTINGS_INPUT_CONSUMERS[consumerType] ?? []).find((t) => fieldOf(t) === field)\n return sourceType ? settingsSourceForType(consumerId, consumerType, sourceType, edges, typeOf) : undefined\n}\n\n/**\n * Whether `edge` brings a prompt-clause setting (Motion) into its target's\n * Settings input and is the one of its kind that applies (the last edge). The\n * hint collectors of both engines ask this, so the clause a run gets is the\n * one the node's chips show.\n */\nexport function isSettingsHintEdge(\n edge: SettingsEdge,\n consumerType: string,\n edges: ReadonlyArray<SettingsEdge>,\n typeOf: (nodeId: string) => string | undefined | null,\n): boolean {\n if (edge.targetHandle !== SETTINGS_INPUT_HANDLE) return false\n const sourceType = typeOf(edge.source)\n if (!isSettingsHintSource(sourceType)) return false\n return settingsSourceForType(edge.target, consumerType, sourceType, edges, typeOf) === edge.source\n}\n\n/**\n * Every setting wired into `consumerId`'s Settings input, one per kind (the\n * last edge of a kind wins), in the order of `SETTINGS_INPUT_CONSUMERS`.\n */\nexport function connectedSettingsSources(\n consumerId: string,\n consumerType: string,\n edges: ReadonlyArray<SettingsEdge>,\n typeOf: (nodeId: string) => string | undefined | null,\n): Array<{ sourceType: SettingsSourceType; field?: SettingsField; sourceId: string }> {\n const out: Array<{ sourceType: SettingsSourceType; field?: SettingsField; sourceId: string }> = []\n for (const sourceType of SETTINGS_INPUT_CONSUMERS[consumerType] ?? []) {\n const sourceId = settingsSourceForType(consumerId, consumerType, sourceType, edges, typeOf)\n if (!sourceId) continue\n const field = fieldOf(sourceType)\n out.push(field ? { sourceType, field, sourceId } : { sourceType, sourceId })\n }\n return out\n}\n\n/**\n * `seconds` as `model` renders it: the nearest duration the catalog lists for\n * the model, a tie going to the shorter one — the rule the provider layer\n * applies when it renders (`snapToAllowedDuration`, KIE), so the length the\n * run is priced at is the length it renders. Not `normalizeModelInput`'s\n * duration snap, which replaces an invalid value with the model's FIRST\n * length: right for a typo, wrong for a wired length (a 60 s Duration would\n * become the model's shortest clip instead of its longest). A model without a\n * duration list, and the \"auto\" duration, keep the value.\n */\nexport function snapToModelDuration(model: string, seconds: number): number {\n const durations = MODEL_CATALOG[model]?.durations\n if (!durations || durations.length === 0 || isAutoVideoDuration(seconds)) return seconds\n let best = durations[0]!\n for (const d of durations) {\n const closer = Math.abs(d - seconds) < Math.abs(best - seconds)\n const tieShorter = Math.abs(d - seconds) === Math.abs(best - seconds) && d < best\n if (closer || tieShorter) best = d\n }\n return best\n}\n\nexport type SettingsInputProblem = { readonly kind: \"provider-not-accepted\"; readonly sourceId: string; readonly value: string }\n\n/**\n * The consumer's data once its Settings input has been read (after the field\n * mapping resolver wrote each wired value into its field):\n * - a wired Provider must name a model this consumer runs: a Provider node set\n * to an image model cannot drive Generate Video, and the run refuses with\n * `problem` rather than sending an image model to the video provider;\n * - a wired Provider on a node that runs several models per run replaces the\n * list with its one model (see `SettingsConsumer.modelList`);\n * - a wired Duration is fitted to the model (see `SettingsConsumer.duration`);\n * - a wired Aspect Ratio is fitted to the model (`fitAspectRatioToModel`).\n */\nexport function applySettingsInput(\n consumerType: string,\n consumerId: string,\n data: Readonly<Record<string, unknown>>,\n edges: ReadonlyArray<SettingsEdge>,\n typeOf: (nodeId: string) => string | undefined | null,\n): { data: Record<string, unknown>; problem?: SettingsInputProblem } {\n const consumer = SETTINGS_CONSUMERS[consumerType]\n const connected = connectedSettingsSources(consumerId, consumerType, edges, typeOf)\n if (!consumer || connected.length === 0) return { data: { ...data } }\n let next: Record<string, unknown> = { ...data }\n\n const providerSource = connected.find((c) => c.sourceType === \"provider\")\n if (providerSource) {\n const value = typeof next.provider === \"string\" ? next.provider : \"\"\n if (!consumer.models.includes(value)) {\n return { data: next, problem: { kind: \"provider-not-accepted\", sourceId: providerSource.sourceId, value } }\n }\n if (consumer.modelList) next = { ...next, [consumer.modelList]: [value] }\n }\n\n const model = (typeof next.provider === \"string\" && next.provider) || consumer.defaultModel\n if (consumer.duration === \"model\" && connected.some((c) => c.sourceType === \"duration\")) {\n const raw = next.duration\n const seconds = typeof raw === \"number\" ? raw : typeof raw === \"string\" ? Number.parseInt(raw, 10) : Number.NaN\n if (Number.isFinite(seconds)) next = { ...next, duration: snapToModelDuration(model, seconds) }\n }\n if (connected.some((c) => c.sourceType === \"aspect-ratio\") && typeof next.aspectRatio === \"string\") {\n next = { ...next, aspectRatio: fitAspectRatioToModel(model, next.aspectRatio) }\n }\n return { data: next }\n}\n\ninterface SettingsGraphNode {\n readonly id: string\n readonly type?: string | null\n readonly data?: unknown\n}\n\n/** One setting wired into a node's Settings input. */\nexport interface WiredSetting {\n readonly sourceType: SettingsSourceType\n /** The field it sets; none for a prompt-clause setting (Motion). */\n readonly field?: SettingsField\n readonly sourceId: string\n /** The value the wired node holds, read the way the run engines read it. */\n readonly value: string | undefined\n}\n\n/**\n * What `consumerId` runs with once its Settings input is read: its data with\n * each wired setting written into its field and fitted to the model — the\n * steps the run engines take (field-mapping resolver, then\n * `applySettingsInput`), for the readers that run before any resolver: the\n * workflow estimate, the node's chips and its settings panel.\n */\nexport function resolveWiredSettings(\n consumerId: string,\n consumerType: string,\n data: Readonly<Record<string, unknown>>,\n nodes: ReadonlyArray<SettingsGraphNode>,\n edges: ReadonlyArray<SettingsEdge>,\n): { data: Record<string, unknown>; wired: WiredSetting[]; problem?: SettingsInputProblem } {\n const byId = new Map(nodes.map((n) => [n.id, n]))\n const typeOf = (id: string) => byId.get(id)?.type\n const wired: WiredSetting[] = connectedSettingsSources(consumerId, consumerType, edges, typeOf).map((c) => ({\n ...c,\n value: getParameterValue((byId.get(c.sourceId)?.data ?? {}) as Record<string, unknown>, c.sourceType),\n }))\n if (wired.length === 0) return { data: { ...data }, wired }\n let next: Record<string, unknown> = { ...data }\n for (const w of wired) {\n if (w.field && w.value != null) next = { ...next, [w.field]: w.value }\n }\n const applied = applySettingsInput(consumerType, consumerId, next, edges, typeOf)\n return applied.problem ? { data: applied.data, wired, problem: applied.problem } : { data: applied.data, wired }\n}\n\ninterface SettingsNodeLike {\n readonly id?: string\n readonly type?: string | null\n readonly data?: unknown\n}\n\ninterface SettingsEdgeLike {\n readonly source?: string\n readonly target: string\n readonly targetHandle?: string | null\n}\n\n/**\n * `node` as it runs, for the readers that plan or price a run before any\n * resolver: the workflow estimates, the Run price, and the fan-out plan (a\n * wired Provider turns a several-model image run into one). A node with no\n * Settings input — or a caller without the graph — gets `node` back as is.\n */\nexport function withWiredSettings<T extends SettingsNodeLike>(\n node: T,\n nodes?: ReadonlyArray<SettingsNodeLike>,\n edges?: ReadonlyArray<SettingsEdgeLike>,\n): T {\n const type = node.type ?? \"\"\n if (!nodes || !edges || !node.id || !SETTINGS_CONSUMERS[type]) return node\n const graphNodes = nodes.flatMap((n) => (n.id ? [{ id: n.id, type: n.type, data: n.data }] : []))\n const graphEdges = edges.map((e) => ({ source: e.source ?? \"\", target: e.target, targetHandle: e.targetHandle }))\n const { data } = resolveWiredSettings(node.id, type, (node.data ?? {}) as Record<string, unknown>, graphNodes, graphEdges)\n return { ...node, data }\n}\n","import { settingsInputFields } from \"./settings-input.js\"\n\n/**\n * Per-node-type list of field names eligible for fieldMappings resolution.\n * Text fields also participate in {} injection when the resolver sees a\n * string value containing {} markers; non-text fields just receive the\n * mapped source's value verbatim.\n */\nexport const NODE_MAPPABLE_FIELDS: Readonly<Record<string, readonly string[]>> = {\n // + the fields its Settings input sets (settings-input.ts).\n \"generate-image\": [\"prompt\", \"style\", \"negativePrompt\", ...settingsInputFields(\"generate-image\")],\n \"edit-image\": [\"prompt\", \"style\", \"negativePrompt\"],\n \"image-to-image\": [\"prompt\", \"style\", \"negativePrompt\"],\n \"modify-image\": [\"prompt\", \"style\", \"negativePrompt\"],\n \"text-to-video\": [\"prompt\", \"negativePrompt\"],\n \"image-to-video\": [\"prompt\"],\n // Unified t2v/i2v node — replaced the two deprecated keys above (kept only\n // for back-compat with un-migrated workflow JSON). Mirrors text-to-video so\n // fieldMappings/{} injection AND missing-ref detection work on the live node.\n // + the fields its Settings input sets (settings-input.ts): a Generation\n // Settings node wired there overrides the node's own aspect ratio, duration\n // and model at run time, through the same resolver as a field mapping.\n \"generate-video\": [\"prompt\", \"negativePrompt\", ...settingsInputFields(\"generate-video\")],\n // Trimmed multi-segment stitch variant of generate-video — prompt only, no\n // negativePrompt field on the node; + the fields its Settings input sets.\n \"generate-video-pro\": [\"prompt\", ...settingsInputFields(\"generate-video-pro\")],\n // Span-replace sibling of generate-video-pro — prompt only, no\n // negativePrompt field on the node.\n \"edit-video-pro\": [\"prompt\"],\n // The subject to track — a {Label} reference or a mapping writes it.\n \"video-mask\": [\"prompt\"],\n \"video-analysis\": [\"analysisFocus\", \"youtubeUrl\"],\n \"video-to-video\": [\"prompt\"],\n // + the two neighbour-text fields (continuity across clips): a wired Text node can feed\n // what is spoken before / after this clip, and {} injection works in them as in directText.\n \"text-to-speech\": [\"directText\", \"previousText\", \"nextText\"],\n // Save to Collection: the record's own fields, each mappable from an upstream\n // node or a {Ref}; the link field is `link` (node-data keys ending in url are\n // locked by the Copilot's deny-list).\n \"collection-write\": [\"title\", \"text\", \"link\", \"dedupeKey\"],\n \"lip-sync\": [\"prompt\"],\n \"generate-music\": [\"prompt\", \"lyrics\", \"genre\", \"mood\"],\n \"text-to-audio\": [\"prompt\"],\n \"suno-generate\": [\"prompt\", \"lyrics\", \"style\", \"title\", \"negativeStyle\"],\n \"suno-cover\": [\"prompt\", \"lyrics\", \"style\", \"title\", \"negativeStyle\"],\n \"suno-extend\": [\"prompt\", \"style\", \"title\"],\n \"suno-lyrics\": [\"prompt\"],\n \"suno-replace-section\":[\"prompt\", \"tags\", \"title\", \"fullLyrics\", \"negativeTags\"],\n \"suno-style-boost\": [\"content\"],\n \"suno-upload-extend\": [\"prompt\", \"style\", \"title\"],\n \"suno-mashup\": [\"style\", \"title\", \"negativeStyle\"],\n \"voice-remix\": [\"voiceDescription\", \"text\"],\n \"voice-design\": [\"voiceDescription\", \"text\"],\n \"forced-alignment\": [\"transcript\"],\n \"ai-writer\": [\"systemPrompt\", \"userInput\"],\n \"llm-chat\": [\"systemPrompt\", \"userInput\"],\n \"video-composer\": [\"compositionPrompt\"],\n \"after-effects\": [\"effectPrompt\"],\n \"lottie-overlay\": [\"overlayPrompt\"],\n \"3d-title\": [\"titlePrompt\"],\n \"generate-3d-scene\": [\"scenePrompt\"],\n \"edit-3d-scene\": [\"editPrompt\"],\n \"pro-3d-render\": [\"scenePrompt\"],\n \"motion-graphics\": [\"motionPrompt\"],\n // Every field the panel offers a source for. Numbers arrive as text from a\n // Scene Count / Duration node; readScriptSettings coerces them on both engines.\n \"generate-script\": [\"styleGuide\", \"tone\", \"sceneCount\", \"targetLength\"],\n \"speech-to-video\": [\"prompt\", \"negativePrompt\"],\n \"extend-video\": [\"prompt\"],\n \"motion-transfer\": [\"prompt\"],\n \"cinematic-avatar\": [\"prompt\"],\n \"image-to-text\": [\"customPrompt\"],\n \"instagram-post\": [\"caption\", \"title\"],\n \"tiktok-post\": [\"caption\", \"title\"],\n \"youtube-upload\": [\"caption\", \"title\"],\n \"linkedin-post\": [\"caption\", \"title\"],\n \"x-post\": [\"caption\", \"title\"],\n \"facebook-post\": [\"caption\", \"title\"],\n \"telegram-post\": [\"caption\", \"title\"],\n \"save-to-storage\": [\"filename\"],\n \"webhook-output\": [\"url\"],\n \"character\": [\"characterName\", \"description\", \"baseOutfit\"],\n \"face\": [\"faceName\", \"description\"],\n \"object\": [\"objectName\", \"description\"],\n \"creature\": [\"creatureName\", \"description\"],\n \"location\": [\"locationName\", \"description\"],\n \"web-scrape\": [\"query\", \"url\", \"target\"],\n \"site-capture\": [\"url\"],\n \"meta-ads-scrape\": [\"query\", \"pageUrls\"],\n \"instagram-scrape\": [\"targets\"],\n // Content Recipe's material arrives on its `in` wire and the post link on\n // its `link` wire (a Video URL node's page link) — only the focus is a field.\n \"content-recipe\": [\"focus\"],\n // Content Ideas folds its recipes on the `recipes` wire (FAN_IN_TARGETS);\n // the brand profile and the language are fields a Text node can feed.\n \"content-ideas\": [\"brand\", \"language\"],\n // Social Search: the keyword or account a Text node (or a List item) feeds.\n \"social-search\": [\"query\"],\n}\n\n/** suno-generate secondary text fields exposed as `field-<key>` canvas handles. */\nexport const SUNO_FIELD_HANDLE_FIELDS = [\"style\", \"lyrics\", \"title\", \"negativeStyle\"] as const\n/** Map a `field-<key>` handle id to its data key, or null if not a field handle. */\nexport function fieldKeyFromHandle(handleId: string): string | null {\n return handleId.startsWith(\"field-\") ? handleId.slice(\"field-\".length) : null\n}\n","/**\n * Generate Script's request settings: ONE reader for both DAG engines, and the\n * limits the `/v1/generate-script` route validates against.\n *\n * A run reads the node's data AFTER field mappings rewrote it, so a value can\n * arrive in a shape its field never had: a Scene Count or Duration node maps\n * its number as TEXT (\"6\"), and a Tone mapped from a Text node can be a whole\n * paragraph. Passing those on raw failed the editor's single-node run on the\n * route's 400 and sent the server run's text as-is. This reader coerces instead\n * of rejecting (the `normalizeModelInput` principle): a number-like value\n * becomes a whole number clamped to the route's range, text is trimmed and cut\n * to the route's length, and an unusable value is dropped so the generator's\n * own default applies.\n */\nimport { resolveNodeRefs } from \"./node-refs.js\"\nimport { LLM_TEXT_INPUT_MAX } from \"./model-constants.js\"\n\nexport const SCRIPT_SCENE_COUNT_RANGE = { min: 1, max: 20 } as const\nexport const SCRIPT_TARGET_DURATION_RANGE = { min: 5, max: 600 } as const\n/** What the script generator uses when a request leaves the field out. */\nexport const SCRIPT_SCENE_COUNT_DEFAULT = 5\n/** Seconds; what the script generator uses when a request leaves it out. */\nexport const SCRIPT_TARGET_DURATION_DEFAULT = 60\nexport const SCRIPT_TONE_MAX_LENGTH = 200\nexport const SCRIPT_STYLE_GUIDE_MAX_LENGTH = LLM_TEXT_INPUT_MAX\n\nexport interface ScriptSettings {\n sceneCount?: number\n tone?: string\n /** Seconds. */\n targetDuration?: number\n styleGuide?: string\n}\n\nfunction clampInt(value: unknown, range: { readonly min: number; readonly max: number }): number | undefined {\n const n = typeof value === \"number\"\n ? value\n : typeof value === \"string\" && value.trim().length > 0 ? Number(value) : Number.NaN\n if (!Number.isFinite(n)) return undefined\n return Math.min(range.max, Math.max(range.min, Math.round(n)))\n}\n\nfunction clampText(value: unknown, max: number): string | undefined {\n if (typeof value !== \"string\") return undefined\n const text = value.trim()\n return text.length > 0 ? text.slice(0, max) : undefined\n}\n\n/**\n * The settings a Generate Script node sends. `refMap` resolves `{Node Label}`\n * references in the style guide, the one field here with a reference-aware\n * editor; references with no matching node stay as typed.\n */\nexport function readScriptSettings(\n data: Record<string, unknown>,\n refMap?: ReadonlyMap<string, string>,\n): ScriptSettings {\n const styleGuide = typeof data.styleGuide === \"string\" && refMap && refMap.size > 0\n ? resolveNodeRefs(data.styleGuide, refMap)\n : data.styleGuide\n return {\n sceneCount: clampInt(data.sceneCount, SCRIPT_SCENE_COUNT_RANGE),\n // The panel's own fields (the ones a mapping writes) come first. `style` is\n // an older key for the tone, and `targetDuration` is the route's name for\n // the length, which workflow JSON written by an agent can carry.\n tone: clampText(data.tone ?? data.style, SCRIPT_TONE_MAX_LENGTH),\n targetDuration: clampInt(data.targetLength ?? data.targetDuration, SCRIPT_TARGET_DURATION_RANGE),\n styleGuide: clampText(styleGuide, SCRIPT_STYLE_GUIDE_MAX_LENGTH),\n }\n}\n","/**\n * What a JSON pip CARRIES — the handle typing behind \"an EDL is not a\n * transcript\" (decided 2026-10-07) and its reverse, \"a transcript is not an\n * EDL\" (decided 2026-10-08).\n *\n * Every JSON output colours the same \"look\" data pip, so a validator that sees\n * only the source NODE type cannot tell Edit Plan's edit list from a\n * Transcribe's transcript. Wired into Add Captions' Transcript input, the edit\n * list is accepted at connect time and only fails (or captions nothing) at run\n * time. This module is the one place that knows the difference, read by the\n * canvas validators and the server's edge normalization alike (MCP workflow\n * writes, the REST delta lane, the Copilot).\n *\n * Output kinds are DATA, never a list of node names:\n * - a render node's `json` pip answers its registry `jsonKind`\n * (`RENDER_NODE_TYPES`), so a render registered later — Speaker View, whose\n * json is an EDL — is covered by its own registry entry; its transcript pip\n * (`transcriptOutput`, Speaker View's `transcript`) is a Transcript;\n * - the other JSON producers declare a kind per output pip in\n * `JSON_OUTPUT_KINDS` below. EVERY node with a JSON output declares one\n * (decided 2026-10-08): `transcript`, `edl`, or `other` for JSON that is\n * neither (a scrape, an analysis, a collection). `other` is a positive\n * statement, not a gap — it connects exactly as an undeclared pip always\n * has. A guard test enumerates the node definitions' JSON pips and fails\n * on one with no declaration, so a new JSON node cannot ship unclassified\n * and a Transcript producer cannot slip past the EDL/Transcript block.\n * Input kinds follow the platform's handle vocabulary: a `transcript` pip\n * expects a Transcript, an `edl` pip an EDL.\n */\nimport { RENDER_JSON_HANDLE, RENDER_NODE_TYPES, type RenderNodeDescriptor } from \"./render-nodes.js\"\nimport { UGC_PRIMARY_HANDLE } from \"./ugc-node-wires.js\"\nimport { unitJsonPips } from \"./unit-contract-compose.js\"\n\n/** The two JSON shapes the platform's handle vocabulary tells apart. */\nexport type JsonKind = \"transcript\" | \"edl\"\n\n/**\n * What a JSON output pip DECLARES: one of the two kinds, or `other` — JSON that\n * is neither a Transcript nor an EDL. Only `JsonKind` ever takes part in a\n * connection check; `other` records that the pip was classified.\n */\nexport type JsonOutputDeclaration = JsonKind | \"other\"\n\ninterface JsonOutputs {\n /** The pip an edge with no `sourceHandle` reads — absent when that read is not JSON (Text to Dialogue's is its audio). */\n readonly primary?: string\n readonly pips: Readonly<Record<string, JsonOutputDeclaration>>\n}\n\n/** JSON outputs of the hand-written nodes that are not renders: pip id → what it carries. */\nconst LEGACY_JSON_OUTPUT_KINDS: Readonly<Record<string, JsonOutputs>> = Object.freeze({\n // Edit Plan: the plan on `edl` — a Tighten EDL, a clip set (`Edl[]`) or a chapter list.\n \"edit-plan\": { primary: \"edl\", pips: { edl: \"edl\" } },\n // Transcribe: its json is the normalized Transcript (its `text` pip is plain text, no kind).\n transcribe: { primary: \"json\", pips: { json: \"transcript\" } },\n // Camera Switch: the switched edit and the renamed (still a Transcript) transcript.\n \"camera-switch\": { primary: \"edl\", pips: { edl: \"edl\", transcript: \"transcript\" } },\n // Speaker Frames: the stored track file's descriptor (P3-22) — neither a\n // Transcript nor an EDL, read by Speaker View's `tracks` input (P3.9).\n \"speaker-frames\": { primary: \"tracks\", pips: { tracks: \"other\" } },\n // Text to Dialogue: the Transcript built from the model's own word timings (its default read is the audio).\n \"text-to-dialogue\": { pips: { json: \"transcript\" } },\n\n // ── JSON that is neither a Transcript nor an EDL (decided 2026-10-08) ──\n // Forced Alignment: `{ alignment: [{ word, start, end }] }` in seconds — a word list, not a Transcript.\n \"forced-alignment\": { primary: \"data\", pips: { data: \"other\" } },\n // Video Analysis / Video Audit: the canonical analysis result (an audit IS an analysis).\n \"video-analysis\": { primary: \"json\", pips: { json: \"other\" } },\n \"video-audit\": { primary: \"json\", pips: { json: \"other\" } },\n // Silence Detect: `{ version, ranges, durationMs }`. Audio Sync: `{ version, reference, offsets, notes }`.\n \"silence-detect\": { primary: \"json\", pips: { json: \"other\" } },\n \"audio-sync\": { primary: \"json\", pips: { json: \"other\" } },\n // Scrapers and searches: the scraped page / ad array / post list.\n \"web-scrape\": { primary: \"json\", pips: { json: \"other\" } },\n \"meta-ads-scrape\": { primary: \"json\", pips: { json: \"other\" } },\n \"instagram-scrape\": { primary: \"json\", pips: { json: \"other\" } },\n \"social-search\": { primary: \"json\", pips: { json: \"other\" } },\n // Site Capture: the capture's output (title, sections, stills, page facts). Its stills are its `image` pip.\n \"site-capture\": { pips: { json: \"other\" } },\n \"telegram-channel-feed\": { primary: \"json\", pips: { json: \"other\" } },\n // Content Recipe: the recipe's structured result.\n \"content-recipe\": { primary: \"json\", pips: { json: \"other\" } },\n // Collections and libraries: the stored rows, whatever the user keeps in them.\n \"collection-read\": { primary: \"json\", pips: { json: \"other\" } },\n \"collection-write\": { primary: \"json\", pips: { json: \"other\" } },\n \"inspiration-read\": { primary: \"json\", pips: { json: \"other\" } },\n \"competitor-read\": { primary: \"json\", pips: { json: \"other\" } },\n // Describe to Picker: the picker values read off an image.\n \"describe-to-picker\": { primary: \"picker-json\", pips: { \"picker-json\": \"other\" } },\n // The UGC video nodes: their own versioned JSON (a creator record, a plan, the\n // clip tickets, the sized plan), and UGC Cards' layer plan and caption plan.\n // Their text pips (category, transcript, report) are not JSON pips. The pip an\n // edge with no `sourceHandle` reads is the UGC wires' own (UGC_PRIMARY_HANDLE).\n \"ugc-creator\": { primary: UGC_PRIMARY_HANDLE[\"ugc-creator\"], pips: { creator: \"other\" } },\n \"ugc-script\": { primary: UGC_PRIMARY_HANDLE[\"ugc-script\"], pips: { plan: \"other\" } },\n \"ugc-clips\": { primary: UGC_PRIMARY_HANDLE[\"ugc-clips\"], pips: { clips: \"other\", \"plan-out\": \"other\" } },\n \"ugc-cards\": { primary: UGC_PRIMARY_HANDLE[\"ugc-cards\"], pips: { layerPlan: \"other\", captionPlan: \"other\" } },\n})\n\n/**\n * The JSON outputs of the nodes that are not renders: the hand-written table ∪\n * the node units' `contract.jsonPips` rows (generated/unit-contracts.ts). A unit\n * declares every one of its JSON pips (the validator's twin of the guard test)\n * and has no `primary`: an edge with no `sourceHandle` from a unit reads no JSON.\n */\nconst JSON_OUTPUT_KINDS: Readonly<Record<string, JsonOutputs>> = Object.freeze(composeJsonOutputs(LEGACY_JSON_OUTPUT_KINDS, unitJsonPips()))\n\n/** `legacy` with each unit row added as `{ pips }`, refusing a type that is in both (throws at load). */\nfunction composeJsonOutputs(\n legacy: Readonly<Record<string, JsonOutputs>>,\n rows: ReadonlyArray<readonly [string, Readonly<Record<string, JsonOutputDeclaration>>]>,\n): Record<string, JsonOutputs> {\n const out: Record<string, JsonOutputs> = { ...legacy }\n for (const [type, pips] of rows) {\n if (Object.hasOwn(out, type)) throw new Error(`JSON_OUTPUT_KINDS: ${type} is both a legacy entry and a node unit`)\n out[type] = { pips }\n }\n return out\n}\n\n/** The input pips whose kind is fixed by the handle vocabulary. */\nconst JSON_INPUT_KINDS: Readonly<Record<string, JsonKind>> = Object.freeze({\n transcript: \"transcript\",\n edl: \"edl\",\n})\n\nconst own = <T>(table: Readonly<Record<string, T>>, key: string): T | undefined =>\n Object.hasOwn(table, key) ? table[key] : undefined\n\n/**\n * What the JSON output `sourceHandle` of a node of `nodeType` DECLARES —\n * `transcript`, `edl`, `other` — or `undefined` when the pip is not declared at\n * all (a non-JSON pip, an unknown handle, an unregistered node). `renders` is\n * the render-node registry (injectable for tests). The guard test reads this to\n * prove every JSON pip is classified.\n */\nexport function declaredJsonOutput(\n nodeType: string | null | undefined,\n sourceHandle: string | null | undefined,\n renders: Readonly<Record<string, RenderNodeDescriptor>> = RENDER_NODE_TYPES,\n): JsonOutputDeclaration | undefined {\n if (typeof nodeType !== \"string\") return undefined\n const render = own(renders, nodeType)\n if (render) {\n const pip = sourceHandle ?? RENDER_JSON_HANDLE\n if (pip === RENDER_JSON_HANDLE) return render.jsonKind\n return pip === render.transcriptOutput.handle ? \"transcript\" : undefined\n }\n const outputs = own(JSON_OUTPUT_KINDS, nodeType)\n if (!outputs) return undefined\n const pip = sourceHandle ?? outputs.primary\n return typeof pip === \"string\" ? own(outputs.pips, pip) : undefined\n}\n\n/** The declared JSON output pips of the non-render nodes, as `[nodeType, pipId, declaration]` rows. */\nexport function declaredJsonOutputRows(): ReadonlyArray<readonly [string, string, JsonOutputDeclaration]> {\n return Object.entries(JSON_OUTPUT_KINDS).flatMap(([type, o]) =>\n Object.entries(o.pips).map(([pip, kind]) => [type, pip, kind] as const),\n )\n}\n\n/**\n * What the JSON output `sourceHandle` of a node of `nodeType` carries, or\n * `undefined` when it is not known to carry one of the two kinds (anything\n * declared `other`, a non-JSON pip, anything unregistered).\n */\nexport function jsonOutputKind(\n nodeType: string | null | undefined,\n sourceHandle: string | null | undefined,\n renders: Readonly<Record<string, RenderNodeDescriptor>> = RENDER_NODE_TYPES,\n): JsonKind | undefined {\n const declared = declaredJsonOutput(nodeType, sourceHandle, renders)\n return declared === \"other\" ? undefined : declared\n}\n\n/** What the JSON input `targetHandle` of a node expects, or `undefined`. */\nexport function jsonInputKind(\n _nodeType: string | null | undefined,\n targetHandle: string | null | undefined,\n): JsonKind | undefined {\n return typeof targetHandle === \"string\" ? own(JSON_INPUT_KINDS, targetHandle) : undefined\n}\n\nexport interface JsonKindMismatch {\n readonly output: JsonKind\n readonly input: JsonKind\n}\n\n/**\n * The connections this blocks: a JSON output of one kind wired into an input of\n * the other (decided 2026-10-07 / 2026-10-08) — an EDL into a Transcript input\n * and a Transcript into an EDL input. Both directions read the same two\n * tables. `null` for every other pair — including pairs it cannot classify,\n * which keep today's behaviour.\n */\nexport function jsonKindMismatch(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n targetType: string | null | undefined,\n targetHandle: string | null | undefined,\n renders: Readonly<Record<string, RenderNodeDescriptor>> = RENDER_NODE_TYPES,\n): JsonKindMismatch | null {\n const input = jsonInputKind(targetType, targetHandle)\n if (!input) return null\n const output = jsonOutputKind(sourceType, sourceHandle, renders)\n return output && output !== input ? { output, input } : null\n}\n\n/** The sentence a rejected connection is explained with. */\nexport function jsonKindMismatchMessage(\n mismatch: JsonKindMismatch,\n labels: { readonly sourceLabel?: string; readonly targetLabel?: string } = {},\n): string {\n const source = labels.sourceLabel ?? \"This output\"\n const target = labels.targetLabel ?? \"this node\"\n if (mismatch.output === \"transcript\") {\n return (\n `${source} outputs a transcript, not an edit list (EDL), so it cannot feed the EDL input of ${target}. ` +\n `Wire an Edit Plan's or Camera Switch's edl there instead.`\n )\n }\n return (\n `${source} outputs an edit list (EDL), not a transcript, so it cannot feed the Transcript input of ${target}. ` +\n `Wire a Transcribe node's json (or Apply EDL's or Camera Switch's transcript) there instead.`\n )\n}\n","/**\n * The preview stop rule (Track A, decided 2026-10-04): a run stops at a\n * Preview render, and nothing downstream of it runs until Render final.\n *\n * It starts at a render node (`PREVIEW_RENDER_NODE_TYPES`), or at a use-case\n * node with review on (`REVIEW_HOLDING_USE_CASE_TYPES`, whose own run ends at\n * a Preview), in either of two cases:\n * - the render EXECUTES in this run and its effective quality, after the\n * run's input overrides (`withRunOverrides`), is `proxy`;\n * - the render sits OUTSIDE the run and an item its saved output would hand\n * a consumer is a stamped Preview — decided per wire, exactly as the input\n * resolvers read it: an `each` wire reads the latest batch, any other wire\n * the selected result (`SavedRenderStampReader`).\n *\n * Everything forward of a start — through every way one node feeds another\n * (`buildFeedMaps`: edges, teleports, Group membership, field mappings) — is\n * GATED: never executed, never counted, never billed. A forward closure, not\n * router gating, so a Combine Videos fed by the render AND an intro upload\n * stops too. The invariant: no node ever consumes a preview. The render's own\n * run stays allowed — a start render is gated only when it is itself\n * downstream of another preview.\n *\n * One rule for both engines, the editor's estimates and its chip, and SDK users.\n */\nimport { buildFeedMaps } from \"./trigger-feeds.js\"\nimport { defaultEdgeOutputMode } from \"./producer-types.js\"\nimport { mergeNodeInputOverrides } from \"./presentation-utils.js\"\nimport { RENDER_NODE_TYPE_IDS } from \"./render-nodes.js\"\nimport { unitReviewHolds } from \"./unit-contract-compose.js\"\n\n/** Render nodes a run can stop at: every render in the registry (SV18). */\nexport const PREVIEW_RENDER_NODE_TYPES: ReadonlySet<string> = new Set(RENDER_NODE_TYPE_IDS)\n\n/**\n * Use-case nodes whose review-on run ends at a Preview of their own: what\n * follows them waits for their Render final, exactly as after a render at\n * Preview. They are not render nodes (`PREVIEW_RENDER_NODE_TYPES` stays the\n * renders), so they join the hold here: the node units that declare\n * `contract.reviewHold` (generated/unit-contracts.ts).\n */\nexport const REVIEW_HOLDING_USE_CASE_TYPES: ReadonlySet<string> = new Set(unitReviewHolds())\n\n/** A node whose take can be a Preview that holds what follows it. */\nexport function isPreviewHoldingType(type: string | null | undefined): boolean {\n return PREVIEW_RENDER_NODE_TYPES.has(type ?? \"\") || REVIEW_HOLDING_USE_CASE_TYPES.has(type ?? \"\")\n}\n\n/**\n * Stable refusal code: a run with nobody to review it (a trigger, an API or\n * MCP call, a present link, an app run) holds a Preview render. Set the\n * render to Final, or run with a Final override on it.\n */\nexport const PREVIEW_REVIEW_REQUIRED = \"preview_review_required\"\n\n/**\n * Stable refusal code: a sub-workflow or a component holds a Preview render.\n * A nested graph has no Render final path, so this refusal is permanent.\n */\nexport const PREVIEW_RENDER_NESTED = \"preview_render_nested\"\n\n/**\n * The same two refusals when what holds the run is not (only) a render: a\n * use-case node with \"Review before render\" on. `…_REVIEW_ON`: only such\n * nodes hold it (turn their review off); `…_MIXED`: renders at Preview and\n * such nodes both do. The two codes above stay what a render-held refusal\n * (and every older one) carries. Branch on {@link isPreviewRefusalCode}, never\n * on one code: all six mean \"this run stops for a review nobody can give\".\n */\nexport const PREVIEW_REVIEW_REQUIRED_REVIEW_ON = \"preview_review_required_review_on\"\nexport const PREVIEW_REVIEW_REQUIRED_MIXED = \"preview_review_required_mixed\"\nexport const PREVIEW_RENDER_NESTED_REVIEW_ON = \"preview_render_nested_review_on\"\nexport const PREVIEW_RENDER_NESTED_MIXED = \"preview_render_nested_mixed\"\n\nconst PREVIEW_REFUSAL_CODES: ReadonlySet<string> = new Set([\n PREVIEW_REVIEW_REQUIRED,\n PREVIEW_REVIEW_REQUIRED_REVIEW_ON,\n PREVIEW_REVIEW_REQUIRED_MIXED,\n PREVIEW_RENDER_NESTED,\n PREVIEW_RENDER_NESTED_REVIEW_ON,\n PREVIEW_RENDER_NESTED_MIXED,\n])\n\n/** Is `code` a preview refusal — a run that stops for a review nobody can give (any of the six codes)? */\nexport function isPreviewRefusalCode(code: unknown): boolean {\n return typeof code === \"string\" && PREVIEW_REFUSAL_CODES.has(code)\n}\n\n/** A node as the stop rule reads it (either engine's graph, or a saved one). */\nexport interface PreviewGateNode {\n readonly id: string\n readonly type?: string | null\n readonly data?: unknown\n readonly parentId?: string | null\n}\n\n/** A wire as the stop rule reads it. `data.outputMode` is the wire's mode. */\nexport interface PreviewGateEdge {\n readonly source: string\n readonly target: string\n readonly sourceHandle?: string | null\n readonly targetHandle?: string | null\n readonly data?: unknown\n}\n\n/** What a saved render result says about itself: `\"proxy\"` is a Preview. */\nexport interface SavedRenderQualityStamp {\n readonly quality?: string\n}\n\n/**\n * How the rule reads a saved render: the result a scalar wire receives\n * (`output`) and the rows an `each` wire iterates (`batch`, the LATEST batch\n * only — `undefined` when the render has none, and the wire then reads the one\n * result). The saved-output reader both engines use plugs in here.\n */\nexport interface SavedRenderStampReader {\n output(data: Readonly<Record<string, unknown>>): SavedRenderQualityStamp | undefined\n batch(data: Readonly<Record<string, unknown>>): ReadonlyArray<SavedRenderQualityStamp | null> | undefined\n}\n\n/** A reader that sees no stamps: every saved render reads as unstamped. */\nexport const NO_SAVED_RENDER_STAMPS: SavedRenderStampReader = {\n output: () => undefined,\n batch: () => undefined,\n}\n\n/**\n * The production reader. No render result carries a `quality` stamp until the\n * results themselves are stamped, so today it reads none and the saved-preview\n * half of the rule is inert; the stamped-result reader replaces it here, the\n * one place every caller takes it from.\n */\nexport const SAVED_RENDER_STAMPS: SavedRenderStampReader = NO_SAVED_RENDER_STAMPS\n\n/** One run's view: which nodes execute, and how saved renders are read. */\nexport interface PreviewGateRun {\n /** Does this node execute in this run? Default: every node that is not frozen (`data.skipped`). */\n readonly executes?: (nodeId: string) => boolean\n /** Default: `SAVED_RENDER_STAMPS`. */\n readonly savedRenders?: SavedRenderStampReader\n}\n\nexport interface PreviewStops {\n /** Render nodes that execute in this run at Preview quality (and review-on use-case nodes). */\n readonly previewRenderIds: readonly string[]\n /** Render nodes outside the run whose saved output hands a Preview on (and\n * review-on use-case nodes whose saved take is a Preview, stamped `proxy`). */\n readonly savedPreviewRenderIds: readonly string[]\n /** Every node that would consume a preview: never executed in this run. */\n readonly gatedNodeIds: ReadonlySet<string>\n}\n\ntype Data = Readonly<Record<string, unknown>>\n\nconst dataOf = (n: PreviewGateNode): Data =>\n (n.data && typeof n.data === \"object\" ? n.data : {}) as Data\n\nconst isPreviewStamp = (stamp: SavedRenderQualityStamp | null | undefined): boolean => stamp?.quality === \"proxy\"\n\n/**\n * A node that renders a Preview in this run: a render node whose quality\n * (after any run overrides) is `proxy`, or a use-case node with review on\n * that does not run as its own Render final — the continuation a Render final\n * sets on it for that run only (`useCaseContinue`, render-final, naming the\n * run it finishes), which renders the final and releases what follows.\n */\nexport function rendersAsPreview(node: PreviewGateNode): boolean {\n const data = dataOf(node)\n if (REVIEW_HOLDING_USE_CASE_TYPES.has(node.type ?? \"\")) {\n const cont = data.useCaseContinue as { mode?: unknown; jobId?: unknown } | null | undefined\n const rendersFinal = cont?.mode === \"render-final\" && typeof cont.jobId === \"string\"\n return data.reviewBeforeRender === true && !rendersFinal\n }\n return PREVIEW_RENDER_NODE_TYPES.has(node.type ?? \"\") && data.quality === \"proxy\"\n}\n\nconst TELEPORT_TYPES: ReadonlySet<string> = new Set([\"teleport-send\", \"teleport-receive\"])\nconst isTeleport = (n: PreviewGateNode | undefined): boolean => TELEPORT_TYPES.has(n?.type ?? \"\")\n\nconst outputModeOf = (edge: PreviewGateEdge): string | undefined => {\n const mode = edge.data && typeof edge.data === \"object\" ? (edge.data as { outputMode?: unknown }).outputMode : undefined\n return typeof mode === \"string\" ? mode : undefined\n}\n\n/**\n * Does a consumer's wire read the render's latest batch, as the resolvers\n * decide it? The consumer-side wire's own mode, else the default for the real\n * source (the render) on the render-side handle. Through a teleport pair the\n * consumer's wire is the one leaving the last teleport, and the render-side\n * handle is the one on the render → teleport wire.\n */\nfunction readsEach(render: PreviewGateNode, consumerEdge: PreviewGateEdge, renderHandle: string | null | undefined): boolean {\n return (outputModeOf(consumerEdge) ?? defaultEdgeOutputMode(render.type, renderHandle)) === \"each\"\n}\n\n/**\n * The consumers a saved render hands a Preview to (empty when it hands none).\n * A teleport pair is transparent, exactly as the input resolvers walk it: the\n * nodes reached through it are decided per consumer wire, so a teleport fanning\n * out to an `each` and a scalar consumer stops only the one reading a Preview.\n */\nfunction savedPreviewConsumers(\n render: PreviewGateNode,\n children: ReadonlyMap<string, readonly string[]>,\n nodeById: ReadonlyMap<string, PreviewGateNode>,\n edges: readonly PreviewGateEdge[],\n reader: SavedRenderStampReader,\n): string[] {\n const data = dataOf(render)\n const scalarIsPreview = isPreviewStamp(reader.output(data))\n const batch = reader.batch(data)\n const eachIsPreview = batch ? batch.some(isPreviewStamp) : scalarIsPreview\n const out = new Set<string>()\n const visited = new Set<string>([render.id])\n // (node a Preview may reach, the render-side handle it travels on)\n const walk = (from: string, renderHandle: string | null | undefined, isRender: boolean): void => {\n const wires = edges.filter((e) => e.source === from)\n for (const child of children.get(from) ?? []) {\n const wiresToChild = wires.filter((e) => e.target === child)\n if (isTeleport(nodeById.get(child))) {\n if (visited.has(child)) continue\n visited.add(child)\n // Leaving the render, the wire into the teleport names the handle;\n // past it the handle is the one already carried.\n if (isRender && wiresToChild.length > 0) for (const w of wiresToChild) walk(child, w.sourceHandle, false)\n else walk(child, renderHandle, false)\n continue\n }\n // A child fed with no wire (Group membership, a field mapping) reads the\n // render's one result, as a scalar wire does.\n const preview =\n wiresToChild.length === 0\n ? scalarIsPreview\n : wiresToChild.some((e) =>\n readsEach(render, e, isRender ? e.sourceHandle : renderHandle) ? eachIsPreview : scalarIsPreview,\n )\n if (preview) out.add(child)\n }\n }\n walk(render.id, undefined, true)\n return [...out]\n}\n\n/** The stop rule: where this run stops, and everything it does not run. */\nexport function previewStops(\n nodes: readonly PreviewGateNode[],\n edges: readonly PreviewGateEdge[],\n run: PreviewGateRun = {},\n): PreviewStops {\n const nodeById = new Map(nodes.map((n) => [n.id, n]))\n const executes =\n run.executes ?? ((id: string) => { const n = nodeById.get(id); return !!n && dataOf(n).skipped !== true })\n const reader = run.savedRenders ?? SAVED_RENDER_STAMPS\n const { children } = buildFeedMaps(nodes, edges)\n const previewRenderIds: string[] = []\n const savedPreviewRenderIds: string[] = []\n const seeds: string[] = []\n for (const n of nodes) {\n if (!isPreviewHoldingType(n.type)) continue\n const kids = children.get(n.id) ?? []\n if (executes(n.id)) {\n if (!rendersAsPreview(n)) continue\n previewRenderIds.push(n.id)\n seeds.push(...kids)\n } else {\n const consumers = savedPreviewConsumers(n, children, nodeById, edges, reader)\n if (consumers.length === 0) continue\n savedPreviewRenderIds.push(n.id)\n seeds.push(...consumers)\n }\n }\n const gated = new Set<string>()\n const queue = [...seeds]\n while (queue.length > 0) {\n const id = queue.shift()!\n if (gated.has(id)) continue\n gated.add(id)\n for (const next of children.get(id) ?? []) if (!gated.has(next)) queue.push(next)\n }\n return { previewRenderIds, savedPreviewRenderIds, gatedNodeIds: gated }\n}\n\n/** The nodes this run does not execute because they would consume a preview. */\nexport function previewGatedNodeIds(\n nodes: readonly PreviewGateNode[],\n edges: readonly PreviewGateEdge[],\n run?: PreviewGateRun,\n): Set<string> {\n return new Set(previewStops(nodes, edges, run).gatedNodeIds)\n}\n\n/** Does this run hold anything a reviewer would have to review: a Preview\n * render it executes, or a saved Preview it hands on? */\nexport function holdsPreviewRender(\n nodes: readonly PreviewGateNode[],\n edges: readonly PreviewGateEdge[],\n run?: PreviewGateRun,\n): boolean {\n const stops = previewStops(nodes, edges, run)\n return stops.previewRenderIds.length > 0 || stops.savedPreviewRenderIds.length > 0\n}\n\n/**\n * The fields a run's input override clears from the node it overrides, so a\n * fresh input wins over a cached result. The server's merge and\n * `withRunOverrides` both clear exactly these.\n */\nexport const RUN_OVERRIDE_CLEARED_FIELDS = [\n \"generatedResults\",\n \"activeResultIndex\",\n \"generatedImageUrl\",\n \"generatedVideoUrl\",\n \"generatedAudioUrl\",\n \"generatedText\",\n] as const\n\n/**\n * Node fields set for ONE run only, by that run's input override: a use-case\n * node's continuation of an earlier run (`useCaseContinue` — a Render final, a\n * Continue). Never saved (`TRANSIENT_RUNTIME_KEYS`); one found on a saved graph\n * is stale, and every reader ignores it — the server's engine drops it before\n * its override merge, and `withRunOverrides` before its own.\n */\nexport const RUN_ONLY_NODE_FIELDS = [\"useCaseContinue\"] as const\n\n/** `data` without its saved run-only fields, or `data` itself when it holds none. */\nfunction withoutRunOnlyFields(data: Data): Data {\n if (!RUN_ONLY_NODE_FIELDS.some((key) => key in data)) return data\n const kept: Record<string, unknown> = { ...data }\n for (const key of RUN_ONLY_NODE_FIELDS) delete kept[key]\n return kept\n}\n\n/**\n * The graph a run executes once its input overrides (`{ [nodeId]: fields }`)\n * are merged: the same merge as the server's — a node's saved run-only fields\n * (`RUN_ONLY_NODE_FIELDS`) dropped first, so only THIS run's override can set\n * one; then the shallow merge, clearing the overridden node's saved results.\n * Never mutates; a node with no override and no saved run-only field is\n * returned as is. Render final is a run with `{ [renderId]: { quality: \"final\" } }`.\n *\n * Apply it ONCE, to the saved graph: on a graph it already produced it would\n * drop the continuation that run's override set. With no overrides it is the\n * saved graph as a plain run reads it.\n */\nexport function withRunOverrides<N extends PreviewGateNode>(\n nodes: readonly N[],\n overrides: Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined,\n): N[] {\n return nodes.map((n) => {\n const saved = dataOf(n)\n const data = withoutRunOnlyFields(saved)\n const fields = overrides?.[n.id]\n if (!fields) return data === saved ? n : { ...n, data }\n const merged = mergeNodeInputOverrides(n.type ?? undefined, { ...data }, { ...fields })\n for (const key of RUN_OVERRIDE_CLEARED_FIELDS) delete merged[key]\n return { ...n, data: merged }\n })\n}\n","import { UNIT_USE_CASE_TYPES } from \"./generated/unit-contracts.js\"\n\n/**\n * The use-case node types — each a route (`POST /v1/<type>`, `/estimate`,\n * and `POST /v1/<type>/continue` to continue one of its runs): the node units\n * whose execution.kind is \"use-case\" (generated/unit-contracts.ts), in their\n * position order, the order every list of the types shows.\n */\nexport const USE_CASE_NODE_TYPES = UNIT_USE_CASE_TYPES\nexport type UseCaseNodeType = (typeof USE_CASE_NODE_TYPES)[number]\n\n/** Is `type` a use-case node type? Anything that is not one of the strings above is not (an object key like \"constructor\" included). */\nexport function isUseCaseNodeType(type: unknown): type is UseCaseNodeType {\n return typeof type === \"string\" && (USE_CASE_NODE_TYPES as readonly string[]).includes(type)\n}\n\nif (new Set(USE_CASE_NODE_TYPES).size !== USE_CASE_NODE_TYPES.length) {\n throw new Error(`USE_CASE_NODE_TYPES: ${USE_CASE_NODE_TYPES.join(\", \")} lists a type twice — a type is one node unit`)\n}\n","/**\n * A run CONTINUED from an earlier execution (`continueFromExecutionId` on\n * `POST /v1/workflows/:id/run`): the nodes it does not run hand on what that\n * execution produced, never the workflow's saved results. Render final after a\n * run that stopped at a preview is one, and an app's Render final runs as one,\n * outside the app run.\n *\n * The stable codes a continuation is refused with. A client branches on the\n * code, never on the text.\n */\n\n/** The execution does not exist, or the caller did not start it. */\nexport const CONTINUATION_NOT_FOUND = \"continuation_not_found\"\n\n/** The execution ran another workflow. */\nexport const CONTINUATION_WORKFLOW_MISMATCH = \"continuation_workflow_mismatch\"\n\n/** The execution ran another version of the graph: a published app version\n * where this run uses the live workflow, or the reverse, or another version. */\nexport const CONTINUATION_VERSION_MISMATCH = \"continuation_version_mismatch\"\n\n/** The execution has not ended `completed` (it is still running, or it\n * failed or was cancelled). */\nexport const CONTINUATION_NOT_COMPLETED = \"continuation_not_completed\"\n\n/** A continuation names the nodes it runs (`nodeIds`); every other node hands\n * on the execution's output. */\nexport const CONTINUATION_SUBSET_REQUIRED = \"continuation_subset_required\"\n\n/** A continue-from-failed run (a use-case node's, or a saved workflow's) needs\n * an execution that ended `failed`: a completed run has nothing to resume, a\n * running one is not over. */\nexport const CONTINUATION_NOT_FAILED = \"continuation_not_failed\"\n\n/** A continue-from-failed of a run a later continuation of it has superseded\n * — that later one failed too: continue it instead. A saved workflow's run\n * also answers it when a later continuation completed everything the run left\n * (the work is done; its results are on that run). */\nexport const CONTINUATION_SUPERSEDED = \"continuation_superseded\"\n\n/** A continue-from-failed of a saved workflow's run whose lineage's newest\n * continuation COMPLETED by stopping at a Preview review — of an Apply EDL\n * render, or of a use-case node with review on (Tighten Episode): continuing\n * again would only stop at the same Preview. The answer names that execution\n * (`executionId`), its renders (`renderNodeIds`) and its use-case nodes\n * (`reviewNodeIds`), and the run that finishes them (`next`:\n * `continueFromExecutionId`, `nodeIds`, `inputOverrides`, to send to `/run`):\n * for one render, its Render final (`renderFinal` with\n * `continueFromExecutionId` set to that execution) is the same run. A\n * continue-from-failed after it builds on that run. */\nexport const CONTINUATION_PREVIEW_PENDING = \"continuation_preview_pending\"\n\n/** A continue-from-failed (use-case nodes) of a failed run whose wrapper is not\n * settled yet (its fee not yet refunded): ask again in a moment. A retry\n * answer, not a refusal — outside `RUN_CONTINUATION_CODES`. */\nexport const CONTINUATION_SETTLING = \"continuation_settling\"\n\n/** A Render final (use-case nodes) of a preview with the very edit a COMPLETED\n * final of it already rendered (decided 2026-10-13): nothing would change, so\n * nothing runs — the answer names that final. A changed edit renders again. */\nexport const RENDER_FINAL_ALREADY_RENDERED = \"render_final_already_rendered\"\nexport const RENDER_FINAL_ALREADY_RENDERED_MESSAGE = \"Already rendered with this edit.\"\n\n/** A Render final (use-case nodes) of a clip pack whose review dropped every\n * clip: there is nothing to render, so nothing runs and nothing is charged.\n * A refusal of the request, outside `RUN_CONTINUATION_CODES`. */\nexport const USE_CASE_NOTHING_KEPT = \"use_case_nothing_kept\"\nexport const USE_CASE_NOTHING_KEPT_MESSAGE = \"Every clip was dropped in the review: keep at least one clip to render the final.\"\n\n/** Every continuation refusal code. */\nexport const RUN_CONTINUATION_CODES = [\n CONTINUATION_NOT_FOUND,\n CONTINUATION_WORKFLOW_MISMATCH,\n CONTINUATION_VERSION_MISMATCH,\n CONTINUATION_NOT_COMPLETED,\n CONTINUATION_SUBSET_REQUIRED,\n CONTINUATION_NOT_FAILED,\n CONTINUATION_SUPERSEDED,\n CONTINUATION_PREVIEW_PENDING,\n] as const\n\nexport type RunContinuationCode = (typeof RUN_CONTINUATION_CODES)[number]\n","/**\n * Render final for agents (`renderFinal: { renderNodeId }` on\n * `POST /v1/workflows/:id/run`, the SDK's `workflows.renderFinal`, MCP\n * `render_final`; decided 2026-10-06). The server derives the nodes the run\n * executes and the render's one-shot Final override from the saved graph.\n *\n * The stable codes a Render final request is refused with when the node it\n * names cannot be rendered. A client branches on the code, never on the text.\n */\n\n/** The workflow has no node with that id. */\nexport const RENDER_FINAL_NODE_NOT_FOUND = \"render_final_node_not_found\"\n\n/** The node is not a render a Render final can run (an Apply EDL render). */\nexport const RENDER_FINAL_NOT_A_RENDER = \"render_final_not_a_render\"\n\n/** Every Render final refusal code. */\nexport const RENDER_FINAL_CODES = [RENDER_FINAL_NODE_NOT_FOUND, RENDER_FINAL_NOT_A_RENDER] as const\n\nexport type RenderFinalCode = (typeof RENDER_FINAL_CODES)[number]\n","/**\n * The ONE rule both engines use when a text-shaped wire reaches a social post:\n * a value that is exactly one media LINK — and nothing else — carries the\n * medium, not the caption. An Extract Field over a saved record's cover posts\n * the picture; a page link, a sentence with a link in it, a JSON value or a\n * format no platform posts stays the caption (decided 2026-10-08).\n *\n * The file name is read from the parsed URL's PATH, anchored at its end: a host\n * that merely contains a file ending (`movistar.es`, `webmd.com`, `gifs.com`)\n * or a file name in the query (`?img=a.png`) is a page link. Only the formats\n * the platforms accept count — avif / heic / svg / bmp are not pictures to\n * Telegram, X or Instagram and would fail the post.\n */\nimport { AUDIO_PRODUCER_TYPES, DYNAMIC_PRODUCER_TYPES, IMAGE_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from \"./producer-types.js\"\nimport { ENTITY_NODE_KINDS } from \"./entity-node-fields.js\"\n\nexport type LoneMediaUrlKind = \"image\" | \"video\"\n\nconst IMAGE_FILE_RE = /\\.(png|jpe?g|gif|webp)$/i\nconst VIDEO_FILE_RE = /\\.(mp4|mov|webm|m4v)$/i\n\n/** Which medium a text value is when its WHOLE value is one media link; `null`\n * for anything else (empty, several words, a comma-joined pair of links, a\n * page link, a file ending in the host or the query, an unsupported format). */\nexport function loneMediaUrlKind(value: string): LoneMediaUrlKind | null {\n const s = value.trim()\n if (s.length === 0 || /[\\s,]/.test(s) || !/^https?:\\/\\//i.test(s)) return null\n let pathname: string\n try {\n pathname = new URL(s).pathname\n } catch {\n return null\n }\n if (IMAGE_FILE_RE.test(pathname)) return \"image\"\n if (VIDEO_FILE_RE.test(pathname)) return \"video\"\n return null\n}\n\n/** A trigger whose ONE wire carries a message's text AND its medium (the\n * caption and the photo of an incoming Telegram message): both engines route\n * the two together from the message itself, so the wire's single value is\n * never read as \"one media link\". */\nconst MESSAGE_TRIGGER_TYPES: ReadonlySet<string> = new Set([\"telegram-trigger\", \"telegram-account-trigger\"])\n\n/** A source whose wire a social post reads as TEXT: not a declared image, video\n * or audio producer, not a dynamic (multi-typed) one such as List — whose typed\n * columns route by column type — not a message trigger, and not an entity\n * whose picture is a reference. Derived from the producer sets, so a new text\n * node is covered and a new media node (which must join its producer set to\n * connect at all) is excluded, with nothing to remember. */\nexport function isLoneMediaLinkSource(nodeType: string | null | undefined): boolean {\n if (!nodeType) return false\n if (IMAGE_PRODUCER_TYPES.has(nodeType) || VIDEO_PRODUCER_TYPES.has(nodeType) || AUDIO_PRODUCER_TYPES.has(nodeType)) return false\n if (DYNAMIC_PRODUCER_TYPES.has(nodeType) || MESSAGE_TRIGGER_TYPES.has(nodeType)) return false\n if ((ENTITY_NODE_KINDS as readonly string[]).includes(nodeType) || nodeType === \"face\") return false\n return true\n}\n","/**\n * Collections — where a workflow's records live (decided 2026-10-05).\n *\n * A collection belongs to one person and holds records: a title, a text, a\n * link, the links of its pictures / videos / sounds, a small bag of extra\n * fields and where the record came from. Text and links only — never files;\n * a media link from a platform expires on its own schedule, so a consumer\n * that needs the picture later copies it (an upload node), the collection\n * keeps the link as given.\n *\n * Why public: `Collection` / `CollectionRecord` are what `/v1/collections`\n * returns and the SDK's `collections` resource types; the caps are what the\n * page and the API quote; the digest and the ingest map are the ONE rule the\n * read node, MCP and the CLI render records with.\n */\n\nimport { loneMediaUrlKind } from \"./lone-media-url.js\"\n\nexport const COLLECTION_NAME_MAX = 80\nexport const COLLECTION_DESCRIPTION_MAX = 500\nexport const COLLECTION_RECORD_TITLE_MAX = 500\nexport const COLLECTION_RECORD_TEXT_MAX = 20_000\nexport const COLLECTION_RECORD_URL_MAX = 2_000\nexport const COLLECTION_RECORD_MEDIA_MAX = 20\nexport const COLLECTION_RECORD_FIELDS_MAX = 50\nexport const COLLECTION_RECORD_FIELDS_BYTES_MAX = 16 * 1024\nexport const COLLECTION_DEDUPE_KEY_MAX = 300\nexport const COLLECTION_IDEMPOTENCY_KEY_MAX = 200\n/** Records per page of `GET /v1/collections/:id/records`. */\nexport const COLLECTIONS_PAGE_MAX = 100\nexport const COLLECTIONS_PAGE_DEFAULT = 50\n/** The longest a headline (a record's one-line name) gets. */\nexport const COLLECTION_HEADLINE_MAX = 120\n\nexport const COLLECTION_MEDIA_TYPES = [\"image\", \"video\", \"audio\", \"link\"] as const\nexport type CollectionMediaType = (typeof COLLECTION_MEDIA_TYPES)[number]\n\nexport interface CollectionMedia {\n readonly type: CollectionMediaType\n /** The file's link, as given (never fetched, never copied). */\n readonly url: string\n /** A video's poster frame, when known. */\n readonly posterUrl?: string\n}\n\n/** How many collections a person may have, and how many records each may hold. */\nexport interface CollectionCaps {\n readonly collections: number\n readonly records: number\n}\n\n/**\n * Caps by effective tier (decided 2026-10-05: open to free accounts; past the\n * records cap the OLDEST records are evicted, never the write refused — a\n * scheduled pipeline must not stall silently). `payg` is a derived tier whose\n * entitlements are basic's; `enterprise` reads as business.\n *\n * A tier this table does not know has NO caps here (`collectionCapsForTier`\n * answers undefined): the API then holds the account to no cap rather than to\n * free's, because the cap is enforced by DELETING records — a new tier or a\n * misspelt one must never cost a paying account its records. Add the tier.\n */\nexport const COLLECTION_TIER_CAPS: Readonly<Record<string, CollectionCaps>> = {\n free: { collections: 3, records: 500 },\n payg: { collections: 10, records: 5_000 },\n basic: { collections: 10, records: 5_000 },\n standard: { collections: 30, records: 20_000 },\n pro: { collections: 100, records: 100_000 },\n business: { collections: 300, records: 250_000 },\n enterprise: { collections: 300, records: 250_000 },\n}\n\nexport function collectionCapsForTier(tier: string | null | undefined): CollectionCaps | undefined {\n return tier ? COLLECTION_TIER_CAPS[tier] : undefined\n}\n\nexport interface Collection {\n readonly id: string\n readonly name: string\n readonly description: string\n readonly recordCount: number\n /** How many of its records have been used (`usedAt` set) and are not in the Trash. On the one-collection read; a server before the usage migration leaves it out. */\n readonly usedCount?: number\n /** How many of its records are in the Trash. On the one-collection read; a server before the usage migration leaves it out. `recordCount` counts them too (they still count toward the cap). */\n readonly trashCount?: number\n readonly createdAt: string\n readonly updatedAt: string\n}\n\n/** Where a record came from — a node in a run, or a direct write. The same shape says who USED it. */\nexport interface CollectionRecordSource {\n readonly via?: \"api\" | \"mcp\" | \"node\" | \"ui\"\n readonly nodeType?: string\n readonly workflowId?: string\n readonly executionId?: string\n readonly nodeId?: string\n /** Read-side enrichment: the workflow's name and project, looked up when the records are listed. Ignored on a write. */\n readonly workflowName?: string\n readonly projectId?: string\n}\n\nexport type CollectionFieldValue = string | number | boolean\n\n/** Which records a list or a read returns: every record, the ones not used yet, or the ones used. */\nexport const COLLECTION_USAGES = [\"all\", \"unused\", \"used\"] as const\nexport type CollectionUsage = (typeof COLLECTION_USAGES)[number]\n\nexport interface CollectionRecord {\n readonly id: string\n readonly collectionId: string\n readonly title: string\n readonly text: string\n readonly url: string | null\n readonly media: readonly CollectionMedia[]\n readonly fields: Readonly<Record<string, CollectionFieldValue>>\n /** The normalized key the collection deduplicates on (defaults to the link); null when the record has none. */\n readonly dedupeKey: string | null\n readonly source: CollectionRecordSource\n readonly createdAt: string\n /** When the record was used (a Save to Collection node with \"mark the item as used\", the API, the page) — null until then. A server before the usage migration leaves it out. */\n readonly usedAt?: string | null\n /** Who used it, in the shape of `source`; empty until then. */\n readonly usedBy?: CollectionRecordSource\n /** When the record was moved to the Trash (a delete on the page, the API or the CLI); null while it is live. A server before the usage migration leaves it out. */\n readonly deletedAt?: string | null\n}\n\n/** Which records a list returns: the live ones (`active`, the default) or the ones in the Trash. Nodes, exports and MCP read the live ones only. */\nexport const COLLECTION_RECORD_STATUSES = [\"active\", \"trash\"] as const\nexport type CollectionRecordStatus = (typeof COLLECTION_RECORD_STATUSES)[number]\n\n/** The most records one bulk call (`POST /v1/collections/:id/records/bulk`) touches. */\nexport const COLLECTION_BULK_MAX = 100\n/** The actions of a bulk call: move the records to the Trash, bring them back, or delete records already in the Trash for good. */\nexport const COLLECTION_BULK_ACTIONS = [\"trash\", \"restore\", \"delete\"] as const\nexport type CollectionBulkAction = (typeof COLLECTION_BULK_ACTIONS)[number]\n/** The most records a numbered page may skip (`offset`) — past any page a person turns to, within the largest cap. */\nexport const COLLECTION_RECORDS_OFFSET_MAX = 1_000_000\n\n/** The body of `POST /v1/collections/:id/records/bulk`. */\nexport type BulkCollectionRecordsInput = {\n readonly ids: readonly string[]\n readonly action: CollectionBulkAction\n}\n\nexport interface BulkCollectionRecordsResult {\n /** How many of the ids were the caller's records in that collection and changed (a record already in the asked state is not counted). */\n readonly updated: number\n}\n\n/** The caller's limits as the API quotes them: `null` is \"no limit\" (a\n * self-hosted server with no ceiling configured, or a tier the caps table\n * does not know). */\nexport interface CollectionLimits {\n readonly collections: number | null\n readonly records: number | null\n}\n\n/** The answer of `GET /v1/collections`. `available` is false on a server whose\n * database does not have collections yet (the data is then empty). */\nexport interface ListCollectionsResult {\n readonly data: readonly Collection[]\n readonly available: boolean\n /** The caller's limits, so a client never carries its own copy of the tier table. */\n readonly caps: CollectionLimits\n}\n\nexport type CreateCollectionInput = {\n readonly name: string\n readonly description?: string\n}\n\nexport type UpdateCollectionInput = {\n readonly name?: string\n readonly description?: string\n}\n\n/** Query of `GET /v1/collections/:id/records`. */\nexport type ListCollectionRecordsParams = {\n /** Words to find in the title, the text or the link. */\n readonly q?: string\n /** Only records saved at or after this ISO timestamp (date and time). */\n readonly since?: string\n /** Only records saved before this ISO timestamp (date and time). */\n readonly until?: string\n /** `all` (default), `unused` (not used yet) or `used`. */\n readonly usage?: CollectionUsage\n /** `newest` (default) or `oldest` first. */\n readonly order?: \"newest\" | \"oldest\"\n /** `active` (default: the live records) or `trash`. */\n readonly status?: CollectionRecordStatus\n /** The `nextCursor` of the previous page. Not together with `offset`. */\n readonly cursor?: string\n /** Skip this many records first (0–`COLLECTION_RECORDS_OFFSET_MAX`; a numbered page is `offset = (page - 1) × limit`). Not together with `cursor`; the result then carries `total`. */\n readonly offset?: number\n /** 1–100, default 50. */\n readonly limit?: number\n}\n\n/** The body of `PATCH /v1/collections/:id/records/:recordId`: mark a record used (or not used again). */\nexport type SetCollectionRecordUsedInput = {\n readonly used: boolean\n /** Who is marking it; the API fills `via` when absent. */\n readonly source?: CollectionRecordSource\n}\n\nexport interface ListCollectionRecordsResult {\n readonly data: readonly CollectionRecord[]\n readonly nextCursor: string | null\n /** How many records match the filters in all (a numbered page is `ceil(total / limit)` pages). Only on a page asked for by `offset`, and left out when the server could not count. */\n readonly total?: number\n}\n\n/** The body of `POST /v1/collections/:id/records`. An explicit field wins over\n * what `item` (any JSON — a feed post, a search result, an LLM's object) maps to. */\nexport type AddCollectionRecordInput = {\n readonly title?: string\n readonly text?: string\n readonly url?: string\n readonly media?: readonly CollectionMedia[]\n readonly fields?: Readonly<Record<string, CollectionFieldValue>>\n readonly dedupeKey?: string\n readonly source?: CollectionRecordSource\n readonly item?: unknown\n}\n\nexport type CollectionWriteOutcome = \"inserted\" | \"duplicate\" | \"replayed\"\n\nexport interface AddCollectionRecordResult {\n readonly record: CollectionRecord\n readonly outcome: CollectionWriteOutcome\n /** Records evicted past the collection's cap by this write. */\n readonly evicted: number\n}\n\nexport type CollectionExportFormat = \"csv\" | \"json\"\nexport type CollectionDigestFormat = \"headlines\" | \"full\"\nexport const COLLECTION_DIGEST_SEPARATOR = \"\\n\\n---\\n\\n\"\n\n/** The Read Collection node: how far back it may look (720 hours = 30 days; `days` × 24 is held to the same ceiling) and how many records one run emits. */\nexport const COLLECTION_READ_WINDOW_HOURS_MAX = 720\nexport const COLLECTION_READ_LIMIT_MAX = 200\nexport type CollectionReadWindowUnit = \"hours\" | \"days\"\nexport type CollectionReadOrder = \"newest\" | \"oldest\"\n\n/** The start of a Read Collection window, as an ISO timestamp — `amount` × `unit` back from `now`, held to the ceiling. */\nexport function collectionReadSince(amount: number, unit: CollectionReadWindowUnit, now = Date.now()): string {\n const hours = Math.min(COLLECTION_READ_WINDOW_HOURS_MAX, Math.max(1, Math.floor(Number.isFinite(amount) ? amount : 24)) * (unit === \"days\" ? 24 : 1))\n return new Date(now - hours * 3_600_000).toISOString()\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null && !Array.isArray(v)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" && v.trim().length > 0 ? v : undefined)\nconst isScalar = (v: unknown): v is CollectionFieldValue =>\n typeof v === \"string\" || (typeof v === \"number\" && Number.isFinite(v)) || typeof v === \"boolean\"\n\n/** A link a record may hold: `http(s)`, no whitespace, at most 2,000 characters. */\nexport function isCollectionUrl(v: unknown): v is string {\n return typeof v === \"string\" && /^https?:\\/\\/\\S+$/i.test(v) && v.length <= COLLECTION_RECORD_URL_MAX\n}\nconst isHttpUrl = isCollectionUrl\n\n/**\n * The first `max` characters of a text, counted as Postgres counts them\n * (`char_length`: code points), so a cut never splits a surrogate pair into a\n * lone half the database refuses.\n */\nexport function clampChars(text: string, max: number): string {\n if (text.length <= max) return text\n const points = Array.from(text)\n return points.length <= max ? text : points.slice(0, max).join(\"\")\n}\n\n/**\n * A Save to Collection field held to the record route's limit — the ONE rule\n * both engines apply to a field whose `{Node}` references resolved to more\n * than was typed: a title, text or duplicate key is cut to whole characters\n * (as the store cuts an item's), and a link over the limit is not sent at all\n * (a cut link is a wrong link; the item's own link then wins).\n */\nexport function fitCollectionField(key: \"title\" | \"text\" | \"link\" | \"dedupeKey\", value: string): string | undefined {\n switch (key) {\n case \"title\":\n return clampChars(value, COLLECTION_RECORD_TITLE_MAX)\n case \"text\":\n return clampChars(value, COLLECTION_RECORD_TEXT_MAX)\n case \"dedupeKey\":\n return clampChars(value, COLLECTION_DEDUPE_KEY_MAX)\n case \"link\":\n return value.length <= COLLECTION_RECORD_URL_MAX ? value : undefined\n }\n}\n\n/**\n * The key a collection deduplicates on: trimmed, inner whitespace collapsed,\n * lower-cased, at most 300 characters; null when there is nothing to key on.\n */\nexport function normalizeDedupeKey(raw: unknown): string | null {\n if (typeof raw === \"number\" && Number.isFinite(raw)) raw = String(raw)\n if (typeof raw !== \"string\") return null\n const compact = raw.trim().replace(/\\s+/g, \" \")\n // A link keeps its path's case: a short link or a video id is case-sensitive\n // (bit.ly/AbC and bit.ly/abc are two pages). Only its scheme and host are\n // case-insensitive, and the URL parser folds exactly those.\n const key = clampChars(looksLikeLink(compact) ? canonicalUrl(compact) : compact.toLowerCase(), COLLECTION_DEDUPE_KEY_MAX).trim()\n return key.length > 0 ? key : null\n}\n\n// A boolean wrapper: the type guard would narrow the string to `never` in the else branch.\nconst looksLikeLink = (s: string): boolean => isCollectionUrl(s)\n\n/**\n * How many records one write may evict past the cap. A cap that drops at once\n * (a lapsed subscription, billing briefly reading \"free\") then trims a big\n * collection a little per write instead of deleting most of it in one go.\n */\nexport const COLLECTION_EVICT_MAX_PER_WRITE = 100\n\nfunction canonicalUrl(url: string): string {\n try {\n return new URL(url).href\n } catch {\n return url\n }\n}\n\nexport function isCollectionMedia(v: unknown): v is CollectionMedia {\n return (\n isRecord(v) &&\n (COLLECTION_MEDIA_TYPES as readonly string[]).includes(v.type as string) &&\n isHttpUrl(v.url) &&\n (v.posterUrl === undefined || v.posterUrl === null || isHttpUrl(v.posterUrl))\n )\n}\n\n/** The media list as stored: known kinds with http(s) links, no repeats, at most 20. */\nexport function normalizeCollectionMedia(value: unknown): CollectionMedia[] {\n if (!Array.isArray(value)) return []\n const seen = new Set<string>()\n const out: CollectionMedia[] = []\n for (const item of value) {\n if (out.length >= COLLECTION_RECORD_MEDIA_MAX) break\n if (!isCollectionMedia(item) || seen.has(item.url)) continue\n seen.add(item.url)\n out.push({ type: item.type, url: item.url, ...(item.posterUrl ? { posterUrl: item.posterUrl } : {}) })\n }\n return out\n}\n\n/** The extra fields as stored: scalar values only, at most 50 keys and 16 KB. */\nexport function normalizeCollectionFields(value: unknown): Record<string, CollectionFieldValue> {\n if (!isRecord(value)) return {}\n const out: Record<string, CollectionFieldValue> = {}\n let bytes = 2\n let count = 0\n for (const [key, v] of Object.entries(value)) {\n if (count >= COLLECTION_RECORD_FIELDS_MAX) break\n if (!isScalar(v) || key.length === 0 || key.length > 100) continue\n const entry = JSON.stringify(key) + \":\" + JSON.stringify(v) + \",\"\n if (bytes + entry.length > COLLECTION_RECORD_FIELDS_BYTES_MAX) break\n out[key] = v\n bytes += entry.length\n count += 1\n }\n return out\n}\n\n/**\n * A record's one-line name: its title, else the first line of its text, else\n * its link. Tolerates a partial record (a hand-written node result in workflow\n * JSON): a missing field reads as empty rather than throwing on the canvas.\n */\nexport function collectionRecordHeadline(record: Partial<Pick<CollectionRecord, \"title\" | \"text\" | \"url\">>): string {\n const title = (typeof record.title === \"string\" ? record.title : \"\").trim()\n if (title) return clampChars(title, COLLECTION_HEADLINE_MAX)\n const line = (typeof record.text === \"string\" ? record.text : \"\")\n .split(/\\r?\\n/)\n .map((l) => l.trim())\n .find((l) => l.length > 0)\n if (line) return line.length > COLLECTION_HEADLINE_MAX ? `${clampChars(line, COLLECTION_HEADLINE_MAX - 1)}…` : line\n return typeof record.url === \"string\" ? record.url : \"\"\n}\n\n/**\n * ONE digest for a collection's records — what the Read Collection node's\n * `text` handle, MCP `read_collection` and the CLI print. `headlines`: one line\n * per record (headline · date · link); `full`: the whole text of each record\n * under its headline, separated by a rule.\n */\nexport function collectionRecordsDigest(\n records: ReadonlyArray<Partial<Pick<CollectionRecord, \"title\" | \"text\" | \"url\" | \"createdAt\">> | null | undefined>,\n format: CollectionDigestFormat = \"headlines\",\n): string {\n // Tolerates a partial or null record (a hand-written node result in\n // workflow JSON): the engines rebuild this digest from saved data.\n const rows = records.filter((r): r is Partial<Pick<CollectionRecord, \"title\" | \"text\" | \"url\" | \"createdAt\">> => typeof r === \"object\" && r !== null)\n const str = (v: unknown): string => (typeof v === \"string\" ? v : \"\")\n if (format === \"full\") {\n return rows\n .map((r) => {\n const head = collectionRecordHeadline(r)\n const body = str(r.text).trim()\n const lines = [head ? `### ${head}` : \"\", body && body !== head ? body : \"\", str(r.url)].filter((l) => l.length > 0)\n return lines.join(\"\\n\")\n })\n .filter((block) => block.length > 0)\n .join(COLLECTION_DIGEST_SEPARATOR)\n }\n return rows\n .map((r) => {\n const parts = [collectionRecordHeadline(r)]\n const created = str(r.createdAt)\n if (created) parts.push(created.slice(0, 10))\n const url = str(r.url)\n if (url && url !== parts[0]) parts.push(url)\n return `- ${parts.filter((p) => p.length > 0).join(\" · \")}`\n })\n .join(\"\\n\")\n}\n\n/** What `ingestRecordFromJson` reads out of an item: the record's fields, before explicit overrides. */\nexport interface IngestedRecord {\n readonly title: string\n readonly text: string\n readonly url: string | null\n readonly media: CollectionMedia[]\n readonly fields: Record<string, CollectionFieldValue>\n readonly dedupeKey: string | null\n}\n\nconst TITLE_KEYS = [\"title\", \"headline\", \"name\", \"subject\"] as const\nconst TEXT_KEYS = [\"text\", \"body\", \"caption\", \"description\", \"content\", \"summary\", \"dek\"] as const\nconst URL_KEYS = [\"url\", \"postUrl\", \"link\", \"href\", \"permalink\"] as const\n/**\n * Keys a record is told apart by when it has no link. `id` comes last and only\n * as a non-numeric string: an LLM writing `{ \"id\": 1, … }` per article, or a\n * scraper's ordinal, numbers each RUN's items from 1 — a key that would mark\n * every later run's first item a duplicate of the first run's.\n */\nconst DEDUPE_KEYS = [\"slug\", \"postId\", \"externalId\", \"id\"] as const\nconst isDedupeValue = (key: string, v: unknown): boolean =>\n key === \"id\"\n ? typeof v === \"string\" && v.trim().length > 0 && !/^\\d+$/.test(v.trim())\n : (typeof v === \"string\" && v.trim().length > 0) || (typeof v === \"number\" && Number.isFinite(v))\nconst IMAGE_KEYS = [\"imageUrl\", \"thumbnailUrl\", \"image\", \"thumbnail\"] as const\nconst VIDEO_KEYS = [\"videoUrl\", \"video\"] as const\nconst AUDIO_KEYS = [\"audioUrl\", \"audio\"] as const\nconst MEDIA_SHAPED_KEYS = new Set<string>([\"media\", ...IMAGE_KEYS, ...VIDEO_KEYS, ...AUDIO_KEYS])\n\nfunction firstString(item: Record<string, unknown>, keys: readonly string[]): string | undefined {\n for (const key of keys) {\n const v = str(item[key])\n if (v !== undefined) return v\n }\n return undefined\n}\n\n/** The first link key whose value IS a link (`{ url: \"t.me/x\", postUrl: \"https://t.me/x\" }` reads the second). */\nfunction firstUrl(item: Record<string, unknown>, keys: readonly string[]): string | null {\n for (const key of keys) {\n const v = item[key]\n if (typeof v === \"string\" && isHttpUrl(v.trim())) return v.trim()\n }\n return null\n}\n\n/** Every medium an item carries, in page order, each link once, at most 20 — one pass, whatever the item's size. */\nfunction mediaFromItem(item: Record<string, unknown>): CollectionMedia[] {\n const seen = new Set<string>()\n const out: CollectionMedia[] = []\n const push = (m: CollectionMedia): boolean => {\n if (out.length >= COLLECTION_RECORD_MEDIA_MAX) return false\n if (!seen.has(m.url)) {\n seen.add(m.url)\n out.push(m)\n }\n return true\n }\n if (Array.isArray(item.media)) {\n for (const entry of item.media) {\n if (out.length >= COLLECTION_RECORD_MEDIA_MAX) break\n if (!isRecord(entry)) continue\n const type = entry.type === \"photo\" ? \"image\" : entry.type\n const poster = isHttpUrl(entry.posterUrl) ? entry.posterUrl : undefined\n if (type === \"video\" && !isHttpUrl(entry.url) && poster) {\n // A video the platform embeds nowhere: its poster is all there is to keep.\n push({ type: \"image\", url: poster })\n continue\n }\n if (isCollectionMedia({ ...entry, type })) push({ type: type as CollectionMediaType, url: entry.url as string, ...(poster ? { posterUrl: poster } : {}) })\n }\n } else if (isRecord(item.media)) {\n // A Social Search post: `media: { kind, thumbnailUrl, videoUrl }`.\n const m = item.media\n if (isHttpUrl(m.videoUrl)) push({ type: \"video\", url: m.videoUrl, ...(isHttpUrl(m.thumbnailUrl) ? { posterUrl: m.thumbnailUrl } : {}) })\n else if (isHttpUrl(m.thumbnailUrl)) push({ type: \"image\", url: m.thumbnailUrl })\n }\n for (const key of IMAGE_KEYS) if (isHttpUrl(item[key]) && !push({ type: \"image\", url: item[key] as string })) break\n for (const key of VIDEO_KEYS) if (isHttpUrl(item[key]) && !push({ type: \"video\", url: item[key] as string })) break\n for (const key of AUDIO_KEYS) if (isHttpUrl(item[key]) && !push({ type: \"audio\", url: item[key] as string })) break\n // A `mediaUrl` whose kind sits beside it (`mediaKind`: image / photo / video / audio), else read off the\n // file's ending, else a plain link. Both keys stay fields as well: a workflow may read them there.\n if (isHttpUrl(item.mediaUrl)) push({ type: mediaKindOf(item.mediaKind, item.mediaUrl), url: item.mediaUrl })\n return out\n}\n\nfunction mediaKindOf(kind: unknown, url: string): CollectionMediaType {\n if (kind === \"photo\" || kind === \"image\") return \"image\"\n if (kind === \"video\" || kind === \"audio\") return kind\n return loneMediaUrlKind(url) ?? \"link\"\n}\n\n/**\n * A record read out of any JSON item — a Telegram post, a Social Search\n * result, an LLM's object, a plain string. Title ← title / headline / name;\n * text ← text / body / caption / description; link ← the first of url /\n * postUrl / link that IS an http(s) link; media ← `media[]` and the image /\n * video / audio link keys; the dedupe key ← the link, else slug / id / postId;\n * every other scalar lands in `fields` (a nested object's `name`, such as a\n * forwarded-from, lands as that name). One pass over the item: its size is\n * the caller's body limit, never a loop of its own.\n */\nexport function ingestRecordFromJson(item: unknown): IngestedRecord {\n if (!isRecord(item)) {\n const text = typeof item === \"string\" ? item : item === undefined || item === null ? \"\" : JSON.stringify(item)\n return { title: \"\", text: clampChars(text, COLLECTION_RECORD_TEXT_MAX), url: null, media: [], fields: {}, dedupeKey: null }\n }\n const title = clampChars((firstString(item, TITLE_KEYS) ?? \"\").trim(), COLLECTION_RECORD_TITLE_MAX)\n const text = clampChars(firstString(item, TEXT_KEYS) ?? \"\", COLLECTION_RECORD_TEXT_MAX)\n const url = firstUrl(item, URL_KEYS)\n const media = mediaFromItem(item)\n const taken = new Set<string>([...TITLE_KEYS, ...TEXT_KEYS, ...URL_KEYS, ...MEDIA_SHAPED_KEYS])\n const fields: Record<string, unknown> = {}\n let kept = 0\n for (const [key, v] of Object.entries(item)) {\n if (kept >= COLLECTION_RECORD_FIELDS_MAX) break\n if (taken.has(key)) continue\n if (isScalar(v)) fields[key] = v\n else if (isRecord(v) && typeof v.name === \"string\" && v.name.trim()) fields[key] = v.name\n else continue\n kept += 1\n }\n const dedupeSource = url ?? DEDUPE_KEYS.filter((k) => isDedupeValue(k, item[k])).map((k) => item[k])[0]\n return {\n title,\n text,\n url,\n media,\n fields: normalizeCollectionFields(fields),\n dedupeKey: normalizeDedupeKey(dedupeSource),\n }\n}\n","/**\n * When a public video node outputs its input unchanged — no job, no charge —\n * because there is nothing for it to do (spec R14). One rule for both engines:\n * the orchestrator asks before any reservation, the canvas block before its API\n * call. The API routes keep their limits (Combine Videos still needs two URLs;\n * an empty overlay request is still `no_layers`).\n */\nexport type PassThroughWarning = \"no_layers\" | \"no_captions\" | \"single_input\"\nexport interface PassThrough { readonly videoUrl: string; readonly warning: PassThroughWarning }\n\nconst present = (u: string | null | undefined): u is string => typeof u === \"string\" && u.length > 0\n\n/** Exactly one resolved video → that video, unchanged. */\nexport function combineVideosPassThrough(videoUrls: ReadonlyArray<string | null | undefined>): PassThrough | null {\n const urls = videoUrls.filter(present)\n return urls.length === 1 ? { videoUrl: urls[0]!, warning: \"single_input\" } : null\n}\n\n/** A wired layer plan that resolved to nothing, with no handle layer either → the base video. */\nexport function videoOverlayPassThrough(input: {\n readonly videoUrl: string | null | undefined\n readonly planWired: boolean\n readonly layerCount: number\n}): PassThrough | null {\n if (!input.planWired || input.layerCount > 0 || !present(input.videoUrl)) return null\n return { videoUrl: input.videoUrl, warning: \"no_layers\" }\n}\n\n/** A wired caption plan whose styling produced no segment → the input video. */\nexport function captionPlanPassThrough(input: {\n readonly videoUrl: string | null | undefined\n readonly planWired: boolean\n readonly segmentCount: number\n}): PassThrough | null {\n if (!input.planWired || input.segmentCount > 0 || !present(input.videoUrl)) return null\n return { videoUrl: input.videoUrl, warning: \"no_captions\" }\n}\n","import {\n DEFAULT_TRANSCRIBE_NODE_PROVIDER,\n transcribeLaneSupportsWordTimestamps,\n transcribeProvidersWithWordTimestamps,\n} from \"./model-constants.js\"\nimport { renderTranscriptOutputOf } from \"./render-nodes.js\"\n\n/**\n * Pre-run checks for the transcribe → captions chain.\n *\n * A transcription lane that cannot return per-word timings (`whisper`) still\n * RUNS and BILLS — it just hands back phrase segments with `words: []`. Anything\n * downstream that needs words then fails AFTER the transcription was paid for.\n * These helpers let every run surface (the editor's DAG, the backend\n * orchestrator, single-node Run) refuse BEFORE any spend, with one message.\n * Pure: no I/O, no framework types — callers pass plain nodes/edges.\n */\n\n/** The refusal for a lane that can't return word timings; `null` when it can.\n * An absent provider resolves to the transcribe NODE default. */\nexport function transcribeWordTimestampsRefusal(provider: string | null | undefined): string | null {\n const lane = provider || DEFAULT_TRANSCRIBE_NODE_PROVIDER\n if (transcribeLaneSupportsWordTimestamps(lane)) return null\n return `the \"${lane}\" engine does not return word timings — pick ${transcribeProvidersWithWordTimestamps().join(\" or \")}`\n}\n\nexport interface PreflightGraphNode {\n readonly id: string\n readonly type?: string | null\n readonly data?: Record<string, unknown> | null\n}\nexport interface PreflightGraphEdge {\n readonly source: string\n readonly target: string\n readonly sourceHandle?: string | null\n readonly targetHandle?: string | null\n}\n\nexport interface WordlessTranscriptFeed {\n readonly transcribeNodeId: string\n /** The add-captions node that would receive a transcript with no words. */\n readonly consumerNodeId: string\n readonly provider: string\n readonly message: string\n}\n\n// Handle ids (generated map: backend/src/lib/mcp/generated/node-handles.ts).\nconst TRANSCRIBE_JSON_OUT = \"json\"\nconst TRANSCRIPT_IN = \"transcript\"\n\n/**\n * Every transcribe node on a word-INCAPABLE lane whose `json` output reaches an\n * add-captions `transcript` input — directly, or through apply-edl, which remaps\n * the transcript and re-emits it on its own `json` handle (or any render, by\n * its registry `transcriptOutput`: Speaker View's `transcript`). add-captions rejects a\n * transcript with no words, so such a run can only fail, after paying for the\n * transcription. Skipped nodes are ignored on both ends.\n *\n * The engine is read from node data and nothing else can change it: `provider`\n * is not a mappable field on transcribe, so what this check sees IS what runs.\n * add-captions' own \"transcript has no words\" guard stays as defence in depth\n * for a transcript that arrives from anywhere other than a transcribe node.\n */\nexport function findWordlessTranscriptFeeds(\n nodes: readonly PreflightGraphNode[],\n edges: readonly PreflightGraphEdge[],\n): WordlessTranscriptFeed[] {\n const byId = new Map(nodes.map((n) => [n.id, n]))\n const isSkipped = (n: PreflightGraphNode | undefined): boolean => !n || n.data?.skipped === true\n const out: WordlessTranscriptFeed[] = []\n\n for (const node of nodes) {\n if (node.type !== \"transcribe\" || isSkipped(node)) continue\n const provider = (typeof node.data?.provider === \"string\" && node.data.provider) || DEFAULT_TRANSCRIBE_NODE_PROVIDER\n const refusal = transcribeWordTimestampsRefusal(provider)\n if (!refusal) continue\n\n // Walk the transcript's path: transcribe.json → [render.transcript → its transcript output]* → add-captions.transcript,\n // out of every render on the pip its registry names (RENDER_NODE_TYPES transcriptOutput)\n const seen = new Set<string>()\n const frontier: Array<{ id: string; outHandle: string }> = [{ id: node.id, outHandle: TRANSCRIBE_JSON_OUT }]\n while (frontier.length > 0) {\n const { id, outHandle } = frontier.pop()!\n for (const e of edges) {\n if (e.source !== id || (e.sourceHandle ?? null) !== outHandle || e.targetHandle !== TRANSCRIPT_IN) continue\n const target = byId.get(e.target)\n if (isSkipped(target)) continue\n if (target!.type === \"add-captions\") {\n out.push({\n transcribeNodeId: node.id,\n consumerNodeId: target!.id,\n provider,\n message: `Captions need word timings, but ${refusal}.`,\n })\n } else if (!seen.has(target!.id)) {\n const remapped = renderTranscriptOutputOf(target!.type)\n if (remapped) {\n seen.add(target!.id)\n frontier.push({ id: target!.id, outHandle: remapped.handle })\n }\n }\n }\n }\n }\n return out\n}\n","/**\n * Workflow-node parameter normalization.\n *\n * The config panels already prevent an impossible provider/parameter pair from\n * being *selected*: their dropdowns are provider-aware and a fail-safe effect\n * snaps stale values when the provider changes. But both of those are React\n * effects — they only run when that specific node's panel or hover strip is\n * mounted. A node written straight into workflow JSON by a non-UI author (an\n * agent, an import, a template) is never seen by either, so its invalid pair\n * survives all the way to the provider call.\n *\n * That is the 2026-08-09 incident: one `generate-image` node carrying\n * `gpt-image` + `16:9` (GPT Image 1.5 renders 1:1 / 3:2 / 2:3 only) reached KIE,\n * got rejected, and aborted a run whose five sibling nodes had already produced\n * — and billed for — their images.\n *\n * This module is the write-boundary guard: it heals the node instead of\n * rejecting it, so the user sees a valid value on the canvas rather than a\n * failed run. It reads exclusively from `MODEL_CATALOG`, so a model added later\n * is covered without touching this file.\n */\n\nimport { autoAspectNeedsSourceImage, normalizeModelInput, type ModelInputAdjustment } from \"./model-catalog.js\"\nimport { imageGenAutoAspectNeedsSourceImage } from \"./credit-identifiers.js\"\n\n/**\n * Node types whose `data` carries catalog-governed model parameters under the\n * shape this module understands (`provider` + aspectRatio/resolution/quality).\n *\n * IMAGE ONLY, deliberately. The video nodes route several of these fields\n * through mode-dependent defaults (`\"adaptive\"` for Seedance/Hailuo, duration\n * composites tied to pricing) that this flat normalizer would flatten wrongly;\n * they get their own pass once those defaults are catalog-derived too.\n *\n * `modify-image` carries the same provider/aspectRatio/resolution/quality trio\n * as `image-to-image` (it routes through the same worker), and `edit-image`\n * carries provider + aspectRatio. `edit-image`'s `targetResolution` is an\n * UPSCALE target, a different field this module never reads — so listing the\n * type here heals its ratio without touching what it is priced on.\n */\nexport const MODEL_PARAM_NODE_TYPES: ReadonlySet<string> = new Set([\n \"generate-image\",\n \"image-to-image\",\n \"modify-image\",\n \"edit-image\",\n])\n\n/**\n * The image node types that transform a SOURCE image (their required `image`\n * input). On these \"auto\" means \"keep the source photo's shape\", and the run\n * resolves it against that image — natively on a model that lists \"auto\", else\n * to the model's nearest listed ratio (`normalizeModelInput`'s `sourceImage`).\n *\n * `generate-image` is absent: its photo is optional, and it is the first image\n * its references ASSEMBLE to, not a node input — see\n * `AUTO_ASPECT_AT_RUN_NODE_TYPES`.\n */\nexport const SOURCE_IMAGE_NODE_TYPES: ReadonlySet<string> = new Set([\n \"image-to-image\",\n \"modify-image\",\n \"edit-image\",\n])\n\n/**\n * The node types whose \"auto\" aspect ratio the RUN resolves against a photo,\n * so a write boundary (which has no photo) keeps it: the source-image types,\n * plus `generate-image`, whose photo is the first reference the run assembles\n * (or its inpaint / refine base). A Generate Image run with no photo snaps\n * \"auto\" exactly as this boundary used to — the value that reaches a provider\n * never changes there.\n */\nexport const AUTO_ASPECT_AT_RUN_NODE_TYPES: ReadonlySet<string> = new Set([\n ...SOURCE_IMAGE_NODE_TYPES,\n \"generate-image\",\n])\n\n/**\n * The image nodes whose aspect-ratio dropdown leads with the photo \"Auto\" tile\n * (Generate Image and Modify Image: `withPhotoAuto` in the editor). On these an\n * UNSET ratio IS Auto — the dropdown shows Auto for it, and both engines send\n * \"auto\" for it — so what the editor shows is what the run asks for.\n *\n * It used to send nothing, which handed the ratio to the provider's own\n * default (16:9 on nearly every model) while the panel displayed \"Auto\" or the\n * model's first listed ratio: a 3:4 photo through Modify Image came back 16:9\n * (#2009). \"auto\" then resolves exactly as a chosen Auto does — natively on a\n * model that lists it, else to the model's ratio nearest the photo, else (no\n * photo) the model's first listed ratio.\n */\nexport const PHOTO_AUTO_ASPECT_NODE_TYPES: ReadonlySet<string> = new Set([\n \"generate-image\",\n \"modify-image\",\n])\n\n/**\n * The aspect ratio a node asks for: its stored value, or \"auto\" when it is\n * unset on a photo-Auto node (`PHOTO_AUTO_ASPECT_NODE_TYPES`). Every other node\n * type gets its value back unchanged (undefined stays undefined).\n */\nexport function nodeAspectRatio(nodeType: \"generate-image\" | \"modify-image\", aspectRatio: unknown): string\nexport function nodeAspectRatio(nodeType: string | undefined, aspectRatio: unknown): string | undefined\nexport function nodeAspectRatio(nodeType: string | undefined, aspectRatio: unknown): string | undefined {\n if (typeof aspectRatio === \"string\" && aspectRatio.trim() !== \"\") return aspectRatio\n return nodeType !== undefined && PHOTO_AUTO_ASPECT_NODE_TYPES.has(nodeType) ? \"auto\" : undefined\n}\n\nexport interface NodeParamAdjustment extends ModelInputAdjustment {\n nodeId: string\n provider: string\n}\n\nexport interface NormalizedNodes<T> {\n nodes: T[]\n /** Empty when nothing needed correcting. */\n adjustments: NodeParamAdjustment[]\n}\n\ninterface NodeLike {\n id?: unknown\n type?: unknown\n data?: unknown\n}\n\n/**\n * Return `nodes` with every catalog-governed image parameter coerced into a\n * combination its provider actually accepts, plus the list of what changed.\n *\n * Immutable: nodes that need no correction are returned by reference, and a\n * corrected node is a fresh object (never a mutation of the caller's input).\n *\n * Multi-provider nodes (`data.providers` holding 2+ entries) are SKIPPED: the\n * valid set there is the intersection across every selected provider, and when\n * a stored value falls outside it there is no single defensible replacement —\n * picking one provider's default would silently misconfigure the others. Those\n * nodes are still guarded interactively by the panel's intersection dropdown.\n */\nexport function normalizeNodeModelParams<T extends NodeLike>(\n nodes: readonly T[],\n): NormalizedNodes<T> {\n const adjustments: NodeParamAdjustment[] = []\n const out = nodes.map((node) => {\n const type = typeof node.type === \"string\" ? node.type : \"\"\n if (!MODEL_PARAM_NODE_TYPES.has(type)) return node\n\n const data = node.data\n if (!data || typeof data !== \"object\" || Array.isArray(data)) return node\n const d = data as Record<string, unknown>\n\n const multi = Array.isArray(d.providers) ? (d.providers as unknown[]) : []\n if (multi.length > 1) return node\n\n const provider =\n typeof d.provider === \"string\"\n ? d.provider\n : typeof multi[0] === \"string\"\n ? (multi[0] as string)\n : undefined\n if (!provider) return node\n\n // A write boundary has no photo, so \"auto\" on a node the run resolves it for\n // is left for the run to resolve against the photo — snapping it here would\n // discard the very request (\"keep my photo's shape\") the run can honour. It\n // is stored in its canonical spelling, the one the image routes' ratio enum\n // accepts. A Generate Image run snaps against its model's i2i sibling once\n // references attach, and this boundary cannot count them (wired ones come\n // from edges), so it asks about both.\n const deferAuto = AUTO_ASPECT_AT_RUN_NODE_TYPES.has(type) && (\n type === \"generate-image\"\n ? imageGenAutoAspectNeedsSourceImage({ provider, aspectRatio: d.aspectRatio })\n : autoAspectNeedsSourceImage(provider, d.aspectRatio)\n )\n const normalized = normalizeModelInput(provider, {\n aspectRatio: !deferAuto && typeof d.aspectRatio === \"string\" ? d.aspectRatio : undefined,\n resolution: typeof d.resolution === \"string\" ? d.resolution : undefined,\n quality: typeof d.quality === \"string\" ? d.quality : undefined,\n })\n const respell = deferAuto && d.aspectRatio !== \"auto\"\n if (normalized.adjustments.length === 0 && !respell) return node\n\n const nodeId = typeof node.id === \"string\" ? node.id : \"(unknown node)\"\n for (const adj of normalized.adjustments) {\n adjustments.push({ ...adj, nodeId, provider })\n }\n\n // Only the three governed keys are rewritten; everything else on the node\n // is passed through untouched. A dropped lever is written as `undefined`\n // rather than deleted so the shape stays stable for downstream readers.\n return {\n ...node,\n data: {\n ...d,\n aspectRatio: deferAuto ? \"auto\" : normalized.aspectRatio,\n resolution: normalized.resolution,\n quality: normalized.quality,\n },\n }\n })\n\n return { nodes: out, adjustments }\n}\n\n/** One-line-per-change summary, for surfacing back to an agent or a log. */\nexport function describeNodeAdjustments(adjustments: readonly NodeParamAdjustment[]): string[] {\n return adjustments.map(\n (a) => `${a.nodeId} (${a.provider}): ${a.field} \"${a.from}\" → ${a.to === undefined ? \"removed\" : `\"${a.to}\"`} — ${a.reason}`,\n )\n}\n","/**\n * Prompt pre/post text (\"affixes\") — the PUBLIC node-data contract.\n *\n * Every AI prompt node may carry two optional strings that are wrapped around\n * its run-time prompt: `promptPrefix` goes before, `promptSuffix` after. Both\n * support `{Node Label}` references and plain-text snippets exactly like the\n * main prompt. They are settings (edited in the node's config panel, captured\n * by presets, settable through workflow JSON / `inputOverrides`), never shown\n * on the node face or to published-app end users.\n *\n * Only the KEYS + TYPE live here (what the SDK/API contract needs). The wrap\n * behaviour (`applyPromptAffixes`) lives in `@nodaro/prompts` next to\n * `resolvePrompt` — see the spec's IP-placement note.\n */\nexport const PROMPT_PREFIX_KEY = \"promptPrefix\" as const\nexport const PROMPT_SUFFIX_KEY = \"promptSuffix\" as const\n\nexport interface PromptAffixFields {\n /** Text placed BEFORE the node's prompt at run time. Supports {Node Label} refs. */\n readonly promptPrefix?: string\n /** Text placed AFTER the node's prompt at run time. Supports {Node Label} refs. */\n readonly promptSuffix?: string\n}\n\n/** The affix pair read off node data (blank / non-string values are omitted). */\nexport interface PromptAffixes {\n readonly prefix?: string\n readonly suffix?: string\n}\n\nfunction nonBlank(v: unknown): string | undefined {\n return typeof v === \"string\" && v.trim().length > 0 ? v : undefined\n}\n\n/** Read `{ prefix, suffix }` off a node's `data`. Never throws; unknown shapes → `{}`. */\nexport function readPromptAffixes(data: Record<string, unknown>): PromptAffixes {\n const prefix = nonBlank(data[PROMPT_PREFIX_KEY])\n const suffix = nonBlank(data[PROMPT_SUFFIX_KEY])\n return {\n ...(prefix !== undefined ? { prefix } : {}),\n ...(suffix !== undefined ? { suffix } : {}),\n }\n}\n","import { isExecutionDataKey } from \"./node-runtime-keys.js\"\nimport { COMPOSER_PLAN_FIELDS } from \"./model-constants.js\"\nimport { PROMPT_PREFIX_KEY, PROMPT_SUFFIX_KEY } from \"./prompt-affixes.js\"\n\n/**\n * Generated-plan state on composer nodes that a preset must NEITHER capture NOR\n * carry, and that the dropdown must CLEAR when applying a preset:\n *\n * - every composer node's plan field (`COMPOSER_PLAN_MAP[*].planField` —\n * sceneGraph / effectPlan / overlayPlan / titlePlan / motionPlan /\n * compositePlan): a large LLM-authored plan blob, regenerated per run.\n * - `lottieUrl`: the R2 url of the authored Lottie JSON (motion-graphics'\n * `lottie` handle output) — a reapable generated artifact, not config.\n *\n * Derived from the single source of truth (COMPOSER_PLAN_MAP) so a new composer\n * node type is covered by construction — no per-type list to keep in sync.\n *\n * Two distinct hazards this closes (see motion-graphics-presets design §2a/§2b):\n * 1. Apply-time staleness: applying a preset over a node that already generated\n * a plan would leave the OLD animation showing under the NEW prompt (the\n * plan field is named by no patch, so it persists in the preview and on the\n * output handle). The dropdown spreads `{ ...clearPatch, ...preset.data }`\n * where clearPatch maps each key here to `undefined`.\n * 2. Capture pollution: a user-saved preset would otherwise capture the plan\n * blob (~tens of KB) + a stale url, re-injecting them on every apply and\n * bloating the preset row. These keys are in the capture-exclusion set below.\n */\nexport const PRESET_APPLY_CLEAR_KEYS: readonly string[] = [\n ...COMPOSER_PLAN_FIELDS, \"lottieUrl\",\n // Scene revision history contains old plans and their reference/prompt context.\n // Preserve it in workflows, never capture or resurrect it through a preset.\n \"sceneHistory\", \"scenePendingPlan\", \"sceneJobBaseRevisionId\", \"expectedRevisionId\",\n \"changeSummary\", \"selectedObjectIds\", \"lockedObjectIds\", \"referenceObjectIds\", \"referenceRoles\",\n]\n\n/**\n * The three keys that carry a preset's PROMPT CONTENT: the prompt itself plus the pre/post text\n * wrapped around it at run time. A preset \"owns prompt content\" iff its data defines any of them.\n */\nconst PROMPT_CONTENT_KEYS: readonly string[] = [\"prompt\", \"scenePrompt\", \"editPrompt\", PROMPT_PREFIX_KEY, PROMPT_SUFFIX_KEY]\n\n/**\n * The keys applying THIS preset must clear on the node: always `PRESET_APPLY_CLEAR_KEYS`, plus\n * `promptPrefix` / `promptSuffix` when the preset owns prompt content. The dropdown spreads\n * `{ ...clearPatch, ...preset.data }`, so the preset's own affixes (if any) land back on top of\n * the clear — the clear only decides what happens to the keys the preset does NOT set.\n *\n * The hazard this closes: with a STATIC clear set the affixes are named by no patch, so applying\n * preset B (which ships only `prompt`) over a node carrying preset A's `promptPrefix` leaves A's\n * prefix in place, silently wrapping B's prompt. The node then runs text no preset ever authored,\n * and nothing in the UI attributes it — the prefix lives in a collapsed settings section.\n *\n * The rule is ASYMMETRIC on purpose, because the two directions have opposite promises:\n * - A preset that owns prompt content is authoring the whole prompt, affixes included, so any\n * leftover affix from a previous preset is stale — clear both.\n * - A settings-only preset (provider / aspect ratio / seed …) promises to touch nothing about the\n * prompt, so it leaves prompt AND affixes exactly as the user has them.\n * - `prompt` is NEVER cleared, only overwritten when the preset ships it. That is the feature's\n * core promise: apply a preset that ships only affixes and your typed prompt is kept, wrapped.\n *\n * Pure; `PRESET_APPLY_CLEAR_KEYS` itself stays a fixed set (it is also spread into\n * `PRESET_EXCLUDED_KEYS`, and affixes must remain capture-INCLUDED for presets to ship them).\n */\nexport function presetApplyClearKeys(\n presetData: Readonly<Record<string, unknown>>,\n nodeType?: string,\n): readonly string[] {\n const ownsPromptContent = PROMPT_CONTENT_KEYS.some((k) => presetData[k] !== undefined)\n const base = ownsPromptContent\n ? [...PRESET_APPLY_CLEAR_KEYS, PROMPT_PREFIX_KEY, PROMPT_SUFFIX_KEY]\n : PRESET_APPLY_CLEAR_KEYS\n const levers = presetLeverClearKeys(presetData, nodeType)\n return levers.length > 0 ? [...base, ...levers] : base\n}\n\n/**\n * Per node type, the look levers a preset may leave unset. Applying any preset\n * with data to a node of a listed type clears every member that preset does not\n * set, so one preset's plate colour, weight or position never carries over into\n * the next. Data-driven, so a new preset of a listed type is covered by\n * construction. The members stay capture-included: a saved preset carries the\n * levers its node had, so it clears only the ones that were unset when it was saved.\n */\nexport const PRESET_LEVER_GROUPS: Readonly<Record<string, readonly string[]>> = {\n \"add-captions\": [\n \"look\", \"fontFamily\", \"fontWeight\", \"strokeColor\", \"strokeWidth\", \"highlightColor\",\n \"uppercase\", \"positionY\", \"animate\", \"maxWordsPerLine\", \"backgroundColor\",\n ],\n}\n\n/**\n * The lever-group keys applying THIS preset clears on a node of `nodeType`: every\n * member of the node type's group that the preset does not set. Nothing for a node\n * type with no group, and nothing for empty preset data. Pure.\n */\nexport function presetLeverClearKeys(\n presetData: Readonly<Record<string, unknown>>,\n nodeType?: string,\n): readonly string[] {\n if (!nodeType || !Object.hasOwn(PRESET_LEVER_GROUPS, nodeType)) return []\n if (!Object.values(presetData).some((v) => v !== undefined)) return []\n return PRESET_LEVER_GROUPS[nodeType]!.filter((k) => presetData[k] === undefined)\n}\n\n/**\n * Config fields that are intentionally NOT part of a preset, because they are not portable\n * configuration — they identify the node on the canvas, wire it into one specific graph, or point\n * at specific DB entities. Capturing them would make a preset silently wrong when applied to a\n * different node or workflow. This is the single place that defines that contract, so the system\n * stays correct-by-construction as new node types are added.\n *\n * Identity:\n * - `label`: the node's canvas identity. Presets carry their own name and must not rename the node.\n *\n * Graph wiring (reference specific upstream node / handle / tile ids — meaningless elsewhere):\n * - `fieldMappings`: field -> upstream node id.\n * - `referenceImageOrder` / `referenceOrder` / `connectedMediaOrder` / `connectedRefImageOrder`:\n * orderings keyed by the ids of wired upstream references.\n *\n * Structural identifiers (handle / port / route / channel ids that must stay unique per node and\n * that downstream edges target — copying them across nodes orphans edges or duplicates a channel):\n * - `routes` / `routeId` / `routeIds`: router routes + sub-workflow/condition route pairing ids.\n * - `ports` / `inputPorts` / `outputPorts`: sub-workflow port arrays (each port has a handle id).\n * - `channel` / `channelColor`: teleport send/receive pairing channel (auto-assigned per node).\n *\n * DB entity references / per-wiring identity state (tied to specific characters/locations):\n * - `characterDefinitionIds`, `suppressedCanonicalCharacterIds`, `suppressedCanonicalLocationIds`.\n * - `identityMeta`: per-identity overrides keyed by the wired identity's index/label.\n * - `extraRefs`: extra references carrying `characterSlug` + workflow-specific asset urls.\n *\n * Preset meta:\n * - `__activePresetId`: which preset is currently loaded onto the node (for the dropdown's\n * active-name + dirty `*`). Node-local UI state, never part of a preset's own config.\n * - `__promptFinalView`: field keys currently showing the final-prompt view (Edit ⇄ Final\n * per-field toggle). Node-local UI state, never part of a preset's own config.\n *\n * Editor-only memory:\n * - `settingsBeforeAudio`: the picture settings an audio recording turned off on a use-case node\n * (Tighten Episode, Clip Pack), kept to give back when a video is wired again. It belongs to\n * THIS node's wiring, never a reusable configuration — a preset applied elsewhere would hand\n * another node values to restore on its next video wire.\n *\n * NOTE: manual reference image urls (`referenceImageUrl` / `referenceImageUrls`) are deliberately\n * KEPT — they are self-contained R2 urls a user set as input, and portable across nodes.\n *\n * Generated composer-plan state (`PRESET_APPLY_CLEAR_KEYS` — every COMPOSER_PLAN_MAP plan field +\n * `lottieUrl`): NOT portable config — a per-run LLM-authored plan blob / reapable artifact url.\n * Excluded here (preset-scoped, zero blast radius) rather than via EXECUTION_DATA_KEYS, whose\n * non-preset consumers (undo-skip in use-workflow-store, auto-execute IGNORE_KEYS) would then\n * treat a legitimately-persisted plan as transient runtime state.\n */\nexport const PRESET_EXCLUDED_KEYS: ReadonlySet<string> = new Set([\n \"label\",\n \"fieldMappings\",\n \"__activePresetId\",\n \"__promptFinalView\",\n \"referenceImageOrder\",\n \"referenceOrder\",\n \"connectedMediaOrder\",\n \"connectedRefImageOrder\",\n \"characterDefinitionIds\",\n \"suppressedCanonicalCharacterIds\",\n \"suppressedCanonicalLocationIds\",\n \"identityMeta\",\n \"extraRefs\",\n // editor-only memory of the node's own wiring (an audio recording's lock)\n \"settingsBeforeAudio\",\n // structural identifiers\n \"routes\",\n \"routeId\",\n \"routeIds\",\n \"ports\",\n \"inputPorts\",\n \"outputPorts\",\n \"channel\",\n \"channelColor\",\n // generated composer-plan state (derived from COMPOSER_PLAN_MAP + lottieUrl)\n ...PRESET_APPLY_CLEAR_KEYS,\n])\n\n/**\n * Capture a node's reusable configuration from its `data`: a shallow copy minus runtime/result\n * state (`isExecutionDataKey`: the global keys, plus the node type's own when `nodeType` is given)\n * and graph/identity fields (PRESET_EXCLUDED_KEYS). Pure; never mutates the input. The node type is\n * stored alongside the result by the caller.\n */\nexport function extractPresetData(\n data: Readonly<Record<string, unknown>>,\n nodeType?: string,\n): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const key of Object.keys(data)) {\n if (isExecutionDataKey(key, nodeType)) continue\n if (PRESET_EXCLUDED_KEYS.has(key)) continue\n out[key] = data[key]\n }\n return out\n}\n\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (typeof a !== typeof b) return false\n if (a === null || b === null) return a === b\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n return a.every((v, i) => deepEqual(v, b[i]))\n }\n if (typeof a === \"object\" && typeof b === \"object\") {\n const ka = Object.keys(a as object)\n const kb = Object.keys(b as object)\n if (ka.length !== kb.length) return false\n return ka.every((k) =>\n deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]),\n )\n }\n return false\n}\n\n/**\n * True iff the node's `data` still matches the preset — i.e. every key the preset defines\n * deep-equals the node's current value. Compares only preset-defined keys (the node may carry\n * extra keys the preset doesn't set, e.g. seed, which must NOT count as a mismatch). Used to drive\n * the dropdown's dirty `*` indicator.\n */\nexport function presetDataMatches(\n nodeData: Readonly<Record<string, unknown>>,\n presetData: Readonly<Record<string, unknown>>,\n): boolean {\n for (const key of Object.keys(presetData)) {\n if (!deepEqual(nodeData[key], presetData[key])) return false\n }\n return true\n}\n","import { z } from \"zod\"\nimport { extractPresetData } from \"./node-preset-extract.js\"\n\nexport const NODE_PRESET_EXPORT_KIND = \"nodaro.node-presets\" as const\n\nexport interface ExportedPreset {\n nodeType: string\n name: string\n description?: string\n data: Record<string, unknown>\n}\n\nexport interface NodePresetExport {\n kind: typeof NODE_PRESET_EXPORT_KIND\n version: 1\n exportedAt: string\n presets: ExportedPreset[]\n}\n\nconst exportedPresetSchema = z.object({\n nodeType: z.string().min(1).max(120),\n name: z.string().min(1).max(120),\n description: z.string().max(500).optional(),\n data: z.record(z.string(), z.unknown()),\n})\n\nconst envelopeSchema = z.object({\n kind: z.literal(NODE_PRESET_EXPORT_KIND),\n version: z.literal(1),\n exportedAt: z.string().optional().default(\"\"),\n presets: z.array(exportedPresetSchema).max(500),\n})\n\nexport function buildNodePresetExport(\n presets: ExportedPreset[],\n exportedAtIso: string,\n): NodePresetExport {\n return {\n kind: NODE_PRESET_EXPORT_KIND,\n version: 1,\n exportedAt: exportedAtIso,\n presets: presets.map((p) => ({ ...p, data: extractPresetData(p.data, p.nodeType) })),\n }\n}\n\n/**\n * Validate an unknown parsed-JSON value as a preset export; throws on invalid. Defensively\n * re-strips runtime keys from each preset's data.\n */\nexport function parseNodePresetExport(input: unknown): NodePresetExport {\n const parsed = envelopeSchema.parse(input)\n return {\n ...parsed,\n presets: parsed.presets.map((p) => ({ ...p, data: extractPresetData(p.data, p.nodeType) })),\n }\n}\n","/**\n * A render node's SAVED output — what a render (Apply EDL) hands downstream\n * when the run does not run it: a node outside a Run from here, a Skip-frozen\n * node, or the editor's own read of the canvas. ONE reader, so the two engines\n * cannot pick different takes again (they did: the server took\n * `generatedVideoUrl` first, the editor the selected result).\n *\n * - A SCALAR edge reads the selected result (`generatedResults[activeResultIndex]`),\n * as the node's medium (`data.output`). That also repairs a pick saved before\n * the results gallery wrote the right field: such a node holds the picked\n * take's index with the newest take still on `generatedVideoUrl`, and the\n * selected result wins (decided 2026-10-04).\n * - An EACH edge reads the render's LATEST batch only (`__listResults`, the\n * rows of its last run once per clip) — never its accumulated history,\n * which holds earlier runs' clips too (TA6, decided 2026-10-04). A render\n * that ran once has no batch; the edge then reads the one result.\n *\n * Every item carries what its render stamped on it — `quality` (\"proxy\" is a\n * Preview), `clipKey` (the plan clip it was cut from), `planBasis` (the plan\n * value it was cut from) and `renderBasis` (the render's own settings) —\n * copied onto the result by every lane that lands a take.\n */\nimport { normalizeEdl } from \"./edl.js\"\nimport { editPlanBasis } from \"./edit-plan-review.js\"\nimport { defaultEdgeOutputMode } from \"./producer-types.js\"\nimport { resolveIndex, selectListItems, type SelectorFields } from \"./selector.js\"\n\n/** The quality an Apply EDL render was made at. \"proxy\" is a Preview. */\nexport type RenderQuality = \"proxy\" | \"final\"\n\n/** The medium a render hands on. */\nexport type RenderMedium = \"video\" | \"audio\"\n\n/** What a finished render says about itself beside its URL. */\nexport interface RenderResultStamp {\n readonly quality?: RenderQuality\n /** The plan clip the render was cut from (`edlSpanKey` of that clip). */\n readonly clipKey?: string\n /** The plan value the render was cut from (`renderReadBasis`): stamped only\n * when that value is the plan's own (`renderPlanBasis`). Absent = unknown. */\n readonly planBasis?: string\n /** The render's own settings (`renderSettingsBasis`): its output, its\n * crossfade and the media it read. */\n readonly renderBasis?: string\n}\n\n/** One row of a run's per-item results, row-aligned with them. A row that\n * produced nothing (a hole) carries no take's fields; a render's hole still\n * says what it was sent for (`renderSentRowStamps`): the quality its run\n * renders at and, when the run can name it, its clip (`clipKey`,\n * `renderPlanRowClipKeys`), so a failed row is matched to its clip by key.\n * `{}` is a hole that names none (a run made before every row was stamped, or\n * a node that is not a render). */\nexport interface RunResultRowStamp extends RenderResultStamp {\n readonly jobId?: string\n readonly thumbnailUrl?: string\n /** The row never ran: a Stop, or the fail-fast after another row failed,\n * skipped it. It is a hole, never a failure. */\n readonly cancelled?: true\n}\n\n/** One saved render result. */\nexport interface SavedRenderItem extends RenderResultStamp {\n readonly url: string\n readonly medium: RenderMedium\n readonly jobId?: string\n readonly thumbnailUrl?: string\n}\n\ntype Data = Readonly<Record<string, unknown>>\n\nconst MEDIUM_FIELD: Readonly<Record<RenderMedium, string>> = {\n video: \"generatedVideoUrl\",\n audio: \"generatedAudioUrl\",\n}\n\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" && v.length > 0 ? v : undefined)\n\nconst BASIS = /^[0-9a-f]{16}$/\n/** A basis as `editPlanBasis` writes it — 16 lowercase hex digits — or nothing. */\nconst basisOf = (v: unknown): string | undefined => (typeof v === \"string\" && BASIS.test(v) ? v : undefined)\n\n/** The stamp a finished render's output carries: a known quality, a non-empty\n * clip key and the two bases as 16 hex digits, nothing else (an unknown value\n * is dropped, not trusted). */\nexport function renderResultStamp(output: unknown): RenderResultStamp {\n const o = (output && typeof output === \"object\" ? output : {}) as Record<string, unknown>\n const quality = o.quality === \"proxy\" || o.quality === \"final\" ? o.quality : undefined\n const clipKey = str(o.clipKey)\n const planBasis = basisOf(o.planBasis)\n const renderBasis = basisOf(o.renderBasis)\n return {\n ...(quality ? { quality } : {}),\n ...(clipKey ? { clipKey } : {}),\n ...(planBasis ? { planBasis } : {}),\n ...(renderBasis ? { renderBasis } : {}),\n }\n}\n\n/** The medium a render node renders: its `output`, video when absent. */\nfunction mediumOf(data: Data): RenderMedium {\n return data.output === \"audio\" ? \"audio\" : \"video\"\n}\n\ninterface ResultEntry {\n readonly url?: unknown\n readonly jobId?: unknown\n readonly thumbnailUrl?: unknown\n}\n\nfunction resultsOf(data: Data): readonly ResultEntry[] {\n return Array.isArray(data.generatedResults) ? (data.generatedResults as ResultEntry[]) : []\n}\n\nfunction itemOf(url: string, medium: RenderMedium, entry: ResultEntry | undefined): SavedRenderItem {\n const jobId = str(entry?.jobId)\n const thumbnailUrl = str(entry?.thumbnailUrl)\n return {\n url,\n medium,\n ...(jobId ? { jobId } : {}),\n ...(thumbnailUrl ? { thumbnailUrl } : {}),\n ...(entry ? renderResultStamp(entry) : {}),\n }\n}\n\n/** The one result a saved render hands a scalar edge: the selected result (as\n * the node's medium), else the saved field of its medium, else the other\n * medium's field (as that medium). */\nexport function savedRenderOutput(data: Data): SavedRenderItem | undefined {\n const medium = mediumOf(data)\n const results = resultsOf(data)\n const index = typeof data.activeResultIndex === \"number\" ? data.activeResultIndex : 0\n const selected = results[index] ?? results[0]\n const selectedUrl = str(selected?.url)\n if (selectedUrl) return itemOf(selectedUrl, medium, selected)\n // No results kept (a node saved before results were): the saved field of its\n // medium, else the other medium's — which then names the medium itself.\n const own = str(data[MEDIUM_FIELD[medium]])\n if (own) return { url: own, medium }\n const other: RenderMedium = medium === \"video\" ? \"audio\" : \"video\"\n const otherUrl = str(data[MEDIUM_FIELD[other]])\n return otherUrl ? { url: otherUrl, medium: other } : undefined\n}\n\n/** The rows of a saved render's LATEST batch, row-aligned (`null` = a row that\n * produced nothing), each with what its render stamped. `undefined` when the\n * render has no batch (it ran once, or never). */\nexport function savedRenderBatch(data: Data): ReadonlyArray<SavedRenderItem | null> | undefined {\n const batch = data.__listResults\n if (!Array.isArray(batch) || batch.length === 0) return undefined\n const medium = mediumOf(data)\n const byUrl = new Map<string, ResultEntry>()\n for (const entry of resultsOf(data)) {\n const url = str(entry.url)\n if (url && !byUrl.has(url)) byUrl.set(url, entry)\n }\n return batch.map((row) => {\n const url = str(row)\n return url ? itemOf(url, medium, byUrl.get(url)) : null\n })\n}\n\n/** The latest batch as the list an each edge iterates (`\"\"` = a hole). */\nexport function savedRenderBatchUrls(data: Data): string[] | undefined {\n const batch = savedRenderBatch(data)\n return batch ? batch.map((item) => item?.url ?? \"\") : undefined\n}\n\n/**\n * A plan clip's identity: the outer span of its kept segments on the master\n * clock, `${min inMs}-${max outMs}` (integer ms, as `normalizeEdl` rounds them).\n * Taken from the PLAN's clip, never from a rendered EDL — Camera Switch can\n * move a clip's outer edges inward. `undefined` when the value is not an EDL\n * with segments.\n */\nexport function edlSpanKey(edl: unknown): string | undefined {\n if (!edl || typeof edl !== \"object\" || Array.isArray(edl)) return undefined\n let segments: ReturnType<typeof normalizeEdl>[\"segments\"]\n try {\n segments = normalizeEdl(edl).segments\n } catch {\n return undefined\n }\n if (segments.length === 0) return undefined\n let min = Infinity\n let max = -Infinity\n for (const s of segments) {\n if (s.inMs < min) min = s.inMs\n if (s.outMs > max) max = s.outMs\n }\n return Number.isFinite(min) && Number.isFinite(max) ? `${min}-${max}` : undefined\n}\n\n/** The clip key of row `row` of a clips plan (a list of EDLs, objects or JSON\n * strings). `undefined` for a plan that is one EDL (Tighten), a missing row,\n * or a row that is not an EDL. */\nexport function planClipKeyAt(plan: unknown, row: number): string | undefined {\n if (!Array.isArray(plan)) return undefined\n let clip: unknown = plan[row]\n if (typeof clip === \"string\") {\n if (!clip.trim()) return undefined\n try {\n clip = JSON.parse(clip)\n } catch {\n return undefined\n }\n }\n return edlSpanKey(clip)\n}\n\n/** A node or an edge as the plan walk needs it (either engine's graph). */\nexport interface RenderGraphNode {\n readonly id: string\n readonly type?: string | null\n}\nexport interface RenderGraphEdge {\n readonly source: string\n readonly target: string\n readonly sourceHandle?: string | null\n readonly targetHandle?: string | null\n /** The wire's settings: its `outputMode` and its range / list selector. */\n readonly data?: unknown\n}\n\n/** One wire on the way from the plan to the render that picks clips: the render's\n * `edl` wire, or a Camera Switch's. */\nexport interface RenderPlanHop {\n /** The consumer's wire — the one whose selector the input resolvers apply. */\n readonly edge: RenderGraphEdge\n /** Whether the wire hands on one clip per row (\"each\"), as both resolvers\n * decide it: its `outputMode`, else the default of the node behind any\n * teleports, on the handle that node is wired from. */\n readonly each: boolean\n /** The type of the node the wire hands the clips on from, behind any\n * teleports: what a \"Selected\" (`last`) wire reads is that node's own output. */\n readonly source?: string\n}\n\n/** The Edit Plan behind a render and the wires between them, plan side first. */\nexport interface RenderPlanPath {\n readonly planId: string\n readonly hops: readonly RenderPlanHop[]\n}\n\nconst TELEPORT_TYPES: ReadonlySet<string> = new Set([\"teleport-send\", \"teleport-receive\"])\n/** Nodes that re-cut the EDL they are given (per clip, row for row) and hand\n * it on: the plan clip behind their output is the clip on their `edl` input. */\nconst EDL_PASS_THROUGH_TYPES: ReadonlySet<string> = new Set([\"camera-switch\"])\n\nfunction outputModeOf(data: unknown): string | undefined {\n const mode = data && typeof data === \"object\" ? (data as { outputMode?: unknown }).outputMode : undefined\n return typeof mode === \"string\" ? mode : undefined\n}\n\n/**\n * The Edit Plan whose clips a render's `edl` input comes from, and the wires\n * that pick them: up the LAST wire on its `edl` handle (both engines keep the\n * last value), through teleports and Camera Switch. `undefined` when the EDL\n * comes from anything else.\n */\nexport function renderPlanPath(\n renderId: string,\n nodes: readonly RenderGraphNode[],\n edges: readonly RenderGraphEdge[],\n): RenderPlanPath | undefined {\n const byId = new Map(nodes.map((n) => [n.id, n]))\n // The last wire on a node's `edl` handle (the value both engines keep).\n const lastEdlInto = (id: string): RenderGraphEdge | undefined =>\n edges.filter((e) => e.target === id && e.targetHandle === \"edl\").at(-1)\n // A teleport's one input — the wire both engines' teleport walks follow.\n const teleportInput = (id: string): RenderGraphEdge | undefined => edges.find((e) => e.target === id)\n const visited = new Set<string>()\n const hops: RenderPlanHop[] = []\n let consumer = lastEdlInto(renderId)\n let edge = consumer\n while (edge && consumer) {\n const node = byId.get(edge.source)\n if (!node || visited.has(node.id)) return undefined\n visited.add(node.id)\n if (TELEPORT_TYPES.has(node.type ?? \"\")) {\n edge = teleportInput(node.id)\n continue\n }\n // The resolvers read the consumer wire's mode and selector, and default the\n // mode from the node behind the teleports on the handle it is wired from.\n const mode = outputModeOf(consumer.data) ?? defaultEdgeOutputMode(node.type, edge.sourceHandle)\n hops.unshift({ edge: consumer, each: mode === \"each\", ...(node.type ? { source: node.type } : {}) })\n if (node.type === \"edit-plan\") return { planId: node.id, hops }\n if (!EDL_PASS_THROUGH_TYPES.has(node.type ?? \"\")) return undefined\n consumer = lastEdlInto(node.id)\n edge = consumer\n }\n return undefined\n}\n\n/** Whether every pass-through node on the path (Camera Switch: the target of\n * every hop but the last) ran in this run (`ranIds`) — the same-run rule. */\nfunction passThroughRan(path: RenderPlanPath, ranIds: ReadonlySet<string>): boolean {\n return path.hops.slice(0, -1).every((hop) => ranIds.has(hop.edge.target))\n}\n\n/** The Edit Plan whose clips a render's `edl` input comes from (`renderPlanPath`). */\nexport function renderPlanNodeId(\n renderId: string,\n nodes: readonly RenderGraphNode[],\n edges: readonly RenderGraphEdge[],\n): string | undefined {\n return renderPlanPath(renderId, nodes, edges)?.planId\n}\n\n/** A dropped clip's place in a plan list (TA16): `\"\"` or `null`. Clips are\n * objects as well as JSON text, so this is never \"not a string\". */\nconst isHole = (clip: unknown): boolean => clip == null || (typeof clip === \"string\" && !clip.trim())\n\n/** The clips left once the holes are dropped, in order. */\nconst keptClips = (clips: readonly unknown[]): readonly unknown[] => clips.filter((clip) => !isHole(clip))\n\n/**\n * The clips a wire that hands on ONE value passes, as both input resolvers pick\n * it (decided 2026-10-05): `item` the clip at its index (its range / list\n * selector does not apply), legacy `item:N` the N-th from 0 (else the first),\n * `all` what its selector leaves (one value only when that is one clip), and\n * \"Selected\" (`last`) the source's own output — an Edit Plan's is its first\n * KEPT clip, the scalar both engines read off a list with holes. A Camera Switch that ran per clip keeps a different clip as its own\n * output in each engine (the server its first, the editor the last to land),\n * so a Selected wire out of it names a clip only when it had one.\n */\nfunction singlePick(clips: readonly unknown[], hop: RenderPlanHop): readonly unknown[] {\n const data = hop.edge.data as (SelectorFields & { itemIndex?: unknown }) | undefined\n const mode = outputModeOf(hop.edge.data)\n if (mode === \"item\") {\n const expr = typeof data?.itemIndex === \"string\" ? data.itemIndex : \"1\"\n return [clips[resolveIndex(expr, clips.length)] ?? clips[0]]\n }\n if (mode?.startsWith(\"item:\")) return [clips[parseInt(mode.slice(5), 10)] ?? clips[0]]\n if (mode === \"all\") return selectListItems(clips as string[], data)\n if (hop.source === \"edit-plan\") return keptClips(clips).slice(0, 1)\n return clips.length === 1 ? clips : []\n}\n\n/**\n * The plan value a render iteration reads. `plan` is the plan's output as the\n * engine holds it: a clip set's clips (a list of EDLs, objects or JSON strings,\n * `\"\"` at a dropped clip), or a Tighten plan's one EDL — which every wire hands\n * on as it is. `hops` are the wires from the plan down (`renderPlanPath`). Each\n * \"each\" wire hands on the clips its selector picks — Camera Switch's row k is\n * row k of ITS selection, the render's row k row k of its own — exactly as both\n * input resolvers select before they index. A wire that hands on one value\n * hands on the clip it picks (`singlePick`), and names one only when exactly\n * one is picked.\n *\n * Holes (a dropped clip, TA16) follow the row space each wire really hands on.\n * A pass-through node (Camera Switch: every hop but the last) runs once per\n * KEPT clip of its selection and both engines store its batch by iteration, so\n * the next wire reads a list without the holes. The last wire, into the\n * render, is not compacted: a render wired straight to the plan is rowed in\n * the plan's own rows, holes included.\n *\n * With a row on an \"each\" wire, the row's clip; a row past the clips starts\n * over from the first, as the resolvers read it. With no row (a render run\n * once, or Repeat xN with nothing list-driven), the clip only when exactly one\n * KEPT clip is left — the scalar both engines read — and any other plan names\n * no single clip. An empty row names nothing.\n */\nexport function renderPlanValue(\n plan: unknown,\n row: number | undefined,\n hops: readonly RenderPlanHop[] = [],\n): unknown {\n if (!Array.isArray(plan)) return plan === null || typeof plan !== \"object\" ? undefined : plan\n let clips: readonly unknown[] = plan\n for (const [i, hop] of hops.entries()) {\n if (clips.length === 0) return undefined\n if (hop.each) {\n clips = selectListItems(clips as string[], hop.edge.data as SelectorFields | undefined)\n // Into a pass-through node: it hands on its batch by iteration, one per kept clip.\n if (i < hops.length - 1) clips = keptClips(clips)\n } else {\n clips = singlePick(clips, hop)\n if (clips.length !== 1) return undefined\n }\n }\n if (clips.length === 0) return undefined\n const rowed = row !== undefined && (hops.at(-1)?.each ?? true)\n if (rowed) {\n const clip = clips[row % clips.length]\n return isHole(clip) ? undefined : clip\n }\n const kept = keptClips(clips)\n return kept.length === 1 ? kept[0] : undefined\n}\n\n/** The clip a render iteration reads, as a key (`edlSpanKey` of the clip\n * `renderPlanValue` picks). A Tighten plan names no clip. */\nexport function renderClipKey(\n plan: unknown,\n row: number | undefined,\n hops: readonly RenderPlanHop[] = [],\n): string | undefined {\n if (!Array.isArray(plan)) return undefined\n const clip = renderPlanValue(plan, row, hops)\n return clip === undefined ? undefined : planClipKeyAt([clip], 0)\n}\n\n/**\n * The clip key a render iteration stamps — the ONE rule both engines call: the\n * Edit Plan behind its `edl` wire (`renderPlanPath`), its clips as the engine\n * holds them (`planClips`), picked by every wire on the way and indexed by the\n * iteration's list row (`renderClipKey`). Pass the row only when a list drives\n * it, never an iteration number.\n */\nexport function renderPlanClipKey(\n renderId: string,\n nodes: readonly RenderGraphNode[],\n edges: readonly RenderGraphEdge[],\n planClips: (planNode: RenderGraphNode) => unknown,\n row: number | undefined,\n): string | undefined {\n const path = renderPlanPath(renderId, nodes, edges)\n const planNode = path ? nodes.find((n) => n.id === path.planId) : undefined\n if (!path || !planNode) return undefined\n return renderClipKey(planClips(planNode), row, path.hops)\n}\n\n/**\n * The clip key of EVERY iteration of a render's fan-out, row-aligned with its\n * batch: `rows[k]` is iteration k's list row (`FanOutPlan.rows`), as both\n * engines hand it to `renderPlanClipKey` (never the iteration number). Both\n * engines stamp it on each batch row up front, so a row that FAILED still\n * names its clip (decided 2026-10-06): the batch has one row per run, not one\n * per plan clip, and a reader matches rows to clips by this key, never by\n * position. The plan is read once, as the run held it when the fan-out began.\n */\nexport function renderPlanRowClipKeys(\n renderId: string,\n nodes: readonly RenderGraphNode[],\n edges: readonly RenderGraphEdge[],\n planClips: (planNode: RenderGraphNode) => unknown,\n rows: ReadonlyArray<number | undefined>,\n ranIds: ReadonlySet<string>,\n): Array<string | undefined> {\n const path = renderPlanPath(renderId, nodes, edges)\n const planNode = path ? nodes.find((n) => n.id === path.planId) : undefined\n // The same-run rule (`renderPlanBasis`): behind a pass-through node that did\n // not run in this run the render iterates that node's SAVED batch, which can\n // come from an older review, so the plan as it is now cannot name its rows.\n if (!path || !planNode || !passThroughRan(path, ranIds)) return rows.map(() => undefined)\n const plan = planClips(planNode)\n return rows.map((row) => renderClipKey(plan, row, path.hops))\n}\n\n/** The quality a render runs at: its `quality` setting as the run holds it\n * (\"proxy\" is a Preview; anything else renders a final). */\nexport function renderRunQuality(data: Readonly<Record<string, unknown>> | undefined): RenderQuality {\n return data?.quality === \"proxy\" ? \"proxy\" : \"final\"\n}\n\n/**\n * What every row of a render's fan-out batch is stamped with before it runs\n * (decided 2026-10-06): the quality the run renders at and the clip the row is\n * sent for (`renderPlanRowClipKeys`, absent when the run cannot name it). Both\n * engines write it on every row; a landed take's own stamp wins over it, so a\n * row that FAILED still says which clip, and at which quality, it was sent for.\n */\nexport function renderSentRowStamps(\n quality: RenderQuality,\n clipKeys: ReadonlyArray<string | undefined>,\n): RunResultRowStamp[] {\n return clipKeys.map((clipKey) => ({ quality, ...(clipKey ? { clipKey } : {}) }))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The bases a render is stamped with (A3-1)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** `renderReadBasis` of every plan object already hashed (see `editPlanBasis`:\n * plan objects are never mutated in place). Keyed by the object the caller\n * holds, since stripping `meta` makes a new one every time. */\nconst readBasisByValue = new WeakMap<object, string>()\n\nconst isPlainObject = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\n\n/**\n * The fingerprint of the plan value a render read (R2 a, decided 2026-10-06):\n * `editPlanBasis` of the value with its top-level `meta` removed. No renderer\n * reads `meta`, so an edited hook (a clip's `meta.hook`, text only) leaves it\n * unchanged. A clip given as JSON text reads as its object. `undefined` for\n * anything that is not one plan object (a list, a scalar, unparsable text).\n */\nexport function renderReadBasis(value: unknown): string | undefined {\n let v = value\n if (typeof v === \"string\") {\n if (!v.trim()) return undefined\n try {\n v = JSON.parse(v)\n } catch {\n return undefined\n }\n }\n if (!isPlainObject(v)) return undefined\n const cached = readBasisByValue.get(v)\n if (cached !== undefined) return cached\n const { meta: _meta, ...rest } = v\n const basis = editPlanBasis(rest)\n readBasisByValue.set(v, basis)\n return basis\n}\n\n/** A render's own settings, as it reads them. */\nexport interface RenderSettingsInput {\n /** Any value other than \"audio\" is a video render. */\n readonly output?: unknown\n /** The default crossfade in ms; missing, negative or non-finite is a hard cut. */\n readonly crossfadeMs?: unknown\n}\n\n/**\n * The fingerprint of a render's own settings (R19 a, decided 2026-10-06):\n * `editPlanBasis({crossfadeMs, output, sources})`. `sources` is the EFFECTIVE\n * source list — the URL of each source of the effective EDL the render cuts,\n * in order, with the `sources` wires' overrides applied (`\"\"` for a source with\n * no URL). A change to any of the three changes the cut while the plan value\n * stays equal. The settings are read as the render reads them: whole ms, a\n * hard cut when the crossfade is missing.\n */\nexport function renderSettingsBasis(settings: RenderSettingsInput, sources: ReadonlyArray<string | undefined> = []): string {\n const raw = settings.crossfadeMs\n const crossfadeMs = typeof raw === \"number\" && Number.isFinite(raw) ? Math.max(0, Math.round(raw)) : 0\n return editPlanBasis({\n crossfadeMs,\n output: settings.output === \"audio\" ? \"audio\" : \"video\",\n sources: sources.map((url) => (typeof url === \"string\" ? url : \"\")),\n })\n}\n\n/**\n * The plan basis a render iteration stamps — the ONE rule both engines call\n * (R1 a, decided 2026-10-06). The plan value the iteration read\n * (`renderPlanValue` of `planOutput` — the plan's output as the run holds it —\n * along `renderPlanPath`), as `renderReadBasis`.\n *\n * THE SAME-RUN RULE. Behind a pass-through node (Camera Switch) the render reads\n * that node's output, which is the plan's current value only when the node ran\n * in the same run as the render; a SAVED output can come from an older plan.\n * So the basis is stamped only when every pass-through node on the path is in\n * `ranIds`, the nodes executed in the render's run, and is `undefined`\n * otherwise — the take then reads as unknown (stale), never as current. A\n * render wired straight to the plan (through teleports at most) reads the\n * plan's output itself and is always stamped.\n */\nexport function renderPlanBasis(\n renderId: string,\n nodes: readonly RenderGraphNode[],\n edges: readonly RenderGraphEdge[],\n planOutput: (planNode: RenderGraphNode) => unknown,\n row: number | undefined,\n ranIds: ReadonlySet<string>,\n): string | undefined {\n const path = renderPlanPath(renderId, nodes, edges)\n const planNode = path ? nodes.find((n) => n.id === path.planId) : undefined\n if (!path || !planNode) return undefined\n if (!passThroughRan(path, ranIds)) return undefined\n return renderReadBasis(renderPlanValue(planOutput(planNode), row, path.hops))\n}\n","/**\n * Legacy handle ids and the canonical id each one means today.\n *\n * A node's handle ids are declared ONCE, in the editor's `NODE_DEFINITIONS`\n * (`frontend/src/types/nodes.ts`), which generates the MCP handle map, the\n * node skills and the public tool docs. Saved workflows, though, still carry\n * the ids a node rendered before a rename, and an MCP client may send a name\n * it read in an older doc. These tables map those spellings to the current\n * ids, keyed by node TYPE, so every reader rewires an edge the same way:\n *\n * - the editor, when it loads a workflow (`use-workflow-store.ts`);\n * - the server, when an MCP client writes one (`workflow-edge-normalization.ts`),\n * and the Workflow Copilot's own edge check.\n *\n * Structural vocabulary only — no behaviour, no prompt content. A guard test\n * in the frontend fails when an alias points at a handle the node no longer\n * declares, or when a \"legacy\" spelling is still a declared handle.\n *\n * NOTE: the ffmpeg-overlapping nodes (merge-video-audio, mix-audio,\n * combine-audio, adjust-volume, trim-video, …) keep their live `in` target and\n * their `video-out` / `audio-out` pips from the #2809 migration (trim-audio\n * keeps its `in` and renders `audio`): never alias those AWAY, or a second\n * rewrite would move a live edge onto a pip the node does not render. The\n * entries below go the other way (#1877): the id their definitions used to\n * declare (`video` / `audio`) onto the pip that draws.\n */\nimport { AUDIO_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from \"./producer-types.js\"\n\n/** Legacy SOURCE handle id → canonical id, per node type. */\nexport const LEGACY_SOURCE_HANDLE_ALIASES: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n // Batch 1\n \"generate-music\": { \"audio-out\": \"audio\" },\n // Batch 2 — Suno output id normalization\n \"suno-add-instrumental\": { \"audio-out\": \"audio\" },\n \"suno-add-vocals\": { \"audio-out\": \"audio\" },\n \"suno-convert-wav\": { \"audio-out\": \"audio\" },\n \"suno-mashup\": { \"audio-out\": \"audio\" },\n \"suno-replace-section\": { \"audio-out\": \"audio\" },\n \"suno-upload-extend\": { \"audio-out\": \"audio\" },\n \"suno-music-video\": { \"video-out\": \"video\" },\n \"suno-style-boost\": { \"text-out\": \"text\" },\n \"suno-separate\": { \"vocal-out\": \"vocals\", \"instrumental-out\": \"instrumental\" },\n // Batch 4 — Processing output id normalization (non-ffmpeg ones only)\n \"split-text\": { out: \"text\" },\n // split-media produces dual-typed outputs; map each leg of the legacy\n // `*-out` pair to the new single-word form.\n \"split-media\": { \"audio-out\": \"audio\", \"video-out\": \"video\" },\n // Phase 20 — Image-producer output id normalization. Pre-migration these\n // nodes shipped a single generic `out` source handle; after the typed-handle\n // migration their source pip is the canonical type name.\n \"edit-image\": { out: \"image\" },\n \"modify-image\": { out: \"image\" },\n \"image-to-image\": { out: \"image\" },\n \"upscale-image\": { out: \"image\" },\n \"remove-background\": { out: \"image\" },\n \"face-swap\": { out: \"video\" },\n // Phase 21 — Video-producer output id normalization.\n \"motion-transfer\": { out: \"video\" },\n // Phase 22 — Upload/source-node output id normalization.\n \"reference-audio\": { \"audio-out\": \"audio\" },\n // Phase 24c — Compositing-stragglers output id normalization.\n \"speed-ramp\": { \"video-out\": \"video\" },\n \"fade-video\": { \"video-out\": \"video\" },\n \"transcode-video\": { \"video-out\": \"video\" },\n \"manual-edit\": { \"video-out\": \"video\" },\n \"social-media-format\": { \"media-out\": \"media\", \"text-out\": \"text\" },\n // Telegram Channel Feed: the pip was `out` until it took the platform's\n // text id (`text`), which its definition and docs always named.\n \"telegram-channel-feed\": { out: \"text\" },\n // Telegram Trigger: the docs once named six outputs; the component renders\n // one, `out`, and media rides it by kind on both engines.\n \"telegram-trigger\": { text: \"out\", imageUrl: \"out\", videoUrl: \"out\", audioUrl: \"out\" },\n // #1877 — the definitions now declare the pips these components render. The\n // id they used to declare (what MCP clients and the docs were told) moves\n // onto the pip that draws, so an edge written with it still connects.\n \"add-captions\": { video: \"video-out\" },\n \"adjust-volume\": { audio: \"audio-out\" },\n \"audio-fx\": { audio: \"audio-out\" },\n \"combine-audio\": { audio: \"audio-out\" },\n \"loop-video\": { video: \"video-out\" },\n \"merge-video-audio\": { video: \"video-out\" },\n \"mix-audio\": { audio: \"audio-out\" },\n \"resize-video\": { video: \"video-out\" },\n \"trim-video\": { video: \"video-out\" },\n \"save-to-storage\": { asset: \"out\" },\n // (audio-separation's old `audio` is NOT aliased: it could mean any of the\n // seven stems, and a stem is never guessed.)\n}\n\n/** Legacy TARGET handle id → canonical id, per node type. */\nexport const LEGACY_TARGET_HANDLE_ALIASES: Readonly<Record<string, Readonly<Record<string, string>>>> = {\n // Batch 1\n \"text-to-speech\": { in: \"prompt\" },\n \"text-to-audio\": { in: \"prompt\" },\n \"generate-music\": { in: \"prompt\" },\n \"audio-isolation\": { in: \"audio\" },\n \"text-to-dialogue\": { in: \"prompt\" },\n \"voice-changer\": { in: \"audio\" },\n dubbing: { in: \"audio\" },\n // voice-remix / voice-design keep the legacy `audio-style` target id intact\n // — that name is hard-coded in the runtime hint composers. Only `in` moves.\n \"voice-remix\": { in: \"audio\" },\n \"voice-design\": { in: \"prompt\" },\n \"forced-alignment\": { in: \"audio\" },\n // Batch 2 — Suno target id normalization\n \"suno-generate\": { in: \"prompt\" },\n \"suno-lyrics\": { in: \"prompt\" },\n \"suno-style-boost\": { text: \"prompt\" },\n // Batch 3 — Script & Text target id normalization\n \"generate-script\": { in: \"prompt\" },\n transcribe: { in: \"audio\" },\n // Batch 4 — Processing target id normalization (non-ffmpeg only)\n \"combine-text\": { in: \"text\" },\n \"split-text\": { in: \"text\" },\n \"split-media\": { \"video-in\": \"video\", \"audio-in\": \"audio\" },\n // Phase 20 — Image-producer target id normalization.\n \"face-swap\": { in: \"video\" },\n // Phase 21 — Video-producer target id normalization.\n \"video-to-video\": { in: \"video\" },\n \"video-upscale\": { in: \"video\" },\n \"extend-video\": { in: \"video\" },\n \"motion-transfer\": { in: \"video\" },\n \"lip-sync\": { videoIn: \"video\" },\n // Phase 24c — Compositing-stragglers target id normalization.\n \"after-effects\": { in: \"video\" },\n \"motion-graphics\": { in: \"video\" },\n \"lottie-overlay\": { in: \"video\" },\n // video-composer renders ONE target pip, `in` (\"Media\"). An earlier table\n // sent saved edges to a `video` pip the node never had; this heals those.\n \"video-composer\": { video: \"in\" },\n \"render-video\": { in: \"composition\" },\n \"speed-ramp\": { in: \"video\" },\n \"fade-video\": { in: \"video\" },\n \"transcode-video\": { in: \"video\" },\n // (manual-edit keeps `in` as a multi-asset target.)\n \"social-media-format\": { \"media-in\": \"media\", \"text-in\": \"text\" },\n}\n\n/**\n * Node types whose handles are created at run time — a column per list field,\n * a lane per Router route, a slot per overlay layer, a sub-workflow's ports —\n * so an edge into them cannot be checked against the declared handle list.\n */\nexport const DYNAMIC_HANDLE_NODE_TYPES: ReadonlySet<string> = new Set([\n \"list\",\n \"loop\",\n \"group\",\n \"collect\",\n \"router\",\n \"component\",\n \"sub-workflow\",\n \"sub-workflow-input\",\n \"sub-workflow-output\",\n \"selector\",\n // Payload parameters become handles.\n \"webhook-trigger\",\n // One `variant:<id>` handle per layer.\n \"image-overlay\",\n])\n\n/** The canonical source handle id for a legacy spelling on this node type, or the spelling itself. */\nexport function canonicalSourceHandle(nodeType: string | undefined, handle: string): string {\n return (nodeType && LEGACY_SOURCE_HANDLE_ALIASES[nodeType]?.[handle]) || handle\n}\n\n/** The canonical target handle id for a legacy spelling on this node type, or the spelling itself. */\nexport function canonicalTargetHandle(nodeType: string | undefined, handle: string): string {\n return (nodeType && LEGACY_TARGET_HANDLE_ALIASES[nodeType]?.[handle]) || handle\n}\n\n// ---------------------------------------------------------------------------\n// The classifiers that follow the tables — a target handle decided by the\n// SOURCE node's type. The editor applied these on load with five private\n// sets; they live beside the tables so the server's write-time pass\n// (backend/src/lib/workflow-edge-normalization.ts) makes the same decision.\n// ---------------------------------------------------------------------------\n\n/** Suno nodes whose typed shape split the legacy `in` into `audio` + `prompt`. */\nconst SUNO_IN_CLASSIFIER_TARGETS: ReadonlySet<string> = new Set([\n \"suno-cover\", \"suno-extend\", \"suno-replace-section\", \"suno-upload-extend\",\n])\n/** Suno nodes with a typed `voice` target — the resolvers that wire personaId\n * (suno-upload-extend's payload takes none). */\nconst SUNO_VOICE_CAPABLE_TARGETS: ReadonlySet<string> = new Set([\"suno-generate\", \"suno-cover\", \"suno-extend\"])\n/** motion-transfer's legacy `in` took an image, a video or a text; the blanket\n * `in → video` rewrite loses the first and the last. The editor's own list,\n * less face-swap: its one output is a video (the source table above says so),\n * and an image lane for it fed the resolver a video as `imageUrl`. */\nconst IMAGE_SOURCE_TYPES_FOR_CLASSIFIER: ReadonlySet<string> = new Set([\n \"generate-image\", \"upload-image\", \"edit-image\", \"image-to-image\",\n \"modify-image\", \"upscale-image\", \"remove-background\", \"generate-mask\",\n \"scene\",\n])\n/** Identity entities route to the `assets` typed handle (mirrors generate-video's). */\nconst IDENTITY_TYPES_FOR_CLASSIFIER: ReadonlySet<string> = new Set([\n \"character\", \"face\", \"object\", \"creature\", \"location\",\n])\n/** The video producers — the ONE set the canvas validators and the\n * orchestrator read, so a node is a video source here the day it is added.\n * (A frozen copy of the editor's list missed thirteen of them — youtube-video,\n * face-swap, slideshow, ai-avatar, … — and sent their legacy wires to\n * `prompt` / `audio`.) A dynamic producer (list, sub-workflow, the dual-mode\n * media nodes) is deliberately NOT one: its lane is unknown until run time,\n * and the rules treat it as they always did. */\nconst VIDEO_SOURCE_TYPES_FOR_CLASSIFIER: ReadonlySet<string> = VIDEO_PRODUCER_TYPES\n/** The audio producers plus youtube-video (audio-extractable on the backend). */\nconst AUDIO_SOURCE_TYPES_FOR_CLASSIFIER: ReadonlySet<string> = new Set([...AUDIO_PRODUCER_TYPES, \"youtube-video\"])\n/** Dual-mode revoice nodes: `audio` in → audio out, `video` in → video out. Their\n * legacy `in` was both, and the table alone would send a video to `audio`. */\nconst DUAL_MODE_REVOICE_TARGETS: ReadonlySet<string> = new Set([\"voice-changer\", \"voice-changer-pro\", \"dubbing\"])\n\n/**\n * The target handle an edge lands on AFTER the alias table, decided by the\n * source node's type. `handle` is the id after the table; `sentHandle` the id\n * as written, for the rule that only reinterprets a legacy `in`. Returns the\n * handle unchanged when no rule applies — a no-op for every typed wire.\n */\nexport function classifyLegacyTargetHandle(\n targetType: string | undefined,\n handle: string | null | undefined,\n sourceType: string | undefined,\n sentHandle: string | null | undefined = handle,\n): string | null | undefined {\n if (!targetType) return handle\n const source = sourceType ?? \"\"\n // suno-voice → a Suno node with a typed voice handle: the persona ref, even\n // when the table already sent its `in` to `prompt`.\n if (\n source === \"suno-voice\" &&\n SUNO_VOICE_CAPABLE_TARGETS.has(targetType) &&\n (handle === \"in\" || handle === \"prompt\" || handle == null)\n ) {\n return \"voice\"\n }\n // Legacy `in` on the Suno continuation nodes → `audio` for an audio source, else `prompt`.\n if (SUNO_IN_CLASSIFIER_TARGETS.has(targetType) && (handle === \"in\" || handle == null)) {\n return AUDIO_SOURCE_TYPES_FOR_CLASSIFIER.has(source) ? \"audio\" : \"prompt\"\n }\n // motion-transfer's `video` (the table's choice for its legacy `in`) by source.\n if (targetType === \"motion-transfer\" && handle === \"video\") {\n if (IDENTITY_TYPES_FOR_CLASSIFIER.has(source)) return \"assets\"\n if (IMAGE_SOURCE_TYPES_FOR_CLASSIFIER.has(source)) return \"image\"\n if (!VIDEO_SOURCE_TYPES_FOR_CLASSIFIER.has(source)) return \"prompt\"\n return handle\n }\n // video-to-video / extend-video: the pre-migration `in` also took a prompt.\n if (\n (targetType === \"video-to-video\" || targetType === \"extend-video\") &&\n handle === \"video\" &&\n !VIDEO_SOURCE_TYPES_FOR_CLASSIFIER.has(source)\n ) {\n return \"prompt\"\n }\n // A legacy `in` (or no handle) on a dual-mode revoice node: the lane the source is.\n if (DUAL_MODE_REVOICE_TARGETS.has(targetType) && (sentHandle === \"in\" || sentHandle == null)) {\n return VIDEO_SOURCE_TYPES_FOR_CLASSIFIER.has(source) ? \"video\" : \"audio\"\n }\n return handle\n}\n\n/**\n * Source pips a component renders that its NODE_DEFINITIONS entry does not\n * declare, or declares under another name — the burn-down list of issue\n * #1877, pinned to the rendered JSX by the frontend guard\n * (node-output-handles-completeness.test.ts). The server treats these as the\n * node's real outputs: an edge on one draws; an edge on the declared-only id\n * does not, so the write-time pass moves it onto the one pip that draws. An\n * entry leaves this table the day its definition is fixed.\n *\n * EMPTY since #1877 was burned down: every definition declares the pips its\n * component renders, and the ids they used to declare are source aliases\n * above. The table and `renderedSourceHandle` stay so a drift that is found\n * later can be recorded here instead of shipping an invisible edge; the guard\n * test fails until it is.\n */\nexport const RENDERED_OUTPUT_HANDLES: Readonly<Record<string, readonly string[]>> = {}\n\n/**\n * The pip that draws for a source handle a node DECLARES but does not render\n * (a `RENDERED_OUTPUT_HANDLES` node): `<handle>-out` when that is a rendered\n * pip (the ffmpeg family), else the node's single rendered pip; null when the\n * handle is not such a case, or several pips could be meant (never guessed).\n * `declaredOutputs` is the node's definition list — `NODE_HANDLES[type].outputs`\n * on the server, `NODE_DEF_MAP.get(type).outputs` in the editor. The editor\n * applies it when it LOADS a graph, the server when it WRITES one: the same\n * move, from one place.\n */\nexport function renderedSourceHandle(\n nodeType: string | undefined,\n handle: string | null | undefined,\n declaredOutputs: ReadonlyArray<string> | undefined,\n): string | null {\n if (!nodeType || !handle) return null\n const rendered = RENDERED_OUTPUT_HANDLES[nodeType]\n if (!rendered || rendered.includes(handle) || !declaredOutputs?.includes(handle)) return null\n if (rendered.includes(`${handle}-out`)) return `${handle}-out`\n return rendered.length === 1 ? rendered[0]! : null\n}\n","/**\n * Site Capture node — the wire contract both engines read.\n *\n * The node runs `POST /v1/site-capture` (a web page captured the way a phone\n * shows it: a full-page image, up to 8 section stills in page order, a section\n * map and the page's exact figures) and polls its job. What it hands on is read\n * from that job's output here, once, so the editor and a server run cannot\n * disagree:\n * - `image`: the stills, in page order. The first still is the pip's single\n * value; every still is its list (an \"each\" wire runs once per still, a\n * Bundle wire takes them all). The full-page image is never one of them.\n * - `json`: the capture's output as the route returns it.\n */\n\nexport const SITE_CAPTURE_NODE_TYPE = \"site-capture\" as const\n\n/** The stills a capture may return — the route's `maxStills` bounds. */\nexport const SITE_CAPTURE_STILLS = { min: 3, max: 8, default: 8 } as const\n\n/** A node's `maxStills`, clamped to the route's bounds; anything else is the default. */\nexport function siteCaptureMaxStills(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return SITE_CAPTURE_STILLS.default\n return Math.min(SITE_CAPTURE_STILLS.max, Math.max(SITE_CAPTURE_STILLS.min, Math.round(value)))\n}\n\n/**\n * The page a run captures: the address typed on the node, else the first web\n * address in the text wired into it (a Text node, a list item), else that\n * text's first word, which the route normalises (\"example.com\") or refuses.\n */\nexport function siteCapturePageUrl(typed: unknown, upstream?: string | null): string {\n const own = typeof typed === \"string\" ? typed.trim() : \"\"\n if (own.length > 0) return own\n const text = typeof upstream === \"string\" ? upstream.trim() : \"\"\n if (text.length === 0) return \"\"\n const link = text.match(/https?:\\/\\/[^\\s<>\"'`]+/i)\n if (link) return link[0].replace(/[),.;:!?]+$/, \"\")\n return text.split(/\\s+/)[0] ?? \"\"\n}\n\n/** One still of a capture, as its output lists it. */\nexport interface SiteCaptureStill {\n readonly url: string\n readonly index: number\n readonly label: string\n readonly category: string\n}\n\n/** The stills of a capture's output, in page order; none when it holds none. */\nexport function siteCaptureStills(output: unknown): SiteCaptureStill[] {\n if (!output || typeof output !== \"object\" || Array.isArray(output)) return []\n const raw = (output as { stills?: unknown }).stills\n if (!Array.isArray(raw)) return []\n return raw\n .filter((s): s is Record<string, unknown> => !!s && typeof s === \"object\" && typeof (s as { url?: unknown }).url === \"string\" && (s as { url: string }).url.length > 0)\n .map((s, i) => ({\n url: s.url as string,\n index: typeof s.index === \"number\" ? s.index : i,\n label: typeof s.label === \"string\" ? s.label : \"\",\n category: typeof s.category === \"string\" ? s.category : \"other\",\n }))\n .sort((a, b) => a.index - b.index)\n}\n\n/** The still URLs of a capture's output, in page order. */\nexport function siteCaptureStillUrls(output: unknown): string[] {\n return siteCaptureStills(output).map((s) => s.url)\n}\n\n/**\n * What a capture hands on: `json` (the output itself), `imageUrl` (the first\n * still) and `listResults` (every still, in page order). Nothing for an output\n * that is not an object.\n */\nexport function siteCaptureNodeOutputs(output: unknown): { json?: Record<string, unknown>; imageUrl?: string; listResults?: string[] } {\n if (!output || typeof output !== \"object\" || Array.isArray(output)) return {}\n const urls = siteCaptureStillUrls(output)\n return {\n json: output as Record<string, unknown>,\n ...(urls.length > 0 ? { imageUrl: urls[0], listResults: urls } : {}),\n }\n}\n"]}