literally-aeo 0.1.1 → 0.2.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 (262) hide show
  1. package/README.md +42 -6
  2. package/dist/author-tools.js +33 -64
  3. package/dist/cli.mjs +2723 -1616
  4. package/dist/lib/agents/author-schema.js +4 -5
  5. package/dist/lib/agents/author-validation.js +5 -6
  6. package/dist/lib/agents/copy-validation.js +4 -5
  7. package/dist/lib/agents/verifier.js +8 -8
  8. package/dist/lib/analysis/domain-classifier.js +8 -8
  9. package/dist/lib/analysis/domain-labels.js +3 -4
  10. package/dist/lib/analysis/progress.js +3 -4
  11. package/dist/lib/analysis/sentiment.js +8 -8
  12. package/dist/lib/author/examples.js +5 -6
  13. package/dist/lib/bundle/contracts.js +5 -6
  14. package/dist/lib/bundle/export.js +22 -19
  15. package/dist/lib/bundle/isolation.js +17 -0
  16. package/dist/lib/bundle/journal.js +6 -7
  17. package/dist/lib/bundle/project-journal.js +11 -10
  18. package/dist/lib/bundle/project.js +19 -16
  19. package/dist/lib/bundle/read.js +23 -20
  20. package/dist/lib/bundle/recorder.js +9 -8
  21. package/dist/lib/bundle/redact.js +6 -7
  22. package/dist/lib/bundle/trace-coverage.js +6 -7
  23. package/dist/lib/bundle/verify-integrity.js +8 -9
  24. package/dist/lib/bundle/verify-measurement.js +10 -11
  25. package/dist/lib/bundle/verify-report.js +11 -12
  26. package/dist/lib/bundle/verify.js +17 -18
  27. package/dist/lib/bundle/writer-lock.js +3 -1
  28. package/dist/lib/capture-manifest.js +3 -4
  29. package/dist/lib/checks/run-checks.js +10 -9
  30. package/dist/lib/chunks/chunk-2B5QF6UQ.js +159 -0
  31. package/dist/lib/chunks/{chunk-ZBDUE3A5.js → chunk-2GU6CNQI.js} +12 -7
  32. package/dist/lib/chunks/{chunk-CKUTDJAB.js → chunk-2ROXN2EC.js} +42 -7
  33. package/dist/lib/chunks/{chunk-XHWRSGX3.js → chunk-3JO5TXBA.js} +1 -1
  34. package/dist/lib/chunks/{chunk-XL4JIQ5X.js → chunk-4PD65FRJ.js} +7 -3
  35. package/dist/lib/chunks/{chunk-GMKF2FU4.js → chunk-5JPYM4MD.js} +1 -1
  36. package/dist/lib/chunks/{chunk-5VNYUCLL.js → chunk-622NMXN6.js} +6 -9
  37. package/dist/lib/chunks/{chunk-XNRSHATN.js → chunk-663HABKP.js} +5 -5
  38. package/dist/lib/chunks/{chunk-RMFT4KKK.js → chunk-6G25V4CF.js} +1 -1
  39. package/dist/lib/chunks/{chunk-GVC4LH2N.js → chunk-6GHHNPFJ.js} +1 -1
  40. package/dist/lib/chunks/{chunk-KMRQSIZW.js → chunk-6GOBBNDU.js} +16 -1
  41. package/dist/lib/chunks/{chunk-SBAZBOPI.js → chunk-6P7EZJI7.js} +4 -2
  42. package/dist/lib/chunks/chunk-7XO3SQAX.js +117 -0
  43. package/dist/lib/chunks/{chunk-SWS3K62X.js → chunk-7Z27HQWL.js} +3 -3
  44. package/dist/lib/chunks/{chunk-IPNK7FYT.js → chunk-AYY4MYTW.js} +1 -1
  45. package/dist/lib/chunks/{chunk-WDSCJEDG.js → chunk-BE4ENGUY.js} +10 -10
  46. package/dist/lib/chunks/{chunk-FKLNEB2P.js → chunk-BGOIPHJZ.js} +39 -11
  47. package/dist/lib/chunks/{chunk-7GXRDAUY.js → chunk-BLKLPUYR.js} +2 -2
  48. package/dist/lib/chunks/chunk-BSRKN6FU.js +93 -0
  49. package/dist/lib/chunks/{chunk-PCYNBDZ7.js → chunk-CO5T6WU5.js} +14 -9
  50. package/dist/lib/chunks/{chunk-E3OEE5XN.js → chunk-CUYVHXHI.js} +2 -2
  51. package/dist/lib/chunks/{chunk-2GY42RIJ.js → chunk-D3GE3OCB.js} +1 -1
  52. package/dist/lib/chunks/chunk-DVFFYY5G.js +74 -0
  53. package/dist/lib/chunks/{chunk-ZXGATMMH.js → chunk-EBUQPCKB.js} +1 -1
  54. package/dist/lib/chunks/{chunk-4E4NDGOZ.js → chunk-EE26FNSY.js} +1 -1
  55. package/dist/lib/chunks/{chunk-AUB5THIS.js → chunk-EJ655TVU.js} +1 -1
  56. package/dist/lib/chunks/{chunk-S2AM76LT.js → chunk-F4W5YHDZ.js} +2 -2
  57. package/dist/lib/chunks/chunk-FAUFE7MI.js +31 -0
  58. package/dist/lib/chunks/{chunk-FNDJUELJ.js → chunk-FOCJ7HPC.js} +7 -7
  59. package/dist/lib/chunks/{chunk-FPAN3VRW.js → chunk-FUAUPNRO.js} +26 -18
  60. package/dist/lib/chunks/{chunk-OQVIRYT5.js → chunk-G62E525I.js} +2 -2
  61. package/dist/lib/chunks/{chunk-2NJEWPCV.js → chunk-GDKGZQ3T.js} +2 -2
  62. package/dist/lib/chunks/{chunk-HSZ3DM74.js → chunk-GEFKDW7X.js} +15 -2
  63. package/dist/lib/chunks/{chunk-47IZBMP2.js → chunk-GESHTTSA.js} +2 -2
  64. package/dist/lib/chunks/chunk-GNMFJ2OK.js +321 -0
  65. package/dist/lib/chunks/{chunk-NVBMIPXR.js → chunk-HFRAHG5C.js} +44 -26
  66. package/dist/lib/chunks/{chunk-MHAKYFDF.js → chunk-HQG63ZKO.js} +11 -11
  67. package/dist/lib/chunks/{chunk-OORO55OM.js → chunk-HTOD4W4E.js} +21 -6
  68. package/dist/lib/chunks/{chunk-Q2PWES4B.js → chunk-I3XGRGXE.js} +1 -1
  69. package/dist/lib/chunks/{chunk-WUELMJ22.js → chunk-IE7NAL6B.js} +1 -1
  70. package/dist/lib/chunks/{chunk-KRFHQQS7.js → chunk-JXMDOAKA.js} +17 -17
  71. package/dist/lib/chunks/{chunk-S7KJZIUR.js → chunk-KJMU5KH4.js} +2 -2
  72. package/dist/lib/chunks/{chunk-POUSX3T4.js → chunk-L7MEIRJB.js} +1 -1
  73. package/dist/lib/chunks/{chunk-CPT2GKKW.js → chunk-LOBXOZ2R.js} +1 -1
  74. package/dist/lib/chunks/{chunk-IAR6XGEW.js → chunk-ML4W6KC6.js} +1 -1
  75. package/dist/lib/chunks/{chunk-WKH6BJAZ.js → chunk-MNWO7EHC.js} +4 -4
  76. package/dist/lib/chunks/{chunk-D2LPQO6Y.js → chunk-MRL5RUP7.js} +1 -1
  77. package/dist/lib/chunks/{chunk-IEVAFDW7.js → chunk-NCXSNHXX.js} +3 -3
  78. package/dist/lib/chunks/{chunk-HFOYASRQ.js → chunk-NGHAP2P5.js} +4 -4
  79. package/dist/lib/chunks/{chunk-ZLOOC46D.js → chunk-OKL7GN2F.js} +3 -3
  80. package/dist/lib/chunks/{chunk-3DG7GHFA.js → chunk-OQU5IXAJ.js} +5 -5
  81. package/dist/lib/chunks/{chunk-I7VNIW6Q.js → chunk-OU73OUX4.js} +16 -10
  82. package/dist/lib/chunks/{chunk-56VOFZ7T.js → chunk-QHUDJVPJ.js} +90 -24
  83. package/dist/lib/chunks/{chunk-KHU5DRBE.js → chunk-QSJ4IKUF.js} +9 -9
  84. package/dist/lib/chunks/{chunk-FBFZBLTY.js → chunk-R6XDZWUL.js} +7 -8
  85. package/dist/lib/chunks/{chunk-CJ5YD3CU.js → chunk-RJ5R6YYA.js} +5 -5
  86. package/dist/lib/chunks/{chunk-LPND3VNQ.js → chunk-RR46EDDR.js} +33 -25
  87. package/dist/lib/chunks/chunk-RYCRL3YA.js +106 -0
  88. package/dist/lib/chunks/{chunk-Z4LMDKBU.js → chunk-SHUMCKCS.js} +2 -2
  89. package/dist/lib/chunks/{chunk-3EBWDHPK.js → chunk-TJQ5OPLQ.js} +10 -12
  90. package/dist/lib/chunks/chunk-U64NCRRR.js +97 -0
  91. package/dist/lib/chunks/chunk-U772TN32.js +67 -0
  92. package/dist/lib/chunks/{chunk-YR67JG2V.js → chunk-UEMZYHYJ.js} +8 -3
  93. package/dist/lib/chunks/{chunk-J46W3EMQ.js → chunk-UZJSTJFP.js} +5 -5
  94. package/dist/lib/chunks/{chunk-XJVXASDD.js → chunk-V7OAPKNF.js} +3 -3
  95. package/dist/lib/chunks/{chunk-WE2WPNG2.js → chunk-VKM6MMA4.js} +66 -7
  96. package/dist/lib/chunks/{chunk-YWJPJI3W.js → chunk-VL253W5C.js} +3 -1
  97. package/dist/lib/chunks/{chunk-MD4AVTK2.js → chunk-VPZQGND4.js} +3 -3
  98. package/dist/lib/chunks/{chunk-X2Y2ZNG3.js → chunk-W2VGLWTS.js} +3 -3
  99. package/dist/lib/chunks/{chunk-6AUEDSTU.js → chunk-W5DC23OP.js} +1 -1
  100. package/dist/lib/chunks/chunk-W5X7WJYL.js +91 -0
  101. package/dist/lib/chunks/{chunk-QFVRCSJ2.js → chunk-WDOA5JEH.js} +2 -0
  102. package/dist/lib/chunks/{chunk-I3TMFPK4.js → chunk-WVACVWBL.js} +2 -2
  103. package/dist/lib/chunks/{chunk-MIF5IYNR.js → chunk-XDG6NPJB.js} +26 -29
  104. package/dist/lib/chunks/{chunk-X6E44EGV.js → chunk-XR44YSHT.js} +2 -2
  105. package/dist/lib/chunks/chunk-Y2CZ6FZY.js +61 -0
  106. package/dist/lib/chunks/{chunk-5KKLUM7M.js → chunk-YAAUWCJ4.js} +1 -1
  107. package/dist/lib/chunks/{chunk-3KQFLOC7.js → chunk-YRBIC5QH.js} +1 -1
  108. package/dist/lib/chunks/chunk-ZIGNJAPC.js +11 -0
  109. package/dist/lib/cli/bundle-commands.js +71 -65
  110. package/dist/lib/cli/guide-command.js +25 -0
  111. package/dist/lib/cli/io.js +1 -1
  112. package/dist/lib/cli/run-commands.js +270 -104
  113. package/dist/lib/cli/status-command.js +234 -0
  114. package/dist/lib/codex-workflow/aggregate.js +8 -9
  115. package/dist/lib/codex-workflow/author-tools.js +6 -7
  116. package/dist/lib/codex-workflow/author.js +17 -17
  117. package/dist/lib/codex-workflow/capture.js +10 -9
  118. package/dist/lib/codex-workflow/checkpoint.js +6 -7
  119. package/dist/lib/codex-workflow/checks.js +6 -7
  120. package/dist/lib/codex-workflow/codex-binary.js +13 -0
  121. package/dist/lib/codex-workflow/codex-home.js +6 -3
  122. package/dist/lib/codex-workflow/copy-editor.js +14 -14
  123. package/dist/lib/codex-workflow/copy-recovery.js +3 -4
  124. package/dist/lib/codex-workflow/copy.js +11 -11
  125. package/dist/lib/codex-workflow/finish.js +17 -18
  126. package/dist/lib/codex-workflow/host-models.js +7 -7
  127. package/dist/lib/codex-workflow/loop.js +42 -38
  128. package/dist/lib/codex-workflow/quality.js +3 -4
  129. package/dist/lib/codex-workflow/run-inputs.js +5 -6
  130. package/dist/lib/codex-workflow/run-source.js +14 -13
  131. package/dist/lib/codex-workflow/schemas.js +5 -6
  132. package/dist/lib/codex-workflow/session.js +7 -8
  133. package/dist/lib/codex-workflow/stage.js +26 -23
  134. package/dist/lib/codex-workflow/workdir.js +6 -7
  135. package/dist/lib/engine/audit-file.js +7 -6
  136. package/dist/lib/engine/author.js +37 -31
  137. package/dist/lib/engine/budget.js +7 -1
  138. package/dist/lib/engine/cost-estimate.js +41 -0
  139. package/dist/lib/engine/local-run.js +48 -42
  140. package/dist/lib/engine/preflight.js +10 -6
  141. package/dist/lib/engine/rejudge.js +56 -50
  142. package/dist/lib/engine/resources.js +1 -1
  143. package/dist/lib/engine/run-configuration.js +2 -1
  144. package/dist/lib/engine/run-status.js +151 -0
  145. package/dist/lib/engine/templates.js +8 -7
  146. package/dist/lib/grounding/controller.js +7 -7
  147. package/dist/lib/grounding/extract.js +6 -6
  148. package/dist/lib/grounding/grounding-runtime.js +18 -17
  149. package/dist/lib/grounding/model.js +5 -5
  150. package/dist/lib/grounding/recorded-tools.js +10 -9
  151. package/dist/lib/harness/report/artifacts.js +4 -5
  152. package/dist/lib/lib/checkpoint.js +3 -4
  153. package/dist/lib/models/batching.js +5 -5
  154. package/dist/lib/models/cost-coefficients.js +20 -0
  155. package/dist/lib/models/local-profile.js +10 -0
  156. package/dist/lib/models/pricing.js +6 -0
  157. package/dist/lib/models/profiles.js +7 -14
  158. package/dist/lib/models/structured-images.js +1 -1
  159. package/dist/lib/models/structured.js +4 -4
  160. package/dist/lib/models/supported-models.js +20 -0
  161. package/dist/lib/pipeline.js +9 -8
  162. package/dist/lib/probes/agent-cli-parsers.js +1 -1
  163. package/dist/lib/probes/agent-clis.js +6 -5
  164. package/dist/lib/probes/charged-trace.js +10 -0
  165. package/dist/lib/probes/probes.js +6 -6
  166. package/dist/lib/runner.js +10 -10
  167. package/dist/lib/schema.js +3 -4
  168. package/dist/lib/section-result.js +3 -4
  169. package/dist/lib/stores/artifacts.js +3 -4
  170. package/dist/lib/stores/files.js +9 -9
  171. package/dist/lib/stores/local-versions.js +4 -5
  172. package/dist/lib/stores/memory.js +6 -7
  173. package/dist/lib/stores/publication.js +5 -6
  174. package/dist/lib/viewer/server.js +18 -19
  175. package/dist/lib/workflow/schema.js +2 -3
  176. package/dist/types/agents/copy-validation.d.ts +4 -4
  177. package/dist/types/agents/verifier.d.ts +6 -6
  178. package/dist/types/bundle/contracts.d.ts +1 -1
  179. package/dist/types/bundle/isolation.d.ts +37 -0
  180. package/dist/types/bundle/project-journal.d.ts +2 -0
  181. package/dist/types/bundle/recorder.d.ts +4 -0
  182. package/dist/types/bundle/writer-lock.d.ts +9 -0
  183. package/dist/types/cli/guide-command.d.ts +4 -0
  184. package/dist/types/cli/status-command.d.ts +2 -0
  185. package/dist/types/codex-workflow/codex-binary.d.ts +26 -0
  186. package/dist/types/codex-workflow/codex-home.d.ts +24 -20
  187. package/dist/types/codex-workflow/copy-editor.d.ts +1 -1
  188. package/dist/types/codex-workflow/copy.d.ts +3 -4
  189. package/dist/types/codex-workflow/finish.d.ts +5 -3
  190. package/dist/types/codex-workflow/host-models.d.ts +7 -3
  191. package/dist/types/codex-workflow/loop.d.ts +10 -1
  192. package/dist/types/codex-workflow/run-inputs.d.ts +28 -113
  193. package/dist/types/codex-workflow/stage.d.ts +16 -5
  194. package/dist/types/engine/audit-file.d.ts +3 -2
  195. package/dist/types/engine/author.d.ts +7 -1
  196. package/dist/types/engine/budget.d.ts +46 -15
  197. package/dist/types/engine/cost-estimate.d.ts +40 -0
  198. package/dist/types/engine/local-run.d.ts +6 -0
  199. package/dist/types/engine/preflight.d.ts +5 -0
  200. package/dist/types/engine/resources.d.ts +2 -0
  201. package/dist/types/engine/run-configuration.d.ts +4 -3
  202. package/dist/types/engine/run-status.d.ts +75 -0
  203. package/dist/types/engine/templates.d.ts +1 -2
  204. package/dist/types/models/cost-coefficients.d.ts +106 -0
  205. package/dist/types/models/local-profile.d.ts +12 -0
  206. package/dist/types/models/pricing.d.ts +8 -0
  207. package/dist/types/models/profiles.d.ts +55 -160
  208. package/dist/types/models/served-model.d.ts +2 -3
  209. package/dist/types/models/structured.d.ts +3 -3
  210. package/dist/types/models/supported-models.d.ts +48 -0
  211. package/dist/types/probes/charged-trace.d.ts +8 -0
  212. package/dist/types/probes/probe-trace.d.ts +2 -0
  213. package/dist/types/schema.d.ts +28 -113
  214. package/dist/types/workflow/schema.d.ts +79 -152
  215. package/package.json +2 -1
  216. package/resources/guide/OPERATOR.md +180 -0
  217. package/src/agents/copy-validation.ts +8 -12
  218. package/src/agents/verifier.ts +10 -14
  219. package/src/bundle/contracts.ts +3 -3
  220. package/src/bundle/isolation.ts +157 -0
  221. package/src/bundle/project-journal.ts +4 -0
  222. package/src/bundle/project.ts +20 -7
  223. package/src/bundle/recorder.ts +5 -0
  224. package/src/bundle/writer-lock.ts +27 -0
  225. package/src/cli/guide-command.ts +28 -0
  226. package/src/cli/io.ts +2 -0
  227. package/src/cli/literally-aeo.ts +39 -19
  228. package/src/cli/run-commands.ts +236 -18
  229. package/src/cli/status-command.ts +113 -0
  230. package/src/codex-workflow/codex-binary.ts +105 -0
  231. package/src/codex-workflow/codex-home.ts +50 -40
  232. package/src/codex-workflow/copy.ts +7 -10
  233. package/src/codex-workflow/finish.ts +13 -8
  234. package/src/codex-workflow/host-models.ts +33 -24
  235. package/src/codex-workflow/loop.ts +36 -9
  236. package/src/codex-workflow/stage.ts +126 -17
  237. package/src/engine/audit-file.ts +10 -8
  238. package/src/engine/author.ts +47 -2
  239. package/src/engine/budget.ts +138 -43
  240. package/src/engine/cost-estimate.ts +178 -0
  241. package/src/engine/guide/OPERATOR.md +180 -0
  242. package/src/engine/local-run.ts +38 -8
  243. package/src/engine/preflight.ts +90 -7
  244. package/src/engine/resources.ts +9 -4
  245. package/src/engine/run-configuration.ts +19 -1
  246. package/src/engine/run-status.ts +452 -0
  247. package/src/engine/templates.ts +5 -2
  248. package/src/models/cost-coefficients.ts +140 -0
  249. package/src/models/local-profile.ts +150 -0
  250. package/src/models/pricing.ts +31 -0
  251. package/src/models/profiles.ts +58 -419
  252. package/src/models/served-model.ts +2 -3
  253. package/src/models/structured-images.ts +5 -4
  254. package/src/models/structured.ts +20 -7
  255. package/src/models/supported-models.ts +112 -0
  256. package/src/probes/agent-clis.ts +24 -2
  257. package/src/probes/charged-trace.ts +87 -0
  258. package/src/probes/probe-trace.ts +2 -0
  259. package/src/probes/probes.ts +48 -2
  260. package/dist/lib/chunks/chunk-CFFPOTP4.js +0 -356
  261. package/dist/lib/chunks/chunk-LIZX4N3H.js +0 -110
  262. package/dist/lib/chunks/chunk-OYKV5NDM.js +0 -28
