@koda-sl/baker-cli 0.571.0 → 0.573.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 (438) hide show
  1. package/README.md +1 -1
  2. package/dist/{account-7KZ7MHMN.js → account-SGHH4SIM.js} +4 -4
  3. package/dist/{account-users-NUI3ILRE.js → account-users-KP6A43DU.js} +4 -4
  4. package/dist/{accounts-I2ZLR76R.js → accounts-FV5FPX3X.js} +3 -3
  5. package/dist/{accounts-FLKNFDIE.js → accounts-LQFSNBIC.js} +5 -5
  6. package/dist/{actions-IR47GVZ6.js → actions-RZ62K3WT.js} +18 -18
  7. package/dist/{activecampaign-MNJYIWJL.js → activecampaign-E6PM6YNO.js} +3 -3
  8. package/dist/{add-QMTD6EGI.js → add-HMAQJG4J.js} +3 -3
  9. package/dist/{add-4I25INAO.js → add-MLTE6PPC.js} +2 -2
  10. package/dist/{ads-PWTQC6KV.js → ads-T6J6QQKX.js} +4 -4
  11. package/dist/{advertisers-LOIXTTGP.js → advertisers-FP7MTMUI.js} +3 -3
  12. package/dist/{analytics-NL2KGDLK.js → analytics-AYYFKMF6.js} +6 -6
  13. package/dist/{analytics-6AHC3J4L.js → analytics-D2IA2P5E.js} +3 -3
  14. package/dist/{assign-NKHIHVGI.js → assign-EE4EDOPX.js} +3 -3
  15. package/dist/{audience-size-WEOM6XIL.js → audience-size-SRNH57FA.js} +3 -3
  16. package/dist/{audit-4RIBJ7BR.js → audit-R5JG3ABY.js} +3 -3
  17. package/dist/{autocomplete-FMTJDXTL.js → autocomplete-AIKXLHME.js} +3 -3
  18. package/dist/{avatars-LY5SFMWO.js → avatars-3CAQ5OBN.js} +4 -4
  19. package/dist/{bid-pricing-MQ7WLV5U.js → bid-pricing-PDZIJGOX.js} +4 -4
  20. package/dist/{brand-LR5IXW3W.js → brand-2SN7MM72.js} +2 -2
  21. package/dist/{brief-4DSXIX3F.js → brief-FPEBHIE3.js} +12 -12
  22. package/dist/{campaign-groups-EZYLKMO2.js → campaign-groups-OHL6POG2.js} +9 -9
  23. package/dist/{campaign-writes-UMENYMKO.js → campaign-writes-RKCE4MSZ.js} +3 -3
  24. package/dist/{campaigns-PP2DQMJE.js → campaigns-HGMQSYUM.js} +12 -12
  25. package/dist/{campaigns-TAFDM242.js → campaigns-UWUEENB6.js} +5 -5
  26. package/dist/{canvas-RKR3ZB4E.js → canvas-II524GS7.js} +13 -13
  27. package/dist/{capabilities-45RZ6E6W.js → capabilities-FF6NNJ5L.js} +3 -3
  28. package/dist/{chats-VOLBYA3R.js → chats-XVAFLM47.js} +8 -3
  29. package/dist/chats-XVAFLM47.js.map +1 -0
  30. package/dist/{check-4DI73QX4.js → check-FFRPBGUH.js} +5 -5
  31. package/dist/{chunk-JCDCIQMA.js → chunk-2EEDKWYY.js} +2 -2
  32. package/dist/{chunk-TNI7CN4L.js → chunk-2KQQHBBQ.js} +5 -5
  33. package/dist/{chunk-VWHUO3AP.js → chunk-33ZP44QR.js} +2 -2
  34. package/dist/{chunk-CDPX6WAL.js → chunk-34RDCDCF.js} +2 -2
  35. package/dist/{chunk-MC5F2L64.js → chunk-4SAO6RT2.js} +2 -2
  36. package/dist/{chunk-Z5JWFNG4.js → chunk-4W4MLIRR.js} +2 -2
  37. package/dist/{chunk-O2ECZKXP.js → chunk-5XB352F5.js} +2 -2
  38. package/dist/{chunk-TPJ34LXX.js → chunk-643AA3RB.js} +3 -3
  39. package/dist/{chunk-RVIBHENP.js → chunk-7GFGFBWZ.js} +2 -2
  40. package/dist/{chunk-EKOMZH2S.js → chunk-7MIOMG22.js} +2 -2
  41. package/dist/{chunk-D5HD46VV.js → chunk-7YEP3NFN.js} +3 -3
  42. package/dist/{chunk-WZATC4O5.js → chunk-AP7X3ONA.js} +3 -3
  43. package/dist/{chunk-BXTIG5JL.js → chunk-C3G56TJV.js} +3 -3
  44. package/dist/{chunk-ELC42LJJ.js → chunk-C4BPAMAJ.js} +5 -5
  45. package/dist/{chunk-4QFMRL6O.js → chunk-C57CXCTI.js} +2 -2
  46. package/dist/{chunk-XGG72YRO.js → chunk-C7LLNXRJ.js} +2 -2
  47. package/dist/{chunk-VAURJ4QJ.js → chunk-CKN4HQZM.js} +2 -2
  48. package/dist/{chunk-2TS2ITSG.js → chunk-DXQ5DUFU.js} +2 -2
  49. package/dist/{chunk-QSS34JWZ.js → chunk-EV2HVFTJ.js} +2 -2
  50. package/dist/{chunk-5VXEH72O.js → chunk-GQUBM3Z6.js} +2 -2
  51. package/dist/{chunk-2Q7K4F4H.js → chunk-ICASR3ES.js} +4 -2
  52. package/dist/chunk-ICASR3ES.js.map +1 -0
  53. package/dist/{chunk-B4BITHOD.js → chunk-IZXYI5NB.js} +13 -14
  54. package/dist/chunk-IZXYI5NB.js.map +1 -0
  55. package/dist/{chunk-IAE24RKD.js → chunk-JJBO7QIR.js} +3 -3
  56. package/dist/{chunk-CTJWMZPL.js → chunk-K7APGDEO.js} +2 -2
  57. package/dist/{chunk-P4UCSXNA.js → chunk-L2LGHWJN.js} +2 -2
  58. package/dist/{chunk-QLO4RNHU.js → chunk-M2RXXLK3.js} +3 -3
  59. package/dist/{chunk-I33FO2ON.js → chunk-MYGPWKEI.js} +2 -2
  60. package/dist/{chunk-COOJKEJE.js → chunk-N7EHQNNG.js} +2 -2
  61. package/dist/{chunk-X25XRSDP.js → chunk-OHVXHNUR.js} +2 -2
  62. package/dist/{chunk-V5ODOBBI.js → chunk-OJRS3TGS.js} +3 -3
  63. package/dist/{chunk-EGICPBDY.js → chunk-OX5DS7UE.js} +6 -6
  64. package/dist/{chunk-XWAOECD2.js → chunk-PRHDGULQ.js} +12 -24
  65. package/dist/{chunk-XWAOECD2.js.map → chunk-PRHDGULQ.js.map} +1 -1
  66. package/dist/{chunk-TEJOILEY.js → chunk-PRZBEZBA.js} +2 -2
  67. package/dist/{chunk-LQACNCAV.js → chunk-PTE6BNCH.js} +2 -2
  68. package/dist/{chunk-JT3UUBID.js → chunk-Q5DLTIYL.js} +3 -3
  69. package/dist/{chunk-KUI74TNG.js → chunk-QVO5VPNA.js} +2 -2
  70. package/dist/{chunk-2Z6PFHD2.js → chunk-RBR5PHYJ.js} +2 -2
  71. package/dist/{chunk-H3RCEM6L.js → chunk-RHBCKOF2.js} +2 -2
  72. package/dist/{chunk-2YXTXSYG.js → chunk-S3XCG55E.js} +2 -2
  73. package/dist/{chunk-JSOOLOHP.js → chunk-SPNF2V46.js} +2 -2
  74. package/dist/{chunk-YDALLZNS.js → chunk-SPNY52S5.js} +2 -2
  75. package/dist/{chunk-G4FU6VC5.js → chunk-VSALEVXN.js} +2 -2
  76. package/dist/{chunk-5OC6VUDZ.js → chunk-XPV3KK6B.js} +4 -4
  77. package/dist/{claim-3UMAFZEM.js → claim-YABJMHON.js} +3 -3
  78. package/dist/cli.js +31 -31
  79. package/dist/{companies-RL5A26AT.js → companies-K2IVXNC5.js} +3 -3
  80. package/dist/{company-DJ44F5C6.js → company-6JAVJPSU.js} +3 -3
  81. package/dist/{complete-PGNIP3LN.js → complete-4R6O7TAF.js} +3 -3
  82. package/dist/{connect-ROARWN63.js → connect-FWT2IC5N.js} +6 -6
  83. package/dist/{conversation-GDFMJL7X.js → conversation-DSRM4JIU.js} +3 -3
  84. package/dist/{conversions-2IFWDQKK.js → conversions-4D5TEPO4.js} +8 -8
  85. package/dist/{create-PXAUL6FF.js → create-3OYFSUR5.js} +3 -3
  86. package/dist/{create-B5DIYK5D.js → create-FMGLMQZC.js} +2 -2
  87. package/dist/{create-BRCSXXFO.js → create-SDFDKJGJ.js} +3 -3
  88. package/dist/{create-R6CMATVY.js → create-VW23RNWT.js} +3 -3
  89. package/dist/{creatives-XNVWQWFF.js → creatives-B7GJ2IC5.js} +12 -12
  90. package/dist/{creatives-D6O6Z46U.js → creatives-E33LXJG7.js} +9 -9
  91. package/dist/{credentials-CLJO7WWY.js → credentials-WGGZFBDJ.js} +3 -3
  92. package/dist/{critique-OUJDTVMI.js → critique-EOYMGUIK.js} +8 -8
  93. package/dist/{critique-MBMKW6SL.js → critique-US4B3ZY5.js} +3 -3
  94. package/dist/{crm-H5ITJ2RC.js → crm-T4XPJZTR.js} +4 -4
  95. package/dist/{crm-JJHYRABB.js → crm-UBQ735O6.js} +4 -4
  96. package/dist/{customers-C5YXAVXI.js → customers-HHQUU3MA.js} +5 -5
  97. package/dist/{delete-WZ3KVVX5.js → delete-JPIV5E2Y.js} +3 -3
  98. package/dist/{delete-NBUDIGSD.js → delete-UC5XQZWC.js} +2 -2
  99. package/dist/{delete-3GYCQK6B.js → delete-X5TD7P3U.js} +3 -3
  100. package/dist/{demographics-O7AJW7DO.js → demographics-6GQYZIVR.js} +3 -3
  101. package/dist/{discard-RMVZAX2J.js → discard-5UNX5TEZ.js} +3 -3
  102. package/dist/{domain-J3ZMBOHS.js → domain-7BOPJLTP.js} +3 -3
  103. package/dist/{download-ZVOGLTFB.js → download-B4IV43AJ.js} +2 -2
  104. package/dist/{draft-ZPGGWU7E.js → draft-FVB6SEP3.js} +4 -4
  105. package/dist/{draft-TPR3DH5N.js → draft-QT6MVG47.js} +3 -3
  106. package/dist/{draft-6PJD3MCW.js → draft-VRE52N6B.js} +3 -3
  107. package/dist/{experiments-MM4BYHRH.js → experiments-3JSDRY5W.js} +4 -4
  108. package/dist/{extract-JMY6YRPW.js → extract-BVSL6H3S.js} +2 -2
  109. package/dist/{facets-B5AZAU2C.js → facets-NN33WFSR.js} +3 -3
  110. package/dist/{feedback-4MCMOMVN.js → feedback-BYXZEEW3.js} +3 -3
  111. package/dist/{feedback-2EVDGTEN.js → feedback-HN32HLFT.js} +12 -12
  112. package/dist/{feedback-record-DL7UEU2H.js → feedback-record-GZNCHZFT.js} +13 -13
  113. package/dist/{fetch-JDNFK476.js → fetch-3JPN4QAJ.js} +3 -3
  114. package/dist/{fit-DKVH5BDW.js → fit-2R5NGB7E.js} +5 -5
  115. package/dist/{flows-LURTZICL.js → flows-XM7GBTIU.js} +11 -11
  116. package/dist/{fonts-HUXFDDAE.js → fonts-IO4X2AKN.js} +5 -5
  117. package/dist/{forecast-UHTW4Y7Q.js → forecast-MOFJ3BKH.js} +4 -4
  118. package/dist/{funnel-QM7WFFMD.js → funnel-FR7JQUZW.js} +4 -4
  119. package/dist/{get-FWPR2YPC.js → get-BMJIYS25.js} +3 -3
  120. package/dist/{get-237TYJZT.js → get-MXXANBI3.js} +3 -3
  121. package/dist/{google-DTSLO3PT.js → google-MHFI5OGW.js} +2 -2
  122. package/dist/{google-ads-RZOQQDQN.js → google-ads-ULZRFDZU.js} +3 -3
  123. package/dist/{history-XL52537O.js → history-F3U3WNEJ.js} +3 -3
  124. package/dist/{history-H7S7XRBX.js → history-SGFTHPT2.js} +3 -3
  125. package/dist/{hubspot-2DSISSUI.js → hubspot-FASIF5U5.js} +7 -7
  126. package/dist/{ideas-2XBFQJ56.js → ideas-TKCOPOMS.js} +4 -4
  127. package/dist/{images-VFRQ32G5.js → images-K4EPTLTF.js} +7 -7
  128. package/dist/{ingest-TPVH44VI.js → ingest-MCCJBWYC.js} +2 -2
  129. package/dist/{ingest-4RPLN54K.js → ingest-T3AV5OR4.js} +3 -3
  130. package/dist/{inspect-VD3GVXDU.js → inspect-3OHTBHNO.js} +3 -3
  131. package/dist/{keyword-metrics-PW2DDIJW.js → keyword-metrics-E4PPLUYX.js} +3 -3
  132. package/dist/{keywords-for-site-JEPABY6E.js → keywords-for-site-HD2FOBMH.js} +3 -3
  133. package/dist/{landing-4N6YSB4L.js → landing-NC2A277E.js} +2 -2
  134. package/dist/{leads-R5OZJQHW.js → leads-LL2S6ENL.js} +3 -3
  135. package/dist/{learn-AQ2FRFB7.js → learn-2CP2SROJ.js} +4 -4
  136. package/dist/{line-item-writes-LGO7HIJJ.js → line-item-writes-56A4ITU6.js} +3 -3
  137. package/dist/{line-items-AAZVKQ7E.js → line-items-AIIDDTTH.js} +5 -5
  138. package/dist/{link-7IGHVARH.js → link-BIXBY5KG.js} +3 -3
  139. package/dist/{linkedin-UB2CW4KP.js → linkedin-TXX22PPH.js} +30 -30
  140. package/dist/{linkedin-person-D6U2ZAUW.js → linkedin-person-5KEGEX6G.js} +3 -3
  141. package/dist/{list-VZKUHY4Y.js → list-C5AT3LF4.js} +3 -3
  142. package/dist/{list-P44QRX2O.js → list-UQNU4QUE.js} +2 -2
  143. package/dist/{list-UMJACDTQ.js → list-YBHQ3HIB.js} +3 -3
  144. package/dist/{log-6ZKMUTYS.js → log-FZJTWN3S.js} +3 -3
  145. package/dist/{make-5CEIJRBC.js → make-ESUFN3T4.js} +15 -15
  146. package/dist/{map-ZL4MQVJZ.js → map-WDOBMEAW.js} +4 -4
  147. package/dist/{mcp-GSRYLRD4.js → mcp-JJZ5YGSS.js} +2 -2
  148. package/dist/{media-sources-VSPVHLYN.js → media-sources-AJ5USQXV.js} +2 -2
  149. package/dist/{members-L6SXP6GC.js → members-NSR7S62Y.js} +3 -3
  150. package/dist/{normalize-GK7DH7ZP.js → normalize-RQEHHRES.js} +3 -3
  151. package/dist/{options-FDAAHG7C.js → options-4BW4P6JD.js} +6 -6
  152. package/dist/{organization-K2FTFAAO.js → organization-TKGXZYH6.js} +3 -3
  153. package/dist/{performance-RG2HR46T.js → performance-27VHB3UA.js} +4 -4
  154. package/dist/{performance-N3UROH7Z.js → performance-XGHZDQGU.js} +3 -3
  155. package/dist/{preview-NVWIEUHF.js → preview-2YRMPWI2.js} +3 -3
  156. package/dist/{promoted-tweet-writes-7QZRFDOM.js → promoted-tweet-writes-PT6BW64X.js} +3 -3
  157. package/dist/{promoted-tweets-V555Y7DN.js → promoted-tweets-SBZXEU7S.js} +3 -3
  158. package/dist/{publish-5KR6YLA6.js → publish-Z7ZK3XB7.js} +3 -3
  159. package/dist/{reddit-XPQ7YAJW.js → reddit-L4RQNJBL.js} +4 -4
  160. package/dist/{refresh-XFHEBSDU.js → refresh-EWALAFUQ.js} +2 -2
  161. package/dist/{release-3ECEF26P.js → release-C2H2KBNY.js} +3 -3
  162. package/dist/{remove-OCTUC3RB.js → remove-JOXARFD3.js} +2 -2
  163. package/dist/{reopen-JRI3TYD4.js → reopen-WRW4JVO2.js} +3 -3
  164. package/dist/{rerun-HWWYCDT2.js → rerun-GYWQOZOF.js} +14 -14
  165. package/dist/{research-ODPU62BA.js → research-422BF4O4.js} +2 -2
  166. package/dist/{research-TG5CBTYP.js → research-MCTV6ZJZ.js} +13 -13
  167. package/dist/{reset-J2NLNITD.js → reset-7ANRT4I3.js} +2 -2
  168. package/dist/{reset-SRU7YJUR.js → reset-MZDRR5VP.js} +2 -2
  169. package/dist/{resolve-KHMMUGB2.js → resolve-KKRG65WF.js} +3 -3
  170. package/dist/{retry-WP7LWKZF.js → retry-PDKRPWIZ.js} +2 -2
  171. package/dist/{retry-VLH4AO7F.js → retry-YZCBWAHT.js} +2 -2
  172. package/dist/{revenue-EEIS2AV5.js → revenue-F7E5ZRLB.js} +4 -4
  173. package/dist/{rules-TTUGQAEB.js → rules-GRLAFAZU.js} +5 -5
  174. package/dist/{rules-add-AIXUAZXG.js → rules-add-3C7LW4HD.js} +5 -5
  175. package/dist/{run-YA6IWQAJ.js → run-QDPXTMW6.js} +14 -14
  176. package/dist/{run-AQTACLY6.js → run-ZV73UQ3E.js} +3 -3
  177. package/dist/{scaffold-ad-IYNFJPT7.js → scaffold-ad-LBLEARDJ.js} +10 -10
  178. package/dist/{scaffold-static-ad-SPYKSAJR.js → scaffold-static-ad-TM3JX4HS.js} +18 -18
  179. package/dist/{scaffold-video-BUN27PKS.js → scaffold-video-EINW32ZH.js} +9 -9
  180. package/dist/{schedule-EH2MOC5C.js → schedule-X5ZKZXPC.js} +2 -2
  181. package/dist/{scheduled-agents-DTAEP25E.js → scheduled-agents-APZA42K2.js} +11 -11
  182. package/dist/{schema-7B4MVVAS.js → schema-6JF4ZNGY.js} +4 -4
  183. package/dist/{search-ZZWIJRXJ.js → search-4VAIJA2O.js} +2 -2
  184. package/dist/{select-LWZRF7KV.js → select-TNLQGGNE.js} +11 -11
  185. package/dist/{set-prompt-YKDH6FYK.js → set-prompt-GU3HPWWZ.js} +8 -8
  186. package/dist/{setup-links-OE6PC2YQ.js → setup-links-ORBZ5T4H.js} +3 -3
  187. package/dist/{shopify-CCPLZI2H.js → shopify-SN3TBTL5.js} +3 -3
  188. package/dist/{site-FW5BBLYG.js → site-3ZORNMAE.js} +4 -4
  189. package/dist/{sources-X77TGJ52.js → sources-WGEC6FGZ.js} +6 -6
  190. package/dist/{sources-WPHMWBEK.js → sources-WT6M3QIX.js} +6 -6
  191. package/dist/{stale-SPCDL73V.js → stale-5YYPMXWX.js} +10 -10
  192. package/dist/{status-FLETGJ2A.js → status-WED3AXTZ.js} +3 -3
  193. package/dist/{stock-5AOSQH52.js → stock-33GHQWNQ.js} +2 -2
  194. package/dist/{sync-363VKXU3.js → sync-2GLGCSRQ.js} +2 -2
  195. package/dist/{sync-definition-ZDE5L644.js → sync-definition-SNUWHPGO.js} +9 -9
  196. package/dist/{tags-Y6MNMIEA.js → tags-AQNOA7X5.js} +3 -3
  197. package/dist/{tags-YHAC3NVY.js → tags-CVPMOYKI.js} +3 -3
  198. package/dist/{tags-VOKUNEIW.js → tags-IQY7GYMU.js} +2 -2
  199. package/dist/{tags-ZCQMJ5YH.js → tags-MYUCES3W.js} +4 -4
  200. package/dist/{tags-6MN3AWKN.js → tags-SCMHCPF4.js} +3 -3
  201. package/dist/{targeting-criteria-ECQFHQF3.js → targeting-criteria-RVJHW22S.js} +3 -3
  202. package/dist/{targets-U2JHTB5U.js → targets-G6SN6VTL.js} +3 -3
  203. package/dist/{testimonials-IDVLMXDT.js → testimonials-JALUWWLB.js} +6 -6
  204. package/dist/{top-companies-CBI4O3ZB.js → top-companies-WR6TXTNM.js} +3 -3
  205. package/dist/{transcript-IIRFTFRW.js → transcript-JMRRJEET.js} +3 -3
  206. package/dist/{translate-N6QW4FZB.js → translate-IGCEMHXS.js} +13 -13
  207. package/dist/{triggers-Q3KRAMA3.js → triggers-UUSPHGXX.js} +3 -3
  208. package/dist/{unlink-7RVQXKAR.js → unlink-U5VBTO7P.js} +3 -3
  209. package/dist/{unstage-3LPHNZKR.js → unstage-KSYT7FOP.js} +3 -3
  210. package/dist/{update-LNSSLZXG.js → update-GFKDIJRE.js} +3 -3
  211. package/dist/{update-YBTFH5MN.js → update-QF6BLM5F.js} +3 -3
  212. package/dist/{update-AL3LBHGK.js → update-VBQKI72I.js} +2 -2
  213. package/dist/{update-AWR7EHGA.js → update-ZIKHDZRT.js} +3 -3
  214. package/dist/{upload-45GCGMA5.js → upload-UYE73VLK.js} +3 -3
  215. package/dist/{url-params-U6ZM4LL2.js → url-params-P6MV2HKB.js} +3 -3
  216. package/dist/{validate-S325RXPH.js → validate-HIYNINCN.js} +11 -11
  217. package/dist/{videos-NW2UP342.js → videos-XGQL37V4.js} +6 -6
  218. package/dist/{viewer-check-IDXFRRCO.js → viewer-check-TYTVCSQW.js} +6 -6
  219. package/dist/{web-VMPKMBKA.js → web-PIMTCU4V.js} +3 -3
  220. package/dist/{winning-ads-7UJXCWFH.js → winning-ads-P4MXWYK6.js} +3 -3
  221. package/dist/{write-commands-R42DQEW6.js → write-commands-24EOSYWL.js} +4 -4
  222. package/dist/{x-UGTUOCVR.js → x-HBA6AJJA.js} +6 -6
  223. package/package.json +1 -1
  224. package/dist/chats-VOLBYA3R.js.map +0 -1
  225. package/dist/chunk-2Q7K4F4H.js.map +0 -1
  226. package/dist/chunk-B4BITHOD.js.map +0 -1
  227. /package/dist/{account-7KZ7MHMN.js.map → account-SGHH4SIM.js.map} +0 -0
  228. /package/dist/{account-users-NUI3ILRE.js.map → account-users-KP6A43DU.js.map} +0 -0
  229. /package/dist/{accounts-I2ZLR76R.js.map → accounts-FV5FPX3X.js.map} +0 -0
  230. /package/dist/{accounts-FLKNFDIE.js.map → accounts-LQFSNBIC.js.map} +0 -0
  231. /package/dist/{actions-IR47GVZ6.js.map → actions-RZ62K3WT.js.map} +0 -0
  232. /package/dist/{activecampaign-MNJYIWJL.js.map → activecampaign-E6PM6YNO.js.map} +0 -0
  233. /package/dist/{add-QMTD6EGI.js.map → add-HMAQJG4J.js.map} +0 -0
  234. /package/dist/{add-4I25INAO.js.map → add-MLTE6PPC.js.map} +0 -0
  235. /package/dist/{ads-PWTQC6KV.js.map → ads-T6J6QQKX.js.map} +0 -0
  236. /package/dist/{advertisers-LOIXTTGP.js.map → advertisers-FP7MTMUI.js.map} +0 -0
  237. /package/dist/{analytics-NL2KGDLK.js.map → analytics-AYYFKMF6.js.map} +0 -0
  238. /package/dist/{analytics-6AHC3J4L.js.map → analytics-D2IA2P5E.js.map} +0 -0
  239. /package/dist/{assign-NKHIHVGI.js.map → assign-EE4EDOPX.js.map} +0 -0
  240. /package/dist/{audience-size-WEOM6XIL.js.map → audience-size-SRNH57FA.js.map} +0 -0
  241. /package/dist/{audit-4RIBJ7BR.js.map → audit-R5JG3ABY.js.map} +0 -0
  242. /package/dist/{autocomplete-FMTJDXTL.js.map → autocomplete-AIKXLHME.js.map} +0 -0
  243. /package/dist/{avatars-LY5SFMWO.js.map → avatars-3CAQ5OBN.js.map} +0 -0
  244. /package/dist/{bid-pricing-MQ7WLV5U.js.map → bid-pricing-PDZIJGOX.js.map} +0 -0
  245. /package/dist/{brand-LR5IXW3W.js.map → brand-2SN7MM72.js.map} +0 -0
  246. /package/dist/{brief-4DSXIX3F.js.map → brief-FPEBHIE3.js.map} +0 -0
  247. /package/dist/{campaign-groups-EZYLKMO2.js.map → campaign-groups-OHL6POG2.js.map} +0 -0
  248. /package/dist/{campaign-writes-UMENYMKO.js.map → campaign-writes-RKCE4MSZ.js.map} +0 -0
  249. /package/dist/{campaigns-PP2DQMJE.js.map → campaigns-HGMQSYUM.js.map} +0 -0
  250. /package/dist/{campaigns-TAFDM242.js.map → campaigns-UWUEENB6.js.map} +0 -0
  251. /package/dist/{canvas-RKR3ZB4E.js.map → canvas-II524GS7.js.map} +0 -0
  252. /package/dist/{capabilities-45RZ6E6W.js.map → capabilities-FF6NNJ5L.js.map} +0 -0
  253. /package/dist/{check-4DI73QX4.js.map → check-FFRPBGUH.js.map} +0 -0
  254. /package/dist/{chunk-JCDCIQMA.js.map → chunk-2EEDKWYY.js.map} +0 -0
  255. /package/dist/{chunk-TNI7CN4L.js.map → chunk-2KQQHBBQ.js.map} +0 -0
  256. /package/dist/{chunk-VWHUO3AP.js.map → chunk-33ZP44QR.js.map} +0 -0
  257. /package/dist/{chunk-CDPX6WAL.js.map → chunk-34RDCDCF.js.map} +0 -0
  258. /package/dist/{chunk-MC5F2L64.js.map → chunk-4SAO6RT2.js.map} +0 -0
  259. /package/dist/{chunk-Z5JWFNG4.js.map → chunk-4W4MLIRR.js.map} +0 -0
  260. /package/dist/{chunk-O2ECZKXP.js.map → chunk-5XB352F5.js.map} +0 -0
  261. /package/dist/{chunk-TPJ34LXX.js.map → chunk-643AA3RB.js.map} +0 -0
  262. /package/dist/{chunk-RVIBHENP.js.map → chunk-7GFGFBWZ.js.map} +0 -0
  263. /package/dist/{chunk-EKOMZH2S.js.map → chunk-7MIOMG22.js.map} +0 -0
  264. /package/dist/{chunk-D5HD46VV.js.map → chunk-7YEP3NFN.js.map} +0 -0
  265. /package/dist/{chunk-WZATC4O5.js.map → chunk-AP7X3ONA.js.map} +0 -0
  266. /package/dist/{chunk-BXTIG5JL.js.map → chunk-C3G56TJV.js.map} +0 -0
  267. /package/dist/{chunk-ELC42LJJ.js.map → chunk-C4BPAMAJ.js.map} +0 -0
  268. /package/dist/{chunk-4QFMRL6O.js.map → chunk-C57CXCTI.js.map} +0 -0
  269. /package/dist/{chunk-XGG72YRO.js.map → chunk-C7LLNXRJ.js.map} +0 -0
  270. /package/dist/{chunk-VAURJ4QJ.js.map → chunk-CKN4HQZM.js.map} +0 -0
  271. /package/dist/{chunk-2TS2ITSG.js.map → chunk-DXQ5DUFU.js.map} +0 -0
  272. /package/dist/{chunk-QSS34JWZ.js.map → chunk-EV2HVFTJ.js.map} +0 -0
  273. /package/dist/{chunk-5VXEH72O.js.map → chunk-GQUBM3Z6.js.map} +0 -0
  274. /package/dist/{chunk-IAE24RKD.js.map → chunk-JJBO7QIR.js.map} +0 -0
  275. /package/dist/{chunk-CTJWMZPL.js.map → chunk-K7APGDEO.js.map} +0 -0
  276. /package/dist/{chunk-P4UCSXNA.js.map → chunk-L2LGHWJN.js.map} +0 -0
  277. /package/dist/{chunk-QLO4RNHU.js.map → chunk-M2RXXLK3.js.map} +0 -0
  278. /package/dist/{chunk-I33FO2ON.js.map → chunk-MYGPWKEI.js.map} +0 -0
  279. /package/dist/{chunk-COOJKEJE.js.map → chunk-N7EHQNNG.js.map} +0 -0
  280. /package/dist/{chunk-X25XRSDP.js.map → chunk-OHVXHNUR.js.map} +0 -0
  281. /package/dist/{chunk-V5ODOBBI.js.map → chunk-OJRS3TGS.js.map} +0 -0
  282. /package/dist/{chunk-EGICPBDY.js.map → chunk-OX5DS7UE.js.map} +0 -0
  283. /package/dist/{chunk-TEJOILEY.js.map → chunk-PRZBEZBA.js.map} +0 -0
  284. /package/dist/{chunk-LQACNCAV.js.map → chunk-PTE6BNCH.js.map} +0 -0
  285. /package/dist/{chunk-JT3UUBID.js.map → chunk-Q5DLTIYL.js.map} +0 -0
  286. /package/dist/{chunk-KUI74TNG.js.map → chunk-QVO5VPNA.js.map} +0 -0
  287. /package/dist/{chunk-2Z6PFHD2.js.map → chunk-RBR5PHYJ.js.map} +0 -0
  288. /package/dist/{chunk-H3RCEM6L.js.map → chunk-RHBCKOF2.js.map} +0 -0
  289. /package/dist/{chunk-2YXTXSYG.js.map → chunk-S3XCG55E.js.map} +0 -0
  290. /package/dist/{chunk-JSOOLOHP.js.map → chunk-SPNF2V46.js.map} +0 -0
  291. /package/dist/{chunk-YDALLZNS.js.map → chunk-SPNY52S5.js.map} +0 -0
  292. /package/dist/{chunk-G4FU6VC5.js.map → chunk-VSALEVXN.js.map} +0 -0
  293. /package/dist/{chunk-5OC6VUDZ.js.map → chunk-XPV3KK6B.js.map} +0 -0
  294. /package/dist/{claim-3UMAFZEM.js.map → claim-YABJMHON.js.map} +0 -0
  295. /package/dist/{companies-RL5A26AT.js.map → companies-K2IVXNC5.js.map} +0 -0
  296. /package/dist/{company-DJ44F5C6.js.map → company-6JAVJPSU.js.map} +0 -0
  297. /package/dist/{complete-PGNIP3LN.js.map → complete-4R6O7TAF.js.map} +0 -0
  298. /package/dist/{connect-ROARWN63.js.map → connect-FWT2IC5N.js.map} +0 -0
  299. /package/dist/{conversation-GDFMJL7X.js.map → conversation-DSRM4JIU.js.map} +0 -0
  300. /package/dist/{conversions-2IFWDQKK.js.map → conversions-4D5TEPO4.js.map} +0 -0
  301. /package/dist/{create-PXAUL6FF.js.map → create-3OYFSUR5.js.map} +0 -0
  302. /package/dist/{create-B5DIYK5D.js.map → create-FMGLMQZC.js.map} +0 -0
  303. /package/dist/{create-BRCSXXFO.js.map → create-SDFDKJGJ.js.map} +0 -0
  304. /package/dist/{create-R6CMATVY.js.map → create-VW23RNWT.js.map} +0 -0
  305. /package/dist/{creatives-XNVWQWFF.js.map → creatives-B7GJ2IC5.js.map} +0 -0
  306. /package/dist/{creatives-D6O6Z46U.js.map → creatives-E33LXJG7.js.map} +0 -0
  307. /package/dist/{credentials-CLJO7WWY.js.map → credentials-WGGZFBDJ.js.map} +0 -0
  308. /package/dist/{critique-OUJDTVMI.js.map → critique-EOYMGUIK.js.map} +0 -0
  309. /package/dist/{critique-MBMKW6SL.js.map → critique-US4B3ZY5.js.map} +0 -0
  310. /package/dist/{crm-H5ITJ2RC.js.map → crm-T4XPJZTR.js.map} +0 -0
  311. /package/dist/{crm-JJHYRABB.js.map → crm-UBQ735O6.js.map} +0 -0
  312. /package/dist/{customers-C5YXAVXI.js.map → customers-HHQUU3MA.js.map} +0 -0
  313. /package/dist/{delete-WZ3KVVX5.js.map → delete-JPIV5E2Y.js.map} +0 -0
  314. /package/dist/{delete-NBUDIGSD.js.map → delete-UC5XQZWC.js.map} +0 -0
  315. /package/dist/{delete-3GYCQK6B.js.map → delete-X5TD7P3U.js.map} +0 -0
  316. /package/dist/{demographics-O7AJW7DO.js.map → demographics-6GQYZIVR.js.map} +0 -0
  317. /package/dist/{discard-RMVZAX2J.js.map → discard-5UNX5TEZ.js.map} +0 -0
  318. /package/dist/{domain-J3ZMBOHS.js.map → domain-7BOPJLTP.js.map} +0 -0
  319. /package/dist/{download-ZVOGLTFB.js.map → download-B4IV43AJ.js.map} +0 -0
  320. /package/dist/{draft-ZPGGWU7E.js.map → draft-FVB6SEP3.js.map} +0 -0
  321. /package/dist/{draft-TPR3DH5N.js.map → draft-QT6MVG47.js.map} +0 -0
  322. /package/dist/{draft-6PJD3MCW.js.map → draft-VRE52N6B.js.map} +0 -0
  323. /package/dist/{experiments-MM4BYHRH.js.map → experiments-3JSDRY5W.js.map} +0 -0
  324. /package/dist/{extract-JMY6YRPW.js.map → extract-BVSL6H3S.js.map} +0 -0
  325. /package/dist/{facets-B5AZAU2C.js.map → facets-NN33WFSR.js.map} +0 -0
  326. /package/dist/{feedback-4MCMOMVN.js.map → feedback-BYXZEEW3.js.map} +0 -0
  327. /package/dist/{feedback-2EVDGTEN.js.map → feedback-HN32HLFT.js.map} +0 -0
  328. /package/dist/{feedback-record-DL7UEU2H.js.map → feedback-record-GZNCHZFT.js.map} +0 -0
  329. /package/dist/{fetch-JDNFK476.js.map → fetch-3JPN4QAJ.js.map} +0 -0
  330. /package/dist/{fit-DKVH5BDW.js.map → fit-2R5NGB7E.js.map} +0 -0
  331. /package/dist/{flows-LURTZICL.js.map → flows-XM7GBTIU.js.map} +0 -0
  332. /package/dist/{fonts-HUXFDDAE.js.map → fonts-IO4X2AKN.js.map} +0 -0
  333. /package/dist/{forecast-UHTW4Y7Q.js.map → forecast-MOFJ3BKH.js.map} +0 -0
  334. /package/dist/{funnel-QM7WFFMD.js.map → funnel-FR7JQUZW.js.map} +0 -0
  335. /package/dist/{get-FWPR2YPC.js.map → get-BMJIYS25.js.map} +0 -0
  336. /package/dist/{get-237TYJZT.js.map → get-MXXANBI3.js.map} +0 -0
  337. /package/dist/{google-DTSLO3PT.js.map → google-MHFI5OGW.js.map} +0 -0
  338. /package/dist/{google-ads-RZOQQDQN.js.map → google-ads-ULZRFDZU.js.map} +0 -0
  339. /package/dist/{history-XL52537O.js.map → history-F3U3WNEJ.js.map} +0 -0
  340. /package/dist/{history-H7S7XRBX.js.map → history-SGFTHPT2.js.map} +0 -0
  341. /package/dist/{hubspot-2DSISSUI.js.map → hubspot-FASIF5U5.js.map} +0 -0
  342. /package/dist/{ideas-2XBFQJ56.js.map → ideas-TKCOPOMS.js.map} +0 -0
  343. /package/dist/{images-VFRQ32G5.js.map → images-K4EPTLTF.js.map} +0 -0
  344. /package/dist/{ingest-TPVH44VI.js.map → ingest-MCCJBWYC.js.map} +0 -0
  345. /package/dist/{ingest-4RPLN54K.js.map → ingest-T3AV5OR4.js.map} +0 -0
  346. /package/dist/{inspect-VD3GVXDU.js.map → inspect-3OHTBHNO.js.map} +0 -0
  347. /package/dist/{keyword-metrics-PW2DDIJW.js.map → keyword-metrics-E4PPLUYX.js.map} +0 -0
  348. /package/dist/{keywords-for-site-JEPABY6E.js.map → keywords-for-site-HD2FOBMH.js.map} +0 -0
  349. /package/dist/{landing-4N6YSB4L.js.map → landing-NC2A277E.js.map} +0 -0
  350. /package/dist/{leads-R5OZJQHW.js.map → leads-LL2S6ENL.js.map} +0 -0
  351. /package/dist/{learn-AQ2FRFB7.js.map → learn-2CP2SROJ.js.map} +0 -0
  352. /package/dist/{line-item-writes-LGO7HIJJ.js.map → line-item-writes-56A4ITU6.js.map} +0 -0
  353. /package/dist/{line-items-AAZVKQ7E.js.map → line-items-AIIDDTTH.js.map} +0 -0
  354. /package/dist/{link-7IGHVARH.js.map → link-BIXBY5KG.js.map} +0 -0
  355. /package/dist/{linkedin-UB2CW4KP.js.map → linkedin-TXX22PPH.js.map} +0 -0
  356. /package/dist/{linkedin-person-D6U2ZAUW.js.map → linkedin-person-5KEGEX6G.js.map} +0 -0
  357. /package/dist/{list-VZKUHY4Y.js.map → list-C5AT3LF4.js.map} +0 -0
  358. /package/dist/{list-P44QRX2O.js.map → list-UQNU4QUE.js.map} +0 -0
  359. /package/dist/{list-UMJACDTQ.js.map → list-YBHQ3HIB.js.map} +0 -0
  360. /package/dist/{log-6ZKMUTYS.js.map → log-FZJTWN3S.js.map} +0 -0
  361. /package/dist/{make-5CEIJRBC.js.map → make-ESUFN3T4.js.map} +0 -0
  362. /package/dist/{map-ZL4MQVJZ.js.map → map-WDOBMEAW.js.map} +0 -0
  363. /package/dist/{mcp-GSRYLRD4.js.map → mcp-JJZ5YGSS.js.map} +0 -0
  364. /package/dist/{media-sources-VSPVHLYN.js.map → media-sources-AJ5USQXV.js.map} +0 -0
  365. /package/dist/{members-L6SXP6GC.js.map → members-NSR7S62Y.js.map} +0 -0
  366. /package/dist/{normalize-GK7DH7ZP.js.map → normalize-RQEHHRES.js.map} +0 -0
  367. /package/dist/{options-FDAAHG7C.js.map → options-4BW4P6JD.js.map} +0 -0
  368. /package/dist/{organization-K2FTFAAO.js.map → organization-TKGXZYH6.js.map} +0 -0
  369. /package/dist/{performance-RG2HR46T.js.map → performance-27VHB3UA.js.map} +0 -0
  370. /package/dist/{performance-N3UROH7Z.js.map → performance-XGHZDQGU.js.map} +0 -0
  371. /package/dist/{preview-NVWIEUHF.js.map → preview-2YRMPWI2.js.map} +0 -0
  372. /package/dist/{promoted-tweet-writes-7QZRFDOM.js.map → promoted-tweet-writes-PT6BW64X.js.map} +0 -0
  373. /package/dist/{promoted-tweets-V555Y7DN.js.map → promoted-tweets-SBZXEU7S.js.map} +0 -0
  374. /package/dist/{publish-5KR6YLA6.js.map → publish-Z7ZK3XB7.js.map} +0 -0
  375. /package/dist/{reddit-XPQ7YAJW.js.map → reddit-L4RQNJBL.js.map} +0 -0
  376. /package/dist/{refresh-XFHEBSDU.js.map → refresh-EWALAFUQ.js.map} +0 -0
  377. /package/dist/{release-3ECEF26P.js.map → release-C2H2KBNY.js.map} +0 -0
  378. /package/dist/{remove-OCTUC3RB.js.map → remove-JOXARFD3.js.map} +0 -0
  379. /package/dist/{reopen-JRI3TYD4.js.map → reopen-WRW4JVO2.js.map} +0 -0
  380. /package/dist/{rerun-HWWYCDT2.js.map → rerun-GYWQOZOF.js.map} +0 -0
  381. /package/dist/{research-ODPU62BA.js.map → research-422BF4O4.js.map} +0 -0
  382. /package/dist/{research-TG5CBTYP.js.map → research-MCTV6ZJZ.js.map} +0 -0
  383. /package/dist/{reset-J2NLNITD.js.map → reset-7ANRT4I3.js.map} +0 -0
  384. /package/dist/{reset-SRU7YJUR.js.map → reset-MZDRR5VP.js.map} +0 -0
  385. /package/dist/{resolve-KHMMUGB2.js.map → resolve-KKRG65WF.js.map} +0 -0
  386. /package/dist/{retry-WP7LWKZF.js.map → retry-PDKRPWIZ.js.map} +0 -0
  387. /package/dist/{retry-VLH4AO7F.js.map → retry-YZCBWAHT.js.map} +0 -0
  388. /package/dist/{revenue-EEIS2AV5.js.map → revenue-F7E5ZRLB.js.map} +0 -0
  389. /package/dist/{rules-TTUGQAEB.js.map → rules-GRLAFAZU.js.map} +0 -0
  390. /package/dist/{rules-add-AIXUAZXG.js.map → rules-add-3C7LW4HD.js.map} +0 -0
  391. /package/dist/{run-YA6IWQAJ.js.map → run-QDPXTMW6.js.map} +0 -0
  392. /package/dist/{run-AQTACLY6.js.map → run-ZV73UQ3E.js.map} +0 -0
  393. /package/dist/{scaffold-ad-IYNFJPT7.js.map → scaffold-ad-LBLEARDJ.js.map} +0 -0
  394. /package/dist/{scaffold-static-ad-SPYKSAJR.js.map → scaffold-static-ad-TM3JX4HS.js.map} +0 -0
  395. /package/dist/{scaffold-video-BUN27PKS.js.map → scaffold-video-EINW32ZH.js.map} +0 -0
  396. /package/dist/{schedule-EH2MOC5C.js.map → schedule-X5ZKZXPC.js.map} +0 -0
  397. /package/dist/{scheduled-agents-DTAEP25E.js.map → scheduled-agents-APZA42K2.js.map} +0 -0
  398. /package/dist/{schema-7B4MVVAS.js.map → schema-6JF4ZNGY.js.map} +0 -0
  399. /package/dist/{search-ZZWIJRXJ.js.map → search-4VAIJA2O.js.map} +0 -0
  400. /package/dist/{select-LWZRF7KV.js.map → select-TNLQGGNE.js.map} +0 -0
  401. /package/dist/{set-prompt-YKDH6FYK.js.map → set-prompt-GU3HPWWZ.js.map} +0 -0
  402. /package/dist/{setup-links-OE6PC2YQ.js.map → setup-links-ORBZ5T4H.js.map} +0 -0
  403. /package/dist/{shopify-CCPLZI2H.js.map → shopify-SN3TBTL5.js.map} +0 -0
  404. /package/dist/{site-FW5BBLYG.js.map → site-3ZORNMAE.js.map} +0 -0
  405. /package/dist/{sources-X77TGJ52.js.map → sources-WGEC6FGZ.js.map} +0 -0
  406. /package/dist/{sources-WPHMWBEK.js.map → sources-WT6M3QIX.js.map} +0 -0
  407. /package/dist/{stale-SPCDL73V.js.map → stale-5YYPMXWX.js.map} +0 -0
  408. /package/dist/{status-FLETGJ2A.js.map → status-WED3AXTZ.js.map} +0 -0
  409. /package/dist/{stock-5AOSQH52.js.map → stock-33GHQWNQ.js.map} +0 -0
  410. /package/dist/{sync-363VKXU3.js.map → sync-2GLGCSRQ.js.map} +0 -0
  411. /package/dist/{sync-definition-ZDE5L644.js.map → sync-definition-SNUWHPGO.js.map} +0 -0
  412. /package/dist/{tags-Y6MNMIEA.js.map → tags-AQNOA7X5.js.map} +0 -0
  413. /package/dist/{tags-YHAC3NVY.js.map → tags-CVPMOYKI.js.map} +0 -0
  414. /package/dist/{tags-VOKUNEIW.js.map → tags-IQY7GYMU.js.map} +0 -0
  415. /package/dist/{tags-ZCQMJ5YH.js.map → tags-MYUCES3W.js.map} +0 -0
  416. /package/dist/{tags-6MN3AWKN.js.map → tags-SCMHCPF4.js.map} +0 -0
  417. /package/dist/{targeting-criteria-ECQFHQF3.js.map → targeting-criteria-RVJHW22S.js.map} +0 -0
  418. /package/dist/{targets-U2JHTB5U.js.map → targets-G6SN6VTL.js.map} +0 -0
  419. /package/dist/{testimonials-IDVLMXDT.js.map → testimonials-JALUWWLB.js.map} +0 -0
  420. /package/dist/{top-companies-CBI4O3ZB.js.map → top-companies-WR6TXTNM.js.map} +0 -0
  421. /package/dist/{transcript-IIRFTFRW.js.map → transcript-JMRRJEET.js.map} +0 -0
  422. /package/dist/{translate-N6QW4FZB.js.map → translate-IGCEMHXS.js.map} +0 -0
  423. /package/dist/{triggers-Q3KRAMA3.js.map → triggers-UUSPHGXX.js.map} +0 -0
  424. /package/dist/{unlink-7RVQXKAR.js.map → unlink-U5VBTO7P.js.map} +0 -0
  425. /package/dist/{unstage-3LPHNZKR.js.map → unstage-KSYT7FOP.js.map} +0 -0
  426. /package/dist/{update-LNSSLZXG.js.map → update-GFKDIJRE.js.map} +0 -0
  427. /package/dist/{update-YBTFH5MN.js.map → update-QF6BLM5F.js.map} +0 -0
  428. /package/dist/{update-AL3LBHGK.js.map → update-VBQKI72I.js.map} +0 -0
  429. /package/dist/{update-AWR7EHGA.js.map → update-ZIKHDZRT.js.map} +0 -0
  430. /package/dist/{upload-45GCGMA5.js.map → upload-UYE73VLK.js.map} +0 -0
  431. /package/dist/{url-params-U6ZM4LL2.js.map → url-params-P6MV2HKB.js.map} +0 -0
  432. /package/dist/{validate-S325RXPH.js.map → validate-HIYNINCN.js.map} +0 -0
  433. /package/dist/{videos-NW2UP342.js.map → videos-XGQL37V4.js.map} +0 -0
  434. /package/dist/{viewer-check-IDXFRRCO.js.map → viewer-check-TYTVCSQW.js.map} +0 -0
  435. /package/dist/{web-VMPKMBKA.js.map → web-PIMTCU4V.js.map} +0 -0
  436. /package/dist/{winning-ads-7UJXCWFH.js.map → winning-ads-P4MXWYK6.js.map} +0 -0
  437. /package/dist/{write-commands-R42DQEW6.js.map → write-commands-24EOSYWL.js.map} +0 -0
  438. /package/dist/{x-UGTUOCVR.js.map → x-HBA6AJJA.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/canvas/viewer-check.ts","../src/commands/canvas/casting-check.ts","../src/commands/canvas/turn-renders.ts"],"sourcesContent":["/**\n * Would the person this ad reaches understand it?\n *\n * A static ad is judged by who sees it. A production Session shipped a whiteboard reading\n * \"Reasons I joined the Club®\" to a prospecting ad set: a stranger does not know there is a\n * club, what it is, or that it is about driving jobs. Every check the run had passed it,\n * because they asked whether the words were spelled right, not whether anyone could tell\n * what was on offer. The same words would have been fine for someone who had been to the\n * site.\n *\n * So before anything is rendered, a model plays the viewer the ad set reaches (what they\n * already know, where they scroll) and says, from the words and the picture alone, what is\n * offered, to whom, and what to do next. The decision model (Jev), not the viewer, compares that\n * with what the concept means to say, in whatever language each is written. The viewer decides:\n * there is no rule about temperature.\n */\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { VIEWER_CHECK_MODEL } from \"@baker/canvas-contract\";\nimport { defineCommand } from \"citty\";\nimport { parse as parseYaml } from \"yaml\";\nimport { z } from \"zod\";\nimport { askJev } from \"../../engine/nodes/local/lib/jev.ts\";\nimport { askAboutText, type ReviewUsage } from \"../../engine/nodes/local/lib/render-review.ts\";\nimport { readAdSpec } from \"../../engine/scaffold/static-ad-spec.ts\";\nimport { requireCredentialsFromEnv } from \"../../engine/client/env.ts\";\nimport { HttpClient } from \"../../engine/client/http.ts\";\nimport { optionalTurnId } from \"../../env.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport {\n AWARENESS_VALUES,\n type Awareness,\n describeMarket,\n marketFromCompanyDoc,\n type ViewerMarket,\n viewerFromKnowledge,\n VIEWER_KNOWS_VALUES,\n VIEWER_SOURCE_VALUES,\n VIEWER_TEMPERATURE_VALUES,\n type ViewerProfile,\n} from \"../../viewer-profile.ts\";\nimport { readAudienceNames } from \"../../audience-names.ts\";\nimport { rememberedJev } from \"../../engine/lib/remembered-nouls.ts\";\nimport { adSetViewerRows, audienceNamesOf } from \"../ads/meta/adset-viewers.ts\";\nimport { companyLine, readCompanyReading } from \"../../engine/creative-context/company.ts\";\nimport { briefRules } from \"../../engine/creative-rules/select.ts\";\nimport { heldRules } from \"./rule-gate.ts\";\nimport { findWorkspaceRoot } from \"./normalize-paths.ts\";\nimport { holdUnbilledSpend } from \"./unbilled-spend.ts\";\nimport { type CastingOutcome, castingCheck, castingCheckFailure } from \"./casting-check.ts\";\nimport { readTurnRenders, recordViewerFail, updateTurnRenders, viewerChecksSpent } from \"./turn-renders.ts\";\n\nexport const VIEWER_QUESTIONS = [\"offer\", \"for_whom\", \"next_step\"] as const;\nexport type ViewerQuestion = (typeof VIEWER_QUESTIONS)[number];\n\nexport const VIEWER_CLARITY = [\"clear\", \"guess\", \"unclear\"] as const;\nexport type ViewerClarity = (typeof VIEWER_CLARITY)[number];\n\nconst ViewerReply = z.object({ answer: z.string().default(\"\"), clarity: z.enum(VIEWER_CLARITY) });\n\n/** What the viewer model answers: each question with how sure it is, and what it would need to be told. */\nexport const ViewerAnswerSchema = z.object({\n offer: ViewerReply,\n for_whom: ViewerReply,\n next_step: ViewerReply,\n /** The words that talk to the viewer as if they had already done something with the brand; \"\" when none. */\n presumes: z.string().default(\"\"),\n missing: z.string().default(\"\"),\n});\nexport type ViewerAnswer = z.infer<typeof ViewerAnswerSchema>;\n\n/** What the concept means the viewer to take away (`prompt.json` `message`, the persona it is written for). */\nexport type ViewerIntended = {\n offer?: string;\n persona?: string;\n /** What the company sells, in a few words (COMPANY.md's first line): a viewer sure of it read the offer. */\n sells?: string;\n};\n\nexport type ViewerMiss =\n | {\n question: ViewerQuestion;\n /** `unclear`: they could not tell. `guessed`: they had to infer it. `misread`: they were sure, and wrong. */\n reason: \"unclear\" | \"guessed\" | \"misread\";\n viewerSaid: string;\n intended?: string;\n }\n | {\n /** The ad talks to them as someone who already bought, signed up, tried or gave; they have not. */\n question: \"presumes\";\n reason: \"presumed\";\n /** The words that presume it. */\n viewerSaid: string;\n };\n\nexport type ViewerVerdict = { pass: boolean; missed: ViewerMiss[] };\n\n/**\n * The least each answer must reach. What is offered has to be said by the ad; what to do\n * next may be inferred (the platform's button carries it). Who it is for is asked, and goes\n * into the fix, but never fails an ad alone: on E8 (BENCH.md) it decided no ad that did not\n * work and failed ads that did, where the offer itself says who it is for (an Audi finance\n * deal). One table so the calibration set moves a threshold here, not in the judge.\n */\nexport const VIEWER_REQUIRED_CLARITY: Readonly<Record<ViewerQuestion, ViewerClarity>> = {\n offer: \"clear\",\n for_whom: \"unclear\",\n next_step: \"guess\",\n};\n\nconst RANK: Readonly<Record<ViewerClarity, number>> = { unclear: 0, guess: 1, clear: 2 };\n\n/** A reply at least as sure as `least`. Pure. */\nexport const sureEnough = (clarity: ViewerClarity, least: ViewerClarity): boolean => RANK[clarity] >= RANK[least];\n\n/**\n * At or above this, the decision model says the viewer read the offer the ad means. Measured on\n * 30 readings in 9 languages (scripts/viewer-read-evals): read 0.77–0.98, misread 0.26 or less.\n */\nexport const OFFER_READ = 0.5;\n\nconst READ_QUESTION =\n \"A viewer said an ad offers `viewer_said`; the ad means `meant`. Does `viewer_said` name the same thing on offer as `meant`, in other words or in another language? A general kind of thing that covers it counts (delivery driver jobs for van driving work).\";\nconst SELLS_QUESTION =\n \"A viewer said an ad offers `viewer_said`. Is `viewer_said` about what `company_sells` describes: the same product or service, a part of it, or a step toward buying it (a quote, a survey, a trial), in any language?\";\n\n/** For each reading, the probability it names what the ad means (or what the company sells); null when no judgment came back. */\nexport type ReadJudge = (\n pairs: ReadonlyArray<{ said: string; meant: string; sells?: string }>,\n) => Promise<number[] | null>;\n\n/**\n * The decision model as the judge, its spend reported to `onSpend`: one Noul against what the ad\n * means and one against what the company sells, the higher kept. A message written as a promise\n * or a belief names no product, and a viewer who named the product read it (Dev, Oct 2026).\n */\nexport function jevReadJudge(onSpend?: (usage: ReviewUsage) => void): ReadJudge {\n return async (pairs) => {\n const questions = pairs.flatMap((p): Array<{ instructions: Record<string, string> }> => [\n { instructions: { viewer_said: p.said, meant: p.meant, question: READ_QUESTION } },\n ...(p.sells ? [{ instructions: { viewer_said: p.said, company_sells: p.sells, question: SELLS_QUESTION } }] : []),\n ]);\n const answers = await askJev(questions, onSpend);\n if (answers === null) return null;\n let next = 0;\n return pairs.map((p) => {\n const meant = answers[next++] ?? 0;\n return p.sells ? Math.max(meant, answers[next++] ?? 0) : meant;\n });\n };\n}\n\n/**\n * Which of the viewer's readings name something other than what the ad means: the decision model\n * reads both in whatever language each is written (the viewer answers in English; the ad's message\n * is in the ad's). A pair with nothing to compare, or no judgment at all, is never a misreading: the\n * check does not refuse an ad on a guess. One request for every pair.\n */\nexport async function misreadings(\n pairs: ReadonlyArray<{ said: string; meant?: string | undefined; sells?: string | undefined }>,\n judge: ReadJudge,\n): Promise<boolean[]> {\n const asked = pairs.flatMap((p, i) =>\n p.said.trim() && p.meant?.trim()\n ? [{ i, pair: { said: p.said.trim(), meant: p.meant.trim(), ...(p.sells?.trim() ? { sells: p.sells.trim() } : {}) } }]\n : [],\n );\n const out = pairs.map(() => false);\n if (asked.length === 0) return out;\n const judged = await judge(asked.map((a) => a.pair)).catch(() => null);\n if (judged === null) return out;\n asked.forEach((a, k) => {\n const p = judged[k];\n out[a.i] = p !== undefined && p < OFFER_READ;\n });\n return out;\n}\n\n/** Whether the viewer understood the ad well enough, and what they missed. Pure. */\nexport function judgeViewerAnswer(\n answer: ViewerAnswer,\n intended: ViewerIntended,\n required: Readonly<Record<ViewerQuestion, ViewerClarity>> = VIEWER_REQUIRED_CLARITY,\n /** The decision model said the viewer, sure of the offer, named something else (`misreadings`). */\n offerMisread = false,\n): ViewerVerdict {\n const missed: ViewerMiss[] = [];\n for (const question of VIEWER_QUESTIONS) {\n const reply = answer[question];\n const meant = question === \"offer\" ? intended.offer : question === \"for_whom\" ? intended.persona : undefined;\n const withIntended = meant ? { intended: meant } : {};\n if (RANK[reply.clarity] < RANK[required[question]]) {\n missed.push({\n question,\n reason: reply.clarity === \"unclear\" ? \"unclear\" : \"guessed\",\n viewerSaid: reply.answer,\n ...withIntended,\n });\n } else if (question === \"offer\" && offerMisread) {\n // Only the offer is compared: who an ad is for is said in too many ways\n // (\"unemployed men 25-45\" vs \"people looking for driving work\") to hold against an ad.\n missed.push({ question, reason: \"misread\", viewerSaid: reply.answer, ...withIntended });\n }\n }\n if (answer.presumes.trim()) missed.push({ question: \"presumes\", reason: \"presumed\", viewerSaid: answer.presumes.trim() });\n return { pass: missed.length === 0, missed };\n}\n\n// --- The viewer's question ---\n\n/** One line of the ad's copy, the thing in the picture it is written on when lettered in the scene, and its role. */\nexport type ViewerCopyLine = { text: string; on?: string; role?: string };\n\n/** Roles a glance never reads: the small print. */\nconst SMALL_PRINT = /^(fine_print|legal|disclaimer|footnote)$/;\n\n/** Everything the viewer check reads: what is on the ad, who sees it, and what it means to say. */\nexport type ViewerCheckInput = {\n copy: ViewerCopyLine[];\n /** The picture, in words (`prompt.json` scene). */\n scene: string;\n /** The advertiser's name, which the platform prints above every ad. */\n brand?: string;\n viewer: ViewerProfile;\n intended: ViewerIntended;\n};\n\n/** Where the viewer meets the ad. Advantage+ (\"automatic\") includes Stories and Reels. */\nfunction wherePhrase(placements: readonly string[]): string {\n const fullScreen = placements.length === 0 || placements.some((p) => /automatic|stor|reel/i.test(p));\n return fullScreen\n ? \"full screen through Instagram or Facebook Stories and Reels, thumb ready to swipe\"\n : \"through your Instagram or Facebook feed\";\n}\n\n/**\n * What the viewer already knows, in their own terms. Only a viewer who knows the offer is told it.\n * The advertiser is never named: a stranger does not know whose ad it is, so the words must say it.\n */\nfunction knowledgePhrase(viewer: ViewerProfile, offer: string | undefined): string {\n const brand = \"the advertiser\";\n if (!viewer.knows.includes(\"brand\")) return `You have never heard of ${brand} and know nothing about what it sells.`;\n const offerPart = viewer.knows.includes(\"offer\")\n ? offer\n ? ` You know what they offer: ${offer}.`\n : \" You know what they offer.\"\n : \" You do not know what they are offering right now.\";\n const product = viewer.knows.includes(\"product\") ? \" You have used what they sell.\" : \"\";\n return `You have come across ${brand} before.${offerPart}${product}`;\n}\n\n/**\n * The viewer model's prompt. Written to the reader guidance for Gemini 3 text models\n * (`.context/prompting-google-gemini-image.md` §2, §7): short, the purpose stated, the data\n * first and the question last, the answer a fixed JSON the code grades — the model is never\n * asked whether the ad \"works\", only what it understood. Pure.\n */\nexport function buildViewerPrompt(input: ViewerCheckInput): string {\n const brand = \"the advertiser\";\n // Only a stranger can be talked to as a returning customer by mistake: retargeting copy\n // (\"still in your cart\", \"thanks for your donation last winter\") is right for the viewer who knows the brand.\n const stranger = !input.viewer.knows.includes(\"brand\");\n // A glance reads the big words and skips the small print.\n const read = input.copy.filter((line) => !SMALL_PRINT.test((line.role ?? \"\").trim().toLowerCase().replace(/[\\s-]+/g, \"_\")));\n const words =\n read.length > 0\n ? read.map((line) => `- \"${line.text}\"${line.on ? ` (written on the ${line.on})` : \"\"}`).join(\"\\n\")\n : \"- none: the picture is the whole ad\";\n return [\n `${input.viewer.market ? `You are ${describeMarket(input.viewer.market)}.` : \"You live where this ad runs and read its language natively.\"} You are scrolling ${wherePhrase(input.viewer.placements)}. ${knowledgePhrase(input.viewer, input.intended.offer)}`,\n `An ad from an advertiser whose name means nothing to you holds you for about three seconds: you take in the picture and read the biggest words, not every line. This is what you see, plus the platform's usual button under it (such as \"Learn more\"):`,\n \"\",\n `Picture: ${input.scene.trim()}`,\n \"Words on it:\",\n words,\n \"\",\n \"Answer as this person, from those words, that picture and what you already know. Do not fill gaps with what ads like this usually sell.\",\n 'For each question give your answer in English and how sure you are: \"clear\" when the words or the picture say it outright, or you already know it; \"guess\" when you are piecing it together from someone else\\'s story or review, a list of perks, a statistic or the advertiser\\'s name; \"unclear\" when you cannot tell.',\n \"offer: what is being offered?\",\n \"for_whom: who is it for?\",\n \"next_step: what would you do next if you wanted it?\",\n ...(stranger\n ? [\n `presumes: quote the words that say you have already done something with ${brand} (bought, signed up, started a trial, an order or a registration, donated, left something in a basket); words that only speak to you, or say what you would get, do not count; \"\" when none do.`,\n ]\n : []),\n 'missing: in one short sentence, what you would need to be told to get it; \"\" when nothing.',\n \"\",\n `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\"},${stranger ? '\"presumes\":\"\",' : \"\"}\"missing\":\"\"}`,\n ].join(\"\\n\");\n}\n\n/**\n * The cache key of one viewer check: the words, the picture, the viewer (what they know and\n * where they scroll, not how that was explained), what the ad means to say, the model, and\n * the prompt itself, so a rewritten prompt asks again. Pure.\n */\nexport function viewerCheckCacheKey(input: ViewerCheckInput, model: string): string {\n const { temperature, knows, placements, market } = input.viewer;\n const canonical = {\n prompt: buildViewerPrompt({ ...input, viewer: { ...input.viewer, reasons: [] } }),\n viewer: { temperature, knows: [...knows].sort(), placements: [...placements].sort(), ...(market ? { market } : {}) },\n intended: input.intended,\n model,\n };\n return createHash(\"sha256\").update(JSON.stringify(canonical)).digest(\"hex\");\n}\n\n/** The model boundary: the parsed JSON reply to one prompt, or null when no model answered. */\nexport type AskViewerModel = (prompt: string) => Promise<unknown>;\n\ntype JudgedViewerCheck = {\n input: ViewerCheckInput;\n answer: ViewerAnswer;\n verdict: ViewerVerdict;\n /** The answer came from the cache: nothing was asked or paid for. */\n cached: boolean;\n};\n\nexport type ViewerCheckOutcome =\n | (JudgedViewerCheck & { status: \"passed\" })\n | (JudgedViewerCheck & { status: \"failed\" })\n | { status: \"unavailable\"; input: ViewerCheckInput };\n\nasync function cachedAnswer(file: string): Promise<ViewerAnswer | null> {\n try {\n const parsed = ViewerAnswerSchema.safeParse(JSON.parse(await readFile(file, \"utf8\")));\n return parsed.success ? parsed.data : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Ask the viewer, or read the answer this exact ad and viewer already got, and grade it.\n * The answer is what is cached, not the verdict, so a change to the judge re-grades for\n * free. A model that does not answer (twice) or answers out of shape is `unavailable`:\n * the caller lets the render through and says it was not checked.\n */\nexport async function checkViewer(\n input: ViewerCheckInput,\n opts: {\n cacheDir: string;\n model: string;\n ask: AskViewerModel;\n /** Whether the viewer read the offer the ad means (`misreadings`); the decision model unless given. */\n judge?: ReadJudge;\n },\n): Promise<ViewerCheckOutcome> {\n const file = path.join(opts.cacheDir, \"viewer-check\", `${viewerCheckCacheKey(input, opts.model)}.json`);\n let answer = await cachedAnswer(file);\n const cached = answer !== null;\n const prompt = buildViewerPrompt(input);\n for (let attempt = 0; answer === null && attempt < 2; attempt++) {\n const parsed = ViewerAnswerSchema.safeParse(await opts.ask(prompt));\n if (parsed.success) answer = parsed.data;\n }\n if (answer === null) return { status: \"unavailable\", input };\n if (!cached) {\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${JSON.stringify(answer, null, 2)}\\n`, \"utf8\");\n }\n // Only a viewer sure enough of the offer can have misread it.\n const sure = sureEnough(answer.offer.clarity, VIEWER_REQUIRED_CLARITY.offer);\n const [offerMisread = false] = sure\n ? await misreadings(\n [{ said: answer.offer.answer, meant: input.intended.offer, sells: input.intended.sells }],\n opts.judge ?? jevReadJudge(),\n )\n : [];\n const verdict = judgeViewerAnswer(answer, input.intended, VIEWER_REQUIRED_CLARITY, offerMisread);\n const judged = { input, answer, verdict, cached };\n return verdict.pass ? { ...judged, status: \"passed\" } : { ...judged, status: \"failed\" };\n}\n\n/** The viewer in one phrase, for the agent: \"a cold viewer who knows nothing about the brand yet, on automatic placements\". */\nexport function describeViewer(viewer: ViewerProfile): string {\n const known = viewer.knows.map((k) => `the ${k}`);\n const knows =\n known.length > 0\n ? `who knows ${known.length > 1 ? `${known.slice(0, -1).join(\", \")} and ${known.at(-1)}` : known[0]}`\n : \"who knows nothing about the brand yet\";\n return `a ${viewer.temperature} viewer ${knows}, on ${viewer.placements.join(\", \") || \"automatic\"} placements`;\n}\n\nconst QUESTION_WORDS: Readonly<Record<ViewerQuestion, string>> = {\n offer: \"what is offered\",\n for_whom: \"who it is for\",\n next_step: \"what to do next\",\n};\n\nfunction missLine(miss: ViewerMiss): string {\n if (miss.question === \"presumes\") {\n return `The words talk to them as if they had already done something with the brand: \"${miss.viewerSaid}\". They have not.`;\n }\n const said = miss.viewerSaid.trim() ? `\"${miss.viewerSaid.trim()}\"` : \"nothing\";\n const how =\n miss.reason === \"misread\"\n ? `was sure it is ${said}`\n : miss.reason === \"guessed\"\n ? `could only guess ${said}`\n : `could not tell (said ${said})`;\n const question = QUESTION_WORDS[miss.question];\n return `${question.charAt(0).toUpperCase()}${question.slice(1)}: they ${how}${miss.intended ? `; the ad means \"${miss.intended}\"` : \"\"}.`;\n}\n\n/** The `{ ok: false, error }` a failed check prints: what the viewer missed, and the rewrite that fixes it. Pure. */\nexport function viewerCheckFailure(\n outcome: Extract<ViewerCheckOutcome, { status: \"failed\" }>,\n slug: string,\n): { ok: false; error: { code: \"viewer_check_failed\"; message: string; fix: string; viewer: ViewerProfile; missed: ViewerMiss[] } } {\n const { viewer } = outcome.input;\n const who = describeViewer(viewer);\n const missing = outcome.answer.missing.trim();\n const unsaid = outcome.verdict.missed.flatMap((m) => (m.question === \"presumes\" ? [] : [QUESTION_WORDS[m.question]]));\n // The one rewrite that answers a missed offer, so it takes one edit, not seven (dev, Oct 2026).\n const offer = outcome.input.intended.offer?.trim();\n const rewrite =\n offer && outcome.verdict.missed.some((m) => m.question === \"offer\")\n ? [`Do this: make the biggest words say \"${offer}\", plainly, in the ad's language; keep the rest.`]\n : [];\n const fix = [\n ...rewrite,\n ...(unsaid.length > 0 ? [`Seen by ${who}, the words and picture alone do not say ${unsaid.join(\" or \")}.`] : [`Seen by ${who}:`]),\n ...outcome.verdict.missed.map(missLine),\n ...(missing ? [`They needed: ${missing}`] : []),\n \"Rewrite the copy in prompt.json so the words on the ad say it plainly (name the offer and who it is for; a stranger reads only what is printed), then re-run.\",\n // The run asks the viewer itself, from the same cache: a separate check is one more wait (dev, Oct 2026).\n `Then run the same \\`baker canvas run\\` again: it checks the new copy before it spends (or \\`baker canvas viewer-check ${slug}\\` alone).`,\n \"If this ad will run to people who already know the brand, record that viewer in _definition.md (`targetAdSet` and `viewer`, from `baker ads meta adsets --audience`) instead of rewriting.\",\n ].join(\" \");\n return {\n ok: false,\n error: {\n code: \"viewer_check_failed\",\n message: `Not rendered: ${who} would not understand this ad.`,\n fix,\n viewer,\n missed: outcome.verdict.missed,\n },\n };\n}\n\n// --- Who sees the ad ---\n\n/** The `viewer` a `_definition.md` records, as `baker ads meta adsets --audience` prints it. */\nconst RecordedViewer = z.object({\n temperature: z.enum(VIEWER_TEMPERATURE_VALUES),\n knows: z.array(z.enum(VIEWER_KNOWS_VALUES)).default([]),\n placements: z.array(z.string().min(1)).default([\"automatic\"]),\n source: z.enum(VIEWER_SOURCE_VALUES),\n reasons: z.array(z.string()).default([]),\n market: z\n .object({\n country: z.string().min(2),\n language: z.string().optional(),\n currency: z.string().optional(),\n address: z.string().optional(),\n })\n .optional(),\n});\n\n/** What a creative says about who will see it: `_definition.md`'s `viewer`, `targetAdSet`, `persona`, `awareness`. */\nexport type ViewerSources = { recorded?: unknown; targetAdSet?: string; persona?: string; awareness?: Awareness };\n\n/** One persona in the Knowledge (`src/content/personas/`): its file name, title and `segment`. */\nexport type PersonaEntry = { slug: string; title?: string; segment?: string };\n\n/** The reads resolving a viewer may need. Injected so the order is tested without an ad account. */\nexport type ViewerLookups = {\n /** The viewer the ad set reaches (`classifyAudience`), or null when no connected account holds it. */\n adSetViewer: (adSetId: string) => Promise<ViewerProfile | null>;\n personas: () => Promise<PersonaEntry[]>;\n /** The market COMPANY.md names (`marketFromCompanyDoc`), for a viewer read with none. */\n companyMarket?: () => Promise<ViewerMarket | undefined>;\n /** What the company sells, from its reading, for the casting check. */\n company?: () => Promise<string>;\n /** The company's rules about who appears that hold for this ad (its scope, its waivers), for the casting check. */\n castRules?: (creativeDir: string) => Promise<string[]>;\n};\n\nexport type ResolvedViewer = {\n viewer: ViewerProfile;\n from: \"recorded\" | \"ad_set\" | \"knowledge\" | \"default\";\n /** What could not be read on the way, in the order it was tried. */\n notes: string[];\n};\n\n/** A name as it compares: accents and case off, words only (\"Pet-owners\" and \"pet owners\" alike). */\nconst nameKey = (text: string): string =>\n text\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .toLowerCase()\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter(Boolean)\n .join(\" \");\n\n/**\n * The segments the concept is written for: the persona the creative names, matched to its\n * entry in the Knowledge by file name, title or segment (or taken as written when none\n * matches); every persona on file when it names none. Pure.\n */\nexport function personaSegments(persona: string | undefined, entries: readonly PersonaEntry[]): string[] {\n const describe = (entry: PersonaEntry) => entry.segment ?? entry.title ?? entry.slug;\n if (!persona?.trim()) return entries.map(describe);\n const wanted = nameKey(persona);\n const match = entries.find((entry) =>\n [entry.slug.replace(/[-_]/g, \" \"), entry.title, entry.segment].some((name) => name && nameKey(name) === wanted),\n );\n return [match ? describe(match) : persona.trim()];\n}\n\n/**\n * The viewer an ad is checked against, in this order: the one recorded in `_definition.md`;\n * the one its `targetAdSet` reaches; the one the Knowledge describes (personas and the\n * concept's awareness); a cold stranger, saying so.\n */\nexport async function resolveViewer(sources: ViewerSources, lookups: ViewerLookups): Promise<ResolvedViewer> {\n const resolved = await resolveViewerAlone(sources, lookups);\n if (resolved.viewer.market || !lookups.companyMarket) return resolved;\n const market = await lookups.companyMarket().catch(() => undefined);\n return market ? { ...resolved, viewer: { ...resolved.viewer, market } } : resolved;\n}\n\nasync function resolveViewerAlone(sources: ViewerSources, lookups: ViewerLookups): Promise<ResolvedViewer> {\n const notes: string[] = [];\n if (sources.recorded !== undefined) {\n const recorded = RecordedViewer.safeParse(sources.recorded);\n if (recorded.success) return { viewer: recorded.data, from: \"recorded\", notes };\n notes.push(\"The viewer recorded in _definition.md is not in the shape `baker ads meta adsets --audience` prints; it was skipped.\");\n }\n if (sources.targetAdSet) {\n try {\n const fromAdSet = await lookups.adSetViewer(sources.targetAdSet);\n if (fromAdSet) return { viewer: fromAdSet, from: \"ad_set\", notes };\n notes.push(`Ad set ${sources.targetAdSet} is not in any connected Meta ad account.`);\n } catch (e) {\n notes.push(`Could not read ad set ${sources.targetAdSet} (${e instanceof Error ? e.message : String(e)}).`);\n }\n }\n let entries: PersonaEntry[] = [];\n try {\n entries = await lookups.personas();\n } catch (e) {\n notes.push(`Could not read the personas in the Knowledge (${e instanceof Error ? e.message : String(e)}).`);\n }\n const personas = personaSegments(sources.persona, entries);\n if (personas.length > 0 || sources.awareness) {\n return { viewer: viewerFromKnowledge({ personas, awareness: sources.awareness }), from: \"knowledge\", notes };\n }\n return {\n viewer: {\n temperature: \"cold\",\n knows: [],\n placements: [\"automatic\"],\n source: \"knowledge\",\n reasons: [\n \"Nothing says who will see this ad (no viewer or targetAdSet in _definition.md, no persona in the Knowledge), so it is checked against a cold stranger who has never heard of the brand.\",\n ],\n },\n from: \"default\",\n notes,\n };\n}\n\n// --- Reading a creative ---\n\n/** The ad as the viewer check reads it, before the viewer is known, and the people it casts (D2). */\nexport type CreativeAd = Omit<ViewerCheckInput, \"viewer\"> & { people?: string[] };\n\nconst Frontmatter = z.object({\n viewer: z.unknown().optional(),\n targetAdSet: z.union([z.string(), z.number()]).transform(String).optional(),\n persona: z.string().optional(),\n awareness: z.enum(AWARENESS_VALUES).optional().catch(undefined),\n angle: z.string().optional(),\n});\n\nfunction frontmatterOf(raw: string): z.infer<typeof Frontmatter> {\n const block = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1];\n if (!block) return {};\n try {\n const parsed = Frontmatter.safeParse(parseYaml(block));\n return parsed.success ? parsed.data : {};\n } catch {\n return {};\n }\n}\n\n/**\n * A creative folder read for the viewer check: the words, the picture and the brand from\n * `prompt.json` (an ad spec or an older blueprint, through `readAdSpec`), what the ad means\n * to say (`message`, else the definition's `angle`; the spec's viewer, else the `persona`),\n * and what `_definition.md` says about who will see it. Throws when `prompt.json` cannot be\n * read: there is no ad to check.\n */\nexport async function readCreativeForViewerCheck(creativeDir: string): Promise<{ ad: CreativeAd; sources: ViewerSources }> {\n const spec = readAdSpec(JSON.parse(await readFile(path.join(creativeDir, \"prompt.json\"), \"utf8\")));\n const definition = frontmatterOf(await readFile(path.join(creativeDir, \"_definition.md\"), \"utf8\").catch(() => \"\"));\n const offer = spec.message?.trim() || definition.angle?.trim();\n const persona = spec.viewer?.who.trim() || definition.persona?.trim();\n const brand = spec.brand?.name?.trim();\n // src/creatives/<slug>/ → the workspace, whose company reading says what it sells.\n const sells = (await readCompanyReading(path.resolve(creativeDir, \"../../..\")))?.sells;\n return {\n ad: {\n copy: spec.copy.map((line) => ({\n text: line.text,\n ...(line.lettering === \"in_scene\" && line.on ? { on: line.on } : {}),\n ...(line.role ? { role: line.role } : {}),\n })),\n scene: spec.scene.description,\n ...(brand ? { brand } : {}),\n intended: { ...(offer ? { offer } : {}), ...(persona ? { persona } : {}), ...(sells ? { sells } : {}) },\n ...castPeople(spec),\n },\n sources: {\n ...(definition.viewer !== undefined ? { recorded: definition.viewer } : {}),\n ...(definition.targetAdSet ? { targetAdSet: definition.targetAdSet } : {}),\n ...(definition.persona?.trim() ? { persona: definition.persona.trim() } : {}),\n ...(definition.awareness ? { awareness: definition.awareness } : {}),\n },\n };\n}\n\n/** The people a spec casts (from an avatar, or a picture of ours), in words, for the casting check. */\nfunction castPeople(spec: ReturnType<typeof readAdSpec>): { people?: string[] } {\n const people = spec.references\n .filter((r) => r.role === \"identity\" && (r.avatar || r.image) && !/^ANIMAL_/.test(r.id))\n .map((r) => r.what);\n return people.length > 0 ? { people } : {};\n}\n\n/** The personas in the Knowledge (`src/content/personas/**.md`), each with its `segment` and `# title`. */\nexport async function readPersonas(workspaceRoot: string): Promise<PersonaEntry[]> {\n const dir = path.join(workspaceRoot, \"src\", \"content\", \"personas\");\n let files: string[];\n try {\n files = (await readdir(dir, { recursive: true })).filter((f) => f.endsWith(\".md\"));\n } catch {\n return [];\n }\n return await Promise.all(\n files.map(async (file) => {\n const raw = await readFile(path.join(dir, file), \"utf8\");\n const block = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1];\n let segment: unknown;\n try {\n segment = block ? (parseYaml(block) as { segment?: unknown } | null)?.segment : undefined;\n } catch {\n segment = undefined;\n }\n const title = raw.match(/^#\\s+(.+)$/m)?.[1]?.trim();\n return {\n slug: path.basename(file, \".md\"),\n ...(title ? { title } : {}),\n ...(typeof segment === \"string\" && segment.trim() ? { segment: segment.trim() } : {}),\n };\n }),\n );\n}\n\n// --- Live reads ---\n\ntype MetaRow = Record<string, unknown>;\n\n/** One read of the Baker API, as the viewer lookups make it. */\ntype BakerRead = <T>(apiPath: string, params?: Record<string, string>) => Promise<T>;\n\n/**\n * Reads through the canvas engine's client, built from the connection alone: the CLI's\n * `apiGet` validates every optional override and ends the process on a malformed one, and\n * the render reads only the connection (`requireConnection`) so an unrelated override cannot\n * stop it. A missing connection throws here, and the lookup says so as a note.\n */\nfunction bakerRead(): BakerRead {\n const creds = requireCredentialsFromEnv();\n const http = new HttpClient({ baseUrl: creds.url, apiKey: creds.apiKey, timeoutMs: 60_000, maxRetries: 1 });\n return (apiPath, params) => http.getJson(params ? `${apiPath}?${new URLSearchParams(params)}` : apiPath);\n}\n\n/** The Meta ad accounts to look an ad set up in: the one the Runtime names, else the connected ones. */\nasync function metaAccountIds(read: BakerRead): Promise<string[]> {\n const named = process.env.BAKER_META_AD_ACCOUNT_ID;\n if (named) return [named];\n const accounts = await read<Array<{ externalId?: unknown; id?: unknown }>>(\"/api/ads/meta/accounts\");\n return accounts.flatMap((a) => {\n const id = a.externalId ?? a.id;\n return typeof id === \"string\" && id ? [id] : [];\n });\n}\n\n/** The viewer one Meta ad set reaches, read as `baker ads meta adsets --audience` reads it. */\nasync function metaAdSetViewer(adSetId: string, workspaceRoot: string): Promise<ViewerProfile | null> {\n const read = bakerRead();\n for (const account of (await metaAccountIds(read)).slice(0, 5)) {\n const params = { \"account-id\": account.startsWith(\"act_\") ? account : `act_${account}` };\n const adSet = (await read<MetaRow[]>(\"/api/ads/meta/adsets\", params)).find((row) => String(row.id) === adSetId);\n if (!adSet) continue;\n // The audience list and the objectives only sharpen the read, as in `adsets --audience`.\n const [audiences, campaigns] = await Promise.all([\n read<MetaRow[]>(\"/api/ads/meta/audiences\", params).catch(() => []),\n read<MetaRow[]>(\"/api/ads/meta/campaigns\", params).catch(() => []),\n ]);\n const cacheDir = path.join(workspaceRoot, \"canvas\", \".cache\");\n const spent: ReviewUsage[] = [];\n const readName = await readAudienceNames(\n audienceNamesOf([adSet], audiences),\n rememberedJev(path.join(cacheDir, \"audience-names.json\"), (u) => spent.push(u)),\n );\n await holdUnbilledSpend(cacheDir, spent).catch(() => undefined);\n return adSetViewerRows([adSet], audiences, campaigns, readName)[0]?.viewer ?? null;\n }\n return null;\n}\n\n/** The rules the casting question is told at most: who appears is a few lines of any brand's rules. */\nconst CAST_RULES = 8;\n\n/** The reads a real check makes: the Meta ad set through the API, the personas from the workspace. */\nexport function liveViewerLookups(workspaceRoot: string): ViewerLookups {\n return {\n adSetViewer: (adSetId) => metaAdSetViewer(adSetId, workspaceRoot),\n personas: () => readPersonas(workspaceRoot),\n companyMarket: async () =>\n marketFromCompanyDoc(await readFile(path.join(workspaceRoot, \"COMPANY.md\"), \"utf8\").catch(() => null)),\n company: async () => companyLine(await readCompanyReading(workspaceRoot)),\n // Who appears, as the rules that hold for this ad say: a person's on its picture or cast, the brand's on\n // its cast only (a brand document's picture rules are often its web design system's: `briefRules`).\n castRules: async (creativeDir) =>\n briefRules((await heldRules(creativeDir)).rules)\n .filter((r) => r.applies === \"cast\" || (r.origin === \"learned\" && r.applies === \"picture\"))\n .slice(0, CAST_RULES)\n .map((r) => r.text),\n };\n}\n\n/** The viewer model through the gateway, its spend reported to `onSpend`. */\nexport function gatewayViewerModel(model: string, onSpend?: (usage: ReviewUsage) => void): AskViewerModel {\n return (prompt) => askAboutText(model, prompt, onSpend);\n}\n\n// --- Before a render ---\n\n/** Why a render goes without asking the viewer: a correction or a resumed render of an ad already checked, or the person's own call. */\nexport type ViewerCheckSkip = \"fix\" | \"resume\" | \"asked\" | null;\n\nconst SKIP_WORDS: Readonly<Record<Exclude<ViewerCheckSkip, null>, string>> = {\n fix: \"a correction of a version already checked\",\n resume: \"a resumed render, checked when it started\",\n asked: \"--skip-viewer-check\",\n};\n\n/**\n * Why this render goes without asking the viewer, or null to ask: a correction (`--fix`, an autofix\n * round), a chosen option and a re-layout keep words already checked; an edit of the words is\n * asked about, since what it changed is what the viewer reads. Pure.\n */\nexport function viewerCheckSkip(run: {\n fix: boolean;\n useVariant: boolean;\n relaid: boolean;\n autoFixRound: number;\n resumed: boolean;\n asked: boolean;\n}): ViewerCheckSkip {\n if (run.fix || run.useVariant || run.relaid || run.autoFixRound > 0) return \"fix\";\n if (run.resumed) return \"resume\";\n return run.asked ? \"asked\" : null;\n}\n\nexport type PreRenderViewerCheck = {\n /** Who the ad is checked against, for the review after the render; null when the ad could not be read. */\n viewer: ViewerProfile | null;\n /** What to print on the run log. */\n lines: string[];\n /** Set when the viewer would not understand the ad, or its people would not pass: print it and exit 2, before anything is spent. */\n failure?: ReturnType<typeof viewerCheckFailure> | ReturnType<typeof castingCheckFailure>;\n};\n\n/**\n * The check `baker canvas run` makes on a static ad before it spends: resolve the viewer,\n * ask them (from the cache when this ad and viewer were asked before), and refuse the\n * render when they would not understand it. A correction, a resumed render and an explicit\n * skip still resolve the viewer (the review after the render reads it) but ask nothing. A\n * model that does not answer lets the render through, saying so.\n */\nexport async function viewerCheckBeforeRender(opts: {\n creativeDir: string;\n cacheDir: string;\n slug: string;\n skip: ViewerCheckSkip;\n /** This ad already failed the viewer twice in this turn (`viewerChecksSpent`): a miss is said, never held against the render. */\n spent?: boolean;\n lookups: ViewerLookups;\n model: string;\n ask: AskViewerModel;\n /** Whether the viewer read the offer (`misreadings`); the decision model unless given. */\n judge?: ReadJudge;\n}): Promise<PreRenderViewerCheck> {\n let creative: Awaited<ReturnType<typeof readCreativeForViewerCheck>>;\n try {\n creative = await readCreativeForViewerCheck(opts.creativeDir);\n } catch (e) {\n return {\n viewer: null,\n lines: [`[warn] viewer_check_skipped: prompt.json could not be read for the viewer check (${e instanceof Error ? e.message : String(e)}).`],\n };\n }\n const resolved = await resolveViewer(creative.sources, opts.lookups);\n const who = describeViewer(resolved.viewer);\n const lines = resolved.notes.map((note) => `[viewer] ${note}`);\n if (opts.skip) return { viewer: resolved.viewer, lines: [...lines, `[viewer] not asked: ${SKIP_WORDS[opts.skip]}.`] };\n // Who is cast, against who buys and where it runs (D2): asked alongside the viewer, never after it.\n const casting = (async () =>\n castingCheck(\n {\n people: creative.ad.people ?? [],\n company: (await opts.lookups.company?.().catch(() => \"\")) ?? \"\",\n rules: (await opts.lookups.castRules?.(opts.creativeDir).catch(() => [])) ?? [],\n ...(resolved.viewer.market ? { market: describeMarket(resolved.viewer.market) } : {}),\n ...(creative.ad.intended.persona ? { persona: creative.ad.intended.persona } : {}),\n },\n { cacheDir: opts.cacheDir, model: opts.model, ask: opts.ask },\n ))().catch((): CastingOutcome => ({ status: \"unavailable\" }));\n const outcome = await checkViewer({ ...creative.ad, viewer: resolved.viewer }, opts);\n if (outcome.status === \"unavailable\") {\n lines.push(\n `[warn] viewer_check_unavailable: the viewer model did not answer, so this ad renders without the viewer check. Read the copy as ${who} before showing it, or run \\`baker canvas viewer-check ${opts.slug}\\` again.`,\n );\n } else if (outcome.status === \"failed\" && !opts.spent) {\n return { viewer: resolved.viewer, lines, failure: viewerCheckFailure(outcome, opts.slug) };\n } else if (outcome.status === \"failed\") {\n lines.push(\n `[viewer] this ad failed the viewer check twice in this turn, so it renders as written. Tell the person what ${who} missed: ${outcome.verdict.missed.map(missLine).join(\" \")}`,\n );\n } else {\n lines.push(`[viewer] ${who} understood it: ${outcome.answer.offer.answer}${outcome.cached ? \" (cached)\" : \"\"}.`);\n }\n if (outcome.status === \"unavailable\") return { viewer: resolved.viewer, lines };\n const cast = await casting;\n if (cast.status === \"failed\") return { viewer: resolved.viewer, lines, failure: castingCheckFailure(cast.answer, opts.slug) };\n if (cast.status === \"passed\") lines.push(`[casting] the people cast pass as real customers${cast.cached ? \" (cached)\" : \"\"}.`);\n if (cast.status === \"unavailable\") {\n lines.push(\"[warn] casting_check_unavailable: the model did not answer; check yourself that the people cast look like this company's real customers.\");\n }\n return { viewer: resolved.viewer, lines };\n}\n\n// --- `baker canvas viewer-check <slug>` ---\n\nconst DESCRIPTION =\n \"Would the person this ad reaches understand it? A model plays the viewer the creative is for (the `viewer` in _definition.md, else the one its `targetAdSet` reaches, else the persona and awareness in the Knowledge, else a cold stranger) and says, from prompt.json's copy and scene alone, what is offered, to whom and what to do next; the answer is compared with prompt.json's `message`. Start here after writing the copy, before rendering: baker canvas viewer-check spring-offer. `baker canvas run` makes the same check before it spends, from the same cache, and refuses a static ad the viewer would not understand (exit 2, `viewer_check_failed`, `fix` saying what they missed). Output is compact; --full adds the viewer's whole answer and why that viewer was chosen.\";\n\nconst ARGS = {\n slug: {\n type: \"positional\",\n required: true,\n description: \"The creative: its slug (src/creatives/<slug>/), or the path to its folder, canvas or prompt.json.\",\n },\n full: {\n type: \"boolean\",\n required: false,\n default: false,\n description: \"Add the viewer's whole answer, what the ad means to say, and how the viewer was resolved.\",\n },\n} as const;\n\nregisterSchema({ command: \"canvas.viewer-check\", description: DESCRIPTION, args: ARGS });\n\n/** The creative folder an argument names: a path to it (or a file in it), else `src/creatives/<slug>/`. */\nasync function creativeDirOf(arg: string, workspaceRoot: string): Promise<string> {\n const direct = path.resolve(arg);\n try {\n return (await stat(direct)).isDirectory() ? direct : path.dirname(direct);\n } catch {\n return path.join(workspaceRoot, \"src\", \"creatives\", arg);\n }\n}\n\nexport const viewerCheckCommand = defineCommand({\n meta: { name: \"viewer-check\", description: DESCRIPTION },\n args: ARGS,\n async run({ args }) {\n const cwd = process.cwd();\n const workspaceRoot = findWorkspaceRoot(cwd) ?? cwd;\n const creativeDir = await creativeDirOf(String(args.slug), workspaceRoot);\n const slug = path.basename(creativeDir);\n let creative: Awaited<ReturnType<typeof readCreativeForViewerCheck>>;\n try {\n creative = await readCreativeForViewerCheck(creativeDir);\n } catch (e) {\n writeJson({\n ok: false,\n error: {\n code: \"NOT_FOUND\",\n message: `No readable prompt.json in ${creativeDir} (${e instanceof Error ? e.message : String(e)}).`,\n fix: \"Pass the creative's slug (src/creatives/<slug>/) or its folder; its prompt.json must parse.\",\n },\n });\n process.exit(1);\n }\n const resolved = await resolveViewer(creative.sources, liveViewerLookups(workspaceRoot));\n const input: ViewerCheckInput = { ...creative.ad, viewer: resolved.viewer };\n const cacheDir = path.join(workspaceRoot, \"canvas\", \".cache\");\n const spent: ReviewUsage[] = [];\n const outcome = await checkViewer(input, {\n cacheDir,\n model: VIEWER_CHECK_MODEL,\n ask: gatewayViewerModel(VIEWER_CHECK_MODEL, (usage) => spent.push(usage)),\n judge: jevReadJudge((usage) => spent.push(usage)),\n });\n // No run record carries this check: the next render of this workspace bills it.\n await holdUnbilledSpend(cacheDir, spent);\n const who = describeViewer(resolved.viewer);\n const detail = args.full\n ? {\n viewer_profile: resolved.viewer,\n viewer_from: resolved.from,\n intended: input.intended,\n ...(outcome.status !== \"unavailable\" ? { answer: outcome.answer } : {}),\n ...(resolved.notes.length > 0 ? { notes: resolved.notes } : {}),\n }\n : {};\n if (outcome.status === \"failed\") {\n const turnId = optionalTurnId();\n const ledger = await readTurnRenders(cacheDir);\n // Failed twice in this turn already: the render goes ahead, and the person hears what was missed.\n if (viewerChecksSpent(ledger, turnId, slug)) {\n writeJson({\n ok: true,\n data: { checked: true, understood: false, viewer: who, missed: outcome.verdict.missed, ...detail },\n hints: [\n `This ad failed the viewer check twice in this turn: render it as written (baker canvas run --slug ${slug}) and tell the person what ${who} missed: ${outcome.verdict.missed.map(missLine).join(\" \")}`,\n ],\n });\n return;\n }\n if (turnId) await updateTurnRenders(cacheDir, (current) => recordViewerFail(current, turnId, slug));\n const failure = viewerCheckFailure(outcome, slug);\n writeJson({ ...failure, error: { ...failure.error, ...detail } });\n process.exit(2);\n }\n if (outcome.status === \"unavailable\") {\n writeJson({\n ok: true,\n data: { checked: false, viewer: who, ...detail },\n hints: [\n \"The viewer model did not answer (no gateway key here, or it failed twice). Read the copy as this viewer yourself, or run the check again.\",\n ],\n });\n return;\n }\n writeJson({\n ok: true,\n data: {\n checked: true,\n understood: true,\n viewer: who,\n offer: outcome.answer.offer.answer,\n for_whom: outcome.answer.for_whom.answer,\n next_step: outcome.answer.next_step.answer,\n ...(outcome.cached ? { cached: true } : {}),\n ...detail,\n },\n hints: [\n resolved.from === \"default\"\n ? \"Checked against a cold stranger because nothing says who will see this ad: record `targetAdSet` and `viewer` in _definition.md (`baker ads meta adsets --audience`) when it will run in a known ad set.\"\n : `Checked against ${who}. Render it: baker canvas run --slug ${slug}`,\n ],\n });\n },\n});\n","/**\n * Would the people in this ad pass as real customers of this company, where it runs?\n *\n * Audited Sept 2026: casting came from the reference ad's stranger or from whichever avatar was\n * passed first: a 24-year-old model in a hoodie selling trade courses to unemployed adults\n * changing careers, a Spanish face on a Mexican ad. Before a static ad renders, a text model reads\n * who is cast (each person's description, from the avatar), what the company sells, who the ad\n * is for and where it runs, and says whether each would pass as a real customer, and who would\n * instead. Cached by the question, so asking again is free; a model that does not answer lets\n * the render through, saying so.\n */\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nexport const CastingAnswerSchema = z.object({\n passes: z.boolean(),\n why: z.string().default(\"\"),\n instead: z.string().default(\"\"),\n});\nexport type CastingAnswer = z.infer<typeof CastingAnswerSchema>;\n\nexport type CastingInput = {\n /** Each person cast, in words (the avatar's own description). */\n people: string[];\n /** What the company sells, from COMPANY.md. */\n company: string;\n /** Where the ad runs, as the viewer would be (`describeMarket`). */\n market?: string;\n /** Who the ad is for. */\n persona?: string;\n /** The company's own rules about who appears in its ads, in their words. */\n rules?: readonly string[];\n};\n\n/** The casting question, the answer a fixed JSON the code reads. Pure. */\nexport function buildCastingPrompt(input: CastingInput): string {\n return [\n \"An ad is about to be made with these people in it:\",\n ...input.people.map((p) => `- ${p}`),\n \"\",\n `The company: ${input.company.trim() || \"(not written down)\"}`,\n ...(input.persona ? [`The ad is for: ${input.persona}`] : []),\n ...(input.market ? [`It runs for ${input.market}.`] : []),\n ...(input.rules && input.rules.length > 0\n ? [\"The company's own rules about who appears in its ads:\", ...input.rules.map((r) => `- ${r}`)]\n : []),\n \"\",\n \"Would each of these people pass, to someone scrolling there, as a real customer of this company (or, for a testimonial, someone who really used it)? Judge age, look, setting and origin against who actually buys this, where the ad runs. A model-like face selling to people who are not models does not pass, and a person a rule rules out does not pass. A rule about how or where a person is shown (their size, framing, a round photo, inside a mockup) is not this question: the finished ad is checked against it.\",\n 'Reply with only this JSON: {\"passes\":true|false,\"why\":\"<one sentence>\",\"instead\":\"<who would pass, in a few words, when one does not>\"}',\n ].join(\"\\n\");\n}\n\nexport type CastingOutcome =\n | { status: \"passed\" | \"failed\"; answer: CastingAnswer; cached: boolean }\n | { status: \"unavailable\" }\n | { status: \"skipped\" };\n\nfunction cacheKey(input: CastingInput, model: string): string {\n return createHash(\"sha256\").update(JSON.stringify({ prompt: buildCastingPrompt(input), model })).digest(\"hex\");\n}\n\nfunction parseOrNull(raw: string): unknown {\n try {\n return JSON.parse(raw);\n } catch {\n return null;\n }\n}\n\n/** Ask, or read the answer this exact question already got. Nobody cast: nothing to check. */\nexport async function castingCheck(\n input: CastingInput,\n opts: { cacheDir: string; model: string; ask: (prompt: string) => Promise<unknown> },\n): Promise<CastingOutcome> {\n if (input.people.length === 0) return { status: \"skipped\" };\n const file = path.join(opts.cacheDir, \"casting-check\", `${cacheKey(input, opts.model)}.json`);\n const cachedRaw = await readFile(file, \"utf8\").catch(() => null);\n // A write cut short leaves half a file: that is a miss, never a failed run.\n const cachedParse = cachedRaw ? CastingAnswerSchema.safeParse(parseOrNull(cachedRaw)) : null;\n if (cachedParse?.success) return { status: cachedParse.data.passes ? \"passed\" : \"failed\", answer: cachedParse.data, cached: true };\n const prompt = buildCastingPrompt(input);\n for (let attempt = 0; attempt < 2; attempt++) {\n const parsed = CastingAnswerSchema.safeParse(await opts.ask(prompt));\n if (!parsed.success) continue;\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${JSON.stringify(parsed.data, null, 2)}\\n`, \"utf8\");\n return { status: parsed.data.passes ? \"passed\" : \"failed\", answer: parsed.data, cached: false };\n }\n return { status: \"unavailable\" };\n}\n\n/** The `{ ok: false, error }` a failed casting check prints. Pure. */\nexport function castingCheckFailure(answer: CastingAnswer, slug: string) {\n return {\n ok: false as const,\n error: {\n code: \"casting_check_failed\" as const,\n message: `Not rendered: the people cast would not pass as this company's real customers. ${answer.why}`.trim(),\n fix: [\n answer.instead ? `Cast ${answer.instead} instead:` : \"Cast someone who would:\",\n \"`baker avatars list` for the company's avatars (pass the one that fits with `--avatar` on the scaffold, or set its identity sheet URL from `baker avatars get <handle>` as the PERSON reference's `image` in prompt.json), or `baker avatars create` from the persona (age, origin, setting, accent for this market).\",\n `Then \\`baker canvas run --slug ${slug}\\` again.`,\n ].join(\" \"),\n },\n };\n}\n","/**\n * How many times each ad was rendered in this chat turn, and how the last one ended, so a turn\n * stops spending time on an ad that is done or cannot be finished. Dev, Oct 2026: a producer\n * re-rendered a `ready_with_notes` ad four more times to chase its notes, and another re-ran an ad\n * whose concept could not be kept truthfully until the turn ran out. The run's own autofix rounds\n * are one render here: only the commands an agent starts count.\n */\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { canonicalize } from \"@baker/canvas-contract\";\nimport { z } from \"zod\";\nimport { updateLockedFile } from \"../../engine/lib/file-lock.ts\";\nimport type { StaticVerdict } from \"../../engine/nodes/local/lib/static-review.ts\";\nimport type { AutoFixStep } from \"./static-autofix.ts\";\n\n/** Renders an agent may start for one ad in one turn, its autofix rounds included in each. */\nconst RUNS_PER_TURN = 2;\n\n/**\n * Viewer checks one ad may fail in one turn before it renders anyway, what the viewer missed said\n * with it. Dev, Oct 2026: a producer rewrote one ad's copy for seven checks, then sat blocked.\n */\nconst VIEWER_FAILS_PER_TURN = 2;\n\n/**\n * The time one ad may take in one turn, its renders and their correction rounds together. Past it the\n * ad is shown as it stands: the person's next message says what changes. Dev, Oct 2026: two autofix\n * rounds and a second render held one producer 21 minutes on one ad, the other two long finished.\n * 12, not 8: three rounds, each from the best attempt so far, finish what two left (prod, Oct 2026:\n * ads shown \"Needs fixes\" until the person asked again, twice).\n */\nconst AD_TURN_MS = 12 * 60_000;\n\n/** About how long each correction round takes, its review included (dev, Oct 2026 runs). */\nconst ROUND_MS: Record<AutoFixStep[\"kind\"], number> = {\n respec: 60_000,\n extend: 80_000,\n relayout: 100_000,\n fix: 150_000,\n regenerate: 220_000,\n};\n\n/** About how long a render an agent starts takes before its first review (dev, Oct 2026 runs). */\nconst RENDER_MS = 150_000;\n\nconst LedgerSchema = z.object({\n turnId: z.string(),\n creatives: z.record(\n z.string(),\n z.object({\n runs: z.number().default(0),\n verdict: z.string().optional(),\n viewerFails: z.number().optional(),\n spentMs: z.number().optional(),\n lastCorrection: z.boolean().optional(),\n }),\n ),\n});\nexport type TurnRenders = z.infer<typeof LedgerSchema>;\ntype Entry = TurnRenders[\"creatives\"][string];\n\n/** Whether `entry` has had its renders or its time in this turn. */\nconst budgetSpent = (entry: Entry): boolean =>\n (entry.spentMs ?? 0) + RENDER_MS > AD_TURN_MS || entry.runs >= RUNS_PER_TURN;\n\n/**\n * Whether an ad past its budget may still have one correction: it still needs fixes and has not had\n * that one yet. Zernio, Oct 2026: automatic rounds failing one check took 9.5 minutes, and the\n * `--fix` the agent then ran was refused for time, the ad shown broken. Bounded: once a turn.\n */\nconst lastCorrectionDue = (entry: Entry, correction: boolean | undefined): boolean =>\n correction === true && entry.verdict === \"needs_fixes\" && entry.lastCorrection !== true;\n\nexport type TurnRenderRefusal = { code: \"CONFLICT\"; message: string; fix: string };\n\nconst SHOW_AS_IT_STANDS =\n \"Show the best version as a version (\\\"Version 3\\\"), never a file path or a run id, and say in one plain sentence what is left, in the person's words. End there: no question and no options; their next message says what changes.\";\n\n/**\n * Whether a run may still turn out to be a correction of the version shown (`turnRenderRefusal`),\n * known before the run reads or spends anything: a `--fix`, a `--regenerate`, or a prompt.json\n * changed since that version (an edit of its words or colours). Run again with nothing changed, a\n * ready ad is refused at once. `--use-variant` is the person's choice among the options, never a\n * defect: it comes with their next message, in a new turn. Pure.\n */\nexport function mayBeCorrection(\n run: { fix?: string; regenerate?: string; useVariant?: string },\n shownPrompt: unknown,\n promptOnDisk: unknown,\n): boolean {\n if (run.fix !== undefined || run.regenerate !== undefined) return true;\n return shownPrompt !== undefined && promptOnDisk != null && canonicalize(shownPrompt) !== canonicalize(promptOnDisk);\n}\n\n/**\n * Why this ad gets no further render in this turn, or null. A ready ad is never rendered anew (that\n * chased notes four renders deep), but a `correction` of the version shown (a `--fix`, a size laid\n * out again, prompt.json's words or colours edited: one edit grown on top of it) may answer a real\n * defect the agent sees, within the same renders and time as any other. Production, Oct 2026: an ad\n * with its logo drawn twice, `ready_with_notes`, could not be corrected and was saved as it was. An ad\n * that still needs fixes gets one correction past its budget (`lastCorrectionDue`). Pure.\n */\nexport function turnRenderRefusal(\n ledger: TurnRenders | undefined,\n turnId: string | undefined,\n slug: string,\n opts: { correction?: boolean; shape?: \"plate\" | \"relayout\" } = {},\n): TurnRenderRefusal | null {\n const entry = turnId !== undefined && ledger?.turnId === turnId ? ledger.creatives[slug] : undefined;\n if (!entry) return null;\n if ((entry.verdict === \"ready\" || entry.verdict === \"ready_with_notes\") && opts.correction !== true) {\n return {\n code: \"CONFLICT\",\n message: `This ad is already ready in this turn (${entry.verdict}): its notes are not defects, and new options are not made for them.`,\n fix: `Show it now. Only a real defect you can name in it (a logo drawn twice, a word wrong) is corrected in this turn: \\`baker canvas run --slug <slug> --fix \"<what to change>\"\\`, or \\`--regenerate ${opts.shape === \"relayout\" ? \"adapt\" : \"format\"}_<size>\\` for one size. Any other change comes with the person's next message.`,\n };\n }\n if (budgetSpent(entry) && lastCorrectionDue(entry, opts.correction)) return null;\n if ((entry.spentMs ?? 0) + RENDER_MS > AD_TURN_MS) {\n return {\n code: \"CONFLICT\",\n message: `This ad has had its ${AD_TURN_MS / 60_000} minutes in this turn, its automatic corrections included, and is still not ready.`,\n fix: SHOW_AS_IT_STANDS,\n };\n }\n if (entry.runs >= RUNS_PER_TURN) {\n return {\n code: \"CONFLICT\",\n message: `This ad was rendered twice in this turn, its automatic corrections included, and is still not ready.`,\n fix: SHOW_AS_IT_STANDS,\n };\n }\n return null;\n}\n\n/**\n * The ledger with one more render of `slug` that ended `verdict` after `tookMs`; a new turn starts it\n * afresh. A render started past the ad's budget was its one last correction, and is marked spent. Pure.\n */\nexport function recordTurnRender(\n ledger: TurnRenders | undefined,\n turnId: string,\n slug: string,\n verdict: StaticVerdict,\n tookMs?: number,\n): TurnRenders {\n const creatives = ledger?.turnId === turnId ? ledger.creatives : {};\n const entry = creatives[slug];\n const spentMs = (entry?.spentMs ?? 0) + (tookMs ?? 0);\n return {\n turnId,\n creatives: {\n ...creatives,\n [slug]: {\n ...entry,\n runs: (entry?.runs ?? 0) + 1,\n verdict,\n ...(spentMs > 0 ? { spentMs } : {}),\n ...(entry && budgetSpent(entry) ? { lastCorrection: true } : {}),\n },\n },\n };\n}\n\n/**\n * Whether a correction round of `kind` still fits `slug`'s time in this turn, this render having\n * taken `renderMs` so far. Outside a chat turn only this render counts. Pure.\n */\nexport function roundFitsTurn(\n ledger: TurnRenders | undefined,\n turnId: string | undefined,\n slug: string | undefined,\n renderMs: number,\n kind: AutoFixStep[\"kind\"],\n): boolean {\n const entry = turnId !== undefined && slug !== undefined && ledger?.turnId === turnId ? ledger.creatives[slug] : undefined;\n return (entry?.spentMs ?? 0) + renderMs + ROUND_MS[kind] <= AD_TURN_MS;\n}\n\n/** The ledger with one more failed viewer check of `slug`; a new turn starts it afresh. Pure. */\nexport function recordViewerFail(ledger: TurnRenders | undefined, turnId: string, slug: string): TurnRenders {\n const creatives = ledger?.turnId === turnId ? ledger.creatives : {};\n const entry = creatives[slug] ?? { runs: 0 };\n return { turnId, creatives: { ...creatives, [slug]: { ...entry, viewerFails: (entry.viewerFails ?? 0) + 1 } } };\n}\n\n/** Whether `slug` failed the viewer check often enough in this turn to render without being held back again. Pure. */\nexport function viewerChecksSpent(ledger: TurnRenders | undefined, turnId: string | undefined, slug: string): boolean {\n const entry = turnId !== undefined && ledger?.turnId === turnId ? ledger.creatives[slug] : undefined;\n return (entry?.viewerFails ?? 0) >= VIEWER_FAILS_PER_TURN;\n}\n\nconst ledgerPath = (cacheDir: string) => path.join(cacheDir, \"turn-renders.json\");\n\nexport async function readTurnRenders(cacheDir: string): Promise<TurnRenders | undefined> {\n try {\n const parsed = LedgerSchema.safeParse(JSON.parse(await readFile(ledgerPath(cacheDir), \"utf8\")));\n return parsed.success ? parsed.data : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Change the record under a lock, written whole through a rename: `--series` runs every ad's render\n * as its own process at once, and a plain read-then-write let each one overwrite the others' entries.\n */\nexport async function updateTurnRenders(\n cacheDir: string,\n change: (ledger: TurnRenders | undefined) => TurnRenders,\n): Promise<void> {\n await updateLockedFile(ledgerPath(cacheDir), async () => JSON.stringify(change(await readTurnRenders(cacheDir))));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,SAAAC,QAAO,SAAS,YAAAC,WAAU,MAAM,aAAAC,kBAAiB;AAC1D,OAAOC,WAAU;AAEjB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,iBAAiB;AACnC,SAAS,KAAAC,UAAS;;;ACXlB,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,iBAAiB;AAC3C,OAAO,UAAU;AACjB,SAAS,SAAS;AAEX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,QAAQ,EAAE,QAAQ;AAAA,EAClB,KAAK,EAAE,OAAO,EA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AAC;AACD;AAAA,MACF;AACA,UAAI,OAAQ,OAAM,kBAAkB,UAAU,CAAC,YAAY,iBAAiB,SAAS,QAAQ,IAAI,CAAC;AAClG,YAAM,UAAU,mBAAmB,SAAS,IAAI;AAChD,gBAAU,EAAE,GAAG,SAAS,OAAO,EAAE,GAAG,QAAQ,OAAO,GAAG,OAAO,EAAE,CAAC;AAChE,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,QAAI,QAAQ,WAAW,eAAe;AACpC,gBAAU;AAAA,QACR,IAAI;AAAA,QACJ,MAAM,EAAE,SAAS,OAAO,QAAQ,KAAK,GAAG,OAAO;AAAA,QAC/C,OAAO;AAAA,UACL;AAAA,QACF;AAAA,MACF,CAAC;AACD;AAAA,IACF;AACA,cAAU;AAAA,MACR,IAAI;AAAA,MACJ,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,OAAO,QAAQ,OAAO,MAAM;AAAA,QAC5B,UAAU,QAAQ,OAAO,SAAS;AAAA,QAClC,WAAW,QAAQ,OAAO,UAAU;AAAA,QACpC,GAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;AAAA,QACzC,GAAG;AAAA,MACL;AAAA,MACA,OAAO;AAAA,QACL,SAAS,SAAS,YACd,4MACA,mBAAmB,GAAG,wCAAwC,IAAI;AAAA,MACxE;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":["createHash","mkdir","readFile","writeFile","path","z","readFile","path","z","z","path","readFile","z","createHash","readFile","path","mkdir","writeFile"]}
