@askexenow/exe-os 0.9.296 → 0.9.298

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.
Files changed (256) hide show
  1. package/deploy/compose/.env.customer.example +6 -1
  2. package/deploy/compose/.env.example +6 -1
  3. package/deploy/compose/docker-compose.yml +24 -5
  4. package/deploy/compose/generate-env.ts +20 -2
  5. package/deploy/compose/setup.sh +10 -1
  6. package/deploy/stack-manifests/v0.9.json +1 -1
  7. package/dist/active-agent-3JXJQ2GZ.js +27 -0
  8. package/dist/active-agent-XK54VI3S.js +28 -0
  9. package/dist/agentic-ontology-BPJOT2H2.js +25 -0
  10. package/dist/backfill-metadata-OTLLYTX4.js +600 -0
  11. package/dist/behaviors-BGEUHF7D.js +46 -0
  12. package/dist/bin/agentic-ontology-backfill.js +5 -5
  13. package/dist/bin/agentic-reflection-backfill.js +6 -6
  14. package/dist/bin/agentic-semantic-label.js +5 -5
  15. package/dist/bin/backfill-conversations.js +4 -4
  16. package/dist/bin/backfill-responses.js +4 -4
  17. package/dist/bin/backfill-vectors.js +5 -5
  18. package/dist/bin/bulk-sync-postgres.js +7 -7
  19. package/dist/bin/cc-doctor.js +5 -4
  20. package/dist/bin/cleanup-stale-review-tasks.js +9 -9
  21. package/dist/bin/cli.js +15 -15
  22. package/dist/bin/exe-agent-config.js +2 -2
  23. package/dist/bin/exe-agent.js +13 -13
  24. package/dist/bin/exe-assign.js +5 -5
  25. package/dist/bin/exe-boot.js +32 -17
  26. package/dist/bin/exe-call.js +4 -4
  27. package/dist/bin/exe-cloud.js +7 -7
  28. package/dist/bin/exe-dispatch.js +9 -9
  29. package/dist/bin/exe-doctor.js +2 -2
  30. package/dist/bin/exe-export-behaviors.js +7 -7
  31. package/dist/bin/exe-forget.js +6 -6
  32. package/dist/bin/exe-gateway.js +7 -7
  33. package/dist/bin/exe-healthcheck.js +5 -4
  34. package/dist/bin/exe-heartbeat.js +9 -9
  35. package/dist/bin/exe-kill.js +12 -12
  36. package/dist/bin/exe-launch-agent.js +25 -16
  37. package/dist/bin/exe-new-employee.js +6 -6
  38. package/dist/bin/exe-pending-messages.js +10 -10
  39. package/dist/bin/exe-pending-notifications.js +9 -9
  40. package/dist/bin/exe-pending-reviews.js +9 -9
  41. package/dist/bin/exe-rename.js +4 -4
  42. package/dist/bin/exe-review.js +11 -11
  43. package/dist/bin/exe-search.js +5 -5
  44. package/dist/bin/exe-session-cleanup.js +14 -14
  45. package/dist/bin/exe-settings.js +8 -8
  46. package/dist/bin/exe-start-codex.js +11 -11
  47. package/dist/bin/exe-start-opencode.js +8 -8
  48. package/dist/bin/exe-status.js +10 -10
  49. package/dist/bin/exe-team.js +3 -3
  50. package/dist/bin/git-sweep.js +10 -10
  51. package/dist/bin/graph-backfill.js +4 -4
  52. package/dist/bin/graph-export.js +5 -5
  53. package/dist/bin/import-history.js +7 -7
  54. package/dist/bin/install-launchd.js +10 -124
  55. package/dist/bin/install.js +21 -12
  56. package/dist/bin/intercom-check.js +4 -4
  57. package/dist/bin/mcp-sessions.js +2 -2
  58. package/dist/bin/orchestration-metrics.js +4 -4
  59. package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
  60. package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
  61. package/dist/bin/scan-tasks.js +9 -9
  62. package/dist/bin/setup.js +1 -1
  63. package/dist/bin/shard-migrate.js +4 -4
  64. package/dist/bin/stack-update.js +27 -3
  65. package/dist/capability-cards-KR7BOS2H.js +89 -0
  66. package/dist/capacity-monitor-CQFYTU45.js +51 -0
  67. package/dist/catchup-brief-HNT2CYJQ.js +175 -0
  68. package/dist/cc-binary-detect-4B25R3TO.js +15 -0
  69. package/dist/chunk-2DQIQXHX.js +204 -0
  70. package/dist/chunk-2DWYR2LJ.js +395 -0
  71. package/dist/chunk-2MSLUPJA.js +70 -0
  72. package/dist/chunk-2P5KBHJH.js +362 -0
  73. package/dist/chunk-2QGG6GG3.js +4388 -0
  74. package/dist/chunk-2XR6OX3M.js +181 -0
  75. package/dist/chunk-3REXR56D.js +98 -0
  76. package/dist/chunk-4FEZF2HJ.js +184 -0
  77. package/dist/chunk-54PQ35JV.js +244 -0
  78. package/dist/chunk-5ALR7GCX.js +33 -0
  79. package/dist/chunk-5GJ5MHC3.js +1094 -0
  80. package/dist/chunk-5IIJUSVD.js +240 -0
  81. package/dist/chunk-5XM7CTLK.js +199 -0
  82. package/dist/chunk-6GQMQJE2.js +331 -0
  83. package/dist/chunk-7C4K7HSF.js +262 -0
  84. package/dist/chunk-AAFTYJ5R.js +185 -0
  85. package/dist/chunk-ANIZN35L.js +284 -0
  86. package/dist/chunk-AOXVDJ7W.js +150 -0
  87. package/dist/chunk-AR3HN5SA.js +76 -0
  88. package/dist/chunk-BFFM7FF4.js +214 -0
  89. package/dist/chunk-CVJYNRYF.js +50 -0
  90. package/dist/chunk-CXEY5CE2.js +81 -0
  91. package/dist/chunk-CY4IRJ2I.js +381 -0
  92. package/dist/chunk-DBNTPP7Q.js +1079 -0
  93. package/dist/chunk-DTLYO26W.js +402 -0
  94. package/dist/chunk-EESPF5VS.js +1350 -0
  95. package/dist/chunk-EN4D3BCA.js +2135 -0
  96. package/dist/chunk-EYDBWKYI.js +304 -0
  97. package/dist/chunk-FCSS3YHS.js +348 -0
  98. package/dist/chunk-G4VSF4DA.js +630 -0
  99. package/dist/chunk-GEF6EHCW.js +197 -0
  100. package/dist/chunk-GXDV35ZN.js +735 -0
  101. package/dist/chunk-HJWT6TFU.js +97 -0
  102. package/dist/chunk-HQD3IPZA.js +14597 -0
  103. package/dist/chunk-I3IW6AAX.js +3342 -0
  104. package/dist/chunk-I4JYP7CK.js +535 -0
  105. package/dist/chunk-J2VWNIYC.js +167 -0
  106. package/dist/chunk-JK5OLEM6.js +227 -0
  107. package/dist/chunk-JVMP77TZ.js +1186 -0
  108. package/dist/chunk-KJ5DAVIP.js +122 -0
  109. package/dist/chunk-KPP2AYJV.js +333 -0
  110. package/dist/chunk-L2WWAOQF.js +455 -0
  111. package/dist/chunk-L3STXXCO.js +731 -0
  112. package/dist/chunk-LMX434DW.js +38 -0
  113. package/dist/chunk-LP4NNUZN.js +58 -0
  114. package/dist/chunk-MN7Q23PF.js +157 -0
  115. package/dist/chunk-O4QLYWMC.js +668 -0
  116. package/dist/chunk-OP5W524C.js +85 -0
  117. package/dist/chunk-OQ336FHE.js +836 -0
  118. package/dist/chunk-P7WAPK6X.js +54 -0
  119. package/dist/chunk-PLM4JJHE.js +128 -0
  120. package/dist/chunk-POTMDICN.js +1352 -0
  121. package/dist/chunk-POZYABJT.js +567 -0
  122. package/dist/chunk-PQG2IQNN.js +280 -0
  123. package/dist/chunk-PUGKVPCC.js +210 -0
  124. package/dist/chunk-QE6AI57N.js +1158 -0
  125. package/dist/chunk-QNCZDDVW.js +448 -0
  126. package/dist/chunk-QZIYE2QV.js +456 -0
  127. package/dist/chunk-RXOHALES.js +345 -0
  128. package/dist/chunk-SGUSCL3H.js +129 -0
  129. package/dist/chunk-SWOGQD57.js +85 -0
  130. package/dist/chunk-SZLIO4SL.js +128 -0
  131. package/dist/chunk-T2USDSC2.js +221 -0
  132. package/dist/chunk-UKE7MZVO.js +382 -0
  133. package/dist/chunk-VSRJPOZD.js +290 -0
  134. package/dist/chunk-WCQ3Y5LB.js +2162 -0
  135. package/dist/chunk-WHBT6M3P.js +30 -0
  136. package/dist/chunk-WR6ANODF.js +57 -0
  137. package/dist/chunk-X7ADWEZ7.js +171 -0
  138. package/dist/chunk-Y4QZXMCD.js +123 -0
  139. package/dist/chunk-Y4WA4CUW.js +377 -0
  140. package/dist/chunk-YUOUHUAJ.js +127 -0
  141. package/dist/chunk-YXC3OWWW.js +128 -0
  142. package/dist/co-activation-EN7HT734.js +74 -0
  143. package/dist/co-occurrence-TRPHUCSC.js +95 -0
  144. package/dist/core-memory-TVMGLIJ7.js +110 -0
  145. package/dist/crdt-sync-WOMERQIS.js +33 -0
  146. package/dist/crm-webhook-Q5Z74FDJ.js +10 -0
  147. package/dist/cto-delegation-gate-NEMNMLXB.js +280 -0
  148. package/dist/daemon-orchestration-RYDUCL24.js +143 -0
  149. package/dist/db-backup-Z3E3LHZK.js +43 -0
  150. package/dist/doc-graph-extractor-TSCKGSB5.js +133 -0
  151. package/dist/dreaming-42LRG6AO.js +34 -0
  152. package/dist/exe-drift-SJ6OTCQV.js +70 -0
  153. package/dist/exe-export-SRDDONTU.js +77 -0
  154. package/dist/exe-import-PWHXRFLN.js +80 -0
  155. package/dist/exe-key-GH6ITI5C.js +673 -0
  156. package/dist/exe-snapshot-RVLH5PJZ.js +338 -0
  157. package/dist/fast-db-init-CM4XPET2.js +7 -0
  158. package/dist/gateway/index.js +14 -14
  159. package/dist/git-staleness-7EFCUGT2.js +112 -0
  160. package/dist/git-task-sweep-6DR24G3Y.js +42 -0
  161. package/dist/global-procedures-NXLOLU7Y.js +22 -0
  162. package/dist/graph-auto-extract-5F3PLBCK.js +183 -0
  163. package/dist/hooks/bug-report-worker.js +11 -11
  164. package/dist/hooks/codex-stop-task-finalizer.js +11 -11
  165. package/dist/hooks/commit-complete.js +11 -11
  166. package/dist/hooks/error-recall.js +10 -7
  167. package/dist/hooks/exe-heartbeat-hook.js +3 -3
  168. package/dist/hooks/ingest.js +6 -6
  169. package/dist/hooks/instructions-loaded.js +4 -4
  170. package/dist/hooks/manifest.json +19 -19
  171. package/dist/hooks/notification.js +4 -4
  172. package/dist/hooks/post-compact.js +10 -10
  173. package/dist/hooks/post-tool-combined.js +5 -5
  174. package/dist/hooks/pre-compact.js +11 -11
  175. package/dist/hooks/pre-tool-use.js +14 -14
  176. package/dist/hooks/prompt-submit.js +26 -22
  177. package/dist/hooks/session-end.js +15 -15
  178. package/dist/hooks/session-start.js +12 -12
  179. package/dist/hooks/stop.js +14 -14
  180. package/dist/hooks/subagent-stop.js +10 -10
  181. package/dist/hooks/summary-worker.js +14 -14
  182. package/dist/index.js +19 -19
  183. package/dist/installer-5WBAZKSI.js +344 -0
  184. package/dist/installer-ENK2QYTC.js +298 -0
  185. package/dist/installer-TUO7KCRN.js +40 -0
  186. package/dist/lib/cloud-sync.js +7 -7
  187. package/dist/lib/consolidation.js +5 -5
  188. package/dist/lib/database.js +4 -2
  189. package/dist/lib/db-read-worker-client.js +121 -0
  190. package/dist/lib/db-read-worker.js +73 -0
  191. package/dist/lib/db.js +4 -2
  192. package/dist/lib/employee-templates.js +4 -4
  193. package/dist/lib/employees.js +2 -2
  194. package/dist/lib/exe-daemon.js +110 -87
  195. package/dist/lib/hybrid-search.js +5 -5
  196. package/dist/lib/identity.js +2 -2
  197. package/dist/lib/messaging.js +9 -9
  198. package/dist/lib/reminders.js +3 -3
  199. package/dist/lib/schedules.js +5 -5
  200. package/dist/lib/session-registry.js +4 -4
  201. package/dist/lib/skill-learning.js +6 -6
  202. package/dist/lib/store.js +4 -4
  203. package/dist/lib/task-router.js +3 -3
  204. package/dist/lib/tasks.js +10 -10
  205. package/dist/lib/tmux-routing.js +8 -8
  206. package/dist/lib/token-spend.js +3 -3
  207. package/dist/mcp/register-tools.js +56 -55
  208. package/dist/mcp/server.js +58 -57
  209. package/dist/mcp/tools/complete-reminder.js +4 -4
  210. package/dist/mcp/tools/create-reminder.js +4 -4
  211. package/dist/mcp/tools/create-task.js +12 -12
  212. package/dist/mcp/tools/deactivate-behavior.js +7 -7
  213. package/dist/mcp/tools/list-reminders.js +4 -4
  214. package/dist/mcp/tools/list-tasks.js +12 -12
  215. package/dist/mcp/tools/send-message.js +11 -11
  216. package/dist/mcp/tools/update-task.js +11 -11
  217. package/dist/mcp-http-config-FA6LWCTD.js +31 -0
  218. package/dist/memory-cards-4QRWCJ54.js +180 -0
  219. package/dist/memory-graph-extractor-HCS4XTQK.js +22 -0
  220. package/dist/memory-poisoning-defense-7I4LY4VL.js +224 -0
  221. package/dist/memory-reflection-ZSSO6RFR.js +244 -0
  222. package/dist/notifications-VQJCTOMC.js +47 -0
  223. package/dist/orchestration-events-UFRQWTRS.js +27 -0
  224. package/dist/orchestrator-ZSSTRMDC.js +35 -0
  225. package/dist/pipeline-router-U7WWUVKV.js +15 -0
  226. package/dist/plan-limits-KVFTHSQU.js +28 -0
  227. package/dist/project-boot-KOGUVIQ4.js +299 -0
  228. package/dist/projection-worker-OMUSXRHO.js +1084 -0
  229. package/dist/prospective-memory-PC72YWLY.js +232 -0
  230. package/dist/reranker-E3MOR2MC.js +19 -0
  231. package/dist/retrieval-health-OEHPZH65.js +12 -0
  232. package/dist/review-polling-4GWZSSSQ.js +126 -0
  233. package/dist/runtime/index.js +11 -11
  234. package/dist/session-events-A3L5KUHB.js +38 -0
  235. package/dist/session-kill-telemetry-UFJY57N2.js +31 -0
  236. package/dist/session-scope-5MT6U7CR.js +88 -0
  237. package/dist/setup-wizard-NZE2I7M5.js +12 -0
  238. package/dist/skill-refinement-Q6USTB35.js +159 -0
  239. package/dist/steward-gate-XOYAMKNY.js +15 -0
  240. package/dist/task-enforcement-MQ4TKLAN.js +506 -0
  241. package/dist/task-scope-AWFGZWPM.js +37 -0
  242. package/dist/tasks-crud-LMPAYXKS.js +79 -0
  243. package/dist/tasks-notify-6DZOY3MH.js +40 -0
  244. package/dist/tasks-review-TMBMXNUJ.js +49 -0
  245. package/dist/telemetry-upload-C2PKRA26.js +741 -0
  246. package/dist/token-budget-HOOQPFKR.js +86 -0
  247. package/dist/tool-telemetry-EJVBIKOS.js +17 -0
  248. package/dist/tui/App.js +16 -16
  249. package/dist/tui-data-6HIDQFN7.js +260 -0
  250. package/dist/wiki-acl-DOBVII5N.js +111 -0
  251. package/dist/worker-gate-ZH5PK25Z.js +21 -0
  252. package/dist/workflow-engine-SGU6WUWF.js +28 -0
  253. package/dist/worktree-NRQVJ2M4.js +28 -0
  254. package/dist/worktree-sweep-FBEHEPZO.js +21 -0
  255. package/package.json +1 -1
  256. package/release-notes.json +88 -88
