literally-aeo 0.0.0-stage → 0.1.1
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-2GY42RIJ.js +33 -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-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-3DG7GHFA.js +297 -0
- package/dist/lib/chunks/chunk-3EBWDHPK.js +133 -0
- package/dist/lib/chunks/chunk-3KQFLOC7.js +188 -0
- package/dist/lib/chunks/chunk-3UFZ2XPE.js +73 -0
- package/dist/lib/chunks/chunk-47IZBMP2.js +115 -0
- package/dist/lib/chunks/chunk-4E4NDGOZ.js +47 -0
- package/dist/lib/chunks/chunk-4QQJXCD2.js +113 -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-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-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-AP5DLF36.js +150 -0
- package/dist/lib/chunks/chunk-AUB5THIS.js +341 -0
- package/dist/lib/chunks/chunk-B5L2KMTU.js +108 -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-CKUTDJAB.js +213 -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-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-E3OEE5XN.js +202 -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-FNDJUELJ.js +253 -0
- package/dist/lib/chunks/chunk-FPAN3VRW.js +350 -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-GMKF2FU4.js +104 -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-H56DDRKE.js +85 -0
- package/dist/lib/chunks/chunk-HFOYASRQ.js +99 -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-I3TMFPK4.js +229 -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-JQ3P552S.js +0 -0
- package/dist/lib/chunks/chunk-JS3GBU3R.js +46 -0
- package/dist/lib/chunks/chunk-KHU5DRBE.js +343 -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-LPND3VNQ.js +812 -0
- package/dist/lib/chunks/chunk-MD4AVTK2.js +257 -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-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-NVBMIPXR.js +259 -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-OORO55OM.js +922 -0
- package/dist/lib/chunks/chunk-OQVIRYT5.js +147 -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-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-POUSX3T4.js +64 -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-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-SWS3K62X.js +93 -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-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-XL4JIQ5X.js +316 -0
- package/dist/lib/chunks/chunk-XNRSHATN.js +303 -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-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-ZBDUE3A5.js +136 -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-ZXGATMMH.js +101 -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,812 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultBatchSize,
|
|
3
|
+
isStageFresh,
|
|
4
|
+
partition,
|
|
5
|
+
runStage,
|
|
6
|
+
stageInputsDigest
|
|
7
|
+
} from "./chunk-56VOFZ7T.js";
|
|
8
|
+
import {
|
|
9
|
+
copyEditHistory,
|
|
10
|
+
editCopyDraft,
|
|
11
|
+
readCopyEdits
|
|
12
|
+
} from "./chunk-CJ5YD3CU.js";
|
|
13
|
+
import {
|
|
14
|
+
CopyVerificationUnavailableError
|
|
15
|
+
} from "./chunk-KZR25REO.js";
|
|
16
|
+
import {
|
|
17
|
+
readStoredReview,
|
|
18
|
+
reportQuality
|
|
19
|
+
} from "./chunk-NCLFZOZU.js";
|
|
20
|
+
import {
|
|
21
|
+
finishRun,
|
|
22
|
+
writeFinished
|
|
23
|
+
} from "./chunk-KRFHQQS7.js";
|
|
24
|
+
import {
|
|
25
|
+
copywriterFiles,
|
|
26
|
+
materializeCopyInputs,
|
|
27
|
+
readSnapshot,
|
|
28
|
+
validateCopyDraft
|
|
29
|
+
} from "./chunk-3EBWDHPK.js";
|
|
30
|
+
import {
|
|
31
|
+
hostModels
|
|
32
|
+
} from "./chunk-OYKV5NDM.js";
|
|
33
|
+
import {
|
|
34
|
+
stableBatchLayout
|
|
35
|
+
} from "./chunk-SBQ4TWGJ.js";
|
|
36
|
+
import {
|
|
37
|
+
aggregateWorkdir
|
|
38
|
+
} from "./chunk-J46W3EMQ.js";
|
|
39
|
+
import {
|
|
40
|
+
validateStage
|
|
41
|
+
} from "./chunk-AUB5THIS.js";
|
|
42
|
+
import {
|
|
43
|
+
materializeWorkdir
|
|
44
|
+
} from "./chunk-CPT2GKKW.js";
|
|
45
|
+
import {
|
|
46
|
+
acquireWriterLock
|
|
47
|
+
} from "./chunk-KMRQSIZW.js";
|
|
48
|
+
import {
|
|
49
|
+
codexModel
|
|
50
|
+
} from "./chunk-MIF5IYNR.js";
|
|
51
|
+
import {
|
|
52
|
+
writePendingJson
|
|
53
|
+
} from "./chunk-MX6Y4RD2.js";
|
|
54
|
+
import {
|
|
55
|
+
writeRunInputs
|
|
56
|
+
} from "./chunk-2NJEWPCV.js";
|
|
57
|
+
import {
|
|
58
|
+
openRecorder,
|
|
59
|
+
recordingAccounting
|
|
60
|
+
} from "./chunk-XL4JIQ5X.js";
|
|
61
|
+
import {
|
|
62
|
+
RunOrigin,
|
|
63
|
+
measurementDigest
|
|
64
|
+
} from "./chunk-I3TMFPK4.js";
|
|
65
|
+
import {
|
|
66
|
+
capturePlan
|
|
67
|
+
} from "./chunk-YHS5IEVZ.js";
|
|
68
|
+
import {
|
|
69
|
+
verdictSchemaFor
|
|
70
|
+
} from "./chunk-5VNYUCLL.js";
|
|
71
|
+
import {
|
|
72
|
+
classifyVerifierFailure
|
|
73
|
+
} from "./chunk-FBFZBLTY.js";
|
|
74
|
+
import {
|
|
75
|
+
isObject
|
|
76
|
+
} from "./chunk-7PLK6VGC.js";
|
|
77
|
+
import {
|
|
78
|
+
structuredFailureDiagnostic
|
|
79
|
+
} from "./chunk-NANJGMEJ.js";
|
|
80
|
+
import {
|
|
81
|
+
ModelBudgetError
|
|
82
|
+
} from "./chunk-TNL2GWYR.js";
|
|
83
|
+
import {
|
|
84
|
+
aeoSnapshotSchema,
|
|
85
|
+
maxReviewRounds
|
|
86
|
+
} from "./chunk-SDWYZM64.js";
|
|
87
|
+
import {
|
|
88
|
+
GroundingIntegrityError
|
|
89
|
+
} from "./chunk-ZYSPTOKK.js";
|
|
90
|
+
import {
|
|
91
|
+
contentHash
|
|
92
|
+
} from "./chunk-H2KDLDK6.js";
|
|
93
|
+
import {
|
|
94
|
+
aeoReportCopySchema
|
|
95
|
+
} from "./chunk-PKB6JRJM.js";
|
|
96
|
+
|
|
97
|
+
// src/codex-workflow/loop.ts
|
|
98
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
99
|
+
import path from "node:path";
|
|
100
|
+
import { z } from "zod";
|
|
101
|
+
var defaultMaxPasses = maxReviewRounds;
|
|
102
|
+
var hostModelsOf = (ctx) => {
|
|
103
|
+
if (ctx.internalModels) {
|
|
104
|
+
return ctx.internalModels;
|
|
105
|
+
}
|
|
106
|
+
const models = hostModels();
|
|
107
|
+
return ctx.recorder ? {
|
|
108
|
+
...models,
|
|
109
|
+
accounting: recordingAccounting(models.accounting, ctx.recorder)
|
|
110
|
+
} : models;
|
|
111
|
+
};
|
|
112
|
+
var copyInputsOf = (source, extra = {}) => {
|
|
113
|
+
return {
|
|
114
|
+
config: source.config,
|
|
115
|
+
runId: source.request.runId,
|
|
116
|
+
configVersion: source.request.configVersion,
|
|
117
|
+
grounding: source.grounding,
|
|
118
|
+
verifierRole: source.request.modelProfile?.roles.premiseVerifier,
|
|
119
|
+
...extra
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
var copyPayloadSchema = z.looseObject({
|
|
123
|
+
copy: aeoReportCopySchema,
|
|
124
|
+
provenance: z.unknown().optional(),
|
|
125
|
+
receipt: z.unknown().optional(),
|
|
126
|
+
confidence: z.number(),
|
|
127
|
+
outcome: z.string(),
|
|
128
|
+
draft: z.unknown().optional(),
|
|
129
|
+
quality: aeoSnapshotSchema.shape.meta.shape.quality
|
|
130
|
+
});
|
|
131
|
+
var prepareWorkdir = async (source, dir, options = {}) => {
|
|
132
|
+
if (options.held) {
|
|
133
|
+
return prepareLockedWorkdir(source, dir, {
|
|
134
|
+
...options,
|
|
135
|
+
writer: options.held.writer
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
await mkdir(dir, { recursive: true });
|
|
139
|
+
const writer = await acquireWriterLock(dir, "codex workflow");
|
|
140
|
+
try {
|
|
141
|
+
return await prepareLockedWorkdir(source, dir, {
|
|
142
|
+
...options,
|
|
143
|
+
writer
|
|
144
|
+
});
|
|
145
|
+
} catch (err) {
|
|
146
|
+
await writer.release();
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var prepareLockedWorkdir = async (source, dir, options) => {
|
|
151
|
+
const { writer } = options;
|
|
152
|
+
const answers = await materializeWorkdir({
|
|
153
|
+
dir,
|
|
154
|
+
config: source.config,
|
|
155
|
+
captured: source.captured,
|
|
156
|
+
copyRules: (await copywriterFiles())["RULES.md"] ?? ""
|
|
157
|
+
});
|
|
158
|
+
await writeRunInputs(dir, source);
|
|
159
|
+
const recorder = options.held?.recorder ?? await openRecorder(dir, {
|
|
160
|
+
origin: options.origin ?? RunOrigin.LOCAL,
|
|
161
|
+
runId: source.request.runId,
|
|
162
|
+
measurementDigest: measurementDigest({
|
|
163
|
+
config: source.config,
|
|
164
|
+
surfaces: source.surfaces,
|
|
165
|
+
sections: source.request.sections ?? null
|
|
166
|
+
}),
|
|
167
|
+
planDigest: capturePlan(
|
|
168
|
+
source.config,
|
|
169
|
+
source.surfaces,
|
|
170
|
+
source.request.sections
|
|
171
|
+
).digest,
|
|
172
|
+
...writer.takenOver && { takenOver: writer.takenOver }
|
|
173
|
+
});
|
|
174
|
+
const internalModels = options.held ? options.internalModels : options.internalModels && {
|
|
175
|
+
...options.internalModels,
|
|
176
|
+
accounting: recordingAccounting(
|
|
177
|
+
options.internalModels.accounting,
|
|
178
|
+
recorder
|
|
179
|
+
)
|
|
180
|
+
};
|
|
181
|
+
const log = options.log ?? ((line) => {
|
|
182
|
+
console.log(line);
|
|
183
|
+
});
|
|
184
|
+
log(
|
|
185
|
+
`${source.reportKey} ${source.id}: ${answers.length} captured answers in ${dir}`
|
|
186
|
+
);
|
|
187
|
+
return {
|
|
188
|
+
dir,
|
|
189
|
+
brand: source.config.brand,
|
|
190
|
+
answers,
|
|
191
|
+
allAnswers: answers,
|
|
192
|
+
batchLayout: await stableBatchLayout(dir, {
|
|
193
|
+
config: source.config,
|
|
194
|
+
files: partition(answers).flatMap(
|
|
195
|
+
(batch) => batch.files.map((answer) => answer.file)
|
|
196
|
+
),
|
|
197
|
+
size: defaultBatchSize
|
|
198
|
+
}),
|
|
199
|
+
sections: source.config.sections.map((section) => section.key),
|
|
200
|
+
ownedDomains: source.config.competitorQualification?.ownedDomains,
|
|
201
|
+
source,
|
|
202
|
+
secrets: options.secrets ?? [],
|
|
203
|
+
internalModels,
|
|
204
|
+
recorder,
|
|
205
|
+
releaseWriter: writer.release,
|
|
206
|
+
signal: options.signal,
|
|
207
|
+
log,
|
|
208
|
+
aggregate: {
|
|
209
|
+
dir,
|
|
210
|
+
config: source.config,
|
|
211
|
+
surfaces: source.surfaces,
|
|
212
|
+
capture: source.capture,
|
|
213
|
+
captured: source.captured
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
var savedVerifierMemorySchema = z.object({
|
|
218
|
+
scope: z.string(),
|
|
219
|
+
history: z.record(
|
|
220
|
+
z.string(),
|
|
221
|
+
z.array(
|
|
222
|
+
z.object({
|
|
223
|
+
text: z.string(),
|
|
224
|
+
review: verdictSchemaFor([], []).shape.reviews.element
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
)
|
|
228
|
+
}).nullable();
|
|
229
|
+
var withCopy = async (ctx, inputs) => {
|
|
230
|
+
const snapshot = await readSnapshot(ctx.dir);
|
|
231
|
+
await materializeCopyInputs({
|
|
232
|
+
dir: ctx.dir,
|
|
233
|
+
config: inputs.config,
|
|
234
|
+
snapshot,
|
|
235
|
+
runId: inputs.runId,
|
|
236
|
+
grounding: inputs.grounding,
|
|
237
|
+
previous: inputs.previous,
|
|
238
|
+
notes: inputs.notes
|
|
239
|
+
});
|
|
240
|
+
const internalModels = hostModelsOf(ctx);
|
|
241
|
+
const memoryFile = path.join(ctx.dir, "PENDING", "verifier-history.json");
|
|
242
|
+
const memoryScope = contentHash({
|
|
243
|
+
config: inputs.config,
|
|
244
|
+
runId: inputs.runId,
|
|
245
|
+
snapshot,
|
|
246
|
+
grounding: inputs.grounding,
|
|
247
|
+
role: inputs.verifierRole
|
|
248
|
+
});
|
|
249
|
+
const verifierMemory = {
|
|
250
|
+
read: async () => {
|
|
251
|
+
const raw = await readFile(memoryFile, "utf8").catch(() => "null");
|
|
252
|
+
const saved = savedVerifierMemorySchema.parse(JSON.parse(raw));
|
|
253
|
+
return saved?.scope === memoryScope ? saved.history : {};
|
|
254
|
+
},
|
|
255
|
+
write: async (history) => {
|
|
256
|
+
await writePendingJson(memoryFile, { scope: memoryScope, history });
|
|
257
|
+
await ctx.checkpoint?.(["PENDING/verifier-history.json"]);
|
|
258
|
+
},
|
|
259
|
+
edits: async () => copyEditHistory(await readCopyEdits(ctx.dir, memoryScope))
|
|
260
|
+
};
|
|
261
|
+
const validation = {
|
|
262
|
+
config: inputs.config,
|
|
263
|
+
snapshot,
|
|
264
|
+
runId: inputs.runId,
|
|
265
|
+
configVersion: inputs.configVersion,
|
|
266
|
+
grounding: inputs.grounding,
|
|
267
|
+
secrets: ctx.secrets,
|
|
268
|
+
verifierRole: inputs.verifierRole ?? internalModels.profile.roles.premiseVerifier,
|
|
269
|
+
previous: inputs.previous,
|
|
270
|
+
brandLogo: inputs.brandLogo,
|
|
271
|
+
accounting: internalModels.accounting,
|
|
272
|
+
signal: ctx.signal
|
|
273
|
+
};
|
|
274
|
+
const review = async (draft) => {
|
|
275
|
+
const shape = validateStage(
|
|
276
|
+
{ brand: ctx.brand, answers: [], sections: ctx.sections, coverage: true },
|
|
277
|
+
"write",
|
|
278
|
+
draft
|
|
279
|
+
);
|
|
280
|
+
return shape.errors.length ? {
|
|
281
|
+
valid: false,
|
|
282
|
+
outcome: "invalid_copy",
|
|
283
|
+
errors: shape.errors.map((message) => ({
|
|
284
|
+
path: "draft",
|
|
285
|
+
code: "schema_invalid",
|
|
286
|
+
message
|
|
287
|
+
}))
|
|
288
|
+
} : validateCopyDraft({ ...validation, draft, verifierMemory });
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
...ctx,
|
|
292
|
+
validateCopy: async (initialDraft, { round = 1, previousFindings, reviewed } = {}) => {
|
|
293
|
+
const requestedNotes = round === 1 ? (inputs.notes ?? []).map((note) => `Requested edit: ${note}`) : [];
|
|
294
|
+
let draft = initialDraft;
|
|
295
|
+
let result = previousFindings?.length || requestedNotes.length ? null : await review(draft);
|
|
296
|
+
const findings = previousFindings?.length ? [...previousFindings] : [
|
|
297
|
+
...(result?.errors ?? []).map(
|
|
298
|
+
(error) => `${error.path}: ${error.message} (${error.code})`
|
|
299
|
+
),
|
|
300
|
+
...requestedNotes
|
|
301
|
+
];
|
|
302
|
+
let editedDraft;
|
|
303
|
+
if (!result || result.outcome === "invalid_copy") {
|
|
304
|
+
if (result) {
|
|
305
|
+
await reviewed?.(findings);
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
editedDraft = await editCopyDraft({
|
|
309
|
+
dir: ctx.dir,
|
|
310
|
+
scope: memoryScope,
|
|
311
|
+
round,
|
|
312
|
+
draft,
|
|
313
|
+
errors: findings,
|
|
314
|
+
validation,
|
|
315
|
+
reviewHistory: await verifierMemory.read(),
|
|
316
|
+
checkpoint: ctx.checkpoint
|
|
317
|
+
});
|
|
318
|
+
result = await review(editedDraft);
|
|
319
|
+
draft = editedDraft;
|
|
320
|
+
} catch (error) {
|
|
321
|
+
const outcome = classifyVerifierFailure(error, ctx.signal);
|
|
322
|
+
ctx.log?.(
|
|
323
|
+
`copy verifier edit/recheck unavailable: ${outcome}; ${JSON.stringify(structuredFailureDiagnostic(error, ctx.signal))}`
|
|
324
|
+
);
|
|
325
|
+
return {
|
|
326
|
+
ok: false,
|
|
327
|
+
fixable: false,
|
|
328
|
+
outcome,
|
|
329
|
+
errors: [
|
|
330
|
+
"The verifier could not complete its edit and recheck; its saved work is retained"
|
|
331
|
+
]
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (result.valid) {
|
|
336
|
+
return {
|
|
337
|
+
ok: true,
|
|
338
|
+
fixable: false,
|
|
339
|
+
errors: [],
|
|
340
|
+
editedDraft,
|
|
341
|
+
payload: {
|
|
342
|
+
copy: result.copy,
|
|
343
|
+
provenance: result.provenance,
|
|
344
|
+
receipt: result.receipt,
|
|
345
|
+
confidence: isObject(draft) ? draft.confidence : void 0,
|
|
346
|
+
outcome: result.outcome
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
ok: false,
|
|
352
|
+
outcome: result.outcome,
|
|
353
|
+
fixable: result.outcome === "invalid_copy",
|
|
354
|
+
editedDraft,
|
|
355
|
+
errors: result.errors.map(
|
|
356
|
+
(error) => `${error.path}: ${error.message} (${error.code})`
|
|
357
|
+
)
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
var finish = async (ctx, { degraded, write, ground, quality }) => {
|
|
363
|
+
const result = await finishRun({
|
|
364
|
+
source: ctx.source,
|
|
365
|
+
dir: ctx.dir,
|
|
366
|
+
degraded,
|
|
367
|
+
write,
|
|
368
|
+
ground,
|
|
369
|
+
internalModels: hostModelsOf(ctx),
|
|
370
|
+
signal: ctx.signal,
|
|
371
|
+
quality
|
|
372
|
+
});
|
|
373
|
+
ctx.source.grounding = result.grounding;
|
|
374
|
+
await ctx.checkpoint?.();
|
|
375
|
+
const labels = Object.entries(result.labelStats).map(([key, value]) => `${key} ${value}`).join(", ");
|
|
376
|
+
ctx.log(
|
|
377
|
+
`finish: snapshot ${path.relative(process.cwd(), result.snapshotFile)}, ${result.partialFailures.length} partial failure(s), labels ${labels}; store ${result.written}${result.writeMessage ? ` (${result.writeMessage})` : ""}`
|
|
378
|
+
);
|
|
379
|
+
return result;
|
|
380
|
+
};
|
|
381
|
+
var aggregate = async (ctx) => {
|
|
382
|
+
const output = await aggregateWorkdir(ctx.aggregate);
|
|
383
|
+
for (const [key, result] of Object.entries(output.sections)) {
|
|
384
|
+
const { summary, matrix } = result.visibility;
|
|
385
|
+
ctx.log(
|
|
386
|
+
`aggregate ${key}: ${matrix.length} rows, sov ${summary.prospectShareOfVoice ?? "n/a"} chat / ${summary.agentShareOfVoice ?? "n/a"} agent, top competitor ${summary.topCompetitorDomain ?? "none"}`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
var runVerdict = (run, reused) => {
|
|
391
|
+
if (reused) {
|
|
392
|
+
return "reused";
|
|
393
|
+
}
|
|
394
|
+
return run.ok ? "ok" : "FAILED";
|
|
395
|
+
};
|
|
396
|
+
var report = (ctx, run, { reused = false } = {}) => {
|
|
397
|
+
const verdict = runVerdict(run, reused);
|
|
398
|
+
const usage = run.usage ? ` ${run.usage.inputTokens} in / ${run.usage.outputTokens} out` : "";
|
|
399
|
+
ctx.log(
|
|
400
|
+
`${verdict.padEnd(7)} ${run.stage} (${Math.round(run.durationMs / 1e3)}s${usage}) ${JSON.stringify(run.summary)}`
|
|
401
|
+
);
|
|
402
|
+
for (const error of run.errors) {
|
|
403
|
+
ctx.log(` ${error.slice(0, 300)}`);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
var workflowStateSchema = z.looseObject({
|
|
407
|
+
stages: z.array(z.record(z.string(), z.unknown())).optional()
|
|
408
|
+
});
|
|
409
|
+
var writeState = async (dir, run) => {
|
|
410
|
+
const file = path.join(dir, "STATE.json");
|
|
411
|
+
const raw = await readFile(file, "utf8").catch(() => "{}") || "{}";
|
|
412
|
+
const state = workflowStateSchema.parse(JSON.parse(raw));
|
|
413
|
+
state.stages = [
|
|
414
|
+
...state.stages ?? [],
|
|
415
|
+
{ ...run, at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
416
|
+
];
|
|
417
|
+
await writeFile(file, JSON.stringify(state, null, 2));
|
|
418
|
+
};
|
|
419
|
+
var recordedRunSchema = z.looseObject({
|
|
420
|
+
degraded: z.array(z.string()).optional(),
|
|
421
|
+
summary: z.record(z.string(), z.unknown()).optional()
|
|
422
|
+
}).nullable();
|
|
423
|
+
var runOne = async (ctx, stage, { force, pass }) => {
|
|
424
|
+
if (!force && await isStageFresh(ctx, stage)) {
|
|
425
|
+
const raw = await readFile(
|
|
426
|
+
path.join(ctx.dir, "OUT", `${stage}.result.json`),
|
|
427
|
+
"utf8"
|
|
428
|
+
).catch(() => "null");
|
|
429
|
+
const previous = recordedRunSchema.parse(JSON.parse(raw));
|
|
430
|
+
const run2 = {
|
|
431
|
+
stage,
|
|
432
|
+
model: codexModel.model,
|
|
433
|
+
ok: true,
|
|
434
|
+
durationMs: 0,
|
|
435
|
+
usage: null,
|
|
436
|
+
errors: [],
|
|
437
|
+
degraded: previous?.degraded ?? [],
|
|
438
|
+
summary: { ...previous?.summary, reused: true }
|
|
439
|
+
};
|
|
440
|
+
report(ctx, run2, { reused: true });
|
|
441
|
+
return run2;
|
|
442
|
+
}
|
|
443
|
+
const run = await runStage(ctx, stage, { pass, force });
|
|
444
|
+
report(ctx, run);
|
|
445
|
+
await writeState(ctx.dir, run);
|
|
446
|
+
return run;
|
|
447
|
+
};
|
|
448
|
+
var deliverableCopy = async (ctx, inputs, written) => {
|
|
449
|
+
if (written.ok) {
|
|
450
|
+
const raw = await readFile(path.join(ctx.dir, "OUT", "write.json"), "utf8");
|
|
451
|
+
return copyPayloadSchema.parse(JSON.parse(raw));
|
|
452
|
+
}
|
|
453
|
+
const draft = {
|
|
454
|
+
intro: [{ kind: "fact", factId: "aggregate:captured" }],
|
|
455
|
+
sections: Object.fromEntries(
|
|
456
|
+
inputs.config.sections.map((section) => [section.key, { subtitle: [] }])
|
|
457
|
+
),
|
|
458
|
+
confidence: 1
|
|
459
|
+
};
|
|
460
|
+
const validated = await validateCopyDraft({
|
|
461
|
+
...inputs,
|
|
462
|
+
draft,
|
|
463
|
+
snapshot: await readSnapshot(ctx.dir),
|
|
464
|
+
secrets: ctx.secrets,
|
|
465
|
+
accounting: ctx.internalModels?.accounting
|
|
466
|
+
});
|
|
467
|
+
if (!validated.valid || !validated.copy || !validated.provenance || !validated.receipt) {
|
|
468
|
+
throw new Error(
|
|
469
|
+
`Frozen report facts did not validate: ${validated.errors.map((error) => error.code).join(", ")}.`
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
const quality = {
|
|
473
|
+
needsImprovement: true,
|
|
474
|
+
reviewRounds: Math.min(
|
|
475
|
+
Number(written.summary.attempts ?? defaultMaxPasses),
|
|
476
|
+
defaultMaxPasses
|
|
477
|
+
),
|
|
478
|
+
issues: [
|
|
479
|
+
{
|
|
480
|
+
stage: "write",
|
|
481
|
+
code: "narrative_needs_improvement",
|
|
482
|
+
message: "The report uses verified measurement facts while its narrative needs improvement."
|
|
483
|
+
},
|
|
484
|
+
...written.errors.map((message) => ({
|
|
485
|
+
stage: "write",
|
|
486
|
+
code: "copy_review",
|
|
487
|
+
message
|
|
488
|
+
}))
|
|
489
|
+
]
|
|
490
|
+
};
|
|
491
|
+
const payload = {
|
|
492
|
+
copy: validated.copy,
|
|
493
|
+
provenance: validated.provenance,
|
|
494
|
+
receipt: validated.receipt,
|
|
495
|
+
outcome: validated.outcome,
|
|
496
|
+
confidence: 1,
|
|
497
|
+
draft,
|
|
498
|
+
quality
|
|
499
|
+
};
|
|
500
|
+
await writeFile(
|
|
501
|
+
path.join(ctx.dir, "OUT", "write.json"),
|
|
502
|
+
JSON.stringify(payload, null, 2)
|
|
503
|
+
);
|
|
504
|
+
await writeFile(
|
|
505
|
+
path.join(ctx.dir, "OUT", "write.inputs.sha"),
|
|
506
|
+
await stageInputsDigest(ctx, "write")
|
|
507
|
+
);
|
|
508
|
+
await ctx.checkpoint?.();
|
|
509
|
+
ctx.log(
|
|
510
|
+
"copy: delivering verified report facts; narrative improvement notes retained"
|
|
511
|
+
);
|
|
512
|
+
return payload;
|
|
513
|
+
};
|
|
514
|
+
var shipWithoutVerifier = /* @__PURE__ */ new Set([
|
|
515
|
+
"invalid_review",
|
|
516
|
+
"verifier_unavailable"
|
|
517
|
+
]);
|
|
518
|
+
var writeReportCopy = async (ctx, inputs, { force }) => {
|
|
519
|
+
let run;
|
|
520
|
+
try {
|
|
521
|
+
run = await runOne(ctx, "write", { force });
|
|
522
|
+
} catch (error) {
|
|
523
|
+
if (!(error instanceof CopyVerificationUnavailableError) || !shipWithoutVerifier.has(error.outcome) || ctx.signal?.aborted) {
|
|
524
|
+
throw error;
|
|
525
|
+
}
|
|
526
|
+
ctx.log(
|
|
527
|
+
`copy verifier stayed ${error.outcome} after its tries; delivering the verified facts without the narrative`
|
|
528
|
+
);
|
|
529
|
+
run = {
|
|
530
|
+
stage: "write",
|
|
531
|
+
model: codexModel.model,
|
|
532
|
+
ok: false,
|
|
533
|
+
durationMs: 0,
|
|
534
|
+
usage: null,
|
|
535
|
+
errors: error.errors.map(
|
|
536
|
+
(message) => `verifier ${error.outcome}: ${message}`
|
|
537
|
+
),
|
|
538
|
+
degraded: [],
|
|
539
|
+
summary: { attempts: defaultMaxPasses, verifier: error.outcome }
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
return { run, copy: await deliverableCopy(ctx, inputs, run) };
|
|
543
|
+
};
|
|
544
|
+
var withoutAnswers = (ctx, files) => {
|
|
545
|
+
const gone = new Set(files);
|
|
546
|
+
return {
|
|
547
|
+
...ctx,
|
|
548
|
+
answers: ctx.answers.filter((answer) => !gone.has(answer.file))
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
var correctionTrailSchema = z.array(
|
|
552
|
+
z.looseObject({ outcome: z.string().optional() })
|
|
553
|
+
);
|
|
554
|
+
var Scorecard = class {
|
|
555
|
+
#ctx;
|
|
556
|
+
#startedAt;
|
|
557
|
+
#runs;
|
|
558
|
+
#stages;
|
|
559
|
+
#finish;
|
|
560
|
+
#copyOutcome;
|
|
561
|
+
constructor(ctx) {
|
|
562
|
+
this.#ctx = ctx;
|
|
563
|
+
this.#startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
564
|
+
this.#runs = [];
|
|
565
|
+
this.#stages = [];
|
|
566
|
+
this.#finish = null;
|
|
567
|
+
this.#copyOutcome = "skipped";
|
|
568
|
+
}
|
|
569
|
+
finished(partialFailures, store) {
|
|
570
|
+
this.#finish = { partialFailures, store };
|
|
571
|
+
}
|
|
572
|
+
copy(outcome) {
|
|
573
|
+
this.#copyOutcome = outcome;
|
|
574
|
+
}
|
|
575
|
+
stage(run, pass) {
|
|
576
|
+
this.#runs.push(run);
|
|
577
|
+
this.#stages.push({
|
|
578
|
+
stage: run.stage,
|
|
579
|
+
...pass ? { pass } : {},
|
|
580
|
+
ok: run.ok,
|
|
581
|
+
durationMs: run.durationMs,
|
|
582
|
+
usage: run.usage,
|
|
583
|
+
...run.summary,
|
|
584
|
+
...run.degraded.length ? { degradedFiles: run.degraded } : {},
|
|
585
|
+
...run.errors.length ? { errors: run.errors.map((error) => error.slice(0, 300)) } : {}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
async write(verdict) {
|
|
589
|
+
const { dir } = this.#ctx;
|
|
590
|
+
const review = await readStoredReview(dir);
|
|
591
|
+
const trailText = await readFile(path.join(dir, "OUT", "corrections.json"), "utf8").catch(
|
|
592
|
+
() => "[]"
|
|
593
|
+
) || "[]";
|
|
594
|
+
const trail = correctionTrailSchema.parse(JSON.parse(trailText));
|
|
595
|
+
const runs = this.#runs;
|
|
596
|
+
const total = (key) => {
|
|
597
|
+
return runs.reduce((sum, run) => sum + (run.usage?.[key] ?? 0), 0);
|
|
598
|
+
};
|
|
599
|
+
const card = {
|
|
600
|
+
version: 1,
|
|
601
|
+
startedAt: this.#startedAt,
|
|
602
|
+
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
603
|
+
model: codexModel.model,
|
|
604
|
+
answers: this.#ctx.answers.length,
|
|
605
|
+
verdict,
|
|
606
|
+
stages: this.#stages,
|
|
607
|
+
corrections: {
|
|
608
|
+
applied: trail.filter((entry) => entry.outcome === "applied").length,
|
|
609
|
+
refused: trail.filter((entry) => entry.outcome?.startsWith("refused")).length
|
|
610
|
+
},
|
|
611
|
+
reviewPasses: runs.filter((run) => run.stage === "review").length,
|
|
612
|
+
failedCriteria: (review?.criteria ?? []).filter((criterion) => criterion.outcome === "fail").map((criterion) => criterion.criterionId),
|
|
613
|
+
unresolved: review?.unresolved.length ?? 0,
|
|
614
|
+
finish: this.#finish,
|
|
615
|
+
copy: this.#copyOutcome,
|
|
616
|
+
degraded: runs.flatMap((run) => run.degraded),
|
|
617
|
+
durationMs: runs.reduce((sum, run) => sum + run.durationMs, 0),
|
|
618
|
+
usage: {
|
|
619
|
+
inputTokens: total("inputTokens"),
|
|
620
|
+
outputTokens: total("outputTokens")
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
await writeFile(
|
|
624
|
+
path.join(dir, "SCORECARD.json"),
|
|
625
|
+
JSON.stringify(card, null, 2)
|
|
626
|
+
);
|
|
627
|
+
this.#ctx.log(
|
|
628
|
+
`scorecard: ${verdict}, ${card.reviewPasses} pass(es), ${card.corrections.applied} corrections (${card.corrections.refused} refused), ${card.unresolved} unresolved, ${card.degraded.length} degraded, ${Math.round(card.durationMs / 6e4)} min, ${Math.round(card.usage.inputTokens / 1e3)}k in / ${Math.round(card.usage.outputTokens / 1e3)}k out`
|
|
629
|
+
);
|
|
630
|
+
return card;
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
var reviewProgressSchema = z.object({ rounds: z.number(), digest: z.string(), accepted: z.boolean() }).nullable();
|
|
634
|
+
var runWorkflow = async (prepared, options = {}) => {
|
|
635
|
+
try {
|
|
636
|
+
return await runWorkflowSteps(prepared, options);
|
|
637
|
+
} catch (err) {
|
|
638
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
639
|
+
try {
|
|
640
|
+
await prepared.recorder?.record(
|
|
641
|
+
prepared.signal?.aborted ? "run_interrupted" : "run_failed",
|
|
642
|
+
{
|
|
643
|
+
error: err instanceof Error ? err.name : typeof err,
|
|
644
|
+
// Bounded: the message names what broke, not a dump of state.
|
|
645
|
+
reason: reason.slice(0, 500)
|
|
646
|
+
}
|
|
647
|
+
);
|
|
648
|
+
} catch (recordError) {
|
|
649
|
+
prepared.log(
|
|
650
|
+
`run journal: the failure could not be recorded: ${String(recordError).slice(0, 200)}`
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
throw err;
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
var runWorkflowSteps = async (prepared, options) => {
|
|
657
|
+
const force = options.force ?? false;
|
|
658
|
+
const maxPasses = Math.max(
|
|
659
|
+
1,
|
|
660
|
+
Math.min(options.maxPasses ?? defaultMaxPasses, defaultMaxPasses)
|
|
661
|
+
);
|
|
662
|
+
const scorecard = new Scorecard(prepared);
|
|
663
|
+
let ctx = prepared;
|
|
664
|
+
for (const stage of ["analyze", "qualify"]) {
|
|
665
|
+
const run = await runOne(ctx, stage, { force });
|
|
666
|
+
scorecard.stage(run);
|
|
667
|
+
if (run.degraded.length) {
|
|
668
|
+
ctx = withoutAnswers(ctx, run.degraded);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
await aggregate(ctx);
|
|
672
|
+
await ctx.checkpoint?.();
|
|
673
|
+
const progressFile = path.join(ctx.dir, "REVIEW", "progress.json");
|
|
674
|
+
const savedProgress = reviewProgressSchema.parse(
|
|
675
|
+
JSON.parse(await readFile(progressFile, "utf8").catch(() => "null"))
|
|
676
|
+
);
|
|
677
|
+
const progress = !force && savedProgress?.digest === await stageInputsDigest(ctx, "review") ? savedProgress : null;
|
|
678
|
+
let rounds = progress?.rounds ?? 0;
|
|
679
|
+
let verdict = progress?.accepted ? "accepted" : "needs_another_pass";
|
|
680
|
+
for (let pass = rounds + 1; verdict !== "accepted" && pass <= maxPasses; pass += 1) {
|
|
681
|
+
const run = await runOne(ctx, "review", { force: pass > 1 || force, pass });
|
|
682
|
+
scorecard.stage(run, pass);
|
|
683
|
+
rounds = pass;
|
|
684
|
+
if (!run.ok) {
|
|
685
|
+
ctx.log(
|
|
686
|
+
`review pass ${pass} produced nothing the host could accept; the state stands as it is`
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
if (Number(run.summary.corrections ?? 0) > 0) {
|
|
690
|
+
await aggregate(ctx);
|
|
691
|
+
}
|
|
692
|
+
if (run.ok && !Number(run.summary.corrections ?? 0) && !Number(run.summary.refusedCorrections ?? 0) && run.summary.verdict === "accepted") {
|
|
693
|
+
verdict = "accepted";
|
|
694
|
+
ctx.log(`accepted after ${pass} scrutiny pass${pass === 1 ? "" : "es"}`);
|
|
695
|
+
}
|
|
696
|
+
await mkdir(path.dirname(progressFile), { recursive: true });
|
|
697
|
+
await writeFile(
|
|
698
|
+
progressFile,
|
|
699
|
+
JSON.stringify({
|
|
700
|
+
rounds,
|
|
701
|
+
digest: await stageInputsDigest(ctx, "review"),
|
|
702
|
+
accepted: verdict === "accepted"
|
|
703
|
+
})
|
|
704
|
+
);
|
|
705
|
+
await ctx.checkpoint?.();
|
|
706
|
+
}
|
|
707
|
+
if (verdict !== "accepted") {
|
|
708
|
+
ctx.log(
|
|
709
|
+
`not accepted after ${maxPasses} scrutiny passes; the report ships with the open notes in REVIEW/`
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
const degraded = prepared.answers.map((answer) => answer.file).filter((file) => !ctx.answers.some((answer) => answer.file === file));
|
|
713
|
+
let finished = null;
|
|
714
|
+
try {
|
|
715
|
+
finished = await finish(ctx, {
|
|
716
|
+
degraded,
|
|
717
|
+
write: false,
|
|
718
|
+
ground: options.ground,
|
|
719
|
+
quality: await reportQuality(ctx.dir, {
|
|
720
|
+
rounds,
|
|
721
|
+
degraded,
|
|
722
|
+
accepted: verdict === "accepted"
|
|
723
|
+
})
|
|
724
|
+
});
|
|
725
|
+
scorecard.finished(finished.partialFailures.length, finished.written);
|
|
726
|
+
} catch (error) {
|
|
727
|
+
if (isBlocker(error, ctx.signal)) {
|
|
728
|
+
throw error;
|
|
729
|
+
}
|
|
730
|
+
ctx.log(`finish failed: ${String(error).slice(0, 400)}`);
|
|
731
|
+
scorecard.finished(-1, "failed");
|
|
732
|
+
}
|
|
733
|
+
let copy = null;
|
|
734
|
+
let copyOutcome = "skipped";
|
|
735
|
+
if (finished) {
|
|
736
|
+
try {
|
|
737
|
+
const inputs = copyInputsOf(ctx.source, {
|
|
738
|
+
brandLogo: await options.brandLogo?.()
|
|
739
|
+
});
|
|
740
|
+
const copyContext = await withCopy(ctx, inputs);
|
|
741
|
+
const { run: written, copy: delivered } = await writeReportCopy(
|
|
742
|
+
copyContext,
|
|
743
|
+
inputs,
|
|
744
|
+
{ force }
|
|
745
|
+
);
|
|
746
|
+
scorecard.stage(written);
|
|
747
|
+
copy = delivered;
|
|
748
|
+
copyOutcome = "validated";
|
|
749
|
+
if (copy.quality) {
|
|
750
|
+
const quality = finished.snapshot.meta.quality;
|
|
751
|
+
if (!quality) {
|
|
752
|
+
throw new Error(
|
|
753
|
+
`The finished snapshot has no quality record: ${finished.snapshotFile}.`
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
quality.needsImprovement = true;
|
|
757
|
+
quality.issues.push(...copy.quality.issues);
|
|
758
|
+
await writeFile(
|
|
759
|
+
finished.snapshotFile,
|
|
760
|
+
JSON.stringify(finished.snapshot, null, 2)
|
|
761
|
+
);
|
|
762
|
+
await ctx.checkpoint?.();
|
|
763
|
+
}
|
|
764
|
+
} catch (error) {
|
|
765
|
+
if (isBlocker(error, ctx.signal)) {
|
|
766
|
+
throw error;
|
|
767
|
+
}
|
|
768
|
+
ctx.log(`copy stage failed: ${String(error).slice(0, 400)}`);
|
|
769
|
+
copyOutcome = "errored";
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
scorecard.copy(copyOutcome);
|
|
773
|
+
if (finished && options.write) {
|
|
774
|
+
finished = await writeFinished(ctx.source, finished);
|
|
775
|
+
scorecard.finished(finished.partialFailures.length, finished.written);
|
|
776
|
+
ctx.log(
|
|
777
|
+
`store: ${finished.written}${finished.writeMessage ? ` (${finished.writeMessage})` : ""}`
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
const finalScorecard = await scorecard.write(verdict);
|
|
781
|
+
await ctx.recorder?.record("run_completed", {
|
|
782
|
+
verdict,
|
|
783
|
+
copyOutcome,
|
|
784
|
+
finished: finished !== null,
|
|
785
|
+
degradedAnswers: degraded.length
|
|
786
|
+
});
|
|
787
|
+
await ctx.checkpoint?.();
|
|
788
|
+
return {
|
|
789
|
+
verdict,
|
|
790
|
+
degraded,
|
|
791
|
+
finish: finished,
|
|
792
|
+
copy,
|
|
793
|
+
copyOutcome,
|
|
794
|
+
scorecard: finalScorecard
|
|
795
|
+
};
|
|
796
|
+
};
|
|
797
|
+
var isBlocker = (error, signal) => {
|
|
798
|
+
return error instanceof ModelBudgetError || error instanceof GroundingIntegrityError || signal?.aborted === true;
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
export {
|
|
802
|
+
defaultMaxPasses,
|
|
803
|
+
copyInputsOf,
|
|
804
|
+
prepareWorkdir,
|
|
805
|
+
withCopy,
|
|
806
|
+
finish,
|
|
807
|
+
aggregate,
|
|
808
|
+
runOne,
|
|
809
|
+
deliverableCopy,
|
|
810
|
+
writeReportCopy,
|
|
811
|
+
runWorkflow
|
|
812
|
+
};
|