literally-aeo 0.2.2 → 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 +6031 -5158
- package/dist/lib/agents/author-schema.js +5 -5
- package/dist/lib/agents/author-validation.js +7 -7
- package/dist/lib/agents/copy-validation.js +9 -9
- package/dist/lib/agents/copywriter-input.js +8 -8
- package/dist/lib/agents/facts.js +7 -7
- package/dist/lib/agents/narrative-facts.js +6 -6
- package/dist/lib/agents/verifier.js +13 -12
- 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 +8 -8
- 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 +23 -15
- package/dist/lib/bundle/verify.js +31 -23
- package/dist/lib/capture-manifest.js +6 -6
- package/dist/lib/checks/crawler-access.js +2 -2
- package/dist/lib/checks/renderability.js +2 -2
- package/dist/lib/checks/run-checks.js +12 -12
- package/dist/lib/chunks/{chunk-3CMPR6ZZ.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-VHKHYAC5.js → chunk-3S2FAVRE.js} +2 -2
- 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-S6QOXJAL.js → chunk-4Q2WFZ5J.js} +11 -4
- package/dist/lib/chunks/{chunk-7DNLRXEY.js → chunk-5JU2Y2I6.js} +2 -2
- package/dist/lib/chunks/{chunk-KFAT65P7.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-HCUJ2J7P.js → chunk-7KLTOVIY.js} +9 -9
- package/dist/lib/chunks/{chunk-EOO5RBUW.js → chunk-7ZR3WDF2.js} +38 -5
- package/dist/lib/chunks/chunk-A5PF7UE2.js +86 -0
- package/dist/lib/chunks/{chunk-PKNODC6Y.js → chunk-AB7DUTX5.js} +1 -1
- package/dist/lib/chunks/{chunk-WDT2Y7D7.js → chunk-AQCWKHTE.js} +11 -7
- package/dist/lib/chunks/{chunk-UNCUG2YS.js → chunk-ASHFEFCU.js} +3 -3
- package/dist/lib/chunks/{chunk-BYHXNFWN.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-QD3JXA3Y.js → chunk-CQNIPZH3.js} +18 -18
- 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-K2FZFESR.js → chunk-FONFW67K.js} +4 -4
- package/dist/lib/chunks/{chunk-PIFTG6YW.js → chunk-FPPHYGIO.js} +2 -2
- package/dist/lib/chunks/{chunk-VXYQWE45.js → chunk-FYE4R5TY.js} +2 -2
- package/dist/lib/chunks/{chunk-JYCVBFH5.js → chunk-H2DOBJZC.js} +2 -2
- package/dist/lib/chunks/{chunk-XA27KAUV.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-R5UPOEWE.js → chunk-HYMWNGOK.js} +10 -3
- 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-AT3XMGES.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-YEUCAPKP.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-XSER7WEB.js → chunk-LJCWZ5SZ.js} +14 -14
- package/dist/lib/chunks/{chunk-HGGRPOSA.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-HGGOGCPX.js → chunk-MPQXB7HN.js} +7 -7
- package/dist/lib/chunks/{chunk-YGLWQFKL.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-GLUGYZQO.js → chunk-OTVHGRCO.js} +8 -8
- package/dist/lib/chunks/{chunk-RIJERFGU.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-4GLW3ZRO.js → chunk-QUZYFAGP.js} +4 -4
- package/dist/lib/chunks/{chunk-T6XZQOXS.js → chunk-QVMPTT7R.js} +5 -5
- package/dist/lib/chunks/{chunk-OOLWU667.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-ZOGIJGU3.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-PIF3GL62.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-J7QKT5E7.js → chunk-WUIY7BXR.js} +34 -17
- 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-LTCDLURT.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-7YZPEX3T.js → chunk-ZHGABG7L.js} +2 -2
- package/dist/lib/chunks/chunk-ZZCRYG36.js +31 -0
- package/dist/lib/cli/bundle-commands.js +89 -73
- package/dist/lib/cli/run-commands.js +136 -92
- package/dist/lib/cli/status-command.js +75 -59
- 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 +23 -22
- package/dist/lib/codex-workflow/capture.js +38 -17
- 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 +19 -18
- package/dist/lib/codex-workflow/copy-recovery.js +4 -4
- package/dist/lib/codex-workflow/copy.js +16 -15
- package/dist/lib/codex-workflow/finish.js +28 -24
- package/dist/lib/codex-workflow/host-models.js +2 -2
- package/dist/lib/codex-workflow/loop.js +51 -46
- 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 +30 -28
- package/dist/lib/codex-workflow/workdir.js +18 -11
- package/dist/lib/engine/audit-file.js +7 -7
- package/dist/lib/engine/author.js +38 -36
- package/dist/lib/engine/cost-estimate.js +37 -9
- package/dist/lib/engine/local-run.js +74 -58
- package/dist/lib/engine/preflight.js +37 -9
- package/dist/lib/engine/rejudge.js +80 -64
- package/dist/lib/engine/run-bindings.js +62 -0
- package/dist/lib/engine/run-status.js +75 -59
- package/dist/lib/engine/templates.js +8 -8
- 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 +19 -17
- package/dist/lib/stores/local-versions.js +5 -5
- package/dist/lib/stores/memory.js +19 -14
- package/dist/lib/stores/publication.js +10 -10
- package/dist/lib/stores/unit-record.js +28 -0
- package/dist/lib/viewer/server.js +32 -24
- 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/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/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/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/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 +2 -2
- 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/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
|
+
};
|
package/src/models/structured.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type InternalModelRoleConfig,
|
|
24
24
|
} from './profiles';
|
|
25
25
|
import { servedModelOf } from './served-model';
|
|
26
|
+
import { gatewayCostUsd } from './gateway-cost';
|
|
26
27
|
|
|
27
28
|
export type StructuredCallUsage = {
|
|
28
29
|
callId: string;
|
|
@@ -147,15 +148,6 @@ const reasoningEffortOf = (
|
|
|
147
148
|
return openai?.reasoningEffort ?? gatewayEffort;
|
|
148
149
|
};
|
|
149
150
|
|
|
150
|
-
const reportedNumber = (value: unknown): number | undefined => {
|
|
151
|
-
const number =
|
|
152
|
-
typeof value === 'string' && value.trim() ? Number(value) : value;
|
|
153
|
-
|
|
154
|
-
return typeof number === 'number' && Number.isFinite(number) && number >= 0
|
|
155
|
-
? number
|
|
156
|
-
: undefined;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
151
|
const isGatewayCreditRefusal = (error: unknown): boolean => {
|
|
160
152
|
// Gateway requires a positive balance before routing even BYOK requests:
|
|
161
153
|
// https://vercel.com/docs/ai-gateway/authentication-and-byok/byok
|
|
@@ -320,7 +312,7 @@ const gatewayTransport: StructuredTransport = async (input) => {
|
|
|
320
312
|
outputTokens: reported.outputTokens,
|
|
321
313
|
cachedInputTokens: reported.inputTokenDetails.cacheReadTokens,
|
|
322
314
|
reasoningTokens: reported.outputTokenDetails.reasoningTokens,
|
|
323
|
-
costUsd:
|
|
315
|
+
costUsd: gatewayCostUsd(providerMetadata),
|
|
324
316
|
};
|
|
325
317
|
|
|
326
318
|
try {
|
|
@@ -42,7 +42,7 @@ export const supportedModels: readonly SupportedModel[] = [
|
|
|
42
42
|
id: 'anthropic/claude-opus-5.5',
|
|
43
43
|
label: 'Claude Opus 5.5',
|
|
44
44
|
pricingUsdPerMillion: { input: 4, output: 20, cachedInput: 0.2 },
|
|
45
|
-
pricingCheckedAt: '2026-11-
|
|
45
|
+
pricingCheckedAt: '2026-11-09',
|
|
46
46
|
contextWindow: 1_000_000,
|
|
47
47
|
maxOutputTokens: 128_000,
|
|
48
48
|
thinkingInOutput: true,
|
|
@@ -54,7 +54,7 @@ export const supportedModels: readonly SupportedModel[] = [
|
|
|
54
54
|
id: 'anthropic/claude-sonnet-5.5',
|
|
55
55
|
label: 'Claude Sonnet 5.5',
|
|
56
56
|
pricingUsdPerMillion: { input: 2, output: 10, cachedInput: 0.1 },
|
|
57
|
-
pricingCheckedAt: '2026-11-
|
|
57
|
+
pricingCheckedAt: '2026-11-09',
|
|
58
58
|
contextWindow: 1_000_000,
|
|
59
59
|
maxOutputTokens: 128_000,
|
|
60
60
|
thinkingInOutput: true,
|
package/src/pipeline.ts
CHANGED
|
@@ -12,11 +12,7 @@ import type {
|
|
|
12
12
|
} from './schema';
|
|
13
13
|
import { agentProbedPrompts, isAgentSurface } from './schema';
|
|
14
14
|
import { createLog } from './lib/log';
|
|
15
|
-
import {
|
|
16
|
-
aiSearchProbeModels,
|
|
17
|
-
runProbesForPrompts,
|
|
18
|
-
type ProbeResult,
|
|
19
|
-
} from './probes/probes';
|
|
15
|
+
import { runProbesForPrompts, type ProbeResult } from './probes/probes';
|
|
20
16
|
import {
|
|
21
17
|
runAgentProbesForPrompts,
|
|
22
18
|
type AgentCliVersions,
|
|
@@ -27,6 +23,9 @@ import type { ProbeOutcome } from './probes/outcomes';
|
|
|
27
23
|
import type { ProbeFailureKind } from './probes/failure';
|
|
28
24
|
import type { ProbeLimiter } from './probes/limits';
|
|
29
25
|
import { withSection, type ProbeTrace } from './probes/probe-trace';
|
|
26
|
+
import { requestedModelOf } from './probes/attempt';
|
|
27
|
+
import type { ProbeDependencies, RunBindings } from './probes/bindings';
|
|
28
|
+
import { legacyProbeBindings } from './probes/legacy-bindings';
|
|
30
29
|
import {
|
|
31
30
|
plannedProbeUnitsForSection,
|
|
32
31
|
probeUnitKey,
|
|
@@ -148,6 +147,9 @@ export type SectionRunArgs = {
|
|
|
148
147
|
// The run journal: every probe attempt becomes an operation.
|
|
149
148
|
trace?: ProbeTrace;
|
|
150
149
|
signal?: AbortSignal;
|
|
150
|
+
// What the probe adapters are created with: the gateway, credentials,
|
|
151
|
+
// clients.
|
|
152
|
+
probeDependencies: ProbeDependencies;
|
|
151
153
|
logContext: Record<string, unknown>;
|
|
152
154
|
};
|
|
153
155
|
|
|
@@ -207,20 +209,29 @@ export type SectionCaptureSummary = Omit<SectionCapture, 'probes'> & {
|
|
|
207
209
|
probeCount: number;
|
|
208
210
|
};
|
|
209
211
|
|
|
210
|
-
// The model a capture asked for
|
|
211
|
-
//
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
// The model a capture asked for, by the binding that captured it: the bound
|
|
213
|
+
// model of a model API, else the one an agent's answer names, else none.
|
|
214
|
+
const capturedRequestedModel = (
|
|
215
|
+
probe: CheckpointProbe,
|
|
216
|
+
bindings: RunBindings,
|
|
217
|
+
): string | null => {
|
|
218
|
+
return requestedModelOf(
|
|
219
|
+
bindings[probe.modelName],
|
|
220
|
+
'requestedModel' in probe ? probe.requestedModel : undefined,
|
|
221
|
+
);
|
|
218
222
|
};
|
|
219
223
|
|
|
220
|
-
|
|
224
|
+
// The adapter a capture records (probe adapters spec §4.6): only one that
|
|
225
|
+
// is not the surface's legacy adapter, so a capture taken with the legacy
|
|
226
|
+
// adapter keeps the bytes, profile and collection digest older releases
|
|
227
|
+
// gave it. Absent means the legacy adapter.
|
|
228
|
+
const recordedAdapterOf = (
|
|
221
229
|
surface: AeoSurface,
|
|
222
|
-
|
|
223
|
-
|
|
230
|
+
bindings: RunBindings,
|
|
231
|
+
): { adapter?: string } => {
|
|
232
|
+
const { adapter } = bindings[surface];
|
|
233
|
+
|
|
234
|
+
return adapter === legacyProbeBindings[surface].adapter ? {} : { adapter };
|
|
224
235
|
};
|
|
225
236
|
|
|
226
237
|
const isAgentProbe = (probe: Probe): probe is AgentProbeResult => {
|
|
@@ -330,7 +341,10 @@ export const captureSectionProbes = async (
|
|
|
330
341
|
runId: args.runId,
|
|
331
342
|
capturedAt: new Date().toISOString(),
|
|
332
343
|
captureMetadata: {
|
|
333
|
-
requestedModel:
|
|
344
|
+
requestedModel: capturedRequestedModel(
|
|
345
|
+
probe,
|
|
346
|
+
args.probeDependencies.bindings,
|
|
347
|
+
),
|
|
334
348
|
reportedModel: probe.reportedModel ?? null,
|
|
335
349
|
// Progress comparisons hash these into each answer's collection
|
|
336
350
|
// method, so they stay as earlier releases recorded them. Chat
|
|
@@ -342,6 +356,10 @@ export const captureSectionProbes = async (
|
|
|
342
356
|
language: args.language,
|
|
343
357
|
agentProbes: args.agentProbes,
|
|
344
358
|
},
|
|
359
|
+
...recordedAdapterOf(
|
|
360
|
+
probe.modelName,
|
|
361
|
+
args.probeDependencies.bindings,
|
|
362
|
+
),
|
|
345
363
|
},
|
|
346
364
|
probe,
|
|
347
365
|
});
|
|
@@ -378,6 +396,7 @@ export const captureSectionProbes = async (
|
|
|
378
396
|
trace,
|
|
379
397
|
limiter: args.limiter,
|
|
380
398
|
signal: args.signal,
|
|
399
|
+
dependencies: args.probeDependencies,
|
|
381
400
|
},
|
|
382
401
|
{ logContext: args.logContext },
|
|
383
402
|
)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { LanguageModel } from 'ai';
|
|
2
|
+
import type { Range } from '../models/cost-coefficients';
|
|
3
|
+
import type { RetrievalExposure, RetrievalLog } from '../schema';
|
|
4
|
+
import type { AeoSurface } from '../surfaces';
|
|
5
|
+
import type { AIOverviewReference } from './dataforseo';
|
|
6
|
+
import type { ProbeFailureKind } from './failure';
|
|
7
|
+
import type { ProbeProvider } from './limits';
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// The probe port (specs/aeo-probe-adapters-spec.md §4.2): one vendor's way
|
|
11
|
+
// of asking one buyer question on one surface. An adapter translates the
|
|
12
|
+
// vendor's request and response and classifies its errors; the host's
|
|
13
|
+
// attempt loop (attempt.ts) owns the pools, the journal, retries, answer
|
|
14
|
+
// finalisation and banking. Importing this module loads no SDK.
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
/** Every registered adapter, with its version. A change to an adapter's
|
|
18
|
+
* request or parsing bumps its version. */
|
|
19
|
+
export const ProbeAdapterId = {
|
|
20
|
+
GATEWAY_OPENAI: 'gateway.openai@1',
|
|
21
|
+
GATEWAY_GOOGLE: 'gateway.google@1',
|
|
22
|
+
GATEWAY_ANTHROPIC: 'gateway.anthropic@1',
|
|
23
|
+
GATEWAY_PERPLEXITY: 'gateway.perplexity@1',
|
|
24
|
+
DATAFORSEO_AI_OVERVIEW: 'dataforseo.ai_overview@1',
|
|
25
|
+
CLI_CLAUDE_CODE: 'cli.claude_code@1',
|
|
26
|
+
CLI_CODEX: 'cli.codex@1',
|
|
27
|
+
CLI_CURSOR: 'cli.cursor@1',
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
export type ProbeAdapterId =
|
|
31
|
+
(typeof ProbeAdapterId)[keyof typeof ProbeAdapterId];
|
|
32
|
+
|
|
33
|
+
/** A setting an adapter reads. Settings that share a group are
|
|
34
|
+
* alternatives: any one of them is enough. `billsAccount` names the
|
|
35
|
+
* provider account an auth setting bills per use, outside the run's cap;
|
|
36
|
+
* plan and doctor disclose it. */
|
|
37
|
+
export type ProbeSetting = {
|
|
38
|
+
name: string;
|
|
39
|
+
secret: boolean;
|
|
40
|
+
group?: 'auth';
|
|
41
|
+
billsAccount?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** The retry family whose rules the host applies (attempt.ts). */
|
|
45
|
+
export type ProbeRetryFamily = 'chat' | 'agent';
|
|
46
|
+
|
|
47
|
+
/** `metered`: every attempt is reserved against the run's budget;
|
|
48
|
+
* `subscription`: the operator's own plan pays, and nothing is reserved. */
|
|
49
|
+
export type ProbeBilling = 'metered' | 'subscription';
|
|
50
|
+
|
|
51
|
+
/** How the host reads the model an answer names: through servedModelOf
|
|
52
|
+
* against the requested model, as the CLI reported it, or not at all. */
|
|
53
|
+
export type ServedModelRule = 'compare_to_requested' | 'raw' | 'none';
|
|
54
|
+
|
|
55
|
+
/** What an adapter is, independent of a run: what it observes, what it
|
|
56
|
+
* needs, which pool and retry rules it runs under, and what it costs. */
|
|
57
|
+
export type ProbeAdapterProfile = {
|
|
58
|
+
id: ProbeAdapterId;
|
|
59
|
+
observes: { retrieval: RetrievalExposure; servedModel: ServedModelRule };
|
|
60
|
+
settings: readonly ProbeSetting[];
|
|
61
|
+
pool: Exclude<ProbeProvider, 'analyzer'>;
|
|
62
|
+
retry: ProbeRetryFamily;
|
|
63
|
+
estimateUsd: Range<number>;
|
|
64
|
+
billing: ProbeBilling;
|
|
65
|
+
/** Google's grounding redirects in the answer and its retrieval log are
|
|
66
|
+
* resolved to their targets before the answer is banked. */
|
|
67
|
+
resolvesRedirects: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** The sources an answer cites, rendered after the body (answer-text.ts). */
|
|
71
|
+
export type AnswerSources =
|
|
72
|
+
| { format: 'search'; sources: readonly unknown[] }
|
|
73
|
+
| { format: 'ai_overview'; references: readonly AIOverviewReference[] }
|
|
74
|
+
| { format: 'none' };
|
|
75
|
+
|
|
76
|
+
export type ProbeAnswer = {
|
|
77
|
+
/** The body, without the source block. */
|
|
78
|
+
answerText: string;
|
|
79
|
+
sources: AnswerSources;
|
|
80
|
+
/** null: the log could not be captured. */
|
|
81
|
+
retrieval: RetrievalLog | null;
|
|
82
|
+
/** Google AI Overview's honest absence. */
|
|
83
|
+
noOverview?: true;
|
|
84
|
+
/** The model asked for, when the request names it only at answer time
|
|
85
|
+
* (Codex); null when the CLI's own default answered. */
|
|
86
|
+
requestedModel?: string | null;
|
|
87
|
+
/** The model the provider or CLI named, raw; observes.servedModel says
|
|
88
|
+
* how the host reads it. */
|
|
89
|
+
servedModel?: string;
|
|
90
|
+
reportedCostUsd?: number;
|
|
91
|
+
/** Coding agents only; null stays unknown. */
|
|
92
|
+
usedWebSearch?: boolean | null;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type ProbeContext = { signal?: AbortSignal };
|
|
96
|
+
|
|
97
|
+
/** A request as the adapter dispatches it: the prompt it sends, with any
|
|
98
|
+
* prefix, and the parameters that shape the answer. Recorded when an
|
|
99
|
+
* attempt starts (spec §4.9). */
|
|
100
|
+
export type ProbeRequest = {
|
|
101
|
+
prompt: string;
|
|
102
|
+
parameters: Readonly<Record<string, unknown>>;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** The models a chat adapter asks through, by model ID: the run's Vercel AI
|
|
106
|
+
* Gateway provider, created with the run's own key. */
|
|
107
|
+
export type ChatModelProvider = (modelId: string) => LanguageModel;
|
|
108
|
+
|
|
109
|
+
export type ProbeFailureClass = { kind: ProbeFailureKind; message: string };
|
|
110
|
+
|
|
111
|
+
/** One adapter instance, serving one surface. */
|
|
112
|
+
export type ProbeAdapter = ProbeAdapterProfile & {
|
|
113
|
+
surface: AeoSurface;
|
|
114
|
+
/** The model the binding pins, for an adapter that calls a model API. */
|
|
115
|
+
model?: string;
|
|
116
|
+
/** The request `probe` dispatches for `promptText`, built from the same
|
|
117
|
+
* values the dispatch uses. */
|
|
118
|
+
request: (promptText: string) => ProbeRequest;
|
|
119
|
+
probe: (promptText: string, ctx: ProbeContext) => Promise<ProbeAnswer>;
|
|
120
|
+
/** The message is journaled, so it never carries the prompt. */
|
|
121
|
+
classifyError: (error: unknown) => ProbeFailureClass;
|
|
122
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { retrievalLogSchema } from '../../schema';
|
|
3
|
+
import type { AeoAgentSurface } from '../../surfaces';
|
|
4
|
+
import type {
|
|
5
|
+
ProbeAdapter,
|
|
6
|
+
ProbeAdapterProfile,
|
|
7
|
+
ProbeAnswer,
|
|
8
|
+
} from '../adapter';
|
|
9
|
+
import { claudeCodeProfile, runClaudeCodeProbe } from './cli-claude-code';
|
|
10
|
+
import {
|
|
11
|
+
codexProfile,
|
|
12
|
+
codexRequestParameters,
|
|
13
|
+
runCodexProbe,
|
|
14
|
+
} from './cli-codex';
|
|
15
|
+
import { cursorProfile, runCursorProbe } from './cli-cursor';
|
|
16
|
+
import {
|
|
17
|
+
agentProbeTimeoutMs,
|
|
18
|
+
classifyAgentError,
|
|
19
|
+
type AgentProbeFn,
|
|
20
|
+
type AgentRuntime,
|
|
21
|
+
} from './cli-process';
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// The coding-agent CLI adapters (cli.claude_code, cli.codex, cli.cursor):
|
|
25
|
+
// one CLI run per attempt, on this machine or, in the hosted platform,
|
|
26
|
+
// through the isolated worker transport. The answer is the CLI's own final
|
|
27
|
+
// message; whether a web tool ran and what it retrieved come from the CLI's
|
|
28
|
+
// structured events, never from the answer text.
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
export const cliAdapterProfiles = {
|
|
32
|
+
claude_code: claudeCodeProfile,
|
|
33
|
+
codex: codexProfile,
|
|
34
|
+
cursor: cursorProfile,
|
|
35
|
+
} satisfies Record<AeoAgentSurface, ProbeAdapterProfile>;
|
|
36
|
+
|
|
37
|
+
// What a worker sends back for a probe or a version request.
|
|
38
|
+
const agentAnswerSchema = z.object({
|
|
39
|
+
text: z.string(),
|
|
40
|
+
usedWebSearch: z.boolean().nullable(),
|
|
41
|
+
retrieval: retrievalLogSchema,
|
|
42
|
+
requestedModel: z.string().nullable().optional(),
|
|
43
|
+
reportedModel: z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// What a CLI probe's request records beyond its prompt: the CLI, and for
|
|
47
|
+
// Codex the model and sandbox it is started with.
|
|
48
|
+
const requestParameters: Readonly<
|
|
49
|
+
Record<AeoAgentSurface, (env: NodeJS.ProcessEnv) => Record<string, unknown>>
|
|
50
|
+
> = {
|
|
51
|
+
claude_code: () => ({ cli: 'claude' }),
|
|
52
|
+
codex: codexRequestParameters,
|
|
53
|
+
cursor: () => ({ cli: 'cursor-agent' }),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const localProbes: Readonly<Record<AeoAgentSurface, AgentProbeFn>> = {
|
|
57
|
+
claude_code: runClaudeCodeProbe,
|
|
58
|
+
codex: runCodexProbe,
|
|
59
|
+
cursor: runCursorProbe,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** probeForSurface is one CLI run: through the runtime's worker transport
|
|
63
|
+
* when it has one, else on this machine. */
|
|
64
|
+
export const probeForSurface = (surface: AeoAgentSurface): AgentProbeFn => {
|
|
65
|
+
return async (prompt, runtime, signal) => {
|
|
66
|
+
if (!runtime.transport) {
|
|
67
|
+
return localProbes[surface](prompt, runtime, signal);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const answer = await runtime.transport.invoke(
|
|
71
|
+
surface,
|
|
72
|
+
{
|
|
73
|
+
task: 'probe',
|
|
74
|
+
prompt,
|
|
75
|
+
timeoutMs: Math.min(runtime.timeoutMs ?? agentProbeTimeoutMs, 300_000),
|
|
76
|
+
},
|
|
77
|
+
signal,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return agentAnswerSchema.parse(answer);
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* createCliAdapter is the adapter of `surface`'s CLI, running each attempt
|
|
86
|
+
* with `runtime`: its environment, its config directory, its deadline and,
|
|
87
|
+
* hosted, its worker transport.
|
|
88
|
+
*/
|
|
89
|
+
export const createCliAdapter = (
|
|
90
|
+
surface: AeoAgentSurface,
|
|
91
|
+
{ runtime }: { runtime: AgentRuntime },
|
|
92
|
+
): ProbeAdapter => {
|
|
93
|
+
const run = probeForSurface(surface);
|
|
94
|
+
|
|
95
|
+
const adapter: ProbeAdapter = {
|
|
96
|
+
...cliAdapterProfiles[surface],
|
|
97
|
+
surface,
|
|
98
|
+
request: (promptText) => ({
|
|
99
|
+
prompt: promptText,
|
|
100
|
+
parameters: requestParameters[surface](runtime.env),
|
|
101
|
+
}),
|
|
102
|
+
probe: async (promptText, { signal }) => {
|
|
103
|
+
const answer = await run(promptText, runtime, signal);
|
|
104
|
+
const probeAnswer: ProbeAnswer = {
|
|
105
|
+
answerText: answer.text,
|
|
106
|
+
sources: { format: 'none' },
|
|
107
|
+
retrieval: answer.retrieval,
|
|
108
|
+
usedWebSearch: answer.usedWebSearch,
|
|
109
|
+
...(answer.requestedModel !== undefined && {
|
|
110
|
+
requestedModel: answer.requestedModel,
|
|
111
|
+
}),
|
|
112
|
+
...(answer.reportedModel !== undefined && {
|
|
113
|
+
servedModel: answer.reportedModel,
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return probeAnswer;
|
|
118
|
+
},
|
|
119
|
+
classifyError: classifyAgentError,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return adapter;
|
|
123
|
+
};
|