@askexenow/exe-os 0.9.271 → 0.9.272
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/active-agent-BDYXURXQ.js +26 -0
- package/dist/active-agent-YWBGAKGU.js +25 -0
- package/dist/agentic-ontology-56VHSVS3.js +25 -0
- package/dist/backfill-metadata-G46ABBVR.js +597 -0
- package/dist/backfill-metadata-VAV27KJK.js +597 -0
- package/dist/behaviors-USUTDXVA.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 +4 -4
- package/dist/bin/cleanup-stale-review-tasks.js +10 -10
- package/dist/bin/cli.js +16 -16
- package/dist/bin/exe-agent-config.js +3 -3
- package/dist/bin/exe-agent.js +4 -4
- package/dist/bin/exe-assign.js +5 -5
- package/dist/bin/exe-boot.js +17 -17
- package/dist/bin/exe-call.js +4 -4
- package/dist/bin/exe-cloud.js +4 -4
- package/dist/bin/exe-dispatch.js +10 -10
- 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 +4 -4
- package/dist/bin/exe-heartbeat.js +10 -10
- package/dist/bin/exe-kill.js +13 -13
- package/dist/bin/exe-launch-agent.js +37 -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 +5 -5
- 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 +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 +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/scan-tasks.js +10 -10
- package/dist/bin/setup.js +1 -1
- package/dist/bin/shard-migrate.js +4 -4
- package/dist/capacity-monitor-IFVRCIM7.js +49 -0
- package/dist/capacity-monitor-Q47GBDSY.js +49 -0
- package/dist/catchup-brief-RP4QHXNT.js +151 -0
- package/dist/catchup-brief-TKA6TEK4.js +151 -0
- package/dist/chunk-23KJ2LXY.js +58 -0
- package/dist/chunk-2NQQP3FF.js +630 -0
- package/dist/chunk-3FU5I3KV.js +526 -0
- package/dist/chunk-46IEEKPU.js +13696 -0
- package/dist/chunk-57UAFTO2.js +3958 -0
- package/dist/chunk-5AS622MM.js +3958 -0
- package/dist/chunk-62DEE65H.js +371 -0
- package/dist/chunk-64T6DFSS.js +447 -0
- package/dist/chunk-6BWDP63Z.js +197 -0
- package/dist/chunk-6GPYL7TX.js +214 -0
- package/dist/chunk-6KWLUVFL.js +54 -0
- package/dist/chunk-6N5ISWBF.js +1148 -0
- package/dist/chunk-6OD7PVMC.js +333 -0
- package/dist/chunk-7ET5CYTD.js +382 -0
- package/dist/chunk-7IWLKR6N.js +76 -0
- package/dist/chunk-7OEUOJL5.js +1021 -0
- package/dist/chunk-AIRJTKDK.js +204 -0
- package/dist/chunk-ATJ3NXDP.js +244 -0
- package/dist/chunk-B5IS7LE4.js +128 -0
- package/dist/chunk-BKINEQVI.js +244 -0
- package/dist/chunk-BOJV6NI3.js +128 -0
- package/dist/chunk-BPHWI6N2.js +284 -0
- package/dist/chunk-BXCQWWJP.js +185 -0
- package/dist/chunk-BZ6K7AY3.js +50 -0
- package/dist/chunk-C54KIFLS.js +214 -0
- package/dist/chunk-C6OYEJJI.js +260 -0
- package/dist/chunk-CHBHR5W6.js +3556 -0
- package/dist/chunk-D2T3272U.js +171 -0
- package/dist/chunk-DCHEIVGT.js +221 -0
- package/dist/chunk-DHIBLMSP.js +30 -0
- package/dist/chunk-E2AF2WYY.js +346 -0
- package/dist/chunk-E2KZEZZW.js +1090 -0
- package/dist/chunk-E4KWB4WM.js +348 -0
- package/dist/chunk-ENU7URWK.js +1073 -0
- package/dist/chunk-EZ7KAZMC.js +132 -0
- package/dist/chunk-F4FSSHR4.js +1073 -0
- package/dist/chunk-FPXU56FG.js +346 -0
- package/dist/chunk-FY7HHR5I.js +128 -0
- package/dist/chunk-G2S2UMU4.js +159 -0
- package/dist/chunk-G33BHQCO.js +70 -0
- package/dist/chunk-GJQTL7RX.js +127 -0
- package/dist/chunk-GLCKDEM2.js +97 -0
- package/dist/chunk-GMA34SXV.js +240 -0
- package/dist/chunk-GVAVEBYR.js +2091 -0
- package/dist/chunk-HOSJTLBQ.js +513 -0
- package/dist/chunk-IC6HVAS3.js +56 -0
- package/dist/chunk-IDFJNO44.js +1051 -0
- package/dist/chunk-ILFJMEY5.js +97 -0
- package/dist/chunk-ISQAOSL3.js +1921 -0
- package/dist/chunk-J6V2DCZK.js +382 -0
- package/dist/chunk-JP4CLFLR.js +1148 -0
- package/dist/chunk-JTIOZHWG.js +58 -0
- package/dist/chunk-KDICWAYV.js +1345 -0
- package/dist/chunk-KOBIB6WG.js +159 -0
- package/dist/chunk-KQFDDQB6.js +13696 -0
- package/dist/chunk-KZNSOHCB.js +280 -0
- package/dist/chunk-LVMBYP3C.js +171 -0
- package/dist/chunk-M2WQW5NC.js +227 -0
- package/dist/chunk-MY6SP5NZ.js +551 -0
- package/dist/chunk-N2ACW2ZG.js +363 -0
- package/dist/chunk-NSMJDATI.js +495 -0
- package/dist/chunk-NSQ5JE23.js +1090 -0
- package/dist/chunk-NZL567WG.js +81 -0
- package/dist/chunk-O5OMH6LI.js +244 -0
- package/dist/chunk-OBUV3W7L.js +163 -0
- package/dist/chunk-OLDS7LJN.js +495 -0
- package/dist/chunk-OO2I22RX.js +38 -0
- package/dist/chunk-OPUUT33V.js +447 -0
- package/dist/chunk-OT3VMTKB.js +50 -0
- package/dist/chunk-P6RVIOVA.js +157 -0
- package/dist/chunk-PUA5564C.js +210 -0
- package/dist/chunk-PUQLKLQX.js +731 -0
- package/dist/chunk-QROKS65G.js +76 -0
- package/dist/chunk-R54I2N2T.js +818 -0
- package/dist/chunk-RCFYQHUP.js +818 -0
- package/dist/chunk-RJTND4YS.js +284 -0
- package/dist/chunk-SBLHQMMZ.js +81 -0
- package/dist/chunk-SG2ANG5C.js +123 -0
- package/dist/chunk-SVFNKSZV.js +333 -0
- package/dist/chunk-TAQT2DC7.js +330 -0
- package/dist/chunk-TB7HFW7M.js +127 -0
- package/dist/chunk-UUKDAIH2.js +731 -0
- package/dist/chunk-V6VEFEEH.js +1345 -0
- package/dist/chunk-VIO2ALGH.js +290 -0
- package/dist/chunk-VKCUSNJW.js +377 -0
- package/dist/chunk-VRPPJFIQ.js +1921 -0
- package/dist/chunk-WP3PVBBP.js +204 -0
- package/dist/chunk-WQEUY7DC.js +129 -0
- package/dist/chunk-WXMXUKCA.js +262 -0
- package/dist/chunk-X2WBH2IO.js +297 -0
- package/dist/chunk-X33TSJNO.js +394 -0
- package/dist/chunk-X7MMI2UI.js +89 -0
- package/dist/chunk-XG3BQZIK.js +85 -0
- package/dist/chunk-XIKBIAOS.js +75 -0
- package/dist/chunk-XPEB545Q.js +54 -0
- package/dist/chunk-XWH2MLWS.js +330 -0
- package/dist/chunk-YH7V73XW.js +89 -0
- package/dist/chunk-YMLM5D65.js +135 -0
- package/dist/chunk-YNJPRQ6J.js +377 -0
- package/dist/chunk-YSNEHBI6.js +551 -0
- package/dist/chunk-ZD6BMW2K.js +33 -0
- package/dist/chunk-ZKG5IYCG.js +668 -0
- package/dist/chunk-ZU4K7ZNX.js +197 -0
- package/dist/co-activation-HZMJC34P.js +72 -0
- package/dist/co-occurrence-AVYXRV4L.js +74 -0
- package/dist/core-memory-NPJCVUMF.js +110 -0
- package/dist/core-memory-OKGXL33Z.js +110 -0
- package/dist/crdt-sync-ZCH55JNR.js +33 -0
- package/dist/crm-webhook-6OMVUUGR.js +10 -0
- package/dist/crm-webhook-UCWF3XDB.js +10 -0
- package/dist/cto-delegation-gate-JFZFZGC2.js +206 -0
- package/dist/cto-delegation-gate-K32M4GVM.js +206 -0
- package/dist/daemon-orchestration-2Q7BYOHC.js +135 -0
- package/dist/daemon-orchestration-4RJ2CZJL.js +135 -0
- package/dist/db-backup-5GA2YFDX.js +33 -0
- package/dist/dreaming-I6KXO6E2.js +32 -0
- package/dist/dreaming-NJBK5ILR.js +32 -0
- package/dist/exe-drift-VSMIMHL4.js +68 -0
- package/dist/exe-export-DVHHIA6Y.js +73 -0
- package/dist/exe-export-GIVQDENS.js +73 -0
- package/dist/exe-import-7N46LSMQ.js +76 -0
- package/dist/exe-import-FINYUV5T.js +76 -0
- package/dist/exe-key-H45JY44F.js +579 -0
- package/dist/exe-key-MAEQGTB7.js +579 -0
- package/dist/exe-snapshot-3TEM3BFD.js +164 -0
- package/dist/exe-snapshot-HECGUHL3.js +164 -0
- package/dist/fast-db-init-3CNTADVO.js +7 -0
- package/dist/fast-db-init-HXCS2AP5.js +7 -0
- package/dist/gateway/index.js +8 -8
- package/dist/git-staleness-YCEBBIVK.js +110 -0
- package/dist/git-task-sweep-H34STRNT.js +40 -0
- package/dist/git-task-sweep-YL7NLDCK.js +40 -0
- package/dist/global-procedures-IHZM6C2K.js +20 -0
- package/dist/graph-auto-extract-RZQ3MHP2.js +162 -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.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 +11 -11
- package/dist/hooks/post-tool-combined.js +5 -5
- package/dist/hooks/pre-compact.js +12 -12
- package/dist/hooks/pre-tool-use.js +15 -15
- package/dist/hooks/prompt-submit.js +21 -21
- package/dist/hooks/session-end.js +16 -16
- package/dist/hooks/session-start.js +10 -10
- package/dist/hooks/stop.js +15 -15
- package/dist/hooks/subagent-stop.js +11 -11
- package/dist/hooks/summary-worker.js +15 -15
- package/dist/index.js +18 -18
- package/dist/installer-4EW5ZDGD.js +296 -0
- package/dist/installer-B2JTQO55.js +38 -0
- package/dist/installer-MIL352T7.js +342 -0
- package/dist/lib/agent-config.js +9 -3
- 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.js +2 -2
- package/dist/lib/employee-templates.js +4 -4
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon.js +34 -34
- 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 +4 -4
- 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 +54 -54
- package/dist/mcp/server.js +55 -55
- 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 +5 -5
- 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-OJQR246S.js +27 -0
- package/dist/memory-cards-IPULSQFA.js +174 -0
- package/dist/memory-graph-extractor-3TZZOKHY.js +17 -0
- package/dist/memory-poisoning-defense-SGUGR5YJ.js +225 -0
- package/dist/memory-reflection-H3WGCEM6.js +238 -0
- package/dist/notifications-VWPO6NJF.js +45 -0
- package/dist/notifications-WCSRQN2V.js +45 -0
- package/dist/orchestration-events-O5PSDEIO.js +25 -0
- package/dist/orchestrator-RAPEJUOI.js +33 -0
- package/dist/orchestrator-XPG6LJAI.js +33 -0
- package/dist/pipeline-router-5NT6FUC3.js +13 -0
- package/dist/pipeline-router-KSUXONDT.js +13 -0
- package/dist/plan-limits-53NXLNDQ.js +26 -0
- package/dist/project-boot-ITN3FZMM.js +299 -0
- package/dist/projection-worker-27XX5M2W.js +964 -0
- package/dist/reranker-GU7L2PJX.js +19 -0
- package/dist/reranker-TZEXIJAN.js +19 -0
- package/dist/review-polling-FA2J2Q5O.js +124 -0
- package/dist/review-polling-MLS4BQ3N.js +124 -0
- package/dist/runtime/index.js +12 -12
- package/dist/session-events-WWGF3B2N.js +36 -0
- package/dist/session-events-ZHXXAH6B.js +36 -0
- package/dist/session-kill-telemetry-O4TJHHOZ.js +29 -0
- package/dist/session-scope-CQXB7VMH.js +86 -0
- package/dist/session-scope-HHUMJYF6.js +86 -0
- package/dist/setup-wizard-UM2RHSBJ.js +12 -0
- package/dist/skill-refinement-MJPOHYD5.js +157 -0
- package/dist/skill-refinement-NVUBRK22.js +157 -0
- package/dist/stack-release-BAPCXMXW.js +713 -0
- package/dist/stack-release-W4TWTEZP.js +731 -0
- package/dist/steward-gate-VLE7OCKO.js +13 -0
- package/dist/task-enforcement-FUHDL6UR.js +391 -0
- package/dist/task-enforcement-QL3K4N3F.js +391 -0
- package/dist/task-scope-TZYMB634.js +35 -0
- package/dist/task-scope-ZVLUBS4C.js +35 -0
- package/dist/tasks-crud-4MSLJWXE.js +77 -0
- package/dist/tasks-crud-HIPXKRKX.js +77 -0
- package/dist/tasks-notify-7JBUNE7R.js +38 -0
- package/dist/tasks-notify-UPIJ3L4O.js +38 -0
- package/dist/tasks-review-5SJSFTUB.js +47 -0
- package/dist/tasks-review-JHSYBR5I.js +47 -0
- package/dist/telemetry-upload-BSGOXGUP.js +739 -0
- package/dist/telemetry-upload-LTX3C5HZ.js +739 -0
- package/dist/token-budget-2CDWQU3Q.js +84 -0
- package/dist/tool-telemetry-7YS7EN7B.js +17 -0
- package/dist/tui/App.js +17 -17
- package/dist/tui-data-GDGBOS6G.js +258 -0
- package/dist/tui-data-VXF2RBVM.js +258 -0
- package/dist/wiki-acl-MJIMXRQV.js +111 -0
- package/dist/worker-gate-WQGTZOSM.js +21 -0
- package/dist/worker-gate-X2YDTKTL.js +21 -0
- package/dist/workflow-engine-CYXRZXBM.js +28 -0
- package/dist/workflow-engine-KMLAXVA4.js +28 -0
- package/dist/worktree-NLSKVRNC.js +26 -0
- package/dist/worktree-sweep-44TMEPLE.js +19 -0
- package/package.json +1 -1
- package/release-notes.json +24 -19
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initStore
|
|
3
|
+
} from "./chunk-RCFYQHUP.js";
|
|
4
|
+
import {
|
|
5
|
+
getClient,
|
|
6
|
+
isInitialized
|
|
7
|
+
} from "./chunk-CHBHR5W6.js";
|
|
8
|
+
|
|
9
|
+
// src/lib/schedules.ts
|
|
10
|
+
import crypto from "crypto";
|
|
11
|
+
import { execSync } from "child_process";
|
|
12
|
+
var CRON_FIELD = /^[\d*/,\-]+$/;
|
|
13
|
+
function isValidCron(cron) {
|
|
14
|
+
const fields = cron.trim().split(/\s+/);
|
|
15
|
+
if (fields.length !== 5) return false;
|
|
16
|
+
return fields.every((f) => CRON_FIELD.test(f));
|
|
17
|
+
}
|
|
18
|
+
var SAFE_ID = /^[a-zA-Z0-9_\-]+$/;
|
|
19
|
+
function isValidScheduleId(id) {
|
|
20
|
+
return SAFE_ID.test(id) && id.length <= 128;
|
|
21
|
+
}
|
|
22
|
+
async function ensureDb() {
|
|
23
|
+
if (!isInitialized()) {
|
|
24
|
+
await initStore();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parseHumanCron(input) {
|
|
28
|
+
const s = input.toLowerCase().trim();
|
|
29
|
+
if (/^[\d*\/,-]+\s+[\d*\/,-]+\s+[\d*\/,-]+\s+[\d*\/,-]+\s+[\d*\/,-]+$/.test(s)) {
|
|
30
|
+
return s;
|
|
31
|
+
}
|
|
32
|
+
const dayMap = {
|
|
33
|
+
sunday: "0",
|
|
34
|
+
sun: "0",
|
|
35
|
+
monday: "1",
|
|
36
|
+
mon: "1",
|
|
37
|
+
tuesday: "2",
|
|
38
|
+
tue: "2",
|
|
39
|
+
wednesday: "3",
|
|
40
|
+
wed: "3",
|
|
41
|
+
thursday: "4",
|
|
42
|
+
thu: "4",
|
|
43
|
+
friday: "5",
|
|
44
|
+
fri: "5",
|
|
45
|
+
saturday: "6",
|
|
46
|
+
sat: "6"
|
|
47
|
+
};
|
|
48
|
+
const everyMatch = s.match(/every\s+(\d+)\s*([mh])/);
|
|
49
|
+
if (everyMatch) {
|
|
50
|
+
const n = everyMatch[1];
|
|
51
|
+
const unit = everyMatch[2];
|
|
52
|
+
if (unit === "m") return `*/${n} * * * *`;
|
|
53
|
+
if (unit === "h") return `0 */${n} * * *`;
|
|
54
|
+
}
|
|
55
|
+
let hour = -1;
|
|
56
|
+
let minute = 0;
|
|
57
|
+
if (/midnight/.test(s)) {
|
|
58
|
+
hour = 0;
|
|
59
|
+
} else if (/noon/.test(s)) {
|
|
60
|
+
hour = 12;
|
|
61
|
+
} else {
|
|
62
|
+
const timeMatch = s.match(/(\d{1,2})(?::(\d{2}))?\s*(am|pm)?/);
|
|
63
|
+
if (timeMatch) {
|
|
64
|
+
hour = parseInt(timeMatch[1], 10);
|
|
65
|
+
minute = timeMatch[2] ? parseInt(timeMatch[2], 10) : 0;
|
|
66
|
+
if (timeMatch[3] === "pm" && hour < 12) hour += 12;
|
|
67
|
+
if (timeMatch[3] === "am" && hour === 12) hour = 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (hour === -1) hour = 0;
|
|
71
|
+
let dow = "*";
|
|
72
|
+
if (/weekday|weekdays/.test(s)) {
|
|
73
|
+
dow = "1-5";
|
|
74
|
+
} else if (/weekend|weekends/.test(s)) {
|
|
75
|
+
dow = "0,6";
|
|
76
|
+
} else {
|
|
77
|
+
for (const [name, val] of Object.entries(dayMap)) {
|
|
78
|
+
if (s.includes(name)) {
|
|
79
|
+
dow = val;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return `${minute} ${hour} * * ${dow}`;
|
|
85
|
+
}
|
|
86
|
+
async function createSchedule(input) {
|
|
87
|
+
if (!isValidCron(input.cron)) {
|
|
88
|
+
throw new Error(`Invalid cron expression: ${input.cron}. Must be 5 fields with only digits, *, /, -, comma.`);
|
|
89
|
+
}
|
|
90
|
+
await ensureDb();
|
|
91
|
+
const client = getClient();
|
|
92
|
+
const id = crypto.randomUUID().slice(0, 8);
|
|
93
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
94
|
+
const prompt = input.prompt ?? input.description;
|
|
95
|
+
await client.execute({
|
|
96
|
+
sql: `INSERT INTO schedules (id, cron, description, job_type, prompt, assigned_to, project_name, active, use_crontab, created_at)
|
|
97
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`,
|
|
98
|
+
args: [
|
|
99
|
+
id,
|
|
100
|
+
input.cron,
|
|
101
|
+
input.description,
|
|
102
|
+
input.jobType ?? "report",
|
|
103
|
+
prompt,
|
|
104
|
+
input.assignedTo ?? null,
|
|
105
|
+
input.projectName ?? null,
|
|
106
|
+
input.useCrontab ? 1 : 0,
|
|
107
|
+
now
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
if (input.useCrontab) {
|
|
111
|
+
addToCrontab(id, input.cron, prompt, input.projectName);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
id,
|
|
115
|
+
cron: input.cron,
|
|
116
|
+
description: input.description,
|
|
117
|
+
jobType: input.jobType ?? "report",
|
|
118
|
+
prompt,
|
|
119
|
+
assignedTo: input.assignedTo,
|
|
120
|
+
projectName: input.projectName,
|
|
121
|
+
active: true,
|
|
122
|
+
useCrontab: input.useCrontab ?? false,
|
|
123
|
+
createdAt: now
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async function listSchedules(activeOnly = true) {
|
|
127
|
+
await ensureDb();
|
|
128
|
+
const client = getClient();
|
|
129
|
+
const sql = activeOnly ? "SELECT * FROM schedules WHERE active = 1 ORDER BY created_at ASC" : "SELECT * FROM schedules ORDER BY created_at ASC";
|
|
130
|
+
const result = await client.execute({ sql, args: [] });
|
|
131
|
+
return result.rows.map((row) => ({
|
|
132
|
+
id: String(row.id),
|
|
133
|
+
cron: String(row.cron),
|
|
134
|
+
description: String(row.description),
|
|
135
|
+
jobType: String(row.job_type),
|
|
136
|
+
prompt: row.prompt ? String(row.prompt) : void 0,
|
|
137
|
+
assignedTo: row.assigned_to ? String(row.assigned_to) : void 0,
|
|
138
|
+
projectName: row.project_name ? String(row.project_name) : void 0,
|
|
139
|
+
active: Number(row.active) === 1,
|
|
140
|
+
useCrontab: Number(row.use_crontab) === 1,
|
|
141
|
+
createdAt: String(row.created_at)
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
async function deleteSchedule(id) {
|
|
145
|
+
await ensureDb();
|
|
146
|
+
const client = getClient();
|
|
147
|
+
const existing = await client.execute({
|
|
148
|
+
sql: "SELECT use_crontab FROM schedules WHERE id = ?",
|
|
149
|
+
args: [id]
|
|
150
|
+
});
|
|
151
|
+
if (existing.rows.length === 0) return false;
|
|
152
|
+
const usesCrontab = Number(existing.rows[0].use_crontab) === 1;
|
|
153
|
+
await client.execute({
|
|
154
|
+
sql: "DELETE FROM schedules WHERE id = ?",
|
|
155
|
+
args: [id]
|
|
156
|
+
});
|
|
157
|
+
if (usesCrontab) {
|
|
158
|
+
removeFromCrontab(id);
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function addToCrontab(id, cron, prompt, projectDir) {
|
|
163
|
+
if (!isValidCron(cron)) {
|
|
164
|
+
throw new Error(`Invalid cron expression: ${cron}`);
|
|
165
|
+
}
|
|
166
|
+
if (!isValidScheduleId(id)) {
|
|
167
|
+
throw new Error(`Invalid schedule ID: ${id}`);
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const cwd = projectDir ? `cd ${JSON.stringify(projectDir)} && ` : "";
|
|
171
|
+
const escapedPrompt = prompt.replace(/"/g, '\\"');
|
|
172
|
+
const entry = `${cron} ${cwd}claude -p --dangerously-skip-permissions "${escapedPrompt}" # exe-schedule:${id}`;
|
|
173
|
+
execSync(
|
|
174
|
+
`(crontab -l 2>/dev/null; echo ${JSON.stringify(entry)}) | crontab -`,
|
|
175
|
+
{ timeout: 5e3, stdio: "ignore" }
|
|
176
|
+
);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
if (err instanceof Error && err.message.startsWith("Invalid")) throw err;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function removeFromCrontab(id) {
|
|
182
|
+
if (!isValidScheduleId(id)) return;
|
|
183
|
+
try {
|
|
184
|
+
execSync(
|
|
185
|
+
`crontab -l 2>/dev/null | grep -v "exe-schedule:${id}" | crontab -`,
|
|
186
|
+
{ timeout: 5e3, stdio: "ignore" }
|
|
187
|
+
);
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
parseHumanCron,
|
|
194
|
+
createSchedule,
|
|
195
|
+
listSchedules,
|
|
196
|
+
deleteSchedule
|
|
197
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getClient
|
|
3
|
+
} from "./chunk-CHBHR5W6.js";
|
|
4
|
+
import "./chunk-2I23RPSI.js";
|
|
5
|
+
import "./chunk-C6OYEJJI.js";
|
|
6
|
+
import "./chunk-FXU7JOXK.js";
|
|
7
|
+
import "./chunk-VXIMSRTO.js";
|
|
8
|
+
import "./chunk-LYH5HE24.js";
|
|
9
|
+
import "./chunk-MLKGABMK.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/co-activation.ts
|
|
12
|
+
async function recordCoActivations(entityIds) {
|
|
13
|
+
if (entityIds.length < 2) return;
|
|
14
|
+
const unique = [...new Set(entityIds)].slice(0, 20);
|
|
15
|
+
const client = getClient();
|
|
16
|
+
const pairs = [];
|
|
17
|
+
for (let i = 0; i < unique.length; i++) {
|
|
18
|
+
for (let j = i + 1; j < unique.length; j++) {
|
|
19
|
+
const idI = unique[i];
|
|
20
|
+
const idJ = unique[j];
|
|
21
|
+
const pair = idI < idJ ? [idI, idJ] : [idJ, idI];
|
|
22
|
+
pairs.push(pair);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (const [a, b] of pairs) {
|
|
26
|
+
await client.execute({
|
|
27
|
+
sql: `INSERT INTO co_activations (entity_a_id, entity_b_id, count, last_activated_at)
|
|
28
|
+
VALUES (?, ?, 1, datetime('now'))
|
|
29
|
+
ON CONFLICT (entity_a_id, entity_b_id)
|
|
30
|
+
DO UPDATE SET count = count + 1, last_activated_at = datetime('now')`,
|
|
31
|
+
args: [a, b]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function getHotPairs(limit = 20) {
|
|
36
|
+
const client = getClient();
|
|
37
|
+
const result = await client.execute({
|
|
38
|
+
sql: `SELECT entity_a_id, entity_b_id, count, last_activated_at
|
|
39
|
+
FROM co_activations
|
|
40
|
+
ORDER BY count DESC
|
|
41
|
+
LIMIT ?`,
|
|
42
|
+
args: [limit]
|
|
43
|
+
});
|
|
44
|
+
return result.rows.map((r) => ({
|
|
45
|
+
entity_a_id: String(r.entity_a_id),
|
|
46
|
+
entity_b_id: String(r.entity_b_id),
|
|
47
|
+
count: Number(r.count),
|
|
48
|
+
last_activated_at: String(r.last_activated_at)
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
async function getCoActivationNeighbors(entityId, limit = 20) {
|
|
52
|
+
const client = getClient();
|
|
53
|
+
const result = await client.execute({
|
|
54
|
+
sql: `SELECT entity_a_id, entity_b_id, count, last_activated_at
|
|
55
|
+
FROM co_activations
|
|
56
|
+
WHERE entity_a_id = ? OR entity_b_id = ?
|
|
57
|
+
ORDER BY count DESC
|
|
58
|
+
LIMIT ?`,
|
|
59
|
+
args: [entityId, entityId, limit]
|
|
60
|
+
});
|
|
61
|
+
return result.rows.map((r) => ({
|
|
62
|
+
entity_a_id: String(r.entity_a_id),
|
|
63
|
+
entity_b_id: String(r.entity_b_id),
|
|
64
|
+
count: Number(r.count),
|
|
65
|
+
last_activated_at: String(r.last_activated_at)
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
getCoActivationNeighbors,
|
|
70
|
+
getHotPairs,
|
|
71
|
+
recordCoActivations
|
|
72
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getClient
|
|
3
|
+
} from "./chunk-CHBHR5W6.js";
|
|
4
|
+
import "./chunk-2I23RPSI.js";
|
|
5
|
+
import "./chunk-C6OYEJJI.js";
|
|
6
|
+
import "./chunk-FXU7JOXK.js";
|
|
7
|
+
import "./chunk-VXIMSRTO.js";
|
|
8
|
+
import "./chunk-LYH5HE24.js";
|
|
9
|
+
import "./chunk-MLKGABMK.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/co-occurrence.ts
|
|
12
|
+
var SPECIFICITY = {
|
|
13
|
+
file: 5,
|
|
14
|
+
function: 4,
|
|
15
|
+
error: 3,
|
|
16
|
+
tool: 2,
|
|
17
|
+
agent: 1,
|
|
18
|
+
project: 0
|
|
19
|
+
};
|
|
20
|
+
function getSpecificity(type) {
|
|
21
|
+
return SPECIFICITY[type] ?? 1;
|
|
22
|
+
}
|
|
23
|
+
function coOccurrenceId(entityId1, entityId2) {
|
|
24
|
+
const sorted = [entityId1, entityId2].sort();
|
|
25
|
+
return `cooccur:${sorted[0]}:${sorted[1]}`;
|
|
26
|
+
}
|
|
27
|
+
function entityIdFromNameType(type, name) {
|
|
28
|
+
return `mem:${type}:${name.toLowerCase().replace(/[^a-z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")}`;
|
|
29
|
+
}
|
|
30
|
+
async function createCoOccurrenceEdges(entities, _memoryId) {
|
|
31
|
+
if (entities.length < 2) return 0;
|
|
32
|
+
const client = getClient();
|
|
33
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
34
|
+
const seen = /* @__PURE__ */ new Set();
|
|
35
|
+
const deduped = entities.filter((e) => {
|
|
36
|
+
const key = `${e.type}:${e.name}`;
|
|
37
|
+
if (seen.has(key)) return false;
|
|
38
|
+
seen.add(key);
|
|
39
|
+
return true;
|
|
40
|
+
});
|
|
41
|
+
const sorted = deduped.sort((a, b) => getSpecificity(b.type) - getSpecificity(a.type));
|
|
42
|
+
const MAX_PAIRS = 10;
|
|
43
|
+
const pairs = [];
|
|
44
|
+
for (let i = 0; i < sorted.length && pairs.length < MAX_PAIRS; i++) {
|
|
45
|
+
for (let j = i + 1; j < sorted.length && pairs.length < MAX_PAIRS; j++) {
|
|
46
|
+
pairs.push([sorted[i], sorted[j]]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
let created = 0;
|
|
50
|
+
for (const [a, b] of pairs) {
|
|
51
|
+
const aId = entityIdFromNameType(a.type, a.name);
|
|
52
|
+
const bId = entityIdFromNameType(b.type, b.name);
|
|
53
|
+
const relId = coOccurrenceId(aId, bId);
|
|
54
|
+
const sortedIds = [aId, bId].sort();
|
|
55
|
+
const sourceId = sortedIds[0];
|
|
56
|
+
const targetId = sortedIds[1];
|
|
57
|
+
try {
|
|
58
|
+
await client.execute({
|
|
59
|
+
sql: `INSERT INTO relationships (id, source_entity_id, target_entity_id, type, weight, timestamp, properties)
|
|
60
|
+
VALUES (?, ?, ?, 'co_occurs_with', 1.0, ?, '{}')
|
|
61
|
+
ON CONFLICT(source_entity_id, target_entity_id, type) DO UPDATE SET
|
|
62
|
+
weight = MIN(weight + 0.1, 10.0),
|
|
63
|
+
timestamp = ?`,
|
|
64
|
+
args: [relId, sourceId, targetId, now, now]
|
|
65
|
+
});
|
|
66
|
+
created++;
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return created;
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
createCoOccurrenceEdges
|
|
74
|
+
};
|
|
@@ -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-DCHEIVGT.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
|
+
};
|