@askexenow/exe-os 0.9.112 → 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 +54 -11
  3. package/dist/bin/agentic-reflection-backfill.js +29 -1
  4. package/dist/bin/agentic-semantic-label.js +29 -1
  5. package/dist/bin/backfill-conversations.js +53 -10
  6. package/dist/bin/backfill-responses.js +54 -11
  7. package/dist/bin/backfill-vectors.js +29 -1
  8. package/dist/bin/bulk-sync-postgres.js +55 -12
  9. package/dist/bin/cleanup-stale-review-tasks.js +75 -15
  10. package/dist/bin/cli.js +293 -76
  11. package/dist/bin/exe-agent-config.js +7 -1
  12. package/dist/bin/exe-agent.js +28 -2
  13. package/dist/bin/exe-assign.js +54 -11
  14. package/dist/bin/exe-boot.js +481 -147
  15. package/dist/bin/exe-call.js +45 -4
  16. package/dist/bin/exe-cloud.js +93 -15
  17. package/dist/bin/exe-dispatch.js +369 -24
  18. package/dist/bin/exe-doctor.js +53 -10
  19. package/dist/bin/exe-export-behaviors.js +54 -11
  20. package/dist/bin/exe-forget.js +54 -11
  21. package/dist/bin/exe-gateway.js +128 -23
  22. package/dist/bin/exe-heartbeat.js +75 -15
  23. package/dist/bin/exe-kill.js +54 -11
  24. package/dist/bin/exe-launch-agent.js +70 -12
  25. package/dist/bin/exe-new-employee.js +175 -7
  26. package/dist/bin/exe-pending-messages.js +75 -15
  27. package/dist/bin/exe-pending-notifications.js +75 -15
  28. package/dist/bin/exe-pending-reviews.js +75 -15
  29. package/dist/bin/exe-rename.js +54 -11
  30. package/dist/bin/exe-review.js +54 -11
  31. package/dist/bin/exe-search.js +54 -11
  32. package/dist/bin/exe-session-cleanup.js +491 -146
  33. package/dist/bin/exe-settings.js +10 -4
  34. package/dist/bin/exe-start-codex.js +524 -245
  35. package/dist/bin/exe-start-opencode.js +534 -165
  36. package/dist/bin/exe-status.js +75 -15
  37. package/dist/bin/exe-support.js +1 -1
  38. package/dist/bin/exe-team.js +54 -11
  39. package/dist/bin/git-sweep.js +369 -24
  40. package/dist/bin/graph-backfill.js +54 -11
  41. package/dist/bin/graph-export.js +54 -11
  42. package/dist/bin/install.js +62 -4
  43. package/dist/bin/intercom-check.js +491 -146
  44. package/dist/bin/pre-publish.js +13 -1
  45. package/dist/bin/scan-tasks.js +369 -24
  46. package/dist/bin/setup.js +91 -13
  47. package/dist/bin/shard-migrate.js +54 -11
  48. package/dist/bin/stack-update.js +1 -1
  49. package/dist/bin/update.js +3 -3
  50. package/dist/gateway/index.js +128 -23
  51. package/dist/hooks/bug-report-worker.js +128 -23
  52. package/dist/hooks/codex-stop-task-finalizer.js +512 -140
  53. package/dist/hooks/commit-complete.js +369 -24
  54. package/dist/hooks/error-recall.js +54 -11
  55. package/dist/hooks/ingest.js +4575 -252
  56. package/dist/hooks/instructions-loaded.js +54 -11
  57. package/dist/hooks/notification.js +54 -11
  58. package/dist/hooks/post-compact.js +75 -15
  59. package/dist/hooks/post-tool-combined.js +75 -15
  60. package/dist/hooks/pre-compact.js +449 -104
  61. package/dist/hooks/pre-tool-use.js +90 -15
  62. package/dist/hooks/prompt-submit.js +129 -24
  63. package/dist/hooks/session-end.js +451 -109
  64. package/dist/hooks/session-start.js +104 -16
  65. package/dist/hooks/stop.js +74 -14
  66. package/dist/hooks/subagent-stop.js +75 -15
  67. package/dist/hooks/summary-worker.js +73 -7
  68. package/dist/index.js +128 -23
  69. package/dist/lib/agent-config.js +16 -1
  70. package/dist/lib/cloud-sync.js +38 -1
  71. package/dist/lib/consolidation.js +16 -1
  72. package/dist/lib/database.js +16 -0
  73. package/dist/lib/db.js +16 -0
  74. package/dist/lib/device-registry.js +16 -0
  75. package/dist/lib/employee-templates.js +29 -3
  76. package/dist/lib/employees.js +16 -1
  77. package/dist/lib/exe-daemon.js +268 -42
  78. package/dist/lib/hybrid-search.js +54 -11
  79. package/dist/lib/license.js +3 -3
  80. package/dist/lib/messaging.js +21 -4
  81. package/dist/lib/schedules.js +29 -1
  82. package/dist/lib/skill-learning.js +458 -70
  83. package/dist/lib/status-brief.js +14 -1
  84. package/dist/lib/store.js +54 -11
  85. package/dist/lib/tasks.js +393 -91
  86. package/dist/lib/tmux-routing.js +316 -14
  87. package/dist/mcp/server.js +169 -30
  88. package/dist/mcp/tools/create-task.js +75 -13
  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 +390 -91
  93. package/dist/runtime/index.js +446 -101
  94. package/dist/tui/App.js +208 -54
  95. package/package.json +1 -1
