@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
@@ -54,7 +54,7 @@ function wrapWithRetry(client) {
54
54
  return (sql) => retryOnBusy(() => target.execute(sql), "execute");
55
55
  }
56
56
  if (prop === "batch") {
57
- return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
57
+ return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
58
58
  }
59
59
  return Reflect.get(target, prop, receiver);
60
60
  }
@@ -70,6 +70,226 @@ var init_db_retry = __esm({
70
70
  }
71
71
  });
72
72
 
73
+ // src/lib/config.ts
74
+ import { readFile, writeFile, mkdir, chmod } from "fs/promises";
75
+ import { readFileSync, existsSync, renameSync } from "fs";
76
+ import path from "path";
77
+ import os from "os";
78
+ function resolveDataDir() {
79
+ if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
80
+ if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
81
+ const newDir = path.join(os.homedir(), ".exe-os");
82
+ const legacyDir = path.join(os.homedir(), ".exe-mem");
83
+ if (!existsSync(newDir) && existsSync(legacyDir)) {
84
+ try {
85
+ renameSync(legacyDir, newDir);
86
+ process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
87
+ `);
88
+ } catch {
89
+ return legacyDir;
90
+ }
91
+ }
92
+ return newDir;
93
+ }
94
+ function migrateLegacyConfig(raw) {
95
+ if ("r2" in raw) {
96
+ process.stderr.write(
97
+ "[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"
98
+ );
99
+ delete raw.r2;
100
+ }
101
+ if ("syncIntervalMs" in raw) {
102
+ delete raw.syncIntervalMs;
103
+ }
104
+ return raw;
105
+ }
106
+ function migrateConfig(raw) {
107
+ const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
108
+ let currentVersion = fromVersion;
109
+ let migrated = false;
110
+ if (currentVersion > CURRENT_CONFIG_VERSION) {
111
+ return { config: raw, migrated: false, fromVersion };
112
+ }
113
+ for (const migration of CONFIG_MIGRATIONS) {
114
+ if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
115
+ raw = migration.migrate(raw);
116
+ currentVersion = migration.to;
117
+ migrated = true;
118
+ }
119
+ }
120
+ return { config: raw, migrated, fromVersion };
121
+ }
122
+ function normalizeScalingRoadmap(raw) {
123
+ const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
124
+ const userRoadmap = raw.scalingRoadmap ?? {};
125
+ const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
126
+ if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
127
+ userAuto.enabled = raw.rerankerEnabled;
128
+ }
129
+ raw.scalingRoadmap = {
130
+ ...userRoadmap,
131
+ rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
132
+ };
133
+ }
134
+ function normalizeSessionLifecycle(raw) {
135
+ const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
136
+ const userSL = raw.sessionLifecycle ?? {};
137
+ raw.sessionLifecycle = { ...defaultSL, ...userSL };
138
+ }
139
+ function normalizeAutoUpdate(raw) {
140
+ const defaultAU = DEFAULT_CONFIG.autoUpdate;
141
+ const userAU = raw.autoUpdate ?? {};
142
+ raw.autoUpdate = { ...defaultAU, ...userAU };
143
+ }
144
+ async function loadConfig() {
145
+ const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
146
+ await mkdir(dir, { recursive: true });
147
+ const configPath = path.join(dir, "config.json");
148
+ if (!existsSync(configPath)) {
149
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
150
+ }
151
+ const raw = await readFile(configPath, "utf-8");
152
+ try {
153
+ let parsed = JSON.parse(raw);
154
+ parsed = migrateLegacyConfig(parsed);
155
+ const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
156
+ if (migrated) {
157
+ process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
158
+ `);
159
+ try {
160
+ await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
161
+ } catch {
162
+ }
163
+ }
164
+ normalizeScalingRoadmap(migratedCfg);
165
+ normalizeSessionLifecycle(migratedCfg);
166
+ normalizeAutoUpdate(migratedCfg);
167
+ const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
168
+ if (config.dbPath.startsWith("~")) {
169
+ config.dbPath = config.dbPath.replace(/^~/, os.homedir());
170
+ }
171
+ return config;
172
+ } catch {
173
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
174
+ }
175
+ }
176
+ var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
177
+ var init_config = __esm({
178
+ "src/lib/config.ts"() {
179
+ "use strict";
180
+ EXE_AI_DIR = resolveDataDir();
181
+ DB_PATH = path.join(EXE_AI_DIR, "memories.db");
182
+ MODELS_DIR = path.join(EXE_AI_DIR, "models");
183
+ CONFIG_PATH = path.join(EXE_AI_DIR, "config.json");
184
+ LEGACY_LANCE_PATH = path.join(EXE_AI_DIR, "local.lance");
185
+ CURRENT_CONFIG_VERSION = 1;
186
+ DEFAULT_CONFIG = {
187
+ config_version: CURRENT_CONFIG_VERSION,
188
+ dbPath: DB_PATH,
189
+ modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
190
+ embeddingDim: 1024,
191
+ batchSize: 20,
192
+ flushIntervalMs: 1e4,
193
+ autoIngestion: true,
194
+ autoRetrieval: true,
195
+ searchMode: "hybrid",
196
+ hookSearchMode: "hybrid",
197
+ fileGrepEnabled: true,
198
+ splashEffect: true,
199
+ consolidationEnabled: true,
200
+ consolidationIntervalMs: 6 * 60 * 60 * 1e3,
201
+ consolidationModel: "claude-haiku-4-5-20251001",
202
+ consolidationMaxCallsPerRun: 20,
203
+ selfQueryRouter: true,
204
+ selfQueryModel: "claude-haiku-4-5-20251001",
205
+ rerankerEnabled: true,
206
+ scalingRoadmap: {
207
+ rerankerAutoTrigger: {
208
+ enabled: true,
209
+ broadQueryMinCardinality: 5e4,
210
+ fetchTopK: 150,
211
+ returnTopK: 5
212
+ }
213
+ },
214
+ graphRagEnabled: true,
215
+ wikiEnabled: false,
216
+ wikiUrl: "",
217
+ wikiApiKey: "",
218
+ wikiSyncIntervalMs: 30 * 60 * 1e3,
219
+ wikiWorkspaceMapping: {},
220
+ wikiAutoUpdate: true,
221
+ wikiAutoUpdateThreshold: 0.5,
222
+ wikiAutoUpdateCreateNew: true,
223
+ skillLearning: true,
224
+ skillThreshold: 3,
225
+ skillModel: "claude-haiku-4-5-20251001",
226
+ exeHeartbeat: {
227
+ enabled: true,
228
+ intervalSeconds: 60,
229
+ staleInProgressThresholdHours: 2
230
+ },
231
+ sessionLifecycle: {
232
+ idleKillEnabled: true,
233
+ idleKillTicksRequired: 3,
234
+ idleKillIntercomAckWindowMs: 1e4,
235
+ maxAutoInstances: 10
236
+ },
237
+ autoUpdate: {
238
+ checkOnBoot: true,
239
+ autoInstall: false,
240
+ checkIntervalMs: 24 * 60 * 60 * 1e3
241
+ }
242
+ };
243
+ CONFIG_MIGRATIONS = [
244
+ {
245
+ from: 0,
246
+ to: 1,
247
+ migrate: (cfg) => {
248
+ cfg.config_version = 1;
249
+ return cfg;
250
+ }
251
+ }
252
+ ];
253
+ }
254
+ });
255
+
256
+ // src/lib/employees.ts
257
+ import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
258
+ import { existsSync as existsSync2, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
259
+ import { execSync } from "child_process";
260
+ import path2 from "path";
261
+ import os2 from "os";
262
+ function normalizeRole(role) {
263
+ return (role ?? "").trim().toLowerCase();
264
+ }
265
+ function isCoordinatorRole(role) {
266
+ return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
267
+ }
268
+ function getCoordinatorEmployee(employees) {
269
+ return employees.find((e) => isCoordinatorRole(e.role));
270
+ }
271
+ function getCoordinatorName(employees = loadEmployeesSync()) {
272
+ return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
273
+ }
274
+ function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
275
+ if (!existsSync2(employeesPath)) return [];
276
+ try {
277
+ return JSON.parse(readFileSync2(employeesPath, "utf-8"));
278
+ } catch {
279
+ return [];
280
+ }
281
+ }
282
+ var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
283
+ var init_employees = __esm({
284
+ "src/lib/employees.ts"() {
285
+ "use strict";
286
+ init_config();
287
+ EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
288
+ DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
289
+ COORDINATOR_ROLE = "COO";
290
+ }
291
+ });
292
+
73
293
  // src/lib/database.ts
