literally-aeo 0.2.2 → 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 (304) hide show
  1. package/dist/cli.mjs +6031 -5158
  2. package/dist/lib/agents/author-schema.js +5 -5
  3. package/dist/lib/agents/author-validation.js +7 -7
  4. package/dist/lib/agents/copy-validation.js +9 -9
  5. package/dist/lib/agents/copywriter-input.js +8 -8
  6. package/dist/lib/agents/facts.js +7 -7
  7. package/dist/lib/agents/narrative-facts.js +6 -6
  8. package/dist/lib/agents/verifier.js +13 -12
  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 +8 -8
  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 +23 -15
  31. package/dist/lib/bundle/verify.js +31 -23
  32. package/dist/lib/capture-manifest.js +6 -6
  33. package/dist/lib/checks/crawler-access.js +2 -2
  34. package/dist/lib/checks/renderability.js +2 -2
  35. package/dist/lib/checks/run-checks.js +12 -12
  36. package/dist/lib/chunks/{chunk-3CMPR6ZZ.js → chunk-2C723CW7.js} +1 -1
  37. package/dist/lib/chunks/chunk-2FDSOZ6Q.js +287 -0
  38. package/dist/lib/chunks/{chunk-PWOYEIPF.js → chunk-2U5QSA6Q.js} +7 -7
  39. package/dist/lib/chunks/{chunk-6EI4CVRW.js → chunk-3ESH5NDR.js} +5 -1
  40. package/dist/lib/chunks/{chunk-VHKHYAC5.js → chunk-3S2FAVRE.js} +2 -2
  41. package/dist/lib/chunks/{chunk-LR27H2HZ.js → chunk-44NSZBCP.js} +6 -6
  42. package/dist/lib/chunks/{chunk-JBOOD6MU.js → chunk-4AWFF53U.js} +12 -4
  43. package/dist/lib/chunks/{chunk-MENTBQGB.js → chunk-4HPMLJKC.js} +4 -4
  44. package/dist/lib/chunks/{chunk-S6QOXJAL.js → chunk-4Q2WFZ5J.js} +11 -4
  45. package/dist/lib/chunks/{chunk-7DNLRXEY.js → chunk-5JU2Y2I6.js} +2 -2
  46. package/dist/lib/chunks/{chunk-KFAT65P7.js → chunk-64JFN2Q5.js} +1 -1
  47. package/dist/lib/chunks/chunk-66UE4TT2.js +245 -0
  48. package/dist/lib/chunks/chunk-6N3C6E3D.js +105 -0
  49. package/dist/lib/chunks/{chunk-F2NSJ6PG.js → chunk-6RED3G6K.js} +7 -3
  50. package/dist/lib/chunks/{chunk-HCUJ2J7P.js → chunk-7KLTOVIY.js} +9 -9
  51. package/dist/lib/chunks/{chunk-EOO5RBUW.js → chunk-7ZR3WDF2.js} +38 -5
  52. package/dist/lib/chunks/chunk-A5PF7UE2.js +86 -0
  53. package/dist/lib/chunks/{chunk-PKNODC6Y.js → chunk-AB7DUTX5.js} +1 -1
  54. package/dist/lib/chunks/{chunk-WDT2Y7D7.js → chunk-AQCWKHTE.js} +11 -7
  55. package/dist/lib/chunks/{chunk-UNCUG2YS.js → chunk-ASHFEFCU.js} +3 -3
  56. package/dist/lib/chunks/{chunk-BYHXNFWN.js → chunk-ASIFUJG2.js} +1 -1
  57. package/dist/lib/chunks/{chunk-ZSEY7AHQ.js → chunk-BBK54RVK.js} +14 -11
  58. package/dist/lib/chunks/chunk-BQMUZLHO.js +17 -0
  59. package/dist/lib/chunks/{chunk-QD3JXA3Y.js → chunk-CQNIPZH3.js} +18 -18
  60. package/dist/lib/chunks/{chunk-7HM6IZ3L.js → chunk-CVEXMYPW.js} +2 -2
  61. package/dist/lib/chunks/chunk-CXZIHHLJ.js +95 -0
  62. package/dist/lib/chunks/{chunk-75DMLOQ7.js → chunk-CYJNBVQB.js} +1 -1
  63. package/dist/lib/chunks/{chunk-FAUFE7MI.js → chunk-D7N5OLYL.js} +1 -1
  64. package/dist/lib/chunks/{chunk-E2YTTB6Q.js → chunk-DSK3PM4Z.js} +1 -1
  65. package/dist/lib/chunks/{chunk-TNL2GWYR.js → chunk-EUXNCXCR.js} +22 -0
  66. package/dist/lib/chunks/{chunk-FJL2V6P5.js → chunk-F4EQULFR.js} +6 -6
  67. package/dist/lib/chunks/{chunk-QGZ4QSUE.js → chunk-FHV4PBYG.js} +1 -1
  68. package/dist/lib/chunks/{chunk-K2FZFESR.js → chunk-FONFW67K.js} +4 -4
  69. package/dist/lib/chunks/{chunk-PIFTG6YW.js → chunk-FPPHYGIO.js} +2 -2
  70. package/dist/lib/chunks/{chunk-VXYQWE45.js → chunk-FYE4R5TY.js} +2 -2
  71. package/dist/lib/chunks/{chunk-JYCVBFH5.js → chunk-H2DOBJZC.js} +2 -2
  72. package/dist/lib/chunks/{chunk-XA27KAUV.js → chunk-HEWHNSDP.js} +68 -36
  73. package/dist/lib/chunks/{chunk-RXSHKWZJ.js → chunk-HLC6OHGO.js} +2 -2
  74. package/dist/lib/chunks/{chunk-6HMHXSCS.js → chunk-HXXFRZTJ.js} +2 -2
  75. package/dist/lib/chunks/{chunk-R5UPOEWE.js → chunk-HYMWNGOK.js} +10 -3
  76. package/dist/lib/chunks/chunk-IH67TEGY.js +73 -0
  77. package/dist/lib/chunks/{chunk-JKPBXPCW.js → chunk-IMADI2YP.js} +1 -1
  78. package/dist/lib/chunks/{chunk-AT3XMGES.js → chunk-JBGQFPTY.js} +4 -4
  79. package/dist/lib/chunks/{chunk-JQDQVG3D.js → chunk-JDU3ZCKO.js} +1 -1
  80. package/dist/lib/chunks/{chunk-2KH7LNK7.js → chunk-JGIX427K.js} +7 -7
  81. package/dist/lib/chunks/{chunk-7CW6U5WJ.js → chunk-JIE2ANVD.js} +1 -1
  82. package/dist/lib/chunks/{chunk-YEUCAPKP.js → chunk-JJFOILZK.js} +2 -2
  83. package/dist/lib/chunks/{chunk-F7DBTXKG.js → chunk-JMIK2QN3.js} +4 -3
  84. package/dist/lib/chunks/chunk-JW7DTYSI.js +116 -0
  85. package/dist/lib/chunks/{chunk-BFWK3TBN.js → chunk-JXLCKACO.js} +2 -2
  86. package/dist/lib/chunks/{chunk-7WO3FFPS.js → chunk-K5NQDJLE.js} +1 -1
  87. package/dist/lib/chunks/{chunk-BXF4OC74.js → chunk-KI2FB4Y3.js} +30 -16
  88. package/dist/lib/chunks/{chunk-Y2CZ6FZY.js → chunk-KRWDELRS.js} +30 -7
  89. package/dist/lib/chunks/{chunk-SIJOQRRK.js → chunk-KRXOJJR7.js} +1 -1
  90. package/dist/lib/chunks/chunk-KSUI4DAY.js +15 -0
  91. package/dist/lib/chunks/chunk-KXFZ3CH3.js +98 -0
  92. package/dist/lib/chunks/{chunk-XSER7WEB.js → chunk-LJCWZ5SZ.js} +14 -14
  93. package/dist/lib/chunks/{chunk-HGGRPOSA.js → chunk-LNYQMWJO.js} +3 -3
  94. package/dist/lib/chunks/{chunk-DL6YQDTE.js → chunk-LOIAGEKN.js} +2 -2
  95. package/dist/lib/chunks/{chunk-I3UE52ZV.js → chunk-LPOIMPJK.js} +2 -2
  96. package/dist/lib/chunks/{chunk-66T7JC57.js → chunk-LUKP64NX.js} +2 -2
  97. package/dist/lib/chunks/chunk-MNG5TZRW.js +208 -0
  98. package/dist/lib/chunks/{chunk-HGGOGCPX.js → chunk-MPQXB7HN.js} +7 -7
  99. package/dist/lib/chunks/{chunk-YGLWQFKL.js → chunk-MZ2KN3IH.js} +3 -3
  100. package/dist/lib/chunks/chunk-N62G4EWT.js +91 -0
  101. package/dist/lib/chunks/{chunk-7YDXD4MD.js → chunk-ODIXZHHX.js} +1 -1
  102. package/dist/lib/chunks/{chunk-GLUGYZQO.js → chunk-OTVHGRCO.js} +8 -8
  103. package/dist/lib/chunks/{chunk-RIJERFGU.js → chunk-OVF27NAO.js} +69 -17
  104. package/dist/lib/chunks/chunk-P6LHGBYU.js +90 -0
  105. package/dist/lib/chunks/{chunk-U5USH2HB.js → chunk-PAL5SXIP.js} +1 -1
  106. package/dist/lib/chunks/{chunk-W5XYW6ZM.js → chunk-PT6PK2MJ.js} +26 -19
  107. package/dist/lib/chunks/{chunk-OD36HUXA.js → chunk-Q22FCF4A.js} +6 -7
  108. package/dist/lib/chunks/chunk-QKTKQSPS.js +292 -0
  109. package/dist/lib/chunks/{chunk-K4Y5NT4M.js → chunk-QO5TPMWS.js} +2 -2
  110. package/dist/lib/chunks/{chunk-4GLW3ZRO.js → chunk-QUZYFAGP.js} +4 -4
  111. package/dist/lib/chunks/{chunk-T6XZQOXS.js → chunk-QVMPTT7R.js} +5 -5
  112. package/dist/lib/chunks/{chunk-OOLWU667.js → chunk-RGZY6YUQ.js} +5 -5
  113. package/dist/lib/chunks/{chunk-U6BW6LGX.js → chunk-RM2VVR7Y.js} +1 -1
  114. package/dist/lib/chunks/{chunk-AJO7XVXK.js → chunk-RMSH7RUG.js} +6 -6
  115. package/dist/lib/chunks/{chunk-V5B6UZ3E.js → chunk-RQGEPR6V.js} +1 -0
  116. package/dist/lib/chunks/{chunk-V5JJEEBT.js → chunk-RYB77E7O.js} +6 -5
  117. package/dist/lib/chunks/chunk-S24JGY7B.js +97 -0
  118. package/dist/lib/chunks/{chunk-6GKKALCI.js → chunk-SF4UJ2AY.js} +1 -1
  119. package/dist/lib/chunks/chunk-SJCUR4QX.js +94 -0
  120. package/dist/lib/chunks/{chunk-XAN4CRFP.js → chunk-SQ55KGHO.js} +1 -1
  121. package/dist/lib/chunks/{chunk-ZOGIJGU3.js → chunk-TKOQMB6A.js} +7 -7
  122. package/dist/lib/chunks/{chunk-UYDQXXDQ.js → chunk-TWK6IA4P.js} +1 -1
  123. package/dist/lib/chunks/{chunk-DVFFYY5G.js → chunk-U42I3SBR.js} +13 -9
  124. package/dist/lib/chunks/{chunk-PIF3GL62.js → chunk-UECQONVZ.js} +5 -5
  125. package/dist/lib/chunks/{chunk-FDM2YNQL.js → chunk-VTY53IFN.js} +1 -1
  126. package/dist/lib/chunks/chunk-VYUC772A.js +338 -0
  127. package/dist/lib/chunks/{chunk-WCLKIPJV.js → chunk-WPCBE2NZ.js} +1 -1
  128. package/dist/lib/chunks/{chunk-3OE4UQIB.js → chunk-WRHGLRUK.js} +5 -5
  129. package/dist/lib/chunks/{chunk-J7QKT5E7.js → chunk-WUIY7BXR.js} +34 -17
  130. package/dist/lib/chunks/{chunk-7YYDUHJG.js → chunk-WZA4H4TG.js} +39 -13
  131. package/dist/lib/chunks/{chunk-NH4QGBJV.js → chunk-XBSA7MNJ.js} +7 -2
  132. package/dist/lib/chunks/chunk-XTBCXEH7.js +243 -0
  133. package/dist/lib/chunks/{chunk-ZQ3ER7JD.js → chunk-YPVJAXPP.js} +1 -1
  134. package/dist/lib/chunks/{chunk-SASE7U6E.js → chunk-YQD5ITKI.js} +1 -1
  135. package/dist/lib/chunks/{chunk-LTCDLURT.js → chunk-YY4BH5XM.js} +6 -6
  136. package/dist/lib/chunks/{chunk-J5NPHPXY.js → chunk-Z3BZRBQF.js} +36 -2
  137. package/dist/lib/chunks/{chunk-XFUYEFQP.js → chunk-ZBQU2VU3.js} +1 -1
  138. package/dist/lib/chunks/{chunk-7YZPEX3T.js → chunk-ZHGABG7L.js} +2 -2
  139. package/dist/lib/chunks/chunk-ZZCRYG36.js +31 -0
  140. package/dist/lib/cli/bundle-commands.js +89 -73
  141. package/dist/lib/cli/run-commands.js +136 -92
  142. package/dist/lib/cli/status-command.js +75 -59
  143. package/dist/lib/codex-workflow/aggregate.js +20 -12
  144. package/dist/lib/codex-workflow/author-tools.js +7 -7
  145. package/dist/lib/codex-workflow/author.js +23 -22
  146. package/dist/lib/codex-workflow/capture.js +38 -17
  147. package/dist/lib/codex-workflow/checkpoint.js +7 -7
  148. package/dist/lib/codex-workflow/checks.js +9 -9
  149. package/dist/lib/codex-workflow/copy-editor.js +19 -18
  150. package/dist/lib/codex-workflow/copy-recovery.js +4 -4
  151. package/dist/lib/codex-workflow/copy.js +16 -15
  152. package/dist/lib/codex-workflow/finish.js +28 -24
  153. package/dist/lib/codex-workflow/host-models.js +2 -2
  154. package/dist/lib/codex-workflow/loop.js +51 -46
  155. package/dist/lib/codex-workflow/quality.js +4 -4
  156. package/dist/lib/codex-workflow/run-inputs.js +6 -6
  157. package/dist/lib/codex-workflow/run-source.js +16 -16
  158. package/dist/lib/codex-workflow/schemas.js +6 -6
  159. package/dist/lib/codex-workflow/session.js +8 -8
  160. package/dist/lib/codex-workflow/stage.js +30 -28
  161. package/dist/lib/codex-workflow/workdir.js +18 -11
  162. package/dist/lib/engine/audit-file.js +7 -7
  163. package/dist/lib/engine/author.js +38 -36
  164. package/dist/lib/engine/cost-estimate.js +37 -9
  165. package/dist/lib/engine/local-run.js +74 -58
  166. package/dist/lib/engine/preflight.js +37 -9
  167. package/dist/lib/engine/rejudge.js +80 -64
  168. package/dist/lib/engine/run-bindings.js +62 -0
  169. package/dist/lib/engine/run-status.js +75 -59
  170. package/dist/lib/engine/templates.js +8 -8
  171. package/dist/lib/grounding/controller.js +8 -7
  172. package/dist/lib/grounding/extract.js +8 -6
  173. package/dist/lib/grounding/grounding-runtime.js +22 -21
  174. package/dist/lib/grounding/model-usage.js +2 -2
  175. package/dist/lib/grounding/model.js +7 -5
  176. package/dist/lib/grounding/recorded-tools.js +9 -9
  177. package/dist/lib/harness/report/artifacts.js +5 -5
  178. package/dist/lib/lib/checkpoint.js +5 -5
  179. package/dist/lib/lib/log.js +1 -1
  180. package/dist/lib/models/accounting.js +1 -1
  181. package/dist/lib/models/batching.js +6 -4
  182. package/dist/lib/models/budget-protection.js +1 -1
  183. package/dist/lib/models/cost-coefficients.js +2 -1
  184. package/dist/lib/models/gateway-cost.js +7 -0
  185. package/dist/lib/models/structured.js +5 -3
  186. package/dist/lib/models/supported-models.js +1 -1
  187. package/dist/lib/pipeline.js +36 -17
  188. package/dist/lib/probes/adapter.js +6 -0
  189. package/dist/lib/probes/adapters/cli-agents.js +44 -0
  190. package/dist/lib/probes/adapters/cli-claude-code.js +21 -0
  191. package/dist/lib/probes/adapters/cli-codex.js +23 -0
  192. package/dist/lib/probes/adapters/cli-cursor.js +21 -0
  193. package/dist/lib/probes/adapters/cli-process.js +34 -0
  194. package/dist/lib/probes/adapters/dataforseo-ai-overview.js +20 -0
  195. package/dist/lib/probes/adapters/gateway-chat.js +30 -0
  196. package/dist/lib/probes/adapters/gateway-perplexity.js +19 -0
  197. package/dist/lib/probes/agent-cli-parsers.js +2 -2
  198. package/dist/lib/probes/agent-clis.js +26 -11
  199. package/dist/lib/probes/answer-text.js +21 -0
  200. package/dist/lib/probes/attempt.js +28 -0
  201. package/dist/lib/probes/bindings.js +69 -0
  202. package/dist/lib/probes/charged-trace.js +47 -3
  203. package/dist/lib/probes/dataforseo-locale.js +1 -1
  204. package/dist/lib/probes/dataforseo.js +8 -5
  205. package/dist/lib/probes/grounding-urls.js +6 -4
  206. package/dist/lib/probes/legacy-bindings.js +7 -0
  207. package/dist/lib/probes/limits.js +1 -1
  208. package/dist/lib/probes/probes.js +33 -12
  209. package/dist/lib/runner.js +17 -14
  210. package/dist/lib/schema.js +4 -4
  211. package/dist/lib/section-result.js +6 -6
  212. package/dist/lib/stores/artifacts.js +7 -7
  213. package/dist/lib/stores/files.js +19 -17
  214. package/dist/lib/stores/local-versions.js +5 -5
  215. package/dist/lib/stores/memory.js +19 -14
  216. package/dist/lib/stores/publication.js +10 -10
  217. package/dist/lib/stores/unit-record.js +28 -0
  218. package/dist/lib/viewer/server.js +32 -24
  219. package/dist/lib/workflow/schema.js +3 -3
  220. package/dist/types/bundle/contracts.d.ts +1 -1
  221. package/dist/types/capture-manifest.d.ts +1 -0
  222. package/dist/types/codex-workflow/capture.d.ts +13 -0
  223. package/dist/types/codex-workflow/workdir.d.ts +0 -1
  224. package/dist/types/engine/cost-estimate.d.ts +5 -1
  225. package/dist/types/engine/preflight.d.ts +6 -1
  226. package/dist/types/engine/run-bindings.d.ts +25 -0
  227. package/dist/types/models/accounting.d.ts +7 -0
  228. package/dist/types/models/cost-coefficients.d.ts +5 -5
  229. package/dist/types/models/gateway-cost.d.ts +3 -0
  230. package/dist/types/pipeline.d.ts +2 -0
  231. package/dist/types/probes/adapter.d.ts +112 -0
  232. package/dist/types/probes/adapters/cli-agents.d.ts +19 -0
  233. package/dist/types/probes/adapters/cli-claude-code.d.ts +4 -0
  234. package/dist/types/probes/adapters/cli-codex.d.ts +10 -0
  235. package/dist/types/probes/adapters/cli-cursor.d.ts +4 -0
  236. package/dist/types/probes/adapters/cli-process.d.ts +86 -0
  237. package/dist/types/probes/adapters/dataforseo-ai-overview.d.ts +12 -0
  238. package/dist/types/probes/adapters/gateway-chat.d.ts +32 -0
  239. package/dist/types/probes/adapters/gateway-perplexity.d.ts +10 -0
  240. package/dist/types/probes/agent-clis.d.ts +7 -49
  241. package/dist/types/probes/answer-text.d.ts +20 -0
  242. package/dist/types/probes/attempt.d.ts +113 -0
  243. package/dist/types/probes/bindings.d.ts +79 -0
  244. package/dist/types/probes/charged-trace.d.ts +2 -1
  245. package/dist/types/probes/dataforseo.d.ts +24 -1
  246. package/dist/types/probes/grounding-urls.d.ts +18 -5
  247. package/dist/types/probes/legacy-bindings.d.ts +36 -0
  248. package/dist/types/probes/limits.d.ts +12 -6
  249. package/dist/types/probes/probe-trace.d.ts +10 -0
  250. package/dist/types/probes/probes.d.ts +5 -3
  251. package/dist/types/stores/ports.d.ts +1 -0
  252. package/dist/types/stores/unit-record.d.ts +11 -0
  253. package/package.json +6 -6
  254. package/src/analysis/progress.ts +10 -1
  255. package/src/bundle/contracts.ts +1 -1
  256. package/src/bundle/recorder.ts +47 -1
  257. package/src/capture-manifest.ts +6 -0
  258. package/src/cli/run-commands.ts +37 -1
  259. package/src/codex-workflow/capture.ts +60 -0
  260. package/src/codex-workflow/workdir.ts +3 -4
  261. package/src/engine/cost-estimate.ts +10 -4
  262. package/src/engine/local-run.ts +21 -2
  263. package/src/engine/preflight.ts +113 -17
  264. package/src/engine/rejudge.ts +5 -0
  265. package/src/engine/run-bindings.ts +142 -0
  266. package/src/grounding/extract.ts +1 -0
  267. package/src/grounding/model-usage.ts +4 -0
  268. package/src/lib/log.ts +17 -15
  269. package/src/models/accounting.ts +34 -0
  270. package/src/models/budget-protection.ts +1 -0
  271. package/src/models/cost-coefficients.ts +17 -13
  272. package/src/models/gateway-cost.ts +32 -0
  273. package/src/models/structured.ts +2 -10
  274. package/src/models/supported-models.ts +2 -2
  275. package/src/pipeline.ts +36 -17
  276. package/src/probes/adapter.ts +122 -0
  277. package/src/probes/adapters/cli-agents.ts +123 -0
  278. package/src/probes/adapters/cli-claude-code.ts +119 -0
  279. package/src/probes/adapters/cli-codex.ts +145 -0
  280. package/src/probes/adapters/cli-cursor.ts +95 -0
  281. package/src/probes/adapters/cli-process.ts +522 -0
  282. package/src/probes/adapters/dataforseo-ai-overview.ts +106 -0
  283. package/src/probes/adapters/gateway-chat.ts +339 -0
  284. package/src/probes/adapters/gateway-perplexity.ts +104 -0
  285. package/src/probes/agent-clis.ts +151 -1088
  286. package/src/probes/answer-text.ts +153 -0
  287. package/src/probes/attempt.ts +462 -0
  288. package/src/probes/bindings.ts +344 -0
  289. package/src/probes/charged-trace.ts +54 -13
  290. package/src/probes/dataforseo-locale.ts +13 -2
  291. package/src/probes/dataforseo.ts +265 -188
  292. package/src/probes/grounding-urls.ts +68 -19
  293. package/src/probes/legacy-bindings.ts +40 -0
  294. package/src/probes/limits.ts +31 -18
  295. package/src/probes/probe-trace.ts +10 -0
  296. package/src/probes/probes.ts +64 -736
  297. package/src/runner.ts +13 -0
  298. package/src/stores/files.ts +78 -54
  299. package/src/stores/memory.ts +4 -1
  300. package/src/stores/ports.ts +3 -0
  301. package/src/stores/unit-record.ts +151 -0
  302. package/dist/lib/chunks/chunk-BGAHZIL3.js +0 -563
  303. package/dist/lib/chunks/chunk-IB6RROHE.js +0 -204
  304. package/dist/lib/chunks/chunk-WZGI7UVM.js +0 -937
