literally-aeo 0.2.1 → 0.3.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/dist/cli.mjs +6075 -5175
- package/dist/lib/agents/author-schema.js +5 -5
- package/dist/lib/agents/author-validation.js +9 -7
- package/dist/lib/agents/copy-validation.js +10 -10
- package/dist/lib/agents/copywriter-input.js +9 -9
- package/dist/lib/agents/facts.js +8 -8
- package/dist/lib/agents/narrative-facts.js +6 -6
- package/dist/lib/agents/verifier.js +14 -13
- package/dist/lib/analysis/domain-classifier.js +12 -10
- package/dist/lib/analysis/domain-labels.js +4 -4
- package/dist/lib/analysis/outreach.js +2 -2
- package/dist/lib/analysis/progress.js +9 -9
- package/dist/lib/analysis/retrieval.js +5 -5
- package/dist/lib/analysis/scoring.js +5 -5
- package/dist/lib/analysis/search-analyzer.js +6 -6
- package/dist/lib/analysis/sentiment.js +12 -10
- package/dist/lib/analysis/source-mix.js +2 -2
- package/dist/lib/author/examples.js +6 -6
- package/dist/lib/bundle/contracts.js +6 -6
- package/dist/lib/bundle/export.js +18 -18
- package/dist/lib/bundle/journal.js +7 -7
- package/dist/lib/bundle/project-journal.js +10 -10
- package/dist/lib/bundle/project.js +16 -16
- package/dist/lib/bundle/read.js +19 -19
- package/dist/lib/bundle/recorder.js +8 -8
- package/dist/lib/bundle/redact.js +7 -7
- package/dist/lib/bundle/trace-coverage.js +7 -7
- package/dist/lib/bundle/verify-integrity.js +9 -9
- package/dist/lib/bundle/verify-measurement.js +22 -13
- package/dist/lib/bundle/verify-report.js +24 -16
- package/dist/lib/bundle/verify.js +32 -24
- package/dist/lib/capture-manifest.js +6 -6
- package/dist/lib/checks/crawler-access.js +2 -2
- package/dist/lib/checks/money-pages.js +13 -0
- package/dist/lib/checks/renderability.js +2 -2
- package/dist/lib/checks/run-checks.js +12 -12
- package/dist/lib/chunks/{chunk-XAKME6NM.js → chunk-2C723CW7.js} +1 -1
- package/dist/lib/chunks/chunk-2FDSOZ6Q.js +287 -0
- package/dist/lib/chunks/{chunk-PWOYEIPF.js → chunk-2U5QSA6Q.js} +7 -7
- package/dist/lib/chunks/{chunk-6EI4CVRW.js → chunk-3ESH5NDR.js} +5 -1
- package/dist/lib/chunks/{chunk-7LBSNDRR.js → chunk-3S2FAVRE.js} +22 -3
- package/dist/lib/chunks/{chunk-LR27H2HZ.js → chunk-44NSZBCP.js} +6 -6
- package/dist/lib/chunks/{chunk-JBOOD6MU.js → chunk-4AWFF53U.js} +12 -4
- package/dist/lib/chunks/{chunk-MENTBQGB.js → chunk-4HPMLJKC.js} +4 -4
- package/dist/lib/chunks/{chunk-AAFHXNLU.js → chunk-4Q2WFZ5J.js} +11 -4
- package/dist/lib/chunks/{chunk-SD7LR26G.js → chunk-5JU2Y2I6.js} +2 -2
- package/dist/lib/chunks/{chunk-RPTADJXD.js → chunk-64JFN2Q5.js} +1 -1
- package/dist/lib/chunks/chunk-66UE4TT2.js +245 -0
- package/dist/lib/chunks/chunk-6N3C6E3D.js +105 -0
- package/dist/lib/chunks/{chunk-F2NSJ6PG.js → chunk-6RED3G6K.js} +7 -3
- package/dist/lib/chunks/{chunk-QJZTDZMB.js → chunk-7KLTOVIY.js} +9 -9
- package/dist/lib/chunks/{chunk-PXB4PWJI.js → chunk-7ZR3WDF2.js} +38 -5
- package/dist/lib/chunks/chunk-A5PF7UE2.js +86 -0
- package/dist/lib/chunks/{chunk-JXBLGCXZ.js → chunk-AB7DUTX5.js} +1 -1
- package/dist/lib/chunks/{chunk-WDT2Y7D7.js → chunk-AQCWKHTE.js} +11 -7
- package/dist/lib/chunks/{chunk-SQQ56UP2.js → chunk-ASHFEFCU.js} +3 -3
- package/dist/lib/chunks/{chunk-AK6YNTCV.js → chunk-ASIFUJG2.js} +1 -1
- package/dist/lib/chunks/{chunk-ZSEY7AHQ.js → chunk-BBK54RVK.js} +14 -11
- package/dist/lib/chunks/chunk-BQMUZLHO.js +17 -0
- package/dist/lib/chunks/{chunk-KSOHZKV5.js → chunk-CQNIPZH3.js} +21 -21
- package/dist/lib/chunks/{chunk-7HM6IZ3L.js → chunk-CVEXMYPW.js} +2 -2
- package/dist/lib/chunks/chunk-CXZIHHLJ.js +95 -0
- package/dist/lib/chunks/{chunk-75DMLOQ7.js → chunk-CYJNBVQB.js} +1 -1
- package/dist/lib/chunks/{chunk-FAUFE7MI.js → chunk-D7N5OLYL.js} +1 -1
- package/dist/lib/chunks/{chunk-E2YTTB6Q.js → chunk-DSK3PM4Z.js} +1 -1
- package/dist/lib/chunks/{chunk-TNL2GWYR.js → chunk-EUXNCXCR.js} +22 -0
- package/dist/lib/chunks/{chunk-FJL2V6P5.js → chunk-F4EQULFR.js} +6 -6
- package/dist/lib/chunks/{chunk-QGZ4QSUE.js → chunk-FHV4PBYG.js} +1 -1
- package/dist/lib/chunks/chunk-FK2JQHAX.js +30 -0
- package/dist/lib/chunks/{chunk-K2FZFESR.js → chunk-FONFW67K.js} +4 -4
- package/dist/lib/chunks/{chunk-W5X7WJYL.js → chunk-FPPHYGIO.js} +3 -3
- package/dist/lib/chunks/{chunk-XNTFOVCE.js → chunk-FYE4R5TY.js} +2 -2
- package/dist/lib/chunks/{chunk-FIC7JSR4.js → chunk-H2DOBJZC.js} +2 -2
- package/dist/lib/chunks/{chunk-R2AJYV6A.js → chunk-HEWHNSDP.js} +68 -36
- package/dist/lib/chunks/{chunk-RXSHKWZJ.js → chunk-HLC6OHGO.js} +2 -2
- package/dist/lib/chunks/{chunk-6HMHXSCS.js → chunk-HXXFRZTJ.js} +2 -2
- package/dist/lib/chunks/{chunk-JYFEXVWC.js → chunk-HYMWNGOK.js} +13 -6
- package/dist/lib/chunks/chunk-IH67TEGY.js +73 -0
- package/dist/lib/chunks/{chunk-JKPBXPCW.js → chunk-IMADI2YP.js} +1 -1
- package/dist/lib/chunks/{chunk-SLAPBFRH.js → chunk-JBGQFPTY.js} +4 -4
- package/dist/lib/chunks/{chunk-JQDQVG3D.js → chunk-JDU3ZCKO.js} +1 -1
- package/dist/lib/chunks/{chunk-2KH7LNK7.js → chunk-JGIX427K.js} +7 -7
- package/dist/lib/chunks/{chunk-7CW6U5WJ.js → chunk-JIE2ANVD.js} +1 -1
- package/dist/lib/chunks/{chunk-T5XQ6NXD.js → chunk-JJFOILZK.js} +2 -2
- package/dist/lib/chunks/{chunk-F7DBTXKG.js → chunk-JMIK2QN3.js} +4 -3
- package/dist/lib/chunks/chunk-JW7DTYSI.js +116 -0
- package/dist/lib/chunks/{chunk-BFWK3TBN.js → chunk-JXLCKACO.js} +2 -2
- package/dist/lib/chunks/{chunk-7WO3FFPS.js → chunk-K5NQDJLE.js} +1 -1
- package/dist/lib/chunks/{chunk-BXF4OC74.js → chunk-KI2FB4Y3.js} +30 -16
- package/dist/lib/chunks/{chunk-Y2CZ6FZY.js → chunk-KRWDELRS.js} +30 -7
- package/dist/lib/chunks/{chunk-SIJOQRRK.js → chunk-KRXOJJR7.js} +1 -1
- package/dist/lib/chunks/chunk-KSUI4DAY.js +15 -0
- package/dist/lib/chunks/chunk-KXFZ3CH3.js +98 -0
- package/dist/lib/chunks/{chunk-3OWJBGQE.js → chunk-LJCWZ5SZ.js} +14 -14
- package/dist/lib/chunks/{chunk-AJKV46SM.js → chunk-LNYQMWJO.js} +3 -3
- package/dist/lib/chunks/{chunk-DL6YQDTE.js → chunk-LOIAGEKN.js} +2 -2
- package/dist/lib/chunks/{chunk-I3UE52ZV.js → chunk-LPOIMPJK.js} +2 -2
- package/dist/lib/chunks/{chunk-66T7JC57.js → chunk-LUKP64NX.js} +2 -2
- package/dist/lib/chunks/chunk-MNG5TZRW.js +208 -0
- package/dist/lib/chunks/{chunk-SMPP7B7F.js → chunk-MPQXB7HN.js} +7 -7
- package/dist/lib/chunks/{chunk-6JICXLDA.js → chunk-MZ2KN3IH.js} +3 -3
- package/dist/lib/chunks/chunk-N62G4EWT.js +91 -0
- package/dist/lib/chunks/{chunk-7YDXD4MD.js → chunk-ODIXZHHX.js} +1 -1
- package/dist/lib/chunks/{chunk-MTDYBJXH.js → chunk-OTVHGRCO.js} +8 -8
- package/dist/lib/chunks/{chunk-YZEZRQIG.js → chunk-OVF27NAO.js} +69 -17
- package/dist/lib/chunks/chunk-P6LHGBYU.js +90 -0
- package/dist/lib/chunks/{chunk-U5USH2HB.js → chunk-PAL5SXIP.js} +1 -1
- package/dist/lib/chunks/{chunk-W5XYW6ZM.js → chunk-PT6PK2MJ.js} +26 -19
- package/dist/lib/chunks/{chunk-OD36HUXA.js → chunk-Q22FCF4A.js} +6 -7
- package/dist/lib/chunks/chunk-QKTKQSPS.js +292 -0
- package/dist/lib/chunks/{chunk-K4Y5NT4M.js → chunk-QO5TPMWS.js} +2 -2
- package/dist/lib/chunks/{chunk-VPXYGN4I.js → chunk-QUZYFAGP.js} +17 -22
- package/dist/lib/chunks/{chunk-HI3PD3KR.js → chunk-QVMPTT7R.js} +5 -5
- package/dist/lib/chunks/{chunk-OQFAMKLN.js → chunk-RGZY6YUQ.js} +5 -5
- package/dist/lib/chunks/{chunk-U6BW6LGX.js → chunk-RM2VVR7Y.js} +1 -1
- package/dist/lib/chunks/{chunk-AJO7XVXK.js → chunk-RMSH7RUG.js} +6 -6
- package/dist/lib/chunks/{chunk-V5B6UZ3E.js → chunk-RQGEPR6V.js} +1 -0
- package/dist/lib/chunks/{chunk-V5JJEEBT.js → chunk-RYB77E7O.js} +6 -5
- package/dist/lib/chunks/chunk-S24JGY7B.js +97 -0
- package/dist/lib/chunks/{chunk-6GKKALCI.js → chunk-SF4UJ2AY.js} +1 -1
- package/dist/lib/chunks/chunk-SJCUR4QX.js +94 -0
- package/dist/lib/chunks/{chunk-XAN4CRFP.js → chunk-SQ55KGHO.js} +1 -1
- package/dist/lib/chunks/{chunk-66DVMLGR.js → chunk-TKOQMB6A.js} +7 -7
- package/dist/lib/chunks/{chunk-UYDQXXDQ.js → chunk-TWK6IA4P.js} +1 -1
- package/dist/lib/chunks/{chunk-DVFFYY5G.js → chunk-U42I3SBR.js} +13 -9
- package/dist/lib/chunks/{chunk-FL6LN2K6.js → chunk-UECQONVZ.js} +5 -5
- package/dist/lib/chunks/{chunk-FDM2YNQL.js → chunk-VTY53IFN.js} +1 -1
- package/dist/lib/chunks/chunk-VYUC772A.js +338 -0
- package/dist/lib/chunks/{chunk-WCLKIPJV.js → chunk-WPCBE2NZ.js} +1 -1
- package/dist/lib/chunks/{chunk-3OE4UQIB.js → chunk-WRHGLRUK.js} +5 -5
- package/dist/lib/chunks/{chunk-3GPUCXVA.js → chunk-WUIY7BXR.js} +36 -19
- package/dist/lib/chunks/{chunk-7YYDUHJG.js → chunk-WZA4H4TG.js} +39 -13
- package/dist/lib/chunks/{chunk-NH4QGBJV.js → chunk-XBSA7MNJ.js} +7 -2
- package/dist/lib/chunks/chunk-XTBCXEH7.js +243 -0
- package/dist/lib/chunks/{chunk-ZQ3ER7JD.js → chunk-YPVJAXPP.js} +1 -1
- package/dist/lib/chunks/{chunk-SASE7U6E.js → chunk-YQD5ITKI.js} +1 -1
- package/dist/lib/chunks/{chunk-DDS4G4DO.js → chunk-YY4BH5XM.js} +6 -6
- package/dist/lib/chunks/{chunk-J5NPHPXY.js → chunk-Z3BZRBQF.js} +36 -2
- package/dist/lib/chunks/{chunk-XFUYEFQP.js → chunk-ZBQU2VU3.js} +1 -1
- package/dist/lib/chunks/{chunk-E3OGPTUY.js → chunk-ZHGABG7L.js} +2 -2
- package/dist/lib/chunks/chunk-ZZCRYG36.js +31 -0
- package/dist/lib/cli/bundle-commands.js +91 -74
- package/dist/lib/cli/run-commands.js +141 -96
- package/dist/lib/cli/status-command.js +77 -60
- package/dist/lib/codex-workflow/aggregate.js +20 -12
- package/dist/lib/codex-workflow/author-tools.js +7 -7
- package/dist/lib/codex-workflow/author.js +25 -23
- package/dist/lib/codex-workflow/capture.js +39 -18
- package/dist/lib/codex-workflow/checkpoint.js +7 -7
- package/dist/lib/codex-workflow/checks.js +9 -9
- package/dist/lib/codex-workflow/copy-editor.js +20 -19
- package/dist/lib/codex-workflow/copy-recovery.js +4 -4
- package/dist/lib/codex-workflow/copy.js +17 -16
- package/dist/lib/codex-workflow/finish.js +29 -25
- package/dist/lib/codex-workflow/host-models.js +2 -2
- package/dist/lib/codex-workflow/loop.js +54 -48
- package/dist/lib/codex-workflow/quality.js +4 -4
- package/dist/lib/codex-workflow/run-inputs.js +6 -6
- package/dist/lib/codex-workflow/run-source.js +16 -16
- package/dist/lib/codex-workflow/schemas.js +6 -6
- package/dist/lib/codex-workflow/session.js +8 -8
- package/dist/lib/codex-workflow/stage.js +32 -29
- package/dist/lib/codex-workflow/workdir.js +18 -11
- package/dist/lib/engine/audit-file.js +9 -8
- package/dist/lib/engine/author.js +40 -37
- package/dist/lib/engine/cost-estimate.js +37 -9
- package/dist/lib/engine/local-run.js +76 -59
- package/dist/lib/engine/preflight.js +37 -9
- package/dist/lib/engine/rejudge.js +82 -65
- package/dist/lib/engine/run-bindings.js +62 -0
- package/dist/lib/engine/run-status.js +77 -60
- package/dist/lib/engine/templates.js +10 -9
- package/dist/lib/grounding/controller.js +8 -7
- package/dist/lib/grounding/extract.js +8 -6
- package/dist/lib/grounding/grounding-runtime.js +22 -21
- package/dist/lib/grounding/model-usage.js +2 -2
- package/dist/lib/grounding/model.js +7 -5
- package/dist/lib/grounding/recorded-tools.js +9 -9
- package/dist/lib/harness/report/artifacts.js +5 -5
- package/dist/lib/lib/checkpoint.js +5 -5
- package/dist/lib/lib/log.js +1 -1
- package/dist/lib/models/accounting.js +1 -1
- package/dist/lib/models/batching.js +6 -4
- package/dist/lib/models/budget-protection.js +1 -1
- package/dist/lib/models/cost-coefficients.js +2 -1
- package/dist/lib/models/gateway-cost.js +7 -0
- package/dist/lib/models/structured.js +5 -3
- package/dist/lib/models/supported-models.js +1 -1
- package/dist/lib/pipeline.js +36 -17
- package/dist/lib/probes/adapter.js +6 -0
- package/dist/lib/probes/adapters/cli-agents.js +44 -0
- package/dist/lib/probes/adapters/cli-claude-code.js +21 -0
- package/dist/lib/probes/adapters/cli-codex.js +23 -0
- package/dist/lib/probes/adapters/cli-cursor.js +21 -0
- package/dist/lib/probes/adapters/cli-process.js +34 -0
- package/dist/lib/probes/adapters/dataforseo-ai-overview.js +20 -0
- package/dist/lib/probes/adapters/gateway-chat.js +30 -0
- package/dist/lib/probes/adapters/gateway-perplexity.js +19 -0
- package/dist/lib/probes/agent-cli-parsers.js +2 -2
- package/dist/lib/probes/agent-clis.js +26 -11
- package/dist/lib/probes/answer-text.js +21 -0
- package/dist/lib/probes/attempt.js +28 -0
- package/dist/lib/probes/bindings.js +69 -0
- package/dist/lib/probes/charged-trace.js +47 -3
- package/dist/lib/probes/dataforseo-locale.js +1 -1
- package/dist/lib/probes/dataforseo.js +8 -5
- package/dist/lib/probes/grounding-urls.js +6 -4
- package/dist/lib/probes/legacy-bindings.js +7 -0
- package/dist/lib/probes/limits.js +1 -1
- package/dist/lib/probes/probes.js +33 -12
- package/dist/lib/runner.js +17 -14
- package/dist/lib/schema.js +4 -4
- package/dist/lib/section-result.js +6 -6
- package/dist/lib/stores/artifacts.js +7 -7
- package/dist/lib/stores/files.js +20 -18
- package/dist/lib/stores/local-versions.js +5 -5
- package/dist/lib/stores/memory.js +20 -15
- package/dist/lib/stores/publication.js +11 -11
- package/dist/lib/stores/unit-record.js +28 -0
- package/dist/lib/viewer/server.js +33 -25
- package/dist/lib/workflow/schema.js +3 -3
- package/dist/types/bundle/contracts.d.ts +1 -1
- package/dist/types/capture-manifest.d.ts +1 -0
- package/dist/types/checks/money-pages.d.ts +19 -0
- package/dist/types/codex-workflow/capture.d.ts +13 -0
- package/dist/types/codex-workflow/workdir.d.ts +0 -1
- package/dist/types/engine/cost-estimate.d.ts +5 -1
- package/dist/types/engine/preflight.d.ts +6 -1
- package/dist/types/engine/run-bindings.d.ts +25 -0
- package/dist/types/models/accounting.d.ts +7 -0
- package/dist/types/models/cost-coefficients.d.ts +5 -5
- package/dist/types/models/gateway-cost.d.ts +3 -0
- package/dist/types/pipeline.d.ts +2 -0
- package/dist/types/probes/adapter.d.ts +112 -0
- package/dist/types/probes/adapters/cli-agents.d.ts +19 -0
- package/dist/types/probes/adapters/cli-claude-code.d.ts +4 -0
- package/dist/types/probes/adapters/cli-codex.d.ts +10 -0
- package/dist/types/probes/adapters/cli-cursor.d.ts +4 -0
- package/dist/types/probes/adapters/cli-process.d.ts +86 -0
- package/dist/types/probes/adapters/dataforseo-ai-overview.d.ts +12 -0
- package/dist/types/probes/adapters/gateway-chat.d.ts +32 -0
- package/dist/types/probes/adapters/gateway-perplexity.d.ts +10 -0
- package/dist/types/probes/agent-clis.d.ts +7 -49
- package/dist/types/probes/answer-text.d.ts +20 -0
- package/dist/types/probes/attempt.d.ts +113 -0
- package/dist/types/probes/bindings.d.ts +79 -0
- package/dist/types/probes/charged-trace.d.ts +2 -1
- package/dist/types/probes/dataforseo.d.ts +24 -1
- package/dist/types/probes/grounding-urls.d.ts +18 -5
- package/dist/types/probes/legacy-bindings.d.ts +36 -0
- package/dist/types/probes/limits.d.ts +12 -6
- package/dist/types/probes/probe-trace.d.ts +10 -0
- package/dist/types/probes/probes.d.ts +5 -3
- package/dist/types/stores/ports.d.ts +1 -0
- package/dist/types/stores/unit-record.d.ts +11 -0
- package/package.json +6 -6
- package/src/agents/author-validation.ts +22 -1
- package/src/analysis/progress.ts +10 -1
- package/src/bundle/contracts.ts +1 -1
- package/src/bundle/recorder.ts +47 -1
- package/src/capture-manifest.ts +6 -0
- package/src/checks/money-pages.ts +48 -0
- package/src/cli/run-commands.ts +37 -1
- package/src/codex-workflow/capture.ts +60 -0
- package/src/codex-workflow/workdir.ts +3 -4
- package/src/engine/audit-file.ts +20 -30
- package/src/engine/cost-estimate.ts +10 -4
- package/src/engine/local-run.ts +21 -2
- package/src/engine/preflight.ts +113 -17
- package/src/engine/rejudge.ts +5 -0
- package/src/engine/run-bindings.ts +142 -0
- package/src/grounding/extract.ts +1 -0
- package/src/grounding/model-usage.ts +4 -0
- package/src/lib/log.ts +17 -15
- package/src/models/accounting.ts +34 -0
- package/src/models/budget-protection.ts +1 -0
- package/src/models/cost-coefficients.ts +17 -13
- package/src/models/gateway-cost.ts +32 -0
- package/src/models/structured.ts +2 -10
- package/src/models/supported-models.ts +3 -3
- package/src/pipeline.ts +36 -17
- package/src/probes/adapter.ts +122 -0
- package/src/probes/adapters/cli-agents.ts +123 -0
- package/src/probes/adapters/cli-claude-code.ts +119 -0
- package/src/probes/adapters/cli-codex.ts +145 -0
- package/src/probes/adapters/cli-cursor.ts +95 -0
- package/src/probes/adapters/cli-process.ts +522 -0
- package/src/probes/adapters/dataforseo-ai-overview.ts +106 -0
- package/src/probes/adapters/gateway-chat.ts +339 -0
- package/src/probes/adapters/gateway-perplexity.ts +104 -0
- package/src/probes/agent-clis.ts +151 -1088
- package/src/probes/answer-text.ts +153 -0
- package/src/probes/attempt.ts +462 -0
- package/src/probes/bindings.ts +344 -0
- package/src/probes/charged-trace.ts +54 -13
- package/src/probes/dataforseo-locale.ts +13 -2
- package/src/probes/dataforseo.ts +265 -188
- package/src/probes/grounding-urls.ts +68 -19
- package/src/probes/legacy-bindings.ts +40 -0
- package/src/probes/limits.ts +31 -18
- package/src/probes/probe-trace.ts +10 -0
- package/src/probes/probes.ts +64 -736
- package/src/runner.ts +13 -0
- package/src/stores/files.ts +78 -54
- package/src/stores/memory.ts +4 -1
- package/src/stores/ports.ts +3 -0
- package/src/stores/unit-record.ts +151 -0
- package/dist/lib/chunks/chunk-BGAHZIL3.js +0 -563
- package/dist/lib/chunks/chunk-IB6RROHE.js +0 -204
- package/dist/lib/chunks/chunk-WZGI7UVM.js +0 -937
package/src/engine/local-run.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { acquireWriterLock, type WriterLock } from '../bundle/writer-lock';
|
|
12
12
|
import { capturePlan } from '../capture-manifest';
|
|
13
13
|
import {
|
|
14
|
+
assertBankUsable,
|
|
14
15
|
captureForRun,
|
|
15
16
|
agentSurfacesToCapture,
|
|
16
17
|
} from '../codex-workflow/capture';
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
} from '../models/accounting';
|
|
35
36
|
import { resolveSupportedModel } from '../models/supported-models';
|
|
36
37
|
import { chargedProbeTrace } from '../probes/charged-trace';
|
|
38
|
+
import { probeDependenciesOf } from '../probes/bindings';
|
|
37
39
|
import type { InternalModelContext } from '../models/context';
|
|
38
40
|
import { ProbeLimiter } from '../probes/limits';
|
|
39
41
|
import { planRun, type RunPlan } from '../runner';
|
|
@@ -43,7 +45,9 @@ import { openFileStores } from '../stores/files';
|
|
|
43
45
|
import type { CapturedUnitRecord } from '../stores/ports';
|
|
44
46
|
import { getEnvironment } from '../lib/env';
|
|
45
47
|
import { toAuditConfig, toRunRequest, type AuditFile } from './audit-file';
|
|
48
|
+
import { resolveRunBindings } from './run-bindings';
|
|
46
49
|
import {
|
|
50
|
+
readFrozenBudget,
|
|
47
51
|
resolveRunBudget,
|
|
48
52
|
type BudgetAmendment,
|
|
49
53
|
type RunBudget,
|
|
@@ -228,6 +232,14 @@ const openLockedLocalRun = async (
|
|
|
228
232
|
},
|
|
229
233
|
): Promise<LocalRun> => {
|
|
230
234
|
const { recorder } = held;
|
|
235
|
+
const bank = path.join(dir, bankDir);
|
|
236
|
+
// Frozen before the budget and the first canary, then kept on every
|
|
237
|
+
// resume: a directory that holds a budget but no bindings started before
|
|
238
|
+
// bindings were frozen. Frozen after the budget, an attempt stopped
|
|
239
|
+
// between the two (a refused plan, a crash) would read as one.
|
|
240
|
+
const bindings = await resolveRunBindings(bank, {
|
|
241
|
+
startedBefore: (await readFrozenBudget(dir)) !== undefined,
|
|
242
|
+
});
|
|
231
243
|
const budget = await resolveRunBudget(dir, file.runPolicy.budget, {
|
|
232
244
|
model: resolveSupportedModel(file.model).id,
|
|
233
245
|
...(maxUsd !== undefined && { maxUsd }),
|
|
@@ -239,7 +251,6 @@ const openLockedLocalRun = async (
|
|
|
239
251
|
...(derivedFromRunId !== undefined && { derivedFromRunId }),
|
|
240
252
|
};
|
|
241
253
|
const plan = planRun(config, request);
|
|
242
|
-
const bank = path.join(dir, bankDir);
|
|
243
254
|
const stores = await openFileStores(config.reportKey, {
|
|
244
255
|
checkpointDir: bank,
|
|
245
256
|
contentDir: path.join(bank, 'report'),
|
|
@@ -280,6 +291,9 @@ const openLockedLocalRun = async (
|
|
|
280
291
|
recorder,
|
|
281
292
|
),
|
|
282
293
|
};
|
|
294
|
+
// Before the canaries, which dispatch: a bank the run cannot build on
|
|
295
|
+
// stops it with nothing sent.
|
|
296
|
+
await assertBankUsable(stores.probeStore, plan, bindings);
|
|
283
297
|
const agents = await agentSurfacesToCapture(plan, stores.probeStore);
|
|
284
298
|
const agentCliVersions = await detectAgentClis();
|
|
285
299
|
|
|
@@ -297,8 +311,13 @@ const openLockedLocalRun = async (
|
|
|
297
311
|
);
|
|
298
312
|
}
|
|
299
313
|
|
|
300
|
-
const probes = chargedProbeTrace(
|
|
314
|
+
const probes = chargedProbeTrace(
|
|
315
|
+
probeTraceOf(recorder, 'probe'),
|
|
316
|
+
ledger,
|
|
317
|
+
bindings,
|
|
318
|
+
);
|
|
301
319
|
const capture = await captureForRun({
|
|
320
|
+
probeDependencies: probeDependenciesOf(getEnvironment(), bindings),
|
|
302
321
|
config,
|
|
303
322
|
request,
|
|
304
323
|
plan,
|
package/src/engine/preflight.ts
CHANGED
|
@@ -7,6 +7,12 @@ import {
|
|
|
7
7
|
detectAgentClis,
|
|
8
8
|
versionForSurface,
|
|
9
9
|
} from '../probes/agent-clis';
|
|
10
|
+
import {
|
|
11
|
+
probeAdapterProfiles,
|
|
12
|
+
profileOf,
|
|
13
|
+
type ProbeBinding,
|
|
14
|
+
type RunBindings,
|
|
15
|
+
} from '../probes/bindings';
|
|
10
16
|
import {
|
|
11
17
|
agentSurfaces,
|
|
12
18
|
isAgentSurface,
|
|
@@ -43,22 +49,32 @@ export type PreflightCheck = {
|
|
|
43
49
|
const gatewaySetting = 'AI_GATEWAY_API_KEY';
|
|
44
50
|
const overviewSettings = ['DATAFORSEO_LOGIN', 'DATAFORSEO_PASSWORD'] as const;
|
|
45
51
|
|
|
46
|
-
// The
|
|
47
|
-
|
|
48
|
-
export const credentialSettingNames = [
|
|
52
|
+
// The engine's own secrets, outside the probe adapters' settings.
|
|
53
|
+
export const engineSecretSettingNames = [
|
|
49
54
|
'AI_GATEWAY_API_KEY',
|
|
50
55
|
'DATAFORSEO_PASSWORD',
|
|
51
56
|
'AEO_DATABASE_URL',
|
|
52
57
|
'AEO_SITE_DATABASE_URL',
|
|
53
58
|
'AEO_API_TOKEN',
|
|
54
|
-
'OPENAI_API_KEY',
|
|
55
|
-
'ANTHROPIC_API_KEY',
|
|
56
|
-
'CLAUDE_CODE_OAUTH_TOKEN',
|
|
57
59
|
'GOOGLE_GENERATIVE_AI_API_KEY',
|
|
58
60
|
'PERPLEXITY_API_KEY',
|
|
59
|
-
'CURSOR_API_KEY',
|
|
60
61
|
] as const;
|
|
61
62
|
|
|
63
|
+
// The run's own credentials, by variable name: their values never enter a
|
|
64
|
+
// bundle. Values only; the names are not secret. A probe adapter's
|
|
65
|
+
// non-secret settings (a login name, a directory) stay out, or an export
|
|
66
|
+
// would refuse a bundle that merely mentions them.
|
|
67
|
+
export const credentialSettingNames: readonly string[] = [
|
|
68
|
+
...new Set([
|
|
69
|
+
...engineSecretSettingNames,
|
|
70
|
+
...Object.values(probeAdapterProfiles).flatMap((profile) =>
|
|
71
|
+
profile.settings
|
|
72
|
+
.filter((setting) => setting.secret)
|
|
73
|
+
.map((setting) => setting.name),
|
|
74
|
+
),
|
|
75
|
+
]),
|
|
76
|
+
];
|
|
77
|
+
|
|
62
78
|
/** Every setting a run may read, for applying the env file. */
|
|
63
79
|
export const runSettingNames = [
|
|
64
80
|
gatewaySetting,
|
|
@@ -66,6 +82,26 @@ export const runSettingNames = [
|
|
|
66
82
|
...Object.values(agentAuthEnv).flatMap((auth) => auth.anyOf),
|
|
67
83
|
];
|
|
68
84
|
|
|
85
|
+
// A coding agent's probes bill its own plan, outside the run's cap; an
|
|
86
|
+
// auth setting that bills a provider account per use (an API key) says so,
|
|
87
|
+
// since the cap does not see that spend either.
|
|
88
|
+
const agentAuthDetail = (
|
|
89
|
+
binding: ProbeBinding,
|
|
90
|
+
auth: ReturnType<typeof agentAuthMode>,
|
|
91
|
+
): string => {
|
|
92
|
+
if (auth.kind === 'cli_session') {
|
|
93
|
+
return 'uses the CLI login on this machine, checked by a canary before the run';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const account = profileOf(binding).settings.find(
|
|
97
|
+
(setting) => setting.name === auth.name,
|
|
98
|
+
)?.billsAccount;
|
|
99
|
+
|
|
100
|
+
return account === undefined
|
|
101
|
+
? `authenticates with ${auth.name}`
|
|
102
|
+
: `authenticates with ${auth.name}, billed to that ${account} account outside the run's cap`;
|
|
103
|
+
};
|
|
104
|
+
|
|
69
105
|
/** How an agent surface authenticates on this machine: a variable, or the
|
|
70
106
|
* CLI's own login, which only the run's canary can prove. */
|
|
71
107
|
export const agentAuthMode = (
|
|
@@ -81,6 +117,46 @@ export const agentAuthMode = (
|
|
|
81
117
|
: { kind: 'variable', name };
|
|
82
118
|
};
|
|
83
119
|
|
|
120
|
+
const sourceLabel = (name: string, settings: Settings): string => {
|
|
121
|
+
const source = settings.sourceOf(name);
|
|
122
|
+
|
|
123
|
+
if (source === undefined) {
|
|
124
|
+
return `${name} not set`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return `${name} from the ${source === 'environment' ? 'process environment' : 'env file'}`;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** bindingLabel names an adapter and the model it is bound to. */
|
|
131
|
+
const bindingLabel = (binding: ProbeBinding): string => {
|
|
132
|
+
return binding.model === undefined
|
|
133
|
+
? binding.adapter
|
|
134
|
+
: `${binding.adapter} with ${binding.model}`;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/** A chat surface's bound adapter, with the settings it needs by name and
|
|
138
|
+
* where each is set, never its value. */
|
|
139
|
+
const chatBindingCheck = (
|
|
140
|
+
surface: AeoSurface,
|
|
141
|
+
binding: ProbeBinding,
|
|
142
|
+
settings: Settings,
|
|
143
|
+
): PreflightCheck => {
|
|
144
|
+
const required = profileOf(binding).settings.filter(
|
|
145
|
+
(setting) => setting.group === undefined,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
name: `${surface} probes`,
|
|
150
|
+
ok: required.every(
|
|
151
|
+
(setting) => settings.sourceOf(setting.name) !== undefined,
|
|
152
|
+
),
|
|
153
|
+
detail: [
|
|
154
|
+
bindingLabel(binding),
|
|
155
|
+
...required.map((setting) => sourceLabel(setting.name, settings)),
|
|
156
|
+
].join('; '),
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
84
160
|
const settingCheck = (name: string, settings: Settings): PreflightCheck => {
|
|
85
161
|
const source = settings.sourceOf(name);
|
|
86
162
|
|
|
@@ -220,8 +296,11 @@ export const runPreflight = async (args: {
|
|
|
220
296
|
groundingSearch?: boolean;
|
|
221
297
|
/** Money pages are rendered in Chromium by the renderability check. */
|
|
222
298
|
rendersPages?: boolean;
|
|
299
|
+
/** The bindings the run measures with: each surface's adapter, whose
|
|
300
|
+
* settings preflight requires. */
|
|
301
|
+
bindings: RunBindings;
|
|
223
302
|
}): Promise<PreflightCheck[]> => {
|
|
224
|
-
const { surfaces, settings } = args;
|
|
303
|
+
const { surfaces, settings, bindings } = args;
|
|
225
304
|
const nodeMajor = Number(process.versions.node.split('.')[0]);
|
|
226
305
|
const versions = await detectAgentClis();
|
|
227
306
|
const agents = surfaces.filter(isAgentSurface);
|
|
@@ -235,28 +314,45 @@ export const runPreflight = async (args: {
|
|
|
235
314
|
modelCheck(args.model),
|
|
236
315
|
// Every stage session runs on Codex, whatever is measured.
|
|
237
316
|
await codexCheck(),
|
|
238
|
-
settingCheck(gatewaySetting, settings),
|
|
239
317
|
];
|
|
240
318
|
|
|
241
|
-
//
|
|
319
|
+
// Each setting the run needs once: the gateway key always, for the
|
|
320
|
+
// host's own model calls whatever is measured; every ungrouped setting of
|
|
321
|
+
// a bound adapter in scope; and the search provider's pair when full
|
|
322
|
+
// grounding searches through it, so a pinned provider never degrades to
|
|
242
323
|
// `unavailable` searches mid-run (spec §3.3).
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
)
|
|
247
|
-
|
|
324
|
+
const chatSurfaces = surfaces.filter((surface) => !isAgentSurface(surface));
|
|
325
|
+
const required = new Set<string>([
|
|
326
|
+
gatewaySetting,
|
|
327
|
+
...chatSurfaces.flatMap((surface) =>
|
|
328
|
+
profileOf(bindings[surface])
|
|
329
|
+
.settings.filter((setting) => setting.group === undefined)
|
|
330
|
+
.map((setting) => setting.name),
|
|
331
|
+
),
|
|
332
|
+
...(args.groundingSearch ? overviewSettings : []),
|
|
333
|
+
]);
|
|
334
|
+
|
|
335
|
+
checks.push(
|
|
336
|
+
...[...required].map((name) => settingCheck(name, settings)),
|
|
337
|
+
...chatSurfaces.map((surface) =>
|
|
338
|
+
chatBindingCheck(surface, bindings[surface], settings),
|
|
339
|
+
),
|
|
340
|
+
);
|
|
248
341
|
|
|
342
|
+
// A coding agent authenticates with any one of its adapter's auth
|
|
343
|
+
// settings, or with the CLI's own login, which only the canary can prove.
|
|
249
344
|
for (const surface of agents) {
|
|
250
345
|
const version = versionForSurface(surface, versions);
|
|
251
346
|
const auth = agentAuthMode(surface, settings);
|
|
347
|
+
const binding = bindingLabel(bindings[surface]);
|
|
252
348
|
|
|
253
349
|
checks.push({
|
|
254
350
|
name: `${surface} probes`,
|
|
255
351
|
ok: version !== null,
|
|
256
352
|
detail:
|
|
257
353
|
version === null
|
|
258
|
-
?
|
|
259
|
-
: `${cliNameForSurface(surface)} ${version}; ${
|
|
354
|
+
? `${binding}; \`${cliNameForSurface(surface)}\` not found on PATH`
|
|
355
|
+
: `${binding}; ${cliNameForSurface(surface)} ${version}; ${agentAuthDetail(bindings[surface], auth)}`,
|
|
260
356
|
});
|
|
261
357
|
}
|
|
262
358
|
|
package/src/engine/rejudge.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { readRunInputs } from '../codex-workflow/run-inputs';
|
|
|
11
11
|
import { hasErrorCode } from '../stores/fs-errors';
|
|
12
12
|
import { localReportKey, type AuditFile } from './audit-file';
|
|
13
13
|
import { bankDir, planLocalRun, runDirectoryState } from './local-run';
|
|
14
|
+
import { carryFrozenBindings } from './run-bindings';
|
|
14
15
|
|
|
15
16
|
const technicalFile = 'TECHNICAL.json';
|
|
16
17
|
|
|
@@ -87,6 +88,10 @@ export const prepareRejudgment = async ({
|
|
|
87
88
|
path.join(source, bankDir, `${reportKey}.jsonl`),
|
|
88
89
|
path.join(target, bankDir, `${reportKey}.jsonl`),
|
|
89
90
|
);
|
|
91
|
+
await carryFrozenBindings(
|
|
92
|
+
path.join(source, bankDir),
|
|
93
|
+
path.join(target, bankDir),
|
|
94
|
+
);
|
|
90
95
|
// The technical checks are part of the measurement, like the captures:
|
|
91
96
|
// a rejudgment judges the site as it was, never as it is today.
|
|
92
97
|
await copyFile(
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { copyFile, readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { writeFileAtomically } from '../codex-workflow/pending';
|
|
5
|
+
import {
|
|
6
|
+
availableBindings,
|
|
7
|
+
defaultProbeBindings,
|
|
8
|
+
RunBindingsError,
|
|
9
|
+
type RunBindings,
|
|
10
|
+
} from '../probes/bindings';
|
|
11
|
+
import { legacyProbeBindings } from '../probes/legacy-bindings';
|
|
12
|
+
import { hasErrorCode } from '../stores/fs-errors';
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// A run's frozen bindings (specs/aeo-probe-adapters-spec.md §4.5): written
|
|
16
|
+
// to BANK/bindings.json before the first canary and read back on every
|
|
17
|
+
// resume, like the budget's cap and model. A directory from before this
|
|
18
|
+
// file existed is frozen with the legacy bindings, the ones its banked
|
|
19
|
+
// answers were captured with.
|
|
20
|
+
// ============================================================================
|
|
21
|
+
|
|
22
|
+
export const bindingsFile = 'bindings.json';
|
|
23
|
+
|
|
24
|
+
const frozenBindingsSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
version: z.literal(1),
|
|
27
|
+
bindings: z.record(
|
|
28
|
+
z.string(),
|
|
29
|
+
z
|
|
30
|
+
.object({
|
|
31
|
+
adapter: z.string().min(1),
|
|
32
|
+
model: z.string().min(1).optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict(),
|
|
35
|
+
),
|
|
36
|
+
})
|
|
37
|
+
.strict();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* estimateBindingsOf is the bindings a run directory's estimate prices: its
|
|
41
|
+
* frozen bindings once it has usable ones, else the defaults a new run
|
|
42
|
+
* would freeze. Read-only. A frozen binding the engine cannot build is the
|
|
43
|
+
* run's start to refuse (exit 2), not the estimate's.
|
|
44
|
+
*/
|
|
45
|
+
export const estimateBindingsOf = async (
|
|
46
|
+
bankPath: string,
|
|
47
|
+
): Promise<RunBindings> => {
|
|
48
|
+
const text = await readFile(path.join(bankPath, bindingsFile), 'utf8').catch(
|
|
49
|
+
(err: unknown) => {
|
|
50
|
+
if (hasErrorCode(err, 'ENOENT')) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
throw err;
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (text === undefined) {
|
|
59
|
+
return defaultProbeBindings;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
return availableBindings(
|
|
64
|
+
frozenBindingsSchema.parse(JSON.parse(text)).bindings,
|
|
65
|
+
);
|
|
66
|
+
} catch {
|
|
67
|
+
// Refused with its reason when the run starts.
|
|
68
|
+
return defaultProbeBindings;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* resolveRunBindings returns the bindings a run measures with: the frozen
|
|
74
|
+
* ones on a resume, refused when the installed engine cannot build them;
|
|
75
|
+
* otherwise the defaults for a new run, or the legacy bindings for a run
|
|
76
|
+
* that started before bindings were frozen, written before they are used.
|
|
77
|
+
*/
|
|
78
|
+
export const resolveRunBindings = async (
|
|
79
|
+
bankPath: string,
|
|
80
|
+
{ startedBefore }: { startedBefore: boolean },
|
|
81
|
+
): Promise<RunBindings> => {
|
|
82
|
+
const file = path.join(bankPath, bindingsFile);
|
|
83
|
+
const text = await readFile(file, 'utf8').catch((err: unknown) => {
|
|
84
|
+
if (hasErrorCode(err, 'ENOENT')) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
throw err;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (text !== undefined) {
|
|
92
|
+
let frozen: z.infer<typeof frozenBindingsSchema>;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
frozen = frozenBindingsSchema.parse(JSON.parse(text));
|
|
96
|
+
} catch (error) {
|
|
97
|
+
throw new RunBindingsError(
|
|
98
|
+
`${file} is not a frozen bindings file (${error instanceof Error ? error.message.slice(0, 200) : String(error)}). Please restore it; a run never re-chooses how it measures.`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return availableBindings(frozen.bindings);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const bindings = startedBefore ? legacyProbeBindings : defaultProbeBindings;
|
|
106
|
+
|
|
107
|
+
await freezeBindings(bankPath, bindings);
|
|
108
|
+
|
|
109
|
+
return bindings;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* carryFrozenBindings gives a derived run directory (a rejudgment) the
|
|
114
|
+
* bindings its reused answers were captured under: the source's frozen
|
|
115
|
+
* file, or, from before bindings were frozen, the legacy bindings. Never
|
|
116
|
+
* the installed defaults.
|
|
117
|
+
*/
|
|
118
|
+
export const carryFrozenBindings = async (
|
|
119
|
+
sourceBank: string,
|
|
120
|
+
targetBank: string,
|
|
121
|
+
): Promise<void> => {
|
|
122
|
+
await copyFile(
|
|
123
|
+
path.join(sourceBank, bindingsFile),
|
|
124
|
+
path.join(targetBank, bindingsFile),
|
|
125
|
+
).catch(async (err: unknown) => {
|
|
126
|
+
if (!hasErrorCode(err, 'ENOENT')) {
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
await freezeBindings(targetBank, legacyProbeBindings);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const freezeBindings = async (
|
|
135
|
+
bankPath: string,
|
|
136
|
+
bindings: RunBindings,
|
|
137
|
+
): Promise<void> => {
|
|
138
|
+
await writeFileAtomically(
|
|
139
|
+
path.join(bankPath, bindingsFile),
|
|
140
|
+
`${JSON.stringify({ version: 1, bindings }, null, 2)}\n`,
|
|
141
|
+
);
|
|
142
|
+
};
|
package/src/grounding/extract.ts
CHANGED
|
@@ -556,6 +556,7 @@ export const extractClaimCandidates = async (args: {
|
|
|
556
556
|
observe: (id, evidence) =>
|
|
557
557
|
args.accounting.observe?.(id, evidence) ?? Promise.resolve(),
|
|
558
558
|
settle: (id, usage) => args.accounting.settle(id, usage),
|
|
559
|
+
release: (id) => args.accounting.release(id),
|
|
559
560
|
reserve: async (call) => {
|
|
560
561
|
const hadInFlight = inFlight.size > 0;
|
|
561
562
|
|
package/src/lib/log.ts
CHANGED
|
@@ -30,12 +30,11 @@ const levelOrder: Record<LogLevel, number> = {
|
|
|
30
30
|
// Console formatting
|
|
31
31
|
// ---------------------------------------------------------------------------
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const useColor = Boolean(process.stdout.isTTY) && !NO_COLOR;
|
|
33
|
+
// Read when a line is emitted, never into a constant at import: every
|
|
34
|
+
// module imports this one, and importing a library module reads nothing.
|
|
35
|
+
const useColor = (): boolean => {
|
|
36
|
+
return Boolean(process.stdout.isTTY) && !readEnv('NO_COLOR');
|
|
37
|
+
};
|
|
39
38
|
|
|
40
39
|
const ansi = {
|
|
41
40
|
reset: '\u001b[0m',
|
|
@@ -47,14 +46,14 @@ const ansi = {
|
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
const paint = (text: string, color: string): string => {
|
|
50
|
-
return useColor ? `${color}${text}${ansi.reset}` : text;
|
|
49
|
+
return useColor() ? `${color}${text}${ansi.reset}` : text;
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
const levelTags: Record<LogLevel, string> = {
|
|
54
|
-
debug:
|
|
55
|
-
info:
|
|
56
|
-
warn:
|
|
57
|
-
error:
|
|
52
|
+
const levelTags: Record<LogLevel, { text: string; color: string }> = {
|
|
53
|
+
debug: { text: 'DEBUG', color: ansi.gray },
|
|
54
|
+
info: { text: 'INFO ', color: ansi.cyan },
|
|
55
|
+
warn: { text: 'WARN ', color: ansi.yellow },
|
|
56
|
+
error: { text: 'ERROR', color: ansi.red },
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
const formatClockTime = (date: Date): string => {
|
|
@@ -89,18 +88,21 @@ const formatFields = (fields?: LogFields): string => {
|
|
|
89
88
|
return ` ${parts.join(' ')}`;
|
|
90
89
|
};
|
|
91
90
|
|
|
92
|
-
const consoleMinLevel
|
|
91
|
+
const consoleMinLevel = (): LogLevel => {
|
|
92
|
+
return readEnv('AEO_DEBUG') ? 'debug' : 'info';
|
|
93
|
+
};
|
|
93
94
|
|
|
94
95
|
// ---------------------------------------------------------------------------
|
|
95
96
|
// Emission
|
|
96
97
|
// ---------------------------------------------------------------------------
|
|
97
98
|
|
|
98
99
|
const emit = ({ level, component, message, fields }: LogEntry): void => {
|
|
99
|
-
if (levelOrder[level] < levelOrder[consoleMinLevel]) {
|
|
100
|
+
if (levelOrder[level] < levelOrder[consoleMinLevel()]) {
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
const
|
|
104
|
+
const tag = levelTags[level];
|
|
105
|
+
const line = `${paint(formatClockTime(new Date()), ansi.dim)} ${paint(tag.text, tag.color)} ${paint(
|
|
104
106
|
`[${component}]`,
|
|
105
107
|
ansi.dim,
|
|
106
108
|
)} ${message}${paint(formatFields(fields), ansi.dim)}`;
|
package/src/models/accounting.ts
CHANGED
|
@@ -127,6 +127,13 @@ export type ModelCallAccounting = {
|
|
|
127
127
|
reserve(call: ModelCallReservation): Promise<void>;
|
|
128
128
|
assertOwned(): Promise<void>;
|
|
129
129
|
settle(callId: string, usage: ModelCallUsage): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Withdraws a reservation whose call was never dispatched (its operation
|
|
132
|
+
* could not be recorded first). Unlike a settlement at $0, it records no
|
|
133
|
+
* cost the provider did not report: the call leaves the ledger. A settled
|
|
134
|
+
* call cannot be released.
|
|
135
|
+
*/
|
|
136
|
+
release(callId: string): Promise<void>;
|
|
130
137
|
/** Present when the run records its execution: the request before
|
|
131
138
|
* dispatch, the response before settlement. A failure stops the call. */
|
|
132
139
|
observe?(callId: string, evidence: ModelCallEvidence): Promise<void>;
|
|
@@ -318,6 +325,22 @@ const settleCall = (
|
|
|
318
325
|
return settled;
|
|
319
326
|
};
|
|
320
327
|
|
|
328
|
+
const releaseCall = (state: BudgetState, callId: string): BudgetState => {
|
|
329
|
+
const call = state.calls[callId];
|
|
330
|
+
|
|
331
|
+
if (!call) {
|
|
332
|
+
throw new ModelBudgetError('Model call was not reserved');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (call.usage) {
|
|
336
|
+
throw new ModelBudgetError('A settled model call cannot be released');
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const { [callId]: _released, ...calls } = state.calls;
|
|
340
|
+
|
|
341
|
+
return { ...state, calls };
|
|
342
|
+
};
|
|
343
|
+
|
|
321
344
|
// Runs synchronous work so that a throw becomes a rejected promise, as it would
|
|
322
345
|
// inside an async function.
|
|
323
346
|
const runAsPromise = (work: () => void) => {
|
|
@@ -348,6 +371,11 @@ export const createMemoryModelAccounting = (
|
|
|
348
371
|
state.calls = settleCall(state, { callId, usage }).calls;
|
|
349
372
|
});
|
|
350
373
|
},
|
|
374
|
+
release: (callId: string) => {
|
|
375
|
+
return runAsPromise(() => {
|
|
376
|
+
state.calls = releaseCall(state, callId).calls;
|
|
377
|
+
});
|
|
378
|
+
},
|
|
351
379
|
};
|
|
352
380
|
|
|
353
381
|
return accounting;
|
|
@@ -463,6 +491,9 @@ export const createFileModelAccounting = (args: {
|
|
|
463
491
|
settle: async (callId, usage) => {
|
|
464
492
|
await update((state) => settleCall(state, { callId, usage }));
|
|
465
493
|
},
|
|
494
|
+
release: async (callId) => {
|
|
495
|
+
await update((state) => releaseCall(state, callId));
|
|
496
|
+
},
|
|
466
497
|
};
|
|
467
498
|
|
|
468
499
|
return accounting;
|
|
@@ -650,6 +681,9 @@ export const createPostgresModelAccounting = (args: {
|
|
|
650
681
|
settle: async (callId, usage) => {
|
|
651
682
|
await update((state) => settleCall(state, { callId, usage }));
|
|
652
683
|
},
|
|
684
|
+
release: async (callId) => {
|
|
685
|
+
await update((state) => releaseCall(state, callId));
|
|
686
|
+
},
|
|
653
687
|
};
|
|
654
688
|
|
|
655
689
|
return accounting;
|
|
@@ -35,6 +35,7 @@ export const withModelBudgetProtection = (
|
|
|
35
35
|
observe: (callId, evidence) =>
|
|
36
36
|
accounting.observe?.(callId, evidence) ?? Promise.resolve(),
|
|
37
37
|
settle: (callId, usage) => accounting.settle(callId, usage),
|
|
38
|
+
release: (callId) => accounting.release(callId),
|
|
38
39
|
reserve: (call) => {
|
|
39
40
|
let usd = copy.usd + verifier.usd;
|
|
40
41
|
let tokens = copy.tokens + verifier.tokens;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProbeAdapterId } from '../probes/adapter';
|
|
2
2
|
import type { TokenUsage } from './pricing';
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
@@ -29,9 +29,13 @@ import type { TokenUsage } from './pricing';
|
|
|
29
29
|
// The probe and search figures are not calibrated yet: they are rough
|
|
30
30
|
// per-request assumptions (a probe's model tokens and its provider's search
|
|
31
31
|
// fee), to be replaced by the costs the gateway reports.
|
|
32
|
+
//
|
|
33
|
+
// Version 2 (probe adapters spec §4.8) keys the probe figures by adapter
|
|
34
|
+
// rather than by surface, with version 1's numbers for every default
|
|
35
|
+
// adapter: a surface costs what the adapter it is bound to costs.
|
|
32
36
|
// ============================================================================
|
|
33
37
|
|
|
34
|
-
export const costCoefficientsVersion =
|
|
38
|
+
export const costCoefficientsVersion = 2;
|
|
35
39
|
|
|
36
40
|
export type TokenRange = {
|
|
37
41
|
input: number;
|
|
@@ -85,17 +89,17 @@ export const hostTokensPerAnswer = {
|
|
|
85
89
|
/** Grounding search per captured answer under full grounding. */
|
|
86
90
|
export const searchUsdPerAnswer = { low: 0.001, high: 0.01 } as const;
|
|
87
91
|
|
|
88
|
-
/** One probe unit, by
|
|
89
|
-
*
|
|
90
|
-
export const probeUsd: Record<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
/** One probe unit, by adapter, in USD. The coding-agent CLIs run on the
|
|
93
|
+
* operator's own plan and bill nothing to the run's cap. */
|
|
94
|
+
export const probeUsd: Readonly<Record<ProbeAdapterId, Range<number>>> = {
|
|
95
|
+
[ProbeAdapterId.GATEWAY_OPENAI]: { low: 0.01, high: 0.05 },
|
|
96
|
+
[ProbeAdapterId.GATEWAY_GOOGLE]: { low: 0.02, high: 0.06 },
|
|
97
|
+
[ProbeAdapterId.GATEWAY_ANTHROPIC]: { low: 0.02, high: 0.08 },
|
|
98
|
+
[ProbeAdapterId.GATEWAY_PERPLEXITY]: { low: 0.01, high: 0.03 },
|
|
99
|
+
[ProbeAdapterId.DATAFORSEO_AI_OVERVIEW]: { low: 0.002, high: 0.006 },
|
|
100
|
+
[ProbeAdapterId.CLI_CLAUDE_CODE]: { low: 0, high: 0 },
|
|
101
|
+
[ProbeAdapterId.CLI_CODEX]: { low: 0, high: 0 },
|
|
102
|
+
[ProbeAdapterId.CLI_CURSOR]: { low: 0, high: 0 },
|
|
99
103
|
};
|
|
100
104
|
|
|
101
105
|
/** The calibrated workload a Codex session is: a batch of answer files
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isObject } from '../lib/type-guards';
|
|
2
|
+
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// The cost the Vercel AI Gateway reports for a call, read one way for every
|
|
5
|
+
// caller: host model calls (structured.ts) and chat probes alike. A value the
|
|
6
|
+
// gateway did not report, or reported in a shape that is not a cost, is
|
|
7
|
+
// unknown (undefined), never zero.
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/** reportedNumber reads a non-negative number given as a number or a
|
|
11
|
+
* numeric string. */
|
|
12
|
+
const reportedNumber = (value: unknown): number | undefined => {
|
|
13
|
+
const number =
|
|
14
|
+
typeof value === 'string' && value.trim() ? Number(value) : value;
|
|
15
|
+
|
|
16
|
+
return typeof number === 'number' && Number.isFinite(number) && number >= 0
|
|
17
|
+
? number
|
|
18
|
+
: undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** gatewayCostUsd is the cost in a response's provider metadata, when the
|
|
22
|
+
* gateway reported one. */
|
|
23
|
+
export const gatewayCostUsd = (
|
|
24
|
+
providerMetadata: unknown,
|
|
25
|
+
): number | undefined => {
|
|
26
|
+
const cost =
|
|
27
|
+
isObject(providerMetadata) && isObject(providerMetadata.gateway)
|
|
28
|
+
? providerMetadata.gateway.cost
|
|
29
|
+
: undefined;
|
|
30
|
+
|
|
31
|
+
return reportedNumber(cost);
|
|
32
|
+
};
|