agentic-qe 3.13.12 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/qe-court/SKILL.md +4 -4
- package/.claude/skills/qe-court/config-schema.json +38 -0
- package/.claude/skills/qe-court/evals/qe-court.yaml +8 -8
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +53 -0
- package/assets/skills/qe-court/SKILL.md +4 -4
- package/assets/skills/qe-court/config-schema.json +38 -0
- package/assets/skills/qe-court/evals/qe-court.yaml +8 -8
- package/assets/skills/skills-manifest.json +1 -1
- package/dist/cli/brain-commands.d.ts +1 -0
- package/dist/cli/brain-commands.js +1 -0
- package/dist/cli/bundle.js +5 -5
- package/dist/cli/chunks/adapter-3VBXL7DO.js +2 -0
- package/dist/cli/chunks/{agent-booster-wasm-7I7LZFNC.js → agent-booster-wasm-JZO6VUW4.js} +2 -2
- package/dist/cli/chunks/{agent-handler-QZZT52BH.js → agent-handler-534KFGEJ.js} +2 -2
- package/dist/cli/chunks/{agent-memory-branch-MLQS5Y26.js → agent-memory-branch-B7KWLWY4.js} +2 -2
- package/dist/cli/chunks/aqe-learning-engine-NXRNKJNA.js +2 -0
- package/dist/cli/chunks/{arena-IM4CP6LP.js → arena-7CCD3S3I.js} +2 -2
- package/dist/cli/chunks/{arena-WRIY37EJ.js → arena-OW5MELJX.js} +4 -4
- package/dist/cli/chunks/{audit-BSAQ4EFN.js → audit-BHVKN4E2.js} +3 -3
- package/dist/cli/chunks/base-F6GMOKU2.js +2 -0
- package/dist/cli/chunks/{better-sqlite3-X2XZUXWZ.js → better-sqlite3-P5FA6WFK.js} +2 -2
- package/dist/cli/chunks/brain-handler-WNW5LOV7.js +90 -0
- package/dist/cli/chunks/{branch-enumerator-NI4Q7DSJ.js → branch-enumerator-TVZ2ODKH.js} +2 -2
- package/dist/cli/chunks/{browser-PXBLORUZ.js → browser-TCEB2W2F.js} +2 -2
- package/dist/cli/chunks/browser-workflow-QRDC46LR.js +2 -0
- package/dist/cli/chunks/{chunk-4FVOJBEU.js → chunk-2D7UBX5S.js} +1 -1
- package/dist/cli/chunks/{chunk-NG6A7LCG.js → chunk-2HYVOX6N.js} +1 -1
- package/dist/cli/chunks/{chunk-MGKH4LCM.js → chunk-2NO4H35K.js} +1 -1
- package/dist/cli/chunks/{chunk-UC4EIULB.js → chunk-2O4DDPEA.js} +19 -19
- package/dist/cli/chunks/{chunk-IT5QIUUA.js → chunk-3EM2MK3Z.js} +2 -2
- package/dist/cli/chunks/chunk-3GUO4ERR.js +24 -0
- package/dist/cli/chunks/{chunk-XIKYUBIV.js → chunk-3JIJBR4V.js} +2 -2
- package/dist/cli/chunks/{chunk-NL2SCAGJ.js → chunk-3QT6S3A3.js} +3 -3
- package/dist/cli/chunks/{chunk-SOS37ECY.js → chunk-3RYTAYR6.js} +1 -1
- package/dist/cli/chunks/chunk-43GPSYAL.js +14 -0
- package/dist/cli/chunks/{chunk-IPDM3CAK.js → chunk-4FEJEVG7.js} +1 -1
- package/dist/cli/chunks/{chunk-M3354CE4.js → chunk-4MK2G6TK.js} +2 -2
- package/dist/cli/chunks/{chunk-AM42ROKZ.js → chunk-4XTHRAUV.js} +1 -1
- package/dist/cli/chunks/{chunk-LRO74LPA.js → chunk-4ZVGSVHV.js} +4 -4
- package/dist/cli/chunks/{chunk-I5SXLV7D.js → chunk-52DFCV57.js} +2 -2
- package/dist/cli/chunks/{chunk-WYFAPA2G.js → chunk-5LEAGKX5.js} +2 -2
- package/dist/cli/chunks/{chunk-OZ53BIY5.js → chunk-5MZF4N4Q.js} +1 -1
- package/dist/cli/chunks/{chunk-NDRZZSD5.js → chunk-5VDVYTO5.js} +2 -2
- package/dist/cli/chunks/chunk-5XGVSQS2.js +11 -0
- package/dist/cli/chunks/{chunk-SXFSJJZF.js → chunk-6AOZU3UN.js} +2 -2
- package/dist/cli/chunks/{chunk-2VTX4SYW.js → chunk-6AYO3IR2.js} +2 -2
- package/dist/cli/chunks/{chunk-4AITMWFZ.js → chunk-6DPAMYLU.js} +2 -2
- package/dist/cli/chunks/{chunk-WE3VKDMK.js → chunk-6IJMD2ZL.js} +3 -3
- package/dist/cli/chunks/{chunk-5E76HULA.js → chunk-6IZQSLYZ.js} +2 -2
- package/dist/cli/chunks/{chunk-VBHA4SDU.js → chunk-6W42XWLL.js} +2 -2
- package/dist/cli/chunks/{chunk-ASWWBNX2.js → chunk-7BOPFN3Y.js} +2 -2
- package/dist/cli/chunks/{chunk-SCQNISGS.js → chunk-7OUMJCJT.js} +1 -1
- package/dist/cli/chunks/{chunk-M73KM3AZ.js → chunk-7RAB2BZY.js} +160 -26
- package/dist/cli/chunks/{chunk-4ANJV6I4.js → chunk-7RVAHJQZ.js} +3 -3
- package/dist/cli/chunks/{chunk-VQCLSX7T.js → chunk-A2WZEMWT.js} +1 -1
- package/dist/cli/chunks/{chunk-YQOQVSYU.js → chunk-A7SKM6JL.js} +1 -1
- package/dist/cli/chunks/chunk-AFGT26NR.js +2 -0
- package/dist/cli/chunks/{chunk-JVFZAJ5N.js → chunk-AR6SATU3.js} +2 -2
- package/dist/cli/chunks/{chunk-YL2GOJF6.js → chunk-AVLA5PBJ.js} +2 -2
- package/dist/cli/chunks/{chunk-R7LGVJMZ.js → chunk-B3H4K7CY.js} +2 -2
- package/dist/cli/chunks/{chunk-UWZYXI3R.js → chunk-BQCTO7UB.js} +2 -2
- package/dist/cli/chunks/{chunk-HAJG44BD.js → chunk-BZ4QVFP2.js} +2 -2
- package/dist/cli/chunks/{chunk-NNLZAVFH.js → chunk-CIUOC5F3.js} +1 -1
- package/dist/cli/chunks/{chunk-KRZYWVS3.js → chunk-CIZ6LSNV.js} +2 -2
- package/dist/cli/chunks/{chunk-HQWFZQMJ.js → chunk-DDPJUAXQ.js} +2 -2
- package/dist/cli/chunks/{chunk-X3JNFQW2.js → chunk-DJITEQYS.js} +2 -2
- package/dist/cli/chunks/{chunk-TB2N3CAK.js → chunk-DOWCOZDO.js} +2 -2
- package/dist/cli/chunks/{chunk-GJJWXRAD.js → chunk-E4NU4BJA.js} +2 -2
- package/dist/cli/chunks/{chunk-H3GAR4SV.js → chunk-E722WNWC.js} +2 -2
- package/dist/cli/chunks/chunk-ECTPFCON.js +2 -0
- package/dist/cli/chunks/{chunk-4YFXF5AQ.js → chunk-EJ6IP7DE.js} +5 -5
- package/dist/cli/chunks/{chunk-AN5CGTTJ.js → chunk-ENGKLFLY.js} +2 -2
- package/dist/cli/chunks/{chunk-7A4WTRWI.js → chunk-FF43SRP6.js} +1 -1
- package/dist/cli/chunks/{chunk-52VGZJSD.js → chunk-FOHYBR3O.js} +1 -1
- package/dist/cli/chunks/{chunk-6KI6LAAZ.js → chunk-FRL3X2QA.js} +2 -2
- package/dist/cli/chunks/{chunk-3ASVQILY.js → chunk-GKNDP5VK.js} +2 -2
- package/dist/cli/chunks/{chunk-2VY7FL6A.js → chunk-GVEJP5T7.js} +2 -2
- package/dist/cli/chunks/{chunk-VD53LBF7.js → chunk-H3YDDKBW.js} +3 -3
- package/dist/cli/chunks/{chunk-Z6DSYLAG.js → chunk-H6NFDOMK.js} +1 -1
- package/dist/cli/chunks/{chunk-BZIPYXSW.js → chunk-H76TV4UU.js} +3 -3
- package/dist/cli/chunks/{chunk-XT473WPO.js → chunk-HJIAVR6P.js} +2 -2
- package/dist/cli/chunks/{chunk-MLXLGBQZ.js → chunk-HLNQDRHA.js} +1 -1
- package/dist/cli/chunks/{chunk-DGFINXUE.js → chunk-HNKPLVYS.js} +1 -1
- package/dist/cli/chunks/{chunk-WXU7FAEB.js → chunk-HQ7243G3.js} +2 -2
- package/dist/cli/chunks/{chunk-VA2ORJB5.js → chunk-HQHLHSJO.js} +2 -2
- package/dist/cli/chunks/{chunk-2W3D5A4R.js → chunk-I3VHXA2W.js} +2 -2
- package/dist/cli/chunks/{chunk-EG73WYAW.js → chunk-IE5LC7MB.js} +2 -2
- package/dist/cli/chunks/{chunk-S6WHYOWV.js → chunk-IL4AEB3J.js} +27 -25
- package/dist/cli/chunks/{chunk-TWUWLSGQ.js → chunk-IL6QRXRP.js} +6 -6
- package/dist/cli/chunks/{chunk-5PNQNBDZ.js → chunk-IQ3JFHZN.js} +1 -1
- package/dist/cli/chunks/{chunk-MB2KLJ6Q.js → chunk-IQLRA4FV.js} +1 -1
- package/dist/cli/chunks/{chunk-A5RWLPVT.js → chunk-J3XSHJGK.js} +2 -2
- package/dist/cli/chunks/{chunk-U5G6OC2C.js → chunk-JAK5UUWH.js} +2 -2
- package/dist/cli/chunks/{chunk-E67ZXRG6.js → chunk-JGROLJ33.js} +1 -1
- package/dist/cli/chunks/{chunk-VNODKACB.js → chunk-JMKMDSXG.js} +2 -2
- package/dist/cli/chunks/{chunk-LXVT6JXO.js → chunk-JRKEBESE.js} +2 -2
- package/dist/cli/chunks/{chunk-AKUDUB3O.js → chunk-JTWJR2KY.js} +2 -2
- package/dist/cli/chunks/{chunk-IOJ34SXJ.js → chunk-JY4VZ6BN.js} +2 -2
- package/dist/cli/chunks/{chunk-AYH3DMW2.js → chunk-K6CGQR5R.js} +1 -1
- package/dist/cli/chunks/{chunk-QXO35J6F.js → chunk-KDIZQHG5.js} +2 -2
- package/dist/cli/chunks/{chunk-7LATB5IR.js → chunk-KTSCZ7AW.js} +2 -2
- package/dist/cli/chunks/{chunk-M7CPJW53.js → chunk-L4C42WYI.js} +2 -2
- package/dist/cli/chunks/{chunk-QG5L2JM5.js → chunk-LCSVROU7.js} +10 -10
- package/dist/cli/chunks/{chunk-6BSZHNOC.js → chunk-LKR7T3OZ.js} +1 -1
- package/dist/cli/chunks/{chunk-GJUGG6UR.js → chunk-LZHTCUCO.js} +2 -2
- package/dist/cli/chunks/{chunk-7RVLVIAI.js → chunk-M3HUZD2I.js} +1 -1
- package/dist/cli/chunks/{chunk-RP5VFZJO.js → chunk-MO7EITJK.js} +2 -2
- package/dist/cli/chunks/{chunk-44NPKZGI.js → chunk-N2YAUDAV.js} +2 -2
- package/dist/cli/chunks/{chunk-G6FJHDUG.js → chunk-NDPQ2WPU.js} +1 -1
- package/dist/cli/chunks/{chunk-UBOGJHWC.js → chunk-NKWO2X3T.js} +1 -1
- package/dist/cli/chunks/{chunk-NJ3QXJ54.js → chunk-NOPVFBQM.js} +2 -2
- package/dist/cli/chunks/{chunk-AOOCV56W.js → chunk-NYARYONH.js} +1 -1
- package/dist/cli/chunks/{chunk-6KKVMPPR.js → chunk-O2MZZL54.js} +2 -2
- package/dist/cli/chunks/{chunk-2JAC57JE.js → chunk-OIYUSWHX.js} +1 -1
- package/dist/cli/chunks/{chunk-BODFJ3DC.js → chunk-OONCRNFA.js} +2 -2
- package/dist/cli/chunks/{chunk-ZMYV4R32.js → chunk-PEW6FZ47.js} +1 -1
- package/dist/cli/chunks/{chunk-42AS3HPO.js → chunk-Q73RRTLE.js} +2 -2
- package/dist/cli/chunks/{chunk-IQH2RDN3.js → chunk-QKQZ4IJF.js} +5 -5
- package/dist/cli/chunks/{chunk-MYVKTG55.js → chunk-QMMDN4WX.js} +3 -3
- package/dist/cli/chunks/chunk-QQCENKCX.js +2 -0
- package/dist/cli/chunks/{chunk-7PCIN7UN.js → chunk-QSPRQPEL.js} +2 -2
- package/dist/cli/chunks/{chunk-ZSAGRDXA.js → chunk-QZPFUFZG.js} +2 -2
- package/dist/cli/chunks/chunk-R2B6EE45.js +2 -0
- package/dist/cli/chunks/{chunk-33YZGOT6.js → chunk-R6WJF4D5.js} +2 -2
- package/dist/cli/chunks/{chunk-QM4Z7TQH.js → chunk-RGVD6ZUX.js} +1 -1
- package/dist/cli/chunks/{chunk-VQD2ELNL.js → chunk-RKUYVVGJ.js} +2 -2
- package/dist/cli/chunks/{chunk-5VSS2RBD.js → chunk-S5YVLPXU.js} +2 -2
- package/dist/cli/chunks/{chunk-IPZEBALY.js → chunk-SROZXIMT.js} +37 -37
- package/dist/cli/chunks/{chunk-GMLRIZ4E.js → chunk-SSV6KSFT.js} +1 -1
- package/dist/cli/chunks/{chunk-PVINNJ4P.js → chunk-SUSMHSXT.js} +2 -2
- package/dist/cli/chunks/{chunk-KXSUDN46.js → chunk-T3BZAFLP.js} +1 -1
- package/dist/cli/chunks/{chunk-MLFELTJX.js → chunk-TGOGCA74.js} +2 -2
- package/dist/cli/chunks/{chunk-G45AOQDZ.js → chunk-TKYEP7OR.js} +1 -1
- package/dist/cli/chunks/{chunk-KYJBJ56M.js → chunk-TQJE7DNL.js} +2 -2
- package/dist/cli/chunks/{chunk-5PI75QYP.js → chunk-TRDEULS7.js} +2 -2
- package/dist/cli/chunks/{chunk-OG3DBHIV.js → chunk-U4GZWPKM.js} +2 -2
- package/dist/cli/chunks/{chunk-NJ4YVAG7.js → chunk-UI6WSPEK.js} +3 -3
- package/dist/cli/chunks/{chunk-4M7YZ2X7.js → chunk-UUJ5VQJM.js} +1 -1
- package/dist/cli/chunks/{chunk-UJUK6T4V.js → chunk-VESOYP6A.js} +2 -2
- package/dist/cli/chunks/{chunk-7ZVO7I4Q.js → chunk-VOSISOFD.js} +1 -1
- package/dist/cli/chunks/{chunk-HRTSYT4N.js → chunk-VPVZHJSU.js} +2 -2
- package/dist/cli/chunks/{chunk-66OQ7AB3.js → chunk-VRRG66XB.js} +1 -1
- package/dist/cli/chunks/{chunk-4Z4X2ND4.js → chunk-VXU53F7Z.js} +2 -2
- package/dist/cli/chunks/{chunk-XM5I7J5S.js → chunk-VYENTZ45.js} +2 -2
- package/dist/cli/chunks/chunk-WJXHE52V.js +65 -0
- package/dist/cli/chunks/{chunk-3XVZHJQT.js → chunk-WKNWRDA5.js} +1 -1
- package/dist/cli/chunks/{chunk-DFLASG3B.js → chunk-WTHAVFIC.js} +1 -1
- package/dist/cli/chunks/{chunk-NTALX2YC.js → chunk-WWWX76QB.js} +2 -2
- package/dist/cli/chunks/{chunk-L3GBNX7B.js → chunk-XITTURP2.js} +2 -2
- package/dist/cli/chunks/{chunk-FI6J3UHJ.js → chunk-XXFKN7LB.js} +1 -1
- package/dist/cli/chunks/{chunk-RP2BRRLX.js → chunk-YEAC3DC6.js} +2 -2
- package/dist/cli/chunks/{chunk-JTYCOFTD.js → chunk-YKWMKRYB.js} +1 -1
- package/dist/cli/chunks/chunk-YKZV7O65.js +2 -0
- package/dist/cli/chunks/{chunk-N4OQ4D4V.js → chunk-YW4RNZWT.js} +2 -2
- package/dist/cli/chunks/{chunk-P6EFKHNI.js → chunk-ZAAYOENS.js} +2 -2
- package/dist/cli/chunks/chunk-ZBKGX72B.js +13 -0
- package/dist/cli/chunks/{chunk-TJVTV3HP.js → chunk-ZBOWR4XT.js} +2 -2
- package/dist/cli/chunks/{chunk-4THFPRFM.js → chunk-ZCVJCCQQ.js} +2 -2
- package/dist/cli/chunks/{chunk-X2SZCVDA.js → chunk-ZI3UO7QR.js} +8 -7
- package/dist/cli/chunks/{chunk-DCVFHVPR.js → chunk-ZNSMVQCG.js} +2 -2
- package/dist/cli/chunks/{chunk-Z56BBX77.js → chunk-ZQSXG7FA.js} +2 -2
- package/dist/cli/chunks/{ci-QAUD62WH.js → ci-B432UH6N.js} +2 -2
- package/dist/cli/chunks/{ci-output-TZDVTNE7.js → ci-output-GTHH7WYG.js} +2 -2
- package/dist/cli/chunks/{circuit-breaker-ZWPHJ7YJ.js → circuit-breaker-VW75DLME.js} +2 -2
- package/dist/cli/chunks/{claude-flow-setup-SCB4EURN.js → claude-flow-setup-RE3IVT7U.js} +2 -2
- package/dist/cli/chunks/client-HNBZUEVV.js +2 -0
- package/dist/cli/chunks/{cline-installer-EHZLMLXF.js → cline-installer-NUBZZ55N.js} +2 -2
- package/dist/cli/chunks/{code-3N6PBJMK.js → code-K6JCWKNW.js} +2 -2
- package/dist/cli/chunks/{code-index-extractor-6DIKHNRI.js → code-index-extractor-I4ILB5JN.js} +2 -2
- package/dist/cli/chunks/{codex-installer-P7DPQMYL.js → codex-installer-AKQ5BCHU.js} +2 -2
- package/dist/cli/chunks/{completions-5MKWWCCE.js → completions-V3KJVJF4.js} +2 -2
- package/dist/cli/chunks/{complexity-analyzer-TPM4IPEK.js → complexity-analyzer-HRG7OOY3.js} +2 -2
- package/dist/cli/chunks/{continuedev-installer-VXODKGVX.js → continuedev-installer-CNTDONWG.js} +2 -2
- package/dist/cli/chunks/{copilot-installer-PVD5O56P.js → copilot-installer-XPWWIWYA.js} +2 -2
- package/dist/cli/chunks/core-handlers-TB7NLYXL.js +2 -0
- package/dist/cli/chunks/{cost-tracker-JOMZEQF3.js → cost-tracker-MFNLQ56K.js} +2 -2
- package/dist/cli/chunks/{coverage-HTXLEV3B.js → coverage-KOIK654V.js} +3 -3
- package/dist/cli/chunks/cross-domain-router-MDSI553U.js +2 -0
- package/dist/cli/chunks/{cursor-installer-SHKDTDDZ.js → cursor-installer-S5MKLRQQ.js} +2 -2
- package/dist/cli/chunks/{daemon-FCFEWVVJ.js → daemon-DUS6JYW6.js} +3 -3
- package/dist/cli/chunks/{daemon-PN4FEPLE.js → daemon-Z7VPGWHY.js} +4 -4
- package/dist/cli/chunks/{dag-attention-scheduler-PLOHU5SR.js → dag-attention-scheduler-7CQ3ARNI.js} +2 -2
- package/dist/cli/chunks/{detect-F3H4ZEZY.js → detect-WORBCAYF.js} +2 -2
- package/dist/cli/chunks/{dist-node-5TC665N6.js → dist-node-KRNI6OYW.js} +2 -2
- package/dist/cli/chunks/{domain-handler-ZIWVFXCU.js → domain-handler-KRUR2VQG.js} +2 -2
- package/dist/cli/chunks/{domain-transfer-7Q5JYMYR.js → domain-transfer-VEOVLV54.js} +2 -2
- package/dist/cli/chunks/dream-X7ISHFEE.js +2 -0
- package/dist/cli/chunks/embed-and-insert-pattern-QU3NQVA5.js +3 -0
- package/dist/cli/chunks/{eval-E2K2T75A.js → eval-AYQ7BSUP.js} +2 -2
- package/dist/cli/chunks/{experience-capture-middleware-Z5SE2O53.js → experience-capture-middleware-AWQBL6LT.js} +3 -3
- package/dist/cli/chunks/{fast-paths-3H52RSUK.js → fast-paths-V5EL4BYJ.js} +2 -2
- package/dist/cli/chunks/{feature-flags-LUHSMHPS.js → feature-flags-BXX7BP22.js} +2 -2
- package/dist/cli/chunks/{feature-flags-ONIKUZVK.js → feature-flags-P34BPRWU.js} +2 -2
- package/dist/cli/chunks/{file-discovery-FLYSYSS4.js → file-discovery-MS6BKQ2U.js} +2 -2
- package/dist/cli/chunks/{fleet-6OJUAAKV.js → fleet-7WVVPA4W.js} +3 -3
- package/dist/cli/chunks/{gnn-wrapper-PUL6B7KZ.js → gnn-wrapper-7WQ3LEPG.js} +2 -2
- package/dist/cli/chunks/{heartbeat-handler-HGHHDUDY.js → heartbeat-handler-P7QD3BZH.js} +4 -4
- package/dist/cli/chunks/heartbeat-scheduler-2C5XGFQT.js +2 -0
- package/dist/cli/chunks/hnsw-adapter-KCVMXLUL.js +2 -0
- package/dist/cli/chunks/hnsw-index-OGWZS6MP.js +2 -0
- package/dist/cli/chunks/{hnsw-legacy-bridge-NDZSNMYX.js → hnsw-legacy-bridge-Y3GAR3UP.js} +2 -2
- package/dist/cli/chunks/{hnswlib-node-PISLKSO2.js → hnswlib-node-5QUXZQWQ.js} +2 -2
- package/dist/cli/chunks/{hooks-WYG54MRI.js → hooks-2D64KPRY.js} +10 -10
- package/dist/cli/chunks/{hypergraph-engine-EDHKHZZ2.js → hypergraph-engine-5INXEZDP.js} +2 -2
- package/dist/cli/chunks/{hypergraph-handler-OCHZAPPL.js → hypergraph-handler-YJJJ3ESZ.js} +3 -3
- package/dist/cli/chunks/impact-analyzer-IBJ43GQL.js +2 -0
- package/dist/cli/chunks/{init-handler-5TCJ672H.js → init-handler-QSFYJN5Q.js} +6 -6
- package/dist/cli/chunks/init-wizard-6XMFD5LP.js +2 -0
- package/dist/cli/chunks/kernel-UDUMUPB3.js +2 -0
- package/dist/cli/chunks/{kilocode-installer-SWUQRCTZ.js → kilocode-installer-3N3QGTJU.js} +2 -2
- package/dist/cli/chunks/{kiro-installer-L22EBAM5.js → kiro-installer-GIWVTFZQ.js} +2 -2
- package/dist/cli/chunks/knowledge-graph-JRYTUG3W.js +2 -0
- package/dist/cli/chunks/learning-SGO2DQ5Q.js +122 -0
- package/dist/cli/chunks/{llm-router-F2L4LFT2.js → llm-router-HBBULO65.js} +14 -14
- package/dist/cli/chunks/llm-router-service-KF5ZALUQ.js +2 -0
- package/dist/cli/chunks/{load-A4ZF2KHC.js → load-B5OFYB4H.js} +2 -2
- package/dist/cli/chunks/load-test-LHMBCNCH.js +2 -0
- package/dist/cli/chunks/{mcp-T2Z46NNK.js → mcp-FG3LNQR4.js} +2 -2
- package/dist/cli/chunks/{memory-PUC3J6XC.js → memory-SPS7ZWLC.js} +5 -5
- package/dist/cli/chunks/memory-backend-WZHKHBZK.js +2 -0
- package/dist/cli/chunks/memory-handlers-P7FTPWP3.js +2 -0
- package/dist/cli/chunks/{multi-model-executor-U5L4FI4O.js → multi-model-executor-PUB7E6KH.js} +2 -2
- package/dist/cli/chunks/{opencode-installer-UWI6KHYH.js → opencode-installer-TGCSGVG2.js} +2 -2
- package/dist/cli/chunks/{orchestrator-3BEI7R5D.js → orchestrator-S5FTJFGB.js} +10 -13
- package/dist/cli/chunks/pattern-null-store-UZSHCRL2.js +2 -0
- package/dist/cli/chunks/{pattern-usage-recorder-EGWUI5LU.js → pattern-usage-recorder-LCXXGRAB.js} +2 -2
- package/dist/cli/chunks/{pipeline-JG6M4RHD.js → pipeline-ENOSRHKW.js} +2 -2
- package/dist/cli/chunks/{platform-F76G6RUI.js → platform-WCRBO3Z7.js} +2 -2
- package/dist/cli/chunks/{plugin-EEGN3PMK.js → plugin-JZ5ODJSU.js} +2 -2
- package/dist/cli/chunks/{prime-radiant-advanced-wasm-7KZAINFT.js → prime-radiant-advanced-wasm-DPJUPNCG.js} +2 -2
- package/dist/cli/chunks/protocol-executor-42NLVDTC.js +2 -0
- package/dist/cli/chunks/{protocol-handler-UCEHYK2R.js → protocol-handler-IP4NLVY3.js} +2 -2
- package/dist/cli/chunks/{prove-JSNG75VD.js → prove-P6FM4RU7.js} +2 -2
- package/dist/cli/chunks/qe-reasoning-bank-W74RSMMU.js +2 -0
- package/dist/cli/chunks/{quality-7SRM2HBM.js → quality-UHP4XO26.js} +2 -2
- package/dist/cli/chunks/{quality-gate-A5MPWHST.js → quality-gate-63DDBSGM.js} +3 -3
- package/dist/cli/chunks/queen-coordinator-XELKSRMS.js +2 -0
- package/dist/cli/chunks/real-embeddings-6SO5MFRQ.js +2 -0
- package/dist/cli/chunks/{roocode-installer-UYQK64BZ.js → roocode-installer-WTWUOFCH.js} +2 -2
- package/dist/cli/chunks/router-GTW2EQZV.js +2 -0
- package/dist/cli/chunks/routing-feedback-NVOBWEMK.js +2 -0
- package/dist/cli/chunks/{routing-handler-PY3KPDTH.js → routing-handler-IK7HYERQ.js} +2 -2
- package/dist/cli/chunks/{ruvector-commands-GCAOUTYS.js → ruvector-commands-THLB4NIM.js} +2 -2
- package/dist/cli/chunks/rvf-dual-writer-5OPVMXNL.js +2 -0
- package/dist/cli/chunks/rvf-migration-adapter-5S4YFTX4.js +2 -0
- package/dist/cli/chunks/rvf-migration-coordinator-BUKCSHBD.js +2 -0
- package/dist/cli/chunks/rvf-native-adapter-LYSJHEVX.js +2 -0
- package/dist/cli/chunks/{rvf-store-integrity-HNDKOM4L.js → rvf-store-integrity-ECTADZIN.js} +2 -2
- package/dist/cli/chunks/safe-db-AEB3JMLD.js +2 -0
- package/dist/cli/chunks/schedule-4QNPCQNT.js +2 -0
- package/dist/cli/chunks/scheduler-S3DFHX6A.js +2 -0
- package/dist/cli/chunks/{security-MQ2VB7PY.js → security-HN4UXFXX.js} +3 -3
- package/dist/cli/chunks/{shared-rvf-adapter-TAZEU6QK.js → shared-rvf-adapter-XJCPX5SN.js} +2 -2
- package/dist/cli/chunks/{shared-rvf-dual-writer-B7N6AOCY.js → shared-rvf-dual-writer-23X5PNY5.js} +2 -2
- package/dist/cli/chunks/sqlite-persistence-L2KISU2H.js +2 -0
- package/dist/cli/chunks/{status-handler-NZP7DFHE.js → status-handler-ZXANTHKT.js} +2 -2
- package/dist/cli/chunks/{structural-health-ALLUQ4X6.js → structural-health-LR6WI3AH.js} +2 -2
- package/dist/cli/chunks/{sync-WJJG5J6V.js → sync-4OEI3BC2.js} +2 -2
- package/dist/cli/chunks/{sync-MM7OCUYD.js → sync-I5IUJF33.js} +2 -2
- package/dist/cli/chunks/{task-handler-CAQUEEB4.js → task-handler-R3ATJKU5.js} +2 -2
- package/dist/cli/chunks/{task-handlers-25BJ7D3W.js → task-handlers-4X357AEW.js} +3 -3
- package/dist/cli/chunks/{test-HW7GVGVN.js → test-PR2B5H2F.js} +4 -4
- package/dist/cli/chunks/{test-scheduling-HTMFJMSP.js → test-scheduling-ZNOSQVLD.js} +3 -3
- package/dist/cli/chunks/token-bootstrap-LYXOI72S.js +2 -0
- package/dist/cli/chunks/{token-usage-RJZDMBDP.js → token-usage-R6EQZBX2.js} +2 -2
- package/dist/cli/chunks/{transformers-3YFW3EUO.js → transformers-COQWK27J.js} +2 -2
- package/dist/cli/chunks/{tree-sitter-wasm-parser-U3PQPIK7.js → tree-sitter-wasm-parser-LLIW2X3M.js} +2 -2
- package/dist/cli/chunks/{types-7Q762WDO.js → types-MEYTZITK.js} +2 -2
- package/dist/cli/chunks/unified-memory-5KQMA7FV.js +2 -0
- package/dist/cli/chunks/unified-memory-hnsw-PQRPTYOD.js +2 -0
- package/dist/cli/chunks/unified-persistence-YDONVPJB.js +2 -0
- package/dist/cli/chunks/{upgrade-F7MKJWBQ.js → upgrade-DVIJ456A.js} +2 -2
- package/dist/cli/chunks/{validate-B27AVRA6.js → validate-UYTSMJ5X.js} +2 -2
- package/dist/cli/chunks/{validate-swarm-GYZR3GNL.js → validate-swarm-P32WCJR6.js} +2 -2
- package/dist/cli/chunks/{vibium-W4XQMPJP.js → vibium-JGVOLM6X.js} +2 -2
- package/dist/cli/chunks/visual-security-RJ7RTNGJ.js +2 -0
- package/dist/cli/chunks/{web-tree-sitter-I7CDCFJU.js → web-tree-sitter-5ZGNCTPN.js} +2 -2
- package/dist/cli/chunks/{windsurf-installer-UYLHFDHU.js → windsurf-installer-IILSSQAE.js} +2 -2
- package/dist/cli/chunks/{witness-chain-B66SYZKU.js → witness-chain-JZMXCG3B.js} +2 -2
- package/dist/cli/chunks/witness-chain-YXXXNGAM.js +2 -0
- package/dist/cli/chunks/{witness-key-manager-U4JPAHVW.js → witness-key-manager-UUTLNUIH.js} +2 -2
- package/dist/cli/chunks/{workflow-DYMO47FF.js → workflow-NS7HXVHZ.js} +4 -4
- package/dist/cli/chunks/workflow-orchestrator-5KUAVSTH.js +2 -0
- package/dist/cli/chunks/{wrappers-7S6DQTEA.js → wrappers-XKEDSV5W.js} +2 -2
- package/dist/cli/commands/learning.js +44 -0
- package/dist/cli/commands/llm-router.js +27 -21
- package/dist/cli/handlers/brain-handler.js +2 -0
- package/dist/context/compaction/index.d.ts +1 -0
- package/dist/context/compaction/index.js +3 -0
- package/dist/context/compaction/instruction-provenance.d.ts +20 -0
- package/dist/context/compaction/instruction-provenance.js +18 -0
- package/dist/context/compaction/tier2-session-summary.d.ts +8 -0
- package/dist/context/compaction/tier2-session-summary.js +20 -0
- package/dist/context/compaction/tier3-llm-compact.d.ts +4 -0
- package/dist/context/compaction/tier3-llm-compact.js +32 -4
- package/dist/init/phases/07-hooks.js +0 -3
- package/dist/integrations/embeddings/base/EmbeddingGenerator.js +4 -2
- package/dist/integrations/ruvector/brain-exporter.d.ts +1 -1
- package/dist/integrations/ruvector/brain-exporter.js +15 -3
- package/dist/integrations/ruvector/brain-rvf-exporter.d.ts +4 -0
- package/dist/integrations/ruvector/brain-rvf-exporter.js +118 -37
- package/dist/integrations/ruvector/brain-search.d.ts +1 -1
- package/dist/integrations/ruvector/brain-search.js +1 -1
- package/dist/integrations/ruvector/brain-shared.d.ts +4 -2
- package/dist/integrations/ruvector/brain-shared.js +11 -4
- package/dist/integrations/ruvector/brain-table-ddl.d.ts +2 -2
- package/dist/integrations/ruvector/brain-table-ddl.js +20 -8
- package/dist/integrations/ruvector/cognitive-container.js +1 -1
- package/dist/integrations/ruvector/rvf-dual-writer.d.ts +4 -0
- package/dist/integrations/ruvector/rvf-dual-writer.js +57 -9
- package/dist/integrations/ruvector/rvf-store-integrity.js +1 -1
- package/dist/kernel/unified-memory-schemas.d.ts +4 -3
- package/dist/kernel/unified-memory-schemas.js +19 -9
- package/dist/kernel/unified-memory.d.ts +2 -0
- package/dist/kernel/unified-memory.js +19 -0
- package/dist/learning/embed-and-insert-pattern.js +6 -3
- package/dist/learning/embedding-space.d.ts +50 -0
- package/dist/learning/embedding-space.js +128 -0
- package/dist/learning/evidence-admission-store.d.ts +15 -0
- package/dist/learning/evidence-admission-store.js +68 -0
- package/dist/learning/index.d.ts +4 -0
- package/dist/learning/index.js +2 -0
- package/dist/learning/learning-evidence-admission.d.ts +44 -0
- package/dist/learning/learning-evidence-admission.js +97 -0
- package/dist/learning/pattern-store.d.ts +5 -0
- package/dist/learning/pattern-store.js +36 -7
- package/dist/learning/qe-flywheel/coupled-anchor.d.ts +8 -0
- package/dist/learning/qe-flywheel/coupled-anchor.js +46 -3
- package/dist/learning/qe-reasoning-bank.js +4 -0
- package/dist/learning/real-embeddings.d.ts +3 -0
- package/dist/learning/real-embeddings.js +40 -3
- package/dist/learning/real-qe-reasoning-bank.js +7 -3
- package/dist/learning/rvf-pattern-migration.d.ts +2 -0
- package/dist/learning/rvf-pattern-migration.js +5 -3
- package/dist/learning/rvf-pattern-store.d.ts +3 -0
- package/dist/learning/rvf-pattern-store.js +21 -1
- package/dist/learning/sqlite-persistence.d.ts +7 -2
- package/dist/learning/sqlite-persistence.js +58 -21
- package/dist/mcp/bundle.js +603 -447
- package/dist/mcp/handlers/memory-handlers.js +6 -2
- package/dist/migrations/20260830_add_learning_evidence_tables.d.ts +7 -0
- package/dist/migrations/20260830_add_learning_evidence_tables.js +173 -0
- package/dist/persistence/rvf-migration-adapter.d.ts +2 -0
- package/dist/persistence/rvf-migration-adapter.js +56 -12
- package/dist/shared/llm/llm-router-service.d.ts +8 -0
- package/dist/shared/llm/llm-router-service.js +21 -3
- package/dist/shared/sql-safety.js +4 -0
- package/dist/skills/qe-court/cli.d.ts +3 -0
- package/dist/skills/qe-court/cli.js +54 -0
- package/dist/verification/adversarial-verify/calibrate.d.ts +46 -2
- package/dist/verification/adversarial-verify/calibrate.js +104 -2
- package/dist/verification/adversarial-verify/index.d.ts +1 -1
- package/dist/verification/adversarial-verify/index.js +1 -1
- package/package.json +8 -3
- package/dist/cli/chunks/adapter-FUV6LBJT.js +0 -2
- package/dist/cli/chunks/aqe-learning-engine-QNFNA3J4.js +0 -2
- package/dist/cli/chunks/base-37W2XIXC.js +0 -2
- package/dist/cli/chunks/brain-handler-TVTTWZGP.js +0 -89
- package/dist/cli/chunks/browser-workflow-PDIUEK7B.js +0 -2
- package/dist/cli/chunks/chunk-EDRPTLAX.js +0 -2
- package/dist/cli/chunks/chunk-GEQWCK4F.js +0 -2
- package/dist/cli/chunks/chunk-GQLJYTXN.js +0 -2
- package/dist/cli/chunks/chunk-NLZUGANH.js +0 -11
- package/dist/cli/chunks/chunk-O4BWESH5.js +0 -2
- package/dist/cli/chunks/chunk-PGFCKE4G.js +0 -12
- package/dist/cli/chunks/chunk-RACWX2ZX.js +0 -9
- package/dist/cli/chunks/chunk-SNC73DWF.js +0 -2
- package/dist/cli/chunks/chunk-TDVMILKO.js +0 -2
- package/dist/cli/chunks/chunk-TK5XLF3Z.js +0 -65
- package/dist/cli/chunks/chunk-UQ4UCHO7.js +0 -2
- package/dist/cli/chunks/chunk-VZGP77YU.js +0 -12
- package/dist/cli/chunks/chunk-WA6CSEOX.js +0 -2
- package/dist/cli/chunks/chunk-WYIXNHPF.js +0 -2
- package/dist/cli/chunks/client-4W3KWTAU.js +0 -2
- package/dist/cli/chunks/core-handlers-BDU2XBLO.js +0 -2
- package/dist/cli/chunks/cross-domain-router-BPB6IHN4.js +0 -2
- package/dist/cli/chunks/dream-WFCZGFDY.js +0 -2
- package/dist/cli/chunks/embed-and-insert-pattern-VESJQSYD.js +0 -3
- package/dist/cli/chunks/heartbeat-scheduler-HWS4SHRM.js +0 -2
- package/dist/cli/chunks/hnsw-adapter-7QOBHKRB.js +0 -2
- package/dist/cli/chunks/hnsw-index-6WUKYJH7.js +0 -2
- package/dist/cli/chunks/hybrid-router-525JTRA5.js +0 -2
- package/dist/cli/chunks/impact-analyzer-GG6CJEOK.js +0 -2
- package/dist/cli/chunks/init-wizard-4VFAOK4Y.js +0 -2
- package/dist/cli/chunks/kernel-N3FQGOST.js +0 -2
- package/dist/cli/chunks/knowledge-graph-I5QIHB4G.js +0 -2
- package/dist/cli/chunks/learning-TQOGG3CR.js +0 -119
- package/dist/cli/chunks/llm-router-service-NCJZYJLG.js +0 -2
- package/dist/cli/chunks/load-test-DCJEYIXD.js +0 -2
- package/dist/cli/chunks/memory-backend-O6KO2KTX.js +0 -2
- package/dist/cli/chunks/memory-handlers-4Z43WEKD.js +0 -2
- package/dist/cli/chunks/pattern-null-store-5WIJKX2K.js +0 -2
- package/dist/cli/chunks/protocol-executor-5TPNAZTB.js +0 -2
- package/dist/cli/chunks/provider-manager-3VMOZ6HV.js +0 -2
- package/dist/cli/chunks/qe-reasoning-bank-BATV4NTT.js +0 -2
- package/dist/cli/chunks/queen-coordinator-EIHGYBUO.js +0 -2
- package/dist/cli/chunks/real-embeddings-ZBF5EQOG.js +0 -2
- package/dist/cli/chunks/router-EMVGY4HU.js +0 -2
- package/dist/cli/chunks/routing-feedback-JUP4OFB2.js +0 -2
- package/dist/cli/chunks/rvf-dual-writer-BUNP4SKD.js +0 -2
- package/dist/cli/chunks/rvf-migration-adapter-VSOAPLMB.js +0 -2
- package/dist/cli/chunks/rvf-migration-coordinator-LSWEHAWX.js +0 -2
- package/dist/cli/chunks/rvf-native-adapter-LOC42TQ6.js +0 -2
- package/dist/cli/chunks/safe-db-WQ62IQKV.js +0 -2
- package/dist/cli/chunks/schedule-XJRP57TE.js +0 -2
- package/dist/cli/chunks/scheduler-EZH5SDIM.js +0 -2
- package/dist/cli/chunks/sqlite-persistence-HPEVCTIB.js +0 -2
- package/dist/cli/chunks/token-bootstrap-F2DCLWGW.js +0 -2
- package/dist/cli/chunks/unified-memory-ATILROKR.js +0 -2
- package/dist/cli/chunks/unified-memory-hnsw-XJXAX7DW.js +0 -2
- package/dist/cli/chunks/unified-persistence-3TN5PBWE.js +0 -2
- package/dist/cli/chunks/visual-security-VFWRBCNA.js +0 -2
- package/dist/cli/chunks/witness-chain-JC5LEXRV.js +0 -2
- package/dist/cli/chunks/workflow-orchestrator-TKQUF2KN.js +0 -2
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{d as J,e as B,f as te,g as j}from"./chunk-YQOQVSYU.js";import{a as ne}from"./chunk-GMLRIZ4E.js";import{b as _e}from"./chunk-VNODKACB.js";import{a as ie}from"./chunk-2W3D5A4R.js";import{b as De,c as nt}from"./chunk-6KI6LAAZ.js";import{a as re,b as Fe,d as Oe,f as it}from"./chunk-HQWFZQMJ.js";import{c as Ie}from"./chunk-EDRPTLAX.js";import{b as P,c as w}from"./chunk-E67ZXRG6.js";import{a as v,b as xe,c as Ce}from"./chunk-L3GBNX7B.js";import{i as C}from"./chunk-52VGZJSD.js";import{B as Q,D as H,G as ee,P as M,S as F,b as D}from"./chunk-AN5CGTTJ.js";import{a as Te,d as $,f as rt}from"./chunk-ZMYV4R32.js";var G=$(E=>{var ft=E&&E.__extends||(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var i in s)s.hasOwnProperty(i)&&(r[i]=s[i])},n(e,t)};return function(e,t){n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})();Object.defineProperty(E,"__esModule",{value:!0});var mt=Object.prototype.hasOwnProperty;function ue(n,e){return mt.call(n,e)}E.hasOwnProperty=ue;function ze(n){if(Array.isArray(n)){for(var e=new Array(n.length),t=0;t<e.length;t++)e[t]=""+t;return e}if(Object.keys)return Object.keys(n);var r=[];for(var s in n)ue(n,s)&&r.push(s);return r}E._objectKeys=ze;function pt(n){switch(typeof n){case"object":return JSON.parse(JSON.stringify(n));case"undefined":return null;default:return n}}E._deepClone=pt;function gt(n){for(var e=0,t=n.length,r;e<t;){if(r=n.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}E.isInteger=gt;function ce(n){return n.indexOf("/")===-1&&n.indexOf("~")===-1?n:n.replace(/~/g,"~0").replace(/\//g,"~1")}E.escapePathComponent=ce;function yt(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}E.unescapePathComponent=yt;function he(n,e){var t;for(var r in n)if(ue(n,r)){if(n[r]===e)return ce(r)+"/";if(typeof n[r]=="object"&&(t=he(n[r],e),t!=""))return ce(r)+"/"+t}return""}E._getPathRecursive=he;function vt(n,e){if(n===e)return"/";var t=he(n,e);if(t==="")throw new Error("Object not found in root");return"/"+t}E.getPath=vt;function le(n){if(n===void 0)return!0;if(n){if(Array.isArray(n)){for(var e=0,t=n.length;e<t;e++)if(le(n[e]))return!0}else if(typeof n=="object"){for(var r=ze(n),s=r.length,i=0;i<s;i++)if(le(n[r[i]]))return!0}}return!1}E.hasUndefined=le;function qe(n,e){var t=[n];for(var r in e){var s=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof s<"u"&&t.push(r+": "+s)}return t.join(`
|
|
3
|
-
`)}var Pt=(function(n){ft(e,n);function e(t,r,s,i,a){var c=this.constructor,u=n.call(this,qe(t,{name:r,index:s,operation:i,tree:a}))||this;return u.name=r,u.index=s,u.operation=i,u.tree=a,Object.setPrototypeOf(u,c.prototype),u.message=qe(t,{name:r,index:s,operation:i,tree:a}),u}return e})(Error);E.PatchError=Pt});var de=$(g=>{Object.defineProperty(g,"__esModule",{value:!0});var R=G();g.JsonPatchError=R.PatchError;g.deepClone=R._deepClone;var L={add:function(n,e,t){return n[e]=this.value,{newDocument:t}},remove:function(n,e,t){var r=n[e];return delete n[e],{newDocument:t,removed:r}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:function(n,e,t){var r=V(t,this.path);r&&(r=R._deepClone(r));var s=O(t,{op:"remove",path:this.from}).removed;return O(t,{op:"add",path:this.path,value:s}),{newDocument:t,removed:r}},copy:function(n,e,t){var r=V(t,this.from);return O(t,{op:"add",path:this.path,value:R._deepClone(r)}),{newDocument:t}},test:function(n,e,t){return{newDocument:t,test:z(n[e],this.value)}},_get:function(n,e,t){return this.value=n[e],{newDocument:t}}},wt={add:function(n,e,t){return R.isInteger(e)?n.splice(e,0,this.value):n[e]=this.value,{newDocument:t,index:e}},remove:function(n,e,t){var r=n.splice(e,1);return{newDocument:t,removed:r[0]}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:L.move,copy:L.copy,test:L.test,_get:L._get};function V(n,e){if(e=="")return n;var t={op:"_get",path:e};return O(n,t),t.value}g.getValueByPointer=V;function O(n,e,t,r,s,i){if(t===void 0&&(t=!1),r===void 0&&(r=!0),s===void 0&&(s=!0),i===void 0&&(i=0),t&&(typeof t=="function"?t(e,0,n,e.path):Y(e,0)),e.path===""){var a={newDocument:n};if(e.op==="add")return a.newDocument=e.value,a;if(e.op==="replace")return a.newDocument=e.value,a.removed=n,a;if(e.op==="move"||e.op==="copy")return a.newDocument=V(n,e.from),e.op==="move"&&(a.removed=n),a;if(e.op==="test"){if(a.test=z(n,e.value),a.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",i,e,n);return a.newDocument=n,a}else{if(e.op==="remove")return a.removed=n,a.newDocument=null,a;if(e.op==="_get")return e.value=n,a;if(t)throw new g.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,n);return a}}else{r||(n=R._deepClone(n));var c=e.path||"",u=c.split("/"),o=n,l=1,f=u.length,d=void 0,h=void 0,m=void 0;for(typeof t=="function"?m=t:m=Y;;){if(h=u[l],h&&h.indexOf("~")!=-1&&(h=R.unescapePathComponent(h)),s&&(h=="__proto__"||h=="prototype"&&l>0&&u[l-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&d===void 0&&(o[h]===void 0?d=u.slice(0,l).join("/"):l==f-1&&(d=e.path),d!==void 0&&m(e,0,n,d)),l++,Array.isArray(o)){if(h==="-")h=o.length;else{if(t&&!R.isInteger(h))throw new g.JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",i,e,n);R.isInteger(h)&&(h=~~h)}if(l>=f){if(t&&e.op==="add"&&h>o.length)throw new g.JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,e,n);var a=wt[e.op].call(e,o,h,n);if(a.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",i,e,n);return a}}else if(l>=f){var a=L[e.op].call(e,o,h,n);if(a.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",i,e,n);return a}if(o=o[h],t&&l<f&&(!o||typeof o!="object"))throw new g.JsonPatchError("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,n)}}}g.applyOperation=O;function $e(n,e,t,r,s){if(r===void 0&&(r=!0),s===void 0&&(s=!0),t&&!Array.isArray(e))throw new g.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(n=R._deepClone(n));for(var i=new Array(e.length),a=0,c=e.length;a<c;a++)i[a]=O(n,e[a],t,!0,s,a),n=i[a].newDocument;return i.newDocument=n,i}g.applyPatch=$e;function St(n,e,t){var r=O(n,e);if(r.test===!1)throw new g.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",t,e,n);return r.newDocument}g.applyReducer=St;function Y(n,e,t,r){if(typeof n!="object"||n===null||Array.isArray(n))throw new g.JsonPatchError("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,n,t);if(L[n.op]){if(typeof n.path!="string")throw new g.JsonPatchError("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,n,t);if(n.path.indexOf("/")!==0&&n.path.length>0)throw new g.JsonPatchError('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,n,t);if((n.op==="move"||n.op==="copy")&&typeof n.from!="string")throw new g.JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&n.value===void 0)throw new g.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&R.hasUndefined(n.value))throw new g.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,n,t);if(t){if(n.op=="add"){var s=n.path.split("/").length,i=r.split("/").length;if(s!==i+1&&s!==i)throw new g.JsonPatchError("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,n,t)}else if(n.op==="replace"||n.op==="remove"||n.op==="_get"){if(n.path!==r)throw new g.JsonPatchError("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,n,t)}else if(n.op==="move"||n.op==="copy"){var a={op:"_get",path:n.from,value:void 0},c=Je([a],t);if(c&&c.name==="OPERATION_PATH_UNRESOLVABLE")throw new g.JsonPatchError("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,n,t)}}}else throw new g.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,n,t)}g.validator=Y;function Je(n,e,t){try{if(!Array.isArray(n))throw new g.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)$e(R._deepClone(e),R._deepClone(n),t||!0);else{t=t||Y;for(var r=0;r<n.length;r++)t(n[r],r,e,void 0)}}catch(s){if(s instanceof g.JsonPatchError)return s;throw s}}g.validate=Je;function z(n,e){if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){var t=Array.isArray(n),r=Array.isArray(e),s,i,a;if(t&&r){if(i=n.length,i!=e.length)return!1;for(s=i;s--!==0;)if(!z(n[s],e[s]))return!1;return!0}if(t!=r)return!1;var c=Object.keys(n);if(i=c.length,i!==Object.keys(e).length)return!1;for(s=i;s--!==0;)if(!e.hasOwnProperty(c[s]))return!1;for(s=i;s--!==0;)if(a=c[s],!z(n[a],e[a]))return!1;return!0}return n!==n&&e!==e}g._areEquals=z});var Be=$(k=>{Object.defineProperty(k,"__esModule",{value:!0});var b=G(),bt=de(),me=new WeakMap,Et=(function(){function n(e){this.observers=new Map,this.obj=e}return n})(),Rt=(function(){function n(e,t){this.callback=e,this.observer=t}return n})();function At(n){return me.get(n)}function Tt(n,e){return n.observers.get(e)}function xt(n,e){n.observers.delete(e.callback)}function Ct(n,e){e.unobserve()}k.unobserve=Ct;function Dt(n,e){var t=[],r,s=At(n);if(!s)s=new Et(n),me.set(n,s);else{var i=Tt(s,e);r=i&&i.observer}if(r)return r;if(r={},s.value=b._deepClone(n),e){r.callback=e,r.next=null;var a=function(){fe(r)},c=function(){clearTimeout(r.next),r.next=setTimeout(a)};typeof window<"u"&&(window.addEventListener("mouseup",c),window.addEventListener("keyup",c),window.addEventListener("mousedown",c),window.addEventListener("keydown",c),window.addEventListener("change",c))}return r.patches=t,r.object=n,r.unobserve=function(){fe(r),clearTimeout(r.next),xt(s,r),typeof window<"u"&&(window.removeEventListener("mouseup",c),window.removeEventListener("keyup",c),window.removeEventListener("mousedown",c),window.removeEventListener("keydown",c),window.removeEventListener("change",c))},s.observers.set(e,new Rt(e,r)),r}k.observe=Dt;function fe(n,e){e===void 0&&(e=!1);var t=me.get(n.object);pe(t.value,n.object,n.patches,"",e),n.patches.length&&bt.applyPatch(t.value,n.patches);var r=n.patches;return r.length>0&&(n.patches=[],n.callback&&n.callback(r)),r}k.generate=fe;function pe(n,e,t,r,s){if(e!==n){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=b._objectKeys(e),a=b._objectKeys(n),c=!1,u=!1,o=a.length-1;o>=0;o--){var l=a[o],f=n[l];if(b.hasOwnProperty(e,l)&&!(e[l]===void 0&&f!==void 0&&Array.isArray(e)===!1)){var d=e[l];typeof f=="object"&&f!=null&&typeof d=="object"&&d!=null&&Array.isArray(f)===Array.isArray(d)?pe(f,d,t,r+"/"+b.escapePathComponent(l),s):f!==d&&(c=!0,s&&t.push({op:"test",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(f)}),t.push({op:"replace",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(d)}))}else Array.isArray(n)===Array.isArray(e)?(s&&t.push({op:"test",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(f)}),t.push({op:"remove",path:r+"/"+b.escapePathComponent(l)}),u=!0):(s&&t.push({op:"test",path:r,value:n}),t.push({op:"replace",path:r,value:e}),c=!0)}if(!(!u&&i.length==a.length))for(var o=0;o<i.length;o++){var l=i[o];!b.hasOwnProperty(n,l)&&e[l]!==void 0&&t.push({op:"add",path:r+"/"+b.escapePathComponent(l),value:b._deepClone(e[l])})}}}function Ft(n,e,t){t===void 0&&(t=!1);var r=[];return pe(n,e,r,"",t),r}k.compare=Ft});var je=$(I=>{var Ot=de();Object.assign(I,Ot);var It=Be();Object.assign(I,It);var K=G();I.JsonPatchError=K.PatchError;I.deepClone=K._deepClone;I.escapePathComponent=K.escapePathComponent;I.unescapePathComponent=K.unescapePathComponent});nt();Ce();var q=class{constructor(e,t){this.createAdapter=e;this.config=t?.base??W,this.rvfPath=t?.rvfPath??".agentic-qe/patterns.rvf",this.skipCloseOnDispose=t?.skipCloseOnDispose??!1}createAdapter;config;rvfPath;skipCloseOnDispose;adapter=null;sqliteStore=null;initialized=!1;rvfInitError=null;searchOps=0;totalSearchMs=0;setSqliteStore(e){this.sqliteStore=e}getAdapter(){return this.adapter}async initialize(){if(!this.initialized){if(process.env.AQE_MEMORY_BACKEND==="memory"){this.adapter=null,this.initialized=!0;return}try{this.adapter=this.createAdapter(this.rvfPath,this.config.embeddingDimension),this.initialized=!0,console.log(`[RvfPatternStore] Initialized: ${this.rvfPath} (dim=${this.config.embeddingDimension})`)}catch(e){this.rvfInitError=v(e),console.error(`[RvfPatternStore] ERROR: RVF native init failed \u2014 vector search is DISABLED. Cause: ${this.rvfInitError}. Fix: install @ruvector/rvf-node native bindings, or set useRVFPatternStore=false to use SQLite HNSW.`),this.adapter=null,this.initialized=!0}if(!this.sqliteStore)try{let{createSQLitePatternStore:e}=await import("./sqlite-persistence-HPEVCTIB.js"),t=e();await t.initialize(),this.sqliteStore=t}catch{}await this.purgeOrphanedVectors()}}async purgeOrphanedVectors(){if(!(!this.adapter||!this.sqliteStore))try{let e=this.adapter.status()?.totalVectors??0,t=this.sqliteStore.getStats()?.totalPatterns??0;if(e<=t)return;let{readFileSync:r,existsSync:s}=await import("node:fs"),i=`${this.rvfPath}.idmap.json`;if(!s(i))return;let a=JSON.parse(r(i,"utf-8")),c=new Set((a.entries??[]).map(l=>Array.isArray(l)?l[0]:void 0).filter(l=>typeof l=="string")),u=new Set(this.sqliteStore.getPatterns({limit:1e4}).map(l=>l.id)),o=[...c].filter(l=>!u.has(l));if(o.length===0)return;this.adapter.delete(o),console.log(`[RvfPatternStore] Removed ${o.length} ghost vectors (index ${e} > DB ${t})`)}catch(e){console.warn(`[RvfPatternStore] orphan purge skipped: ${v(e)}`)}}async dispose(){if(this.adapter&&!this.skipCloseOnDispose)try{this.adapter.close()}catch{}this.adapter=null,this.initialized=!1}async store(e){await this.ensureInitialized();let t=j(e);if(!t.valid)return w(new Error(`Invalid pattern: ${t.errors.join(", ")}`));if(e.confidence<this.config.minConfidence)return w(new Error(`Pattern confidence ${e.confidence} below threshold ${this.config.minConfidence}`));if(this.sqliteStore)try{let r=this.sqliteStore.storePattern(e,e.embedding);r&&r!==e.id&&(e.id=r)}catch(r){console.warn(`[RvfPatternStore] SQLite persist failed for ${e.id}:`,v(r))}if(e.embedding&&this.adapter)try{let r=e.embedding instanceof Float32Array?e.embedding:new Float32Array(e.embedding);this.adapter.ingest([{id:e.id,vector:r}])}catch(r){console.warn(`[RvfPatternStore] RVF ingest failed for ${e.id}:`,v(r))}return P(e.id)}async create(e){let t=e.confidence??.5,r=e.qeDomain??"test-generation",s={id:C(),patternType:e.patternType,qeDomain:r,domain:r,name:e.name,description:e.description,confidence:t,usageCount:0,successRate:0,qualityScore:J({confidence:t,usageCount:0,successRate:0}),context:{tags:[],...e.context},template:{example:"",...e.template},embedding:e.embedding,tier:"short-term",createdAt:new Date,lastUsedAt:new Date,successfulUses:0,reusable:!1,reuseCount:0,averageTokenSavings:0},i=await this.store(s);return i.success?P(s):w(i.error)}async get(e){if(this.sqliteStore)try{return this.sqliteStore.getPattern(e)??null}catch{return null}return null}async search(e,t={}){await this.ensureInitialized();let r=performance.now(),s=t.limit??10,i=[];if(Array.isArray(e)&&this.adapter)try{let c=e instanceof Float32Array?e:new Float32Array(e),u=this.adapter.search(c,s*2);for(let o of u){let l=await this.get(o.id);if(l&&this.matchesFilters(l,t)){let f=this.calculateReuseInfo(l,o.score);i.push({pattern:l,score:o.score,matchType:"vector",similarity:o.score,canReuse:f.canReuse,estimatedTokenSavings:f.estimatedTokenSavings,reuseConfidence:f.reuseConfidence})}}}catch(c){console.warn("[RvfPatternStore] RVF search failed:",v(c))}if(Array.isArray(e)&&!this.adapter&&this.sqliteStore&&i.length===0)try{let c=this.sqliteStore.getPatterns({limit:s*4}),u=e,o=Math.sqrt(u.reduce((l,f)=>l+f*f,0));if(o>0)for(let l of c){if(!this.matchesFilters(l,t))continue;let f=this.sqliteStore.getPattern(l.id),d=f?.embedding;if(!d||d.length!==u.length)continue;let h=0,m=0;for(let S=0;S<u.length;S++)h+=u[S]*d[S],m+=d[S]*d[S];if(m=Math.sqrt(m),m===0)continue;let p=h/(o*m),y=this.calculateReuseInfo(f,p);i.push({pattern:f,score:p,matchType:"vector",similarity:p,canReuse:y.canReuse,estimatedTokenSavings:y.estimatedTokenSavings,reuseConfidence:y.reuseConfidence})}}catch{}if(typeof e=="string"&&!e.trim()&&this.sqliteStore)try{let c=this.sqliteStore.getPatterns({limit:s*2}),u=new Set(i.map(o=>o.pattern.id));for(let o of c){if(u.has(o.id)||!this.matchesFilters(o,t))continue;let l=this.calculateReuseInfo(o,o.confidence);i.push({pattern:o,score:o.confidence,matchType:"exact",similarity:o.confidence,canReuse:l.canReuse,estimatedTokenSavings:l.estimatedTokenSavings,reuseConfidence:l.reuseConfidence})}}catch{}if(typeof e=="string"&&e.trim()&&this.sqliteStore)try{let c=this.sqliteStore.searchFTS(e,s*2),u=new Set(i.map(o=>o.pattern.id));for(let o of c){if(u.has(o.id))continue;let l=await this.get(o.id);if(l&&this.matchesFilters(l,t)){let f=this.calculateReuseInfo(l,o.ftsScore);i.push({pattern:l,score:.5*o.ftsScore,matchType:"exact",similarity:o.ftsScore,canReuse:f.canReuse,estimatedTokenSavings:f.estimatedTokenSavings,reuseConfidence:f.reuseConfidence})}}}catch{}i.sort((c,u)=>u.score-c.score);let a=performance.now()-r;return this.searchOps++,this.totalSearchMs+=a,P(i.slice(0,s))}async recordUsage(e,t,r,s){if(!this.sqliteStore)return w(new Error("No SQLite store attached"));try{return this.sqliteStore.recordUsage(e,t,r,s),P(void 0)}catch(i){return w(new Error(`recordUsage failed: ${v(i)}`))}}async promote(e){if(!this.sqliteStore)return w(new Error("No SQLite store attached"));try{return this.sqliteStore.promotePattern(e),P(void 0)}catch(t){return w(new Error(`promote failed: ${v(t)}`))}}async delete(e){if(this.adapter)try{this.adapter.delete([e])}catch(t){console.warn(`[RvfPatternStore] RVF delete failed for ${e}:`,v(t))}if(this.sqliteStore)try{this.sqliteStore.deletePattern(e)}catch(t){return w(new Error(`SQLite delete failed: ${v(t)}`))}return P(void 0)}async getStats(){let e=this.adapter?.status(),t=0,r={},s={shortTerm:0,longTerm:0};if(this.sqliteStore)try{let i=this.sqliteStore.getStats();t=i.totalPatterns,r=i.byDomain,s={shortTerm:i.byTier["short-term"]??0,longTerm:i.byTier["long-term"]??0}}catch{}return{totalPatterns:t,byTier:s,byDomain:r,byType:{},avgConfidence:0,avgQualityScore:0,avgSuccessRate:0,searchOperations:this.searchOps,avgSearchLatencyMs:this.searchOps>0?this.totalSearchMs/this.searchOps:0,hnswStats:{nativeAvailable:this.adapter!==null,vectorCount:e?.totalVectors??0,indexSizeBytes:e?.fileSizeBytes??0,...this.rvfInitError?{rvfInitError:this.rvfInitError}:{}}}}async cleanup(){if(!this.sqliteStore)return{removed:0,promoted:0};let e=0,t=0;try{let r=this.sqliteStore.getPatterns({limit:1e4});for(let s of r)s.confidence<this.config.minConfidence&&s.usageCount>3?(await this.delete(s.id),e++):s.tier==="short-term"&&s.successfulUses>=B&&(await this.promote(s.id),t++)}catch(r){console.warn("[RvfPatternStore] Cleanup error:",v(r))}return{removed:e,promoted:t}}async ensureInitialized(){this.initialized||await this.initialize()}matchesFilters(e,t){return!(t.patternType&&e.patternType!==t.patternType||t.domain&&e.qeDomain!==t.domain||t.tier&&e.tier!==t.tier||t.minConfidence&&e.confidence<t.minConfidence||t.minQualityScore&&e.qualityScore<t.minQualityScore)}calculateReuseInfo(e,t){let r=this.config.reuseOptimization,s=r.enabled&&t>=r.minSimilarityForReuse&&e.successRate>=r.minSuccessRateForReuse;return{canReuse:s,estimatedTokenSavings:s?500:0,reuseConfidence:s?t*e.successRate:0}}};it();Ce();F();function at(n,e){let r=[n.pattern,n];for(let s of r){let i=e.split("."),a=s;for(let c of i){if(a==null)break;if(typeof a=="object")a=a[c];else{a=void 0;break}}if(a!==void 0)return a}}function ot(n,e,t){switch(e){case"eq":return n===t;case"gt":return typeof n=="number"&&typeof t=="number"&&n>t;case"lt":return typeof n=="number"&&typeof t=="number"&&n<t;case"gte":return typeof n=="number"&&typeof t=="number"&&n>=t;case"lte":return typeof n=="number"&&typeof t=="number"&&n<=t;case"in":return Array.isArray(t)?t.includes(n):!1;case"contains":return Array.isArray(n)||typeof n=="string"&&typeof t=="string"?n.includes(t):!1;case"between":{if(typeof n!="number"||!Array.isArray(t)||t.length!==2){if(n instanceof Date&&Array.isArray(t)&&t.length===2){let i=n.getTime(),a=t[0]instanceof Date?t[0].getTime():Number(t[0]),c=t[1]instanceof Date?t[1].getTime():Number(t[1]);return i>=a&&i<=c}return!1}let[r,s]=t;return n>=r&&n<=s}default:return!1}}function X(n,e){switch(e.type){case"AND":return(e.children??[]).every(r=>X(n,r));case"OR":{let t=e.children??[];return t.length===0?!0:t.some(r=>X(n,r))}case"NOT":return e.child?!X(n,e.child):!0;case"FIELD":{if(!e.field||!e.operator)return!0;let t=at(n,e.field);return ot(t,e.operator,e.value)}default:return!0}}function Ne(n,e){return e?n.filter(t=>X(t,e)):n}F();F();var Me=1e4,Le=2166136261;function ke(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}var oe=new Uint8Array(256);for(let n=0;n<256;n++){let e=0,t=n;for(;t;)e++,t&=t-1;oe[n]=e}var He="0123456789abcdef";function ct(n){let e=Math.min(n.length,16),t="";for(let r=0;r<e;r++){let s=n[r];t+=He[s>>4]+He[s&15]}return t}function lt(n,e){if(n.length!==e.length)throw new Error(`Cannot bind vectors of different lengths: ${n.length} vs ${e.length}`);let t=new Uint8Array(n.length);for(let r=0;r<n.length;r++)t[r]=n[r]^e[r];return t}function ut(n){if(n.length===0)throw new Error("Cannot bundle zero vectors");let e=n[0].length;for(let s=1;s<n.length;s++)if(n[s].length!==e)throw new Error(`Vector length mismatch at index ${s}: expected ${e}, got ${n[s].length}`);let t=new Uint8Array(e),r=n.length/2;for(let s=0;s<e;s++){let i=0;for(let a=0;a<8;a++){let c=0,u=1<<a;for(let o=0;o<n.length;o++)n[o][s]&u&&c++;c>=r&&(i|=u)}t[s]=i}return t}function ht(n,e,t){if(n.length!==e.length)throw new Error(`Cannot compute Hamming distance for vectors of different lengths: ${n.length} vs ${e.length}`);let r=0;for(let i=0;i<n.length;i++)r+=oe[n[i]^e[i]];let s=t??n.length*8;return s>0?r/s:0}function dt(n,e,t){return 1-ht(n,e,t)}var se=class{dimensions;baseSeed;byteLen;tokenCache=new Map;constructor(e){if(this.dimensions=e?.dimensions??Me,this.baseSeed=e?.seed??Le,this.byteLen=Math.ceil(this.dimensions/8),this.dimensions<=0)throw new Error(`HDC dimensions must be positive, got ${this.dimensions}`)}tokenToHypervector(e){let t=this.tokenCache.get(e);if(t)return new Uint8Array(t);let r=ke(e)^this.baseSeed,s=this.generateSeededVector(r);return this.tokenCache.set(e,s),new Uint8Array(s)}fingerprintPattern(e){if(e.length===0)return new Uint8Array(this.byteLen);let t=this.tokenToHypervector(e[0]);for(let r=1;r<e.length;r++)t=lt(t,this.tokenToHypervector(e[r]));return t}fingerprintWithContext(e,t){let r=this.fingerprintPattern(e);if(t.length===0)return r;let s=this.fingerprintPattern(t);return ut([r,s])}similarity(e,t){return dt(e,t,this.dimensions)}generateSeededVector(e){let t=new Uint8Array(this.byteLen),r=new ne(e),s=0;for(;s<this.byteLen;){let a=r.next(),c=Math.min(4,this.byteLen-s);for(let u=0;u<c;u++)t[s++]=a>>>u*8&255}let i=this.dimensions%8;return i>0&&(t[this.byteLen-1]&=(1<<i)-1),t}},ae=class{dimensions;baseSeed;constructor(e){if(this.dimensions=e?.dimensions??Me,this.baseSeed=e?.seed??Le,this.dimensions<=0)throw new Error(`HDC dimensions must be positive, got ${this.dimensions}`)}fingerprint(e){let t=`${e.id}|${e.domain}|${e.type}|${e.content??""}`,r=ke(t)^this.baseSeed,s=this.generateVector(r);return{vector:s,dimensions:this.dimensions,hash:ct(s)}}compositionalBind(e,t){if(e.length!==t.length)throw new Error(`Cannot bind vectors of different lengths: ${e.length} vs ${t.length}`);let r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e[s]^t[s];return r}hammingDistance(e,t){if(e.length!==t.length)throw new Error(`Cannot compute Hamming distance for vectors of different lengths: ${e.length} vs ${t.length}`);let r=0;for(let s=0;s<e.length;s++)r+=oe[e[s]^t[s]];return r}similarity(e,t){return 1-this.hammingDistance(e,t)/this.dimensions}batchFingerprint(e){return e.map(t=>this.fingerprint(t))}generateVector(e){let t=Math.ceil(this.dimensions/8),r=new Uint8Array(t),s=new ne(e),i=0;for(;i<t;){let c=s.next(),u=t-i,o=u<4?u:4;for(let l=0;l<o;l++)r[i++]=c>>>l*8&255}let a=this.dimensions%8;return a>0&&(r[t-1]&=(1<<a)-1),r}};function Ue(n){return new ae(n)}function Qe(n){return Q()?new se(n):null}var ye=rt(je(),1),ge=ye.default??ye,_t=`
|
|
4
|
-
CREATE TABLE IF NOT EXISTS pattern_deltas (
|
|
5
|
-
id TEXT PRIMARY KEY,
|
|
6
|
-
pattern_id TEXT NOT NULL,
|
|
7
|
-
version INTEGER NOT NULL,
|
|
8
|
-
timestamp INTEGER NOT NULL,
|
|
9
|
-
type TEXT NOT NULL CHECK (type IN ('genesis', 'update', 'rollback')),
|
|
10
|
-
patch TEXT NOT NULL DEFAULT '[]',
|
|
11
|
-
reverse_patch TEXT NOT NULL DEFAULT '[]',
|
|
12
|
-
metadata TEXT
|
|
13
|
-
);
|
|
14
|
-
CREATE INDEX IF NOT EXISTS idx_pattern_deltas_pid_version
|
|
15
|
-
ON pattern_deltas (pattern_id, version);
|
|
16
|
-
CREATE INDEX IF NOT EXISTS idx_pattern_deltas_timestamp
|
|
17
|
-
ON pattern_deltas (timestamp);
|
|
18
|
-
`;function We(n,e){let t=ge.compare(n,e),r=ge.compare(e,n);return{forward:t,reverse:r}}function Nt(n,e){let t=JSON.parse(JSON.stringify(n));return ge.applyPatch(t,e).newDocument}function Xe(n){return{id:n.id,patternId:n.pattern_id,version:n.version,timestamp:n.timestamp,type:n.type,patch:JSON.parse(n.patch),reversePatch:JSON.parse(n.reverse_patch),metadata:n.metadata?JSON.parse(n.metadata):void 0}}var Z=class{db;config;prepared=new Map;initialized=!1;constructor(e,t){this.db=e,this.config={maxVersionsPerPattern:t?.maxVersionsPerPattern??100,compressDeltas:t?.compressDeltas??!1}}initialize(){this.initialized||(this.db.exec(_t),this.prepareStatements(),this.initialized=!0)}prepareStatements(){this.prepared.set("insert",this.db.prepare(`
|
|
19
|
-
INSERT INTO pattern_deltas (id, pattern_id, version, timestamp, type, patch, reverse_patch, metadata)
|
|
20
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
21
|
-
`)),this.prepared.set("getHistory",this.db.prepare(`
|
|
22
|
-
SELECT * FROM pattern_deltas
|
|
23
|
-
WHERE pattern_id = ?
|
|
24
|
-
ORDER BY version ASC
|
|
25
|
-
`)),this.prepared.set("currentVersion",this.db.prepare(`
|
|
26
|
-
SELECT MAX(version) as max_version FROM pattern_deltas
|
|
27
|
-
WHERE pattern_id = ?
|
|
28
|
-
`)),this.prepared.set("incrementalSync",this.db.prepare(`
|
|
29
|
-
SELECT * FROM pattern_deltas
|
|
30
|
-
WHERE timestamp > ?
|
|
31
|
-
ORDER BY timestamp ASC
|
|
32
|
-
`)),this.prepared.set("countForPattern",this.db.prepare(`
|
|
33
|
-
SELECT COUNT(*) as cnt FROM pattern_deltas
|
|
34
|
-
WHERE pattern_id = ?
|
|
35
|
-
`)),this.prepared.set("deleteOldest",this.db.prepare(`
|
|
36
|
-
DELETE FROM pattern_deltas
|
|
37
|
-
WHERE pattern_id = ? AND version IN (
|
|
38
|
-
SELECT version FROM pattern_deltas
|
|
39
|
-
WHERE pattern_id = ?
|
|
40
|
-
ORDER BY version ASC
|
|
41
|
-
LIMIT ?
|
|
42
|
-
)
|
|
43
|
-
`))}ensureInitialized(){if(!this.initialized)throw new Error("DeltaTracker not initialized. Call initialize() first.")}createGenesis(e,t,r){this.ensureInitialized();let s=this.getCurrentVersion(e);if(s>=0)throw new Error(`Genesis already exists for pattern ${e} (current version: ${s})`);let i={id:C(),patternId:e,version:0,timestamp:Date.now(),type:"genesis",patch:[],reversePatch:[],metadata:{...r,snapshot:t}};return this.insertEvent(i),i}recordDelta(e,t,r,s){this.ensureInitialized();let i=this.getCurrentVersion(e);if(i<0)throw new Error(`No genesis found for pattern ${e}. Call createGenesis() first.`);let{forward:a,reverse:c}=We(t,r),u={id:C(),patternId:e,version:i+1,timestamp:Date.now(),type:"update",patch:a,reversePatch:c,metadata:s};return this.insertEvent(u),this.enforceRetention(e),u}rollback(e,t){this.ensureInitialized();let r=this.getHistory(e);if(r.length===0)throw new Error(`No history found for pattern ${e}`);let s=r[r.length-1].version;if(t<0||t>s)throw new Error(`Invalid rollback version ${t}. Valid range: 0-${s}`);if(t===s)return this.reconstructState(r,s);let i=this.reconstructState(r,t),a=this.reconstructState(r,s),{forward:c,reverse:u}=We(a,i),o={id:C(),patternId:e,version:s+1,timestamp:Date.now(),type:"rollback",patch:c,reversePatch:u,metadata:{rolledBackTo:t}};return this.insertEvent(o),this.enforceRetention(e),i}getHistory(e){return this.ensureInitialized(),this.prepared.get("getHistory").all(e).map(Xe)}incrementalSync(e){return this.ensureInitialized(),this.prepared.get("incrementalSync").all(e).map(Xe)}getCurrentVersion(e){return this.ensureInitialized(),this.prepared.get("currentVersion").get(e).max_version??-1}insertEvent(e){this.prepared.get("insert").run(e.id,e.patternId,e.version,e.timestamp,e.type,JSON.stringify(e.patch),JSON.stringify(e.reversePatch),e.metadata?JSON.stringify(e.metadata):null)}reconstructState(e,t){let r=e.find(i=>i.type==="genesis");if(!r||!r.metadata?.snapshot)throw new Error("Cannot reconstruct state: no genesis snapshot found");let s=JSON.parse(JSON.stringify(r.metadata.snapshot));for(let i of e)if(i.version!==0){if(i.version>t)break;s=Nt(s,i.patch)}return s}enforceRetention(e){let{maxVersionsPerPattern:t}=this.config,s=this.prepared.get("countForPattern").get(e).cnt;if(s>t){let i=s-t;this.db.prepare(`DELETE FROM pattern_deltas
|
|
44
|
-
WHERE pattern_id = ? AND version != 0 AND id IN (
|
|
45
|
-
SELECT id FROM pattern_deltas
|
|
46
|
-
WHERE pattern_id = ? AND version != 0
|
|
47
|
-
ORDER BY version ASC
|
|
48
|
-
LIMIT ?
|
|
49
|
-
)`).run(e,e,i)}}};F();var Ht={maxHistoryPerPattern:50,snapshotInterval:10,batchSize:20,epsilon:1e-7},ve=class{config;history=new Map;snapshots=new Map;versions=new Map;buffer=[];constructor(e){this.config={...Ht,...e}}recordGenesis(e,t,r){if(this.versions.has(e))throw new Error(`Genesis already exists for pattern ${e} (version ${this.versions.get(e)})`);let s=this.computeSparseChanges(new Array(t.length).fill(0),t),i={patternId:e,version:0,timestamp:Date.now(),deltaType:"genesis",sparseChanges:s,metadata:r,compressedSize:s.length},a={patternId:e,version:0,fullVector:[...t],timestamp:i.timestamp};return this.versions.set(e,0),this.getOrCreate(this.history,e).push(i),this.getOrCreate(this.snapshots,e).push(a),this.buffer.push(i),i}recordDelta(e,t,r,s){let i=this.versions.get(e);if(i===void 0)throw new Error(`No genesis found for pattern ${e}. Call recordGenesis() first.`);let a=i+1,c=this.computeSparseChanges(t,r),u={patternId:e,version:a,timestamp:Date.now(),deltaType:"update",sparseChanges:c,metadata:s,compressedSize:c.length};return this.versions.set(e,a),this.getOrCreate(this.history,e).push(u),this.buffer.push(u),a%this.config.snapshotInterval===0&&this.getOrCreate(this.snapshots,e).push({patternId:e,version:a,fullVector:[...r],timestamp:u.timestamp}),this.enforceRetention(e),u}getHistory(e,t){let r=this.history.get(e);if(!r||r.length===0)return[];let s=[...r].reverse();return t!==void 0&&t>0?s.slice(0,t):s}rollback(e,t){let r=this.reconstructAtVersion(e,t);return r===null?null:{patternId:e,version:t,fullVector:r,timestamp:Date.now()}}getVersion(e){return this.versions.get(e)??-1}reconstructAtVersion(e,t){let r=this.history.get(e);if(!r||r.length===0)return null;let s=this.versions.get(e);if(t<0||t>s)return null;let i=this.snapshots.get(e)||[],a=null;for(let o=i.length-1;o>=0;o--)if(i[o].version<=t){a=i[o];break}if(!a)return null;let c=[...a.fullVector],u=a.version+1;for(let o of r)if(!(o.version<u)){if(o.version>t)break;this.applySparseForward(c,o.sparseChanges)}return c}pruneHistory(e,t){let r=t??this.config.maxHistoryPerPattern,s=this.history.get(e);if(!s||s.length<=r)return 0;let i=s.length-r,a=s.slice(0,i),c=s.slice(i),u=a.findIndex(f=>f.deltaType==="genesis");u>=0&&(c.unshift(a[u]),a.splice(u,1)),this.history.set(e,c);let o=c[0]?.version??0,l=this.snapshots.get(e);return l&&this.snapshots.set(e,l.filter(f=>f.version===0||f.version>=o)),a.length}getStats(){let e=0;for(let r of this.history.values())e+=r.length;let t=this.history.size;return{totalPatterns:t,totalDeltas:e,avgDeltasPerPattern:t>0?e/t:0}}flush(){let e=[...this.buffer];return this.buffer.length=0,e}getBufferSize(){return this.buffer.length}clear(){this.history.clear(),this.snapshots.clear(),this.versions.clear(),this.buffer.length=0}computeSparseChanges(e,t){let r=[],s=Math.max(e.length,t.length);for(let i=0;i<s;i++){let a=i<e.length?e[i]:0,c=i<t.length?t[i]:0;Math.abs(a-c)>this.config.epsilon&&r.push({index:i,oldValue:a,newValue:c})}return r}applySparseForward(e,t){for(let r of t){for(;e.length<=r.index;)e.push(0);e[r.index]=r.newValue}}enforceRetention(e){this.pruneHistory(e,this.config.maxHistoryPerPattern)}getOrCreate(e,t){let r=e.get(t);return r||(r=[],e.set(t,r)),r}};function Ge(n){return H()?new ve(n):null}F();var Mt=128,Lt=8,kt=1e4,Pe=class{dimension;beta;maxPatterns;patterns;constructor(e){if(this.dimension=e?.dimension??Mt,this.beta=e?.beta??Lt,this.maxPatterns=e?.maxPatterns??kt,this.patterns=[],this.dimension<=0)throw new Error(`Hopfield dimension must be positive, got ${this.dimension}`);if(this.beta<=0)throw new Error(`Hopfield beta must be positive, got ${this.beta}`);if(this.maxPatterns<=0)throw new Error(`Hopfield maxPatterns must be positive, got ${this.maxPatterns}`)}store(e,t){if(this.assertEnabled(),e.length!==this.dimension)throw new Error(`Pattern dimension mismatch: expected ${this.dimension}, got ${e.length}`);if(this.dotProduct(e,e)===0)throw new Error("Cannot store zero-magnitude pattern in Hopfield memory");let s=this.normalize(e);this.patterns.length>=this.maxPatterns&&this.patterns.shift(),this.patterns.push({pattern:s,metadata:t??{},storedAt:Date.now()})}recall(e){if(this.assertEnabled(),e.length!==this.dimension)throw new Error(`Query dimension mismatch: expected ${this.dimension}, got ${e.length}`);if(this.patterns.length===0)return null;let t=this.normalize(e),r=new Float32Array(this.patterns.length);for(let l=0;l<this.patterns.length;l++)r[l]=this.beta*this.dotProduct(this.patterns[l].pattern,t);let s=this.softmax(r),i=0,a=s[0];for(let l=1;l<s.length;l++)s[l]>a&&(a=s[l],i=l);let c=this.patterns[i],u=this.getEnergy(t),o=this.cosineSimilarity(t,c.pattern);return{pattern:new Float32Array(c.pattern),metadata:{...c.metadata},energy:u,similarity:o}}batchRecall(e){return this.assertEnabled(),e.map(t=>this.recall(t))}getPatternCount(){return this.patterns.length}clear(){this.patterns.length=0}getEnergy(e){if(e.length!==this.dimension)throw new Error(`State dimension mismatch: expected ${this.dimension}, got ${e.length}`);let t=this.normalize(e);if(this.patterns.length===0)return .5*this.dotProduct(t,t);let r=new Float32Array(this.patterns.length);for(let o=0;o<this.patterns.length;o++)r[o]=this.dotProduct(this.patterns[o].pattern,t);let s=new Float32Array(this.patterns.length),i=-1/0;for(let o=0;o<this.patterns.length;o++)s[o]=this.beta*r[o],s[o]>i&&(i=s[o]);let a=0;for(let o=0;o<this.patterns.length;o++)a+=Math.exp(s[o]-i);let c=1/this.beta*(i+Math.log(a)),u=this.dotProduct(t,t);return-c+.5*u}softmax(e){let t=new Float32Array(e.length),r=-1/0;for(let i=0;i<e.length;i++)e[i]>r&&(r=e[i]);let s=0;for(let i=0;i<e.length;i++)t[i]=Math.exp(e[i]-r),s+=t[i];if(s>0)for(let i=0;i<t.length;i++)t[i]/=s;return t}dotProduct(e,t){let r=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s];return r}cosineSimilarity(e,t){let r=this.dotProduct(e,t),s=Math.sqrt(this.dotProduct(e,e)),i=Math.sqrt(this.dotProduct(t,t));return s===0||i===0?0:r/(s*i)}normalize(e){let t=Math.sqrt(this.dotProduct(e,e)),r=new Float32Array(e.length);if(t>0)for(let s=0;s<e.length;s++)r[s]=e[s]/t;return r}assertEnabled(){if(!D().useHopfieldMemory)throw new Error("Hopfield memory is disabled (useHopfieldMemory feature flag is false)")}};function Ve(n){return new Pe(n)}F();var Ut={dimensions:32,curvature:-1,maxElements:1e4,efConstruction:200,M:16},_=1e-5,Ye=1-_;function Qt(n,e){let t=0;for(let r=0;r<n.length;r++)t+=n[r]*e[r];return t}function A(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t]*n[t];return e}function qt(n,e){let t=new Float32Array(n.length);for(let r=0;r<n.length;r++)t[r]=n[r]-e[r];return t}var T=class n{static poincareDistance(e,t){let r=A(qt(e,t)),s=Math.max(_,1-A(e)),i=Math.max(_,1-A(t));return Math.acosh(Math.max(1,1+2*r/(s*i)))}static mobiusAdd(e,t){let r=Qt(e,t),s=A(e),i=A(t),a=Math.max(_,1+2*r+s*i),c=1+2*r+i,u=1-s,o=new Float32Array(e.length);for(let l=0;l<e.length;l++)o[l]=(c*e[l]+u*t[l])/a;return n.project(o)}static expMap(e,t){let r=2/Math.max(_,1-A(e)),s=Math.sqrt(A(t));if(s<_)return new Float32Array(e);let i=Math.tanh(r*s/2),a=new Float32Array(t.length);for(let c=0;c<t.length;c++)a[c]=i/s*t[c];return n.mobiusAdd(e,a)}static project(e){let t=Math.sqrt(A(e));if(t<=Ye)return new Float32Array(e);let r=Ye/t,s=new Float32Array(e.length);for(let i=0;i<e.length;i++)s[i]=e[i]*r;return s}static euclideanToHyperbolic(e){let t=Math.sqrt(A(e));if(t<_)return new Float32Array(e.length);let r=Math.tanh(t)/t,s=new Float32Array(e.length);for(let i=0;i<e.length;i++)s[i]=e[i]*r;return n.project(s)}},we=class{config;points=new Map;constructor(e){if(this.config={...Ut,...e},this.config.dimensions<=0)throw new Error(`dimensions must be positive, got ${this.config.dimensions}`);if(this.config.curvature>=0)throw new Error(`curvature must be negative for hyperbolic space, got ${this.config.curvature}`);if(this.config.maxElements<=0)throw new Error(`maxElements must be positive, got ${this.config.maxElements}`)}insert(e,t,r){if(t.length!==this.config.dimensions)throw new Error(`Dimension mismatch: expected ${this.config.dimensions}, got ${t.length}`);if(this.points.size>=this.config.maxElements)throw new Error(`Maximum elements (${this.config.maxElements}) reached`);this.points.set(e,{id:e,coordinates:T.project(t),metadata:r?{...r}:void 0})}search(e,t){if(e.length!==this.config.dimensions)throw new Error(`Query dimension mismatch: expected ${this.config.dimensions}, got ${e.length}`);let r=T.project(e),s=[];for(let i of this.points.values())s.push({id:i.id,distance:T.poincareDistance(r,i.coordinates),point:i});return s.sort((i,a)=>i.distance-a.distance),s.slice(0,Math.max(0,t))}embedHierarchy(e){let t=new Map;if(e.length===0)return t;let r=this.config.dimensions,s=new Map,i=new Map,a=[];for(let u of e)if(i.set(u.id,u),!u.parentId)a.push(u.id);else{let o=s.get(u.parentId);o||(o=[],s.set(u.parentId,o)),o.push(u.id)}let c=a.map((u,o)=>({id:u,depth:0,angOff:2*Math.PI*o/Math.max(1,a.length),angSpan:2*Math.PI/Math.max(1,a.length)}));for(;c.length>0;){let{id:u,depth:o,angOff:l,angSpan:f}=c.shift(),d=Math.tanh(.3*(o+.1)),h=l+f/2,m=new Float32Array(r);m[0]=d*Math.cos(h),m[1]=d*Math.sin(h);let p=i.get(u);if(p&&p.features.length>0){let N=d*.1;for(let x=2;x<r&&x-2<p.features.length;x++)m[x]=p.features[x-2]*N}let y=T.project(m);t.set(u,y),this.points.set(u,{id:u,coordinates:y,metadata:{depth:o,parentId:p?.parentId}});let S=s.get(u)??[];for(let N=0;N<S.length;N++){let x=f/Math.max(1,S.length);c.push({id:S[N],depth:o+1,angOff:l+N*x,angSpan:x})}}return t}getStats(){return{elementCount:this.points.size,dimensions:this.config.dimensions,curvature:this.config.curvature}}};function Ke(n){return zt()?new we(n):null}function zt(){return D().useHyperbolicHnsw}F();var Se=class{index=null;initialized=!1;config;constructor(e){this.config=e??{}}ensureInitialized(){if(this.initialized)return this.index!==null;if(this.initialized=!0,!M())return!1;try{return this.index=Ke(this.config),this.index!==null}catch(e){return console.warn("[HyperbolicPatternIndex] Failed to create HyperbolicHNSW:",e instanceof Error?e.message:e),this.index=null,!1}}get isAvailable(){return this.index!==null}indexPattern(e,t,r){if(!(!this.ensureInitialized()||!this.index))try{let s=t instanceof Float32Array?t:new Float32Array(t),i=T.euclideanToHyperbolic(s);this.index.insert(e,i,r)}catch(s){console.debug(`[HyperbolicPatternIndex] Failed to index pattern ${e}:`,s instanceof Error?s.message:s)}}search(e,t){if(!this.ensureInitialized()||!this.index)return[];try{let r=e instanceof Float32Array?e:new Float32Array(e),s=T.euclideanToHyperbolic(r);return this.index.search(s,t).map(a=>({patternId:a.id,distance:a.distance,metadata:a.point.metadata}))}catch(r){return console.warn("[HyperbolicPatternIndex] Search failed:",r instanceof Error?r.message:r),[]}}getStats(){return this.index?this.index.getStats():null}reset(){this.index=null,this.initialized=!1}};function Ze(n){return new Se(n)}var be=null;function et(){return be||(be=Ue({dimensions:1e4})),be}var Ee;function $t(){return Ee===void 0&&(Ee=Qe()),Ee}var U=null,Re=0;function tt(n){return(!U||Re!==n)&&(U=Ve({dimension:n,maxPatterns:1e4}),Re=n),U}var W={namespace:"qe-patterns",embeddingDimension:384,hnsw:{M:16,efConstruction:200,efSearch:100,maxElements:5e4},promotionThreshold:B,minConfidence:.3,maxPatternsPerDomain:5e3,autoCleanup:!0,cleanupIntervalMs:36e5,tokenTracking:{enabled:!0,trackInputOutput:!0,estimateCosts:!0,costPerInputToken:3e-6,costPerOutputToken:15e-6},reuseOptimization:{enabled:!0,minSimilarityForReuse:.85,minSuccessRateForReuse:.9,maxAgeForReuse:7}},Ae=class{constructor(e,t={}){this.memory=e;this.config={...W,...t}}memory;config;initialized=!1;cleanupTimer;sqliteStore=null;nullStore=null;loadingPromise=null;patternCache=new Map;domainIndex=new Map;typeIndex=new Map;tierIndex=new Map;hnswIndex=null;hnswAvailable=!1;hnswInitPromise=null;hdcCache=new Map;hdcTokenCache=new Map;deltaTracker=null;vectorDeltaTracker=void 0;hyperbolicIndex=null;stats={searchOperations:0,searchLatencies:[]};setSqliteStore(e){if(this.sqliteStore=e,H()&&!this.deltaTracker)try{let t=e.getDb();this.deltaTracker=new Z(t),this.deltaTracker.initialize(),console.log("[PatternStore] Delta event sourcing initialized")}catch(t){console.warn("[PatternStore] Delta tracker init failed:",t instanceof Error?t.message:t)}this.initialized&&(this.loadingPromise=this.loadPatterns().catch(t=>console.warn("[PatternStore] Failed to load patterns after setSqliteStore:",t)).finally(()=>{this.loadingPromise=null}))}async initialize(){this.initialized||(this.tierIndex.set("short-term",new Set),this.tierIndex.set("long-term",new Set),await this.loadPatterns(),this.config.autoCleanup&&(this.cleanupTimer=setInterval(()=>this.cleanup(),this.config.cleanupIntervalMs)),this.initialized=!0)}async ensureHNSW(){return this.hnswIndex!==null?this.hnswIndex:this.hnswAvailable===!1&&this.hnswInitPromise===null&&!(this.hnswIndex===null&&this.hnswAvailable===!1)?null:this.hnswInitPromise?(await this.hnswInitPromise,this.hnswIndex):(this.hnswInitPromise=this.initializeHNSWInternal(),await this.hnswInitPromise,this.hnswInitPromise=null,this.hnswIndex)}async initializeHNSWInternal(){try{if(D().useUnifiedHnsw)try{let{HnswLegacyBridge:a}=await import("./hnsw-legacy-bridge-NDZSNMYX.js"),{HnswAdapter:c}=await import("./hnsw-adapter-7QOBHKRB.js"),u=new c("patterns",{dimensions:this.config.embeddingDimension,M:this.config.hnsw.M,efConstruction:this.config.hnsw.efConstruction,efSearch:this.config.hnsw.efSearch,metric:"cosine"});this.hnswIndex=new a(u),this.hnswAvailable=!0,console.log("[PatternStore] Using unified HNSW via HnswLegacyBridge (ADR-071)"),await this.loadEmbeddingsIntoHNSW();return}catch(a){console.warn("[PatternStore] Unified HNSW bridge failed, falling back:",a)}let{HNSWIndex:t}=await import("./hnsw-index-6WUKYJH7.js");this.hnswIndex=new t(this.memory,{dimensions:this.config.embeddingDimension,M:this.config.hnsw.M,efConstruction:this.config.hnsw.efConstruction,efSearch:this.config.hnsw.efSearch,maxElements:this.config.hnsw.maxElements,namespace:`${this.config.namespace}:hnsw`,metric:"cosine"});let r=5e3,s=this.hnswIndex.initialize(),i=new Promise((a,c)=>setTimeout(()=>c(new Error("HNSW init timeout")),r));await Promise.race([s,i]),this.hnswAvailable=this.hnswIndex.isNativeAvailable(),await this.loadEmbeddingsIntoHNSW(),console.log(`[PatternStore] HNSW lazy-initialized (native: ${this.hnswAvailable})`)}catch(e){console.warn("[PatternStore] HNSW not available, using memory backend search:",v(e)),this.hnswIndex=null,this.hnswAvailable=!1}}async loadEmbeddingsIntoHNSW(){if(!(!this.hnswIndex||!this.sqliteStore))try{let e=this.sqliteStore.getAllEmbeddings(),t=this.config.hnsw.maxElements,r=0,s=0;for(let{patternId:i,embedding:a}of e){if(r>=t)break;if(!a||a.length!==this.config.embeddingDimension){s++;continue}let c=this.patternCache.get(i);if(!c){s++;continue}try{await this.hnswIndex.insert(i,a,{filePath:c.patternType,lineCoverage:c.confidence*100,branchCoverage:c.qualityScore*100,functionCoverage:0,statementCoverage:0,uncoveredLineCount:0,uncoveredBranchCount:0,riskScore:1-c.confidence,lastUpdated:Date.now(),totalLines:0}),r++}catch{s++}}r>0&&console.log(`[PatternStore] Loaded ${r} embeddings into HNSW (skipped ${s})`)}catch(e){console.warn("[PatternStore] Failed to load SQLite embeddings into HNSW:",v(e))}}getVectorDeltaTracker(){return this.vectorDeltaTracker===void 0&&(this.vectorDeltaTracker=Ge()),this.vectorDeltaTracker}async loadPatterns(){if(this.sqliteStore)try{let e=this.sqliteStore.getPatterns({limit:5e4});for(let t of e)this.indexPattern(t);e.length>0&&console.log(`[PatternStore] Loaded ${e.length} patterns from SQLite into memory cache`)}catch(e){console.warn("[PatternStore] Failed to load patterns from SQLite:",v(e))}}indexPattern(e){this.patternCache.set(e.id,e),this.domainIndex.has(e.qeDomain)||this.domainIndex.set(e.qeDomain,new Set),this.domainIndex.get(e.qeDomain).add(e.id),this.typeIndex.has(e.patternType)||this.typeIndex.set(e.patternType,new Set),this.typeIndex.get(e.patternType).add(e.id);let t=e.tier==="long-term"?"long-term":"short-term";e.tier!==t&&(e.tier=t),this.tierIndex.get(t).add(e.id)}unindexPattern(e){this.patternCache.delete(e.id),this.domainIndex.get(e.qeDomain)?.delete(e.id),this.typeIndex.get(e.patternType)?.delete(e.id),this.tierIndex.get(e.tier)?.delete(e.id),this.hdcCache.delete(e.id),this.hdcTokenCache.delete(e.id)}async store(e){this.initialized||await this.initialize(),this.loadingPromise&&await this.loadingPromise;let t=j(e);if(!t.valid)return w(new Error(`Invalid pattern: ${t.errors.join(", ")}`));if(e.confidence<this.config.minConfidence)return w(new Error(`Pattern confidence ${e.confidence} below threshold ${this.config.minConfidence}`));(this.domainIndex.get(e.qeDomain)?.size||0)>=this.config.maxPatternsPerDomain&&await this.cleanupDomain(e.qeDomain);let s=this.patternCache.get(e.id)??null;if(this.indexPattern(e),this.sqliteStore)try{let i=this.sqliteStore.storePattern(e,e.embedding);i&&i!==e.id&&(this.unindexPattern(e),e.id=i,this.indexPattern(e))}catch(i){console.warn(`[PatternStore] SQLite persist failed for ${e.id}:`,v(i))}if(e.embedding){let i=await this.ensureHNSW();if(i)try{await i.insert(e.id,e.embedding,{filePath:e.patternType,lineCoverage:e.confidence*100,branchCoverage:e.qualityScore*100,functionCoverage:0,statementCoverage:0,uncoveredLineCount:0,uncoveredBranchCount:0,riskScore:1-e.confidence,lastUpdated:Date.now(),totalLines:0})}catch(a){console.warn(`[PatternStore] Failed to index embedding for ${e.id}:`,a)}}if(Q())try{let a=et().fingerprint({id:e.id,domain:e.qeDomain,type:e.patternType,content:e.description});this.hdcCache.set(e.id,a.vector)}catch(i){console.debug(`[PatternStore] HDC fingerprint failed for ${e.id}:`,v(i))}try{let i=$t();if(i){let a=[e.patternType,e.qeDomain];e.context?.tags&&a.push(...e.context.tags),e.name&&a.push(e.name);let c=i.fingerprintPattern(a);this.hdcTokenCache.set(e.id,c)}}catch(i){console.debug(`[PatternStore] HDC token fingerprint failed for ${e.id}:`,v(i))}if(ee()&&e.embedding)try{tt(e.embedding.length).store(new Float32Array(e.embedding),{id:e.id,name:e.name,domain:e.qeDomain})}catch(i){console.debug(`[PatternStore] Hopfield store failed for ${e.id}:`,v(i))}if(H()&&this.deltaTracker)try{let i={id:e.id,name:e.name,confidence:e.confidence,qualityScore:e.qualityScore,usageCount:e.usageCount,successRate:e.successRate,tier:e.tier};this.deltaTracker.createGenesis(e.id,i)}catch(i){console.debug(`[PatternStore] Delta genesis for ${e.id}:`,v(i))}if(e.embedding)try{let i=this.getVectorDeltaTracker();i&&(s?.embedding?i.recordDelta(e.id,s.embedding,e.embedding):i.getVersion(e.id)<0&&i.recordGenesis(e.id,e.embedding))}catch(i){console.debug(`[PatternStore] VectorDeltaTracker for ${e.id}:`,v(i))}try{M()&&e.embedding&&this.indexHyperbolic(e.id,e.embedding,{domain:e.qeDomain,type:e.patternType,name:e.name})}catch{}return P(e.id)}async create(e){let t=new Date,r=e.qeDomain||this.detectDomainFromType(e.patternType),s={id:C(),patternType:e.patternType,qeDomain:r,domain:r,name:e.name,description:e.description,confidence:e.confidence??.5,usageCount:0,successRate:0,qualityScore:.25,context:{...e.context,tags:e.context?.tags||[]},template:{...e.template,example:void 0},embedding:e.embedding,tier:"short-term",createdAt:t,lastUsedAt:t,successfulUses:0,reusable:!1,reuseCount:0,averageTokenSavings:0},i=await this.store(s);return i.success?P(s):w(i.error)}detectDomainFromType(e){return{"test-template":"test-generation","assertion-pattern":"test-generation","mock-pattern":"test-generation","coverage-strategy":"coverage-analysis","mutation-strategy":"test-generation","api-contract":"contract-testing","visual-baseline":"visual-accessibility","a11y-check":"visual-accessibility","perf-benchmark":"chaos-resilience","flaky-fix":"test-execution","refactor-safe":"code-intelligence","error-handling":"test-generation","meta-optimization":"learning-optimization"}[e]||"test-generation"}async get(e){return this.initialized||await this.initialize(),this.loadingPromise&&await this.loadingPromise,this.patternCache.get(e)??null}async search(e,t={}){this.initialized||await this.initialize(),this.loadingPromise&&await this.loadingPromise;let r=performance.now(),s=t.limit||10,i=[];try{if(Array.isArray(e)&&ee())try{let d=tt(e.length);if(d.getPatternCount()>0){let h=d.recall(new Float32Array(e));if(h&&h.similarity>.98){let m=h.metadata.id,p=await this.get(m);if(p&&this.matchesFilters(p,t)){let y=this.calculateReuseInfo(p,h.similarity);i.push({pattern:p,score:h.similarity,matchType:"vector",similarity:h.similarity,canReuse:y.canReuse,estimatedTokenSavings:y.estimatedTokenSavings,reuseConfidence:y.reuseConfidence})}}}}catch(d){console.debug("[PatternStore] Hopfield recall failed:",v(d))}if(Array.isArray(e)&&t.useVectorSearch!==!1){let d=await this.ensureHNSW();if(d){let h=await d.search(e,s*2);for(let m of h){let p=await this.get(m.key);if(p&&this.matchesFilters(p,t)){let y=this.calculateReuseInfo(p,m.score);i.push({pattern:p,score:m.score,matchType:"vector",similarity:m.score,canReuse:y.canReuse,estimatedTokenSavings:y.estimatedTokenSavings,reuseConfidence:y.reuseConfidence})}}}}if(typeof e=="string"&&e.trim()&&this.sqliteStore)try{let d=this.sqliteStore.searchFTS(e,s*2);if(d.length>0){let h=new Map(d.map(p=>[p.id,p.ftsScore])),m=new Set(i.map(p=>p.pattern.id));for(let p of i){let y=h.get(p.pattern.id);y!==void 0&&(p.score=.75*p.score+.25*y)}for(let p of d){if(m.has(p.id))continue;let y=await this.get(p.id);if(y&&this.matchesFilters(y,t)){let S=this.calculateReuseInfo(y,p.ftsScore);i.push({pattern:y,score:.5*p.ftsScore,matchType:"exact",similarity:p.ftsScore,canReuse:S.canReuse,estimatedTokenSavings:S.estimatedTokenSavings,reuseConfidence:S.reuseConfidence})}}}}catch{}if(typeof e=="string"||i.length<s){let d=await this.searchByText(typeof e=="string"?e:"",t,s-i.length),h=new Set(i.map(m=>m.pattern.id));for(let m of d)h.has(m.pattern.id)||i.push(m)}let a=720*60*60*1e3,c=Date.now();for(let d of i){let h=d.pattern.lastUsedAt?.getTime()??d.pattern.createdAt.getTime(),m=c-h,p=Math.pow(.5,m/a),y=d.pattern.usageCount>0?p:.5;d.score=d.score*(.7+.3*y)}let u=this.sqliteStore?.getDatabase();if(u&&i.length>0)try{this.nullStore||(this.nullStore=new ie(u));let d=this.nullStore.getNullSummaries(i.map(h=>h.pattern.id));for(let h of i){let m=d.get(h.pattern.id);m&&(h.nullSummary=m,h.score=ie.applyNullDiscount(h.score,m,t.contextFingerprint))}}catch(d){console.debug("[PatternStore] null discount skipped:",v(d))}i.sort((d,h)=>h.score-d.score);let o=i;t.filter&&(o=Ne(i,t.filter));let l=o.slice(0,s),f=performance.now()-r;return this.recordSearchLatency(f),P(l)}catch(a){return w(xe(a))}}async searchByText(e,t,r){let s=[],i=e.toLowerCase(),a;t.domain?a=this.domainIndex.get(t.domain)||new Set:t.patternType?a=this.typeIndex.get(t.patternType)||new Set:t.tier?a=this.tierIndex.get(t.tier)||new Set:a=new Set(this.patternCache.keys());let c=[...a];if(Q()&&i&&this.hdcCache.size>0)try{let u=et(),o=u.fingerprint({id:"query",domain:t.domain??"unknown",type:t.patternType??"unknown",content:e}),l=c.filter(h=>this.hdcCache.has(h)).map(h=>({id:h,similarity:u.similarity(o.vector,this.hdcCache.get(h))}));l.sort((h,m)=>m.similarity-h.similarity);let f=l.map(h=>h.id),d=c.filter(h=>!this.hdcCache.has(h));c=[...f,...d]}catch{}for(let u of c){if(s.length>=r)break;let o=this.patternCache.get(u);if(!o||!this.matchesFilters(o,t))continue;let l=0;if(i){let f=o.name.toLowerCase(),d=o.description.toLowerCase();f.includes(i)&&(l+=.5),d.includes(i)&&(i.length/d.length>.3?l+=.5:l+=.3);for(let h of o.context.tags)if(h.toLowerCase().includes(i)){l+=.2;break}l=Math.min(l,1)}else l=o.qualityScore;if(l>0||!i){let f=this.calculateReuseInfo(o,l);s.push({pattern:o,score:l||o.qualityScore,matchType:i?"exact":"context",similarity:l||o.qualityScore,canReuse:f.canReuse,estimatedTokenSavings:f.estimatedTokenSavings,reuseConfidence:f.reuseConfidence})}}return s}calculateReuseInfo(e,t){let{reuseOptimization:r}=this.config,s=t>=r.minSimilarityForReuse,i=e.successRate>=r.minSuccessRateForReuse,a=e.lastUsedAt instanceof Date?e.lastUsedAt.getTime():new Date(e.lastUsedAt).getTime(),u=(Date.now()-a)/(1e3*60*60*24)<=r.maxAgeForReuse,o=r.enabled&&e.reusable&&s&&i&&u,l=o?e.averageTokenSavings>0?e.averageTokenSavings:e.tokensUsed||0:0,f=t,d=e.successRate,h=Math.min(e.reuseCount/10,1),m=o?f*.4+d*.4+h*.2:0;return{canReuse:o,estimatedTokenSavings:l,reuseConfidence:m}}matchesFilters(e,t){if(t.patternType&&e.patternType!==t.patternType||t.domain&&e.qeDomain!==t.domain||t.tier&&e.tier!==t.tier||t.minConfidence!==void 0&&e.confidence<t.minConfidence||t.minQualityScore!==void 0&&e.qualityScore<t.minQualityScore)return!1;if(t.context){let r=t.context;if(r.language&&e.context.language!==r.language||r.framework&&e.context.framework!==r.framework||r.testType&&e.context.testType!==r.testType)return!1}return!0}async recordUsage(e,t,r,s){let i=await this.get(e);if(!i)return w(new Error(`Pattern not found: ${e}`));let a=new Date,c=i.usageCount+1,u=i.successfulUses+(t?1:0),o=u/c,l=t?.02:-.01,f=Math.max(.1,Math.min(1,i.confidence+l)),d=J({confidence:f,usageCount:c,successRate:o}),h={...i,usageCount:c,successfulUses:u,successRate:o,confidence:f,qualityScore:d,lastUsedAt:a};if(this.sqliteStore)try{this.sqliteStore.recordUsage(e,t,r,s)}catch(y){console.warn(`[PatternStore] SQLite recordUsage failed for ${e}:`,v(y))}if(H()&&this.deltaTracker)try{let y={id:i.id,name:i.name,confidence:i.confidence,qualityScore:i.qualityScore,usageCount:i.usageCount,successRate:i.successRate,tier:i.tier},S={id:h.id,name:h.name,confidence:h.confidence,qualityScore:h.qualityScore,usageCount:h.usageCount,successRate:h.successRate,tier:h.tier};this.deltaTracker.recordDelta(e,y,S,{success:t})}catch(y){console.debug(`[PatternStore] Delta recordDelta for ${e}:`,v(y))}let m=te(h);return m.meetsUsageCriteria&&m.meetsQualityCriteria&&m.meetsCoherenceCriteria&&h.tier==="short-term"?await this.promote(e):this.patternCache.set(e,h),P(void 0)}async promote(e){let t=await this.get(e);if(!t)return w(new Error(`Pattern not found: ${e}`));if(t.tier==="long-term")return P(void 0);let r={...t,tier:"long-term",confidence:Math.min(1,t.confidence+.1)};if(this.tierIndex.get("short-term")?.delete(e),this.tierIndex.get("long-term")?.add(e),this.patternCache.set(e,r),this.sqliteStore)try{this.sqliteStore.promotePattern(e)}catch(s){console.debug("[PatternStore] SQLite promotion error:",s instanceof Error?s.message:s)}return console.log(`[PatternStore] Promoted pattern ${e} (${t.name}) to long-term storage`),P(void 0)}async delete(e){let t=this.patternCache.get(e);if(!t)return w(new Error(`Pattern not found: ${e}`));if(this.unindexPattern(t),this.sqliteStore)try{this.sqliteStore.deletePattern(e)}catch(r){console.debug("[PatternStore] SQLite deletion error:",r instanceof Error?r.message:r)}if(this.hnswIndex!==null)try{await this.hnswIndex.delete(e)}catch(r){console.debug("[PatternStore] HNSW deletion error:",r instanceof Error?r.message:r)}return P(void 0)}async getStats(){let e={},t={};for(let[o,l]of this.domainIndex)e[o]=l.size;for(let[o,l]of this.typeIndex)t[o]=l.size;let r=0,s=0,i=0,a=0;for(let o of this.patternCache.values())r+=o.confidence,s+=o.qualityScore,i+=o.successRate,a++;let c=await this.ensureHNSW(),u=c!==null?await c.getStats():{nativeHNSW:!1,vectorCount:0,indexSizeBytes:0,lazyLoaded:!0};return{totalPatterns:this.patternCache.size,byTier:{shortTerm:this.tierIndex.get("short-term")?.size||0,longTerm:this.tierIndex.get("long-term")?.size||0},byDomain:e,byType:t,avgConfidence:a>0?r/a:0,avgQualityScore:a>0?s/a:0,avgSuccessRate:a>0?i/a:0,searchOperations:this.stats.searchOperations,avgSearchLatencyMs:this.calculateAvgLatency(),hnswStats:{nativeAvailable:u.nativeHNSW,vectorCount:u.vectorCount,indexSizeBytes:u.indexSizeBytes}}}async cleanup(){let e=0,t=0,r=[],s=[];for(let i of this.patternCache.values()){let a=te(i);if(a.meetsUsageCriteria&&a.meetsQualityCriteria&&a.meetsCoherenceCriteria){s.push(i.id);continue}if(i.tier==="short-term"){let u=i.createdAt instanceof Date?i.createdAt.getTime():new Date(i.createdAt).getTime(),o=Date.now()-u,l=o>10080*60*1e3,f=i.qualityScore<.2,d=i.usageCount===0&&o>1440*60*1e3;(l&&f||d)&&r.push(i.id)}}for(let i of s)(await this.promote(i)).success&&t++;for(let i of r)(await this.delete(i)).success&&e++;return console.log(`[PatternStore] Cleanup: removed ${e}, promoted ${t}`),{removed:e,promoted:t}}async cleanupDomain(e){let t=this.domainIndex.get(e);if(!t||t.size<this.config.maxPatternsPerDomain)return;let r=[];for(let a of t){let c=this.patternCache.get(a);c&&r.push(c)}r.sort((a,c)=>a.qualityScore-c.qualityScore);let s=Math.ceil(r.length*.1),i=0;for(let a of r){if(i>=s)break;a.tier==="short-term"&&(await this.delete(a.id),i++)}}recordSearchLatency(e){this.stats.searchOperations++,this.stats.searchLatencies.push(e),this.stats.searchLatencies.length>1e3&&(this.stats.searchLatencies=this.stats.searchLatencies.slice(-1e3))}calculateAvgLatency(){return this.stats.searchLatencies.length===0?0:this.stats.searchLatencies.reduce((t,r)=>t+r,0)/this.stats.searchLatencies.length}async dispose(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=void 0),this.patternCache.clear(),this.domainIndex.clear(),this.typeIndex.clear(),this.tierIndex.clear(),this.hdcCache.clear(),this.deltaTracker=null,this.hyperbolicIndex&&(this.hyperbolicIndex.reset(),this.hyperbolicIndex=null),U&&(U.clear(),U=null,Re=0),this.initialized=!1}indexHyperbolic(e,t,r){if(M())try{this.hyperbolicIndex||(this.hyperbolicIndex=Ze({dimensions:this.config.embeddingDimension,maxElements:this.config.hnsw.maxElements})),this.hyperbolicIndex.indexPattern(e,t,r)}catch(s){console.debug(`[PatternStore] Hyperbolic indexing failed for ${e}:`,s instanceof Error?s.message:s)}}async searchHyperbolic(e,t=10){if(!M()||!this.hyperbolicIndex)return P([]);try{let r=this.hyperbolicIndex.search(e,t),s=[];for(let i of r){let a=await this.get(i.patternId);if(!a)continue;let c=Math.exp(-i.distance),u=this.calculateReuseInfo(a,c);s.push({pattern:a,score:c,matchType:"vector",similarity:c,canReuse:u.canReuse,estimatedTokenSavings:u.estimatedTokenSavings,reuseConfidence:u.reuseConfidence})}return P(s)}catch(r){return console.warn("[PatternStore] Hyperbolic search failed, returning empty results:",r instanceof Error?r.message:r),P([])}}};function Jr(n,e){try{if(D().useRVFPatternStore&&Oe()){let{existsSync:r}=Te("fs"),{join:s}=Te("path"),i=process.env.AQE_PROJECT_ROOT??De(),a=s(i,".agentic-qe"),c=s(a,"patterns.rvf");if(r(a)){let u={...W,...e},o=!1;try{let l=_e(a,u.embeddingDimension);if(l){o=!0;let f=new q(()=>l,{rvfPath:c,base:u,skipCloseOnDispose:!0});return console.log("[PatternStore] Using RVF-backed store (ADR-066)"),f}}catch{}if(!o){let l=new q((f,d)=>{let h=()=>{try{return Fe(f)}catch{return null}},m=h();if(m){if(m.dimension()!==d){try{m.close()}catch{}throw new Error(`RVF dimension mismatch (file=${m.dimension()}, requested=${d})`)}return m}try{return re(f,d)}catch(p){if(m=h(),m&&m.dimension()===d)return m;if(Ie(f,p instanceof Error?p.message:String(p)))return re(f,d);throw p}},{rvfPath:c,base:u});return console.log("[PatternStore] Using RVF-backed store (ADR-066)"),l}}}}catch(t){console.warn("[PatternStore] RVF store unavailable, using in-memory HNSW:",t instanceof Error?t.message:t)}return new Ae(n,e)}export{Jr as a};
|
|
50
|
-
/*! Bundled license information:
|
|
51
|
-
|
|
52
|
-
fast-json-patch/commonjs/helpers.js:
|
|
53
|
-
(*!
|
|
54
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
55
|
-
* (c) 2017-2022 Joachim Wester
|
|
56
|
-
* MIT licensed
|
|
57
|
-
*)
|
|
58
|
-
|
|
59
|
-
fast-json-patch/commonjs/duplex.js:
|
|
60
|
-
(*!
|
|
61
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
62
|
-
* (c) 2017-2021 Joachim Wester
|
|
63
|
-
* MIT license
|
|
64
|
-
*)
|
|
65
|
-
*/
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
var t=["claude","claude-code","codex","openai","ollama","openrouter","bedrock","azure-openai","gemini","cognitum"];function i(r){return t.includes(r)}function s(r,o,n){let e=new Error(r);return e.name="LLMError",e.code=o,e.provider=n?.provider,e.model=n?.model,e.retryable=n?.retryable??!1,e.retryAfterMs=n?.retryAfterMs,e.cause=n?.cause,e}function a(r){return r instanceof Error&&"code"in r&&typeof r.code=="string"}export{i as a,s as b,a as c};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
var h={0:"sqlite-only",1:"hybrid",2:"dual-write-sqlite-primary",3:"dual-write-rvf-primary",4:"rvf-primary"},g=class{config;db=null;rvfStore=null;totalWrites=0;totalReads=0;rvfWriteFailures=0;rvfReadFailures=0;fallbacksUsed=0;sqliteLatencies=[];rvfLatencies=[];sqliteWriteLatencies=[];rvfWriteLatencies=[];constructor(e){this.config={rvfPath:".agentic-qe/patterns.rvf",dimensions:384,enableFallback:!0,...e}}setSqliteDb(e){this.db=e}setRvfStore(e){this.rvfStore=e}get stage(){return this.config.stage}setStage(e){this.config={...this.config,stage:e}}write(e,t){this.totalWrites++;let s={sqliteSuccess:!1,rvfSuccess:!1,stage:this.config.stage,fallbackUsed:!1},n=this.config.stage<4,o=this.config.stage>=2;if(n&&this.db){let i=performance.now();try{let r=Buffer.from(t instanceof Float32Array?t.buffer:new Float32Array(t).buffer);this.db.prepare(`
|
|
3
|
-
INSERT INTO qe_pattern_embeddings (pattern_id, embedding, dimension, model, created_at)
|
|
4
|
-
VALUES (?, ?, ?, 'all-MiniLM-L6-v2', datetime('now'))
|
|
5
|
-
ON CONFLICT(pattern_id) DO UPDATE SET
|
|
6
|
-
embedding = excluded.embedding, dimension = excluded.dimension, created_at = datetime('now')
|
|
7
|
-
`).run(e,r,t.length),s.sqliteSuccess=!0,this.sqliteWriteLatencies.push(performance.now()-i)}catch(r){s.sqliteSuccess=!1,process.env.AQE_DEBUG_MIGRATION&&console.warn("[RVF-Migration] SQLite write failed:",r.message)}}if(o&&this.rvfStore){let i=performance.now();try{this.rvfStore.ingest([{id:e,vector:t}]),s.rvfSuccess=!0,this.rvfWriteLatencies.push(performance.now()-i)}catch{this.rvfWriteFailures++,s.rvfSuccess=!1}}if(this.config.stage===4&&!s.rvfSuccess&&this.config.enableFallback&&this.db)try{let i=Buffer.from(t instanceof Float32Array?t.buffer:new Float32Array(t).buffer);this.db.prepare(`
|
|
8
|
-
INSERT INTO qe_pattern_embeddings (pattern_id, embedding, dimension, model, created_at)
|
|
9
|
-
VALUES (?, ?, ?, 'all-MiniLM-L6-v2', datetime('now'))
|
|
10
|
-
ON CONFLICT(pattern_id) DO UPDATE SET
|
|
11
|
-
embedding = excluded.embedding, dimension = excluded.dimension, created_at = datetime('now')
|
|
12
|
-
`).run(e,i,t.length),s.sqliteSuccess=!0,s.fallbackUsed=!0,this.fallbacksUsed++}catch{}return s}delete(e){this.totalWrites++;let t={sqliteSuccess:!1,rvfSuccess:!1,stage:this.config.stage,fallbackUsed:!1};if(this.config.stage<4&&this.db)try{this.db.prepare("DELETE FROM qe_pattern_embeddings WHERE pattern_id = ?").run(e),t.sqliteSuccess=!0}catch{}if(this.config.stage>=2&&this.rvfStore)try{this.rvfStore.delete([e]),t.rvfSuccess=!0}catch{this.rvfWriteFailures++}return t}search(e,t){this.totalReads++;let s=this.config.stage>=3;if(s&&this.rvfStore){let r=performance.now();try{let a=this.rvfStore.search(e,t),c=performance.now()-r;return this.rvfLatencies.push(c),{data:a,source:"rvf",latencyMs:c,stage:this.config.stage}}catch{if(this.rvfReadFailures++,!this.config.enableFallback)return{data:null,source:"rvf",latencyMs:0,stage:this.config.stage};this.fallbacksUsed++}}let n=performance.now(),o=this.searchSqlite(e,t),i=performance.now()-n;return this.sqliteLatencies.push(i),{data:o,source:s?"fallback":"sqlite",latencyMs:i,stage:this.config.stage}}status(){let e=0;if(this.db)try{e=this.db.prepare("SELECT COUNT(*) as cnt FROM qe_pattern_embeddings").get()?.cnt??0}catch{}let t=null;if(this.rvfStore)try{t=this.rvfStore.status()}catch{}return{sqlite:{vectorCount:e},rvf:t,stage:this.config.stage}}getMetrics(){return{stage:this.config.stage,stageName:h[this.config.stage],totalWrites:this.totalWrites,totalReads:this.totalReads,rvfWriteFailures:this.rvfWriteFailures,rvfReadFailures:this.rvfReadFailures,fallbacksUsed:this.fallbacksUsed,sqliteReadLatencyAvgMs:d(this.sqliteLatencies),rvfReadLatencyAvgMs:d(this.rvfLatencies),sqliteWriteLatencyAvgMs:d(this.sqliteWriteLatencies),rvfWriteLatencyAvgMs:d(this.rvfWriteLatencies)}}resetMetrics(){this.totalWrites=0,this.totalReads=0,this.rvfWriteFailures=0,this.rvfReadFailures=0,this.fallbacksUsed=0,this.sqliteLatencies=[],this.rvfLatencies=[],this.sqliteWriteLatencies=[],this.rvfWriteLatencies=[]}searchSqlite(e,t){if(!this.db)return[];let s;try{s=this.db.prepare("SELECT pattern_id, embedding, dimension FROM qe_pattern_embeddings").all()}catch{return[]}let n=e instanceof Float32Array?Array.from(e):e,o=Math.sqrt(n.reduce((r,a)=>r+a*a,0));if(o===0)return[];let i=[];for(let r of s){if(r.dimension!==n.length)continue;let a=new Float32Array(r.embedding.buffer,r.embedding.byteOffset,r.dimension),c=0,f=0;for(let l=0;l<r.dimension;l++)c+=n[l]*a[l],f+=a[l]*a[l];f=Math.sqrt(f),f!==0&&i.push({id:r.pattern_id,score:c/(o*f)})}return i.sort((r,a)=>a.score-r.score),i.slice(0,t)}};function d(u){return u.length===0?0:u.reduce((e,t)=>e+t,0)/u.length}export{h as a,g as b};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a as d,b as n}from"./chunk-UQ4UCHO7.js";var o=new Map,u=new Set(["anthropic"]),s=/^[a-z0-9][a-z0-9-]{0,62}$/;function g(e){if(typeof e!="string"||e.trim().length===0)return"provider type must be a non-empty string";if(e!==e.toLowerCase())return`provider type "${e}" must be lowercase (AQE_LLM_PROVIDER is matched case-insensitively)`;if(!s.test(e))return`provider type "${e}" must match ${s.source} (lowercase alphanumeric and dashes)`;if(d(e))return`provider type "${e}" is built in and cannot be overridden`;if(u.has(e))return`provider type "${e}" is reserved`}function c(e,r,t={}){let i=g(e);if(i)throw n(i,"INVALID_REGISTRATION",{retryable:!1});if(typeof r!="function")throw n(`provider "${e}" must be registered with a factory function`,"INVALID_REGISTRATION",{retryable:!1});o.set(e,{...t,type:e,factory:r,source:t.source??"api"})}function v(e,r,t={}){try{c(e,r,t);return}catch(i){return i instanceof Error?i.message:String(i)}}function y(e){return o.delete(e)}function P(e){return o.has(e)}function R(e){return o.get(e)}function L(){return[...o.keys()]}var l=["isAvailable","healthCheck","generate","complete","getConfig","getSupportedModels","getCostPerToken","dispose"];function f(e,r){if(!r||typeof r!="object")return`provider "${e}" factory returned ${r===null?"null":typeof r}, expected an LLMProvider`;let t=r,i=l.filter(a=>typeof t[a]!="function");if(i.length>0)return`provider "${e}" is missing required LLMProvider method(s): ${i.join(", ")}`;if(typeof t.type!="string"||t.type.length===0)return`provider "${e}" must expose a non-empty \`type\``;if(t.type!==e)return`provider "${e}" reports type "${t.type}" \u2014 a provider must not claim an identity other than the one it was registered under`}function m(e){let r=o.get(e);if(!r)throw n(`Unknown provider type: ${e}`,"PROVIDER_UNAVAILABLE",{retryable:!1});let t=r.factory(r.config),i=f(e,t);if(i)throw n(i,"INVALID_REGISTRATION",{retryable:!1});return t}function h(e){let r=o.get(e);if(r)return{mode:r.billingMode??"metered-api",source:r.source,detail:r.sourceDetail}}export{g as a,v as b,y as c,P as d,R as e,L as f,m as g,h};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{b as A,c as D,d as V,e as E}from"./chunk-MGKH4LCM.js";import{b as v,c as G}from"./chunk-TDVMILKO.js";import{a as x,b as $,c as H,e as w}from"./chunk-G6FJHDUG.js";import{b as P,c as U}from"./chunk-UQ4UCHO7.js";import{a as k}from"./chunk-Z6DSYLAG.js";import{b as F,c as J}from"./chunk-L3GBNX7B.js";import{i as _}from"./chunk-52VGZJSD.js";var N={security:{provider:"claude",model:"claude-opus-4-7",temperature:.1,maxTokens:16e3,priority:100},"test-generation":{provider:"claude",model:"claude-sonnet-4-6",temperature:.3,maxTokens:8e3,priority:90},"code-analysis":{provider:"claude",model:"claude-sonnet-4-6",temperature:.2,maxTokens:8e3,priority:85},performance:{provider:"claude",model:"claude-haiku-4-5-20251001",temperature:.2,maxTokens:4e3,priority:70},documentation:{provider:"claude",model:"claude-haiku-4-5-20251001",temperature:.4,maxTokens:4e3,priority:60},learning:{provider:"claude",model:"claude-sonnet-4-6",temperature:.3,maxTokens:8e3,priority:80},coordination:{provider:"claude",model:"claude-haiku-4-5-20251001",temperature:.2,maxTokens:2e3,priority:75},simple:{provider:"openai",model:"gpt-4o-mini",temperature:.3,maxTokens:2e3,priority:50},general:{provider:"claude",model:"claude-sonnet-4-6",temperature:.3,maxTokens:4e3,priority:60}},q={"security-auditor":"security","security-architect":"security","security-scanner":"security","v3-qe-security-scanner":"security","security-manager":"security","vulnerability-scanner":"security","penetration-tester":"security","compliance-auditor":"security","threat-analyzer":"security","test-generator":"test-generation","v3-qe-test-generator":"test-generation",tester:"test-generation","tdd-specialist":"test-generation","tdd-london-swarm":"test-generation","unit-test-generator":"test-generation","integration-test-generator":"test-generation","e2e-test-generator":"test-generation","mutation-tester":"test-generation","property-based-tester":"test-generation","contract-tester":"test-generation","v3-qe-contract-tester":"test-generation","api-tester":"test-generation","visual-tester":"test-generation","v3-qe-visual-tester":"test-generation","accessibility-tester":"test-generation","code-reviewer":"code-analysis","code-analyzer":"code-analysis",reviewer:"code-analysis","v3-qe-code-intelligence":"code-analysis","v3-qe-code-analyzer":"code-analysis","coverage-analyzer":"code-analysis","v3-qe-coverage-analyzer":"code-analysis","defect-predictor":"code-analysis","v3-qe-defect-predictor":"code-analysis","static-analyzer":"code-analysis","complexity-analyzer":"code-analysis","dependency-analyzer":"code-analysis","refactoring-advisor":"code-analysis","quality-assessor":"code-analysis","v3-qe-quality-assessor":"code-analysis","test-executor":"code-analysis","v3-qe-test-executor":"code-analysis","parallel-executor":"code-analysis","flaky-test-detector":"code-analysis","test-orchestrator":"code-analysis","performance-tester":"performance","performance-engineer":"performance","perf-analyzer":"performance","performance-benchmarker":"performance","load-tester":"performance","stress-tester":"performance","v3-qe-chaos-engineer":"performance","chaos-engineer":"performance","resilience-tester":"performance","scalability-tester":"performance","api-docs":"documentation","doc-generator":"documentation","readme-generator":"documentation","changelog-generator":"documentation","specification-writer":"documentation","v3-qe-learning-optimizer":"learning","learning-optimizer":"learning","ml-developer":"learning","pattern-learner":"learning","optimization-agent":"learning","smart-agent":"learning","requirements-validator":"code-analysis","v3-qe-requirements-validator":"code-analysis","bdd-generator":"test-generation","acceptance-tester":"test-generation",coordinator:"coordination","hierarchical-coordinator":"coordination","mesh-coordinator":"coordination","adaptive-coordinator":"coordination","collective-intelligence-coordinator":"coordination","swarm-memory-manager":"coordination","byzantine-coordinator":"coordination","raft-manager":"coordination","gossip-coordinator":"coordination","consensus-builder":"coordination","crdt-synchronizer":"coordination","quorum-manager":"coordination","task-orchestrator":"coordination","memory-coordinator":"coordination",coder:"code-analysis",planner:"code-analysis",researcher:"code-analysis","backend-dev":"code-analysis","mobile-dev":"code-analysis","cicd-engineer":"code-analysis","system-architect":"code-analysis","base-template-generator":"test-generation","github-modes":"coordination","pr-manager":"coordination","code-review-swarm":"code-analysis","issue-tracker":"coordination","release-manager":"coordination","workflow-automation":"coordination","project-board-sync":"coordination","repo-architect":"code-analysis","multi-repo-swarm":"coordination","sparc-coord":"coordination","sparc-coder":"code-analysis",specification:"documentation",pseudocode:"code-analysis",architecture:"code-analysis",refinement:"code-analysis","memory-specialist":"learning","production-validator":"code-analysis"},y={heavyweight:{requiresReasoning:!0,requiresTools:!0,requiresVision:!1,requiresExtendedThinking:!0,requiresJsonMode:!0,minContextSize:1e5,costSensitivity:"low",latencySensitivity:"low"},standard:{requiresReasoning:!0,requiresTools:!0,requiresVision:!1,requiresExtendedThinking:!1,requiresJsonMode:!0,minContextSize:5e4,costSensitivity:"medium",latencySensitivity:"medium"},lightweight:{requiresReasoning:!1,requiresTools:!0,requiresVision:!1,requiresExtendedThinking:!1,requiresJsonMode:!0,minContextSize:16e3,costSensitivity:"medium",latencySensitivity:"high"},minimal:{requiresReasoning:!1,requiresTools:!1,requiresVision:!1,requiresExtendedThinking:!1,requiresJsonMode:!1,minContextSize:4e3,costSensitivity:"high",latencySensitivity:"medium"}},X={security:y.heavyweight,"test-generation":y.standard,"code-analysis":y.standard,learning:y.standard,performance:{...y.lightweight,costSensitivity:"high"},coordination:y.lightweight,general:{...y.lightweight,requiresJsonMode:!1,latencySensitivity:"medium"},documentation:{...y.minimal,minContextSize:16e3},simple:y.minimal};function j(u){if(u in q)return q[u];let e=u.toLowerCase();return e.includes("security")||e.includes("audit")||e.includes("vulnerab")||e.includes("penetration")||e.includes("threat")||e.includes("compliance")?"security":e.includes("test-gen")||e.includes("tdd")||e.includes("unit-test")||e.includes("e2e-test")||e.includes("integration-test")||e.includes("mutation")?"test-generation":e.includes("code-")||e.includes("coverage")||e.includes("defect")||e.includes("review")||e.includes("analyzer")||e.includes("quality")?"code-analysis":e.includes("perf")||e.includes("load")||e.includes("stress")||e.includes("benchmark")||e.includes("chaos")||e.includes("resilience")?"performance":e.includes("doc")||e.includes("readme")||e.includes("changelog")||e.includes("spec")?"documentation":e.includes("learn")||e.includes("ml-")||e.includes("pattern")||e.includes("optim")?"learning":e.includes("coord")||e.includes("swarm")||e.includes("orchestrat")||e.includes("consensus")||e.includes("manager")?"coordination":"general"}var S={},W={};function Z(u,e){S={...u??{}},W={...e??{}}}function Y(u){let e=j(u),t=N[e],r=S[u];if(!r)return t;let i=r.provider!==void 0&&r.provider!==t.provider,o=r.model??(i?W[r.provider]:void 0);return{...t,...r.provider!==void 0?{provider:r.provider}:{},...o!==void 0?{model:o}:{},...r.temperature!==void 0?{temperature:r.temperature}:{},...r.maxTokens!==void 0?{maxTokens:r.maxTokens}:{},priority:r.priority??t.priority+100}}function ee(){return Object.keys(S).map(u=>{let e=Y(u);return{id:`agent-override-${u}`,name:`User override: ${u} -> ${e.provider}/${e.model}`,description:`Per-agent routing override from .agentic-qe/llm-config.json (agentOverrides["${u}"])`,condition:{agentType:[u]},action:{provider:e.provider,model:e.model,temperature:e.temperature,maxTokens:e.maxTokens,priority:e.priority},enabled:!0,priority:e.priority}}).sort((u,e)=>e.priority-u.priority)}var f=class{rules=[];constructor(e=[]){this.setRules(e)}setRules(e){this.rules=[...e].filter(t=>t.enabled).sort((t,r)=>r.priority-t.priority)}getRules(){return[...this.rules]}addRule(e){this.rules.push(e),this.rules=this.rules.filter(t=>t.enabled).sort((t,r)=>r.priority-t.priority)}removeRule(e){let t=this.rules.findIndex(r=>r.id===e);return t>=0?(this.rules.splice(t,1),!0):!1}setRuleEnabled(e,t){let r=this.rules.find(i=>i.id===e);return r?(r.enabled=t,this.rules=this.rules.filter(i=>i.enabled).sort((i,o)=>o.priority-i.priority),!0):!1}evaluate(e){let t=0;for(let r of this.rules)if(t++,this.matchesCondition(e,r.condition))return{rule:r,rulesEvaluated:t};return null}evaluateAll(e){return this.rules.filter(t=>this.matchesCondition(e,t.condition))}matchesCondition(e,t){if(t.agentType!==void 0&&(!e.agentType||!t.agentType.includes(e.agentType))||t.requiresTools!==void 0&&!!e.requiresTools!==t.requiresTools)return!1;if(t.complexity!==void 0){let r=Array.isArray(t.complexity)?t.complexity:[t.complexity];if(!e.complexity||!r.includes(e.complexity))return!1}if(t.localOnly!==void 0&&t.localOnly){let r=["ollama","onnx"];if(e.preferredProvider&&!r.includes(e.preferredProvider))return!1}if(t.requiresReasoning!==void 0&&t.requiresReasoning&&e.complexity==="low")return!1;if(t.tokenRange!==void 0){let r=this.estimateTokens(e);if(t.tokenRange.min!==void 0&&r<t.tokenRange.min||t.tokenRange.max!==void 0&&r>t.tokenRange.max)return!1}return!(t.requiredCapabilities!==void 0&&t.requiredCapabilities.length>0&&(!e.requiredCapabilities||e.requiredCapabilities.length===0||!t.requiredCapabilities.every(i=>e.requiredCapabilities.includes(i)))||t.custom!==void 0&&!t.custom(e))}estimateTokens(e){let t=0;e.systemPrompt&&(t+=Math.ceil(e.systemPrompt.length/4));for(let r of e.messages)t+=Math.ceil(r.content.length/4);return t}},L=[{id:"security-agents-opus",name:"Security Agents to Claude Opus",description:"Route security-critical agents to Claude Opus for best security analysis",condition:{agentType:["security-auditor","security-architect","v3-qe-security-scanner"]},action:{provider:"claude",model:"claude-opus-4-7",temperature:.1},enabled:!0,priority:100},{id:"test-gen-with-tools",name:"Test Generation with Tools",description:"Route test generation requests that need tools to Claude Sonnet",condition:{agentType:["v3-qe-test-generator","tester"],requiresTools:!0},action:{provider:"claude",model:"claude-sonnet-4-6",temperature:.3},enabled:!0,priority:95},{id:"high-complexity-reasoning",name:"High Complexity Reasoning",description:"Route high complexity tasks requiring reasoning to advanced models",condition:{complexity:"high",requiresReasoning:!0},action:{provider:"claude",model:"claude-opus-4-7",temperature:.2},enabled:!0,priority:90},{id:"code-analysis-agents",name:"Code Analysis Agents",description:"Route code analysis to Claude Sonnet for balanced performance",condition:{agentType:["code-analyzer","v3-qe-code-intelligence","reviewer"]},action:{provider:"claude",model:"claude-sonnet-4-6",temperature:.2},enabled:!0,priority:85},{id:"coverage-analysis",name:"Coverage Analysis Agents",description:"Route coverage analysis to efficient models",condition:{agentType:["v3-qe-coverage-analyzer"]},action:{provider:"claude",model:"claude-sonnet-4-6",temperature:.1},enabled:!0,priority:80},{id:"defect-prediction",name:"Defect Prediction Agents",description:"Route defect prediction to capable models",condition:{agentType:["v3-qe-defect-predictor"]},action:{provider:"claude",model:"claude-sonnet-4-6",temperature:.3},enabled:!0,priority:75},{id:"medium-complexity",name:"Medium Complexity Tasks",description:"Route medium complexity to balanced Claude Sonnet",condition:{complexity:"medium"},action:{provider:"claude",model:"claude-sonnet-4-6",temperature:.3},enabled:!0,priority:60},{id:"low-complexity-haiku",name:"Low Complexity to Haiku",description:"Route low complexity tasks to Haiku for cost efficiency",condition:{complexity:"low"},action:{provider:"claude",model:"claude-haiku-4-5-20251001",temperature:.3},enabled:!0,priority:50},{id:"local-only-ollama",name:"Local Only Requests",description:"Route local-only requests to Ollama",condition:{localOnly:!0},action:{provider:"ollama",model:"llama3.1",temperature:.3},enabled:!0,priority:40},{id:"small-requests-haiku",name:"Small Token Requests",description:"Route small requests to Haiku for efficiency",condition:{tokenRange:{max:500}},action:{provider:"claude",model:"claude-haiku-4-5-20251001",temperature:.3},enabled:!0,priority:30}];import{randomUUID as K}from"crypto";var C=class{decisions=[];providerCalls=[];fallbacks=[];cacheHits=0;cacheMisses=0;startTime=new Date;maxRecords;maxCallRecords;constructor(e={}){this.maxRecords=e.maxRecords??1e4,this.maxCallRecords=e.maxCallRecords??5e3}recordRoutingDecision(e,t,r={}){let i={id:`rd-${Date.now()}-${K().slice(0,8)}`,timestamp:new Date,provider:e.providerType,model:e.model,mode:this.inferMode(e.reason),reason:e.reason,latencyMs:t,decisionTimeMs:e.metadata.decisionTimeMs,agentType:r.agentType,success:r.success??!0,tokenUsage:r.tokenUsage,cost:r.cost,wasFallback:e.reason==="fallback",ruleId:e.matchedRule?.id};this.decisions.push(i),this.trimRecords()}recordProviderCall(e,t,r,i,o={}){let n=o.inputTokens??Math.floor(i*.7),a=o.outputTokens??i-n,s={timestamp:new Date,provider:e,model:t,latencyMs:r,inputTokens:n,outputTokens:a,totalTokens:i,success:o.success??!0,cost:o.cost,agentType:o.agentType};this.providerCalls.push(s),this.trimCallRecords()}recordFallback(e,t,r,i){let o={timestamp:new Date,fromProvider:e,toProvider:t,reason:r,agentType:i};this.fallbacks.push(o),this.fallbacks.length>1e3&&(this.fallbacks=this.fallbacks.slice(-1e3))}recordCacheHit(){this.cacheHits++}recordCacheMiss(){this.cacheMisses++}getMetrics(e="all"){let t=this.getWindowStart(e),r=this.filterByTime(this.decisions,t),i=this.filterByTime(this.providerCalls,t),o=this.filterByTime(this.fallbacks,t),n=this.calculateProviderMetrics(r,i),a=this.calculateAgentMetrics(r,i),s=r.map(m=>m.decisionTimeMs),c=r.length,l=this.countByMode(r),d=r.filter(m=>m.wasFallback).length,g=r.filter(m=>m.ruleId).length;return{byProvider:Object.fromEntries(n),byAgentType:a,totalDecisions:c,decisionsByMode:l,avgDecisionTimeMs:this.average(s),p95DecisionTimeMs:this.percentile(s,95),p99DecisionTimeMs:this.percentile(s,99),fallbackRate:c>0?d/c:0,ruleMatchRate:c>0?g/c:0,estimatedCostSavings:this.calculateCostSavings(r),ruleStats:{totalEvaluated:r.reduce((m,b)=>m+1,0),matched:g,avgRulesPerDecision:1},cacheStats:{hits:this.cacheHits,misses:this.cacheMisses,hitRate:this.cacheHits+this.cacheMisses>0?this.cacheHits/(this.cacheHits+this.cacheMisses):0},period:{start:t,end:new Date},recentDecisions:r.slice(-50),fallbackStats:this.calculateFallbackStats(o)}}getMetricsByProvider(e){let t=this.decisions.filter(s=>s.provider===e),r=this.providerCalls.filter(s=>s.provider===e),i=r.map(s=>s.latencyMs),o=t.map(s=>s.decisionTimeMs),n=r.filter(s=>s.success),a=r.filter(s=>!s.success);return{provider:e,selectionCount:t.length,ruleMatchCount:t.filter(s=>s.ruleId).length,fallbackCount:t.filter(s=>s.wasFallback).length,avgDecisionTimeMs:this.average(o),successRate:r.length>0?n.length/r.length:1,avgLatencyMs:this.average(i),p95LatencyMs:this.percentile(i,95),p99LatencyMs:this.percentile(i,99),totalCost:r.reduce((s,c)=>s+(c.cost??0),0),totalTokens:r.reduce((s,c)=>s+c.totalTokens,0),totalInputTokens:r.reduce((s,c)=>s+c.inputTokens,0),totalOutputTokens:r.reduce((s,c)=>s+c.outputTokens,0),circuitState:"closed",latencyHistogram:i.slice(-100),decisionTimeHistogram:o.slice(-100),errorCount:a.length,lastError:a.length>0?a[a.length-1].timestamp:void 0,recentCalls:r.slice(-20)}}getMetricsByAgentType(e){let t=this.decisions.filter(c=>c.agentType===e),r=this.providerCalls.filter(c=>c.agentType===e),i=new Map,o=new Map;for(let c of t)i.set(c.provider,(i.get(c.provider)??0)+1),o.set(c.model,(o.get(c.model)??0)+1);let n=r.map(c=>c.latencyMs),a=t.filter(c=>c.wasFallback).length,s=t.filter(c=>c.success).length;return{agentType:e,totalDecisions:t.length,providerDistribution:i,modelDistribution:o,avgLatencyMs:this.average(n),totalCost:r.reduce((c,l)=>c+(l.cost??0),0),totalTokens:r.reduce((c,l)=>c+l.totalTokens,0),fallbackRate:t.length>0?a/t.length:0,successRate:t.length>0?s/t.length:1}}getAuditLog(e={}){let t=this.decisions;e.since&&(t=t.filter(i=>i.timestamp>=e.since)),e.provider&&(t=t.filter(i=>i.provider===e.provider)),e.agentType&&(t=t.filter(i=>i.agentType===e.agentType));let r=e.limit??100;return t.slice(-r).map(i=>({id:i.id,timestamp:i.timestamp,context:{agentType:i.agentType},decision:{providerType:i.provider,model:i.model,providerModelId:i.model,reason:i.reason,confidence:1,metadata:{decisionTimeMs:i.decisionTimeMs,timestamp:i.timestamp}},outcome:{success:i.success,latencyMs:i.latencyMs,tokenUsage:i.tokenUsage,cost:i.cost}}))}resetMetrics(){this.decisions=[],this.providerCalls=[],this.fallbacks=[],this.cacheHits=0,this.cacheMisses=0,this.startTime=new Date}inferMode(e){switch(e){case"manual":return"manual";case"rule-match":return"rule-based";case"cost-optimization":return"cost-optimized";case"performance-optimization":return"performance-optimized";default:return"rule-based"}}trimRecords(){this.decisions.length>this.maxRecords&&(this.decisions=this.decisions.slice(-this.maxRecords))}trimCallRecords(){this.providerCalls.length>this.maxCallRecords&&(this.providerCalls=this.providerCalls.slice(-this.maxCallRecords))}getWindowStart(e){let t=new Date;switch(e){case"1m":return new Date(t.getTime()-60*1e3);case"5m":return new Date(t.getTime()-300*1e3);case"15m":return new Date(t.getTime()-900*1e3);case"1h":return new Date(t.getTime()-3600*1e3);case"24h":return new Date(t.getTime()-1440*60*1e3);case"7d":return new Date(t.getTime()-10080*60*1e3);default:return this.startTime}}filterByTime(e,t){return e.filter(r=>r.timestamp>=t)}calculateProviderMetrics(e,t){let r=new Map;for(let i of v){let o=e.filter(l=>l.provider===i),n=t.filter(l=>l.provider===i);if(o.length===0&&n.length===0)continue;let a=n.map(l=>l.latencyMs),s=o.map(l=>l.decisionTimeMs),c=n.filter(l=>l.success);r.set(i,{provider:i,selectionCount:o.length,ruleMatchCount:o.filter(l=>l.ruleId).length,fallbackCount:o.filter(l=>l.wasFallback).length,avgDecisionTimeMs:this.average(s),successRate:n.length>0?c.length/n.length:1,avgLatencyMs:this.average(a),p95LatencyMs:this.percentile(a,95),p99LatencyMs:this.percentile(a,99),totalCost:n.reduce((l,d)=>l+(d.cost??0),0),totalTokens:n.reduce((l,d)=>l+d.totalTokens,0),circuitState:"closed"})}return r}calculateAgentMetrics(e,t){let r=new Set;e.forEach(o=>o.agentType&&r.add(o.agentType)),t.forEach(o=>o.agentType&&r.add(o.agentType));let i=new Map;for(let o of r)i.set(o,this.getMetricsByAgentType(o));return i}countByMode(e){let t={manual:0,"rule-based":0,"cost-optimized":0,"performance-optimized":0};for(let r of e)t[r.mode]++;return t}calculateFallbackStats(e){let t=new Map,r=new Map;for(let i of e)t.set(i.fromProvider,(t.get(i.fromProvider)??0)+1),r.set(i.reason,(r.get(i.reason)??0)+1);return{total:e.length,byProvider:t,byReason:r}}calculateCostSavings(e){return e.reduce((t,r)=>r.cost&&r.mode==="cost-optimized"?t+r.cost.totalCost*.2:t,0)}average(e){return e.length===0?0:e.reduce((t,r)=>t+r,0)/e.length}percentile(e,t){if(e.length===0)return 0;let r=[...e].sort((o,n)=>o-n),i=Math.ceil(t/100*r.length)-1;return r[Math.max(0,i)]}};function I(u){return new C(u)}var R=class{records=[];alerts=[];maxRecords;alertCheckInterval;constructor(e={}){this.maxRecords=e.maxRecords??1e4}recordCost(e,t,r,i,o={}){let n=this.calculateCost(t,r,i),a={timestamp:new Date,provider:e,model:t,inputTokens:r,outputTokens:i,inputCost:n.inputCost,outputCost:n.outputCost,totalCost:n.totalCost,agentType:o.agentType,requestId:o.requestId};return this.records.push(a),this.trimRecords(),this.checkAlerts(),a}recordCostFromInfo(e,t,r,i,o={}){let n={timestamp:new Date,provider:e,model:t,inputTokens:r.promptTokens,outputTokens:r.completionTokens,inputCost:i.inputCost,outputCost:i.outputCost,totalCost:i.totalCost,agentType:o.agentType,requestId:o.requestId};return this.records.push(n),this.trimRecords(),this.checkAlerts(),n}getCostByProvider(e="all"){let t=this.getPeriodStart(e),r=this.filterByTime(t),i=new Map;for(let o of v){let n=r.filter(c=>c.provider===o);if(n.length===0)continue;let a=n.reduce((c,l)=>c+l.totalCost,0),s=n.reduce((c,l)=>c+l.inputTokens+l.outputTokens,0);i.set(o,{totalCost:a,totalTokens:s,totalRequests:n.length,avgCostPerRequest:a/n.length,avgCostPerToken:s>0?a/s:0})}return i}getCostByAgentType(e="all"){let t=this.getPeriodStart(e),r=this.filterByTime(t),i=new Set;r.forEach(a=>a.agentType&&i.add(a.agentType));let o=new Map;for(let a of i){let s=r.filter(d=>d.agentType===a),c=s.reduce((d,g)=>d+g.totalCost,0),l=s.reduce((d,g)=>d+g.inputTokens+g.outputTokens,0);o.set(a,{totalCost:c,totalTokens:l,totalRequests:s.length,avgCostPerRequest:s.length>0?c/s.length:0,avgCostPerToken:l>0?c/l:0})}let n=r.filter(a=>!a.agentType);if(n.length>0){let a=n.reduce((c,l)=>c+l.totalCost,0),s=n.reduce((c,l)=>c+l.inputTokens+l.outputTokens,0);o.set("unknown",{totalCost:a,totalTokens:s,totalRequests:n.length,avgCostPerRequest:a/n.length,avgCostPerToken:s>0?a/s:0})}return o}getCostByModel(e="all"){let t=this.getPeriodStart(e),r=this.filterByTime(t),i=new Set;r.forEach(n=>i.add(n.model));let o=new Map;for(let n of i){let a=r.filter(l=>l.model===n),s=a.reduce((l,d)=>l+d.totalCost,0),c=a.reduce((l,d)=>l+d.inputTokens+d.outputTokens,0);o.set(n,{totalCost:s,totalTokens:c,totalRequests:a.length,avgCostPerRequest:a.length>0?s/a.length:0,avgCostPerToken:c>0?s/c:0})}return o}getTotalCost(e="all"){let t=this.getPeriodStart(e);return this.filterByTime(t).reduce((i,o)=>i+o.totalCost,0)}getCostTrend(e){let t=new Date,r=[],i,o;switch(e){case"1h":i=300*1e3,o=12;break;case"24h":i=3600*1e3,o=24;break;case"7d":i=1440*60*1e3,o=7;break}for(let n=o-1;n>=0;n--){let a=new Date(t.getTime()-n*i),s=new Date(a.getTime()-i),c=this.records.filter(l=>l.timestamp>=s&&l.timestamp<a);r.push({timestamp:a,cost:c.reduce((l,d)=>l+d.totalCost,0),tokens:c.reduce((l,d)=>l+d.inputTokens+d.outputTokens,0),requests:c.length})}return r}addBudgetAlert(e,t,r){let i={threshold:e,period:t,callback:r,active:!0};return this.alerts.push(i),this.alertCheckInterval||(this.alertCheckInterval=setInterval(()=>this.checkAlerts(),6e4)),`alert-${this.alerts.length-1}`}removeBudgetAlert(e){return e>=0&&e<this.alerts.length?(this.alerts.splice(e,1),this.alerts.length===0&&this.alertCheckInterval&&(clearInterval(this.alertCheckInterval),this.alertCheckInterval=void 0),!0):!1}getOptimizationSuggestions(){let e=[],t=this.getCostByModel("24h");for(let[n,a]of t)k[n]&&a.totalCost>1&&(n.includes("opus")&&e.push({type:"model-switch",description:"Consider using Sonnet instead of Opus for non-critical tasks",estimatedSavings:a.totalCost*.5,currentCost:a.totalCost,suggestedModel:"claude-sonnet-4-6"}),n==="gpt-4o"&&e.push({type:"model-switch",description:"Consider using GPT-4o-mini for simpler tasks",estimatedSavings:a.totalCost*.7,currentCost:a.totalCost,suggestedModel:"gpt-4o-mini"}));let r=this.getCostByProvider("24h"),i=[...r.values()].reduce((n,a)=>n+a.totalCost,0);return i>10&&!r.has("ollama")&&e.push({type:"provider-switch",description:"Consider using Ollama for development/testing workloads",estimatedSavings:i*.3,currentCost:i,suggestedProvider:"ollama"}),[...t.values()].reduce((n,a)=>n+a.totalRequests,0)>100&&e.push({type:"caching",description:"Enable response caching to reduce redundant API calls",estimatedSavings:i*.15,currentCost:i}),e}getRecords(){return[...this.records]}clear(){this.records=[]}reset(){this.records=[],this.alerts=[],this.alertCheckInterval&&(clearInterval(this.alertCheckInterval),this.alertCheckInterval=void 0)}dispose(){this.alertCheckInterval&&(clearInterval(this.alertCheckInterval),this.alertCheckInterval=void 0)}calculateCost(e,t,r){let i=k[e];if(!i)return{inputCost:0,outputCost:0,totalCost:0,currency:"USD"};let o=t/1e6*i.input,n=r/1e6*i.output;return{inputCost:o,outputCost:n,totalCost:o+n,currency:"USD"}}trimRecords(){this.records.length>this.maxRecords&&(this.records=this.records.slice(-this.maxRecords))}getPeriodStart(e){let t=new Date;switch(e){case"1h":return new Date(t.getTime()-3600*1e3);case"24h":return new Date(t.getTime()-1440*60*1e3);case"7d":return new Date(t.getTime()-10080*60*1e3);case"30d":return new Date(t.getTime()-720*60*60*1e3);default:return new Date(0)}}filterByTime(e){return this.records.filter(t=>t.timestamp>=e)}checkAlerts(){for(let e of this.alerts){if(!e.active)continue;let t=this.getTotalCost(e.period);if(t>=e.threshold){e.active=!1;let r=this.getPeriodStart(e.period),i=this.filterByTime(r),o=i.reduce((n,a)=>n+a.inputTokens+a.outputTokens,0);try{e.callback({totalCost:t,totalTokens:o,totalRequests:i.length,avgCostPerRequest:i.length>0?t/i.length:0,avgCostPerToken:o>0?t/o:0})}catch(n){console.error("Budget alert callback error:",n)}}}}};function z(u){return new R(u)}J();var T=class{cache=new Map;maxSize;ttlMs;constructor(e=100,t=6e4){this.maxSize=e,this.ttlMs=t}get(e){let t=this.cache.get(e);return t?Date.now()>t.expiresAt?(this.cache.delete(e),null):t.decision:null}set(e,t){if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}this.cache.set(e,{decision:t,expiresAt:Date.now()+this.ttlMs})}clear(){this.cache.clear()}getStats(){return{hits:0,misses:0,size:this.cache.size}}},M=class{config;providerManager;ruleEngine;decisionCache;metrics;routerMetrics;costMetrics;initialized=!1;constructor(e,t){this.providerManager=e,this.config={...G,...t};let r=this.config.rules.length>0?this.config.rules:L;this.ruleEngine=new f(r),this.decisionCache=new T(100,this.config.decisionCacheTtlMs),this.metrics=new O,this.routerMetrics=I(),this.costMetrics=z()}async initialize(){this.initialized||(await this.providerManager.initialize(),this.initialized=!0)}getMode(){return this.config.mode}setMode(e){this.config.mode=e,this.decisionCache.clear()}getConfig(){return{...this.config}}updateConfig(e){this.config={...this.config,...e},e.rules&&this.ruleEngine.setRules(e.rules),e.decisionCacheTtlMs&&(this.decisionCache=new T(100,e.decisionCacheTtlMs))}async selectProvider(e){await this.ensureInitialized();let t=Date.now();if(this.config.cacheDecisions){let i=this.generateCacheKey(e),o=this.decisionCache.get(i);if(o)return this.metrics.recordCacheHit(),this.routerMetrics.recordCacheHit(),o;this.metrics.recordCacheMiss(),this.routerMetrics.recordCacheMiss()}let r;switch(this.config.mode){case"manual":r=await this.selectManual(e);break;case"rule-based":r=await this.selectRuleBased(e);break;case"cost-optimized":r=await this.selectCostOptimized(e);break;case"performance-optimized":r=await this.selectPerformanceOptimized(e);break;default:r=await this.selectRuleBased(e)}if(r.metadata.decisionTimeMs=Date.now()-t,this.config.cacheDecisions){let i=this.generateCacheKey(e);this.decisionCache.set(i,r)}return this.metrics.recordDecision(r,this.config.mode),r}async chat(e){await this.ensureInitialized();let t=_(),r=await this.selectProvider(e),i=e.agentType??"";if(V(i)&&(D(r.model)||D(r.providerModelId))){let n=r.model,a=r.providerModelId;r.model=E(i,r.model,A),r.providerModelId=E(i,r.providerModelId,A),console.warn(`[aqe] ADR-093: ${i} pinned to ${r.model} (was ${n}/${a}); set AQE_CYBER_VERIFIED=true after Cyber Verification Program approval`)}return await this.executeWithFallback(e,r,t)}async*stream(e){await this.ensureInitialized();let t=await this.selectProvider(e),r=await this.chat(e),i=100;for(let o=0;o<r.content.length;o+=i){let n=o+i>=r.content.length;yield{type:n?"done":"content",delta:r.content.slice(o,o+i),accumulated:r.content.slice(0,o+i),done:n,tokenCount:Math.ceil((o+i)/4),model:r.model,provider:t.providerType,usage:n?r.usage:void 0}}}getMetrics(){return this.metrics.getMetrics()}getEnhancedMetrics(e){return this.routerMetrics.getMetrics(e)}getProviderMetrics(e){return this.routerMetrics.getMetricsByProvider(e)}getAgentMetrics(e){return this.routerMetrics.getMetricsByAgentType(e)}getCostByProvider(e){return this.costMetrics.getCostByProvider(e)}getCostByAgentType(e){return this.costMetrics.getCostByAgentType(e)}getCostByModel(e){return this.costMetrics.getCostByModel(e)}getTotalCost(e){return this.costMetrics.getTotalCost(e)}getCostTrend(e){return this.costMetrics.getCostTrend(e)}getAuditLog(e){return this.routerMetrics.getAuditLog(e)}getOptimizationSuggestions(){return this.costMetrics.getOptimizationSuggestions()}resetMetrics(){this.metrics.reset(),this.routerMetrics.resetMetrics(),this.costMetrics.reset()}clearCache(){this.decisionCache.clear()}async selectManual(e){let t=e.preferredProvider??this.config.defaultProvider,r=e.model??this.config.defaultModel,i=this.providerManager.getProvider(t);return i?this.createDecision(i,t,r,"manual"):this.createFallbackDecision(e,"manual")}async selectRuleBased(e){let t=this.ruleEngine.evaluate(e);if(t){let{rule:o,rulesEvaluated:n}=t,a=o.action.provider,s=this.providerManager.getProvider(a);if(s){let c=this.createDecision(s,a,o.action.model,"rule-match",o);return c.metadata.rulesEvaluated=n,c}}let r=this.config.defaultProvider,i=this.providerManager.getProvider(r);return i?this.createDecision(i,r,this.config.defaultModel,"default"):this.createFallbackDecision(e,"rule-based")}async selectCostOptimized(e){let t=this.providerManager.getAvailableProviders();if(t.length===0)return this.createFallbackDecision(e,"cost-optimized");let r=1/0,i=t[0],o,n=[];for(let a of t){let s=this.providerManager.getProvider(a);if(!s)continue;let{input:c,output:l}=s.getCostPerToken(),d=this.estimateCostValue(e,c,l);n.push({provider:a,model:s.getConfig().model,reason:`Estimated cost: $${d.toFixed(6)}`,estimatedCost:d,excluded:!1}),d<r&&(r=d,i=a,o=s)}if(o){let a=o.getConfig(),s=this.createDecision(o,i,a.model,"cost-optimization");return s.metadata.estimatedCost=this.createCostEstimate(e,o),s.metadata.alternativesConsidered=n,s}return this.createFallbackDecision(e,"cost-optimized")}async selectPerformanceOptimized(e){let t=this.providerManager.getAvailableProviders(),r=this.providerManager.getMetrics();if(t.length===0)return this.createFallbackDecision(e,"performance-optimized");let i=1/0,o=t[0],n,a=[];for(let s of t){let c=this.providerManager.getProvider(s);if(!c)continue;let d=r[s]?.avgLatencyMs??1/0;a.push({provider:s,model:c.getConfig().model,reason:`Avg latency: ${d}ms`,estimatedLatencyMs:d,excluded:!1}),d<i&&(i=d,o=s,n=c)}if(n){let s=n.getConfig(),c=this.createDecision(n,o,s.model,"performance-optimization");return c.metadata.estimatedLatencyMs=i,c.metadata.alternativesConsidered=a,c}return this.createFallbackDecision(e,"performance-optimized")}async executeWithFallback(e,t,r){let{fallbackChain:i,fallbackBehavior:o}=this.config,n,a=0,s=[{provider:t.providerType,model:t.providerModelId}],c=this.config.defaultProvider;c&&c!==t.providerType&&s.push({provider:c,model:this.config.defaultModel});for(let d of i.entries)if(d.enabled&&d.provider!==t.providerType)for(let g of d.models)s.push({provider:d.provider,model:g});let l=s;if(e.requiresTools){let d=s.filter(g=>w(g.model));if(d.length>0&&d.length<s.length){let g=s.filter(m=>!w(m.model)).map(m=>`${m.provider}:${m.model}`);console.warn(`[llm-router] requiresTools: skipping tool-less model(s) ${g.join(", ")}`),l=d}}this.providerManager.assertWithinBudget(e.messages,{model:l[0]?.model,maxTokens:e.maxTokens});for(let{provider:d,model:g}of l){if(a>=o.maxAttempts)break;let m=this.providerManager.getProvider(d);if(!m)continue;a++;let b=Date.now();try{let p=await m.generate(e.messages,{model:g,temperature:e.temperature,maxTokens:e.maxTokens,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,skipCache:e.skipCache,metadata:e.metadata});this.providerManager.recordResponseSpend(p,e.agentType);let h=Date.now()-b;return this.metrics.recordSuccess(d),this.routerMetrics.recordRoutingDecision(t,h,{agentType:e.agentType,success:!0,tokenUsage:p.usage,cost:p.cost}),this.routerMetrics.recordProviderCall(d,g,h,p.usage.totalTokens,{inputTokens:p.usage.promptTokens,outputTokens:p.usage.completionTokens,success:!0,cost:p.cost.totalCost,agentType:e.agentType}),this.costMetrics.recordCostFromInfo(d,g,p.usage,p.cost,{agentType:e.agentType,requestId:p.requestId}),{content:p.content,model:p.model,providerModelId:p.model,provider:p.provider,usage:p.usage,cost:p.cost,latencyMs:p.latencyMs,finishReason:p.finishReason,cached:p.cached,requestId:p.requestId,routingDecision:t}}catch(p){n=F(p);let h=Date.now()-b;if(this.metrics.recordFailure(d),this.routerMetrics.recordProviderCall(d,g,h,0,{success:!1,agentType:e.agentType}),a<s.length){let B=s[a];B&&this.routerMetrics.recordFallback(d,B.provider,n.message,e.agentType)}!(U(p)&&!p.retryable)&&a<o.maxAttempts&&await this.delay(o.delayMs)}}throw P(`All providers failed after ${a} attempts: ${n?.message??"Unknown error"}`,"PROVIDER_UNAVAILABLE",{retryable:!1,cause:n})}createDecision(e,t,r,i,o){let{canonicalModel:n,providerModelId:a}=this.resolveModelIds(r,t);return{provider:e,providerType:t,model:n,providerModelId:a,reason:i,matchedRule:o,confidence:i==="rule-match"?.95:.8,metadata:{decisionTimeMs:0,timestamp:new Date}}}resolveModelIds(e,t){let i={claude:"anthropic","claude-code":"anthropic",openai:"openai",ollama:"ollama",openrouter:"openrouter",gemini:"gemini","azure-openai":"azure",bedrock:"bedrock"}[t];if(!i)return{canonicalModel:e,providerModelId:e};try{let o=$(e),n=x(o,i);return{canonicalModel:o,providerModelId:n}}catch{try{if(H(e)){let n=x(e,i);return{canonicalModel:e,providerModelId:n}}}catch{}return{canonicalModel:e,providerModelId:e}}}createFallbackDecision(e,t){for(let i of this.config.fallbackChain.entries){if(!i.enabled||!["claude","openai","ollama"].includes(i.provider))continue;let n=this.providerManager.getProvider(i.provider);if(n)return this.createDecision(n,i.provider,i.models[0],"fallback")}let r=this.providerManager.getAvailableProviders();if(r.length>0){let i=r[0],o=this.providerManager.getProvider(i);return this.createDecision(o,i,o.getConfig().model,"fallback")}throw P(`No providers available for ${t} selection`,"PROVIDER_UNAVAILABLE",{retryable:!1})}generateCacheKey(e){return[this.config.mode,e.agentType??"default",e.complexity??"medium",e.requiresTools?"tools":"no-tools",e.preferredProvider??"any"].join(":")}estimateCostValue(e,t,r){let i=0;e.systemPrompt&&(i+=Math.ceil(e.systemPrompt.length/4));for(let n of e.messages)i+=Math.ceil(n.content.length/4);let o=e.maxTokens??1e3;return i*t+o*r}createCostEstimate(e,t){let{input:r,output:i}=t.getCostPerToken(),o=0;e.systemPrompt&&(o+=Math.ceil(e.systemPrompt.length/4));for(let s of e.messages)o+=Math.ceil(s.content.length/4);let n=e.maxTokens??1e3,a=o*r+n*i;return{inputTokens:o,outputTokens:n,totalCostUsd:a,inputCostPer1M:r*1e6,outputCostPer1M:i*1e6}}delay(e){return new Promise(t=>setTimeout(t,e))}async ensureInitialized(){this.initialized||await this.initialize()}},O=class{decisions=new Map;decisionsByMode={manual:0,"rule-based":0,"cost-optimized":0,"performance-optimized":0};totalDecisions=0;cacheHits=0;cacheMisses=0;totalRulesEvaluated=0;rulesMatched=0;fallbackCount=0;startTime=new Date;recordDecision(e,t){this.totalDecisions++,this.decisionsByMode[t]++,e.metadata.rulesEvaluated&&(this.totalRulesEvaluated+=e.metadata.rulesEvaluated),e.matchedRule&&this.rulesMatched++,e.reason==="fallback"&&this.fallbackCount++;let r=this.decisions.get(e.providerType);r||(r=this.createEmptyMetrics(e.providerType),this.decisions.set(e.providerType,r)),r.selectionCount++,e.reason==="rule-match"&&r.ruleMatchCount++,e.reason==="fallback"&&r.fallbackCount++}recordSuccess(e){let t=this.decisions.get(e);if(t){let r=t.successRate*t.selectionCount;t.successRate=(r+1)/t.selectionCount}}recordFailure(e){}recordCacheHit(){this.cacheHits++}recordCacheMiss(){this.cacheMisses++}getMetrics(){let e={};for(let[r,i]of this.decisions)e[r]={...i};let t=this.totalDecisions>0?this.rulesMatched/this.totalDecisions:0;return{byProvider:e,totalDecisions:this.totalDecisions,decisionsByMode:{...this.decisionsByMode},avgDecisionTimeMs:0,p95DecisionTimeMs:0,p99DecisionTimeMs:0,fallbackRate:this.totalDecisions>0?this.fallbackCount/this.totalDecisions:0,ruleMatchRate:t,estimatedCostSavings:0,ruleStats:{totalEvaluated:this.totalRulesEvaluated,matched:this.rulesMatched,avgRulesPerDecision:this.totalDecisions>0?this.totalRulesEvaluated/this.totalDecisions:0},cacheStats:{hits:this.cacheHits,misses:this.cacheMisses,hitRate:this.cacheHits+this.cacheMisses>0?this.cacheHits/(this.cacheHits+this.cacheMisses):0},period:{start:this.startTime,end:new Date}}}reset(){this.decisions.clear(),this.decisionsByMode={manual:0,"rule-based":0,"cost-optimized":0,"performance-optimized":0},this.totalDecisions=0,this.cacheHits=0,this.cacheMisses=0,this.totalRulesEvaluated=0,this.rulesMatched=0,this.fallbackCount=0,this.startTime=new Date}createEmptyMetrics(e){return{provider:e,selectionCount:0,ruleMatchCount:0,fallbackCount:0,avgDecisionTimeMs:0,successRate:1,avgLatencyMs:0,p95LatencyMs:0,p99LatencyMs:0,totalCost:0,totalTokens:0,circuitState:"closed"}}};function tt(u,e){return new M(u,e)}function rt(u){return new M(u,{mode:"rule-based",rules:L,defaultProvider:"claude",defaultModel:"claude-sonnet-4-6",enableMetrics:!0,cacheDecisions:!0})}export{Z as a,ee as b,L as c,M as d,tt as e,rt as f};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{c as a,d as b,e as c}from"./chunk-WE3VKDMK.js";import"./chunk-ZSAGRDXA.js";import"./chunk-L3GBNX7B.js";import"./chunk-ZMYV4R32.js";c();export{a as VibiumClientImpl,b as VibiumClientProvider};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k,n as l}from"./chunk-IPZEBALY.js";import"./chunk-M3354CE4.js";import"./chunk-UJUK6T4V.js";import"./chunk-4YFXF5AQ.js";import"./chunk-DCVFHVPR.js";import"./chunk-5PI75QYP.js";import"./chunk-QG5L2JM5.js";import"./chunk-66OQ7AB3.js";import"./chunk-MYVKTG55.js";import"./chunk-IPDM3CAK.js";import"./chunk-X2SZCVDA.js";import"./chunk-WXU7FAEB.js";import"./chunk-SXFSJJZF.js";import"./chunk-4FVOJBEU.js";import"./chunk-XT473WPO.js";import"./chunk-DGFINXUE.js";import"./chunk-TB2N3CAK.js";import"./chunk-HRTSYT4N.js";import"./chunk-I5SXLV7D.js";import"./chunk-A5RWLPVT.js";import"./chunk-AYH3DMW2.js";import"./chunk-MLFELTJX.js";import"./chunk-NDRZZSD5.js";import"./chunk-KXSUDN46.js";import"./chunk-LXVT6JXO.js";import"./chunk-NG6A7LCG.js";import"./chunk-6BSZHNOC.js";import"./chunk-WE3VKDMK.js";import"./chunk-7PCIN7UN.js";import"./chunk-2VY7FL6A.js";import"./chunk-IQH2RDN3.js";import"./chunk-P6EFKHNI.js";import"./chunk-NL2SCAGJ.js";import"./chunk-NJ3QXJ54.js";import"./chunk-X3JNFQW2.js";import"./chunk-XIKYUBIV.js";import"./chunk-IT5QIUUA.js";import"./chunk-HAJG44BD.js";import"./chunk-NTALX2YC.js";import"./chunk-DFLASG3B.js";import"./chunk-BODFJ3DC.js";import"./chunk-SCQNISGS.js";import"./chunk-RP5VFZJO.js";import"./chunk-BZIPYXSW.js";import"./chunk-OG3DBHIV.js";import"./chunk-ZSAGRDXA.js";import"./chunk-4ANJV6I4.js";import"./chunk-G45AOQDZ.js";import"./chunk-FI6J3UHJ.js";import"./chunk-GJJWXRAD.js";import"./chunk-4THFPRFM.js";import"./chunk-PVINNJ4P.js";import"./chunk-7A4WTRWI.js";import"./chunk-5VSS2RBD.js";import"./chunk-33YZGOT6.js";import"./chunk-QXO35J6F.js";import"./chunk-NNLZAVFH.js";import"./chunk-NJ4YVAG7.js";import"./chunk-AKUDUB3O.js";import"./chunk-R7LGVJMZ.js";import"./chunk-5PNQNBDZ.js";import"./chunk-QM4Z7TQH.js";import"./chunk-RACWX2ZX.js";import"./chunk-GQLJYTXN.js";import"./chunk-NLZUGANH.js";import"./chunk-UC4EIULB.js";import"./chunk-4AITMWFZ.js";import"./chunk-SNC73DWF.js";import"./chunk-WA6CSEOX.js";import"./chunk-WYFAPA2G.js";import"./chunk-WYIXNHPF.js";import"./chunk-MGKH4LCM.js";import"./chunk-TDVMILKO.js";import"./chunk-G6FJHDUG.js";import"./chunk-UQ4UCHO7.js";import"./chunk-Z6DSYLAG.js";import"./chunk-RP2BRRLX.js";import"./chunk-TJVTV3HP.js";import"./chunk-TWUWLSGQ.js";import"./chunk-TK5XLF3Z.js";import"./chunk-4M7YZ2X7.js";import"./chunk-44NPKZGI.js";import"./chunk-OZ53BIY5.js";import"./chunk-YQOQVSYU.js";import"./chunk-GMLRIZ4E.js";import"./chunk-VNODKACB.js";import"./chunk-2W3D5A4R.js";import"./chunk-UWZYXI3R.js";import"./chunk-H3GAR4SV.js";import"./chunk-VQD2ELNL.js";import"./chunk-O4BWESH5.js";import"./chunk-S6WHYOWV.js";import"./chunk-PGFCKE4G.js";import"./chunk-M73KM3AZ.js";import"./chunk-KRZYWVS3.js";import"./chunk-3ASVQILY.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-6KI6LAAZ.js";import"./chunk-VA2ORJB5.js";import"./chunk-7ZVO7I4Q.js";import"./chunk-HQWFZQMJ.js";import"./chunk-EDRPTLAX.js";import"./chunk-E67ZXRG6.js";import"./chunk-L3GBNX7B.js";import"./chunk-52VGZJSD.js";import"./chunk-XM5I7J5S.js";import"./chunk-Z56BBX77.js";import"./chunk-5E76HULA.js";import"./chunk-7LATB5IR.js";import"./chunk-4Z4X2ND4.js";import"./chunk-U5G6OC2C.js";import"./chunk-JVFZAJ5N.js";import"./chunk-2VTX4SYW.js";import"./chunk-N4OQ4D4V.js";import"./chunk-AN5CGTTJ.js";import"./chunk-ZMYV4R32.js";export{c as adoptExternalFleet,e as assignAgentLevel,k as disposeFleet,f as getAgentLevel,g as getAllAgentLevels,a as getFleetState,d as getFleetTopology,l as handleAQEHealth,j as handleFleetHealth,h as handleFleetInit,i as handleFleetStatus,b as isFleetInitialized};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a,b}from"./chunk-QXO35J6F.js";import"./chunk-NNLZAVFH.js";import"./chunk-E67ZXRG6.js";import"./chunk-52VGZJSD.js";import"./chunk-ZMYV4R32.js";export{a as CrossDomainEventRouter,b as createCrossDomainRouter};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t,v as u}from"./chunk-IQH2RDN3.js";import"./chunk-P6EFKHNI.js";import"./chunk-NL2SCAGJ.js";import"./chunk-NJ3QXJ54.js";import"./chunk-TWUWLSGQ.js";import"./chunk-TK5XLF3Z.js";import"./chunk-4M7YZ2X7.js";import"./chunk-44NPKZGI.js";import"./chunk-OZ53BIY5.js";import"./chunk-YQOQVSYU.js";import"./chunk-GMLRIZ4E.js";import"./chunk-VNODKACB.js";import"./chunk-2W3D5A4R.js";import"./chunk-UWZYXI3R.js";import"./chunk-H3GAR4SV.js";import"./chunk-VQD2ELNL.js";import"./chunk-O4BWESH5.js";import"./chunk-S6WHYOWV.js";import"./chunk-PGFCKE4G.js";import"./chunk-M73KM3AZ.js";import"./chunk-KRZYWVS3.js";import"./chunk-3ASVQILY.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-6KI6LAAZ.js";import"./chunk-VA2ORJB5.js";import"./chunk-7ZVO7I4Q.js";import"./chunk-HQWFZQMJ.js";import"./chunk-EDRPTLAX.js";import"./chunk-E67ZXRG6.js";import"./chunk-L3GBNX7B.js";import"./chunk-52VGZJSD.js";import"./chunk-Z56BBX77.js";import"./chunk-5E76HULA.js";import"./chunk-7LATB5IR.js";import"./chunk-4Z4X2ND4.js";import"./chunk-U5G6OC2C.js";import"./chunk-JVFZAJ5N.js";import"./chunk-2VTX4SYW.js";import"./chunk-N4OQ4D4V.js";import"./chunk-AN5CGTTJ.js";import"./chunk-ZMYV4R32.js";export{q as BUILT_IN_STRATEGIES,b as ConceptGraph,g as DEFAULT_ACTIVATION_CONFIG,a as DEFAULT_CONCEPT_GRAPH_CONFIG,m as DEFAULT_DREAM_CONFIG,s as DEFAULT_DREAM_SCHEDULER_CONFIG,i as DEFAULT_INSIGHT_CONFIG,k as DEFAULT_VALIDATION_THRESHOLDS,n as DreamEngine,t as DreamScheduler,f as HISTORY_TRIM_TARGET_RATIO,j as InsightGenerator,d as MAX_ACTIVATION_HISTORY_ENTRIES,e as MAX_COACTIVATION_ENTRIES,l as RVCOWBranchManager,r as SpeculativeDreamer,h as SpreadingActivation,c as createConceptGraph,o as createDreamEngine,u as createDreamScheduler,p as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a as r,b as i}from"./chunk-PGFCKE4G.js";import"./chunk-L3GBNX7B.js";import"./chunk-JVFZAJ5N.js";import"./chunk-ZMYV4R32.js";async function u(a,o,d,s,m,t={}){try{let e=`${d??""} ${s??""} ${(m??[]).join(" ")}`.trim();if(!e)return;let n=await i(e,t);if(!n||n.length===0)return;let f=Buffer.from(new Float32Array(n).buffer),g={...r,...t};a.prepare(`INSERT OR REPLACE INTO qe_pattern_embeddings (pattern_id, embedding, dimension, model)
|
|
3
|
-
VALUES (?, ?, ?, ?)`).run(o,f,n.length,g.modelName)}catch(e){console.debug("[ensurePatternEmbedding] non-fatal:",e instanceof Error?e.message:String(e))}}export{u as ensurePatternEmbedding};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{b as a}from"./chunk-ASWWBNX2.js";import"./chunk-LXVT6JXO.js";import"./chunk-NG6A7LCG.js";import"./chunk-6BSZHNOC.js";import"./chunk-YQOQVSYU.js";import"./chunk-M73KM3AZ.js";import"./chunk-KRZYWVS3.js";import"./chunk-3ASVQILY.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-6KI6LAAZ.js";import"./chunk-VA2ORJB5.js";import"./chunk-L3GBNX7B.js";import"./chunk-Z56BBX77.js";import"./chunk-5E76HULA.js";import"./chunk-7LATB5IR.js";import"./chunk-4Z4X2ND4.js";import"./chunk-U5G6OC2C.js";import"./chunk-JVFZAJ5N.js";import"./chunk-2VTX4SYW.js";import"./chunk-N4OQ4D4V.js";import"./chunk-AN5CGTTJ.js";import"./chunk-ZMYV4R32.js";export{a as HeartbeatSchedulerWorker};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a,b}from"./chunk-2VTX4SYW.js";import"./chunk-N4OQ4D4V.js";import"./chunk-AN5CGTTJ.js";import"./chunk-ZMYV4R32.js";b();export{a as HnswAdapter};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a,b,c,d}from"./chunk-TJVTV3HP.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-4Z4X2ND4.js";import"./chunk-2VTX4SYW.js";import"./chunk-N4OQ4D4V.js";import"./chunk-AN5CGTTJ.js";import"./chunk-ZMYV4R32.js";export{a as DEFAULT_HNSW_CONFIG,b as HNSWIndex,d as benchmarkHNSW,c as createHNSWIndex};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{d as a,e as b,f as c}from"./chunk-WYIXNHPF.js";import"./chunk-MGKH4LCM.js";import"./chunk-TDVMILKO.js";import"./chunk-G6FJHDUG.js";import"./chunk-UQ4UCHO7.js";import"./chunk-Z6DSYLAG.js";import"./chunk-L3GBNX7B.js";import"./chunk-52VGZJSD.js";import"./chunk-ZMYV4R32.js";export{a as HybridRouter,b as createHybridRouter,c as createQERouter};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a}from"./chunk-RP5VFZJO.js";import"./chunk-BZIPYXSW.js";import"./chunk-OG3DBHIV.js";import"./chunk-WYFAPA2G.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-VA2ORJB5.js";import"./chunk-E67ZXRG6.js";import"./chunk-L3GBNX7B.js";import"./chunk-52VGZJSD.js";import"./chunk-ZMYV4R32.js";export{a as ImpactAnalyzerService};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{a,b,c,d}from"./chunk-LRO74LPA.js";import"./chunk-GJUGG6UR.js";import"./chunk-AM42ROKZ.js";import"./chunk-SCQNISGS.js";import"./chunk-FI6J3UHJ.js";import"./chunk-VA2ORJB5.js";import"./chunk-L3GBNX7B.js";import"./chunk-Z56BBX77.js";import"./chunk-5E76HULA.js";import"./chunk-ZMYV4R32.js";export{a as InitOrchestrator,b as createInitOrchestrator,d as formatInitResult,c as quickInit};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{A as b,z as a}from"./chunk-QG5L2JM5.js";import"./chunk-66OQ7AB3.js";import"./chunk-MYVKTG55.js";import"./chunk-IPDM3CAK.js";import"./chunk-X2SZCVDA.js";import"./chunk-WXU7FAEB.js";import"./chunk-4FVOJBEU.js";import"./chunk-DGFINXUE.js";import"./chunk-TB2N3CAK.js";import"./chunk-HRTSYT4N.js";import"./chunk-AYH3DMW2.js";import"./chunk-KXSUDN46.js";import"./chunk-WE3VKDMK.js";import"./chunk-7PCIN7UN.js";import"./chunk-2VY7FL6A.js";import"./chunk-IQH2RDN3.js";import"./chunk-P6EFKHNI.js";import"./chunk-NL2SCAGJ.js";import"./chunk-NJ3QXJ54.js";import"./chunk-IT5QIUUA.js";import"./chunk-NTALX2YC.js";import"./chunk-DFLASG3B.js";import"./chunk-BODFJ3DC.js";import"./chunk-SCQNISGS.js";import"./chunk-RP5VFZJO.js";import"./chunk-BZIPYXSW.js";import"./chunk-OG3DBHIV.js";import"./chunk-ZSAGRDXA.js";import"./chunk-GJJWXRAD.js";import"./chunk-4THFPRFM.js";import"./chunk-7A4WTRWI.js";import"./chunk-5VSS2RBD.js";import"./chunk-33YZGOT6.js";import"./chunk-NNLZAVFH.js";import"./chunk-RACWX2ZX.js";import"./chunk-GQLJYTXN.js";import"./chunk-NLZUGANH.js";import"./chunk-UC4EIULB.js";import"./chunk-4AITMWFZ.js";import"./chunk-SNC73DWF.js";import"./chunk-WA6CSEOX.js";import"./chunk-WYFAPA2G.js";import"./chunk-WYIXNHPF.js";import"./chunk-MGKH4LCM.js";import"./chunk-TDVMILKO.js";import"./chunk-G6FJHDUG.js";import"./chunk-UQ4UCHO7.js";import"./chunk-Z6DSYLAG.js";import"./chunk-RP2BRRLX.js";import"./chunk-TJVTV3HP.js";import"./chunk-TWUWLSGQ.js";import"./chunk-TK5XLF3Z.js";import"./chunk-4M7YZ2X7.js";import"./chunk-44NPKZGI.js";import"./chunk-OZ53BIY5.js";import"./chunk-YQOQVSYU.js";import"./chunk-GMLRIZ4E.js";import"./chunk-VNODKACB.js";import"./chunk-2W3D5A4R.js";import"./chunk-UWZYXI3R.js";import"./chunk-H3GAR4SV.js";import"./chunk-VQD2ELNL.js";import"./chunk-O4BWESH5.js";import"./chunk-S6WHYOWV.js";import"./chunk-PGFCKE4G.js";import"./chunk-M73KM3AZ.js";import"./chunk-KRZYWVS3.js";import"./chunk-3ASVQILY.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-6KI6LAAZ.js";import"./chunk-VA2ORJB5.js";import"./chunk-7ZVO7I4Q.js";import"./chunk-HQWFZQMJ.js";import"./chunk-EDRPTLAX.js";import"./chunk-E67ZXRG6.js";import"./chunk-L3GBNX7B.js";import"./chunk-52VGZJSD.js";import"./chunk-XM5I7J5S.js";import"./chunk-Z56BBX77.js";import"./chunk-5E76HULA.js";import"./chunk-7LATB5IR.js";import"./chunk-4Z4X2ND4.js";import"./chunk-U5G6OC2C.js";import"./chunk-JVFZAJ5N.js";import"./chunk-2VTX4SYW.js";import"./chunk-N4OQ4D4V.js";import"./chunk-AN5CGTTJ.js";import"./chunk-ZMYV4R32.js";export{a as QEKernelImpl,b as createKernel};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.13.12");process.exit(0)}
|
|
2
|
-
import{g as a}from"./chunk-BZIPYXSW.js";import"./chunk-OG3DBHIV.js";import"./chunk-WYFAPA2G.js";import"./chunk-GEQWCK4F.js";import"./chunk-IOJ34SXJ.js";import"./chunk-VA2ORJB5.js";import"./chunk-E67ZXRG6.js";import"./chunk-L3GBNX7B.js";import"./chunk-ZMYV4R32.js";export{a as KnowledgeGraphService};
|