@koda-sl/baker-cli 0.449.0 → 0.450.0-dev.d6701597d

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 (158) hide show
  1. package/README.md +8 -0
  2. package/dist/{account-F6MHQ64I.js → account-4H7QVBRK.js} +3 -3
  3. package/dist/{account-writes-ISE4U2FQ.js → account-writes-AK42HGRM.js} +3 -3
  4. package/dist/{ad-group-writes-UU5NNKSO.js → ad-group-writes-QQS4223F.js} +3 -3
  5. package/dist/{ad-groups-CGFXZNIA.js → ad-groups-WGPDPUI2.js} +7 -7
  6. package/dist/{ad-writes-NALDYWOR.js → ad-writes-XE2IE4DS.js} +3 -3
  7. package/dist/{ads-C47NA2HH.js → ads-73PGA4YC.js} +2 -2
  8. package/dist/{ads-PV7GZXPR.js → ads-BCOSQALY.js} +8 -8
  9. package/dist/{animate-FWWHSYPL.js → animate-AIZ3GS4J.js} +4 -4
  10. package/dist/{audiences-VEKGLWBG.js → audiences-TGD5US2M.js} +3 -3
  11. package/dist/{brief-UO52ZHFI.js → brief-YFJHQ5VQ.js} +5 -5
  12. package/dist/{campaign-writes-SX52CJYW.js → campaign-writes-SXLZFYF6.js} +3 -3
  13. package/dist/{campaigns-X3DPCCSN.js → campaigns-YS3OGQXO.js} +7 -7
  14. package/dist/{canvas-DPCBGW7K.js → canvas-5NB27FX2.js} +13 -13
  15. package/dist/{catalog-ME44ZRZF.js → catalog-VSSY6FGI.js} +6 -6
  16. package/dist/{catalogs-G3YEVG6S.js → catalogs-BRXEDE56.js} +3 -3
  17. package/dist/{chatgpt-QNUN63YS.js → chatgpt-7W75X3ER.js} +13 -13
  18. package/dist/{chunk-K7FZXIOZ.js → chunk-464O4MT2.js} +2 -2
  19. package/dist/{chunk-647RO73Q.js → chunk-6NB47MRW.js} +3 -3
  20. package/dist/{chunk-35XWJEWH.js → chunk-7J6EHOH6.js} +2 -2
  21. package/dist/{chunk-CHSNHVYF.js → chunk-CAMX6OHF.js} +4 -4
  22. package/dist/chunk-CAMX6OHF.js.map +1 -0
  23. package/dist/{chunk-GBMP4F45.js → chunk-CMPEUZOR.js} +19 -13
  24. package/dist/{chunk-GBMP4F45.js.map → chunk-CMPEUZOR.js.map} +1 -1
  25. package/dist/{chunk-HBTF25YG.js → chunk-DGUNI37S.js} +2 -2
  26. package/dist/{chunk-54UVGFX3.js → chunk-EAP4O4FE.js} +4 -4
  27. package/dist/{chunk-K66OLA6Y.js → chunk-EBWBG6YV.js} +54 -27
  28. package/dist/chunk-EBWBG6YV.js.map +1 -0
  29. package/dist/{chunk-KLBTXETO.js → chunk-FTWJFDIN.js} +169 -169
  30. package/dist/chunk-FTWJFDIN.js.map +1 -0
  31. package/dist/{chunk-KQTYTCKQ.js → chunk-HZUDRKGR.js} +2 -2
  32. package/dist/{chunk-5Y5UAJWD.js → chunk-KAUOHQTF.js} +2 -2
  33. package/dist/{chunk-TT5R35PJ.js → chunk-LECGCWT5.js} +6 -6
  34. package/dist/{chunk-KFE3S63W.js → chunk-NCWCZY5P.js} +3 -3
  35. package/dist/{chunk-7ZHMGXE2.js → chunk-NJXNU2G6.js} +3 -3
  36. package/dist/{chunk-GLCPTMPG.js → chunk-OQ6663F4.js} +5 -5
  37. package/dist/{chunk-HQSCJYZO.js → chunk-P5T7OZKV.js} +2 -2
  38. package/dist/{chunk-VB6WJJR3.js → chunk-PZXCWSKV.js} +2 -2
  39. package/dist/{chunk-J5IY3GVE.js → chunk-Q2V6E6SL.js} +4 -4
  40. package/dist/{chunk-2QHODRR6.js → chunk-RZBEK2VE.js} +2 -2
  41. package/dist/{chunk-IBURXTL4.js → chunk-S3A3YOKO.js} +6 -6
  42. package/dist/{chunk-LYBXCXJB.js → chunk-VNUNE5AB.js} +2 -2
  43. package/dist/{chunk-ULJ5RFOV.js → chunk-XFGAUP5B.js} +2 -2
  44. package/dist/{chunk-FD27ZDVP.js → chunk-Y6ZQXUZ7.js} +3 -3
  45. package/dist/{chunk-Z2EOC6PL.js → chunk-YUCLMOEG.js} +5 -5
  46. package/dist/chunk-YUCLMOEG.js.map +1 -0
  47. package/dist/cli.js +7 -7
  48. package/dist/{conversion-report-N4HANYOB.js → conversion-report-XQBJ6LG4.js} +2 -2
  49. package/dist/{conversion-writes-LW4HQKK5.js → conversion-writes-UBCVXP2E.js} +3 -3
  50. package/dist/{conversions-TS723AZV.js → conversions-D236RTUK.js} +5 -5
  51. package/dist/{creatives-SJTJU6VT.js → creatives-B5NTXPUB.js} +7 -7
  52. package/dist/{credentials-VOZTILFO.js → credentials-C33K6XCJ.js} +14 -14
  53. package/dist/credentials-C33K6XCJ.js.map +1 -0
  54. package/dist/{critique-65W63MFZ.js → critique-4V5SKH7C.js} +6 -6
  55. package/dist/{customers-4AWBFDUF.js → customers-A36LOZOB.js} +3 -3
  56. package/dist/{draft-THPZFASM.js → draft-MNFJ4G3C.js} +3 -3
  57. package/dist/engine/index.js +5 -5
  58. package/dist/{feedback-XNJQ63DS.js → feedback-OLTCHE6C.js} +2 -2
  59. package/dist/{feedback-record-FDLMWMDG.js → feedback-record-7WZ4H7EP.js} +8 -8
  60. package/dist/{fit-7237F5EB.js → fit-UOFYFJ4Q.js} +5 -5
  61. package/dist/{generate-MMBYB44G.js → generate-3XYYITU6.js} +3 -3
  62. package/dist/{history-DBIEYQHY.js → history-Q3QCT64S.js} +3 -3
  63. package/dist/{insights-ZIU6FJMS.js → insights-LNAXV2CG.js} +2 -2
  64. package/dist/{learn-3VO6DXUX.js → learn-FUQSY7DN.js} +4 -4
  65. package/dist/{locations-74TPQWAT.js → locations-2NKBJKBT.js} +2 -2
  66. package/dist/{make-LCNP76OF.js → make-BMWRKIIY.js} +16 -13
  67. package/dist/{make-LCNP76OF.js.map → make-BMWRKIIY.js.map} +1 -1
  68. package/dist/{models-7U3GRYHF.js → models-3Z6MDHQW.js} +2 -2
  69. package/dist/{pixels-45A55MOP.js → pixels-TZPF746S.js} +3 -3
  70. package/dist/{rerun-CET74VPF.js → rerun-6XZG7BGK.js} +14 -14
  71. package/dist/{research-EY7C7JJY.js → research-2BLEISBG.js} +2 -2
  72. package/dist/{run-XQ7EM3JT.js → run-MMEDKJDB.js} +14 -14
  73. package/dist/{scaffold-ad-U2KSHKBC.js → scaffold-ad-PBTEWDAC.js} +12 -12
  74. package/dist/{scaffold-static-ad-63LQKUSO.js → scaffold-static-ad-RM4M4X5U.js} +21 -21
  75. package/dist/scaffold-static-ad-RM4M4X5U.js.map +1 -0
  76. package/dist/{scaffold-video-MUS6LHJQ.js → scaffold-video-O2TTKZIE.js} +11 -11
  77. package/dist/{select-4Z7BW5RH.js → select-OEUKOVZ5.js} +8 -8
  78. package/dist/{set-prompt-OB2V3XJP.js → set-prompt-5E5I7QAZ.js} +7 -7
  79. package/dist/{stale-DAYXOY3Z.js → stale-IGFUKEN2.js} +7 -7
  80. package/dist/{studio-C5K3YX3P.js → studio-RA7QQH4O.js} +4 -4
  81. package/dist/{sync-definition-ILS2B2BJ.js → sync-definition-UGSDX2SZ.js} +10 -10
  82. package/dist/{translate-TA5KQIU7.js → translate-VP5R67PL.js} +11 -11
  83. package/dist/{validate-LDBAAXQO.js → validate-CSJM7XZM.js} +8 -8
  84. package/dist/{viewer-check-45T2HLAH.js → viewer-check-L4B4LIAX.js} +4 -4
  85. package/dist/{winning-ads-ASH5DSV3.js → winning-ads-2WS7FI4E.js} +2 -2
  86. package/package.json +1 -1
  87. package/dist/chunk-CHSNHVYF.js.map +0 -1
  88. package/dist/chunk-K66OLA6Y.js.map +0 -1
  89. package/dist/chunk-KLBTXETO.js.map +0 -1
  90. package/dist/chunk-Z2EOC6PL.js.map +0 -1
  91. package/dist/credentials-VOZTILFO.js.map +0 -1
  92. package/dist/scaffold-static-ad-63LQKUSO.js.map +0 -1
  93. /package/dist/{account-F6MHQ64I.js.map → account-4H7QVBRK.js.map} +0 -0
  94. /package/dist/{account-writes-ISE4U2FQ.js.map → account-writes-AK42HGRM.js.map} +0 -0
  95. /package/dist/{ad-group-writes-UU5NNKSO.js.map → ad-group-writes-QQS4223F.js.map} +0 -0
  96. /package/dist/{ad-groups-CGFXZNIA.js.map → ad-groups-WGPDPUI2.js.map} +0 -0
  97. /package/dist/{ad-writes-NALDYWOR.js.map → ad-writes-XE2IE4DS.js.map} +0 -0
  98. /package/dist/{ads-C47NA2HH.js.map → ads-73PGA4YC.js.map} +0 -0
  99. /package/dist/{ads-PV7GZXPR.js.map → ads-BCOSQALY.js.map} +0 -0
  100. /package/dist/{animate-FWWHSYPL.js.map → animate-AIZ3GS4J.js.map} +0 -0
  101. /package/dist/{audiences-VEKGLWBG.js.map → audiences-TGD5US2M.js.map} +0 -0
  102. /package/dist/{brief-UO52ZHFI.js.map → brief-YFJHQ5VQ.js.map} +0 -0
  103. /package/dist/{campaign-writes-SX52CJYW.js.map → campaign-writes-SXLZFYF6.js.map} +0 -0
  104. /package/dist/{campaigns-X3DPCCSN.js.map → campaigns-YS3OGQXO.js.map} +0 -0
  105. /package/dist/{canvas-DPCBGW7K.js.map → canvas-5NB27FX2.js.map} +0 -0
  106. /package/dist/{catalog-ME44ZRZF.js.map → catalog-VSSY6FGI.js.map} +0 -0
  107. /package/dist/{catalogs-G3YEVG6S.js.map → catalogs-BRXEDE56.js.map} +0 -0
  108. /package/dist/{chatgpt-QNUN63YS.js.map → chatgpt-7W75X3ER.js.map} +0 -0
  109. /package/dist/{chunk-K7FZXIOZ.js.map → chunk-464O4MT2.js.map} +0 -0
  110. /package/dist/{chunk-647RO73Q.js.map → chunk-6NB47MRW.js.map} +0 -0
  111. /package/dist/{chunk-35XWJEWH.js.map → chunk-7J6EHOH6.js.map} +0 -0
  112. /package/dist/{chunk-HBTF25YG.js.map → chunk-DGUNI37S.js.map} +0 -0
  113. /package/dist/{chunk-54UVGFX3.js.map → chunk-EAP4O4FE.js.map} +0 -0
  114. /package/dist/{chunk-KQTYTCKQ.js.map → chunk-HZUDRKGR.js.map} +0 -0
  115. /package/dist/{chunk-5Y5UAJWD.js.map → chunk-KAUOHQTF.js.map} +0 -0
  116. /package/dist/{chunk-TT5R35PJ.js.map → chunk-LECGCWT5.js.map} +0 -0
  117. /package/dist/{chunk-KFE3S63W.js.map → chunk-NCWCZY5P.js.map} +0 -0
  118. /package/dist/{chunk-7ZHMGXE2.js.map → chunk-NJXNU2G6.js.map} +0 -0
  119. /package/dist/{chunk-GLCPTMPG.js.map → chunk-OQ6663F4.js.map} +0 -0
  120. /package/dist/{chunk-HQSCJYZO.js.map → chunk-P5T7OZKV.js.map} +0 -0
  121. /package/dist/{chunk-VB6WJJR3.js.map → chunk-PZXCWSKV.js.map} +0 -0
  122. /package/dist/{chunk-J5IY3GVE.js.map → chunk-Q2V6E6SL.js.map} +0 -0
  123. /package/dist/{chunk-2QHODRR6.js.map → chunk-RZBEK2VE.js.map} +0 -0
  124. /package/dist/{chunk-IBURXTL4.js.map → chunk-S3A3YOKO.js.map} +0 -0
  125. /package/dist/{chunk-LYBXCXJB.js.map → chunk-VNUNE5AB.js.map} +0 -0
  126. /package/dist/{chunk-ULJ5RFOV.js.map → chunk-XFGAUP5B.js.map} +0 -0
  127. /package/dist/{chunk-FD27ZDVP.js.map → chunk-Y6ZQXUZ7.js.map} +0 -0
  128. /package/dist/{conversion-report-N4HANYOB.js.map → conversion-report-XQBJ6LG4.js.map} +0 -0
  129. /package/dist/{conversion-writes-LW4HQKK5.js.map → conversion-writes-UBCVXP2E.js.map} +0 -0
  130. /package/dist/{conversions-TS723AZV.js.map → conversions-D236RTUK.js.map} +0 -0
  131. /package/dist/{creatives-SJTJU6VT.js.map → creatives-B5NTXPUB.js.map} +0 -0
  132. /package/dist/{critique-65W63MFZ.js.map → critique-4V5SKH7C.js.map} +0 -0
  133. /package/dist/{customers-4AWBFDUF.js.map → customers-A36LOZOB.js.map} +0 -0
  134. /package/dist/{draft-THPZFASM.js.map → draft-MNFJ4G3C.js.map} +0 -0
  135. /package/dist/{feedback-XNJQ63DS.js.map → feedback-OLTCHE6C.js.map} +0 -0
  136. /package/dist/{feedback-record-FDLMWMDG.js.map → feedback-record-7WZ4H7EP.js.map} +0 -0
  137. /package/dist/{fit-7237F5EB.js.map → fit-UOFYFJ4Q.js.map} +0 -0
  138. /package/dist/{generate-MMBYB44G.js.map → generate-3XYYITU6.js.map} +0 -0
  139. /package/dist/{history-DBIEYQHY.js.map → history-Q3QCT64S.js.map} +0 -0
  140. /package/dist/{insights-ZIU6FJMS.js.map → insights-LNAXV2CG.js.map} +0 -0
  141. /package/dist/{learn-3VO6DXUX.js.map → learn-FUQSY7DN.js.map} +0 -0
  142. /package/dist/{locations-74TPQWAT.js.map → locations-2NKBJKBT.js.map} +0 -0
  143. /package/dist/{models-7U3GRYHF.js.map → models-3Z6MDHQW.js.map} +0 -0
  144. /package/dist/{pixels-45A55MOP.js.map → pixels-TZPF746S.js.map} +0 -0
  145. /package/dist/{rerun-CET74VPF.js.map → rerun-6XZG7BGK.js.map} +0 -0
  146. /package/dist/{research-EY7C7JJY.js.map → research-2BLEISBG.js.map} +0 -0
  147. /package/dist/{run-XQ7EM3JT.js.map → run-MMEDKJDB.js.map} +0 -0
  148. /package/dist/{scaffold-ad-U2KSHKBC.js.map → scaffold-ad-PBTEWDAC.js.map} +0 -0
  149. /package/dist/{scaffold-video-MUS6LHJQ.js.map → scaffold-video-O2TTKZIE.js.map} +0 -0
  150. /package/dist/{select-4Z7BW5RH.js.map → select-OEUKOVZ5.js.map} +0 -0
  151. /package/dist/{set-prompt-OB2V3XJP.js.map → set-prompt-5E5I7QAZ.js.map} +0 -0
  152. /package/dist/{stale-DAYXOY3Z.js.map → stale-IGFUKEN2.js.map} +0 -0
  153. /package/dist/{studio-C5K3YX3P.js.map → studio-RA7QQH4O.js.map} +0 -0
  154. /package/dist/{sync-definition-ILS2B2BJ.js.map → sync-definition-UGSDX2SZ.js.map} +0 -0
  155. /package/dist/{translate-TA5KQIU7.js.map → translate-VP5R67PL.js.map} +0 -0
  156. /package/dist/{validate-LDBAAXQO.js.map → validate-CSJM7XZM.js.map} +0 -0
  157. /package/dist/{viewer-check-45T2HLAH.js.map → viewer-check-L4B4LIAX.js.map} +0 -0
  158. /package/dist/{winning-ads-ASH5DSV3.js.map → winning-ads-2WS7FI4E.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  schemaArgs,
3
3
  stageChatgptOp
4
- } from "./chunk-35XWJEWH.js";
4
+ } from "./chunk-7J6EHOH6.js";
5
5
  import {
6
6
  CHATGPT_ADS_REFERENCE
7
- } from "./chunk-KLBTXETO.js";
7
+ } from "./chunk-FTWJFDIN.js";
8
8
  import "./chunk-VFIOJD5M.js";
