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/cli/io.ts
CHANGED
package/src/cli/literally-aeo.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Console } from 'node:console';
|
|
2
2
|
import { toolVersion } from '../bundle/contracts';
|
|
3
3
|
import { runExport, runVerify, runView } from './bundle-commands';
|
|
4
|
+
import { runGuide } from './guide-command';
|
|
4
5
|
import { parseFlags, writeErr, writeOut } from './io';
|
|
5
6
|
import {
|
|
6
7
|
runDoctor,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
runRejudge,
|
|
11
12
|
runRun,
|
|
12
13
|
} from './run-commands';
|
|
14
|
+
import { runStatus } from './status-command';
|
|
13
15
|
|
|
14
16
|
// ============================================================================
|
|
15
17
|
// literally-aeo (specs/aeo-open-source-cli-spec.md §4.3). No command loads
|
|
@@ -23,40 +25,52 @@ Usage:
|
|
|
23
25
|
literally-aeo init [--config audit.json]
|
|
24
26
|
literally-aeo doctor [--config audit.json] [--env-file .env] [--output audit-run]
|
|
25
27
|
literally-aeo plan [--config audit.json] [--output audit-run]
|
|
26
|
-
literally-aeo run [--config audit.json] [--env-file .env] [--output audit-run] [--budget-file limits.json]
|
|
27
|
-
literally-aeo author --brief brief.json [--output audit-draft] [--env-file .env]
|
|
28
|
-
literally-aeo rejudge <run-dir> --output <new-run-dir> [--config audit.json] [--env-file .env]
|
|
28
|
+
literally-aeo run [--config audit.json] [--env-file .env] [--output audit-run] [--max-usd N] [--budget-file limits.json]
|
|
29
|
+
literally-aeo author --brief brief.json [--estimate] [--max-usd N] [--model <id>] [--output audit-draft] [--env-file .env]
|
|
30
|
+
literally-aeo rejudge <run-dir> --output <new-run-dir> [--model <id>] [--max-usd N] [--config audit.json] [--env-file .env]
|
|
29
31
|
literally-aeo view <archive|bundle-dir|run-dir> [--working] [--port N]
|
|
30
32
|
literally-aeo export <run-dir> [--output <file.aeo.zip>] [--env-file <file>] [--accept-findings] [--redact redactions.json]
|
|
31
33
|
literally-aeo verify <archive|bundle-dir|run-dir>
|
|
34
|
+
literally-aeo status <run-dir>
|
|
35
|
+
literally-aeo guide
|
|
32
36
|
|
|
33
37
|
Every command takes --json (a versioned result on stdout) and --quiet.
|
|
34
38
|
|
|
35
39
|
init writes an example audit.json and .env.example, never over a file.
|
|
36
|
-
doctor checks the CLIs, settings and run directory a run needs,
|
|
37
|
-
settings are named, never shown
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
doctor checks the model, the CLIs, settings and run directory a run needs,
|
|
41
|
+
offline; settings are named, never shown, and an unsupported model is
|
|
42
|
+
refused with the supported list. plan prints what a run would measure, its
|
|
43
|
+
estimated cost as a range, and whether the run directory is new, resumable
|
|
44
|
+
or completed, offline. run measures: it captures every planned answer
|
|
45
|
+
(reusing what the run directory already holds), judges, reviews and writes
|
|
46
|
+
the report; running it again resumes. A new run starts only under an
|
|
47
|
+
approved cap, --max-usd or runPolicy.budget.maxUsd, which covers every
|
|
48
|
+
paid call (probes, Codex stages, host model calls, searches); without one
|
|
49
|
+
it prints the estimate and spends nothing. A run freezes its cap and its
|
|
50
|
+
model; --max-usd or --budget-file raises the cap of a run, recorded.
|
|
51
|
+
author researches a brief (JSON: companyName, website,
|
|
52
|
+
desiredRecommendation, and optionally competitors, moneyPages, notes) and
|
|
53
|
+
proposes an audit.json beside the record of the session; --estimate prints
|
|
54
|
+
what that costs and spends nothing, and the session needs --max-usd. A run
|
|
55
|
+
of that file bundles the record and the diff from proposal to final.
|
|
56
|
+
rejudge judges a finished run's captures again in a new run directory,
|
|
57
|
+
carrying the original revision as its predecessor; nothing is probed
|
|
58
|
+
again, and --model judges with another model. view serves the
|
|
48
59
|
report and its evidence on this machine only (127.0.0.1, a one-time link);
|
|
49
60
|
a run directory without a finalized revision shows its working state,
|
|
50
61
|
labelled as such. export packs a run directory into a portable archive;
|
|
51
|
-
verify checks one offline.
|
|
62
|
+
verify checks one offline. status reports a run directory's phase,
|
|
63
|
+
answers and spend against its cap, read-only, beside a live run too. guide
|
|
64
|
+
prints the protocol an AI agent follows to run an audit for a user.
|
|
52
65
|
|
|
53
66
|
Settings come from the process environment first, then the env file
|
|
54
67
|
(default ./.env); no other file is read.
|
|
55
68
|
|
|
56
69
|
Exit codes: 0 done; 1 invalid input, a failed check or an error; 2 stopped
|
|
57
|
-
before or during work and resumable (
|
|
58
|
-
writer holding the run), or an
|
|
59
|
-
limitations; 128 plus the signal
|
|
70
|
+
before or during work and resumable (no approved cap, the cap reached,
|
|
71
|
+
missing setting, failed canary, a live writer holding the run), or an
|
|
72
|
+
unsupported bundle; 3 done with disclosed limitations; 128 plus the signal
|
|
73
|
+
number when interrupted.`;
|
|
60
74
|
|
|
61
75
|
const main = async (argv: readonly string[]) => {
|
|
62
76
|
const flags = parseFlags(argv);
|
|
@@ -101,6 +115,12 @@ const main = async (argv: readonly string[]) => {
|
|
|
101
115
|
case 'view':
|
|
102
116
|
return runView(commandFlags, usageText);
|
|
103
117
|
|
|
118
|
+
case 'status':
|
|
119
|
+
return runStatus(commandFlags, usageText);
|
|
120
|
+
|
|
121
|
+
case 'guide':
|
|
122
|
+
return runGuide(commandFlags);
|
|
123
|
+
|
|
104
124
|
default:
|
|
105
125
|
throw new Error(usageText);
|
|
106
126
|
}
|
package/src/cli/run-commands.ts
CHANGED
|
@@ -5,7 +5,20 @@ import { workflowSecrets } from '../codex-workflow/codex-home';
|
|
|
5
5
|
import { prepareWorkdir, runWorkflow } from '../codex-workflow/loop';
|
|
6
6
|
import { readAuditFile, type AuditFile } from '../engine/audit-file';
|
|
7
7
|
import { readSettings, type Settings } from '../engine/env-file';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BudgetCapMissingError,
|
|
10
|
+
readBudgetAmendment,
|
|
11
|
+
readFrozenBudget,
|
|
12
|
+
RunModelChangedError,
|
|
13
|
+
type BudgetAmendment,
|
|
14
|
+
} from '../engine/budget';
|
|
15
|
+
import {
|
|
16
|
+
describeCostRange,
|
|
17
|
+
estimateAuthorCost,
|
|
18
|
+
estimateRunCost,
|
|
19
|
+
type AuthorCostEstimate,
|
|
20
|
+
type RunCostEstimate,
|
|
21
|
+
} from '../engine/cost-estimate';
|
|
9
22
|
import {
|
|
10
23
|
openLocalRun,
|
|
11
24
|
planLocalRun,
|
|
@@ -34,6 +47,11 @@ import { engineResources } from '../engine/resources';
|
|
|
34
47
|
import { exampleAuditFile, exampleEnvFile } from '../engine/templates';
|
|
35
48
|
import { getEnvironment, writeEnv } from '../lib/env';
|
|
36
49
|
import { ModelBudgetError } from '../models/accounting';
|
|
50
|
+
import {
|
|
51
|
+
findSupportedModel,
|
|
52
|
+
recommendedModelId,
|
|
53
|
+
resolveSupportedModel,
|
|
54
|
+
} from '../models/supported-models';
|
|
37
55
|
import { hasErrorCode } from '../stores/fs-errors';
|
|
38
56
|
import { formatLine, writeErr, writeOut, type Flags } from './io';
|
|
39
57
|
|
|
@@ -51,6 +69,57 @@ const runDirOf = (flags: Flags) => {
|
|
|
51
69
|
return path.resolve(flags.options.get('--output') ?? 'audit-run');
|
|
52
70
|
};
|
|
53
71
|
|
|
72
|
+
/** The amount the operator approved with --max-usd, if any. */
|
|
73
|
+
const maxUsdOf = (flags: Flags): number | undefined => {
|
|
74
|
+
const value = flags.options.get('--max-usd');
|
|
75
|
+
|
|
76
|
+
if (value === undefined) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const usd = Number(value.replace(/^\$/, ''));
|
|
81
|
+
|
|
82
|
+
if (!Number.isFinite(usd) || usd <= 0) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Please give --max-usd a positive amount in dollars, such as 40; got ${value}.`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return usd;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** The cost lines a person reads, for plan and for a refused run. */
|
|
92
|
+
const estimateLines = (estimate: RunCostEstimate | AuthorCostEstimate) => {
|
|
93
|
+
const categories: [string, { low: number; high: number } | undefined][] = [
|
|
94
|
+
[
|
|
95
|
+
'probes',
|
|
96
|
+
'probes' in estimate.categories ? estimate.categories.probes : undefined,
|
|
97
|
+
],
|
|
98
|
+
['Codex stages', estimate.categories.stages],
|
|
99
|
+
[
|
|
100
|
+
'host model calls',
|
|
101
|
+
'hostCalls' in estimate.categories
|
|
102
|
+
? estimate.categories.hostCalls
|
|
103
|
+
: undefined,
|
|
104
|
+
],
|
|
105
|
+
['search', estimate.categories.search],
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
return [
|
|
109
|
+
formatLine(
|
|
110
|
+
'Estimated cost',
|
|
111
|
+
`${describeCostRange(estimate)} (an estimate, not a quote; ${estimate.model})`,
|
|
112
|
+
),
|
|
113
|
+
...categories.flatMap(([label, range]) =>
|
|
114
|
+
range ? [formatLine(` ${label}`, describeCostRange(range))] : [],
|
|
115
|
+
),
|
|
116
|
+
formatLine(
|
|
117
|
+
'Recommended cap',
|
|
118
|
+
`$${estimate.recommendedCapUsd} (the high end)`,
|
|
119
|
+
),
|
|
120
|
+
];
|
|
121
|
+
};
|
|
122
|
+
|
|
54
123
|
/** init writes the two templates beside each other, never over an
|
|
55
124
|
* existing file. */
|
|
56
125
|
export const runInit = async (flags: Flags) => {
|
|
@@ -91,12 +160,19 @@ export const runInit = async (flags: Flags) => {
|
|
|
91
160
|
|
|
92
161
|
export const runDoctor = async (flags: Flags) => {
|
|
93
162
|
const file = await readAuditFile(configPathOf(flags));
|
|
94
|
-
|
|
163
|
+
// An unsupported model is doctor's finding, not its crash: the rest of
|
|
164
|
+
// the checks still run, against the plan the recommended model would make.
|
|
165
|
+
const isSupported =
|
|
166
|
+
findSupportedModel(file.model ?? recommendedModelId) !== undefined;
|
|
167
|
+
const { plan, request } = planLocalRun(
|
|
168
|
+
isSupported ? file : { ...file, model: undefined },
|
|
169
|
+
);
|
|
95
170
|
const settings = await readSettings(flags.options.get('--env-file'));
|
|
96
171
|
const checks = await runPreflight({
|
|
97
172
|
surfaces: plan.surfaces,
|
|
98
173
|
settings,
|
|
99
174
|
dir: runDirOf(flags),
|
|
175
|
+
model: file.model,
|
|
100
176
|
groundingSearch: usesGroundingSearch(request),
|
|
101
177
|
});
|
|
102
178
|
const ok = checks.every((check) => check.ok);
|
|
@@ -128,8 +204,15 @@ export const runPlan = async (flags: Flags) => {
|
|
|
128
204
|
const dir = runDirOf(flags);
|
|
129
205
|
const state = await runDirectoryState(dir);
|
|
130
206
|
const bySurface = Object.fromEntries(plan.probesBySurface);
|
|
207
|
+
const model = resolveSupportedModel(file.model);
|
|
208
|
+
const estimate = estimateRunCost({
|
|
209
|
+
plan,
|
|
210
|
+
model,
|
|
211
|
+
grounding: request.grounding,
|
|
212
|
+
});
|
|
131
213
|
const summary = {
|
|
132
214
|
brand: config.brand.name,
|
|
215
|
+
model: model.id,
|
|
133
216
|
sections: config.sections.map((section) => ({
|
|
134
217
|
key: section.key,
|
|
135
218
|
questions: section.prompts.length,
|
|
@@ -140,11 +223,10 @@ export const runPlan = async (flags: Flags) => {
|
|
|
140
223
|
maxPlannedUnits: request.maxPlannedUnits,
|
|
141
224
|
grounding: request.grounding,
|
|
142
225
|
budget: file.runPolicy.budget,
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
budgetRecordedOnly: ['probe answers', 'Codex stage sessions'],
|
|
226
|
+
// The cap covers every paid call: probes, Codex stage sessions, host
|
|
227
|
+
// model calls and searches.
|
|
228
|
+
estimate,
|
|
229
|
+
recommendedCapUsd: estimate.recommendedCapUsd,
|
|
148
230
|
runDirectory: { path: dir, state },
|
|
149
231
|
digests,
|
|
150
232
|
};
|
|
@@ -158,6 +240,7 @@ export const runPlan = async (flags: Flags) => {
|
|
|
158
240
|
writeOut(
|
|
159
241
|
[
|
|
160
242
|
formatLine('Brand', summary.brand),
|
|
243
|
+
formatLine('Model', summary.model),
|
|
161
244
|
...summary.sections.map((section) =>
|
|
162
245
|
formatLine(`Section ${section.key}`, `${section.questions} questions`),
|
|
163
246
|
),
|
|
@@ -175,14 +258,12 @@ export const runPlan = async (flags: Flags) => {
|
|
|
175
258
|
? 'full (claims researched and adjudicated)'
|
|
176
259
|
: 'extraction_only (claims inventoried, not researched)',
|
|
177
260
|
),
|
|
261
|
+
...estimateLines(estimate),
|
|
178
262
|
formatLine(
|
|
179
|
-
'
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
formatLine(
|
|
184
|
-
' recorded, not capped',
|
|
185
|
-
summary.budgetRecordedOnly.join('; '),
|
|
263
|
+
'Cap',
|
|
264
|
+
summary.budget.maxUsd === undefined
|
|
265
|
+
? 'none in audit.json; approve one with run --max-usd <amount>'
|
|
266
|
+
: `${'$'}${summary.budget.maxUsd} (audit.json), covering every paid call`,
|
|
186
267
|
),
|
|
187
268
|
formatLine('Run directory', `${dir} (${state})`),
|
|
188
269
|
formatLine('Measurement digest', digests.measurement),
|
|
@@ -204,10 +285,27 @@ export const runRun = async (flags: Flags) => {
|
|
|
204
285
|
const amendment = budgetFile
|
|
205
286
|
? await readBudgetAmendment(path.resolve(budgetFile))
|
|
206
287
|
: undefined;
|
|
288
|
+
const maxUsd = maxUsdOf(flags);
|
|
289
|
+
const refused = await refuseWithoutCap({
|
|
290
|
+
file,
|
|
291
|
+
dir,
|
|
292
|
+
maxUsd,
|
|
293
|
+
estimate: estimateRunCost({
|
|
294
|
+
plan,
|
|
295
|
+
model: resolveSupportedModel(file.model),
|
|
296
|
+
grounding: request.grounding,
|
|
297
|
+
}),
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
if (refused !== undefined) {
|
|
301
|
+
return refused;
|
|
302
|
+
}
|
|
303
|
+
|
|
207
304
|
const checks = await runPreflight({
|
|
208
305
|
surfaces: plan.surfaces,
|
|
209
306
|
settings,
|
|
210
307
|
dir,
|
|
308
|
+
model: file.model,
|
|
211
309
|
groundingSearch: usesGroundingSearch(request),
|
|
212
310
|
});
|
|
213
311
|
const failing = checks.filter((check) => !check.ok);
|
|
@@ -228,10 +326,46 @@ export const runRun = async (flags: Flags) => {
|
|
|
228
326
|
configFile: configPathOf(flags),
|
|
229
327
|
dir,
|
|
230
328
|
settings,
|
|
329
|
+
maxUsd,
|
|
231
330
|
amendment,
|
|
232
331
|
});
|
|
233
332
|
};
|
|
234
333
|
|
|
334
|
+
/** A run starts only under an amount the operator approved: a new run
|
|
335
|
+
* directory without --max-usd or runPolicy.budget.maxUsd is refused with
|
|
336
|
+
* the estimate, before any paid work (exit 2, nothing spent). A resume
|
|
337
|
+
* keeps the cap it froze. */
|
|
338
|
+
const refuseWithoutCap = async ({
|
|
339
|
+
file,
|
|
340
|
+
dir,
|
|
341
|
+
maxUsd,
|
|
342
|
+
estimate,
|
|
343
|
+
}: {
|
|
344
|
+
file: AuditFile;
|
|
345
|
+
dir: string;
|
|
346
|
+
maxUsd: number | undefined;
|
|
347
|
+
estimate: RunCostEstimate;
|
|
348
|
+
}): Promise<number | undefined> => {
|
|
349
|
+
if (maxUsd !== undefined || file.runPolicy.budget.maxUsd !== undefined) {
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (await readFrozenBudget(dir)) {
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
writeErr(
|
|
358
|
+
[
|
|
359
|
+
'Not started: a run needs an approved spending cap. Nothing was spent.',
|
|
360
|
+
...estimateLines(estimate),
|
|
361
|
+
'',
|
|
362
|
+
`Approve an amount and run again with it, for example: --max-usd ${estimate.recommendedCapUsd}`,
|
|
363
|
+
].join('\n'),
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
return 2;
|
|
367
|
+
};
|
|
368
|
+
|
|
235
369
|
/** author researches a brief and proposes an audit.json (spec §4.1). */
|
|
236
370
|
export const runAuthor = async (flags: Flags, usage: string) => {
|
|
237
371
|
const briefFile = flags.options.get('--brief');
|
|
@@ -241,6 +375,36 @@ export const runAuthor = async (flags: Flags, usage: string) => {
|
|
|
241
375
|
}
|
|
242
376
|
|
|
243
377
|
const brief = await readBrief(path.resolve(briefFile));
|
|
378
|
+
const model = resolveSupportedModel(flags.options.get('--model'));
|
|
379
|
+
const estimate = estimateAuthorCost(model);
|
|
380
|
+
const maxUsd = maxUsdOf(flags);
|
|
381
|
+
|
|
382
|
+
// --estimate is free: it reads the brief and prints what researching it
|
|
383
|
+
// would cost, and spends nothing.
|
|
384
|
+
if (flags.switches.has('--estimate') || maxUsd === undefined) {
|
|
385
|
+
if (flags.switches.has('--json')) {
|
|
386
|
+
writeOut(
|
|
387
|
+
JSON.stringify({
|
|
388
|
+
resultVersion: 1,
|
|
389
|
+
command: 'author',
|
|
390
|
+
started: false,
|
|
391
|
+
estimate,
|
|
392
|
+
recommendedCapUsd: estimate.recommendedCapUsd,
|
|
393
|
+
}),
|
|
394
|
+
);
|
|
395
|
+
} else {
|
|
396
|
+
writeOut(
|
|
397
|
+
[
|
|
398
|
+
...estimateLines(estimate),
|
|
399
|
+
'',
|
|
400
|
+
`Nothing was spent. To research the brief, approve an amount: --max-usd ${estimate.recommendedCapUsd}`,
|
|
401
|
+
].join('\n'),
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return flags.switches.has('--estimate') ? 0 : 2;
|
|
406
|
+
}
|
|
407
|
+
|
|
244
408
|
const dir = path.resolve(flags.options.get('--output') ?? 'audit-draft');
|
|
245
409
|
const settings = await readSettings(flags.options.get('--env-file'));
|
|
246
410
|
// The author researches through the pinned search provider, so its key
|
|
@@ -275,6 +439,8 @@ export const runAuthor = async (flags: Flags, usage: string) => {
|
|
|
275
439
|
const result = await runLocalAuthor({
|
|
276
440
|
brief,
|
|
277
441
|
dir,
|
|
442
|
+
model,
|
|
443
|
+
maxUsd,
|
|
278
444
|
secrets: settings.values(credentialSettingNames),
|
|
279
445
|
});
|
|
280
446
|
|
|
@@ -302,6 +468,14 @@ export const runAuthor = async (flags: Flags, usage: string) => {
|
|
|
302
468
|
return 2;
|
|
303
469
|
}
|
|
304
470
|
|
|
471
|
+
if (err instanceof ModelBudgetError) {
|
|
472
|
+
writeErr(
|
|
473
|
+
`Stopped at the approved cap of $${maxUsd}: ${err.message}. Nothing more was spent; run the same command with a higher --max-usd to continue.`,
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
return 2;
|
|
477
|
+
}
|
|
478
|
+
|
|
305
479
|
throw err;
|
|
306
480
|
}
|
|
307
481
|
};
|
|
@@ -344,9 +518,33 @@ export const runRejudge = async (flags: Flags, usage: string) => {
|
|
|
344
518
|
configOption === undefined
|
|
345
519
|
? await readRecordedAuthorEvidence(sourceDir)
|
|
346
520
|
: undefined;
|
|
347
|
-
|
|
521
|
+
// --model judges the same captures with another model: the method
|
|
522
|
+
// changes, the measurement does not, and the lineage records both.
|
|
523
|
+
const modelOption = flags.options.get('--model');
|
|
524
|
+
const configured = await readAuditFile(configFile);
|
|
525
|
+
const file =
|
|
526
|
+
modelOption === undefined
|
|
527
|
+
? configured
|
|
528
|
+
: { ...configured, model: resolveSupportedModel(modelOption).id };
|
|
348
529
|
const settings = await readSettings(flags.options.get('--env-file'));
|
|
349
530
|
const { plan, request } = planLocalRun(file);
|
|
531
|
+
const maxUsd = maxUsdOf(flags);
|
|
532
|
+
const refused = await refuseWithoutCap({
|
|
533
|
+
file,
|
|
534
|
+
dir,
|
|
535
|
+
maxUsd,
|
|
536
|
+
// Nothing is probed again: only the judging and writing are paid.
|
|
537
|
+
estimate: estimateRunCost({
|
|
538
|
+
plan: { units: plan.units, probesBySurface: new Map() },
|
|
539
|
+
model: resolveSupportedModel(file.model),
|
|
540
|
+
grounding: request.grounding,
|
|
541
|
+
}),
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
if (refused !== undefined) {
|
|
545
|
+
return refused;
|
|
546
|
+
}
|
|
547
|
+
|
|
350
548
|
const lineage = await prepareRejudgment({
|
|
351
549
|
source: sourceDir,
|
|
352
550
|
target: dir,
|
|
@@ -358,6 +556,7 @@ export const runRejudge = async (flags: Flags, usage: string) => {
|
|
|
358
556
|
surfaces: plan.surfaces,
|
|
359
557
|
settings,
|
|
360
558
|
dir,
|
|
559
|
+
model: file.model,
|
|
361
560
|
groundingSearch: usesGroundingSearch(request),
|
|
362
561
|
});
|
|
363
562
|
const failing = checks.filter((check) => !check.ok);
|
|
@@ -382,6 +581,8 @@ export const runRejudge = async (flags: Flags, usage: string) => {
|
|
|
382
581
|
configFile,
|
|
383
582
|
dir,
|
|
384
583
|
settings,
|
|
584
|
+
maxUsd,
|
|
585
|
+
...(modelOption !== undefined && { modelOverride: file.model }),
|
|
385
586
|
evidence,
|
|
386
587
|
derivedFromRunId: lineage.runId,
|
|
387
588
|
});
|
|
@@ -393,6 +594,10 @@ type ExecuteRunOptions = {
|
|
|
393
594
|
configFile: string;
|
|
394
595
|
dir: string;
|
|
395
596
|
settings: Settings;
|
|
597
|
+
/** The cap approved on the command line. */
|
|
598
|
+
maxUsd?: number;
|
|
599
|
+
/** The model a rejudgment names outside the configuration file. */
|
|
600
|
+
modelOverride?: string;
|
|
396
601
|
amendment?: BudgetAmendment;
|
|
397
602
|
/** Author evidence already recorded; read beside configFile otherwise. */
|
|
398
603
|
evidence?: RecordedAuthorEvidence;
|
|
@@ -407,6 +612,8 @@ const executeRun = async ({
|
|
|
407
612
|
configFile,
|
|
408
613
|
dir,
|
|
409
614
|
settings,
|
|
615
|
+
maxUsd,
|
|
616
|
+
modelOverride,
|
|
410
617
|
amendment,
|
|
411
618
|
evidence,
|
|
412
619
|
derivedFromRunId,
|
|
@@ -417,6 +624,7 @@ const executeRun = async ({
|
|
|
417
624
|
dir,
|
|
418
625
|
configFile,
|
|
419
626
|
evidence: evidence ?? (await readAuthorEvidence(configFile, file)),
|
|
627
|
+
...(modelOverride !== undefined && { model: modelOverride }),
|
|
420
628
|
});
|
|
421
629
|
|
|
422
630
|
// The copy stage reads its rules and publisher context from the engine,
|
|
@@ -440,6 +648,7 @@ const executeRun = async ({
|
|
|
440
648
|
try {
|
|
441
649
|
const local = await openLocalRun(file, dir, {
|
|
442
650
|
signal: controller.signal,
|
|
651
|
+
...(maxUsd !== undefined && { maxUsd }),
|
|
443
652
|
amendment,
|
|
444
653
|
derivedFromRunId,
|
|
445
654
|
});
|
|
@@ -456,6 +665,7 @@ const executeRun = async ({
|
|
|
456
665
|
signal: controller.signal,
|
|
457
666
|
origin: 'local',
|
|
458
667
|
held: local.held,
|
|
668
|
+
ledger: local.ledger,
|
|
459
669
|
}).catch(async (err: unknown) => {
|
|
460
670
|
await local.held.writer.release();
|
|
461
671
|
await local.source.close();
|
|
@@ -511,17 +721,25 @@ const executeRun = async ({
|
|
|
511
721
|
|
|
512
722
|
if (
|
|
513
723
|
err instanceof PreflightFailedError ||
|
|
514
|
-
err instanceof WriterLockHeldError
|
|
724
|
+
err instanceof WriterLockHeldError ||
|
|
725
|
+
err instanceof BudgetCapMissingError
|
|
515
726
|
) {
|
|
516
727
|
writeErr(err.message);
|
|
517
728
|
|
|
518
729
|
return 2;
|
|
519
730
|
}
|
|
520
731
|
|
|
521
|
-
|
|
732
|
+
if (err instanceof RunModelChangedError) {
|
|
733
|
+
writeErr(err.message);
|
|
734
|
+
|
|
735
|
+
return 1;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// Spending stops at the cap; the ledger and every banked answer survive
|
|
739
|
+
// for the resume, which never pays for them again.
|
|
522
740
|
if (err instanceof ModelBudgetError) {
|
|
523
741
|
writeErr(
|
|
524
|
-
`Stopped at the run's
|
|
742
|
+
`Stopped at the run's cap: ${err.message}. Nothing past the cap was dispatched. To continue, approve a higher amount and run the same command with --max-usd <amount> (or --budget-file <limits.json>); literally-aeo status ${dir} shows the spend so far.`,
|
|
525
743
|
);
|
|
526
744
|
|
|
527
745
|
return 2;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { readRunStatus, type RunStatus } from '../engine/run-status';
|
|
3
|
+
import { formatLine, writeErr, writeOut, type Flags } from './io';
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// literally-aeo status <run-dir> (specs/aeo-claude-operator-spec.md §4.5):
|
|
7
|
+
// where a run is, what it has captured and what it has spent against its
|
|
8
|
+
// cap. Read-only and offline; safe to poll beside a running writer.
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
const usd = (value: number | undefined) => {
|
|
12
|
+
return value === undefined ? 'unknown' : `$${value.toFixed(2)}`;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const toJson = (status: RunStatus) => {
|
|
16
|
+
// JSON carries null where a value is unknown, never a guess.
|
|
17
|
+
const result = {
|
|
18
|
+
resultVersion: 1,
|
|
19
|
+
command: 'status',
|
|
20
|
+
runDirectory: { path: status.dir, state: status.state },
|
|
21
|
+
writer: status.writer ?? null,
|
|
22
|
+
phase: status.phase ?? null,
|
|
23
|
+
lastActivity: status.lastActivity
|
|
24
|
+
? {
|
|
25
|
+
...status.lastActivity,
|
|
26
|
+
stage: status.lastActivity.stage ?? null,
|
|
27
|
+
role: status.lastActivity.role ?? null,
|
|
28
|
+
}
|
|
29
|
+
: null,
|
|
30
|
+
completedStages: status.completedStages,
|
|
31
|
+
answers: { ...status.answers, planned: status.answers.planned ?? null },
|
|
32
|
+
spend: {
|
|
33
|
+
...status.spend,
|
|
34
|
+
capUsd: status.spend.capUsd ?? null,
|
|
35
|
+
deadlineAt: status.spend.deadlineAt ?? null,
|
|
36
|
+
remainingUsd: status.spend.remainingUsd ?? null,
|
|
37
|
+
},
|
|
38
|
+
lastError: status.lastError ?? null,
|
|
39
|
+
stoppedAtBudget: status.stoppedAtBudget,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const toText = (status: RunStatus) => {
|
|
46
|
+
const { answers, spend, writer, lastError } = status;
|
|
47
|
+
const lines = [
|
|
48
|
+
formatLine('Run directory', `${status.dir} (${status.state})`),
|
|
49
|
+
formatLine(
|
|
50
|
+
'Writer',
|
|
51
|
+
writer
|
|
52
|
+
? `${writer.purpose}, process ${writer.pid} on ${writer.host} since ${writer.since} (${writer.state})`
|
|
53
|
+
: 'none',
|
|
54
|
+
),
|
|
55
|
+
formatLine('Phase', status.phase ?? 'not started'),
|
|
56
|
+
formatLine(
|
|
57
|
+
'Stage outputs',
|
|
58
|
+
status.completedStages.length > 0
|
|
59
|
+
? status.completedStages.join(', ')
|
|
60
|
+
: 'none yet',
|
|
61
|
+
),
|
|
62
|
+
formatLine(
|
|
63
|
+
'Answers',
|
|
64
|
+
`${answers.captured} captured of ${answers.planned ?? 'unknown'} planned${answers.failed > 0 ? `, ${answers.failed} failed` : ''}`,
|
|
65
|
+
),
|
|
66
|
+
formatLine(
|
|
67
|
+
'Spend',
|
|
68
|
+
`${usd(spend.chargedUsd)} of ${usd(spend.capUsd)} (${usd(spend.openUsd)} reserved, not settled)`,
|
|
69
|
+
),
|
|
70
|
+
...Object.entries(spend.byCategory).map(([category, spent]) =>
|
|
71
|
+
formatLine(` ${category}`, `${usd(spent.usd)} in ${spent.calls} calls`),
|
|
72
|
+
),
|
|
73
|
+
formatLine(
|
|
74
|
+
'Last error',
|
|
75
|
+
lastError
|
|
76
|
+
? `${lastError.type} at ${lastError.at}: ${lastError.reason}`
|
|
77
|
+
: 'none',
|
|
78
|
+
),
|
|
79
|
+
...(status.stoppedAtBudget
|
|
80
|
+
? [
|
|
81
|
+
'',
|
|
82
|
+
"Stopped at the run's cap. To continue, approve a higher amount and run the same command with --max-usd <new total> (or --budget-file <limits.json>); it resumes.",
|
|
83
|
+
]
|
|
84
|
+
: []),
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
return lines.join('\n');
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const runStatus = async (flags: Flags, usage: string) => {
|
|
91
|
+
const target = flags.positional[0];
|
|
92
|
+
|
|
93
|
+
if (target === undefined) {
|
|
94
|
+
throw new Error(usage);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const dir = path.resolve(target);
|
|
98
|
+
const status = await readRunStatus(dir);
|
|
99
|
+
|
|
100
|
+
if (!status) {
|
|
101
|
+
writeErr(`${dir} holds no run.`);
|
|
102
|
+
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
writeOut(
|
|
107
|
+
flags.switches.has('--json')
|
|
108
|
+
? JSON.stringify(toJson(status))
|
|
109
|
+
: toText(status),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return 0;
|
|
113
|
+
};
|