literally-aeo 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/dist/cli.mjs +6075 -5175
  2. package/dist/lib/agents/author-schema.js +5 -5
  3. package/dist/lib/agents/author-validation.js +9 -7
  4. package/dist/lib/agents/copy-validation.js +10 -10
  5. package/dist/lib/agents/copywriter-input.js +9 -9
  6. package/dist/lib/agents/facts.js +8 -8
  7. package/dist/lib/agents/narrative-facts.js +6 -6
  8. package/dist/lib/agents/verifier.js +14 -13
  9. package/dist/lib/analysis/domain-classifier.js +12 -10
  10. package/dist/lib/analysis/domain-labels.js +4 -4
  11. package/dist/lib/analysis/outreach.js +2 -2
  12. package/dist/lib/analysis/progress.js +9 -9
  13. package/dist/lib/analysis/retrieval.js +5 -5
  14. package/dist/lib/analysis/scoring.js +5 -5
  15. package/dist/lib/analysis/search-analyzer.js +6 -6
  16. package/dist/lib/analysis/sentiment.js +12 -10
  17. package/dist/lib/analysis/source-mix.js +2 -2
  18. package/dist/lib/author/examples.js +6 -6
  19. package/dist/lib/bundle/contracts.js +6 -6
  20. package/dist/lib/bundle/export.js +18 -18
  21. package/dist/lib/bundle/journal.js +7 -7
  22. package/dist/lib/bundle/project-journal.js +10 -10
  23. package/dist/lib/bundle/project.js +16 -16
  24. package/dist/lib/bundle/read.js +19 -19
  25. package/dist/lib/bundle/recorder.js +8 -8
  26. package/dist/lib/bundle/redact.js +7 -7
  27. package/dist/lib/bundle/trace-coverage.js +7 -7
  28. package/dist/lib/bundle/verify-integrity.js +9 -9
  29. package/dist/lib/bundle/verify-measurement.js +22 -13
  30. package/dist/lib/bundle/verify-report.js +24 -16
  31. package/dist/lib/bundle/verify.js +32 -24
  32. package/dist/lib/capture-manifest.js +6 -6
  33. package/dist/lib/checks/crawler-access.js +2 -2
  34. package/dist/lib/checks/money-pages.js +13 -0
  35. package/dist/lib/checks/renderability.js +2 -2
  36. package/dist/lib/checks/run-checks.js +12 -12
  37. package/dist/lib/chunks/{chunk-XAKME6NM.js → chunk-2C723CW7.js} +1 -1
  38. package/dist/lib/chunks/chunk-2FDSOZ6Q.js +287 -0
  39. package/dist/lib/chunks/{chunk-PWOYEIPF.js → chunk-2U5QSA6Q.js} +7 -7
  40. package/dist/lib/chunks/{chunk-6EI4CVRW.js → chunk-3ESH5NDR.js} +5 -1
  41. package/dist/lib/chunks/{chunk-7LBSNDRR.js → chunk-3S2FAVRE.js} +22 -3
  42. package/dist/lib/chunks/{chunk-LR27H2HZ.js → chunk-44NSZBCP.js} +6 -6
  43. package/dist/lib/chunks/{chunk-JBOOD6MU.js → chunk-4AWFF53U.js} +12 -4
  44. package/dist/lib/chunks/{chunk-MENTBQGB.js → chunk-4HPMLJKC.js} +4 -4
  45. package/dist/lib/chunks/{chunk-AAFHXNLU.js → chunk-4Q2WFZ5J.js} +11 -4
  46. package/dist/lib/chunks/{chunk-SD7LR26G.js → chunk-5JU2Y2I6.js} +2 -2
  47. package/dist/lib/chunks/{chunk-RPTADJXD.js → chunk-64JFN2Q5.js} +1 -1
  48. package/dist/lib/chunks/chunk-66UE4TT2.js +245 -0
  49. package/dist/lib/chunks/chunk-6N3C6E3D.js +105 -0
  50. package/dist/lib/chunks/{chunk-F2NSJ6PG.js → chunk-6RED3G6K.js} +7 -3
  51. package/dist/lib/chunks/{chunk-QJZTDZMB.js → chunk-7KLTOVIY.js} +9 -9
  52. package/dist/lib/chunks/{chunk-PXB4PWJI.js → chunk-7ZR3WDF2.js} +38 -5
  53. package/dist/lib/chunks/chunk-A5PF7UE2.js +86 -0
  54. package/dist/lib/chunks/{chunk-JXBLGCXZ.js → chunk-AB7DUTX5.js} +1 -1
  55. package/dist/lib/chunks/{chunk-WDT2Y7D7.js → chunk-AQCWKHTE.js} +11 -7
  56. package/dist/lib/chunks/{chunk-SQQ56UP2.js → chunk-ASHFEFCU.js} +3 -3
  57. package/dist/lib/chunks/{chunk-AK6YNTCV.js → chunk-ASIFUJG2.js} +1 -1
  58. package/dist/lib/chunks/{chunk-ZSEY7AHQ.js → chunk-BBK54RVK.js} +14 -11
  59. package/dist/lib/chunks/chunk-BQMUZLHO.js +17 -0
  60. package/dist/lib/chunks/{chunk-KSOHZKV5.js → chunk-CQNIPZH3.js} +21 -21
  61. package/dist/lib/chunks/{chunk-7HM6IZ3L.js → chunk-CVEXMYPW.js} +2 -2
  62. package/dist/lib/chunks/chunk-CXZIHHLJ.js +95 -0
  63. package/dist/lib/chunks/{chunk-75DMLOQ7.js → chunk-CYJNBVQB.js} +1 -1
  64. package/dist/lib/chunks/{chunk-FAUFE7MI.js → chunk-D7N5OLYL.js} +1 -1
  65. package/dist/lib/chunks/{chunk-E2YTTB6Q.js → chunk-DSK3PM4Z.js} +1 -1
  66. package/dist/lib/chunks/{chunk-TNL2GWYR.js → chunk-EUXNCXCR.js} +22 -0
  67. package/dist/lib/chunks/{chunk-FJL2V6P5.js → chunk-F4EQULFR.js} +6 -6
  68. package/dist/lib/chunks/{chunk-QGZ4QSUE.js → chunk-FHV4PBYG.js} +1 -1
  69. package/dist/lib/chunks/chunk-FK2JQHAX.js +30 -0
  70. package/dist/lib/chunks/{chunk-K2FZFESR.js → chunk-FONFW67K.js} +4 -4
  71. package/dist/lib/chunks/{chunk-W5X7WJYL.js → chunk-FPPHYGIO.js} +3 -3
  72. package/dist/lib/chunks/{chunk-XNTFOVCE.js → chunk-FYE4R5TY.js} +2 -2
  73. package/dist/lib/chunks/{chunk-FIC7JSR4.js → chunk-H2DOBJZC.js} +2 -2
  74. package/dist/lib/chunks/{chunk-R2AJYV6A.js → chunk-HEWHNSDP.js} +68 -36
  75. package/dist/lib/chunks/{chunk-RXSHKWZJ.js → chunk-HLC6OHGO.js} +2 -2
  76. package/dist/lib/chunks/{chunk-6HMHXSCS.js → chunk-HXXFRZTJ.js} +2 -2
  77. package/dist/lib/chunks/{chunk-JYFEXVWC.js → chunk-HYMWNGOK.js} +13 -6
  78. package/dist/lib/chunks/chunk-IH67TEGY.js +73 -0
  79. package/dist/lib/chunks/{chunk-JKPBXPCW.js → chunk-IMADI2YP.js} +1 -1
  80. package/dist/lib/chunks/{chunk-SLAPBFRH.js → chunk-JBGQFPTY.js} +4 -4
  81. package/dist/lib/chunks/{chunk-JQDQVG3D.js → chunk-JDU3ZCKO.js} +1 -1
  82. package/dist/lib/chunks/{chunk-2KH7LNK7.js → chunk-JGIX427K.js} +7 -7
  83. package/dist/lib/chunks/{chunk-7CW6U5WJ.js → chunk-JIE2ANVD.js} +1 -1
  84. package/dist/lib/chunks/{chunk-T5XQ6NXD.js → chunk-JJFOILZK.js} +2 -2
  85. package/dist/lib/chunks/{chunk-F7DBTXKG.js → chunk-JMIK2QN3.js} +4 -3
  86. package/dist/lib/chunks/chunk-JW7DTYSI.js +116 -0
  87. package/dist/lib/chunks/{chunk-BFWK3TBN.js → chunk-JXLCKACO.js} +2 -2
  88. package/dist/lib/chunks/{chunk-7WO3FFPS.js → chunk-K5NQDJLE.js} +1 -1
  89. package/dist/lib/chunks/{chunk-BXF4OC74.js → chunk-KI2FB4Y3.js} +30 -16
  90. package/dist/lib/chunks/{chunk-Y2CZ6FZY.js → chunk-KRWDELRS.js} +30 -7
  91. package/dist/lib/chunks/{chunk-SIJOQRRK.js → chunk-KRXOJJR7.js} +1 -1
  92. package/dist/lib/chunks/chunk-KSUI4DAY.js +15 -0
  93. package/dist/lib/chunks/chunk-KXFZ3CH3.js +98 -0
  94. package/dist/lib/chunks/{chunk-3OWJBGQE.js → chunk-LJCWZ5SZ.js} +14 -14
  95. package/dist/lib/chunks/{chunk-AJKV46SM.js → chunk-LNYQMWJO.js} +3 -3
  96. package/dist/lib/chunks/{chunk-DL6YQDTE.js → chunk-LOIAGEKN.js} +2 -2
  97. package/dist/lib/chunks/{chunk-I3UE52ZV.js → chunk-LPOIMPJK.js} +2 -2
  98. package/dist/lib/chunks/{chunk-66T7JC57.js → chunk-LUKP64NX.js} +2 -2
  99. package/dist/lib/chunks/chunk-MNG5TZRW.js +208 -0
  100. package/dist/lib/chunks/{chunk-SMPP7B7F.js → chunk-MPQXB7HN.js} +7 -7
  101. package/dist/lib/chunks/{chunk-6JICXLDA.js → chunk-MZ2KN3IH.js} +3 -3
  102. package/dist/lib/chunks/chunk-N62G4EWT.js +91 -0
  103. package/dist/lib/chunks/{chunk-7YDXD4MD.js → chunk-ODIXZHHX.js} +1 -1
  104. package/dist/lib/chunks/{chunk-MTDYBJXH.js → chunk-OTVHGRCO.js} +8 -8
  105. package/dist/lib/chunks/{chunk-YZEZRQIG.js → chunk-OVF27NAO.js} +69 -17
  106. package/dist/lib/chunks/chunk-P6LHGBYU.js +90 -0
  107. package/dist/lib/chunks/{chunk-U5USH2HB.js → chunk-PAL5SXIP.js} +1 -1
  108. package/dist/lib/chunks/{chunk-W5XYW6ZM.js → chunk-PT6PK2MJ.js} +26 -19
  109. package/dist/lib/chunks/{chunk-OD36HUXA.js → chunk-Q22FCF4A.js} +6 -7
  110. package/dist/lib/chunks/chunk-QKTKQSPS.js +292 -0
  111. package/dist/lib/chunks/{chunk-K4Y5NT4M.js → chunk-QO5TPMWS.js} +2 -2
  112. package/dist/lib/chunks/{chunk-VPXYGN4I.js → chunk-QUZYFAGP.js} +17 -22
  113. package/dist/lib/chunks/{chunk-HI3PD3KR.js → chunk-QVMPTT7R.js} +5 -5
  114. package/dist/lib/chunks/{chunk-OQFAMKLN.js → chunk-RGZY6YUQ.js} +5 -5
  115. package/dist/lib/chunks/{chunk-U6BW6LGX.js → chunk-RM2VVR7Y.js} +1 -1
  116. package/dist/lib/chunks/{chunk-AJO7XVXK.js → chunk-RMSH7RUG.js} +6 -6
  117. package/dist/lib/chunks/{chunk-V5B6UZ3E.js → chunk-RQGEPR6V.js} +1 -0
  118. package/dist/lib/chunks/{chunk-V5JJEEBT.js → chunk-RYB77E7O.js} +6 -5
  119. package/dist/lib/chunks/chunk-S24JGY7B.js +97 -0
  120. package/dist/lib/chunks/{chunk-6GKKALCI.js → chunk-SF4UJ2AY.js} +1 -1
  121. package/dist/lib/chunks/chunk-SJCUR4QX.js +94 -0
  122. package/dist/lib/chunks/{chunk-XAN4CRFP.js → chunk-SQ55KGHO.js} +1 -1
  123. package/dist/lib/chunks/{chunk-66DVMLGR.js → chunk-TKOQMB6A.js} +7 -7
  124. package/dist/lib/chunks/{chunk-UYDQXXDQ.js → chunk-TWK6IA4P.js} +1 -1
  125. package/dist/lib/chunks/{chunk-DVFFYY5G.js → chunk-U42I3SBR.js} +13 -9
  126. package/dist/lib/chunks/{chunk-FL6LN2K6.js → chunk-UECQONVZ.js} +5 -5
  127. package/dist/lib/chunks/{chunk-FDM2YNQL.js → chunk-VTY53IFN.js} +1 -1
  128. package/dist/lib/chunks/chunk-VYUC772A.js +338 -0
  129. package/dist/lib/chunks/{chunk-WCLKIPJV.js → chunk-WPCBE2NZ.js} +1 -1
  130. package/dist/lib/chunks/{chunk-3OE4UQIB.js → chunk-WRHGLRUK.js} +5 -5
  131. package/dist/lib/chunks/{chunk-3GPUCXVA.js → chunk-WUIY7BXR.js} +36 -19
  132. package/dist/lib/chunks/{chunk-7YYDUHJG.js → chunk-WZA4H4TG.js} +39 -13
  133. package/dist/lib/chunks/{chunk-NH4QGBJV.js → chunk-XBSA7MNJ.js} +7 -2
  134. package/dist/lib/chunks/chunk-XTBCXEH7.js +243 -0
  135. package/dist/lib/chunks/{chunk-ZQ3ER7JD.js → chunk-YPVJAXPP.js} +1 -1
  136. package/dist/lib/chunks/{chunk-SASE7U6E.js → chunk-YQD5ITKI.js} +1 -1
  137. package/dist/lib/chunks/{chunk-DDS4G4DO.js → chunk-YY4BH5XM.js} +6 -6
  138. package/dist/lib/chunks/{chunk-J5NPHPXY.js → chunk-Z3BZRBQF.js} +36 -2
  139. package/dist/lib/chunks/{chunk-XFUYEFQP.js → chunk-ZBQU2VU3.js} +1 -1
  140. package/dist/lib/chunks/{chunk-E3OGPTUY.js → chunk-ZHGABG7L.js} +2 -2
  141. package/dist/lib/chunks/chunk-ZZCRYG36.js +31 -0
  142. package/dist/lib/cli/bundle-commands.js +91 -74
  143. package/dist/lib/cli/run-commands.js +141 -96
  144. package/dist/lib/cli/status-command.js +77 -60
  145. package/dist/lib/codex-workflow/aggregate.js +20 -12
  146. package/dist/lib/codex-workflow/author-tools.js +7 -7
  147. package/dist/lib/codex-workflow/author.js +25 -23
  148. package/dist/lib/codex-workflow/capture.js +39 -18
  149. package/dist/lib/codex-workflow/checkpoint.js +7 -7
  150. package/dist/lib/codex-workflow/checks.js +9 -9
  151. package/dist/lib/codex-workflow/copy-editor.js +20 -19
  152. package/dist/lib/codex-workflow/copy-recovery.js +4 -4
  153. package/dist/lib/codex-workflow/copy.js +17 -16
  154. package/dist/lib/codex-workflow/finish.js +29 -25
  155. package/dist/lib/codex-workflow/host-models.js +2 -2
  156. package/dist/lib/codex-workflow/loop.js +54 -48
  157. package/dist/lib/codex-workflow/quality.js +4 -4
  158. package/dist/lib/codex-workflow/run-inputs.js +6 -6
  159. package/dist/lib/codex-workflow/run-source.js +16 -16
  160. package/dist/lib/codex-workflow/schemas.js +6 -6
  161. package/dist/lib/codex-workflow/session.js +8 -8
  162. package/dist/lib/codex-workflow/stage.js +32 -29
  163. package/dist/lib/codex-workflow/workdir.js +18 -11
  164. package/dist/lib/engine/audit-file.js +9 -8
  165. package/dist/lib/engine/author.js +40 -37
  166. package/dist/lib/engine/cost-estimate.js +37 -9
  167. package/dist/lib/engine/local-run.js +76 -59
  168. package/dist/lib/engine/preflight.js +37 -9
  169. package/dist/lib/engine/rejudge.js +82 -65
  170. package/dist/lib/engine/run-bindings.js +62 -0
  171. package/dist/lib/engine/run-status.js +77 -60
  172. package/dist/lib/engine/templates.js +10 -9
  173. package/dist/lib/grounding/controller.js +8 -7
  174. package/dist/lib/grounding/extract.js +8 -6
  175. package/dist/lib/grounding/grounding-runtime.js +22 -21
  176. package/dist/lib/grounding/model-usage.js +2 -2
  177. package/dist/lib/grounding/model.js +7 -5
  178. package/dist/lib/grounding/recorded-tools.js +9 -9
  179. package/dist/lib/harness/report/artifacts.js +5 -5
  180. package/dist/lib/lib/checkpoint.js +5 -5
  181. package/dist/lib/lib/log.js +1 -1
  182. package/dist/lib/models/accounting.js +1 -1
  183. package/dist/lib/models/batching.js +6 -4
  184. package/dist/lib/models/budget-protection.js +1 -1
  185. package/dist/lib/models/cost-coefficients.js +2 -1
  186. package/dist/lib/models/gateway-cost.js +7 -0
  187. package/dist/lib/models/structured.js +5 -3
  188. package/dist/lib/models/supported-models.js +1 -1
  189. package/dist/lib/pipeline.js +36 -17
  190. package/dist/lib/probes/adapter.js +6 -0
  191. package/dist/lib/probes/adapters/cli-agents.js +44 -0
  192. package/dist/lib/probes/adapters/cli-claude-code.js +21 -0
  193. package/dist/lib/probes/adapters/cli-codex.js +23 -0
  194. package/dist/lib/probes/adapters/cli-cursor.js +21 -0
  195. package/dist/lib/probes/adapters/cli-process.js +34 -0
  196. package/dist/lib/probes/adapters/dataforseo-ai-overview.js +20 -0
  197. package/dist/lib/probes/adapters/gateway-chat.js +30 -0
  198. package/dist/lib/probes/adapters/gateway-perplexity.js +19 -0
  199. package/dist/lib/probes/agent-cli-parsers.js +2 -2
  200. package/dist/lib/probes/agent-clis.js +26 -11
  201. package/dist/lib/probes/answer-text.js +21 -0
  202. package/dist/lib/probes/attempt.js +28 -0
  203. package/dist/lib/probes/bindings.js +69 -0
  204. package/dist/lib/probes/charged-trace.js +47 -3
  205. package/dist/lib/probes/dataforseo-locale.js +1 -1
  206. package/dist/lib/probes/dataforseo.js +8 -5
  207. package/dist/lib/probes/grounding-urls.js +6 -4
  208. package/dist/lib/probes/legacy-bindings.js +7 -0
  209. package/dist/lib/probes/limits.js +1 -1
  210. package/dist/lib/probes/probes.js +33 -12
  211. package/dist/lib/runner.js +17 -14
  212. package/dist/lib/schema.js +4 -4
  213. package/dist/lib/section-result.js +6 -6
  214. package/dist/lib/stores/artifacts.js +7 -7
  215. package/dist/lib/stores/files.js +20 -18
  216. package/dist/lib/stores/local-versions.js +5 -5
  217. package/dist/lib/stores/memory.js +20 -15
  218. package/dist/lib/stores/publication.js +11 -11
  219. package/dist/lib/stores/unit-record.js +28 -0
  220. package/dist/lib/viewer/server.js +33 -25
  221. package/dist/lib/workflow/schema.js +3 -3
  222. package/dist/types/bundle/contracts.d.ts +1 -1
  223. package/dist/types/capture-manifest.d.ts +1 -0
  224. package/dist/types/checks/money-pages.d.ts +19 -0
  225. package/dist/types/codex-workflow/capture.d.ts +13 -0
  226. package/dist/types/codex-workflow/workdir.d.ts +0 -1
  227. package/dist/types/engine/cost-estimate.d.ts +5 -1
  228. package/dist/types/engine/preflight.d.ts +6 -1
  229. package/dist/types/engine/run-bindings.d.ts +25 -0
  230. package/dist/types/models/accounting.d.ts +7 -0
  231. package/dist/types/models/cost-coefficients.d.ts +5 -5
  232. package/dist/types/models/gateway-cost.d.ts +3 -0
  233. package/dist/types/pipeline.d.ts +2 -0
  234. package/dist/types/probes/adapter.d.ts +112 -0
  235. package/dist/types/probes/adapters/cli-agents.d.ts +19 -0
  236. package/dist/types/probes/adapters/cli-claude-code.d.ts +4 -0
  237. package/dist/types/probes/adapters/cli-codex.d.ts +10 -0
  238. package/dist/types/probes/adapters/cli-cursor.d.ts +4 -0
  239. package/dist/types/probes/adapters/cli-process.d.ts +86 -0
  240. package/dist/types/probes/adapters/dataforseo-ai-overview.d.ts +12 -0
  241. package/dist/types/probes/adapters/gateway-chat.d.ts +32 -0
  242. package/dist/types/probes/adapters/gateway-perplexity.d.ts +10 -0
  243. package/dist/types/probes/agent-clis.d.ts +7 -49
  244. package/dist/types/probes/answer-text.d.ts +20 -0
  245. package/dist/types/probes/attempt.d.ts +113 -0
  246. package/dist/types/probes/bindings.d.ts +79 -0
  247. package/dist/types/probes/charged-trace.d.ts +2 -1
  248. package/dist/types/probes/dataforseo.d.ts +24 -1
  249. package/dist/types/probes/grounding-urls.d.ts +18 -5
  250. package/dist/types/probes/legacy-bindings.d.ts +36 -0
  251. package/dist/types/probes/limits.d.ts +12 -6
  252. package/dist/types/probes/probe-trace.d.ts +10 -0
  253. package/dist/types/probes/probes.d.ts +5 -3
  254. package/dist/types/stores/ports.d.ts +1 -0
  255. package/dist/types/stores/unit-record.d.ts +11 -0
  256. package/package.json +6 -6
  257. package/src/agents/author-validation.ts +22 -1
  258. package/src/analysis/progress.ts +10 -1
  259. package/src/bundle/contracts.ts +1 -1
  260. package/src/bundle/recorder.ts +47 -1
  261. package/src/capture-manifest.ts +6 -0
  262. package/src/checks/money-pages.ts +48 -0
  263. package/src/cli/run-commands.ts +37 -1
  264. package/src/codex-workflow/capture.ts +60 -0
  265. package/src/codex-workflow/workdir.ts +3 -4
  266. package/src/engine/audit-file.ts +20 -30
  267. package/src/engine/cost-estimate.ts +10 -4
  268. package/src/engine/local-run.ts +21 -2
  269. package/src/engine/preflight.ts +113 -17
  270. package/src/engine/rejudge.ts +5 -0
  271. package/src/engine/run-bindings.ts +142 -0
  272. package/src/grounding/extract.ts +1 -0
  273. package/src/grounding/model-usage.ts +4 -0
  274. package/src/lib/log.ts +17 -15
  275. package/src/models/accounting.ts +34 -0
  276. package/src/models/budget-protection.ts +1 -0
  277. package/src/models/cost-coefficients.ts +17 -13
  278. package/src/models/gateway-cost.ts +32 -0
  279. package/src/models/structured.ts +2 -10
  280. package/src/models/supported-models.ts +3 -3
  281. package/src/pipeline.ts +36 -17
  282. package/src/probes/adapter.ts +122 -0
  283. package/src/probes/adapters/cli-agents.ts +123 -0
  284. package/src/probes/adapters/cli-claude-code.ts +119 -0
  285. package/src/probes/adapters/cli-codex.ts +145 -0
  286. package/src/probes/adapters/cli-cursor.ts +95 -0
  287. package/src/probes/adapters/cli-process.ts +522 -0
  288. package/src/probes/adapters/dataforseo-ai-overview.ts +106 -0
  289. package/src/probes/adapters/gateway-chat.ts +339 -0
  290. package/src/probes/adapters/gateway-perplexity.ts +104 -0
  291. package/src/probes/agent-clis.ts +151 -1088
  292. package/src/probes/answer-text.ts +153 -0
  293. package/src/probes/attempt.ts +462 -0
  294. package/src/probes/bindings.ts +344 -0
  295. package/src/probes/charged-trace.ts +54 -13
  296. package/src/probes/dataforseo-locale.ts +13 -2
  297. package/src/probes/dataforseo.ts +265 -188
  298. package/src/probes/grounding-urls.ts +68 -19
  299. package/src/probes/legacy-bindings.ts +40 -0
  300. package/src/probes/limits.ts +31 -18
  301. package/src/probes/probe-trace.ts +10 -0
  302. package/src/probes/probes.ts +64 -736
  303. package/src/runner.ts +13 -0
  304. package/src/stores/files.ts +78 -54
  305. package/src/stores/memory.ts +4 -1
  306. package/src/stores/ports.ts +3 -0
  307. package/src/stores/unit-record.ts +151 -0
  308. package/dist/lib/chunks/chunk-BGAHZIL3.js +0 -563
  309. package/dist/lib/chunks/chunk-IB6RROHE.js +0 -204
  310. package/dist/lib/chunks/chunk-WZGI7UVM.js +0 -937
