@askexenow/exe-os 0.9.65 → 0.9.67

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 (113) hide show
  1. package/deploy/stack-manifests/v0.9.json +54 -5
  2. package/dist/bin/age-ontology-load.js +61 -0
  3. package/dist/bin/agentic-ontology-backfill.js +4708 -0
  4. package/dist/bin/agentic-reflection-backfill.js +4144 -0
  5. package/dist/bin/{exe-link.js → agentic-semantic-label.js} +1532 -2173
  6. package/dist/bin/backfill-conversations.js +528 -20
  7. package/dist/bin/backfill-responses.js +528 -20
  8. package/dist/bin/backfill-vectors.js +255 -20
  9. package/dist/bin/bulk-sync-postgres.js +4876 -0
  10. package/dist/bin/cleanup-stale-review-tasks.js +529 -21
  11. package/dist/bin/cli.js +3471 -1491
  12. package/dist/bin/exe-agent-config.js +4 -0
  13. package/dist/bin/exe-agent.js +16 -0
  14. package/dist/bin/exe-assign.js +528 -20
  15. package/dist/bin/exe-boot.js +492 -54
  16. package/dist/bin/exe-call.js +16 -0
  17. package/dist/bin/exe-cloud.js +7415 -518
  18. package/dist/bin/exe-dispatch.js +540 -22
  19. package/dist/bin/exe-doctor.js +3404 -1225
  20. package/dist/bin/exe-export-behaviors.js +542 -24
  21. package/dist/bin/exe-forget.js +529 -21
  22. package/dist/bin/exe-gateway.js +595 -25
  23. package/dist/bin/exe-heartbeat.js +541 -24
  24. package/dist/bin/exe-kill.js +529 -21
  25. package/dist/bin/exe-launch-agent.js +2334 -1067
  26. package/dist/bin/exe-new-employee.js +324 -166
  27. package/dist/bin/exe-pending-messages.js +529 -21
  28. package/dist/bin/exe-pending-notifications.js +529 -21
  29. package/dist/bin/exe-pending-reviews.js +529 -21
  30. package/dist/bin/exe-rename.js +529 -21
  31. package/dist/bin/exe-review.js +529 -21
  32. package/dist/bin/exe-search.js +542 -24
  33. package/dist/bin/exe-session-cleanup.js +540 -22
  34. package/dist/bin/exe-settings.js +14 -0
  35. package/dist/bin/exe-start-codex.js +817 -144
  36. package/dist/bin/exe-start-opencode.js +776 -80
  37. package/dist/bin/exe-status.js +529 -21
  38. package/dist/bin/exe-team.js +529 -21
  39. package/dist/bin/git-sweep.js +540 -22
  40. package/dist/bin/graph-backfill.js +580 -21
  41. package/dist/bin/graph-export.js +529 -21
  42. package/dist/bin/graph-layer-benchmark.js +109 -0
  43. package/dist/bin/install.js +420 -289
  44. package/dist/bin/intercom-check.js +540 -22
  45. package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
  46. package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
  47. package/dist/bin/scan-tasks.js +540 -22
  48. package/dist/bin/setup.js +790 -206
  49. package/dist/bin/shard-migrate.js +528 -20
  50. package/dist/bin/update.js +4 -0
  51. package/dist/gateway/index.js +593 -23
  52. package/dist/hooks/bug-report-worker.js +651 -64
  53. package/dist/hooks/codex-stop-task-finalizer.js +540 -22
  54. package/dist/hooks/commit-complete.js +540 -22
  55. package/dist/hooks/error-recall.js +542 -24
  56. package/dist/hooks/exe-heartbeat-hook.js +4 -0
  57. package/dist/hooks/ingest-worker.js +4 -0
  58. package/dist/hooks/ingest.js +539 -22
  59. package/dist/hooks/instructions-loaded.js +529 -21
  60. package/dist/hooks/notification.js +529 -21
  61. package/dist/hooks/post-compact.js +529 -21
  62. package/dist/hooks/post-tool-combined.js +543 -25
  63. package/dist/hooks/pre-compact.js +772 -127
  64. package/dist/hooks/pre-tool-use.js +529 -21
  65. package/dist/hooks/prompt-submit.js +543 -25
  66. package/dist/hooks/session-end.js +673 -140
  67. package/dist/hooks/session-start.js +662 -26
  68. package/dist/hooks/stop.js +540 -23
  69. package/dist/hooks/subagent-stop.js +529 -21
  70. package/dist/hooks/summary-worker.js +571 -126
  71. package/dist/index.js +593 -23
  72. package/dist/lib/agent-config.js +4 -0
  73. package/dist/lib/cloud-sync.js +408 -47
  74. package/dist/lib/config.js +25 -1
  75. package/dist/lib/consolidation.js +5 -1
  76. package/dist/lib/database.js +128 -0
  77. package/dist/lib/db-daemon-client.js +4 -0
  78. package/dist/lib/db.js +128 -0
  79. package/dist/lib/device-registry.js +128 -0
  80. package/dist/lib/embedder.js +25 -1
  81. package/dist/lib/employee-templates.js +16 -0
  82. package/dist/lib/employees.js +4 -0
  83. package/dist/lib/exe-daemon-client.js +4 -0
  84. package/dist/lib/exe-daemon.js +3158 -930
  85. package/dist/lib/hybrid-search.js +542 -24
  86. package/dist/lib/identity.js +7 -0
  87. package/dist/lib/keychain.js +178 -22
  88. package/dist/lib/license.js +4 -0
  89. package/dist/lib/messaging.js +7 -0
  90. package/dist/lib/reminders.js +7 -0
  91. package/dist/lib/schedules.js +255 -20
  92. package/dist/lib/skill-learning.js +28 -1
  93. package/dist/lib/status-brief.js +39 -0
  94. package/dist/lib/store.js +528 -20
  95. package/dist/lib/task-router.js +4 -0
  96. package/dist/lib/tasks.js +28 -1
  97. package/dist/lib/tmux-routing.js +28 -1
  98. package/dist/lib/token-spend.js +7 -0
  99. package/dist/mcp/server.js +2739 -813
  100. package/dist/mcp/tools/complete-reminder.js +7 -0
  101. package/dist/mcp/tools/create-reminder.js +7 -0
  102. package/dist/mcp/tools/create-task.js +28 -1
  103. package/dist/mcp/tools/deactivate-behavior.js +7 -0
  104. package/dist/mcp/tools/list-reminders.js +7 -0
  105. package/dist/mcp/tools/list-tasks.js +7 -0
  106. package/dist/mcp/tools/send-message.js +7 -0
  107. package/dist/mcp/tools/update-task.js +28 -1
  108. package/dist/runtime/index.js +540 -22
  109. package/dist/tui/App.js +618 -29
  110. package/package.json +9 -5
  111. package/src/commands/exe/cloud.md +11 -8
  112. package/stack.release.json +3 -3
  113. package/src/commands/exe/link.md +0 -17
