@askexenow/exe-os 0.9.264 → 0.9.266
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.example +4 -2
- package/deploy/compose/docker-compose.yml +6 -4
- package/deploy/compose/generate-env.ts +5 -2
- package/dist/active-agent-2XJJZFEW.js +25 -0
- package/dist/active-agent-JZ4PHIAK.js +26 -0
- package/dist/agentic-ontology-J4B525DT.js +25 -0
- package/dist/backfill-metadata-TWEC6BJD.js +597 -0
- package/dist/backfill-metadata-VGZLCJWZ.js +597 -0
- package/dist/backfill-metadata-WM46YQZL.js +597 -0
- package/dist/behaviors-BPIVFAGY.js +25 -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 +4 -4
- package/dist/bin/backfill-responses.js +4 -4
- package/dist/bin/backfill-vectors.js +5 -5
- package/dist/bin/bulk-sync-postgres.js +6 -6
- package/dist/bin/cc-doctor.js +6 -1
- package/dist/bin/cleanup-stale-review-tasks.js +9 -9
- package/dist/bin/cli.js +15 -15
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +4 -4
- package/dist/bin/exe-assign.js +5 -5
- package/dist/bin/exe-boot.js +16 -16
- package/dist/bin/exe-call.js +4 -4
- package/dist/bin/exe-cloud.js +4 -4
- package/dist/bin/exe-dispatch.js +9 -9
- package/dist/bin/exe-doctor.js +1 -1
- 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 +6 -1
- package/dist/bin/exe-heartbeat.js +10 -10
- package/dist/bin/exe-kill.js +12 -12
- package/dist/bin/exe-launch-agent.js +16 -16
- package/dist/bin/exe-new-employee.js +6 -6
- package/dist/bin/exe-pending-messages.js +10 -10
- package/dist/bin/exe-pending-notifications.js +9 -9
- package/dist/bin/exe-pending-reviews.js +12 -10
- package/dist/bin/exe-rename.js +4 -4
- package/dist/bin/exe-review.js +11 -11
- package/dist/bin/exe-search.js +5 -5
- package/dist/bin/exe-session-cleanup.js +14 -14
- package/dist/bin/exe-settings.js +4 -4
- package/dist/bin/exe-start-codex.js +11 -11
- package/dist/bin/exe-start-opencode.js +8 -8
- package/dist/bin/exe-status.js +10 -10
- package/dist/bin/exe-team.js +3 -3
- package/dist/bin/git-sweep.js +10 -10
- package/dist/bin/graph-backfill.js +4 -4
- package/dist/bin/graph-export.js +5 -5
- package/dist/bin/import-history.js +7 -7
- package/dist/bin/install.js +6 -6
- package/dist/bin/intercom-check.js +6 -5
- 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/scan-tasks.js +9 -9
- package/dist/bin/setup.js +1 -1
- package/dist/bin/shard-migrate.js +4 -4
- package/dist/capacity-monitor-3QORC56J.js +49 -0
- package/dist/capacity-monitor-FWRBCZCZ.js +49 -0
- package/dist/capacity-monitor-FZORNXTA.js +49 -0
- package/dist/catchup-brief-242H63OP.js +151 -0
- package/dist/catchup-brief-PRKHIRWW.js +151 -0
- package/dist/catchup-brief-T7W2ARRB.js +151 -0
- package/dist/catchup-brief-VJDLXJHJ.js +151 -0
- package/dist/chunk-2FDYA3GS.js +75 -0
- package/dist/chunk-2GU3NYMB.js +813 -0
- package/dist/chunk-2V33IVZF.js +1148 -0
- package/dist/chunk-2VT7Z2E2.js +197 -0
- package/dist/chunk-2W5NQOQJ.js +333 -0
- package/dist/chunk-32QR5EHE.js +244 -0
- package/dist/chunk-3DBROKA6.js +382 -0
- package/dist/chunk-3DS2YHAT.js +204 -0
- package/dist/chunk-3L6XLN4V.js +1090 -0
- package/dist/chunk-3O2ZD7YV.js +227 -0
- package/dist/chunk-3T4PNG5O.js +447 -0
- package/dist/chunk-3W324KN7.js +13696 -0
- package/dist/chunk-43O2PZH7.js +214 -0
- package/dist/chunk-4AHL6I7X.js +284 -0
- package/dist/chunk-4IATAIAF.js +89 -0
- package/dist/chunk-5GBPXJIH.js +50 -0
- package/dist/chunk-5IXN2532.js +58 -0
- package/dist/chunk-5M4F2FVD.js +204 -0
- package/dist/chunk-5SH5TR45.js +731 -0
- package/dist/chunk-5TANMPI4.js +377 -0
- package/dist/chunk-5XGMTWKW.js +128 -0
- package/dist/chunk-67E5WIMW.js +333 -0
- package/dist/chunk-6AQAILCS.js +13696 -0
- package/dist/chunk-6NRJIARA.js +346 -0
- package/dist/chunk-6O22GTSE.js +1148 -0
- package/dist/chunk-72KQJZBH.js +382 -0
- package/dist/chunk-7B2AENJ3.js +1345 -0
- package/dist/chunk-7GKMYFVR.js +551 -0
- package/dist/chunk-7HUGVJHW.js +1021 -0
- package/dist/chunk-7HWBGXDV.js +333 -0
- package/dist/chunk-7O5CMDP6.js +1345 -0
- package/dist/chunk-7P2JKEO3.js +382 -0
- package/dist/chunk-7ROGPDW6.js +197 -0
- package/dist/chunk-7ZMLNURG.js +513 -0
- package/dist/chunk-A3G4UXNA.js +280 -0
- package/dist/chunk-A4T6U3XZ.js +371 -0
- package/dist/chunk-A4UY44T7.js +486 -0
- package/dist/chunk-ADJNRFEK.js +13696 -0
- package/dist/chunk-AVJTW67M.js +513 -0
- package/dist/chunk-AZHPQGSI.js +159 -0
- package/dist/chunk-B6RC7DAC.js +1090 -0
- package/dist/chunk-BAOJLZVC.js +244 -0
- package/dist/chunk-BCUMPA7J.js +159 -0
- package/dist/chunk-BH2ST7KK.js +183 -0
- package/dist/chunk-BQAC3GCO.js +127 -0
- package/dist/chunk-C4BIYP5C.js +129 -0
- package/dist/chunk-CBUZG6OC.js +89 -0
- package/dist/chunk-CGQRWCCP.js +81 -0
- package/dist/chunk-CIWJRYIC.js +244 -0
- package/dist/chunk-CLX4WQHT.js +214 -0
- package/dist/chunk-CZO2DGGF.js +214 -0
- package/dist/chunk-D4CQZL46.js +76 -0
- package/dist/chunk-D55SXO3N.js +3951 -0
- package/dist/chunk-DEBLYXA2.js +56 -0
- package/dist/chunk-EDNUE5L3.js +38 -0
- package/dist/chunk-EPDSRI6O.js +284 -0
- package/dist/chunk-ESNHLTLC.js +1073 -0
- package/dist/chunk-EU34R2A3.js +1073 -0
- package/dist/chunk-FICUAZEA.js +128 -0
- package/dist/chunk-FP6U5PSY.js +818 -0
- package/dist/chunk-G4KEDLSM.js +488 -0
- package/dist/chunk-G55UTKFR.js +89 -0
- package/dist/chunk-GIJUXLK5.js +330 -0
- package/dist/chunk-GVSSEGIV.js +348 -0
- package/dist/chunk-GYOOZ725.js +330 -0
- package/dist/chunk-HCULUL4D.js +447 -0
- package/dist/chunk-HDRQKH7R.js +1051 -0
- package/dist/chunk-HHBN7Y7R.js +197 -0
- package/dist/chunk-IODP4JNE.js +551 -0
- package/dist/chunk-IQBXQ7GF.js +1073 -0
- package/dist/chunk-ITF6GEJI.js +2091 -0
- package/dist/chunk-IXHVSWLM.js +58 -0
- package/dist/chunk-IZ6LCET7.js +58 -0
- package/dist/chunk-J3ZFONT4.js +1921 -0
- package/dist/chunk-JEOFG274.js +394 -0
- package/dist/chunk-JH7ISOIJ.js +33 -0
- package/dist/chunk-JVRMAVPN.js +731 -0
- package/dist/chunk-KBYRYSXT.js +3951 -0
- package/dist/chunk-KECNXWD6.js +1051 -0
- package/dist/chunk-KIYCHS35.js +128 -0
- package/dist/chunk-KUP3D6G2.js +1345 -0
- package/dist/chunk-KXS5HHDH.js +54 -0
- package/dist/chunk-LPG3U5UW.js +731 -0
- package/dist/chunk-LVZW4WQY.js +221 -0
- package/dist/chunk-LWOCCDSB.js +240 -0
- package/dist/chunk-M4HRKRSE.js +30 -0
- package/dist/chunk-MPG5DR3K.js +244 -0
- package/dist/chunk-NH6TPXZV.js +13696 -0
- package/dist/chunk-NOG2LVBA.js +159 -0
- package/dist/chunk-NP3CYOEY.js +290 -0
- package/dist/chunk-O5TZI7OZ.js +50 -0
- package/dist/chunk-OVQOKLYA.js +210 -0
- package/dist/chunk-OW26ML36.js +1148 -0
- package/dist/chunk-P2DOIWQG.js +260 -0
- package/dist/chunk-P2QTTEYP.js +3951 -0
- package/dist/chunk-P5IKFL7B.js +85 -0
- package/dist/chunk-PD2LUPHD.js +377 -0
- package/dist/chunk-PF5EFIAH.js +818 -0
- package/dist/chunk-PK3NFO76.js +551 -0
- package/dist/chunk-Q3N4KHLM.js +330 -0
- package/dist/chunk-QHQTMWYH.js +54 -0
- package/dist/chunk-QKMFMJTU.js +171 -0
- package/dist/chunk-QNYOPM2L.js +1921 -0
- package/dist/chunk-R77M74QM.js +13696 -0
- package/dist/chunk-RHZ2CRJU.js +3556 -0
- package/dist/chunk-RLR4LVO5.js +1090 -0
- package/dist/chunk-RMDDSWFH.js +495 -0
- package/dist/chunk-RPLEZ74B.js +95 -0
- package/dist/chunk-RXMVPGH2.js +346 -0
- package/dist/chunk-S2ARWNS6.js +135 -0
- package/dist/chunk-SHPIATX7.js +90 -0
- package/dist/chunk-SPOA7EOD.js +81 -0
- package/dist/chunk-SQUZ3TI2.js +668 -0
- package/dist/chunk-SUGBKORD.js +1148 -0
- package/dist/chunk-T2XD7XL2.js +346 -0
- package/dist/chunk-TAIYLROT.js +127 -0
- package/dist/chunk-TCD4XCBS.js +495 -0
- package/dist/chunk-TK23WXKB.js +128 -0
- package/dist/chunk-TOVXER6J.js +76 -0
- package/dist/chunk-TSBMSHMM.js +163 -0
- package/dist/chunk-U776PBU6.js +488 -0
- package/dist/chunk-UIPAZYP7.js +171 -0
- package/dist/chunk-UTVNIAOF.js +284 -0
- package/dist/chunk-VF6VT4MR.js +70 -0
- package/dist/chunk-VZXLYUKS.js +171 -0
- package/dist/chunk-WIAHPJDS.js +58 -0
- package/dist/chunk-WM5ELLT4.js +54 -0
- package/dist/chunk-WUUSPOCC.js +1921 -0
- package/dist/chunk-WXHAMPK4.js +81 -0
- package/dist/chunk-WXW4GF6M.js +495 -0
- package/dist/chunk-WYNZ23XH.js +262 -0
- package/dist/chunk-WZOQLU2Y.js +127 -0
- package/dist/chunk-X24GBZKR.js +157 -0
- package/dist/chunk-X5FRF5MG.js +13696 -0
- package/dist/chunk-XBPLYFBA.js +204 -0
- package/dist/chunk-XDGKFXFW.js +363 -0
- package/dist/chunk-XIT6ONPY.js +630 -0
- package/dist/{chunk-YGOUKUNX.js → chunk-XLYBSXWS.js} +2 -1
- package/dist/chunk-XNRJ5JHU.js +377 -0
- package/dist/chunk-XREWTPZM.js +123 -0
- package/dist/chunk-XURCA5VD.js +297 -0
- package/dist/chunk-Y55VFZJB.js +50 -0
- package/dist/chunk-YIH2YMWP.js +76 -0
- package/dist/chunk-YZMCCT73.js +97 -0
- package/dist/chunk-ZTP3VV23.js +447 -0
- package/dist/co-activation-JOYR73H2.js +72 -0
- package/dist/co-occurrence-G7RRJ3DB.js +74 -0
- package/dist/core-memory-6KK55Z65.js +110 -0
- package/dist/core-memory-QRS6GBXL.js +110 -0
- package/dist/core-memory-QXMQ5I7S.js +110 -0
- package/dist/crdt-sync-QWK65Z5A.js +33 -0
- package/dist/crm-webhook-BNUS3USD.js +10 -0
- package/dist/crm-webhook-CH5W633Y.js +10 -0
- package/dist/crm-webhook-ZTIRFVAH.js +10 -0
- package/dist/cto-delegation-gate-DNZJGBS7.js +206 -0
- package/dist/cto-delegation-gate-XY3NMGTE.js +206 -0
- package/dist/cto-delegation-gate-YI3LK7VY.js +206 -0
- package/dist/daemon-orchestration-7LVOHYKA.js +135 -0
- package/dist/daemon-orchestration-LS62JMTI.js +135 -0
- package/dist/daemon-orchestration-SDQNWI3K.js +135 -0
- package/dist/db-backup-5ENHDNZI.js +33 -0
- package/dist/dreaming-PGJOCGAM.js +32 -0
- package/dist/dreaming-UNHHGOU3.js +32 -0
- package/dist/dreaming-ZBKE2GFX.js +32 -0
- package/dist/exe-drift-QQJMUQXA.js +68 -0
- package/dist/exe-export-BEZZSQB4.js +73 -0
- package/dist/exe-export-JNSQRIWI.js +73 -0
- package/dist/exe-export-TQGI2VBT.js +73 -0
- package/dist/exe-import-2SR2UP3D.js +76 -0
- package/dist/exe-import-73Q4VLFK.js +76 -0
- package/dist/exe-import-AVGWQZLU.js +76 -0
- package/dist/exe-key-6JHEINOM.js +579 -0
- package/dist/exe-key-RIRPIFK6.js +579 -0
- package/dist/exe-key-WR6QEHYO.js +579 -0
- package/dist/exe-snapshot-NDMDQJOH.js +164 -0
- package/dist/exe-snapshot-PVCBPMPJ.js +164 -0
- package/dist/exe-snapshot-U6K3J6BD.js +164 -0
- package/dist/fast-db-init-22OBOPTN.js +7 -0
- package/dist/fast-db-init-M6ZYYGAL.js +7 -0
- package/dist/fast-db-init-ZHRRYI7M.js +7 -0
- package/dist/gateway/index.js +8 -8
- package/dist/git-staleness-4DGYC3RY.js +110 -0
- package/dist/git-task-sweep-64KSWRUI.js +40 -0
- package/dist/git-task-sweep-CUR7R2ZM.js +40 -0
- package/dist/git-task-sweep-YG3IVGK3.js +40 -0
- package/dist/global-procedures-TYDNKM7V.js +20 -0
- package/dist/graph-auto-extract-I6B5HWTP.js +162 -0
- package/dist/hooks/bug-report-worker.js +11 -11
- package/dist/hooks/codex-stop-task-finalizer.js +11 -11
- package/dist/hooks/commit-complete.js +11 -11
- package/dist/hooks/error-recall.js +6 -6
- package/dist/hooks/exe-heartbeat-hook.js +3 -3
- package/dist/hooks/ingest.js +6 -6
- package/dist/hooks/instructions-loaded.js +4 -4
- package/dist/hooks/manifest.json +19 -19
- package/dist/hooks/notification.js +4 -4
- package/dist/hooks/post-compact.js +10 -10
- package/dist/hooks/post-tool-combined.js +5 -5
- package/dist/hooks/pre-compact.js +11 -11
- package/dist/hooks/pre-tool-use.js +14 -14
- package/dist/hooks/prompt-submit.js +27 -22
- package/dist/hooks/session-end.js +15 -15
- package/dist/hooks/session-start.js +10 -10
- package/dist/hooks/stop.js +14 -14
- package/dist/hooks/subagent-stop.js +10 -10
- package/dist/hooks/summary-worker.js +14 -14
- package/dist/index.js +17 -17
- package/dist/installer-4LP73C3M.js +38 -0
- package/dist/installer-AUVLNS4D.js +296 -0
- package/dist/installer-KCRLQSQH.js +38 -0
- package/dist/installer-KGXYUOIV.js +296 -0
- package/dist/installer-UI6TNJGO.js +342 -0
- package/dist/installer-Z7NPD4PD.js +342 -0
- package/dist/lib/cloud-sync.js +4 -4
- package/dist/lib/consolidation.js +5 -5
- package/dist/lib/database.js +2 -2
- package/dist/lib/db-daemon-client.js +6 -0
- package/dist/lib/db.js +2 -2
- package/dist/lib/employee-templates.js +4 -4
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon.js +39 -38
- package/dist/lib/hybrid-search.js +5 -5
- package/dist/lib/identity.js +2 -2
- package/dist/lib/messaging.js +9 -9
- 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 +4 -4
- package/dist/lib/store.js +4 -4
- package/dist/lib/task-router.js +3 -3
- package/dist/lib/tasks.js +10 -10
- package/dist/lib/tmux-routing.js +8 -8
- package/dist/lib/token-spend.js +3 -3
- package/dist/mcp/register-tools.js +53 -52
- package/dist/mcp/server.js +54 -53
- 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 +12 -12
- package/dist/mcp/tools/deactivate-behavior.js +5 -5
- package/dist/mcp/tools/list-reminders.js +4 -4
- package/dist/mcp/tools/list-tasks.js +12 -12
- package/dist/mcp/tools/send-message.js +11 -11
- package/dist/mcp/tools/update-task.js +11 -11
- package/dist/mcp-http-config-LN5ITKGS.js +27 -0
- package/dist/mcp-http-config-V43VHNEH.js +27 -0
- package/dist/memory-cards-S36DCEY4.js +174 -0
- package/dist/memory-graph-extractor-66YL4V4B.js +17 -0
- package/dist/memory-poisoning-defense-MXWE6CTY.js +225 -0
- package/dist/memory-reflection-W676LUX5.js +238 -0
- package/dist/notifications-45QSHDFA.js +45 -0
- package/dist/notifications-OFLXZTDZ.js +45 -0
- package/dist/notifications-XAV4V7T5.js +45 -0
- package/dist/orchestration-events-MJLWJ2H2.js +25 -0
- package/dist/orchestrator-7XBMFK7D.js +33 -0
- package/dist/orchestrator-AIAKV5ST.js +33 -0
- package/dist/orchestrator-VK7D6I36.js +33 -0
- package/dist/pipeline-router-DXH5QVUH.js +13 -0
- package/dist/pipeline-router-EV6C5S33.js +13 -0
- package/dist/pipeline-router-MQKRNCTR.js +13 -0
- package/dist/plan-limits-TQMLKZBG.js +26 -0
- package/dist/project-boot-4XTXHDG4.js +299 -0
- package/dist/projection-worker-NAYVNSI4.js +964 -0
- package/dist/reranker-CJW3UYE2.js +19 -0
- package/dist/reranker-KHZI7HQK.js +19 -0
- package/dist/reranker-UPMS3OX7.js +19 -0
- package/dist/reranker-ZN73HWSB.js +19 -0
- package/dist/review-polling-3UEZSPNT.js +124 -0
- package/dist/review-polling-KBDX3ILL.js +124 -0
- package/dist/review-polling-RL75XLAY.js +124 -0
- package/dist/runtime/index.js +11 -11
- package/dist/session-events-2CHOLA6D.js +36 -0
- package/dist/session-events-HM22KEHN.js +36 -0
- package/dist/session-events-ZULAN4XL.js +36 -0
- package/dist/session-kill-telemetry-LUPVYGZX.js +29 -0
- package/dist/session-scope-EPZZZHHJ.js +86 -0
- package/dist/session-scope-V2RSOTDU.js +86 -0
- package/dist/session-scope-ZGE6GHMS.js +86 -0
- package/dist/setup-wizard-KNWH54HW.js +12 -0
- package/dist/skill-refinement-BSX6Q6IN.js +157 -0
- package/dist/skill-refinement-C4GNWV4F.js +157 -0
- package/dist/skill-refinement-CAUIE4YM.js +157 -0
- package/dist/steward-gate-MZ2DV36N.js +13 -0
- package/dist/task-enforcement-6OMXG6EA.js +333 -0
- package/dist/task-enforcement-JFSF6QDD.js +333 -0
- package/dist/task-enforcement-JRTAOYZT.js +333 -0
- package/dist/task-scope-4HJSCJ7L.js +35 -0
- package/dist/task-scope-7HYE4AS6.js +35 -0
- package/dist/task-scope-GNCB2GAM.js +35 -0
- package/dist/tasks-crud-JJL6MMJF.js +77 -0
- package/dist/tasks-crud-KMIPDHBZ.js +77 -0
- package/dist/tasks-crud-MZIOYF3R.js +77 -0
- package/dist/tasks-notify-5D6LF52K.js +38 -0
- package/dist/tasks-notify-7KNZ4ULO.js +38 -0
- package/dist/tasks-notify-JNGGXFUY.js +38 -0
- package/dist/tasks-review-N6I5UC7G.js +47 -0
- package/dist/tasks-review-U5VEV4Y7.js +47 -0
- package/dist/tasks-review-USHAMO5N.js +47 -0
- package/dist/telemetry-upload-BIB5TJA4.js +739 -0
- package/dist/telemetry-upload-BV2M2NND.js +739 -0
- package/dist/telemetry-upload-Y7QPDJW4.js +739 -0
- package/dist/token-budget-2LUZOFO7.js +84 -0
- package/dist/tool-telemetry-5JT6DPVK.js +17 -0
- package/dist/tui/App.js +16 -16
- package/dist/tui-data-DMAKZMGD.js +258 -0
- package/dist/tui-data-X7NI6ZQ3.js +258 -0
- package/dist/tui-data-ZSB5DDEY.js +258 -0
- package/dist/wiki-acl-QHGGWX63.js +111 -0
- package/dist/worker-gate-4XKUOFWO.js +21 -0
- package/dist/worker-gate-TPZBOXOA.js +21 -0
- package/dist/worker-gate-TXLX33PX.js +21 -0
- package/dist/workflow-engine-3PIT3Y56.js +28 -0
- package/dist/workflow-engine-F3URLOPA.js +28 -0
- package/dist/workflow-engine-OFOL446Z.js +28 -0
- package/dist/worktree-V3NVP7MV.js +26 -0
- package/dist/worktree-sweep-2CADL43Y.js +19 -0
- package/package.json +1 -1
- package/release-notes.json +27 -25
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXE_AI_DIR
|
|
3
|
+
} from "./chunk-VXIMSRTO.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/worker-gate.ts
|
|
6
|
+
import { readdirSync, writeFileSync, unlinkSync, mkdirSync, existsSync, readFileSync } from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
var WORKER_PID_DIR = path.join(EXE_AI_DIR, "worker-pids");
|
|
9
|
+
var MAX_CONCURRENT_WORKERS = 3;
|
|
10
|
+
function tryAcquireWorkerSlot() {
|
|
11
|
+
try {
|
|
12
|
+
mkdirSync(WORKER_PID_DIR, { recursive: true });
|
|
13
|
+
const reservationId = `res-${process.pid}-${Date.now()}`;
|
|
14
|
+
const reservationPath = path.join(WORKER_PID_DIR, `${reservationId}.pid`);
|
|
15
|
+
writeFileSync(reservationPath, String(process.pid));
|
|
16
|
+
const files = readdirSync(WORKER_PID_DIR);
|
|
17
|
+
let alive = 0;
|
|
18
|
+
for (const f of files) {
|
|
19
|
+
if (!f.endsWith(".pid")) continue;
|
|
20
|
+
if (f.startsWith("res-")) {
|
|
21
|
+
const resParts = f.replace(".pid", "").split("-");
|
|
22
|
+
const resPid = parseInt(resParts[1] ?? "", 10);
|
|
23
|
+
if (!isNaN(resPid) && resPid > 0) {
|
|
24
|
+
try {
|
|
25
|
+
process.kill(resPid, 0);
|
|
26
|
+
alive++;
|
|
27
|
+
} catch {
|
|
28
|
+
try {
|
|
29
|
+
unlinkSync(path.join(WORKER_PID_DIR, f));
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
alive++;
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const dashIdx = f.lastIndexOf("-");
|
|
39
|
+
const pid = parseInt(f.slice(dashIdx + 1).replace(".pid", ""), 10);
|
|
40
|
+
if (isNaN(pid)) continue;
|
|
41
|
+
try {
|
|
42
|
+
process.kill(pid, 0);
|
|
43
|
+
alive++;
|
|
44
|
+
} catch {
|
|
45
|
+
try {
|
|
46
|
+
unlinkSync(path.join(WORKER_PID_DIR, f));
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (alive >= MAX_CONCURRENT_WORKERS) {
|
|
52
|
+
try {
|
|
53
|
+
unlinkSync(reservationPath);
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
unlinkSync(reservationPath);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
} catch {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function registerWorkerPid(pid) {
|
|
68
|
+
try {
|
|
69
|
+
mkdirSync(WORKER_PID_DIR, { recursive: true });
|
|
70
|
+
writeFileSync(path.join(WORKER_PID_DIR, `worker-${pid}.pid`), String(pid));
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function cleanupWorkerPid() {
|
|
75
|
+
try {
|
|
76
|
+
unlinkSync(path.join(WORKER_PID_DIR, `worker-${process.pid}.pid`));
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
var BACKFILL_LOCK = path.join(WORKER_PID_DIR, "backfill.lock");
|
|
81
|
+
function tryAcquireBackfillLock() {
|
|
82
|
+
try {
|
|
83
|
+
mkdirSync(WORKER_PID_DIR, { recursive: true });
|
|
84
|
+
if (existsSync(BACKFILL_LOCK)) {
|
|
85
|
+
try {
|
|
86
|
+
const pid = parseInt(
|
|
87
|
+
readFileSync(BACKFILL_LOCK, "utf8").trim(),
|
|
88
|
+
10
|
|
89
|
+
);
|
|
90
|
+
if (!isNaN(pid) && pid > 0) {
|
|
91
|
+
try {
|
|
92
|
+
process.kill(pid, 0);
|
|
93
|
+
return false;
|
|
94
|
+
} catch {
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
writeFileSync(BACKFILL_LOCK, String(process.pid));
|
|
101
|
+
return true;
|
|
102
|
+
} catch {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function releaseBackfillLock() {
|
|
107
|
+
try {
|
|
108
|
+
unlinkSync(BACKFILL_LOCK);
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function getTaskAwareCapacity() {
|
|
113
|
+
const { getClient } = await import("./lib/database.js");
|
|
114
|
+
const { sessionScopeFilter } = await import("./task-scope-4HJSCJ7L.js");
|
|
115
|
+
const client = getClient();
|
|
116
|
+
const scope = sessionScopeFilter();
|
|
117
|
+
const result = await client.execute({
|
|
118
|
+
sql: `SELECT assigned_to, COUNT(*) as cnt
|
|
119
|
+
FROM tasks
|
|
120
|
+
WHERE status IN ('open', 'in_progress')${scope.sql}
|
|
121
|
+
GROUP BY assigned_to`,
|
|
122
|
+
args: [...scope.args]
|
|
123
|
+
});
|
|
124
|
+
const busyAgents = [];
|
|
125
|
+
let totalInProgress = 0;
|
|
126
|
+
for (const row of result.rows) {
|
|
127
|
+
const agent = String(row.assigned_to ?? "");
|
|
128
|
+
const count = Number(row.cnt ?? 0);
|
|
129
|
+
if (agent && count > 0) {
|
|
130
|
+
busyAgents.push(agent);
|
|
131
|
+
totalInProgress += count;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const idleAgents = [];
|
|
135
|
+
try {
|
|
136
|
+
const { listTmuxSessions } = await import("./lib/tmux-status.js");
|
|
137
|
+
const { isExeSession } = await import("./lib/tmux-routing.js");
|
|
138
|
+
const { baseAgentName } = await import("./lib/employees.js");
|
|
139
|
+
const liveSessions = listTmuxSessions().filter((s) => !isExeSession(s) && s.includes("-"));
|
|
140
|
+
const liveAgentNames = new Set(liveSessions.map((s) => baseAgentName(s.split("-")[0] ?? "")));
|
|
141
|
+
for (const name of liveAgentNames) {
|
|
142
|
+
if (name && !busyAgents.includes(name)) {
|
|
143
|
+
idleAgents.push(name);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch {
|
|
147
|
+
}
|
|
148
|
+
return { busyAgents, idleAgents, totalInProgress };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
MAX_CONCURRENT_WORKERS,
|
|
153
|
+
tryAcquireWorkerSlot,
|
|
154
|
+
registerWorkerPid,
|
|
155
|
+
cleanupWorkerPid,
|
|
156
|
+
tryAcquireBackfillLock,
|
|
157
|
+
releaseBackfillLock,
|
|
158
|
+
getTaskAwareCapacity
|
|
159
|
+
};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import {
|
|
2
|
+
storeBehavior
|
|
3
|
+
} from "./chunk-32QR5EHE.js";
|
|
4
|
+
import {
|
|
5
|
+
getClient
|
|
6
|
+
} from "./chunk-RHZ2CRJU.js";
|
|
7
|
+
import {
|
|
8
|
+
loadConfig
|
|
9
|
+
} from "./chunk-VXIMSRTO.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/skill-learning.ts
|
|
12
|
+
import crypto from "crypto";
|
|
13
|
+
var DEFAULT_SKILL_THRESHOLD = 3;
|
|
14
|
+
async function extractTrajectory(taskId, agentId) {
|
|
15
|
+
const client = getClient();
|
|
16
|
+
const result = await client.execute({
|
|
17
|
+
sql: `SELECT tool_name, raw_text
|
|
18
|
+
FROM memories
|
|
19
|
+
WHERE task_id = ? AND agent_id = ?
|
|
20
|
+
ORDER BY timestamp ASC`,
|
|
21
|
+
args: [taskId, agentId]
|
|
22
|
+
});
|
|
23
|
+
if (result.rows.length === 0) return [];
|
|
24
|
+
const rawTools = result.rows.map((r) => {
|
|
25
|
+
const toolName = String(r.tool_name);
|
|
26
|
+
if (toolName === "Bash") {
|
|
27
|
+
const text = String(r.raw_text);
|
|
28
|
+
const cmdMatch = text.match(/(?:command|Command).*?[:\s]+"?(\w+)/);
|
|
29
|
+
return cmdMatch ? `Bash:${cmdMatch[1]}` : "Bash";
|
|
30
|
+
}
|
|
31
|
+
return toolName;
|
|
32
|
+
});
|
|
33
|
+
const signature = [];
|
|
34
|
+
for (const tool of rawTools) {
|
|
35
|
+
if (signature.length === 0 || signature[signature.length - 1] !== tool) {
|
|
36
|
+
signature.push(tool);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return signature;
|
|
40
|
+
}
|
|
41
|
+
function hashSignature(signature) {
|
|
42
|
+
return crypto.createHash("sha256").update(signature.join("|")).digest("hex").slice(0, 16);
|
|
43
|
+
}
|
|
44
|
+
async function storeTrajectory(opts) {
|
|
45
|
+
const client = getClient();
|
|
46
|
+
const id = crypto.randomUUID();
|
|
47
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
48
|
+
const signatureHash = hashSignature(opts.signature);
|
|
49
|
+
await client.execute({
|
|
50
|
+
sql: `INSERT INTO trajectories (id, task_id, agent_id, project_name, task_title, signature, signature_hash, tool_count, created_at)
|
|
51
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
52
|
+
args: [
|
|
53
|
+
id,
|
|
54
|
+
opts.taskId,
|
|
55
|
+
opts.agentId,
|
|
56
|
+
opts.projectName,
|
|
57
|
+
opts.taskTitle,
|
|
58
|
+
JSON.stringify(opts.signature),
|
|
59
|
+
signatureHash,
|
|
60
|
+
opts.signature.length,
|
|
61
|
+
now
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
return id;
|
|
65
|
+
}
|
|
66
|
+
async function findSimilarTrajectories(signature, threshold = DEFAULT_SKILL_THRESHOLD) {
|
|
67
|
+
const client = getClient();
|
|
68
|
+
const hash = hashSignature(signature);
|
|
69
|
+
const result = await client.execute({
|
|
70
|
+
sql: `SELECT id, task_id, agent_id, project_name, task_title, signature, signature_hash, tool_count, skill_id, created_at
|
|
71
|
+
FROM trajectories
|
|
72
|
+
WHERE signature_hash = ?
|
|
73
|
+
ORDER BY created_at DESC
|
|
74
|
+
LIMIT 20`,
|
|
75
|
+
args: [hash]
|
|
76
|
+
});
|
|
77
|
+
const mapRow = (r) => ({
|
|
78
|
+
id: String(r.id),
|
|
79
|
+
taskId: String(r.task_id),
|
|
80
|
+
agentId: String(r.agent_id),
|
|
81
|
+
projectName: String(r.project_name),
|
|
82
|
+
taskTitle: String(r.task_title),
|
|
83
|
+
signature: JSON.parse(String(r.signature)),
|
|
84
|
+
signatureHash: String(r.signature_hash),
|
|
85
|
+
toolCount: Number(r.tool_count),
|
|
86
|
+
skillId: r.skill_id ? String(r.skill_id) : null,
|
|
87
|
+
createdAt: String(r.created_at)
|
|
88
|
+
});
|
|
89
|
+
const matches = result.rows.map(mapRow);
|
|
90
|
+
if (matches.length >= threshold) return matches;
|
|
91
|
+
const nearResult = await client.execute({
|
|
92
|
+
sql: `SELECT id, task_id, agent_id, project_name, task_title, signature, signature_hash, tool_count, skill_id, created_at
|
|
93
|
+
FROM trajectories
|
|
94
|
+
WHERE tool_count BETWEEN ? AND ?
|
|
95
|
+
AND signature_hash != ?
|
|
96
|
+
ORDER BY created_at DESC
|
|
97
|
+
LIMIT 50`,
|
|
98
|
+
args: [
|
|
99
|
+
Math.max(1, signature.length - 3),
|
|
100
|
+
signature.length + 3,
|
|
101
|
+
hash
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
for (const r of nearResult.rows) {
|
|
105
|
+
const candidateSig = JSON.parse(String(r.signature));
|
|
106
|
+
if (editDistance(signature, candidateSig) <= 2) {
|
|
107
|
+
matches.push(mapRow(r));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return matches;
|
|
111
|
+
}
|
|
112
|
+
async function captureTrajectory(opts) {
|
|
113
|
+
const signature = await extractTrajectory(opts.taskId, opts.agentId);
|
|
114
|
+
if (signature.length < 3) {
|
|
115
|
+
return { trajectoryId: "", similarCount: 0, similar: [] };
|
|
116
|
+
}
|
|
117
|
+
const trajectoryId = await storeTrajectory({
|
|
118
|
+
taskId: opts.taskId,
|
|
119
|
+
agentId: opts.agentId,
|
|
120
|
+
projectName: opts.projectName,
|
|
121
|
+
taskTitle: opts.taskTitle,
|
|
122
|
+
signature
|
|
123
|
+
});
|
|
124
|
+
const similar = await findSimilarTrajectories(
|
|
125
|
+
signature,
|
|
126
|
+
opts.skillThreshold ?? DEFAULT_SKILL_THRESHOLD
|
|
127
|
+
);
|
|
128
|
+
return { trajectoryId, similarCount: similar.length, similar };
|
|
129
|
+
}
|
|
130
|
+
function buildExtractionPrompt(trajectories) {
|
|
131
|
+
const items = trajectories.map((t, i) => {
|
|
132
|
+
const sig = t.signature.join(" \u2192 ");
|
|
133
|
+
return `Task ${i + 1}: "${t.taskTitle}" (${t.agentId}, ${t.projectName}) \u2014 ${t.toolCount} tool calls
|
|
134
|
+
Signature: ${sig}`;
|
|
135
|
+
}).join("\n\n");
|
|
136
|
+
return `You are analyzing ${trajectories.length} completed tasks that followed similar procedures:
|
|
137
|
+
|
|
138
|
+
${items}
|
|
139
|
+
|
|
140
|
+
Extract the reusable procedure. Format your response EXACTLY like this:
|
|
141
|
+
|
|
142
|
+
SKILL: {name \u2014 short, descriptive}
|
|
143
|
+
TRIGGER: {when to use this \u2014 one sentence}
|
|
144
|
+
STEPS:
|
|
145
|
+
1. ...
|
|
146
|
+
2. ...
|
|
147
|
+
PITFALLS: {common mistakes to avoid}
|
|
148
|
+
|
|
149
|
+
Be specific and actionable. Include tool names, file patterns, and concrete commands where applicable.`;
|
|
150
|
+
}
|
|
151
|
+
async function extractSkill(trajectories, model) {
|
|
152
|
+
if (trajectories.length === 0) return null;
|
|
153
|
+
const config = await loadConfig();
|
|
154
|
+
const skillModel = model ?? config.skillModel;
|
|
155
|
+
const Anthropic = (await import("@anthropic-ai/sdk")).default;
|
|
156
|
+
const client = new Anthropic();
|
|
157
|
+
const prompt = buildExtractionPrompt(trajectories);
|
|
158
|
+
const response = await client.messages.create({
|
|
159
|
+
model: skillModel,
|
|
160
|
+
max_tokens: 500,
|
|
161
|
+
messages: [{ role: "user", content: prompt }]
|
|
162
|
+
});
|
|
163
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
164
|
+
const skillText = textBlock?.text;
|
|
165
|
+
if (!skillText) return null;
|
|
166
|
+
const agentId = trajectories[0].agentId;
|
|
167
|
+
const projectName = trajectories[0].projectName;
|
|
168
|
+
const skillId = await storeBehavior({
|
|
169
|
+
agentId,
|
|
170
|
+
content: skillText,
|
|
171
|
+
domain: "skill",
|
|
172
|
+
projectName
|
|
173
|
+
});
|
|
174
|
+
const dbClient = getClient();
|
|
175
|
+
for (const t of trajectories) {
|
|
176
|
+
await dbClient.execute({
|
|
177
|
+
sql: "UPDATE trajectories SET skill_id = ? WHERE id = ?",
|
|
178
|
+
args: [skillId, t.id]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
process.stderr.write(
|
|
182
|
+
`[skill-learning] Skill extracted from ${trajectories.length} trajectories \u2192 behavior ${skillId}
|
|
183
|
+
`
|
|
184
|
+
);
|
|
185
|
+
return skillId;
|
|
186
|
+
}
|
|
187
|
+
async function captureAndLearn(opts) {
|
|
188
|
+
try {
|
|
189
|
+
const config = await loadConfig();
|
|
190
|
+
if (!config.skillLearning) return;
|
|
191
|
+
const { trajectoryId, similarCount, similar } = await captureTrajectory({
|
|
192
|
+
...opts,
|
|
193
|
+
skillThreshold: config.skillThreshold
|
|
194
|
+
});
|
|
195
|
+
if (!trajectoryId) return;
|
|
196
|
+
if (similarCount >= config.skillThreshold) {
|
|
197
|
+
const unprocessed = similar.filter((t) => !t.skillId);
|
|
198
|
+
if (unprocessed.length >= config.skillThreshold) {
|
|
199
|
+
extractSkill(unprocessed, config.skillModel).catch((err) => {
|
|
200
|
+
process.stderr.write(
|
|
201
|
+
`[skill-learning] Extraction failed: ${err instanceof Error ? err.message : String(err)}
|
|
202
|
+
`
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} catch (err) {
|
|
208
|
+
process.stderr.write(
|
|
209
|
+
`[skill-learning] captureAndLearn failed: ${err instanceof Error ? err.message : String(err)}
|
|
210
|
+
`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async function sweepTrajectories(threshold, model) {
|
|
215
|
+
const config = await loadConfig();
|
|
216
|
+
if (!config.skillLearning) return { clustersProcessed: 0, skillsExtracted: 0 };
|
|
217
|
+
const t = threshold ?? config.skillThreshold;
|
|
218
|
+
const client = getClient();
|
|
219
|
+
const result = await client.execute({
|
|
220
|
+
sql: `SELECT signature_hash, COUNT(*) as cnt
|
|
221
|
+
FROM trajectories
|
|
222
|
+
WHERE skill_id IS NULL
|
|
223
|
+
GROUP BY signature_hash
|
|
224
|
+
HAVING cnt >= ?
|
|
225
|
+
ORDER BY cnt DESC
|
|
226
|
+
LIMIT 10`,
|
|
227
|
+
args: [t]
|
|
228
|
+
});
|
|
229
|
+
let clustersProcessed = 0;
|
|
230
|
+
let skillsExtracted = 0;
|
|
231
|
+
for (const row of result.rows) {
|
|
232
|
+
const hash = String(row.signature_hash);
|
|
233
|
+
const trajResult = await client.execute({
|
|
234
|
+
sql: `SELECT id, task_id, agent_id, project_name, task_title, signature, signature_hash, tool_count, created_at
|
|
235
|
+
FROM trajectories
|
|
236
|
+
WHERE signature_hash = ? AND skill_id IS NULL
|
|
237
|
+
ORDER BY created_at DESC
|
|
238
|
+
LIMIT 10`,
|
|
239
|
+
args: [hash]
|
|
240
|
+
});
|
|
241
|
+
const trajectories = trajResult.rows.map((r) => ({
|
|
242
|
+
id: String(r.id),
|
|
243
|
+
taskId: String(r.task_id),
|
|
244
|
+
agentId: String(r.agent_id),
|
|
245
|
+
projectName: String(r.project_name),
|
|
246
|
+
taskTitle: String(r.task_title),
|
|
247
|
+
signature: JSON.parse(String(r.signature)),
|
|
248
|
+
signatureHash: String(r.signature_hash),
|
|
249
|
+
toolCount: Number(r.tool_count),
|
|
250
|
+
skillId: null,
|
|
251
|
+
createdAt: String(r.created_at)
|
|
252
|
+
}));
|
|
253
|
+
if (trajectories.length >= t) {
|
|
254
|
+
clustersProcessed++;
|
|
255
|
+
const skillId = await extractSkill(trajectories, model ?? config.skillModel);
|
|
256
|
+
if (skillId) skillsExtracted++;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return { clustersProcessed, skillsExtracted };
|
|
260
|
+
}
|
|
261
|
+
function editDistance(a, b) {
|
|
262
|
+
const m = a.length;
|
|
263
|
+
const n = b.length;
|
|
264
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
265
|
+
for (let i = 0; i <= m; i++) dp[i][0] = i;
|
|
266
|
+
for (let j = 0; j <= n; j++) dp[0][j] = j;
|
|
267
|
+
for (let i = 1; i <= m; i++) {
|
|
268
|
+
for (let j = 1; j <= n; j++) {
|
|
269
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
270
|
+
dp[i][j] = Math.min(
|
|
271
|
+
dp[i - 1][j] + 1,
|
|
272
|
+
dp[i][j - 1] + 1,
|
|
273
|
+
dp[i - 1][j - 1] + cost
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return dp[m][n];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export {
|
|
281
|
+
extractTrajectory,
|
|
282
|
+
hashSignature,
|
|
283
|
+
storeTrajectory,
|
|
284
|
+
findSimilarTrajectories,
|
|
285
|
+
captureTrajectory,
|
|
286
|
+
extractSkill,
|
|
287
|
+
captureAndLearn,
|
|
288
|
+
sweepTrajectories,
|
|
289
|
+
editDistance
|
|
290
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sendMessage
|
|
3
|
+
} from "./chunk-Q3N4KHLM.js";
|
|
4
|
+
import {
|
|
5
|
+
getActiveAgent
|
|
6
|
+
} from "./chunk-YG7PIB2R.js";
|
|
7
|
+
|
|
8
|
+
// src/mcp/tools/send-message.ts
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
function registerSendMessage(server) {
|
|
11
|
+
server.registerTool(
|
|
12
|
+
"send_message",
|
|
13
|
+
{
|
|
14
|
+
title: "Send Message",
|
|
15
|
+
description: "Send a structured message to another agent. Messages are queued and delivered via intercom. NOTE: messages are fire-and-forget \u2014 do NOT use for actionable work dispatch. Use create_task instead to assign work to employees.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
target_agent: z.string().describe("Recipient agent name"),
|
|
18
|
+
content: z.string().describe("Message content"),
|
|
19
|
+
target_project: z.string().optional().describe("Project context (optional)"),
|
|
20
|
+
priority: z.enum(["normal", "urgent"]).default("normal").describe("Message priority (default: normal)"),
|
|
21
|
+
target_device: z.string().optional().describe("Target device ID for cross-machine delivery (default: local)")
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
async ({ target_agent, content, target_project, priority, target_device }) => {
|
|
25
|
+
const { agentId } = getActiveAgent();
|
|
26
|
+
const msg = await sendMessage({
|
|
27
|
+
fromAgent: agentId,
|
|
28
|
+
targetAgent: target_agent,
|
|
29
|
+
targetProject: target_project,
|
|
30
|
+
targetDevice: target_device,
|
|
31
|
+
content,
|
|
32
|
+
priority
|
|
33
|
+
});
|
|
34
|
+
const statusText = msg.status === "delivered" ? "delivered" : msg.status === "failed" ? `failed: ${msg.failureReason}` : "queued (pending delivery)";
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{
|
|
38
|
+
type: "text",
|
|
39
|
+
text: `Message sent to ${target_agent}: ${statusText}
|
|
40
|
+
ID: ${msg.id}`
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
registerSendMessage
|
|
50
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
redactSecrets
|
|
3
|
+
} from "./chunk-Y25OJWOQ.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/memory-write-governor.ts
|
|
6
|
+
import { createHash } from "crypto";
|
|
7
|
+
var HIGH_VALUE_SUPERSESSION_TYPES = /* @__PURE__ */ new Set([
|
|
8
|
+
"decision",
|
|
9
|
+
"adr",
|
|
10
|
+
"behavior",
|
|
11
|
+
"procedure"
|
|
12
|
+
]);
|
|
13
|
+
var NOISE_DROP_PATTERNS = [
|
|
14
|
+
/^\s*\[📋\s+\d+\s+reviews?\s+pending\b/im,
|
|
15
|
+
/^\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*$/im,
|
|
16
|
+
/^\s*The UserPromptSubmit hook checks the DB for new tasks/im,
|
|
17
|
+
/^\s*Intercom is a speedup, not delivery/im,
|
|
18
|
+
/^\s*Context bar reads as USAGE not remaining/im,
|
|
19
|
+
// Intercom noise — these repeat on every prompt and cause 18K+ duplicates
|
|
20
|
+
/^\/exe-intercom\b/i,
|
|
21
|
+
/^You have pending notifications\.\s*Run list_tasks/i,
|
|
22
|
+
/^You have open tasks\.\s*Run list_tasks/i,
|
|
23
|
+
/^You have a new P\d+ task/i,
|
|
24
|
+
/^You have more open tasks to dispatch/i,
|
|
25
|
+
/^No new tasks\.\s*(Standing by|Idle|Dashboard)/i
|
|
26
|
+
];
|
|
27
|
+
var SKIP_EMBED_PATTERNS = [
|
|
28
|
+
/tmux capture-pane\b/i,
|
|
29
|
+
/docker ps\b/i,
|
|
30
|
+
/docker images\b/i,
|
|
31
|
+
/git status\b/i,
|
|
32
|
+
/grep .*node_modules/i,
|
|
33
|
+
/npm (install|ci)\b[\s\S]*(added \d+ packages|audited \d+ packages)/i
|
|
34
|
+
];
|
|
35
|
+
function normalizeMemoryText(text) {
|
|
36
|
+
return text.replace(/\r\n/g, "\n").replace(/[ \t]+$/gm, "").replace(/\n{4,}/g, "\n\n\n").trim();
|
|
37
|
+
}
|
|
38
|
+
function classifyMemoryType(input) {
|
|
39
|
+
if (input.memory_type && input.memory_type.trim()) return input.memory_type.trim();
|
|
40
|
+
const tool = input.tool_name.toLowerCase();
|
|
41
|
+
const text = input.raw_text.toLowerCase();
|
|
42
|
+
if (tool.includes("store_decision") || tool.includes("decision")) return "decision";
|
|
43
|
+
if (tool.includes("commit") || text.includes("adr-") || text.includes("architectural decision")) return "adr";
|
|
44
|
+
if (tool.includes("store_behavior") || tool.includes("behavior")) return "behavior";
|
|
45
|
+
if (tool.includes("global_procedure") || text.includes("organization-wide procedures")) return "procedure";
|
|
46
|
+
if (tool.includes("checkpoint") || text.startsWith("context checkpoint")) return "checkpoint";
|
|
47
|
+
if (tool.includes("sessionsummary") || tool.includes("session-summary")) return "summary";
|
|
48
|
+
if (tool.includes("sessionend") || text.startsWith("session ended")) return "summary";
|
|
49
|
+
if (tool.includes("send_whatsapp") || tool.includes("conversation")) return "conversation";
|
|
50
|
+
if (tool === "store_memory" || tool === "manual") return "observation";
|
|
51
|
+
if (tool === "userprompt" || tool === "slashcommand") return "conversation";
|
|
52
|
+
return "raw";
|
|
53
|
+
}
|
|
54
|
+
function shouldDropMemory(text) {
|
|
55
|
+
const normalized = normalizeMemoryText(text);
|
|
56
|
+
if (normalized.length < 10) return { drop: true, reason: "too_short" };
|
|
57
|
+
if (NOISE_DROP_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
|
58
|
+
return { drop: true, reason: "known_boilerplate_noise" };
|
|
59
|
+
}
|
|
60
|
+
return { drop: false };
|
|
61
|
+
}
|
|
62
|
+
function shouldSkipEmbedding(input) {
|
|
63
|
+
const type = classifyMemoryType(input);
|
|
64
|
+
if (HIGH_VALUE_SUPERSESSION_TYPES.has(type)) return false;
|
|
65
|
+
if (type === "raw" && input.raw_text.length > 2e4) return true;
|
|
66
|
+
if (SKIP_EMBED_PATTERNS.some((pattern) => pattern.test(input.raw_text))) return true;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
function hashMemoryContent(text) {
|
|
70
|
+
return createHash("sha256").update(normalizeMemoryText(text)).digest("hex");
|
|
71
|
+
}
|
|
72
|
+
function scopedDedupArgs(input) {
|
|
73
|
+
return [input.contentHash, input.agentId, input.projectName, input.memoryType];
|
|
74
|
+
}
|
|
75
|
+
function governMemoryRecord(record) {
|
|
76
|
+
const redacted = redactSecrets(record.raw_text);
|
|
77
|
+
const normalized = normalizeMemoryText(redacted.text);
|
|
78
|
+
const memoryType = classifyMemoryType({
|
|
79
|
+
raw_text: normalized,
|
|
80
|
+
agent_id: record.agent_id,
|
|
81
|
+
project_name: record.project_name,
|
|
82
|
+
tool_name: record.tool_name,
|
|
83
|
+
memory_type: record.memory_type
|
|
84
|
+
});
|
|
85
|
+
const drop = shouldDropMemory(normalized);
|
|
86
|
+
const skipEmbedding = shouldSkipEmbedding({
|
|
87
|
+
raw_text: normalized,
|
|
88
|
+
agent_id: record.agent_id,
|
|
89
|
+
project_name: record.project_name,
|
|
90
|
+
tool_name: record.tool_name,
|
|
91
|
+
memory_type: memoryType
|
|
92
|
+
});
|
|
93
|
+
const trajectoryValue = record.trajectory;
|
|
94
|
+
const redactedTrajectory = typeof trajectoryValue === "string" ? redactSecrets(trajectoryValue).text : record.trajectory;
|
|
95
|
+
return {
|
|
96
|
+
record: {
|
|
97
|
+
...record,
|
|
98
|
+
raw_text: normalized,
|
|
99
|
+
memory_type: memoryType,
|
|
100
|
+
vector: skipEmbedding ? null : record.vector,
|
|
101
|
+
keywords: record.keywords ? redactSecrets(record.keywords).text : record.keywords,
|
|
102
|
+
trajectory: redactedTrajectory
|
|
103
|
+
},
|
|
104
|
+
contentHash: hashMemoryContent(normalized),
|
|
105
|
+
shouldDrop: drop.drop,
|
|
106
|
+
dropReason: drop.reason,
|
|
107
|
+
skipEmbedding,
|
|
108
|
+
hygiene: {
|
|
109
|
+
dedup: true,
|
|
110
|
+
supersession: HIGH_VALUE_SUPERSESSION_TYPES.has(memoryType)
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function findScopedDuplicate(input) {
|
|
115
|
+
const { getClient } = await import("./lib/database.js");
|
|
116
|
+
const client = getClient();
|
|
117
|
+
const args = scopedDedupArgs(input);
|
|
118
|
+
let sql = `SELECT id FROM memories
|
|
119
|
+
WHERE content_hash = ?
|
|
120
|
+
AND agent_id = ?
|
|
121
|
+
AND project_name = ?
|
|
122
|
+
AND COALESCE(memory_type, 'raw') = ?
|
|
123
|
+
AND COALESCE(status, 'active') != 'deleted'`;
|
|
124
|
+
if (input.excludeId) {
|
|
125
|
+
sql += " AND id != ?";
|
|
126
|
+
args.push(input.excludeId);
|
|
127
|
+
}
|
|
128
|
+
sql += " ORDER BY timestamp DESC LIMIT 1";
|
|
129
|
+
const result = await client.execute({ sql, args });
|
|
130
|
+
return result.rows[0]?.id ? String(result.rows[0].id) : null;
|
|
131
|
+
}
|
|
132
|
+
async function runPostWriteMemoryHygiene(memoryId) {
|
|
133
|
+
try {
|
|
134
|
+
const { getClient } = await import("./lib/database.js");
|
|
135
|
+
const client = getClient();
|
|
136
|
+
const current = await client.execute({
|
|
137
|
+
sql: `SELECT id, agent_id, project_name, memory_type, content_hash, supersedes_id,
|
|
138
|
+
importance, timestamp
|
|
139
|
+
FROM memories
|
|
140
|
+
WHERE id = ?
|
|
141
|
+
LIMIT 1`,
|
|
142
|
+
args: [memoryId]
|
|
143
|
+
});
|
|
144
|
+
const row = current.rows[0];
|
|
145
|
+
if (!row) return;
|
|
146
|
+
const memoryType = String(row.memory_type ?? "raw");
|
|
147
|
+
const contentHash = row.content_hash ? String(row.content_hash) : null;
|
|
148
|
+
const agentId = String(row.agent_id);
|
|
149
|
+
const projectName = String(row.project_name);
|
|
150
|
+
if (contentHash) {
|
|
151
|
+
await client.execute({
|
|
152
|
+
sql: `UPDATE memories
|
|
153
|
+
SET status = 'deleted',
|
|
154
|
+
outcome = COALESCE(outcome, 'superseded')
|
|
155
|
+
WHERE id != ?
|
|
156
|
+
AND content_hash = ?
|
|
157
|
+
AND agent_id = ?
|
|
158
|
+
AND project_name = ?
|
|
159
|
+
AND COALESCE(memory_type, 'raw') = ?
|
|
160
|
+
AND COALESCE(status, 'active') = 'active'`,
|
|
161
|
+
args: [memoryId, contentHash, agentId, projectName, memoryType]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const supersedesId = row.supersedes_id ? String(row.supersedes_id) : null;
|
|
165
|
+
if (supersedesId && HIGH_VALUE_SUPERSESSION_TYPES.has(memoryType)) {
|
|
166
|
+
const old = await client.execute({
|
|
167
|
+
sql: `SELECT importance FROM memories WHERE id = ? LIMIT 1`,
|
|
168
|
+
args: [supersedesId]
|
|
169
|
+
});
|
|
170
|
+
const oldImportance = Number(old.rows[0]?.importance ?? 0);
|
|
171
|
+
const newImportance = Number(row.importance ?? 0);
|
|
172
|
+
await client.batch([
|
|
173
|
+
{
|
|
174
|
+
sql: `UPDATE memories
|
|
175
|
+
SET status = 'archived',
|
|
176
|
+
outcome = COALESCE(outcome, 'superseded')
|
|
177
|
+
WHERE id = ?`,
|
|
178
|
+
args: [supersedesId]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
sql: `UPDATE memories
|
|
182
|
+
SET importance = MAX(COALESCE(importance, 5), ?),
|
|
183
|
+
parent_memory_id = COALESCE(parent_memory_id, ?)
|
|
184
|
+
WHERE id = ?`,
|
|
185
|
+
args: [Math.max(oldImportance, newImportance), supersedesId, memoryId]
|
|
186
|
+
}
|
|
187
|
+
], "write");
|
|
188
|
+
}
|
|
189
|
+
} catch (err) {
|
|
190
|
+
process.stderr.write(
|
|
191
|
+
`[memory-governor] post-write hygiene failed for ${memoryId}: ${err instanceof Error ? err.message : String(err)}
|
|
192
|
+
`
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function schedulePostWriteMemoryHygiene(memoryIds) {
|
|
197
|
+
if (process.env.EXE_SKIP_MEMORY_HYGIENE === "1") return;
|
|
198
|
+
if (memoryIds.length === 0) return;
|
|
199
|
+
const run = () => {
|
|
200
|
+
void Promise.all(memoryIds.map((id) => runPostWriteMemoryHygiene(id)));
|
|
201
|
+
};
|
|
202
|
+
if (typeof setImmediate === "function") setImmediate(run);
|
|
203
|
+
else setTimeout(run, 0);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
governMemoryRecord,
|
|
208
|
+
findScopedDuplicate,
|
|
209
|
+
schedulePostWriteMemoryHygiene
|
|
210
|
+
};
|