@askexenow/exe-os 0.9.66 → 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 (99) 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} +1523 -2275
  6. package/dist/bin/backfill-conversations.js +506 -20
  7. package/dist/bin/backfill-responses.js +506 -20
  8. package/dist/bin/backfill-vectors.js +233 -20
  9. package/dist/bin/bulk-sync-postgres.js +4876 -0
  10. package/dist/bin/cleanup-stale-review-tasks.js +507 -21
  11. package/dist/bin/cli.js +2450 -1530
  12. package/dist/bin/exe-assign.js +506 -20
  13. package/dist/bin/exe-boot.js +410 -60
  14. package/dist/bin/exe-cloud.js +795 -105
  15. package/dist/bin/exe-dispatch.js +516 -22
  16. package/dist/bin/exe-doctor.js +587 -30
  17. package/dist/bin/exe-export-behaviors.js +518 -24
  18. package/dist/bin/exe-forget.js +507 -21
  19. package/dist/bin/exe-gateway.js +571 -25
  20. package/dist/bin/exe-heartbeat.js +518 -24
  21. package/dist/bin/exe-kill.js +507 -21
  22. package/dist/bin/exe-launch-agent.js +2312 -1069
  23. package/dist/bin/exe-new-employee.js +197 -165
  24. package/dist/bin/exe-pending-messages.js +507 -21
  25. package/dist/bin/exe-pending-notifications.js +507 -21
  26. package/dist/bin/exe-pending-reviews.js +507 -21
  27. package/dist/bin/exe-rename.js +507 -21
  28. package/dist/bin/exe-review.js +507 -21
  29. package/dist/bin/exe-search.js +518 -24
  30. package/dist/bin/exe-session-cleanup.js +516 -22
  31. package/dist/bin/exe-settings.js +4 -0
  32. package/dist/bin/exe-start-codex.js +682 -143
  33. package/dist/bin/exe-start-opencode.js +627 -79
  34. package/dist/bin/exe-status.js +507 -21
  35. package/dist/bin/exe-team.js +507 -21
  36. package/dist/bin/git-sweep.js +516 -22
  37. package/dist/bin/graph-backfill.js +558 -21
  38. package/dist/bin/graph-export.js +507 -21
  39. package/dist/bin/graph-layer-benchmark.js +109 -0
  40. package/dist/bin/install.js +305 -288
  41. package/dist/bin/intercom-check.js +516 -22
  42. package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
  43. package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
  44. package/dist/bin/scan-tasks.js +516 -22
  45. package/dist/bin/setup.js +412 -62
  46. package/dist/bin/shard-migrate.js +506 -20
  47. package/dist/gateway/index.js +569 -23
  48. package/dist/hooks/bug-report-worker.js +519 -25
  49. package/dist/hooks/codex-stop-task-finalizer.js +516 -22
  50. package/dist/hooks/commit-complete.js +516 -22
  51. package/dist/hooks/error-recall.js +518 -24
  52. package/dist/hooks/ingest.js +516 -22
  53. package/dist/hooks/instructions-loaded.js +507 -21
  54. package/dist/hooks/notification.js +507 -21
  55. package/dist/hooks/post-compact.js +507 -21
  56. package/dist/hooks/post-tool-combined.js +519 -25
  57. package/dist/hooks/pre-compact.js +516 -22
  58. package/dist/hooks/pre-tool-use.js +507 -21
  59. package/dist/hooks/prompt-submit.js +519 -25
  60. package/dist/hooks/session-end.js +516 -22
  61. package/dist/hooks/session-start.js +520 -26
  62. package/dist/hooks/stop.js +517 -23
  63. package/dist/hooks/subagent-stop.js +507 -21
  64. package/dist/hooks/summary-worker.js +411 -61
  65. package/dist/index.js +569 -23
  66. package/dist/lib/cloud-sync.js +391 -53
  67. package/dist/lib/config.js +13 -1
  68. package/dist/lib/consolidation.js +1 -1
  69. package/dist/lib/database.js +124 -0
  70. package/dist/lib/db.js +124 -0
  71. package/dist/lib/device-registry.js +124 -0
  72. package/dist/lib/embedder.js +13 -1
  73. package/dist/lib/exe-daemon.js +2184 -561
  74. package/dist/lib/hybrid-search.js +518 -24
  75. package/dist/lib/identity.js +3 -0
  76. package/dist/lib/keychain.js +178 -22
  77. package/dist/lib/messaging.js +3 -0
  78. package/dist/lib/reminders.js +3 -0
  79. package/dist/lib/schedules.js +233 -20
  80. package/dist/lib/skill-learning.js +16 -1
  81. package/dist/lib/store.js +506 -20
  82. package/dist/lib/tasks.js +16 -1
  83. package/dist/lib/tmux-routing.js +16 -1
  84. package/dist/lib/token-spend.js +3 -0
  85. package/dist/mcp/server.js +1757 -428
  86. package/dist/mcp/tools/complete-reminder.js +3 -0
  87. package/dist/mcp/tools/create-reminder.js +3 -0
  88. package/dist/mcp/tools/create-task.js +16 -1
  89. package/dist/mcp/tools/deactivate-behavior.js +3 -0
  90. package/dist/mcp/tools/list-reminders.js +3 -0
  91. package/dist/mcp/tools/list-tasks.js +3 -0
  92. package/dist/mcp/tools/send-message.js +3 -0
  93. package/dist/mcp/tools/update-task.js +16 -1
  94. package/dist/runtime/index.js +516 -22
  95. package/dist/tui/App.js +594 -29
  96. package/package.json +8 -5
  97. package/src/commands/exe/cloud.md +6 -10
  98. package/stack.release.json +3 -3
  99. package/src/commands/exe/link.md +0 -18
