@askexenow/exe-os 0.9.111 → 0.9.113

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 (95) hide show
  1. package/README.md +9 -7
  2. package/dist/bin/agentic-ontology-backfill.js +62 -12
  3. package/dist/bin/agentic-reflection-backfill.js +37 -2
  4. package/dist/bin/agentic-semantic-label.js +37 -2
  5. package/dist/bin/backfill-conversations.js +61 -11
  6. package/dist/bin/backfill-responses.js +62 -12
  7. package/dist/bin/backfill-vectors.js +37 -2
  8. package/dist/bin/bulk-sync-postgres.js +63 -13
  9. package/dist/bin/cleanup-stale-review-tasks.js +83 -16
  10. package/dist/bin/cli.js +312 -80
  11. package/dist/bin/exe-agent-config.js +7 -1
  12. package/dist/bin/exe-agent.js +29 -3
  13. package/dist/bin/exe-assign.js +62 -12
  14. package/dist/bin/exe-boot.js +500 -151
  15. package/dist/bin/exe-call.js +46 -5
  16. package/dist/bin/exe-cloud.js +101 -16
  17. package/dist/bin/exe-dispatch.js +827 -27
  18. package/dist/bin/exe-doctor.js +61 -11
  19. package/dist/bin/exe-export-behaviors.js +67 -14
  20. package/dist/bin/exe-forget.js +62 -12
  21. package/dist/bin/exe-gateway.js +147 -27
  22. package/dist/bin/exe-heartbeat.js +83 -16
  23. package/dist/bin/exe-kill.js +62 -12
  24. package/dist/bin/exe-launch-agent.js +83 -15
  25. package/dist/bin/exe-new-employee.js +176 -8
  26. package/dist/bin/exe-pending-messages.js +83 -16
  27. package/dist/bin/exe-pending-notifications.js +83 -16
  28. package/dist/bin/exe-pending-reviews.js +83 -16
  29. package/dist/bin/exe-rename.js +62 -12
  30. package/dist/bin/exe-review.js +62 -12
  31. package/dist/bin/exe-search.js +62 -12
  32. package/dist/bin/exe-session-cleanup.js +949 -149
  33. package/dist/bin/exe-settings.js +10 -4
  34. package/dist/bin/exe-start-codex.js +537 -248
  35. package/dist/bin/exe-start-opencode.js +547 -168
  36. package/dist/bin/exe-status.js +83 -16
  37. package/dist/bin/exe-support.js +1 -1
  38. package/dist/bin/exe-team.js +62 -12
  39. package/dist/bin/git-sweep.js +827 -27
  40. package/dist/bin/graph-backfill.js +62 -12
  41. package/dist/bin/graph-export.js +62 -12
  42. package/dist/bin/install.js +62 -4
  43. package/dist/bin/intercom-check.js +949 -149
  44. package/dist/bin/pre-publish.js +14 -2
  45. package/dist/bin/scan-tasks.js +827 -27
  46. package/dist/bin/setup.js +99 -14
  47. package/dist/bin/shard-migrate.js +62 -12
  48. package/dist/bin/stack-update.js +1 -1
  49. package/dist/bin/update.js +3 -3
  50. package/dist/gateway/index.js +586 -26
  51. package/dist/hooks/bug-report-worker.js +586 -26
  52. package/dist/hooks/codex-stop-task-finalizer.js +977 -143
  53. package/dist/hooks/commit-complete.js +827 -27
  54. package/dist/hooks/error-recall.js +62 -12
  55. package/dist/hooks/ingest.js +4579 -249
  56. package/dist/hooks/instructions-loaded.js +62 -12
  57. package/dist/hooks/notification.js +62 -12
  58. package/dist/hooks/post-compact.js +83 -16
  59. package/dist/hooks/post-tool-combined.js +83 -16
  60. package/dist/hooks/pre-compact.js +907 -107
  61. package/dist/hooks/pre-tool-use.js +98 -16
  62. package/dist/hooks/prompt-submit.js +596 -30
  63. package/dist/hooks/session-end.js +909 -112
  64. package/dist/hooks/session-start.js +112 -17
  65. package/dist/hooks/stop.js +82 -15
  66. package/dist/hooks/subagent-stop.js +83 -16
  67. package/dist/hooks/summary-worker.js +81 -8
  68. package/dist/index.js +595 -29
  69. package/dist/lib/agent-config.js +16 -1
  70. package/dist/lib/cloud-sync.js +45 -1
  71. package/dist/lib/consolidation.js +16 -1
  72. package/dist/lib/database.js +23 -0
  73. package/dist/lib/db.js +23 -0
  74. package/dist/lib/device-registry.js +23 -0
  75. package/dist/lib/employee-templates.js +30 -4
  76. package/dist/lib/employees.js +16 -1
  77. package/dist/lib/exe-daemon.js +482 -52
  78. package/dist/lib/hybrid-search.js +62 -12
  79. package/dist/lib/license.js +3 -3
  80. package/dist/lib/messaging.js +21 -4
  81. package/dist/lib/schedules.js +37 -2
  82. package/dist/lib/skill-learning.js +910 -41
  83. package/dist/lib/status-brief.js +14 -1
  84. package/dist/lib/store.js +62 -12
  85. package/dist/lib/tasks.js +843 -93
  86. package/dist/lib/tmux-routing.js +766 -16
  87. package/dist/mcp/server.js +238 -41
  88. package/dist/mcp/tools/create-task.js +525 -15
  89. package/dist/mcp/tools/deactivate-behavior.js +33 -24
  90. package/dist/mcp/tools/list-tasks.js +21 -4
  91. package/dist/mcp/tools/send-message.js +21 -4
  92. package/dist/mcp/tools/update-task.js +840 -93
  93. package/dist/runtime/index.js +913 -107
  94. package/dist/tui/App.js +227 -58
  95. package/package.json +1 -1