1
+ {"version":3,"sources":["../src/commands/canvas/viewer-check.ts","../src/commands/canvas/casting-check.ts","../src/commands/canvas/turn-renders.ts"],"sourcesContent":["/**\n * Would the person this ad reaches understand it?\n *\n * A static ad is judged by who sees it. A production Session shipped a whiteboard reading\n * \"Reasons I joined the Club®\" to a prospecting ad set: a stranger does not know there is a\n * club, what it is, or that it is about driving jobs. Every check the run had passed it,\n * because they asked whether the words were spelled right, not whether anyone could tell\n * what was on offer. The same words would have been fine for someone who had been to the\n * site.\n *\n * So before anything is rendered, a model plays the viewer the ad set reaches (what they\n * already know, where they scroll) and says, from the words and the picture alone, what is\n * offered, to whom, and what to do next. The decision model (Jev), not the viewer, compares that\n * with what the concept means to say, in whatever language each is written. The viewer decides:\n * there is no rule about temperature.\n */\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { VIEWER_CHECK_MODEL } from \"@baker/canvas-contract\";\nimport { defineCommand } from \"citty\";\nimport { parse as parseYaml } from \"yaml\";\nimport { z } from \"zod\";\nimport { askJev } from \"../../engine/nodes/local/lib/jev.ts\";\nimport { askAboutText, type ReviewUsage } from \"../../engine/nodes/local/lib/render-review.ts\";\nimport { readAdSpec } from \"../../engine/scaffold/static-ad-spec.ts\";\nimport { requireCredentialsFromEnv } from \"../../engine/client/env.ts\";\nimport { HttpClient } from \"../../engine/client/http.ts\";\nimport { optionalTurnId } from \"../../env.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport {\n AWARENESS_VALUES,\n type Awareness,\n describeMarket,\n marketFromCompanyDoc,\n type ViewerMarket,\n viewerFromKnowledge,\n VIEWER_KNOWS_VALUES,\n VIEWER_SOURCE_VALUES,\n VIEWER_TEMPERATURE_VALUES,\n type ViewerProfile,\n} from \"../../viewer-profile.ts\";\nimport { readAudienceNames } from \"../../audience-names.ts\";\nimport { rememberedJev } from \"../../engine/lib/remembered-nouls.ts\";\nimport { adSetViewerRows, audienceNamesOf } from \"../ads/meta/adset-viewers.ts\";\nimport { companyLine, readCompanyReading } from \"../../engine/creative-context/company.ts\";\nimport { briefRules } from \"../../engine/creative-rules/select.ts\";\nimport { heldRules } from \"./rule-gate.ts\";\nimport { findWorkspaceRoot } from \"./normalize-paths.ts\";\nimport { holdUnbilledSpend } from \"./unbilled-spend.ts\";\nimport { type CastingOutcome, castingCheck, castingCheckFailure } from \"./casting-check.ts\";\nimport { readTurnRenders, recordViewerFail, updateTurnRenders, viewerChecksSpent } from \"./turn-renders.ts\";\n\nexport const VIEWER_QUESTIONS = [\"offer\", \"for_whom\", \"next_step\"] as const;\nexport type ViewerQuestion = (typeof VIEWER_QUESTIONS)[number];\n\nexport const VIEWER_CLARITY = [\"clear\", \"guess\", \"unclear\"] as const;\nexport type ViewerClarity = (typeof VIEWER_CLARITY)[number];\n\nconst ViewerReply = z.object({ answer: z.string().default(\"\"), clarity: z.enum(VIEWER_CLARITY) });\n\n/** What the viewer model answers: each question with how sure it is, and what it would need to be told. */\nexport const ViewerAnswerSchema = z.object({\n offer: ViewerReply,\n for_whom: ViewerReply,\n next_step: ViewerReply,\n /** The words that talk to the viewer as if they had already done something with the brand; \"\" when none. */\n presumes: z.string().default(\"\"),\n missing: z.string().default(\"\"),\n});\nexport type ViewerAnswer = z.infer<typeof ViewerAnswerSchema>;\n\n/** What the concept means the viewer to take away (`prompt.json` `message`, the persona it is written for). */\nexport type ViewerIntended = {\n offer?: string;\n persona?: string;\n /** What the company sells, in a few words (COMPANY.md's first line): a viewer sure of it read the offer. */\n sells?: string;\n};\n\nexport type ViewerMiss =\n | {\n question: ViewerQuestion;\n /** `unclear`: they could not tell. `guessed`: they had to infer it. `misread`: they were sure, and wrong. */\n reason: \"unclear\" | \"guessed\" | \"misread\";\n viewerSaid: string;\n intended?: string;\n }\n | {\n /** The ad talks to them as someone who already bought, signed up, tried or gave; they have not. */\n question: \"presumes\";\n reason: \"presumed\";\n /** The words that presume it. */\n viewerSaid: string;\n };\n\nexport type ViewerVerdict = { pass: boolean; missed: ViewerMiss[] };\n\n/**\n * The least each answer must reach. What is offered has to be said by the ad; what to do\n * next may be inferred (the platform's button carries it). Who it is for is asked, and goes\n * into the fix, but never fails an ad alone: on E8 (BENCH.md) it decided no ad that did not\n * work and failed ads that did, where the offer itself says who it is for (an Audi finance\n * deal). One table so the calibration set moves a threshold here, not in the judge.\n */\nexport const VIEWER_REQUIRED_CLARITY: Readonly<Record<ViewerQuestion, ViewerClarity>> = {\n offer: \"clear\",\n for_whom: \"unclear\",\n next_step: \"guess\",\n};\n\nconst RANK: Readonly<Record<ViewerClarity, number>> = { unclear: 0, guess: 1, clear: 2 };\n\n/** A reply at least as sure as `least`. Pure. */\nexport const sureEnough = (clarity: ViewerClarity, least: ViewerClarity): boolean => RANK[clarity] >= RANK[least];\n\n/**\n * At or above this, the decision model says the viewer read the offer the ad means. Measured on\n * 30 readings in 9 languages (scripts/viewer-read-evals): read 0.77–0.98, misread 0.26 or less.\n */\nexport const OFFER_READ = 0.5;\n\nconst READ_QUESTION =\n \"A viewer said an ad offers `viewer_said`; the ad means `meant`. Does `viewer_said` name the same thing on offer as `meant`, in other words or in another language? A general kind of thing that covers it counts (delivery driver jobs for van driving work).\";\nconst SELLS_QUESTION =\n \"A viewer said an ad offers `viewer_said`. Is `viewer_said` about what `company_sells` describes: the same product or service, a part of it, or a step toward buying it (a quote, a survey, a trial), in any language?\";\n\n/** For each reading, the probability it names what the ad means (or what the company sells); null when no judgment came back. */\nexport type ReadJudge = (\n pairs: ReadonlyArray<{ said: string; meant: string; sells?: string }>,\n) => Promise<number[] | null>;\n\n/**\n * The decision model as the judge, its spend reported to `onSpend`: one Noul against what the ad\n * means and one against what the company sells, the higher kept. A message written as a promise\n * or a belief names no product, and a viewer who named the product read it (Dev, Oct 2026).\n */\nexport function jevReadJudge(onSpend?: (usage: ReviewUsage) => void): ReadJudge {\n return async (pairs) => {\n const questions = pairs.flatMap((p): Array<{ instructions: Record<string, string> }> => [\n { instructions: { viewer_said: p.said, meant: p.meant, question: READ_QUESTION } },\n ...(p.sells ? [{ instructions: { viewer_said: p.said, company_sells: p.sells, question: SELLS_QUESTION } }] : []),\n ]);\n const answers = await askJev(questions, onSpend);\n if (answers === null) return null;\n let next = 0;\n return pairs.map((p) => {\n const meant = answers[next++] ?? 0;\n return p.sells ? Math.max(meant, answers[next++] ?? 0) : meant;\n });\n };\n}\n\n/**\n * Which of the viewer's readings name something other than what the ad means: the decision model\n * reads both in whatever language each is written (the viewer answers in English; the ad's message\n * is in the ad's). A pair with nothing to compare, or no judgment at all, is never a misreading: the\n * check does not refuse an ad on a guess. One request for every pair.\n */\nexport async function misreadings(\n pairs: ReadonlyArray<{ said: string; meant?: string | undefined; sells?: string | undefined }>,\n judge: ReadJudge,\n): Promise<boolean[]> {\n const asked = pairs.flatMap((p, i) =>\n p.said.trim() && p.meant?.trim()\n ? [{ i, pair: { said: p.said.trim(), meant: p.meant.trim(), ...(p.sells?.trim() ? { sells: p.sells.trim() } : {}) } }]\n : [],\n );\n const out = pairs.map(() => false);\n if (asked.length === 0) return out;\n const judged = await judge(asked.map((a) => a.pair)).catch(() => null);\n if (judged === null) return out;\n asked.forEach((a, k) => {\n const p = judged[k];\n out[a.i] = p !== undefined && p < OFFER_READ;\n });\n return out;\n}\n\n/** Whether the viewer understood the ad well enough, and what they missed. Pure. */\nexport function judgeViewerAnswer(\n answer: ViewerAnswer,\n intended: ViewerIntended,\n required: Readonly<Record<ViewerQuestion, ViewerClarity>> = VIEWER_REQUIRED_CLARITY,\n /** The decision model said the viewer, sure of the offer, named something else (`misreadings`). */\n offerMisread = false,\n): ViewerVerdict {\n const missed: ViewerMiss[] = [];\n for (const question of VIEWER_QUESTIONS) {\n const reply = answer[question];\n const meant = question === \"offer\" ? intended.offer : question === \"for_whom\" ? intended.persona : undefined;\n const withIntended = meant ? { intended: meant } : {};\n if (RANK[reply.clarity] < RANK[required[question]]) {\n missed.push({\n question,\n reason: reply.clarity === \"unclear\" ? \"unclear\" : \"guessed\",\n viewerSaid: reply.answer,\n ...withIntended,\n });\n } else if (question === \"offer\" && offerMisread) {\n // Only the offer is compared: who an ad is for is said in too many ways\n // (\"unemployed men 25-45\" vs \"people looking for driving work\") to hold against an ad.\n missed.push({ question, reason: \"misread\", viewerSaid: reply.answer, ...withIntended });\n }\n }\n if (answer.presumes.trim()) missed.push({ question: \"presumes\", reason: \"presumed\", viewerSaid: answer.presumes.trim() });\n return { pass: missed.length === 0, missed };\n}\n\n// --- The viewer's question ---\n\n/** One line of the ad's copy, the thing in the picture it is written on when lettered in the scene, and its role. */\nexport type ViewerCopyLine = { text: string; on?: string; role?: string };\n\n/** Roles a glance never reads: the small print. */\nconst SMALL_PRINT = /^(fine_print|legal|disclaimer|footnote)$/;\n\n/** Everything the viewer check reads: what is on the ad, who sees it, and what it means to say. */\nexport type ViewerCheckInput = {\n copy: ViewerCopyLine[];\n /** The picture, in words (`prompt.json` scene). */\n scene: string;\n /** The advertiser's name, which the platform prints above every ad. */\n brand?: string;\n viewer: ViewerProfile;\n intended: ViewerIntended;\n};\n\n/** Where the viewer meets the ad. Advantage+ (\"automatic\") includes Stories and Reels. */\nfunction wherePhrase(placements: readonly string[]): string {\n const fullScreen = placements.length === 0 || placements.some((p) => /automatic|stor|reel/i.test(p));\n return fullScreen\n ? \"full screen through Instagram or Facebook Stories and Reels, thumb ready to swipe\"\n : \"through your Instagram or Facebook feed\";\n}\n\n/**\n * What the viewer already knows, in their own terms. Only a viewer who knows the offer is told it.\n * The advertiser is never named: a stranger does not know whose ad it is, so the words must say it.\n */\nfunction knowledgePhrase(viewer: ViewerProfile, offer: string | undefined): string {\n const brand = \"the advertiser\";\n if (!viewer.knows.includes(\"brand\")) return `You have never heard of ${brand} and know nothing about what it sells.`;\n const offerPart = viewer.knows.includes(\"offer\")\n ? offer\n ? ` You know what they offer: ${offer}.`\n : \" You know what they offer.\"\n : \" You do not know what they are offering right now.\";\n const product = viewer.knows.includes(\"product\") ? \" You have used what they sell.\" : \"\";\n return `You have come across ${brand} before.${offerPart}${product}`;\n}\n\n/**\n * The viewer model's prompt. Written to the reader guidance for Gemini 3 text models\n * (`.context/prompting-google-gemini-image.md` §2, §7): short, the purpose stated, the data\n * first and the question last, the answer a fixed JSON the code grades — the model is never\n * asked whether the ad \"works\", only what it understood. Pure.\n */\nexport function buildViewerPrompt(input: ViewerCheckInput): string {\n const brand = \"the advertiser\";\n // Only a stranger can be talked to as a returning customer by mistake: retargeting copy\n // (\"still in your cart\", \"thanks for your donation last winter\") is right for the viewer who knows the brand.\n const stranger = !input.viewer.knows.includes(\"brand\");\n // A glance reads the big words and skips the small print.\n const read = input.copy.filter((line) => !SMALL_PRINT.test((line.role ?? \"\").trim().toLowerCase().replace(/[\\s-]+/g, \"_\")));\n const words =\n read.length > 0\n ? read.map((line) => `- \"${line.text}\"${line.on ? ` (written on the ${line.on})` : \"\"}`).join(\"\\n\")\n : \"- none: the picture is the whole ad\";\n return [\n `${input.viewer.market ? `You are ${describeMarket(input.viewer.market)}.` : \"You live where this ad runs and read its language natively.\"} You are scrolling ${wherePhrase(input.viewer.placements)}. ${knowledgePhrase(input.viewer, input.intended.offer)}`,\n `An ad from an advertiser whose name means nothing to you holds you for about three seconds: you take in the picture and read the biggest words, not every line. This is what you see, plus the platform's usual button under it (such as \"Learn more\"):`,\n \"\",\n `Picture: ${input.scene.trim()}`,\n \"Words on it:\",\n words,\n \"\",\n \"Answer as this person, from those words, that picture and what you already know. Do not fill gaps with what ads like this usually sell.\",\n 'For each question give your answer in English and how sure you are: \"clear\" when the words or the picture say it outright, or you already know it; \"guess\" when you are piecing it together from someone else\\'s story or review, a list of perks, a statistic or the advertiser\\'s name; \"unclear\" when you cannot tell.',\n \"offer: what is being offered?\",\n \"for_whom: who is it for?\",\n \"next_step: what would you do next if you wanted it?\",\n ...(stranger\n ? [\n `presumes: quote the words that say you have already done something with ${brand} (bought, signed up, started a trial, an order or a registration, donated, left something in a basket); words that only speak to you, or say what you would get, do not count; \"\" when none do.`,\n ]\n : []),\n 'missing: in one short sentence, what you would need to be told to get it; \"\" when nothing.',\n \"\",\n `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\"},${stranger ? '\"presumes\":\"\",' : \"\"}\"missing\":\"\"}`,\n ].join(\"\\n\");\n}\n\n/**\n * The cache key of one viewer check: the words, the picture, the viewer (what they know and\n * where they scroll, not how that was explained), what the ad means to say, the model, and\n * the prompt itself, so a rewritten prompt asks again. Pure.\n */\nexport function viewerCheckCacheKey(input: ViewerCheckInput, model: string): string {\n const { temperature, knows, placements, market } = input.viewer;\n const canonical = {\n prompt: buildViewerPrompt({ ...input, viewer: { ...input.viewer, reasons: [] } }),\n viewer: { temperature, knows: [...knows].sort(), placements: [...placements].sort(), ...(market ? { market } : {}) },\n intended: input.intended,\n model,\n };\n return createHash(\"sha256\").update(JSON.stringify(canonical)).digest(\"hex\");\n}\n\n/** The model boundary: the parsed JSON reply to one prompt, or null when no model answered. */\nexport type AskViewerModel = (prompt: string) => Promise<unknown>;\n\ntype JudgedViewerCheck = {\n input: ViewerCheckInput;\n answer: ViewerAnswer;\n verdict: ViewerVerdict;\n /** The answer came from the cache: nothing was asked or paid for. */\n cached: boolean;\n};\n\nexport type ViewerCheckOutcome =\n | (JudgedViewerCheck & { status: \"passed\" })\n | (JudgedViewerCheck & { status: \"failed\" })\n | { status: \"unavailable\"; input: ViewerCheckInput };\n\nasync function cachedAnswer(file: string): Promise<ViewerAnswer | null> {\n try {\n const parsed = ViewerAnswerSchema.safeParse(JSON.parse(await readFile(file, \"utf8\")));\n return parsed.success ? parsed.data : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Ask the viewer, or read the answer this exact ad and viewer already got, and grade it.\n * The answer is what is cached, not the verdict, so a change to the judge re-grades for\n * free. A model that does not answer (twice) or answers out of shape is `unavailable`:\n * the caller lets the render through and says it was not checked.\n */\nexport async function checkViewer(\n input: ViewerCheckInput,\n opts: {\n cacheDir: string;\n model: string;\n ask: AskViewerModel;\n /** Whether the viewer read the offer the ad means (`misreadings`); the decision model unless given. */\n judge?: ReadJudge;\n },\n): Promise<ViewerCheckOutcome> {\n const file = path.join(opts.cacheDir, \"viewer-check\", `${viewerCheckCacheKey(input, opts.model)}.json`);\n let answer = await cachedAnswer(file);\n const cached = answer !== null;\n const prompt = buildViewerPrompt(input);\n for (let attempt = 0; answer === null && attempt < 2; attempt++) {\n const parsed = ViewerAnswerSchema.safeParse(await opts.ask(prompt));\n if (parsed.success) answer = parsed.data;\n }\n if (answer === null) return { status: \"unavailable\", input };\n if (!cached) {\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${JSON.stringify(answer, null, 2)}\\n`, \"utf8\");\n }\n // Only a viewer sure enough of the offer can have misread it.\n const sure = sureEnough(answer.offer.clarity, VIEWER_REQUIRED_CLARITY.offer);\n const [offerMisread = false] = sure\n ? await misreadings(\n [{ said: answer.offer.answer, meant: input.intended.offer, sells: input.intended.sells }],\n opts.judge ?? jevReadJudge(),\n )\n : [];\n const verdict = judgeViewerAnswer(answer, input.intended, VIEWER_REQUIRED_CLARITY, offerMisread);\n const judged = { input, answer, verdict, cached };\n return verdict.pass ? { ...judged, status: \"passed\" } : { ...judged, status: \"failed\" };\n}\n\n/** The viewer in one phrase, for the agent: \"a cold viewer who knows nothing about the brand yet, on automatic placements\". */\nexport function describeViewer(viewer: ViewerProfile): string {\n const known = viewer.knows.map((k) => `the ${k}`);\n const knows =\n known.length > 0\n ? `who knows ${known.length > 1 ? `${known.slice(0, -1).join(\", \")} and ${known.at(-1)}` : known[0]}`\n : \"who knows nothing about the brand yet\";\n return `a ${viewer.temperature} viewer ${knows}, on ${viewer.placements.join(\", \") || \"automatic\"} placements`;\n}\n\nconst QUESTION_WORDS: Readonly<Record<ViewerQuestion, string>> = {\n offer: \"what is offered\",\n for_whom: \"who it is for\",\n next_step: \"what to do next\",\n};\n\nfunction missLine(miss: ViewerMiss): string {\n if (miss.question === \"presumes\") {\n return `The words talk to them as if they had already done something with the brand: \"${miss.viewerSaid}\". They have not.`;\n }\n const said = miss.viewerSaid.trim() ? `\"${miss.viewerSaid.trim()}\"` : \"nothing\";\n const how =\n miss.reason === \"misread\"\n ? `was sure it is ${said}`\n : miss.reason === \"guessed\"\n ? `could only guess ${said}`\n : `could not tell (said ${said})`;\n const question = QUESTION_WORDS[miss.question];\n return `${question.charAt(0).toUpperCase()}${question.slice(1)}: they ${how}${miss.intended ? `; the ad means \"${miss.intended}\"` : \"\"}.`;\n}\n\n/** The `{ ok: false, error }` a failed check prints: what the viewer missed, and the rewrite that fixes it. Pure. */\nexport function viewerCheckFailure(\n outcome: Extract<ViewerCheckOutcome, { status: \"failed\" }>,\n slug: string,\n): { ok: false; error: { code: \"viewer_check_failed\"; message: string; fix: string; viewer: ViewerProfile; missed: ViewerMiss[] } } {\n const { viewer } = outcome.input;\n const who = describeViewer(viewer);\n const missing = outcome.answer.missing.trim();\n const unsaid = outcome.verdict.missed.flatMap((m) => (m.question === \"presumes\" ? [] : [QUESTION_WORDS[m.question]]));\n // The one rewrite that answers a missed offer, so it takes one edit, not seven (dev, Oct 2026).\n const offer = outcome.input.intended.offer?.trim();\n const rewrite =\n offer && outcome.verdict.missed.some((m) => m.question === \"offer\")\n ? [`Do this: make the biggest words say \"${offer}\", plainly, in the ad's language; keep the rest.`]\n : [];\n const fix = [\n ...rewrite,\n ...(unsaid.length > 0 ? [`Seen by ${who}, the words and picture alone do not say ${unsaid.join(\" or \")}.`] : [`Seen by ${who}:`]),\n ...outcome.verdict.missed.map(missLine),\n ...(missing ? [`They needed: ${missing}`] : []),\n \"Rewrite the copy in prompt.json so the words on the ad say it plainly (name the offer and who it is for; a stranger reads only what is printed), then re-run.\",\n // The run asks the viewer itself, from the same cache: a separate check is one more wait (dev, Oct 2026).\n `Then run the same \\`baker canvas run\\` again: it checks the new copy before it spends (or \\`baker canvas viewer-check ${slug}\\` alone).`,\n \"If this ad will run to people who already know the brand, record that viewer in _definition.md (`targetAdSet` and `viewer`, from `baker ads meta adsets --audience`) instead of rewriting.\",\n ].join(\" \");\n return {\n ok: false,\n error: {\n code: \"viewer_check_failed\",\n message: `Not rendered: ${who} would not understand this ad.`,\n fix,\n viewer,\n missed: outcome.verdict.missed,\n },\n };\n}\n\n// --- Who sees the ad ---\n\n/** The `viewer` a `_definition.md` records, as `baker ads meta adsets --audience` prints it. */\nconst RecordedViewer = z.object({\n temperature: z.enum(VIEWER_TEMPERATURE_VALUES),\n knows: z.array(z.enum(VIEWER_KNOWS_VALUES)).default([]),\n placements: z.array(z.string().min(1)).default([\"automatic\"]),\n source: z.enum(VIEWER_SOURCE_VALUES),\n reasons: z.array(z.string()).default([]),\n market: z\n .object({\n country: z.string().min(2),\n language: z.string().optional(),\n currency: z.string().optional(),\n address: z.string().optional(),\n })\n .optional(),\n});\n\n/** What a creative says about who will see it: `_definition.md`'s `viewer`, `targetAdSet`, `persona`, `awareness`. */\nexport type ViewerSources = { recorded?: unknown; targetAdSet?: string; persona?: string; awareness?: Awareness };\n\n/** One persona in the Knowledge (`src/content/personas/`): its file name, title and `segment`. */\nexport type PersonaEntry = { slug: string; title?: string; segment?: string };\n\n/** The reads resolving a viewer may need. Injected so the order is tested without an ad account. */\nexport type ViewerLookups = {\n /** The viewer the ad set reaches (`classifyAudience`), or null when no connected account holds it. */\n adSetViewer: (adSetId: string) => Promise<ViewerProfile | null>;\n personas: () => Promise<PersonaEntry[]>;\n /** The market COMPANY.md names (`marketFromCompanyDoc`), for a viewer read with none. */\n companyMarket?: () => Promise<ViewerMarket | undefined>;\n /** What the company sells, from its reading, for the casting check. */\n company?: () => Promise<string>;\n /** The company's rules about who appears that hold for this ad (its scope, its waivers), for the casting check. */\n castRules?: (creativeDir: string) => Promise<string[]>;\n};\n\nexport type ResolvedViewer = {\n viewer: ViewerProfile;\n from: \"recorded\" | \"ad_set\" | \"knowledge\" | \"default\";\n /** What could not be read on the way, in the order it was tried. */\n notes: string[];\n};\n\n/** A name as it compares: accents and case off, words only (\"Pet-owners\" and \"pet owners\" alike). */\nconst nameKey = (text: string): string =>\n text\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .toLowerCase()\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter(Boolean)\n .join(\" \");\n\n/**\n * The segments the concept is written for: the persona the creative names, matched to its\n * entry in the Knowledge by file name, title or segment (or taken as written when none\n * matches); every persona on file when it names none. Pure.\n */\nexport function personaSegments(persona: string | undefined, entries: readonly PersonaEntry[]): string[] {\n const describe = (entry: PersonaEntry) => entry.segment ?? entry.title ?? entry.slug;\n if (!persona?.trim()) return entries.map(describe);\n const wanted = nameKey(persona);\n const match = entries.find((entry) =>\n [entry.slug.replace(/[-_]/g, \" \"), entry.title, entry.segment].some((name) => name && nameKey(name) === wanted),\n );\n return [match ? describe(match) : persona.trim()];\n}\n\n/**\n * The viewer an ad is checked against, in this order: the one recorded in `_definition.md`;\n * the one its `targetAdSet` reaches; the one the Knowledge describes (personas and the\n * concept's awareness); a cold stranger, saying so.\n */\nexport async function resolveViewer(sources: ViewerSources, lookups: ViewerLookups): Promise<ResolvedViewer> {\n const resolved = await resolveViewerAlone(sources, lookups);\n if (resolved.viewer.market || !lookups.companyMarket) return resolved;\n const market = await lookups.companyMarket().catch(() => undefined);\n return market ? { ...resolved, viewer: { ...resolved.viewer, market } } : resolved;\n}\n\nasync function resolveViewerAlone(sources: ViewerSources, lookups: ViewerLookups): Promise<ResolvedViewer> {\n const notes: string[] = [];\n if (sources.recorded !== undefined) {\n const recorded = RecordedViewer.safeParse(sources.recorded);\n if (recorded.success) return { viewer: recorded.data, from: \"recorded\", notes };\n notes.push(\"The viewer recorded in _definition.md is not in the shape `baker ads meta adsets --audience` prints; it was skipped.\");\n }\n if (sources.targetAdSet) {\n try {\n const fromAdSet = await lookups.adSetViewer(sources.targetAdSet);\n if (fromAdSet) return { viewer: fromAdSet, from: \"ad_set\", notes };\n notes.push(`Ad set ${sources.targetAdSet} is not in any connected Meta ad account.`);\n } catch (e) {\n notes.push(`Could not read ad set ${sources.targetAdSet} (${e instanceof Error ? e.message : String(e)}).`);\n }\n }\n let entries: PersonaEntry[] = [];\n try {\n entries = await lookups.personas();\n } catch (e) {\n notes.push(`Could not read the personas in the Knowledge (${e instanceof Error ? e.message : String(e)}).`);\n }\n const personas = personaSegments(sources.persona, entries);\n if (personas.length > 0 || sources.awareness) {\n return { viewer: viewerFromKnowledge({ personas, awareness: sources.awareness }), from: \"knowledge\", notes };\n }\n return {\n viewer: {\n temperature: \"cold\",\n knows: [],\n placements: [\"automatic\"],\n source: \"knowledge\",\n reasons: [\n \"Nothing says who will see this ad (no viewer or targetAdSet in _definition.md, no persona in the Knowledge), so it is checked against a cold stranger who has never heard of the brand.\",\n ],\n },\n from: \"default\",\n notes,\n };\n}\n\n// --- Reading a creative ---\n\n/** The ad as the viewer check reads it, before the viewer is known, and the people it casts (D2). */\nexport type CreativeAd = Omit<ViewerCheckInput, \"viewer\"> & { people?: string[] };\n\nconst Frontmatter = z.object({\n viewer: z.unknown().optional(),\n targetAdSet: z.union([z.string(), z.number()]).transform(String).optional(),\n persona: z.string().optional(),\n awareness: z.enum(AWARENESS_VALUES).optional().catch(undefined),\n angle: z.string().optional(),\n});\n\nfunction frontmatterOf(raw: string): z.infer<typeof Frontmatter> {\n const block = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1];\n if (!block) return {};\n try {\n const parsed = Frontmatter.safeParse(parseYaml(block));\n return parsed.success ? parsed.data : {};\n } catch {\n return {};\n }\n}\n\n/**\n * A creative folder read for the viewer check: the words, the picture and the brand from\n * `prompt.json` (an ad spec or an older blueprint, through `readAdSpec`), what the ad means\n * to say (`message`, else the definition's `angle`; the spec's viewer, else the `persona`),\n * and what `_definition.md` says about who will see it. Throws when `prompt.json` cannot be\n * read: there is no ad to check.\n */\nexport async function readCreativeForViewerCheck(creativeDir: string): Promise<{ ad: CreativeAd; sources: ViewerSources }> {\n const spec = readAdSpec(JSON.parse(await readFile(path.join(creativeDir, \"prompt.json\"), \"utf8\")));\n const definition = frontmatterOf(await readFile(path.join(creativeDir, \"_definition.md\"), \"utf8\").catch(() => \"\"));\n const offer = spec.message?.trim() || definition.angle?.trim();\n const persona = spec.viewer?.who.trim() || definition.persona?.trim();\n const brand = spec.brand?.name?.trim();\n // src/creatives/<slug>/ → the workspace, whose company reading says what it sells.\n const sells = (await readCompanyReading(path.resolve(creativeDir, \"../../..\")))?.sells;\n return {\n ad: {\n copy: spec.copy.map((line) => ({\n text: line.text,\n ...(line.lettering === \"in_scene\" && line.on ? { on: line.on } : {}),\n ...(line.role ? { role: line.role } : {}),\n })),\n scene: spec.scene.description,\n ...(brand ? { brand } : {}),\n intended: { ...(offer ? { offer } : {}), ...(persona ? { persona } : {}), ...(sells ? { sells } : {}) },\n ...castPeople(spec),\n },\n sources: {\n ...(definition.viewer !== undefined ? { recorded: definition.viewer } : {}),\n ...(definition.targetAdSet ? { targetAdSet: definition.targetAdSet } : {}),\n ...(definition.persona?.trim() ? { persona: definition.persona.trim() } : {}),\n ...(definition.awareness ? { awareness: definition.awareness } : {}),\n },\n };\n}\n\n/** The people a spec casts (from an avatar, or a picture of ours), in words, for the casting check. */\nfunction castPeople(spec: ReturnType<typeof readAdSpec>): { people?: string[] } {\n const people = spec.references\n .filter((r) => r.role === \"identity\" && (r.avatar || r.image) && !/^ANIMAL_/.test(r.id))\n .map((r) => r.what);\n return people.length > 0 ? { people } : {};\n}\n\n/** The personas in the Knowledge (`src/content/personas/**.md`), each with its `segment` and `# title`. */\nexport async function readPersonas(workspaceRoot: string): Promise<PersonaEntry[]> {\n const dir = path.join(workspaceRoot, \"src\", \"content\", \"personas\");\n let files: string[];\n try {\n files = (await readdir(dir, { recursive: true })).filter((f) => f.endsWith(\".md\"));\n } catch {\n return [];\n }\n return await Promise.all(\n files.map(async (file) => {\n const raw = await readFile(path.join(dir, file), \"utf8\");\n const block = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)?.[1];\n let segment: unknown;\n try {\n segment = block ? (parseYaml(block) as { segment?: unknown } | null)?.segment : undefined;\n } catch {\n segment = undefined;\n }\n const title = raw.match(/^#\\s+(.+)$/m)?.[1]?.trim();\n return {\n slug: path.basename(file, \".md\"),\n ...(title ? { title } : {}),\n ...(typeof segment === \"string\" && segment.trim() ? { segment: segment.trim() } : {}),\n };\n }),\n );\n}\n\n// --- Live reads ---\n\ntype MetaRow = Record<string, unknown>;\n\n/** One read of the Baker API, as the viewer lookups make it. */\ntype BakerRead = <T>(apiPath: string, params?: Record<string, string>) => Promise<T>;\n\n/**\n * Reads through the canvas engine's client, built from the connection alone: the CLI's\n * `apiGet` validates every optional override and ends the process on a malformed one, and\n * the render reads only the connection (`requireConnection`) so an unrelated override cannot\n * stop it. A missing connection throws here, and the lookup says so as a note.\n */\nfunction bakerRead(): BakerRead {\n const creds = requireCredentialsFromEnv();\n const http = new HttpClient({ baseUrl: creds.url, apiKey: creds.apiKey, timeoutMs: 60_000, maxRetries: 1 });\n return (apiPath, params) => http.getJson(params ? `${apiPath}?${new URLSearchParams(params)}` : apiPath);\n}\n\n/** The Meta ad accounts to look an ad set up in: the one the Runtime names, else the connected ones. */\nasync function metaAccountIds(read: BakerRead): Promise<string[]> {\n const named = process.env.BAKER_META_AD_ACCOUNT_ID;\n if (named) return [named];\n const accounts = await read<Array<{ externalId?: unknown; id?: unknown }>>(\"/api/ads/meta/accounts\");\n return accounts.flatMap((a) => {\n const id = a.externalId ?? a.id;\n return typeof id === \"string\" && id ? [id] : [];\n });\n}\n\n/** The viewer one Meta ad set reaches, read as `baker ads meta adsets --audience` reads it. */\nasync function metaAdSetViewer(adSetId: string, workspaceRoot: string): Promise<ViewerProfile | null> {\n const read = bakerRead();\n for (const account of (await metaAccountIds(read)).slice(0, 5)) {\n const params = { \"account-id\": account.startsWith(\"act_\") ? account : `act_${account}` };\n const adSet = (await read<MetaRow[]>(\"/api/ads/meta/adsets\", params)).find((row) => String(row.id) === adSetId);\n if (!adSet) continue;\n // The audience list and the objectives only sharpen the read, as in `adsets --audience`.\n const [audiences, campaigns] = await Promise.all([\n read<MetaRow[]>(\"/api/ads/meta/audiences\", params).catch(() => []),\n read<MetaRow[]>(\"/api/ads/meta/campaigns\", params).catch(() => []),\n ]);\n const cacheDir = path.join(workspaceRoot, \"canvas\", \".cache\");\n const spent: ReviewUsage[] = [];\n const readName = await readAudienceNames(\n audienceNamesOf([adSet], audiences),\n rememberedJev(path.join(cacheDir, \"audience-names.json\"), (u) => spent.push(u)),\n );\n await holdUnbilledSpend(cacheDir, spent).catch(() => undefined);\n return adSetViewerRows([adSet], audiences, campaigns, readName)[0]?.viewer ?? null;\n }\n return null;\n}\n\n/** The rules the casting question is told at most: who appears is a few lines of any brand's rules. */\nconst CAST_RULES = 8;\n\n/** The reads a real check makes: the Meta ad set through the API, the personas from the workspace. */\nexport function liveViewerLookups(workspaceRoot: string): ViewerLookups {\n return {\n adSetViewer: (adSetId) => metaAdSetViewer(adSetId, workspaceRoot),\n personas: () => readPersonas(workspaceRoot),\n companyMarket: async () =>\n marketFromCompanyDoc(await readFile(path.join(workspaceRoot, \"COMPANY.md\"), \"utf8\").catch(() => null)),\n company: async () => companyLine(await readCompanyReading(workspaceRoot)),\n // Who appears, as the rules that hold for this ad say: a person's on its picture or cast, the brand's on\n // its cast only (a brand document's picture rules are often its web design system's: `briefRules`).\n castRules: async (creativeDir) =>\n briefRules((await heldRules(creativeDir)).rules)\n .filter((r) => r.applies === \"cast\" || (r.origin === \"learned\" && r.applies === \"picture\"))\n .slice(0, CAST_RULES)\n .map((r) => r.text),\n };\n}\n\n/** The viewer model through the gateway, its spend reported to `onSpend`. */\nexport function gatewayViewerModel(model: string, onSpend?: (usage: ReviewUsage) => void): AskViewerModel {\n return (prompt) => askAboutText(model, prompt, onSpend);\n}\n\n// --- Before a render ---\n\n/** Why a render goes without asking the viewer: a correction or a resumed render of an ad already checked, or the person's own call. */\nexport type ViewerCheckSkip = \"fix\" | \"resume\" | \"asked\" | null;\n\nconst SKIP_WORDS: Readonly<Record<Exclude<ViewerCheckSkip, null>, string>> = {\n fix: \"a correction of a version already checked\",\n resume: \"a resumed render, checked when it started\",\n asked: \"--skip-viewer-check\",\n};\n\n/**\n * Why this render goes without asking the viewer, or null to ask: a correction (`--fix`, an autofix\n * round), a chosen option and a re-layout keep words already checked; an edit of the words is\n * asked about, since what it changed is what the viewer reads. Pure.\n */\nexport function viewerCheckSkip(run: {\n fix: boolean;\n useVariant: boolean;\n relaid: boolean;\n autoFixRound: number;\n resumed: boolean;\n asked: boolean;\n}): ViewerCheckSkip {\n if (run.fix || run.useVariant || run.relaid || run.autoFixRound > 0) return \"fix\";\n if (run.resumed) return \"resume\";\n return run.asked ? \"asked\" : null;\n}\n\nexport type PreRenderViewerCheck = {\n /** Who the ad is checked against, for the review after the render; null when the ad could not be read. */\n viewer: ViewerProfile | null;\n /** What to print on the run log. */\n lines: string[];\n /** Set when the viewer would not understand the ad, or its people would not pass: print it and exit 2, before anything is spent. */\n failure?: ReturnType<typeof viewerCheckFailure> | ReturnType<typeof castingCheckFailure>;\n};\n\n/**\n * The check `baker canvas run` makes on a static ad before it spends: resolve the viewer,\n * ask them (from the cache when this ad and viewer were asked before), and refuse the\n * render when they would not understand it. A correction, a resumed render and an explicit\n * skip still resolve the viewer (the review after the render reads it) but ask nothing. A\n * model that does not answer lets the render through, saying so.\n */\nexport async function viewerCheckBeforeRender(opts: {\n creativeDir: string;\n cacheDir: string;\n slug: string;\n skip: ViewerCheckSkip;\n /** This ad already failed the viewer twice in this turn (`viewerChecksSpent`): a miss is said, never held against the render. */\n spent?: boolean;\n lookups: ViewerLookups;\n model: string;\n ask: AskViewerModel;\n /** Whether the viewer read the offer (`misreadings`); the decision model unless given. */\n judge?: ReadJudge;\n}): Promise<PreRenderViewerCheck> {\n let creative: Awaited<ReturnType<typeof readCreativeForViewerCheck>>;\n try {\n creative = await readCreativeForViewerCheck(opts.creativeDir);\n } catch (e) {\n return {\n viewer: null,\n lines: [`[warn] viewer_check_skipped: prompt.json could not be read for the viewer check (${e instanceof Error ? e.message : String(e)}).`],\n };\n }\n const resolved = await resolveViewer(creative.sources, opts.lookups);\n const who = describeViewer(resolved.viewer);\n const lines = resolved.notes.map((note) => `[viewer] ${note}`);\n if (opts.skip) return { viewer: resolved.viewer, lines: [...lines, `[viewer] not asked: ${SKIP_WORDS[opts.skip]}.`] };\n // Who is cast, against who buys and where it runs (D2): asked alongside the viewer, never after it.\n const casting = (async () =>\n castingCheck(\n {\n people: creative.ad.people ?? [],\n company: (await opts.lookups.company?.().catch(() => \"\")) ?? \"\",\n rules: (await opts.lookups.castRules?.(opts.creativeDir).catch(() => [])) ?? [],\n ...(resolved.viewer.market ? { market: describeMarket(resolved.viewer.market) } : {}),\n ...(creative.ad.intended.persona ? { persona: creative.ad.intended.persona } : {}),\n },\n { cacheDir: opts.cacheDir, model: opts.model, ask: opts.ask },\n ))().catch((): CastingOutcome => ({ status: \"unavailable\" }));\n const outcome = await checkViewer({ ...creative.ad, viewer: resolved.viewer }, opts);\n if (outcome.status === \"unavailable\") {\n lines.push(\n `[warn] viewer_check_unavailable: the viewer model did not answer, so this ad renders without the viewer check. Read the copy as ${who} before showing it, or run \\`baker canvas viewer-check ${opts.slug}\\` again.`,\n );\n } else if (outcome.status === \"failed\" && !opts.spent) {\n return { viewer: resolved.viewer, lines, failure: viewerCheckFailure(outcome, opts.slug) };\n } else if (outcome.status === \"failed\") {\n lines.push(\n `[viewer] this ad failed the viewer check twice in this turn, so it renders as written. Tell the person what ${who} missed: ${outcome.verdict.missed.map(missLine).join(\" \")}`,\n );\n } else {\n lines.push(`[viewer] ${who} understood it: ${outcome.answer.offer.answer}${outcome.cached ? \" (cached)\" : \"\"}.`);\n }\n if (outcome.status === \"unavailable\") return { viewer: resolved.viewer, lines };\n const cast = await casting;\n if (cast.status === \"failed\") return { viewer: resolved.viewer, lines, failure: castingCheckFailure(cast.answer, opts.slug) };\n if (cast.status === \"passed\") lines.push(`[casting] the people cast pass as real customers${cast.cached ? \" (cached)\" : \"\"}.`);\n if (cast.status === \"unavailable\") {\n lines.push(\"[warn] casting_check_unavailable: the model did not answer; check yourself that the people cast look like this company's real customers.\");\n }\n return { viewer: resolved.viewer, lines };\n}\n\n// --- `baker canvas viewer-check <slug>` ---\n\nconst DESCRIPTION =\n \"Would the person this ad reaches understand it? A model plays the viewer the creative is for (the `viewer` in _definition.md, else the one its `targetAdSet` reaches, else the persona and awareness in the Knowledge, else a cold stranger) and says, from prompt.json's copy and scene alone, what is offered, to whom and what to do next; the answer is compared with prompt.json's `message`. Start here after writing the copy, before rendering: baker canvas viewer-check spring-offer. `baker canvas run` makes the same check before it spends, from the same cache, and refuses a static ad the viewer would not understand (exit 2, `viewer_check_failed`, `fix` saying what they missed). Output is compact; --full adds the viewer's whole answer and why that viewer was chosen.\";\n\nconst ARGS = {\n slug: {\n type: \"positional\",\n required: true,\n description: \"The creative: its slug (src/creatives/<slug>/), or the path to its folder, canvas or prompt.json.\",\n },\n full: {\n type: \"boolean\",\n required: false,\n default: false,\n description: \"Add the viewer's whole answer, what the ad means to say, and how the viewer was resolved.\",\n },\n} as const;\n\nregisterSchema({ command: \"canvas.viewer-check\", description: DESCRIPTION, args: ARGS });\n\n/** The creative folder an argument names: a path to it (or a file in it), else `src/creatives/<slug>/`. */\nasync function creativeDirOf(arg: string, workspaceRoot: string): Promise<string> {\n const direct = path.resolve(arg);\n try {\n return (await stat(direct)).isDirectory() ? direct : path.dirname(direct);\n } catch {\n return path.join(workspaceRoot, \"src\", \"creatives\", arg);\n }\n}\n\nexport const viewerCheckCommand = defineCommand({\n meta: { name: \"viewer-check\", description: DESCRIPTION },\n args: ARGS,\n async run({ args }) {\n const cwd = process.cwd();\n const workspaceRoot = findWorkspaceRoot(cwd) ?? cwd;\n const creativeDir = await creativeDirOf(String(args.slug), workspaceRoot);\n const slug = path.basename(creativeDir);\n let creative: Awaited<ReturnType<typeof readCreativeForViewerCheck>>;\n try {\n creative = await readCreativeForViewerCheck(creativeDir);\n } catch (e) {\n writeJson({\n ok: false,\n error: {\n code: \"NOT_FOUND\",\n message: `No readable prompt.json in ${creativeDir} (${e instanceof Error ? e.message : String(e)}).`,\n fix: \"Pass the creative's slug (src/creatives/<slug>/) or its folder; its prompt.json must parse.\",\n },\n });\n process.exit(1);\n }\n const resolved = await resolveViewer(creative.sources, liveViewerLookups(workspaceRoot));\n const input: ViewerCheckInput = { ...creative.ad, viewer: resolved.viewer };\n const cacheDir = path.join(workspaceRoot, \"canvas\", \".cache\");\n const spent: ReviewUsage[] = [];\n const outcome = await checkViewer(input, {\n cacheDir,\n model: VIEWER_CHECK_MODEL,\n ask: gatewayViewerModel(VIEWER_CHECK_MODEL, (usage) => spent.push(usage)),\n judge: jevReadJudge((usage) => spent.push(usage)),\n });\n // No run record carries this check: the next render of this workspace bills it.\n await holdUnbilledSpend(cacheDir, spent);\n const who = describeViewer(resolved.viewer);\n const detail = args.full\n ? {\n viewer_profile: resolved.viewer,\n viewer_from: resolved.from,\n intended: input.intended,\n ...(outcome.status !== \"unavailable\" ? { answer: outcome.answer } : {}),\n ...(resolved.notes.length > 0 ? { notes: resolved.notes } : {}),\n }\n : {};\n if (outcome.status === \"failed\") {\n const turnId = optionalTurnId();\n const ledger = await readTurnRenders(cacheDir);\n // Failed twice in this turn already: the render goes ahead, and the person hears what was missed.\n if (viewerChecksSpent(ledger, turnId, slug)) {\n writeJson({\n ok: true,\n data: { checked: true, understood: false, viewer: who, missed: outcome.verdict.missed, ...detail },\n hints: [\n `This ad failed the viewer check twice in this turn: render it as written (baker canvas run --slug ${slug}) and tell the person what ${who} missed: ${outcome.verdict.missed.map(missLine).join(\" \")}`,\n ],\n });\n return;\n }\n if (turnId) await updateTurnRenders(cacheDir, (current) => recordViewerFail(current, turnId, slug));\n const failure = viewerCheckFailure(outcome, slug);\n writeJson({ ...failure, error: { ...failure.error, ...detail } });\n process.exit(2);\n }\n if (outcome.status === \"unavailable\") {\n writeJson({\n ok: true,\n data: { checked: false, viewer: who, ...detail },\n hints: [\n \"The viewer model did not answer (no gateway key here, or it failed twice). Read the copy as this viewer yourself, or run the check again.\",\n ],\n });\n return;\n }\n writeJson({\n ok: true,\n data: {\n checked: true,\n understood: true,\n viewer: who,\n offer: outcome.answer.offer.answer,\n for_whom: outcome.answer.for_whom.answer,\n next_step: outcome.answer.next_step.answer,\n ...(outcome.cached ? { cached: true } : {}),\n ...detail,\n },\n hints: [\n resolved.from === \"default\"\n ? \"Checked against a cold stranger because nothing says who will see this ad: record `targetAdSet` and `viewer` in _definition.md (`baker ads meta adsets --audience`) when it will run in a known ad set.\"\n : `Checked against ${who}. Render it: baker canvas run --slug ${slug}`,\n ],\n });\n },\n});\n","/**\n * Would the people in this ad pass as real customers of this company, where it runs?\n *\n * Audited Sept 2026: casting came from the reference ad's stranger or from whichever avatar was\n * passed first: a 24-year-old model in a hoodie selling trade courses to unemployed adults\n * changing careers, a Spanish face on a Mexican ad. Before a static ad renders, a text model reads\n * who is cast (each person's description, from the avatar), what the company sells, who the ad\n * is for and where it runs, and says whether each would pass as a real customer, and who would\n * instead. Cached by the question, so asking again is free; a model that does not answer lets\n * the render through, saying so.\n */\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\n\nexport const CastingAnswerSchema = z.object({\n passes: z.boolean(),\n why: z.string().default(\"\"),\n instead: z.string().default(\"\"),\n});\nexport type CastingAnswer = z.infer<typeof CastingAnswerSchema>;\n\nexport type CastingInput = {\n /** Each person cast, in words (the avatar's own description). */\n people: string[];\n /** What the company sells, from COMPANY.md. */\n company: string;\n /** Where the ad runs, as the viewer would be (`describeMarket`). */\n market?: string;\n /** Who the ad is for. */\n persona?: string;\n /** The company's own rules about who appears in its ads, in their words. */\n rules?: readonly string[];\n};\n\n/** The casting question, the answer a fixed JSON the code reads. Pure. */\nexport function buildCastingPrompt(input: CastingInput): string {\n return [\n \"An ad is about to be made with these people in it:\",\n ...input.people.map((p) => `- ${p}`),\n \"\",\n `The company: ${input.company.trim() || \"(not written down)\"}`,\n ...(input.persona ? [`The ad is for: ${input.persona}`] : []),\n ...(input.market ? [`It runs for ${input.market}.`] : []),\n ...(input.rules && input.rules.length > 0\n ? [\"The company's own rules about who appears in its ads:\", ...input.rules.map((r) => `- ${r}`)]\n : []),\n \"\",\n \"Would each of these people pass, to someone scrolling there, as a real customer of this company (or, for a testimonial, someone who really used it)? Judge age, look, setting and origin against who actually buys this, where the ad runs. A model-like face selling to people who are not models does not pass, and a person a rule rules out does not pass. A rule about how or where a person is shown (their size, framing, a round photo, inside a mockup) is not this question: the finished ad is checked against it.\",\n 'Reply with only this JSON: {\"passes\":true|false,\"why\":\"<one sentence>\",\"instead\":\"<who would pass, in a few words, when one does not>\"}',\n ].join(\"\\n\");\n}\n\nexport type CastingOutcome =\n | { status: \"passed\" | \"failed\"; answer: CastingAnswer; cached: boolean }\n | { status: \"unavailable\" }\n | { status: \"skipped\" };\n\nfunction cacheKey(input: CastingInput, model: string): string {\n return createHash(\"sha256\").update(JSON.stringify({ prompt: buildCastingPrompt(input), model })).digest(\"hex\");\n}\n\nfunction parseOrNull(raw: string): unknown {\n try {\n return JSON.parse(raw);\n } catch {\n return null;\n }\n}\n\n/** Ask, or read the answer this exact question already got. Nobody cast: nothing to check. */\nexport async function castingCheck(\n input: CastingInput,\n opts: { cacheDir: string; model: string; ask: (prompt: string) => Promise<unknown> },\n): Promise<CastingOutcome> {\n if (input.people.length === 0) return { status: \"skipped\" };\n const file = path.join(opts.cacheDir, \"casting-check\", `${cacheKey(input, opts.model)}.json`);\n const cachedRaw = await readFile(file, \"utf8\").catch(() => null);\n // A write cut short leaves half a file: that is a miss, never a failed run.\n const cachedParse = cachedRaw ? CastingAnswerSchema.safeParse(parseOrNull(cachedRaw)) : null;\n if (cachedParse?.success) return { status: cachedParse.data.passes ? \"passed\" : \"failed\", answer: cachedParse.data, cached: true };\n const prompt = buildCastingPrompt(input);\n for (let attempt = 0; attempt < 2; attempt++) {\n const parsed = CastingAnswerSchema.safeParse(await opts.ask(prompt));\n if (!parsed.success) continue;\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, `${JSON.stringify(parsed.data, null, 2)}\\n`, \"utf8\");\n return { status: parsed.data.passes ? \"passed\" : \"failed\", answer: parsed.data, cached: false };\n }\n return { status: \"unavailable\" };\n}\n\n/** The `{ ok: false, error }` a failed casting check prints. Pure. */\nexport function castingCheckFailure(answer: CastingAnswer, slug: string) {\n return {\n ok: false as const,\n error: {\n code: \"casting_check_failed\" as const,\n message: `Not rendered: the people cast would not pass as this company's real customers. ${answer.why}`.trim(),\n fix: [\n answer.instead ? `Cast ${answer.instead} instead:` : \"Cast someone who would:\",\n \"`baker avatars list` for the company's avatars (pass the one that fits with `--avatar` on the scaffold, or set its identity sheet URL from `baker avatars get <handle>` as the PERSON reference's `image` in prompt.json), or `baker avatars create` from the persona (age, origin, setting, accent for this market).\",\n `Then \\`baker canvas run --slug ${slug}\\` again.`,\n ].join(\" \"),\n },\n };\n}\n","/**\n * How many times each ad was rendered in this chat turn, and how the last one ended, so a turn\n * stops spending time on an ad that is done or cannot be finished. Dev, Oct 2026: a producer\n * re-rendered a `ready_with_notes` ad four more times to chase its notes, and another re-ran an ad\n * whose concept could not be kept truthfully until the turn ran out. The run's own autofix rounds\n * are one render here: only the commands an agent starts count.\n */\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { canonicalize } from \"@baker/canvas-contract\";\nimport { z } from \"zod\";\nimport { updateLockedFile } from \"../../engine/lib/file-lock.ts\";\nimport type { StaticVerdict } from \"../../engine/nodes/local/lib/static-review.ts\";\nimport type { AutoFixStep } from \"./static-autofix.ts\";\n\n/** Renders an agent may start for one ad in one turn, its autofix rounds included in each. */\nconst RUNS_PER_TURN = 2;\n\n/**\n * Viewer checks one ad may fail in one turn before it renders anyway, what the viewer missed said\n * with it. Dev, Oct 2026: a producer rewrote one ad's copy for seven checks, then sat blocked.\n */\nconst VIEWER_FAILS_PER_TURN = 2;\n\n/**\n * The time one render an agent starts may take, its correction rounds included: no round is started\n * past it. Dev, Oct 2026: two autofix rounds held one producer 21 minutes on one ad, the other two\n * long finished. Each render has its own, never the turn's: counted per turn, one render with its\n * rounds (prod, Oct 2026: 576–781s) spent it, and every render the agent then started was refused\n * (BAKER-2414). 12, not 8: three rounds, each from the best attempt so far, finish what two left.\n */\nconst RUN_MS = 12 * 60_000;\n\n/** About how long each correction round takes, its review included (dev, Oct 2026 runs). */\nconst ROUND_MS: Record<AutoFixStep[\"kind\"], number> = {\n respec: 60_000,\n extend: 80_000,\n relayout: 100_000,\n fix: 150_000,\n regenerate: 220_000,\n};\n\nconst LedgerSchema = z.object({\n turnId: z.string(),\n creatives: z.record(\n z.string(),\n z.object({\n runs: z.number().default(0),\n verdict: z.string().optional(),\n viewerFails: z.number().optional(),\n lastCorrection: z.boolean().optional(),\n }),\n ),\n});\nexport type TurnRenders = z.infer<typeof LedgerSchema>;\ntype Entry = TurnRenders[\"creatives\"][string];\n\n/** Whether `entry` has had its renders in this turn. */\nconst budgetSpent = (entry: Entry): boolean => entry.runs >= RUNS_PER_TURN;\n\n/**\n * Whether an ad past its budget may still have one correction: it still needs fixes and has not had\n * that one yet. Zernio, Oct 2026: automatic rounds failing one check took 9.5 minutes, and the\n * `--fix` the agent then ran was refused for time, the ad shown broken. Bounded: once a turn.\n */\nconst lastCorrectionDue = (entry: Entry, correction: boolean | undefined): boolean =>\n correction === true && entry.verdict === \"needs_fixes\" && entry.lastCorrection !== true;\n\nexport type TurnRenderRefusal = { code: \"CONFLICT\"; message: string; fix: string };\n\nconst SHOW_AS_IT_STANDS =\n \"Show the best version as a version (\\\"Version 3\\\"), never a file path or a run id, and say in one plain sentence what is left, in the person's words. End there: no question and no options; their next message says what changes.\";\n\n/**\n * Whether a run may still turn out to be a correction of the version shown (`turnRenderRefusal`),\n * known before the run reads or spends anything: a `--fix`, a `--regenerate`, or a prompt.json\n * changed since that version (an edit of its words or colours). Run again with nothing changed, a\n * ready ad is refused at once. `--use-variant` is the person's choice among the options, never a\n * defect: it comes with their next message, in a new turn. Pure.\n */\nexport function mayBeCorrection(\n run: { fix?: string; regenerate?: string; useVariant?: string },\n shownPrompt: unknown,\n promptOnDisk: unknown,\n): boolean {\n if (run.fix !== undefined || run.regenerate !== undefined) return true;\n return shownPrompt !== undefined && promptOnDisk != null && canonicalize(shownPrompt) !== canonicalize(promptOnDisk);\n}\n\n/**\n * Why this ad gets no further render in this turn, or null. A ready ad is never rendered anew (that\n * chased notes four renders deep), but a `correction` of the version shown (a `--fix`, a size laid\n * out again, prompt.json's words or colours edited: one edit grown on top of it) may answer a real\n * defect the agent sees, within the same renders as any other. Production, Oct 2026: an ad\n * with its logo drawn twice, `ready_with_notes`, could not be corrected and was saved as it was. An ad\n * that still needs fixes gets one correction past its budget (`lastCorrectionDue`). Pure.\n */\nexport function turnRenderRefusal(\n ledger: TurnRenders | undefined,\n turnId: string | undefined,\n slug: string,\n opts: { correction?: boolean; shape?: \"plate\" | \"relayout\" } = {},\n): TurnRenderRefusal | null {\n const entry = turnId !== undefined && ledger?.turnId === turnId ? ledger.creatives[slug] : undefined;\n if (!entry) return null;\n if ((entry.verdict === \"ready\" || entry.verdict === \"ready_with_notes\") && opts.correction !== true) {\n return {\n code: \"CONFLICT\",\n message: `This ad is already ready in this turn (${entry.verdict}): its notes are not defects, and new options are not made for them.`,\n fix: `Show it now. Only a real defect you can name in it (a logo drawn twice, a word wrong) is corrected in this turn: \\`baker canvas run --slug <slug> --fix \"<what to change>\"\\`, or \\`--regenerate ${opts.shape === \"relayout\" ? \"adapt\" : \"format\"}_<size>\\` for one size. Any other change comes with the person's next message.`,\n };\n }\n if (budgetSpent(entry) && lastCorrectionDue(entry, opts.correction)) return null;\n if (budgetSpent(entry)) {\n return {\n code: \"CONFLICT\",\n message: `This ad was rendered ${entry.runs} times in this turn (the ${RUNS_PER_TURN} runs you start, then one last correction while it needs fixes), each with its automatic corrections, and is still not ready.`,\n fix: lastCorrectionDue(entry, true)\n ? `Its one last correction is still open: \\`baker canvas run --slug <slug> --fix \"<what to change>\"\\`, \\`--regenerate ${opts.shape === \"relayout\" ? \"adapt\" : \"format\"}_<size>\\` for one size, or its words or colours edited in prompt.json. Else: ${SHOW_AS_IT_STANDS}`\n : SHOW_AS_IT_STANDS,\n };\n }\n return null;\n}\n\n/**\n * The ledger with one more render of `slug` that ended `verdict`; a new turn starts it\n * afresh. A render started past the ad's budget was its one last correction, and is marked spent. Pure.\n */\nexport function recordTurnRender(\n ledger: TurnRenders | undefined,\n turnId: string,\n slug: string,\n verdict: StaticVerdict,\n): TurnRenders {\n const creatives = ledger?.turnId === turnId ? ledger.creatives : {};\n const entry = creatives[slug];\n return {\n turnId,\n creatives: {\n ...creatives,\n [slug]: {\n ...entry,\n runs: (entry?.runs ?? 0) + 1,\n verdict,\n ...(entry && budgetSpent(entry) ? { lastCorrection: true } : {}),\n },\n },\n };\n}\n\n/** Whether a correction round of `kind` still fits this render's time, it having taken `renderMs` so far. Pure. */\nexport function roundFitsRun(renderMs: number, kind: AutoFixStep[\"kind\"]): boolean {\n return renderMs + ROUND_MS[kind] <= RUN_MS;\n}\n\n/** The ledger with one more failed viewer check of `slug`; a new turn starts it afresh. Pure. */\nexport function recordViewerFail(ledger: TurnRenders | undefined, turnId: string, slug: string): TurnRenders {\n const creatives = ledger?.turnId === turnId ? ledger.creatives : {};\n const entry = creatives[slug] ?? { runs: 0 };\n return { turnId, creatives: { ...creatives, [slug]: { ...entry, viewerFails: (entry.viewerFails ?? 0) + 1 } } };\n}\n\n/** Whether `slug` failed the viewer check often enough in this turn to render without being held back again. Pure. */\nexport function viewerChecksSpent(ledger: TurnRenders | undefined, turnId: string | undefined, slug: string): boolean {\n const entry = turnId !== undefined && ledger?.turnId === turnId ? ledger.creatives[slug] : undefined;\n return (entry?.viewerFails ?? 0) >= VIEWER_FAILS_PER_TURN;\n}\n\nconst ledgerPath = (cacheDir: string) => path.join(cacheDir, \"turn-renders.json\");\n\nexport async function readTurnRenders(cacheDir: string): Promise<TurnRenders | undefined> {\n try {\n const parsed = LedgerSchema.safeParse(JSON.parse(await readFile(ledgerPath(cacheDir), \"utf8\")));\n return parsed.success ? parsed.data : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Change the record under a lock, written whole through a rename: `--series` runs every ad's render\n * as its own process at once, and a plain read-then-write let each one overwrite the others' entries.\n */\nexport async function updateTurnRenders(\n cacheDir: string,\n change: (ledger: TurnRenders | undefined) => TurnRenders,\n): Promise<void> {\n await updateLockedFile(ledgerPath(cacheDir), async () => JSON.stringify(change(await readTurnRenders(cacheDir))));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,SAAAC,QAAO,SAAS,YAAAC,WAAU,MAAM,aAAAC,kBAAiB;AAC1D,OAAOC,WAAU;AAEjB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,iBAAiB;AACnC,SAAS,KAAAC,UAAS;;;ACXlB,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,iBAAiB;AAC3C,OAAO,UAAU;AACjB,SAAS,SAAS;AAEX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,QAAQ,EAAE,QAAQ;AAAA,EAClB,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE;AAChC,CAAC;AAiBM,SAAS,mBAAmB,OAA6B;AAC9D,SAAO;AAAA,IACL;AAAA,IACA,GAAG,MAAM,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AAAA,IACnC;AAAA,IACA,gBAAgB,MAAM,QAAQ,KAAK,KAAK,oBAAoB;AAAA,IAC5D,GAAI,MAAM,UAAU,CAAC,kBAAkB,MAAM,OAAO,EAAE,IAAI,CAAC;AAAA,IAC3D,GAAI,MAAM,SAAS,CAAC,eAAe,MAAM,MAAM,GAAG,IAAI,CAAC;AAAA,IACvD,GAAI,MAAM,SAAS,MAAM,MAAM,SAAS,IACpC,CAAC,yDAAyD,GAAG,M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mBAAmB,GAAG,wCAAwC,IAAI;AAAA,MACxE;AAAA,IACF,CAAC;AAAA,EACH;AACF,CAAC;","names":["createHash","mkdir","readFile","writeFile","path","z","readFile","path","z","z","path","readFile","z","createHash","readFile","path","mkdir","writeFile"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ACTION_TEMP_ID_PREFIX
3
- } from "./chunk-2Q7K4F4H.js";
3
+ } from "./chunk-ICASR3ES.js";
4
4
  import {
5
5
  ApiError
6
6
  } from "./chunk-LJEJCIHR.js";
@@ -200,4 +200,4 @@ export {
200
200
  buildListHints,
201
201
  buildGetHints
202
202
  };
203
- //# sourceMappingURL=chunk-TEJOILEY.js.map
203
+ //# sourceMappingURL=chunk-PRZBEZBA.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RESEARCH_GOOGLE_ADS_MAX_COPY
3
- } from "./chunk-2Q7K4F4H.js";
3
+ } from "./chunk-ICASR3ES.js";
4
4
 
