@askexenow/exe-os 0.9.287 → 0.9.289
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/deploy/compose/.env.customer.example +10 -1
- package/deploy/compose/.env.example +8 -1
- package/deploy/compose/README.md +27 -0
- package/deploy/compose/docker-compose.yml +72 -54
- package/deploy/compose/generate-env.ts +16 -2
- package/deploy/compose/setup.sh +63 -0
- package/dist/active-agent-DVMG6WVY.js +27 -0
- package/dist/active-agent-JJVXXRZV.js +26 -0
- package/dist/active-agent-KB4346K6.js +26 -0
- package/dist/active-agent-LTYLGBJX.js +27 -0
- package/dist/active-agent-V4W557J4.js +26 -0
- package/dist/active-agent-XZVU5XBO.js +27 -0
- package/dist/agentic-ontology-2LJST3BE.js +25 -0
- package/dist/agentic-ontology-4PNQX4YW.js +25 -0
- package/dist/agentic-ontology-WOTOTSR7.js +25 -0
- package/dist/backfill-metadata-O2BQIEVT.js +599 -0
- package/dist/backfill-metadata-PHXNTBNR.js +599 -0
- package/dist/backfill-metadata-W7PJ6YGP.js +599 -0
- package/dist/background-jobs-RIECIYW5.js +25 -0
- package/dist/background-jobs-YTYZRTCM.js +25 -0
- package/dist/behaviors-EM5KZSHT.js +39 -0
- package/dist/behaviors-MO5BWFPW.js +39 -0
- package/dist/behaviors-TMA2HRTL.js +39 -0
- package/dist/bin/age-ontology-load.js +2 -2
- package/dist/bin/agentic-ontology-backfill.js +8 -8
- package/dist/bin/agentic-reflection-backfill.js +9 -9
- package/dist/bin/agentic-semantic-label.js +8 -8
- package/dist/bin/backfill-conversations.js +8 -8
- package/dist/bin/backfill-responses.js +8 -8
- package/dist/bin/backfill-vectors.js +11 -11
- package/dist/bin/bulk-sync-postgres.js +9 -9
- package/dist/bin/cc-doctor.js +8 -7
- package/dist/bin/cleanup-stale-review-tasks.js +14 -14
- package/dist/bin/cli.js +20 -20
- package/dist/bin/deferred-daemon-restart.js +1 -1
- package/dist/bin/exe-agent-config.js +5 -5
- package/dist/bin/exe-agent.js +10 -10
- package/dist/bin/exe-assign.js +10 -10
- package/dist/bin/exe-boot.js +33 -22
- package/dist/bin/exe-call.js +6 -6
- package/dist/bin/exe-cloud.js +8 -8
- package/dist/bin/exe-dispatch.js +14 -14
- package/dist/bin/exe-doctor.js +4 -1
- package/dist/bin/exe-export-behaviors.js +9 -9
- package/dist/bin/exe-forget.js +8 -8
- package/dist/bin/exe-gateway.js +9 -9
- package/dist/bin/exe-healthcheck.js +10 -7
- package/dist/bin/exe-heartbeat.js +14 -14
- package/dist/bin/exe-kill.js +17 -17
- package/dist/bin/exe-launch-agent.js +21 -21
- package/dist/bin/exe-new-employee.js +9 -9
- package/dist/bin/exe-pending-messages.js +15 -15
- package/dist/bin/exe-pending-notifications.js +14 -14
- package/dist/bin/exe-pending-reviews.js +14 -14
- package/dist/bin/exe-rename.js +6 -6
- package/dist/bin/exe-review.js +16 -16
- package/dist/bin/exe-search.js +7 -7
- package/dist/bin/exe-session-cleanup.js +19 -19
- package/dist/bin/exe-settings.js +8 -8
- package/dist/bin/exe-start-codex.js +13 -13
- package/dist/bin/exe-start-opencode.js +10 -10
- package/dist/bin/exe-start.sh +29 -7
- package/dist/bin/exe-status.js +15 -15
- package/dist/bin/exe-support.js +3 -3
- package/dist/bin/exe-team.js +5 -5
- package/dist/bin/git-sweep.js +15 -15
- package/dist/bin/graph-backfill.js +9 -9
- package/dist/bin/graph-export.js +7 -7
- package/dist/bin/import-history.js +11 -11
- package/dist/bin/install-launchd.js +24 -1
- package/dist/bin/install.js +36 -12
- package/dist/bin/intercom-check.js +4 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +6 -6
- package/dist/bin/postgres-agentic-reflection-backfill.js +4 -4
- package/dist/bin/postgres-agentic-semantic-backfill.js +3 -3
- package/dist/bin/scan-tasks.js +14 -14
- package/dist/bin/setup.js +2 -2
- package/dist/bin/shard-migrate.js +7 -7
- package/dist/bin/stack-update.js +7 -6
- package/dist/bin/vps-health-gate.js +1 -1
- package/dist/branding-6PY5DNDC.js +97 -0
- package/dist/branding-PCLBJ3EP.js +97 -0
- package/dist/capability-cards-4NKVY6GD.js +88 -0
- package/dist/capability-cards-OEL47N2B.js +88 -0
- package/dist/capability-cards-UD5TCSAZ.js +88 -0
- package/dist/capacity-monitor-AU7MVZED.js +50 -0
- package/dist/capacity-monitor-CV7PWPYR.js +50 -0
- package/dist/capacity-monitor-UGMHVSUD.js +50 -0
- package/dist/catchup-brief-AZND3EET.js +174 -0
- package/dist/catchup-brief-HNEUKB7X.js +174 -0
- package/dist/catchup-brief-TFL6MYOZ.js +154 -0
- package/dist/chunk-22R3G3GD.js +297 -0
- package/dist/chunk-2CO47E5Q.js +210 -0
- package/dist/chunk-2F5SG3CE.js +230 -0
- package/dist/chunk-2F5UVNYP.js +167 -0
- package/dist/chunk-2IJCGYY2.js +30 -0
- package/dist/chunk-2QMWIGJK.js +197 -0
- package/dist/chunk-2V52EJI7.js +14365 -0
- package/dist/chunk-2WCXJVSN.js +456 -0
- package/dist/chunk-2X52UGP7.js +190 -0
- package/dist/chunk-2ZAOSGBX.js +668 -0
- package/dist/chunk-32K5NWMR.js +42 -0
- package/dist/chunk-32VOJ4GK.js +181 -0
- package/dist/chunk-3AUM4JVV.js +127 -0
- package/dist/chunk-3H5FNTXS.js +85 -0
- package/dist/chunk-3OC6MJIX.js +210 -0
- package/dist/chunk-3OSDE4Y2.js +1119 -0
- package/dist/chunk-3Q4UEXDE.js +297 -0
- package/dist/chunk-3RZNDPPW.js +2113 -0
- package/dist/chunk-3X2ZT5FN.js +3276 -0
- package/dist/chunk-43QFBQHT.js +1094 -0
- package/dist/chunk-44CP7NR2.js +333 -0
- package/dist/chunk-4EBW3URQ.js +4318 -0
- package/dist/chunk-4FMNDJMY.js +50 -0
- package/dist/chunk-4KVMYS3U.js +280 -0
- package/dist/chunk-4UTH3H4H.js +128 -0
- package/dist/chunk-5BKYHLA3.js +411 -0
- package/dist/chunk-5J2L25OK.js +203 -0
- package/dist/chunk-5NQOIKAB.js +214 -0
- package/dist/chunk-5P3HOBZX.js +487 -0
- package/dist/chunk-5RRYMKXN.js +150 -0
- package/dist/chunk-5TYYOPTD.js +50 -0
- package/dist/chunk-5VAARLQR.js +58 -0
- package/dist/chunk-5XOAYMSU.js +4318 -0
- package/dist/chunk-64GBV67L.js +1068 -0
- package/dist/chunk-6DQNLI55.js +240 -0
- package/dist/chunk-6GOT6FNJ.js +1352 -0
- package/dist/chunk-6KH24PJ7.js +221 -0
- package/dist/chunk-6MFM4N37.js +574 -0
- package/dist/chunk-6TV66RAI.js +192 -0
- package/dist/chunk-6UD5CM2H.js +244 -0
- package/dist/chunk-6WEETM7D.js +81 -0
- package/dist/chunk-6YR3J6WG.js +203 -0
- package/dist/chunk-6ZD3MW7T.js +97 -0
- package/dist/chunk-73ORCJNJ.js +231 -0
- package/dist/chunk-75GH76GO.js +129 -0
- package/dist/chunk-77HA7ATH.js +89 -0
- package/dist/chunk-7CHKD5IP.js +38 -0
- package/dist/chunk-7G52QPUX.js +271 -0
- package/dist/chunk-7GTKCVVG.js +735 -0
- package/dist/chunk-7K4YVOAK.js +76 -0
- package/dist/chunk-7LOYIUOF.js +456 -0
- package/dist/chunk-7M5ZHD4E.js +214 -0
- package/dist/chunk-7XUJF3LZ.js +284 -0
- package/dist/chunk-A3GC762G.js +333 -0
- package/dist/chunk-ALTFDYI6.js +97 -0
- package/dist/chunk-AN25OIRX.js +38 -0
- package/dist/chunk-AOWC2J6S.js +14225 -0
- package/dist/chunk-AVTDW4L6.js +562 -0
- package/dist/chunk-BEQTE7GH.js +668 -0
- package/dist/chunk-BJTBA4XS.js +290 -0
- package/dist/chunk-BJYLTU2G.js +621 -0
- package/dist/chunk-BQBPNRUW.js +231 -0
- package/dist/chunk-BQD4XYWX.js +159 -0
- package/dist/chunk-BR2OA4AZ.js +123 -0
- package/dist/chunk-BTP3LPMP.js +210 -0
- package/dist/chunk-BVFCZNJH.js +41 -0
- package/dist/chunk-BW7HTZMW.js +240 -0
- package/dist/chunk-BYOEIN37.js +176 -0
- package/dist/chunk-BZP3ZSRI.js +97 -0
- package/dist/chunk-C2NCSKRZ.js +373 -0
- package/dist/chunk-C3AH5JAS.js +510 -0
- package/dist/chunk-CEKZ77KA.js +471 -0
- package/dist/chunk-CMDKYYFK.js +630 -0
- package/dist/chunk-CNTBRVYW.js +54 -0
- package/dist/chunk-CTJQX44O.js +271 -0
- package/dist/chunk-CVG2PBCO.js +1105 -0
- package/dist/chunk-CZ47BFAT.js +299 -0
- package/dist/chunk-CZHC3HIO.js +362 -0
- package/dist/chunk-D6LUKYKM.js +731 -0
- package/dist/chunk-DFSI6HFJ.js +2078 -0
- package/dist/chunk-DIZOFRZO.js +284 -0
- package/dist/chunk-DJLDKRXK.js +30 -0
- package/dist/chunk-DRX46W5O.js +1068 -0
- package/dist/chunk-DYICAAAM.js +630 -0
- package/dist/chunk-E4BXNYLD.js +128 -0
- package/dist/chunk-EESAZNRC.js +348 -0
- package/dist/chunk-EKXOBH7F.js +227 -0
- package/dist/chunk-ELQZYKVN.js +394 -0
- package/dist/chunk-EQY6GDVD.js +369 -0
- package/dist/chunk-EVM22AGQ.js +382 -0
- package/dist/chunk-EY7TBDZ5.js +38 -0
- package/dist/chunk-EYLU6MJT.js +192 -0
- package/dist/chunk-F23GFLKY.js +4318 -0
- package/dist/chunk-F5SADWWW.js +240 -0
- package/dist/chunk-FDOEMBUB.js +345 -0
- package/dist/chunk-FE6HKM2N.js +157 -0
- package/dist/chunk-FG2OXKU5.js +539 -0
- package/dist/chunk-FP6TDXIL.js +456 -0
- package/dist/chunk-FTG36JG5.js +280 -0
- package/dist/chunk-FVWATWI2.js +377 -0
- package/dist/chunk-FZDW76SH.js +89 -0
- package/dist/chunk-G2OW4LUS.js +55 -0
- package/dist/chunk-G6GC2YSP.js +262 -0
- package/dist/chunk-GAYD7KBH.js +836 -0
- package/dist/chunk-GETGWHCO.js +227 -0
- package/dist/chunk-GGLUKNFC.js +1350 -0
- package/dist/chunk-GLEE2MUJ.js +262 -0
- package/dist/chunk-GUODMEAR.js +42 -0
- package/dist/chunk-H6LA4UV5.js +735 -0
- package/dist/chunk-H6PW4LNY.js +129 -0
- package/dist/chunk-HEMJ5RDU.js +345 -0
- package/dist/chunk-HH2JVSKL.js +1157 -0
- package/dist/chunk-HJQQ7746.js +185 -0
- package/dist/chunk-HLFNLJSB.js +271 -0
- package/dist/chunk-HMP6KB4V.js +382 -0
- package/dist/chunk-HX735WX7.js +33 -0
- package/dist/chunk-I35KAK3E.js +458 -0
- package/dist/chunk-I4DA5D5Q.js +1922 -0
- package/dist/chunk-I53O26HI.js +1119 -0
- package/dist/chunk-IBLEQQDQ.js +181 -0
- package/dist/chunk-IS2BEXUC.js +2113 -0
- package/dist/chunk-ISCEGQHA.js +244 -0
- package/dist/chunk-IUQBMSBI.js +1350 -0
- package/dist/chunk-J6PDP2GY.js +221 -0
- package/dist/chunk-JCERHH3L.js +85 -0
- package/dist/chunk-JCNCPBWU.js +97 -0
- package/dist/chunk-JEMLH7H2.js +1350 -0
- package/dist/chunk-JGOGSH55.js +14378 -0
- package/dist/chunk-JMR2X5FJ.js +630 -0
- package/dist/chunk-JR3MYBWG.js +2078 -0
- package/dist/chunk-JRZ47IFL.js +82 -0
- package/dist/chunk-JSEICUAL.js +197 -0
- package/dist/chunk-JZEROVAU.js +546 -0
- package/dist/chunk-K3KOLZTH.js +123 -0
- package/dist/chunk-K4OH3B2I.js +14248 -0
- package/dist/chunk-KFHAVF6J.js +97 -0
- package/dist/chunk-KJALZ6F6.js +128 -0
- package/dist/chunk-KMAIBYV3.js +402 -0
- package/dist/chunk-KMTNAXIB.js +54 -0
- package/dist/chunk-KQ4Z2G24.js +260 -0
- package/dist/chunk-KVH5DSTA.js +369 -0
- package/dist/chunk-L4R5NOVT.js +81 -0
- package/dist/chunk-LCB6YCE6.js +70 -0
- package/dist/chunk-LHW7TZGJ.js +244 -0
- package/dist/chunk-LIH36DXG.js +159 -0
- package/dist/chunk-M3VHV2RV.js +106 -0
- package/dist/chunk-M543SLJZ.js +1352 -0
- package/dist/chunk-M6KDMU5P.js +2113 -0
- package/dist/chunk-MDAGRPZG.js +197 -0
- package/dist/chunk-MFTGN7KN.js +411 -0
- package/dist/chunk-MLNOSXRZ.js +402 -0
- package/dist/chunk-MNI5K34D.js +290 -0
- package/dist/chunk-MUDH7ZLR.js +129 -0
- package/dist/chunk-MUHKJCF7.js +128 -0
- package/dist/chunk-MUMBWV57.js +379 -0
- package/dist/chunk-NAQLGLOG.js +176 -0
- package/dist/chunk-NIBCUAEI.js +123 -0
- package/dist/chunk-NIZCTXYW.js +89 -0
- package/dist/chunk-NS5G36TN.js +712 -0
- package/dist/chunk-NSKQWLQL.js +76 -0
- package/dist/chunk-NUA3WRTO.js +1157 -0
- package/dist/chunk-NV5SSKZE.js +171 -0
- package/dist/chunk-NXJ2CP2C.js +290 -0
- package/dist/chunk-O3IESEF6.js +85 -0
- package/dist/chunk-OAO2BK25.js +81 -0
- package/dist/chunk-OFY7RGLL.js +348 -0
- package/dist/chunk-OICU3UHF.js +181 -0
- package/dist/chunk-OK6HCC2Z.js +731 -0
- package/dist/chunk-ONTUBOYP.js +230 -0
- package/dist/chunk-OQB7TERT.js +54 -0
- package/dist/chunk-OXUHCIGV.js +1352 -0
- package/dist/chunk-P362EYLO.js +106 -0
- package/dist/chunk-P4T4JOCE.js +192 -0
- package/dist/chunk-PNQDP3OA.js +800 -0
- package/dist/chunk-PYTSVZWG.js +377 -0
- package/dist/chunk-Q2R3WUW4.js +448 -0
- package/dist/chunk-QAOWXQKA.js +333 -0
- package/dist/chunk-QEFT6G6J.js +2078 -0
- package/dist/chunk-QFGJERAP.js +1119 -0
- package/dist/chunk-QFVY5MHR.js +402 -0
- package/dist/chunk-QLMSROQC.js +604 -0
- package/dist/chunk-QNR4ZQDU.js +14365 -0
- package/dist/chunk-QO7M774X.js +1094 -0
- package/dist/chunk-QODXLGH2.js +70 -0
- package/dist/chunk-QQ3T45AO.js +348 -0
- package/dist/chunk-QV6HNEMH.js +230 -0
- package/dist/chunk-R5LCP56X.js +299 -0
- package/dist/chunk-RHC57KVT.js +85 -0
- package/dist/chunk-RHE7SHZJ.js +345 -0
- package/dist/chunk-RHTZA6X6.js +1922 -0
- package/dist/chunk-RJY45A5J.js +133 -0
- package/dist/chunk-RL4RQIEI.js +731 -0
- package/dist/chunk-RVOPNDGY.js +150 -0
- package/dist/chunk-RW4EMKQF.js +185 -0
- package/dist/chunk-S35K4C6F.js +127 -0
- package/dist/chunk-S3QEHFGE.js +373 -0
- package/dist/chunk-SCQEAMO3.js +299 -0
- package/dist/chunk-SFQYQH5Z.js +50 -0
- package/dist/chunk-SLFB2RY6.js +133 -0
- package/dist/chunk-SSC7EKY2.js +133 -0
- package/dist/chunk-SWFFGWAF.js +262 -0
- package/dist/chunk-SXZCFZ5T.js +157 -0
- package/dist/chunk-SYOGNG2R.js +379 -0
- package/dist/chunk-T5LT62O5.js +14365 -0
- package/dist/chunk-TDGPZF5T.js +539 -0
- package/dist/chunk-TEOJ63HX.js +362 -0
- package/dist/chunk-TF6DEHEL.js +167 -0
- package/dist/chunk-TH7ZNVGB.js +33 -0
- package/dist/chunk-TMV5LCTC.js +167 -0
- package/dist/chunk-TO5ZXGDF.js +190 -0
- package/dist/chunk-TTNYB6OH.js +33 -0
- package/dist/chunk-TUHR7Z7R.js +221 -0
- package/dist/chunk-U5RKF7MQ.js +836 -0
- package/dist/chunk-UDMFABWN.js +510 -0
- package/dist/chunk-UHKXYDBM.js +668 -0
- package/dist/chunk-UKS5CXQU.js +382 -0
- package/dist/chunk-UQBD2L52.js +128 -0
- package/dist/chunk-UTARH2WY.js +76 -0
- package/dist/chunk-UXYAQCIB.js +30 -0
- package/dist/chunk-UZHCPLB2.js +127 -0
- package/dist/chunk-V2OOLS63.js +41 -0
- package/dist/chunk-VBAY3OA7.js +604 -0
- package/dist/chunk-VK4KORCQ.js +204 -0
- package/dist/chunk-VNJKA3K5.js +171 -0
- package/dist/chunk-VP4MDSUA.js +1156 -0
- package/dist/chunk-VWA7OCXI.js +58 -0
- package/dist/chunk-VWZZF3YB.js +70 -0
- package/dist/chunk-VYPKS352.js +214 -0
- package/dist/chunk-W6JB72KR.js +448 -0
- package/dist/chunk-WG4PSSI5.js +510 -0
- package/dist/chunk-WJPZPASS.js +373 -0
- package/dist/chunk-WLDBPKRL.js +3246 -0
- package/dist/chunk-WO2SPDUE.js +231 -0
- package/dist/chunk-WXEPPHDU.js +1094 -0
- package/dist/chunk-WXNSOT6K.js +82 -0
- package/dist/chunk-X2PSVVHB.js +448 -0
- package/dist/chunk-X5Y4JSD4.js +128 -0
- package/dist/chunk-X7VPB6Z5.js +621 -0
- package/dist/chunk-XA2GMH53.js +85 -0
- package/dist/chunk-XC2ZMYDN.js +204 -0
- package/dist/chunk-XFQJH67J.js +157 -0
- package/dist/chunk-XQ5LT6UM.js +362 -0
- package/dist/chunk-XRMBKPIP.js +204 -0
- package/dist/chunk-XUC7YYW5.js +171 -0
- package/dist/chunk-XVDWHYIK.js +3276 -0
- package/dist/chunk-Y4ZA4GCQ.js +85 -0
- package/dist/chunk-Y6CVAZ7T.js +97 -0
- package/dist/chunk-YA7WVZF5.js +377 -0
- package/dist/chunk-YACAOZVG.js +185 -0
- package/dist/chunk-YEHV3FN5.js +836 -0
- package/dist/chunk-YMMYZXVZ.js +55 -0
- package/dist/chunk-YMZ6IGC3.js +284 -0
- package/dist/chunk-Z5P7AUFM.js +280 -0
- package/dist/chunk-Z5RXZRUC.js +227 -0
- package/dist/chunk-Z5YFGOLZ.js +1068 -0
- package/dist/chunk-ZLYKY6GP.js +150 -0
- package/dist/chunk-ZOP7NAM2.js +58 -0
- package/dist/chunk-ZPILUBWK.js +2142 -0
- package/dist/chunk-ZUNYZYKV.js +1157 -0
- package/dist/co-activation-54LO5GAA.js +73 -0
- package/dist/co-activation-ESPLEOMH.js +73 -0
- package/dist/co-activation-WCLF766F.js +73 -0
- package/dist/co-occurrence-52ZTRX2I.js +94 -0
- package/dist/co-occurrence-LPHW6UTZ.js +94 -0
- package/dist/co-occurrence-O4G6VQUU.js +94 -0
- package/dist/code-context-index-OX3LN34G.js +30 -0
- package/dist/code-context-index-QR5PAXM4.js +30 -0
- package/dist/conversation-wiki-populator-IMHNWKEU.js +105 -0
- package/dist/conversation-wiki-populator-IWSKIHQK.js +105 -0
- package/dist/core-memory-3LSCC75D.js +110 -0
- package/dist/core-memory-J6AEOYFN.js +110 -0
- package/dist/core-memory-XF4CLLDR.js +110 -0
- package/dist/cpu-steal-5YKTUPWF.js +23 -0
- package/dist/crdt-sync-5JOW6T2I.js +33 -0
- package/dist/crdt-sync-6L4OI4OA.js +33 -0
- package/dist/crdt-sync-UQ3PXFRB.js +33 -0
- package/dist/crm-webhook-BAXEYDPD.js +10 -0
- package/dist/crm-webhook-KVBGOUHU.js +10 -0
- package/dist/crm-webhook-VONTDB3M.js +10 -0
- package/dist/cto-delegation-gate-3WUTWBCT.js +279 -0
- package/dist/cto-delegation-gate-B7AKO7FX.js +279 -0
- package/dist/cto-delegation-gate-DZF3Z66I.js +279 -0
- package/dist/daemon-auth-55T2DI6G.js +13 -0
- package/dist/daemon-auth-M2G5PBME.js +13 -0
- package/dist/daemon-orchestration-3ANZVE7Y.js +138 -0
- package/dist/daemon-orchestration-APVUUNFB.js +138 -0
- package/dist/daemon-orchestration-ZBDBRKVR.js +138 -0
- package/dist/daemon-restart-report-F3P5AQS4.js +9 -0
- package/dist/db-backup-J7253HNV.js +33 -0
- package/dist/db-backup-LPCCZYIL.js +33 -0
- package/dist/db-backup-M733ORYE.js +33 -0
- package/dist/db-restore-events-AIL6GSEK.js +76 -0
- package/dist/db-restore-events-LB3O46HH.js +76 -0
- package/dist/db-restore-events-QF3KCGVZ.js +76 -0
- package/dist/doc-graph-extractor-CF2WBSGL.js +132 -0
- package/dist/doc-graph-extractor-IOSZSDDW.js +132 -0
- package/dist/doc-graph-extractor-RSYHLOKD.js +132 -0
- package/dist/dreaming-KA3SN53N.js +33 -0
- package/dist/dreaming-L4FLJJO2.js +33 -0
- package/dist/dreaming-YKEKUE55.js +33 -0
- package/dist/entity-boost-YFIFLE6N.js +375 -0
- package/dist/entity-boost-ZKACOJKH.js +375 -0
- package/dist/exe-drift-AVJRXHCB.js +69 -0
- package/dist/exe-drift-CLJ74KCO.js +69 -0
- package/dist/exe-drift-MYT5NQ52.js +69 -0
- package/dist/exe-export-QF5V54XC.js +75 -0
- package/dist/exe-export-T2FHC5GC.js +75 -0
- package/dist/exe-export-TBV2JI4P.js +75 -0
- package/dist/exe-import-6UAKJF3Y.js +78 -0
- package/dist/exe-import-KJQO4PJX.js +78 -0
- package/dist/exe-import-M4VYXCJZ.js +78 -0
- package/dist/exe-key-7PDQ72W2.js +580 -0
- package/dist/exe-key-KGQUC27D.js +580 -0
- package/dist/exe-key-Q772PMBM.js +580 -0
- package/dist/exe-org-KK22SSB3.js +73 -0
- package/dist/exe-org-VAUMR7TL.js +73 -0
- package/dist/exe-snapshot-KF3HPOWJ.js +337 -0
- package/dist/exe-snapshot-SK6PMOFA.js +337 -0
- package/dist/exe-snapshot-W5IVP6VF.js +337 -0
- package/dist/fast-db-init-EXNYB2HK.js +7 -0
- package/dist/fast-db-init-FMECTLNS.js +7 -0
- package/dist/fast-db-init-MZOQZ2BW.js +7 -0
- package/dist/founder-context-N2VZ5MY2.js +96 -0
- package/dist/founder-context-QGKRISJH.js +96 -0
- package/dist/gateway/index.js +13 -13
- package/dist/git-staleness-2EOHIOMZ.js +111 -0
- package/dist/git-staleness-U7ADZARV.js +111 -0
- package/dist/git-staleness-ZEYJXPFP.js +111 -0
- package/dist/git-task-sweep-I74JXGNT.js +41 -0
- package/dist/git-task-sweep-T27IFHBH.js +41 -0
- package/dist/git-task-sweep-YKLOPYYV.js +41 -0
- package/dist/global-procedures-B23F4IQ3.js +21 -0
- package/dist/global-procedures-LUBLZ6WN.js +21 -0
- package/dist/global-procedures-VJUQAYZ5.js +21 -0
- package/dist/graph-auto-extract-CSLZXRDY.js +182 -0
- package/dist/graph-auto-extract-DZRIETGW.js +182 -0
- package/dist/graph-auto-extract-ZTZ44VKT.js +182 -0
- package/dist/hook-integrity-HJBXTLQD.js +89 -0
- package/dist/hook-integrity-YPMNLP7B.js +89 -0
- package/dist/hooks/bug-report-worker.js +16 -16
- package/dist/hooks/codex-stop-task-finalizer.js +16 -16
- package/dist/hooks/commit-complete.js +17 -17
- package/dist/hooks/error-recall.js +9 -9
- package/dist/hooks/exe-heartbeat-hook.js +6 -6
- package/dist/hooks/ingest-worker.js +5 -5
- package/dist/hooks/ingest.js +13 -13
- package/dist/hooks/instructions-loaded.js +7 -7
- package/dist/hooks/manifest.json +20 -20
- package/dist/hooks/notification.js +7 -7
- package/dist/hooks/post-compact.js +16 -16
- package/dist/hooks/post-tool-combined.js +7 -7
- package/dist/hooks/pre-compact.js +21 -21
- package/dist/hooks/pre-tool-use.js +20 -20
- package/dist/hooks/prompt-submit.js +28 -28
- package/dist/hooks/session-end.js +26 -26
- package/dist/hooks/session-start.js +47 -17
- package/dist/hooks/stop.js +23 -23
- package/dist/hooks/subagent-stop.js +16 -16
- package/dist/hooks/summary-worker.js +23 -23
- package/dist/index.js +24 -24
- package/dist/installer-2MDIUMZS.js +343 -0
- package/dist/installer-AU5VMP4U.js +39 -0
- package/dist/installer-DS7H47GB.js +297 -0
- package/dist/installer-H7BIYSIK.js +39 -0
- package/dist/installer-JSUC44TR.js +39 -0
- package/dist/installer-L4NJWZGV.js +297 -0
- package/dist/installer-QE3LBMVF.js +343 -0
- package/dist/installer-QH75OOGL.js +297 -0
- package/dist/installer-XREYYGF2.js +343 -0
- package/dist/key-backup-status-IJCQT4NV.js +39 -0
- package/dist/key-backup-status-X5CBECJ3.js +39 -0
- package/dist/lib/agent-config.js +2 -2
- package/dist/lib/cloud-sync.js +7 -7
- package/dist/lib/config.js +13 -3
- package/dist/lib/consolidation.js +9 -9
- package/dist/lib/database.js +4 -4
- package/dist/lib/db-daemon-client.js +3 -3
- package/dist/lib/db.js +4 -4
- package/dist/lib/device-registry.js +1 -1
- package/dist/lib/embed-worker.js +18 -7
- package/dist/lib/embedder.js +4 -4
- package/dist/lib/employee-templates.js +6 -6
- package/dist/lib/employees.js +4 -4
- package/dist/lib/exe-daemon-client.js +3 -3
- package/dist/lib/exe-daemon.js +140 -63
- package/dist/lib/hybrid-search.js +7 -7
- package/dist/lib/identity-templates.js +1 -1
- package/dist/lib/identity.js +4 -4
- package/dist/lib/license.js +2 -2
- package/dist/lib/messaging.js +14 -14
- package/dist/lib/reminders.js +5 -5
- package/dist/lib/schedules.js +7 -7
- package/dist/lib/session-registry.js +6 -6
- package/dist/lib/skill-learning.js +8 -8
- package/dist/lib/status-brief.js +1 -1
- package/dist/lib/store.js +6 -6
- package/dist/lib/task-router.js +5 -5
- package/dist/lib/tasks.js +15 -15
- package/dist/lib/tmux-routing.js +13 -13
- package/dist/lib/token-spend.js +5 -5
- package/dist/lib/ws-client.js +5 -0
- package/dist/license-gate-R5EZ7HD3.js +14 -0
- package/dist/license-gate-X57APN2E.js +14 -0
- package/dist/mcp/register-tools.js +72 -70
- package/dist/mcp/server.js +74 -72
- package/dist/mcp/tools/complete-reminder.js +6 -6
- package/dist/mcp/tools/create-reminder.js +6 -6
- package/dist/mcp/tools/create-task.js +17 -17
- package/dist/mcp/tools/deactivate-behavior.js +9 -9
- package/dist/mcp/tools/list-reminders.js +6 -6
- package/dist/mcp/tools/list-tasks.js +17 -17
- package/dist/mcp/tools/send-message.js +16 -16
- package/dist/mcp/tools/update-task.js +16 -16
- package/dist/mcp-http-config-DV6S22TF.js +28 -0
- package/dist/mcp-http-config-KMP55RXI.js +28 -0
- package/dist/mcp-http-config-XYHPQVRA.js +28 -0
- package/dist/memory-cards-AULW7ITU.js +179 -0
- package/dist/memory-cards-AUWC6FN6.js +179 -0
- package/dist/memory-cards-NLTRIBSD.js +179 -0
- package/dist/memory-graph-extractor-7OWSK2ON.js +21 -0
- package/dist/memory-graph-extractor-NGJQIKAA.js +21 -0
- package/dist/memory-graph-extractor-QWFPKSX5.js +21 -0
- package/dist/memory-poisoning-defense-5WWOLHUQ.js +223 -0
- package/dist/memory-poisoning-defense-742X4H52.js +223 -0
- package/dist/memory-poisoning-defense-TLVXFY43.js +223 -0
- package/dist/memory-queue-4QU434ZH.js +19 -0
- package/dist/memory-queue-OXHHNDOC.js +19 -0
- package/dist/memory-queue-client-6KTL3U3I.js +16 -0
- package/dist/memory-queue-client-P4TZNVQB.js +16 -0
- package/dist/memory-reflection-6GF5OK2W.js +243 -0
- package/dist/memory-reflection-C52FI4W2.js +243 -0
- package/dist/memory-reflection-SGIE7OJ7.js +243 -0
- package/dist/message-queue-client-DFXF7LJD.js +92 -0
- package/dist/message-queue-client-ELWCWKBO.js +92 -0
- package/dist/notifications-67M5SPLO.js +46 -0
- package/dist/notifications-HUH2H5WZ.js +46 -0
- package/dist/notifications-U3NJYMXX.js +46 -0
- package/dist/oauth-server-NR3XEPA4.js +437 -0
- package/dist/oauth-server-RKCMPBIP.js +437 -0
- package/dist/orchestration-events-MC3IZ46I.js +26 -0
- package/dist/orchestration-events-NZCUTMCJ.js +26 -0
- package/dist/orchestration-events-TKODYRYP.js +26 -0
- package/dist/orchestration-phase-FPAVQ57X.js +23 -0
- package/dist/orchestration-phase-UCTFU32J.js +23 -0
- package/dist/orchestrator-3MJ6YJKT.js +34 -0
- package/dist/orchestrator-GNI5PCA6.js +34 -0
- package/dist/orchestrator-HOXFT4PP.js +34 -0
- package/dist/pipeline-router-NCUDK335.js +14 -0
- package/dist/pipeline-router-P2QAQHUY.js +14 -0
- package/dist/pipeline-router-POLBFEBM.js +14 -0
- package/dist/plan-limits-DGAFE7V6.js +27 -0
- package/dist/plan-limits-J4WXJVDS.js +27 -0
- package/dist/plan-limits-UDKZ2O7W.js +27 -0
- package/dist/project-boot-5R3GLCVN.js +299 -0
- package/dist/project-boot-FRCQHQTF.js +299 -0
- package/dist/project-boot-QHXOUJGT.js +299 -0
- package/dist/projection-worker-7EWWMJHG.js +1034 -0
- package/dist/projection-worker-QZW4DOY3.js +1034 -0
- package/dist/projection-worker-XDKC3GIZ.js +1034 -0
- package/dist/prospective-memory-7B65EHWB.js +231 -0
- package/dist/prospective-memory-JIGVZM2I.js +231 -0
- package/dist/push-notifications-ERC4SQSQ.js +15 -0
- package/dist/push-notifications-X7E7GSC7.js +15 -0
- package/dist/reranker-EUG4XM44.js +19 -0
- package/dist/reranker-SF3LMYGY.js +19 -0
- package/dist/reranker-SOM2WMD6.js +19 -0
- package/dist/retrieval-health-7FRD2KLM.js +11 -0
- package/dist/retrieval-health-P6QHP263.js +11 -0
- package/dist/retrieval-health-WLNAPJCX.js +11 -0
- package/dist/review-polling-66EJAMR3.js +125 -0
- package/dist/review-polling-SYKYNFRK.js +125 -0
- package/dist/review-polling-WHPJUENR.js +125 -0
- package/dist/runtime/index.js +20 -20
- package/dist/session-events-A6EDTM27.js +37 -0
- package/dist/session-events-DONPZ7DR.js +37 -0
- package/dist/session-events-WMK6FCKZ.js +37 -0
- package/dist/session-kill-telemetry-2BU72YXD.js +30 -0
- package/dist/session-kill-telemetry-NV2S2YZ2.js +30 -0
- package/dist/session-kill-telemetry-Y47QAFHP.js +30 -0
- package/dist/session-scope-H3FJVQ6E.js +87 -0
- package/dist/session-scope-I56DVQEY.js +87 -0
- package/dist/session-scope-RYBNHQ43.js +87 -0
- package/dist/setup-wizard-MX3S3DVH.js +12 -0
- package/dist/setup-wizard-NID5EPDN.js +12 -0
- package/dist/setup-wizard-YRBCVPCU.js +12 -0
- package/dist/shard-manager-AX4W5B3N.js +30 -0
- package/dist/shard-manager-F3YYEG5S.js +30 -0
- package/dist/skill-refinement-57DCIDKT.js +158 -0
- package/dist/skill-refinement-KRMGOT5M.js +158 -0
- package/dist/skill-refinement-XTBCHOMO.js +158 -0
- package/dist/stack-update-3LZQWW3G.js +80 -0
- package/dist/stack-update-CZ2QHS6T.js +76 -0
- package/dist/stack-update-XNEO4WQH.js +76 -0
- package/dist/steward-gate-J7VMPHEN.js +14 -0
- package/dist/steward-gate-KC4NOULU.js +14 -0
- package/dist/steward-gate-PVUKWYED.js +14 -0
- package/dist/task-enforcement-AI433TPY.js +439 -0
- package/dist/task-enforcement-G4MYUJ2E.js +439 -0
- package/dist/task-enforcement-QBF44BXN.js +439 -0
- package/dist/task-scope-D2VOYU3P.js +36 -0
- package/dist/task-scope-HGL6VACL.js +36 -0
- package/dist/task-scope-XRH4KDJB.js +36 -0
- package/dist/tasks-crud-2KYGDJG2.js +78 -0
- package/dist/tasks-crud-DFE4XOW7.js +78 -0
- package/dist/tasks-crud-J5TSLFQN.js +78 -0
- package/dist/tasks-notify-2VRKOK74.js +39 -0
- package/dist/tasks-notify-AJSRQHLZ.js +39 -0
- package/dist/tasks-notify-Q23MIKDA.js +39 -0
- package/dist/tasks-review-ISSCHGTG.js +48 -0
- package/dist/tasks-review-NRSVHN7V.js +48 -0
- package/dist/tasks-review-VV3RLPLT.js +48 -0
- package/dist/telemetry-upload-ISI6TEX4.js +740 -0
- package/dist/telemetry-upload-VZ3A6EPD.js +740 -0
- package/dist/telemetry-upload-XML6WVPW.js +740 -0
- package/dist/token-budget-KVRHMY7V.js +85 -0
- package/dist/token-budget-SIXJ7ED5.js +85 -0
- package/dist/token-budget-WV2GIFYJ.js +85 -0
- package/dist/tool-capability-index-NOMFY27N.js +10 -0
- package/dist/tool-capability-index-TK5K76RB.js +10 -0
- package/dist/tool-telemetry-6DGIQUV3.js +17 -0
- package/dist/tool-telemetry-NTFTPF3L.js +17 -0
- package/dist/tool-telemetry-NXPM2T5E.js +17 -0
- package/dist/tui/App.js +81 -39
- package/dist/tui-data-2LNENF36.js +259 -0
- package/dist/tui-data-C4474APN.js +259 -0
- package/dist/tui-data-KP66NOW3.js +259 -0
- package/dist/webhook-pipe-VQMOLXMW.js +114 -0
- package/dist/webhook-pipe-ZAEPBTDB.js +114 -0
- package/dist/wiki-acl-33D5QTU4.js +111 -0
- package/dist/wiki-acl-4A3ZUPJK.js +111 -0
- package/dist/wiki-acl-DRTEVIHT.js +111 -0
- package/dist/wiki-client-AN52BINX.js +157 -0
- package/dist/wiki-client-XZ6VZTH6.js +157 -0
- package/dist/worker-gate-EVSFKALM.js +21 -0
- package/dist/worker-gate-NCEAKLJE.js +21 -0
- package/dist/worker-gate-O2KXQN5T.js +21 -0
- package/dist/workflow-engine-MUO435MX.js +28 -0
- package/dist/workflow-engine-RV6JLGHQ.js +28 -0
- package/dist/workflow-engine-WFN3HPAZ.js +28 -0
- package/dist/worktree-36S7LYES.js +27 -0
- package/dist/worktree-O66YDTSF.js +27 -0
- package/dist/worktree-WTNPY42O.js +27 -0
- package/dist/worktree-sweep-M2ENRTY6.js +20 -0
- package/dist/worktree-sweep-M5AXCSU7.js +20 -0
- package/dist/worktree-sweep-NKEGKQT3.js +20 -0
- package/package.json +1 -1
- package/release-notes.json +58 -58
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractKeywords,
|
|
3
|
+
keywordsToString
|
|
4
|
+
} from "./chunk-CHCA3ZM2.js";
|
|
5
|
+
import {
|
|
6
|
+
blobToVector
|
|
7
|
+
} from "./chunk-OTVEIJUQ.js";
|
|
8
|
+
import {
|
|
9
|
+
findScopedDuplicate,
|
|
10
|
+
governMemoryRecord,
|
|
11
|
+
schedulePostWriteMemoryHygiene
|
|
12
|
+
} from "./chunk-BTP3LPMP.js";
|
|
13
|
+
import {
|
|
14
|
+
orgBus
|
|
15
|
+
} from "./chunk-MP2AFCGL.js";
|
|
16
|
+
import {
|
|
17
|
+
disposeTurso,
|
|
18
|
+
ensureSchema,
|
|
19
|
+
getClient,
|
|
20
|
+
initTurso
|
|
21
|
+
} from "./chunk-3X2ZT5FN.js";
|
|
22
|
+
import {
|
|
23
|
+
EMBEDDING_DIM
|
|
24
|
+
} from "./chunk-FXU7JOXK.js";
|
|
25
|
+
import {
|
|
26
|
+
getMasterKey
|
|
27
|
+
} from "./chunk-Z42MXYWW.js";
|
|
28
|
+
import {
|
|
29
|
+
loadConfig
|
|
30
|
+
} from "./chunk-5P3HOBZX.js";
|
|
31
|
+
|
|
32
|
+
// src/lib/store.ts
|
|
33
|
+
var _debugStore = process.env.EXE_DEBUG === "1";
|
|
34
|
+
function logStoreDebug(context, err) {
|
|
35
|
+
if (_debugStore) {
|
|
36
|
+
process.stderr.write(
|
|
37
|
+
`[store] ${context}: ${err instanceof Error ? err.message : String(err)}
|
|
38
|
+
`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function logStoreWarn(context, err) {
|
|
43
|
+
process.stderr.write(
|
|
44
|
+
`[store] WARN ${context}: ${err instanceof Error ? err.message : String(err)}
|
|
45
|
+
`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
var SHARD_CB_MAX_FAILURES = 3;
|
|
49
|
+
var SHARD_CB_COOLDOWN_MS = 5 * 6e4;
|
|
50
|
+
var _shardCircuits = /* @__PURE__ */ new Map();
|
|
51
|
+
function isShardCircuitOpen(project) {
|
|
52
|
+
const state = _shardCircuits.get(project);
|
|
53
|
+
if (!state || state.openedAt === null) return false;
|
|
54
|
+
if (Date.now() - state.openedAt > SHARD_CB_COOLDOWN_MS) {
|
|
55
|
+
state.openedAt = null;
|
|
56
|
+
state.failures = 0;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function recordShardFailure(project, error) {
|
|
62
|
+
const state = _shardCircuits.get(project) ?? { failures: 0, openedAt: null, lastError: "" };
|
|
63
|
+
state.failures++;
|
|
64
|
+
state.lastError = error;
|
|
65
|
+
if (state.failures >= SHARD_CB_MAX_FAILURES && state.openedAt === null) {
|
|
66
|
+
state.openedAt = Date.now();
|
|
67
|
+
process.stderr.write(
|
|
68
|
+
`[store] Shard circuit OPEN for "${project}" after ${state.failures} consecutive failures. Will retry in ${SHARD_CB_COOLDOWN_MS / 6e4}min. Last error: ${error}
|
|
69
|
+
`
|
|
70
|
+
);
|
|
71
|
+
void import("./orchestration-events-TKODYRYP.js").then(({ recordOrchestrationEventBestEffort }) => {
|
|
72
|
+
recordOrchestrationEventBestEffort({
|
|
73
|
+
eventType: "shard.circuit_open",
|
|
74
|
+
source: "store.recordShardFailure",
|
|
75
|
+
severity: "error",
|
|
76
|
+
projectName: project,
|
|
77
|
+
payload: { failures: state.failures, lastError: error.slice(0, 200) }
|
|
78
|
+
});
|
|
79
|
+
}).catch(() => {
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
_shardCircuits.set(project, state);
|
|
83
|
+
}
|
|
84
|
+
function recordShardSuccess(project) {
|
|
85
|
+
_shardCircuits.delete(project);
|
|
86
|
+
}
|
|
87
|
+
var INIT_MAX_RETRIES = 3;
|
|
88
|
+
var INIT_RETRY_DELAY_MS = 1e3;
|
|
89
|
+
function isBusyError(err) {
|
|
90
|
+
if (err instanceof Error) {
|
|
91
|
+
const msg = err.message.toLowerCase();
|
|
92
|
+
return msg.includes("sqlite_busy") || msg.includes("database is locked");
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
async function retryOnBusy(fn, label) {
|
|
97
|
+
for (let attempt = 0; attempt <= INIT_MAX_RETRIES; attempt++) {
|
|
98
|
+
try {
|
|
99
|
+
return await fn();
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (!isBusyError(err) || attempt === INIT_MAX_RETRIES) throw err;
|
|
102
|
+
process.stderr.write(
|
|
103
|
+
`[store] SQLITE_BUSY during ${label}, retry ${attempt + 1}/${INIT_MAX_RETRIES}
|
|
104
|
+
`
|
|
105
|
+
);
|
|
106
|
+
await new Promise((r) => setTimeout(r, INIT_RETRY_DELAY_MS * (attempt + 1)));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
throw new Error("unreachable");
|
|
110
|
+
}
|
|
111
|
+
var _pendingRecords = [];
|
|
112
|
+
var _batchSize = 20;
|
|
113
|
+
var _flushIntervalMs = 1e4;
|
|
114
|
+
var _flushTimer = null;
|
|
115
|
+
var _flushing = false;
|
|
116
|
+
var _nextVersion = 1;
|
|
117
|
+
async function initStore(options) {
|
|
118
|
+
if (_flushTimer !== null) {
|
|
119
|
+
clearInterval(_flushTimer);
|
|
120
|
+
_flushTimer = null;
|
|
121
|
+
}
|
|
122
|
+
_pendingRecords = [];
|
|
123
|
+
_flushing = false;
|
|
124
|
+
_batchSize = options?.batchSize ?? 20;
|
|
125
|
+
_flushIntervalMs = options?.flushIntervalMs ?? 1e4;
|
|
126
|
+
let dbPath = options?.dbPath;
|
|
127
|
+
if (!dbPath) {
|
|
128
|
+
const config = await loadConfig();
|
|
129
|
+
dbPath = config.dbPath;
|
|
130
|
+
}
|
|
131
|
+
let masterKey = options?.masterKey ?? null;
|
|
132
|
+
if (!masterKey) {
|
|
133
|
+
masterKey = await getMasterKey();
|
|
134
|
+
if (!masterKey) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
"No encryption key found. Run /exe-setup to generate one."
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const hexKey = masterKey.toString("hex");
|
|
141
|
+
await initTurso({
|
|
142
|
+
dbPath,
|
|
143
|
+
encryptionKey: hexKey
|
|
144
|
+
});
|
|
145
|
+
await retryOnBusy(() => ensureSchema(), "ensureSchema");
|
|
146
|
+
try {
|
|
147
|
+
const { initDaemonClient } = await import("./lib/database.js");
|
|
148
|
+
await initDaemonClient();
|
|
149
|
+
} catch (e) {
|
|
150
|
+
logStoreWarn("catch", e);
|
|
151
|
+
}
|
|
152
|
+
if (!options?.lightweight) {
|
|
153
|
+
try {
|
|
154
|
+
if (process.env.EXE_DISABLE_SHARDING !== "1") {
|
|
155
|
+
const { initShardManager } = await import("./shard-manager-F3YYEG5S.js");
|
|
156
|
+
initShardManager(hexKey);
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {
|
|
159
|
+
logStoreWarn("catch", e);
|
|
160
|
+
}
|
|
161
|
+
const client = getClient();
|
|
162
|
+
const vResult = await retryOnBusy(
|
|
163
|
+
() => client.execute("SELECT MAX(version) as max_v FROM memories"),
|
|
164
|
+
"version-query"
|
|
165
|
+
);
|
|
166
|
+
_nextVersion = (Number(vResult.rows[0]?.max_v) || 0) + 1;
|
|
167
|
+
try {
|
|
168
|
+
const { loadGlobalProcedures } = await import("./global-procedures-VJUQAYZ5.js");
|
|
169
|
+
await loadGlobalProcedures();
|
|
170
|
+
} catch (e) {
|
|
171
|
+
logStoreWarn("catch", e);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function classifyTier(record) {
|
|
176
|
+
if (record.tool_name === "commit_to_long_term_memory" && (record.importance ?? 0) >= 8) return 1;
|
|
177
|
+
if (["store_memory", "manual"].includes(record.tool_name ?? "") && (record.importance ?? 0) >= 5) return 2;
|
|
178
|
+
return 3;
|
|
179
|
+
}
|
|
180
|
+
function inferFilePaths(record) {
|
|
181
|
+
if (!["Read", "Write", "Edit"].includes(record.tool_name)) return null;
|
|
182
|
+
const firstLine = record.raw_text.split("\n")[0] ?? "";
|
|
183
|
+
const match = firstLine.match(/(\/[\w./-]+\.\w+)/);
|
|
184
|
+
return match ? JSON.stringify([match[1]]) : null;
|
|
185
|
+
}
|
|
186
|
+
function inferCommitHash(record) {
|
|
187
|
+
if (record.tool_name !== "Bash") return null;
|
|
188
|
+
const match = record.raw_text.match(/\b([a-f0-9]{7,40})\b/);
|
|
189
|
+
return match ? match[1] : null;
|
|
190
|
+
}
|
|
191
|
+
function inferLanguageType(record) {
|
|
192
|
+
const text = record.raw_text;
|
|
193
|
+
if (!text || text.length < 10) return null;
|
|
194
|
+
const trimmed = text.trimStart();
|
|
195
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json";
|
|
196
|
+
if (/\b(SELECT|INSERT|UPDATE|DELETE|CREATE TABLE|ALTER TABLE)\b/i.test(text)) return "sql";
|
|
197
|
+
if (/\b(function |const |import |export |class |def |async |=>)\b/.test(text)) return "code";
|
|
198
|
+
if (trimmed.startsWith("#") || trimmed.startsWith("*")) return "prose";
|
|
199
|
+
return "mixed";
|
|
200
|
+
}
|
|
201
|
+
function inferDomain(record) {
|
|
202
|
+
const proj = (record.project_name ?? "").toLowerCase();
|
|
203
|
+
if (proj.includes("marketing") || proj.includes("content")) return "marketing";
|
|
204
|
+
if (proj.includes("crm") || proj.includes("customer")) return "customer";
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
async function writeMemory(record) {
|
|
208
|
+
if (record.agent_id) record.agent_id = record.agent_id.toLowerCase();
|
|
209
|
+
if (record.vector !== null && record.vector.length !== EMBEDDING_DIM) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
`Expected ${EMBEDDING_DIM}-dim vector, got ${record.vector.length}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
const governed = governMemoryRecord(record);
|
|
215
|
+
if (governed.shouldDrop) return;
|
|
216
|
+
record = governed.record;
|
|
217
|
+
const contentHash = governed.contentHash;
|
|
218
|
+
const memoryType = record.memory_type ?? "raw";
|
|
219
|
+
if (_pendingRecords.some(
|
|
220
|
+
(r) => r.content_hash === contentHash && r.agent_id === record.agent_id && r.project_name === record.project_name && (r.memory_type ?? "raw") === memoryType
|
|
221
|
+
)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const existing = await findScopedDuplicate({
|
|
226
|
+
contentHash,
|
|
227
|
+
agentId: record.agent_id,
|
|
228
|
+
projectName: record.project_name,
|
|
229
|
+
memoryType
|
|
230
|
+
});
|
|
231
|
+
if (existing) return;
|
|
232
|
+
} catch (e) {
|
|
233
|
+
logStoreWarn("catch", e);
|
|
234
|
+
}
|
|
235
|
+
if (!record.session_scope) {
|
|
236
|
+
try {
|
|
237
|
+
const { resolveExeSession } = await import("./lib/tmux-routing.js");
|
|
238
|
+
record.session_scope = resolveExeSession() ?? null;
|
|
239
|
+
} catch {
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const dbRow = {
|
|
243
|
+
id: record.id,
|
|
244
|
+
agent_id: record.agent_id,
|
|
245
|
+
agent_role: record.agent_role,
|
|
246
|
+
session_id: record.session_id,
|
|
247
|
+
timestamp: record.timestamp,
|
|
248
|
+
tool_name: record.tool_name,
|
|
249
|
+
project_name: record.project_name,
|
|
250
|
+
has_error: record.has_error ? 1 : 0,
|
|
251
|
+
raw_text: record.raw_text,
|
|
252
|
+
vector: record.vector,
|
|
253
|
+
version: 0,
|
|
254
|
+
// Placeholder — assigned atomically at flush time
|
|
255
|
+
task_id: record.task_id ?? null,
|
|
256
|
+
importance: record.importance ?? 5,
|
|
257
|
+
status: record.status ?? "active",
|
|
258
|
+
confidence: record.confidence ?? 0.7,
|
|
259
|
+
last_accessed: record.last_accessed ?? record.timestamp,
|
|
260
|
+
workspace_id: record.workspace_id ?? null,
|
|
261
|
+
document_id: record.document_id ?? null,
|
|
262
|
+
user_id: record.user_id ?? null,
|
|
263
|
+
char_offset: record.char_offset ?? null,
|
|
264
|
+
page_number: record.page_number ?? null,
|
|
265
|
+
source_path: record.source_path ?? null,
|
|
266
|
+
source_type: record.source_type ?? null,
|
|
267
|
+
tier: record.tier ?? classifyTier(record),
|
|
268
|
+
supersedes_id: record.supersedes_id ?? null,
|
|
269
|
+
valid_from: record.valid_from ?? record.timestamp,
|
|
270
|
+
invalid_at: record.invalid_at ?? null,
|
|
271
|
+
draft: record.draft ? 1 : 0,
|
|
272
|
+
memory_type: memoryType,
|
|
273
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null,
|
|
274
|
+
content_hash: contentHash,
|
|
275
|
+
intent: record.intent ?? null,
|
|
276
|
+
outcome: record.outcome ?? null,
|
|
277
|
+
domain: record.domain ?? inferDomain(record),
|
|
278
|
+
referenced_entities: record.referenced_entities ?? null,
|
|
279
|
+
retrieval_count: record.retrieval_count ?? 0,
|
|
280
|
+
chain_position: record.chain_position ?? null,
|
|
281
|
+
review_status: record.review_status ?? null,
|
|
282
|
+
context_window_pct: record.context_window_pct ?? null,
|
|
283
|
+
file_paths: record.file_paths ?? inferFilePaths(record),
|
|
284
|
+
commit_hash: record.commit_hash ?? inferCommitHash(record),
|
|
285
|
+
duration_ms: record.duration_ms ?? null,
|
|
286
|
+
token_cost: record.token_cost ?? null,
|
|
287
|
+
audience: record.audience ?? null,
|
|
288
|
+
language_type: record.language_type ?? inferLanguageType(record),
|
|
289
|
+
parent_memory_id: record.parent_memory_id ?? null,
|
|
290
|
+
procedure_for: record.procedure_for ?? null,
|
|
291
|
+
session_scope: record.session_scope ?? null,
|
|
292
|
+
keywords: record.keywords ?? keywordsToString(extractKeywords(record.raw_text)),
|
|
293
|
+
founder_id: record.founder_id ?? null
|
|
294
|
+
};
|
|
295
|
+
try {
|
|
296
|
+
const { checkMemoryPoisoning } = await import("./memory-poisoning-defense-TLVXFY43.js");
|
|
297
|
+
const poisonResult = await checkMemoryPoisoning({
|
|
298
|
+
memoryId: dbRow.id,
|
|
299
|
+
vector: Array.isArray(dbRow.vector) ? dbRow.vector : void 0,
|
|
300
|
+
agentId: dbRow.agent_id,
|
|
301
|
+
projectName: dbRow.project_name,
|
|
302
|
+
toolName: dbRow.tool_name,
|
|
303
|
+
sessionId: dbRow.session_id,
|
|
304
|
+
importance: dbRow.importance ?? 5
|
|
305
|
+
});
|
|
306
|
+
if (poisonResult.quarantined) {
|
|
307
|
+
dbRow.quarantined = 1;
|
|
308
|
+
dbRow.quarantine_reason = poisonResult.reason ?? "flagged";
|
|
309
|
+
}
|
|
310
|
+
} catch {
|
|
311
|
+
}
|
|
312
|
+
_pendingRecords.push(dbRow);
|
|
313
|
+
orgBus.emit({
|
|
314
|
+
type: "memory_stored",
|
|
315
|
+
agentId: record.agent_id,
|
|
316
|
+
project: record.project_name,
|
|
317
|
+
timestamp: record.timestamp
|
|
318
|
+
});
|
|
319
|
+
const MAX_PENDING = 1e3;
|
|
320
|
+
if (_pendingRecords.length >= MAX_PENDING) {
|
|
321
|
+
_pendingRecords.shift();
|
|
322
|
+
process.stderr.write(`[exe-os] \u26A0 Memory buffer full (${MAX_PENDING}) \u2014 oldest record dropped. This indicates sustained high write volume.
|
|
323
|
+
`);
|
|
324
|
+
}
|
|
325
|
+
if (_flushTimer === null) {
|
|
326
|
+
_flushTimer = setInterval(() => {
|
|
327
|
+
void flushBatch();
|
|
328
|
+
}, _flushIntervalMs);
|
|
329
|
+
if (_flushTimer && typeof _flushTimer === "object" && "unref" in _flushTimer) {
|
|
330
|
+
_flushTimer.unref();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (_pendingRecords.length >= _batchSize) {
|
|
334
|
+
await flushBatch();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async function flushBatch() {
|
|
338
|
+
if (_flushing || _pendingRecords.length === 0) return 0;
|
|
339
|
+
_flushing = true;
|
|
340
|
+
try {
|
|
341
|
+
const batch = _pendingRecords.slice(0);
|
|
342
|
+
const client = getClient();
|
|
343
|
+
const interactiveTx = client.interactiveTransactions !== false;
|
|
344
|
+
if (interactiveTx) await client.execute("BEGIN IMMEDIATE");
|
|
345
|
+
const vResult = await client.execute("SELECT COALESCE(MAX(version), 0) as max_v FROM memories");
|
|
346
|
+
let baseVersion = (Number(vResult.rows[0]?.max_v) || 0) + 1;
|
|
347
|
+
for (const row of batch) {
|
|
348
|
+
row.version = baseVersion++;
|
|
349
|
+
}
|
|
350
|
+
let _extractKeywords = null;
|
|
351
|
+
let _keywordsToString = null;
|
|
352
|
+
try {
|
|
353
|
+
const mod = await import("./keyword-extractor-UJHFWVZE.js");
|
|
354
|
+
_extractKeywords = mod.extractKeywords;
|
|
355
|
+
_keywordsToString = mod.keywordsToString;
|
|
356
|
+
} catch {
|
|
357
|
+
}
|
|
358
|
+
const buildStmt = (row) => {
|
|
359
|
+
const hasVector = row.vector !== null;
|
|
360
|
+
const taskId = row.task_id ?? null;
|
|
361
|
+
const importance = row.importance ?? 5;
|
|
362
|
+
const status = row.status ?? "active";
|
|
363
|
+
const confidence = row.confidence ?? 0.7;
|
|
364
|
+
const lastAccessed = row.last_accessed ?? row.timestamp;
|
|
365
|
+
const workspaceId = row.workspace_id ?? null;
|
|
366
|
+
const documentId = row.document_id ?? null;
|
|
367
|
+
const userId = row.user_id ?? null;
|
|
368
|
+
const charOffset = row.char_offset ?? null;
|
|
369
|
+
const pageNumber = row.page_number ?? null;
|
|
370
|
+
const sourcePath = row.source_path ?? null;
|
|
371
|
+
const sourceType = row.source_type ?? null;
|
|
372
|
+
const tier = row.tier ?? 3;
|
|
373
|
+
const supersedesId = row.supersedes_id ?? null;
|
|
374
|
+
const validFrom = row.valid_from ?? row.timestamp;
|
|
375
|
+
const invalidAt = row.invalid_at ?? null;
|
|
376
|
+
const draft = row.draft ? 1 : 0;
|
|
377
|
+
const memoryType = row.memory_type ?? "raw";
|
|
378
|
+
const trajectory = row.trajectory ?? null;
|
|
379
|
+
const contentHash = row.content_hash ?? null;
|
|
380
|
+
const keywords = row.keywords ?? (_extractKeywords && _keywordsToString ? _keywordsToString(_extractKeywords(row.raw_text)) : "");
|
|
381
|
+
const intent = row.intent ?? null;
|
|
382
|
+
const outcome = row.outcome ?? null;
|
|
383
|
+
const domain = row.domain ?? null;
|
|
384
|
+
const referencedEntities = row.referenced_entities ?? null;
|
|
385
|
+
const retrievalCount = row.retrieval_count ?? 0;
|
|
386
|
+
const chainPosition = row.chain_position ?? null;
|
|
387
|
+
const reviewStatus = row.review_status ?? null;
|
|
388
|
+
const contextWindowPct = row.context_window_pct ?? null;
|
|
389
|
+
const filePaths = row.file_paths ?? null;
|
|
390
|
+
const commitHash = row.commit_hash ?? null;
|
|
391
|
+
const durationMs = row.duration_ms ?? null;
|
|
392
|
+
const tokenCost = row.token_cost ?? null;
|
|
393
|
+
const audience = row.audience ?? null;
|
|
394
|
+
const languageType = row.language_type ?? null;
|
|
395
|
+
const parentMemoryId = row.parent_memory_id ?? null;
|
|
396
|
+
const procedureFor = row.procedure_for ?? null;
|
|
397
|
+
const sessionScope = row.session_scope ?? null;
|
|
398
|
+
const founderId = row.founder_id ?? null;
|
|
399
|
+
const cols = `id, agent_id, agent_role, session_id, timestamp,
|
|
400
|
+
tool_name, project_name,
|
|
401
|
+
has_error, raw_text, vector, version, task_id, importance, status,
|
|
402
|
+
confidence, last_accessed,
|
|
403
|
+
workspace_id, document_id, user_id, char_offset, page_number,
|
|
404
|
+
source_path, source_type, tier, supersedes_id, valid_from, invalid_at, draft, memory_type, trajectory, content_hash,
|
|
405
|
+
intent, outcome, domain, referenced_entities, retrieval_count,
|
|
406
|
+
chain_position, review_status, context_window_pct, file_paths, commit_hash,
|
|
407
|
+
duration_ms, token_cost, audience, language_type, parent_memory_id, procedure_for, session_scope, keywords, founder_id`;
|
|
408
|
+
const metaArgs = [
|
|
409
|
+
intent,
|
|
410
|
+
outcome,
|
|
411
|
+
domain,
|
|
412
|
+
referencedEntities,
|
|
413
|
+
retrievalCount,
|
|
414
|
+
chainPosition,
|
|
415
|
+
reviewStatus,
|
|
416
|
+
contextWindowPct,
|
|
417
|
+
filePaths,
|
|
418
|
+
commitHash,
|
|
419
|
+
durationMs,
|
|
420
|
+
tokenCost,
|
|
421
|
+
audience,
|
|
422
|
+
languageType,
|
|
423
|
+
parentMemoryId,
|
|
424
|
+
procedureFor,
|
|
425
|
+
sessionScope,
|
|
426
|
+
keywords,
|
|
427
|
+
founderId
|
|
428
|
+
];
|
|
429
|
+
const baseArgs = [
|
|
430
|
+
row.id,
|
|
431
|
+
row.agent_id,
|
|
432
|
+
row.agent_role,
|
|
433
|
+
row.session_id,
|
|
434
|
+
row.timestamp,
|
|
435
|
+
row.tool_name,
|
|
436
|
+
row.project_name,
|
|
437
|
+
row.has_error,
|
|
438
|
+
row.raw_text
|
|
439
|
+
];
|
|
440
|
+
const sharedArgs = [
|
|
441
|
+
row.version,
|
|
442
|
+
taskId,
|
|
443
|
+
importance,
|
|
444
|
+
status,
|
|
445
|
+
confidence,
|
|
446
|
+
lastAccessed,
|
|
447
|
+
workspaceId,
|
|
448
|
+
documentId,
|
|
449
|
+
userId,
|
|
450
|
+
charOffset,
|
|
451
|
+
pageNumber,
|
|
452
|
+
sourcePath,
|
|
453
|
+
sourceType,
|
|
454
|
+
tier,
|
|
455
|
+
supersedesId,
|
|
456
|
+
validFrom,
|
|
457
|
+
invalidAt,
|
|
458
|
+
draft,
|
|
459
|
+
memoryType,
|
|
460
|
+
trajectory,
|
|
461
|
+
contentHash
|
|
462
|
+
];
|
|
463
|
+
return {
|
|
464
|
+
sql: hasVector ? `INSERT OR IGNORE INTO memories (${cols})
|
|
465
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
|
|
466
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
467
|
+
args: hasVector ? [...baseArgs, vectorToBlob(row.vector), ...sharedArgs, ...metaArgs] : [...baseArgs, ...sharedArgs, ...metaArgs]
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
const globalStmts = batch.map(buildStmt);
|
|
471
|
+
if (interactiveTx) {
|
|
472
|
+
try {
|
|
473
|
+
for (const stmt of globalStmts) {
|
|
474
|
+
await client.execute(stmt);
|
|
475
|
+
}
|
|
476
|
+
await client.execute("COMMIT");
|
|
477
|
+
} catch (txErr) {
|
|
478
|
+
try {
|
|
479
|
+
await client.execute("ROLLBACK");
|
|
480
|
+
} catch {
|
|
481
|
+
}
|
|
482
|
+
throw txErr;
|
|
483
|
+
}
|
|
484
|
+
} else {
|
|
485
|
+
await client.batch(globalStmts, "write");
|
|
486
|
+
}
|
|
487
|
+
_nextVersion = baseVersion;
|
|
488
|
+
try {
|
|
489
|
+
const { insertMemoryCardsForBatch } = await import("./memory-cards-AUWC6FN6.js");
|
|
490
|
+
await insertMemoryCardsForBatch(batch);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
logStoreWarn("catch", e);
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
const { insertOntologyForBatch } = await import("./agentic-ontology-2LJST3BE.js");
|
|
496
|
+
await insertOntologyForBatch(batch);
|
|
497
|
+
} catch (e) {
|
|
498
|
+
logStoreWarn("catch", e);
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
const { extractGraphForBatch } = await import("./memory-graph-extractor-7OWSK2ON.js");
|
|
502
|
+
await extractGraphForBatch(batch);
|
|
503
|
+
} catch (e) {
|
|
504
|
+
logStoreWarn("catch", e);
|
|
505
|
+
}
|
|
506
|
+
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
507
|
+
_pendingRecords.splice(0, batch.length);
|
|
508
|
+
try {
|
|
509
|
+
const { isShardingEnabled, getReadyShardClient } = await import("./shard-manager-F3YYEG5S.js");
|
|
510
|
+
if (process.env.EXE_DISABLE_SHARDING !== "1" && isShardingEnabled()) {
|
|
511
|
+
const byProject = /* @__PURE__ */ new Map();
|
|
512
|
+
let skippedUnknown = 0;
|
|
513
|
+
for (const row of batch) {
|
|
514
|
+
const proj = row.project_name?.trim();
|
|
515
|
+
if (!proj) {
|
|
516
|
+
skippedUnknown++;
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if (!byProject.has(proj)) byProject.set(proj, []);
|
|
520
|
+
byProject.get(proj).push(row);
|
|
521
|
+
}
|
|
522
|
+
if (skippedUnknown > 0) {
|
|
523
|
+
process.stderr.write(
|
|
524
|
+
`[store] Shard skip: ${skippedUnknown} record(s) with empty project_name (kept in main DB only)
|
|
525
|
+
`
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
for (const [project, rows] of byProject) {
|
|
529
|
+
if (isShardCircuitOpen(project)) {
|
|
530
|
+
logStoreDebug("shard-circuit", `Skipping shard write for "${project}" \u2014 circuit open`);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
try {
|
|
534
|
+
const shardClient = await getReadyShardClient(project);
|
|
535
|
+
const shardStmts = rows.map(buildStmt);
|
|
536
|
+
await shardClient.batch(shardStmts, "write");
|
|
537
|
+
recordShardSuccess(project);
|
|
538
|
+
} catch (err) {
|
|
539
|
+
const fullError = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
540
|
+
${err.stack.split("\n").slice(1, 3).join("\n")}` : ""}` : String(err);
|
|
541
|
+
recordShardFailure(project, fullError);
|
|
542
|
+
process.stderr.write(
|
|
543
|
+
`[store] Shard write failed for ${project} (${rows.length} records): ${fullError}
|
|
544
|
+
`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
} catch (e) {
|
|
550
|
+
logStoreWarn("catch", e);
|
|
551
|
+
}
|
|
552
|
+
return batch.length;
|
|
553
|
+
} finally {
|
|
554
|
+
_flushing = false;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function buildWikiScopeFilter(options, columnPrefix) {
|
|
558
|
+
const args = [];
|
|
559
|
+
let clause = "";
|
|
560
|
+
if (options?.workspaceId !== void 0) {
|
|
561
|
+
clause += ` AND ${columnPrefix}workspace_id = ?`;
|
|
562
|
+
args.push(options.workspaceId);
|
|
563
|
+
}
|
|
564
|
+
if (options?.userId === void 0) {
|
|
565
|
+
clause += ` AND ${columnPrefix}user_id IS NULL`;
|
|
566
|
+
} else if (options.userId === null) {
|
|
567
|
+
clause += ` AND ${columnPrefix}user_id IS NULL`;
|
|
568
|
+
} else {
|
|
569
|
+
clause += ` AND (${columnPrefix}user_id = ? OR ${columnPrefix}user_id IS NULL)`;
|
|
570
|
+
args.push(options.userId);
|
|
571
|
+
}
|
|
572
|
+
return { clause, args };
|
|
573
|
+
}
|
|
574
|
+
function buildRawVisibilityFilter(options, columnPrefix) {
|
|
575
|
+
if (options?.includeRaw === false) {
|
|
576
|
+
return {
|
|
577
|
+
clause: ` AND COALESCE(${columnPrefix}memory_type, 'raw') != 'raw'`,
|
|
578
|
+
args: []
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
return { clause: "", args: [] };
|
|
582
|
+
}
|
|
583
|
+
async function searchMemories(queryVector, agentId, options) {
|
|
584
|
+
let client;
|
|
585
|
+
try {
|
|
586
|
+
const { isShardingEnabled, shardExists, getReadyShardClient } = await import("./shard-manager-F3YYEG5S.js");
|
|
587
|
+
if (isShardingEnabled() && options?.projectName && shardExists(options.projectName)) {
|
|
588
|
+
client = await getReadyShardClient(options.projectName);
|
|
589
|
+
} else {
|
|
590
|
+
client = getClient();
|
|
591
|
+
}
|
|
592
|
+
} catch (e) {
|
|
593
|
+
logStoreDebug("shard routing fallback", e);
|
|
594
|
+
client = getClient();
|
|
595
|
+
}
|
|
596
|
+
const limit = options?.limit ?? 10;
|
|
597
|
+
const activeEmbeddingModel = (await loadConfig()).modelFile;
|
|
598
|
+
let hasEmbeddingModelCol = false;
|
|
599
|
+
try {
|
|
600
|
+
const info = await client.execute("PRAGMA table_info(memories)");
|
|
601
|
+
hasEmbeddingModelCol = info.rows.some((r) => r.name === "embedding_model");
|
|
602
|
+
} catch (e) {
|
|
603
|
+
logStoreDebug("embedding_model column check failed", e);
|
|
604
|
+
}
|
|
605
|
+
const statusFilter = options?.includeArchived ? "" : `
|
|
606
|
+
AND COALESCE(status, 'active') = 'active'`;
|
|
607
|
+
const draftFilter = options?.includeDrafts ? "" : `
|
|
608
|
+
AND (draft = 0 OR draft IS NULL)`;
|
|
609
|
+
let sql = `SELECT id, agent_id, agent_role, session_id, timestamp,
|
|
610
|
+
tool_name, project_name,
|
|
611
|
+
has_error, raw_text, vector, importance, status,
|
|
612
|
+
confidence, last_accessed,
|
|
613
|
+
workspace_id, document_id, user_id,
|
|
614
|
+
char_offset, page_number,
|
|
615
|
+
source_path, source_type, strength
|
|
616
|
+
FROM memories
|
|
617
|
+
WHERE (agent_id = ? OR agent_id = 'wiki')
|
|
618
|
+
AND vector IS NOT NULL${statusFilter}${draftFilter}
|
|
619
|
+
AND COALESCE(confidence, 0.7) >= 0.3`;
|
|
620
|
+
const args = [agentId];
|
|
621
|
+
if (hasEmbeddingModelCol && typeof activeEmbeddingModel === "string" && activeEmbeddingModel.length > 0) {
|
|
622
|
+
sql += `
|
|
623
|
+
AND (embedding_model = ? OR embedding_model IS NULL)`;
|
|
624
|
+
args.push(activeEmbeddingModel);
|
|
625
|
+
}
|
|
626
|
+
try {
|
|
627
|
+
const { founderScopeFilter } = await import("./founder-context-QGKRISJH.js");
|
|
628
|
+
const founderFilter = founderScopeFilter(options?.founderId);
|
|
629
|
+
sql += founderFilter.sql;
|
|
630
|
+
args.push(...founderFilter.args.filter((a) => a !== null));
|
|
631
|
+
} catch {
|
|
632
|
+
}
|
|
633
|
+
if (options?.asOf) {
|
|
634
|
+
sql += ` AND (valid_from IS NULL OR valid_from <= ?) AND (invalid_at IS NULL OR invalid_at > ?)`;
|
|
635
|
+
args.push(options.asOf, options.asOf);
|
|
636
|
+
} else {
|
|
637
|
+
sql += ` AND invalid_at IS NULL`;
|
|
638
|
+
}
|
|
639
|
+
const scope = buildWikiScopeFilter(options, "");
|
|
640
|
+
sql += scope.clause;
|
|
641
|
+
args.push(...scope.args);
|
|
642
|
+
const rawVisibility = buildRawVisibilityFilter(options, "");
|
|
643
|
+
sql += rawVisibility.clause;
|
|
644
|
+
args.push(...rawVisibility.args);
|
|
645
|
+
if (options?.projectName) {
|
|
646
|
+
sql += ` AND project_name = ?`;
|
|
647
|
+
args.push(options.projectName);
|
|
648
|
+
}
|
|
649
|
+
if (options?.sessionScope) {
|
|
650
|
+
sql += ` AND (session_scope = ? OR session_scope IS NULL)`;
|
|
651
|
+
args.push(options.sessionScope);
|
|
652
|
+
}
|
|
653
|
+
if (options?.toolName) {
|
|
654
|
+
sql += ` AND tool_name = ?`;
|
|
655
|
+
args.push(options.toolName);
|
|
656
|
+
}
|
|
657
|
+
if (options?.hasError !== void 0) {
|
|
658
|
+
sql += ` AND has_error = ?`;
|
|
659
|
+
args.push(options.hasError ? 1 : 0);
|
|
660
|
+
}
|
|
661
|
+
if (options?.since) {
|
|
662
|
+
sql += ` AND timestamp >= ?`;
|
|
663
|
+
args.push(options.since);
|
|
664
|
+
}
|
|
665
|
+
if (options?.memoryTypes && options.memoryTypes.length > 0) {
|
|
666
|
+
const uniqueTypes = [...new Set(options.memoryTypes)];
|
|
667
|
+
sql += ` AND memory_type IN (${uniqueTypes.map(() => "?").join(",")})`;
|
|
668
|
+
args.push(...uniqueTypes);
|
|
669
|
+
} else if (options?.memoryType) {
|
|
670
|
+
sql += ` AND memory_type = ?`;
|
|
671
|
+
args.push(options.memoryType);
|
|
672
|
+
}
|
|
673
|
+
sql += ` ORDER BY vector_distance_cos(vector, vector32(?))`;
|
|
674
|
+
args.push(vectorToBlob(queryVector));
|
|
675
|
+
sql += ` LIMIT ?`;
|
|
676
|
+
args.push(limit);
|
|
677
|
+
const result = await client.execute({ sql, args });
|
|
678
|
+
return result.rows.map((row) => ({
|
|
679
|
+
id: row.id,
|
|
680
|
+
agent_id: row.agent_id,
|
|
681
|
+
agent_role: row.agent_role,
|
|
682
|
+
session_id: row.session_id,
|
|
683
|
+
timestamp: row.timestamp,
|
|
684
|
+
tool_name: row.tool_name,
|
|
685
|
+
project_name: row.project_name,
|
|
686
|
+
has_error: row.has_error === 1,
|
|
687
|
+
raw_text: row.raw_text,
|
|
688
|
+
vector: row.vector == null ? [] : Array.isArray(row.vector) ? row.vector : blobToVector(row.vector),
|
|
689
|
+
importance: row.importance ?? 5,
|
|
690
|
+
status: row.status ?? "active",
|
|
691
|
+
confidence: row.confidence ?? 0.7,
|
|
692
|
+
last_accessed: row.last_accessed ?? row.timestamp,
|
|
693
|
+
workspace_id: row.workspace_id ?? null,
|
|
694
|
+
document_id: row.document_id ?? null,
|
|
695
|
+
user_id: row.user_id ?? null,
|
|
696
|
+
char_offset: row.char_offset ?? null,
|
|
697
|
+
page_number: row.page_number ?? null,
|
|
698
|
+
source_path: row.source_path ?? null,
|
|
699
|
+
source_type: row.source_type ?? null,
|
|
700
|
+
strength: row.strength ?? 1
|
|
701
|
+
}));
|
|
702
|
+
}
|
|
703
|
+
async function attachDocumentMetadata(records) {
|
|
704
|
+
const docIds = [
|
|
705
|
+
...new Set(
|
|
706
|
+
records.map((r) => r.document_id).filter((id) => typeof id === "string" && id.length > 0)
|
|
707
|
+
)
|
|
708
|
+
];
|
|
709
|
+
if (docIds.length === 0) return records;
|
|
710
|
+
try {
|
|
711
|
+
const client = getClient();
|
|
712
|
+
const placeholders = docIds.map(() => "?").join(",");
|
|
713
|
+
const result = await client.execute({
|
|
714
|
+
sql: `SELECT id, filename, mime, source_type, uploaded_at
|
|
715
|
+
FROM documents
|
|
716
|
+
WHERE id IN (${placeholders})`,
|
|
717
|
+
args: docIds
|
|
718
|
+
});
|
|
719
|
+
const byId = /* @__PURE__ */ new Map();
|
|
720
|
+
for (const row of result.rows) {
|
|
721
|
+
const id = row.id;
|
|
722
|
+
byId.set(id, {
|
|
723
|
+
document_id: id,
|
|
724
|
+
filename: row.filename,
|
|
725
|
+
mime: row.mime ?? null,
|
|
726
|
+
source_type: row.source_type ?? null,
|
|
727
|
+
uploaded_at: row.uploaded_at
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
for (const record of records) {
|
|
731
|
+
if (!record.document_id) continue;
|
|
732
|
+
record.document_metadata = byId.get(record.document_id) ?? null;
|
|
733
|
+
}
|
|
734
|
+
} catch (e) {
|
|
735
|
+
logStoreWarn("catch", e);
|
|
736
|
+
}
|
|
737
|
+
return records;
|
|
738
|
+
}
|
|
739
|
+
async function flushTier3(agentId, options) {
|
|
740
|
+
const client = getClient();
|
|
741
|
+
const maxAge = options?.maxAgeHours ?? 72;
|
|
742
|
+
const cutoff = new Date(Date.now() - maxAge * 36e5).toISOString();
|
|
743
|
+
if (options?.dryRun) {
|
|
744
|
+
const result2 = await client.execute({
|
|
745
|
+
sql: `SELECT COUNT(*) as cnt FROM memories
|
|
746
|
+
WHERE agent_id = ? AND tier = 3 AND status = 'active' AND timestamp < ?`,
|
|
747
|
+
args: [agentId, cutoff]
|
|
748
|
+
});
|
|
749
|
+
return { archived: Number(result2.rows[0]?.cnt ?? 0) };
|
|
750
|
+
}
|
|
751
|
+
const result = await client.execute({
|
|
752
|
+
sql: `UPDATE memories SET status = 'archived'
|
|
753
|
+
WHERE agent_id = ? AND tier = 3 AND status = 'active' AND timestamp < ?`,
|
|
754
|
+
args: [agentId, cutoff]
|
|
755
|
+
});
|
|
756
|
+
return { archived: result.rowsAffected };
|
|
757
|
+
}
|
|
758
|
+
async function disposeStore() {
|
|
759
|
+
if (_flushTimer !== null) {
|
|
760
|
+
clearInterval(_flushTimer);
|
|
761
|
+
_flushTimer = null;
|
|
762
|
+
}
|
|
763
|
+
if (_pendingRecords.length > 0) {
|
|
764
|
+
await flushBatch();
|
|
765
|
+
}
|
|
766
|
+
await disposeTurso();
|
|
767
|
+
_pendingRecords = [];
|
|
768
|
+
_nextVersion = 1;
|
|
769
|
+
}
|
|
770
|
+
function vectorToSqlLiteral(vector) {
|
|
771
|
+
const f32 = vector instanceof Float32Array ? vector : new Float32Array(vector);
|
|
772
|
+
return JSON.stringify(Array.from(f32));
|
|
773
|
+
}
|
|
774
|
+
var vectorToBlob = vectorToSqlLiteral;
|
|
775
|
+
async function updateMemoryStatus(id, status) {
|
|
776
|
+
const client = getClient();
|
|
777
|
+
await client.execute({
|
|
778
|
+
sql: `UPDATE memories SET status = ? WHERE id = ?`,
|
|
779
|
+
args: [status, id]
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
async function reserveVersions(count) {
|
|
783
|
+
const client = getClient();
|
|
784
|
+
await client.execute("BEGIN IMMEDIATE");
|
|
785
|
+
try {
|
|
786
|
+
const vResult = await client.execute("SELECT COALESCE(MAX(version), 0) as max_v FROM memories");
|
|
787
|
+
let baseVersion = (Number(vResult.rows[0]?.max_v) || 0) + 1;
|
|
788
|
+
if (_nextVersion > baseVersion) {
|
|
789
|
+
baseVersion = _nextVersion;
|
|
790
|
+
}
|
|
791
|
+
const reserved = [];
|
|
792
|
+
for (let i = 0; i < count; i++) {
|
|
793
|
+
reserved.push(baseVersion + i);
|
|
794
|
+
}
|
|
795
|
+
_nextVersion = baseVersion + count;
|
|
796
|
+
await client.execute("COMMIT");
|
|
797
|
+
return reserved;
|
|
798
|
+
} catch (err) {
|
|
799
|
+
try {
|
|
800
|
+
await client.execute("ROLLBACK");
|
|
801
|
+
} catch {
|
|
802
|
+
}
|
|
803
|
+
throw err;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
async function getMemoryCardinality(agentId) {
|
|
807
|
+
try {
|
|
808
|
+
const client = getClient();
|
|
809
|
+
const result = await client.execute({
|
|
810
|
+
sql: `SELECT COUNT(*) as cnt FROM memories WHERE agent_id = ? AND COALESCE(status, 'active') = 'active'`,
|
|
811
|
+
args: [agentId]
|
|
812
|
+
});
|
|
813
|
+
return Number(result.rows[0]?.cnt) || 0;
|
|
814
|
+
} catch (e) {
|
|
815
|
+
logStoreWarn("getMemoryCardinality", e);
|
|
816
|
+
return 0;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
export {
|
|
821
|
+
initStore,
|
|
822
|
+
classifyTier,
|
|
823
|
+
writeMemory,
|
|
824
|
+
flushBatch,
|
|
825
|
+
buildWikiScopeFilter,
|
|
826
|
+
buildRawVisibilityFilter,
|
|
827
|
+
searchMemories,
|
|
828
|
+
attachDocumentMetadata,
|
|
829
|
+
flushTier3,
|
|
830
|
+
disposeStore,
|
|
831
|
+
vectorToSqlLiteral,
|
|
832
|
+
vectorToBlob,
|
|
833
|
+
updateMemoryStatus,
|
|
834
|
+
reserveVersions,
|
|
835
|
+
getMemoryCardinality
|
|
836
|
+
};
|