@koda-sl/baker-cli 0.852.0-dev.d40dfecc3 → 0.852.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 (904) hide show
  1. package/README.md +3 -4
  2. package/dist/account-LYIKZSK6.js +82 -0
  3. package/dist/account-NUMWJW6T.js +83 -0
  4. package/dist/account-reads-XQW6DONK.js +230 -0
  5. package/dist/account-users-HLAIWV56.js +69 -0
  6. package/dist/account-writes-SQNABDXI.js +68 -0
  7. package/dist/accounts-3SJ7MJ2J.js +122 -0
  8. package/dist/accounts-DEE32AAB.js +505 -0
  9. package/dist/accounts-VD3L6PNZ.js +81 -0
  10. package/dist/actions-FRKZVXCV.js +55 -0
  11. package/dist/activecampaign-LEFG3NHR.js +935 -0
  12. package/dist/ad-group-writes-KEFM32CI.js +172 -0
  13. package/dist/ad-groups-LQ43ZKNL.js +70 -0
  14. package/dist/ad-writes-XPHRUOPG.js +176 -0
  15. package/dist/add-AGLSZKII.js +108 -0
  16. package/dist/add-D4LTUMP7.js +662 -0
  17. package/dist/add-SX4AZSWP.js +661 -0
  18. package/dist/ads-ANPWI4VC.js +48 -0
  19. package/dist/ads-IHKW7OPB.js +79 -0
  20. package/dist/advertisers-Y3XOK4KZ.js +126 -0
  21. package/dist/alerts-NIPFX5W7.js +153 -0
  22. package/dist/analytics-56YWZQXD.js +2791 -0
  23. package/dist/analytics-62RX4Y7M.js +461 -0
  24. package/dist/animate-FNBWXIGV.js +482 -0
  25. package/dist/assign-5LY7WGFF.js +83 -0
  26. package/dist/audience-size-QS2KK5LQ.js +77 -0
  27. package/dist/audiences-ICDEHT2G.js +280 -0
  28. package/dist/audit-DGFXEARA.js +155 -0
  29. package/dist/autocomplete-IKXTDPIZ.js +117 -0
  30. package/dist/avatars-7XQ7CHR5.js +38 -0
  31. package/dist/bid-pricing-XQH4KP6G.js +104 -0
  32. package/dist/brief-AJNHUSNI.js +511 -0
  33. package/dist/campaign-groups-2Q5ZY77R.js +118 -0
  34. package/dist/campaign-writes-KN5W3MHP.js +176 -0
  35. package/dist/campaign-writes-ZAI7K5DH.js +169 -0
  36. package/dist/campaigns-3BV5AJWW.js +78 -0
  37. package/dist/campaigns-BECFEETG.js +193 -0
  38. package/dist/campaigns-ZL7H636S.js +111 -0
  39. package/dist/canvas-B5FB2Y4Y.js +48 -0
  40. package/dist/capabilities-YC7R3SC2.js +184 -0
  41. package/dist/catalog-IUC2NDKC.js +89 -0
  42. package/dist/catalogs-OBZ6RBGL.js +130 -0
  43. package/dist/changes-VNVWJDIH.js +288 -0
  44. package/dist/chatgpt-HBHB7HCD.js +47 -0
  45. package/dist/chats-76BSMXGD.js +659 -0
  46. package/dist/check-M7BR7ZE5.js +54 -0
  47. package/dist/chunk-22FIUNKA.js +24026 -0
  48. package/dist/chunk-22FIUNKA.js.map +1 -0
  49. package/dist/chunk-2QW27HOH.js +8382 -0
  50. package/dist/chunk-34HHJJGC.js +685 -0
  51. package/dist/chunk-3E3HCJQW.js +329 -0
  52. package/dist/chunk-4K3RSU2Q.js +224 -0
  53. package/dist/chunk-56ZBWT6K.js +547 -0
  54. package/dist/chunk-5JW4S663.js +64 -0
  55. package/dist/chunk-5X32X4Y4.js +915 -0
  56. package/dist/chunk-7BLFVYVN.js +51 -0
  57. package/dist/chunk-ADAHRMJK.js +46 -0
  58. package/dist/chunk-BSZG36OF.js +98 -0
  59. package/dist/chunk-CA37TFTI.js +1124 -0
  60. package/dist/chunk-CGW6CIGD.js +479 -0
  61. package/dist/chunk-CK5QALZI.js +251 -0
  62. package/dist/chunk-DVAVH7UV.js +103 -0
  63. package/dist/chunk-DWKUYUKC.js +1862 -0
  64. package/dist/chunk-DZE2UHST.js +147 -0
  65. package/dist/chunk-E6UZBNR2.js +61 -0
  66. package/dist/chunk-FCX746P4.js +6340 -0
  67. package/dist/chunk-FGTSDCB4.js +175 -0
  68. package/dist/chunk-H7JSYC4X.js +4416 -0
  69. package/dist/chunk-H7JSYC4X.js.map +1 -0
  70. package/dist/chunk-HHX73JNN.js +313 -0
  71. package/dist/chunk-ICEPT2UY.js +260 -0
  72. package/dist/chunk-IDJKNL7P.js +392 -0
  73. package/dist/chunk-INW3G4P3.js +749 -0
  74. package/dist/chunk-IYMF3GSB.js +396 -0
  75. package/dist/chunk-KLF5K55H.js +732 -0
  76. package/dist/chunk-KQ4XRUMX.js +341 -0
  77. package/dist/chunk-LQ2OYP25.js +1577 -0
  78. package/dist/chunk-LVJTYN5B.js +155 -0
  79. package/dist/chunk-LXDZCFII.js +375 -0
  80. package/dist/chunk-MCAY57W7.js +9127 -0
  81. package/dist/chunk-MCI6ASBE.js +660 -0
  82. package/dist/chunk-MIAAADD3.js +320 -0
  83. package/dist/chunk-MJX6NXSX.js +65 -0
  84. package/dist/chunk-NAF5XSOI.js +430 -0
  85. package/dist/chunk-NLW7LW75.js +91 -0
  86. package/dist/chunk-O27BGGFC.js +152 -0
  87. package/dist/chunk-O7JZT4G3.js +262 -0
  88. package/dist/chunk-ORCAPJDH.js +3378 -0
  89. package/dist/chunk-OTLMQDGW.js +374 -0
  90. package/dist/chunk-P5YJ3EA7.js +202 -0
  91. package/dist/chunk-QAEUP6YB.js +89 -0
  92. package/dist/chunk-QTIPLD3K.js +274 -0
  93. package/dist/chunk-RUCJNF4B.js +423 -0
  94. package/dist/chunk-S3CNDNCK.js +91 -0
  95. package/dist/chunk-SAA4VKF2.js +285 -0
  96. package/dist/chunk-SCN5ZF4U.js +76 -0
  97. package/dist/chunk-SDFVQDNF.js +10430 -0
  98. package/dist/chunk-SDFVQDNF.js.map +1 -0
  99. package/dist/chunk-SELST7KK.js +170 -0
  100. package/dist/chunk-SH5WRHTG.js +78 -0
  101. package/dist/chunk-T7V2OPW2.js +127 -0
  102. package/dist/chunk-V6OAGU3U.js +509 -0
  103. package/dist/chunk-V76H3HWD.js +505 -0
  104. package/dist/chunk-VDS6NSLF.js +877 -0
  105. package/dist/chunk-VPNV2WDD.js +303 -0
  106. package/dist/chunk-VRCUW2J5.js +23 -0
  107. package/dist/chunk-WONTGSXR.js +170 -0
  108. package/dist/chunk-WUYDIH4N.js +142 -0
  109. package/dist/chunk-X6LTFBPF.js +604 -0
  110. package/dist/chunk-X7UGF2LE.js +197 -0
  111. package/dist/chunk-XOQWT2LZ.js +548 -0
  112. package/dist/chunk-XQRMBE6T.js +1883 -0
  113. package/dist/chunk-XTNXJZRK.js +863 -0
  114. package/dist/chunk-XXYRJ5YO.js +411 -0
  115. package/dist/chunk-YL7XIJ43.js +723 -0
  116. package/dist/chunk-YL7XIJ43.js.map +1 -0
  117. package/dist/chunk-YYN6I6L5.js +163 -0
  118. package/dist/chunk-ZJK3PVM2.js +723 -0
  119. package/dist/chunk-ZSC3LYTP.js +3248 -0
  120. package/dist/chunk-ZSC3LYTP.js.map +1 -0
  121. package/dist/chunk-ZVA2BZKM.js +746 -0
  122. package/dist/chunk-ZWANN4QQ.js +163 -0
  123. package/dist/chunk-ZXG5MYV4.js +26 -0
  124. package/dist/claim-W2QLJLKZ.js +218 -0
  125. package/dist/cli.js +38 -38
  126. package/dist/companies-TJR33KNS.js +36 -0
  127. package/dist/company-OGES42WN.js +311 -0
  128. package/dist/complete-FCR3UXSH.js +87 -0
  129. package/dist/connect-KACFSWER.js +46 -0
  130. package/dist/conversation-TLM7HDLK.js +100 -0
  131. package/dist/conversion-report-4WJ5D4FD.js +130 -0
  132. package/dist/conversion-upload-command-REUCOQWP.js +456 -0
  133. package/dist/conversion-writes-2W3RVOJW.js +194 -0
  134. package/dist/conversions-2QHK35VN.js +141 -0
  135. package/dist/conversions-TI3MZYCT.js +78 -0
  136. package/dist/create-5VQBHCGR.js +356 -0
  137. package/dist/create-EAY2FGWT.js +65 -0
  138. package/dist/create-EN2XXE7H.js +190 -0
  139. package/dist/create-TIKC6VNL.js +219 -0
  140. package/dist/creatives-SVNGDC45.js +48 -0
  141. package/dist/creatives-U2CIA6KE.js +235 -0
  142. package/dist/credentials-TSWUQUWC.js +291 -0
  143. package/dist/critique-K3IPZB5P.js +230 -0
  144. package/dist/crm-55ZVWDQF.js +327 -0
  145. package/dist/crm-REPCWBGZ.js +418 -0
  146. package/dist/currency-W5SXMZMS.js +91 -0
  147. package/dist/customers-UN5KGSPW.js +69 -0
  148. package/dist/data-GXAJGTKM.js +665 -0
  149. package/dist/delete-3BHIQWRA.js +60 -0
  150. package/dist/delete-UJTIAYNP.js +71 -0
  151. package/dist/delete-Z2TCOW7K.js +70 -0
  152. package/dist/demographics-EAX6HNK7.js +145 -0
  153. package/dist/discard-BJ4ZSAHC.js +72 -0
  154. package/dist/discover-RHVFYP6K.js +191 -0
  155. package/dist/domain-O5ZO3DND.js +104 -0
  156. package/dist/download-4GPS3IQ7.js +174 -0
  157. package/dist/draft-4A3QXAHP.js +389 -0
  158. package/dist/draft-APO4PJTI.js +427 -0
  159. package/dist/draft-BO5QGZBG.js +153 -0
  160. package/dist/draft-ORRHY3BU.js +227 -0
  161. package/dist/draft-UIFX2SZ4.js +340 -0
  162. package/dist/draft-ULEQPQYF.js +640 -0
  163. package/dist/engine/index.js +9 -9
  164. package/dist/experiments-LMMZJPZU.js +241 -0
  165. package/dist/extract-DJNIQC3V.js +144 -0
  166. package/dist/facets-V2AKFR2X.js +118 -0
  167. package/dist/feedback-6P545EJO.js +115 -0
  168. package/dist/fetch-D7I5WPU5.js +487 -0
  169. package/dist/fit-BMJTIAOF.js +69 -0
  170. package/dist/flows-LCP5GK5X.js +342 -0
  171. package/dist/forecast-BAP5V237.js +189 -0
  172. package/dist/forecast-DTEBUBC2.js +122 -0
  173. package/dist/funnel-HBLIX62B.js +701 -0
  174. package/dist/generate-AQZZ5LHX.js +265 -0
  175. package/dist/get-FPNIXE7U.js +114 -0
  176. package/dist/get-UEL3XOCM.js +77 -0
  177. package/dist/google-EQQN5LVF.js +164 -0
  178. package/dist/google-SO2H3SLF.js +3765 -0
  179. package/dist/google-SO2H3SLF.js.map +1 -0
  180. package/dist/google-ads-AIVV6NDM.js +201 -0
  181. package/dist/history-2SQ5K7SI.js +108 -0
  182. package/dist/history-CH3UMQOA.js +204 -0
  183. package/dist/history-EQO2QAQX.js +155 -0
  184. package/dist/hubspot-FP5F3DF6.js +853 -0
  185. package/dist/ideas-ZZVGRYFM.js +49 -0
  186. package/dist/images-WPECEULY.js +92 -0
  187. package/dist/ingest-IJYPSWBT.js +162 -0
  188. package/dist/ingest-LAONXSXA.js +31 -0
  189. package/dist/insights-FBGRQJZH.js +151 -0
  190. package/dist/inspect-AGYBLEOH.js +38 -0
  191. package/dist/intent-7Z2X4EL6.js +97 -0
  192. package/dist/keyword-gap-4INNXP3Q.js +132 -0
  193. package/dist/keyword-metrics-L2KRRX6S.js +234 -0
  194. package/dist/keywords-for-site-CMVX773Q.js +134 -0
  195. package/dist/languages-I7M63R3S.js +41 -0
  196. package/dist/leads-AZA4XCI6.js +137 -0
  197. package/dist/learn-DR3M4NWV.js +213 -0
  198. package/dist/line-item-writes-HKUDMC7V.js +212 -0
  199. package/dist/line-items-FYEWAYZI.js +107 -0
  200. package/dist/link-I3IJAUDD.js +70 -0
  201. package/dist/linkedin-LDQEX5EI.js +1498 -0
  202. package/dist/linkedin-person-KMCYKTNQ.js +142 -0
  203. package/dist/list-FF4Z7ZSJ.js +89 -0
  204. package/dist/list-IMA2UKN4.js +320 -0
  205. package/dist/list-YLNP2PNI.js +169 -0
  206. package/dist/locations-2XCXK5FB.js +41 -0
  207. package/dist/locations-7UESZZO3.js +69 -0
  208. package/dist/log-6XLS6FF6.js +98 -0
  209. package/dist/make-JBN7RVQC.js +1391 -0
  210. package/dist/map-AH3GT36P.js +519 -0
  211. package/dist/mcp-WOGB4LFO.js +1017 -0
  212. package/dist/media-sources-W7WLORRN.js +35 -0
  213. package/dist/members-PKQM7VME.js +50 -0
  214. package/dist/metrics-RZXAVZWW.js +193 -0
  215. package/dist/models-ELL6ENZ2.js +155 -0
  216. package/dist/normalize-ISMEKGAM.js +145 -0
  217. package/dist/options-LG4TJYZF.js +126 -0
  218. package/dist/organization-5F2UNO53.js +949 -0
  219. package/dist/people-4MXQW22A.js +161 -0
  220. package/dist/people-KJXAYQDE.js +171 -0
  221. package/dist/performance-BZ2D62UE.js +28 -0
  222. package/dist/performance-WDOBJ3NO.js +6294 -0
  223. package/dist/pipedrive-3YC2GR3M.js +533 -0
  224. package/dist/pixels-AWPYUSNW.js +62 -0
  225. package/dist/plan-LVTD6FZI.js +213 -0
  226. package/dist/posts-GX6MUVUG.js +36 -0
  227. package/dist/preview-JSTSQFXH.js +103 -0
  228. package/dist/promoted-tweet-writes-DP6ORCNX.js +184 -0
  229. package/dist/promoted-tweets-VCEY6KCG.js +119 -0
  230. package/dist/publish-A5HHFTWT.js +430 -0
  231. package/dist/query-MAQFFK7H.js +68 -0
  232. package/dist/read-T7HYDHSS.js +166 -0
  233. package/dist/reddit-DOZRSZG2.js +30 -0
  234. package/dist/refresh-TV4644XE.js +100 -0
  235. package/dist/release-LZ3AJFQJ.js +66 -0
  236. package/dist/relevant-pages-FEF5NHMU.js +101 -0
  237. package/dist/remove-QOMG2RPN.js +54 -0
  238. package/dist/reopen-ET5XH2A4.js +69 -0
  239. package/dist/rerun-KE4YQJTZ.js +101 -0
  240. package/dist/research-MJXOZXCS.js +266 -0
  241. package/dist/research-SYXCLMVQ.js +78 -0
  242. package/dist/reset-35CQVJUF.js +58 -0
  243. package/dist/reset-JJ7HESHC.js +58 -0
  244. package/dist/resolve-WPW3WUCU.js +125 -0
  245. package/dist/retry-OGM3ZT64.js +66 -0
  246. package/dist/retry-RZFRN73L.js +66 -0
  247. package/dist/revenue-KPTLBWRO.js +99 -0
  248. package/dist/rules-XX7BZNGH.js +163 -0
  249. package/dist/run-CI6MGV3E.js +73 -0
  250. package/dist/run-XPGJ4N2A.js +78 -0
  251. package/dist/scaffold-ad-EOUMVW77.js +1603 -0
  252. package/dist/scaffold-ad-EOUMVW77.js.map +1 -0
  253. package/dist/scaffold-static-ad-BSVNHRWI.js +998 -0
  254. package/dist/scaffold-video-HV5MA35T.js +889 -0
  255. package/dist/scaffold-video-HV5MA35T.js.map +1 -0
  256. package/dist/schedule-HBHXSZCK.js +65 -0
  257. package/dist/scheduled-agents-TF5NL3EG.js +59 -0
  258. package/dist/schema-G77I7C6X.js +136 -0
  259. package/dist/schema-YAHA75PQ.js +241 -0
  260. package/dist/search-ITIKP5AS.js +192 -0
  261. package/dist/search-terms-4F25WL6Y.js +412 -0
  262. package/dist/select-YH6VBDO5.js +134 -0
  263. package/dist/set-ONJBYEGT.js +286 -0
  264. package/dist/set-ONJBYEGT.js.map +1 -0
  265. package/dist/set-prompt-US7ZKLLB.js +204 -0
  266. package/dist/setup-links-IHQ5WONJ.js +145 -0
  267. package/dist/shopify-6WFQCGUS.js +4032 -0
  268. package/dist/site-M3MBRLZJ.js +181 -0
  269. package/dist/sources-DE7QIZSV.js +30 -0
  270. package/dist/sources-LML63ISG.js +463 -0
  271. package/dist/stale-7QJ2IRW6.js +92 -0
  272. package/dist/status-77OL4B45.js +68 -0
  273. package/dist/stock-KM3WLRHN.js +213 -0
  274. package/dist/studio-RMYKICEJ.js +49 -0
  275. package/dist/sync-L25EVQAI.js +58 -0
  276. package/dist/sync-definition-HIEWNQNI.js +74 -0
  277. package/dist/tag-manager-SL6FDPER.js +43 -0
  278. package/dist/tag-manager-SL6FDPER.js.map +1 -0
  279. package/dist/tags-AXCQCJGZ.js +24 -0
  280. package/dist/tags-KGWISKLB.js +26 -0
  281. package/dist/tags-MZFIIXL5.js +24 -0
  282. package/dist/tags-QQXAAWUY.js +182 -0
  283. package/dist/tags-RTIT7IW2.js +24 -0
  284. package/dist/targeting-criteria-IZ6DPA3L.js +113 -0
  285. package/dist/targets-OGGHIAZI.js +110 -0
  286. package/dist/testimonials-JHB7OKIY.js +32 -0
  287. package/dist/themes-FPIC5RUE.js +102 -0
  288. package/dist/top-companies-ICP6X6KR.js +250 -0
  289. package/dist/transcript-KF736ZJ3.js +168 -0
  290. package/dist/translate-2YFBXM32.js +607 -0
  291. package/dist/triggers-TSNJSHMU.js +148 -0
  292. package/dist/unlink-GH4D444H.js +73 -0
  293. package/dist/unstage-I2NYIM25.js +92 -0
  294. package/dist/update-35NWLUT5.js +237 -0
  295. package/dist/update-HEMI6DKR.js +193 -0
  296. package/dist/update-PFCO5LEE.js +175 -0
  297. package/dist/update-RUBMPMZB.js +69 -0
  298. package/dist/upload-I4WIFYMS.js +185 -0
  299. package/dist/url-options-PBCEEKX6.js +137 -0
  300. package/dist/url-params-T7KQX5FJ.js +102 -0
  301. package/dist/validate-SJAZONOS.js +180 -0
  302. package/dist/videos-P3U53TZL.js +41 -0
  303. package/dist/viewer-check-ZGUCQHTC.js +89 -0
  304. package/dist/visuals-JYOZPGB7.js +129 -0
  305. package/dist/web-SHS6TJWV.js +180 -0
  306. package/dist/winning-ads-L5HVV5OR.js +88 -0
  307. package/dist/write-commands-FUOSA6MJ.js +1555 -0
  308. package/dist/write-commands-M2CV6P4R.js +207 -0
  309. package/dist/x-VG4U3PFE.js +47 -0
  310. package/package.json +1 -1
  311. package/dist/account-Y3IDIJ3T.js +0 -82
  312. package/dist/account-Z62BVYAI.js +0 -83
  313. package/dist/account-reads-XOGHJB3K.js +0 -230
  314. package/dist/account-users-ZDZ7B4BX.js +0 -69
  315. package/dist/account-writes-EP35RCNO.js +0 -68
  316. package/dist/accounts-5ZMP7KU7.js +0 -505
  317. package/dist/accounts-7CHGRXBP.js +0 -122
  318. package/dist/accounts-SUIMNTTA.js +0 -81
  319. package/dist/actions-Q7DDN427.js +0 -55
  320. package/dist/activecampaign-BAWTDTSA.js +0 -935
  321. package/dist/ad-group-writes-EVLV4BRD.js +0 -172
  322. package/dist/ad-groups-UQRBWF2N.js +0 -70
  323. package/dist/ad-writes-EBCZ5DCY.js +0 -176
  324. package/dist/add-3WUVL3MN.js +0 -662
  325. package/dist/add-HBRY2SF6.js +0 -108
  326. package/dist/add-I4DL3DN5.js +0 -661
  327. package/dist/ads-2TOWF4GX.js +0 -79
  328. package/dist/ads-BYETTX2Y.js +0 -48
  329. package/dist/advertisers-AJQEQ3VF.js +0 -126
  330. package/dist/alerts-RJBTQ2OX.js +0 -153
  331. package/dist/analytics-RIZ4RJ6O.js +0 -2791
  332. package/dist/analytics-WLFBQOO4.js +0 -461
  333. package/dist/animate-EN7VTJEI.js +0 -482
  334. package/dist/assign-MAXWMYQ2.js +0 -83
  335. package/dist/audience-size-ISJSPSRW.js +0 -77
  336. package/dist/audiences-EZK4PDB5.js +0 -280
  337. package/dist/audit-EHKSN2WS.js +0 -155
  338. package/dist/autocomplete-I6V2CKI4.js +0 -117
  339. package/dist/avatars-775WMIZF.js +0 -38
  340. package/dist/bid-pricing-HFBQ23DD.js +0 -104
  341. package/dist/brief-LR5YTTVQ.js +0 -511
  342. package/dist/campaign-groups-DKB3K7L4.js +0 -118
  343. package/dist/campaign-writes-4T5DSUMT.js +0 -176
  344. package/dist/campaign-writes-DXV2HPB2.js +0 -169
  345. package/dist/campaigns-5BYWFXHO.js +0 -78
  346. package/dist/campaigns-6OYAQVIE.js +0 -193
  347. package/dist/campaigns-UEPNMAIN.js +0 -111
  348. package/dist/canvas-6CWER4CP.js +0 -48
  349. package/dist/capabilities-U53QPNBQ.js +0 -184
  350. package/dist/catalog-KTAYEWYO.js +0 -89
  351. package/dist/catalogs-YJSOVGDM.js +0 -130
  352. package/dist/changes-6UGDHAZW.js +0 -539
  353. package/dist/changes-6UGDHAZW.js.map +0 -1
  354. package/dist/changes-YOTRCCNB.js +0 -288
  355. package/dist/chatgpt-DPLD452Q.js +0 -47
  356. package/dist/chats-QVGXEYT6.js +0 -659
  357. package/dist/check-3YGJFXU2.js +0 -54
  358. package/dist/chunk-2AW62CH3.js +0 -46
  359. package/dist/chunk-2DGJKIHF.js +0 -78
  360. package/dist/chunk-2N5MQP65.js +0 -127
  361. package/dist/chunk-2Z2AEFVW.js +0 -915
  362. package/dist/chunk-33KRW6HE.js +0 -374
  363. package/dist/chunk-34CJ5QXO.js +0 -91
  364. package/dist/chunk-3HAKK5FO.js +0 -660
  365. package/dist/chunk-433NCHRS.js +0 -4413
  366. package/dist/chunk-433NCHRS.js.map +0 -1
  367. package/dist/chunk-4A2UZ3Q3.js +0 -24026
  368. package/dist/chunk-4A2UZ3Q3.js.map +0 -1
  369. package/dist/chunk-4MIETRE4.js +0 -103
  370. package/dist/chunk-4X6QBNIB.js +0 -320
  371. package/dist/chunk-52V5324M.js +0 -224
  372. package/dist/chunk-5OXVEKML.js +0 -548
  373. package/dist/chunk-5WQ3UHJ2.js +0 -341
  374. package/dist/chunk-624DWMDW.js +0 -8382
  375. package/dist/chunk-63XEBJIX.js +0 -262
  376. package/dist/chunk-7J5XOR5D.js +0 -98
  377. package/dist/chunk-A6B45KSH.js +0 -724
  378. package/dist/chunk-A6B45KSH.js.map +0 -1
  379. package/dist/chunk-B5RLBFMI.js +0 -26
  380. package/dist/chunk-CE6M4VLG.js +0 -1883
  381. package/dist/chunk-CG6BJIHU.js +0 -175
  382. package/dist/chunk-CHPHAPPP.js +0 -547
  383. package/dist/chunk-CPBXSDXS.js +0 -9127
  384. package/dist/chunk-CSOESLNA.js +0 -61
  385. package/dist/chunk-CV74M3H6.js +0 -723
  386. package/dist/chunk-CWYONUBS.js +0 -163
  387. package/dist/chunk-CZWMU2GB.js +0 -142
  388. package/dist/chunk-D7DLBQLS.js +0 -76
  389. package/dist/chunk-DSZ3OLQU.js +0 -65
  390. package/dist/chunk-ECUN7W2Y.js +0 -91
  391. package/dist/chunk-EDDHOHTW.js +0 -285
  392. package/dist/chunk-FCWDXKLI.js +0 -732
  393. package/dist/chunk-G4IFJB4Z.js +0 -863
  394. package/dist/chunk-GJPS6SUI.js +0 -147
  395. package/dist/chunk-HQISXBEX.js +0 -685
  396. package/dist/chunk-HSPOURUB.js +0 -877
  397. package/dist/chunk-J5LG2M5T.js +0 -155
  398. package/dist/chunk-JHPZATWG.js +0 -152
  399. package/dist/chunk-JY5OIBMR.js +0 -3378
  400. package/dist/chunk-KDCPM6W2.js +0 -6340
  401. package/dist/chunk-KUNNKG4S.js +0 -202
  402. package/dist/chunk-MQIO7WLM.js +0 -396
  403. package/dist/chunk-MQZHJAH3.js +0 -197
  404. package/dist/chunk-NOJC3PUZ.js +0 -479
  405. package/dist/chunk-NR5EJ6TC.js +0 -10361
  406. package/dist/chunk-NR5EJ6TC.js.map +0 -1
  407. package/dist/chunk-NZZ7ATO5.js +0 -3248
  408. package/dist/chunk-NZZ7ATO5.js.map +0 -1
  409. package/dist/chunk-OBT55DQA.js +0 -260
  410. package/dist/chunk-P7Q7YO4E.js +0 -170
  411. package/dist/chunk-PA5OJXQ3.js +0 -313
  412. package/dist/chunk-PMK2WXS5.js +0 -411
  413. package/dist/chunk-QSZRATGC.js +0 -746
  414. package/dist/chunk-QYOLOU5G.js +0 -329
  415. package/dist/chunk-RDRWLYFV.js +0 -604
  416. package/dist/chunk-RS4BSY3E.js +0 -509
  417. package/dist/chunk-S2V54TOS.js +0 -170
  418. package/dist/chunk-SY7CUZGW.js +0 -89
  419. package/dist/chunk-TDNOPJXB.js +0 -1124
  420. package/dist/chunk-TWSIY2FS.js +0 -392
  421. package/dist/chunk-TXLSPOLG.js +0 -505
  422. package/dist/chunk-V7T6HAPO.js +0 -375
  423. package/dist/chunk-VELT4JFT.js +0 -274
  424. package/dist/chunk-WE2FY3CF.js +0 -1862
  425. package/dist/chunk-WVXJYBWA.js +0 -251
  426. package/dist/chunk-WYBX53EI.js +0 -164
  427. package/dist/chunk-XBLVA6BC.js +0 -1577
  428. package/dist/chunk-XNTV3QKG.js +0 -64
  429. package/dist/chunk-Y62YTEPM.js +0 -23
  430. package/dist/chunk-YBSRIW5S.js +0 -51
  431. package/dist/chunk-YXYUHTQM.js +0 -423
  432. package/dist/chunk-ZBSG24TQ.js +0 -430
  433. package/dist/chunk-ZDDJTA3H.js +0 -303
  434. package/dist/chunk-ZIZBAKJF.js +0 -749
  435. package/dist/claim-XHSTFNS3.js +0 -218
  436. package/dist/companies-ITNWR5Q4.js +0 -36
  437. package/dist/company-ANL7K7CY.js +0 -311
  438. package/dist/complete-7L3ILPCT.js +0 -87
  439. package/dist/connect-SD7PFKPI.js +0 -46
  440. package/dist/conversation-SKZMGVA5.js +0 -100
  441. package/dist/conversion-report-ZPENZMJF.js +0 -130
  442. package/dist/conversion-upload-command-6TY2DIBM.js +0 -456
  443. package/dist/conversion-writes-NIDUTQHX.js +0 -194
  444. package/dist/conversions-3Q3PEAAN.js +0 -78
  445. package/dist/conversions-IMST22UQ.js +0 -141
  446. package/dist/create-5KE4XHS3.js +0 -65
  447. package/dist/create-NR4WX6PS.js +0 -190
  448. package/dist/create-QBA7VZSZ.js +0 -356
  449. package/dist/create-SPNJBN6K.js +0 -219
  450. package/dist/creatives-3E5BEATB.js +0 -48
  451. package/dist/creatives-42PW2C24.js +0 -235
  452. package/dist/credentials-T7F2PFNY.js +0 -291
  453. package/dist/critique-I2HAOTTX.js +0 -230
  454. package/dist/crm-EVN7PDQE.js +0 -418
  455. package/dist/crm-OO2WO6OG.js +0 -327
  456. package/dist/currency-CLB7ROUV.js +0 -91
  457. package/dist/customers-V7WKKZI2.js +0 -69
  458. package/dist/data-ZDTEJD6A.js +0 -665
  459. package/dist/delete-5P6K4EOJ.js +0 -71
  460. package/dist/delete-7VLK5I4V.js +0 -60
  461. package/dist/delete-TRJMPMN5.js +0 -70
  462. package/dist/demographics-K5WTHZCW.js +0 -145
  463. package/dist/discard-ANRGHE2Z.js +0 -72
  464. package/dist/discover-EAI4WDSL.js +0 -191
  465. package/dist/domain-LQ4VCYC4.js +0 -104
  466. package/dist/download-HVNPTNFN.js +0 -174
  467. package/dist/draft-4DFLYVL6.js +0 -153
  468. package/dist/draft-572T3UNG.js +0 -427
  469. package/dist/draft-IHEEODST.js +0 -340
  470. package/dist/draft-JGEZVDAS.js +0 -389
  471. package/dist/draft-KZKNUQ2I.js +0 -227
  472. package/dist/draft-R3GI7JWY.js +0 -640
  473. package/dist/experiments-C4R65GA6.js +0 -241
  474. package/dist/extract-J7Q6DYE7.js +0 -144
  475. package/dist/facets-GXBTQCAW.js +0 -118
  476. package/dist/feedback-FZTJATY7.js +0 -115
  477. package/dist/fetch-GSMAAL7N.js +0 -487
  478. package/dist/fit-K63JPI3A.js +0 -69
  479. package/dist/flows-C45HCGGB.js +0 -342
  480. package/dist/forecast-NOQNCFTX.js +0 -122
  481. package/dist/forecast-YFCLMXAV.js +0 -189
  482. package/dist/funnel-U47RAS7K.js +0 -701
  483. package/dist/generate-7467FZZH.js +0 -265
  484. package/dist/get-I77O6MRD.js +0 -114
  485. package/dist/get-J2QFYRHW.js +0 -77
  486. package/dist/google-GBGLPAP5.js +0 -3759
  487. package/dist/google-GBGLPAP5.js.map +0 -1
  488. package/dist/google-OYP3AU3I.js +0 -164
  489. package/dist/google-ads-74CPXLIA.js +0 -201
  490. package/dist/history-DD3UWZZ4.js +0 -108
  491. package/dist/history-KBTYILFZ.js +0 -204
  492. package/dist/history-M6VLA7TD.js +0 -155
  493. package/dist/hubspot-W5LYFWTH.js +0 -853
  494. package/dist/ideas-6LZ6VINW.js +0 -49
  495. package/dist/images-TUQEYLFE.js +0 -92
  496. package/dist/ingest-S7I6E2GE.js +0 -31
  497. package/dist/ingest-XJNSFWBC.js +0 -162
  498. package/dist/insights-MZ5DPH5X.js +0 -151
  499. package/dist/inspect-AQBNRV5E.js +0 -38
  500. package/dist/intent-6NJBN3OR.js +0 -97
  501. package/dist/keyword-gap-Y5J2VZDP.js +0 -132
  502. package/dist/keyword-metrics-DSEJ2KDM.js +0 -234
  503. package/dist/keywords-for-site-CYVRXIF5.js +0 -134
  504. package/dist/languages-H4VPFO7Y.js +0 -41
  505. package/dist/leads-ZRHPHJRE.js +0 -137
  506. package/dist/learn-ZR35TBVQ.js +0 -213
  507. package/dist/line-item-writes-L73P5MN7.js +0 -212
  508. package/dist/line-items-KC5PKV2T.js +0 -107
  509. package/dist/link-64FQKM6S.js +0 -70
  510. package/dist/linkedin-BD63QPGK.js +0 -1498
  511. package/dist/linkedin-person-6XXLSFDE.js +0 -142
  512. package/dist/list-KYTLJVHG.js +0 -169
  513. package/dist/list-VQNYW5R4.js +0 -89
  514. package/dist/list-WOCSNSYO.js +0 -320
  515. package/dist/locations-AR4ZTFT4.js +0 -69
  516. package/dist/locations-UPY33JUY.js +0 -41
  517. package/dist/log-LLJ3M63R.js +0 -98
  518. package/dist/make-UM6P6RD3.js +0 -1391
  519. package/dist/map-SKH3NVSQ.js +0 -519
  520. package/dist/mcp-FIBT4HAH.js +0 -1017
  521. package/dist/media-sources-ZY7S74U2.js +0 -35
  522. package/dist/members-PK3Q7AZX.js +0 -50
  523. package/dist/metrics-BNLDV4BU.js +0 -193
  524. package/dist/models-QEB3EOSF.js +0 -155
  525. package/dist/normalize-KEDHUMAB.js +0 -145
  526. package/dist/options-VYRUYL4N.js +0 -126
  527. package/dist/organization-RTJDOJEV.js +0 -949
  528. package/dist/people-3VU3QSRN.js +0 -161
  529. package/dist/people-A3YXUYUR.js +0 -171
  530. package/dist/performance-6I57ZQTD.js +0 -6294
  531. package/dist/performance-OBAWMTVU.js +0 -28
  532. package/dist/pipedrive-7AA7ZD7M.js +0 -533
  533. package/dist/pixels-M2UBKUJI.js +0 -62
  534. package/dist/plan-YP5D6JXM.js +0 -213
  535. package/dist/posts-B5DGAKAC.js +0 -36
  536. package/dist/preview-66BGLU5H.js +0 -103
  537. package/dist/promoted-tweet-writes-ZUFVAVGA.js +0 -184
  538. package/dist/promoted-tweets-3AKHKOI4.js +0 -119
  539. package/dist/publish-JPIOQKB4.js +0 -430
  540. package/dist/query-FZAFUWCX.js +0 -68
  541. package/dist/read-OMNUPQ77.js +0 -166
  542. package/dist/reddit-TKE3IXST.js +0 -30
  543. package/dist/refresh-BE7KEADW.js +0 -100
  544. package/dist/release-EUXHZEO7.js +0 -66
  545. package/dist/relevant-pages-OFFMPMKG.js +0 -101
  546. package/dist/remove-6HAN547O.js +0 -54
  547. package/dist/reopen-HBEWR4CF.js +0 -69
  548. package/dist/rerun-PLS5XYTW.js +0 -101
  549. package/dist/research-B5VHPALW.js +0 -78
  550. package/dist/research-RCD54TCL.js +0 -266
  551. package/dist/reset-DQXYM75W.js +0 -58
  552. package/dist/reset-Y7UWO233.js +0 -58
  553. package/dist/resolve-NVL3FTQU.js +0 -125
  554. package/dist/retry-MMY5H6O6.js +0 -66
  555. package/dist/retry-YCYZPMXM.js +0 -66
  556. package/dist/revenue-C24BDD5A.js +0 -99
  557. package/dist/rules-MGEJJJ4O.js +0 -163
  558. package/dist/run-2RGSNKFH.js +0 -78
  559. package/dist/run-TPAZDCY2.js +0 -73
  560. package/dist/scaffold-ad-UOXDJIVB.js +0 -1600
  561. package/dist/scaffold-ad-UOXDJIVB.js.map +0 -1
  562. package/dist/scaffold-static-ad-ZM3LOIFK.js +0 -998
  563. package/dist/scaffold-video-EBQOBQXI.js +0 -888
  564. package/dist/scaffold-video-EBQOBQXI.js.map +0 -1
  565. package/dist/schedule-IVNAF7NB.js +0 -65
  566. package/dist/scheduled-agents-NODIHKKM.js +0 -59
  567. package/dist/schema-F6QTDMJW.js +0 -136
  568. package/dist/schema-JCAV2D44.js +0 -241
  569. package/dist/search-A4GTDVIE.js +0 -192
  570. package/dist/search-terms-OFLKWSEF.js +0 -412
  571. package/dist/select-HER2THTU.js +0 -134
  572. package/dist/set-MXHNM4NH.js +0 -274
  573. package/dist/set-MXHNM4NH.js.map +0 -1
  574. package/dist/set-prompt-G27JMELE.js +0 -204
  575. package/dist/setup-links-LVJU7KHP.js +0 -145
  576. package/dist/shopify-ZQFONX3R.js +0 -4032
  577. package/dist/site-X43NFWHL.js +0 -181
  578. package/dist/sources-3KYI7TSD.js +0 -30
  579. package/dist/sources-G7QWYL2J.js +0 -463
  580. package/dist/stale-F7UXOYYY.js +0 -92
  581. package/dist/status-7RLJ7ZND.js +0 -68
  582. package/dist/stock-BSMF4FH4.js +0 -213
  583. package/dist/studio-2X6UOCAR.js +0 -49
  584. package/dist/sync-XAWDIOTT.js +0 -58
  585. package/dist/sync-definition-73CCAEDP.js +0 -74
  586. package/dist/tag-manager-YUUNKP7Q.js +0 -45
  587. package/dist/tag-manager-YUUNKP7Q.js.map +0 -1
  588. package/dist/tags-5V3NCHKE.js +0 -26
  589. package/dist/tags-HSLB3YPN.js +0 -24
  590. package/dist/tags-M57YBWGW.js +0 -182
  591. package/dist/tags-MWMY3GRG.js +0 -24
  592. package/dist/tags-QHEJUOHL.js +0 -24
  593. package/dist/targeting-criteria-FIXPSX2K.js +0 -113
  594. package/dist/targets-BVAFNU4K.js +0 -110
  595. package/dist/testimonials-RIL2ARX7.js +0 -32
  596. package/dist/themes-VAKXKG4M.js +0 -102
  597. package/dist/top-companies-KEV55RME.js +0 -250
  598. package/dist/transcript-ZOJWRPZD.js +0 -168
  599. package/dist/translate-WL6KD2X4.js +0 -607
  600. package/dist/triggers-AALSXPLW.js +0 -148
  601. package/dist/unlink-WD5D3XBG.js +0 -73
  602. package/dist/unstage-BVNREABR.js +0 -92
  603. package/dist/update-3YQGAFEX.js +0 -69
  604. package/dist/update-6355E7VP.js +0 -193
  605. package/dist/update-HYZXKLZ7.js +0 -237
  606. package/dist/update-TZLOKZ22.js +0 -175
  607. package/dist/upload-PMKPLLAA.js +0 -185
  608. package/dist/url-options-DOOHH2JE.js +0 -137
  609. package/dist/url-params-CXUAYJBD.js +0 -102
  610. package/dist/validate-YRTGO4UN.js +0 -180
  611. package/dist/videos-KGPDOMSN.js +0 -41
  612. package/dist/viewer-check-PRUOWSNM.js +0 -89
  613. package/dist/visuals-L73TEVWN.js +0 -129
  614. package/dist/web-IVYO7PY6.js +0 -180
  615. package/dist/winning-ads-QRBI3TLN.js +0 -88
  616. package/dist/write-commands-FUXBKDN7.js +0 -1555
  617. package/dist/write-commands-YECHEWMG.js +0 -207
  618. package/dist/x-WVWMOUAQ.js +0 -47
  619. /package/dist/{account-Y3IDIJ3T.js.map → account-LYIKZSK6.js.map} +0 -0
  620. /package/dist/{account-Z62BVYAI.js.map → account-NUMWJW6T.js.map} +0 -0
  621. /package/dist/{account-reads-XOGHJB3K.js.map → account-reads-XQW6DONK.js.map} +0 -0
  622. /package/dist/{account-users-ZDZ7B4BX.js.map → account-users-HLAIWV56.js.map} +0 -0
  623. /package/dist/{account-writes-EP35RCNO.js.map → account-writes-SQNABDXI.js.map} +0 -0
  624. /package/dist/{accounts-7CHGRXBP.js.map → accounts-3SJ7MJ2J.js.map} +0 -0
  625. /package/dist/{accounts-5ZMP7KU7.js.map → accounts-DEE32AAB.js.map} +0 -0
  626. /package/dist/{accounts-SUIMNTTA.js.map → accounts-VD3L6PNZ.js.map} +0 -0
  627. /package/dist/{actions-Q7DDN427.js.map → actions-FRKZVXCV.js.map} +0 -0
  628. /package/dist/{activecampaign-BAWTDTSA.js.map → activecampaign-LEFG3NHR.js.map} +0 -0
  629. /package/dist/{ad-group-writes-EVLV4BRD.js.map → ad-group-writes-KEFM32CI.js.map} +0 -0
  630. /package/dist/{ad-groups-UQRBWF2N.js.map → ad-groups-LQ43ZKNL.js.map} +0 -0
  631. /package/dist/{ad-writes-EBCZ5DCY.js.map → ad-writes-XPHRUOPG.js.map} +0 -0
  632. /package/dist/{add-HBRY2SF6.js.map → add-AGLSZKII.js.map} +0 -0
  633. /package/dist/{add-3WUVL3MN.js.map → add-D4LTUMP7.js.map} +0 -0
  634. /package/dist/{add-I4DL3DN5.js.map → add-SX4AZSWP.js.map} +0 -0
  635. /package/dist/{ads-BYETTX2Y.js.map → ads-ANPWI4VC.js.map} +0 -0
  636. /package/dist/{ads-2TOWF4GX.js.map → ads-IHKW7OPB.js.map} +0 -0
  637. /package/dist/{advertisers-AJQEQ3VF.js.map → advertisers-Y3XOK4KZ.js.map} +0 -0
  638. /package/dist/{alerts-RJBTQ2OX.js.map → alerts-NIPFX5W7.js.map} +0 -0
  639. /package/dist/{analytics-RIZ4RJ6O.js.map → analytics-56YWZQXD.js.map} +0 -0
  640. /package/dist/{analytics-WLFBQOO4.js.map → analytics-62RX4Y7M.js.map} +0 -0
  641. /package/dist/{animate-EN7VTJEI.js.map → animate-FNBWXIGV.js.map} +0 -0
  642. /package/dist/{assign-MAXWMYQ2.js.map → assign-5LY7WGFF.js.map} +0 -0
  643. /package/dist/{audience-size-ISJSPSRW.js.map → audience-size-QS2KK5LQ.js.map} +0 -0
  644. /package/dist/{audiences-EZK4PDB5.js.map → audiences-ICDEHT2G.js.map} +0 -0
  645. /package/dist/{audit-EHKSN2WS.js.map → audit-DGFXEARA.js.map} +0 -0
  646. /package/dist/{autocomplete-I6V2CKI4.js.map → autocomplete-IKXTDPIZ.js.map} +0 -0
  647. /package/dist/{avatars-775WMIZF.js.map → avatars-7XQ7CHR5.js.map} +0 -0
  648. /package/dist/{bid-pricing-HFBQ23DD.js.map → bid-pricing-XQH4KP6G.js.map} +0 -0
  649. /package/dist/{brief-LR5YTTVQ.js.map → brief-AJNHUSNI.js.map} +0 -0
  650. /package/dist/{campaign-groups-DKB3K7L4.js.map → campaign-groups-2Q5ZY77R.js.map} +0 -0
  651. /package/dist/{campaign-writes-4T5DSUMT.js.map → campaign-writes-KN5W3MHP.js.map} +0 -0
  652. /package/dist/{campaign-writes-DXV2HPB2.js.map → campaign-writes-ZAI7K5DH.js.map} +0 -0
  653. /package/dist/{campaigns-5BYWFXHO.js.map → campaigns-3BV5AJWW.js.map} +0 -0
  654. /package/dist/{campaigns-6OYAQVIE.js.map → campaigns-BECFEETG.js.map} +0 -0
  655. /package/dist/{campaigns-UEPNMAIN.js.map → campaigns-ZL7H636S.js.map} +0 -0
  656. /package/dist/{canvas-6CWER4CP.js.map → canvas-B5FB2Y4Y.js.map} +0 -0
  657. /package/dist/{capabilities-U53QPNBQ.js.map → capabilities-YC7R3SC2.js.map} +0 -0
  658. /package/dist/{catalog-KTAYEWYO.js.map → catalog-IUC2NDKC.js.map} +0 -0
  659. /package/dist/{catalogs-YJSOVGDM.js.map → catalogs-OBZ6RBGL.js.map} +0 -0
  660. /package/dist/{changes-YOTRCCNB.js.map → changes-VNVWJDIH.js.map} +0 -0
  661. /package/dist/{chatgpt-DPLD452Q.js.map → chatgpt-HBHB7HCD.js.map} +0 -0
  662. /package/dist/{chats-QVGXEYT6.js.map → chats-76BSMXGD.js.map} +0 -0
  663. /package/dist/{check-3YGJFXU2.js.map → check-M7BR7ZE5.js.map} +0 -0
  664. /package/dist/{chunk-624DWMDW.js.map → chunk-2QW27HOH.js.map} +0 -0
  665. /package/dist/{chunk-HQISXBEX.js.map → chunk-34HHJJGC.js.map} +0 -0
  666. /package/dist/{chunk-QYOLOU5G.js.map → chunk-3E3HCJQW.js.map} +0 -0
  667. /package/dist/{chunk-52V5324M.js.map → chunk-4K3RSU2Q.js.map} +0 -0
  668. /package/dist/{chunk-CHPHAPPP.js.map → chunk-56ZBWT6K.js.map} +0 -0
  669. /package/dist/{chunk-XNTV3QKG.js.map → chunk-5JW4S663.js.map} +0 -0
  670. /package/dist/{chunk-2Z2AEFVW.js.map → chunk-5X32X4Y4.js.map} +0 -0
  671. /package/dist/{chunk-YBSRIW5S.js.map → chunk-7BLFVYVN.js.map} +0 -0
  672. /package/dist/{chunk-2AW62CH3.js.map → chunk-ADAHRMJK.js.map} +0 -0
  673. /package/dist/{chunk-7J5XOR5D.js.map → chunk-BSZG36OF.js.map} +0 -0
  674. /package/dist/{chunk-TDNOPJXB.js.map → chunk-CA37TFTI.js.map} +0 -0
  675. /package/dist/{chunk-NOJC3PUZ.js.map → chunk-CGW6CIGD.js.map} +0 -0
  676. /package/dist/{chunk-WVXJYBWA.js.map → chunk-CK5QALZI.js.map} +0 -0
  677. /package/dist/{chunk-4MIETRE4.js.map → chunk-DVAVH7UV.js.map} +0 -0
  678. /package/dist/{chunk-WE2FY3CF.js.map → chunk-DWKUYUKC.js.map} +0 -0
  679. /package/dist/{chunk-GJPS6SUI.js.map → chunk-DZE2UHST.js.map} +0 -0
  680. /package/dist/{chunk-CSOESLNA.js.map → chunk-E6UZBNR2.js.map} +0 -0
  681. /package/dist/{chunk-KDCPM6W2.js.map → chunk-FCX746P4.js.map} +0 -0
  682. /package/dist/{chunk-CG6BJIHU.js.map → chunk-FGTSDCB4.js.map} +0 -0
  683. /package/dist/{chunk-PA5OJXQ3.js.map → chunk-HHX73JNN.js.map} +0 -0
  684. /package/dist/{chunk-OBT55DQA.js.map → chunk-ICEPT2UY.js.map} +0 -0
  685. /package/dist/{chunk-TWSIY2FS.js.map → chunk-IDJKNL7P.js.map} +0 -0
  686. /package/dist/{chunk-ZIZBAKJF.js.map → chunk-INW3G4P3.js.map} +0 -0
  687. /package/dist/{chunk-MQIO7WLM.js.map → chunk-IYMF3GSB.js.map} +0 -0
  688. /package/dist/{chunk-FCWDXKLI.js.map → chunk-KLF5K55H.js.map} +0 -0
  689. /package/dist/{chunk-5WQ3UHJ2.js.map → chunk-KQ4XRUMX.js.map} +0 -0
  690. /package/dist/{chunk-XBLVA6BC.js.map → chunk-LQ2OYP25.js.map} +0 -0
  691. /package/dist/{chunk-J5LG2M5T.js.map → chunk-LVJTYN5B.js.map} +0 -0
  692. /package/dist/{chunk-V7T6HAPO.js.map → chunk-LXDZCFII.js.map} +0 -0
  693. /package/dist/{chunk-CPBXSDXS.js.map → chunk-MCAY57W7.js.map} +0 -0
  694. /package/dist/{chunk-3HAKK5FO.js.map → chunk-MCI6ASBE.js.map} +0 -0
  695. /package/dist/{chunk-4X6QBNIB.js.map → chunk-MIAAADD3.js.map} +0 -0
  696. /package/dist/{chunk-DSZ3OLQU.js.map → chunk-MJX6NXSX.js.map} +0 -0
  697. /package/dist/{chunk-ZBSG24TQ.js.map → chunk-NAF5XSOI.js.map} +0 -0
  698. /package/dist/{chunk-34CJ5QXO.js.map → chunk-NLW7LW75.js.map} +0 -0
  699. /package/dist/{chunk-JHPZATWG.js.map → chunk-O27BGGFC.js.map} +0 -0
  700. /package/dist/{chunk-63XEBJIX.js.map → chunk-O7JZT4G3.js.map} +0 -0
  701. /package/dist/{chunk-JY5OIBMR.js.map → chunk-ORCAPJDH.js.map} +0 -0
  702. /package/dist/{chunk-33KRW6HE.js.map → chunk-OTLMQDGW.js.map} +0 -0
  703. /package/dist/{chunk-KUNNKG4S.js.map → chunk-P5YJ3EA7.js.map} +0 -0
  704. /package/dist/{chunk-SY7CUZGW.js.map → chunk-QAEUP6YB.js.map} +0 -0
  705. /package/dist/{chunk-VELT4JFT.js.map → chunk-QTIPLD3K.js.map} +0 -0
  706. /package/dist/{chunk-YXYUHTQM.js.map → chunk-RUCJNF4B.js.map} +0 -0
  707. /package/dist/{chunk-ECUN7W2Y.js.map → chunk-S3CNDNCK.js.map} +0 -0
  708. /package/dist/{chunk-EDDHOHTW.js.map → chunk-SAA4VKF2.js.map} +0 -0
  709. /package/dist/{chunk-D7DLBQLS.js.map → chunk-SCN5ZF4U.js.map} +0 -0
  710. /package/dist/{chunk-S2V54TOS.js.map → chunk-SELST7KK.js.map} +0 -0
  711. /package/dist/{chunk-2DGJKIHF.js.map → chunk-SH5WRHTG.js.map} +0 -0
  712. /package/dist/{chunk-2N5MQP65.js.map → chunk-T7V2OPW2.js.map} +0 -0
  713. /package/dist/{chunk-RS4BSY3E.js.map → chunk-V6OAGU3U.js.map} +0 -0
  714. /package/dist/{chunk-TXLSPOLG.js.map → chunk-V76H3HWD.js.map} +0 -0
  715. /package/dist/{chunk-HSPOURUB.js.map → chunk-VDS6NSLF.js.map} +0 -0
  716. /package/dist/{chunk-ZDDJTA3H.js.map → chunk-VPNV2WDD.js.map} +0 -0
  717. /package/dist/{chunk-Y62YTEPM.js.map → chunk-VRCUW2J5.js.map} +0 -0
  718. /package/dist/{chunk-P7Q7YO4E.js.map → chunk-WONTGSXR.js.map} +0 -0
  719. /package/dist/{chunk-CZWMU2GB.js.map → chunk-WUYDIH4N.js.map} +0 -0
  720. /package/dist/{chunk-RDRWLYFV.js.map → chunk-X6LTFBPF.js.map} +0 -0
  721. /package/dist/{chunk-MQZHJAH3.js.map → chunk-X7UGF2LE.js.map} +0 -0
  722. /package/dist/{chunk-5OXVEKML.js.map → chunk-XOQWT2LZ.js.map} +0 -0
  723. /package/dist/{chunk-CE6M4VLG.js.map → chunk-XQRMBE6T.js.map} +0 -0
  724. /package/dist/{chunk-G4IFJB4Z.js.map → chunk-XTNXJZRK.js.map} +0 -0
  725. /package/dist/{chunk-PMK2WXS5.js.map → chunk-XXYRJ5YO.js.map} +0 -0
  726. /package/dist/{chunk-CWYONUBS.js.map → chunk-YYN6I6L5.js.map} +0 -0
  727. /package/dist/{chunk-CV74M3H6.js.map → chunk-ZJK3PVM2.js.map} +0 -0
  728. /package/dist/{chunk-QSZRATGC.js.map → chunk-ZVA2BZKM.js.map} +0 -0
  729. /package/dist/{chunk-WYBX53EI.js.map → chunk-ZWANN4QQ.js.map} +0 -0
  730. /package/dist/{chunk-B5RLBFMI.js.map → chunk-ZXG5MYV4.js.map} +0 -0
  731. /package/dist/{claim-XHSTFNS3.js.map → claim-W2QLJLKZ.js.map} +0 -0
  732. /package/dist/{companies-ITNWR5Q4.js.map → companies-TJR33KNS.js.map} +0 -0
  733. /package/dist/{company-ANL7K7CY.js.map → company-OGES42WN.js.map} +0 -0
  734. /package/dist/{complete-7L3ILPCT.js.map → complete-FCR3UXSH.js.map} +0 -0
  735. /package/dist/{connect-SD7PFKPI.js.map → connect-KACFSWER.js.map} +0 -0
  736. /package/dist/{conversation-SKZMGVA5.js.map → conversation-TLM7HDLK.js.map} +0 -0
  737. /package/dist/{conversion-report-ZPENZMJF.js.map → conversion-report-4WJ5D4FD.js.map} +0 -0
  738. /package/dist/{conversion-upload-command-6TY2DIBM.js.map → conversion-upload-command-REUCOQWP.js.map} +0 -0
  739. /package/dist/{conversion-writes-NIDUTQHX.js.map → conversion-writes-2W3RVOJW.js.map} +0 -0
  740. /package/dist/{conversions-IMST22UQ.js.map → conversions-2QHK35VN.js.map} +0 -0
  741. /package/dist/{conversions-3Q3PEAAN.js.map → conversions-TI3MZYCT.js.map} +0 -0
  742. /package/dist/{create-QBA7VZSZ.js.map → create-5VQBHCGR.js.map} +0 -0
  743. /package/dist/{create-5KE4XHS3.js.map → create-EAY2FGWT.js.map} +0 -0
  744. /package/dist/{create-NR4WX6PS.js.map → create-EN2XXE7H.js.map} +0 -0
  745. /package/dist/{create-SPNJBN6K.js.map → create-TIKC6VNL.js.map} +0 -0
  746. /package/dist/{creatives-3E5BEATB.js.map → creatives-SVNGDC45.js.map} +0 -0
  747. /package/dist/{creatives-42PW2C24.js.map → creatives-U2CIA6KE.js.map} +0 -0
  748. /package/dist/{credentials-T7F2PFNY.js.map → credentials-TSWUQUWC.js.map} +0 -0
  749. /package/dist/{critique-I2HAOTTX.js.map → critique-K3IPZB5P.js.map} +0 -0
  750. /package/dist/{crm-OO2WO6OG.js.map → crm-55ZVWDQF.js.map} +0 -0
  751. /package/dist/{crm-EVN7PDQE.js.map → crm-REPCWBGZ.js.map} +0 -0
  752. /package/dist/{currency-CLB7ROUV.js.map → currency-W5SXMZMS.js.map} +0 -0
  753. /package/dist/{customers-V7WKKZI2.js.map → customers-UN5KGSPW.js.map} +0 -0
  754. /package/dist/{data-ZDTEJD6A.js.map → data-GXAJGTKM.js.map} +0 -0
  755. /package/dist/{delete-7VLK5I4V.js.map → delete-3BHIQWRA.js.map} +0 -0
  756. /package/dist/{delete-5P6K4EOJ.js.map → delete-UJTIAYNP.js.map} +0 -0
  757. /package/dist/{delete-TRJMPMN5.js.map → delete-Z2TCOW7K.js.map} +0 -0
  758. /package/dist/{demographics-K5WTHZCW.js.map → demographics-EAX6HNK7.js.map} +0 -0
  759. /package/dist/{discard-ANRGHE2Z.js.map → discard-BJ4ZSAHC.js.map} +0 -0
  760. /package/dist/{discover-EAI4WDSL.js.map → discover-RHVFYP6K.js.map} +0 -0
  761. /package/dist/{domain-LQ4VCYC4.js.map → domain-O5ZO3DND.js.map} +0 -0
  762. /package/dist/{download-HVNPTNFN.js.map → download-4GPS3IQ7.js.map} +0 -0
  763. /package/dist/{draft-JGEZVDAS.js.map → draft-4A3QXAHP.js.map} +0 -0
  764. /package/dist/{draft-572T3UNG.js.map → draft-APO4PJTI.js.map} +0 -0
  765. /package/dist/{draft-4DFLYVL6.js.map → draft-BO5QGZBG.js.map} +0 -0
  766. /package/dist/{draft-KZKNUQ2I.js.map → draft-ORRHY3BU.js.map} +0 -0
  767. /package/dist/{draft-IHEEODST.js.map → draft-UIFX2SZ4.js.map} +0 -0
  768. /package/dist/{draft-R3GI7JWY.js.map → draft-ULEQPQYF.js.map} +0 -0
  769. /package/dist/{experiments-C4R65GA6.js.map → experiments-LMMZJPZU.js.map} +0 -0
  770. /package/dist/{extract-J7Q6DYE7.js.map → extract-DJNIQC3V.js.map} +0 -0
  771. /package/dist/{facets-GXBTQCAW.js.map → facets-V2AKFR2X.js.map} +0 -0
  772. /package/dist/{feedback-FZTJATY7.js.map → feedback-6P545EJO.js.map} +0 -0
  773. /package/dist/{fetch-GSMAAL7N.js.map → fetch-D7I5WPU5.js.map} +0 -0
  774. /package/dist/{fit-K63JPI3A.js.map → fit-BMJTIAOF.js.map} +0 -0
  775. /package/dist/{flows-C45HCGGB.js.map → flows-LCP5GK5X.js.map} +0 -0
  776. /package/dist/{forecast-YFCLMXAV.js.map → forecast-BAP5V237.js.map} +0 -0
  777. /package/dist/{forecast-NOQNCFTX.js.map → forecast-DTEBUBC2.js.map} +0 -0
  778. /package/dist/{funnel-U47RAS7K.js.map → funnel-HBLIX62B.js.map} +0 -0
  779. /package/dist/{generate-7467FZZH.js.map → generate-AQZZ5LHX.js.map} +0 -0
  780. /package/dist/{get-I77O6MRD.js.map → get-FPNIXE7U.js.map} +0 -0
  781. /package/dist/{get-J2QFYRHW.js.map → get-UEL3XOCM.js.map} +0 -0
  782. /package/dist/{google-OYP3AU3I.js.map → google-EQQN5LVF.js.map} +0 -0
  783. /package/dist/{google-ads-74CPXLIA.js.map → google-ads-AIVV6NDM.js.map} +0 -0
  784. /package/dist/{history-DD3UWZZ4.js.map → history-2SQ5K7SI.js.map} +0 -0
  785. /package/dist/{history-KBTYILFZ.js.map → history-CH3UMQOA.js.map} +0 -0
  786. /package/dist/{history-M6VLA7TD.js.map → history-EQO2QAQX.js.map} +0 -0
  787. /package/dist/{hubspot-W5LYFWTH.js.map → hubspot-FP5F3DF6.js.map} +0 -0
  788. /package/dist/{ideas-6LZ6VINW.js.map → ideas-ZZVGRYFM.js.map} +0 -0
  789. /package/dist/{images-TUQEYLFE.js.map → images-WPECEULY.js.map} +0 -0
  790. /package/dist/{ingest-XJNSFWBC.js.map → ingest-IJYPSWBT.js.map} +0 -0
  791. /package/dist/{ingest-S7I6E2GE.js.map → ingest-LAONXSXA.js.map} +0 -0
  792. /package/dist/{insights-MZ5DPH5X.js.map → insights-FBGRQJZH.js.map} +0 -0
  793. /package/dist/{inspect-AQBNRV5E.js.map → inspect-AGYBLEOH.js.map} +0 -0
  794. /package/dist/{intent-6NJBN3OR.js.map → intent-7Z2X4EL6.js.map} +0 -0
  795. /package/dist/{keyword-gap-Y5J2VZDP.js.map → keyword-gap-4INNXP3Q.js.map} +0 -0
  796. /package/dist/{keyword-metrics-DSEJ2KDM.js.map → keyword-metrics-L2KRRX6S.js.map} +0 -0
  797. /package/dist/{keywords-for-site-CYVRXIF5.js.map → keywords-for-site-CMVX773Q.js.map} +0 -0
  798. /package/dist/{languages-H4VPFO7Y.js.map → languages-I7M63R3S.js.map} +0 -0
  799. /package/dist/{leads-ZRHPHJRE.js.map → leads-AZA4XCI6.js.map} +0 -0
  800. /package/dist/{learn-ZR35TBVQ.js.map → learn-DR3M4NWV.js.map} +0 -0
  801. /package/dist/{line-item-writes-L73P5MN7.js.map → line-item-writes-HKUDMC7V.js.map} +0 -0
  802. /package/dist/{line-items-KC5PKV2T.js.map → line-items-FYEWAYZI.js.map} +0 -0
  803. /package/dist/{link-64FQKM6S.js.map → link-I3IJAUDD.js.map} +0 -0
  804. /package/dist/{linkedin-BD63QPGK.js.map → linkedin-LDQEX5EI.js.map} +0 -0
  805. /package/dist/{linkedin-person-6XXLSFDE.js.map → linkedin-person-KMCYKTNQ.js.map} +0 -0
  806. /package/dist/{list-VQNYW5R4.js.map → list-FF4Z7ZSJ.js.map} +0 -0
  807. /package/dist/{list-WOCSNSYO.js.map → list-IMA2UKN4.js.map} +0 -0
  808. /package/dist/{list-KYTLJVHG.js.map → list-YLNP2PNI.js.map} +0 -0
  809. /package/dist/{locations-UPY33JUY.js.map → locations-2XCXK5FB.js.map} +0 -0
  810. /package/dist/{locations-AR4ZTFT4.js.map → locations-7UESZZO3.js.map} +0 -0
  811. /package/dist/{log-LLJ3M63R.js.map → log-6XLS6FF6.js.map} +0 -0
  812. /package/dist/{make-UM6P6RD3.js.map → make-JBN7RVQC.js.map} +0 -0
  813. /package/dist/{map-SKH3NVSQ.js.map → map-AH3GT36P.js.map} +0 -0
  814. /package/dist/{mcp-FIBT4HAH.js.map → mcp-WOGB4LFO.js.map} +0 -0
  815. /package/dist/{media-sources-ZY7S74U2.js.map → media-sources-W7WLORRN.js.map} +0 -0
  816. /package/dist/{members-PK3Q7AZX.js.map → members-PKQM7VME.js.map} +0 -0
  817. /package/dist/{metrics-BNLDV4BU.js.map → metrics-RZXAVZWW.js.map} +0 -0
  818. /package/dist/{models-QEB3EOSF.js.map → models-ELL6ENZ2.js.map} +0 -0
  819. /package/dist/{normalize-KEDHUMAB.js.map → normalize-ISMEKGAM.js.map} +0 -0
  820. /package/dist/{options-VYRUYL4N.js.map → options-LG4TJYZF.js.map} +0 -0
  821. /package/dist/{organization-RTJDOJEV.js.map → organization-5F2UNO53.js.map} +0 -0
  822. /package/dist/{people-3VU3QSRN.js.map → people-4MXQW22A.js.map} +0 -0
  823. /package/dist/{people-A3YXUYUR.js.map → people-KJXAYQDE.js.map} +0 -0
  824. /package/dist/{performance-OBAWMTVU.js.map → performance-BZ2D62UE.js.map} +0 -0
  825. /package/dist/{performance-6I57ZQTD.js.map → performance-WDOBJ3NO.js.map} +0 -0
  826. /package/dist/{pipedrive-7AA7ZD7M.js.map → pipedrive-3YC2GR3M.js.map} +0 -0
  827. /package/dist/{pixels-M2UBKUJI.js.map → pixels-AWPYUSNW.js.map} +0 -0
  828. /package/dist/{plan-YP5D6JXM.js.map → plan-LVTD6FZI.js.map} +0 -0
  829. /package/dist/{posts-B5DGAKAC.js.map → posts-GX6MUVUG.js.map} +0 -0
  830. /package/dist/{preview-66BGLU5H.js.map → preview-JSTSQFXH.js.map} +0 -0
  831. /package/dist/{promoted-tweet-writes-ZUFVAVGA.js.map → promoted-tweet-writes-DP6ORCNX.js.map} +0 -0
  832. /package/dist/{promoted-tweets-3AKHKOI4.js.map → promoted-tweets-VCEY6KCG.js.map} +0 -0
  833. /package/dist/{publish-JPIOQKB4.js.map → publish-A5HHFTWT.js.map} +0 -0
  834. /package/dist/{query-FZAFUWCX.js.map → query-MAQFFK7H.js.map} +0 -0
  835. /package/dist/{read-OMNUPQ77.js.map → read-T7HYDHSS.js.map} +0 -0
  836. /package/dist/{reddit-TKE3IXST.js.map → reddit-DOZRSZG2.js.map} +0 -0
  837. /package/dist/{refresh-BE7KEADW.js.map → refresh-TV4644XE.js.map} +0 -0
  838. /package/dist/{release-EUXHZEO7.js.map → release-LZ3AJFQJ.js.map} +0 -0
  839. /package/dist/{relevant-pages-OFFMPMKG.js.map → relevant-pages-FEF5NHMU.js.map} +0 -0
  840. /package/dist/{remove-6HAN547O.js.map → remove-QOMG2RPN.js.map} +0 -0
  841. /package/dist/{reopen-HBEWR4CF.js.map → reopen-ET5XH2A4.js.map} +0 -0
  842. /package/dist/{rerun-PLS5XYTW.js.map → rerun-KE4YQJTZ.js.map} +0 -0
  843. /package/dist/{research-RCD54TCL.js.map → research-MJXOZXCS.js.map} +0 -0
  844. /package/dist/{research-B5VHPALW.js.map → research-SYXCLMVQ.js.map} +0 -0
  845. /package/dist/{reset-DQXYM75W.js.map → reset-35CQVJUF.js.map} +0 -0
  846. /package/dist/{reset-Y7UWO233.js.map → reset-JJ7HESHC.js.map} +0 -0
  847. /package/dist/{resolve-NVL3FTQU.js.map → resolve-WPW3WUCU.js.map} +0 -0
  848. /package/dist/{retry-MMY5H6O6.js.map → retry-OGM3ZT64.js.map} +0 -0
  849. /package/dist/{retry-YCYZPMXM.js.map → retry-RZFRN73L.js.map} +0 -0
  850. /package/dist/{revenue-C24BDD5A.js.map → revenue-KPTLBWRO.js.map} +0 -0
  851. /package/dist/{rules-MGEJJJ4O.js.map → rules-XX7BZNGH.js.map} +0 -0
  852. /package/dist/{run-TPAZDCY2.js.map → run-CI6MGV3E.js.map} +0 -0
  853. /package/dist/{run-2RGSNKFH.js.map → run-XPGJ4N2A.js.map} +0 -0
  854. /package/dist/{scaffold-static-ad-ZM3LOIFK.js.map → scaffold-static-ad-BSVNHRWI.js.map} +0 -0
  855. /package/dist/{schedule-IVNAF7NB.js.map → schedule-HBHXSZCK.js.map} +0 -0
  856. /package/dist/{scheduled-agents-NODIHKKM.js.map → scheduled-agents-TF5NL3EG.js.map} +0 -0
  857. /package/dist/{schema-F6QTDMJW.js.map → schema-G77I7C6X.js.map} +0 -0
  858. /package/dist/{schema-JCAV2D44.js.map → schema-YAHA75PQ.js.map} +0 -0
  859. /package/dist/{search-A4GTDVIE.js.map → search-ITIKP5AS.js.map} +0 -0
  860. /package/dist/{search-terms-OFLKWSEF.js.map → search-terms-4F25WL6Y.js.map} +0 -0
  861. /package/dist/{select-HER2THTU.js.map → select-YH6VBDO5.js.map} +0 -0
  862. /package/dist/{set-prompt-G27JMELE.js.map → set-prompt-US7ZKLLB.js.map} +0 -0
  863. /package/dist/{setup-links-LVJU7KHP.js.map → setup-links-IHQ5WONJ.js.map} +0 -0
  864. /package/dist/{shopify-ZQFONX3R.js.map → shopify-6WFQCGUS.js.map} +0 -0
  865. /package/dist/{site-X43NFWHL.js.map → site-M3MBRLZJ.js.map} +0 -0
  866. /package/dist/{sources-3KYI7TSD.js.map → sources-DE7QIZSV.js.map} +0 -0
  867. /package/dist/{sources-G7QWYL2J.js.map → sources-LML63ISG.js.map} +0 -0
  868. /package/dist/{stale-F7UXOYYY.js.map → stale-7QJ2IRW6.js.map} +0 -0
  869. /package/dist/{status-7RLJ7ZND.js.map → status-77OL4B45.js.map} +0 -0
  870. /package/dist/{stock-BSMF4FH4.js.map → stock-KM3WLRHN.js.map} +0 -0
  871. /package/dist/{studio-2X6UOCAR.js.map → studio-RMYKICEJ.js.map} +0 -0
  872. /package/dist/{sync-XAWDIOTT.js.map → sync-L25EVQAI.js.map} +0 -0
  873. /package/dist/{sync-definition-73CCAEDP.js.map → sync-definition-HIEWNQNI.js.map} +0 -0
  874. /package/dist/{tags-HSLB3YPN.js.map → tags-AXCQCJGZ.js.map} +0 -0
  875. /package/dist/{tags-5V3NCHKE.js.map → tags-KGWISKLB.js.map} +0 -0
  876. /package/dist/{tags-MWMY3GRG.js.map → tags-MZFIIXL5.js.map} +0 -0
  877. /package/dist/{tags-M57YBWGW.js.map → tags-QQXAAWUY.js.map} +0 -0
  878. /package/dist/{tags-QHEJUOHL.js.map → tags-RTIT7IW2.js.map} +0 -0
  879. /package/dist/{targeting-criteria-FIXPSX2K.js.map → targeting-criteria-IZ6DPA3L.js.map} +0 -0
  880. /package/dist/{targets-BVAFNU4K.js.map → targets-OGGHIAZI.js.map} +0 -0
  881. /package/dist/{testimonials-RIL2ARX7.js.map → testimonials-JHB7OKIY.js.map} +0 -0
  882. /package/dist/{themes-VAKXKG4M.js.map → themes-FPIC5RUE.js.map} +0 -0
  883. /package/dist/{top-companies-KEV55RME.js.map → top-companies-ICP6X6KR.js.map} +0 -0
  884. /package/dist/{transcript-ZOJWRPZD.js.map → transcript-KF736ZJ3.js.map} +0 -0
  885. /package/dist/{translate-WL6KD2X4.js.map → translate-2YFBXM32.js.map} +0 -0
  886. /package/dist/{triggers-AALSXPLW.js.map → triggers-TSNJSHMU.js.map} +0 -0
  887. /package/dist/{unlink-WD5D3XBG.js.map → unlink-GH4D444H.js.map} +0 -0
  888. /package/dist/{unstage-BVNREABR.js.map → unstage-I2NYIM25.js.map} +0 -0
  889. /package/dist/{update-HYZXKLZ7.js.map → update-35NWLUT5.js.map} +0 -0
  890. /package/dist/{update-6355E7VP.js.map → update-HEMI6DKR.js.map} +0 -0
  891. /package/dist/{update-TZLOKZ22.js.map → update-PFCO5LEE.js.map} +0 -0
  892. /package/dist/{update-3YQGAFEX.js.map → update-RUBMPMZB.js.map} +0 -0
  893. /package/dist/{upload-PMKPLLAA.js.map → upload-I4WIFYMS.js.map} +0 -0
  894. /package/dist/{url-options-DOOHH2JE.js.map → url-options-PBCEEKX6.js.map} +0 -0
  895. /package/dist/{url-params-CXUAYJBD.js.map → url-params-T7KQX5FJ.js.map} +0 -0
  896. /package/dist/{validate-YRTGO4UN.js.map → validate-SJAZONOS.js.map} +0 -0
  897. /package/dist/{videos-KGPDOMSN.js.map → videos-P3U53TZL.js.map} +0 -0
  898. /package/dist/{viewer-check-PRUOWSNM.js.map → viewer-check-ZGUCQHTC.js.map} +0 -0
  899. /package/dist/{visuals-L73TEVWN.js.map → visuals-JYOZPGB7.js.map} +0 -0
  900. /package/dist/{web-IVYO7PY6.js.map → web-SHS6TJWV.js.map} +0 -0
  901. /package/dist/{winning-ads-QRBI3TLN.js.map → winning-ads-L5HVV5OR.js.map} +0 -0
  902. /package/dist/{write-commands-FUXBKDN7.js.map → write-commands-FUOSA6MJ.js.map} +0 -0
  903. /package/dist/{write-commands-YECHEWMG.js.map → write-commands-M2CV6P4R.js.map} +0 -0
  904. /package/dist/{x-WVWMOUAQ.js.map → x-VG4U3PFE.js.map} +0 -0