5
5
  // src/commands/research/hints.ts
6
6
  var AD_COPY_ROUTE = 'This returns competing domains and their SERP economics \u2014 no ad copy, no headlines, no creative. For a competitor\'s Google ads and their copy: `baker research google-ads <competitor.com> --copy` (Google\'s Ads Transparency Center: every ad, how long it has run, and the text ads\' headline and description). For Meta and LinkedIn: `baker winning-ads advertisers "<brand>"` \u2192 `baker winning-ads search "<brief>" --advertiser-id <id>` \u2192 `baker winning-ads content <adId>` (`primary_text` / `headline` / `cta`, plus the spoken transcript and on-screen text for video). Do not keep querying this command for copy.';
@@ -331,4 +331,4 @@ export {
331
331
  companySearchHints,
332
332
  unknownIndustriesFix
333
333
  };
334
- //# sourceMappingURL=chunk-LQACNCAV.js.map
334
+ //# sourceMappingURL=chunk-PTE6BNCH.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  avatarsOf
3
- } from "./chunk-VAURJ4QJ.js";
3
+ } from "./chunk-CKN4HQZM.js";
4
4
  import {
5
5
  readAvatars
6
6
  } from "./chunk-6MJKVNLL.js";
7
7
  import {
8
8
  readCreativeContext,
9
9
  workspaceOfCreative
10
- } from "./chunk-RVIBHENP.js";
10
+ } from "./chunk-7GFGFBWZ.js";
11
11
  import {
12
12
  frontmatterOf,
13
13
  ruleTells
@@ -139,4 +139,4 @@ export {
139
139
  heldRules,
140
140
  ruleGate
141
141
  };
142
- //# sourceMappingURL=chunk-JT3UUBID.js.map
142
+ //# sourceMappingURL=chunk-Q5DLTIYL.js.map
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  X_DRAFT_BATCH_MAX,
13
13
  xDraftOpInputSchema
14
- } from "./chunk-2Q7K4F4H.js";
14
+ } from "./chunk-ICASR3ES.js";
15
15
  import {
16
16
  ApiError,
17
17
  apiPost
@@ -166,4 +166,4 @@ export {
166
166
  requireTarget,
167
167
  requireTargets
168
168
  };
169
- //# sourceMappingURL=chunk-KUI74TNG.js.map
169
+ //# sourceMappingURL=chunk-QVO5VPNA.js.map
@@ -3,7 +3,7 @@ import {
3
3
  parseDefinitionDelivery,
4
4
  resolveDelivery,
5
5
  resolveFormatList
6
- } from "./chunk-ELC42LJJ.js";
6
+ } from "./chunk-C4BPAMAJ.js";
7
7
  import {
8
8
  AD_PLACEMENTS
9
9
  } from "./chunk-MCJ5I5LR.js";