@@ -0,0 +1,74 @@
1
+ // src/models/cost-coefficients.ts
2
+ var costCoefficientsVersion = 1;
3
+ var stageTokens = {
4
+ perAnswer: {
5
+ low: { input: 3e4, output: 4e3 },
6
+ high: { input: 9e4, output: 16e3 }
7
+ },
8
+ perRun: {
9
+ low: { input: 25e4, output: 1e4 },
10
+ high: { input: 9e5, output: 4e4 }
11
+ },
12
+ /** The share of stage input served from cache: high is cheap. The
13
+ * supported models reported none through the gateway in the spike. */
14
+ cachedShare: { low: 0, high: 0.8 }
15
+ };
16
+ var authorTokens = {
17
+ session: {
18
+ low: { input: 25e4, output: 1e4 },
19
+ high: { input: 8e5, output: 45e3 }
20
+ }
21
+ };
22
+ var authorSearchLowUsd = 0.05;
23
+ var hostTokensPerAnswer = {
24
+ extraction_only: {
25
+ low: { input: 1500, output: 3e3 },
26
+ high: { input: 8e3, output: 12e3 }
27
+ },
28
+ full: {
29
+ low: { input: 6e3, output: 6e3 },
30
+ high: { input: 24e3, output: 18e3 }
31
+ }
32
+ };
33
+ var searchUsdPerAnswer = { low: 1e-3, high: 0.01 };
34
+ var probeUsd = {
35
+ chatgpt: { low: 0.01, high: 0.05 },
36
+ gemini: { low: 0.02, high: 0.06 },
37
+ claude: { low: 0.02, high: 0.08 },
38
+ perplexity: { low: 0.01, high: 0.03 },
39
+ google_ai_overview: { low: 2e-3, high: 6e-3 },
40
+ claude_code: { low: 0, high: 0 },
41
+ codex: { low: 0, high: 0 },
42
+ cursor: { low: 0, high: 0 }
43
+ };
44
+ var sessionReservation = ({
45
+ cost,
46
+ answers
47
+ }) => {
48
+ const batch = {
49
+ input: 5e4 + answers * (stageTokens.perAnswer.high.input / 2),
50
+ output: 8e3 + answers * (stageTokens.perAnswer.high.output / 2)
51
+ };
52
+ const tokens = {
53
+ answers: batch,
54
+ report: stageTokens.perRun.high,
55
+ brief: authorTokens.session.high
56
+ }[cost];
57
+ const reservation = {
58
+ inputTokens: tokens.input,
59
+ cachedInputTokens: Math.round(tokens.input * stageTokens.cachedShare.low),
60
+ outputTokens: tokens.output
61
+ };
62
+ return reservation;
63
+ };
64
+
65
+ export {
66
+ costCoefficientsVersion,
67
+ stageTokens,
68
+ authorTokens,
69
+ authorSearchLowUsd,
70
+ hostTokensPerAnswer,
71
+ searchUsdPerAnswer,
72
+ probeUsd,
73
+ sessionReservation
74
+ };
@@ -2,7 +2,7 @@ import {
2
2
  bundleManifestSchema,
3
3
  bundlePaths,
4
4
  digestManifest
5
- } from "./chunk-I3TMFPK4.js";
5
+ } from "./chunk-WVACVWBL.js";
6
6
  import {
7
7
  canonicalDigest,
8
8
  encodeBundleJson,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  checkpointFiles
3
- } from "./chunk-XHWRSGX3.js";
3
+ } from "./chunk-3JO5TXBA.js";
4
4
 