@@ -1,563 +0,0 @@
1
- import {
2
- extractAnthropicRetrieval,
3
- extractGeminiRetrieval,
4
- extractOpenAiRetrieval,
5
- retrievalResultUrls,
6
- rewriteRetrievalUrls
7
- } from "./chunk-S2SFHTJD.js";
8
- import {
9
- getGoogleAIOverview
10
- } from "./chunk-IB6RROHE.js";
11
- import {
12
- ProbeTraceError,
13
- endAttempt,
14
- startAttempt
15
- } from "./chunk-GVOF5ZUG.js";
16
- import {
17
- ProbeFailure,
18
- classifyGatewayError,
19
- errorMessage,
20
- retryDelayMs
21
- } from "./chunk-7O3M6I2X.js";
22
- import {
23
- extractGroundingRedirectUrls,
24
- resolveGroundingRedirects,
25
- rewriteTextUrls
26
- } from "./chunk-7YYDUHJG.js";
27
- import {
28
- isGroundingRedirectUrl
29
- } from "./chunk-UGCT46PC.js";
30
- import {
31
- servedModelOf
32
- } from "./chunk-ZVAKKRRD.js";
33
- import {
34
- createLog
35
- } from "./chunk-ZSEY7AHQ.js";
36
- import {
37
- isObject
38
- } from "./chunk-7PLK6VGC.js";
39
- import {
40
- chatRunsPerPrompt
41
- } from "./chunk-DL6YQDTE.js";
42
- import {
43
- sleep,
44
- unlimited
45
- } from "./chunk-W5XYW6ZM.js";
46
- import {
47
- surfaceRetrievalExposure
48
- } from "./chunk-HXHFMFQU.js";
49
- import {
50
- chatSurfaces
51
- } from "./chunk-AASWJR7Q.js";
52
-
53
- // src/probes/probes.ts
54
- import { streamText } from "ai";
55
- import { gateway } from "@ai-sdk/gateway";
56
- import { openai } from "@ai-sdk/openai";
57
- import { google } from "@ai-sdk/google";
58
- import { anthropic } from "@ai-sdk/anthropic";
59
- var log = createLog("AISearchProbes");
60
- var probeMaxOutputTokens = 2e3;
61
- var chatProbeTimeoutMs = 18e4;
62
- var aiSearchProbeModels = {
63
- chatgpt: "openai/gpt-5.4-mini",
64
- gemini: "google/gemini-3-flash",
65
- claude: "anthropic/claude-sonnet-4.5",
66
- perplexity: "perplexity/sonar-pro"
67
- };
68
- var chatProbeRequestedModel = (surface) => {
69
- return surface === "google_ai_overview" ? null : aiSearchProbeModels[surface];
70
- };
71
- var gatewayCostOf = (metadata) => {
72
- const cost = isObject(metadata) && isObject(metadata.gateway) ? metadata.gateway.cost : void 0;
73
- const usd = typeof cost === "string" && cost.trim() ? Number(cost) : cost;
74
- return typeof usd === "number" && Number.isFinite(usd) && usd >= 0 ? usd : void 0;
75
- };
76
- var reportedCostOf = (costs) => {
77
- if (costs.some((cost) => cost === void 0)) {
78
- return {};
79
- }
80
- return {
81
- reportedCostUsd: costs.reduce((sum, cost) => sum + (cost ?? 0), 0)
82
- };
83
- };
84
- var searchPromptPrefix = "Search the web for current information to answer the following question. Return a complete answer, not just search results.\n\n";
85
- var formatProbeSources = (sources) => {
86
- const rows = [];
87
- for (const source of sources) {
88
- if (!source || typeof source !== "object" || !("sourceType" in source) || source.sourceType !== "url" || !("url" in source) || typeof source.url !== "string") {
89
- continue;
90
- }
91
- const title = "title" in source && typeof source.title === "string" ? source.title : source.url;
92
- rows.push(`- ${title}: ${source.url}`);
93
- }
94
- return rows.length > 0 ? `Sources used by search:
95
- ${rows.join("\n")}` : "";
96
- };
97
- var withProbeSources = (text, sources) => {
98
- const sourceList = formatProbeSources(sources);
99
- if (!sourceList) {
100
- return text;
101
- }
102
- return `${text.trim()}
103
-
104
- ${sourceList}`;
105
- };
106
- var toProviderToolSet = (tools) => {
107
- return tools;
108
- };
109
- var runSearchRequiredProbe = async (args) => {
110
- const prompt = `${searchPromptPrefix}${args.promptText}`;
111
- let streamFailure;
112
- const streamed = streamText({
113
- onError: ({ error }) => {
114
- streamFailure ??= error;
115
- },
116
- model: gateway(args.modelId),
117
- prompt,
118
- maxOutputTokens: probeMaxOutputTokens,
119
- tools: toProviderToolSet(args.tools),
120
- toolChoice: "required",
121
- maxRetries: 0,
122
- abortSignal: AbortSignal.timeout(chatProbeTimeoutMs)
123
- });
124
- const [
125
- steps,
126
- text,
127
- sources,
128
- finishReason,
129
- toolCalls,
130
- response,
131
- providerMetadata
132
- ] = await Promise.all([
133
- streamed.steps,
134
- streamed.text,
135
- streamed.sources,
136
- streamed.finishReason,
137
- streamed.toolCalls,
138
- streamed.response,
139
- streamed.providerMetadata
140
- ]).catch((error) => {
141
- throw streamFailure ?? error;
142
- });
143
- const first = {
144
- steps,
145
- text,
146
- sources,
147
- finishReason,
148
- toolCalls,
149
- response,
150
- providerMetadata
151
- };
152
- let retrieval = args.extractRetrieval(first);
153
- const reportedModel = servedModelOf(args.modelId, first.response.modelId);
154
- const served = reportedModel === void 0 ? {} : { reportedModel };
155
- if (retrieval.calls.length === 0) {
156
- log.warn("Search-required probe yielded no retrieval calls; not stored", {
157
- model: args.modelName,
158
- stepCount: first.steps.length,
159
- partTypes: [
160
- ...new Set(
161
- first.steps.flatMap((step) => step.content.map((p) => p.type))
162
- )
163
- ]
164
- });
165
- retrieval = null;
166
- }
167
- const firstCost = gatewayCostOf(first.providerMetadata);
168
- if (first.text.trim().length > 0) {
169
- return {
170
- text: withProbeSources(first.text, first.sources),
171
- retrieval,
172
- ...served,
173
- ...reportedCostOf([firstCost])
174
- };
175
- }
176
- log.warn("Search probe returned no answer text; synthesizing from search", {
177
- model: args.modelName,
178
- finishReason: first.finishReason,
179
- toolCallCount: first.toolCalls.length,
180
- sourceCount: first.sources.length
181
- });
182
- let followupFailure;
183
- const followupStream = streamText({
184
- onError: ({ error }) => {
185
- followupFailure ??= error;
186
- },
187
- model: gateway(args.modelId),
188
- messages: [
189
- { role: "user", content: prompt },
190
- ...first.response.messages,
191
- {
192
- role: "user",
193
- content: "Using the web search results from the previous turn, answer the original question in a complete, readable response. Do not perform another search. If the search results were insufficient, say what was missing."
194
- }
195
- ],
196
- maxOutputTokens: probeMaxOutputTokens,
197
- tools: toProviderToolSet(args.tools),
198
- toolChoice: "none",
199
- maxRetries: 0,
200
- abortSignal: AbortSignal.timeout(chatProbeTimeoutMs)
201
- });
202
- const [followupText, followupSources, followupMetadata] = await Promise.all([
203
- followupStream.text,
204
- followupStream.sources,
205
- followupStream.providerMetadata
206
- ]).catch((error) => {
207
- throw followupFailure ?? error;
208
- });
209
- const followup = { text: followupText, sources: followupSources };
210
- if (followup.text.trim().length > 0) {
211
- return {
212
- text: withProbeSources(
213
- followup.text,
214
- first.sources.length > 0 ? first.sources : followup.sources
215
- ),
216
- retrieval,
217
- ...served,
218
- ...reportedCostOf([firstCost, gatewayCostOf(followupMetadata)])
219
- };
220
- }
221
- throw new ProbeFailure(
222
- "empty_answer",
223
- `${args.modelName} completed a required web search but returned no answer text (tool calls: ${first.toolCalls.length}, sources: ${first.sources.length})`
224
- );
225
- };
226
- var unexposedRetrieval = (surface) => {
227
- return { exposure: surfaceRetrievalExposure[surface], calls: [] };
228
- };
229
- var buildProbeModels = (args) => {
230
- const runsOn = (surface) => {
231
- return chatRunsPerPrompt(surface, args.chatProbes);
232
- };
233
- const all = [
234
- {
235
- name: "chatgpt",
236
- runs: runsOn("chatgpt"),
237
- provider: "gateway",
238
- probe: async (promptText) => {
239
- return runSearchRequiredProbe({
240
- modelName: "chatgpt",
241
- modelId: aiSearchProbeModels.chatgpt,
242
- promptText,
243
- tools: { web_search: openai.tools.webSearch({}) },
244
- extractRetrieval: (result) => extractOpenAiRetrieval(result.steps)
245
- });
246
- }
247
- },
248
- {
249
- name: "gemini",
250
- runs: runsOn("gemini"),
251
- provider: "gateway",
252
- probe: async (promptText) => {
253
- return runSearchRequiredProbe({
254
- modelName: "gemini",
255
- modelId: aiSearchProbeModels.gemini,
256
- promptText,
257
- tools: { google_search: google.tools.googleSearch({}) },
258
- extractRetrieval: (result) => extractGeminiRetrieval(result.providerMetadata)
259
- });
260
- }
261
- },
262
- {
263
- name: "claude",
264
- runs: runsOn("claude"),
265
- provider: "gateway",
266
- probe: async (promptText) => {
267
- return runSearchRequiredProbe({
268
- modelName: "claude",
269
- modelId: aiSearchProbeModels.claude,
270
- promptText,
271
- tools: {
272
- web_search: anthropic.tools.webSearch_20250305({ maxUses: 5 })
273
- },
274
- extractRetrieval: (result) => extractAnthropicRetrieval(result.steps)
275
- });
276
- }
277
- },
278
- {
279
- name: "perplexity",
280
- runs: runsOn("perplexity"),
281
- provider: "gateway",
282
- probe: async (promptText) => {
283
- let streamFailure;
284
- const stream = streamText({
285
- onError: ({ error }) => {
286
- streamFailure ??= error;
287
- },
288
- model: gateway(aiSearchProbeModels.perplexity),
289
- prompt: `${searchPromptPrefix}${promptText}`,
290
- maxOutputTokens: probeMaxOutputTokens,
291
- maxRetries: 0,
292
- abortSignal: AbortSignal.timeout(chatProbeTimeoutMs)
293
- });
294
- const result = await Promise.all([
295
- stream.text,
296
- stream.sources,
297
- stream.response,
298
- stream.providerMetadata
299
- ]).then(([text, sources, response, providerMetadata]) => ({
300
- text,
301
- sources,
302
- response,
303
- providerMetadata
304
- })).catch((error) => {
305
- throw streamFailure ?? error;
306
- });
307
- if (result.text.trim().length === 0) {
308
- throw new ProbeFailure(
309
- "empty_answer",
310
- "perplexity returned no answer text"
311
- );
312
- }
313
- const reportedModel = servedModelOf(
314
- aiSearchProbeModels.perplexity,
315
- result.response.modelId
316
- );
317
- return {
318
- text: withProbeSources(result.text, result.sources),
319
- retrieval: unexposedRetrieval("perplexity"),
320
- ...reportedModel === void 0 ? {} : { reportedModel },
321
- ...reportedCostOf([gatewayCostOf(result.providerMetadata)])
322
- };
323
- }
324
- },
325
- {
326
- name: "google_ai_overview",
327
- runs: runsOn("google_ai_overview"),
328
- provider: "dataforseo",
329
- probe: async (promptText) => {
330
- const retrieval = unexposedRetrieval("google_ai_overview");
331
- const result = await getGoogleAIOverview(
332
- promptText,
333
- args.geography,
334
- args.language
335
- );
336
- if (result.status === "no_overview") {
337
- return { text: "", retrieval, noOverview: true };
338
- }
339
- let text = result.markdown;
340
- if (result.references.length > 0) {
341
- text += "\n\nSources cited in AI Overview:\n";
342
- text += result.references.map((r) => {
343
- const domainLabel = isGroundingRedirectUrl(r.url) ? "" : ` (${r.domain})`;
344
- return `- ${r.source}${domainLabel}: "${r.title}" \u2014 ${r.url}`;
345
- }).join("\n");
346
- }
347
- if (text.trim().length === 0) {
348
- throw new ProbeFailure(
349
- "empty_answer",
350
- "google_ai_overview returned an AI Overview with no text"
351
- );
352
- }
353
- return { text, retrieval };
354
- }
355
- }
356
- ];
357
- return all.filter((m) => args.surfaces.includes(m.name));
358
- };
359
- var finalizeAnswer = async (answer, logContext) => {
360
- const text = answer.text.replaceAll("\0", "");
361
- const resolved = await resolveGroundingRedirects(
362
- [
363
- ...extractGroundingRedirectUrls(text),
364
- ...answer.retrieval ? retrievalResultUrls(answer.retrieval) : []
365
- ],
366
- logContext
367
- );
368
- return {
369
- ...answer,
370
- text: rewriteTextUrls(text, resolved),
371
- retrieval: answer.retrieval ? rewriteRetrievalUrls(answer.retrieval, resolved) : null
372
- };
373
- };
374
- var runProbesForPrompts = async (job, opts = {}) => {
375
- const probeModels = buildProbeModels({
376
- geography: job.geography,
377
- language: job.language,
378
- surfaces: job.surfaces ?? chatSurfaces,
379
- chatProbes: job.chatProbes
380
- });
381
- const limiter = job.limiter ?? unlimited();
382
- const tasks = [];
383
- for (const prompt of job.prompts) {
384
- for (const model of probeModels) {
385
- for (let run = 1; run <= model.runs; run++) {
386
- const unit = {
387
- promptId: prompt.id,
388
- surface: model.name,
389
- runIndex: run
390
- };
391
- if (job.filter && !job.filter({
392
- promptId: prompt.id,
393
- surface: model.name,
394
- runIndex: run
395
- })) {
396
- continue;
397
- }
398
- tasks.push(
399
- runChatUnit(unit, {
400
- prompt,
401
- model,
402
- limiter,
403
- job,
404
- logContext: opts.logContext
405
- })
406
- );
407
- }
408
- }
409
- }
410
- const outcomes = await Promise.all(tasks);
411
- const captured = outcomes.filter((o) => o.status === "captured").length;
412
- log.info("Probes completed", {
413
- ...opts.logContext,
414
- planned: outcomes.length,
415
- captured,
416
- failed: outcomes.length - captured
417
- });
418
- return outcomes;
419
- };
420
- var runChatUnit = async (unit, { prompt, model, limiter, job, logContext }) => {
421
- const context = {
422
- ...logContext,
423
- model: model.name,
424
- promptId: prompt.id,
425
- run: unit.runIndex
426
- };
427
- let attempt = 0;
428
- let answer = null;
429
- let lastKind = "cli_error";
430
- let lastError = "";
431
- let traced;
432
- for (; ; ) {
433
- if (job.signal?.aborted) {
434
- return {
435
- status: "failed",
436
- unit,
437
- kind: "timeout",
438
- attempts: attempt,
439
- lastError: "run aborted before the unit executed"
440
- };
441
- }
442
- attempt += 1;
443
- const startedAt = Date.now();
444
- const retryOf = traced?.id;
445
- traced = void 0;
446
- try {
447
- const raw = await limiter.run(model.provider, async () => {
448
- traced = await startAttempt(job.trace, {
449
- surface: model.name,
450
- promptId: prompt.id,
451
- promptText: prompt.promptText,
452
- runIndex: unit.runIndex,
453
- attempt,
454
- ...retryOf === void 0 ? {} : { retryOf },
455
- requestedModel: chatProbeRequestedModel(model.name)
456
- });
457
- return model.probe(prompt.promptText);
458
- });
459
- answer = await finalizeAnswer(raw, logContext);
460
- log.debug("Probe completed", {
461
- ...context,
462
- attempt,
463
- durationMs: Date.now() - startedAt,
464
- chars: answer.text.length,
465
- ...answer.noOverview ? { noOverview: true } : {}
466
- });
467
- break;
468
- } catch (error) {
469
- if (error instanceof ProbeTraceError) {
470
- return {
471
- status: "failed",
472
- unit,
473
- kind: "persistence",
474
- attempts: attempt,
475
- lastError: error.message
476
- };
477
- }
478
- lastKind = classifyGatewayError(error);
479
- lastError = errorMessage(error);
480
- const unrecorded2 = await endAttempt(traced, {
481
- outcome: job.signal?.aborted ? "cancelled" : "failed",
482
- kind: lastKind,
483
- error: lastError
484
- });
485
- if (unrecorded2 !== null) {
486
- return {
487
- status: "failed",
488
- unit,
489
- kind: "persistence",
490
- attempts: attempt,
491
- lastError: unrecorded2
492
- };
493
- }
494
- const delayMs = retryDelayMs(lastKind, attempt);
495
- log.warn(delayMs === null ? "Probe failed" : "Probe failed; retrying", {
496
- ...context,
497
- attempt,
498
- kind: lastKind,
499
- durationMs: Date.now() - startedAt,
500
- ...delayMs === null ? {} : { retryInMs: delayMs },
501
- error: lastError
502
- });
503
- if (delayMs === null) {
504
- return {
505
- status: "failed",
506
- unit,
507
- kind: lastKind,
508
- attempts: attempt,
509
- lastError
510
- };
511
- }
512
- await sleep(delayMs, job.signal);
513
- }
514
- }
515
- const unrecorded = await endAttempt(traced, {
516
- outcome: "succeeded",
517
- text: answer.text,
518
- retrieval: answer.retrieval,
519
- requestedModel: chatProbeRequestedModel(model.name),
520
- ...answer.reportedModel ? { reportedModel: answer.reportedModel } : {},
521
- ...answer.noOverview ? { noOverview: true } : {},
522
- ...answer.reportedCostUsd === void 0 ? {} : { costUsd: answer.reportedCostUsd }
523
- });
524
- if (unrecorded !== null) {
525
- return {
526
- status: "failed",
527
- unit,
528
- kind: "persistence",
529
- attempts: attempt,
530
- lastError: unrecorded
531
- };
532
- }
533
- const probe = {
534
- promptId: prompt.id,
535
- promptText: prompt.promptText,
536
- promptCategory: prompt.category,
537
- modelName: model.name,
538
- runIndex: unit.runIndex,
539
- text: answer.text,
540
- ...answer.retrieval ? { retrieval: answer.retrieval } : {},
541
- ...answer.noOverview ? { noOverview: true } : {},
542
- ...answer.reportedModel ? { reportedModel: answer.reportedModel } : {}
543
- };
544
- try {
545
- await job.onResult?.(probe);
546
- } catch (error) {
547
- const message = errorMessage(error);
548
- log.error("Probe captured but could not be persisted", error, context);
549
- return {
550
- status: "failed",
551
- unit,
552
- kind: "persistence",
553
- attempts: attempt,
554
- lastError: message
555
- };
556
- }
557
- return { status: "captured", unit, probe, attempts: attempt };
558
- };
559
-
560
- export {
561
- aiSearchProbeModels,
562
- runProbesForPrompts
563
- };