@@ -178,6 +178,11 @@ function normalizeAutoUpdate(raw) {
178
178
  const userAU = raw.autoUpdate ?? {};
179
179
  raw.autoUpdate = { ...defaultAU, ...userAU };
180
180
  }
181
+ function normalizeOrchestration(raw) {
182
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
183
+ const userOrg = raw.orchestration ?? {};
184
+ raw.orchestration = { ...defaultOrg, ...userOrg };
185
+ }
181
186
  async function loadConfig() {
182
187
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
183
188
  await ensurePrivateDir(dir);
@@ -202,10 +207,15 @@ async function loadConfig() {
202
207
  normalizeScalingRoadmap(migratedCfg);
203
208
  normalizeSessionLifecycle(migratedCfg);
204
209
  normalizeAutoUpdate(migratedCfg);
210
+ normalizeOrchestration(migratedCfg);
205
211
  const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
206
212
  if (config.dbPath.startsWith("~")) {
207
213
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
208
214
  }
215
+ const envDbPath = path.join(dir, "memories.db");
216
+ if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
217
+ config.dbPath = envDbPath;
218
+ }
209
219
  return config;
210
220
  } catch {
211
221
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -277,6 +287,10 @@ var init_config = __esm({
277
287
  checkOnBoot: true,
278
288
  autoInstall: false,
279
289
  checkIntervalMs: 24 * 60 * 60 * 1e3
290
+ },
291
+ orchestration: {
292
+ phase: "phase_1_coo",
293
+ phaseSetBy: "default"
280
294
  }
281
295
  };
282
296
  CONFIG_MIGRATIONS = [
@@ -1518,6 +1532,9 @@ function getClient() {
1518
1532
  if (_daemonClient && _daemonClient._isDaemonActive()) {
1519
1533
  return _daemonClient;
1520
1534
  }
1535
+ if (!_resilientClient) {
1536
+ return _adapterClient;
1537
+ }
1521
1538
  return _resilientClient;
1522
1539
  }
1523
1540
  async function initDaemonClient() {
@@ -2550,6 +2567,127 @@ async function ensureSchema() {
2550
2567
  VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
2551
2568
  END;
2552
2569
  `);
2570
+ await client.executeMultiple(`
2571
+ CREATE TABLE IF NOT EXISTS agent_sessions (
2572
+ id TEXT PRIMARY KEY,
2573
+ agent_id TEXT NOT NULL,
2574
+ project_name TEXT,
2575
+ started_at TEXT NOT NULL,
2576
+ last_event_at TEXT NOT NULL,
2577
+ event_count INTEGER NOT NULL DEFAULT 0,
2578
+ properties TEXT DEFAULT '{}'
2579
+ );
2580
+
2581
+ CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
2582
+ ON agent_sessions(agent_id, started_at);
2583
+
2584
+ CREATE TABLE IF NOT EXISTS agent_goals (
2585
+ id TEXT PRIMARY KEY,
2586
+ statement TEXT NOT NULL,
2587
+ owner_agent_id TEXT,
2588
+ project_name TEXT,
2589
+ status TEXT NOT NULL DEFAULT 'open',
2590
+ priority INTEGER NOT NULL DEFAULT 5,
2591
+ success_criteria TEXT,
2592
+ parent_goal_id TEXT,
2593
+ due_at TEXT,
2594
+ achieved_at TEXT,
2595
+ supersedes_id TEXT,
2596
+ created_at TEXT NOT NULL,
2597
+ updated_at TEXT NOT NULL,
2598
+ source_memory_id TEXT
2599
+ );
2600
+
2601
+ CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
2602
+ ON agent_goals(project_name, status, priority);
2603
+
2604
+ CREATE TABLE IF NOT EXISTS agent_events (
2605
+ id TEXT PRIMARY KEY,
2606
+ event_type TEXT NOT NULL,
2607
+ occurred_at TEXT NOT NULL,
2608
+ sequence_index INTEGER NOT NULL,
2609
+ actor_agent_id TEXT,
2610
+ agent_role TEXT,
2611
+ project_name TEXT,
2612
+ session_id TEXT,
2613
+ task_id TEXT,
2614
+ goal_id TEXT,
2615
+ parent_event_id TEXT,
2616
+ intention TEXT,
2617
+ outcome TEXT,
2618
+ evidence_memory_id TEXT,
2619
+ impact TEXT,
2620
+ payload TEXT DEFAULT '{}',
2621
+ created_at TEXT NOT NULL
2622
+ );
2623
+
2624
+ CREATE INDEX IF NOT EXISTS idx_agent_events_time
2625
+ ON agent_events(occurred_at, sequence_index);
2626
+
2627
+ CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
2628
+ ON agent_events(session_id, sequence_index);
2629
+
2630
+ CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
2631
+ ON agent_events(goal_id, occurred_at);
2632
+
2633
+ CREATE INDEX IF NOT EXISTS idx_agent_events_memory
2634
+ ON agent_events(evidence_memory_id);
2635
+
2636
+ CREATE TABLE IF NOT EXISTS agent_goal_links (
2637
+ id TEXT PRIMARY KEY,
2638
+ goal_id TEXT NOT NULL,
2639
+ link_type TEXT NOT NULL,
2640
+ target_id TEXT NOT NULL,
2641
+ target_type TEXT NOT NULL,
2642
+ created_at TEXT NOT NULL
2643
+ );
2644
+
2645
+ CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
2646
+ ON agent_goal_links(goal_id, target_type);
2647
+
2648
+ CREATE TABLE IF NOT EXISTS agent_semantic_labels (
2649
+ id TEXT PRIMARY KEY,
2650
+ source_memory_id TEXT NOT NULL,
2651
+ event_id TEXT,
2652
+ labeler TEXT NOT NULL,
2653
+ schema_version INTEGER NOT NULL DEFAULT 1,
2654
+ confidence REAL NOT NULL DEFAULT 0,
2655
+ labels TEXT NOT NULL,
2656
+ created_at TEXT NOT NULL,
2657
+ updated_at TEXT NOT NULL
2658
+ );
2659
+
2660
+ CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
2661
+ ON agent_semantic_labels(source_memory_id, labeler);
2662
+
2663
+ CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
2664
+ ON agent_semantic_labels(event_id);
2665
+
2666
+ CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
2667
+ id TEXT PRIMARY KEY,
2668
+ project_name TEXT,
2669
+ session_id TEXT,
2670
+ window_start_at TEXT NOT NULL,
2671
+ window_end_at TEXT NOT NULL,
2672
+ event_count INTEGER NOT NULL DEFAULT 0,
2673
+ goal_count INTEGER NOT NULL DEFAULT 0,
2674
+ success_count INTEGER NOT NULL DEFAULT 0,
2675
+ failure_count INTEGER NOT NULL DEFAULT 0,
2676
+ risk_count INTEGER NOT NULL DEFAULT 0,
2677
+ summary TEXT NOT NULL,
2678
+ learnings TEXT NOT NULL DEFAULT '[]',
2679
+ next_actions TEXT NOT NULL DEFAULT '[]',
2680
+ evidence_event_ids TEXT NOT NULL DEFAULT '[]',
2681
+ confidence REAL NOT NULL DEFAULT 0,
2682
+ created_at TEXT NOT NULL
2683
+ );
2684
+
2685
+ CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
2686
+ ON agent_reflection_checkpoints(project_name, window_end_at);
2687
+
2688
+ CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
2689
+ ON agent_reflection_checkpoints(session_id, window_end_at);
2690
+ `);
2553
2691
  try {
2554
2692
  await client.execute({
2555
2693
  sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
@@ -2713,7 +2851,7 @@ __export(shard_manager_exports, {
2713
2851
  shardExists: () => shardExists
2714
2852
  });
2715
2853
  import path7 from "path";
2716
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
2854
+ import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
2717
2855
  import { createClient as createClient2 } from "@libsql/client";
2718
2856
  function initShardManager(encryptionKey) {
2719
2857
  _encryptionKey = encryptionKey;
@@ -2777,7 +2915,7 @@ async function auditShardHealth(options = {}) {
2777
2915
  const shards = [];
2778
2916
  for (const name of names) {
2779
2917
  const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
2780
- const stat = statSync2(dbPath);
2918
+ const stat = statSync3(dbPath);
2781
2919
  const item = {
2782
2920
  name,
2783
2921
  path: dbPath,
@@ -3030,7 +3168,7 @@ async function getReadyShardClient(projectName) {
3030
3168
  _shardLastAccess.delete(safeName);
3031
3169
  const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
3032
3170
  if (existsSync7(dbPath)) {
3033
- const stat = statSync2(dbPath);
3171
+ const stat = statSync3(dbPath);
3034
3172
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
3035
3173
  const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
3036
3174
  renameSync3(dbPath, archivedPath);
@@ -3150,6 +3288,12 @@ var init_platform_procedures = __esm({
3150
3288
  priority: "p0",
3151
3289
  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."
3152
3290
  },
3291
+ {
3292
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
3293
+ domain: "workflow",
3294
+ priority: "p1",
3295
+ 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."
3296
+ },
3153
3297
  {
3154
3298
  title: "Single dispatch path \u2014 create_task only",
3155
3299
  domain: "workflow",
@@ -3208,6 +3352,12 @@ var init_platform_procedures = __esm({
3208
3352
  priority: "p0",
3209
3353
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
3210
3354
  },
3355
+ {
3356
+ title: "Commit discipline \u2014 never leave verified work floating",
3357
+ domain: "workflow",
3358
+ priority: "p1",
3359
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
3360
+ },
3211
3361
  {
3212
3362
  title: "Desktop and TUI are the same product",
3213
3363
  domain: "architecture",
@@ -3378,11 +3528,12 @@ init_database();
3378
3528
 
3379
3529
  // src/lib/keychain.ts
3380
3530
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3381
- import { existsSync as existsSync6 } from "fs";
3531
+ import { existsSync as existsSync6, statSync as statSync2 } from "fs";
3382
3532
  import { execSync as execSync2 } from "child_process";
3383
3533
  import path6 from "path";
3384
3534
  import os5 from "os";
3385
- var SERVICE = "exe-mem";
3535
+ var SERVICE = "exe-os";
3536
+ var LEGACY_SERVICE = "exe-mem";
3386
3537
  var ACCOUNT = "master-key";
3387
3538
  function getKeyDir() {
3388
3539
  return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path6.join(os5.homedir(), ".exe-os");
@@ -3390,29 +3541,66 @@ function getKeyDir() {
3390
3541
  function getKeyPath() {
3391
3542
  return path6.join(getKeyDir(), "master.key");
3392
3543
  }
3393
- function macKeychainGet() {
3544
+ function nativeKeychainAllowed() {
3545
+ return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
3546
+ }
3547
+ var linuxSecretAvailability = null;
3548
+ function linuxSecretAvailable() {
3549
+ if (!nativeKeychainAllowed()) return false;
3550
+ if (process.platform !== "linux") return false;
3551
+ if (linuxSecretAvailability !== null) return linuxSecretAvailability;
3552
+ try {
3553
+ execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
3554
+ } catch {
3555
+ linuxSecretAvailability = false;
3556
+ return false;
3557
+ }
3558
+ try {
3559
+ execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
3560
+ linuxSecretAvailability = true;
3561
+ } catch {
3562
+ linuxSecretAvailability = false;
3563
+ }
3564
+ return linuxSecretAvailability;
3565
+ }
3566
+ function isRootOnlyTrustedServerKeyFile(keyPath) {
3567
+ if (process.platform !== "linux") return false;
3568
+ try {
3569
+ const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
3570
+ const st = statSync2(keyPath);
3571
+ if (!st.isFile() || (st.mode & 63) !== 0) return false;
3572
+ if (uid === 0) return true;
3573
+ const exeOsDir = process.env.EXE_OS_DIR;
3574
+ return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
3575
+ } catch {
3576
+ return false;
3577
+ }
3578
+ }
3579
+ function macKeychainGet(service = SERVICE) {
3580
+ if (!nativeKeychainAllowed()) return null;
3394
3581
  if (process.platform !== "darwin") return null;
3395
3582
  try {
3396
3583
  return execSync2(
3397
- `security find-generic-password -s "${SERVICE}" -a "${ACCOUNT}" -w 2>/dev/null`,
3584
+ `security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
3398
3585
  { encoding: "utf-8", timeout: 5e3 }
3399
3586
  ).trim();
3400
3587
  } catch {
3401
3588
  return null;
3402
3589
  }
3403
3590
  }