9
9
  import "./chunk-XBOK23HI.js";
10
10
  import "./chunk-IFWP3ZDO.js";
@@ -57,4 +57,4 @@ export {
57
57
  pixelCreateOp,
58
58
  pixelsCommand
59
59
  };
60
- //# sourceMappingURL=pixels-45A55MOP.js.map
60
+ //# sourceMappingURL=pixels-TZPF746S.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  executeCanvasRun
3
- } from "./chunk-GBMP4F45.js";
4
- import "./chunk-K7FZXIOZ.js";
5
- import "./chunk-J5IY3GVE.js";
3
+ } from "./chunk-CMPEUZOR.js";
4
+ import "./chunk-464O4MT2.js";
5
+ import "./chunk-Q2V6E6SL.js";
6
6
  import "./chunk-WN4KX7GE.js";
7
7
  import "./chunk-PWGWMIIJ.js";
8
8
  import "./chunk-W3ZHJJVT.js";
@@ -10,13 +10,13 @@ import "./chunk-IVIJJXXT.js";
10
10
  import "./chunk-WS2GMOSG.js";
11
11
  import "./chunk-Q6ULQMWG.js";
12
12
  import "./chunk-KKJ4KJCW.js";
13
- import "./chunk-IBURXTL4.js";
14
- import "./chunk-FD27ZDVP.js";
15
- import "./chunk-5Y5UAJWD.js";
16
- import "./chunk-Z2EOC6PL.js";
13
+ import "./chunk-S3A3YOKO.js";
14
+ import "./chunk-Y6ZQXUZ7.js";
15
+ import "./chunk-KAUOHQTF.js";
16
+ import "./chunk-YUCLMOEG.js";
17
17
  import "./chunk-3ACMDRSE.js";
18
18
  import "./chunk-A4LOJ2VD.js";
19
- import "./chunk-7ZHMGXE2.js";
19
+ import "./chunk-NJXNU2G6.js";
20
20
  import "./chunk-4QEY2L6U.js";
21
21
  import "./chunk-QRP3PXWN.js";
22
22
  import "./chunk-3IBYKLXR.js";
@@ -24,13 +24,13 @@ import "./chunk-NFSLRRIE.js";
24
24
  import "./chunk-F2S5BLPE.js";
25
25
  import "./chunk-WTOYCUKH.js";
26
26
  import "./chunk-DZSIUEGH.js";
27
- import "./chunk-GLCPTMPG.js";
28
- import "./chunk-K66OLA6Y.js";
27
+ import "./chunk-OQ6663F4.js";
28
+ import "./chunk-EBWBG6YV.js";
29
29
  import "./chunk-W3B4BHQU.js";
30
- import "./chunk-KFE3S63W.js";
30
+ import "./chunk-NCWCZY5P.js";
31
31
  import "./chunk-DGCUPJZD.js";
32
- import "./chunk-VB6WJJR3.js";
33
- import "./chunk-CHSNHVYF.js";
32
+ import "./chunk-PZXCWSKV.js";
33
+ import "./chunk-CAMX6OHF.js";
34
34
  import "./chunk-RX6F3GEA.js";
35
35
  import "./chunk-5HYSKH77.js";
36
36
  import "./chunk-KIGGMKAE.js";
@@ -82,4 +82,4 @@ var rerunCommand = defineCommand({
82
82
  export {
83
83
  rerunCommand
84
84
  };
85
- //# sourceMappingURL=rerun-CET74VPF.js.map
85
+ //# sourceMappingURL=rerun-6XZG7BGK.js.map
@@ -43,7 +43,7 @@ Full guide: __tooling__/docs/tools/baker/research.md`
43
43
  fetch: () => import("./fetch-W7NULDEO.js").then((m) => m.fetchCommand),
44
44
  "google-ads": () => import("./google-ads-OK6IG3UV.js").then((m) => m.googleAdsCommand),
45
45
  reddit: () => import("./reddit-GIP3ADMS.js").then((m) => m.redditCommand),
46
- customers: () => import("./customers-4AWBFDUF.js").then((m) => m.customersCommand),
46
+ customers: () => import("./customers-A36LOZOB.js").then((m) => m.customersCommand),
47
47
  advertisers: () => import("./advertisers-AE75CGVE.js").then((m) => m.advertisersCommand),
48
48
  autocomplete: () => import("./autocomplete-VS3XG3B7.js").then((m) => m.autocompleteCommand),
49
49
  countries: () => import("./countries-ESAKTQAE.js").then((m) => m.countriesCommand),
@@ -59,4 +59,4 @@ Full guide: __tooling__/docs/tools/baker/research.md`
59
59
  export {
60
60
  researchCommand
61
61
  };
62
- //# sourceMappingURL=research-EY7C7JJY.js.map
62
+ //# sourceMappingURL=research-2BLEISBG.js.map
@@ -3,9 +3,9 @@ import {
3
3
  executeCanvasRun,
4
4
  runCommand,
5
5
  stopBeforeKinds
6
- } from "./chunk-GBMP4F45.js";
7
- import "./chunk-K7FZXIOZ.js";
8
- import "./chunk-J5IY3GVE.js";
6
+ } from "./chunk-CMPEUZOR.js";
7
+ import "./chunk-464O4MT2.js";
8
+ import "./chunk-Q2V6E6SL.js";
9
9
  import "./chunk-WN4KX7GE.js";
10
10
  import "./chunk-PWGWMIIJ.js";
11
11
  import "./chunk-W3ZHJJVT.js";
@@ -13,13 +13,13 @@ import "./chunk-IVIJJXXT.js";
13
13
  import "./chunk-WS2GMOSG.js";
14
14
  import "./chunk-Q6ULQMWG.js";
15
15
  import "./chunk-KKJ4KJCW.js";
16
- import "./chunk-IBURXTL4.js";
17
- import "./chunk-FD27ZDVP.js";
18
- import "./chunk-5Y5UAJWD.js";
19
- import "./chunk-Z2EOC6PL.js";
16
+ import "./chunk-S3A3YOKO.js";
17
+ import "./chunk-Y6ZQXUZ7.js";
18
+ import "./chunk-KAUOHQTF.js";
19
+ import "./chunk-YUCLMOEG.js";
20
20
  import "./chunk-3ACMDRSE.js";
21
21
  import "./chunk-A4LOJ2VD.js";
22
- import "./chunk-7ZHMGXE2.js";
22
+ import "./chunk-NJXNU2G6.js";
23
23
  import "./chunk-4QEY2L6U.js";
24
24
  import "./chunk-QRP3PXWN.js";
25
25
  import "./chunk-3IBYKLXR.js";
@@ -27,13 +27,13 @@ import "./chunk-NFSLRRIE.js";
27
27
  import "./chunk-F2S5BLPE.js";
28
28
  import "./chunk-WTOYCUKH.js";
29
29
  import "./chunk-DZSIUEGH.js";
30
- import "./chunk-GLCPTMPG.js";
31
- import "./chunk-K66OLA6Y.js";
30
+ import "./chunk-OQ6663F4.js";
31
+ import "./chunk-EBWBG6YV.js";
32
32
  import "./chunk-W3B4BHQU.js";
33
- import "./chunk-KFE3S63W.js";
33
+ import "./chunk-NCWCZY5P.js";
34
34
  import "./chunk-DGCUPJZD.js";
35
- import "./chunk-VB6WJJR3.js";
36
- import "./chunk-CHSNHVYF.js";
35
+ import "./chunk-PZXCWSKV.js";
36
+ import "./chunk-CAMX6OHF.js";
37
37
  import "./chunk-RX6F3GEA.js";
38
38
  import "./chunk-5HYSKH77.js";
39
39
  import "./chunk-KIGGMKAE.js";
@@ -57,4 +57,4 @@ export {
57
57
  runCommand,
58
58
  stopBeforeKinds
59
59
  };
60
- //# sourceMappingURL=run-XQ7EM3JT.js.map
60
+ //# sourceMappingURL=run-MMEDKJDB.js.map
@@ -4,17 +4,17 @@ import {
4
4
  import {
5
5
  SHIPPED_CAPTIONS_DIR,
6
6
  SHIPPED_OVERLAY_COMPOSITION_DIR
7
- } from "./chunk-ULJ5RFOV.js";
7
+ } from "./chunk-XFGAUP5B.js";
8
8
  import {
9
9
  syncCreativeDefinitionBestEffort
10
- } from "./chunk-TT5R35PJ.js";
11
- import "./chunk-K7FZXIOZ.js";
10
+ } from "./chunk-LECGCWT5.js";
11
+ import "./chunk-464O4MT2.js";
12
12
  import {
13
13
  readAvatars
14
14
  } from "./chunk-PWGWMIIJ.js";