@@ -0,0 +1,11 @@
1
+ import type { UnitRecord } from './ports';
2
+ /** A stored row that no release could have written. */
3
+ export declare class ProbeStoreIntegrityError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /**
7
+ * parseUnitRecord validates a stored row and returns it as a unit record,
8
+ * unchanged but for the `status` a row from before unit outcomes lacks.
9
+ * `where` names the row in the error (a file line, a unit key).
10
+ */
11
+ export declare const parseUnitRecord: (row: unknown, where: string) => UnitRecord;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "literally-aeo",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Literally.dev AEO: run an AI visibility audit locally and verify its evidence offline.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -88,11 +88,11 @@
88
88
  "vitest": "^4.1.10"
89
89
  },
90
90
  "scripts": {
91
- "build": "node scripts/build.mjs",
92
- "typecheck": "tsc --noEmit",
93
- "lint": "eslint --max-warnings=0",
94
- "test": "vitest run",
95
- "test:watch": "vitest",
91
+ "build": "sh scripts/capped.sh node scripts/build.mjs",
92
+ "typecheck": "sh scripts/capped.sh tsc --noEmit",
93
+ "lint": "sh scripts/capped.sh eslint --max-warnings=0",
94
+ "test": "sh scripts/capped.sh vitest run",
95
+ "test:watch": "sh scripts/capped.sh vitest",
96
96
  "format": "prettier --write .",
97
97
  "cli": "tsx src/cli/literally-aeo.ts"
98
98
  }
