@askexenow/exe-os 0.9.87 → 0.9.89

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 (102) hide show
  1. package/deploy/compose/docker-compose.yml +3 -3
  2. package/dist/bin/age-ontology-load.js +8 -2
  3. package/dist/bin/agentic-ontology-backfill.js +11 -0
  4. package/dist/bin/agentic-reflection-backfill.js +11 -0
  5. package/dist/bin/agentic-semantic-label.js +11 -0
  6. package/dist/bin/backfill-conversations.js +12 -0
  7. package/dist/bin/backfill-responses.js +12 -0
  8. package/dist/bin/backfill-vectors.js +12 -0
  9. package/dist/bin/bulk-sync-postgres.js +29 -1
  10. package/dist/bin/cc-doctor.js +3 -2
  11. package/dist/bin/cleanup-stale-review-tasks.js +12 -0
  12. package/dist/bin/cli.js +170 -15
  13. package/dist/bin/exe-agent.js +1 -0
  14. package/dist/bin/exe-assign.js +12 -0
  15. package/dist/bin/exe-boot.js +139 -4
  16. package/dist/bin/exe-call.js +2 -0
  17. package/dist/bin/exe-cloud.js +138 -3
  18. package/dist/bin/exe-dispatch.js +12 -1
  19. package/dist/bin/exe-doctor.js +12 -0
  20. package/dist/bin/exe-export-behaviors.js +11 -0
  21. package/dist/bin/exe-forget.js +12 -0
  22. package/dist/bin/exe-gateway.js +132 -35
  23. package/dist/bin/exe-healthcheck.js +2 -1
  24. package/dist/bin/exe-heartbeat.js +12 -0
  25. package/dist/bin/exe-kill.js +11 -0
  26. package/dist/bin/exe-launch-agent.js +11 -0
  27. package/dist/bin/exe-new-employee.js +4 -2
  28. package/dist/bin/exe-pending-messages.js +11 -0
  29. package/dist/bin/exe-pending-notifications.js +12 -0
  30. package/dist/bin/exe-pending-reviews.js +12 -0
  31. package/dist/bin/exe-rename.js +12 -0
  32. package/dist/bin/exe-review.js +12 -0
  33. package/dist/bin/exe-search.js +12 -0
  34. package/dist/bin/exe-session-cleanup.js +12 -1
  35. package/dist/bin/exe-settings.js +3 -0
  36. package/dist/bin/exe-start-codex.js +13 -2
  37. package/dist/bin/exe-start-opencode.js +13 -2
  38. package/dist/bin/exe-status.js +12 -0
  39. package/dist/bin/exe-team.js +12 -0
  40. package/dist/bin/git-sweep.js +12 -1
  41. package/dist/bin/graph-backfill.js +11 -0
  42. package/dist/bin/graph-export.js +11 -0
  43. package/dist/bin/graph-layer-benchmark.js +9 -1
  44. package/dist/bin/intercom-check.js +13 -1
  45. package/dist/bin/list-providers.js +1 -0
  46. package/dist/bin/postgres-agentic-reflection-backfill.js +7 -1
  47. package/dist/bin/postgres-agentic-semantic-backfill.js +7 -1
  48. package/dist/bin/registry-proxy.js +1 -0
  49. package/dist/bin/scan-tasks.js +13 -1
  50. package/dist/bin/setup.js +141 -7
  51. package/dist/bin/shard-migrate.js +11 -0
  52. package/dist/bin/stack-update.js +24 -7
  53. package/dist/bin/update.js +5 -0
  54. package/dist/gateway/index.js +12 -1
  55. package/dist/hooks/bug-report-worker.js +12 -1
  56. package/dist/hooks/codex-stop-task-finalizer.js +12 -1
  57. package/dist/hooks/commit-complete.js +12 -1
  58. package/dist/hooks/error-recall.js +11 -0
  59. package/dist/hooks/ingest.js +11 -0
  60. package/dist/hooks/instructions-loaded.js +11 -0
  61. package/dist/hooks/notification.js +11 -0
  62. package/dist/hooks/post-compact.js +11 -0
  63. package/dist/hooks/post-tool-combined.js +11 -0
  64. package/dist/hooks/pre-compact.js +12 -1
  65. package/dist/hooks/pre-tool-use.js +11 -0
  66. package/dist/hooks/prompt-submit.js +12 -1
  67. package/dist/hooks/session-end.js +12 -1
  68. package/dist/hooks/session-start.js +11 -0
  69. package/dist/hooks/stop.js +11 -0
  70. package/dist/hooks/subagent-stop.js +11 -0
  71. package/dist/hooks/summary-worker.js +137 -3
  72. package/dist/index.js +12 -1
  73. package/dist/lib/cloud-sync.js +136 -2
  74. package/dist/lib/consolidation.js +1 -0
  75. package/dist/lib/database.js +11 -0
  76. package/dist/lib/db.js +11 -0
  77. package/dist/lib/device-registry.js +11 -0
  78. package/dist/lib/employee-templates.js +1 -0
  79. package/dist/lib/exe-daemon.js +771 -49
  80. package/dist/lib/hybrid-search.js +11 -0
  81. package/dist/lib/identity.js +1 -0
  82. package/dist/lib/messaging.js +2 -1
  83. package/dist/lib/reminders.js +1 -0
  84. package/dist/lib/schedules.js +11 -0
  85. package/dist/lib/skill-learning.js +1 -0
  86. package/dist/lib/store.js +11 -0
  87. package/dist/lib/tasks.js +2 -1
  88. package/dist/lib/tmux-routing.js +2 -1
  89. package/dist/lib/token-spend.js +1 -0
  90. package/dist/lib/ws-client.js +8 -0
  91. package/dist/mcp/server.js +613 -27
  92. package/dist/mcp/tools/complete-reminder.js +1 -0
  93. package/dist/mcp/tools/create-reminder.js +1 -0
  94. package/dist/mcp/tools/create-task.js +2 -1
  95. package/dist/mcp/tools/deactivate-behavior.js +1 -0
  96. package/dist/mcp/tools/list-reminders.js +1 -0
  97. package/dist/mcp/tools/list-tasks.js +1 -0
  98. package/dist/mcp/tools/send-message.js +2 -1
  99. package/dist/mcp/tools/update-task.js +2 -1
  100. package/dist/runtime/index.js +12 -1
  101. package/dist/tui/App.js +12 -1
  102. package/package.json +2 -2
