@remnic/core 1.1.12 → 1.1.14
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-cli.d.ts +2 -1
- package/dist/access-cli.js +263 -82
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +26 -60
- package/dist/access-http.js +43 -29
- package/dist/access-mcp.d.ts +24 -6
- package/dist/access-mcp.js +35 -28
- package/dist/access-schema.d.ts +9 -6
- package/dist/access-schema.js +7 -5
- package/dist/access-service-DcCDmNYC.d.ts +1542 -0
- package/dist/access-service.d.ts +25 -7
- package/dist/access-service.js +33 -26
- package/dist/active-memory-bridge.js +2 -2
- package/dist/active-recall.js +11 -3
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/claude-code.d.ts +24 -0
- package/dist/adapters/claude-code.js +9 -0
- package/dist/adapters/codex.d.ts +25 -0
- package/dist/adapters/codex.js +9 -0
- package/dist/adapters/hermes.d.ts +35 -0
- package/dist/adapters/hermes.js +9 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.js +26 -0
- package/dist/adapters/registry.d.ts +20 -0
- package/dist/adapters/registry.js +13 -0
- package/dist/adapters/replit.d.ts +28 -0
- package/dist/adapters/replit.js +9 -0
- package/dist/adapters/types.d.ts +43 -0
- package/dist/adapters/types.js +8 -0
- package/dist/bootstrap.d.ts +20 -5
- package/dist/boxes.d.ts +7 -0
- package/dist/boxes.js +1 -1
- package/dist/briefing.d.ts +5 -3
- package/dist/briefing.js +9 -6
- package/dist/buffer-surprise-report.js +1 -1
- package/dist/buffer.d.ts +18 -4
- package/dist/buffer.js +1 -1
- package/dist/calibration.js +4 -4
- package/dist/capsule-cli.d.ts +4 -4
- package/dist/capsule-cli.js +1 -1
- package/dist/capsule-crypto-5CYAGVC5.js +18 -0
- package/dist/capsule-merge-4MGKE7C5.js +189 -0
- package/dist/causal-behavior.d.ts +8 -28
- package/dist/causal-behavior.js +6 -3
- package/dist/causal-behavior.js.map +1 -1
- package/dist/causal-chain.js +3 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +24 -13
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +3 -3
- package/dist/causal-trajectory.js +1 -1
- package/dist/chunk-25MQ7IHJ.js +427 -0
- package/dist/chunk-25MQ7IHJ.js.map +1 -0
- package/dist/chunk-2F2W355T.js +256 -0
- package/dist/chunk-2F2W355T.js.map +1 -0
- package/dist/chunk-2KI4QFHU.js +228 -0
- package/dist/chunk-2KI4QFHU.js.map +1 -0
- package/dist/chunk-2PRQG7PV.js +86 -0
- package/dist/chunk-2PRQG7PV.js.map +1 -0
- package/dist/chunk-2QR3XXIC.js +2272 -0
- package/dist/chunk-2QR3XXIC.js.map +1 -0
- package/dist/chunk-2WWLHTZY.js +121 -0
- package/dist/chunk-326G7DJK.js +2185 -0
- package/dist/chunk-326G7DJK.js.map +1 -0
- package/dist/chunk-34DQE4KF.js +174 -0
- package/dist/chunk-34DQE4KF.js.map +1 -0
- package/dist/chunk-3APJ5EVB.js +601 -0
- package/dist/chunk-3APJ5EVB.js.map +1 -0
- package/dist/chunk-3HPAPHUK.js +51 -0
- package/dist/chunk-3HPAPHUK.js.map +1 -0
- package/dist/chunk-3JXBXXM2.js +69 -0
- package/dist/chunk-3JXBXXM2.js.map +1 -0
- package/dist/chunk-3KW65B36.js +681 -0
- package/dist/chunk-3KW65B36.js.map +1 -0
- package/dist/chunk-3UXOZBHV.js +20 -0
- package/dist/chunk-3UXOZBHV.js.map +1 -0
- package/dist/chunk-3VAL7ZL2.js +266 -0
- package/dist/chunk-3VAL7ZL2.js.map +1 -0
- package/dist/chunk-3Y4P7RXM.js +31 -0
- package/dist/chunk-3Y4P7RXM.js.map +1 -0
- package/dist/chunk-47VWKCAF.js +273 -0
- package/dist/chunk-47VWKCAF.js.map +1 -0
- package/dist/chunk-4CRG46BG.js +271 -0
- package/dist/chunk-5375UYTQ.js +914 -0
- package/dist/chunk-5375UYTQ.js.map +1 -0
- package/dist/chunk-56K5QLHX.js +506 -0
- package/dist/chunk-56K5QLHX.js.map +1 -0
- package/dist/chunk-5RGLBDQF.js +596 -0
- package/dist/chunk-5RGLBDQF.js.map +1 -0
- package/dist/chunk-5UZXUTVO.js +9 -0
- package/dist/chunk-5UZXUTVO.js.map +1 -0
- package/dist/chunk-65PG43EQ.js +105 -0
- package/dist/chunk-65PG43EQ.js.map +1 -0
- package/dist/chunk-66DHUKLO.js +57 -0
- package/dist/chunk-66DHUKLO.js.map +1 -0
- package/dist/chunk-6FC5EGNV.js +46 -0
- package/dist/chunk-6FC5EGNV.js.map +1 -0
- package/dist/chunk-6H2TESSP.js +62 -0
- package/dist/chunk-6H2TESSP.js.map +1 -0
- package/dist/chunk-6LVVDPJ4.js +32 -0
- package/dist/chunk-6LVVDPJ4.js.map +1 -0
- package/dist/chunk-6RVI47ZR.js +159 -0
- package/dist/chunk-6RVI47ZR.js.map +1 -0
- package/dist/chunk-7AAT6G4Q.js +5117 -0
- package/dist/chunk-7AAT6G4Q.js.map +1 -0
- package/dist/chunk-7DTASS5T.js +29 -0
- package/dist/chunk-7DTASS5T.js.map +1 -0
- package/dist/chunk-7IASACLB.js +596 -0
- package/dist/chunk-7MNMYOFP.js +32 -0
- package/dist/chunk-7MNMYOFP.js.map +1 -0
- package/dist/chunk-7N4KAIGN.js +133 -0
- package/dist/chunk-7N4KAIGN.js.map +1 -0
- package/dist/chunk-7OZ53EXP.js +101 -0
- package/dist/chunk-7OZ53EXP.js.map +1 -0
- package/dist/chunk-7XYTQGCC.js +134 -0
- package/dist/chunk-7XYTQGCC.js.map +1 -0
- package/dist/chunk-A2XUIMJ3.js +341 -0
- package/dist/chunk-A2XUIMJ3.js.map +1 -0
- package/dist/chunk-AGZQD76C.js +201 -0
- package/dist/chunk-AGZQD76C.js.map +1 -0
- package/dist/chunk-APO3DCMU.js +361 -0
- package/dist/chunk-APO3DCMU.js.map +1 -0
- package/dist/chunk-BFBF3XEF.js +283 -0
- package/dist/chunk-BFBF3XEF.js.map +1 -0
- package/dist/chunk-BJ3KMYTB.js +1974 -0
- package/dist/chunk-BJ3KMYTB.js.map +1 -0
- package/dist/chunk-CHEL3SKB.js +6758 -0
- package/dist/chunk-CHEL3SKB.js.map +1 -0
- package/dist/chunk-CQZRLNMV.js +1491 -0
- package/dist/chunk-CQZRLNMV.js.map +1 -0
- package/dist/chunk-D46YSIYX.js +892 -0
- package/dist/chunk-D46YSIYX.js.map +1 -0
- package/dist/chunk-DINWEURR.js +648 -0
- package/dist/chunk-DINWEURR.js.map +1 -0
- package/dist/chunk-DK5LDEQM.js +530 -0
- package/dist/chunk-DK5LDEQM.js.map +1 -0
- package/dist/chunk-DOM4GKSW.js +34 -0
- package/dist/chunk-DOM4GKSW.js.map +1 -0
- package/dist/chunk-EDTHC6UD.js +1075 -0
- package/dist/chunk-EFJ3MQ4V.js +721 -0
- package/dist/chunk-EHRTFRWW.js +89 -0
- package/dist/chunk-EHRTFRWW.js.map +1 -0
- package/dist/chunk-FAJ7FZYM.js +11 -0
- package/dist/chunk-FAJ7FZYM.js.map +1 -0
- package/dist/chunk-FBYESMQ2.js +570 -0
- package/dist/chunk-FDU6HUUL.js +147 -0
- package/dist/chunk-FF4KLI5W.js +99 -0
- package/dist/chunk-FF4KLI5W.js.map +1 -0
- package/dist/chunk-FIT6DMX6.js +310 -0
- package/dist/chunk-FIT6DMX6.js.map +1 -0
- package/dist/chunk-FJ43PRLT.js +272 -0
- package/dist/chunk-FJ43PRLT.js.map +1 -0
- package/dist/chunk-FKFMOY3N.js +32 -0
- package/dist/chunk-FKFMOY3N.js.map +1 -0
- package/dist/chunk-FLTNHQK6.js +262 -0
- package/dist/chunk-FLTNHQK6.js.map +1 -0
- package/dist/chunk-GA454ALV.js +12436 -0
- package/dist/chunk-GA454ALV.js.map +1 -0
- package/dist/chunk-GGKRUQOO.js +228 -0
- package/dist/chunk-GIF42EW3.js +63 -0
- package/dist/chunk-GIF42EW3.js.map +1 -0
- package/dist/chunk-GL6I6MEQ.js +647 -0
- package/dist/chunk-H3ME6L6D.js +709 -0
- package/dist/chunk-H3ME6L6D.js.map +1 -0
- package/dist/chunk-HHLLAQGZ.js +1 -0
- package/dist/chunk-HXXBL2KD.js +2040 -0
- package/dist/chunk-I5V2VDIW.js +219 -0
- package/dist/chunk-I5V2VDIW.js.map +1 -0
- package/dist/chunk-I6K5FBRQ.js +35 -0
- package/dist/chunk-I6K5FBRQ.js.map +1 -0
- package/dist/chunk-ICRIXAP2.js +121 -0
- package/dist/chunk-ICRIXAP2.js.map +1 -0
- package/dist/chunk-J4EB7DNW.js +11 -0
- package/dist/chunk-J4EB7DNW.js.map +1 -0
- package/dist/chunk-JLFA7DQG.js +62 -0
- package/dist/chunk-JLFA7DQG.js.map +1 -0
- package/dist/chunk-KJTKLXTH.js +9 -0
- package/dist/chunk-KJTKLXTH.js.map +1 -0
- package/dist/chunk-KLAO5DGL.js +917 -0
- package/dist/chunk-KLAO5DGL.js.map +1 -0
- package/dist/chunk-KNKUID7G.js +183 -0
- package/dist/chunk-KOSORCJG.js +624 -0
- package/dist/chunk-KOSORCJG.js.map +1 -0
- package/dist/chunk-KUJVMMZQ.js +1262 -0
- package/dist/chunk-KUJVMMZQ.js.map +1 -0
- package/dist/chunk-LCR46JY5.js +123 -0
- package/dist/chunk-LCR46JY5.js.map +1 -0
- package/dist/chunk-LLQ2LLWF.js +148 -0
- package/dist/chunk-LLQ2LLWF.js.map +1 -0
- package/dist/chunk-LPMVBPA3.js +236 -0
- package/dist/chunk-LT3NLYSI.js +50 -0
- package/dist/chunk-LT3NLYSI.js.map +1 -0
- package/dist/chunk-LUDTDZLK.js +287 -0
- package/dist/chunk-LUDTDZLK.js.map +1 -0
- package/dist/chunk-M23FSH32.js +3963 -0
- package/dist/chunk-M23FSH32.js.map +1 -0
- package/dist/chunk-MC26UJIM.js +118 -0
- package/dist/chunk-ME6ESPZU.js +119 -0
- package/dist/chunk-ME6ESPZU.js.map +1 -0
- package/dist/chunk-MGKYQQYF.js +272 -0
- package/dist/chunk-MJFNCJXV.js +66 -0
- package/dist/chunk-MJFNCJXV.js.map +1 -0
- package/dist/chunk-MSWG7JI6.js +237 -0
- package/dist/chunk-MSWG7JI6.js.map +1 -0
- package/dist/chunk-MT25YHYH.js +141 -0
- package/dist/chunk-MT25YHYH.js.map +1 -0
- package/dist/chunk-MT4HVDUZ.js +53 -0
- package/dist/chunk-MY6TPVXW.js +219 -0
- package/dist/chunk-N2D6GXBM.js +267 -0
- package/dist/chunk-N2D6GXBM.js.map +1 -0
- package/dist/chunk-NJ3MJQZX.js +46 -0
- package/dist/chunk-NJ3MJQZX.js.map +1 -0
- package/dist/chunk-NMZY542O.js +335 -0
- package/dist/chunk-NMZY542O.js.map +1 -0
- package/dist/chunk-NNVTUXEB.js +23 -0
- package/dist/chunk-NZL6GGQE.js +375 -0
- package/dist/chunk-NZL6GGQE.js.map +1 -0
- package/dist/chunk-P4NEIHUT.js +108 -0
- package/dist/chunk-P7FMDTKL.js +103 -0
- package/dist/chunk-P7FMDTKL.js.map +1 -0
- package/dist/chunk-PHK3HARR.js +32 -0
- package/dist/chunk-PHK3HARR.js.map +1 -0
- package/dist/chunk-PIRJPV5T.js +98 -0
- package/dist/chunk-PIRJPV5T.js.map +1 -0
- package/dist/chunk-PK7H5L6Y.js +159 -0
- package/dist/chunk-PK7H5L6Y.js.map +1 -0
- package/dist/chunk-PR5FBTFU.js +233 -0
- package/dist/chunk-PR5FBTFU.js.map +1 -0
- package/dist/chunk-PU63GXWS.js +174 -0
- package/dist/chunk-PU63GXWS.js.map +1 -0
- package/dist/chunk-PZIAX57I.js +124 -0
- package/dist/chunk-PZIAX57I.js.map +1 -0
- package/dist/chunk-Q7P4WJDP.js +26 -0
- package/dist/chunk-Q7P4WJDP.js.map +1 -0
- package/dist/chunk-QQUAB63I.js +63 -0
- package/dist/chunk-QQUAB63I.js.map +1 -0
- package/dist/chunk-QRNI5JBH.js +18 -0
- package/dist/chunk-RHY3HH7P.js +601 -0
- package/dist/chunk-RHY3HH7P.js.map +1 -0
- package/dist/chunk-RRF5UOBJ.js +91 -0
- package/dist/chunk-RXDLTSWT.js +124 -0
- package/dist/chunk-RXDLTSWT.js.map +1 -0
- package/dist/chunk-RYED3SPJ.js +42 -0
- package/dist/chunk-RYED3SPJ.js.map +1 -0
- package/dist/chunk-S7KDBTWT.js +106 -0
- package/dist/chunk-S7KDBTWT.js.map +1 -0
- package/dist/chunk-SEDEKFYQ.js +1 -0
- package/dist/chunk-TECVW3JP.js +36 -0
- package/dist/chunk-TECVW3JP.js.map +1 -0
- package/dist/chunk-TFO23QT4.js +88 -0
- package/dist/chunk-TFO23QT4.js.map +1 -0
- package/dist/chunk-TK4UEOSK.js +76 -0
- package/dist/chunk-TK4UEOSK.js.map +1 -0
- package/dist/chunk-TKWGAOLV.js +122 -0
- package/dist/chunk-TKWGAOLV.js.map +1 -0
- package/dist/chunk-TMM4S4IJ.js +597 -0
- package/dist/chunk-TMM4S4IJ.js.map +1 -0
- package/dist/chunk-TMQLARTH.js +188 -0
- package/dist/chunk-TMQLARTH.js.map +1 -0
- package/dist/chunk-TPDBFYEG.js +130 -0
- package/dist/chunk-TPDBFYEG.js.map +1 -0
- package/dist/chunk-TPMQ3G6Z.js +145 -0
- package/dist/chunk-TPMQ3G6Z.js.map +1 -0
- package/dist/chunk-TZOLIGIG.js +61 -0
- package/dist/chunk-TZOLIGIG.js.map +1 -0
- package/dist/chunk-U3PN77QT.js +113 -0
- package/dist/chunk-U3WSW6PZ.js +277 -0
- package/dist/chunk-U4SCL7B7.js +640 -0
- package/dist/chunk-U4SCL7B7.js.map +1 -0
- package/dist/chunk-UWK5OXUJ.js +156 -0
- package/dist/chunk-UWK5OXUJ.js.map +1 -0
- package/dist/chunk-UWVJF25J.js +74 -0
- package/dist/chunk-UXHQAFNA.js +1317 -0
- package/dist/chunk-UXHQAFNA.js.map +1 -0
- package/dist/chunk-V5OCT34X.js +1 -0
- package/dist/chunk-VLXA6PI2.js +304 -0
- package/dist/chunk-VLXA6PI2.js.map +1 -0
- package/dist/chunk-VNO6ZJ35.js +500 -0
- package/dist/chunk-VNO6ZJ35.js.map +1 -0
- package/dist/chunk-VW676BEI.js +827 -0
- package/dist/chunk-VW676BEI.js.map +1 -0
- package/dist/chunk-W3LR522O.js +2296 -0
- package/dist/chunk-W4L6CZKA.js +96 -0
- package/dist/chunk-W4L6CZKA.js.map +1 -0
- package/dist/chunk-W4RVMTHR.js +372 -0
- package/dist/chunk-W4RVMTHR.js.map +1 -0
- package/dist/chunk-WEHSQBFR.js +188 -0
- package/dist/chunk-WEHSQBFR.js.map +1 -0
- package/dist/chunk-WELDCG6C.js +380 -0
- package/dist/chunk-WELDCG6C.js.map +1 -0
- package/dist/chunk-WZYKANL3.js +2800 -0
- package/dist/chunk-WZYKANL3.js.map +1 -0
- package/dist/chunk-XIG5PDM7.js +48 -0
- package/dist/chunk-XJNBEDFE.js +193 -0
- package/dist/chunk-XJNBEDFE.js.map +1 -0
- package/dist/chunk-XVVIG67A.js +291 -0
- package/dist/chunk-XVVIG67A.js.map +1 -0
- package/dist/chunk-XVZ7B3HG.js +135 -0
- package/dist/chunk-YBPYIAA5.js +73 -0
- package/dist/chunk-YBPYIAA5.js.map +1 -0
- package/dist/chunk-Z734BLO3.js +21 -0
- package/dist/chunk-Z734BLO3.js.map +1 -0
- package/dist/chunk-ZKSK55RC.js +269 -0
- package/dist/chunk-ZKSK55RC.js.map +1 -0
- package/dist/chunk-ZTFCYYEZ.js +69 -0
- package/dist/chunk-ZTFCYYEZ.js.map +1 -0
- package/dist/chunk-ZY2MNJR6.js +329 -0
- package/dist/chunk-ZY2MNJR6.js.map +1 -0
- package/dist/cli-D3VpkVwB.d.ts +1136 -0
- package/dist/cli.d.ts +39 -10
- package/dist/cli.js +108 -49
- package/dist/commitment-ledger.js +1 -1
- package/dist/compat/checks.d.ts +5 -0
- package/dist/compat/checks.js +11 -0
- package/dist/compat/checks.js.map +1 -0
- package/dist/compat/types.d.ts +30 -0
- package/dist/compat/types.js +1 -0
- package/dist/compat/types.js.map +1 -0
- package/dist/compounding/engine.d.ts +221 -0
- package/dist/compounding/engine.js +32 -0
- package/dist/compounding/engine.js.map +1 -0
- package/dist/compounding/preference-consolidator.d.ts +92 -0
- package/dist/compounding/preference-consolidator.js +553 -0
- package/dist/compounding/preference-consolidator.js.map +1 -0
- package/dist/config.d.ts +4 -2
- package/dist/config.js +9 -4
- package/dist/conflict-policy-DyJ2wd-h.d.ts +4 -0
- package/dist/connectors/codex-materialize-runner.d.ts +64 -0
- package/dist/connectors/codex-materialize-runner.js +33 -0
- package/dist/connectors/codex-materialize-runner.js.map +1 -0
- package/dist/connectors/codex-materialize.d.ts +195 -0
- package/dist/connectors/codex-materialize.js +38 -0
- package/dist/connectors/codex-materialize.js.map +1 -0
- package/dist/connectors/index.d.ts +444 -0
- package/dist/connectors/index.js +115 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors-cli-CwbyjGR7.d.ts +257 -0
- package/dist/connectors-cli.d.ts +1 -1
- package/dist/consolidation-provenance-check.d.ts +3 -1
- package/dist/consolidation-undo.d.ts +3 -1
- package/dist/contradiction/index.d.ts +258 -0
- package/dist/contradiction/index.js +43 -0
- package/dist/contradiction/index.js.map +1 -0
- package/dist/contradiction-review-ATP4S6IC.js +30 -0
- package/dist/contradiction-review-ATP4S6IC.js.map +1 -0
- package/dist/contradiction-scan-5A4IDZV5.js +13 -0
- package/dist/contradiction-scan-5A4IDZV5.js.map +1 -0
- package/dist/conversation-index/backend.d.ts +97 -0
- package/dist/conversation-index/backend.js +13 -0
- package/dist/conversation-index/backend.js.map +1 -0
- package/dist/conversation-index/chunker.d.ts +16 -0
- package/dist/conversation-index/chunker.js +8 -0
- package/dist/conversation-index/chunker.js.map +1 -0
- package/dist/conversation-index/cleanup.d.ts +11 -0
- package/dist/conversation-index/cleanup.js +9 -0
- package/dist/conversation-index/cleanup.js.map +1 -0
- package/dist/conversation-index/faiss-adapter.d.ts +6 -0
- package/dist/conversation-index/faiss-adapter.js +16 -0
- package/dist/conversation-index/faiss-adapter.js.map +1 -0
- package/dist/conversation-index/indexer.d.ts +23 -0
- package/dist/conversation-index/indexer.js +15 -0
- package/dist/conversation-index/indexer.js.map +1 -0
- package/dist/conversation-index/search.d.ts +6 -0
- package/dist/conversation-index/search.js +11 -0
- package/dist/conversation-index/search.js.map +1 -0
- package/dist/embedding-fallback.js +2 -2
- package/dist/enrichment/index.d.ts +163 -0
- package/dist/enrichment/index.js +18 -0
- package/dist/enrichment/index.js.map +1 -0
- package/dist/entity-retrieval.d.ts +4 -2
- package/dist/entity-retrieval.js +8 -5
- package/dist/evals.js +1 -1
- package/dist/explicit-capture.d.ts +20 -5
- package/dist/explicit-capture.js +2 -2
- package/dist/extraction-judge-training.js +1 -1
- package/dist/extraction.js +8 -8
- package/dist/faiss-adapter-CzPghc4C.d.ts +70 -0
- package/dist/fallback-llm.d.ts +2 -0
- package/dist/fallback-llm.js +4 -4
- package/dist/graph-edge-decay-5DI5GUNL.js +207 -0
- package/dist/index.d.ts +66 -711
- package/dist/index.js +556 -2680
- package/dist/index.js.map +1 -1
- package/dist/lcm/archive.d.ts +89 -0
- package/dist/lcm/archive.js +12 -0
- package/dist/lcm/archive.js.map +1 -0
- package/dist/lcm/dag.d.ts +48 -0
- package/dist/lcm/dag.js +8 -0
- package/dist/lcm/dag.js.map +1 -0
- package/dist/lcm/engine.d.ts +116 -0
- package/dist/lcm/engine.js +20 -0
- package/dist/lcm/engine.js.map +1 -0
- package/dist/lcm/index.d.ts +12 -0
- package/dist/lcm/index.js +44 -0
- package/dist/lcm/index.js.map +1 -0
- package/dist/lcm/queue.d.ts +62 -0
- package/dist/lcm/queue.js +8 -0
- package/dist/lcm/queue.js.map +1 -0
- package/dist/lcm/recall.d.ts +20 -0
- package/dist/lcm/recall.js +8 -0
- package/dist/lcm/recall.js.map +1 -0
- package/dist/lcm/schema.d.ts +16 -0
- package/dist/lcm/schema.js +14 -0
- package/dist/lcm/schema.js.map +1 -0
- package/dist/lcm/summarizer.d.ts +38 -0
- package/dist/lcm/summarizer.js +12 -0
- package/dist/lcm/summarizer.js.map +1 -0
- package/dist/lcm/tools.d.ts +29 -0
- package/dist/lcm/tools.js +8 -0
- package/dist/lcm/tools.js.map +1 -0
- package/dist/live-connectors-runner.js +5 -5
- package/dist/local-llm.js +3 -3
- package/dist/maintenance/archive-observations.d.ts +18 -0
- package/dist/maintenance/archive-observations.js +8 -0
- package/dist/maintenance/archive-observations.js.map +1 -0
- package/dist/maintenance/backup-stamp.d.ts +3 -0
- package/dist/maintenance/backup-stamp.js +8 -0
- package/dist/maintenance/backup-stamp.js.map +1 -0
- package/dist/maintenance/memory-governance-cron.d.ts +85 -0
- package/dist/maintenance/memory-governance-cron.js +22 -0
- package/dist/maintenance/memory-governance-cron.js.map +1 -0
- package/dist/maintenance/memory-governance.d.ts +137 -0
- package/dist/maintenance/memory-governance.js +40 -0
- package/dist/maintenance/memory-governance.js.map +1 -0
- package/dist/maintenance/migrate-observations.d.ts +18 -0
- package/dist/maintenance/migrate-observations.js +9 -0
- package/dist/maintenance/migrate-observations.js.map +1 -0
- package/dist/maintenance/observation-ledger-utils.d.ts +10 -0
- package/dist/maintenance/observation-ledger-utils.js +10 -0
- package/dist/maintenance/observation-ledger-utils.js.map +1 -0
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +15 -0
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -0
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js.map +1 -0
- package/dist/maintenance/rebuild-memory-projection.d.ts +77 -0
- package/dist/maintenance/rebuild-memory-projection.js +35 -0
- package/dist/maintenance/rebuild-memory-projection.js.map +1 -0
- package/dist/maintenance/rebuild-observations.d.ts +17 -0
- package/dist/maintenance/rebuild-observations.js +9 -0
- package/dist/maintenance/rebuild-observations.js.map +1 -0
- package/dist/mcp-memory-inspector-app.d.ts +24 -6
- package/dist/memory-projection-store.d.ts +108 -3
- package/dist/memory-projection-store.js +2 -1
- package/dist/memory-worth-outcomes.d.ts +4 -2
- package/dist/migrate/from-engram.d.ts +24 -0
- package/dist/migrate/from-engram.js +12 -0
- package/dist/migrate/from-engram.js.map +1 -0
- package/dist/namespaces/migrate.d.ts +50 -0
- package/dist/namespaces/migrate.js +50 -0
- package/dist/namespaces/migrate.js.map +1 -0
- package/dist/namespaces/principal.d.ts +17 -0
- package/dist/namespaces/principal.js +16 -0
- package/dist/namespaces/principal.js.map +1 -0
- package/dist/namespaces/search.d.ts +46 -0
- package/dist/namespaces/search.js +28 -0
- package/dist/namespaces/search.js.map +1 -0
- package/dist/namespaces/storage.d.ts +32 -0
- package/dist/namespaces/storage.js +28 -0
- package/dist/namespaces/storage.js.map +1 -0
- package/dist/network/tailscale.d.ts +41 -0
- package/dist/network/tailscale.js +9 -0
- package/dist/network/tailscale.js.map +1 -0
- package/dist/network/webdav.d.ts +39 -0
- package/dist/network/webdav.js +10 -0
- package/dist/network/webdav.js.map +1 -0
- package/dist/objective-state-writers.js +2 -2
- package/dist/operator-toolkit.d.ts +4 -2
- package/dist/operator-toolkit.js +32 -14
- package/dist/opik-exporter.js +2 -2
- package/dist/opik-exporter.js.map +1 -1
- package/dist/orchestrator-DuWl9Hwx.d.ts +1244 -0
- package/dist/orchestrator.d.ts +22 -7
- package/dist/orchestrator.js +79 -44
- package/dist/path-MR5JPYOP.js +9 -0
- package/dist/path-MR5JPYOP.js.map +1 -0
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +102 -3
- package/dist/qmd.js +23 -5
- package/dist/recall-explain-renderer.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/replay/normalizers/chatgpt.d.ts +6 -0
- package/dist/replay/normalizers/chatgpt.js +11 -0
- package/dist/replay/normalizers/chatgpt.js.map +1 -0
- package/dist/replay/normalizers/claude.d.ts +6 -0
- package/dist/replay/normalizers/claude.js +11 -0
- package/dist/replay/normalizers/claude.js.map +1 -0
- package/dist/replay/normalizers/openclaw.d.ts +6 -0
- package/dist/replay/normalizers/openclaw.js +11 -0
- package/dist/replay/normalizers/openclaw.js.map +1 -0
- package/dist/replay/normalizers/shared.d.ts +16 -0
- package/dist/replay/normalizers/shared.js +14 -0
- package/dist/replay/normalizers/shared.js.map +1 -0
- package/dist/replay/runner.d.ts +35 -0
- package/dist/replay/runner.js +16 -0
- package/dist/replay/runner.js.map +1 -0
- package/dist/replay/types.d.ts +57 -0
- package/dist/replay/types.js +19 -0
- package/dist/replay/types.js.map +1 -0
- package/dist/resolution-B7FNQSSP.js +12 -0
- package/dist/resolution-B7FNQSSP.js.map +1 -0
- package/dist/resolve-provider-secret.js +2 -2
- package/dist/resume-bundles.js +8 -6
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/routing/engine.d.ts +35 -0
- package/dist/routing/engine.js +16 -0
- package/dist/routing/engine.js.map +1 -0
- package/dist/routing/store.d.ts +27 -0
- package/dist/routing/store.js +10 -0
- package/dist/routing/store.js.map +1 -0
- package/dist/runtime/better-sqlite.d.ts +8 -0
- package/dist/runtime/better-sqlite.js +10 -0
- package/dist/runtime/better-sqlite.js.map +1 -0
- package/dist/runtime/child-process.d.ts +32 -0
- package/dist/runtime/child-process.js +10 -0
- package/dist/runtime/child-process.js.map +1 -0
- package/dist/runtime/env.d.ts +5 -0
- package/dist/runtime/env.js +12 -0
- package/dist/runtime/env.js.map +1 -0
- package/dist/schemas.d.ts +22 -22
- package/dist/sdk-compat.js +1 -1
- package/dist/search/document-scanner.d.ts +22 -0
- package/dist/search/document-scanner.js +8 -0
- package/dist/search/document-scanner.js.map +1 -0
- package/dist/search/embed-helper.d.ts +35 -0
- package/dist/search/embed-helper.js +9 -0
- package/dist/search/embed-helper.js.map +1 -0
- package/dist/search/factory.d.ts +32 -0
- package/dist/search/factory.js +29 -0
- package/dist/search/factory.js.map +1 -0
- package/dist/search/index.d.ts +15 -0
- package/dist/search/index.js +50 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/lancedb-backend.d.ts +51 -0
- package/dist/search/lancedb-backend.js +10 -0
- package/dist/search/lancedb-backend.js.map +1 -0
- package/dist/search/meilisearch-backend.d.ts +48 -0
- package/dist/search/meilisearch-backend.js +10 -0
- package/dist/search/meilisearch-backend.js.map +1 -0
- package/dist/search/noop-backend.d.ts +26 -0
- package/dist/search/noop-backend.js +8 -0
- package/dist/search/noop-backend.js.map +1 -0
- package/dist/search/orama-backend.d.ts +53 -0
- package/dist/search/orama-backend.js +10 -0
- package/dist/search/orama-backend.js.map +1 -0
- package/dist/search/port.d.ts +61 -0
- package/dist/search/port.js +1 -0
- package/dist/search/port.js.map +1 -0
- package/dist/search/remote-backend.d.ts +39 -0
- package/dist/search/remote-backend.js +9 -0
- package/dist/search/remote-backend.js.map +1 -0
- package/dist/secure-store/index.d.ts +890 -0
- package/dist/secure-store/index.js +156 -0
- package/dist/secure-store/index.js.map +1 -0
- package/dist/semantic-VwGI14Ok.d.ts +69 -0
- package/dist/semantic-consolidation-4HkHWgeI.d.ts +180 -0
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -6
- package/dist/semantic-rule-promotion.js +8 -5
- package/dist/semantic-rule-verifier.js +8 -5
- package/dist/shared-context/manager.d.ts +131 -0
- package/dist/shared-context/manager.js +15 -0
- package/dist/shared-context/manager.js.map +1 -0
- package/dist/skills-registry.js +13 -1
- package/dist/skills-registry.js.map +1 -1
- package/dist/state-store-VZU2IA53.js +16 -0
- package/dist/state-store-VZU2IA53.js.map +1 -0
- package/dist/storage-paths.d.ts +9 -0
- package/dist/storage-paths.js +20 -0
- package/dist/storage-paths.js.map +1 -0
- package/dist/storage.d.ts +3 -1
- package/dist/storage.js +7 -4
- package/dist/summarizer.d.ts +5 -0
- package/dist/summarizer.js +9 -8
- package/dist/summary-snapshot.js +2 -1
- package/dist/surfaces/dreams.d.ts +16 -0
- package/dist/surfaces/dreams.js +282 -0
- package/dist/surfaces/dreams.js.map +1 -0
- package/dist/surfaces/heartbeat.d.ts +17 -0
- package/dist/surfaces/heartbeat.js +265 -0
- package/dist/surfaces/heartbeat.js.map +1 -0
- package/dist/temporal-supersession.d.ts +3 -1
- package/dist/threading.d.ts +5 -0
- package/dist/threading.js +2 -1
- package/dist/tier-migration.d.ts +4 -2
- package/dist/tokens.js +2 -2
- package/dist/transcript.d.ts +15 -1
- package/dist/transcript.js +2 -1
- package/dist/transfer/autodetect.d.ts +4 -0
- package/dist/transfer/autodetect.js +15 -0
- package/dist/transfer/autodetect.js.map +1 -0
- package/dist/transfer/backup.d.ts +21 -0
- package/dist/transfer/backup.js +17 -0
- package/dist/transfer/backup.js.map +1 -0
- package/dist/transfer/capsule-export.d.ts +113 -0
- package/dist/transfer/capsule-export.js +19 -0
- package/dist/transfer/capsule-export.js.map +1 -0
- package/dist/transfer/capsule-import.d.ts +124 -0
- package/dist/transfer/capsule-import.js +16 -0
- package/dist/transfer/capsule-import.js.map +1 -0
- package/dist/transfer/constants.d.ts +13 -0
- package/dist/transfer/constants.js +12 -0
- package/dist/transfer/constants.js.map +1 -0
- package/dist/transfer/export-json.d.ts +11 -0
- package/dist/transfer/export-json.js +11 -0
- package/dist/transfer/export-json.js.map +1 -0
- package/dist/transfer/export-md.d.ts +10 -0
- package/dist/transfer/export-md.js +13 -0
- package/dist/transfer/export-md.js.map +1 -0
- package/dist/transfer/export-sqlite.d.ts +9 -0
- package/dist/transfer/export-sqlite.js +12 -0
- package/dist/transfer/export-sqlite.js.map +1 -0
- package/dist/transfer/fs-utils.d.ts +61 -0
- package/dist/transfer/fs-utils.js +40 -0
- package/dist/transfer/fs-utils.js.map +1 -0
- package/dist/transfer/import-json.d.ts +16 -0
- package/dist/transfer/import-json.js +13 -0
- package/dist/transfer/import-json.js.map +1 -0
- package/dist/transfer/import-md.d.ts +14 -0
- package/dist/transfer/import-md.js +11 -0
- package/dist/transfer/import-md.js.map +1 -0
- package/dist/transfer/import-sqlite.d.ts +14 -0
- package/dist/transfer/import-sqlite.js +12 -0
- package/dist/transfer/import-sqlite.js.map +1 -0
- package/dist/transfer/sqlite-schema.d.ts +4 -0
- package/dist/transfer/sqlite-schema.js +10 -0
- package/dist/transfer/sqlite-schema.js.map +1 -0
- package/dist/transfer/types.d.ts +916 -0
- package/dist/transfer/types.js +30 -0
- package/dist/transfer/types.js.map +1 -0
- package/dist/types.d.ts +28 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +9 -6
- package/dist/work/board.d.ts +43 -0
- package/dist/work/board.js +14 -0
- package/dist/work/board.js.map +1 -0
- package/dist/work/boundary.d.ts +8 -0
- package/dist/work/boundary.js +14 -0
- package/dist/work/boundary.js.map +1 -0
- package/dist/work/storage.d.ts +39 -0
- package/dist/work/storage.js +11 -0
- package/dist/work/storage.js.map +1 -0
- package/dist/work/types.d.ts +75 -0
- package/dist/work/types.js +1 -0
- package/dist/work/types.js.map +1 -0
- package/package.json +2767 -6
- package/scripts/faiss_index.py +816 -0
- package/scripts/faiss_requirements.txt +3 -0
- package/skills/remnic-entities/SKILL.md +51 -0
- package/skills/remnic-memory-workflow/SKILL.md +61 -0
- package/skills/remnic-recall/SKILL.md +51 -0
- package/skills/remnic-remember/SKILL.md +56 -0
- package/skills/remnic-search/SKILL.md +51 -0
- package/skills/remnic-status/SKILL.md +51 -0
- package/src/abort-error.test.ts +49 -0
- package/src/abort-error.ts +46 -0
- package/src/abstraction-nodes.ts +162 -0
- package/src/access-audit.test.ts +178 -0
- package/src/access-audit.ts +125 -0
- package/src/access-cli.test.ts +439 -0
- package/src/access-cli.ts +438 -0
- package/src/access-http.test.ts +225 -0
- package/src/access-http.ts +1899 -0
- package/src/access-idempotency.ts +232 -0
- package/src/access-mcp.test.ts +568 -0
- package/src/access-mcp.ts +3056 -0
- package/src/access-schema-pi.test.ts +60 -0
- package/src/access-schema.ts +522 -0
- package/src/access-service-namespace.test.ts +123 -0
- package/src/access-service.ts +5629 -0
- package/src/action-confidence.test.ts +206 -0
- package/src/action-confidence.ts +466 -0
- package/src/active-memory-bridge.test.ts +285 -0
- package/src/active-memory-bridge.ts +217 -0
- package/src/active-recall.test.ts +484 -0
- package/src/active-recall.ts +459 -0
- package/src/adapters/claude-code.ts +56 -0
- package/src/adapters/codex.ts +57 -0
- package/src/adapters/hermes.ts +64 -0
- package/src/adapters/index.ts +6 -0
- package/src/adapters/registry.ts +41 -0
- package/src/adapters/replit.ts +55 -0
- package/src/adapters/types.ts +51 -0
- package/src/behavior-learner.ts +144 -0
- package/src/behavior-signals.ts +73 -0
- package/src/binary-lifecycle/backend.ts +117 -0
- package/src/binary-lifecycle/index.ts +35 -0
- package/src/binary-lifecycle/manifest.ts +79 -0
- package/src/binary-lifecycle/pipeline.ts +352 -0
- package/src/binary-lifecycle/scanner.ts +89 -0
- package/src/binary-lifecycle/types.ts +89 -0
- package/src/bootstrap.ts +178 -0
- package/src/boxes.ts +521 -0
- package/src/briefing.test.ts +1535 -0
- package/src/briefing.ts +1382 -0
- package/src/buffer-session.test.ts +443 -0
- package/src/buffer-surprise-report.ts +176 -0
- package/src/buffer-surprise-telemetry.test.ts +606 -0
- package/src/buffer-surprise-trigger.test.ts +766 -0
- package/src/buffer-surprise.test.ts +339 -0
- package/src/buffer-surprise.ts +203 -0
- package/src/buffer.ts +900 -0
- package/src/bulk-import/cli-command.test.ts +204 -0
- package/src/bulk-import/index.ts +34 -0
- package/src/bulk-import/pipeline.test.ts +445 -0
- package/src/bulk-import/pipeline.ts +178 -0
- package/src/bulk-import/registry.test.ts +151 -0
- package/src/bulk-import/registry.ts +72 -0
- package/src/bulk-import/types.test.ts +272 -0
- package/src/bulk-import/types.ts +145 -0
- package/src/calibration.ts +394 -0
- package/src/capsule-cli.test.ts +398 -0
- package/src/capsule-cli.ts +565 -0
- package/src/causal-behavior.ts +308 -0
- package/src/causal-chain.ts +419 -0
- package/src/causal-consolidation.ts +370 -0
- package/src/causal-retrieval.ts +286 -0
- package/src/causal-trajectory-graph.ts +60 -0
- package/src/causal-trajectory.ts +303 -0
- package/src/chunking.ts +220 -0
- package/src/citations.ts +232 -0
- package/src/cli.ts +9403 -0
- package/src/codex-cli-fallback.ts +162 -0
- package/src/codex-thread-key.ts +1 -0
- package/src/coding/access-coding-context.test.ts +197 -0
- package/src/coding/coding-branch-scope.test.ts +281 -0
- package/src/coding/coding-namespace.test.ts +360 -0
- package/src/coding/coding-namespace.ts +412 -0
- package/src/coding/coding-orchestrator.test.ts +249 -0
- package/src/coding/git-context.test.ts +507 -0
- package/src/coding/git-context.ts +336 -0
- package/src/coding/mcp-set-coding-context.test.ts +174 -0
- package/src/coding/review-context.test.ts +316 -0
- package/src/coding/review-context.ts +349 -0
- package/src/coding/wire-coding-context.test.ts +468 -0
- package/src/commitment-ledger.test.ts +78 -0
- package/src/commitment-ledger.ts +337 -0
- package/src/compat/checks.test.ts +206 -0
- package/src/compat/checks.ts +716 -0
- package/src/compat/types.ts +33 -0
- package/src/compounding/engine.ts +1686 -0
- package/src/compounding/preference-consolidator.ts +778 -0
- package/src/compression-optimizer.ts +312 -0
- package/src/config.test.ts +930 -0
- package/src/config.ts +3807 -0
- package/src/connectors/codex/instructions.md +160 -0
- package/src/connectors/codex/resources/namespace-cheatsheet.md +48 -0
- package/src/connectors/codex-marketplace.ts +500 -0
- package/src/connectors/codex-materialize-runner.ts +212 -0
- package/src/connectors/codex-materialize.ts +983 -0
- package/src/connectors/coerce.ts +62 -0
- package/src/connectors/index.test.ts +1570 -0
- package/src/connectors/index.ts +3222 -0
- package/src/connectors/live/framework.ts +164 -0
- package/src/connectors/live/github.test.ts +1218 -0
- package/src/connectors/live/github.ts +1068 -0
- package/src/connectors/live/gmail.test.ts +1706 -0
- package/src/connectors/live/gmail.ts +1293 -0
- package/src/connectors/live/google-drive.test.ts +696 -0
- package/src/connectors/live/google-drive.ts +724 -0
- package/src/connectors/live/index.ts +101 -0
- package/src/connectors/live/live-connectors.test.ts +689 -0
- package/src/connectors/live/notion.test.ts +1109 -0
- package/src/connectors/live/notion.ts +978 -0
- package/src/connectors/live/registry.ts +103 -0
- package/src/connectors/live/state-store.ts +399 -0
- package/src/connectors/live/transient-errors.ts +150 -0
- package/src/connectors/weclone-installer.test.ts +850 -0
- package/src/connectors-cli.ts +513 -0
- package/src/console/state.test.ts +224 -0
- package/src/console/state.ts +514 -0
- package/src/console/trace.test.ts +813 -0
- package/src/console/trace.ts +603 -0
- package/src/console/tui.test.ts +582 -0
- package/src/console/tui.ts +508 -0
- package/src/consolidation-operator.ts +182 -0
- package/src/consolidation-provenance-check.ts +551 -0
- package/src/consolidation-undo.ts +718 -0
- package/src/contradiction/contradiction-judge.test.ts +189 -0
- package/src/contradiction/contradiction-judge.ts +333 -0
- package/src/contradiction/contradiction-review.ts +574 -0
- package/src/contradiction/contradiction-scan.ts +504 -0
- package/src/contradiction/contradiction.test.ts +2230 -0
- package/src/contradiction/index.ts +37 -0
- package/src/contradiction/resolution.ts +383 -0
- package/src/conversation-index/backend.ts +323 -0
- package/src/conversation-index/chunker.ts +47 -0
- package/src/conversation-index/cleanup.ts +53 -0
- package/src/conversation-index/faiss-adapter.ts +384 -0
- package/src/conversation-index/indexer.test.ts +164 -0
- package/src/conversation-index/indexer.ts +192 -0
- package/src/conversation-index/search.ts +37 -0
- package/src/cross-namespace-budget.test.ts +275 -0
- package/src/cross-namespace-budget.ts +365 -0
- package/src/cue-anchors.ts +163 -0
- package/src/curation/index.ts +544 -0
- package/src/dashboard-runtime.ts +337 -0
- package/src/day-summary.ts +122 -0
- package/src/dedup/index.ts +330 -0
- package/src/dedup/semantic.test.ts +1577 -0
- package/src/dedup/semantic.ts +148 -0
- package/src/delinearize.ts +193 -0
- package/src/direct-answer-wiring.test.ts +473 -0
- package/src/direct-answer-wiring.ts +180 -0
- package/src/direct-answer.test.ts +484 -0
- package/src/direct-answer.ts +273 -0
- package/src/embedding-fallback.ts +565 -0
- package/src/enrichment/audit.ts +89 -0
- package/src/enrichment/index.ts +27 -0
- package/src/enrichment/pipeline.ts +197 -0
- package/src/enrichment/provider-registry.ts +85 -0
- package/src/enrichment/types.ts +100 -0
- package/src/enrichment/web-search-provider.ts +63 -0
- package/src/entity-retrieval.ts +774 -0
- package/src/entity-schema.ts +239 -0
- package/src/evals.ts +1312 -0
- package/src/event-order-recall.test.ts +4164 -0
- package/src/event-order-recall.ts +2802 -0
- package/src/evidence-pack.test.ts +89 -0
- package/src/evidence-pack.ts +388 -0
- package/src/explicit-capture.ts +530 -0
- package/src/explicit-cue-recall.test.ts +3019 -0
- package/src/explicit-cue-recall.ts +5545 -0
- package/src/extraction-judge-telemetry.ts +234 -0
- package/src/extraction-judge-training.ts +221 -0
- package/src/extraction-judge.ts +846 -0
- package/src/extraction-timeout.test.ts +265 -0
- package/src/extraction.ts +2719 -0
- package/src/fallback-llm.test.ts +1060 -0
- package/src/fallback-llm.ts +918 -0
- package/src/focused-list-recall.test.ts +734 -0
- package/src/focused-list-recall.ts +1160 -0
- package/src/graph-dashboard-diff.ts +35 -0
- package/src/graph-dashboard-key.ts +5 -0
- package/src/graph-dashboard-parser.ts +104 -0
- package/src/graph-edge-reinforcement.ts +192 -0
- package/src/graph-events.ts +151 -0
- package/src/graph-recall.test.ts +164 -0
- package/src/graph-recall.ts +189 -0
- package/src/graph-retrieval.test.ts +809 -0
- package/src/graph-retrieval.ts +823 -0
- package/src/graph-snapshot.ts +329 -0
- package/src/graph.ts +813 -0
- package/src/harmonic-retrieval.ts +223 -0
- package/src/himem.ts +154 -0
- package/src/hygiene.ts +87 -0
- package/src/identity-continuity.ts +333 -0
- package/src/importance.ts +328 -0
- package/src/importers/base.test.ts +294 -0
- package/src/importers/base.ts +436 -0
- package/src/importers/index.ts +21 -0
- package/src/index.ts +1204 -0
- package/src/intent.ts +154 -0
- package/src/json-extract.ts +85 -0
- package/src/json-store.ts +42 -0
- package/src/lcm/archive.ts +617 -0
- package/src/lcm/dag.ts +199 -0
- package/src/lcm/engine.ts +645 -0
- package/src/lcm/index.ts +7 -0
- package/src/lcm/queue.test.ts +178 -0
- package/src/lcm/queue.ts +200 -0
- package/src/lcm/recall.ts +117 -0
- package/src/lcm/schema.ts +154 -0
- package/src/lcm/summarizer.ts +235 -0
- package/src/lcm/tools.ts +191 -0
- package/src/lcm-engine.test.ts +660 -0
- package/src/legacy-hook-compat.test.ts +20 -0
- package/src/legacy-hook-compat.ts +45 -0
- package/src/lifecycle.ts +289 -0
- package/src/live-connectors-runner.ts +385 -0
- package/src/local-llm-qos.test.ts +303 -0
- package/src/local-llm-thinking.test.ts +292 -0
- package/src/local-llm.ts +1464 -0
- package/src/logger.ts +49 -0
- package/src/maintenance/archive-observations.ts +147 -0
- package/src/maintenance/backup-stamp.ts +3 -0
- package/src/maintenance/dreams-ledger.ts +516 -0
- package/src/maintenance/first-start-migration.ts +362 -0
- package/src/maintenance/forget.test.ts +206 -0
- package/src/maintenance/forget.ts +126 -0
- package/src/maintenance/graph-edge-decay.test.ts +409 -0
- package/src/maintenance/graph-edge-decay.ts +394 -0
- package/src/maintenance/memory-governance-cron.ts +447 -0
- package/src/maintenance/memory-governance.ts +1039 -0
- package/src/maintenance/migrate-observations.ts +216 -0
- package/src/maintenance/observation-ledger-utils.ts +54 -0
- package/src/maintenance/pattern-reinforcement.test.ts +875 -0
- package/src/maintenance/pattern-reinforcement.ts +369 -0
- package/src/maintenance/purge.ts +334 -0
- package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +78 -0
- package/src/maintenance/rebuild-memory-projection.ts +1234 -0
- package/src/maintenance/rebuild-observations.ts +178 -0
- package/src/maintenance/tier-stats.test.ts +378 -0
- package/src/maintenance/tier-stats.ts +222 -0
- package/src/mcp-memory-inspector-app.ts +421 -0
- package/src/memory-action-policy.ts +80 -0
- package/src/memory-cache.ts +208 -0
- package/src/memory-extension/claude-code-publisher.ts +51 -0
- package/src/memory-extension/codex-publisher.ts +149 -0
- package/src/memory-extension/hermes-publisher.ts +51 -0
- package/src/memory-extension/index.ts +100 -0
- package/src/memory-extension/shared-instructions.ts +133 -0
- package/src/memory-extension/types.ts +86 -0
- package/src/memory-extension-host/host-discovery.ts +276 -0
- package/src/memory-extension-host/index.ts +14 -0
- package/src/memory-extension-host/render-extensions-block.ts +73 -0
- package/src/memory-extension-host/types.ts +21 -0
- package/src/memory-lifecycle-ledger-utils.ts +116 -0
- package/src/memory-projection-format.ts +11 -0
- package/src/memory-projection-store.ts +951 -0
- package/src/memory-provenance.test.ts +196 -0
- package/src/memory-provenance.ts +484 -0
- package/src/memory-worth-bench.test.ts +71 -0
- package/src/memory-worth-bench.ts +265 -0
- package/src/memory-worth-filter.test.ts +209 -0
- package/src/memory-worth-filter.ts +204 -0
- package/src/memory-worth-frontmatter.test.ts +311 -0
- package/src/memory-worth-outcomes.test.ts +316 -0
- package/src/memory-worth-outcomes.ts +286 -0
- package/src/memory-worth.test.ts +317 -0
- package/src/memory-worth.ts +215 -0
- package/src/message-parts/index.ts +806 -0
- package/src/message-parts/message-parts.test.ts +421 -0
- package/src/migrate/from-engram.ts +789 -0
- package/src/model-registry.ts +313 -0
- package/src/models-json.ts +76 -0
- package/src/namespaces/migrate.ts +187 -0
- package/src/namespaces/path.ts +25 -0
- package/src/namespaces/principal.test.ts +195 -0
- package/src/namespaces/principal.ts +86 -0
- package/src/namespaces/search.test.ts +105 -0
- package/src/namespaces/search.ts +233 -0
- package/src/namespaces/storage.ts +74 -0
- package/src/native-knowledge.ts +1823 -0
- package/src/negative.ts +72 -0
- package/src/network/tailscale.ts +179 -0
- package/src/network/webdav.ts +385 -0
- package/src/objective-state-writers.ts +951 -0
- package/src/objective-state.ts +320 -0
- package/src/onboarding/index.ts +529 -0
- package/src/openai-chat-compat.ts +56 -0
- package/src/operator-toolkit.ts +2132 -0
- package/src/opik-exporter.test.ts +72 -0
- package/src/opik-exporter.ts +587 -0
- package/src/orchestrator-extraction-queue.test.ts +197 -0
- package/src/orchestrator-flush.test.ts +1171 -0
- package/src/orchestrator-pattern-reinforcement.test.ts +128 -0
- package/src/orchestrator-source-attribution.test.ts +701 -0
- package/src/orchestrator.ts +16368 -0
- package/src/page-versioning.ts +450 -0
- package/src/patterns-cli.ts +574 -0
- package/src/peers/index.ts +54 -0
- package/src/peers/migrate-from-identity-anchor.test.ts +291 -0
- package/src/peers/migrate-from-identity-anchor.ts +350 -0
- package/src/peers/peers.test.ts +419 -0
- package/src/peers/profile-reasoner.ts +694 -0
- package/src/peers/storage.ts +1350 -0
- package/src/peers/types.ts +138 -0
- package/src/plugin-id.ts +84 -0
- package/src/policy-runtime.ts +209 -0
- package/src/procedural/procedure-miner.ts +150 -0
- package/src/procedural/procedure-recall.ts +93 -0
- package/src/procedural/procedure-stats.ts +213 -0
- package/src/procedural/procedure-types.ts +132 -0
- package/src/procedural/reinforcement-core.test.ts +132 -0
- package/src/procedural/reinforcement-core.ts +73 -0
- package/src/profiling.test.ts +263 -0
- package/src/profiling.ts +435 -0
- package/src/projection/index.ts +398 -0
- package/src/qmd-recall-cache.test.ts +138 -0
- package/src/qmd-recall-cache.ts +111 -0
- package/src/qmd.test.ts +258 -0
- package/src/qmd.ts +2614 -0
- package/src/reasoning-trace-recall.ts +201 -0
- package/src/reasoning-trace-types.ts +235 -0
- package/src/recall-audit-anomaly.test.ts +246 -0
- package/src/recall-audit-anomaly.ts +297 -0
- package/src/recall-audit.test.ts +51 -0
- package/src/recall-audit.ts +72 -0
- package/src/recall-budget-config.test.ts +87 -0
- package/src/recall-disclosure-escalation.test.ts +196 -0
- package/src/recall-disclosure-escalation.ts +158 -0
- package/src/recall-disclosure-shaping.test.ts +146 -0
- package/src/recall-disclosure.test.ts +214 -0
- package/src/recall-explain-renderer.test.ts +140 -0
- package/src/recall-explain-renderer.ts +356 -0
- package/src/recall-mmr.test.ts +808 -0
- package/src/recall-mmr.ts +607 -0
- package/src/recall-qos.test.ts +85 -0
- package/src/recall-qos.ts +82 -0
- package/src/recall-query-policy.ts +221 -0
- package/src/recall-state.test.ts +233 -0
- package/src/recall-state.ts +456 -0
- package/src/recall-tag-filter.ts +143 -0
- package/src/recall-tokenization.ts +35 -0
- package/src/recall-xray-cli.test.ts +118 -0
- package/src/recall-xray-cli.ts +100 -0
- package/src/recall-xray-disclosure-telemetry.test.ts +183 -0
- package/src/recall-xray-renderer.test.ts +539 -0
- package/src/recall-xray-renderer.ts +487 -0
- package/src/recall-xray.test.ts +503 -0
- package/src/recall-xray.ts +621 -0
- package/src/reconstruct.ts +41 -0
- package/src/release-changelog.ts +35 -0
- package/src/relevance.ts +67 -0
- package/src/replay/normalizers/chatgpt.ts +133 -0
- package/src/replay/normalizers/claude.ts +102 -0
- package/src/replay/normalizers/openclaw.ts +119 -0
- package/src/replay/normalizers/shared.ts +69 -0
- package/src/replay/runner.ts +197 -0
- package/src/replay/types.ts +143 -0
- package/src/rerank.test.ts +48 -0
- package/src/rerank.ts +176 -0
- package/src/resolve-auth-token.test.ts +226 -0
- package/src/resolve-auth-token.ts +151 -0
- package/src/resolve-provider-secret.test.ts +187 -0
- package/src/resolve-provider-secret.ts +410 -0
- package/src/response-guidance-recall.test.ts +3952 -0
- package/src/response-guidance-recall.ts +4431 -0
- package/src/resume-bundles.ts +415 -0
- package/src/retrieval-agents.ts +623 -0
- package/src/retrieval-tiers.ts +25 -0
- package/src/retrieval.ts +104 -0
- package/src/review/index.test.ts +201 -0
- package/src/review/index.ts +536 -0
- package/src/routing/engine.ts +162 -0
- package/src/routing/store.ts +321 -0
- package/src/runtime/better-sqlite.test.ts +32 -0
- package/src/runtime/better-sqlite.ts +76 -0
- package/src/runtime/child-process.ts +67 -0
- package/src/runtime/env.ts +48 -0
- package/src/sanitize.ts +58 -0
- package/src/schemas.ts +449 -0
- package/src/sdk-compat.ts +87 -0
- package/src/search/document-scanner.ts +96 -0
- package/src/search/embed-helper.ts +142 -0
- package/src/search/factory.ts +189 -0
- package/src/search/index.ts +10 -0
- package/src/search/lancedb-backend.ts +342 -0
- package/src/search/meilisearch-backend.ts +232 -0
- package/src/search/noop-backend.ts +57 -0
- package/src/search/orama-backend.ts +358 -0
- package/src/search/port.ts +86 -0
- package/src/search/remote-backend.ts +124 -0
- package/src/secure-store/cipher.ts +271 -0
- package/src/secure-store/cli-handlers.ts +355 -0
- package/src/secure-store/cli-renderer.ts +131 -0
- package/src/secure-store/header.ts +373 -0
- package/src/secure-store/index.ts +137 -0
- package/src/secure-store/kdf.ts +263 -0
- package/src/secure-store/keyring.ts +106 -0
- package/src/secure-store/metadata.ts +394 -0
- package/src/secure-store/passphrase-reader.ts +252 -0
- package/src/secure-store/secure-fs.ts +571 -0
- package/src/secure-store/secure-store.test.ts +755 -0
- package/src/semantic-chunking.ts +545 -0
- package/src/semantic-consolidation.test.ts +182 -0
- package/src/semantic-consolidation.ts +432 -0
- package/src/semantic-rule-promotion.ts +183 -0
- package/src/semantic-rule-verifier.ts +160 -0
- package/src/session-integrity.ts +569 -0
- package/src/session-observer-bands.ts +11 -0
- package/src/session-observer-state.ts +346 -0
- package/src/session-toggles.test.ts +96 -0
- package/src/session-toggles.ts +159 -0
- package/src/shared-context/manager.ts +810 -0
- package/src/signal.ts +84 -0
- package/src/skills-registry.test.ts +277 -0
- package/src/skills-registry.ts +120 -0
- package/src/source-attribution-roundtrip.test.ts +215 -0
- package/src/source-attribution.test.ts +1425 -0
- package/src/source-attribution.ts +639 -0
- package/src/spaces/index.ts +627 -0
- package/src/storage-paths.ts +117 -0
- package/src/storage.ts +6657 -0
- package/src/store-contract.ts +55 -0
- package/src/summarizer.ts +844 -0
- package/src/summary-snapshot.test.ts +681 -0
- package/src/summary-snapshot.ts +238 -0
- package/src/surfaces/dreams.test.ts +394 -0
- package/src/surfaces/dreams.ts +346 -0
- package/src/surfaces/heartbeat.test.ts +415 -0
- package/src/surfaces/heartbeat.ts +325 -0
- package/src/sync/index.ts +308 -0
- package/src/targeted-fact-recall.test.ts +1694 -0
- package/src/targeted-fact-recall.ts +2905 -0
- package/src/taxonomy/default-taxonomy.ts +87 -0
- package/src/taxonomy/index.ts +26 -0
- package/src/taxonomy/resolver-doc-generator.ts +57 -0
- package/src/taxonomy/resolver.ts +184 -0
- package/src/taxonomy/taxonomy-loader.ts +186 -0
- package/src/taxonomy/types.ts +48 -0
- package/src/telemetry-transcript.ts +70 -0
- package/src/temporal-index.ts +890 -0
- package/src/temporal-supersession.test.ts +2703 -0
- package/src/temporal-supersession.ts +493 -0
- package/src/temporal-validity.test.ts +448 -0
- package/src/temporal-validity.ts +123 -0
- package/src/threading.ts +395 -0
- package/src/tier-migration.ts +124 -0
- package/src/tier-routing.ts +102 -0
- package/src/tmt.ts +462 -0
- package/src/tokens.test.ts +178 -0
- package/src/tokens.ts +279 -0
- package/src/topics.ts +147 -0
- package/src/training-export/cli-date-validation.test.ts +258 -0
- package/src/training-export/converter.test.ts +452 -0
- package/src/training-export/converter.ts +319 -0
- package/src/training-export/date-parse.ts +117 -0
- package/src/training-export/index.ts +26 -0
- package/src/training-export/registry.test.ts +85 -0
- package/src/training-export/registry.ts +57 -0
- package/src/training-export/types.ts +31 -0
- package/src/transcript.ts +1179 -0
- package/src/transfer/autodetect.ts +30 -0
- package/src/transfer/backup.ts +138 -0
- package/src/transfer/capsule-crypto.ts +485 -0
- package/src/transfer/capsule-encrypt.test.ts +690 -0
- package/src/transfer/capsule-export.ts +543 -0
- package/src/transfer/capsule-fork.ts +375 -0
- package/src/transfer/capsule-import.ts +564 -0
- package/src/transfer/capsule-merge.ts +433 -0
- package/src/transfer/conflict-policy.ts +16 -0
- package/src/transfer/constants.ts +13 -0
- package/src/transfer/exclusions.ts +37 -0
- package/src/transfer/export-json.ts +65 -0
- package/src/transfer/export-md.ts +59 -0
- package/src/transfer/export-sqlite.ts +52 -0
- package/src/transfer/fs-utils.ts +269 -0
- package/src/transfer/import-json.ts +108 -0
- package/src/transfer/import-md.ts +84 -0
- package/src/transfer/import-sqlite.ts +100 -0
- package/src/transfer/integrity.ts +71 -0
- package/src/transfer/sqlite-schema.ts +16 -0
- package/src/transfer/types.ts +297 -0
- package/src/trust-zones.ts +1186 -0
- package/src/types.ts +3074 -0
- package/src/user-model.test.ts +124 -0
- package/src/user-model.ts +162 -0
- package/src/utility-learner.ts +353 -0
- package/src/utility-runtime.ts +88 -0
- package/src/utility-telemetry.ts +215 -0
- package/src/utils/category-dir.ts +44 -0
- package/src/utils/errno.ts +6 -0
- package/src/utils/iso-timestamp.test.ts +37 -0
- package/src/utils/iso-timestamp.ts +164 -0
- package/src/utils/path.ts +26 -0
- package/src/verified-recall.ts +138 -0
- package/src/version-utils.test.ts +10 -0
- package/src/version-utils.ts +9 -0
- package/src/whitespace.ts +10 -0
- package/src/work/board.ts +359 -0
- package/src/work/boundary.ts +107 -0
- package/src/work/storage.ts +436 -0
- package/src/work/types.ts +82 -0
- package/src/work-product-ledger.ts +265 -0
- package/dist/access-service-DDjzFALq.d.ts +0 -2088
- package/dist/capsule-crypto-SJS5VVAP.js +0 -18
- package/dist/capsule-export-7QNCBZOQ.js +0 -17
- package/dist/capsule-import-EPBHD2EN.js +0 -16
- package/dist/capsule-merge-DI7PNQ2H.js +0 -189
- package/dist/chunk-23ZZK64Y.js +0 -26
- package/dist/chunk-23ZZK64Y.js.map +0 -1
- package/dist/chunk-242S3I2A.js +0 -647
- package/dist/chunk-2LGMW3DJ.js +0 -111
- package/dist/chunk-3B6KIRBH.js +0 -5213
- package/dist/chunk-3B6KIRBH.js.map +0 -1
- package/dist/chunk-457A4P3L.js +0 -119
- package/dist/chunk-457A4P3L.js.map +0 -1
- package/dist/chunk-4IS4SXIQ.js +0 -2040
- package/dist/chunk-4YM32CRU.js +0 -721
- package/dist/chunk-6TBWYBJ3.js +0 -236
- package/dist/chunk-74EMIVE4.js +0 -329
- package/dist/chunk-74EMIVE4.js.map +0 -1
- package/dist/chunk-767ODGE6.js +0 -183
- package/dist/chunk-7V22HTMD.js +0 -623
- package/dist/chunk-7V22HTMD.js.map +0 -1
- package/dist/chunk-7ZM3BFKK.js +0 -9705
- package/dist/chunk-7ZM3BFKK.js.map +0 -1
- package/dist/chunk-AQJNPMOA.js +0 -643
- package/dist/chunk-AQJNPMOA.js.map +0 -1
- package/dist/chunk-ASAITVLA.js +0 -64
- package/dist/chunk-ASAITVLA.js.map +0 -1
- package/dist/chunk-BBE34QBJ.js +0 -275
- package/dist/chunk-BBE34QBJ.js.map +0 -1
- package/dist/chunk-BZSQEPRW.js +0 -14710
- package/dist/chunk-BZSQEPRW.js.map +0 -1
- package/dist/chunk-CPKTBRS2.js +0 -891
- package/dist/chunk-CPKTBRS2.js.map +0 -1
- package/dist/chunk-D4GAOFF6.js +0 -562
- package/dist/chunk-D4GAOFF6.js.map +0 -1
- package/dist/chunk-D54LZC5L.js +0 -147
- package/dist/chunk-DF3RVK3X.js +0 -119
- package/dist/chunk-DF3RVK3X.js.map +0 -1
- package/dist/chunk-DZZPC36E.js +0 -1451
- package/dist/chunk-DZZPC36E.js.map +0 -1
- package/dist/chunk-E2UCDP5S.js +0 -570
- package/dist/chunk-E6K4NIEU.js +0 -747
- package/dist/chunk-E6K4NIEU.js.map +0 -1
- package/dist/chunk-EEQLFRUM.js +0 -89
- package/dist/chunk-ETOW6ACV.js +0 -158
- package/dist/chunk-ETOW6ACV.js.map +0 -1
- package/dist/chunk-FMEBPEAO.js +0 -347
- package/dist/chunk-FMEBPEAO.js.map +0 -1
- package/dist/chunk-FQDPCE3I.js +0 -1837
- package/dist/chunk-FQDPCE3I.js.map +0 -1
- package/dist/chunk-FYIYMQ5N.js +0 -221
- package/dist/chunk-FYIYMQ5N.js.map +0 -1
- package/dist/chunk-G2WADRQ3.js +0 -219
- package/dist/chunk-G4SK7DSQ.js +0 -121
- package/dist/chunk-GVPWB7EY.js +0 -390
- package/dist/chunk-GVPWB7EY.js.map +0 -1
- package/dist/chunk-HELQZFZO.js +0 -1075
- package/dist/chunk-HL5LRPNA.js +0 -1914
- package/dist/chunk-HL5LRPNA.js.map +0 -1
- package/dist/chunk-HQZVVSVB.js +0 -147
- package/dist/chunk-HQZVVSVB.js.map +0 -1
- package/dist/chunk-HY3L4WKC.js +0 -2195
- package/dist/chunk-HY3L4WKC.js.map +0 -1
- package/dist/chunk-IB3BFHGN.js +0 -228
- package/dist/chunk-IXEJRKCZ.js +0 -18
- package/dist/chunk-JBMSGZEQ.js +0 -441
- package/dist/chunk-JBMSGZEQ.js.map +0 -1
- package/dist/chunk-JESOB2HO.js +0 -108
- package/dist/chunk-JKDVIE52.js +0 -272
- package/dist/chunk-JRNQ3RNA.js +0 -284
- package/dist/chunk-JRNQ3RNA.js.map +0 -1
- package/dist/chunk-K6WK37A6.js +0 -865
- package/dist/chunk-K6WK37A6.js.map +0 -1
- package/dist/chunk-MARWOCVP.js +0 -48
- package/dist/chunk-MNU6ZBWT.js +0 -4454
- package/dist/chunk-MNU6ZBWT.js.map +0 -1
- package/dist/chunk-N5AKDXAI.js +0 -74
- package/dist/chunk-OA3L7BFR.js +0 -183
- package/dist/chunk-OA3L7BFR.js.map +0 -1
- package/dist/chunk-OR64ZGRZ.js +0 -23
- package/dist/chunk-P77UEOU2.js +0 -1521
- package/dist/chunk-P77UEOU2.js.map +0 -1
- package/dist/chunk-PH4C2U43.js +0 -239
- package/dist/chunk-PH4C2U43.js.map +0 -1
- package/dist/chunk-RVPLBATS.js +0 -1586
- package/dist/chunk-RVPLBATS.js.map +0 -1
- package/dist/chunk-U5JMRGKX.js +0 -340
- package/dist/chunk-U5JMRGKX.js.map +0 -1
- package/dist/chunk-URB2WSKZ.js +0 -350
- package/dist/chunk-URB2WSKZ.js.map +0 -1
- package/dist/chunk-UVMUAWVT.js +0 -596
- package/dist/chunk-WEJG4TB5.js +0 -118
- package/dist/chunk-X7HPGUVG.js +0 -271
- package/dist/chunk-XAMBKFQS.js +0 -2777
- package/dist/chunk-XAMBKFQS.js.map +0 -1
- package/dist/chunk-XJKFSSDW.js +0 -726
- package/dist/chunk-XJKFSSDW.js.map +0 -1
- package/dist/chunk-XMHBH5H6.js +0 -283
- package/dist/chunk-XMHBH5H6.js.map +0 -1
- package/dist/chunk-XMVFHBHT.js +0 -277
- package/dist/chunk-Y3VMVTYX.js +0 -53
- package/dist/chunk-YNB73F22.js +0 -137
- package/dist/chunk-YNB73F22.js.map +0 -1
- package/dist/chunk-Z2E7VW55.js +0 -335
- package/dist/chunk-Z2E7VW55.js.map +0 -1
- package/dist/chunk-ZG7PTKBK.js +0 -2296
- package/dist/chunk-ZNQN6ZTA.js +0 -135
- package/dist/chunk-ZVTKDVVM.js +0 -827
- package/dist/chunk-ZVTKDVVM.js.map +0 -1
- package/dist/cli-BR8KpIU0.d.ts +0 -1259
- package/dist/codex-materialize-CQlLTzke.d.ts +0 -139
- package/dist/connectors-cli-DFGtY2DB.d.ts +0 -257
- package/dist/contradiction-review-5LTTVDQV.js +0 -22
- package/dist/contradiction-scan-QTXAMBUA.js +0 -414
- package/dist/contradiction-scan-QTXAMBUA.js.map +0 -1
- package/dist/engine-35M5BKQ7.js +0 -28
- package/dist/fs-utils-IRVUFB6G.js +0 -30
- package/dist/graph-edge-decay-PWB63GRE.js +0 -207
- package/dist/memory-governance-IMPQZXFC.js +0 -37
- package/dist/memory-projection-store-CY8TU40w.d.ts +0 -222
- package/dist/orchestrator-DDMPqU6R.d.ts +0 -1792
- package/dist/path-RMTY5Y5A.js +0 -9
- package/dist/port-B6VEDIkC.d.ts +0 -53
- package/dist/resolution-YGIBORXI.js +0 -101
- package/dist/resolution-YGIBORXI.js.map +0 -1
- package/dist/secure-store-4R2GSO7S.js +0 -156
- package/dist/semantic-consolidation-ByBXb-sf.d.ts +0 -180
- package/dist/state-store-3EH7HYIN.js +0 -16
- package/dist/types-V3FJ26TF.js +0 -30
- /package/dist/{capsule-crypto-SJS5VVAP.js.map → adapters/claude-code.js.map} +0 -0
- /package/dist/{capsule-export-7QNCBZOQ.js.map → adapters/codex.js.map} +0 -0
- /package/dist/{capsule-import-EPBHD2EN.js.map → adapters/hermes.js.map} +0 -0
- /package/dist/{contradiction-review-5LTTVDQV.js.map → adapters/index.js.map} +0 -0
- /package/dist/{engine-35M5BKQ7.js.map → adapters/registry.js.map} +0 -0
- /package/dist/{fs-utils-IRVUFB6G.js.map → adapters/replit.js.map} +0 -0
- /package/dist/{memory-governance-IMPQZXFC.js.map → adapters/types.js.map} +0 -0
- /package/dist/{path-RMTY5Y5A.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
- /package/dist/{capsule-merge-DI7PNQ2H.js.map → capsule-merge-4MGKE7C5.js.map} +0 -0
- /package/dist/{chunk-G4SK7DSQ.js.map → chunk-2WWLHTZY.js.map} +0 -0
- /package/dist/{chunk-X7HPGUVG.js.map → chunk-4CRG46BG.js.map} +0 -0
- /package/dist/{chunk-UVMUAWVT.js.map → chunk-7IASACLB.js.map} +0 -0
- /package/dist/{chunk-HELQZFZO.js.map → chunk-EDTHC6UD.js.map} +0 -0
- /package/dist/{chunk-4YM32CRU.js.map → chunk-EFJ3MQ4V.js.map} +0 -0
- /package/dist/{chunk-E2UCDP5S.js.map → chunk-FBYESMQ2.js.map} +0 -0
- /package/dist/{chunk-D54LZC5L.js.map → chunk-FDU6HUUL.js.map} +0 -0
- /package/dist/{chunk-IB3BFHGN.js.map → chunk-GGKRUQOO.js.map} +0 -0
- /package/dist/{chunk-242S3I2A.js.map → chunk-GL6I6MEQ.js.map} +0 -0
- /package/dist/{secure-store-4R2GSO7S.js.map → chunk-HHLLAQGZ.js.map} +0 -0
- /package/dist/{chunk-4IS4SXIQ.js.map → chunk-HXXBL2KD.js.map} +0 -0
- /package/dist/{chunk-767ODGE6.js.map → chunk-KNKUID7G.js.map} +0 -0
- /package/dist/{chunk-6TBWYBJ3.js.map → chunk-LPMVBPA3.js.map} +0 -0
- /package/dist/{chunk-WEJG4TB5.js.map → chunk-MC26UJIM.js.map} +0 -0
- /package/dist/{chunk-JKDVIE52.js.map → chunk-MGKYQQYF.js.map} +0 -0
- /package/dist/{chunk-Y3VMVTYX.js.map → chunk-MT4HVDUZ.js.map} +0 -0
- /package/dist/{chunk-G2WADRQ3.js.map → chunk-MY6TPVXW.js.map} +0 -0
- /package/dist/{chunk-OR64ZGRZ.js.map → chunk-NNVTUXEB.js.map} +0 -0
- /package/dist/{chunk-JESOB2HO.js.map → chunk-P4NEIHUT.js.map} +0 -0
- /package/dist/{chunk-IXEJRKCZ.js.map → chunk-QRNI5JBH.js.map} +0 -0
- /package/dist/{chunk-EEQLFRUM.js.map → chunk-RRF5UOBJ.js.map} +0 -0
- /package/dist/{state-store-3EH7HYIN.js.map → chunk-SEDEKFYQ.js.map} +0 -0
- /package/dist/{chunk-2LGMW3DJ.js.map → chunk-U3PN77QT.js.map} +0 -0
- /package/dist/{chunk-XMVFHBHT.js.map → chunk-U3WSW6PZ.js.map} +0 -0
- /package/dist/{chunk-N5AKDXAI.js.map → chunk-UWVJF25J.js.map} +0 -0
- /package/dist/{types-V3FJ26TF.js.map → chunk-V5OCT34X.js.map} +0 -0
- /package/dist/{chunk-ZG7PTKBK.js.map → chunk-W3LR522O.js.map} +0 -0
- /package/dist/{chunk-MARWOCVP.js.map → chunk-XIG5PDM7.js.map} +0 -0
- /package/dist/{chunk-ZNQN6ZTA.js.map → chunk-XVZ7B3HG.js.map} +0 -0
- /package/dist/{graph-edge-decay-PWB63GRE.js.map → graph-edge-decay-5DI5GUNL.js.map} +0 -0
package/dist/chunk-P77UEOU2.js
DELETED
|
@@ -1,1521 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
abortError,
|
|
3
|
-
isAbortError,
|
|
4
|
-
throwIfAborted
|
|
5
|
-
} from "./chunk-PVGDJXVK.js";
|
|
6
|
-
import {
|
|
7
|
-
launchProcess
|
|
8
|
-
} from "./chunk-OR64ZGRZ.js";
|
|
9
|
-
import {
|
|
10
|
-
getCachedQmdSearch,
|
|
11
|
-
setCachedQmdSearch
|
|
12
|
-
} from "./chunk-PFV5C235.js";
|
|
13
|
-
import {
|
|
14
|
-
mergeEnv
|
|
15
|
-
} from "./chunk-MARWOCVP.js";
|
|
16
|
-
import {
|
|
17
|
-
log
|
|
18
|
-
} from "./chunk-2ODBA7MQ.js";
|
|
19
|
-
|
|
20
|
-
// src/qmd.ts
|
|
21
|
-
import { createHash } from "crypto";
|
|
22
|
-
import os from "os";
|
|
23
|
-
import path from "path";
|
|
24
|
-
var QMD_TIMEOUT_MS = 3e4;
|
|
25
|
-
var QMD_DAEMON_TIMEOUT_MS = 8e3;
|
|
26
|
-
var QMD_PROBE_TIMEOUT_MS = 8e3;
|
|
27
|
-
var QMD_UPDATE_BACKOFF_MS = 15 * 60 * 1e3;
|
|
28
|
-
var QMD_EMBED_BACKOFF_MS = 60 * 60 * 1e3;
|
|
29
|
-
var QMD_CLI_WARN_THROTTLE_MS = 15 * 60 * 1e3;
|
|
30
|
-
var QMD_FALLBACK_PATHS = [
|
|
31
|
-
path.join(os.homedir(), ".bun", "bin", "qmd"),
|
|
32
|
-
"/usr/local/bin/qmd",
|
|
33
|
-
"/opt/homebrew/bin/qmd"
|
|
34
|
-
];
|
|
35
|
-
var QMD_GLOBAL_STATE_KEY = "__openclawEngramQmdGlobalState";
|
|
36
|
-
function getGlobalQmdState() {
|
|
37
|
-
const g = globalThis;
|
|
38
|
-
if (!g[QMD_GLOBAL_STATE_KEY]) {
|
|
39
|
-
g[QMD_GLOBAL_STATE_KEY] = {
|
|
40
|
-
warnedGlobalUpdateBehavior: false,
|
|
41
|
-
lastGlobalUpdateRunAtMs: null,
|
|
42
|
-
lastGlobalUpdateFailAtMs: null,
|
|
43
|
-
lastGlobalEmbedRunAtMs: null,
|
|
44
|
-
lastGlobalEmbedFailAtMs: null,
|
|
45
|
-
lastCliWarnAtMs: null,
|
|
46
|
-
lastUpdateByCollectionMs: {},
|
|
47
|
-
lastUpdateFailByCollectionMs: {},
|
|
48
|
-
lastEmbedByCollectionMs: {},
|
|
49
|
-
lastEmbedFailByCollectionMs: {}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return g[QMD_GLOBAL_STATE_KEY];
|
|
53
|
-
}
|
|
54
|
-
function errorMessage(err) {
|
|
55
|
-
if (typeof err === "string") return err;
|
|
56
|
-
if (err instanceof Error) return err.message;
|
|
57
|
-
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
58
|
-
return err.message;
|
|
59
|
-
}
|
|
60
|
-
return String(err);
|
|
61
|
-
}
|
|
62
|
-
function isCallerCancellation(err, signal) {
|
|
63
|
-
if (signal?.aborted) return true;
|
|
64
|
-
if (isAbortError(err)) return true;
|
|
65
|
-
if (err && typeof err === "object") {
|
|
66
|
-
const code = "code" in err ? err.code : void 0;
|
|
67
|
-
if (code === "ABORT_ERR" || code === "ERR_CANCELED") return true;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
function isDaemonTimeoutError(err) {
|
|
72
|
-
return /timed out/i.test(errorMessage(err));
|
|
73
|
-
}
|
|
74
|
-
function sleepWithSignal(ms, signal) {
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
throwIfAborted(signal);
|
|
77
|
-
const timer = setTimeout(() => {
|
|
78
|
-
cleanup();
|
|
79
|
-
resolve();
|
|
80
|
-
}, ms);
|
|
81
|
-
const onAbort = () => {
|
|
82
|
-
clearTimeout(timer);
|
|
83
|
-
cleanup();
|
|
84
|
-
reject(abortError("operation aborted while waiting"));
|
|
85
|
-
};
|
|
86
|
-
const cleanup = () => {
|
|
87
|
-
signal?.removeEventListener("abort", onAbort);
|
|
88
|
-
};
|
|
89
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function isSqliteBusyError(msg) {
|
|
93
|
-
const lower = msg.toLowerCase();
|
|
94
|
-
return lower.includes("database is locked") || lower.includes("sqlite_busy") || lower.includes("sqlite_busy_recovery") || lower.includes("sqliterror: database is locked");
|
|
95
|
-
}
|
|
96
|
-
function stripControlChars(s) {
|
|
97
|
-
return s.replace(/\x1b\[[0-9;]*[A-Za-z]/g, "").replace(/[\u0000-\u001f\u007f]/g, "");
|
|
98
|
-
}
|
|
99
|
-
function truncateForLog(s, max = 2e3) {
|
|
100
|
-
const cleaned = stripControlChars(s);
|
|
101
|
-
return cleaned.length > max ? cleaned.slice(0, max) + "\u2026(truncated)" : cleaned;
|
|
102
|
-
}
|
|
103
|
-
function isVectorDimensionMismatchError(err) {
|
|
104
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
105
|
-
return /dimension mismatch/i.test(msg) || /vectors?_vec/i.test(msg) && /float\[\d+\]/i.test(msg) || /embedding/i.test(msg) && /dimensions?/i.test(msg);
|
|
106
|
-
}
|
|
107
|
-
function parseQmdVersion(version) {
|
|
108
|
-
if (!version) return null;
|
|
109
|
-
const match = version.match(/v?(\d{1,10})\.(\d{1,10})\.(\d{1,10})/i);
|
|
110
|
-
if (!match) return null;
|
|
111
|
-
return [
|
|
112
|
-
Number.parseInt(match[1] ?? "0", 10),
|
|
113
|
-
Number.parseInt(match[2] ?? "0", 10),
|
|
114
|
-
Number.parseInt(match[3] ?? "0", 10)
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
function versionAtLeast(current, target) {
|
|
118
|
-
if (!current) return false;
|
|
119
|
-
for (let i = 0; i < 3; i += 1) {
|
|
120
|
-
if ((current[i] ?? 0) > target[i]) return true;
|
|
121
|
-
if ((current[i] ?? 0) < target[i]) return false;
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
function normalizeSearchOptions(options) {
|
|
126
|
-
if (!options) return void 0;
|
|
127
|
-
const intent = typeof options.intent === "string" ? options.intent.trim() : "";
|
|
128
|
-
const normalized = {};
|
|
129
|
-
if (intent.length > 0) {
|
|
130
|
-
normalized.intent = intent;
|
|
131
|
-
}
|
|
132
|
-
if (options.explain === true) {
|
|
133
|
-
normalized.explain = true;
|
|
134
|
-
}
|
|
135
|
-
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
136
|
-
}
|
|
137
|
-
function parseExplainScores(value) {
|
|
138
|
-
if (!Array.isArray(value)) return void 0;
|
|
139
|
-
const scores = value.filter((entry) => typeof entry === "number");
|
|
140
|
-
return scores.length > 0 ? scores : void 0;
|
|
141
|
-
}
|
|
142
|
-
function parseQmdExplain(value) {
|
|
143
|
-
if (!value || typeof value !== "object") return void 0;
|
|
144
|
-
const candidate = value;
|
|
145
|
-
const parsed = {
|
|
146
|
-
ftsScores: parseExplainScores(candidate.ftsScores),
|
|
147
|
-
vectorScores: parseExplainScores(candidate.vectorScores),
|
|
148
|
-
rrf: typeof candidate.rrf === "number" ? candidate.rrf : void 0,
|
|
149
|
-
rerankScore: typeof candidate.rerankScore === "number" ? candidate.rerankScore : void 0,
|
|
150
|
-
blendedScore: typeof candidate.blendedScore === "number" ? candidate.blendedScore : void 0
|
|
151
|
-
};
|
|
152
|
-
return Object.values(parsed).some((entry) => entry !== void 0) ? parsed : void 0;
|
|
153
|
-
}
|
|
154
|
-
var AsyncMutex = class {
|
|
155
|
-
locked = false;
|
|
156
|
-
queue = [];
|
|
157
|
-
async runExclusive(fn, signal) {
|
|
158
|
-
const release = await this.acquire(signal);
|
|
159
|
-
try {
|
|
160
|
-
throwIfAborted(signal);
|
|
161
|
-
return await fn();
|
|
162
|
-
} finally {
|
|
163
|
-
release();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
acquire(signal) {
|
|
167
|
-
throwIfAborted(signal);
|
|
168
|
-
if (!this.locked) {
|
|
169
|
-
this.locked = true;
|
|
170
|
-
return Promise.resolve(() => this.release());
|
|
171
|
-
}
|
|
172
|
-
return new Promise((resolve, reject) => {
|
|
173
|
-
const waiter = {
|
|
174
|
-
resolve: (release) => {
|
|
175
|
-
signal?.removeEventListener("abort", waiter.onAbort);
|
|
176
|
-
resolve(release);
|
|
177
|
-
},
|
|
178
|
-
reject: (reason) => {
|
|
179
|
-
signal?.removeEventListener("abort", waiter.onAbort);
|
|
180
|
-
reject(reason);
|
|
181
|
-
},
|
|
182
|
-
signal,
|
|
183
|
-
onAbort: () => {
|
|
184
|
-
this.queue = this.queue.filter((entry) => entry !== waiter);
|
|
185
|
-
reject(abortError("operation aborted while waiting for qmd mutex"));
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
signal?.addEventListener("abort", waiter.onAbort, { once: true });
|
|
189
|
-
this.queue.push(waiter);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
release() {
|
|
193
|
-
while (this.queue.length > 0) {
|
|
194
|
-
const next = this.queue.shift();
|
|
195
|
-
if (!next) break;
|
|
196
|
-
if (next.signal?.aborted) {
|
|
197
|
-
next.reject(abortError("operation aborted while waiting for qmd mutex"));
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
this.locked = true;
|
|
201
|
-
next.resolve(() => this.release());
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
this.locked = false;
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
var QMD_MUTEX = new AsyncMutex();
|
|
208
|
-
function runQmd(args, timeoutMs = QMD_TIMEOUT_MS, qmdPath = "qmd", signal) {
|
|
209
|
-
return QMD_MUTEX.runExclusive(async () => {
|
|
210
|
-
throwIfAborted(signal, `qmd ${args.join(" ")} aborted before start`);
|
|
211
|
-
const maxAttempts = isLikelyWriteCommand(args) ? 3 : 1;
|
|
212
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
213
|
-
try {
|
|
214
|
-
return await runQmdOnce(args, timeoutMs, qmdPath, signal);
|
|
215
|
-
} catch (err) {
|
|
216
|
-
if (isAbortError(err)) throw err;
|
|
217
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
218
|
-
if (attempt < maxAttempts && isSqliteBusyError(msg)) {
|
|
219
|
-
await sleepWithSignal(1500 * attempt, signal);
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
throw err;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
throw new Error("qmd command failed");
|
|
226
|
-
}, signal);
|
|
227
|
-
}
|
|
228
|
-
function isLikelyWriteCommand(args) {
|
|
229
|
-
const cmd = args[0] ?? "";
|
|
230
|
-
return cmd === "update" || cmd === "embed" || cmd === "cleanup" || cmd === "collection";
|
|
231
|
-
}
|
|
232
|
-
function runQmdOnce(args, timeoutMs, qmdPath, signal) {
|
|
233
|
-
return new Promise((resolve, reject) => {
|
|
234
|
-
throwIfAborted(signal, `qmd ${args.join(" ")} aborted before spawn`);
|
|
235
|
-
const child = launchProcess(qmdPath, args, {
|
|
236
|
-
env: mergeEnv({ NO_COLOR: "1" }),
|
|
237
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
238
|
-
});
|
|
239
|
-
if (!child.stdout || !child.stderr) {
|
|
240
|
-
reject(new Error(`qmd ${args.join(" ")} failed to open stdio pipes`));
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
let stdout = "";
|
|
244
|
-
let stderr = "";
|
|
245
|
-
let settled = false;
|
|
246
|
-
const timer = setTimeout(() => {
|
|
247
|
-
settled = true;
|
|
248
|
-
cleanup();
|
|
249
|
-
child.kill("SIGKILL");
|
|
250
|
-
reject(new Error(`qmd ${args.join(" ")} timed out after ${timeoutMs}ms`));
|
|
251
|
-
}, timeoutMs);
|
|
252
|
-
const onAbort = () => {
|
|
253
|
-
if (settled) return;
|
|
254
|
-
settled = true;
|
|
255
|
-
clearTimeout(timer);
|
|
256
|
-
cleanup();
|
|
257
|
-
child.kill("SIGKILL");
|
|
258
|
-
reject(abortError(`qmd ${args.join(" ")} aborted`));
|
|
259
|
-
};
|
|
260
|
-
const cleanup = () => {
|
|
261
|
-
signal?.removeEventListener("abort", onAbort);
|
|
262
|
-
};
|
|
263
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
264
|
-
child.stdout.on("data", (data) => {
|
|
265
|
-
stdout += data.toString();
|
|
266
|
-
});
|
|
267
|
-
child.stderr.on("data", (data) => {
|
|
268
|
-
stderr += data.toString();
|
|
269
|
-
});
|
|
270
|
-
child.on("error", (err) => {
|
|
271
|
-
if (settled) return;
|
|
272
|
-
settled = true;
|
|
273
|
-
clearTimeout(timer);
|
|
274
|
-
cleanup();
|
|
275
|
-
reject(err);
|
|
276
|
-
});
|
|
277
|
-
child.on("close", (code) => {
|
|
278
|
-
if (settled) return;
|
|
279
|
-
settled = true;
|
|
280
|
-
clearTimeout(timer);
|
|
281
|
-
cleanup();
|
|
282
|
-
const isVersionCheck = args.length === 1 && args[0] === "--version";
|
|
283
|
-
if (code === 0 || isVersionCheck && code === 1) {
|
|
284
|
-
resolve({ stdout, stderr });
|
|
285
|
-
} else {
|
|
286
|
-
reject(
|
|
287
|
-
new Error(
|
|
288
|
-
`qmd ${args.join(" ")} failed (code ${code}): ${truncateForLog(stderr || stdout)}`
|
|
289
|
-
)
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
var nextJsonRpcId = 1;
|
|
296
|
-
var QmdDaemonSession = class {
|
|
297
|
-
child = null;
|
|
298
|
-
initialized = false;
|
|
299
|
-
buffer = "";
|
|
300
|
-
startPromise = null;
|
|
301
|
-
pendingRequests = /* @__PURE__ */ new Map();
|
|
302
|
-
qmdPath;
|
|
303
|
-
constructor(qmdPath) {
|
|
304
|
-
this.qmdPath = qmdPath;
|
|
305
|
-
}
|
|
306
|
-
/** Spawn the qmd mcp child process and perform MCP handshake. */
|
|
307
|
-
async start() {
|
|
308
|
-
if (this.child && !this.child.killed && this.initialized) {
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
if (this.startPromise) {
|
|
312
|
-
return this.startPromise;
|
|
313
|
-
}
|
|
314
|
-
this.startPromise = (async () => {
|
|
315
|
-
const processAlreadyRunning = this.child != null && !this.child.killed;
|
|
316
|
-
if (!processAlreadyRunning) {
|
|
317
|
-
if (this.child) {
|
|
318
|
-
this.cleanup({ killChild: true });
|
|
319
|
-
}
|
|
320
|
-
try {
|
|
321
|
-
const child = launchProcess(this.qmdPath, ["mcp"], {
|
|
322
|
-
env: mergeEnv({ NO_COLOR: "1" }),
|
|
323
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
324
|
-
});
|
|
325
|
-
this.child = child;
|
|
326
|
-
this.buffer = "";
|
|
327
|
-
child.stdout?.on("data", (data) => {
|
|
328
|
-
if (this.child !== child) return;
|
|
329
|
-
this.handleStdoutData(data);
|
|
330
|
-
});
|
|
331
|
-
child.stderr?.on("data", (data) => {
|
|
332
|
-
if (this.child !== child) return;
|
|
333
|
-
const msg = data.toString().trim();
|
|
334
|
-
if (msg) log.debug(`QMD mcp stderr: ${stripControlChars(msg)}`);
|
|
335
|
-
});
|
|
336
|
-
child.stdin?.on("error", (err) => {
|
|
337
|
-
log.debug(`QMD mcp stdin error (suppressed): ${err.message}`);
|
|
338
|
-
});
|
|
339
|
-
child.on("error", (err) => {
|
|
340
|
-
if (this.child !== child) return;
|
|
341
|
-
log.debug(`QMD mcp process error: ${err.message}`);
|
|
342
|
-
this.cleanup({ child });
|
|
343
|
-
});
|
|
344
|
-
child.on("close", (code) => {
|
|
345
|
-
if (this.child !== child) return;
|
|
346
|
-
log.debug(`QMD mcp process exited (code ${code})`);
|
|
347
|
-
this.cleanup({ child });
|
|
348
|
-
});
|
|
349
|
-
} catch (err) {
|
|
350
|
-
log.debug(`QMD mcp: failed to spawn process: ${err}`);
|
|
351
|
-
this.cleanup({ killChild: true });
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
} else {
|
|
355
|
-
log.debug("QMD mcp: process already running, retrying handshake");
|
|
356
|
-
}
|
|
357
|
-
try {
|
|
358
|
-
const result = await this.sendRequest(
|
|
359
|
-
"initialize",
|
|
360
|
-
{
|
|
361
|
-
protocolVersion: "2024-11-05",
|
|
362
|
-
capabilities: {},
|
|
363
|
-
clientInfo: { name: "openclaw-remnic", version: "1.0.0" }
|
|
364
|
-
},
|
|
365
|
-
6e4
|
|
366
|
-
);
|
|
367
|
-
if (!result) {
|
|
368
|
-
this.cleanup({ killChild: true });
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
this.sendNotification("notifications/initialized");
|
|
372
|
-
this.initialized = true;
|
|
373
|
-
log.info("QMD mcp: stdio session initialized");
|
|
374
|
-
return true;
|
|
375
|
-
} catch (err) {
|
|
376
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
377
|
-
if (/timed out/i.test(msg)) {
|
|
378
|
-
log.debug(`QMD mcp: handshake timed out \u2014 process still loading, will retry later`);
|
|
379
|
-
this.initialized = false;
|
|
380
|
-
} else {
|
|
381
|
-
log.debug(`QMD mcp: failed to start stdio session: ${err}`);
|
|
382
|
-
this.cleanup({ killChild: true });
|
|
383
|
-
}
|
|
384
|
-
return false;
|
|
385
|
-
} finally {
|
|
386
|
-
this.startPromise = null;
|
|
387
|
-
}
|
|
388
|
-
})();
|
|
389
|
-
return this.startPromise;
|
|
390
|
-
}
|
|
391
|
-
/** Call an MCP tool and return the parsed result. */
|
|
392
|
-
async callTool(name, args, timeoutMs = 3e4, signal) {
|
|
393
|
-
if (!this.child || this.child.killed || !this.initialized) {
|
|
394
|
-
throw new Error("QMD mcp process not running");
|
|
395
|
-
}
|
|
396
|
-
return this.sendRequest("tools/call", { name, arguments: args }, timeoutMs, signal);
|
|
397
|
-
}
|
|
398
|
-
/** Kill stdio process and clear state so the next probe can restart. */
|
|
399
|
-
invalidate() {
|
|
400
|
-
this.cleanup({ killChild: true });
|
|
401
|
-
}
|
|
402
|
-
isActive() {
|
|
403
|
-
return this.child !== null && !this.child.killed && this.initialized;
|
|
404
|
-
}
|
|
405
|
-
/** True while the process is spawned but the MCP handshake has not yet completed. */
|
|
406
|
-
isLoading() {
|
|
407
|
-
return this.child !== null && !this.child.killed && !this.initialized;
|
|
408
|
-
}
|
|
409
|
-
sendRequest(method, params, timeoutMs, signal) {
|
|
410
|
-
return new Promise((resolve, reject) => {
|
|
411
|
-
throwIfAborted(signal, `QMD mcp ${method} aborted before request`);
|
|
412
|
-
if (!this.child || !this.child.stdin || this.child.killed) {
|
|
413
|
-
reject(new Error("QMD mcp process not available"));
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
const id = nextJsonRpcId++;
|
|
417
|
-
const timer = setTimeout(() => {
|
|
418
|
-
this.pendingRequests.delete(id);
|
|
419
|
-
cleanup();
|
|
420
|
-
reject(new Error(`QMD mcp ${method} timed out after ${timeoutMs}ms`));
|
|
421
|
-
}, timeoutMs);
|
|
422
|
-
const onAbort = () => {
|
|
423
|
-
clearTimeout(timer);
|
|
424
|
-
this.pendingRequests.delete(id);
|
|
425
|
-
cleanup();
|
|
426
|
-
reject(abortError(`QMD mcp ${method} aborted`));
|
|
427
|
-
};
|
|
428
|
-
const cleanup = () => {
|
|
429
|
-
signal?.removeEventListener("abort", onAbort);
|
|
430
|
-
};
|
|
431
|
-
this.pendingRequests.set(id, { resolve, reject, timer, cleanup });
|
|
432
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
433
|
-
const message = JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n";
|
|
434
|
-
this.child.stdin.write(message, (err) => {
|
|
435
|
-
if (err) {
|
|
436
|
-
clearTimeout(timer);
|
|
437
|
-
this.pendingRequests.delete(id);
|
|
438
|
-
cleanup();
|
|
439
|
-
reject(new Error(`Failed to write to QMD mcp stdin: ${err.message}`));
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
sendNotification(method, params) {
|
|
445
|
-
if (!this.child || !this.child.stdin || this.child.killed) return;
|
|
446
|
-
if (this.child.stdin.destroyed) return;
|
|
447
|
-
const msg = { jsonrpc: "2.0", method };
|
|
448
|
-
if (params) msg.params = params;
|
|
449
|
-
try {
|
|
450
|
-
this.child.stdin.write(JSON.stringify(msg) + "\n");
|
|
451
|
-
} catch {
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
handleStdoutData(data) {
|
|
455
|
-
this.buffer += data.toString();
|
|
456
|
-
let newlineIdx;
|
|
457
|
-
while ((newlineIdx = this.buffer.indexOf("\n")) !== -1) {
|
|
458
|
-
const line = this.buffer.slice(0, newlineIdx).trim();
|
|
459
|
-
this.buffer = this.buffer.slice(newlineIdx + 1);
|
|
460
|
-
if (!line) continue;
|
|
461
|
-
try {
|
|
462
|
-
const msg = JSON.parse(line);
|
|
463
|
-
this.handleMessage(msg);
|
|
464
|
-
} catch {
|
|
465
|
-
log.debug(`QMD mcp: unparseable stdout: ${truncateForLog(line, 200)}`);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
handleMessage(msg) {
|
|
470
|
-
if (msg.id !== void 0 && msg.id !== null) {
|
|
471
|
-
const pending = this.pendingRequests.get(msg.id);
|
|
472
|
-
if (pending) {
|
|
473
|
-
clearTimeout(pending.timer);
|
|
474
|
-
this.pendingRequests.delete(msg.id);
|
|
475
|
-
pending.cleanup();
|
|
476
|
-
if (msg.error) {
|
|
477
|
-
pending.reject(new Error(JSON.stringify(msg.error)));
|
|
478
|
-
} else {
|
|
479
|
-
pending.resolve(msg.result);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
if (msg.method) {
|
|
485
|
-
log.debug(`QMD mcp notification: ${msg.method}`);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
cleanup(opts) {
|
|
489
|
-
const target = opts?.child ?? this.child;
|
|
490
|
-
if (!target) return;
|
|
491
|
-
if (opts?.child && this.child !== opts.child) {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
if (opts?.killChild && !target.killed) {
|
|
495
|
-
target.kill("SIGTERM");
|
|
496
|
-
}
|
|
497
|
-
this.initialized = false;
|
|
498
|
-
for (const [, pending] of this.pendingRequests) {
|
|
499
|
-
clearTimeout(pending.timer);
|
|
500
|
-
pending.cleanup();
|
|
501
|
-
pending.reject(new Error("QMD mcp process terminated"));
|
|
502
|
-
}
|
|
503
|
-
this.pendingRequests.clear();
|
|
504
|
-
this.startPromise = null;
|
|
505
|
-
this.child = null;
|
|
506
|
-
this.buffer = "";
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
var QMD_RESULT_LINE_RE = /^#([0-9a-fA-F]+)\s+(\d+)%\s+(.+)/;
|
|
510
|
-
var QMD_PATH_TITLE_RE = /^(.+?\.[a-zA-Z]{2,10})\s+-\s+(.*)$/;
|
|
511
|
-
function parseQmdMarkdownResultText(text, transport) {
|
|
512
|
-
const results = [];
|
|
513
|
-
for (const line of text.split("\n")) {
|
|
514
|
-
const m = QMD_RESULT_LINE_RE.exec(line.trim());
|
|
515
|
-
if (!m) continue;
|
|
516
|
-
const rest = m[3];
|
|
517
|
-
const pathTitleSplit = QMD_PATH_TITLE_RE.exec(rest);
|
|
518
|
-
if (!pathTitleSplit) continue;
|
|
519
|
-
results.push({
|
|
520
|
-
docid: m[1],
|
|
521
|
-
path: pathTitleSplit[1] ?? "unknown",
|
|
522
|
-
snippet: "",
|
|
523
|
-
score: parseInt(m[2], 10) / 100,
|
|
524
|
-
transport
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
return results;
|
|
528
|
-
}
|
|
529
|
-
function parseMcpSearchResult(result, transport = "daemon") {
|
|
530
|
-
const resultObj = result;
|
|
531
|
-
if (!resultObj) return [];
|
|
532
|
-
const results = [];
|
|
533
|
-
const pushDocs = (docs) => {
|
|
534
|
-
for (const doc of docs) {
|
|
535
|
-
const d = doc;
|
|
536
|
-
results.push({
|
|
537
|
-
docid: typeof d.docid === "string" ? d.docid.replace(/^#/, "") : "",
|
|
538
|
-
path: typeof d.file === "string" ? d.file : typeof d.path === "string" ? d.path : typeof d.docid === "string" ? d.docid.replace(/^#/, "") : "unknown",
|
|
539
|
-
snippet: typeof d.snippet === "string" ? d.snippet : "",
|
|
540
|
-
score: typeof d.score === "number" ? d.score : 0,
|
|
541
|
-
explain: parseQmdExplain(d.explain),
|
|
542
|
-
transport
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
const topStructured = resultObj.structuredContent;
|
|
547
|
-
const topDocs = topStructured?.results ?? topStructured?.documents;
|
|
548
|
-
if (Array.isArray(topDocs)) pushDocs(topDocs);
|
|
549
|
-
const content = resultObj.content;
|
|
550
|
-
if (Array.isArray(content)) {
|
|
551
|
-
for (const item of content) {
|
|
552
|
-
const structured = item?.structuredContent;
|
|
553
|
-
const docResults = structured?.results ?? structured?.documents;
|
|
554
|
-
if (Array.isArray(docResults)) pushDocs(docResults);
|
|
555
|
-
if (typeof item?.text === "string") {
|
|
556
|
-
try {
|
|
557
|
-
const parsed = JSON.parse(item.text);
|
|
558
|
-
const textResults = parsed?.results ?? parsed?.documents;
|
|
559
|
-
if (Array.isArray(textResults)) pushDocs(textResults);
|
|
560
|
-
} catch {
|
|
561
|
-
const existingKeys = new Set(results.map((r) => `${r.docid.toLowerCase()}|${r.path}`));
|
|
562
|
-
const parsed = parseQmdMarkdownResultText(item.text, transport);
|
|
563
|
-
for (const p of parsed) {
|
|
564
|
-
const key = `${p.docid.toLowerCase()}|${p.path}`;
|
|
565
|
-
if (!existingKeys.has(key)) {
|
|
566
|
-
results.push(p);
|
|
567
|
-
existingKeys.add(key);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
return results;
|
|
575
|
-
}
|
|
576
|
-
function parseQmdSearchStdout(stdout, transport = "subprocess") {
|
|
577
|
-
const trimmedOut = stdout.trim();
|
|
578
|
-
if (!trimmedOut || trimmedOut === "No results found.") return [];
|
|
579
|
-
const parsed = JSON.parse(trimmedOut);
|
|
580
|
-
if (!Array.isArray(parsed)) return [];
|
|
581
|
-
return parsed.map(
|
|
582
|
-
(entry) => ({
|
|
583
|
-
docid: entry.docid ?? "",
|
|
584
|
-
path: entry.file ?? entry.path ?? entry.docid ?? "unknown",
|
|
585
|
-
snippet: entry.snippet ?? "",
|
|
586
|
-
score: typeof entry.score === "number" ? entry.score : 0,
|
|
587
|
-
explain: parseQmdExplain(entry.explain),
|
|
588
|
-
transport
|
|
589
|
-
})
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
var SHARED_DAEMON_SESSIONS = /* @__PURE__ */ new Map();
|
|
593
|
-
function retainSharedDaemonSession(qmdPath) {
|
|
594
|
-
const normalizedPath = qmdPath.trim() || "qmd";
|
|
595
|
-
const existing = SHARED_DAEMON_SESSIONS.get(normalizedPath);
|
|
596
|
-
if (existing) {
|
|
597
|
-
existing.refs += 1;
|
|
598
|
-
return existing.session;
|
|
599
|
-
}
|
|
600
|
-
const session = new QmdDaemonSession(normalizedPath);
|
|
601
|
-
SHARED_DAEMON_SESSIONS.set(normalizedPath, {
|
|
602
|
-
refs: 1,
|
|
603
|
-
session
|
|
604
|
-
});
|
|
605
|
-
return session;
|
|
606
|
-
}
|
|
607
|
-
function releaseSharedDaemonSession(session) {
|
|
608
|
-
if (!session) return;
|
|
609
|
-
for (const [qmdPath, entry] of SHARED_DAEMON_SESSIONS.entries()) {
|
|
610
|
-
if (entry.session !== session) continue;
|
|
611
|
-
entry.refs = Math.max(0, entry.refs - 1);
|
|
612
|
-
if (entry.refs === 0) {
|
|
613
|
-
entry.session.invalidate();
|
|
614
|
-
SHARED_DAEMON_SESSIONS.delete(qmdPath);
|
|
615
|
-
}
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
var QmdClient = class _QmdClient {
|
|
620
|
-
constructor(collection, maxResults, opts) {
|
|
621
|
-
this.collection = collection;
|
|
622
|
-
this.maxResults = maxResults;
|
|
623
|
-
this.slowLog = opts?.slowLog;
|
|
624
|
-
this.updateTimeoutMs = opts?.updateTimeoutMs ?? 12e4;
|
|
625
|
-
this.updateMinIntervalMs = Math.max(0, opts?.updateMinIntervalMs ?? 15 * 6e4);
|
|
626
|
-
this.configuredQmdPath = opts?.qmdPath?.trim() ? opts.qmdPath.trim() : void 0;
|
|
627
|
-
if (this.configuredQmdPath) {
|
|
628
|
-
this.qmdPath = this.configuredQmdPath;
|
|
629
|
-
this.qmdPathSource = "configured";
|
|
630
|
-
}
|
|
631
|
-
this.daemonEnabled = Boolean(opts?.daemonUrl);
|
|
632
|
-
this.daemonRecheckIntervalMs = opts?.daemonRecheckIntervalMs ?? 15e3;
|
|
633
|
-
}
|
|
634
|
-
collection;
|
|
635
|
-
maxResults;
|
|
636
|
-
available = null;
|
|
637
|
-
_lastUpdateFailAtMs = null;
|
|
638
|
-
lastEmbedFailAtMs = null;
|
|
639
|
-
lastUpdateRunAtMs = null;
|
|
640
|
-
get lastUpdateFailedAtMs() {
|
|
641
|
-
return this._lastUpdateFailAtMs;
|
|
642
|
-
}
|
|
643
|
-
get lastUpdateRanAtMs() {
|
|
644
|
-
return this.lastUpdateRunAtMs;
|
|
645
|
-
}
|
|
646
|
-
resetUpdateThrottles() {
|
|
647
|
-
this._lastUpdateFailAtMs = null;
|
|
648
|
-
this.lastUpdateRunAtMs = null;
|
|
649
|
-
const gs = getGlobalQmdState();
|
|
650
|
-
gs.lastGlobalUpdateRunAtMs = null;
|
|
651
|
-
gs.lastGlobalUpdateFailAtMs = null;
|
|
652
|
-
}
|
|
653
|
-
updateTimeoutMs;
|
|
654
|
-
updateMinIntervalMs;
|
|
655
|
-
slowLog;
|
|
656
|
-
configuredQmdPath;
|
|
657
|
-
qmdPathSource = "auto-path";
|
|
658
|
-
cliVersion = null;
|
|
659
|
-
lastCliProbeError = null;
|
|
660
|
-
// Daemon mode fields
|
|
661
|
-
daemonSession = null;
|
|
662
|
-
daemonAvailable = false;
|
|
663
|
-
daemonSessionPath = null;
|
|
664
|
-
lastDaemonCheckAtMs = 0;
|
|
665
|
-
daemonEnabled;
|
|
666
|
-
daemonRecheckIntervalMs;
|
|
667
|
-
/** Consecutive transient daemon failures before invalidating the session. */
|
|
668
|
-
daemonTransientFailures = 0;
|
|
669
|
-
static DAEMON_MAX_TRANSIENT_FAILURES = 3;
|
|
670
|
-
qmdPath = "qmd";
|
|
671
|
-
async probe() {
|
|
672
|
-
const cliOk = await this.probeCli();
|
|
673
|
-
if (this.daemonEnabled) {
|
|
674
|
-
await this.probeDaemon();
|
|
675
|
-
}
|
|
676
|
-
return cliOk || this.daemonAvailable;
|
|
677
|
-
}
|
|
678
|
-
async probeDaemon() {
|
|
679
|
-
this.lastDaemonCheckAtMs = Date.now();
|
|
680
|
-
const normalizedPath = this.qmdPath.trim() || "qmd";
|
|
681
|
-
if (!this.daemonSession || this.daemonSessionPath !== normalizedPath) {
|
|
682
|
-
releaseSharedDaemonSession(this.daemonSession);
|
|
683
|
-
this.daemonSession = retainSharedDaemonSession(normalizedPath);
|
|
684
|
-
this.daemonSessionPath = normalizedPath;
|
|
685
|
-
}
|
|
686
|
-
try {
|
|
687
|
-
const PROBE_QUICK_TIMEOUT_MS = 3e3;
|
|
688
|
-
const ok = await Promise.race([
|
|
689
|
-
this.daemonSession.start(),
|
|
690
|
-
new Promise((resolve) => setTimeout(() => resolve(false), PROBE_QUICK_TIMEOUT_MS))
|
|
691
|
-
]);
|
|
692
|
-
if (!ok) {
|
|
693
|
-
const loading = this.daemonSession.isLoading();
|
|
694
|
-
log.debug(`QMD daemon: stdio session not ready within ${PROBE_QUICK_TIMEOUT_MS}ms probe window${loading ? " (still loading)" : ""}`);
|
|
695
|
-
this.daemonAvailable = false;
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
698
|
-
log.info(`QMD daemon: stdio session active (collection=${this.collection})`);
|
|
699
|
-
this.daemonAvailable = true;
|
|
700
|
-
this.daemonTransientFailures = 0;
|
|
701
|
-
return true;
|
|
702
|
-
} catch (err) {
|
|
703
|
-
log.debug(`QMD daemon: probe failed: ${err}`);
|
|
704
|
-
this.daemonAvailable = false;
|
|
705
|
-
return false;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
async probeCli() {
|
|
709
|
-
const parseVersion = (stdout, stderr) => {
|
|
710
|
-
const lines = `${stdout}
|
|
711
|
-
${stderr}`.split("\n").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
712
|
-
if (lines.length === 0) return null;
|
|
713
|
-
const semanticLines = lines.filter((line) => parseQmdVersion(line) !== null);
|
|
714
|
-
if (semanticLines.length === 0) return lines[0] ?? null;
|
|
715
|
-
return semanticLines.find((line) => /\bqmd\b/i.test(line)) ?? semanticLines[0] ?? null;
|
|
716
|
-
};
|
|
717
|
-
const markProbeFailure = (err) => {
|
|
718
|
-
this.lastCliProbeError = err instanceof Error ? err.message : String(err);
|
|
719
|
-
};
|
|
720
|
-
if (this.configuredQmdPath) {
|
|
721
|
-
try {
|
|
722
|
-
const result = await runQmd(["--version"], QMD_PROBE_TIMEOUT_MS, this.configuredQmdPath);
|
|
723
|
-
this.available = true;
|
|
724
|
-
this.qmdPath = this.configuredQmdPath;
|
|
725
|
-
this.qmdPathSource = "configured";
|
|
726
|
-
this.cliVersion = parseVersion(result.stdout, result.stderr);
|
|
727
|
-
this.lastCliProbeError = null;
|
|
728
|
-
return true;
|
|
729
|
-
} catch (err) {
|
|
730
|
-
markProbeFailure(err);
|
|
731
|
-
this.logCliProbeWarning(
|
|
732
|
-
`QMD: configured qmdPath failed (${this.configuredQmdPath}): ${this.lastCliProbeError}`
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
try {
|
|
737
|
-
const result = await runQmd(["--version"], QMD_PROBE_TIMEOUT_MS, "qmd");
|
|
738
|
-
this.available = true;
|
|
739
|
-
this.qmdPath = "qmd";
|
|
740
|
-
this.qmdPathSource = "auto-path";
|
|
741
|
-
this.cliVersion = parseVersion(result.stdout, result.stderr);
|
|
742
|
-
this.lastCliProbeError = null;
|
|
743
|
-
return true;
|
|
744
|
-
} catch (err) {
|
|
745
|
-
markProbeFailure(err);
|
|
746
|
-
for (const fallbackPath of QMD_FALLBACK_PATHS) {
|
|
747
|
-
try {
|
|
748
|
-
const result = await runQmd(["--version"], QMD_PROBE_TIMEOUT_MS, fallbackPath);
|
|
749
|
-
this.available = true;
|
|
750
|
-
this.qmdPath = fallbackPath;
|
|
751
|
-
this.qmdPathSource = "auto-fallback";
|
|
752
|
-
this.cliVersion = parseVersion(result.stdout, result.stderr);
|
|
753
|
-
this.lastCliProbeError = null;
|
|
754
|
-
log.info(`QMD: found at ${fallbackPath}`);
|
|
755
|
-
return true;
|
|
756
|
-
} catch (fallbackErr) {
|
|
757
|
-
markProbeFailure(fallbackErr);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
this.available = false;
|
|
761
|
-
return false;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
logCliProbeWarning(message) {
|
|
765
|
-
const state = getGlobalQmdState();
|
|
766
|
-
const now = Date.now();
|
|
767
|
-
const canWarn = state.lastCliWarnAtMs === null || now - state.lastCliWarnAtMs >= QMD_CLI_WARN_THROTTLE_MS;
|
|
768
|
-
if (!canWarn) {
|
|
769
|
-
log.debug(message);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
state.lastCliWarnAtMs = now;
|
|
773
|
-
if (this.daemonAvailable) {
|
|
774
|
-
log.debug(message);
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
log.warn(message);
|
|
778
|
-
}
|
|
779
|
-
/** Re-probe daemon if it was down and recheck interval has elapsed. */
|
|
780
|
-
async maybeProbeDaemon() {
|
|
781
|
-
if (!this.daemonEnabled) return;
|
|
782
|
-
if (this.daemonAvailable && this.daemonSession?.isActive()) return;
|
|
783
|
-
if (this.daemonAvailable === false) {
|
|
784
|
-
const elapsed = Date.now() - this.lastDaemonCheckAtMs;
|
|
785
|
-
if (elapsed < this.daemonRecheckIntervalMs) return;
|
|
786
|
-
}
|
|
787
|
-
this.daemonAvailable = false;
|
|
788
|
-
await this.probeDaemon();
|
|
789
|
-
}
|
|
790
|
-
isAvailable() {
|
|
791
|
-
return this.available === true || this.daemonAvailable;
|
|
792
|
-
}
|
|
793
|
-
/** Debug string for troubleshooting availability issues. */
|
|
794
|
-
debugStatus() {
|
|
795
|
-
const cliPath = this.available ? this.qmdPath : this.configuredQmdPath ?? "unavailable";
|
|
796
|
-
const cliVersion = this.cliVersion ?? "unknown";
|
|
797
|
-
const probeError = this.lastCliProbeError ? ` cliProbeError=${this.lastCliProbeError}` : "";
|
|
798
|
-
return `cli=${this.available} daemon=${this.daemonAvailable} session=${!!this.daemonSession} cliPath=${cliPath} cliPathSource=${this.qmdPathSource} cliVersion=${cliVersion}${probeError}`;
|
|
799
|
-
}
|
|
800
|
-
isDaemonMode() {
|
|
801
|
-
return this.daemonAvailable;
|
|
802
|
-
}
|
|
803
|
-
dispose() {
|
|
804
|
-
releaseSharedDaemonSession(this.daemonSession);
|
|
805
|
-
this.daemonSession = null;
|
|
806
|
-
this.daemonSessionPath = null;
|
|
807
|
-
this.daemonAvailable = false;
|
|
808
|
-
this.daemonTransientFailures = 0;
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* Record a daemon search success — resets the transient failure counter.
|
|
812
|
-
*/
|
|
813
|
-
recordDaemonSuccess() {
|
|
814
|
-
this.daemonTransientFailures = 0;
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
* Handle a non-timeout, non-cancellation daemon error.
|
|
818
|
-
* Tolerates up to DAEMON_MAX_TRANSIENT_FAILURES consecutive failures
|
|
819
|
-
* before invalidating the session. This prevents a single transient
|
|
820
|
-
* error from pushing all concurrent searches through the subprocess
|
|
821
|
-
* mutex for the full recheck interval.
|
|
822
|
-
*/
|
|
823
|
-
handleDaemonTransientError(label, err, durationMs) {
|
|
824
|
-
if (!this.daemonAvailable) {
|
|
825
|
-
log.debug(`QMD daemon ${label} failed after ${durationMs}ms (daemon already unavailable, ignoring): ${err}`);
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
this.daemonTransientFailures += 1;
|
|
829
|
-
if (this.daemonTransientFailures >= _QmdClient.DAEMON_MAX_TRANSIENT_FAILURES) {
|
|
830
|
-
log.debug(`QMD daemon ${label} failed after ${durationMs}ms (${this.daemonTransientFailures} consecutive failures, invalidating): ${err}`);
|
|
831
|
-
this.daemonSession?.invalidate();
|
|
832
|
-
this.daemonAvailable = false;
|
|
833
|
-
this.daemonTransientFailures = 0;
|
|
834
|
-
} else {
|
|
835
|
-
log.debug(`QMD daemon ${label} failed after ${durationMs}ms (transient ${this.daemonTransientFailures}/${_QmdClient.DAEMON_MAX_TRANSIENT_FAILURES}): ${err}`);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
async runQmdCommand(args, timeoutMs, signal) {
|
|
839
|
-
return runQmd(args, timeoutMs, this.qmdPath, signal);
|
|
840
|
-
}
|
|
841
|
-
supportsIntentHints() {
|
|
842
|
-
return versionAtLeast(parseQmdVersion(this.cliVersion), [1, 1, 5]);
|
|
843
|
-
}
|
|
844
|
-
supportsExplainTraces() {
|
|
845
|
-
return versionAtLeast(parseQmdVersion(this.cliVersion), [1, 1, 2]);
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* QMD v2 (>= 2.0.0) uses a new MCP tool API:
|
|
849
|
-
* - `search` and `vsearch` tools removed; only `query` tool exists
|
|
850
|
-
* - `query` accepts `{ searches: [{ type, query }], collections?: string[] }`
|
|
851
|
-
* instead of `{ query: string, collection?: string }`
|
|
852
|
-
* - `collection` (singular) → `collections` (plural array)
|
|
853
|
-
*/
|
|
854
|
-
isQmdV2() {
|
|
855
|
-
return versionAtLeast(parseQmdVersion(this.cliVersion), [2, 0, 0]);
|
|
856
|
-
}
|
|
857
|
-
resolveSearchOptions(options) {
|
|
858
|
-
const normalized = normalizeSearchOptions(options);
|
|
859
|
-
if (!normalized) return void 0;
|
|
860
|
-
const resolved = {};
|
|
861
|
-
if (normalized.intent && this.supportsIntentHints()) {
|
|
862
|
-
resolved.intent = normalized.intent;
|
|
863
|
-
}
|
|
864
|
-
if (normalized.explain === true && this.supportsExplainTraces()) {
|
|
865
|
-
resolved.explain = true;
|
|
866
|
-
}
|
|
867
|
-
return Object.keys(resolved).length > 0 ? resolved : void 0;
|
|
868
|
-
}
|
|
869
|
-
resolveSupportedSearchOptions(options) {
|
|
870
|
-
return this.resolveSearchOptions(options);
|
|
871
|
-
}
|
|
872
|
-
async search(query, collection, maxResults, options, execution) {
|
|
873
|
-
if (!this.isAvailable()) return [];
|
|
874
|
-
const trimmed = query.trim();
|
|
875
|
-
if (!trimmed) return [];
|
|
876
|
-
const col = collection ?? this.collection;
|
|
877
|
-
const n = maxResults ?? this.maxResults;
|
|
878
|
-
const searchOptions = this.resolveSearchOptions(options);
|
|
879
|
-
const optionsFingerprint = searchOptions ? JSON.stringify(searchOptions) : "";
|
|
880
|
-
const cacheKey = createHash("sha256").update(`${col}:${n}:${optionsFingerprint}:${trimmed}`).digest("hex");
|
|
881
|
-
const cached = getCachedQmdSearch(cacheKey);
|
|
882
|
-
if (cached) {
|
|
883
|
-
log.debug(`QMD search cache hit (${cached.length} results)`);
|
|
884
|
-
return cached;
|
|
885
|
-
}
|
|
886
|
-
await this.maybeProbeDaemon();
|
|
887
|
-
if (this.daemonAvailable) {
|
|
888
|
-
let results;
|
|
889
|
-
try {
|
|
890
|
-
results = await this.searchViaDaemon(trimmed, col, n, searchOptions, execution?.signal);
|
|
891
|
-
} catch (err) {
|
|
892
|
-
if (isCallerCancellation(err, execution?.signal)) {
|
|
893
|
-
throw isAbortError(err) ? err : abortError("QMD daemon search aborted");
|
|
894
|
-
}
|
|
895
|
-
throw err;
|
|
896
|
-
}
|
|
897
|
-
if (results !== null) {
|
|
898
|
-
if (results.length === 0) {
|
|
899
|
-
log.debug("QMD daemon search returned 0 results; skipping subprocess");
|
|
900
|
-
}
|
|
901
|
-
setCachedQmdSearch(cacheKey, results);
|
|
902
|
-
return results;
|
|
903
|
-
}
|
|
904
|
-
log.debug("QMD daemon search timed out/failed; skipping subprocess (daemon-only mode)");
|
|
905
|
-
return [];
|
|
906
|
-
}
|
|
907
|
-
if (this.daemonSession?.isLoading()) {
|
|
908
|
-
log.debug("QMD search: daemon loading, skipping subprocess");
|
|
909
|
-
return [];
|
|
910
|
-
}
|
|
911
|
-
const subprocessResults = await this.searchViaSubprocess(trimmed, col, n, searchOptions, execution?.signal);
|
|
912
|
-
setCachedQmdSearch(cacheKey, subprocessResults);
|
|
913
|
-
return subprocessResults;
|
|
914
|
-
}
|
|
915
|
-
async searchGlobal(query, maxResults, execution) {
|
|
916
|
-
if (!this.isAvailable()) return [];
|
|
917
|
-
const trimmed = query.trim();
|
|
918
|
-
if (!trimmed) return [];
|
|
919
|
-
const n = maxResults ?? 6;
|
|
920
|
-
await this.maybeProbeDaemon();
|
|
921
|
-
if (this.daemonAvailable) {
|
|
922
|
-
let results;
|
|
923
|
-
try {
|
|
924
|
-
results = await this.searchViaDaemon(trimmed, void 0, n, void 0, execution?.signal);
|
|
925
|
-
} catch (err) {
|
|
926
|
-
if (isCallerCancellation(err, execution?.signal)) {
|
|
927
|
-
throw isAbortError(err) ? err : abortError("QMD daemon global search aborted");
|
|
928
|
-
}
|
|
929
|
-
throw err;
|
|
930
|
-
}
|
|
931
|
-
if (results !== null) {
|
|
932
|
-
if (results.length === 0) {
|
|
933
|
-
log.debug("QMD daemon global search returned 0 results; skipping subprocess");
|
|
934
|
-
}
|
|
935
|
-
return results;
|
|
936
|
-
}
|
|
937
|
-
log.debug("QMD daemon global search timed out/failed; skipping subprocess (daemon-only mode)");
|
|
938
|
-
return [];
|
|
939
|
-
}
|
|
940
|
-
if (this.daemonSession?.isLoading()) {
|
|
941
|
-
log.debug("QMD searchGlobal: daemon loading, skipping subprocess");
|
|
942
|
-
return [];
|
|
943
|
-
}
|
|
944
|
-
return this.searchGlobalViaSubprocess(trimmed, n, execution?.signal);
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* BM25 keyword search (fast, ~0.3s). Uses `qmd search`.
|
|
948
|
-
*/
|
|
949
|
-
async bm25Search(query, collection, maxResults, execution) {
|
|
950
|
-
if (!this.isAvailable()) return [];
|
|
951
|
-
const trimmed = query.trim();
|
|
952
|
-
if (!trimmed) return [];
|
|
953
|
-
const col = collection ?? this.collection;
|
|
954
|
-
const n = maxResults ?? this.maxResults;
|
|
955
|
-
await this.maybeProbeDaemon();
|
|
956
|
-
if (this.daemonAvailable && this.daemonSession) {
|
|
957
|
-
let results;
|
|
958
|
-
try {
|
|
959
|
-
results = await this.bm25SearchViaDaemon(trimmed, col, n, execution?.signal);
|
|
960
|
-
} catch (err) {
|
|
961
|
-
if (isCallerCancellation(err, execution?.signal)) {
|
|
962
|
-
throw isAbortError(err) ? err : abortError("QMD daemon bm25 aborted");
|
|
963
|
-
}
|
|
964
|
-
throw err;
|
|
965
|
-
}
|
|
966
|
-
if (results !== null) {
|
|
967
|
-
if (results.length === 0) {
|
|
968
|
-
log.debug("QMD daemon bm25 returned 0 results; skipping subprocess");
|
|
969
|
-
}
|
|
970
|
-
return results;
|
|
971
|
-
}
|
|
972
|
-
log.debug("QMD daemon bm25 timed out/failed; skipping subprocess (daemon-only mode)");
|
|
973
|
-
return [];
|
|
974
|
-
}
|
|
975
|
-
if (this.daemonSession?.isLoading()) {
|
|
976
|
-
log.debug("QMD bm25: daemon loading, skipping subprocess");
|
|
977
|
-
return [];
|
|
978
|
-
}
|
|
979
|
-
return this.bm25SearchViaSubprocess(trimmed, col, n, execution?.signal);
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Vector similarity search (~3-4s). Uses `qmd vsearch`.
|
|
983
|
-
*/
|
|
984
|
-
async vectorSearch(query, collection, maxResults, execution) {
|
|
985
|
-
if (!this.isAvailable()) return [];
|
|
986
|
-
const trimmed = query.trim();
|
|
987
|
-
if (!trimmed) return [];
|
|
988
|
-
const col = collection ?? this.collection;
|
|
989
|
-
const n = maxResults ?? this.maxResults;
|
|
990
|
-
await this.maybeProbeDaemon();
|
|
991
|
-
if (this.daemonAvailable && this.daemonSession) {
|
|
992
|
-
let results;
|
|
993
|
-
try {
|
|
994
|
-
results = await this.vsearchViaDaemon(trimmed, col, n, execution?.signal);
|
|
995
|
-
} catch (err) {
|
|
996
|
-
if (isCallerCancellation(err, execution?.signal)) {
|
|
997
|
-
throw isAbortError(err) ? err : abortError("QMD daemon vsearch aborted");
|
|
998
|
-
}
|
|
999
|
-
throw err;
|
|
1000
|
-
}
|
|
1001
|
-
if (results !== null) {
|
|
1002
|
-
if (results.length === 0) {
|
|
1003
|
-
log.debug("QMD daemon vsearch returned 0 results; skipping subprocess");
|
|
1004
|
-
}
|
|
1005
|
-
return results;
|
|
1006
|
-
}
|
|
1007
|
-
log.debug("QMD daemon vsearch timed out/failed; skipping subprocess (daemon-only mode)");
|
|
1008
|
-
return [];
|
|
1009
|
-
}
|
|
1010
|
-
if (this.daemonSession?.isLoading()) {
|
|
1011
|
-
log.debug("QMD vsearch: daemon loading, skipping subprocess");
|
|
1012
|
-
return [];
|
|
1013
|
-
}
|
|
1014
|
-
return this.vsearchViaSubprocess(trimmed, col, n, execution?.signal);
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Hybrid search: runs BM25 + vector in parallel, merges/dedupes by path
|
|
1018
|
-
* keeping the best score and first non-empty snippet.
|
|
1019
|
-
*/
|
|
1020
|
-
async hybridSearch(query, collection, maxResults, execution) {
|
|
1021
|
-
const n = maxResults ?? this.maxResults;
|
|
1022
|
-
const trimmed = query.trim();
|
|
1023
|
-
if (!trimmed) return [];
|
|
1024
|
-
const [bm25Results, vectorResults] = await Promise.all([
|
|
1025
|
-
this.bm25Search(trimmed, collection, n, execution),
|
|
1026
|
-
this.vectorSearch(trimmed, collection, n, execution)
|
|
1027
|
-
]);
|
|
1028
|
-
const merged = /* @__PURE__ */ new Map();
|
|
1029
|
-
for (const r of [...bm25Results, ...vectorResults]) {
|
|
1030
|
-
const key = r.path || r.docid;
|
|
1031
|
-
const existing = merged.get(key);
|
|
1032
|
-
if (!existing || r.score > existing.score) {
|
|
1033
|
-
merged.set(key, {
|
|
1034
|
-
...r,
|
|
1035
|
-
snippet: r.snippet || existing?.snippet || ""
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
return [...merged.values()].sort((a, b) => b.score - a.score).slice(0, n);
|
|
1040
|
-
}
|
|
1041
|
-
async searchViaDaemon(query, collection, maxResults, options, signal) {
|
|
1042
|
-
if (!this.daemonSession || !this.daemonAvailable) return null;
|
|
1043
|
-
const startedAtMs = Date.now();
|
|
1044
|
-
const v2 = this.isQmdV2();
|
|
1045
|
-
try {
|
|
1046
|
-
let args;
|
|
1047
|
-
if (v2) {
|
|
1048
|
-
const searches = [{ type: "lex", query }];
|
|
1049
|
-
searches.push({ type: "vec", query });
|
|
1050
|
-
args = { searches, limit: maxResults };
|
|
1051
|
-
if (collection) {
|
|
1052
|
-
args.collections = [collection];
|
|
1053
|
-
}
|
|
1054
|
-
if (options?.intent) {
|
|
1055
|
-
args.intent = options.intent;
|
|
1056
|
-
}
|
|
1057
|
-
if (options?.explain === true) {
|
|
1058
|
-
args.explain = true;
|
|
1059
|
-
}
|
|
1060
|
-
} else {
|
|
1061
|
-
args = { query, limit: maxResults };
|
|
1062
|
-
if (collection) {
|
|
1063
|
-
args.collection = collection;
|
|
1064
|
-
}
|
|
1065
|
-
if (options?.intent) {
|
|
1066
|
-
args.intent = options.intent;
|
|
1067
|
-
}
|
|
1068
|
-
if (options?.explain === true) {
|
|
1069
|
-
args.explain = true;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
const result = await this.daemonSession.callTool("query", args, QMD_DAEMON_TIMEOUT_MS, signal);
|
|
1073
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1074
|
-
if (this.slowLog?.enabled && durationMs >= this.slowLog.thresholdMs) {
|
|
1075
|
-
log.warn(
|
|
1076
|
-
`SLOW QMD daemon query: durationMs=${durationMs} collection=${collection ?? "global"} maxResults=${maxResults} queryChars=${query.length} v2=${v2}`
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1079
|
-
const results = parseMcpSearchResult(result, "daemon");
|
|
1080
|
-
log.debug(`QMD daemon search: ${results.length} results in ${durationMs}ms (v2=${v2})`);
|
|
1081
|
-
this.recordDaemonSuccess();
|
|
1082
|
-
return results;
|
|
1083
|
-
} catch (err) {
|
|
1084
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1085
|
-
if (isCallerCancellation(err, signal)) {
|
|
1086
|
-
log.debug(`QMD daemon search aborted/cancelled after ${durationMs}ms`);
|
|
1087
|
-
throw isAbortError(err) ? err : abortError("QMD daemon search aborted");
|
|
1088
|
-
}
|
|
1089
|
-
if (isDaemonTimeoutError(err)) {
|
|
1090
|
-
log.debug(`QMD daemon search timed out after ${durationMs}ms, falling back to subprocess`);
|
|
1091
|
-
return null;
|
|
1092
|
-
}
|
|
1093
|
-
this.handleDaemonTransientError("search", err, durationMs);
|
|
1094
|
-
return null;
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
async bm25SearchViaDaemon(query, collection, maxResults, signal) {
|
|
1098
|
-
if (!this.daemonSession || !this.daemonAvailable) return null;
|
|
1099
|
-
const startedAtMs = Date.now();
|
|
1100
|
-
const v2 = this.isQmdV2();
|
|
1101
|
-
try {
|
|
1102
|
-
let result;
|
|
1103
|
-
if (v2) {
|
|
1104
|
-
result = await this.daemonSession.callTool(
|
|
1105
|
-
"query",
|
|
1106
|
-
{
|
|
1107
|
-
searches: [{ type: "lex", query }],
|
|
1108
|
-
collections: [collection],
|
|
1109
|
-
limit: maxResults
|
|
1110
|
-
},
|
|
1111
|
-
QMD_DAEMON_TIMEOUT_MS,
|
|
1112
|
-
signal
|
|
1113
|
-
);
|
|
1114
|
-
} else {
|
|
1115
|
-
result = await this.daemonSession.callTool(
|
|
1116
|
-
"search",
|
|
1117
|
-
{ query, limit: maxResults, collection },
|
|
1118
|
-
QMD_DAEMON_TIMEOUT_MS,
|
|
1119
|
-
signal
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1123
|
-
const results = parseMcpSearchResult(result);
|
|
1124
|
-
log.debug(`QMD daemon bm25: ${results.length} results in ${durationMs}ms (v2=${v2})`);
|
|
1125
|
-
this.recordDaemonSuccess();
|
|
1126
|
-
return results;
|
|
1127
|
-
} catch (err) {
|
|
1128
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1129
|
-
if (isCallerCancellation(err, signal)) {
|
|
1130
|
-
log.debug(`QMD daemon bm25 aborted/cancelled after ${durationMs}ms`);
|
|
1131
|
-
throw isAbortError(err) ? err : abortError("QMD daemon bm25 aborted");
|
|
1132
|
-
}
|
|
1133
|
-
if (isDaemonTimeoutError(err)) {
|
|
1134
|
-
log.debug(`QMD daemon bm25 timed out after ${durationMs}ms, falling back to subprocess`);
|
|
1135
|
-
return null;
|
|
1136
|
-
}
|
|
1137
|
-
this.handleDaemonTransientError("bm25", err, durationMs);
|
|
1138
|
-
return null;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
async vsearchViaDaemon(query, collection, maxResults, signal) {
|
|
1142
|
-
if (!this.daemonSession || !this.daemonAvailable) return null;
|
|
1143
|
-
const startedAtMs = Date.now();
|
|
1144
|
-
const v2 = this.isQmdV2();
|
|
1145
|
-
try {
|
|
1146
|
-
let result;
|
|
1147
|
-
if (v2) {
|
|
1148
|
-
result = await this.daemonSession.callTool(
|
|
1149
|
-
"query",
|
|
1150
|
-
{
|
|
1151
|
-
searches: [{ type: "vec", query }],
|
|
1152
|
-
collections: [collection],
|
|
1153
|
-
limit: maxResults
|
|
1154
|
-
},
|
|
1155
|
-
QMD_DAEMON_TIMEOUT_MS,
|
|
1156
|
-
signal
|
|
1157
|
-
);
|
|
1158
|
-
} else {
|
|
1159
|
-
result = await this.daemonSession.callTool(
|
|
1160
|
-
"vsearch",
|
|
1161
|
-
{ query, limit: maxResults, collection },
|
|
1162
|
-
QMD_DAEMON_TIMEOUT_MS,
|
|
1163
|
-
signal
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1166
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1167
|
-
const results = parseMcpSearchResult(result);
|
|
1168
|
-
log.debug(`QMD daemon vsearch: ${results.length} results in ${durationMs}ms (v2=${v2})`);
|
|
1169
|
-
this.recordDaemonSuccess();
|
|
1170
|
-
return results;
|
|
1171
|
-
} catch (err) {
|
|
1172
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1173
|
-
if (isCallerCancellation(err, signal)) {
|
|
1174
|
-
log.debug(`QMD daemon vsearch aborted/cancelled after ${durationMs}ms`);
|
|
1175
|
-
throw isAbortError(err) ? err : abortError("QMD daemon vsearch aborted");
|
|
1176
|
-
}
|
|
1177
|
-
if (isDaemonTimeoutError(err)) {
|
|
1178
|
-
log.debug(`QMD daemon vsearch timed out after ${durationMs}ms, falling back to subprocess`);
|
|
1179
|
-
return null;
|
|
1180
|
-
}
|
|
1181
|
-
this.handleDaemonTransientError("vsearch", err, durationMs);
|
|
1182
|
-
return null;
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
async searchViaSubprocess(query, collection, maxResults, options, signal) {
|
|
1186
|
-
if (this.available === false) return [];
|
|
1187
|
-
const startedAtMs = Date.now();
|
|
1188
|
-
try {
|
|
1189
|
-
const args = ["query", query, "-c", collection, "--json", "-n", String(maxResults)];
|
|
1190
|
-
if (options?.intent) {
|
|
1191
|
-
args.push("--intent", options.intent);
|
|
1192
|
-
}
|
|
1193
|
-
if (options?.explain === true) {
|
|
1194
|
-
args.push("--explain");
|
|
1195
|
-
}
|
|
1196
|
-
const { stdout } = await runQmd(
|
|
1197
|
-
args,
|
|
1198
|
-
QMD_TIMEOUT_MS,
|
|
1199
|
-
this.qmdPath,
|
|
1200
|
-
signal
|
|
1201
|
-
);
|
|
1202
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1203
|
-
if (this.slowLog?.enabled && durationMs >= this.slowLog.thresholdMs) {
|
|
1204
|
-
log.warn(
|
|
1205
|
-
`SLOW QMD query: durationMs=${durationMs} collection=${collection} maxResults=${maxResults} queryChars=${query.length}`
|
|
1206
|
-
);
|
|
1207
|
-
}
|
|
1208
|
-
return parseQmdSearchStdout(stdout, "subprocess");
|
|
1209
|
-
} catch (err) {
|
|
1210
|
-
if (isCallerCancellation(err, signal)) {
|
|
1211
|
-
throw isAbortError(err) ? err : abortError("QMD subprocess search aborted");
|
|
1212
|
-
}
|
|
1213
|
-
log.debug(`QMD search failed: ${err}`);
|
|
1214
|
-
return [];
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
async bm25SearchViaSubprocess(query, collection, maxResults, signal) {
|
|
1218
|
-
if (this.available === false) return [];
|
|
1219
|
-
const startedAtMs = Date.now();
|
|
1220
|
-
try {
|
|
1221
|
-
const { stdout } = await runQmd(
|
|
1222
|
-
["search", query, "-c", collection, "--json", "-n", String(maxResults)],
|
|
1223
|
-
QMD_TIMEOUT_MS,
|
|
1224
|
-
this.qmdPath,
|
|
1225
|
-
signal
|
|
1226
|
-
);
|
|
1227
|
-
log.debug(`QMD bm25: ${Date.now() - startedAtMs}ms`);
|
|
1228
|
-
return parseQmdSearchStdout(stdout);
|
|
1229
|
-
} catch (err) {
|
|
1230
|
-
if (isCallerCancellation(err, signal)) {
|
|
1231
|
-
throw isAbortError(err) ? err : abortError("QMD subprocess bm25 aborted");
|
|
1232
|
-
}
|
|
1233
|
-
log.debug(`QMD bm25 search failed: ${err}`);
|
|
1234
|
-
return [];
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
async vsearchViaSubprocess(query, collection, maxResults, signal) {
|
|
1238
|
-
if (this.available === false) return [];
|
|
1239
|
-
const startedAtMs = Date.now();
|
|
1240
|
-
try {
|
|
1241
|
-
const { stdout } = await runQmd(
|
|
1242
|
-
["vsearch", query, "-c", collection, "--json", "-n", String(maxResults)],
|
|
1243
|
-
QMD_TIMEOUT_MS,
|
|
1244
|
-
this.qmdPath,
|
|
1245
|
-
signal
|
|
1246
|
-
);
|
|
1247
|
-
log.debug(`QMD vsearch: ${Date.now() - startedAtMs}ms`);
|
|
1248
|
-
return parseQmdSearchStdout(stdout);
|
|
1249
|
-
} catch (err) {
|
|
1250
|
-
if (isCallerCancellation(err, signal)) {
|
|
1251
|
-
throw isAbortError(err) ? err : abortError("QMD subprocess vsearch aborted");
|
|
1252
|
-
}
|
|
1253
|
-
log.debug(`QMD vsearch failed: ${err}`);
|
|
1254
|
-
return [];
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
async searchGlobalViaSubprocess(query, maxResults, signal) {
|
|
1258
|
-
if (this.available === false) return [];
|
|
1259
|
-
const startedAtMs = Date.now();
|
|
1260
|
-
try {
|
|
1261
|
-
const { stdout } = await runQmd(
|
|
1262
|
-
["query", query, "--json", "-n", String(maxResults)],
|
|
1263
|
-
QMD_TIMEOUT_MS,
|
|
1264
|
-
this.qmdPath,
|
|
1265
|
-
signal
|
|
1266
|
-
);
|
|
1267
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1268
|
-
if (this.slowLog?.enabled && durationMs >= this.slowLog.thresholdMs) {
|
|
1269
|
-
log.warn(
|
|
1270
|
-
`SLOW QMD global query: durationMs=${durationMs} maxResults=${maxResults} queryChars=${query.length}`
|
|
1271
|
-
);
|
|
1272
|
-
}
|
|
1273
|
-
return parseQmdSearchStdout(stdout);
|
|
1274
|
-
} catch (err) {
|
|
1275
|
-
if (isCallerCancellation(err, signal)) {
|
|
1276
|
-
throw isAbortError(err) ? err : abortError("QMD subprocess global search aborted");
|
|
1277
|
-
}
|
|
1278
|
-
log.debug(`QMD global search failed: ${err}`);
|
|
1279
|
-
return [];
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
async update(execution) {
|
|
1283
|
-
await this.runUpdateForCollection(
|
|
1284
|
-
this.collection,
|
|
1285
|
-
{ perCollectionThrottle: false },
|
|
1286
|
-
execution?.signal
|
|
1287
|
-
);
|
|
1288
|
-
}
|
|
1289
|
-
async updateCollection(collection, execution) {
|
|
1290
|
-
await this.runUpdateForCollection(
|
|
1291
|
-
collection,
|
|
1292
|
-
{ perCollectionThrottle: true },
|
|
1293
|
-
execution?.signal
|
|
1294
|
-
);
|
|
1295
|
-
}
|
|
1296
|
-
async updateCollectionStrict(collection, execution) {
|
|
1297
|
-
await this.runUpdateForCollection(
|
|
1298
|
-
collection,
|
|
1299
|
-
{ perCollectionThrottle: true, strict: true },
|
|
1300
|
-
execution?.signal
|
|
1301
|
-
);
|
|
1302
|
-
}
|
|
1303
|
-
updatesAllCollections() {
|
|
1304
|
-
return true;
|
|
1305
|
-
}
|
|
1306
|
-
async runUpdateForCollection(collection, options, signal) {
|
|
1307
|
-
if (this.available === false) {
|
|
1308
|
-
if (options.strict) {
|
|
1309
|
-
throw new Error("QMD unavailable");
|
|
1310
|
-
}
|
|
1311
|
-
return;
|
|
1312
|
-
}
|
|
1313
|
-
const name = collection.trim();
|
|
1314
|
-
if (!name) {
|
|
1315
|
-
if (options.strict) {
|
|
1316
|
-
throw new Error("QMD collection name is required");
|
|
1317
|
-
}
|
|
1318
|
-
return;
|
|
1319
|
-
}
|
|
1320
|
-
const globalState = getGlobalQmdState();
|
|
1321
|
-
const now = Date.now();
|
|
1322
|
-
if (!options.strict && options.perCollectionThrottle) {
|
|
1323
|
-
if (globalState.lastGlobalUpdateFailAtMs && now - globalState.lastGlobalUpdateFailAtMs < QMD_UPDATE_BACKOFF_MS) {
|
|
1324
|
-
log.debug("QMD update: suppressed by global failure backoff");
|
|
1325
|
-
return;
|
|
1326
|
-
}
|
|
1327
|
-
const lastCollectionRun = globalState.lastUpdateByCollectionMs[name];
|
|
1328
|
-
if (Number.isFinite(lastCollectionRun) && now - lastCollectionRun < this.updateMinIntervalMs) {
|
|
1329
|
-
log.debug(`QMD update: suppressed by per-collection min-interval gate (${name})`);
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1332
|
-
const lastCollectionFail = globalState.lastUpdateFailByCollectionMs[name];
|
|
1333
|
-
if (Number.isFinite(lastCollectionFail) && now - lastCollectionFail < QMD_UPDATE_BACKOFF_MS) {
|
|
1334
|
-
log.debug(`QMD update: suppressed by per-collection failure backoff (${name})`);
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
} else if (!options.strict) {
|
|
1338
|
-
if (this.lastUpdateRunAtMs && now - this.lastUpdateRunAtMs < this.updateMinIntervalMs) {
|
|
1339
|
-
log.debug("QMD update: suppressed due to min-interval gate");
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
if (this._lastUpdateFailAtMs && now - this._lastUpdateFailAtMs < QMD_UPDATE_BACKOFF_MS) {
|
|
1343
|
-
log.debug("QMD update: suppressed due to recent failures (backoff)");
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
|
-
if (globalState.lastGlobalUpdateRunAtMs && now - globalState.lastGlobalUpdateRunAtMs < this.updateMinIntervalMs) {
|
|
1347
|
-
log.debug("QMD update: suppressed by global min-interval gate");
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
if (globalState.lastGlobalUpdateFailAtMs && now - globalState.lastGlobalUpdateFailAtMs < QMD_UPDATE_BACKOFF_MS) {
|
|
1351
|
-
log.debug("QMD update: suppressed by global failure backoff");
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
try {
|
|
1356
|
-
if (!globalState.warnedGlobalUpdateBehavior) {
|
|
1357
|
-
globalState.warnedGlobalUpdateBehavior = true;
|
|
1358
|
-
log.warn(
|
|
1359
|
-
"QMD update runs globally across collections in current CLI versions; Engram now rate-limits update calls to reduce gateway load."
|
|
1360
|
-
);
|
|
1361
|
-
}
|
|
1362
|
-
const startedAtMs = Date.now();
|
|
1363
|
-
await this.runQmdCommand(["update", "-c", name], this.updateTimeoutMs, signal);
|
|
1364
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1365
|
-
if (this.slowLog?.enabled && durationMs >= this.slowLog.thresholdMs) {
|
|
1366
|
-
log.warn(`SLOW QMD update: durationMs=${durationMs}`);
|
|
1367
|
-
}
|
|
1368
|
-
const at = Date.now();
|
|
1369
|
-
if (options.perCollectionThrottle) {
|
|
1370
|
-
globalState.lastUpdateByCollectionMs[name] = at;
|
|
1371
|
-
globalState.lastGlobalUpdateRunAtMs = at;
|
|
1372
|
-
} else {
|
|
1373
|
-
this.lastUpdateRunAtMs = at;
|
|
1374
|
-
globalState.lastGlobalUpdateRunAtMs = at;
|
|
1375
|
-
}
|
|
1376
|
-
log.debug(`QMD update completed for collection=${name}`);
|
|
1377
|
-
} catch (err) {
|
|
1378
|
-
const at = Date.now();
|
|
1379
|
-
if (options.perCollectionThrottle) {
|
|
1380
|
-
globalState.lastUpdateFailByCollectionMs[name] = at;
|
|
1381
|
-
globalState.lastGlobalUpdateFailAtMs = at;
|
|
1382
|
-
} else {
|
|
1383
|
-
this._lastUpdateFailAtMs = at;
|
|
1384
|
-
globalState.lastGlobalUpdateFailAtMs = at;
|
|
1385
|
-
}
|
|
1386
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1387
|
-
log.warn(`QMD update failed for collection ${name}: ${msg}`);
|
|
1388
|
-
if (options.strict) {
|
|
1389
|
-
throw err;
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
async embed() {
|
|
1394
|
-
if (this.available === false) return;
|
|
1395
|
-
const globalState = getGlobalQmdState();
|
|
1396
|
-
if (this.lastEmbedFailAtMs && Date.now() - this.lastEmbedFailAtMs < QMD_EMBED_BACKOFF_MS) {
|
|
1397
|
-
log.debug("QMD embed: suppressed due to recent failures (backoff)");
|
|
1398
|
-
return;
|
|
1399
|
-
}
|
|
1400
|
-
if (globalState.lastGlobalEmbedRunAtMs && Date.now() - globalState.lastGlobalEmbedRunAtMs < this.updateMinIntervalMs) {
|
|
1401
|
-
log.debug("QMD embed: suppressed by global min-interval gate");
|
|
1402
|
-
return;
|
|
1403
|
-
}
|
|
1404
|
-
if (globalState.lastGlobalEmbedFailAtMs && Date.now() - globalState.lastGlobalEmbedFailAtMs < QMD_EMBED_BACKOFF_MS) {
|
|
1405
|
-
log.debug("QMD embed: suppressed by global failure backoff");
|
|
1406
|
-
return;
|
|
1407
|
-
}
|
|
1408
|
-
try {
|
|
1409
|
-
const startedAtMs = Date.now();
|
|
1410
|
-
await this.runQmdCommand(["embed", "-c", this.collection], 3e5);
|
|
1411
|
-
const durationMs = Date.now() - startedAtMs;
|
|
1412
|
-
if (this.slowLog?.enabled && durationMs >= this.slowLog.thresholdMs) {
|
|
1413
|
-
log.warn(`SLOW QMD embed: durationMs=${durationMs}`);
|
|
1414
|
-
}
|
|
1415
|
-
globalState.lastGlobalEmbedRunAtMs = Date.now();
|
|
1416
|
-
log.debug("QMD embed completed");
|
|
1417
|
-
} catch (err) {
|
|
1418
|
-
if (isVectorDimensionMismatchError(err)) {
|
|
1419
|
-
try {
|
|
1420
|
-
log.warn("QMD embed hit a vector dimension mismatch; retrying with force re-embed");
|
|
1421
|
-
await this.runQmdCommand(["embed", "-f", "-c", this.collection], 3e5);
|
|
1422
|
-
globalState.lastGlobalEmbedRunAtMs = Date.now();
|
|
1423
|
-
this.lastEmbedFailAtMs = null;
|
|
1424
|
-
globalState.lastGlobalEmbedFailAtMs = null;
|
|
1425
|
-
log.warn("QMD embed recovered by forcing a full vector rebuild");
|
|
1426
|
-
return;
|
|
1427
|
-
} catch (retryErr) {
|
|
1428
|
-
const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
1429
|
-
log.warn(`QMD force re-embed failed after dimension mismatch: ${retryMsg}`);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
const now = Date.now();
|
|
1433
|
-
this.lastEmbedFailAtMs = now;
|
|
1434
|
-
globalState.lastGlobalEmbedFailAtMs = now;
|
|
1435
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1436
|
-
log.warn(`QMD embed failed: ${msg}`);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
async embedCollection(collection) {
|
|
1440
|
-
if (this.available === false) return;
|
|
1441
|
-
const name = collection.trim();
|
|
1442
|
-
if (!name) return;
|
|
1443
|
-
const globalState = getGlobalQmdState();
|
|
1444
|
-
const now = Date.now();
|
|
1445
|
-
if (globalState.lastGlobalEmbedFailAtMs && now - globalState.lastGlobalEmbedFailAtMs < QMD_EMBED_BACKOFF_MS) {
|
|
1446
|
-
log.debug(`QMD embed: suppressed by global failure backoff (${name})`);
|
|
1447
|
-
return;
|
|
1448
|
-
}
|
|
1449
|
-
const lastCollectionRun = globalState.lastEmbedByCollectionMs[name];
|
|
1450
|
-
if (Number.isFinite(lastCollectionRun) && now - lastCollectionRun < this.updateMinIntervalMs) {
|
|
1451
|
-
log.debug(`QMD embed: suppressed by per-collection min-interval gate (${name})`);
|
|
1452
|
-
return;
|
|
1453
|
-
}
|
|
1454
|
-
const lastCollectionFail = globalState.lastEmbedFailByCollectionMs[name];
|
|
1455
|
-
if (Number.isFinite(lastCollectionFail) && now - lastCollectionFail < QMD_EMBED_BACKOFF_MS) {
|
|
1456
|
-
log.debug(`QMD embed: suppressed by per-collection failure backoff (${name})`);
|
|
1457
|
-
return;
|
|
1458
|
-
}
|
|
1459
|
-
try {
|
|
1460
|
-
await this.runQmdCommand(["embed", "-c", name], 3e5);
|
|
1461
|
-
const at = Date.now();
|
|
1462
|
-
globalState.lastEmbedByCollectionMs[name] = at;
|
|
1463
|
-
globalState.lastGlobalEmbedRunAtMs = at;
|
|
1464
|
-
} catch (err) {
|
|
1465
|
-
if (isVectorDimensionMismatchError(err)) {
|
|
1466
|
-
try {
|
|
1467
|
-
log.warn(`QMD embed for collection ${name} hit a vector dimension mismatch; retrying with force re-embed`);
|
|
1468
|
-
await this.runQmdCommand(["embed", "-f", "-c", name], 3e5);
|
|
1469
|
-
const recoveredAt = Date.now();
|
|
1470
|
-
globalState.lastEmbedByCollectionMs[name] = recoveredAt;
|
|
1471
|
-
globalState.lastGlobalEmbedRunAtMs = recoveredAt;
|
|
1472
|
-
delete globalState.lastEmbedFailByCollectionMs[name];
|
|
1473
|
-
globalState.lastGlobalEmbedFailAtMs = null;
|
|
1474
|
-
log.warn(`QMD embed for collection ${name} recovered by forcing a full vector rebuild`);
|
|
1475
|
-
return;
|
|
1476
|
-
} catch (retryErr) {
|
|
1477
|
-
const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
1478
|
-
log.warn(`QMD force re-embed failed for collection ${name}: ${retryMsg}`);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
const at = Date.now();
|
|
1482
|
-
globalState.lastEmbedFailByCollectionMs[name] = at;
|
|
1483
|
-
globalState.lastGlobalEmbedFailAtMs = at;
|
|
1484
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1485
|
-
log.warn(`QMD embed failed for collection ${name}: ${msg}`);
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
async ensureCollection(memoryDir) {
|
|
1489
|
-
if (this.available === false && !this.daemonAvailable) return "unknown";
|
|
1490
|
-
if (this.available === false) return "skipped";
|
|
1491
|
-
try {
|
|
1492
|
-
const { stdout } = await runQmd(
|
|
1493
|
-
["collection", "list"],
|
|
1494
|
-
QMD_TIMEOUT_MS,
|
|
1495
|
-
this.qmdPath
|
|
1496
|
-
);
|
|
1497
|
-
const collectionRegex = new RegExp(
|
|
1498
|
-
`^${this.collection}\\s+\\(qmd://`,
|
|
1499
|
-
"m"
|
|
1500
|
-
);
|
|
1501
|
-
if (collectionRegex.test(stdout)) {
|
|
1502
|
-
return "present";
|
|
1503
|
-
}
|
|
1504
|
-
} catch (err) {
|
|
1505
|
-
log.debug(
|
|
1506
|
-
`QMD collection check unavailable for "${this.collection}" (will not disable features): ${err instanceof Error ? err.message : String(err)}`
|
|
1507
|
-
);
|
|
1508
|
-
return "unknown";
|
|
1509
|
-
}
|
|
1510
|
-
log.info(
|
|
1511
|
-
`QMD collection "${this.collection}" not found. Add it to ~/.config/qmd/index.yml pointing at ${memoryDir}`
|
|
1512
|
-
);
|
|
1513
|
-
return "missing";
|
|
1514
|
-
}
|
|
1515
|
-
};
|
|
1516
|
-
|
|
1517
|
-
export {
|
|
1518
|
-
parseQmdExplain,
|
|
1519
|
-
QmdClient
|
|
1520
|
-
};
|
|
1521
|
-
//# sourceMappingURL=chunk-P77UEOU2.js.map
|