@@ -1,6 +1,7 @@
1
1
  import { aeoAuditConfigSchema, type AeoAuditConfig } from '../schema';
2
2
  import { normalizeDomain } from '../analysis/scoring';
3
3
  import banlist from '../author/banlist.json';
4
+ import { maxMoneyPages, moneyPageProblem } from '../checks/money-pages';
4
5
  import { canonicalResearchUrl, fetchGroundingSource } from '../grounding/fetch';
5
6
  import { SourceRetrievalError } from '../grounding/guarded-request';
6
7
  import { credentialDetected } from './credentials';
@@ -277,7 +278,9 @@ export const validateAuthorOutput = async (args: {
277
278
 
278
279
  if (
279
280
  !underHost(normalizeDomain(config.brand.domain), host) ||
280
- config.moneyPages.some((url) => !underHost(normalizeDomain(url), host)) ||
281
+ config.moneyPages.some(
282
+ (url) => moneyPageProblem(url, { domain: host })?.kind === 'off_site',
283
+ ) ||
281
284
  competitors.some((competitor) =>
282
285
  args.protectedClientHosts.some((client) =>
283
286
  underHost(normalizeDomain(competitor.domain), normalizeDomain(client)),
@@ -293,6 +296,24 @@ export const validateAuthorOutput = async (args: {
293
296
  };
294
297
  }
295
298
 
299
+ // The site checks fetch and render every money page: a page the guard
300
+ // would refuse, or more than it may fetch, is the author's to repair.
301
+ config.moneyPages.forEach((url, index) => {
302
+ const problem = moneyPageProblem(url, { domain: host });
303
+
304
+ if (problem?.kind === 'unsafe_url') {
305
+ errors.push(
306
+ `moneyPages.${index}: Use a public https URL with no port or credentials (${problem.message})`,
307
+ );
308
+ }
309
+ });
310
+
311
+ if (config.moneyPages.length > maxMoneyPages) {
312
+ errors.push(
313
+ `moneyPages: Keep the ${maxMoneyPages} pages that matter most; the site checks fetch at most ${maxMoneyPages}.`,
314
+ );
315
+ }
316
+
296
317
  // Repairable only once the submission is the right company's: a wrong
297
318
  // host with one attributed claim must not spend a repair session first.
298
319
  notes.data.proposedFacts.forEach((fact, index) => {
@@ -206,6 +206,9 @@ export const projectProgressMeasurement = (
206
206
  const cliVersion =
207
207
  capture?.probeProfile.cliVersion ?? row?.agentCliVersion ?? null;
208
208
  const parameters = capture?.probeProfile.parameters ?? null;
209
+ // Hashed exactly when recorded: a capture without it was taken with its
210
+ // surface's legacy adapter, and digests as earlier releases did.
211
+ const adapter = capture?.probeProfile.adapter;
209
212
  const hasParameters =
210
213
  parameters !== null && Object.keys(parameters).length > 0;
211
214
  // Empty strings carry no metadata, so these checks are truthiness checks.
@@ -244,7 +247,13 @@ export const projectProgressMeasurement = (
244
247
  cliVersion,
245
248
  collectionMetadataKnown,
246
249
  collectionMethodDigest: collectionMetadataKnown
247
- ? contentHash({ requestedModel, reportedModel, cliVersion, parameters })
250
+ ? contentHash({
251
+ requestedModel,
252
+ reportedModel,
253
+ cliVersion,
254
+ parameters,
255
+ ...(adapter === undefined ? {} : { adapter }),
256
+ })
248
257
  : null,
249
258
  };
250
259
  });
@@ -13,7 +13,7 @@ import { canonicalDigest } from './json';
13
13
  export const toolId = 'literally-aeo';
14
14
  // The package version, recorded in every journal and bundle; the build and
15
15
  // version.spec.ts refuse a mismatch with package.json.
16
- export const toolVersion = '0.2.1';
16
+ export const toolVersion = '0.3.0';
17
17
  // Version 2: config.json may set chatProbes, and agentProbes.runsPerPrompt
18
18
  // above 2. A verifier that reads only version 1 then refuses the bundle as
19
19
  // unsupported instead of dropping its depth and failing it.
@@ -7,6 +7,7 @@ import type {
7
7
  ModelCallReservation,
8
8
  ModelCallUsage,
9
9
  } from '../models/accounting';
10
+ import type { RedirectResolution } from '../probes/grounding-urls';
10
11
  import type { ProbeAttemptEnd, ProbeTrace } from '../probes/probe-trace';
11
12
  import { hasErrorCode } from '../stores/fs-errors';
12
13
  import {
@@ -384,10 +385,27 @@ export const recordingAccounting = (
384
385
  });
385
386
  };
386
387
 
388
+ // A released call was never dispatched: its operation ends cancelled,
389
+ // with no response and no cost.
390
+ const release = async (callId: string) => {
391
+ await accounting.release(callId);
392
+
393
+ const handle = open.get(callId);
394
+
395
+ open.delete(callId);
396
+ requests.delete(callId);
397
+ responses.delete(callId);
398
+ await handle?.finish({
399
+ outcome: 'cancelled',
400
+ details: { released: true },
401
+ });
402
+ };
403
+
387
404
  const wrapped: ModelCallAccounting = {
388
405
  deadlineAt: accounting.deadlineAt,
389
406
  reserve,
390
407
  settle,
408
+ release,
391
409
  observe,
392
410
  assertOwned: () => accounting.assertOwned(),
393
411
  };
@@ -441,6 +459,25 @@ export const recorded = async <T>({
441
459
  return value;
442
460
  };
443
461
 
462
+ // An answer can name any number of wrappers; the journal keeps the first
463
+ // hundred resolutions and says how many it left out.
464
+ const maxRecordedRedirects = 100;
465
+
466
+ const redirectDetails = (
467
+ redirects: readonly RedirectResolution[] | undefined,
468
+ ): Record<string, unknown> => {
469
+ if (!redirects || redirects.length === 0) {
470
+ return {};
471
+ }
472
+
473
+ return {
474
+ redirects: redirects.slice(0, maxRecordedRedirects),
475
+ ...(redirects.length > maxRecordedRedirects && {
476
+ redirectsOmitted: redirects.length - maxRecordedRedirects,
477
+ }),
478
+ };
479
+ };
480
+
444
481
  /**
445
482
  * probeTraceOf records probe attempts (or canaries) as operations: the
446
483
  * prompt as input; the answer and its retrieval log as outputs; the
@@ -455,7 +492,11 @@ export const probeTraceOf = (
455
492
  kind,
456
493
  role: attempt.surface,
457
494
  attempt: attempt.attempt,
458
- inputs: { prompt: attempt.promptText },
495
+ inputs: {
496
+ prompt: attempt.promptText,
497
+ // The request as dispatched, prefix and parameters included.
498
+ ...(attempt.request && { request: JSON.stringify(attempt.request) }),
499
+ },
459
500
  details: {
460
501
  sectionKey: attempt.sectionKey ?? null,
461
502
  surface: attempt.surface,
@@ -463,6 +504,7 @@ export const probeTraceOf = (
463
504
  runIndex: attempt.runIndex,
464
505
  retryOf: attempt.retryOf ?? null,
465
506
  requestedModel: attempt.requestedModel,
507
+ ...(attempt.adapter !== undefined && { adapter: attempt.adapter }),
466
508
  },
467
509
  });
468
510
 
@@ -491,6 +533,10 @@ export const probeTraceOf = (
491
533
  // neither named one, never the requested model (§7.1).
492
534
  reportedModel: result.reportedModel ?? null,
493
535
  noOverview: result.noOverview === true,
536
+ // What the provider reported the attempt cost; null when it did
537
+ // not say, never the estimate.
538
+ costUsd: result.costUsd ?? null,
539
+ ...redirectDetails(result.redirects),
494
540
  },
495
541
  });
496
542
  };
@@ -43,6 +43,9 @@ const captureSchema = unitSchema
43
43
  reportedModel: z.string().nullable(),
44
44
  cliVersion: z.string().nullable(),
45
45
  parameters: z.record(z.string(), z.unknown()).nullable(),
46
+ // Present only when the capture was not taken with its surface's
47
+ // legacy adapter (probe adapters spec §4.6).
48
+ adapter: z.string().optional(),
46
49
  }),
47
50
  metadataProvenance: z.enum(['captured_record', 'legacy_preserved_record']),
48
51
  digest,
@@ -277,6 +280,9 @@ export const buildCaptureManifest = (args: {
277
280
  ? record.probe.agentCliVersion
278
281
  : null,
279
282
  parameters: record.captureMetadata?.parameters ?? null,
283
+ ...(record.captureMetadata?.adapter === undefined
284
+ ? {}
285
+ : { adapter: record.captureMetadata.adapter }),
280
286
  },
281
287
  metadataProvenance: record.captureMetadata
282
288
  ? ('captured_record' as const)
@@ -0,0 +1,48 @@
1
+ import {
2
+ SourceRetrievalError,
3
+ validateResearchUrl,
4
+ } from '../grounding/guarded-request';
5
+ import { urlIsOnDomain } from '../report/core/domain-match';
6
+
7
+ // ============================================================================
8
+ // Which money pages the site checks may fetch and render
9
+ // (specs/aeo-checks-and-reach-spec.md §3.3). One rule for every place a
10
+ // config is admitted: audit.json, the author's output and the hosted
11
+ // platform. The verifier never applies it: stored bundles keep verifying.
12
+ // ============================================================================
13
+
14
+ export const maxMoneyPages = 20;
15
+
16
+ /** Why a money page is refused: another site's page, or a URL the guard
17
+ * would never fetch. Each caller words the remedy its own input offers. */
18
+ export type MoneyPageProblem =
19
+ { kind: 'off_site' } | { kind: 'unsafe_url'; message: string };
20
+
21
+ /**
22
+ * moneyPageProblem says why the site checks may not fetch a page, or
23
+ * undefined when they may. The page must be on the brand's site or its
24
+ * subdomains (or on a host the operator allowed), and public https with no
25
+ * port or credentials.
26
+ */
27
+ export const moneyPageProblem = (
28
+ page: string,
29
+ site: { domain: string; checkHosts?: readonly string[] },
30
+ ): MoneyPageProblem | undefined => {
31
+ const hosts = [site.domain, ...(site.checkHosts ?? [])];
32
+
33
+ if (!hosts.some((host) => urlIsOnDomain(page, host))) {
34
+ return { kind: 'off_site' };
35
+ }
36
+
37
+ try {
38
+ validateResearchUrl(page);
39
+ } catch (err) {
40
+ if (err instanceof SourceRetrievalError) {
41
+ return { kind: 'unsafe_url', message: err.message };
42
+ }
43
+
44
+ throw err;
45
+ }
46
+
47
+ return undefined;
48
+ };
@@ -20,6 +20,7 @@ import {
20
20
  type RunCostEstimate,
21
21
  } from '../engine/cost-estimate';
22
22
  import {
23
+ bankDir,
23
24
  openLocalRun,
24
25
  planLocalRun,
25
26
  PreflightFailedError,
@@ -32,6 +33,12 @@ import {
32
33
  runSettingNames,
33
34
  } from '../engine/preflight';
34
35
  import { prepareRejudgment } from '../engine/rejudge';
36
+ import {
37
+ defaultProbeBindings,
38
+ profileOf,
39
+ RunBindingsError,
40
+ } from '../probes/bindings';
41
+ import { estimateBindingsOf } from '../engine/run-bindings';
35
42
  import {
36
43
  readAuthorEvidence,
37
44
  readBrief,
@@ -175,6 +182,7 @@ export const runDoctor = async (flags: Flags) => {
175
182
  model: file.model,
176
183
  groundingSearch: usesGroundingSearch(request),
177
184
  rendersPages: file.moneyPages.length > 0,
185
+ bindings: await estimateBindingsOf(path.join(runDirOf(flags), bankDir)),
178
186
  });
179
187
  const ok = checks.every((check) => check.ok);
180
188
 
@@ -206,10 +214,30 @@ export const runPlan = async (flags: Flags) => {
206
214
  const state = await runDirectoryState(dir);
207
215
  const bySurface = Object.fromEntries(plan.probesBySurface);
208
216
  const model = resolveSupportedModel(file.model);
217
+ const bindings = await estimateBindingsOf(path.join(dir, bankDir));
209
218
  const estimate = estimateRunCost({
210
219
  plan,
211
220
  model,
212
221
  grounding: request.grounding,
222
+ bindings,
223
+ });
224
+ // A coding agent bills its own plan, or, on an API key, that provider
225
+ // account per use: either way outside the cap, which the plan says.
226
+ const agentBilling = plan.agentSurfaces.flatMap((surface) => {
227
+ const accounts = profileOf(bindings[surface]).settings.flatMap((setting) =>
228
+ setting.billsAccount === undefined
229
+ ? []
230
+ : [`on ${setting.name}, that ${setting.billsAccount} account`],
231
+ );
232
+
233
+ return accounts.length === 0
234
+ ? []
235
+ : [
236
+ formatLine(
237
+ `${surface} billing`,
238
+ `on its own login, your plan; ${accounts.join('; ')}, outside this run's cap`,
239
+ ),
240
+ ];
213
241
  });
214
242
  const summary = {
215
243
  brand: config.brand.name,
@@ -246,6 +274,7 @@ export const runPlan = async (flags: Flags) => {
246
274
  formatLine(`Section ${section.key}`, `${section.questions} questions`),
247
275
  ),
248
276
  formatLine('Surfaces', summary.surfaces.join(', ')),
277
+ ...agentBilling,
249
278
  ...Object.entries(bySurface).map(([surface, count]) =>
250
279
  formatLine(` ${surface}`, `${count} answers`),
251
280
  ),
@@ -295,6 +324,7 @@ export const runRun = async (flags: Flags) => {
295
324
  plan,
296
325
  model: resolveSupportedModel(file.model),
297
326
  grounding: request.grounding,
327
+ bindings: await estimateBindingsOf(path.join(dir, bankDir)),
298
328
  }),
299
329
  });
300
330
 
@@ -309,6 +339,7 @@ export const runRun = async (flags: Flags) => {
309
339
  model: file.model,
310
340
  groundingSearch: usesGroundingSearch(request),
311
341
  rendersPages: file.moneyPages.length > 0,
342
+ bindings: await estimateBindingsOf(path.join(dir, bankDir)),
312
343
  });
313
344
  const failing = checks.filter((check) => !check.ok);
314
345
 
@@ -416,6 +447,7 @@ export const runAuthor = async (flags: Flags, usage: string) => {
416
447
  settings,
417
448
  dir,
418
449
  groundingSearch: true,
450
+ bindings: defaultProbeBindings,
419
451
  });
420
452
  const failing = checks.filter((check) => !check.ok);
421
453
 
@@ -540,6 +572,7 @@ export const runRejudge = async (flags: Flags, usage: string) => {
540
572
  plan: { units: plan.units, probesBySurface: new Map() },
541
573
  model: resolveSupportedModel(file.model),
542
574
  grounding: request.grounding,
575
+ bindings: defaultProbeBindings,
543
576
  }),
544
577
  });
545
578
 
@@ -560,6 +593,8 @@ export const runRejudge = async (flags: Flags, usage: string) => {
560
593
  dir,
561
594
  model: file.model,
562
595
  groundingSearch: usesGroundingSearch(request),
596
+ // Nothing is probed again; the settings checked are the same.
597
+ bindings: defaultProbeBindings,
563
598
  });
