literally-aeo 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +73 -2
- package/dist/author-tools.js +3031 -0
- package/dist/cli.mjs +25536 -0
- package/dist/lib/access/schema.js +24 -0
- package/dist/lib/agents/author-schema.js +28 -0
- package/dist/lib/agents/author-validation.js +46 -0
- package/dist/lib/agents/copy-schema.js +30 -0
- package/dist/lib/agents/copy-validation.js +62 -0
- package/dist/lib/agents/copywriter-input.js +31 -0
- package/dist/lib/agents/credentials.js +6 -0
- package/dist/lib/agents/facts.js +31 -0
- package/dist/lib/agents/narrative-facts.js +12 -0
- package/dist/lib/agents/verifier.js +62 -0
- package/dist/lib/analysis/answer-text.js +19 -0
- package/dist/lib/analysis/competitor-classifier.js +6 -0
- package/dist/lib/analysis/domain-classifier.js +73 -0
- package/dist/lib/analysis/domain-labels.js +32 -0
- package/dist/lib/analysis/domain-match.js +12 -0
- package/dist/lib/analysis/name-forms.js +12 -0
- package/dist/lib/analysis/outreach.js +17 -0
- package/dist/lib/analysis/progress-schema.js +13 -0
- package/dist/lib/analysis/progress.js +39 -0
- package/dist/lib/analysis/qualified-competitors.js +7 -0
- package/dist/lib/analysis/retrieval.js +16 -0
- package/dist/lib/analysis/scoring.js +12 -0
- package/dist/lib/analysis/search-analyzer.js +17 -0
- package/dist/lib/analysis/sentiment.js +61 -0
- package/dist/lib/analysis/source-classifier.js +22 -0
- package/dist/lib/analysis/source-mix.js +16 -0
- package/dist/lib/analysis/verbatim.js +6 -0
- package/dist/lib/api/errors.js +10 -0
- package/dist/lib/author/examples.js +34 -0
- package/dist/lib/bundle/checks.js +16 -0
- package/dist/lib/bundle/contracts.js +66 -0
- package/dist/lib/bundle/export.js +69 -0
- package/dist/lib/bundle/journal.js +41 -0
- package/dist/lib/bundle/json.js +13 -0
- package/dist/lib/bundle/lineage.js +13 -0
- package/dist/lib/bundle/paths.js +6 -0
- package/dist/lib/bundle/project-journal.js +36 -0
- package/dist/lib/bundle/project.js +55 -0
- package/dist/lib/bundle/read.js +60 -0
- package/dist/lib/bundle/recorder.js +46 -0
- package/dist/lib/bundle/redact.js +35 -0
- package/dist/lib/bundle/trace-coverage.js +33 -0
- package/dist/lib/bundle/verify-integrity.js +41 -0
- package/dist/lib/bundle/verify-measurement.js +49 -0
- package/dist/lib/bundle/verify-report.js +62 -0
- package/dist/lib/bundle/verify.js +71 -0
- package/dist/lib/bundle/writer-lock.js +11 -0
- package/dist/lib/bundle/zip.js +13 -0
- package/dist/lib/capture-manifest.js +42 -0
- package/dist/lib/checks/crawler-access.js +16 -0
- package/dist/lib/checks/renderability.js +8 -0
- package/dist/lib/checks/run-checks.js +38 -0
- package/dist/lib/chunks/chunk-2KJZ326K.js +253 -0
- package/dist/lib/chunks/chunk-2MGARWKY.js +138 -0
- package/dist/lib/chunks/chunk-2NJEWPCV.js +94 -0
- package/dist/lib/chunks/chunk-2PAO43CH.js +43 -0
- package/dist/lib/chunks/chunk-2QLAFBCG.js +8 -0
- package/dist/lib/chunks/chunk-2ROSV4HD.js +64 -0
- package/dist/lib/chunks/chunk-2URYGUMH.js +27 -0
- package/dist/lib/chunks/chunk-3BFCI7LI.js +34 -0
- package/dist/lib/chunks/chunk-3BJWRD4O.js +0 -0
- package/dist/lib/chunks/chunk-3EBWDHPK.js +133 -0
- package/dist/lib/chunks/chunk-3UFZ2XPE.js +73 -0
- package/dist/lib/chunks/chunk-4E4NDGOZ.js +47 -0
- package/dist/lib/chunks/chunk-4QQJXCD2.js +113 -0
- package/dist/lib/chunks/chunk-4US3OBKJ.js +136 -0
- package/dist/lib/chunks/chunk-4ZY6P5SO.js +303 -0
- package/dist/lib/chunks/chunk-55U7PRRM.js +26 -0
- package/dist/lib/chunks/chunk-565CYND6.js +93 -0
- package/dist/lib/chunks/chunk-56VOFZ7T.js +1486 -0
- package/dist/lib/chunks/chunk-5B3RNVZ6.js +193 -0
- package/dist/lib/chunks/chunk-5EX5DKMA.js +812 -0
- package/dist/lib/chunks/chunk-5GZVDGTX.js +316 -0
- package/dist/lib/chunks/chunk-5H3SNUQT.js +101 -0
- package/dist/lib/chunks/chunk-5HT55QYX.js +53 -0
- package/dist/lib/chunks/chunk-5KKLUM7M.js +105 -0
- package/dist/lib/chunks/chunk-5SOTF3XD.js +56 -0
- package/dist/lib/chunks/chunk-5T3V6XJS.js +41 -0
- package/dist/lib/chunks/chunk-5VNYUCLL.js +352 -0
- package/dist/lib/chunks/chunk-5ZITQDVE.js +149 -0
- package/dist/lib/chunks/chunk-6AUEDSTU.js +52 -0
- package/dist/lib/chunks/chunk-6EH4N3EU.js +113 -0
- package/dist/lib/chunks/chunk-6EI4CVRW.js +33 -0
- package/dist/lib/chunks/chunk-6GKKALCI.js +538 -0
- package/dist/lib/chunks/chunk-6GSQKCKF.js +48 -0
- package/dist/lib/chunks/chunk-6KHQ7DXP.js +100 -0
- package/dist/lib/chunks/chunk-6KO7HGCQ.js +229 -0
- package/dist/lib/chunks/chunk-6RAKXYSR.js +226 -0
- package/dist/lib/chunks/chunk-72P6NOKD.js +190 -0
- package/dist/lib/chunks/chunk-74UNVGWB.js +0 -0
- package/dist/lib/chunks/chunk-7GXRDAUY.js +554 -0
- package/dist/lib/chunks/chunk-7MR6IJ7I.js +0 -0
- package/dist/lib/chunks/chunk-7O3M6I2X.js +123 -0
- package/dist/lib/chunks/chunk-7PLK6VGC.js +12 -0
- package/dist/lib/chunks/chunk-7QYZSP7Q.js +190 -0
- package/dist/lib/chunks/chunk-7YYDUHJG.js +113 -0
- package/dist/lib/chunks/chunk-7ZOJE6BH.js +73 -0
- package/dist/lib/chunks/chunk-AKKFERA4.js +99 -0
- package/dist/lib/chunks/chunk-AP5DLF36.js +150 -0
- package/dist/lib/chunks/chunk-AUB5THIS.js +341 -0
- package/dist/lib/chunks/chunk-AWOJWMPN.js +213 -0
- package/dist/lib/chunks/chunk-B5L2KMTU.js +108 -0
- package/dist/lib/chunks/chunk-BEQLSAVX.js +202 -0
- package/dist/lib/chunks/chunk-C6CMSW5J.js +13 -0
- package/dist/lib/chunks/chunk-CFFPOTP4.js +356 -0
- package/dist/lib/chunks/chunk-CJ5YD3CU.js +237 -0
- package/dist/lib/chunks/chunk-CPT2GKKW.js +188 -0
- package/dist/lib/chunks/chunk-CQ62GN7P.js +30 -0
- package/dist/lib/chunks/chunk-CRVCWDH6.js +0 -0
- package/dist/lib/chunks/chunk-CS24IL3K.js +115 -0
- package/dist/lib/chunks/chunk-D2INDP5W.js +240 -0
- package/dist/lib/chunks/chunk-D2LPQO6Y.js +39 -0
- package/dist/lib/chunks/chunk-D5B4ZOW6.js +61 -0
- package/dist/lib/chunks/chunk-D7GEQVLL.js +115 -0
- package/dist/lib/chunks/chunk-DC6PN7QJ.js +193 -0
- package/dist/lib/chunks/chunk-DYJVVQHD.js +60 -0
- package/dist/lib/chunks/chunk-E3CDKC5B.js +45 -0
- package/dist/lib/chunks/chunk-E4HADK7C.js +18 -0
- package/dist/lib/chunks/chunk-E6NQQU6V.js +111 -0
- package/dist/lib/chunks/chunk-EBXOHAMQ.js +131 -0
- package/dist/lib/chunks/chunk-EPQHVILQ.js +348 -0
- package/dist/lib/chunks/chunk-EV4DRS5M.js +61 -0
- package/dist/lib/chunks/chunk-EYKINDNK.js +29 -0
- package/dist/lib/chunks/chunk-EZD2C7QS.js +10 -0
- package/dist/lib/chunks/chunk-FBFZBLTY.js +752 -0
- package/dist/lib/chunks/chunk-FFOVLI3U.js +235 -0
- package/dist/lib/chunks/chunk-FKLNEB2P.js +529 -0
- package/dist/lib/chunks/chunk-FT5NSQYX.js +0 -0
- package/dist/lib/chunks/chunk-FWBVTM7F.js +11 -0
- package/dist/lib/chunks/chunk-GLXY73MK.js +165 -0
- package/dist/lib/chunks/chunk-GMGKKE5N.js +11 -0
- package/dist/lib/chunks/chunk-GVC4LH2N.js +130 -0
- package/dist/lib/chunks/chunk-GVOF5ZUG.js +44 -0
- package/dist/lib/chunks/chunk-H2KDLDK6.js +13 -0
- package/dist/lib/chunks/chunk-H3G3VTT7.js +259 -0
- package/dist/lib/chunks/chunk-H56DDRKE.js +85 -0
- package/dist/lib/chunks/chunk-HOJXKHPX.js +34 -0
- package/dist/lib/chunks/chunk-HSZ3DM74.js +55 -0
- package/dist/lib/chunks/chunk-HXHFMFQU.js +29 -0
- package/dist/lib/chunks/chunk-I7VNIW6Q.js +196 -0
- package/dist/lib/chunks/chunk-IAR6XGEW.js +184 -0
- package/dist/lib/chunks/chunk-IB6RROHE.js +204 -0
- package/dist/lib/chunks/chunk-IBOWGKN7.js +98 -0
- package/dist/lib/chunks/chunk-IEVAFDW7.js +513 -0
- package/dist/lib/chunks/chunk-IPNK7FYT.js +70 -0
- package/dist/lib/chunks/chunk-IRPKBDB7.js +13 -0
- package/dist/lib/chunks/chunk-ISN6MBNB.js +70 -0
- package/dist/lib/chunks/chunk-J46W3EMQ.js +237 -0
- package/dist/lib/chunks/chunk-J6IJGYP5.js +147 -0
- package/dist/lib/chunks/chunk-JQ3P552S.js +0 -0
- package/dist/lib/chunks/chunk-JS3GBU3R.js +46 -0
- package/dist/lib/chunks/chunk-KMRQSIZW.js +90 -0
- package/dist/lib/chunks/chunk-KRFHQQS7.js +323 -0
- package/dist/lib/chunks/chunk-KZR25REO.js +95 -0
- package/dist/lib/chunks/chunk-LIZX4N3H.js +110 -0
- package/dist/lib/chunks/chunk-M2OD74GP.js +93 -0
- package/dist/lib/chunks/chunk-MHAKYFDF.js +741 -0
- package/dist/lib/chunks/chunk-MIF5IYNR.js +139 -0
- package/dist/lib/chunks/chunk-MRRWMAPA.js +0 -0
- package/dist/lib/chunks/chunk-MX6Y4RD2.js +22 -0
- package/dist/lib/chunks/chunk-N2XIGMJ6.js +0 -0
- package/dist/lib/chunks/chunk-N2ZZ6JRF.js +188 -0
- package/dist/lib/chunks/chunk-NANJGMEJ.js +108 -0
- package/dist/lib/chunks/chunk-NCLFZOZU.js +74 -0
- package/dist/lib/chunks/chunk-NH4QGBJV.js +61 -0
- package/dist/lib/chunks/chunk-NL2LDKXX.js +125 -0
- package/dist/lib/chunks/chunk-NZFMOQHU.js +32 -0
- package/dist/lib/chunks/chunk-O2DKE2RO.js +77 -0
- package/dist/lib/chunks/chunk-O7M2OY3H.js +35 -0
- package/dist/lib/chunks/chunk-OBXAHX3L.js +46 -0
- package/dist/lib/chunks/chunk-OL746E4T.js +350 -0
- package/dist/lib/chunks/chunk-OORO55OM.js +922 -0
- package/dist/lib/chunks/chunk-OVUCZLH2.js +114 -0
- package/dist/lib/chunks/chunk-OX656HYK.js +46 -0
- package/dist/lib/chunks/chunk-OYKV5NDM.js +28 -0
- package/dist/lib/chunks/chunk-P4K6BP3L.js +104 -0
- package/dist/lib/chunks/chunk-PCYNBDZ7.js +386 -0
- package/dist/lib/chunks/chunk-PDS5KWO3.js +256 -0
- package/dist/lib/chunks/chunk-PKB6JRJM.js +53 -0
- package/dist/lib/chunks/chunk-PO2J5OQ3.js +46 -0
- package/dist/lib/chunks/chunk-PYLJISDZ.js +206 -0
- package/dist/lib/chunks/chunk-Q2PWES4B.js +822 -0
- package/dist/lib/chunks/chunk-QBD24WTZ.js +37 -0
- package/dist/lib/chunks/chunk-QFVRCSJ2.js +54 -0
- package/dist/lib/chunks/chunk-QTXOW5XC.js +14 -0
- package/dist/lib/chunks/chunk-RBOO4NDG.js +33 -0
- package/dist/lib/chunks/chunk-RMFT4KKK.js +281 -0
- package/dist/lib/chunks/chunk-S2AM76LT.js +90 -0
- package/dist/lib/chunks/chunk-S2SFHTJD.js +152 -0
- package/dist/lib/chunks/chunk-S42BCLHP.js +0 -0
- package/dist/lib/chunks/chunk-S7KJZIUR.js +241 -0
- package/dist/lib/chunks/chunk-SBAZBOPI.js +33 -0
- package/dist/lib/chunks/chunk-SBQ4TWGJ.js +33 -0
- package/dist/lib/chunks/chunk-SDWYZM64.js +371 -0
- package/dist/lib/chunks/chunk-SREGO3PU.js +25 -0
- package/dist/lib/chunks/chunk-SWJ7KQSL.js +318 -0
- package/dist/lib/chunks/chunk-SZ2UBZKG.js +13 -0
- package/dist/lib/chunks/chunk-TCOH3FGE.js +66 -0
- package/dist/lib/chunks/chunk-TGTM5ZFR.js +82 -0
- package/dist/lib/chunks/chunk-TNL2GWYR.js +345 -0
- package/dist/lib/chunks/chunk-UGCT46PC.js +20 -0
- package/dist/lib/chunks/chunk-ULRXHSJL.js +85 -0
- package/dist/lib/chunks/chunk-URUODEVG.js +0 -0
- package/dist/lib/chunks/chunk-V5B6UZ3E.js +47 -0
- package/dist/lib/chunks/chunk-VHDVKEWO.js +102 -0
- package/dist/lib/chunks/chunk-W46Y7KBR.js +29 -0
- package/dist/lib/chunks/chunk-W5XYW6ZM.js +133 -0
- package/dist/lib/chunks/chunk-WDSCJEDG.js +371 -0
- package/dist/lib/chunks/chunk-WE2WPNG2.js +104 -0
- package/dist/lib/chunks/chunk-WJUHRJVW.js +55 -0
- package/dist/lib/chunks/chunk-WKH6BJAZ.js +167 -0
- package/dist/lib/chunks/chunk-WTQWU522.js +343 -0
- package/dist/lib/chunks/chunk-WUELMJ22.js +345 -0
- package/dist/lib/chunks/chunk-X2Y2ZNG3.js +776 -0
- package/dist/lib/chunks/chunk-X6E44EGV.js +261 -0
- package/dist/lib/chunks/chunk-XHWRSGX3.js +95 -0
- package/dist/lib/chunks/chunk-XI5H46DF.js +47 -0
- package/dist/lib/chunks/chunk-XJVXASDD.js +281 -0
- package/dist/lib/chunks/chunk-XU6WQ5UL.js +257 -0
- package/dist/lib/chunks/chunk-Y4OGZ3Q5.js +365 -0
- package/dist/lib/chunks/chunk-Y6D6IVOM.js +299 -0
- package/dist/lib/chunks/chunk-YHS5IEVZ.js +252 -0
- package/dist/lib/chunks/chunk-YIEAIIND.js +6 -0
- package/dist/lib/chunks/chunk-YOZNLFSB.js +297 -0
- package/dist/lib/chunks/chunk-YR67JG2V.js +65 -0
- package/dist/lib/chunks/chunk-YWJPJI3W.js +51 -0
- package/dist/lib/chunks/chunk-Z4LMDKBU.js +369 -0
- package/dist/lib/chunks/chunk-Z7V63UZA.js +108 -0
- package/dist/lib/chunks/chunk-ZCOI3HE2.js +45 -0
- package/dist/lib/chunks/chunk-ZLOOC46D.js +142 -0
- package/dist/lib/chunks/chunk-ZSEY7AHQ.js +123 -0
- package/dist/lib/chunks/chunk-ZVAKKRRD.js +11 -0
- package/dist/lib/chunks/chunk-ZXQPD4OC.js +202 -0
- package/dist/lib/chunks/chunk-ZYSPTOKK.js +302 -0
- package/dist/lib/cli/bundle-commands.js +371 -0
- package/dist/lib/cli/io.js +12 -0
- package/dist/lib/cli/run-commands.js +614 -0
- package/dist/lib/codex-workflow/aggregate.js +56 -0
- package/dist/lib/codex-workflow/author-search.js +48 -0
- package/dist/lib/codex-workflow/author-tools.js +63 -0
- package/dist/lib/codex-workflow/author.js +99 -0
- package/dist/lib/codex-workflow/batch-input.js +7 -0
- package/dist/lib/codex-workflow/batch-layout.js +8 -0
- package/dist/lib/codex-workflow/capture.js +62 -0
- package/dist/lib/codex-workflow/checkpoint.js +39 -0
- package/dist/lib/codex-workflow/checks.js +44 -0
- package/dist/lib/codex-workflow/codex-home.js +17 -0
- package/dist/lib/codex-workflow/copy-editor.js +66 -0
- package/dist/lib/codex-workflow/copy-recovery.js +32 -0
- package/dist/lib/codex-workflow/copy.js +66 -0
- package/dist/lib/codex-workflow/finish.js +84 -0
- package/dist/lib/codex-workflow/host-models.js +15 -0
- package/dist/lib/codex-workflow/loop.js +140 -0
- package/dist/lib/codex-workflow/pending.js +8 -0
- package/dist/lib/codex-workflow/prompts.js +8 -0
- package/dist/lib/codex-workflow/quality.js +31 -0
- package/dist/lib/codex-workflow/run-inputs.js +38 -0
- package/dist/lib/codex-workflow/run-source.js +55 -0
- package/dist/lib/codex-workflow/schemas.js +58 -0
- package/dist/lib/codex-workflow/session.js +40 -0
- package/dist/lib/codex-workflow/stage.js +98 -0
- package/dist/lib/codex-workflow/workdir.js +42 -0
- package/dist/lib/configs/literally-2026-q3.js +6 -0
- package/dist/lib/container/protocol.js +20 -0
- package/dist/lib/coverage-schema.js +6 -0
- package/dist/lib/engine/audit-file.js +46 -0
- package/dist/lib/engine/author.js +97 -0
- package/dist/lib/engine/budget.js +16 -0
- package/dist/lib/engine/env-file.js +8 -0
- package/dist/lib/engine/local-run.js +149 -0
- package/dist/lib/engine/package-root.js +8 -0
- package/dist/lib/engine/preflight.js +43 -0
- package/dist/lib/engine/rejudge.js +151 -0
- package/dist/lib/engine/resources.js +7 -0
- package/dist/lib/engine/run-configuration.js +15 -0
- package/dist/lib/engine/templates.js +33 -0
- package/dist/lib/grounding/controller.js +31 -0
- package/dist/lib/grounding/extract.js +38 -0
- package/dist/lib/grounding/fetch.js +23 -0
- package/dist/lib/grounding/file-store.js +17 -0
- package/dist/lib/grounding/grounding-runtime.js +62 -0
- package/dist/lib/grounding/model-usage.js +9 -0
- package/dist/lib/grounding/model.js +30 -0
- package/dist/lib/grounding/profile.js +15 -0
- package/dist/lib/grounding/recorded-tools.js +35 -0
- package/dist/lib/grounding/schema.js +42 -0
- package/dist/lib/grounding/session.js +30 -0
- package/dist/lib/grounding/tools.js +25 -0
- package/dist/lib/grounding/validation.js +28 -0
- package/dist/lib/grounding.js +13 -0
- package/dist/lib/harness/checkpoint.js +17 -0
- package/dist/lib/harness/contracts.js +30 -0
- package/dist/lib/harness/criteria.js +14 -0
- package/dist/lib/harness/policy.js +25 -0
- package/dist/lib/harness/report/artifacts.js +36 -0
- package/dist/lib/harness/report/capture-coverage.js +11 -0
- package/dist/lib/harness/store.js +46 -0
- package/dist/lib/lib/analysis-checkpoint.js +10 -0
- package/dist/lib/lib/canonical-json.js +8 -0
- package/dist/lib/lib/checkpoint.js +34 -0
- package/dist/lib/lib/env.js +14 -0
- package/dist/lib/lib/log.js +7 -0
- package/dist/lib/lib/paths.js +8 -0
- package/dist/lib/lib/progress-comparison.js +16 -0
- package/dist/lib/lib/report-presentation.js +13 -0
- package/dist/lib/lib/run-id.js +8 -0
- package/dist/lib/lib/type-guards.js +8 -0
- package/dist/lib/models/accounting.js +22 -0
- package/dist/lib/models/batching.js +18 -0
- package/dist/lib/models/budget-protection.js +6 -0
- package/dist/lib/models/context.js +0 -0
- package/dist/lib/models/coverage-rounds.js +6 -0
- package/dist/lib/models/errors.js +8 -0
- package/dist/lib/models/failure-diagnostics.js +6 -0
- package/dist/lib/models/profiles.js +30 -0
- package/dist/lib/models/served-model.js +6 -0
- package/dist/lib/models/structured-images.js +10 -0
- package/dist/lib/models/structured.js +25 -0
- package/dist/lib/models/wire-schema.js +6 -0
- package/dist/lib/pipeline.js +57 -0
- package/dist/lib/probes/agent-cli-parsers.js +23 -0
- package/dist/lib/probes/agent-clis.js +64 -0
- package/dist/lib/probes/chat-retrieval.js +17 -0
- package/dist/lib/probes/child-process.js +13 -0
- package/dist/lib/probes/dataforseo-locale.js +10 -0
- package/dist/lib/probes/dataforseo.js +10 -0
- package/dist/lib/probes/failure.js +26 -0
- package/dist/lib/probes/grounding-urls.js +19 -0
- package/dist/lib/probes/limits.js +12 -0
- package/dist/lib/probes/outcomes.js +13 -0
- package/dist/lib/probes/probe-trace.js +12 -0
- package/dist/lib/probes/probes.js +40 -0
- package/dist/lib/probes/web-tool-guard.js +18 -0
- package/dist/lib/report/contracts.js +34 -0
- package/dist/lib/report/core/answer-text.js +18 -0
- package/dist/lib/report/core/copy-schema.js +10 -0
- package/dist/lib/report/core/domain-match.js +11 -0
- package/dist/lib/report/core/grounding.js +12 -0
- package/dist/lib/report/core/normalize-domain.js +6 -0
- package/dist/lib/report/core/progress-comparison.js +15 -0
- package/dist/lib/report/core/progress-question-sets.js +16 -0
- package/dist/lib/report/core/progress-schema.js +12 -0
- package/dist/lib/report/core/progress-slot-key.js +6 -0
- package/dist/lib/report/core/qualified-competitors.js +6 -0
- package/dist/lib/report/core/report-presentation.js +12 -0
- package/dist/lib/report/core/retrieval.js +10 -0
- package/dist/lib/report/core/schema.js +70 -0
- package/dist/lib/report/core/source-classifier.js +21 -0
- package/dist/lib/report/core/surfaces.js +18 -0
- package/dist/lib/retrieval.js +11 -0
- package/dist/lib/runner.js +71 -0
- package/dist/lib/schema.js +110 -0
- package/dist/lib/section-result.js +34 -0
- package/dist/lib/stores/artifacts.js +35 -0
- package/dist/lib/stores/content-hash.js +10 -0
- package/dist/lib/stores/file-publication.js +20 -0
- package/dist/lib/stores/files.js +76 -0
- package/dist/lib/stores/fs-errors.js +6 -0
- package/dist/lib/stores/local-versions.js +40 -0
- package/dist/lib/stores/memory.js +312 -0
- package/dist/lib/stores/ports.js +6 -0
- package/dist/lib/stores/publication-history.js +10 -0
- package/dist/lib/stores/publication.js +50 -0
- package/dist/lib/stores/run-lifecycle.js +12 -0
- package/dist/lib/stores/versions.js +6 -0
- package/dist/lib/surfaces.js +19 -0
- package/dist/lib/viewer/page.js +6 -0
- package/dist/lib/viewer/server.js +71 -0
- package/dist/lib/workflow/callbacks.js +15 -0
- package/dist/lib/workflow/lineage.js +8 -0
- package/dist/lib/workflow/schema.js +52 -0
- package/dist/types/access/schema.d.ts +75 -0
- package/dist/types/agents/author-schema.d.ts +76 -0
- package/dist/types/agents/author-validation.d.ts +73 -0
- package/dist/types/agents/copy-schema.d.ts +345 -0
- package/dist/types/agents/copy-validation.d.ts +158 -0
- package/dist/types/agents/copywriter-input.d.ts +46 -0
- package/dist/types/agents/credentials.d.ts +10 -0
- package/dist/types/agents/facts.d.ts +69 -0
- package/dist/types/agents/narrative-facts.d.ts +8 -0
- package/dist/types/agents/verifier.d.ts +167 -0
- package/dist/types/analysis/answer-text.d.ts +1 -0
- package/dist/types/analysis/competitor-classifier.d.ts +1 -0
- package/dist/types/analysis/domain-classifier.d.ts +105 -0
- package/dist/types/analysis/domain-labels.d.ts +30 -0
- package/dist/types/analysis/domain-match.d.ts +1 -0
- package/dist/types/analysis/name-forms.d.ts +25 -0
- package/dist/types/analysis/outreach.d.ts +6 -0
- package/dist/types/analysis/progress-schema.d.ts +1 -0
- package/dist/types/analysis/progress.d.ts +15 -0
- package/dist/types/analysis/qualified-competitors.d.ts +1 -0
- package/dist/types/analysis/retrieval.d.ts +22 -0
- package/dist/types/analysis/scoring.d.ts +55 -0
- package/dist/types/analysis/search-analyzer.d.ts +23 -0
- package/dist/types/analysis/sentiment.d.ts +99 -0
- package/dist/types/analysis/source-classifier.d.ts +1 -0
- package/dist/types/analysis/source-mix.d.ts +6 -0
- package/dist/types/analysis/verbatim.d.ts +1 -0
- package/dist/types/api/errors.d.ts +30 -0
- package/dist/types/author/examples.d.ts +31 -0
- package/dist/types/bundle/checks.d.ts +45 -0
- package/dist/types/bundle/contracts.d.ts +354 -0
- package/dist/types/bundle/export.d.ts +46 -0
- package/dist/types/bundle/journal.d.ts +39 -0
- package/dist/types/bundle/json.d.ts +8 -0
- package/dist/types/bundle/lineage.d.ts +13 -0
- package/dist/types/bundle/paths.d.ts +2 -0
- package/dist/types/bundle/project-journal.d.ts +31 -0
- package/dist/types/bundle/project.d.ts +30 -0
- package/dist/types/bundle/read.d.ts +9 -0
- package/dist/types/bundle/recorder.d.ts +89 -0
- package/dist/types/bundle/redact.d.ts +17 -0
- package/dist/types/bundle/trace-coverage.d.ts +36 -0
- package/dist/types/bundle/verify-integrity.d.ts +11 -0
- package/dist/types/bundle/verify-measurement.d.ts +26 -0
- package/dist/types/bundle/verify-report.d.ts +16 -0
- package/dist/types/bundle/verify.d.ts +31 -0
- package/dist/types/bundle/writer-lock.d.ts +23 -0
- package/dist/types/bundle/zip.d.ts +24 -0
- package/dist/types/capture-manifest.d.ts +122 -0
- package/dist/types/checks/crawler-access.d.ts +25 -0
- package/dist/types/checks/renderability.d.ts +4 -0
- package/dist/types/checks/run-checks.d.ts +8 -0
- package/dist/types/cli/bundle-commands.d.ts +5 -0
- package/dist/types/cli/io.d.ts +10 -0
- package/dist/types/cli/literally-aeo.d.ts +1 -0
- package/dist/types/cli/run-commands.d.ts +14 -0
- package/dist/types/codex-workflow/aggregate.d.ts +76 -0
- package/dist/types/codex-workflow/author-search.d.ts +26 -0
- package/dist/types/codex-workflow/author-tools-server.d.ts +1 -0
- package/dist/types/codex-workflow/author-tools.d.ts +145 -0
- package/dist/types/codex-workflow/author.d.ts +101 -0
- package/dist/types/codex-workflow/batch-input.d.ts +12 -0
- package/dist/types/codex-workflow/batch-layout.d.ts +16 -0
- package/dist/types/codex-workflow/capture.d.ts +37 -0
- package/dist/types/codex-workflow/checkpoint.d.ts +18 -0
- package/dist/types/codex-workflow/checks.d.ts +53 -0
- package/dist/types/codex-workflow/codex-home.d.ts +47 -0
- package/dist/types/codex-workflow/copy-editor.d.ts +164 -0
- package/dist/types/codex-workflow/copy-recovery.d.ts +30 -0
- package/dist/types/codex-workflow/copy.d.ts +62 -0
- package/dist/types/codex-workflow/finish.d.ts +53 -0
- package/dist/types/codex-workflow/host-models.d.ts +5 -0
- package/dist/types/codex-workflow/loop.d.ts +177 -0
- package/dist/types/codex-workflow/pending.d.ts +6 -0
- package/dist/types/codex-workflow/prompts.d.ts +14 -0
- package/dist/types/codex-workflow/quality.d.ts +25 -0
- package/dist/types/codex-workflow/run-inputs.d.ts +951 -0
- package/dist/types/codex-workflow/run-source.d.ts +34 -0
- package/dist/types/codex-workflow/schemas.d.ts +493 -0
- package/dist/types/codex-workflow/session.d.ts +13 -0
- package/dist/types/codex-workflow/stage.d.ts +136 -0
- package/dist/types/codex-workflow/workdir.d.ts +40 -0
- package/dist/types/configs/literally-2026-q3.d.ts +2 -0
- package/dist/types/container/protocol.d.ts +72 -0
- package/dist/types/coverage-schema.d.ts +6 -0
- package/dist/types/engine/audit-file.d.ts +126 -0
- package/dist/types/engine/author.d.ts +52 -0
- package/dist/types/engine/budget.d.ts +68 -0
- package/dist/types/engine/env-file.d.ts +13 -0
- package/dist/types/engine/local-run.d.ts +62 -0
- package/dist/types/engine/package-root.d.ts +8 -0
- package/dist/types/engine/preflight.d.ts +27 -0
- package/dist/types/engine/rejudge.d.ts +14 -0
- package/dist/types/engine/resources.d.ts +8 -0
- package/dist/types/engine/run-configuration.d.ts +36 -0
- package/dist/types/engine/templates.d.ts +38 -0
- package/dist/types/grounding/controller.d.ts +110 -0
- package/dist/types/grounding/extract.d.ts +103 -0
- package/dist/types/grounding/fetch.d.ts +53 -0
- package/dist/types/grounding/file-store.d.ts +2 -0
- package/dist/types/grounding/grounding-runtime.d.ts +43 -0
- package/dist/types/grounding/model-usage.d.ts +13 -0
- package/dist/types/grounding/model.d.ts +51 -0
- package/dist/types/grounding/profile.d.ts +15 -0
- package/dist/types/grounding/recorded-tools.d.ts +12 -0
- package/dist/types/grounding/schema.d.ts +521 -0
- package/dist/types/grounding/session.d.ts +143 -0
- package/dist/types/grounding/tools.d.ts +135 -0
- package/dist/types/grounding/validation.d.ts +35 -0
- package/dist/types/grounding.d.ts +1 -0
- package/dist/types/harness/checkpoint.d.ts +29 -0
- package/dist/types/harness/contracts.d.ts +141 -0
- package/dist/types/harness/criteria.d.ts +34 -0
- package/dist/types/harness/policy.d.ts +9 -0
- package/dist/types/harness/report/artifacts.d.ts +287 -0
- package/dist/types/harness/report/capture-coverage.d.ts +11 -0
- package/dist/types/harness/store.d.ts +116 -0
- package/dist/types/lib/analysis-checkpoint.d.ts +20 -0
- package/dist/types/lib/canonical-json.d.ts +11 -0
- package/dist/types/lib/checkpoint.d.ts +33 -0
- package/dist/types/lib/env.d.ts +31 -0
- package/dist/types/lib/log.d.ts +11 -0
- package/dist/types/lib/paths.d.ts +2 -0
- package/dist/types/lib/progress-comparison.d.ts +1 -0
- package/dist/types/lib/report-presentation.d.ts +1 -0
- package/dist/types/lib/run-id.d.ts +2 -0
- package/dist/types/lib/type-guards.d.ts +9 -0
- package/dist/types/models/accounting.d.ts +147 -0
- package/dist/types/models/batching.d.ts +17 -0
- package/dist/types/models/budget-protection.d.ts +10 -0
- package/dist/types/models/context.d.ts +8 -0
- package/dist/types/models/coverage-rounds.d.ts +47 -0
- package/dist/types/models/errors.d.ts +12 -0
- package/dist/types/models/failure-diagnostics.d.ts +8 -0
- package/dist/types/models/profiles.d.ts +551 -0
- package/dist/types/models/served-model.d.ts +11 -0
- package/dist/types/models/structured-images.d.ts +9 -0
- package/dist/types/models/structured.d.ts +111 -0
- package/dist/types/models/wire-schema.d.ts +27 -0
- package/dist/types/pipeline.d.ts +117 -0
- package/dist/types/probes/agent-cli-parsers.d.ts +46 -0
- package/dist/types/probes/agent-clis.d.ts +132 -0
- package/dist/types/probes/chat-retrieval.d.ts +14 -0
- package/dist/types/probes/child-process.d.ts +28 -0
- package/dist/types/probes/dataforseo-locale.d.ts +8 -0
- package/dist/types/probes/dataforseo.d.ts +15 -0
- package/dist/types/probes/failure.d.ts +30 -0
- package/dist/types/probes/grounding-urls.d.ts +18 -0
- package/dist/types/probes/limits.d.ts +30 -0
- package/dist/types/probes/outcomes.d.ts +20 -0
- package/dist/types/probes/probe-trace.d.ts +51 -0
- package/dist/types/probes/probes.d.ts +47 -0
- package/dist/types/probes/web-tool-guard.d.ts +59 -0
- package/dist/types/report/contracts.d.ts +973 -0
- package/dist/types/report/core/answer-text.d.ts +24 -0
- package/dist/types/report/core/copy-schema.d.ts +47 -0
- package/dist/types/report/core/domain-match.d.ts +9 -0
- package/dist/types/report/core/grounding.d.ts +4 -0
- package/dist/types/report/core/normalize-domain.d.ts +2 -0
- package/dist/types/report/core/progress-comparison.d.ts +52 -0
- package/dist/types/report/core/progress-question-sets.d.ts +16 -0
- package/dist/types/report/core/progress-schema.d.ts +101 -0
- package/dist/types/report/core/progress-slot-key.d.ts +9 -0
- package/dist/types/report/core/qualified-competitors.d.ts +6 -0
- package/dist/types/report/core/report-presentation.d.ts +10 -0
- package/dist/types/report/core/retrieval.d.ts +6 -0
- package/dist/types/report/core/schema.d.ts +745 -0
- package/dist/types/report/core/source-classifier.d.ts +21 -0
- package/dist/types/report/core/surfaces.d.ts +11 -0
- package/dist/types/retrieval.d.ts +1 -0
- package/dist/types/runner.d.ts +96 -0
- package/dist/types/schema.d.ts +858 -0
- package/dist/types/section-result.d.ts +4 -0
- package/dist/types/stores/artifacts.d.ts +2 -0
- package/dist/types/stores/content-hash.d.ts +2 -0
- package/dist/types/stores/file-publication.d.ts +31 -0
- package/dist/types/stores/files.d.ts +87 -0
- package/dist/types/stores/fs-errors.d.ts +5 -0
- package/dist/types/stores/local-versions.d.ts +54 -0
- package/dist/types/stores/memory.d.ts +76 -0
- package/dist/types/stores/ports.d.ts +150 -0
- package/dist/types/stores/publication-history.d.ts +27 -0
- package/dist/types/stores/publication.d.ts +53 -0
- package/dist/types/stores/run-lifecycle.d.ts +7 -0
- package/dist/types/stores/versions.d.ts +71 -0
- package/dist/types/surfaces.d.ts +1 -0
- package/dist/types/viewer/page.d.ts +2 -0
- package/dist/types/viewer/server.d.ts +14 -0
- package/dist/types/workflow/callbacks.d.ts +22 -0
- package/dist/types/workflow/lineage.d.ts +20 -0
- package/dist/types/workflow/schema.d.ts +1572 -0
- package/package.json +95 -3
- package/resources/author/COPY_RULES.md +95 -0
- package/resources/author/RULES.md +104 -0
- package/resources/author/banlist.json +38 -0
- package/resources/editorial/COMPANY.md +11 -0
- package/resources/editorial/positioning.md +8 -0
- package/resources/editorial/services.md +4 -0
- package/src/access/schema.ts +96 -0
- package/src/agents/author-schema.ts +49 -0
- package/src/agents/author-validation.ts +409 -0
- package/src/agents/copy-schema.ts +214 -0
- package/src/agents/copy-validation.ts +1170 -0
- package/src/agents/copywriter-input.ts +90 -0
- package/src/agents/credentials.ts +60 -0
- package/src/agents/facts.ts +343 -0
- package/src/agents/narrative-facts.ts +174 -0
- package/src/agents/verifier.ts +603 -0
- package/src/analysis/answer-text.ts +1 -0
- package/src/analysis/competitor-classifier.ts +15 -0
- package/src/analysis/domain-classifier.ts +804 -0
- package/src/analysis/domain-labels.ts +67 -0
- package/src/analysis/domain-match.ts +1 -0
- package/src/analysis/name-forms.ts +59 -0
- package/src/analysis/outreach.ts +107 -0
- package/src/analysis/progress-schema.ts +1 -0
- package/src/analysis/progress.ts +346 -0
- package/src/analysis/qualified-competitors.ts +1 -0
- package/src/analysis/retrieval.ts +105 -0
- package/src/analysis/scoring.ts +167 -0
- package/src/analysis/search-analyzer.ts +83 -0
- package/src/analysis/sentiment.ts +558 -0
- package/src/analysis/source-classifier.ts +1 -0
- package/src/analysis/source-mix.ts +56 -0
- package/src/analysis/verbatim.ts +107 -0
- package/src/api/errors.ts +50 -0
- package/src/author/COPY_RULES.md +95 -0
- package/src/author/RULES.md +104 -0
- package/src/author/banlist.json +38 -0
- package/src/author/examples.ts +79 -0
- package/src/bundle/checks.ts +146 -0
- package/src/bundle/contracts.ts +289 -0
- package/src/bundle/export.ts +448 -0
- package/src/bundle/journal.ts +270 -0
- package/src/bundle/json.ts +157 -0
- package/src/bundle/lineage.ts +45 -0
- package/src/bundle/paths.ts +36 -0
- package/src/bundle/project-journal.ts +179 -0
- package/src/bundle/project.ts +434 -0
- package/src/bundle/read.ts +154 -0
- package/src/bundle/recorder.ts +497 -0
- package/src/bundle/redact.ts +134 -0
- package/src/bundle/trace-coverage.ts +168 -0
- package/src/bundle/verify-integrity.ts +322 -0
- package/src/bundle/verify-measurement.ts +384 -0
- package/src/bundle/verify-report.ts +260 -0
- package/src/bundle/verify.ts +400 -0
- package/src/bundle/writer-lock.ts +133 -0
- package/src/bundle/zip.ts +281 -0
- package/src/capture-manifest.ts +348 -0
- package/src/checks/crawler-access.ts +373 -0
- package/src/checks/renderability.ts +164 -0
- package/src/checks/run-checks.ts +74 -0
- package/src/cli/bundle-commands.ts +249 -0
- package/src/cli/io.ts +63 -0
- package/src/cli/literally-aeo.ts +121 -0
- package/src/cli/run-commands.ts +535 -0
- package/src/codex-workflow/aggregate.ts +336 -0
- package/src/codex-workflow/author-search.ts +76 -0
- package/src/codex-workflow/author-tools-server.ts +208 -0
- package/src/codex-workflow/author-tools.ts +1202 -0
- package/src/codex-workflow/author.ts +512 -0
- package/src/codex-workflow/batch-input.ts +145 -0
- package/src/codex-workflow/batch-layout.ts +47 -0
- package/src/codex-workflow/capture.ts +255 -0
- package/src/codex-workflow/checkpoint.ts +127 -0
- package/src/codex-workflow/checks.ts +510 -0
- package/src/codex-workflow/codex-home.ts +187 -0
- package/src/codex-workflow/copy-editor.ts +322 -0
- package/src/codex-workflow/copy-recovery.ts +134 -0
- package/src/codex-workflow/copy.ts +195 -0
- package/src/codex-workflow/finish.ts +433 -0
- package/src/codex-workflow/host-models.ts +35 -0
- package/src/codex-workflow/loop.ts +1159 -0
- package/src/codex-workflow/pending.ts +24 -0
- package/src/codex-workflow/prompts.ts +153 -0
- package/src/codex-workflow/quality.ts +97 -0
- package/src/codex-workflow/run-inputs.ts +117 -0
- package/src/codex-workflow/run-source.ts +149 -0
- package/src/codex-workflow/schemas.ts +222 -0
- package/src/codex-workflow/session.ts +70 -0
- package/src/codex-workflow/stage.ts +2344 -0
- package/src/codex-workflow/workdir.ts +242 -0
- package/src/configs/literally-2026-q3.ts +199 -0
- package/src/container/protocol.ts +152 -0
- package/src/coverage-schema.ts +7 -0
- package/src/engine/audit-file.ts +254 -0
- package/src/engine/author.ts +279 -0
- package/src/engine/budget.ts +164 -0
- package/src/engine/editorial/COMPANY.md +11 -0
- package/src/engine/editorial/positioning.md +8 -0
- package/src/engine/editorial/services.md +4 -0
- package/src/engine/env-file.ts +87 -0
- package/src/engine/local-run.ts +323 -0
- package/src/engine/package-root.ts +47 -0
- package/src/engine/preflight.ts +156 -0
- package/src/engine/rejudge.ts +118 -0
- package/src/engine/resources.ts +45 -0
- package/src/engine/run-configuration.ts +70 -0
- package/src/engine/templates.ts +66 -0
- package/src/grounding/controller.ts +1211 -0
- package/src/grounding/extract.ts +830 -0
- package/src/grounding/fetch.ts +448 -0
- package/src/grounding/file-store.ts +131 -0
- package/src/grounding/grounding-runtime.ts +318 -0
- package/src/grounding/model-usage.ts +48 -0
- package/src/grounding/model.ts +508 -0
- package/src/grounding/profile.ts +63 -0
- package/src/grounding/recorded-tools.ts +40 -0
- package/src/grounding/schema.ts +262 -0
- package/src/grounding/session.ts +681 -0
- package/src/grounding/tools.ts +500 -0
- package/src/grounding/validation.ts +435 -0
- package/src/grounding.ts +1 -0
- package/src/harness/checkpoint.ts +53 -0
- package/src/harness/contracts.ts +169 -0
- package/src/harness/criteria.ts +166 -0
- package/src/harness/policy.ts +28 -0
- package/src/harness/report/artifacts.ts +130 -0
- package/src/harness/report/capture-coverage.ts +40 -0
- package/src/harness/store.ts +167 -0
- package/src/lib/analysis-checkpoint.ts +94 -0
- package/src/lib/canonical-json.ts +90 -0
- package/src/lib/checkpoint.ts +140 -0
- package/src/lib/env.ts +80 -0
- package/src/lib/log.ts +192 -0
- package/src/lib/paths.ts +14 -0
- package/src/lib/progress-comparison.ts +1 -0
- package/src/lib/report-presentation.ts +1 -0
- package/src/lib/run-id.ts +39 -0
- package/src/lib/type-guards.ts +14 -0
- package/src/models/accounting.ts +656 -0
- package/src/models/batching.ts +68 -0
- package/src/models/budget-protection.ts +68 -0
- package/src/models/context.ts +9 -0
- package/src/models/coverage-rounds.ts +125 -0
- package/src/models/errors.ts +39 -0
- package/src/models/failure-diagnostics.ts +157 -0
- package/src/models/profiles.ts +511 -0
- package/src/models/served-model.ts +20 -0
- package/src/models/structured-images.ts +95 -0
- package/src/models/structured.ts +634 -0
- package/src/models/wire-schema.ts +453 -0
- package/src/pipeline.ts +496 -0
- package/src/probes/agent-cli-parsers.ts +835 -0
- package/src/probes/agent-clis.ts +1482 -0
- package/src/probes/chat-retrieval.ts +238 -0
- package/src/probes/child-process.ts +280 -0
- package/src/probes/dataforseo-locale.ts +71 -0
- package/src/probes/dataforseo.ts +286 -0
- package/src/probes/failure.ts +182 -0
- package/src/probes/grounding-urls.ts +182 -0
- package/src/probes/limits.ts +181 -0
- package/src/probes/outcomes.ts +40 -0
- package/src/probes/probe-trace.ts +109 -0
- package/src/probes/probes.ts +789 -0
- package/src/probes/web-tool-guard.ts +195 -0
- package/src/report/contracts.ts +161 -0
- package/src/report/core/answer-text.ts +144 -0
- package/src/report/core/copy-schema.ts +75 -0
- package/src/report/core/domain-match.ts +52 -0
- package/src/report/core/grounding.ts +32 -0
- package/src/report/core/normalize-domain.ts +16 -0
- package/src/report/core/progress-comparison.ts +362 -0
- package/src/report/core/progress-question-sets.ts +93 -0
- package/src/report/core/progress-schema.ts +150 -0
- package/src/report/core/progress-slot-key.ts +20 -0
- package/src/report/core/qualified-competitors.ts +15 -0
- package/src/report/core/report-presentation.ts +112 -0
- package/src/report/core/retrieval.ts +49 -0
- package/src/report/core/schema.ts +489 -0
- package/src/report/core/source-classifier.ts +239 -0
- package/src/report/core/surfaces.ts +64 -0
- package/src/retrieval.ts +1 -0
- package/src/runner.ts +461 -0
- package/src/schema.ts +181 -0
- package/src/section-result.ts +315 -0
- package/src/stores/artifacts.ts +74 -0
- package/src/stores/content-hash.ts +8 -0
- package/src/stores/file-publication.ts +194 -0
- package/src/stores/files.ts +1069 -0
- package/src/stores/fs-errors.ts +12 -0
- package/src/stores/local-versions.ts +412 -0
- package/src/stores/memory.ts +432 -0
- package/src/stores/ports.ts +231 -0
- package/src/stores/publication-history.ts +48 -0
- package/src/stores/publication.ts +221 -0
- package/src/stores/run-lifecycle.ts +72 -0
- package/src/stores/versions.ts +113 -0
- package/src/surfaces.ts +1 -0
- package/src/viewer/page.ts +208 -0
- package/src/viewer/server.ts +215 -0
- package/src/workflow/callbacks.ts +201 -0
- package/src/workflow/lineage.ts +36 -0
- package/src/workflow/schema.ts +256 -0
|
@@ -0,0 +1,776 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ResearchLimitError,
|
|
3
|
+
ResearchOwnershipError,
|
|
4
|
+
researchCallCharge
|
|
5
|
+
} from "./chunk-Y4OGZ3Q5.js";
|
|
6
|
+
import {
|
|
7
|
+
proposedAssessmentSchema
|
|
8
|
+
} from "./chunk-WUELMJ22.js";
|
|
9
|
+
import {
|
|
10
|
+
researchActionSchema,
|
|
11
|
+
researchToolResultSchema
|
|
12
|
+
} from "./chunk-EPQHVILQ.js";
|
|
13
|
+
import {
|
|
14
|
+
ModelBudgetError
|
|
15
|
+
} from "./chunk-TNL2GWYR.js";
|
|
16
|
+
import {
|
|
17
|
+
GroundingIntegrityError,
|
|
18
|
+
adjudicationEvidenceDigest,
|
|
19
|
+
assessmentDigest,
|
|
20
|
+
createGroundingBundle,
|
|
21
|
+
groundingDigest,
|
|
22
|
+
validateCandidateOccurrences,
|
|
23
|
+
validateGroundingBundle
|
|
24
|
+
} from "./chunk-ZYSPTOKK.js";
|
|
25
|
+
import {
|
|
26
|
+
SourceRetrievalError
|
|
27
|
+
} from "./chunk-SWJ7KQSL.js";
|
|
28
|
+
import {
|
|
29
|
+
contentHash
|
|
30
|
+
} from "./chunk-H2KDLDK6.js";
|
|
31
|
+
import {
|
|
32
|
+
adjudicationVersion,
|
|
33
|
+
claimCandidateSchema,
|
|
34
|
+
groundingPolicyVersion,
|
|
35
|
+
groundingSchemaVersion
|
|
36
|
+
} from "./chunk-6RAKXYSR.js";
|
|
37
|
+
|
|
38
|
+
// src/grounding/controller.ts
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
var pruneUnknownReferences = (proposed, sources) => {
|
|
41
|
+
const held = new Set(
|
|
42
|
+
sources.flatMap(
|
|
43
|
+
(source) => source.passages.map((passage) => `${source.id}/${passage.id}`)
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
let dropped = 0;
|
|
47
|
+
const assessments = proposed.map((assessment) => {
|
|
48
|
+
const references = assessment.references.filter(
|
|
49
|
+
(reference) => held.has(`${reference.sourceId}/${reference.passageId}`)
|
|
50
|
+
);
|
|
51
|
+
if (references.length === assessment.references.length) {
|
|
52
|
+
return assessment;
|
|
53
|
+
}
|
|
54
|
+
dropped += assessment.references.length - references.length;
|
|
55
|
+
if (assessment.verdict === "unresolved") {
|
|
56
|
+
return { ...assessment, references };
|
|
57
|
+
}
|
|
58
|
+
return references.length > 0 ? { ...assessment, references } : {
|
|
59
|
+
claimId: assessment.claimId,
|
|
60
|
+
verdict: "unresolved",
|
|
61
|
+
references,
|
|
62
|
+
explanation: assessment.explanation,
|
|
63
|
+
reason: "not_in_sources"
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
return { assessments, dropped };
|
|
67
|
+
};
|
|
68
|
+
var decisionRequestSchema = z.object({ inputDigest: z.string().optional() });
|
|
69
|
+
var parseCallAction = (call) => {
|
|
70
|
+
const parsed = researchActionSchema.safeParse(call.request);
|
|
71
|
+
return parsed.success ? parsed.data : void 0;
|
|
72
|
+
};
|
|
73
|
+
var parseCallResult = (call) => {
|
|
74
|
+
const parsed = researchToolResultSchema.safeParse(call.result);
|
|
75
|
+
return parsed.success ? parsed.data : void 0;
|
|
76
|
+
};
|
|
77
|
+
var getCallCandidateIds = (call) => {
|
|
78
|
+
const action = parseCallAction(call);
|
|
79
|
+
if (!action || action.tool === "finish_research") {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
return action.candidateIds;
|
|
83
|
+
};
|
|
84
|
+
var getDecisionInputDigest = (call) => {
|
|
85
|
+
const parsed = decisionRequestSchema.safeParse(call.request);
|
|
86
|
+
return parsed.success ? parsed.data.inputDigest : void 0;
|
|
87
|
+
};
|
|
88
|
+
var isReusableResult = (result) => {
|
|
89
|
+
return result !== void 0 && result.kind !== "failure";
|
|
90
|
+
};
|
|
91
|
+
var retrievalKinds = {
|
|
92
|
+
search_sources: "search",
|
|
93
|
+
fetch_source: "fetch",
|
|
94
|
+
read_saved_evidence: "read"
|
|
95
|
+
};
|
|
96
|
+
var isRetrievalCall = (call) => {
|
|
97
|
+
return ["fetch", "search", "read"].includes(call.kind);
|
|
98
|
+
};
|
|
99
|
+
var getActionIdentity = (action) => {
|
|
100
|
+
switch (action.tool) {
|
|
101
|
+
case "search_sources": {
|
|
102
|
+
return { tool: action.tool, query: action.query };
|
|
103
|
+
}
|
|
104
|
+
case "fetch_source": {
|
|
105
|
+
return { tool: action.tool, url: action.url };
|
|
106
|
+
}
|
|
107
|
+
case "read_saved_evidence": {
|
|
108
|
+
return {
|
|
109
|
+
tool: action.tool,
|
|
110
|
+
evidenceId: action.evidenceId,
|
|
111
|
+
start: action.start,
|
|
112
|
+
length: action.length
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
default: {
|
|
116
|
+
const unhandled = action;
|
|
117
|
+
throw new Error(`Unhandled research action: ${String(unhandled)}.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var getRetrieval = (call) => {
|
|
122
|
+
const result = parseCallResult(call);
|
|
123
|
+
const failureReason = result?.kind === "failure" ? result.reason : null;
|
|
124
|
+
const retrieval = {
|
|
125
|
+
callId: call.id,
|
|
126
|
+
kind: call.kind,
|
|
127
|
+
status: call.state === "pending" ? "unknown" : call.state,
|
|
128
|
+
reason: call.failure ?? failureReason,
|
|
129
|
+
sourceId: result?.kind === "fetch" ? result.source.id : null
|
|
130
|
+
};
|
|
131
|
+
return retrieval;
|
|
132
|
+
};
|
|
133
|
+
var storedAdjudicationSchema = z.array(proposedAssessmentSchema);
|
|
134
|
+
var completedTools = (session) => {
|
|
135
|
+
return session.calls.filter(
|
|
136
|
+
(call) => call.state === "completed" && ["search", "fetch", "read"].includes(call.kind) && (call.kind === "fetch" || call.inputDigest === session.inputDigest) && call.result !== void 0
|
|
137
|
+
).flatMap((call) => {
|
|
138
|
+
const result = researchToolResultSchema.safeParse(call.result);
|
|
139
|
+
if (!result.success) {
|
|
140
|
+
throw new GroundingIntegrityError(
|
|
141
|
+
`Committed research result is invalid for call: ${call.id}.`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return [result.data];
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
var sourceContext = (args, session) => {
|
|
148
|
+
const results = completedTools(session);
|
|
149
|
+
const sources = new Map(
|
|
150
|
+
[...args.baseBundle?.sources ?? [], ...args.seedSources ?? []].map(
|
|
151
|
+
(source) => [source.id, source]
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
const urls = new Set(args.knownUrls);
|
|
155
|
+
for (const source of sources.values()) {
|
|
156
|
+
urls.add(source.finalUrl);
|
|
157
|
+
}
|
|
158
|
+
for (const result of results) {
|
|
159
|
+
if (result.kind === "search") {
|
|
160
|
+
for (const lead of result.leads) {
|
|
161
|
+
urls.add(lead.url);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (result.kind === "fetch") {
|
|
165
|
+
if (!sources.has(result.source.id)) {
|
|
166
|
+
sources.set(result.source.id, result.source);
|
|
167
|
+
}
|
|
168
|
+
for (const url of result.links) {
|
|
169
|
+
urls.add(url);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { sources: [...sources.values()], allowedUrls: [...urls], results };
|
|
174
|
+
};
|
|
175
|
+
var assertLive = (args) => {
|
|
176
|
+
args.signal?.throwIfAborted();
|
|
177
|
+
if (!Number.isFinite(Date.parse(args.jobDeadlineAt)) || Date.now() >= Date.parse(args.jobDeadlineAt)) {
|
|
178
|
+
throw new ResearchLimitError("deadline");
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var assertCovers = (assessments, selected) => {
|
|
182
|
+
const selectedIds = new Set(selected.map(({ id }) => id));
|
|
183
|
+
if (assessments.some(({ claimId }) => !selectedIds.has(claimId))) {
|
|
184
|
+
throw new GroundingIntegrityError("Adjudicator returned an unknown claim.");
|
|
185
|
+
}
|
|
186
|
+
const assessed = new Set(assessments.map(({ claimId }) => claimId));
|
|
187
|
+
if (assessments.length !== selected.length || assessed.size !== selected.length) {
|
|
188
|
+
throw new GroundingIntegrityError(
|
|
189
|
+
`Adjudication must cover every selected claim exactly once: ${assessments.length} of ${selected.length}.`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
var isIntegrity = (error) => {
|
|
194
|
+
return error instanceof GroundingIntegrityError || error instanceof ResearchOwnershipError || error instanceof ModelBudgetError && !["exhausted", "deadline"].includes(error.kind) || error instanceof Error && error.name === "ZodError";
|
|
195
|
+
};
|
|
196
|
+
var stopForError = (error, deadlineAt) => {
|
|
197
|
+
if (Date.now() >= Date.parse(deadlineAt)) {
|
|
198
|
+
return "deadline";
|
|
199
|
+
}
|
|
200
|
+
if (error instanceof ResearchLimitError) {
|
|
201
|
+
return error.reason;
|
|
202
|
+
}
|
|
203
|
+
if (error instanceof ModelBudgetError) {
|
|
204
|
+
return error.kind === "deadline" ? "deadline" : "budget_exhausted";
|
|
205
|
+
}
|
|
206
|
+
return "provider_unavailable";
|
|
207
|
+
};
|
|
208
|
+
var undispatchedSearchFailures = /* @__PURE__ */ new Set([
|
|
209
|
+
"invalid_query",
|
|
210
|
+
"unavailable"
|
|
211
|
+
]);
|
|
212
|
+
var isUndispatchedSearch = (result) => {
|
|
213
|
+
return result.kind === "failure" && undispatchedSearchFailures.has(result.reason);
|
|
214
|
+
};
|
|
215
|
+
var runGroundingResearch = async (args) => {
|
|
216
|
+
assertLive(args);
|
|
217
|
+
if (args.tools.searchProvider !== args.profile.searchProvider) {
|
|
218
|
+
throw new GroundingIntegrityError(
|
|
219
|
+
`Research search provider differs from pinned profile: ${args.tools.searchProvider}.`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
if (args.baseBundle) {
|
|
223
|
+
validateGroundingBundle(args.baseBundle, {
|
|
224
|
+
reportKey: args.configIdentity.reportKey,
|
|
225
|
+
configVersion: args.configIdentity.configVersion
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
const candidates = args.candidates.map(
|
|
229
|
+
(candidate) => claimCandidateSchema.parse(candidate)
|
|
230
|
+
);
|
|
231
|
+
for (const candidate of candidates) {
|
|
232
|
+
validateCandidateOccurrences(candidate, args.answers);
|
|
233
|
+
}
|
|
234
|
+
const selected = candidates.filter(
|
|
235
|
+
(candidate) => candidate.disposition === "selected"
|
|
236
|
+
);
|
|
237
|
+
if (selected.length > args.profile.maxCandidates) {
|
|
238
|
+
throw new GroundingIntegrityError(
|
|
239
|
+
`Selected candidates exceed research allocation: ${selected.length}.`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
let session = await args.store.initialize({
|
|
243
|
+
phase: args.phase,
|
|
244
|
+
owner: args.owner,
|
|
245
|
+
profile: args.profile,
|
|
246
|
+
deadlineAt: args.jobDeadlineAt,
|
|
247
|
+
revisionSalt: args.revisionSalt,
|
|
248
|
+
input: {
|
|
249
|
+
configIdentity: args.configIdentity,
|
|
250
|
+
runId: args.runId,
|
|
251
|
+
reviewAsOf: args.reviewAsOf,
|
|
252
|
+
baseBundleDigest: args.baseBundle?.digest,
|
|
253
|
+
candidates,
|
|
254
|
+
answerDigests: args.answers.map(({ id, digest }) => ({ id, digest })),
|
|
255
|
+
knownUrls: args.knownUrls,
|
|
256
|
+
publicSearchTerms: args.publicSearchTerms,
|
|
257
|
+
coverage: args.coverage,
|
|
258
|
+
adjudication: args.model.adjudication,
|
|
259
|
+
decisionProfileDigest: args.model.decisionProfileDigest,
|
|
260
|
+
...args.revisionSalt ? { revisionSalt: args.revisionSalt } : {}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
if (session.bundle) {
|
|
264
|
+
return validateGroundingBundle(session.bundle, {
|
|
265
|
+
...args.configIdentity,
|
|
266
|
+
runId: args.runId,
|
|
267
|
+
answers: args.answers
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const refresh = async () => {
|
|
271
|
+
const current = await args.store.read(args.phase, args.owner);
|
|
272
|
+
if (current?.id !== session.id || current.revision !== session.revision || contentHash(current.owner) !== contentHash(session.owner)) {
|
|
273
|
+
throw new ResearchOwnershipError();
|
|
274
|
+
}
|
|
275
|
+
session = current;
|
|
276
|
+
await args.store.assertOwned(session);
|
|
277
|
+
};
|
|
278
|
+
let stage = session.stopReason ?? "researching";
|
|
279
|
+
const progress = () => {
|
|
280
|
+
args.onProgress?.({
|
|
281
|
+
phase: args.phase,
|
|
282
|
+
elapsedMs: Date.now() - Date.parse(session.startedAt),
|
|
283
|
+
attemptedRequests: session.calls.length,
|
|
284
|
+
completedRequests: session.calls.filter(
|
|
285
|
+
(call) => call.state === "completed"
|
|
286
|
+
).length,
|
|
287
|
+
selectedCandidates: selected.length,
|
|
288
|
+
researchedCandidates: new Set(session.calls.flatMap(getCallCandidateIds)).size,
|
|
289
|
+
unresolvedCandidates: session.bundle?.assessments.filter(
|
|
290
|
+
(assessment) => assessment.verdict === "unresolved"
|
|
291
|
+
).length ?? selected.length,
|
|
292
|
+
remainingDecisions: Math.max(
|
|
293
|
+
0,
|
|
294
|
+
args.profile.maxDecisions - session.calls.filter((call) => call.kind === "decision").length
|
|
295
|
+
),
|
|
296
|
+
remainingUsd: Math.max(
|
|
297
|
+
0,
|
|
298
|
+
args.profile.maxUsd - session.calls.reduce(
|
|
299
|
+
(sum, call) => sum + researchCallCharge(call).usd,
|
|
300
|
+
0
|
|
301
|
+
)
|
|
302
|
+
),
|
|
303
|
+
reason: stage
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
const timer = setInterval(progress, 3e4);
|
|
307
|
+
timer.unref();
|
|
308
|
+
progress();
|
|
309
|
+
try {
|
|
310
|
+
let noProgress = session.noProgressCount ?? 0;
|
|
311
|
+
while (!session.stopReason) {
|
|
312
|
+
assertLive(args);
|
|
313
|
+
await args.store.assertOwned(session);
|
|
314
|
+
let reason;
|
|
315
|
+
if (selected.length === 0) {
|
|
316
|
+
reason = "evidence_ready";
|
|
317
|
+
} else if (noProgress >= 2) {
|
|
318
|
+
reason = "no_progress";
|
|
319
|
+
} else if (Date.now() >= Date.parse(session.deadlineAt)) {
|
|
320
|
+
reason = "deadline";
|
|
321
|
+
}
|
|
322
|
+
if (reason) {
|
|
323
|
+
await args.store.stop(session, reason);
|
|
324
|
+
await refresh();
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
const context = sourceContext(args, session);
|
|
328
|
+
const signature = contentHash({
|
|
329
|
+
input: session.inputDigest,
|
|
330
|
+
calls: session.calls.map((call) => ({
|
|
331
|
+
id: call.id,
|
|
332
|
+
state: call.state
|
|
333
|
+
}))
|
|
334
|
+
});
|
|
335
|
+
let action;
|
|
336
|
+
let decisionId;
|
|
337
|
+
const savedDecision = session.calls.find(
|
|
338
|
+
(call) => call.kind === "decision" && call.state === "completed" && !call.consumed && getDecisionInputDigest(call) === session.inputDigest
|
|
339
|
+
);
|
|
340
|
+
try {
|
|
341
|
+
if (savedDecision) {
|
|
342
|
+
action = researchActionSchema.parse(savedDecision.result);
|
|
343
|
+
decisionId = savedDecision.id;
|
|
344
|
+
} else {
|
|
345
|
+
const call = await args.store.reserve(session, {
|
|
346
|
+
kind: "decision",
|
|
347
|
+
signature,
|
|
348
|
+
reservedUsd: args.profile.decisionReserveUsd,
|
|
349
|
+
reservedTokens: args.profile.decisionReserveTokens,
|
|
350
|
+
request: { inputDigest: session.inputDigest }
|
|
351
|
+
});
|
|
352
|
+
decisionId = call.id;
|
|
353
|
+
await args.store.assertOwned(session);
|
|
354
|
+
let usage;
|
|
355
|
+
try {
|
|
356
|
+
action = researchActionSchema.parse(
|
|
357
|
+
await args.model.decide(
|
|
358
|
+
{
|
|
359
|
+
candidates: selected,
|
|
360
|
+
sources: context.sources,
|
|
361
|
+
allowedUrls: context.allowedUrls,
|
|
362
|
+
publicSearchTerms: args.publicSearchTerms,
|
|
363
|
+
previousResults: context.results.slice(-4),
|
|
364
|
+
remaining: {
|
|
365
|
+
decisions: args.profile.maxDecisions - session.calls.filter((item) => item.kind === "decision").length - 1,
|
|
366
|
+
searches: args.profile.maxSearches - session.calls.filter((item) => item.kind === "search").length,
|
|
367
|
+
documents: args.profile.maxDocuments - context.sources.length + (args.baseBundle?.sources.length ?? 0),
|
|
368
|
+
elapsedMs: Math.max(
|
|
369
|
+
0,
|
|
370
|
+
Date.parse(session.deadlineAt) - Date.now()
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
AbortSignal.any([
|
|
375
|
+
...args.signal ? [args.signal] : [],
|
|
376
|
+
AbortSignal.timeout(
|
|
377
|
+
Math.max(1, Date.parse(session.deadlineAt) - Date.now())
|
|
378
|
+
)
|
|
379
|
+
]),
|
|
380
|
+
(value) => {
|
|
381
|
+
usage = value;
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
);
|
|
385
|
+
await args.store.commit(session, call.id, {
|
|
386
|
+
result: action,
|
|
387
|
+
usage
|
|
388
|
+
});
|
|
389
|
+
} catch (error) {
|
|
390
|
+
await args.store.commit(session, call.id, {
|
|
391
|
+
failure: error instanceof ResearchLimitError ? error.reason : "decision_failed",
|
|
392
|
+
usage
|
|
393
|
+
});
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
} catch (error) {
|
|
398
|
+
args.signal?.throwIfAborted();
|
|
399
|
+
if (isIntegrity(error)) {
|
|
400
|
+
throw error;
|
|
401
|
+
}
|
|
402
|
+
await args.store.stop(session, stopForError(error, session.deadlineAt));
|
|
403
|
+
await refresh();
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
await refresh();
|
|
407
|
+
if (action.tool === "finish_research") {
|
|
408
|
+
const evidenced = new Set(
|
|
409
|
+
session.calls.filter(
|
|
410
|
+
(call) => call.state === "completed" && call.kind !== "decision" && parseCallResult(call)?.kind !== "failure"
|
|
411
|
+
).flatMap(getCallCandidateIds)
|
|
412
|
+
);
|
|
413
|
+
const unevidenced = selected.filter((candidate) => !evidenced.has(candidate.id)).map((candidate) => candidate.id);
|
|
414
|
+
await args.store.stop(
|
|
415
|
+
session,
|
|
416
|
+
action.reason === "evidence_ready" && unevidenced.length === selected.length && selected.length ? "sources_exhausted" : action.reason
|
|
417
|
+
);
|
|
418
|
+
await refresh();
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
if (action.candidateIds.some(
|
|
422
|
+
(id) => !selected.some((candidate) => candidate.id === id)
|
|
423
|
+
)) {
|
|
424
|
+
noProgress = await args.store.consumeDecision(
|
|
425
|
+
session,
|
|
426
|
+
decisionId,
|
|
427
|
+
false
|
|
428
|
+
);
|
|
429
|
+
await refresh();
|
|
430
|
+
if (noProgress >= 2) {
|
|
431
|
+
await args.store.stop(session, "no_progress");
|
|
432
|
+
await refresh();
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
const actionSignature = contentHash({
|
|
438
|
+
input: session.inputDigest,
|
|
439
|
+
action: getActionIdentity(action)
|
|
440
|
+
});
|
|
441
|
+
const reused = session.calls.find(
|
|
442
|
+
(call) => call.signature === actionSignature && call.state === "completed" && isReusableResult(parseCallResult(call))
|
|
443
|
+
);
|
|
444
|
+
let madeProgress = false;
|
|
445
|
+
if (reused) {
|
|
446
|
+
noProgress += 1;
|
|
447
|
+
} else {
|
|
448
|
+
const kind = retrievalKinds[action.tool];
|
|
449
|
+
try {
|
|
450
|
+
if (action.tool === "search_sources") {
|
|
451
|
+
for (const candidateId of action.candidateIds) {
|
|
452
|
+
const queries = new Set(
|
|
453
|
+
session.calls.filter((call2) => call2.kind === "search").flatMap((call2) => {
|
|
454
|
+
const request = parseCallAction(call2);
|
|
455
|
+
return request?.tool === "search_sources" && request.candidateIds.includes(candidateId) ? [request.query] : [];
|
|
456
|
+
})
|
|
457
|
+
);
|
|
458
|
+
if (!queries.has(action.query) && queries.size >= args.profile.maxQueriesPerCandidate) {
|
|
459
|
+
throw new ResearchLimitError("budget_exhausted");
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (action.tool === "fetch_source") {
|
|
464
|
+
const documents = new Set(
|
|
465
|
+
session.calls.flatMap((call2) => {
|
|
466
|
+
const request = parseCallAction(call2);
|
|
467
|
+
const result2 = parseCallResult(call2);
|
|
468
|
+
return request?.tool === "fetch_source" && result2?.kind === "fetch" ? [request.url] : [];
|
|
469
|
+
})
|
|
470
|
+
);
|
|
471
|
+
if (!documents.has(action.url) && documents.size >= args.profile.maxDocuments) {
|
|
472
|
+
throw new ResearchLimitError("budget_exhausted");
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const call = await args.store.reserve(session, {
|
|
476
|
+
kind,
|
|
477
|
+
signature: actionSignature,
|
|
478
|
+
reservedUsd: kind === "search" ? args.profile.searchReserveUsd : 0,
|
|
479
|
+
reservedTokens: 0,
|
|
480
|
+
request: action
|
|
481
|
+
});
|
|
482
|
+
if (kind === "search") {
|
|
483
|
+
await args.accounting.reserve({
|
|
484
|
+
callId: call.id,
|
|
485
|
+
role: "research_search",
|
|
486
|
+
reservedUsd: args.profile.searchReserveUsd,
|
|
487
|
+
inputTokens: 0,
|
|
488
|
+
maxOutputTokens: 0
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
await args.accounting.assertOwned();
|
|
492
|
+
await args.store.assertOwned(session);
|
|
493
|
+
const before = contentHash({
|
|
494
|
+
sources: context.sources.map((source) => source.id),
|
|
495
|
+
urls: context.allowedUrls,
|
|
496
|
+
failures: [
|
|
497
|
+
...new Set(
|
|
498
|
+
context.results.filter((result2) => result2.kind === "failure").map(contentHash)
|
|
499
|
+
)
|
|
500
|
+
],
|
|
501
|
+
reads: [
|
|
502
|
+
...new Set(
|
|
503
|
+
context.results.filter((result2) => result2.kind === "read").map(contentHash)
|
|
504
|
+
)
|
|
505
|
+
]
|
|
506
|
+
});
|
|
507
|
+
let requestCount = 0;
|
|
508
|
+
let result;
|
|
509
|
+
try {
|
|
510
|
+
result = researchToolResultSchema.parse(
|
|
511
|
+
await args.tools.execute(action, {
|
|
512
|
+
sources: context.sources,
|
|
513
|
+
allowedUrls: context.allowedUrls,
|
|
514
|
+
signal: AbortSignal.any([
|
|
515
|
+
...args.signal ? [args.signal] : [],
|
|
516
|
+
AbortSignal.timeout(
|
|
517
|
+
Math.max(
|
|
518
|
+
1,
|
|
519
|
+
Math.min(
|
|
520
|
+
15e3,
|
|
521
|
+
Date.parse(session.deadlineAt) - Date.now()
|
|
522
|
+
)
|
|
523
|
+
)
|
|
524
|
+
)
|
|
525
|
+
]),
|
|
526
|
+
beforeFetchRequest: async () => {
|
|
527
|
+
if (requestCount++ > 0) {
|
|
528
|
+
await args.store.reserve(session, {
|
|
529
|
+
kind: "fetch",
|
|
530
|
+
signature: `${call.id}:redirect:${requestCount}`,
|
|
531
|
+
reservedUsd: 0,
|
|
532
|
+
reservedTokens: 0
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
await args.store.assertOwned(session);
|
|
536
|
+
}
|
|
537
|
+
})
|
|
538
|
+
);
|
|
539
|
+
if (result.kind === "search" && result.reportedCostUsd !== null) {
|
|
540
|
+
await args.accounting.settle(call.id, {
|
|
541
|
+
costUsd: result.reportedCostUsd,
|
|
542
|
+
inputTokens: 0,
|
|
543
|
+
outputTokens: 0,
|
|
544
|
+
requestId: result.providerRequestId
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
if (kind === "search" && isUndispatchedSearch(result)) {
|
|
548
|
+
await args.accounting.settle(call.id, {
|
|
549
|
+
costUsd: 0,
|
|
550
|
+
inputTokens: 0,
|
|
551
|
+
outputTokens: 0
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
} catch (error) {
|
|
555
|
+
args.signal?.throwIfAborted();
|
|
556
|
+
if (isIntegrity(error) || error instanceof ResearchLimitError) {
|
|
557
|
+
throw error;
|
|
558
|
+
}
|
|
559
|
+
result = {
|
|
560
|
+
kind: "failure",
|
|
561
|
+
reason: error instanceof SourceRetrievalError && error.reason === "unsafe_destination" ? "unsafe_destination" : "retrieval_failed",
|
|
562
|
+
retryable: false
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
await args.store.commit(session, call.id, {
|
|
566
|
+
result,
|
|
567
|
+
usage: kind === "search" && isUndispatchedSearch(result) ? { usd: 0, tokens: 0 } : void 0
|
|
568
|
+
});
|
|
569
|
+
await refresh();
|
|
570
|
+
const after = sourceContext(args, session);
|
|
571
|
+
const fingerprint = contentHash({
|
|
572
|
+
sources: after.sources.map((source) => source.id),
|
|
573
|
+
urls: after.allowedUrls,
|
|
574
|
+
failures: [
|
|
575
|
+
...new Set(
|
|
576
|
+
after.results.filter((result2) => result2.kind === "failure").map(contentHash)
|
|
577
|
+
)
|
|
578
|
+
],
|
|
579
|
+
reads: [
|
|
580
|
+
...new Set(
|
|
581
|
+
after.results.filter((result2) => result2.kind === "read").map(contentHash)
|
|
582
|
+
)
|
|
583
|
+
]
|
|
584
|
+
});
|
|
585
|
+
madeProgress = fingerprint !== before;
|
|
586
|
+
noProgress = madeProgress ? 0 : noProgress + 1;
|
|
587
|
+
} catch (error) {
|
|
588
|
+
args.signal?.throwIfAborted();
|
|
589
|
+
if (isIntegrity(error)) {
|
|
590
|
+
throw error;
|
|
591
|
+
}
|
|
592
|
+
await args.store.stop(
|
|
593
|
+
session,
|
|
594
|
+
stopForError(error, session.deadlineAt)
|
|
595
|
+
);
|
|
596
|
+
await refresh();
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
noProgress = await args.store.consumeDecision(
|
|
601
|
+
session,
|
|
602
|
+
decisionId,
|
|
603
|
+
madeProgress
|
|
604
|
+
);
|
|
605
|
+
await refresh();
|
|
606
|
+
if (noProgress >= 2) {
|
|
607
|
+
await args.store.stop(session, "no_progress");
|
|
608
|
+
await refresh();
|
|
609
|
+
}
|
|
610
|
+
progress();
|
|
611
|
+
}
|
|
612
|
+
assertLive(args);
|
|
613
|
+
await args.store.assertOwned(session);
|
|
614
|
+
stage = "adjudicating";
|
|
615
|
+
progress();
|
|
616
|
+
let frozen = session.sourceBundle;
|
|
617
|
+
if (!frozen) {
|
|
618
|
+
const context = sourceContext(args, session);
|
|
619
|
+
const { stopReason } = session;
|
|
620
|
+
if (!stopReason) {
|
|
621
|
+
throw new GroundingIntegrityError(
|
|
622
|
+
`Research session ended without a stop reason: ${session.id}.`
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
frozen = createGroundingBundle({
|
|
626
|
+
schemaVersion: groundingSchemaVersion,
|
|
627
|
+
policyVersion: groundingPolicyVersion,
|
|
628
|
+
configIdentity: args.configIdentity,
|
|
629
|
+
...args.runId ? { runId: args.runId } : {},
|
|
630
|
+
reviewAsOf: args.reviewAsOf,
|
|
631
|
+
sources: context.sources,
|
|
632
|
+
facts: args.baseBundle?.facts ?? [],
|
|
633
|
+
candidates,
|
|
634
|
+
assessments: [],
|
|
635
|
+
adjudication: null,
|
|
636
|
+
coverage: {
|
|
637
|
+
...args.coverage,
|
|
638
|
+
selectedCandidates: selected.length,
|
|
639
|
+
overflowCandidates: candidates.filter(
|
|
640
|
+
(candidate) => candidate.disposition === "overflow"
|
|
641
|
+
).length,
|
|
642
|
+
stopReason,
|
|
643
|
+
retrievals: session.calls.filter(isRetrievalCall).map(getRetrieval),
|
|
644
|
+
gaps: context.results.some((result) => result.kind === "failure") ? [
|
|
645
|
+
{
|
|
646
|
+
candidateIds: selected.map((candidate) => candidate.id),
|
|
647
|
+
reason: "retrieval_failed"
|
|
648
|
+
}
|
|
649
|
+
] : []
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
await args.store.freezeSources(session, frozen);
|
|
653
|
+
}
|
|
654
|
+
const adjudicationKey = adjudicationEvidenceDigest(
|
|
655
|
+
frozen,
|
|
656
|
+
args.model.adjudication
|
|
657
|
+
);
|
|
658
|
+
const completed = session.calls.find(
|
|
659
|
+
(call) => call.kind === "adjudication" && call.state === "completed" && (call.signature === adjudicationKey || call.signature === frozen.sourceBundleDigest)
|
|
660
|
+
);
|
|
661
|
+
let proposed;
|
|
662
|
+
if (completed) {
|
|
663
|
+
proposed = storedAdjudicationSchema.parse(completed.result);
|
|
664
|
+
} else if (selected.length === 0) {
|
|
665
|
+
proposed = [];
|
|
666
|
+
} else {
|
|
667
|
+
try {
|
|
668
|
+
const call = await args.store.reserve(session, {
|
|
669
|
+
kind: "adjudication",
|
|
670
|
+
signature: adjudicationKey,
|
|
671
|
+
reservedUsd: args.profile.adjudicationReserveUsd,
|
|
672
|
+
reservedTokens: args.profile.adjudicationReserveTokens
|
|
673
|
+
});
|
|
674
|
+
await args.store.assertOwned(session);
|
|
675
|
+
let usage;
|
|
676
|
+
try {
|
|
677
|
+
proposed = await args.model.adjudicate(
|
|
678
|
+
frozen,
|
|
679
|
+
AbortSignal.any([
|
|
680
|
+
...args.signal ? [args.signal] : [],
|
|
681
|
+
AbortSignal.timeout(
|
|
682
|
+
Math.max(1, Date.parse(args.jobDeadlineAt) - Date.now())
|
|
683
|
+
)
|
|
684
|
+
]),
|
|
685
|
+
(value) => {
|
|
686
|
+
usage = value;
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
assertCovers(proposed, selected);
|
|
690
|
+
await args.store.commit(session, call.id, {
|
|
691
|
+
result: proposed,
|
|
692
|
+
usage
|
|
693
|
+
});
|
|
694
|
+
} catch (error) {
|
|
695
|
+
await args.store.commit(session, call.id, {
|
|
696
|
+
failure: "adjudication_failed",
|
|
697
|
+
usage
|
|
698
|
+
});
|
|
699
|
+
throw error;
|
|
700
|
+
}
|
|
701
|
+
} catch (error) {
|
|
702
|
+
args.signal?.throwIfAborted();
|
|
703
|
+
if (isIntegrity(error)) {
|
|
704
|
+
throw error;
|
|
705
|
+
}
|
|
706
|
+
proposed = selected.map((candidate) => ({
|
|
707
|
+
claimId: candidate.id,
|
|
708
|
+
verdict: "unresolved",
|
|
709
|
+
references: [],
|
|
710
|
+
explanation: "Claim assessment could not be completed within the recorded allocation.",
|
|
711
|
+
reason: error instanceof ResearchLimitError || error instanceof ModelBudgetError ? "budget_exhausted" : "provider_unavailable"
|
|
712
|
+
}));
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const pruned = pruneUnknownReferences(proposed, frozen.sources);
|
|
716
|
+
const assessed = pruned.assessments.map((assessment) => {
|
|
717
|
+
const candidate = selected.find((item) => item.id === assessment.claimId);
|
|
718
|
+
if (!candidate) {
|
|
719
|
+
throw new GroundingIntegrityError(
|
|
720
|
+
`Adjudicator returned an unknown claim: ${assessment.claimId}.`
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
const value = {
|
|
724
|
+
...assessment,
|
|
725
|
+
scope: candidate.scope,
|
|
726
|
+
sourceBundleDigest: frozen.sourceBundleDigest
|
|
727
|
+
};
|
|
728
|
+
return {
|
|
729
|
+
candidate,
|
|
730
|
+
assessment: { ...value, digest: assessmentDigest(value) }
|
|
731
|
+
};
|
|
732
|
+
});
|
|
733
|
+
const assessments = assessed.map(({ assessment }) => assessment);
|
|
734
|
+
assertCovers(assessments, selected);
|
|
735
|
+
const facts = args.phase === "author" ? assessed.map(({ candidate, assessment }) => ({
|
|
736
|
+
id: candidate.id,
|
|
737
|
+
proposition: candidate.proposition,
|
|
738
|
+
scope: candidate.scope,
|
|
739
|
+
references: assessment.references,
|
|
740
|
+
status: assessment.verdict === "supported" ? "supported" : "unresolved",
|
|
741
|
+
reason: assessment.explanation
|
|
742
|
+
})) : frozen.facts;
|
|
743
|
+
const final = {
|
|
744
|
+
...frozen,
|
|
745
|
+
facts,
|
|
746
|
+
assessments,
|
|
747
|
+
adjudication: {
|
|
748
|
+
...args.model.adjudication,
|
|
749
|
+
policyVersion: adjudicationVersion,
|
|
750
|
+
...pruned.dropped ? { droppedReferences: pruned.dropped } : {}
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
const bundle = validateGroundingBundle(
|
|
754
|
+
{ ...final, digest: groundingDigest(final) },
|
|
755
|
+
{ ...args.configIdentity, runId: args.runId, answers: args.answers }
|
|
756
|
+
);
|
|
757
|
+
assertLive(args);
|
|
758
|
+
await args.store.freeze(session, bundle);
|
|
759
|
+
await refresh();
|
|
760
|
+
if (!session.stopReason) {
|
|
761
|
+
throw new GroundingIntegrityError(
|
|
762
|
+
`Frozen research session has no stop reason: ${session.id}.`
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
stage = session.stopReason;
|
|
766
|
+
progress();
|
|
767
|
+
return bundle;
|
|
768
|
+
} finally {
|
|
769
|
+
clearInterval(timer);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
export {
|
|
774
|
+
pruneUnknownReferences,
|
|
775
|
+
runGroundingResearch
|
|
776
|
+
};
|