@askexenow/exe-os 0.9.44 → 0.9.45

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.
@@ -4104,8 +4104,8 @@ function deriveMachineKey() {
4104
4104
  }
4105
4105
  function readMachineId() {
4106
4106
  try {
4107
- const { readFileSync: readFileSync34 } = __require("fs");
4108
- return readFileSync34("/etc/machine-id", "utf-8").trim();
4107
+ const { readFileSync: readFileSync35 } = __require("fs");
4108
+ return readFileSync35("/etc/machine-id", "utf-8").trim();
4109
4109
  } catch {
4110
4110
  return "";
4111
4111
  }
@@ -5607,10 +5607,10 @@ async function disposeEmbedder() {
5607
5607
  async function embedDirect(text3) {
5608
5608
  const llamaCpp = await import("node-llama-cpp");
5609
5609
  const { MODELS_DIR: MODELS_DIR2 } = await Promise.resolve().then(() => (init_config(), config_exports));
5610
- const { existsSync: existsSync40 } = await import("fs");
5610
+ const { existsSync: existsSync41 } = await import("fs");
5611
5611
  const path54 = await import("path");
5612
5612
  const modelPath = path54.join(MODELS_DIR2, "jina-embeddings-v5-small-q4_k_m.gguf");
5613
- if (!existsSync40(modelPath)) {
5613
+ if (!existsSync41(modelPath)) {
5614
5614
  throw new Error(`Embedding model not found at ${modelPath}. Run '/exe-setup' to download it.`);
5615
5615
  }
5616
5616
  const llama = await llamaCpp.getLlama();
@@ -13761,10 +13761,10 @@ function registerCreateTask(server) {
13761
13761
  skipDispatch: true
13762
13762
  });
13763
13763
  try {
13764
- const { existsSync: existsSync40, mkdirSync: mkdirSync20, writeFileSync: writeFileSync25 } = await import("fs");
13764
+ const { existsSync: existsSync41, mkdirSync: mkdirSync20, writeFileSync: writeFileSync25 } = await import("fs");
13765
13765
  const { identityPath: identityPath2 } = await Promise.resolve().then(() => (init_identity(), identity_exports));
13766
13766
  const idPath = identityPath2(assigned_to);
13767
- if (!existsSync40(idPath)) {
13767
+ if (!existsSync41(idPath)) {
13768
13768
  const { loadEmployees: loadEmployees2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
13769
13769
  const employees = await loadEmployees2();
13770
13770
  const emp = employees.find((e) => e.name === assigned_to);
@@ -13773,7 +13773,7 @@ function registerCreateTask(server) {
13773
13773
  const template = getTemplateForTitle2(emp.role);
13774
13774
  if (template) {
13775
13775
  const dir = (await import("path")).dirname(idPath);
13776
- if (!existsSync40(dir)) mkdirSync20(dir, { recursive: true });
13776
+ if (!existsSync41(dir)) mkdirSync20(dir, { recursive: true });
13777
13777
  writeFileSync25(idPath, template.replace(/^agent_id: \w+/m, `agent_id: ${assigned_to}`), "utf-8");
13778
13778
  }
13779
13779
  }
@@ -16261,6 +16261,9 @@ var init_crm_bridge = __esm({
16261
16261
 
16262
16262
  // src/mcp/tools/send-whatsapp.ts
16263
16263
  import { z as z36 } from "zod";
16264
+ import { existsSync as existsSync23, readFileSync as readFileSync19 } from "fs";
16265
+ import { homedir as homedir2 } from "os";
16266
+ import { join as join2 } from "path";
16264
16267
  async function lookupPhoneByName(name) {
16265
16268
  const apiToken = process.env.CRM_API_TOKEN;
16266
16269
  const graphqlUrl = process.env.CRM_GRAPHQL_URL || "http://localhost:3000";
@@ -16305,6 +16308,58 @@ async function lookupPhoneByName(name) {
16305
16308
  return null;
16306
16309
  }
16307
16310
  }
16311
+ function normalizeGatewaySendUrl(value) {
16312
+ const raw = value?.trim();
16313
+ if (!raw) return DEFAULT_GATEWAY_SEND_URL;
16314
+ if (raw.endsWith("/api/send")) return raw;
16315
+ return `${raw.replace(/\/+$/, "")}/api/send`;
16316
+ }
16317
+ function loadGatewayJson() {
16318
+ const configPath = process.env.EXE_GATEWAY_CONFIG?.trim() || process.env.EXE_GATEWAY_CONFIG_PATH?.trim() || join2(homedir2(), ".exe-os", "gateway.json");
16319
+ if (!existsSync23(configPath)) return {};
16320
+ try {
16321
+ return JSON.parse(readFileSync19(configPath, "utf8"));
16322
+ } catch {
16323
+ return {};
16324
+ }
16325
+ }
16326
+ function getGatewaySendConfig() {
16327
+ const config2 = loadGatewayJson();
16328
+ const port = typeof config2.port === "number" ? config2.port : 3100;
16329
+ const configuredUrl = process.env.EXE_GATEWAY_SEND_URL || process.env.EXE_GATEWAY_URL || (process.env.EXE_GATEWAY_HOST ? `http://${process.env.EXE_GATEWAY_HOST}:${process.env.EXE_GATEWAY_PORT ?? port}` : void 0);
16330
+ const url = normalizeGatewaySendUrl(configuredUrl);
16331
+ const configAuthToken = typeof config2.authToken === "string" ? config2.authToken : void 0;
16332
+ const authToken = process.env.EXE_GATEWAY_AUTH_TOKEN || configAuthToken;
16333
+ return { url, authToken };
16334
+ }
16335
+ async function sendWhatsAppViaGateway(to, text3, account) {
16336
+ const gateway = getGatewaySendConfig();
16337
+ const headers = { "Content-Type": "application/json" };
16338
+ if (gateway.authToken) headers.Authorization = `Bearer ${gateway.authToken}`;
16339
+ const res = await fetch(gateway.url, {
16340
+ method: "POST",
16341
+ headers,
16342
+ body: JSON.stringify({
16343
+ platform: "whatsapp",
16344
+ ...account ? { account } : {},
16345
+ to,
16346
+ text: text3
16347
+ }),
16348
+ signal: AbortSignal.timeout(3e4)
16349
+ });
16350
+ const bodyText = await res.text();
16351
+ let body = {};
16352
+ try {
16353
+ body = bodyText ? JSON.parse(bodyText) : {};
16354
+ } catch {
16355
+ body = { error: bodyText };
16356
+ }
16357
+ if (!res.ok || body.sent === false) {
16358
+ const reason = typeof body.error === "string" ? body.error : `HTTP ${res.status}`;
16359
+ throw new Error(`Gateway send failed (${res.status}): ${reason}`);
16360
+ }
16361
+ return { account: typeof body.account === "string" ? body.account : account ?? "default" };
16362
+ }
16308
16363
  async function sendWhatsAppMessage(phoneNumberId, accessToken, to, text3) {
16309
16364
  const url = `${GRAPH_API_BASE}/${phoneNumberId}/messages`;
16310
16365
  const res = await fetch(url, {
@@ -16356,17 +16411,7 @@ function registerSendWhatsapp(server) {
16356
16411
  }
16357
16412
  const { agentId } = getActiveAgent();
16358
16413
  const waAccount = accountName ? getAccountByName(accountName) : getDefaultAccount();
16359
- if (!waAccount) {
16360
- const hint = accountName ? `Account "${accountName}" not found.` : "No WhatsApp accounts configured.";
16361
- return {
16362
- content: [
16363
- {
16364
- type: "text",
16365
- text: `Failed: ${hint} Check ~/.exe-os/whatsapp-accounts.json`
16366
- }
16367
- ]
16368
- };
16369
- }
16414
+ const useMetaBusinessApi = Boolean(waAccount);
16370
16415
  const results = [];
16371
16416
  for (const recipient of recipients) {
16372
16417
  let phone;
@@ -16388,12 +16433,12 @@ function registerSendWhatsapp(server) {
16388
16433
  phone = looked;
16389
16434
  }
16390
16435
  try {
16391
- await sendWhatsAppMessage(
16436
+ const sentAccount = useMetaBusinessApi && waAccount ? (await sendWhatsAppMessage(
16392
16437
  waAccount.phoneNumberId,
16393
16438
  waAccount.accessToken,
16394
16439
  phone,
16395
16440
  message
16396
- );
16441
+ ), waAccount.name) : (await sendWhatsAppViaGateway(phone, message, accountName)).account;
16397
16442
  pushConversationToCRM({
16398
16443
  platform: "whatsapp",
16399
16444
  senderId: phone,
@@ -16402,13 +16447,13 @@ function registerSendWhatsapp(server) {
16402
16447
  agentResponse: message,
16403
16448
  agentName: agentId,
16404
16449
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
16405
- accountId: waAccount.name
16450
+ accountId: sentAccount
16406
16451
  }).catch(() => {
16407
16452
  });
16408
16453
  results.push({ recipient, phone, ok: true });
16409
16454
  } catch (err) {
16410
16455
  const raw = err instanceof Error ? err.message : String(err);
16411
- const friendly = raw.includes("HTTP") ? raw : `Message delivery failed. Check WhatsApp configuration.`;
16456
+ const friendly = raw.includes("HTTP") || raw.includes("Gateway send failed") ? raw : `Message delivery failed. Check WhatsApp configuration.`;
16412
16457
  results.push({
16413
16458
  recipient,
16414
16459
  phone,
@@ -16420,14 +16465,15 @@ function registerSendWhatsapp(server) {
16420
16465
  const sent = results.filter((r) => r.ok).length;
16421
16466
  const failed = results.filter((r) => !r.ok);
16422
16467
  const failedDetail = failed.map((f) => `${f.recipient}: ${f.error}`).join("; ");
16423
- const summary = failed.length === 0 ? `Sent ${sent}/${recipients.length} messages via ${waAccount.name}.` : `Sent ${sent}/${recipients.length} messages via ${waAccount.name}. Failed: ${failedDetail}`;
16468
+ const transport = useMetaBusinessApi && waAccount ? `Meta Business API/${waAccount.name}` : `exe-gateway/${accountName ?? "default"}`;
16469
+ const summary = failed.length === 0 ? `Sent ${sent}/${recipients.length} messages via ${transport}.` : `Sent ${sent}/${recipients.length} messages via ${transport}. Failed: ${failedDetail}`;
16424
16470
  return {
16425
16471
  content: [{ type: "text", text: summary }]
16426
16472
  };
16427
16473
  }
16428
16474
  );
16429
16475
  }
16430
- var GRAPH_API_VERSION, GRAPH_API_BASE;
16476
+ var GRAPH_API_VERSION, GRAPH_API_BASE, DEFAULT_GATEWAY_SEND_URL;
16431
16477
  var init_send_whatsapp = __esm({
16432
16478
  "src/mcp/tools/send-whatsapp.ts"() {
16433
16479
  "use strict";
@@ -16437,6 +16483,7 @@ var init_send_whatsapp = __esm({
16437
16483
  init_plan_limits();
16438
16484
  GRAPH_API_VERSION = "v21.0";
16439
16485
  GRAPH_API_BASE = `https://graph.facebook.com/${GRAPH_API_VERSION}`;
16486
+ DEFAULT_GATEWAY_SEND_URL = "http://127.0.0.1:3100/api/send";
16440
16487
  }
16441
16488
  });
16442
16489
 
@@ -16774,14 +16821,14 @@ var init_gateway = __esm({
16774
16821
  });
16775
16822
 
16776
16823
  // src/automation/trigger-engine.ts
16777
- import { readFileSync as readFileSync19, writeFileSync as writeFileSync14, existsSync as existsSync23, mkdirSync as mkdirSync10 } from "fs";
16824
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync14, existsSync as existsSync24, mkdirSync as mkdirSync10 } from "fs";
16778
16825
  import { randomUUID as randomUUID5 } from "crypto";
16779
16826
  import path29 from "path";
16780
16827
  import os13 from "os";
16781
16828
  function loadTriggers(project) {
16782
- if (!existsSync23(TRIGGERS_PATH)) return [];
16829
+ if (!existsSync24(TRIGGERS_PATH)) return [];
16783
16830
  try {
16784
- const raw = readFileSync19(TRIGGERS_PATH, "utf-8");
16831
+ const raw = readFileSync20(TRIGGERS_PATH, "utf-8");
16785
16832
  const all = JSON.parse(raw);
16786
16833
  if (!Array.isArray(all)) return [];
16787
16834
  if (project) {
@@ -16794,7 +16841,7 @@ function loadTriggers(project) {
16794
16841
  }
16795
16842
  function saveTriggers(triggers) {
16796
16843
  const dir = path29.dirname(TRIGGERS_PATH);
16797
- if (!existsSync23(dir)) mkdirSync10(dir, { recursive: true });
16844
+ if (!existsSync24(dir)) mkdirSync10(dir, { recursive: true });
16798
16845
  writeFileSync14(TRIGGERS_PATH, JSON.stringify(triggers, null, 2), "utf-8");
16799
16846
  }
16800
16847
  function createNewTrigger(input) {
@@ -17124,14 +17171,14 @@ var init_list_triggers = __esm({
17124
17171
  });
17125
17172
 
17126
17173
  // src/automation/starter-packs/index.ts
17127
- import { readFileSync as readFileSync20, readdirSync as readdirSync8, existsSync as existsSync24 } from "fs";
17174
+ import { readFileSync as readFileSync21, readdirSync as readdirSync8, existsSync as existsSync25 } from "fs";
17128
17175
  import path30 from "path";
17129
17176
  import { fileURLToPath as fileURLToPath3 } from "url";
17130
17177
  function listPacks() {
17131
17178
  const packsDir = path30.join(__dirname, ".");
17132
- if (!existsSync24(packsDir)) return [];
17179
+ if (!existsSync25(packsDir)) return [];
17133
17180
  return readdirSync8(packsDir, { withFileTypes: true }).filter(
17134
- (d) => d.isDirectory() && existsSync24(path30.join(packsDir, d.name, "custom-objects.json"))
17181
+ (d) => d.isDirectory() && existsSync25(path30.join(packsDir, d.name, "custom-objects.json"))
17135
17182
  ).map((d) => d.name);
17136
17183
  }
17137
17184
  function loadPack(industry) {
@@ -17141,30 +17188,30 @@ function loadPack(industry) {
17141
17188
  const wikiDir = path30.join(packDir, "wiki-seeds");
17142
17189
  const manifestPath = path30.join(packDir, "pack.json");
17143
17190
  const identityContextPath = path30.join(packDir, "identity-context.md");
17144
- if (!existsSync24(objectsPath)) return null;
17191
+ if (!existsSync25(objectsPath)) return null;
17145
17192
  let customObjects = [];
17146
17193
  try {
17147
17194
  customObjects = JSON.parse(
17148
- readFileSync20(objectsPath, "utf-8")
17195
+ readFileSync21(objectsPath, "utf-8")
17149
17196
  );
17150
17197
  } catch {
17151
17198
  customObjects = [];
17152
17199
  }
17153
17200
  let triggers = [];
17154
- if (existsSync24(triggersPath)) {
17201
+ if (existsSync25(triggersPath)) {
17155
17202
  try {
17156
17203
  triggers = JSON.parse(
17157
- readFileSync20(triggersPath, "utf-8")
17204
+ readFileSync21(triggersPath, "utf-8")
17158
17205
  );
17159
17206
  } catch {
17160
17207
  triggers = [];
17161
17208
  }
17162
17209
  }
17163
17210
  const wikiSeeds = [];
17164
- if (existsSync24(wikiDir)) {
17211
+ if (existsSync25(wikiDir)) {
17165
17212
  const files = readdirSync8(wikiDir).filter((f) => f.endsWith(".md"));
17166
17213
  for (const file of files) {
17167
- const content = readFileSync20(path30.join(wikiDir, file), "utf-8");
17214
+ const content = readFileSync21(path30.join(wikiDir, file), "utf-8");
17168
17215
  const titleMatch = content.match(/^#\s+(.+)/m);
17169
17216
  wikiSeeds.push({
17170
17217
  filename: file,
@@ -17174,17 +17221,17 @@ function loadPack(industry) {
17174
17221
  }
17175
17222
  }
17176
17223
  let manifest = {};
17177
- if (existsSync24(manifestPath)) {
17224
+ if (existsSync25(manifestPath)) {
17178
17225
  try {
17179
- manifest = JSON.parse(readFileSync20(manifestPath, "utf-8"));
17226
+ manifest = JSON.parse(readFileSync21(manifestPath, "utf-8"));
17180
17227
  } catch {
17181
17228
  manifest = {};
17182
17229
  }
17183
17230
  }
17184
17231
  let identityContext = null;
17185
- if (existsSync24(identityContextPath)) {
17232
+ if (existsSync25(identityContextPath)) {
17186
17233
  try {
17187
- identityContext = readFileSync20(identityContextPath, "utf-8");
17234
+ identityContext = readFileSync21(identityContextPath, "utf-8");
17188
17235
  } catch {
17189
17236
  identityContext = null;
17190
17237
  }
@@ -17375,18 +17422,18 @@ All memory, tasks, behaviors, documents, and wiki content belonging to {{company
17375
17422
  });
17376
17423
 
17377
17424
  // src/lib/client-coo.ts
17378
- import { existsSync as existsSync25, mkdirSync as mkdirSync11, writeFileSync as writeFileSync15 } from "fs";
17425
+ import { existsSync as existsSync26, mkdirSync as mkdirSync11, writeFileSync as writeFileSync15 } from "fs";
17379
17426
  import path31 from "path";
17380
17427
  async function provisionClientCOO(vars, opts = {}) {
17381
17428
  const identityDir = opts.identityDir ?? path31.join(EXE_AI_DIR, "identity");
17382
17429
  const rosterPath = opts.employeesPath ?? EMPLOYEES_PATH;
17383
17430
  const storeFeedbackBehavior = opts.storeFeedbackBehavior ?? true;
17384
17431
  const identityPath2 = path31.join(identityDir, `${vars.agent_name}.md`);
17385
- if (existsSync25(identityPath2)) {
17432
+ if (existsSync26(identityPath2)) {
17386
17433
  throw new ClientCOOClobberError(vars.agent_name, identityPath2);
17387
17434
  }
17388
17435
  const body = renderClientCOOTemplate(vars);
17389
- if (!existsSync25(identityDir)) {
17436
+ if (!existsSync26(identityDir)) {
17390
17437
  mkdirSync11(identityDir, { recursive: true });
17391
17438
  }
17392
17439
  writeFileSync15(identityPath2, body, "utf-8");
@@ -18900,7 +18947,7 @@ import { z as z47 } from "zod";
18900
18947
  import { execFile } from "child_process";
18901
18948
  import { promisify } from "util";
18902
18949
  import path32 from "path";
18903
- import { existsSync as existsSync26 } from "fs";
18950
+ import { existsSync as existsSync27 } from "fs";
18904
18951
  async function executeDeployment(params, client) {
18905
18952
  const {
18906
18953
  client_name,
@@ -19066,7 +19113,7 @@ async function runAnsiblePlaybook(vpsIp, domain, sslEmail, clientName) {
19066
19113
  "-e",
19067
19114
  `client_name=${safeClientName}`
19068
19115
  ];
19069
- if (existsSync26(clientVarsPath)) {
19116
+ if (existsSync27(clientVarsPath)) {
19070
19117
  args.push("-e", `@${clientVarsPath}`);
19071
19118
  }
19072
19119
  try {
@@ -19157,7 +19204,7 @@ var init_deploy_client = __esm({
19157
19204
 
19158
19205
  // src/lib/orchestration-package.ts
19159
19206
  import { randomUUID as randomUUID6 } from "crypto";
19160
- import { copyFileSync, existsSync as existsSync27, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync16 } from "fs";
19207
+ import { copyFileSync, existsSync as existsSync28, mkdirSync as mkdirSync12, readFileSync as readFileSync22, writeFileSync as writeFileSync16 } from "fs";
19161
19208
  import os14 from "os";
19162
19209
  import path33 from "path";
19163
19210
  function ensureObject(value, label) {
@@ -19225,8 +19272,8 @@ function getBackupPath() {
19225
19272
  }
19226
19273
  function readRosterFile() {
19227
19274
  const rosterPath = getRosterPath();
19228
- if (!existsSync27(rosterPath)) return [];
19229
- const raw = readFileSync21(rosterPath, "utf-8");
19275
+ if (!existsSync28(rosterPath)) return [];
19276
+ const raw = readFileSync22(rosterPath, "utf-8");
19230
19277
  const parsed = JSON.parse(raw);
19231
19278
  if (!Array.isArray(parsed)) {
19232
19279
  throw new Error("Roster file must contain a JSON array");
@@ -19239,7 +19286,7 @@ function writeRosterFile(roster) {
19239
19286
  }
19240
19287
  const rosterPath = getRosterPath();
19241
19288
  mkdirSync12(path33.dirname(rosterPath), { recursive: true });
19242
- if (existsSync27(rosterPath)) {
19289
+ if (existsSync28(rosterPath)) {
19243
19290
  const currentRoster = readRosterFile();
19244
19291
  if (roster.length < currentRoster.length) {
19245
19292
  throw new Error(
@@ -19559,7 +19606,7 @@ var init_export_orchestration = __esm({
19559
19606
  });
19560
19607
 
19561
19608
  // src/mcp/tools/import-orchestration.ts
19562
- import { readFileSync as readFileSync22 } from "fs";
19609
+ import { readFileSync as readFileSync23 } from "fs";
19563
19610
  import { z as z49 } from "zod";
19564
19611
  function registerImportOrchestration(server) {
19565
19612
  server.registerTool(
@@ -19586,7 +19633,7 @@ function registerImportOrchestration(server) {
19586
19633
  };
19587
19634
  }
19588
19635
  await initStore();
19589
- const raw = readFileSync22(package_path, "utf-8");
19636
+ const raw = readFileSync23(package_path, "utf-8");
19590
19637
  const pkg = validatePackage(JSON.parse(raw));
19591
19638
  const result = await importOrchestration(pkg, merge_strategy);
19592
19639
  return {
@@ -19619,9 +19666,9 @@ var init_import_orchestration = __esm({
19619
19666
 
19620
19667
  // src/mcp/tools/load-skill.ts
19621
19668
  import { z as z50 } from "zod";
19622
- import { readFileSync as readFileSync23, readdirSync as readdirSync9, statSync as statSync5 } from "fs";
19669
+ import { readFileSync as readFileSync24, readdirSync as readdirSync9, statSync as statSync5 } from "fs";
19623
19670
  import path35 from "path";
19624
- import { homedir as homedir2 } from "os";
19671
+ import { homedir as homedir3 } from "os";
19625
19672
  function listAvailableSkills() {
19626
19673
  try {
19627
19674
  const entries = readdirSync9(SKILLS_DIR);
@@ -19675,7 +19722,7 @@ ${skills.map((s) => `- ${s}`).join("\n")}`
19675
19722
  const sanitized = path35.basename(skill_name);
19676
19723
  const skillFile = path35.join(SKILLS_DIR, sanitized, "SKILL.md");
19677
19724
  try {
19678
- const content = readFileSync23(skillFile, "utf-8");
19725
+ const content = readFileSync24(skillFile, "utf-8");
19679
19726
  return {
19680
19727
  content: [{
19681
19728
  type: "text",
@@ -19704,7 +19751,7 @@ var SKILLS_DIR;
19704
19751
  var init_load_skill = __esm({
19705
19752
  "src/mcp/tools/load-skill.ts"() {
19706
19753
  "use strict";
19707
- SKILLS_DIR = path35.join(homedir2(), ".claude", "skills");
19754
+ SKILLS_DIR = path35.join(homedir3(), ".claude", "skills");
19708
19755
  }
19709
19756
  });
19710
19757
 
@@ -21401,9 +21448,9 @@ var init_list_agent_sessions = __esm({
21401
21448
 
21402
21449
  // src/mcp/tools/get-daemon-health.ts
21403
21450
  import { z as z66 } from "zod";
21404
- import { existsSync as existsSync28, readFileSync as readFileSync24 } from "fs";
21451
+ import { existsSync as existsSync29, readFileSync as readFileSync25 } from "fs";
21405
21452
  import path37 from "path";
21406
- import { homedir as homedir3 } from "os";
21453
+ import { homedir as homedir4 } from "os";
21407
21454
  function formatUptime(seconds) {
21408
21455
  const h = Math.floor(seconds / 3600);
21409
21456
  const m = Math.floor(seconds % 3600 / 60);
@@ -21414,8 +21461,8 @@ function formatUptime(seconds) {
21414
21461
  }
21415
21462
  function isDaemonAlive() {
21416
21463
  try {
21417
- if (!existsSync28(PID_PATH2)) return { alive: false, pid: null };
21418
- const pid = parseInt(readFileSync24(PID_PATH2, "utf8").trim(), 10);
21464
+ if (!existsSync29(PID_PATH2)) return { alive: false, pid: null };
21465
+ const pid = parseInt(readFileSync25(PID_PATH2, "utf8").trim(), 10);
21419
21466
  if (isNaN(pid) || pid <= 0) return { alive: false, pid: null };
21420
21467
  process.kill(pid, 0);
21421
21468
  return { alive: true, pid };
@@ -21482,7 +21529,7 @@ var PID_PATH2;
21482
21529
  var init_get_daemon_health = __esm({
21483
21530
  "src/mcp/tools/get-daemon-health.ts"() {
21484
21531
  "use strict";
21485
- PID_PATH2 = path37.join(homedir3(), ".exe-os", "exed.pid");
21532
+ PID_PATH2 = path37.join(homedir4(), ".exe-os", "exed.pid");
21486
21533
  }
21487
21534
  });
21488
21535
 
@@ -21764,7 +21811,7 @@ __export(agent_signals_exports, {
21764
21811
  hasOpenTasks: () => hasOpenTasks,
21765
21812
  hasUnreadInbox: () => hasUnreadInbox
21766
21813
  });
21767
- import { readFileSync as readFileSync25, existsSync as existsSync29 } from "fs";
21814
+ import { readFileSync as readFileSync26, existsSync as existsSync30 } from "fs";
21768
21815
  import os16 from "os";
21769
21816
  import path38 from "path";
21770
21817
  async function hasOpenTasks(client, agentId) {
@@ -21809,9 +21856,9 @@ async function hasUnreadInbox(client, agentId) {
21809
21856
  }
21810
21857
  }
21811
21858
  function hadRecentIntercomAck(sessionName, windowMs, nowMs = Date.now(), intercomLog = path38.join(os16.homedir(), ".exe-os", "intercom.log")) {
21812
- if (!existsSync29(intercomLog)) return false;
21859
+ if (!existsSync30(intercomLog)) return false;
21813
21860
  try {
21814
- const raw = readFileSync25(intercomLog, "utf8");
21861
+ const raw = readFileSync26(intercomLog, "utf8");
21815
21862
  const lines = raw.split("\n");
21816
21863
  for (let i = lines.length - 1; i >= 0; i--) {
21817
21864
  const line = lines[i];
@@ -21884,9 +21931,9 @@ __export(daemon_orchestration_exports, {
21884
21931
  shouldNudgeEmployee: () => shouldNudgeEmployee
21885
21932
  });
21886
21933
  import { execSync as execSync13 } from "child_process";
21887
- import { existsSync as existsSync30, readFileSync as readFileSync26, writeFileSync as writeFileSync18 } from "fs";
21888
- import { homedir as homedir4 } from "os";
21889
- import { join as join2 } from "path";
21934
+ import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "fs";
21935
+ import { homedir as homedir5 } from "os";
21936
+ import { join as join3 } from "path";
21890
21937
  function shouldNudgeEmployee(sessionState, hasOpenTasks2, lastNudgeMs, nowMs, dedupMs) {
21891
21938
  if (sessionState !== "idle") return false;
21892
21939
  if (!hasOpenTasks2) return false;
@@ -22111,8 +22158,8 @@ async function pollReviewNudge(deps, state) {
22111
22158
  function loadNudgeState() {
22112
22159
  const state = { lastNudge: /* @__PURE__ */ new Map() };
22113
22160
  try {
22114
- if (!existsSync30(NUDGE_STATE_PATH)) return state;
22115
- const raw = JSON.parse(readFileSync26(NUDGE_STATE_PATH, "utf8"));
22161
+ if (!existsSync31(NUDGE_STATE_PATH)) return state;
22162
+ const raw = JSON.parse(readFileSync27(NUDGE_STATE_PATH, "utf8"));
22116
22163
  if (Array.isArray(raw)) {
22117
22164
  for (const [key, val] of raw) {
22118
22165
  if (key && typeof val?.at === "number" && typeof val?.count === "number") {
@@ -22460,7 +22507,7 @@ var init_daemon_orchestration = __esm({
22460
22507
  SESSION_CONTEXT_THRESHOLD_PCT = Number(process.env.EXE_CONTEXT_KILL_PCT) || 50;
22461
22508
  IDLE_KILL_INTERCOM_ACK_WINDOW_MS = Number(process.env.EXE_INTERCOM_ACK_WINDOW_MS) || 1e4;
22462
22509
  REVIEW_NUDGE_COOLDOWN_MS = 3e5;
22463
- NUDGE_STATE_PATH = join2(homedir4(), ".exe-os", "review-nudge-state.json");
22510
+ NUDGE_STATE_PATH = join3(homedir5(), ".exe-os", "review-nudge-state.json");
22464
22511
  AUTO_WAKE_COOLDOWN_MS = 5 * 60 * 1e3;
22465
22512
  AUTO_WAKE_MAX_RETRIES = 3;
22466
22513
  _autoWakeLastSpawn = /* @__PURE__ */ new Map();
@@ -22582,7 +22629,7 @@ __export(worker_gate_exports, {
22582
22629
  tryAcquireBackfillLock: () => tryAcquireBackfillLock,
22583
22630
  tryAcquireWorkerSlot: () => tryAcquireWorkerSlot
22584
22631
  });
22585
- import { readdirSync as readdirSync10, writeFileSync as writeFileSync19, unlinkSync as unlinkSync9, mkdirSync as mkdirSync14, existsSync as existsSync31 } from "fs";
22632
+ import { readdirSync as readdirSync10, writeFileSync as writeFileSync19, unlinkSync as unlinkSync9, mkdirSync as mkdirSync14, existsSync as existsSync32 } from "fs";
22586
22633
  import path39 from "path";
22587
22634
  function tryAcquireWorkerSlot() {
22588
22635
  try {
@@ -22643,7 +22690,7 @@ function cleanupWorkerPid() {
22643
22690
  function tryAcquireBackfillLock() {
22644
22691
  try {
22645
22692
  mkdirSync14(WORKER_PID_DIR, { recursive: true });
22646
- if (existsSync31(BACKFILL_LOCK)) {
22693
+ if (existsSync32(BACKFILL_LOCK)) {
22647
22694
  try {
22648
22695
  const pid = parseInt(
22649
22696
  __require("fs").readFileSync(BACKFILL_LOCK, "utf8").trim(),
@@ -22684,14 +22731,14 @@ var init_worker_gate = __esm({
22684
22731
 
22685
22732
  // src/mcp/tools/get-worker-gate.ts
22686
22733
  import { z as z68 } from "zod";
22687
- import { readdirSync as readdirSync11, existsSync as existsSync32 } from "fs";
22734
+ import { readdirSync as readdirSync11, existsSync as existsSync33 } from "fs";
22688
22735
  import path40 from "path";
22689
22736
  function countAliveWorkers() {
22690
22737
  let alive = 0;
22691
22738
  let stale = 0;
22692
22739
  let reservations = 0;
22693
22740
  try {
22694
- if (!existsSync32(WORKER_PID_DIR2)) return { alive: 0, stale: 0, reservations: 0 };
22741
+ if (!existsSync33(WORKER_PID_DIR2)) return { alive: 0, stale: 0, reservations: 0 };
22695
22742
  const files = readdirSync11(WORKER_PID_DIR2);
22696
22743
  for (const f of files) {
22697
22744
  if (!f.endsWith(".pid")) continue;
@@ -23060,12 +23107,12 @@ __export(db_backup_exports, {
23060
23107
  listBackups: () => listBackups,
23061
23108
  rotateBackups: () => rotateBackups
23062
23109
  });
23063
- import { copyFileSync as copyFileSync2, existsSync as existsSync33, mkdirSync as mkdirSync15, readdirSync as readdirSync12, unlinkSync as unlinkSync10, statSync as statSync6 } from "fs";
23110
+ import { copyFileSync as copyFileSync2, existsSync as existsSync34, mkdirSync as mkdirSync15, readdirSync as readdirSync12, unlinkSync as unlinkSync10, statSync as statSync6 } from "fs";
23064
23111
  import path41 from "path";
23065
23112
  function findActiveDb() {
23066
23113
  for (const name of DB_NAMES) {
23067
23114
  const p = path41.join(EXE_AI_DIR, name);
23068
- if (existsSync33(p)) return p;
23115
+ if (existsSync34(p)) return p;
23069
23116
  }
23070
23117
  return null;
23071
23118
  }
@@ -23079,14 +23126,14 @@ function createBackup(reason = "manual") {
23079
23126
  const backupPath = path41.join(BACKUP_DIR, backupName);
23080
23127
  copyFileSync2(dbPath, backupPath);
23081
23128
  const walPath = dbPath + "-wal";
23082
- if (existsSync33(walPath)) {
23129
+ if (existsSync34(walPath)) {
23083
23130
  try {
23084
23131
  copyFileSync2(walPath, backupPath + "-wal");
23085
23132
  } catch {
23086
23133
  }
23087
23134
  }
23088
23135
  const shmPath = dbPath + "-shm";
23089
- if (existsSync33(shmPath)) {
23136
+ if (existsSync34(shmPath)) {
23090
23137
  try {
23091
23138
  copyFileSync2(shmPath, backupPath + "-shm");
23092
23139
  } catch {
@@ -23095,7 +23142,7 @@ function createBackup(reason = "manual") {
23095
23142
  return backupPath;
23096
23143
  }
23097
23144
  function rotateBackups(keepDays = DEFAULT_KEEP_DAYS) {
23098
- if (!existsSync33(BACKUP_DIR)) return 0;
23145
+ if (!existsSync34(BACKUP_DIR)) return 0;
23099
23146
  const cutoff = Date.now() - keepDays * 24 * 60 * 60 * 1e3;
23100
23147
  let deleted = 0;
23101
23148
  try {
@@ -23117,7 +23164,7 @@ function rotateBackups(keepDays = DEFAULT_KEEP_DAYS) {
23117
23164
  return deleted;
23118
23165
  }
23119
23166
  function listBackups() {
23120
- if (!existsSync33(BACKUP_DIR)) return [];
23167
+ if (!existsSync34(BACKUP_DIR)) return [];
23121
23168
  try {
23122
23169
  const files = readdirSync12(BACKUP_DIR).filter((f) => f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm"));
23123
23170
  return files.map((name) => {
@@ -23154,7 +23201,7 @@ var init_db_backup = __esm({
23154
23201
 
23155
23202
  // src/bin/exe-doctor.ts
23156
23203
  import os17 from "os";
23157
- import { existsSync as existsSync34, readFileSync as readFileSync27 } from "fs";
23204
+ import { existsSync as existsSync35, readFileSync as readFileSync28 } from "fs";
23158
23205
  import { spawn as spawn2 } from "child_process";
23159
23206
  import path42 from "path";
23160
23207
  import { randomUUID as randomUUID7 } from "crypto";
@@ -23308,7 +23355,7 @@ async function auditOrphanedProjects(client) {
23308
23355
  for (const row of result.rows) {
23309
23356
  const name = row.project_name;
23310
23357
  const count = Number(row.cnt);
23311
- const exists = existsSync34(path42.join(home, name)) || existsSync34(path42.join(home, "..", name)) || existsSync34(path42.join(process.cwd(), "..", name));
23358
+ const exists = existsSync35(path42.join(home, name)) || existsSync35(path42.join(home, "..", name)) || existsSync35(path42.join(process.cwd(), "..", name));
23312
23359
  if (!exists) {
23313
23360
  orphans.push({ project_name: name, count });
23314
23361
  }
@@ -23322,12 +23369,12 @@ function auditHookHealth() {
23322
23369
  "logs",
23323
23370
  "hooks.log"
23324
23371
  );
23325
- if (!existsSync34(logPath)) {
23372
+ if (!existsSync35(logPath)) {
23326
23373
  return { logExists: false, totalLines: 0, errorsLastHour: 0, topPatterns: [] };
23327
23374
  }
23328
23375
  let content;
23329
23376
  try {
23330
- content = readFileSync27(logPath, "utf-8");
23377
+ content = readFileSync28(logPath, "utf-8");
23331
23378
  } catch {
23332
23379
  return { logExists: false, totalLines: 0, errorsLastHour: 0, topPatterns: [] };
23333
23380
  }
@@ -23852,9 +23899,9 @@ __export(crdt_sync_exports, {
23852
23899
  rebuildFromDb: () => rebuildFromDb
23853
23900
  });
23854
23901
  import * as Y from "yjs";
23855
- import { readFileSync as readFileSync28, writeFileSync as writeFileSync20, existsSync as existsSync35, mkdirSync as mkdirSync16, unlinkSync as unlinkSync11 } from "fs";
23902
+ import { readFileSync as readFileSync29, writeFileSync as writeFileSync20, existsSync as existsSync36, mkdirSync as mkdirSync16, unlinkSync as unlinkSync11 } from "fs";
23856
23903
  import path43 from "path";
23857
- import { homedir as homedir5 } from "os";
23904
+ import { homedir as homedir6 } from "os";
23858
23905
  function getStatePath() {
23859
23906
  return _statePathOverride ?? DEFAULT_STATE_PATH;
23860
23907
  }
@@ -23865,9 +23912,9 @@ function initCrdtDoc() {
23865
23912
  if (doc) return doc;
23866
23913
  doc = new Y.Doc();
23867
23914
  const sp = getStatePath();
23868
- if (existsSync35(sp)) {
23915
+ if (existsSync36(sp)) {
23869
23916
  try {
23870
- const state = readFileSync28(sp);
23917
+ const state = readFileSync29(sp);
23871
23918
  Y.applyUpdate(doc, new Uint8Array(state));
23872
23919
  } catch {
23873
23920
  console.warn("[crdt-sync] WARN: corrupted state file, rebuilding from DB");
@@ -24010,7 +24057,7 @@ function persistState() {
24010
24057
  try {
24011
24058
  const sp = getStatePath();
24012
24059
  const dir = path43.dirname(sp);
24013
- if (!existsSync35(dir)) mkdirSync16(dir, { recursive: true });
24060
+ if (!existsSync36(dir)) mkdirSync16(dir, { recursive: true });
24014
24061
  const state = Y.encodeStateAsUpdate(doc);
24015
24062
  writeFileSync20(sp, Buffer.from(state));
24016
24063
  } catch {
@@ -24053,7 +24100,7 @@ var DEFAULT_STATE_PATH, _statePathOverride, doc;
24053
24100
  var init_crdt_sync = __esm({
24054
24101
  "src/lib/crdt-sync.ts"() {
24055
24102
  "use strict";
24056
- DEFAULT_STATE_PATH = path43.join(homedir5(), ".exe-os", "crdt-state.bin");
24103
+ DEFAULT_STATE_PATH = path43.join(homedir6(), ".exe-os", "crdt-state.bin");
24057
24104
  _statePathOverride = null;
24058
24105
  doc = null;
24059
24106
  }
@@ -24088,16 +24135,16 @@ __export(cloud_sync_exports, {
24088
24135
  pushToPostgres: () => pushToPostgres,
24089
24136
  recordRosterDeletion: () => recordRosterDeletion
24090
24137
  });
24091
- import { readFileSync as readFileSync29, writeFileSync as writeFileSync21, existsSync as existsSync36, readdirSync as readdirSync13, mkdirSync as mkdirSync17, appendFileSync as appendFileSync3, unlinkSync as unlinkSync12, openSync as openSync2, closeSync as closeSync2, statSync as statSync7 } from "fs";
24138
+ import { readFileSync as readFileSync30, writeFileSync as writeFileSync21, existsSync as existsSync37, readdirSync as readdirSync13, mkdirSync as mkdirSync17, appendFileSync as appendFileSync3, unlinkSync as unlinkSync12, openSync as openSync2, closeSync as closeSync2, statSync as statSync7 } from "fs";
24092
24139
  import crypto18 from "crypto";
24093
24140
  import path44 from "path";
24094
- import { homedir as homedir6 } from "os";
24141
+ import { homedir as homedir7 } from "os";
24095
24142
  function sqlSafe(v) {
24096
24143
  return v === void 0 ? null : v;
24097
24144
  }
24098
24145
  function logError(msg) {
24099
24146
  try {
24100
- const logPath = path44.join(homedir6(), ".exe-os", "workers.log");
24147
+ const logPath = path44.join(homedir7(), ".exe-os", "workers.log");
24101
24148
  appendFileSync3(logPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
24102
24149
  `);
24103
24150
  } catch {
@@ -24109,8 +24156,8 @@ function loadPgClient() {
24109
24156
  const configPath = path44.join(EXE_AI_DIR, "config.json");
24110
24157
  let cloudPostgresUrl;
24111
24158
  try {
24112
- if (existsSync36(configPath)) {
24113
- const cfg = JSON.parse(readFileSync29(configPath, "utf8"));
24159
+ if (existsSync37(configPath)) {
24160
+ const cfg = JSON.parse(readFileSync30(configPath, "utf8"));
24114
24161
  cloudPostgresUrl = cfg.cloud?.postgresUrl;
24115
24162
  if (cfg.cloud?.syncToPostgres === false) {
24116
24163
  _pgFailed = true;
@@ -24128,7 +24175,7 @@ function loadPgClient() {
24128
24175
  _pgPromise = (async () => {
24129
24176
  const { createRequire: createRequire7 } = await import("module");
24130
24177
  const { pathToFileURL: pathToFileURL7 } = await import("url");
24131
- const exeDbRoot = process.env.EXE_DB_ROOT ?? path44.join(homedir6(), "exe-db");
24178
+ const exeDbRoot = process.env.EXE_DB_ROOT ?? path44.join(homedir7(), "exe-db");
24132
24179
  const req = createRequire7(path44.join(exeDbRoot, "package.json"));
24133
24180
  const entry = req.resolve("@prisma/client");
24134
24181
  const mod = await import(pathToFileURL7(entry).href);
@@ -24178,7 +24225,7 @@ async function withRosterLock(fn) {
24178
24225
  } catch (err) {
24179
24226
  if (err.code === "EEXIST") {
24180
24227
  try {
24181
- const ts2 = parseInt(readFileSync29(ROSTER_LOCK_PATH, "utf-8"), 10);
24228
+ const ts2 = parseInt(readFileSync30(ROSTER_LOCK_PATH, "utf-8"), 10);
24182
24229
  if (Date.now() - ts2 < LOCK_STALE_MS) {
24183
24230
  throw new Error("Roster merge already in progress \u2014 another sync is running");
24184
24231
  }
@@ -24570,7 +24617,7 @@ async function cloudSync(config2) {
24570
24617
  const employees = await loadEmployees();
24571
24618
  rosterResult.employees = employees.length;
24572
24619
  const idDir = path44.join(EXE_AI_DIR, "identity");
24573
- if (existsSync36(idDir)) {
24620
+ if (existsSync37(idDir)) {
24574
24621
  rosterResult.identities = readdirSync13(idDir).filter((f) => f.endsWith(".md")).length;
24575
24622
  }
24576
24623
  } catch {
@@ -24583,7 +24630,7 @@ async function cloudSync(config2) {
24583
24630
  const backupSize = statSync7(latestBackup).size;
24584
24631
  const MAX_CLOUD_BACKUP_BYTES = 50 * 1024 * 1024;
24585
24632
  if (backupSize <= MAX_CLOUD_BACKUP_BYTES) {
24586
- const backupData = readFileSync29(latestBackup);
24633
+ const backupData = readFileSync30(latestBackup);
24587
24634
  const deviceId = loadDeviceId() ?? "unknown";
24588
24635
  const encrypted = encryptSyncBlob(backupData);
24589
24636
  const backupRes = await fetchWithRetry(`${config2.endpoint}/sync/push-db-backup`, {
@@ -24619,8 +24666,8 @@ async function cloudSync(config2) {
24619
24666
  function recordRosterDeletion(name) {
24620
24667
  let deletions = [];
24621
24668
  try {
24622
- if (existsSync36(ROSTER_DELETIONS_PATH)) {
24623
- deletions = JSON.parse(readFileSync29(ROSTER_DELETIONS_PATH, "utf-8"));
24669
+ if (existsSync37(ROSTER_DELETIONS_PATH)) {
24670
+ deletions = JSON.parse(readFileSync30(ROSTER_DELETIONS_PATH, "utf-8"));
24624
24671
  }
24625
24672
  } catch {
24626
24673
  }
@@ -24629,8 +24676,8 @@ function recordRosterDeletion(name) {
24629
24676
  }
24630
24677
  function consumeRosterDeletions() {
24631
24678
  try {
24632
- if (!existsSync36(ROSTER_DELETIONS_PATH)) return [];
24633
- const deletions = JSON.parse(readFileSync29(ROSTER_DELETIONS_PATH, "utf-8"));
24679
+ if (!existsSync37(ROSTER_DELETIONS_PATH)) return [];
24680
+ const deletions = JSON.parse(readFileSync30(ROSTER_DELETIONS_PATH, "utf-8"));
24634
24681
  writeFileSync21(ROSTER_DELETIONS_PATH, "[]");
24635
24682
  return deletions;
24636
24683
  } catch {
@@ -24642,33 +24689,33 @@ function buildRosterBlob(paths) {
24642
24689
  const identityDir = paths?.identityDir ?? path44.join(EXE_AI_DIR, "identity");
24643
24690
  const configPath = paths?.configPath ?? path44.join(EXE_AI_DIR, "config.json");
24644
24691
  let roster = [];
24645
- if (existsSync36(rosterPath)) {
24692
+ if (existsSync37(rosterPath)) {
24646
24693
  try {
24647
- roster = JSON.parse(readFileSync29(rosterPath, "utf-8"));
24694
+ roster = JSON.parse(readFileSync30(rosterPath, "utf-8"));
24648
24695
  } catch {
24649
24696
  }
24650
24697
  }
24651
24698
  const identities = {};
24652
- if (existsSync36(identityDir)) {
24699
+ if (existsSync37(identityDir)) {
24653
24700
  for (const file of readdirSync13(identityDir).filter((f) => f.endsWith(".md"))) {
24654
24701
  try {
24655
- identities[file] = readFileSync29(path44.join(identityDir, file), "utf-8");
24702
+ identities[file] = readFileSync30(path44.join(identityDir, file), "utf-8");
24656
24703
  } catch {
24657
24704
  }
24658
24705
  }
24659
24706
  }
24660
24707
  let config2;
24661
- if (existsSync36(configPath)) {
24708
+ if (existsSync37(configPath)) {
24662
24709
  try {
24663
- config2 = JSON.parse(readFileSync29(configPath, "utf-8"));
24710
+ config2 = JSON.parse(readFileSync30(configPath, "utf-8"));
24664
24711
  } catch {
24665
24712
  }
24666
24713
  }
24667
24714
  let agentConfig;
24668
24715
  const agentConfigPath = path44.join(EXE_AI_DIR, "agent-config.json");
24669
- if (existsSync36(agentConfigPath)) {
24716
+ if (existsSync37(agentConfigPath)) {
24670
24717
  try {
24671
- agentConfig = JSON.parse(readFileSync29(agentConfigPath, "utf-8"));
24718
+ agentConfig = JSON.parse(readFileSync30(agentConfigPath, "utf-8"));
24672
24719
  } catch {
24673
24720
  }
24674
24721
  }
@@ -24746,9 +24793,9 @@ async function cloudPullRoster(config2) {
24746
24793
  function mergeConfig(remoteConfig, configPath) {
24747
24794
  const cfgPath = configPath ?? path44.join(EXE_AI_DIR, "config.json");
24748
24795
  let local = {};
24749
- if (existsSync36(cfgPath)) {
24796
+ if (existsSync37(cfgPath)) {
24750
24797
  try {
24751
- local = JSON.parse(readFileSync29(cfgPath, "utf-8"));
24798
+ local = JSON.parse(readFileSync30(cfgPath, "utf-8"));
24752
24799
  } catch {
24753
24800
  }
24754
24801
  }
@@ -24782,11 +24829,11 @@ async function mergeRosterFromRemote(remote, paths) {
24782
24829
  ) ?? lookupKey;
24783
24830
  const remoteIdentity = remote.identities[matchedKey];
24784
24831
  if (remoteIdentity) {
24785
- if (!existsSync36(identityDir)) mkdirSync17(identityDir, { recursive: true });
24832
+ if (!existsSync37(identityDir)) mkdirSync17(identityDir, { recursive: true });
24786
24833
  const idPath = path44.join(identityDir, `${remoteEmp.name}.md`);
24787
24834
  let localIdentity = null;
24788
24835
  try {
24789
- localIdentity = existsSync36(idPath) ? readFileSync29(idPath, "utf-8") : null;
24836
+ localIdentity = existsSync37(idPath) ? readFileSync30(idPath, "utf-8") : null;
24790
24837
  } catch {
24791
24838
  }
24792
24839
  if (localIdentity !== remoteIdentity) {
@@ -24818,9 +24865,9 @@ async function mergeRosterFromRemote(remote, paths) {
24818
24865
  try {
24819
24866
  const agentConfigPath = path44.join(EXE_AI_DIR, "agent-config.json");
24820
24867
  let local = {};
24821
- if (existsSync36(agentConfigPath)) {
24868
+ if (existsSync37(agentConfigPath)) {
24822
24869
  try {
24823
- local = JSON.parse(readFileSync29(agentConfigPath, "utf-8"));
24870
+ local = JSON.parse(readFileSync30(agentConfigPath, "utf-8"));
24824
24871
  } catch {
24825
24872
  }
24826
24873
  }
@@ -26010,10 +26057,10 @@ var init_backup_vps = __esm({
26010
26057
 
26011
26058
  // src/lib/people.ts
26012
26059
  import { readFile as readFile5, writeFile as writeFile6, mkdir as mkdir5 } from "fs/promises";
26013
- import { existsSync as existsSync37, readFileSync as readFileSync30 } from "fs";
26060
+ import { existsSync as existsSync38, readFileSync as readFileSync31 } from "fs";
26014
26061
  import path45 from "path";
26015
26062
  async function loadPeople() {
26016
- if (!existsSync37(PEOPLE_PATH)) return [];
26063
+ if (!existsSync38(PEOPLE_PATH)) return [];
26017
26064
  try {
26018
26065
  const raw = await readFile5(PEOPLE_PATH, "utf-8");
26019
26066
  return JSON.parse(raw);
@@ -27942,11 +27989,11 @@ __export(update_check_exports, {
27942
27989
  getRemoteVersion: () => getRemoteVersion
27943
27990
  });
27944
27991
  import { execSync as execSync15 } from "child_process";
27945
- import { readFileSync as readFileSync31 } from "fs";
27992
+ import { readFileSync as readFileSync32 } from "fs";
27946
27993
  import path51 from "path";
27947
27994
  function getLocalVersion(packageRoot) {
27948
27995
  const pkgPath = path51.join(packageRoot, "package.json");
27949
- const pkg = JSON.parse(readFileSync31(pkgPath, "utf-8"));
27996
+ const pkg = JSON.parse(readFileSync32(pkgPath, "utf-8"));
27950
27997
  return pkg.version;
27951
27998
  }
27952
27999
  function getRemoteVersion() {
@@ -28018,12 +28065,12 @@ __export(device_registry_exports, {
28018
28065
  });
28019
28066
  import crypto21 from "crypto";
28020
28067
  import os21 from "os";
28021
- import { readFileSync as readFileSync32, writeFileSync as writeFileSync23, mkdirSync as mkdirSync18, existsSync as existsSync38 } from "fs";
28068
+ import { readFileSync as readFileSync33, writeFileSync as writeFileSync23, mkdirSync as mkdirSync18, existsSync as existsSync39 } from "fs";
28022
28069
  import path52 from "path";
28023
28070
  function getDeviceInfo() {
28024
- if (existsSync38(DEVICE_JSON_PATH)) {
28071
+ if (existsSync39(DEVICE_JSON_PATH)) {
28025
28072
  try {
28026
- const raw = readFileSync32(DEVICE_JSON_PATH, "utf8");
28073
+ const raw = readFileSync33(DEVICE_JSON_PATH, "utf8");
28027
28074
  const data = JSON.parse(raw);
28028
28075
  if (data.deviceId && data.friendlyName && data.hostname) {
28029
28076
  return data;
@@ -28294,7 +28341,7 @@ import os22 from "os";
28294
28341
  import net2 from "net";
28295
28342
  import { createServer as createHttpServer } from "http";
28296
28343
  import { randomUUID as randomUUID9 } from "crypto";
28297
- import { writeFileSync as writeFileSync24, unlinkSync as unlinkSync13, mkdirSync as mkdirSync19, existsSync as existsSync39, readFileSync as readFileSync33, chmodSync as chmodSync2 } from "fs";
28344
+ import { writeFileSync as writeFileSync24, unlinkSync as unlinkSync13, mkdirSync as mkdirSync19, existsSync as existsSync40, readFileSync as readFileSync34, chmodSync as chmodSync2 } from "fs";
28298
28345
  import path53 from "path";
28299
28346
 
28300
28347
  // src/lib/orchestration-metrics.ts
@@ -28397,7 +28444,7 @@ function enqueue(queue, entry) {
28397
28444
  }
28398
28445
  async function loadModel() {
28399
28446
  const modelPath = path53.join(MODELS_DIR, MODEL_FILE);
28400
- if (!existsSync39(modelPath)) {
28447
+ if (!existsSync40(modelPath)) {
28401
28448
  process.stderr.write(`[exed] No model at ${modelPath} \u2014 running without embeddings (VPS mode).
28402
28449
  `);
28403
28450
  return;
@@ -28805,7 +28852,7 @@ function startServer() {
28805
28852
  const oldPath = path53.join(path53.dirname(SOCKET_PATH2), oldFile);
28806
28853
  try {
28807
28854
  if (oldFile.endsWith(".pid")) {
28808
- const pid = parseInt(readFileSync33(oldPath, "utf8").trim(), 10);
28855
+ const pid = parseInt(readFileSync34(oldPath, "utf8").trim(), 10);
28809
28856
  if (pid > 0) try {
28810
28857
  process.kill(pid, "SIGKILL");
28811
28858
  } catch {
@@ -29456,11 +29503,11 @@ function startIntercomQueueDrain() {
29456
29503
  try {
29457
29504
  const { baseAgentName: ban } = (init_employees(), __toCommonJS(employees_exports));
29458
29505
  const path54 = __require("path");
29459
- const { existsSync: existsSync40 } = __require("fs");
29506
+ const { existsSync: existsSync41 } = __require("fs");
29460
29507
  const os23 = __require("os");
29461
29508
  const agent = ban(session.split("-")[0] ?? session);
29462
29509
  const markerPath = path54.join(os23.homedir(), ".exe-os", "session-cache", `current-task-${agent}.json`);
29463
- return existsSync40(markerPath);
29510
+ return existsSync41(markerPath);
29464
29511
  } catch {
29465
29512
  return false;
29466
29513
  }
@@ -29624,8 +29671,8 @@ process.on("SIGINT", () => void shutdown());
29624
29671
  process.on("SIGTERM", () => void shutdown());
29625
29672
  function checkExistingDaemon() {
29626
29673
  try {
29627
- if (!existsSync39(PID_PATH3)) return false;
29628
- const pid = parseInt(readFileSync33(PID_PATH3, "utf8").trim(), 10);
29674
+ if (!existsSync40(PID_PATH3)) return false;
29675
+ const pid = parseInt(readFileSync34(PID_PATH3, "utf8").trim(), 10);
29629
29676
  if (!pid || isNaN(pid)) return false;
29630
29677
  process.kill(pid, 0);
29631
29678
  process.stderr.write(`[exed] Another daemon is already running (PID ${pid}). Exiting.