@askexenow/exe-os 0.9.7 → 0.9.8

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 (95) hide show
  1. package/dist/bin/backfill-conversations.js +754 -79
  2. package/dist/bin/backfill-responses.js +752 -77
  3. package/dist/bin/backfill-vectors.js +752 -77
  4. package/dist/bin/cleanup-stale-review-tasks.js +657 -35
  5. package/dist/bin/cli.js +1388 -605
  6. package/dist/bin/exe-agent-config.js +123 -95
  7. package/dist/bin/exe-agent.js +41 -25
  8. package/dist/bin/exe-assign.js +732 -57
  9. package/dist/bin/exe-boot.js +784 -153
  10. package/dist/bin/exe-call.js +209 -138
  11. package/dist/bin/exe-cloud.js +35 -12
  12. package/dist/bin/exe-dispatch.js +692 -70
  13. package/dist/bin/exe-doctor.js +648 -26
  14. package/dist/bin/exe-export-behaviors.js +650 -20
  15. package/dist/bin/exe-forget.js +635 -13
  16. package/dist/bin/exe-gateway.js +1053 -271
  17. package/dist/bin/exe-heartbeat.js +665 -43
  18. package/dist/bin/exe-kill.js +646 -16
  19. package/dist/bin/exe-launch-agent.js +887 -97
  20. package/dist/bin/exe-link.js +658 -43
  21. package/dist/bin/exe-new-employee.js +378 -177
  22. package/dist/bin/exe-pending-messages.js +656 -34
  23. package/dist/bin/exe-pending-notifications.js +635 -13
  24. package/dist/bin/exe-pending-reviews.js +659 -37
  25. package/dist/bin/exe-rename.js +645 -30
  26. package/dist/bin/exe-review.js +635 -13
  27. package/dist/bin/exe-search.js +771 -88
  28. package/dist/bin/exe-session-cleanup.js +834 -150
  29. package/dist/bin/exe-settings.js +127 -91
  30. package/dist/bin/exe-start-codex.js +729 -94
  31. package/dist/bin/exe-start-opencode.js +717 -82
  32. package/dist/bin/exe-status.js +657 -35
  33. package/dist/bin/exe-team.js +635 -13
  34. package/dist/bin/git-sweep.js +720 -89
  35. package/dist/bin/graph-backfill.js +643 -13
  36. package/dist/bin/graph-export.js +646 -16
  37. package/dist/bin/install.js +596 -193
  38. package/dist/bin/scan-tasks.js +724 -93
  39. package/dist/bin/setup.js +1038 -210
  40. package/dist/bin/shard-migrate.js +645 -15
  41. package/dist/bin/wiki-sync.js +646 -16
  42. package/dist/gateway/index.js +1027 -245
  43. package/dist/hooks/bug-report-worker.js +891 -170
  44. package/dist/hooks/commit-complete.js +718 -87
  45. package/dist/hooks/error-recall.js +776 -93
  46. package/dist/hooks/exe-heartbeat-hook.js +85 -71
  47. package/dist/hooks/ingest-worker.js +840 -156
  48. package/dist/hooks/ingest.js +90 -73
  49. package/dist/hooks/instructions-loaded.js +669 -38
  50. package/dist/hooks/notification.js +661 -30
  51. package/dist/hooks/post-compact.js +674 -43
  52. package/dist/hooks/pre-compact.js +718 -87
  53. package/dist/hooks/pre-tool-use.js +872 -125
  54. package/dist/hooks/prompt-ingest-worker.js +758 -83
  55. package/dist/hooks/prompt-submit.js +1060 -319
  56. package/dist/hooks/response-ingest-worker.js +758 -83
  57. package/dist/hooks/session-end.js +721 -90
  58. package/dist/hooks/session-start.js +1031 -207
  59. package/dist/hooks/stop.js +680 -49
  60. package/dist/hooks/subagent-stop.js +674 -43
  61. package/dist/hooks/summary-worker.js +816 -132
  62. package/dist/index.js +1015 -232
  63. package/dist/lib/cloud-sync.js +663 -48
  64. package/dist/lib/consolidation.js +26 -3
  65. package/dist/lib/database.js +626 -18
  66. package/dist/lib/db.js +2261 -0
  67. package/dist/lib/device-registry.js +640 -25
  68. package/dist/lib/embedder.js +96 -43
  69. package/dist/lib/employee-templates.js +16 -0
  70. package/dist/lib/employees.js +259 -83
  71. package/dist/lib/exe-daemon-client.js +101 -63
  72. package/dist/lib/exe-daemon.js +894 -162
  73. package/dist/lib/hybrid-search.js +771 -88
  74. package/dist/lib/identity.js +27 -7
  75. package/dist/lib/messaging.js +55 -28
  76. package/dist/lib/reminders.js +21 -1
  77. package/dist/lib/schedules.js +636 -14
  78. package/dist/lib/skill-learning.js +21 -1
  79. package/dist/lib/store.js +643 -13
  80. package/dist/lib/task-router.js +82 -71
  81. package/dist/lib/tasks.js +98 -71
  82. package/dist/lib/tmux-routing.js +87 -60
  83. package/dist/lib/token-spend.js +26 -6
  84. package/dist/mcp/server.js +1784 -458
  85. package/dist/mcp/tools/complete-reminder.js +21 -1
  86. package/dist/mcp/tools/create-reminder.js +21 -1
  87. package/dist/mcp/tools/create-task.js +290 -164
  88. package/dist/mcp/tools/deactivate-behavior.js +24 -4
  89. package/dist/mcp/tools/list-reminders.js +21 -1
  90. package/dist/mcp/tools/list-tasks.js +195 -38
  91. package/dist/mcp/tools/send-message.js +58 -31
  92. package/dist/mcp/tools/update-task.js +75 -48
  93. package/dist/runtime/index.js +720 -89
  94. package/dist/tui/App.js +853 -123
  95. package/package.json +3 -2
@@ -303,7 +303,7 @@ function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
303
303
  return [];
304
304
  }
305
305
  }
