literally-aeo 0.1.0 → 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.
- package/README.md +42 -6
- package/dist/author-tools.js +33 -64
- package/dist/cli.mjs +2723 -1616
- package/dist/lib/agents/author-schema.js +4 -5
- package/dist/lib/agents/author-validation.js +5 -6
- package/dist/lib/agents/copy-validation.js +4 -5
- package/dist/lib/agents/verifier.js +8 -8
- package/dist/lib/analysis/domain-classifier.js +8 -8
- package/dist/lib/analysis/domain-labels.js +3 -4
- package/dist/lib/analysis/progress.js +3 -4
- package/dist/lib/analysis/sentiment.js +8 -8
- package/dist/lib/author/examples.js +5 -6
- package/dist/lib/bundle/contracts.js +5 -6
- package/dist/lib/bundle/export.js +22 -19
- package/dist/lib/bundle/isolation.js +17 -0
- package/dist/lib/bundle/journal.js +6 -7
- package/dist/lib/bundle/project-journal.js +11 -10
- package/dist/lib/bundle/project.js +19 -16
- package/dist/lib/bundle/read.js +23 -20
- package/dist/lib/bundle/recorder.js +9 -8
- package/dist/lib/bundle/redact.js +6 -7
- package/dist/lib/bundle/trace-coverage.js +6 -7
- package/dist/lib/bundle/verify-integrity.js +8 -9
- package/dist/lib/bundle/verify-measurement.js +10 -11
- package/dist/lib/bundle/verify-report.js +11 -12
- package/dist/lib/bundle/verify.js +17 -18
- package/dist/lib/bundle/writer-lock.js +3 -1
- package/dist/lib/capture-manifest.js +3 -4
- package/dist/lib/checks/run-checks.js +10 -9
- package/dist/lib/chunks/chunk-2B5QF6UQ.js +159 -0
- package/dist/lib/chunks/{chunk-4US3OBKJ.js → chunk-2GU6CNQI.js} +12 -7
- package/dist/lib/chunks/{chunk-AWOJWMPN.js → chunk-2ROXN2EC.js} +42 -7
- package/dist/lib/chunks/{chunk-XHWRSGX3.js → chunk-3JO5TXBA.js} +1 -1
- package/dist/lib/chunks/{chunk-5GZVDGTX.js → chunk-4PD65FRJ.js} +7 -3
- package/dist/lib/chunks/{chunk-P4K6BP3L.js → chunk-5JPYM4MD.js} +1 -1
- package/dist/lib/chunks/{chunk-5VNYUCLL.js → chunk-622NMXN6.js} +6 -9
- package/dist/lib/chunks/{chunk-4ZY6P5SO.js → chunk-663HABKP.js} +5 -5
- package/dist/lib/chunks/{chunk-RMFT4KKK.js → chunk-6G25V4CF.js} +1 -1
- package/dist/lib/chunks/{chunk-GVC4LH2N.js → chunk-6GHHNPFJ.js} +1 -1
- package/dist/lib/chunks/{chunk-KMRQSIZW.js → chunk-6GOBBNDU.js} +16 -1
- package/dist/lib/chunks/{chunk-SBAZBOPI.js → chunk-6P7EZJI7.js} +4 -2
- package/dist/lib/chunks/chunk-7XO3SQAX.js +117 -0
- package/dist/lib/chunks/{chunk-M2OD74GP.js → chunk-7Z27HQWL.js} +3 -3
- package/dist/lib/chunks/{chunk-IPNK7FYT.js → chunk-AYY4MYTW.js} +1 -1
- package/dist/lib/chunks/{chunk-WDSCJEDG.js → chunk-BE4ENGUY.js} +10 -10
- package/dist/lib/chunks/{chunk-FKLNEB2P.js → chunk-BGOIPHJZ.js} +39 -11
- package/dist/lib/chunks/{chunk-7GXRDAUY.js → chunk-BLKLPUYR.js} +2 -2
- package/dist/lib/chunks/chunk-BSRKN6FU.js +93 -0
- package/dist/lib/chunks/{chunk-PCYNBDZ7.js → chunk-CO5T6WU5.js} +14 -9
- package/dist/lib/chunks/{chunk-BEQLSAVX.js → chunk-CUYVHXHI.js} +2 -2
- package/dist/lib/chunks/{chunk-RBOO4NDG.js → chunk-D3GE3OCB.js} +1 -1
- package/dist/lib/chunks/chunk-DVFFYY5G.js +74 -0
- package/dist/lib/chunks/{chunk-5H3SNUQT.js → chunk-EBUQPCKB.js} +1 -1
- package/dist/lib/chunks/{chunk-4E4NDGOZ.js → chunk-EE26FNSY.js} +1 -1
- package/dist/lib/chunks/{chunk-AUB5THIS.js → chunk-EJ655TVU.js} +1 -1
- package/dist/lib/chunks/{chunk-S2AM76LT.js → chunk-F4W5YHDZ.js} +2 -2
- package/dist/lib/chunks/chunk-FAUFE7MI.js +31 -0
- package/dist/lib/chunks/{chunk-2KJZ326K.js → chunk-FOCJ7HPC.js} +7 -7
- package/dist/lib/chunks/{chunk-OL746E4T.js → chunk-FUAUPNRO.js} +26 -18
- package/dist/lib/chunks/{chunk-J6IJGYP5.js → chunk-G62E525I.js} +2 -2
- package/dist/lib/chunks/{chunk-2NJEWPCV.js → chunk-GDKGZQ3T.js} +2 -2
- package/dist/lib/chunks/{chunk-HSZ3DM74.js → chunk-GEFKDW7X.js} +15 -2
- package/dist/lib/chunks/{chunk-CS24IL3K.js → chunk-GESHTTSA.js} +2 -2
- package/dist/lib/chunks/chunk-GNMFJ2OK.js +321 -0
- package/dist/lib/chunks/{chunk-H3G3VTT7.js → chunk-HFRAHG5C.js} +44 -26
- package/dist/lib/chunks/{chunk-MHAKYFDF.js → chunk-HQG63ZKO.js} +11 -11
- package/dist/lib/chunks/{chunk-OORO55OM.js → chunk-HTOD4W4E.js} +21 -6
- package/dist/lib/chunks/{chunk-Q2PWES4B.js → chunk-I3XGRGXE.js} +1 -1
- package/dist/lib/chunks/{chunk-WUELMJ22.js → chunk-IE7NAL6B.js} +1 -1
- package/dist/lib/chunks/{chunk-KRFHQQS7.js → chunk-JXMDOAKA.js} +17 -17
- package/dist/lib/chunks/{chunk-S7KJZIUR.js → chunk-KJMU5KH4.js} +2 -2
- package/dist/lib/chunks/{chunk-2ROSV4HD.js → chunk-L7MEIRJB.js} +1 -1
- package/dist/lib/chunks/{chunk-CPT2GKKW.js → chunk-LOBXOZ2R.js} +1 -1
- package/dist/lib/chunks/{chunk-IAR6XGEW.js → chunk-ML4W6KC6.js} +1 -1
- package/dist/lib/chunks/{chunk-WKH6BJAZ.js → chunk-MNWO7EHC.js} +4 -4
- package/dist/lib/chunks/{chunk-D2LPQO6Y.js → chunk-MRL5RUP7.js} +1 -1
- package/dist/lib/chunks/{chunk-IEVAFDW7.js → chunk-NCXSNHXX.js} +3 -3
- package/dist/lib/chunks/{chunk-AKKFERA4.js → chunk-NGHAP2P5.js} +4 -4
- package/dist/lib/chunks/{chunk-ZLOOC46D.js → chunk-OKL7GN2F.js} +3 -3
- package/dist/lib/chunks/{chunk-YOZNLFSB.js → chunk-OQU5IXAJ.js} +5 -5
- package/dist/lib/chunks/{chunk-I7VNIW6Q.js → chunk-OU73OUX4.js} +16 -10
- package/dist/lib/chunks/{chunk-56VOFZ7T.js → chunk-QHUDJVPJ.js} +90 -24
- package/dist/lib/chunks/{chunk-WTQWU522.js → chunk-QSJ4IKUF.js} +9 -9
- package/dist/lib/chunks/{chunk-FBFZBLTY.js → chunk-R6XDZWUL.js} +7 -8
- package/dist/lib/chunks/{chunk-CJ5YD3CU.js → chunk-RJ5R6YYA.js} +5 -5
- package/dist/lib/chunks/{chunk-5EX5DKMA.js → chunk-RR46EDDR.js} +33 -25
- package/dist/lib/chunks/chunk-RYCRL3YA.js +106 -0
- package/dist/lib/chunks/{chunk-Z4LMDKBU.js → chunk-SHUMCKCS.js} +2 -2
- package/dist/lib/chunks/{chunk-3EBWDHPK.js → chunk-TJQ5OPLQ.js} +10 -12
- package/dist/lib/chunks/chunk-U64NCRRR.js +97 -0
- package/dist/lib/chunks/chunk-U772TN32.js +67 -0
- package/dist/lib/chunks/{chunk-YR67JG2V.js → chunk-UEMZYHYJ.js} +8 -3
- package/dist/lib/chunks/{chunk-J46W3EMQ.js → chunk-UZJSTJFP.js} +5 -5
- package/dist/lib/chunks/{chunk-XJVXASDD.js → chunk-V7OAPKNF.js} +3 -3
- package/dist/lib/chunks/{chunk-WE2WPNG2.js → chunk-VKM6MMA4.js} +66 -7
- package/dist/lib/chunks/{chunk-YWJPJI3W.js → chunk-VL253W5C.js} +3 -1
- package/dist/lib/chunks/{chunk-XU6WQ5UL.js → chunk-VPZQGND4.js} +3 -3
- package/dist/lib/chunks/{chunk-X2Y2ZNG3.js → chunk-W2VGLWTS.js} +3 -3
- package/dist/lib/chunks/{chunk-6AUEDSTU.js → chunk-W5DC23OP.js} +1 -1
- package/dist/lib/chunks/chunk-W5X7WJYL.js +91 -0
- package/dist/lib/chunks/{chunk-QFVRCSJ2.js → chunk-WDOA5JEH.js} +2 -0
- package/dist/lib/chunks/{chunk-6KO7HGCQ.js → chunk-WVACVWBL.js} +2 -2
- package/dist/lib/chunks/{chunk-MIF5IYNR.js → chunk-XDG6NPJB.js} +26 -29
- package/dist/lib/chunks/{chunk-X6E44EGV.js → chunk-XR44YSHT.js} +2 -2
- package/dist/lib/chunks/chunk-Y2CZ6FZY.js +61 -0
- package/dist/lib/chunks/{chunk-5KKLUM7M.js → chunk-YAAUWCJ4.js} +1 -1
- package/dist/lib/chunks/{chunk-N2ZZ6JRF.js → chunk-YRBIC5QH.js} +1 -1
- package/dist/lib/chunks/chunk-ZIGNJAPC.js +11 -0
- package/dist/lib/cli/bundle-commands.js +71 -65
- package/dist/lib/cli/guide-command.js +25 -0
- package/dist/lib/cli/io.js +1 -1
- package/dist/lib/cli/run-commands.js +270 -104
- package/dist/lib/cli/status-command.js +234 -0
- package/dist/lib/codex-workflow/aggregate.js +8 -9
- package/dist/lib/codex-workflow/author-tools.js +6 -7
- package/dist/lib/codex-workflow/author.js +17 -17
- package/dist/lib/codex-workflow/capture.js +10 -9
- package/dist/lib/codex-workflow/checkpoint.js +6 -7
- package/dist/lib/codex-workflow/checks.js +6 -7
- package/dist/lib/codex-workflow/codex-binary.js +13 -0
- package/dist/lib/codex-workflow/codex-home.js +6 -3
- package/dist/lib/codex-workflow/copy-editor.js +14 -14
- package/dist/lib/codex-workflow/copy-recovery.js +3 -4
- package/dist/lib/codex-workflow/copy.js +11 -11
- package/dist/lib/codex-workflow/finish.js +17 -18
- package/dist/lib/codex-workflow/host-models.js +7 -7
- package/dist/lib/codex-workflow/loop.js +42 -38
- package/dist/lib/codex-workflow/quality.js +3 -4
- package/dist/lib/codex-workflow/run-inputs.js +5 -6
- package/dist/lib/codex-workflow/run-source.js +14 -13
- package/dist/lib/codex-workflow/schemas.js +5 -6
- package/dist/lib/codex-workflow/session.js +7 -8
- package/dist/lib/codex-workflow/stage.js +26 -23
- package/dist/lib/codex-workflow/workdir.js +6 -7
- package/dist/lib/engine/audit-file.js +7 -6
- package/dist/lib/engine/author.js +37 -31
- package/dist/lib/engine/budget.js +7 -1
- package/dist/lib/engine/cost-estimate.js +41 -0
- package/dist/lib/engine/local-run.js +48 -42
- package/dist/lib/engine/preflight.js +10 -6
- package/dist/lib/engine/rejudge.js +56 -50
- package/dist/lib/engine/resources.js +1 -1
- package/dist/lib/engine/run-configuration.js +2 -1
- package/dist/lib/engine/run-status.js +151 -0
- package/dist/lib/engine/templates.js +8 -7
- package/dist/lib/grounding/controller.js +7 -7
- package/dist/lib/grounding/extract.js +6 -6
- package/dist/lib/grounding/grounding-runtime.js +18 -17
- package/dist/lib/grounding/model.js +5 -5
- package/dist/lib/grounding/recorded-tools.js +10 -9
- package/dist/lib/harness/report/artifacts.js +4 -5
- package/dist/lib/lib/checkpoint.js +3 -4
- package/dist/lib/models/batching.js +5 -5
- package/dist/lib/models/cost-coefficients.js +20 -0
- package/dist/lib/models/local-profile.js +10 -0
- package/dist/lib/models/pricing.js +6 -0
- package/dist/lib/models/profiles.js +7 -14
- package/dist/lib/models/structured-images.js +1 -1
- package/dist/lib/models/structured.js +4 -4
- package/dist/lib/models/supported-models.js +20 -0
- package/dist/lib/pipeline.js +9 -8
- package/dist/lib/probes/agent-cli-parsers.js +1 -1
- package/dist/lib/probes/agent-clis.js +6 -5
- package/dist/lib/probes/charged-trace.js +10 -0
- package/dist/lib/probes/probes.js +6 -6
- package/dist/lib/runner.js +10 -10
- package/dist/lib/schema.js +3 -4
- package/dist/lib/section-result.js +3 -4
- package/dist/lib/stores/artifacts.js +3 -4
- package/dist/lib/stores/files.js +9 -9
- package/dist/lib/stores/local-versions.js +4 -5
- package/dist/lib/stores/memory.js +6 -7
- package/dist/lib/stores/publication.js +5 -6
- package/dist/lib/viewer/server.js +18 -19
- package/dist/lib/workflow/schema.js +2 -3
- package/dist/types/agents/copy-validation.d.ts +4 -4
- package/dist/types/agents/verifier.d.ts +6 -6
- package/dist/types/bundle/contracts.d.ts +1 -1
- package/dist/types/bundle/isolation.d.ts +37 -0
- package/dist/types/bundle/project-journal.d.ts +2 -0
- package/dist/types/bundle/recorder.d.ts +4 -0
- package/dist/types/bundle/writer-lock.d.ts +9 -0
- package/dist/types/cli/guide-command.d.ts +4 -0
- package/dist/types/cli/status-command.d.ts +2 -0
- package/dist/types/codex-workflow/codex-binary.d.ts +26 -0
- package/dist/types/codex-workflow/codex-home.d.ts +24 -20
- package/dist/types/codex-workflow/copy-editor.d.ts +1 -1
- package/dist/types/codex-workflow/copy.d.ts +3 -4
- package/dist/types/codex-workflow/finish.d.ts +5 -3
- package/dist/types/codex-workflow/host-models.d.ts +7 -3
- package/dist/types/codex-workflow/loop.d.ts +10 -1
- package/dist/types/codex-workflow/run-inputs.d.ts +28 -113
- package/dist/types/codex-workflow/stage.d.ts +16 -5
- package/dist/types/engine/audit-file.d.ts +3 -2
- package/dist/types/engine/author.d.ts +7 -1
- package/dist/types/engine/budget.d.ts +46 -15
- package/dist/types/engine/cost-estimate.d.ts +40 -0
- package/dist/types/engine/local-run.d.ts +6 -0
- package/dist/types/engine/preflight.d.ts +5 -0
- package/dist/types/engine/resources.d.ts +2 -0
- package/dist/types/engine/run-configuration.d.ts +4 -3
- package/dist/types/engine/run-status.d.ts +75 -0
- package/dist/types/engine/templates.d.ts +1 -2
- package/dist/types/models/cost-coefficients.d.ts +106 -0
- package/dist/types/models/local-profile.d.ts +12 -0
- package/dist/types/models/pricing.d.ts +8 -0
- package/dist/types/models/profiles.d.ts +55 -160
- package/dist/types/models/served-model.d.ts +2 -3
- package/dist/types/models/structured.d.ts +3 -3
- package/dist/types/models/supported-models.d.ts +48 -0
- package/dist/types/probes/charged-trace.d.ts +8 -0
- package/dist/types/probes/probe-trace.d.ts +2 -0
- package/dist/types/schema.d.ts +28 -113
- package/dist/types/workflow/schema.d.ts +79 -152
- package/package.json +2 -1
- package/resources/guide/OPERATOR.md +180 -0
- package/src/agents/copy-validation.ts +8 -12
- package/src/agents/verifier.ts +10 -14
- package/src/bundle/contracts.ts +3 -3
- package/src/bundle/isolation.ts +157 -0
- package/src/bundle/project-journal.ts +4 -0
- package/src/bundle/project.ts +20 -7
- package/src/bundle/recorder.ts +5 -0
- package/src/bundle/writer-lock.ts +27 -0
- package/src/cli/guide-command.ts +28 -0
- package/src/cli/io.ts +2 -0
- package/src/cli/literally-aeo.ts +39 -19
- package/src/cli/run-commands.ts +236 -18
- package/src/cli/status-command.ts +113 -0
- package/src/codex-workflow/codex-binary.ts +105 -0
- package/src/codex-workflow/codex-home.ts +50 -40
- package/src/codex-workflow/copy.ts +7 -10
- package/src/codex-workflow/finish.ts +13 -8
- package/src/codex-workflow/host-models.ts +33 -24
- package/src/codex-workflow/loop.ts +36 -9
- package/src/codex-workflow/stage.ts +126 -17
- package/src/engine/audit-file.ts +10 -8
- package/src/engine/author.ts +47 -2
- package/src/engine/budget.ts +138 -43
- package/src/engine/cost-estimate.ts +178 -0
- package/src/engine/guide/OPERATOR.md +180 -0
- package/src/engine/local-run.ts +38 -8
- package/src/engine/preflight.ts +90 -7
- package/src/engine/resources.ts +9 -4
- package/src/engine/run-configuration.ts +19 -1
- package/src/engine/run-status.ts +452 -0
- package/src/engine/templates.ts +5 -2
- package/src/models/cost-coefficients.ts +140 -0
- package/src/models/local-profile.ts +150 -0
- package/src/models/pricing.ts +31 -0
- package/src/models/profiles.ts +58 -419
- package/src/models/served-model.ts +2 -3
- package/src/models/structured-images.ts +5 -4
- package/src/models/structured.ts +20 -7
- package/src/models/supported-models.ts +112 -0
- package/src/probes/agent-clis.ts +24 -2
- package/src/probes/charged-trace.ts +87 -0
- package/src/probes/probe-trace.ts +2 -0
- package/src/probes/probes.ts +48 -2
- package/dist/lib/chunks/chunk-CFFPOTP4.js +0 -356
- package/dist/lib/chunks/chunk-LIZX4N3H.js +0 -110
- package/dist/lib/chunks/chunk-OYKV5NDM.js +0 -28
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
codexStageModelSchema,
|
|
4
|
+
internalModelRoleSchema,
|
|
5
|
+
modelPricingSchema,
|
|
6
|
+
} from './profiles';
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// The models a local run may judge, research and write with
|
|
10
|
+
// (specs/aeo-claude-operator-spec.md §4.1): one gateway model runs every
|
|
11
|
+
// text role and the Codex stages. Each entry holds public facts only (list
|
|
12
|
+
// prices with the date they were checked, the context window, the output
|
|
13
|
+
// ceiling) and what the engine has verified about it. Adding or changing a
|
|
14
|
+
// model is a release of the package; a run records the profile built from
|
|
15
|
+
// the entry it resolved (src/models/local-profile.ts).
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
export const supportedModelSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
/** The gateway model ID, as audit.json's `model` names it. */
|
|
21
|
+
id: z.string().min(1),
|
|
22
|
+
label: z.string().min(1),
|
|
23
|
+
pricingUsdPerMillion: modelPricingSchema,
|
|
24
|
+
pricingCheckedAt: z.iso.date(),
|
|
25
|
+
contextWindow: z.number().int().positive(),
|
|
26
|
+
maxOutputTokens: z.number().int().positive(),
|
|
27
|
+
/** The model's hidden reasoning is billed inside the output allowance,
|
|
28
|
+
* so every role is given room to think on top of its answer. */
|
|
29
|
+
thinkingInOutput: z.boolean(),
|
|
30
|
+
providerOptions: internalModelRoleSchema.shape.providerOptions,
|
|
31
|
+
stageReasoningEffort: codexStageModelSchema.shape.reasoningEffort,
|
|
32
|
+
/** The date a real batch ran through the gateway on Codex's Responses
|
|
33
|
+
* wire API with this model (the spike, spec §4.3); null until then. */
|
|
34
|
+
stageRuntimeVerifiedAt: z.iso.date().nullable(),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
|
|
38
|
+
export type SupportedModel = z.infer<typeof supportedModelSchema>;
|
|
39
|
+
|
|
40
|
+
export const supportedModels: readonly SupportedModel[] = [
|
|
41
|
+
{
|
|
42
|
+
id: 'anthropic/claude-opus-5.5',
|
|
43
|
+
label: 'Claude Opus 5.5',
|
|
44
|
+
pricingUsdPerMillion: { input: 4, output: 20, cachedInput: 0.2 },
|
|
45
|
+
pricingCheckedAt: '2026-11-04',
|
|
46
|
+
contextWindow: 1_000_000,
|
|
47
|
+
maxOutputTokens: 128_000,
|
|
48
|
+
thinkingInOutput: true,
|
|
49
|
+
providerOptions: { gateway: { reasoning: { effort: 'high' } } },
|
|
50
|
+
stageReasoningEffort: 'high',
|
|
51
|
+
stageRuntimeVerifiedAt: '2026-11-04',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'anthropic/claude-sonnet-5.5',
|
|
55
|
+
label: 'Claude Sonnet 5.5',
|
|
56
|
+
pricingUsdPerMillion: { input: 2, output: 10, cachedInput: 0.2 },
|
|
57
|
+
pricingCheckedAt: '2026-11-04',
|
|
58
|
+
contextWindow: 1_000_000,
|
|
59
|
+
maxOutputTokens: 128_000,
|
|
60
|
+
thinkingInOutput: true,
|
|
61
|
+
providerOptions: { gateway: { reasoning: { effort: 'high' } } },
|
|
62
|
+
stageReasoningEffort: 'high',
|
|
63
|
+
stageRuntimeVerifiedAt: '2026-11-04',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** The model a run uses when audit.json names none: the strongest the
|
|
68
|
+
* engine supports, because judgment and copy quality are the report. */
|
|
69
|
+
export const recommendedModelId = 'anthropic/claude-opus-5.5';
|
|
70
|
+
|
|
71
|
+
/** The supported models as a list a person or an agent can read. */
|
|
72
|
+
export const describeSupportedModels = (): string[] => {
|
|
73
|
+
const lines = supportedModels.map((model) => {
|
|
74
|
+
const { input, cachedInput, output } = model.pricingUsdPerMillion;
|
|
75
|
+
const recommended = model.id === recommendedModelId ? ' (recommended)' : '';
|
|
76
|
+
|
|
77
|
+
return `${model.id}${recommended}: ${model.label}, $${input} in / $${cachedInput} cached / $${output} out per million tokens (checked ${model.pricingCheckedAt})`;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return lines;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** findSupportedModel returns the list's entry for a gateway model ID. */
|
|
84
|
+
export const findSupportedModel = (id: string): SupportedModel | undefined => {
|
|
85
|
+
return supportedModels.find((model) => model.id === id);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export class UnsupportedModelError extends Error {
|
|
89
|
+
constructor(id: string) {
|
|
90
|
+
super(
|
|
91
|
+
[
|
|
92
|
+
`${id} is not a supported model. Set audit.json's "model" to one of:`,
|
|
93
|
+
...describeSupportedModels().map((line) => ` ${line}`),
|
|
94
|
+
].join('\n'),
|
|
95
|
+
);
|
|
96
|
+
this.name = 'UnsupportedModelError';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** resolveSupportedModel returns the entry a run uses: the named model, or
|
|
101
|
+
* the recommended one when none is named. An unknown ID is refused. */
|
|
102
|
+
export const resolveSupportedModel = (
|
|
103
|
+
id: string = recommendedModelId,
|
|
104
|
+
): SupportedModel => {
|
|
105
|
+
const model = findSupportedModel(id);
|
|
106
|
+
|
|
107
|
+
if (!model) {
|
|
108
|
+
throw new UnsupportedModelError(id);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return model;
|
|
112
|
+
};
|
package/src/probes/agent-clis.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { agentSurfaces, surfaceRunCounts, retrievalLogSchema } from '../schema';
|
|
|
14
14
|
import { createLog } from '../lib/log';
|
|
15
15
|
import { isRecord } from '../lib/type-guards';
|
|
16
16
|
import { getEnvironment, readEnv } from '../lib/env';
|
|
17
|
+
import { codexArgs, resolveCodexBinary } from '../codex-workflow/codex-binary';
|
|
17
18
|
import type { ProbePromptInput, ProbeResult } from './probes';
|
|
18
19
|
import {
|
|
19
20
|
AgentStreamError,
|
|
@@ -321,6 +322,23 @@ const probeForSurface = (surface: AeoAgentSurface): AgentProbeFn => {
|
|
|
321
322
|
}
|
|
322
323
|
};
|
|
323
324
|
|
|
325
|
+
/** What to spawn for an agent CLI on this machine. Codex is this package's
|
|
326
|
+
* own pinned dependency (specs/aeo-claude-operator-spec.md §4.3), run with
|
|
327
|
+
* the operator's Codex login when it is measured; the others come from
|
|
328
|
+
* PATH. */
|
|
329
|
+
const localCommand = (
|
|
330
|
+
command: string,
|
|
331
|
+
args: readonly string[],
|
|
332
|
+
): { command: string; args: string[] } => {
|
|
333
|
+
if (command !== 'codex') {
|
|
334
|
+
return { command, args: [...args] };
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const binary = resolveCodexBinary();
|
|
338
|
+
|
|
339
|
+
return { command: binary.command, args: codexArgs(binary, args) };
|
|
340
|
+
};
|
|
341
|
+
|
|
324
342
|
const cliVersion = async (
|
|
325
343
|
command: string,
|
|
326
344
|
args: string[],
|
|
@@ -340,7 +358,10 @@ const cliVersion = async (
|
|
|
340
358
|
requireWorkerTransport();
|
|
341
359
|
}
|
|
342
360
|
|
|
343
|
-
const
|
|
361
|
+
const local = localCommand(command, args);
|
|
362
|
+
const { stdout } = await execFileAsync(local.command, local.args, {
|
|
363
|
+
timeout: 15_000,
|
|
364
|
+
});
|
|
344
365
|
|
|
345
366
|
return stdout.trim().split('\n')[0] ?? null;
|
|
346
367
|
} catch {
|
|
@@ -1218,7 +1239,8 @@ const execCli = async (
|
|
|
1218
1239
|
command: string,
|
|
1219
1240
|
{ cliArgs, cwd, runtime, env, signal }: ExecCliOptions,
|
|
1220
1241
|
): Promise<CliOutput> => {
|
|
1221
|
-
const
|
|
1242
|
+
const local = localCommand(command, cliArgs);
|
|
1243
|
+
const result = await runChild(local.command, local.args, {
|
|
1222
1244
|
cwd,
|
|
1223
1245
|
env,
|
|
1224
1246
|
timeoutMs: runtime.timeoutMs ?? agentProbeTimeoutMs,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import {
|
|
3
|
+
ModelBudgetError,
|
|
4
|
+
type ModelCallAccounting,
|
|
5
|
+
} from '../models/accounting';
|
|
6
|
+
import { probeUsd } from '../models/cost-coefficients';
|
|
7
|
+
import type { ProbeTrace } from './probe-trace';
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Probes on the run's ledger (specs/aeo-claude-operator-spec.md §4.2): every
|
|
11
|
+
// probe attempt is reserved at its surface's high estimate before it is
|
|
12
|
+
// dispatched and settled with the cost the gateway reported; one that
|
|
13
|
+
// reported none keeps charging its estimate. An attempt the cap cannot afford is never
|
|
14
|
+
// dispatched; the run learns of it through `exhausted` and stops resumable,
|
|
15
|
+
// with every answer captured so far banked.
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
export type ChargedTrace = {
|
|
19
|
+
trace: ProbeTrace;
|
|
20
|
+
/** The first refusal of the cap, once an attempt was refused. */
|
|
21
|
+
exhausted: () => ModelBudgetError | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const chargedProbeTrace = (
|
|
25
|
+
trace: ProbeTrace,
|
|
26
|
+
ledger: ModelCallAccounting,
|
|
27
|
+
): ChargedTrace => {
|
|
28
|
+
let refused: ModelBudgetError | undefined;
|
|
29
|
+
|
|
30
|
+
const charged: ProbeTrace = {
|
|
31
|
+
start: async (attempt) => {
|
|
32
|
+
const estimateUsd = probeUsd[attempt.surface].high;
|
|
33
|
+
const callId = `probe:${attempt.surface}:${attempt.promptId}:${attempt.runIndex}:${attempt.attempt}:${randomUUID()}`;
|
|
34
|
+
// The coding-agent surfaces run on the operator's own login.
|
|
35
|
+
const isPaid = estimateUsd > 0;
|
|
36
|
+
|
|
37
|
+
if (isPaid) {
|
|
38
|
+
try {
|
|
39
|
+
await ledger.reserve({
|
|
40
|
+
callId,
|
|
41
|
+
role: `probe:${attempt.surface}`,
|
|
42
|
+
...(attempt.requestedModel !== null && {
|
|
43
|
+
requestedModel: attempt.requestedModel,
|
|
44
|
+
}),
|
|
45
|
+
reservedUsd: estimateUsd,
|
|
46
|
+
inputTokens: 0,
|
|
47
|
+
maxOutputTokens: 0,
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error instanceof ModelBudgetError) {
|
|
51
|
+
refused ??= error;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const handle = await trace.start(attempt);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
id: handle.id,
|
|
62
|
+
end: async (result) => {
|
|
63
|
+
await handle.end(result);
|
|
64
|
+
|
|
65
|
+
if (!isPaid) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const reportedUsd =
|
|
70
|
+
result.outcome === 'succeeded' ? result.costUsd : undefined;
|
|
71
|
+
|
|
72
|
+
// Without a reported cost the call keeps charging its estimate,
|
|
73
|
+
// and the ledger records no cost the provider did not report.
|
|
74
|
+
await ledger.settle(callId, {
|
|
75
|
+
...(attempt.requestedModel !== null && {
|
|
76
|
+
requestedModel: attempt.requestedModel,
|
|
77
|
+
}),
|
|
78
|
+
...(reportedUsd !== undefined && { costUsd: reportedUsd }),
|
|
79
|
+
...(result.outcome !== 'succeeded' && { valid: false }),
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return { trace: charged, exhausted: () => refused };
|
|
87
|
+
};
|
package/src/probes/probes.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { chatSurfaces, surfaceRunCounts } from '../schema';
|
|
|
8
8
|
import { surfaceRetrievalExposure } from '../retrieval';
|
|
9
9
|
import { createLog } from '../lib/log';
|
|
10
10
|
import { servedModelOf } from '../models/served-model';
|
|
11
|
+
import { isObject } from '../lib/type-guards';
|
|
11
12
|
import {
|
|
12
13
|
endAttempt,
|
|
13
14
|
ProbeTraceError,
|
|
@@ -141,6 +142,36 @@ type ProbeAnswer = {
|
|
|
141
142
|
retrieval: RetrievalLog | null;
|
|
142
143
|
noOverview?: true;
|
|
143
144
|
reportedModel?: string;
|
|
145
|
+
/** What the gateway reported the probe's calls cost; absent when it did
|
|
146
|
+
* not say. The ledger then settles the probe at its estimate. */
|
|
147
|
+
reportedCostUsd?: number;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** The cost the gateway reports in a response's provider metadata. */
|
|
151
|
+
const gatewayCostOf = (metadata: unknown): number | undefined => {
|
|
152
|
+
const cost =
|
|
153
|
+
isObject(metadata) && isObject(metadata.gateway)
|
|
154
|
+
? metadata.gateway.cost
|
|
155
|
+
: undefined;
|
|
156
|
+
const usd = typeof cost === 'string' && cost.trim() ? Number(cost) : cost;
|
|
157
|
+
|
|
158
|
+
return typeof usd === 'number' && Number.isFinite(usd) && usd >= 0
|
|
159
|
+
? usd
|
|
160
|
+
: undefined;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/** The reported costs of a probe's calls, summed; absent unless every call
|
|
164
|
+
* reported one. */
|
|
165
|
+
const reportedCostOf = (
|
|
166
|
+
costs: readonly (number | undefined)[],
|
|
167
|
+
): { reportedCostUsd?: number } => {
|
|
168
|
+
if (costs.some((cost) => cost === undefined)) {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
reportedCostUsd: costs.reduce<number>((sum, cost) => sum + (cost ?? 0), 0),
|
|
174
|
+
};
|
|
144
175
|
};
|
|
145
176
|
|
|
146
177
|
type ProbeModelConfig = {
|
|
@@ -289,11 +320,14 @@ const runSearchRequiredProbe = async (args: {
|
|
|
289
320
|
retrieval = null;
|
|
290
321
|
}
|
|
291
322
|
|
|
323
|
+
const firstCost = gatewayCostOf(first.providerMetadata);
|
|
324
|
+
|
|
292
325
|
if (first.text.trim().length > 0) {
|
|
293
326
|
return {
|
|
294
327
|
text: withProbeSources(first.text, first.sources),
|
|
295
328
|
retrieval,
|
|
296
329
|
...served,
|
|
330
|
+
...reportedCostOf([firstCost]),
|
|
297
331
|
};
|
|
298
332
|
}
|
|
299
333
|
|
|
@@ -329,9 +363,10 @@ const runSearchRequiredProbe = async (args: {
|
|
|
329
363
|
abortSignal: AbortSignal.timeout(chatProbeTimeoutMs),
|
|
330
364
|
});
|
|
331
365
|
|
|
332
|
-
const [followupText, followupSources] = await Promise.all([
|
|
366
|
+
const [followupText, followupSources, followupMetadata] = await Promise.all([
|
|
333
367
|
followupStream.text,
|
|
334
368
|
followupStream.sources,
|
|
369
|
+
followupStream.providerMetadata,
|
|
335
370
|
]).catch((error: unknown) => {
|
|
336
371
|
throw followupFailure ?? error;
|
|
337
372
|
});
|
|
@@ -346,6 +381,7 @@ const runSearchRequiredProbe = async (args: {
|
|
|
346
381
|
),
|
|
347
382
|
retrieval,
|
|
348
383
|
...served,
|
|
384
|
+
...reportedCostOf([firstCost, gatewayCostOf(followupMetadata)]),
|
|
349
385
|
};
|
|
350
386
|
}
|
|
351
387
|
|
|
@@ -443,8 +479,14 @@ const buildProbeModels = (args: {
|
|
|
443
479
|
stream.text,
|
|
444
480
|
stream.sources,
|
|
445
481
|
stream.response,
|
|
482
|
+
stream.providerMetadata,
|
|
446
483
|
])
|
|
447
|
-
.then(([text, sources, response]) => ({
|
|
484
|
+
.then(([text, sources, response, providerMetadata]) => ({
|
|
485
|
+
text,
|
|
486
|
+
sources,
|
|
487
|
+
response,
|
|
488
|
+
providerMetadata,
|
|
489
|
+
}))
|
|
448
490
|
.catch((error: unknown) => {
|
|
449
491
|
throw streamFailure ?? error;
|
|
450
492
|
});
|
|
@@ -465,6 +507,7 @@ const buildProbeModels = (args: {
|
|
|
465
507
|
text: withProbeSources(result.text, result.sources),
|
|
466
508
|
retrieval: unexposedRetrieval('perplexity'),
|
|
467
509
|
...(reportedModel === undefined ? {} : { reportedModel }),
|
|
510
|
+
...reportedCostOf([gatewayCostOf(result.providerMetadata)]),
|
|
468
511
|
};
|
|
469
512
|
},
|
|
470
513
|
},
|
|
@@ -744,6 +787,9 @@ const runChatUnit = async (
|
|
|
744
787
|
requestedModel: chatProbeRequestedModel(model.name),
|
|
745
788
|
...(answer.reportedModel ? { reportedModel: answer.reportedModel } : {}),
|
|
746
789
|
...(answer.noOverview ? { noOverview: true as const } : {}),
|
|
790
|
+
...(answer.reportedCostUsd === undefined
|
|
791
|
+
? {}
|
|
792
|
+
: { costUsd: answer.reportedCostUsd }),
|
|
747
793
|
});
|
|
748
794
|
|
|
749
795
|
if (unrecorded !== null) {
|