5
5
  // src/codex-workflow/session.ts
6
6
  import { readFile, rm, writeFile } from "node:fs/promises";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  qualificationQuoteMaxLength,
3
3
  stageSchemas
4
- } from "./chunk-GVC4LH2N.js";
4
+ } from "./chunk-6GHHNPFJ.js";
5
5
  import {
6
6
  locateVerbatimPassage
7
7
  } from "./chunk-3UFZ2XPE.js";
@@ -4,10 +4,10 @@ import {
4
4
  import {
5
5
  assertCopyValidation,
6
6
  copyCheckerVersion
7
- } from "./chunk-FBFZBLTY.js";
7
+ } from "./chunk-R6XDZWUL.js";
8
8
  import {
9
9
  internalModelProfileSchema
10
- } from "./chunk-CFFPOTP4.js";
10
+ } from "./chunk-RYCRL3YA.js";
11
11
  import {
12
12
  aeoSnapshotSchema
13
13
  } from "./chunk-SDWYZM64.js";
@@ -0,0 +1,31 @@
1
+ import {
2
+ createMemoryModelAccounting
3
+ } from "./chunk-TNL2GWYR.js";
4
+
5
+ // src/codex-workflow/host-models.ts
6
+ var hostStepMaxUsd = 5;
7
+ var hostStepAccounting = () => {
8
+ return createMemoryModelAccounting({
9
+ maxUsd: hostStepMaxUsd,
10
+ maxTokens: 5e6,
11
+ deadlineAt: new Date(Date.now() + 30 * 6e4).toISOString()
12
+ });
13
+ };
14
+ var hostModels = (profile) => {
15
+ return { profile, accounting: hostStepAccounting() };
16
+ };
17
+ var pinnedProfileOf = (profile) => {
18
+ if (!profile) {
19
+ throw new Error(
20
+ "The run request pins no model profile; the host model steps need one."
21
+ );
22
+ }
23
+ return profile;
24
+ };
25
+
26
+ export {
27
+ hostStepMaxUsd,
28
+ hostStepAccounting,
29
+ hostModels,
30
+ pinnedProfileOf
31
+ };
@@ -6,26 +6,26 @@ import {
6
6
  } from "./chunk-5T3V6XJS.js";