@@ -3251,6 +3251,22 @@ async function ensureSchema() {
3251
3251
  } catch (e) {
3252
3252
  logCatchDebug("migration", e);
3253
3253
  }
3254
+ try {
3255
+ await client.execute({
3256
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3257
+ args: []
3258
+ });
3259
+ } catch (e) {
3260
+ logCatchDebug("migration", e);
3261
+ }
3262
+ try {
3263
+ await client.execute({
3264
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3265
+ args: []
3266
+ });
3267
+ } catch (e) {
3268
+ logCatchDebug("migration", e);
3269
+ }
3254
3270
  }
3255
3271
  async function disposeDatabase() {
3256
3272
  if (_walCheckpointTimer) {
@@ -4374,11 +4390,17 @@ var init_platform_procedures = __esm({
4374
4390
  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."
4375
4391
  },
4376
4392
  {
4377
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4393
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4378
4394
  domain: "workflow",
4379
4395
  priority: "p1",
4380
4396
  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."
4381
4397
  },
4398
+ {
4399
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4400
+ domain: "identity",
4401
+ priority: "p0",
4402
+ 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."
4403
+ },
4382
4404
  {
4383
4405
  title: "Single dispatch path \u2014 create_task only",
4384
4406
  domain: "workflow",
@@ -4412,6 +4434,12 @@ var init_platform_procedures = __esm({
4412
4434
  priority: "p0",
4413
4435
  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."
4414
4436
  },
4437
+ {
4438
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4439
+ domain: "security",
4440
+ priority: "p0",
4441
+ 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."
4442
+ },
4415
4443
  {
4416
4444
  title: "Customer patch triage \u2014 upstream bug vs customization",
4417
4445
  domain: "support",
@@ -4697,10 +4725,24 @@ function stableId(memoryId, type, content) {
4697
4725
  return createHash3("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
4698
4726
  }
4699
4727
  function cleanText(text) {
4700
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4701
- }
4702
- function splitSentences(text) {
4703
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
4728
+ let cleaned = text.replace(
4729
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
4730
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
4731
+ );
4732
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4733
+ return cleaned;
4734
+ }
4735
+ function splitSegments(text) {
4736
+ const cleaned = cleanText(text);
4737
+ 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);
4738
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
4739
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
4740
+ if (lines.length > 0) return lines;
4741
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
4742
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
4743
+ }
4744
+ }
4745
+ return segments;
4704
4746
  }
4705
4747
  function inferCardType(sentence, toolName) {
4706
4748
  const lower = sentence.toLowerCase();
@@ -4732,12 +4774,12 @@ function predicateFor(type) {
4732
4774
  }
4733
4775
  }
4734
4776
  function extractMemoryCards(row) {
4735
- const sentences = splitSentences(row.raw_text);
4777
+ const segments = splitSegments(row.raw_text);
4736
4778
  const cards = [];
4737
- for (const sentence of sentences) {
4779
+ for (const sentence of segments) {
4738
4780
  const type = inferCardType(sentence, row.tool_name);
4739
4781
  const subject = extractSubject(sentence, row.agent_id);
4740
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
4782
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
4741
4783
  cards.push({
4742
4784
  id: stableId(row.id, type, content),
4743
4785
  memory_id: row.id,
@@ -4833,13 +4875,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
4833
4875
  last_accessed: String(row.timestamp)
4834
4876
  }));
4835
4877
  }
4836
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
4878
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
4837
4879
  var init_memory_cards = __esm({
4838
4880
  "src/lib/memory-cards.ts"() {
4839
4881
  "use strict";
4840
4882
  init_database();
4841
- MAX_CARDS_PER_MEMORY = 6;
4842
- MAX_SENTENCE_CHARS = 360;
4883
+ MAX_CARDS_PER_MEMORY = 8;
4884
+ MAX_SEGMENT_CHARS = 500;
4885
+ MIN_SEGMENT_CHARS = 20;
4843
4886
  }
4844
4887
  });
4845
4888
 
@@ -3251,6 +3251,22 @@ async function ensureSchema() {
3251
3251
  } catch (e) {
3252
3252
  logCatchDebug("migration", e);
3253
3253
  }
3254
+ try {
3255
+ await client.execute({
3256
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3257
+ args: []
3258
+ });
3259
+ } catch (e) {
3260
+ logCatchDebug("migration", e);
3261
+ }
3262
+ try {
3263
+ await client.execute({
3264
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3265
+ args: []
3266
+ });
3267
+ } catch (e) {
3268
+ logCatchDebug("migration", e);
3269
+ }
3254
3270
  }
3255
3271
  async function disposeDatabase() {
3256
3272
  if (_walCheckpointTimer) {
@@ -4374,11 +4390,17 @@ var init_platform_procedures = __esm({
4374
4390
  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."
4375
4391
  },
4376
4392
  {
4377
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4393
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4378
4394
  domain: "workflow",
4379
4395
  priority: "p1",
4380
4396
  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."
4381
4397
  },
4398
+ {
4399
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4400
+ domain: "identity",
4401
+ priority: "p0",
4402
+ 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."
4403
+ },
4382
4404
  {
4383
4405
  title: "Single dispatch path \u2014 create_task only",
4384
4406
  domain: "workflow",
@@ -4412,6 +4434,12 @@ var init_platform_procedures = __esm({
4412
4434
  priority: "p0",
4413
4435
  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."
4414
4436
  },
4437
+ {
4438
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4439
+ domain: "security",
4440
+ priority: "p0",
4441
+ 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."
4442
+ },
4415
4443
  {
4416
4444
  title: "Customer patch triage \u2014 upstream bug vs customization",
4417
4445
  domain: "support",
@@ -4697,10 +4725,24 @@ function stableId(memoryId, type, content) {
4697
4725
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
4698
4726
  }
4699
4727
  function cleanText(text) {
4700
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4701
- }
4702
- function splitSentences(text) {
4703
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
4728
+ let cleaned = text.replace(
4729
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
4730
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
4731
+ );
4732
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4733
+ return cleaned;
4734
+ }
4735
+ function splitSegments(text) {
4736
+ const cleaned = cleanText(text);
4737
+ 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);
4738
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
4739
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
4740
+ if (lines.length > 0) return lines;
4741
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
4742
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
4743
+ }
4744
+ }
4745
+ return segments;
4704
4746
  }
4705
4747
  function inferCardType(sentence, toolName) {
4706
4748
  const lower = sentence.toLowerCase();
@@ -4732,12 +4774,12 @@ function predicateFor(type) {
4732
4774
  }
4733
4775
  }
4734
4776
  function extractMemoryCards(row) {
4735
- const sentences = splitSentences(row.raw_text);
4777
+ const segments = splitSegments(row.raw_text);
4736
4778
  const cards = [];
4737
- for (const sentence of sentences) {
4779
+ for (const sentence of segments) {
4738
4780
  const type = inferCardType(sentence, row.tool_name);
4739
4781
  const subject = extractSubject(sentence, row.agent_id);
4740
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
4782
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
4741
4783
  cards.push({
4742
4784
  id: stableId(row.id, type, content),
4743
4785
  memory_id: row.id,
@@ -4833,13 +4875,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
4833
4875
  last_accessed: String(row.timestamp)
4834
4876
  }));
4835
4877
  }
4836
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
4878
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
4837
4879
  var init_memory_cards = __esm({
4838
4880
  "src/lib/memory-cards.ts"() {
4839
4881
  "use strict";
4840
4882
  init_database();
4841
- MAX_CARDS_PER_MEMORY = 6;
4842
- MAX_SENTENCE_CHARS = 360;
4883
+ MAX_CARDS_PER_MEMORY = 8;
4884
+ MAX_SEGMENT_CHARS = 500;
4885
+ MIN_SEGMENT_CHARS = 20;
4843
4886
  }
4844
4887
  });
4845
4888
 
@@ -3546,6 +3546,22 @@ async function ensureSchema() {
3546
3546
  } catch (e) {
3547
3547
  logCatchDebug("migration", e);
3548
3548
  }
3549
+ try {
3550
+ await client.execute({
3551
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3552
+ args: []
3553
+ });
3554
+ } catch (e) {
3555
+ logCatchDebug("migration", e);
3556
+ }
3557
+ try {
3558
+ await client.execute({
3559
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3560
+ args: []
3561
+ });
3562
+ } catch (e) {
3563
+ logCatchDebug("migration", e);
3564
+ }
3549
3565
  }
3550
3566
  async function disposeDatabase() {
3551
3567
  if (_walCheckpointTimer) {
@@ -3612,7 +3628,7 @@ var init_license = __esm({
3612
3628
  LICENSE_PATH = path10.join(EXE_AI_DIR, "license.key");
3613
3629
  CACHE_PATH = path10.join(EXE_AI_DIR, "license-cache.json");
3614
3630
  DEVICE_ID_PATH = path10.join(EXE_AI_DIR, "device-id");
3615
- API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
3631
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://cloud.askexe.com";
3616
3632
  }
3617
3633
  });
3618
3634
 
@@ -3665,6 +3681,18 @@ function extractRootExe(name) {
3665
3681
  const parts = name.split("-").filter(Boolean);
3666
3682
  return parts.length > 0 ? parts[parts.length - 1] : null;
3667
3683
  }
3684
+ function registerParentExe(sessionKey, parentExe, dispatchedBy) {
3685
+ if (!existsSync12(SESSION_CACHE)) {
3686
+ mkdirSync7(SESSION_CACHE, { recursive: true });
3687
+ }
3688
+ const rootExe = extractRootExe(parentExe) ?? parentExe;
3689
+ const filePath = path13.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`);
3690
+ writeFileSync7(filePath, JSON.stringify({
3691
+ parentExe: rootExe,
3692
+ dispatchedBy: dispatchedBy || rootExe,
3693
+ registeredAt: (/* @__PURE__ */ new Date()).toISOString()
3694
+ }));
3695
+ }
3668
3696
  function getParentExe(sessionKey) {
3669
3697
  try {
3670
3698
  const data = JSON.parse(readFileSync10(path13.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`), "utf8"));
@@ -3674,11 +3702,12 @@ function getParentExe(sessionKey) {
3674
3702
  }
3675
3703
  }
3676
3704
  function resolveExeSession() {
3705
+ if (process.env.EXE_SESSION_NAME) {
3706
+ const fromEnv = extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
3707
+ if (fromEnv) return fromEnv;
3708
+ }
3677
3709
  const mySession = getMySession();
3678
3710
  if (!mySession) {
3679
- if (process.env.EXE_SESSION_NAME) {
3680
- return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
3681
- }
3682
3711
  return null;
3683
3712
  }
3684
3713
  const fromSessionName = extractRootExe(mySession);
@@ -3693,6 +3722,10 @@ function resolveExeSession() {
3693
3722
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
3694
3723
  `
3695
3724
  );
3725
+ try {
3726
+ registerParentExe(key, fromSessionName);
3727
+ } catch {
3728
+ }
3696
3729
  candidate = fromSessionName;
3697
3730
  } else {
3698
3731
  candidate = fromCache;
@@ -4996,11 +5029,17 @@ var init_platform_procedures = __esm({
4996
5029
  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."
4997
5030
  },
4998
5031
  {
4999
- title: "Customer orchestration maturity \u2014 recommend, never trap",
5032
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
5000
5033
  domain: "workflow",
5001
5034
  priority: "p1",
5002
5035
  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."
5003
5036
  },
5037
+ {
5038
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
5039
+ domain: "identity",
5040
+ priority: "p0",
5041
+ 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."
5042
+ },
5004
5043
  {
5005
5044
  title: "Single dispatch path \u2014 create_task only",
5006
5045
  domain: "workflow",
@@ -5034,6 +5073,12 @@ var init_platform_procedures = __esm({
5034
5073
  priority: "p0",
5035
5074
  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."
5036
5075
  },
5076
+ {
5077
+ title: "Destructive operations \u2014 mandatory reviewer gate",
5078
+ domain: "security",
5079
+ priority: "p0",
5080
+ 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."
5081
+ },
5037
5082
  {
5038
5083
  title: "Customer patch triage \u2014 upstream bug vs customization",
5039
5084
  domain: "support",
@@ -5319,10 +5364,24 @@ function stableId(memoryId, type, content) {
5319
5364
  return createHash3("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
5320
5365
  }
5321
5366
  function cleanText(text) {
5322
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5323
- }
5324
- function splitSentences(text) {
5325
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
5367
+ let cleaned = text.replace(
5368
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
5369
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
5370
+ );
5371
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
5372
+ return cleaned;
5373
+ }
5374
+ function splitSegments(text) {
5375
+ const cleaned = cleanText(text);
5376
+ 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);
5377
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
5378
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
5379
+ if (lines.length > 0) return lines;
5380
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
5381
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
5382
+ }
5383
+ }
5384
+ return segments;
5326
5385
  }
5327
5386
  function inferCardType(sentence, toolName) {
5328
5387
  const lower = sentence.toLowerCase();
@@ -5354,12 +5413,12 @@ function predicateFor(type) {
5354
5413
  }
5355
5414
  }
5356
5415
  function extractMemoryCards(row) {
5357
- const sentences = splitSentences(row.raw_text);
5416
+ const segments = splitSegments(row.raw_text);
5358
5417
  const cards = [];
5359
- for (const sentence of sentences) {
5418
+ for (const sentence of segments) {
5360
5419
  const type = inferCardType(sentence, row.tool_name);
5361
5420
  const subject = extractSubject(sentence, row.agent_id);
5362
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
5421
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
5363
5422
  cards.push({
5364
5423
  id: stableId(row.id, type, content),
5365
5424
  memory_id: row.id,
@@ -5455,13 +5514,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
5455
5514
  last_accessed: String(row.timestamp)
5456
5515
  }));
5457
5516
  }
5458
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
5517
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
5459
5518
  var init_memory_cards = __esm({
5460
5519
  "src/lib/memory-cards.ts"() {
5461
5520
  "use strict";
5462
5521
  init_database();
5463
- MAX_CARDS_PER_MEMORY = 6;
5464
- MAX_SENTENCE_CHARS = 360;
5522
+ MAX_CARDS_PER_MEMORY = 8;
5523
+ MAX_SEGMENT_CHARS = 500;
5524
+ MIN_SEGMENT_CHARS = 20;
5465
5525
  }
5466
5526
  });
5467
5527
 
@@ -3502,6 +3502,22 @@ async function ensureSchema() {
3502
3502
  } catch (e) {
3503
3503
  logCatchDebug("migration", e);
3504
3504
  }
3505
+ try {
3506
+ await client.execute({
3507
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
3508
+ args: []
3509
+ });
3510
+ } catch (e) {
3511
+ logCatchDebug("migration", e);
3512
+ }
3513
+ try {
3514
+ await client.execute({
3515
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
3516
+ args: []
3517
+ });
3518
+ } catch (e) {
3519
+ logCatchDebug("migration", e);
3520
+ }
3505
3521
  }
3506
3522
  async function disposeDatabase() {
3507
3523
  if (_walCheckpointTimer) {
@@ -4625,11 +4641,17 @@ var init_platform_procedures = __esm({
4625
4641
  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."
4626
4642
  },
4627
4643
  {
4628
- title: "Customer orchestration maturity \u2014 recommend, never trap",
4644
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
4629
4645
  domain: "workflow",
4630
4646
  priority: "p1",
4631
4647
  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."
4632
4648
  },
4649
+ {
4650
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
4651
+ domain: "identity",
4652
+ priority: "p0",
4653
+ 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."
4654
+ },
4633
4655
  {
4634
4656
  title: "Single dispatch path \u2014 create_task only",
4635
4657
  domain: "workflow",
@@ -4663,6 +4685,12 @@ var init_platform_procedures = __esm({
4663
4685
  priority: "p0",
4664
4686
  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."
4665
4687
  },
4688
+ {
4689
+ title: "Destructive operations \u2014 mandatory reviewer gate",
4690
+ domain: "security",
4691
+ priority: "p0",
4692
+ 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."
4693
+ },
4666
4694
  {
4667
4695
  title: "Customer patch triage \u2014 upstream bug vs customization",
4668
4696
  domain: "support",
@@ -4948,10 +4976,24 @@ function stableId(memoryId, type, content) {
4948
4976
  return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
4949
4977
  }
4950
4978
  function cleanText(text) {
4951
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4979
+ let cleaned = text.replace(
4980
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
4981
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
4982
+ );
4983
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
4984
+ return cleaned;
4952
4985
  }
4953
- function splitSentences(text) {
4954
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
4986
+ function splitSegments(text) {
4987
+ const cleaned = cleanText(text);
4988
+ 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);
4989
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
4990
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
4991
+ if (lines.length > 0) return lines;
4992
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
4993
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
4994
+ }
4995
+ }
4996
+ return segments;
4955
4997
  }
4956
4998
  function inferCardType(sentence, toolName) {
4957
4999
  const lower = sentence.toLowerCase();
@@ -4983,12 +5025,12 @@ function predicateFor(type) {
4983
5025
  }
4984
5026
  }
4985
5027
  function extractMemoryCards(row) {
4986
- const sentences = splitSentences(row.raw_text);
5028
+ const segments = splitSegments(row.raw_text);
4987
5029
  const cards = [];
4988
- for (const sentence of sentences) {
5030
+ for (const sentence of segments) {
4989
5031
  const type = inferCardType(sentence, row.tool_name);
4990
5032
  const subject = extractSubject(sentence, row.agent_id);
4991
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
5033
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
4992
5034
  cards.push({
4993
5035
  id: stableId(row.id, type, content),
4994
5036
  memory_id: row.id,
@@ -5084,13 +5126,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
5084
5126
  last_accessed: String(row.timestamp)
5085
5127
  }));
5086
5128
  }
5087
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
5129
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
5088
5130
  var init_memory_cards = __esm({
5089
5131
  "src/lib/memory-cards.ts"() {
5090
5132
  "use strict";
5091
5133
  init_database();
5092
- MAX_CARDS_PER_MEMORY = 6;
5093
- MAX_SENTENCE_CHARS = 360;
5134
+ MAX_CARDS_PER_MEMORY = 8;
5135
+ MAX_SEGMENT_CHARS = 500;
5136
+ MIN_SEGMENT_CHARS = 20;
5094
5137
  }
5095
5138
  });
5096
5139
 
@@ -7402,7 +7445,7 @@ async function hybridSearch(queryText, agentId, options) {
7402
7445
  try {
7403
7446
  const client = getClient();
7404
7447
  void client.execute({
7405
- sql: `UPDATE memories SET last_accessed = ?, retrieval_count = COALESCE(retrieval_count, 0) + 1 WHERE id IN (${placeholders})`,
7448
+ 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})`,
7406
7449
  args: [now, ...ids]
7407
7450
  }).catch(() => {
7408
7451
  });
@@ -8651,7 +8694,7 @@ var init_license = __esm({
8651
8694
  LICENSE_PATH = path15.join(EXE_AI_DIR, "license.key");
8652
8695
  CACHE_PATH = path15.join(EXE_AI_DIR, "license-cache.json");
8653
8696
  DEVICE_ID_PATH = path15.join(EXE_AI_DIR, "device-id");
8654
- API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
8697
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://cloud.askexe.com";
8655
8698
  }
8656
8699
  });
8657
8700
 
@@ -8704,6 +8747,18 @@ function extractRootExe(name) {
8704
8747
  const parts = name.split("-").filter(Boolean);
8705
8748
  return parts.length > 0 ? parts[parts.length - 1] : null;
8706
8749
  }
8750
+ function registerParentExe(sessionKey, parentExe, dispatchedBy) {
8751
+ if (!existsSync16(SESSION_CACHE)) {
8752
+ mkdirSync8(SESSION_CACHE, { recursive: true });
8753
+ }
8754
+ const rootExe = extractRootExe(parentExe) ?? parentExe;
8755
+ const filePath = path18.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`);
8756
+ writeFileSync7(filePath, JSON.stringify({
8757
+ parentExe: rootExe,
8758
+ dispatchedBy: dispatchedBy || rootExe,
8759
+ registeredAt: (/* @__PURE__ */ new Date()).toISOString()
8760
+ }));
8761
+ }
8707
8762
  function getParentExe(sessionKey) {
8708
8763
  try {
8709
8764
  const data = JSON.parse(readFileSync11(path18.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`), "utf8"));
@@ -8713,11 +8768,12 @@ function getParentExe(sessionKey) {
8713
8768
  }
8714
8769
  }
8715
8770
  function resolveExeSession() {
8771
+ if (process.env.EXE_SESSION_NAME) {
8772
+ const fromEnv = extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
8773
+ if (fromEnv) return fromEnv;
8774
+ }
8716
8775
  const mySession = getMySession();
8717
8776
  if (!mySession) {
8718
- if (process.env.EXE_SESSION_NAME) {
8719
- return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
8720
- }
8721
8777
  return null;
8722
8778
  }
8723
8779
  const fromSessionName = extractRootExe(mySession);
@@ -8732,6 +8788,10 @@ function resolveExeSession() {
8732
8788
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
8733
8789
  `
8734
8790
  );
8791
+ try {
8792
+ registerParentExe(key, fromSessionName);
8793
+ } catch {
8794
+ }
8735
8795
  candidate = fromSessionName;
8736
8796
  } else {
8737
8797
  candidate = fromCache;