@@ -212,6 +212,10 @@ async function loadConfig() {
212
212
  if (config.dbPath.startsWith("~")) {
213
213
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
214
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
+ }
215
219
  return config;
216
220
  } catch {
217
221
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -1528,6 +1532,9 @@ function getClient() {
1528
1532
  if (_daemonClient && _daemonClient._isDaemonActive()) {
1529
1533
  return _daemonClient;
1530
1534
  }
1535
+ if (!_resilientClient) {
1536
+ return _adapterClient;
1537
+ }
1531
1538
  return _resilientClient;
1532
1539
  }
1533
1540
  async function initDaemonClient() {
@@ -2560,6 +2567,127 @@ async function ensureSchema() {
2560
2567
  VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
2561
2568
  END;
2562
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
+ `);
2563
2691
  try {
2564
2692
  await client.execute({
2565
2693
  sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
@@ -2723,7 +2851,7 @@ __export(shard_manager_exports, {
2723
2851
  shardExists: () => shardExists
2724
2852
  });
2725
2853
  import path7 from "path";
2726
- 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";
2727
2855
  import { createClient as createClient2 } from "@libsql/client";
2728
2856
  function initShardManager(encryptionKey) {
2729
2857
  _encryptionKey = encryptionKey;
@@ -2787,7 +2915,7 @@ async function auditShardHealth(options = {}) {
2787
2915
  const shards = [];
2788
2916
  for (const name of names) {
2789
2917
  const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
2790
- const stat = statSync2(dbPath);
2918
+ const stat = statSync3(dbPath);
2791
2919
  const item = {
2792
2920
  name,
2793
2921
  path: dbPath,
@@ -3040,7 +3168,7 @@ async function getReadyShardClient(projectName) {
3040
3168
  _shardLastAccess.delete(safeName);
3041
3169
  const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
3042
3170
  if (existsSync7(dbPath)) {
3043
- const stat = statSync2(dbPath);
3171
+ const stat = statSync3(dbPath);
3044
3172
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
3045
3173
  const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
3046
3174
  renameSync3(dbPath, archivedPath);
@@ -3400,11 +3528,12 @@ init_database();
3400
3528
 
3401
3529
  // src/lib/keychain.ts
3402
3530
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3403
- import { existsSync as existsSync6 } from "fs";
3531
+ import { existsSync as existsSync6, statSync as statSync2 } from "fs";
3404
3532
  import { execSync as execSync2 } from "child_process";
3405
3533
  import path6 from "path";
3406
3534
  import os5 from "os";
3407
- var SERVICE = "exe-mem";
3535
+ var SERVICE = "exe-os";
3536
+ var LEGACY_SERVICE = "exe-mem";
3408
3537
  var ACCOUNT = "master-key";
3409
3538
  function getKeyDir() {
3410
3539
  return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path6.join(os5.homedir(), ".exe-os");
@@ -3412,29 +3541,79 @@ function getKeyDir() {
3412
3541
  function getKeyPath() {
3413
3542
  return path6.join(getKeyDir(), "master.key");
3414
3543
  }
3415
- 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;
3416
3581
  if (process.platform !== "darwin") return null;
3417
3582
  try {
3418
3583
  return execSync2(
3419
- `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`,
3420
3585
  { encoding: "utf-8", timeout: 5e3 }
3421
3586
  ).trim();
3422
3587
  } catch {
3423
3588
  return null;
3424
3589
  }
3425
3590
  }
3426
- function macKeychainSet(value) {
3591
+ function macKeychainSet(value, service = SERVICE) {
3592
+ if (!nativeKeychainAllowed()) return false;
3427
3593
  if (process.platform !== "darwin") return false;
3428
3594
  try {
3429
3595
  try {
3430
3596
  execSync2(
3431
- `security delete-generic-password -s "${SERVICE}" -a "${ACCOUNT}" 2>/dev/null`,
3597
+ `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3432
3598
  { timeout: 5e3 }
3433
3599
  );
3434
3600
  } catch {
3435
3601
  }
3436
3602
  execSync2(
3437
- `security add-generic-password -s "${SERVICE}" -a "${ACCOUNT}" -w "${value}"`,
3603
+ `security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
3604
+ { timeout: 5e3 }
3605
+ );
3606
+ return true;
3607
+ } catch {
3608
+ return false;
3609
+ }
3610
+ }
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`,
3438
3617
  { timeout: 5e3 }
3439
3618
  );
3440
3619
  return true;
@@ -3442,22 +3621,35 @@ function macKeychainSet(value) {
3442
3621
  return false;
3443
3622
  }
3444
3623
  }