7
7
  import {
8
8
  recordedGroundingTools
9
- } from "./chunk-2GY42RIJ.js";
9
+ } from "./chunk-D3GE3OCB.js";
10
10
  import {
11
11
  runGroundingResearch
12
- } from "./chunk-X2Y2ZNG3.js";
12
+ } from "./chunk-W2VGLWTS.js";
13
13
  import {
14
14
  candidateInventoryPolicyVersion,
15
15
  claimExtractionIdentity,
16
16
  extractClaimCandidates,
17
17
  validatedExtractionBatchSchema
18
- } from "./chunk-7GXRDAUY.js";
18
+ } from "./chunk-BLKLPUYR.js";
19
19
  import {
20
20
  createGatewayGroundingModel
21
- } from "./chunk-WUELMJ22.js";
21
+ } from "./chunk-IE7NAL6B.js";
22
+ import {
23
+ resolveDataForSeoLocale
24
+ } from "./chunk-NH4QGBJV.js";
22
25
  import {
23
26
  createDataForSeoSearchAdapter,
24
27
  createGroundingTools
25
28
  } from "./chunk-EPQHVILQ.js";
26
- import {
27
- resolveDataForSeoLocale
28
- } from "./chunk-NH4QGBJV.js";
29
29
  import {
30
30
  extractionCacheRunIdsFromManifest,
31
31
  savedAnswersFromManifest,
@@ -1,20 +1,20 @@
1
- import {
2
- auditCopyFile,
3
- authorEvidenceFile,
4
- authorEvidenceSchema
5
- } from "./chunk-HSZ3DM74.js";
6
1
  import {
7
2
  stagePrompts
8
3
  } from "./chunk-4QQJXCD2.js";
9
4
  import {
10
- codexModel
11
- } from "./chunk-MIF5IYNR.js";
5
+ codexGateway
6
+ } from "./chunk-XDG6NPJB.js";
7
+ import {
8
+ auditCopyFile,
9
+ authorEvidenceFile,
10
+ authorEvidenceSchema
11
+ } from "./chunk-GEFKDW7X.js";
12
12
  import {
13
13
  readRunInputs
14
- } from "./chunk-2NJEWPCV.js";
14
+ } from "./chunk-GDKGZQ3T.js";
15
15
  import {
16
16
  stageVersions
17
- } from "./chunk-GVC4LH2N.js";
17
+ } from "./chunk-6GHHNPFJ.js";
18
18
  import {
19
19
  predecessorDir,
20
20
  readDerivedFrom
@@ -24,10 +24,13 @@ import {
24
24
  } from "./chunk-SREGO3PU.js";
25
25
  import {
26
26
  projectJournal
27
- } from "./chunk-ZBDUE3A5.js";
27
+ } from "./chunk-2GU6CNQI.js";
28
28
  import {
29
29
  capturedAnswerOf
30
- } from "./chunk-GMKF2FU4.js";
30
+ } from "./chunk-5JPYM4MD.js";
31
+ import {
32
+ isolationLimitations
33
+ } from "./chunk-BSRKN6FU.js";
31
34
  import {
32
35
  hasErrorCode
33
36
  } from "./chunk-2QLAFBCG.js";