3404
- function macKeychainSet(value) {
3591
+ function macKeychainSet(value, service = SERVICE) {
3592
+ if (!nativeKeychainAllowed()) return false;
3405
3593
  if (process.platform !== "darwin") return false;
3406
3594
  try {
3407
3595
  try {
3408
3596
  execSync2(
3409
- `security delete-generic-password -s "${SERVICE}" -a "${ACCOUNT}" 2>/dev/null`,
3597
+ `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3410
3598
  { timeout: 5e3 }
3411
3599
  );
3412
3600
  } catch {
3413
3601
  }
3414
3602
  execSync2(
3415
- `security add-generic-password -s "${SERVICE}" -a "${ACCOUNT}" -w "${value}"`,
3603
+ `security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
3416
3604
  { timeout: 5e3 }
3417
3605
  );
3418
3606
  return true;
@@ -3420,22 +3608,48 @@ function macKeychainSet(value) {
3420
3608
  return false;
3421
3609
  }
3422
3610
  }
3423
- function linuxSecretGet() {
3424
- if (process.platform !== "linux") return null;
3611
+ function macKeychainDelete(service = SERVICE) {
3612
+ if (!nativeKeychainAllowed()) return false;
3613
+ if (process.platform !== "darwin") return false;
3614
+ try {
3615
+ execSync2(
3616
+ `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3617
+ { timeout: 5e3 }
3618
+ );
3619
+ return true;
3620
+ } catch {
3621
+ return false;
3622
+ }
3623
+ }
3624
+ function linuxSecretGet(service = SERVICE) {
3625
+ if (!linuxSecretAvailable()) return null;
3425
3626
  try {
3426
3627
  return execSync2(
3427
- `secret-tool lookup service "${SERVICE}" account "${ACCOUNT}" 2>/dev/null`,
3628
+ `secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3428
3629
  { encoding: "utf-8", timeout: 5e3 }
3429
3630
  ).trim();
3430
3631
  } catch {
3431
3632
  return null;
3432
3633
  }
3433
3634
  }
3434
- function linuxSecretSet(value) {
3635
+ function linuxSecretSet(value, service = SERVICE) {
3636
+ if (!linuxSecretAvailable()) return false;
3637
+ try {
3638
+ execSync2(
3639
+ `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3640
+ { timeout: 5e3 }
3641
+ );
3642
+ return true;
3643
+ } catch {
3644
+ return false;
3645
+ }
3646
+ }
3647
+ function linuxSecretDelete(service = SERVICE) {
3648
+ if (!nativeKeychainAllowed()) return false;
3435
3649
  if (process.platform !== "linux") return false;
3436
3650
  try {
3437
3651
  execSync2(
3438
- `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${SERVICE}" account "${ACCOUNT}"`,
3652
+ `secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3439
3653
  { timeout: 5e3 }
3440
3654
  );
3441
3655
  return true;
@@ -3444,6 +3658,7 @@ function linuxSecretSet(value) {
3444
3658
  }
3445
3659
  }
3446
3660
  async function tryKeytar() {
3661
+ if (!nativeKeychainAllowed()) return null;
3447
3662
  try {
3448
3663
  return await import("keytar");
3449
3664
  } catch {
@@ -3518,7 +3733,19 @@ async function writeMachineBoundFileFallback(b64) {
3518
3733
  return "plaintext";
3519
3734
  }
3520
3735
  async function getMasterKey() {
3521
- const nativeValue = macKeychainGet() ?? linuxSecretGet();
3736
+ let nativeValue = macKeychainGet() ?? linuxSecretGet();
3737
+ if (!nativeValue) {
3738
+ const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
3739
+ if (legacyValue) {
3740
+ const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
3741
+ if (migrated) {
3742
+ macKeychainDelete(LEGACY_SERVICE);
3743
+ linuxSecretDelete(LEGACY_SERVICE);
3744
+ process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
3745
+ }
3746
+ nativeValue = legacyValue;
3747
+ }
3748
+ }
3522
3749
  if (nativeValue) {
3523
3750
  return Buffer.from(nativeValue, "base64");
3524
3751
  }
@@ -3526,12 +3753,17 @@ async function getMasterKey() {
3526
3753
  if (keytar) {
3527
3754
  try {
3528
3755
  const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
3529
- if (keytarValue) {
3530
- const migrated = macKeychainSet(keytarValue) || linuxSecretSet(keytarValue);
3756
+ const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
3757
+ if (legacyKeytarValue) {
3758
+ const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
3531
3759
  if (migrated) {
3532
3760
  process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
3761
+ try {
3762
+ await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
3763
+ } catch {
3764
+ }
3533
3765
  }
3534
- return Buffer.from(keytarValue, "base64");
3766
+ return Buffer.from(legacyKeytarValue, "base64");
3535
3767
  }
3536
3768
  } catch {
3537
3769
  }
@@ -3556,7 +3788,7 @@ async function getMasterKey() {
3556
3788
  const decrypted = decryptWithMachineKey(content, machineKey);
3557
3789
  if (!decrypted) {
3558
3790
  process.stderr.write(
3559
- "[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os link import\n"
3791
+ "[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
3560
3792
  );
3561
3793
  return null;
3562
3794
  }
@@ -3565,6 +3797,9 @@ async function getMasterKey() {
3565
3797
  b64Value = content;
3566
3798
  }
3567
3799
  const key = Buffer.from(b64Value, "base64");
3800
+ if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
3801
+ return key;
3802
+ }
3568
3803
  const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
3569
3804
  if (migrated) {
3570
3805
  process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
@@ -138,6 +138,11 @@ function normalizeAutoUpdate(raw) {
138
138
  const userAU = raw.autoUpdate ?? {};
139
139
  raw.autoUpdate = { ...defaultAU, ...userAU };
140
140
  }
141
+ function normalizeOrchestration(raw) {
142
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
143
+ const userOrg = raw.orchestration ?? {};
144
+ raw.orchestration = { ...defaultOrg, ...userOrg };
145
+ }
141
146
  async function loadConfig() {
142
147
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
143
148
  await ensurePrivateDir(dir);
@@ -162,10 +167,15 @@ async function loadConfig() {
162
167
  normalizeScalingRoadmap(migratedCfg);
163
168
  normalizeSessionLifecycle(migratedCfg);
164
169
  normalizeAutoUpdate(migratedCfg);
170
+ normalizeOrchestration(migratedCfg);
165
171
  const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
166
172
  if (config.dbPath.startsWith("~")) {
167
173
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
168
174
  }
175
+ const envDbPath = path.join(dir, "memories.db");
176
+ if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
177
+ config.dbPath = envDbPath;
178
+ }
169
179
  return config;
170
180
  } catch {
171
181
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -185,7 +195,16 @@ function loadConfigSync() {
185
195
  normalizeScalingRoadmap(migratedCfg);
186
196
  normalizeSessionLifecycle(migratedCfg);
187
197
  normalizeAutoUpdate(migratedCfg);
188
- return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
198
+ normalizeOrchestration(migratedCfg);
199
+ const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
200
+ if (config.dbPath.startsWith("~")) {
201
+ config.dbPath = config.dbPath.replace(/^~/, os.homedir());
202
+ }
203
+ const envDbPath = path.join(dir, "memories.db");
204
+ if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
205
+ config.dbPath = envDbPath;
206
+ }
207
+ return config;
189
208
  } catch {
190
209
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
191
210
  }
@@ -206,6 +225,7 @@ async function loadConfigFrom(configPath) {
206
225
  normalizeScalingRoadmap(migratedCfg);
207
226
  normalizeSessionLifecycle(migratedCfg);
208
227
  normalizeAutoUpdate(migratedCfg);
228
+ normalizeOrchestration(migratedCfg);
209
229
  return { ...DEFAULT_CONFIG, ...migratedCfg };
210
230
  } catch {
211
231
  return { ...DEFAULT_CONFIG };
@@ -277,6 +297,10 @@ var init_config = __esm({
277
297
  checkOnBoot: true,
278
298
  autoInstall: false,
279
299
  checkIntervalMs: 24 * 60 * 60 * 1e3
300
+ },
301
+ orchestration: {
302
+ phase: "phase_1_coo",
303
+ phaseSetBy: "default"
280
304
  }
281
305
  };
282
306
  CONFIG_MIGRATIONS = [
@@ -884,6 +908,9 @@ function getClient() {
884
908
  if (_daemonClient && _daemonClient._isDaemonActive()) {
885
909
  return _daemonClient;
886
910
  }
911
+ if (!_resilientClient) {
912
+ return _adapterClient;
913
+ }
887
914
  return _resilientClient;
888
915
  }
889
916
 
@@ -60,6 +60,8 @@ async function generateStatusBrief(employees, data, _activeAgentIds) {
60
60
  }
61
61
  const sections = [];
62
62
  sections.push([` EXE STATUS BRIEF \u2014 ${dateStr}${sessionTag}`]);
63
+ const orchestrationLines = buildOrchestrationPhase(data, employees);
64
+ if (orchestrationLines.length > 0) sections.push(orchestrationLines);
63
65
  const reminderLines = buildReminders(data);
64
66
  if (reminderLines.length > 0) sections.push(reminderLines);
65
67
  const actionLines = buildActionRequired(data);
@@ -102,6 +104,11 @@ function buildFirstBootBrief(employees, dateStr, sessionTag) {
102
104
  bodyLines.push(` ${emoji} ${emp.name}${role}`);
103
105
  }
104
106
  bodyLines.push("");
107
+ bodyLines.push(" \u{1F9ED} Orchestration:");
108
+ bodyLines.push(" \u2022 Phase 1 \u2014 COO / Chief of Staff mode");
109
+ bodyLines.push(" \u2022 Recommended start: build company context first");
110
+ bodyLines.push(" \u2022 You can unlock executives or parallel mode anytime");
111
+ bodyLines.push("");
105
112
  bodyLines.push(" \u{1F4A1} Quick start:");
106
113
  bodyLines.push(" \u2022 Run `exe-os backfill-conversations` to import Claude Code history");
107
114
  bodyLines.push(" \u2022 Say `/exe` to launch your COO with a full status brief");
@@ -132,6 +139,38 @@ function buildReminders(data) {
132
139
  }
133
140
  return lines;
134
141
  }
142
+ function buildOrchestrationPhase(data, employees) {
143
+ if (!data.orchestrationPhase) return [];
144
+ const phase = data.orchestrationPhase;
145
+ const hasExecutiveBench = employees.some((e) => ["cto", "cmo"].includes(e.role.toLowerCase()));
146
+ const openWorkCount = data.globalTasks.filter((t) => t.status === "open" || t.status === "in_progress").length;
147
+ const domainKeywordHits = data.globalTasks.filter(
148
+ (t) => /\b(api|bug|code|repo|build|deploy|design|brand|copy|content|marketing|legal|finance|sales|crm)\b/i.test(t.title)
149
+ ).length;
150
+ const phase1Signal = !hasExecutiveBench && (openWorkCount >= 3 || domainKeywordHits >= 2);
151
+ if (phase === "phase_2_executives") {
152
+ return [
153
+ "\u{1F9ED} ORCHESTRATION",
154
+ " Phase 2 \u2014 Executive bench",
155
+ " Focus: COO works with CTO/CMO/domain executives before specialist fan-out",
156
+ " You can switch phases anytime: exe-os org phase"
157
+ ];
158
+ }
159
+ if (phase === "phase_3_parallel_org") {
160
+ return [
161
+ "\u{1F9ED} ORCHESTRATION",
162
+ " Phase 3 \u2014 Parallel execution org",
163
+ " Focus: executives can delegate to specialists in parallel with review gates",
164
+ " You can switch phases anytime: exe-os org phase"
165
+ ];
166
+ }
167
+ return [
168
+ "\u{1F9ED} ORCHESTRATION",
169
+ " Phase 1 \u2014 COO / Chief of Staff mode",
170
+ " Focus: building company context before delegation",
171
+ phase1Signal ? " Signal: repeated domain work detected. Consider: exe-os org unlock executives" : " Ready later? exe-os org unlock executives"
172
+ ];
173
+ }
135
174
  function buildActionRequired(data) {
136
175
  const lines = [];
137
176
  let hasIssues = false;