15
15
  import {
16
16
  pinnedModelHint
17
- } from "./chunk-HQSCJYZO.js";
17
+ } from "./chunk-P5T7OZKV.js";
18
18
  import {
19
19
  enforceNewCreativeLimit
20
20
  } from "./chunk-ZZQXVYUY.js";
@@ -24,7 +24,7 @@ import {
24
24
  resolveFormats,
25
25
  resolvePlatform,
26
26
  titleFromSlug
27
- } from "./chunk-FD27ZDVP.js";
27
+ } from "./chunk-Y6ZQXUZ7.js";
28
28
  import {
29
29
  BRAND_DIR,
30
30
  REBUILD_FILE,
@@ -54,7 +54,7 @@ import {
54
54
  voiceGenderModel,
55
55
  webFontUrl,
56
56
  writeSceneFiles
57
- } from "./chunk-Z2EOC6PL.js";
57
+ } from "./chunk-YUCLMOEG.js";
58
58
  import "./chunk-4QEY2L6U.js";
59
59
  import {
60
60
  fetchJson,
@@ -73,19 +73,19 @@ import {
73
73
  import {
74
74
  defaultRegistry,
75
75
  validateCanvasDeep
76
- } from "./chunk-GLCPTMPG.js";
76
+ } from "./chunk-OQ6663F4.js";
77
77
  import {
78
78
  READ_WORDS_PER_SECOND,
79
79
  wordCount
80
- } from "./chunk-K66OLA6Y.js";
80
+ } from "./chunk-EBWBG6YV.js";
81
81
  import "./chunk-W3B4BHQU.js";
82
82
  import {
83
83
  videoSafeArea
84
- } from "./chunk-KFE3S63W.js";
84
+ } from "./chunk-NCWCZY5P.js";
85
85
  import "./chunk-DGCUPJZD.js";
86
86
  import {
87
87
  ACTOR_SHEET_MODEL
88
- } from "./chunk-VB6WJJR3.js";
88
+ } from "./chunk-PZXCWSKV.js";
89
89
  import {
90
90
  AD_IMAGE_MODEL,
91
91
  DEFAULT_VIDEO_GENERATE_MODEL,
@@ -95,7 +95,7 @@ import {
95
95
  clipDurationsFor,
96
96
  frameRealismDirection,
97
97
  withoutCastName
98
- } from "./chunk-CHSNHVYF.js";
98
+ } from "./chunk-CAMX6OHF.js";
99
99
  import "./chunk-RX6F3GEA.js";
100
100
  import "./chunk-5HYSKH77.js";
101
101
  import "./chunk-KIGGMKAE.js";
@@ -1546,4 +1546,4 @@ async function stageBrandDisplayFace(outDir, compositionDir) {
1546
1546
  export {
1547
1547
  scaffoldAdCommand
1548
1548
  };
1549
- //# sourceMappingURL=scaffold-ad-U2KSHKBC.js.map
1549
+ //# sourceMappingURL=scaffold-ad-PBTEWDAC.js.map
@@ -9,15 +9,15 @@ import {
9
9
  loadAssetText,
10
10
  parseElements,
11
11
  resolveModel
12
- } from "./chunk-ULJ5RFOV.js";
12
+ } from "./chunk-XFGAUP5B.js";
13
13
  import {
14
14
  syncCreativeDefinitionBestEffort
15
- } from "./chunk-TT5R35PJ.js";
15
+ } from "./chunk-LECGCWT5.js";
16
16
  import {
17
17
  buildBackendClient
18
- } from "./chunk-GBMP4F45.js";
19
- import "./chunk-K7FZXIOZ.js";
20
- import "./chunk-J5IY3GVE.js";
18
+ } from "./chunk-CMPEUZOR.js";
19
+ import "./chunk-464O4MT2.js";
20
+ import "./chunk-Q2V6E6SL.js";
21
21
  import "./chunk-WN4KX7GE.js";
22
22
  import "./chunk-PWGWMIIJ.js";
23
23
  import "./chunk-W3ZHJJVT.js";
@@ -28,7 +28,7 @@ import "./chunk-KKJ4KJCW.js";
28
28
  import {
29
29
  enforceNewCreativeLimit
30
30
  } from "./chunk-ZZQXVYUY.js";
31
- import "./chunk-IBURXTL4.js";
31
+ import "./chunk-S3A3YOKO.js";
32
32
  import {
33
33
  buildCreativeDefinition,
34
34
  describeBlueprintIntent,
@@ -37,8 +37,8 @@ import {
37
37
  resolvePlatform,
38
38
  setDefinitionViewer,
39
39
  titleFromSlug
40
- } from "./chunk-FD27ZDVP.js";
41
- import "./chunk-5Y5UAJWD.js";
40
+ } from "./chunk-Y6ZQXUZ7.js";
41
+ import "./chunk-KAUOHQTF.js";
42
42
  import {
43
43
  brandBlock,
44
44
  brandHeadlineFont,
@@ -53,14 +53,14 @@ import {
53
53
  staticAdSpec,
54
54
  staticAvatarsNotCast,
55
55
  webFontUrl
56
- } from "./chunk-Z2EOC6PL.js";
56
+ } from "./chunk-YUCLMOEG.js";
57
57
  import "./chunk-3ACMDRSE.js";
58
58
  import "./chunk-A4LOJ2VD.js";
59
59
  import {
60
60
  describeViewer,
61
61
  liveViewerLookups,
62
62
  resolveViewer
63
- } from "./chunk-7ZHMGXE2.js";
63
+ } from "./chunk-NJXNU2G6.js";
64
64
  import "./chunk-4QEY2L6U.js";
65
65
  import {
66
66
  LIBRARY_PLATFORMS,
@@ -73,7 +73,7 @@ import {
73
73
  readCachedFit,
74
74
  referenceDescribeContext,
75
75
  resolveSourcePlatform
76
- } from "./chunk-54UVGFX3.js";
76
+ } from "./chunk-EAP4O4FE.js";
77
77
  import {
78
78
  fetchJson,
79
79
  lookupGoogleCss
@@ -92,16 +92,16 @@ import {
92
92
  createEngineFromEnv,
93
93
  defaultRegistry,
94
94
  validateCanvasDeep
95
- } from "./chunk-GLCPTMPG.js";
96
- import "./chunk-K66OLA6Y.js";
95
+ } from "./chunk-OQ6663F4.js";
96
+ import "./chunk-EBWBG6YV.js";
97
97
  import "./chunk-W3B4BHQU.js";
98
- import "./chunk-KFE3S63W.js";
98
+ import "./chunk-NCWCZY5P.js";
99
99
  import "./chunk-DGCUPJZD.js";
100
100
  import {
101
101
  conceptClassOf,
102
102
  conceptProblems,
103
103
  readAdSpec
104
- } from "./chunk-VB6WJJR3.js";
104
+ } from "./chunk-PZXCWSKV.js";
105
105
  import {
106
106
  AD_DESCRIBE_FOCUS,
107
107
  AD_DESCRIBE_MODEL,
@@ -111,7 +111,7 @@ import {
111
111
  AD_SELECT_SYSTEM,
112
112
  BLUEPRINT_ANALYSIS_MODEL,
113
113
  deliverySet
114
- } from "./chunk-CHSNHVYF.js";
114
+ } from "./chunk-CAMX6OHF.js";
115
115
  import "./chunk-RX6F3GEA.js";
