@remnic/core 10.0.25 → 10.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.js +37 -36
- package/dist/access-authorization-probe.js +38 -37
- package/dist/access-boundary.js +37 -36
- package/dist/access-cli.js +100 -99
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +37 -36
- package/dist/access-http-briefing.js +38 -37
- package/dist/access-http-query.js +39 -38
- package/dist/access-http.js +56 -55
- package/dist/access-identity-continuity-surface.js +37 -36
- package/dist/access-lcm-surface.js +37 -36
- package/dist/access-mcp.js +48 -47
- package/dist/access-namespace-preflight.js +37 -36
- package/dist/access-observe-write-category.js +4 -4
- package/dist/access-observe-write-surface.js +37 -36
- package/dist/access-operations-batch.js +38 -37
- package/dist/access-operations.js +45 -44
- package/dist/access-recall-concurrency.js +37 -36
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-response.js +37 -36
- package/dist/access-recall-surface.js +37 -36
- package/dist/access-schema.js +3 -3
- package/dist/access-service.js +37 -36
- package/dist/access-surface-catalog.js +39 -38
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/active-recall.js +7 -7
- package/dist/{auto-sync-7WWAKW6F.js → auto-sync-UQESPLCB.js} +5 -5
- package/dist/briefing.js +7 -7
- package/dist/buffer.js +3 -3
- package/dist/calibration.js +5 -4
- package/dist/calibration.js.map +1 -1
- package/dist/causal-consolidation.js +8 -8
- package/dist/{chunk-AAQA6ZUP.js → chunk-23ZLN5X6.js} +13 -2
- package/dist/{chunk-AAQA6ZUP.js.map → chunk-23ZLN5X6.js.map} +1 -1
- package/dist/{chunk-OFQOOLQQ.js → chunk-27LPB4NS.js} +2 -2
- package/dist/{chunk-YW4ZYASS.js → chunk-27SAUQ5R.js} +2 -2
- package/dist/{chunk-2JGBX5XY.js → chunk-2HLMFRZ7.js} +2 -2
- package/dist/{chunk-DJMGVSST.js → chunk-33UAWCBN.js} +2 -2
- package/dist/{chunk-UHBZK3CK.js → chunk-36DZ242S.js} +2 -2
- package/dist/chunk-3VRMUNWL.js +289 -0
- package/dist/chunk-3VRMUNWL.js.map +1 -0
- package/dist/{chunk-466EGMFQ.js → chunk-42KSEX6C.js} +1 -1
- package/dist/chunk-42KSEX6C.js.map +1 -0
- package/dist/{chunk-LT4SMGE4.js → chunk-4WT6I4VG.js} +2 -2
- package/dist/{chunk-ML7ZJAKJ.js → chunk-5HT35H4L.js} +4 -4
- package/dist/{chunk-LO76EF3Y.js → chunk-7EJCAFMS.js} +2 -2
- package/dist/{chunk-YRKKW4KT.js → chunk-7IOB5F7Y.js} +3 -3
- package/dist/{chunk-IVUCF3QO.js → chunk-7RTNJ6M2.js} +2 -2
- package/dist/{chunk-VPXIKBPX.js → chunk-A3IURDU2.js} +22 -1
- package/dist/chunk-A3IURDU2.js.map +1 -0
- package/dist/{chunk-YUZRI3QU.js → chunk-AN3G5DZH.js} +2 -2
- package/dist/{chunk-N36PBG4A.js → chunk-AQ52ZFBC.js} +2 -2
- package/dist/{chunk-O6ADSFGY.js → chunk-AYHPSYZI.js} +2 -2
- package/dist/{chunk-FT4UQYOV.js → chunk-BDLOEODO.js} +2 -2
- package/dist/{chunk-GXVLEXIX.js → chunk-BDQMMX3M.js} +2 -2
- package/dist/{chunk-VOEBHBWG.js → chunk-BHQPOCQE.js} +2 -2
- package/dist/{chunk-V4MB5ONM.js → chunk-BWXKJDDH.js} +4 -4
- package/dist/{chunk-2I3OREMR.js → chunk-CCDHRDQ3.js} +2 -2
- package/dist/{chunk-XKPLERHV.js → chunk-COGLFRXT.js} +37 -37
- package/dist/{chunk-EP6BA7VV.js → chunk-CU5TILGD.js} +2 -5
- package/dist/chunk-CU5TILGD.js.map +1 -0
- package/dist/{chunk-BI3CIDIH.js → chunk-DF2G4IXN.js} +3 -3
- package/dist/{chunk-33G67YZF.js → chunk-DWL6YIZH.js} +2 -2
- package/dist/{chunk-W3GFSWKE.js → chunk-EET24NSB.js} +8 -8
- package/dist/{chunk-2DT7PIDZ.js → chunk-EPOYPPOW.js} +2 -2
- package/dist/{chunk-W7NVMERN.js → chunk-ERAVI25Z.js} +2 -2
- package/dist/{chunk-RYYVMZBR.js → chunk-ETPIYK4J.js} +2 -2
- package/dist/{chunk-ZDUMF4H6.js → chunk-FFGHFU7A.js} +14 -14
- package/dist/{chunk-DYJHGJZ4.js → chunk-FJJWA7NL.js} +55 -7
- package/dist/chunk-FJJWA7NL.js.map +1 -0
- package/dist/{chunk-ZUCNOTNF.js → chunk-G6XEYFCO.js} +14 -14
- package/dist/{chunk-NFB5QTOH.js → chunk-GCZHKBY2.js} +2 -2
- package/dist/{chunk-JNLEJE4A.js → chunk-GEHIRZXF.js} +2 -2
- package/dist/{chunk-VUBVNY3W.js → chunk-GMZNJZRP.js} +2 -2
- package/dist/{chunk-RTV3DB4I.js → chunk-H2X22KZW.js} +2 -2
- package/dist/{chunk-VYVQZRXF.js → chunk-H3AW6QZF.js} +2 -2
- package/dist/{chunk-RQMSD4CN.js → chunk-H75L4ZOH.js} +59 -59
- package/dist/{chunk-ZDDDWTC7.js → chunk-HJQXHLQQ.js} +2 -2
- package/dist/{chunk-PDFAX4PK.js → chunk-HNEOLXRF.js} +2 -2
- package/dist/{chunk-5JXNXKKV.js → chunk-I27WOMJ7.js} +2 -2
- package/dist/{chunk-LDZD3OQG.js → chunk-IHGLQJW6.js} +2 -2
- package/dist/{chunk-D42L5SQF.js → chunk-IHS2UGYM.js} +6 -6
- package/dist/{chunk-VVSPHTSU.js → chunk-JHQAXATW.js} +2 -2
- package/dist/{chunk-6VWCL2IZ.js → chunk-JX32ROLZ.js} +3 -3
- package/dist/{chunk-OPNSIFFU.js → chunk-JYZLDZ2R.js} +8 -8
- package/dist/{chunk-2C5YAVHA.js → chunk-JZIZBJCW.js} +2 -2
- package/dist/{chunk-7LCGFUMB.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-CA2R2AD4.js → chunk-L3IP56F4.js} +38 -38
- package/dist/{chunk-32FVH5OQ.js → chunk-L5TJWQEF.js} +6 -6
- package/dist/{chunk-PIN5OPBA.js → chunk-LVU7FP27.js} +1 -1
- package/dist/{chunk-QM2SPLKQ.js → chunk-MLED254J.js} +1 -1
- package/dist/chunk-MLED254J.js.map +1 -0
- package/dist/{chunk-5NO42IYF.js → chunk-MPZYCRC6.js} +4 -4
- package/dist/{chunk-A2IJEV5L.js → chunk-MSMGQDVW.js} +2 -2
- package/dist/{chunk-FBNL4BYD.js → chunk-N34ZW6E4.js} +2 -2
- package/dist/{chunk-Q35L7TYB.js → chunk-NYPQHFC3.js} +2 -2
- package/dist/{chunk-G2OYFTUD.js → chunk-O6S5FLZB.js} +2 -2
- package/dist/{chunk-SSUTJLCF.js → chunk-PLD6SOU7.js} +2 -2
- package/dist/{chunk-YBO2WGCV.js → chunk-PM72NSEW.js} +2 -2
- package/dist/{chunk-DUPHIZBY.js → chunk-PUDYANAX.js} +2 -2
- package/dist/{chunk-62CRBI5B.js → chunk-PXTLPC3P.js} +2 -2
- package/dist/{chunk-AAQ77A44.js → chunk-QNKEMFZY.js} +2 -2
- package/dist/{chunk-3F3HA3R2.js → chunk-RN7HPFYS.js} +2 -2
- package/dist/{chunk-NIS3FOMD.js → chunk-S36KJNQH.js} +2 -2
- package/dist/{chunk-QC5TJUSP.js → chunk-SU5V2LWR.js} +2 -2
- package/dist/{chunk-INBB7D3V.js → chunk-SYUNCM26.js} +2 -2
- package/dist/{chunk-TKC5LZ43.js → chunk-UIDWASOS.js} +2 -2
- package/dist/{chunk-UXXLP2PD.js → chunk-UJPGQCXD.js} +3 -3
- package/dist/{chunk-EML6HJE6.js → chunk-UKWRCQWT.js} +2 -2
- package/dist/{chunk-4OEBL5T3.js → chunk-V7KGDLBC.js} +2 -2
- package/dist/{chunk-5FNZ3G6X.js → chunk-VKQI47DJ.js} +4 -4
- package/dist/{chunk-TXE55Z3X.js → chunk-VMHCC7LO.js} +2 -2
- package/dist/{chunk-HVIXRLXJ.js → chunk-VN3GHPBU.js} +2 -2
- package/dist/{chunk-OMERTLB7.js → chunk-W6MOLW5S.js} +9 -7
- package/dist/chunk-W6MOLW5S.js.map +1 -0
- package/dist/{chunk-IBGRIAE5.js → chunk-WFUO7NWX.js} +2 -2
- package/dist/{chunk-3K6J5GO5.js → chunk-WJAGO5LL.js} +3 -3
- package/dist/{chunk-CJRENHVZ.js → chunk-XNAOCY67.js} +2 -2
- package/dist/{chunk-7UHCV5B3.js → chunk-XSXM5LYZ.js} +2 -2
- package/dist/{chunk-PVHQSLNN.js → chunk-Y6IF6H2U.js} +2 -2
- package/dist/{chunk-CFZ4SXXH.js → chunk-YEF5AAWN.js} +2 -2
- package/dist/{chunk-QZ7WOCME.js → chunk-Z3XVYXQ3.js} +2 -2
- package/dist/cli.js +73 -72
- package/dist/coding/export-okf-codegraph.js +6 -6
- package/dist/compounding/engine.js +8 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -7
- package/dist/connectors/codex-materialize-runner.js +7 -7
- package/dist/connectors/index.js +7 -7
- package/dist/convergence-refresh.js +9 -9
- package/dist/corpus-watermark.js +9 -9
- package/dist/deep-recall-http-glue.js +4 -4
- package/dist/deep-recall-policy-llm.js +3 -3
- package/dist/entity-retrieval.js +7 -7
- package/dist/external-wiki-access.js +38 -37
- package/dist/extraction-faithfulness.js +3 -3
- package/dist/extraction-judge.js +3 -3
- package/dist/extraction-span-wire.d.ts +8 -0
- package/dist/extraction-span-wire.d.ts.map +1 -1
- package/dist/extraction-span-wire.js +5 -3
- package/dist/extraction.js +15 -14
- package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
- package/dist/fallback-llm-codex-subscription.js +1 -1
- package/dist/fallback-llm.js +2 -2
- package/dist/{first-start-migration-QVD22WWS.js → first-start-migration-A6PHIBUQ.js} +4 -4
- package/dist/harmonic-retrieval.js +7 -7
- package/dist/index.js +113 -112
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +5 -5
- package/dist/local-llm-helpers.d.ts +2 -1
- package/dist/local-llm-helpers.d.ts.map +1 -1
- package/dist/local-llm-helpers.js +1 -1
- package/dist/local-llm-rate-limit.d.ts +169 -0
- package/dist/local-llm-rate-limit.d.ts.map +1 -0
- package/dist/local-llm-rate-limit.js +48 -0
- package/dist/local-llm-rate-limit.js.map +1 -0
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +7 -2
- package/dist/location/index.js +9 -9
- package/dist/maintenance/memory-governance.js +7 -7
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -7
- package/dist/maintenance/rebuild-memory-projection-runner.js +9 -9
- package/dist/maintenance/rebuild-memory-projection.js +8 -8
- package/dist/memory-browse-operations.js +38 -37
- package/dist/memory-browse.js +3 -3
- package/dist/namespaces/migrate.js +8 -8
- package/dist/namespaces/storage.js +7 -7
- package/dist/operator-doctor-corpus.js +10 -10
- package/dist/operator-toolkit.js +16 -16
- package/dist/orchestration/maintenance.js +20 -19
- package/dist/orchestrator.js +102 -101
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation-operations.js +38 -37
- package/dist/recall-navigation.js +37 -36
- package/dist/recall-planner-llm.js +2 -2
- package/dist/recall-state-view-admission.js +3 -3
- package/dist/recall-why-service.js +3 -3
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/resume-bundles.js +8 -8
- package/dist/semantic-consolidation.js +8 -8
- package/dist/semantic-rule-promotion.js +7 -7
- package/dist/semantic-rule-verifier.js +7 -7
- package/dist/source-agent-qualifier.js +10 -10
- package/dist/standup/build.js +7 -7
- package/dist/storage.js +6 -6
- package/dist/summarizer.js +6 -5
- package/dist/support-passport/index.js +40 -39
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/export-okf.js +7 -7
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +7 -7
- package/dist/who-knows-cli.js +8 -8
- package/dist/who-knows.js +7 -7
- package/package.json +2 -2
- package/src/ambient-provenance.test.ts +21 -3
- package/src/config.ts +9 -0
- package/src/extraction-span-wire.ts +11 -0
- package/src/extraction.ts +2 -2
- package/src/fallback-llm-codex-subscription.ts +6 -9
- package/src/local-llm-helpers.ts +2 -1
- package/src/local-llm-json-schema-fallback.test.ts +278 -0
- package/src/local-llm-rate-limit.test.ts +406 -0
- package/src/local-llm-rate-limit.ts +418 -0
- package/src/local-llm.ts +57 -5
- package/src/types.ts +8 -0
- package/dist/chunk-466EGMFQ.js.map +0 -1
- package/dist/chunk-DYJHGJZ4.js.map +0 -1
- package/dist/chunk-EP6BA7VV.js.map +0 -1
- package/dist/chunk-OMERTLB7.js.map +0 -1
- package/dist/chunk-QM2SPLKQ.js.map +0 -1
- package/dist/chunk-VPXIKBPX.js.map +0 -1
- /package/dist/{auto-sync-7WWAKW6F.js.map → auto-sync-UQESPLCB.js.map} +0 -0
- /package/dist/{chunk-OFQOOLQQ.js.map → chunk-27LPB4NS.js.map} +0 -0
- /package/dist/{chunk-YW4ZYASS.js.map → chunk-27SAUQ5R.js.map} +0 -0
- /package/dist/{chunk-2JGBX5XY.js.map → chunk-2HLMFRZ7.js.map} +0 -0
- /package/dist/{chunk-DJMGVSST.js.map → chunk-33UAWCBN.js.map} +0 -0
- /package/dist/{chunk-UHBZK3CK.js.map → chunk-36DZ242S.js.map} +0 -0
- /package/dist/{chunk-LT4SMGE4.js.map → chunk-4WT6I4VG.js.map} +0 -0
- /package/dist/{chunk-ML7ZJAKJ.js.map → chunk-5HT35H4L.js.map} +0 -0
- /package/dist/{chunk-LO76EF3Y.js.map → chunk-7EJCAFMS.js.map} +0 -0
- /package/dist/{chunk-YRKKW4KT.js.map → chunk-7IOB5F7Y.js.map} +0 -0
- /package/dist/{chunk-IVUCF3QO.js.map → chunk-7RTNJ6M2.js.map} +0 -0
- /package/dist/{chunk-YUZRI3QU.js.map → chunk-AN3G5DZH.js.map} +0 -0
- /package/dist/{chunk-N36PBG4A.js.map → chunk-AQ52ZFBC.js.map} +0 -0
- /package/dist/{chunk-O6ADSFGY.js.map → chunk-AYHPSYZI.js.map} +0 -0
- /package/dist/{chunk-FT4UQYOV.js.map → chunk-BDLOEODO.js.map} +0 -0
- /package/dist/{chunk-GXVLEXIX.js.map → chunk-BDQMMX3M.js.map} +0 -0
- /package/dist/{chunk-VOEBHBWG.js.map → chunk-BHQPOCQE.js.map} +0 -0
- /package/dist/{chunk-V4MB5ONM.js.map → chunk-BWXKJDDH.js.map} +0 -0
- /package/dist/{chunk-2I3OREMR.js.map → chunk-CCDHRDQ3.js.map} +0 -0
- /package/dist/{chunk-XKPLERHV.js.map → chunk-COGLFRXT.js.map} +0 -0
- /package/dist/{chunk-BI3CIDIH.js.map → chunk-DF2G4IXN.js.map} +0 -0
- /package/dist/{chunk-33G67YZF.js.map → chunk-DWL6YIZH.js.map} +0 -0
- /package/dist/{chunk-W3GFSWKE.js.map → chunk-EET24NSB.js.map} +0 -0
- /package/dist/{chunk-2DT7PIDZ.js.map → chunk-EPOYPPOW.js.map} +0 -0
- /package/dist/{chunk-W7NVMERN.js.map → chunk-ERAVI25Z.js.map} +0 -0
- /package/dist/{chunk-RYYVMZBR.js.map → chunk-ETPIYK4J.js.map} +0 -0
- /package/dist/{chunk-ZDUMF4H6.js.map → chunk-FFGHFU7A.js.map} +0 -0
- /package/dist/{chunk-ZUCNOTNF.js.map → chunk-G6XEYFCO.js.map} +0 -0
- /package/dist/{chunk-NFB5QTOH.js.map → chunk-GCZHKBY2.js.map} +0 -0
- /package/dist/{chunk-JNLEJE4A.js.map → chunk-GEHIRZXF.js.map} +0 -0
- /package/dist/{chunk-VUBVNY3W.js.map → chunk-GMZNJZRP.js.map} +0 -0
- /package/dist/{chunk-RTV3DB4I.js.map → chunk-H2X22KZW.js.map} +0 -0
- /package/dist/{chunk-VYVQZRXF.js.map → chunk-H3AW6QZF.js.map} +0 -0
- /package/dist/{chunk-RQMSD4CN.js.map → chunk-H75L4ZOH.js.map} +0 -0
- /package/dist/{chunk-ZDDDWTC7.js.map → chunk-HJQXHLQQ.js.map} +0 -0
- /package/dist/{chunk-PDFAX4PK.js.map → chunk-HNEOLXRF.js.map} +0 -0
- /package/dist/{chunk-5JXNXKKV.js.map → chunk-I27WOMJ7.js.map} +0 -0
- /package/dist/{chunk-LDZD3OQG.js.map → chunk-IHGLQJW6.js.map} +0 -0
- /package/dist/{chunk-D42L5SQF.js.map → chunk-IHS2UGYM.js.map} +0 -0
- /package/dist/{chunk-VVSPHTSU.js.map → chunk-JHQAXATW.js.map} +0 -0
- /package/dist/{chunk-6VWCL2IZ.js.map → chunk-JX32ROLZ.js.map} +0 -0
- /package/dist/{chunk-OPNSIFFU.js.map → chunk-JYZLDZ2R.js.map} +0 -0
- /package/dist/{chunk-2C5YAVHA.js.map → chunk-JZIZBJCW.js.map} +0 -0
- /package/dist/{chunk-7LCGFUMB.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-CA2R2AD4.js.map → chunk-L3IP56F4.js.map} +0 -0
- /package/dist/{chunk-32FVH5OQ.js.map → chunk-L5TJWQEF.js.map} +0 -0
- /package/dist/{chunk-PIN5OPBA.js.map → chunk-LVU7FP27.js.map} +0 -0
- /package/dist/{chunk-5NO42IYF.js.map → chunk-MPZYCRC6.js.map} +0 -0
- /package/dist/{chunk-A2IJEV5L.js.map → chunk-MSMGQDVW.js.map} +0 -0
- /package/dist/{chunk-FBNL4BYD.js.map → chunk-N34ZW6E4.js.map} +0 -0
- /package/dist/{chunk-Q35L7TYB.js.map → chunk-NYPQHFC3.js.map} +0 -0
- /package/dist/{chunk-G2OYFTUD.js.map → chunk-O6S5FLZB.js.map} +0 -0
- /package/dist/{chunk-SSUTJLCF.js.map → chunk-PLD6SOU7.js.map} +0 -0
- /package/dist/{chunk-YBO2WGCV.js.map → chunk-PM72NSEW.js.map} +0 -0
- /package/dist/{chunk-DUPHIZBY.js.map → chunk-PUDYANAX.js.map} +0 -0
- /package/dist/{chunk-62CRBI5B.js.map → chunk-PXTLPC3P.js.map} +0 -0
- /package/dist/{chunk-AAQ77A44.js.map → chunk-QNKEMFZY.js.map} +0 -0
- /package/dist/{chunk-3F3HA3R2.js.map → chunk-RN7HPFYS.js.map} +0 -0
- /package/dist/{chunk-NIS3FOMD.js.map → chunk-S36KJNQH.js.map} +0 -0
- /package/dist/{chunk-QC5TJUSP.js.map → chunk-SU5V2LWR.js.map} +0 -0
- /package/dist/{chunk-INBB7D3V.js.map → chunk-SYUNCM26.js.map} +0 -0
- /package/dist/{chunk-TKC5LZ43.js.map → chunk-UIDWASOS.js.map} +0 -0
- /package/dist/{chunk-UXXLP2PD.js.map → chunk-UJPGQCXD.js.map} +0 -0
- /package/dist/{chunk-EML6HJE6.js.map → chunk-UKWRCQWT.js.map} +0 -0
- /package/dist/{chunk-4OEBL5T3.js.map → chunk-V7KGDLBC.js.map} +0 -0
- /package/dist/{chunk-5FNZ3G6X.js.map → chunk-VKQI47DJ.js.map} +0 -0
- /package/dist/{chunk-TXE55Z3X.js.map → chunk-VMHCC7LO.js.map} +0 -0
- /package/dist/{chunk-HVIXRLXJ.js.map → chunk-VN3GHPBU.js.map} +0 -0
- /package/dist/{chunk-IBGRIAE5.js.map → chunk-WFUO7NWX.js.map} +0 -0
- /package/dist/{chunk-3K6J5GO5.js.map → chunk-WJAGO5LL.js.map} +0 -0
- /package/dist/{chunk-CJRENHVZ.js.map → chunk-XNAOCY67.js.map} +0 -0
- /package/dist/{chunk-7UHCV5B3.js.map → chunk-XSXM5LYZ.js.map} +0 -0
- /package/dist/{chunk-PVHQSLNN.js.map → chunk-Y6IF6H2U.js.map} +0 -0
- /package/dist/{chunk-CFZ4SXXH.js.map → chunk-YEF5AAWN.js.map} +0 -0
- /package/dist/{chunk-QZ7WOCME.js.map → chunk-Z3XVYXQ3.js.map} +0 -0
- /package/dist/{first-start-migration-QVD22WWS.js.map → first-start-migration-A6PHIBUQ.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dateInTimezone,
|
|
3
3
|
defaultTimezone
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-XNAOCY67.js";
|
|
5
|
+
import "./chunk-AN3G5DZH.js";
|
|
6
6
|
import "./chunk-UOBPK2OS.js";
|
|
7
7
|
import "./chunk-CIO7GCWE.js";
|
|
8
8
|
import "./chunk-YN2DQ2D6.js";
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
} from "./chunk-V7IZKJI3.js";
|
|
14
14
|
import "./chunk-QDW3E4RD.js";
|
|
15
15
|
import "./chunk-UHVXE24Y.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-UIDWASOS.js";
|
|
17
17
|
import "./chunk-I55KAVET.js";
|
|
18
18
|
import "./chunk-L2EXJQJP.js";
|
|
19
19
|
import "./chunk-45GF7Y3V.js";
|
|
20
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-CU5TILGD.js";
|
|
21
21
|
import "./chunk-E2AWJ7KQ.js";
|
|
22
22
|
import "./chunk-YCVB7X56.js";
|
|
23
23
|
import "./chunk-YBA52OKG.js";
|
|
@@ -98,4 +98,4 @@ function startWearablesAutoSync(settings, deps) {
|
|
|
98
98
|
export {
|
|
99
99
|
startWearablesAutoSync
|
|
100
100
|
};
|
|
101
|
-
//# sourceMappingURL=auto-sync-
|
|
101
|
+
//# sourceMappingURL=auto-sync-UQESPLCB.js.map
|
package/dist/briefing.js
CHANGED
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
renderBriefingMarkdown,
|
|
19
19
|
resolveBriefingSaveDir,
|
|
20
20
|
validateBriefingFormat
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-4WT6I4VG.js";
|
|
22
22
|
import "./chunk-GZFKCLRC.js";
|
|
23
23
|
import "./chunk-6JMQR72P.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-IHS2UGYM.js";
|
|
25
25
|
import "./chunk-UHVXE24Y.js";
|
|
26
26
|
import "./chunk-TRMJ6BYC.js";
|
|
27
27
|
import "./chunk-V4JZCTMK.js";
|
|
@@ -42,11 +42,11 @@ import "./chunk-A7Q43EUZ.js";
|
|
|
42
42
|
import "./chunk-S2V7RUCL.js";
|
|
43
43
|
import "./chunk-PPUNC7UX.js";
|
|
44
44
|
import "./chunk-X3724WL4.js";
|
|
45
|
-
import "./chunk-MRPOZBJC.js";
|
|
46
45
|
import "./chunk-S2HLHAZ4.js";
|
|
46
|
+
import "./chunk-MRPOZBJC.js";
|
|
47
47
|
import "./chunk-DM2T26WE.js";
|
|
48
48
|
import "./chunk-LDXUBPMO.js";
|
|
49
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-EPOYPPOW.js";
|
|
50
50
|
import "./chunk-AAD2ZS6P.js";
|
|
51
51
|
import "./chunk-FF6N7BXC.js";
|
|
52
52
|
import "./chunk-JNIVZNIB.js";
|
|
@@ -75,11 +75,11 @@ import "./chunk-IUM3VSHI.js";
|
|
|
75
75
|
import "./chunk-C64XATK7.js";
|
|
76
76
|
import "./chunk-42JKGUFJ.js";
|
|
77
77
|
import "./chunk-23G5P7TA.js";
|
|
78
|
-
import "./chunk-
|
|
78
|
+
import "./chunk-UIDWASOS.js";
|
|
79
79
|
import "./chunk-I55KAVET.js";
|
|
80
80
|
import "./chunk-L2EXJQJP.js";
|
|
81
81
|
import "./chunk-45GF7Y3V.js";
|
|
82
|
-
import "./chunk-
|
|
82
|
+
import "./chunk-CU5TILGD.js";
|
|
83
83
|
import "./chunk-E2AWJ7KQ.js";
|
|
84
84
|
import "./chunk-Z7L72ZHL.js";
|
|
85
85
|
import "./chunk-4O4TKIXQ.js";
|
|
@@ -87,7 +87,7 @@ import "./chunk-YCVB7X56.js";
|
|
|
87
87
|
import "./chunk-PQVCH2AE.js";
|
|
88
88
|
import "./chunk-PJKTFXE2.js";
|
|
89
89
|
import "./chunk-W5BIQOAJ.js";
|
|
90
|
-
import "./chunk-
|
|
90
|
+
import "./chunk-42KSEX6C.js";
|
|
91
91
|
import "./chunk-YBA52OKG.js";
|
|
92
92
|
import "./chunk-5LRV557D.js";
|
|
93
93
|
import "./chunk-BT7NVCML.js";
|
package/dist/buffer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SmartBuffer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PUDYANAX.js";
|
|
4
4
|
import "./chunk-T5IF2ZCE.js";
|
|
5
5
|
import "./chunk-H3FZVNRN.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-7EJCAFMS.js";
|
|
7
|
+
import "./chunk-LVU7FP27.js";
|
|
8
8
|
import "./chunk-CSAKJVXW.js";
|
|
9
9
|
import "./chunk-K2XUWZBM.js";
|
|
10
10
|
import "./chunk-OD4FM2U7.js";
|
package/dist/calibration.js
CHANGED
|
@@ -4,18 +4,19 @@ import {
|
|
|
4
4
|
import "./chunk-QW27DOHG.js";
|
|
5
5
|
import {
|
|
6
6
|
LocalLlmClient
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-FJJWA7NL.js";
|
|
8
|
+
import "./chunk-MLED254J.js";
|
|
9
|
+
import "./chunk-3VRMUNWL.js";
|
|
9
10
|
import "./chunk-U4LUIE6Y.js";
|
|
10
11
|
import "./chunk-JUXOTY6J.js";
|
|
11
12
|
import "./chunk-TOTT6S2V.js";
|
|
12
13
|
import {
|
|
13
14
|
FallbackLlmClient
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UIDWASOS.js";
|
|
15
16
|
import "./chunk-I55KAVET.js";
|
|
16
17
|
import "./chunk-L2EXJQJP.js";
|
|
17
18
|
import "./chunk-45GF7Y3V.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-CU5TILGD.js";
|
|
19
20
|
import "./chunk-E2AWJ7KQ.js";
|
|
20
21
|
import "./chunk-YBA52OKG.js";
|
|
21
22
|
import {
|
package/dist/calibration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calibration.ts"],"sourcesContent":["/**\n * calibration.ts — Prediction-Error-Driven Model-User Calibration\n *\n * Analyzes patterns in user corrections to identify systematic miscalibration\n * between the model's predictions and the user's actual expectations.\n * During consolidation, replays chains of similar corrections through an LLM\n * to synthesize CalibrationRules that adjust model behavior for this specific user.\n *\n * Inspired by:\n * - Cerebellar motor calibration (prediction errors drive lasting adjustments)\n * - Temporal difference learning (dopamine signals prediction error)\n * - Tesla FSD shadow mode (divergence between prediction and reality = training signal)\n */\n\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { resolveLocalLlmCapabilities } from \"./capabilities.js\";\nimport { OUTPUT_LANGUAGE_POLICY } from \"./extraction-prompt.js\";\nimport { FallbackLlmClient } from \"./fallback-llm.js\";\nimport { listJsonFiles } from \"./json-store.js\";\nimport { isMacOsReplicationJunkBasename } from \"./utils/macos-replication-junk.js\";\nimport { LocalLlmClient } from \"./local-llm.js\";\nimport { log } from \"./logger.js\";\nimport { writeFileAtomically } from \"./maintenance/atomic-file.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, PluginConfig } from \"./types.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CalibrationRule {\n id: string;\n ruleType: \"model_tendency\" | \"user_expectation\" | \"scope_boundary\" | \"verification_required\";\n condition: string;\n modelTendency: string;\n userExpectation: string;\n calibration: string;\n confidence: number;\n evidenceCount: number;\n evidenceCorrectionIds: string[];\n createdAt: string;\n lastReinforcedAt: string;\n}\n\nexport interface CalibrationIndex {\n rules: CalibrationRule[];\n updatedAt: string;\n totalCorrectionsAnalyzed: number;\n /**\n * Weeks whose rule reinforcement is already committed. A retry of any of\n * these weeks must not increment `evidenceCount` again. Older indexes\n * persisted a single `appliedWeekId`; reads fold it into this list.\n */\n appliedWeekIds?: string[];\n}\n\n// ─── Storage ─────────────────────────────────────────────────────────────────\n\nfunction calibrationDir(memoryDir: string): string {\n return path.join(memoryDir, \"state\", \"calibration\");\n}\n\nfunction calibrationIndexPath(memoryDir: string): string {\n return path.join(calibrationDir(memoryDir), \"calibration-index.json\");\n}\n\n/** Week ids are short (`YYYY-Www`). Longer values are not used as stamps. */\nconst MAX_APPLIED_WEEK_ID_LENGTH = 32;\n\nexport function appliedCalibrationWeekId(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (trimmed.length === 0 || trimmed.length > MAX_APPLIED_WEEK_ID_LENGTH) return undefined;\n return trimmed;\n}\n\nexport async function readCalibrationIndex(memoryDir: string): Promise<CalibrationIndex> {\n try {\n const raw = JSON.parse(await readFile(calibrationIndexPath(memoryDir), \"utf8\"));\n const appliedWeekIds = normalizeAppliedWeekIds(raw.appliedWeekIds, raw.appliedWeekId);\n return {\n rules: Array.isArray(raw.rules) ? raw.rules : [],\n updatedAt: typeof raw.updatedAt === \"string\" ? raw.updatedAt : new Date().toISOString(),\n totalCorrectionsAnalyzed: typeof raw.totalCorrectionsAnalyzed === \"number\" ? raw.totalCorrectionsAnalyzed : 0,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n } catch {\n return { rules: [], updatedAt: new Date().toISOString(), totalCorrectionsAnalyzed: 0 };\n }\n}\n\nfunction normalizeAppliedWeekIds(list: unknown, additional: unknown): string[] {\n const weeks: string[] = [];\n if (Array.isArray(list)) {\n for (const entry of list) {\n const week = appliedCalibrationWeekId(entry);\n if (week && !weeks.includes(week)) weeks.push(week);\n }\n }\n const extra = appliedCalibrationWeekId(additional);\n if (extra && !weeks.includes(extra)) weeks.push(extra);\n return weeks;\n}\n\n/**\n * Attach the week stamp to the index that will be written with the reinforced\n * rules. The stamp and the evidence increment commit together. Every\n * previously applied week stays in the list so an out-of-order retry of an\n * older week is still recognized as already applied.\n */\nexport function withAppliedCalibrationWeek(\n index: CalibrationIndex,\n idempotencyKey: string | undefined,\n): CalibrationIndex {\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, idempotencyKey);\n return {\n rules: index.rules,\n updatedAt: index.updatedAt,\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n}\n\nasync function writeCalibrationIndex(memoryDir: string, index: CalibrationIndex): Promise<void> {\n const dir = calibrationDir(memoryDir);\n await mkdir(dir, { recursive: true });\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, undefined);\n const stamped: CalibrationIndex = {\n rules: index.rules,\n updatedAt: new Date().toISOString(),\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n await writeFileAtomically(calibrationIndexPath(memoryDir), JSON.stringify(stamped, null, 2));\n}\n\n// ─── Correction Reading ──────────────────────────────────────────────────────\n\nexport interface CorrectionMemory {\n id: string;\n content: string;\n created: string;\n confidence: number;\n entityRefs: string[];\n tags: string[];\n}\n\nconst CALIBRATION_RULE_TYPES = new Set([\n \"model_tendency\",\n \"user_expectation\",\n \"scope_boundary\",\n \"verification_required\",\n]);\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidenceIds(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction nonEmptyString(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Exported for entity-contamination R-11 regression coverage (#682\n * PR 2/3 — codex review). Tests can drive the real correction-reading\n * path instead of duplicating the regex inline, so calibration parser\n * regressions surface via the contamination suite.\n */\nexport async function readCalibrationCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrectionsImpl(memoryDir: string): Promise<CorrectionMemory[]> {\n const correctionsDir = path.join(memoryDir, \"corrections\");\n const files = await listJsonFiles(correctionsDir).catch(() => {\n // Corrections might be in facts/ directories too\n return [] as string[];\n });\n\n // Also scan facts directories for correction-category files\n const factsDir = path.join(memoryDir, \"facts\");\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const dayDirs = (await readdir(factsDir)).filter((d: string) => /^\\d{4}-\\d{2}-\\d{2}$/.test(d));\n for (const day of dayDirs) {\n const dayPath = path.join(factsDir, day);\n const dayFiles = (await readdir(dayPath))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.startsWith(\"correction-\") && f.endsWith(\".md\"))\n .map((f: string) => path.join(dayPath, f));\n files.push(...dayFiles);\n }\n } catch {\n // facts dir might not exist\n }\n\n // Also check the dedicated corrections directory\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const corrFiles = (await readdir(correctionsDir))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.endsWith(\".md\"))\n .map((f: string) => path.join(correctionsDir, f));\n files.push(...corrFiles);\n } catch {\n // corrections dir might not exist\n }\n\n const corrections: CorrectionMemory[] = [];\n const seen = new Set<string>();\n\n for (const filePath of files) {\n try {\n const raw = await readFile(filePath, \"utf8\");\n\n // Parse frontmatter\n const fmMatch = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n if (!fmMatch) continue;\n\n const content = fmMatch[2].trim();\n if (!content || content.length < 10) continue;\n\n // Extract id from frontmatter\n const idMatch = fmMatch[1].match(/^id:\\s*(.+)$/m);\n const id = idMatch?.[1]?.trim() ?? path.basename(filePath, \".md\");\n\n if (seen.has(id)) continue;\n seen.add(id);\n\n const confMatch = fmMatch[1].match(/^confidence:\\s*(.+)$/m);\n const confidence = confMatch ? parseFloat(confMatch[1]) : 0.9;\n\n const entityMatch = fmMatch[1].match(/^entityRef:\\s*(.+)$/m);\n const entityRefs = entityMatch ? [entityMatch[1].trim()] : [];\n\n corrections.push({ id, content, created: \"\", confidence, entityRefs, tags: [] });\n } catch {\n // skip unparseable files\n }\n }\n\n return corrections;\n}\n\n// ─── LLM-Assisted Clustering and Replay ──────────────────────────────────────\n\nexport const CLUSTER_PROMPT = `You are analyzing user corrections to an AI assistant. Each correction represents a moment where the assistant's prediction of what the user wanted was WRONG.\n\nYour job: Group these corrections into clusters where the SAME TYPE of misunderstanding is happening. Then for each cluster, synthesize a CalibrationRule.\n\nA CalibrationRule describes:\n- condition: When does this type of mistake happen?\n- modelTendency: What does the model tend to assume or do wrong?\n- userExpectation: What does the user actually want instead?\n- calibration: How should the model adjust its behavior?\n- ruleType: One of \"model_tendency\", \"user_expectation\", \"scope_boundary\", \"verification_required\"\n\nFocus on PATTERNS, not individual corrections. A cluster needs at least 2 corrections to be worth a rule.\n${OUTPUT_LANGUAGE_POLICY}\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\n \"ruleType\": \"model_tendency\",\n \"condition\": \"When discussing project scope or task boundaries\",\n \"modelTendency\": \"The model tends to assume broader scope than the user intends\",\n \"userExpectation\": \"The user prefers narrow, specific task definitions and wants to be asked before scope expansion\",\n \"calibration\": \"When uncertain about scope, ask for clarification rather than assuming. Default to the narrower interpretation.\",\n \"confidence\": 0.85,\n \"evidenceIds\": [\"correction-id-1\", \"correction-id-2\"]\n }\n ]\n}`;\n\ninterface CalibrationChatClient {\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: {\n temperature?: number;\n maxTokens?: number;\n agentId?: string;\n modelChain?: AgentPersonaModelConfig;\n }\n ): Promise<{ content?: string | null } | null>;\n}\n\ninterface CalibrationLlmOptions {\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n /** Plugin config. Supplies `localLlm*` settings when the gateway chain is empty. */\n pluginConfig?: PluginConfig;\n}\n\nfunction resolveCalibrationChatClient(options: CalibrationLlmOptions): CalibrationChatClient | null {\n const gateway = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n if (gateway.isAvailable({ agentId: options.gatewayAgentId, modelChain: options.modelChain })) {\n return gateway;\n }\n const pluginConfig = options.pluginConfig;\n if (pluginConfig && resolveLocalLlmCapabilities(pluginConfig).localLlm) {\n log.info(`[calibration] using configured local LLM (model=${pluginConfig.localLlmModel})`);\n const local = new LocalLlmClient(pluginConfig);\n return {\n chatCompletion(messages, chatOptions) {\n return local.chatCompletion(messages, {\n temperature: chatOptions?.temperature,\n maxTokens: chatOptions?.maxTokens,\n });\n },\n };\n }\n log.warn(\"[calibration] no LLM available — skipping consolidation\");\n return null;\n}\n\nexport async function synthesizeCalibrationRules(\n corrections: CorrectionMemory[],\n llm: CalibrationChatClient,\n existingRules: CalibrationRule[],\n agentId?: string,\n modelChain?: AgentPersonaModelConfig\n): Promise<CalibrationRule[]> {\n if (corrections.length < 2) return [];\n\n // Format corrections for the LLM\n const correctionText = corrections\n .slice(0, 50) // limit to avoid huge prompts\n .map((c, i) => `[${c.id}] ${c.content}`)\n .join(\"\\n\\n\");\n\n const existingRulesText =\n existingRules.length > 0\n ? `\\n\\nExisting calibration rules (avoid duplicating these):\\n${existingRules.map((r) => `- ${r.condition}: ${r.calibration}`).join(\"\\n\")}`\n : \"\";\n\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CLUSTER_PROMPT },\n {\n role: \"user\",\n content: `Here are ${corrections.length} corrections from this user:\\n\\n${correctionText}${existingRulesText}`,\n },\n ],\n { temperature: 0.3, maxTokens: 3000, agentId, modelChain }\n );\n\n if (!response?.content) return [];\n\n try {\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n if (!Array.isArray(parsed.rules)) return [];\n\n const now = new Date().toISOString();\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n return rawRules\n .map((r: unknown): CalibrationRule | undefined => {\n if (!r || typeof r !== \"object\" || Array.isArray(r)) return undefined;\n const raw = r as Record<string, unknown>;\n const ruleType = nonEmptyString(raw.ruleType);\n const condition = nonEmptyString(raw.condition);\n const modelTendency = nonEmptyString(raw.modelTendency);\n const calibration = nonEmptyString(raw.calibration);\n const confidence = parseConfidence(raw.confidence);\n if (\n !ruleType ||\n !CALIBRATION_RULE_TYPES.has(ruleType) ||\n !condition ||\n !modelTendency ||\n !calibration ||\n confidence === undefined\n ) {\n return undefined;\n }\n const evidenceCorrectionIds = parseEvidenceIds(raw.evidenceIds);\n return {\n id: `cal-${createHash(\"sha256\")\n .update(condition + calibration)\n .digest(\"hex\")\n .slice(0, 12)}`,\n ruleType: ruleType as CalibrationRule[\"ruleType\"],\n condition,\n modelTendency,\n userExpectation: nonEmptyString(raw.userExpectation) ?? \"\",\n calibration,\n confidence,\n evidenceCount: evidenceCorrectionIds.length,\n evidenceCorrectionIds,\n createdAt: now,\n lastReinforcedAt: now,\n };\n })\n .filter((rule): rule is CalibrationRule => !!rule);\n } catch {\n log.warn(\"[calibration] failed to parse LLM response\");\n return [];\n }\n}\n\n// ─── Recall Section ──────────────────────────────────────────────────────────\n\n/**\n * Build a recall section from calibration rules relevant to the current query.\n * Uses the LLM to select which rules apply to the current context.\n */\nexport function buildCalibrationRecallSection(\n rules: CalibrationRule[],\n query: string,\n maxChars: number = 1200,\n): string | null {\n if (rules.length === 0) return null;\n\n // Simple relevance: include all rules (they're already filtered to this user)\n // In production, could use embedding similarity to filter\n const lines: string[] = [\n \"## Model Calibration (learned from past corrections)\",\n \"\",\n \"Adjustments for this specific user, learned from patterns in their corrections:\",\n \"\",\n ];\n\n let totalChars = lines.join(\"\\n\").length;\n\n for (const rule of rules) {\n const line = `- **${rule.condition}**: ${rule.modelTendency} → Instead: ${rule.calibration}`;\n if (totalChars + line.length + 1 > maxChars) break;\n lines.push(line);\n totalChars += line.length + 1;\n }\n\n if (lines.length <= 4) return null;\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Options weekly compounding passes into calibration. Gateway agent and task\n * chain fields stay limited to `modelSource: \"gateway\"`. `pluginConfig` carries\n * the `localLlm*` settings used when that chain is empty.\n */\nexport function calibrationConsolidationInput(config: PluginConfig): {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig: PluginConfig;\n} {\n const gateway = config.modelSource === \"gateway\";\n return {\n memoryDir: config.memoryDir,\n gatewayConfig: config.gatewayConfig,\n gatewayAgentId: gateway ? (config.gatewayAgentId || undefined) : undefined,\n modelChain: gateway ? config.taskModelChain : undefined,\n workspaceDir: config.workspaceDir,\n pluginConfig: config,\n };\n}\n\n/**\n * Run the full calibration pipeline:\n * 1. Read all corrections\n * 2. Send to LLM for clustering and rule synthesis\n * 3. Merge with existing rules\n * 4. Write updated index\n */\nexport async function runCalibrationConsolidation(options: {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n /**\n * When set, a week whose reinforcement is already in the index is returned\n * as-is. Weekly synthesis passes the ISO week id so a retry after a later\n * artifact failure does not count the same corrections twice.\n */\n idempotencyKey?: string;\n}): Promise<CalibrationRule[]> {\n try {\n const idempotencyKey = appliedCalibrationWeekId(options.idempotencyKey);\n const existingIndex = await readCalibrationIndex(options.memoryDir);\n if (idempotencyKey && (existingIndex.appliedWeekIds ?? []).includes(idempotencyKey)) {\n log.debug(`[calibration] week ${idempotencyKey} already applied — skipping`);\n return existingIndex.rules;\n }\n\n const llm = resolveCalibrationChatClient(options);\n if (!llm) return [];\n\n const corrections = await readCorrections(options.memoryDir);\n if (corrections.length < 3) {\n log.info(`[calibration] only ${corrections.length} corrections — need at least 3`);\n return [];\n }\n\n const newRules = await synthesizeCalibrationRules(\n corrections,\n llm,\n existingIndex.rules,\n options.gatewayAgentId,\n options.modelChain\n );\n if (newRules.length === 0) {\n log.info(\"[calibration] no new calibration rules synthesized\");\n return existingIndex.rules;\n }\n\n // Merge: keep existing rules, add new ones (deduplicate by id)\n const ruleMap = new Map(existingIndex.rules.map((r) => [r.id, r]));\n for (const rule of newRules) {\n if (ruleMap.has(rule.id)) {\n // Reinforce existing rule\n const existing = ruleMap.get(rule.id)!;\n existing.lastReinforcedAt = new Date().toISOString();\n existing.evidenceCount += rule.evidenceCount;\n existing.confidence = Math.min(1, existing.confidence + 0.05);\n } else {\n ruleMap.set(rule.id, rule);\n }\n }\n\n const allRules = [...ruleMap.values()];\n await writeCalibrationIndex(options.memoryDir, withAppliedCalibrationWeek({\n rules: allRules,\n updatedAt: existingIndex.updatedAt,\n totalCorrectionsAnalyzed: corrections.length,\n appliedWeekIds: existingIndex.appliedWeekIds,\n }, idempotencyKey));\n\n log.debug(`[calibration] synthesized ${newRules.length} new rule(s), ${allRules.length} total`);\n return allRules;\n } catch (error) {\n log.warn(\n `[calibration] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`\n );\n return [];\n }\n}\n\n/**\n * Standalone entry point for calibration consolidation that can be called\n * independently of weekly compounding. The compounding engine's\n * `synthesizeWeekly()` is one trigger, but orchestrators or periodic\n * maintenance jobs should call this directly so calibration is not gated\n * on weekly compounding being enabled.\n */\nexport async function runCalibrationIfEnabled(options: {\n memoryDir: string;\n calibrationEnabled: boolean;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n}): Promise<CalibrationRule[]> {\n if (!options.calibrationEnabled) {\n return [];\n }\n return runCalibrationConsolidation({\n memoryDir: options.memoryDir,\n gatewayConfig: options.gatewayConfig,\n gatewayAgentId: options.gatewayAgentId,\n modelChain: options.modelChain,\n workspaceDir: options.workspaceDir,\n pluginConfig: options.pluginConfig,\n });\n}\n\n/**\n * Get calibration rules for recall injection.\n * Reads the pre-computed calibration index.\n */\nexport async function getCalibrationRulesForRecall(\n memoryDir: string,\n): Promise<CalibrationRule[]> {\n const index = await readCalibrationIndex(memoryDir);\n return index.rules;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,gBAAgB;AAChC,OAAO,UAAU;AAyCjB,SAAS,eAAe,WAA2B;AACjD,SAAO,KAAK,KAAK,WAAW,SAAS,aAAa;AACpD;AAEA,SAAS,qBAAqB,WAA2B;AACvD,SAAO,KAAK,KAAK,eAAe,SAAS,GAAG,wBAAwB;AACtE;AAGA,IAAM,6BAA6B;AAE5B,SAAS,yBAAyB,OAAoC;AAC3E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,KAAK,QAAQ,SAAS,2BAA4B,QAAO;AAChF,SAAO;AACT;AAEA,eAAsB,qBAAqB,WAA8C;AACvF,MAAI;AACF,UAAM,MAAM,KAAK,MAAM,MAAM,SAAS,qBAAqB,SAAS,GAAG,MAAM,CAAC;AAC9E,UAAM,iBAAiB,wBAAwB,IAAI,gBAAgB,IAAI,aAAa;AACpF,WAAO;AAAA,MACL,OAAO,MAAM,QAAQ,IAAI,KAAK,IAAI,IAAI,QAAQ,CA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O;AAAA,MACP,WAAW,cAAc;AAAA,MACzB,0BAA0B,YAAY;AAAA,MACtC,gBAAgB,cAAc;AAAA,IAChC,GAAG,cAAc,CAAC;AAElB,QAAI,MAAM,6BAA6B,SAAS,MAAM,iBAAiB,SAAS,MAAM,QAAQ;AAC9F,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI;AAAA,MACF,mDAAmD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IAC3G;AACA,WAAO,CAAC;AAAA,EACV;AACF;AASA,eAAsB,wBAAwB,SAQf;AAC7B,MAAI,CAAC,QAAQ,oBAAoB;AAC/B,WAAO,CAAC;AAAA,EACV;AACA,SAAO,4BAA4B;AAAA,IACjC,WAAW,QAAQ;AAAA,IACnB,eAAe,QAAQ;AAAA,IACvB,gBAAgB,QAAQ;AAAA,IACxB,YAAY,QAAQ;AAAA,IACpB,cAAc,QAAQ;AAAA,IACtB,cAAc,QAAQ;AAAA,EACxB,CAAC;AACH;AAMA,eAAsB,6BACpB,WAC4B;AAC5B,QAAM,QAAQ,MAAM,qBAAqB,SAAS;AAClD,SAAO,MAAM;AACf;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/calibration.ts"],"sourcesContent":["/**\n * calibration.ts — Prediction-Error-Driven Model-User Calibration\n *\n * Analyzes patterns in user corrections to identify systematic miscalibration\n * between the model's predictions and the user's actual expectations.\n * During consolidation, replays chains of similar corrections through an LLM\n * to synthesize CalibrationRules that adjust model behavior for this specific user.\n *\n * Inspired by:\n * - Cerebellar motor calibration (prediction errors drive lasting adjustments)\n * - Temporal difference learning (dopamine signals prediction error)\n * - Tesla FSD shadow mode (divergence between prediction and reality = training signal)\n */\n\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { resolveLocalLlmCapabilities } from \"./capabilities.js\";\nimport { OUTPUT_LANGUAGE_POLICY } from \"./extraction-prompt.js\";\nimport { FallbackLlmClient } from \"./fallback-llm.js\";\nimport { listJsonFiles } from \"./json-store.js\";\nimport { isMacOsReplicationJunkBasename } from \"./utils/macos-replication-junk.js\";\nimport { LocalLlmClient } from \"./local-llm.js\";\nimport { log } from \"./logger.js\";\nimport { writeFileAtomically } from \"./maintenance/atomic-file.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, PluginConfig } from \"./types.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CalibrationRule {\n id: string;\n ruleType: \"model_tendency\" | \"user_expectation\" | \"scope_boundary\" | \"verification_required\";\n condition: string;\n modelTendency: string;\n userExpectation: string;\n calibration: string;\n confidence: number;\n evidenceCount: number;\n evidenceCorrectionIds: string[];\n createdAt: string;\n lastReinforcedAt: string;\n}\n\nexport interface CalibrationIndex {\n rules: CalibrationRule[];\n updatedAt: string;\n totalCorrectionsAnalyzed: number;\n /**\n * Weeks whose rule reinforcement is already committed. A retry of any of\n * these weeks must not increment `evidenceCount` again. Older indexes\n * persisted a single `appliedWeekId`; reads fold it into this list.\n */\n appliedWeekIds?: string[];\n}\n\n// ─── Storage ─────────────────────────────────────────────────────────────────\n\nfunction calibrationDir(memoryDir: string): string {\n return path.join(memoryDir, \"state\", \"calibration\");\n}\n\nfunction calibrationIndexPath(memoryDir: string): string {\n return path.join(calibrationDir(memoryDir), \"calibration-index.json\");\n}\n\n/** Week ids are short (`YYYY-Www`). Longer values are not used as stamps. */\nconst MAX_APPLIED_WEEK_ID_LENGTH = 32;\n\nexport function appliedCalibrationWeekId(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (trimmed.length === 0 || trimmed.length > MAX_APPLIED_WEEK_ID_LENGTH) return undefined;\n return trimmed;\n}\n\nexport async function readCalibrationIndex(memoryDir: string): Promise<CalibrationIndex> {\n try {\n const raw = JSON.parse(await readFile(calibrationIndexPath(memoryDir), \"utf8\"));\n const appliedWeekIds = normalizeAppliedWeekIds(raw.appliedWeekIds, raw.appliedWeekId);\n return {\n rules: Array.isArray(raw.rules) ? raw.rules : [],\n updatedAt: typeof raw.updatedAt === \"string\" ? raw.updatedAt : new Date().toISOString(),\n totalCorrectionsAnalyzed: typeof raw.totalCorrectionsAnalyzed === \"number\" ? raw.totalCorrectionsAnalyzed : 0,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n } catch {\n return { rules: [], updatedAt: new Date().toISOString(), totalCorrectionsAnalyzed: 0 };\n }\n}\n\nfunction normalizeAppliedWeekIds(list: unknown, additional: unknown): string[] {\n const weeks: string[] = [];\n if (Array.isArray(list)) {\n for (const entry of list) {\n const week = appliedCalibrationWeekId(entry);\n if (week && !weeks.includes(week)) weeks.push(week);\n }\n }\n const extra = appliedCalibrationWeekId(additional);\n if (extra && !weeks.includes(extra)) weeks.push(extra);\n return weeks;\n}\n\n/**\n * Attach the week stamp to the index that will be written with the reinforced\n * rules. The stamp and the evidence increment commit together. Every\n * previously applied week stays in the list so an out-of-order retry of an\n * older week is still recognized as already applied.\n */\nexport function withAppliedCalibrationWeek(\n index: CalibrationIndex,\n idempotencyKey: string | undefined,\n): CalibrationIndex {\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, idempotencyKey);\n return {\n rules: index.rules,\n updatedAt: index.updatedAt,\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n}\n\nasync function writeCalibrationIndex(memoryDir: string, index: CalibrationIndex): Promise<void> {\n const dir = calibrationDir(memoryDir);\n await mkdir(dir, { recursive: true });\n const appliedWeekIds = normalizeAppliedWeekIds(index.appliedWeekIds, undefined);\n const stamped: CalibrationIndex = {\n rules: index.rules,\n updatedAt: new Date().toISOString(),\n totalCorrectionsAnalyzed: index.totalCorrectionsAnalyzed,\n ...(appliedWeekIds.length > 0 ? { appliedWeekIds } : {}),\n };\n await writeFileAtomically(calibrationIndexPath(memoryDir), JSON.stringify(stamped, null, 2));\n}\n\n// ─── Correction Reading ──────────────────────────────────────────────────────\n\nexport interface CorrectionMemory {\n id: string;\n content: string;\n created: string;\n confidence: number;\n entityRefs: string[];\n tags: string[];\n}\n\nconst CALIBRATION_RULE_TYPES = new Set([\n \"model_tendency\",\n \"user_expectation\",\n \"scope_boundary\",\n \"verification_required\",\n]);\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidenceIds(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction nonEmptyString(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Exported for entity-contamination R-11 regression coverage (#682\n * PR 2/3 — codex review). Tests can drive the real correction-reading\n * path instead of duplicating the regex inline, so calibration parser\n * regressions surface via the contamination suite.\n */\nexport async function readCalibrationCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrections(memoryDir: string): Promise<CorrectionMemory[]> {\n return readCorrectionsImpl(memoryDir);\n}\n\nasync function readCorrectionsImpl(memoryDir: string): Promise<CorrectionMemory[]> {\n const correctionsDir = path.join(memoryDir, \"corrections\");\n const files = await listJsonFiles(correctionsDir).catch(() => {\n // Corrections might be in facts/ directories too\n return [] as string[];\n });\n\n // Also scan facts directories for correction-category files\n const factsDir = path.join(memoryDir, \"facts\");\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const dayDirs = (await readdir(factsDir)).filter((d: string) => /^\\d{4}-\\d{2}-\\d{2}$/.test(d));\n for (const day of dayDirs) {\n const dayPath = path.join(factsDir, day);\n const dayFiles = (await readdir(dayPath))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.startsWith(\"correction-\") && f.endsWith(\".md\"))\n .map((f: string) => path.join(dayPath, f));\n files.push(...dayFiles);\n }\n } catch {\n // facts dir might not exist\n }\n\n // Also check the dedicated corrections directory\n try {\n const { readdir } = await import(\"node:fs/promises\");\n const corrFiles = (await readdir(correctionsDir))\n .filter((f: string) => !isMacOsReplicationJunkBasename(f) && f.endsWith(\".md\"))\n .map((f: string) => path.join(correctionsDir, f));\n files.push(...corrFiles);\n } catch {\n // corrections dir might not exist\n }\n\n const corrections: CorrectionMemory[] = [];\n const seen = new Set<string>();\n\n for (const filePath of files) {\n try {\n const raw = await readFile(filePath, \"utf8\");\n\n // Parse frontmatter\n const fmMatch = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n if (!fmMatch) continue;\n\n const content = fmMatch[2].trim();\n if (!content || content.length < 10) continue;\n\n // Extract id from frontmatter\n const idMatch = fmMatch[1].match(/^id:\\s*(.+)$/m);\n const id = idMatch?.[1]?.trim() ?? path.basename(filePath, \".md\");\n\n if (seen.has(id)) continue;\n seen.add(id);\n\n const confMatch = fmMatch[1].match(/^confidence:\\s*(.+)$/m);\n const confidence = confMatch ? parseFloat(confMatch[1]) : 0.9;\n\n const entityMatch = fmMatch[1].match(/^entityRef:\\s*(.+)$/m);\n const entityRefs = entityMatch ? [entityMatch[1].trim()] : [];\n\n corrections.push({ id, content, created: \"\", confidence, entityRefs, tags: [] });\n } catch {\n // skip unparseable files\n }\n }\n\n return corrections;\n}\n\n// ─── LLM-Assisted Clustering and Replay ──────────────────────────────────────\n\nexport const CLUSTER_PROMPT = `You are analyzing user corrections to an AI assistant. Each correction represents a moment where the assistant's prediction of what the user wanted was WRONG.\n\nYour job: Group these corrections into clusters where the SAME TYPE of misunderstanding is happening. Then for each cluster, synthesize a CalibrationRule.\n\nA CalibrationRule describes:\n- condition: When does this type of mistake happen?\n- modelTendency: What does the model tend to assume or do wrong?\n- userExpectation: What does the user actually want instead?\n- calibration: How should the model adjust its behavior?\n- ruleType: One of \"model_tendency\", \"user_expectation\", \"scope_boundary\", \"verification_required\"\n\nFocus on PATTERNS, not individual corrections. A cluster needs at least 2 corrections to be worth a rule.\n${OUTPUT_LANGUAGE_POLICY}\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\n \"ruleType\": \"model_tendency\",\n \"condition\": \"When discussing project scope or task boundaries\",\n \"modelTendency\": \"The model tends to assume broader scope than the user intends\",\n \"userExpectation\": \"The user prefers narrow, specific task definitions and wants to be asked before scope expansion\",\n \"calibration\": \"When uncertain about scope, ask for clarification rather than assuming. Default to the narrower interpretation.\",\n \"confidence\": 0.85,\n \"evidenceIds\": [\"correction-id-1\", \"correction-id-2\"]\n }\n ]\n}`;\n\ninterface CalibrationChatClient {\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: {\n temperature?: number;\n maxTokens?: number;\n agentId?: string;\n modelChain?: AgentPersonaModelConfig;\n }\n ): Promise<{ content?: string | null } | null>;\n}\n\ninterface CalibrationLlmOptions {\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n /** Plugin config. Supplies `localLlm*` settings when the gateway chain is empty. */\n pluginConfig?: PluginConfig;\n}\n\nfunction resolveCalibrationChatClient(options: CalibrationLlmOptions): CalibrationChatClient | null {\n const gateway = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n if (gateway.isAvailable({ agentId: options.gatewayAgentId, modelChain: options.modelChain })) {\n return gateway;\n }\n const pluginConfig = options.pluginConfig;\n if (pluginConfig && resolveLocalLlmCapabilities(pluginConfig).localLlm) {\n log.info(`[calibration] using configured local LLM (model=${pluginConfig.localLlmModel})`);\n const local = new LocalLlmClient(pluginConfig);\n return {\n chatCompletion(messages, chatOptions) {\n return local.chatCompletion(messages, {\n temperature: chatOptions?.temperature,\n maxTokens: chatOptions?.maxTokens,\n });\n },\n };\n }\n log.warn(\"[calibration] no LLM available — skipping consolidation\");\n return null;\n}\n\nexport async function synthesizeCalibrationRules(\n corrections: CorrectionMemory[],\n llm: CalibrationChatClient,\n existingRules: CalibrationRule[],\n agentId?: string,\n modelChain?: AgentPersonaModelConfig\n): Promise<CalibrationRule[]> {\n if (corrections.length < 2) return [];\n\n // Format corrections for the LLM\n const correctionText = corrections\n .slice(0, 50) // limit to avoid huge prompts\n .map((c, i) => `[${c.id}] ${c.content}`)\n .join(\"\\n\\n\");\n\n const existingRulesText =\n existingRules.length > 0\n ? `\\n\\nExisting calibration rules (avoid duplicating these):\\n${existingRules.map((r) => `- ${r.condition}: ${r.calibration}`).join(\"\\n\")}`\n : \"\";\n\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CLUSTER_PROMPT },\n {\n role: \"user\",\n content: `Here are ${corrections.length} corrections from this user:\\n\\n${correctionText}${existingRulesText}`,\n },\n ],\n { temperature: 0.3, maxTokens: 3000, agentId, modelChain }\n );\n\n if (!response?.content) return [];\n\n try {\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n if (!Array.isArray(parsed.rules)) return [];\n\n const now = new Date().toISOString();\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n return rawRules\n .map((r: unknown): CalibrationRule | undefined => {\n if (!r || typeof r !== \"object\" || Array.isArray(r)) return undefined;\n const raw = r as Record<string, unknown>;\n const ruleType = nonEmptyString(raw.ruleType);\n const condition = nonEmptyString(raw.condition);\n const modelTendency = nonEmptyString(raw.modelTendency);\n const calibration = nonEmptyString(raw.calibration);\n const confidence = parseConfidence(raw.confidence);\n if (\n !ruleType ||\n !CALIBRATION_RULE_TYPES.has(ruleType) ||\n !condition ||\n !modelTendency ||\n !calibration ||\n confidence === undefined\n ) {\n return undefined;\n }\n const evidenceCorrectionIds = parseEvidenceIds(raw.evidenceIds);\n return {\n id: `cal-${createHash(\"sha256\")\n .update(condition + calibration)\n .digest(\"hex\")\n .slice(0, 12)}`,\n ruleType: ruleType as CalibrationRule[\"ruleType\"],\n condition,\n modelTendency,\n userExpectation: nonEmptyString(raw.userExpectation) ?? \"\",\n calibration,\n confidence,\n evidenceCount: evidenceCorrectionIds.length,\n evidenceCorrectionIds,\n createdAt: now,\n lastReinforcedAt: now,\n };\n })\n .filter((rule): rule is CalibrationRule => !!rule);\n } catch {\n log.warn(\"[calibration] failed to parse LLM response\");\n return [];\n }\n}\n\n// ─── Recall Section ──────────────────────────────────────────────────────────\n\n/**\n * Build a recall section from calibration rules relevant to the current query.\n * Uses the LLM to select which rules apply to the current context.\n */\nexport function buildCalibrationRecallSection(\n rules: CalibrationRule[],\n query: string,\n maxChars: number = 1200,\n): string | null {\n if (rules.length === 0) return null;\n\n // Simple relevance: include all rules (they're already filtered to this user)\n // In production, could use embedding similarity to filter\n const lines: string[] = [\n \"## Model Calibration (learned from past corrections)\",\n \"\",\n \"Adjustments for this specific user, learned from patterns in their corrections:\",\n \"\",\n ];\n\n let totalChars = lines.join(\"\\n\").length;\n\n for (const rule of rules) {\n const line = `- **${rule.condition}**: ${rule.modelTendency} → Instead: ${rule.calibration}`;\n if (totalChars + line.length + 1 > maxChars) break;\n lines.push(line);\n totalChars += line.length + 1;\n }\n\n if (lines.length <= 4) return null;\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Options weekly compounding passes into calibration. Gateway agent and task\n * chain fields stay limited to `modelSource: \"gateway\"`. `pluginConfig` carries\n * the `localLlm*` settings used when that chain is empty.\n */\nexport function calibrationConsolidationInput(config: PluginConfig): {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig: PluginConfig;\n} {\n const gateway = config.modelSource === \"gateway\";\n return {\n memoryDir: config.memoryDir,\n gatewayConfig: config.gatewayConfig,\n gatewayAgentId: gateway ? (config.gatewayAgentId || undefined) : undefined,\n modelChain: gateway ? config.taskModelChain : undefined,\n workspaceDir: config.workspaceDir,\n pluginConfig: config,\n };\n}\n\n/**\n * Run the full calibration pipeline:\n * 1. Read all corrections\n * 2. Send to LLM for clustering and rule synthesis\n * 3. Merge with existing rules\n * 4. Write updated index\n */\nexport async function runCalibrationConsolidation(options: {\n memoryDir: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n /**\n * When set, a week whose reinforcement is already in the index is returned\n * as-is. Weekly synthesis passes the ISO week id so a retry after a later\n * artifact failure does not count the same corrections twice.\n */\n idempotencyKey?: string;\n}): Promise<CalibrationRule[]> {\n try {\n const idempotencyKey = appliedCalibrationWeekId(options.idempotencyKey);\n const existingIndex = await readCalibrationIndex(options.memoryDir);\n if (idempotencyKey && (existingIndex.appliedWeekIds ?? []).includes(idempotencyKey)) {\n log.debug(`[calibration] week ${idempotencyKey} already applied — skipping`);\n return existingIndex.rules;\n }\n\n const llm = resolveCalibrationChatClient(options);\n if (!llm) return [];\n\n const corrections = await readCorrections(options.memoryDir);\n if (corrections.length < 3) {\n log.info(`[calibration] only ${corrections.length} corrections — need at least 3`);\n return [];\n }\n\n const newRules = await synthesizeCalibrationRules(\n corrections,\n llm,\n existingIndex.rules,\n options.gatewayAgentId,\n options.modelChain\n );\n if (newRules.length === 0) {\n log.info(\"[calibration] no new calibration rules synthesized\");\n return existingIndex.rules;\n }\n\n // Merge: keep existing rules, add new ones (deduplicate by id)\n const ruleMap = new Map(existingIndex.rules.map((r) => [r.id, r]));\n for (const rule of newRules) {\n if (ruleMap.has(rule.id)) {\n // Reinforce existing rule\n const existing = ruleMap.get(rule.id)!;\n existing.lastReinforcedAt = new Date().toISOString();\n existing.evidenceCount += rule.evidenceCount;\n existing.confidence = Math.min(1, existing.confidence + 0.05);\n } else {\n ruleMap.set(rule.id, rule);\n }\n }\n\n const allRules = [...ruleMap.values()];\n await writeCalibrationIndex(options.memoryDir, withAppliedCalibrationWeek({\n rules: allRules,\n updatedAt: existingIndex.updatedAt,\n totalCorrectionsAnalyzed: corrections.length,\n appliedWeekIds: existingIndex.appliedWeekIds,\n }, idempotencyKey));\n\n log.debug(`[calibration] synthesized ${newRules.length} new rule(s), ${allRules.length} total`);\n return allRules;\n } catch (error) {\n log.warn(\n `[calibration] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`\n );\n return [];\n }\n}\n\n/**\n * Standalone entry point for calibration consolidation that can be called\n * independently of weekly compounding. The compounding engine's\n * `synthesizeWeekly()` is one trigger, but orchestrators or periodic\n * maintenance jobs should call this directly so calibration is not gated\n * on weekly compounding being enabled.\n */\nexport async function runCalibrationIfEnabled(options: {\n memoryDir: string;\n calibrationEnabled: boolean;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n}): Promise<CalibrationRule[]> {\n if (!options.calibrationEnabled) {\n return [];\n }\n return runCalibrationConsolidation({\n memoryDir: options.memoryDir,\n gatewayConfig: options.gatewayConfig,\n gatewayAgentId: options.gatewayAgentId,\n modelChain: options.modelChain,\n workspaceDir: options.workspaceDir,\n pluginConfig: options.pluginConfig,\n });\n}\n\n/**\n * Get calibration rules for recall injection.\n * Reads the pre-computed calibration index.\n */\nexport async function getCalibrationRulesForRecall(\n memoryDir: string,\n): Promise<CalibrationRule[]> {\n const index = await readCalibrationIndex(memoryDir);\n return index.rules;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,gBAAgB;AAChC,OAAO,UAAU;AAyCjB,SAAS,eAAe,WAA2B;AACjD,SAAO,KAAK,KAAK,WAAW,SAAS,aAAa;AACpD;AAEA,SAAS,qBAAqB,WAA2B;AACvD,SAAO,KAAK,KAAK,eAA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from "./chunk-GZXXPCWJ.js";
|
|
5
5
|
import {
|
|
6
6
|
buildExtensionsBlockForConsolidation
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GCZHKBY2.js";
|
|
8
8
|
import "./chunk-5JMAGU26.js";
|
|
9
9
|
import "./chunk-B7RWBZXW.js";
|
|
10
10
|
import {
|
|
11
11
|
runPostConsolidationMaterialize
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JZIZBJCW.js";
|
|
13
13
|
import "./chunk-3UXOZBHV.js";
|
|
14
14
|
import "./chunk-PIWFNPQT.js";
|
|
15
15
|
import "./chunk-TOTT6S2V.js";
|
|
@@ -19,7 +19,7 @@ import "./chunk-QDW3E4RD.js";
|
|
|
19
19
|
import {
|
|
20
20
|
resolveCausalTrajectoryStoreDir
|
|
21
21
|
} from "./chunk-C2RW36YR.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-IHS2UGYM.js";
|
|
23
23
|
import "./chunk-UHVXE24Y.js";
|
|
24
24
|
import "./chunk-TRMJ6BYC.js";
|
|
25
25
|
import "./chunk-V4JZCTMK.js";
|
|
@@ -40,11 +40,11 @@ import "./chunk-A7Q43EUZ.js";
|
|
|
40
40
|
import "./chunk-S2V7RUCL.js";
|
|
41
41
|
import "./chunk-PPUNC7UX.js";
|
|
42
42
|
import "./chunk-X3724WL4.js";
|
|
43
|
-
import "./chunk-MRPOZBJC.js";
|
|
44
43
|
import "./chunk-S2HLHAZ4.js";
|
|
44
|
+
import "./chunk-MRPOZBJC.js";
|
|
45
45
|
import "./chunk-DM2T26WE.js";
|
|
46
46
|
import "./chunk-LDXUBPMO.js";
|
|
47
|
-
import "./chunk-
|
|
47
|
+
import "./chunk-EPOYPPOW.js";
|
|
48
48
|
import "./chunk-AAD2ZS6P.js";
|
|
49
49
|
import "./chunk-FF6N7BXC.js";
|
|
50
50
|
import "./chunk-JNIVZNIB.js";
|
|
@@ -75,13 +75,13 @@ import "./chunk-42JKGUFJ.js";
|
|
|
75
75
|
import "./chunk-23G5P7TA.js";
|
|
76
76
|
import {
|
|
77
77
|
FallbackLlmClient
|
|
78
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-UIDWASOS.js";
|
|
79
79
|
import "./chunk-I55KAVET.js";
|
|
80
80
|
import "./chunk-L2EXJQJP.js";
|
|
81
81
|
import "./chunk-45GF7Y3V.js";
|
|
82
82
|
import {
|
|
83
83
|
fallbackLlmRuntimeContextFromConfig
|
|
84
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-CU5TILGD.js";
|
|
85
85
|
import "./chunk-E2AWJ7KQ.js";
|
|
86
86
|
import "./chunk-Z7L72ZHL.js";
|
|
87
87
|
import "./chunk-4O4TKIXQ.js";
|
|
@@ -89,7 +89,7 @@ import "./chunk-YCVB7X56.js";
|
|
|
89
89
|
import "./chunk-PQVCH2AE.js";
|
|
90
90
|
import "./chunk-PJKTFXE2.js";
|
|
91
91
|
import "./chunk-W5BIQOAJ.js";
|
|
92
|
-
import "./chunk-
|
|
92
|
+
import "./chunk-42KSEX6C.js";
|
|
93
93
|
import "./chunk-YBA52OKG.js";
|
|
94
94
|
import "./chunk-5LRV557D.js";
|
|
95
95
|
import "./chunk-BT7NVCML.js";
|
|
@@ -33,9 +33,20 @@ var EXTRACTION_PROVIDER_JSON_SCHEMA_WITHOUT_SPAN = omitFactSpan(
|
|
|
33
33
|
function extractionProviderJsonSchema(spanMode = "off") {
|
|
34
34
|
return spanMode === "off" ? EXTRACTION_PROVIDER_JSON_SCHEMA_WITHOUT_SPAN : EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN;
|
|
35
35
|
}
|
|
36
|
+
function extractionProviderResponseFormat(spanMode = "off") {
|
|
37
|
+
return {
|
|
38
|
+
type: "json_schema",
|
|
39
|
+
json_schema: {
|
|
40
|
+
name: "extraction_result",
|
|
41
|
+
schema: extractionProviderJsonSchema(spanMode),
|
|
42
|
+
strict: false
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
36
46
|
|
|
37
47
|
export {
|
|
38
48
|
applySpanMode,
|
|
39
|
-
extractionProviderJsonSchema
|
|
49
|
+
extractionProviderJsonSchema,
|
|
50
|
+
extractionProviderResponseFormat
|
|
40
51
|
};
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-23ZLN5X6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extraction-span-wire.ts"],"sourcesContent":["/**\n * Extraction seam for span mode (issue #2333 leftover slice + #2952).\n *\n * Default off. Callers pass `enabled` to `applySpanMode`. The provider JSON\n * schema is mode-aware so off-mode structured output cannot advertise `span`.\n */\n\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport type { ExtractionSpanConfig } from \"./extraction-span-config.js\";\nimport { parseSpanOffsets, type ParsedSpan } from \"./extraction-span.js\";\nimport { ExtractionProviderOutputSchema } from \"./schemas.js\";\n\nexport function applySpanMode(opts: {\n enabled?: boolean | 0 | 1;\n text: string;\n start: number;\n end: number;\n}): ParsedSpan {\n return parseSpanOffsets(opts.text, { start: opts.start, end: opts.end }, opts.enabled);\n}\n\nconst JSON_SCHEMA_OPTS = { $refStrategy: \"none\" as const, effectStrategy: \"input\" as const };\n\nconst EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN = zodToJsonSchema(\n ExtractionProviderOutputSchema,\n JSON_SCHEMA_OPTS,\n) as Record<string, unknown>;\n\ntype FactItems = {\n properties?: Record<string, unknown>;\n required?: string[];\n};\n\nfunction omitFactSpan(schema: Record<string, unknown>): Record<string, unknown> {\n const clone = structuredClone(schema) as {\n properties?: { facts?: { items?: FactItems } };\n };\n const items = clone.properties?.facts?.items;\n if (!items?.properties || !(\"span\" in items.properties)) {\n throw new Error(\"extraction provider schema is missing facts.items.properties.span\");\n }\n delete items.properties.span;\n if (Array.isArray(items.required)) {\n items.required = items.required.filter((key) => key !== \"span\");\n }\n return clone as Record<string, unknown>;\n}\n\nconst EXTRACTION_PROVIDER_JSON_SCHEMA_WITHOUT_SPAN = omitFactSpan(\n EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN,\n);\n\n/** Provider JSON schema: `span` is present in on/shadow, absent in off. */\nexport function extractionProviderJsonSchema(\n spanMode: ExtractionSpanConfig[\"spanMode\"] = \"off\",\n): Record<string, unknown> {\n return spanMode === \"off\"\n ? EXTRACTION_PROVIDER_JSON_SCHEMA_WITHOUT_SPAN\n : EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN;\n}\n"],"mappings":";;;;;;;;AAOA,SAAS,uBAAuB;AAKzB,SAAS,cAAc,MAKf;AACb,SAAO,iBAAiB,KAAK,MAAM,EAAE,OAAO,KAAK,OAAO,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO;AACvF;AAEA,IAAM,mBAAmB,EAAE,cAAc,QAAiB,gBAAgB,QAAiB;AAE3F,IAAM,4CAA4C;AAAA,EAChD;AAAA,EACA;AACF;AAOA,SAAS,aAAa,QAA0D;AAC9E,QAAM,QAAQ,gBAAgB,MAAM;AAGpC,QAAM,QAAQ,MAAM,YAAY,OAAO;AACvC,MAAI,CAAC,OAAO,cAAc,EAAE,UAAU,MAAM,aAAa;AACvD,UAAM,IAAI,MAAM,mEAAmE;AAAA,EACrF;AACA,SAAO,MAAM,WAAW;AACxB,MAAI,MAAM,QAAQ,MAAM,QAAQ,GAAG;AACjC,UAAM,WAAW,MAAM,SAAS,OAAO,CAAC,QAAQ,QAAQ,MAAM;AAAA,EAChE;AACA,SAAO;AACT;AAEA,IAAM,+CAA+C;AAAA,EACnD;AACF;AAGO,SAAS,6BACd,WAA6C,OACpB;AACzB,SAAO,aAAa,QAChB,+CACA;AACN;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/extraction-span-wire.ts"],"sourcesContent":["/**\n * Extraction seam for span mode (issue #2333 leftover slice + #2952).\n *\n * Default off. Callers pass `enabled` to `applySpanMode`. The provider JSON\n * schema is mode-aware so off-mode structured output cannot advertise `span`.\n */\n\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\nimport type { ExtractionSpanConfig } from \"./extraction-span-config.js\";\nimport { parseSpanOffsets, type ParsedSpan } from \"./extraction-span.js\";\nimport { ExtractionProviderOutputSchema } from \"./schemas.js\";\n\nexport function applySpanMode(opts: {\n enabled?: boolean | 0 | 1;\n text: string;\n start: number;\n end: number;\n}): ParsedSpan {\n return parseSpanOffsets(opts.text, { start: opts.start, end: opts.end }, opts.enabled);\n}\n\nconst JSON_SCHEMA_OPTS = { $refStrategy: \"none\" as const, effectStrategy: \"input\" as const };\n\nconst EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN = zodToJsonSchema(\n ExtractionProviderOutputSchema,\n JSON_SCHEMA_OPTS,\n) as Record<string, unknown>;\n\ntype FactItems = {\n properties?: Record<string, unknown>;\n required?: string[];\n};\n\nfunction omitFactSpan(schema: Record<string, unknown>): Record<string, unknown> {\n const clone = structuredClone(schema) as {\n properties?: { facts?: { items?: FactItems } };\n };\n const items = clone.properties?.facts?.items;\n if (!items?.properties || !(\"span\" in items.properties)) {\n throw new Error(\"extraction provider schema is missing facts.items.properties.span\");\n }\n delete items.properties.span;\n if (Array.isArray(items.required)) {\n items.required = items.required.filter((key) => key !== \"span\");\n }\n return clone as Record<string, unknown>;\n}\n\nconst EXTRACTION_PROVIDER_JSON_SCHEMA_WITHOUT_SPAN = omitFactSpan(\n EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN,\n);\n\n/** Provider JSON schema: `span` is present in on/shadow, absent in off. */\nexport function extractionProviderJsonSchema(\n spanMode: ExtractionSpanConfig[\"spanMode\"] = \"off\",\n): Record<string, unknown> {\n return spanMode === \"off\"\n ? EXTRACTION_PROVIDER_JSON_SCHEMA_WITHOUT_SPAN\n : EXTRACTION_PROVIDER_JSON_SCHEMA_WITH_SPAN;\n}\n\nexport function extractionProviderResponseFormat(spanMode: ExtractionSpanConfig[\"spanMode\"] = \"off\") {\n return {\n type: \"json_schema\" as const,\n json_schema: {\n name: \"extraction_result\",\n schema: extractionProviderJsonSchema(spanMode),\n strict: false,\n },\n };\n}\n"],"mappings":";;;;;;;;AAOA,SAAS,uBAAuB;AAKzB,SAAS,cAAc,MAKf;AACb,SAAO,iBAAiB,KAAK,MAAM,EAAE,OAAO,KAAK,OAAO,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO;AACvF;AAEA,IAAM,mBAAmB,EAAE,cAAc,QAAiB,gBAAgB,QAAiB;AAE3F,IAAM,4CAA4C;AAAA,EAChD;AAAA,EACA;AACF;AAOA,SAAS,aAAa,QAA0D;AAC9E,QAAM,QAAQ,gBAAgB,MAAM;AAGpC,QAAM,QAAQ,MAAM,YAAY,OAAO;AACvC,MAAI,CAAC,OAAO,cAAc,EAAE,UAAU,MAAM,aAAa;AACvD,UAAM,IAAI,MAAM,mEAAmE;AAAA,EACrF;AACA,SAAO,MAAM,WAAW;AACxB,MAAI,MAAM,QAAQ,MAAM,QAAQ,GAAG;AACjC,UAAM,WAAW,MAAM,SAAS,OAAO,CAAC,QAAQ,QAAQ,MAAM;AAAA,EAChE;AACA,SAAO;AACT;AAEA,IAAM,+CAA+C;AAAA,EACnD;AACF;AAGO,SAAS,6BACd,WAA6C,OACpB;AACzB,SAAO,aAAa,QAChB,+CACA;AACN;AAEO,SAAS,iCAAiC,WAA6C,OAAO;AACnG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,MACX,MAAM;AAAA,MACN,QAAQ,6BAA6B,QAAQ;AAAA,MAC7C,QAAQ;AAAA,IACV;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SupportPassportError,
|
|
3
3
|
getOperation
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-L3IP56F4.js";
|
|
5
5
|
import {
|
|
6
6
|
abortError,
|
|
7
7
|
isAbortError
|
|
@@ -499,4 +499,4 @@ export {
|
|
|
499
499
|
buildSupportPassportPublicRequestHandler,
|
|
500
500
|
composeSupportPassportExternalRequestHandlers
|
|
501
501
|
};
|
|
502
|
-
//# sourceMappingURL=chunk-
|
|
502
|
+
//# sourceMappingURL=chunk-27LPB4NS.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCorpusNamespaceRoots
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JHQAXATW.js";
|
|
4
4
|
import {
|
|
5
5
|
capabilityAllowsNamespace
|
|
6
6
|
} from "./chunk-IG747LRN.js";
|
|
@@ -200,4 +200,4 @@ async function readAggregateExtractionWatermark(options) {
|
|
|
200
200
|
export {
|
|
201
201
|
readAggregateExtractionWatermark
|
|
202
202
|
};
|
|
203
|
-
//# sourceMappingURL=chunk-
|
|
203
|
+
//# sourceMappingURL=chunk-27SAUQ5R.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KJTKLXTH.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IHS2UGYM.js";
|
|
7
7
|
import {
|
|
8
8
|
assertInjectedStorageRooted
|
|
9
9
|
} from "./chunk-P55FACBG.js";
|
|
@@ -260,4 +260,4 @@ export {
|
|
|
260
260
|
backupExistingLedger,
|
|
261
261
|
rebuildMemoryLifecycleLedger
|
|
262
262
|
};
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-2HLMFRZ7.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-TBBDFYXW.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IHS2UGYM.js";
|
|
7
7
|
import {
|
|
8
8
|
bumpMemoryCorpusVersionForDir
|
|
9
9
|
} from "./chunk-M5GVCJSJ.js";
|
|
@@ -769,4 +769,4 @@ export {
|
|
|
769
769
|
listMemoryGovernanceRuns,
|
|
770
770
|
readMemoryGovernanceRunArtifact
|
|
771
771
|
};
|
|
772
|
-
//# sourceMappingURL=chunk-
|
|
772
|
+
//# sourceMappingURL=chunk-33UAWCBN.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rebuildMemoryProjection
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JX32ROLZ.js";
|
|
4
4
|
|
|
5
5
|
// src/convergence-refresh.ts
|
|
6
6
|
async function refreshConvergedNamespaces(namespaces, namespaceSearchRouter, getStorage, searchEnabled) {
|
|
@@ -32,4 +32,4 @@ async function refreshConvergedNamespaces(namespaces, namespaceSearchRouter, get
|
|
|
32
32
|
export {
|
|
33
33
|
refreshConvergedNamespaces
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-36DZ242S.js.map
|