@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) {
@@ -196,22 +416,24 @@ async function ensureSchema() {
196
416
  ON behaviors(agent_id, active);
197
417
  `);
198
418
  try {
419
+ const coordinatorName = getCoordinatorName();
199
420
  const existing = await client.execute({
200
- sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = 'exe'",
201
- args: []
421
+ sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
422
+ args: [coordinatorName]
202
423
  });
203
424
  if (Number(existing.rows[0]?.cnt) === 0) {
204
- await client.executeMultiple(`
205
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
206
- VALUES
207
- (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');
208
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
209
- VALUES
210
- (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');
211
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
212
- VALUES
213
- (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');
214
- `);
425
+ const seededAt = "2026-03-25T00:00:00Z";
426
+ for (const [domain, content] of [
427
+ ["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
428
+ ["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
429
+ ["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
430
+ ]) {
431
+ await client.execute({
432
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
433
+ VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
434
+ args: [coordinatorName, domain, content, seededAt, seededAt]
435
+ });
436
+ }
215
437
  }
216
438
  } catch {
217
439
  }
@@ -903,204 +1125,49 @@ async function ensureSchema() {
903
1125
  } catch {
904
1126
  }
905
1127
  }
906
- }
907
- var _client, _resilientClient, initTurso;
908
- var init_database = __esm({
909
- "src/lib/database.ts"() {
910
- "use strict";
911
- init_db_retry();
912
- _client = null;
913
- _resilientClient = null;
914
- initTurso = initDatabase;
915
- }
916
- });
917
-
918
- // src/lib/config.ts
919
- import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
920
- import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
921
- import path2 from "path";
922
- import os2 from "os";
923
- function resolveDataDir() {
924
- if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
925
- if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
926
- const newDir = path2.join(os2.homedir(), ".exe-os");
927
- const legacyDir = path2.join(os2.homedir(), ".exe-mem");
928
- if (!existsSync2(newDir) && existsSync2(legacyDir)) {
929
- try {
930
- renameSync(legacyDir, newDir);
931
- process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
932
- `);
933
- } catch {
934
- return legacyDir;
935
- }
1128
+ try {
1129
+ await client.execute({
1130
+ sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
1131
+ args: []
1132
+ });
1133
+ } catch {
936
1134
  }
937
- return newDir;
938
- }
939
- function migrateLegacyConfig(raw) {
940
- if ("r2" in raw) {
941
- process.stderr.write(
942
- "[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"
1135
+ try {
1136
+ await client.execute(
1137
+ `CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
943
1138
  );
944
- delete raw.r2;
945
- }
946
- if ("syncIntervalMs" in raw) {
947
- delete raw.syncIntervalMs;
948
- }
949
- return raw;
950
- }
951
- function migrateConfig(raw) {
952
- const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
953
- let currentVersion = fromVersion;
954
- let migrated = false;
955
- if (currentVersion > CURRENT_CONFIG_VERSION) {
956
- return { config: raw, migrated: false, fromVersion };
957
- }
958
- for (const migration of CONFIG_MIGRATIONS) {
959
- if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
960
- raw = migration.migrate(raw);
961
- currentVersion = migration.to;
962
- migrated = true;
963
- }
1139
+ } catch {
964
1140
  }
965
- return { config: raw, migrated, fromVersion };
966
- }
967
- function normalizeScalingRoadmap(raw) {
968
- const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
969
- const userRoadmap = raw.scalingRoadmap ?? {};
970
- const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
971
- if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
972
- userAuto.enabled = raw.rerankerEnabled;
1141
+ try {
1142
+ await client.execute({
1143
+ sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
1144
+ args: []
1145
+ });
1146
+ } catch {
973
1147
  }
974
- raw.scalingRoadmap = {
975
- ...userRoadmap,
976
- rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
977
- };
978
- }
979
- function normalizeSessionLifecycle(raw) {
980
- const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
981
- const userSL = raw.sessionLifecycle ?? {};
982
- raw.sessionLifecycle = { ...defaultSL, ...userSL };
983
- }
984
- function normalizeAutoUpdate(raw) {
985
- const defaultAU = DEFAULT_CONFIG.autoUpdate;
986
- const userAU = raw.autoUpdate ?? {};
987
- raw.autoUpdate = { ...defaultAU, ...userAU };
988
- }
989
- async function loadConfig() {
990
- const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
991
- await mkdir2(dir, { recursive: true });
992
- const configPath = path2.join(dir, "config.json");
993
- if (!existsSync2(configPath)) {
994
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1148
+ try {
1149
+ await client.execute(
1150
+ `CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
1151
+ );
1152
+ } catch {
995
1153
  }
996
- const raw = await readFile2(configPath, "utf-8");
997
1154
  try {
998
- let parsed = JSON.parse(raw);
999
- parsed = migrateLegacyConfig(parsed);
1000
- const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
1001
- if (migrated) {
1002
- process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
1003
- `);
1004
- try {
1005
- await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
1006
- } catch {
1007
- }
1008
- }
1009
- normalizeScalingRoadmap(migratedCfg);
1010
- normalizeSessionLifecycle(migratedCfg);
1011
- normalizeAutoUpdate(migratedCfg);
1012
- const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
1013
- if (config.dbPath.startsWith("~")) {
1014
- config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
1015
- }
1016
- return config;
1155
+ await client.execute({
1156
+ sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
1157
+ args: []
1158
+ });
1017
1159
  } catch {
1018
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1019
1160
  }
1020
1161
  }
1021
- var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
1022
- var init_config = __esm({
1023
- "src/lib/config.ts"() {
1162
+ var _client, _resilientClient, initTurso;
1163
+ var init_database = __esm({
1164
+ "src/lib/database.ts"() {
1024
1165
  "use strict";
1025
- EXE_AI_DIR = resolveDataDir();
1026
- DB_PATH = path2.join(EXE_AI_DIR, "memories.db");
1027
- MODELS_DIR = path2.join(EXE_AI_DIR, "models");
1028
- CONFIG_PATH = path2.join(EXE_AI_DIR, "config.json");
1029
- LEGACY_LANCE_PATH = path2.join(EXE_AI_DIR, "local.lance");
1030
- CURRENT_CONFIG_VERSION = 1;
1031
- DEFAULT_CONFIG = {
1032
- config_version: CURRENT_CONFIG_VERSION,
1033
- dbPath: DB_PATH,
1034
- modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
1035
- embeddingDim: 1024,
1036
- batchSize: 20,
1037
- flushIntervalMs: 1e4,
1038
- autoIngestion: true,
1039
- autoRetrieval: true,
1040
- searchMode: "hybrid",
1041
- hookSearchMode: "hybrid",
1042
- fileGrepEnabled: true,
1043
- splashEffect: true,
1044
- consolidationEnabled: true,
1045
- consolidationIntervalMs: 6 * 60 * 60 * 1e3,
1046
- consolidationModel: "claude-haiku-4-5-20251001",
1047
- consolidationMaxCallsPerRun: 20,
1048
- selfQueryRouter: true,
1049
- selfQueryModel: "claude-haiku-4-5-20251001",
1050
- rerankerEnabled: true,
1051
- scalingRoadmap: {
1052
- rerankerAutoTrigger: {
1053
- enabled: true,
1054
- broadQueryMinCardinality: 5e4,
1055
- fetchTopK: 150,
1056
- returnTopK: 5
1057
- }
1058
- },
1059
- graphRagEnabled: true,
1060
- wikiEnabled: false,
1061
- wikiUrl: "",
1062
- wikiApiKey: "",
1063
- wikiSyncIntervalMs: 30 * 60 * 1e3,
1064
- wikiWorkspaceMapping: {
1065
- exe: "Executive",
1066
- yoshi: "Engineering",
1067
- mari: "Marketing",
1068
- tom: "Engineering",
1069
- sasha: "Production"
1070
- },
1071
- wikiAutoUpdate: true,
1072
- wikiAutoUpdateThreshold: 0.5,
1073
- wikiAutoUpdateCreateNew: true,
1074
- skillLearning: true,
1075
- skillThreshold: 3,
1076
- skillModel: "claude-haiku-4-5-20251001",
1077
- exeHeartbeat: {
1078
- enabled: true,
1079
- intervalSeconds: 60,
1080
- staleInProgressThresholdHours: 2
1081
- },
1082
- sessionLifecycle: {
1083
- idleKillEnabled: true,
1084
- idleKillTicksRequired: 3,
1085
- idleKillIntercomAckWindowMs: 1e4,
1086
- maxAutoInstances: 10
1087
- },
1088
- autoUpdate: {
1089
- checkOnBoot: true,
1090
- autoInstall: false,
1091
- checkIntervalMs: 24 * 60 * 60 * 1e3
1092
- }
1093
- };
1094
- CONFIG_MIGRATIONS = [
1095
- {
1096
- from: 0,
1097
- to: 1,
1098
- migrate: (cfg) => {
1099
- cfg.config_version = 1;
1100
- return cfg;
1101
- }
1102
- }
1103
- ];
1166
+ init_db_retry();
1167
+ init_employees();
1168
+ _client = null;
1169
+ _resilientClient = null;
1170
+ initTurso = initDatabase;
1104
1171
  }
1105
1172
  });
1106
1173
 
@@ -1172,12 +1239,12 @@ __export(shard_manager_exports, {
1172
1239
  listShards: () => listShards,
1173
1240
  shardExists: () => shardExists
1174
1241
  });
1175
- import path3 from "path";
1176
- import { existsSync as existsSync3, mkdirSync, readdirSync } from "fs";
1242
+ import path4 from "path";
1243
+ import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
1177
1244
  import { createClient as createClient2 } from "@libsql/client";
1178
1245
  function initShardManager(encryptionKey) {
1179
1246
  _encryptionKey = encryptionKey;
1180
- if (!existsSync3(SHARDS_DIR)) {
1247
+ if (!existsSync4(SHARDS_DIR)) {
1181
1248
  mkdirSync(SHARDS_DIR, { recursive: true });
1182
1249
  }
1183
1250
  _shardingEnabled = true;
@@ -1198,7 +1265,7 @@ function getShardClient(projectName) {
1198
1265
  }
1199
1266
  const cached = _shards.get(safeName);
1200
1267
  if (cached) return cached;
1201
- const dbPath = path3.join(SHARDS_DIR, `${safeName}.db`);
1268
+ const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
1202
1269
  const client = createClient2({
1203
1270
  url: `file:${dbPath}`,
1204
1271
  encryptionKey: _encryptionKey
@@ -1208,10 +1275,10 @@ function getShardClient(projectName) {
1208
1275
  }
1209
1276
  function shardExists(projectName) {
1210
1277
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
1211
- return existsSync3(path3.join(SHARDS_DIR, `${safeName}.db`));
1278
+ return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
1212
1279
  }
1213
1280
  function listShards() {
1214
- if (!existsSync3(SHARDS_DIR)) return [];
1281
+ if (!existsSync4(SHARDS_DIR)) return [];
1215
1282
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
1216
1283
  }
1217
1284
  async function ensureShardSchema(client) {
@@ -1281,7 +1348,11 @@ async function ensureShardSchema(client) {
1281
1348
  "ALTER TABLE memories ADD COLUMN source_path TEXT",
1282
1349
  "ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
1283
1350
  "ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
1284
- "ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
1351
+ "ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
1352
+ // MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
1353
+ "ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
1354
+ "ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
1355
+ "ALTER TABLE memories ADD COLUMN trajectory TEXT"
1285
1356
  ]) {
1286
1357
  try {
1287
1358
  await client.execute(col);
@@ -1393,7 +1464,7 @@ var init_shard_manager = __esm({
1393
1464
  "src/lib/shard-manager.ts"() {
1394
1465
  "use strict";
1395
1466
  init_config();
1396
- SHARDS_DIR = path3.join(EXE_AI_DIR, "shards");
1467
+ SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
1397
1468
  _shards = /* @__PURE__ */ new Map();
1398
1469
  _encryptionKey = null;
1399
1470
  _shardingEnabled = false;
@@ -1411,26 +1482,26 @@ var init_platform_procedures = __esm({
1411
1482
  title: "What is exe-os \u2014 the operating model every agent must understand",
1412
1483
  domain: "architecture",
1413
1484
  priority: "p0",
1414
- 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."
1485
+ 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."
1415
1486
  },
1416
1487
  {
1417
1488
  title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
1418
1489
  domain: "architecture",
1419
1490
  priority: "p0",
1420
- 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."
1491
+ 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."
1421
1492
  },
1422
1493
  {
1423
- title: "Sessions explained \u2014 what exeN means and how projects work",
1494
+ title: "Sessions explained \u2014 coordinator session names and projects",
1424
1495
  domain: "architecture",
1425
1496
  priority: "p0",
1426
- 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."
1497
+ 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."
1427
1498
  },
1428
1499
  // --- Hierarchy and dispatch ---
1429
1500
  {
1430
1501
  title: "Chain of command \u2014 who talks to whom",
1431
1502
  domain: "workflow",
1432
1503
  priority: "p0",
1433
- 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."
1504
+ 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."
1434
1505
  },
1435
1506
  {
1436
1507
  title: "Single dispatch path \u2014 create_task only",
@@ -1440,30 +1511,30 @@ var init_platform_procedures = __esm({
1440
1511
  },
1441
1512
  // --- Session isolation ---
1442
1513
  {
1443
- title: "Session scoping \u2014 stay in your exe boundary",
1514
+ title: "Session scoping \u2014 stay in your coordinator boundary",
1444
1515
  domain: "security",
1445
1516
  priority: "p0",
1446
- 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."
1517
+ 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."
1447
1518
  },
1448
1519
  {
1449
1520
  title: "Session isolation \u2014 never touch another session's work",
1450
1521
  domain: "workflow",
1451
1522
  priority: "p0",
1452
- 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.`
1523
+ 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."
1453
1524
  },
1454
1525
  // --- Engineering: session scoping in code ---
1455
1526
  {
1456
1527
  title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
1457
1528
  domain: "architecture",
1458
1529
  priority: "p0",
1459
- 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."
1530
+ 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."
1460
1531
  },
1461
1532
  // --- Hard constraints ---
1462
1533
  {
1463
1534
  title: "What you CANNOT do in exe-os \u2014 hard constraints",
1464
1535
  domain: "security",
1465
1536
  priority: "p0",
1466
- 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."
1537
+ 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."
1467
1538
  },
1468
1539
  // --- Operations ---
1469
1540
  {
@@ -1582,18 +1653,18 @@ ${p.content}`).join("\n\n");
1582
1653
  });
1583
1654
 
1584
1655
  // src/lib/session-registry.ts
1585
- import path4 from "path";
1586
- import os3 from "os";
1656
+ import path5 from "path";
1657
+ import os4 from "os";
1587
1658
  var REGISTRY_PATH;
1588
1659
  var init_session_registry = __esm({
1589
1660
  "src/lib/session-registry.ts"() {
1590
1661
  "use strict";
1591
- REGISTRY_PATH = path4.join(os3.homedir(), ".exe-os", "session-registry.json");
1662
+ REGISTRY_PATH = path5.join(os4.homedir(), ".exe-os", "session-registry.json");
1592
1663
  }
1593
1664
  });
1594
1665
 
1595
1666
  // src/lib/session-key.ts
1596
- import { execSync } from "child_process";
1667
+ import { execSync as execSync2 } from "child_process";
1597
1668
  var init_session_key = __esm({
1598
1669
  "src/lib/session-key.ts"() {
1599
1670
  "use strict";
@@ -1608,7 +1679,7 @@ var init_transport = __esm({
1608
1679
  });
1609
1680
 
1610
1681
  // src/lib/cc-agent-support.ts
1611
- import { execSync as execSync2 } from "child_process";
1682
+ import { execSync as execSync3 } from "child_process";
1612
1683
  var init_cc_agent_support = __esm({
1613
1684
  "src/lib/cc-agent-support.ts"() {
1614
1685
  "use strict";
@@ -1637,31 +1708,16 @@ var init_provider_table = __esm({
1637
1708
  });
1638
1709
 
1639
1710
  // src/lib/intercom-queue.ts
1640
- import { readFileSync as readFileSync2, writeFileSync, renameSync as renameSync2, existsSync as existsSync4, mkdirSync as mkdirSync2 } from "fs";
1641
- import path5 from "path";
1642
- import os4 from "os";
1711
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, renameSync as renameSync3, existsSync as existsSync5, mkdirSync as mkdirSync2 } from "fs";
1712
+ import path6 from "path";
1713
+ import os5 from "os";
1643
1714
  var QUEUE_PATH, TTL_MS, INTERCOM_LOG;
1644
1715
  var init_intercom_queue = __esm({
1645
1716
  "src/lib/intercom-queue.ts"() {
1646
1717
  "use strict";
1647
- QUEUE_PATH = path5.join(os4.homedir(), ".exe-os", "intercom-queue.json");
1718
+ QUEUE_PATH = path6.join(os5.homedir(), ".exe-os", "intercom-queue.json");
1648
1719
  TTL_MS = 60 * 60 * 1e3;
1649
- INTERCOM_LOG = path5.join(os4.homedir(), ".exe-os", "intercom.log");
1650
- }
1651
- });
1652
-
1653
- // src/lib/employees.ts
1654
- import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
1655
- import { existsSync as existsSync5, symlinkSync, readlinkSync, readFileSync as readFileSync3, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
1656
- import { execSync as execSync3 } from "child_process";
1657
- import path6 from "path";
1658
- import os5 from "os";
1659
- var EMPLOYEES_PATH;
1660
- var init_employees = __esm({
1661
- "src/lib/employees.ts"() {
1662
- "use strict";
1663
- init_config();
1664
- EMPLOYEES_PATH = path6.join(EXE_AI_DIR, "exe-employees.json");
1720
+ INTERCOM_LOG = path6.join(os5.homedir(), ".exe-os", "intercom.log");
1665
1721
  }
1666
1722
  });
1667
1723
 
@@ -1712,6 +1768,7 @@ var init_tmux_routing = __esm({
1712
1768
  init_provider_table();
1713
1769
  init_intercom_queue();
1714
1770
  init_plan_limits();
1771
+ init_employees();
1715
1772
  SPAWN_LOCK_DIR = path9.join(os6.homedir(), ".exe-os", "spawn-locks");
1716
1773
  SESSION_CACHE = path9.join(os6.homedir(), ".exe-os", "session-cache");
1717
1774
  INTERCOM_LOG2 = path9.join(os6.homedir(), ".exe-os", "intercom.log");
@@ -1724,17 +1781,17 @@ var init_tmux_routing = __esm({
1724
1781
  init_database();
1725
1782
 
1726
1783
  // src/lib/keychain.ts
1727
- import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1728
- import { existsSync } from "fs";
1729
- import path from "path";
1730
- import os from "os";
1784
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
1785
+ import { existsSync as existsSync3 } from "fs";
1786
+ import path3 from "path";
1787
+ import os3 from "os";
1731
1788
  var SERVICE = "exe-mem";
1732
1789
  var ACCOUNT = "master-key";
1733
1790
  function getKeyDir() {
1734
- return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path.join(os.homedir(), ".exe-os");
1791
+ return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
1735
1792
  }
1736
1793
  function getKeyPath() {
1737
- return path.join(getKeyDir(), "master.key");
1794
+ return path3.join(getKeyDir(), "master.key");
1738
1795
  }
1739
1796
  async function tryKeytar() {
1740
1797
  try {
@@ -1755,11 +1812,11 @@ async function getMasterKey() {
1755
1812
  }
1756
1813
  }
1757
1814
  const keyPath = getKeyPath();
1758
- if (!existsSync(keyPath)) {
1815
+ if (!existsSync3(keyPath)) {
1759
1816
  return null;
1760
1817
  }
1761
1818
  try {
1762
- const content = await readFile(keyPath, "utf-8");
1819
+ const content = await readFile3(keyPath, "utf-8");
1763
1820
  return Buffer.from(content.trim(), "base64");
1764
1821
  } catch {
1765
1822
  return null;