@askexenow/exe-os 0.8.80 → 0.8.82

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 (110) hide show
  1. package/dist/bin/backfill-conversations.js +359 -267
  2. package/dist/bin/backfill-responses.js +357 -265
  3. package/dist/bin/backfill-vectors.js +339 -264
  4. package/dist/bin/cleanup-stale-review-tasks.js +315 -256
  5. package/dist/bin/cli.js +494 -240
  6. package/dist/bin/exe-agent.js +141 -46
  7. package/dist/bin/exe-assign.js +151 -63
  8. package/dist/bin/exe-boot.js +294 -115
  9. package/dist/bin/exe-call.js +76 -51
  10. package/dist/bin/exe-cloud.js +58 -45
  11. package/dist/bin/exe-dispatch.js +434 -277
  12. package/dist/bin/exe-doctor.js +317 -246
  13. package/dist/bin/exe-export-behaviors.js +328 -248
  14. package/dist/bin/exe-forget.js +314 -231
  15. package/dist/bin/exe-gateway.js +2676 -1402
  16. package/dist/bin/exe-heartbeat.js +329 -264
  17. package/dist/bin/exe-kill.js +324 -244
  18. package/dist/bin/exe-launch-agent.js +574 -463
  19. package/dist/bin/exe-link.js +1055 -95
  20. package/dist/bin/exe-new-employee.js +49 -54
  21. package/dist/bin/exe-pending-messages.js +310 -253
  22. package/dist/bin/exe-pending-notifications.js +299 -228
  23. package/dist/bin/exe-pending-reviews.js +314 -245
  24. package/dist/bin/exe-rename.js +259 -195
  25. package/dist/bin/exe-review.js +140 -64
  26. package/dist/bin/exe-search.js +543 -356
  27. package/dist/bin/exe-session-cleanup.js +463 -382
  28. package/dist/bin/exe-settings.js +129 -99
  29. package/dist/bin/exe-start.sh +6 -6
  30. package/dist/bin/exe-status.js +95 -36
  31. package/dist/bin/exe-team.js +116 -51
  32. package/dist/bin/git-sweep.js +482 -307
  33. package/dist/bin/graph-backfill.js +357 -245
  34. package/dist/bin/graph-export.js +324 -244
  35. package/dist/bin/install.js +33 -10
  36. package/dist/bin/scan-tasks.js +481 -307
  37. package/dist/bin/setup.js +1147 -140
  38. package/dist/bin/shard-migrate.js +321 -241
  39. package/dist/bin/update.js +1 -7
  40. package/dist/bin/wiki-sync.js +318 -238
  41. package/dist/gateway/index.js +2656 -1383
  42. package/dist/hooks/bug-report-worker.js +641 -472
  43. package/dist/hooks/commit-complete.js +482 -307
  44. package/dist/hooks/error-recall.js +363 -135
  45. package/dist/hooks/exe-heartbeat-hook.js +97 -27
  46. package/dist/hooks/ingest-worker.js +584 -397
  47. package/dist/hooks/ingest.js +123 -58
  48. package/dist/hooks/instructions-loaded.js +212 -82
  49. package/dist/hooks/notification.js +200 -70
  50. package/dist/hooks/post-compact.js +199 -81
  51. package/dist/hooks/pre-compact.js +352 -140
  52. package/dist/hooks/pre-tool-use.js +416 -278
  53. package/dist/hooks/prompt-ingest-worker.js +376 -299
  54. package/dist/hooks/prompt-submit.js +414 -188
  55. package/dist/hooks/response-ingest-worker.js +408 -338
  56. package/dist/hooks/session-end.js +209 -83
  57. package/dist/hooks/session-start.js +382 -158
  58. package/dist/hooks/stop.js +209 -83
  59. package/dist/hooks/subagent-stop.js +209 -85
  60. package/dist/hooks/summary-worker.js +606 -510
  61. package/dist/index.js +2133 -855
  62. package/dist/lib/cloud-sync.js +1175 -184
  63. package/dist/lib/config.js +1 -9
  64. package/dist/lib/consolidation.js +71 -34
  65. package/dist/lib/database.js +166 -14
  66. package/dist/lib/device-registry.js +189 -117
  67. package/dist/lib/embedder.js +6 -10
  68. package/dist/lib/employee-templates.js +134 -39
  69. package/dist/lib/employees.js +30 -7
  70. package/dist/lib/exe-daemon-client.js +5 -7
  71. package/dist/lib/exe-daemon.js +514 -152
  72. package/dist/lib/hybrid-search.js +543 -356
  73. package/dist/lib/identity-templates.js +15 -15
  74. package/dist/lib/identity.js +19 -15
  75. package/dist/lib/license.js +1 -7
  76. package/dist/lib/messaging.js +157 -135
  77. package/dist/lib/reminders.js +97 -0
  78. package/dist/lib/schedules.js +302 -231
  79. package/dist/lib/skill-learning.js +33 -27
  80. package/dist/lib/status-brief.js +11 -14
  81. package/dist/lib/store.js +326 -237
  82. package/dist/lib/task-router.js +105 -1
  83. package/dist/lib/tasks.js +233 -116
  84. package/dist/lib/tmux-routing.js +173 -56
  85. package/dist/lib/ws-client.js +13 -3
  86. package/dist/mcp/server.js +2009 -1015
  87. package/dist/mcp/tools/complete-reminder.js +97 -0
  88. package/dist/mcp/tools/create-reminder.js +97 -0
  89. package/dist/mcp/tools/create-task.js +426 -262
  90. package/dist/mcp/tools/deactivate-behavior.js +119 -44
  91. package/dist/mcp/tools/list-reminders.js +97 -0
  92. package/dist/mcp/tools/list-tasks.js +56 -57
  93. package/dist/mcp/tools/send-message.js +206 -143
  94. package/dist/mcp/tools/update-task.js +259 -85
  95. package/dist/runtime/index.js +495 -316
  96. package/dist/tui/App.js +1128 -919
  97. package/package.json +2 -10
  98. package/src/commands/exe/afk.md +8 -8
  99. package/src/commands/exe/assign.md +1 -1
  100. package/src/commands/exe/build-adv.md +1 -1
  101. package/src/commands/exe/call.md +10 -10
  102. package/src/commands/exe/employee-heartbeat.md +9 -6
  103. package/src/commands/exe/heartbeat.md +5 -5
  104. package/src/commands/exe/intercom.md +26 -15
  105. package/src/commands/exe/launch.md +2 -2
  106. package/src/commands/exe/new-employee.md +1 -1
  107. package/src/commands/exe/review.md +2 -2
  108. package/src/commands/exe/schedule.md +1 -1
  109. package/src/commands/exe/sessions.md +2 -2
  110. package/src/commands/exe.md +22 -20