@@ -36,7 +39,7 @@ import {
36
39
  calculationVersion,
37
40
  measurementDigest,
38
41
  predecessorPrefix
39
- } from "./chunk-I3TMFPK4.js";
42
+ } from "./chunk-WVACVWBL.js";
40
43
  import {
41
44
  canonicalDigest,
42
45
  encodeBundleJson
@@ -109,6 +112,14 @@ var runPolicyOf = (request) => {
109
112
  };
110
113
  return runPolicy;
111
114
  };
115
+ var stageModelOf = (inputs) => {
116
+ const stages = inputs.request.modelProfile?.stages;
117
+ return stages ? {
118
+ model: stages.model,
119
+ provider: codexGateway.providerName,
120
+ reasoningEffort: stages.reasoningEffort
121
+ } : null;
122
+ };
112
123
  var methodOf = async (dir, inputs, snapshot) => {
113
124
  const meta = isRecord(snapshot) && isRecord(snapshot.meta) ? snapshot.meta : {};
114
125
  const schemas = {};
@@ -137,11 +148,7 @@ var methodOf = async (dir, inputs, snapshot) => {
137
148
  // a session's own packet is in the journal.
138
149
  stagePrompts,
139
150
  stageVersions,
140
- codexModel: {
141
- model: codexModel.model,
142
- provider: codexModel.providerName,
143
- reasoningEffort: codexModel.reasoningEffort
144
- }
151
+ codexModel: stageModelOf(inputs)
145
152
  };
146
153
  return method;
147
154
  };
