@askexenow/exe-os 0.9.84 → 0.9.86

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 (82) hide show
  1. package/dist/bin/agentic-ontology-backfill.js +32 -14
  2. package/dist/bin/agentic-reflection-backfill.js +32 -14
  3. package/dist/bin/agentic-semantic-label.js +32 -14
  4. package/dist/bin/backfill-conversations.js +32 -14
  5. package/dist/bin/backfill-responses.js +32 -14
  6. package/dist/bin/backfill-vectors.js +32 -14
  7. package/dist/bin/bulk-sync-postgres.js +32 -14
  8. package/dist/bin/cleanup-stale-review-tasks.js +35 -17
  9. package/dist/bin/cli.js +224 -86
  10. package/dist/bin/exe-assign.js +32 -14
  11. package/dist/bin/exe-boot.js +57 -39
  12. package/dist/bin/exe-cloud.js +22 -4
  13. package/dist/bin/exe-dispatch.js +43 -25
  14. package/dist/bin/exe-doctor.js +22 -4
  15. package/dist/bin/exe-export-behaviors.js +32 -14
  16. package/dist/bin/exe-forget.js +32 -14
  17. package/dist/bin/exe-gateway.js +47 -29
  18. package/dist/bin/exe-heartbeat.js +37 -19
  19. package/dist/bin/exe-kill.js +36 -18
  20. package/dist/bin/exe-launch-agent.js +170 -79
  21. package/dist/bin/exe-new-employee.js +32 -0
  22. package/dist/bin/exe-pending-messages.js +35 -17
  23. package/dist/bin/exe-pending-notifications.js +35 -17
  24. package/dist/bin/exe-pending-reviews.js +37 -19
  25. package/dist/bin/exe-rename.js +34 -16
  26. package/dist/bin/exe-review.js +32 -14
  27. package/dist/bin/exe-search.js +40 -22
  28. package/dist/bin/exe-session-cleanup.js +67 -44
  29. package/dist/bin/exe-start-codex.js +39 -21
  30. package/dist/bin/exe-start-opencode.js +37 -19
  31. package/dist/bin/exe-status.js +44 -26
  32. package/dist/bin/exe-team.js +32 -14
  33. package/dist/bin/git-sweep.js +45 -27
  34. package/dist/bin/graph-backfill.js +32 -14
  35. package/dist/bin/graph-export.js +32 -14
  36. package/dist/bin/install.js +32 -0
  37. package/dist/bin/intercom-check.js +49 -31
  38. package/dist/bin/scan-tasks.js +45 -27
  39. package/dist/bin/setup.js +29 -11
  40. package/dist/bin/shard-migrate.js +32 -14
  41. package/dist/bin/stack-update.js +95 -7
  42. package/dist/bin/update.js +1 -1
  43. package/dist/gateway/index.js +47 -29
  44. package/dist/hooks/bug-report-worker.js +47 -29
  45. package/dist/hooks/codex-stop-task-finalizer.js +41 -23
  46. package/dist/hooks/commit-complete.js +46 -28
  47. package/dist/hooks/error-recall.js +44 -26
  48. package/dist/hooks/ingest-worker.js +4 -4
  49. package/dist/hooks/ingest.js +38 -20
  50. package/dist/hooks/instructions-loaded.js +32 -14
  51. package/dist/hooks/notification.js +32 -14
  52. package/dist/hooks/post-compact.js +32 -14
  53. package/dist/hooks/post-tool-combined.js +45 -27
  54. package/dist/hooks/pre-compact.js +43 -25
  55. package/dist/hooks/pre-tool-use.js +40 -22
  56. package/dist/hooks/prompt-submit.js +60 -42
  57. package/dist/hooks/session-end.js +48 -30
  58. package/dist/hooks/session-start.js +50 -32
  59. package/dist/hooks/stop.js +35 -17
  60. package/dist/hooks/subagent-stop.js +32 -14
  61. package/dist/hooks/summary-worker.js +37 -19
  62. package/dist/index.js +43 -25
  63. package/dist/lib/cloud-sync.js +32 -14
  64. package/dist/lib/database.js +22 -4
  65. package/dist/lib/db-daemon-client.js +16 -4
  66. package/dist/lib/db.js +22 -4
  67. package/dist/lib/device-registry.js +22 -4
  68. package/dist/lib/embedder.js +16 -4
  69. package/dist/lib/exe-daemon-client.js +16 -4
  70. package/dist/lib/exe-daemon.js +165 -66
  71. package/dist/lib/hybrid-search.js +40 -22
  72. package/dist/lib/schedules.js +35 -17
  73. package/dist/lib/skill-learning.js +16 -4
  74. package/dist/lib/store.js +32 -14
  75. package/dist/lib/tasks.js +16 -4
  76. package/dist/lib/tmux-routing.js +18 -6
  77. package/dist/mcp/server.js +142 -60
  78. package/dist/mcp/tools/create-task.js +18 -6
  79. package/dist/mcp/tools/update-task.js +18 -6
  80. package/dist/runtime/index.js +43 -25
  81. package/dist/tui/App.js +73 -55
  82. package/package.json +1 -1