@@ -245,7 +245,7 @@ services:
245
245
  environment:
246
246
  NODE_ENV: production
247
247
  EXED_PORT: "8765"
248
- EXED_HOST: 0.0.0.0
248
+ EXED_HOST: "127.0.0.1"
249
249
  EXED_MCP_TOKEN: ${EXED_MCP_TOKEN:?EXED_MCP_TOKEN is required}
250
250
  EXED_DEVICE_ID: ${EXED_DEVICE_ID:-vps-default}
251
251
  EXE_LICENSE_KEY: ${EXE_LICENSE_KEY:?EXE_LICENSE_KEY is required — purchase at https://askexe.com}
@@ -286,11 +286,11 @@ services:
286
286
  EXE_GATEWAY_HOME: /data
287
287
  EXE_GATEWAY_CONFIG: /data/gateway.json
288
288
  EXE_GATEWAY_PORT: "3100"
289
- EXE_GATEWAY_HOST: 0.0.0.0
289
+ EXE_GATEWAY_HOST: "127.0.0.1"
290
290
  EXE_GATEWAY_AUTH_TOKEN: ${EXE_GATEWAY_AUTH_TOKEN:?EXE_GATEWAY_AUTH_TOKEN is required}
291
291
  EXE_GATEWAY_WHATSAPP_VERIFY_TOKEN: ${EXE_GATEWAY_WHATSAPP_VERIFY_TOKEN:?EXE_GATEWAY_WHATSAPP_VERIFY_TOKEN is required}
292
292
  EXE_GATEWAY_WS_RELAY_ENABLED: "true"
293
- EXE_GATEWAY_WS_RELAY_HOST: 0.0.0.0
293
+ EXE_GATEWAY_WS_RELAY_HOST: "127.0.0.1"
294
294
  EXE_GATEWAY_WS_RELAY_PORT: "3101"
295
295
  EXE_GATEWAY_WS_RELAY_AUTH_TOKEN: ${EXE_GATEWAY_WS_RELAY_AUTH_TOKEN:?EXE_GATEWAY_WS_RELAY_AUTH_TOKEN is required}
296
296
  WHATSAPP_ACCESS_TOKEN: ${WHATSAPP_ACCESS_TOKEN:-}
@@ -3,6 +3,12 @@
3
3
  // src/bin/age-ontology-load.ts
4
4
  import { Client } from "pg";
5
5
 
6
+ // src/lib/pg-ssl.ts
7
+ function pgSslConfig() {
8
+ if (process.env.EXE_DB_SSL_DISABLED === "true") return {};
9
+ return { ssl: { rejectUnauthorized: process.env.EXE_DB_SSL_ALLOW_SELFSIGNED !== "true" } };
10
+ }
11
+
6
12
  // src/lib/background-jobs.ts
7
13
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync, unlinkSync } from "fs";
8
14
  import { execFileSync } from "child_process";
