@remnic/core 1.1.12 → 1.1.13
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 +257 -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/index.js
CHANGED
|
@@ -13,8 +13,49 @@ import {
|
|
|
13
13
|
writePeerProfile
|
|
14
14
|
} from "./chunk-4DWOBS2A.js";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
EnrichmentProviderRegistry,
|
|
17
|
+
WebSearchProvider,
|
|
18
|
+
appendAuditEntry,
|
|
19
|
+
defaultEnrichmentPipelineConfig,
|
|
20
|
+
readAuditLog,
|
|
21
|
+
runEnrichmentPipeline
|
|
22
|
+
} from "./chunk-N2D6GXBM.js";
|
|
23
|
+
import {
|
|
24
|
+
MARKETPLACE_MANIFEST_FILENAME,
|
|
25
|
+
MARKETPLACE_SCHEMA_VERSION,
|
|
26
|
+
checkMarketplaceManifest,
|
|
27
|
+
doctorConnector,
|
|
28
|
+
generateMarketplaceManifest,
|
|
29
|
+
getConnectorToken,
|
|
30
|
+
installConnector,
|
|
31
|
+
installFromMarketplace,
|
|
32
|
+
listConnectors,
|
|
33
|
+
loadRegistry,
|
|
34
|
+
removeConnector,
|
|
35
|
+
saveRegistry,
|
|
36
|
+
validateMarketplaceManifest,
|
|
37
|
+
writeMarketplaceManifest
|
|
38
|
+
} from "./chunk-326G7DJK.js";
|
|
39
|
+
import "./chunk-V5OCT34X.js";
|
|
40
|
+
import {
|
|
41
|
+
executeResolution,
|
|
42
|
+
isValidResolutionVerb
|
|
43
|
+
} from "./chunk-47VWKCAF.js";
|
|
44
|
+
import {
|
|
45
|
+
ACTIVE_STATUSES,
|
|
46
|
+
judgeContradictionPairs,
|
|
47
|
+
runContradictionScan
|
|
48
|
+
} from "./chunk-DK5LDEQM.js";
|
|
49
|
+
import {
|
|
50
|
+
computePairId,
|
|
51
|
+
isCoolingDown,
|
|
52
|
+
listPairs,
|
|
53
|
+
readPair,
|
|
54
|
+
resolvePair,
|
|
55
|
+
writePair,
|
|
56
|
+
writePairs
|
|
57
|
+
} from "./chunk-APO3DCMU.js";
|
|
58
|
+
import {
|
|
18
59
|
generateToken,
|
|
19
60
|
getAllValidTokens,
|
|
20
61
|
getAllValidTokensCached,
|
|
@@ -23,7 +64,7 @@ import {
|
|
|
23
64
|
resolveConnectorFromToken,
|
|
24
65
|
revokeToken,
|
|
25
66
|
saveTokenStore
|
|
26
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-MSWG7JI6.js";
|
|
27
68
|
import {
|
|
28
69
|
runGraphRecall
|
|
29
70
|
} from "./chunk-DGVM5SFL.js";
|
|
@@ -53,22 +94,48 @@ import {
|
|
|
53
94
|
runBulkImportCliCommand,
|
|
54
95
|
runBulkImportPipeline,
|
|
55
96
|
validateImportTurn
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-
|
|
97
|
+
} from "./chunk-CHEL3SKB.js";
|
|
98
|
+
import "./chunk-ICRIXAP2.js";
|
|
99
|
+
import "./chunk-EHRTFRWW.js";
|
|
100
|
+
import "./chunk-S7KDBTWT.js";
|
|
101
|
+
import "./chunk-TZOLIGIG.js";
|
|
102
|
+
import "./chunk-TK4UEOSK.js";
|
|
103
|
+
import "./chunk-TFO23QT4.js";
|
|
104
|
+
import "./chunk-7OZ53EXP.js";
|
|
105
|
+
import "./chunk-GIF42EW3.js";
|
|
106
|
+
import "./chunk-66DHUKLO.js";
|
|
107
|
+
import "./chunk-Z734BLO3.js";
|
|
108
|
+
import "./chunk-DOM4GKSW.js";
|
|
109
|
+
import "./chunk-W4L6CZKA.js";
|
|
110
|
+
import "./chunk-3JXBXXM2.js";
|
|
111
|
+
import "./chunk-6H2TESSP.js";
|
|
112
|
+
import "./chunk-TKWGAOLV.js";
|
|
113
|
+
import "./chunk-FIT6DMX6.js";
|
|
114
|
+
import "./chunk-TPMQ3G6Z.js";
|
|
115
|
+
import "./chunk-JLFA7DQG.js";
|
|
116
|
+
import "./chunk-KLAO5DGL.js";
|
|
117
|
+
import "./chunk-PZIAX57I.js";
|
|
118
|
+
import "./chunk-65PG43EQ.js";
|
|
119
|
+
import "./chunk-KJTKLXTH.js";
|
|
120
|
+
import "./chunk-PK7H5L6Y.js";
|
|
121
|
+
import "./chunk-LT3NLYSI.js";
|
|
122
|
+
import "./chunk-TMM4S4IJ.js";
|
|
123
|
+
import "./chunk-XVZ7B3HG.js";
|
|
58
124
|
import {
|
|
59
125
|
clearAuthTokenSecretCache,
|
|
60
126
|
isAgentAccessSecretRef,
|
|
61
127
|
resolveAgentAccessAuthToken
|
|
62
128
|
} from "./chunk-MXC3AP5I.js";
|
|
63
|
-
import "./chunk-
|
|
129
|
+
import "./chunk-4CRG46BG.js";
|
|
64
130
|
import {
|
|
65
131
|
parseXrayBudgetFlag,
|
|
66
132
|
parseXrayCliOptions
|
|
67
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-MT4HVDUZ.js";
|
|
68
134
|
import {
|
|
69
135
|
parseStrictCliDate
|
|
70
136
|
} from "./chunk-AJA46VX5.js";
|
|
71
|
-
import "./chunk-
|
|
137
|
+
import "./chunk-UXHQAFNA.js";
|
|
138
|
+
import "./chunk-MT25YHYH.js";
|
|
72
139
|
import "./chunk-HL4DB7TO.js";
|
|
73
140
|
import "./chunk-ZPKBYX2F.js";
|
|
74
141
|
import "./chunk-3SLRNYNG.js";
|
|
@@ -77,7 +144,7 @@ import "./chunk-Y4Z4I6WK.js";
|
|
|
77
144
|
import "./chunk-5HRY2WRF.js";
|
|
78
145
|
import {
|
|
79
146
|
reportBufferSurpriseDistribution
|
|
80
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-YBPYIAA5.js";
|
|
81
148
|
import {
|
|
82
149
|
DEFAULT_SURPRISE_K,
|
|
83
150
|
computeSurprise
|
|
@@ -85,35 +152,53 @@ import {
|
|
|
85
152
|
import {
|
|
86
153
|
getMemoryForActiveMemory,
|
|
87
154
|
recallForActiveMemory
|
|
88
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-2WWLHTZY.js";
|
|
89
156
|
import "./chunk-6MKAMLQL.js";
|
|
90
157
|
import {
|
|
91
158
|
DEFAULT_TAXONOMY,
|
|
92
159
|
Orchestrator,
|
|
93
|
-
applyLcmSchema,
|
|
94
160
|
branchNamespaceName,
|
|
95
161
|
buildProcedureRecallSection,
|
|
96
162
|
decideSemanticDedup,
|
|
97
163
|
defaultWorkspaceDir,
|
|
98
164
|
describeCodingScope,
|
|
99
|
-
ensureLcmStateDir,
|
|
100
165
|
generateResolverDocument,
|
|
101
166
|
getTaxonomyDir,
|
|
102
167
|
getTaxonomyFilePath,
|
|
103
168
|
loadTaxonomy,
|
|
104
|
-
migrateFromEngram,
|
|
105
|
-
openLcmDatabase,
|
|
106
169
|
projectNamespaceName,
|
|
107
170
|
resolveCodingNamespaceOverlay,
|
|
108
|
-
rollbackFromEngramMigration,
|
|
109
171
|
sanitizeSessionKeyForFilename,
|
|
110
172
|
saveTaxonomy,
|
|
111
173
|
validateSlug,
|
|
112
174
|
validateTaxonomy
|
|
113
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-GA454ALV.js";
|
|
114
176
|
import "./chunk-CK5NTM2S.js";
|
|
115
|
-
import
|
|
177
|
+
import {
|
|
178
|
+
migrateFromEngram,
|
|
179
|
+
rollbackFromEngramMigration
|
|
180
|
+
} from "./chunk-KOSORCJG.js";
|
|
181
|
+
import "./chunk-BFBF3XEF.js";
|
|
182
|
+
import "./chunk-HHLLAQGZ.js";
|
|
183
|
+
import "./chunk-UWK5OXUJ.js";
|
|
184
|
+
import "./chunk-VNO6ZJ35.js";
|
|
185
|
+
import "./chunk-34DQE4KF.js";
|
|
186
|
+
import "./chunk-56K5QLHX.js";
|
|
187
|
+
import "./chunk-7N4KAIGN.js";
|
|
188
|
+
import "./chunk-TPDBFYEG.js";
|
|
189
|
+
import "./chunk-ZTFCYYEZ.js";
|
|
190
|
+
import {
|
|
191
|
+
applyLcmSchema,
|
|
192
|
+
ensureLcmStateDir,
|
|
193
|
+
openLcmDatabase
|
|
194
|
+
} from "./chunk-7XYTQGCC.js";
|
|
195
|
+
import "./chunk-TECVW3JP.js";
|
|
196
|
+
import "./chunk-RYED3SPJ.js";
|
|
197
|
+
import "./chunk-KUJVMMZQ.js";
|
|
198
|
+
import "./chunk-U4SCL7B7.js";
|
|
116
199
|
import "./chunk-FSFEQI74.js";
|
|
200
|
+
import "./chunk-OIGNEXKZ.js";
|
|
201
|
+
import "./chunk-MDYG7VI7.js";
|
|
117
202
|
import "./chunk-Z5AAYHUC.js";
|
|
118
203
|
import {
|
|
119
204
|
computeTierValueScore,
|
|
@@ -121,14 +206,12 @@ import {
|
|
|
121
206
|
} from "./chunk-S75M5ZRK.js";
|
|
122
207
|
import "./chunk-TPB3I2AC.js";
|
|
123
208
|
import "./chunk-UHGBNIOS.js";
|
|
124
|
-
import "./chunk-
|
|
125
|
-
import "./chunk-
|
|
209
|
+
import "./chunk-H3ME6L6D.js";
|
|
210
|
+
import "./chunk-XJNBEDFE.js";
|
|
126
211
|
import {
|
|
127
212
|
buildTargetedFactRecallSection,
|
|
128
213
|
shouldRecallTargetedFactEvidence
|
|
129
214
|
} from "./chunk-VWT3F4IV.js";
|
|
130
|
-
import "./chunk-OIGNEXKZ.js";
|
|
131
|
-
import "./chunk-MDYG7VI7.js";
|
|
132
215
|
import "./chunk-JR4ZC3G4.js";
|
|
133
216
|
import "./chunk-5IZL4DCV.js";
|
|
134
217
|
import "./chunk-5NPGSAVB.js";
|
|
@@ -162,7 +245,7 @@ import {
|
|
|
162
245
|
builtInLiveConnectorDefinitions,
|
|
163
246
|
hasEnabledLiveConnector,
|
|
164
247
|
runLiveConnectorsOnce
|
|
165
|
-
} from "./chunk-
|
|
248
|
+
} from "./chunk-U3WSW6PZ.js";
|
|
166
249
|
import "./chunk-H63EDPFJ.js";
|
|
167
250
|
import {
|
|
168
251
|
hasBroadGraphIntent,
|
|
@@ -172,7 +255,7 @@ import {
|
|
|
172
255
|
planRecallMode
|
|
173
256
|
} from "./chunk-PD6O7AXF.js";
|
|
174
257
|
import "./chunk-YAZNBMNF.js";
|
|
175
|
-
import "./chunk-
|
|
258
|
+
import "./chunk-LCR46JY5.js";
|
|
176
259
|
import {
|
|
177
260
|
clearVerdictCache,
|
|
178
261
|
createVerdictCache,
|
|
@@ -185,19 +268,21 @@ import {
|
|
|
185
268
|
} from "./chunk-C4SQJZAF.js";
|
|
186
269
|
import {
|
|
187
270
|
ExtractionEngine
|
|
188
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-W3LR522O.js";
|
|
189
272
|
import "./chunk-4RA3C3EV.js";
|
|
190
273
|
import "./chunk-WW3QQF4H.js";
|
|
191
274
|
import "./chunk-54V4BZWP.js";
|
|
192
|
-
import
|
|
193
|
-
|
|
275
|
+
import {
|
|
276
|
+
ModelRegistry
|
|
277
|
+
} from "./chunk-QR3C7BKQ.js";
|
|
278
|
+
import "./chunk-EDTHC6UD.js";
|
|
194
279
|
import {
|
|
195
280
|
buildFocusedListRecallSection,
|
|
196
281
|
shouldRecallFocusedListEvidence
|
|
197
282
|
} from "./chunk-DB5A3NHS.js";
|
|
198
283
|
import {
|
|
199
284
|
buildEntityRecallSection
|
|
200
|
-
} from "./chunk-
|
|
285
|
+
} from "./chunk-7IASACLB.js";
|
|
201
286
|
import {
|
|
202
287
|
buildEventOrderRecallSection,
|
|
203
288
|
shouldRecallEventOrderEvidence
|
|
@@ -229,21 +314,25 @@ import {
|
|
|
229
314
|
FILTER_LABELS,
|
|
230
315
|
isDirectAnswerEligible
|
|
231
316
|
} from "./chunk-Y4FHOFJ2.js";
|
|
232
|
-
import "./chunk-
|
|
317
|
+
import "./chunk-NMZY542O.js";
|
|
233
318
|
import {
|
|
234
319
|
CODEX_THREAD_KEY_PREFIX
|
|
235
320
|
} from "./chunk-3PG3H5TD.js";
|
|
236
321
|
import "./chunk-2NMMFZ5T.js";
|
|
322
|
+
import {
|
|
323
|
+
buildExtensionsBlockForConsolidation
|
|
324
|
+
} from "./chunk-I5V2VDIW.js";
|
|
325
|
+
import {
|
|
326
|
+
runCodexMaterialize,
|
|
327
|
+
runPostConsolidationMaterialize
|
|
328
|
+
} from "./chunk-ME6ESPZU.js";
|
|
237
329
|
import {
|
|
238
330
|
MATERIALIZE_VERSION,
|
|
239
331
|
SENTINEL_FILE,
|
|
240
|
-
buildExtensionsBlockForConsolidation,
|
|
241
332
|
describeMemoriesDir,
|
|
242
333
|
ensureSentinel,
|
|
243
|
-
materializeForNamespace
|
|
244
|
-
|
|
245
|
-
runPostConsolidationMaterialize
|
|
246
|
-
} from "./chunk-CPKTBRS2.js";
|
|
334
|
+
materializeForNamespace
|
|
335
|
+
} from "./chunk-RHY3HH7P.js";
|
|
247
336
|
import {
|
|
248
337
|
REMNIC_EXTENSIONS_TOTAL_TOKEN_LIMIT,
|
|
249
338
|
discoverMemoryExtensions,
|
|
@@ -251,20 +340,37 @@ import {
|
|
|
251
340
|
renderExtensionsFooter,
|
|
252
341
|
resolveExtensionsRoot
|
|
253
342
|
} from "./chunk-EJI5XIBB.js";
|
|
254
|
-
import "./chunk-
|
|
343
|
+
import "./chunk-2PRQG7PV.js";
|
|
344
|
+
import "./chunk-LUDTDZLK.js";
|
|
255
345
|
import "./chunk-PYXS46O7.js";
|
|
256
346
|
import "./chunk-3QKK7QOS.js";
|
|
257
|
-
import "./chunk-
|
|
258
|
-
import "./chunk-
|
|
259
|
-
import "./chunk-
|
|
347
|
+
import "./chunk-P4NEIHUT.js";
|
|
348
|
+
import "./chunk-W4RVMTHR.js";
|
|
349
|
+
import "./chunk-MC26UJIM.js";
|
|
260
350
|
import "./chunk-CULXMQJH.js";
|
|
261
|
-
import "./chunk-
|
|
351
|
+
import "./chunk-5375UYTQ.js";
|
|
352
|
+
import "./chunk-FF4KLI5W.js";
|
|
262
353
|
import "./chunk-EABGC2TL.js";
|
|
354
|
+
import "./chunk-PU63GXWS.js";
|
|
355
|
+
import "./chunk-6RVI47ZR.js";
|
|
263
356
|
import {
|
|
264
|
-
LanceDbBackend,
|
|
265
|
-
MeilisearchBackend,
|
|
266
357
|
OramaBackend
|
|
267
|
-
} from "./chunk-
|
|
358
|
+
} from "./chunk-XVVIG67A.js";
|
|
359
|
+
import "./chunk-PIRJPV5T.js";
|
|
360
|
+
import "./chunk-RXDLTSWT.js";
|
|
361
|
+
import {
|
|
362
|
+
LanceDbBackend
|
|
363
|
+
} from "./chunk-3VAL7ZL2.js";
|
|
364
|
+
import {
|
|
365
|
+
MeilisearchBackend
|
|
366
|
+
} from "./chunk-TMQLARTH.js";
|
|
367
|
+
import "./chunk-MJFNCJXV.js";
|
|
368
|
+
import "./chunk-NJ3MJQZX.js";
|
|
369
|
+
import "./chunk-QQUAB63I.js";
|
|
370
|
+
import "./chunk-PR5FBTFU.js";
|
|
371
|
+
import "./chunk-FJ43PRLT.js";
|
|
372
|
+
import "./chunk-LLQ2LLWF.js";
|
|
373
|
+
import "./chunk-7DTASS5T.js";
|
|
268
374
|
import "./chunk-YRMVARQP.js";
|
|
269
375
|
import {
|
|
270
376
|
LEGACY_PLUGIN_ID,
|
|
@@ -273,7 +379,7 @@ import {
|
|
|
273
379
|
} from "./chunk-U66YHYC7.js";
|
|
274
380
|
import {
|
|
275
381
|
QmdClient
|
|
276
|
-
} from "./chunk-
|
|
382
|
+
} from "./chunk-BJ3KMYTB.js";
|
|
277
383
|
import {
|
|
278
384
|
DEFAULT_POLL_INTERVAL_MS,
|
|
279
385
|
GOOGLE_DRIVE_CONNECTOR_ID,
|
|
@@ -288,26 +394,21 @@ import {
|
|
|
288
394
|
defaultGoogleDriveClientFactory,
|
|
289
395
|
validateGoogleDriveConfig,
|
|
290
396
|
validateNotionConfig
|
|
291
|
-
} from "./chunk-
|
|
397
|
+
} from "./chunk-HXXBL2KD.js";
|
|
292
398
|
import {
|
|
293
399
|
CONNECTOR_ID_PATTERN,
|
|
294
400
|
isValidConnectorId,
|
|
295
401
|
listConnectorStates,
|
|
296
402
|
readConnectorState,
|
|
297
403
|
writeConnectorState
|
|
298
|
-
} from "./chunk-
|
|
404
|
+
} from "./chunk-LPMVBPA3.js";
|
|
299
405
|
import "./chunk-JXS5PDQ7.js";
|
|
300
406
|
import "./chunk-HMDCOMYU.js";
|
|
301
407
|
import "./chunk-7SEAZFFB.js";
|
|
302
|
-
import "./chunk-
|
|
408
|
+
import "./chunk-D46YSIYX.js";
|
|
303
409
|
import "./chunk-AJU4PJGY.js";
|
|
304
410
|
import "./chunk-C6QPK5GG.js";
|
|
305
|
-
import "./chunk-
|
|
306
|
-
import {
|
|
307
|
-
coerceInstallExtension,
|
|
308
|
-
parseConfig
|
|
309
|
-
} from "./chunk-HY3L4WKC.js";
|
|
310
|
-
import "./chunk-Z5LAYHGJ.js";
|
|
411
|
+
import "./chunk-2KI4QFHU.js";
|
|
311
412
|
import {
|
|
312
413
|
CONNECTORS_OUTPUT_FORMATS,
|
|
313
414
|
parseConnectorsFormat,
|
|
@@ -318,36 +419,53 @@ import {
|
|
|
318
419
|
renderConnectorsRunResult,
|
|
319
420
|
runConnectorPollOnce
|
|
320
421
|
} from "./chunk-OZHRDTDX.js";
|
|
422
|
+
import "./chunk-3UXOZBHV.js";
|
|
321
423
|
import "./chunk-KVE7R4CG.js";
|
|
322
424
|
import "./chunk-4WMCPJWX.js";
|
|
323
425
|
import {
|
|
324
426
|
SmartBuffer
|
|
325
|
-
} from "./chunk-
|
|
427
|
+
} from "./chunk-5RGLBDQF.js";
|
|
326
428
|
import {
|
|
327
429
|
FallbackLlmClient
|
|
328
|
-
} from "./chunk-
|
|
329
|
-
import "./chunk-
|
|
430
|
+
} from "./chunk-DINWEURR.js";
|
|
431
|
+
import "./chunk-FLTNHQK6.js";
|
|
330
432
|
import "./chunk-7SI52C65.js";
|
|
331
433
|
import "./chunk-L2EXJQJP.js";
|
|
332
434
|
import "./chunk-UZB5KHKX.js";
|
|
333
435
|
import {
|
|
334
436
|
setCodexCliFallbackRunnerForProcess
|
|
335
437
|
} from "./chunk-RK6F44Y6.js";
|
|
438
|
+
import {
|
|
439
|
+
isOpenaiApiKeyDisabled,
|
|
440
|
+
parseConfig,
|
|
441
|
+
resolveEnvVars
|
|
442
|
+
} from "./chunk-2QR3XXIC.js";
|
|
443
|
+
import {
|
|
444
|
+
coerceInstallExtension
|
|
445
|
+
} from "./chunk-PHK3HARR.js";
|
|
446
|
+
import "./chunk-Z5LAYHGJ.js";
|
|
336
447
|
import "./chunk-6HZ6AO2P.js";
|
|
337
448
|
import "./chunk-JWPLJLDU.js";
|
|
338
449
|
import {
|
|
339
450
|
BootstrapEngine
|
|
340
451
|
} from "./chunk-N53K2EXC.js";
|
|
341
452
|
import "./chunk-XYIK4LF6.js";
|
|
342
|
-
import "./chunk-
|
|
453
|
+
import "./chunk-NZL6GGQE.js";
|
|
343
454
|
import "./chunk-PVGDJXVK.js";
|
|
344
455
|
import "./chunk-NGAVDO7E.js";
|
|
345
456
|
import {
|
|
346
457
|
EngramAccessHttpServer
|
|
347
|
-
} from "./chunk-
|
|
458
|
+
} from "./chunk-CQZRLNMV.js";
|
|
459
|
+
import "./chunk-SEDEKFYQ.js";
|
|
460
|
+
import "./chunk-6FC5EGNV.js";
|
|
461
|
+
import "./chunk-3Y4P7RXM.js";
|
|
462
|
+
import "./chunk-6LVVDPJ4.js";
|
|
463
|
+
import "./chunk-7MNMYOFP.js";
|
|
464
|
+
import "./chunk-FKFMOY3N.js";
|
|
465
|
+
import "./chunk-FAJ7FZYM.js";
|
|
348
466
|
import {
|
|
349
467
|
EngramMcpServer
|
|
350
|
-
} from "./chunk-
|
|
468
|
+
} from "./chunk-WZYKANL3.js";
|
|
351
469
|
import {
|
|
352
470
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_CANONICAL_TOOL,
|
|
353
471
|
REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
|
|
@@ -368,10 +486,12 @@ import {
|
|
|
368
486
|
EngramAccessService,
|
|
369
487
|
computeProcedureStats,
|
|
370
488
|
formatProcedureStatsText
|
|
371
|
-
} from "./chunk-
|
|
489
|
+
} from "./chunk-M23FSH32.js";
|
|
490
|
+
import "./chunk-ZKSK55RC.js";
|
|
491
|
+
import "./chunk-WELDCG6C.js";
|
|
372
492
|
import {
|
|
373
493
|
importCapsule
|
|
374
|
-
} from "./chunk-
|
|
494
|
+
} from "./chunk-GGKRUQOO.js";
|
|
375
495
|
import "./chunk-BT7NVCML.js";
|
|
376
496
|
import "./chunk-H7XKCNR6.js";
|
|
377
497
|
import {
|
|
@@ -381,18 +501,18 @@ import {
|
|
|
381
501
|
renderXrayJson,
|
|
382
502
|
renderXrayMarkdown,
|
|
383
503
|
renderXrayText
|
|
384
|
-
} from "./chunk-
|
|
504
|
+
} from "./chunk-FBYESMQ2.js";
|
|
385
505
|
import "./chunk-SOBJ6NEY.js";
|
|
386
506
|
import {
|
|
387
507
|
normalizeOriginUrl,
|
|
388
508
|
resolveGitContext,
|
|
389
509
|
stableHash
|
|
390
|
-
} from "./chunk-
|
|
510
|
+
} from "./chunk-FDU6HUUL.js";
|
|
391
511
|
import {
|
|
392
512
|
isTrustZoneName
|
|
393
513
|
} from "./chunk-QDZ2RLEC.js";
|
|
394
|
-
import "./chunk-
|
|
395
|
-
import "./chunk-
|
|
514
|
+
import "./chunk-MGKYQQYF.js";
|
|
515
|
+
import "./chunk-GL6I6MEQ.js";
|
|
396
516
|
import {
|
|
397
517
|
isLcmMessagePartKind,
|
|
398
518
|
normalizeExplicitParts,
|
|
@@ -402,33 +522,30 @@ import {
|
|
|
402
522
|
parseOpenClawMessageParts,
|
|
403
523
|
parsePiMessageParts,
|
|
404
524
|
partsFromRenderedText
|
|
405
|
-
} from "./chunk-
|
|
525
|
+
} from "./chunk-3APJ5EVB.js";
|
|
406
526
|
import "./chunk-5UM2VJ6D.js";
|
|
407
|
-
import "./chunk-
|
|
527
|
+
import "./chunk-EFJ3MQ4V.js";
|
|
408
528
|
import {
|
|
409
529
|
memoryWorthOutcomeEligibleCategories,
|
|
410
530
|
recordMemoryOutcome
|
|
411
531
|
} from "./chunk-EIR5VLIH.js";
|
|
412
532
|
import "./chunk-PCUKNJAZ.js";
|
|
413
|
-
import "./chunk-
|
|
533
|
+
import "./chunk-RRF5UOBJ.js";
|
|
414
534
|
import "./chunk-NBNN5GOB.js";
|
|
415
|
-
import
|
|
416
|
-
launchProcessSync
|
|
417
|
-
} from "./chunk-OR64ZGRZ.js";
|
|
535
|
+
import "./chunk-NNVTUXEB.js";
|
|
418
536
|
import {
|
|
419
537
|
buildProcedureMarkdownBody,
|
|
420
538
|
parseProcedureStepsFromBody
|
|
421
539
|
} from "./chunk-QDW3E4RD.js";
|
|
422
|
-
import "./chunk-
|
|
423
|
-
import "./chunk-2LGMW3DJ.js";
|
|
540
|
+
import "./chunk-25MQ7IHJ.js";
|
|
424
541
|
import {
|
|
425
542
|
CrossNamespaceBudget,
|
|
426
543
|
DEFAULT_CROSS_NAMESPACE_BUDGET
|
|
427
544
|
} from "./chunk-GDFS42HT.js";
|
|
545
|
+
import "./chunk-U3PN77QT.js";
|
|
428
546
|
import "./chunk-RK2Y4XOM.js";
|
|
429
547
|
import "./chunk-2LSZVONP.js";
|
|
430
548
|
import "./chunk-WIICJPET.js";
|
|
431
|
-
import "./chunk-G2WADRQ3.js";
|
|
432
549
|
import {
|
|
433
550
|
BRIEFING_FORMAT_ALLOWED,
|
|
434
551
|
FileCalendarSource,
|
|
@@ -441,14 +558,19 @@ import {
|
|
|
441
558
|
renderBriefingMarkdown,
|
|
442
559
|
resolveBriefingSaveDir,
|
|
443
560
|
validateBriefingFormat
|
|
444
|
-
} from "./chunk-
|
|
561
|
+
} from "./chunk-VW676BEI.js";
|
|
445
562
|
import {
|
|
446
563
|
StorageManager,
|
|
564
|
+
parseEntityFile,
|
|
565
|
+
serializeEntityFile
|
|
566
|
+
} from "./chunk-7AAT6G4Q.js";
|
|
567
|
+
import "./chunk-5UZXUTVO.js";
|
|
568
|
+
import "./chunk-YNJHCGDT.js";
|
|
569
|
+
import {
|
|
447
570
|
parseFlexibleIsoTimestamp,
|
|
448
571
|
parseIsoOffsetTimestamp,
|
|
449
572
|
parseIsoUtcTimestamp
|
|
450
|
-
} from "./chunk-
|
|
451
|
-
import "./chunk-YNJHCGDT.js";
|
|
573
|
+
} from "./chunk-P7FMDTKL.js";
|
|
452
574
|
import {
|
|
453
575
|
CITATION_UNKNOWN,
|
|
454
576
|
DEFAULT_CITATION_FORMAT,
|
|
@@ -464,15 +586,18 @@ import {
|
|
|
464
586
|
DEFAULT_RECALL_DISCLOSURE,
|
|
465
587
|
RECALL_DISCLOSURE_LEVELS,
|
|
466
588
|
isRecallDisclosure
|
|
467
|
-
} from "./chunk-
|
|
468
|
-
import
|
|
469
|
-
|
|
589
|
+
} from "./chunk-Q7P4WJDP.js";
|
|
590
|
+
import {
|
|
591
|
+
normalizeProjectionPreview,
|
|
592
|
+
normalizeProjectionTags
|
|
593
|
+
} from "./chunk-SCU65EZI.js";
|
|
594
|
+
import "./chunk-3KW65B36.js";
|
|
595
|
+
import "./chunk-3HPAPHUK.js";
|
|
470
596
|
import "./chunk-PFV5C235.js";
|
|
471
597
|
import "./chunk-RULE4VG5.js";
|
|
472
598
|
import "./chunk-DM2T26WE.js";
|
|
473
599
|
import "./chunk-QSVPYQPG.js";
|
|
474
600
|
import "./chunk-FVQJYWH7.js";
|
|
475
|
-
import "./chunk-4DJQYKMN.js";
|
|
476
601
|
import "./chunk-G7D6GZ5J.js";
|
|
477
602
|
import {
|
|
478
603
|
createVersion,
|
|
@@ -483,17 +608,18 @@ import {
|
|
|
483
608
|
} from "./chunk-FAAFWE4G.js";
|
|
484
609
|
import {
|
|
485
610
|
expandTildePath
|
|
486
|
-
} from "./chunk-
|
|
487
|
-
import
|
|
488
|
-
|
|
489
|
-
readEnvVar,
|
|
490
|
-
resolveHomeDir
|
|
491
|
-
} from "./chunk-MARWOCVP.js";
|
|
492
|
-
import "./chunk-74EMIVE4.js";
|
|
611
|
+
} from "./chunk-QRNI5JBH.js";
|
|
612
|
+
import "./chunk-ZY2MNJR6.js";
|
|
613
|
+
import "./chunk-MY6TPVXW.js";
|
|
493
614
|
import "./chunk-DT5TVLJE.js";
|
|
494
615
|
import {
|
|
495
616
|
resolvePrincipal
|
|
496
|
-
} from "./chunk-
|
|
617
|
+
} from "./chunk-UWVJF25J.js";
|
|
618
|
+
import "./chunk-4DJQYKMN.js";
|
|
619
|
+
import {
|
|
620
|
+
readEnvVar,
|
|
621
|
+
resolveHomeDir
|
|
622
|
+
} from "./chunk-XIG5PDM7.js";
|
|
497
623
|
import "./chunk-TBBDFYXW.js";
|
|
498
624
|
import {
|
|
499
625
|
initLogger,
|
|
@@ -518,16 +644,18 @@ import {
|
|
|
518
644
|
recallRequestSchema,
|
|
519
645
|
suggestionSubmitRequestSchema,
|
|
520
646
|
validateRequest
|
|
521
|
-
} from "./chunk-
|
|
522
|
-
import "./chunk-
|
|
523
|
-
import "./chunk-
|
|
647
|
+
} from "./chunk-A2XUIMJ3.js";
|
|
648
|
+
import "./chunk-2F2W355T.js";
|
|
649
|
+
import "./chunk-KNKUID7G.js";
|
|
650
|
+
import {
|
|
651
|
+
CAPSULE_ID_PATTERN
|
|
652
|
+
} from "./chunk-WEHSQBFR.js";
|
|
653
|
+
import "./chunk-J4EB7DNW.js";
|
|
654
|
+
import "./chunk-I6K5FBRQ.js";
|
|
524
655
|
import {
|
|
525
656
|
assertIsDirectoryNotSymlink,
|
|
526
657
|
assertRealpathInsideRoot
|
|
527
|
-
} from "./chunk-
|
|
528
|
-
import {
|
|
529
|
-
CAPSULE_ID_PATTERN
|
|
530
|
-
} from "./chunk-OA3L7BFR.js";
|
|
658
|
+
} from "./chunk-AGZQD76C.js";
|
|
531
659
|
import "./chunk-BJMBJZ2Y.js";
|
|
532
660
|
import "./chunk-UKJAGEXH.js";
|
|
533
661
|
import "./chunk-FP2373TW.js";
|
|
@@ -2229,15 +2357,21 @@ function walkMdFiles(dir, callback) {
|
|
|
2229
2357
|
// src/review/index.ts
|
|
2230
2358
|
import fs6 from "fs";
|
|
2231
2359
|
import path10 from "path";
|
|
2360
|
+
var DEFAULT_CONFIDENCE_THRESHOLD = 0.7;
|
|
2232
2361
|
function listReviewItems(options) {
|
|
2233
2362
|
const startTime = Date.now();
|
|
2234
2363
|
const {
|
|
2235
2364
|
memoryDir,
|
|
2236
2365
|
reason: filterReason,
|
|
2237
2366
|
limit = 50,
|
|
2238
|
-
confidenceThreshold =
|
|
2367
|
+
confidenceThreshold = DEFAULT_CONFIDENCE_THRESHOLD
|
|
2239
2368
|
} = options;
|
|
2240
2369
|
const items = [];
|
|
2370
|
+
const addItem = (item) => {
|
|
2371
|
+
if (items.length >= limit) return;
|
|
2372
|
+
if (filterReason && item.reviewReason !== filterReason) return;
|
|
2373
|
+
items.push(item);
|
|
2374
|
+
};
|
|
2241
2375
|
const suggestionsDir = path10.join(memoryDir, "suggestions");
|
|
2242
2376
|
if (fs6.existsSync(suggestionsDir)) {
|
|
2243
2377
|
walkMd(suggestionsDir, (filePath, content) => {
|
|
@@ -2245,7 +2379,7 @@ function listReviewItems(options) {
|
|
|
2245
2379
|
const fm = parseFrontmatter4(content);
|
|
2246
2380
|
const body = extractBody4(content);
|
|
2247
2381
|
if (!fm?.id) return;
|
|
2248
|
-
|
|
2382
|
+
addItem({
|
|
2249
2383
|
id: fm.id,
|
|
2250
2384
|
content: body,
|
|
2251
2385
|
category: fm.category ?? "suggestion",
|
|
@@ -2265,7 +2399,7 @@ function listReviewItems(options) {
|
|
|
2265
2399
|
const fm = parseFrontmatter4(content);
|
|
2266
2400
|
const body = extractBody4(content);
|
|
2267
2401
|
if (!fm?.id) return;
|
|
2268
|
-
|
|
2402
|
+
addItem({
|
|
2269
2403
|
id: fm.id,
|
|
2270
2404
|
content: body,
|
|
2271
2405
|
category: fm.category ?? "review",
|
|
@@ -2291,8 +2425,9 @@ function listReviewItems(options) {
|
|
|
2291
2425
|
if (!fm?.id) return;
|
|
2292
2426
|
const confidence = parseConfidence(fm.confidence, 1);
|
|
2293
2427
|
if (confidence >= confidenceThreshold) return;
|
|
2428
|
+
if (parseBoolean(fm.reviewDismissed)) return;
|
|
2294
2429
|
if (items.some((i) => i.id === fm.id)) return;
|
|
2295
|
-
|
|
2430
|
+
addItem({
|
|
2296
2431
|
id: fm.id,
|
|
2297
2432
|
content: body,
|
|
2298
2433
|
category: fm.category ?? category.slice(0, -1),
|
|
@@ -2305,95 +2440,136 @@ function listReviewItems(options) {
|
|
|
2305
2440
|
});
|
|
2306
2441
|
});
|
|
2307
2442
|
}
|
|
2308
|
-
const filtered = filterReason ? items.filter((i) => i.reviewReason === filterReason) : items;
|
|
2309
2443
|
return {
|
|
2310
|
-
items
|
|
2311
|
-
total:
|
|
2444
|
+
items,
|
|
2445
|
+
total: items.length,
|
|
2312
2446
|
durationMs: Date.now() - startTime
|
|
2313
2447
|
};
|
|
2314
2448
|
}
|
|
2315
|
-
function performReview(memoryDir, itemId, action) {
|
|
2449
|
+
function performReview(memoryDir, itemId, action, options = {}) {
|
|
2316
2450
|
switch (action) {
|
|
2317
2451
|
case "approve":
|
|
2318
|
-
return approveItem(memoryDir, itemId);
|
|
2452
|
+
return approveItem(memoryDir, itemId, options);
|
|
2319
2453
|
case "dismiss":
|
|
2320
|
-
return dismissItem(memoryDir, itemId);
|
|
2454
|
+
return dismissItem(memoryDir, itemId, options);
|
|
2321
2455
|
case "flag":
|
|
2322
|
-
return flagItem(memoryDir, itemId);
|
|
2456
|
+
return flagItem(memoryDir, itemId, options);
|
|
2323
2457
|
}
|
|
2324
2458
|
}
|
|
2325
|
-
function approveItem(memoryDir, itemId) {
|
|
2326
|
-
const
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
const updatedContent = content.replace(/confidence: [\d.]+/, "confidence: 0.9").replace(/confidenceTier: \w+/, "confidenceTier: high");
|
|
2341
|
-
fs6.mkdirSync(path10.dirname(outputPath), { recursive: true });
|
|
2342
|
-
fs6.writeFileSync(outputPath, updatedContent);
|
|
2343
|
-
fs6.unlinkSync(found);
|
|
2459
|
+
function approveItem(memoryDir, itemId, options) {
|
|
2460
|
+
const found = findReviewFileById(memoryDir, itemId, options);
|
|
2461
|
+
if (!found) {
|
|
2462
|
+
return { itemId, action: "approve", message: "Item not found" };
|
|
2463
|
+
}
|
|
2464
|
+
const content = fs6.readFileSync(found.filePath, "utf8");
|
|
2465
|
+
const fm = parseFrontmatter4(content);
|
|
2466
|
+
if (!fm) return { itemId, action: "approve", message: "Could not parse frontmatter" };
|
|
2467
|
+
const updatedContent = updateFrontmatterFields(content, {
|
|
2468
|
+
confidence: "0.9",
|
|
2469
|
+
confidenceTier: "high",
|
|
2470
|
+
reviewDismissed: null
|
|
2471
|
+
});
|
|
2472
|
+
if (found.location === "category") {
|
|
2473
|
+
fs6.writeFileSync(found.filePath, updatedContent, "utf8");
|
|
2344
2474
|
return {
|
|
2345
2475
|
itemId,
|
|
2346
2476
|
action: "approve",
|
|
2347
|
-
updatedPath:
|
|
2348
|
-
message:
|
|
2477
|
+
updatedPath: found.filePath,
|
|
2478
|
+
message: "Approved low-confidence memory in place with confidence 0.9"
|
|
2349
2479
|
};
|
|
2350
2480
|
}
|
|
2351
|
-
|
|
2481
|
+
const category = fm.category ?? "fact";
|
|
2482
|
+
const targetDir = getCategoryDir(memoryDir, category);
|
|
2483
|
+
const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
2484
|
+
const outputPath = path10.join(targetDir, dateDir, path10.basename(found.filePath));
|
|
2485
|
+
fs6.mkdirSync(path10.dirname(outputPath), { recursive: true });
|
|
2486
|
+
const promotedPath = writeFileWithoutClobber(outputPath, updatedContent, itemId);
|
|
2487
|
+
fs6.unlinkSync(found.filePath);
|
|
2488
|
+
return {
|
|
2489
|
+
itemId,
|
|
2490
|
+
action: "approve",
|
|
2491
|
+
updatedPath: promotedPath,
|
|
2492
|
+
message: `Promoted to ${category} with confidence 0.9`
|
|
2493
|
+
};
|
|
2352
2494
|
}
|
|
2353
|
-
function dismissItem(memoryDir, itemId) {
|
|
2354
|
-
const
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2495
|
+
function dismissItem(memoryDir, itemId, options) {
|
|
2496
|
+
const found = findReviewFileById(memoryDir, itemId, options);
|
|
2497
|
+
if (!found) {
|
|
2498
|
+
return { itemId, action: "dismiss", message: "Item not found" };
|
|
2499
|
+
}
|
|
2500
|
+
if (found.location === "queue") {
|
|
2501
|
+
fs6.unlinkSync(found.filePath);
|
|
2502
|
+
return { itemId, action: "dismiss", message: "Dismissed and removed" };
|
|
2503
|
+
}
|
|
2504
|
+
const content = fs6.readFileSync(found.filePath, "utf8");
|
|
2505
|
+
fs6.writeFileSync(
|
|
2506
|
+
found.filePath,
|
|
2507
|
+
updateFrontmatterFields(content, {
|
|
2508
|
+
reviewDismissed: "true",
|
|
2509
|
+
reviewDismissedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2510
|
+
}),
|
|
2511
|
+
"utf8"
|
|
2512
|
+
);
|
|
2513
|
+
return {
|
|
2514
|
+
itemId,
|
|
2515
|
+
action: "dismiss",
|
|
2516
|
+
updatedPath: found.filePath,
|
|
2517
|
+
message: "Dismissed low-confidence memory in place"
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
function flagItem(memoryDir, itemId, options) {
|
|
2521
|
+
const found = findReviewFileById(memoryDir, itemId, options);
|
|
2522
|
+
if (!found) {
|
|
2523
|
+
return { itemId, action: "flag", message: "Item not found" };
|
|
2363
2524
|
}
|
|
2364
|
-
|
|
2525
|
+
const content = fs6.readFileSync(found.filePath, "utf8");
|
|
2526
|
+
const fixed = updateFrontmatterFields(content, {
|
|
2527
|
+
flagged: "true",
|
|
2528
|
+
flaggedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2529
|
+
});
|
|
2530
|
+
fs6.writeFileSync(found.filePath, fixed);
|
|
2531
|
+
return {
|
|
2532
|
+
itemId,
|
|
2533
|
+
action: "flag",
|
|
2534
|
+
updatedPath: found.filePath,
|
|
2535
|
+
message: "Flagged for further review"
|
|
2536
|
+
};
|
|
2365
2537
|
}
|
|
2366
|
-
function
|
|
2367
|
-
const
|
|
2368
|
-
for (const loc of locations) {
|
|
2538
|
+
function findReviewFileById(memoryDir, id, options = {}) {
|
|
2539
|
+
for (const loc of ["suggestions", "review"]) {
|
|
2369
2540
|
const dir = path10.join(memoryDir, loc);
|
|
2370
2541
|
if (!fs6.existsSync(dir)) continue;
|
|
2371
|
-
const found = findFileById(dir,
|
|
2372
|
-
if (found) {
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
`
|
|
2380
|
-
);
|
|
2381
|
-
fs6.writeFileSync(found, fixed);
|
|
2382
|
-
return { itemId, action: "flag", message: "Flagged for further review" };
|
|
2383
|
-
}
|
|
2542
|
+
const found = findFileById(dir, id);
|
|
2543
|
+
if (found) return { filePath: found, location: "queue" };
|
|
2544
|
+
}
|
|
2545
|
+
for (const category of ALL_CATEGORY_DIRS) {
|
|
2546
|
+
const dir = path10.join(memoryDir, category);
|
|
2547
|
+
if (!fs6.existsSync(dir)) continue;
|
|
2548
|
+
const found = findFileById(dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
|
|
2549
|
+
if (found) return { filePath: found, location: "category" };
|
|
2384
2550
|
}
|
|
2385
|
-
return
|
|
2551
|
+
return null;
|
|
2386
2552
|
}
|
|
2387
|
-
function findFileById(dir, id) {
|
|
2553
|
+
function findFileById(dir, id, include) {
|
|
2388
2554
|
const files = walkMdPaths(dir);
|
|
2389
2555
|
for (const filePath of files) {
|
|
2390
2556
|
const content = readFileSafe3(filePath);
|
|
2391
2557
|
if (!content) continue;
|
|
2392
2558
|
const fm = parseFrontmatter4(content);
|
|
2393
|
-
if (fm?.id === id) return filePath;
|
|
2559
|
+
if (fm?.id === id && (!include || include(fm))) return filePath;
|
|
2394
2560
|
}
|
|
2395
2561
|
return null;
|
|
2396
2562
|
}
|
|
2563
|
+
function isLowConfidenceReviewCandidate(fm, options) {
|
|
2564
|
+
const threshold = options.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD;
|
|
2565
|
+
return parseConfidence(fm.confidence, 1) < threshold && !parseBoolean(fm.reviewDismissed);
|
|
2566
|
+
}
|
|
2567
|
+
function parseBoolean(value) {
|
|
2568
|
+
if (typeof value === "boolean") return value;
|
|
2569
|
+
if (typeof value !== "string") return false;
|
|
2570
|
+
const normalized = value.trim().toLowerCase();
|
|
2571
|
+
return normalized === "true" || normalized === "1" || normalized === "yes";
|
|
2572
|
+
}
|
|
2397
2573
|
function parseConfidence(value, fallback) {
|
|
2398
2574
|
if (typeof value === "number") return Number.isFinite(value) ? value : fallback;
|
|
2399
2575
|
if (typeof value === "string") {
|
|
@@ -2402,6 +2578,36 @@ function parseConfidence(value, fallback) {
|
|
|
2402
2578
|
}
|
|
2403
2579
|
return fallback;
|
|
2404
2580
|
}
|
|
2581
|
+
function updateFrontmatterFields(content, fields) {
|
|
2582
|
+
const match = content.match(/^(---\n)([\s\S]*?)(\n---(?:\n|$))/);
|
|
2583
|
+
if (!match) return content;
|
|
2584
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2585
|
+
const lines = match[2].split("\n");
|
|
2586
|
+
const nextLines = [];
|
|
2587
|
+
for (const line of lines) {
|
|
2588
|
+
const colonIdx = line.indexOf(":");
|
|
2589
|
+
if (colonIdx === -1) {
|
|
2590
|
+
nextLines.push(line);
|
|
2591
|
+
continue;
|
|
2592
|
+
}
|
|
2593
|
+
const key = line.slice(0, colonIdx).trim();
|
|
2594
|
+
if (!Object.prototype.hasOwnProperty.call(fields, key)) {
|
|
2595
|
+
nextLines.push(line);
|
|
2596
|
+
continue;
|
|
2597
|
+
}
|
|
2598
|
+
seen.add(key);
|
|
2599
|
+
const value = fields[key];
|
|
2600
|
+
if (value !== null) {
|
|
2601
|
+
nextLines.push(`${key}: ${value}`);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
2605
|
+
if (value !== null && !seen.has(key)) {
|
|
2606
|
+
nextLines.push(`${key}: ${value}`);
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
return `${match[1]}${nextLines.join("\n")}${match[3]}${content.slice(match[0].length)}`;
|
|
2610
|
+
}
|
|
2405
2611
|
function readFileSafe3(filePath) {
|
|
2406
2612
|
try {
|
|
2407
2613
|
return fs6.readFileSync(filePath, "utf8");
|
|
@@ -2409,6 +2615,46 @@ function readFileSafe3(filePath) {
|
|
|
2409
2615
|
return null;
|
|
2410
2616
|
}
|
|
2411
2617
|
}
|
|
2618
|
+
function writeFileWithoutClobber(basePath, content, discriminator) {
|
|
2619
|
+
const parsed = path10.parse(basePath);
|
|
2620
|
+
const safeDiscriminator = sanitizeFilePart(discriminator);
|
|
2621
|
+
for (let attempt = 0; attempt < 1e3; attempt++) {
|
|
2622
|
+
const candidate = attempt === 0 ? basePath : path10.join(
|
|
2623
|
+
parsed.dir,
|
|
2624
|
+
`${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
|
|
2625
|
+
);
|
|
2626
|
+
try {
|
|
2627
|
+
fs6.writeFileSync(candidate, content, { encoding: "utf8", flag: "wx" });
|
|
2628
|
+
return candidate;
|
|
2629
|
+
} catch (error) {
|
|
2630
|
+
if (error.code === "EEXIST") continue;
|
|
2631
|
+
throw error;
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
throw new Error(`Could not find a free review promotion path for ${basePath}`);
|
|
2635
|
+
}
|
|
2636
|
+
function sanitizeFilePart(value) {
|
|
2637
|
+
const chars = [];
|
|
2638
|
+
let previousWasDash = false;
|
|
2639
|
+
for (const char of value) {
|
|
2640
|
+
const next = isSafeFilePartChar(char) ? char : "-";
|
|
2641
|
+
if (next === "-" && previousWasDash) continue;
|
|
2642
|
+
chars.push(next);
|
|
2643
|
+
previousWasDash = next === "-";
|
|
2644
|
+
if (chars.length >= 64) break;
|
|
2645
|
+
}
|
|
2646
|
+
let start = 0;
|
|
2647
|
+
let end = chars.length;
|
|
2648
|
+
while (start < end && chars[start] === "-") start++;
|
|
2649
|
+
while (end > start && chars[end - 1] === "-") end--;
|
|
2650
|
+
const sanitized = chars.slice(start, end).join("");
|
|
2651
|
+
return sanitized || "review-item";
|
|
2652
|
+
}
|
|
2653
|
+
function isSafeFilePartChar(value) {
|
|
2654
|
+
if (value.length !== 1) return false;
|
|
2655
|
+
const code = value.charCodeAt(0);
|
|
2656
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || value === "." || value === "_" || value === "-";
|
|
2657
|
+
}
|
|
2412
2658
|
function parseFrontmatter4(content) {
|
|
2413
2659
|
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
2414
2660
|
if (!match) return null;
|
|
@@ -2619,2232 +2865,101 @@ function hashContent3(content) {
|
|
|
2619
2865
|
return crypto5.createHash("sha256").update(content).digest("hex").slice(0, 16);
|
|
2620
2866
|
}
|
|
2621
2867
|
|
|
2622
|
-
// src/
|
|
2623
|
-
import fs9 from "fs";
|
|
2624
|
-
import path13 from "path";
|
|
2625
|
-
import os from "os";
|
|
2626
|
-
import { createRequire } from "module";
|
|
2627
|
-
import { fileURLToPath } from "url";
|
|
2628
|
-
|
|
2629
|
-
// src/connectors/codex-marketplace.ts
|
|
2868
|
+
// src/spaces/index.ts
|
|
2630
2869
|
import fs8 from "fs";
|
|
2631
2870
|
import path12 from "path";
|
|
2632
|
-
|
|
2633
|
-
var
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
return {
|
|
2638
|
-
version: MARKETPLACE_SCHEMA_VERSION,
|
|
2639
|
-
name: "remnic",
|
|
2640
|
-
description: "Remnic: Local-first AI memory with semantic search and consolidation",
|
|
2641
|
-
plugins: [
|
|
2642
|
-
{
|
|
2643
|
-
name: "remnic",
|
|
2644
|
-
version,
|
|
2645
|
-
description: "Persistent memory plugin for Codex CLI",
|
|
2646
|
-
repository: "joshuaswarren/remnic",
|
|
2647
|
-
installType: "github",
|
|
2648
|
-
entry: "packages/plugin-codex",
|
|
2649
|
-
configSchema: "openclaw.plugin.json"
|
|
2650
|
-
}
|
|
2651
|
-
]
|
|
2652
|
-
};
|
|
2653
|
-
}
|
|
2654
|
-
function validateMarketplaceManifest(manifest) {
|
|
2655
|
-
const validation = checkMarketplaceManifest(manifest);
|
|
2656
|
-
if (!validation.valid) {
|
|
2657
|
-
throw new Error(
|
|
2658
|
-
`Invalid marketplace manifest: ${validation.errors.join("; ")}`
|
|
2659
|
-
);
|
|
2660
|
-
}
|
|
2661
|
-
return manifest;
|
|
2871
|
+
import crypto6 from "crypto";
|
|
2872
|
+
var MANIFEST_VERSION = 1;
|
|
2873
|
+
function getSpacesDir(baseDir) {
|
|
2874
|
+
const homeDir = baseDir ?? resolveHomeDir();
|
|
2875
|
+
return path12.join(homeDir, ".config", "engram", "spaces");
|
|
2662
2876
|
}
|
|
2663
|
-
function
|
|
2664
|
-
|
|
2665
|
-
if (typeof manifest !== "object" || manifest === null) {
|
|
2666
|
-
return { valid: false, errors: ["manifest must be a non-null object"] };
|
|
2667
|
-
}
|
|
2668
|
-
const obj = manifest;
|
|
2669
|
-
if (obj.version !== MARKETPLACE_SCHEMA_VERSION) {
|
|
2670
|
-
errors.push(`version must be ${MARKETPLACE_SCHEMA_VERSION}, got ${JSON.stringify(obj.version)}`);
|
|
2671
|
-
}
|
|
2672
|
-
if (typeof obj.name !== "string" || obj.name.trim().length === 0) {
|
|
2673
|
-
errors.push("name must be a non-empty string");
|
|
2674
|
-
}
|
|
2675
|
-
if (typeof obj.description !== "string" || obj.description.trim().length === 0) {
|
|
2676
|
-
errors.push("description must be a non-empty string");
|
|
2677
|
-
}
|
|
2678
|
-
if (!Array.isArray(obj.plugins)) {
|
|
2679
|
-
errors.push("plugins must be an array");
|
|
2680
|
-
} else if (obj.plugins.length === 0) {
|
|
2681
|
-
errors.push("plugins must contain at least one entry");
|
|
2682
|
-
} else {
|
|
2683
|
-
for (let i = 0; i < obj.plugins.length; i++) {
|
|
2684
|
-
const plugin = obj.plugins[i];
|
|
2685
|
-
const prefix = `plugins[${i}]`;
|
|
2686
|
-
if (typeof plugin !== "object" || plugin === null) {
|
|
2687
|
-
errors.push(`${prefix} must be a non-null object`);
|
|
2688
|
-
continue;
|
|
2689
|
-
}
|
|
2690
|
-
if (typeof plugin.name !== "string" || plugin.name.trim().length === 0) {
|
|
2691
|
-
errors.push(`${prefix}.name must be a non-empty string`);
|
|
2692
|
-
}
|
|
2693
|
-
if (typeof plugin.version !== "string" || plugin.version.trim().length === 0) {
|
|
2694
|
-
errors.push(`${prefix}.version must be a non-empty string`);
|
|
2695
|
-
}
|
|
2696
|
-
if (typeof plugin.description !== "string" || plugin.description.trim().length === 0) {
|
|
2697
|
-
errors.push(`${prefix}.description must be a non-empty string`);
|
|
2698
|
-
}
|
|
2699
|
-
if (typeof plugin.repository !== "string" || plugin.repository.trim().length === 0) {
|
|
2700
|
-
errors.push(`${prefix}.repository must be a non-empty string`);
|
|
2701
|
-
}
|
|
2702
|
-
if (typeof plugin.installType !== "string" || !VALID_INSTALL_TYPES.has(plugin.installType)) {
|
|
2703
|
-
errors.push(
|
|
2704
|
-
`${prefix}.installType must be one of: ${[...VALID_INSTALL_TYPES].join(", ")}; got ${JSON.stringify(plugin.installType)}`
|
|
2705
|
-
);
|
|
2706
|
-
}
|
|
2707
|
-
if ("manifestUrl" in plugin && plugin.manifestUrl !== void 0) {
|
|
2708
|
-
if (typeof plugin.manifestUrl !== "string" || plugin.manifestUrl.trim().length === 0) {
|
|
2709
|
-
errors.push(`${prefix}.manifestUrl must be a non-empty string when provided`);
|
|
2710
|
-
}
|
|
2711
|
-
}
|
|
2712
|
-
if ("entry" in plugin && plugin.entry !== void 0) {
|
|
2713
|
-
if (typeof plugin.entry !== "string" || plugin.entry.trim().length === 0) {
|
|
2714
|
-
errors.push(`${prefix}.entry must be a non-empty string when provided`);
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
if ("configSchema" in plugin && plugin.configSchema !== void 0) {
|
|
2718
|
-
if (typeof plugin.configSchema !== "string" || plugin.configSchema.trim().length === 0) {
|
|
2719
|
-
errors.push(`${prefix}.configSchema must be a non-empty string when provided`);
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
return { valid: errors.length === 0, errors };
|
|
2877
|
+
function getManifestPath(baseDir) {
|
|
2878
|
+
return path12.join(getSpacesDir(baseDir), "manifest.json");
|
|
2725
2879
|
}
|
|
2726
|
-
|
|
2727
|
-
const
|
|
2728
|
-
if (!
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
const destPath = path12.join(outputDir, MARKETPLACE_MANIFEST_FILENAME);
|
|
2735
|
-
const tmpPath = `${destPath}.tmp.${process.pid}`;
|
|
2736
|
-
const content = JSON.stringify(manifest, null, 2) + "\n";
|
|
2737
|
-
fs8.writeFileSync(tmpPath, content);
|
|
2738
|
-
fs8.renameSync(tmpPath, destPath);
|
|
2739
|
-
}
|
|
2740
|
-
async function installFromMarketplace(source, sourceType, config, logger) {
|
|
2741
|
-
const _log = logger ?? {
|
|
2742
|
-
info: (msg) => log.info(`[marketplace] ${msg}`),
|
|
2743
|
-
warn: (msg) => log.warn(`[marketplace] ${msg}`),
|
|
2744
|
-
debug: (msg) => log.debug(`[marketplace] ${msg}`)
|
|
2745
|
-
};
|
|
2746
|
-
if (!config.codexMarketplaceEnabled) {
|
|
2747
|
-
return {
|
|
2748
|
-
ok: false,
|
|
2749
|
-
message: "Codex marketplace is disabled in config (codexMarketplaceEnabled: false)",
|
|
2750
|
-
source,
|
|
2751
|
-
sourceType,
|
|
2752
|
-
pluginsFound: [],
|
|
2753
|
-
errors: ["marketplace_disabled"]
|
|
2754
|
-
};
|
|
2755
|
-
}
|
|
2756
|
-
try {
|
|
2757
|
-
const manifest = await resolveManifest(source, sourceType, _log);
|
|
2758
|
-
const pluginNames = manifest.plugins.map((p) => p.name);
|
|
2759
|
-
_log.info(`marketplace install: found ${pluginNames.length} plugin(s) from ${sourceType}://${source}`);
|
|
2760
|
-
return {
|
|
2761
|
-
ok: true,
|
|
2762
|
-
message: `Successfully resolved ${pluginNames.length} plugin(s) from marketplace: ${pluginNames.join(", ")}`,
|
|
2763
|
-
source,
|
|
2764
|
-
sourceType,
|
|
2765
|
-
pluginsFound: pluginNames,
|
|
2766
|
-
errors: []
|
|
2767
|
-
};
|
|
2768
|
-
} catch (err) {
|
|
2769
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
2770
|
-
_log.warn(`marketplace install failed: ${errMsg}`);
|
|
2771
|
-
return {
|
|
2772
|
-
ok: false,
|
|
2773
|
-
message: `Failed to install from marketplace: ${errMsg}`,
|
|
2774
|
-
source,
|
|
2775
|
-
sourceType,
|
|
2776
|
-
pluginsFound: [],
|
|
2777
|
-
errors: [errMsg]
|
|
2880
|
+
function loadManifest(baseDir, memoryDirOverride) {
|
|
2881
|
+
const manifestPath2 = getManifestPath(baseDir);
|
|
2882
|
+
if (!fs8.existsSync(manifestPath2)) {
|
|
2883
|
+
const personalSpace = createPersonalSpace(baseDir, memoryDirOverride);
|
|
2884
|
+
const manifest = {
|
|
2885
|
+
activeSpaceId: personalSpace.id,
|
|
2886
|
+
spaces: [personalSpace],
|
|
2887
|
+
version: MANIFEST_VERSION
|
|
2778
2888
|
};
|
|
2889
|
+
saveManifest(manifest, baseDir);
|
|
2890
|
+
return manifest;
|
|
2779
2891
|
}
|
|
2892
|
+
const raw = JSON.parse(fs8.readFileSync(manifestPath2, "utf8"));
|
|
2893
|
+
return raw;
|
|
2780
2894
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
case "url":
|
|
2786
|
-
return resolveUrl(source, logger);
|
|
2787
|
-
case "github":
|
|
2788
|
-
return resolveGithub(source, logger);
|
|
2789
|
-
case "git":
|
|
2790
|
-
return resolveGit(source, logger);
|
|
2791
|
-
default: {
|
|
2792
|
-
const _ = sourceType;
|
|
2793
|
-
throw new Error(`Invalid source type: ${String(_)}`);
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2895
|
+
function saveManifest(manifest, baseDir) {
|
|
2896
|
+
const manifestPath2 = getManifestPath(baseDir);
|
|
2897
|
+
fs8.mkdirSync(path12.dirname(manifestPath2), { recursive: true });
|
|
2898
|
+
fs8.writeFileSync(manifestPath2, JSON.stringify(manifest, null, 2) + "\n");
|
|
2796
2899
|
}
|
|
2797
|
-
function
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
}
|
|
2813
|
-
return validateMarketplaceManifest(parsed);
|
|
2900
|
+
function createPersonalSpace(baseDir, memoryDirOverride) {
|
|
2901
|
+
const homeDir = baseDir ?? resolveHomeDir();
|
|
2902
|
+
const standalonePath = path12.join(homeDir, ".engram", "memory");
|
|
2903
|
+
const openclawPath = path12.join(homeDir, ".openclaw", "workspace", "memory", "local");
|
|
2904
|
+
const memoryDir = memoryDirOverride ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs8.existsSync(standalonePath) ? standalonePath : fs8.existsSync(openclawPath) ? openclawPath : standalonePath);
|
|
2905
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2906
|
+
return {
|
|
2907
|
+
id: "personal",
|
|
2908
|
+
name: "Personal",
|
|
2909
|
+
kind: "personal",
|
|
2910
|
+
description: "Default personal memory space",
|
|
2911
|
+
memoryDir,
|
|
2912
|
+
createdAt: now,
|
|
2913
|
+
updatedAt: now,
|
|
2914
|
+
owner: readEnvVar("USER")
|
|
2915
|
+
};
|
|
2814
2916
|
}
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
try {
|
|
2819
|
-
parsedUrl = new URL(url);
|
|
2820
|
-
} catch {
|
|
2821
|
-
throw new Error(`Invalid URL: ${url}`);
|
|
2822
|
-
}
|
|
2823
|
-
if (parsedUrl.protocol !== "https:" && parsedUrl.protocol !== "http:") {
|
|
2824
|
-
throw new Error(`Unsupported URL protocol: ${parsedUrl.protocol} (use https or http)`);
|
|
2825
|
-
}
|
|
2826
|
-
const response = await fetch(url);
|
|
2827
|
-
if (!response.ok) {
|
|
2828
|
-
throw new Error(`HTTP ${response.status} fetching ${url}`);
|
|
2829
|
-
}
|
|
2830
|
-
const body = await response.json();
|
|
2831
|
-
return validateMarketplaceManifest(body);
|
|
2917
|
+
function listSpaces(baseDir) {
|
|
2918
|
+
const manifest = loadManifest(baseDir);
|
|
2919
|
+
return manifest.spaces;
|
|
2832
2920
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
logger.debug?.(`fetching marketplace manifest from GitHub: ${rawUrl}`);
|
|
2839
|
-
return resolveUrl(rawUrl, logger);
|
|
2921
|
+
function getActiveSpace(baseDir) {
|
|
2922
|
+
const manifest = loadManifest(baseDir);
|
|
2923
|
+
const space = manifest.spaces.find((s) => s.id === manifest.activeSpaceId);
|
|
2924
|
+
if (!space) throw new Error(`Active space ${manifest.activeSpaceId} not found`);
|
|
2925
|
+
return space;
|
|
2840
2926
|
}
|
|
2841
|
-
|
|
2842
|
-
const
|
|
2843
|
-
|
|
2844
|
-
)
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2927
|
+
function createSpace(options) {
|
|
2928
|
+
const manifest = loadManifest(options.baseDir);
|
|
2929
|
+
const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
|
|
2930
|
+
if (manifest.spaces.some((s) => s.id === id)) {
|
|
2931
|
+
throw new Error(`Space "${id}" already exists`);
|
|
2932
|
+
}
|
|
2933
|
+
if (options.parentSpaceId && !manifest.spaces.some((s) => s.id === options.parentSpaceId)) {
|
|
2934
|
+
throw new Error(`Parent space "${options.parentSpaceId}" not found`);
|
|
2848
2935
|
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2936
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2937
|
+
const memoryDir = options.memoryDir ?? path12.join(
|
|
2938
|
+
getSpacesDir(options.baseDir),
|
|
2939
|
+
id,
|
|
2940
|
+
"memory"
|
|
2851
2941
|
);
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
// src/connectors/index.ts
|
|
2875
|
-
var BUILTIN_CONNECTORS = [
|
|
2876
|
-
{
|
|
2877
|
-
id: "claude-code",
|
|
2878
|
-
name: "Claude Code",
|
|
2879
|
-
version: "1.0.0",
|
|
2880
|
-
description: "Anthropic's Claude Code CLI \u2014 direct memory access via MCP",
|
|
2881
|
-
capabilities: {
|
|
2882
|
-
observe: true,
|
|
2883
|
-
recall: true,
|
|
2884
|
-
store: true,
|
|
2885
|
-
search: true,
|
|
2886
|
-
entities: true,
|
|
2887
|
-
realtimeSync: true,
|
|
2888
|
-
batch: false,
|
|
2889
|
-
maxBudgetChars: 32e3,
|
|
2890
|
-
connectionType: "mcp"
|
|
2891
|
-
},
|
|
2892
|
-
configSchema: {
|
|
2893
|
-
mcpServerUrl: "URL of the MCP Remnic server",
|
|
2894
|
-
namespace: "Optional namespace (default: 'default')"
|
|
2895
|
-
},
|
|
2896
|
-
homepage: "https://claude.ai/code",
|
|
2897
|
-
author: "Anthropic",
|
|
2898
|
-
tags: ["official", "ai", "claude"],
|
|
2899
|
-
requiresToken: true
|
|
2900
|
-
},
|
|
2901
|
-
{
|
|
2902
|
-
id: "codex-cli",
|
|
2903
|
-
name: "Codex CLI",
|
|
2904
|
-
version: "1.0.0",
|
|
2905
|
-
description: "OpenAI Codex CLI \u2014 memory via MCP tool",
|
|
2906
|
-
capabilities: {
|
|
2907
|
-
observe: true,
|
|
2908
|
-
recall: true,
|
|
2909
|
-
store: true,
|
|
2910
|
-
search: false,
|
|
2911
|
-
entities: false,
|
|
2912
|
-
realtimeSync: false,
|
|
2913
|
-
batch: true,
|
|
2914
|
-
maxBudgetChars: 8e3,
|
|
2915
|
-
connectionType: "mcp"
|
|
2916
|
-
},
|
|
2917
|
-
configSchema: {
|
|
2918
|
-
mcpServerUrl: "URL of the MCP Remnic server",
|
|
2919
|
-
namespace: "Optional namespace"
|
|
2920
|
-
},
|
|
2921
|
-
homepage: "https://openai.com/codex",
|
|
2922
|
-
author: "OpenAI",
|
|
2923
|
-
tags: ["official", "ai", "codex"],
|
|
2924
|
-
requiresToken: true
|
|
2925
|
-
},
|
|
2926
|
-
{
|
|
2927
|
-
id: "cursor",
|
|
2928
|
-
name: "Cursor IDE",
|
|
2929
|
-
version: "1.0.0",
|
|
2930
|
-
description: "Cursor IDE \u2014 memory via config file + tool calls",
|
|
2931
|
-
capabilities: {
|
|
2932
|
-
observe: false,
|
|
2933
|
-
recall: true,
|
|
2934
|
-
store: false,
|
|
2935
|
-
search: true,
|
|
2936
|
-
entities: false,
|
|
2937
|
-
realtimeSync: false,
|
|
2938
|
-
batch: false,
|
|
2939
|
-
maxBudgetChars: 32e3,
|
|
2940
|
-
connectionType: "embedded"
|
|
2941
|
-
},
|
|
2942
|
-
configSchema: {
|
|
2943
|
-
memoryDir: "Path to Remnic memory directory"
|
|
2944
|
-
},
|
|
2945
|
-
homepage: "https://cursor.com",
|
|
2946
|
-
author: "Cursor Inc.",
|
|
2947
|
-
tags: ["official", "ide"]
|
|
2948
|
-
},
|
|
2949
|
-
{
|
|
2950
|
-
id: "cline",
|
|
2951
|
-
name: "Cline",
|
|
2952
|
-
version: "1.0.0",
|
|
2953
|
-
description: "VS Code Cline extension \u2014 memory via MCP",
|
|
2954
|
-
capabilities: {
|
|
2955
|
-
observe: true,
|
|
2956
|
-
recall: true,
|
|
2957
|
-
store: true,
|
|
2958
|
-
search: false,
|
|
2959
|
-
entities: false,
|
|
2960
|
-
realtimeSync: false,
|
|
2961
|
-
batch: true,
|
|
2962
|
-
maxBudgetChars: 8e3,
|
|
2963
|
-
connectionType: "mcp"
|
|
2964
|
-
},
|
|
2965
|
-
configSchema: {
|
|
2966
|
-
mcpServerUrl: "URL of the MCP Remnic server",
|
|
2967
|
-
namespace: "Optional namespace"
|
|
2968
|
-
},
|
|
2969
|
-
homepage: "https://github.com/cline/cline",
|
|
2970
|
-
author: "Cline",
|
|
2971
|
-
tags: ["community", "vscode"]
|
|
2972
|
-
},
|
|
2973
|
-
{
|
|
2974
|
-
id: "github-copilot",
|
|
2975
|
-
name: "GitHub Copilot",
|
|
2976
|
-
version: "1.0.0",
|
|
2977
|
-
description: "GitHub Copilot \u2014 memory via MCP server",
|
|
2978
|
-
capabilities: {
|
|
2979
|
-
observe: false,
|
|
2980
|
-
recall: true,
|
|
2981
|
-
store: false,
|
|
2982
|
-
search: true,
|
|
2983
|
-
entities: false,
|
|
2984
|
-
realtimeSync: false,
|
|
2985
|
-
batch: false,
|
|
2986
|
-
maxBudgetChars: 16e3,
|
|
2987
|
-
connectionType: "mcp"
|
|
2988
|
-
},
|
|
2989
|
-
configSchema: {
|
|
2990
|
-
mcpServerUrl: "URL of the MCP Remnic server"
|
|
2991
|
-
},
|
|
2992
|
-
homepage: "https://github.com/features/copilot",
|
|
2993
|
-
author: "GitHub",
|
|
2994
|
-
tags: ["official", "ai", "github"]
|
|
2995
|
-
},
|
|
2996
|
-
{
|
|
2997
|
-
id: "roo-code",
|
|
2998
|
-
name: "Roo Code",
|
|
2999
|
-
version: "1.0.0",
|
|
3000
|
-
description: "Roo Code \u2014 memory via MCP",
|
|
3001
|
-
capabilities: {
|
|
3002
|
-
observe: true,
|
|
3003
|
-
recall: true,
|
|
3004
|
-
store: true,
|
|
3005
|
-
search: false,
|
|
3006
|
-
entities: false,
|
|
3007
|
-
realtimeSync: false,
|
|
3008
|
-
batch: true,
|
|
3009
|
-
maxBudgetChars: 16e3,
|
|
3010
|
-
connectionType: "mcp"
|
|
3011
|
-
},
|
|
3012
|
-
configSchema: {
|
|
3013
|
-
mcpServerUrl: "URL of the MCP Remnic server",
|
|
3014
|
-
namespace: "Optional namespace"
|
|
3015
|
-
},
|
|
3016
|
-
homepage: "https://roocode.com",
|
|
3017
|
-
author: "Roo Code",
|
|
3018
|
-
tags: ["community", "vscode"]
|
|
3019
|
-
},
|
|
3020
|
-
{
|
|
3021
|
-
id: "windsurf",
|
|
3022
|
-
name: "Windsurf",
|
|
3023
|
-
version: "1.0.0",
|
|
3024
|
-
description: "Windsurf IDE \u2014 memory via MCP",
|
|
3025
|
-
capabilities: {
|
|
3026
|
-
observe: true,
|
|
3027
|
-
recall: true,
|
|
3028
|
-
store: true,
|
|
3029
|
-
search: true,
|
|
3030
|
-
entities: false,
|
|
3031
|
-
realtimeSync: false,
|
|
3032
|
-
batch: false,
|
|
3033
|
-
maxBudgetChars: 32e3,
|
|
3034
|
-
connectionType: "mcp"
|
|
3035
|
-
},
|
|
3036
|
-
configSchema: {
|
|
3037
|
-
mcpServerUrl: "URL of the MCP Remnic server"
|
|
3038
|
-
},
|
|
3039
|
-
homepage: "https://windsurf.com",
|
|
3040
|
-
author: "Codeium",
|
|
3041
|
-
tags: ["official", "ide"]
|
|
3042
|
-
},
|
|
3043
|
-
{
|
|
3044
|
-
id: "amp",
|
|
3045
|
-
name: "Amp",
|
|
3046
|
-
version: "1.0.0",
|
|
3047
|
-
description: "Amp coding agent \u2014 memory via MCP",
|
|
3048
|
-
capabilities: {
|
|
3049
|
-
observe: true,
|
|
3050
|
-
recall: true,
|
|
3051
|
-
store: true,
|
|
3052
|
-
search: true,
|
|
3053
|
-
entities: false,
|
|
3054
|
-
realtimeSync: false,
|
|
3055
|
-
batch: false,
|
|
3056
|
-
maxBudgetChars: 32e3,
|
|
3057
|
-
connectionType: "mcp"
|
|
3058
|
-
},
|
|
3059
|
-
configSchema: {
|
|
3060
|
-
mcpServerUrl: "URL of the MCP Remnic server"
|
|
3061
|
-
},
|
|
3062
|
-
homepage: "https://ampcode.com",
|
|
3063
|
-
author: "Sourcegraph",
|
|
3064
|
-
tags: ["official", "ai"]
|
|
3065
|
-
},
|
|
3066
|
-
{
|
|
3067
|
-
id: "pi",
|
|
3068
|
-
name: "Pi Coding Agent",
|
|
3069
|
-
version: "1.0.0",
|
|
3070
|
-
description: "Pi Coding Agent \u2014 native extension for recall, observe, MCP tools, and compaction coordination",
|
|
3071
|
-
capabilities: {
|
|
3072
|
-
observe: true,
|
|
3073
|
-
recall: true,
|
|
3074
|
-
store: true,
|
|
3075
|
-
search: true,
|
|
3076
|
-
entities: true,
|
|
3077
|
-
realtimeSync: true,
|
|
3078
|
-
batch: true,
|
|
3079
|
-
maxBudgetChars: 32e3,
|
|
3080
|
-
connectionType: "http"
|
|
3081
|
-
},
|
|
3082
|
-
configSchema: {
|
|
3083
|
-
remnicDaemonUrl: "URL of the Remnic daemon (default: http://127.0.0.1:4318)",
|
|
3084
|
-
namespace: "Optional namespace",
|
|
3085
|
-
installExtension: "Install the Pi extension into ~/.pi/agent/extensions/remnic (default: true)"
|
|
3086
|
-
},
|
|
3087
|
-
homepage: "https://pi.dev",
|
|
3088
|
-
author: "Remnic",
|
|
3089
|
-
tags: ["official", "ai", "pi", "coding-agent"],
|
|
3090
|
-
requiresToken: true
|
|
3091
|
-
},
|
|
3092
|
-
{
|
|
3093
|
-
id: "replit",
|
|
3094
|
-
name: "Replit Agent",
|
|
3095
|
-
version: "1.0.0",
|
|
3096
|
-
description: "Replit Agent \u2014 memory via HTTP API (reduced capabilities)",
|
|
3097
|
-
capabilities: {
|
|
3098
|
-
observe: true,
|
|
3099
|
-
recall: true,
|
|
3100
|
-
store: true,
|
|
3101
|
-
search: false,
|
|
3102
|
-
entities: false,
|
|
3103
|
-
realtimeSync: false,
|
|
3104
|
-
batch: false,
|
|
3105
|
-
maxBudgetChars: 8e3,
|
|
3106
|
-
connectionType: "http"
|
|
3107
|
-
},
|
|
3108
|
-
configSchema: {
|
|
3109
|
-
apiUrl: "URL of the Remnic HTTP API",
|
|
3110
|
-
authToken: "Bearer token for authentication"
|
|
3111
|
-
},
|
|
3112
|
-
homepage: "https://replit.com",
|
|
3113
|
-
author: "Replit",
|
|
3114
|
-
tags: ["official", "cloud"],
|
|
3115
|
-
requiresToken: true
|
|
3116
|
-
},
|
|
3117
|
-
{
|
|
3118
|
-
id: "generic-mcp",
|
|
3119
|
-
name: "Generic MCP Client",
|
|
3120
|
-
version: "1.0.0",
|
|
3121
|
-
description: "Any MCP-compatible client \u2014 connect via standard MCP protocol",
|
|
3122
|
-
capabilities: {
|
|
3123
|
-
observe: true,
|
|
3124
|
-
recall: true,
|
|
3125
|
-
store: true,
|
|
3126
|
-
search: true,
|
|
3127
|
-
entities: true,
|
|
3128
|
-
realtimeSync: true,
|
|
3129
|
-
batch: true,
|
|
3130
|
-
maxBudgetChars: 64e3,
|
|
3131
|
-
connectionType: "mcp"
|
|
3132
|
-
},
|
|
3133
|
-
configSchema: {
|
|
3134
|
-
mcpServerUrl: "URL of the MCP Remnic server",
|
|
3135
|
-
namespace: "Optional namespace",
|
|
3136
|
-
authToken: "Bearer token for authentication"
|
|
3137
|
-
},
|
|
3138
|
-
homepage: "https://github.com/joshuaswarren/remnic",
|
|
3139
|
-
author: "Remnic",
|
|
3140
|
-
tags: ["generic", "mcp"],
|
|
3141
|
-
requiresToken: true
|
|
3142
|
-
},
|
|
3143
|
-
{
|
|
3144
|
-
id: "weclone",
|
|
3145
|
-
name: "WeClone Avatar",
|
|
3146
|
-
version: "1.0.0",
|
|
3147
|
-
description: "Memory-aware OpenAI-compatible proxy for deployed WeClone avatars \u2014 injects Remnic recall into chat completions and buffers turns via observe",
|
|
3148
|
-
capabilities: {
|
|
3149
|
-
observe: true,
|
|
3150
|
-
recall: true,
|
|
3151
|
-
store: false,
|
|
3152
|
-
search: false,
|
|
3153
|
-
entities: false,
|
|
3154
|
-
realtimeSync: false,
|
|
3155
|
-
batch: false,
|
|
3156
|
-
maxBudgetChars: 32e3,
|
|
3157
|
-
connectionType: "http"
|
|
3158
|
-
},
|
|
3159
|
-
configSchema: {
|
|
3160
|
-
wecloneApiUrl: "Base URL of the WeClone OpenAI-compatible API (e.g. http://localhost:8000/v1)",
|
|
3161
|
-
proxyPort: "Local port where the memory proxy will listen (default 8100)",
|
|
3162
|
-
remnicDaemonUrl: "URL of the Remnic daemon exposing /engram/v1/recall and /engram/v1/observe",
|
|
3163
|
-
sessionStrategy: "Per-caller session mapping strategy: 'caller-id' | 'single'",
|
|
3164
|
-
wecloneModelName: "Optional fine-tuned model name passed through to WeClone"
|
|
3165
|
-
},
|
|
3166
|
-
homepage: "https://github.com/xming521/weclone",
|
|
3167
|
-
author: "Remnic",
|
|
3168
|
-
tags: ["official", "ai", "weclone", "proxy"],
|
|
3169
|
-
requiresToken: true
|
|
3170
|
-
},
|
|
3171
|
-
{
|
|
3172
|
-
id: "hermes",
|
|
3173
|
-
name: "Hermes Agent",
|
|
3174
|
-
version: "1.0.0",
|
|
3175
|
-
description: "Hermes Agent MemoryProvider \u2014 automatic recall/observe on every turn via Python plugin protocol",
|
|
3176
|
-
capabilities: {
|
|
3177
|
-
observe: true,
|
|
3178
|
-
recall: true,
|
|
3179
|
-
store: true,
|
|
3180
|
-
search: true,
|
|
3181
|
-
entities: false,
|
|
3182
|
-
realtimeSync: true,
|
|
3183
|
-
batch: false,
|
|
3184
|
-
maxBudgetChars: 32e3,
|
|
3185
|
-
connectionType: "http"
|
|
3186
|
-
},
|
|
3187
|
-
configSchema: {
|
|
3188
|
-
host: "Remnic daemon host (default: 127.0.0.1)",
|
|
3189
|
-
port: "Remnic daemon port (default: 4318)",
|
|
3190
|
-
profile: "Hermes profile name (default: default)"
|
|
3191
|
-
},
|
|
3192
|
-
homepage: "https://github.com/joshuaswarren/remnic/tree/main/packages/plugin-hermes",
|
|
3193
|
-
author: "Remnic",
|
|
3194
|
-
tags: ["official", "python", "hermes"],
|
|
3195
|
-
requiresToken: true
|
|
3196
|
-
}
|
|
3197
|
-
];
|
|
3198
|
-
var REGISTRY_DIR_NAME = ".engram-connectors";
|
|
3199
|
-
function getRegistryPath() {
|
|
3200
|
-
const xdgConfigHome = readEnvVar("XDG_CONFIG_HOME");
|
|
3201
|
-
const configDir = xdgConfigHome ? path13.join(xdgConfigHome, "engram") : path13.join(resolveHomeDir(), ".config", "engram");
|
|
3202
|
-
return path13.join(configDir, REGISTRY_DIR_NAME, "registry.json");
|
|
3203
|
-
}
|
|
3204
|
-
function loadRegistry() {
|
|
3205
|
-
const regPath = getRegistryPath();
|
|
3206
|
-
if (!fs9.existsSync(regPath)) {
|
|
3207
|
-
const registry = {
|
|
3208
|
-
connectors: BUILTIN_CONNECTORS,
|
|
3209
|
-
registryPath: regPath
|
|
3210
|
-
};
|
|
3211
|
-
saveRegistry(registry);
|
|
3212
|
-
return registry;
|
|
3213
|
-
}
|
|
3214
|
-
const raw = fs9.readFileSync(regPath, "utf8");
|
|
3215
|
-
try {
|
|
3216
|
-
const parsed = JSON.parse(raw);
|
|
3217
|
-
const builtinIds = new Set(BUILTIN_CONNECTORS.map((b) => b.id));
|
|
3218
|
-
const customOnly = (parsed.connectors ?? []).filter((c) => !builtinIds.has(c.id));
|
|
3219
|
-
const merged = [...BUILTIN_CONNECTORS, ...customOnly];
|
|
3220
|
-
return {
|
|
3221
|
-
connectors: merged,
|
|
3222
|
-
registryPath: regPath
|
|
3223
|
-
};
|
|
3224
|
-
} catch {
|
|
3225
|
-
const registry = {
|
|
3226
|
-
connectors: BUILTIN_CONNECTORS,
|
|
3227
|
-
registryPath: regPath
|
|
3228
|
-
};
|
|
3229
|
-
saveRegistry(registry);
|
|
3230
|
-
return registry;
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
function saveRegistry(registry) {
|
|
3234
|
-
const regPath = registry.registryPath;
|
|
3235
|
-
fs9.mkdirSync(path13.dirname(regPath), { recursive: true });
|
|
3236
|
-
fs9.writeFileSync(regPath, JSON.stringify({ connectors: registry.connectors }, null, 2));
|
|
3237
|
-
}
|
|
3238
|
-
function listConnectors() {
|
|
3239
|
-
const registry = loadRegistry();
|
|
3240
|
-
const connectorsDir = getConnectorsDir();
|
|
3241
|
-
const installedIds = /* @__PURE__ */ new Set();
|
|
3242
|
-
if (fs9.existsSync(connectorsDir)) {
|
|
3243
|
-
for (const entry of fs9.readdirSync(connectorsDir)) {
|
|
3244
|
-
if (entry.endsWith(".json")) {
|
|
3245
|
-
try {
|
|
3246
|
-
const config = JSON.parse(
|
|
3247
|
-
fs9.readFileSync(path13.join(connectorsDir, entry), "utf8")
|
|
3248
|
-
);
|
|
3249
|
-
installedIds.add(config.connectorId);
|
|
3250
|
-
} catch {
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
const available = registry.connectors.map((manifest) => ({
|
|
3256
|
-
...manifest,
|
|
3257
|
-
installed: installedIds.has(manifest.id)
|
|
3258
|
-
}));
|
|
3259
|
-
const installed = [];
|
|
3260
|
-
for (const id of installedIds) {
|
|
3261
|
-
const configPath = path13.join(connectorsDir, `${id}.json`);
|
|
3262
|
-
try {
|
|
3263
|
-
const raw = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3264
|
-
const { token: _redacted, ...config } = raw;
|
|
3265
|
-
installed.push({
|
|
3266
|
-
connectorId: id,
|
|
3267
|
-
config,
|
|
3268
|
-
status: "installed",
|
|
3269
|
-
installedAt: raw.installedAt
|
|
3270
|
-
});
|
|
3271
|
-
} catch {
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
return { installed, available };
|
|
3275
|
-
}
|
|
3276
|
-
function getConnectorToken(connectorId) {
|
|
3277
|
-
try {
|
|
3278
|
-
return loadTokenStore().tokens.find((t) => t.connector === connectorId)?.token;
|
|
3279
|
-
} catch {
|
|
3280
|
-
return void 0;
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
function readSavedConnectorConfig(configPath) {
|
|
3284
|
-
if (!fs9.existsSync(configPath)) return {};
|
|
3285
|
-
try {
|
|
3286
|
-
const parsed = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3287
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
3288
|
-
const {
|
|
3289
|
-
connectorId: _connectorId,
|
|
3290
|
-
installedAt: _installedAt,
|
|
3291
|
-
token: _token,
|
|
3292
|
-
...config
|
|
3293
|
-
} = parsed;
|
|
3294
|
-
return config;
|
|
3295
|
-
} catch {
|
|
3296
|
-
return {};
|
|
3297
|
-
}
|
|
3298
|
-
}
|
|
3299
|
-
function removeClearedSavedConnectorConfig(savedConnectorConfig, rawUserConfig) {
|
|
3300
|
-
const merged = { ...savedConnectorConfig };
|
|
3301
|
-
for (const [key, value] of Object.entries(rawUserConfig)) {
|
|
3302
|
-
if (value === void 0 || value === null || value === "") {
|
|
3303
|
-
delete merged[key];
|
|
3304
|
-
}
|
|
3305
|
-
}
|
|
3306
|
-
return merged;
|
|
3307
|
-
}
|
|
3308
|
-
function compactConnectorConfigOverrides(rawUserConfig) {
|
|
3309
|
-
const safeUserConfig = {};
|
|
3310
|
-
for (const [key, value] of Object.entries(rawUserConfig)) {
|
|
3311
|
-
if (value === void 0 || value === null || value === "") continue;
|
|
3312
|
-
safeUserConfig[key] = value;
|
|
3313
|
-
}
|
|
3314
|
-
return safeUserConfig;
|
|
3315
|
-
}
|
|
3316
|
-
function installConnector(options) {
|
|
3317
|
-
const registry = loadRegistry();
|
|
3318
|
-
const manifest = registry.connectors.find((c) => c.id === options.connectorId);
|
|
3319
|
-
if (!manifest) {
|
|
3320
|
-
return {
|
|
3321
|
-
connectorId: options.connectorId,
|
|
3322
|
-
status: "error",
|
|
3323
|
-
message: `Unknown connector: ${options.connectorId}`
|
|
3324
|
-
};
|
|
3325
|
-
}
|
|
3326
|
-
const existing = listConnectors().installed.find(
|
|
3327
|
-
(c) => c.connectorId === options.connectorId
|
|
3328
|
-
);
|
|
3329
|
-
if (existing && !options.force) {
|
|
3330
|
-
return {
|
|
3331
|
-
connectorId: options.connectorId,
|
|
3332
|
-
status: "already_installed",
|
|
3333
|
-
message: "Already installed. Use --force to reinstall."
|
|
3334
|
-
};
|
|
3335
|
-
}
|
|
3336
|
-
const configDir = getConnectorsDir();
|
|
3337
|
-
fs9.mkdirSync(configDir, { recursive: true });
|
|
3338
|
-
const configPath = path13.join(configDir, `${options.connectorId}.json`);
|
|
3339
|
-
const savedConnectorConfig = existing ? readSavedConnectorConfig(configPath) : {};
|
|
3340
|
-
let hermesSavedProfile;
|
|
3341
|
-
let hermesSavedHost;
|
|
3342
|
-
let hermesSavedPort;
|
|
3343
|
-
let hermesResolvedProfile;
|
|
3344
|
-
let hermesResolvedHost;
|
|
3345
|
-
let hermesResolvedPort;
|
|
3346
|
-
if (options.connectorId === "hermes") {
|
|
3347
|
-
if (fs9.existsSync(configPath)) {
|
|
3348
|
-
try {
|
|
3349
|
-
const prev = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3350
|
-
if (prev?.profile != null) {
|
|
3351
|
-
try {
|
|
3352
|
-
hermesSavedProfile = sanitizeHermesProfile(String(prev.profile));
|
|
3353
|
-
} catch {
|
|
3354
|
-
}
|
|
3355
|
-
}
|
|
3356
|
-
if (prev?.host != null) {
|
|
3357
|
-
try {
|
|
3358
|
-
hermesSavedHost = sanitizeHermesHost(String(prev.host));
|
|
3359
|
-
} catch {
|
|
3360
|
-
}
|
|
3361
|
-
}
|
|
3362
|
-
if (prev?.port != null) {
|
|
3363
|
-
try {
|
|
3364
|
-
const coercedPort = Number(String(prev.port));
|
|
3365
|
-
hermesSavedPort = sanitizeHermesPort(coercedPort);
|
|
3366
|
-
} catch {
|
|
3367
|
-
}
|
|
3368
|
-
}
|
|
3369
|
-
} catch {
|
|
3370
|
-
}
|
|
3371
|
-
}
|
|
3372
|
-
hermesResolvedProfile = hermesSavedProfile ?? "default";
|
|
3373
|
-
hermesResolvedHost = hermesSavedHost ?? "127.0.0.1";
|
|
3374
|
-
if (options.config?.port !== void 0) {
|
|
3375
|
-
try {
|
|
3376
|
-
hermesResolvedPort = sanitizeHermesPort(Number(String(options.config.port)));
|
|
3377
|
-
} catch (err) {
|
|
3378
|
-
return {
|
|
3379
|
-
connectorId: options.connectorId,
|
|
3380
|
-
status: "error",
|
|
3381
|
-
message: `Invalid Hermes config: ${err instanceof Error ? err.message : String(err)}`
|
|
3382
|
-
};
|
|
3383
|
-
}
|
|
3384
|
-
}
|
|
3385
|
-
if (hermesResolvedPort === void 0) {
|
|
3386
|
-
hermesResolvedPort = hermesSavedPort ?? 4318;
|
|
3387
|
-
}
|
|
3388
|
-
if (options.config?.profile !== void 0) {
|
|
3389
|
-
try {
|
|
3390
|
-
hermesResolvedProfile = sanitizeHermesProfile(String(options.config.profile));
|
|
3391
|
-
} catch (err) {
|
|
3392
|
-
return {
|
|
3393
|
-
connectorId: options.connectorId,
|
|
3394
|
-
status: "error",
|
|
3395
|
-
message: `Invalid Hermes config: ${err instanceof Error ? err.message : String(err)}`
|
|
3396
|
-
};
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
if (options.config?.host !== void 0) {
|
|
3400
|
-
try {
|
|
3401
|
-
hermesResolvedHost = sanitizeHermesHost(String(options.config.host));
|
|
3402
|
-
} catch (err) {
|
|
3403
|
-
return {
|
|
3404
|
-
connectorId: options.connectorId,
|
|
3405
|
-
status: "error",
|
|
3406
|
-
message: `Invalid Hermes config: ${err instanceof Error ? err.message : String(err)}`
|
|
3407
|
-
};
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
}
|
|
3411
|
-
const nonHermesPriorTokenStore = options.connectorId !== "hermes" && manifest.requiresToken ? loadTokenStore() : null;
|
|
3412
|
-
let tokenEntry = null;
|
|
3413
|
-
if (options.connectorId === "hermes") {
|
|
3414
|
-
try {
|
|
3415
|
-
tokenEntry = buildTokenEntry(options.connectorId);
|
|
3416
|
-
} catch {
|
|
3417
|
-
}
|
|
3418
|
-
} else if (manifest.requiresToken) {
|
|
3419
|
-
try {
|
|
3420
|
-
tokenEntry = generateToken(options.connectorId);
|
|
3421
|
-
} catch {
|
|
3422
|
-
if (nonHermesPriorTokenStore !== null) {
|
|
3423
|
-
try {
|
|
3424
|
-
saveTokenStore(nonHermesPriorTokenStore);
|
|
3425
|
-
} catch {
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
if (options.connectorId !== "hermes" && manifest.requiresToken && tokenEntry === null) {
|
|
3431
|
-
return {
|
|
3432
|
-
connectorId: options.connectorId,
|
|
3433
|
-
status: "error",
|
|
3434
|
-
message: `${manifest.name} install aborted: token generation failed. Run \`remnic token generate ${options.connectorId}\` to create the token, then reinstall.`
|
|
3435
|
-
};
|
|
3436
|
-
}
|
|
3437
|
-
const { token: _callerToken, ...rawUserConfig } = options.config ?? {};
|
|
3438
|
-
const savedConnectorConfigForMerge = removeClearedSavedConnectorConfig(savedConnectorConfig, rawUserConfig);
|
|
3439
|
-
const safeUserConfig = compactConnectorConfigOverrides(rawUserConfig);
|
|
3440
|
-
const resolvedConfig = {
|
|
3441
|
-
...savedConnectorConfigForMerge,
|
|
3442
|
-
...safeUserConfig,
|
|
3443
|
-
connectorId: options.connectorId,
|
|
3444
|
-
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3445
|
-
// For hermes, always overlay the sanitized/coerced resolved values so that
|
|
3446
|
-
// the connector JSON always has a numeric port and validated profile/host.
|
|
3447
|
-
// This also ensures options.config string values (from --config=port=5555)
|
|
3448
|
-
// are replaced with their sanitized numeric equivalents (Fix 2 root cause).
|
|
3449
|
-
...hermesResolvedProfile !== void 0 ? {
|
|
3450
|
-
profile: hermesResolvedProfile,
|
|
3451
|
-
host: hermesResolvedHost,
|
|
3452
|
-
port: hermesResolvedPort
|
|
3453
|
-
} : {}
|
|
3454
|
-
};
|
|
3455
|
-
if (options.connectorId === "hermes") {
|
|
3456
|
-
const rawProfile = hermesResolvedProfile;
|
|
3457
|
-
const hermesHost = hermesResolvedHost;
|
|
3458
|
-
const hermesPort = hermesResolvedPort;
|
|
3459
|
-
let hermesProfile;
|
|
3460
|
-
try {
|
|
3461
|
-
hermesProfile = sanitizeHermesProfile(rawProfile);
|
|
3462
|
-
} catch (err) {
|
|
3463
|
-
return {
|
|
3464
|
-
connectorId: options.connectorId,
|
|
3465
|
-
status: "error",
|
|
3466
|
-
message: `Hermes install aborted: ${err instanceof Error ? err.message : String(err)}`
|
|
3467
|
-
};
|
|
3468
|
-
}
|
|
3469
|
-
if (!tokenEntry) {
|
|
3470
|
-
return {
|
|
3471
|
-
connectorId: options.connectorId,
|
|
3472
|
-
status: "error",
|
|
3473
|
-
message: "Hermes install aborted: token store unavailable. Run `remnic token generate hermes` then reinstall to complete setup."
|
|
3474
|
-
};
|
|
3475
|
-
}
|
|
3476
|
-
let yamlResult;
|
|
3477
|
-
try {
|
|
3478
|
-
yamlResult = upsertHermesConfig({
|
|
3479
|
-
profile: hermesProfile,
|
|
3480
|
-
host: hermesHost,
|
|
3481
|
-
port: hermesPort,
|
|
3482
|
-
token: tokenEntry.token
|
|
3483
|
-
});
|
|
3484
|
-
} catch (err) {
|
|
3485
|
-
return {
|
|
3486
|
-
connectorId: options.connectorId,
|
|
3487
|
-
status: "error",
|
|
3488
|
-
message: `Hermes install aborted: config.yaml write failed \u2014 ${err instanceof Error ? err.message : String(err)}`
|
|
3489
|
-
};
|
|
3490
|
-
}
|
|
3491
|
-
if (!yamlResult.updated) {
|
|
3492
|
-
return {
|
|
3493
|
-
connectorId: options.connectorId,
|
|
3494
|
-
status: "error",
|
|
3495
|
-
message: `Hermes install aborted: ${yamlResult.reason ?? "config.yaml not written"}. Create the Hermes profile directory first, then reinstall.`
|
|
3496
|
-
};
|
|
3497
|
-
}
|
|
3498
|
-
const priorTokenStore = loadTokenStore();
|
|
3499
|
-
let committed = false;
|
|
3500
|
-
try {
|
|
3501
|
-
commitTokenEntry(tokenEntry);
|
|
3502
|
-
committed = true;
|
|
3503
|
-
} catch (commitErr) {
|
|
3504
|
-
let tokensRolledBack = true;
|
|
3505
|
-
let tokensRollbackErrMsg = "";
|
|
3506
|
-
try {
|
|
3507
|
-
saveTokenStore(priorTokenStore);
|
|
3508
|
-
} catch (tokenRestoreErr) {
|
|
3509
|
-
tokensRolledBack = false;
|
|
3510
|
-
tokensRollbackErrMsg = tokenRestoreErr instanceof Error ? tokenRestoreErr.message : String(tokenRestoreErr);
|
|
3511
|
-
}
|
|
3512
|
-
let yamlRolledBack = true;
|
|
3513
|
-
let yamlRollbackErrMsg = "";
|
|
3514
|
-
try {
|
|
3515
|
-
if (yamlResult.priorContent === null) {
|
|
3516
|
-
fs9.unlinkSync(yamlResult.configPath);
|
|
3517
|
-
} else if (typeof yamlResult.priorContent === "string") {
|
|
3518
|
-
writeSecretFileSync(yamlResult.configPath, yamlResult.priorContent);
|
|
3519
|
-
}
|
|
3520
|
-
} catch (yamlRestoreErr) {
|
|
3521
|
-
yamlRolledBack = false;
|
|
3522
|
-
yamlRollbackErrMsg = yamlRestoreErr instanceof Error ? yamlRestoreErr.message : String(yamlRestoreErr);
|
|
3523
|
-
}
|
|
3524
|
-
const commitErrMsg = commitErr instanceof Error ? commitErr.message : String(commitErr);
|
|
3525
|
-
let message;
|
|
3526
|
-
if (tokensRolledBack && yamlRolledBack) {
|
|
3527
|
-
message = `Hermes install failed during token commit \u2014 ${commitErrMsg}. config.yaml and tokens.json restored to prior state. Resolve the tokens.json access issue, then reinstall.`;
|
|
3528
|
-
} else if (!yamlRolledBack && tokensRolledBack) {
|
|
3529
|
-
message = `Hermes install failed during token commit \u2014 ${commitErrMsg}. tokens.json restored but config.yaml rollback ALSO failed (${yamlRollbackErrMsg}). Hermes daemon may be in an inconsistent state: config references a stale token. Manually inspect ${yamlResult.configPath} and reinstall.`;
|
|
3530
|
-
} else if (yamlRolledBack && !tokensRolledBack) {
|
|
3531
|
-
message = `Hermes install failed during token commit \u2014 ${commitErrMsg}. config.yaml restored but tokens.json rollback ALSO failed (${tokensRollbackErrMsg}). Hermes daemon may be in an inconsistent state: tokens.json is corrupt or incomplete. Manually inspect ~/.remnic/tokens.json and reinstall.`;
|
|
3532
|
-
} else {
|
|
3533
|
-
message = `Hermes install failed during token commit \u2014 ${commitErrMsg}. BOTH rollbacks failed: config.yaml rollback failed (${yamlRollbackErrMsg}); tokens.json rollback failed (${tokensRollbackErrMsg}). Hermes daemon is likely in an inconsistent state. Manually inspect ${yamlResult.configPath} and ~/.remnic/tokens.json, then reinstall.`;
|
|
3534
|
-
}
|
|
3535
|
-
return {
|
|
3536
|
-
connectorId: options.connectorId,
|
|
3537
|
-
status: "error",
|
|
3538
|
-
message
|
|
3539
|
-
};
|
|
3540
|
-
}
|
|
3541
|
-
try {
|
|
3542
|
-
writeSecretFileSync(configPath, JSON.stringify(resolvedConfig, null, 2));
|
|
3543
|
-
} catch (writeErr) {
|
|
3544
|
-
let tokenRollbackFailed = false;
|
|
3545
|
-
let tokenRollbackMsg = "token store restored to pre-install snapshot";
|
|
3546
|
-
try {
|
|
3547
|
-
saveTokenStore(priorTokenStore);
|
|
3548
|
-
} catch (tokenRestoreErr) {
|
|
3549
|
-
tokenRollbackFailed = true;
|
|
3550
|
-
tokenRollbackMsg = `token rollback failed: ${tokenRestoreErr instanceof Error ? tokenRestoreErr.message : String(tokenRestoreErr)}`;
|
|
3551
|
-
}
|
|
3552
|
-
let yamlRollbackMsg = "config.yaml restored";
|
|
3553
|
-
try {
|
|
3554
|
-
if (yamlResult.priorContent === null) {
|
|
3555
|
-
let unlinkSucceeded = false;
|
|
3556
|
-
let unlinkErr;
|
|
3557
|
-
try {
|
|
3558
|
-
fs9.unlinkSync(yamlResult.configPath);
|
|
3559
|
-
unlinkSucceeded = true;
|
|
3560
|
-
} catch (err) {
|
|
3561
|
-
unlinkErr = err;
|
|
3562
|
-
}
|
|
3563
|
-
if (unlinkSucceeded) {
|
|
3564
|
-
yamlRollbackMsg = "config.yaml removed (was newly created)";
|
|
3565
|
-
} else {
|
|
3566
|
-
const unlinkMsg = unlinkErr instanceof Error ? unlinkErr.message : String(unlinkErr);
|
|
3567
|
-
yamlRollbackMsg = `config.yaml rollback failed: could not remove newly-created file \u2014 ${unlinkMsg}`;
|
|
3568
|
-
}
|
|
3569
|
-
} else if (typeof yamlResult.priorContent === "string") {
|
|
3570
|
-
writeSecretFileSync(yamlResult.configPath, yamlResult.priorContent);
|
|
3571
|
-
yamlRollbackMsg = "config.yaml restored to prior content";
|
|
3572
|
-
}
|
|
3573
|
-
} catch (yamlRollbackErr) {
|
|
3574
|
-
yamlRollbackMsg = `config.yaml rollback failed: ${yamlRollbackErr instanceof Error ? yamlRollbackErr.message : String(yamlRollbackErr)}`;
|
|
3575
|
-
}
|
|
3576
|
-
const urgentSuffix = tokenRollbackFailed ? ` tokens.json may be in an inconsistent state \u2014 manually restore hermes token with 'remnic token generate hermes'.` : "";
|
|
3577
|
-
return {
|
|
3578
|
-
connectorId: options.connectorId,
|
|
3579
|
-
status: "error",
|
|
3580
|
-
message: `Hermes install aborted: connector config write failed \u2014 connector directory may not be writable. Rollback: ${tokenRollbackMsg}; ${yamlRollbackMsg}.${urgentSuffix} Resolve the permission issue, then reinstall.`
|
|
3581
|
-
};
|
|
3582
|
-
}
|
|
3583
|
-
const notes = [];
|
|
3584
|
-
notes.push(`Updated Hermes config: ${yamlResult.configPath}`);
|
|
3585
|
-
if (hermesProfile === "default") {
|
|
3586
|
-
const legacyDefaultConfigPath = hermesDefaultProfileConfigPath();
|
|
3587
|
-
if (!sameHermesConfigTarget(yamlResult.configPath, legacyDefaultConfigPath)) {
|
|
3588
|
-
try {
|
|
3589
|
-
const legacyDefaultCleanResult = removeHermesConfigFile(legacyDefaultConfigPath);
|
|
3590
|
-
if (legacyDefaultCleanResult.updated) {
|
|
3591
|
-
notes.push(`Cleaned stale remnic: block from legacy default profile: ${legacyDefaultConfigPath}`);
|
|
3592
|
-
}
|
|
3593
|
-
} catch {
|
|
3594
|
-
notes.push("Note: could not clean stale remnic: block from legacy default profile");
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
}
|
|
3598
|
-
let oldProfileResolvesToDifferentFile = false;
|
|
3599
|
-
if (hermesSavedProfile !== void 0) {
|
|
3600
|
-
try {
|
|
3601
|
-
oldProfileResolvesToDifferentFile = !sameHermesConfigTarget(hermesConfigPath(hermesSavedProfile), hermesConfigPath(hermesProfile));
|
|
3602
|
-
} catch {
|
|
3603
|
-
oldProfileResolvesToDifferentFile = false;
|
|
3604
|
-
}
|
|
3605
|
-
}
|
|
3606
|
-
if (oldProfileResolvesToDifferentFile) {
|
|
3607
|
-
try {
|
|
3608
|
-
const oldCleanResult = removeHermesConfig({ profile: hermesSavedProfile });
|
|
3609
|
-
if (oldCleanResult.updated) {
|
|
3610
|
-
notes.push(`Cleaned stale remnic: block from previous profile: ${oldCleanResult.configPath}`);
|
|
3611
|
-
}
|
|
3612
|
-
} catch {
|
|
3613
|
-
notes.push(`Note: could not clean stale remnic: block from previous profile "${hermesSavedProfile}"`);
|
|
3614
|
-
}
|
|
3615
|
-
}
|
|
3616
|
-
if (committed && tokenEntry) {
|
|
3617
|
-
const daemonOk = checkDaemonHealth(hermesHost, hermesPort, tokenEntry.token);
|
|
3618
|
-
if (daemonOk) {
|
|
3619
|
-
notes.push("Daemon health check: OK");
|
|
3620
|
-
} else {
|
|
3621
|
-
notes.push(
|
|
3622
|
-
`Daemon not reachable at ${hermesHost}:${hermesPort} \u2014 start with: remnic daemon start`
|
|
3623
|
-
);
|
|
3624
|
-
}
|
|
3625
|
-
}
|
|
3626
|
-
const suffix = notes.length > 0 ? `
|
|
3627
|
-
${notes.join("\n ")}` : "";
|
|
3628
|
-
return {
|
|
3629
|
-
connectorId: options.connectorId,
|
|
3630
|
-
status: "installed",
|
|
3631
|
-
configPath,
|
|
3632
|
-
message: `Installed ${manifest.name} v${manifest.version}${suffix}`
|
|
3633
|
-
};
|
|
3634
|
-
}
|
|
3635
|
-
let extensionMessage = "";
|
|
3636
|
-
let extensionInstalled = false;
|
|
3637
|
-
let extensionHandle = null;
|
|
3638
|
-
if (options.connectorId === "codex-cli") {
|
|
3639
|
-
const coerced = coerceInstallExtension(resolvedConfig.installExtension);
|
|
3640
|
-
if (coerced !== void 0) {
|
|
3641
|
-
resolvedConfig.installExtension = coerced;
|
|
3642
|
-
}
|
|
3643
|
-
const shouldInstall = resolvedConfig.installExtension !== false;
|
|
3644
|
-
resolvedConfig.installExtension = shouldInstall;
|
|
3645
|
-
const codexHomeOverride = typeof resolvedConfig.codexHome === "string" && resolvedConfig.codexHome.length > 0 ? resolvedConfig.codexHome : null;
|
|
3646
|
-
const resolvedCodexHome = resolveCodexHome(codexHomeOverride);
|
|
3647
|
-
resolvedConfig.codexHome = resolvedCodexHome;
|
|
3648
|
-
if (shouldInstall) {
|
|
3649
|
-
try {
|
|
3650
|
-
const extensionSourceOverride = typeof resolvedConfig.extensionSourceDir === "string" && resolvedConfig.extensionSourceDir.length > 0 ? resolvedConfig.extensionSourceDir : null;
|
|
3651
|
-
const extResult = installCodexMemoryExtension({
|
|
3652
|
-
codexHome: resolvedCodexHome,
|
|
3653
|
-
sourceDir: extensionSourceOverride
|
|
3654
|
-
});
|
|
3655
|
-
extensionMessage = ` (memory extension: ${extResult.remnicExtensionDir})`;
|
|
3656
|
-
extensionInstalled = true;
|
|
3657
|
-
extensionHandle = extResult;
|
|
3658
|
-
} catch (err) {
|
|
3659
|
-
const errMsg = err instanceof Error ? err.message : "unknown error";
|
|
3660
|
-
let extensionErrTokenRolledBack = false;
|
|
3661
|
-
let extensionErrTokenRollbackMsg = "";
|
|
3662
|
-
if (tokenEntry !== null && nonHermesPriorTokenStore !== null) {
|
|
3663
|
-
try {
|
|
3664
|
-
saveTokenStore(nonHermesPriorTokenStore);
|
|
3665
|
-
extensionErrTokenRolledBack = true;
|
|
3666
|
-
} catch (tokenRestoreErr) {
|
|
3667
|
-
extensionErrTokenRolledBack = false;
|
|
3668
|
-
extensionErrTokenRollbackMsg = tokenRestoreErr instanceof Error ? tokenRestoreErr.message : String(tokenRestoreErr);
|
|
3669
|
-
}
|
|
3670
|
-
}
|
|
3671
|
-
const tokenRollbackSuffix = manifest.requiresToken ? extensionErrTokenRolledBack ? " Token has been rolled back." : ` Token rollback FAILED (${extensionErrTokenRollbackMsg}) \u2014 tokens.json may contain an orphaned entry. Manually inspect ~/.remnic/tokens.json and reinstall.` : "";
|
|
3672
|
-
return {
|
|
3673
|
-
connectorId: options.connectorId,
|
|
3674
|
-
status: "error",
|
|
3675
|
-
message: `Memory extension install failed \u2014 ${errMsg}.${tokenRollbackSuffix} Resolve the issue, then reinstall.`
|
|
3676
|
-
};
|
|
3677
|
-
}
|
|
3678
|
-
} else {
|
|
3679
|
-
extensionMessage = " (memory extension: skipped via installExtension=false)";
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
let weCloneProxyHandleRollback = null;
|
|
3683
|
-
if (options.connectorId === "weclone") {
|
|
3684
|
-
try {
|
|
3685
|
-
let proxyConfigPath = null;
|
|
3686
|
-
if (existing && fs9.existsSync(configPath)) {
|
|
3687
|
-
try {
|
|
3688
|
-
const savedRegistryConfig = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3689
|
-
if (typeof savedRegistryConfig.proxyConfigPath === "string" && savedRegistryConfig.proxyConfigPath.length > 0) {
|
|
3690
|
-
proxyConfigPath = savedRegistryConfig.proxyConfigPath;
|
|
3691
|
-
}
|
|
3692
|
-
} catch {
|
|
3693
|
-
}
|
|
3694
|
-
}
|
|
3695
|
-
if (proxyConfigPath === null) {
|
|
3696
|
-
proxyConfigPath = resolveWeCloneProxyConfigPath();
|
|
3697
|
-
}
|
|
3698
|
-
const prior = readWeCloneProxyConfigIfExists(proxyConfigPath);
|
|
3699
|
-
const proxyConfig = buildWeCloneProxyConfig({
|
|
3700
|
-
userConfig: safeUserConfig,
|
|
3701
|
-
priorConfig: prior ? safeParseJson(prior) : null,
|
|
3702
|
-
authToken: tokenEntry?.token
|
|
3703
|
-
});
|
|
3704
|
-
fs9.mkdirSync(path13.dirname(proxyConfigPath), { recursive: true });
|
|
3705
|
-
weCloneProxyHandleRollback = () => {
|
|
3706
|
-
try {
|
|
3707
|
-
if (prior === null) {
|
|
3708
|
-
if (fs9.existsSync(proxyConfigPath)) {
|
|
3709
|
-
fs9.unlinkSync(proxyConfigPath);
|
|
3710
|
-
}
|
|
3711
|
-
} else {
|
|
3712
|
-
writeSecretFileSync(proxyConfigPath, prior);
|
|
3713
|
-
}
|
|
3714
|
-
} catch {
|
|
3715
|
-
}
|
|
3716
|
-
};
|
|
3717
|
-
try {
|
|
3718
|
-
writeSecretFileSync(
|
|
3719
|
-
proxyConfigPath,
|
|
3720
|
-
JSON.stringify(proxyConfig, null, 2)
|
|
3721
|
-
);
|
|
3722
|
-
} catch (writeErr) {
|
|
3723
|
-
try {
|
|
3724
|
-
weCloneProxyHandleRollback();
|
|
3725
|
-
} catch {
|
|
3726
|
-
}
|
|
3727
|
-
weCloneProxyHandleRollback = null;
|
|
3728
|
-
throw writeErr;
|
|
3729
|
-
}
|
|
3730
|
-
resolvedConfig.proxyConfigPath = proxyConfigPath;
|
|
3731
|
-
resolvedConfig.proxyPort = proxyConfig.proxyPort;
|
|
3732
|
-
resolvedConfig.wecloneApiUrl = proxyConfig.wecloneApiUrl;
|
|
3733
|
-
resolvedConfig.remnicDaemonUrl = proxyConfig.remnicDaemonUrl;
|
|
3734
|
-
resolvedConfig.sessionStrategy = proxyConfig.sessionStrategy;
|
|
3735
|
-
} catch (weCloneErr) {
|
|
3736
|
-
let tokenRolledBack = false;
|
|
3737
|
-
let tokenRollbackMsg = "";
|
|
3738
|
-
if (tokenEntry !== null && nonHermesPriorTokenStore !== null) {
|
|
3739
|
-
try {
|
|
3740
|
-
saveTokenStore(nonHermesPriorTokenStore);
|
|
3741
|
-
tokenRolledBack = true;
|
|
3742
|
-
} catch (tokenRestoreErr) {
|
|
3743
|
-
tokenRolledBack = false;
|
|
3744
|
-
tokenRollbackMsg = tokenRestoreErr instanceof Error ? tokenRestoreErr.message : String(tokenRestoreErr);
|
|
3745
|
-
}
|
|
3746
|
-
}
|
|
3747
|
-
const tokenSuffix = manifest.requiresToken && tokenEntry !== null ? tokenRolledBack ? " Token has been rolled back." : ` Token rollback FAILED (${tokenRollbackMsg}) \u2014 tokens.json may contain an orphaned entry. Manually inspect ~/.remnic/tokens.json and reinstall.` : "";
|
|
3748
|
-
return {
|
|
3749
|
-
connectorId: options.connectorId,
|
|
3750
|
-
status: "error",
|
|
3751
|
-
message: `WeClone install aborted: proxy config write failed \u2014 ${weCloneErr instanceof Error ? weCloneErr.message : String(weCloneErr)}.${tokenSuffix} Resolve the write permission issue on ~/.remnic/connectors/, then reinstall.`
|
|
3752
|
-
};
|
|
3753
|
-
}
|
|
3754
|
-
}
|
|
3755
|
-
const INTERNAL_KEYS_DENYLIST = [
|
|
3756
|
-
"extensionSourceDir"
|
|
3757
|
-
// test-only override for the plugin-codex source path
|
|
3758
|
-
];
|
|
3759
|
-
for (const key of INTERNAL_KEYS_DENYLIST) {
|
|
3760
|
-
delete resolvedConfig[key];
|
|
3761
|
-
}
|
|
3762
|
-
try {
|
|
3763
|
-
writeSecretFileSync(configPath, JSON.stringify(resolvedConfig, null, 2));
|
|
3764
|
-
} catch (writeErr) {
|
|
3765
|
-
let configWriteTokenRolledBack = false;
|
|
3766
|
-
let configWriteTokenRollbackMsg = "";
|
|
3767
|
-
if (tokenEntry !== null && nonHermesPriorTokenStore !== null) {
|
|
3768
|
-
try {
|
|
3769
|
-
saveTokenStore(nonHermesPriorTokenStore);
|
|
3770
|
-
configWriteTokenRolledBack = true;
|
|
3771
|
-
} catch (tokenRestoreErr) {
|
|
3772
|
-
configWriteTokenRolledBack = false;
|
|
3773
|
-
configWriteTokenRollbackMsg = tokenRestoreErr instanceof Error ? tokenRestoreErr.message : String(tokenRestoreErr);
|
|
3774
|
-
}
|
|
3775
|
-
}
|
|
3776
|
-
if (extensionInstalled && extensionHandle !== null) {
|
|
3777
|
-
try {
|
|
3778
|
-
extensionHandle.rollback();
|
|
3779
|
-
} catch {
|
|
3780
|
-
console.warn(
|
|
3781
|
-
"[remnic/connectors] installConnector: config write failed and extension rollback also failed \u2014 manual cleanup of memories_extensions/remnic may be required."
|
|
3782
|
-
);
|
|
3783
|
-
}
|
|
3784
|
-
}
|
|
3785
|
-
if (weCloneProxyHandleRollback !== null) {
|
|
3786
|
-
try {
|
|
3787
|
-
weCloneProxyHandleRollback();
|
|
3788
|
-
} catch {
|
|
3789
|
-
}
|
|
3790
|
-
}
|
|
3791
|
-
const configWriteTokenSuffix = manifest.requiresToken && tokenEntry !== null ? configWriteTokenRolledBack ? " Token has been rolled back." : ` Token rollback FAILED (${configWriteTokenRollbackMsg}) \u2014 tokens.json may contain an orphaned entry. Manually inspect ~/.remnic/tokens.json and reinstall.` : "";
|
|
3792
|
-
return {
|
|
3793
|
-
connectorId: options.connectorId,
|
|
3794
|
-
status: "error",
|
|
3795
|
-
message: `${manifest.name} install aborted: connector config write failed \u2014 ${writeErr instanceof Error ? writeErr.message : String(writeErr)}.${configWriteTokenSuffix} Resolve the write permission issue, then reinstall.`
|
|
3796
|
-
};
|
|
3797
|
-
}
|
|
3798
|
-
if (extensionInstalled && extensionHandle !== null) {
|
|
3799
|
-
extensionHandle.commit();
|
|
3800
|
-
}
|
|
3801
|
-
return {
|
|
3802
|
-
connectorId: options.connectorId,
|
|
3803
|
-
status: "installed",
|
|
3804
|
-
configPath,
|
|
3805
|
-
message: `Installed ${manifest.name} v${manifest.version}${extensionMessage}`
|
|
3806
|
-
};
|
|
3807
|
-
}
|
|
3808
|
-
function removeConnector(connectorId) {
|
|
3809
|
-
const configDir = getConnectorsDir();
|
|
3810
|
-
const configPath = path13.join(configDir, `${connectorId}.json`);
|
|
3811
|
-
let codexHomeOverride = null;
|
|
3812
|
-
let savedInstallExtension = void 0;
|
|
3813
|
-
let configParsed = false;
|
|
3814
|
-
if (connectorId === "codex-cli" && fs9.existsSync(configPath)) {
|
|
3815
|
-
try {
|
|
3816
|
-
const parsed = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3817
|
-
configParsed = true;
|
|
3818
|
-
if (typeof parsed.codexHome === "string" && parsed.codexHome.length > 0) {
|
|
3819
|
-
codexHomeOverride = parsed.codexHome;
|
|
3820
|
-
}
|
|
3821
|
-
const coerced = coerceInstallExtension(parsed.installExtension);
|
|
3822
|
-
if (coerced !== void 0) {
|
|
3823
|
-
savedInstallExtension = coerced;
|
|
3824
|
-
}
|
|
3825
|
-
} catch {
|
|
3826
|
-
console.debug(
|
|
3827
|
-
"[remnic/connectors] removeConnector: codex-cli.json parse failed \u2014 skipping extension removal to avoid touching unverified paths"
|
|
3828
|
-
);
|
|
3829
|
-
}
|
|
3830
|
-
}
|
|
3831
|
-
if (!fs9.existsSync(configPath)) {
|
|
3832
|
-
let staleTokenRevoked = false;
|
|
3833
|
-
try {
|
|
3834
|
-
staleTokenRevoked = revokeToken(connectorId);
|
|
3835
|
-
} catch {
|
|
3836
|
-
}
|
|
3837
|
-
const message = staleTokenRevoked ? `${connectorId} is not installed. Removed stale token entry for ${connectorId}.` : "Not installed";
|
|
3838
|
-
return {
|
|
3839
|
-
connectorId,
|
|
3840
|
-
configPath,
|
|
3841
|
-
status: "not_found",
|
|
3842
|
-
message
|
|
3843
|
-
};
|
|
3844
|
-
}
|
|
3845
|
-
let storedProfile = "default";
|
|
3846
|
-
if (connectorId === "hermes") {
|
|
3847
|
-
try {
|
|
3848
|
-
const stored = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3849
|
-
if (typeof stored?.profile === "string") storedProfile = stored.profile;
|
|
3850
|
-
} catch {
|
|
3851
|
-
}
|
|
3852
|
-
}
|
|
3853
|
-
let weCloneProxyConfigPath = null;
|
|
3854
|
-
let weCloneRegistryParseFailed = false;
|
|
3855
|
-
if (connectorId === "weclone") {
|
|
3856
|
-
try {
|
|
3857
|
-
const stored = JSON.parse(fs9.readFileSync(configPath, "utf8"));
|
|
3858
|
-
if (typeof stored.proxyConfigPath === "string" && stored.proxyConfigPath.length > 0) {
|
|
3859
|
-
weCloneProxyConfigPath = stored.proxyConfigPath;
|
|
3860
|
-
}
|
|
3861
|
-
} catch {
|
|
3862
|
-
weCloneRegistryParseFailed = true;
|
|
3863
|
-
}
|
|
3864
|
-
if (weCloneProxyConfigPath === null && !weCloneRegistryParseFailed) {
|
|
3865
|
-
try {
|
|
3866
|
-
weCloneProxyConfigPath = resolveWeCloneProxyConfigPath();
|
|
3867
|
-
} catch {
|
|
3868
|
-
}
|
|
3869
|
-
}
|
|
3870
|
-
}
|
|
3871
|
-
if (connectorId === "weclone" && weCloneRegistryParseFailed) {
|
|
3872
|
-
console.warn(
|
|
3873
|
-
"[remnic/connectors] removeConnector: weclone.json is malformed \u2014 aborting removal to preserve provenance. Fix or delete " + configPath + " manually and retry."
|
|
3874
|
-
);
|
|
3875
|
-
return {
|
|
3876
|
-
connectorId,
|
|
3877
|
-
configPath,
|
|
3878
|
-
message: "Removal aborted: weclone.json is malformed. Registry config left in place for inspection; proxy config NOT removed.",
|
|
3879
|
-
status: "skipped",
|
|
3880
|
-
reason: "config-parse-failed"
|
|
3881
|
-
};
|
|
3882
|
-
}
|
|
3883
|
-
if (connectorId === "codex-cli" && fs9.existsSync(configPath) && !configParsed) {
|
|
3884
|
-
console.warn(
|
|
3885
|
-
"[remnic/connectors] removeConnector: codex-cli.json is malformed \u2014 aborting removal to preserve provenance. Fix or delete " + configPath + " manually and retry."
|
|
3886
|
-
);
|
|
3887
|
-
return {
|
|
3888
|
-
connectorId,
|
|
3889
|
-
configPath,
|
|
3890
|
-
message: "Removal aborted: codex-cli.json is malformed. Config file left in place for inspection.",
|
|
3891
|
-
status: "skipped",
|
|
3892
|
-
reason: "config-parse-failed"
|
|
3893
|
-
};
|
|
3894
|
-
}
|
|
3895
|
-
let extensionMessage = "";
|
|
3896
|
-
if (connectorId === "codex-cli") {
|
|
3897
|
-
if (savedInstallExtension === false) {
|
|
3898
|
-
extensionMessage = " (memory extension: skipped \u2014 installExtension=false)";
|
|
3899
|
-
} else if (savedInstallExtension !== true || codexHomeOverride === null) {
|
|
3900
|
-
extensionMessage = " (memory extension: skipped \u2014 no install provenance in saved config)";
|
|
3901
|
-
} else {
|
|
3902
|
-
const extResult = removeCodexMemoryExtension({ codexHome: codexHomeOverride });
|
|
3903
|
-
extensionMessage = extResult.removed ? ` (memory extension removed: ${extResult.remnicExtensionDir})` : " (no memory extension present)";
|
|
3904
|
-
}
|
|
3905
|
-
}
|
|
3906
|
-
try {
|
|
3907
|
-
fs9.unlinkSync(configPath);
|
|
3908
|
-
} catch (unlinkErr) {
|
|
3909
|
-
const sanitizedErr = unlinkErr instanceof Error ? unlinkErr.message : String(unlinkErr);
|
|
3910
|
-
return {
|
|
3911
|
-
connectorId,
|
|
3912
|
-
configPath,
|
|
3913
|
-
status: "error",
|
|
3914
|
-
message: `${connectorId} remove aborted: could not delete connector file (${sanitizedErr}). Token and any connector-specific state were not modified.`
|
|
3915
|
-
};
|
|
3916
|
-
}
|
|
3917
|
-
const notes = [];
|
|
3918
|
-
let tokenRevoked = true;
|
|
3919
|
-
try {
|
|
3920
|
-
revokeToken(connectorId);
|
|
3921
|
-
} catch (revokeErr) {
|
|
3922
|
-
tokenRevoked = false;
|
|
3923
|
-
const revokeMsg = revokeErr instanceof Error ? revokeErr.message : String(revokeErr);
|
|
3924
|
-
notes.push(`Warning: token revocation failed \u2014 ${revokeMsg}. The token for ${connectorId} may still be present in tokens.json.`);
|
|
3925
|
-
}
|
|
3926
|
-
let weCloneProxyDeleteFailed = null;
|
|
3927
|
-
if (connectorId === "weclone") {
|
|
3928
|
-
if (weCloneProxyConfigPath === null) {
|
|
3929
|
-
notes.push(
|
|
3930
|
-
"WeClone proxy config cleanup skipped: no persisted path found in saved config (likely a legacy install predating proxyConfigPath provenance)."
|
|
3931
|
-
);
|
|
3932
|
-
} else {
|
|
3933
|
-
const expectedSuffix = path13.join("connectors", "weclone.json");
|
|
3934
|
-
const isSafePath = path13.isAbsolute(weCloneProxyConfigPath) && weCloneProxyConfigPath.endsWith(expectedSuffix);
|
|
3935
|
-
if (!isSafePath) {
|
|
3936
|
-
weCloneProxyDeleteFailed = `Proxy config path ${JSON.stringify(weCloneProxyConfigPath)} failed safety validation (must be absolute and end with "${expectedSuffix}"). Refusing to delete \u2014 remove the file manually if it exists.`;
|
|
3937
|
-
} else {
|
|
3938
|
-
try {
|
|
3939
|
-
if (fs9.existsSync(weCloneProxyConfigPath)) {
|
|
3940
|
-
fs9.unlinkSync(weCloneProxyConfigPath);
|
|
3941
|
-
notes.push(`Removed WeClone proxy config: ${weCloneProxyConfigPath}`);
|
|
3942
|
-
}
|
|
3943
|
-
} catch (err) {
|
|
3944
|
-
weCloneProxyDeleteFailed = err instanceof Error ? err.message : String(err);
|
|
3945
|
-
}
|
|
3946
|
-
}
|
|
3947
|
-
}
|
|
3948
|
-
}
|
|
3949
|
-
if (weCloneProxyDeleteFailed !== null && weCloneProxyConfigPath !== null) {
|
|
3950
|
-
const tokenStatus = tokenRevoked ? "the registry config was deleted and the token was revoked" : "the registry config was deleted but TOKEN REVOCATION ALSO FAILED \u2014 inspect ~/.remnic/tokens.json and revoke manually";
|
|
3951
|
-
return {
|
|
3952
|
-
connectorId,
|
|
3953
|
-
configPath,
|
|
3954
|
-
status: "error",
|
|
3955
|
-
message: `WeClone remove partially succeeded: ${tokenStatus}, but the proxy config at ${weCloneProxyConfigPath} could not be deleted (${weCloneProxyDeleteFailed}). Manually remove that file \u2014 it may still contain a Remnic daemon bearer token.`
|
|
3956
|
-
};
|
|
3957
|
-
}
|
|
3958
|
-
if (connectorId === "hermes") {
|
|
3959
|
-
try {
|
|
3960
|
-
const yamlResult = removeHermesConfig({ profile: storedProfile });
|
|
3961
|
-
if (yamlResult.updated) {
|
|
3962
|
-
notes.push(`Removed remnic: block from Hermes config: ${yamlResult.configPath}`);
|
|
3963
|
-
} else if (yamlResult.reason?.startsWith("Hermes config cleanup partially failed:")) {
|
|
3964
|
-
const tokenStatus = tokenRevoked ? "the connector registry config was deleted and the token was revoked" : "the connector registry config was deleted but TOKEN REVOCATION ALSO FAILED \u2014 inspect ~/.remnic/tokens.json and revoke manually";
|
|
3965
|
-
return {
|
|
3966
|
-
connectorId,
|
|
3967
|
-
configPath,
|
|
3968
|
-
status: "error",
|
|
3969
|
-
message: `Hermes remove partially succeeded: ${tokenStatus}, but ${yamlResult.reason}. Updated paths: ${yamlResult.configPath}. Manually remove any stale remnic: block and token material from the failed Hermes config path.`
|
|
3970
|
-
};
|
|
3971
|
-
} else if (yamlResult.skipped) {
|
|
3972
|
-
notes.push(`Hermes config cleanup skipped: ${yamlResult.reason}`);
|
|
3973
|
-
}
|
|
3974
|
-
} catch (err) {
|
|
3975
|
-
notes.push(
|
|
3976
|
-
`Hermes config cleanup skipped: ${err instanceof Error ? err.message : String(err)}`
|
|
3977
|
-
);
|
|
3978
|
-
}
|
|
3979
|
-
}
|
|
3980
|
-
const suffix = notes.length > 0 ? `
|
|
3981
|
-
${notes.join("\n ")}` : "";
|
|
3982
|
-
return {
|
|
3983
|
-
connectorId,
|
|
3984
|
-
configPath,
|
|
3985
|
-
status: "removed",
|
|
3986
|
-
message: `Removed${extensionMessage}${suffix}`
|
|
3987
|
-
};
|
|
3988
|
-
}
|
|
3989
|
-
function sanitizeHermesProfile(profile) {
|
|
3990
|
-
if (typeof profile !== "string" || profile.length === 0) {
|
|
3991
|
-
throw new Error("Hermes profile name must be a non-empty string");
|
|
3992
|
-
}
|
|
3993
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(profile)) {
|
|
3994
|
-
throw new Error(
|
|
3995
|
-
`Invalid Hermes profile name: ${JSON.stringify(profile)} \u2014 must match [A-Za-z0-9][A-Za-z0-9._-]*`
|
|
3996
|
-
);
|
|
3997
|
-
}
|
|
3998
|
-
if (profile.includes("..")) {
|
|
3999
|
-
throw new Error(`Invalid Hermes profile name: ${JSON.stringify(profile)} \u2014 must not contain ".."`);
|
|
4000
|
-
}
|
|
4001
|
-
return profile;
|
|
4002
|
-
}
|
|
4003
|
-
function hermesConfigPath(profile) {
|
|
4004
|
-
const safeProfile = sanitizeHermesProfile(profile);
|
|
4005
|
-
const hermesRoot = path13.resolve(resolveHomeDir(), ".hermes");
|
|
4006
|
-
const rootConfigPath = path13.join(hermesRoot, "config.yaml");
|
|
4007
|
-
const profilesRoot = path13.join(hermesRoot, "profiles");
|
|
4008
|
-
if (safeProfile === "default") {
|
|
4009
|
-
const defaultProfileDir = path13.join(profilesRoot, safeProfile);
|
|
4010
|
-
if (isFile(rootConfigPath) || !fs9.existsSync(rootConfigPath) && !isDirectory(defaultProfileDir)) {
|
|
4011
|
-
return rootConfigPath;
|
|
4012
|
-
}
|
|
4013
|
-
}
|
|
4014
|
-
const cfgPath = path13.resolve(profilesRoot, safeProfile, "config.yaml");
|
|
4015
|
-
const rel = path13.relative(profilesRoot, cfgPath);
|
|
4016
|
-
if (rel.startsWith("..") || path13.isAbsolute(rel)) {
|
|
4017
|
-
throw new Error(
|
|
4018
|
-
`Invalid Hermes profile path: resolved outside ${profilesRoot}`
|
|
4019
|
-
);
|
|
4020
|
-
}
|
|
4021
|
-
return cfgPath;
|
|
4022
|
-
}
|
|
4023
|
-
function isDirectory(filePath) {
|
|
4024
|
-
try {
|
|
4025
|
-
return fs9.statSync(filePath).isDirectory();
|
|
4026
|
-
} catch {
|
|
4027
|
-
return false;
|
|
4028
|
-
}
|
|
4029
|
-
}
|
|
4030
|
-
function isFile(filePath) {
|
|
4031
|
-
try {
|
|
4032
|
-
return fs9.statSync(filePath).isFile();
|
|
4033
|
-
} catch {
|
|
4034
|
-
return false;
|
|
4035
|
-
}
|
|
4036
|
-
}
|
|
4037
|
-
function hermesConfigTarget(filePath) {
|
|
4038
|
-
try {
|
|
4039
|
-
return fs9.realpathSync.native(filePath);
|
|
4040
|
-
} catch {
|
|
4041
|
-
return path13.resolve(filePath);
|
|
4042
|
-
}
|
|
4043
|
-
}
|
|
4044
|
-
function sameHermesConfigTarget(leftPath, rightPath) {
|
|
4045
|
-
return hermesConfigTarget(leftPath) === hermesConfigTarget(rightPath);
|
|
4046
|
-
}
|
|
4047
|
-
function hermesDefaultProfileConfigPath() {
|
|
4048
|
-
const hermesRoot = path13.resolve(resolveHomeDir(), ".hermes");
|
|
4049
|
-
return path13.join(hermesRoot, "profiles", "default", "config.yaml");
|
|
4050
|
-
}
|
|
4051
|
-
function hermesConfigCleanupPaths(profile) {
|
|
4052
|
-
const cfgPath = hermesConfigPath(profile);
|
|
4053
|
-
const safeProfile = sanitizeHermesProfile(profile);
|
|
4054
|
-
if (safeProfile !== "default") {
|
|
4055
|
-
return [cfgPath];
|
|
4056
|
-
}
|
|
4057
|
-
return [.../* @__PURE__ */ new Set([cfgPath, hermesDefaultProfileConfigPath()])];
|
|
4058
|
-
}
|
|
4059
|
-
function sanitizeHermesHost(host) {
|
|
4060
|
-
if (typeof host !== "string" || host.length === 0) {
|
|
4061
|
-
throw new Error("Hermes host must be a non-empty string");
|
|
4062
|
-
}
|
|
4063
|
-
if (host.length > 253) {
|
|
4064
|
-
throw new Error(`Hermes host too long (max 253 chars): ${JSON.stringify(host.slice(0, 32))}\u2026`);
|
|
4065
|
-
}
|
|
4066
|
-
if (host.startsWith("[")) {
|
|
4067
|
-
if (!host.endsWith("]")) {
|
|
4068
|
-
throw new Error(
|
|
4069
|
-
`Invalid Hermes host: ${JSON.stringify(host)} \u2014 unbalanced brackets in IPv6 literal`
|
|
4070
|
-
);
|
|
4071
|
-
}
|
|
4072
|
-
const inner = host.slice(1, -1);
|
|
4073
|
-
if (inner.length === 0 || !/^[0-9A-Fa-f:]+$/.test(inner)) {
|
|
4074
|
-
throw new Error(
|
|
4075
|
-
`Invalid Hermes host: ${JSON.stringify(host)} \u2014 bracketed IPv6 literal must contain only hex digits and colons`
|
|
4076
|
-
);
|
|
4077
|
-
}
|
|
4078
|
-
return host;
|
|
4079
|
-
}
|
|
4080
|
-
if (host.includes(":")) {
|
|
4081
|
-
throw new Error(
|
|
4082
|
-
`Invalid Hermes host: ${JSON.stringify(host)} \u2014 host must not include a port; supply the port separately with --config port=<n>`
|
|
4083
|
-
);
|
|
4084
|
-
}
|
|
4085
|
-
if (!/^[A-Za-z0-9._\-]+$/.test(host)) {
|
|
4086
|
-
throw new Error(
|
|
4087
|
-
`Invalid Hermes host: ${JSON.stringify(host)} \u2014 must be a plain hostname or IP literal`
|
|
4088
|
-
);
|
|
4089
|
-
}
|
|
4090
|
-
return host;
|
|
4091
|
-
}
|
|
4092
|
-
function sanitizeHermesPort(port) {
|
|
4093
|
-
const numeric = Number(port);
|
|
4094
|
-
if (!Number.isInteger(numeric)) {
|
|
4095
|
-
throw new Error(
|
|
4096
|
-
`Invalid Hermes port "${port}": must be a positive integer`
|
|
4097
|
-
);
|
|
4098
|
-
}
|
|
4099
|
-
if (numeric < 1 || numeric > 65535) {
|
|
4100
|
-
throw new Error(`Invalid Hermes port: ${JSON.stringify(port)} \u2014 must be an integer in [1, 65535]`);
|
|
4101
|
-
}
|
|
4102
|
-
return numeric;
|
|
4103
|
-
}
|
|
4104
|
-
function writeSecretFileSync(filePath, data) {
|
|
4105
|
-
fs9.writeFileSync(filePath, data, { mode: 384 });
|
|
4106
|
-
try {
|
|
4107
|
-
fs9.chmodSync(filePath, 384);
|
|
4108
|
-
} catch {
|
|
4109
|
-
}
|
|
4110
|
-
}
|
|
4111
|
-
function upsertHermesConfig(opts) {
|
|
4112
|
-
const cfgPath = hermesConfigPath(opts.profile);
|
|
4113
|
-
const profileDir = path13.dirname(cfgPath);
|
|
4114
|
-
const safeHost = sanitizeHermesHost(opts.host);
|
|
4115
|
-
const safePort = sanitizeHermesPort(opts.port);
|
|
4116
|
-
if (!/^[A-Za-z0-9_]+$/.test(opts.token)) {
|
|
4117
|
-
throw new Error("Invalid Hermes token: contains non-alphanumeric characters");
|
|
4118
|
-
}
|
|
4119
|
-
if (!isDirectory(profileDir)) {
|
|
4120
|
-
return {
|
|
4121
|
-
updated: false,
|
|
4122
|
-
skipped: true,
|
|
4123
|
-
reason: `Hermes profile directory not found: ${profileDir}`,
|
|
4124
|
-
configPath: cfgPath
|
|
4125
|
-
};
|
|
4126
|
-
}
|
|
4127
|
-
const block = [
|
|
4128
|
-
"remnic:",
|
|
4129
|
-
` host: "${safeHost}"`,
|
|
4130
|
-
` port: ${safePort}`,
|
|
4131
|
-
` token: "${opts.token}"`
|
|
4132
|
-
].join("\n");
|
|
4133
|
-
if (!fs9.existsSync(cfgPath)) {
|
|
4134
|
-
writeSecretFileSync(cfgPath, block + "\n");
|
|
4135
|
-
return { updated: true, skipped: false, configPath: cfgPath, priorContent: null };
|
|
4136
|
-
}
|
|
4137
|
-
const raw = fs9.readFileSync(cfgPath, "utf8");
|
|
4138
|
-
const hasRemnicBlock = /^remnic:/m.test(raw);
|
|
4139
|
-
if (!hasRemnicBlock) {
|
|
4140
|
-
const separator = raw.endsWith("\n") ? "\n" : "\n\n";
|
|
4141
|
-
writeSecretFileSync(cfgPath, raw + separator + block + "\n");
|
|
4142
|
-
return { updated: true, skipped: false, configPath: cfgPath, priorContent: raw };
|
|
4143
|
-
}
|
|
4144
|
-
const splitLines = raw.split("\n");
|
|
4145
|
-
if (splitLines.length > 0 && splitLines[splitLines.length - 1] === "") {
|
|
4146
|
-
splitLines.pop();
|
|
4147
|
-
}
|
|
4148
|
-
const lines = splitLines;
|
|
4149
|
-
const newLines = [];
|
|
4150
|
-
let inRemnicBlock = false;
|
|
4151
|
-
let blockWritten = false;
|
|
4152
|
-
const written = { host: false, port: false, token: false };
|
|
4153
|
-
for (let i = 0; i < lines.length; i++) {
|
|
4154
|
-
const line = lines[i];
|
|
4155
|
-
if (/^remnic:/.test(line)) {
|
|
4156
|
-
inRemnicBlock = true;
|
|
4157
|
-
newLines.push(line);
|
|
4158
|
-
continue;
|
|
4159
|
-
}
|
|
4160
|
-
if (inRemnicBlock) {
|
|
4161
|
-
if (line.length > 0 && !/^\s/.test(line)) {
|
|
4162
|
-
if (!written.host) newLines.push(` host: "${safeHost}"`);
|
|
4163
|
-
if (!written.port) newLines.push(` port: ${safePort}`);
|
|
4164
|
-
if (!written.token) newLines.push(` token: "${opts.token}"`);
|
|
4165
|
-
blockWritten = true;
|
|
4166
|
-
inRemnicBlock = false;
|
|
4167
|
-
newLines.push(line);
|
|
4168
|
-
continue;
|
|
4169
|
-
}
|
|
4170
|
-
if (/^\s+host:/.test(line)) {
|
|
4171
|
-
newLines.push(` host: "${safeHost}"`);
|
|
4172
|
-
written.host = true;
|
|
4173
|
-
} else if (/^\s+port:/.test(line)) {
|
|
4174
|
-
newLines.push(` port: ${safePort}`);
|
|
4175
|
-
written.port = true;
|
|
4176
|
-
} else if (/^\s+token:/.test(line)) {
|
|
4177
|
-
newLines.push(` token: "${opts.token}"`);
|
|
4178
|
-
written.token = true;
|
|
4179
|
-
} else {
|
|
4180
|
-
newLines.push(line);
|
|
4181
|
-
}
|
|
4182
|
-
continue;
|
|
4183
|
-
}
|
|
4184
|
-
newLines.push(line);
|
|
4185
|
-
}
|
|
4186
|
-
if (inRemnicBlock && !blockWritten) {
|
|
4187
|
-
if (!written.host) newLines.push(` host: "${safeHost}"`);
|
|
4188
|
-
if (!written.port) newLines.push(` port: ${safePort}`);
|
|
4189
|
-
if (!written.token) newLines.push(` token: "${opts.token}"`);
|
|
4190
|
-
}
|
|
4191
|
-
writeSecretFileSync(cfgPath, newLines.join("\n") + "\n");
|
|
4192
|
-
return { updated: true, skipped: false, configPath: cfgPath, priorContent: raw };
|
|
4193
|
-
}
|
|
4194
|
-
function removeHermesConfig(opts) {
|
|
4195
|
-
const cfgPaths = hermesConfigCleanupPaths(opts.profile);
|
|
4196
|
-
const results = cfgPaths.map((cfgPath) => {
|
|
4197
|
-
try {
|
|
4198
|
-
return removeHermesConfigFile(cfgPath);
|
|
4199
|
-
} catch (err) {
|
|
4200
|
-
return {
|
|
4201
|
-
updated: false,
|
|
4202
|
-
skipped: true,
|
|
4203
|
-
reason: `Hermes config cleanup failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
4204
|
-
configPath: cfgPath
|
|
4205
|
-
};
|
|
4206
|
-
}
|
|
4207
|
-
});
|
|
4208
|
-
const updated = results.filter((result) => result.updated);
|
|
4209
|
-
const cleanupFailures = results.filter((result) => result.reason?.startsWith("Hermes config cleanup failed:"));
|
|
4210
|
-
if (updated.length > 0) {
|
|
4211
|
-
const updatedPaths = updated.map((result) => result.configPath).join(", ");
|
|
4212
|
-
if (cleanupFailures.length > 0) {
|
|
4213
|
-
const failedPaths = cleanupFailures.map((result) => result.configPath).join(", ");
|
|
4214
|
-
return {
|
|
4215
|
-
updated: false,
|
|
4216
|
-
skipped: true,
|
|
4217
|
-
reason: `Hermes config cleanup partially failed: updated ${updatedPaths}; failed ${failedPaths}`,
|
|
4218
|
-
configPath: `${updatedPaths}; failed: ${failedPaths}`
|
|
4219
|
-
};
|
|
4220
|
-
}
|
|
4221
|
-
return {
|
|
4222
|
-
updated: true,
|
|
4223
|
-
skipped: false,
|
|
4224
|
-
configPath: updatedPaths
|
|
4225
|
-
};
|
|
4226
|
-
}
|
|
4227
|
-
const cleanupFailure = cleanupFailures[0];
|
|
4228
|
-
if (cleanupFailure) {
|
|
4229
|
-
return cleanupFailure;
|
|
4230
|
-
}
|
|
4231
|
-
const existingWithoutBlock = results.find((result) => result.reason !== "Hermes config.yaml not found");
|
|
4232
|
-
return existingWithoutBlock ?? results[0] ?? {
|
|
4233
|
-
updated: false,
|
|
4234
|
-
skipped: true,
|
|
4235
|
-
reason: "Hermes config.yaml not found",
|
|
4236
|
-
configPath: hermesConfigPath(opts.profile)
|
|
4237
|
-
};
|
|
4238
|
-
}
|
|
4239
|
-
function removeHermesConfigFile(cfgPath) {
|
|
4240
|
-
if (!fs9.existsSync(cfgPath)) {
|
|
4241
|
-
return {
|
|
4242
|
-
updated: false,
|
|
4243
|
-
skipped: true,
|
|
4244
|
-
reason: "Hermes config.yaml not found",
|
|
4245
|
-
configPath: cfgPath
|
|
4246
|
-
};
|
|
4247
|
-
}
|
|
4248
|
-
const raw = fs9.readFileSync(cfgPath, "utf8");
|
|
4249
|
-
if (!/^remnic:/m.test(raw)) {
|
|
4250
|
-
return {
|
|
4251
|
-
updated: false,
|
|
4252
|
-
skipped: true,
|
|
4253
|
-
reason: "No remnic: block found in config.yaml",
|
|
4254
|
-
configPath: cfgPath
|
|
4255
|
-
};
|
|
4256
|
-
}
|
|
4257
|
-
const lines = raw.split("\n");
|
|
4258
|
-
const newLines = [];
|
|
4259
|
-
let inRemnicBlock = false;
|
|
4260
|
-
for (const line of lines) {
|
|
4261
|
-
if (/^remnic:/.test(line)) {
|
|
4262
|
-
inRemnicBlock = true;
|
|
4263
|
-
continue;
|
|
4264
|
-
}
|
|
4265
|
-
if (inRemnicBlock) {
|
|
4266
|
-
if (line.length > 0 && !/^\s/.test(line)) {
|
|
4267
|
-
inRemnicBlock = false;
|
|
4268
|
-
newLines.push(line);
|
|
4269
|
-
}
|
|
4270
|
-
continue;
|
|
4271
|
-
}
|
|
4272
|
-
newLines.push(line);
|
|
4273
|
-
}
|
|
4274
|
-
while (newLines.length > 0 && newLines[newLines.length - 1]?.trim() === "") {
|
|
4275
|
-
newLines.pop();
|
|
4276
|
-
}
|
|
4277
|
-
writeSecretFileSync(cfgPath, newLines.length > 0 ? newLines.join("\n") + "\n" : "");
|
|
4278
|
-
return { updated: true, skipped: false, configPath: cfgPath };
|
|
4279
|
-
}
|
|
4280
|
-
var HEALTH_EXIT_OK = 0;
|
|
4281
|
-
var HEALTH_EXIT_UNAUTHORIZED = 2;
|
|
4282
|
-
function checkDaemonHealth(host, port, authToken) {
|
|
4283
|
-
try {
|
|
4284
|
-
const safePort = Math.trunc(Number(port));
|
|
4285
|
-
if (!Number.isFinite(safePort) || safePort < 1 || safePort > 65535) {
|
|
4286
|
-
return false;
|
|
4287
|
-
}
|
|
4288
|
-
const bareHost = host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
|
|
4289
|
-
const script = [
|
|
4290
|
-
"const http = require('http');",
|
|
4291
|
-
"const env = process['env'];",
|
|
4292
|
-
"const headers = {};",
|
|
4293
|
-
"if (env.REMNIC_HEALTH_TOKEN) {",
|
|
4294
|
-
" headers['authorization'] = 'Bearer ' + env.REMNIC_HEALTH_TOKEN;",
|
|
4295
|
-
"}",
|
|
4296
|
-
"const req = http.get({",
|
|
4297
|
-
" host: env.REMNIC_HEALTH_HOST,",
|
|
4298
|
-
" port: parseInt(env.REMNIC_HEALTH_PORT, 10),",
|
|
4299
|
-
" path: '/engram/v1/health',",
|
|
4300
|
-
" headers,",
|
|
4301
|
-
" timeout: 3000,",
|
|
4302
|
-
"}, (res) => { process.exit(res.statusCode === 200 ? 0 : res.statusCode === 401 ? 2 : 1); });",
|
|
4303
|
-
"req.on('error', () => process.exit(1));",
|
|
4304
|
-
"req.on('timeout', () => { req.destroy(); process.exit(1); });"
|
|
4305
|
-
].join("\n");
|
|
4306
|
-
const env = mergeEnv({
|
|
4307
|
-
REMNIC_HEALTH_HOST: bareHost,
|
|
4308
|
-
REMNIC_HEALTH_PORT: String(safePort)
|
|
4309
|
-
});
|
|
4310
|
-
if (authToken) {
|
|
4311
|
-
env.REMNIC_HEALTH_TOKEN = authToken;
|
|
4312
|
-
}
|
|
4313
|
-
const processPath = process.execPath;
|
|
4314
|
-
const launchOptions = { timeout: 4e3, env };
|
|
4315
|
-
const result = launchProcessSync(processPath, ["-e", script], launchOptions);
|
|
4316
|
-
if (result.status === HEALTH_EXIT_OK) {
|
|
4317
|
-
return true;
|
|
4318
|
-
}
|
|
4319
|
-
if (result.status === HEALTH_EXIT_UNAUTHORIZED) {
|
|
4320
|
-
console.error(
|
|
4321
|
-
"[remnic/connectors] health probe got 401 \u2014 retrying after token cache TTL..."
|
|
4322
|
-
);
|
|
4323
|
-
launchProcessSync(processPath, ["-e", "setTimeout(() => {}, 6000)"], {
|
|
4324
|
-
timeout: 7e3,
|
|
4325
|
-
env: {}
|
|
4326
|
-
});
|
|
4327
|
-
const retry = launchProcessSync(processPath, ["-e", script], launchOptions);
|
|
4328
|
-
return retry.status === HEALTH_EXIT_OK;
|
|
4329
|
-
}
|
|
4330
|
-
return false;
|
|
4331
|
-
} catch {
|
|
4332
|
-
return false;
|
|
4333
|
-
}
|
|
4334
|
-
}
|
|
4335
|
-
async function doctorConnector(connectorId) {
|
|
4336
|
-
const installed = listConnectors().installed;
|
|
4337
|
-
const instance = installed.find((c) => c.connectorId === connectorId);
|
|
4338
|
-
if (!instance) {
|
|
4339
|
-
return {
|
|
4340
|
-
connectorId,
|
|
4341
|
-
checks: [{ name: "Installed", ok: false, detail: "Not installed" }],
|
|
4342
|
-
healthy: false
|
|
4343
|
-
};
|
|
4344
|
-
}
|
|
4345
|
-
const configPath = path13.join(getConnectorsDir(), `${connectorId}.json`);
|
|
4346
|
-
const checks = [];
|
|
4347
|
-
checks.push({
|
|
4348
|
-
name: "Config file",
|
|
4349
|
-
ok: fs9.existsSync(configPath),
|
|
4350
|
-
detail: configPath
|
|
4351
|
-
});
|
|
4352
|
-
try {
|
|
4353
|
-
const raw = fs9.readFileSync(configPath, "utf8");
|
|
4354
|
-
JSON.parse(raw);
|
|
4355
|
-
checks.push({ name: "Config valid", ok: true, detail: "OK" });
|
|
4356
|
-
} catch (e) {
|
|
4357
|
-
checks.push({ name: "Config valid", ok: false, detail: String(e) });
|
|
4358
|
-
}
|
|
4359
|
-
const mcpUrl = instance.config.mcpServerUrl;
|
|
4360
|
-
if (mcpUrl) {
|
|
4361
|
-
try {
|
|
4362
|
-
const controller = new AbortController();
|
|
4363
|
-
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
4364
|
-
const response = await fetch(mcpUrl, { signal: controller.signal });
|
|
4365
|
-
clearTimeout(timeoutId);
|
|
4366
|
-
checks.push({ name: "MCP server", ok: response.ok, detail: mcpUrl });
|
|
4367
|
-
} catch (e) {
|
|
4368
|
-
checks.push({
|
|
4369
|
-
name: "MCP server",
|
|
4370
|
-
ok: false,
|
|
4371
|
-
detail: `Cannot reach ${mcpUrl}: ${e instanceof Error ? e.message : "unknown"}`
|
|
4372
|
-
});
|
|
4373
|
-
}
|
|
4374
|
-
}
|
|
4375
|
-
const memoryDir = instance.config.memoryDir;
|
|
4376
|
-
if (memoryDir) {
|
|
4377
|
-
if (fs9.existsSync(memoryDir)) {
|
|
4378
|
-
checks.push({ name: "Memory directory", ok: true, detail: memoryDir });
|
|
4379
|
-
} else {
|
|
4380
|
-
checks.push({ name: "Memory directory", ok: false, detail: `Not found: ${memoryDir}` });
|
|
4381
|
-
}
|
|
4382
|
-
}
|
|
4383
|
-
const healthy = checks.every((c) => c.ok);
|
|
4384
|
-
return { connectorId, checks, healthy };
|
|
4385
|
-
}
|
|
4386
|
-
var CODEX_MEMORIES_SUBDIR = "memories";
|
|
4387
|
-
var CODEX_EXTENSIONS_SUBDIR = "memories_extensions";
|
|
4388
|
-
var REMNIC_EXTENSION_DIR_NAME = "remnic";
|
|
4389
|
-
function resolveCodexHome(override) {
|
|
4390
|
-
if (override && typeof override === "string" && override.trim().length > 0) {
|
|
4391
|
-
return path13.resolve(override.trim());
|
|
4392
|
-
}
|
|
4393
|
-
const envHome = readEnvVar("CODEX_HOME");
|
|
4394
|
-
if (envHome && envHome.trim().length > 0) {
|
|
4395
|
-
return path13.resolve(envHome.trim());
|
|
4396
|
-
}
|
|
4397
|
-
const home = readEnvVar("HOME") || readEnvVar("USERPROFILE") || resolveHomeDir();
|
|
4398
|
-
return path13.resolve(home, ".codex");
|
|
4399
|
-
}
|
|
4400
|
-
function resolveCodexMemoryExtensionPaths(codexHomeOverride) {
|
|
4401
|
-
const codexHome = resolveCodexHome(codexHomeOverride);
|
|
4402
|
-
const memoriesDir = path13.join(codexHome, CODEX_MEMORIES_SUBDIR);
|
|
4403
|
-
const extensionsRoot = path13.join(path13.dirname(memoriesDir), CODEX_EXTENSIONS_SUBDIR);
|
|
4404
|
-
const remnicExtensionDir = path13.join(extensionsRoot, REMNIC_EXTENSION_DIR_NAME);
|
|
4405
|
-
return { codexHome, memoriesDir, extensionsRoot, remnicExtensionDir };
|
|
4406
|
-
}
|
|
4407
|
-
function locatePluginCodexExtensionSource(override) {
|
|
4408
|
-
if (override && typeof override === "string" && override.trim().length > 0) {
|
|
4409
|
-
const resolved = path13.resolve(override.trim());
|
|
4410
|
-
if (fs9.existsSync(resolved) && fs9.statSync(resolved).isDirectory()) {
|
|
4411
|
-
return resolved;
|
|
4412
|
-
}
|
|
4413
|
-
throw new Error(`Codex extension source directory not found: ${resolved}`);
|
|
4414
|
-
}
|
|
4415
|
-
const EXTENSION_SUBPATH = path13.join("memories_extensions", "remnic");
|
|
4416
|
-
const WORKSPACE_RELATIVE_PATH = path13.join(
|
|
4417
|
-
"packages",
|
|
4418
|
-
"plugin-codex",
|
|
4419
|
-
"memories_extensions",
|
|
4420
|
-
"remnic"
|
|
4421
|
-
);
|
|
4422
|
-
const searched = [];
|
|
4423
|
-
try {
|
|
4424
|
-
const moduleDir = path13.dirname(fileURLToPath(import.meta.url));
|
|
4425
|
-
const bundledCandidate = path13.join(moduleDir, "codex");
|
|
4426
|
-
searched.push(bundledCandidate);
|
|
4427
|
-
if (fs9.existsSync(bundledCandidate) && fs9.statSync(bundledCandidate).isDirectory()) {
|
|
4428
|
-
return bundledCandidate;
|
|
4429
|
-
}
|
|
4430
|
-
const distConnectorsCandidate = path13.join(moduleDir, "connectors", "codex");
|
|
4431
|
-
searched.push(distConnectorsCandidate);
|
|
4432
|
-
if (fs9.existsSync(distConnectorsCandidate) && fs9.statSync(distConnectorsCandidate).isDirectory()) {
|
|
4433
|
-
return distConnectorsCandidate;
|
|
4434
|
-
}
|
|
4435
|
-
} catch {
|
|
4436
|
-
}
|
|
4437
|
-
try {
|
|
4438
|
-
const requireFromHere = createRequire(import.meta.url);
|
|
4439
|
-
const pluginPkgJsonPath = requireFromHere.resolve("@remnic/plugin-codex/package.json");
|
|
4440
|
-
const pluginPkgRoot = path13.dirname(pluginPkgJsonPath);
|
|
4441
|
-
const candidate = path13.join(pluginPkgRoot, EXTENSION_SUBPATH);
|
|
4442
|
-
searched.push(candidate);
|
|
4443
|
-
if (fs9.existsSync(candidate) && fs9.statSync(candidate).isDirectory()) {
|
|
4444
|
-
return candidate;
|
|
4445
|
-
}
|
|
4446
|
-
} catch {
|
|
4447
|
-
}
|
|
4448
|
-
try {
|
|
4449
|
-
const moduleDir = path13.dirname(fileURLToPath(import.meta.url));
|
|
4450
|
-
let dir = moduleDir;
|
|
4451
|
-
for (let depth = 0; depth < 8; depth += 1) {
|
|
4452
|
-
const candidate = path13.join(
|
|
4453
|
-
dir,
|
|
4454
|
-
"node_modules",
|
|
4455
|
-
"@remnic",
|
|
4456
|
-
"plugin-codex",
|
|
4457
|
-
EXTENSION_SUBPATH
|
|
4458
|
-
);
|
|
4459
|
-
searched.push(candidate);
|
|
4460
|
-
if (fs9.existsSync(candidate) && fs9.statSync(candidate).isDirectory()) {
|
|
4461
|
-
return candidate;
|
|
4462
|
-
}
|
|
4463
|
-
const parent = path13.dirname(dir);
|
|
4464
|
-
if (parent === dir) break;
|
|
4465
|
-
dir = parent;
|
|
4466
|
-
}
|
|
4467
|
-
} catch {
|
|
4468
|
-
}
|
|
4469
|
-
const anchors = [];
|
|
4470
|
-
try {
|
|
4471
|
-
anchors.push(path13.dirname(fileURLToPath(import.meta.url)));
|
|
4472
|
-
} catch {
|
|
4473
|
-
}
|
|
4474
|
-
anchors.push(process.cwd());
|
|
4475
|
-
for (const anchor of anchors) {
|
|
4476
|
-
let dir = anchor;
|
|
4477
|
-
for (let depth = 0; depth < 12; depth += 1) {
|
|
4478
|
-
const candidate = path13.join(dir, WORKSPACE_RELATIVE_PATH);
|
|
4479
|
-
searched.push(candidate);
|
|
4480
|
-
if (fs9.existsSync(candidate) && fs9.statSync(candidate).isDirectory()) {
|
|
4481
|
-
return candidate;
|
|
4482
|
-
}
|
|
4483
|
-
const parent = path13.dirname(dir);
|
|
4484
|
-
if (parent === dir) break;
|
|
4485
|
-
dir = parent;
|
|
4486
|
-
}
|
|
4487
|
-
}
|
|
4488
|
-
throw new Error(
|
|
4489
|
-
"Could not locate the plugin-codex memories_extensions/remnic source directory.\nPaths searched:\n" + searched.map((p) => ` - ${p}`).join("\n") + "\nInstall @remnic/plugin-codex or pass sourceDir explicitly."
|
|
4490
|
-
);
|
|
4491
|
-
}
|
|
4492
|
-
function copyDirRecursiveSync(src, dest) {
|
|
4493
|
-
let count = 0;
|
|
4494
|
-
fs9.mkdirSync(dest, { recursive: true });
|
|
4495
|
-
const entries = fs9.readdirSync(src, { withFileTypes: true });
|
|
4496
|
-
for (const entry of entries) {
|
|
4497
|
-
const from = path13.join(src, entry.name);
|
|
4498
|
-
const to = path13.join(dest, entry.name);
|
|
4499
|
-
if (entry.isDirectory()) {
|
|
4500
|
-
count += copyDirRecursiveSync(from, to);
|
|
4501
|
-
} else if (entry.isFile()) {
|
|
4502
|
-
fs9.copyFileSync(from, to);
|
|
4503
|
-
count += 1;
|
|
4504
|
-
}
|
|
4505
|
-
}
|
|
4506
|
-
return count;
|
|
4507
|
-
}
|
|
4508
|
-
function installCodexMemoryExtension(options = {}) {
|
|
4509
|
-
const paths = resolveCodexMemoryExtensionPaths(options.codexHome ?? null);
|
|
4510
|
-
const sourceDir = locatePluginCodexExtensionSource(options.sourceDir ?? null);
|
|
4511
|
-
fs9.mkdirSync(paths.extensionsRoot, { recursive: true });
|
|
4512
|
-
const tmpPrefix = `.${REMNIC_EXTENSION_DIR_NAME}.tmp-`;
|
|
4513
|
-
const STALE_TMP_THRESHOLD_MS = 10 * 60 * 1e3;
|
|
4514
|
-
const now = Date.now();
|
|
4515
|
-
try {
|
|
4516
|
-
const existingEntries = fs9.readdirSync(paths.extensionsRoot);
|
|
4517
|
-
for (const entry of existingEntries) {
|
|
4518
|
-
if (!entry.startsWith(tmpPrefix)) continue;
|
|
4519
|
-
const stalePath = path13.join(paths.extensionsRoot, entry);
|
|
4520
|
-
try {
|
|
4521
|
-
const stat = fs9.statSync(stalePath);
|
|
4522
|
-
const ageMs = now - stat.mtimeMs;
|
|
4523
|
-
if (ageMs < STALE_TMP_THRESHOLD_MS) {
|
|
4524
|
-
continue;
|
|
4525
|
-
}
|
|
4526
|
-
fs9.rmSync(stalePath, { recursive: true, force: true });
|
|
4527
|
-
} catch {
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
} catch {
|
|
4531
|
-
}
|
|
4532
|
-
const tmpName = `${tmpPrefix}${process.pid}-${Date.now()}`;
|
|
4533
|
-
const tmpDir = path13.join(paths.extensionsRoot, tmpName);
|
|
4534
|
-
let filesCopied = 0;
|
|
4535
|
-
let commitFn = () => {
|
|
4536
|
-
};
|
|
4537
|
-
let rollbackFn = () => {
|
|
4538
|
-
};
|
|
4539
|
-
try {
|
|
4540
|
-
filesCopied = copyDirRecursiveSync(sourceDir, tmpDir);
|
|
4541
|
-
const backupDir = `${paths.remnicExtensionDir}.bak-${Date.now()}`;
|
|
4542
|
-
const hadExisting = fs9.existsSync(paths.remnicExtensionDir);
|
|
4543
|
-
if (hadExisting) {
|
|
4544
|
-
fs9.renameSync(paths.remnicExtensionDir, backupDir);
|
|
4545
|
-
}
|
|
4546
|
-
try {
|
|
4547
|
-
fs9.renameSync(tmpDir, paths.remnicExtensionDir);
|
|
4548
|
-
} catch (renameErr) {
|
|
4549
|
-
if (hadExisting) {
|
|
4550
|
-
try {
|
|
4551
|
-
fs9.renameSync(backupDir, paths.remnicExtensionDir);
|
|
4552
|
-
} catch {
|
|
4553
|
-
}
|
|
4554
|
-
}
|
|
4555
|
-
throw renameErr;
|
|
4556
|
-
}
|
|
4557
|
-
commitFn = () => {
|
|
4558
|
-
if (hadExisting) {
|
|
4559
|
-
try {
|
|
4560
|
-
fs9.rmSync(backupDir, { recursive: true, force: true });
|
|
4561
|
-
} catch {
|
|
4562
|
-
}
|
|
4563
|
-
}
|
|
4564
|
-
};
|
|
4565
|
-
rollbackFn = () => {
|
|
4566
|
-
if (hadExisting) {
|
|
4567
|
-
try {
|
|
4568
|
-
if (fs9.existsSync(paths.remnicExtensionDir)) {
|
|
4569
|
-
fs9.rmSync(paths.remnicExtensionDir, { recursive: true, force: true });
|
|
4570
|
-
}
|
|
4571
|
-
fs9.renameSync(backupDir, paths.remnicExtensionDir);
|
|
4572
|
-
} catch {
|
|
4573
|
-
}
|
|
4574
|
-
} else {
|
|
4575
|
-
try {
|
|
4576
|
-
if (fs9.existsSync(paths.remnicExtensionDir)) {
|
|
4577
|
-
fs9.rmSync(paths.remnicExtensionDir, { recursive: true, force: true });
|
|
4578
|
-
}
|
|
4579
|
-
} catch {
|
|
4580
|
-
}
|
|
4581
|
-
}
|
|
4582
|
-
};
|
|
4583
|
-
} catch (err) {
|
|
4584
|
-
if (fs9.existsSync(tmpDir)) {
|
|
4585
|
-
try {
|
|
4586
|
-
fs9.rmSync(tmpDir, { recursive: true, force: true });
|
|
4587
|
-
} catch {
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
throw err;
|
|
4591
|
-
}
|
|
4592
|
-
const instructionsPath = path13.join(paths.remnicExtensionDir, "instructions.md");
|
|
4593
|
-
return {
|
|
4594
|
-
...paths,
|
|
4595
|
-
instructionsPath,
|
|
4596
|
-
filesCopied,
|
|
4597
|
-
commit: commitFn,
|
|
4598
|
-
rollback: rollbackFn
|
|
4599
|
-
};
|
|
4600
|
-
}
|
|
4601
|
-
function removeCodexMemoryExtension(options = {}) {
|
|
4602
|
-
const paths = resolveCodexMemoryExtensionPaths(options.codexHome ?? null);
|
|
4603
|
-
let removed = false;
|
|
4604
|
-
if (fs9.existsSync(paths.remnicExtensionDir)) {
|
|
4605
|
-
fs9.rmSync(paths.remnicExtensionDir, { recursive: true, force: true });
|
|
4606
|
-
removed = true;
|
|
4607
|
-
}
|
|
4608
|
-
return { ...paths, removed };
|
|
4609
|
-
}
|
|
4610
|
-
function getConnectorsDir() {
|
|
4611
|
-
const xdgConfigHome = readEnvVar("XDG_CONFIG_HOME");
|
|
4612
|
-
const configDir = xdgConfigHome ? path13.join(xdgConfigHome, "engram") : path13.join(resolveHomeDir(), ".config", "engram");
|
|
4613
|
-
return path13.join(configDir, REGISTRY_DIR_NAME, "connectors");
|
|
4614
|
-
}
|
|
4615
|
-
var WECLONE_PROXY_CONFIG_DIRNAME = ".remnic";
|
|
4616
|
-
var WECLONE_PROXY_CONFIG_FILENAME = "weclone.json";
|
|
4617
|
-
function resolveWeCloneProxyConfigPath() {
|
|
4618
|
-
const override = readEnvVar("REMNIC_HOME") ?? readEnvVar("ENGRAM_HOME");
|
|
4619
|
-
if (override && override.length > 0) {
|
|
4620
|
-
return path13.resolve(override, "connectors", WECLONE_PROXY_CONFIG_FILENAME);
|
|
4621
|
-
}
|
|
4622
|
-
const envHome = readEnvVar("HOME");
|
|
4623
|
-
const home = envHome && envHome.length > 0 ? envHome : os.homedir();
|
|
4624
|
-
return path13.resolve(
|
|
4625
|
-
home,
|
|
4626
|
-
WECLONE_PROXY_CONFIG_DIRNAME,
|
|
4627
|
-
"connectors",
|
|
4628
|
-
WECLONE_PROXY_CONFIG_FILENAME
|
|
4629
|
-
);
|
|
4630
|
-
}
|
|
4631
|
-
function readWeCloneProxyConfigIfExists(configPath) {
|
|
4632
|
-
try {
|
|
4633
|
-
if (!fs9.existsSync(configPath)) return null;
|
|
4634
|
-
return fs9.readFileSync(configPath, "utf8");
|
|
4635
|
-
} catch {
|
|
4636
|
-
return null;
|
|
4637
|
-
}
|
|
4638
|
-
}
|
|
4639
|
-
function safeParseJson(raw) {
|
|
4640
|
-
try {
|
|
4641
|
-
const parsed = JSON.parse(raw);
|
|
4642
|
-
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
4643
|
-
return parsed;
|
|
4644
|
-
}
|
|
4645
|
-
return null;
|
|
4646
|
-
} catch {
|
|
4647
|
-
return null;
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
var WECLONE_DEFAULTS = {
|
|
4651
|
-
wecloneApiUrl: "http://localhost:8000/v1",
|
|
4652
|
-
wecloneModelName: "weclone-avatar",
|
|
4653
|
-
proxyPort: 8100,
|
|
4654
|
-
remnicDaemonUrl: "http://localhost:4318",
|
|
4655
|
-
sessionStrategy: "single",
|
|
4656
|
-
memoryInjection: {
|
|
4657
|
-
maxTokens: 1500,
|
|
4658
|
-
position: "system-append",
|
|
4659
|
-
template: "[Memory Context]\n{memories}\n[End Memory Context]"
|
|
4660
|
-
}
|
|
4661
|
-
};
|
|
4662
|
-
function resolveStringField(userConfig, priorConfig, key, fallback) {
|
|
4663
|
-
const fromUser = userConfig[key];
|
|
4664
|
-
if (typeof fromUser === "string" && fromUser.length > 0) return fromUser;
|
|
4665
|
-
if (priorConfig) {
|
|
4666
|
-
const fromPrior = priorConfig[key];
|
|
4667
|
-
if (typeof fromPrior === "string" && fromPrior.length > 0) return fromPrior;
|
|
4668
|
-
}
|
|
4669
|
-
return fallback;
|
|
4670
|
-
}
|
|
4671
|
-
function coercePort(value) {
|
|
4672
|
-
if (typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 65535) {
|
|
4673
|
-
return value;
|
|
4674
|
-
}
|
|
4675
|
-
if (typeof value === "string" && value.length > 0) {
|
|
4676
|
-
const n = Number(value);
|
|
4677
|
-
if (Number.isInteger(n) && n >= 1 && n <= 65535) return n;
|
|
4678
|
-
}
|
|
4679
|
-
return null;
|
|
4680
|
-
}
|
|
4681
|
-
function resolvePort(userConfig, priorConfig, fallback) {
|
|
4682
|
-
const fromUser = coercePort(userConfig.proxyPort);
|
|
4683
|
-
if (fromUser !== null) return fromUser;
|
|
4684
|
-
if (priorConfig) {
|
|
4685
|
-
const fromPrior = coercePort(priorConfig.proxyPort);
|
|
4686
|
-
if (fromPrior !== null) return fromPrior;
|
|
4687
|
-
}
|
|
4688
|
-
return fallback;
|
|
4689
|
-
}
|
|
4690
|
-
function resolveSessionStrategy(userConfig, priorConfig) {
|
|
4691
|
-
const valid = /* @__PURE__ */ new Set(["caller-id", "single"]);
|
|
4692
|
-
const fromUser = userConfig.sessionStrategy;
|
|
4693
|
-
if (typeof fromUser === "string" && valid.has(fromUser)) {
|
|
4694
|
-
return fromUser;
|
|
4695
|
-
}
|
|
4696
|
-
if (priorConfig) {
|
|
4697
|
-
const fromPrior = priorConfig.sessionStrategy;
|
|
4698
|
-
if (typeof fromPrior === "string" && valid.has(fromPrior)) {
|
|
4699
|
-
return fromPrior;
|
|
4700
|
-
}
|
|
4701
|
-
}
|
|
4702
|
-
return WECLONE_DEFAULTS.sessionStrategy;
|
|
4703
|
-
}
|
|
4704
|
-
function buildWeCloneProxyConfig(args) {
|
|
4705
|
-
const { userConfig, priorConfig, authToken } = args;
|
|
4706
|
-
const wecloneApiUrl = resolveStringField(
|
|
4707
|
-
userConfig,
|
|
4708
|
-
priorConfig,
|
|
4709
|
-
"wecloneApiUrl",
|
|
4710
|
-
WECLONE_DEFAULTS.wecloneApiUrl
|
|
4711
|
-
);
|
|
4712
|
-
const wecloneModelName = resolveStringField(
|
|
4713
|
-
userConfig,
|
|
4714
|
-
priorConfig,
|
|
4715
|
-
"wecloneModelName",
|
|
4716
|
-
WECLONE_DEFAULTS.wecloneModelName
|
|
4717
|
-
);
|
|
4718
|
-
const remnicDaemonUrl = resolveStringField(
|
|
4719
|
-
userConfig,
|
|
4720
|
-
priorConfig,
|
|
4721
|
-
"remnicDaemonUrl",
|
|
4722
|
-
WECLONE_DEFAULTS.remnicDaemonUrl
|
|
4723
|
-
);
|
|
4724
|
-
const proxyPort = resolvePort(
|
|
4725
|
-
userConfig,
|
|
4726
|
-
priorConfig,
|
|
4727
|
-
WECLONE_DEFAULTS.proxyPort
|
|
4728
|
-
);
|
|
4729
|
-
const sessionStrategy = resolveSessionStrategy(userConfig, priorConfig);
|
|
4730
|
-
const memoryInjection = {
|
|
4731
|
-
...WECLONE_DEFAULTS.memoryInjection,
|
|
4732
|
-
...priorConfig && typeof priorConfig.memoryInjection === "object" && priorConfig.memoryInjection !== null && !Array.isArray(priorConfig.memoryInjection) ? priorConfig.memoryInjection : {},
|
|
4733
|
-
...typeof userConfig.memoryInjection === "object" && userConfig.memoryInjection !== null && !Array.isArray(userConfig.memoryInjection) ? userConfig.memoryInjection : {}
|
|
4734
|
-
};
|
|
4735
|
-
const config = {
|
|
4736
|
-
wecloneApiUrl,
|
|
4737
|
-
wecloneModelName,
|
|
4738
|
-
proxyPort,
|
|
4739
|
-
remnicDaemonUrl,
|
|
4740
|
-
sessionStrategy,
|
|
4741
|
-
memoryInjection
|
|
4742
|
-
};
|
|
4743
|
-
if (authToken && authToken.length > 0) {
|
|
4744
|
-
config.remnicAuthToken = authToken;
|
|
4745
|
-
} else if (typeof userConfig.remnicAuthToken === "string" && userConfig.remnicAuthToken.length > 0) {
|
|
4746
|
-
config.remnicAuthToken = userConfig.remnicAuthToken;
|
|
4747
|
-
} else if (priorConfig && typeof priorConfig.remnicAuthToken === "string" && priorConfig.remnicAuthToken.length > 0) {
|
|
4748
|
-
config.remnicAuthToken = priorConfig.remnicAuthToken;
|
|
4749
|
-
}
|
|
4750
|
-
return config;
|
|
4751
|
-
}
|
|
4752
|
-
|
|
4753
|
-
// src/spaces/index.ts
|
|
4754
|
-
import fs10 from "fs";
|
|
4755
|
-
import path14 from "path";
|
|
4756
|
-
import crypto6 from "crypto";
|
|
4757
|
-
var MANIFEST_VERSION = 1;
|
|
4758
|
-
function getSpacesDir(baseDir) {
|
|
4759
|
-
const homeDir = baseDir ?? resolveHomeDir();
|
|
4760
|
-
return path14.join(homeDir, ".config", "engram", "spaces");
|
|
4761
|
-
}
|
|
4762
|
-
function getManifestPath(baseDir) {
|
|
4763
|
-
return path14.join(getSpacesDir(baseDir), "manifest.json");
|
|
4764
|
-
}
|
|
4765
|
-
function loadManifest(baseDir, memoryDirOverride) {
|
|
4766
|
-
const manifestPath2 = getManifestPath(baseDir);
|
|
4767
|
-
if (!fs10.existsSync(manifestPath2)) {
|
|
4768
|
-
const personalSpace = createPersonalSpace(baseDir, memoryDirOverride);
|
|
4769
|
-
const manifest = {
|
|
4770
|
-
activeSpaceId: personalSpace.id,
|
|
4771
|
-
spaces: [personalSpace],
|
|
4772
|
-
version: MANIFEST_VERSION
|
|
4773
|
-
};
|
|
4774
|
-
saveManifest(manifest, baseDir);
|
|
4775
|
-
return manifest;
|
|
4776
|
-
}
|
|
4777
|
-
const raw = JSON.parse(fs10.readFileSync(manifestPath2, "utf8"));
|
|
4778
|
-
return raw;
|
|
4779
|
-
}
|
|
4780
|
-
function saveManifest(manifest, baseDir) {
|
|
4781
|
-
const manifestPath2 = getManifestPath(baseDir);
|
|
4782
|
-
fs10.mkdirSync(path14.dirname(manifestPath2), { recursive: true });
|
|
4783
|
-
fs10.writeFileSync(manifestPath2, JSON.stringify(manifest, null, 2) + "\n");
|
|
4784
|
-
}
|
|
4785
|
-
function createPersonalSpace(baseDir, memoryDirOverride) {
|
|
4786
|
-
const homeDir = baseDir ?? resolveHomeDir();
|
|
4787
|
-
const standalonePath = path14.join(homeDir, ".engram", "memory");
|
|
4788
|
-
const openclawPath = path14.join(homeDir, ".openclaw", "workspace", "memory", "local");
|
|
4789
|
-
const memoryDir = memoryDirOverride ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs10.existsSync(standalonePath) ? standalonePath : fs10.existsSync(openclawPath) ? openclawPath : standalonePath);
|
|
4790
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4791
|
-
return {
|
|
4792
|
-
id: "personal",
|
|
4793
|
-
name: "Personal",
|
|
4794
|
-
kind: "personal",
|
|
4795
|
-
description: "Default personal memory space",
|
|
4796
|
-
memoryDir,
|
|
4797
|
-
createdAt: now,
|
|
4798
|
-
updatedAt: now,
|
|
4799
|
-
owner: readEnvVar("USER")
|
|
4800
|
-
};
|
|
4801
|
-
}
|
|
4802
|
-
function listSpaces(baseDir) {
|
|
4803
|
-
const manifest = loadManifest(baseDir);
|
|
4804
|
-
return manifest.spaces;
|
|
4805
|
-
}
|
|
4806
|
-
function getActiveSpace(baseDir) {
|
|
4807
|
-
const manifest = loadManifest(baseDir);
|
|
4808
|
-
const space = manifest.spaces.find((s) => s.id === manifest.activeSpaceId);
|
|
4809
|
-
if (!space) throw new Error(`Active space ${manifest.activeSpaceId} not found`);
|
|
4810
|
-
return space;
|
|
4811
|
-
}
|
|
4812
|
-
function createSpace(options) {
|
|
4813
|
-
const manifest = loadManifest(options.baseDir);
|
|
4814
|
-
const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
|
|
4815
|
-
if (manifest.spaces.some((s) => s.id === id)) {
|
|
4816
|
-
throw new Error(`Space "${id}" already exists`);
|
|
4817
|
-
}
|
|
4818
|
-
if (options.parentSpaceId && !manifest.spaces.some((s) => s.id === options.parentSpaceId)) {
|
|
4819
|
-
throw new Error(`Parent space "${options.parentSpaceId}" not found`);
|
|
4820
|
-
}
|
|
4821
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4822
|
-
const memoryDir = options.memoryDir ?? path14.join(
|
|
4823
|
-
getSpacesDir(options.baseDir),
|
|
4824
|
-
id,
|
|
4825
|
-
"memory"
|
|
4826
|
-
);
|
|
4827
|
-
const space = {
|
|
4828
|
-
id,
|
|
4829
|
-
name: options.name,
|
|
4830
|
-
kind: options.kind,
|
|
4831
|
-
description: options.description,
|
|
4832
|
-
memoryDir,
|
|
4833
|
-
createdAt: now,
|
|
4834
|
-
updatedAt: now,
|
|
4835
|
-
owner: readEnvVar("USER"),
|
|
4836
|
-
parentSpaceId: options.parentSpaceId
|
|
4837
|
-
};
|
|
4838
|
-
fs10.mkdirSync(memoryDir, { recursive: true });
|
|
4839
|
-
manifest.spaces.push(space);
|
|
4840
|
-
manifest.updatedAt = now;
|
|
4841
|
-
saveManifest(manifest, options.baseDir);
|
|
4842
|
-
appendAudit({
|
|
4843
|
-
action: "space.create",
|
|
4844
|
-
sourceSpaceId: id,
|
|
4845
|
-
details: `Created ${options.kind} space "${options.name}"`
|
|
4846
|
-
}, options.baseDir);
|
|
4847
|
-
return space;
|
|
2942
|
+
const space = {
|
|
2943
|
+
id,
|
|
2944
|
+
name: options.name,
|
|
2945
|
+
kind: options.kind,
|
|
2946
|
+
description: options.description,
|
|
2947
|
+
memoryDir,
|
|
2948
|
+
createdAt: now,
|
|
2949
|
+
updatedAt: now,
|
|
2950
|
+
owner: readEnvVar("USER"),
|
|
2951
|
+
parentSpaceId: options.parentSpaceId
|
|
2952
|
+
};
|
|
2953
|
+
fs8.mkdirSync(memoryDir, { recursive: true });
|
|
2954
|
+
manifest.spaces.push(space);
|
|
2955
|
+
manifest.updatedAt = now;
|
|
2956
|
+
saveManifest(manifest, options.baseDir);
|
|
2957
|
+
appendAudit({
|
|
2958
|
+
action: "space.create",
|
|
2959
|
+
sourceSpaceId: id,
|
|
2960
|
+
details: `Created ${options.kind} space "${options.name}"`
|
|
2961
|
+
}, options.baseDir);
|
|
2962
|
+
return space;
|
|
4848
2963
|
}
|
|
4849
2964
|
function deleteSpace(spaceId, baseDir) {
|
|
4850
2965
|
const manifest = loadManifest(baseDir);
|
|
@@ -5009,34 +3124,34 @@ function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
|
|
|
5009
3124
|
};
|
|
5010
3125
|
}
|
|
5011
3126
|
function getAuditLog(baseDir) {
|
|
5012
|
-
const auditPath =
|
|
5013
|
-
if (!
|
|
5014
|
-
const lines =
|
|
3127
|
+
const auditPath = path12.join(getSpacesDir(baseDir), "audit.jsonl");
|
|
3128
|
+
if (!fs8.existsSync(auditPath)) return [];
|
|
3129
|
+
const lines = fs8.readFileSync(auditPath, "utf8").trim().split("\n");
|
|
5015
3130
|
return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
|
|
5016
3131
|
}
|
|
5017
3132
|
function appendAudit(entry, baseDir) {
|
|
5018
|
-
const auditPath =
|
|
5019
|
-
|
|
3133
|
+
const auditPath = path12.join(getSpacesDir(baseDir), "audit.jsonl");
|
|
3134
|
+
fs8.mkdirSync(path12.dirname(auditPath), { recursive: true });
|
|
5020
3135
|
const full = {
|
|
5021
3136
|
id: crypto6.randomUUID(),
|
|
5022
3137
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5023
3138
|
...entry
|
|
5024
3139
|
};
|
|
5025
|
-
|
|
3140
|
+
fs8.appendFileSync(auditPath, JSON.stringify(full) + "\n");
|
|
5026
3141
|
}
|
|
5027
3142
|
function copyMemories(sourceDir, targetDir, options) {
|
|
5028
3143
|
let merged = 0;
|
|
5029
3144
|
const conflicts = [];
|
|
5030
3145
|
let skipped = 0;
|
|
5031
|
-
if (!
|
|
3146
|
+
if (!fs8.existsSync(sourceDir)) {
|
|
5032
3147
|
return { merged: 0, conflicts: [], skipped: 0 };
|
|
5033
3148
|
}
|
|
5034
|
-
|
|
3149
|
+
fs8.mkdirSync(targetDir, { recursive: true });
|
|
5035
3150
|
const sourceFiles = walkMd2(sourceDir);
|
|
5036
3151
|
for (const sourcePath of sourceFiles) {
|
|
5037
|
-
const content =
|
|
5038
|
-
const relativePath =
|
|
5039
|
-
const targetPath =
|
|
3152
|
+
const content = fs8.readFileSync(sourcePath, "utf8");
|
|
3153
|
+
const relativePath = path12.relative(sourceDir, sourcePath);
|
|
3154
|
+
const targetPath = path12.join(targetDir, relativePath);
|
|
5040
3155
|
const sourceHash = hashContent4(content);
|
|
5041
3156
|
if (options?.filterIds?.length) {
|
|
5042
3157
|
const fm = parseSimpleFrontmatter(content);
|
|
@@ -5045,8 +3160,8 @@ function copyMemories(sourceDir, targetDir, options) {
|
|
|
5045
3160
|
continue;
|
|
5046
3161
|
}
|
|
5047
3162
|
}
|
|
5048
|
-
if (
|
|
5049
|
-
const targetContent =
|
|
3163
|
+
if (fs8.existsSync(targetPath) && !options?.force) {
|
|
3164
|
+
const targetContent = fs8.readFileSync(targetPath, "utf8");
|
|
5050
3165
|
const targetHash = hashContent4(targetContent);
|
|
5051
3166
|
if (sourceHash !== targetHash) {
|
|
5052
3167
|
conflicts.push({
|
|
@@ -5062,8 +3177,8 @@ function copyMemories(sourceDir, targetDir, options) {
|
|
|
5062
3177
|
skipped++;
|
|
5063
3178
|
continue;
|
|
5064
3179
|
}
|
|
5065
|
-
|
|
5066
|
-
|
|
3180
|
+
fs8.mkdirSync(path12.dirname(targetPath), { recursive: true });
|
|
3181
|
+
fs8.writeFileSync(targetPath, content);
|
|
5067
3182
|
merged++;
|
|
5068
3183
|
}
|
|
5069
3184
|
return { merged, conflicts, skipped };
|
|
@@ -5074,8 +3189,8 @@ function hashContent4(content) {
|
|
|
5074
3189
|
function walkMd2(dir) {
|
|
5075
3190
|
const results = [];
|
|
5076
3191
|
function walk(d) {
|
|
5077
|
-
for (const entry of
|
|
5078
|
-
const fullPath =
|
|
3192
|
+
for (const entry of fs8.readdirSync(d, { withFileTypes: true })) {
|
|
3193
|
+
const fullPath = path12.join(d, entry.name);
|
|
5079
3194
|
if (entry.isDirectory()) {
|
|
5080
3195
|
walk(fullPath);
|
|
5081
3196
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -5203,10 +3318,10 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
|
|
|
5203
3318
|
`;
|
|
5204
3319
|
|
|
5205
3320
|
// src/memory-extension/codex-publisher.ts
|
|
5206
|
-
import
|
|
5207
|
-
import
|
|
5208
|
-
import
|
|
5209
|
-
var
|
|
3321
|
+
import fs9 from "fs";
|
|
3322
|
+
import os from "os";
|
|
3323
|
+
import path13 from "path";
|
|
3324
|
+
var REMNIC_EXTENSION_DIR_NAME = "remnic";
|
|
5210
3325
|
var CodexMemoryExtensionPublisher = class {
|
|
5211
3326
|
hostId = "codex";
|
|
5212
3327
|
static capabilities = {
|
|
@@ -5216,13 +3331,13 @@ var CodexMemoryExtensionPublisher = class {
|
|
|
5216
3331
|
readPathTemplate: true
|
|
5217
3332
|
};
|
|
5218
3333
|
async resolveExtensionRoot(env) {
|
|
5219
|
-
const codexHome = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() ||
|
|
5220
|
-
return
|
|
3334
|
+
const codexHome = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() || path13.join(resolveHomeDir(), ".codex") : env.CODEX_HOME?.trim() || path13.join(env.HOME ?? env.USERPROFILE ?? os.homedir(), ".codex");
|
|
3335
|
+
return path13.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
|
|
5221
3336
|
}
|
|
5222
3337
|
async isHostAvailable() {
|
|
5223
3338
|
try {
|
|
5224
|
-
const home = readEnvVar("CODEX_HOME")?.trim() ||
|
|
5225
|
-
return
|
|
3339
|
+
const home = readEnvVar("CODEX_HOME")?.trim() || path13.join(resolveHomeDir(), ".codex");
|
|
3340
|
+
return fs9.existsSync(home);
|
|
5226
3341
|
} catch {
|
|
5227
3342
|
return false;
|
|
5228
3343
|
}
|
|
@@ -5272,22 +3387,22 @@ When running inside the Codex phase-2 consolidation sandbox:
|
|
|
5272
3387
|
}
|
|
5273
3388
|
async publish(ctx) {
|
|
5274
3389
|
const extensionRoot = await this.resolveExtensionRoot();
|
|
5275
|
-
const instructionsPath =
|
|
3390
|
+
const instructionsPath = path13.join(extensionRoot, "instructions.md");
|
|
5276
3391
|
const filesWritten = [];
|
|
5277
3392
|
const skipped = [];
|
|
5278
3393
|
ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
|
|
5279
|
-
|
|
3394
|
+
fs9.mkdirSync(extensionRoot, { recursive: true });
|
|
5280
3395
|
const content = await this.renderInstructions(ctx);
|
|
5281
3396
|
const tmpPath = `${instructionsPath}.tmp-${process.pid}-${Date.now()}`;
|
|
5282
3397
|
try {
|
|
5283
|
-
|
|
5284
|
-
|
|
3398
|
+
fs9.writeFileSync(tmpPath, content, "utf-8");
|
|
3399
|
+
fs9.renameSync(tmpPath, instructionsPath);
|
|
5285
3400
|
filesWritten.push(instructionsPath);
|
|
5286
3401
|
ctx.log.info(`Wrote ${instructionsPath}`);
|
|
5287
3402
|
} catch (err) {
|
|
5288
3403
|
try {
|
|
5289
|
-
if (
|
|
5290
|
-
|
|
3404
|
+
if (fs9.existsSync(tmpPath)) {
|
|
3405
|
+
fs9.unlinkSync(tmpPath);
|
|
5291
3406
|
}
|
|
5292
3407
|
} catch {
|
|
5293
3408
|
}
|
|
@@ -5302,8 +3417,8 @@ When running inside the Codex phase-2 consolidation sandbox:
|
|
|
5302
3417
|
}
|
|
5303
3418
|
async unpublish() {
|
|
5304
3419
|
const extensionRoot = await this.resolveExtensionRoot();
|
|
5305
|
-
if (
|
|
5306
|
-
|
|
3420
|
+
if (fs9.existsSync(extensionRoot)) {
|
|
3421
|
+
fs9.rmSync(extensionRoot, { recursive: true, force: true });
|
|
5307
3422
|
}
|
|
5308
3423
|
}
|
|
5309
3424
|
};
|
|
@@ -5387,264 +3502,6 @@ function publisherForConnector(connectorId) {
|
|
|
5387
3502
|
return publisherFor(hostIdForConnector(connectorId));
|
|
5388
3503
|
}
|
|
5389
3504
|
|
|
5390
|
-
// src/enrichment/types.ts
|
|
5391
|
-
function defaultEnrichmentPipelineConfig() {
|
|
5392
|
-
return {
|
|
5393
|
-
enabled: false,
|
|
5394
|
-
providers: [],
|
|
5395
|
-
importanceThresholds: {
|
|
5396
|
-
critical: [],
|
|
5397
|
-
high: [],
|
|
5398
|
-
normal: [],
|
|
5399
|
-
low: []
|
|
5400
|
-
},
|
|
5401
|
-
maxCandidatesPerEntity: 20,
|
|
5402
|
-
autoEnrichOnCreate: false,
|
|
5403
|
-
scheduleIntervalMs: 36e5
|
|
5404
|
-
};
|
|
5405
|
-
}
|
|
5406
|
-
|
|
5407
|
-
// src/enrichment/provider-registry.ts
|
|
5408
|
-
var EnrichmentProviderRegistry = class {
|
|
5409
|
-
providers = /* @__PURE__ */ new Map();
|
|
5410
|
-
/** Register a provider. Overwrites any existing provider with the same id. */
|
|
5411
|
-
register(provider) {
|
|
5412
|
-
this.providers.set(provider.id, provider);
|
|
5413
|
-
}
|
|
5414
|
-
/** Look up a single provider by id. */
|
|
5415
|
-
get(id) {
|
|
5416
|
-
return this.providers.get(id);
|
|
5417
|
-
}
|
|
5418
|
-
/**
|
|
5419
|
-
* Return all registered providers whose id appears in the config's
|
|
5420
|
-
* `providers` list with `enabled: true`.
|
|
5421
|
-
*/
|
|
5422
|
-
listEnabled(config) {
|
|
5423
|
-
const enabledIds = new Set(
|
|
5424
|
-
config.providers.filter((p) => p.enabled).map((p) => p.id)
|
|
5425
|
-
);
|
|
5426
|
-
const result = [];
|
|
5427
|
-
for (const [id, provider] of this.providers.entries()) {
|
|
5428
|
-
if (enabledIds.has(id)) {
|
|
5429
|
-
result.push(provider);
|
|
5430
|
-
}
|
|
5431
|
-
}
|
|
5432
|
-
return result;
|
|
5433
|
-
}
|
|
5434
|
-
/**
|
|
5435
|
-
* Return providers that should run for a given importance level.
|
|
5436
|
-
* Providers are resolved from `config.importanceThresholds[level]` and
|
|
5437
|
-
* filtered to only those that are both registered and enabled.
|
|
5438
|
-
*/
|
|
5439
|
-
getForImportance(level, config) {
|
|
5440
|
-
if (level === "trivial") return [];
|
|
5441
|
-
const thresholds = config.importanceThresholds;
|
|
5442
|
-
const providerIds = level === "critical" ? thresholds.critical : level === "high" ? thresholds.high : level === "normal" ? thresholds.normal : thresholds.low;
|
|
5443
|
-
const enabledIds = new Set(
|
|
5444
|
-
config.providers.filter((p) => p.enabled).map((p) => p.id)
|
|
5445
|
-
);
|
|
5446
|
-
const result = [];
|
|
5447
|
-
for (const id of providerIds) {
|
|
5448
|
-
if (!enabledIds.has(id)) continue;
|
|
5449
|
-
const provider = this.providers.get(id);
|
|
5450
|
-
if (provider) {
|
|
5451
|
-
result.push(provider);
|
|
5452
|
-
}
|
|
5453
|
-
}
|
|
5454
|
-
return result;
|
|
5455
|
-
}
|
|
5456
|
-
};
|
|
5457
|
-
|
|
5458
|
-
// src/enrichment/web-search-provider.ts
|
|
5459
|
-
var WebSearchProvider = class {
|
|
5460
|
-
id = "web-search";
|
|
5461
|
-
costTier = "cheap";
|
|
5462
|
-
searchFn;
|
|
5463
|
-
constructor(options = {}) {
|
|
5464
|
-
this.searchFn = options.searchFn;
|
|
5465
|
-
}
|
|
5466
|
-
async isAvailable() {
|
|
5467
|
-
return this.searchFn !== void 0;
|
|
5468
|
-
}
|
|
5469
|
-
async enrich(entity) {
|
|
5470
|
-
if (!this.searchFn) return [];
|
|
5471
|
-
const query = `${entity.name} ${entity.type}`;
|
|
5472
|
-
let snippets;
|
|
5473
|
-
try {
|
|
5474
|
-
snippets = await this.searchFn(query);
|
|
5475
|
-
} catch {
|
|
5476
|
-
return [];
|
|
5477
|
-
}
|
|
5478
|
-
return snippets.filter((s) => typeof s === "string" && s.trim().length > 0).map((snippet) => ({
|
|
5479
|
-
text: snippet.trim(),
|
|
5480
|
-
source: this.id,
|
|
5481
|
-
sourceUrl: void 0,
|
|
5482
|
-
confidence: 0.5,
|
|
5483
|
-
category: "fact",
|
|
5484
|
-
tags: ["web-search"]
|
|
5485
|
-
}));
|
|
5486
|
-
}
|
|
5487
|
-
};
|
|
5488
|
-
|
|
5489
|
-
// src/enrichment/pipeline.ts
|
|
5490
|
-
function isRateLimited(provider, config, buckets) {
|
|
5491
|
-
const providerCfg = config.providers.find((p) => p.id === provider.id);
|
|
5492
|
-
if (!providerCfg?.rateLimit) return false;
|
|
5493
|
-
const now = Date.now();
|
|
5494
|
-
let bucket = buckets.get(provider.id);
|
|
5495
|
-
if (!bucket) {
|
|
5496
|
-
bucket = {
|
|
5497
|
-
minuteCount: 0,
|
|
5498
|
-
minuteReset: now + 6e4,
|
|
5499
|
-
dayCount: 0,
|
|
5500
|
-
dayReset: now + 864e5
|
|
5501
|
-
};
|
|
5502
|
-
buckets.set(provider.id, bucket);
|
|
5503
|
-
}
|
|
5504
|
-
if (now >= bucket.minuteReset) {
|
|
5505
|
-
bucket.minuteCount = 0;
|
|
5506
|
-
bucket.minuteReset = now + 6e4;
|
|
5507
|
-
}
|
|
5508
|
-
if (now >= bucket.dayReset) {
|
|
5509
|
-
bucket.dayCount = 0;
|
|
5510
|
-
bucket.dayReset = now + 864e5;
|
|
5511
|
-
}
|
|
5512
|
-
const { maxPerMinute, maxPerDay } = providerCfg.rateLimit;
|
|
5513
|
-
return bucket.minuteCount >= maxPerMinute || bucket.dayCount >= maxPerDay;
|
|
5514
|
-
}
|
|
5515
|
-
function recordCall(providerId, buckets) {
|
|
5516
|
-
const bucket = buckets.get(providerId);
|
|
5517
|
-
if (bucket) {
|
|
5518
|
-
bucket.minuteCount += 1;
|
|
5519
|
-
bucket.dayCount += 1;
|
|
5520
|
-
}
|
|
5521
|
-
}
|
|
5522
|
-
async function runEnrichmentPipeline(entities, registry, config, log2) {
|
|
5523
|
-
if (!config.enabled) return [];
|
|
5524
|
-
if (entities.length === 0) return [];
|
|
5525
|
-
const rateBuckets = /* @__PURE__ */ new Map();
|
|
5526
|
-
const results = [];
|
|
5527
|
-
for (const entity of entities) {
|
|
5528
|
-
const providers = registry.getForImportance(entity.importanceLevel, config);
|
|
5529
|
-
for (const provider of providers) {
|
|
5530
|
-
const start = Date.now();
|
|
5531
|
-
let available;
|
|
5532
|
-
try {
|
|
5533
|
-
available = await provider.isAvailable();
|
|
5534
|
-
} catch {
|
|
5535
|
-
available = false;
|
|
5536
|
-
}
|
|
5537
|
-
if (!available) {
|
|
5538
|
-
log2.debug?.(
|
|
5539
|
-
`enrichment: skipping provider ${provider.id} for ${entity.name} \u2014 unavailable`
|
|
5540
|
-
);
|
|
5541
|
-
results.push({
|
|
5542
|
-
entityName: entity.name,
|
|
5543
|
-
provider: provider.id,
|
|
5544
|
-
candidatesFound: 0,
|
|
5545
|
-
candidatesAccepted: 0,
|
|
5546
|
-
candidatesRejected: 0,
|
|
5547
|
-
acceptedCandidates: [],
|
|
5548
|
-
elapsed: Date.now() - start
|
|
5549
|
-
});
|
|
5550
|
-
continue;
|
|
5551
|
-
}
|
|
5552
|
-
if (isRateLimited(provider, config, rateBuckets)) {
|
|
5553
|
-
log2.debug?.(
|
|
5554
|
-
`enrichment: skipping provider ${provider.id} for ${entity.name} \u2014 rate limited`
|
|
5555
|
-
);
|
|
5556
|
-
results.push({
|
|
5557
|
-
entityName: entity.name,
|
|
5558
|
-
provider: provider.id,
|
|
5559
|
-
candidatesFound: 0,
|
|
5560
|
-
candidatesAccepted: 0,
|
|
5561
|
-
candidatesRejected: 0,
|
|
5562
|
-
acceptedCandidates: [],
|
|
5563
|
-
elapsed: Date.now() - start
|
|
5564
|
-
});
|
|
5565
|
-
continue;
|
|
5566
|
-
}
|
|
5567
|
-
let candidates;
|
|
5568
|
-
try {
|
|
5569
|
-
candidates = await provider.enrich(entity);
|
|
5570
|
-
} catch (err) {
|
|
5571
|
-
recordCall(provider.id, rateBuckets);
|
|
5572
|
-
log2.error?.(
|
|
5573
|
-
`enrichment: provider ${provider.id} failed for ${entity.name}: ${err instanceof Error ? err.message : String(err)}`
|
|
5574
|
-
);
|
|
5575
|
-
results.push({
|
|
5576
|
-
entityName: entity.name,
|
|
5577
|
-
provider: provider.id,
|
|
5578
|
-
candidatesFound: 0,
|
|
5579
|
-
candidatesAccepted: 0,
|
|
5580
|
-
candidatesRejected: 0,
|
|
5581
|
-
acceptedCandidates: [],
|
|
5582
|
-
elapsed: Date.now() - start
|
|
5583
|
-
});
|
|
5584
|
-
continue;
|
|
5585
|
-
}
|
|
5586
|
-
recordCall(provider.id, rateBuckets);
|
|
5587
|
-
for (const candidate of candidates) {
|
|
5588
|
-
candidate.source = provider.id;
|
|
5589
|
-
}
|
|
5590
|
-
const maxCandidates = config.maxCandidatesPerEntity;
|
|
5591
|
-
let accepted;
|
|
5592
|
-
if (maxCandidates === 0) {
|
|
5593
|
-
accepted = [];
|
|
5594
|
-
} else if (maxCandidates > 0 && candidates.length > maxCandidates) {
|
|
5595
|
-
accepted = candidates.slice(0, maxCandidates);
|
|
5596
|
-
} else {
|
|
5597
|
-
accepted = candidates;
|
|
5598
|
-
}
|
|
5599
|
-
const rejected = candidates.length - accepted.length;
|
|
5600
|
-
results.push({
|
|
5601
|
-
entityName: entity.name,
|
|
5602
|
-
provider: provider.id,
|
|
5603
|
-
candidatesFound: candidates.length,
|
|
5604
|
-
candidatesAccepted: accepted.length,
|
|
5605
|
-
candidatesRejected: rejected,
|
|
5606
|
-
acceptedCandidates: accepted,
|
|
5607
|
-
elapsed: Date.now() - start
|
|
5608
|
-
});
|
|
5609
|
-
}
|
|
5610
|
-
}
|
|
5611
|
-
return results;
|
|
5612
|
-
}
|
|
5613
|
-
|
|
5614
|
-
// src/enrichment/audit.ts
|
|
5615
|
-
import { mkdir, readFile, appendFile } from "fs/promises";
|
|
5616
|
-
import { existsSync } from "fs";
|
|
5617
|
-
import path16 from "path";
|
|
5618
|
-
var AUDIT_FILENAME = "enrichment-audit.jsonl";
|
|
5619
|
-
function auditFilePath(auditDir) {
|
|
5620
|
-
return path16.join(auditDir, AUDIT_FILENAME);
|
|
5621
|
-
}
|
|
5622
|
-
async function appendAuditEntry(auditDir, entry) {
|
|
5623
|
-
await mkdir(auditDir, { recursive: true });
|
|
5624
|
-
const line = JSON.stringify(entry) + "\n";
|
|
5625
|
-
await appendFile(auditFilePath(auditDir), line, "utf-8");
|
|
5626
|
-
}
|
|
5627
|
-
async function readAuditLog(auditDir, since) {
|
|
5628
|
-
const filePath = auditFilePath(auditDir);
|
|
5629
|
-
if (!existsSync(filePath)) return [];
|
|
5630
|
-
const raw = await readFile(filePath, "utf-8");
|
|
5631
|
-
const entries = [];
|
|
5632
|
-
for (const line of raw.split("\n")) {
|
|
5633
|
-
const trimmed = line.trim();
|
|
5634
|
-
if (trimmed.length === 0) continue;
|
|
5635
|
-
try {
|
|
5636
|
-
const parsed = JSON.parse(trimmed);
|
|
5637
|
-
if (typeof parsed === "object" && parsed !== null && "timestamp" in parsed && "entityName" in parsed) {
|
|
5638
|
-
const entry = parsed;
|
|
5639
|
-
if (since && entry.timestamp < since) continue;
|
|
5640
|
-
entries.push(entry);
|
|
5641
|
-
}
|
|
5642
|
-
} catch {
|
|
5643
|
-
}
|
|
5644
|
-
}
|
|
5645
|
-
return entries;
|
|
5646
|
-
}
|
|
5647
|
-
|
|
5648
3505
|
// src/importers/base.ts
|
|
5649
3506
|
var DEFAULT_IMPORT_BATCH_SIZE = 25;
|
|
5650
3507
|
var MIN_IMPORT_BATCH_SIZE = 1;
|
|
@@ -5766,20 +3623,20 @@ async function defaultWriteMemoriesToOrchestrator(target, memories) {
|
|
|
5766
3623
|
}
|
|
5767
3624
|
|
|
5768
3625
|
// src/transfer/capsule-fork.ts
|
|
5769
|
-
import { lstat, mkdir
|
|
5770
|
-
import
|
|
3626
|
+
import { lstat, mkdir, readFile, realpath, writeFile } from "fs/promises";
|
|
3627
|
+
import path14 from "path";
|
|
5771
3628
|
async function forkCapsule(opts) {
|
|
5772
3629
|
validateForkId(opts.forkId);
|
|
5773
|
-
const rootAbs =
|
|
3630
|
+
const rootAbs = path14.resolve(opts.targetRoot);
|
|
5774
3631
|
await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
|
|
5775
|
-
const forkDirAbs =
|
|
3632
|
+
const forkDirAbs = path14.join(rootAbs, "forks", opts.forkId);
|
|
5776
3633
|
const forkEntryExists = await pathEntryExists(forkDirAbs);
|
|
5777
3634
|
if (forkEntryExists) {
|
|
5778
3635
|
throw new Error(
|
|
5779
3636
|
`forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
|
|
5780
3637
|
);
|
|
5781
3638
|
}
|
|
5782
|
-
const archiveAbs =
|
|
3639
|
+
const archiveAbs = path14.resolve(opts.sourceArchive);
|
|
5783
3640
|
const importResult = await importCapsule({
|
|
5784
3641
|
archivePath: archiveAbs,
|
|
5785
3642
|
root: rootAbs,
|
|
@@ -5801,10 +3658,10 @@ async function forkCapsule(opts) {
|
|
|
5801
3658
|
importedRecords: importResult.imported.length,
|
|
5802
3659
|
skippedRecords: importResult.skipped.length
|
|
5803
3660
|
};
|
|
5804
|
-
const lineagePath =
|
|
3661
|
+
const lineagePath = path14.join(forkDirAbs, "lineage.json");
|
|
5805
3662
|
const rootReal = await realpath(rootAbs);
|
|
5806
3663
|
await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
|
|
5807
|
-
await
|
|
3664
|
+
await mkdir(path14.dirname(lineagePath), { recursive: true });
|
|
5808
3665
|
await writeFile(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
|
|
5809
3666
|
return {
|
|
5810
3667
|
archivePath: archiveAbs,
|
|
@@ -5818,17 +3675,17 @@ async function readForkLineage(targetRoot, forkId) {
|
|
|
5818
3675
|
if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
|
|
5819
3676
|
return null;
|
|
5820
3677
|
}
|
|
5821
|
-
const rootAbs =
|
|
3678
|
+
const rootAbs = path14.resolve(targetRoot);
|
|
5822
3679
|
const rootReal = await realpath(rootAbs).catch(() => rootAbs);
|
|
5823
|
-
const lineagePath =
|
|
5824
|
-
const rel =
|
|
5825
|
-
if (rel.startsWith("..") ||
|
|
3680
|
+
const lineagePath = path14.join(rootReal, "forks", forkId, "lineage.json");
|
|
3681
|
+
const rel = path14.relative(rootReal, lineagePath);
|
|
3682
|
+
if (rel.startsWith("..") || path14.isAbsolute(rel)) {
|
|
5826
3683
|
return null;
|
|
5827
3684
|
}
|
|
5828
3685
|
if (!await isLineagePathContained(rootReal, lineagePath)) {
|
|
5829
3686
|
return null;
|
|
5830
3687
|
}
|
|
5831
|
-
const raw = await
|
|
3688
|
+
const raw = await readFile(lineagePath, "utf-8").catch(() => null);
|
|
5832
3689
|
if (raw === null) return null;
|
|
5833
3690
|
try {
|
|
5834
3691
|
const parsed = JSON.parse(raw);
|
|
@@ -5863,19 +3720,19 @@ async function pathEntryExists(absPath) {
|
|
|
5863
3720
|
async function isLineagePathContained(rootReal, lineagePath) {
|
|
5864
3721
|
let existing = lineagePath;
|
|
5865
3722
|
const suffix = [];
|
|
5866
|
-
while (existing !==
|
|
3723
|
+
while (existing !== path14.dirname(existing)) {
|
|
5867
3724
|
const st = await lstat(existing).catch(() => null);
|
|
5868
3725
|
if (st !== null) break;
|
|
5869
|
-
suffix.unshift(
|
|
5870
|
-
existing =
|
|
3726
|
+
suffix.unshift(path14.basename(existing));
|
|
3727
|
+
existing = path14.dirname(existing);
|
|
5871
3728
|
}
|
|
5872
3729
|
const existingReal = await realpath(existing).catch(() => existing);
|
|
5873
|
-
const targetReal = suffix.length > 0 ?
|
|
5874
|
-
const rel =
|
|
3730
|
+
const targetReal = suffix.length > 0 ? path14.join(existingReal, ...suffix) : existingReal;
|
|
3731
|
+
const rel = path14.relative(rootReal, targetReal);
|
|
5875
3732
|
if (rel === "") return true;
|
|
5876
3733
|
if (rel === "..") return false;
|
|
5877
|
-
if (rel.startsWith(`..${
|
|
5878
|
-
if (
|
|
3734
|
+
if (rel.startsWith(`..${path14.sep}`)) return false;
|
|
3735
|
+
if (path14.isAbsolute(rel)) return false;
|
|
5879
3736
|
return true;
|
|
5880
3737
|
}
|
|
5881
3738
|
export {
|
|
@@ -5883,6 +3740,7 @@ export {
|
|
|
5883
3740
|
ACTION_CONFIDENCE_DECISIONS,
|
|
5884
3741
|
ACTION_CONFIDENCE_RISK_CATEGORIES,
|
|
5885
3742
|
ACTION_CONFIDENCE_RULE_KINDS,
|
|
3743
|
+
ACTIVE_STATUSES,
|
|
5886
3744
|
AccessAuditAdapter,
|
|
5887
3745
|
BRIEFING_FORMAT_ALLOWED,
|
|
5888
3746
|
BootstrapEngine,
|
|
@@ -5929,6 +3787,7 @@ export {
|
|
|
5929
3787
|
MARKETPLACE_SCHEMA_VERSION,
|
|
5930
3788
|
MATERIALIZE_VERSION,
|
|
5931
3789
|
MeilisearchBackend,
|
|
3790
|
+
ModelRegistry,
|
|
5932
3791
|
NOTION_CONNECTOR_ID,
|
|
5933
3792
|
NOTION_CURSOR_KIND,
|
|
5934
3793
|
NOTION_DEFAULT_POLL_INTERVAL_MS,
|
|
@@ -6005,6 +3864,7 @@ export {
|
|
|
6005
3864
|
collectStructuredPlanCues,
|
|
6006
3865
|
collectTemporalLexicalCues,
|
|
6007
3866
|
computeMemoryWorth,
|
|
3867
|
+
computePairId,
|
|
6008
3868
|
computeProcedureStats,
|
|
6009
3869
|
computeSurprise,
|
|
6010
3870
|
computeTierValueScore,
|
|
@@ -6034,6 +3894,7 @@ export {
|
|
|
6034
3894
|
ensureLcmStateDir,
|
|
6035
3895
|
ensureSentinel,
|
|
6036
3896
|
evaluateActionConfidence,
|
|
3897
|
+
executeResolution,
|
|
6037
3898
|
expandTildePath,
|
|
6038
3899
|
extractGraphEdges,
|
|
6039
3900
|
facetHasBoundary,
|
|
@@ -6076,12 +3937,14 @@ export {
|
|
|
6076
3937
|
installFromMarketplace,
|
|
6077
3938
|
intentCompatibilityScore,
|
|
6078
3939
|
isAgentAccessSecretRef,
|
|
3940
|
+
isCoolingDown,
|
|
6079
3941
|
isDirectAnswerEligible,
|
|
6080
3942
|
isDurableVerdict,
|
|
6081
3943
|
isEdgeType,
|
|
6082
3944
|
isImportRole,
|
|
6083
3945
|
isLcmMessagePartKind,
|
|
6084
3946
|
isNodeType,
|
|
3947
|
+
isOpenaiApiKeyDisabled,
|
|
6085
3948
|
isReasoningTracePath,
|
|
6086
3949
|
isRecallDisclosure,
|
|
6087
3950
|
isReviewPrompt,
|
|
@@ -6092,10 +3955,13 @@ export {
|
|
|
6092
3955
|
isUserModelDimension,
|
|
6093
3956
|
isValidCachedVerdict,
|
|
6094
3957
|
isValidConnectorId,
|
|
3958
|
+
isValidResolutionVerb,
|
|
3959
|
+
judgeContradictionPairs,
|
|
6095
3960
|
judgeFactDurability,
|
|
6096
3961
|
listBulkImportSources,
|
|
6097
3962
|
listConnectorStates,
|
|
6098
3963
|
listConnectors,
|
|
3964
|
+
listPairs,
|
|
6099
3965
|
listPeers,
|
|
6100
3966
|
listReviewItems,
|
|
6101
3967
|
listSpaces,
|
|
@@ -6120,6 +3986,8 @@ export {
|
|
|
6120
3986
|
normalizeCachedVerdict,
|
|
6121
3987
|
normalizeExplicitParts,
|
|
6122
3988
|
normalizeOriginUrl,
|
|
3989
|
+
normalizeProjectionPreview,
|
|
3990
|
+
normalizeProjectionTags,
|
|
6123
3991
|
normalizeQueryText,
|
|
6124
3992
|
normalizeRetrievedMemoryProvenance,
|
|
6125
3993
|
normalizeTurnExpansionEnd,
|
|
@@ -6139,6 +4007,7 @@ export {
|
|
|
6139
4007
|
parseConnectorsListOptions,
|
|
6140
4008
|
parseConnectorsRunName,
|
|
6141
4009
|
parseConnectorsStatusOptions,
|
|
4010
|
+
parseEntityFile,
|
|
6142
4011
|
parseFlexibleIsoTimestamp,
|
|
6143
4012
|
parseIsoOffsetTimestamp,
|
|
6144
4013
|
parseIsoTimestamp,
|
|
@@ -6170,6 +4039,7 @@ export {
|
|
|
6170
4039
|
readForkLineage,
|
|
6171
4040
|
readInteractionLogRaw,
|
|
6172
4041
|
readManifest,
|
|
4042
|
+
readPair,
|
|
6173
4043
|
readPeer,
|
|
6174
4044
|
readPeerProfile,
|
|
6175
4045
|
recallForActiveMemory,
|
|
@@ -6195,8 +4065,10 @@ export {
|
|
|
6195
4065
|
resolveCategory,
|
|
6196
4066
|
resolveCodingNamespaceOverlay,
|
|
6197
4067
|
resolveConnectorFromToken,
|
|
4068
|
+
resolveEnvVars,
|
|
6198
4069
|
resolveExtensionsRoot,
|
|
6199
4070
|
resolveGitContext,
|
|
4071
|
+
resolvePair,
|
|
6200
4072
|
resolvePrincipal,
|
|
6201
4073
|
resolveRemnicPluginEntry,
|
|
6202
4074
|
revertToVersion,
|
|
@@ -6207,6 +4079,7 @@ export {
|
|
|
6207
4079
|
runBulkImportPipeline,
|
|
6208
4080
|
runCodexMaterialize,
|
|
6209
4081
|
runConnectorPollOnce,
|
|
4082
|
+
runContradictionScan,
|
|
6210
4083
|
runEnrichmentPipeline,
|
|
6211
4084
|
runGraphRecall,
|
|
6212
4085
|
runImporter,
|
|
@@ -6219,6 +4092,7 @@ export {
|
|
|
6219
4092
|
saveTaxonomy,
|
|
6220
4093
|
saveTokenStore,
|
|
6221
4094
|
scanForBinaries,
|
|
4095
|
+
serializeEntityFile,
|
|
6222
4096
|
setCodexCliFallbackRunnerForProcess,
|
|
6223
4097
|
shareSpace,
|
|
6224
4098
|
shouldRecallEventOrderEvidence,
|
|
@@ -6247,6 +4121,8 @@ export {
|
|
|
6247
4121
|
writeConnectorState,
|
|
6248
4122
|
writeManifest,
|
|
6249
4123
|
writeMarketplaceManifest,
|
|
4124
|
+
writePair,
|
|
4125
|
+
writePairs,
|
|
6250
4126
|
writePeer,
|
|
6251
4127
|
writePeerProfile
|
|
6252
4128
|
};
|