116
116
  import {
117
117
  VIEWER_KNOWS_VALUES,
@@ -471,7 +471,7 @@ var VIEWER_PLACEMENTS_DESCRIPTION = "Where the viewer meets the ad, comma-separa
471
471
  var SOURCE_ADVERTISER_ID_DESCRIPTION = "The library advertiser id of the reference (the `advertiser_id` beside the ad in search results). Defaults to the one the library returns for the ad.";
472
472
  registerSchema({
473
473
  command: "canvas.scaffold-static-ad",
474
- description: "Turn a reference image into a runnable static-ad canvas: billed image_describe + element-selection passes, then a canvas on which the image model renders the finished ad from prompt.json. Start here for a static ad adapted from a winning ad: pass `--source-ad-id <ad_id> --source-platform <platform>` from the search result, so the library's structured read grounds the describe pass (and so prompt.json) and the source is recorded on the creative; the image may then be omitted. A person in one ad is an invented, realistic person drawn from the description; `--avatar <handle>` (`baker avatars list`) only when the same actor must recur across ads.",
474
+ description: "Turn a reference image into a runnable static-ad canvas: billed image_describe + element-selection passes, then a canvas on which the image model renders the finished ad from prompt.json. Start here for a static ad adapted from a winning ad: pass `--source-ad-id <ad_id> --source-platform <platform>` from the search result, so the library's structured read grounds the describe pass (and so prompt.json) and the source is recorded on the creative; the image may then be omitted. Use `--avatar <handle>` by default whenever the ad needs a person: inspect `baker avatars list`, choose a ready actor who fits the buyer, or create one with explicit identity and setting. Description-only casting remains available when explicitly requested.",
475
475
  args: {
476
476
  file: {
477
477
  type: "positional",
@@ -642,7 +642,7 @@ async function scaffoldFromSpec(args, slug) {
642
642
  var scaffoldStaticAdCommand = defineCommand({
643
643
  meta: {
644
644
  name: "scaffold-static-ad",
645
- description: "Turn a source/inspiration image into a runnable static-ad canvas. Runs billed passes \u2014 image_describe (read into prompt.json, the ad spec you rewrite) and an AI selection of the image's MAIN identity elements \u2014 then scaffolds a canvas on which the image model renders the FINISHED ad: up to three variants, one request each, from a brief compiled from prompt.json, the copy quoted verbatim, the brand's typeface shown as a specimen and the logo from src/brand/logos/ as a reference (only when prompt.json has \"logo\": true). A prefilter drops variants whose words or placement fail the checks, and a judge compares the rest pairwise against the brief; the chosen picture is delivered at the lead format (4:5 for a feed) and every other placement format is that ad re-laid out for its own frame by one image request, with the chosen picture as the reference: the same words, people, product and logo, re-scaled for the frame, never cut or shrunk onto a background. The run reads every word back and refuses to call the ad ready when one is off. No copy means the picture is the ad. Pass --placements none for a single base ad, or a preset to pick the set. Edit prompt.json and drop the real assets, then `baker canvas run` it. A person who appears in this one ad is drawn as an invented, realistic person from the description \u2014 no slot to fill; pass `--avatar <handle>` (`baker avatars list`) only when the same actor has to recur across several ads. Never a photo of anyone real. A reference from the library: pass `--source-ad-id <ad_id> --source-platform <platform>` so its structured read grounds the describe pass and the source is recorded on the creative."
645
+ description: "Turn a source/inspiration image into a runnable static-ad canvas. Runs billed passes \u2014 image_describe (read into prompt.json, the ad spec you rewrite) and an AI selection of the image's MAIN identity elements \u2014 then scaffolds a canvas on which the image model renders the FINISHED ad: up to three variants, one request each, from a brief compiled from prompt.json, the copy quoted verbatim, the brand's typeface shown as a specimen and the logo from src/brand/logos/ as a reference (only when prompt.json has \"logo\": true). A prefilter drops variants whose words or placement fail the checks, and a judge compares the rest pairwise against the brief; the chosen picture is delivered at the lead format (4:5 for a feed) and every other placement format is that ad re-laid out for its own frame by one image request, with the chosen picture as the reference: the same words, people, product and logo, re-scaled for the frame, never cut or shrunk onto a background. The run reads every word back and refuses to call the ad ready when one is off. No copy means the picture is the ad. Pass --placements none for a single base ad, or a preset to pick the set. Edit prompt.json and drop the real assets, then `baker canvas run` it. A person is cast from a suitable company Avatar by default: pass `--avatar <handle>` (`baker avatars list`), or create one with explicit identity and buyer setting. A description-only one-off remains available when explicitly requested. Never cast a stranger from a searched photo. A reference from the library: pass `--source-ad-id <ad_id> --source-platform <platform>` so its structured read grounds the describe pass and the source is recorded on the creative."
646
646
  },
647
647
  args: {
648
648
  file: {
@@ -694,7 +694,7 @@ var scaffoldStaticAdCommand = defineCommand({
694
694
  },
695
695
  avatar: {
696
696
  type: "string",
697
- description: "Cast company avatars as the ad's people \u2014 pass this when the same actor has to recur across several ads (a one-off person needs none: they are drawn from the description). One handle, or several comma-separated in the order the people were detected (`--avatar marta` / `--avatar marta,joan`). Each person slot grounds on that avatar's identity sheet and prompt.json describes them in the avatar's own words, so the ad shows the company's cast instead of the source ad's. `baker avatars list` shows who there is; checked before anything is billed."
697
+ description: "Cast company avatars as the ad's people \u2014 preferred whenever an ad needs an actor, including a single ad. Choose a ready avatar who fits the buyer, or create one with explicit identity and setting. One handle, or several comma-separated in the order the people were detected (`--avatar marta` / `--avatar marta,joan`). Each person slot grounds on that avatar's identity sheet and prompt.json describes them in the avatar's own words, so the ad shows the company's cast instead of the source ad's. `baker avatars list` shows who there is; checked before anything is billed."
698
698
  }
699
699
  },
700
700
  async run({ args }) {
@@ -940,7 +940,7 @@ var scaffoldStaticAdCommand = defineCommand({
940
940
  in_scene_text: report.in_scene_text,
941
941
  logo: report.logo.why,
942
942
  takes: report.takes === 1 ? "1 finished ad is rendered and used as it is (no judge)." : `${report.takes} variants of the finished ad are rendered, one request each on its own direction. A prefilter drops any whose words or placement fail the checks, and the judge compares the rest pairwise against the brief (words, picture, space, one idea, the brief itself, brand); the winner becomes the ad and the others stay in the run as options the person can switch to (\`baker canvas run --use-variant\`).`,
943
- pictures: "The reference's own people, products, animals and badges are not slots to fill: they are the source's world. A person is drawn from the description, or cast from a company Avatar (--avatar <handle>) when they recur across ads; never a found photo. To show our own product or another picture, add it to prompt.json's `references` with its `image` (a path from this folder, or a URL): every run wires it.",
943
+ pictures: "The reference's own people, products, animals and badges are not slots to fill: they are the source's world. Cast a person from a suitable ready company Avatar by default (--avatar <handle>); create one from the buyer context if none fits. A description-only one-off is available when explicitly requested; never use a stranger's found photo. To show our own product or another picture, add it to prompt.json's `references` with its `image` (a path from this folder, or a URL): every run wires it.",
944
944
  formats: staticFormatsNote(report, opts.genModel),
945
945
  viewer: viewerNote(who),
946
946
  note: `Populate as you go: for each [TODO] ingest slot, source its real asset and wire it into the slot right away, one at a time. The logo is optional and never a slot to fill: it is given to the model only when prompt.json has \`"logo": true\` and src/brand/logos/ has the real file; never fetch or draw a stand-in. When every slot is filled, \`baker canvas validate\` then \`baker canvas run\`. Running generates billed images: it is not free.`
@@ -963,4 +963,4 @@ export {
963
963
  uploadSourceAsReference,
964
964
  validateScaffoldedStaticAd
965
965
  };
966
- //# sourceMappingURL=scaffold-static-ad-63LQKUSO.js.map
966
+ //# sourceMappingURL=scaffold-static-ad-RM4M4X5U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/canvas/scaffold-static-ad.ts","../src/commands/canvas/scaffold-viewer.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n AD_DESCRIBE_FOCUS,\n AD_DESCRIBE_MODEL,\n AD_FORMAT_PLATFORMS,\n AD_PLATFORMS,\n AD_SELECT_PROMPT,\n AD_SELECT_SYSTEM,\n type AdFormatPlatform,\n BLUEPRINT_ANALYSIS_MODEL,\n deliverySet,\n} from \"@baker/canvas-contract\";\nimport { referenceReadResponseSchema } from \"@baker/api/ad-library\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../client.ts\";\nimport { enforceNewCreativeLimit } from \"./creative-limit.ts\";\nimport type { BackendClient } from \"../../engine/client/backend-client.ts\";\nimport type { ValidationIssue } from \"../../engine/engine/errors.ts\";\nimport { createEngineFromEnv, defaultRegistry, ValidationError, validateCanvasDeep } from \"../../engine/index.ts\";\nimport { toModelSafeImage } from \"../../engine/nodes/ingest.ts\";\nimport { sha256Hex } from \"../../engine/storage/sha256.ts\";\nimport { fetchExternalBytes, MAX_REMOTE_IMAGE_BYTES } from \"../../lib/externalFetch.ts\";\nimport { brandBlock, readNamedTypefaces, readStaticBrandKit } from \"../../engine/scaffold/static-brand.ts\";\nimport { brandHeadlineFont, type ResolvedFont, webFontUrl } from \"../../engine/scaffold/static-fonts.ts\";\nimport { pickImageModel } from \"../../engine/lib/image-model-router.ts\";\nimport { conceptClassOf, conceptProblems, readAdSpec } from \"../../engine/scaffold/static-ad-spec.ts\";\nimport {\n castAvatarsOnStaticElements,\n type StaticAdOpts,\n scaffoldStaticAd,\n staticAdReport,\n staticAdSpec,\n staticAvatarsNotCast,\n} from \"../../engine/scaffold/staticAd.ts\";\nimport {\n fail,\n fileExists,\n loadAssetText,\n parseElements,\n resolveModel,\n} from \"./scaffold-common.ts\";\nimport { fetchJson, lookupGoogleCss } from \"../brand/fonts.ts\";\nimport { findBrandRoot } from \"./static-copy-projection.ts\";\nimport {\n buildCreativeDefinition,\n describeBlueprintIntent,\n resolveFormatList,\n resolvePlatform,\n setDefinitionViewer,\n titleFromSlug,\n} from \"./creative-definition.ts\";\nimport { buildBackendClient } from \"./run.ts\";\nimport { isValidScaffoldSlug, resolveScaffoldStaticAdPaths } from \"./scaffold-static-ad-paths.ts\";\nimport { resolveRelativeCanvasPaths } from \"./resolve-paths.ts\";\nimport { computeSourceSha } from \"./source-version.ts\";\nimport { syncCreativeDefinitionBestEffort } from \"./sync-definition.ts\";\nimport { type ScaffoldViewer, scaffoldViewer } from \"./scaffold-viewer.ts\";\nimport { describeViewer, liveViewerLookups } from \"./viewer-check.ts\";\nimport { resolveCastAvatars } from \"../avatars/resolveCast.ts\";\nimport {\n fetchLibraryReference,\n LIBRARY_PLATFORMS,\n type LibraryReference,\n libraryReferenceBlock,\n mergeReferenceIntoBlueprint,\n referenceDescribeContext,\n resolveSourcePlatform,\n} from \"./library-reference.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { conceptFromFit, fitHints, NO_FIT_HINT, readCachedFit } from \"../winning-ads/fit.ts\";\nimport { findWorkspaceRoot } from \"./normalize-paths.ts\";\nimport { marketFromCompanyDoc, VIEWER_TEMPERATURE_VALUES } from \"../../viewer-profile.ts\";\n\n/** A workspace file as the canvas refers to it: relative to the canvas, never absolute. */\nfunction toCanvasRelative(canvasDir: string, file: string): string {\n const rel = path.relative(canvasDir, file).split(path.sep).join(\"/\");\n return rel.startsWith(\".\") ? rel : `./${rel}`;\n}\n\n/**\n * Localize the source image to the durable content-addressed R2 store — downloading a URL first,\n * since winning-ad references are presigned and expire within the hour — so both the vision passes\n * and the emitted canvas ingest a stable URL that re-runs in any future sandbox. Raster source\n * images NEVER enter git (they bloated every client repo when this wrote a committed\n * `references/` copy); the R2 URL is content-addressed, so it survives forever and re-scaffolds\n * of the same source upload nothing new.\n *\n * The bytes are normalized through `toModelSafeImage` up front (rasterizing SVG/AVIF/HEIC/… to\n * PNG), so the first `baker canvas run` ingests a model-safe reference.\n */\nexport async function uploadSourceAsReference(\n source: string,\n isUrl: boolean,\n client: BackendClient,\n): Promise<string> {\n let bytes: Buffer;\n if (isUrl) {\n // Somebody else's server, so it climbs on a refusal. The R2 PUT below is\n // ours and deliberately stays a bare `fetch` — routing our own storage\n // through a metered exit would bill us for our own bytes.\n try {\n ({ buffer: bytes } = await fetchExternalBytes(source, { maxBytes: MAX_REMOTE_IMAGE_BYTES }));\n } catch (e) {\n throw new Error(`failed to download source image (${e instanceof Error ? e.message : String(e)})`);\n }\n } else {\n bytes = await readFile(source);\n }\n const safe = await toModelSafeImage(bytes);\n const sha256 = sha256Hex(safe.bytes);\n // \"source\": wired into the COMMITTED canvas.json — the GC registry pins it forever.\n const { putUrl, publicUrl } = await client.presignAssetUpload(sha256, safe.mime, undefined, \"source\");\n const putRes = await fetch(putUrl, {\n method: \"PUT\",\n body: new Uint8Array(safe.bytes),\n headers: { \"Content-Type\": safe.mime },\n });\n if (!putRes.ok) throw new Error(`source upload failed (${putRes.status})`);\n return publicUrl;\n}\n\n/**\n * The typeface the model is shown: the brand's font file, else the family tokens.json or\n * BRAND.md names (fetched as a web font file). Null when the brand names none: the model\n * then follows the blueprint's `fonts`, and no neutral default is put in front of it.\n */\nasync function brandFace(\n root: string,\n kit: { headlineFont?: string },\n toCanvas: (file: string) => string,\n): Promise<ResolvedFont | null> {\n const font = await brandHeadlineFont({\n file: kit.headlineFont,\n named: await readNamedTypefaces(root),\n resolveUrl: (family, weight) => webFontUrl(family, weight, { lookupGoogleCss, fetchJson }),\n });\n if (!font) return null;\n return \"path\" in font.slot ? { ...font, slot: { path: toCanvas(font.slot.path) } } : font;\n}\n\ntype Report = ReturnType<typeof staticAdReport>;\n\n/** What the checklist says about the copy. */\nfunction staticTextNote(report: Report): string {\n if (report.text_forward) {\n return \"The reference pictures nothing but copy, so this ad is its words on the brand's colours: keep prompt.json's \\`references\\` empty unless the concept wants a picture.\";\n }\n const face = report.font ? `in ${report.font}, shown to it as a specimen` : \"in the face `brand.typeface` names (the brand has no font file)\";\n return `The copy is set by the image model: every line of \\`copy\\` in prompt.json, exactly as written, once. A line marked \\`\"lettering\": \"designed\"\\` is set ${face}; a line marked \\`\"in_scene\"\\` is lettered on the object it names (\\`on\\`), the way \\`look\\` says. Edit the copy in prompt.json; every run compiles the render prompts from it again and the review reads every word back against it.`;\n}\n\n/** How each delivered format is made. */\nfunction staticFormatsNote(report: Report, genModel: string): string {\n const set =\n report.placements === null && report.platforms === null\n ? \" Pass --platforms meta,tiktok,google_display,… for every size where the ad runs.\"\n : \"\";\n const banners =\n report.banners.length > 0\n ? ` The fixed banners ${report.banners.join(\", \")} are not made from the picture: make them apart, from the delivered sizes, before staging a display campaign.`\n : \"\";\n const plan = report.format_plan;\n const made: Record<string, (format: string) => string> = {\n master: (format) => `${format} is the chosen picture (rendered at ${plan.master.renderRatio})`,\n relayout: (format) =>\n `${format} is the chosen ad re-laid out for that frame by the image model (one billed request): the same words, people, product and logo, re-scaled for the frame, inside its safe area`,\n crop: (format) => `${format} is cut from it, every word kept inside its safe area (free)`,\n adapt: (format) => `${format} is adapted from it by the reframe model (one billed request)`,\n };\n const how = plan.sizes.map((f) => made[f.from]?.(f.format) ?? f.format).join(\"; \");\n const again = plan.sizes.some((s) => s.from === \"relayout\") ? \"\" : \" No size is rendered again.\";\n return `Delivers ${report.output_formats.join(\", \")}, each at its exact size, all from one picture (${genModel}): ${how}.${again}${set}${banners}`;\n}\n\n/** Who the ad is for, in the output: the ad set and the viewer it reaches, when known. */\nfunction viewerOutput(who: ScaffoldViewer): Record<string, unknown> {\n return {\n ...(who.targetAdSet ? { target_adset: who.targetAdSet } : {}),\n ...(who.viewer\n ? {\n viewer: {\n temperature: who.viewer.temperature,\n knows: who.viewer.knows,\n placements: who.viewer.placements,\n source: who.viewer.source,\n },\n }\n : {}),\n };\n}\n\n/** What the checklist says about the viewer. */\nfunction viewerNote(who: ScaffoldViewer): string {\n if (!who.viewer) {\n return \"Nobody said who sees this ad: pass --target-adset <id> (or, with no ad account, --viewer-temperature from the Knowledge) so the sizes keep clear of its placements and every run checks the ad against that viewer. Until then it is checked against a cold stranger.\";\n }\n const sizes = who.adPlacements ? `the sizes keep clear of ${who.adPlacements.join(\", \")}` : \"the sizes keep clear of every placement (Advantage+)\";\n return `Made for ${describeViewer(who.viewer)}: write prompt.json's \\`viewer\\` for them, ${sizes}, and every run checks the ad against this viewer before it spends.`;\n}\n\n/** Resolve every model id, honoring overrides; an unknown override throws (see `resolveModel`). */\nfunction resolveModels(args: Record<string, unknown>) {\n return {\n describeModel: resolveModel(\"image_describe\", args[\"describe-model\"], AD_DESCRIBE_MODEL),\n selectModel: resolveModel(\"text_generate\", args[\"select-model\"], BLUEPRINT_ANALYSIS_MODEL),\n // The render model: `--gen-model`, else the router's model for the concept (decided once\n // the blueprint is read, `renderModelFor`). Resolved here only so a bad override fails for free.\n genModel: args[\"gen-model\"] ? resolveModel(\"image_generate\", args[\"gen-model\"], String(args[\"gen-model\"])) : undefined,\n };\n}\n\n// Each `_definition.md` platform maps to the placement preset a static ad on that\n// channel should ship. Channels whose default static placement is a single ratio\n// (x's 1.91:1 card is off-grid; \"other\" is unknown) get no fan-out — the base ad only.\nexport const PLATFORM_PLACEMENTS: Record<string, AdFormatPlatform | undefined> = {\n meta: \"meta_feed_stories\",\n google: \"google_demandgen\",\n linkedin: \"linkedin\",\n tiktok: \"tiktok\",\n youtube: \"youtube\",\n x: undefined,\n other: undefined,\n};\n\n/** A validated placement resolution — a preset (or undefined for no fan-out), or an error to fail fast on. */\nexport type PlacementsResolution =\n | { ok: true; placements: AdFormatPlatform | undefined }\n | { ok: false; message: string };\n\n/**\n * The placement set to fan the ad out to. `--placements` wins when given —\n * `none` disables fan-out, any AD_FORMAT_PLATFORMS value forces that set, and an\n * UNRECOGNIZED value is an error (it silently changes what gets billed/rendered,\n * so we surface the typo instead of falling back). With no flag, it's derived\n * from the definition platform (default meta → feed+stories).\n */\nexport function resolvePlacements(placementsFlag: string | undefined, definitionPlatform: string): PlacementsResolution {\n const flag = placementsFlag?.trim();\n if (flag === undefined || flag === \"\") return { ok: true, placements: PLATFORM_PLACEMENTS[definitionPlatform] };\n if (flag === \"none\") return { ok: true, placements: undefined };\n if ((AD_FORMAT_PLATFORMS as readonly string[]).includes(flag)) return { ok: true, placements: flag as AdFormatPlatform };\n return {\n ok: false,\n message: `--placements \"${flag}\" is not a valid placement set. Use one of: ${AD_FORMAT_PLATFORMS.join(\", \")}, or \"none\" for a single base ad.`,\n };\n}\n\n/**\n * `--platforms`: where the ad runs, as platforms or placement ids from the registry\n * (`AD_PLATFORMS`, `AD_PLACEMENTS`). A name the registry does not hold is refused rather than\n * dropped, since it silently changes the sizes made and billed.\n */\nexport function resolvePlatforms(\n flag: string | undefined,\n): { ok: true; platforms: string[] | undefined } | { ok: false; message: string } {\n const names = (flag ?? \"\").split(\",\").map((n) => n.trim()).filter(Boolean);\n if (names.length === 0) return { ok: true, platforms: undefined };\n const { unknown, formats, banners } = deliverySet(names);\n if (unknown.length > 0) {\n return { ok: false, message: `--platforms names ${unknown.join(\", \")}, which is no platform here. Use any of: ${AD_PLATFORMS.join(\", \")}.` };\n }\n if (formats.length === 0 && banners.length > 0) {\n return {\n ok: false,\n message: `--platforms ${names.join(\",\")} requires only fixed-size banners (${banners.map((b) => b.format).join(\", \")}), which are never made from the picture: add a platform with a feed or story size (meta, google_display, …).`,\n };\n }\n return { ok: true, platforms: names };\n}\n\n/**\n * Validate the scaffolded canvas as `canvas validate` will read it: canvas-relative paths\n * (`./prompt.json`) resolved against the canvas's own folder. A prompt over the model's cap\n * is the blueprint the describe pass wrote — already paid for, and fixed by editing\n * prompt.json — so it is reported as a hint on a written canvas, never an exit that\n * discards it. Every other issue still blocks.\n */\nexport async function validateScaffoldedStaticAd(\n canvas: unknown,\n canvasDir: string,\n): Promise<{ blocking: ValidationIssue[]; hints: string[]; estimatedCredits?: number }> {\n const validation = await validateCanvasDeep(resolveRelativeCanvasPaths(canvas, canvasDir), defaultRegistry());\n if (validation.ok) return { blocking: [], hints: [], estimatedCredits: validation.estimatedCredits };\n const overCap = validation.issues.filter((i) => i.code === \"PROMPT_OVER_MODEL_LIMIT\");\n return {\n blocking: validation.issues.filter((i) => i.code !== \"PROMPT_OVER_MODEL_LIMIT\"),\n hints: overCap.map((i) => `${i.code}: ${i.message} Trim prompt.json, then \\`baker canvas validate\\`.`),\n };\n}\n\n/** The describe + element-selection canvas, run once up front; we read both node outputs after. */\nexport function buildDescribeCanvas(\n imageSource: string,\n imageIsUrl: boolean,\n describeModel: string,\n selectModel: string,\n context?: string,\n) {\n const originalParams = imageIsUrl\n ? { source: \"url\" as const, url: imageSource, expect: \"image\" as const }\n : { source: \"path\" as const, path: imageSource, expect: \"image\" as const };\n return {\n schema: \"baker-canvas/1\" as const,\n metadata: { name: \"static-ad describe pass\" },\n nodes: [\n { id: \"original\", type: \"ingest\", params: originalParams },\n {\n id: \"describe\",\n type: \"image_describe\",\n inputs: { image: \"$ref:original.asset\" },\n params: { model: describeModel, max_tokens: 9000, ...(context ? { context } : {}), focus: AD_DESCRIBE_FOCUS },\n },\n {\n id: \"select\",\n type: \"text_generate\",\n inputs: { blueprint: \"$ref:describe.description\" },\n params: {\n model: selectModel,\n max_tokens: 4000,\n temperature: 0,\n response_format: \"json_object\",\n system: AD_SELECT_SYSTEM,\n prompt: AD_SELECT_PROMPT,\n },\n },\n ],\n // No declared output: runVisionPasses reads both node outputs after the run.\n };\n}\n\n/** Run the vision passes and read back the blueprint and the selected elements. */\nasync function runVisionPasses(canvas: ReturnType<typeof buildDescribeCanvas>): Promise<{\n blueprint: unknown;\n elements: unknown[];\n creditsSpent: number | undefined;\n}> {\n const engine = createEngineFromEnv({ log: (line) => process.stderr.write(`${line}\\n`) });\n let outputsByNode: Record<string, Record<string, unknown>>;\n let creditsSpent: number | undefined;\n try {\n const result = await engine.run(canvas, {});\n outputsByNode = result.outputs_by_node;\n creditsSpent = (result.stats as { total_credits?: number })?.total_credits;\n } catch (e) {\n if (e instanceof ValidationError) return fail(\"validation\", JSON.stringify(e.issues));\n return fail(\"describe\", e instanceof Error ? e.message : String(e));\n }\n try {\n const blueprint = JSON.parse(await loadAssetText(outputsByNode.describe?.description, \"describe output\"));\n const elements = parseElements(await loadAssetText(outputsByNode.select?.text, \"selection output\"));\n return { blueprint, elements, creditsSpent };\n } catch (e) {\n return fail(\"read_outputs\", e instanceof Error ? e.message : String(e));\n }\n}\n\n/**\n * Whether the picture's read is the library's shared one: a library ad's own picture read with nothing of the\n * company's own (its context, another model) depends only on the ad, so it is read once for every\n * company (`/api/ad-library/reference-read`; dev, Oct 2026: each company paid ~40 s for the same read).\n */\nexport function sharesLibraryRead(args: Record<string, unknown>, fromLibrary: boolean): boolean {\n return fromLibrary && !args.file && !args.context && !args[\"describe-model\"] && !args[\"select-model\"];\n}\n\n/**\n * The library's shared read of the ad, null when it cannot be had (the run then reads the\n * picture itself). A first read takes as long as a local one; a reused one is instant and free.\n */\nasync function sharedLibraryRead(reference: LibraryReference): Promise<Awaited<ReturnType<typeof runVisionPasses>> | null> {\n try {\n const read = referenceReadResponseSchema.parse(\n await apiPost<unknown>(\n \"/api/ad-library/reference-read\",\n { ad_id: reference.ad_id, platform: reference.platform },\n { timeoutMs: 240_000 },\n ),\n );\n process.stderr.write(`[read ] ${read.reused ? \"the library's read of this ad, already made\" : \"read this ad for the library\"}\\n`);\n return {\n blueprint: read.blueprint,\n elements: parseElements(JSON.stringify({ elements: read.elements })),\n creditsSpent: read.credits_charged,\n };\n } catch (e) {\n process.stderr.write(`[read ] the library's read is unavailable (${e instanceof Error ? e.message : String(e)}); reading the picture here\\n`);\n return null;\n }\n}\n\nconst SOURCE_AD_ID_DESCRIPTION =\n \"The winners-library ad this creative adapts (the `ad_id` from `baker winning-ads search`). The library's read of \" +\n \"that ad (container, layout, colours, text blocks with their roles, persuasion mechanism, offer) is fetched and \" +\n \"written into prompt.json as `reference`, the describe pass is told it so the two reads agree, and the source is \" +\n \"recorded on the creative from this scaffold on. With it, the image is optional: the library's picture is used \" +\n \"when none is given. Pass it whenever the reference came from the library.\";\nconst PLATFORMS_DESCRIPTION =\n \"Where the ad runs, comma-separated platforms or placements (e.g. `meta,tiktok`, `google_display`, `meta_reels`): \" +\n \"every size they require is delivered, each kept clear of its own placement's interface (a 9:16 for TikTok keeps clear of TikTok's buttons). \" +\n `Platforms: ${AD_PLATFORMS.join(\", \")}. Wins over --placements. Fixed banner sizes (728x90…) are listed in the report, not made.`;\n\nconst SOURCE_PLATFORM_DESCRIPTION = `Which platform the library ad is on: ${LIBRARY_PLATFORMS.join(\"|\")} (default meta).`;\nconst TARGET_ADSET_DESCRIPTION =\n \"The Meta ad set this ad will run in (an id from `baker ads meta adsets`). Who it reaches is read off its targeting, \" +\n \"as `baker ads meta adsets --audience` reads it, and recorded in _definition.md as `targetAdSet` and `viewer`; the \" +\n \"sizes and the render brief keep clear of its placements, and every run checks the ad against that viewer. Free, \" +\n \"read before anything is billed. Start here whenever the ad is for a known ad set.\";\nconst VIEWER_TEMPERATURE_DESCRIPTION =\n \"With no ad set to read (no ad account, or not decided yet): how warm the viewer is, from the Knowledge (personas, \" +\n \"funnel): cold (never heard of the brand), warm (knows the brand), hot (a customer). Recorded as `viewer` with \" +\n \"`source: knowledge`. With --target-adset it corrects the temperature read off the ad set.\";\nconst VIEWER_KNOWS_DESCRIPTION =\n \"What the viewer already knows, comma-separated from brand,offer,product (e.g. `brand,offer`). Needs \" +\n \"--viewer-temperature or --target-adset.\";\nconst VIEWER_PLACEMENTS_DESCRIPTION =\n \"Where the viewer meets the ad, comma-separated Meta placements (e.g. `instagram_feed,facebook_feed`, \" +\n \"`instagram_stories`); default automatic (Advantage+, Reels included). The sizes keep clear of these placements' \" +\n \"interface. Needs --viewer-temperature or --target-adset.\";\nconst SOURCE_ADVERTISER_ID_DESCRIPTION =\n \"The library advertiser id of the reference (the `advertiser_id` beside the ad in search results). Defaults to the one the library returns for the ad.\";\n\nregisterSchema({\n command: \"canvas.scaffold-static-ad\",\n description:\n \"Turn a reference image into a runnable static-ad canvas: billed image_describe + element-selection passes, then a canvas on which the image model renders the finished ad from prompt.json. Start here for a static ad adapted from a winning ad: pass `--source-ad-id <ad_id> --source-platform <platform>` from the search result, so the library's structured read grounds the describe pass (and so prompt.json) and the source is recorded on the creative; the image may then be omitted. Use `--avatar <handle>` by default whenever the ad needs a person: inspect `baker avatars list`, choose a ready actor who fits the buyer, or create one with explicit identity and setting. Description-only casting remains available when explicitly requested.\",\n args: {\n file: {\n type: \"positional\",\n required: false,\n description: \"Path or http(s) URL to the reference image. Optional with --source-ad-id: the library's picture is used.\",\n },\n \"source-ad-id\": { type: \"string\", required: false, description: SOURCE_AD_ID_DESCRIPTION },\n \"source-platform\": {\n type: \"string\",\n required: false,\n description: SOURCE_PLATFORM_DESCRIPTION,\n enum: [...LIBRARY_PLATFORMS],\n },\n \"source-advertiser-id\": { type: \"string\", required: false, description: SOURCE_ADVERTISER_ID_DESCRIPTION },\n context: {\n type: \"string\",\n required: false,\n description: \"Known provenance (advertiser, category, market, their brand palette) to ground the describe pass\",\n },\n slug: {\n type: \"string\",\n required: false,\n description: \"Creative slug: writes src/creatives/<slug>/<slug>.canvas.json, prompt.json and _definition.md\",\n },\n title: { type: \"string\", required: false, description: \"Creative title for _definition.md (default: title-cased slug)\" },\n platform: {\n type: \"string\",\n required: false,\n description: \"Ad platform for _definition.md and the default placement set (meta|google|linkedin|tiktok|youtube|x|other; default meta)\",\n },\n advertiser: {\n type: \"string\",\n required: false,\n description: \"Source advertiser name for _definition.md (default: the library ad's advertiser when --source-ad-id is given)\",\n },\n placements: {\n type: \"string\",\n required: false,\n description: \"Formats delivered: meta_feed|meta_feed_stories|meta_all|linkedin|google_demandgen|tiktok|youtube, or none for a single base ad (default from --platform)\",\n },\n platforms: { type: \"string\", required: false, description: PLATFORMS_DESCRIPTION },\n aspect: { type: \"string\", required: false, description: \"Force the lead format (else inferred from the image)\" },\n \"target-adset\": { type: \"string\", required: false, description: TARGET_ADSET_DESCRIPTION },\n \"viewer-temperature\": {\n type: \"string\",\n required: false,\n description: VIEWER_TEMPERATURE_DESCRIPTION,\n enum: [...VIEWER_TEMPERATURE_VALUES],\n },\n \"viewer-knows\": { type: \"string\", required: false, description: VIEWER_KNOWS_DESCRIPTION },\n \"viewer-placements\": { type: \"string\", required: false, description: VIEWER_PLACEMENTS_DESCRIPTION },\n takes: {\n type: \"string\",\n required: false,\n description: \"Variants of the finished ad rendered (one request each) and judged, 1-3 (default 3). 1 skips the judge.\",\n },\n avatar: {\n type: \"string\",\n required: false,\n description: \"Cast company avatars as the ad's people, comma-separated in detection order (`marta` or `marta,joan`)\",\n },\n out: { type: \"string\", required: false, description: \"Output canvas path (default <image-dir>/static-ad.canvas.json)\" },\n \"describe-model\": { type: \"string\", required: false, description: \"Override the image_describe model id\" },\n \"select-model\": { type: \"string\", required: false, description: \"Override the element-selection text_generate model id\" },\n \"gen-model\": { type: \"string\", required: false, description: \"Override the image_generate model id\" },\n },\n});\n\n/** What the library said about the reference, or why nothing was fetched. Never fails the scaffold. */\ntype ReferenceLookup =\n | { status: \"none\" }\n | { status: \"grounded\"; reference: LibraryReference; mediaUrl: string | undefined }\n | { status: \"unavailable\"; adId: string; platform: string; message: string };\n\nasync function lookupReference(args: Record<string, unknown>): Promise<ReferenceLookup> {\n const adId = args[\"source-ad-id\"] ? String(args[\"source-ad-id\"]).trim() : \"\";\n if (!adId) return { status: \"none\" };\n const platformResult = resolveSourcePlatform(args[\"source-platform\"] ? String(args[\"source-platform\"]) : undefined);\n if (!platformResult.ok) return fail(\"invalid_source_platform\", platformResult.message);\n const platform = platformResult.platform;\n const advertiserId = args[\"source-advertiser-id\"] ? String(args[\"source-advertiser-id\"]).trim() : undefined;\n try {\n const ad = await fetchLibraryReference(adId, platform);\n return {\n status: \"grounded\",\n reference: libraryReferenceBlock(ad, { adId, platform, advertiserId }),\n mediaUrl: ad.media_url ?? undefined,\n };\n } catch (e) {\n return { status: \"unavailable\", adId, platform, message: e instanceof Error ? e.message : String(e) };\n }\n}\n\n/**\n * A static ad started from an ad spec rather than a reference picture: the spec is the ad (its\n * message, viewer and whatever the agent still has to write), the brand and formats are ours,\n * and the canvas has no source picture. Free: nothing is described or billed.\n */\nasync function scaffoldFromSpec(args: Record<string, unknown>, slug: string | undefined): Promise<void> {\n if (!slug) return fail(\"missing_slug\", \"--spec needs --slug: an ad started from a spec is a creative.\");\n const specPath = path.resolve(process.cwd(), String(args.spec));\n let started: ReturnType<typeof readAdSpec>;\n try {\n started = readAdSpec(JSON.parse(await readFile(specPath, \"utf8\")));\n } catch (e) {\n return fail(\"invalid_spec\", `${specPath} is not an ad spec: ${e instanceof Error ? e.message : String(e)}`);\n }\n const outPath = path.join(process.cwd(), \"src\", \"creatives\", slug, `${slug}.canvas.json`);\n const dir = path.dirname(outPath);\n const blueprintPath = path.join(dir, \"prompt.json\");\n const definitionPath = path.join(dir, \"_definition.md\");\n await enforceNewCreativeLimit(slug, outPath);\n const existingDefinition = (await fileExists(definitionPath)) ? await readFile(definitionPath, \"utf8\") : null;\n const who = await scaffoldViewer(args, existingDefinition, liveViewerLookups(process.cwd()).adSetViewer);\n if (!who.ok) return fail(\"invalid_viewer\", who.message);\n await mkdir(dir, { recursive: true });\n\n const workspaceRoot = (await findBrandRoot(dir)) ?? process.cwd();\n const kit = await readStaticBrandKit(workspaceRoot);\n const market =\n who.viewer?.market ?? marketFromCompanyDoc(await readFile(path.join(workspaceRoot, \"COMPANY.md\"), \"utf8\").catch(() => null));\n const brand = brandBlock(kit);\n const platform = resolvePlatform(args.platform ? String(args.platform) : undefined);\n const placementsResult = resolvePlacements(args.placements ? String(args.placements) : undefined, platform);\n if (!placementsResult.ok) return fail(\"invalid_placements\", placementsResult.message);\n const font = await brandFace(workspaceRoot, kit, (file) => toCanvasRelative(dir, file));\n const genModel = pickImageModel(conceptClassOf(started), \"generate\");\n const opts: StaticAdOpts = {\n genModel,\n blueprintPath: \"./prompt.json\",\n placements: placementsResult.placements,\n ...(who.adPlacements ? { adPlacements: who.adPlacements } : {}),\n brand: { logoPath: kit.logo ? toCanvasRelative(dir, kit.logo) : undefined, ...(font ? { font } : {}) },\n };\n const report = staticAdReport({}, [], { ...opts, spec: started });\n const spec = {\n ...started,\n ...(brand ? { brand: { ...brand, ...started.brand } } : {}),\n formats: report.output_formats,\n logo: Boolean(kit.logo),\n ...(market ? { viewer: { ...(started.viewer ?? { who: \"the people this ad is for\" }), market } } : {}),\n };\n await writeFile(blueprintPath, `${JSON.stringify(spec, null, 2)}\\n`, \"utf8\");\n const canvas = scaffoldStaticAd({}, [], { ...opts, spec });\n const validation = await validateScaffoldedStaticAd(canvas, dir);\n if (validation.blocking.length > 0) return fail(\"validation\", validation.blocking.map((i) => i.message).join(\"; \"));\n await writeFile(outPath, `${JSON.stringify(canvas, null, 2)}\\n`, \"utf8\");\n\n const title = args.title ? String(args.title) : titleFromSlug(slug);\n const recorded = who.record ? { targetAdSet: who.targetAdSet, viewer: who.viewer } : {};\n if (existingDefinition === null) {\n const formats = resolveFormatList(report.output_formats);\n await writeFile(definitionPath, buildCreativeDefinition({ title, kind: \"static\", platform, formats, ...recorded }), \"utf8\");\n }\n await syncCreativeDefinitionBestEffort({\n slug,\n title,\n platform,\n formats: resolveFormatList(report.output_formats),\n canvas,\n sourceSha: await computeSourceSha(outPath),\n });\n process.stdout.write(\n `${JSON.stringify(\n {\n ok: true,\n canvas_path: outPath,\n prompt_path: blueprintPath,\n definition_path: definitionPath,\n output: canvas.output,\n hints: [...who.notes, ...validation.hints],\n ...viewerOutput(who),\n output_formats: report.output_formats,\n stats: { total_nodes: canvas.nodes.length, describe_credits_spent: 0, run_estimated_credits: validation.estimatedCredits },\n },\n null,\n 2,\n )}\\n`,\n );\n}\n\nexport const scaffoldStaticAdCommand = defineCommand({\n meta: {\n name: \"scaffold-static-ad\",\n description:\n \"Turn a source/inspiration image into a runnable static-ad canvas. Runs billed passes — image_describe (read \" +\n \"into prompt.json, the ad spec you rewrite) and an AI selection of the image's MAIN identity elements — then \" +\n \"scaffolds a canvas on which the image model renders the FINISHED ad: up to three variants, one request each, \" +\n \"from a brief compiled from prompt.json, the copy quoted verbatim, the brand's typeface shown as a specimen and \" +\n 'the logo from src/brand/logos/ as a reference (only when prompt.json has \"logo\": true). A prefilter drops ' +\n \"variants whose words or placement fail the checks, and a judge compares the rest pairwise against the brief; \" +\n \"the chosen picture is delivered at the lead format (4:5 for a feed) and every other placement format is that \" +\n \"ad re-laid out for its own frame by one image request, with the chosen picture as the reference: the same \" +\n \"words, people, product and logo, re-scaled for the frame, never cut or shrunk onto a background. The run reads every word back and refuses to call the ad ready when one is off. No copy means the picture is the ad. Pass --placements none for a single base ad, \" +\n \"or a preset to pick the set. Edit prompt.json and drop the real assets, then `baker canvas run` it. A person \" +\n \"is cast from a suitable company Avatar by default: pass `--avatar <handle>` (`baker avatars list`), \" +\n \"or create one with explicit identity and buyer setting. A description-only one-off remains available when \" +\n \"explicitly requested. Never cast a stranger from a searched photo. A reference from the library: pass \" +\n \"`--source-ad-id <ad_id> --source-platform <platform>` so its structured read grounds the describe pass and the \" +\n \"source is recorded on the creative.\",\n },\n args: {\n file: {\n type: \"positional\",\n required: false,\n description: \"Path or http(s) URL to the source/inspiration image (optional with --source-ad-id)\",\n },\n \"source-ad-id\": { type: \"string\", description: SOURCE_AD_ID_DESCRIPTION },\n spec: {\n type: \"string\",\n description:\n \"Start from an ad spec (a prompt.json) instead of a reference picture: no describe pass, no source. `baker creatives make` writes one from an idea when no proven ad fits. Needs --slug.\",\n },\n \"source-platform\": { type: \"string\", description: SOURCE_PLATFORM_DESCRIPTION },\n \"source-advertiser-id\": { type: \"string\", description: SOURCE_ADVERTISER_ID_DESCRIPTION },\n context: { type: \"string\", description: \"Known provenance (advertiser, category, market) to ground the describe\" },\n out: { type: \"string\", description: \"Output canvas path (default <image-dir>/static-ad.canvas.json)\" },\n slug: {\n type: \"string\",\n description: \"Creative slug — writes the canvas to src/creatives/<slug>/<slug>.canvas.json (repo convention)\",\n },\n title: { type: \"string\", description: \"Creative title for _definition.md (default: title-cased slug)\" },\n platform: {\n type: \"string\",\n description:\n \"Ad platform (meta|google|linkedin|tiktok|youtube|x|other; default meta). Sets _definition.md AND, unless --placements is given, the formats the ad is delivered in (meta → 4:5+9:16, google → 1:1+4:5+16:9, linkedin → 1:1, tiktok → 9:16, youtube → 16:9; x/other → one format).\",\n },\n advertiser: {\n type: \"string\",\n description: \"Source advertiser recorded in _definition.md (default: the library ad's advertiser)\",\n },\n \"describe-model\": { type: \"string\", description: \"Override the image_describe model id\" },\n \"select-model\": { type: \"string\", description: \"Override the text_generate model id for element selection\" },\n \"gen-model\": { type: \"string\", description: \"Override the image_generate model id\" },\n aspect: {\n type: \"string\",\n description:\n \"Force the ad's lead format (else inferred from the image). Delivered exactly: the ad renders at the model's nearest shape and is cropped to it.\",\n },\n \"target-adset\": { type: \"string\", description: TARGET_ADSET_DESCRIPTION },\n \"viewer-temperature\": { type: \"string\", description: VIEWER_TEMPERATURE_DESCRIPTION },\n \"viewer-knows\": { type: \"string\", description: VIEWER_KNOWS_DESCRIPTION },\n \"viewer-placements\": { type: \"string\", description: VIEWER_PLACEMENTS_DESCRIPTION },\n placements: {\n type: \"string\",\n description:\n \"Formats the ad is delivered in. One of meta_feed | meta_feed_stories | meta_all | linkedin | google_demandgen | tiktok | youtube, or `none` for a single base ad. Default: derived from --platform (meta → feed + stories). Every format is made from the one chosen picture: the picture itself (the 4:5 when it is delivered), or that ad re-laid out for the format's own frame (one billed request per format).\",\n },\n platforms: { type: \"string\", description: PLATFORMS_DESCRIPTION },\n takes: {\n type: \"string\",\n description: \"Variants of the finished ad to render (one request each) and judge, 1-3 (default 3). 1 skips the judge.\",\n },\n avatar: {\n type: \"string\",\n description:\n \"Cast company avatars as the ad's people — preferred whenever an ad needs an actor, including a single ad. \" +\n \"Choose a ready avatar who fits the buyer, or create one with explicit identity and setting. One handle, or \" +\n \"several comma-separated in the order the people were detected (`--avatar marta` / `--avatar marta,joan`). \" +\n \"Each person slot grounds on that avatar's identity sheet and prompt.json describes them in the avatar's own \" +\n \"words, so the ad shows the company's cast instead of the source ad's. `baker avatars list` shows who there is; \" +\n \"checked before anything is billed.\",\n },\n },\n async run({ args }) {\n const slug = args.slug ? String(args.slug) : undefined;\n if (slug && !isValidScaffoldSlug(slug)) {\n process.stderr.write(\n `${JSON.stringify({ ok: false, error: { code: \"invalid_slug\", message: \"--slug must be lowercase kebab (a-z, 0-9, hyphens), max 100 chars\" } }, null, 2)}\\n`,\n );\n process.exit(2);\n }\n // The library's read of the reference, fetched before anything bills. A failed fetch\n // with an image given degrades to a scaffold without the DNA (warned, and said in hints);\n // with no image there is nothing to describe, so it stops here.\n if (args.spec) return scaffoldFromSpec(args, slug);\n const lookup = await lookupReference(args);\n if (lookup.status === \"unavailable\") {\n process.stderr.write(\n `[warn] winners-library ad ${lookup.adId} (${lookup.platform}) could not be read (${lookup.message}); scaffolding without its structured read\\n`,\n );\n }\n const reference = lookup.status === \"grounded\" ? lookup.reference : undefined;\n const fileArg = args.file ? String(args.file) : undefined;\n const sourceFile = fileArg ?? (lookup.status === \"grounded\" ? lookup.mediaUrl : undefined);\n if (!sourceFile) {\n if (lookup.status === \"none\") return fail(\"missing_source\", \"Pass the reference image, or --source-ad-id <ad_id> to use a library ad.\");\n if (lookup.status === \"unavailable\") return fail(\"source_unavailable\", `No image given and the library ad could not be read (${lookup.message}).`);\n return fail(\"source_unavailable\", `The library holds no picture for ad ${reference?.ad_id}; pass the image.`);\n }\n\n const { imageIsUrl, imageSource, outPath, blueprintPath, definitionPath, referencesDir } =\n resolveScaffoldStaticAdPaths(sourceFile, args.out ? String(args.out) : undefined, process.cwd(), slug);\n\n if (slug) await enforceNewCreativeLimit(slug, outPath);\n\n // Who the ad is for, read before anything is billed: a bad flag fails for free, and an ad\n // set that cannot be read only costs the ad its narrower placements.\n const existingDefinition =\n definitionPath && (await fileExists(definitionPath)) ? await readFile(definitionPath, \"utf8\") : null;\n const who = await scaffoldViewer(args, existingDefinition, liveViewerLookups(process.cwd()).adSetViewer);\n if (!who.ok) return fail(\"invalid_viewer\", who.message);\n\n // The fit made of this reference (`baker winning-ads fit`), read before anything bills: a\n // reference judged not to fit is refused here, and one that fits seeds prompt.json's concept.\n const fitRoot = findWorkspaceRoot(process.cwd()) ?? process.cwd();\n const fit =\n reference || lookup.status === \"unavailable\"\n ? await readCachedFit(fitRoot, reference?.platform ?? (lookup.status === \"unavailable\" ? lookup.platform : \"meta\"), reference?.ad_id ?? (lookup.status === \"unavailable\" ? lookup.adId : \"\"))\n : null;\n const fitProblems = fit ? fitHints(fit, reference?.ad_id ?? \"\").filter((h) => h.startsWith(\"Pick another reference\")) : [];\n if (fitProblems.length > 0) return fail(\"concept_does_not_fit\", fitProblems.join(\" \"));\n\n // Create the creative folder up front (was missing — the agent had to `mkdir -p` and re-run,\n // double-billing the vision passes) and fail before any billed work if the path is unwritable.\n await mkdir(path.dirname(outPath), { recursive: true });\n\n let models: ReturnType<typeof resolveModels>;\n try {\n models = resolveModels(args);\n } catch (e) {\n return fail(\"unknown_model\", e instanceof Error ? e.message : String(e));\n }\n const { describeModel, selectModel } = models;\n\n // Resolved before the billed passes: a handle that cannot be cast fails for free.\n const cast = await resolveCastAvatars(args.avatar);\n if (\"error\" in cast) return fail(\"avatar\", cast.error);\n\n // Localize the source to durable storage BEFORE any billed pass: presigned\n // winning-ad URLs expire within the hour, the raster bytes must never land\n // in git, and the vision passes + emitted canvas then read one stable URL\n // (a dead source aborts here, before any credits are spent).\n let durableSourceUrl: string | undefined;\n if (referencesDir) {\n const client = buildBackendClient();\n if (client) {\n try {\n durableSourceUrl = await uploadSourceAsReference(imageSource, imageIsUrl, client);\n } catch (e) {\n return fail(\"source_unavailable\", e instanceof Error ? e.message : String(e));\n }\n }\n }\n\n // One run: ingest → describe → select. We read both node outputs after.\n const describeCanvas = buildDescribeCanvas(\n durableSourceUrl ?? imageSource,\n durableSourceUrl !== undefined || imageIsUrl,\n describeModel,\n selectModel,\n referenceDescribeContext(reference, args.context ? String(args.context) : undefined),\n );\n const shared =\n reference && sharesLibraryRead(args, lookup.status === \"grounded\") ? await sharedLibraryRead(reference) : null;\n const vision = shared ?? (await runVisionPasses(describeCanvas));\n const { creditsSpent } = vision;\n // The library's read joins the blueprint as `reference` (bookkeeping, never a mechanism).\n const blueprint = mergeReferenceIntoBlueprint(vision.blueprint, reference);\n // Cast by who the ad is for (D2): the definition's persona, else the viewer the ad set reaches.\n const persona = existingDefinition?.match(/^persona:\\s*\"?([^\"\\n]+)\"?\\s*$/m)?.[1];\n const elements = castAvatarsOnStaticElements(vision.elements, cast.avatars, persona);\n const uncast = staticAvatarsNotCast(elements, cast.handles);\n\n // The brand's colours ride in prompt.json as `brand`: the brief ties each to an object and\n // never borrows a colour from the reference ad.\n const canvasDir = path.dirname(outPath);\n const workspaceRoot = (await findBrandRoot(canvasDir)) ?? process.cwd();\n const kit = await readStaticBrandKit(workspaceRoot);\n // Where the ad runs: the ad set's countries, else the market COMPANY.md names (D1).\n const market =\n who.viewer?.market ?? marketFromCompanyDoc(await readFile(path.join(workspaceRoot, \"COMPANY.md\"), \"utf8\").catch(() => null));\n const brand = brandBlock(kit);\n\n // Creative convention: point the canvas at the durable source URL (content-addressed,\n // never expires, re-runs in any fresh sandbox with zero git bloat) and at a canvas-relative\n // blueprint path. Ad-hoc canvases (no slug) keep their verbatim source + absolute blueprint path.\n let canvasImagePath = imageSource;\n let canvasImageIsUrl = imageIsUrl;\n let canvasBlueprintPath = blueprintPath;\n if (referencesDir) {\n canvasBlueprintPath = \"./prompt.json\";\n if (durableSourceUrl) {\n canvasImagePath = durableSourceUrl;\n canvasImageIsUrl = true;\n }\n }\n\n const definitionPlatform = resolvePlatform(args.platform ? String(args.platform) : undefined);\n const placementsResult = resolvePlacements(\n args.placements ? String(args.placements) : undefined,\n definitionPlatform,\n );\n if (!placementsResult.ok) return fail(\"invalid_placements\", placementsResult.message);\n const placements = placementsResult.placements;\n const platformsResult = resolvePlatforms(args.platforms ? String(args.platforms) : undefined);\n if (!platformsResult.ok) return fail(\"invalid_platforms\", platformsResult.message);\n\n // The brand's typeface and logo: the canvas points at them by canvas-relative path, so\n // the render reads the real files.\n const relative = (file: string | undefined) => (file ? toCanvasRelative(canvasDir, file) : undefined);\n const takes = args.takes !== undefined ? Number.parseInt(String(args.takes), 10) : undefined;\n if (takes !== undefined && !(takes >= 1 && takes <= 3)) return fail(\"invalid_takes\", \"--takes must be 1, 2 or 3\");\n const font = await brandFace(workspaceRoot, kit, (file) => toCanvasRelative(canvasDir, file));\n\n // The render model the router picks for this kind of concept, unless `--gen-model` pinned one.\n const genModel = models.genModel ?? pickImageModel(conceptClassOf(staticAdSpec(blueprint, elements)), \"generate\");\n const opts: StaticAdOpts = {\n genModel,\n imagePath: canvasImagePath,\n imageIsUrl: canvasImageIsUrl,\n blueprintPath: canvasBlueprintPath,\n aspectRatio: args.aspect ? String(args.aspect) : undefined,\n placements,\n ...(platformsResult.platforms ? { platforms: platformsResult.platforms } : {}),\n ...(who.adPlacements ? { adPlacements: who.adPlacements } : {}),\n brand: { logoPath: relative(kit.logo), ...(font ? { font } : {}) },\n takes,\n };\n\n // prompt.json is the ad spec the agent rewrites into our ad; every render prompt is\n // compiled from it (static-brief.ts), here and again on every run.\n let canvas: ReturnType<typeof scaffoldStaticAd>;\n let report: ReturnType<typeof staticAdReport>;\n let conceptNotes: string[] = [];\n try {\n report = staticAdReport(blueprint, elements, { ...opts, spec: staticAdSpec(blueprint, elements, { logo: Boolean(kit.logo) }) });\n const spec = staticAdSpec(blueprint, elements, {\n brand,\n formats: report.output_formats,\n logo: Boolean(kit.logo),\n ...(fit ? { fit: conceptFromFit(fit, reference?.ad_id ?? \"\") } : {}),\n ...(market ? { market } : {}),\n });\n await writeFile(blueprintPath, `${JSON.stringify(spec, null, 2)}\\n`, \"utf8\");\n conceptNotes = conceptProblems(spec).map(\n (p) => `CONCEPT: ${p} Then \\`baker canvas run\\`; until then it refuses to render.`,\n );\n if (!fit && reference) {\n conceptNotes.push(\n `${NO_FIT_HINT}: \\`baker winning-ads fit ${reference.ad_id}\\` says what it wins on and what we have for it, and re-scaffolding seeds prompt.json's \\`concept\\` from it.`,\n );\n }\n canvas = scaffoldStaticAd(blueprint, elements, { ...opts, spec });\n } catch (e) {\n return fail(\"scaffold\", e instanceof Error ? e.message : String(e));\n }\n\n const validation = await validateScaffoldedStaticAd(canvas, path.dirname(outPath));\n if (validation.blocking.length > 0) {\n process.stderr.write(\n `${JSON.stringify({ ok: false, error: { code: \"validation\", issues: validation.blocking } }, null, 2)}\\n`,\n );\n process.exit(2);\n }\n\n await writeFile(outPath, `${JSON.stringify(canvas, null, 2)}\\n`, \"utf8\");\n\n // The library ids, recorded on the creative from this scaffold on (the definition and the\n // sync alike), so `baker_uses` in reference search counts this adaptation before Publish.\n const sourceFields = reference\n ? {\n sourceAdId: reference.ad_id,\n sourcePlatform: reference.platform,\n ...(reference.advertiser_id ? { sourceAdvertiserId: reference.advertiser_id } : {}),\n }\n : lookup.status === \"unavailable\"\n ? {\n sourceAdId: lookup.adId,\n sourcePlatform: lookup.platform,\n ...(args[\"source-advertiser-id\"] ? { sourceAdvertiserId: String(args[\"source-advertiser-id\"]).trim() } : {}),\n }\n : {};\n\n // Auto-write _definition.md so the creative joins the content collection immediately (title,\n // platform, source metadata) — the agent no longer hand-writes it. Preserve one on re-scaffold.\n const recorded = who.record ? { targetAdSet: who.targetAdSet, viewer: who.viewer } : {};\n if (definitionPath && existingDefinition !== null && who.record) {\n await writeFile(definitionPath, setDefinitionViewer(existingDefinition, recorded), \"utf8\");\n }\n if (definitionPath && existingDefinition === null) {\n await writeFile(\n definitionPath,\n buildCreativeDefinition({\n title: args.title ? String(args.title) : titleFromSlug(slug ?? \"\"),\n kind: \"static\",\n platform: definitionPlatform,\n formats: resolveFormatList(report.output_formats),\n sourceReferenceUrl: durableSourceUrl ?? (imageIsUrl ? imageSource : undefined),\n sourceAdvertiser: args.advertiser\n ? String(args.advertiser)\n : (reference?.advertiser ?? (args.context ? String(args.context) : undefined)),\n ...sourceFields,\n sourceKind: \"image\",\n ...recorded,\n description: describeBlueprintIntent(blueprint),\n }),\n \"utf8\",\n );\n }\n\n // Push the parsed node-graph so the dashboard can draw this creative's\n // workflow immediately — before the first (billed) run. Best-effort.\n if (slug) {\n await syncCreativeDefinitionBestEffort({\n slug,\n title: args.title ? String(args.title) : titleFromSlug(slug),\n platform: definitionPlatform,\n formats: resolveFormatList(report.output_formats),\n sourceReferenceUrl: durableSourceUrl ?? (imageIsUrl ? imageSource : undefined),\n ...sourceFields,\n canvas,\n sourceSha: await computeSourceSha(outPath),\n });\n }\n\n const hints = [\n ...who.notes,\n ...(lookup.status === \"unavailable\"\n ? [\n `REFERENCE NOT READ: the winners library could not return ad ${lookup.adId} (${lookup.message}). prompt.json is read from the picture alone and has no \\`reference\\` block; the source ids are still recorded. Check the ad id and platform, or continue from the picture.`,\n ]\n : []),\n ...(uncast.length\n ? [\n `NOT CAST: ${uncast.map((h) => `\\`${h}\\``).join(\", \")} — the element selection found fewer people than avatars passed, so ${uncast.length === 1 ? \"this avatar plays\" : \"these avatars play\"} nobody in this ad. Tell the user who is cast and who is not.`,\n ]\n : []),\n ...validation.hints,\n ...conceptNotes,\n ...report.describe_gaps.map((gap) =>\n gap === \"winning_mechanisms\"\n ? \"The describe pass named no winning mechanism. Look at the source ad, add a `mechanism` entry to prompt.json ({ device, why_it_works }) and rebuild that device for our brand; a rewrite without it keeps the look and loses what made the ad work.\"\n : \"The describe pass recorded no typefaces. The designed lines are set in the brand's font when one loads (src/brand/fonts/, tokens.json or BRAND.md); with none, name our face in prompt.json's `brand.typeface` (for example \\\"a heavy geometric sans\\\"), or they are set in a plain sans.\",\n ),\n ];\n process.stdout.write(\n `${JSON.stringify(\n {\n ok: true,\n canvas_path: outPath,\n prompt_path: blueprintPath,\n definition_path: definitionPath ?? undefined,\n source_reference: durableSourceUrl ?? undefined,\n ...(reference\n ? {\n reference: {\n ad_id: reference.ad_id,\n platform: reference.platform,\n advertiser_id: reference.advertiser_id,\n format_pattern: reference.format_pattern,\n mechanism: reference.message.mechanism,\n },\n }\n : {}),\n output: canvas.output,\n ...(hints.length ? { hints } : {}),\n models: { describe: describeModel, select: selectModel, gen: opts.genModel },\n aspect_ratio: report.aspect_ratio,\n placements: report.placements,\n ...viewerOutput(who),\n output_formats: report.output_formats,\n stats: {\n total_nodes: canvas.nodes.length,\n describe_credits_spent: creditsSpent,\n run_estimated_credits: validation.estimatedCredits,\n },\n checklist: {\n edit_prompt: `Edit ${path.basename(blueprintPath)}: it is the ad spec, read from your image, to rewrite into the ad you want. \\`viewer\\` (who sees it and what they already know), \\`message\\` (the one thing it tells them), \\`copy\\` (each line, \\`in_scene\\` or \\`designed\\`), \\`scene\\`, \\`references\\` (one picture each, by role), \\`colors\\` (each tied to an object, from the brand) and an optional \\`direction\\`. You never write a model prompt: every render prompt is compiled from this file and shown on its node.${reference ? \" Its `reference` block is the library's read of the source ad (container, layout, mechanism, offer, text blocks): keep it as the account of why the ad won, and rebuild it for our brand.\" : \"\"}`,\n mechanism: report.winning_mechanisms,\n rebuild_the_mechanism:\n \"`mechanism` is WHY the source ad works. Rebuild each device for our brand in prompt.json's copy and scene (a rhyme stays a rhyme in our words, a before/after stays a before/after of our product); never copy the source's literal copy.\",\n assets_to_supply: report.elements,\n summary: report.summary,\n text: staticTextNote(report),\n font: report.font,\n in_scene_text: report.in_scene_text,\n logo: report.logo.why,\n takes:\n report.takes === 1\n ? \"1 finished ad is rendered and used as it is (no judge).\"\n : `${report.takes} variants of the finished ad are rendered, one request each on its own direction. A prefilter drops any whose words or placement fail the checks, and the judge compares the rest pairwise against the brief (words, picture, space, one idea, the brief itself, brand); the winner becomes the ad and the others stay in the run as options the person can switch to (\\`baker canvas run --use-variant\\`).`,\n pictures:\n \"The reference's own people, products, animals and badges are not slots to fill: they are the source's world. Cast a person from a suitable ready company Avatar by default (--avatar <handle>); create one from the buyer context if none fits. A description-only one-off is available when explicitly requested; never use a stranger's found photo. To show our own product or another picture, add it to prompt.json's `references` with its `image` (a path from this folder, or a URL): every run wires it.\",\n formats: staticFormatsNote(report, opts.genModel),\n viewer: viewerNote(who),\n note: `Populate as you go: for each [TODO] ingest slot, source its real asset and wire it into the slot right away, one at a time. The logo is optional and never a slot to fill: it is given to the model only when prompt.json has \\`\"logo\": true\\` and src/brand/logos/ has the real file; never fetch or draw a stand-in. When every slot is filled, \\`baker canvas validate\\` then \\`baker canvas run\\`. Running generates billed images: it is not free.`,\n },\n },\n null,\n 2,\n )}\\n`,\n );\n },\n});\n","import {\n VIEWER_KNOWS_VALUES,\n VIEWER_TEMPERATURE_VALUES,\n type ViewerKnows,\n type ViewerProfile,\n type ViewerTemperature,\n} from \"../../viewer-profile.ts\";\nimport { parseDefinitionViewerFields } from \"./creative-definition.ts\";\nimport { resolveViewer } from \"./viewer-check.ts\";\n\n/**\n * Who a scaffolded static ad is for, decided before anything is billed: the viewer the\n * ad set it will run in reaches (`--target-adset`, read as `baker ads meta adsets\n * --audience` reads it). The viewer's placements are what the sizes, the brief and the\n * prefilter keep clear of; the viewer itself is recorded in `_definition.md`, where the\n * viewer check reads it before every render.\n */\n\n/** The scaffold flags that say who the ad is for, as citty hands them over. */\nexport type ScaffoldViewerFlags = {\n \"target-adset\"?: unknown;\n \"viewer-temperature\"?: unknown;\n \"viewer-knows\"?: unknown;\n \"viewer-placements\"?: unknown;\n};\n\nexport type ScaffoldViewer = {\n ok: true;\n targetAdSet?: string;\n viewer?: ViewerProfile;\n /** Write `targetAdSet` / `viewer` into `_definition.md`: they came from this scaffold's flags. */\n record: boolean;\n /** The placements the sizes are planned around; absent = Advantage+ (Reels included). */\n adPlacements?: string[];\n /** What could not be read, for the hints. */\n notes: string[];\n};\n\n/** The viewer one ad set reaches, or null when no connected account holds it. */\nexport type AdSetViewerLookup = (adSetId: string) => Promise<ViewerProfile | null>;\n\nfunction flagText(value: unknown): string | undefined {\n const text = typeof value === \"string\" || typeof value === \"number\" ? String(value).trim() : \"\";\n return text || undefined;\n}\n\n/** Placements that narrow what Advantage+ runs; `automatic` alone is Advantage+ itself. */\nfunction narrows(placements: readonly string[]): boolean {\n return placements.some((placement) => placement !== \"automatic\");\n}\n\nfunction flagList(value: unknown): string[] | undefined {\n const list = (flagText(value) ?? \"\")\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n return list.length > 0 ? list : undefined;\n}\n\n/** What the `--viewer-*` flags say, checked. */\ntype ViewerFields = { temperature?: ViewerTemperature; knows?: ViewerKnows[]; placements?: string[] };\n\nconst isTemperature = (value: string): value is ViewerTemperature =>\n (VIEWER_TEMPERATURE_VALUES as readonly string[]).includes(value);\nconst isKnows = (value: string): value is ViewerKnows => (VIEWER_KNOWS_VALUES as readonly string[]).includes(value);\n\nfunction viewerFields(flags: ScaffoldViewerFlags): { ok: true; fields: ViewerFields } | { ok: false; message: string } {\n const temperature = flagText(flags[\"viewer-temperature\"]);\n if (temperature !== undefined && !isTemperature(temperature)) {\n return { ok: false, message: `--viewer-temperature must be one of ${VIEWER_TEMPERATURE_VALUES.join(\", \")}` };\n }\n const knows = flagList(flags[\"viewer-knows\"]);\n if (knows && !knows.every(isKnows)) {\n return { ok: false, message: `--viewer-knows takes ${VIEWER_KNOWS_VALUES.join(\", \")}` };\n }\n const placements = flagList(flags[\"viewer-placements\"]);\n return {\n ok: true,\n fields: {\n ...(temperature ? { temperature } : {}),\n ...(knows ? { knows: knows.filter(isKnows) } : {}),\n ...(placements ? { placements } : {}),\n },\n };\n}\n\n/** The viewer the agent read from the Knowledge, with no ad set to read it from. */\nfunction givenViewer(fields: ViewerFields): ViewerProfile | undefined {\n if (!fields.temperature) return undefined;\n return {\n temperature: fields.temperature,\n knows: fields.knows ?? [],\n placements: fields.placements ?? [\"automatic\"],\n source: \"knowledge\",\n reasons: [\"No ad set was read: this viewer was given when the ad was scaffolded, from the Knowledge.\"],\n };\n}\n\nconst FIELD_WORDS: Record<keyof ViewerFields, string> = {\n temperature: \"Temperature\",\n knows: \"What they know\",\n placements: \"Placements\",\n};\n\n/** The viewer read off the ad set, with whatever the agent stated in its place. */\nfunction correctedViewer(read: ViewerProfile, fields: ViewerFields): ViewerProfile {\n const stated = (Object.keys(FIELD_WORDS) as (keyof ViewerFields)[]).filter((key) => fields[key] !== undefined);\n if (stated.length === 0) return read;\n return {\n ...read,\n ...fields,\n reasons: [...read.reasons, ...stated.map((key) => `${FIELD_WORDS[key]} given when the ad was scaffolded.`)],\n };\n}\n\nconst EVERY_PLACEMENT = \"so the sizes keep clear of every placement\";\n\nasync function readAdSet(\n adSetId: string,\n adSetViewer: AdSetViewerLookup,\n notes: string[],\n): Promise<ViewerProfile | undefined> {\n try {\n const viewer = await adSetViewer(adSetId);\n if (viewer) return viewer;\n notes.push(`Ad set ${adSetId} is not in any connected Meta ad account, ${EVERY_PLACEMENT}.`);\n } catch (e) {\n notes.push(`Could not read ad set ${adSetId} (${e instanceof Error ? e.message : String(e)}), ${EVERY_PLACEMENT}.`);\n }\n return undefined;\n}\n\n/**\n * The viewer a creative's `_definition.md` already names, resolved as the viewer check\n * resolves it (the recorded viewer, else its ad set's); nothing is written back.\n */\nasync function recordedViewer(definition: string, adSetViewer: AdSetViewerLookup): Promise<ScaffoldViewer> {\n const { targetAdSet, viewer: recorded } = parseDefinitionViewerFields(definition);\n if (!targetAdSet && recorded === undefined) return { ok: true, record: false, notes: [] };\n const resolved = await resolveViewer({ recorded, targetAdSet }, { adSetViewer, personas: async () => [] });\n const viewer = resolved.from === \"recorded\" || resolved.from === \"ad_set\" ? resolved.viewer : undefined;\n return outcome(targetAdSet, viewer, false, resolved.notes);\n}\n\nfunction outcome(\n targetAdSet: string | undefined,\n viewer: ViewerProfile | undefined,\n record: boolean,\n notes: string[],\n): ScaffoldViewer {\n return {\n ok: true,\n ...(targetAdSet ? { targetAdSet } : {}),\n ...(viewer ? { viewer } : {}),\n record,\n ...(viewer && narrows(viewer.placements) ? { adPlacements: viewer.placements } : {}),\n notes,\n };\n}\n\n/**\n * Who the ad is for, from the scaffold's flags: `--target-adset` read off the ad set (any\n * `--viewer-*` flag correcting that read), else the `--viewer-*` flags alone (a viewer from\n * the Knowledge); with neither, whatever the creative's `_definition.md` already records.\n * A bad flag is refused before anything is billed; an ad set that cannot be read is not.\n */\nexport async function scaffoldViewer(\n flags: ScaffoldViewerFlags,\n existingDefinition: string | null,\n adSetViewer: AdSetViewerLookup,\n): Promise<ScaffoldViewer | { ok: false; message: string }> {\n const targetAdSet = flagText(flags[\"target-adset\"]);\n const given = viewerFields(flags);\n if (!given.ok) return given;\n const { fields } = given;\n if (!targetAdSet && !fields.temperature && (fields.knows || fields.placements)) {\n return {\n ok: false,\n message: \"--viewer-knows and --viewer-placements describe a viewer: pass --viewer-temperature too\",\n };\n }\n if (!targetAdSet && !fields.temperature && existingDefinition !== null) {\n return await recordedViewer(existingDefinition, adSetViewer);\n }\n const notes: string[] = [];\n const read = targetAdSet ? await readAdSet(targetAdSet, adSetViewer, notes) : undefined;\n const viewer = read ? correctedViewer(read, fields) : givenViewer(fields);\n return outcome(targetAdSet, viewer, targetAdSet !== undefined || viewer !== undefined, notes);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,UAAU,iBAAiB;AAC3C,OAAO,UAAU;AAajB,SAAS,qBAAqB;;;AC2B9B,SAAS,SAAS,OAAoC;AACpD,QAAM,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,OAAO,KAAK,EAAE,KAAK,IAAI;AAC7F,SAAO,QAAQ;AACjB;AAGA,SAAS,QAAQ,YAAwC;AACvD,SAAO,WAAW,KAAK,CAAC,cAAc,cAAc,WAAW;AACjE;AAEA,SAAS,SAAS,OAAsC;AACtD,QAAM,QAAQ,SAAS,KAAK,KAAK,IAC9B,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,OAAO;AAC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