@@ -246,7 +253,8 @@ var projectWorkdir = async (dir, {
246
253
  version: 1,
247
254
  writers: journal.writers,
248
255
  agentCliVersions: capture.agentCliVersions,
249
- limitations: journal.writers.length > 0 ? [] : [
256
+ isolation: journal.isolation,
257
+ limitations: journal.writers.length > 0 ? isolationLimitations(journal.isolation) : [
250
258
  "The work directory predates runtime recording; the writers of this run are unknown."
251
259
  ]
252
260
  }
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-ZXQPD4OC.js";
4
4
  import {
5
5
  verifyBundle
6
- } from "./chunk-XNRSHATN.js";
6
+ } from "./chunk-663HABKP.js";
7
7
  import {
8
8
  RunOrigin,
9
9
  toolVersion
10
- } from "./chunk-I3TMFPK4.js";
10
+ } from "./chunk-WVACVWBL.js";
11
11
  import {
12
12
  parseBundleJson
13
13
  } from "./chunk-E6NQQU6V.js";
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-2QLAFBCG.js";
4
4
  import {
5
5
  captureArtifactSchema
6
- } from "./chunk-5KKLUM7M.js";
6
+ } from "./chunk-YAAUWCJ4.js";
7
7
  import {
8
8
  aeoAuditConfigSchema,
9
9
  runRequestSchema
10
- } from "./chunk-ZLOOC46D.js";
10
+ } from "./chunk-OKL7GN2F.js";
11
11
  import {
12
12
  aeoSurfaceSchema
13
13
  } from "./chunk-SDWYZM64.js";
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  writeFileAtomically
3
3
  } from "./chunk-MX6Y4RD2.js";
4
+ import {
5
+ isRecord
6
+ } from "./chunk-7PLK6VGC.js";
4
7
 
5
8
  // src/engine/run-configuration.ts
6
9
  import { readFile } from "node:fs/promises";
@@ -31,14 +34,24 @@ var readRecordedAuthorEvidence = async (dir) => {
31
34
  );
32
35
  return text === void 0 ? void 0 : authorEvidenceSchema.parse(JSON.parse(text));
33
36
  };
37
+ var configWithModel = (text, model) => {
38
+ const config = JSON.parse(text);
39
+ if (!isRecord(config)) {
40
+ throw new Error("The configuration to record is not a JSON object.");
41
+ }
42
+ return `${JSON.stringify({ ...config, model }, null, 2)}
43
+ `;
44
+ };
34
45
  var recordRunConfiguration = async ({
35
46
  dir,
36
47
  configFile,
37
- evidence
48
+ evidence,
49
+ model
38
50
  }) => {
51
+ const text = await readFile(configFile, "utf8");
39
52
  await writeFileAtomically(
40
53
  path.join(dir, auditCopyFile),
41
- await readFile(configFile, "utf8")
54
+ model === void 0 ? text : configWithModel(text, model)
42
55
  );
43
56
  await writeFileAtomically(
44
57
  path.join(dir, authorEvidenceFile),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readFinalizedRevisions
3
- } from "./chunk-KHU5DRBE.js";
3
+ } from "./chunk-QSJ4IKUF.js";
4
4
  import {
5
5
  BundleRefusedError,
6
6
  archiveLimits,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-2QLAFBCG.js";
15
15
  import {
16
16
  bundlePaths
17
- } from "./chunk-I3TMFPK4.js";
17
+ } from "./chunk-WVACVWBL.js";
18
18
 
19
19
  // src/bundle/read.ts
20
20
  import { lstat, readdir, readFile } from "node:fs/promises";
