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.
- 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-ZBDUE3A5.js → chunk-2GU6CNQI.js} +12 -7
- package/dist/lib/chunks/{chunk-CKUTDJAB.js → chunk-2ROXN2EC.js} +42 -7
- package/dist/lib/chunks/{chunk-XHWRSGX3.js → chunk-3JO5TXBA.js} +1 -1
- package/dist/lib/chunks/{chunk-XL4JIQ5X.js → chunk-4PD65FRJ.js} +7 -3
- package/dist/lib/chunks/{chunk-GMKF2FU4.js → chunk-5JPYM4MD.js} +1 -1
- package/dist/lib/chunks/{chunk-5VNYUCLL.js → chunk-622NMXN6.js} +6 -9
- package/dist/lib/chunks/{chunk-XNRSHATN.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-SWS3K62X.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-E3OEE5XN.js → chunk-CUYVHXHI.js} +2 -2
- package/dist/lib/chunks/{chunk-2GY42RIJ.js → chunk-D3GE3OCB.js} +1 -1
- package/dist/lib/chunks/chunk-DVFFYY5G.js +74 -0
- package/dist/lib/chunks/{chunk-ZXGATMMH.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-FNDJUELJ.js → chunk-FOCJ7HPC.js} +7 -7
- package/dist/lib/chunks/{chunk-FPAN3VRW.js → chunk-FUAUPNRO.js} +26 -18
- package/dist/lib/chunks/{chunk-OQVIRYT5.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-47IZBMP2.js → chunk-GESHTTSA.js} +2 -2
- package/dist/lib/chunks/chunk-GNMFJ2OK.js +321 -0
- package/dist/lib/chunks/{chunk-NVBMIPXR.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-POUSX3T4.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-HFOYASRQ.js → chunk-NGHAP2P5.js} +4 -4
- package/dist/lib/chunks/{chunk-ZLOOC46D.js → chunk-OKL7GN2F.js} +3 -3
- package/dist/lib/chunks/{chunk-3DG7GHFA.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-KHU5DRBE.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-LPND3VNQ.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-MD4AVTK2.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-I3TMFPK4.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-3KQFLOC7.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
package/src/engine/budget.ts
CHANGED
|
@@ -6,42 +6,59 @@ import type { ModelBudgetLimits } from '../models/accounting';
|
|
|
6
6
|
import { hasErrorCode } from '../stores/fs-errors';
|
|
7
7
|
|
|
8
8
|
// ============================================================================
|
|
9
|
-
// A local run's budget (specs/aeo-open-source-cli-spec.md §6
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// and
|
|
9
|
+
// A local run's budget (specs/aeo-open-source-cli-spec.md §6,
|
|
10
|
+
// specs/aeo-claude-operator-spec.md §4.2): finite dollar, token and time
|
|
11
|
+
// allowances, frozen with the run and its model and kept across restarts.
|
|
12
|
+
// The dollar cap is the amount the operator approved: there is no default,
|
|
13
|
+
// and a run without one does not start. Editing audit.json never amends a
|
|
14
|
+
// run in progress; raising a limit is an explicit, recorded amendment. The
|
|
15
|
+
// ledger itself (reservations and settlements of every paid call) lives
|
|
16
|
+
// beside it in BANK/, so spending is never reset.
|
|
14
17
|
// ============================================================================
|
|
15
18
|
|
|
16
19
|
export const budgetFile = 'BUDGET.json';
|
|
17
20
|
|
|
21
|
+
const maxUsdSchema = z.number().finite().positive();
|
|
22
|
+
|
|
23
|
+
/** What audit.json says: the dollar cap is optional there, because the
|
|
24
|
+
* operator may approve it on the command line instead. */
|
|
18
25
|
export const budgetPolicySchema = z
|
|
19
26
|
.object({
|
|
20
|
-
maxUsd:
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
maxUsd: maxUsdSchema.optional(),
|
|
28
|
+
// A backstop against a runaway loop; the dollar cap is the approval.
|
|
29
|
+
maxTokens: z.number().int().positive().default(100_000_000),
|
|
30
|
+
maxHours: z.number().finite().positive().max(72).default(12),
|
|
23
31
|
})
|
|
24
32
|
.strict();
|
|
25
33
|
|
|
26
34
|
export type BudgetPolicy = z.infer<typeof budgetPolicySchema>;
|
|
27
35
|
|
|
36
|
+
/** The limits a run froze: the cap is always there. */
|
|
37
|
+
const frozenPolicySchema = budgetPolicySchema.extend({ maxUsd: maxUsdSchema });
|
|
38
|
+
|
|
39
|
+
export type FrozenBudgetPolicy = z.infer<typeof frozenPolicySchema>;
|
|
40
|
+
|
|
28
41
|
/** A --budget-file: the limits to raise; what it leaves out stays. */
|
|
29
|
-
export const budgetAmendmentSchema =
|
|
42
|
+
export const budgetAmendmentSchema = frozenPolicySchema.partial().strict();
|
|
30
43
|
|
|
31
44
|
export type BudgetAmendment = z.infer<typeof budgetAmendmentSchema>;
|
|
32
45
|
|
|
33
46
|
const budgetStateSchema = z
|
|
34
47
|
.object({
|
|
35
48
|
version: z.literal(1),
|
|
36
|
-
original:
|
|
37
|
-
current:
|
|
49
|
+
original: frozenPolicySchema,
|
|
50
|
+
current: frozenPolicySchema,
|
|
38
51
|
deadlineAt: z.iso.datetime(),
|
|
52
|
+
/** The gateway model the run judges and writes with, frozen with the
|
|
53
|
+
* budget. Absent on a directory from before model selection: the first
|
|
54
|
+
* resume records the model it continues with. */
|
|
55
|
+
model: z.string().min(1).optional(),
|
|
39
56
|
amendments: z.array(
|
|
40
57
|
z
|
|
41
58
|
.object({
|
|
42
59
|
at: z.iso.datetime(),
|
|
43
|
-
from:
|
|
44
|
-
to:
|
|
60
|
+
from: frozenPolicySchema,
|
|
61
|
+
to: frozenPolicySchema,
|
|
45
62
|
deadlineFrom: z.iso.datetime(),
|
|
46
63
|
deadlineTo: z.iso.datetime(),
|
|
47
64
|
})
|
|
@@ -54,7 +71,8 @@ type BudgetState = z.infer<typeof budgetStateSchema>;
|
|
|
54
71
|
|
|
55
72
|
export type RunBudget = {
|
|
56
73
|
limits: ModelBudgetLimits;
|
|
57
|
-
policy:
|
|
74
|
+
policy: FrozenBudgetPolicy;
|
|
75
|
+
model: string;
|
|
58
76
|
/** The amendment this invocation recorded, for the run journal. */
|
|
59
77
|
amended: BudgetState['amendments'][number] | undefined;
|
|
60
78
|
/** audit.json asks for other limits than the run froze: reported, never
|
|
@@ -79,56 +97,127 @@ export const readBudgetAmendment = async (
|
|
|
79
97
|
return budgetAmendmentSchema.parse(JSON.parse(text));
|
|
80
98
|
};
|
|
81
99
|
|
|
100
|
+
/** Thrown before any paid work when a new run has no approved cap. */
|
|
101
|
+
export class BudgetCapMissingError extends Error {
|
|
102
|
+
constructor(message: string) {
|
|
103
|
+
super(message);
|
|
104
|
+
this.name = 'BudgetCapMissingError';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Thrown before any paid work when audit.json names another model than
|
|
109
|
+
* the run directory froze. */
|
|
110
|
+
export class RunModelChangedError extends Error {
|
|
111
|
+
constructor(message: string) {
|
|
112
|
+
super(message);
|
|
113
|
+
this.name = 'RunModelChangedError';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** readFrozenBudget reads a run directory's BUDGET.json; undefined when
|
|
118
|
+
* the directory has not started. Read-only. */
|
|
119
|
+
export const readFrozenBudget = async (
|
|
120
|
+
dir: string,
|
|
121
|
+
): Promise<BudgetState | undefined> => {
|
|
122
|
+
const text = await readFile(path.join(dir, budgetFile), 'utf8').catch(
|
|
123
|
+
(err: unknown) => {
|
|
124
|
+
if (hasErrorCode(err, 'ENOENT')) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
throw err;
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return text === undefined
|
|
133
|
+
? undefined
|
|
134
|
+
: budgetStateSchema.parse(JSON.parse(text));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
type ResolveRunBudgetOptions = {
|
|
138
|
+
/** The gateway model audit.json resolves to. */
|
|
139
|
+
model: string;
|
|
140
|
+
/** The cap approved on the command line (`--max-usd`). On a new run it
|
|
141
|
+
* sets the cap; on a resume it raises it, recorded like a --budget-file. */
|
|
142
|
+
maxUsd?: number;
|
|
143
|
+
amendment?: BudgetAmendment;
|
|
144
|
+
now?: () => Date;
|
|
145
|
+
};
|
|
146
|
+
|
|
82
147
|
/**
|
|
83
|
-
* resolveRunBudget returns the limits a run executes under:
|
|
84
|
-
* audit.json on the first run, kept on every
|
|
85
|
-
* amendment.
|
|
86
|
-
*
|
|
148
|
+
* resolveRunBudget returns the limits and the model a run executes under:
|
|
149
|
+
* frozen from audit.json (and --max-usd) on the first run, kept on every
|
|
150
|
+
* resume, raised only by an amendment. A new run without a dollar cap is
|
|
151
|
+
* refused, as is a resume whose audit.json names another model. An
|
|
152
|
+
* amendment that lowers a limit is refused: the ledger may already hold
|
|
153
|
+
* more than the lower limit.
|
|
87
154
|
*/
|
|
88
155
|
export const resolveRunBudget = async (
|
|
89
156
|
dir: string,
|
|
90
157
|
policy: BudgetPolicy,
|
|
91
|
-
{
|
|
92
|
-
amendment,
|
|
93
|
-
now = () => new Date(),
|
|
94
|
-
}: { amendment?: BudgetAmendment; now?: () => Date } = {},
|
|
158
|
+
{ model, maxUsd, amendment, now = () => new Date() }: ResolveRunBudgetOptions,
|
|
95
159
|
): Promise<RunBudget> => {
|
|
96
160
|
const file = path.join(dir, budgetFile);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
161
|
+
const existing = await readFrozenBudget(dir);
|
|
162
|
+
const at = now();
|
|
163
|
+
|
|
164
|
+
if (existing?.model !== undefined && existing.model !== model) {
|
|
165
|
+
throw new RunModelChangedError(
|
|
166
|
+
`This run directory judges with ${existing.model}; audit.json now names ${model}. A run never changes its model. To judge the same answers with ${model}, use: literally-aeo rejudge ${dir} --output <new-dir> --model ${model}`,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const cap = maxUsd ?? policy.maxUsd;
|
|
171
|
+
|
|
172
|
+
const startState = (): BudgetState => {
|
|
173
|
+
if (cap === undefined) {
|
|
174
|
+
throw new BudgetCapMissingError(
|
|
175
|
+
'No spending cap: approve one with --max-usd <amount> or runPolicy.budget.maxUsd in audit.json.',
|
|
176
|
+
);
|
|
100
177
|
}
|
|
101
178
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
amendments: [],
|
|
179
|
+
const frozen = { ...policy, maxUsd: cap };
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
version: 1,
|
|
183
|
+
original: frozen,
|
|
184
|
+
current: frozen,
|
|
185
|
+
deadlineAt: hoursFrom(at, policy.maxHours),
|
|
186
|
+
model,
|
|
187
|
+
amendments: [],
|
|
188
|
+
};
|
|
113
189
|
};
|
|
190
|
+
|
|
191
|
+
let state: BudgetState = existing ?? startState();
|
|
114
192
|
let amended: RunBudget['amended'];
|
|
193
|
+
const modelAdopted = state.model === undefined;
|
|
194
|
+
|
|
195
|
+
state = { ...state, model };
|
|
196
|
+
|
|
197
|
+
// On a resume --max-usd raises the cap like a --budget-file does.
|
|
198
|
+
const change: BudgetAmendment = {
|
|
199
|
+
...amendment,
|
|
200
|
+
...(existing && maxUsd !== undefined && maxUsd !== existing.current.maxUsd
|
|
201
|
+
? { maxUsd }
|
|
202
|
+
: {}),
|
|
203
|
+
};
|
|
115
204
|
|
|
116
|
-
if (
|
|
117
|
-
const to = { ...state.current, ...
|
|
205
|
+
if (Object.keys(change).length > 0) {
|
|
206
|
+
const to = { ...state.current, ...change };
|
|
118
207
|
|
|
119
208
|
if (
|
|
120
209
|
to.maxUsd < state.current.maxUsd ||
|
|
121
210
|
to.maxTokens < state.current.maxTokens
|
|
122
211
|
) {
|
|
123
212
|
throw new Error(
|
|
124
|
-
`A
|
|
213
|
+
`A cap can only be raised; this run already allows $${state.current.maxUsd} and ${state.current.maxTokens} tokens.`,
|
|
125
214
|
);
|
|
126
215
|
}
|
|
127
216
|
|
|
128
217
|
const deadlineTo =
|
|
129
|
-
|
|
218
|
+
change.maxHours === undefined
|
|
130
219
|
? state.deadlineAt
|
|
131
|
-
: hoursFrom(at,
|
|
220
|
+
: hoursFrom(at, change.maxHours);
|
|
132
221
|
|
|
133
222
|
amended = {
|
|
134
223
|
at: at.toISOString(),
|
|
@@ -145,7 +234,7 @@ export const resolveRunBudget = async (
|
|
|
145
234
|
};
|
|
146
235
|
}
|
|
147
236
|
|
|
148
|
-
if (!existing || amended) {
|
|
237
|
+
if (!existing || amended || modelAdopted) {
|
|
149
238
|
await writeFileAtomically(file, JSON.stringify(state, null, 2));
|
|
150
239
|
}
|
|
151
240
|
|
|
@@ -156,8 +245,14 @@ export const resolveRunBudget = async (
|
|
|
156
245
|
deadlineAt: state.deadlineAt,
|
|
157
246
|
},
|
|
158
247
|
policy: state.current,
|
|
248
|
+
model,
|
|
159
249
|
amended,
|
|
160
|
-
|
|
250
|
+
// Only what audit.json itself asks for: a cap approved on the command
|
|
251
|
+
// line is not audit.json's, and a recorded raise is not a difference.
|
|
252
|
+
policyDiffers:
|
|
253
|
+
policy.maxTokens !== state.original.maxTokens ||
|
|
254
|
+
policy.maxHours !== state.original.maxHours ||
|
|
255
|
+
(policy.maxUsd !== undefined && policy.maxUsd !== state.original.maxUsd),
|
|
161
256
|
};
|
|
162
257
|
|
|
163
258
|
return budget;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { authorToolCaps } from '../codex-workflow/author-tools';
|
|
2
|
+
import {
|
|
3
|
+
authorSearchLowUsd,
|
|
4
|
+
authorTokens,
|
|
5
|
+
costCoefficientsVersion,
|
|
6
|
+
hostTokensPerAnswer,
|
|
7
|
+
probeUsd,
|
|
8
|
+
searchUsdPerAnswer,
|
|
9
|
+
stageTokens,
|
|
10
|
+
type Range,
|
|
11
|
+
type TokenRange,
|
|
12
|
+
} from '../models/cost-coefficients';
|
|
13
|
+
import { tokenCostUsd } from '../models/pricing';
|
|
14
|
+
import type { SupportedModel } from '../models/supported-models';
|
|
15
|
+
import type { RunPlan } from '../runner';
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// What a run or an author session is expected to cost
|
|
19
|
+
// (specs/aeo-claude-operator-spec.md §4.2): a low-to-high range per kind of
|
|
20
|
+
// paid work, from the plan, the model's list prices and the calibrated
|
|
21
|
+
// coefficients. An estimate, never a quote; the cap the operator approves
|
|
22
|
+
// is what bounds the spend.
|
|
23
|
+
// ============================================================================
|
|
24
|
+
|
|
25
|
+
export type CostRange = Range<number>;
|
|
26
|
+
|
|
27
|
+
export type RunCostEstimate = {
|
|
28
|
+
currency: 'USD';
|
|
29
|
+
/** An estimate, labelled as such wherever it is shown. */
|
|
30
|
+
kind: 'estimate';
|
|
31
|
+
model: string;
|
|
32
|
+
coefficientsVersion: number;
|
|
33
|
+
low: number;
|
|
34
|
+
high: number;
|
|
35
|
+
categories: {
|
|
36
|
+
probes: CostRange;
|
|
37
|
+
stages: CostRange;
|
|
38
|
+
hostCalls: CostRange;
|
|
39
|
+
search: CostRange;
|
|
40
|
+
};
|
|
41
|
+
/** The cap to propose to the operator: the high end, rounded up. */
|
|
42
|
+
recommendedCapUsd: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type AuthorCostEstimate = Omit<RunCostEstimate, 'categories'> & {
|
|
46
|
+
categories: { stages: CostRange; search: CostRange };
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const cents = (usd: number): number => {
|
|
50
|
+
return Math.round(usd * 100) / 100;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const rangeOf = (low: number, high: number): CostRange => {
|
|
54
|
+
return { low: cents(low), high: cents(high) };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The high end rounded up to a whole dollar, so the approved amount reads
|
|
58
|
+
* as an amount and never falls just short of the estimate. */
|
|
59
|
+
const recommendedCapOf = (high: number): number => {
|
|
60
|
+
return Math.max(1, Math.ceil(high));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const tokensCost = (
|
|
64
|
+
model: SupportedModel,
|
|
65
|
+
tokens: TokenRange,
|
|
66
|
+
cachedShare: number,
|
|
67
|
+
): number => {
|
|
68
|
+
return tokenCostUsd(model.pricingUsdPerMillion, {
|
|
69
|
+
inputTokens: tokens.input,
|
|
70
|
+
cachedInputTokens: Math.round(tokens.input * cachedShare),
|
|
71
|
+
outputTokens: tokens.output,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const scaled = (tokens: TokenRange, factor: number): TokenRange => {
|
|
76
|
+
return { input: tokens.input * factor, output: tokens.output * factor };
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const sumOf = (ranges: readonly CostRange[]): CostRange => {
|
|
80
|
+
return rangeOf(
|
|
81
|
+
ranges.reduce((total, range) => total + range.low, 0),
|
|
82
|
+
ranges.reduce((total, range) => total + range.high, 0),
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
type EstimateRunOptions = {
|
|
87
|
+
plan: Pick<RunPlan, 'units' | 'probesBySurface'>;
|
|
88
|
+
model: SupportedModel;
|
|
89
|
+
grounding: 'full' | 'extraction_only';
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** estimateRunCost estimates a whole run as planned; a resume spends less,
|
|
93
|
+
* because banked answers are never probed again. */
|
|
94
|
+
export const estimateRunCost = ({
|
|
95
|
+
plan,
|
|
96
|
+
model,
|
|
97
|
+
grounding,
|
|
98
|
+
}: EstimateRunOptions): RunCostEstimate => {
|
|
99
|
+
const answers = plan.units.length;
|
|
100
|
+
const { cachedShare } = stageTokens;
|
|
101
|
+
|
|
102
|
+
const probes = sumOf(
|
|
103
|
+
[...plan.probesBySurface].map(([surface, count]) =>
|
|
104
|
+
rangeOf(probeUsd[surface].low * count, probeUsd[surface].high * count),
|
|
105
|
+
),
|
|
106
|
+
);
|
|
107
|
+
// The cheap end assumes the cache serves most input; the dear end less.
|
|
108
|
+
const stages = rangeOf(
|
|
109
|
+
tokensCost(
|
|
110
|
+
model,
|
|
111
|
+
scaled(stageTokens.perAnswer.low, answers),
|
|
112
|
+
cachedShare.high,
|
|
113
|
+
) + tokensCost(model, stageTokens.perRun.low, cachedShare.high),
|
|
114
|
+
tokensCost(
|
|
115
|
+
model,
|
|
116
|
+
scaled(stageTokens.perAnswer.high, answers),
|
|
117
|
+
cachedShare.low,
|
|
118
|
+
) + tokensCost(model, stageTokens.perRun.high, cachedShare.low),
|
|
119
|
+
);
|
|
120
|
+
const hostTokens = hostTokensPerAnswer[grounding];
|
|
121
|
+
const hostCalls = rangeOf(
|
|
122
|
+
tokensCost(model, scaled(hostTokens.low, answers), 0),
|
|
123
|
+
tokensCost(model, scaled(hostTokens.high, answers), 0),
|
|
124
|
+
);
|
|
125
|
+
const search =
|
|
126
|
+
grounding === 'full'
|
|
127
|
+
? rangeOf(
|
|
128
|
+
searchUsdPerAnswer.low * answers,
|
|
129
|
+
searchUsdPerAnswer.high * answers,
|
|
130
|
+
)
|
|
131
|
+
: rangeOf(0, 0);
|
|
132
|
+
const total = sumOf([probes, stages, hostCalls, search]);
|
|
133
|
+
|
|
134
|
+
const estimate: RunCostEstimate = {
|
|
135
|
+
currency: 'USD',
|
|
136
|
+
kind: 'estimate',
|
|
137
|
+
model: model.id,
|
|
138
|
+
coefficientsVersion: costCoefficientsVersion,
|
|
139
|
+
low: total.low,
|
|
140
|
+
high: total.high,
|
|
141
|
+
categories: { probes, stages, hostCalls, search },
|
|
142
|
+
recommendedCapUsd: recommendedCapOf(total.high),
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return estimate;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** estimateAuthorCost estimates one author session and its research. */
|
|
149
|
+
export const estimateAuthorCost = (
|
|
150
|
+
model: SupportedModel,
|
|
151
|
+
): AuthorCostEstimate => {
|
|
152
|
+
const { cachedShare } = stageTokens;
|
|
153
|
+
const stages = rangeOf(
|
|
154
|
+
tokensCost(model, authorTokens.session.low, cachedShare.high),
|
|
155
|
+
tokensCost(model, authorTokens.session.high, cachedShare.low),
|
|
156
|
+
);
|
|
157
|
+
// The research tools refuse to search past their own spend cap.
|
|
158
|
+
const search = rangeOf(authorSearchLowUsd, authorToolCaps.searchSpendUsd);
|
|
159
|
+
const total = sumOf([stages, search]);
|
|
160
|
+
|
|
161
|
+
const estimate: AuthorCostEstimate = {
|
|
162
|
+
currency: 'USD',
|
|
163
|
+
kind: 'estimate',
|
|
164
|
+
model: model.id,
|
|
165
|
+
coefficientsVersion: costCoefficientsVersion,
|
|
166
|
+
low: total.low,
|
|
167
|
+
high: total.high,
|
|
168
|
+
categories: { stages, search },
|
|
169
|
+
recommendedCapUsd: recommendedCapOf(total.high),
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return estimate;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/** One line a person reads: "$12.40 to $38.10 (estimate)". */
|
|
176
|
+
export const describeCostRange = (range: CostRange): string => {
|
|
177
|
+
return `$${range.low.toFixed(2)} to $${range.high.toFixed(2)}`;
|
|
178
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Operating literally-aeo for a user
|
|
2
|
+
|
|
3
|
+
You are an AI agent running an AEO audit on the user's own machine, for a
|
|
4
|
+
user who is usually not a developer. This guide is the protocol. Phrase
|
|
5
|
+
things your own way; never skip a checkpoint, never reorder the paid steps,
|
|
6
|
+
and never spend money the user has not approved as an amount.
|
|
7
|
+
|
|
8
|
+
The engine enforces the cap, not you: every paid run needs `--max-usd`, and
|
|
9
|
+
a run stops (exit 2) before it would cross it. Your job is to get the user's
|
|
10
|
+
informed yes for an amount, then pass exactly that amount.
|
|
11
|
+
|
|
12
|
+
## Rules that hold throughout
|
|
13
|
+
|
|
14
|
+
- **Keys never pass through the chat.** Never ask for a key, password or
|
|
15
|
+
token in the conversation, never print one, never `cat` the `.env` file.
|
|
16
|
+
The user pastes keys into `.env` in their own editor. `literally-aeo
|
|
17
|
+
doctor` reports settings by name and source only; that is all you need.
|
|
18
|
+
- **Consent per system change.** Installing Node or another tool, or
|
|
19
|
+
changing shell configuration, needs the user's yes for that change.
|
|
20
|
+
- **One folder per brand.** Keep everything for a brand under
|
|
21
|
+
`~/literally-aeo/<brand>/` (the `.env`, the brief, `draft/`, `run/`),
|
|
22
|
+
never in Documents or the user's working folders.
|
|
23
|
+
- **Never delete a run directory to start fresh.** Running the same command
|
|
24
|
+
again resumes and reuses every answer already paid for. Deleting it pays
|
|
25
|
+
for them again.
|
|
26
|
+
- **Exit codes:** 0 done; 1 failed (invalid input or an error: read the
|
|
27
|
+
message); 2 stopped and resumable (a missing setting, a failed canary,
|
|
28
|
+
another writer, or the cap); 3 done with disclosed limits.
|
|
29
|
+
- **Machine-readable output:** add `--json` to any command and read stdout.
|
|
30
|
+
Progress goes to stderr.
|
|
31
|
+
- **Disclose untrusted reads.** Tell the user once, plainly: the analysis
|
|
32
|
+
stages run Codex in a sandbox that restricts writes and network access,
|
|
33
|
+
not reads, and the answers and pages it reads are untrusted text. The
|
|
34
|
+
stage prompts treat them as material, never as instructions. On a machine
|
|
35
|
+
holding confidential files, a container is the safer place to run.
|
|
36
|
+
|
|
37
|
+
## Checkpoint 1: install and check
|
|
38
|
+
|
|
39
|
+
1. Check `node --version` (24 or newer). If Node is missing or older, say
|
|
40
|
+
what you would install and how, and do it only on a yes.
|
|
41
|
+
2. `npm install -g literally-aeo`. Codex ships with the package; there is
|
|
42
|
+
nothing else to install for the analysis stages.
|
|
43
|
+
3. `mkdir -p ~/literally-aeo/<brand> && cd ~/literally-aeo/<brand>`, then
|
|
44
|
+
`literally-aeo init`. It writes an example `audit.json` (a fictional
|
|
45
|
+
company: a placeholder for `doctor`, replaced in checkpoint 5) and
|
|
46
|
+
`.env.example`, never over an existing file.
|
|
47
|
+
4. `literally-aeo doctor --json`. Read `checks`: what is missing, the Codex
|
|
48
|
+
binary the engine will run, and which coding-agent CLIs (`claude`,
|
|
49
|
+
`codex`, `cursor-agent`) are installed. `doctor` cannot tell whether a
|
|
50
|
+
CLI is logged in: a run checks that with a canary before any paid work,
|
|
51
|
+
so never tell the user a login works until a run has passed it.
|
|
52
|
+
|
|
53
|
+
## Checkpoint 2: accounts and keys
|
|
54
|
+
|
|
55
|
+
Explain each account in one sentence, what it pays for, and the cheapest
|
|
56
|
+
way to start:
|
|
57
|
+
|
|
58
|
+
- **Vercel AI Gateway** (`AI_GATEWAY_API_KEY`): pays for the assistant
|
|
59
|
+
answers the audit measures and every model call that judges them.
|
|
60
|
+
- **DataForSEO** (`DATAFORSEO_LOGIN`, `DATAFORSEO_PASSWORD`): pays for
|
|
61
|
+
Google AI Overviews, the searches that check the product claims answers
|
|
62
|
+
make, and the research behind the proposed config.
|
|
63
|
+
|
|
64
|
+
Copy `.env.example` to `.env` (`cp .env.example .env`) and ask the user to
|
|
65
|
+
open `.env` in their editor and paste the values. Then run
|
|
66
|
+
`literally-aeo doctor --env-file .env --json` again until every setting the
|
|
67
|
+
run needs reports present.
|
|
68
|
+
|
|
69
|
+
Coding-agent surfaces (Claude Code, Codex, Cursor) are measured with the
|
|
70
|
+
CLI's own login on this machine. They matter most when the buyers are
|
|
71
|
+
developers. If the user cannot or will not set one up, remove it from
|
|
72
|
+
`surfaces` in `audit.json` in checkpoint 5 and tell them it is now out of
|
|
73
|
+
scope for this audit.
|
|
74
|
+
|
|
75
|
+
## Checkpoint 3: the brief
|
|
76
|
+
|
|
77
|
+
Ask, in plain words:
|
|
78
|
+
|
|
79
|
+
- the company name and website;
|
|
80
|
+
- what they want AI assistants to recommend them for;
|
|
81
|
+
- competitors they know (optional);
|
|
82
|
+
- pages that matter most, such as pricing or a product page (optional);
|
|
83
|
+
- anything else worth knowing (optional).
|
|
84
|
+
|
|
85
|
+
Write their answers to `brief.json`:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"companyName": "Acme Files",
|
|
90
|
+
"website": "https://acme.example",
|
|
91
|
+
"desiredRecommendation": "Secure file sharing for regulated teams",
|
|
92
|
+
"competitors": "Rival Drive (rival.example)",
|
|
93
|
+
"moneyPages": "https://acme.example/pricing",
|
|
94
|
+
"notes": ""
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Checkpoint 4: approve the research cost
|
|
99
|
+
|
|
100
|
+
Run `literally-aeo author --brief brief.json --estimate --json` and show the
|
|
101
|
+
estimate. It spends nothing. Only on a yes, run
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
literally-aeo author --brief brief.json --output draft --env-file .env --max-usd <approved amount>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
It researches the company and proposes `draft/audit.json`, with
|
|
108
|
+
`draft/author-record.json` beside it. Keep both files together.
|
|
109
|
+
|
|
110
|
+
## Checkpoint 5: approve the questions
|
|
111
|
+
|
|
112
|
+
Read `draft/audit.json` and present it as a short list, never as JSON: the
|
|
113
|
+
sections, the buyer questions in each, the competitors, and the surfaces
|
|
114
|
+
(the assistants that will be asked). Apply the user's edits to
|
|
115
|
+
`draft/audit.json` yourself. The optional `model` field names the model
|
|
116
|
+
that judges and writes the report; leave it out to use the recommended
|
|
117
|
+
one, which `literally-aeo doctor` lists with every supported model. Run
|
|
118
|
+
`literally-aeo doctor --config draft/audit.json --env-file .env --json`
|
|
119
|
+
after editing.
|
|
120
|
+
|
|
121
|
+
## Checkpoint 6: approve the audit cost
|
|
122
|
+
|
|
123
|
+
Run `literally-aeo plan --config draft/audit.json --output run --json`.
|
|
124
|
+
Show the estimate's low to high range, what drives it (answers per surface,
|
|
125
|
+
the model), and the categories (`estimate.categories`). Recommend
|
|
126
|
+
`recommendedCapUsd`, the high end, as the cap. Say it is an estimate, not a
|
|
127
|
+
quote. The user's approved amount is the cap.
|
|
128
|
+
|
|
129
|
+
## Checkpoint 7: run and watch
|
|
130
|
+
|
|
131
|
+
Start the run in the background:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
literally-aeo run --config draft/audit.json --env-file .env --output run --max-usd <approved amount>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
It takes from minutes to hours. Follow it with
|
|
138
|
+
`literally-aeo status run --json`: `phase`, `answers` (captured of planned),
|
|
139
|
+
`spend` (charged against `capUsd`, by category), `lastError`. Poll every few
|
|
140
|
+
minutes, not continuously. Tell the user what changed, briefly.
|
|
141
|
+
|
|
142
|
+
When the process exits:
|
|
143
|
+
|
|
144
|
+
- **0**: done. Go to checkpoint 8.
|
|
145
|
+
- **3**: done with disclosed limits (unjudged answers, a narrative marked
|
|
146
|
+
as needing improvement). Explain the limits in plain words, then go to
|
|
147
|
+
checkpoint 8.
|
|
148
|
+
- **2**: stopped and resumable. Read `literally-aeo status run --json` and
|
|
149
|
+
the stderr message and explain why. If `stoppedAtBudget` is true, the cap
|
|
150
|
+
was reached: show what was spent (`spend`) and what is left to do, and
|
|
151
|
+
ask whether to raise it, to what total. Only on a new yes, run the same
|
|
152
|
+
command with `--max-usd <new total cap>`; the raise is recorded, and the
|
|
153
|
+
answers already paid for are reused. Otherwise fix the cause (a setting,
|
|
154
|
+
a login) and run the same command again; it resumes.
|
|
155
|
+
- **1**: read the error, fix the input if you can, and explain it if you
|
|
156
|
+
cannot. Never delete `run/`.
|
|
157
|
+
|
|
158
|
+
To judge the same answers again with another model, use
|
|
159
|
+
`literally-aeo rejudge run --output run-<model> --model <id> --env-file .env`:
|
|
160
|
+
nothing is asked again, and only the judging is paid for. Without
|
|
161
|
+
`--max-usd` it prints its estimate and spends nothing; show that, get an
|
|
162
|
+
amount approved, and run it again with `--max-usd <approved amount>`. A run
|
|
163
|
+
never changes its own model: editing `model` in `audit.json` over an
|
|
164
|
+
existing run directory is refused.
|
|
165
|
+
|
|
166
|
+
## Checkpoint 8: explain the result
|
|
167
|
+
|
|
168
|
+
Open the report with `literally-aeo view run` (a one-time link on this
|
|
169
|
+
machine only). Summarize: where the brand is mentioned and cited, on which
|
|
170
|
+
assistants, who is recommended instead, and what the report recommends.
|
|
171
|
+
Quote the report; do not add claims it does not make.
|
|
172
|
+
|
|
173
|
+
## Checkpoint 9: keep and share
|
|
174
|
+
|
|
175
|
+
Offer `literally-aeo export run`: a `.aeo.zip` bundle with the captured
|
|
176
|
+
answers, every judgment, the metrics, the report and the journal of every
|
|
177
|
+
operation, which anyone can check offline with `literally-aeo verify`.
|
|
178
|
+
Credentials found in it block the export. Tell the user the bundle shows
|
|
179
|
+
the questions and the answers, so they should share it only where those can
|
|
180
|
+
be read.
|