@askexenow/exe-os 0.8.61 → 0.8.63

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 (62) hide show
  1. package/dist/bin/backfill-conversations.js +2 -3
  2. package/dist/bin/backfill-responses.js +3 -4
  3. package/dist/bin/backfill-vectors.js +0 -1
  4. package/dist/bin/cleanup-stale-review-tasks.js +0 -1
  5. package/dist/bin/cli.js +1654 -397
  6. package/dist/bin/exe-assign.js +0 -1
  7. package/dist/bin/exe-boot.js +61 -84
  8. package/dist/bin/exe-cloud.js +28 -60
  9. package/dist/bin/exe-dispatch.js +0 -1
  10. package/dist/bin/exe-doctor.js +0 -1
  11. package/dist/bin/exe-export-behaviors.js +1 -2
  12. package/dist/bin/exe-forget.js +0 -1
  13. package/dist/bin/exe-gateway.js +16 -17
  14. package/dist/bin/exe-heartbeat.js +1 -2
  15. package/dist/bin/exe-kill.js +2 -3
  16. package/dist/bin/exe-launch-agent.js +1 -2
  17. package/dist/bin/exe-link.js +49 -78
  18. package/dist/bin/exe-pending-messages.js +1 -2
  19. package/dist/bin/exe-pending-notifications.js +0 -1
  20. package/dist/bin/exe-pending-reviews.js +1 -2
  21. package/dist/bin/exe-review.js +0 -1
  22. package/dist/bin/exe-search.js +2 -3
  23. package/dist/bin/exe-session-cleanup.js +4 -5
  24. package/dist/bin/exe-status.js +0 -1
  25. package/dist/bin/exe-team.js +0 -1
  26. package/dist/bin/git-sweep.js +0 -1
  27. package/dist/bin/graph-backfill.js +5 -6
  28. package/dist/bin/graph-export.js +0 -1
  29. package/dist/bin/scan-tasks.js +0 -1
  30. package/dist/bin/setup.js +1460 -115
  31. package/dist/bin/shard-migrate.js +0 -1
  32. package/dist/bin/wiki-sync.js +0 -1
  33. package/dist/gateway/index.js +16 -17
  34. package/dist/hooks/bug-report-worker.js +11 -12
  35. package/dist/hooks/commit-complete.js +0 -1
  36. package/dist/hooks/error-recall.js +2 -3
  37. package/dist/hooks/ingest-worker.js +14 -15
  38. package/dist/hooks/instructions-loaded.js +0 -1
  39. package/dist/hooks/notification.js +0 -1
  40. package/dist/hooks/post-compact.js +0 -1
  41. package/dist/hooks/pre-compact.js +2 -3
  42. package/dist/hooks/pre-tool-use.js +0 -1
  43. package/dist/hooks/prompt-ingest-worker.js +2 -3
  44. package/dist/hooks/prompt-submit.js +6 -7
  45. package/dist/hooks/response-ingest-worker.js +2 -3
  46. package/dist/hooks/session-end.js +3 -4
  47. package/dist/hooks/session-start.js +2 -3
  48. package/dist/hooks/stop.js +2 -3
  49. package/dist/hooks/subagent-stop.js +0 -1
  50. package/dist/hooks/summary-worker.js +51 -74
  51. package/dist/index.js +7 -8
  52. package/dist/lib/cloud-sync.js +21 -12
  53. package/dist/lib/consolidation.js +0 -1
  54. package/dist/lib/exe-daemon.js +33 -65
  55. package/dist/lib/hybrid-search.js +2 -3
  56. package/dist/lib/keychain.js +19 -58
  57. package/dist/lib/schedules.js +2 -3
  58. package/dist/lib/store.js +0 -1
  59. package/dist/mcp/server.js +29 -30
  60. package/dist/runtime/index.js +2 -3
  61. package/dist/tui/App.js +24 -56
  62. package/package.json +1 -1
@@ -2022,7 +2022,6 @@ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3
2022
2022
  import { existsSync as existsSync4 } from "fs";
2023
2023
  import path4 from "path";
2024
2024
  import os2 from "os";
2025
- import crypto from "crypto";
2026
2025
  var SERVICE = "exe-mem";
2027
2026
  var ACCOUNT = "master-key";
2028
2027
  function getKeyDir() {
@@ -1472,7 +1472,6 @@ import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3
1472
1472
  import { existsSync as existsSync3 } from "fs";
1473
1473
  import path3 from "path";
1474
1474
  import os2 from "os";
1475
- import crypto from "crypto";
1476
1475
  function getKeyDir() {
1477
1476
  return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os2.homedir(), ".exe-os");
1478
1477
  }
@@ -1537,65 +1536,34 @@ async function deleteMasterKey() {
1537
1536
  await unlink(keyPath);
1538
1537
  }