@@ -47,7 +47,7 @@ function wrapWithRetry(client) {
47
47
  return (sql) => retryOnBusy(() => target.execute(sql), "execute");
48
48
  }
49
49
  if (prop === "batch") {
50
- return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
50
+ return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
51
51
  }
52
52
  return Reflect.get(target, prop, receiver);
53
53
  }
@@ -63,6 +63,226 @@ var init_db_retry = __esm({
63
63
  }
64
64
  });
65
65
 
66
+ // src/lib/config.ts
67
+ import { readFile, writeFile, mkdir, chmod } from "fs/promises";
68
+ import { readFileSync, existsSync, renameSync } from "fs";
69
+ import path from "path";
70
+ import os from "os";
71
+ function resolveDataDir() {
72
+ if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
73
+ if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
74
+ const newDir = path.join(os.homedir(), ".exe-os");
75
+ const legacyDir = path.join(os.homedir(), ".exe-mem");
76
+ if (!existsSync(newDir) && existsSync(legacyDir)) {
77
+ try {
78
+ renameSync(legacyDir, newDir);
79
+ process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
80
+ `);
81
+ } catch {
82
+ return legacyDir;
83
+ }
84
+ }
85
+ return newDir;
86
+ }
87
+ function migrateLegacyConfig(raw) {
88
+ if ("r2" in raw) {
89
+ process.stderr.write(
90
+ "[exe-os] Warning: config.json contains deprecated 'r2' field from v1.0. R2 sync has been replaced in v1.1. The 'r2' field will be ignored.\n"
91
+ );
92
+ delete raw.r2;
93
+ }
94
+ if ("syncIntervalMs" in raw) {
95
+ delete raw.syncIntervalMs;
96
+ }
97
+ return raw;
98
+ }
99
+ function migrateConfig(raw) {
100
+ const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
101
+ let currentVersion = fromVersion;
102
+ let migrated = false;
103
+ if (currentVersion > CURRENT_CONFIG_VERSION) {
104
+ return { config: raw, migrated: false, fromVersion };
105
+ }
106
+ for (const migration of CONFIG_MIGRATIONS) {
107
+ if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
108
+ raw = migration.migrate(raw);
109
+ currentVersion = migration.to;
110
+ migrated = true;
111
+ }
112
+ }
113
+ return { config: raw, migrated, fromVersion };
114
+ }
115
+ function normalizeScalingRoadmap(raw) {
116
+ const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
117
+ const userRoadmap = raw.scalingRoadmap ?? {};
118
+ const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
119
+ if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
120
+ userAuto.enabled = raw.rerankerEnabled;
121
+ }
122
+ raw.scalingRoadmap = {
123
+ ...userRoadmap,
124
+ rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
125
+ };
126
+ }
127
+ function normalizeSessionLifecycle(raw) {
128
+ const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
129
+ const userSL = raw.sessionLifecycle ?? {};
130
+ raw.sessionLifecycle = { ...defaultSL, ...userSL };
131
+ }
132
+ function normalizeAutoUpdate(raw) {
133
+ const defaultAU = DEFAULT_CONFIG.autoUpdate;
134
+ const userAU = raw.autoUpdate ?? {};
135
+ raw.autoUpdate = { ...defaultAU, ...userAU };
136
+ }
137
+ async function loadConfig() {
138
+ const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
139
+ await mkdir(dir, { recursive: true });
140
+ const configPath = path.join(dir, "config.json");
141
+ if (!existsSync(configPath)) {
142
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
143
+ }
144
+ const raw = await readFile(configPath, "utf-8");
145
+ try {
146
+ let parsed = JSON.parse(raw);
147
+ parsed = migrateLegacyConfig(parsed);
148
+ const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
149
+ if (migrated) {
150
+ process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
151
+ `);
152
+ try {
153
+ await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
154
+ } catch {
155
+ }
156
+ }
157
+ normalizeScalingRoadmap(migratedCfg);
158
+ normalizeSessionLifecycle(migratedCfg);
159
+ normalizeAutoUpdate(migratedCfg);
160
+ const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
161
+ if (config.dbPath.startsWith("~")) {
162
+ config.dbPath = config.dbPath.replace(/^~/, os.homedir());
163
+ }
164
+ return config;
165
+ } catch {
166
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
167
+ }
168
+ }
169
+ var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
170
+ var init_config = __esm({
171
+ "src/lib/config.ts"() {
172
+ "use strict";
173
+ EXE_AI_DIR = resolveDataDir();
174
+ DB_PATH = path.join(EXE_AI_DIR, "memories.db");
175
+ MODELS_DIR = path.join(EXE_AI_DIR, "models");
176
+ CONFIG_PATH = path.join(EXE_AI_DIR, "config.json");
177
+ LEGACY_LANCE_PATH = path.join(EXE_AI_DIR, "local.lance");
178
+ CURRENT_CONFIG_VERSION = 1;
179
+ DEFAULT_CONFIG = {
180
+ config_version: CURRENT_CONFIG_VERSION,
181
+ dbPath: DB_PATH,
182
+ modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
183
+ embeddingDim: 1024,
184
+ batchSize: 20,
185
+ flushIntervalMs: 1e4,
186
+ autoIngestion: true,
187
+ autoRetrieval: true,
188
+ searchMode: "hybrid",
189
+ hookSearchMode: "hybrid",
190
+ fileGrepEnabled: true,
191
+ splashEffect: true,
192
+ consolidationEnabled: true,
193
+ consolidationIntervalMs: 6 * 60 * 60 * 1e3,
194
+ consolidationModel: "claude-haiku-4-5-20251001",
195
+ consolidationMaxCallsPerRun: 20,
196
+ selfQueryRouter: true,
197
+ selfQueryModel: "claude-haiku-4-5-20251001",
198
+ rerankerEnabled: true,
199
+ scalingRoadmap: {
200
+ rerankerAutoTrigger: {
201
+ enabled: true,
202
+ broadQueryMinCardinality: 5e4,
203
+ fetchTopK: 150,
204
+ returnTopK: 5
205
+ }
206
+ },
207
+ graphRagEnabled: true,
208
+ wikiEnabled: false,
209
+ wikiUrl: "",
210
+ wikiApiKey: "",
211
+ wikiSyncIntervalMs: 30 * 60 * 1e3,
212
+ wikiWorkspaceMapping: {},
213
+ wikiAutoUpdate: true,
214
+ wikiAutoUpdateThreshold: 0.5,
215
+ wikiAutoUpdateCreateNew: true,
216
+ skillLearning: true,
217
+ skillThreshold: 3,
218
+ skillModel: "claude-haiku-4-5-20251001",
219
+ exeHeartbeat: {
220
+ enabled: true,
221
+ intervalSeconds: 60,
222
+ staleInProgressThresholdHours: 2
223
+ },
224
+ sessionLifecycle: {
225
+ idleKillEnabled: true,
226
+ idleKillTicksRequired: 3,
227
+ idleKillIntercomAckWindowMs: 1e4,
228
+ maxAutoInstances: 10
229
+ },
230
+ autoUpdate: {
231
+ checkOnBoot: true,
232
+ autoInstall: false,
233
+ checkIntervalMs: 24 * 60 * 60 * 1e3
234
+ }
235
+ };
236
+ CONFIG_MIGRATIONS = [
237
+ {
238
+ from: 0,
239
+ to: 1,
240
+ migrate: (cfg) => {
241
+ cfg.config_version = 1;
242
+ return cfg;
243
+ }
244
+ }
245
+ ];
246
+ }
247
+ });
248
+
249
+ // src/lib/employees.ts
250
+ import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
251
+ import { existsSync as existsSync2, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
252
+ import { execSync } from "child_process";
253
+ import path2 from "path";
254
+ import os2 from "os";
255
+ function normalizeRole(role) {
256
+ return (role ?? "").trim().toLowerCase();
257
+ }
258
+ function isCoordinatorRole(role) {
259
+ return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
260
+ }
261
+ function getCoordinatorEmployee(employees) {
262
+ return employees.find((e) => isCoordinatorRole(e.role));
263
+ }
264
+ function getCoordinatorName(employees = loadEmployeesSync()) {
265
+ return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
266
+ }
267
+ function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
268
+ if (!existsSync2(employeesPath)) return [];
269
+ try {
270
+ return JSON.parse(readFileSync2(employeesPath, "utf-8"));
271
+ } catch {
272
+ return [];
273
+ }
274
+ }
275
+ var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
276
+ var init_employees = __esm({
277
+ "src/lib/employees.ts"() {
278
+ "use strict";
279
+ init_config();
280
+ EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
281
+ DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
282
+ COORDINATOR_ROLE = "COO";
283
+ }
284
+ });
285
+
66
286
  // src/lib/database.ts