306
- var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
306
+ var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE, IDENTITY_DIR;
307
307
  var init_employees = __esm({
308
308
  "src/lib/employees.ts"() {
309
309
  "use strict";
@@ -311,12 +311,609 @@ var init_employees = __esm({
311
311
  EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
312
312
  DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
313
313
  COORDINATOR_ROLE = "COO";
314
+ IDENTITY_DIR = path2.join(EXE_AI_DIR, "identity");
315
+ }
316
+ });
317
+
318
+ // src/lib/database-adapter.ts
319
+ import os3 from "os";
320
+ import path3 from "path";
321
+ import { createRequire } from "module";
322
+ import { pathToFileURL } from "url";
323
+ function quotedIdentifier(identifier) {
324
+ return `"${identifier.replace(/"/g, '""')}"`;
325
+ }
326
+ function unqualifiedTableName(name) {
327
+ const raw = name.trim().replace(/^"|"$/g, "");
328
+ const parts = raw.split(".");
329
+ return parts[parts.length - 1].replace(/^"|"$/g, "").toLowerCase();
330
+ }
331
+ function stripTrailingSemicolon(sql) {
332
+ return sql.trim().replace(/;+\s*$/u, "");
333
+ }
334
+ function appendClause(sql, clause) {
335
+ const trimmed = stripTrailingSemicolon(sql);
336
+ const returningMatch = /\sRETURNING\b[\s\S]*$/iu.exec(trimmed);
337
+ if (!returningMatch) {
338
+ return `${trimmed}${clause}`;
339
+ }
340
+ const idx = returningMatch.index;
341
+ return `${trimmed.slice(0, idx)}${clause}${trimmed.slice(idx)}`;
342
+ }
343
+ function normalizeStatement(stmt) {
344
+ if (typeof stmt === "string") {
345
+ return { kind: "positional", sql: stmt, args: [] };
346
+ }
347
+ const sql = stmt.sql;
348
+ if (Array.isArray(stmt.args) || stmt.args === void 0) {
349
+ return { kind: "positional", sql, args: stmt.args ?? [] };
350
+ }
351
+ return { kind: "named", sql, args: stmt.args };
352
+ }
353
+ function rewriteBooleanLiterals(sql) {
354
+ let out = sql;
355
+ for (const column of BOOLEAN_COLUMN_NAMES) {
356
+ const scoped = `((?:\\b[a-z_][a-z0-9_]*\\.)?${column})`;
357
+ out = out.replace(new RegExp(`${scoped}\\s*=\\s*0\\b`, "giu"), "$1 = FALSE");
358
+ out = out.replace(new RegExp(`${scoped}\\s*=\\s*1\\b`, "giu"), "$1 = TRUE");
359
+ out = out.replace(new RegExp(`${scoped}\\s*!=\\s*0\\b`, "giu"), "$1 != FALSE");
360
+ out = out.replace(new RegExp(`${scoped}\\s*!=\\s*1\\b`, "giu"), "$1 != TRUE");
361
+ out = out.replace(new RegExp(`${scoped}\\s*<>\\s*0\\b`, "giu"), "$1 <> FALSE");
362
+ out = out.replace(new RegExp(`${scoped}\\s*<>\\s*1\\b`, "giu"), "$1 <> TRUE");
363
+ }
364
+ return out;
365
+ }
366
+ function rewriteInsertOrIgnore(sql) {
367
+ if (!/^\s*INSERT\s+OR\s+IGNORE\s+INTO\b/iu.test(sql)) {
368
+ return sql;
369
+ }
370
+ const replaced = sql.replace(/^\s*INSERT\s+OR\s+IGNORE\s+INTO\b/iu, "INSERT INTO");
371
+ return /\bON\s+CONFLICT\b/iu.test(replaced) ? replaced : appendClause(replaced, " ON CONFLICT DO NOTHING");
372
+ }
373
+ function rewriteInsertOrReplace(sql) {
374
+ const match = /^\s*INSERT\s+OR\s+REPLACE\s+INTO\s+([A-Za-z0-9_."]+)\s*\(([^)]+)\)([\s\S]*)$/iu.exec(sql);
375
+ if (!match) {
376
+ return sql;
377
+ }
378
+ const rawTable = match[1];
379
+ const rawColumns = match[2];
380
+ const remainder = match[3];
381
+ const tableName = unqualifiedTableName(rawTable);
382
+ const conflictKeys = UPSERT_KEYS[tableName];
383
+ if (!conflictKeys?.length) {
384
+ return sql;
385
+ }
386
+ const columns = rawColumns.split(",").map((col) => col.trim().replace(/^"|"$/g, ""));
387
+ const updateColumns = columns.filter((col) => !conflictKeys.includes(col));
388
+ const conflictTarget = conflictKeys.map(quotedIdentifier).join(", ");
389
+ const updateClause = updateColumns.length === 0 ? " DO NOTHING" : ` DO UPDATE SET ${updateColumns.map((col) => `${quotedIdentifier(col)} = EXCLUDED.${quotedIdentifier(col)}`).join(", ")}`;
390
+ return `INSERT INTO ${rawTable} (${rawColumns})${appendClause(remainder, ` ON CONFLICT (${conflictTarget})${updateClause}`)}`;
391
+ }
392
+ function rewriteSql(sql) {
393
+ let out = sql;
394
+ out = out.replace(/\bdatetime\(\s*['"]now['"]\s*\)/giu, "CURRENT_TIMESTAMP");
395
+ out = out.replace(/\bvector32\s*\(\s*\?\s*\)/giu, "?");
396
+ out = rewriteBooleanLiterals(out);
397
+ out = rewriteInsertOrReplace(out);
398
+ out = rewriteInsertOrIgnore(out);
399
+ return stripTrailingSemicolon(out);
400
+ }
401
+ function toBoolean(value) {
402
+ if (value === null || value === void 0) return value;
403
+ if (typeof value === "boolean") return value;
404
+ if (typeof value === "number") return value !== 0;
405
+ if (typeof value === "bigint") return value !== 0n;
406
+ if (typeof value === "string") {
407
+ const normalized = value.trim().toLowerCase();
408
+ if (normalized === "0" || normalized === "false") return false;
409
+ if (normalized === "1" || normalized === "true") return true;
410
+ }
411
+ return Boolean(value);
412
+ }
413
+ function countQuestionMarks(sql, end) {
414
+ let count = 0;
415
+ let inSingle = false;
416
+ let inDouble = false;
417
+ let inLineComment = false;
418
+ let inBlockComment = false;
419
+ for (let i = 0; i < end; i++) {
420
+ const ch = sql[i];
421
+ const next = sql[i + 1];
422
+ if (inLineComment) {
423
+ if (ch === "\n") inLineComment = false;
424
+ continue;
425
+ }
426
+ if (inBlockComment) {
427
+ if (ch === "*" && next === "/") {
428
+ inBlockComment = false;
429
+ i += 1;
430
+ }
431
+ continue;
432
+ }
433
+ if (!inSingle && !inDouble && ch === "-" && next === "-") {
434
+ inLineComment = true;
435
+ i += 1;
436
+ continue;
437
+ }
438
+ if (!inSingle && !inDouble && ch === "/" && next === "*") {
439
+ inBlockComment = true;
440
+ i += 1;
441
+ continue;
442
+ }
443
+ if (!inDouble && ch === "'" && sql[i - 1] !== "\\") {
444
+ inSingle = !inSingle;
445
+ continue;
446
+ }
447
+ if (!inSingle && ch === '"' && sql[i - 1] !== "\\") {
448
+ inDouble = !inDouble;
449
+ continue;
450
+ }
451
+ if (!inSingle && !inDouble && ch === "?") {
452
+ count += 1;
453
+ }
454
+ }
455
+ return count;
456
+ }
457
+ function findBooleanPlaceholderIndexes(sql) {
458
+ const indexes = /* @__PURE__ */ new Set();
459
+ for (const column of BOOLEAN_COLUMN_NAMES) {
460
+ const pattern = new RegExp(`(?:\\b[a-z_][a-z0-9_]*\\.)?${column}\\s*=\\s*\\?`, "giu");
461
+ for (const match of sql.matchAll(pattern)) {
462
+ const matchText = match[0];
463
+ const qIndex = match.index + matchText.lastIndexOf("?");
464
+ indexes.add(countQuestionMarks(sql, qIndex + 1));
465
+ }
466
+ }
467
+ return indexes;
468
+ }
469
+ function coerceInsertBooleanArgs(sql, args) {
470
+ const match = /^\s*INSERT(?:\s+OR\s+(?:IGNORE|REPLACE))?\s+INTO\s+([A-Za-z0-9_."]+)\s*\(([^)]+)\)/iu.exec(sql);
471
+ if (!match) return;
472
+ const rawTable = match[1];
473
+ const rawColumns = match[2];
474
+ const boolColumns = BOOLEAN_COLUMNS_BY_TABLE[unqualifiedTableName(rawTable)];
475
+ if (!boolColumns?.size) return;
476
+ const columns = rawColumns.split(",").map((col) => col.trim().replace(/^"|"$/g, ""));
477
+ for (const [index, column] of columns.entries()) {
478
+ if (boolColumns.has(column) && index < args.length) {
479
+ args[index] = toBoolean(args[index]);
480
+ }
481
+ }
482
+ }
483
+ function coerceUpdateBooleanArgs(sql, args) {
484
+ const match = /^\s*UPDATE\s+([A-Za-z0-9_."]+)\s+SET\s+([\s\S]+?)(?:\s+WHERE\b|$)/iu.exec(sql);
485
+ if (!match) return;
486
+ const rawTable = match[1];
487
+ const setClause = match[2];
488
+ const boolColumns = BOOLEAN_COLUMNS_BY_TABLE[unqualifiedTableName(rawTable)];
489
+ if (!boolColumns?.size) return;
490
+ const assignments = setClause.split(",");
491
+ let placeholderIndex = 0;
492
+ for (const assignment of assignments) {
493
+ if (!assignment.includes("?")) continue;
494
+ placeholderIndex += 1;
495
+ const colMatch = /^\s*(?:[A-Za-z_][A-Za-z0-9_]*\.)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*\?/iu.exec(assignment);
496
+ if (colMatch && boolColumns.has(colMatch[1])) {
497
+ args[placeholderIndex - 1] = toBoolean(args[placeholderIndex - 1]);
498
+ }
499
+ }
500
+ }
501
+ function coerceBooleanArgs(sql, args) {
502
+ const nextArgs = [...args];
503
+ coerceInsertBooleanArgs(sql, nextArgs);
504
+ coerceUpdateBooleanArgs(sql, nextArgs);
505
+ const placeholderIndexes = findBooleanPlaceholderIndexes(sql);
506
+ for (const index of placeholderIndexes) {
507
+ if (index > 0 && index <= nextArgs.length) {
508
+ nextArgs[index - 1] = toBoolean(nextArgs[index - 1]);
509
+ }
510
+ }
511
+ return nextArgs;
512
+ }
513
+ function convertQuestionMarksToDollarParams(sql) {
514
+ let out = "";
515
+ let placeholder = 0;
516
+ let inSingle = false;
517
+ let inDouble = false;
518
+ let inLineComment = false;
519
+ let inBlockComment = false;
520
+ for (let i = 0; i < sql.length; i++) {
521
+ const ch = sql[i];
522
+ const next = sql[i + 1];
523
+ if (inLineComment) {
524
+ out += ch;
525
+ if (ch === "\n") inLineComment = false;
526
+ continue;
527
+ }
528
+ if (inBlockComment) {
529
+ out += ch;
530
+ if (ch === "*" && next === "/") {
531
+ out += next;
532
+ inBlockComment = false;
533
+ i += 1;
534
+ }
535
+ continue;
536
+ }
537
+ if (!inSingle && !inDouble && ch === "-" && next === "-") {
538
+ out += ch + next;
539
+ inLineComment = true;
540
+ i += 1;
541
+ continue;
542
+ }
543
+ if (!inSingle && !inDouble && ch === "/" && next === "*") {
544
+ out += ch + next;
545
+ inBlockComment = true;
546
+ i += 1;
547
+ continue;
548
+ }
549
+ if (!inDouble && ch === "'" && sql[i - 1] !== "\\") {
550
+ inSingle = !inSingle;
551
+ out += ch;
552
+ continue;
553
+ }
554
+ if (!inSingle && ch === '"' && sql[i - 1] !== "\\") {
555
+ inDouble = !inDouble;
556
+ out += ch;
557
+ continue;
558
+ }
559
+ if (!inSingle && !inDouble && ch === "?") {
560
+ placeholder += 1;
561
+ out += `$${placeholder}`;
562
+ continue;
563
+ }
564
+ out += ch;
565
+ }
566
+ return out;
567
+ }
568
+ function translateStatementForPostgres(stmt) {
569
+ const normalized = normalizeStatement(stmt);
570
+ if (normalized.kind === "named") {
571
+ throw new Error("Named SQL parameters are not supported by the Prisma adapter.");
572
+ }
573
+ const rewrittenSql = rewriteSql(normalized.sql);
574
+ const coercedArgs = coerceBooleanArgs(rewrittenSql, normalized.args);
575
+ return {
576
+ sql: convertQuestionMarksToDollarParams(rewrittenSql),
577
+ args: coercedArgs
578
+ };
579
+ }
580
+ function shouldBypassPostgres(stmt) {
581
+ const normalized = normalizeStatement(stmt);
582
+ if (normalized.kind === "named") {
583
+ return true;
584
+ }
585
+ return IMMEDIATE_FALLBACK_PATTERNS.some((pattern) => pattern.test(normalized.sql));
586
+ }
587
+ function shouldFallbackOnError(error) {
588
+ const message = error instanceof Error ? error.message : String(error);
589
+ return /42P01|42883|42601|does not exist|syntax error|not supported|Named SQL parameters are not supported/iu.test(message);
590
+ }
591
+ function isReadQuery(sql) {
592
+ const trimmed = sql.trimStart();
593
+ return /^(SELECT|WITH|SHOW|EXPLAIN|VALUES)\b/iu.test(trimmed) || /\bRETURNING\b/iu.test(trimmed);
594
+ }
595
+ function buildRow(row, columns) {
596
+ const values = columns.map((column) => row[column]);
597
+ return Object.assign(values, row);
598
+ }
599
+ function buildResultSet(rows, rowsAffected = 0) {
600
+ const columns = rows[0] ? Object.keys(rows[0]) : [];
601
+ const resultRows = rows.map((row) => buildRow(row, columns));
602
+ return {
603
+ columns,
604
+ columnTypes: columns.map(() => ""),
605
+ rows: resultRows,
606
+ rowsAffected,
607
+ lastInsertRowid: void 0,
608
+ toJSON() {
609
+ return {
610
+ columns,
611
+ columnTypes: columns.map(() => ""),
612
+ rows,
613
+ rowsAffected,
614
+ lastInsertRowid: void 0
615
+ };
616
+ }
617
+ };
618
+ }
619
+ async function loadPrismaClient() {
620
+ if (!prismaClientPromise) {
621
+ prismaClientPromise = (async () => {
622
+ const explicitPath = process.env.EXE_OS_PRISMA_CLIENT_PATH;
623
+ if (explicitPath) {
624
+ const module2 = await import(pathToFileURL(explicitPath).href);
625
+ const PrismaClient2 = module2.PrismaClient ?? module2.default?.PrismaClient;
626
+ if (!PrismaClient2) {
627
+ throw new Error(`No PrismaClient export found at ${explicitPath}`);
628
+ }
629
+ return new PrismaClient2();
630
+ }
631
+ const exeDbRoot = process.env.EXE_DB_ROOT ?? path3.join(os3.homedir(), "exe-db");
632
+ const requireFromExeDb = createRequire(path3.join(exeDbRoot, "package.json"));
633
+ const prismaEntry = requireFromExeDb.resolve("@prisma/client");
634
+ const module = await import(pathToFileURL(prismaEntry).href);
635
+ const PrismaClient = module.PrismaClient ?? module.default?.PrismaClient;
636
+ if (!PrismaClient) {
637
+ throw new Error(`No PrismaClient export found in ${prismaEntry}`);
638
+ }
639
+ return new PrismaClient();
640
+ })();
641
+ }
642
+ return prismaClientPromise;
643
+ }
644
+ async function ensureCompatibilityViews(prisma) {
645
+ if (!compatibilityBootstrapPromise) {
646
+ compatibilityBootstrapPromise = (async () => {
647
+ for (const mapping of VIEW_MAPPINGS) {
648
+ const relation = mapping.source.replace(/"/g, "");
649
+ const rows = await prisma.$queryRawUnsafe(
650
+ "SELECT to_regclass($1) AS regclass",
651
+ relation
652
+ );
653
+ if (!rows[0]?.regclass) {
654
+ continue;
655
+ }
656
+ await prisma.$executeRawUnsafe(
657
+ `CREATE OR REPLACE VIEW public.${quotedIdentifier(mapping.view)} AS SELECT * FROM ${mapping.source}`
658
+ );
659
+ }
660
+ })();
661
+ }
662
+ return compatibilityBootstrapPromise;
663
+ }
664
+ async function executeOnPrisma(executor, stmt) {
665
+ const translated = translateStatementForPostgres(stmt);
666
+ if (isReadQuery(translated.sql)) {
667
+ const rows = await executor.$queryRawUnsafe(
668
+ translated.sql,
669
+ ...translated.args
670
+ );
671
+ return buildResultSet(rows, /\bRETURNING\b/iu.test(translated.sql) ? rows.length : 0);
672
+ }
673
+ const rowsAffected = await executor.$executeRawUnsafe(translated.sql, ...translated.args);
674
+ return buildResultSet([], rowsAffected);
675
+ }
676
+ function splitSqlStatements(sql) {
677
+ const parts = [];
678
+ let current = "";
679
+ let inSingle = false;
680
+ let inDouble = false;
681
+ let inLineComment = false;
682
+ let inBlockComment = false;
683
+ for (let i = 0; i < sql.length; i++) {
684
+ const ch = sql[i];
685
+ const next = sql[i + 1];
686
+ if (inLineComment) {
687
+ current += ch;
688
+ if (ch === "\n") inLineComment = false;
689
+ continue;
690
+ }
691
+ if (inBlockComment) {
692
+ current += ch;
693
+ if (ch === "*" && next === "/") {
694
+ current += next;
695
+ inBlockComment = false;
696
+ i += 1;
697
+ }
698
+ continue;
699
+ }
700
+ if (!inSingle && !inDouble && ch === "-" && next === "-") {
701
+ current += ch + next;
702
+ inLineComment = true;
703
+ i += 1;
704
+ continue;
705
+ }
706
+ if (!inSingle && !inDouble && ch === "/" && next === "*") {
707
+ current += ch + next;
708
+ inBlockComment = true;
709
+ i += 1;
710
+ continue;
711
+ }
712
+ if (!inDouble && ch === "'" && sql[i - 1] !== "\\") {
713
+ inSingle = !inSingle;
714
+ current += ch;
715
+ continue;
716
+ }
717
+ if (!inSingle && ch === '"' && sql[i - 1] !== "\\") {
718
+ inDouble = !inDouble;
719
+ current += ch;
720
+ continue;
721
+ }
722
+ if (!inSingle && !inDouble && ch === ";") {
723
+ if (current.trim()) {
724
+ parts.push(current.trim());
725
+ }
726
+ current = "";
727
+ continue;
728
+ }
729
+ current += ch;
730
+ }
731
+ if (current.trim()) {
732
+ parts.push(current.trim());
733
+ }
734
+ return parts;
735
+ }
736
+ async function createPrismaDbAdapter(fallbackClient) {
737
+ const prisma = await loadPrismaClient();
738
+ await ensureCompatibilityViews(prisma);
739
+ let closed = false;
740
+ let adapter;
741
+ const fallbackExecute = async (stmt, error) => {
742
+ if (!fallbackClient) {
743
+ if (error) throw error;
744
+ throw new Error("No fallback SQLite client is available for this Prisma-routed query.");
745
+ }
746
+ if (error) {
747
+ process.stderr.write(
748
+ `[database-adapter] Falling back to SQLite: ${error instanceof Error ? error.message : String(error)}
749
+ `
750
+ );
751
+ }
752
+ return fallbackClient.execute(stmt);
753
+ };
754
+ adapter = {
755
+ async execute(stmt) {
756
+ if (shouldBypassPostgres(stmt)) {
757
+ return fallbackExecute(stmt);
758
+ }
759
+ try {
760
+ return await executeOnPrisma(prisma, stmt);
761
+ } catch (error) {
762
+ if (shouldFallbackOnError(error)) {
763
+ return fallbackExecute(stmt, error);
764
+ }
765
+ throw error;
766
+ }
767
+ },
768
+ async batch(stmts, mode) {
769
+ if (stmts.some((stmt) => shouldBypassPostgres(stmt))) {
770
+ if (!fallbackClient) {
771
+ throw new Error("Cannot batch unsupported SQLite-only statements without a fallback client.");
772
+ }
773
+ return fallbackClient.batch(stmts, mode);
774
+ }
775
+ try {
776
+ if (prisma.$transaction) {
777
+ return await prisma.$transaction(async (tx) => {
778
+ const results2 = [];
779
+ for (const stmt of stmts) {
780
+ results2.push(await executeOnPrisma(tx, stmt));
781
+ }
782
+ return results2;
783
+ });
784
+ }
785
+ const results = [];
786
+ for (const stmt of stmts) {
787
+ results.push(await executeOnPrisma(prisma, stmt));
788
+ }
789
+ return results;
790
+ } catch (error) {
791
+ if (fallbackClient && shouldFallbackOnError(error)) {
792
+ process.stderr.write(
793
+ `[database-adapter] Falling back batch to SQLite: ${error instanceof Error ? error.message : String(error)}
794
+ `
795
+ );
796
+ return fallbackClient.batch(stmts, mode);
797
+ }
798
+ throw error;
799
+ }
800
+ },
801
+ async migrate(stmts) {
802
+ if (fallbackClient) {
803
+ return fallbackClient.migrate(stmts);
804
+ }
805
+ return adapter.batch(stmts, "deferred");
806
+ },
807
+ async transaction(mode) {
808
+ if (!fallbackClient) {
809
+ throw new Error("Interactive transactions are only supported on the SQLite fallback client.");
810
+ }
811
+ return fallbackClient.transaction(mode);
812
+ },
813
+ async executeMultiple(sql) {
814
+ if (fallbackClient && shouldBypassPostgres(sql)) {
815
+ return fallbackClient.executeMultiple(sql);
816
+ }
817
+ for (const statement of splitSqlStatements(sql)) {
818
+ await adapter.execute(statement);
819
+ }
820
+ },
821
+ async sync() {
822
+ if (fallbackClient) {
823
+ return fallbackClient.sync();
824
+ }
825
+ return { frame_no: 0, frames_synced: 0 };
826
+ },
827
+ close() {
828
+ closed = true;
829
+ prismaClientPromise = null;
830
+ compatibilityBootstrapPromise = null;
831
+ void prisma.$disconnect?.();
832
+ },
833
+ get closed() {
834
+ return closed;
835
+ },
836
+ get protocol() {
837
+ return "prisma-postgres";
838
+ }
839
+ };
840
+ return adapter;
841
+ }
842
+ var VIEW_MAPPINGS, UPSERT_KEYS, BOOLEAN_COLUMNS_BY_TABLE, BOOLEAN_COLUMN_NAMES, IMMEDIATE_FALLBACK_PATTERNS, prismaClientPromise, compatibilityBootstrapPromise;
843
+ var init_database_adapter = __esm({
844
+ "src/lib/database-adapter.ts"() {
845
+ "use strict";
846
+ VIEW_MAPPINGS = [
847
+ { view: "memories", source: "memory.memory_records" },
848
+ { view: "tasks", source: "memory.tasks" },
849
+ { view: "behaviors", source: "memory.behaviors" },
850
+ { view: "entities", source: "memory.entities" },
851
+ { view: "relationships", source: "memory.relationships" },
852
+ { view: "entity_memories", source: "memory.entity_memories" },
853
+ { view: "entity_aliases", source: "memory.entity_aliases" },
854
+ { view: "notifications", source: "memory.notifications" },
855
+ { view: "messages", source: "memory.messages" },
856
+ { view: "users", source: "wiki.users" },
857
+ { view: "workspaces", source: "wiki.workspaces" },
858
+ { view: "workspace_users", source: "wiki.workspace_users" },
859
+ { view: "documents", source: "wiki.workspace_documents" },
860
+ { view: "chats", source: "wiki.workspace_chats" }
861
+ ];
862
+ UPSERT_KEYS = {
863
+ memories: ["id"],
864
+ tasks: ["id"],
865
+ behaviors: ["id"],
866
+ entities: ["id"],
867
+ relationships: ["id"],
868
+ entity_aliases: ["alias"],
869
+ notifications: ["id"],
870
+ messages: ["id"],
871
+ users: ["id"],
872
+ workspaces: ["id"],
873
+ workspace_users: ["id"],
874
+ documents: ["id"],
875
+ chats: ["id"]
876
+ };
877
+ BOOLEAN_COLUMNS_BY_TABLE = {
878
+ memories: /* @__PURE__ */ new Set(["has_error", "draft"]),
879
+ behaviors: /* @__PURE__ */ new Set(["active"]),
880
+ notifications: /* @__PURE__ */ new Set(["read"]),
881
+ users: /* @__PURE__ */ new Set(["has_personal_memory"])
882
+ };
883
+ BOOLEAN_COLUMN_NAMES = new Set(
884
+ Object.values(BOOLEAN_COLUMNS_BY_TABLE).flatMap((cols) => [...cols])
885
+ );
886
+ IMMEDIATE_FALLBACK_PATTERNS = [
887
+ /\bPRAGMA\b/i,
888
+ /\bsqlite_master\b/i,
889
+ /(?:^|[.\s])(?:memories|conversations|entities)_fts\b/i,
890
+ /\bMATCH\b/i,
891
+ /\bvector_distance_cos\s*\(/i,
892
+ /\bjson_extract\s*\(/i,
893
+ /\bjulianday\s*\(/i,
894
+ /\bstrftime\s*\(/i,
895
+ /\blast_insert_rowid\s*\(/i
896
+ ];
897
+ prismaClientPromise = null;
898
+ compatibilityBootstrapPromise = null;
314
899
  }
315
900
  });
316
901
 
317
902
  // src/lib/database.ts
318
903
  import { createClient } from "@libsql/client";
319
904
  async function initDatabase(config) {
905
+ if (_walCheckpointTimer) {
906
+ clearInterval(_walCheckpointTimer);
907
+ _walCheckpointTimer = null;
908
+ }
909
+ if (_daemonClient) {
910
+ _daemonClient.close();
911
+ _daemonClient = null;
912
+ }
913
+ if (_adapterClient && _adapterClient !== _resilientClient) {
914
+ _adapterClient.close();
915
+ }
916
+ _adapterClient = null;
320
917
  if (_client) {
321
918
  _client.close();
322
919
  _client = null;
@@ -330,6 +927,7 @@ async function initDatabase(config) {
330
927
  }
331
928
  _client = createClient(opts);
332
929
  _resilientClient = wrapWithRetry(_client);
930
+ _adapterClient = _resilientClient;
333
931
  _client.execute("PRAGMA busy_timeout = 30000").catch(() => {
334
932
  });
335
933
  _client.execute("PRAGMA journal_mode = WAL").catch(() => {
@@ -340,11 +938,17 @@ async function initDatabase(config) {
340
938
  });
341
939
  }, 3e4);
342
940
  _walCheckpointTimer.unref();
941
+ if (process.env.DATABASE_URL) {
942
+ _adapterClient = await createPrismaDbAdapter(_resilientClient);
943
+ }
343
944
  }
344
945
  function getClient() {
345
- if (!_resilientClient) {
946
+ if (!_adapterClient) {
346
947
  throw new Error("Database client not initialized. Call initDatabase() first.");
347
948
  }
949
+ if (process.env.DATABASE_URL) {
950
+ return _adapterClient;
951
+ }
348
952
  if (process.env.EXE_IS_DAEMON === "1") {
349
953
  return _resilientClient;
350
954
  }
@@ -1284,16 +1888,18 @@ async function ensureSchema() {
1284
1888
  }
1285
1889
  }
1286
1890
  }
1287
- var _client, _resilientClient, _walCheckpointTimer, _daemonClient, initTurso;
1891
+ var _client, _resilientClient, _walCheckpointTimer, _daemonClient, _adapterClient, initTurso;
1288
1892
  var init_database = __esm({
1289
1893
  "src/lib/database.ts"() {
1290
1894
  "use strict";
1291
1895
  init_db_retry();
1292
1896
  init_employees();
1897
+ init_database_adapter();
1293
1898
  _client = null;
1294
1899
  _resilientClient = null;
1295
1900
  _walCheckpointTimer = null;
1296
1901
  _daemonClient = null;
1902
+ _adapterClient = null;
1297
1903
  initTurso = initDatabase;
1298
1904
  }
1299
1905
  });
@@ -1366,7 +1972,7 @@ __export(shard_manager_exports, {
1366
1972
  listShards: () => listShards,
1367
1973
  shardExists: () => shardExists
1368
1974
  });
1369
- import path4 from "path";
1975
+ import path5 from "path";
1370
1976
  import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
1371
1977
  import { createClient as createClient2 } from "@libsql/client";
1372
1978
  function initShardManager(encryptionKey) {
@@ -1392,7 +1998,7 @@ function getShardClient(projectName) {
1392
1998
  }
1393
1999
  const cached = _shards.get(safeName);
1394
2000
  if (cached) return cached;
1395
- const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
2001
+ const dbPath = path5.join(SHARDS_DIR, `${safeName}.db`);
1396
2002
  const client = createClient2({
1397
2003
  url: `file:${dbPath}`,
1398
2004
  encryptionKey: _encryptionKey
@@ -1402,7 +2008,7 @@ function getShardClient(projectName) {
1402
2008
  }
1403
2009
  function shardExists(projectName) {
1404
2010
  const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
1405
- return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
2011
+ return existsSync4(path5.join(SHARDS_DIR, `${safeName}.db`));
1406
2012
  }
1407
2013
  function listShards() {
1408
2014
  if (!existsSync4(SHARDS_DIR)) return [];
@@ -1479,7 +2085,23 @@ async function ensureShardSchema(client) {
1479
2085
  // MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
1480
2086
  "ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
1481
2087
  "ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
1482
- "ALTER TABLE memories ADD COLUMN trajectory TEXT"
2088
+ "ALTER TABLE memories ADD COLUMN trajectory TEXT",
2089
+ // Metadata enrichment columns (must match database.ts)
2090
+ "ALTER TABLE memories ADD COLUMN intent TEXT",
2091
+ "ALTER TABLE memories ADD COLUMN outcome TEXT",
2092
+ "ALTER TABLE memories ADD COLUMN domain TEXT",
2093
+ "ALTER TABLE memories ADD COLUMN referenced_entities TEXT",
2094
+ "ALTER TABLE memories ADD COLUMN retrieval_count INTEGER DEFAULT 0",
2095
+ "ALTER TABLE memories ADD COLUMN chain_position TEXT",
2096
+ "ALTER TABLE memories ADD COLUMN review_status TEXT",
2097
+ "ALTER TABLE memories ADD COLUMN context_window_pct INTEGER",
2098
+ "ALTER TABLE memories ADD COLUMN file_paths TEXT",
2099
+ "ALTER TABLE memories ADD COLUMN commit_hash TEXT",
2100
+ "ALTER TABLE memories ADD COLUMN duration_ms INTEGER",
2101
+ "ALTER TABLE memories ADD COLUMN token_cost REAL",
2102
+ "ALTER TABLE memories ADD COLUMN audience TEXT",
2103
+ "ALTER TABLE memories ADD COLUMN language_type TEXT",
2104
+ "ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
1483
2105
  ]) {
1484
2106
  try {
1485
2107
  await client.execute(col);
@@ -1591,7 +2213,7 @@ var init_shard_manager = __esm({
1591
2213
  "src/lib/shard-manager.ts"() {
1592
2214
  "use strict";
1593
2215
  init_config();
1594
- SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
2216
+ SHARDS_DIR = path5.join(EXE_AI_DIR, "shards");
1595
2217
  _shards = /* @__PURE__ */ new Map();
1596
2218
  _encryptionKey = null;
1597
2219
  _shardingEnabled = false;
@@ -1787,8 +2409,8 @@ ${p.content}`).join("\n\n");
1787
2409
 
1788
2410
  // src/lib/notifications.ts
1789
2411
  import crypto from "crypto";
1790
- import path5 from "path";
1791
- import os4 from "os";
2412
+ import path6 from "path";
2413
+ import os5 from "os";
1792
2414
  import {
1793
2415
  readFileSync as readFileSync3,
1794
2416
  readdirSync as readdirSync2,
@@ -1804,13 +2426,13 @@ var init_notifications = __esm({
1804
2426
  });
1805
2427
 
1806
2428
  // src/lib/session-registry.ts
1807
- import path6 from "path";
1808
- import os5 from "os";
2429
+ import path7 from "path";
2430
+ import os6 from "os";
1809
2431
  var REGISTRY_PATH;
1810
2432
  var init_session_registry = __esm({
1811
2433
  "src/lib/session-registry.ts"() {
1812
2434
  "use strict";
1813
- REGISTRY_PATH = path6.join(os5.homedir(), ".exe-os", "session-registry.json");
2435
+ REGISTRY_PATH = path7.join(os6.homedir(), ".exe-os", "session-registry.json");
1814
2436
  }
1815
2437
  });
1816
2438
 
@@ -2046,14 +2668,14 @@ var init_runtime_table = __esm({
2046
2668
 
2047
2669
  // src/lib/agent-config.ts
2048
2670
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync6, mkdirSync as mkdirSync2 } from "fs";
2049
- import path7 from "path";
2671
+ import path8 from "path";
2050
2672
  var AGENT_CONFIG_PATH, DEFAULT_MODELS;
2051
2673
  var init_agent_config = __esm({
2052
2674
  "src/lib/agent-config.ts"() {
2053
2675
  "use strict";
2054
2676
  init_config();
2055
2677
  init_runtime_table();
2056
- AGENT_CONFIG_PATH = path7.join(EXE_AI_DIR, "agent-config.json");
2678
+ AGENT_CONFIG_PATH = path8.join(EXE_AI_DIR, "agent-config.json");
2057
2679
  DEFAULT_MODELS = {
2058
2680
  claude: "claude-opus-4",
2059
2681
  codex: RUNTIME_TABLE.codex?.defaultModel ?? "gpt-5.4",
@@ -2064,37 +2686,37 @@ var init_agent_config = __esm({
2064
2686
 
2065
2687
  // src/lib/intercom-queue.ts
2066
2688
  import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, renameSync as renameSync3, existsSync as existsSync7, mkdirSync as mkdirSync3 } from "fs";
2067
- import path8 from "path";
2068
- import os6 from "os";
2689
+ import path9 from "path";
2690
+ import os7 from "os";
2069
2691
  var QUEUE_PATH, TTL_MS, INTERCOM_LOG;
2070
2692
  var init_intercom_queue = __esm({
2071
2693
  "src/lib/intercom-queue.ts"() {
2072
2694
  "use strict";
2073
- QUEUE_PATH = path8.join(os6.homedir(), ".exe-os", "intercom-queue.json");
2695
+ QUEUE_PATH = path9.join(os7.homedir(), ".exe-os", "intercom-queue.json");
2074
2696
  TTL_MS = 60 * 60 * 1e3;
2075
- INTERCOM_LOG = path8.join(os6.homedir(), ".exe-os", "intercom.log");
2697
+ INTERCOM_LOG = path9.join(os7.homedir(), ".exe-os", "intercom.log");
2076
2698
  }
2077
2699
  });
2078
2700
 
2079
2701
  // src/lib/license.ts
2080
2702
  import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
2081
2703
  import { randomUUID as randomUUID2 } from "crypto";
2082
- import path9 from "path";
2704
+ import path10 from "path";
2083
2705
  import { jwtVerify, importSPKI } from "jose";
2084
2706
  var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH;
2085
2707
  var init_license = __esm({
2086
2708
  "src/lib/license.ts"() {
2087
2709
  "use strict";
2088
2710
  init_config();
2089
- LICENSE_PATH = path9.join(EXE_AI_DIR, "license.key");
2090
- CACHE_PATH = path9.join(EXE_AI_DIR, "license-cache.json");
2091
- DEVICE_ID_PATH = path9.join(EXE_AI_DIR, "device-id");
2711
+ LICENSE_PATH = path10.join(EXE_AI_DIR, "license.key");
2712
+ CACHE_PATH = path10.join(EXE_AI_DIR, "license-cache.json");
2713
+ DEVICE_ID_PATH = path10.join(EXE_AI_DIR, "device-id");
2092
2714
  }
2093
2715
  });
2094
2716
 
2095
2717
  // src/lib/plan-limits.ts
2096
2718
  import { readFileSync as readFileSync7, existsSync as existsSync9 } from "fs";
2097
- import path10 from "path";
2719
+ import path11 from "path";
2098
2720
  var CACHE_PATH2;
2099
2721
  var init_plan_limits = __esm({
2100
2722
  "src/lib/plan-limits.ts"() {
@@ -2103,14 +2725,14 @@ var init_plan_limits = __esm({
2103
2725
  init_employees();
2104
2726
  init_license();
2105
2727
  init_config();
2106
- CACHE_PATH2 = path10.join(EXE_AI_DIR, "license-cache.json");
2728
+ CACHE_PATH2 = path11.join(EXE_AI_DIR, "license-cache.json");
2107
2729
  }
2108
2730
  });
2109
2731
 
2110
2732
  // src/lib/tmux-routing.ts
2111
2733
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync10, appendFileSync, readdirSync as readdirSync3 } from "fs";
2112
- import path11 from "path";
2113
- import os7 from "os";
2734
+ import path12 from "path";
2735
+ import os8 from "os";
2114
2736
  import { fileURLToPath as fileURLToPath2 } from "url";
2115
2737
  function getMySession() {
2116
2738
  return getTransport().getMySession();
@@ -2123,7 +2745,7 @@ function extractRootExe(name) {
2123
2745
  }
2124
2746
  function getParentExe(sessionKey) {
2125
2747
  try {
2126
- const data = JSON.parse(readFileSync8(path11.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`), "utf8"));
2748
+ const data = JSON.parse(readFileSync8(path12.join(SESSION_CACHE, `parent-exe-${sessionKey}.json`), "utf8"));
2127
2749
  return data.parentExe || null;
2128
2750
  } catch {
2129
2751
  return null;
@@ -2171,16 +2793,16 @@ var init_tmux_routing = __esm({
2171
2793
  init_intercom_queue();
2172
2794
  init_plan_limits();
2173
2795
  init_employees();
2174
- SPAWN_LOCK_DIR = path11.join(os7.homedir(), ".exe-os", "spawn-locks");
2175
- SESSION_CACHE = path11.join(os7.homedir(), ".exe-os", "session-cache");
2176
- INTERCOM_LOG2 = path11.join(os7.homedir(), ".exe-os", "intercom.log");
2177
- DEBOUNCE_FILE = path11.join(SESSION_CACHE, "intercom-debounce.json");
2796
+ SPAWN_LOCK_DIR = path12.join(os8.homedir(), ".exe-os", "spawn-locks");
2797
+ SESSION_CACHE = path12.join(os8.homedir(), ".exe-os", "session-cache");
2798
+ INTERCOM_LOG2 = path12.join(os8.homedir(), ".exe-os", "intercom.log");
2799
+ DEBOUNCE_FILE = path12.join(SESSION_CACHE, "intercom-debounce.json");
2178
2800
  DEBOUNCE_CLEANUP_AGE_MS = 5 * 60 * 1e3;
2179
2801
  }
2180
2802
  });
2181
2803
 
2182
2804
  // src/lib/tasks-review.ts
2183
- import path12 from "path";
2805
+ import path13 from "path";
2184
2806
  import { existsSync as existsSync11, readdirSync as readdirSync4, unlinkSync as unlinkSync3 } from "fs";
2185
2807
  async function listPendingReviews(limit, sessionScope) {
2186
2808
  const client = getClient();
@@ -2242,8 +2864,8 @@ var init_task_scope = __esm({
2242
2864
  // src/bin/exe-heartbeat.ts
2243
2865
  import { createHash as createHash2 } from "crypto";
2244
2866
  import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6 } from "fs";
2245
- import os8 from "os";
2246
- import path13 from "path";
2867
+ import os9 from "os";
2868
+ import path14 from "path";
2247
2869
 
2248
2870
  // src/lib/store.ts
2249
2871
  import { createHash } from "crypto";
@@ -2252,15 +2874,15 @@ init_database();
2252
2874
  // src/lib/keychain.ts
2253
2875
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
2254
2876
  import { existsSync as existsSync3 } from "fs";
2255
- import path3 from "path";
2256
- import os3 from "os";
2877
+ import path4 from "path";
2878
+ import os4 from "os";
2257
2879
  var SERVICE = "exe-mem";
2258
2880
  var ACCOUNT = "master-key";
2259
2881
  function getKeyDir() {
2260
- return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
2882
+ return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path4.join(os4.homedir(), ".exe-os");
2261
2883
  }
2262
2884
  function getKeyPath() {
2263
- return path3.join(getKeyDir(), "master.key");
2885
+ return path4.join(getKeyDir(), "master.key");
2264
2886
  }
2265
2887
  async function tryKeytar() {
2266
2888
  try {
@@ -2283,7 +2905,7 @@ async function getMasterKey() {
2283
2905
  const keyPath = getKeyPath();
2284
2906
  if (!existsSync3(keyPath)) {
2285
2907
  process.stderr.write(
2286
- `[keychain] Key not found at ${keyPath} (HOME=${os3.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
2908
+ `[keychain] Key not found at ${keyPath} (HOME=${os4.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
2287
2909
  `
2288
2910
  );
2289
2911
  return null;
@@ -2416,13 +3038,13 @@ var MESSAGE_PREVIEW_CHARS = 80;
2416
3038
  var MARKER_FILENAME = "exe-heartbeat-marker.json";
2417
3039
  var SESSION_CACHE_SUBDIR = "session-cache";
2418
3040
  function resolveExeOsDir() {
2419
- return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path13.join(os8.homedir(), ".exe-os");
3041
+ return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path14.join(os9.homedir(), ".exe-os");
2420
3042
  }
2421
3043
  function getMarkerDir() {
2422
- return path13.join(resolveExeOsDir(), SESSION_CACHE_SUBDIR);
3044
+ return path14.join(resolveExeOsDir(), SESSION_CACHE_SUBDIR);
2423
3045
  }
2424
3046
  function getMarkerPath() {
2425
- return path13.join(getMarkerDir(), MARKER_FILENAME);
3047
+ return path14.join(getMarkerDir(), MARKER_FILENAME);
2426
3048
  }
2427
3049
  var UNREAD_MESSAGE_STATUSES = ["pending", "delivered"];
2428
3050
  function readMarker() {