@@ -983,6 +983,7 @@ __export(agent_config_exports, {
983
983
  getAgentRuntime: () => getAgentRuntime,
984
984
  loadAgentConfig: () => loadAgentConfig,
985
985
  saveAgentConfig: () => saveAgentConfig,
986
+ setAgentMcps: () => setAgentMcps,
986
987
  setAgentRuntime: () => setAgentRuntime
987
988
  });
988
989
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync5 } from "fs";
@@ -1009,7 +1010,7 @@ function getAgentRuntime(agentId) {
1009
1010
  if (orgDefault) return orgDefault;
1010
1011
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
1011
1012
  }
1012
- function setAgentRuntime(agentId, runtime, model, reasoning_effort) {
1013
+ function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
1013
1014
  const knownModels = KNOWN_RUNTIMES[runtime];
1014
1015
  if (!knownModels) {
1015
1016
  return {
@@ -1024,12 +1025,26 @@ function setAgentRuntime(agentId, runtime, model, reasoning_effort) {
1024
1025
  };
1025
1026
  }
1026
1027
  const config2 = loadAgentConfig();
1028
+ const existing = config2[agentId];
1027
1029
  const entry = { runtime, model };
1028
1030
  if (reasoning_effort) entry.reasoning_effort = reasoning_effort;
1031
+ if (mcps !== void 0) {
1032
+ entry.mcps = mcps.includes("exe-os") ? mcps : ["exe-os", ...mcps];
1033
+ } else if (existing?.mcps) {
1034
+ entry.mcps = existing.mcps;
1035
+ }
1029
1036
  config2[agentId] = entry;
1030
1037
  saveAgentConfig(config2);
1031
1038
  return { ok: true };
1032
1039
  }
1040
+ function setAgentMcps(agentId, mcps) {
1041
+ const config2 = loadAgentConfig();
1042
+ const existing = config2[agentId] ?? getAgentRuntime(agentId);
1043
+ existing.mcps = mcps.includes("exe-os") ? mcps : ["exe-os", ...mcps];
1044
+ config2[agentId] = existing;
1045
+ saveAgentConfig(config2);
1046
+ return { ok: true };
1047
+ }
1033
1048
  function clearAgentRuntime(agentId) {
1034
1049
  const config2 = loadAgentConfig();
1035
1050
  delete config2[agentId];
@@ -2504,6 +2519,13 @@ async function ensureSchema() {
2504
2519
  } catch (e) {
2505
2520
  logCatchDebug("migration", e);
2506
2521
  }
2522
+ for (const col of ["created_by_agent TEXT", "created_by_device TEXT", "source_session_id TEXT"]) {
2523
+ try {
2524
+ await client.execute({ sql: `ALTER TABLE behaviors ADD COLUMN ${col}`, args: [] });
2525
+ } catch (e) {
2526
+ logCatchDebug("migration", e);
2527
+ }
2528
+ }
2507
2529
  try {
2508
2530
  await client.execute({
2509
2531
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3720,6 +3742,22 @@ async function ensureSchema() {
3720
3742
  } catch (e) {
3721
3743
  logCatchDebug("migration", e);
3722
3744
  }
3745
+ try {
3746
+ await client.execute({
3747
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3748
+ args: []
3749
+ });
3750
+ } catch (e) {
3751
+ logCatchDebug("migration", e);
3752
+ }
3753
+ try {
3754
+ await client.execute({
3755
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3756
+ args: []
3757
+ });
3758
+ } catch (e) {
3759
+ logCatchDebug("migration", e);
3760
+ }
3723
3761
  }
3724
3762
  async function disposeDatabase() {
3725
3763
  if (_walCheckpointTimer) {
@@ -5031,11 +5069,17 @@ var init_platform_procedures = __esm({
5031
5069
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator 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."
5032
5070
  },
5033
5071
  {
5034
- title: "Customer orchestration maturity \u2014 recommend, never trap",
5072
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
5035
5073
  domain: "workflow",
5036
5074
  priority: "p1",
5037
5075
  content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
5038
5076
  },
5077
+ {
5078
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
5079
+ domain: "identity",
5080
+ priority: "p0",
5081
+ content: "These procedures reference 'COO' as a shorthand for the coordinator role. This is an INTERNAL routing slot used by exe-os code (chain-of-command checks, dispatch logic, session detection). It is NOT your display title. Your actual title comes from your identity file's `title:` field \u2014 that is what you use externally: introductions, sign-offs, team comms, and any user-facing text. If your identity says `title: AI Chief of Staff`, you are the AI Chief of Staff. The routing slot stays `role: coo` for code compatibility \u2014 never rename it, but also never introduce yourself as 'COO' unless your identity file explicitly says so. The founder chose your title; respect it."
5082
+ },
5039
5083
  {
5040
5084
  title: "Single dispatch path \u2014 create_task only",
5041
5085
  domain: "workflow",
@@ -5069,6 +5113,12 @@ var init_platform_procedures = __esm({
5069
5113
  priority: "p0",
5070
5114
  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."
5071
5115
  },
5116
+ {
5117
+ title: "Destructive operations \u2014 mandatory reviewer gate",
5118
+ domain: "security",
5119
+ priority: "p0",
5120
+ content: "Before ANY destructive operation (delete, remove, overwrite, drop, reset, force-push, truncate), you MUST: (1) Have your full task spec accessible \u2014 if you cannot read it, STOP and report to your reviewer. Never improvise destructive actions. (2) Confirm with your reviewer (assigned_by or COO) before executing. (3) If the task spec explicitly authorizes the operation, proceed \u2014 but log it. Violation = immediate task failure. This applies to ALL agents regardless of role."
5121
+ },
5072
5122
  {
5073
5123
  title: "Customer patch triage \u2014 upstream bug vs customization",
5074
5124
  domain: "support",
@@ -5220,7 +5270,7 @@ var init_platform_procedures = __esm({
5220
5270
  title: "MCP tool dispatch \u2014 all tools use action parameter",
5221
5271
  domain: "tool-use",
5222
5272
  priority: "p0",
5223
- content: 'exe-os MCP tools come in two surfaces depending on EXE_MCP_TOOL_SURFACE config. Consolidated (19 tools): action-based dispatch \u2014 memory(action="recall"), task(action="create"), etc. Legacy (108 tools): one tool per operation \u2014 recall_my_memory, create_task, etc. Both surfaces have identical functionality. Use whichever tool names are available in your session. If you see domain tools (memory, task, config, etc.), use the action parameter. If you see specific tools (recall_my_memory, create_task, etc.), call them directly.'
5273
+ content: 'exe-os MCP tools use consolidated action-based dispatch by default (19 tools). Call domain tools with an action parameter: memory(action="recall"), task(action="create"), config(action="list_employees"), etc. Legacy mode (108 separate tools like recall_my_memory, create_task) is still available via EXE_MCP_TOOL_SURFACE=legacy but will be removed in a future version. If you see specific tool names, call them directly \u2014 both surfaces are identical. Consolidated is the default and recommended surface.'
5224
5274
  },
5225
5275
  {
5226
5276
  title: "MCP tools \u2014 memory, decision, and search",
@@ -5354,10 +5404,24 @@ function stableId(memoryId, type, content) {
5354
5404
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
5355
5405
  }
5356
5406
  function cleanText(text3) {
5357
- return text3.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5407
+ let cleaned = text3.replace(
5408
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
5409
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
5410
+ );
5411
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5412
+ return cleaned;
5358
5413
  }
5359
- function splitSentences(text3) {
5360
- return cleanText(text3).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
5414
+ function splitSegments(text3) {
5415
+ const cleaned = cleanText(text3);
5416
+ const segments = cleaned.split(/(?<=[.!?:;])\s+|\n{2,}|(?<=\))\s+(?=[A-Z])|\s*[|│]\s*/).map((s) => s.trim()).filter((s) => s.length >= MIN_SEGMENT_CHARS && s.length <= MAX_SEGMENT_CHARS);
5417
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
5418
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
5419
+ if (lines.length > 0) return lines;
5420
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
5421
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
5422
+ }
5423
+ }
5424
+ return segments;
5361
5425
  }
5362
5426
  function inferCardType(sentence, toolName) {
5363
5427
  const lower = sentence.toLowerCase();
@@ -5389,12 +5453,12 @@ function predicateFor(type) {
5389
5453
  }
5390
5454
  }
5391
5455
  function extractMemoryCards(row) {
5392
- const sentences = splitSentences(row.raw_text);
5456
+ const segments = splitSegments(row.raw_text);
5393
5457
  const cards = [];
5394
- for (const sentence of sentences) {
5458
+ for (const sentence of segments) {
5395
5459
  const type = inferCardType(sentence, row.tool_name);
5396
5460
  const subject = extractSubject(sentence, row.agent_id);
5397
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
5461
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
5398
5462
  cards.push({
5399
5463
  id: stableId(row.id, type, content),
5400
5464
  memory_id: row.id,
@@ -5490,13 +5554,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
5490
5554
  last_accessed: String(row.timestamp)
5491
5555
  }));
5492
5556
  }
5493
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
5557
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
5494
5558
  var init_memory_cards = __esm({
5495
5559
  "src/lib/memory-cards.ts"() {
5496
5560
  "use strict";
5497
5561
  init_database();
5498
- MAX_CARDS_PER_MEMORY = 6;
5499
- MAX_SENTENCE_CHARS = 360;
5562
+ MAX_CARDS_PER_MEMORY = 8;
5563
+ MAX_SEGMENT_CHARS = 500;
5564
+ MIN_SEGMENT_CHARS = 20;
5500
5565
  }
5501
5566
  });
5502
5567
 
@@ -7740,7 +7805,7 @@ async function hybridSearch(queryText, agentId, options) {
7740
7805
  try {
7741
7806
  const client = getClient();
7742
7807
  void client.execute({
7743
- sql: `UPDATE memories SET last_accessed = ?, retrieval_count = COALESCE(retrieval_count, 0) + 1 WHERE id IN (${placeholders})`,
7808
+ sql: `UPDATE memories SET last_accessed = ?, retrieval_count = COALESCE(retrieval_count, 0) + 1, strength = MIN(1.0, COALESCE(strength, 1.0) + 0.1) WHERE id IN (${placeholders})`,
7744
7809
  args: [now, ...ids]
7745
7810
  }).catch(() => {
7746
7811
  });
@@ -8829,7 +8894,7 @@ async function assertVpsLicense(opts) {
8829
8894
  }
8830
8895
  if (!transientFailure) {
8831
8896
  throw new Error(
8832
- "License validation failed: unknown backend state. Restore network connectivity to https://askexe.com/cloud and retry."
8897
+ "License validation failed: unknown backend state. Restore network connectivity to https://cloud.askexe.com and retry."
8833
8898
  );
8834
8899
  }
8835
8900
  const fresh = await getCachedLicense();
@@ -8866,7 +8931,7 @@ async function assertVpsLicense(opts) {
8866
8931
  } catch {
8867
8932
  }
8868
8933
  throw new Error(
8869
- `License validation unreachable for more than ${graceDays} days. Restore network connectivity to https://askexe.com/cloud and retry. This VPS image refuses to boot after the offline grace window.`
8934
+ `License validation unreachable for more than ${graceDays} days. Restore network connectivity to https://cloud.askexe.com and retry. This VPS image refuses to boot after the offline grace window.`
8870
8935
  );
8871
8936
  }
8872
8937
  function startLicenseRevalidation(intervalMs = 36e5) {
@@ -8898,7 +8963,7 @@ var init_license = __esm({
8898
8963
  LICENSE_PATH = path13.join(EXE_AI_DIR, "license.key");
8899
8964
  CACHE_PATH = path13.join(EXE_AI_DIR, "license-cache.json");
8900
8965
  DEVICE_ID_PATH = path13.join(EXE_AI_DIR, "device-id");
8901
- API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
8966
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://cloud.askexe.com";
8902
8967
  RETRY_DELAY_MS = 500;
8903
8968
  LICENSE_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
8904
8969
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeHztAMOpR/ZMh+rWuOASjEZ54CGY
@@ -10847,11 +10912,12 @@ function getDispatchedBy(sessionKey) {
10847
10912
  }
10848
10913
  }
10849
10914
  function resolveExeSession() {
10915
+ if (process.env.EXE_SESSION_NAME) {
10916
+ const fromEnv = extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
10917
+ if (fromEnv) return fromEnv;
10918
+ }
10850
10919
  const mySession = getMySession();
10851
10920
  if (!mySession) {
10852
- if (process.env.EXE_SESSION_NAME) {
10853
- return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
10854
- }
10855
10921
  return null;
10856
10922
  }
10857
10923
  const fromSessionName = extractRootExe(mySession);
@@ -10866,6 +10932,10 @@ function resolveExeSession() {
10866
10932
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
10867
10933
  `
10868
10934
  );
10935
+ try {
10936
+ registerParentExe(key, fromSessionName);
10937
+ } catch {
10938
+ }
10869
10939
  candidate = fromSessionName;
10870
10940
  } else {
10871
10941
  candidate = fromCache;
@@ -11793,6 +11863,19 @@ async function resolveTask(client, identifier, scopeSession) {
11793
11863
  args: [identifier, ...scope.args]
11794
11864
  });
11795
11865
  if (result3.rows.length === 1) return result3.rows[0];
11866
+ if (/^[a-f0-9]{7,12}$/i.test(identifier)) {
11867
+ result3 = await client.execute({
11868
+ sql: `SELECT * FROM tasks WHERE id LIKE ?`,
11869
+ args: [`${identifier}%`]
11870
+ });
11871
+ if (result3.rows.length === 1) return result3.rows[0];
11872
+ if (result3.rows.length > 1) {
11873
+ const matches = result3.rows.map((r) => `${String(r.id)} "${String(r.title)}" (${String(r.status)})`).join(", ");
11874
+ throw new Error(
11875
+ `Multiple tasks match short-ID "${identifier}": ${matches}. Use a longer prefix to disambiguate.`
11876
+ );
11877
+ }
11878
+ }
11796
11879
  result3 = await client.execute({
11797
11880
  sql: `SELECT * FROM tasks WHERE task_file LIKE ?${scope.sql}`,
11798
11881
  args: [`%${identifier}%`, ...scope.args]
@@ -12339,12 +12422,13 @@ async function cascadeUnblock(taskId, baseDir, now) {
12339
12422
  WHERE blocked_by = ? AND status = 'blocked'`,
12340
12423
  args: [now, taskId]
12341
12424
  });
12342
- if (baseDir && unblocked.rowsAffected > 0) {
12343
- const ubScope = sessionScopeFilter();
12344
- const unblockedRows = await client.execute({
12345
- sql: `SELECT task_file FROM tasks WHERE blocked_by IS NULL AND updated_at = ?${ubScope.sql}`,
12346
- args: [now, ...ubScope.args]
12347
- });
12425
+ if (unblocked.rowsAffected === 0) return;
12426
+ const ubScope = sessionScopeFilter();
12427
+ const unblockedRows = await client.execute({
12428
+ sql: `SELECT id, title, assigned_to, priority, task_file FROM tasks WHERE blocked_by IS NULL AND updated_at = ?${ubScope.sql}`,
12429
+ args: [now, ...ubScope.args]
12430
+ });
12431
+ if (baseDir) {
12348
12432
  for (const ur of unblockedRows.rows) {
12349
12433
  try {
12350
12434
  const ubFile = path24.join(baseDir, String(ur.task_file));
@@ -12356,6 +12440,19 @@ async function cascadeUnblock(taskId, baseDir, now) {
12356
12440
  }
12357
12441
  }
12358
12442
  }
12443
+ if (unblockedRows.rows.length > 0 && !process.env.VITEST) {
12444
+ try {
12445
+ const { queueIntercom: queueIntercom2 } = await Promise.resolve().then(() => (init_intercom_queue(), intercom_queue_exports));
12446
+ const dispatched = /* @__PURE__ */ new Set();
12447
+ for (const ur of unblockedRows.rows) {
12448
+ const assignee = String(ur.assigned_to);
12449
+ if (dispatched.has(assignee)) continue;
12450
+ dispatched.add(assignee);
12451
+ queueIntercom2(`${assignee}`, `unblocked: "${String(ur.title)}" is now ready`);
12452
+ }
12453
+ } catch {
12454
+ }
12455
+ }
12359
12456
  }
12360
12457
  async function findNextTask(assignedTo) {
12361
12458
  const client = getClient();
@@ -12497,6 +12594,15 @@ var init_tasks_notify = __esm({
12497
12594
  // src/lib/behaviors.ts
12498
12595
  import crypto8 from "crypto";
12499
12596
  async function storeBehavior(opts) {
12597
+ try {
12598
+ const { loadEmployeesSync: loadEmployeesSync2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
12599
+ const roster = loadEmployeesSync2();
12600
+ if (roster.length > 0 && !roster.some((e) => e.name === opts.agentId)) {
12601
+ throw new Error(`Agent "${opts.agentId}" not found in roster. Cannot store behavior for unregistered agent.`);
12602
+ }
12603
+ } catch (e) {
12604
+ if (e instanceof Error && e.message.includes("not found in roster")) throw e;
12605
+ }
12500
12606
  const client = getClient();
12501
12607
  const id = crypto8.randomUUID();
12502
12608
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -12507,10 +12613,18 @@ async function storeBehavior(opts) {
12507
12613
  vector = new Float32Array(vec);
12508
12614
  } catch {
12509
12615
  }
12616
+ let createdByDevice = null;
12617
+ try {
12618
+ const { loadDeviceId: loadDeviceId2 } = await Promise.resolve().then(() => (init_license(), license_exports));
12619
+ createdByDevice = loadDeviceId2() ?? null;
12620
+ } catch {
12621
+ }
12622
+ const createdByAgent = process.env.AGENT_ID ?? null;
12623
+ const sourceSessionId = process.env.CLAUDE_SESSION_ID ?? process.env.SESSION_ID ?? null;
12510
12624
  await client.execute({
12511
- sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector)
12512
- VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?)`,
12513
- args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now, vector ? vector.buffer : null]
12625
+ sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector, created_by_agent, created_by_device, source_session_id)
12626
+ VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?)`,
12627
+ args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now, vector ? vector.buffer : null, createdByAgent, createdByDevice, sourceSessionId]
12514
12628
  });
12515
12629
  return id;
12516
12630
  }
@@ -12532,7 +12646,10 @@ async function listBehaviorsByDomain(agentId, domain) {
12532
12646
  active: Number(r.active),
12533
12647
  created_at: String(r.created_at),
12534
12648
  updated_at: String(r.updated_at),
12535
- vector: r.vector ? Array.from(new Float32Array(r.vector)) : null
12649
+ vector: r.vector ? Array.from(new Float32Array(r.vector)) : null,
12650
+ created_by_agent: r.created_by_agent ? String(r.created_by_agent) : null,
12651
+ created_by_device: r.created_by_device ? String(r.created_by_device) : null,
12652
+ source_session_id: r.source_session_id ? String(r.source_session_id) : null
12536
12653
  }));
12537
12654
  }
12538
12655
  async function deactivateBehavior(id) {
@@ -12971,6 +13088,12 @@ async function updateTask(input) {
12971
13088
  }
12972
13089
  }
12973
13090
  }
13091
+ if (input.status === "cancelled") {
13092
+ try {
13093
+ await cascadeUnblock(taskId, input.baseDir, now);
13094
+ } catch {
13095
+ }
13096
+ }
12974
13097
  if ((input.status === "done" || input.status === "closed") && !isCoordinatorName(String(row.assigned_to)) && !process.env.VITEST) {
12975
13098
  Promise.resolve().then(() => (init_skill_learning(), skill_learning_exports)).then(
12976
13099
  ({ captureAndLearn: captureAndLearn2 }) => captureAndLearn2({
@@ -17281,8 +17404,11 @@ function rowToBehavior(r) {
17281
17404
  active: Number(r.active),
17282
17405
  created_at: String(r.created_at),
17283
17406
  updated_at: String(r.updated_at),
17284
- vector: null
17407
+ vector: null,
17285
17408
  // Not needed for listing
17409
+ created_by_agent: r.created_by_agent ? String(r.created_by_agent) : null,
17410
+ created_by_device: r.created_by_device ? String(r.created_by_device) : null,
17411
+ source_session_id: r.source_session_id ? String(r.source_session_id) : null
17286
17412
  };
17287
17413
  }
17288
17414
  function registerListBehaviors(server2) {
@@ -19784,15 +19910,16 @@ function registerSetAgentConfig(server2) {
19784
19910
  "set_agent_config",
19785
19911
  {
19786
19912
  title: "Set Agent Config",
19787
- description: "Set or view per-agent runtime + model configuration. Controls which runtime (claude, codex, opencode) and model each agent uses when dispatched. COO-only. Omit runtime/model to view current config for an agent or all agents.",
19913
+ description: "Set or view per-agent runtime, model, and MCP configuration. Controls which runtime (claude, codex, opencode), model, and MCP servers each agent uses when dispatched. COO-only. Omit runtime/model to view current config for an agent or all agents. Pass mcps to restrict which MCP servers an agent loads (exe-os always included).",
19788
19914
  inputSchema: {
19789
19915
  agent_id: z48.string().optional().describe("Agent name, or 'default' for org-wide default. Omit to view all agents."),
19790
19916
  runtime: z48.string().optional().describe(`Runtime: ${Object.keys(KNOWN_RUNTIMES).join(", ")}`),
19791
19917
  model: z48.string().optional().describe("Model name (e.g. claude-opus-4, gpt-5.4, anthropic/claude-sonnet-4-6)"),
19792
- reasoning_effort: z48.string().optional().describe("Codex reasoning effort: low, medium, high, xhigh. Per-agent override for thinking/reasoning depth.")
19918
+ reasoning_effort: z48.string().optional().describe("Codex reasoning effort: low, medium, high, xhigh. Per-agent override for thinking/reasoning depth."),
19919
+ mcps: z48.array(z48.string()).optional().describe("MCP server allowlist. Only these servers load for this agent. exe-os always included. Omit to load all MCPs.")
19793
19920
  }
19794
19921
  },
19795
- async ({ agent_id, runtime, model, reasoning_effort }) => {
19922
+ async ({ agent_id, runtime, model, reasoning_effort, mcps }) => {
19796
19923
  const { agentId, agentRole } = getActiveAgent();
19797
19924
  const isCoordinator = isCoordinatorRole(agentRole) || (() => {
19798
19925
  try {
@@ -19824,15 +19951,26 @@ function registerSetAgentConfig(server2) {
19824
19951
  isError: true
19825
19952
  };
19826
19953
  }
19954
+ if (mcps && agent_id && !runtime && !model) {
19955
+ const { setAgentMcps: setAgentMcps2 } = await Promise.resolve().then(() => (init_agent_config(), agent_config_exports));
19956
+ const result4 = setAgentMcps2(agent_id, mcps);
19957
+ if (!result4.ok) {
19958
+ return { content: [{ type: "text", text: result4.error }], isError: true };
19959
+ }
19960
+ return {
19961
+ content: [{ type: "text", text: `Set ${agent_id} MCPs \u2192 [${mcps.join(", ")}] (exe-os always included)` }]
19962
+ };
19963
+ }
19827
19964
  if (!runtime || !model) {
19828
19965
  if (agent_id) {
19829
19966
  const cfg = getAgentRuntime(agent_id);
19830
19967
  const label = RUNTIME_LABELS[cfg.runtime] ?? cfg.runtime;
19968
+ const mcpInfo = cfg.mcps ? ` | MCPs: [${cfg.mcps.join(", ")}]` : " | MCPs: all";
19831
19969
  return {
19832
19970
  content: [
19833
19971
  {
19834
19972
  type: "text",
19835
- text: `${agent_id}: ${label} / ${cfg.model}`
19973
+ text: `${agent_id}: ${label} / ${cfg.model}${mcpInfo}`
19836
19974
  }
19837
19975
  ]
19838
19976
  };
@@ -19879,7 +20017,7 @@ function registerSetAgentConfig(server2) {
19879
20017
  isError: true
19880
20018
  };
19881
20019
  }
19882
- const result3 = setAgentRuntime(agent_id, runtime, model, reasoning_effort);
20020
+ const result3 = setAgentRuntime(agent_id, runtime, model, reasoning_effort, mcps);
19883
20021
  if (!result3.ok) {
19884
20022
  return {
19885
20023
  content: [{ type: "text", text: result3.error }],
@@ -19888,6 +20026,7 @@ function registerSetAgentConfig(server2) {
19888
20026
  }
19889
20027
  const parts = [`Set ${agent_id} \u2192 runtime=${runtime} model=${model}`];
19890
20028
  if (reasoning_effort) parts[0] += ` reasoning_effort=${reasoning_effort}`;
20029
+ if (mcps) parts[0] += ` mcps=[${mcps.join(", ")}]`;
19891
20030
  return {
19892
20031
  content: [{ type: "text", text: parts[0] }]
19893
20032
  };
@@ -22640,6 +22779,27 @@ async function cloudSync(config2) {
22640
22779
  if (stmts.length > 0) await client.batch(stmts, "write");
22641
22780
  pulled = pullResult.records.length;
22642
22781
  } else {
22782
+ try {
22783
+ const incomingIds = pullResult.records.map((r) => sqlSafe(r.id));
22784
+ if (incomingIds.length > 0) {
22785
+ const ph = incomingIds.map(() => "?").join(",");
22786
+ const existing = await client.execute({
22787
+ sql: `SELECT id, version, timestamp FROM memories WHERE id IN (${ph})`,
22788
+ args: incomingIds
22789
+ });
22790
+ const localMap = new Map(existing.rows.map((r) => [String(r.id), r]));
22791
+ for (const rec of pullResult.records) {
22792
+ const local = localMap.get(String(rec.id));
22793
+ if (local && Number(local.version) > 0 && Number(local.version) !== Number(rec.version ?? 0)) {
22794
+ process.stderr.write(
22795
+ `[cloud-sync] CONFLICT: memory ${String(rec.id).slice(0, 8)} \u2014 local v${local.version} vs remote v${rec.version ?? 0}. Remote wins (LWW).
22796
+ `
22797
+ );
22798
+ }
22799
+ }
22800
+ }
22801
+ } catch {
22802
+ }
22643
22803
  const stmts = pullResult.records.map((rec) => ({
22644
22804
  sql: `INSERT OR REPLACE INTO memories
22645
22805
  (id, agent_id, agent_role, session_id, timestamp,
@@ -25670,7 +25830,7 @@ var CLIENT_COO_PLACEHOLDERS = [
25670
25830
  "title"
25671
25831
  ];
25672
25832
  function renderClientCOOTemplate(vars) {
25673
- const resolved = { ...vars, title: vars.title || "Chief Operating Officer" };
25833
+ const resolved = { ...vars, title: vars.title || "Chief of Staff" };
25674
25834
  for (const key of CLIENT_COO_PLACEHOLDERS) {
25675
25835
  const value = resolved[key];
25676
25836
  if (typeof value !== "string" || value.length === 0) {
@@ -27055,7 +27215,10 @@ function rowToBehavior2(r) {
27055
27215
  active: Number(r.active),
27056
27216
  created_at: String(r.created_at),
27057
27217
  updated_at: String(r.updated_at),
27058
- vector: null
27218
+ vector: null,
27219
+ created_by_agent: r.created_by_agent ? String(r.created_by_agent) : null,
27220
+ created_by_device: r.created_by_device ? String(r.created_by_device) : null,
27221
+ source_session_id: r.source_session_id ? String(r.source_session_id) : null
27059
27222
  };
27060
27223
  }
27061
27224
  function registerBehavior(server2) {
@@ -27063,9 +27226,9 @@ function registerBehavior(server2) {
27063
27226
  "behavior",
27064
27227
  {
27065
27228
  title: "Behavior",
27066
- description: "Manage behavioral patterns, corrections, and reusable procedures for employees. Actions: store (create new), list (query existing), deactivate (soft-delete, restricted).",
27229
+ description: "Manage behavioral patterns, corrections, and reusable procedures for employees. Actions: store (create new), list (query existing), audit (creation context), deactivate (soft-delete, restricted).",
27067
27230
  inputSchema: {
27068
- action: z78.enum(["store", "list", "deactivate"]).describe("Action to perform"),
27231
+ action: z78.enum(["store", "list", "deactivate", "audit"]).describe("Action to perform"),
27069
27232
  content: z78.string().max(500).optional().describe("The behavioral instruction \u2014 one clear sentence (store)"),
27070
27233
  domain: z78.string().optional().describe("Category: workflow, code-style, tool-use, communication, architecture, testing"),
27071
27234
  priority: z78.enum(["p0", "p1", "p2"]).optional().describe("Priority tier. p0 = always included. p1 = standard (default). p2 = nice-to-have."),
@@ -27114,7 +27277,8 @@ function registerBehavior(server2) {
27114
27277
  const lines = behaviors.map((b) => {
27115
27278
  const scope = b.project_name ?? "global";
27116
27279
  const dom = b.domain ?? "general";
27117
- return `- [${b.agent_id}] [${dom}] (${scope}) ${b.content}
27280
+ const createdBy = b.created_by_agent ? ` (by: ${b.created_by_agent})` : "";
27281
+ return `- [${b.agent_id}] [${dom}] (${scope})${createdBy} ${b.content}
27118
27282
  ID: ${b.id}`;
27119
27283
  });
27120
27284
  return {
@@ -27199,6 +27363,39 @@ Use /exe-forget to remove any that this supersedes.`;
27199
27363
  content: [{ type: "text", text: responseText }]
27200
27364
  };
27201
27365
  }
27366
+ if (action === "audit") {
27367
+ if (!behavior_id) {
27368
+ return {
27369
+ content: [{ type: "text", text: "Missing required field: behavior_id is required for audit action." }],
27370
+ isError: true
27371
+ };
27372
+ }
27373
+ const client2 = getClient();
27374
+ const auditResult = await client2.execute({
27375
+ sql: `SELECT id, agent_id, content, domain, priority, project_name, active,
27376
+ created_at, updated_at, created_by_agent, created_by_device, source_session_id
27377
+ FROM behaviors WHERE id = ?`,
27378
+ args: [behavior_id]
27379
+ });
27380
+ if (auditResult.rows.length === 0) {
27381
+ return { content: [{ type: "text", text: `Behavior not found: ${behavior_id}` }], isError: true };
27382
+ }
27383
+ const b = auditResult.rows[0];
27384
+ const auditText = [
27385
+ `## Behavior Audit: ${b.id}`,
27386
+ `**Agent:** ${b.agent_id}`,
27387
+ `**Content:** ${b.content}`,
27388
+ `**Domain:** ${b.domain ?? "none"} | **Priority:** ${b.priority} | **Active:** ${b.active ? "yes" : "no"}`,
27389
+ `**Project:** ${b.project_name ?? "global"}`,
27390
+ `**Created:** ${b.created_at} | **Updated:** ${b.updated_at}`,
27391
+ ``,
27392
+ `### Creation context`,
27393
+ `**Created by agent:** ${b.created_by_agent ?? "unknown (pre-audit)"}`,
27394
+ `**Created from device:** ${b.created_by_device ?? "unknown (pre-audit)"}`,
27395
+ `**Source session:** ${b.source_session_id ?? "unknown (pre-audit)"}`
27396
+ ].join("\n");
27397
+ return { content: [{ type: "text", text: auditText }] };
27398
+ }
27202
27399
  const caller = getActiveAgent();
27203
27400
  const allowed = canCoordinate(caller.agentId, caller.agentRole);
27204
27401
  if (!allowed) {
@@ -31560,7 +31757,7 @@ function registerAllTools(server2, license, hasKey) {
31560
31757
  if (license && !isToolAllowedForPlan(name, license.plan)) return;
31561
31758
  fn(server2);
31562
31759
  };
31563
- const mcpToolSurface = process.env.EXE_MCP_TOOL_SURFACE ?? "legacy";
31760
+ const mcpToolSurface = process.env.EXE_MCP_TOOL_SURFACE ?? "consolidated";
31564
31761
  const exposeConsolidatedTasks = mcpToolSurface === "both" || mcpToolSurface === "consolidated";
31565
31762
  const exposeLegacyTasks = mcpToolSurface !== "consolidated";
31566
31763
  const exposeConsolidatedMemory = mcpToolSurface === "both" || mcpToolSurface === "consolidated";