1539
1538
  }
1540
- function exportMnemonic(key) {
1541
- if (key.length !== 32) {
1542
- throw new Error(`Key must be 32 bytes, got ${key.length}`);
1543
- }
1544
- const hash = crypto.createHash("sha256").update(key).digest();
1545
- const checksumByte = hash[0];
1546
- let bits = "";
1547
- for (const byte of key) {
1548
- bits += byte.toString(2).padStart(8, "0");
1549
- }
1550
- bits += checksumByte.toString(2).padStart(8, "0");
1551
- const words = [];
1552
- let wordlist;
1539
+ async function loadBip39() {
1553
1540
  try {
1554
- const bip39 = __require("bip39");
1555
- wordlist = bip39.wordlists?.english ?? bip39.default?.wordlists?.english;
1556
- if (!wordlist) throw new Error("no wordlist");
1541
+ return await import("bip39");
1557
1542
  } catch {
1558
- throw new Error("bip39 package required. Install with: npm install bip39");
1543
+ throw new Error(
1544
+ "bip39 package not found. Run: npm install -g bip39\nOr reinstall exe-os: npm install -g @askexenow/exe-os"
1545
+ );
1559
1546
  }
1560
- for (let i = 0; i < 264; i += 11) {
1561
- const index = parseInt(bits.slice(i, i + 11), 2);
1562
- words.push(wordlist[index]);
1547
+ }
1548
+ async function exportMnemonic(key) {
1549
+ if (key.length !== 32) {
1550
+ throw new Error(`Key must be 32 bytes, got ${key.length}`);
1563
1551
  }
1564
- return words.join(" ");
1552
+ const { entropyToMnemonic } = await loadBip39();
1553
+ return entropyToMnemonic(key.toString("hex"));
1565
1554
  }
1566
- function importMnemonic(mnemonic) {
1567
- const words = mnemonic.trim().split(/\s+/);
1555
+ async function importMnemonic(mnemonic) {
1556
+ const trimmed = mnemonic.trim();
1557
+ const words = trimmed.split(/\s+/);
1568
1558
  if (words.length !== 24) {
1569
1559
  throw new Error(`Expected 24 words, got ${words.length}`);
1570
1560
  }
1571
- let wordlist;
1572
- try {
1573
- const bip39 = __require("bip39");
1574
- wordlist = bip39.wordlists?.english ?? bip39.default?.wordlists?.english;
1575
- if (!wordlist) throw new Error("no wordlist");
1576
- } catch {
1577
- throw new Error("bip39 package required. Install with: npm install bip39");
1561
+ const { validateMnemonic, mnemonicToEntropy } = await loadBip39();
1562
+ if (!validateMnemonic(trimmed)) {
1563
+ throw new Error("Invalid mnemonic \u2014 check for typos or missing words");
1578
1564
  }
1579
- let bits = "";
1580
- for (const word of words) {
1581
- const index = wordlist.indexOf(word.toLowerCase());
1582
- if (index === -1) {
1583
- throw new Error(`Invalid BIP39 word: "${word}"`);
1584
- }
1585
- bits += index.toString(2).padStart(11, "0");
1586
- }
1587
- const entropyBits = bits.slice(0, 256);
1588
- const checksumBits = bits.slice(256, 264);
1589
- const key = Buffer.alloc(32);
1590
- for (let i = 0; i < 32; i++) {
1591
- key[i] = parseInt(entropyBits.slice(i * 8, (i + 1) * 8), 2);
1592
- }
1593
- const hash = crypto.createHash("sha256").update(key).digest();
1594
- const expectedChecksum = hash[0].toString(2).padStart(8, "0");
1595
- if (checksumBits !== expectedChecksum) {
1596
- throw new Error("Invalid mnemonic checksum");
1597
- }
1598
- return key;
1565
+ const entropy = mnemonicToEntropy(trimmed);
1566
+ return Buffer.from(entropy, "hex");
1599
1567
  }
1600
1568
  var SERVICE, ACCOUNT;
1601
1569
  var init_keychain = __esm({
@@ -2781,7 +2749,7 @@ var init_plan_limits = __esm({
2781
2749
  });
2782
2750
 
2783
2751
  // src/lib/notifications.ts
2784
- import crypto2 from "crypto";
2752
+ import crypto from "crypto";
2785
2753
  import path9 from "path";
2786
2754
  import os5 from "os";
2787
2755
  import {
@@ -2794,7 +2762,7 @@ import {
2794
2762
  async function writeNotification(notification) {
2795
2763
  try {
2796
2764
  const client = getClient();
2797
- const id = crypto2.randomUUID();
2765
+ const id = crypto.randomUUID();
2798
2766
  const now = (/* @__PURE__ */ new Date()).toISOString();
2799
2767
  await client.execute({
2800
2768
  sql: `INSERT INTO notifications (id, agent_id, agent_role, event, project, summary, task_file, read, created_at)
@@ -2917,7 +2885,7 @@ async function migrateJsonNotifications() {
2917
2885
  sql: `INSERT OR IGNORE INTO notifications (id, agent_id, agent_role, event, project, summary, task_file, read, created_at)
2918
2886
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
2919
2887
  args: [
2920
- crypto2.randomUUID(),
2888
+ crypto.randomUUID(),
2921
2889
  data.agentId ?? "unknown",
2922
2890
  data.agentRole ?? "unknown",
2923
2891
  data.event ?? "session_summary",
@@ -2966,7 +2934,7 @@ __export(session_kill_telemetry_exports, {
2966
2934
  recordSessionKill: () => recordSessionKill,
2967
2935
  sumTokensSavedSince: () => sumTokensSavedSince
2968
2936
  });
2969
- import crypto3 from "crypto";
2937
+ import crypto2 from "crypto";
2970
2938
  async function recordSessionKill(input) {
2971
2939
  try {
2972
2940
  const client = getClient();
@@ -2976,7 +2944,7 @@ async function recordSessionKill(input) {
2976
2944
  ticks_idle, estimated_tokens_saved)
2977
2945
  VALUES (?, ?, ?, ?, ?, ?, ?)`,
2978
2946
  args: [
2979
- crypto3.randomUUID(),
2947
+ crypto2.randomUUID(),
2980
2948
  input.sessionName,
2981
2949
  input.agentId,
2982
2950
  (/* @__PURE__ */ new Date()).toISOString(),
@@ -3058,7 +3026,7 @@ var init_session_kill_telemetry = __esm({
3058
3026
  });
3059
3027
 
3060
3028
  // src/lib/tasks-crud.ts
3061
- import crypto4 from "crypto";
3029
+ import crypto3 from "crypto";
3062
3030
  import path10 from "path";
3063
3031
  import { execSync as execSync5 } from "child_process";
3064
3032
  import { mkdir as mkdir4, writeFile as writeFile4, appendFile } from "fs/promises";
@@ -3149,7 +3117,7 @@ async function resolveTask(client, identifier, scopeSession) {
3149
3117
  }
3150
3118
  async function createTaskCore(input) {
3151
3119
  const client = getClient();
3152
- const id = crypto4.randomUUID();
3120
+ const id = crypto3.randomUUID();
3153
3121
  const now = (/* @__PURE__ */ new Date()).toISOString();
3154
3122
  const slug = slugify(input.title);
3155
3123
  const taskFile = input.taskFile ?? `exe/${input.assignedTo}/${slug}.md`;
@@ -3944,10 +3912,10 @@ var init_tasks_notify = __esm({
3944
3912
  });
3945
3913
 
3946
3914
  // src/lib/behaviors.ts
3947
- import crypto5 from "crypto";
3915
+ import crypto4 from "crypto";
3948
3916
  async function storeBehavior(opts) {
3949
3917
  const client = getClient();
3950
- const id = crypto5.randomUUID();
3918
+ const id = crypto4.randomUUID();
3951
3919
  const now = (/* @__PURE__ */ new Date()).toISOString();
3952
3920
  await client.execute({
3953
3921
  sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at)
@@ -3976,7 +3944,7 @@ __export(skill_learning_exports, {
3976
3944
  storeTrajectory: () => storeTrajectory,
3977
3945
  sweepTrajectories: () => sweepTrajectories
3978
3946
  });
3979
- import crypto6 from "crypto";
3947
+ import crypto5 from "crypto";
3980
3948
  async function extractTrajectory(taskId, agentId) {
3981
3949
  const client = getClient();
3982
3950
  const result = await client.execute({
@@ -4005,11 +3973,11 @@ async function extractTrajectory(taskId, agentId) {
4005
3973
  return signature;
4006
3974
  }
4007
3975
  function hashSignature(signature) {
4008
- return crypto6.createHash("sha256").update(signature.join("|")).digest("hex").slice(0, 16);
3976
+ return crypto5.createHash("sha256").update(signature.join("|")).digest("hex").slice(0, 16);
4009
3977
  }
4010
3978
  async function storeTrajectory(opts) {
4011
3979
  const client = getClient();
4012
- const id = crypto6.randomUUID();
3980
+ const id = crypto5.randomUUID();
4013
3981
  const now = (/* @__PURE__ */ new Date()).toISOString();
4014
3982
  const signatureHash = hashSignature(opts.signature);
4015
3983
  await client.execute({
@@ -5647,13 +5615,13 @@ __export(crypto_exports, {
5647
5615
  initSyncCrypto: () => initSyncCrypto,
5648
5616
  isSyncCryptoInitialized: () => isSyncCryptoInitialized
5649
5617
  });
5650
- import crypto7 from "crypto";
5618
+ import crypto6 from "crypto";
5651
5619
  function initSyncCrypto(masterKey) {
5652
5620
  if (masterKey.length !== 32) {
5653
5621
  throw new Error(`Master key must be 32 bytes, got ${masterKey.length}`);
5654
5622
  }
5655
5623
  _syncKey = Buffer.from(
5656
- crypto7.hkdfSync("sha256", masterKey, "", SYNC_HKDF_INFO, 32)
5624
+ crypto6.hkdfSync("sha256", masterKey, "", SYNC_HKDF_INFO, 32)
5657
5625
  );
5658
5626
  }
5659
5627
  function isSyncCryptoInitialized() {
@@ -5667,8 +5635,8 @@ function requireSyncKey() {
5667
5635
  }
5668
5636
  function encryptSyncBlob(data) {
5669
5637
  const key = requireSyncKey();
5670
- const iv = crypto7.randomBytes(IV_LENGTH);
5671
- const cipher = crypto7.createCipheriv(ALGORITHM, key, iv);
5638
+ const iv = crypto6.randomBytes(IV_LENGTH);
5639
+ const cipher = crypto6.createCipheriv(ALGORITHM, key, iv);
5672
5640
  const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
5673
5641
  const tag = cipher.getAuthTag();
5674
5642
  return Buffer.concat([iv, encrypted, tag]).toString("base64");
@@ -5682,7 +5650,7 @@ function decryptSyncBlob(ciphertext) {
5682
5650
  const iv = combined.subarray(0, IV_LENGTH);
5683
5651
  const tag = combined.subarray(combined.length - TAG_LENGTH);
5684
5652
  const encrypted = combined.subarray(IV_LENGTH, combined.length - TAG_LENGTH);
5685
- const decipher = crypto7.createDecipheriv(ALGORITHM, key, iv);
5653
+ const decipher = crypto6.createDecipheriv(ALGORITHM, key, iv);
5686
5654
  decipher.setAuthTag(tag);
5687
5655
  return Buffer.concat([decipher.update(encrypted), decipher.final()]);
5688
5656
  }
@@ -5747,7 +5715,7 @@ __export(cloud_sync_exports, {
5747
5715
  recordRosterDeletion: () => recordRosterDeletion
5748
5716
  });
5749
5717
  import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, existsSync as existsSync15, readdirSync as readdirSync7, mkdirSync as mkdirSync9, appendFileSync as appendFileSync2, unlinkSync as unlinkSync7, openSync, closeSync } from "fs";
5750
- import crypto8 from "crypto";
5718
+ import crypto7 from "crypto";
5751
5719
  import path19 from "path";
5752
5720
  import { homedir } from "os";
5753
5721
  function sqlSafe(v) {
@@ -6130,7 +6098,7 @@ function buildRosterBlob(paths) {
6130
6098
  }
6131
6099
  const deletedNames = consumeRosterDeletions();
6132
6100
  const content = JSON.stringify({ roster, identities, config, deletedNames });
6133
- const hash = crypto8.createHash("sha256").update(content).digest("hex").slice(0, 16);
6101
+ const hash = crypto7.createHash("sha256").update(content).digest("hex").slice(0, 16);
6134
6102
  return { roster, identities, config, deletedNames, version: hash };
6135
6103
  }
6136
6104
  async function cloudPushRoster(config) {
@@ -6220,21 +6188,30 @@ async function mergeRosterFromRemote(remote, paths) {
6220
6188
  const localEmployees = await loadEmployees(rosterPath);
6221
6189
  const localNames = new Set(localEmployees.map((e) => e.name));
6222
6190
  let added = 0;
6191
+ let identitiesUpdated = 0;
6223
6192
  for (const remoteEmp of remote.roster) {
6224
- if (localNames.has(remoteEmp.name)) continue;
6225
- localEmployees.push(remoteEmp);
6226
- localNames.add(remoteEmp.name);
6227
- added++;
6228
- if (remote.identities[`${remoteEmp.name}.md`]) {
6193
+ if (!localNames.has(remoteEmp.name)) {
6194
+ localEmployees.push(remoteEmp);
6195
+ localNames.add(remoteEmp.name);
6196
+ added++;
6197
+ try {
6198
+ registerBinSymlinks(remoteEmp.name);
6199
+ } catch {
6200
+ }
6201
+ }
6202
+ const remoteIdentity = remote.identities[`${remoteEmp.name}.md`];
6203
+ if (remoteIdentity) {
6229
6204
  if (!existsSync15(identityDir)) mkdirSync9(identityDir, { recursive: true });
6230
6205
  const idPath = path19.join(identityDir, `${remoteEmp.name}.md`);
6231
- if (!existsSync15(idPath)) {
6232
- writeFileSync8(idPath, remote.identities[`${remoteEmp.name}.md`], "utf-8");
6206
+ let localIdentity = null;
6207
+ try {
6208
+ localIdentity = existsSync15(idPath) ? readFileSync12(idPath, "utf-8") : null;
6209
+ } catch {
6210
+ }
6211
+ if (localIdentity !== remoteIdentity) {
6212
+ writeFileSync8(idPath, remoteIdentity, "utf-8");
6213
+ identitiesUpdated++;
6233
6214
  }
6234
- }
6235
- try {
6236
- registerBinSymlinks(remoteEmp.name);
6237
- } catch {
6238
6215
  }
6239
6216
  }
6240
6217
  let removed = 0;
@@ -6256,7 +6233,7 @@ async function mergeRosterFromRemote(remote, paths) {
6256
6233
  } catch {
6257
6234
  }
6258
6235
  }
6259
- return { added };
6236
+ return { added, identitiesUpdated };
6260
6237
  });
6261
6238
  }
6262
6239
  async function cloudPushBlob(route, data, metaKey, config) {
@@ -6703,7 +6680,7 @@ __export(schedules_exports, {
6703
6680
  listSchedules: () => listSchedules,
6704
6681
  parseHumanCron: () => parseHumanCron
6705
6682
  });
6706
- import crypto9 from "crypto";
6683
+ import crypto8 from "crypto";
6707
6684
  import { execSync as execSync10 } from "child_process";
6708
6685
  async function ensureDb() {
6709
6686
  if (!isInitialized()) {
@@ -6772,7 +6749,7 @@ function parseHumanCron(input) {
6772
6749
  async function createSchedule(input) {
6773
6750
  await ensureDb();
6774
6751
  const client = getClient();
6775
- const id = crypto9.randomUUID().slice(0, 8);
6752
+ const id = crypto8.randomUUID().slice(0, 8);
6776
6753
  const now = (/* @__PURE__ */ new Date()).toISOString();
6777
6754
  const prompt = input.prompt ?? input.description;
6778
6755
  await client.execute({
@@ -608,7 +608,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
608
608
  import { existsSync } from "fs";
609
609
  import path from "path";
610
610
  import os from "os";
611
- import crypto from "crypto";
612
611
  var SERVICE = "exe-mem";
613
612
  var ACCOUNT = "master-key";
614
613
  function getKeyDir() {
@@ -662,83 +661,52 @@ async function setMasterKey(key) {
662
661
  await writeFile(keyPath, b64 + "\n", "utf-8");
663
662
  await chmod(keyPath, 384);
664
663
  }
665
- function exportMnemonic(key) {
666
- if (key.length !== 32) {
667
- throw new Error(`Key must be 32 bytes, got ${key.length}`);
668
- }
669
- const hash = crypto.createHash("sha256").update(key).digest();
670
- const checksumByte = hash[0];
671
- let bits = "";
672
- for (const byte of key) {
673
- bits += byte.toString(2).padStart(8, "0");
674
- }
675
- bits += checksumByte.toString(2).padStart(8, "0");
676
- const words = [];
677
- let wordlist;
664
+ async function loadBip39() {
678
665
  try {
679
- const bip39 = __require("bip39");
680
- wordlist = bip39.wordlists?.english ?? bip39.default?.wordlists?.english;
681
- if (!wordlist) throw new Error("no wordlist");
666
+ return await import("bip39");
682
667
  } catch {
683
- throw new Error("bip39 package required. Install with: npm install bip39");
668
+ throw new Error(
669
+ "bip39 package not found. Run: npm install -g bip39\nOr reinstall exe-os: npm install -g @askexenow/exe-os"
670
+ );
684
671
  }
685
- for (let i = 0; i < 264; i += 11) {
686
- const index = parseInt(bits.slice(i, i + 11), 2);
687
- words.push(wordlist[index]);
672
+ }
673
+ async function exportMnemonic(key) {
674
+ if (key.length !== 32) {
675
+ throw new Error(`Key must be 32 bytes, got ${key.length}`);
688
676
  }
689
- return words.join(" ");
677
+ const { entropyToMnemonic } = await loadBip39();
678
+ return entropyToMnemonic(key.toString("hex"));
690
679
  }
691
- function importMnemonic(mnemonic) {
692
- const words = mnemonic.trim().split(/\s+/);
680
+ async function importMnemonic(mnemonic) {
681
+ const trimmed = mnemonic.trim();
682
+ const words = trimmed.split(/\s+/);
693
683
  if (words.length !== 24) {
694
684
  throw new Error(`Expected 24 words, got ${words.length}`);
695
685
  }
696
- let wordlist;
697
- try {
698
- const bip39 = __require("bip39");
699
- wordlist = bip39.wordlists?.english ?? bip39.default?.wordlists?.english;
700
- if (!wordlist) throw new Error("no wordlist");
701
- } catch {
702
- throw new Error("bip39 package required. Install with: npm install bip39");
703
- }
704
- let bits = "";
705
- for (const word of words) {
706
- const index = wordlist.indexOf(word.toLowerCase());
707
- if (index === -1) {
708
- throw new Error(`Invalid BIP39 word: "${word}"`);
709
- }
710
- bits += index.toString(2).padStart(11, "0");
711
- }
712
- const entropyBits = bits.slice(0, 256);
713
- const checksumBits = bits.slice(256, 264);
714
- const key = Buffer.alloc(32);
715
- for (let i = 0; i < 32; i++) {
716
- key[i] = parseInt(entropyBits.slice(i * 8, (i + 1) * 8), 2);
717
- }
718
- const hash = crypto.createHash("sha256").update(key).digest();
719
- const expectedChecksum = hash[0].toString(2).padStart(8, "0");
720
- if (checksumBits !== expectedChecksum) {
721
- throw new Error("Invalid mnemonic checksum");
686
+ const { validateMnemonic, mnemonicToEntropy } = await loadBip39();
687
+ if (!validateMnemonic(trimmed)) {
688
+ throw new Error("Invalid mnemonic \u2014 check for typos or missing words");
722
689
  }
723
- return key;
690
+ const entropy = mnemonicToEntropy(trimmed);
691
+ return Buffer.from(entropy, "hex");
724
692
  }
725
693
 
726
694
  // src/bin/exe-cloud.ts
727
695
  init_config();
728
696
 
729
697
  // src/lib/ws-auth.ts
730
- import crypto2 from "crypto";
698
+ import crypto from "crypto";
731
699
  var WS_AUTH_HKDF_INFO = "exe-os-ws-auth-v1";
732
700
  var ORG_ID_HKDF_INFO = "exe-os-org-id-v1";
733
701
  function deriveWsAuthToken(masterKey) {
734
- return Buffer.from(crypto2.hkdfSync("sha256", masterKey, "", WS_AUTH_HKDF_INFO, 32));
702
+ return Buffer.from(crypto.hkdfSync("sha256", masterKey, "", WS_AUTH_HKDF_INFO, 32));
735
703
  }
736
704
  function deriveOrgId(masterKey) {
737
- const raw = Buffer.from(crypto2.hkdfSync("sha256", masterKey, "", ORG_ID_HKDF_INFO, 32));
738
- return crypto2.createHash("sha256").update(raw).digest("hex").slice(0, 32);
705
+ const raw = Buffer.from(crypto.hkdfSync("sha256", masterKey, "", ORG_ID_HKDF_INFO, 32));
706
+ return crypto.createHash("sha256").update(raw).digest("hex").slice(0, 32);
739
707
  }
740
708
  function hashAuthToken(token) {
741
- return crypto2.createHash("sha256").update(token).digest("hex");
709
+ return crypto.createHash("sha256").update(token).digest("hex");
742
710
  }
743
711
 
744
712
  // src/lib/is-main.ts
@@ -757,7 +725,7 @@ function isMainModule(importMetaUrl) {
757
725
 
758
726
  // src/lib/cloud-sync.ts
759
727
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync5, readdirSync, mkdirSync as mkdirSync2, appendFileSync, unlinkSync, openSync, closeSync } from "fs";
760
- import crypto4 from "crypto";
728
+ import crypto3 from "crypto";
761
729
  import path5 from "path";
762
730
  import { homedir } from "os";
763
731
 
@@ -765,7 +733,7 @@ import { homedir } from "os";
765
733
  import { createClient } from "@libsql/client";
766
734
 
767
735
  // src/lib/crypto.ts
768
- import crypto3 from "crypto";
736
+ import crypto2 from "crypto";
769
737
 
770
738
  // src/lib/compress.ts
771
739
  import { brotliCompressSync, brotliDecompressSync, constants } from "zlib";
@@ -823,7 +791,7 @@ async function setupMode() {
823
791
  if (hasPhrase.toLowerCase().startsWith("y")) {
824
792
  const mnemonic = await ask(rl, " Paste your 24 words: ");
825
793
  try {
826
- const key = importMnemonic(mnemonic);
794
+ const key = await importMnemonic(mnemonic);
827
795
  await setMasterKey(key);
828
796
  console.log(" \u2713 Key imported.\n");
829
797
  } catch (err) {
@@ -930,7 +898,7 @@ async function syncMode() {
930
898
  process.exit(1);
931
899
  }
932
900
  const config = await loadConfig();
933
- const mnemonic = exportMnemonic(key);
901
+ const mnemonic = await exportMnemonic(key);
934
902
  console.log(BAR);
935
903
  console.log(" EXE CLOUD \u2014 DEVICE SYNC INFO");
936
904
  console.log(BAR);
@@ -4450,7 +4450,6 @@ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4
4450
4450
  import { existsSync as existsSync11 } from "fs";
4451
4451
  import path14 from "path";
4452
4452
  import os6 from "os";
4453
- import crypto6 from "crypto";
4454
4453
  var SERVICE = "exe-mem";
4455
4454
  var ACCOUNT = "master-key";
4456
4455
  function getKeyDir() {
@@ -1651,7 +1651,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1651
1651
  import { existsSync } from "fs";
1652
1652
  import path from "path";
1653
1653
  import os from "os";
1654
- import crypto from "crypto";
1655
1654
  var SERVICE = "exe-mem";
1656
1655
  var ACCOUNT = "master-key";
1657
1656
  function getKeyDir() {
@@ -1543,7 +1543,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1543
1543
  import { existsSync } from "fs";
1544
1544
  import path from "path";
1545
1545
  import os from "os";
1546
- import crypto from "crypto";
1547
1546
  var SERVICE = "exe-mem";
1548
1547
  var ACCOUNT = "master-key";
1549
1548
  function getKeyDir() {
@@ -1873,7 +1872,7 @@ import {
1873
1872
 
1874
1873
  // src/lib/behaviors.ts
1875
1874
  init_database();
1876
- import crypto2 from "crypto";
1875
+ import crypto from "crypto";
1877
1876
  async function listBehaviors(agentId2, projectName2, limit = 30) {
1878
1877
  const client = getClient();
1879
1878
  const result = await client.execute({
@@ -928,7 +928,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
928
928
  import { existsSync } from "fs";
929
929
  import path from "path";
930
930
  import os from "os";
931
- import crypto from "crypto";
932
931
  function getKeyDir() {
933
932
  return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path.join(os.homedir(), ".exe-os");
934
933
  }
@@ -1923,7 +1923,6 @@ import { readFile as readFile2, writeFile as writeFile2, unlink, mkdir as mkdir2
1923
1923
  import { existsSync as existsSync3 } from "fs";
1924
1924
  import path3 from "path";
1925
1925
  import os2 from "os";
1926
- import crypto from "crypto";
1927
1926
  function getKeyDir() {
1928
1927
  return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os2.homedir(), ".exe-os");
1929
1928
  }
@@ -5113,7 +5112,7 @@ var init_plan_limits = __esm({
5113
5112
  });
5114
5113
 
5115
5114
  // src/lib/notifications.ts
5116
- import crypto3 from "crypto";
5115
+ import crypto2 from "crypto";
5117
5116
  import path11 from "path";
5118
5117
  import os6 from "os";
5119
5118
  import {
@@ -5126,7 +5125,7 @@ import {
5126
5125
  async function writeNotification(notification) {
5127
5126
  try {
5128
5127
  const client = getClient();
5129
- const id = crypto3.randomUUID();
5128
+ const id = crypto2.randomUUID();
5130
5129
  const now = (/* @__PURE__ */ new Date()).toISOString();
5131
5130
  await client.execute({
5132
5131
  sql: `INSERT INTO notifications (id, agent_id, agent_role, event, project, summary, task_file, read, created_at)
@@ -5165,7 +5164,7 @@ var init_notifications = __esm({
5165
5164
  });
5166
5165
 
5167
5166
  // src/lib/session-kill-telemetry.ts
5168
- import crypto4 from "crypto";
5167
+ import crypto3 from "crypto";
5169
5168
  async function recordSessionKill(input) {
5170
5169
  try {
5171
5170
  const client = getClient();
@@ -5175,7 +5174,7 @@ async function recordSessionKill(input) {
5175
5174
  ticks_idle, estimated_tokens_saved)
5176
5175
  VALUES (?, ?, ?, ?, ?, ?, ?)`,
5177
5176
  args: [
5178
- crypto4.randomUUID(),
5177
+ crypto3.randomUUID(),
5179
5178
  input.sessionName,
5180
5179
  input.agentId,
5181
5180
  (/* @__PURE__ */ new Date()).toISOString(),
@@ -5223,7 +5222,7 @@ var init_task_scope = __esm({
5223
5222
  });
5224
5223
 
5225
5224
  // src/lib/tasks-crud.ts
5226
- import crypto5 from "crypto";
5225
+ import crypto4 from "crypto";
5227
5226
  import path12 from "path";
5228
5227
  import { execSync as execSync4 } from "child_process";
5229
5228
  import { mkdir as mkdir4, writeFile as writeFile4, appendFile } from "fs/promises";
@@ -5314,7 +5313,7 @@ async function resolveTask(client, identifier, scopeSession) {
5314
5313
  }
5315
5314
  async function createTaskCore(input) {
5316
5315
  const client = getClient();
5317
- const id = crypto5.randomUUID();
5316
+ const id = crypto4.randomUUID();
5318
5317
  const now = (/* @__PURE__ */ new Date()).toISOString();
5319
5318
  const slug = slugify(input.title);
5320
5319
  const taskFile = input.taskFile ?? `exe/${input.assignedTo}/${slug}.md`;
@@ -6100,10 +6099,10 @@ var init_tasks_notify = __esm({
6100
6099
  });
6101
6100
 
6102
6101
  // src/lib/behaviors.ts
6103
- import crypto6 from "crypto";
6102
+ import crypto5 from "crypto";
6104
6103
  async function storeBehavior(opts) {
6105
6104
  const client = getClient();
6106
- const id = crypto6.randomUUID();
6105
+ const id = crypto5.randomUUID();
6107
6106
  const now = (/* @__PURE__ */ new Date()).toISOString();
6108
6107
  await client.execute({
6109
6108
  sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at)
@@ -6132,7 +6131,7 @@ __export(skill_learning_exports, {
6132
6131
  storeTrajectory: () => storeTrajectory,
6133
6132
  sweepTrajectories: () => sweepTrajectories
6134
6133
  });
6135
- import crypto7 from "crypto";
6134
+ import crypto6 from "crypto";
6136
6135
  async function extractTrajectory(taskId, agentId) {
6137
6136
  const client = getClient();
6138
6137
  const result = await client.execute({
@@ -6161,11 +6160,11 @@ async function extractTrajectory(taskId, agentId) {
6161
6160
  return signature;
6162
6161
  }
6163
6162
  function hashSignature(signature) {
6164
- return crypto7.createHash("sha256").update(signature.join("|")).digest("hex").slice(0, 16);
6163
+ return crypto6.createHash("sha256").update(signature.join("|")).digest("hex").slice(0, 16);
6165
6164
  }
6166
6165
  async function storeTrajectory(opts) {
6167
6166
  const client = getClient();
6168
- const id = crypto7.randomUUID();
6167
+ const id = crypto6.randomUUID();
6169
6168
  const now = (/* @__PURE__ */ new Date()).toISOString();
6170
6169
  const signatureHash = hashSignature(opts.signature);
6171
6170
  await client.execute({
@@ -7543,10 +7542,10 @@ __export(messaging_exports, {
7543
7542
  sendMessage: () => sendMessage,
7544
7543
  setWsClientSend: () => setWsClientSend
7545
7544
  });
7546
- import crypto8 from "crypto";
7545
+ import crypto7 from "crypto";
7547
7546
  function generateUlid() {
7548
7547
  const timestamp = Date.now().toString(36).padStart(10, "0");
7549
- const random = crypto8.randomBytes(10).toString("hex").slice(0, 16);
7548
+ const random = crypto7.randomBytes(10).toString("hex").slice(0, 16);
7550
7549
  return (timestamp + random).toUpperCase();
7551
7550
  }
7552
7551
  function rowToMessage(row) {
@@ -8378,11 +8377,11 @@ init_crm_bridge();
8378
8377
 
8379
8378
  // src/lib/pipeline-router.ts
8380
8379
  init_database();
8381
- import crypto2 from "crypto";
8380
+ import crypto from "crypto";
8382
8381
  async function sinkConversationStore(msg, agentResponse, agentName) {
8383
8382
  try {
8384
8383
  const client = getClient();
8385
- const id = crypto2.randomUUID();
8384
+ const id = crypto.randomUUID();
8386
8385
  const mediaJson = msg.media ? JSON.stringify(msg.media) : null;
8387
8386
  await client.execute({
8388
8387
  sql: `INSERT INTO conversations
@@ -8432,7 +8431,7 @@ async function sinkMemory(msg, agentResponse, agentName) {
8432
8431
  ].filter(Boolean).join("\n");
8433
8432
  const vector = await embed2(rawText);
8434
8433
  await writeMemory2({
8435
- id: crypto2.randomUUID(),
8434
+ id: crypto.randomUUID(),
8436
8435
  agent_id: agentName ?? "gateway",
8437
8436
  agent_role: "gateway",
8438
8437
  session_id: `gateway-${msg.platform}`,
@@ -1627,7 +1627,7 @@ var init_employees = __esm({
1627
1627
  });
1628
1628
 
1629
1629
  // src/lib/notifications.ts
1630
- import crypto2 from "crypto";
1630
+ import crypto from "crypto";
1631
1631
  import path5 from "path";
1632
1632
  import os3 from "os";
1633
1633
  import {
@@ -1998,7 +1998,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
1998
1998
  import { existsSync } from "fs";
1999
1999
  import path from "path";
2000
2000
  import os from "os";
2001
- import crypto from "crypto";
2002
2001
  var SERVICE = "exe-mem";
2003
2002
  var ACCOUNT = "master-key";
2004
2003
  function getKeyDir() {