@@ -88,4 +88,4 @@ export {
88
88
  deliveryDefinitionFields,
89
89
  deliveryNote
90
90
  };
91
- //# sourceMappingURL=chunk-2Z6PFHD2.js.map
91
+ //# sourceMappingURL=chunk-RBR5PHYJ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  OBJECTIVE_TYPES,
4
4
  calendarDaySchema,
5
5
  targetingCriteriaSchema
6
- } from "./chunk-2Q7K4F4H.js";
6
+ } from "./chunk-ICASR3ES.js";
7
7
 
8
8
  // ../api/src/ads-linkedin/planning.ts
9
9
  import { z } from "zod";
@@ -58,4 +58,4 @@ export {
58
58
  LINKEDIN_FORECAST_DEFAULT_DAYS,
59
59
  linkedinForecastRequestSchema
60
60
  };
61
- //# sourceMappingURL=chunk-H3RCEM6L.js.map
61
+ //# sourceMappingURL=chunk-RHBCKOF2.js.map
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-UK4XSLV2.js";
32
32
  import {
33
33
  videosIngestRequestSchema
34
- } from "./chunk-2Q7K4F4H.js";
34
+ } from "./chunk-ICASR3ES.js";
35
35
  import {
36
36
  ApiError,
37
37
  apiPost
@@ -451,4 +451,4 @@ export {
451
451
  runVideoIngest,
452
452
  ingestHints
453
453
  };
454
- //# sourceMappingURL=chunk-2YXTXSYG.js.map
454
+ //# sourceMappingURL=chunk-S3XCG55E.js.map
@@ -8,7 +8,7 @@ import {
8
8
  calendarDaySchema,
9
9
  todayUtc,
10
10
  windowTooLong
11
- } from "./chunk-2Q7K4F4H.js";
11
+ } from "./chunk-ICASR3ES.js";
12
12
 
