@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
@@ -3137,6 +3137,13 @@ async function ensureSchema() {
3137
3137
  } catch (e) {
3138
3138
  logCatchDebug("migration", e);
3139
3139
  }
3140
+ for (const col of ["created_by_agent TEXT", "created_by_device TEXT", "source_session_id TEXT"]) {
3141
+ try {
3142
+ await client.execute({ sql: `ALTER TABLE behaviors ADD COLUMN ${col}`, args: [] });
3143
+ } catch (e) {
3144
+ logCatchDebug("migration", e);
3145
+ }
3146
+ }
3140
3147
  try {
3141
3148
  await client.execute({
3142
3149
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -4353,6 +4360,22 @@ async function ensureSchema() {
4353
4360
  } catch (e) {
4354
4361
  logCatchDebug("migration", e);
4355
4362
  }
4363
+ try {
4364
+ await client.execute({
4365
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
4366
+ args: []
4367
+ });
4368
+ } catch (e) {
4369
+ logCatchDebug("migration", e);
4370
+ }
4371
+ try {
4372
+ await client.execute({
4373
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
4374
+ args: []
4375
+ });
4376
+ } catch (e) {
4377
+ logCatchDebug("migration", e);
4378
+ }
4356
4379
  }
4357
4380
  async function disposeDatabase() {
4358
4381
  if (_walCheckpointTimer) {
@@ -4704,11 +4727,17 @@ var init_platform_procedures = __esm({
4704
4727
  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."
4705
4728
  },
4706
4729
  {
4707
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4730
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4708
4731
  domain: "workflow",
4709
4732
  priority: "p1",
4710
4733
  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."
4711
4734
  },
4735
+ {
4736
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4737
+ domain: "identity",
4738
+ priority: "p0",
4739
+ 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."
4740
+ },
4712
4741
  {
4713
4742
  title: "Single dispatch path \u2014 create_task only",
4714
4743
  domain: "workflow",
@@ -4742,6 +4771,12 @@ var init_platform_procedures = __esm({
4742
4771
  priority: "p0",
4743
4772
  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."
4744
4773
  },
4774
+ {
4775
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4776
+ domain: "security",
4777
+ priority: "p0",
4778
+ 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."
4779
+ },
4745
4780
  {
4746
4781
  title: "Customer patch triage \u2014 upstream bug vs customization",
4747
4782
  domain: "support",
@@ -4893,7 +4928,7 @@ var init_platform_procedures = __esm({
4893
4928
  title: "MCP tool dispatch \u2014 all tools use action parameter",
4894
4929
  domain: "tool-use",
4895
4930
  priority: "p0",
4896
- 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.'
4931
+ 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.'
4897
4932
  },
4898
4933
  {
4899
4934
  title: "MCP tools \u2014 memory, decision, and search",
@@ -5027,10 +5062,24 @@ function stableId(memoryId, type, content) {
5027
5062
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
5028
5063
  }
5029
5064
  function cleanText(text) {
5030
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5065
+ let cleaned = text.replace(
5066
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
5067
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
5068
+ );
5069
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5070
+ return cleaned;
5031
5071
  }
5032
- function splitSentences(text) {
5033
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
5072
+ function splitSegments(text) {
5073
+ const cleaned = cleanText(text);
5074
+ 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);
5075
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
5076
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
5077
+ if (lines.length > 0) return lines;
5078
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
5079
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
5080
+ }
5081
+ }
5082
+ return segments;
5034
5083
  }
5035
5084
  function inferCardType(sentence, toolName) {
5036
5085
  const lower = sentence.toLowerCase();
@@ -5062,12 +5111,12 @@ function predicateFor(type) {
5062
5111
  }
5063
5112
  }
5064
5113
  function extractMemoryCards(row) {
5065
- const sentences = splitSentences(row.raw_text);
5114
+ const segments = splitSegments(row.raw_text);
5066
5115
  const cards = [];
5067
- for (const sentence of sentences) {
5116
+ for (const sentence of segments) {
5068
5117
  const type = inferCardType(sentence, row.tool_name);
5069
5118
  const subject = extractSubject(sentence, row.agent_id);
5070
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
5119
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
5071
5120
  cards.push({
5072
5121
  id: stableId(row.id, type, content),
5073
5122
  memory_id: row.id,
@@ -5163,13 +5212,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
5163
5212
  last_accessed: String(row.timestamp)
5164
5213
  }));
5165
5214
  }
5166
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
5215
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
5167
5216
  var init_memory_cards = __esm({
5168
5217
  "src/lib/memory-cards.ts"() {
5169
5218
  "use strict";
5170
5219
  init_database();
5171
- MAX_CARDS_PER_MEMORY = 6;
5172
- MAX_SENTENCE_CHARS = 360;
5220
+ MAX_CARDS_PER_MEMORY = 8;
5221
+ MAX_SEGMENT_CHARS = 500;
5222
+ MIN_SEGMENT_CHARS = 20;
5173
5223
  }
5174
5224
  });
5175
5225
 
@@ -2102,6 +2102,13 @@ async function ensureSchema() {
2102
2102
  } catch (e) {
2103
2103
  logCatchDebug("migration", e);
2104
2104
  }
2105
+ for (const col of ["created_by_agent TEXT", "created_by_device TEXT", "source_session_id TEXT"]) {
2106
+ try {
2107
+ await client.execute({ sql: `ALTER TABLE behaviors ADD COLUMN ${col}`, args: [] });
2108
+ } catch (e) {
2109
+ logCatchDebug("migration", e);
2110
+ }
2111
+ }
2105
2112
  try {
2106
2113
  await client.execute({
2107
2114
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3318,6 +3325,22 @@ async function ensureSchema() {
3318
3325
  } catch (e) {
3319
3326
  logCatchDebug("migration", e);
3320
3327
  }
3328
+ try {
3329
+ await client.execute({
3330
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3331
+ args: []
3332
+ });
3333
+ } catch (e) {
3334
+ logCatchDebug("migration", e);
3335
+ }
3336
+ try {
3337
+ await client.execute({
3338
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3339
+ args: []
3340
+ });
3341
+ } catch (e) {
3342
+ logCatchDebug("migration", e);
3343
+ }
3321
3344
  }
3322
3345
  async function disposeDatabase() {
3323
3346
  if (_walCheckpointTimer) {
@@ -4441,11 +4464,17 @@ var init_platform_procedures = __esm({
4441
4464
  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."
4442
4465
  },
4443
4466
  {
4444
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4467
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4445
4468
  domain: "workflow",
4446
4469
  priority: "p1",
4447
4470
  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."
4448
4471
  },
4472
+ {
4473
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4474
+ domain: "identity",
4475
+ priority: "p0",
4476
+ 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."
4477
+ },
4449
4478
  {
4450
4479
  title: "Single dispatch path \u2014 create_task only",
4451
4480
  domain: "workflow",
@@ -4479,6 +4508,12 @@ var init_platform_procedures = __esm({
4479
4508
  priority: "p0",
4480
4509
  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."
4481
4510
  },
4511
+ {
4512
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4513
+ domain: "security",
4514
+ priority: "p0",
4515
+ 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."
4516
+ },
4482
4517
  {
4483
4518
  title: "Customer patch triage \u2014 upstream bug vs customization",
4484
4519
  domain: "support",
@@ -4630,7 +4665,7 @@ var init_platform_procedures = __esm({
4630
4665
  title: "MCP tool dispatch \u2014 all tools use action parameter",
4631
4666
  domain: "tool-use",
4632
4667
  priority: "p0",
4633
- 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.'
4668
+ 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.'
4634
4669
  },
4635
4670
  {
4636
4671
  title: "MCP tools \u2014 memory, decision, and search",
@@ -4764,10 +4799,24 @@ function stableId(memoryId, type, content) {
4764
4799
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
4765
4800
  }
4766
4801
  function cleanText(text) {
4767
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4768
- }
4769
- function splitSentences(text) {
4770
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
4802
+ let cleaned = text.replace(
4803
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
4804
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
4805
+ );
4806
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4807
+ return cleaned;
4808
+ }
4809
+ function splitSegments(text) {
4810
+ const cleaned = cleanText(text);
4811
+ 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);
4812
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
4813
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
4814
+ if (lines.length > 0) return lines;
4815
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
4816
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
4817
+ }
4818
+ }
4819
+ return segments;
4771
4820
  }
4772
4821
  function inferCardType(sentence, toolName) {
4773
4822
  const lower = sentence.toLowerCase();
@@ -4799,12 +4848,12 @@ function predicateFor(type) {
4799
4848
  }
4800
4849
  }
4801
4850
  function extractMemoryCards(row) {
4802
- const sentences = splitSentences(row.raw_text);
4851
+ const segments = splitSegments(row.raw_text);
4803
4852
  const cards = [];
4804
- for (const sentence of sentences) {
4853
+ for (const sentence of segments) {
4805
4854
  const type = inferCardType(sentence, row.tool_name);
4806
4855
  const subject = extractSubject(sentence, row.agent_id);
4807
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
4856
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
4808
4857
  cards.push({
4809
4858
  id: stableId(row.id, type, content),
4810
4859
  memory_id: row.id,
@@ -4900,13 +4949,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
4900
4949
  last_accessed: String(row.timestamp)
4901
4950
  }));
4902
4951
  }
4903
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
4952
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
4904
4953
  var init_memory_cards = __esm({
4905
4954
  "src/lib/memory-cards.ts"() {
4906
4955
  "use strict";
4907
4956
  init_database();
4908
- MAX_CARDS_PER_MEMORY = 6;
4909
- MAX_SENTENCE_CHARS = 360;
4957
+ MAX_CARDS_PER_MEMORY = 8;
4958
+ MAX_SEGMENT_CHARS = 500;
4959
+ MIN_SEGMENT_CHARS = 20;
4910
4960
  }
4911
4961
  });
4912
4962
 
@@ -5925,7 +5975,7 @@ import crypto2 from "crypto";
5925
5975
  async function listBehaviors(agentId2, projectName2, limit = 30) {
5926
5976
  const client = getClient();
5927
5977
  const result = await client.execute({
5928
- sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector
5978
+ sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector, created_by_agent, created_by_device, source_session_id
5929
5979
  FROM behaviors
5930
5980
  WHERE agent_id = ? AND active = 1
5931
5981
  AND (project_name IS NULL OR project_name = ?)
@@ -5954,7 +6004,10 @@ async function listBehaviors(agentId2, projectName2, limit = 30) {
5954
6004
  active: Number(r.active),
5955
6005
  created_at: String(r.created_at),
5956
6006
  updated_at: String(r.updated_at),
5957
- vector: r.vector ? Array.from(new Float32Array(r.vector)) : null
6007
+ vector: r.vector ? Array.from(new Float32Array(r.vector)) : null,
6008
+ created_by_agent: r.created_by_agent ? String(r.created_by_agent) : null,
6009
+ created_by_device: r.created_by_device ? String(r.created_by_device) : null,
6010
+ source_session_id: r.source_session_id ? String(r.source_session_id) : null
5958
6011
  }));
5959
6012
  }
5960
6013
 
@@ -2026,6 +2026,13 @@ async function ensureSchema() {
2026
2026
  } catch (e) {
2027
2027
  logCatchDebug("migration", e);
2028
2028
  }
2029
+ for (const col of ["created_by_agent TEXT", "created_by_device TEXT", "source_session_id TEXT"]) {
2030
+ try {
2031
+ await client.execute({ sql: `ALTER TABLE behaviors ADD COLUMN ${col}`, args: [] });
2032
+ } catch (e) {
2033
+ logCatchDebug("migration", e);
2034
+ }
2035
+ }
2029
2036
  try {
2030
2037
  await client.execute({
2031
2038
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3242,6 +3249,22 @@ async function ensureSchema() {
3242
3249
  } catch (e) {
3243
3250
  logCatchDebug("migration", e);
3244
3251
  }
3252
+ try {
3253
+ await client.execute({
3254
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3255
+ args: []
3256
+ });
3257
+ } catch (e) {
3258
+ logCatchDebug("migration", e);
3259
+ }
3260
+ try {
3261
+ await client.execute({
3262
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3263
+ args: []
3264
+ });
3265
+ } catch (e) {
3266
+ logCatchDebug("migration", e);
3267
+ }
3245
3268
  }
3246
3269
  async function disposeDatabase() {
3247
3270
  if (_walCheckpointTimer) {
@@ -4365,11 +4388,17 @@ var init_platform_procedures = __esm({
4365
4388
  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."
4366
4389
  },
4367
4390
  {
4368
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4391
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4369
4392
  domain: "workflow",
4370
4393
  priority: "p1",
4371
4394
  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."
4372
4395
  },
4396
+ {
4397
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4398
+ domain: "identity",
4399
+ priority: "p0",
4400
+ 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."
4401
+ },
4373
4402
  {
4374
4403
  title: "Single dispatch path \u2014 create_task only",
4375
4404
  domain: "workflow",
@@ -4403,6 +4432,12 @@ var init_platform_procedures = __esm({
4403
4432
  priority: "p0",
4404
4433
  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."
4405
4434
  },
4435
+ {
4436
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4437
+ domain: "security",
4438
+ priority: "p0",
4439
+ 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."
4440
+ },
4406
4441
  {
4407
4442
  title: "Customer patch triage \u2014 upstream bug vs customization",
4408
4443
  domain: "support",
@@ -4554,7 +4589,7 @@ var init_platform_procedures = __esm({
4554
4589
  title: "MCP tool dispatch \u2014 all tools use action parameter",
4555
4590
  domain: "tool-use",
4556
4591
  priority: "p0",
4557
- 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.'
4592
+ 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.'
4558
4593
  },
4559
4594
  {
4560
4595
  title: "MCP tools \u2014 memory, decision, and search",
@@ -4688,10 +4723,24 @@ function stableId(memoryId, type, content) {
4688
4723
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
4689
4724
  }
4690
4725
  function cleanText(text) {
4691
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4692
- }
4693
- function splitSentences(text) {
4694
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
4726
+ let cleaned = text.replace(
4727
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
4728
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
4729
+ );
4730
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4731
+ return cleaned;
4732
+ }
4733
+ function splitSegments(text) {
4734
+ const cleaned = cleanText(text);
4735
+ 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);
4736
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
4737
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
4738
+ if (lines.length > 0) return lines;
4739
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
4740
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
4741
+ }
4742
+ }
4743
+ return segments;
4695
4744
  }
4696
4745
  function inferCardType(sentence, toolName) {
4697
4746
  const lower = sentence.toLowerCase();
@@ -4723,12 +4772,12 @@ function predicateFor(type) {
4723
4772
  }
4724
4773
  }
4725
4774
  function extractMemoryCards(row) {
4726
- const sentences = splitSentences(row.raw_text);
4775
+ const segments = splitSegments(row.raw_text);
4727
4776
  const cards = [];
4728
- for (const sentence of sentences) {
4777
+ for (const sentence of segments) {
4729
4778
  const type = inferCardType(sentence, row.tool_name);
4730
4779
  const subject = extractSubject(sentence, row.agent_id);
4731
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
4780
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
4732
4781
  cards.push({
4733
4782
  id: stableId(row.id, type, content),
4734
4783
  memory_id: row.id,
@@ -4824,13 +4873,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
4824
4873
  last_accessed: String(row.timestamp)
4825
4874
  }));
4826
4875
  }
4827
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
4876
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
4828
4877
  var init_memory_cards = __esm({
4829
4878
  "src/lib/memory-cards.ts"() {
4830
4879
  "use strict";
4831
4880
  init_database();
4832
- MAX_CARDS_PER_MEMORY = 6;
4833
- MAX_SENTENCE_CHARS = 360;
4881
+ MAX_CARDS_PER_MEMORY = 8;
4882
+ MAX_SEGMENT_CHARS = 500;
4883
+ MIN_SEGMENT_CHARS = 20;
4834
4884
  }
4835
4885
  });
4836
4886