@askexenow/exe-os 0.9.112 → 0.9.114

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 (96) hide show
  1. package/README.md +9 -7
  2. package/dist/bin/agentic-ontology-backfill.js +78 -23
  3. package/dist/bin/agentic-reflection-backfill.js +53 -13
  4. package/dist/bin/agentic-semantic-label.js +53 -13
  5. package/dist/bin/backfill-conversations.js +77 -22
  6. package/dist/bin/backfill-responses.js +78 -23
  7. package/dist/bin/backfill-vectors.js +53 -13
  8. package/dist/bin/bulk-sync-postgres.js +78 -23
  9. package/dist/bin/cleanup-stale-review-tasks.js +98 -26
  10. package/dist/bin/cli.js +388 -97
  11. package/dist/bin/exe-agent-config.js +7 -1
  12. package/dist/bin/exe-agent.js +55 -2
  13. package/dist/bin/exe-assign.js +78 -23
  14. package/dist/bin/exe-boot.js +524 -161
  15. package/dist/bin/exe-call.js +53 -4
  16. package/dist/bin/exe-cloud.js +127 -26
  17. package/dist/bin/exe-dispatch.js +402 -39
  18. package/dist/bin/exe-doctor.js +76 -21
  19. package/dist/bin/exe-export-behaviors.js +77 -22
  20. package/dist/bin/exe-forget.js +77 -22
  21. package/dist/bin/exe-gateway.js +161 -38
  22. package/dist/bin/exe-heartbeat.js +98 -26
  23. package/dist/bin/exe-kill.js +77 -22
  24. package/dist/bin/exe-launch-agent.js +173 -29
  25. package/dist/bin/exe-new-employee.js +183 -7
  26. package/dist/bin/exe-pending-messages.js +98 -26
  27. package/dist/bin/exe-pending-notifications.js +98 -26
  28. package/dist/bin/exe-pending-reviews.js +98 -26
  29. package/dist/bin/exe-rename.js +77 -22
  30. package/dist/bin/exe-review.js +77 -22
  31. package/dist/bin/exe-search.js +77 -22
  32. package/dist/bin/exe-session-cleanup.js +523 -160
  33. package/dist/bin/exe-settings.js +10 -4
  34. package/dist/bin/exe-start-codex.js +554 -255
  35. package/dist/bin/exe-start-opencode.js +564 -175
  36. package/dist/bin/exe-status.js +98 -26
  37. package/dist/bin/exe-support.js +1 -1
  38. package/dist/bin/exe-team.js +77 -22
  39. package/dist/bin/git-sweep.js +402 -39
  40. package/dist/bin/graph-backfill.js +78 -23
  41. package/dist/bin/graph-export.js +77 -22
  42. package/dist/bin/install.js +70 -4
  43. package/dist/bin/intercom-check.js +523 -160
  44. package/dist/bin/pre-publish.js +13 -1
  45. package/dist/bin/scan-tasks.js +402 -39
  46. package/dist/bin/setup.js +151 -24
  47. package/dist/bin/shard-migrate.js +78 -23
  48. package/dist/bin/stack-update.js +1 -1
  49. package/dist/bin/update.js +3 -3
  50. package/dist/gateway/index.js +161 -38
  51. package/dist/hooks/bug-report-worker.js +161 -38
  52. package/dist/hooks/codex-stop-task-finalizer.js +542 -150
  53. package/dist/hooks/commit-complete.js +402 -39
  54. package/dist/hooks/error-recall.js +77 -22
  55. package/dist/hooks/ingest.js +4592 -251
  56. package/dist/hooks/instructions-loaded.js +77 -22
  57. package/dist/hooks/notification.js +77 -22
  58. package/dist/hooks/post-compact.js +98 -26
  59. package/dist/hooks/post-tool-combined.js +98 -26
  60. package/dist/hooks/pre-compact.js +482 -119
  61. package/dist/hooks/pre-tool-use.js +148 -26
  62. package/dist/hooks/prompt-submit.js +162 -39
  63. package/dist/hooks/session-end.js +484 -124
  64. package/dist/hooks/session-start.js +135 -27
  65. package/dist/hooks/stop.js +97 -25
  66. package/dist/hooks/subagent-stop.js +98 -26
  67. package/dist/hooks/summary-worker.js +107 -18
  68. package/dist/index.js +188 -38
  69. package/dist/lib/agent-config.js +24 -1
  70. package/dist/lib/cloud-sync.js +72 -12
  71. package/dist/lib/consolidation.js +25 -2
  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 +24 -1
  77. package/dist/lib/exe-daemon.js +441 -58
  78. package/dist/lib/hybrid-search.js +77 -22
  79. package/dist/lib/keychain.js +24 -12
  80. package/dist/lib/license.js +3 -3
  81. package/dist/lib/messaging.js +21 -4
  82. package/dist/lib/schedules.js +53 -13
  83. package/dist/lib/skill-learning.js +466 -70
  84. package/dist/lib/status-brief.js +14 -1
  85. package/dist/lib/store.js +78 -23
  86. package/dist/lib/tasks.js +403 -95
  87. package/dist/lib/tmux-routing.js +326 -18
  88. package/dist/mcp/server.js +213 -45
  89. package/dist/mcp/tools/create-task.js +85 -17
  90. package/dist/mcp/tools/deactivate-behavior.js +33 -24
  91. package/dist/mcp/tools/list-tasks.js +21 -4
  92. package/dist/mcp/tools/send-message.js +21 -4
  93. package/dist/mcp/tools/update-task.js +400 -95
  94. package/dist/runtime/index.js +506 -116
  95. package/dist/tui/App.js +268 -69
  96. package/package.json +1 -1
package/dist/bin/cli.js CHANGED
@@ -368,7 +368,9 @@ __export(agent_config_exports, {
368
368
  clearAgentRuntime: () => clearAgentRuntime,
369
369
  getAgentRuntime: () => getAgentRuntime,
370
370
  loadAgentConfig: () => loadAgentConfig,
371
+ normalizeCcModelName: () => normalizeCcModelName,
371
372
  saveAgentConfig: () => saveAgentConfig,
373
+ setAgentMcps: () => setAgentMcps,
372
374
  setAgentRuntime: () => setAgentRuntime
373
375
  });
374
376
  import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync3 } from "fs";
@@ -395,7 +397,14 @@ function getAgentRuntime(agentId) {
395
397
  if (orgDefault) return orgDefault;
396
398
  return { runtime: DEFAULT_RUNTIME, model: DEFAULT_MODELS[DEFAULT_RUNTIME] };
397
399
  }
