@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/index.js CHANGED
@@ -402,7 +402,7 @@ var init_agent_config = __esm({
402
402
  init_secure_files();
403
403
  AGENT_CONFIG_PATH = path3.join(EXE_AI_DIR, "agent-config.json");
404
404
  KNOWN_RUNTIMES = {
405
- claude: ["claude-opus-4", "claude-sonnet-4", "claude-haiku-4.5"],
405
+ claude: ["claude-opus-4.6", "claude-opus-4", "claude-sonnet-4.6", "claude-sonnet-4", "claude-haiku-4.5"],
406
406
  codex: ["gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark", "o3", "o4-mini"],
407
407
  opencode: ["anthropic/claude-sonnet-4-6", "openai/gpt-5.4", "google/gemini-2.5-pro", "deepseek/deepseek-r3", "minimax/minimax-m2.5"]
408
408
  };
@@ -412,7 +412,7 @@ var init_agent_config = __esm({
412
412
  opencode: "OpenCode (open source)"
413
413
  };
414
414
  DEFAULT_MODELS = {
415
- claude: "claude-opus-4",
415
+ claude: "claude-opus-4.6",
416
416
  codex: RUNTIME_TABLE.codex?.defaultModel ?? "gpt-5.4",
417
417
  opencode: RUNTIME_TABLE.opencode?.defaultModel ?? "anthropic/claude-sonnet-4-6"
418
418
  };
@@ -680,6 +680,7 @@ var session_registry_exports = {};
680
680
  __export(session_registry_exports, {
681
681
  listSessions: () => listSessions,
682
682
  pruneStaleSessions: () => pruneStaleSessions,
683
+ refreshSessionProject: () => refreshSessionProject,
683
684
  registerSession: () => registerSession
684
685
  });
685
686
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, existsSync as existsSync5 } from "fs";
@@ -700,6 +701,16 @@ function registerSession(entry) {
700
701
  }
701
702
  writeFileSync3(REGISTRY_PATH, JSON.stringify(sessions, null, 2));
702
703
  }
704
+ function refreshSessionProject(windowName, projectDir) {
705
+ const sessions = listSessions();
706
+ const entry = sessions.find((s) => s.windowName === windowName);
707
+ if (!entry || entry.projectDir === projectDir) return;
708
+ entry.projectDir = projectDir;
709
+ try {
710
+ writeFileSync3(REGISTRY_PATH, JSON.stringify(sessions, null, 2));
711
+ } catch {
712
+ }
713
+ }
703
714
  function listSessions() {
704
715
  try {
705
716
  const raw = readFileSync4(REGISTRY_PATH, "utf8");
@@ -1178,9 +1189,9 @@ var MAX_RETRIES2, BASE_DELAY_MS, MAX_JITTER_MS;
1178
1189
  var init_db_retry = __esm({
1179
1190
  "src/lib/db-retry.ts"() {
1180
1191
  "use strict";
1181
- MAX_RETRIES2 = 3;
1182
- BASE_DELAY_MS = 200;
1183
- MAX_JITTER_MS = 300;
1192
+ MAX_RETRIES2 = 5;
1193
+ BASE_DELAY_MS = 250;
1194
+ MAX_JITTER_MS = 400;
1184
1195
  }
1185
1196
  });
1186
1197
 
@@ -1768,6 +1779,15 @@ var init_database_adapter = __esm({
1768
1779
  }
1769
1780
  });
1770
1781
 
1782
+ // src/types/memory.ts
1783
+ var EMBEDDING_DIM;
1784
+ var init_memory = __esm({
1785
+ "src/types/memory.ts"() {
1786
+ "use strict";
1787
+ EMBEDDING_DIM = 1024;
1788
+ }
1789
+ });
1790
+
1771
1791
  // src/lib/daemon-auth.ts
1772
1792
  import crypto from "crypto";
1773
1793
  import path8 from "path";
@@ -2339,7 +2359,7 @@ function createDaemonDbClient(fallbackClient) {
2339
2359
  });
2340
2360
  if (response.error) {
2341
2361
  const errMsg = String(response.error);
2342
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
2362
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
2343
2363
  process.stderr.write(`[db-daemon] Transport error (${errMsg}), falling back to direct
2344
2364
  `);
2345
2365
  return fallbackClient.execute(stmt);
@@ -2364,7 +2384,7 @@ function createDaemonDbClient(fallbackClient) {
2364
2384
  });
2365
2385
  if (response.error) {
2366
2386
  const errMsg = String(response.error);
2367
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
2387
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
2368
2388
  process.stderr.write(`[db-daemon] Batch transport error (${errMsg}), falling back to direct
2369
2389
  `);
2370
2390
  return fallbackClient.batch(stmts, mode);
@@ -2487,7 +2507,7 @@ async function initDatabase(config2) {
2487
2507
  });
2488
2508
  }, 3e4);
