@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
@@ -750,6 +750,7 @@ __export(agent_config_exports, {
750
750
  getAgentRuntime: () => getAgentRuntime,
751
751
  loadAgentConfig: () => loadAgentConfig,
752
752
  saveAgentConfig: () => saveAgentConfig,
753
+ setAgentMcps: () => setAgentMcps,
753
754
  setAgentRuntime: () => setAgentRuntime
754
755
  });
755
756
  import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync3 } from "fs";
@@ -776,7 +777,7 @@ function getAgentRuntime(agentId) {
776
777
  if (orgDefault) return orgDefault;
777
778
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
778
779
  }
779
- function setAgentRuntime(agentId, runtime, model, reasoning_effort) {
780
+ function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
780
781
  const knownModels = KNOWN_RUNTIMES[runtime];
781
782
  if (!knownModels) {
782
783
  return {
@@ -791,12 +792,26 @@ function setAgentRuntime(agentId, runtime, model, reasoning_effort) {
791
792
  };
792
793
  }
793
794
  const config2 = loadAgentConfig();
795
+ const existing = config2[agentId];
794
796
  const entry = { runtime, model };
795
797
  if (reasoning_effort) entry.reasoning_effort = reasoning_effort;
798
+ if (mcps !== void 0) {
799
+ entry.mcps = mcps.includes("exe-os") ? mcps : ["exe-os", ...mcps];
800
+ } else if (existing?.mcps) {
801
+ entry.mcps = existing.mcps;
802
+ }
796
803
  config2[agentId] = entry;
797
804
  saveAgentConfig(config2);
798
805
  return { ok: true };
799
806
  }
807
+ function setAgentMcps(agentId, mcps) {
808
+ const config2 = loadAgentConfig();
809
+ const existing = config2[agentId] ?? getAgentRuntime(agentId);
810
+ existing.mcps = mcps.includes("exe-os") ? mcps : ["exe-os", ...mcps];
811
+ config2[agentId] = existing;
812
+ saveAgentConfig(config2);
813
+ return { ok: true };
814
+ }
800
815
  function clearAgentRuntime(agentId) {
801
816
  const config2 = loadAgentConfig();
802
817
  delete config2[agentId];
@@ -2697,6 +2712,13 @@ async function ensureSchema() {
2697
2712
  } catch (e) {
2698
2713
  logCatchDebug("migration", e);
2699
2714
  }
2715
+ for (const col of ["created_by_agent TEXT", "created_by_device TEXT", "source_session_id TEXT"]) {
2716
+ try {
2717
+ await client.execute({ sql: `ALTER TABLE behaviors ADD COLUMN ${col}`, args: [] });
2718
+ } catch (e) {
2719
+ logCatchDebug("migration", e);
2720
+ }
2721
+ }
2700
2722
  try {
2701
2723
  await client.execute({
2702
2724
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3913,6 +3935,22 @@ async function ensureSchema() {
3913
3935
  } catch (e) {
3914
3936
  logCatchDebug("migration", e);
3915
3937
  }
3938
+ try {
3939
+ await client.execute({
3940
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3941
+ args: []
3942
+ });
3943
+ } catch (e) {
3944
+ logCatchDebug("migration", e);
3945
+ }
3946
+ try {
3947
+ await client.execute({
3948
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3949
+ args: []
3950
+ });
3951
+ } catch (e) {
3952
+ logCatchDebug("migration", e);
3953
+ }
3916
3954
  }
3917
3955
  async function disposeDatabase() {
3918
3956
  if (_walCheckpointTimer) {
@@ -5049,11 +5087,17 @@ var init_platform_procedures = __esm({
5049
5087
  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."
5050
5088
  },
5051
5089
  {
5052
- title: "Customer orchestration maturity \u2014 recommend, never trap",
5090
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
5053
5091
  domain: "workflow",
5054
5092
  priority: "p1",
5055
5093
  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."
5056
5094
  },
5095
+ {
5096
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
5097
+ domain: "identity",
5098
+ priority: "p0",
5099
+ 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."
5100
+ },
5057
5101
  {
5058
5102
  title: "Single dispatch path \u2014 create_task only",
5059
5103
  domain: "workflow",
@@ -5087,6 +5131,12 @@ var init_platform_procedures = __esm({
5087
5131
  priority: "p0",
5088
5132
  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."
5089
5133
  },
5134
+ {
5135
+ title: "Destructive operations \u2014 mandatory reviewer gate",
5136
+ domain: "security",
5137
+ priority: "p0",
5138
+ 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."
5139
+ },
5090
5140
  {
5091
5141
  title: "Customer patch triage \u2014 upstream bug vs customization",
5092
5142
  domain: "support",
@@ -5238,7 +5288,7 @@ var init_platform_procedures = __esm({
5238
5288
  title: "MCP tool dispatch \u2014 all tools use action parameter",
5239
5289
  domain: "tool-use",
5240
5290
  priority: "p0",
5241
- 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.'
5291
+ 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.'
5242
5292
  },
5243
5293
  {
5244
5294
  title: "MCP tools \u2014 memory, decision, and search",
@@ -5372,10 +5422,24 @@ function stableId(memoryId, type, content) {
5372
5422
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
5373
5423
  }
5374
5424
  function cleanText(text) {
5375
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5425
+ let cleaned = text.replace(
5426
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
5427
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
5428
+ );
5429
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5430
+ return cleaned;
5376
5431
  }
5377
- function splitSentences(text) {
5378
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
5432
+ function splitSegments(text) {
5433
+ const cleaned = cleanText(text);
5434
+ 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);
5435
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
5436
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
5437
+ if (lines.length > 0) return lines;
5438
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
5439
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
5440
+ }
5441
+ }
5442
+ return segments;
5379
5443
  }
5380
5444
  function inferCardType(sentence, toolName) {
5381
5445
  const lower = sentence.toLowerCase();
@@ -5407,12 +5471,12 @@ function predicateFor(type) {
5407
5471
  }
5408
5472
  }
5409
5473
  function extractMemoryCards(row) {
5410
- const sentences = splitSentences(row.raw_text);
5474
+ const segments = splitSegments(row.raw_text);
5411
5475
  const cards = [];
5412
- for (const sentence of sentences) {
5476
+ for (const sentence of segments) {
5413
5477
  const type = inferCardType(sentence, row.tool_name);
5414
5478
  const subject = extractSubject(sentence, row.agent_id);
5415
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
5479
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
5416
5480
  cards.push({
5417
5481
  id: stableId(row.id, type, content),
5418
5482
  memory_id: row.id,
@@ -5508,13 +5572,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
5508
5572
  last_accessed: String(row.timestamp)
5509
5573
  }));
5510
5574
  }
5511
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
5575
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
5512
5576
  var init_memory_cards = __esm({
5513
5577
  "src/lib/memory-cards.ts"() {
5514
5578
  "use strict";
5515
5579
  init_database();
5516
- MAX_CARDS_PER_MEMORY = 6;
5517
- MAX_SENTENCE_CHARS = 360;
5580
+ MAX_CARDS_PER_MEMORY = 8;
5581
+ MAX_SEGMENT_CHARS = 500;
5582
+ MIN_SEGMENT_CHARS = 20;
5518
5583
  }
5519
5584
  });
5520
5585
 
@@ -7959,7 +8024,7 @@ async function assertVpsLicense(opts) {
7959
8024
  }
7960
8025
  if (!transientFailure) {
7961
8026
  throw new Error(
7962
- "License validation failed: unknown backend state. Restore network connectivity to https://askexe.com/cloud and retry."
8027
+ "License validation failed: unknown backend state. Restore network connectivity to https://cloud.askexe.com and retry."
7963
8028
  );
7964
8029
  }
7965
8030
  const fresh = await getCachedLicense();
@@ -7996,7 +8061,7 @@ async function assertVpsLicense(opts) {
7996
8061
  } catch {
7997
8062
  }
7998
8063
  throw new Error(
7999
- `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.`
8064
+ `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.`
8000
8065
  );
8001
8066
  }
8002
8067
  function startLicenseRevalidation(intervalMs = 36e5) {
@@ -8028,7 +8093,7 @@ var init_license = __esm({
8028
8093
  LICENSE_PATH = path10.join(EXE_AI_DIR, "license.key");
8029
8094
  CACHE_PATH = path10.join(EXE_AI_DIR, "license-cache.json");
8030
8095
  DEVICE_ID_PATH = path10.join(EXE_AI_DIR, "device-id");
8031
- API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
8096
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://cloud.askexe.com";
8032
8097
  RETRY_DELAY_MS = 500;
8033
8098
  LICENSE_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
8034
8099
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeHztAMOpR/ZMh+rWuOASjEZ54CGY
@@ -10647,6 +10712,19 @@ async function resolveTask(client, identifier, scopeSession) {
10647
10712
  args: [identifier, ...scope.args]
10648
10713
  });
10649
10714
  if (result.rows.length === 1) return result.rows[0];
10715
+ if (/^[a-f0-9]{7,12}$/i.test(identifier)) {
10716
+ result = await client.execute({
10717
+ sql: `SELECT * FROM tasks WHERE id LIKE ?`,
10718
+ args: [`${identifier}%`]
10719
+ });
10720
+ if (result.rows.length === 1) return result.rows[0];
10721
+ if (result.rows.length > 1) {
10722
+ const matches = result.rows.map((r) => `${String(r.id)} "${String(r.title)}" (${String(r.status)})`).join(", ");
10723
+ throw new Error(
10724
+ `Multiple tasks match short-ID "${identifier}": ${matches}. Use a longer prefix to disambiguate.`
10725
+ );
10726
+ }
10727
+ }
10650
10728
  result = await client.execute({
10651
10729
  sql: `SELECT * FROM tasks WHERE task_file LIKE ?${scope.sql}`,
10652
10730
  args: [`%${identifier}%`, ...scope.args]
@@ -11501,12 +11579,13 @@ async function cascadeUnblock(taskId, baseDir, now) {
11501
11579
  WHERE blocked_by = ? AND status = 'blocked'`,
11502
11580
  args: [now, taskId]
11503
11581
  });
11504
- if (baseDir && unblocked.rowsAffected > 0) {
11505
- const ubScope = sessionScopeFilter();
11506
- const unblockedRows = await client.execute({
11507
- sql: `SELECT task_file FROM tasks WHERE blocked_by IS NULL AND updated_at = ?${ubScope.sql}`,
11508
- args: [now, ...ubScope.args]
11509
- });
11582
+ if (unblocked.rowsAffected === 0) return;
11583
+ const ubScope = sessionScopeFilter();
11584
+ const unblockedRows = await client.execute({
11585
+ sql: `SELECT id, title, assigned_to, priority, task_file FROM tasks WHERE blocked_by IS NULL AND updated_at = ?${ubScope.sql}`,
11586
+ args: [now, ...ubScope.args]
11587
+ });
11588
+ if (baseDir) {
11510
11589
  for (const ur of unblockedRows.rows) {
11511
11590
  try {
11512
11591
  const ubFile = path20.join(baseDir, String(ur.task_file));
@@ -11518,6 +11597,19 @@ async function cascadeUnblock(taskId, baseDir, now) {
11518
11597
  }
11519
11598
  }
11520
11599
  }
11600
+ if (unblockedRows.rows.length > 0 && !process.env.VITEST) {
11601
+ try {
11602
+ const { queueIntercom: queueIntercom2 } = await Promise.resolve().then(() => (init_intercom_queue(), intercom_queue_exports));
11603
+ const dispatched = /* @__PURE__ */ new Set();
11604
+ for (const ur of unblockedRows.rows) {
11605
+ const assignee = String(ur.assigned_to);
11606
+ if (dispatched.has(assignee)) continue;
11607
+ dispatched.add(assignee);
11608
+ queueIntercom2(`${assignee}`, `unblocked: "${String(ur.title)}" is now ready`);
11609
+ }
11610
+ } catch {
11611
+ }
11612
+ }
11521
11613
  }
11522
11614
  async function findNextTask(assignedTo) {
11523
11615
  const client = getClient();
@@ -11659,6 +11751,15 @@ var init_tasks_notify = __esm({
11659
11751
  // src/lib/behaviors.ts
11660
11752
  import crypto8 from "crypto";
11661
11753
  async function storeBehavior(opts) {
11754
+ try {
11755
+ const { loadEmployeesSync: loadEmployeesSync2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
11756
+ const roster = loadEmployeesSync2();
11757
+ if (roster.length > 0 && !roster.some((e) => e.name === opts.agentId)) {
11758
+ throw new Error(`Agent "${opts.agentId}" not found in roster. Cannot store behavior for unregistered agent.`);
11759
+ }
11760
+ } catch (e) {
11761
+ if (e instanceof Error && e.message.includes("not found in roster")) throw e;
11762
+ }
11662
11763
  const client = getClient();
11663
11764
  const id = crypto8.randomUUID();
11664
11765
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -11669,10 +11770,18 @@ async function storeBehavior(opts) {
11669
11770
  vector = new Float32Array(vec);
11670
11771
  } catch {
11671
11772
  }
11773
+ let createdByDevice = null;
11774
+ try {
11775
+ const { loadDeviceId: loadDeviceId2 } = await Promise.resolve().then(() => (init_license(), license_exports));
11776
+ createdByDevice = loadDeviceId2() ?? null;
11777
+ } catch {
11778
+ }
11779
+ const createdByAgent = process.env.AGENT_ID ?? null;
11780
+ const sourceSessionId = process.env.CLAUDE_SESSION_ID ?? process.env.SESSION_ID ?? null;
11672
11781
  await client.execute({
11673
- sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector)
11674
- VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?)`,
11675
- args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now, vector ? vector.buffer : null]
11782
+ 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)
11783
+ VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?)`,
11784
+ args: [id, opts.agentId, opts.projectName ?? null, opts.domain ?? null, opts.priority ?? "p1", opts.content, now, now, vector ? vector.buffer : null, createdByAgent, createdByDevice, sourceSessionId]
11676
11785
  });
11677
11786
  return id;
11678
11787
  }
@@ -12104,6 +12213,12 @@ async function updateTask(input) {
12104
12213
  }
12105
12214
  }
12106
12215
  }
12216
+ if (input.status === "cancelled") {
12217
+ try {
12218
+ await cascadeUnblock(taskId, input.baseDir, now);
12219
+ } catch {
12220
+ }
12221
+ }
12107
12222
  if ((input.status === "done" || input.status === "closed") && !isCoordinatorName(String(row.assigned_to)) && !process.env.VITEST) {
12108
12223
  Promise.resolve().then(() => (init_skill_learning(), skill_learning_exports)).then(
12109
12224
  ({ captureAndLearn: captureAndLearn2 }) => captureAndLearn2({
@@ -12635,11 +12750,12 @@ function getDispatchedBy(sessionKey) {
12635
12750
  }
12636
12751
  }
12637
12752
  function resolveExeSession() {
12753
+ if (process.env.EXE_SESSION_NAME) {
12754
+ const fromEnv = extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
12755
+ if (fromEnv) return fromEnv;
12756
+ }
12638
12757
  const mySession = getMySession();
12639
12758
  if (!mySession) {
12640
- if (process.env.EXE_SESSION_NAME) {
12641
- return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
12642
- }
12643
12759
  return null;
12644
12760
  }
12645
12761
  const fromSessionName = extractRootExe(mySession);
@@ -12654,6 +12770,10 @@ function resolveExeSession() {
12654
12770
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
12655
12771
  `
12656
12772
  );
12773
+ try {
12774
+ registerParentExe(key, fromSessionName);
12775
+ } catch {
12776
+ }
12657
12777
  candidate = fromSessionName;
12658
12778
  } else {
12659
12779
  candidate = fromCache;
@@ -2065,6 +2065,13 @@ async function ensureSchema() {
2065
2065
  } catch (e) {
2066
2066
  logCatchDebug("migration", e);
2067
2067
  }
2068
+ for (const col of ["created_by_agent TEXT", "created_by_device TEXT", "source_session_id TEXT"]) {
2069
+ try {
2070
+ await client.execute({ sql: `ALTER TABLE behaviors ADD COLUMN ${col}`, args: [] });
2071
+ } catch (e) {
2072
+ logCatchDebug("migration", e);
2073
+ }
2074
+ }
2068
2075
  try {
2069
2076
  await client.execute({
2070
2077
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3281,6 +3288,22 @@ async function ensureSchema() {
3281
3288
  } catch (e) {
3282
3289
  logCatchDebug("migration", e);
3283
3290
  }
3291
+ try {
3292
+ await client.execute({
3293
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3294
+ args: []
3295
+ });
3296
+ } catch (e) {
3297
+ logCatchDebug("migration", e);
3298
+ }
3299
+ try {
3300
+ await client.execute({
3301
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3302
+ args: []
3303
+ });
3304
+ } catch (e) {
3305
+ logCatchDebug("migration", e);
3306
+ }
3284
3307
  }
3285
3308
  async function disposeDatabase() {
3286
3309
  if (_walCheckpointTimer) {
@@ -4404,11 +4427,17 @@ var init_platform_procedures = __esm({
4404
4427
  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."
4405
4428
  },
4406
4429
  {
4407
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4430
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4408
4431
  domain: "workflow",
4409
4432
  priority: "p1",
4410
4433
  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."
4411
4434
  },
4435
+ {
4436
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4437
+ domain: "identity",
4438
+ priority: "p0",
4439
+ 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."
4440
+ },
4412
4441
  {
4413
4442
  title: "Single dispatch path \u2014 create_task only",
4414
4443
  domain: "workflow",
@@ -4442,6 +4471,12 @@ var init_platform_procedures = __esm({
4442
4471
  priority: "p0",
4443
4472
  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."
4444
4473
  },
4474
+ {
4475
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4476
+ domain: "security",
4477
+ priority: "p0",
4478
+ 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."
4479
+ },
4445
4480
  {
4446
4481
  title: "Customer patch triage \u2014 upstream bug vs customization",
4447
4482
  domain: "support",
@@ -4593,7 +4628,7 @@ var init_platform_procedures = __esm({
4593
4628
  title: "MCP tool dispatch \u2014 all tools use action parameter",
4594
4629
  domain: "tool-use",
4595
4630
  priority: "p0",
4596
- 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.'
4631
+ 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.'
4597
4632
  },
4598
4633
  {
4599
4634
  title: "MCP tools \u2014 memory, decision, and search",
@@ -4727,10 +4762,24 @@ function stableId(memoryId, type, content) {
4727
4762
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
4728
4763
  }
4729
4764
  function cleanText(text) {
4730
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4731
- }
4732
- function splitSentences(text) {
4733
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
4765
+ let cleaned = text.replace(
4766
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
4767
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
4768
+ );
4769
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4770
+ return cleaned;
4771
+ }
4772
+ function splitSegments(text) {
4773
+ const cleaned = cleanText(text);
4774
+ 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);
4775
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
4776
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
4777
+ if (lines.length > 0) return lines;
4778
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
4779
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
4780
+ }
4781
+ }
4782
+ return segments;
4734
4783
  }
4735
4784
  function inferCardType(sentence, toolName) {
4736
4785
  const lower = sentence.toLowerCase();
@@ -4762,12 +4811,12 @@ function predicateFor(type) {
4762
4811
  }
4763
4812
  }
4764
4813
  function extractMemoryCards(row) {
4765
- const sentences = splitSentences(row.raw_text);
4814
+ const segments = splitSegments(row.raw_text);
4766
4815
  const cards = [];
4767
- for (const sentence of sentences) {
4816
+ for (const sentence of segments) {
4768
4817
  const type = inferCardType(sentence, row.tool_name);
4769
4818
  const subject = extractSubject(sentence, row.agent_id);
4770
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
4819
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
4771
4820
  cards.push({
4772
4821
  id: stableId(row.id, type, content),
4773
4822
  memory_id: row.id,
@@ -4863,13 +4912,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
4863
4912
  last_accessed: String(row.timestamp)
4864
4913
  }));
4865
4914
  }
4866
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
4915
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
4867
4916
  var init_memory_cards = __esm({
4868
4917
  "src/lib/memory-cards.ts"() {
4869
4918
  "use strict";
4870
4919
  init_database();
4871
- MAX_CARDS_PER_MEMORY = 6;
4872
- MAX_SENTENCE_CHARS = 360;
4920
+ MAX_CARDS_PER_MEMORY = 8;
4921
+ MAX_SEGMENT_CHARS = 500;
4922
+ MIN_SEGMENT_CHARS = 20;
4873
4923
  }
4874
4924
  });
4875
4925
 
@@ -6104,7 +6154,7 @@ var init_license = __esm({
6104
6154
  LICENSE_PATH = path11.join(EXE_AI_DIR, "license.key");
6105
6155
  CACHE_PATH = path11.join(EXE_AI_DIR, "license-cache.json");
6106
6156
  DEVICE_ID_PATH = path11.join(EXE_AI_DIR, "device-id");
6107
- API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
6157
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://cloud.askexe.com";
6108
6158
  }
6109
6159
  });
6110
6160
 
@@ -6157,6 +6207,18 @@ function extractRootExe(name) {
6157
6207
  const parts = name.split("-").filter(Boolean);
6158
6208
  return parts.length > 0 ? parts[parts.length - 1] : null;
6159
6209
  }
6210
+ function registerParentExe(sessionKey, parentExe, dispatchedBy) {
6211
+ if (!existsSync14(SESSION_CACHE)) {
6212
+ mkdirSync7(SESSION_CACHE, { recursive: true });
6213
+ }
6214
+ const rootExe = extractRootExe(parentExe) ?? parentExe;
6215
+ const filePath = path14.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`);
6216
+ writeFileSync6(filePath, JSON.stringify({
6217
+ parentExe: rootExe,
6218
+ dispatchedBy: dispatchedBy || rootExe,
6219
+ registeredAt: (/* @__PURE__ */ new Date()).toISOString()
6220
+ }));
6221
+ }
6160
6222
  function getParentExe(sessionKey) {
6161
6223
  try {
6162
6224
  const data = JSON.parse(readFileSync9(path14.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`), "utf8"));
@@ -6166,11 +6228,12 @@ function getParentExe(sessionKey) {
6166
6228
  }
6167
6229
  }
6168
6230
  function resolveExeSession() {
6231
+ if (process.env.EXE_SESSION_NAME) {
6232
+ const fromEnv = extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
6233
+ if (fromEnv) return fromEnv;
6234
+ }
6169
6235
  const mySession = getMySession();
6170
6236
  if (!mySession) {
6171
- if (process.env.EXE_SESSION_NAME) {
6172
- return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
6173
- }
6174
6237
  return null;
6175
6238
  }
6176
6239
  const fromSessionName = extractRootExe(mySession);
@@ -6185,6 +6248,10 @@ function resolveExeSession() {
6185
6248
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
6186
6249
  `
6187
6250
  );
6251
+ try {
6252
+ registerParentExe(key, fromSessionName);
6253
+ } catch {
6254
+ }
6188
6255
  candidate = fromSessionName;
6189
6256
  } else {
6190
6257
  candidate = fromCache;