@askexenow/exe-os 0.9.37 → 0.9.39

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 (73) hide show
  1. package/deploy/stack-manifests/v0.9.json +55 -0
  2. package/dist/bin/backfill-conversations.js +36 -9
  3. package/dist/bin/backfill-responses.js +36 -9
  4. package/dist/bin/backfill-vectors.js +36 -9
  5. package/dist/bin/cleanup-stale-review-tasks.js +37 -10
  6. package/dist/bin/cli.js +624 -204
  7. package/dist/bin/exe-agent.js +13 -5
  8. package/dist/bin/exe-assign.js +36 -9
  9. package/dist/bin/exe-boot.js +50 -20
  10. package/dist/bin/exe-call.js +134 -342
  11. package/dist/bin/exe-dispatch.js +36 -9
  12. package/dist/bin/exe-doctor.js +39 -12
  13. package/dist/bin/exe-export-behaviors.js +38 -11
  14. package/dist/bin/exe-forget.js +36 -9
  15. package/dist/bin/exe-gateway.js +64 -15
  16. package/dist/bin/exe-heartbeat.js +37 -10
  17. package/dist/bin/exe-kill.js +36 -9
  18. package/dist/bin/exe-launch-agent.js +287 -1081
  19. package/dist/bin/exe-new-employee.js +100 -14
  20. package/dist/bin/exe-pending-messages.js +36 -9
  21. package/dist/bin/exe-pending-notifications.js +36 -9
  22. package/dist/bin/exe-pending-reviews.js +36 -9
  23. package/dist/bin/exe-rename.js +1780 -204
  24. package/dist/bin/exe-review.js +36 -9
  25. package/dist/bin/exe-search.js +38 -11
  26. package/dist/bin/exe-session-cleanup.js +38 -11
  27. package/dist/bin/exe-start-codex.js +38 -11
  28. package/dist/bin/exe-start-opencode.js +38 -11
  29. package/dist/bin/exe-status.js +37 -10
  30. package/dist/bin/exe-team.js +36 -9
  31. package/dist/bin/git-sweep.js +36 -9
  32. package/dist/bin/graph-backfill.js +36 -9
  33. package/dist/bin/graph-export.js +36 -9
  34. package/dist/bin/install.js +70 -3
  35. package/dist/bin/intercom-check.js +38 -11
  36. package/dist/bin/scan-tasks.js +36 -9
  37. package/dist/bin/setup.js +20 -19
  38. package/dist/bin/shard-migrate.js +36 -9
  39. package/dist/bin/stack-update.js +308 -0
  40. package/dist/gateway/index.js +62 -13
  41. package/dist/hooks/bug-report-worker.js +40 -12
  42. package/dist/hooks/codex-stop-task-finalizer.js +38 -11
  43. package/dist/hooks/commit-complete.js +36 -9
  44. package/dist/hooks/error-recall.js +38 -11
  45. package/dist/hooks/ingest.js +38 -10
  46. package/dist/hooks/instructions-loaded.js +44 -12
  47. package/dist/hooks/notification.js +36 -9
  48. package/dist/hooks/post-compact.js +36 -9
  49. package/dist/hooks/post-tool-combined.js +39 -12
  50. package/dist/hooks/pre-compact.js +37 -10
  51. package/dist/hooks/pre-tool-use.js +38 -10
  52. package/dist/hooks/prompt-submit.js +43 -15
  53. package/dist/hooks/session-end.js +37 -10
  54. package/dist/hooks/session-start.js +49 -16
  55. package/dist/hooks/stop.js +37 -10
  56. package/dist/hooks/subagent-stop.js +36 -9
  57. package/dist/hooks/summary-worker.js +45 -18
  58. package/dist/index.js +60 -11
  59. package/dist/lib/consolidation.js +2 -1
  60. package/dist/lib/employee-templates.js +4 -3
  61. package/dist/lib/employees.js +2 -1
  62. package/dist/lib/exe-daemon.js +11229 -10537
  63. package/dist/lib/hybrid-search.js +38 -11
  64. package/dist/lib/identity.js +8 -3
  65. package/dist/lib/schedules.js +36 -9
  66. package/dist/lib/store.js +36 -9
  67. package/dist/mcp/server.js +6873 -6249
  68. package/dist/mcp/tools/create-task.js +10 -4
  69. package/dist/runtime/index.js +36 -9
  70. package/dist/tui/App.js +42 -13
  71. package/package.json +4 -1
  72. package/stack.release.json +31 -0
  73. package/stack.release.schema.json +31 -0
