@askexenow/exe-os 0.9.16 → 0.9.18

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 (97) hide show
  1. package/dist/bin/backfill-conversations.js +1242 -909
  2. package/dist/bin/backfill-responses.js +1245 -912
  3. package/dist/bin/backfill-vectors.js +1244 -906
  4. package/dist/bin/cleanup-stale-review-tasks.js +1870 -417
  5. package/dist/bin/cli.js +217 -107
  6. package/dist/bin/exe-agent-config.js +2 -2
  7. package/dist/bin/exe-agent.js +62 -0
  8. package/dist/bin/exe-assign.js +346 -10
  9. package/dist/bin/exe-boot.js +387 -32
  10. package/dist/bin/exe-call.js +72 -2
  11. package/dist/bin/exe-cloud.js +8 -0
  12. package/dist/bin/exe-dispatch.js +1821 -225
  13. package/dist/bin/exe-doctor.js +720 -52
  14. package/dist/bin/exe-export-behaviors.js +1429 -148
  15. package/dist/bin/exe-forget.js +1408 -34
  16. package/dist/bin/exe-gateway.js +1629 -1295
  17. package/dist/bin/exe-heartbeat.js +1899 -448
  18. package/dist/bin/exe-kill.js +1624 -346
  19. package/dist/bin/exe-launch-agent.js +726 -90
  20. package/dist/bin/exe-link.js +27 -8
  21. package/dist/bin/exe-new-employee.js +75 -9
  22. package/dist/bin/exe-pending-messages.js +2769 -1316
  23. package/dist/bin/exe-pending-notifications.js +2829 -1376
  24. package/dist/bin/exe-pending-reviews.js +2847 -1392
  25. package/dist/bin/exe-rename.js +89 -8
  26. package/dist/bin/exe-review.js +1494 -312
  27. package/dist/bin/exe-search.js +1608 -1300
  28. package/dist/bin/exe-session-cleanup.js +194 -91
  29. package/dist/bin/exe-settings.js +10 -2
  30. package/dist/bin/exe-start-codex.js +769 -120
  31. package/dist/bin/exe-start-opencode.js +763 -108
  32. package/dist/bin/exe-status.js +1887 -434
  33. package/dist/bin/exe-team.js +1782 -324
  34. package/dist/bin/git-sweep.js +408 -33
  35. package/dist/bin/graph-backfill.js +681 -27
  36. package/dist/bin/graph-export.js +1419 -141
  37. package/dist/bin/install.js +4 -8
  38. package/dist/bin/intercom-check.js +8641 -0
  39. package/dist/bin/scan-tasks.js +553 -38
  40. package/dist/bin/setup.js +82 -10
  41. package/dist/bin/shard-migrate.js +682 -28
  42. package/dist/gateway/index.js +1629 -1295
  43. package/dist/hooks/bug-report-worker.js +1136 -183
  44. package/dist/hooks/codex-stop-task-finalizer.js +1060 -107
  45. package/dist/hooks/commit-complete.js +408 -33
  46. package/dist/hooks/error-recall.js +1608 -1300
  47. package/dist/hooks/ingest-worker.js +250 -7966
  48. package/dist/hooks/ingest.js +707 -119
  49. package/dist/hooks/instructions-loaded.js +383 -20
  50. package/dist/hooks/notification.js +383 -20
  51. package/dist/hooks/post-compact.js +384 -21
  52. package/dist/hooks/{response-ingest-worker.js → post-tool-combined.js} +4157 -1716
  53. package/dist/hooks/pre-compact.js +486 -45
  54. package/dist/hooks/pre-tool-use.js +385 -22
  55. package/dist/hooks/prompt-submit.js +291 -96
  56. package/dist/hooks/session-end.js +490 -48
  57. package/dist/hooks/session-start.js +236 -22
  58. package/dist/hooks/stop.js +192 -50
  59. package/dist/hooks/subagent-stop.js +95 -18
  60. package/dist/hooks/summary-worker.js +205 -361
  61. package/dist/index.js +221 -105
  62. package/dist/lib/agent-config.js +2 -2
  63. package/dist/lib/cloud-sync.js +27 -8
  64. package/dist/lib/consolidation.js +437 -41
  65. package/dist/lib/database.js +20 -8
  66. package/dist/lib/db-daemon-client.js +2 -2
  67. package/dist/lib/db.js +20 -8
  68. package/dist/lib/device-registry.js +27 -8
  69. package/dist/lib/employee-templates.js +62 -0
  70. package/dist/lib/employees.js +2 -2
  71. package/dist/lib/exe-daemon.js +6703 -6259
  72. package/dist/lib/hybrid-search.js +1608 -1300
  73. package/dist/lib/identity.js +1 -1
  74. package/dist/lib/messaging.js +11 -3
  75. package/dist/lib/reminders.js +1 -1
  76. package/dist/lib/schedules.js +718 -26
  77. package/dist/lib/session-registry.js +11 -0
  78. package/dist/lib/skill-learning.js +639 -9
  79. package/dist/lib/store.js +676 -27
  80. package/dist/lib/tasks.js +665 -27
  81. package/dist/lib/tmux-routing.js +732 -94
  82. package/dist/lib/token-spend.js +1 -1
  83. package/dist/mcp/server.js +856 -383
  84. package/dist/mcp/tools/complete-reminder.js +1 -1
  85. package/dist/mcp/tools/create-reminder.js +1 -1
  86. package/dist/mcp/tools/create-task.js +616 -46
  87. package/dist/mcp/tools/deactivate-behavior.js +9 -1
  88. package/dist/mcp/tools/list-reminders.js +1 -1
  89. package/dist/mcp/tools/list-tasks.js +10 -2
  90. package/dist/mcp/tools/send-message.js +11 -3
  91. package/dist/mcp/tools/update-task.js +677 -39
  92. package/dist/runtime/index.js +425 -37
  93. package/dist/tui/App.js +365 -34
  94. package/package.json +5 -2
  95. package/src/commands/exe/intercom.md +6 -17
  96. package/dist/bin/wiki-sync.js +0 -2991
  97. package/dist/hooks/prompt-ingest-worker.js +0 -3979