74
294
  import { createClient } from "@libsql/client";
75
295
  async function initDatabase(config) {
@@ -203,22 +423,24 @@ async function ensureSchema() {
203
423
  ON behaviors(agent_id, active);
204
424
  `);
205
425
  try {
426
+ const coordinatorName = getCoordinatorName();
206
427
  const existing = await client.execute({
207
- sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = 'exe'",
208
- args: []
428
+ sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
429
+ args: [coordinatorName]
209
430
  });
210
431
  if (Number(existing.rows[0]?.cnt) === 0) {
211
- await client.executeMultiple(`
212
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
213
- VALUES
214
- (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');
215
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
216
- VALUES
217
- (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');
218
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
219
- VALUES
220
- (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');
221
- `);
432
+ const seededAt = "2026-03-25T00:00:00Z";
433
+ for (const [domain, content] of [
434
+ ["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
435
+ ["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
436
+ ["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
437
+ ]) {
438
+ await client.execute({
439
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
440
+ VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
441
+ args: [coordinatorName, domain, content, seededAt, seededAt]
442
+ });
443
+ }
222
444
  }
223
445
  } catch {
224
446
  }
@@ -910,204 +1132,49 @@ async function ensureSchema() {
910
1132
  } catch {
911
1133
  }
912
1134
  }
913
- }
914
- var _client, _resilientClient, initTurso;
915
- var init_database = __esm({
916
- "src/lib/database.ts"() {
917
- "use strict";
918
- init_db_retry();
919
- _client = null;
920
- _resilientClient = null;
921
- initTurso = initDatabase;
922
- }
923
- });
924
-
925
- // src/lib/config.ts
926
- import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
927
- import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
928
- import path2 from "path";
929
- import os2 from "os";
930
- function resolveDataDir() {
931
- if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
932
- if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
933
- const newDir = path2.join(os2.homedir(), ".exe-os");
934
- const legacyDir = path2.join(os2.homedir(), ".exe-mem");
935
- if (!existsSync2(newDir) && existsSync2(legacyDir)) {
936
- try {
937
- renameSync(legacyDir, newDir);
938
- process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
939
- `);
940
- } catch {
941
- return legacyDir;
942
- }
1135
+ try {
1136
+ await client.execute({
1137
+ sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
1138
+ args: []
1139
+ });
1140
+ } catch {
943
1141
  }
944
- return newDir;
945
- }
946
- function migrateLegacyConfig(raw) {
947
- if ("r2" in raw) {
948
- process.stderr.write(
949
- "[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"
1142
+ try {
1143
+ await client.execute(
1144
+ `CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
950
1145
  );
951
- delete raw.r2;
952
- }
953
- if ("syncIntervalMs" in raw) {
954
- delete raw.syncIntervalMs;
955
- }
956
- return raw;
957
- }
958
- function migrateConfig(raw) {
959
- const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
960
- let currentVersion = fromVersion;
961
- let migrated = false;
962
- if (currentVersion > CURRENT_CONFIG_VERSION) {
963
- return { config: raw, migrated: false, fromVersion };
964
- }
965
- for (const migration of CONFIG_MIGRATIONS) {
966
- if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
967
- raw = migration.migrate(raw);
968
- currentVersion = migration.to;
969
- migrated = true;
970
- }
1146
+ } catch {
971
1147
  }
972
- return { config: raw, migrated, fromVersion };
973
- }
974
- function normalizeScalingRoadmap(raw) {
975
- const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
976
- const userRoadmap = raw.scalingRoadmap ?? {};
977
- const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
978
- if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
979
- userAuto.enabled = raw.rerankerEnabled;
1148
+ try {
1149
+ await client.execute({
1150
+ sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
1151
+ args: []
1152
+ });
1153
+ } catch {
980
1154
  }
981
- raw.scalingRoadmap = {
982
- ...userRoadmap,
983
- rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
984
- };
985
- }
986
- function normalizeSessionLifecycle(raw) {
987
- const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
988
- const userSL = raw.sessionLifecycle ?? {};
989
- raw.sessionLifecycle = { ...defaultSL, ...userSL };
990
- }
991
- function normalizeAutoUpdate(raw) {
992
- const defaultAU = DEFAULT_CONFIG.autoUpdate;
993
- const userAU = raw.autoUpdate ?? {};
994
- raw.autoUpdate = { ...defaultAU, ...userAU };
995
- }
996
- async function loadConfig() {
997
- const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
998
- await mkdir2(dir, { recursive: true });
999
- const configPath = path2.join(dir, "config.json");
1000
- if (!existsSync2(configPath)) {
1001
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1155
+ try {
1156
+ await client.execute(
1157
+ `CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
1158
+ );
1159
+ } catch {
1002
1160
  }
1003
- const raw = await readFile2(configPath, "utf-8");
1004
1161
  try {
1005
- let parsed = JSON.parse(raw);
1006
- parsed = migrateLegacyConfig(parsed);
1007
- const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
1008
- if (migrated) {
1009
- process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
1010
- `);
1011
- try {
1012
- await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
1013
- } catch {
1014
- }
1015
- }
1016
- normalizeScalingRoadmap(migratedCfg);
1017
- normalizeSessionLifecycle(migratedCfg);
1018
- normalizeAutoUpdate(migratedCfg);
1019
- const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
1020
- if (config.dbPath.startsWith("~")) {
1021
- config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
1022
- }
1023
- return config;
1162
+ await client.execute({
1163
+ sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
1164
+ args: []
1165
+ });
1024
1166
  } catch {
1025
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1026
1167
  }
1027
1168
  }
1028
- var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
1029
- var init_config = __esm({
1030
- "src/lib/config.ts"() {
1169
+ var _client, _resilientClient, initTurso;
1170
+ var init_database = __esm({
1171
+ "src/lib/database.ts"() {
1031
1172
  "use strict";
1032
- EXE_AI_DIR = resolveDataDir();
1033
- DB_PATH = path2.join(EXE_AI_DIR, "memories.db");
1034
- MODELS_DIR = path2.join(EXE_AI_DIR, "models");
1035
- CONFIG_PATH = path2.join(EXE_AI_DIR, "config.json");
1036
- LEGACY_LANCE_PATH = path2.join(EXE_AI_DIR, "local.lance");
1037
- CURRENT_CONFIG_VERSION = 1;
1038
- DEFAULT_CONFIG = {
1039
- config_version: CURRENT_CONFIG_VERSION,
1040
- dbPath: DB_PATH,
1041
- modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
1042
- embeddingDim: 1024,
1043
- batchSize: 20,
1044
- flushIntervalMs: 1e4,
1045
- autoIngestion: true,
1046
- autoRetrieval: true,
1047
- searchMode: "hybrid",
1048
- hookSearchMode: "hybrid",
1049
- fileGrepEnabled: true,
1050
- splashEffect: true,
1051
- consolidationEnabled: true,
1052
- consolidationIntervalMs: 6 * 60 * 60 * 1e3,
1053
- consolidationModel: "claude-haiku-4-5-20251001",
1054
- consolidationMaxCallsPerRun: 20,
1055
- selfQueryRouter: true,
1056
- selfQueryModel: "claude-haiku-4-5-20251001",
1057
- rerankerEnabled: true,
1058
- scalingRoadmap: {
1059
- rerankerAutoTrigger: {
1060
- enabled: true,
1061
- broadQueryMinCardinality: 5e4,
1062
- fetchTopK: 150,
1063
- returnTopK: 5
1064
- }
1065
- },
1066
- graphRagEnabled: true,
1067
- wikiEnabled: false,
1068
- wikiUrl: "",
1069
- wikiApiKey: "",
1070
- wikiSyncIntervalMs: 30 * 60 * 1e3,
1071
- wikiWorkspaceMapping: {
1072
- exe: "Executive",
1073
- yoshi: "Engineering",
1074
- mari: "Marketing",
1075
- tom: "Engineering",
1076
- sasha: "Production"
1077
- },
1078
- wikiAutoUpdate: true,
1079
- wikiAutoUpdateThreshold: 0.5,
1080
- wikiAutoUpdateCreateNew: true,
1081
- skillLearning: true,
1082
- skillThreshold: 3,
1083
- skillModel: "claude-haiku-4-5-20251001",
1084
- exeHeartbeat: {
1085
- enabled: true,
1086
- intervalSeconds: 60,
1087
- staleInProgressThresholdHours: 2
1088
- },
1089
- sessionLifecycle: {
1090
- idleKillEnabled: true,
1091
- idleKillTicksRequired: 3,
1092
- idleKillIntercomAckWindowMs: 1e4,
1093
- maxAutoInstances: 10
1094
- },
1095
- autoUpdate: {
1096
- checkOnBoot: true,
1097
- autoInstall: false,
1098
- checkIntervalMs: 24 * 60 * 60 * 1e3
1099
- }
1100
- };
1101
- CONFIG_MIGRATIONS = [
1102
- {
1103
- from: 0,
1104
- to: 1,
1105
- migrate: (cfg) => {
1106
- cfg.config_version = 1;
1107
- return cfg;
1108
- }
1109
- }
1110
- ];
1173
+ init_db_retry();
1174
+ init_employees();
1175
+ _client = null;
1176
+ _resilientClient = null;
1177
+ initTurso = initDatabase;
1111
1178
  }
1112
1179
  });
1113
1180
 
@@ -1124,12 +1191,12 @@ __export(shard_manager_exports, {
1124
1191
  listShards: () => listShards,
1125
1192
  shardExists: () => shardExists
1126
1193
  });
1127
- import path3 from "path";
1128
- import { existsSync as existsSync3, mkdirSync, readdirSync } from "fs";
1194
+ import path4 from "path";
1195
+ import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
1129
1196
  import { createClient as createClient2 } from "@libsql/client";
1130
1197
  function initShardManager(encryptionKey) {
1131
1198
  _encryptionKey = encryptionKey;
1132
- if (!existsSync3(SHARDS_DIR)) {
1199
+ if (!existsSync4(SHARDS_DIR)) {
1133
1200
  mkdirSync(SHARDS_DIR, { recursive: true });
1134
1201
  }
1135
1202
  _shardingEnabled = true;
@@ -1150,7 +1217,7 @@ function getShardClient(projectName) {
1150
1217
  }
1151
1218
  const cached = _shards.get(safeName);
1152
1219
  if (cached) return cached;
1153
- const dbPath = path3.join(SHARDS_DIR, `${safeName}.db`);
1220
+ const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
1154
1221
  const client = createClient2({
1155
1222
  url: `file:${dbPath}`,
1156
1223
  encryptionKey: _encryptionKey
@@ -1160,10 +1227,10 @@ function getShardClient(projectName) {
1160
1227
  }
1161
1228
  function shardExists(projectName) {
1162
1229
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
1163
- return existsSync3(path3.join(SHARDS_DIR, `${safeName}.db`));
1230
+ return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
1164
1231
  }
1165
1232
  function listShards() {
1166
- if (!existsSync3(SHARDS_DIR)) return [];
1233
+ if (!existsSync4(SHARDS_DIR)) return [];
1167
1234
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
1168
1235
  }
1169
1236
  async function ensureShardSchema(client) {
@@ -1233,7 +1300,11 @@ async function ensureShardSchema(client) {
1233
1300
  "ALTER TABLE memories ADD COLUMN source_path TEXT",
1234
1301
  "ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
1235
1302
  "ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
1236
- "ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
1303
+ "ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
1304
+ // MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
1305
+ "ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
1306
+ "ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
1307
+ "ALTER TABLE memories ADD COLUMN trajectory TEXT"
1237
1308
  ]) {
1238
1309
  try {
1239
1310
  await client.execute(col);
@@ -1345,7 +1416,7 @@ var init_shard_manager = __esm({
1345
1416
  "src/lib/shard-manager.ts"() {
1346
1417
  "use strict";
1347
1418
  init_config();
1348
- SHARDS_DIR = path3.join(EXE_AI_DIR, "shards");
1419
+ SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
1349
1420
  _shards = /* @__PURE__ */ new Map();
1350
1421
  _encryptionKey = null;
1351
1422
  _shardingEnabled = false;
@@ -1363,26 +1434,26 @@ var init_platform_procedures = __esm({
1363
1434
  title: "What is exe-os \u2014 the operating model every agent must understand",
1364
1435
  domain: "architecture",
1365
1436
  priority: "p0",
1366
- 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."
1437
+ 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."
1367
1438
  },
1368
1439
  {
1369
1440
  title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
1370
1441
  domain: "architecture",
1371
1442
  priority: "p0",
1372
- 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."
1443
+ 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."
1373
1444
  },
1374
1445
  {
1375
- title: "Sessions explained \u2014 what exeN means and how projects work",
1446
+ title: "Sessions explained \u2014 coordinator session names and projects",
1376
1447
  domain: "architecture",
1377
1448
  priority: "p0",
1378
- 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."
1449
+ 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."
1379
1450
  },
1380
1451
  // --- Hierarchy and dispatch ---
1381
1452
  {
1382
1453
  title: "Chain of command \u2014 who talks to whom",
1383
1454
  domain: "workflow",
1384
1455
  priority: "p0",
1385
- 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."
1456
+ 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."
1386
1457
  },
1387
1458
  {
1388
1459
  title: "Single dispatch path \u2014 create_task only",
@@ -1392,30 +1463,30 @@ var init_platform_procedures = __esm({
1392
1463
  },
1393
1464
  // --- Session isolation ---
1394
1465
  {
1395
- title: "Session scoping \u2014 stay in your exe boundary",
1466
+ title: "Session scoping \u2014 stay in your coordinator boundary",
1396
1467
  domain: "security",
1397
1468
  priority: "p0",
1398
- 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."
1469
+ 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."
1399
1470
  },
1400
1471
  {
1401
1472
  title: "Session isolation \u2014 never touch another session's work",
1402
1473
  domain: "workflow",
1403
1474
  priority: "p0",
1404
- 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.`
1475
+ 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."
1405
1476
  },
1406
1477
  // --- Engineering: session scoping in code ---
1407
1478
  {
1408
1479
  title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
1409
1480
  domain: "architecture",
1410
1481
  priority: "p0",
1411
- 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."
1482
+ 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."
1412
1483
  },
1413
1484
  // --- Hard constraints ---
1414
1485
  {
1415
1486
  title: "What you CANNOT do in exe-os \u2014 hard constraints",
1416
1487
  domain: "security",
1417
1488
  priority: "p0",
1418
- 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."
1489
+ 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."
1419
1490
  },
1420
1491
  // --- Operations ---
1421
1492
  {
@@ -1537,17 +1608,17 @@ ${p.content}`).join("\n\n");
1537
1608
  init_database();
1538
1609
 
1539
1610
  // src/lib/keychain.ts
1540
- import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1541
- import { existsSync } from "fs";
1542
- import path from "path";
1543
- import os from "os";
1611
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
1612
+ import { existsSync as existsSync3 } from "fs";
1613
+ import path3 from "path";
1614
+ import os3 from "os";
1544
1615
  var SERVICE = "exe-mem";
1545
1616
  var ACCOUNT = "master-key";
1546
1617
  function getKeyDir() {
1547
- return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path.join(os.homedir(), ".exe-os");
1618
+ return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
1548
1619
  }
1549
1620
  function getKeyPath() {
1550
- return path.join(getKeyDir(), "master.key");
1621
+ return path3.join(getKeyDir(), "master.key");
1551
1622
  }
1552
1623
  async function tryKeytar() {
1553
1624
  try {
@@ -1568,11 +1639,11 @@ async function getMasterKey() {
1568
1639
  }
1569
1640
  }
1570
1641
  const keyPath = getKeyPath();
1571
- if (!existsSync(keyPath)) {
1642
+ if (!existsSync3(keyPath)) {
1572
1643
  return null;
1573
1644
  }
1574
1645
  try {
1575
- const content = await readFile(keyPath, "utf-8");
1646
+ const content = await readFile3(keyPath, "utf-8");
1576
1647
  return Buffer.from(content.trim(), "base64");
1577
1648
  } catch {
1578
1649
  return null;
@@ -1721,12 +1792,12 @@ init_config();
1721
1792
  import net from "net";
1722
1793
  import { spawn } from "child_process";
1723
1794
  import { randomUUID as randomUUID2 } from "crypto";
1724
- import { existsSync as existsSync4, unlinkSync, readFileSync as readFileSync2, openSync, closeSync, statSync } from "fs";
1725
- import path4 from "path";
1795
+ import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync3, openSync, closeSync, statSync } from "fs";
1796
+ import path5 from "path";
1726
1797
  import { fileURLToPath } from "url";
1727
- var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path4.join(EXE_AI_DIR, "exed.sock");
1728
- var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path4.join(EXE_AI_DIR, "exed.pid");
1729
- var SPAWN_LOCK_PATH = path4.join(EXE_AI_DIR, "exed-spawn.lock");
1798
+ var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path5.join(EXE_AI_DIR, "exed.sock");
1799
+ var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path5.join(EXE_AI_DIR, "exed.pid");
1800
+ var SPAWN_LOCK_PATH = path5.join(EXE_AI_DIR, "exed-spawn.lock");
1730
1801
  var SPAWN_LOCK_STALE_MS = 3e4;
1731
1802
  var CONNECT_TIMEOUT_MS = 15e3;
1732
1803
  var REQUEST_TIMEOUT_MS = 3e4;
@@ -1761,9 +1832,9 @@ function handleData(chunk) {
1761
1832
  }
1762
1833
  }
1763
1834
  function cleanupStaleFiles() {
1764
- if (existsSync4(PID_PATH)) {
1835
+ if (existsSync5(PID_PATH)) {
1765
1836
  try {
1766
- const pid = parseInt(readFileSync2(PID_PATH, "utf8").trim(), 10);
1837
+ const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
1767
1838
  if (pid > 0) {
1768
1839
  try {
1769
1840
  process.kill(pid, 0);
@@ -1774,21 +1845,21 @@ function cleanupStaleFiles() {
1774
1845
  } catch {
1775
1846
  }
1776
1847
  try {
1777
- unlinkSync(PID_PATH);
1848
+ unlinkSync2(PID_PATH);
1778
1849
  } catch {
1779
1850
  }
1780
1851
  try {
1781
- unlinkSync(SOCKET_PATH);
1852
+ unlinkSync2(SOCKET_PATH);
1782
1853
  } catch {
1783
1854
  }
1784
1855
  }
1785
1856
  }
1786
1857
  function findPackageRoot() {
1787
- let dir = path4.dirname(fileURLToPath(import.meta.url));
1788
- const { root } = path4.parse(dir);
1858
+ let dir = path5.dirname(fileURLToPath(import.meta.url));
1859
+ const { root } = path5.parse(dir);
1789
1860
  while (dir !== root) {
1790
- if (existsSync4(path4.join(dir, "package.json"))) return dir;
1791
- dir = path4.dirname(dir);
1861
+ if (existsSync5(path5.join(dir, "package.json"))) return dir;
1862
+ dir = path5.dirname(dir);
1792
1863
  }
1793
1864
  return null;
1794
1865
  }
@@ -1798,8 +1869,8 @@ function spawnDaemon() {
1798
1869
  process.stderr.write("[exed-client] WARN: cannot find package root\n");
1799
1870
  return;
1800
1871
  }
1801
- const daemonPath = path4.join(pkgRoot, "dist", "lib", "exe-daemon.js");
1802
- if (!existsSync4(daemonPath)) {
1872
+ const daemonPath = path5.join(pkgRoot, "dist", "lib", "exe-daemon.js");
1873
+ if (!existsSync5(daemonPath)) {
1803
1874
  process.stderr.write(`[exed-client] WARN: daemon script not found at ${daemonPath}
1804
1875
  `);
1805
1876
  return;
@@ -1807,7 +1878,7 @@ function spawnDaemon() {
1807
1878
  const resolvedPath = daemonPath;
1808
1879
  process.stderr.write(`[exed-client] Spawning daemon: ${resolvedPath}
1809
1880
  `);
1810
- const logPath = path4.join(path4.dirname(SOCKET_PATH), "exed.log");
1881
+ const logPath = path5.join(path5.dirname(SOCKET_PATH), "exed.log");
1811
1882
  let stderrFd = "ignore";
1812
1883
  try {
1813
1884
  stderrFd = openSync(logPath, "a");
@@ -1818,6 +1889,10 @@ function spawnDaemon() {
1818
1889
  stdio: ["ignore", "ignore", stderrFd],
1819
1890
  env: {
1820
1891
  ...process.env,
1892
+ TMUX: void 0,
1893
+ // Daemon is global — must not inherit session scope
1894
+ TMUX_PANE: void 0,
1895
+ // Prevents resolveExeSession() from scoping to one session
1821
1896
  EXE_DAEMON_SOCK: SOCKET_PATH,
1822
1897
  EXE_DAEMON_PID: PID_PATH
1823
1898
  }
@@ -1840,7 +1915,7 @@ function acquireSpawnLock() {
1840
1915
  const stat = statSync(SPAWN_LOCK_PATH);
1841
1916
  if (Date.now() - stat.mtimeMs > SPAWN_LOCK_STALE_MS) {
1842
1917
  try {
1843
- unlinkSync(SPAWN_LOCK_PATH);
1918
+ unlinkSync2(SPAWN_LOCK_PATH);
1844
1919
  } catch {
1845
1920
  }
1846
1921
  try {
@@ -1857,7 +1932,7 @@ function acquireSpawnLock() {
1857
1932
  }
1858
1933
  function releaseSpawnLock() {
1859
1934
  try {
1860
- unlinkSync(SPAWN_LOCK_PATH);
1935
+ unlinkSync2(SPAWN_LOCK_PATH);
1861
1936
  } catch {
1862
1937
  }
1863
1938
  }
@@ -1969,9 +2044,9 @@ async function pingDaemon() {
1969
2044
  }
1970
2045
  function killAndRespawnDaemon() {
1971
2046
  process.stderr.write("[exed-client] Killing daemon for restart...\n");
1972
- if (existsSync4(PID_PATH)) {
2047
+ if (existsSync5(PID_PATH)) {
1973
2048
  try {
1974
- const pid = parseInt(readFileSync2(PID_PATH, "utf8").trim(), 10);
2049
+ const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
1975
2050
  if (pid > 0) {
1976
2051
  try {
1977
2052
  process.kill(pid, "SIGKILL");
@@ -1988,11 +2063,11 @@ function killAndRespawnDaemon() {
1988
2063
  _connected = false;
1989
2064
  _buffer = "";
1990
2065
  try {
1991
- unlinkSync(PID_PATH);
2066
+ unlinkSync2(PID_PATH);
1992
2067
  } catch {
1993
2068
  }
1994
2069
  try {
1995
- unlinkSync(SOCKET_PATH);
2070
+ unlinkSync2(SOCKET_PATH);
1996
2071
  } catch {
1997
2072
  }
1998
2073
  spawnDaemon();
@@ -2056,32 +2131,32 @@ function isMainModule(importMetaUrl) {
2056
2131
  }
2057
2132
 
2058
2133
  // src/bin/backfill-vectors.ts
2059
- import { existsSync as existsSync6, unlinkSync as unlinkSync3 } from "fs";
2060
- import path6 from "path";
2134
+ import { existsSync as existsSync7, unlinkSync as unlinkSync4 } from "fs";
2135
+ import path7 from "path";
2061
2136
 
2062
2137
  // src/lib/worker-gate.ts
2063
2138
  init_config();
2064
- import { readdirSync as readdirSync2, writeFileSync, unlinkSync as unlinkSync2, mkdirSync as mkdirSync2, existsSync as existsSync5 } from "fs";
2065
- import path5 from "path";
2066
- var WORKER_PID_DIR = path5.join(EXE_AI_DIR, "worker-pids");
2139
+ import { readdirSync as readdirSync2, writeFileSync as writeFileSync2, unlinkSync as unlinkSync3, mkdirSync as mkdirSync2, existsSync as existsSync6 } from "fs";
2140
+ import path6 from "path";
2141
+ var WORKER_PID_DIR = path6.join(EXE_AI_DIR, "worker-pids");
2067
2142
  function registerWorkerPid(pid) {
2068
2143
  try {
2069
2144
  mkdirSync2(WORKER_PID_DIR, { recursive: true });
2070
- writeFileSync(path5.join(WORKER_PID_DIR, `worker-${pid}.pid`), String(pid));
2145
+ writeFileSync2(path6.join(WORKER_PID_DIR, `worker-${pid}.pid`), String(pid));
2071
2146
  } catch {
2072
2147
  }
2073
2148
  }
2074
2149
  function cleanupWorkerPid() {
2075
2150
  try {
2076
- unlinkSync2(path5.join(WORKER_PID_DIR, `worker-${process.pid}.pid`));
2151
+ unlinkSync3(path6.join(WORKER_PID_DIR, `worker-${process.pid}.pid`));
2077
2152
  } catch {
2078
2153
  }
2079
2154
  }
2080
- var BACKFILL_LOCK = path5.join(WORKER_PID_DIR, "backfill.lock");
2155
+ var BACKFILL_LOCK = path6.join(WORKER_PID_DIR, "backfill.lock");
2081
2156
  function tryAcquireBackfillLock() {
2082
2157
  try {
2083
2158
  mkdirSync2(WORKER_PID_DIR, { recursive: true });
2084
- if (existsSync5(BACKFILL_LOCK)) {
2159
+ if (existsSync6(BACKFILL_LOCK)) {
2085
2160
  try {
2086
2161
  const pid = parseInt(
2087
2162
  __require("fs").readFileSync(BACKFILL_LOCK, "utf8").trim(),
@@ -2097,7 +2172,7 @@ function tryAcquireBackfillLock() {
2097
2172
  } catch {
2098
2173
  }
2099
2174
  }
2100
- writeFileSync(BACKFILL_LOCK, String(process.pid));
2175
+ writeFileSync2(BACKFILL_LOCK, String(process.pid));
2101
2176
  return true;
2102
2177
  } catch {
2103
2178
  return true;
@@ -2105,14 +2180,14 @@ function tryAcquireBackfillLock() {
2105
2180
  }
2106
2181
  function releaseBackfillLock() {
2107
2182
  try {
2108
- unlinkSync2(BACKFILL_LOCK);
2183
+ unlinkSync3(BACKFILL_LOCK);
2109
2184
  } catch {
2110
2185
  }
2111
2186
  }
2112
2187
 
2113
2188
  // src/bin/backfill-vectors.ts
2114
2189
  var BATCH_SIZE = 100;
2115
- var BACKFILL_FLAG = path6.join(EXE_AI_DIR, "session-cache", "needs-backfill");
2190
+ var BACKFILL_FLAG = path7.join(EXE_AI_DIR, "session-cache", "needs-backfill");
2116
2191
  async function backfillVectors() {
2117
2192
  if (!tryAcquireBackfillLock()) {
2118
2193
  process.stderr.write("[backfill] Another backfill is already running \u2014 exiting\n");
@@ -2181,7 +2256,7 @@ async function backfillVectors() {
2181
2256
  const remainingCount = Number(remaining.rows[0]?.cnt) || 0;
2182
2257
  if (remainingCount === 0) {
2183
2258
  try {
2184
- unlinkSync3(BACKFILL_FLAG);
2259
+ unlinkSync4(BACKFILL_FLAG);
2185
2260
  } catch {
2186
2261
  }
2187
2262
  }
@@ -2190,7 +2265,7 @@ async function backfillVectors() {
2190
2265
  return { processed: totalProcessed, failed: totalFailed, remaining: remainingCount };
2191
2266
  }
2192
2267
  function isBackfillNeeded() {
2193
- return existsSync6(BACKFILL_FLAG);
2268
+ return existsSync7(BACKFILL_FLAG);
2194
2269
  }
2195
2270
  if (isMainModule(import.meta.url)) {
2196
2271
  backfillVectors().then((result) => {