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/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,
|
|
@@ -53,8 +53,8 @@ export const supportedModels: readonly SupportedModel[] = [
|
|
|
53
53
|
{
|
|
54
54
|
id: 'anthropic/claude-sonnet-5.5',
|
|
55
55
|
label: 'Claude Sonnet 5.5',
|
|
56
|
-
pricingUsdPerMillion: { input: 2, output: 10, cachedInput: 0.
|
|
57
|
-
pricingCheckedAt: '2026-11-
|
|
56
|
+
pricingUsdPerMillion: { input: 2, output: 10, cachedInput: 0.1 },
|
|
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
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { probeUsd } from '../../models/cost-coefficients';
|
|
4
|
+
import { ProbeAdapterId, type ProbeAdapterProfile } from '../adapter';
|
|
5
|
+
import { parseClaudeCodeStream } from '../agent-cli-parsers';
|
|
6
|
+
import { childEnv } from '../child-process';
|
|
7
|
+
import {
|
|
8
|
+
attachCliOutput,
|
|
9
|
+
authSettingNames,
|
|
10
|
+
execCli,
|
|
11
|
+
withScratchDir,
|
|
12
|
+
type AgentProbeFn,
|
|
13
|
+
} from './cli-process';
|
|
14
|
+
|
|
15
|
+
export const claudeCodeProfile: ProbeAdapterProfile = {
|
|
16
|
+
id: ProbeAdapterId.CLI_CLAUDE_CODE,
|
|
17
|
+
observes: { retrieval: 'full', servedModel: 'raw' },
|
|
18
|
+
settings: [
|
|
19
|
+
{ name: 'CLAUDE_CODE_OAUTH_TOKEN', secret: true, group: 'auth' },
|
|
20
|
+
{
|
|
21
|
+
name: 'ANTHROPIC_API_KEY',
|
|
22
|
+
secret: true,
|
|
23
|
+
group: 'auth',
|
|
24
|
+
billsAccount: 'Anthropic',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
pool: 'claude_code',
|
|
28
|
+
retry: 'agent',
|
|
29
|
+
estimateUsd: probeUsd[ProbeAdapterId.CLI_CLAUDE_CODE],
|
|
30
|
+
billing: 'subscription',
|
|
31
|
+
resolvesRedirects: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Claude Code's auth variables and its config directory, nothing else from
|
|
35
|
+
// the parent (§4.5).
|
|
36
|
+
const claudeEnvKeys = [
|
|
37
|
+
...authSettingNames(claudeCodeProfile),
|
|
38
|
+
'CLAUDE_CONFIG_DIR',
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Claude Code
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// `claude -p --output-format stream-json --verbose` streams NDJSON: every
|
|
45
|
+
// assistant turn with its tool_use blocks, the tool results, and a final
|
|
46
|
+
// `result` event with the answer and any permission denials. `--verbose` is
|
|
47
|
+
// mandatory (the CLI refuses stream-json in print mode without it). The old
|
|
48
|
+
// `--output-format json` path read `usage.server_tool_use.web_search_requests`,
|
|
49
|
+
// a counter that stays 0 for the CLI's own WebSearch/WebFetch tools — every
|
|
50
|
+
// committed Claude Code row said "from memory" (correctness spec §1.1).
|
|
51
|
+
// Isolated `--settings` file: web tools pre-allowed so the headless run never
|
|
52
|
+
// stalls on a permission prompt, everything else denied.
|
|
53
|
+
//
|
|
54
|
+
// Environment isolation (added 2026-08-22 after a real contamination):
|
|
55
|
+
// `--setting-sources project` drops the operator's user-scope config — the
|
|
56
|
+
// scratch dir has no project settings, so user plugins, skills, and CLAUDE.md
|
|
57
|
+
// never load. Without it, an installed vendor plugin leaks into the probe's
|
|
58
|
+
// system prompt and biases answers toward that vendor (one baseline captured
|
|
59
|
+
// "I notice you have <vendor> tooling set up in this environment").
|
|
60
|
+
// Verified 2026-09-03 on 2.1.251: the stream's init event reports
|
|
61
|
+
// `mcp_servers: []` and `plugins: []`. NOT `--bare` — it forces API-key-only
|
|
62
|
+
// auth and would break the accepted subscription-billing default. Claude
|
|
63
|
+
// Code's own built-in skills remain, which is the honest surface: every real
|
|
64
|
+
// user has those.
|
|
65
|
+
|
|
66
|
+
export const runClaudeCodeProbe: AgentProbeFn = async (
|
|
67
|
+
promptText,
|
|
68
|
+
runtime,
|
|
69
|
+
signal,
|
|
70
|
+
) => {
|
|
71
|
+
return withScratchDir(runtime, 'claude_code', async (dir) => {
|
|
72
|
+
const settingsPath = path.join(dir, 'probe-settings.json');
|
|
73
|
+
await writeFile(
|
|
74
|
+
settingsPath,
|
|
75
|
+
JSON.stringify({
|
|
76
|
+
permissions: {
|
|
77
|
+
// Bare tool names allow every use of the tool — the documented rule
|
|
78
|
+
// form ('WebFetch(*)' is not valid rule syntax and would leave
|
|
79
|
+
// fetches auto-denied in headless mode; the parser now turns that
|
|
80
|
+
// denial into a loud rejected-tool failure).
|
|
81
|
+
allow: ['WebSearch', 'WebFetch'],
|
|
82
|
+
deny: ['Bash', 'Read', 'Edit', 'Write'],
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
'utf8',
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const output = await execCli('claude', {
|
|
89
|
+
cliArgs: [
|
|
90
|
+
'-p',
|
|
91
|
+
promptText,
|
|
92
|
+
'--output-format',
|
|
93
|
+
'stream-json',
|
|
94
|
+
'--verbose',
|
|
95
|
+
'--settings',
|
|
96
|
+
settingsPath,
|
|
97
|
+
'--strict-mcp-config',
|
|
98
|
+
'--setting-sources',
|
|
99
|
+
'project',
|
|
100
|
+
],
|
|
101
|
+
cwd: dir,
|
|
102
|
+
runtime,
|
|
103
|
+
env: childEnv(
|
|
104
|
+
runtime.env,
|
|
105
|
+
claudeEnvKeys,
|
|
106
|
+
runtime.claudeConfigDir
|
|
107
|
+
? { CLAUDE_CONFIG_DIR: runtime.claudeConfigDir }
|
|
108
|
+
: {},
|
|
109
|
+
),
|
|
110
|
+
signal,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
return parseClaudeCodeStream(output.stdout);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw attachCliOutput(error, output);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { probeUsd } from '../../models/cost-coefficients';
|
|
4
|
+
import { ProbeAdapterId, type ProbeAdapterProfile } from '../adapter';
|
|
5
|
+
import { AgentStreamError, parseCodexEvents } from '../agent-cli-parsers';
|
|
6
|
+
import { childEnv } from '../child-process';
|
|
7
|
+
import {
|
|
8
|
+
attachCliOutput,
|
|
9
|
+
authSettingNames,
|
|
10
|
+
execCli,
|
|
11
|
+
withScratchDir,
|
|
12
|
+
type AgentProbeFn,
|
|
13
|
+
} from './cli-process';
|
|
14
|
+
|
|
15
|
+
export const codexProfile: ProbeAdapterProfile = {
|
|
16
|
+
id: ProbeAdapterId.CLI_CODEX,
|
|
17
|
+
observes: { retrieval: 'queries_only', servedModel: 'raw' },
|
|
18
|
+
settings: [
|
|
19
|
+
{
|
|
20
|
+
name: 'OPENAI_API_KEY',
|
|
21
|
+
secret: true,
|
|
22
|
+
group: 'auth',
|
|
23
|
+
billsAccount: 'OpenAI',
|
|
24
|
+
},
|
|
25
|
+
{ name: 'CODEX_HOME', secret: false, group: 'auth' },
|
|
26
|
+
],
|
|
27
|
+
pool: 'codex',
|
|
28
|
+
retry: 'agent',
|
|
29
|
+
estimateUsd: probeUsd[ProbeAdapterId.CLI_CODEX],
|
|
30
|
+
billing: 'subscription',
|
|
31
|
+
resolvesRedirects: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Codex's auth variables, nothing else from the parent (§4.5).
|
|
35
|
+
const codexEnvKeys = authSettingNames(codexProfile);
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Codex
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// `codex exec --json` emits JSONL events; the final agent message carries the
|
|
41
|
+
// answer (also written to --output-last-message as the robust capture path),
|
|
42
|
+
// and `web_search` items reveal whether live retrieval happened. Web search
|
|
43
|
+
// is enabled explicitly; the sandbox stays read-only — the probe asks a
|
|
44
|
+
// question, it must not touch the machine. Isolation flags (verified against
|
|
45
|
+
// codex-cli 0.148.0 and 0.150.1): --cd pins the working root to the scratch
|
|
46
|
+
// dir (without it Codex resets to the last trusted project — repo-context
|
|
47
|
+
// leakage), --ignore-user-config skips the operator's config.toml (auth
|
|
48
|
+
// still works), --ephemeral keeps probe sessions out of session history.
|
|
49
|
+
// `--sandbox read-only` relies on Landlock/seccomp; a container must allow
|
|
50
|
+
// them or Codex fails closed (hardening spec §3.4).
|
|
51
|
+
|
|
52
|
+
// The model a Codex probe measures is pinned per stack (`aeo:codexProbeModel`
|
|
53
|
+
// → AEO_CODEX_PROBE_MODEL): the CLI's own default is chosen server-side per
|
|
54
|
+
// account and changes across releases, which would silently move the
|
|
55
|
+
// measured surface between reports. Unset means the CLI default, recorded as
|
|
56
|
+
// no requested model.
|
|
57
|
+
const codexProbeModel = (env: NodeJS.ProcessEnv): string | null => {
|
|
58
|
+
const model = env.AEO_CODEX_PROBE_MODEL?.trim() ?? '';
|
|
59
|
+
|
|
60
|
+
return model === '' ? null : model;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Read-only unless the runtime opts out: the probe asks a question, it must
|
|
64
|
+
// not touch the machine.
|
|
65
|
+
const codexSandboxOf = (env: NodeJS.ProcessEnv): string => {
|
|
66
|
+
return env.AEO_CODEX_SANDBOX === 'danger-full-access'
|
|
67
|
+
? 'danger-full-access'
|
|
68
|
+
: 'read-only';
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The parameters a Codex probe runs with, as its request records them. */
|
|
72
|
+
export const codexRequestParameters = (env: NodeJS.ProcessEnv) => {
|
|
73
|
+
return {
|
|
74
|
+
cli: 'codex',
|
|
75
|
+
model: codexProbeModel(env),
|
|
76
|
+
sandbox: codexSandboxOf(env),
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const runCodexProbe: AgentProbeFn = async (
|
|
81
|
+
promptText,
|
|
82
|
+
runtime,
|
|
83
|
+
signal,
|
|
84
|
+
) => {
|
|
85
|
+
return withScratchDir(runtime, 'codex', async (dir) => {
|
|
86
|
+
const lastMessagePath = path.join(dir, 'last-message.txt');
|
|
87
|
+
const requestedModel = codexProbeModel(runtime.env);
|
|
88
|
+
const output = await execCli('codex', {
|
|
89
|
+
cliArgs: [
|
|
90
|
+
'exec',
|
|
91
|
+
'--json',
|
|
92
|
+
...(requestedModel ? ['--model', requestedModel] : []),
|
|
93
|
+
'--sandbox',
|
|
94
|
+
codexSandboxOf(runtime.env),
|
|
95
|
+
'--skip-git-repo-check',
|
|
96
|
+
'--ignore-user-config',
|
|
97
|
+
'--ephemeral',
|
|
98
|
+
'--cd',
|
|
99
|
+
dir,
|
|
100
|
+
'--output-last-message',
|
|
101
|
+
lastMessagePath,
|
|
102
|
+
'-c',
|
|
103
|
+
'tools.web_search=true',
|
|
104
|
+
promptText,
|
|
105
|
+
],
|
|
106
|
+
cwd: dir,
|
|
107
|
+
runtime,
|
|
108
|
+
env: childEnv(runtime.env, codexEnvKeys),
|
|
109
|
+
signal,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
const parsed = parseCodexEvents(output.stdout);
|
|
114
|
+
let lastMessage = parsed.lastMessage;
|
|
115
|
+
|
|
116
|
+
// The --output-last-message file is authoritative; the JSONL scan is
|
|
117
|
+
// the fallback for CLI versions without it.
|
|
118
|
+
try {
|
|
119
|
+
const fromFile = (await readFile(lastMessagePath, 'utf8')).trim();
|
|
120
|
+
|
|
121
|
+
if (fromFile) {
|
|
122
|
+
lastMessage = fromFile;
|
|
123
|
+
}
|
|
124
|
+
} catch {
|
|
125
|
+
// File absent — keep the JSONL-derived message.
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!lastMessage) {
|
|
129
|
+
throw new AgentStreamError(
|
|
130
|
+
'cli_error',
|
|
131
|
+
'Codex returned no agent message',
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
text: lastMessage,
|
|
137
|
+
requestedModel,
|
|
138
|
+
usedWebSearch: parsed.usedWebSearch,
|
|
139
|
+
retrieval: parsed.retrieval,
|
|
140
|
+
};
|
|
141
|
+
} catch (error) {
|
|
142
|
+
throw attachCliOutput(error, output);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
};
|