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
@@ -28,7 +28,12 @@ import {
28
28
  } from '../probes/agent-clis';
29
29
  import { createFileResearchSessionStore } from '../grounding/file-store';
30
30
  import { openGroundingRuntime } from '../grounding/grounding-runtime';
31
- import { createFileModelAccounting } from '../models/accounting';
31
+ import {
32
+ createFileModelAccounting,
33
+ type ModelCallAccounting,
34
+ } from '../models/accounting';
35
+ import { resolveSupportedModel } from '../models/supported-models';
36
+ import { chargedProbeTrace } from '../probes/charged-trace';
32
37
  import type { InternalModelContext } from '../models/context';
33
38
  import { ProbeLimiter } from '../probes/limits';
34
39
  import { planRun, type RunPlan } from '../runner';
@@ -134,6 +139,9 @@ export type LocalRun = {
134
139
  /** The run's pinned model context: every host call charges its ledger
135
140
  * and is recorded in the run journal. */
136
141
  internalModels: InternalModelContext;
142
+ /** The same ledger unwrapped, for the Codex sessions, which the journal
143
+ * records as operations of their own. */
144
+ ledger: ModelCallAccounting;
137
145
  ground: GroundRun;
138
146
  /** The directory's writer lock and its run journal, held from before the
139
147
  * first canary: the workflow continues under both (prepareWorkdir held). */
@@ -154,6 +162,8 @@ export const openLocalRun = async (
154
162
  dir: string,
155
163
  options: {
156
164
  signal?: AbortSignal;
165
+ /** The cap approved on the command line (`run --max-usd`). */
166
+ maxUsd?: number;
157
167
  amendment?: BudgetAmendment;
158
168
  derivedFromRunId?: string;
159
169
  } = {},
@@ -203,12 +213,14 @@ const openLockedLocalRun = async (
203
213
  dir: string,
204
214
  {
205
215
  signal,
216
+ maxUsd,
206
217
  amendment,
207
218
  derivedFromRunId,
208
219
  runId,
209
220
  held,
210
221
  }: {
211
222
  signal?: AbortSignal;
223
+ maxUsd?: number;
212
224
  amendment?: BudgetAmendment;
213
225
  derivedFromRunId?: string;
214
226
  runId: string;
@@ -217,7 +229,9 @@ const openLockedLocalRun = async (
217
229
  ): Promise<LocalRun> => {
218
230
  const { recorder } = held;
219
231
  const budget = await resolveRunBudget(dir, file.runPolicy.budget, {
220
- amendment,
232
+ model: resolveSupportedModel(file.model).id,
233
+ ...(maxUsd !== undefined && { maxUsd }),
234
+ ...(amendment && { amendment }),
221
235
  });
222
236
  const config = toAuditConfig(file);
223
237
  const request = {
@@ -237,17 +251,20 @@ const openLockedLocalRun = async (
237
251
 
238
252
  return Promise.resolve();
239
253
  };
254
+ // One ledger for every paid call of the run: probes, Codex sessions,
255
+ // host model calls and searches (specs/aeo-claude-operator-spec.md §4.2).
256
+ const ledger = createFileModelAccounting({
257
+ filename: path.join(bank, 'model-budget.json'),
258
+ limits: budget.limits,
259
+ assertOwned,
260
+ });
240
261
  const grounding = openGroundingRuntime({
241
262
  request,
242
263
  config,
243
264
  analysisStore: stores.analysisStore,
244
265
  env: getEnvironment(),
245
266
  signal,
246
- rawAccounting: createFileModelAccounting({
247
- filename: path.join(bank, 'model-budget.json'),
248
- limits: budget.limits,
249
- assertOwned,
250
- }),
267
+ rawAccounting: ledger,
251
268
  store: createFileResearchSessionStore(
252
269
  path.join(bank, 'research'),
253
270
  assertOwned,
@@ -280,6 +297,7 @@ const openLockedLocalRun = async (
280
297
  );
281
298
  }
282
299
 
300
+ const probes = chargedProbeTrace(probeTraceOf(recorder, 'probe'), ledger);
283
301
  const capture = await captureForRun({
284
302
  config,
285
303
  request,
@@ -288,10 +306,21 @@ const openLockedLocalRun = async (
288
306
  agentCliVersions,
289
307
  limiter: new ProbeLimiter(request.limits),
290
308
  internalModels,
291
- trace: probeTraceOf(recorder, 'probe'),
309
+ trace: probes.trace,
292
310
  signal,
293
311
  logContext: { reportKey: config.reportKey, runId, local: true },
312
+ }).catch((err: unknown) => {
313
+ // A unit the cap refused fails as unrecorded, and the capture may
314
+ // report only the shortfall: the cap is the reason, and the run stops
315
+ // resumable with everything captured so far banked.
316
+ throw probes.exhausted() ?? err;
294
317
  });
318
+ const exhausted = probes.exhausted();
319
+
320
+ if (exhausted) {
321
+ throw exhausted;
322
+ }
323
+
295
324
  const captured = (await stores.probeStore.list()).filter(
296
325
  (entry): entry is CapturedUnitRecord => entry.status === 'captured',
297
326
  );
@@ -315,6 +344,7 @@ const openLockedLocalRun = async (
315
344
  source,
316
345
  budget,
317
346
  internalModels,
347
+ ledger,
318
348
  ground: (manifest, options) => grounding.ground(manifest, options),
319
349
  held,
320
350
  };
@@ -7,10 +7,20 @@ import {
7
7
  versionForSurface,
8
8
  } from '../probes/agent-clis';
9
9
  import {
10
+ agentSurfaces,
10
11
  isAgentSurface,
11
12
  type AeoAgentSurface,
12
13
  type AeoSurface,
13
14
  } from '../schema';
15
+ import {
16
+ codexBinaryVersion,
17
+ resolveCodexBinary,
18
+ } from '../codex-workflow/codex-binary';
19
+ import {
20
+ describeSupportedModels,
21
+ findSupportedModel,
22
+ recommendedModelId,
23
+ } from '../models/supported-models';
14
24
  import type { Settings } from './env-file';
15
25
 
16
26
  // ============================================================================
@@ -99,11 +109,69 @@ const directoryCheck = async (dir: string): Promise<PreflightCheck> => {
99
109
  }
100
110
  };
101
111
 
112
+ /** The model audit.json names, or the recommended one: refused when it is
113
+ * not on the supported list, which the detail then prints. */
114
+ export const modelCheck = (model: string | undefined): PreflightCheck => {
115
+ const id = model ?? recommendedModelId;
116
+ const supported = findSupportedModel(id);
117
+
118
+ if (!supported) {
119
+ return {
120
+ name: 'model',
121
+ ok: false,
122
+ detail: [
123
+ `${id} is not supported; use one of:`,
124
+ ...describeSupportedModels(),
125
+ ].join('\n '),
126
+ };
127
+ }
128
+
129
+ return {
130
+ name: 'model',
131
+ ok: true,
132
+ detail: [
133
+ `${supported.id}${model === undefined ? ' (recommended; audit.json names none)' : ''}`,
134
+ supported.stageRuntimeVerifiedAt === null
135
+ ? 'not yet verified on the Codex stage runtime through the gateway'
136
+ : `verified on the Codex stage runtime ${supported.stageRuntimeVerifiedAt}`,
137
+ ].join('; '),
138
+ };
139
+ };
140
+
141
+ /** The Codex the stages run: this package's own, unless overridden. */
142
+ const codexCheck = async (): Promise<PreflightCheck> => {
143
+ try {
144
+ const binary = resolveCodexBinary();
145
+ const version = await codexBinaryVersion(binary);
146
+ const origin =
147
+ binary.source === 'dependency'
148
+ ? "the package's own pinned dependency"
149
+ : `AEO_CODEX_BIN=${binary.path}`;
150
+
151
+ return {
152
+ name: 'codex (stage runtime)',
153
+ ok: version !== null,
154
+ detail:
155
+ version === null
156
+ ? `${binary.path} did not start; reinstall literally-aeo`
157
+ : `${version}, from ${origin}`,
158
+ };
159
+ } catch (err) {
160
+ return {
161
+ name: 'codex (stage runtime)',
162
+ ok: false,
163
+ detail: `not installed with the package (${err instanceof Error ? err.message : String(err)}); reinstall literally-aeo`,
164
+ };
165
+ }
166
+ };
167
+
102
168
  /** runPreflight checks what a run over these surfaces needs locally. */
103
169
  export const runPreflight = async (args: {
104
170
  surfaces: readonly AeoSurface[];
105
171
  settings: Settings;
106
172
  dir: string;
173
+ /** audit.json's `model`; absent means the recommended model. */
174
+ model?: string;
107
175
  /** Full grounding researches through the pinned search provider. */
108
176
  groundingSearch?: boolean;
109
177
  }): Promise<PreflightCheck[]> => {
@@ -118,13 +186,9 @@ export const runPreflight = async (args: {
118
186
  ok: nodeMajor >= minimumNodeMajor,
119
187
  detail: `${process.version} (${minimumNodeMajor} or newer required)`,
120
188
  },
121
- {
122
- // Every stage session runs on the Codex CLI, whatever is measured.
123
- name: 'codex CLI',
124
- ok: versions.codex !== null,
125
- detail:
126
- versions.codex ?? 'not found on PATH; the workflow stages need it',
127
- },
189
+ modelCheck(args.model),
190
+ // Every stage session runs on Codex, whatever is measured.
191
+ await codexCheck(),
128
192
  settingCheck(gatewaySetting, settings),
129
193
  ];
130
194
 
@@ -150,6 +214,25 @@ export const runPreflight = async (args: {
150
214
  });
151
215
  }
152
216
 
217
+ // Which coding-agent CLIs this machine has, for a config that would
218
+ // measure them: what to install or log in to, or what to leave out.
219
+ for (const surface of agentSurfaces) {
220
+ if (agents.includes(surface)) {
221
+ continue;
222
+ }
223
+
224
+ const version = versionForSurface(surface, versions);
225
+
226
+ checks.push({
227
+ name: `${surface} CLI`,
228
+ ok: true,
229
+ detail:
230
+ version === null
231
+ ? `\`${cliNameForSurface(surface)}\` not installed; needed only when the config measures coding agents`
232
+ : `${cliNameForSurface(surface)} ${version} installed; this config does not measure it`,
233
+ });
234
+ }
235
+
153
236
  checks.push(await directoryCheck(args.dir));
154
237
 
155
238
  return checks;
@@ -4,10 +4,11 @@ import { enginePackageRoot } from './package-root';
4
4
 
5
5
  // ============================================================================
6
6
  // The engine's own files (specs/aeo-open-source-cli-spec.md §4.1): the copy
7
- // and author rules, the banlist and the neutral editorial context. A packed
8
- // install carries them in resources/; a checkout reads them in place under
9
- // src/. Never the caller's working directory, and never a publisher's
10
- // private editorial files unless AEO_EDITORIAL_DIR names them.
7
+ // and author rules, the banlist, the neutral editorial context and the
8
+ // operator guide. A packed install carries them in resources/; a checkout
9
+ // reads them in place under src/. Never the caller's working directory, and
10
+ // never a publisher's private editorial files unless AEO_EDITORIAL_DIR names
11
+ // them.
11
12
  // ============================================================================
12
13
 
13
14
  export type EngineResources = {
@@ -15,6 +16,8 @@ export type EngineResources = {
15
16
  root: string;
16
17
  author: string;
17
18
  editorial: string;
19
+ /** The operator guide `literally-aeo guide` prints. */
20
+ guide: string;
18
21
  };
19
22
 
20
23
  const exists = async (file: string) => {
@@ -34,6 +37,7 @@ export const engineResources = async (): Promise<EngineResources> => {
34
37
  root,
35
38
  author: path.join(packed, 'author'),
36
39
  editorial: path.join(packed, 'editorial'),
40
+ guide: path.join(packed, 'guide', 'OPERATOR.md'),
37
41
  };
38
42
  }
39
43
 
@@ -41,5 +45,6 @@ export const engineResources = async (): Promise<EngineResources> => {
41
45
  root,
42
46
  author: path.join(root, 'src', 'author'),
43
47
  editorial: path.join(root, 'src', 'engine', 'editorial'),
48
+ guide: path.join(root, 'src', 'engine', 'guide', 'OPERATOR.md'),
44
49
  };
45
50
  };
@@ -2,6 +2,7 @@ import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { writeFileAtomically } from '../codex-workflow/pending';
5
+ import { isRecord } from '../lib/type-guards';
5
6
 
6
7
  // ============================================================================
7
8
  // What a local run keeps about its own configuration
@@ -50,18 +51,35 @@ export const readRecordedAuthorEvidence = async (
50
51
 
51
52
  /** recordRunConfiguration writes the run's audit.json and author evidence
52
53
  * into its directory, replacing what an earlier invocation wrote. */
54
+ /** The operator's configuration with the model the run actually used. */
55
+ const configWithModel = (text: string, model: string): string => {
56
+ const config: unknown = JSON.parse(text);
57
+
58
+ if (!isRecord(config)) {
59
+ throw new Error('The configuration to record is not a JSON object.');
60
+ }
61
+
62
+ return `${JSON.stringify({ ...config, model }, null, 2)}\n`;
63
+ };
64
+
53
65
  export const recordRunConfiguration = async ({
54
66
  dir,
55
67
  configFile,
56
68
  evidence,
69
+ model,
57
70
  }: {
58
71
  dir: string;
59
72
  configFile: string;
60
73
  evidence: RecordedAuthorEvidence;
74
+ /** A model named outside the file (`rejudge --model`): the recorded
75
+ * configuration is the one the run ran with, not the file's. */
76
+ model?: string;
61
77
  }): Promise<void> => {
78
+ const text = await readFile(configFile, 'utf8');
79
+
62
80
  await writeFileAtomically(
63
81
  path.join(dir, auditCopyFile),
64
- await readFile(configFile, 'utf8'),
82
+ model === undefined ? text : configWithModel(text, model),
65
83
  );
66
84
  await writeFileAtomically(
67
85
  path.join(dir, authorEvidenceFile),