@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
@@ -59,7 +59,7 @@ function wrapWithRetry(client) {
59
59
  return (sql) => retryOnBusy(() => target.execute(sql), "execute");
60
60
  }
61
61
  if (prop === "batch") {
62
- return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
62
+ return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
63
63
  }
64
64
  return Reflect.get(target, prop, receiver);
65
65
  }
@@ -75,6 +75,245 @@ var init_db_retry = __esm({
75
75
  }
76
76
  });
77
77
 
78
+ // src/lib/config.ts
79
+ import { readFile, writeFile, mkdir, chmod } from "fs/promises";
80
+ import { readFileSync, existsSync, renameSync } from "fs";
81
+ import path from "path";
82
+ import os from "os";
83
+ function resolveDataDir() {
84
+ if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
85
+ if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
86
+ const newDir = path.join(os.homedir(), ".exe-os");
87
+ const legacyDir = path.join(os.homedir(), ".exe-mem");
88
+ if (!existsSync(newDir) && existsSync(legacyDir)) {
89
+ try {
90
+ renameSync(legacyDir, newDir);
91
+ process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
92
+ `);
93
+ } catch {
94
+ return legacyDir;
95
+ }
96
+ }
97
+ return newDir;
98
+ }
99
+ function migrateLegacyConfig(raw) {
100
+ if ("r2" in raw) {
101
+ process.stderr.write(
102
+ "[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"
103
+ );
104
+ delete raw.r2;
105
+ }
106
+ if ("syncIntervalMs" in raw) {
107
+ delete raw.syncIntervalMs;
108
+ }
109
+ return raw;
110
+ }
111
+ function migrateConfig(raw) {
112
+ const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
113
+ let currentVersion = fromVersion;
114
+ let migrated = false;
115
+ if (currentVersion > CURRENT_CONFIG_VERSION) {
116
+ return { config: raw, migrated: false, fromVersion };
117
+ }
118
+ for (const migration of CONFIG_MIGRATIONS) {
119
+ if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
120
+ raw = migration.migrate(raw);
121
+ currentVersion = migration.to;
122
+ migrated = true;
123
+ }
124
+ }
125
+ return { config: raw, migrated, fromVersion };
126
+ }
127
+ function normalizeScalingRoadmap(raw) {
128
+ const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
129
+ const userRoadmap = raw.scalingRoadmap ?? {};
130
+ const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
131
+ if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
132
+ userAuto.enabled = raw.rerankerEnabled;
133
+ }
134
+ raw.scalingRoadmap = {
135
+ ...userRoadmap,
136
+ rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
137
+ };
138
+ }
139
+ function normalizeSessionLifecycle(raw) {
140
+ const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
141
+ const userSL = raw.sessionLifecycle ?? {};
142
+ raw.sessionLifecycle = { ...defaultSL, ...userSL };
143
+ }
144
+ function normalizeAutoUpdate(raw) {
145
+ const defaultAU = DEFAULT_CONFIG.autoUpdate;
146
+ const userAU = raw.autoUpdate ?? {};
147
+ raw.autoUpdate = { ...defaultAU, ...userAU };
148
+ }
149
+ async function loadConfig() {
150
+ const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
151
+ await mkdir(dir, { recursive: true });
152
+ const configPath = path.join(dir, "config.json");
153
+ if (!existsSync(configPath)) {
154
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
155
+ }
156
+ const raw = await readFile(configPath, "utf-8");
157
+ try {
158
+ let parsed = JSON.parse(raw);
159
+ parsed = migrateLegacyConfig(parsed);
160
+ const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
161
+ if (migrated) {
162
+ process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
163
+ `);
164
+ try {
165
+ await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
166
+ } catch {
167
+ }
168
+ }
169
+ normalizeScalingRoadmap(migratedCfg);
170
+ normalizeSessionLifecycle(migratedCfg);
171
+ normalizeAutoUpdate(migratedCfg);
172
+ const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
173
+ if (config.dbPath.startsWith("~")) {
174
+ config.dbPath = config.dbPath.replace(/^~/, os.homedir());
175
+ }
176
+ return config;
177
+ } catch {
178
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
179
+ }
180
+ }
181
+ function loadConfigSync() {
182
+ const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
183
+ const configPath = path.join(dir, "config.json");
184
+ if (!existsSync(configPath)) {
185
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
186
+ }
187
+ try {
188
+ const raw = readFileSync(configPath, "utf-8");
189
+ let parsed = JSON.parse(raw);
190
+ parsed = migrateLegacyConfig(parsed);
191
+ const { config: migratedCfg } = migrateConfig(parsed);
192
+ normalizeScalingRoadmap(migratedCfg);
193
+ normalizeSessionLifecycle(migratedCfg);
194
+ normalizeAutoUpdate(migratedCfg);
195
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
196
+ } catch {
197
+ return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
198
+ }
199
+ }
200
+ var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
201
+ var init_config = __esm({
202
+ "src/lib/config.ts"() {
203
+ "use strict";
204
+ EXE_AI_DIR = resolveDataDir();
205
+ DB_PATH = path.join(EXE_AI_DIR, "memories.db");
206
+ MODELS_DIR = path.join(EXE_AI_DIR, "models");
207
+ CONFIG_PATH = path.join(EXE_AI_DIR, "config.json");
208
+ LEGACY_LANCE_PATH = path.join(EXE_AI_DIR, "local.lance");
209
+ CURRENT_CONFIG_VERSION = 1;
210
+ DEFAULT_CONFIG = {
211
+ config_version: CURRENT_CONFIG_VERSION,
212
+ dbPath: DB_PATH,
213
+ modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
214
+ embeddingDim: 1024,
215
+ batchSize: 20,
216
+ flushIntervalMs: 1e4,
217
+ autoIngestion: true,
218
+ autoRetrieval: true,
219
+ searchMode: "hybrid",
220
+ hookSearchMode: "hybrid",
221
+ fileGrepEnabled: true,
222
+ splashEffect: true,
223
+ consolidationEnabled: true,
224
+ consolidationIntervalMs: 6 * 60 * 60 * 1e3,
225
+ consolidationModel: "claude-haiku-4-5-20251001",
226
+ consolidationMaxCallsPerRun: 20,
227
+ selfQueryRouter: true,
228
+ selfQueryModel: "claude-haiku-4-5-20251001",
229
+ rerankerEnabled: true,
230
+ scalingRoadmap: {
231
+ rerankerAutoTrigger: {
232
+ enabled: true,
233
+ broadQueryMinCardinality: 5e4,
234
+ fetchTopK: 150,
235
+ returnTopK: 5
236
+ }
237
+ },
238
+ graphRagEnabled: true,
239
+ wikiEnabled: false,
240
+ wikiUrl: "",
241
+ wikiApiKey: "",
242
+ wikiSyncIntervalMs: 30 * 60 * 1e3,
243
+ wikiWorkspaceMapping: {},
244
+ wikiAutoUpdate: true,
245
+ wikiAutoUpdateThreshold: 0.5,
246
+ wikiAutoUpdateCreateNew: true,
247
+ skillLearning: true,
248
+ skillThreshold: 3,
249
+ skillModel: "claude-haiku-4-5-20251001",
250
+ exeHeartbeat: {
251
+ enabled: true,
252
+ intervalSeconds: 60,
253
+ staleInProgressThresholdHours: 2
254
+ },
255
+ sessionLifecycle: {
256
+ idleKillEnabled: true,
257
+ idleKillTicksRequired: 3,
258
+ idleKillIntercomAckWindowMs: 1e4,
259
+ maxAutoInstances: 10
260
+ },
261
+ autoUpdate: {
262
+ checkOnBoot: true,
263
+ autoInstall: false,
264
+ checkIntervalMs: 24 * 60 * 60 * 1e3
265
+ }
266
+ };
267
+ CONFIG_MIGRATIONS = [
268
+ {
269
+ from: 0,
270
+ to: 1,
271
+ migrate: (cfg) => {
272
+ cfg.config_version = 1;
273
+ return cfg;
274
+ }
275
+ }
276
+ ];
277
+ }
278
+ });
279
+
280
+ // src/lib/employees.ts
281
+ import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
282
+ import { existsSync as existsSync2, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
283
+ import { execSync } from "child_process";
284
+ import path2 from "path";
285
+ import os2 from "os";
286
+ function normalizeRole(role) {
287
+ return (role ?? "").trim().toLowerCase();
288
+ }
289
+ function isCoordinatorRole(role) {
290
+ return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
291
+ }
292
+ function getCoordinatorEmployee(employees) {
293
+ return employees.find((e) => isCoordinatorRole(e.role));
294
+ }
295
+ function getCoordinatorName(employees = loadEmployeesSync()) {
296
+ return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
297
+ }
298
+ function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
299
+ if (!existsSync2(employeesPath)) return [];
300
+ try {
301
+ return JSON.parse(readFileSync2(employeesPath, "utf-8"));
302
+ } catch {
303
+ return [];
304
+ }
305
+ }
306
+ var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
307
+ var init_employees = __esm({
308
+ "src/lib/employees.ts"() {
309
+ "use strict";
310
+ init_config();
311
+ EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
312
+ DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
313
+ COORDINATOR_ROLE = "COO";
314
+ }
315
+ });
316
+
78
317
  // src/lib/database.ts