2489
2509
  _walCheckpointTimer.unref();
2490
- if (process.env.DATABASE_URL) {
2510
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
2491
2511
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
2492
2512
  }
2493
2513
  }
@@ -2498,7 +2518,7 @@ function getClient() {
2498
2518
  if (!_adapterClient) {
2499
2519
  throw new Error("Database client not initialized. Call initDatabase() first.");
2500
2520
  }
2501
- if (process.env.DATABASE_URL) {
2521
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
2502
2522
  return _adapterClient;
2503
2523
  }
2504
2524
  if (process.env.EXE_IS_DAEMON === "1") {
@@ -2510,9 +2530,11 @@ function getClient() {
2510
2530
  return _resilientClient;
2511
2531
  }
2512
2532
  async function initDaemonClient() {
2513
- if (process.env.DATABASE_URL) return;
2533
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") return;
2514
2534
  if (process.env.EXE_IS_DAEMON === "1") return;
2535
+ if (process.env.VITEST) return;
2515
2536
  if (!_resilientClient) return;
2537
+ if (_daemonClient) return;
2516
2538
  try {
2517
2539
  const { initDaemonDbClient: initDaemonDbClient2 } = await Promise.resolve().then(() => (init_db_daemon_client(), db_daemon_client_exports));
2518
2540
  _daemonClient = await initDaemonDbClient2(_resilientClient);
@@ -2661,6 +2683,13 @@ async function ensureSchema() {
2661
2683
  });
2662
2684
  } catch {
2663
2685
  }
2686
+ try {
2687
+ await client.execute({
2688
+ sql: `ALTER TABLE behaviors ADD COLUMN vector F32_BLOB(${EMBEDDING_DIM})`,
2689
+ args: []
2690
+ });
2691
+ } catch {
2692
+ }
2664
2693
  try {
2665
2694
  await client.execute({
2666
2695
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3531,6 +3560,7 @@ var init_database = __esm({
3531
3560
  init_db_retry();
3532
3561
  init_employees();
3533
3562
  init_database_adapter();
3563
+ init_memory();
3534
3564
  _client = null;
3535
3565
  _resilientClient = null;
3536
3566
  _walCheckpointTimer = null;
@@ -4065,15 +4095,20 @@ async function createTaskCore(input) {
4065
4095
  const { resolveExeSession: resolveExeSession2 } = await Promise.resolve().then(() => (init_tmux_routing(), tmux_routing_exports));
4066
4096
  const resolved = resolveExeSession2();
4067
4097
  if (resolved && input.projectName) {
4068
- const { getSessionProject: getSessionProject2 } = await Promise.resolve().then(() => (init_session_scope(), session_scope_exports));
4069
- const sessionProject = getSessionProject2(resolved);
4070
- if (sessionProject && sessionProject !== input.projectName) {
4071
- scopeMismatchWarning = `session/project mismatch: session "${resolved}" owns "${sessionProject}" but task targets "${input.projectName}". Routed to default scope.`;
4072
- process.stderr.write(`[create_task] ${scopeMismatchWarning}
4073
- `);
4074
- earlySessionScope = null;
4075
- } else {
4098
+ const isCoordinatorSession = !resolved.includes("-");
4099
+ if (isCoordinatorSession) {
4076
4100
  earlySessionScope = resolved;
4101
+ } else {
4102
+ const { getSessionProject: getSessionProject2 } = await Promise.resolve().then(() => (init_session_scope(), session_scope_exports));
4103
+ const sessionProject = getSessionProject2(resolved);
4104
+ if (sessionProject && sessionProject !== input.projectName) {
4105
+ scopeMismatchWarning = `session/project mismatch: session "${resolved}" owns "${sessionProject}" but task targets "${input.projectName}". Routed to default scope.`;
4106
+ process.stderr.write(`[create_task] ${scopeMismatchWarning}
4107
+ `);
4108
+ earlySessionScope = null;
4109
+ } else {
4110
+ earlySessionScope = resolved;
4111
+ }
4077
4112
  }
4078
4113
  } else {
4079
4114
  earlySessionScope = resolved;
@@ -4958,6 +4993,10 @@ async function dispatchTaskToEmployee(input) {
4958
4993
  if (transport.isAlive(sessionName)) {
4959
4994
  const result = sendIntercom(sessionName);
4960
4995
  const dispatched = result === "acknowledged" || result === "debounced" || result === "queued" ? "verified" : result === "delivered" ? "sent_unverified" : "session_dead";
4996
+ process.stderr.write(
4997
+ `[dispatch-audit] intercom \u2192 ${sessionName} | task="${input.title}" [${input.priority}] | result=${dispatched} (sendIntercom=${result})
4998
+ `
4999
+ );
4961
5000
  return { dispatched, session: sessionName, crossProject };
4962
5001
  } else {
4963
5002
  const projectDir = input.projectDir ?? process.cwd();
@@ -4966,11 +5005,15 @@ async function dispatchTaskToEmployee(input) {
4966
5005
  });
4967
5006
  if (result.status === "failed") {
4968
5007
  process.stderr.write(
4969
- `[dispatch] Failed to spawn ${input.assignedTo}: ${result.error}
5008
+ `[dispatch-audit] SPAWN FAILED \u2192 ${input.assignedTo} | task="${input.title}" [${input.priority}] | error=${result.error}
4970
5009
  `
4971
5010
  );
4972
5011
  return { dispatched: "session_missing" };
4973
5012
  }
5013
+ process.stderr.write(
5014
+ `[dispatch-audit] SPAWNED \u2192 ${result.sessionName} | task="${input.title}" [${input.priority}]
5015
+ `
5016
+ );
4974
5017
  return { dispatched: "spawned", session: result.sessionName, crossProject };
4975
5018
  }
4976
5019
  } catch {
@@ -4980,7 +5023,13 @@ async function dispatchTaskToEmployee(input) {
4980
5023
  function notifyTaskDone() {
4981
5024
  try {
4982
5025
  const key = getSessionKey();
4983
- if (key && !process.env.VITEST) notifyParentExe(key);
5026
+ if (key && !process.env.VITEST) {
5027
+ notifyParentExe(key);
5028
+ process.stderr.write(
5029
+ `[dispatch-audit] notifyTaskDone \u2192 parent coordinator (session=${key})
5030
+ `
5031
+ );
5032
+ }
4984
5033
  } catch {
4985
5034
  }
4986
5035
  }
@@ -5001,6 +5050,74 @@ var init_tasks_notify = __esm({
5001
5050
  }
5002
5051
  });
5003
5052
 
5053
+ // src/lib/embedder.ts
5054
+ var embedder_exports = {};
5055
+ __export(embedder_exports, {
5056
+ disposeEmbedder: () => disposeEmbedder,
5057
+ embed: () => embed,
5058
+ embedDirect: () => embedDirect,
5059
+ getEmbedder: () => getEmbedder
5060
+ });
5061
+ async function getEmbedder() {
5062
+ const ok = await connectEmbedDaemon();
5063
+ if (!ok) {
5064
+ throw new Error(
5065
+ "Could not connect to embedding daemon. Ensure the model is installed (run /exe-setup)."
5066
+ );
5067
+ }
5068
+ }
5069
+ async function embed(text) {
5070
+ const priority = process.env.EXE_EMBED_PRIORITY === "low" ? "low" : "high";
5071
+ const vector = await embedViaClient(text, priority);
5072
+ if (!vector) {
5073
+ throw new Error(
5074
+ "Embedding failed: daemon unavailable. Run /exe-setup to verify model installation."
5075
+ );
5076
+ }
5077
+ if (vector.length !== EMBEDDING_DIM) {
5078
+ throw new Error(
5079
+ `Embedding dimension mismatch: expected ${EMBEDDING_DIM}, got ${vector.length}. Ensure the correct Jina v5-small Q4_K_M GGUF model is installed.`
5080
+ );
5081
+ }
5082
+ return vector;
5083
+ }
5084
+ async function disposeEmbedder() {
5085
+ disconnectClient();
5086
+ }
5087
+ async function embedDirect(text) {
5088
+ const llamaCpp = await import("node-llama-cpp");
5089
+ const { MODELS_DIR: MODELS_DIR2 } = await Promise.resolve().then(() => (init_config(), config_exports));
5090
+ const { existsSync: existsSync18 } = await import("fs");
5091
+ const path23 = await import("path");
5092
+ const modelPath = path23.join(MODELS_DIR2, "jina-embeddings-v5-small-q4_k_m.gguf");
5093
+ if (!existsSync18(modelPath)) {
5094
+ throw new Error(`Embedding model not found at ${modelPath}. Run '/exe-setup' to download it.`);
5095
+ }
5096
+ const llama = await llamaCpp.getLlama();
5097
+ const model = await llama.loadModel({ modelPath });
5098
+ const context = await model.createEmbeddingContext();
5099
+ try {
5100
+ const embedding = await context.getEmbeddingFor(text);
5101
+ const vector = Array.from(embedding.vector);
5102
+ if (vector.length !== EMBEDDING_DIM) {
5103
+ throw new Error(
5104
+ `Embedding dimension mismatch: expected ${EMBEDDING_DIM}, got ${vector.length}.`
5105
+ );
5106
+ }
5107
+ return vector;
5108
+ } finally {
5109
+ await context.dispose();
5110
+ await model.dispose();
5111
+ }
5112
+ }
5113
+ var init_embedder = __esm({
5114
+ "src/lib/embedder.ts"() {
5115
+ "use strict";
5116
+ init_memory();
5117
+ init_exe_daemon_client();
5118
+ }
5119
+ });
5120
+
5004
5121
  // src/lib/behaviors.ts
5005
5122
  var behaviors_exports = {};
5006
5123
  __export(behaviors_exports, {
@@ -5014,17 +5131,24 @@ async function storeBehavior(opts) {
5014
5131
  const client = getClient();
5015
5132
  const id = crypto5.randomUUID();
5016
5133
  const now = (/* @__PURE__ */ new Date()).toISOString();
5134
+ let vector = null;
5135
+ try {
5136
+ const { embed: embed2 } = await Promise.resolve().then(() => (init_embedder(), embedder_exports));
5137
+ const vec = await embed2(opts.content);
5138
+ vector = new Float32Array(vec);
5139
+ } catch {
5140
+ }
5017
5141
  await client.execute({
5018
- sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at)
5019
- VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?)`,
5020
- args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now]
5142
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector)
5143
+ VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?)`,
5144
+ args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now, vector ? vector.buffer : null]
5021
5145
  });
5022
5146
  return id;
5023
5147
  }
5024
5148
  async function listBehaviors(agentId, projectName, limit = 30) {
5025
5149
  const client = getClient();
5026
5150
  const result = await client.execute({
5027
- sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at
5151
+ sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector
5028
5152
  FROM behaviors
5029
5153
  WHERE agent_id = ? AND active = 1
5030
5154
  AND (project_name IS NULL OR project_name = ?)
@@ -5045,13 +5169,14 @@ async function listBehaviors(agentId, projectName, limit = 30) {
5045
5169
  content: String(r.content),
5046
5170
  active: Number(r.active),
5047
5171
  created_at: String(r.created_at),
5048
- updated_at: String(r.updated_at)
5172
+ updated_at: String(r.updated_at),
5173
+ vector: r.vector ? Array.from(new Float32Array(r.vector)) : null
5049
5174
  }));
5050
5175
  }
5051
5176
  async function listBehaviorsByDomain(agentId, domain) {
5052
5177
  const client = getClient();
5053
5178
  const result = await client.execute({
5054
- sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at
5179
+ sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector
5055
5180
  FROM behaviors
5056
5181
  WHERE agent_id = ? AND domain = ? AND active = 1`,
5057
5182
  args: [agentId, domain]
@@ -5065,7 +5190,8 @@ async function listBehaviorsByDomain(agentId, domain) {
5065
5190
  content: String(r.content),
5066
5191
  active: Number(r.active),
5067
5192
  created_at: String(r.created_at),
5068
- updated_at: String(r.updated_at)
5193
+ updated_at: String(r.updated_at),
5194
+ vector: r.vector ? Array.from(new Float32Array(r.vector)) : null
5069
5195
  }));
5070
5196
  }
5071
5197
  async function deactivateBehavior(id) {
@@ -6175,7 +6301,7 @@ function isSessionBusy(sessionName) {
6175
6301
  function isExeSession(sessionName) {
6176
6302
  const matchesBaseWithInstance = (baseName) => sessionName === baseName || sessionName.startsWith(baseName) && /^\d+$/.test(sessionName.slice(baseName.length));
6177
6303
  const coordinatorName = getCoordinatorName();
6178
- return matchesBaseWithInstance(coordinatorName) || matchesBaseWithInstance("exe");
6304
+ return matchesBaseWithInstance(coordinatorName);
6179
6305
  }
6180
6306
  function sendIntercom(targetSession) {
6181
6307
  const transport = getTransport();
@@ -6679,15 +6805,6 @@ var init_tmux_routing = __esm({
6679
6805
  }
6680
6806
  });
6681
6807
 
6682
- // src/types/memory.ts
6683
- var EMBEDDING_DIM;
6684
- var init_memory = __esm({
6685
- "src/types/memory.ts"() {
6686
- "use strict";
6687
- EMBEDDING_DIM = 1024;
6688
- }
6689
- });
6690
-
6691
6808
  // src/lib/keychain.ts
6692
6809
  import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
6693
6810
  import { existsSync as existsSync15 } from "fs";
@@ -7175,6 +7292,68 @@ var init_platform_procedures = __esm({
7175
7292
  domain: "architecture",
7176
7293
  priority: "p0",
7177
7294
  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."
7295
+ },
7296
+ // --- MCP is the ONLY data interface ---
7297
+ {
7298
+ title: "MCP disconnect \u2014 ask the user, never work around it",
7299
+ domain: "workflow",
7300
+ priority: "p0",
7301
+ 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."
7302
+ },
7303
+ // --- MCP Tool Catalog (Layer 0 — every agent knows what tools exist) ---
7304
+ {
7305
+ title: "MCP tools \u2014 memory and search",
7306
+ domain: "tool-use",
7307
+ priority: "p1",
7308
+ 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)."
7309
+ },
7310
+ {
7311
+ title: "MCP tools \u2014 task orchestration",
7312
+ domain: "tool-use",
7313
+ priority: "p1",
7314
+ 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."
7315
+ },
7316
+ {
7317
+ title: "MCP tools \u2014 knowledge graph (GraphRAG)",
7318
+ domain: "tool-use",
7319
+ priority: "p1",
7320
+ 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."
7321
+ },
7322
+ {
7323
+ title: "MCP tools \u2014 identity, behavior, and decisions",
7324
+ domain: "tool-use",
7325
+ priority: "p1",
7326
+ 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."
7327
+ },
7328
+ {
7329
+ title: "MCP tools \u2014 communication and messaging",
7330
+ domain: "tool-use",
7331
+ priority: "p1",
7332
+ 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.)."
7333
+ },
7334
+ {
7335
+ title: "MCP tools \u2014 wiki, documents, and content",
7336
+ domain: "tool-use",
7337
+ priority: "p1",
7338
+ 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."
7339
+ },
7340
+ {
7341
+ title: "MCP tools \u2014 system, operations, and admin",
7342
+ domain: "tool-use",
7343
+ priority: "p1",
7344
+ 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."
7345
+ },
7346
+ {
7347
+ title: "MCP tools \u2014 config, licensing, and team",
7348
+ domain: "tool-use",
7349
+ priority: "p1",
7350
+ 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."
7351
+ },
7352
+ {
7353
+ title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
7354
+ domain: "tool-use",
7355
+ priority: "p1",
7356
+ 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."
7178
7357
  }
7179
7358
  ];
7180
7359
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -7324,6 +7503,11 @@ async function initStore(options) {
7324
7503
  encryptionKey: hexKey
7325
7504
  });
7326
7505
  await retryOnBusy2(() => ensureSchema(), "ensureSchema");
7506
+ try {
7507
+ const { initDaemonClient: initDaemonClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
7508
+ await initDaemonClient2();
7509
+ } catch {
7510
+ }
7327
7511
  if (!options?.lightweight) {
7328
7512
  try {
7329
7513
  const { initShardManager: initShardManager2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
@@ -8440,74 +8624,6 @@ var init_crm_bridge = __esm({
8440
8624
  }
8441
8625
  });
8442
8626
 
8443
- // src/lib/embedder.ts
8444
- var embedder_exports = {};
8445
- __export(embedder_exports, {
8446
- disposeEmbedder: () => disposeEmbedder,
8447
- embed: () => embed,
8448
- embedDirect: () => embedDirect,
8449
- getEmbedder: () => getEmbedder
8450
- });
8451
- async function getEmbedder() {
8452
- const ok = await connectEmbedDaemon();
8453
- if (!ok) {
8454
- throw new Error(
8455
- "Could not connect to embedding daemon. Ensure the model is installed (run /exe-setup)."
8456
- );
8457
- }
8458
- }
8459
- async function embed(text) {
8460
- const priority = process.env.EXE_EMBED_PRIORITY === "low" ? "low" : "high";
8461
- const vector = await embedViaClient(text, priority);
8462
- if (!vector) {
8463
- throw new Error(
8464
- "Embedding failed: daemon unavailable. Run /exe-setup to verify model installation."
8465
- );
8466
- }
8467
- if (vector.length !== EMBEDDING_DIM) {
8468
- throw new Error(
8469
- `Embedding dimension mismatch: expected ${EMBEDDING_DIM}, got ${vector.length}. Ensure the correct Jina v5-small Q4_K_M GGUF model is installed.`
8470
- );
8471
- }
8472
- return vector;
8473
- }
8474
- async function disposeEmbedder() {
8475
- disconnectClient();
8476
- }
8477
- async function embedDirect(text) {
8478
- const llamaCpp = await import("node-llama-cpp");
8479
- const { MODELS_DIR: MODELS_DIR2 } = await Promise.resolve().then(() => (init_config(), config_exports));
8480
- const { existsSync: existsSync18 } = await import("fs");
8481
- const path23 = await import("path");
8482
- const modelPath = path23.join(MODELS_DIR2, "jina-embeddings-v5-small-q4_k_m.gguf");
8483
- if (!existsSync18(modelPath)) {
8484
- throw new Error(`Embedding model not found at ${modelPath}. Run '/exe-setup' to download it.`);
8485
- }
8486
- const llama = await llamaCpp.getLlama();
8487
- const model = await llama.loadModel({ modelPath });
8488
- const context = await model.createEmbeddingContext();
8489
- try {
8490
- const embedding = await context.getEmbeddingFor(text);
8491
- const vector = Array.from(embedding.vector);
8492
- if (vector.length !== EMBEDDING_DIM) {
8493
- throw new Error(
8494
- `Embedding dimension mismatch: expected ${EMBEDDING_DIM}, got ${vector.length}.`
8495
- );
8496
- }
8497
- return vector;
8498
- } finally {
8499
- await context.dispose();
8500
- await model.dispose();
8501
- }
8502
- }
8503
- var init_embedder = __esm({
8504
- "src/lib/embedder.ts"() {
8505
- "use strict";
8506
- init_memory();
8507
- init_exe_daemon_client();
8508
- }
8509
- });
8510
-
8511
8627
  // src/lib/wiki-client.ts
8512
8628
  var wiki_client_exports = {};
8513
8629
  __export(wiki_client_exports, {
@@ -132,7 +132,7 @@ var DEFAULT_RUNTIME = "claude";
132
132
  // src/lib/agent-config.ts
133
133
  var AGENT_CONFIG_PATH = path2.join(EXE_AI_DIR, "agent-config.json");
134
134
  var KNOWN_RUNTIMES = {
135
- claude: ["claude-opus-4", "claude-sonnet-4", "claude-haiku-4.5"],
135
+ claude: ["claude-opus-4.6", "claude-opus-4", "claude-sonnet-4.6", "claude-sonnet-4", "claude-haiku-4.5"],
136
136
  codex: ["gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark", "o3", "o4-mini"],
137
137
  opencode: ["anthropic/claude-sonnet-4-6", "openai/gpt-5.4", "google/gemini-2.5-pro", "deepseek/deepseek-r3", "minimax/minimax-m2.5"]
138
138
  };
@@ -142,7 +142,7 @@ var RUNTIME_LABELS = {
142
142
  opencode: "OpenCode (open source)"
143
143
  };
144
144
  var DEFAULT_MODELS = {
145
- claude: "claude-opus-4",
145
+ claude: "claude-opus-4.6",
146
146
  codex: RUNTIME_TABLE.codex?.defaultModel ?? "gpt-5.4",
147
147
  opencode: RUNTIME_TABLE.opencode?.defaultModel ?? "anthropic/claude-sonnet-4-6"
148
148
  };
@@ -63,9 +63,9 @@ var MAX_RETRIES, BASE_DELAY_MS, MAX_JITTER_MS;
63
63
  var init_db_retry = __esm({
64
64
  "src/lib/db-retry.ts"() {
65
65
  "use strict";
66
- MAX_RETRIES = 3;
67
- BASE_DELAY_MS = 200;
68
- MAX_JITTER_MS = 300;
66
+ MAX_RETRIES = 5;
67
+ BASE_DELAY_MS = 250;
68
+ MAX_JITTER_MS = 400;
69
69
  }
70
70
  });
71
71
 
@@ -863,6 +863,15 @@ var init_database_adapter = __esm({
863
863
  }
864
864
  });
865
865
 
866
+ // src/types/memory.ts
867
+ var EMBEDDING_DIM;
868
+ var init_memory = __esm({
869
+ "src/types/memory.ts"() {
870
+ "use strict";
871
+ EMBEDDING_DIM = 1024;
872
+ }
873
+ });
874
+
866
875
  // src/lib/daemon-auth.ts
867
876
  import crypto from "crypto";
868
877
  import path4 from "path";
@@ -1285,7 +1294,7 @@ function createDaemonDbClient(fallbackClient) {
1285
1294
  });
1286
1295
  if (response.error) {
1287
1296
  const errMsg = String(response.error);
1288
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
1297
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
1289
1298
  process.stderr.write(`[db-daemon] Transport error (${errMsg}), falling back to direct
1290
1299
  `);
1291
1300
  return fallbackClient.execute(stmt);
@@ -1310,7 +1319,7 @@ function createDaemonDbClient(fallbackClient) {
1310
1319
  });
1311
1320
  if (response.error) {
1312
1321
  const errMsg = String(response.error);
1313
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
1322
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
1314
1323
  process.stderr.write(`[db-daemon] Batch transport error (${errMsg}), falling back to direct
1315
1324
  `);
1316
1325
  return fallbackClient.batch(stmts, mode);
@@ -1433,7 +1442,7 @@ async function initDatabase(config) {
1433
1442
  });
1434
1443
  }, 3e4);
1435
1444
  _walCheckpointTimer.unref();
1436
- if (process.env.DATABASE_URL) {
1445
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1437
1446
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1438
1447
  }
1439
1448
  }
@@ -1444,7 +1453,7 @@ function getClient() {
1444
1453
  if (!_adapterClient) {
1445
1454
  throw new Error("Database client not initialized. Call initDatabase() first.");
1446
1455
  }
1447
- if (process.env.DATABASE_URL) {
1456
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1448
1457
  return _adapterClient;
1449
1458
  }
1450
1459
  if (process.env.EXE_IS_DAEMON === "1") {
@@ -1456,9 +1465,11 @@ function getClient() {
1456
1465
  return _resilientClient;
1457
1466
  }
1458
1467
  async function initDaemonClient() {
1459
- if (process.env.DATABASE_URL) return;
1468
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") return;
1460
1469
  if (process.env.EXE_IS_DAEMON === "1") return;
1470
+ if (process.env.VITEST) return;
1461
1471
  if (!_resilientClient) return;
1472
+ if (_daemonClient) return;
1462
1473
  try {
1463
1474
  const { initDaemonDbClient: initDaemonDbClient2 } = await Promise.resolve().then(() => (init_db_daemon_client(), db_daemon_client_exports));
1464
1475
  _daemonClient = await initDaemonDbClient2(_resilientClient);
@@ -1607,6 +1618,13 @@ async function ensureSchema() {
1607
1618
  });
1608
1619
  } catch {
1609
1620
  }
1621
+ try {
1622
+ await client.execute({
1623
+ sql: `ALTER TABLE behaviors ADD COLUMN vector F32_BLOB(${EMBEDDING_DIM})`,
1624
+ args: []
1625
+ });
1626
+ } catch {
1627
+ }
1610
1628
  try {
1611
1629
  await client.execute({
1612
1630
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -2477,6 +2495,7 @@ var init_database = __esm({
2477
2495
  init_db_retry();
2478
2496
  init_employees();
2479
2497
  init_database_adapter();
2498
+ init_memory();
2480
2499
  _client = null;
2481
2500
  _resilientClient = null;
2482
2501
  _walCheckpointTimer = null;