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
|
@@ -1,937 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ProbeTraceError,
|
|
3
|
-
endAttempt,
|
|
4
|
-
startAttempt
|
|
5
|
-
} from "./chunk-GVOF5ZUG.js";
|
|
6
|
-
import {
|
|
7
|
-
AgentStreamError,
|
|
8
|
-
RejectedWebToolError,
|
|
9
|
-
RetrievalConsistencyError,
|
|
10
|
-
parseClaudeCodeStream,
|
|
11
|
-
parseCodexEvents,
|
|
12
|
-
parseCursorStream
|
|
13
|
-
} from "./chunk-6GKKALCI.js";
|
|
14
|
-
import {
|
|
15
|
-
isWorkerInvocationError,
|
|
16
|
-
requireWorkerTransport,
|
|
17
|
-
workerTransport
|
|
18
|
-
} from "./chunk-565CYND6.js";
|
|
19
|
-
import {
|
|
20
|
-
ChildProcessError,
|
|
21
|
-
childEnv,
|
|
22
|
-
runChild
|
|
23
|
-
} from "./chunk-7QYZSP7Q.js";
|
|
24
|
-
import {
|
|
25
|
-
codexArgs,
|
|
26
|
-
resolveCodexBinary
|
|
27
|
-
} from "./chunk-U772TN32.js";
|
|
28
|
-
import {
|
|
29
|
-
ProbeFailure,
|
|
30
|
-
agentProbeRetryPolicy,
|
|
31
|
-
errorMessage,
|
|
32
|
-
isAuthError,
|
|
33
|
-
isCapacityError,
|
|
34
|
-
retryDelayMs
|
|
35
|
-
} from "./chunk-7O3M6I2X.js";
|
|
36
|
-
import {
|
|
37
|
-
createLog
|
|
38
|
-
} from "./chunk-ZSEY7AHQ.js";
|
|
39
|
-
import {
|
|
40
|
-
getEnvironment,
|
|
41
|
-
readEnv
|
|
42
|
-
} from "./chunk-PO2J5OQ3.js";
|
|
43
|
-
import {
|
|
44
|
-
isRecord
|
|
45
|
-
} from "./chunk-7PLK6VGC.js";
|
|
46
|
-
import {
|
|
47
|
-
sleep,
|
|
48
|
-
unlimited
|
|
49
|
-
} from "./chunk-W5XYW6ZM.js";
|
|
50
|
-
import {
|
|
51
|
-
retrievalLogSchema
|
|
52
|
-
} from "./chunk-EDQTINTL.js";
|
|
53
|
-
import {
|
|
54
|
-
agentSurfaces,
|
|
55
|
-
surfaceRunCounts
|
|
56
|
-
} from "./chunk-AASWJR7Q.js";
|
|
57
|
-
|
|
58
|
-
// src/probes/agent-clis.ts
|
|
59
|
-
import { execFile } from "node:child_process";
|
|
60
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
61
|
-
import { homedir, tmpdir } from "node:os";
|
|
62
|
-
import path from "node:path";
|
|
63
|
-
import { promisify } from "node:util";
|
|
64
|
-
import { z } from "zod";
|
|
65
|
-
var execFileAsync = promisify(execFile);
|
|
66
|
-
var log = createLog("AgentCliProbes");
|
|
67
|
-
var retryJitterRatio = 0.2;
|
|
68
|
-
var addJitter = (delayMs) => {
|
|
69
|
-
const factor = 1 - retryJitterRatio + Math.random() * 2 * retryJitterRatio;
|
|
70
|
-
return Math.round(delayMs * factor);
|
|
71
|
-
};
|
|
72
|
-
var agentProbeTimeoutMs = 5 * 60 * 1e3;
|
|
73
|
-
var agentKillGraceMs = 1e4;
|
|
74
|
-
var agentMaxBufferBytes = 64 * 1024 * 1024;
|
|
75
|
-
var defaultAgentRuntime = (env = getEnvironment()) => {
|
|
76
|
-
return { env, claudeConfigDir: null };
|
|
77
|
-
};
|
|
78
|
-
var detectAgentClis = async () => {
|
|
79
|
-
return {
|
|
80
|
-
claudeCode: await cliVersion("claude", ["--version"]),
|
|
81
|
-
codex: await cliVersion("codex", ["--version"]),
|
|
82
|
-
cursor: await cliVersion("cursor-agent", ["--version"])
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
var versionForSurface = (surface, versions) => {
|
|
86
|
-
switch (surface) {
|
|
87
|
-
case "claude_code":
|
|
88
|
-
return versions.claudeCode;
|
|
89
|
-
case "codex":
|
|
90
|
-
return versions.codex;
|
|
91
|
-
case "cursor":
|
|
92
|
-
return versions.cursor;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var assertAgentClis = (surfaces, versions) => {
|
|
96
|
-
const missing = surfaces.filter((s) => !versionForSurface(s, versions));
|
|
97
|
-
if (missing.length === 0) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
throw new Error(
|
|
101
|
-
[
|
|
102
|
-
`Missing agent CLI${missing.length === 1 ? "" : "s"} for surface${missing.length === 1 ? "" : "s"} in scope:`,
|
|
103
|
-
...missing.map(
|
|
104
|
-
(s) => ` - ${s} \u2014 \`${cliNameForSurface(s)}\` not found on PATH`
|
|
105
|
-
),
|
|
106
|
-
"Install and authenticate the CLI, or narrow the run with --surfaces to",
|
|
107
|
-
"leave the surface out (the snapshot then records it as unmeasured)."
|
|
108
|
-
].join("\n")
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
var agentAuthEnv = {
|
|
112
|
-
claude_code: {
|
|
113
|
-
anyOf: ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"],
|
|
114
|
-
purpose: "Claude Code probes (subscription token from `claude setup-token`, or an API key)"
|
|
115
|
-
},
|
|
116
|
-
codex: {
|
|
117
|
-
anyOf: ["OPENAI_API_KEY", "CODEX_HOME"],
|
|
118
|
-
purpose: "Codex probes (an API key, or a CODEX_HOME provisioned with `codex login --with-api-key`)"
|
|
119
|
-
},
|
|
120
|
-
cursor: {
|
|
121
|
-
anyOf: ["CURSOR_API_KEY"],
|
|
122
|
-
purpose: "Cursor probes"
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var assertAgentAuth = (surfaces, env) => {
|
|
126
|
-
const transport = workerTransport();
|
|
127
|
-
if (readEnv("AEO_ISOLATED_ADAPTER") === "1" && !transport) {
|
|
128
|
-
requireWorkerTransport();
|
|
129
|
-
}
|
|
130
|
-
const missing = surfaces.filter(
|
|
131
|
-
(surface) => transport ? !transport.has(surface) : !agentAuthEnv[surface].anyOf.some((name) => env[name])
|
|
132
|
-
);
|
|
133
|
-
if (missing.length === 0) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
throw new Error(
|
|
137
|
-
[
|
|
138
|
-
"Non-interactive run: agent CLI auth must be provided by environment for every agent surface in scope:",
|
|
139
|
-
...missing.map(
|
|
140
|
-
(surface) => ` - ${surface} \u2014 one of ${agentAuthEnv[surface].anyOf.join(", ")} (${agentAuthEnv[surface].purpose})`
|
|
141
|
-
),
|
|
142
|
-
"Set them, or narrow the run with --surfaces."
|
|
143
|
-
].join("\n")
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
var cliNameForSurface = (surface) => {
|
|
147
|
-
switch (surface) {
|
|
148
|
-
case "claude_code":
|
|
149
|
-
return "claude";
|
|
150
|
-
case "codex":
|
|
151
|
-
return "codex";
|
|
152
|
-
case "cursor":
|
|
153
|
-
return "cursor-agent";
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
var agentAnswerSchema = z.object({
|
|
157
|
-
text: z.string(),
|
|
158
|
-
usedWebSearch: z.boolean().nullable(),
|
|
159
|
-
retrieval: retrievalLogSchema,
|
|
160
|
-
requestedModel: z.string().nullable().optional(),
|
|
161
|
-
reportedModel: z.string().optional()
|
|
162
|
-
});
|
|
163
|
-
var workerVersionSchema = z.string().nullish();
|
|
164
|
-
var getVersionSurface = (command) => {
|
|
165
|
-
if (command === "claude") {
|
|
166
|
-
return "claude_code";
|
|
167
|
-
}
|
|
168
|
-
if (command === "codex") {
|
|
169
|
-
return "codex";
|
|
170
|
-
}
|
|
171
|
-
return "cursor";
|
|
172
|
-
};
|
|
173
|
-
var probeForSurface = (surface) => {
|
|
174
|
-
const transport = workerTransport();
|
|
175
|
-
if (transport) {
|
|
176
|
-
return async (prompt, runtime, signal) => {
|
|
177
|
-
const answer = await transport.invoke(
|
|
178
|
-
surface,
|
|
179
|
-
{
|
|
180
|
-
task: "probe",
|
|
181
|
-
prompt,
|
|
182
|
-
timeoutMs: Math.min(
|
|
183
|
-
runtime.timeoutMs ?? agentProbeTimeoutMs,
|
|
184
|
-
3e5
|
|
185
|
-
)
|
|
186
|
-
},
|
|
187
|
-
signal
|
|
188
|
-
);
|
|
189
|
-
return agentAnswerSchema.parse(answer);
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
if (readEnv("AEO_ISOLATED_ADAPTER") === "1") {
|
|
193
|
-
requireWorkerTransport();
|
|
194
|
-
}
|
|
195
|
-
switch (surface) {
|
|
196
|
-
case "claude_code":
|
|
197
|
-
return runClaudeCodeProbe;
|
|
198
|
-
case "codex":
|
|
199
|
-
return runCodexProbe;
|
|
200
|
-
case "cursor":
|
|
201
|
-
return runCursorProbe;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
var localCommand = (command, args) => {
|
|
205
|
-
if (command !== "codex") {
|
|
206
|
-
return { command, args: [...args] };
|
|
207
|
-
}
|
|
208
|
-
const binary = resolveCodexBinary();
|
|
209
|
-
return { command: binary.command, args: codexArgs(binary, args) };
|
|
210
|
-
};
|
|
211
|
-
var cliVersion = async (command, args) => {
|
|
212
|
-
try {
|
|
213
|
-
const transport = workerTransport();
|
|
214
|
-
if (transport) {
|
|
215
|
-
const version = await transport.invoke(getVersionSurface(command), {
|
|
216
|
-
task: "version"
|
|
217
|
-
});
|
|
218
|
-
return workerVersionSchema.parse(version) ?? null;
|
|
219
|
-
}
|
|
220
|
-
if (readEnv("AEO_ISOLATED_ADAPTER") === "1") {
|
|
221
|
-
requireWorkerTransport();
|
|
222
|
-
}
|
|
223
|
-
const local = localCommand(command, args);
|
|
224
|
-
const { stdout } = await execFileAsync(local.command, local.args, {
|
|
225
|
-
timeout: 15e3
|
|
226
|
-
});
|
|
227
|
-
return stdout.trim().split("\n")[0] ?? null;
|
|
228
|
-
} catch {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
var canaryPrompt = "Reply with the single word OK and nothing else. Do not search the web.";
|
|
233
|
-
var runCanaryProbe = async (surface, runtime, { signal, trace } = {}) => {
|
|
234
|
-
const startedAt = Date.now();
|
|
235
|
-
let traced;
|
|
236
|
-
for (let attempt = 1; ; attempt += 1) {
|
|
237
|
-
signal?.throwIfAborted();
|
|
238
|
-
const retryOf = traced?.id;
|
|
239
|
-
traced = await startAttempt(trace, {
|
|
240
|
-
surface,
|
|
241
|
-
promptId: "canary",
|
|
242
|
-
promptText: canaryPrompt,
|
|
243
|
-
runIndex: 0,
|
|
244
|
-
attempt,
|
|
245
|
-
...retryOf === void 0 ? {} : { retryOf },
|
|
246
|
-
requestedModel: null
|
|
247
|
-
});
|
|
248
|
-
try {
|
|
249
|
-
const answer = await probeForSurface(surface)(
|
|
250
|
-
canaryPrompt,
|
|
251
|
-
{
|
|
252
|
-
...runtime,
|
|
253
|
-
timeoutMs: Math.min(runtime.timeoutMs ?? 12e4, 12e4)
|
|
254
|
-
},
|
|
255
|
-
signal
|
|
256
|
-
);
|
|
257
|
-
log.info("Canary probe passed", {
|
|
258
|
-
surface,
|
|
259
|
-
durationMs: Date.now() - startedAt,
|
|
260
|
-
chars: answer.text.length
|
|
261
|
-
});
|
|
262
|
-
const unrecorded = await endAttempt(traced, {
|
|
263
|
-
outcome: "succeeded",
|
|
264
|
-
text: answer.text,
|
|
265
|
-
retrieval: answer.retrieval,
|
|
266
|
-
requestedModel: answer.requestedModel ?? null,
|
|
267
|
-
...answer.reportedModel ? { reportedModel: answer.reportedModel } : {}
|
|
268
|
-
});
|
|
269
|
-
return unrecorded === null ? null : { kind: "persistence", message: unrecorded, surface };
|
|
270
|
-
} catch (error) {
|
|
271
|
-
const failure = classifyAgentError(error);
|
|
272
|
-
const unrecorded = await endAttempt(traced, {
|
|
273
|
-
outcome: signal?.aborted ? "cancelled" : "failed",
|
|
274
|
-
kind: failure.kind,
|
|
275
|
-
error: failure.message
|
|
276
|
-
});
|
|
277
|
-
signal?.throwIfAborted();
|
|
278
|
-
if (unrecorded !== null) {
|
|
279
|
-
return { kind: "persistence", message: unrecorded, surface };
|
|
280
|
-
}
|
|
281
|
-
const delay = retryDelayMs(failure.kind, attempt);
|
|
282
|
-
if (delay !== null) {
|
|
283
|
-
await sleep(delay, signal);
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
log.error("Canary probe failed", error, {
|
|
287
|
-
surface,
|
|
288
|
-
kind: failure.kind,
|
|
289
|
-
detail: failure.message
|
|
290
|
-
});
|
|
291
|
-
return { ...failure, surface };
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
var runCanaryProbes = async (surfaces, runtime, options = {}) => {
|
|
296
|
-
const failures = (await Promise.all(
|
|
297
|
-
surfaces.map((surface) => runCanaryProbe(surface, runtime, options))
|
|
298
|
-
)).filter((failure) => failure !== null);
|
|
299
|
-
const [firstFailure] = failures;
|
|
300
|
-
if (firstFailure) {
|
|
301
|
-
const kind = failures.find(
|
|
302
|
-
(failure) => ["auth", "rejected_web_tool"].includes(failure.kind)
|
|
303
|
-
)?.kind ?? firstFailure.kind;
|
|
304
|
-
throw new ProbeFailure(
|
|
305
|
-
kind,
|
|
306
|
-
[
|
|
307
|
-
"Agent canary probe failed; the CLI is installed but cannot answer (auth, network, or configuration):",
|
|
308
|
-
...failures.map(
|
|
309
|
-
({ surface, kind: kind2, message }) => ` - ${surface}: ${kind2} \u2014 ${message}`
|
|
310
|
-
).sort()
|
|
311
|
-
].join("\n")
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
var runAgentProbesForPrompts = async (args) => {
|
|
316
|
-
const surfaces = args.surfaces ?? agentSurfaces;
|
|
317
|
-
const limiter = args.limiter ?? unlimited();
|
|
318
|
-
const runtime = args.runtime ?? defaultAgentRuntime();
|
|
319
|
-
const specs = [];
|
|
320
|
-
for (const prompt of args.prompts) {
|
|
321
|
-
for (const surface of surfaces) {
|
|
322
|
-
if (!versionForSurface(surface, args.versions)) {
|
|
323
|
-
throw new Error(
|
|
324
|
-
`Agent CLI for ${surface} (${cliNameForSurface(surface)}) is not installed; the pre-flight check should have rejected this run.`
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
const runs = args.runsPerPrompt ?? surfaceRunCounts[surface];
|
|
328
|
-
for (let run = 1; run <= runs; run++) {
|
|
329
|
-
if (args.filter && !args.filter({ promptId: prompt.id, surface, runIndex: run })) {
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
specs.push({ surface, prompt, runIndex: run });
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const outcomes = await Promise.all(
|
|
337
|
-
specs.map(
|
|
338
|
-
(spec) => runAgentUnit(spec, {
|
|
339
|
-
version: versionForSurface(spec.surface, args.versions) ?? "unknown",
|
|
340
|
-
limiter,
|
|
341
|
-
runtime,
|
|
342
|
-
signal: args.signal,
|
|
343
|
-
onResult: args.onResult,
|
|
344
|
-
trace: args.trace,
|
|
345
|
-
logContext: args.logContext
|
|
346
|
-
})
|
|
347
|
-
)
|
|
348
|
-
);
|
|
349
|
-
const rejectedWebToolSurfaces = surfaces.filter((surface) => {
|
|
350
|
-
const onSurface = outcomes.filter((o) => o.unit.surface === surface);
|
|
351
|
-
return onSurface.length > 0 && onSurface.every(
|
|
352
|
-
(o) => o.status === "failed" && o.kind === "rejected_web_tool"
|
|
353
|
-
);
|
|
354
|
-
});
|
|
355
|
-
const captured = outcomes.filter((o) => o.status === "captured").length;
|
|
356
|
-
log.info("Agent probes completed", {
|
|
357
|
-
...args.logContext,
|
|
358
|
-
planned: specs.length,
|
|
359
|
-
captured,
|
|
360
|
-
failed: specs.length - captured,
|
|
361
|
-
...rejectedWebToolSurfaces.length > 0 ? { rejectedWebToolSurfaces } : {}
|
|
362
|
-
});
|
|
363
|
-
return { outcomes, rejectedWebToolSurfaces };
|
|
364
|
-
};
|
|
365
|
-
var runAgentUnit = async (spec, ctx) => {
|
|
366
|
-
const unit = {
|
|
367
|
-
promptId: spec.prompt.id,
|
|
368
|
-
surface: spec.surface,
|
|
369
|
-
runIndex: spec.runIndex
|
|
370
|
-
};
|
|
371
|
-
const context = {
|
|
372
|
-
...ctx.logContext,
|
|
373
|
-
surface: spec.surface,
|
|
374
|
-
promptId: spec.prompt.id,
|
|
375
|
-
run: spec.runIndex
|
|
376
|
-
};
|
|
377
|
-
const probe = probeForSurface(spec.surface);
|
|
378
|
-
let attempt = 0;
|
|
379
|
-
let answer = null;
|
|
380
|
-
let traced;
|
|
381
|
-
for (; ; ) {
|
|
382
|
-
if (ctx.signal?.aborted) {
|
|
383
|
-
return {
|
|
384
|
-
status: "failed",
|
|
385
|
-
unit,
|
|
386
|
-
kind: "timeout",
|
|
387
|
-
attempts: attempt,
|
|
388
|
-
lastError: "run aborted before the unit executed"
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
attempt += 1;
|
|
392
|
-
const probeStartedAt = Date.now();
|
|
393
|
-
const retryOf = traced?.id;
|
|
394
|
-
traced = void 0;
|
|
395
|
-
try {
|
|
396
|
-
answer = await ctx.limiter.run(
|
|
397
|
-
spec.surface,
|
|
398
|
-
async () => {
|
|
399
|
-
traced = await startAttempt(ctx.trace, {
|
|
400
|
-
surface: spec.surface,
|
|
401
|
-
promptId: spec.prompt.id,
|
|
402
|
-
promptText: spec.prompt.promptText,
|
|
403
|
-
runIndex: spec.runIndex,
|
|
404
|
-
attempt,
|
|
405
|
-
...retryOf === void 0 ? {} : { retryOf },
|
|
406
|
-
// Known from the CLI's answer; recorded when the attempt ends.
|
|
407
|
-
requestedModel: null
|
|
408
|
-
});
|
|
409
|
-
return probe(spec.prompt.promptText, ctx.runtime, ctx.signal);
|
|
410
|
-
},
|
|
411
|
-
{ signal: ctx.signal }
|
|
412
|
-
);
|
|
413
|
-
log.info("Agent probe completed", {
|
|
414
|
-
...context,
|
|
415
|
-
attempt,
|
|
416
|
-
usedWebSearch: answer.usedWebSearch,
|
|
417
|
-
retrievalCalls: answer.retrieval.calls.length,
|
|
418
|
-
durationMs: Date.now() - probeStartedAt,
|
|
419
|
-
chars: answer.text.length
|
|
420
|
-
});
|
|
421
|
-
break;
|
|
422
|
-
} catch (error) {
|
|
423
|
-
if (error instanceof ProbeTraceError) {
|
|
424
|
-
return {
|
|
425
|
-
status: "failed",
|
|
426
|
-
unit,
|
|
427
|
-
kind: "persistence",
|
|
428
|
-
attempts: attempt,
|
|
429
|
-
lastError: error.message
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
const failure = classifyAgentError(error);
|
|
433
|
-
const unrecorded2 = await endAttempt(traced, {
|
|
434
|
-
outcome: ctx.signal?.aborted ? "cancelled" : "failed",
|
|
435
|
-
kind: failure.kind,
|
|
436
|
-
error: failure.message
|
|
437
|
-
});
|
|
438
|
-
if (unrecorded2 !== null) {
|
|
439
|
-
return {
|
|
440
|
-
status: "failed",
|
|
441
|
-
unit,
|
|
442
|
-
kind: "persistence",
|
|
443
|
-
attempts: attempt,
|
|
444
|
-
lastError: unrecorded2
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
const ladderDelayMs = retryDelayMs(
|
|
448
|
-
failure.kind,
|
|
449
|
-
attempt,
|
|
450
|
-
agentProbeRetryPolicy
|
|
451
|
-
);
|
|
452
|
-
const delayMs = ladderDelayMs === null ? null : addJitter(ladderDelayMs);
|
|
453
|
-
log.warn(
|
|
454
|
-
delayMs === null ? "Agent probe failed" : "Agent probe failed; retrying",
|
|
455
|
-
{
|
|
456
|
-
...context,
|
|
457
|
-
attempt,
|
|
458
|
-
kind: failure.kind,
|
|
459
|
-
...delayMs === null ? {} : { retryInMs: delayMs },
|
|
460
|
-
durationMs: Date.now() - probeStartedAt,
|
|
461
|
-
error: failure.message
|
|
462
|
-
}
|
|
463
|
-
);
|
|
464
|
-
if (delayMs === null) {
|
|
465
|
-
return {
|
|
466
|
-
status: "failed",
|
|
467
|
-
unit,
|
|
468
|
-
kind: failure.kind,
|
|
469
|
-
attempts: attempt,
|
|
470
|
-
lastError: failure.message
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
if (failure.kind === "capacity") {
|
|
474
|
-
ctx.limiter.pause(spec.surface, delayMs);
|
|
475
|
-
}
|
|
476
|
-
await sleep(delayMs, ctx.signal);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
const text = answer.text.replaceAll("\0", "");
|
|
480
|
-
const unrecorded = await endAttempt(traced, {
|
|
481
|
-
outcome: "succeeded",
|
|
482
|
-
text,
|
|
483
|
-
retrieval: answer.retrieval,
|
|
484
|
-
requestedModel: answer.requestedModel ?? null,
|
|
485
|
-
...answer.reportedModel ? { reportedModel: answer.reportedModel } : {}
|
|
486
|
-
});
|
|
487
|
-
if (unrecorded !== null) {
|
|
488
|
-
return {
|
|
489
|
-
status: "failed",
|
|
490
|
-
unit,
|
|
491
|
-
kind: "persistence",
|
|
492
|
-
attempts: attempt,
|
|
493
|
-
lastError: unrecorded
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
const result = {
|
|
497
|
-
promptId: spec.prompt.id,
|
|
498
|
-
promptText: spec.prompt.promptText,
|
|
499
|
-
promptCategory: spec.prompt.category,
|
|
500
|
-
modelName: spec.surface,
|
|
501
|
-
runIndex: spec.runIndex,
|
|
502
|
-
text,
|
|
503
|
-
usedWebSearch: answer.usedWebSearch,
|
|
504
|
-
agentCliVersion: ctx.version,
|
|
505
|
-
retrieval: answer.retrieval,
|
|
506
|
-
requestedModel: answer.requestedModel ?? null,
|
|
507
|
-
...answer.reportedModel ? { reportedModel: answer.reportedModel } : {}
|
|
508
|
-
};
|
|
509
|
-
try {
|
|
510
|
-
await ctx.onResult?.(result);
|
|
511
|
-
} catch (error) {
|
|
512
|
-
log.error(
|
|
513
|
-
"Agent probe captured but could not be persisted",
|
|
514
|
-
error,
|
|
515
|
-
context
|
|
516
|
-
);
|
|
517
|
-
return {
|
|
518
|
-
status: "failed",
|
|
519
|
-
unit,
|
|
520
|
-
kind: "persistence",
|
|
521
|
-
attempts: attempt,
|
|
522
|
-
lastError: errorMessage(error)
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
return { status: "captured", unit, probe: result, attempts: attempt };
|
|
526
|
-
};
|
|
527
|
-
var cliOutputByError = /* @__PURE__ */ new WeakMap();
|
|
528
|
-
var attachCliOutput = (error, output) => {
|
|
529
|
-
if (typeof error === "object" && error !== null) {
|
|
530
|
-
cliOutputByError.set(error, output);
|
|
531
|
-
}
|
|
532
|
-
return error;
|
|
533
|
-
};
|
|
534
|
-
var workerFailureKinds = /* @__PURE__ */ new Map([
|
|
535
|
-
["capacity", "capacity"],
|
|
536
|
-
["auth", "auth"],
|
|
537
|
-
["timeout", "timeout"],
|
|
538
|
-
["parser", "parser"],
|
|
539
|
-
["rejected_web_tool", "rejected_web_tool"]
|
|
540
|
-
]);
|
|
541
|
-
var classifyAgentError = (error) => {
|
|
542
|
-
if (error instanceof ProbeFailure) {
|
|
543
|
-
return { kind: error.kind, message: error.message };
|
|
544
|
-
}
|
|
545
|
-
if (isWorkerInvocationError(error)) {
|
|
546
|
-
const kind = workerFailureKinds.get(error.kind) ?? "cli_error";
|
|
547
|
-
return { kind, message: error.detail ?? error.message };
|
|
548
|
-
}
|
|
549
|
-
if (error instanceof RejectedWebToolError) {
|
|
550
|
-
return { kind: "rejected_web_tool", message: error.message };
|
|
551
|
-
}
|
|
552
|
-
if (error instanceof RetrievalConsistencyError) {
|
|
553
|
-
return { kind: "parser", message: error.message };
|
|
554
|
-
}
|
|
555
|
-
if (error instanceof ChildProcessError) {
|
|
556
|
-
const { result } = error;
|
|
557
|
-
if (result.timedOut || result.aborted) {
|
|
558
|
-
return { kind: "timeout", message: error.message };
|
|
559
|
-
}
|
|
560
|
-
const signals = cliFailureSignals(result);
|
|
561
|
-
return {
|
|
562
|
-
kind: kindFromSignals(signals.errorTexts, "cli_error"),
|
|
563
|
-
message: signals.detail ? `${error.message} \u2014 ${signals.detail}` : error.message
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
if (error instanceof AgentStreamError) {
|
|
567
|
-
const output = cliOutputByError.get(error);
|
|
568
|
-
const signals = output ? cliFailureSignals({ code: 0, signal: null, ...output }) : { detail: "", errorTexts: [] };
|
|
569
|
-
return {
|
|
570
|
-
kind: error.kind === "cli_error" ? kindFromSignals(signals.errorTexts, "cli_error") : "parser",
|
|
571
|
-
message: signals.detail ? `${error.message} \u2014 ${signals.detail}` : error.message
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
const message = errorMessage(error);
|
|
575
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
576
|
-
return { kind: "timeout", message };
|
|
577
|
-
}
|
|
578
|
-
return { kind: "cli_error", message };
|
|
579
|
-
};
|
|
580
|
-
var kindFromSignals = (errorTexts, fallback) => {
|
|
581
|
-
const joined = errorTexts.join("\n");
|
|
582
|
-
if (isCapacityError(joined)) {
|
|
583
|
-
return "capacity";
|
|
584
|
-
}
|
|
585
|
-
if (isAuthError(joined)) {
|
|
586
|
-
return "auth";
|
|
587
|
-
}
|
|
588
|
-
return fallback;
|
|
589
|
-
};
|
|
590
|
-
var cliFailureDetailChars = 300;
|
|
591
|
-
var describeExit = ({
|
|
592
|
-
code,
|
|
593
|
-
signal
|
|
594
|
-
}) => {
|
|
595
|
-
if (typeof code === "number") {
|
|
596
|
-
return `exit ${code}`;
|
|
597
|
-
}
|
|
598
|
-
if (signal) {
|
|
599
|
-
return `killed by ${signal}`;
|
|
600
|
-
}
|
|
601
|
-
return "";
|
|
602
|
-
};
|
|
603
|
-
var cliFailureSignals = (output) => {
|
|
604
|
-
const exit = describeExit(output);
|
|
605
|
-
const stderrText = output.stderr.trim();
|
|
606
|
-
const errorTexts = [];
|
|
607
|
-
let lastErrorEventText = null;
|
|
608
|
-
if (stderrText) {
|
|
609
|
-
errorTexts.push(stderrText);
|
|
610
|
-
}
|
|
611
|
-
const events = parseEventLines(output.stdout);
|
|
612
|
-
for (const event of events) {
|
|
613
|
-
if (!isErrorEvent(event)) {
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
const text = eventMessage(event);
|
|
617
|
-
if (text) {
|
|
618
|
-
errorTexts.push(text);
|
|
619
|
-
lastErrorEventText = text;
|
|
620
|
-
}
|
|
621
|
-
if (typeof event.error === "string") {
|
|
622
|
-
errorTexts.push(event.error);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
let detail;
|
|
626
|
-
if (lastErrorEventText) {
|
|
627
|
-
detail = `error event: ${lastErrorEventText.slice(0, cliFailureDetailChars)}`;
|
|
628
|
-
} else if (stderrText) {
|
|
629
|
-
detail = `stderr: ${stderrText.slice(0, cliFailureDetailChars)}`;
|
|
630
|
-
} else {
|
|
631
|
-
const last = lastCliMessage(events, output.stdout);
|
|
632
|
-
detail = last ? `last stdout message: ${last}` : "";
|
|
633
|
-
}
|
|
634
|
-
return {
|
|
635
|
-
detail: [exit, detail].filter(Boolean).join(", "),
|
|
636
|
-
errorTexts
|
|
637
|
-
};
|
|
638
|
-
};
|
|
639
|
-
var describeCliFailure = (output) => {
|
|
640
|
-
return cliFailureSignals(output).detail;
|
|
641
|
-
};
|
|
642
|
-
var parseEventLines = (stdout) => {
|
|
643
|
-
const events = [];
|
|
644
|
-
for (const line of stdout.split("\n")) {
|
|
645
|
-
const trimmed = line.trim();
|
|
646
|
-
if (!trimmed.startsWith("{")) {
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
try {
|
|
650
|
-
const event = JSON.parse(trimmed);
|
|
651
|
-
if (isRecord(event)) {
|
|
652
|
-
events.push(event);
|
|
653
|
-
}
|
|
654
|
-
} catch {
|
|
655
|
-
continue;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return events;
|
|
659
|
-
};
|
|
660
|
-
var isErrorEvent = (event) => {
|
|
661
|
-
if (event.type === "error") {
|
|
662
|
-
return true;
|
|
663
|
-
}
|
|
664
|
-
if (typeof event.error === "string" || isRecord(event.error)) {
|
|
665
|
-
return true;
|
|
666
|
-
}
|
|
667
|
-
if (event.is_error === true) {
|
|
668
|
-
return true;
|
|
669
|
-
}
|
|
670
|
-
if (typeof event.subtype === "string" && /error/i.test(event.subtype)) {
|
|
671
|
-
return true;
|
|
672
|
-
}
|
|
673
|
-
const item = isRecord(event.item) ? event.item : null;
|
|
674
|
-
if (item && (item.error !== void 0 || item.status === "failed")) {
|
|
675
|
-
return true;
|
|
676
|
-
}
|
|
677
|
-
return false;
|
|
678
|
-
};
|
|
679
|
-
var lastCliMessage = (events, stdout) => {
|
|
680
|
-
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
681
|
-
const event = events[i];
|
|
682
|
-
if (!event) {
|
|
683
|
-
continue;
|
|
684
|
-
}
|
|
685
|
-
const text = eventMessage(event);
|
|
686
|
-
if (text) {
|
|
687
|
-
return text.slice(0, cliFailureDetailChars);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
return stdout.trim().slice(-cliFailureDetailChars);
|
|
691
|
-
};
|
|
692
|
-
var eventMessage = (event) => {
|
|
693
|
-
const candidates = [event.result];
|
|
694
|
-
const message = isRecord(event.message) ? event.message : null;
|
|
695
|
-
if (Array.isArray(message?.content)) {
|
|
696
|
-
for (const block of message.content) {
|
|
697
|
-
if (isRecord(block) && typeof block.text === "string") {
|
|
698
|
-
candidates.push(block.text);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
if (isRecord(event.item)) {
|
|
703
|
-
candidates.push(event.item.text);
|
|
704
|
-
}
|
|
705
|
-
if (isRecord(event.msg)) {
|
|
706
|
-
candidates.push(event.msg.message);
|
|
707
|
-
}
|
|
708
|
-
candidates.push(event.message);
|
|
709
|
-
if (isRecord(event.error)) {
|
|
710
|
-
candidates.push(event.error.message);
|
|
711
|
-
}
|
|
712
|
-
candidates.push(event.error);
|
|
713
|
-
for (const candidate of candidates) {
|
|
714
|
-
if (typeof candidate === "string" && candidate.trim()) {
|
|
715
|
-
return unwrapApiErrorBody(candidate.trim());
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
return null;
|
|
719
|
-
};
|
|
720
|
-
var unwrapApiErrorBody = (text) => {
|
|
721
|
-
if (!text.startsWith("{")) {
|
|
722
|
-
return text;
|
|
723
|
-
}
|
|
724
|
-
try {
|
|
725
|
-
const body = JSON.parse(text);
|
|
726
|
-
if (isRecord(body) && isRecord(body.error) && typeof body.error.message === "string") {
|
|
727
|
-
return typeof body.status === "number" ? `HTTP ${body.status}: ${body.error.message}` : body.error.message;
|
|
728
|
-
}
|
|
729
|
-
} catch {
|
|
730
|
-
}
|
|
731
|
-
return text;
|
|
732
|
-
};
|
|
733
|
-
var withScratchDir = async (runtime, surface, fn) => {
|
|
734
|
-
const dir = await mkdtemp(path.join(tmpdir(), "aeo-agent-probe-"));
|
|
735
|
-
try {
|
|
736
|
-
return await fn(dir);
|
|
737
|
-
} finally {
|
|
738
|
-
await rm(dir, { recursive: true, force: true });
|
|
739
|
-
if (surface === "claude_code" && !runtime.claudeConfigDir) {
|
|
740
|
-
await rm(claudeTranscriptDir(runtime.env, dir), {
|
|
741
|
-
recursive: true,
|
|
742
|
-
force: true
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
var claudeTranscriptDir = (env, cwd) => {
|
|
748
|
-
const configDir = env.CLAUDE_CONFIG_DIR ?? path.join(env.HOME ?? homedir(), ".claude");
|
|
749
|
-
return path.join(configDir, "projects", cwd.replaceAll("/", "-"));
|
|
750
|
-
};
|
|
751
|
-
var claudeEnvKeys = [
|
|
752
|
-
"ANTHROPIC_API_KEY",
|
|
753
|
-
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
754
|
-
"CLAUDE_CONFIG_DIR"
|
|
755
|
-
];
|
|
756
|
-
var codexEnvKeys = ["OPENAI_API_KEY", "CODEX_HOME"];
|
|
757
|
-
var cursorEnvKeys = ["CURSOR_API_KEY"];
|
|
758
|
-
var execCli = async (command, { cliArgs, cwd, runtime, env, signal }) => {
|
|
759
|
-
const local = localCommand(command, cliArgs);
|
|
760
|
-
const result = await runChild(local.command, local.args, {
|
|
761
|
-
cwd,
|
|
762
|
-
env,
|
|
763
|
-
timeoutMs: runtime.timeoutMs ?? agentProbeTimeoutMs,
|
|
764
|
-
maxBuffer: agentMaxBufferBytes,
|
|
765
|
-
killGraceMs: agentKillGraceMs,
|
|
766
|
-
signal
|
|
767
|
-
});
|
|
768
|
-
return { stdout: result.stdout, stderr: result.stderr };
|
|
769
|
-
};
|
|
770
|
-
var runClaudeCodeProbe = async (promptText, runtime, signal) => {
|
|
771
|
-
return withScratchDir(runtime, "claude_code", async (dir) => {
|
|
772
|
-
const settingsPath = path.join(dir, "probe-settings.json");
|
|
773
|
-
await writeFile(
|
|
774
|
-
settingsPath,
|
|
775
|
-
JSON.stringify({
|
|
776
|
-
permissions: {
|
|
777
|
-
// Bare tool names allow every use of the tool — the documented rule
|
|
778
|
-
// form ('WebFetch(*)' is not valid rule syntax and would leave
|
|
779
|
-
// fetches auto-denied in headless mode; the parser now turns that
|
|
780
|
-
// denial into a loud rejected-tool failure).
|
|
781
|
-
allow: ["WebSearch", "WebFetch"],
|
|
782
|
-
deny: ["Bash", "Read", "Edit", "Write"]
|
|
783
|
-
}
|
|
784
|
-
}),
|
|
785
|
-
"utf8"
|
|
786
|
-
);
|
|
787
|
-
const output = await execCli("claude", {
|
|
788
|
-
cliArgs: [
|
|
789
|
-
"-p",
|
|
790
|
-
promptText,
|
|
791
|
-
"--output-format",
|
|
792
|
-
"stream-json",
|
|
793
|
-
"--verbose",
|
|
794
|
-
"--settings",
|
|
795
|
-
settingsPath,
|
|
796
|
-
"--strict-mcp-config",
|
|
797
|
-
"--setting-sources",
|
|
798
|
-
"project"
|
|
799
|
-
],
|
|
800
|
-
cwd: dir,
|
|
801
|
-
runtime,
|
|
802
|
-
env: childEnv(
|
|
803
|
-
runtime.env,
|
|
804
|
-
claudeEnvKeys,
|
|
805
|
-
runtime.claudeConfigDir ? { CLAUDE_CONFIG_DIR: runtime.claudeConfigDir } : {}
|
|
806
|
-
),
|
|
807
|
-
signal
|
|
808
|
-
});
|
|
809
|
-
try {
|
|
810
|
-
return parseClaudeCodeStream(output.stdout);
|
|
811
|
-
} catch (error) {
|
|
812
|
-
throw attachCliOutput(error, output);
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
};
|
|
816
|
-
var codexProbeModel = (env) => {
|
|
817
|
-
const model = env.AEO_CODEX_PROBE_MODEL?.trim() ?? "";
|
|
818
|
-
return model === "" ? null : model;
|
|
819
|
-
};
|
|
820
|
-
var runCodexProbe = async (promptText, runtime, signal) => {
|
|
821
|
-
return withScratchDir(runtime, "codex", async (dir) => {
|
|
822
|
-
const lastMessagePath = path.join(dir, "last-message.txt");
|
|
823
|
-
const requestedModel = codexProbeModel(runtime.env);
|
|
824
|
-
const output = await execCli("codex", {
|
|
825
|
-
cliArgs: [
|
|
826
|
-
"exec",
|
|
827
|
-
"--json",
|
|
828
|
-
...requestedModel ? ["--model", requestedModel] : [],
|
|
829
|
-
"--sandbox",
|
|
830
|
-
readEnv("AEO_CODEX_SANDBOX") === "danger-full-access" ? "danger-full-access" : "read-only",
|
|
831
|
-
"--skip-git-repo-check",
|
|
832
|
-
"--ignore-user-config",
|
|
833
|
-
"--ephemeral",
|
|
834
|
-
"--cd",
|
|
835
|
-
dir,
|
|
836
|
-
"--output-last-message",
|
|
837
|
-
lastMessagePath,
|
|
838
|
-
"-c",
|
|
839
|
-
"tools.web_search=true",
|
|
840
|
-
promptText
|
|
841
|
-
],
|
|
842
|
-
cwd: dir,
|
|
843
|
-
runtime,
|
|
844
|
-
env: childEnv(runtime.env, codexEnvKeys),
|
|
845
|
-
signal
|
|
846
|
-
});
|
|
847
|
-
try {
|
|
848
|
-
const parsed = parseCodexEvents(output.stdout);
|
|
849
|
-
let lastMessage = parsed.lastMessage;
|
|
850
|
-
try {
|
|
851
|
-
const fromFile = (await readFile(lastMessagePath, "utf8")).trim();
|
|
852
|
-
if (fromFile) {
|
|
853
|
-
lastMessage = fromFile;
|
|
854
|
-
}
|
|
855
|
-
} catch {
|
|
856
|
-
}
|
|
857
|
-
if (!lastMessage) {
|
|
858
|
-
throw new AgentStreamError(
|
|
859
|
-
"cli_error",
|
|
860
|
-
"Codex returned no agent message"
|
|
861
|
-
);
|
|
862
|
-
}
|
|
863
|
-
return {
|
|
864
|
-
text: lastMessage,
|
|
865
|
-
requestedModel,
|
|
866
|
-
usedWebSearch: parsed.usedWebSearch,
|
|
867
|
-
retrieval: parsed.retrieval
|
|
868
|
-
};
|
|
869
|
-
} catch (error) {
|
|
870
|
-
throw attachCliOutput(error, output);
|
|
871
|
-
}
|
|
872
|
-
});
|
|
873
|
-
};
|
|
874
|
-
var cursorProjectConfig = {
|
|
875
|
-
permissions: {
|
|
876
|
-
allow: [],
|
|
877
|
-
deny: ["Shell(*)", "Write(*)", "Edit(*)", "Delete(*)"]
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
var runCursorProbe = async (promptText, runtime, signal) => {
|
|
881
|
-
return withScratchDir(runtime, "cursor", async (dir) => {
|
|
882
|
-
await mkdir(path.join(dir, ".cursor"), { recursive: true });
|
|
883
|
-
await writeFile(
|
|
884
|
-
path.join(dir, ".cursor", "cli.json"),
|
|
885
|
-
JSON.stringify(cursorProjectConfig),
|
|
886
|
-
"utf8"
|
|
887
|
-
);
|
|
888
|
-
const output = await execCli("cursor-agent", {
|
|
889
|
-
cliArgs: [
|
|
890
|
-
"-p",
|
|
891
|
-
promptText,
|
|
892
|
-
"--output-format",
|
|
893
|
-
"stream-json",
|
|
894
|
-
"--trust",
|
|
895
|
-
"--force"
|
|
896
|
-
],
|
|
897
|
-
cwd: dir,
|
|
898
|
-
runtime,
|
|
899
|
-
env: childEnv(runtime.env, cursorEnvKeys),
|
|
900
|
-
signal
|
|
901
|
-
});
|
|
902
|
-
try {
|
|
903
|
-
return parseCursorStream(output.stdout);
|
|
904
|
-
} catch (error) {
|
|
905
|
-
throw attachCliOutput(error, output);
|
|
906
|
-
}
|
|
907
|
-
});
|
|
908
|
-
};
|
|
909
|
-
var runAgentProbeDirect = async (surface, {
|
|
910
|
-
prompt,
|
|
911
|
-
runtime,
|
|
912
|
-
signal
|
|
913
|
-
}) => {
|
|
914
|
-
if (readEnv("AEO_ISOLATED_ADAPTER") === "1") {
|
|
915
|
-
throw new Error("Direct CLI launch prohibited in adapter.");
|
|
916
|
-
}
|
|
917
|
-
return probeForSurface(surface)(prompt, runtime, signal);
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
export {
|
|
921
|
-
defaultAgentRuntime,
|
|
922
|
-
detectAgentClis,
|
|
923
|
-
versionForSurface,
|
|
924
|
-
assertAgentClis,
|
|
925
|
-
agentAuthEnv,
|
|
926
|
-
assertAgentAuth,
|
|
927
|
-
cliNameForSurface,
|
|
928
|
-
canaryPrompt,
|
|
929
|
-
runCanaryProbe,
|
|
930
|
-
runCanaryProbes,
|
|
931
|
-
runAgentProbesForPrompts,
|
|
932
|
-
classifyAgentError,
|
|
933
|
-
cliFailureSignals,
|
|
934
|
-
describeCliFailure,
|
|
935
|
-
claudeTranscriptDir,
|
|
936
|
-
runAgentProbeDirect
|
|
937
|
-
};
|