@askexenow/exe-os 0.9.299 → 0.9.300
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 +1 -1
- package/deploy/compose/.env.example +1 -1
- package/deploy/compose/docker-compose.yml +31 -5
- package/deploy/compose/generate-env.ts +1 -1
- package/deploy/compose/observability/otel-collector-config.yaml +10 -1
- package/deploy/compose/setup.sh +1 -1
- package/dist/active-agent-56J56WW5.js +27 -0
- package/dist/active-agent-VDWK7TES.js +28 -0
- package/dist/agentic-ontology-MZ4WHFDE.js +25 -0
- package/dist/assets/com.askexe.exed.plist +6 -5
- package/dist/backfill-metadata-IHKI5GXV.js +600 -0
- package/dist/backfill-metadata-ZU3SZNBD.js +600 -0
- package/dist/behaviors-G4KWGS24.js +46 -0
- package/dist/behaviors-WO67R6C4.js +46 -0
- package/dist/bin/agentic-ontology-backfill.js +5 -5
- package/dist/bin/agentic-reflection-backfill.js +6 -6
- package/dist/bin/agentic-semantic-label.js +5 -5
- package/dist/bin/backfill-conversations.js +6 -6
- package/dist/bin/backfill-responses.js +6 -6
- package/dist/bin/backfill-vectors.js +8 -8
- package/dist/bin/bulk-sync-postgres.js +13 -7
- package/dist/bin/cc-doctor.js +5 -5
- package/dist/bin/cleanup-stale-review-tasks.js +10 -10
- package/dist/bin/cli.js +16 -16
- package/dist/bin/deferred-daemon-restart.js +1 -1
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +10 -10
- package/dist/bin/exe-assign.js +8 -8
- package/dist/bin/exe-boot.js +30 -20
- package/dist/bin/exe-call.js +4 -4
- package/dist/bin/exe-cloud.js +13 -7
- package/dist/bin/exe-dispatch.js +10 -10
- package/dist/bin/exe-doctor.js +2 -2
- package/dist/bin/exe-export-behaviors.js +7 -7
- package/dist/bin/exe-forget.js +6 -6
- package/dist/bin/exe-gateway.js +7 -7
- package/dist/bin/exe-healthcheck.js +5 -5
- package/dist/bin/exe-heartbeat.js +10 -10
- package/dist/bin/exe-kill.js +13 -13
- package/dist/bin/exe-launch-agent.js +29 -19
- package/dist/bin/exe-new-employee.js +6 -6
- package/dist/bin/exe-pending-messages.js +11 -11
- package/dist/bin/exe-pending-notifications.js +10 -10
- package/dist/bin/exe-pending-reviews.js +10 -10
- package/dist/bin/exe-rename.js +4 -4
- package/dist/bin/exe-review.js +12 -12
- package/dist/bin/exe-search.js +5 -5
- package/dist/bin/exe-session-cleanup.js +15 -15
- package/dist/bin/exe-settings.js +13 -7
- package/dist/bin/exe-start-codex.js +11 -11
- package/dist/bin/exe-start-opencode.js +8 -8
- package/dist/bin/exe-status.js +11 -11
- package/dist/bin/exe-team.js +3 -3
- package/dist/bin/git-sweep.js +11 -11
- package/dist/bin/graph-backfill.js +6 -6
- package/dist/bin/graph-export.js +5 -5
- package/dist/bin/import-history.js +9 -9
- package/dist/bin/install-launchd.js +7 -3
- package/dist/bin/install.js +19 -15
- package/dist/bin/intercom-check.js +4 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +4 -4
- package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
- package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
- package/dist/bin/pre-publish.js +24 -1
- package/dist/bin/scan-tasks.js +10 -10
- package/dist/bin/setup.js +1 -1
- package/dist/bin/shard-migrate.js +4 -4
- package/dist/bin/stack-update.js +123 -3
- package/dist/bin/vps-health-gate.js +1 -1
- package/dist/capability-cards-XAQSL26B.js +89 -0
- package/dist/capacity-monitor-6MQLFFQT.js +51 -0
- package/dist/capacity-monitor-BB3LKJLE.js +51 -0
- package/dist/catchup-brief-BQSL5M5S.js +175 -0
- package/dist/catchup-brief-COALBX6L.js +175 -0
- package/dist/cc-binary-detect-B5JDCJ5J.js +19 -0
- package/dist/chunk-22LDUTY7.js +14597 -0
- package/dist/chunk-24M4AJPG.js +128 -0
- package/dist/chunk-2B7RCTPT.js +85 -0
- package/dist/chunk-2QBA6YE6.js +127 -0
- package/dist/chunk-2RGDEBZC.js +731 -0
- package/dist/chunk-32DBQWR5.js +333 -0
- package/dist/chunk-3EOPMTG2.js +128 -0
- package/dist/chunk-3NS4V4JW.js +382 -0
- package/dist/chunk-3NYY2NZ3.js +836 -0
- package/dist/chunk-3ROUD5WA.js +97 -0
- package/dist/chunk-3RY2ARDN.js +129 -0
- package/dist/chunk-3Y5IRIRU.js +290 -0
- package/dist/chunk-3ZWWUKBI.js +210 -0
- package/dist/chunk-463G3VAH.js +122 -0
- package/dist/chunk-4LC7BFI2.js +76 -0
- package/dist/chunk-4Z3FWLOE.js +836 -0
- package/dist/chunk-5BAU4T5G.js +208 -0
- package/dist/chunk-5FP7YHCG.js +1158 -0
- package/dist/chunk-5U3JZP62.js +1352 -0
- package/dist/chunk-5VNFXIGF.js +85 -0
- package/dist/chunk-6UVUJNLY.js +1186 -0
- package/dist/chunk-7KPWYWYL.js +290 -0
- package/dist/chunk-7URNGDEY.js +2145 -0
- package/dist/chunk-ADZQBZOX.js +122 -0
- package/dist/chunk-APSZAEDO.js +1186 -0
- package/dist/chunk-ASHF6VO4.js +2265 -0
- package/dist/chunk-BT2LEHIW.js +448 -0
- package/dist/chunk-BTS5QUWB.js +50 -0
- package/dist/chunk-BWJDJ3BS.js +604 -0
- package/dist/chunk-CME46VWP.js +150 -0
- package/dist/chunk-D3ICCKXY.js +54 -0
- package/dist/chunk-D3IOU3NO.js +377 -0
- package/dist/chunk-DFGXRKI2.js +221 -0
- package/dist/chunk-DO65VHQZ.js +128 -0
- package/dist/chunk-E2OMUBXQ.js +567 -0
- package/dist/chunk-ECMXIV6N.js +97 -0
- package/dist/chunk-EDMVA3PT.js +727 -0
- package/dist/chunk-F5OSXH4A.js +4388 -0
- package/dist/chunk-F5OWHPRG.js +236 -0
- package/dist/chunk-F7MZA3QP.js +199 -0
- package/dist/chunk-FRNXQSB4.js +134 -0
- package/dist/chunk-FTAASABV.js +362 -0
- package/dist/chunk-GBL5QSTM.js +197 -0
- package/dist/chunk-GRXWINOW.js +244 -0
- package/dist/chunk-GUPNVUG5.js +348 -0
- package/dist/chunk-GY66UPMX.js +167 -0
- package/dist/chunk-HCCG67BY.js +43 -0
- package/dist/chunk-HCSZZXZZ.js +197 -0
- package/dist/chunk-HNGNZU62.js +240 -0
- package/dist/chunk-HP2D5LIE.js +214 -0
- package/dist/chunk-HUABQHDC.js +1352 -0
- package/dist/chunk-HYKO2LNW.js +157 -0
- package/dist/chunk-IFL6DG2K.js +181 -0
- package/dist/chunk-IKPQRHVQ.js +304 -0
- package/dist/chunk-JCWA3X6A.js +402 -0
- package/dist/chunk-JHPK33IP.js +2162 -0
- package/dist/chunk-JWGDH5I2.js +127 -0
- package/dist/chunk-KBXQFXYM.js +567 -0
- package/dist/chunk-KGY5QIOJ.js +1350 -0
- package/dist/chunk-KLES22FB.js +1094 -0
- package/dist/chunk-KY43UELJ.js +331 -0
- package/dist/chunk-L32V4O5Z.js +58 -0
- package/dist/chunk-LC7ETNTJ.js +1350 -0
- package/dist/chunk-LEJ5FKIK.js +55 -0
- package/dist/chunk-LNLLCAI4.js +377 -0
- package/dist/chunk-LQWZYMNU.js +448 -0
- package/dist/chunk-LY3SOO73.js +76 -0
- package/dist/chunk-M6CIHXXB.js +159 -0
- package/dist/chunk-MJOQ35DX.js +427 -0
- package/dist/chunk-MO5HER5Y.js +345 -0
- package/dist/chunk-MY4TGLT6.js +284 -0
- package/dist/chunk-N3ARGCVG.js +345 -0
- package/dist/chunk-N4XG2M2U.js +735 -0
- package/dist/chunk-N72JNFJ4.js +535 -0
- package/dist/chunk-NM3AUMFE.js +2145 -0
- package/dist/chunk-NPPQ3TR4.js +735 -0
- package/dist/chunk-NTWF4DAF.js +581 -0
- package/dist/chunk-NXL3VKXM.js +331 -0
- package/dist/chunk-OMSLHEEF.js +456 -0
- package/dist/chunk-OYIP3QVN.js +167 -0
- package/dist/chunk-P2IOW54H.js +668 -0
- package/dist/chunk-P5KXQ3RN.js +731 -0
- package/dist/chunk-P5UXP53T.js +81 -0
- package/dist/chunk-PH6VRRFR.js +395 -0
- package/dist/chunk-Q3GKOF7Z.js +85 -0
- package/dist/chunk-QKBN3CY2.js +381 -0
- package/dist/chunk-QNNAVMQH.js +1094 -0
- package/dist/chunk-QODDW4YI.js +171 -0
- package/dist/chunk-QPAYPTSH.js +2162 -0
- package/dist/chunk-QRWDJ5RI.js +381 -0
- package/dist/chunk-RBFZCHVB.js +105 -0
- package/dist/chunk-RCEULTPF.js +185 -0
- package/dist/chunk-RCGHXBCX.js +630 -0
- package/dist/chunk-ROSCLRTH.js +204 -0
- package/dist/chunk-RYAOSGUW.js +227 -0
- package/dist/chunk-S2SPGHPY.js +38 -0
- package/dist/chunk-SBPEWD7Z.js +171 -0
- package/dist/chunk-SDPUWZP5.js +333 -0
- package/dist/chunk-SVLSHDNL.js +54 -0
- package/dist/chunk-SVUYBT5N.js +262 -0
- package/dist/chunk-T7PTLVJV.js +284 -0
- package/dist/chunk-TGUSLO4B.js +50 -0
- package/dist/chunk-TPJH6PE6.js +1158 -0
- package/dist/chunk-TVW7EDOJ.js +382 -0
- package/dist/chunk-TYRUIE6P.js +58 -0
- package/dist/chunk-UN5EPVBN.js +14597 -0
- package/dist/chunk-URLH7ZVR.js +70 -0
- package/dist/chunk-USYRTGR7.js +402 -0
- package/dist/chunk-V4ABCEHM.js +30 -0
- package/dist/chunk-VKCNXOQ6.js +214 -0
- package/dist/chunk-WB2B25UM.js +230 -0
- package/dist/chunk-WCUZX7F7.js +204 -0
- package/dist/chunk-WL5RMOZQ.js +362 -0
- package/dist/chunk-WPAXAOHD.js +1079 -0
- package/dist/chunk-XABJRAUW.js +3346 -0
- package/dist/chunk-YDFY6YCH.js +280 -0
- package/dist/chunk-YGUMRYCN.js +33 -0
- package/dist/chunk-YJSP5PPG.js +128 -0
- package/dist/chunk-YOMETWOJ.js +4388 -0
- package/dist/chunk-Z4FVFSE3.js +81 -0
- package/dist/chunk-Z4TLSNUW.js +244 -0
- package/dist/chunk-ZP6T5K6I.js +535 -0
- package/dist/chunk-ZR6ZJT32.js +123 -0
- package/dist/co-activation-JGF5YIDU.js +74 -0
- package/dist/co-occurrence-HLLC6GT2.js +95 -0
- package/dist/co-occurrence-W2LIAPHI.js +95 -0
- package/dist/code-context-index-FCL47WKE.js +30 -0
- package/dist/conversation-entity-extractor-WC2RU6RS.js +114 -0
- package/dist/core-memory-CRSR2PSL.js +110 -0
- package/dist/core-memory-VSKFRMEV.js +110 -0
- package/dist/crdt-sync-6VH2YDVY.js +33 -0
- package/dist/crm-webhook-RXFPZJXP.js +10 -0
- package/dist/crm-webhook-Z26LEFKG.js +10 -0
- package/dist/cto-delegation-gate-45IBLPTK.js +280 -0
- package/dist/cto-delegation-gate-SF4EUB2Q.js +280 -0
- package/dist/daemon-orchestration-VB3BLYIT.js +143 -0
- package/dist/daemon-orchestration-W66UYGUD.js +143 -0
- package/dist/db-backup-NVUTS7L5.js +43 -0
- package/dist/doc-graph-extractor-MLYQYT4B.js +133 -0
- package/dist/doc-graph-extractor-SVFSXKL6.js +133 -0
- package/dist/dreaming-AZYRAGKA.js +34 -0
- package/dist/dreaming-WG5CDUHX.js +34 -0
- package/dist/entity-boost-XAFCDDB6.js +375 -0
- package/dist/exe-drift-3SGA53CL.js +70 -0
- package/dist/exe-export-APUNLKWF.js +77 -0
- package/dist/exe-export-NM4SXB3P.js +77 -0
- package/dist/exe-import-6GLNCP62.js +80 -0
- package/dist/exe-import-U4H4ES3Z.js +80 -0
- package/dist/exe-key-FIPXUTMF.js +673 -0
- package/dist/exe-key-WTLCMOYJ.js +673 -0
- package/dist/exe-snapshot-ILO3WSEC.js +338 -0
- package/dist/exe-snapshot-IODRQLBX.js +338 -0
- package/dist/fast-db-init-7LYYUCSJ.js +7 -0
- package/dist/fast-db-init-IU7GYFWB.js +7 -0
- package/dist/gateway/index.js +11 -11
- package/dist/git-staleness-GGCFPHQ5.js +112 -0
- package/dist/git-task-sweep-M3SWXFKJ.js +42 -0
- package/dist/git-task-sweep-Y6KNWB67.js +42 -0
- package/dist/global-procedures-626WAU3I.js +22 -0
- package/dist/graph-auto-extract-TKHQ4OR3.js +183 -0
- package/dist/graph-auto-extract-VGFEWFZX.js +183 -0
- package/dist/graph-rag-KECA5TE4.js +35 -0
- package/dist/hooks/bug-report-worker.js +12 -12
- package/dist/hooks/codex-stop-task-finalizer.js +12 -12
- package/dist/hooks/commit-complete.js +12 -12
- package/dist/hooks/error-recall.js +6 -6
- package/dist/hooks/exe-heartbeat-hook.js +3 -3
- package/dist/hooks/ingest-worker.js +3 -3
- package/dist/hooks/ingest.js +6 -6
- package/dist/hooks/instructions-loaded.js +4 -4
- package/dist/hooks/manifest.json +20 -20
- package/dist/hooks/notification.js +4 -4
- package/dist/hooks/post-compact.js +11 -11
- package/dist/hooks/post-tool-combined.js +6 -6
- package/dist/hooks/pre-compact.js +15 -15
- package/dist/hooks/pre-tool-use.js +15 -15
- package/dist/hooks/prompt-submit.js +23 -23
- package/dist/hooks/session-end.js +20 -20
- package/dist/hooks/session-start.js +12 -12
- package/dist/hooks/stop.js +18 -18
- package/dist/hooks/subagent-stop.js +11 -11
- package/dist/hooks/summary-worker.js +18 -18
- package/dist/index.js +20 -20
- package/dist/installer-3FB5EMPB.js +40 -0
- package/dist/installer-BRQ42CPB.js +344 -0
- package/dist/installer-PXZJG256.js +298 -0
- package/dist/lib/cloud-sync.js +13 -7
- package/dist/lib/consolidation.js +7 -7
- package/dist/lib/database.js +6 -4
- package/dist/lib/db-daemon-client.js +11 -202
- package/dist/lib/db.js +6 -4
- package/dist/lib/embedder.js +3 -3
- package/dist/lib/employee-templates.js +4 -4
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon-client.js +2 -2
- package/dist/lib/exe-daemon.js +53 -51
- package/dist/lib/hybrid-search.js +5 -5
- package/dist/lib/identity.js +2 -2
- package/dist/lib/messaging.js +10 -10
- package/dist/lib/reminders.js +3 -3
- package/dist/lib/schedules.js +5 -5
- package/dist/lib/session-registry.js +4 -4
- package/dist/lib/skill-learning.js +6 -6
- package/dist/lib/store.js +4 -4
- package/dist/lib/task-router.js +3 -3
- package/dist/lib/tasks.js +11 -11
- package/dist/lib/tmux-routing.js +9 -9
- package/dist/lib/token-spend.js +3 -3
- package/dist/mcp/register-tools.js +65 -63
- package/dist/mcp/server.js +66 -64
- package/dist/mcp/tools/complete-reminder.js +4 -4
- package/dist/mcp/tools/create-reminder.js +4 -4
- package/dist/mcp/tools/create-task.js +13 -13
- package/dist/mcp/tools/deactivate-behavior.js +7 -7
- package/dist/mcp/tools/list-reminders.js +4 -4
- package/dist/mcp/tools/list-tasks.js +13 -13
- package/dist/mcp/tools/send-message.js +12 -12
- package/dist/mcp/tools/update-task.js +12 -12
- package/dist/mcp-http-config-OF3MB7M5.js +31 -0
- package/dist/memory-cards-CPIZVXWI.js +180 -0
- package/dist/memory-graph-extractor-JIYWLBFF.js +22 -0
- package/dist/memory-graph-extractor-MDPSLZDM.js +22 -0
- package/dist/memory-poisoning-defense-5UZT3WWA.js +224 -0
- package/dist/memory-queue-client-WKWRFERJ.js +16 -0
- package/dist/memory-reflection-TA2VQYPH.js +244 -0
- package/dist/message-queue-client-IFQQ2HI7.js +92 -0
- package/dist/notifications-CZBQ3H5T.js +47 -0
- package/dist/notifications-EIIL2EQV.js +47 -0
- package/dist/orchestration-events-VUYR6MXE.js +27 -0
- package/dist/orchestrator-MAMR4C37.js +35 -0
- package/dist/orchestrator-VE5WHEJH.js +35 -0
- package/dist/pipeline-router-DKXD6DJO.js +15 -0
- package/dist/pipeline-router-YNW63BY5.js +15 -0
- package/dist/plan-limits-ZM4MNZKY.js +28 -0
- package/dist/project-boot-E2TWYTAC.js +299 -0
- package/dist/projection-worker-WFPRM4AI.js +1084 -0
- package/dist/projection-worker-YKV3PFCV.js +1084 -0
- package/dist/prospective-memory-OAFZUODU.js +232 -0
- package/dist/reranker-AFU75HEX.js +19 -0
- package/dist/reranker-RYNSJNDF.js +19 -0
- package/dist/retrieval-health-RSQEIYIB.js +12 -0
- package/dist/review-polling-LGX7DUNT.js +126 -0
- package/dist/review-polling-MJBCYV4I.js +126 -0
- package/dist/runtime/index.js +16 -16
- package/dist/services/codex-reviewd/index.js +855 -0
- package/dist/session-events-5N47BRFK.js +38 -0
- package/dist/session-events-PT6SVS2P.js +38 -0
- package/dist/session-kill-telemetry-HKL2NQMR.js +31 -0
- package/dist/session-scope-GQNCM6UQ.js +88 -0
- package/dist/session-scope-MMGM232A.js +88 -0
- package/dist/setup-wizard-SELXXVLD.js +12 -0
- package/dist/setup-wizard-X7YSRDNQ.js +12 -0
- package/dist/skill-refinement-CCP4ULZ3.js +159 -0
- package/dist/skill-refinement-WCPDNHZ5.js +159 -0
- package/dist/stack-update-5VSGG36W.js +84 -0
- package/dist/steward-gate-PIXNK4BK.js +15 -0
- package/dist/task-enforcement-LEBWCYZT.js +506 -0
- package/dist/task-enforcement-VOSQRAQB.js +506 -0
- package/dist/task-scope-CQZ33PRU.js +37 -0
- package/dist/task-scope-JTTEZKDU.js +37 -0
- package/dist/tasks-crud-DC4GCXQQ.js +79 -0
- package/dist/tasks-crud-T32IRPXF.js +79 -0
- package/dist/tasks-notify-OBFVHJDP.js +40 -0
- package/dist/tasks-notify-OUQWUM6W.js +40 -0
- package/dist/tasks-review-N33MTHWJ.js +49 -0
- package/dist/tasks-review-OSBG2YN2.js +49 -0
- package/dist/telemetry-upload-EYHEWTKG.js +741 -0
- package/dist/telemetry-upload-XLBW4DRP.js +741 -0
- package/dist/token-budget-I6FMMDFX.js +86 -0
- package/dist/tool-capability-index-IWQBQKM7.js +10 -0
- package/dist/tool-telemetry-2E3Z7CRV.js +17 -0
- package/dist/tui/App.js +17 -17
- package/dist/tui-data-VWT4Q5UT.js +260 -0
- package/dist/tui-data-XFBFBSBE.js +260 -0
- package/dist/wiki-acl-EUOPNUIQ.js +111 -0
- package/dist/worker-gate-OQMKAMP7.js +21 -0
- package/dist/worker-gate-ZPP3SZK6.js +21 -0
- package/dist/workflow-engine-P7WYJP2B.js +28 -0
- package/dist/workflow-engine-UYNB5RTB.js +28 -0
- package/dist/worktree-H5C4LMQR.js +28 -0
- package/dist/worktree-sweep-KFWF3XZD.js +21 -0
- package/package.json +1 -1
- package/release-notes.json +30 -104
- package/src/commands/exe.md +18 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getClient
|
|
3
|
+
} from "./chunk-XABJRAUW.js";
|
|
4
|
+
import "./chunk-2I23RPSI.js";
|
|
5
|
+
import "./chunk-PH6VRRFR.js";
|
|
6
|
+
import "./chunk-PNQDP3OA.js";
|
|
7
|
+
import "./chunk-7HLWBYH7.js";
|
|
8
|
+
import "./chunk-FXU7JOXK.js";
|
|
9
|
+
import "./chunk-R36FAN53.js";
|
|
10
|
+
import "./chunk-LYH5HE24.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
12
|
+
|
|
13
|
+
// src/lib/co-activation.ts
|
|
14
|
+
async function recordCoActivations(entityIds) {
|
|
15
|
+
if (entityIds.length < 2) return;
|
|
16
|
+
const unique = [...new Set(entityIds)].slice(0, 20);
|
|
17
|
+
const client = getClient();
|
|
18
|
+
const pairs = [];
|
|
19
|
+
for (let i = 0; i < unique.length; i++) {
|
|
20
|
+
for (let j = i + 1; j < unique.length; j++) {
|
|
21
|
+
const idI = unique[i];
|
|
22
|
+
const idJ = unique[j];
|
|
23
|
+
const pair = idI < idJ ? [idI, idJ] : [idJ, idI];
|
|
24
|
+
pairs.push(pair);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const [a, b] of pairs) {
|
|
28
|
+
await client.execute({
|
|
29
|
+
sql: `INSERT INTO co_activations (entity_a_id, entity_b_id, count, last_activated_at)
|
|
30
|
+
VALUES (?, ?, 1, datetime('now'))
|
|
31
|
+
ON CONFLICT (entity_a_id, entity_b_id)
|
|
32
|
+
DO UPDATE SET count = count + 1, last_activated_at = datetime('now')`,
|
|
33
|
+
args: [a, b]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function getHotPairs(limit = 20) {
|
|
38
|
+
const client = getClient();
|
|
39
|
+
const result = await client.execute({
|
|
40
|
+
sql: `SELECT entity_a_id, entity_b_id, count, last_activated_at
|
|
41
|
+
FROM co_activations
|
|
42
|
+
ORDER BY count DESC
|
|
43
|
+
LIMIT ?`,
|
|
44
|
+
args: [limit]
|
|
45
|
+
});
|
|
46
|
+
return result.rows.map((r) => ({
|
|
47
|
+
entity_a_id: String(r.entity_a_id),
|
|
48
|
+
entity_b_id: String(r.entity_b_id),
|
|
49
|
+
count: Number(r.count),
|
|
50
|
+
last_activated_at: String(r.last_activated_at)
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
async function getCoActivationNeighbors(entityId, limit = 20) {
|
|
54
|
+
const client = getClient();
|
|
55
|
+
const result = await client.execute({
|
|
56
|
+
sql: `SELECT entity_a_id, entity_b_id, count, last_activated_at
|
|
57
|
+
FROM co_activations
|
|
58
|
+
WHERE entity_a_id = ? OR entity_b_id = ?
|
|
59
|
+
ORDER BY count DESC
|
|
60
|
+
LIMIT ?`,
|
|
61
|
+
args: [entityId, entityId, limit]
|
|
62
|
+
});
|
|
63
|
+
return result.rows.map((r) => ({
|
|
64
|
+
entity_a_id: String(r.entity_a_id),
|
|
65
|
+
entity_b_id: String(r.entity_b_id),
|
|
66
|
+
count: Number(r.count),
|
|
67
|
+
last_activated_at: String(r.last_activated_at)
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
getCoActivationNeighbors,
|
|
72
|
+
getHotPairs,
|
|
73
|
+
recordCoActivations
|
|
74
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
entityId,
|
|
3
|
+
normalizeEntityName
|
|
4
|
+
} from "./chunk-6OAAN25C.js";
|
|
5
|
+
import "./chunk-GUMRIUI5.js";
|
|
6
|
+
import "./chunk-I7AW4237.js";
|
|
7
|
+
import {
|
|
8
|
+
getClient
|
|
9
|
+
} from "./chunk-XABJRAUW.js";
|
|
10
|
+
import "./chunk-2I23RPSI.js";
|
|
11
|
+
import "./chunk-PH6VRRFR.js";
|
|
12
|
+
import "./chunk-PNQDP3OA.js";
|
|
13
|
+
import "./chunk-7HLWBYH7.js";
|
|
14
|
+
import "./chunk-FXU7JOXK.js";
|
|
15
|
+
import "./chunk-R36FAN53.js";
|
|
16
|
+
import "./chunk-LYH5HE24.js";
|
|
17
|
+
import "./chunk-MLKGABMK.js";
|
|
18
|
+
|
|
19
|
+
// src/lib/co-occurrence.ts
|
|
20
|
+
var SPECIFICITY = {
|
|
21
|
+
file: 5,
|
|
22
|
+
function: 4,
|
|
23
|
+
error: 3,
|
|
24
|
+
tool: 2,
|
|
25
|
+
agent: 1,
|
|
26
|
+
project: 0
|
|
27
|
+
};
|
|
28
|
+
function getSpecificity(type) {
|
|
29
|
+
return SPECIFICITY[type] ?? 1;
|
|
30
|
+
}
|
|
31
|
+
function coOccurrenceId(entityId1, entityId2) {
|
|
32
|
+
const sorted = [entityId1, entityId2].sort();
|
|
33
|
+
return `cooccur:${sorted[0]}:${sorted[1]}`;
|
|
34
|
+
}
|
|
35
|
+
async function actualEntityId(name, type, fallbackId) {
|
|
36
|
+
try {
|
|
37
|
+
const result = await getClient().execute({
|
|
38
|
+
sql: "SELECT id FROM entities WHERE LOWER(name) = LOWER(?) AND type = ? LIMIT 1",
|
|
39
|
+
args: [name, type]
|
|
40
|
+
});
|
|
41
|
+
return result.rows[0]?.id ? String(result.rows[0].id) : fallbackId;
|
|
42
|
+
} catch {
|
|
43
|
+
return fallbackId;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function createCoOccurrenceEdges(entities, _memoryId) {
|
|
47
|
+
if (entities.length < 2) return 0;
|
|
48
|
+
const client = getClient();
|
|
49
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
50
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51
|
+
const deduped = entities.filter((e) => {
|
|
52
|
+
const key = `${e.type.toLowerCase()}:${normalizeEntityName(e.name)}`;
|
|
53
|
+
if (seen.has(key)) return false;
|
|
54
|
+
seen.add(key);
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
const sorted = deduped.sort((a, b) => getSpecificity(b.type) - getSpecificity(a.type));
|
|
58
|
+
const MAX_PAIRS = 10;
|
|
59
|
+
const pairs = [];
|
|
60
|
+
for (let i = 0; i < sorted.length && pairs.length < MAX_PAIRS; i++) {
|
|
61
|
+
for (let j = i + 1; j < sorted.length && pairs.length < MAX_PAIRS; j++) {
|
|
62
|
+
pairs.push([sorted[i], sorted[j]]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let created = 0;
|
|
66
|
+
for (const [a, b] of pairs) {
|
|
67
|
+
const aName = normalizeEntityName(a.name);
|
|
68
|
+
const bName = normalizeEntityName(b.name);
|
|
69
|
+
const aType = a.type.toLowerCase();
|
|
70
|
+
const bType = b.type.toLowerCase();
|
|
71
|
+
const aId = await actualEntityId(aName, aType, entityId(aName, aType));
|
|
72
|
+
const bId = await actualEntityId(bName, bType, entityId(bName, bType));
|
|
73
|
+
if (aId === bId) continue;
|
|
74
|
+
const relId = coOccurrenceId(aId, bId);
|
|
75
|
+
const sortedIds = [aId, bId].sort();
|
|
76
|
+
const sourceId = sortedIds[0];
|
|
77
|
+
const targetId = sortedIds[1];
|
|
78
|
+
try {
|
|
79
|
+
await client.execute({
|
|
80
|
+
sql: `INSERT INTO relationships (id, source_entity_id, target_entity_id, type, weight, timestamp, properties)
|
|
81
|
+
VALUES (?, ?, ?, 'co_occurs_with', 1.0, ?, '{}')
|
|
82
|
+
ON CONFLICT(source_entity_id, target_entity_id, type) DO UPDATE SET
|
|
83
|
+
weight = MIN(weight + 0.1, 10.0),
|
|
84
|
+
timestamp = ?`,
|
|
85
|
+
args: [relId, sourceId, targetId, now, now]
|
|
86
|
+
});
|
|
87
|
+
created++;
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return created;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
createCoOccurrenceEdges
|
|
95
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
entityId,
|
|
3
|
+
normalizeEntityName
|
|
4
|
+
} from "./chunk-EDMVA3PT.js";
|
|
5
|
+
import "./chunk-I7AW4237.js";
|
|
6
|
+
import "./chunk-GUMRIUI5.js";
|
|
7
|
+
import {
|
|
8
|
+
getClient
|
|
9
|
+
} from "./chunk-XABJRAUW.js";
|
|
10
|
+
import "./chunk-2I23RPSI.js";
|
|
11
|
+
import "./chunk-PH6VRRFR.js";
|
|
12
|
+
import "./chunk-PNQDP3OA.js";
|
|
13
|
+
import "./chunk-7HLWBYH7.js";
|
|
14
|
+
import "./chunk-FXU7JOXK.js";
|
|
15
|
+
import "./chunk-R36FAN53.js";
|
|
16
|
+
import "./chunk-LYH5HE24.js";
|
|
17
|
+
import "./chunk-MLKGABMK.js";
|
|
18
|
+
|
|
19
|
+
// src/lib/co-occurrence.ts
|
|
20
|
+
var SPECIFICITY = {
|
|
21
|
+
file: 5,
|
|
22
|
+
function: 4,
|
|
23
|
+
error: 3,
|
|
24
|
+
tool: 2,
|
|
25
|
+
agent: 1,
|
|
26
|
+
project: 0
|
|
27
|
+
};
|
|
28
|
+
function getSpecificity(type) {
|
|
29
|
+
return SPECIFICITY[type] ?? 1;
|
|
30
|
+
}
|
|
31
|
+
function coOccurrenceId(entityId1, entityId2) {
|
|
32
|
+
const sorted = [entityId1, entityId2].sort();
|
|
33
|
+
return `cooccur:${sorted[0]}:${sorted[1]}`;
|
|
34
|
+
}
|
|
35
|
+
async function actualEntityId(name, type, fallbackId) {
|
|
36
|
+
try {
|
|
37
|
+
const result = await getClient().execute({
|
|
38
|
+
sql: "SELECT id FROM entities WHERE LOWER(name) = LOWER(?) AND type = ? LIMIT 1",
|
|
39
|
+
args: [name, type]
|
|
40
|
+
});
|
|
41
|
+
return result.rows[0]?.id ? String(result.rows[0].id) : fallbackId;
|
|
42
|
+
} catch {
|
|
43
|
+
return fallbackId;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function createCoOccurrenceEdges(entities, _memoryId) {
|
|
47
|
+
if (entities.length < 2) return 0;
|
|
48
|
+
const client = getClient();
|
|
49
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
50
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51
|
+
const deduped = entities.filter((e) => {
|
|
52
|
+
const key = `${e.type.toLowerCase()}:${normalizeEntityName(e.name)}`;
|
|
53
|
+
if (seen.has(key)) return false;
|
|
54
|
+
seen.add(key);
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
const sorted = deduped.sort((a, b) => getSpecificity(b.type) - getSpecificity(a.type));
|
|
58
|
+
const MAX_PAIRS = 10;
|
|
59
|
+
const pairs = [];
|
|
60
|
+
for (let i = 0; i < sorted.length && pairs.length < MAX_PAIRS; i++) {
|
|
61
|
+
for (let j = i + 1; j < sorted.length && pairs.length < MAX_PAIRS; j++) {
|
|
62
|
+
pairs.push([sorted[i], sorted[j]]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let created = 0;
|
|
66
|
+
for (const [a, b] of pairs) {
|
|
67
|
+
const aName = normalizeEntityName(a.name);
|
|
68
|
+
const bName = normalizeEntityName(b.name);
|
|
69
|
+
const aType = a.type.toLowerCase();
|
|
70
|
+
const bType = b.type.toLowerCase();
|
|
71
|
+
const aId = await actualEntityId(aName, aType, entityId(aName, aType));
|
|
72
|
+
const bId = await actualEntityId(bName, bType, entityId(bName, bType));
|
|
73
|
+
if (aId === bId) continue;
|
|
74
|
+
const relId = coOccurrenceId(aId, bId);
|
|
75
|
+
const sortedIds = [aId, bId].sort();
|
|
76
|
+
const sourceId = sortedIds[0];
|
|
77
|
+
const targetId = sortedIds[1];
|
|
78
|
+
try {
|
|
79
|
+
await client.execute({
|
|
80
|
+
sql: `INSERT INTO relationships (id, source_entity_id, target_entity_id, type, weight, timestamp, properties)
|
|
81
|
+
VALUES (?, ?, ?, 'co_occurs_with', 1.0, ?, '{}')
|
|
82
|
+
ON CONFLICT(source_entity_id, target_entity_id, type) DO UPDATE SET
|
|
83
|
+
weight = MIN(weight + 0.1, 10.0),
|
|
84
|
+
timestamp = ?`,
|
|
85
|
+
args: [relId, sourceId, targetId, now, now]
|
|
86
|
+
});
|
|
87
|
+
created++;
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return created;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
createCoOccurrenceEdges
|
|
95
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
analyzeBlastRadius,
|
|
3
|
+
buildCodeContextIndex,
|
|
4
|
+
buildCodeContextIndexWithEmbeddings,
|
|
5
|
+
getCodeContextIndexPath,
|
|
6
|
+
getCodeContextStats,
|
|
7
|
+
loadOrBuildCodeContextIndex,
|
|
8
|
+
searchCodeContext,
|
|
9
|
+
searchCodeContextSemantic,
|
|
10
|
+
traceCodeSymbol
|
|
11
|
+
} from "./chunk-BWJDJ3BS.js";
|
|
12
|
+
import "./chunk-I7AW4237.js";
|
|
13
|
+
import "./chunk-NTWF4DAF.js";
|
|
14
|
+
import "./chunk-QOZQ2MYZ.js";
|
|
15
|
+
import "./chunk-HCCG67BY.js";
|
|
16
|
+
import "./chunk-7L2EV3XX.js";
|
|
17
|
+
import "./chunk-R36FAN53.js";
|
|
18
|
+
import "./chunk-LYH5HE24.js";
|
|
19
|
+
import "./chunk-MLKGABMK.js";
|
|
20
|
+
export {
|
|
21
|
+
analyzeBlastRadius,
|
|
22
|
+
buildCodeContextIndex,
|
|
23
|
+
buildCodeContextIndexWithEmbeddings,
|
|
24
|
+
getCodeContextIndexPath,
|
|
25
|
+
getCodeContextStats,
|
|
26
|
+
loadOrBuildCodeContextIndex,
|
|
27
|
+
searchCodeContext,
|
|
28
|
+
searchCodeContextSemantic,
|
|
29
|
+
traceCodeSymbol
|
|
30
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXTRACT_TOOL
|
|
3
|
+
} from "./chunk-EDMVA3PT.js";
|
|
4
|
+
import "./chunk-I7AW4237.js";
|
|
5
|
+
import "./chunk-GUMRIUI5.js";
|
|
6
|
+
import "./chunk-MLKGABMK.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/conversation-entity-extractor.ts
|
|
9
|
+
async function extractFromConversation(msg, agentResponse, agentName, model = "claude-haiku-4-5-20251001") {
|
|
10
|
+
const text = msg.text ?? "";
|
|
11
|
+
if (text.length < 20) {
|
|
12
|
+
return { entities: [], relationships: [], hyperedges: [] };
|
|
13
|
+
}
|
|
14
|
+
const senderName = msg.senderName ?? msg.senderId;
|
|
15
|
+
const prompt = [
|
|
16
|
+
`Extract entities and relationships from this conversation message.`,
|
|
17
|
+
`Platform: ${msg.platform} | Sender: ${senderName} | Account: ${msg.accountId ?? "unknown"}`,
|
|
18
|
+
``,
|
|
19
|
+
`Focus on: people (from sender name, mentioned names), companies, products, topics discussed, locations mentioned.`,
|
|
20
|
+
`Only extract what's clearly stated. For business conversations, capture: customer intent, product interest, service requests.`,
|
|
21
|
+
``,
|
|
22
|
+
`MESSAGE:`,
|
|
23
|
+
text,
|
|
24
|
+
agentResponse ? `
|
|
25
|
+
AGENT RESPONSE (${agentName ?? "unknown"}):
|
|
26
|
+
${agentResponse}` : ""
|
|
27
|
+
].join("\n");
|
|
28
|
+
try {
|
|
29
|
+
const Anthropic = (await import("@anthropic-ai/sdk")).default;
|
|
30
|
+
const client = new Anthropic();
|
|
31
|
+
const response = await client.messages.create({
|
|
32
|
+
model,
|
|
33
|
+
max_tokens: 512,
|
|
34
|
+
system: prompt,
|
|
35
|
+
messages: [{ role: "user", content: "Extract entities and relationships from the message above." }],
|
|
36
|
+
tools: [EXTRACT_TOOL],
|
|
37
|
+
tool_choice: { type: "tool", name: "extract_entities_and_relationships" }
|
|
38
|
+
});
|
|
39
|
+
const toolBlock = response.content.find((b) => b.type === "tool_use");
|
|
40
|
+
if (!toolBlock || toolBlock.type !== "tool_use") {
|
|
41
|
+
return { entities: [], relationships: [], hyperedges: [] };
|
|
42
|
+
}
|
|
43
|
+
const input = toolBlock.input;
|
|
44
|
+
const rawEntities = input.entities ?? [];
|
|
45
|
+
const rawRels = input.relationships ?? [];
|
|
46
|
+
const rawHyperedges = input.hyperedges ?? [];
|
|
47
|
+
const entities = rawEntities.map((e) => ({ name: e.name ?? "", type: e.type ?? "concept" })).filter((e) => e.name.length > 0);
|
|
48
|
+
const relationships = rawRels.map((r) => ({
|
|
49
|
+
source: r.source ?? "",
|
|
50
|
+
sourceType: r.source_type ?? "concept",
|
|
51
|
+
target: r.target ?? "",
|
|
52
|
+
targetType: r.target_type ?? "concept",
|
|
53
|
+
relationship: r.relationship ?? "related_to",
|
|
54
|
+
confidence: Number(r.confidence ?? 1),
|
|
55
|
+
confidenceLabel: String(r.confidence_label ?? "extracted")
|
|
56
|
+
})).filter((r) => r.source.length > 0 && r.target.length > 0);
|
|
57
|
+
const hyperedges = rawHyperedges.map((h) => ({
|
|
58
|
+
label: String(h.label ?? ""),
|
|
59
|
+
relation: String(h.relation ?? ""),
|
|
60
|
+
entityNames: h.entity_names ?? [],
|
|
61
|
+
confidence: Number(h.confidence ?? 1)
|
|
62
|
+
})).filter((h) => h.label.length > 0 && h.entityNames.length >= 3);
|
|
63
|
+
const senderExists = entities.some(
|
|
64
|
+
(e) => e.type === "person" && e.name.toLowerCase() === senderName.toLowerCase()
|
|
65
|
+
);
|
|
66
|
+
if (!senderExists) {
|
|
67
|
+
entities.push({ name: senderName, type: "person" });
|
|
68
|
+
}
|
|
69
|
+
if (msg.accountId) {
|
|
70
|
+
const hasCommunicates = relationships.some(
|
|
71
|
+
(r) => r.relationship === "communicates_with" && r.source.toLowerCase() === senderName.toLowerCase()
|
|
72
|
+
);
|
|
73
|
+
if (!hasCommunicates) {
|
|
74
|
+
relationships.push({
|
|
75
|
+
source: senderName,
|
|
76
|
+
sourceType: "person",
|
|
77
|
+
target: msg.accountId,
|
|
78
|
+
targetType: "person",
|
|
79
|
+
relationship: "communicates_with",
|
|
80
|
+
confidence: 1,
|
|
81
|
+
confidenceLabel: "extracted"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const provenance = {
|
|
86
|
+
source: "gateway-conversation",
|
|
87
|
+
platform: msg.platform,
|
|
88
|
+
senderId: msg.senderId,
|
|
89
|
+
senderName: msg.senderName,
|
|
90
|
+
accountId: msg.accountId,
|
|
91
|
+
messageId: msg.messageId,
|
|
92
|
+
timestamp: msg.timestamp,
|
|
93
|
+
agentName,
|
|
94
|
+
extractionModel: model,
|
|
95
|
+
extractedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
96
|
+
};
|
|
97
|
+
for (const entity of entities) {
|
|
98
|
+
entity.properties = { ...entity.properties ?? {}, provenance };
|
|
99
|
+
}
|
|
100
|
+
for (const rel of relationships) {
|
|
101
|
+
rel.properties = { ...rel.properties ?? {}, provenance };
|
|
102
|
+
}
|
|
103
|
+
return { entities, relationships, hyperedges };
|
|
104
|
+
} catch (err) {
|
|
105
|
+
process.stderr.write(
|
|
106
|
+
`[conversation-entity-extractor] Extraction failed: ${err instanceof Error ? err.message : String(err)}
|
|
107
|
+
`
|
|
108
|
+
);
|
|
109
|
+
return { entities: [], relationships: [], hyperedges: [] };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
extractFromConversation
|
|
114
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import "./chunk-MLKGABMK.js";
|
|
2
|
+
|
|
3
|
+
// src/lib/core-memory.ts
|
|
4
|
+
var MAX_CORE_ENTRIES = 10;
|
|
5
|
+
var MAX_ENTRY_LENGTH = 500;
|
|
6
|
+
var MAX_TOTAL_CHARS = 5e3;
|
|
7
|
+
async function getCoreMemory(agentId) {
|
|
8
|
+
try {
|
|
9
|
+
const { getClient } = await import("./lib/database.js");
|
|
10
|
+
const client = getClient();
|
|
11
|
+
const result = await client.execute({
|
|
12
|
+
sql: `SELECT key, value, updated_at FROM core_memory
|
|
13
|
+
WHERE agent_id = ? ORDER BY key ASC`,
|
|
14
|
+
args: [agentId]
|
|
15
|
+
});
|
|
16
|
+
return result.rows.map((r) => ({
|
|
17
|
+
key: String(r.key),
|
|
18
|
+
value: String(r.value),
|
|
19
|
+
updatedAt: String(r.updated_at)
|
|
20
|
+
}));
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function setCoreMemory(agentId, key, value) {
|
|
26
|
+
if (value.length > MAX_ENTRY_LENGTH) {
|
|
27
|
+
throw new Error(`Core memory value too long (${value.length}/${MAX_ENTRY_LENGTH} chars). Core memory is for key facts, not documents.`);
|
|
28
|
+
}
|
|
29
|
+
const { getClient } = await import("./lib/database.js");
|
|
30
|
+
const client = getClient();
|
|
31
|
+
const countResult = await client.execute({
|
|
32
|
+
sql: `SELECT COUNT(*) as cnt FROM core_memory WHERE agent_id = ?`,
|
|
33
|
+
args: [agentId]
|
|
34
|
+
});
|
|
35
|
+
const count = Number(countResult.rows[0]?.cnt ?? 0);
|
|
36
|
+
const existing = await client.execute({
|
|
37
|
+
sql: `SELECT key FROM core_memory WHERE agent_id = ? AND key = ?`,
|
|
38
|
+
args: [agentId, key]
|
|
39
|
+
});
|
|
40
|
+
if (existing.rows.length === 0 && count >= MAX_CORE_ENTRIES) {
|
|
41
|
+
const oldest = await client.execute({
|
|
42
|
+
sql: `SELECT key, value, updated_at FROM core_memory
|
|
43
|
+
WHERE agent_id = ? ORDER BY updated_at ASC LIMIT 1`,
|
|
44
|
+
args: [agentId]
|
|
45
|
+
});
|
|
46
|
+
if (oldest.rows.length > 0) {
|
|
47
|
+
const oldKey = String(oldest.rows[0].key);
|
|
48
|
+
const oldValue = String(oldest.rows[0].value);
|
|
49
|
+
try {
|
|
50
|
+
const { randomUUID } = await import("crypto");
|
|
51
|
+
const { writeMemory } = await import("./lib/store.js");
|
|
52
|
+
await writeMemory({
|
|
53
|
+
id: randomUUID(),
|
|
54
|
+
agent_id: agentId,
|
|
55
|
+
agent_role: "core-demotion",
|
|
56
|
+
session_id: "core-memory-demotion",
|
|
57
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
58
|
+
tool_name: "core_memory_demotion",
|
|
59
|
+
project_name: "exe-os",
|
|
60
|
+
has_error: false,
|
|
61
|
+
raw_text: `[Demoted from core memory] ${oldKey}: ${oldValue}`,
|
|
62
|
+
vector: null
|
|
63
|
+
});
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
await client.execute({
|
|
67
|
+
sql: `DELETE FROM core_memory WHERE agent_id = ? AND key = ?`,
|
|
68
|
+
args: [agentId, oldKey]
|
|
69
|
+
});
|
|
70
|
+
process.stderr.write(`[core-memory] Auto-demoted "${oldKey}" to regular memory (core full at ${MAX_CORE_ENTRIES})
|
|
71
|
+
`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const sizeResult = await client.execute({
|
|
75
|
+
sql: `SELECT COALESCE(SUM(LENGTH(value)), 0) as total FROM core_memory WHERE agent_id = ? AND key != ?`,
|
|
76
|
+
args: [agentId, key]
|
|
77
|
+
});
|
|
78
|
+
const currentSize = Number(sizeResult.rows[0]?.total ?? 0);
|
|
79
|
+
if (currentSize + value.length > MAX_TOTAL_CHARS) {
|
|
80
|
+
throw new Error(`Core memory would exceed ${MAX_TOTAL_CHARS} char limit. Delete entries or shorten values.`);
|
|
81
|
+
}
|
|
82
|
+
await client.execute({
|
|
83
|
+
sql: `INSERT OR REPLACE INTO core_memory (agent_id, key, value, updated_at)
|
|
84
|
+
VALUES (?, ?, ?, ?)`,
|
|
85
|
+
args: [agentId, key, value, (/* @__PURE__ */ new Date()).toISOString()]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function deleteCoreMemory(agentId, key) {
|
|
89
|
+
const { getClient } = await import("./lib/database.js");
|
|
90
|
+
const client = getClient();
|
|
91
|
+
const result = await client.execute({
|
|
92
|
+
sql: `DELETE FROM core_memory WHERE agent_id = ? AND key = ?`,
|
|
93
|
+
args: [agentId, key]
|
|
94
|
+
});
|
|
95
|
+
return (result.rowsAffected ?? 0) > 0;
|
|
96
|
+
}
|
|
97
|
+
function formatCoreMemoryBlock(entries) {
|
|
98
|
+
if (entries.length === 0) return null;
|
|
99
|
+
const lines = ["## Core Memory (always in context)", ""];
|
|
100
|
+
for (const e of entries) {
|
|
101
|
+
lines.push(`- **${e.key}:** ${e.value}`);
|
|
102
|
+
}
|
|
103
|
+
return lines.join("\n");
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
deleteCoreMemory,
|
|
107
|
+
formatCoreMemoryBlock,
|
|
108
|
+
getCoreMemory,
|
|
109
|
+
setCoreMemory
|
|
110
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import "./chunk-MLKGABMK.js";
|
|
2
|
+
|
|
3
|
+
// src/lib/core-memory.ts
|
|
4
|
+
var MAX_CORE_ENTRIES = 10;
|
|
5
|
+
var MAX_ENTRY_LENGTH = 500;
|
|
6
|
+
var MAX_TOTAL_CHARS = 5e3;
|
|
7
|
+
async function getCoreMemory(agentId) {
|
|
8
|
+
try {
|
|
9
|
+
const { getClient } = await import("./lib/database.js");
|
|
10
|
+
const client = getClient();
|
|
11
|
+
const result = await client.execute({
|
|
12
|
+
sql: `SELECT key, value, updated_at FROM core_memory
|
|
13
|
+
WHERE agent_id = ? ORDER BY key ASC`,
|
|
14
|
+
args: [agentId]
|
|
15
|
+
});
|
|
16
|
+
return result.rows.map((r) => ({
|
|
17
|
+
key: String(r.key),
|
|
18
|
+
value: String(r.value),
|
|
19
|
+
updatedAt: String(r.updated_at)
|
|
20
|
+
}));
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function setCoreMemory(agentId, key, value) {
|
|
26
|
+
if (value.length > MAX_ENTRY_LENGTH) {
|
|
27
|
+
throw new Error(`Core memory value too long (${value.length}/${MAX_ENTRY_LENGTH} chars). Core memory is for key facts, not documents.`);
|
|
28
|
+
}
|
|
29
|
+
const { getClient } = await import("./lib/database.js");
|
|
30
|
+
const client = getClient();
|
|
31
|
+
const countResult = await client.execute({
|
|
32
|
+
sql: `SELECT COUNT(*) as cnt FROM core_memory WHERE agent_id = ?`,
|
|
33
|
+
args: [agentId]
|
|
34
|
+
});
|
|
35
|
+
const count = Number(countResult.rows[0]?.cnt ?? 0);
|
|
36
|
+
const existing = await client.execute({
|
|
37
|
+
sql: `SELECT key FROM core_memory WHERE agent_id = ? AND key = ?`,
|
|
38
|
+
args: [agentId, key]
|
|
39
|
+
});
|
|
40
|
+
if (existing.rows.length === 0 && count >= MAX_CORE_ENTRIES) {
|
|
41
|
+
const oldest = await client.execute({
|
|
42
|
+
sql: `SELECT key, value, updated_at FROM core_memory
|
|
43
|
+
WHERE agent_id = ? ORDER BY updated_at ASC LIMIT 1`,
|
|
44
|
+
args: [agentId]
|
|
45
|
+
});
|
|
46
|
+
if (oldest.rows.length > 0) {
|
|
47
|
+
const oldKey = String(oldest.rows[0].key);
|
|
48
|
+
const oldValue = String(oldest.rows[0].value);
|
|
49
|
+
try {
|
|
50
|
+
const { randomUUID } = await import("crypto");
|
|
51
|
+
const { writeMemory } = await import("./lib/store.js");
|
|
52
|
+
await writeMemory({
|
|
53
|
+
id: randomUUID(),
|
|
54
|
+
agent_id: agentId,
|
|
55
|
+
agent_role: "core-demotion",
|
|
56
|
+
session_id: "core-memory-demotion",
|
|
57
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
58
|
+
tool_name: "core_memory_demotion",
|
|
59
|
+
project_name: "exe-os",
|
|
60
|
+
has_error: false,
|
|
61
|
+
raw_text: `[Demoted from core memory] ${oldKey}: ${oldValue}`,
|
|
62
|
+
vector: null
|
|
63
|
+
});
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
await client.execute({
|
|
67
|
+
sql: `DELETE FROM core_memory WHERE agent_id = ? AND key = ?`,
|
|
68
|
+
args: [agentId, oldKey]
|
|
69
|
+
});
|
|
70
|
+
process.stderr.write(`[core-memory] Auto-demoted "${oldKey}" to regular memory (core full at ${MAX_CORE_ENTRIES})
|
|
71
|
+
`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const sizeResult = await client.execute({
|
|
75
|
+
sql: `SELECT COALESCE(SUM(LENGTH(value)), 0) as total FROM core_memory WHERE agent_id = ? AND key != ?`,
|
|
76
|
+
args: [agentId, key]
|
|
77
|
+
});
|
|
78
|
+
const currentSize = Number(sizeResult.rows[0]?.total ?? 0);
|
|
79
|
+
if (currentSize + value.length > MAX_TOTAL_CHARS) {
|
|
80
|
+
throw new Error(`Core memory would exceed ${MAX_TOTAL_CHARS} char limit. Delete entries or shorten values.`);
|
|
81
|
+
}
|
|
82
|
+
await client.execute({
|
|
83
|
+
sql: `INSERT OR REPLACE INTO core_memory (agent_id, key, value, updated_at)
|
|
84
|
+
VALUES (?, ?, ?, ?)`,
|
|
85
|
+
args: [agentId, key, value, (/* @__PURE__ */ new Date()).toISOString()]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function deleteCoreMemory(agentId, key) {
|
|
89
|
+
const { getClient } = await import("./lib/database.js");
|
|
90
|
+
const client = getClient();
|
|
91
|
+
const result = await client.execute({
|
|
92
|
+
sql: `DELETE FROM core_memory WHERE agent_id = ? AND key = ?`,
|
|
93
|
+
args: [agentId, key]
|
|
94
|
+
});
|
|
95
|
+
return (result.rowsAffected ?? 0) > 0;
|
|
96
|
+
}
|
|
97
|
+
function formatCoreMemoryBlock(entries) {
|
|
98
|
+
if (entries.length === 0) return null;
|
|
99
|
+
const lines = ["## Core Memory (always in context)", ""];
|
|
100
|
+
for (const e of entries) {
|
|
101
|
+
lines.push(`- **${e.key}:** ${e.value}`);
|
|
102
|
+
}
|
|
103
|
+
return lines.join("\n");
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
deleteCoreMemory,
|
|
107
|
+
formatCoreMemoryBlock,
|
|
108
|
+
getCoreMemory,
|
|
109
|
+
setCoreMemory
|
|
110
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_setStatePath,
|
|
3
|
+
applyRemoteUpdate,
|
|
4
|
+
destroyCrdtDoc,
|
|
5
|
+
getDiffUpdate,
|
|
6
|
+
getFullState,
|
|
7
|
+
getStateVector,
|
|
8
|
+
importExistingBehaviors,
|
|
9
|
+
importExistingMemories,
|
|
10
|
+
initCrdtDoc,
|
|
11
|
+
isCrdtSyncEnabled,
|
|
12
|
+
onUpdate,
|
|
13
|
+
readAllBehaviors,
|
|
14
|
+
readAllMemories,
|
|
15
|
+
rebuildFromDb
|
|
16
|
+
} from "./chunk-DFGXRKI2.js";
|
|
17
|
+
import "./chunk-MLKGABMK.js";
|
|
18
|
+
export {
|
|
19
|
+
_setStatePath,
|
|
20
|
+
applyRemoteUpdate,
|
|
21
|
+
destroyCrdtDoc,
|
|
22
|
+
getDiffUpdate,
|
|
23
|
+
getFullState,
|
|
24
|
+
getStateVector,
|
|
25
|
+
importExistingBehaviors,
|
|
26
|
+
importExistingMemories,
|
|
27
|
+
initCrdtDoc,
|
|
28
|
+
isCrdtSyncEnabled,
|
|
29
|
+
onUpdate,
|
|
30
|
+
readAllBehaviors,
|
|
31
|
+
readAllMemories,
|
|
32
|
+
rebuildFromDb
|
|
33
|
+
};
|