398
- function setAgentRuntime(agentId, runtime, model, reasoning_effort) {
400
+ function normalizeCcModelName(model) {
401
+ let ccModel = model.replace(/(\d+)\.(\d+)/g, "$1-$2");
402
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
403
+ ccModel += "[1m]";
404
+ }
405
+ return ccModel;
406
+ }
407
+ function setAgentRuntime(agentId, runtime, model, reasoning_effort, mcps) {
399
408
  const knownModels = KNOWN_RUNTIMES[runtime];
400
409
  if (!knownModels) {
401
410
  return {
@@ -410,12 +419,26 @@ function setAgentRuntime(agentId, runtime, model, reasoning_effort) {
410
419
  };
411
420
  }
412
421
  const config = loadAgentConfig();
422
+ const existing = config[agentId];
413
423
  const entry = { runtime, model };
414
424
  if (reasoning_effort) entry.reasoning_effort = reasoning_effort;
425
+ if (mcps !== void 0) {
426
+ entry.mcps = mcps.includes("exe-os") ? mcps : ["exe-os", ...mcps];
427
+ } else if (existing?.mcps) {
428
+ entry.mcps = existing.mcps;
429
+ }
415
430
  config[agentId] = entry;
416
431
  saveAgentConfig(config);
417
432
  return { ok: true };
418
433
  }
434
+ function setAgentMcps(agentId, mcps) {
435
+ const config = loadAgentConfig();
436
+ const existing = config[agentId] ?? getAgentRuntime(agentId);
437
+ existing.mcps = mcps.includes("exe-os") ? mcps : ["exe-os", ...mcps];
438
+ config[agentId] = existing;
439
+ saveAgentConfig(config);
440
+ return { ok: true };
441
+ }
419
442
  function clearAgentRuntime(agentId) {
420
443
  const config = loadAgentConfig();
421
444
  delete config[agentId];
@@ -842,6 +865,16 @@ import { chmodSync as chmodSync2, existsSync as existsSync7, mkdirSync as mkdirS
842
865
  import { randomBytes } from "crypto";
843
866
  import path6 from "path";
844
867
  import os5 from "os";
868
+ function resolveDefaultAgentId() {
869
+ if (process.env.AGENT_ID && process.env.AGENT_ID !== "default") return process.env.AGENT_ID;
870
+ try {
871
+ const { loadEmployeesSync: loadEmployeesSync2 } = (init_employees(), __toCommonJS(employees_exports));
872
+ const coo = loadEmployeesSync2().find((e) => e.role === "COO");
873
+ if (coo) return coo.name;
874
+ } catch {
875
+ }
876
+ return "exe";
877
+ }
845
878
  function mcpHttpPort() {
846
879
  return process.env.EXE_MCP_PORT || DEFAULT_MCP_HTTP_PORT;
847
880
  }
@@ -871,11 +904,14 @@ function readOrCreateDaemonToken(homeDir = os5.homedir()) {
871
904
  function buildMcpHttpHeaders(homeDir = os5.homedir(), opts = {}) {
872
905
  const agentId = opts.useShellPlaceholders ? "${AGENT_ID:-exe}" : opts.agentId ?? DEFAULT_MCP_HTTP_AGENT_ID;
873
906
  const agentRole = opts.useShellPlaceholders ? "${AGENT_ROLE:-COO}" : opts.agentRole ?? DEFAULT_MCP_HTTP_AGENT_ROLE;
874
- return {
907
+ const sessionName = opts.useShellPlaceholders ? "" : process.env.EXE_SESSION_NAME ?? "";
908
+ const headers = {
875
909
  Authorization: `Bearer ${readOrCreateDaemonToken(homeDir)}`,
876
910
  "X-Agent-Id": agentId,
877
911
  "X-Agent-Role": agentRole
878
912
  };
913
+ if (sessionName) headers["X-Exe-Session"] = sessionName;
914
+ return headers;
879
915
  }
880
916
  function buildClaudeHttpMcpEntry(homeDir = os5.homedir()) {
881
917
  return {
@@ -889,12 +925,15 @@ var init_mcp_http_config = __esm({
889
925
  "src/adapters/mcp-http-config.ts"() {
890
926
  "use strict";
891
927
  DEFAULT_MCP_HTTP_PORT = "48739";
892
- DEFAULT_MCP_HTTP_AGENT_ID = "exe";
928
+ DEFAULT_MCP_HTTP_AGENT_ID = resolveDefaultAgentId();
893
929
  DEFAULT_MCP_HTTP_AGENT_ROLE = "COO";
894
930
  }
895
931
  });
896
932
 
897
933
  // src/adapters/runtime-hook-manifest.ts
934
+ function isLegacyHomeDirHookCommand(command) {
935
+ return LEGACY_HOME_DIR_HOOK_PATTERNS.some((pattern) => command.includes(pattern));
936
+ }
898
937
  function commandHasAnyMarker(command, markers) {
899
938
  return markers.some((marker) => command.includes(marker));
900
939
  }
@@ -904,7 +943,7 @@ function isLegacySplitPostToolCommand(command) {
904
943
  function textHasLegacySplitPostToolHook(text) {
905
944
  return [EXE_HOOK_FILES.ingest, EXE_HOOK_FILES.errorRecall, EXE_HOOK_FILES.ingestWorker].some((file) => text.includes(file));
906
945
  }
907
- var EXE_HOOK_FILES, EXE_HOOKS, EXE_HOOK_MANIFEST, LEGACY_SPLIT_POST_TOOL_HOOK_MARKERS;
946
+ var EXE_HOOK_FILES, EXE_HOOKS, EXE_HOOK_MANIFEST, LEGACY_SPLIT_POST_TOOL_HOOK_MARKERS, LEGACY_HOME_DIR_HOOK_PATTERNS;
908
947
  var init_runtime_hook_manifest = __esm({
909
948
  "src/adapters/runtime-hook-manifest.ts"() {
910
949
  "use strict";
@@ -1043,6 +1082,14 @@ var init_runtime_hook_manifest = __esm({
1043
1082
  "dist/hooks/error-recall.js",
1044
1083
  "dist/hooks/ingest-worker.js"
1045
1084
  ];
1085
+ LEGACY_HOME_DIR_HOOK_PATTERNS = [
1086
+ ".exe-os/hooks/",
1087
+ // Old hook storage path (pre-npm-package era)
1088
+ "log-prefix.js",
1089
+ // Removed hook from early versions
1090
+ "approval-bridge.log"
1091
+ // Removed log redirect from early versions
1092
+ ];
1046
1093
  }
1047
1094
  });
1048
1095
 
@@ -1522,6 +1569,14 @@ async function mergeHooks(packageRoot, homeDir = os6.homedir()) {
1522
1569
  ];
1523
1570
  let added = 0;
1524
1571
  let skipped = 0;
1572
+ for (const eventKey of Object.keys(settings.hooks)) {
1573
+ const groups = settings.hooks[eventKey];
1574
+ if (!Array.isArray(groups)) continue;
1575
+ settings.hooks[eventKey] = groups.map((g) => ({
1576
+ ...g,
1577
+ hooks: g.hooks.filter((h) => !isLegacyHomeDirHookCommand(h.command))
1578
+ })).filter((g) => g.hooks.length > 0);
1579
+ }
1525
1580
  const postToolGroups = settings.hooks["PostToolUse"];
1526
1581
  if (Array.isArray(postToolGroups)) {
1527
1582
  settings.hooks["PostToolUse"] = postToolGroups.map((g) => ({
@@ -2508,7 +2563,7 @@ __export(keychain_exports, {
2508
2563
  importMnemonic: () => importMnemonic,
2509
2564
  setMasterKey: () => setMasterKey
2510
2565
  });
2511
- import { readFile as readFile4, writeFile as writeFile4, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
2566
+ import { readFile as readFile4, writeFile as writeFile4, unlink, mkdir as mkdir4, chmod as chmod2, rename, copyFile } from "fs/promises";
2512
2567
  import { existsSync as existsSync10, statSync } from "fs";
2513
2568
  import { execSync as execSync3 } from "child_process";
2514
2569
  import path9 from "path";
@@ -2543,12 +2598,14 @@ function linuxSecretAvailable() {
2543
2598
  function isRootOnlyTrustedServerKeyFile(keyPath) {
2544
2599
  if (process.platform !== "linux") return false;
2545
2600
  try {
2546
- const uid = typeof os8.userInfo().uid === "number" ? os8.userInfo().uid : -1;
2547
2601
  const st = statSync(keyPath);
2548
2602
  if (!st.isFile() || (st.mode & 63) !== 0) return false;
2603
+ const uid = typeof os8.userInfo().uid === "number" ? os8.userInfo().uid : -1;
2549
2604
  if (uid === 0) return true;
2550
2605
  const exeOsDir = process.env.EXE_OS_DIR;
2551
- return Boolean(exeOsDir && path9.resolve(keyPath).startsWith(path9.resolve(exeOsDir) + path9.sep));
2606
+ if (exeOsDir && path9.resolve(keyPath).startsWith(path9.resolve(exeOsDir) + path9.sep)) return true;
2607
+ if (!linuxSecretAvailable()) return true;
2608
+ return false;
2552
2609
  } catch {
2553
2610
  return false;
2554
2611
  }
@@ -2698,15 +2755,25 @@ async function writeMachineBoundFileFallback(b64) {
2698
2755
  await mkdir4(dir, { recursive: true });
2699
2756
  const keyPath = getKeyPath();
2700
2757
  const machineKey = deriveMachineKey();
2701
- if (machineKey) {
2702
- const encrypted = encryptWithMachineKey(b64, machineKey);
2703
- await writeFile4(keyPath, encrypted + "\n", "utf-8");
2704
- await chmod2(keyPath, 384);
2705
- return "encrypted";
2758
+ const content = machineKey ? encryptWithMachineKey(b64, machineKey) + "\n" : b64 + "\n";
2759
+ const result = machineKey ? "encrypted" : "plaintext";
2760
+ const tmpPath = keyPath + ".tmp";
2761
+ try {
2762
+ if (existsSync10(keyPath)) {
2763
+ await copyFile(keyPath, keyPath + ".bak").catch(() => {
2764
+ });
2765
+ }
2766
+ await writeFile4(tmpPath, content, "utf-8");
2767
+ await chmod2(tmpPath, 384);
2768
+ await rename(tmpPath, keyPath);
2769
+ } catch (err) {
2770
+ try {
2771
+ await unlink(tmpPath);
2772
+ } catch {
2773
+ }
2774
+ throw err;
2706
2775
  }
2707
- await writeFile4(keyPath, b64 + "\n", "utf-8");
2708
- await chmod2(keyPath, 384);
2709
- return "plaintext";
2776
+ return result;
2710
2777
  }
2711
2778
  async function getMasterKey() {
2712
2779
  let nativeValue = macKeychainGet() ?? linuxSecretGet();
@@ -5915,6 +5982,22 @@ async function ensureSchema() {
5915
5982
  } catch (e) {
5916
5983
  logCatchDebug("migration", e);
5917
5984
  }
5985
+ try {
5986
+ await client.execute({
5987
+ sql: `ALTER TABLE memories ADD COLUMN visibility TEXT DEFAULT 'private'`,
5988
+ args: []
5989
+ });
5990
+ } catch (e) {
5991
+ logCatchDebug("migration", e);
5992
+ }
5993
+ try {
5994
+ await client.execute({
5995
+ sql: `ALTER TABLE memories ADD COLUMN strength REAL DEFAULT 1.0`,
5996
+ args: []
5997
+ });
5998
+ } catch (e) {
5999
+ logCatchDebug("migration", e);
6000
+ }
5918
6001
  }
5919
6002
  async function disposeDatabase() {
5920
6003
  if (_walCheckpointTimer) {
@@ -6460,7 +6543,7 @@ async function assertVpsLicense(opts) {
6460
6543
  }
6461
6544
  if (!transientFailure) {
6462
6545
  throw new Error(
6463
- "License validation failed: unknown backend state. Restore network connectivity to https://askexe.com/cloud and retry."
6546
+ "License validation failed: unknown backend state. Restore network connectivity to https://cloud.askexe.com and retry."
6464
6547
  );
6465
6548
  }
6466
6549
  const fresh = await getCachedLicense();
@@ -6497,7 +6580,7 @@ async function assertVpsLicense(opts) {
6497
6580
  } catch {
6498
6581
  }
6499
6582
  throw new Error(
6500
- `License validation unreachable for more than ${graceDays} days. Restore network connectivity to https://askexe.com/cloud and retry. This VPS image refuses to boot after the offline grace window.`
6583
+ `License validation unreachable for more than ${graceDays} days. Restore network connectivity to https://cloud.askexe.com and retry. This VPS image refuses to boot after the offline grace window.`
6501
6584
  );
6502
6585
  }
6503
6586
  function startLicenseRevalidation(intervalMs = 36e5) {
@@ -6529,7 +6612,7 @@ var init_license = __esm({
6529
6612
  LICENSE_PATH = path13.join(EXE_AI_DIR, "license.key");
6530
6613
  CACHE_PATH = path13.join(EXE_AI_DIR, "license-cache.json");
6531
6614
  DEVICE_ID_PATH = path13.join(EXE_AI_DIR, "device-id");
6532
- API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
6615
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://cloud.askexe.com";
6533
6616
  RETRY_DELAY_MS = 500;
6534
6617
  LICENSE_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
6535
6618
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeHztAMOpR/ZMh+rWuOASjEZ54CGY
@@ -6936,6 +7019,7 @@ __export(cloud_sync_exports, {
6936
7019
  markCloudReuploadRequired: () => markCloudReuploadRequired,
6937
7020
  mergeConfig: () => mergeConfig,
6938
7021
  mergeRosterFromRemote: () => mergeRosterFromRemote,
7022
+ migrateEndpoint: () => migrateEndpoint,
6939
7023
  pushToPostgres: () => pushToPostgres,
6940
7024
  recordRosterDeletion: () => recordRosterDeletion
6941
7025
  });
@@ -7106,6 +7190,15 @@ async function fetchWithRetry(url, init) {
7106
7190
  }
7107
7191
  throw lastError;
7108
7192
  }
7193
+ function migrateEndpoint(endpoint) {
7194
+ if (endpoint === "https://askexe.com/cloud" || endpoint === "https://askexe.com/cloud/") {
7195
+ process.stderr.write(
7196
+ "[cloud-sync] Auto-migrating endpoint from askexe.com/cloud to cloud.askexe.com (bypasses Cloudflare WAF for datacenter IPs)\n"
7197
+ );
7198
+ return "https://cloud.askexe.com";
7199
+ }
7200
+ return endpoint;
7201
+ }
7109
7202
  function assertSecureEndpoint(endpoint) {
7110
7203
  if (endpoint.startsWith("https://")) return;
7111
7204
  if (endpoint.startsWith("http://")) {
@@ -7243,6 +7336,7 @@ async function markCloudReuploadRequired(client = getClient()) {
7243
7336
  await client.execute("INSERT OR REPLACE INTO sync_meta (key, value) VALUES ('cloud_reupload_required', '1')");
7244
7337
  }
7245
7338
  async function cloudSync(config) {
7339
+ config = { ...config, endpoint: migrateEndpoint(config.endpoint) };
7246
7340
  if (!isSyncCryptoInitialized()) {
7247
7341
  try {
7248
7342
  const { getMasterKey: getMasterKey2 } = await Promise.resolve().then(() => (init_keychain(), keychain_exports));
@@ -7332,6 +7426,27 @@ async function cloudSync(config) {
7332
7426
  if (stmts.length > 0) await client.batch(stmts, "write");
7333
7427
  pulled = pullResult.records.length;
7334
7428
  } else {
7429
+ try {
7430
+ const incomingIds = pullResult.records.map((r) => sqlSafe(r.id));
7431
+ if (incomingIds.length > 0) {
7432
+ const ph = incomingIds.map(() => "?").join(",");
7433
+ const existing = await client.execute({
7434
+ sql: `SELECT id, version, timestamp FROM memories WHERE id IN (${ph})`,
7435
+ args: incomingIds
7436
+ });
7437
+ const localMap = new Map(existing.rows.map((r) => [String(r.id), r]));
7438
+ for (const rec of pullResult.records) {
7439
+ const local = localMap.get(String(rec.id));
7440
+ if (local && Number(local.version) > 0 && Number(local.version) !== Number(rec.version ?? 0)) {
7441
+ process.stderr.write(
7442
+ `[cloud-sync] CONFLICT: memory ${String(rec.id).slice(0, 8)} \u2014 local v${local.version} vs remote v${rec.version ?? 0}. Remote wins (LWW).
7443
+ `
7444
+ );
7445
+ }
7446
+ }
7447
+ }
7448
+ } catch {
7449
+ }
7335
7450
  const stmts = pullResult.records.map((rec) => ({
7336
7451
  sql: `INSERT OR REPLACE INTO memories
7337
7452
  (id, agent_id, agent_role, session_id, timestamp,
@@ -9089,11 +9204,17 @@ var init_platform_procedures = __esm({
9089
9204
  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."
9090
9205
  },
9091
9206
  {
9092
- title: "Customer orchestration maturity \u2014 recommend, never trap",
9207
+ title: "Orchestration phase guidance \u2014 recommend, never trap",
9093
9208
  domain: "workflow",
9094
9209
  priority: "p1",
9095
9210
  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."
9096
9211
  },
9212
+ {
9213
+ title: "Routing slot vs display title \u2014 internal 'coo' is plumbing, not your name",
9214
+ domain: "identity",
9215
+ priority: "p0",
9216
+ 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."
9217
+ },
9097
9218
  {
9098
9219
  title: "Single dispatch path \u2014 create_task only",
9099
9220
  domain: "workflow",
@@ -9127,6 +9248,12 @@ var init_platform_procedures = __esm({
9127
9248
  priority: "p0",
9128
9249
  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."
9129
9250
  },
9251
+ {
9252
+ title: "Destructive operations \u2014 mandatory reviewer gate",
9253
+ domain: "security",
9254
+ priority: "p0",
9255
+ 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."
9256
+ },
9130
9257
  {
9131
9258
  title: "Customer patch triage \u2014 upstream bug vs customization",
9132
9259
  domain: "support",
@@ -9412,10 +9539,24 @@ function stableId(memoryId, type, content) {
9412
9539
  return createHash3("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
9413
9540
  }
9414
9541
  function cleanText(text) {
9415
- return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
9542
+ let cleaned = text.replace(
9543
+ /```(\w*)\n(.*?)(?:\n[\s\S]*?)```/g,
9544
+ (_m, lang, firstLine) => `[code${lang ? `:${lang}` : ""}] ${firstLine.trim()}`
9545
+ );
9546
+ cleaned = cleaned.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
9547
+ return cleaned;
9416
9548
  }
9417
- function splitSentences(text) {
9418
- return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
9549
+ function splitSegments(text) {
9550
+ const cleaned = cleanText(text);
9551
+ 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);
9552
+ if (segments.length === 0 && cleaned.length >= MIN_SEGMENT_CHARS) {
9553
+ const lines = cleaned.split(/\n+/).map((l) => l.trim()).filter((l) => l.length >= MIN_SEGMENT_CHARS && l.length <= MAX_SEGMENT_CHARS);
9554
+ if (lines.length > 0) return lines;
9555
+ if (cleaned.length >= MIN_SEGMENT_CHARS) {
9556
+ return [cleaned.slice(0, MAX_SEGMENT_CHARS)];
9557
+ }
9558
+ }
9559
+ return segments;
9419
9560
  }
9420
9561
  function inferCardType(sentence, toolName) {
9421
9562
  const lower = sentence.toLowerCase();
@@ -9447,12 +9588,12 @@ function predicateFor(type) {
9447
9588
  }
9448
9589
  }
9449
9590
  function extractMemoryCards(row) {
9450
- const sentences = splitSentences(row.raw_text);
9591
+ const segments = splitSegments(row.raw_text);
9451
9592
  const cards = [];
9452
- for (const sentence of sentences) {
9593
+ for (const sentence of segments) {
9453
9594
  const type = inferCardType(sentence, row.tool_name);
9454
9595
  const subject = extractSubject(sentence, row.agent_id);
9455
- const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
9596
+ const content = sentence.length > MAX_SEGMENT_CHARS ? `${sentence.slice(0, MAX_SEGMENT_CHARS - 1)}\u2026` : sentence;
9456
9597
  cards.push({
9457
9598
  id: stableId(row.id, type, content),
9458
9599
  memory_id: row.id,
@@ -9548,13 +9689,14 @@ Source memory: ${String(row.source_ref ?? row.memory_id)}`,
9548
9689
  last_accessed: String(row.timestamp)
9549
9690
  }));
9550
9691
  }
9551
- var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
9692
+ var MAX_CARDS_PER_MEMORY, MAX_SEGMENT_CHARS, MIN_SEGMENT_CHARS;
9552
9693
  var init_memory_cards = __esm({
9553
9694
  "src/lib/memory-cards.ts"() {
9554
9695
  "use strict";
9555
9696
  init_database();
9556
- MAX_CARDS_PER_MEMORY = 6;
9557
- MAX_SENTENCE_CHARS = 360;
9697
+ MAX_CARDS_PER_MEMORY = 8;
9698
+ MAX_SEGMENT_CHARS = 500;
9699
+ MIN_SEGMENT_CHARS = 20;
9558
9700
  }
9559
9701
  });
9560
9702
 
@@ -10645,7 +10787,7 @@ async function setupMode() {
10645
10787
  rl.close();
10646
10788
  return;
10647
10789
  }
10648
- const endpoint = await ask(rl, " Endpoint [https://askexe.com/cloud]: ") || "https://askexe.com/cloud";
10790
+ const endpoint = await ask(rl, " Endpoint [https://cloud.askexe.com]: ") || "https://cloud.askexe.com";
10649
10791
  console.log(" Validating...");
10650
10792
  try {
10651
10793
  assertSecureEndpoint(endpoint);
@@ -10711,6 +10853,14 @@ async function setupMode() {
10711
10853
  }
10712
10854
  console.log("");
10713
10855
  }
10856
+ try {
10857
+ const keyInfo = await getKeyStorageInfo();
10858
+ if (keyInfo.kind !== "missing") {
10859
+ console.log(` \u2713 Encryption key: ${keyInfo.note}`);
10860
+ }
10861
+ } catch {
10862
+ }
10863
+ console.log("");
10714
10864
  console.log(BAR);
10715
10865
  console.log(latestConfig.cloud?.apiKey ? " Setup complete. Cloud sync is connected." : " Setup complete. Cloud sync is not configured yet.");
10716
10866
  console.log(BAR);
@@ -10802,7 +10952,13 @@ async function statusMode() {
10802
10952
  console.log("");
10803
10953
  if (key) {
10804
10954
  const fingerprint = key.toString("hex").slice(0, 8);
10805
- console.log(` Encryption key: \u2713 present (${fingerprint}...)`);
10955
+ let storageNote = "";
10956
+ try {
10957
+ const keyInfo = await getKeyStorageInfo();
10958
+ if (keyInfo.kind !== "missing") storageNote = ` [${keyInfo.note}]`;
10959
+ } catch {
10960
+ }
10961
+ console.log(` Encryption key: \u2713 present (${fingerprint}...)${storageNote}`);
10806
10962
  } else {
10807
10963
  console.log(" Encryption key: \u2717 not found \u2014 run /exe-setup");
10808
10964
  }
@@ -12291,17 +12447,14 @@ var backfill_metadata_exports = {};
12291
12447
  __export(backfill_metadata_exports, {
12292
12448
  backfillMetadata: () => backfillMetadata
12293
12449
  });
12294
- function roleAgentMarkers(role, fallbackName) {
12450
+ function roleAgentMarkers(role) {
12295
12451
  try {
12296
12452
  const employees = loadEmployeesSync();
12297
- const employee = getEmployeeByRole(employees, role);
12298
- const configuredName = employee?.name?.toLowerCase().trim();
12299
- if (configuredName) {
12300
- return [configuredName];
12301
- }
12453
+ const names = getEmployeeNamesByRole(employees, role).map((n) => n.toLowerCase().trim()).filter(Boolean);
12454
+ if (names.length > 0) return names;
12302
12455
  } catch {
12303
12456
  }
12304
- return [fallbackName];
12457
+ return [];
12305
12458
  }
12306
12459
  function mentionsAgentMarker(text, markers) {
12307
12460
  return markers.some(
@@ -12860,8 +13013,8 @@ var init_backfill_metadata = __esm({
12860
13013
  VALID_LANGUAGE_TYPES = /* @__PURE__ */ new Set(["code", "prose", "mixed", "json", "sql"]);
12861
13014
  MAX_TEXT_LENGTH = 2e3;
12862
13015
  BATCH_SLEEP_MS = 1e3;
12863
- MARKETING_AGENT_MARKERS = roleAgentMarkers("CMO", "mari");
12864
- RESEARCH_AGENT_MARKERS = roleAgentMarkers("AI Product Lead", "gen");
13016
+ MARKETING_AGENT_MARKERS = roleAgentMarkers("CMO");
13017
+ RESEARCH_AGENT_MARKERS = roleAgentMarkers("AI Product Lead");
12865
13018
  if (isMainModule(import.meta.url)) {
12866
13019
  const options = parseArgs2(process.argv.slice(2));
12867
13020
  backfillMetadata(options).then((result) => {
@@ -14341,6 +14494,19 @@ async function resolveTask(client, identifier, scopeSession) {
14341
14494
  args: [identifier, ...scope.args]
14342
14495
  });
14343
14496
  if (result.rows.length === 1) return result.rows[0];
14497
+ if (/^[a-f0-9]{7,12}$/i.test(identifier)) {
14498
+ result = await client.execute({
14499
+ sql: `SELECT * FROM tasks WHERE id LIKE ?`,
14500
+ args: [`${identifier}%`]
14501
+ });
14502
+ if (result.rows.length === 1) return result.rows[0];
14503
+ if (result.rows.length > 1) {
14504
+ const matches = result.rows.map((r) => `${String(r.id)} "${String(r.title)}" (${String(r.status)})`).join(", ");
14505
+ throw new Error(
14506
+ `Multiple tasks match short-ID "${identifier}": ${matches}. Use a longer prefix to disambiguate.`
14507
+ );
14508
+ }
14509
+ }
14344
14510
  result = await client.execute({
14345
14511
  sql: `SELECT * FROM tasks WHERE task_file LIKE ?${scope.sql}`,
14346
14512
  args: [`%${identifier}%`, ...scope.args]
@@ -15195,12 +15361,13 @@ async function cascadeUnblock(taskId, baseDir, now2) {
15195
15361
  WHERE blocked_by = ? AND status = 'blocked'`,
15196
15362
  args: [now2, taskId]
15197
15363
  });
15198
- if (baseDir && unblocked.rowsAffected > 0) {
15199
- const ubScope = sessionScopeFilter();
15200
- const unblockedRows = await client.execute({
15201
- sql: `SELECT task_file FROM tasks WHERE blocked_by IS NULL AND updated_at = ?${ubScope.sql}`,
15202
- args: [now2, ...ubScope.args]
15203
- });
15364
+ if (unblocked.rowsAffected === 0) return;
15365
+ const ubScope = sessionScopeFilter();
15366
+ const unblockedRows = await client.execute({
15367
+ sql: `SELECT id, title, assigned_to, priority, task_file FROM tasks WHERE blocked_by IS NULL AND updated_at = ?${ubScope.sql}`,
15368
+ args: [now2, ...ubScope.args]
15369
+ });
15370
+ if (baseDir) {
15204
15371
  for (const ur of unblockedRows.rows) {
15205
15372
  try {
15206
15373
  const ubFile = path32.join(baseDir, String(ur.task_file));
@@ -15212,6 +15379,19 @@ async function cascadeUnblock(taskId, baseDir, now2) {
15212
15379
  }
15213
15380
  }
15214
15381
  }
15382
+ if (unblockedRows.rows.length > 0 && !process.env.VITEST) {
15383
+ try {
15384
+ const { queueIntercom: queueIntercom2 } = await Promise.resolve().then(() => (init_intercom_queue(), intercom_queue_exports));
15385
+ const dispatched = /* @__PURE__ */ new Set();
15386
+ for (const ur of unblockedRows.rows) {
15387
+ const assignee = String(ur.assigned_to);
15388
+ if (dispatched.has(assignee)) continue;
15389
+ dispatched.add(assignee);
15390
+ queueIntercom2(`${assignee}`, `unblocked: "${String(ur.title)}" is now ready`);
15391
+ }
15392
+ } catch {
15393
+ }
15394
+ }
15215
15395
  }
15216
15396
  async function findNextTask(assignedTo) {
15217
15397
  const client = getClient();
@@ -15421,6 +15601,15 @@ var init_embedder = __esm({
15421
15601
  // src/lib/behaviors.ts
15422
15602
  import crypto10 from "crypto";
15423
15603
  async function storeBehavior(opts) {
15604
+ try {
15605
+ const { loadEmployeesSync: loadEmployeesSync2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
15606
+ const roster = loadEmployeesSync2();
15607
+ if (roster.length > 0 && !roster.some((e) => e.name === opts.agentId)) {
15608
+ throw new Error(`Agent "${opts.agentId}" not found in roster. Cannot store behavior for unregistered agent.`);
15609
+ }
15610
+ } catch (e) {
15611
+ if (e instanceof Error && e.message.includes("not found in roster")) throw e;
15612
+ }
15424
15613
  const client = getClient();
15425
15614
  const id = crypto10.randomUUID();
15426
15615
  const now2 = (/* @__PURE__ */ new Date()).toISOString();
@@ -15874,6 +16063,12 @@ async function updateTask(input) {
15874
16063
  }
15875
16064
  }
15876
16065
  }
16066
+ if (input.status === "cancelled") {
16067
+ try {
16068
+ await cascadeUnblock(taskId, input.baseDir, now2);
16069
+ } catch {
16070
+ }
16071
+ }
15877
16072
  if ((input.status === "done" || input.status === "closed") && !isCoordinatorName(String(row.assigned_to)) && !process.env.VITEST) {
15878
16073
  Promise.resolve().then(() => (init_skill_learning(), skill_learning_exports)).then(
15879
16074
  ({ captureAndLearn: captureAndLearn2 }) => captureAndLearn2({
@@ -16405,11 +16600,12 @@ function getDispatchedBy(sessionKey) {
16405
16600
  }
16406
16601
  }
16407
16602
  function resolveExeSession() {
16603
+ if (process.env.EXE_SESSION_NAME) {
16604
+ const fromEnv = extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
16605
+ if (fromEnv) return fromEnv;
16606
+ }
16408
16607
  const mySession = getMySession();
16409
16608
  if (!mySession) {
16410
- if (process.env.EXE_SESSION_NAME) {
16411
- return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
16412
- }
16413
16609
  return null;
16414
16610
  }
16415
16611
  const fromSessionName = extractRootExe(mySession);
@@ -16424,6 +16620,10 @@ function resolveExeSession() {
16424
16620
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
16425
16621
  `
16426
16622
  );
16623
+ try {
16624
+ registerParentExe(key, fromSessionName);
16625
+ } catch {
16626
+ }
16427
16627
  candidate = fromSessionName;
16428
16628
  } else {
16429
16629
  candidate = fromCache;
@@ -16966,10 +17166,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
16966
17166
  }
16967
17167
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
16968
17168
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
16969
- let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
16970
- if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
16971
- ccModel += "[1m]";
16972
- }
17169
+ const { normalizeCcModelName: normalizeCcModelName2 } = (init_agent_config(), __toCommonJS(agent_config_exports));
17170
+ const ccModel = normalizeCcModelName2(agentRtConfig.model);
16973
17171
  envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
16974
17172
  }
16975
17173
  }
@@ -17582,9 +17780,23 @@ __export(employee_templates_exports, {
17582
17780
  function getSessionPrompt(storedPrompt) {
17583
17781
  const markerIndex = storedPrompt.indexOf(PROCEDURES_MARKER);
17584
17782
  const withoutProcedures = markerIndex >= 0 ? storedPrompt.slice(0, markerIndex).trimEnd() : storedPrompt;
17783
+ let titlePrefix = "";
17784
+ const frontmatterMatch = withoutProcedures.match(/^---\r?\n([\s\S]*?)\r?\n---/);
17785
+ if (frontmatterMatch) {
17786
+ const titleMatch = frontmatterMatch[1].match(/^title:\s*(.+)$/m);
17787
+ const roleMatch = frontmatterMatch[1].match(/^role:\s*(.+)$/m);
17788
+ if (titleMatch) {
17789
+ const title = titleMatch[1].trim();
17790
+ const role = roleMatch ? roleMatch[1].trim() : "";
17791
+ if (title && role && title.toLowerCase() !== role.toLowerCase()) {
17792
+ titlePrefix = `## Your Identity
17793
+ You are **${title}** (specialist). `;
17794
+ }
17795
+ }
17796
+ }
17585
17797
  const rolePrompt = withoutProcedures.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").replace(/<!--[\s\S]*?-->/g, "").trimStart();
17586
17798
  const globalBlock = getGlobalProceduresBlock();
17587
- return `${globalBlock}${rolePrompt}
17799
+ return `${globalBlock}${titlePrefix}${rolePrompt}
17588
17800
  ${BASE_OPERATING_PROCEDURES}`;
17589
17801
  }
17590
17802
  function buildCustomEmployeePrompt(name, role) {
@@ -17603,7 +17815,7 @@ function personalizePrompt(prompt, templateName, actualName) {
17603
17815
  return prompt.replace(new RegExp(`\\bYou are ${escaped}\\b`, "g"), `You are ${actualName}`);
17604
17816
  }
17605
17817
  function renderClientCOOTemplate(vars) {
17606
- const resolved = { ...vars, title: vars.title || "Chief Operating Officer" };
17818
+ const resolved = { ...vars, title: vars.title || "Chief of Staff" };
17607
17819
  for (const key of CLIENT_COO_PLACEHOLDERS) {
17608
17820
  const value = resolved[key];
17609
17821
  if (typeof value !== "string" || value.length === 0) {
@@ -20300,6 +20512,24 @@ async function runSetupWizard(opts = {}) {
20300
20512
  log("");
20301
20513
  log("=== exe-os Setup ===");
20302
20514
  log("");
20515
+ if (process.platform === "darwin") {
20516
+ const currentShell = process.env.SHELL ?? "";
20517
+ if (currentShell.includes("bash")) {
20518
+ log(" \u26A0 Your default shell is bash.");
20519
+ log(" macOS uses zsh by default since Catalina (2019).");
20520
+ log(" exe-os works with bash, but switching to zsh is recommended:");
20521
+ log(" chsh -s /bin/zsh");
20522
+ log(" Then restart your terminal.");
20523
+ log("");
20524
+ const cont = await ask3(rl, " Continue with bash? (y/n, default: y): ");
20525
+ if (cont.toLowerCase() === "n") {
20526
+ log(" Run `chsh -s /bin/zsh`, restart your terminal, then run setup again.");
20527
+ rl.close();
20528
+ return;
20529
+ }
20530
+ log("");
20531
+ }
20532
+ }
20303
20533
  log("What are you setting up?");
20304
20534
  log("");
20305
20535
  log(" [1] First device / brand new Exe OS memory");
@@ -20327,7 +20557,7 @@ async function runSetupWizard(opts = {}) {
20327
20557
  log("");
20328
20558
  const apiKey = await ask3(rl, "Cloud API key (starts with exe_sk_): ");
20329
20559
  if (apiKey && apiKey.startsWith("exe_sk_")) {
20330
- const cloudEndpoint = "https://askexe.com/cloud";
20560
+ const cloudEndpoint = "https://cloud.askexe.com";
20331
20561
  const cloudCfg = { apiKey, endpoint: cloudEndpoint };
20332
20562
  const earlyConfig = await loadConfig();
20333
20563
  earlyConfig.cloud = cloudCfg;
@@ -20427,7 +20657,7 @@ async function runSetupWizard(opts = {}) {
20427
20657
  log("");
20428
20658
  const existingKey = await ask3(rl, "Paste your Exe OS license key, or press Enter to start as a free user: ");
20429
20659
  if (existingKey && existingKey.startsWith("exe_sk_")) {
20430
- const cloudEndpoint = "https://askexe.com/cloud";
20660
+ const cloudEndpoint = "https://cloud.askexe.com";
20431
20661
  try {
20432
20662
  const { loadDeviceId: loadDeviceId2 } = await Promise.resolve().then(() => (init_license(), license_exports));
20433
20663
  const deviceId = loadDeviceId2();
@@ -20452,7 +20682,7 @@ async function runSetupWizard(opts = {}) {
20452
20682
  }
20453
20683
  } catch {
20454
20684
  log("Could not validate key \u2014 saving it and proceeding.");
20455
- cloudConfig = { apiKey: existingKey, endpoint: "https://askexe.com/cloud" };
20685
+ cloudConfig = { apiKey: existingKey, endpoint: "https://cloud.askexe.com" };
20456
20686
  const { saveLicense: saveLicense3, mirrorLicenseKey: mirrorLicenseKey3 } = await Promise.resolve().then(() => (init_license(), license_exports));
20457
20687
  saveLicense3(existingKey);
20458
20688
  mirrorLicenseKey3(existingKey);
@@ -20464,7 +20694,7 @@ async function runSetupWizard(opts = {}) {
20464
20694
  const deviceId = loadDeviceId2();
20465
20695
  let res;
20466
20696
  try {
20467
- res = await fetch("https://askexe.com/cloud/auth/auto-provision", {
20697
+ res = await fetch("https://cloud.askexe.com/auth/auto-provision", {
20468
20698
  method: "POST",
20469
20699
  headers: { "Content-Type": "application/json" },
20470
20700
  body: JSON.stringify({ deviceId }),
@@ -20472,7 +20702,7 @@ async function runSetupWizard(opts = {}) {
20472
20702
  });
20473
20703
  } catch {
20474
20704
  await new Promise((r) => setTimeout(r, 500));
20475
- res = await fetch("https://askexe.com/cloud/auth/auto-provision", {
20705
+ res = await fetch("https://cloud.askexe.com/auth/auto-provision", {
20476
20706
  method: "POST",
20477
20707
  headers: { "Content-Type": "application/json" },
20478
20708
  body: JSON.stringify({ deviceId }),
@@ -20482,7 +20712,7 @@ async function runSetupWizard(opts = {}) {
20482
20712
  if (res.ok) {
20483
20713
  const data = await res.json();
20484
20714
  if (data.apiKey) {
20485
- cloudConfig = { apiKey: data.apiKey, endpoint: "https://askexe.com/cloud" };
20715
+ cloudConfig = { apiKey: data.apiKey, endpoint: "https://cloud.askexe.com" };
20486
20716
  const { saveLicense: saveLicense3, mirrorLicenseKey: mirrorLicenseKey3 } = await Promise.resolve().then(() => (init_license(), license_exports));
20487
20717
  saveLicense3(data.apiKey);
20488
20718
  mirrorLicenseKey3(data.apiKey);
@@ -20972,7 +21202,7 @@ var init_setup_wizard = __esm({
20972
21202
  });
20973
21203
 
20974
21204
  // src/lib/update-backup.ts
20975
- import { copyFile, readFile as readFile6, readdir as readdir3, writeFile as writeFile7, rm as rm2, mkdir as mkdir7, cp } from "fs/promises";
21205
+ import { copyFile as copyFile2, readFile as readFile6, readdir as readdir3, writeFile as writeFile7, rm as rm2, mkdir as mkdir7, cp } from "fs/promises";
20976
21206
  import { existsSync as existsSync36 } from "fs";
20977
21207
  import path42 from "path";
20978
21208
  import os20 from "os";
@@ -21008,7 +21238,7 @@ async function createUpdateBackup(currentVersion, dataDir2, homeDir = os20.homed
21008
21238
  if (!existsSync36(src)) continue;
21009
21239
  const dest = path42.join(backupDir, target.name);
21010
21240
  if (target.type === "file") {
21011
- await copyFile(src, dest);
21241
+ await copyFile2(src, dest);
21012
21242
  } else {
21013
21243
  await cp(src, dest, { recursive: true });
21014
21244
  }
@@ -21019,7 +21249,7 @@ async function createUpdateBackup(currentVersion, dataDir2, homeDir = os20.homed
21019
21249
  if (entry.isFile() && entry.name.endsWith(".db") && entry.name !== BACKUP_DIR_NAME) {
21020
21250
  const src = path42.join(dir, entry.name);
21021
21251
  const dest = path42.join(backupDir, entry.name);
21022
- await copyFile(src, dest);
21252
+ await copyFile2(src, dest);
21023
21253
  backedUpFiles.push(entry.name);
21024
21254
  }
21025
21255
  }
@@ -21028,7 +21258,7 @@ async function createUpdateBackup(currentVersion, dataDir2, homeDir = os20.homed
21028
21258
  for (const target of externalBackupTargets(homeDir)) {
21029
21259
  if (!existsSync36(target.path)) continue;
21030
21260
  await mkdir7(externalDir, { recursive: true });
21031
- await copyFile(target.path, path42.join(externalDir, target.name));
21261
+ await copyFile2(target.path, path42.join(externalDir, target.name));
21032
21262
  externalFiles.push(target);
21033
21263
  }
21034
21264
  const manifest = {
@@ -21063,14 +21293,14 @@ async function restoreFromBackup(dataDir2) {
21063
21293
  if (stat2.isDirectory()) {
21064
21294
  await cp(src, dest, { recursive: true, force: true });
21065
21295
  } else {
21066
- await copyFile(src, dest);
21296
+ await copyFile2(src, dest);
21067
21297
  }
21068
21298
  }
21069
21299
  for (const external of manifest.externalFiles ?? []) {
21070
21300
  const src = path42.join(backupDir, "external", external.name);
21071
21301
  if (!existsSync36(src)) continue;
21072
21302
  await mkdir7(path42.dirname(external.path), { recursive: true });
21073
- await copyFile(src, external.path);
21303
+ await copyFile2(src, external.path);
21074
21304
  }
21075
21305
  return manifest;
21076
21306
  }
@@ -31938,6 +32168,33 @@ var init_dangerous_patterns = __esm({
31938
32168
  regex: /\bkill\s+-9\b/,
31939
32169
  severity: "warning",
31940
32170
  reason: "Force kill signal"
32171
+ },
32172
+ // MCP bypass — agents must use MCP tools, never access the DB directly.
32173
+ // These patterns catch attempts to work around a disconnected MCP server.
32174
+ {
32175
+ regex: /\bsqlite3\b.*\bmemories\.db\b/,
32176
+ severity: "critical",
32177
+ reason: "Direct SQLite access bypasses MCP contract boundary \u2014 use MCP tools"
32178
+ },
32179
+ {
32180
+ regex: /\bsqlite3\b.*\.exe-os\b/,
32181
+ severity: "critical",
32182
+ reason: "Direct SQLite access to exe-os database \u2014 use MCP tools"
32183
+ },
32184
+ {
32185
+ regex: /\bnode\s+-e\b.*\b(better-sqlite3|libsql|sqlite3)\b/,
32186
+ severity: "critical",
32187
+ reason: "Inline Node.js script accessing SQLite directly \u2014 use MCP tools"
32188
+ },
32189
+ {
32190
+ regex: /\brequire\s*\(\s*['"].*memories\.db['"]\s*\)/,
32191
+ severity: "critical",
32192
+ reason: "Direct require of memories database \u2014 use MCP tools"
32193
+ },
32194
+ {
32195
+ regex: /\bcat\b.*\bmemories\.db\b/,
32196
+ severity: "warning",
32197
+ reason: "Reading raw database file \u2014 encrypted data, use MCP tools instead"
31941
32198
  }
31942
32199
  ];
31943
32200
  }
@@ -33142,7 +33399,7 @@ function useOrchestrator(enabled = true) {
33142
33399
  const [pendingReviews, setPendingReviews] = useState8(0);
33143
33400
  const [isLoading, setIsLoading] = useState8(true);
33144
33401
  const orchestratorRef = useRef5(null);
33145
- const exeSessionRef = useRef5("exe1");
33402
+ const exeSessionRef = useRef5("");
33146
33403
  const coordinatorNameRef = useRef5(DEFAULT_COORDINATOR_TEMPLATE_NAME);
33147
33404
  useEffect10(() => {
33148
33405
  if (!enabled) return;
@@ -33739,6 +33996,8 @@ var tui_data_exports = {};
33739
33996
  __export(tui_data_exports, {
33740
33997
  loadMemoryDashboard: () => loadMemoryDashboard,
33741
33998
  loadTaskList: () => loadTaskList,
33999
+ loadTeamBadgeCounts: () => loadTeamBadgeCounts,
34000
+ loadTeamDetailMetrics: () => loadTeamDetailMetrics,
33742
34001
  loadTeamMetrics: () => loadTeamMetrics,
33743
34002
  searchWikiMemoryRows: () => searchWikiMemoryRows
33744
34003
  });
@@ -33767,16 +34026,20 @@ async function loadMemoryDashboard(limit) {
33767
34026
  }))
33768
34027
  };
33769
34028
  }
33770
- async function loadTeamMetrics(employeeNames) {
34029
+ async function loadTeamBadgeCounts() {
33771
34030
  const client = getClient();
33772
34031
  const memoryCounts = /* @__PURE__ */ new Map();
33773
- const projectsByEmployee = /* @__PURE__ */ new Map();
33774
- const currentTaskByEmployee = /* @__PURE__ */ new Map();
33775
- const scope = sessionScopeFilter();
33776
34032
  const memResult = await client.execute("SELECT agent_id, COUNT(*) as cnt FROM memories GROUP BY agent_id");
33777
34033
  for (const row of memResult.rows) {
33778
34034
  memoryCounts.set(String(row.agent_id), Number(row.cnt));
33779
34035
  }
34036
+ return memoryCounts;
34037
+ }
34038
+ async function loadTeamDetailMetrics(employeeNames) {
34039
+ const client = getClient();
34040
+ const projectsByEmployee = /* @__PURE__ */ new Map();
34041
+ const currentTaskByEmployee = /* @__PURE__ */ new Map();
34042
+ const scope = sessionScopeFilter();
33780
34043
  for (const employeeName of employeeNames) {
33781
34044
  const [projectResult, taskResult] = await Promise.all([
33782
34045
  client.execute({
@@ -33809,6 +34072,13 @@ async function loadTeamMetrics(employeeNames) {
33809
34072
  currentTaskByEmployee.set(employeeName, String(taskResult.rows[0].title));
33810
34073
  }
33811
34074
  }
34075
+ return { projectsByEmployee, currentTaskByEmployee };
34076
+ }
34077
+ async function loadTeamMetrics(employeeNames) {
34078
+ const [memoryCounts, { projectsByEmployee, currentTaskByEmployee }] = await Promise.all([
34079
+ loadTeamBadgeCounts(),
34080
+ loadTeamDetailMetrics(employeeNames)
34081
+ ]);
33812
34082
  return { memoryCounts, projectsByEmployee, currentTaskByEmployee };
33813
34083
  }
33814
34084
  async function loadTaskList() {
@@ -35064,6 +35334,8 @@ function TeamView({ onBack, onViewSessions }) {
35064
35334
  const [members, setMembers] = useState12([]);
35065
35335
  const [externals, setExternals] = useState12([]);
35066
35336
  const [loading, setLoading] = useState12(!demo);
35337
+ const [badgeInFlight, setBadgeInFlight] = useState12(!demo);
35338
+ const [detailInFlight, setDetailInFlight] = useState12(!demo);
35067
35339
  const [dbError, setDbError] = useState12(null);
35068
35340
  const [selectedIdx, setSelectedIdx] = useState12(0);
35069
35341
  const [showDetail, setShowDetail] = useState12(false);
@@ -35076,6 +35348,8 @@ function TeamView({ onBack, onViewSessions }) {
35076
35348
  setMembers(DEMO_EMPLOYEES.map((e) => ({ ...e })));
35077
35349
  setExternals(DEMO_EXTERNAL_AGENTS);
35078
35350
  setLoading(false);
35351
+ setBadgeInFlight(false);
35352
+ setDetailInFlight(false);
35079
35353
  return;
35080
35354
  }
35081
35355
  loadTeam();
@@ -35114,33 +35388,48 @@ function TeamView({ onBack, onViewSessions }) {
35114
35388
  let projectsByEmployee = /* @__PURE__ */ new Map();
35115
35389
  let currentTaskByEmployee = /* @__PURE__ */ new Map();
35116
35390
  try {
35117
- const { loadTeamMetrics: loadTeamMetrics2 } = await Promise.resolve().then(() => (init_tui_data(), tui_data_exports));
35118
- const teamMetrics = await loadTeamMetrics2(roster.map((emp) => emp.name));
35119
- memoryCounts = teamMetrics.memoryCounts;
35120
- projectsByEmployee = new Map(
35121
- Array.from(teamMetrics.projectsByEmployee.entries()).map(([name, projects]) => [
35122
- name,
35123
- projects.filter((project) => !DEPRECATED_PROJECTS.has(project.name))
35124
- ])
35125
- );
35391
+ const { loadTeamBadgeCounts: loadTeamBadgeCounts2, loadTeamDetailMetrics: loadTeamDetailMetrics2 } = await Promise.resolve().then(() => (init_tui_data(), tui_data_exports));
35392
+ setBadgeInFlight(true);
35393
+ const badgeCountsPromise = loadTeamBadgeCounts2();
35394
+ const detailsPromise = loadTeamDetailMetrics2(roster.map((emp) => emp.name));
35395
+ memoryCounts = await badgeCountsPromise;
35396
+ setBadgeInFlight(false);
35397
+ const initialMembers = roster.map((emp) => {
35398
+ const agentSt = getAgentStatus(emp.name);
35399
+ return {
35400
+ name: emp.name,
35401
+ role: emp.role,
35402
+ status: agentSt.label,
35403
+ activity: agentSt.label === "active" ? "Processing..." : "",
35404
+ memoryCount: memoryCounts.get(emp.name) ?? 0,
35405
+ projects: void 0,
35406
+ currentTask: void 0,
35407
+ sessionName: agentSt.session
35408
+ };
35409
+ });
35410
+ setMembers(initialMembers);
35411
+ setDetailInFlight(true);
35412
+ const teamMetrics = await detailsPromise;
35413
+ projectsByEmployee = teamMetrics.projectsByEmployee;
35126
35414
  currentTaskByEmployee = teamMetrics.currentTaskByEmployee;
35415
+ setDetailInFlight(false);
35416
+ const finalMembers = roster.map((emp) => {
35417
+ const agentSt = getAgentStatus(emp.name);
35418
+ return {
35419
+ name: emp.name,
35420
+ role: emp.role,
35421
+ status: agentSt.label,
35422
+ activity: agentSt.label === "active" ? "Processing..." : "",
35423
+ memoryCount: memoryCounts.get(emp.name) ?? 0,
35424
+ projects: projectsByEmployee.get(emp.name),
35425
+ currentTask: currentTaskByEmployee.get(emp.name),
35426
+ sessionName: agentSt.session
35427
+ };
35428
+ });
35429
+ setMembers(finalMembers);
35430
+ setDbError(null);
35127
35431
  } catch {
35128
35432
  }
35129
- const teamData = roster.map((emp) => {
35130
- const agentSt = getAgentStatus(emp.name);
35131
- return {
35132
- name: emp.name,
35133
- role: emp.role,
35134
- status: agentSt.label,
35135
- activity: agentSt.label === "active" ? "Processing..." : "",
35136
- memoryCount: memoryCounts.get(emp.name) ?? 0,
35137
- projects: projectsByEmployee.get(emp.name),
35138
- currentTask: currentTaskByEmployee.get(emp.name),
35139
- sessionName: agentSt.session
35140
- };
35141
- });
35142
- setMembers(teamData);
35143
- setDbError(null);
35144
35433
  try {
35145
35434
  const { existsSync: existsSync44, readFileSync: readFileSync39 } = await import("fs");
35146
35435
  const { join: join2 } = await import("path");
@@ -35162,6 +35451,8 @@ function TeamView({ onBack, onViewSessions }) {
35162
35451
  setDbError(err instanceof Error ? err.message : "Unknown error");
35163
35452
  } finally {
35164
35453
  setLoading(false);
35454
+ setBadgeInFlight(false);
35455
+ setDetailInFlight(false);
35165
35456
  }
35166
35457
  });
35167
35458
  }
@@ -35216,6 +35507,8 @@ function TeamView({ onBack, onViewSessions }) {
35216
35507
  orch.pendingReviews,
35217
35508
  " review(s) pending coordinator attention"
35218
35509
  ] }),
35510
+ badgeInFlight && /* @__PURE__ */ jsx12(Text, { color: "#F5D76E", children: " Loading memory counts..." }),
35511
+ detailInFlight && /* @__PURE__ */ jsx12(Text, { color: "#6B4C9A", children: " Loading employee details..." }),
35219
35512
  /* @__PURE__ */ jsx12(Text, { children: " " }),
35220
35513
  /* @__PURE__ */ jsx12(Text, { bold: true, children: "INTERNAL" }),
35221
35514
  /* @__PURE__ */ jsx12(Text, { children: " " }),
@@ -35304,7 +35597,6 @@ function TeamView({ onBack, onViewSessions }) {
35304
35597
  }) })
35305
35598
  ] });
35306
35599
  }
35307
- var DEPRECATED_PROJECTS;
35308
35600
  var init_Team = __esm({
35309
35601
  async "src/tui/views/Team.tsx"() {
35310
35602
  "use strict";
@@ -35314,7 +35606,6 @@ var init_Team = __esm({
35314
35606
  init_demo_data();
35315
35607
  init_useOrchestrator();
35316
35608
  init_agent_status();
35317
- DEPRECATED_PROJECTS = /* @__PURE__ */ new Set(["exe-ai-employees"]);
35318
35609
  }
35319
35610
  });
35320
35611