@@ -0,0 +1,321 @@
1
+ import {
2
+ bankDir,
3
+ runDirectoryState
4
+ } from "./chunk-HFRAHG5C.js";
5
+ import {
6
+ FileProbeStore
7
+ } from "./chunk-HQG63ZKO.js";
8
+ import {
9
+ localReportKey,
10
+ readAuditFile,
11
+ toAuditConfig
12
+ } from "./chunk-OU73OUX4.js";
13
+ import {
14
+ budgetFile
15
+ } from "./chunk-2B5QF6UQ.js";
16
+ import {
17
+ readWriterLock
18
+ } from "./chunk-6GOBBNDU.js";
19
+ import {
20
+ auditCopyFile
21
+ } from "./chunk-GEFKDW7X.js";
22
+ import {
23
+ readRunInputs
24
+ } from "./chunk-GDKGZQ3T.js";
25
+ import {
26
+ runJournalDir
27
+ } from "./chunk-4PD65FRJ.js";
28
+ import {
29
+ readJournal
30
+ } from "./chunk-YRBIC5QH.js";
31
+ import {
32
+ hasErrorCode
33
+ } from "./chunk-2QLAFBCG.js";
34
+ import {
35
+ capturePlan
36
+ } from "./chunk-YHS5IEVZ.js";
37
+ import {
38
+ unitRecordKey
39
+ } from "./chunk-ULRXHSJL.js";
40
+ import {
41
+ chargedCall
42
+ } from "./chunk-TNL2GWYR.js";
43
+
44
+ // src/engine/run-status.ts
45
+ import { readFile, stat } from "node:fs/promises";
46
+ import path from "node:path";
47
+ import { z } from "zod";
48
+ var SpendCategory = {
49
+ PROBES: "probes",
50
+ STAGES: "stages",
51
+ HOST_CALLS: "hostCalls",
52
+ SEARCH: "search"
53
+ };
54
+ var spendCategoryOf = (role) => {
55
+ if (role.startsWith("stage:")) {
56
+ return SpendCategory.STAGES;
57
+ }
58
+ if (role.startsWith("probe:")) {
59
+ return SpendCategory.PROBES;
60
+ }
61
+ if (role.startsWith("search:") || role === "research_search") {
62
+ return SpendCategory.SEARCH;
63
+ }
64
+ return SpendCategory.HOST_CALLS;
65
+ };
66
+ var ledgerCallSchema = z.looseObject({
67
+ callId: z.string(),
68
+ role: z.string(),
69
+ reservedUsd: z.number(),
70
+ inputTokens: z.number(),
71
+ maxOutputTokens: z.number(),
72
+ usage: z.looseObject({
73
+ costUsd: z.number().optional(),
74
+ inputTokens: z.number().optional(),
75
+ outputTokens: z.number().optional()
76
+ }).optional()
77
+ });
78
+ var ledgerSchema = z.looseObject({
79
+ limits: z.looseObject({ maxUsd: z.number(), deadlineAt: z.string() }),
80
+ calls: z.record(z.string(), ledgerCallSchema)
81
+ });
82
+ var budgetStateSchema = z.looseObject({
83
+ current: z.looseObject({ maxUsd: z.number() }),
84
+ deadlineAt: z.string(),
85
+ model: z.string().optional()
86
+ });
87
+ var workflowStages = ["analyze", "qualify", "review", "write"];
88
+ var readText = async (file) => {
89
+ try {
90
+ return await readFile(file, "utf8");
91
+ } catch (err) {
92
+ if (hasErrorCode(err, "ENOENT")) {
93
+ return void 0;
94
+ }
95
+ throw err;
96
+ }
97
+ };
98
+ var exists = async (file) => {
99
+ try {
100
+ await stat(file);
101
+ return true;
102
+ } catch (err) {
103
+ if (hasErrorCode(err, "ENOENT")) {
104
+ return false;
105
+ }
106
+ throw err;
107
+ }
108
+ };
109
+ var parseJson = (text) => {
110
+ if (text === void 0) {
111
+ return void 0;
112
+ }
113
+ try {
114
+ return JSON.parse(text);
115
+ } catch {
116
+ return void 0;
117
+ }
118
+ };
119
+ var readEvents = async (dir) => {
120
+ const text = await readText(path.join(dir, runJournalDir, "events.jsonl"));
121
+ return text === void 0 ? [] : readJournal(text).events;
122
+ };
123
+ var stringField = (value) => {
124
+ return typeof value === "string" ? value : void 0;
125
+ };
126
+ var phaseOf = (activity) => {
127
+ switch (activity.kind) {
128
+ case "probe":
129
+ case "canary":
130
+ return "capture";
131
+ case "technical_check":
132
+ return "technical checks";
133
+ case "research_tool":
134
+ return "grounding";
135
+ case "codex_session":
136
+ return activity.stage ?? "codex session";
137
+ default:
138
+ return activity.role ?? activity.kind;
139
+ }
140
+ };
141
+ var lastActivityOf = (events) => {
142
+ const started = events.findLast(
143
+ (event) => event.type === "operation_started"
144
+ );
145
+ if (!started) {
146
+ return void 0;
147
+ }
148
+ const finished = events.some(
149
+ (event) => event.type === "operation_finished" && event.operationId === started.operationId
150
+ );
151
+ const activity = {
152
+ kind: stringField(started.payload.kind) ?? "unknown",
153
+ stage: stringField(started.payload.stage),
154
+ role: stringField(started.payload.role),
155
+ at: started.at,
156
+ open: !finished
157
+ };
158
+ return activity;
159
+ };
160
+ var endOf = (events) => {
161
+ const writerStart = events.findLastIndex(
162
+ (event) => event.type === "run_started" || event.type === "run_resumed"
163
+ );
164
+ const end = events.slice(Math.max(writerStart, 0)).findLast(
165
+ (event) => ["run_completed", "run_failed", "run_interrupted"].includes(event.type)
166
+ );
167
+ return end;
168
+ };
169
+ var lastErrorOf = (events) => {
170
+ const failure = events.findLast(
171
+ (event) => event.type === "run_failed" || event.type === "run_interrupted"
172
+ );
173
+ if (!failure) {
174
+ return void 0;
175
+ }
176
+ const lastError = {
177
+ type: failure.type,
178
+ error: stringField(failure.payload.error) ?? "unknown",
179
+ reason: stringField(failure.payload.reason) ?? "",
180
+ at: failure.at
181
+ };
182
+ return lastError;
183
+ };
184
+ var emptySpend = () => {
185
+ return {
186
+ probes: { usd: 0, calls: 0 },
187
+ stages: { usd: 0, calls: 0 },
188
+ hostCalls: { usd: 0, calls: 0 },
189
+ search: { usd: 0, calls: 0 }
190
+ };
191
+ };
192
+ var readSpend = async (dir) => {
193
+ const ledger = ledgerSchema.safeParse(
194
+ parseJson(await readText(path.join(dir, bankDir, "model-budget.json")))
195
+ );
196
+ const budget = budgetStateSchema.safeParse(
197
+ parseJson(await readText(path.join(dir, budgetFile)))
198
+ );
199
+ const limits = ledger.success ? ledger.data.limits : void 0;
200
+ const byCategory = emptySpend();
201
+ let settledUsd = 0;
202
+ let openUsd = 0;
203
+ for (const call of Object.values(ledger.success ? ledger.data.calls : {})) {
204
+ const charge = chargedCall(call);
205
+ const category = byCategory[spendCategoryOf(call.role)];
206
+ category.usd += charge.usd;
207
+ category.calls += 1;
208
+ if (call.usage === void 0) {
209
+ openUsd += charge.usd;
210
+ } else {
211
+ settledUsd += charge.usd;
212
+ }
213
+ }
214
+ const capUsd = budget.success ? budget.data.current.maxUsd : limits?.maxUsd;
215
+ const chargedUsd = settledUsd + openUsd;
216
+ const spend = {
217
+ currency: "USD",
218
+ capUsd,
219
+ model: budget.success ? budget.data.model : void 0,
220
+ deadlineAt: budget.success ? budget.data.deadlineAt : limits?.deadlineAt,
221
+ chargedUsd,
222
+ settledUsd,
223
+ openUsd,
224
+ remainingUsd: capUsd === void 0 ? void 0 : Math.max(capUsd - chargedUsd, 0),
225
+ byCategory
226
+ };
227
+ return spend;
228
+ };
229
+ var plannedUnitsOf = async (dir) => {
230
+ const auditCopy = path.join(dir, auditCopyFile);
231
+ if (await exists(auditCopy)) {
232
+ try {
233
+ const file = await readAuditFile(auditCopy);
234
+ const plan = capturePlan(toAuditConfig(file), file.surfaces);
235
+ return {
236
+ reportKey: localReportKey(file),
237
+ keys: new Set(plan.units.map(unitRecordKey))
238
+ };
239
+ } catch {
240
+ }
241
+ }
242
+ const inputs = await readRunInputs(dir).catch(() => void 0);
243
+ if (!inputs) {
244
+ return void 0;
245
+ }
246
+ return { reportKey: inputs.reportKey, keys: void 0 };
247
+ };
248
+ var readAnswers = async (dir) => {
249
+ const planned = await plannedUnitsOf(dir);
250
+ if (!planned) {
251
+ return { planned: void 0, captured: 0, failed: 0 };
252
+ }
253
+ const bank = await FileProbeStore.open(planned.reportKey, {
254
+ dir: path.join(dir, bankDir)
255
+ });
256
+ const records = (await bank.list()).filter(
257
+ (record) => planned.keys === void 0 || planned.keys.has(unitRecordKey(record))
258
+ );
259
+ const inputs = planned.keys === void 0 ? await readRunInputs(dir).catch(() => void 0) : void 0;
260
+ const answers = {
261
+ planned: planned.keys?.size ?? inputs?.capture.plannedUnits,
262
+ captured: records.filter((record) => record.status === "captured").length,
263
+ failed: records.filter((record) => record.status !== "captured").length
264
+ };
265
+ return answers;
266
+ };
267
+ var readRunStatus = async (dir) => {
268
+ const [events, directoryState, hasBank, hasJournal] = await Promise.all([
269
+ readEvents(dir),
270
+ runDirectoryState(dir),
271
+ exists(path.join(dir, bankDir)),
272
+ exists(path.join(dir, runJournalDir, "events.jsonl"))
273
+ ]);
274
+ if (directoryState === "new" && !hasBank && !hasJournal) {
275
+ return void 0;
276
+ }
277
+ const lock = await readWriterLock(dir);
278
+ const lastActivity = lastActivityOf(events);
279
+ const end = endOf(events);
280
+ const completedStages = [];
281
+ for (const stage of workflowStages) {
282
+ if (await exists(path.join(dir, "OUT", `${stage}.json`))) {
283
+ completedStages.push(stage);
284
+ }
285
+ }
286
+ const lastError = lastErrorOf(events);
287
+ let phase = lastActivity && phaseOf(lastActivity);
288
+ if (directoryState === "completed") {
289
+ phase = "completed";
290
+ } else if (end?.type === "run_failed") {
291
+ phase = "stopped";
292
+ } else if (end?.type === "run_interrupted") {
293
+ phase = "interrupted";
294
+ }
295
+ const status = {
296
+ dir,
297
+ // Answers already banked make the next run a resume, not a start.
298
+ state: directoryState === "new" ? "resumable" : directoryState,
299
+ writer: lock && {
300
+ purpose: lock.owner.purpose,
301
+ pid: lock.owner.pid,
302
+ host: lock.owner.host,
303
+ since: lock.owner.acquiredAt,
304
+ state: lock.state
305
+ },
306
+ phase,
307
+ lastActivity,
308
+ completedStages,
309
+ answers: await readAnswers(dir),
310
+ spend: await readSpend(dir),
311
+ lastError,
312
+ stoppedAtBudget: end?.type === "run_failed" && end.payload.error === "ModelBudgetError"
313
+ };
314
+ return status;
315
+ };
316
+
317
+ export {
318
+ SpendCategory,
319
+ spendCategoryOf,
320
+ readRunStatus
321
+ };