564
599
  const failing = checks.filter((check) => !check.ok);
565
600
 
@@ -724,7 +759,8 @@ const executeRun = async ({
724
759
  if (
725
760
  err instanceof PreflightFailedError ||
726
761
  err instanceof WriterLockHeldError ||
727
- err instanceof BudgetCapMissingError
762
+ err instanceof BudgetCapMissingError ||
763
+ err instanceof RunBindingsError
728
764
  ) {
729
765
  writeErr(err.message);
730
766
 
@@ -12,8 +12,15 @@ import type { RunPlan } from '../runner';
12
12
  import type { AeoAuditConfig, RunRequest } from '../schema';
13
13
  import { contentHash } from '../stores/content-hash';
14
14
  import type { CapturedUnitRecord, ProbeStore, Stores } from '../stores/ports';
15
+ import { parseUnitRecord } from '../stores/unit-record';
15
16
  import { isAgentSurface, type AeoAgentSurface } from '../surfaces';
16
17
  import type { ProbeTrace } from '../probes/probe-trace';
18
+ import {
19
+ bankBindingMismatches,
20
+ RunBindingsError,
21
+ type ProbeDependencies,
22
+ type RunBindings,
23
+ } from '../probes/bindings';
17
24
 
18
25
  // ============================================================================
19
26
  // The paid half of a run: every planned probe unit captured or reused from
@@ -35,6 +42,9 @@ export type CaptureDeps = {
35
42
  /** The run journal, when the capture is recorded (a local run). */
36
43
  trace?: ProbeTrace;
37
44
  signal?: AbortSignal;
45
+ /** What the probe adapters are created with: the gateway, credentials,
46
+ * clients. */
47
+ probeDependencies: ProbeDependencies;
38
48
  logContext: Record<string, unknown>;
39
49
  now?: () => Date;
40
50
  /** The section capture service; tests inject one. */
@@ -92,11 +102,54 @@ const sectionArgs = (
92
102
  agentRuntime: deps.agentRuntime,
93
103
  trace: deps.trace,
94
104
  signal: deps.signal,
105
+ probeDependencies: deps.probeDependencies,
95
106
  internalModels: deps.internalModels,
96
107
  logContext: { ...deps.logContext, sectionKey: section.key },
97
108
  };
98
109
  };
99
110
 
111
+ /**
112
+ * assertBankUsable refuses a bank the run cannot build on, before anything
113
+ * is dispatched: a row no release wrote (phase 3 item 6), or a banked
114
+ * answer the plan reuses that another binding captured. captureForRun runs
115
+ * it before its first section, where the sections would otherwise settle
116
+ * independently and spend while one fails; a host runs it before its agent
117
+ * canaries too.
118
+ */
119
+ export const assertBankUsable = async (
120
+ probeStore: Pick<ProbeStore, 'list'>,
121
+ plan: RunPlan,
122
+ bindings: RunBindings,
123
+ ): Promise<void> => {
124
+ const banked = await probeStore.list();
125
+
126
+ for (const record of banked) {
127
+ parseUnitRecord(record, unitRecordKey(record));
128
+ }
129
+
130
+ // A banked answer is reused only under the binding that captured it; a
131
+ // mismatch stops the run, never re-probed silently.
132
+ const plannedKeys = new Set(plan.units.map(unitRecordKey));
133
+ const mismatched = bankBindingMismatches(
134
+ banked.filter(
135
+ (record): record is CapturedUnitRecord =>
136
+ record.status === 'captured' && plannedKeys.has(unitRecordKey(record)),
137
+ ),
138
+ bindings,
139
+ );
140
+
141
+ if (mismatched.length > 0) {
142
+ const surfaces = [...new Set(mismatched.map((record) => record.surface))];
143
+ const bound = surfaces
144
+ .map((surface) => `${surface} (${bindings[surface].adapter})`)
145
+ .join(', ');
146
+
147
+ throw new RunBindingsError(
148
+ `${mismatched.length} banked answers were captured with another adapter than this run's binding of ${bound}. A banked answer is never probed again under another binding: start a fresh run (a new run directory, or mode fresh) to measure them this way.`,
149
+ );
150
+ }
151
+ };
152
+
100
153
  /** Orders by UTF-16 code units, independent of the host's locale. */
101
154
  const compareCodeUnits = (left: string, right: string) => {
102
155
  if (left === right) {
@@ -112,6 +165,13 @@ export const captureForRun = async (
112
165
  const { config, plan } = deps;
113
166
  const now = deps.now ?? (() => new Date());
114
167
  const captureSection = deps.captureSection ?? captureSectionProbes;
168
+
169
+ await assertBankUsable(
170
+ deps.stores.probeStore,
171
+ plan,
172
+ deps.probeDependencies.bindings,
173
+ );
174
+
115
175
  const startedAt = now().toISOString();
116
176
  const settled = await Promise.allSettled(
117
177
  plan.sections.map((section) => captureSection(sectionArgs(deps, section))),
@@ -2,6 +2,7 @@ import { mkdir, writeFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { criteriaForRole, producerGuidance } from '../harness/criteria';
4
4
  import type { AeoAuditConfig } from '../schema';
5
+ import { searchSourcesMarker } from '../probes/answer-text';
5
6
  import type { CapturedUnitRecord } from '../stores/ports';
6
7
  import { isStageName, stageJsonSchema, stageSchemas } from './schemas';
7
8
 
@@ -14,8 +15,6 @@ import { isStageName, stageJsonSchema, stageSchemas } from './schemas';
14
15
  // publisher for a mention.
15
16
  // ============================================================================
16
17
 
17
- export const sourcesMarker = 'Sources used by search:';
18
-
19
18
  export type AnswerFile = {
20
19
  /** Path relative to the work directory. */
21
20
  file: string;
@@ -79,7 +78,7 @@ export const answerFilePath = (record: {
79
78
 
80
79
  /** The body of a captured answer: everything before the sources block. */
81
80
  export const answerBody = (text: string): string => {
82
- const at = text.lastIndexOf(sourcesMarker);
81
+ const at = text.lastIndexOf(searchSourcesMarker);
83
82
 
84
83
  return (at < 0 ? text : text.slice(0, at)).trim();
85
84
  };
@@ -121,7 +120,7 @@ export const materializeWorkdir = async (args: {
121
120
  for (const record of args.captured) {
122
121
  const file = answerFilePath(record);
123
122
  const text = record.probe.text;
124
- const at = text.lastIndexOf(sourcesMarker);
123
+ const at = text.lastIndexOf(searchSourcesMarker);
125
124
  const body = answerBody(text);
126
125
  const sources = at < 0 ? '' : text.slice(at);
127
126
  const content = [
@@ -1,5 +1,10 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { z } from 'zod';
3
+ import {
4
+ maxMoneyPages,
5
+ moneyPageProblem,
6
+ type MoneyPageProblem,
7
+ } from '../checks/money-pages';
3
8
  import {
4
9
  SourceRetrievalError,
5
10
  validateResearchUrl,
@@ -9,7 +14,6 @@ import { localModelProfile } from '../models/local-profile';
9
14
  import { resolveSupportedModel } from '../models/supported-models';
10
15
  import { resolveDataForSeoLocale } from '../probes/dataforseo-locale';
11
16
  import { probeLimitsSchema } from '../probes/limits';
12
- import { urlIsOnDomain } from '../report/core/domain-match';
13
17
  import {
14
18
  aeoAuditConfigSchema,
15
19
  aeoSurfaceSchema,
@@ -114,35 +118,18 @@ const checkHostProblem = (host: string): string | undefined => {
114
118
  return `Use a bare public host name such as docs.acme.example, not ${JSON.stringify(host)}.`;
115
119
  };
116
120
 
117
- /**
118
- * Why a money page is refused. The site checks fetch and render it, so it
119
- * must be public https on the brand's site or its subdomains, or on a host
120
- * the operator named in runPolicy.checkHosts.
121
- */
122
- const moneyPageProblem = (
121
+ /** A refused money page in audit.json's terms: checkHosts is the remedy
122
+ * for a page on another site. */
123
+ const describeMoneyPageProblem = (
123
124
  page: string,
124
- file: {
125
- brand: { domain: string };
126
- runPolicy: { checkHosts: readonly string[] };
127
- },
128
- ): string | undefined => {
129
- try {
130
- validateResearchUrl(page);
131
- } catch (err) {
132
- if (err instanceof SourceRetrievalError) {
133
- return `A money page must be a public https URL with no port or credentials: ${err.message}`;
134
- }
135
-
136
- throw err;
125
+ domain: string,
126
+ problem: MoneyPageProblem,
127
+ ): string => {
128
+ if (problem.kind === 'unsafe_url') {
129
+ return `A money page must be a public https URL with no port or credentials: ${problem.message}`;
137
130
  }
138
131
 
139
- const hosts = [file.brand.domain, ...file.runPolicy.checkHosts];
140
-
141
- if (hosts.some((host) => urlIsOnDomain(page, host))) {
142
- return undefined;
143
- }
144
-
145
- return `${page} is not on ${file.brand.domain} or its subdomains. Name its host in runPolicy.checkHosts to let the site checks fetch it.`;
132
+ return `${page} is not on ${domain} or its subdomains. Name its host in runPolicy.checkHosts to let the site checks fetch it.`;
146
133
  };
147
134
 
148
135
  export const auditFileSchema = z
@@ -167,7 +154,7 @@ export const auditFileSchema = z
167
154
  chatProbes: chatProbeConfigSchema.optional(),
168
155
  geography: z.string().default('us'),
169
156
  language: z.string().default('en'),
170
- moneyPages: z.array(z.url()).max(20).default([]),
157
+ moneyPages: z.array(z.url()).max(maxMoneyPages).default([]),
171
158
  productBrief: z.string().trim().min(1),
172
159
  // `full` researches and adjudicates the claims answers make about the
173
160
  // product; `extraction_only` keeps the claim inventory and skips both.
@@ -201,12 +188,15 @@ export const auditFileSchema = z
201
188
  }
202
189
 
203
190
  for (const [index, page] of file.moneyPages.entries()) {
204
- const problem = moneyPageProblem(page, file);
191
+ const problem = moneyPageProblem(page, {
192
+ domain: file.brand.domain,
193
+ checkHosts: file.runPolicy.checkHosts,
194
+ });
205
195
 
206
196
  if (problem !== undefined) {
207
197
  context.addIssue({
208
198
  code: 'custom',
209
- message: problem,
199
+ message: describeMoneyPageProblem(page, file.brand.domain, problem),
210
200
  path: ['moneyPages', index],
211
201
  });
212
202
  }
@@ -4,7 +4,6 @@ import {
4
4
  authorTokens,
5
5
  costCoefficientsVersion,
6
6
  hostTokensPerAnswer,
7
- probeUsd,
8
7
  searchUsdPerAnswer,
9
8
  stageTokens,
10
9
  type Range,
@@ -12,6 +11,7 @@ import {
12
11
  } from '../models/cost-coefficients';
13
12
  import { tokenCostUsd } from '../models/pricing';
14
13
  import type { SupportedModel } from '../models/supported-models';
14
+ import { profileOf, type RunBindings } from '../probes/bindings';
15
15
  import type { RunPlan } from '../runner';
16
16
 
17
17
  // ============================================================================
@@ -87,6 +87,9 @@ type EstimateRunOptions = {
87
87
  plan: Pick<RunPlan, 'units' | 'probesBySurface'>;
88
88
  model: SupportedModel;
89
89
  grounding: 'full' | 'extraction_only';
90
+ /** The bindings the run measures with: each surface's probes cost what
91
+ * its bound adapter costs. */
92
+ bindings: RunBindings;
90
93
  };
91
94
 
92
95
  /** estimateRunCost estimates a whole run as planned; a resume spends less,
@@ -95,14 +98,17 @@ export const estimateRunCost = ({
95
98
  plan,
96
99
  model,
97
100
  grounding,
101
+ bindings,
98
102
  }: EstimateRunOptions): RunCostEstimate => {
99
103
  const answers = plan.units.length;
100
104
  const { cachedShare } = stageTokens;
101
105
 
102
106
  const probes = sumOf(
103
- [...plan.probesBySurface].map(([surface, count]) =>
104
- rangeOf(probeUsd[surface].low * count, probeUsd[surface].high * count),
105
- ),
107
+ [...plan.probesBySurface].map(([surface, count]) => {
108
+ const usd = profileOf(bindings[surface]).estimateUsd;
109
+
110
+ return rangeOf(usd.low * count, usd.high * count);
111
+ }),
106
112
  );
107
113
  // The cheap end assumes the cache serves most input; the dear end less.
108
114
  const stages = rangeOf(