67
287
  import { createClient } from "@libsql/client";
68
288
  async function initDatabase(config) {
@@ -199,22 +419,24 @@ async function ensureSchema() {
199
419
  ON behaviors(agent_id, active);
200
420
  `);
201
421
  try {
422
+ const coordinatorName = getCoordinatorName();
202
423
  const existing = await client.execute({
203
- sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = 'exe'",
204
- args: []
424
+ sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
425
+ args: [coordinatorName]
205
426
  });
206
427
  if (Number(existing.rows[0]?.cnt) === 0) {
207
- await client.executeMultiple(`
208
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
209
- VALUES
210
- (hex(randomblob(16)), 'exe', NULL, 'workflow', 'Don''t ask "keep going?" \u2014 just keep executing phases/plans autonomously', 1, '2026-03-25T00:00:00Z', '2026-03-25T00:00:00Z');
211
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
212
- VALUES
213
- (hex(randomblob(16)), 'exe', NULL, 'tool-use', 'Always use create_task MCP tool, never write .md files directly for task creation', 1, '2026-03-25T00:00:00Z', '2026-03-25T00:00:00Z');
214
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
215
- VALUES
216
- (hex(randomblob(16)), 'exe', NULL, 'workflow', 'Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission', 1, '2026-03-25T00:00:00Z', '2026-03-25T00:00:00Z');
217
- `);
428
+ const seededAt = "2026-03-25T00:00:00Z";
429
+ for (const [domain, content] of [
430
+ ["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
431
+ ["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
432
+ ["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
433
+ ]) {
434
+ await client.execute({
435
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
436
+ VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
437
+ args: [coordinatorName, domain, content, seededAt, seededAt]
438
+ });
439
+ }
218
440
  }
219
441
  } catch {
220
442
  }
@@ -906,204 +1128,49 @@ async function ensureSchema() {
906
1128
  } catch {
907
1129
  }
908
1130
  }
909
- }
910
- var _client, _resilientClient, initTurso;
911
- var init_database = __esm({
912
- "src/lib/database.ts"() {
913
- "use strict";
914
- init_db_retry();
915
- _client = null;
916
- _resilientClient = null;
917
- initTurso = initDatabase;
918
- }
919
- });
920
-
921
- // src/lib/config.ts
922
- import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
923
- import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
924
- import path2 from "path";
925
- import os2 from "os";
926
- function resolveDataDir() {
927
- if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
928
- if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
929
- const newDir = path2.join(os2.homedir(), ".exe-os");
930
- const legacyDir = path2.join(os2.homedir(), ".exe-mem");
931
- if (!existsSync2(newDir) && existsSync2(legacyDir)) {
932
- try {
933
- renameSync(legacyDir, newDir);
934
- process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
935
- `);
936
- } catch {
937
- return legacyDir;
938
- }
1131
+ try {
1132
+ await client.execute({
1133
+ sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
1134
+ args: []
1135
+ });
1136
+ } catch {
939
1137
  }