3445
- function linuxSecretGet() {
3446
- if (process.platform !== "linux") return null;
3624
+ function linuxSecretGet(service = SERVICE) {
3625
+ if (!linuxSecretAvailable()) return null;
3447
3626
  try {
3448
3627
  return execSync2(
3449
- `secret-tool lookup service "${SERVICE}" account "${ACCOUNT}" 2>/dev/null`,
3628
+ `secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3450
3629
  { encoding: "utf-8", timeout: 5e3 }
3451
3630
  ).trim();
3452
3631
  } catch {
3453
3632
  return null;
3454
3633
  }
3455
3634
  }
3456
- 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;
3457
3649
  if (process.platform !== "linux") return false;
3458
3650
  try {
3459
3651
  execSync2(
3460
- `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`,
3461
3653
  { timeout: 5e3 }
3462
3654
  );
3463
3655
  return true;
@@ -3466,6 +3658,7 @@ function linuxSecretSet(value) {
3466
3658
  }
3467
3659
  }
3468
3660
  async function tryKeytar() {
3661
+ if (!nativeKeychainAllowed()) return null;
3469
3662
  try {
3470
3663
  return await import("keytar");
3471
3664
  } catch {
@@ -3540,7 +3733,19 @@ async function writeMachineBoundFileFallback(b64) {
3540
3733
  return "plaintext";
3541
3734
  }
3542
3735
  async function getMasterKey() {
3543
- 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
+ }
3544
3749
  if (nativeValue) {
3545
3750
  return Buffer.from(nativeValue, "base64");
3546
3751
  }
@@ -3548,12 +3753,17 @@ async function getMasterKey() {
3548
3753
  if (keytar) {
3549
3754
  try {
3550
3755
  const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
3551
- if (keytarValue) {
3552
- 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);
3553
3759
  if (migrated) {
3554
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
+ }
3555
3765
  }
3556
- return Buffer.from(keytarValue, "base64");
3766
+ return Buffer.from(legacyKeytarValue, "base64");
3557
3767
  }
3558
3768
  } catch {
3559
3769
  }
@@ -3578,7 +3788,7 @@ async function getMasterKey() {
3578
3788
  const decrypted = decryptWithMachineKey(content, machineKey);
3579
3789
  if (!decrypted) {
3580
3790
  process.stderr.write(
3581
- "[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"
3582
3792
  );
3583
3793
  return null;
3584
3794
  }
@@ -3587,6 +3797,9 @@ async function getMasterKey() {
3587
3797
  b64Value = content;
3588
3798
  }
3589
3799
  const key = Buffer.from(b64Value, "base64");
3800
+ if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
3801
+ return key;
3802
+ }
3590
3803
  const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
3591
3804
  if (migrated) {
3592
3805
  process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
@@ -172,6 +172,10 @@ async function loadConfig() {
172
172
  if (config.dbPath.startsWith("~")) {
173
173
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
174
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
+ }
175
179
  return config;
176
180
  } catch {
177
181
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -192,7 +196,15 @@ function loadConfigSync() {
192
196
  normalizeSessionLifecycle(migratedCfg);
193
197
  normalizeAutoUpdate(migratedCfg);
194
198
  normalizeOrchestration(migratedCfg);
195
- return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...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;
196
208
  } catch {
197
209
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
198
210
  }
@@ -896,6 +908,9 @@ function getClient() {
896
908
  if (_daemonClient && _daemonClient._isDaemonActive()) {
897
909
  return _daemonClient;
898
910
  }
911
+ if (!_resilientClient) {
912
+ return _adapterClient;
913
+ }
899
914
  return _resilientClient;
900
915
  }
901
916