@@ -1068,7 +1068,7 @@ var init_daemon_auth = __esm({
1068
1068
  // src/lib/exe-daemon-client.ts
1069
1069
  import net from "net";
1070
1070
  import os4 from "os";
1071
- import { spawn } from "child_process";
1071
+ import { spawn, execSync as execSync2 } from "child_process";
1072
1072
  import { randomUUID } from "crypto";
1073
1073
  import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync4, openSync, closeSync, statSync } from "fs";
1074
1074
  import path5 from "path";
@@ -1098,6 +1098,14 @@ function handleData(chunk) {
1098
1098
  }
1099
1099
  }
1100
1100
  }
1101
+ function isZombie(pid) {
1102
+ try {
1103
+ const state = execSync2(`ps -p ${pid} -o state=`, { encoding: "utf8", timeout: 2e3 }).trim();
1104
+ return state.startsWith("Z");
1105
+ } catch {
1106
+ return false;
1107
+ }
1108
+ }
1101
1109
  function cleanupStaleFiles() {
1102
1110
  if (existsSync5(PID_PATH)) {
1103
1111
  try {
@@ -1105,7 +1113,11 @@ function cleanupStaleFiles() {
1105
1113
  if (pid > 0) {
1106
1114
  try {
1107
1115
  process.kill(pid, 0);
1108
- return;
1116
+ if (!isZombie(pid)) {
1117
+ return;
1118
+ }
1119
+ process.stderr.write(`[exed-client] PID ${pid} is a zombie \u2014 cleaning up stale files
1120
+ `);
1109
1121
  } catch {
1110
1122
  }
1111
1123
  }
@@ -1133,8 +1145,8 @@ function findPackageRoot() {
1133
1145
  function getAvailableMemoryGB() {
1134
1146
  if (process.platform === "darwin") {
1135
1147
  try {
1136
- const { execSync: execSync6 } = __require("child_process");
1137
- const vmstat = execSync6("vm_stat", { encoding: "utf8" });
1148
+ const { execSync: execSync7 } = __require("child_process");
1149
+ const vmstat = execSync7("vm_stat", { encoding: "utf8" });
1138
1150
  const pageSize = 16384;
1139
1151
  const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
1140
1152
  const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
@@ -2920,6 +2932,12 @@ async function disposeDatabase() {
2920
2932
  clearInterval(_walCheckpointTimer);
2921
2933
  _walCheckpointTimer = null;
2922
2934
  }
2935
+ if (_client) {
2936
+ try {
2937
+ await _client.execute("PRAGMA wal_checkpoint(PASSIVE)");
2938
+ } catch {
2939
+ }
2940
+ }
2923
2941
  if (_daemonClient) {
2924
2942
  _daemonClient.close();
2925
2943
  _daemonClient = null;
@@ -4094,7 +4112,7 @@ var init_runtime_table = __esm({
4094
4112
  });
4095
4113
 
4096
4114
  // src/lib/session-key.ts
4097
- import { execSync as execSync3 } from "child_process";
4115
+ import { execSync as execSync4 } from "child_process";
4098
4116
  function normalizeCommand(command) {
4099
4117
  const trimmed = command.trim().toLowerCase();
4100
4118
  const parts = trimmed.split(/[\\/]/);
@@ -4113,7 +4131,7 @@ function resolveRuntimeProcess() {
4113
4131
  let pid = process.ppid;
4114
4132
  for (let i = 0; i < 10; i++) {
4115
4133
  try {
4116
- const info = execSync3(`ps -p ${pid} -o ppid=,comm=`, {
4134
+ const info = execSync4(`ps -p ${pid} -o ppid=,comm=`, {
4117
4135
  encoding: "utf8",
4118
4136
  timeout: 2e3
4119
4137
  }).trim();
@@ -4185,7 +4203,7 @@ __export(active_agent_exports, {
4185
4203
  writeActiveAgent: () => writeActiveAgent
4186
4204
  });
4187
4205
  import { readFileSync as readFileSync5, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4, unlinkSync as unlinkSync4, readdirSync as readdirSync3 } from "fs";
4188
- import { execSync as execSync4 } from "child_process";
4206
+ import { execSync as execSync5 } from "child_process";
4189
4207
  import path9 from "path";
4190
4208
  function isNameWithOptionalInstance(candidate, baseName) {
4191
4209
  if (candidate === baseName) return true;
@@ -4279,7 +4297,7 @@ function getActiveAgent() {
4279
4297
  } catch {
4280
4298
  }
4281
4299
  try {
4282
- const sessionName = execSync4(
4300
+ const sessionName = execSync5(
4283
4301
  "tmux display-message -p '#{session_name}' 2>/dev/null",
4284
4302
  { encoding: "utf8", timeout: 2e3 }
4285
4303
  ).trim();
@@ -4591,7 +4609,7 @@ import { existsSync as existsSync12, readFileSync as readFileSync8, writeFileSyn
4591
4609
  import { createHash as createHash4 } from "crypto";
4592
4610
  import path13 from "path";
4593
4611
  import os10 from "os";
4594
- import { execSync as execSync5 } from "child_process";
4612
+ import { execSync as execSync6 } from "child_process";
4595
4613
  import { fileURLToPath as fileURLToPath2 } from "url";
4596
4614
  function resolvePackageRoot() {
4597
4615
  const thisFile = fileURLToPath2(import.meta.url);
@@ -4943,7 +4961,7 @@ init_database();
4943
4961
  // src/lib/keychain.ts
4944
4962
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
4945
4963
  import { existsSync as existsSync6, statSync as statSync2 } from "fs";
4946
- import { execSync as execSync2 } from "child_process";
4964
+ import { execSync as execSync3 } from "child_process";
4947
4965
  import path6 from "path";
4948
4966
  import os5 from "os";
4949
4967
  var SERVICE = "exe-os";
@@ -4964,13 +4982,13 @@ function linuxSecretAvailable() {
4964
4982
  if (process.platform !== "linux") return false;
4965
4983
  if (linuxSecretAvailability !== null) return linuxSecretAvailability;
4966
4984
  try {
4967
- execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
4985
+ execSync3("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
4968
4986
  } catch {
4969
4987
  linuxSecretAvailability = false;
4970
4988
  return false;
4971
4989
  }
4972
4990
  try {
4973
- execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
4991
+ execSync3("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
4974
4992
  linuxSecretAvailability = true;
4975
4993
  } catch {
4976
4994
  linuxSecretAvailability = false;
@@ -4994,7 +5012,7 @@ function macKeychainGet(service = SERVICE) {
4994
5012
  if (!nativeKeychainAllowed()) return null;
4995
5013
  if (process.platform !== "darwin") return null;
4996
5014
  try {
4997
- return execSync2(
5015
+ return execSync3(
4998
5016
  `security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
4999
5017
  { encoding: "utf-8", timeout: 5e3 }
5000
5018
  ).trim();
@@ -5007,13 +5025,13 @@ function macKeychainSet(value, service = SERVICE) {
5007
5025
  if (process.platform !== "darwin") return false;
5008
5026
  try {
5009
5027
  try {
5010
- execSync2(
5028
+ execSync3(
5011
5029
  `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
5012
5030
  { timeout: 5e3 }
5013
5031
  );
5014
5032
  } catch {
5015
5033
  }
5016
- execSync2(
5034
+ execSync3(
5017
5035
  `security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
5018
5036
  { timeout: 5e3 }
5019
5037
  );
@@ -5026,7 +5044,7 @@ function macKeychainDelete(service = SERVICE) {
5026
5044
  if (!nativeKeychainAllowed()) return false;
5027
5045
  if (process.platform !== "darwin") return false;
5028
5046
  try {
5029
- execSync2(
5047
+ execSync3(
5030
5048
  `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
5031
5049
  { timeout: 5e3 }
5032
5050
  );
@@ -5038,7 +5056,7 @@ function macKeychainDelete(service = SERVICE) {
5038
5056
  function linuxSecretGet(service = SERVICE) {
5039
5057
  if (!linuxSecretAvailable()) return null;
5040
5058
  try {
5041
- return execSync2(
5059
+ return execSync3(
5042
5060
  `secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
5043
5061
  { encoding: "utf-8", timeout: 5e3 }
5044
5062
  ).trim();
@@ -5049,7 +5067,7 @@ function linuxSecretGet(service = SERVICE) {
5049
5067
  function linuxSecretSet(value, service = SERVICE) {
5050
5068
  if (!linuxSecretAvailable()) return false;
5051
5069
  try {
5052
- execSync2(
5070
+ execSync3(
5053
5071
  `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
5054
5072
  { timeout: 5e3 }
5055
5073
  );
@@ -5062,7 +5080,7 @@ function linuxSecretDelete(service = SERVICE) {
5062
5080
  if (!nativeKeychainAllowed()) return false;
5063
5081
  if (process.platform !== "linux") return false;
5064
5082
  try {
5065
- execSync2(
5083
+ execSync3(
5066
5084
  `secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
5067
5085
  { timeout: 5e3 }
5068
5086
  );
@@ -1014,7 +1014,7 @@ __export(exe_daemon_client_exports, {
1014
1014
  });
1015
1015
  import net from "net";
1016
1016
  import os4 from "os";
1017
- import { spawn } from "child_process";
1017
+ import { spawn, execSync as execSync2 } from "child_process";
1018
1018
  import { randomUUID } from "crypto";
1019
1019
  import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync4, openSync, closeSync, statSync } from "fs";
1020
1020
  import path5 from "path";
@@ -1044,6 +1044,14 @@ function handleData(chunk) {
1044
1044
  }
1045
1045
  }
1046
1046
  }
1047
+ function isZombie(pid) {
1048
+ try {
1049
+ const state = execSync2(`ps -p ${pid} -o state=`, { encoding: "utf8", timeout: 2e3 }).trim();
1050
+ return state.startsWith("Z");
1051
+ } catch {
1052
+ return false;
1053
+ }
1054
+ }
1047
1055
  function cleanupStaleFiles() {
1048
1056
  if (existsSync5(PID_PATH)) {
1049
1057
  try {
@@ -1051,7 +1059,11 @@ function cleanupStaleFiles() {
1051
1059
  if (pid > 0) {
1052
1060
  try {
1053
1061
  process.kill(pid, 0);
1054
- return;
1062
+ if (!isZombie(pid)) {
1063
+ return;
1064
+ }
1065
+ process.stderr.write(`[exed-client] PID ${pid} is a zombie \u2014 cleaning up stale files
1066
+ `);
1055
1067
  } catch {
1056
1068
  }
1057
1069
  }
@@ -1079,8 +1091,8 @@ function findPackageRoot() {
1079
1091
  function getAvailableMemoryGB() {
1080
1092
  if (process.platform === "darwin") {
1081
1093
  try {
1082
- const { execSync: execSync6 } = __require("child_process");
1083
- const vmstat = execSync6("vm_stat", { encoding: "utf8" });
1094
+ const { execSync: execSync7 } = __require("child_process");
1095
+ const vmstat = execSync7("vm_stat", { encoding: "utf8" });
1084
1096
  const pageSize = 16384;
1085
1097
  const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
1086
1098
  const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
@@ -3070,6 +3082,12 @@ async function disposeDatabase() {
3070
3082
  clearInterval(_walCheckpointTimer);
3071
3083
  _walCheckpointTimer = null;
3072
3084
  }
3085
+ if (_client) {
3086
+ try {
3087
+ await _client.execute("PRAGMA wal_checkpoint(PASSIVE)");
3088
+ } catch {
3089
+ }
3090
+ }
3073
3091
  if (_daemonClient) {
3074
3092
  _daemonClient.close();
3075
3093
  _daemonClient = null;
@@ -3106,7 +3124,7 @@ var init_database = __esm({
3106
3124
  // src/lib/keychain.ts
3107
3125
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3108
3126
  import { existsSync as existsSync6, statSync as statSync2 } from "fs";
3109
- import { execSync as execSync2 } from "child_process";
3127
+ import { execSync as execSync3 } from "child_process";
3110
3128
  import path6 from "path";
3111
3129
  import os5 from "os";
3112
3130
  function getKeyDir() {
@@ -3123,13 +3141,13 @@ function linuxSecretAvailable() {
3123
3141
  if (process.platform !== "linux") return false;
3124
3142
  if (linuxSecretAvailability !== null) return linuxSecretAvailability;
3125
3143
  try {
3126
- execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
3144
+ execSync3("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
3127
3145
  } catch {
3128
3146
  linuxSecretAvailability = false;
3129
3147
  return false;
3130
3148
  }
3131
3149
  try {
3132
- execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
3150
+ execSync3("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
3133
3151
  linuxSecretAvailability = true;
3134
3152
  } catch {
3135
3153
  linuxSecretAvailability = false;
@@ -3153,7 +3171,7 @@ function macKeychainGet(service = SERVICE) {
3153
3171
  if (!nativeKeychainAllowed()) return null;
3154
3172
  if (process.platform !== "darwin") return null;
3155
3173
  try {
3156
- return execSync2(
3174
+ return execSync3(
3157
3175
  `security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
3158
3176
  { encoding: "utf-8", timeout: 5e3 }
3159
3177
  ).trim();
@@ -3166,13 +3184,13 @@ function macKeychainSet(value, service = SERVICE) {
3166
3184
  if (process.platform !== "darwin") return false;
3167
3185
  try {
3168
3186
  try {
3169
- execSync2(
3187
+ execSync3(
3170
3188
  `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3171
3189
  { timeout: 5e3 }
3172
3190
  );
3173
3191
  } catch {
3174
3192
  }
3175
- execSync2(
3193
+ execSync3(
3176
3194
  `security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
3177
3195
  { timeout: 5e3 }
3178
3196
  );
@@ -3185,7 +3203,7 @@ function macKeychainDelete(service = SERVICE) {
3185
3203
  if (!nativeKeychainAllowed()) return false;
3186
3204
  if (process.platform !== "darwin") return false;
3187
3205
  try {
3188
- execSync2(
3206
+ execSync3(
3189
3207
  `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3190
3208
  { timeout: 5e3 }
3191
3209
  );
@@ -3197,7 +3215,7 @@ function macKeychainDelete(service = SERVICE) {
3197
3215
  function linuxSecretGet(service = SERVICE) {
3198
3216
  if (!linuxSecretAvailable()) return null;
3199
3217
  try {
3200
- return execSync2(
3218
+ return execSync3(
3201
3219
  `secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3202
3220
  { encoding: "utf-8", timeout: 5e3 }
3203
3221
  ).trim();
@@ -3208,7 +3226,7 @@ function linuxSecretGet(service = SERVICE) {
3208
3226
  function linuxSecretSet(value, service = SERVICE) {
3209
3227
  if (!linuxSecretAvailable()) return false;
3210
3228
  try {
3211
- execSync2(
3229
+ execSync3(
3212
3230
  `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3213
3231
  { timeout: 5e3 }
3214
3232
  );
@@ -3221,7 +3239,7 @@ function linuxSecretDelete(service = SERVICE) {
3221
3239
  if (!nativeKeychainAllowed()) return false;
3222
3240
  if (process.platform !== "linux") return false;
3223
3241
  try {
3224
- execSync2(
3242
+ execSync3(
3225
3243
  `secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3226
3244
  { timeout: 5e3 }
3227
3245
  );
@@ -5409,7 +5427,7 @@ var init_session_registry = __esm({
5409
5427
  });
5410
5428
 
5411
5429
  // src/lib/session-key.ts
5412
- import { execSync as execSync4 } from "child_process";
5430
+ import { execSync as execSync5 } from "child_process";
5413
5431
  function normalizeCommand(command) {
5414
5432
  const trimmed = command.trim().toLowerCase();
5415
5433
  const parts = trimmed.split(/[\\/]/);
@@ -5428,7 +5446,7 @@ function resolveRuntimeProcess() {
5428
5446
  let pid = process.ppid;
5429
5447
  for (let i = 0; i < 10; i++) {
5430
5448
  try {
5431
- const info = execSync4(`ps -p ${pid} -o ppid=,comm=`, {
5449
+ const info = execSync5(`ps -p ${pid} -o ppid=,comm=`, {
5432
5450
  encoding: "utf8",
5433
5451
  timeout: 2e3
5434
5452
  }).trim();
@@ -5594,7 +5612,7 @@ var init_transport = __esm({
5594
5612
  });
5595
5613
 
5596
5614
  // src/lib/cc-agent-support.ts
5597
- import { execSync as execSync5 } from "child_process";
5615
+ import { execSync as execSync6 } from "child_process";
5598
5616
  var init_cc_agent_support = __esm({
5599
5617
  "src/lib/cc-agent-support.ts"() {
5600
5618
  "use strict";
@@ -5894,13 +5912,13 @@ async function fastDbInit() {
5894
5912
  init_database();
5895
5913
 
5896
5914
  // src/lib/tmux-status.ts
5897
- import { execSync as execSync3 } from "child_process";
5915
+ import { execSync as execSync4 } from "child_process";
5898
5916
  function inTmux() {
5899
5917
  if (process.env.TMUX || process.env.TMUX_PANE) return true;
5900
5918
  const term = process.env.TERM ?? "";
5901
5919
  if (term.startsWith("tmux") || term.startsWith("screen")) return true;
5902
5920
  try {
5903
- execSync3("tmux display-message -p '#{session_name}' 2>/dev/null", {
5921
+ execSync4("tmux display-message -p '#{session_name}' 2>/dev/null", {
5904
5922
  encoding: "utf8",
5905
5923
  timeout: 2e3
5906
5924
  });
@@ -5910,12 +5928,12 @@ function inTmux() {
5910
5928
  try {
5911
5929
  let pid = process.ppid;
5912
5930
  for (let depth = 0; depth < 8 && pid > 1; depth++) {
5913
- const comm = execSync3(`ps -p ${pid} -o comm= 2>/dev/null`, {
5931
+ const comm = execSync4(`ps -p ${pid} -o comm= 2>/dev/null`, {
5914
5932
  encoding: "utf8",
5915
5933
  timeout: 1e3
5916
5934
  }).trim();
5917
5935
  if (/tmux/.test(comm)) return true;
5918
- const ppid = execSync3(`ps -p ${pid} -o ppid= 2>/dev/null`, {
5936
+ const ppid = execSync4(`ps -p ${pid} -o ppid= 2>/dev/null`, {
5919
5937
  encoding: "utf8",
5920
5938
  timeout: 1e3
5921
5939
  }).trim();
@@ -5928,7 +5946,7 @@ function inTmux() {
5928
5946
  }
5929
5947
  function listTmuxSessions() {
5930
5948
  try {
5931
- const out = execSync3("tmux list-sessions -F '#{session_name}' 2>/dev/null", {
5949
+ const out = execSync4("tmux list-sessions -F '#{session_name}' 2>/dev/null", {
5932
5950
  encoding: "utf8",
5933
5951
  timeout: 3e3
5934
5952
  });
@@ -5939,7 +5957,7 @@ function listTmuxSessions() {
5939
5957
  }
5940
5958
  function capturePaneLines(windowName, lines = 10) {
5941
5959
  try {
5942
- const out = execSync3(
5960
+ const out = execSync4(
5943
5961
  `tmux capture-pane -t ${JSON.stringify(windowName)} -p 2>/dev/null | tail -${lines}`,
5944
5962
  { encoding: "utf8", timeout: 3e3 }
5945
5963
  );
@@ -5950,7 +5968,7 @@ function capturePaneLines(windowName, lines = 10) {
5950
5968
  }
5951
5969
  function getPaneCwd(windowName) {
5952
5970
  try {
5953
- const out = execSync3(
5971
+ const out = execSync4(
5954
5972
  `tmux display-message -t ${JSON.stringify(windowName)} -p '#{pane_current_path}' 2>/dev/null`,
5955
5973
  { encoding: "utf8", timeout: 3e3 }
5956
5974
  );
@@ -5961,7 +5979,7 @@ function getPaneCwd(windowName) {
5961
5979
  }
5962
5980
  function projectFromPath(dir) {
5963
5981
  try {
5964
- const root = execSync3("git -C " + JSON.stringify(dir) + " rev-parse --show-toplevel 2>/dev/null", {
5982
+ const root = execSync4("git -C " + JSON.stringify(dir) + " rev-parse --show-toplevel 2>/dev/null", {
5965
5983
  encoding: "utf8",
5966
5984
  timeout: 3e3
5967
5985
  }).trim();
@@ -6020,7 +6038,7 @@ function getEmployeeStatuses(employeeNames) {
6020
6038
  }
6021
6039
  let paneAlive = true;
6022
6040
  try {
6023
- const paneStatus = execSync3(
6041
+ const paneStatus = execSync4(
6024
6042
  `tmux list-panes -t ${JSON.stringify(sessionName)} -F '#{pane_dead}' 2>/dev/null`,
6025
6043
  { encoding: "utf8", timeout: 3e3 }
6026
6044
  ).trim();
@@ -1003,7 +1003,7 @@ __export(exe_daemon_client_exports, {
1003
1003
  });
1004
1004
  import net from "net";
1005
1005
  import os4 from "os";
1006
- import { spawn } from "child_process";
1006
+ import { spawn, execSync as execSync2 } from "child_process";
1007
1007
  import { randomUUID } from "crypto";
1008
1008
  import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync4, openSync, closeSync, statSync } from "fs";
1009
1009
  import path5 from "path";
@@ -1033,6 +1033,14 @@ function handleData(chunk) {
1033
1033
  }
1034
1034
  }
1035
1035
  }
1036
+ function isZombie(pid) {
1037
+ try {
1038
+ const state = execSync2(`ps -p ${pid} -o state=`, { encoding: "utf8", timeout: 2e3 }).trim();
1039
+ return state.startsWith("Z");
1040
+ } catch {
1041
+ return false;
1042
+ }
1043
+ }
1036
1044
  function cleanupStaleFiles() {
1037
1045
  if (existsSync5(PID_PATH)) {
1038
1046
  try {
@@ -1040,7 +1048,11 @@ function cleanupStaleFiles() {
1040
1048
  if (pid > 0) {
1041
1049
  try {
1042
1050
  process.kill(pid, 0);
1043
- return;
1051
+ if (!isZombie(pid)) {
1052
+ return;
1053
+ }
1054
+ process.stderr.write(`[exed-client] PID ${pid} is a zombie \u2014 cleaning up stale files
1055
+ `);
1044
1056
  } catch {
1045
1057
  }
1046
1058
  }
@@ -1068,8 +1080,8 @@ function findPackageRoot() {
1068
1080
  function getAvailableMemoryGB() {
1069
1081
  if (process.platform === "darwin") {
1070
1082
  try {
1071
- const { execSync: execSync3 } = __require("child_process");
1072
- const vmstat = execSync3("vm_stat", { encoding: "utf8" });
1083
+ const { execSync: execSync4 } = __require("child_process");
1084
+ const vmstat = execSync4("vm_stat", { encoding: "utf8" });
1073
1085
  const pageSize = 16384;
1074
1086
  const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
1075
1087
  const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
@@ -3059,6 +3071,12 @@ async function disposeDatabase() {
3059
3071
  clearInterval(_walCheckpointTimer);
3060
3072
  _walCheckpointTimer = null;
3061
3073
  }
3074
+ if (_client) {
3075
+ try {
3076
+ await _client.execute("PRAGMA wal_checkpoint(PASSIVE)");
3077
+ } catch {
3078
+ }
3079
+ }
3062
3080
  if (_daemonClient) {
3063
3081
  _daemonClient.close();
3064
3082
  _daemonClient = null;
@@ -3095,7 +3113,7 @@ var init_database = __esm({
3095
3113
  // src/lib/keychain.ts
3096
3114
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3097
3115
  import { existsSync as existsSync6, statSync as statSync2 } from "fs";
3098
- import { execSync as execSync2 } from "child_process";
3116
+ import { execSync as execSync3 } from "child_process";
3099
3117
  import path6 from "path";
3100
3118
  import os5 from "os";
3101
3119
  function getKeyDir() {
@@ -3112,13 +3130,13 @@ function linuxSecretAvailable() {
3112
3130
  if (process.platform !== "linux") return false;
3113
3131
  if (linuxSecretAvailability !== null) return linuxSecretAvailability;
3114
3132
  try {
3115
- execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
3133
+ execSync3("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
3116
3134
  } catch {
3117
3135
  linuxSecretAvailability = false;
3118
3136
  return false;
3119
3137
  }
3120
3138
  try {
3121
- execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
3139
+ execSync3("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
3122
3140
  linuxSecretAvailability = true;
3123
3141
  } catch {
3124
3142
  linuxSecretAvailability = false;
@@ -3142,7 +3160,7 @@ function macKeychainGet(service = SERVICE) {
3142
3160
  if (!nativeKeychainAllowed()) return null;
3143
3161
  if (process.platform !== "darwin") return null;
3144
3162
  try {
3145
- return execSync2(
3163
+ return execSync3(
3146
3164
  `security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
3147
3165
  { encoding: "utf-8", timeout: 5e3 }
3148
3166
  ).trim();
@@ -3155,13 +3173,13 @@ function macKeychainSet(value, service = SERVICE) {
3155
3173
  if (process.platform !== "darwin") return false;
3156
3174
  try {
3157
3175
  try {
3158
- execSync2(
3176
+ execSync3(
3159
3177
  `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3160
3178
  { timeout: 5e3 }
3161
3179
  );
3162
3180
  } catch {
3163
3181
  }
3164
- execSync2(
3182
+ execSync3(
3165
3183
  `security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
3166
3184
  { timeout: 5e3 }
3167
3185
  );
@@ -3174,7 +3192,7 @@ function macKeychainDelete(service = SERVICE) {
3174
3192
  if (!nativeKeychainAllowed()) return false;
3175
3193
  if (process.platform !== "darwin") return false;
3176
3194
  try {
3177
- execSync2(
3195
+ execSync3(
3178
3196
  `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3179
3197
  { timeout: 5e3 }
3180
3198
  );
@@ -3186,7 +3204,7 @@ function macKeychainDelete(service = SERVICE) {
3186
3204
  function linuxSecretGet(service = SERVICE) {
3187
3205
  if (!linuxSecretAvailable()) return null;
3188
3206
  try {
3189
- return execSync2(
3207
+ return execSync3(
3190
3208
  `secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3191
3209
  { encoding: "utf-8", timeout: 5e3 }
3192
3210
  ).trim();
@@ -3197,7 +3215,7 @@ function linuxSecretGet(service = SERVICE) {
3197
3215
  function linuxSecretSet(value, service = SERVICE) {
3198
3216
  if (!linuxSecretAvailable()) return false;
3199
3217
  try {
3200
- execSync2(
3218
+ execSync3(
3201
3219
  `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3202
3220
  { timeout: 5e3 }
3203
3221
  );
@@ -3210,7 +3228,7 @@ function linuxSecretDelete(service = SERVICE) {
3210
3228
  if (!nativeKeychainAllowed()) return false;
3211
3229
  if (process.platform !== "linux") return false;
3212
3230
  try {
3213
- execSync2(
3231
+ execSync3(
3214
3232
  `secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3215
3233
  { timeout: 5e3 }
3216
3234
  );