@@ -272,8 +278,8 @@ async function main() {
272
278
  if (!ageUrl) throw new Error("AGE_DATABASE_URL is required for Apache AGE target");
273
279
  const graph = process.env.AGE_GRAPH_NAME || "exe_ontology";
274
280
  const limit = Number(process.argv[process.argv.indexOf("--limit") + 1] || "1000");
275
- const source = new Client({ connectionString: sourceUrl });
276
- const age = new Client({ connectionString: ageUrl });
281
+ const source = new Client({ connectionString: sourceUrl, ...pgSslConfig() });
282
+ const age = new Client({ connectionString: ageUrl, ...pgSslConfig() });
277
283
  await source.connect();
278
284
  await age.connect();
279
285
  try {
@@ -1487,6 +1487,7 @@ __export(database_exports, {
1487
1487
  isInitialized: () => isInitialized,
1488
1488
  setExternalClient: () => setExternalClient
1489
1489
  });
1490
+ import { chmodSync as chmodSync2 } from "fs";
1490
1491
  import { createClient } from "@libsql/client";
1491
1492
  async function initDatabase(config) {
1492
1493
  if (_walCheckpointTimer) {
@@ -1528,6 +1529,16 @@ async function initDatabase(config) {
1528
1529
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1529
1530
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1530
1531
  }
1532
+ try {
1533
+ chmodSync2(config.dbPath, 384);
1534
+ for (const suffix of ["-wal", "-shm"]) {
1535
+ try {
1536
+ chmodSync2(config.dbPath + suffix, 384);
1537
+ } catch {
1538
+ }
1539
+ }
1540
+ } catch {
1541
+ }
1531
1542
  }
1532
1543
  function isInitialized() {
1533
1544
  return _adapterClient !== null || _client !== null;
@@ -1487,6 +1487,7 @@ __export(database_exports, {
1487
1487
  isInitialized: () => isInitialized,
1488
1488
  setExternalClient: () => setExternalClient
1489
1489
  });
1490
+ import { chmodSync as chmodSync2 } from "fs";
1490
1491
  import { createClient } from "@libsql/client";
1491
1492
  async function initDatabase(config) {
1492
1493
  if (_walCheckpointTimer) {
@@ -1528,6 +1529,16 @@ async function initDatabase(config) {
1528
1529
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1529
1530
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1530
1531
  }
1532
+ try {
1533
+ chmodSync2(config.dbPath, 384);
1534
+ for (const suffix of ["-wal", "-shm"]) {
1535
+ try {
1536
+ chmodSync2(config.dbPath + suffix, 384);
1537
+ } catch {
1538
+ }
1539
+ }
1540
+ } catch {
1541
+ }
1531
1542
  }
1532
1543
  function isInitialized() {
1533
1544
  return _adapterClient !== null || _client !== null;
@@ -1487,6 +1487,7 @@ __export(database_exports, {
1487
1487
  isInitialized: () => isInitialized,
1488
1488
  setExternalClient: () => setExternalClient
1489
1489
  });
1490
+ import { chmodSync as chmodSync2 } from "fs";
1490
1491
  import { createClient } from "@libsql/client";
1491
1492
  async function initDatabase(config) {
1492
1493
  if (_walCheckpointTimer) {
@@ -1528,6 +1529,16 @@ async function initDatabase(config) {
1528
1529
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1529
1530
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1530
1531
  }
1532
+ try {
1533
+ chmodSync2(config.dbPath, 384);
1534
+ for (const suffix of ["-wal", "-shm"]) {
1535
+ try {
1536
+ chmodSync2(config.dbPath + suffix, 384);
1537
+ } catch {
1538
+ }
1539
+ }
1540
+ } catch {
1541
+ }
1531
1542
  }
1532
1543
  function isInitialized() {
1533
1544
  return _adapterClient !== null || _client !== null;
@@ -1627,6 +1627,7 @@ __export(database_exports, {
1627
1627
  isInitialized: () => isInitialized,
1628
1628
  setExternalClient: () => setExternalClient
1629
1629
  });
1630
+ import { chmodSync as chmodSync2 } from "fs";
1630
1631
  import { createClient } from "@libsql/client";
1631
1632
  async function initDatabase(config) {
1632
1633
  if (_walCheckpointTimer) {
@@ -1668,6 +1669,16 @@ async function initDatabase(config) {
1668
1669
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1669
1670
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1670
1671
  }
1672
+ try {
1673
+ chmodSync2(config.dbPath, 384);
1674
+ for (const suffix of ["-wal", "-shm"]) {
1675
+ try {
1676
+ chmodSync2(config.dbPath + suffix, 384);
1677
+ } catch {
1678
+ }
1679
+ }
1680
+ } catch {
1681
+ }
1671
1682
  }
1672
1683
  function isInitialized() {
1673
1684
  return _adapterClient !== null || _client !== null;
@@ -5109,6 +5120,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
5109
5120
  function isMainModule(importMetaUrl) {
5110
5121
  if (process.argv[1] == null) return false;
5111
5122
  if (process.argv[1].includes("mcp/server")) return false;
5123
+ if (process.argv[1].includes("exe-daemon")) return false;
5112
5124
  try {
5113
5125
  const scriptPath = realpathSync(process.argv[1]);
5114
5126
  const modulePath = realpathSync(fileURLToPath2(importMetaUrl));
@@ -1627,6 +1627,7 @@ __export(database_exports, {
1627
1627
  isInitialized: () => isInitialized,
1628
1628
  setExternalClient: () => setExternalClient
1629
1629
  });
1630
+ import { chmodSync as chmodSync2 } from "fs";
1630
1631
  import { createClient } from "@libsql/client";
1631
1632
  async function initDatabase(config) {
1632
1633
  if (_walCheckpointTimer) {
@@ -1668,6 +1669,16 @@ async function initDatabase(config) {
1668
1669
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1669
1670
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1670
1671
  }
1672
+ try {
1673
+ chmodSync2(config.dbPath, 384);
1674
+ for (const suffix of ["-wal", "-shm"]) {
1675
+ try {
1676
+ chmodSync2(config.dbPath + suffix, 384);
1677
+ } catch {
1678
+ }
1679
+ }
1680
+ } catch {
1681
+ }
1671
1682
  }
1672
1683
  function isInitialized() {
1673
1684
  return _adapterClient !== null || _client !== null;
@@ -5108,6 +5119,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
5108
5119
  function isMainModule(importMetaUrl) {
5109
5120
  if (process.argv[1] == null) return false;
5110
5121
  if (process.argv[1].includes("mcp/server")) return false;
5122
+ if (process.argv[1].includes("exe-daemon")) return false;
5111
5123
  try {
5112
5124
  const scriptPath = realpathSync(process.argv[1]);
5113
5125
  const modulePath = realpathSync(fileURLToPath2(importMetaUrl));
@@ -1623,6 +1623,7 @@ __export(database_exports, {
1623
1623
  isInitialized: () => isInitialized,
1624
1624
  setExternalClient: () => setExternalClient
1625
1625
  });
1626
+ import { chmodSync as chmodSync2 } from "fs";
1626
1627
  import { createClient } from "@libsql/client";
1627
1628
  async function initDatabase(config) {
1628
1629
  if (_walCheckpointTimer) {
@@ -1664,6 +1665,16 @@ async function initDatabase(config) {
1664
1665
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1665
1666
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1666
1667
  }
1668
+ try {
1669
+ chmodSync2(config.dbPath, 384);
1670
+ for (const suffix of ["-wal", "-shm"]) {
1671
+ try {
1672
+ chmodSync2(config.dbPath + suffix, 384);
1673
+ } catch {
1674
+ }
1675
+ }
1676
+ } catch {
1677
+ }
1667
1678
  }
1668
1679
  function isInitialized() {
1669
1680
  return _adapterClient !== null || _client !== null;
@@ -4187,6 +4198,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
4187
4198
  function isMainModule(importMetaUrl) {
4188
4199
  if (process.argv[1] == null) return false;
4189
4200
  if (process.argv[1].includes("mcp/server")) return false;
4201
+ if (process.argv[1].includes("exe-daemon")) return false;
4190
4202
  try {
4191
4203
  const scriptPath = realpathSync(process.argv[1]);
4192
4204
  const modulePath = realpathSync(fileURLToPath2(importMetaUrl));
@@ -1487,6 +1487,7 @@ __export(database_exports, {
1487
1487
  isInitialized: () => isInitialized,
1488
1488
  setExternalClient: () => setExternalClient
1489
1489
  });
1490
+ import { chmodSync as chmodSync2 } from "fs";
1490
1491
  import { createClient } from "@libsql/client";
1491
1492
  async function initDatabase(config) {
1492
1493
  if (_walCheckpointTimer) {
@@ -1528,6 +1529,16 @@ async function initDatabase(config) {
1528
1529
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1529
1530
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1530
1531
  }
1532
+ try {
1533
+ chmodSync2(config.dbPath, 384);
1534
+ for (const suffix of ["-wal", "-shm"]) {
1535
+ try {
1536
+ chmodSync2(config.dbPath + suffix, 384);
1537
+ } catch {
1538
+ }
1539
+ }
1540
+ } catch {
1541
+ }
1531
1542
  }
1532
1543
  function isInitialized() {
1533
1544
  return _adapterClient !== null || _client !== null;
@@ -4337,6 +4348,21 @@ var init_crdt_sync = __esm({
4337
4348
  }
4338
4349
  });
4339
4350
 
4351
+ // src/lib/pg-ssl.ts
4352
+ var pg_ssl_exports = {};
4353
+ __export(pg_ssl_exports, {
4354
+ pgSslConfig: () => pgSslConfig
4355
+ });
4356
+ function pgSslConfig() {
4357
+ if (process.env.EXE_DB_SSL_DISABLED === "true") return {};
4358
+ return { ssl: { rejectUnauthorized: process.env.EXE_DB_SSL_ALLOW_SELFSIGNED !== "true" } };
4359
+ }
4360
+ var init_pg_ssl = __esm({
4361
+ "src/lib/pg-ssl.ts"() {
4362
+ "use strict";
4363
+ }
4364
+ });
4365
+
4340
4366
  // src/lib/store.ts
4341
4367
  init_memory();
4342
4368
  init_database();
@@ -4829,7 +4855,8 @@ function loadPgClient() {
4829
4855
  return new Ctor();
4830
4856
  }
4831
4857
  const { Pool } = await import("pg");
4832
- const pool = new Pool({ connectionString: process.env.DATABASE_URL });
4858
+ const { pgSslConfig: pgSslConfig2 } = await Promise.resolve().then(() => (init_pg_ssl(), pg_ssl_exports));
4859
+ const pool = new Pool({ connectionString: process.env.DATABASE_URL, ...pgSslConfig2() });
4833
4860
  return {
4834
4861
  async $queryRawUnsafe(query, ...values) {
4835
4862
  const result = await pool.query(query, values);
@@ -4879,6 +4906,7 @@ async function pushToPostgres(records) {
4879
4906
  return inserted;
4880
4907
  }
4881
4908
  var ROSTER_DELETIONS_PATH = path10.join(EXE_AI_DIR, "roster-deletions.json");
4909
+ var CODE_CONTEXT_DIR = path10.join(EXE_AI_DIR, "code-context");
4882
4910
 
4883
4911
  // src/bin/bulk-sync-postgres.ts
4884
4912
  var BATCH_SIZE = 500;
@@ -12,6 +12,7 @@ import { fileURLToPath } from "url";
12
12
  function isMainModule(importMetaUrl) {
13
13
  if (process.argv[1] == null) return false;
14
14
  if (process.argv[1].includes("mcp/server")) return false;
15
+ if (process.argv[1].includes("exe-daemon")) return false;
15
16
  try {
16
17
  const scriptPath = realpathSync(process.argv[1]);
17
18
  const modulePath = realpathSync(fileURLToPath(importMetaUrl));
@@ -587,7 +588,7 @@ function runHealthCheck() {
587
588
  const failed = results.filter((r) => !r.pass).length;
588
589
  return { results, passed, failed };
589
590
  }
590
- if (isMainModule(import.meta.url)) {
591
+ if (isMainModule(import.meta.url) && (process.argv[1] ?? "").includes("exe-healthcheck")) {
591
592
  const { results, passed, failed } = runHealthCheck();
592
593
  console.log("\n exe-os Health Check\n");
593
594
  for (const r of results) {
@@ -620,7 +621,7 @@ function runCcDoctor() {
620
621
  const failed = results.filter((r) => !r.pass).length;
621
622
  return { results, passed, failed };
622
623
  }
623
- if (isMainModule(import.meta.url)) {
624
+ if (isMainModule(import.meta.url) && (process.argv[1] ?? "").includes("cc-doctor")) {
624
625
  const { results, passed, failed } = runCcDoctor();
625
626
  console.log("\n CC Install Health Check\n");
626
627
  for (const r of results) {
@@ -1713,6 +1713,7 @@ __export(database_exports, {
1713
1713
  isInitialized: () => isInitialized,
1714
1714
  setExternalClient: () => setExternalClient
1715
1715
  });
1716
+ import { chmodSync as chmodSync2 } from "fs";
1716
1717
  import { createClient } from "@libsql/client";
1717
1718
  async function initDatabase(config) {
1718
1719
  if (_walCheckpointTimer) {
@@ -1754,6 +1755,16 @@ async function initDatabase(config) {
1754
1755
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
1755
1756
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
1756
1757
  }
1758
+ try {
1759
+ chmodSync2(config.dbPath, 384);
1760
+ for (const suffix of ["-wal", "-shm"]) {
1761
+ try {
1762
+ chmodSync2(config.dbPath + suffix, 384);
1763
+ } catch {
1764
+ }
1765
+ }
1766
+ } catch {
1767
+ }
1757
1768
  }
1758
1769
  function isInitialized() {
1759
1770
  return _adapterClient !== null || _client !== null;
@@ -5922,6 +5933,7 @@ import { fileURLToPath as fileURLToPath3 } from "url";
5922
5933
  function isMainModule(importMetaUrl) {
5923
5934
  if (process.argv[1] == null) return false;
5924
5935
  if (process.argv[1].includes("mcp/server")) return false;
5936
+ if (process.argv[1].includes("exe-daemon")) return false;
5925
5937
  try {
5926
5938
  const scriptPath = realpathSync(process.argv[1]);
5927
5939
  const modulePath = realpathSync(fileURLToPath3(importMetaUrl));
package/dist/bin/cli.js CHANGED
@@ -4349,6 +4349,7 @@ __export(database_exports, {
4349
4349
  isInitialized: () => isInitialized,
4350
4350
  setExternalClient: () => setExternalClient
4351
4351
  });
4352
+ import { chmodSync as chmodSync3 } from "fs";
4352
4353
  import { createClient } from "@libsql/client";
4353
4354
  async function initDatabase(config) {
4354
4355
  if (_walCheckpointTimer) {
@@ -4390,6 +4391,16 @@ async function initDatabase(config) {
4390
4391
  if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
4391
4392
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
4392
4393
  }
4394
+ try {
4395
+ chmodSync3(config.dbPath, 384);
4396
+ for (const suffix of ["-wal", "-shm"]) {
4397
+ try {
4398
+ chmodSync3(config.dbPath + suffix, 384);
4399
+ } catch {
4400
+ }
4401
+ }
4402
+ } catch {
4403
+ }
4393
4404
  }
4394
4405
  function isInitialized() {
4395
4406
  return _adapterClient !== null || _client !== null;
@@ -5752,6 +5763,7 @@ import { fileURLToPath as fileURLToPath3 } from "url";
5752
5763
  function isMainModule(importMetaUrl) {
5753
5764
  if (process.argv[1] == null) return false;
5754
5765
  if (process.argv[1].includes("mcp/server")) return false;
5766
+ if (process.argv[1].includes("exe-daemon")) return false;
5755
5767
  try {
5756
5768
  const scriptPath = realpathSync(process.argv[1]);
5757
5769
  const modulePath = realpathSync(fileURLToPath3(importMetaUrl));
@@ -6565,6 +6577,21 @@ var init_crdt_sync = __esm({
6565
6577
  }
6566
6578
  });
6567
6579
 
6580
+ // src/lib/pg-ssl.ts
6581
+ var pg_ssl_exports = {};
6582
+ __export(pg_ssl_exports, {
6583
+ pgSslConfig: () => pgSslConfig
6584
+ });
6585
+ function pgSslConfig() {
6586
+ if (process.env.EXE_DB_SSL_DISABLED === "true") return {};
6587
+ return { ssl: { rejectUnauthorized: process.env.EXE_DB_SSL_ALLOW_SELFSIGNED !== "true" } };
6588
+ }
6589
+ var init_pg_ssl = __esm({
6590
+ "src/lib/pg-ssl.ts"() {
6591
+ "use strict";
6592
+ }
6593
+ });
6594
+
6568
6595
  // src/lib/db-backup.ts
6569
6596
  var db_backup_exports = {};
6570
6597
  __export(db_backup_exports, {
@@ -6678,6 +6705,7 @@ __export(cloud_sync_exports, {
6678
6705
  cloudPull: () => cloudPull,
6679
6706
  cloudPullBehaviors: () => cloudPullBehaviors,
6680
6707
  cloudPullBlob: () => cloudPullBlob,
6708
+ cloudPullCodeContext: () => cloudPullCodeContext,
6681
6709
  cloudPullConversations: () => cloudPullConversations,
6682
6710
  cloudPullDocuments: () => cloudPullDocuments,
6683
6711
  cloudPullGlobalProcedures: () => cloudPullGlobalProcedures,
@@ -6687,6 +6715,7 @@ __export(cloud_sync_exports, {
6687
6715
  cloudPush: () => cloudPush,
6688
6716
  cloudPushBehaviors: () => cloudPushBehaviors,
6689
6717
  cloudPushBlob: () => cloudPushBlob,
6718
+ cloudPushCodeContext: () => cloudPushCodeContext,
6690
6719
  cloudPushConversations: () => cloudPushConversations,
6691
6720
  cloudPushDocuments: () => cloudPushDocuments,
6692
6721
  cloudPushGlobalProcedures: () => cloudPushGlobalProcedures,
@@ -6765,7 +6794,8 @@ function loadPgClient() {
6765
6794
  return new Ctor();
6766
6795
  }
6767
6796
  const { Pool } = await import("pg");
6768
- const pool = new Pool({ connectionString: process.env.DATABASE_URL });
6797
+ const { pgSslConfig: pgSslConfig2 } = await Promise.resolve().then(() => (init_pg_ssl(), pg_ssl_exports));
6798
+ const pool = new Pool({ connectionString: process.env.DATABASE_URL, ...pgSslConfig2() });
6769
6799
  return {
6770
6800
  async $queryRawUnsafe(query, ...values) {
6771
6801
  const result = await pool.query(query, values);
@@ -7310,6 +7340,17 @@ async function cloudSync(config) {
7310
7340
  } catch (err) {
7311
7341
  logError(`[cloud-sync] DB backup upload error: ${err instanceof Error ? err.message : String(err)}`);
7312
7342
  }
7343
+ let codeContextResult = { pushed: 0, pulled: 0 };
7344
+ try {
7345
+ codeContextResult.pushed = await cloudPushCodeContext(config);
7346
+ } catch (err) {
7347
+ logError(`[cloud-sync] Code context push: ${err instanceof Error ? err.message : String(err)}`);
7348
+ }
7349
+ try {
7350
+ codeContextResult.pulled = await cloudPullCodeContext(config);
7351
+ } catch (err) {
7352
+ logError(`[cloud-sync] Code context pull: ${err instanceof Error ? err.message : String(err)}`);
7353
+ }
7313
7354
  return {
7314
7355
  pushed,
7315
7356
  pulled,
@@ -7319,7 +7360,8 @@ async function cloudSync(config) {
7319
7360
  tasks: tasksResult,
7320
7361
  conversations: conversationsResult,
7321
7362
  documents: documentsResult,
7322
- roster: rosterResult
7363
+ roster: rosterResult,
7364
+ codeContext: codeContextResult
7323
7365
  };
7324
7366
  }
7325
7367
  function recordRosterDeletion(name) {
@@ -7957,7 +7999,99 @@ async function cloudPullDocuments(config) {
7957
7999
  }
7958
8000
  return { pulled };
7959
8001
  }
7960
- var LOCALHOST_PATTERNS, FETCH_TIMEOUT_MS, PUSH_BATCH_SIZE, ROSTER_LOCK_PATH, LOCK_STALE_MS, _pgPromise, _pgFailed, CLOUD_REUPLOAD_REQUIRED_MESSAGE, ROSTER_DELETIONS_PATH;
8002
+ async function cloudPushCodeContext(config) {
8003
+ assertSecureEndpoint(config.endpoint);
8004
+ if (!existsSync16(CODE_CONTEXT_DIR)) return 0;
8005
+ const files = readdirSync2(CODE_CONTEXT_DIR).filter(
8006
+ (f) => f.endsWith(".json") && !f.endsWith(".vectors.json") && !f.startsWith(".")
8007
+ );
8008
+ if (files.length === 0) return 0;
8009
+ const metaPath = path16.join(CODE_CONTEXT_DIR, ".sync-meta.json");
8010
+ let syncMeta = {};
8011
+ if (existsSync16(metaPath)) {
8012
+ try {
8013
+ syncMeta = JSON.parse(readFileSync12(metaPath, "utf-8"));
8014
+ } catch {
8015
+ }
8016
+ }
8017
+ let pushed = 0;
8018
+ for (const file of files) {
8019
+ const filePath = path16.join(CODE_CONTEXT_DIR, file);
8020
+ try {
8021
+ const stat2 = statSync4(filePath);
8022
+ const lastPushed = syncMeta[file] ?? 0;
8023
+ if (stat2.mtimeMs <= lastPushed) continue;
8024
+ const content = readFileSync12(filePath, "utf-8");
8025
+ const header = content.substring(0, 300);
8026
+ if (header.includes("/tmp") || header.includes("/var/folders") || header.includes(".worktrees/")) continue;
8027
+ const compressed = compress(Buffer.from(content, "utf8"));
8028
+ const encrypted = encryptSyncBlob(compressed);
8029
+ const resp = await fetchWithRetry(`${config.endpoint}/sync/push-code-context`, {
8030
+ method: "POST",
8031
+ headers: {
8032
+ Authorization: `Bearer ${config.apiKey}`,
8033
+ "Content-Type": "application/json",
8034
+ "X-Device-Id": loadDeviceId()
8035
+ },
8036
+ body: JSON.stringify({ key: file, blob: encrypted })
8037
+ });
8038
+ if (resp.ok) {
8039
+ syncMeta[file] = stat2.mtimeMs;
8040
+ pushed++;
8041
+ }
8042
+ } catch {
8043
+ }
8044
+ }
8045
+ if (pushed > 0) {
8046
+ try {
8047
+ writeFileSync10(metaPath, JSON.stringify(syncMeta));
8048
+ } catch {
8049
+ }
8050
+ }
8051
+ return pushed;
8052
+ }
8053
+ async function cloudPullCodeContext(config) {
8054
+ assertSecureEndpoint(config.endpoint);
8055
+ try {
8056
+ const resp = await fetchWithRetry(`${config.endpoint}/sync/pull-code-context`, {
8057
+ method: "GET",
8058
+ headers: {
8059
+ Authorization: `Bearer ${config.apiKey}`,
8060
+ "X-Device-Id": loadDeviceId()
8061
+ }
8062
+ });
8063
+ if (!resp.ok) return 0;
8064
+ const data = await resp.json();
8065
+ if (!data.indexes || data.indexes.length === 0) return 0;
8066
+ mkdirSync9(CODE_CONTEXT_DIR, { recursive: true });
8067
+ let pulled = 0;
8068
+ for (const { key, blob } of data.indexes) {
8069
+ try {
8070
+ if (key.endsWith(".vectors.json")) continue;
8071
+ const localPath = path16.join(CODE_CONTEXT_DIR, key);
8072
+ const compressed = decryptSyncBlob(blob);
8073
+ const content = decompress(compressed).toString("utf8");
8074
+ if (!existsSync16(localPath)) {
8075
+ writeFileSync10(localPath, content, "utf-8");
8076
+ pulled++;
8077
+ } else {
8078
+ const localContent = readFileSync12(localPath, "utf-8");
8079
+ if (localContent.length !== content.length) {
8080
+ writeFileSync10(localPath, content, "utf-8");
8081
+ pulled++;
8082
+ }
8083
+ }
8084
+ } catch {
8085
+ }
8086
+ }
8087
+ return pulled;
8088
+ } catch (err) {
8089
+ process.stderr.write(`[cloud-sync] Code context pull failed: ${err instanceof Error ? err.message : String(err)}
8090
+ `);
8091
+ return 0;
8092
+ }
8093
+ }
8094
+ var LOCALHOST_PATTERNS, FETCH_TIMEOUT_MS, PUSH_BATCH_SIZE, ROSTER_LOCK_PATH, LOCK_STALE_MS, _pgPromise, _pgFailed, CLOUD_REUPLOAD_REQUIRED_MESSAGE, ROSTER_DELETIONS_PATH, CODE_CONTEXT_DIR;
7961
8095
  var init_cloud_sync = __esm({
7962
8096
  "src/lib/cloud-sync.ts"() {
7963
8097
  "use strict";
@@ -7978,6 +8112,7 @@ var init_cloud_sync = __esm({
7978
8112
  _pgFailed = false;
7979
8113
  CLOUD_REUPLOAD_REQUIRED_MESSAGE = "Cloud sync is blocked because this device rotated its memory encryption key. Run `exe-os cloud reupload` first to re-upload the cloud backup with the new key.";
7980
8114
  ROSTER_DELETIONS_PATH = path16.join(EXE_AI_DIR, "roster-deletions.json");
8115
+ CODE_CONTEXT_DIR = path16.join(EXE_AI_DIR, "code-context");
7981
8116
  }
7982
8117
  });
7983
8118
 
@@ -13327,7 +13462,7 @@ function readQueue() {
13327
13462
  function writeQueue(queue) {
13328
13463
  ensureDir2();
13329
13464
  const tmp = `${QUEUE_PATH}.tmp`;
13330
- writeFileSync18(tmp, JSON.stringify(queue, null, 2));
13465
+ writeFileSync18(tmp, JSON.stringify(queue, null, 2), { mode: 384 });
13331
13466
  renameSync5(tmp, QUEUE_PATH);
13332
13467
  }
13333
13468
  function queueIntercom(targetSession, reason) {
@@ -18498,7 +18633,7 @@ import {
18498
18633
  readFileSync as readFileSync26,
18499
18634
  writeFileSync as writeFileSync23,
18500
18635
  mkdirSync as mkdirSync22,
18501
- chmodSync as chmodSync3,
18636
+ chmodSync as chmodSync4,
18502
18637
  readdirSync as readdirSync9,
18503
18638
  unlinkSync as unlinkSync15
18504
18639
  } from "fs";
@@ -18519,7 +18654,7 @@ function generateSessionWrappers(packageRoot, homeDir) {
18519
18654
  for (const src of candidates) {
18520
18655
  if (existsSync31(src)) {
18521
18656
  writeFileSync23(exeStartDst, readFileSync26(src));
18522
- chmodSync3(exeStartDst, 493);
18657
+ chmodSync4(exeStartDst, 493);
18523
18658
  break;
18524
18659
  }
18525
18660
  }
@@ -18583,7 +18718,7 @@ exec "${exeStartDst}" "$0" "$@"
18583
18718
  exec node "${codexLauncher}" --agent ${emp.name} "$@"
18584
18719
  `;
18585
18720
  writeFileSync23(wrapperPath, content);
18586
- chmodSync3(wrapperPath, 493);
18721
+ chmodSync4(wrapperPath, 493);
18587
18722
  created++;
18588
18723
  }
18589
18724
  }
@@ -18593,7 +18728,7 @@ exec node "${codexLauncher}" --agent ${emp.name} "$@"
18593
18728
  function writeWrapper(wrapperPath, content) {
18594
18729
  try {
18595
18730
  writeFileSync23(wrapperPath, content);
18596
- chmodSync3(wrapperPath, 493);
18731
+ chmodSync4(wrapperPath, 493);
18597
18732
  } catch {
18598
18733
  }
18599
18734
  }
@@ -19687,6 +19822,10 @@ async function runUpdate(cliArgs) {
19687
19822
  \u{1F4E6} Update available: v${result.localVersion} \u2192 v${result.remoteVersion}
19688
19823
  `);
19689
19824
  let proceed = autoMode;
19825
+ if (!proceed && !process.stdin.isTTY) {
19826
+ console.log("Non-interactive mode detected (no TTY). Use --yes to auto-confirm, or run interactively.");
19827
+ process.exit(1);
19828
+ }
19690
19829
  if (!proceed) {
19691
19830
  const rl = createInterface5({ input: process.stdin, output: process.stdout });
19692
19831
  const answer = await new Promise((resolve) => {
@@ -20138,8 +20277,9 @@ function hydrateEnv(raw, opts) {
20138
20277
  else if (key === "MONITOR_AGENT_KEY") continue;
20139
20278
  else if (key === "EXE_GATEWAY_WS_RELAY_AUTH_TOKEN") replacements[key] = randomHexSecret(24);
20140
20279
  else if (key.endsWith("_PASSWORD")) replacements[key] = randomSecret(24);
20141
- else if (key.endsWith("_SECRET") || key.endsWith("_TOKEN") || key.endsWith("_KEY") || key.endsWith("_SALT")) replacements[key] = value.replace(/CHANGEME[A-Z0-9_]*/g, randomSecret(32));
20142
- else if (key === "EXED_MCP_TOKEN") replacements[key] = randomSecret(32);
20280
+ else if (key.endsWith("_TOKEN")) replacements[key] = randomHexSecret(32);
20281
+ else if (key.endsWith("_SECRET") || key.endsWith("_SALT")) replacements[key] = randomSecret(32);
20282
+ else if (key.endsWith("_KEY") && key !== "EXE_LICENSE_KEY") continue;
20143
20283
  }
20144
20284
  if (domain) next = next.replaceAll("CHANGEME_DOMAIN", domain);
20145
20285
  next = patchEnv(next, replacements);
@@ -20536,8 +20676,8 @@ Options:
20536
20676
  }
20537
20677
  function printChanges(changes, composeFile, envFile) {
20538
20678
  if (changes.length === 0) {
20539
- const running = areCliContainersRunning(composeFile, envFile);
20540
- if (running) {
20679
+ const running2 = areCliContainersRunning(composeFile, envFile);
20680
+ if (running2) {
20541
20681
  console.log("Stack .env matches target manifest. Checking container health...\n");
20542
20682
  const unhealthy = printContainerHealth(composeFile, envFile);
20543
20683
  if (unhealthy > 0) {
@@ -20546,16 +20686,28 @@ function printChanges(changes, composeFile, envFile) {
20546
20686
  } else {
20547
20687
  console.log("\n\u2705 Stack already matches target manifest. All services healthy.");
20548
20688
  }
20689
+ return unhealthy;
20549
20690
  } else {
20550
20691
  console.log("\u26A0\uFE0F Stack .env matches target manifest but containers are not running. Will start them.");
20692
+ return 1;
20551
20693
  }
20552
- return;
20553
20694
  }
20554
20695
  console.log("Planned image tag changes:");
20555
20696
  for (const c of changes) {
20556
20697
  console.log(` - ${c.service}: ${c.key}`);
20557
20698
  console.log(` ${c.before ?? "<unset>"} \u2192 ${c.after}`);
20558
20699
  }
20700
+ const running = areCliContainersRunning(composeFile, envFile);
20701
+ if (running) {
20702
+ console.log("\nCurrent container health:");
20703
+ const unhealthy = printContainerHealth(composeFile, envFile);
20704
+ if (unhealthy > 0) {
20705
+ console.log(`
20706
+ \u{1F534} ${unhealthy} service(s) currently unhealthy or crashlooping.`);
20707
+ }
20708
+ return unhealthy;
20709
+ }
20710
+ return 0;
20559
20711
  }
20560
20712
  function areCliContainersRunning(composeFile, envFile) {
20561
20713
  try {
@@ -20665,9 +20817,12 @@ async function main7(args2 = process.argv.slice(2)) {
20665
20817
  console.log(`Compose: ${opts.composeFile}`);
20666
20818
  console.log(`Env: ${opts.envFile}
20667
20819
  `);
20668
- printChanges(plan.changes, opts.composeFile, opts.envFile);
20820
+ const unhealthyCount = printChanges(plan.changes, opts.composeFile, opts.envFile);
20669
20821
  printBreaking(plan.breakingChanges);
20670
- if (opts.check || opts.dryRun) return;
20822
+ if (opts.check || opts.dryRun) {
20823
+ if (unhealthyCount > 0) process.exitCode = 1;
20824
+ return;
20825
+ }
20671
20826
  if (!opts.yes) {
20672
20827
  console.error("\nRefusing to update without --yes. Re-run with --yes after reviewing the plan.");
20673
20828
  process.exit(2);