@askexenow/exe-os 0.9.13 → 0.9.15

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 (70) hide show
  1. package/dist/bin/backfill-conversations.js +31 -4
  2. package/dist/bin/backfill-responses.js +31 -4
  3. package/dist/bin/backfill-vectors.js +25 -4
  4. package/dist/bin/cleanup-stale-review-tasks.js +1 -1
  5. package/dist/bin/cli.js +55 -8
  6. package/dist/bin/exe-assign.js +31 -4
  7. package/dist/bin/exe-boot.js +25 -4
  8. package/dist/bin/exe-dispatch.js +1 -1
  9. package/dist/bin/exe-doctor.js +1 -1
  10. package/dist/bin/exe-export-behaviors.js +1 -1
  11. package/dist/bin/exe-forget.js +1 -1
  12. package/dist/bin/exe-gateway.js +447 -21
  13. package/dist/bin/exe-heartbeat.js +1 -1
  14. package/dist/bin/exe-kill.js +1 -1
  15. package/dist/bin/exe-launch-agent.js +1 -1
  16. package/dist/bin/exe-link.js +31 -4
  17. package/dist/bin/exe-pending-messages.js +1 -1
  18. package/dist/bin/exe-pending-notifications.js +1 -1
  19. package/dist/bin/exe-pending-reviews.js +1 -1
  20. package/dist/bin/exe-rename.js +31 -4
  21. package/dist/bin/exe-review.js +1 -1
  22. package/dist/bin/exe-search.js +31 -4
  23. package/dist/bin/exe-session-cleanup.js +25 -4
  24. package/dist/bin/exe-start-codex.js +1 -1
  25. package/dist/bin/exe-start-opencode.js +1 -1
  26. package/dist/bin/exe-status.js +1 -1
  27. package/dist/bin/exe-team.js +1 -1
  28. package/dist/bin/git-sweep.js +25 -4
  29. package/dist/bin/graph-backfill.js +1 -1
  30. package/dist/bin/graph-export.js +1 -1
  31. package/dist/bin/scan-tasks.js +25 -4
  32. package/dist/bin/setup.js +46 -8
  33. package/dist/bin/shard-migrate.js +1 -1
  34. package/dist/bin/wiki-sync.js +1 -1
  35. package/dist/gateway/index.js +128 -125
  36. package/dist/hooks/bug-report-worker.js +1 -1
  37. package/dist/hooks/codex-stop-task-finalizer.js +1 -1
  38. package/dist/hooks/commit-complete.js +25 -4
  39. package/dist/hooks/error-recall.js +31 -4
  40. package/dist/hooks/ingest-worker.js +25 -4
  41. package/dist/hooks/ingest.js +1 -1
  42. package/dist/hooks/instructions-loaded.js +31 -4
  43. package/dist/hooks/notification.js +31 -4
  44. package/dist/hooks/post-compact.js +31 -4
  45. package/dist/hooks/pre-compact.js +25 -4
  46. package/dist/hooks/pre-tool-use.js +31 -4
  47. package/dist/hooks/prompt-ingest-worker.js +25 -4
  48. package/dist/hooks/prompt-submit.js +25 -4
  49. package/dist/hooks/response-ingest-worker.js +25 -4
  50. package/dist/hooks/session-end.js +25 -4
  51. package/dist/hooks/session-start.js +31 -4
  52. package/dist/hooks/stop.js +25 -4
  53. package/dist/hooks/subagent-stop.js +31 -4
  54. package/dist/hooks/summary-worker.js +25 -4
  55. package/dist/index.js +128 -125
  56. package/dist/lib/cloud-sync.js +31 -4
  57. package/dist/lib/database.js +31 -4
  58. package/dist/lib/db-daemon-client.js +31 -3
  59. package/dist/lib/db.js +31 -4
  60. package/dist/lib/device-registry.js +31 -4
  61. package/dist/lib/embedder.js +30 -3
  62. package/dist/lib/exe-daemon-client.js +31 -3
  63. package/dist/lib/exe-daemon.js +1969 -156
  64. package/dist/lib/hybrid-search.js +31 -4
  65. package/dist/lib/schedules.js +1 -1
  66. package/dist/lib/store.js +1 -1
  67. package/dist/mcp/server.js +25 -4
  68. package/dist/runtime/index.js +25 -4
  69. package/dist/tui/App.js +34 -4
  70. package/package.json +1 -1
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
4
10
  var __esm = (fn, res) => function __init() {
5
11
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
12
  };
