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,741 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openFileVersionStores
|
|
3
|
+
} from "./chunk-RMFT4KKK.js";
|
|
4
|
+
import {
|
|
5
|
+
assertPublishable,
|
|
6
|
+
sameTriple
|
|
7
|
+
} from "./chunk-S2AM76LT.js";
|
|
8
|
+
import {
|
|
9
|
+
validateReportArtifacts
|
|
10
|
+
} from "./chunk-ISN6MBNB.js";
|
|
11
|
+
import {
|
|
12
|
+
filePublicationHistory,
|
|
13
|
+
readFilePublication,
|
|
14
|
+
withFilePublicationLock,
|
|
15
|
+
writeAtomicJson,
|
|
16
|
+
writeFilePublication
|
|
17
|
+
} from "./chunk-AP5DLF36.js";
|
|
18
|
+
import {
|
|
19
|
+
publicationTripleSchema
|
|
20
|
+
} from "./chunk-2URYGUMH.js";
|
|
21
|
+
import {
|
|
22
|
+
aeoCheckpointDir,
|
|
23
|
+
aeoContentDir
|
|
24
|
+
} from "./chunk-IRPKBDB7.js";
|
|
25
|
+
import {
|
|
26
|
+
StoreConflictError
|
|
27
|
+
} from "./chunk-FWBVTM7F.js";
|
|
28
|
+
import {
|
|
29
|
+
UnitConflictError
|
|
30
|
+
} from "./chunk-C6CMSW5J.js";
|
|
31
|
+
import {
|
|
32
|
+
hasErrorCode
|
|
33
|
+
} from "./chunk-2QLAFBCG.js";
|
|
34
|
+
import {
|
|
35
|
+
projectProgressMeasurement
|
|
36
|
+
} from "./chunk-D2INDP5W.js";
|
|
37
|
+
import {
|
|
38
|
+
entryMatches,
|
|
39
|
+
unitRecordKey
|
|
40
|
+
} from "./chunk-ULRXHSJL.js";
|
|
41
|
+
import {
|
|
42
|
+
createLog
|
|
43
|
+
} from "./chunk-ZSEY7AHQ.js";
|
|
44
|
+
import {
|
|
45
|
+
domainLabelsFile,
|
|
46
|
+
domainLabelsFileSchema
|
|
47
|
+
} from "./chunk-ZCOI3HE2.js";
|
|
48
|
+
import {
|
|
49
|
+
aeoAuditConfigSchema
|
|
50
|
+
} from "./chunk-ZLOOC46D.js";
|
|
51
|
+
import {
|
|
52
|
+
evaluateRunClaim,
|
|
53
|
+
isTerminalRun,
|
|
54
|
+
serializeRunFile
|
|
55
|
+
} from "./chunk-WJUHRJVW.js";
|
|
56
|
+
import {
|
|
57
|
+
aeoEvidenceChunkSchema,
|
|
58
|
+
aeoSnapshotSchema,
|
|
59
|
+
evidenceChunkFileName
|
|
60
|
+
} from "./chunk-SDWYZM64.js";
|
|
61
|
+
import {
|
|
62
|
+
parseProgressMeasurement
|
|
63
|
+
} from "./chunk-D7GEQVLL.js";
|
|
64
|
+
import {
|
|
65
|
+
contentHash
|
|
66
|
+
} from "./chunk-H2KDLDK6.js";
|
|
67
|
+
|
|
68
|
+
// src/stores/files.ts
|
|
69
|
+
import { existsSync } from "node:fs";
|
|
70
|
+
import {
|
|
71
|
+
chmod,
|
|
72
|
+
mkdir,
|
|
73
|
+
mkdtemp,
|
|
74
|
+
open,
|
|
75
|
+
readFile,
|
|
76
|
+
readdir,
|
|
77
|
+
rename,
|
|
78
|
+
rm,
|
|
79
|
+
writeFile
|
|
80
|
+
} from "node:fs/promises";
|
|
81
|
+
import path from "node:path";
|
|
82
|
+
import { z } from "zod";
|
|
83
|
+
var log = createLog("FileStores");
|
|
84
|
+
var readJsonl = async (filePath) => {
|
|
85
|
+
let raw;
|
|
86
|
+
try {
|
|
87
|
+
raw = await readFile(filePath, "utf8");
|
|
88
|
+
} catch {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const rows = [];
|
|
92
|
+
for (const line of raw.split("\n")) {
|
|
93
|
+
if (!line.trim()) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
rows.push(JSON.parse(line));
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return rows;
|
|
102
|
+
};
|
|
103
|
+
var JsonlFile = class {
|
|
104
|
+
filePath;
|
|
105
|
+
#queue = Promise.resolve();
|
|
106
|
+
constructor(filePath) {
|
|
107
|
+
this.filePath = filePath;
|
|
108
|
+
}
|
|
109
|
+
append(line) {
|
|
110
|
+
return this.#write(`${line}
|
|
111
|
+
`, "a");
|
|
112
|
+
}
|
|
113
|
+
rewrite(lines) {
|
|
114
|
+
return this.#write(lines.map((line) => `${line}
|
|
115
|
+
`).join(""), "w");
|
|
116
|
+
}
|
|
117
|
+
#write(content, flag) {
|
|
118
|
+
const write = this.#queue.then(async () => {
|
|
119
|
+
const directory = path.dirname(this.filePath);
|
|
120
|
+
await mkdir(directory, { recursive: true, mode: 448 });
|
|
121
|
+
await chmod(directory, 448);
|
|
122
|
+
const file = await open(this.filePath, flag, 384);
|
|
123
|
+
try {
|
|
124
|
+
await file.chmod(384);
|
|
125
|
+
await file.writeFile(content, "utf8");
|
|
126
|
+
} finally {
|
|
127
|
+
await file.close();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
this.#queue = write.catch(() => void 0);
|
|
131
|
+
return write;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var hasUnitKey = (row) => {
|
|
135
|
+
return "sectionKey" in row && typeof row.sectionKey === "string" && "promptId" in row && typeof row.promptId === "string" && "promptText" in row && typeof row.promptText === "string" && "surface" in row && typeof row.surface === "string" && "runIndex" in row && typeof row.runIndex === "number";
|
|
136
|
+
};
|
|
137
|
+
var isFailedUnitLine = (row) => {
|
|
138
|
+
return "status" in row && row.status === "failed";
|
|
139
|
+
};
|
|
140
|
+
var isCapturedUnitLine = (row) => {
|
|
141
|
+
return "probe" in row && Boolean(row.probe) && "capturedAt" in row && typeof row.capturedAt === "string";
|
|
142
|
+
};
|
|
143
|
+
var parseUnitRecord = (row) => {
|
|
144
|
+
if (!row || typeof row !== "object" || !hasUnitKey(row)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (isFailedUnitLine(row)) {
|
|
148
|
+
return row;
|
|
149
|
+
}
|
|
150
|
+
if (isCapturedUnitLine(row)) {
|
|
151
|
+
return { ...row, status: "captured" };
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
};
|
|
155
|
+
var FileProbeStore = class _FileProbeStore {
|
|
156
|
+
#file;
|
|
157
|
+
#records;
|
|
158
|
+
constructor(filePath, records) {
|
|
159
|
+
this.#file = new JsonlFile(filePath);
|
|
160
|
+
this.#records = records;
|
|
161
|
+
}
|
|
162
|
+
static async open(reportKey, opts = {}) {
|
|
163
|
+
const filePath = path.join(
|
|
164
|
+
opts.dir ?? aeoCheckpointDir,
|
|
165
|
+
`${reportKey}.jsonl`
|
|
166
|
+
);
|
|
167
|
+
const records = /* @__PURE__ */ new Map();
|
|
168
|
+
for (const row of await readJsonl(filePath)) {
|
|
169
|
+
const record = parseUnitRecord(row);
|
|
170
|
+
if (record) {
|
|
171
|
+
records.set(unitRecordKey(record), record);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return new _FileProbeStore(filePath, records);
|
|
175
|
+
}
|
|
176
|
+
get size() {
|
|
177
|
+
return this.#records.size;
|
|
178
|
+
}
|
|
179
|
+
get(unit) {
|
|
180
|
+
return Promise.resolve(this.#records.get(unitRecordKey(unit)) ?? null);
|
|
181
|
+
}
|
|
182
|
+
async put(record) {
|
|
183
|
+
const key = unitRecordKey(record);
|
|
184
|
+
const existing = this.#records.get(key);
|
|
185
|
+
if (existing?.status === "captured") {
|
|
186
|
+
if (record.status === "captured") {
|
|
187
|
+
throw new UnitConflictError(key);
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.#records.set(key, record);
|
|
192
|
+
await this.#file.append(JSON.stringify(record));
|
|
193
|
+
}
|
|
194
|
+
async invalidate(match) {
|
|
195
|
+
let removed = 0;
|
|
196
|
+
for (const [key, record] of this.#records) {
|
|
197
|
+
if (!entryMatches(record, match)) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
this.#records.delete(key);
|
|
201
|
+
removed += 1;
|
|
202
|
+
}
|
|
203
|
+
if (removed > 0) {
|
|
204
|
+
await this.#rewrite();
|
|
205
|
+
}
|
|
206
|
+
return removed;
|
|
207
|
+
}
|
|
208
|
+
list() {
|
|
209
|
+
return Promise.resolve([...this.#records.values()]);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* rewriteRecords rewrites stored probes in place (one-off data repairs):
|
|
213
|
+
* `patch` returns the replacement record or null to leave the entry
|
|
214
|
+
* untouched.
|
|
215
|
+
*/
|
|
216
|
+
async rewriteRecords(patch) {
|
|
217
|
+
let changed = 0;
|
|
218
|
+
for (const [key, record] of this.#records) {
|
|
219
|
+
const next = patch(record);
|
|
220
|
+
if (!next) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
this.#records.set(key, next);
|
|
224
|
+
changed += 1;
|
|
225
|
+
}
|
|
226
|
+
if (changed > 0) {
|
|
227
|
+
await this.#rewrite();
|
|
228
|
+
}
|
|
229
|
+
return changed;
|
|
230
|
+
}
|
|
231
|
+
#rewrite() {
|
|
232
|
+
return this.#file.rewrite(
|
|
233
|
+
[...this.#records.values()].map((record) => JSON.stringify(record))
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
var analysisCheckpointPath = (reportKey, dir = aeoCheckpointDir) => {
|
|
238
|
+
return path.join(dir, `${reportKey}.analysis.jsonl`);
|
|
239
|
+
};
|
|
240
|
+
var isAnalysisEntryLine = (row) => {
|
|
241
|
+
return typeof row === "object" && row !== null && "key" in row && typeof row.key === "string" && "value" in row;
|
|
242
|
+
};
|
|
243
|
+
var FileAnalysisStore = class _FileAnalysisStore {
|
|
244
|
+
#file;
|
|
245
|
+
#entries;
|
|
246
|
+
constructor(filePath, entries) {
|
|
247
|
+
this.#file = new JsonlFile(filePath);
|
|
248
|
+
this.#entries = entries;
|
|
249
|
+
}
|
|
250
|
+
static async open(reportKey, opts = {}) {
|
|
251
|
+
const filePath = analysisCheckpointPath(reportKey, opts.dir);
|
|
252
|
+
const entries = /* @__PURE__ */ new Map();
|
|
253
|
+
for (const row of await readJsonl(filePath)) {
|
|
254
|
+
if (isAnalysisEntryLine(row)) {
|
|
255
|
+
entries.set(row.key, row);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return new _FileAnalysisStore(filePath, entries);
|
|
259
|
+
}
|
|
260
|
+
get(key, schema) {
|
|
261
|
+
const entry = this.#entries.get(key);
|
|
262
|
+
if (!entry) {
|
|
263
|
+
return Promise.resolve(null);
|
|
264
|
+
}
|
|
265
|
+
const parsed = schema.safeParse(entry.value);
|
|
266
|
+
if (!parsed.success) {
|
|
267
|
+
log.warn("Ignoring invalid cached analysis entry", {
|
|
268
|
+
key: key.slice(0, 80),
|
|
269
|
+
error: parsed.error.message.slice(0, 200)
|
|
270
|
+
});
|
|
271
|
+
return Promise.resolve(null);
|
|
272
|
+
}
|
|
273
|
+
return Promise.resolve(parsed.data);
|
|
274
|
+
}
|
|
275
|
+
async put(key, value, meta) {
|
|
276
|
+
const entry = {
|
|
277
|
+
key,
|
|
278
|
+
storedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
279
|
+
value,
|
|
280
|
+
...meta ? { meta } : {}
|
|
281
|
+
};
|
|
282
|
+
this.#entries.set(key, entry);
|
|
283
|
+
await this.#file.append(JSON.stringify(entry));
|
|
284
|
+
}
|
|
285
|
+
async clear() {
|
|
286
|
+
const size = this.#entries.size;
|
|
287
|
+
this.#entries.clear();
|
|
288
|
+
await rm(this.#file.filePath, { force: true });
|
|
289
|
+
return size;
|
|
290
|
+
}
|
|
291
|
+
count() {
|
|
292
|
+
return Promise.resolve(this.#entries.size);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var publishedPointerSchema = z.object({ runId: z.string() });
|
|
296
|
+
var storedProgressSchema = z.object({
|
|
297
|
+
reportKey: z.unknown().optional(),
|
|
298
|
+
configVersion: z.unknown().optional(),
|
|
299
|
+
sourceDigest: z.unknown().optional(),
|
|
300
|
+
measurement: z.unknown().optional()
|
|
301
|
+
});
|
|
302
|
+
var storedArtifactSchema = z.object({
|
|
303
|
+
fullScope: z.boolean().catch(false),
|
|
304
|
+
configVersion: z.number().nullish().catch(null),
|
|
305
|
+
snapshot: z.unknown().optional(),
|
|
306
|
+
grounding: z.unknown().optional(),
|
|
307
|
+
captureManifest: z.unknown().optional()
|
|
308
|
+
});
|
|
309
|
+
var FileReportStore = class {
|
|
310
|
+
contentDir;
|
|
311
|
+
#publicationStores;
|
|
312
|
+
constructor(contentDir = aeoContentDir, publicationStores) {
|
|
313
|
+
this.contentDir = contentDir;
|
|
314
|
+
this.#publicationStores = publicationStores;
|
|
315
|
+
}
|
|
316
|
+
#runDir(reportKey, runId) {
|
|
317
|
+
for (const value of [reportKey, runId]) {
|
|
318
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(value)) {
|
|
319
|
+
throw new Error(`Invalid report or run identity provided: ${value}.`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const runsDir = this.contentDir === aeoContentDir ? path.join(aeoCheckpointDir, "reports") : path.join(this.contentDir, ".runs");
|
|
323
|
+
return path.join(runsDir, reportKey, runId);
|
|
324
|
+
}
|
|
325
|
+
async #readableDir(reportKey, runId) {
|
|
326
|
+
if (runId) {
|
|
327
|
+
return this.#runDir(reportKey, runId);
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
const publication = publishedPointerSchema.parse(
|
|
331
|
+
JSON.parse(
|
|
332
|
+
await readFile(
|
|
333
|
+
path.join(this.reportDir(reportKey), "published.json"),
|
|
334
|
+
"utf8"
|
|
335
|
+
)
|
|
336
|
+
)
|
|
337
|
+
);
|
|
338
|
+
return this.#runDir(reportKey, publication.runId);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
if (!hasErrorCode(error, "ENOENT")) {
|
|
341
|
+
throw error;
|
|
342
|
+
}
|
|
343
|
+
return this.reportDir(reportKey);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
reportDir(reportKey) {
|
|
347
|
+
return path.join(this.contentDir, reportKey);
|
|
348
|
+
}
|
|
349
|
+
async readArtifacts(reportKey, runId) {
|
|
350
|
+
try {
|
|
351
|
+
return validateReportArtifacts(
|
|
352
|
+
JSON.parse(
|
|
353
|
+
await readFile(
|
|
354
|
+
path.join(this.#runDir(reportKey, runId), "artifacts.json"),
|
|
355
|
+
"utf8"
|
|
356
|
+
)
|
|
357
|
+
),
|
|
358
|
+
reportKey,
|
|
359
|
+
runId
|
|
360
|
+
);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
if (hasErrorCode(error, "ENOENT")) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/** readProgressArtifacts serves the server-side history projection, which
|
|
369
|
+
* validates its envelope and capture metadata separately so corrupt old
|
|
370
|
+
* provenance becomes an invalid chart point. */
|
|
371
|
+
async readProgressArtifacts(reportKey, runId) {
|
|
372
|
+
try {
|
|
373
|
+
const artifacts = JSON.parse(
|
|
374
|
+
await readFile(
|
|
375
|
+
path.join(this.#runDir(reportKey, runId), "artifacts.json"),
|
|
376
|
+
"utf8"
|
|
377
|
+
)
|
|
378
|
+
);
|
|
379
|
+
return artifacts;
|
|
380
|
+
} catch (error) {
|
|
381
|
+
if (hasErrorCode(error, "ENOENT")) {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
throw error;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
async readProgressMeasurement(reportKey, runId, configVersion) {
|
|
388
|
+
try {
|
|
389
|
+
const value = storedProgressSchema.parse(
|
|
390
|
+
JSON.parse(
|
|
391
|
+
await readFile(
|
|
392
|
+
path.join(this.#runDir(reportKey, runId), "progress.json"),
|
|
393
|
+
"utf8"
|
|
394
|
+
)
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
if (value.reportKey !== reportKey || value.configVersion !== configVersion) {
|
|
398
|
+
throw new StoreConflictError(
|
|
399
|
+
`Stored progress projection of run ${runId} belongs to another report or config.`
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
return parseProgressMeasurement(value.measurement, runId);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (hasErrorCode(error, "ENOENT")) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
async #freezeProgressMeasurement({ reportKey, runId }, { config, artifact }) {
|
|
411
|
+
const directory = this.#runDir(reportKey, runId);
|
|
412
|
+
const sourceDigest = contentHash({
|
|
413
|
+
config,
|
|
414
|
+
snapshot: artifact.snapshot,
|
|
415
|
+
captureManifest: artifact.captureManifest ?? null
|
|
416
|
+
});
|
|
417
|
+
try {
|
|
418
|
+
const existing = storedProgressSchema.parse(
|
|
419
|
+
JSON.parse(
|
|
420
|
+
await readFile(path.join(directory, "progress.json"), "utf8")
|
|
421
|
+
)
|
|
422
|
+
);
|
|
423
|
+
parseProgressMeasurement(existing.measurement, runId);
|
|
424
|
+
if (existing.reportKey !== reportKey || existing.configVersion !== artifact.configVersion || existing.sourceDigest !== sourceDigest) {
|
|
425
|
+
throw new StoreConflictError(
|
|
426
|
+
`Stored progress projection of run ${runId} has a different immutable source.`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
return;
|
|
430
|
+
} catch (error) {
|
|
431
|
+
if (!hasErrorCode(error, "ENOENT")) {
|
|
432
|
+
throw error;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
const measurement = parseProgressMeasurement(
|
|
436
|
+
projectProgressMeasurement({
|
|
437
|
+
runId,
|
|
438
|
+
config: aeoAuditConfigSchema.parse(config),
|
|
439
|
+
snapshot: aeoSnapshotSchema.parse(artifact.snapshot),
|
|
440
|
+
captureManifest: artifact.captureManifest
|
|
441
|
+
}),
|
|
442
|
+
runId
|
|
443
|
+
);
|
|
444
|
+
await writeAtomicJson(directory, "progress.json", {
|
|
445
|
+
reportKey,
|
|
446
|
+
configVersion: artifact.configVersion,
|
|
447
|
+
sourceDigest,
|
|
448
|
+
measurement
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
async readSnapshot(reportKey, runId) {
|
|
452
|
+
const filePath = path.join(
|
|
453
|
+
await this.#readableDir(reportKey, runId),
|
|
454
|
+
"snapshot.json"
|
|
455
|
+
);
|
|
456
|
+
if (!existsSync(filePath)) {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
const snapshot = aeoSnapshotSchema.parse(
|
|
460
|
+
JSON.parse(await readFile(filePath, "utf8"))
|
|
461
|
+
);
|
|
462
|
+
if (snapshot.reportKey !== reportKey) {
|
|
463
|
+
throw new Error(
|
|
464
|
+
`${filePath} belongs to report '${snapshot.reportKey}', not '${reportKey}'.`
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
return snapshot;
|
|
468
|
+
}
|
|
469
|
+
async readLabels(reportKey, runId) {
|
|
470
|
+
const filePath = path.join(
|
|
471
|
+
await this.#readableDir(reportKey, runId),
|
|
472
|
+
domainLabelsFile
|
|
473
|
+
);
|
|
474
|
+
if (!existsSync(filePath)) {
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
const labels = domainLabelsFileSchema.parse(
|
|
478
|
+
JSON.parse(await readFile(filePath, "utf8"))
|
|
479
|
+
);
|
|
480
|
+
return labels;
|
|
481
|
+
}
|
|
482
|
+
async readEvidenceChunk(reportKey, runIdOrFile, requestedFile) {
|
|
483
|
+
const file = requestedFile ?? runIdOrFile;
|
|
484
|
+
if (!/^evidence\/[a-zA-Z0-9_-]+-\d+\.json$/.test(file)) {
|
|
485
|
+
throw new Error(`Invalid evidence file provided: ${file}.`);
|
|
486
|
+
}
|
|
487
|
+
const filePath = path.join(
|
|
488
|
+
await this.#readableDir(
|
|
489
|
+
reportKey,
|
|
490
|
+
requestedFile ? runIdOrFile : void 0
|
|
491
|
+
),
|
|
492
|
+
file
|
|
493
|
+
);
|
|
494
|
+
const chunk = aeoEvidenceChunkSchema.parse(
|
|
495
|
+
JSON.parse(await readFile(filePath, "utf8"))
|
|
496
|
+
);
|
|
497
|
+
return chunk;
|
|
498
|
+
}
|
|
499
|
+
/** writeReport saves an immutable run in a private directory; publication
|
|
500
|
+
* is explicit. */
|
|
501
|
+
async writeReport(reportKey, runId, artifacts) {
|
|
502
|
+
validateReportArtifacts(artifacts, reportKey, runId);
|
|
503
|
+
if (artifacts.snapshot.reportKey !== reportKey) {
|
|
504
|
+
throw new StoreConflictError(
|
|
505
|
+
`Snapshot belongs to another report than ${reportKey}.`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
const targetDir = this.#runDir(reportKey, runId);
|
|
509
|
+
if (existsSync(targetDir)) {
|
|
510
|
+
const existing = JSON.parse(
|
|
511
|
+
await readFile(path.join(targetDir, "artifacts.json"), "utf8")
|
|
512
|
+
);
|
|
513
|
+
if (JSON.stringify(existing) !== JSON.stringify(artifacts)) {
|
|
514
|
+
throw new StoreConflictError(
|
|
515
|
+
`Run artifacts are immutable: ${reportKey}/${runId}.`
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
await mkdir(this.contentDir, { recursive: true });
|
|
521
|
+
const tempDir = await mkdtemp(path.join(this.contentDir, ".tmp-"));
|
|
522
|
+
try {
|
|
523
|
+
await mkdir(path.join(tempDir, "evidence"), { recursive: true });
|
|
524
|
+
await writeFile(
|
|
525
|
+
path.join(tempDir, "snapshot.json"),
|
|
526
|
+
`${JSON.stringify(artifacts.snapshot, null, 2)}
|
|
527
|
+
`,
|
|
528
|
+
"utf8"
|
|
529
|
+
);
|
|
530
|
+
await writeFile(
|
|
531
|
+
path.join(tempDir, domainLabelsFile),
|
|
532
|
+
`${JSON.stringify(artifacts.labels, null, 2)}
|
|
533
|
+
`,
|
|
534
|
+
"utf8"
|
|
535
|
+
);
|
|
536
|
+
for (const chunk of artifacts.chunks) {
|
|
537
|
+
await writeFile(
|
|
538
|
+
path.join(
|
|
539
|
+
tempDir,
|
|
540
|
+
evidenceChunkFileName(chunk.sectionKey, chunk.promptIdx)
|
|
541
|
+
),
|
|
542
|
+
JSON.stringify(chunk),
|
|
543
|
+
"utf8"
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
await writeFile(
|
|
547
|
+
path.join(tempDir, "artifacts.json"),
|
|
548
|
+
JSON.stringify(artifacts),
|
|
549
|
+
"utf8"
|
|
550
|
+
);
|
|
551
|
+
await mkdir(path.dirname(targetDir), { recursive: true });
|
|
552
|
+
await rename(tempDir, targetDir);
|
|
553
|
+
} catch (error) {
|
|
554
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
555
|
+
throw error;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
async publish(requested, receipt) {
|
|
559
|
+
const triple = publicationTripleSchema.parse({
|
|
560
|
+
reportKey: requested.reportKey,
|
|
561
|
+
runId: requested.runId,
|
|
562
|
+
configVersion: requested.configVersion,
|
|
563
|
+
copyVersion: requested.copyVersion
|
|
564
|
+
});
|
|
565
|
+
const { reportKey, runId, configVersion, copyVersion } = triple;
|
|
566
|
+
const directory = this.reportDir(reportKey);
|
|
567
|
+
await withFilePublicationLock(directory, async () => {
|
|
568
|
+
const previous = await readFilePublication(directory, reportKey);
|
|
569
|
+
if (previous && sameTriple(previous, triple)) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const stores = this.#publicationStores ?? {
|
|
573
|
+
...openFileVersionStores(),
|
|
574
|
+
runStore: new FileRunStore()
|
|
575
|
+
};
|
|
576
|
+
const [storedConfig, storedCopy, storedRun] = await Promise.all([
|
|
577
|
+
stores.configStore.getVersion(reportKey, configVersion),
|
|
578
|
+
stores.copyStore.getVersion(reportKey, copyVersion),
|
|
579
|
+
stores.runStore.get(runId)
|
|
580
|
+
]);
|
|
581
|
+
const storedArtifact = storedArtifactSchema.parse(
|
|
582
|
+
JSON.parse(
|
|
583
|
+
await readFile(
|
|
584
|
+
path.join(this.#runDir(reportKey, runId), "artifacts.json"),
|
|
585
|
+
"utf8"
|
|
586
|
+
)
|
|
587
|
+
)
|
|
588
|
+
);
|
|
589
|
+
const { config, artifact } = assertPublishable({
|
|
590
|
+
triple,
|
|
591
|
+
receipt,
|
|
592
|
+
priorPublication: previous?.history?.find(
|
|
593
|
+
(entry) => sameTriple(entry, triple)
|
|
594
|
+
),
|
|
595
|
+
config: storedConfig,
|
|
596
|
+
copy: storedCopy,
|
|
597
|
+
run: storedRun,
|
|
598
|
+
artifact: storedArtifact
|
|
599
|
+
});
|
|
600
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
601
|
+
await this.#freezeProgressMeasurement(triple, {
|
|
602
|
+
config: config.config,
|
|
603
|
+
artifact
|
|
604
|
+
});
|
|
605
|
+
const history = previous ? filePublicationHistory(previous, now) : [];
|
|
606
|
+
if (previous?.history === void 0) {
|
|
607
|
+
await this.#assertLegacyPublication(stores, previous);
|
|
608
|
+
}
|
|
609
|
+
if (!history.some((entry) => sameTriple(entry, triple))) {
|
|
610
|
+
history.push({
|
|
611
|
+
...triple,
|
|
612
|
+
firstPublishedAt: now,
|
|
613
|
+
recordedAt: now,
|
|
614
|
+
origin: "publication"
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
await writeFilePublication(directory, { ...receipt, history });
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
// A pointer written before history existed must still point at a valid,
|
|
621
|
+
// approved publication before its backfilled history is trusted.
|
|
622
|
+
async #assertLegacyPublication(stores, previous) {
|
|
623
|
+
if (!previous) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const { reportKey } = previous;
|
|
627
|
+
const [oldArtifact, oldConfig, oldCopy] = await Promise.all([
|
|
628
|
+
this.readArtifacts(reportKey, previous.runId),
|
|
629
|
+
stores.configStore.getVersion(reportKey, previous.configVersion),
|
|
630
|
+
stores.copyStore.getVersion(reportKey, previous.copyVersion)
|
|
631
|
+
]);
|
|
632
|
+
if (!oldArtifact?.fullScope || oldArtifact.configVersion !== previous.configVersion || oldConfig?.config.reportKey !== reportKey || oldCopy?.copy.reportKey !== reportKey || !["approved", "superseded"].includes(oldConfig.status) || !["approved", "superseded"].includes(oldCopy.status)) {
|
|
633
|
+
throw new StoreConflictError(
|
|
634
|
+
`Existing file publication of ${reportKey} cannot establish valid history.`
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
/** rewriteReport rewrites the snapshot and labels of an existing report in
|
|
639
|
+
* place. */
|
|
640
|
+
async rewriteReport(reportKey, artifacts) {
|
|
641
|
+
const dir = this.reportDir(reportKey);
|
|
642
|
+
await writeFile(
|
|
643
|
+
path.join(dir, domainLabelsFile),
|
|
644
|
+
`${JSON.stringify(artifacts.labels, null, 2)}
|
|
645
|
+
`,
|
|
646
|
+
"utf8"
|
|
647
|
+
);
|
|
648
|
+
await writeFile(
|
|
649
|
+
path.join(dir, "snapshot.json"),
|
|
650
|
+
`${JSON.stringify(artifacts.snapshot, null, 2)}
|
|
651
|
+
`,
|
|
652
|
+
"utf8"
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
async listReportKeys() {
|
|
656
|
+
if (!existsSync(this.contentDir)) {
|
|
657
|
+
return [];
|
|
658
|
+
}
|
|
659
|
+
const entries = await readdir(this.contentDir, { withFileTypes: true });
|
|
660
|
+
const reportKeys = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort();
|
|
661
|
+
return reportKeys;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
var isRunRecordLine = (row) => {
|
|
665
|
+
return typeof row === "object" && row !== null && "runId" in row && typeof row.runId === "string";
|
|
666
|
+
};
|
|
667
|
+
var FileRunStore = class {
|
|
668
|
+
#file;
|
|
669
|
+
constructor(dir = aeoCheckpointDir) {
|
|
670
|
+
this.#file = new JsonlFile(path.join(dir, "runs.jsonl"));
|
|
671
|
+
}
|
|
672
|
+
async start(record) {
|
|
673
|
+
await serializeRunFile(this.#file.filePath, async () => {
|
|
674
|
+
if (!await this.get(record.runId)) {
|
|
675
|
+
await this.#file.append(JSON.stringify(record));
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
async claim(runId, claim) {
|
|
680
|
+
return serializeRunFile(this.#file.filePath, async () => {
|
|
681
|
+
const result = evaluateRunClaim(await this.get(runId), claim);
|
|
682
|
+
if (result.status === "claimed") {
|
|
683
|
+
await this.#file.append(JSON.stringify(result.record));
|
|
684
|
+
}
|
|
685
|
+
return result;
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
async reconcile(runId, outcome, claim) {
|
|
689
|
+
return serializeRunFile(this.#file.filePath, async () => {
|
|
690
|
+
const record = await this.get(runId);
|
|
691
|
+
if (!record || isTerminalRun(record) || record.batchJobId !== claim.batchJobId || record.batchAttempt !== claim.attempt) {
|
|
692
|
+
return false;
|
|
693
|
+
}
|
|
694
|
+
await this.#file.append(JSON.stringify({ ...record, ...outcome }));
|
|
695
|
+
return true;
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
async finish(runId, outcome) {
|
|
699
|
+
await serializeRunFile(this.#file.filePath, async () => {
|
|
700
|
+
const existing = await this.get(runId);
|
|
701
|
+
if (!existing) {
|
|
702
|
+
throw new Error(`Unknown run: ${runId}.`);
|
|
703
|
+
}
|
|
704
|
+
if (isTerminalRun(existing)) {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
await this.#file.append(JSON.stringify({ ...existing, ...outcome }));
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
async get(runId) {
|
|
711
|
+
let found = null;
|
|
712
|
+
for (const row of await readJsonl(this.#file.filePath)) {
|
|
713
|
+
if (isRunRecordLine(row) && row.runId === runId) {
|
|
714
|
+
found = row;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
return found;
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
var openFileStores = async (reportKey, opts = {}) => {
|
|
721
|
+
const stores = {
|
|
722
|
+
probeStore: await FileProbeStore.open(reportKey, {
|
|
723
|
+
dir: opts.checkpointDir
|
|
724
|
+
}),
|
|
725
|
+
analysisStore: await FileAnalysisStore.open(reportKey, {
|
|
726
|
+
dir: opts.checkpointDir
|
|
727
|
+
}),
|
|
728
|
+
reportStore: new FileReportStore(opts.contentDir),
|
|
729
|
+
runStore: new FileRunStore(opts.checkpointDir)
|
|
730
|
+
};
|
|
731
|
+
return stores;
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
export {
|
|
735
|
+
FileProbeStore,
|
|
736
|
+
analysisCheckpointPath,
|
|
737
|
+
FileAnalysisStore,
|
|
738
|
+
FileReportStore,
|
|
739
|
+
FileRunStore,
|
|
740
|
+
openFileStores
|
|
741
|
+
};
|