package/dist/tui/App.js CHANGED
@@ -44,6 +44,7 @@ var session_registry_exports = {};
44
44
  __export(session_registry_exports, {
45
45
  listSessions: () => listSessions,
46
46
  pruneStaleSessions: () => pruneStaleSessions,
47
+ refreshSessionProject: () => refreshSessionProject,
47
48
  registerSession: () => registerSession
48
49
  });
49
50
  import { readFileSync as readFileSync2, writeFileSync, mkdirSync, existsSync as existsSync2 } from "fs";
@@ -64,6 +65,16 @@ function registerSession(entry) {
64
65
  }
65
66
  writeFileSync(REGISTRY_PATH, JSON.stringify(sessions, null, 2));
66
67
  }
68
+ function refreshSessionProject(windowName, projectDir) {
69
+ const sessions = listSessions();
70
+ const entry = sessions.find((s) => s.windowName === windowName);
71
+ if (!entry || entry.projectDir === projectDir) return;
72
+ entry.projectDir = projectDir;
73
+ try {
74
+ writeFileSync(REGISTRY_PATH, JSON.stringify(sessions, null, 2));
75
+ } catch {
76
+ }
77
+ }
67
78
  function listSessions() {
68
79
  try {
69
80
  const raw = readFileSync2(REGISTRY_PATH, "utf8");
@@ -742,7 +753,7 @@ var init_agent_config = __esm({
742
753
  init_secure_files();
743
754
  AGENT_CONFIG_PATH = path3.join(EXE_AI_DIR, "agent-config.json");
744
755
  KNOWN_RUNTIMES = {
745
- claude: ["claude-opus-4", "claude-sonnet-4", "claude-haiku-4.5"],
756
+ claude: ["claude-opus-4.6", "claude-opus-4", "claude-sonnet-4.6", "claude-sonnet-4", "claude-haiku-4.5"],
746
757
  codex: ["gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark", "o3", "o4-mini"],
747
758
  opencode: ["anthropic/claude-sonnet-4-6", "openai/gpt-5.4", "google/gemini-2.5-pro", "deepseek/deepseek-r3", "minimax/minimax-m2.5"]
748
759
  };
@@ -752,7 +763,7 @@ var init_agent_config = __esm({
752
763
  opencode: "OpenCode (open source)"
753
764
  };
754
765
  DEFAULT_MODELS = {
755
- claude: "claude-opus-4",
766
+ claude: "claude-opus-4.6",
756
767
  codex: RUNTIME_TABLE.codex?.defaultModel ?? "gpt-5.4",
757
768
  opencode: RUNTIME_TABLE.opencode?.defaultModel ?? "anthropic/claude-sonnet-4-6"
758
769
  };
@@ -934,9 +945,9 @@ var MAX_RETRIES2, BASE_DELAY_MS, MAX_JITTER_MS;
934
945
  var init_db_retry = __esm({
935
946
  "src/lib/db-retry.ts"() {
936
947
  "use strict";
937
- MAX_RETRIES2 = 3;
938
- BASE_DELAY_MS = 200;
939
- MAX_JITTER_MS = 300;
948
+ MAX_RETRIES2 = 5;
949
+ BASE_DELAY_MS = 250;
950
+ MAX_JITTER_MS = 400;
940
951
  }
941
952
  });
942
953
 
@@ -1780,6 +1791,15 @@ var init_database_adapter = __esm({
1780
1791
  }
1781
1792
  });
1782
1793
 
1794
+ // src/types/memory.ts
1795
+ var EMBEDDING_DIM;
1796
+ var init_memory = __esm({
1797
+ "src/types/memory.ts"() {
1798
+ "use strict";
1799
+ EMBEDDING_DIM = 1024;
1800
+ }
1801
+ });
1802
+
1783
1803
  // src/lib/daemon-auth.ts
1784
1804
  import crypto from "crypto";
1785
1805
  import path7 from "path";
@@ -2054,6 +2074,9 @@ async function connectEmbedDaemon() {
2054
2074
  }
2055
2075
  return false;
2056
2076
  }
2077
+ function sendRequest(texts, priority) {
2078
+ return sendDaemonRequest({ texts, priority });
2079
+ }
2057
2080
  function sendDaemonRequest(payload, timeoutMs = REQUEST_TIMEOUT_MS) {
2058
2081
  return new Promise((resolve) => {
2059
2082
  if (!_socket || !_connected) {
@@ -2076,10 +2099,150 @@ function sendDaemonRequest(payload, timeoutMs = REQUEST_TIMEOUT_MS) {
2076
2099
  }
2077
2100
  });
2078
2101
  }
2102
+ async function pingDaemon() {
2103
+ if (!_socket || !_connected) return null;
2104
+ const response = await sendDaemonRequest({ type: "health" }, 5e3);
2105
+ if (response.health) {
2106
+ return response.health;
2107
+ }
2108
+ return null;
2109
+ }
2110
+ function killAndRespawnDaemon() {
2111
+ if (!acquireSpawnLock()) {
2112
+ process.stderr.write("[exed-client] Another process is already restarting daemon \u2014 skipping\n");
2113
+ if (_socket) {
2114
+ _socket.destroy();
2115
+ _socket = null;
2116
+ }
2117
+ _connected = false;
2118
+ _buffer = "";
2119
+ return;
2120
+ }
2121
+ try {
2122
+ process.stderr.write("[exed-client] Killing daemon for restart...\n");
2123
+ if (existsSync9(PID_PATH)) {
2124
+ try {
2125
+ const pid = parseInt(readFileSync8(PID_PATH, "utf8").trim(), 10);
2126
+ if (pid > 0) {
2127
+ try {
2128
+ process.kill(pid, "SIGKILL");
2129
+ } catch {
2130
+ }
2131
+ }
2132
+ } catch {
2133
+ }
2134
+ }
2135
+ if (_socket) {
2136
+ _socket.destroy();
2137
+ _socket = null;
2138
+ }
2139
+ _connected = false;
2140
+ _buffer = "";
2141
+ try {
2142
+ unlinkSync2(PID_PATH);
2143
+ } catch {
2144
+ }
2145
+ try {
2146
+ unlinkSync2(SOCKET_PATH);
2147
+ } catch {
2148
+ }
2149
+ spawnDaemon();
2150
+ } finally {
2151
+ releaseSpawnLock();
2152
+ }
2153
+ }
2154
+ function isDaemonTooYoung() {
2155
+ try {
2156
+ const stat = statSync(PID_PATH);
2157
+ return Date.now() - stat.mtimeMs < MIN_DAEMON_AGE_MS;
2158
+ } catch {
2159
+ return false;
2160
+ }
2161
+ }
2162
+ async function retryThenRestart(doRequest, label) {
2163
+ const result = await doRequest();
2164
+ if (!result.error) {
2165
+ _consecutiveFailures = 0;
2166
+ return result;
2167
+ }
2168
+ _consecutiveFailures++;
2169
+ for (let i = 0; i < MAX_RETRIES_BEFORE_RESTART; i++) {
2170
+ const delayMs = RETRY_DELAYS_MS[i] ?? 5e3;
2171
+ process.stderr.write(`[exed-client] ${label} failed (${result.error}), retry ${i + 1}/${MAX_RETRIES_BEFORE_RESTART} in ${delayMs}ms
2172
+ `);
2173
+ await new Promise((r) => setTimeout(r, delayMs));
2174
+ if (!_connected) {
2175
+ if (!await connectToSocket()) continue;
2176
+ }
2177
+ const retry = await doRequest();
2178
+ if (!retry.error) {
2179
+ _consecutiveFailures = 0;
2180
+ return retry;
2181
+ }
2182
+ _consecutiveFailures++;
2183
+ }
2184
+ if (isDaemonTooYoung()) {
2185
+ process.stderr.write(`[exed-client] ${label}: daemon too young (< ${MIN_DAEMON_AGE_MS / 1e3}s) \u2014 skipping restart
2186
+ `);
2187
+ return { error: result.error };
2188
+ }
2189
+ process.stderr.write(`[exed-client] ${label}: ${_consecutiveFailures} consecutive failures \u2014 restarting daemon
2190
+ `);
2191
+ killAndRespawnDaemon();
2192
+ const start = Date.now();
2193
+ let delay2 = 200;
2194
+ while (Date.now() - start < CONNECT_TIMEOUT_MS) {
2195
+ await new Promise((r) => setTimeout(r, delay2));
2196
+ if (await connectToSocket()) break;
2197
+ delay2 = Math.min(delay2 * 2, 3e3);
2198
+ }
2199
+ if (!_connected) return { error: "Daemon restart failed" };
2200
+ const final = await doRequest();
2201
+ if (!final.error) _consecutiveFailures = 0;
2202
+ return final;
2203
+ }
2204
+ async function embedViaClient(text, priority = "high") {
2205
+ if (!_connected && !await connectEmbedDaemon()) return null;
2206
+ _requestCount++;
2207
+ if (_requestCount % HEALTH_CHECK_INTERVAL === 0) {
2208
+ const health = await pingDaemon();
2209
+ if (!health && !isDaemonTooYoung()) {
2210
+ process.stderr.write(`[exed-client] Periodic health check failed at request ${_requestCount} \u2014 restarting daemon
2211
+ `);
2212
+ killAndRespawnDaemon();
2213
+ const start = Date.now();
2214
+ let d = 200;
2215
+ while (Date.now() - start < CONNECT_TIMEOUT_MS) {
2216
+ await new Promise((r) => setTimeout(r, d));
2217
+ if (await connectToSocket()) break;
2218
+ d = Math.min(d * 2, 3e3);
2219
+ }
2220
+ if (!_connected) return null;
2221
+ }
2222
+ }
2223
+ const result = await retryThenRestart(
2224
+ () => sendRequest([text], priority),
2225
+ "Embed"
2226
+ );
2227
+ return !result.error && result.vectors?.[0] ? result.vectors[0] : null;
2228
+ }
2229
+ function disconnectClient() {
2230
+ if (_socket) {
2231
+ _socket.destroy();
2232
+ _socket = null;
2233
+ }
2234
+ _connected = false;
2235
+ _buffer = "";
2236
+ for (const [id, entry] of _pending) {
2237
+ clearTimeout(entry.timer);
2238
+ _pending.delete(id);
2239
+ entry.resolve({ error: "Client disconnected" });
2240
+ }
2241
+ }
2079
2242
  function isClientConnected() {
2080
2243
  return _connected;
2081
2244
  }
2082
- var SOCKET_PATH, PID_PATH, SPAWN_LOCK_PATH, SPAWN_LOCK_STALE_MS, CONNECT_TIMEOUT_MS, REQUEST_TIMEOUT_MS, DAEMON_TOKEN_ENV, _socket, _connected, _buffer, _pending, MAX_BUFFER;
2245
+ var SOCKET_PATH, PID_PATH, SPAWN_LOCK_PATH, SPAWN_LOCK_STALE_MS, CONNECT_TIMEOUT_MS, REQUEST_TIMEOUT_MS, DAEMON_TOKEN_ENV, _socket, _connected, _buffer, _requestCount, _consecutiveFailures, HEALTH_CHECK_INTERVAL, MAX_RETRIES_BEFORE_RESTART, RETRY_DELAYS_MS, MIN_DAEMON_AGE_MS, _pending, MAX_BUFFER;
2083
2246
  var init_exe_daemon_client = __esm({
2084
2247
  "src/lib/exe-daemon-client.ts"() {
2085
2248
  "use strict";
@@ -2095,6 +2258,12 @@ var init_exe_daemon_client = __esm({
2095
2258
  _socket = null;
2096
2259
  _connected = false;
2097
2260
  _buffer = "";
2261
+ _requestCount = 0;
2262
+ _consecutiveFailures = 0;
2263
+ HEALTH_CHECK_INTERVAL = 100;
2264
+ MAX_RETRIES_BEFORE_RESTART = 3;
2265
+ RETRY_DELAYS_MS = [1e3, 3e3, 5e3];
2266
+ MIN_DAEMON_AGE_MS = 3e4;
2098
2267
  _pending = /* @__PURE__ */ new Map();
2099
2268
  MAX_BUFFER = 1e7;
2100
2269
  }
@@ -2202,7 +2371,7 @@ function createDaemonDbClient(fallbackClient) {
2202
2371
  });
2203
2372
  if (response.error) {
2204
2373
  const errMsg = String(response.error);
2205
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
2374
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
2206
2375
  process.stderr.write(`[db-daemon] Transport error (${errMsg}), falling back to direct
2207
2376
  `);
2208
2377
  return fallbackClient.execute(stmt);
@@ -2227,7 +2396,7 @@ function createDaemonDbClient(fallbackClient) {
2227
2396
  });
2228
2397
  if (response.error) {
2229
2398
  const errMsg = String(response.error);
2230
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
2399
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
2231
2400
  process.stderr.write(`[db-daemon] Batch transport error (${errMsg}), falling back to direct
2232
2401
  `);
2233
2402
  return fallbackClient.batch(stmts, mode);
@@ -2350,7 +2519,7 @@ async function initDatabase(config) {
2350
2519
  });
2351
2520
  }, 3e4);
2352
2521
  _walCheckpointTimer.unref();
2353
- if (process.env.DATABASE_URL) {
2522
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
2354
2523
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
2355
2524
  }
2356
2525
  }
@@ -2361,7 +2530,7 @@ function getClient() {
2361
2530
  if (!_adapterClient) {
2362
2531
  throw new Error("Database client not initialized. Call initDatabase() first.");
2363
2532
  }
2364
- if (process.env.DATABASE_URL) {
2533
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
2365
2534
  return _adapterClient;
2366
2535
  }
2367
2536
  if (process.env.EXE_IS_DAEMON === "1") {
@@ -2373,9 +2542,11 @@ function getClient() {
2373
2542
  return _resilientClient;
2374
2543
  }
2375
2544
  async function initDaemonClient() {
2376
- if (process.env.DATABASE_URL) return;
2545
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") return;
2377
2546
  if (process.env.EXE_IS_DAEMON === "1") return;
2547
+ if (process.env.VITEST) return;
2378
2548
  if (!_resilientClient) return;
2549
+ if (_daemonClient) return;
2379
2550
  try {
2380
2551
  const { initDaemonDbClient: initDaemonDbClient2 } = await Promise.resolve().then(() => (init_db_daemon_client(), db_daemon_client_exports));
2381
2552
  _daemonClient = await initDaemonDbClient2(_resilientClient);
@@ -2524,6 +2695,13 @@ async function ensureSchema() {
2524
2695
  });
2525
2696
  } catch {
2526
2697
  }
2698
+ try {
2699
+ await client.execute({
2700
+ sql: `ALTER TABLE behaviors ADD COLUMN vector F32_BLOB(${EMBEDDING_DIM})`,
2701
+ args: []
2702
+ });
2703
+ } catch {
2704
+ }
2527
2705
  try {
2528
2706
  await client.execute({
2529
2707
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3394,6 +3572,7 @@ var init_database = __esm({
3394
3572
  init_db_retry();
3395
3573
  init_employees();
3396
3574
  init_database_adapter();
3575
+ init_memory();
3397
3576
  _client = null;
3398
3577
  _resilientClient = null;
3399
3578
  _walCheckpointTimer = null;
@@ -4345,15 +4524,20 @@ async function createTaskCore(input) {
4345
4524
  const { resolveExeSession: resolveExeSession2 } = await Promise.resolve().then(() => (init_tmux_routing(), tmux_routing_exports));
4346
4525
  const resolved = resolveExeSession2();
4347
4526
  if (resolved && input.projectName) {
4348
- const { getSessionProject: getSessionProject2 } = await Promise.resolve().then(() => (init_session_scope(), session_scope_exports));
4349
- const sessionProject = getSessionProject2(resolved);
4350
- if (sessionProject && sessionProject !== input.projectName) {
4351
- scopeMismatchWarning = `session/project mismatch: session "${resolved}" owns "${sessionProject}" but task targets "${input.projectName}". Routed to default scope.`;
4352
- process.stderr.write(`[create_task] ${scopeMismatchWarning}
4353
- `);
4354
- earlySessionScope = null;
4355
- } else {
4527
+ const isCoordinatorSession = !resolved.includes("-");
4528
+ if (isCoordinatorSession) {
4356
4529
  earlySessionScope = resolved;
4530
+ } else {
4531
+ const { getSessionProject: getSessionProject2 } = await Promise.resolve().then(() => (init_session_scope(), session_scope_exports));
4532
+ const sessionProject = getSessionProject2(resolved);
4533
+ if (sessionProject && sessionProject !== input.projectName) {
4534
+ scopeMismatchWarning = `session/project mismatch: session "${resolved}" owns "${sessionProject}" but task targets "${input.projectName}". Routed to default scope.`;
4535
+ process.stderr.write(`[create_task] ${scopeMismatchWarning}
4536
+ `);
4537
+ earlySessionScope = null;
4538
+ } else {
4539
+ earlySessionScope = resolved;
4540
+ }
4357
4541
  }
4358
4542
  } else {
4359
4543
  earlySessionScope = resolved;
@@ -5238,6 +5422,10 @@ async function dispatchTaskToEmployee(input) {
5238
5422
  if (transport.isAlive(sessionName)) {
5239
5423
  const result = sendIntercom(sessionName);
5240
5424
  const dispatched = result === "acknowledged" || result === "debounced" || result === "queued" ? "verified" : result === "delivered" ? "sent_unverified" : "session_dead";
5425
+ process.stderr.write(
5426
+ `[dispatch-audit] intercom \u2192 ${sessionName} | task="${input.title}" [${input.priority}] | result=${dispatched} (sendIntercom=${result})
5427
+ `
5428
+ );
5241
5429
  return { dispatched, session: sessionName, crossProject };
5242
5430
  } else {
5243
5431
  const projectDir = input.projectDir ?? process.cwd();
@@ -5246,11 +5434,15 @@ async function dispatchTaskToEmployee(input) {
5246
5434
  });
5247
5435
  if (result.status === "failed") {
5248
5436
  process.stderr.write(
5249
- `[dispatch] Failed to spawn ${input.assignedTo}: ${result.error}
5437
+ `[dispatch-audit] SPAWN FAILED \u2192 ${input.assignedTo} | task="${input.title}" [${input.priority}] | error=${result.error}
5250
5438
  `
5251
5439
  );
5252
5440
  return { dispatched: "session_missing" };
5253
5441
  }
5442
+ process.stderr.write(
5443
+ `[dispatch-audit] SPAWNED \u2192 ${result.sessionName} | task="${input.title}" [${input.priority}]
5444
+ `
5445
+ );
5254
5446
  return { dispatched: "spawned", session: result.sessionName, crossProject };
5255
5447
  }
5256
5448
  } catch {
@@ -5260,7 +5452,13 @@ async function dispatchTaskToEmployee(input) {
5260
5452
  function notifyTaskDone() {
5261
5453
  try {
5262
5454
  const key = getSessionKey();
5263
- if (key && !process.env.VITEST) notifyParentExe(key);
5455
+ if (key && !process.env.VITEST) {
5456
+ notifyParentExe(key);
5457
+ process.stderr.write(
5458
+ `[dispatch-audit] notifyTaskDone \u2192 parent coordinator (session=${key})
5459
+ `
5460
+ );
5461
+ }
5264
5462
  } catch {
5265
5463
  }
5266
5464
  }
@@ -5281,16 +5479,91 @@ var init_tasks_notify = __esm({
5281
5479
  }
5282
5480
  });
5283
5481
 
5482
+ // src/lib/embedder.ts
5483
+ var embedder_exports = {};
5484
+ __export(embedder_exports, {
5485
+ disposeEmbedder: () => disposeEmbedder,
5486
+ embed: () => embed,
5487
+ embedDirect: () => embedDirect,
5488
+ getEmbedder: () => getEmbedder
5489
+ });
5490
+ async function getEmbedder() {
5491
+ const ok = await connectEmbedDaemon();
5492
+ if (!ok) {
5493
+ throw new Error(
5494
+ "Could not connect to embedding daemon. Ensure the model is installed (run /exe-setup)."
5495
+ );
5496
+ }
5497
+ }
5498
+ async function embed(text) {
5499
+ const priority = process.env.EXE_EMBED_PRIORITY === "low" ? "low" : "high";
5500
+ const vector = await embedViaClient(text, priority);
5501
+ if (!vector) {
5502
+ throw new Error(
5503
+ "Embedding failed: daemon unavailable. Run /exe-setup to verify model installation."
5504
+ );
5505
+ }
5506
+ if (vector.length !== EMBEDDING_DIM) {
5507
+ throw new Error(
5508
+ `Embedding dimension mismatch: expected ${EMBEDDING_DIM}, got ${vector.length}. Ensure the correct Jina v5-small Q4_K_M GGUF model is installed.`
5509
+ );
5510
+ }
5511
+ return vector;
5512
+ }
5513
+ async function disposeEmbedder() {
5514
+ disconnectClient();
5515
+ }
5516
+ async function embedDirect(text) {
5517
+ const llamaCpp = await import("node-llama-cpp");
5518
+ const { MODELS_DIR: MODELS_DIR2 } = await Promise.resolve().then(() => (init_config(), config_exports));
5519
+ const { existsSync: existsSync18 } = await import("fs");
5520
+ const path28 = await import("path");
5521
+ const modelPath = path28.join(MODELS_DIR2, "jina-embeddings-v5-small-q4_k_m.gguf");
5522
+ if (!existsSync18(modelPath)) {
5523
+ throw new Error(`Embedding model not found at ${modelPath}. Run '/exe-setup' to download it.`);
5524
+ }
5525
+ const llama = await llamaCpp.getLlama();
5526
+ const model = await llama.loadModel({ modelPath });
5527
+ const context = await model.createEmbeddingContext();
5528
+ try {
5529
+ const embedding = await context.getEmbeddingFor(text);
5530
+ const vector = Array.from(embedding.vector);
5531
+ if (vector.length !== EMBEDDING_DIM) {
5532
+ throw new Error(
5533
+ `Embedding dimension mismatch: expected ${EMBEDDING_DIM}, got ${vector.length}.`
5534
+ );
5535
+ }
5536
+ return vector;
5537
+ } finally {
5538
+ await context.dispose();
5539
+ await model.dispose();
5540
+ }
5541
+ }
5542
+ var init_embedder = __esm({
5543
+ "src/lib/embedder.ts"() {
5544
+ "use strict";
5545
+ init_memory();
5546
+ init_exe_daemon_client();
5547
+ }
5548
+ });
5549
+
5284
5550
  // src/lib/behaviors.ts
5285
5551
  import crypto5 from "crypto";
5286
5552
  async function storeBehavior(opts) {
5287
5553
  const client = getClient();
5288
5554
  const id = crypto5.randomUUID();
5289
5555
  const now = (/* @__PURE__ */ new Date()).toISOString();
5556
+ let vector = null;
5557
+ try {
5558
+ const { embed: embed2 } = await Promise.resolve().then(() => (init_embedder(), embedder_exports));
5559
+ const vec = await embed2(opts.content);
5560
+ vector = new Float32Array(vec);
5561
+ } catch {
5562
+ }
5290
5563
  await client.execute({
5291
- sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at)
5292
- VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?)`,
5293
- args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now]
5564
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector)
5565
+ VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?)`,
5566
+ args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now, vector ? vector.buffer : null]
5294
5567
  });
5295
5568
  return id;
5296
5569
  }
@@ -6393,7 +6666,7 @@ function isSessionBusy(sessionName) {
6393
6666
  function isExeSession(sessionName) {
6394
6667
  const matchesBaseWithInstance = (baseName) => sessionName === baseName || sessionName.startsWith(baseName) && /^\d+$/.test(sessionName.slice(baseName.length));
6395
6668
  const coordinatorName = getCoordinatorName();
6396
- return matchesBaseWithInstance(coordinatorName) || matchesBaseWithInstance("exe");
6669
+ return matchesBaseWithInstance(coordinatorName);
6397
6670
  }
6398
6671
  function sendIntercom(targetSession) {
6399
6672
  const transport = getTransport();
@@ -8295,6 +8568,68 @@ var init_platform_procedures = __esm({
8295
8568
  domain: "architecture",
8296
8569
  priority: "p0",
8297
8570
  content: "Tasks live in the DB. Intercom (tmux send-keys) is fire-and-forget \u2014 it may fail, get garbled, or arrive mid-work. Never rely on intercom for task delivery. The UserPromptSubmit hook checks the DB for new tasks on every prompt. Your operating procedures step 7 says check for next work. The daemon nudges idle agents as a speedup. If you have no tasks, you found them all."
8571
+ },
8572
+ // --- MCP is the ONLY data interface ---
8573
+ {
8574
+ title: "MCP disconnect \u2014 ask the user, never work around it",
8575
+ domain: "workflow",
8576
+ priority: "p0",
8577
+ content: "If MCP tools are unavailable, disconnected, or returning connection errors: STOP. Tell the user clearly: 'MCP server is disconnected. Please run /mcp to reconnect.' Do NOT attempt workarounds \u2014 no raw Node imports, no direct DB access, no CLI hacks, no daemon socket calls. MCP is the ONLY data interface. Working around it wastes time, hits bundling issues, and bypasses the contract boundary. Ask once, wait, proceed when reconnected."
8578
+ },
8579
+ // --- MCP Tool Catalog (Layer 0 — every agent knows what tools exist) ---
8580
+ {
8581
+ title: "MCP tools \u2014 memory and search",
8582
+ domain: "tool-use",
8583
+ priority: "p1",
8584
+ content: "recall_my_memory: search your own memories (semantic + FTS). ask_team_memory: search a colleague's memories by agent name. store_memory: persist a memory (decisions, summaries, context). commit_memory: high-importance memory that survives consolidation. search_everything: unified search across memories, tasks, entities, conversations. get_session_context: temporal window of memories around a timestamp. consolidate_memories: merge duplicate/related memories into insights. get_memory_cardinality: count memories per agent (health check)."
8585
+ },
8586
+ {
8587
+ title: "MCP tools \u2014 task orchestration",
8588
+ domain: "tool-use",
8589
+ priority: "p1",
8590
+ content: "create_task: dispatch work to an employee (auto-spawns session). The ONLY dispatch path. list_tasks: query tasks by status, assignee, project. get_task: fetch full task details by ID. update_task: change status (in_progress, done, blocked, cancelled) + add result summary. close_task: finalize a reviewed task (COO only). checkpoint_task: save progress state for crash recovery. resume_employee: re-spawn an employee session for an existing task."
8591
+ },
8592
+ {
8593
+ title: "MCP tools \u2014 knowledge graph (GraphRAG)",
8594
+ domain: "tool-use",
8595
+ priority: "p1",
8596
+ content: "query_relationships: find connections between entities in the knowledge graph. get_entity_neighbors: explore an entity's direct connections. get_hot_entities: find most-referenced entities (trending topics). get_graph_stats: graph health \u2014 entity/relationship counts, density. export_graph: export graph data for visualization. merge_entities: deduplicate entities (alias resolution). find_similar_trajectories: match tool-call patterns to past task solutions."
8597
+ },
8598
+ {
8599
+ title: "MCP tools \u2014 identity, behavior, and decisions",
8600
+ domain: "tool-use",
8601
+ priority: "p1",
8602
+ content: "get_identity: read an agent's exe.md (Layer 1 identity). update_identity: write an agent's exe.md. Identity > behavior \u2014 use for permanent rules. store_behavior: record a correction or pattern for an agent (Layer 2 expertise). list_behaviors: view an agent's active behaviors. deactivate_behavior: soft-delete a stale or conflicting behavior. store_decision: record an ADR (architectural decision record). get_decision: retrieve a past decision by query."
8603
+ },
8604
+ {
8605
+ title: "MCP tools \u2014 communication and messaging",
8606
+ domain: "tool-use",
8607
+ priority: "p1",
8608
+ content: "send_message: send supplementary context to another agent (NOT for actionable work \u2014 use create_task). acknowledge_messages: mark messages as read. send_whatsapp: send WhatsApp message via gateway (customer-facing alerts). query_conversations: search ingested conversations across all channels (WhatsApp, email, etc.)."
8609
+ },
8610
+ {
8611
+ title: "MCP tools \u2014 wiki, documents, and content",
8612
+ domain: "tool-use",
8613
+ priority: "p1",
8614
+ content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
8615
+ },
8616
+ {
8617
+ title: "MCP tools \u2014 system, operations, and admin",
8618
+ domain: "tool-use",
8619
+ priority: "p1",
8620
+ content: "get_agent_spend: token usage per agent/session (cost tracking). list_agent_sessions: view agent session history. get_session_kills: audit log of killed sessions. get_daemon_health: check exed daemon status. get_auto_wake_status: daemon auto-wake configuration. get_worker_gate: check worker deployment gates. run_memory_audit: health check \u2014 duplicates, null vectors, orphaned rows. run_consolidation: trigger sleep-time memory consolidation. cloud_sync: force a cloud sync cycle. backup_vps: trigger VPS backup."
8621
+ },
8622
+ {
8623
+ title: "MCP tools \u2014 config, licensing, and team",
8624
+ domain: "tool-use",
8625
+ priority: "p1",
8626
+ content: "set_agent_config: view/change per-agent runtime and model settings. list_employees: view the employee roster. add_person: add a person to the CRM contacts roster. list_people: browse CRM contacts. get_person: fetch contact details. get_license_status: check license validity. create_license: generate a new license key (admin). list_licenses: view all issued licenses. activate_license: activate a license on a device."
8627
+ },
8628
+ {
8629
+ title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
8630
+ domain: "tool-use",
8631
+ priority: "p1",
8632
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
8298
8633
  }
8299
8634
  ];
8300
8635
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -10548,15 +10883,6 @@ var init_wiki_client = __esm({
10548
10883
  }
10549
10884
  });
10550
10885
 
10551
- // src/types/memory.ts
10552
- var EMBEDDING_DIM;
10553
- var init_memory = __esm({
10554
- "src/types/memory.ts"() {
10555
- "use strict";
10556
- EMBEDDING_DIM = 1024;
10557
- }
10558
- });
10559
-
10560
10886
  // src/lib/shard-manager.ts
10561
10887
  var shard_manager_exports = {};
10562
10888
  __export(shard_manager_exports, {
@@ -10949,6 +11275,11 @@ async function initStore(options) {
10949
11275
  encryptionKey: hexKey
10950
11276
  });
10951
11277
  await retryOnBusy2(() => ensureSchema(), "ensureSchema");
11278
+ try {
11279
+ const { initDaemonClient: initDaemonClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
11280
+ await initDaemonClient2();
11281
+ } catch {
11282
+ }
10952
11283
  if (!options?.lightweight) {
10953
11284
  try {
10954
11285
  const { initShardManager: initShardManager2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askexenow/exe-os",
3
- "version": "0.9.16",
3
+ "version": "0.9.18",
4
4
  "description": "AI employee operating system — persistent memory, task management, and multi-agent coordination for Claude Code.",
5
5
  "license": "CC-BY-NC-4.0",
6
6
  "type": "module",
@@ -56,6 +56,9 @@
56
56
  "./dist/hooks/*.js": "./dist/hooks/*.js",
57
57
  "./mcp/server": "./dist/mcp/server.js"
58
58
  },
59
+ "overrides": {
60
+ "protobufjs": ">=7.5.5"
61
+ },
59
62
  "engines": {
60
63
  "node": ">=20.0.0"
61
64
  },
@@ -64,7 +67,7 @@
64
67
  "test:watch": "vitest",
65
68
  "typecheck": "tsc --noEmit",
66
69
  "build": "tsup && mkdir -p dist/assets && cp src/assets/tmux.conf dist/assets/ && cp src/assets/ghostty.conf dist/assets/ && cp src/assets/statusline-command.sh dist/assets/ && cp src/bin/exe-start.sh dist/bin/exe-start.sh",
67
- "deploy": "node dist/bin/pre-build-guard.js 2>/dev/null; tsup && mkdir -p dist/assets && cp src/assets/tmux.conf dist/assets/ && cp src/assets/ghostty.conf dist/assets/ && cp src/assets/statusline-command.sh dist/assets/ && cp src/bin/exe-start.sh dist/bin/exe-start.sh && npm install -g . && node dist/bin/install.js --global && echo '[exe-os] Deploy complete. MCP servers will auto-reconnect on next tool call.'",
70
+ "deploy": "node dist/bin/pre-build-guard.js 2>/dev/null; (kill $(cat ~/.exe-os/exed.pid 2>/dev/null) 2>/dev/null; pgrep -f exe-daemon.js | xargs kill 2>/dev/null; true) && tsup && mkdir -p dist/assets && cp src/assets/tmux.conf dist/assets/ && cp src/assets/ghostty.conf dist/assets/ && cp src/assets/statusline-command.sh dist/assets/ && cp src/bin/exe-start.sh dist/bin/exe-start.sh && npm install -g . && node dist/bin/install.js --global && echo '[exe-os] Deploy complete. MCP servers will auto-reconnect on next tool call.'",
68
71
  "postinstall": "node dist/bin/install.js --global 2>/dev/null || true",
69
72
  "prepublishOnly": "npm run typecheck && npm run build && node dist/bin/customer-readiness.js",
70
73
  "test:publish": "npx vitest run --maxWorkers=4 --exclude 'tests/tui/**' --exclude 'tests/lib/tmux-routing.test.ts' --exclude 'tests/lib/intercom-routing.test.ts' --exclude 'tests/gateway/**' --exclude 'tests/installer/setup-wizard.test.ts' --exclude 'tests/mcp/ingest-document.test.ts' --exclude 'tests/lib/hybrid-search.test.ts' --exclude 'tests/lib/worker-gate.test.ts'",
@@ -33,25 +33,14 @@ if [ "$AGENT" = "UNKNOWN" ] || [ "$AGENT" = "default" ]; then
33
33
  exit 0
34
34
  fi
35
35
 
36
- # Coordinator gets review notifications instead of task dispatch
36
+ # Single combined check one Node process for all intercom queries.
37
+ # Replaces 3 separate node invocations (scan-tasks + messages + notifications)
38
+ # that each paid full Node.js startup + DB init cost (10-20s saved).
37
39
  if [ "$AGENT" = "$COORDINATOR" ] || [ "$AGENT" = "exe" ]; then
38
- node "$(npm root -g)/@askexenow/exe-os/dist/bin/exe-pending-reviews.js" 2>/dev/null
39
- # The coordinator also subscribes to notifications (subtasks_complete, task_complete, etc.)
40
- # so parent-of-parent rollups surface live instead of only at boot.
41
- node "$(npm root -g)/@askexenow/exe-os/dist/bin/exe-pending-notifications.js" "$AGENT" 2>/dev/null
42
- exit 0
40
+ EXE_SESSION="$SESSION_NAME" EXE_SESSION_NAME="$SESSION_NAME" node "$(npm root -g)/@askexenow/exe-os/dist/bin/intercom-check.js" "$AGENT" --coordinator 2>/dev/null
41
+ else
42
+ EXE_SESSION="$SESSION_NAME" EXE_SESSION_NAME="$SESSION_NAME" node "$(npm root -g)/@askexenow/exe-os/dist/bin/intercom-check.js" "$AGENT" 2>/dev/null
43
43
  fi
44
-
45
- # Use canonical scanner — single source of truth for task status detection
46
- node "$(npm root -g)/@askexenow/exe-os/dist/bin/scan-tasks.js" "exe/$AGENT" --format=mandatory 2>/dev/null
47
-
48
- # Check for pending messages
49
- node "$(npm root -g)/@askexenow/exe-os/dist/bin/exe-pending-messages.js" "$AGENT" 2>/dev/null
50
-
51
- # Check for pending notifications (subtasks_complete, rollup signals, etc.)
52
- # Employees acting as parent-of-parents need these too — not only the coordinator.
53
- # See the parent-cascade audit §6.
54
- node "$(npm root -g)/@askexenow/exe-os/dist/bin/exe-pending-notifications.js" "$AGENT" 2>/dev/null
55
44
  ```
56
45
 
57
46
  ### For the coordinator