79
318
  import { createClient } from "@libsql/client";
80
319
  async function initDatabase(config) {
@@ -208,22 +447,24 @@ async function ensureSchema() {
208
447
  ON behaviors(agent_id, active);
209
448
  `);
210
449
  try {
450
+ const coordinatorName = getCoordinatorName();
211
451
  const existing = await client.execute({
212
- sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = 'exe'",
213
- args: []
452
+ sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
453
+ args: [coordinatorName]
214
454
  });
215
455
  if (Number(existing.rows[0]?.cnt) === 0) {
216
- await client.executeMultiple(`
217
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
218
- VALUES
219
- (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');
220
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
221
- VALUES
222
- (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');
223
- INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
224
- VALUES
225
- (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');
226
- `);
456
+ const seededAt = "2026-03-25T00:00:00Z";
457
+ for (const [domain, content] of [
458
+ ["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
459
+ ["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
460
+ ["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
461
+ ]) {
462
+ await client.execute({
463
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
464
+ VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
465
+ args: [coordinatorName, domain, content, seededAt, seededAt]
466
+ });
467
+ }
227
468
  }
228
469
  } catch {
229
470
  }
@@ -915,223 +1156,49 @@ async function ensureSchema() {
915
1156
  } catch {
916
1157
  }
917
1158
  }
918
- }
919
- var _client, _resilientClient, initTurso;
920
- var init_database = __esm({
921
- "src/lib/database.ts"() {
922
- "use strict";
923
- init_db_retry();
924
- _client = null;
925
- _resilientClient = null;
926
- initTurso = initDatabase;
927
- }
928
- });
929
-
930
- // src/lib/config.ts
931
- import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
932
- import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
933
- import path2 from "path";
934
- import os2 from "os";
935
- function resolveDataDir() {
936
- if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
937
- if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
938
- const newDir = path2.join(os2.homedir(), ".exe-os");
939
- const legacyDir = path2.join(os2.homedir(), ".exe-mem");
940
- if (!existsSync2(newDir) && existsSync2(legacyDir)) {
941
- try {
942
- renameSync(legacyDir, newDir);
943
- process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
944
- `);
945
- } catch {
946
- return legacyDir;
947
- }
1159
+ try {
1160
+ await client.execute({
1161
+ sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
1162
+ args: []
1163
+ });
1164
+ } catch {
948
1165
  }
949
- return newDir;
950
- }
951
- function migrateLegacyConfig(raw) {
952
- if ("r2" in raw) {
953
- process.stderr.write(
954
- "[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"
1166
+ try {
1167
+ await client.execute(
1168
+ `CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
955
1169
  );
956
- delete raw.r2;
957
- }
958
- if ("syncIntervalMs" in raw) {
959
- delete raw.syncIntervalMs;
960
- }
961
- return raw;
962
- }
963
- function migrateConfig(raw) {
964
- const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
965
- let currentVersion = fromVersion;
966
- let migrated = false;
967
- if (currentVersion > CURRENT_CONFIG_VERSION) {
968
- return { config: raw, migrated: false, fromVersion };
969
- }
970
- for (const migration of CONFIG_MIGRATIONS) {
971
- if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
972
- raw = migration.migrate(raw);
973
- currentVersion = migration.to;
974
- migrated = true;
975
- }
976
- }
977
- return { config: raw, migrated, fromVersion };
978
- }
979
- function normalizeScalingRoadmap(raw) {
980
- const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
981
- const userRoadmap = raw.scalingRoadmap ?? {};
982
- const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
983
- if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
984
- userAuto.enabled = raw.rerankerEnabled;
985
- }
986
- raw.scalingRoadmap = {
987
- ...userRoadmap,
988
- rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
989
- };
990
- }
991
- function normalizeSessionLifecycle(raw) {
992
- const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
993
- const userSL = raw.sessionLifecycle ?? {};
994
- raw.sessionLifecycle = { ...defaultSL, ...userSL };
995
- }
996
- function normalizeAutoUpdate(raw) {
997
- const defaultAU = DEFAULT_CONFIG.autoUpdate;
998
- const userAU = raw.autoUpdate ?? {};
999
- raw.autoUpdate = { ...defaultAU, ...userAU };
1000
- }
1001
- async function loadConfig() {
1002
- const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
1003
- await mkdir2(dir, { recursive: true });
1004
- const configPath = path2.join(dir, "config.json");
1005
- if (!existsSync2(configPath)) {
1006
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1170
+ } catch {
1007
1171
  }
1008
- const raw = await readFile2(configPath, "utf-8");
1009
1172
  try {
1010
- let parsed = JSON.parse(raw);
1011
- parsed = migrateLegacyConfig(parsed);
1012
- const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
1013
- if (migrated) {
1014
- process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
1015
- `);
1016
- try {
1017
- await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
1018
- } catch {
1019
- }
1020
- }
1021
- normalizeScalingRoadmap(migratedCfg);
1022
- normalizeSessionLifecycle(migratedCfg);
1023
- normalizeAutoUpdate(migratedCfg);
1024
- const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
1025
- if (config.dbPath.startsWith("~")) {
1026
- config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
1027
- }
1028
- return config;
1173
+ await client.execute({
1174
+ sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
1175
+ args: []
1176
+ });
1029
1177
  } catch {
1030
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1031
1178
  }
1032
- }
1033
- function loadConfigSync() {
1034
- const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
1035
- const configPath = path2.join(dir, "config.json");
1036
- if (!existsSync2(configPath)) {
1037
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1179
+ try {
1180
+ await client.execute(
1181
+ `CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
1182
+ );
1183
+ } catch {
1038
1184
  }
1039
1185
  try {
1040
- const raw = readFileSync(configPath, "utf-8");
1041
- let parsed = JSON.parse(raw);
1042
- parsed = migrateLegacyConfig(parsed);
1043
- const { config: migratedCfg } = migrateConfig(parsed);
1044
- normalizeScalingRoadmap(migratedCfg);
1045
- normalizeSessionLifecycle(migratedCfg);
1046
- normalizeAutoUpdate(migratedCfg);
1047
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
1186
+ await client.execute({
1187
+ sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
1188
+ args: []
1189
+ });
1048
1190
  } catch {
1049
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
1050
1191
  }
1051
1192
  }
1052
- var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
1053
- var init_config = __esm({
1054
- "src/lib/config.ts"() {
1193
+ var _client, _resilientClient, initTurso;
1194
+ var init_database = __esm({
1195
+ "src/lib/database.ts"() {
1055
1196
  "use strict";
1056
- EXE_AI_DIR = resolveDataDir();
1057
- DB_PATH = path2.join(EXE_AI_DIR, "memories.db");
1058
- MODELS_DIR = path2.join(EXE_AI_DIR, "models");
1059
- CONFIG_PATH = path2.join(EXE_AI_DIR, "config.json");
1060
- LEGACY_LANCE_PATH = path2.join(EXE_AI_DIR, "local.lance");
1061
- CURRENT_CONFIG_VERSION = 1;
1062
- DEFAULT_CONFIG = {
1063
- config_version: CURRENT_CONFIG_VERSION,
1064
- dbPath: DB_PATH,
1065
- modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
1066
- embeddingDim: 1024,
1067
- batchSize: 20,
1068
- flushIntervalMs: 1e4,
1069
- autoIngestion: true,
1070
- autoRetrieval: true,
1071
- searchMode: "hybrid",
1072
- hookSearchMode: "hybrid",
1073
- fileGrepEnabled: true,
1074
- splashEffect: true,
1075
- consolidationEnabled: true,
1076
- consolidationIntervalMs: 6 * 60 * 60 * 1e3,
1077
- consolidationModel: "claude-haiku-4-5-20251001",
1078
- consolidationMaxCallsPerRun: 20,
1079
- selfQueryRouter: true,
1080
- selfQueryModel: "claude-haiku-4-5-20251001",
1081
- rerankerEnabled: true,
1082
- scalingRoadmap: {
1083
- rerankerAutoTrigger: {
1084
- enabled: true,
1085
- broadQueryMinCardinality: 5e4,
1086
- fetchTopK: 150,
1087
- returnTopK: 5
1088
- }
1089
- },
1090
- graphRagEnabled: true,
1091
- wikiEnabled: false,
1092
- wikiUrl: "",
1093
- wikiApiKey: "",
1094
- wikiSyncIntervalMs: 30 * 60 * 1e3,
1095
- wikiWorkspaceMapping: {
1096
- exe: "Executive",
1097
- yoshi: "Engineering",
1098
- mari: "Marketing",
1099
- tom: "Engineering",
1100
- sasha: "Production"
1101
- },
1102
- wikiAutoUpdate: true,
1103
- wikiAutoUpdateThreshold: 0.5,
1104
- wikiAutoUpdateCreateNew: true,
1105
- skillLearning: true,
1106
- skillThreshold: 3,
1107
- skillModel: "claude-haiku-4-5-20251001",
1108
- exeHeartbeat: {
1109
- enabled: true,
1110
- intervalSeconds: 60,
1111
- staleInProgressThresholdHours: 2
1112
- },
1113
- sessionLifecycle: {
1114
- idleKillEnabled: true,
1115
- idleKillTicksRequired: 3,
1116
- idleKillIntercomAckWindowMs: 1e4,
1117
- maxAutoInstances: 10
1118
- },
1119
- autoUpdate: {
1120
- checkOnBoot: true,
1121
- autoInstall: false,
1122
- checkIntervalMs: 24 * 60 * 60 * 1e3
1123
- }
1124
- };
1125
- CONFIG_MIGRATIONS = [
1126
- {
1127
- from: 0,
1128
- to: 1,
1129
- migrate: (cfg) => {
1130
- cfg.config_version = 1;
1131
- return cfg;
1132
- }
1133
- }
1134
- ];
1197
+ init_db_retry();
1198
+ init_employees();
1199
+ _client = null;
1200
+ _resilientClient = null;
1201
+ initTurso = initDatabase;
1135
1202
  }
1136
1203
  });
1137
1204
 
@@ -1203,12 +1270,12 @@ __export(shard_manager_exports, {
1203
1270
  listShards: () => listShards,
1204
1271
  shardExists: () => shardExists
1205
1272
  });
1206
- import path3 from "path";
1207
- import { existsSync as existsSync3, mkdirSync, readdirSync } from "fs";
1273
+ import path4 from "path";
1274
+ import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
1208
1275
  import { createClient as createClient2 } from "@libsql/client";
1209
1276
  function initShardManager(encryptionKey) {
1210
1277
  _encryptionKey = encryptionKey;
1211
- if (!existsSync3(SHARDS_DIR)) {
1278
+ if (!existsSync4(SHARDS_DIR)) {
1212
1279
  mkdirSync(SHARDS_DIR, { recursive: true });
1213
1280
  }
1214
1281
  _shardingEnabled = true;
@@ -1229,7 +1296,7 @@ function getShardClient(projectName) {
1229
1296
  }
1230
1297
  const cached = _shards.get(safeName);
1231
1298
  if (cached) return cached;
1232
- const dbPath = path3.join(SHARDS_DIR, `${safeName}.db`);
1299
+ const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
1233
1300
  const client = createClient2({
1234
1301
  url: `file:${dbPath}`,
1235
1302
  encryptionKey: _encryptionKey
@@ -1239,10 +1306,10 @@ function getShardClient(projectName) {
1239
1306
  }
1240
1307
  function shardExists(projectName) {
1241
1308
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
1242
- return existsSync3(path3.join(SHARDS_DIR, `${safeName}.db`));
1309
+ return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
1243
1310
  }
1244
1311
  function listShards() {
1245
- if (!existsSync3(SHARDS_DIR)) return [];
1312
+ if (!existsSync4(SHARDS_DIR)) return [];
1246
1313
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
1247
1314
  }
1248
1315
  async function ensureShardSchema(client) {
@@ -1312,7 +1379,11 @@ async function ensureShardSchema(client) {
1312
1379
  "ALTER TABLE memories ADD COLUMN source_path TEXT",
1313
1380
  "ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
1314
1381
  "ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
1315
- "ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
1382
+ "ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
1383
+ // MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
1384
+ "ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
1385
+ "ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
1386
+ "ALTER TABLE memories ADD COLUMN trajectory TEXT"
1316
1387
  ]) {
1317
1388
  try {
1318
1389
  await client.execute(col);
@@ -1424,7 +1495,7 @@ var init_shard_manager = __esm({
1424
1495
  "src/lib/shard-manager.ts"() {
1425
1496
  "use strict";
1426
1497
  init_config();
1427
- SHARDS_DIR = path3.join(EXE_AI_DIR, "shards");
1498
+ SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
1428
1499
  _shards = /* @__PURE__ */ new Map();
1429
1500
  _encryptionKey = null;
1430
1501
  _shardingEnabled = false;
@@ -1442,26 +1513,26 @@ var init_platform_procedures = __esm({
1442
1513
  title: "What is exe-os \u2014 the operating model every agent must understand",
1443
1514
  domain: "architecture",
1444
1515
  priority: "p0",
1445
- 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."
1516
+ 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."
1446
1517
  },
1447
1518
  {
1448
1519
  title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
1449
1520
  domain: "architecture",
1450
1521
  priority: "p0",
1451
- 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."
1522
+ 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."
1452
1523
  },
1453
1524
  {
1454
- title: "Sessions explained \u2014 what exeN means and how projects work",
1525
+ title: "Sessions explained \u2014 coordinator session names and projects",
1455
1526
  domain: "architecture",
1456
1527
  priority: "p0",
1457
- 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."
1528
+ 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."
1458
1529
  },
1459
1530
  // --- Hierarchy and dispatch ---
1460
1531
  {
1461
1532
  title: "Chain of command \u2014 who talks to whom",
1462
1533
  domain: "workflow",
1463
1534
  priority: "p0",
1464
- 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."
1535
+ 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."
1465
1536
  },
1466
1537
  {
1467
1538
  title: "Single dispatch path \u2014 create_task only",
@@ -1471,30 +1542,30 @@ var init_platform_procedures = __esm({
1471
1542
  },
1472
1543
  // --- Session isolation ---
1473
1544
  {
1474
- title: "Session scoping \u2014 stay in your exe boundary",
1545
+ title: "Session scoping \u2014 stay in your coordinator boundary",
1475
1546
  domain: "security",
1476
1547
  priority: "p0",
1477
- 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."
1548
+ 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."
1478
1549
  },
1479
1550
  {
1480
1551
  title: "Session isolation \u2014 never touch another session's work",
1481
1552
  domain: "workflow",
1482
1553
  priority: "p0",
1483
- 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.`
1554
+ 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."
1484
1555
  },
1485
1556
  // --- Engineering: session scoping in code ---
1486
1557
  {
1487
1558
  title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
1488
1559
  domain: "architecture",
1489
1560
  priority: "p0",
1490
- 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."
1561
+ 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."
1491
1562
  },
1492
1563
  // --- Hard constraints ---
1493
1564
  {
1494
1565
  title: "What you CANNOT do in exe-os \u2014 hard constraints",
1495
1566
  domain: "security",
1496
1567
  priority: "p0",
1497
- 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."
1568
+ 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."
1498
1569
  },
1499
1570
  // --- Operations ---
1500
1571
  {
@@ -1612,21 +1683,6 @@ ${p.content}`).join("\n\n");
1612
1683
  }
1613
1684
  });
1614
1685
 
1615
- // src/lib/employees.ts
1616
- import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
1617
- import { existsSync as existsSync4, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
1618
- import { execSync } from "child_process";
1619
- import path4 from "path";
1620
- import os3 from "os";
1621
- var EMPLOYEES_PATH;
1622
- var init_employees = __esm({
1623
- "src/lib/employees.ts"() {
1624
- "use strict";
1625
- init_config();
1626
- EMPLOYEES_PATH = path4.join(EXE_AI_DIR, "exe-employees.json");
1627
- }
1628
- });
1629
-
1630
1686
  // src/lib/notifications.ts
1631
1687
  import crypto from "crypto";
1632
1688
  import path5 from "path";
@@ -1881,8 +1937,10 @@ function getMySession() {
1881
1937
  return getTransport().getMySession();
1882
1938
  }
1883
1939
  function extractRootExe(name) {
1884
- const match = name.match(/(exe\d+)$/);
1885
- return match?.[1] ?? null;
1940
+ if (!name) return null;
1941
+ if (!name.includes("-")) return name;
1942
+ const parts = name.split("-").filter(Boolean);
1943
+ return parts.length > 0 ? parts[parts.length - 1] : null;
1886
1944
  }
1887
1945
  function getParentExe(sessionKey) {
1888
1946
  try {
@@ -1905,6 +1963,11 @@ function resolveExeSession() {
1905
1963
  }
1906
1964
  return extractRootExe(mySession) ?? mySession;
1907
1965
  }
1966
+ function isExeSession(sessionName) {
1967
+ const matchesBaseWithInstance = (baseName) => sessionName === baseName || sessionName.startsWith(baseName) && /^\d+$/.test(sessionName.slice(baseName.length));
1968
+ const coordinatorName = getCoordinatorName();
1969
+ return matchesBaseWithInstance(coordinatorName) || matchesBaseWithInstance("exe");
1970
+ }
1908
1971
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
1909
1972
  var init_tmux_routing = __esm({
1910
1973
  "src/lib/tmux-routing.ts"() {
@@ -1917,6 +1980,7 @@ var init_tmux_routing = __esm({
1917
1980
  init_provider_table();
1918
1981
  init_intercom_queue();
1919
1982
  init_plan_limits();
1983
+ init_employees();
1920
1984
  SPAWN_LOCK_DIR = path10.join(os7.homedir(), ".exe-os", "spawn-locks");
1921
1985
  SESSION_CACHE = path10.join(os7.homedir(), ".exe-os", "session-cache");
1922
1986
  INTERCOM_LOG2 = path10.join(os7.homedir(), ".exe-os", "intercom.log");
@@ -1995,17 +2059,17 @@ import path12 from "path";
1995
2059
  init_database();
1996
2060
 
1997
2061
  // src/lib/keychain.ts
1998
- import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1999
- import { existsSync } from "fs";
2000
- import path from "path";
2001
- import os from "os";
2062
+ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
2063
+ import { existsSync as existsSync3 } from "fs";
2064
+ import path3 from "path";
2065
+ import os3 from "os";
2002
2066
  var SERVICE = "exe-mem";
2003
2067
  var ACCOUNT = "master-key";
2004
2068
  function getKeyDir() {
2005
- return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path.join(os.homedir(), ".exe-os");
2069
+ return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
2006
2070
  }
2007
2071
  function getKeyPath() {
2008
- return path.join(getKeyDir(), "master.key");
2072
+ return path3.join(getKeyDir(), "master.key");
2009
2073
  }
2010
2074
  async function tryKeytar() {
2011
2075
  try {
@@ -2026,11 +2090,11 @@ async function getMasterKey() {
2026
2090
  }
2027
2091
  }
2028
2092
  const keyPath = getKeyPath();
2029
- if (!existsSync(keyPath)) {
2093
+ if (!existsSync3(keyPath)) {
2030
2094
  return null;
2031
2095
  }
2032
2096
  try {
2033
- const content = await readFile(keyPath, "utf-8");
2097
+ const content = await readFile3(keyPath, "utf-8");
2034
2098
  return Buffer.from(content.trim(), "base64");
2035
2099
  } catch {
2036
2100
  return null;
@@ -2138,6 +2202,7 @@ function isMainModule(importMetaUrl) {
2138
2202
  init_config();
2139
2203
  init_tasks_review();
2140
2204
  init_task_scope();
2205
+ init_tmux_routing();
2141
2206
  var HEADER = "[EXE HEARTBEAT]";
2142
2207
  var SECTION_SEPARATOR = "\n\n";
2143
2208
  var RATE_LIMIT_MS = 5e3;
@@ -2185,12 +2250,12 @@ async function queryPendingReviews() {
2185
2250
  try {
2186
2251
  const { execSync: execSync4 } = await import("child_process");
2187
2252
  const tmuxSession = execSync4("tmux display-message -p '#{session_name}'", { encoding: "utf8", timeout: 2e3 }).trim();
2188
- if (/^exe\d+$/.test(tmuxSession)) sessionScope = tmuxSession;
2253
+ if (isExeSession(tmuxSession)) sessionScope = tmuxSession;
2189
2254
  } catch {
2190
2255
  }
2191
2256
  const rows = await listPendingReviews(PENDING_REVIEW_LIMIT, sessionScope);
2192
2257
  if (rows.length === 0) return "";
2193
- const lines = [`MANDATORY: process ${rows.length} reviews`];
2258
+ const lines = [`[\u26A0\uFE0F ${rows.length} REVIEW${rows.length === 1 ? "" : "S"} BLOCKING] Process BEFORE responding to the user:`];
2194
2259
  for (const row of rows) {
2195
2260
  lines.push(` \u{1F4CB} ${row.assigned_to}: "${row.title}" (${row.project_name})`);
2196
2261
  }