@@ -0,0 +1,3378 @@
1
+ import {
2
+ nodeParamsPreview
3
+ } from "./chunk-5JW4S663.js";
4
+ import {
5
+ keepRunResult,
6
+ previewsOf
7
+ } from "./chunk-KQ4XRUMX.js";
8
+ import {
9
+ correctedGraph,
10
+ keptPictureForSizes,
11
+ keptPictureGraph,
12
+ outputRatioWarningsFor,
13
+ runResult,
14
+ shownBaseline,
15
+ shownVersion,
16
+ unreviewedHint,
17
+ verticalRelayoutHints
18
+ } from "./chunk-XXYRJ5YO.js";
19
+ import {
20
+ waitForSheet
21
+ } from "./chunk-WN4KX7GE.js";
22
+ import {
23
+ fetchBrandLogo
24
+ } from "./chunk-EKC2AY2Z.js";
25
+ import {
26
+ runBaker,
27
+ seriesLeadsAbove,
28
+ seriesMembers,
29
+ seriesRunHints,
30
+ writeSeriesMemberCanvas
31
+ } from "./chunk-3E3HCJQW.js";
32
+ import {
33
+ correctedPicture,
34
+ growFromVersion,
35
+ isStaticAdCanvas,
36
+ keepsChosen,
37
+ madeThisRun,
38
+ pictureRecord,
39
+ previousAdImage,
40
+ previousDelivered,
41
+ relaysSizesOnly,
42
+ staticReviewCredits,
43
+ variantImage,
44
+ versionRun
45
+ } from "./chunk-MCI6ASBE.js";
46
+ import {
47
+ buildFailedRunRecord,
48
+ buildInitialRunRecord,
49
+ buildRunRecord,
50
+ creativeSlugFromCanvasPath,
51
+ finalFiles,
52
+ finalOutputLabelsFromCanvas,
53
+ nodeOutputsToRecord,
54
+ withFacts
55
+ } from "./chunk-FGTSDCB4.js";
56
+ import {
57
+ RENDERS_PER_REASON,
58
+ canvasFreshness,
59
+ clearLegacyDirtyMarker,
60
+ readRenderState,
61
+ recordReasons,
62
+ recordRemake,
63
+ recordRenderAttempt,
64
+ recordRendered,
65
+ recordReviewOutcome,
66
+ recordSeriesLeadRun,
67
+ recordSnapshot,
68
+ spentReasons,
69
+ withDurableRenders
70
+ } from "./chunk-P5YJ3EA7.js";
71
+ import {
72
+ AUTO_FIX_ROUNDS,
73
+ BRAND_LOGO_ROLE,
74
+ CLAIMS_MODEL,
75
+ CLAIMS_REQUEST,
76
+ CanvasPrepareError,
77
+ PATCHED_WORDS,
78
+ PEOPLE_PROMPT_VERSION,
79
+ REBUILD_FILE,
80
+ UNREAD_WORDS,
81
+ anchorLines,
82
+ autoFixChoice,
83
+ carryUnchanged,
84
+ castHandles,
85
+ computeSourceSha,
86
+ correctFrom,
87
+ deliveredLogoFindings,
88
+ droppedKeeps,
89
+ exitOnPrepareError,
90
+ findBrandRoot,
91
+ fixMemoryOf,
92
+ formatOfAdaptId,
93
+ formatOfSizeNode,
94
+ frameChanges,
95
+ isNativeCanvas,
96
+ keptLostHint,
97
+ listSceneFiles,
98
+ logoMissesBefore,
99
+ logoPlacementFindings,
100
+ lostVital,
101
+ paidFor,
102
+ peoplePrompt,
103
+ persistingDefects,
104
+ placedLogoBoxes,
105
+ placedTooFar,
106
+ plainRunEdit,
107
+ plannedFormats,
108
+ plannedPlacements,
109
+ prepareCanvas,
110
+ readIdeaAnchor,
111
+ readPeople,
112
+ readStaticBrandKit,
113
+ readStaticPromptJson,
114
+ rederiveFromVariant,
115
+ rendersNewPicture,
116
+ repeatsFailedFix,
117
+ repeatsFailedRemake,
118
+ seriesOf,
119
+ stopsWithoutRepair,
120
+ switchToLogoFile,
121
+ uncastPeople,
122
+ unmendedSource,
123
+ wireNamedPeople,
124
+ wireProofBadges,
125
+ withDeliveredSizes,
126
+ withExtendedSizes,
127
+ withPlannedRelay,
128
+ withRelayEdit,
129
+ withRelayNote
130
+ } from "./chunk-SDFVQDNF.js";
131
+ import {
132
+ advanceDefinitionStatus
133
+ } from "./chunk-3ACMDRSE.js";
134
+ import {
135
+ ViewerAnswerSchema,
136
+ describeViewer,
137
+ gatewayViewerModel,
138
+ jevReadJudge,
139
+ judgeViewerAnswer,
140
+ liveViewerLookups,
141
+ misreadings,
142
+ sureEnough,
143
+ viewerCheckBeforeRender,
144
+ viewerCheckSkip
145
+ } from "./chunk-KLF5K55H.js";
146
+ import {
147
+ mayBeCorrection,
148
+ readTurnRenders,
149
+ recordTurnRender,
150
+ recordViewerFail,
151
+ roundFitsRun,
152
+ runRenderChain,
153
+ turnRefusals,
154
+ turnRenderRefusal,
155
+ updateTurnRenders,
156
+ viewerChecksSpent
157
+ } from "./chunk-T7V2OPW2.js";
158
+ import {
159
+ heldRules
160
+ } from "./chunk-WUYDIH4N.js";
161
+ import {
162
+ readAvatars,
163
+ writeAvatars
164
+ } from "./chunk-QGIRVS5R.js";
165
+ import {
166
+ readCompanyReading
167
+ } from "./chunk-NAF5XSOI.js";
168
+ import {
169
+ frontmatterOf,
170
+ ruleTells
171
+ } from "./chunk-ZJK3PVM2.js";
172
+ import {
173
+ holdUnbilledSpend,
174
+ holdWhenSettled,
175
+ sendBillingSpend,
176
+ takeUnbilledSpend
177
+ } from "./chunk-WJL56TQE.js";
178
+ import {
179
+ canvasOutputsRoot,
180
+ describeRewrites,
181
+ findWorkspaceRoot,
182
+ localPathParam
183
+ } from "./chunk-PDHKESLI.js";
184
+ import {
185
+ MISALIGNED,
186
+ ValidationError,
187
+ asReviewNote,
188
+ compareSizes,
189
+ createEngineFromEnv,
190
+ planVertical,
191
+ resolveConcurrency,
192
+ sizeDifferenceFinding,
193
+ takeCheckWarnings,
194
+ ulid
195
+ } from "./chunk-MCAY57W7.js";
196
+ import {
197
+ BackendClient,
198
+ LOGO_COMPOSITE_ROLE,
199
+ STATIC_ADAPT_FORMAT_ROLE,
200
+ STATIC_ADAPT_ROLE,
201
+ STATIC_FIX_ROLE,
202
+ STATIC_FORMAT_ROLE,
203
+ STATIC_LEAD_ROLE,
204
+ STATIC_MASTER_ROLE,
205
+ STATIC_PICK_ROLE,
206
+ STATIC_PLACE_ROLE,
207
+ STATIC_PLATE_ROLE,
208
+ STATIC_SAFE_FIT_ROLE,
209
+ STATIC_SIZE_ROLE,
210
+ STATIC_VARIANTS_ROLE,
211
+ STATIC_VARIANT_CALL_ROLE,
212
+ VARIANT_PREFILTER_ROLE,
213
+ castsNobody,
214
+ isPlateCanvas,
215
+ nodesWithRole,
216
+ regenerateTargets,
217
+ relaidPictureRole,
218
+ rolesById,
219
+ staticMasterFormat
220
+ } from "./chunk-FCX746P4.js";
221
+ import {
222
+ bytesOf,
223
+ judgeWinner,
224
+ nearIdenticalFindings,
225
+ parseJudgeScores,
226
+ reviewRenderedStatic,
227
+ samePictureSizes,
228
+ staticSafeArea,
229
+ staticVerdict
230
+ } from "./chunk-LQ2OYP25.js";
231
+ import {
232
+ reviewAgainstRules
233
+ } from "./chunk-ADAHRMJK.js";
234
+ import {
235
+ AdSpecSchema,
236
+ adSpecJsonSchema,
237
+ conceptSummary,
238
+ decisionOf,
239
+ isAdSpec,
240
+ isMemeTemplate,
241
+ isVital,
242
+ nativeChrome,
243
+ nativeCopy,
244
+ nativeSurfaceName,
245
+ readAdSpec,
246
+ readInterfaceWords
247
+ } from "./chunk-DWKUYUKC.js";
248
+ import {
249
+ jevCitationJudge
250
+ } from "./chunk-IWPYFKQZ.js";
251
+ import {
252
+ RENDER_REVIEW_MODEL,
253
+ RENDER_REVIEW_UNAVAILABLE,
254
+ askAboutImages,
255
+ askAboutText,
256
+ reviewContextBeside,
257
+ reviewRenderedVideo,
258
+ rulesDigest,
259
+ sceneWindowsBeside,
260
+ sceneWindowsOnDelivered,
261
+ videoPathFromOutput
262
+ } from "./chunk-5X32X4Y4.js";
263
+ import {
264
+ GLANCE_CHECK_MODEL,
265
+ VIEWER_CHECK_MODEL
266
+ } from "./chunk-ZSC3LYTP.js";
267
+ import {
268
+ describeMarket
269
+ } from "./chunk-QKPQ3YUV.js";
270
+ import {
271
+ BackendHttpError,
272
+ LayerExecutionError,
273
+ RunAbortedError,
274
+ describeFailureReason,
275
+ requireCredentialsFromEnv,
276
+ runFailureCode,
277
+ runFailureFix
278
+ } from "./chunk-AEYE57MX.js";
279
+ import {
280
+ sha256Hex
281
+ } from "./chunk-WZ5YRUQU.js";
282
+ import {
283
+ creativesReasonsResponseSchema
284
+ } from "./chunk-2QW27HOH.js";
285
+ import {
286
+ apiPost
287
+ } from "./chunk-SZCEKDLE.js";
288
+ import {
289
+ optionalChatId,
290
+ optionalTurnId
291
+ } from "./chunk-XQIAWIO5.js";
292
+
293
+ // src/commands/canvas/run.ts
294
+ import { readFile as readFile7 } from "fs/promises";
295
+ import path9 from "path";
296
+ import { defineCommand } from "citty";
297
+
298
+ // src/commands/canvas/remembered-review.ts
299
+ import { createHash } from "crypto";
300
+ import { mkdir, readFile, writeFile } from "fs/promises";
301
+ import path from "path";
302
+ async function rememberedVideoReview(opts, review) {
303
+ const bytes = await readFile(opts.video).catch(() => null);
304
+ if (bytes === null) return review();
305
+ const key = createHash("sha256").update(bytes).update(JSON.stringify(opts.asked ?? null)).digest("hex");
306
+ const file = path.join(opts.cacheDir, "video-review", `${key}.json`);
307
+ const kept = await readFile(file, "utf8").then((t) => JSON.parse(t), () => null);
308
+ if (Array.isArray(kept)) return kept;
309
+ const findings = await review();
310
+ if (findings !== null) {
311
+ await mkdir(path.dirname(file), { recursive: true }).catch(() => void 0);
312
+ await writeFile(file, JSON.stringify(findings), "utf8").catch(() => void 0);
313
+ }
314
+ return findings;
315
+ }
316
+
317
+ // src/commands/canvas/run-progress.ts
318
+ function clampNodeError(error) {
319
+ return { ...error, message: error.message.slice(0, 2e3) };
320
+ }
321
+ var RunProgressTracker = class {
322
+ runId;
323
+ meta;
324
+ startedAt;
325
+ nodes = /* @__PURE__ */ new Map();
326
+ finalLabels;
327
+ planned = false;
328
+ constructor(runId, meta, finalLabels) {
329
+ this.runId = runId;
330
+ this.meta = meta;
331
+ this.finalLabels = finalLabels;
332
+ this.startedAt = Date.now();
333
+ }
334
+ apply(event) {
335
+ if (event.kind === "plan") {
336
+ for (const node of event.nodes) {
337
+ this.nodes.set(node.node_id, {
338
+ nodeId: node.node_id,
339
+ nodeType: node.node_type,
340
+ cached: false,
341
+ credits: 0,
342
+ durationMs: 0,
343
+ outputs: [],
344
+ deps: node.deps,
345
+ status: "pending",
346
+ paramsPreview: nodeParamsPreview(node.params, node.deps),
347
+ ...node.role !== void 0 ? { role: node.role } : {}
348
+ });
349
+ }
350
+ this.planned = true;
351
+ return;
352
+ }
353
+ if (event.kind === "node_start") {
354
+ this.patchNode(event.node_id, { status: "running" });
355
+ return;
356
+ }
357
+ if (event.kind === "node_settled") {
358
+ this.patchNode(event.run.node_id, {
359
+ status: "completed",
360
+ cached: event.run.cached,
361
+ credits: event.run.credits,
362
+ durationMs: event.run.duration_ms,
363
+ outputs: nodeOutputsToRecord(
364
+ event.outputs,
365
+ event.run.node_id === this.finalLabels?.nodeId ? this.finalLabels.labels : void 0
366
+ ),
367
+ ...withFacts(event.outputs)
368
+ });
369
+ return;
370
+ }
371
+ this.patchNode(event.node_id, { status: "failed", error: clampNodeError(event.error) });
372
+ }
373
+ /** True once the plan event landed — before that there is nothing worth posting. */
374
+ hasPlan() {
375
+ return this.planned;
376
+ }
377
+ /** Plan facts (deps + params preview) for stamping the terminal record's nodes. */
378
+ planInfo() {
379
+ const info = /* @__PURE__ */ new Map();
380
+ for (const node of this.nodes.values()) {
381
+ info.set(node.nodeId, {
382
+ deps: node.deps ?? [],
383
+ paramsPreview: node.paramsPreview,
384
+ ...node.role !== void 0 ? { role: node.role } : {}
385
+ });
386
+ }
387
+ return info;
388
+ }
389
+ /** The current in-flight state as a postable full record. */
390
+ snapshot() {
391
+ const nodes = [...this.nodes.values()];
392
+ return {
393
+ runId: this.runId,
394
+ ...this.meta,
395
+ status: "running",
396
+ stats: {
397
+ totalNodes: nodes.length,
398
+ cachedNodes: nodes.filter((n) => n.cached).length,
399
+ totalCredits: nodes.reduce((sum, n) => sum + n.credits, 0),
400
+ durationMs: Date.now() - this.startedAt
401
+ },
402
+ nodes
403
+ };
404
+ }
405
+ /**
406
+ * Terminal record for a failed run, preserving what each node got to —
407
+ * completed nodes keep their outputs so the graph shows exactly where the
408
+ * run died instead of an empty husk.
409
+ */
410
+ failedSnapshot(errorMessage) {
411
+ const snapshot = this.snapshot();
412
+ return {
413
+ ...snapshot,
414
+ status: "failed",
415
+ errorMessage: errorMessage.slice(0, 2e3),
416
+ stats: { ...snapshot.stats, durationMs: Date.now() - this.startedAt }
417
+ };
418
+ }
419
+ patchNode(nodeId, patch) {
420
+ const existing = this.nodes.get(nodeId);
421
+ if (!existing) return;
422
+ this.nodes.set(nodeId, { ...existing, ...patch, status: patch.status ?? existing.status });
423
+ }
424
+ };
425
+ var RunRecordPoster = class {
426
+ post;
427
+ latest = null;
428
+ inflight = null;
429
+ warned = false;
430
+ keepaliveTimer = null;
431
+ constructor(post) {
432
+ this.post = post;
433
+ }
434
+ /** Queue a progress snapshot; returns immediately. */
435
+ enqueue(payload) {
436
+ this.latest = payload;
437
+ if (!this.inflight) this.inflight = this.pump();
438
+ }
439
+ /**
440
+ * Re-post the latest snapshot on an interval even with no new node events, so
441
+ * the backend's `canvasRuns.updatedAt` heartbeat stays fresh during a long
442
+ * single-clip poll (a video_generate clip can run minutes with no
443
+ * intervening node events). When this process dies the keepalive stops → the
444
+ * run's `updatedAt` goes stale → the backend reconciliation sweep force-fails
445
+ * it as interrupted and surfaces the clips that finished. `produce` returns
446
+ * null before the plan lands (nothing worth posting yet).
447
+ */
448
+ startKeepalive(produce, intervalMs = 6e4) {
449
+ if (this.keepaliveTimer) return;
450
+ this.keepaliveTimer = setInterval(() => {
451
+ const snapshot = produce();
452
+ if (snapshot) this.enqueue(snapshot);
453
+ }, intervalMs);
454
+ this.keepaliveTimer.unref?.();
455
+ }
456
+ stopKeepalive() {
457
+ if (this.keepaliveTimer) {
458
+ clearInterval(this.keepaliveTimer);
459
+ this.keepaliveTimer = null;
460
+ }
461
+ }
462
+ /**
463
+ * Post the terminal record (awaited, errors surfaced to the caller). Any
464
+ * queued progress snapshot is superseded — the terminal record is the full
465
+ * state — but an in-flight POST is awaited first so it can't land after.
466
+ */
467
+ async flush(terminal) {
468
+ this.stopKeepalive();
469
+ this.latest = null;
470
+ if (this.inflight) await this.inflight;
471
+ await this.post(terminal);
472
+ }
473
+ async pump() {
474
+ while (this.latest) {
475
+ const payload = this.latest;
476
+ this.latest = null;
477
+ try {
478
+ await this.post(payload);
479
+ } catch (e) {
480
+ if (!this.warned) {
481
+ this.warned = true;
482
+ const msg = e instanceof Error ? e.message : String(e);
483
+ process.stderr.write(`[warn] live run progress not streaming (${msg})
484
+ `);
485
+ }
486
+ }
487
+ }
488
+ this.inflight = null;
489
+ }
490
+ };
491
+
492
+ // src/commands/canvas/spec-renders.ts
493
+ async function specRenders(slug, sourceSha, post = (path10, body) => apiPost(path10, body, { read: true, timeoutMs: 15e3 })) {
494
+ try {
495
+ return creativesReasonsResponseSchema.parse(await post("/api/creatives/reasons", { slug, sourceSha })).data.runs;
496
+ } catch {
497
+ return null;
498
+ }
499
+ }
500
+
501
+ // src/commands/canvas/run-retention.ts
502
+ import { rm } from "fs/promises";
503
+ import path2 from "path";
504
+ function runDirsToPrune(entries, keep, currentRunId) {
505
+ const runs = entries.filter((e) => /^r_[0-9A-Za-z]+$/.test(e) && e !== currentRunId).sort();
506
+ if (keep <= 0) return runs;
507
+ return runs.slice(0, Math.max(0, runs.length - keep));
508
+ }
509
+ async function pruneOldRuns(outputsDir, keep, currentRunId, log) {
510
+ const { readdir: readdir2 } = await import("fs/promises");
511
+ let entries;
512
+ try {
513
+ entries = await readdir2(outputsDir);
514
+ } catch {
515
+ return;
516
+ }
517
+ const toPrune = runDirsToPrune(entries, keep, currentRunId);
518
+ if (toPrune.length === 0) return;
519
+ for (const dir of toPrune) {
520
+ await rm(path2.join(outputsDir, dir), { recursive: true, force: true }).catch(
521
+ (e) => log(`[prune ] could not remove ${dir}: ${e.message}`)
522
+ );
523
+ }
524
+ log(`[prune ] removed ${toPrune.length} old run dir(s), kept the ${keep} newest`);
525
+ }
526
+
527
+ // src/commands/canvas/run-resume.ts
528
+ import { randomUUID } from "crypto";
529
+ import { rmSync } from "fs";
530
+ import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "fs/promises";
531
+ import path3 from "path";
532
+ function markerKey(canvasPath) {
533
+ const slug = creativeSlugFromCanvasPath(canvasPath);
534
+ const identity = slug ?? path3.relative(process.cwd(), path3.resolve(canvasPath));
535
+ return sha256Hex(Buffer.from(identity)).slice(0, 32);
536
+ }
537
+ function markerFile(outputsDir, canvasPath) {
538
+ return path3.join(outputsDir, ".inflight", `${markerKey(canvasPath)}.json`);
539
+ }
540
+ function classifyRemoteRun(run) {
541
+ if (run.interrupted === true || run.status === "awaiting_approval") return "adopt";
542
+ if (run.status !== "running") return "ignore";
543
+ return run.adoptable === true ? "adopt" : "concurrent";
544
+ }
545
+ var HEARTBEAT_MS = 2e4;
546
+ var MARKER_LIVE_MS = 9e4;
547
+ function isLiveRender(marker, now = Date.now()) {
548
+ if (marker.pid === void 0) return false;
549
+ const beat = marker.heartbeatAt ?? marker.startedAt;
550
+ if (beat === void 0 || now - beat > MARKER_LIVE_MS) return false;
551
+ try {
552
+ process.kill(marker.pid, 0);
553
+ return true;
554
+ } catch (e) {
555
+ return e.code === "EPERM";
556
+ }
557
+ }
558
+ async function resolveRunId(opts) {
559
+ const existing = await readMarker(opts.outputsDir, opts.canvasPath);
560
+ if (existing?.pid !== void 0 && existing.pid !== process.pid && (opts.isRendering ?? ((marker) => isLiveRender(marker)))(existing)) {
561
+ return { runId: existing.runId, resumed: false, rendering: { runId: existing.runId, pid: existing.pid } };
562
+ }
563
+ if (opts.explicitRunId) return { runId: opts.explicitRunId, resumed: false };
564
+ if (!opts.fresh) {
565
+ if (existing) {
566
+ const sameSource = existing.sourceSha !== void 0 && existing.sourceSha === opts.sourceSha;
567
+ return { runId: existing.runId, resumed: true, source: "local", sameSource };
568
+ }
569
+ if (opts.adoptedRunId) return { runId: opts.adoptedRunId, resumed: true, source: "remote", sameSource: true };
570
+ if (opts.remote) {
571
+ try {
572
+ const active = await opts.remote.getActiveRun(opts.remote.creativeSlug, opts.remote.sourceSha);
573
+ if (active) {
574
+ const decision = classifyRemoteRun(active);
575
+ if (decision === "adopt") return { runId: active.runId, resumed: true, source: "remote", sameSource: true };
576
+ if (decision === "concurrent") {
577
+ return { runId: `r_${ulid()}`, resumed: false, concurrentRunId: active.runId };
578
+ }
579
+ }
580
+ } catch (e) {
581
+ const msg = e instanceof Error ? e.message : String(e);
582
+ process.stderr.write(`[warn] resumable-run lookup failed (${msg}) \u2014 starting a fresh run
583
+ `);
584
+ }
585
+ }
586
+ }
587
+ return { runId: `r_${ulid()}`, resumed: false };
588
+ }
589
+ async function readMarker(outputsDir, canvasPath) {
590
+ try {
591
+ const parsed = JSON.parse(await readFile2(markerFile(outputsDir, canvasPath), "utf8"));
592
+ if (typeof parsed.runId !== "string" || parsed.runId.length === 0) return null;
593
+ const num = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
594
+ return {
595
+ runId: parsed.runId,
596
+ ...Number.isInteger(parsed.pid) ? { pid: parsed.pid } : {},
597
+ ...typeof parsed.token === "string" ? { token: parsed.token } : {},
598
+ ...num(parsed.startedAt) !== void 0 ? { startedAt: num(parsed.startedAt) } : {},
599
+ ...num(parsed.heartbeatAt) !== void 0 ? { heartbeatAt: num(parsed.heartbeatAt) } : {},
600
+ ...typeof parsed.sourceSha === "string" ? { sourceSha: parsed.sourceSha } : {}
601
+ };
602
+ } catch {
603
+ return null;
604
+ }
605
+ }
606
+ async function markRunInFlight(outputsDir, canvasPath, runId, sourceSha) {
607
+ const file = markerFile(outputsDir, canvasPath);
608
+ const token = randomUUID();
609
+ const startedAt = Date.now();
610
+ const write = (heartbeatAt) => writeFile2(
611
+ file,
612
+ JSON.stringify({
613
+ runId,
614
+ pid: process.pid,
615
+ token,
616
+ canvasPath: path3.resolve(canvasPath),
617
+ startedAt,
618
+ heartbeatAt,
619
+ ...sourceSha ? { sourceSha } : {}
620
+ })
621
+ );
622
+ try {
623
+ await mkdir2(path3.dirname(file), { recursive: true });
624
+ await write(startedAt);
625
+ } catch {
626
+ }
627
+ const timer = setInterval(() => {
628
+ void readMarker(outputsDir, canvasPath).then((marker) => marker?.token === token ? write(Date.now()) : void 0).catch(() => void 0);
629
+ }, HEARTBEAT_MS);
630
+ timer.unref();
631
+ return { token, stop: () => clearInterval(timer) };
632
+ }
633
+ function busyFile(outputsDir, canvasPath) {
634
+ return path3.join(outputsDir, ".inflight", `${markerKey(canvasPath)}.busy.json`);
635
+ }
636
+ async function markCanvasBusy(outputsDir, canvasPath, runId, pid = process.pid) {
637
+ const file = busyFile(outputsDir, canvasPath);
638
+ const write = () => writeFile2(file, JSON.stringify({ runId, pid, heartbeatAt: Date.now() }));
639
+ try {
640
+ await mkdir2(path3.dirname(file), { recursive: true });
641
+ await write();
642
+ } catch {
643
+ }
644
+ const timer = setInterval(() => void write().catch(() => void 0), HEARTBEAT_MS);
645
+ timer.unref();
646
+ let released = false;
647
+ const release = () => {
648
+ if (released) return;
649
+ released = true;
650
+ clearInterval(timer);
651
+ try {
652
+ rmSync(file, { force: true });
653
+ } catch {
654
+ }
655
+ };
656
+ return { release };
657
+ }
658
+ async function canvasBusyElsewhere(outputsDir, canvasPath, now = Date.now()) {
659
+ try {
660
+ const held = JSON.parse(await readFile2(busyFile(outputsDir, canvasPath), "utf8"));
661
+ if (typeof held.runId !== "string" || held.pid === void 0 || held.pid === process.pid) return null;
662
+ return isLiveRender(held, now) ? { runId: held.runId, pid: held.pid } : null;
663
+ } catch {
664
+ return null;
665
+ }
666
+ }
667
+ async function clearRunMarker(outputsDir, canvasPath, token) {
668
+ try {
669
+ if (token !== void 0) {
670
+ const marker = await readMarker(outputsDir, canvasPath);
671
+ if (marker?.token !== void 0 && marker.token !== token) return;
672
+ }
673
+ await rm2(markerFile(outputsDir, canvasPath), { force: true });
674
+ } catch {
675
+ }
676
+ }
677
+
678
+ // src/commands/canvas/run-snapshot.ts
679
+ import { existsSync } from "fs";
680
+ import { mkdir as mkdir3, readdir, readFile as readFile3, stat, writeFile as writeFile3 } from "fs/promises";
681
+ import path4 from "path";
682
+ var SNAPSHOT_SCHEMA = "baker-canvas-snapshot/1";
683
+ var MAX_SNAPSHOT_FILE_BYTES = 32 * 1024 * 1024;
684
+ var EXT_TO_MIME = {
685
+ json: "application/json",
686
+ html: "text/html",
687
+ css: "text/css",
688
+ js: "text/javascript",
689
+ txt: "text/plain",
690
+ md: "text/markdown",
691
+ png: "image/png",
692
+ jpg: "image/jpeg",
693
+ jpeg: "image/jpeg",
694
+ webp: "image/webp",
695
+ gif: "image/gif",
696
+ avif: "image/avif",
697
+ mp3: "audio/mpeg",
698
+ wav: "audio/wav",
699
+ mp4: "video/mp4",
700
+ webm: "video/webm",
701
+ mov: "video/quicktime",
702
+ ttf: "font/ttf",
703
+ otf: "font/otf",
704
+ woff: "font/woff",
705
+ woff2: "font/woff2"
706
+ };
707
+ function mimeForFile(filePath) {
708
+ const ext = path4.extname(filePath).slice(1).toLowerCase();
709
+ return EXT_TO_MIME[ext] ?? "application/octet-stream";
710
+ }
711
+ function toPosix(p) {
712
+ return p.split(path4.sep).join("/");
713
+ }
714
+ function isInside(dir, target) {
715
+ const rel = path4.relative(dir, target);
716
+ return !rel.startsWith("..") && !path4.isAbsolute(rel);
717
+ }
718
+ function localPathRefsFromCanvas(parsed) {
719
+ const nodes = parsed?.nodes;
720
+ if (!Array.isArray(nodes)) return [];
721
+ const refs = /* @__PURE__ */ new Set();
722
+ for (const node of nodes) {
723
+ const n = node;
724
+ const params = n.params;
725
+ if (!params || typeof params !== "object") continue;
726
+ const key = localPathParam(n);
727
+ const value = key ? params[key] : void 0;
728
+ if (isSnapshotablePath(value)) refs.add(value);
729
+ }
730
+ return [...refs];
731
+ }
732
+ function isSnapshotablePath(value) {
733
+ return typeof value === "string" && value.length > 0 && !value.includes("[TODO");
734
+ }
735
+ var FINGERPRINTED_FILES = ["prompt.json", "_definition.md"];
736
+ async function sourceRefsToSnapshot(canvasDir, parsed) {
737
+ const refs = new Set(localPathRefsFromCanvas(parsed));
738
+ for (const sceneFile of await listSceneFiles(canvasDir)) {
739
+ refs.add(toPosix(path4.relative(canvasDir, sceneFile)));
740
+ }
741
+ refs.add(REBUILD_FILE);
742
+ for (const fingerprinted of FINGERPRINTED_FILES) {
743
+ if (existsSync(path4.join(canvasDir, fingerprinted))) refs.add(fingerprinted);
744
+ }
745
+ return [...refs];
746
+ }
747
+ async function uploadRunSnapshot(client, opts) {
748
+ try {
749
+ const canvasDir = path4.dirname(opts.canvasPath);
750
+ const canvasBytes = Buffer.from(opts.raw);
751
+ const canvasEntry = {
752
+ path: path4.basename(opts.canvasPath),
753
+ bytes: canvasBytes,
754
+ sha256: sha256Hex(canvasBytes),
755
+ mime: "application/json"
756
+ };
757
+ const files = [];
758
+ const skipped = [];
759
+ for (const refPath of await sourceRefsToSnapshot(canvasDir, opts.parsed)) {
760
+ const abs = path4.isAbsolute(refPath) ? refPath : path4.resolve(canvasDir, refPath);
761
+ if (!isInside(canvasDir, abs)) {
762
+ skipped.push({
763
+ path: toPosix(path4.relative(canvasDir, abs)),
764
+ reason: "outside the creative folder \u2014 read from the workspace on rerun"
765
+ });
766
+ continue;
767
+ }
768
+ let st;
769
+ try {
770
+ st = await stat(abs);
771
+ } catch {
772
+ skipped.push({ path: toPosix(path4.relative(canvasDir, abs)), reason: "missing" });
773
+ continue;
774
+ }
775
+ const fileList = st.isDirectory() ? await listFilesRecursive(abs) : [abs];
776
+ for (const file of fileList) {
777
+ const rel = toPosix(path4.relative(canvasDir, file));
778
+ const size = (await stat(file)).size;
779
+ if (size > MAX_SNAPSHOT_FILE_BYTES) {
780
+ skipped.push({ path: rel, reason: `too large (${size} bytes)` });
781
+ continue;
782
+ }
783
+ const bytes = await readFile3(file);
784
+ files.push({ path: rel, bytes, sha256: sha256Hex(bytes), mime: mimeForFile(file) });
785
+ }
786
+ }
787
+ const identity = sha256Hex(
788
+ Buffer.from(
789
+ JSON.stringify({
790
+ creativeSlug: opts.creativeSlug,
791
+ entries: [canvasEntry, ...files].map((entry) => [entry.path, entry.sha256]),
792
+ skipped
793
+ })
794
+ )
795
+ );
796
+ if (opts.previous?.identity === identity) return opts.previous;
797
+ const put = (bytes, mime) => putContentAddressed(client, bytes, mime, opts.signal);
798
+ const canvasUpload = await put(canvasEntry.bytes, canvasEntry.mime);
799
+ const uploaded = [];
800
+ for (const file of files) {
801
+ const upload = await put(file.bytes, file.mime);
802
+ uploaded.push({ path: file.path, sha256: upload.sha256, url: upload.url });
803
+ }
804
+ const manifest = {
805
+ schema: SNAPSHOT_SCHEMA,
806
+ creativeSlug: opts.creativeSlug,
807
+ canvasSha: canvasUpload.sha256,
808
+ canvas: { path: canvasEntry.path, sha256: canvasUpload.sha256, url: canvasUpload.url },
809
+ files: uploaded,
810
+ skipped: skipped.length > 0 ? skipped : void 0
811
+ };
812
+ const manifestUpload = await put(Buffer.from(JSON.stringify(manifest)), "application/json");
813
+ return { identity, url: manifestUpload.url };
814
+ } catch (e) {
815
+ const msg = e instanceof Error ? e.message : String(e);
816
+ process.stderr.write(`[warn] canvas snapshot not uploaded (${msg}) \u2014 this run cannot be re-run from another workspace
817
+ `);
818
+ return null;
819
+ }
820
+ }
821
+ var MAX_GRAPH_BYTES = 4 * 1024 * 1024;
822
+ async function uploadRunGraph(client, graph, signal) {
823
+ try {
824
+ const bytes = Buffer.from(JSON.stringify(graph));
825
+ if (bytes.length > MAX_GRAPH_BYTES) return null;
826
+ return (await putContentAddressed(client, bytes, "application/json", signal)).url;
827
+ } catch (e) {
828
+ const msg = e instanceof Error ? e.message : String(e);
829
+ process.stderr.write(`[warn] run graph not kept (${msg}) \u2014 a correction from another workspace starts from its picture
830
+ `);
831
+ return null;
832
+ }
833
+ }
834
+ async function putContentAddressed(client, bytes, mime, signal) {
835
+ const sha256 = sha256Hex(bytes);
836
+ const { putUrl, publicUrl } = await client.presignAssetUpload(sha256, mime, signal, "blueprint");
837
+ const held = await fetch(publicUrl, { method: "HEAD", signal }).then(
838
+ (res2) => res2.ok,
839
+ () => false
840
+ );
841
+ if (held) return { sha256, url: publicUrl };
842
+ const res = await fetch(putUrl, {
843
+ method: "PUT",
844
+ body: new Uint8Array(bytes),
845
+ headers: { "Content-Type": mime },
846
+ signal
847
+ });
848
+ if (!res.ok) throw new Error(`snapshot PUT failed ${res.status} ${res.statusText}`);
849
+ return { sha256, url: publicUrl };
850
+ }
851
+ async function listFilesRecursive(dir) {
852
+ const entries = await readdir(dir, { recursive: true, withFileTypes: true });
853
+ return entries.filter((d) => d.isFile()).map((d) => path4.join(d.parentPath, d.name));
854
+ }
855
+ var SnapshotConflictError = class extends Error {
856
+ conflicts;
857
+ constructor(conflicts) {
858
+ super(`local files differ from the recorded snapshot: ${conflicts.join(", ")}`);
859
+ this.name = "SnapshotConflictError";
860
+ this.conflicts = conflicts;
861
+ }
862
+ };
863
+ async function restoreRunSnapshot(manifest, targetDir, opts = {}) {
864
+ const entries = [manifest.canvas, ...manifest.files];
865
+ const resolvedTarget = path4.resolve(targetDir);
866
+ const planned = [];
867
+ const conflicts = [];
868
+ const upToDate = [];
869
+ for (const entry of entries) {
870
+ if (path4.isAbsolute(entry.path) || entry.path.split("/").includes("..")) {
871
+ throw new Error(`snapshot entry escapes the creative directory: ${entry.path}`);
872
+ }
873
+ const target = path4.resolve(resolvedTarget, entry.path);
874
+ if (target !== resolvedTarget && !target.startsWith(resolvedTarget + path4.sep)) {
875
+ throw new Error(`snapshot entry escapes the creative directory: ${entry.path}`);
876
+ }
877
+ const existing = await readFile3(target).catch(() => null);
878
+ if (existing) {
879
+ if (sha256Hex(existing) === entry.sha256) {
880
+ upToDate.push(entry.path);
881
+ continue;
882
+ }
883
+ if (!opts.force) {
884
+ conflicts.push(entry.path);
885
+ continue;
886
+ }
887
+ }
888
+ planned.push({ entry, target });
889
+ }
890
+ if (conflicts.length > 0) throw new SnapshotConflictError(conflicts);
891
+ const restored = [];
892
+ for (const { entry, target } of planned) {
893
+ const res = await fetch(entry.url);
894
+ if (!res.ok) throw new Error(`snapshot download failed for ${entry.path}: ${res.status} ${res.statusText}`);
895
+ const bytes = Buffer.from(await res.arrayBuffer());
896
+ if (sha256Hex(bytes) !== entry.sha256) {
897
+ throw new Error(`snapshot download for ${entry.path} does not match its recorded sha256`);
898
+ }
899
+ await mkdir3(path4.dirname(target), { recursive: true });
900
+ await writeFile3(target, bytes);
901
+ restored.push(entry.path);
902
+ }
903
+ return { canvasPath: path4.resolve(resolvedTarget, manifest.canvas.path), restored, upToDate };
904
+ }
905
+
906
+ // src/commands/canvas/named-people-read.ts
907
+ import { createHash as createHash2 } from "crypto";
908
+ import { mkdir as mkdir4, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
909
+ import path5 from "path";
910
+ var PEOPLE_TIMEOUT_MS = 3e4;
911
+ function peopleReader(cacheDir, spent) {
912
+ const dir = path5.join(cacheDir, "named-people");
913
+ return async (lines) => {
914
+ const said = lines.filter((l) => l.trim());
915
+ if (said.length === 0) return [];
916
+ const key = createHash2("sha256").update(JSON.stringify([PEOPLE_PROMPT_VERSION, CLAIMS_MODEL, said])).digest("hex");
917
+ const file = path5.join(dir, `${key}.json`);
918
+ const cached = await readFile4(file, "utf8").then((text) => readPeople(JSON.parse(text), said)).catch(() => null);
919
+ if (cached) return cached;
920
+ const answer = await askAboutText(CLAIMS_MODEL, peoplePrompt(said), spent, {
921
+ timeoutMs: PEOPLE_TIMEOUT_MS,
922
+ request: CLAIMS_REQUEST
923
+ });
924
+ const people = readPeople(answer, said);
925
+ if (people) {
926
+ await mkdir4(dir, { recursive: true });
927
+ await writeFile4(file, JSON.stringify(answer), "utf8");
928
+ }
929
+ return people;
930
+ };
931
+ }
932
+
933
+ // src/commands/avatars/namedPerson.ts
934
+ var RESEARCH_TIMEOUT_MS = 18e4;
935
+ async function avatarOfNamedPerson(who) {
936
+ const research = await writeAvatars(
937
+ "/api/avatars/research",
938
+ { who, create: true },
939
+ { timeoutMs: RESEARCH_TIMEOUT_MS }
940
+ );
941
+ const handle = research.avatar?.handle;
942
+ if (research.status !== "found" || !handle) return null;
943
+ const read = () => readAvatars("/api/avatars/get", { handle });
944
+ const avatar = await waitForSheet(await read(), read);
945
+ return avatar.sheetUrl ? { handle, sheetUrl: avatar.sheetUrl } : null;
946
+ }
947
+
948
+ // src/commands/canvas/slug-restore.ts
949
+ import { existsSync as existsSync2 } from "fs";
950
+ import path6 from "path";
951
+ var SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
952
+ var SlugRestoreError = class extends Error {
953
+ code;
954
+ fix;
955
+ constructor(code, message, fix) {
956
+ super(message);
957
+ this.name = "SlugRestoreError";
958
+ this.code = code;
959
+ this.fix = fix;
960
+ }
961
+ };
962
+ async function canvasForSlug(slug, opts) {
963
+ if (!SLUG_PATTERN.test(slug)) {
964
+ throw new SlugRestoreError("invalid_slug", `"${slug}" is not a valid creative slug`);
965
+ }
966
+ const targetDir = path6.join(opts.workspaceRoot, "src", "creatives", slug);
967
+ const local = path6.join(targetDir, `${slug}.canvas.json`);
968
+ if (!opts.forceRemote && existsSync2(local)) return { canvasPath: local };
969
+ const client = opts.client();
970
+ if (!client) {
971
+ throw new SlugRestoreError(
972
+ "missing_credentials",
973
+ `"${slug}" is not in this workspace, and restoring it from run history needs Baker credentials (BAKER_API_URL / BAKER_API_KEY).`
974
+ );
975
+ }
976
+ const latest = await client.getLatestSnapshotRun(slug);
977
+ if (!latest) {
978
+ throw new SlugRestoreError(
979
+ "no_snapshot_run",
980
+ `No creative "${slug}" in this workspace, and no recorded run of it to restore from.`,
981
+ "Check the slug against `ls src/creatives`, or scaffold the creative first."
982
+ );
983
+ }
984
+ const manifest = await fetchManifest(latest.canvasSnapshotUrl);
985
+ if (latest.canvasSha && manifest.canvasSha !== latest.canvasSha) {
986
+ throw new SlugRestoreError("snapshot_mismatch", `the snapshot of run ${latest.runId} does not match its recorded canvas`);
987
+ }
988
+ try {
989
+ const restore = await restoreRunSnapshot(manifest, targetDir, { force: opts.forceRemote });
990
+ opts.log(
991
+ restore.restored.length > 0 ? `[restore] ${restore.restored.length} file(s) from run ${latest.runId}: ${restore.restored.join(", ")}` : `[restore] local files already match run ${latest.runId}, nothing downloaded`
992
+ );
993
+ for (const skipped of manifest.skipped ?? []) {
994
+ opts.log(`[warn] snapshot omitted ${skipped.path} (${skipped.reason}); supply it locally if the run needs it fresh`);
995
+ }
996
+ return { canvasPath: restore.canvasPath, adoptRunId: await adoptableRun(client, slug, latest.runId) };
997
+ } catch (e) {
998
+ if (e instanceof SnapshotConflictError) {
999
+ throw new SlugRestoreError(
1000
+ "local_files_differ",
1001
+ `local files differ from the recorded snapshot: ${e.conflicts.join(", ")}`,
1002
+ "Re-run with --force-remote to overwrite them, or run the local canvas file directly with `baker canvas run <file>`."
1003
+ );
1004
+ }
1005
+ throw e;
1006
+ }
1007
+ }
1008
+ async function adoptableRun(client, slug, restoredRunId) {
1009
+ const active = await client.getActiveRun(slug).catch(() => null);
1010
+ return active?.runId === restoredRunId && active.adoptable === true ? restoredRunId : void 0;
1011
+ }
1012
+ async function fetchManifest(url) {
1013
+ const res = await fetch(url);
1014
+ if (!res.ok) {
1015
+ throw new SlugRestoreError("snapshot_unavailable", `snapshot manifest download failed: ${res.status} ${res.statusText}`);
1016
+ }
1017
+ const manifest = await res.json();
1018
+ if (manifest?.schema !== SNAPSHOT_SCHEMA || typeof manifest.canvas?.path !== "string") {
1019
+ throw new SlugRestoreError("snapshot_invalid", "snapshot manifest has an unexpected shape");
1020
+ }
1021
+ return manifest;
1022
+ }
1023
+
1024
+ // src/commands/canvas/batch-run.ts
1025
+ import path7 from "path";
1026
+
1027
+ // src/commands/canvas/series-run.ts
1028
+ async function runSeries(slugs, deps) {
1029
+ return Promise.all(
1030
+ slugs.map(async (slug) => {
1031
+ const plan = await deps.plan(slug);
1032
+ if ("refused" in plan) return { slug, status: "refused", error: plan.refused };
1033
+ if (!plan.run) return { slug, status: "up_to_date", ...plan.runId ? { run_id: plan.runId } : {} };
1034
+ return resultOf(slug, await deps.run(slug));
1035
+ })
1036
+ );
1037
+ }
1038
+ function resultOf(slug, answer) {
1039
+ if (answer.ok !== true) {
1040
+ const error = answer.error ?? {};
1041
+ return {
1042
+ slug,
1043
+ status: "failed",
1044
+ error: {
1045
+ code: error.code ?? "render_failed",
1046
+ message: error.message ?? "The render did not finish.",
1047
+ ...error.fix ? { fix: error.fix } : {}
1048
+ }
1049
+ };
1050
+ }
1051
+ const verdict = answer.verdict;
1052
+ const status = verdict === "ready" || verdict === "ready_with_notes" || verdict === "needs_fixes" ? verdict : "ready";
1053
+ return {
1054
+ slug,
1055
+ status,
1056
+ ...typeof answer.run_id === "string" ? { run_id: answer.run_id } : {},
1057
+ ...answer.files !== void 0 ? { files: answer.files } : {},
1058
+ ...answer.previews !== void 0 ? { previews: answer.previews } : {}
1059
+ };
1060
+ }
1061
+ function seriesEnvelope(lead, results) {
1062
+ const ready = results.filter((r) => r.status === "ready" || r.status === "ready_with_notes");
1063
+ const fixes = results.filter((r) => r.status === "needs_fixes");
1064
+ const stopped = results.filter((r) => r.status === "refused" || r.status === "failed");
1065
+ return {
1066
+ ok: true,
1067
+ data: { lead, ready: ready.map((r) => r.slug), ads: results },
1068
+ hints: [
1069
+ ...ready.filter((r) => r.run_id).map((r) => `Save: baker creatives publish --slug ${r.slug} --run-id ${r.run_id} --title "<title>" --output <lead size>`),
1070
+ ...fixes.length > 0 ? [
1071
+ `Still needs fixes after its own corrections: ${fixes.map((r) => r.slug).join(", ")}. Correct each by itself (baker canvas run --slug <slug> --fix "<what to change>"); the others stay as they are.`
1072
+ ] : [],
1073
+ ...stopped.map((r) => `${r.slug}: ${r.error?.message ?? "not rendered"}${r.error?.fix ? ` ${r.error.fix}` : ""}`),
1074
+ `A new version of the lead (${lead}) reaches every ad of the series on the next \`baker canvas run --series ${lead}\`.`
1075
+ ]
1076
+ };
1077
+ }
1078
+
1079
+ // src/commands/canvas/batch-run.ts
1080
+ var CANVASES_AT_ONCE = 6;
1081
+ var STATIC_VERDICTS = /* @__PURE__ */ new Set(["ready", "ready_with_notes", "needs_fixes", "not_reviewed"]);
1082
+ function rowOf(slug, answer, full) {
1083
+ const hints = Array.isArray(answer.hints) ? answer.hints.filter((h) => typeof h === "string") : [];
1084
+ const withHints = hints.length > 0 ? { hints } : {};
1085
+ if (answer.ok !== true) {
1086
+ const failed = resultOf(slug, answer);
1087
+ return { slug, status: "failed", ...failed.error ? { error: failed.error } : {}, ...withHints };
1088
+ }
1089
+ const data = answer.data ?? {};
1090
+ if (data.stopped === "frames") {
1091
+ return {
1092
+ slug,
1093
+ status: "frames_ready",
1094
+ ...typeof data.runId === "string" ? { run_id: data.runId } : {},
1095
+ frames: data.frames,
1096
+ ...withHints
1097
+ };
1098
+ }
1099
+ const verdict = typeof answer.verdict === "string" && STATIC_VERDICTS.has(answer.verdict) ? answer.verdict : null;
1100
+ const review = Array.isArray(answer.review) ? answer.review : null;
1101
+ const blocking = review?.some((f) => f?.severity === "blocking") ?? false;
1102
+ const unwatched = review === null && hints.includes(RENDER_REVIEW_UNAVAILABLE);
1103
+ const status = verdict ? verdict : unwatched ? "not_reviewed" : blocking ? "needs_fixes" : "ready";
1104
+ return {
1105
+ slug,
1106
+ status,
1107
+ ...verdict ? { verdict } : {},
1108
+ ...review ? { review } : {},
1109
+ ...typeof answer.run_id === "string" ? { run_id: answer.run_id } : {},
1110
+ ...answer.files !== void 0 ? { files: answer.files } : {},
1111
+ ...answer.previews !== void 0 ? { previews: answer.previews } : {},
1112
+ ...withHints,
1113
+ ...full ? Object.fromEntries(
1114
+ ["outputs_dir", "output", "stats", "judge"].filter((key) => answer[key] !== void 0).map((key) => [key, answer[key]])
1115
+ ) : {}
1116
+ };
1117
+ }
1118
+ function targetLabel(target) {
1119
+ return "slug" in target ? target.slug : creativeSlugFromCanvasPath(path7.resolve(target.file)) ?? target.file;
1120
+ }
1121
+ function canvasTargets(args) {
1122
+ const files = args.files.filter((f) => typeof f === "string" && f !== "");
1123
+ if (files.length > 0) return [...new Set(files)].map((file) => ({ file }));
1124
+ const slugs = (args.slug ?? "").split(",").map((s) => s.trim()).filter(Boolean);
1125
+ return [...new Set(slugs)].map((slug) => ({ slug }));
1126
+ }
1127
+ function oneCanvasOnly(opts) {
1128
+ return [
1129
+ opts.fix ? "--fix" : null,
1130
+ opts.from ? "--from" : null,
1131
+ opts.useVariant ? "--use-variant" : null,
1132
+ opts.runId ? "--run-id" : null,
1133
+ opts.keepRuns !== void 0 ? "--keep-runs" : null
1134
+ ].filter((flag) => flag !== null);
1135
+ }
1136
+ function childRunArgs(target, opts) {
1137
+ const value = (flag, v) => v !== void 0 ? [flag, v] : [];
1138
+ return [
1139
+ "canvas",
1140
+ "run",
1141
+ ..."slug" in target ? ["--slug", target.slug] : [target.file],
1142
+ ...opts.forceRemote && "slug" in target ? ["--force-remote"] : [],
1143
+ ...opts.fresh ? ["--fresh"] : [],
1144
+ ...opts.autoFix === false ? ["--no-autofix"] : [],
1145
+ ...opts.skipViewerCheck ? ["--skip-viewer-check"] : [],
1146
+ ...value("--brief", opts.brief),
1147
+ ...value("--until", opts.until),
1148
+ ...value("--regenerate", opts.regenerate),
1149
+ ...value("--concurrency", opts.concurrency),
1150
+ ...value("--cache-policy", opts.cachePolicy),
1151
+ ...opts.record === false ? ["--no-record"] : [],
1152
+ ...value("--cache-dir", opts.cacheDir),
1153
+ ...value("--outputs-dir", opts.outputsDir),
1154
+ ...opts.remoteCache !== void 0 ? ["--remote-cache", opts.remoteCache ? "on" : "off"] : [],
1155
+ ...opts.full ? ["--full"] : []
1156
+ ];
1157
+ }
1158
+ async function runCanvases(targets, run, limit = CANVASES_AT_ONCE, opts = {}) {
1159
+ const results = new Array(targets.length);
1160
+ let next = 0;
1161
+ const worker = async () => {
1162
+ while (next < targets.length) {
1163
+ const at = next++;
1164
+ const target = targets[at];
1165
+ results[at] = rowOf(targetLabel(target), await run(target), opts.full === true);
1166
+ }
1167
+ };
1168
+ await Promise.all(Array.from({ length: Math.min(limit, targets.length) }, worker));
1169
+ return results;
1170
+ }
1171
+ function batchEnvelope(rows) {
1172
+ const ready = rows.filter((r) => r.status === "ready" || r.status === "ready_with_notes");
1173
+ return {
1174
+ ok: true,
1175
+ data: { ready: ready.map((r) => r.slug), canvases: rows },
1176
+ hints: rows.filter((r) => !ready.includes(r)).flatMap(
1177
+ (r) => r.error ? [`${r.slug}: ${r.error.message}${r.error.fix ? ` ${r.error.fix}` : ""}`] : (r.hints ?? []).map((h) => `${r.slug}: ${h}`)
1178
+ )
1179
+ };
1180
+ }
1181
+
1182
+ // src/commands/canvas/voice-retake.ts
1183
+ var nodesOf = (graph) => {
1184
+ const nodes = graph?.nodes;
1185
+ return Array.isArray(nodes) ? nodes : [];
1186
+ };
1187
+ function refsIn(value) {
1188
+ if (typeof value === "string") {
1189
+ const id = /^\$ref:([^.]+)\./.exec(value)?.[1];
1190
+ return id ? [id] : [];
1191
+ }
1192
+ if (Array.isArray(value)) return value.flatMap(refsIn);
1193
+ if (value && typeof value === "object") return Object.values(value).flatMap(refsIn);
1194
+ return [];
1195
+ }
1196
+ function keptVoiceClips(graph) {
1197
+ const nodes = nodesOf(graph);
1198
+ const byId = new Map(nodes.flatMap((n) => typeof n.id === "string" ? [[n.id, n]] : []));
1199
+ const tracks = nodes.filter((n) => {
1200
+ const tags = n.tags ?? {};
1201
+ return n.type === "audio_timeline" && tags.role === "voice" && tags.on_camera === true;
1202
+ });
1203
+ const seen = /* @__PURE__ */ new Set();
1204
+ const queue = tracks.flatMap((t) => refsIn(t.inputs));
1205
+ while (queue.length > 0) {
1206
+ const id = queue.pop();
1207
+ if (seen.has(id)) continue;
1208
+ seen.add(id);
1209
+ queue.push(...refsIn(byId.get(id)?.inputs));
1210
+ }
1211
+ return [...seen].flatMap((id) => {
1212
+ const node = byId.get(id);
1213
+ return node?.type === "video_generate" ? [node] : [];
1214
+ });
1215
+ }
1216
+ var promptOf = (node) => JSON.stringify(node?.params?.prompt ?? null);
1217
+ function retakenTalkingScenes(previous, canvas) {
1218
+ const before = new Map(nodesOf(previous).map((n) => [n.id, n]));
1219
+ return keptVoiceClips(canvas).filter((clip) => before.has(clip.id) && promptOf(before.get(clip.id)) !== promptOf(clip)).map((clip) => String(clip.id));
1220
+ }
1221
+
1222
+ // src/commands/canvas/static-run-review.ts
1223
+ import { readFile as readFile5 } from "fs/promises";
1224
+ import path8 from "path";
1225
+
1226
+ // src/commands/canvas/glance-check.ts
1227
+ import sharp from "sharp";
1228
+ import { z } from "zod";
1229
+ var GLANCE_REQUIRED = {
1230
+ offer: "guess",
1231
+ for_whom: "unclear",
1232
+ next_step: "unclear"
1233
+ };
1234
+ var GLANCE_WIDTH = 400;
1235
+ var GlanceAnswerSchema = ViewerAnswerSchema.extend({
1236
+ /** What kind of product or service they take it for (D4). */
1237
+ category: z.object({ answer: z.string().default(""), clarity: z.enum(["clear", "guess", "unclear"]).default("unclear") }).default({ answer: "", clarity: "unclear" }),
1238
+ stopped: z.string().default(""),
1239
+ me: z.enum(["yes", "no", "unsure"]).default("unsure")
1240
+ });
1241
+ function wherePhrase(placements) {
1242
+ const fullScreen = placements.length === 0 || placements.some((p) => /automatic|stor|reel/i.test(p));
1243
+ return fullScreen ? "your Instagram or Facebook feed, Stories or Reels" : "your Instagram or Facebook feed";
1244
+ }
1245
+ function knowledge(viewer) {
1246
+ if (!viewer.knows.includes("brand")) return "You have never heard of the advertiser.";
1247
+ const offer = viewer.knows.includes("offer") ? " You know roughly what they sell." : "";
1248
+ return `You have come across the advertiser before.${offer}`;
1249
+ }
1250
+ function buildGlancePrompt(input) {
1251
+ const who = input.market ? `You are ${input.market}. ` : "";
1252
+ return [
1253
+ `${who}You are scrolling ${wherePhrase(input.viewer.placements)} on your phone. ${knowledge(input.viewer)}`,
1254
+ "This ad passes under your thumb and holds you for about three seconds: you take in the picture and read the biggest words, not the small print. The image is shown at the size your phone shows it.",
1255
+ "Answer as this person, from those three seconds alone. Do not fill gaps with what ads like this usually sell.",
1256
+ 'For each question give your answer in English and how sure you are: "clear" when the ad says it outright or you already know it; "guess" when you are piecing it together; "unclear" when you cannot tell.',
1257
+ "offer: what is being sold or offered?",
1258
+ "for_whom: who is it for?",
1259
+ "next_step: what would you do next if you wanted it?",
1260
+ "category: what kind of product or service is this for (a payroll app, a trade course, a phone)?",
1261
+ 'missing: in one short sentence, what you would need to be told to get it; "" when nothing.',
1262
+ "stopped: what made you stop on it, or what nearly made you scroll past, in a few words.",
1263
+ 'me: is this for someone like you? "yes", "no" or "unsure".',
1264
+ "",
1265
+ 'Reply with only this JSON: {"offer":{"answer":"","clarity":"clear|guess|unclear"},"for_whom":{"answer":"","clarity":"clear|guess|unclear"},"next_step":{"answer":"","clarity":"clear|guess|unclear"},"category":{"answer":"","clarity":"clear|guess|unclear"},"missing":"","stopped":"","me":"yes|no|unsure"}'
1266
+ ].join("\n");
1267
+ }
1268
+ var QUESTION_WORDS = {
1269
+ offer: "what is offered",
1270
+ for_whom: "who it is for",
1271
+ next_step: "what to do next"
1272
+ };
1273
+ function missWords(miss) {
1274
+ if (miss.question === "presumes") return `it talks to them as a customer already ("${miss.viewerSaid}")`;
1275
+ const said = miss.viewerSaid.trim() ? `"${miss.viewerSaid.trim()}"` : "nothing";
1276
+ const what = QUESTION_WORDS[miss.question];
1277
+ return miss.reason === "misread" ? `${what} (they were sure it is ${said})` : `${what} (they said ${said})`;
1278
+ }
1279
+ function glanceFindings(answer, intended, format, viewer, misread = { offer: false, category: false }) {
1280
+ const verdict = judgeViewerAnswer({ ...answer, presumes: "" }, intended, GLANCE_REQUIRED, misread.offer);
1281
+ const category = answer.category.answer.trim();
1282
+ const kind = intended.recognition && category && misread.category ? [
1283
+ {
1284
+ severity: "warning",
1285
+ what: `${format}: At a glance, a stranger took it for "${category}"; it is meant as ${intended.recognition}.`
1286
+ }
1287
+ ] : [];
1288
+ if (verdict.pass) return kind;
1289
+ const needed = answer.missing.trim() ? ` They needed: ${answer.missing.trim().replace(/[.!]+$/, "")}.` : "";
1290
+ const missed = verdict.missed.map(missWords).join("; ");
1291
+ return [
1292
+ {
1293
+ severity: "blocking",
1294
+ what: `${format}: At a glance, ${describeViewer(viewer).replace(/, on .* placements$/, "")} could not tell ${missed}.${needed}`
1295
+ },
1296
+ ...kind
1297
+ ];
1298
+ }
1299
+ async function glanceMisreads(answer, intended, judge) {
1300
+ const sure = sureEnough(answer.offer.clarity, GLANCE_REQUIRED.offer);
1301
+ const [offer = false, category = false] = await misreadings(
1302
+ [
1303
+ { said: sure ? answer.offer.answer : "", meant: intended.offer, sells: intended.sells },
1304
+ { said: answer.category.answer, meant: intended.recognition }
1305
+ ],
1306
+ judge
1307
+ );
1308
+ return { offer, category };
1309
+ }
1310
+ function gatewayGlanceModel(onSpend) {
1311
+ return (jpeg, prompt) => askAboutImages(GLANCE_CHECK_MODEL, [jpeg], prompt, onSpend);
1312
+ }
1313
+ async function glanceCheck(opts) {
1314
+ let jpeg;
1315
+ try {
1316
+ const bytes = await bytesOf(opts.image);
1317
+ jpeg = (await sharp(bytes).resize({ width: GLANCE_WIDTH }).jpeg({ quality: 85 }).toBuffer()).toString("base64");
1318
+ } catch {
1319
+ return null;
1320
+ }
1321
+ const prompt = buildGlancePrompt({ viewer: opts.viewer, ...opts.market ? { market: opts.market } : {} });
1322
+ for (let attempt = 0; attempt < 2; attempt++) {
1323
+ const parsed = GlanceAnswerSchema.safeParse(await opts.ask(jpeg, prompt));
1324
+ if (parsed.success) {
1325
+ const misread = await glanceMisreads(parsed.data, opts.intended, opts.judge ?? jevReadJudge());
1326
+ return glanceFindings(parsed.data, opts.intended, opts.format, opts.viewer, misread);
1327
+ }
1328
+ }
1329
+ return null;
1330
+ }
1331
+
1332
+ // src/commands/canvas/static-run-review.ts
1333
+ function imagesOf(output) {
1334
+ const list = Array.isArray(output) ? output : [output];
1335
+ const images = list.filter((o) => Boolean(o) && typeof o === "object");
1336
+ return images.length > 0 && images.every((i) => i.kind === "image") ? images : null;
1337
+ }
1338
+ function promptPathOf(parsed) {
1339
+ const nodes = parsed?.nodes;
1340
+ if (!Array.isArray(nodes)) return null;
1341
+ const prompt = nodes.find((n) => n?.id === "prompt" && n?.type === "ingest");
1342
+ const p = prompt?.params;
1343
+ return p?.source === "path" && p.expect === "json" && typeof p.path === "string" ? p.path : null;
1344
+ }
1345
+ function staticReviewTargets(parsed, output) {
1346
+ const promptPath = promptPathOf(parsed);
1347
+ const images = imagesOf(output);
1348
+ if (!promptPath || !images) return null;
1349
+ const labels = finalOutputLabelsFromCanvas(parsed)?.labels ?? [];
1350
+ return {
1351
+ promptPath,
1352
+ // A local file when the run downloaded it, else its durable URL.
1353
+ images: images.flatMap((image, i) => {
1354
+ const source = typeof image.path === "string" ? image.path : typeof image.url === "string" ? image.url : null;
1355
+ return source ? [{ path: source, format: labels[i] ?? "" }] : [];
1356
+ })
1357
+ };
1358
+ }
1359
+ function nodesOf2(parsed) {
1360
+ const nodes = parsed?.nodes;
1361
+ return Array.isArray(nodes) ? nodes : [];
1362
+ }
1363
+ var refId = (ref) => typeof ref === "string" ? ref.match(/^\$ref:([a-z][a-z0-9_]*)\./)?.[1] ?? null : null;
1364
+ var hasRole = (n, role) => n.tags?.role === role;
1365
+ function variantCount(nodes) {
1366
+ const calls = nodes.filter((n) => hasRole(n, STATIC_VARIANT_CALL_ROLE)).length;
1367
+ if (calls > 0) return calls;
1368
+ const one = nodes.find((n) => hasRole(n, STATIC_VARIANTS_ROLE) && n.type === "image_generate");
1369
+ if (one) return typeof one.params?.n === "number" ? one.params.n : 1;
1370
+ if (nodes.some((n) => hasRole(n, STATIC_FIX_ROLE))) return 1;
1371
+ return nodes.filter((n) => n.type === "image_generate" && /^ad(_[a-z])?$/.test(String(n.id))).length;
1372
+ }
1373
+ function staticRunShape(parsed) {
1374
+ const nodes = nodesOf2(parsed);
1375
+ const renders = nodes.filter((n) => n.type === "image_generate" && typeof n.id === "string");
1376
+ const candidates = variantCount(nodes);
1377
+ const logoIds = new Set(nodes.filter((n) => hasRole(n, BRAND_LOGO_ROLE)).map((n) => String(n.id)));
1378
+ const logo = nodes.some((n) => hasRole(n, LOGO_COMPOSITE_ROLE)) || renders.some((n) => {
1379
+ const refs = n.inputs?.reference;
1380
+ return (Array.isArray(refs) ? refs : [refs]).some((r) => logoIds.has(refId(r) ?? ""));
1381
+ }) || // On one picture each size's words call places the logo file.
1382
+ nodes.some((n) => n.type === "static_format" && logoIds.has(refId(n.inputs?.logo) ?? ""));
1383
+ const masterId = nodes.find((n) => hasRole(n, STATIC_MASTER_ROLE))?.id;
1384
+ const adapt = nodes.find((n) => hasRole(n, STATIC_ADAPT_ROLE));
1385
+ return {
1386
+ candidates,
1387
+ judged: candidates > 1 && nodes.some(
1388
+ (n) => n.type === "image_select" && (hasRole(n, STATIC_PICK_ROLE) || n.id === "pick") || hasRole(n, VARIANT_PREFILTER_ROLE) && typeof n.params?.judge_model === "string"
1389
+ ),
1390
+ relays: masterId !== void 0 ? 0 : Math.max(0, renders.length - candidates),
1391
+ cuts: nodes.filter((n) => {
1392
+ const from = refId(n.inputs?.image);
1393
+ return hasRole(n, STATIC_SIZE_ROLE) && from !== null && from === masterId;
1394
+ }).length,
1395
+ relaid: nodes.filter((n) => hasRole(n, STATIC_ADAPT_FORMAT_ROLE)).length,
1396
+ adapted: Array.isArray(adapt?.params?.formats) ? adapt.params.formats.length : 0,
1397
+ plates: nodes.some((n) => hasRole(n, STATIC_LEAD_ROLE)) ? nodes.filter((n) => hasRole(n, STATIC_VARIANT_CALL_ROLE)).length : 0,
1398
+ // The lead the master delivers is the chosen option's own words, replayed: not a size set again.
1399
+ worded: nodes.filter((n) => hasRole(n, STATIC_FORMAT_ROLE) && n.id !== masterReads(nodes)).length,
1400
+ logo
1401
+ };
1402
+ }
1403
+ function masterReads(nodes) {
1404
+ return refId(nodes.find((n) => hasRole(n, STATIC_MASTER_ROLE))?.inputs?.image);
1405
+ }
1406
+ function shapeHint(shape, copy) {
1407
+ const drawn = shape.plates > 0 ? " (a picture each without the ad's words, the lead size's words set on it)" : "";
1408
+ const variants = `${shape.candidates} variant${shape.candidates === 1 ? "" : "s"} rendered${drawn}${shape.judged ? ", ranked by the checks with a judge on a tie" : ", no judge"}`;
1409
+ const sizes = [
1410
+ ...shape.worded > 0 ? [`${shape.worded} size${shape.worded === 1 ? "" : "s"} cut from the chosen picture with ${shape.worded === 1 ? "its" : "their"} words set for ${shape.worded === 1 ? "it" : "them"} (one request each)`] : [],
1411
+ ...shape.relaid > 0 ? [`${shape.relaid} size${shape.relaid === 1 ? "" : "s"} re-laid out from the chosen picture (one request each)`] : [],
1412
+ ...shape.cuts > 0 ? [`${shape.cuts} size${shape.cuts === 1 ? "" : "s"} cut from the chosen picture`] : [],
1413
+ ...shape.adapted > 0 ? [`${shape.adapted} adapted from it`] : [],
1414
+ ...shape.relays > 0 ? [`${shape.relays} other format${shape.relays === 1 ? "" : "s"} re-laid from the winner`] : []
1415
+ ];
1416
+ const text = copy === 0 ? "no copy (the picture is the ad)" : "the copy set by the model and read back word for word";
1417
+ return `This run: ${variants}${sizes.length > 0 ? `; ${sizes.join("; ")}` : ""}; ${text}; ${shape.logo ? "the brand logo on the ad from its real file" : "no logo"}.`;
1418
+ }
1419
+ var PAID_FOR = {
1420
+ edit: "one edit of the version shown",
1421
+ sizes: "only the sizes asked for, laid out again",
1422
+ options: "new options from scratch, every size made from the one chosen"
1423
+ };
1424
+ function runCostHint(stats, kind) {
1425
+ if (!stats) return null;
1426
+ const cached = stats.cached_nodes > 0 ? ` (${stats.cached_nodes} of ${stats.total_nodes} steps came from the cache, free)` : "";
1427
+ return `This run cost ${Math.round(stats.total_credits)} credits: ${PAID_FOR[kind]}${cached}.`;
1428
+ }
1429
+ async function textOf(ref) {
1430
+ const r = ref;
1431
+ try {
1432
+ if (typeof r?.path === "string") return await readFile5(r.path, "utf8");
1433
+ if (typeof r?.url === "string") {
1434
+ const res = await fetch(r.url);
1435
+ return res.ok ? await res.text() : null;
1436
+ }
1437
+ } catch {
1438
+ return null;
1439
+ }
1440
+ return null;
1441
+ }
1442
+ function sizeShapeOf(canvas) {
1443
+ return isPlateCanvas(canvas) ? "plate" : "relayout";
1444
+ }
1445
+ function oneSizeFix(shape) {
1446
+ return shape === "plate" ? "`baker canvas run \u2026 --regenerate format_<size>` (for example `format_9x16`) sets that size's words again on the same picture (one request)" : "`baker canvas run \u2026 --regenerate adapt_<size>` (for example `adapt_9x16`) lays out that size again from the same picture (one request)";
1447
+ }
1448
+ function fixHint(shape) {
1449
+ return `One thing wrong in a version that is otherwise right: \`baker canvas run \u2026 --fix "<what to change>"\` edits that version and changes only that, keeping the picture, the layout and the other words (one render). Wrong or missing words: check the lines in prompt.json \`copy\` are exactly what should be printed, shorten a line the model keeps breaking, and re-run: a change only to copy, positions or colours is made as an edit of the version shown. Wrong picture, colour or subject: edit prompt.json's \`scene\`, \`colors\` or \`references\`. Layout or a logo drawn wrong: say in each line's \`position\` (and \`scene.layout\`) where it sits, by what is around it. A right prompt that rolled badly: \`baker canvas run \u2026 --regenerate static_variants\` renders new options (every size follows from the new pick). One size wrong while the chosen picture is right (words cut or too small, the button small, something drawn twice): ${oneSizeFix(shape)}.`;
1450
+ }
1451
+ function verdictHints(verdict, shape = "plate") {
1452
+ if (verdict === "needs_fixes") {
1453
+ const cost = shape === "plate" ? "each size's words take one request" : "each re-laid-out size takes one request; a cut is free";
1454
+ return [
1455
+ `NOT READY: the finished ad has blocking problems. Do not present it as done, and never ask the person whether to fix them: fix them now, inside this version. A defect in a version that is otherwise right is a \`--fix\`: it edits the chosen picture only, and every size is made from it again (${cost}). The same defect after a fix means the fix does not work: change the spec (prompt.json) or the approach, never the same retry. If it still cannot be fixed, show the person the best version and say in one plain sentence what is left, in their words ("the logo sits where Stories covers it"), without a question; never record your own checks as their feedback.`,
1456
+ fixHint(shape)
1457
+ ];
1458
+ }
1459
+ if (verdict === "not_reviewed") {
1460
+ return [
1461
+ "The finished ad was NOT reviewed: no model gateway key here, or the review model did not answer twice. Look at every word of every format yourself before showing it, or re-run the same command (every node comes from the cache) to review it again."
1462
+ ];
1463
+ }
1464
+ if (verdict === "ready") {
1465
+ return ["Reviewed every format of the finished ad: every word read back exactly, nothing to fix.", SHOW_IT];
1466
+ }
1467
+ return verdict === "ready_with_notes" ? [SHOW_IT] : [];
1468
+ }
1469
+ function verdictBrief(verdict, shape = "plate") {
1470
+ if (verdict === "needs_fixes") {
1471
+ const size = shape === "plate" ? "format_<size>" : "adapt_<size>";
1472
+ return [
1473
+ `NOT READY: fix every blocking finding now, never asking the person: \`--fix "<what to change>"\` for one thing wrong, \`--regenerate ${size}\` for one size. Never present it as done.`
1474
+ ];
1475
+ }
1476
+ if (verdict === "not_reviewed") return verdictHints(verdict, shape);
1477
+ const show = 'Show it as a Version ("Version 2"), never a run id or a file; never ask which to keep or whether to publish.';
1478
+ if (verdict === "ready") return [`Reviewed every format: nothing to fix. ${show}`];
1479
+ return verdict === "ready_with_notes" ? [show] : [];
1480
+ }
1481
+ var SHOW_IT = `Show it as a Version ("Version 2"), never a run id or a file, in one line: the idea's message, who it is for, the customer quote it stands on (or that it is an explore bet), and the finding it answers. Name the versions you would run first; never ask which to keep or whether to publish: the person answers in their own time.`;
1482
+ function allowedSceneWords(spec) {
1483
+ return [.../* @__PURE__ */ new Set([...spec.scene_text, ...spec.third_party_brands.map((b) => b.name)])];
1484
+ }
1485
+ function brandPalette(brand) {
1486
+ if (!brand) return [];
1487
+ const named = [brand.ink, brand.accent, brand.cta, brand.ground, ...brand.palette];
1488
+ return [...new Set(named.filter((hex) => typeof hex === "string"))];
1489
+ }
1490
+ function safeAreaPlacements(viewer) {
1491
+ const named = (viewer?.placements ?? []).filter((p) => p !== "automatic");
1492
+ return named.length > 0 && named.length === viewer?.placements.length ? named : void 0;
1493
+ }
1494
+ function canvasPlacements(parsed) {
1495
+ const node = nodesWithRole(parsed, VARIANT_PREFILTER_ROLE)[0];
1496
+ const placements = node?.params?.placements;
1497
+ return Array.isArray(placements) && placements.length > 0 && placements.every((p) => typeof p === "string") ? placements : void 0;
1498
+ }
1499
+ async function reviewStaticRun(opts) {
1500
+ const targets = staticReviewTargets(opts.parsed, opts.output);
1501
+ if (!targets) return null;
1502
+ const prefilterId = nodesWithRole(opts.parsed, VARIANT_PREFILTER_ROLE)[0]?.id;
1503
+ const tieBreak = prefilterId ? opts.outputsByNode[prefilterId]?.reasoning : void 0;
1504
+ const pickId = nodesWithRole(opts.parsed, STATIC_PICK_ROLE)[0]?.id ?? "pick";
1505
+ const reasoning = typeof tieBreak === "string" ? tieBreak : await textOf(opts.outputsByNode[pickId]?.reasoning);
1506
+ const judge = reasoning ? parseJudgeScores(reasoning) : null;
1507
+ let copy = [];
1508
+ let mechanisms = [];
1509
+ let intended = {};
1510
+ let expectLogo = false;
1511
+ let concept = null;
1512
+ let uncast = [];
1513
+ let nobody = false;
1514
+ let brand = opts.brandName;
1515
+ let lockup = [...opts.lockup ?? []];
1516
+ let sceneText = [];
1517
+ let lines = [];
1518
+ let native;
1519
+ let palette = [];
1520
+ try {
1521
+ const spec = readAdSpec(JSON.parse(await readFile5(targets.promptPath, "utf8")));
1522
+ copy = spec.copy.map((l) => l.text);
1523
+ lines = spec.copy.map((l) => ({ text: l.text, lettering: l.lettering, ...l.role ? { role: l.role } : {} }));
1524
+ if (spec.native) {
1525
+ copy = nativeCopy(spec.native);
1526
+ lines = copy.map((text) => ({ text, lettering: "designed" }));
1527
+ native = nativeSurfaceName(spec.native);
1528
+ }
1529
+ palette = spec.native ? [] : brandPalette(spec.brand);
1530
+ mechanisms = spec.mechanism.map((m) => m.device);
1531
+ brand = spec.brand?.name ?? opts.brandName;
1532
+ const sells = (await readCompanyReading(path8.resolve(path8.dirname(targets.promptPath), "../../..")))?.sells;
1533
+ intended = {
1534
+ ...spec.message?.trim() ? { offer: spec.message.trim() } : {},
1535
+ ...spec.viewer?.who.trim() ? { persona: spec.viewer.who.trim() } : {},
1536
+ ...spec.recognition?.trim() ? { recognition: spec.recognition.trim() } : {},
1537
+ ...sells ? { sells } : {}
1538
+ };
1539
+ lockup = [.../* @__PURE__ */ new Set([...spec.brand?.lockup ?? [], ...lockup])];
1540
+ sceneText = [
1541
+ ...allowedSceneWords(spec),
1542
+ ...spec.native ? nativeChrome(spec.native, spec.viewer?.market?.language, interfaceWordsOf(opts.parsed)) : []
1543
+ ];
1544
+ expectLogo = spec.logo && !spec.native && staticRunShape(opts.parsed).logo;
1545
+ concept = conceptSummary(spec);
1546
+ const cacheDir = path8.join(findWorkspaceRoot(path8.dirname(targets.promptPath)) ?? path8.dirname(targets.promptPath), "canvas", ".cache");
1547
+ const people = spec.native ? [] : await peopleReader(cacheDir, (u) => opts.onSpend?.(u))(copy) ?? [];
1548
+ uncast = uncastPeople(spec, people);
1549
+ nobody = !spec.native && castsNobody(spec);
1550
+ } catch {
1551
+ copy = [];
1552
+ }
1553
+ const shape = staticRunShape(opts.parsed);
1554
+ const placements = canvasPlacements(opts.parsed) ?? safeAreaPlacements(opts.viewer);
1555
+ const masterFormat = staticMasterFormat(opts.parsed) ?? void 0;
1556
+ const glancing = opts.glance === false ? Promise.resolve(null) : glanceAtFinished(
1557
+ targets.images,
1558
+ opts.viewer ?? STRANGER,
1559
+ intended,
1560
+ opts.glance ?? gatewayGlanceModel(opts.onSpend),
1561
+ opts.onSpend
1562
+ ).catch(() => null);
1563
+ const comparing = opts.previous ? nearIdenticalFindings(targets.images, opts.previous).catch(() => []) : Promise.resolve([]);
1564
+ const leadFormat = masterFormat ?? targets.images[0]?.format ?? "";
1565
+ const lead = targets.images.find((i) => i.format === leadFormat);
1566
+ const drawn = native || !lead ? [] : drawnSizes(opts.parsed, targets.images.map((i) => i.format), leadFormat);
1567
+ const matching = lead && drawn.length > 0 ? compareSizes(
1568
+ lead,
1569
+ targets.images.filter((i) => drawn.includes(i.format)),
1570
+ { ...opts.onSpend ? { onSpend: opts.onSpend } : {} }
1571
+ ).catch(() => drawn.map((format) => ({ format, compared: false, differences: [] }))) : Promise.resolve([]);
1572
+ const untouched = opts.settled ? await samePictureSizes(targets.images, opts.settled.images) : [];
1573
+ const changed = targets.images.filter((i) => !untouched.includes(i.format));
1574
+ const held = await heldRules(path8.dirname(targets.promptPath)).catch(() => ({ rules: [] }));
1575
+ const review = await reviewRenderedStatic({
1576
+ images: changed.length > 0 ? changed : targets.images,
1577
+ rules: held.rules,
1578
+ copy,
1579
+ lines,
1580
+ palette,
1581
+ ...placements ? { placements } : {},
1582
+ ...brand ? { brand } : {},
1583
+ ...lockup.length > 0 ? { lockup } : {},
1584
+ ...sceneText.length > 0 ? { sceneText } : {},
1585
+ ...masterFormat ? { masterFormat } : {},
1586
+ ...expectLogo ? { expectLogo } : {},
1587
+ ...concept && concept.mustKeep.length > 0 && referenceSource(opts.parsed) ? { concept: { ...concept, reference: referenceSource(opts.parsed) } } : {},
1588
+ logo: shape.logo,
1589
+ ...native ? { native } : {},
1590
+ ...uncast.length > 0 ? { uncastPeople: uncast } : {},
1591
+ ...nobody ? { castsNobody: true } : {},
1592
+ ...native ? { scrolled: scrolledLines(opts.parsed, opts.outputsByNode) } : {},
1593
+ mechanisms,
1594
+ ...opts.viewer ? { viewer: describeViewer(opts.viewer) } : {},
1595
+ placedLogos: placedLogoBoxes(opts.parsed, opts.outputsByNode),
1596
+ onSpend: opts.onSpend
1597
+ });
1598
+ const [glanced, compared, matched] = await Promise.all([glancing, comparing, matching]);
1599
+ const glance = review === null ? null : glanced;
1600
+ const unchanged = review === null ? [] : compared;
1601
+ const sized = sizeFactFindings(opts.parsed, opts.outputsByNode);
1602
+ const logoChecked = expectLogo && review !== null;
1603
+ const placedLogo = logoChecked ? logoPlacementFindings(opts.parsed, opts.outputsByNode) : [];
1604
+ const deliveredLogo = logoChecked ? await deliveredLogoFindings(opts.parsed, opts.outputsByNode, changed.length > 0 ? changed : targets.images, [
1605
+ .../* @__PURE__ */ new Set([...palette, "#FFFFFF", "#000000"])
1606
+ ]).catch(() => []) : [];
1607
+ const differing = matched.flatMap((m) => m.differences.length > 0 ? [sizeDifferenceFinding(m.format, m.differences)] : []);
1608
+ const fresh = review === null ? null : [...review, ...glance ?? [], ...unchanged, ...sized, ...placedLogo, ...deliveredLogo, ...differing];
1609
+ const reviewed = fresh === null || !opts.settled ? fresh : carryUnchanged(fresh, opts.settled.review, untouched);
1610
+ const verdict = staticVerdict(reviewed);
1611
+ const hints = verdictHints(verdict, sizeShapeOf(opts.parsed));
1612
+ const notes = [];
1613
+ const note = (hint) => {
1614
+ hints.push(hint);
1615
+ notes.push(hint);
1616
+ };
1617
+ const lost = keptLostHint(reviewed ?? [], await ideaOf(targets.promptPath));
1618
+ if (lost) note(lost);
1619
+ const sizeHints = verdict === "needs_fixes" ? sizeFixHints(opts.parsed, reviewed) : [];
1620
+ const sizesFirst = sizeHints[0]?.startsWith("Do this first") === true;
1621
+ if (sizesFirst) hints.push(...sizeHints);
1622
+ for (const f of reviewed ?? []) hints.push(`${f.severity === "blocking" ? "Must fix" : "Should fix"}: ${f.what}`);
1623
+ if ((reviewed ?? []).some((f) => f.severity === "blocking" && f.kind?.item === "rule" && f.kind.element === "copy")) {
1624
+ note(
1625
+ 'A company rule the words break is yours to rewrite in prompt.json\'s `copy` (no automatic round changes the words); only when the person asked for those words, keep them and add `"waive": [{"rule": "<id>", "why": "<their ask>"}]`.'
1626
+ );
1627
+ }
1628
+ if (review !== null && glance === null && opts.glance !== false) {
1629
+ note("The finished ad was not shown to a stranger at a glance (the model did not answer): look at the 4:5 at phone size yourself and say what it sells in three seconds.");
1630
+ }
1631
+ const unmatched = review === null ? [] : matched.filter((m) => !m.compared).map((m) => m.format);
1632
+ if (unmatched.length > 0) {
1633
+ note(
1634
+ `The ${unmatched.join(" and ")} could not be compared with the ${leadFormat} (the model did not answer): look at them side by side yourself, for the same people and product, shown once, unstretched.`
1635
+ );
1636
+ }
1637
+ if (!sizesFirst) hints.push(...sizeHints);
1638
+ hints.push(shapeHint(shape, copy.length));
1639
+ hints.push(...variantHints(judge, prefilterOutcome(opts.parsed, opts.outputsByNode)));
1640
+ return { review: reviewed, verdict, judge, hints, notes };
1641
+ }
1642
+ function scrolledLines(parsed, outputsByNode) {
1643
+ return Object.fromEntries(
1644
+ nodesOf2(parsed).flatMap((n) => {
1645
+ const out = typeof n.id === "string" ? outputsByNode[n.id] : void 0;
1646
+ const format = n.params?.format;
1647
+ return n.type === "static_native" && typeof format === "string" && Array.isArray(out?.scrolled) ? [[format, out.scrolled.filter((t) => typeof t === "string")]] : [];
1648
+ })
1649
+ );
1650
+ }
1651
+ async function ideaOf(promptPath) {
1652
+ const definition = await readFile5(path8.join(path8.dirname(promptPath), "_definition.md"), "utf8").catch(() => "");
1653
+ const idea = frontmatterOf(definition)?.idea;
1654
+ return typeof idea === "string" && idea.trim() ? idea.trim() : void 0;
1655
+ }
1656
+ function referenceSource(parsed) {
1657
+ const original = nodesOf2(parsed).find((n) => n.id === "original" && n.type === "ingest");
1658
+ const source = original?.params?.url ?? original?.params?.path;
1659
+ return typeof source === "string" && !source.includes("[TODO") ? source : null;
1660
+ }
1661
+ function interfaceWordsOf(parsed) {
1662
+ const nodes = parsed?.nodes;
1663
+ const screen = Array.isArray(nodes) ? nodes.find((n) => n?.type === "static_native") : void 0;
1664
+ return readInterfaceWords(screen?.params?.interface_words) ?? void 0;
1665
+ }
1666
+ var STRANGER = { temperature: "cold", knows: [], placements: ["automatic"], source: "knowledge", reasons: [] };
1667
+ async function glanceAtFinished(images, viewer, intended, ask, onSpend) {
1668
+ const shown = images.find((i) => i.format === "4:5") ?? images[0];
1669
+ if (!shown) return null;
1670
+ return await glanceCheck({
1671
+ image: shown.path,
1672
+ format: shown.format,
1673
+ viewer,
1674
+ intended,
1675
+ ask,
1676
+ judge: jevReadJudge(onSpend),
1677
+ ...viewer.market ? { market: describeMarket(viewer.market) } : {}
1678
+ });
1679
+ }
1680
+ function sizeFixHints(parsed, review) {
1681
+ const cut = new Set(nodesWithRole(parsed, STATIC_FORMAT_ROLE).map((n) => n.id));
1682
+ const relaid = [...nodesWithRole(parsed, STATIC_ADAPT_FORMAT_ROLE).map((n) => n.id), ...cut];
1683
+ const blocking = (review ?? []).filter((f) => f.severity === "blocking");
1684
+ const regenerate = relaid.flatMap((id) => {
1685
+ const format = formatOfSizeNode(parsed, id);
1686
+ if (!format || !blocking.some((f) => f.what.startsWith(`${format}:`))) return [];
1687
+ return [
1688
+ cut.has(id) ? `The ${format}'s words alone need fixing and the picture is right: \`baker canvas run \u2026 --regenerate ${id}\` sets the ${format}'s words again on the same picture (one request). If the picture itself is wrong, \`--fix\` it instead: every size's words are set again on the corrected picture.` : `The ${format} alone needs fixing and the chosen picture is right: \`baker canvas run \u2026 --regenerate ${id}\` lays out the ${format} again from the same picture (one request). If the chosen picture itself is wrong, \`--fix\` it instead: every size follows.`
1689
+ ];
1690
+ });
1691
+ const relaidFormats = relaid.map((id) => formatOfSizeNode(parsed, id)).filter((f) => Boolean(f));
1692
+ const sizesOnly = regenerate.length > 0 && blocking.every((f) => relaidFormats.some((format) => f.what.startsWith(`${format}:`)));
1693
+ const lead = sizesOnly ? regenerate.map((h, i) => i === 0 ? `Do this first, not a --fix: ${h}` : h) : regenerate;
1694
+ return [...lead, ...safeFitHints(parsed, blocking)];
1695
+ }
1696
+ var COVERED = / sits? where .+? covers? (?:it|them) /;
1697
+ function safeFitHints(parsed, blocking) {
1698
+ return nodesWithRole(parsed, STATIC_SAFE_FIT_ROLE).flatMap((n) => {
1699
+ const format = typeof n.params?.format === "string" ? n.params.format : formatOfSlug(n.id.replace(/^safe_/, ""));
1700
+ if (!blocking.some((f) => f.what.startsWith(`${format}:`) && COVERED.test(f.what))) return [];
1701
+ return [
1702
+ `The ${format} was already shrunk and shifted automatically to clear what the app covers; small misses are corrected that way, so this one is too large for it. Change the layout itself (shorter copy, fewer lines, a smaller block of text) rather than a \`--fix\` asking to move it, which moves it only about 1%.`
1703
+ ];
1704
+ });
1705
+ }
1706
+ var SIZE_FACT_FINDING = {
1707
+ band_too_far: {
1708
+ what: (format) => `${format}: the words reach too far past the part of the frame the app leaves clear to be moved inside it; set them inside it.`,
1709
+ kind: { item: "safe_zone", element: "copy", defect: "other", edges: [] }
1710
+ },
1711
+ words_over_face: {
1712
+ what: (format) => `${format}: the words were set over a face; set them where no face is.`,
1713
+ kind: { item: "layout", element: "copy", defect: "other", edges: [] }
1714
+ },
1715
+ words_misaligned: {
1716
+ what: (format) => `${format}: ${PATCHED_WORDS}, which shows as a box; set them again on the same picture.`,
1717
+ kind: { item: "layout", element: "copy", defect: "other", edges: [] }
1718
+ },
1719
+ words_not_read: {
1720
+ what: (format) => `${format}: ${UNREAD_WORDS}, so the picture around them may have been redrawn; set them again on the same picture.`,
1721
+ kind: { item: "layout", element: "copy", defect: "other", edges: [] }
1722
+ },
1723
+ subject_covered: {
1724
+ what: (format, facts) => `${format}: the words hide ${(facts.covered ?? ["the product"]).join(" and ")}, which the other sizes show; set them where it stays in view.`,
1725
+ kind: { item: "layout", element: "copy", defect: "other", edges: [] }
1726
+ },
1727
+ subject_cut: {
1728
+ what: (format) => `${format}: no cut of the picture keeps every person and product whole in this size.`,
1729
+ kind: { item: "picture", element: "picture", defect: "cut", edges: [] }
1730
+ }
1731
+ };
1732
+ function coveredIn(facts) {
1733
+ if (facts === void 0 || facts === null || typeof facts !== "object") return null;
1734
+ const covered = facts.covered;
1735
+ return Array.isArray(covered) ? covered.filter((c) => typeof c === "string") : [];
1736
+ }
1737
+ function hiddenEverywhere(sizes, outputsByNode) {
1738
+ const lists = sizes.map((s) => ({ ...s, covered: coveredIn(outputsByNode[s.id]?.facts) }));
1739
+ const labels = new Set(
1740
+ (lists[0]?.covered ?? []).filter((label) => lists.length > 1 && lists.every((s) => s.covered?.includes(label)))
1741
+ );
1742
+ const first = lists.find((s) => s.format && s.covered?.some((label) => labels.has(label)));
1743
+ const notes = first?.format && labels.size > 0 ? [
1744
+ {
1745
+ severity: "warning",
1746
+ what: `${first.format}: the words hide ${[...labels].join(" and ")} in every size; set them where it stays in view if it is what the ad sells.`,
1747
+ kind: { item: "layout", element: "copy", defect: "other", edges: [] }
1748
+ }
1749
+ ] : [];
1750
+ return { labels, notes };
1751
+ }
1752
+ function sizeFactFindings(parsed, outputsByNode) {
1753
+ const added = paintedAdditions(parsed, outputsByNode);
1754
+ const sizes = nodesWithRole(parsed, STATIC_FORMAT_ROLE);
1755
+ const everywhere = hiddenEverywhere(
1756
+ sizes.map((n) => ({ id: n.id, format: formatOfSizeNode(parsed, n.id) })),
1757
+ outputsByNode
1758
+ );
1759
+ const found = sizes.flatMap((n) => {
1760
+ const format = formatOfSizeNode(parsed, n.id);
1761
+ const facts = outputsByNode[n.id]?.facts ?? {};
1762
+ const shownElsewhere = (coveredIn(facts) ?? []).some((label) => !everywhere.labels.has(label));
1763
+ const said = typeof facts.reason === "string" && (facts.reason !== "subject_covered" || shownElsewhere) ? SIZE_FACT_FINDING[facts.reason] : void 0;
1764
+ const patched = facts.reason !== "words_misaligned" && facts.words_mode !== "whole" && typeof facts.residual === "number" && facts.residual > MISALIGNED ? SIZE_FACT_FINDING.words_misaligned : void 0;
1765
+ const covered = (coveredIn(facts) ?? []).filter((label) => !everywhere.labels.has(label));
1766
+ const fromPlate = refId(n.inputs?.plate);
1767
+ const extra = fromPlate ? added.get(fromPlate) : void 0;
1768
+ if (!format) return [];
1769
+ return [
1770
+ ...[said, patched].flatMap(
1771
+ (f) => f ? [{ severity: "blocking", what: f.what(format, covered.length > 0 ? { covered } : {}), kind: f.kind }] : []
1772
+ ),
1773
+ ...extra ? [
1774
+ {
1775
+ severity: "blocking",
1776
+ what: `${format}: the picture painted wider from the chosen one shows ${extra.join(", ")}, which the other sizes do not. It must show the main size's people and product, once each.`,
1777
+ kind: { item: "sizes", element: "picture", defect: "other", edges: [] }
1778
+ }
1779
+ ] : []
1780
+ ];
1781
+ });
1782
+ return [...found, ...everywhere.notes];
1783
+ }
1784
+ function paintedAdditions(parsed, outputsByNode) {
1785
+ return new Map(
1786
+ nodesWithRole(parsed, STATIC_PLATE_ROLE).flatMap((n) => {
1787
+ const facts = outputsByNode[n.id]?.facts;
1788
+ const added = Array.isArray(facts?.added) ? facts.added.filter((a) => typeof a === "string") : [];
1789
+ return facts?.reason === "subject_added" && added.length > 0 ? [[n.id, added]] : [];
1790
+ })
1791
+ );
1792
+ }
1793
+ function drawnSizes(parsed, delivered, masterFormat) {
1794
+ const others = delivered.filter((format) => format && format !== masterFormat);
1795
+ const cut = nodesWithRole(parsed, STATIC_FORMAT_ROLE);
1796
+ if (cut.length === 0) return others;
1797
+ const painted = new Set(nodesWithRole(parsed, STATIC_PLATE_ROLE).map((n) => n.id));
1798
+ const fromPainted = new Set(
1799
+ cut.flatMap((n) => {
1800
+ const plate = refId(n.inputs?.plate);
1801
+ const format = formatOfSizeNode(parsed, n.id);
1802
+ return plate && painted.has(plate) && format ? [format] : [];
1803
+ })
1804
+ );
1805
+ return others.filter((format) => fromPainted.has(format));
1806
+ }
1807
+ function formatOfSlug(slug) {
1808
+ return slug.replace("x", ":").replace("_", ".");
1809
+ }
1810
+ function prefilterNodeId(parsed) {
1811
+ return nodesWithRole(parsed, VARIANT_PREFILTER_ROLE)[0]?.id ?? null;
1812
+ }
1813
+ function prefilterOutcome(parsed, outputsByNode) {
1814
+ const id = prefilterNodeId(parsed);
1815
+ const out = id ? outputsByNode[id] : void 0;
1816
+ return out && Array.isArray(out.dropped) ? out : null;
1817
+ }
1818
+ function prefilterSpend(parsed, outputsByNode, nodeRuns) {
1819
+ const cached = (id2) => nodeRuns.some((r) => r.node_id === id2 && r.cached);
1820
+ const id = prefilterNodeId(parsed);
1821
+ const checks = id && !cached(id) ? prefilterOutcome(parsed, outputsByNode)?.usage ?? [] : [];
1822
+ const fits = [
1823
+ ...nodesWithRole(parsed, STATIC_SAFE_FIT_ROLE),
1824
+ ...nodesWithRole(parsed, STATIC_PLACE_ROLE),
1825
+ // A size cut from one picture reads its subjects and its words; a widened picture its subjects.
1826
+ ...nodesWithRole(parsed, STATIC_LEAD_ROLE),
1827
+ ...nodesWithRole(parsed, STATIC_FORMAT_ROLE),
1828
+ ...nodesWithRole(parsed, STATIC_PLATE_ROLE),
1829
+ // The logo's composite reads the size's words for its check.
1830
+ ...nodesWithRole(parsed, LOGO_COMPOSITE_ROLE),
1831
+ // A finished ad's 9:16 is planned and read, on any canvas.
1832
+ ...nodesOf2(parsed).filter(
1833
+ (n) => n.type === "static_vertical_relayout" && typeof n.id === "string"
1834
+ )
1835
+ ].filter((n) => !cached(n.id)).flatMap((n) => {
1836
+ const usage = outputsByNode[n.id]?.usage;
1837
+ return Array.isArray(usage) ? usage : [];
1838
+ });
1839
+ return [...checks, ...fits];
1840
+ }
1841
+ function variantHints(judge, prefilter) {
1842
+ const hints = [];
1843
+ const dropped = prefilter?.dropped ?? [];
1844
+ const kept = Array.isArray(prefilter?.images) ? prefilter.images.length : judge?.length ?? 0;
1845
+ const total = dropped.length + kept;
1846
+ if (prefilter?.flagged) {
1847
+ hints.push(
1848
+ `Every variant failed the checks; variant ${prefilter.flagged.index + 1} had the fewest problems and was kept: ${prefilter.flagged.reasons.join(" ")}`
1849
+ );
1850
+ } else if (dropped.length > 0) {
1851
+ const list = dropped.map((d) => `variant ${d.index + 1} (${d.reasons.join(" ")})`).join("; ");
1852
+ hints.push(`${dropped.length} of ${total} variants set aside by the checks before the judge: ${list}.`);
1853
+ }
1854
+ const alone = prefilter?.order?.length === 1 && !prefilter.flagged ? prefilter.order[0] : void 0;
1855
+ if (alone !== void 0 && dropped.length > 0) {
1856
+ hints.push(
1857
+ `The checks ranked variant ${alone + 1} best, so no judge was needed; the others stay in this run as options the person can switch to (\`baker canvas run --use-variant\`).`
1858
+ );
1859
+ }
1860
+ const winner = judge ? judgeWinner(judge) : null;
1861
+ if (judge && winner) {
1862
+ const gone = new Set(dropped.map((d) => d.index));
1863
+ const shown = prefilter?.order ?? Array.from({ length: total }, (_, i) => i).filter((i) => !gone.has(i));
1864
+ const variant = (shown[winner.image - 1] ?? winner.image - 1) + 1;
1865
+ const why = winner.of === void 0 ? `${winner.total}/${Object.keys(winner.scores).length * 5}` : `first on ${Object.entries(winner.scores).filter(([, beaten]) => beaten === winner.of).map(([criterion]) => criterion.replace(/_/g, " ")).join(", ") || "none of the criteria alone"}`;
1866
+ hints.push(
1867
+ `The judge picked variant ${variant} of the ${judge.length} it compared (${why}); the others it compared stay in this run as options the person can switch to (\`baker canvas run --use-variant\`).`
1868
+ );
1869
+ }
1870
+ return hints;
1871
+ }
1872
+
1873
+ // src/commands/canvas/static-spec-repair.ts
1874
+ import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
1875
+ import sharp2 from "sharp";
1876
+ import { z as z2 } from "zod";
1877
+ var Answer = z2.object({
1878
+ changed: z2.string().min(1),
1879
+ set: z2.array(z2.object({ path: z2.string().min(1), value: z2.unknown() }))
1880
+ });
1881
+ function withValueAt(root, path10, value) {
1882
+ const [key, ...rest] = path10;
1883
+ if (key === void 0) return value;
1884
+ if (Array.isArray(root)) {
1885
+ const at = Number(key);
1886
+ if (!Number.isInteger(at) || at < 0 || at > root.length) return root;
1887
+ const next = [...root];
1888
+ next[at] = withValueAt(root[at], rest, value);
1889
+ return next;
1890
+ }
1891
+ const holder = root && typeof root === "object" ? root : {};
1892
+ return { ...holder, [key]: withValueAt(holder[key], rest, value) };
1893
+ }
1894
+ function declaredAvatars(spec) {
1895
+ return new Set((spec.concept?.load_bearing ?? []).filter(isVital).flatMap((l) => castHandles(l.ours ?? "")));
1896
+ }
1897
+ function groundedAvatars(spec) {
1898
+ return new Set(spec.references.flatMap((r) => r.avatar ? [r.avatar.toLowerCase()] : []));
1899
+ }
1900
+ function castsOnly(spec, avatars) {
1901
+ const people = spec.references.filter((r) => r.id.startsWith("PERSON_"));
1902
+ return people.length > 0 && people.every((r) => r.avatar !== void 0 && avatars.has(r.avatar.toLowerCase()));
1903
+ }
1904
+ function keepsCast(was, now) {
1905
+ const declared = declaredAvatars(was);
1906
+ if (castsNobody(was) && !castsNobody(now) && !castsOnly(now, declared)) return false;
1907
+ const before = groundedAvatars(was);
1908
+ const after = groundedAvatars(now);
1909
+ return ![...declared].some((handle) => before.has(handle) && !after.has(handle));
1910
+ }
1911
+ function memeTemplateReferences(spec) {
1912
+ return spec.references.filter(isMemeTemplate);
1913
+ }
1914
+ function keepsMemeTemplates(was, now) {
1915
+ return memeTemplateReferences(was).every(
1916
+ (t) => now.references.some((r) => r.id === t.id && r.role === t.role && r.image === t.image && r.what === t.what && r.keep === t.keep)
1917
+ );
1918
+ }
1919
+ function printedWords(spec) {
1920
+ return [...spec.copy.map((l) => l.text), ...spec.native ? nativeCopy(spec.native) : []];
1921
+ }
1922
+ function acceptRepair(before, answer, held = { rules: [] }) {
1923
+ const parsed = Answer.safeParse(answer);
1924
+ if (!parsed.success || !isAdSpec(before)) return null;
1925
+ const spec = parsed.data.set.reduce((at, { path: path10, value }) => withValueAt(at, path10.split("."), value), before);
1926
+ if (!isAdSpec(spec)) return null;
1927
+ const was = AdSpecSchema.safeParse(before);
1928
+ const now = AdSpecSchema.safeParse(spec);
1929
+ if (!was.success || !now.success) return null;
1930
+ if (JSON.stringify(was.data) === JSON.stringify(now.data)) return null;
1931
+ for (const key of ["concept", "mechanism", "message", "brand", "viewer"]) {
1932
+ if (JSON.stringify(was.data[key]) !== JSON.stringify(now.data[key])) return null;
1933
+ }
1934
+ if (was.data.native && was.data.native.surface !== now.data.native?.surface) return null;
1935
+ if (!keepsCast(was.data, now.data) || !keepsMemeTemplates(was.data, now.data)) return null;
1936
+ const kept = printedWords(now.data);
1937
+ const said = printedWords(was.data);
1938
+ if (!said.every((text) => kept.includes(text))) return null;
1939
+ if (was.data.native) {
1940
+ const shown = now.data.native ? nativeCopy(now.data.native) : [];
1941
+ if (!nativeCopy(was.data.native).every((text) => shown.includes(text))) return null;
1942
+ }
1943
+ const added = kept.filter((text) => !said.includes(text));
1944
+ if (ruleTells(added, held.rules, held.language).some((t) => t.kind === "forbidden")) return null;
1945
+ return { changed: parsed.data.changed, spec };
1946
+ }
1947
+ function memeTemplatesOf(spec) {
1948
+ let raw;
1949
+ try {
1950
+ raw = JSON.parse(spec);
1951
+ } catch {
1952
+ return [];
1953
+ }
1954
+ const parsed = AdSpecSchema.safeParse(raw);
1955
+ return parsed.success ? memeTemplateReferences(parsed.data).map((r) => `${r.id} (${r.what})`) : [];
1956
+ }
1957
+ function buildSpecRepairPrompt(spec, findings, schema, restore = []) {
1958
+ const templates = memeTemplatesOf(spec);
1959
+ return [
1960
+ "This is the spec (prompt.json) a static ad was drawn from, and the image is the ad it gave.",
1961
+ "A review found these defects in it, and they come from what the spec asks for, so drawing it again or editing the picture brings them back:",
1962
+ ...findings.map((f) => `- ${f}`),
1963
+ ...restore.length > 0 ? [
1964
+ "",
1965
+ "Restore what made the proven ad win, as the concept declares it: put each of these back in the scene, the references and the lines' `look`, carried by exactly what of ours the concept names; never drop it or put anything the concept does not declare in its place.",
1966
+ ...restore.map((r) => `- ${r}`)
1967
+ ] : [],
1968
+ "",
1969
+ "Correct the spec so these defects cannot happen, changing as little as you can:",
1970
+ "- Drop, replace or reword the element, photo, reference, layout or scene instruction that causes a defect (never what the concept keeps of the proven ad). A second subject the viewer would read as another one (another pet, another person) is dropped, or made unmistakably the same one.",
1971
+ "- A rating or stars shown with no source: name the source only if the spec already states one anywhere; otherwise drop the stars or the rating. Never invent a source, a number or a claim.",
1972
+ "- A native screen's layout (where its headline, bubbles or cards sit, what it shows) is changed in its `native` block.",
1973
+ "- Keep every line of copy word for word: never reword, shorten or drop one. Keep the schema, the brand and everything the defects do not touch.",
1974
+ "- Preserve `concept`, `mechanism`, `message` and `brand` exactly, including the CTA colour. Fix how the ad executes its idea; never change why it works or remove its load-bearing elements to make a defect pass.",
1975
+ ...templates.length > 0 ? [
1976
+ `- These references are real meme templates, grounded on their real pictures: ${templates.join("; ")}. Keep each exactly as it is (id, role, image and use) and keep the scene using it as the picture; never drop, replace or redraw one, and never describe its people or faces in the scene for the image model to draw.`
1977
+ ] : [],
1978
+ "- Keep a native screen on the same `native.surface`. Notes stays Notes, a review stays on its review platform. Change its layout or content only; never replace it with a physical document or a generic ad.",
1979
+ "",
1980
+ 'Reply with only this JSON, naming only the fields you replace, each by its dotted path in the spec ("scene.layout", "references", "copy.2.position", "native.messages"), with its whole new value: {"changed": "<one plain sentence a marketer reads: what you changed and why>", "set": [{"path": "<dotted path>", "value": <its new value>}]}',
1981
+ "",
1982
+ "The spec:",
1983
+ spec,
1984
+ // Bench, Oct 2026: without it the model set a field the spec does not have ("native.layout").
1985
+ ...schema ? ["", "Its JSON schema: set only fields and values it allows.", JSON.stringify(schema)] : []
1986
+ ].join("\n");
1987
+ }
1988
+ function restoreLines(spec, jobs) {
1989
+ const parsed = AdSpecSchema.safeParse(spec);
1990
+ if (!parsed.success || jobs.length === 0) return [];
1991
+ return (parsed.data.concept?.load_bearing ?? []).filter((l) => isVital(l) && l.job !== void 0 && jobs.includes(l.job)).map((l) => {
1992
+ const carried = decisionOf(l) === "keep" ? "kept as in the proven ad" : `carried by ${l.ours?.trim() || "what of ours the concept names"}`;
1993
+ return `${l.job === "stop" ? "what stops the scroll" : "the proof"}, "${l.element}": ${carried}`;
1994
+ });
1995
+ }
1996
+ var REPAIR_TIMEOUT_MS = 15e4;
1997
+ var SHOWN_WIDTH = 768;
1998
+ async function repairSpec(opts) {
1999
+ const text = await readFile6(opts.promptPath, "utf8").catch(() => null);
2000
+ if (text === null) return null;
2001
+ let before;
2002
+ try {
2003
+ before = JSON.parse(text);
2004
+ } catch {
2005
+ return null;
2006
+ }
2007
+ const shown = opts.image ? await bytesOf(opts.image).then(async (bytes) => (await sharp2(bytes).resize({ width: SHOWN_WIDTH }).jpeg({ quality: 85 }).toBuffer()).toString("base64")).catch(() => null) : null;
2008
+ const prompt = buildSpecRepairPrompt(
2009
+ text,
2010
+ opts.findings,
2011
+ adSpecJsonSchema(),
2012
+ restoreLines(before, opts.restore ?? [])
2013
+ );
2014
+ const repair = acceptRepair(
2015
+ before,
2016
+ await askAboutImages(RENDER_REVIEW_MODEL, shown ? [shown] : [], prompt, opts.onSpend, REPAIR_TIMEOUT_MS),
2017
+ opts.held
2018
+ );
2019
+ if (!repair) return null;
2020
+ await writeFile5(opts.promptPath, `${JSON.stringify(repair.spec, null, 2)}
2021
+ `, "utf8");
2022
+ return repair.changed;
2023
+ }
2024
+
2025
+ // src/commands/canvas/band-relay-plan.ts
2026
+ async function bandRelayPlans(canvas, ids, outputsByNode, onSpend) {
2027
+ const ad = outputsByNode.master?.image;
2028
+ const source = typeof ad?.path === "string" ? ad.path : typeof ad?.url === "string" ? ad.url : void 0;
2029
+ if (!source) return {};
2030
+ const bytes = await bytesOf(source).catch(() => null);
2031
+ if (!bytes) return {};
2032
+ const nodes = canvas?.nodes;
2033
+ const placements = Array.isArray(nodes) ? plannedPlacements(nodes) : void 0;
2034
+ const plans = {};
2035
+ for (const id of ids) {
2036
+ const format = formatOfAdaptId(id);
2037
+ if (!format) continue;
2038
+ const plan = await planVertical(bytes, staticSafeArea(format, placements), onSpend, { keepWords: true }).catch(() => null);
2039
+ if (plan) plans[id] = plan.prompt;
2040
+ }
2041
+ return plans;
2042
+ }
2043
+
2044
+ // src/commands/canvas/run.ts
2045
+ function refusePlateVersion(runId) {
2046
+ const message = `The version of run ${runId} could not be found with the picture its sizes are cut from, so it cannot be changed on top of. Render the creative again (baker canvas run --slug <slug>), then make the change on that version.`;
2047
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { code: "version_not_found", message } }, null, 2)}
2048
+ `);
2049
+ process.exit(2);
2050
+ }
2051
+ var OPERATOR = "Operator only, agents never need it.";
2052
+ var runCommand = defineCommand({
2053
+ meta: {
2054
+ name: "run",
2055
+ description: "Validate and execute a canvas. Pass the canvas file, or `--slug <slug>` to run a creative by name: its canvas in this workspace, or, when this workspace does not have it (a fresh workspace, another chat's creative), its files restored from its latest recorded run first. A run that was interrupted resumes; a finished one re-renders from the cache. Several creatives render at once in one command: pass several files, or `--slug a,b,c` (one row each: slug, status, run_id, files, previews). Each delivered picture also gets a JPEG preview at most 1024px on its longest edge, by the same label as its file in `previews`: look at that, not the full file."
2056
+ },
2057
+ args: {
2058
+ file: {
2059
+ type: "positional",
2060
+ required: false,
2061
+ description: "Path to canvas JSON (or use --slug). Several files render at once, each its own run: baker canvas run src/creatives/a/a.canvas.json src/creatives/b/b.canvas.json"
2062
+ },
2063
+ slug: {
2064
+ type: "string",
2065
+ description: "Run the creative src/creatives/<slug>/ by name instead of passing its file. Restores its files from run history when they are not in this workspace; local files are never overwritten unless you pass --force-remote. Several, comma-separated, render at once, each its own run: --slug spring-a,spring-b,spring-c"
2066
+ },
2067
+ series: {
2068
+ type: "string",
2069
+ description: "Render every ad of the series this lead ad leads, all at once (`baker creatives make <idea> --series <lead>` made them): each is the lead's ready version with its own words, reviewed and corrected on its own. An ad already ready from the lead's current version is not rendered again. Start here for several messages in one style: baker canvas run --series spring-offer"
2070
+ },
2071
+ "force-remote": {
2072
+ type: "boolean",
2073
+ default: false,
2074
+ description: "With --slug: restore the recorded files even over local ones, replacing those that differ"
2075
+ },
2076
+ until: {
2077
+ type: "string",
2078
+ description: "Stop before the expensive half and leave the run resumable. `frames` settles the pictures and stops on the doorstep of the clips, so the look can be checked for the price of a few images instead of a whole ad. Continue with `baker canvas run <file> --run-id <the same id>` \u2014 everything already done is cached and is not paid for twice."
2079
+ },
2080
+ brief: {
2081
+ type: "string",
2082
+ description: "What the person asked for, IN THEIR OWN WORDS \u2014 paste their message, do not summarise it. The review compares the finished video against this and reports what they asked for that is missing or contradicted. Without it the review can only say whether the video is well made, not whether it is the one they wanted: every other check grades the render against the spec, and a spec that misread the request agrees with itself."
2083
+ },
2084
+ full: {
2085
+ type: "boolean",
2086
+ default: false,
2087
+ description: "Also print the per-node output, the run's stats, the judge's scores and the full guide in hints. The default is the result alone on stdout (verdict, review, the next step as hints, run_id, files, previews); on stderr, one [log] line naming the progress log (the [hint] lines there are the full guide) and the [warn] lines."
2088
+ },
2089
+ "run-id": { type: "string", description: "Override run id (also resumes that run, re-attaching its in-flight jobs)" },
2090
+ fix: {
2091
+ type: "string",
2092
+ description: `Static ad only: correct a finished version instead of rendering a new one. One render takes that version as its first reference and changes only what you say here ("the CTA sits in the Stories band: move it up", "'Analitica' is missing its accent"), keeping the picture, layout and every other word. It is added on top of that version: its options, pick and earlier corrections are kept as they were made (free), the edit after them. Every size is made again from it (each other size re-laid out from it, one request each) and the review follows as usual. The version is the creative's last render, or --from <run_id>.`
2093
+ },
2094
+ from: {
2095
+ type: "string",
2096
+ description: "With --fix, --use-variant or a --regenerate of sizes only: the run id of the version (default: the one the creative shows, its last render here, or in a new chat the version chosen, else its newest)"
2097
+ },
2098
+ "use-variant": {
2099
+ type: "string",
2100
+ description: "Static ad only: the person asked in the chat for another of a version's variants over the judge's pick. Give its sha256 (the picture's, never the option's number): every size is made again from that picture, the judge's pick replaced. The only requests re-lay out each other size from that picture (one per size). The version is --from <run_id>, else the creative's last render."
2101
+ },
2102
+ autofix: {
2103
+ type: "boolean",
2104
+ default: true,
2105
+ description: `Static ad: when the review finds a blocking defect, the run corrects it itself before it reports (up to ${AUTO_FIX_ROUNDS} more renders: the chosen picture fixed, or only the size at fault laid out again). A logo the model drew that is still not the brand's after a correction (misspelt, redrawn, far from the file) is not drawn again: the brand's logo file is placed on every size of the ad instead, and src/brand/tokens.json records "logoPlacement": "composite" so the brand's next ads place it too (keep that key). --no-autofix reports after the first render.`
2106
+ },
2107
+ "skip-viewer-check": {
2108
+ type: "boolean",
2109
+ default: false,
2110
+ description: "Static ad only: render without the viewer check (see `baker canvas viewer-check`). Only when the person has heard what the viewer missed and asked for this copy as it is."
2111
+ },
2112
+ fresh: {
2113
+ type: "boolean",
2114
+ default: false,
2115
+ description: "Ignore any interrupted-run marker and start a new run id instead of resuming"
2116
+ },
2117
+ "cache-policy": { type: "string", description: "read_write | bypass | read_only" },
2118
+ regenerate: {
2119
+ type: "string",
2120
+ description: "Comma-separated node ids or roles to force fresh THIS run (e.g. --regenerate pick,adapt; on a static ad --regenerate static_variants, or its id gen, renders the variants again; on one cut from one picture --regenerate format_9x16 sets the 9:16's words again on the picture the last version shows, its --fix correction or chosen variant included; on one laid out again for each size --regenerate adapt_9x16 lays out the 9:16 again from that picture, and --regenerate static_adapt_format every re-laid-out size), bypassing the content cache for just those nodes + everything downstream. For a persistent re-render, bump a node's `regenerate` field in the canvas JSON instead."
2121
+ },
2122
+ concurrency: {
2123
+ type: "string",
2124
+ description: "Max nodes running at once (default 8; env BAKER_CANVAS_CONCURRENCY)"
2125
+ },
2126
+ parallel: {
2127
+ type: "string",
2128
+ description: "Alias for --concurrency: independent clips (and every other same-layer node) already fan out in parallel up to this bound"
2129
+ },
2130
+ // citty consumes any `--no-<flag>` as a negation of `<flag>`, so the
2131
+ // opt-out spelling `--no-record` requires the flag to be named `record`
2132
+ // (a literal "no-record" arg would never receive a value).
2133
+ record: {
2134
+ type: "boolean",
2135
+ default: true,
2136
+ description: "Post the durable run-history record to Baker (disable with --no-record)"
2137
+ },
2138
+ "cache-dir": { type: "string", description: `${OPERATOR} Cache root (default <workspace root>/canvas/.cache)` },
2139
+ "outputs-dir": { type: "string", description: `${OPERATOR} Per-run outputs root (default <workspace root>/canvas)` },
2140
+ "keep-runs": {
2141
+ type: "string",
2142
+ description: `${OPERATOR} After the run, prune old r_* run dirs, keeping the N newest (off by default)`
2143
+ },
2144
+ "remote-cache": {
2145
+ type: "string",
2146
+ description: `${OPERATOR} on | off: company-scoped remote cache + durable asset persistence (default on; env BAKER_CANVAS_REMOTE_CACHE)`
2147
+ }
2148
+ },
2149
+ async run({ args }) {
2150
+ if (args.series) {
2151
+ await executeSeriesRun(String(args.series));
2152
+ return;
2153
+ }
2154
+ const targets = canvasTargets({
2155
+ files: Array.isArray(args._) ? args._ : [],
2156
+ slug: args.slug ? String(args.slug) : void 0
2157
+ });
2158
+ const opts = {
2159
+ ...targets.length === 1 ? targets[0] : {},
2160
+ forceRemote: args["force-remote"] === true,
2161
+ cacheDir: args["cache-dir"] ? String(args["cache-dir"]) : void 0,
2162
+ outputsDir: args["outputs-dir"] ? String(args["outputs-dir"]) : void 0,
2163
+ runId: args["run-id"] ? String(args["run-id"]) : void 0,
2164
+ fresh: args.fresh === true,
2165
+ fix: args.fix ? String(args.fix) : void 0,
2166
+ from: args.from ? String(args.from) : void 0,
2167
+ useVariant: args["use-variant"] ? String(args["use-variant"]) : void 0,
2168
+ skipViewerCheck: args["skip-viewer-check"] === true,
2169
+ autoFix: args.autofix !== false,
2170
+ brief: args.brief ? String(args.brief) : void 0,
2171
+ until: args.until ? String(args.until) : void 0,
2172
+ cachePolicy: args["cache-policy"] ? String(args["cache-policy"]) : void 0,
2173
+ regenerate: args.regenerate !== void 0 ? String(args.regenerate) : void 0,
2174
+ // --concurrency wins; --parallel is the discoverable alias for the same bound.
2175
+ concurrency: (args.concurrency ?? args.parallel) !== void 0 ? String(args.concurrency ?? args.parallel) : void 0,
2176
+ keepRuns: args["keep-runs"] !== void 0 ? Number(args["keep-runs"]) : void 0,
2177
+ remoteCache: args["remote-cache"] !== void 0 ? String(args["remote-cache"]) !== "off" : void 0,
2178
+ record: args.record !== false,
2179
+ full: args.full === true
2180
+ };
2181
+ if (targets.length > 1) {
2182
+ await executeBatchRun(targets, opts);
2183
+ return;
2184
+ }
2185
+ await executeCanvasRun(opts);
2186
+ }
2187
+ });
2188
+ function stopBeforeKinds(until) {
2189
+ if (until?.trim() === "frames") return /* @__PURE__ */ new Set(["video_generate"]);
2190
+ return null;
2191
+ }
2192
+ function failPreflight(code, message, fix) {
2193
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { code, message, ...fix ? { fix } : {} } }, null, 2)}
2194
+ `);
2195
+ process.exit(2);
2196
+ }
2197
+ async function canvasFileFor(opts) {
2198
+ if (opts.file) return { canvasPath: path9.resolve(opts.file) };
2199
+ if (!opts.slug) failPreflight("missing_canvas", "Pass the canvas file, or --slug <slug> to run a creative by name.");
2200
+ const cwd = process.cwd();
2201
+ try {
2202
+ return await canvasForSlug(opts.slug, {
2203
+ workspaceRoot: findWorkspaceRoot(cwd) ?? cwd,
2204
+ forceRemote: opts.forceRemote === true,
2205
+ client: buildBackendClient,
2206
+ log: (line) => process.stdout.write(`${line}
2207
+ `)
2208
+ });
2209
+ } catch (e) {
2210
+ if (e instanceof SlugRestoreError) failPreflight(e.code, e.message, e.fix);
2211
+ throw e;
2212
+ }
2213
+ }
2214
+ async function executeSeriesRun(lead) {
2215
+ const root = findWorkspaceRoot(process.cwd()) ?? process.cwd();
2216
+ const members = await seriesMembers(root, lead);
2217
+ if (members.length === 0) {
2218
+ failPreflight(
2219
+ "no_series_ads",
2220
+ `No ad names "${lead}" as its lead (\`series: ${lead}\` in its _definition.md).`,
2221
+ `Make each other message as an ad of the series first (baker creatives make <idea> --series ${lead}), or each language (baker creatives translate --slug ${lead} --to es-MX,de).`
2222
+ );
2223
+ }
2224
+ const canvasRoot = path9.join(root, "canvas");
2225
+ process.stdout.write(`[series] rendering ${members.length} ads of ${lead} at once: ${members.join(", ")}
2226
+ `);
2227
+ const results = await runSeries(members, {
2228
+ plan: async (slug) => {
2229
+ const made = await writeSeriesMemberCanvas(root, slug, { takeLeadDesign: true });
2230
+ if (made === null) return { refused: { code: "not_in_series", message: `${slug} is no ad of this series.`, fix: "" } };
2231
+ if ("refused" in made) return made;
2232
+ if (made.designFromLead) process.stdout.write(`[series] ${slug} takes the lead's design, its own words kept
2233
+ `);
2234
+ try {
2235
+ const prepared = await prepareCanvas(made.canvasPath, { write: false });
2236
+ const state = await readRenderState(canvasRoot, slug);
2237
+ const { rendered } = canvasFreshness(state, slug, made.canvasPath);
2238
+ const fresh = rendered?.sourceSha === prepared.sourceSha && (state.blocking ?? []).length === 0;
2239
+ return fresh ? { run: false, runId: rendered?.runId } : { run: true };
2240
+ } catch (e) {
2241
+ const envelope = e instanceof CanvasPrepareError ? e.toEnvelope().error : null;
2242
+ return {
2243
+ refused: {
2244
+ code: String(envelope?.code ?? "prepare_failed"),
2245
+ message: String(envelope?.message ?? (e instanceof Error ? e.message : e)),
2246
+ fix: String(envelope?.fix ?? "")
2247
+ }
2248
+ };
2249
+ }
2250
+ },
2251
+ run: (slug) => runBaker(["canvas", "run", "--slug", slug])
2252
+ });
2253
+ process.stdout.write(`${JSON.stringify(seriesEnvelope(lead, results), null, 2)}
2254
+ `);
2255
+ }
2256
+ async function executeBatchRun(targets, opts) {
2257
+ const versionFlags = oneCanvasOnly(opts);
2258
+ if (versionFlags.length > 0) {
2259
+ failPreflight(
2260
+ "one_canvas_only",
2261
+ `${versionFlags.join(", ")} applies to one canvas run only, and ${targets.length} canvases were given.`,
2262
+ "Run that creative by itself (baker canvas run --slug <slug> \u2026), or drop the flag to render them all."
2263
+ );
2264
+ }
2265
+ process.stderr.write(
2266
+ `[canvases] rendering ${targets.length} canvases, up to ${CANVASES_AT_ONCE} at once: ${targets.map(targetLabel).join(", ")}
2267
+ `
2268
+ );
2269
+ const rows = await runCanvases(
2270
+ targets,
2271
+ (target) => runBaker(childRunArgs(target, opts), void 0, `[${targetLabel(target)}] `),
2272
+ CANVASES_AT_ONCE,
2273
+ { full: opts.full === true }
2274
+ );
2275
+ process.stdout.write(`${JSON.stringify(batchEnvelope(rows), null, 2)}
2276
+ `);
2277
+ }
2278
+ async function refreshSeriesAd(opts) {
2279
+ const slug = opts.slug ?? (opts.file ? creativeSlugFromCanvasPath(path9.resolve(opts.file)) : null);
2280
+ if (!slug) return false;
2281
+ const root = findWorkspaceRoot(opts.file ? path9.dirname(path9.resolve(opts.file)) : process.cwd());
2282
+ if (!root) return false;
2283
+ const made = await writeSeriesMemberCanvas(root, slug);
2284
+ if (made === null) return false;
2285
+ if ("refused" in made) failPreflight(made.refused.code, made.refused.message, made.refused.fix);
2286
+ process.stdout.write(
2287
+ `[series] ${slug} is the lead ${made.lead}'s version ${made.leadRunId} with this ad's words${made.written ? " (canvas written)" : ""}
2288
+ `
2289
+ );
2290
+ return made.newLeadVersion;
2291
+ }
2292
+ async function editScopeNotes(input) {
2293
+ const { opts, shown } = input;
2294
+ const plain = (opts.autoFixRound ?? 0) === 0 && opts.fix === void 0 && opts.regenerate === void 0 && opts.useVariant === void 0 && opts.from === void 0;
2295
+ if (!plain || !shown.rendered) return [];
2296
+ const notes = [];
2297
+ const changed = !input.native && input.asEdit === null && shown.prompt ? frameChanges(shown.prompt, input.promptNow) : [];
2298
+ if (changed.length > 0) {
2299
+ notes.push(
2300
+ `[scope] this run changes ${changed.join(", ")} since the version shown: new pictures are made. If the person asked only for words, colours or one element, put the rest back (or use --fix).`
2301
+ );
2302
+ }
2303
+ const local = { record: async () => null, graph: async () => null };
2304
+ const previous = await versionRun(input.canvasRoot, shown.rendered.runId, local);
2305
+ for (const clip of previous ? retakenTalkingScenes(previous.canvas, input.canvas) : []) {
2306
+ notes.push(
2307
+ `[voice] the take ${clip} is said again by the video model: it may not sound like the other takes; listen to it before you show it.`
2308
+ );
2309
+ }
2310
+ return notes;
2311
+ }
2312
+ async function reasonsOfSpec(canvasRoot, slug, here, sourceSha) {
2313
+ if (spentReasons(here, sourceSha).length > 0) return here;
2314
+ const kept = await specRenders(slug, sourceSha);
2315
+ if (!kept) return here;
2316
+ const merged = withDurableRenders(here, sourceSha, kept);
2317
+ const known = here?.sourceSha === sourceSha ? here.runs.length : 0;
2318
+ if (merged.runs.length === known) return here;
2319
+ await recordReasons(canvasRoot, slug, merged);
2320
+ return merged;
2321
+ }
2322
+ var canvasHeld = false;
2323
+ var RECORDED_RULE_IDS = 100;
2324
+ async function executeCanvasRun(opts) {
2325
+ await runRenderChain(opts, canvasRunRound);
2326
+ }
2327
+ async function canvasRunRound(opts) {
2328
+ const startedAt = opts.autoFixStartedAt ?? Date.now();
2329
+ const newAsk = (opts.autoFixRound ?? 0) === 0 ? await refreshSeriesAd(opts) : false;
2330
+ const { canvasPath: filePath, adoptRunId } = await canvasFileFor(opts);
2331
+ const canvasRoot = canvasOutputsRoot(filePath);
2332
+ const creativeSlug = creativeSlugFromCanvasPath(filePath) ?? void 0;
2333
+ const held = creativeSlug ? await heldRules(path9.dirname(filePath)) : { rules: [] };
2334
+ if (creativeSlug) await clearLegacyDirtyMarker(canvasRoot, creativeSlug);
2335
+ const turnId = optionalTurnId();
2336
+ const turnCache = opts.cacheDir ?? path9.join(canvasRoot, ".cache");
2337
+ const refusal = creativeSlug && (opts.autoFixRound ?? 0) === 0 ? turnRenderRefusal(await readTurnRenders(turnCache), turnId, creativeSlug) : null;
2338
+ if (refusal) {
2339
+ process.stderr.write(
2340
+ `${JSON.stringify({ ok: false, error: refusal }, null, 2)}
2341
+ `
2342
+ );
2343
+ process.exit(2);
2344
+ }
2345
+ const shown = creativeSlug ? await shownVersion(canvasRoot, creativeSlug) : {};
2346
+ const promptOnDisk = await readFile7(path9.join(path9.dirname(filePath), "prompt.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
2347
+ const promptEdited = mayBeCorrection({}, shown.prompt, promptOnDisk);
2348
+ const ideaHeld = creativeSlug && (opts.autoFixRound ?? 0) === 0 ? (await shownBaseline({
2349
+ canvasRoot,
2350
+ slug: creativeSlug,
2351
+ creativeDir: path9.dirname(filePath),
2352
+ turnId,
2353
+ shown,
2354
+ record: true
2355
+ })).baseline : void 0;
2356
+ const citing = [];
2357
+ await wireProofBadges(
2358
+ path9.join(path9.dirname(filePath), "prompt.json"),
2359
+ fetchBrandLogo,
2360
+ (line) => process.stderr.write(`${line}
2361
+ `),
2362
+ jevCitationJudge((u) => citing.push(u))
2363
+ );
2364
+ await holdUnbilledSpend(turnCache, citing);
2365
+ if ((opts.autoFixRound ?? 0) === 0) {
2366
+ const reading = [];
2367
+ await wireNamedPeople(
2368
+ path9.join(path9.dirname(filePath), "prompt.json"),
2369
+ avatarOfNamedPerson,
2370
+ (line) => process.stderr.write(`${line}
2371
+ `),
2372
+ peopleReader(turnCache, (u) => reading.push(u))
2373
+ );
2374
+ await holdUnbilledSpend(turnCache, reading);
2375
+ }
2376
+ let prepared;
2377
+ try {
2378
+ prepared = await prepareCanvas(filePath, {
2379
+ requireSuppliedAssets: true,
2380
+ gate: true,
2381
+ log: (line) => process.stderr.write(`${line}
2382
+ `),
2383
+ ...ideaHeld ? { baseline: ideaHeld } : {},
2384
+ firstRender: creativeSlug !== void 0 && !shown.rendered && (opts.autoFixRound ?? 0) === 0,
2385
+ // The same refusal of this ad met on two edited versions in this turn lets the next attempt through (`check-policy.ts`).
2386
+ ...creativeSlug ? { breaker: turnRefusals(turnCache, turnId, creativeSlug) } : {}
2387
+ });
2388
+ } catch (e) {
2389
+ if (creativeSlug) await recordRenderAttempt(canvasRoot, creativeSlug, await computeSourceSha(filePath), filePath);
2390
+ exitOnPrepareError(e);
2391
+ }
2392
+ if (creativeSlug) await recordRenderAttempt(canvasRoot, creativeSlug, prepared.sourceSha, filePath);
2393
+ if (prepared.rewrites.length > 0) {
2394
+ process.stderr.write(
2395
+ `[canvas] rewrote ${prepared.rewrites.length} asset reference(s) in the canvas file so it says what runs (absolute paths \u2192 canvas-relative, a URL in an ingest path \u2192 source "url", a path into canvas/ \u2192 the durable URL of the same bytes):
2396
+ ${describeRewrites(prepared.rewrites)}
2397
+ `
2398
+ );
2399
+ }
2400
+ let parsed = prepared.canvas;
2401
+ const promptNow = isStaticAdCanvas(parsed) ? await readStaticPromptJson(parsed).catch(() => null) : null;
2402
+ const native = isNativeCanvas(parsed);
2403
+ if (native && (opts.fix !== void 0 || opts.useVariant !== void 0)) {
2404
+ process.stderr.write(
2405
+ `${JSON.stringify(
2406
+ {
2407
+ ok: false,
2408
+ error: {
2409
+ code: "nothing_to_fix",
2410
+ message: "This ad is a native screen drawn exactly from prompt.json, not a painted picture: there is nothing to correct by --fix or to pick by --use-variant.",
2411
+ fix: "Edit prompt.json's `native` block (its words, people, photos, frame) and run again: nothing renders but a photo whose description changed. A photo with a defect: `--regenerate photo_<n>`."
2412
+ }
2413
+ },
2414
+ null,
2415
+ 2
2416
+ )}
2417
+ `
2418
+ );
2419
+ process.exit(2);
2420
+ }
2421
+ const asEdit = opts.fix === void 0 && opts.useVariant === void 0 && opts.regenerate === void 0 && opts.from === void 0 && shown.rendered ? plainRunEdit(parsed, shown.prompt, promptNow) : null;
2422
+ const editOf = asEdit && shown.rendered ? await previousAdImage(canvasRoot, shown.rendered.runId, void 0, { ...rolesById(parsed), ...relaidPictureRole(parsed) }) : null;
2423
+ const editInstruction = editOf ? asEdit : null;
2424
+ if (editInstruction) {
2425
+ process.stdout.write(`[edit] only the words or colours changed: editing the version of run ${shown.rendered?.runId}: ${editInstruction}
2426
+ `);
2427
+ }
2428
+ const runNotes = await editScopeNotes({
2429
+ opts,
2430
+ asEdit,
2431
+ native,
2432
+ shown,
2433
+ promptNow,
2434
+ canvas: parsed,
2435
+ canvasRoot
2436
+ });
2437
+ for (const note of runNotes) process.stderr.write(`${note}
2438
+ `);
2439
+ const fixInstruction = opts.fix ?? editInstruction ?? void 0;
2440
+ const requested = opts.regenerate?.split(",").map((id) => id.trim()) ?? [];
2441
+ const plainKeep = opts.fix === void 0 && opts.useVariant === void 0 && requested.length === 0 && !promptEdited;
2442
+ const fromRun = opts.from ?? shown.rendered?.runId;
2443
+ const memory = fixMemoryOf(shown, opts.from);
2444
+ if (opts.fix !== void 0 && repeatsFailedFix(memory.lastFix, opts.fix)) {
2445
+ const left = memory.lastFix?.blocking ?? [];
2446
+ process.stderr.write(
2447
+ `${JSON.stringify(
2448
+ {
2449
+ ok: false,
2450
+ error: {
2451
+ code: "no_progress",
2452
+ message: `Not rendered: this exact fix already ran and left ${left.length === 1 ? "this" : "these"} in place: ${left.join(" | ")}`,
2453
+ fix: `Do not ask for the same correction again. Change the approach: edit prompt.json so the problem cannot happen (shorter words, a line moved or dropped, a different position), make just the size at fault again (${oneSizeFix(sizeShapeOf(parsed))}), or ask for new options with \`--regenerate static_variants\`.`
2454
+ }
2455
+ },
2456
+ null,
2457
+ 2
2458
+ )}
2459
+ `
2460
+ );
2461
+ process.exit(2);
2462
+ }
2463
+ const remadeAlready = (opts.autoFixRound ?? 0) === 0 && opts.fix === void 0 && opts.useVariant === void 0 ? repeatsFailedRemake(shown, requested, { from: opts.from, sourceSha: prepared.sourceSha }) : [];
2464
+ if (remadeAlready.length > 0) {
2465
+ const again = `--regenerate ${requested.join(",")}`;
2466
+ const variants = requested.includes(STATIC_VARIANTS_ROLE) || requested.includes("gen");
2467
+ process.stderr.write(
2468
+ `${JSON.stringify(
2469
+ {
2470
+ ok: false,
2471
+ error: {
2472
+ code: "no_progress",
2473
+ message: `Not rendered: \`${again}\` already ran on this version with prompt.json as it is now, and left ${remadeAlready.length === 1 ? "this" : "these"} as ${remadeAlready.length === 1 ? "it was" : "they were"}: ${remadeAlready.join(" | ")}`,
2474
+ fix: `Do not make the same part again from the same prompt.json: it comes back with the same problems. Change the approach: edit prompt.json so the problem cannot happen (shorter words, a line moved or dropped, a different position), or correct this version with \`--fix "<what to change>"\`${variants ? "" : ", or ask for new options with `--regenerate static_variants`"}.`
2475
+ }
2476
+ },
2477
+ null,
2478
+ 2
2479
+ )}
2480
+ `
2481
+ );
2482
+ process.exit(2);
2483
+ }
2484
+ const reasons = (opts.autoFixRound ?? 0) === 0 && creativeSlug && prepared.sourceSha && isStaticAdCanvas(parsed) ? await reasonsOfSpec(canvasRoot, creativeSlug, shown.reasons, prepared.sourceSha) : shown.reasons;
2485
+ const recovering = opts.runId !== void 0 && fixInstruction === void 0 && opts.regenerate === void 0 && opts.useVariant === void 0 && opts.from === void 0 && opts.fresh !== true && reasons?.sourceSha === prepared.sourceSha && (reasons?.runs ?? []).some((r) => r.runId === opts.runId);
2486
+ const spent = (opts.autoFixRound ?? 0) === 0 && !recovering ? spentReasons(reasons, prepared.sourceSha) : [];
2487
+ if (spent.length > 0) {
2488
+ process.stderr.write(
2489
+ `${JSON.stringify(
2490
+ {
2491
+ ok: false,
2492
+ error: {
2493
+ code: "no_progress",
2494
+ message: `Not rendered: ${RENDERS_PER_REASON} renders of this ad, with prompt.json and the canvas as they are now, already ended with ${spent.length === 1 ? "this problem" : "these problems"}: ${spent.join(" | ")}`,
2495
+ fix: `Another render of the same spec pays again for ${spent.length === 1 ? "it" : "them"}, whatever the retry (\`--fix\`, \`--regenerate\`, a plain run). Change the spec in prompt.json so ${spent.length === 1 ? "it" : "they"} cannot happen: shorter words, a line moved or dropped, a different position, a size left out of \`formats\`, or less of the reference kept (\`concept.carry\`); then run again. If nothing in the spec can change it, stop and show the person the best version, saying in one plain sentence what is left.`
2496
+ }
2497
+ },
2498
+ null,
2499
+ 2
2500
+ )}
2501
+ `
2502
+ );
2503
+ process.exit(2);
2504
+ }
2505
+ const dropped = (opts.autoFixRound ?? 0) === 0 && !native ? droppedKeeps(shown.prompt, promptNow) : [];
2506
+ if (dropped.length > 0) {
2507
+ const said = dropped.map((d) => `"${d.element}" still names ${d.words.map((w) => `"${w}"`).join(", ")}`);
2508
+ process.stderr.write(
2509
+ `${JSON.stringify(
2510
+ {
2511
+ ok: false,
2512
+ error: {
2513
+ code: "concept_does_not_fit",
2514
+ message: `Not rendered: the copy no longer has words prompt.json's plan keeps as essential (${said.join("; ")}). The review would ask for them and every correction would draw them back.`,
2515
+ fix: `Update prompt.json's \`concept.load_bearing\` ${dropped.map((d) => `"${d.element}"`).join(", ")}: rewrite its \`ours\` to what of the ad now carries it, the words unchanged in \`element\`, or put the words back in the copy. Then run again.`
2516
+ }
2517
+ },
2518
+ null,
2519
+ 2
2520
+ )}
2521
+ `
2522
+ );
2523
+ process.exit(2);
2524
+ }
2525
+ const remakeOutcome = creativeSlug && (opts.autoFixRound ?? 0) === 0 && isStaticAdCanvas(parsed) ? {
2526
+ lastRemake: requested.length > 0 && opts.fix === void 0 && opts.useVariant === void 0 ? { regenerate: [...requested].sort(), before: memory.blocking } : void 0
2527
+ } : null;
2528
+ let grown = null;
2529
+ const growOn = async (from, growth) => {
2530
+ const version = await versionRun(canvasRoot, from);
2531
+ return version ? growFromVersion(parsed, version, growth) : null;
2532
+ };
2533
+ if (fixInstruction !== void 0) {
2534
+ const instruction = fixInstruction.trim();
2535
+ const from = opts.from ?? shown.rendered?.runId;
2536
+ const previous = editOf ?? (from ? await previousAdImage(canvasRoot, from, void 0, { ...rolesById(parsed), ...relaidPictureRole(parsed) }) : null);
2537
+ if (!instruction || !isStaticAdCanvas(parsed) || !from || !previous) {
2538
+ const message = !instruction ? "--fix needs the correction in words." : !isStaticAdCanvas(parsed) ? "--fix corrects a static ad; this canvas is not one." : !from ? "--fix needs a version to correct: this creative has no recorded render here. Pass --from <run_id>." : `--fix could not find the finished ad of run ${from}.`;
2539
+ const shownRun = shown.rendered?.runId;
2540
+ const fix = instruction && isStaticAdCanvas(parsed) && from ? shownRun && shownRun !== from ? `Correct the version the creative shows: \`baker canvas run --slug ${creativeSlug ?? "<slug>"} --from ${shownRun} --fix "<what to change>"\`.` : `Show the ad as it stands, as a version ("Version 3"), and name in one plain sentence the defect left in it: it is corrected with the person's next message.` : void 0;
2541
+ process.stderr.write(
2542
+ `${JSON.stringify({ ok: false, error: { code: "nothing_to_fix", message, ...fix ? { fix } : {} } }, null, 2)}
2543
+ `
2544
+ );
2545
+ process.exit(2);
2546
+ }
2547
+ const { rules } = held;
2548
+ const corrected = await correctedGraph({
2549
+ canvas: parsed,
2550
+ canvasRoot,
2551
+ from,
2552
+ previous,
2553
+ instruction,
2554
+ promptNow,
2555
+ rules,
2556
+ ...opts.relayAlso ? { relayAlso: opts.relayAlso } : {},
2557
+ ...opts.keepSizes ? { keepSizes: opts.keepSizes } : {},
2558
+ log: (line) => process.stdout.write(`${line}
2559
+ `)
2560
+ });
2561
+ if (!corrected) refusePlateVersion(from);
2562
+ grown = corrected.grown;
2563
+ parsed = corrected.canvas;
2564
+ if (!editInstruction) process.stdout.write(`[fix] correcting the version of run ${from}: ${instruction}
2565
+ `);
2566
+ }
2567
+ if (opts.useVariant !== void 0 && opts.fix === void 0) {
2568
+ const sha = opts.useVariant.trim();
2569
+ const from = opts.from ?? shown.rendered?.runId;
2570
+ grown = from && isStaticAdCanvas(parsed) ? await growOn(from, { kind: "variant", sha256: sha }) : null;
2571
+ const url = from && !grown && isStaticAdCanvas(parsed) ? await variantImage(canvasRoot, from, sha, void 0, rolesById(parsed)) : null;
2572
+ if (!from || !grown && !url) {
2573
+ const message = !isStaticAdCanvas(parsed) ? "--use-variant re-makes the sizes of a static ad; this canvas is not one." : !from ? "--use-variant needs the version the variant belongs to: this creative has no recorded render here. Pass --from <run_id>." : `--use-variant found no variant ${sha} in run ${from}: pass the sha256 of one of that version's variants (never the option's number), and --from with that version's run.`;
2574
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { code: "no_such_variant", message } }, null, 2)}
2575
+ `);
2576
+ process.exit(2);
2577
+ }
2578
+ if (!grown && isPlateCanvas(parsed)) refusePlateVersion(from);
2579
+ if (grown) parsed = grown.canvas;
2580
+ else if (url) parsed = rederiveFromVariant(parsed, { url });
2581
+ process.stdout.write(`[variant] making every size of run ${from} again from the chosen variant ${sha.slice(0, 12)}
2582
+ `);
2583
+ }
2584
+ let relaidFrom;
2585
+ if (opts.regenerate !== void 0 && opts.fix === void 0 && opts.useVariant === void 0 && isStaticAdCanvas(parsed)) {
2586
+ const requested2 = opts.regenerate.split(",").map((id) => id.trim());
2587
+ const from = opts.from ?? shown.rendered?.runId;
2588
+ const sizesOnly = relaysSizesOnly(parsed, regenerateTargets(parsed, requested2).ids);
2589
+ grown = from && sizesOnly ? await growOn(from, { kind: "keep" }) : null;
2590
+ const url = from && sizesOnly && !grown ? await correctedPicture(canvasRoot, from) ?? (shown.picture?.redrawn && shown.picture.runId === from ? await previousAdImage(canvasRoot, from, void 0, { ...rolesById(parsed), ...relaidPictureRole(parsed) }) : null) : null;
2591
+ if (from && grown) {
2592
+ parsed = grown.canvas;
2593
+ relaidFrom = from;
2594
+ process.stdout.write(`[regenerate] re-laying out from the picture run ${from} shows, kept as it was made
2595
+ `);
2596
+ } else if (from && url && !isPlateCanvas(parsed)) {
2597
+ parsed = rederiveFromVariant(parsed, { url });
2598
+ relaidFrom = from;
2599
+ process.stdout.write(`[regenerate] re-laying out from the picture run ${from} shows (its correction or the person's choice)
2600
+ `);
2601
+ }
2602
+ }
2603
+ const plain = fixInstruction === void 0 && opts.useVariant === void 0 && opts.regenerate === void 0 && (opts.extendSizes?.length ?? 0) === 0;
2604
+ if (plain && fromRun && !native && isStaticAdCanvas(parsed) && !seriesOf(parsed)) {
2605
+ grown = await keptPictureGraph({
2606
+ canvas: parsed,
2607
+ canvasRoot,
2608
+ creativeDir: path9.dirname(filePath),
2609
+ fromRun,
2610
+ shownPrompt: shown.prompt,
2611
+ promptNow
2612
+ });
2613
+ if (grown) {
2614
+ parsed = grown.canvas;
2615
+ relaidFrom = fromRun;
2616
+ process.stdout.write(`[version] nothing the variants are made from changed: keeping the picture of run ${fromRun}
2617
+ `);
2618
+ }
2619
+ }
2620
+ if (plain && plainKeep && !grown && fromRun && !native && isStaticAdCanvas(parsed) && !seriesOf(parsed)) {
2621
+ grown = await keptPictureForSizes({
2622
+ canvas: parsed,
2623
+ canvasRoot,
2624
+ creativeDir: path9.dirname(filePath),
2625
+ fromRun,
2626
+ promptNow,
2627
+ rules: held.rules
2628
+ });
2629
+ if (grown) {
2630
+ parsed = grown.canvas;
2631
+ relaidFrom = fromRun;
2632
+ process.stdout.write(`[version] only the sizes added changed: keeping the picture of run ${fromRun}
2633
+ `);
2634
+ }
2635
+ }
2636
+ if (grown) {
2637
+ const kept = Object.keys(grown.pinned);
2638
+ process.stdout.write(`[version] built on top of the version before: ${kept.join(", ")} kept as they were made (free)
2639
+ `);
2640
+ }
2641
+ const canvasText = prepared.text;
2642
+ let regenerate;
2643
+ if (opts.regenerate !== void 0) {
2644
+ const requested2 = opts.regenerate.split(",").map((id) => id.trim()).filter((id) => id.length > 0);
2645
+ const known = new Set(canvasNodeIds(parsed));
2646
+ const { ids: resolved, unknown } = regenerateTargets(parsed, requested2);
2647
+ if (unknown.length > 0) {
2648
+ process.stderr.write(
2649
+ `${JSON.stringify(
2650
+ {
2651
+ ok: false,
2652
+ error: {
2653
+ code: "unknown_regenerate_node",
2654
+ message: `--regenerate names node id(s) not in this canvas: ${unknown.join(", ")}. Known ids: ${[...known].join(", ")}`
2655
+ }
2656
+ },
2657
+ null,
2658
+ 2
2659
+ )}
2660
+ `
2661
+ );
2662
+ process.exit(2);
2663
+ }
2664
+ if (resolved.length > 0) {
2665
+ regenerate = new Set(resolved);
2666
+ process.stdout.write(`[regenerate] forcing fresh this run: ${[...regenerate].join(", ")} (+ downstream)
2667
+ `);
2668
+ if (opts.relayNote) parsed = withRelayNote(parsed, resolved, opts.relayNote);
2669
+ const editFrom = opts.from ?? shown.rendered?.runId;
2670
+ if (opts.relayEdits && editFrom) {
2671
+ const labels = finalOutputLabelsFromCanvas(parsed);
2672
+ const delivered = await previousDelivered(canvasRoot, editFrom, labels?.nodeId ?? "final", labels?.labels ?? [], {
2673
+ prefer: "url"
2674
+ });
2675
+ for (const [id, instruction] of Object.entries(opts.relayEdits)) {
2676
+ if (!resolved.includes(id)) continue;
2677
+ const last = delivered.find((d) => d.format === formatOfSizeNode(parsed, id))?.path;
2678
+ const plan = opts.relayPlans?.[id];
2679
+ parsed = plan ? withPlannedRelay(parsed, id, plan) : last ? withRelayEdit(parsed, id, { previous: last, instruction, asked: opts.relayAsked?.[id] ?? [] }) : withRelayNote(parsed, [id], instruction);
2680
+ }
2681
+ const relaid = resolved.flatMap((id) => formatOfSizeNode(parsed, id) ?? []);
2682
+ parsed = withDeliveredSizes(
2683
+ parsed,
2684
+ Object.fromEntries(delivered.filter((d) => !relaid.includes(d.format)).map((d) => [d.format, d.path]))
2685
+ );
2686
+ }
2687
+ }
2688
+ }
2689
+ if (opts.extendSizes && opts.extendSizes.length > 0 && isStaticAdCanvas(parsed)) {
2690
+ const from = opts.from ?? shown.rendered?.runId;
2691
+ if (opts.extendOnly && from) {
2692
+ const labels = finalOutputLabelsFromCanvas(parsed);
2693
+ const delivered = await previousDelivered(canvasRoot, from, labels?.nodeId ?? "final", labels?.labels ?? [], {
2694
+ prefer: "url"
2695
+ });
2696
+ parsed = withDeliveredSizes(parsed, Object.fromEntries(delivered.map((d) => [d.format, d.path])));
2697
+ }
2698
+ parsed = withExtendedSizes(parsed, opts.extendSizes);
2699
+ process.stdout.write(`[extend] placing ${opts.extendSizes.join(", ")} clear of what covers or cuts it, its margins painted
2700
+ `);
2701
+ }
2702
+ const cacheDir = opts.cacheDir ?? path9.join(canvasRoot, ".cache");
2703
+ const engine = createEngineFromEnv({
2704
+ cacheDir,
2705
+ outputsDir: opts.outputsDir ?? canvasRoot,
2706
+ log: (line) => process.stdout.write(`${line}
2707
+ `),
2708
+ remoteCache: opts.remoteCache
2709
+ });
2710
+ const validation = await engine.validateDeep(parsed);
2711
+ if (!validation.ok) {
2712
+ process.stderr.write(
2713
+ `${JSON.stringify({ ok: false, error: { code: "validation", issues: validation.issues } }, null, 2)}
2714
+ `
2715
+ );
2716
+ process.exit(2);
2717
+ }
2718
+ for (const w of await outputRatioWarningsFor(parsed, filePath)) {
2719
+ process.stdout.write(`[warn] ${w.code}: ${w.message}
2720
+ `);
2721
+ }
2722
+ const canvasSha = sha256Hex(Buffer.from(canvasText));
2723
+ const sourceSha = prepared.sourceSha;
2724
+ const client = opts.record === false ? null : buildBackendClient();
2725
+ const outputsDir = opts.outputsDir ? path9.resolve(opts.outputsDir) : canvasRoot;
2726
+ const { runId, resumed, source, sameSource, concurrentRunId, rendering } = await resolveRunId({
2727
+ explicitRunId: opts.runId,
2728
+ adoptedRunId: adoptRunId,
2729
+ fresh: opts.fresh === true || fixInstruction !== void 0 || opts.useVariant !== void 0 || relaidFrom !== void 0,
2730
+ outputsDir,
2731
+ canvasPath: filePath,
2732
+ sourceSha,
2733
+ remote: client && creativeSlug && sourceSha ? { creativeSlug, sourceSha, getActiveRun: (slug, sha) => client.getActiveRun(slug, sha) } : void 0
2734
+ });
2735
+ const holder = rendering ?? await canvasBusyElsewhere(outputsDir, filePath);
2736
+ if (holder) {
2737
+ process.stderr.write(
2738
+ `${JSON.stringify(
2739
+ {
2740
+ ok: false,
2741
+ error: {
2742
+ code: "CONFLICT",
2743
+ message: `This canvas is already rendering in another process (run ${holder.runId}, pid ${holder.pid}).`,
2744
+ fix: "Wait for that render to finish and use its result instead of starting a second one: two renders of one canvas share a run and overwrite each other. If you started it in the background, read its output when it completes."
2745
+ }
2746
+ },
2747
+ null,
2748
+ 2
2749
+ )}
2750
+ `
2751
+ );
2752
+ process.exit(2);
2753
+ }
2754
+ const viewerUsage = [];
2755
+ const viewerCheck = creativeSlug && isStaticAdCanvas(parsed) ? await viewerCheckBeforeRender({
2756
+ creativeDir: path9.dirname(filePath),
2757
+ cacheDir,
2758
+ slug: creativeSlug,
2759
+ skip: viewerCheckSkip({
2760
+ fix: opts.fix !== void 0,
2761
+ useVariant: opts.useVariant !== void 0,
2762
+ relaid: relaidFrom !== void 0,
2763
+ autoFixRound: opts.autoFixRound ?? 0,
2764
+ resumed: resumed && sameSource === true,
2765
+ asked: opts.skipViewerCheck === true
2766
+ }),
2767
+ spent: viewerChecksSpent(await readTurnRenders(turnCache), turnId, creativeSlug),
2768
+ lookups: liveViewerLookups(path9.dirname(canvasRoot)),
2769
+ model: VIEWER_CHECK_MODEL,
2770
+ ask: gatewayViewerModel(VIEWER_CHECK_MODEL, (usage) => viewerUsage.push(usage)),
2771
+ judge: jevReadJudge((usage) => viewerUsage.push(usage))
2772
+ }) : null;
2773
+ for (const line of viewerCheck?.lines ?? []) process.stdout.write(`${line}
2774
+ `);
2775
+ await holdUnbilledSpend(cacheDir, viewerUsage);
2776
+ if (viewerCheck?.failure) {
2777
+ if (creativeSlug && turnId && viewerCheck.failure.error.code === "viewer_check_failed") {
2778
+ await updateTurnRenders(turnCache, (ledger) => recordViewerFail(ledger, turnId, creativeSlug));
2779
+ }
2780
+ process.stderr.write(`${JSON.stringify(viewerCheck.failure, null, 2)}
2781
+ `);
2782
+ process.exit(2);
2783
+ }
2784
+ if (resumed) {
2785
+ process.stdout.write(
2786
+ `[resume] continuing interrupted run ${runId}${source === "remote" ? " (adopted from run history)" : ""} \u2014 in-flight jobs re-attach, cached nodes skip
2787
+ `
2788
+ );
2789
+ }
2790
+ if (concurrentRunId) {
2791
+ process.stderr.write(
2792
+ `[concurrent] this canvas appears to be running elsewhere right now (run ${concurrentRunId}) \u2014 starting a separate run; pass --run-id ${concurrentRunId} to adopt it instead
2793
+ `
2794
+ );
2795
+ }
2796
+ const abort = new AbortController();
2797
+ let abortedBy = null;
2798
+ for (const signalName of ["SIGINT", "SIGTERM"]) {
2799
+ process.once(signalName, () => {
2800
+ abortedBy = signalName;
2801
+ process.stderr.write(`[interrupt] ${signalName} received \u2014 flushing a resumable snapshot (repeat to force-quit)
2802
+ `);
2803
+ abort.abort(new Error(`aborted by ${signalName}`));
2804
+ });
2805
+ }
2806
+ const inFlight = await markRunInFlight(outputsDir, filePath, runId, sourceSha);
2807
+ if (!canvasHeld) {
2808
+ const held2 = await markCanvasBusy(outputsDir, filePath, runId);
2809
+ canvasHeld = true;
2810
+ process.once("exit", held2.release);
2811
+ }
2812
+ const clearMarker = () => {
2813
+ inFlight.stop();
2814
+ return clearRunMarker(outputsDir, filePath, inFlight.token);
2815
+ };
2816
+ const snapshot = client && creativeSlug ? await uploadRunSnapshot(client, {
2817
+ canvasPath: filePath,
2818
+ raw: canvasText,
2819
+ creativeSlug,
2820
+ parsed,
2821
+ previous: (await readRenderState(canvasRoot, creativeSlug)).snapshot
2822
+ }) : null;
2823
+ if (snapshot && creativeSlug) await recordSnapshot(canvasRoot, creativeSlug, snapshot);
2824
+ const graphUrl = client && creativeSlug && isStaticAdCanvas(parsed) ? await uploadRunGraph(client, parsed) : null;
2825
+ const recordMeta = {
2826
+ creativeSlug,
2827
+ canvasPath: path9.relative(path9.dirname(canvasRoot), filePath) || void 0,
2828
+ canvasSha,
2829
+ // The fingerprint the dashboard compares against the current source to flag
2830
+ // "edited since last render": the same `computeSourceSha` the edit-sync posts,
2831
+ // taken after the preflight wrote the projected graph, so the two are comparable.
2832
+ sourceSha,
2833
+ chatId: optionalChatId(),
2834
+ canvasSnapshotUrl: snapshot?.url,
2835
+ ...graphUrl ? { graphUrl } : {},
2836
+ ...newAsk ? { newAsk: true } : {},
2837
+ ...creativeSlug ? { rules: { digest: rulesDigest(held.rules), ids: held.rules.slice(0, RECORDED_RULE_IDS).map((r) => r.id) } } : {}
2838
+ };
2839
+ if (client) {
2840
+ const registered = await postInitialRunRecord(client, buildInitialRunRecord(runId, recordMeta));
2841
+ if (!registered) {
2842
+ process.stderr.write(
2843
+ "[warn] run start not registered \u2014 this run stays invisible to the dashboard until a later progress post lands, and cannot be resumed from another workspace\n"
2844
+ );
2845
+ }
2846
+ }
2847
+ const leadRun = seriesOf(parsed)?.run_id;
2848
+ if (creativeSlug && leadRun) await recordSeriesLeadRun(canvasRoot, creativeSlug, leadRun);
2849
+ const record = client ? (payload) => client.recordRun(payload) : null;
2850
+ const finalLabels = finalOutputLabelsFromCanvas(parsed) ?? void 0;
2851
+ const progress = record ? new RunProgressTracker(runId, recordMeta, finalLabels) : null;
2852
+ const poster = record ? new RunRecordPoster(record) : null;
2853
+ const flushBilled = async (p, payload) => {
2854
+ const failure = await sendBillingSpend(cacheDir, payload.reviewUsage ?? [], () => p.flush(payload));
2855
+ if (failure !== null) process.stderr.write(`[warn] run record not persisted (${failure})
2856
+ `);
2857
+ return failure;
2858
+ };
2859
+ if (progress && poster) {
2860
+ poster.startKeepalive(() => progress.hasPlan() ? progress.snapshot() : null);
2861
+ }
2862
+ const frameUrls = [];
2863
+ let next = null;
2864
+ let cached = false;
2865
+ let recordRender = (_cached) => Promise.resolve();
2866
+ const madeHere = grown ? madeThisRun({ canvas: parsed, pinned: grown.pinned }) : parsed;
2867
+ const readerSpend = holdWhenSettled(cacheDir, (run, outputs) => prefilterSpend(madeHere, { [run.node_id]: outputs }, [run]));
2868
+ const isFrameNode = (id) => parsed.nodes?.find((n) => n.id === id)?.type === "image_generate";
2869
+ try {
2870
+ const policy = opts.cachePolicy ?? "read_write";
2871
+ const result = await engine.run(parsed, {
2872
+ run_id: runId,
2873
+ signal: abort.signal,
2874
+ cache_policy: policy,
2875
+ ...stopBeforeKinds(opts.until) ? { stop_before_kinds: stopBeforeKinds(opts.until) } : {},
2876
+ concurrency: resolveConcurrency(opts.concurrency, process.env.BAKER_CANVAS_CONCURRENCY),
2877
+ regenerate,
2878
+ ...client ? { has_credits: () => client.hasCredits(abort.signal) } : {},
2879
+ ...grown ? { pinned: grown.pinned } : {},
2880
+ // A creative's render record says whether this is its first render, which no cache read can.
2881
+ ...creativeSlug ? { rendered_before: shown.rendered !== void 0 } : {},
2882
+ review_credits: staticReviewCredits(parsed),
2883
+ // Always set, because the frame collector has to run whether or not this run is
2884
+ // reporting progress to a backend — without it a checkpoint stops with nothing to
2885
+ // show, which is the only thing a checkpoint is for.
2886
+ onProgress: (event) => {
2887
+ if (event.kind === "node_settled") readerSpend.settled(event.run, event.outputs);
2888
+ if (event.kind === "node_settled" && isFrameNode(event.run.node_id)) {
2889
+ for (const out of Object.values(event.outputs ?? {})) {
2890
+ const url = out?.url;
2891
+ if (url) frameUrls.push(url);
2892
+ }
2893
+ }
2894
+ if (progress && poster) {
2895
+ progress.apply(event);
2896
+ if (progress.hasPlan()) poster.enqueue(progress.snapshot());
2897
+ }
2898
+ }
2899
+ });
2900
+ cached = result.node_runs.every((r) => r.cached);
2901
+ await clearMarker();
2902
+ const beforeRunId = shown.rendered?.runId;
2903
+ if (creativeSlug) {
2904
+ const idea = await readIdeaAnchor(path9.dirname(filePath));
2905
+ await recordRendered(canvasRoot, creativeSlug, sourceSha, result.run_id, {
2906
+ canvas: filePath,
2907
+ ...promptNow ? { prompt: promptNow } : {},
2908
+ ...idea ? { anchor: idea.anchor, idea: anchorLines(idea.view) } : {},
2909
+ ...seriesOf(parsed)?.run_id ? { seriesLeadRun: seriesOf(parsed)?.run_id } : {},
2910
+ picture: pictureRecord(result.run_id, {
2911
+ chose: opts.useVariant !== void 0,
2912
+ of: shown.picture,
2913
+ from: fromRun,
2914
+ keeps: fixInstruction !== void 0 || relaidFrom !== void 0,
2915
+ redrawn: opts.autoFixKind === "regenerate"
2916
+ })
2917
+ });
2918
+ }
2919
+ const keepRuns = opts.keepRuns;
2920
+ if (keepRuns !== void 0 && Number.isFinite(keepRuns)) {
2921
+ await pruneOldRuns(outputsDir, keepRuns, result.run_id, (line) => process.stdout.write(`${line}
2922
+ `));
2923
+ }
2924
+ const reviewable = videoPathFromOutput(result.output);
2925
+ await readerSpend.drained();
2926
+ const reviewUsage = poster ? await takeUnbilledSpend(cacheDir) : [];
2927
+ const videoRules = held.rules;
2928
+ const videoAsked = reviewable ? {
2929
+ windows: sceneWindowsOnDelivered(await sceneWindowsBeside(filePath), result.output),
2930
+ context: await reviewContextBeside(filePath),
2931
+ rules: videoRules.map((r) => r.text),
2932
+ brief: opts.brief?.trim() || void 0
2933
+ } : null;
2934
+ const review = reviewable && videoAsked ? await rememberedVideoReview(
2935
+ { cacheDir, video: reviewable, asked: videoAsked },
2936
+ () => reviewRenderedVideo({
2937
+ video: reviewable,
2938
+ windows: videoAsked.windows,
2939
+ ...videoAsked.context,
2940
+ rules: videoRules,
2941
+ checkStills: (stills, labels) => reviewAgainstRules({ stills, formats: labels, rules: videoRules, onSpend: (usage) => reviewUsage.push(usage) }),
2942
+ brief: videoAsked.brief,
2943
+ onSpend: (usage) => reviewUsage.push(usage)
2944
+ })
2945
+ ) : null;
2946
+ const brandKit = reviewable ? null : await readStaticBrandKit(await findBrandRoot(path9.dirname(filePath)) ?? process.cwd());
2947
+ const runShape = {
2948
+ fix: fixInstruction !== void 0,
2949
+ useVariant: opts.useVariant !== void 0,
2950
+ sizesOnly: relaidFrom !== void 0 || opts.extendOnly === true || regenerate !== void 0 && relaysSizesOnly(parsed, [...regenerate])
2951
+ };
2952
+ const staticReview = reviewable ? null : await reviewStaticRun({
2953
+ parsed: madeHere,
2954
+ output: result.output,
2955
+ outputsByNode: result.outputs_by_node,
2956
+ onSpend: (usage) => reviewUsage.push(usage),
2957
+ viewer: viewerCheck?.viewer ?? null,
2958
+ ...brandKit?.name ? { brandName: brandKit.name } : {},
2959
+ ...brandKit?.lockup ? { lockup: brandKit.lockup } : {},
2960
+ // Only a new picture is compared with the last one: an edit, a fix, a chosen option or a
2961
+ // re-layout keeps it on purpose, and would read as "this retry changed nothing".
2962
+ ...beforeRunId && beforeRunId !== result.run_id && rendersNewPicture(runShape) ? { previous: await previousDelivered(canvasRoot, beforeRunId, finalLabels?.nodeId ?? "final", finalLabels?.labels ?? []) } : {},
2963
+ // A size this round did not touch keeps the last round's verdict: the review's second look at it is no defect of the round.
2964
+ ...opts.settledReview && opts.from ? {
2965
+ settled: {
2966
+ review: opts.settledReview,
2967
+ images: await previousDelivered(canvasRoot, opts.from, finalLabels?.nodeId ?? "final", finalLabels?.labels ?? [])
2968
+ }
2969
+ } : {}
2970
+ });
2971
+ const blockingNow = (staticReview?.review ?? []).filter((f) => f.severity === "blocking").map((f) => f.what);
2972
+ const stillThere = fixInstruction !== void 0 && staticReview?.review ? persistingDefects(memory.blocking, staticReview.review) : [];
2973
+ if (creativeSlug && staticReview) {
2974
+ await recordReviewOutcome(
2975
+ canvasRoot,
2976
+ creativeSlug,
2977
+ {
2978
+ blocking: blockingNow,
2979
+ ...fixInstruction !== void 0 ? { lastFix: { instruction: fixInstruction.trim(), blocking: stillThere } } : {},
2980
+ ...remakeOutcome ?? {}
2981
+ },
2982
+ // Counted against the spec it drew, unless replayed whole from the cache: that renders and pays nothing (BAKER-1645).
2983
+ cached ? void 0 : { sourceSha: prepared.sourceSha, runId: result.run_id }
2984
+ );
2985
+ } else if (creativeSlug && remakeOutcome) {
2986
+ await recordRemake(canvasRoot, creativeSlug, void 0);
2987
+ }
2988
+ const costHint = staticReview ? runCostHint(result.stats, paidFor(runShape)) : null;
2989
+ const corrected = opts.autoFixed ?? [];
2990
+ const seriesRoot = creativeSlug && staticReview ? findWorkspaceRoot(path9.dirname(filePath)) : null;
2991
+ const seriesHints = seriesRoot && creativeSlug ? seriesRunHints(creativeSlug, {
2992
+ leads: await seriesLeadsAbove(seriesRoot, creativeSlug),
2993
+ members: await seriesMembers(seriesRoot, creativeSlug)
2994
+ }) : [];
2995
+ const unremoved = stillThere.length > 0 ? [
2996
+ `The fix did not remove ${stillThere.length === 1 ? "this" : "these"}: ${stillThere.join(" | ")}. The same instruction will not run again; change the approach (edit prompt.json so it cannot happen, or make only that size again with \`--regenerate\` on its size node).`
2997
+ ] : [];
2998
+ const unreviewed = !reviewable && !staticReview ? unreviewedHint(result.output) : null;
2999
+ const reviewHints = staticReview ? [
3000
+ ...corrected.length > 0 ? [
3001
+ `Corrected automatically before this result, ${corrected.length} more render${corrected.length === 1 ? "" : "s"}: ${corrected.join(" Then ")} What follows is the review of the corrected version.`
3002
+ ] : [],
3003
+ ...staticReview.hints,
3004
+ ...costHint ? [costHint] : [],
3005
+ ...seriesHints,
3006
+ ...unremoved
3007
+ ] : reviewable ? review === null ? [RENDER_REVIEW_UNAVAILABLE] : review.length === 0 ? ["Reviewed the finished video frame by frame \u2014 nothing to report."] : [
3008
+ `Reviewed the finished video and found ${review.length} thing${review.length === 1 ? "" : "s"} to fix. Show the user what is wrong before you show them the ad.`,
3009
+ ...review.map((f) => `${f.severity === "blocking" ? "Must fix" : "Should fix"} \u2014 ${f.what}`),
3010
+ ...review.some((f) => f.scene) ? [
3011
+ `Anything about the mark or the closing card is a composition fix, not a re-render: both are drawn as HTML by the caption composition, so editing it and re-running re-renders only that pass \u2014 the clips are cached and no generation is paid for again. Fix them, then re-run: edit the \`show\` of the scene files named above \u2014 a shot with a person handling equipment is where limbs and objects go wrong, so widen it, move the hands out of frame, or drop the person from that beat. Re-running re-renders only the scenes you edited; everything else comes from the cache (this run: ${result.stats?.cached_nodes ?? 0} of ${result.stats?.total_nodes ?? 0} nodes were cached).`
3012
+ ] : []
3013
+ ] : unreviewed ? [unreviewed] : [];
3014
+ const verticalHints = verticalRelayoutHints(madeHere, result.outputs_by_node);
3015
+ const hints = [...runNotes, ...verticalHints, ...reviewHints];
3016
+ const brief = staticReview ? [
3017
+ ...runNotes,
3018
+ ...corrected.length > 0 ? [`Corrected automatically before this result, ${corrected.length} more render${corrected.length === 1 ? "" : "s"}; what follows is the review of the corrected version.`] : [],
3019
+ ...verticalHints,
3020
+ ...verdictBrief(staticReview.verdict, sizeShapeOf(madeHere)),
3021
+ ...staticReview.notes,
3022
+ ...seriesHints,
3023
+ ...unremoved
3024
+ ] : reviewable && review !== null && review.length > 0 ? [...runNotes, ...verticalHints, ...reviewHints.slice(0, 1)] : void 0;
3025
+ const lead = (hint) => {
3026
+ hints.unshift(hint);
3027
+ brief?.unshift(hint);
3028
+ };
3029
+ const letThrough = [...prepared.warnings, ...viewerCheck?.warnings ?? [], ...takeCheckWarnings(result.run_id)].map(asReviewNote);
3030
+ const reviewed = staticReview ? staticReview.review : review;
3031
+ const findings = reviewed ? [...reviewed, ...letThrough] : null;
3032
+ const ready = staticReview ? staticReview.verdict === "ready" || staticReview.verdict === "ready_with_notes" : review !== null && !review.some((f) => f.severity === "blocking");
3033
+ const definitionStatus = ready && creativeSlug ? await advanceDefinitionStatus(path9.join(path9.dirname(filePath), "_definition.md"), "rendered") : null;
3034
+ let recordError = null;
3035
+ if (poster) {
3036
+ const unrecorded = await flushBilled(
3037
+ poster,
3038
+ // `review` is null only when nobody looked (no key, no ffmpeg, unreadable video);
3039
+ // an empty array is a render that was reviewed and came back clean. The record
3040
+ // has to keep those apart.
3041
+ buildRunRecord(
3042
+ result,
3043
+ {
3044
+ ...recordMeta,
3045
+ ...findings ? { review: findings } : {},
3046
+ ...reviewUsage.length > 0 ? { reviewUsage } : {},
3047
+ // A static ad that failed a check is never shown as a version (the backend reads both).
3048
+ ...staticReview ? { verdict: staticReview.verdict, presentable: staticReview.verdict !== "needs_fixes" } : {}
3049
+ },
3050
+ progress?.planInfo(),
3051
+ finalLabels
3052
+ )
3053
+ );
3054
+ if (unrecorded !== null) {
3055
+ recordError = `This version was not saved in Baker (${unrecorded}). Run it again with \`--run-id ${result.run_id}\` before showing it or recording feedback on it.`;
3056
+ lead(
3057
+ `This version was not saved in Baker (${unrecorded}): it does not appear in the chat or in Creatives, and the person's feedback cannot be recorded on it. Run it again with \`--run-id ${result.run_id}\` before showing it \u2014 what was already made comes from the cache.`
3058
+ );
3059
+ }
3060
+ }
3061
+ const round = opts.autoFixRound ?? 0;
3062
+ const keepPicture = opts.useVariant !== void 0 || opts.autoFixKeepPicture === true || (fixInstruction !== void 0 || relaidFrom !== void 0) && keepsChosen(shown.picture, fromRun);
3063
+ const attempts = staticReview?.review ? [
3064
+ ...opts.autoFixAttempts ?? [],
3065
+ {
3066
+ runId: result.run_id,
3067
+ review: staticReview.review,
3068
+ ...nodesWithRole(parsed, LOGO_COMPOSITE_ROLE).length > 0 ? { logoOnFile: true } : {}
3069
+ }
3070
+ ] : [];
3071
+ const base = attempts.length > 0 ? correctFrom(attempts) : null;
3072
+ const reverted = base !== null && base.runId !== result.run_id;
3073
+ const before = !reverted && opts.autoFixKind ? opts.autoFixAttempts?.find((a) => a.runId === opts.from)?.review : void 0;
3074
+ const choice = staticReview && base && opts.autoFix !== false ? (
3075
+ // The graph the next round re-prepares (the file's), never this run's rewrite of it: a fix or a
3076
+ // re-layout takes the variants out of `parsed`, and only the file's graph can draw a new picture.
3077
+ autoFixChoice(prepared.canvas, base.review, {
3078
+ round,
3079
+ keepPicture,
3080
+ // Gone back to an earlier attempt: what this round did and left is no longer the picture's.
3081
+ ...!reverted && opts.autoFixKind ? { previous: opts.autoFixKind } : {},
3082
+ ...!reverted && fixInstruction !== void 0 ? { lastFix: { instruction: fixInstruction.trim(), blocking: stillThere } } : {},
3083
+ tooFar: reverted ? [] : placedTooFar(parsed, result.outputs_by_node),
3084
+ fixedBefore: base.fixedBefore,
3085
+ ...opts.autoFixPlanned ? { plannedBefore: opts.autoFixPlanned } : {},
3086
+ ...before ? { before } : {},
3087
+ // What the round this one corrected placed: placing a size for the first time is a new approach.
3088
+ ...before && opts.extendSizes ? { placedBefore: opts.extendSizes } : {},
3089
+ // A drawn logo an earlier attempt, or the version this --fix corrected, already had rejected:
3090
+ // a round after it did not mend it, whatever its match read then.
3091
+ logoMissedBefore: logoMissesBefore(
3092
+ attempts,
3093
+ base.runId,
3094
+ !reverted && fixInstruction !== void 0 ? memory.blocking : []
3095
+ )
3096
+ })
3097
+ ) : null;
3098
+ let step = choice?.step ?? null;
3099
+ if (step && reverted && base) {
3100
+ process.stdout.write(
3101
+ `[autofix] run ${result.run_id} came out worse than run ${base.runId}: the next correction starts from run ${base.runId}
3102
+ `
3103
+ );
3104
+ }
3105
+ const leftAlone = choice?.unmended ?? [];
3106
+ if (leftAlone.length > 0) {
3107
+ process.stdout.write(
3108
+ `[autofix] stopped: round ${round} left the same problems as the version it corrected; another round of its kind would pay for them again
3109
+ `
3110
+ );
3111
+ lead(
3112
+ `The automatic correction stopped: its last round left exactly the problems of the version it corrected (${leftAlone.join(" | ")}). ${unmendedSource(promptOnDisk)} Running the same correction again, or making the same size again from the same prompt.json, repeats them. Change the approach: edit prompt.json so the problem cannot happen (shorter words, a line moved or dropped, a different position), or ask for new options with \`--regenerate static_variants\`.`
3113
+ );
3114
+ }
3115
+ const outOfTime = step !== null && !roundFitsRun(Date.now() - startedAt, step.kind);
3116
+ if (outOfTime) {
3117
+ process.stdout.write(
3118
+ `[autofix] not started: this render has had its time (${Math.round((Date.now() - startedAt) / 6e4)} min). It stands as it is.
3119
+ `
3120
+ );
3121
+ lead(
3122
+ "This render's automatic corrections stopped here. Correct what is left with a run of your own now (`--fix \"<what to change>\"`, or `--regenerate format_<size>` / `adapt_<size>` for one size): it has its own time. Tell the person the ad's state, never how many times it was made or corrected, nor any time or try used up."
3123
+ );
3124
+ step = null;
3125
+ }
3126
+ if (!step && reverted && base) {
3127
+ lead(
3128
+ `Run ${base.runId} has fewer problems than this one: correct that one, never this one (add \`--from ${base.runId}\` to a --fix).`
3129
+ );
3130
+ }
3131
+ let respecced = null;
3132
+ const briefFindings = step?.kind === "respec" ? step.findings : step?.kind === "regenerate" ? step.brief ?? [] : [];
3133
+ const lost = [...new Set((base?.review ?? []).filter(lostVital).flatMap((f) => f.kind?.job ? [f.kind.job] : []))];
3134
+ if (briefFindings.length > 0) {
3135
+ const target = staticReviewTargets(parsed, result.output);
3136
+ const spent2 = [];
3137
+ respecced = target ? await repairSpec({
3138
+ promptPath: target.promptPath,
3139
+ findings: briefFindings,
3140
+ held,
3141
+ ...lost.length > 0 ? { restore: lost } : {},
3142
+ ...target.images[0] ? { image: target.images[0].path } : {},
3143
+ onSpend: (usage) => spent2.push(usage)
3144
+ }) : null;
3145
+ if (spent2.length > 0) await holdUnbilledSpend(cacheDir, spent2);
3146
+ if (step?.kind === "respec" && respecced === null) step = null;
3147
+ }
3148
+ if (step && stopsWithoutRepair(base?.review ?? [], briefFindings, respecced !== null)) {
3149
+ process.stdout.write(
3150
+ "[autofix] stopped: what made the proven ad win is gone and no correction of prompt.json may restore it\n"
3151
+ );
3152
+ lead(
3153
+ "The automatic correction stopped: what made the proven ad win is gone and no correction of prompt.json may restore it, so a new picture from the same plan would come back without it."
3154
+ );
3155
+ step = null;
3156
+ }
3157
+ let logoSwitch = null;
3158
+ if (step && (step.kind === "fix" || step.kind === "regenerate") && step.logoOnFile) {
3159
+ const switched = await switchToLogoFile(filePath).catch(() => ({ placed: false, recorded: false }));
3160
+ if (switched.placed) logoSwitch = { sizes: step.logoOnFile, recorded: switched.recorded };
3161
+ else step = null;
3162
+ }
3163
+ const persisted = step && creativeSlug && respecced === null && !logoSwitch ? spentReasons((await readRenderState(canvasRoot, creativeSlug)).reasons, prepared.sourceSha) : [];
3164
+ if (persisted.length > 0) {
3165
+ process.stdout.write(
3166
+ `[autofix] stopped: ${RENDERS_PER_REASON} renders of this spec ended with the same blocking problem; another would pay for it again
3167
+ `
3168
+ );
3169
+ lead(
3170
+ `The automatic correction stopped: ${RENDERS_PER_REASON} renders of this ad as prompt.json describes it ended with ${persisted.length === 1 ? "this problem" : "these problems"} (${persisted.join(" | ")}), and another render of the same spec is refused. Change the spec in prompt.json so ${persisted.length === 1 ? "it" : "they"} cannot happen (shorter words, a line moved or dropped, a different position, a size left out of \`formats\`, or less of the reference kept), then run again.`
3171
+ );
3172
+ step = null;
3173
+ }
3174
+ const files = finalFiles(result.output, finalLabels?.labels);
3175
+ const printed = runResult(
3176
+ {
3177
+ outputs_dir: result.outputs_dir,
3178
+ output: result.output,
3179
+ stats: result.stats,
3180
+ // The agent reads a finding's words; the review model's typed fields are the correction's.
3181
+ // Null is a video or a picture nobody could look at: its verdict is not_reviewed.
3182
+ ...reviewed ? { review: [...reviewed.map(({ kind: _kind, ...finding }) => finding), ...letThrough] } : reviewable || unreviewed ? { review: null } : {},
3183
+ ...staticReview?.judge?.length ? { judge: staticReview.judge } : {},
3184
+ ...definitionStatus === "updated" ? { definition_status: "rendered" } : {},
3185
+ hints,
3186
+ ...brief ? { brief } : {},
3187
+ // A static ad whose review found a blocking problem is finished but NOT ready.
3188
+ ...staticReview ? { verdict: staticReview.verdict } : {},
3189
+ ...leftAlone.length > 0 || persisted.length > 0 ? { stopped: "defect_persists" } : {},
3190
+ ...recordError !== null ? { version_recorded: false, record_error: recordError } : {},
3191
+ run_id: result.run_id,
3192
+ files,
3193
+ previews: await previewsOf(files, result.outputs_dir)
3194
+ },
3195
+ { full: opts.full === true }
3196
+ );
3197
+ await keepRunResult(result.outputs_dir, {
3198
+ verdict: printed.verdict,
3199
+ review: printed.review,
3200
+ hints,
3201
+ ...staticReview?.judge?.length ? { judge: staticReview.judge } : {}
3202
+ });
3203
+ let relayPlans = {};
3204
+ if (step?.kind === "relayout" && step.planned && !reverted) {
3205
+ const spent2 = [];
3206
+ relayPlans = await bandRelayPlans(parsed, step.planned, result.outputs_by_node, (usage) => spent2.push(usage));
3207
+ if (spent2.length > 0) await holdUnbilledSpend(cacheDir, spent2);
3208
+ }
3209
+ const laidOut = Object.keys(relayPlans).flatMap((id) => formatOfSizeNode(parsed, id) ?? []);
3210
+ const planned = plannedFormats(parsed, step, { reverted });
3211
+ if (step) {
3212
+ const did = logoSwitch ? `The logo the model drew was still not the brand's on ${logoSwitch.sizes.join(" and ")} after a correction, so the brand's own logo file is now placed on every size of this ad${logoSwitch.recorded ? ", and on this brand's next ads (src/brand/tokens.json)" : ""}.` : step.kind === "respec" ? `The spec was corrected: ${respecced}` : step.kind === "fix" ? `The picture was corrected for: ${step.instruction.replace(/^[^:]*: /, "")}` : step.kind === "regenerate" && relaysSizesOnly(parsed, regenerateTargets(parsed, step.ids).ids) ? `The ${step.ids.join(" and ")} ${step.ids.length === 1 ? "was" : "were"} made again from the same chosen picture, avoiding: ${step.note.replace(/^[^:]*: /, "")}` : step.kind === "regenerate" ? `${respecced ? `The spec was corrected (${respecced}) and a` : "A"} new picture was made, avoiding: ${step.note.replace(/^[^:]*: /, "")}` : step.kind === "extend" ? `The ${step.sizes.join(" and ")} ${step.sizes.length === 1 ? "was" : "were"} placed clear of what covers or cuts ${step.sizes.length === 1 ? "it" : "them"}, the margins painted to match.` : laidOut.length > 0 ? `The ${laidOut.join(" and ")} was laid out again so its words, logo and button sit clear of what the app's interface covers.` : `The ${step.ids.map((id) => formatOfSizeNode(parsed, id) ?? id).join(" and ")} was edited: ${Object.values(step.edits).join(" ")}`;
3213
+ process.stdout.write(
3214
+ `[autofix] round ${round + 1} of ${AUTO_FIX_ROUNDS}: run ${result.run_id} needs fixes. ${did} If the correction fails, run ${result.run_id} stands as the latest version: ${JSON.stringify(files)}
3215
+ `
3216
+ );
3217
+ next = {
3218
+ file: filePath,
3219
+ cacheDir: opts.cacheDir,
3220
+ outputsDir: opts.outputsDir,
3221
+ concurrency: opts.concurrency,
3222
+ keepRuns: opts.keepRuns,
3223
+ remoteCache: opts.remoteCache,
3224
+ record: opts.record,
3225
+ brief: opts.brief,
3226
+ full: opts.full,
3227
+ cachePolicy: opts.cachePolicy,
3228
+ fresh: true,
3229
+ from: base?.runId ?? result.run_id,
3230
+ autoFixRound: round + 1,
3231
+ autoFixAttempts: attempts,
3232
+ autoFixStartedAt: startedAt,
3233
+ autoFixed: [...corrected, did],
3234
+ autoFixKind: step.kind,
3235
+ ...opts.autoFixPlanned || planned.length > 0 ? { autoFixPlanned: [...opts.autoFixPlanned ?? [], ...planned] } : {},
3236
+ ...base ? { settledReview: [...base.review] } : {},
3237
+ ...keepPicture ? { autoFixKeepPicture: true } : {},
3238
+ ...step.kind === "fix" ? {
3239
+ fix: step.instruction,
3240
+ ...step.relay ? { relayAlso: step.relay } : {},
3241
+ ...step.keep ? { keepSizes: step.keep } : {},
3242
+ ...step.extend ? { extendSizes: step.extend } : {}
3243
+ } : step.kind === "extend" ? { extendSizes: step.sizes, extendOnly: true } : step.kind === "relayout" ? {
3244
+ ...step.extend ? { extendSizes: step.extend } : {},
3245
+ regenerate: step.ids.join(","),
3246
+ relayEdits: step.edits,
3247
+ ...Object.keys(relayPlans).length > 0 ? { relayPlans } : {},
3248
+ // A second edit of a size is told what the first asked for.
3249
+ ...opts.autoFixKind === "relayout" && opts.relayEdits ? { relayAsked: Object.fromEntries(Object.entries(opts.relayEdits).map(([id, asked]) => [id, [asked]])) } : {}
3250
+ } : step.kind === "regenerate" ? { regenerate: step.ids.join(","), relayNote: step.note, ...step.extend ? { extendSizes: step.extend } : {} } : {}
3251
+ };
3252
+ } else {
3253
+ if (brief && opts.full !== true) for (const hint of hints) process.stderr.write(`[hint] ${hint}
3254
+ `);
3255
+ process.stdout.write(`${JSON.stringify(printed, null, 2)}
3256
+ `);
3257
+ if (creativeSlug && turnId && staticReview) {
3258
+ const verdict = staticReview.verdict;
3259
+ recordRender = (chainCached) => updateTurnRenders(turnCache, (ledger) => recordTurnRender(ledger, turnId, creativeSlug, verdict, { cached: chainCached }));
3260
+ }
3261
+ }
3262
+ } catch (e) {
3263
+ const failedPayload = async (message) => {
3264
+ await readerSpend.drained();
3265
+ const payload = progress?.hasPlan() ? progress.failedSnapshot(message) : buildFailedRunRecord(runId, message, recordMeta);
3266
+ const held2 = await takeUnbilledSpend(cacheDir);
3267
+ return held2.length > 0 ? { ...payload, reviewUsage: held2 } : payload;
3268
+ };
3269
+ if (e instanceof RunAbortedError && e.reason === "signal") {
3270
+ const message = `Interrupted${abortedBy ? ` by ${abortedBy}` : ""} \u2014 re-run \`baker canvas run\` to resume; in-flight jobs re-attach, completed nodes come from the cache.`;
3271
+ if (poster) await flushBilled(poster, { ...await failedPayload(message), interrupted: true });
3272
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { code: "interrupted", message } }, null, 2)}
3273
+ `);
3274
+ process.exit(abortedBy === "SIGTERM" ? 143 : 130);
3275
+ }
3276
+ if (e instanceof RunAbortedError && e.reason === "checkpoint") {
3277
+ await clearMarker();
3278
+ if (poster) {
3279
+ await flushBilled(poster, {
3280
+ ...await failedPayload(`Frames ready to review before the clips. Resume with --run-id ${runId}.`),
3281
+ status: "awaiting_approval"
3282
+ });
3283
+ }
3284
+ const frames = frameUrls;
3285
+ process.stdout.write(
3286
+ `${JSON.stringify(
3287
+ {
3288
+ ok: true,
3289
+ data: { stopped: "frames", runId, frames },
3290
+ hints: [
3291
+ `${e.message}`,
3292
+ frames.length > 0 ? `Review these ${frames.length} frames against the brief and Brand, fix any defects, then resume immediately with the same run id. Wait for the user only when they explicitly requested storyboards only or a review before continuing; do not ask them to choose a version.` : "No frame outputs were captured \u2014 carry on rather than blocking on nothing.",
3293
+ `Carry on with: baker canvas run ${filePath} --run-id ${runId}`
3294
+ ]
3295
+ },
3296
+ null,
3297
+ 2
3298
+ )}
3299
+ `
3300
+ );
3301
+ process.exit(0);
3302
+ }
3303
+ await clearMarker();
3304
+ if (e instanceof ValidationError) {
3305
+ process.stderr.write(
3306
+ `${JSON.stringify({ ok: false, error: { code: "validation", issues: e.issues } }, null, 2)}
3307
+ `
3308
+ );
3309
+ process.exit(2);
3310
+ }
3311
+ if (e instanceof LayerExecutionError) {
3312
+ const failures = e.failures.map((f) => ({ node_id: f.nodeId, message: describeFailureReason(f.reason) }));
3313
+ const failure2 = runFailure(e, runId);
3314
+ if (poster) await flushBilled(poster, { ...await failedPayload(e.message), ...resumableFor(failure2) });
3315
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { ...failure2, message: e.message, failures } }, null, 2)}
3316
+ `);
3317
+ process.exit(1);
3318
+ }
3319
+ const msg = e instanceof Error ? e.message : String(e);
3320
+ const failure = runFailure(e, runId);
3321
+ if (poster) await flushBilled(poster, { ...await failedPayload(msg), ...resumableFor(failure) });
3322
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { ...failure, message: msg } }, null, 2)}
3323
+ `);
3324
+ process.exit(1);
3325
+ }
3326
+ return { cached, next, record: recordRender };
3327
+ }
3328
+ function runFailure(e, runId) {
3329
+ const code = runFailureCode(e);
3330
+ const fix = runFailureFix(code, runId);
3331
+ return fix ? { code, fix } : { code };
3332
+ }
3333
+ function resumableFor(failure) {
3334
+ return failure.fix ? { resumable: true } : {};
3335
+ }
3336
+ function canvasNodeIds(parsed) {
3337
+ const nodes = parsed?.nodes;
3338
+ if (!Array.isArray(nodes)) return [];
3339
+ return nodes.map((node) => node?.id).filter((id) => typeof id === "string");
3340
+ }
3341
+ function buildBackendClient() {
3342
+ try {
3343
+ const creds = requireCredentialsFromEnv();
3344
+ return new BackendClient({ baseUrl: creds.url, apiKey: creds.apiKey });
3345
+ } catch (e) {
3346
+ const msg = e instanceof Error ? e.message : String(e);
3347
+ process.stderr.write(`[warn] run history disabled (${msg})
3348
+ `);
3349
+ return null;
3350
+ }
3351
+ }
3352
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3353
+ function refusedForGood(e) {
3354
+ if (!(e instanceof BackendHttpError) || !("status" in e.detail)) return false;
3355
+ const { status } = e.detail;
3356
+ return status >= 400 && status < 500 && status !== 408 && status !== 429;
3357
+ }
3358
+ async function postInitialRunRecord(client, payload, wait = sleep) {
3359
+ for (let attempt = 0; attempt < 3; attempt++) {
3360
+ try {
3361
+ await client.recordRun(payload);
3362
+ return true;
3363
+ } catch (e) {
3364
+ if (refusedForGood(e)) return false;
3365
+ if (attempt < 2) await wait(500 * 2 ** attempt);
3366
+ }
3367
+ }
3368
+ return false;
3369
+ }
3370
+
3371
+ export {
3372
+ runCommand,
3373
+ stopBeforeKinds,
3374
+ executeCanvasRun,
3375
+ buildBackendClient,
3376
+ postInitialRunRecord
3377
+ };
3378
+ //# sourceMappingURL=chunk-ORCAPJDH.js.map