@@ -0,0 +1,74 @@
1
+ import {
2
+ getClient
3
+ } from "./chunk-I3IW6AAX.js";
4
+ import "./chunk-2I23RPSI.js";
5
+ import "./chunk-2DWYR2LJ.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-I3IW6AAX.js";
10
+ import "./chunk-2I23RPSI.js";
11
+ import "./chunk-2DWYR2LJ.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,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-T2USDSC2.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
+ };
@@ -0,0 +1,10 @@
1
+ import {
2
+ createCRMWebhookHandler,
3
+ parseTwentyWebhook
4
+ } from "./chunk-P7WAPK6X.js";
5
+ import "./chunk-UKE7MZVO.js";
6
+ import "./chunk-MLKGABMK.js";
7
+ export {
8
+ createCRMWebhookHandler,
9
+ parseTwentyWebhook
10
+ };
@@ -0,0 +1,280 @@
1
+ import {
2
+ sessionScopeFilter
3
+ } from "./chunk-2QGG6GG3.js";
4
+ import "./chunk-PQG2IQNN.js";
5
+ import "./chunk-4JERP7NT.js";
6
+ import "./chunk-4FVVJ7ME.js";
7
+ import "./chunk-EYDBWKYI.js";
8
+ import "./chunk-KOO3J5PV.js";
9
+ import "./chunk-22TVSRQQ.js";
10
+ import "./chunk-SSTLTIF3.js";
11
+ import "./chunk-G4VSF4DA.js";
12
+ import "./chunk-QRTJNSKU.js";
13
+ import "./chunk-NGP6LSV2.js";
14
+ import "./chunk-SGUSCL3H.js";
15
+ import "./chunk-CVYC6DUW.js";
16
+ import "./chunk-OPU3NYOO.js";
17
+ import "./chunk-GJV3WDWM.js";
18
+ import "./chunk-MP2AFCGL.js";
19
+ import "./chunk-2MSLUPJA.js";
20
+ import "./chunk-HYZV25LY.js";
21
+ import {
22
+ getClient,
23
+ getEmployeeByRole,
24
+ loadEmployeesSync
25
+ } from "./chunk-I3IW6AAX.js";
26
+ import "./chunk-2I23RPSI.js";
27
+ import "./chunk-2DWYR2LJ.js";
28
+ import "./chunk-PNQDP3OA.js";
29
+ import "./chunk-7HLWBYH7.js";
30
+ import "./chunk-FXU7JOXK.js";
31
+ import "./chunk-YTKVJJSU.js";
32
+ import "./chunk-R36FAN53.js";
33
+ import "./chunk-LYH5HE24.js";
34
+ import "./chunk-MLKGABMK.js";
35
+
36
+ // src/lib/cto-delegation-gate.ts
37
+ import os from "os";
38
+ import path from "path";
39
+ import { existsSync, readFileSync, statSync } from "fs";
40
+ var GATED_ROLE = "CTO";
41
+ function resolveGatedAgent() {
42
+ try {
43
+ const employees = loadEmployeesSync();
44
+ const cto = getEmployeeByRole(employees, GATED_ROLE);
45
+ return cto?.name ?? "";
46
+ } catch {
47
+ return "";
48
+ }
49
+ }
50
+ var GATED_AGENT = resolveGatedAgent();
51
+ function getGatedAgent() {
52
+ return resolveGatedAgent() || GATED_AGENT;
53
+ }
54
+ var BLOCKED_PATH_PREFIXES = [
55
+ "src/",
56
+ "tests/",
57
+ "scripts/",
58
+ "bin/",
59
+ ".github/workflows/",
60
+ ".claude/skills/"
61
+ ];
62
+ var BLOCKED_FILENAMES = [
63
+ "package.json",
64
+ "tsconfig.json",
65
+ "docker-compose.yml"
66
+ ];
67
+ var BLOCKED_DOCKERFILE_PREFIX = "Dockerfile";
68
+ var BLOCKED_EXTENSIONS = [
69
+ ".ts",
70
+ ".js",
71
+ ".tsx",
72
+ ".jsx",
73
+ ".rs",
74
+ ".py",
75
+ ".go",
76
+ ".sh",
77
+ ".yaml",
78
+ ".yml",
79
+ ".prisma",
80
+ ".sql"
81
+ ];
82
+ var EXEMPT_MD_DIR_PREFIXES = [
83
+ ".planning/",
84
+ "exe/output/",
85
+ "exe/",
86
+ "docs/"
87
+ ];
88
+ var RECENT_DISPATCH_WINDOW_MS = 5 * 60 * 1e3;
89
+ var SCRATCHPAD_MAX_AGE_MS = 10 * 60 * 1e3;
90
+ var SCRATCHPAD_ESCAPE_PATTERN = /^(?:ENGINEER|TOM)-CAPABLE:\s*NO\s*—\s*reason:\s*\S+/m;
91
+ function toWorkspaceRelative(filePath, cwd = process.cwd()) {
92
+ const normalized = path.normalize(filePath);
93
+ if (normalized.startsWith(cwd + path.sep)) {
94
+ return normalized.slice(cwd.length + 1);
95
+ }
96
+ if (path.isAbsolute(normalized)) {
97
+ return path.basename(normalized);
98
+ }
99
+ return normalized;
100
+ }
101
+ function isDockerfile(basename) {
102
+ return basename === BLOCKED_DOCKERFILE_PREFIX || basename.startsWith(`${BLOCKED_DOCKERFILE_PREFIX}.`);
103
+ }
104
+ function classifyPath(filePath, cwd) {
105
+ const rel = toWorkspaceRelative(filePath, cwd);
106
+ const basename = path.basename(rel);
107
+ const ext = path.extname(rel).toLowerCase();
108
+ if (ext === ".md") {
109
+ for (const prefix of EXEMPT_MD_DIR_PREFIXES) {
110
+ if (rel.startsWith(prefix)) return "exempt";
111
+ }
112
+ if (!BLOCKED_PATH_PREFIXES.some((p) => rel.startsWith(p))) {
113
+ return "exempt";
114
+ }
115
+ }
116
+ if (BLOCKED_FILENAMES.includes(basename)) return "code";
117
+ if (isDockerfile(basename)) return "code";
118
+ if (BLOCKED_EXTENSIONS.includes(ext)) return "code";
119
+ if (BLOCKED_PATH_PREFIXES.some((p) => rel.startsWith(p))) return "code";
120
+ return "exempt";
121
+ }
122
+ function buildPathTokens(filePath) {
123
+ const GENERIC_SEGMENTS = /* @__PURE__ */ new Set([
124
+ "src",
125
+ "app",
126
+ "api",
127
+ "lib",
128
+ "bin",
129
+ "tests",
130
+ "test",
131
+ "scripts",
132
+ "dist",
133
+ "build",
134
+ "out",
135
+ "pages",
136
+ "routes",
137
+ "components",
138
+ "utils",
139
+ "helpers",
140
+ "types",
141
+ "models"
142
+ ]);
143
+ const normalized = path.normalize(filePath).replace(/\\/g, "/");
144
+ const segments = normalized.split("/").filter(Boolean);
145
+ const tokens = /* @__PURE__ */ new Set();
146
+ const basename = segments[segments.length - 1] ?? "";
147
+ if (basename) tokens.add(basename);
148
+ const parentDir = segments[segments.length - 2];
149
+ if (parentDir && parentDir.length >= 5 && !GENERIC_SEGMENTS.has(parentDir)) {
150
+ tokens.add(parentDir);
151
+ tokens.add(`${parentDir}/${basename}`);
152
+ }
153
+ for (let depth = 2; depth <= Math.min(4, segments.length); depth++) {
154
+ const suffix = segments.slice(segments.length - depth).join("/");
155
+ const leadSegment = segments[segments.length - depth] ?? "";
156
+ if (GENERIC_SEGMENTS.has(leadSegment)) continue;
157
+ tokens.add(suffix);
158
+ }
159
+ return [...tokens].filter((t) => t.length > 0);
160
+ }
161
+ async function isFileInTaskSpec(filePath, agentId) {
162
+ try {
163
+ const client = getClient();
164
+ const scope = sessionScopeFilter();
165
+ const result = await client.execute({
166
+ sql: `SELECT title, context FROM tasks
167
+ WHERE assigned_to = ? AND status = 'in_progress'${scope.sql}`,
168
+ args: [agentId, ...scope.args]
169
+ });
170
+ if (result.rows.length === 0) return false;
171
+ const tokens = buildPathTokens(filePath);
172
+ if (tokens.length === 0) return false;
173
+ for (const row of result.rows) {
174
+ const haystack = [
175
+ String(row.title ?? ""),
176
+ String(row.context ?? "")
177
+ ].join(" ").toLowerCase();
178
+ for (const token of tokens) {
179
+ if (haystack.includes(token.toLowerCase())) {
180
+ return true;
181
+ }
182
+ }
183
+ }
184
+ return false;
185
+ } catch {
186
+ return false;
187
+ }
188
+ }
189
+ async function hasRecentEngineerDispatch(now = Date.now()) {
190
+ try {
191
+ const client = getClient();
192
+ const engineers = loadEmployeesSync().filter(
193
+ (e) => e.role.toLowerCase() === "principal engineer"
194
+ );
195
+ const engineerNames = engineers.map((e) => e.name);
196
+ const gatedAgent = getGatedAgent();
197
+ if (!gatedAgent) return false;
198
+ if (engineerNames.length === 0) return false;
199
+ const placeholders = engineerNames.map(() => "?").join(",");
200
+ const ydScope = sessionScopeFilter();
201
+ const result = await client.execute({
202
+ sql: `SELECT MAX(created_at) AS last_dispatch
203
+ FROM tasks
204
+ WHERE assigned_by = ? AND assigned_to IN (${placeholders})${ydScope.sql}`,
205
+ args: [gatedAgent, ...engineerNames, ...ydScope.args]
206
+ });
207
+ const raw = result.rows[0]?.last_dispatch;
208
+ if (raw === null || raw === void 0) return false;
209
+ const parsed = Date.parse(String(raw));
210
+ if (Number.isNaN(parsed)) return false;
211
+ return now - parsed <= RECENT_DISPATCH_WINDOW_MS;
212
+ } catch {
213
+ return false;
214
+ }
215
+ }
216
+ function scratchpadPath(sessionId, homeDir = os.homedir()) {
217
+ return path.join(
218
+ homeDir,
219
+ ".exe-os",
220
+ "session-cache",
221
+ `cto-scratchpad-${sessionId}.txt`
222
+ );
223
+ }
224
+ function hasValidScratchpadEscape(sessionId, now = Date.now(), homeDir = os.homedir()) {
225
+ const paths = [scratchpadPath(sessionId, homeDir)];
226
+ for (const filePath of paths) {
227
+ if (!existsSync(filePath)) continue;
228
+ try {
229
+ const stat = statSync(filePath);
230
+ if (now - stat.mtimeMs > SCRATCHPAD_MAX_AGE_MS) continue;
231
+ const body = readFileSync(filePath, "utf-8");
232
+ if (SCRATCHPAD_ESCAPE_PATTERN.test(body)) return true;
233
+ } catch {
234
+ }
235
+ }
236
+ return false;
237
+ }
238
+ var GATE_BLOCK_MESSAGE = [
239
+ "ACTION BLOCKED by CTO delegation gate. Your Write/Edit was DENIED \u2014 it did NOT execute.",
240
+ "This edit looks implementable by an engineer. You MUST either:",
241
+ " 1. Dispatch create_task to an engineer, OR",
242
+ " 2. Add ENGINEER-CAPABLE: NO with explicit reason to proceed yourself.",
243
+ "Do NOT report this action as successful. It was blocked. No file was changed.",
244
+ "If you are a sub-agent, report this FAILURE to your parent agent."
245
+ ].join("\n");
246
+ async function evaluateDelegationGate(opts) {
247
+ const gatedAgent = getGatedAgent();
248
+ if (!gatedAgent || opts.agentId !== gatedAgent) {
249
+ return { outcome: "allow", reason: "agent_not_gated" };
250
+ }
251
+ if (!/^(Write|Edit)$/.test(opts.toolName)) {
252
+ return { outcome: "allow", reason: "tool_not_gated" };
253
+ }
254
+ if (classifyPath(opts.filePath, opts.cwd) === "exempt") {
255
+ return { outcome: "allow", reason: "exempt_path" };
256
+ }
257
+ if (await isFileInTaskSpec(opts.filePath, opts.agentId)) {
258
+ return { outcome: "allow", reason: "task_spec_authorized" };
259
+ }
260
+ if (await hasRecentEngineerDispatch(opts.now)) {
261
+ return { outcome: "allow", reason: "recent_engineer_dispatch" };
262
+ }
263
+ if (hasValidScratchpadEscape(opts.sessionId, opts.now, opts.homeDir)) {
264
+ return { outcome: "allow", reason: "scratchpad_escape" };
265
+ }
266
+ return { outcome: "block", reason: "no_delegation_no_escape" };
267
+ }
268
+ export {
269
+ GATED_AGENT,
270
+ GATED_ROLE,
271
+ GATE_BLOCK_MESSAGE,
272
+ buildPathTokens,
273
+ classifyPath,
274
+ evaluateDelegationGate,
275
+ getGatedAgent,
276
+ hasRecentEngineerDispatch,
277
+ hasValidScratchpadEscape,
278
+ isFileInTaskSpec,
279
+ scratchpadPath
280
+ };