940
- return newDir;
941
- }
942
- function migrateLegacyConfig(raw) {
943
- if ("r2" in raw) {
944
- process.stderr.write(
945
- "[exe-os] Warning: config.json contains deprecated 'r2' field from v1.0. R2 sync has been replaced in v1.1. The 'r2' field will be ignored.\n"
1138
+ try {
1139
+ await client.execute(
1140
+ `CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
946
1141
  );
947
- delete raw.r2;
948
- }
949
- if ("syncIntervalMs" in raw) {
950
- delete raw.syncIntervalMs;
951
- }
952
- return raw;
953
- }
954
- function migrateConfig(raw) {
955
- const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
956
- let currentVersion = fromVersion;
957
- let migrated = false;
958
- if (currentVersion > CURRENT_CONFIG_VERSION) {
959
- return { config: raw, migrated: false, fromVersion };
960
- }
961
- for (const migration of CONFIG_MIGRATIONS) {
962
- if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
963
- raw = migration.migrate(raw);
964
- currentVersion = migration.to;
965
- migrated = true;
966
- }
1142
+ } catch {
967
1143
  }
968
- return { config: raw, migrated, fromVersion };
969
- }
970
- function normalizeScalingRoadmap(raw) {
971
- const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
972
- const userRoadmap = raw.scalingRoadmap ?? {};
973
- const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
974
- if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
975
- userAuto.enabled = raw.rerankerEnabled;
1144
+ try {
1145
+ await client.execute({
1146
+ sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
1147
+ args: []
1148
+ });
1149
+ } catch {
976
1150
  }
977
- raw.scalingRoadmap = {
978
- ...userRoadmap,
979
- rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
980
- };
981
- }
982
- function normalizeSessionLifecycle(raw) {
983
- const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
984
- const userSL = raw.sessionLifecycle ?? {};
985
- raw.sessionLifecycle = { ...defaultSL, ...userSL };
986
- }
987
- function normalizeAutoUpdate(raw) {
988
- const defaultAU = DEFAULT_CONFIG.autoUpdate;
989
- const userAU = raw.autoUpdate ?? {};
990
- raw.autoUpdate = { ...defaultAU, ...userAU };
991
- }
992
- async function loadConfig() {
993
- const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
994
- await mkdir2(dir, { recursive: true });
995
- const configPath = path2.join(dir, "config.json");
996
- if (!existsSync2(configPath)) {
997
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1151
+ try {
1152
+ await client.execute(
1153
+ `CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
1154
+ );
1155
+ } catch {
998
1156
  }
999
- const raw = await readFile2(configPath, "utf-8");
1000
1157
  try {
1001
- let parsed = JSON.parse(raw);
1002
- parsed = migrateLegacyConfig(parsed);
1003
- const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
1004
- if (migrated) {
1005
- process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
1006
- `);
1007
- try {
1008
- await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
1009
- } catch {
1010
- }
1011
- }
1012
- normalizeScalingRoadmap(migratedCfg);
1013
- normalizeSessionLifecycle(migratedCfg);
1014
- normalizeAutoUpdate(migratedCfg);
1015
- const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
1016
- if (config.dbPath.startsWith("~")) {
1017
- config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
1018
- }
1019
- return config;
1158
+ await client.execute({
1159
+ sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
1160
+ args: []
1161
+ });
1020
1162
  } catch {
1021
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1022
1163
  }
1023
1164
  }
1024
- var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
1025
- var init_config = __esm({
1026
- "src/lib/config.ts"() {
1165
+ var _client, _resilientClient, initTurso;
1166
+ var init_database = __esm({
1167
+ "src/lib/database.ts"() {
1027
1168
  "use strict";
1028
- EXE_AI_DIR = resolveDataDir();
1029
- DB_PATH = path2.join(EXE_AI_DIR, "memories.db");
1030
- MODELS_DIR = path2.join(EXE_AI_DIR, "models");
1031
- CONFIG_PATH = path2.join(EXE_AI_DIR, "config.json");
1032
- LEGACY_LANCE_PATH = path2.join(EXE_AI_DIR, "local.lance");
1033
- CURRENT_CONFIG_VERSION = 1;
1034
- DEFAULT_CONFIG = {
1035
- config_version: CURRENT_CONFIG_VERSION,
1036
- dbPath: DB_PATH,
1037
- modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
1038
- embeddingDim: 1024,
1039
- batchSize: 20,
1040
- flushIntervalMs: 1e4,
1041
- autoIngestion: true,
1042
- autoRetrieval: true,
1043
- searchMode: "hybrid",
1044
- hookSearchMode: "hybrid",
1045
- fileGrepEnabled: true,
1046
- splashEffect: true,
1047
- consolidationEnabled: true,
1048
- consolidationIntervalMs: 6 * 60 * 60 * 1e3,
1049
- consolidationModel: "claude-haiku-4-5-20251001",
1050
- consolidationMaxCallsPerRun: 20,
1051
- selfQueryRouter: true,
1052
- selfQueryModel: "claude-haiku-4-5-20251001",
1053
- rerankerEnabled: true,
1054
- scalingRoadmap: {
1055
- rerankerAutoTrigger: {
1056
- enabled: true,
1057
- broadQueryMinCardinality: 5e4,
1058
- fetchTopK: 150,
1059
- returnTopK: 5
1060
- }
1061
- },
1062
- graphRagEnabled: true,
1063
- wikiEnabled: false,
1064
- wikiUrl: "",
1065
- wikiApiKey: "",
1066
- wikiSyncIntervalMs: 30 * 60 * 1e3,
1067
- wikiWorkspaceMapping: {
1068
- exe: "Executive",
1069
- yoshi: "Engineering",
1070
- mari: "Marketing",
1071
- tom: "Engineering",
1072
- sasha: "Production"
1073
- },
1074
- wikiAutoUpdate: true,
1075
- wikiAutoUpdateThreshold: 0.5,
1076
- wikiAutoUpdateCreateNew: true,
1077
- skillLearning: true,
1078
- skillThreshold: 3,
1079
- skillModel: "claude-haiku-4-5-20251001",
1080
- exeHeartbeat: {
1081
- enabled: true,
1082
- intervalSeconds: 60,
1083
- staleInProgressThresholdHours: 2
1084
- },
1085
- sessionLifecycle: {
1086
- idleKillEnabled: true,
1087
- idleKillTicksRequired: 3,
1088
- idleKillIntercomAckWindowMs: 1e4,
1089
- maxAutoInstances: 10
1090
- },
1091
- autoUpdate: {
1092
- checkOnBoot: true,
1093
- autoInstall: false,
1094
- checkIntervalMs: 24 * 60 * 60 * 1e3
1095
- }
1096
- };
1097
- CONFIG_MIGRATIONS = [
1098
- {
1099
- from: 0,
1100
- to: 1,
1101
- migrate: (cfg) => {
1102
- cfg.config_version = 1;
1103
- return cfg;
1104
- }
1105
- }
1106
- ];
1169
+ init_db_retry();
1170
+ init_employees();
1171
+ _client = null;
1172
+ _resilientClient = null;
1173
+ initTurso = initDatabase;
1107
1174
  }
1108
1175
  });
1109
1176
 
@@ -1120,12 +1187,12 @@ __export(shard_manager_exports, {
1120
1187
  listShards: () => listShards,
1121
1188
  shardExists: () => shardExists
1122
1189
  });
1123
- import path3 from "path";
1124
- import { existsSync as existsSync3, mkdirSync, readdirSync } from "fs";
1190
+ import path4 from "path";
1191
+ import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
1125
1192
  import { createClient as createClient2 } from "@libsql/client";
1126
1193
  function initShardManager(encryptionKey) {
1127
1194
  _encryptionKey = encryptionKey;
1128
- if (!existsSync3(SHARDS_DIR)) {
1195
+ if (!existsSync4(SHARDS_DIR)) {
1129
1196
  mkdirSync(SHARDS_DIR, { recursive: true });
1130
1197
  }
1131
1198
  _shardingEnabled = true;
@@ -1146,7 +1213,7 @@ function getShardClient(projectName) {
1146
1213
  }
1147
1214
  const cached = _shards.get(safeName);
1148
1215
  if (cached) return cached;
1149
- const dbPath = path3.join(SHARDS_DIR, `${safeName}.db`);
1216
+ const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
1150
1217
  const client = createClient2({
1151
1218
  url: `file:${dbPath}`,
1152
1219
  encryptionKey: _encryptionKey
@@ -1156,10 +1223,10 @@ function getShardClient(projectName) {
1156
1223
  }
1157
1224
  function shardExists(projectName) {
1158
1225
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
1159
- return existsSync3(path3.join(SHARDS_DIR, `${safeName}.db`));
1226
+ return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
1160
1227
  }
1161
1228
  function listShards() {
1162
- if (!existsSync3(SHARDS_DIR)) return [];
1229
+ if (!existsSync4(SHARDS_DIR)) return [];
1163
1230
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
1164
1231
  }
1165
1232
  async function ensureShardSchema(client) {
@@ -1229,7 +1296,11 @@ async function ensureShardSchema(client) {
1229
1296
  "ALTER TABLE memories ADD COLUMN source_path TEXT",
1230
1297
  "ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
1231
1298
  "ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
1232
- "ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
1299
+ "ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
1300
+ // MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
1301
+ "ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
1302
+ "ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
1303
+ "ALTER TABLE memories ADD COLUMN trajectory TEXT"
1233
1304
  ]) {
1234
1305
  try {
1235
1306
  await client.execute(col);
@@ -1341,7 +1412,7 @@ var init_shard_manager = __esm({
1341
1412
  "src/lib/shard-manager.ts"() {
1342
1413
  "use strict";
1343
1414
  init_config();
1344
- SHARDS_DIR = path3.join(EXE_AI_DIR, "shards");
1415
+ SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
1345
1416
  _shards = /* @__PURE__ */ new Map();
1346
1417
  _encryptionKey = null;
1347
1418
  _shardingEnabled = false;
@@ -1359,26 +1430,26 @@ var init_platform_procedures = __esm({
1359
1430
  title: "What is exe-os \u2014 the operating model every agent must understand",
1360
1431
  domain: "architecture",
1361
1432
  priority: "p0",
1362
- content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO (exe), CTO (yoshi), CMO (mari), engineers (tom), content (sasha). Each agent has identity, expertise, and experience layers \u2014 persistent memory that makes them better over time. All data is local-first, E2EE, owned by the user. The MCP server is the ONLY data interface \u2014 never access the DB directly."
1433
+ content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO, CTO, CMO, engineers, and content production specialists. Each agent has identity, expertise, and experience layers \u2014 persistent memory that makes them better over time. All data is local-first, E2EE, owned by the user. The MCP server is the ONLY data interface \u2014 never access the DB directly."
1363
1434
  },
1364
1435
  {
1365
1436
  title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
1366
1437
  domain: "architecture",
1367
1438
  priority: "p0",
1368
- content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC, runs /exe to boot the COO. exe manages employees in tmux sessions. Each exeN is a separate CC window/project. Employees (yoshi, tom, mari) run in their own tmux panes via create_task auto-spawn. The founder talks to exe; exe orchestrates the team. CC is the shell, exe-os is the brain."
1439
+ content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC and boots the COO. The COO manages employees in tmux sessions. Each coordinator session is a separate CC window/project. Employees run in their own tmux panes via create_task auto-spawn. The founder talks to the COO; the COO orchestrates the team. CC is the shell, exe-os is the brain."
1369
1440
  },
1370
1441
  {
1371
- title: "Sessions explained \u2014 what exeN means and how projects work",
1442
+ title: "Sessions explained \u2014 coordinator session names and projects",
1372
1443
  domain: "architecture",
1373
1444
  priority: "p0",
1374
- content: "Each exeN (exe1, exe2, exe3) is an isolated project session. exe1 might be exe-os development, exe2 might be exe-wiki. Each session spawns its own employees: exe1\u2192yoshi-exe1\u2192tom-exe1. Sessions share the same memory DB but tasks are scoped to the session that created them. A founder can run multiple projects simultaneously. Sessions never interfere with each other."
1445
+ content: "Each coordinator session is an isolated project session. One might be exe-os development, another might be exe-wiki. Each session spawns its own employees using {employee}-{coordinatorSession}. Sessions share the same memory DB but tasks are scoped to the session that created them. A founder can run multiple projects simultaneously. Sessions never interfere with each other."
1375
1446
  },
1376
1447
  // --- Hierarchy and dispatch ---
1377
1448
  {
1378
1449
  title: "Chain of command \u2014 who talks to whom",
1379
1450
  domain: "workflow",
1380
1451
  priority: "p0",
1381
- content: "Founder \u2192 exe (COO) \u2192 yoshi (CTO) / mari (CMO). Yoshi \u2192 tom (engineer). Mari \u2192 sasha (content). Never skip levels: exe never assigns directly to tom. Tom never reports directly to exe. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
1452
+ content: "Founder -> COO -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the COO does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
1382
1453
  },
1383
1454
  {
1384
1455
  title: "Single dispatch path \u2014 create_task only",
@@ -1388,30 +1459,30 @@ var init_platform_procedures = __esm({
1388
1459
  },
1389
1460
  // --- Session isolation ---
1390
1461
  {
1391
- title: "Session scoping \u2014 stay in your exe boundary",
1462
+ title: "Session scoping \u2014 stay in your coordinator boundary",
1392
1463
  domain: "security",
1393
1464
  priority: "p0",
1394
- content: "Session scoping is mandatory. Managers dispatch to workers within their own exe session ONLY. exe1\u2192yoshi-exe1\u2192tom-exe1. exe2\u2192yoshi-exe2\u2192tom2-exe2. Cross-session dispatch is blocked by the system. Verify session names before dispatch. Tasks are scoped to the creating exe session."
1465
+ content: "Session scoping is mandatory. Managers dispatch to workers within their own coordinator session ONLY. Employee sessions use {employee}-{coordinatorSession}. Cross-session dispatch is blocked by the system. Verify session names before dispatch. Tasks are scoped to the creating coordinator session."
1395
1466
  },
1396
1467
  {
1397
1468
  title: "Session isolation \u2014 never touch another session's work",
1398
1469
  domain: "workflow",
1399
1470
  priority: "p0",
1400
- content: `Sessions are isolated. exeN owns ONLY tasks it dispatched. (1) Never close/update/cancel tasks from another exe session. (2) Never review work from a different session \u2014 report "belongs to exeN" and skip. (3) Ignore other sessions' items in list_tasks results. (4) Employees inherit session: yoshi-exe1 works ONLY on exe1 tasks. Cross-session work is a system violation.`
1471
+ content: "Sessions are isolated. A coordinator session owns ONLY tasks it dispatched. (1) Never close/update/cancel tasks from another coordinator session. (2) Never review work from a different session \u2014 report that it belongs to another session and skip. (3) Ignore other sessions' items in list_tasks results. (4) Employees inherit session: employee sessions work ONLY on their parent coordinator session's tasks. Cross-session work is a system violation."
1401
1472
  },
1402
1473
  // --- Engineering: session scoping in code ---
1403
1474
  {
1404
1475
  title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
1405
1476
  domain: "architecture",
1406
1477
  priority: "p0",
1407
- content: "Every DB query, notification, review count, and task operation MUST be scoped on 3 dimensions: (1) Session \u2014 filter by session_scope matching current exeN. (2) Project \u2014 filter by project_name. (3) Role \u2014 agents only see data at their hierarchy level. When writing ANY function that touches tasks, reviews, messages, or notifications: always accept a sessionScope parameter and pass it to the SQL WHERE clause. Unscoped queries are bugs. Test by running 2+ exe sessions simultaneously."
1478
+ content: "Every DB query, notification, review count, and task operation MUST be scoped on 3 dimensions: (1) Session \u2014 filter by session_scope matching the current coordinator session. (2) Project \u2014 filter by project_name. (3) Role \u2014 agents only see data at their hierarchy level. When writing ANY function that touches tasks, reviews, messages, or notifications: always accept a sessionScope parameter and pass it to the SQL WHERE clause. Unscoped queries are bugs. Test by running 2+ coordinator sessions simultaneously."
1408
1479
  },
1409
1480
  // --- Hard constraints ---
1410
1481
  {
1411
1482
  title: "What you CANNOT do in exe-os \u2014 hard constraints",
1412
1483
  domain: "security",
1413
1484
  priority: "p0",
1414
- content: "NEVER: (1) Access the database directly \u2014 it's SQLCipher encrypted, always fails. Use MCP tools only. (2) Manually spawn tmux sessions \u2014 create_task handles it. (3) Run git checkout main \u2014 agents work in worktrees. (4) Modify another agent's in-progress task. (5) Push to remote \u2014 exe reviews and pushes. (6) Skip update_task(done) \u2014 it's the ONLY way your work gets reviewed. (7) Run git init."
1485
+ content: "NEVER: (1) Access the database directly \u2014 it's SQLCipher encrypted, always fails. Use MCP tools only. (2) Manually spawn tmux sessions \u2014 create_task handles it. (3) Run git checkout main \u2014 agents work in worktrees. (4) Modify another agent's in-progress task. (5) Push to remote \u2014 the COO reviews and pushes. (6) Skip update_task(done) \u2014 it's the ONLY way your work gets reviewed. (7) Run git init."
1415
1486
  },
1416
1487
  // --- Operations ---
1417
1488
  {
@@ -1532,23 +1603,23 @@ ${p.content}`).join("\n\n");
1532
1603
  // src/lib/schedules.ts
1533
1604
  init_database();
1534
1605
  import crypto from "crypto";
1535
- import { execSync } from "child_process";
1606
+ import { execSync as execSync2 } from "child_process";
1536
1607
 
1537
1608
  // src/lib/store.ts
1538
1609
  init_database();
1539
1610
 
1540
1611
  // src/lib/keychain.ts
1541
- import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1542
- import { existsSync } from "fs";
1543
- import path from "path";
1544
- import os from "os";
1612
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
1613
+ import { existsSync as existsSync3 } from "fs";
1614
+ import path3 from "path";
1615
+ import os3 from "os";
1545
1616
  var SERVICE = "exe-mem";
1546
1617
  var ACCOUNT = "master-key";
1547
1618
  function getKeyDir() {
1548
- return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path.join(os.homedir(), ".exe-os");
1619
+ return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
1549
1620
  }
1550
1621
  function getKeyPath() {
1551
- return path.join(getKeyDir(), "master.key");
1622
+ return path3.join(getKeyDir(), "master.key");
1552
1623
  }
1553
1624
  async function tryKeytar() {
1554
1625
  try {
@@ -1569,11 +1640,11 @@ async function getMasterKey() {
1569
1640
  }
1570
1641
  }
1571
1642
  const keyPath = getKeyPath();
1572
- if (!existsSync(keyPath)) {
1643
+ if (!existsSync3(keyPath)) {
1573
1644
  return null;
1574
1645
  }
1575
1646
  try {
1576
- const content = await readFile(keyPath, "utf-8");
1647
+ const content = await readFile3(keyPath, "utf-8");
1577
1648
  return Buffer.from(content.trim(), "base64");
1578
1649
  } catch {
1579
1650
  return null;
@@ -1853,7 +1924,7 @@ function addToCrontab(id, cron, prompt, projectDir) {
1853
1924
  const cwd = projectDir ? `cd ${JSON.stringify(projectDir)} && ` : "";
1854
1925
  const escapedPrompt = prompt.replace(/"/g, '\\"');
1855
1926
  const entry = `${cron} ${cwd}claude -p --dangerously-skip-permissions "${escapedPrompt}" # exe-schedule:${id}`;
1856
- execSync(
1927
+ execSync2(
1857
1928
  `(crontab -l 2>/dev/null; echo ${JSON.stringify(entry)}) | crontab -`,
1858
1929
  { timeout: 5e3, stdio: "ignore" }
1859
1930
  );
@@ -1862,7 +1933,7 @@ function addToCrontab(id, cron, prompt, projectDir) {
1862
1933
  }
1863
1934
  function removeFromCrontab(id) {
1864
1935
  try {
1865
- execSync(
1936
+ execSync2(
1866
1937
  `crontab -l 2>/dev/null | grep -v "exe-schedule:${id}" | crontab -`,
1867
1938
  { timeout: 5e3, stdio: "ignore" }
1868
1939
  );