13
13
  // ../api/src/accounts/crm-columns.ts
14
14
  var COLUMN_HELD = 0.7;
@@ -465,4 +465,4 @@ export {
465
465
  accountsCampaignsRequestSchema,
466
466
  ACCOUNTS_NO_SETTINGS_MESSAGE
467
467
  };
468
- //# sourceMappingURL=chunk-JSOOLOHP.js.map
468
+ //# sourceMappingURL=chunk-SPNF2V46.js.map
@@ -20,7 +20,7 @@ import {
20
20
  suggestFamilies,
21
21
  unresolvedBrandFamilies,
22
22
  upsertFontFaceCss
23
- } from "./chunk-4QFMRL6O.js";
23
+ } from "./chunk-C57CXCTI.js";
24
24
  import {
25
25
  registerSchema,
26
26
  writeJson
@@ -491,4 +491,4 @@ export {
491
491
  fontsAdoptCommand,
492
492
  fontsCommand
493
493
  };
494
- //# sourceMappingURL=chunk-YDALLZNS.js.map
494
+ //# sourceMappingURL=chunk-SPNY52S5.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  creativesRunResponseSchema
3
- } from "./chunk-2Q7K4F4H.js";
3
+ } from "./chunk-ICASR3ES.js";
4
4
  import {
5
5
  ApiError,
6
6
  apiPost
@@ -20,4 +20,4 @@ async function fetchRunRecord(runId, post = apiPost) {
20
20
  export {
21
21
  fetchRunRecord
22
22
  };
23
- //# sourceMappingURL=chunk-G4FU6VC5.js.map
23
+ //# sourceMappingURL=chunk-VSALEVXN.js.map