@@ -3272,7 +3272,7 @@ __export(shard_manager_exports, {
3272
3272
  shardExists: () => shardExists
3273
3273
  });
3274
3274
  import path7 from "path";
3275
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync } from "fs";
3275
+ import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
3276
3276
  import { createClient as createClient2 } from "@libsql/client";
3277
3277
  function initShardManager(encryptionKey) {
3278
3278
  _encryptionKey = encryptionKey;
@@ -3294,7 +3294,7 @@ function getShardClient(projectName) {
3294
3294
  if (!_encryptionKey) {
3295
3295
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3296
3296
  }
3297
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3297
+ const safeName = safeShardName(projectName);
3298
3298
  if (!safeName || safeName === "unknown") {
3299
3299
  throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3300
3300
  }
@@ -3316,9 +3316,12 @@ function getShardClient(projectName) {
3316
3316
  return client;
3317
3317
  }
3318
3318
  function shardExists(projectName) {
3319
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3319
+ const safeName = safeShardName(projectName);
3320
3320
  return existsSync7(path7.join(SHARDS_DIR, `${safeName}.db`));
3321
3321
  }
3322
+ function safeShardName(projectName) {
3323
+ return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3324
+ }
3322
3325
  function listShards() {
3323
3326
  if (!existsSync7(SHARDS_DIR)) return [];
3324
3327
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
@@ -3412,7 +3415,8 @@ async function ensureShardSchema(client) {
3412
3415
  "ALTER TABLE memories ADD COLUMN token_cost REAL",
3413
3416
  "ALTER TABLE memories ADD COLUMN audience TEXT",
3414
3417
  "ALTER TABLE memories ADD COLUMN language_type TEXT",
3415
- "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
3418
+ "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
3419
+ "ALTER TABLE memories ADD COLUMN deleted_at TEXT"
3416
3420
  ]) {
3417
3421
  try {
3418
3422
  await client.execute(col);
@@ -3508,9 +3512,32 @@ async function ensureShardSchema(client) {
3508
3512
  }
3509
3513
  }
3510
3514
  async function getReadyShardClient(projectName) {
3511
- const client = getShardClient(projectName);
3512
- await ensureShardSchema(client);
3513
- return client;
3515
+ const safeName = safeShardName(projectName);
3516
+ let client = getShardClient(projectName);
3517
+ try {
3518
+ await ensureShardSchema(client);
3519
+ return client;
3520
+ } catch (err) {
3521
+ const message = err instanceof Error ? err.message : String(err);
3522
+ if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
3523
+ client.close();
3524
+ _shards.delete(safeName);
3525
+ _shardLastAccess.delete(safeName);
3526
+ const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
3527
+ if (existsSync7(dbPath)) {
3528
+ const stat = statSync2(dbPath);
3529
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
3530
+ const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
3531
+ renameSync3(dbPath, archivedPath);
3532
+ process.stderr.write(
3533
+ `[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
3534
+ `
3535
+ );
3536
+ }
3537
+ client = getShardClient(projectName);
3538
+ await ensureShardSchema(client);
3539
+ return client;
3540
+ }
3514
3541
  }
3515
3542
  function evictLRU() {
3516
3543
  let oldest = null;
@@ -3731,7 +3758,7 @@ var init_platform_procedures = __esm({
3731
3758
  title: "MCP tools \u2014 wiki, documents, and content",
3732
3759
  domain: "tool-use",
3733
3760
  priority: "p1",
3734
- content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3761
+ content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3735
3762
  },
3736
3763
  {
3737
3764
  title: "MCP tools \u2014 system, operations, and admin",
@@ -3749,7 +3776,7 @@ var init_platform_procedures = __esm({
3749
3776
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3750
3777
  domain: "tool-use",
3751
3778
  priority: "p1",
3752
- content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3779
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3753
3780
  }
3754
3781
  ];
3755
3782
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -4713,7 +4740,7 @@ var init_agent_config = __esm({
4713
4740
  });
4714
4741
 
4715
4742
  // src/lib/intercom-queue.ts
4716
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, renameSync as renameSync3, existsSync as existsSync9, mkdirSync as mkdirSync3 } from "fs";
4743
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, renameSync as renameSync4, existsSync as existsSync9, mkdirSync as mkdirSync3 } from "fs";
4717
4744
  import path10 from "path";
4718
4745
  import os7 from "os";
4719
4746
  var QUEUE_PATH, TTL_MS, INTERCOM_LOG;
@@ -3261,7 +3261,7 @@ __export(shard_manager_exports, {
3261
3261
  shardExists: () => shardExists
3262
3262
  });
3263
3263
  import path7 from "path";
3264
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync } from "fs";
3264
+ import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
3265
3265
  import { createClient as createClient2 } from "@libsql/client";
3266
3266
  function initShardManager(encryptionKey) {
3267
3267
  _encryptionKey = encryptionKey;
@@ -3283,7 +3283,7 @@ function getShardClient(projectName) {
3283
3283
  if (!_encryptionKey) {
3284
3284
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3285
3285
  }
3286
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3286
+ const safeName = safeShardName(projectName);
3287
3287
  if (!safeName || safeName === "unknown") {
3288
3288
  throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3289
3289
  }
@@ -3305,9 +3305,12 @@ function getShardClient(projectName) {
3305
3305
  return client;
3306
3306
  }
3307
3307
  function shardExists(projectName) {
3308
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3308
+ const safeName = safeShardName(projectName);
3309
3309
  return existsSync7(path7.join(SHARDS_DIR, `${safeName}.db`));
3310
3310
  }
3311
+ function safeShardName(projectName) {
3312
+ return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3313
+ }
3311
3314
  function listShards() {
3312
3315
  if (!existsSync7(SHARDS_DIR)) return [];
3313
3316
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
@@ -3401,7 +3404,8 @@ async function ensureShardSchema(client) {
3401
3404
  "ALTER TABLE memories ADD COLUMN token_cost REAL",
3402
3405
  "ALTER TABLE memories ADD COLUMN audience TEXT",
3403
3406
  "ALTER TABLE memories ADD COLUMN language_type TEXT",
3404
- "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
3407
+ "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
3408
+ "ALTER TABLE memories ADD COLUMN deleted_at TEXT"
3405
3409
  ]) {
3406
3410
  try {
3407
3411
  await client.execute(col);
@@ -3497,9 +3501,32 @@ async function ensureShardSchema(client) {
3497
3501
  }
3498
3502
  }
3499
3503
  async function getReadyShardClient(projectName) {
3500
- const client = getShardClient(projectName);
3501
- await ensureShardSchema(client);
3502
- return client;
3504
+ const safeName = safeShardName(projectName);
3505
+ let client = getShardClient(projectName);
3506
+ try {
3507
+ await ensureShardSchema(client);
3508
+ return client;
3509
+ } catch (err) {
3510
+ const message = err instanceof Error ? err.message : String(err);
3511
+ if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
3512
+ client.close();
3513
+ _shards.delete(safeName);
3514
+ _shardLastAccess.delete(safeName);
3515
+ const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
3516
+ if (existsSync7(dbPath)) {
3517
+ const stat = statSync2(dbPath);
3518
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
3519
+ const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
3520
+ renameSync3(dbPath, archivedPath);
3521
+ process.stderr.write(
3522
+ `[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
3523
+ `
3524
+ );
3525
+ }
3526
+ client = getShardClient(projectName);
3527
+ await ensureShardSchema(client);
3528
+ return client;
3529
+ }
3503
3530
  }
3504
3531
  function evictLRU() {
3505
3532
  let oldest = null;
@@ -3720,7 +3747,7 @@ var init_platform_procedures = __esm({
3720
3747
  title: "MCP tools \u2014 wiki, documents, and content",
3721
3748
  domain: "tool-use",
3722
3749
  priority: "p1",
3723
- content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3750
+ content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3724
3751
  },
3725
3752
  {
3726
3753
  title: "MCP tools \u2014 system, operations, and admin",
@@ -3738,7 +3765,7 @@ var init_platform_procedures = __esm({
3738
3765
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3739
3766
  domain: "tool-use",
3740
3767
  priority: "p1",
3741
- content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3768
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3742
3769
  }
3743
3770
  ];
3744
3771
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -6884,7 +6884,7 @@ __export(shard_manager_exports, {
6884
6884
  shardExists: () => shardExists
6885
6885
  });
6886
6886
  import path19 from "path";
6887
- import { existsSync as existsSync16, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
6887
+ import { existsSync as existsSync16, mkdirSync as mkdirSync7, readdirSync as readdirSync4, renameSync as renameSync4, statSync as statSync2 } from "fs";
6888
6888
  import { createClient as createClient2 } from "@libsql/client";
6889
6889
  function initShardManager(encryptionKey) {
6890
6890
  _encryptionKey = encryptionKey;
@@ -6906,7 +6906,7 @@ function getShardClient(projectName2) {
6906
6906
  if (!_encryptionKey) {
6907
6907
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
6908
6908
  }
6909
- const safeName = projectName2.replace(/[^a-zA-Z0-9_-]/g, "_");
6909
+ const safeName = safeShardName(projectName2);
6910
6910
  if (!safeName || safeName === "unknown") {
6911
6911
  throw new Error(`Invalid project name for shard: "${projectName2}" (resolved to "${safeName}")`);
6912
6912
  }
@@ -6928,9 +6928,12 @@ function getShardClient(projectName2) {
6928
6928
  return client;
6929
6929
  }
6930
6930
  function shardExists(projectName2) {
6931
- const safeName = projectName2.replace(/[^a-zA-Z0-9_-]/g, "_");
6931
+ const safeName = safeShardName(projectName2);
6932
6932
  return existsSync16(path19.join(SHARDS_DIR, `${safeName}.db`));
6933
6933
  }
6934
+ function safeShardName(projectName2) {
6935
+ return projectName2.replace(/[^a-zA-Z0-9_-]/g, "_");
6936
+ }
6934
6937
  function listShards() {
6935
6938
  if (!existsSync16(SHARDS_DIR)) return [];
6936
6939
  return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
@@ -7024,7 +7027,8 @@ async function ensureShardSchema(client) {
7024
7027
  "ALTER TABLE memories ADD COLUMN token_cost REAL",
7025
7028
  "ALTER TABLE memories ADD COLUMN audience TEXT",
7026
7029
  "ALTER TABLE memories ADD COLUMN language_type TEXT",
7027
- "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
7030
+ "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
7031
+ "ALTER TABLE memories ADD COLUMN deleted_at TEXT"
7028
7032
  ]) {
7029
7033
  try {
7030
7034
  await client.execute(col);
@@ -7120,9 +7124,32 @@ async function ensureShardSchema(client) {
7120
7124
  }
7121
7125
  }
7122
7126
  async function getReadyShardClient(projectName2) {
7123
- const client = getShardClient(projectName2);
7124
- await ensureShardSchema(client);
7125
- return client;
7127
+ const safeName = safeShardName(projectName2);
7128
+ let client = getShardClient(projectName2);
7129
+ try {
7130
+ await ensureShardSchema(client);
7131
+ return client;
7132
+ } catch (err) {
7133
+ const message = err instanceof Error ? err.message : String(err);
7134
+ if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
7135
+ client.close();
7136
+ _shards.delete(safeName);
7137
+ _shardLastAccess.delete(safeName);
7138
+ const dbPath = path19.join(SHARDS_DIR, `${safeName}.db`);
7139
+ if (existsSync16(dbPath)) {
7140
+ const stat = statSync2(dbPath);
7141
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
7142
+ const archivedPath = path19.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
7143
+ renameSync4(dbPath, archivedPath);
7144
+ process.stderr.write(
7145
+ `[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
7146
+ `
7147
+ );
7148
+ }
7149
+ client = getShardClient(projectName2);
7150
+ await ensureShardSchema(client);
7151
+ return client;
7152
+ }
7126
7153
  }
7127
7154
  function evictLRU() {
7128
7155
  let oldest = null;
@@ -7343,7 +7370,7 @@ var init_platform_procedures = __esm({
7343
7370
  title: "MCP tools \u2014 wiki, documents, and content",
7344
7371
  domain: "tool-use",
7345
7372
  priority: "p1",
7346
- content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
7373
+ content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
7347
7374
  },
7348
7375
  {
7349
7376
  title: "MCP tools \u2014 system, operations, and admin",
@@ -7361,7 +7388,7 @@ var init_platform_procedures = __esm({
7361
7388
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
7362
7389
  domain: "tool-use",
7363
7390
  priority: "p1",
7364
- content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
7391
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
7365
7392
  }
7366
7393
  ];
7367
7394
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -2601,7 +2601,7 @@ __export(shard_manager_exports, {
2601
2601
  shardExists: () => shardExists
2602
2602
  });
2603
2603
  import path7 from "path";
2604
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync } from "fs";
2604
+ import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
2605
2605
  import { createClient as createClient2 } from "@libsql/client";
2606
2606
  function initShardManager(encryptionKey) {
2607
2607
  _encryptionKey = encryptionKey;
@@ -2623,7 +2623,7 @@ function getShardClient(projectName) {
2623
2623
  if (!_encryptionKey) {
2624
2624
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
2625
2625
  }
2626
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2626
+ const safeName = safeShardName(projectName);
2627
2627
  if (!safeName || safeName === "unknown") {
2628
2628
  throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
2629
2629
  }
@@ -2645,9 +2645,12 @@ function getShardClient(projectName) {
2645
2645
  return client;
2646
2646
  }
2647
2647
  function shardExists(projectName) {
2648
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2648
+ const safeName = safeShardName(projectName);
2649
2649
  return existsSync7(path7.join(SHARDS_DIR, `${safeName}.db`));
2650
2650
  }
2651
+ function safeShardName(projectName) {
2652
+ return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
2653
+ }
2651
2654
  function listShards() {
2652
2655
  if (!existsSync7(SHARDS_DIR)) return [];
2653
2656
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
@@ -2741,7 +2744,8 @@ async function ensureShardSchema(client) {
2741
2744
  "ALTER TABLE memories ADD COLUMN token_cost REAL",
2742
2745
  "ALTER TABLE memories ADD COLUMN audience TEXT",
2743
2746
  "ALTER TABLE memories ADD COLUMN language_type TEXT",
2744
- "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
2747
+ "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
2748
+ "ALTER TABLE memories ADD COLUMN deleted_at TEXT"
2745
2749
  ]) {
2746
2750
  try {
2747
2751
  await client.execute(col);
@@ -2837,9 +2841,32 @@ async function ensureShardSchema(client) {
2837
2841
  }
2838
2842
  }
2839
2843
  async function getReadyShardClient(projectName) {
2840
- const client = getShardClient(projectName);
2841
- await ensureShardSchema(client);
2842
- return client;
2844
+ const safeName = safeShardName(projectName);
2845
+ let client = getShardClient(projectName);
2846
+ try {
2847
+ await ensureShardSchema(client);
2848
+ return client;
2849
+ } catch (err) {
2850
+ const message = err instanceof Error ? err.message : String(err);
2851
+ if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
2852
+ client.close();
2853
+ _shards.delete(safeName);
2854
+ _shardLastAccess.delete(safeName);
2855
+ const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
2856
+ if (existsSync7(dbPath)) {
2857
+ const stat = statSync2(dbPath);
2858
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
2859
+ const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
2860
+ renameSync3(dbPath, archivedPath);
2861
+ process.stderr.write(
2862
+ `[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
2863
+ `
2864
+ );
2865
+ }
2866
+ client = getShardClient(projectName);
2867
+ await ensureShardSchema(client);
2868
+ return client;
2869
+ }
2843
2870
  }
2844
2871
  function evictLRU() {
2845
2872
  let oldest = null;
@@ -3060,7 +3087,7 @@ var init_platform_procedures = __esm({
3060
3087
  title: "MCP tools \u2014 wiki, documents, and content",
3061
3088
  domain: "tool-use",
3062
3089
  priority: "p1",
3063
- content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3090
+ content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3064
3091
  },
3065
3092
  {
3066
3093
  title: "MCP tools \u2014 system, operations, and admin",
@@ -3078,7 +3105,7 @@ var init_platform_procedures = __esm({
3078
3105
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3079
3106
  domain: "tool-use",
3080
3107
  priority: "p1",
3081
- content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3108
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3082
3109
  }
3083
3110
  ];
3084
3111
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3250,7 +3250,7 @@ __export(shard_manager_exports, {
3250
3250
  shardExists: () => shardExists
3251
3251
  });
3252
3252
  import path7 from "path";
3253
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync } from "fs";
3253
+ import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
3254
3254
  import { createClient as createClient2 } from "@libsql/client";
3255
3255
  function initShardManager(encryptionKey) {
3256
3256
  _encryptionKey = encryptionKey;
@@ -3272,7 +3272,7 @@ function getShardClient(projectName) {
3272
3272
  if (!_encryptionKey) {
3273
3273
  throw new Error("Shard manager not initialized. Call initShardManager() first.");
3274
3274
  }
3275
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3275
+ const safeName = safeShardName(projectName);
3276
3276
  if (!safeName || safeName === "unknown") {
3277
3277
  throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
3278
3278
  }
@@ -3294,9 +3294,12 @@ function getShardClient(projectName) {
3294
3294
  return client;
3295
3295
  }
3296
3296
  function shardExists(projectName) {
3297
- const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3297
+ const safeName = safeShardName(projectName);
3298
3298
  return existsSync7(path7.join(SHARDS_DIR, `${safeName}.db`));
3299
3299
  }
3300
+ function safeShardName(projectName) {
3301
+ return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
3302
+ }
3300
3303
  function listShards() {
3301
3304
  if (!existsSync7(SHARDS_DIR)) return [];
3302
3305
  return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
@@ -3390,7 +3393,8 @@ async function ensureShardSchema(client) {
3390
3393
  "ALTER TABLE memories ADD COLUMN token_cost REAL",
3391
3394
  "ALTER TABLE memories ADD COLUMN audience TEXT",
3392
3395
  "ALTER TABLE memories ADD COLUMN language_type TEXT",
3393
- "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
3396
+ "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
3397
+ "ALTER TABLE memories ADD COLUMN deleted_at TEXT"
3394
3398
  ]) {
3395
3399
  try {
3396
3400
  await client.execute(col);
@@ -3486,9 +3490,32 @@ async function ensureShardSchema(client) {
3486
3490
  }
3487
3491
  }
3488
3492
  async function getReadyShardClient(projectName) {
3489
- const client = getShardClient(projectName);
3490
- await ensureShardSchema(client);
3491
- return client;
3493
+ const safeName = safeShardName(projectName);
3494
+ let client = getShardClient(projectName);
3495
+ try {
3496
+ await ensureShardSchema(client);
3497
+ return client;
3498
+ } catch (err) {
3499
+ const message = err instanceof Error ? err.message : String(err);
3500
+ if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
3501
+ client.close();
3502
+ _shards.delete(safeName);
3503
+ _shardLastAccess.delete(safeName);
3504
+ const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
3505
+ if (existsSync7(dbPath)) {
3506
+ const stat = statSync2(dbPath);
3507
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
3508
+ const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
3509
+ renameSync3(dbPath, archivedPath);
3510
+ process.stderr.write(
3511
+ `[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
3512
+ `
3513
+ );
3514
+ }
3515
+ client = getShardClient(projectName);
3516
+ await ensureShardSchema(client);
3517
+ return client;
3518
+ }
3492
3519
  }
3493
3520
  function evictLRU() {
3494
3521
  let oldest = null;
@@ -3709,7 +3736,7 @@ var init_platform_procedures = __esm({
3709
3736
  title: "MCP tools \u2014 wiki, documents, and content",
3710
3737
  domain: "tool-use",
3711
3738
  priority: "p1",
3712
- content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3739
+ content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3713
3740
  },
3714
3741
  {
3715
3742
  title: "MCP tools \u2014 system, operations, and admin",
@@ -3727,7 +3754,7 @@ var init_platform_procedures = __esm({
3727
3754
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3728
3755
  domain: "tool-use",
3729
3756
  priority: "p1",
3730
- content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3757
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3731
3758
  }
3732
3759
  ];
3733
3760
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -368,7 +368,8 @@ function isMultiInstance(agentName, employees) {
368
368
  return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
369
369
  }
370
370
  function addEmployee(employees, employee) {
371
- const normalized = { ...employee, name: employee.name.toLowerCase() };
371
+ const { systemPrompt: _legacyPrompt, ...rest } = employee;
372
+ const normalized = { ...rest, name: employee.name.toLowerCase() };
372
373
  if (employees.some((e) => e.name.toLowerCase() === normalized.name)) {
373
374
  throw new Error(`Employee '${normalized.name}' already exists`);
374
375
  }
@@ -685,6 +686,60 @@ name: ${skillName}
685
686
  await writeFile3(destPath, content);
686
687
  return true;
687
688
  }
689
+ function readJsonFile(filePath) {
690
+ try {
691
+ return JSON.parse(readFileSync5(filePath, "utf-8"));
692
+ } catch {
693
+ return null;
694
+ }
695
+ }
696
+ function findAncestorMcpJsons(startDir, homeDir) {
697
+ const files = [];
698
+ let dir = path6.resolve(startDir);
699
+ const root = path6.parse(dir).root;
700
+ const stop = path6.resolve(homeDir);
701
+ while (dir !== root) {
702
+ const candidate = path6.join(dir, ".mcp.json");
703
+ if (existsSync7(candidate)) files.push(candidate);
704
+ if (dir === stop) break;
705
+ dir = path6.dirname(dir);
706
+ }
707
+ return files;
708
+ }
709
+ function pathApplies(projectPath, cwd) {
710
+ const project = path6.resolve(projectPath);
711
+ const current = path6.resolve(cwd);
712
+ return current === project || current.startsWith(project + path6.sep);
713
+ }
714
+ function detectMcpNameCollisions(homeDir = os5.homedir(), cwd = process.cwd()) {
715
+ const claudeJsonPath = path6.join(homeDir, ".claude.json");
716
+ if (!existsSync7(claudeJsonPath)) return [];
717
+ const claudeJson = readJsonFile(claudeJsonPath);
718
+ if (!claudeJson?.projects) return [];
719
+ const collisions = [];
720
+ const mcpJsons = findAncestorMcpJsons(cwd, homeDir);
721
+ if (mcpJsons.length === 0) return [];
722
+ for (const [projectPath, projectConfig] of Object.entries(claudeJson.projects)) {
723
+ if (!pathApplies(projectPath, cwd)) continue;
724
+ const projectServerNames = new Set(Object.keys(projectConfig.mcpServers ?? {}));
725
+ if (projectServerNames.size === 0) continue;
726
+ const enabled = new Set(projectConfig.enabledMcpjsonServers ?? []);
727
+ for (const mcpJsonPath of mcpJsons) {
728
+ const mcpJson = readJsonFile(mcpJsonPath);
729
+ const mcpServerNames = Object.keys(mcpJson?.mcpServers ?? {});
730
+ for (const serverName of mcpServerNames) {
731
+ if (!projectServerNames.has(serverName)) continue;
732
+ collisions.push({
733
+ mcpJsonPath,
734
+ projectPath,
735
+ serverName,
736
+ disabledInMcpJson: !enabled.has(serverName)
737
+ });
738
+ }
739
+ }
740
+ }
741
+ return collisions;
742
+ }
688
743
  async function registerMcpServer(packageRoot, homeDir = os5.homedir()) {
689
744
  const claudeJsonPath = path6.join(homeDir, ".claude.json");
690
745
  let claudeJson = {};
@@ -713,12 +768,26 @@ async function registerMcpServer(packageRoot, homeDir = os5.homedir()) {
713
768
  if (osMatches) {
714
769
  await cleanSettingsJsonMcp(path6.join(homeDir, ".claude", "settings.json"));
715
770
  await migratePermissionsToExeOs(path6.join(homeDir, ".claude", "settings.json"));
771
+ const collisions2 = detectMcpNameCollisions(homeDir, packageRoot).filter((c) => c.serverName === MCP_PRIMARY_KEY || c.serverName === MCP_LEGACY_KEY);
772
+ for (const c of collisions2) {
773
+ process.stderr.write(
774
+ `exe-os: WARNING Claude Code MCP name collision: ${c.serverName} exists in ${c.mcpJsonPath} and ~/.claude.json project ${c.projectPath}. Remove or rename the .mcp.json entry if tools do not surface.
775
+ `
776
+ );
777
+ }
716
778
  return false;
717
779
  }
718
780
  claudeJson.mcpServers[MCP_PRIMARY_KEY] = newEntry;
719
781
  await writeFile3(claudeJsonPath, JSON.stringify(claudeJson, null, 2) + "\n");
720
782
  await cleanSettingsJsonMcp(path6.join(homeDir, ".claude", "settings.json"));
721
783
  await migratePermissionsToExeOs(path6.join(homeDir, ".claude", "settings.json"));
784
+ const collisions = detectMcpNameCollisions(homeDir, packageRoot).filter((c) => c.serverName === MCP_PRIMARY_KEY || c.serverName === MCP_LEGACY_KEY);
785
+ for (const c of collisions) {
786
+ process.stderr.write(
787
+ `exe-os: WARNING Claude Code MCP name collision: ${c.serverName} exists in ${c.mcpJsonPath} and ~/.claude.json project ${c.projectPath}. Remove or rename the .mcp.json entry if tools do not surface.
788
+ `
789
+ );
790
+ }
722
791
  return true;
723
792
  }
724
793
  async function cleanSettingsJsonMcp(settingsPath) {
@@ -1020,8 +1089,6 @@ async function mergeHooks(packageRoot, homeDir = os5.homedir()) {
1020
1089
  "purge_document",
1021
1090
  "rerank_documents",
1022
1091
  "set_document_importance",
1023
- "create_wiki_page",
1024
- "update_wiki_page",
1025
1092
  "get_wiki_page",
1026
1093
  "list_wiki_pages",
1027
1094
  // System