@@ -661,7 +667,7 @@ async function ensureCompatibilityViews(prisma) {
661
667
  for (const mapping of VIEW_MAPPINGS) {
662
668
  const relation = mapping.source.replace(/"/g, "");
663
669
  const rows = await prisma.$queryRawUnsafe(
664
- "SELECT to_regclass($1) AS regclass",
670
+ "SELECT to_regclass($1)::text AS regclass",
665
671
  relation
666
672
  );
667
673
  if (!rows[0]?.regclass) {
@@ -2580,8 +2586,29 @@ function findPackageRoot() {
2580
2586
  }
2581
2587
  return null;
2582
2588
  }
2589
+ function getAvailableMemoryGB() {
2590
+ if (process.platform === "darwin") {
2591
+ try {
2592
+ const { execSync: execSync2 } = __require("child_process");
2593
+ const vmstat = execSync2("vm_stat", { encoding: "utf8" });
2594
+ const pageSize = 16384;
2595
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
2596
+ const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
2597
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
2598
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
2599
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
2600
+ const freePages = free ? parseInt(free[1], 10) : 0;
2601
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
2602
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
2603
+ return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
2604
+ } catch {
2605
+ return os5.freemem() / (1024 * 1024 * 1024);
2606
+ }
2607
+ }
2608
+ return os5.freemem() / (1024 * 1024 * 1024);
2609
+ }
2583
2610
  function spawnDaemon() {
2584
- const freeGB = os5.freemem() / (1024 * 1024 * 1024);
2611
+ const freeGB = getAvailableMemoryGB();
2585
2612
  const totalGB = os5.totalmem() / (1024 * 1024 * 1024);
2586
2613
  if (totalGB <= 8) {
2587
2614
  process.stderr.write(
@@ -2590,9 +2617,9 @@ function spawnDaemon() {
2590
2617
  );
2591
2618
  return;
2592
2619
  }
2593
- if (totalGB <= 16 && freeGB < 4) {
2620
+ if (totalGB <= 16 && freeGB < 2) {
2594
2621
  process.stderr.write(
2595
- `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB free / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2622
+ `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2596
2623
  `
2597
2624
  );
2598
2625
  return;
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
4
10
  var __esm = (fn, res) => function __init() {
5
11
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
12
  };
@@ -661,7 +667,7 @@ async function ensureCompatibilityViews(prisma) {
661
667
  for (const mapping of VIEW_MAPPINGS) {
662
668
  const relation = mapping.source.replace(/"/g, "");
663
669
  const rows = await prisma.$queryRawUnsafe(
664
- "SELECT to_regclass($1) AS regclass",
670
+ "SELECT to_regclass($1)::text AS regclass",
665
671
  relation
666
672
  );
667
673
  if (!rows[0]?.regclass) {
@@ -2580,8 +2586,29 @@ function findPackageRoot() {
2580
2586
  }
2581
2587
  return null;
2582
2588
  }
2589
+ function getAvailableMemoryGB() {
2590
+ if (process.platform === "darwin") {
2591
+ try {
2592
+ const { execSync: execSync2 } = __require("child_process");
2593
+ const vmstat = execSync2("vm_stat", { encoding: "utf8" });
2594
+ const pageSize = 16384;
2595
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
2596
+ const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
2597
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
2598
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
2599
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
2600
+ const freePages = free ? parseInt(free[1], 10) : 0;
2601
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
2602
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
2603
+ return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
2604
+ } catch {
2605
+ return os5.freemem() / (1024 * 1024 * 1024);
2606
+ }
2607
+ }
2608
+ return os5.freemem() / (1024 * 1024 * 1024);
2609
+ }
2583
2610
  function spawnDaemon() {
2584
- const freeGB = os5.freemem() / (1024 * 1024 * 1024);
2611
+ const freeGB = getAvailableMemoryGB();
2585
2612
  const totalGB = os5.totalmem() / (1024 * 1024 * 1024);
2586
2613
  if (totalGB <= 8) {
2587
2614
  process.stderr.write(
@@ -2590,9 +2617,9 @@ function spawnDaemon() {
2590
2617
  );
2591
2618
  return;
2592
2619
  }
2593
- if (totalGB <= 16 && freeGB < 4) {
2620
+ if (totalGB <= 16 && freeGB < 2) {
2594
2621
  process.stderr.write(
2595
- `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB free / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2622
+ `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2596
2623
  `
2597
2624
  );
2598
2625
  return;
@@ -663,7 +663,7 @@ async function ensureCompatibilityViews(prisma) {
663
663
  for (const mapping of VIEW_MAPPINGS) {
664
664
  const relation = mapping.source.replace(/"/g, "");
665
665
  const rows = await prisma.$queryRawUnsafe(
666
- "SELECT to_regclass($1) AS regclass",
666
+ "SELECT to_regclass($1)::text AS regclass",
667
667
  relation
668
668
  );
669
669
  if (!rows[0]?.regclass) {
@@ -2582,8 +2582,29 @@ function findPackageRoot() {
2582
2582
  }
2583
2583
  return null;
2584
2584
  }
2585
+ function getAvailableMemoryGB() {
2586
+ if (process.platform === "darwin") {
2587
+ try {
2588
+ const { execSync: execSync2 } = __require("child_process");
2589
+ const vmstat = execSync2("vm_stat", { encoding: "utf8" });
2590
+ const pageSize = 16384;
2591
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
2592
+ const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
2593
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
2594
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
2595
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
2596
+ const freePages = free ? parseInt(free[1], 10) : 0;
2597
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
2598
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
2599
+ return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
2600
+ } catch {
2601
+ return os5.freemem() / (1024 * 1024 * 1024);
2602
+ }
2603
+ }
2604
+ return os5.freemem() / (1024 * 1024 * 1024);
2605
+ }
2585
2606
  function spawnDaemon() {
2586
- const freeGB = os5.freemem() / (1024 * 1024 * 1024);
2607
+ const freeGB = getAvailableMemoryGB();
2587
2608
  const totalGB = os5.totalmem() / (1024 * 1024 * 1024);
2588
2609
  if (totalGB <= 8) {
2589
2610
  process.stderr.write(
@@ -2592,9 +2613,9 @@ function spawnDaemon() {
2592
2613
  );
2593
2614
  return;
2594
2615
  }
2595
- if (totalGB <= 16 && freeGB < 4) {
2616
+ if (totalGB <= 16 && freeGB < 2) {
2596
2617
  process.stderr.write(
2597
- `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB free / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2618
+ `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2598
2619
  `
2599
2620
  );
2600
2621
  return;
@@ -655,7 +655,7 @@ async function ensureCompatibilityViews(prisma) {
655
655
  for (const mapping of VIEW_MAPPINGS) {
656
656
  const relation = mapping.source.replace(/"/g, "");
657
657
  const rows = await prisma.$queryRawUnsafe(
658
- "SELECT to_regclass($1) AS regclass",
658
+ "SELECT to_regclass($1)::text AS regclass",
659
659
  relation
660
660
  );
661
661
  if (!rows[0]?.regclass) {
package/dist/bin/cli.js CHANGED
@@ -2153,7 +2153,7 @@ async function ensureCompatibilityViews(prisma) {
2153
2153
  for (const mapping of VIEW_MAPPINGS) {
2154
2154
  const relation = mapping.source.replace(/"/g, "");
2155
2155
  const rows = await prisma.$queryRawUnsafe(
2156
- "SELECT to_regclass($1) AS regclass",
2156
+ "SELECT to_regclass($1)::text AS regclass",
2157
2157
  relation
2158
2158
  );
2159
2159
  if (!rows[0]?.regclass) {
@@ -2507,8 +2507,29 @@ function findPackageRoot() {
2507
2507
  }
2508
2508
  return null;
2509
2509
  }
2510
+ function getAvailableMemoryGB() {
2511
+ if (process.platform === "darwin") {
2512
+ try {
2513
+ const { execSync: execSync15 } = __require("child_process");
2514
+ const vmstat = execSync15("vm_stat", { encoding: "utf8" });
2515
+ const pageSize = 16384;
2516
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
2517
+ const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
2518
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
2519
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
2520
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
2521
+ const freePages = free ? parseInt(free[1], 10) : 0;
2522
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
2523
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
2524
+ return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
2525
+ } catch {
2526
+ return os8.freemem() / (1024 * 1024 * 1024);
2527
+ }
2528
+ }
2529
+ return os8.freemem() / (1024 * 1024 * 1024);
2530
+ }
2510
2531
  function spawnDaemon() {
2511
- const freeGB = os8.freemem() / (1024 * 1024 * 1024);
2532
+ const freeGB = getAvailableMemoryGB();
2512
2533
  const totalGB = os8.totalmem() / (1024 * 1024 * 1024);
2513
2534
  if (totalGB <= 8) {
2514
2535
  process.stderr.write(
@@ -2517,9 +2538,9 @@ function spawnDaemon() {
2517
2538
  );
2518
2539
  return;
2519
2540
  }
2520
- if (totalGB <= 16 && freeGB < 4) {
2541
+ if (totalGB <= 16 && freeGB < 2) {
2521
2542
  process.stderr.write(
2522
- `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB free / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2543
+ `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
2523
2544
  `
2524
2545
  );
2525
2546
  return;
@@ -14648,18 +14669,35 @@ function ask2(rl, prompt) {
14648
14669
  doAsk();
14649
14670
  });
14650
14671
  }
14651
- function getAvailableMemoryGB() {
14672
+ function getAvailableMemoryGB2() {
14673
+ if (process.platform === "darwin") {
14674
+ try {
14675
+ const { execSync: execSync15 } = __require("child_process");
14676
+ const vmstat = execSync15("vm_stat", { encoding: "utf8" });
14677
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
14678
+ const pageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : 16384;
14679
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
14680
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
14681
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
14682
+ const freePages = free ? parseInt(free[1], 10) : 0;
14683
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
14684
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
14685
+ return (freePages + inactivePages + speculativePages) * pageSize / (1024 * 1024 * 1024);
14686
+ } catch {
14687
+ return os16.freemem() / (1024 * 1024 * 1024);
14688
+ }
14689
+ }
14652
14690
  return os16.freemem() / (1024 * 1024 * 1024);
14653
14691
  }
14654
14692
  function getTotalMemoryGB() {
14655
14693
  return os16.totalmem() / (1024 * 1024 * 1024);
14656
14694
  }
14657
14695
  function isLowMemory() {
14658
- return getAvailableMemoryGB() < 2;
14696
+ return getAvailableMemoryGB2() < 2;
14659
14697
  }
14660
14698
  async function validateModel(log) {
14661
14699
  const totalGB = getTotalMemoryGB();
14662
- const freeGB = getAvailableMemoryGB();
14700
+ const freeGB = getAvailableMemoryGB2();
14663
14701
  if (totalGB <= 8 || isLowMemory()) {
14664
14702
  log(`System memory: ${totalGB.toFixed(0)}GB total, ${freeGB.toFixed(1)}GB free`);
14665
14703
  log("Skipping in-memory model validation (low memory \u2014 will validate on first use).");
@@ -14875,7 +14913,7 @@ async function runSetupWizard(opts = {}) {
14875
14913
  skipModel = true;
14876
14914
  }
14877
14915
  if (!skipModel) {
14878
- const freeGB = getAvailableMemoryGB();
14916
+ const freeGB = getAvailableMemoryGB2();
14879
14917
  if (freeGB < 2) {
14880
14918
  log(`\u26A0 Low memory detected: ${freeGB.toFixed(1)}GB free of ${totalGB.toFixed(0)}GB total`);
14881
14919
  log(" Close other applications (browser, Slack, etc.) before continuing.");
@@ -24140,6 +24178,15 @@ __export(factory_exports, {
24140
24178
  function createProvider(opts) {
24141
24179
  const { providerId, model, apiKey } = opts;
24142
24180
  if (providerId === "anthropic") {
24181
+ const routerUrl = process.env.API_ROUTER_URL;
24182
+ const routerKey = process.env.API_ROUTER_KEY;
24183
+ const byok = process.env.BYOK_ENABLED === "true";
24184
+ if (routerUrl && routerKey && !byok) {
24185
+ return new AnthropicProvider("anthropic", {
24186
+ apiKey: routerKey,
24187
+ baseUrl: routerUrl
24188
+ });
24189
+ }
24143
24190
  return new AnthropicProvider("anthropic", { apiKey });
24144
24191
  }
24145
24192
  if (providerId === "openai") {
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
4
10
  var __esm = (fn, res) => function __init() {
5
11
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
12
  };
@@ -386,8 +392,29 @@ function findPackageRoot() {
386
392
  }
387
393
  return null;
388
394
  }
395
+ function getAvailableMemoryGB() {
396
+ if (process.platform === "darwin") {
397
+ try {
398
+ const { execSync: execSync2 } = __require("child_process");
399
+ const vmstat = execSync2("vm_stat", { encoding: "utf8" });
400
+ const pageSize = 16384;
401
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
402
+ const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
403
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
404
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
405
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
406
+ const freePages = free ? parseInt(free[1], 10) : 0;
407
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
408
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
409
+ return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
410
+ } catch {
411
+ return os3.freemem() / (1024 * 1024 * 1024);
412
+ }
413
+ }
414
+ return os3.freemem() / (1024 * 1024 * 1024);
415
+ }
389
416
  function spawnDaemon() {
390
- const freeGB = os3.freemem() / (1024 * 1024 * 1024);
417
+ const freeGB = getAvailableMemoryGB();
391
418
  const totalGB = os3.totalmem() / (1024 * 1024 * 1024);
392
419
  if (totalGB <= 8) {
393
420
  process.stderr.write(
@@ -396,9 +423,9 @@ function spawnDaemon() {
396
423
  );
397
424
  return;
398
425
  }
399
- if (totalGB <= 16 && freeGB < 4) {
426
+ if (totalGB <= 16 && freeGB < 2) {
400
427
  process.stderr.write(
401
- `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB free / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
428
+ `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
402
429
  `
403
430
  );
404
431
  return;
@@ -1103,7 +1130,7 @@ async function ensureCompatibilityViews(prisma) {
1103
1130
  for (const mapping of VIEW_MAPPINGS) {
1104
1131
  const relation = mapping.source.replace(/"/g, "");
1105
1132
  const rows = await prisma.$queryRawUnsafe(
1106
- "SELECT to_regclass($1) AS regclass",
1133
+ "SELECT to_regclass($1)::text AS regclass",
1107
1134
  relation
1108
1135
  );
1109
1136
  if (!rows[0]?.regclass) {
@@ -806,7 +806,7 @@ async function ensureCompatibilityViews(prisma) {
806
806
  for (const mapping of VIEW_MAPPINGS) {
807
807
  const relation = mapping.source.replace(/"/g, "");
808
808
  const rows = await prisma.$queryRawUnsafe(
809
- "SELECT to_regclass($1) AS regclass",
809
+ "SELECT to_regclass($1)::text AS regclass",
810
810
  relation
811
811
  );
812
812
  if (!rows[0]?.regclass) {
@@ -1160,8 +1160,29 @@ function findPackageRoot() {
1160
1160
  }
1161
1161
  return null;
1162
1162
  }
1163
+ function getAvailableMemoryGB() {
1164
+ if (process.platform === "darwin") {
1165
+ try {
1166
+ const { execSync: execSync10 } = __require("child_process");
1167
+ const vmstat = execSync10("vm_stat", { encoding: "utf8" });
1168
+ const pageSize = 16384;
1169
+ const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
1170
+ const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
1171
+ const free = vmstat.match(/Pages free:\s+(\d+)/);
1172
+ const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
1173
+ const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
1174
+ const freePages = free ? parseInt(free[1], 10) : 0;
1175
+ const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
1176
+ const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
1177
+ return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
1178
+ } catch {
1179
+ return os4.freemem() / (1024 * 1024 * 1024);
1180
+ }
1181
+ }
1182
+ return os4.freemem() / (1024 * 1024 * 1024);
1183
+ }
1163
1184
  function spawnDaemon() {
1164
- const freeGB = os4.freemem() / (1024 * 1024 * 1024);
1185
+ const freeGB = getAvailableMemoryGB();
1165
1186
  const totalGB = os4.totalmem() / (1024 * 1024 * 1024);
1166
1187
  if (totalGB <= 8) {
1167
1188
  process.stderr.write(
@@ -1170,9 +1191,9 @@ function spawnDaemon() {
1170
1191
  );
1171
1192
  return;
1172
1193
  }
1173
- if (totalGB <= 16 && freeGB < 4) {
1194
+ if (totalGB <= 16 && freeGB < 2) {
1174
1195
  process.stderr.write(
1175
- `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB free / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
1196
+ `[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
1176
1197
  `
1177
1198
  );
1178
1199
  return;
@@ -1164,7 +1164,7 @@ async function ensureCompatibilityViews(prisma) {
1164
1164
  for (const mapping of VIEW_MAPPINGS) {
1165
1165
  const relation = mapping.source.replace(/"/g, "");
1166
1166
  const rows = await prisma.$queryRawUnsafe(
1167
- "SELECT to_regclass($1) AS regclass",
1167
+ "SELECT to_regclass($1)::text AS regclass",
1168
1168
  relation
1169
1169
  );
1170
1170
  if (!rows[0]?.regclass) {
@@ -650,7 +650,7 @@ async function ensureCompatibilityViews(prisma) {
650
650
  for (const mapping of VIEW_MAPPINGS) {
651
651
  const relation = mapping.source.replace(/"/g, "");
652
652
  const rows = await prisma.$queryRawUnsafe(
653
- "SELECT to_regclass($1) AS regclass",
653
+ "SELECT to_regclass($1)::text AS regclass",
654
654
  relation
655
655
  );
656
656
  if (!rows[0]?.regclass) {
@@ -644,7 +644,7 @@ async function ensureCompatibilityViews(prisma) {
644
644
  for (const mapping of VIEW_MAPPINGS) {
645
645
  const relation = mapping.source.replace(/"/g, "");
646
646
  const rows = await prisma.$queryRawUnsafe(
647
- "SELECT to_regclass($1) AS regclass",
647
+ "SELECT to_regclass($1)::text AS regclass",
648
648
  relation
649
649
  );
650
650
  if (!rows[0]?.regclass) {
@@ -651,7 +651,7 @@ async function ensureCompatibilityViews(prisma) {
651
651
  for (const mapping of VIEW_MAPPINGS) {
652
652
  const relation = mapping.source.replace(/"/g, "");
653
653
  const rows = await prisma.$queryRawUnsafe(
654
- "SELECT to_regclass($1) AS regclass",
654
+ "SELECT to_regclass($1)::text AS regclass",
655
655
  relation
656
656
  );
657
657
  if (!rows[0]?.regclass) {