@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.
- package/dist/lib/exe-daemon.js +178 -131
- package/dist/mcp/server.js +163 -116
- package/package.json +1 -1
package/dist/mcp/server.js
CHANGED
|
@@ -849,10 +849,10 @@ async function disposeEmbedder() {
|
|
|
849
849
|
async function embedDirect(text3) {
|
|
850
850
|
const llamaCpp = await import("node-llama-cpp");
|
|
851
851
|
const { MODELS_DIR: MODELS_DIR2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
852
|
-
const { existsSync:
|
|
852
|
+
const { existsSync: existsSync36 } = await import("fs");
|
|
853
853
|
const path47 = await import("path");
|
|
854
854
|
const modelPath = path47.join(MODELS_DIR2, "jina-embeddings-v5-small-q4_k_m.gguf");
|
|
855
|
-
if (!
|
|
855
|
+
if (!existsSync36(modelPath)) {
|
|
856
856
|
throw new Error(`Embedding model not found at ${modelPath}. Run '/exe-setup' to download it.`);
|
|
857
857
|
}
|
|
858
858
|
const llama = await llamaCpp.getLlama();
|
|
@@ -3356,8 +3356,8 @@ function deriveMachineKey() {
|
|
|
3356
3356
|
}
|
|
3357
3357
|
function readMachineId() {
|
|
3358
3358
|
try {
|
|
3359
|
-
const { readFileSync:
|
|
3360
|
-
return
|
|
3359
|
+
const { readFileSync: readFileSync30 } = __require("fs");
|
|
3360
|
+
return readFileSync30("/etc/machine-id", "utf-8").trim();
|
|
3361
3361
|
} catch {
|
|
3362
3362
|
return "";
|
|
3363
3363
|
}
|
|
@@ -12297,7 +12297,7 @@ __export(worker_gate_exports, {
|
|
|
12297
12297
|
tryAcquireBackfillLock: () => tryAcquireBackfillLock,
|
|
12298
12298
|
tryAcquireWorkerSlot: () => tryAcquireWorkerSlot
|
|
12299
12299
|
});
|
|
12300
|
-
import { readdirSync as readdirSync10, writeFileSync as writeFileSync18, unlinkSync as unlinkSync8, mkdirSync as mkdirSync14, existsSync as
|
|
12300
|
+
import { readdirSync as readdirSync10, writeFileSync as writeFileSync18, unlinkSync as unlinkSync8, mkdirSync as mkdirSync14, existsSync as existsSync28 } from "fs";
|
|
12301
12301
|
import path35 from "path";
|
|
12302
12302
|
function tryAcquireWorkerSlot() {
|
|
12303
12303
|
try {
|
|
@@ -12358,7 +12358,7 @@ function cleanupWorkerPid() {
|
|
|
12358
12358
|
function tryAcquireBackfillLock() {
|
|
12359
12359
|
try {
|
|
12360
12360
|
mkdirSync14(WORKER_PID_DIR, { recursive: true });
|
|
12361
|
-
if (
|
|
12361
|
+
if (existsSync28(BACKFILL_LOCK)) {
|
|
12362
12362
|
try {
|
|
12363
12363
|
const pid = parseInt(
|
|
12364
12364
|
__require("fs").readFileSync(BACKFILL_LOCK, "utf8").trim(),
|
|
@@ -12408,12 +12408,12 @@ __export(db_backup_exports, {
|
|
|
12408
12408
|
listBackups: () => listBackups,
|
|
12409
12409
|
rotateBackups: () => rotateBackups
|
|
12410
12410
|
});
|
|
12411
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
12411
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync15, readdirSync as readdirSync12, unlinkSync as unlinkSync9, statSync as statSync5 } from "fs";
|
|
12412
12412
|
import path37 from "path";
|
|
12413
12413
|
function findActiveDb() {
|
|
12414
12414
|
for (const name of DB_NAMES) {
|
|
12415
12415
|
const p = path37.join(EXE_AI_DIR, name);
|
|
12416
|
-
if (
|
|
12416
|
+
if (existsSync30(p)) return p;
|
|
12417
12417
|
}
|
|
12418
12418
|
return null;
|
|
12419
12419
|
}
|
|
@@ -12427,14 +12427,14 @@ function createBackup(reason = "manual") {
|
|
|
12427
12427
|
const backupPath = path37.join(BACKUP_DIR, backupName);
|
|
12428
12428
|
copyFileSync2(dbPath, backupPath);
|
|
12429
12429
|
const walPath = dbPath + "-wal";
|
|
12430
|
-
if (
|
|
12430
|
+
if (existsSync30(walPath)) {
|
|
12431
12431
|
try {
|
|
12432
12432
|
copyFileSync2(walPath, backupPath + "-wal");
|
|
12433
12433
|
} catch {
|
|
12434
12434
|
}
|
|
12435
12435
|
}
|
|
12436
12436
|
const shmPath = dbPath + "-shm";
|
|
12437
|
-
if (
|
|
12437
|
+
if (existsSync30(shmPath)) {
|
|
12438
12438
|
try {
|
|
12439
12439
|
copyFileSync2(shmPath, backupPath + "-shm");
|
|
12440
12440
|
} catch {
|
|
@@ -12443,7 +12443,7 @@ function createBackup(reason = "manual") {
|
|
|
12443
12443
|
return backupPath;
|
|
12444
12444
|
}
|
|
12445
12445
|
function rotateBackups(keepDays = DEFAULT_KEEP_DAYS) {
|
|
12446
|
-
if (!
|
|
12446
|
+
if (!existsSync30(BACKUP_DIR)) return 0;
|
|
12447
12447
|
const cutoff = Date.now() - keepDays * 24 * 60 * 60 * 1e3;
|
|
12448
12448
|
let deleted = 0;
|
|
12449
12449
|
try {
|
|
@@ -12465,7 +12465,7 @@ function rotateBackups(keepDays = DEFAULT_KEEP_DAYS) {
|
|
|
12465
12465
|
return deleted;
|
|
12466
12466
|
}
|
|
12467
12467
|
function listBackups() {
|
|
12468
|
-
if (!
|
|
12468
|
+
if (!existsSync30(BACKUP_DIR)) return [];
|
|
12469
12469
|
try {
|
|
12470
12470
|
const files = readdirSync12(BACKUP_DIR).filter((f) => f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm"));
|
|
12471
12471
|
return files.map((name) => {
|
|
@@ -12519,9 +12519,9 @@ __export(crdt_sync_exports, {
|
|
|
12519
12519
|
rebuildFromDb: () => rebuildFromDb
|
|
12520
12520
|
});
|
|
12521
12521
|
import * as Y from "yjs";
|
|
12522
|
-
import { readFileSync as
|
|
12522
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync19, existsSync as existsSync32, mkdirSync as mkdirSync16, unlinkSync as unlinkSync10 } from "fs";
|
|
12523
12523
|
import path39 from "path";
|
|
12524
|
-
import { homedir as
|
|
12524
|
+
import { homedir as homedir6 } from "os";
|
|
12525
12525
|
function getStatePath() {
|
|
12526
12526
|
return _statePathOverride ?? DEFAULT_STATE_PATH;
|
|
12527
12527
|
}
|
|
@@ -12532,9 +12532,9 @@ function initCrdtDoc() {
|
|
|
12532
12532
|
if (doc) return doc;
|
|
12533
12533
|
doc = new Y.Doc();
|
|
12534
12534
|
const sp = getStatePath();
|
|
12535
|
-
if (
|
|
12535
|
+
if (existsSync32(sp)) {
|
|
12536
12536
|
try {
|
|
12537
|
-
const state =
|
|
12537
|
+
const state = readFileSync26(sp);
|
|
12538
12538
|
Y.applyUpdate(doc, new Uint8Array(state));
|
|
12539
12539
|
} catch {
|
|
12540
12540
|
console.warn("[crdt-sync] WARN: corrupted state file, rebuilding from DB");
|
|
@@ -12677,7 +12677,7 @@ function persistState() {
|
|
|
12677
12677
|
try {
|
|
12678
12678
|
const sp = getStatePath();
|
|
12679
12679
|
const dir = path39.dirname(sp);
|
|
12680
|
-
if (!
|
|
12680
|
+
if (!existsSync32(dir)) mkdirSync16(dir, { recursive: true });
|
|
12681
12681
|
const state = Y.encodeStateAsUpdate(doc);
|
|
12682
12682
|
writeFileSync19(sp, Buffer.from(state));
|
|
12683
12683
|
} catch {
|
|
@@ -12720,7 +12720,7 @@ var DEFAULT_STATE_PATH, _statePathOverride, doc;
|
|
|
12720
12720
|
var init_crdt_sync = __esm({
|
|
12721
12721
|
"src/lib/crdt-sync.ts"() {
|
|
12722
12722
|
"use strict";
|
|
12723
|
-
DEFAULT_STATE_PATH = path39.join(
|
|
12723
|
+
DEFAULT_STATE_PATH = path39.join(homedir6(), ".exe-os", "crdt-state.bin");
|
|
12724
12724
|
_statePathOverride = null;
|
|
12725
12725
|
doc = null;
|
|
12726
12726
|
}
|
|
@@ -12733,7 +12733,7 @@ init_database();
|
|
|
12733
12733
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12734
12734
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12735
12735
|
import { spawn as spawn4 } from "child_process";
|
|
12736
|
-
import { existsSync as
|
|
12736
|
+
import { existsSync as existsSync35, openSync as openSync3, mkdirSync as mkdirSync18, closeSync as closeSync3, readFileSync as readFileSync29 } from "fs";
|
|
12737
12737
|
import path46 from "path";
|
|
12738
12738
|
import os19 from "os";
|
|
12739
12739
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -14033,10 +14033,10 @@ function registerCreateTask(server2) {
|
|
|
14033
14033
|
skipDispatch: true
|
|
14034
14034
|
});
|
|
14035
14035
|
try {
|
|
14036
|
-
const { existsSync:
|
|
14036
|
+
const { existsSync: existsSync36, mkdirSync: mkdirSync19, writeFileSync: writeFileSync21 } = await import("fs");
|
|
14037
14037
|
const { identityPath: identityPath2 } = await Promise.resolve().then(() => (init_identity(), identity_exports));
|
|
14038
14038
|
const idPath = identityPath2(assigned_to);
|
|
14039
|
-
if (!
|
|
14039
|
+
if (!existsSync36(idPath)) {
|
|
14040
14040
|
const { loadEmployees: loadEmployees2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
|
|
14041
14041
|
const employees = await loadEmployees2();
|
|
14042
14042
|
const emp = employees.find((e) => e.name === assigned_to);
|
|
@@ -14045,7 +14045,7 @@ function registerCreateTask(server2) {
|
|
|
14045
14045
|
const template = getTemplateForTitle2(emp.role);
|
|
14046
14046
|
if (template) {
|
|
14047
14047
|
const dir = (await import("path")).dirname(idPath);
|
|
14048
|
-
if (!
|
|
14048
|
+
if (!existsSync36(dir)) mkdirSync19(dir, { recursive: true });
|
|
14049
14049
|
writeFileSync21(idPath, template.replace(/^agent_id: \w+/m, `agent_id: ${assigned_to}`), "utf-8");
|
|
14050
14050
|
}
|
|
14051
14051
|
}
|
|
@@ -15916,6 +15916,9 @@ import { z as z39 } from "zod";
|
|
|
15916
15916
|
// src/mcp/tools/send-whatsapp.ts
|
|
15917
15917
|
init_whatsapp_accounts();
|
|
15918
15918
|
import { z as z36 } from "zod";
|
|
15919
|
+
import { existsSync as existsSync20, readFileSync as readFileSync17 } from "fs";
|
|
15920
|
+
import { homedir as homedir2 } from "os";
|
|
15921
|
+
import { join as join2 } from "path";
|
|
15919
15922
|
|
|
15920
15923
|
// src/gateway/crm-bridge.ts
|
|
15921
15924
|
var config = null;
|
|
@@ -16059,6 +16062,7 @@ init_active_agent();
|
|
|
16059
16062
|
init_plan_limits();
|
|
16060
16063
|
var GRAPH_API_VERSION = "v21.0";
|
|
16061
16064
|
var GRAPH_API_BASE = `https://graph.facebook.com/${GRAPH_API_VERSION}`;
|
|
16065
|
+
var DEFAULT_GATEWAY_SEND_URL = "http://127.0.0.1:3100/api/send";
|
|
16062
16066
|
async function lookupPhoneByName(name) {
|
|
16063
16067
|
const apiToken = process.env.CRM_API_TOKEN;
|
|
16064
16068
|
const graphqlUrl = process.env.CRM_GRAPHQL_URL || "http://localhost:3000";
|
|
@@ -16103,6 +16107,58 @@ async function lookupPhoneByName(name) {
|
|
|
16103
16107
|
return null;
|
|
16104
16108
|
}
|
|
16105
16109
|
}
|
|
16110
|
+
function normalizeGatewaySendUrl(value) {
|
|
16111
|
+
const raw = value?.trim();
|
|
16112
|
+
if (!raw) return DEFAULT_GATEWAY_SEND_URL;
|
|
16113
|
+
if (raw.endsWith("/api/send")) return raw;
|
|
16114
|
+
return `${raw.replace(/\/+$/, "")}/api/send`;
|
|
16115
|
+
}
|
|
16116
|
+
function loadGatewayJson() {
|
|
16117
|
+
const configPath = process.env.EXE_GATEWAY_CONFIG?.trim() || process.env.EXE_GATEWAY_CONFIG_PATH?.trim() || join2(homedir2(), ".exe-os", "gateway.json");
|
|
16118
|
+
if (!existsSync20(configPath)) return {};
|
|
16119
|
+
try {
|
|
16120
|
+
return JSON.parse(readFileSync17(configPath, "utf8"));
|
|
16121
|
+
} catch {
|
|
16122
|
+
return {};
|
|
16123
|
+
}
|
|
16124
|
+
}
|
|
16125
|
+
function getGatewaySendConfig() {
|
|
16126
|
+
const config2 = loadGatewayJson();
|
|
16127
|
+
const port = typeof config2.port === "number" ? config2.port : 3100;
|
|
16128
|
+
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);
|
|
16129
|
+
const url = normalizeGatewaySendUrl(configuredUrl);
|
|
16130
|
+
const configAuthToken = typeof config2.authToken === "string" ? config2.authToken : void 0;
|
|
16131
|
+
const authToken = process.env.EXE_GATEWAY_AUTH_TOKEN || configAuthToken;
|
|
16132
|
+
return { url, authToken };
|
|
16133
|
+
}
|
|
16134
|
+
async function sendWhatsAppViaGateway(to, text3, account) {
|
|
16135
|
+
const gateway = getGatewaySendConfig();
|
|
16136
|
+
const headers = { "Content-Type": "application/json" };
|
|
16137
|
+
if (gateway.authToken) headers.Authorization = `Bearer ${gateway.authToken}`;
|
|
16138
|
+
const res = await fetch(gateway.url, {
|
|
16139
|
+
method: "POST",
|
|
16140
|
+
headers,
|
|
16141
|
+
body: JSON.stringify({
|
|
16142
|
+
platform: "whatsapp",
|
|
16143
|
+
...account ? { account } : {},
|
|
16144
|
+
to,
|
|
16145
|
+
text: text3
|
|
16146
|
+
}),
|
|
16147
|
+
signal: AbortSignal.timeout(3e4)
|
|
16148
|
+
});
|
|
16149
|
+
const bodyText = await res.text();
|
|
16150
|
+
let body = {};
|
|
16151
|
+
try {
|
|
16152
|
+
body = bodyText ? JSON.parse(bodyText) : {};
|
|
16153
|
+
} catch {
|
|
16154
|
+
body = { error: bodyText };
|
|
16155
|
+
}
|
|
16156
|
+
if (!res.ok || body.sent === false) {
|
|
16157
|
+
const reason = typeof body.error === "string" ? body.error : `HTTP ${res.status}`;
|
|
16158
|
+
throw new Error(`Gateway send failed (${res.status}): ${reason}`);
|
|
16159
|
+
}
|
|
16160
|
+
return { account: typeof body.account === "string" ? body.account : account ?? "default" };
|
|
16161
|
+
}
|
|
16106
16162
|
async function sendWhatsAppMessage(phoneNumberId, accessToken, to, text3) {
|
|
16107
16163
|
const url = `${GRAPH_API_BASE}/${phoneNumberId}/messages`;
|
|
16108
16164
|
const res = await fetch(url, {
|
|
@@ -16154,17 +16210,7 @@ function registerSendWhatsapp(server2) {
|
|
|
16154
16210
|
}
|
|
16155
16211
|
const { agentId } = getActiveAgent();
|
|
16156
16212
|
const waAccount = accountName ? getAccountByName(accountName) : getDefaultAccount();
|
|
16157
|
-
|
|
16158
|
-
const hint = accountName ? `Account "${accountName}" not found.` : "No WhatsApp accounts configured.";
|
|
16159
|
-
return {
|
|
16160
|
-
content: [
|
|
16161
|
-
{
|
|
16162
|
-
type: "text",
|
|
16163
|
-
text: `Failed: ${hint} Check ~/.exe-os/whatsapp-accounts.json`
|
|
16164
|
-
}
|
|
16165
|
-
]
|
|
16166
|
-
};
|
|
16167
|
-
}
|
|
16213
|
+
const useMetaBusinessApi = Boolean(waAccount);
|
|
16168
16214
|
const results = [];
|
|
16169
16215
|
for (const recipient of recipients) {
|
|
16170
16216
|
let phone;
|
|
@@ -16186,12 +16232,12 @@ function registerSendWhatsapp(server2) {
|
|
|
16186
16232
|
phone = looked;
|
|
16187
16233
|
}
|
|
16188
16234
|
try {
|
|
16189
|
-
await sendWhatsAppMessage(
|
|
16235
|
+
const sentAccount = useMetaBusinessApi && waAccount ? (await sendWhatsAppMessage(
|
|
16190
16236
|
waAccount.phoneNumberId,
|
|
16191
16237
|
waAccount.accessToken,
|
|
16192
16238
|
phone,
|
|
16193
16239
|
message
|
|
16194
|
-
);
|
|
16240
|
+
), waAccount.name) : (await sendWhatsAppViaGateway(phone, message, accountName)).account;
|
|
16195
16241
|
pushConversationToCRM({
|
|
16196
16242
|
platform: "whatsapp",
|
|
16197
16243
|
senderId: phone,
|
|
@@ -16200,13 +16246,13 @@ function registerSendWhatsapp(server2) {
|
|
|
16200
16246
|
agentResponse: message,
|
|
16201
16247
|
agentName: agentId,
|
|
16202
16248
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16203
|
-
accountId:
|
|
16249
|
+
accountId: sentAccount
|
|
16204
16250
|
}).catch(() => {
|
|
16205
16251
|
});
|
|
16206
16252
|
results.push({ recipient, phone, ok: true });
|
|
16207
16253
|
} catch (err) {
|
|
16208
16254
|
const raw = err instanceof Error ? err.message : String(err);
|
|
16209
|
-
const friendly = raw.includes("HTTP") ? raw : `Message delivery failed. Check WhatsApp configuration.`;
|
|
16255
|
+
const friendly = raw.includes("HTTP") || raw.includes("Gateway send failed") ? raw : `Message delivery failed. Check WhatsApp configuration.`;
|
|
16210
16256
|
results.push({
|
|
16211
16257
|
recipient,
|
|
16212
16258
|
phone,
|
|
@@ -16218,7 +16264,8 @@ function registerSendWhatsapp(server2) {
|
|
|
16218
16264
|
const sent = results.filter((r) => r.ok).length;
|
|
16219
16265
|
const failed = results.filter((r) => !r.ok);
|
|
16220
16266
|
const failedDetail = failed.map((f) => `${f.recipient}: ${f.error}`).join("; ");
|
|
16221
|
-
const
|
|
16267
|
+
const transport = useMetaBusinessApi && waAccount ? `Meta Business API/${waAccount.name}` : `exe-gateway/${accountName ?? "default"}`;
|
|
16268
|
+
const summary = failed.length === 0 ? `Sent ${sent}/${recipients.length} messages via ${transport}.` : `Sent ${sent}/${recipients.length} messages via ${transport}. Failed: ${failedDetail}`;
|
|
16222
16269
|
return {
|
|
16223
16270
|
content: [{ type: "text", text: summary }]
|
|
16224
16271
|
};
|
|
@@ -16543,15 +16590,15 @@ function registerGateway(server2) {
|
|
|
16543
16590
|
import { z as z40 } from "zod";
|
|
16544
16591
|
|
|
16545
16592
|
// src/automation/trigger-engine.ts
|
|
16546
|
-
import { readFileSync as
|
|
16593
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync13, existsSync as existsSync21, mkdirSync as mkdirSync10 } from "fs";
|
|
16547
16594
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
16548
16595
|
import path26 from "path";
|
|
16549
16596
|
import os12 from "os";
|
|
16550
16597
|
var TRIGGERS_PATH = path26.join(os12.homedir(), ".exe-os", "triggers.json");
|
|
16551
16598
|
function loadTriggers(project) {
|
|
16552
|
-
if (!
|
|
16599
|
+
if (!existsSync21(TRIGGERS_PATH)) return [];
|
|
16553
16600
|
try {
|
|
16554
|
-
const raw =
|
|
16601
|
+
const raw = readFileSync18(TRIGGERS_PATH, "utf-8");
|
|
16555
16602
|
const all = JSON.parse(raw);
|
|
16556
16603
|
if (!Array.isArray(all)) return [];
|
|
16557
16604
|
if (project) {
|
|
@@ -16564,7 +16611,7 @@ function loadTriggers(project) {
|
|
|
16564
16611
|
}
|
|
16565
16612
|
function saveTriggers(triggers) {
|
|
16566
16613
|
const dir = path26.dirname(TRIGGERS_PATH);
|
|
16567
|
-
if (!
|
|
16614
|
+
if (!existsSync21(dir)) mkdirSync10(dir, { recursive: true });
|
|
16568
16615
|
writeFileSync13(TRIGGERS_PATH, JSON.stringify(triggers, null, 2), "utf-8");
|
|
16569
16616
|
}
|
|
16570
16617
|
function createNewTrigger(input) {
|
|
@@ -16869,15 +16916,15 @@ function registerListTriggers(server2) {
|
|
|
16869
16916
|
import { z as z42 } from "zod";
|
|
16870
16917
|
|
|
16871
16918
|
// src/automation/starter-packs/index.ts
|
|
16872
|
-
import { readFileSync as
|
|
16919
|
+
import { readFileSync as readFileSync19, readdirSync as readdirSync8, existsSync as existsSync22 } from "fs";
|
|
16873
16920
|
import path27 from "path";
|
|
16874
16921
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
16875
16922
|
var __dirname = path27.dirname(fileURLToPath3(import.meta.url));
|
|
16876
16923
|
function listPacks() {
|
|
16877
16924
|
const packsDir = path27.join(__dirname, ".");
|
|
16878
|
-
if (!
|
|
16925
|
+
if (!existsSync22(packsDir)) return [];
|
|
16879
16926
|
return readdirSync8(packsDir, { withFileTypes: true }).filter(
|
|
16880
|
-
(d) => d.isDirectory() &&
|
|
16927
|
+
(d) => d.isDirectory() && existsSync22(path27.join(packsDir, d.name, "custom-objects.json"))
|
|
16881
16928
|
).map((d) => d.name);
|
|
16882
16929
|
}
|
|
16883
16930
|
function loadPack(industry) {
|
|
@@ -16887,30 +16934,30 @@ function loadPack(industry) {
|
|
|
16887
16934
|
const wikiDir = path27.join(packDir, "wiki-seeds");
|
|
16888
16935
|
const manifestPath = path27.join(packDir, "pack.json");
|
|
16889
16936
|
const identityContextPath = path27.join(packDir, "identity-context.md");
|
|
16890
|
-
if (!
|
|
16937
|
+
if (!existsSync22(objectsPath)) return null;
|
|
16891
16938
|
let customObjects = [];
|
|
16892
16939
|
try {
|
|
16893
16940
|
customObjects = JSON.parse(
|
|
16894
|
-
|
|
16941
|
+
readFileSync19(objectsPath, "utf-8")
|
|
16895
16942
|
);
|
|
16896
16943
|
} catch {
|
|
16897
16944
|
customObjects = [];
|
|
16898
16945
|
}
|
|
16899
16946
|
let triggers = [];
|
|
16900
|
-
if (
|
|
16947
|
+
if (existsSync22(triggersPath)) {
|
|
16901
16948
|
try {
|
|
16902
16949
|
triggers = JSON.parse(
|
|
16903
|
-
|
|
16950
|
+
readFileSync19(triggersPath, "utf-8")
|
|
16904
16951
|
);
|
|
16905
16952
|
} catch {
|
|
16906
16953
|
triggers = [];
|
|
16907
16954
|
}
|
|
16908
16955
|
}
|
|
16909
16956
|
const wikiSeeds = [];
|
|
16910
|
-
if (
|
|
16957
|
+
if (existsSync22(wikiDir)) {
|
|
16911
16958
|
const files = readdirSync8(wikiDir).filter((f) => f.endsWith(".md"));
|
|
16912
16959
|
for (const file of files) {
|
|
16913
|
-
const content =
|
|
16960
|
+
const content = readFileSync19(path27.join(wikiDir, file), "utf-8");
|
|
16914
16961
|
const titleMatch = content.match(/^#\s+(.+)/m);
|
|
16915
16962
|
wikiSeeds.push({
|
|
16916
16963
|
filename: file,
|
|
@@ -16920,17 +16967,17 @@ function loadPack(industry) {
|
|
|
16920
16967
|
}
|
|
16921
16968
|
}
|
|
16922
16969
|
let manifest = {};
|
|
16923
|
-
if (
|
|
16970
|
+
if (existsSync22(manifestPath)) {
|
|
16924
16971
|
try {
|
|
16925
|
-
manifest = JSON.parse(
|
|
16972
|
+
manifest = JSON.parse(readFileSync19(manifestPath, "utf-8"));
|
|
16926
16973
|
} catch {
|
|
16927
16974
|
manifest = {};
|
|
16928
16975
|
}
|
|
16929
16976
|
}
|
|
16930
16977
|
let identityContext = null;
|
|
16931
|
-
if (
|
|
16978
|
+
if (existsSync22(identityContextPath)) {
|
|
16932
16979
|
try {
|
|
16933
|
-
identityContext =
|
|
16980
|
+
identityContext = readFileSync19(identityContextPath, "utf-8");
|
|
16934
16981
|
} catch {
|
|
16935
16982
|
identityContext = null;
|
|
16936
16983
|
}
|
|
@@ -16987,7 +17034,7 @@ function applyPack(industry, project) {
|
|
|
16987
17034
|
|
|
16988
17035
|
// src/lib/client-coo.ts
|
|
16989
17036
|
init_config();
|
|
16990
|
-
import { existsSync as
|
|
17037
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync11, writeFileSync as writeFileSync14 } from "fs";
|
|
16991
17038
|
import path28 from "path";
|
|
16992
17039
|
|
|
16993
17040
|
// src/lib/employee-templates.ts
|
|
@@ -17132,11 +17179,11 @@ async function provisionClientCOO(vars, opts = {}) {
|
|
|
17132
17179
|
const rosterPath = opts.employeesPath ?? EMPLOYEES_PATH;
|
|
17133
17180
|
const storeFeedbackBehavior = opts.storeFeedbackBehavior ?? true;
|
|
17134
17181
|
const identityPath2 = path28.join(identityDir, `${vars.agent_name}.md`);
|
|
17135
|
-
if (
|
|
17182
|
+
if (existsSync23(identityPath2)) {
|
|
17136
17183
|
throw new ClientCOOClobberError(vars.agent_name, identityPath2);
|
|
17137
17184
|
}
|
|
17138
17185
|
const body = renderClientCOOTemplate(vars);
|
|
17139
|
-
if (!
|
|
17186
|
+
if (!existsSync23(identityDir)) {
|
|
17140
17187
|
mkdirSync11(identityDir, { recursive: true });
|
|
17141
17188
|
}
|
|
17142
17189
|
writeFileSync14(identityPath2, body, "utf-8");
|
|
@@ -17797,7 +17844,7 @@ import { z as z47 } from "zod";
|
|
|
17797
17844
|
import { execFile } from "child_process";
|
|
17798
17845
|
import { promisify } from "util";
|
|
17799
17846
|
import path29 from "path";
|
|
17800
|
-
import { existsSync as
|
|
17847
|
+
import { existsSync as existsSync24 } from "fs";
|
|
17801
17848
|
|
|
17802
17849
|
// src/lib/hostinger-api.ts
|
|
17803
17850
|
var DEFAULT_BASE_URL = "https://developers.hostinger.com/api/vps/v1";
|
|
@@ -18155,7 +18202,7 @@ async function runAnsiblePlaybook(vpsIp, domain, sslEmail, clientName) {
|
|
|
18155
18202
|
"-e",
|
|
18156
18203
|
`client_name=${safeClientName}`
|
|
18157
18204
|
];
|
|
18158
|
-
if (
|
|
18205
|
+
if (existsSync24(clientVarsPath)) {
|
|
18159
18206
|
args.push("-e", `@${clientVarsPath}`);
|
|
18160
18207
|
}
|
|
18161
18208
|
try {
|
|
@@ -18237,7 +18284,7 @@ init_database();
|
|
|
18237
18284
|
init_identity();
|
|
18238
18285
|
init_platform_procedures();
|
|
18239
18286
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
18240
|
-
import { copyFileSync, existsSync as
|
|
18287
|
+
import { copyFileSync, existsSync as existsSync25, mkdirSync as mkdirSync12, readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "fs";
|
|
18241
18288
|
import os13 from "os";
|
|
18242
18289
|
import path30 from "path";
|
|
18243
18290
|
var PACKAGE_VERSION = "1.0";
|
|
@@ -18312,8 +18359,8 @@ function getBackupPath() {
|
|
|
18312
18359
|
}
|
|
18313
18360
|
function readRosterFile() {
|
|
18314
18361
|
const rosterPath = getRosterPath();
|
|
18315
|
-
if (!
|
|
18316
|
-
const raw =
|
|
18362
|
+
if (!existsSync25(rosterPath)) return [];
|
|
18363
|
+
const raw = readFileSync20(rosterPath, "utf-8");
|
|
18317
18364
|
const parsed = JSON.parse(raw);
|
|
18318
18365
|
if (!Array.isArray(parsed)) {
|
|
18319
18366
|
throw new Error("Roster file must contain a JSON array");
|
|
@@ -18326,7 +18373,7 @@ function writeRosterFile(roster) {
|
|
|
18326
18373
|
}
|
|
18327
18374
|
const rosterPath = getRosterPath();
|
|
18328
18375
|
mkdirSync12(path30.dirname(rosterPath), { recursive: true });
|
|
18329
|
-
if (
|
|
18376
|
+
if (existsSync25(rosterPath)) {
|
|
18330
18377
|
const currentRoster = readRosterFile();
|
|
18331
18378
|
if (roster.length < currentRoster.length) {
|
|
18332
18379
|
throw new Error(
|
|
@@ -18620,7 +18667,7 @@ function registerExportOrchestration(server2) {
|
|
|
18620
18667
|
}
|
|
18621
18668
|
|
|
18622
18669
|
// src/mcp/tools/import-orchestration.ts
|
|
18623
|
-
import { readFileSync as
|
|
18670
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
18624
18671
|
import { z as z49 } from "zod";
|
|
18625
18672
|
init_store();
|
|
18626
18673
|
init_active_agent();
|
|
@@ -18650,7 +18697,7 @@ function registerImportOrchestration(server2) {
|
|
|
18650
18697
|
};
|
|
18651
18698
|
}
|
|
18652
18699
|
await initStore();
|
|
18653
|
-
const raw =
|
|
18700
|
+
const raw = readFileSync21(package_path, "utf-8");
|
|
18654
18701
|
const pkg = validatePackage(JSON.parse(raw));
|
|
18655
18702
|
const result = await importOrchestration(pkg, merge_strategy);
|
|
18656
18703
|
return {
|
|
@@ -18674,10 +18721,10 @@ function registerImportOrchestration(server2) {
|
|
|
18674
18721
|
|
|
18675
18722
|
// src/mcp/tools/load-skill.ts
|
|
18676
18723
|
import { z as z50 } from "zod";
|
|
18677
|
-
import { readFileSync as
|
|
18724
|
+
import { readFileSync as readFileSync22, readdirSync as readdirSync9, statSync as statSync4 } from "fs";
|
|
18678
18725
|
import path32 from "path";
|
|
18679
|
-
import { homedir as
|
|
18680
|
-
var SKILLS_DIR = path32.join(
|
|
18726
|
+
import { homedir as homedir3 } from "os";
|
|
18727
|
+
var SKILLS_DIR = path32.join(homedir3(), ".claude", "skills");
|
|
18681
18728
|
function listAvailableSkills() {
|
|
18682
18729
|
try {
|
|
18683
18730
|
const entries = readdirSync9(SKILLS_DIR);
|
|
@@ -18731,7 +18778,7 @@ ${skills.map((s) => `- ${s}`).join("\n")}`
|
|
|
18731
18778
|
const sanitized = path32.basename(skill_name);
|
|
18732
18779
|
const skillFile = path32.join(SKILLS_DIR, sanitized, "SKILL.md");
|
|
18733
18780
|
try {
|
|
18734
|
-
const content =
|
|
18781
|
+
const content = readFileSync22(skillFile, "utf-8");
|
|
18735
18782
|
return {
|
|
18736
18783
|
content: [{
|
|
18737
18784
|
type: "text",
|
|
@@ -20353,10 +20400,10 @@ function registerListAgentSessions(server2) {
|
|
|
20353
20400
|
|
|
20354
20401
|
// src/mcp/tools/get-daemon-health.ts
|
|
20355
20402
|
import { z as z66 } from "zod";
|
|
20356
|
-
import { existsSync as
|
|
20403
|
+
import { existsSync as existsSync26, readFileSync as readFileSync23 } from "fs";
|
|
20357
20404
|
import path34 from "path";
|
|
20358
|
-
import { homedir as
|
|
20359
|
-
var PID_PATH2 = path34.join(
|
|
20405
|
+
import { homedir as homedir4 } from "os";
|
|
20406
|
+
var PID_PATH2 = path34.join(homedir4(), ".exe-os", "exed.pid");
|
|
20360
20407
|
function formatUptime(seconds) {
|
|
20361
20408
|
const h = Math.floor(seconds / 3600);
|
|
20362
20409
|
const m = Math.floor(seconds % 3600 / 60);
|
|
@@ -20367,8 +20414,8 @@ function formatUptime(seconds) {
|
|
|
20367
20414
|
}
|
|
20368
20415
|
function isDaemonAlive() {
|
|
20369
20416
|
try {
|
|
20370
|
-
if (!
|
|
20371
|
-
const pid = parseInt(
|
|
20417
|
+
if (!existsSync26(PID_PATH2)) return { alive: false, pid: null };
|
|
20418
|
+
const pid = parseInt(readFileSync23(PID_PATH2, "utf8").trim(), 10);
|
|
20372
20419
|
if (isNaN(pid) || pid <= 0) return { alive: false, pid: null };
|
|
20373
20420
|
process.kill(pid, 0);
|
|
20374
20421
|
return { alive: true, pid };
|
|
@@ -20442,14 +20489,14 @@ init_tmux_routing();
|
|
|
20442
20489
|
init_task_scope();
|
|
20443
20490
|
init_employees();
|
|
20444
20491
|
import { execSync as execSync11 } from "child_process";
|
|
20445
|
-
import { existsSync as
|
|
20446
|
-
import { homedir as
|
|
20447
|
-
import { join as
|
|
20492
|
+
import { existsSync as existsSync27, readFileSync as readFileSync24, writeFileSync as writeFileSync17 } from "fs";
|
|
20493
|
+
import { homedir as homedir5 } from "os";
|
|
20494
|
+
import { join as join3 } from "path";
|
|
20448
20495
|
var IDLE_NUDGE_DEDUP_MS = Number(process.env.EXE_NUDGE_INTERVAL_MS) || 6e4;
|
|
20449
20496
|
var SESSION_TTL_HOURS = Number(process.env.EXE_SESSION_TTL_HOURS) || 4;
|
|
20450
20497
|
var SESSION_CONTEXT_THRESHOLD_PCT = Number(process.env.EXE_CONTEXT_KILL_PCT) || 50;
|
|
20451
20498
|
var IDLE_KILL_INTERCOM_ACK_WINDOW_MS = Number(process.env.EXE_INTERCOM_ACK_WINDOW_MS) || 1e4;
|
|
20452
|
-
var NUDGE_STATE_PATH =
|
|
20499
|
+
var NUDGE_STATE_PATH = join3(homedir5(), ".exe-os", "review-nudge-state.json");
|
|
20453
20500
|
var AUTO_WAKE_COOLDOWN_MS = 5 * 60 * 1e3;
|
|
20454
20501
|
var AUTO_WAKE_MAX_RETRIES = 3;
|
|
20455
20502
|
|
|
@@ -20545,7 +20592,7 @@ function registerGetAutoWakeStatus(server2) {
|
|
|
20545
20592
|
init_worker_gate();
|
|
20546
20593
|
init_config();
|
|
20547
20594
|
import { z as z68 } from "zod";
|
|
20548
|
-
import { readdirSync as readdirSync11, existsSync as
|
|
20595
|
+
import { readdirSync as readdirSync11, existsSync as existsSync29 } from "fs";
|
|
20549
20596
|
import path36 from "path";
|
|
20550
20597
|
var WORKER_PID_DIR2 = path36.join(EXE_AI_DIR, "worker-pids");
|
|
20551
20598
|
function countAliveWorkers() {
|
|
@@ -20553,7 +20600,7 @@ function countAliveWorkers() {
|
|
|
20553
20600
|
let stale = 0;
|
|
20554
20601
|
let reservations = 0;
|
|
20555
20602
|
try {
|
|
20556
|
-
if (!
|
|
20603
|
+
if (!existsSync29(WORKER_PID_DIR2)) return { alive: 0, stale: 0, reservations: 0 };
|
|
20557
20604
|
const files = readdirSync11(WORKER_PID_DIR2);
|
|
20558
20605
|
for (const f of files) {
|
|
20559
20606
|
if (!f.endsWith(".pid")) continue;
|
|
@@ -20641,7 +20688,7 @@ function isMainModule(importMetaUrl) {
|
|
|
20641
20688
|
}
|
|
20642
20689
|
|
|
20643
20690
|
// src/bin/exe-doctor.ts
|
|
20644
|
-
import { existsSync as
|
|
20691
|
+
import { existsSync as existsSync31, readFileSync as readFileSync25 } from "fs";
|
|
20645
20692
|
import { spawn as spawn2 } from "child_process";
|
|
20646
20693
|
import path38 from "path";
|
|
20647
20694
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
@@ -21057,7 +21104,7 @@ async function auditOrphanedProjects(client) {
|
|
|
21057
21104
|
for (const row of result.rows) {
|
|
21058
21105
|
const name = row.project_name;
|
|
21059
21106
|
const count = Number(row.cnt);
|
|
21060
|
-
const exists =
|
|
21107
|
+
const exists = existsSync31(path38.join(home, name)) || existsSync31(path38.join(home, "..", name)) || existsSync31(path38.join(process.cwd(), "..", name));
|
|
21061
21108
|
if (!exists) {
|
|
21062
21109
|
orphans.push({ project_name: name, count });
|
|
21063
21110
|
}
|
|
@@ -21071,12 +21118,12 @@ function auditHookHealth() {
|
|
|
21071
21118
|
"logs",
|
|
21072
21119
|
"hooks.log"
|
|
21073
21120
|
);
|
|
21074
|
-
if (!
|
|
21121
|
+
if (!existsSync31(logPath)) {
|
|
21075
21122
|
return { logExists: false, totalLines: 0, errorsLastHour: 0, topPatterns: [] };
|
|
21076
21123
|
}
|
|
21077
21124
|
let content;
|
|
21078
21125
|
try {
|
|
21079
|
-
content =
|
|
21126
|
+
content = readFileSync25(logPath, "utf-8");
|
|
21080
21127
|
} catch {
|
|
21081
21128
|
return { logExists: false, totalLines: 0, errorsLastHour: 0, topPatterns: [] };
|
|
21082
21129
|
}
|
|
@@ -21498,10 +21545,10 @@ import { z as z70 } from "zod";
|
|
|
21498
21545
|
|
|
21499
21546
|
// src/lib/cloud-sync.ts
|
|
21500
21547
|
init_database();
|
|
21501
|
-
import { readFileSync as
|
|
21548
|
+
import { readFileSync as readFileSync27, writeFileSync as writeFileSync20, existsSync as existsSync33, readdirSync as readdirSync13, mkdirSync as mkdirSync17, appendFileSync as appendFileSync2, unlinkSync as unlinkSync11, openSync as openSync2, closeSync as closeSync2, statSync as statSync6 } from "fs";
|
|
21502
21549
|
import crypto17 from "crypto";
|
|
21503
21550
|
import path40 from "path";
|
|
21504
|
-
import { homedir as
|
|
21551
|
+
import { homedir as homedir7 } from "os";
|
|
21505
21552
|
|
|
21506
21553
|
// src/lib/crypto.ts
|
|
21507
21554
|
import crypto16 from "crypto";
|
|
@@ -21575,7 +21622,7 @@ function sqlSafe(v) {
|
|
|
21575
21622
|
}
|
|
21576
21623
|
function logError(msg) {
|
|
21577
21624
|
try {
|
|
21578
|
-
const logPath = path40.join(
|
|
21625
|
+
const logPath = path40.join(homedir7(), ".exe-os", "workers.log");
|
|
21579
21626
|
appendFileSync2(logPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
21580
21627
|
`);
|
|
21581
21628
|
} catch {
|
|
@@ -21594,8 +21641,8 @@ function loadPgClient() {
|
|
|
21594
21641
|
const configPath = path40.join(EXE_AI_DIR, "config.json");
|
|
21595
21642
|
let cloudPostgresUrl;
|
|
21596
21643
|
try {
|
|
21597
|
-
if (
|
|
21598
|
-
const cfg = JSON.parse(
|
|
21644
|
+
if (existsSync33(configPath)) {
|
|
21645
|
+
const cfg = JSON.parse(readFileSync27(configPath, "utf8"));
|
|
21599
21646
|
cloudPostgresUrl = cfg.cloud?.postgresUrl;
|
|
21600
21647
|
if (cfg.cloud?.syncToPostgres === false) {
|
|
21601
21648
|
_pgFailed = true;
|
|
@@ -21613,7 +21660,7 @@ function loadPgClient() {
|
|
|
21613
21660
|
_pgPromise = (async () => {
|
|
21614
21661
|
const { createRequire: createRequire6 } = await import("module");
|
|
21615
21662
|
const { pathToFileURL: pathToFileURL6 } = await import("url");
|
|
21616
|
-
const exeDbRoot = process.env.EXE_DB_ROOT ?? path40.join(
|
|
21663
|
+
const exeDbRoot = process.env.EXE_DB_ROOT ?? path40.join(homedir7(), "exe-db");
|
|
21617
21664
|
const req = createRequire6(path40.join(exeDbRoot, "package.json"));
|
|
21618
21665
|
const entry = req.resolve("@prisma/client");
|
|
21619
21666
|
const mod = await import(pathToFileURL6(entry).href);
|
|
@@ -21663,7 +21710,7 @@ async function withRosterLock(fn) {
|
|
|
21663
21710
|
} catch (err) {
|
|
21664
21711
|
if (err.code === "EEXIST") {
|
|
21665
21712
|
try {
|
|
21666
|
-
const ts2 = parseInt(
|
|
21713
|
+
const ts2 = parseInt(readFileSync27(ROSTER_LOCK_PATH, "utf-8"), 10);
|
|
21667
21714
|
if (Date.now() - ts2 < LOCK_STALE_MS) {
|
|
21668
21715
|
throw new Error("Roster merge already in progress \u2014 another sync is running");
|
|
21669
21716
|
}
|
|
@@ -22055,7 +22102,7 @@ async function cloudSync(config2) {
|
|
|
22055
22102
|
const employees = await loadEmployees();
|
|
22056
22103
|
rosterResult.employees = employees.length;
|
|
22057
22104
|
const idDir = path40.join(EXE_AI_DIR, "identity");
|
|
22058
|
-
if (
|
|
22105
|
+
if (existsSync33(idDir)) {
|
|
22059
22106
|
rosterResult.identities = readdirSync13(idDir).filter((f) => f.endsWith(".md")).length;
|
|
22060
22107
|
}
|
|
22061
22108
|
} catch {
|
|
@@ -22068,7 +22115,7 @@ async function cloudSync(config2) {
|
|
|
22068
22115
|
const backupSize = statSync6(latestBackup).size;
|
|
22069
22116
|
const MAX_CLOUD_BACKUP_BYTES = 50 * 1024 * 1024;
|
|
22070
22117
|
if (backupSize <= MAX_CLOUD_BACKUP_BYTES) {
|
|
22071
|
-
const backupData =
|
|
22118
|
+
const backupData = readFileSync27(latestBackup);
|
|
22072
22119
|
const deviceId = loadDeviceId() ?? "unknown";
|
|
22073
22120
|
const encrypted = encryptSyncBlob(backupData);
|
|
22074
22121
|
const backupRes = await fetchWithRetry(`${config2.endpoint}/sync/push-db-backup`, {
|
|
@@ -22104,8 +22151,8 @@ async function cloudSync(config2) {
|
|
|
22104
22151
|
var ROSTER_DELETIONS_PATH = path40.join(EXE_AI_DIR, "roster-deletions.json");
|
|
22105
22152
|
function consumeRosterDeletions() {
|
|
22106
22153
|
try {
|
|
22107
|
-
if (!
|
|
22108
|
-
const deletions = JSON.parse(
|
|
22154
|
+
if (!existsSync33(ROSTER_DELETIONS_PATH)) return [];
|
|
22155
|
+
const deletions = JSON.parse(readFileSync27(ROSTER_DELETIONS_PATH, "utf-8"));
|
|
22109
22156
|
writeFileSync20(ROSTER_DELETIONS_PATH, "[]");
|
|
22110
22157
|
return deletions;
|
|
22111
22158
|
} catch {
|
|
@@ -22117,33 +22164,33 @@ function buildRosterBlob(paths) {
|
|
|
22117
22164
|
const identityDir = paths?.identityDir ?? path40.join(EXE_AI_DIR, "identity");
|
|
22118
22165
|
const configPath = paths?.configPath ?? path40.join(EXE_AI_DIR, "config.json");
|
|
22119
22166
|
let roster = [];
|
|
22120
|
-
if (
|
|
22167
|
+
if (existsSync33(rosterPath)) {
|
|
22121
22168
|
try {
|
|
22122
|
-
roster = JSON.parse(
|
|
22169
|
+
roster = JSON.parse(readFileSync27(rosterPath, "utf-8"));
|
|
22123
22170
|
} catch {
|
|
22124
22171
|
}
|
|
22125
22172
|
}
|
|
22126
22173
|
const identities = {};
|
|
22127
|
-
if (
|
|
22174
|
+
if (existsSync33(identityDir)) {
|
|
22128
22175
|
for (const file of readdirSync13(identityDir).filter((f) => f.endsWith(".md"))) {
|
|
22129
22176
|
try {
|
|
22130
|
-
identities[file] =
|
|
22177
|
+
identities[file] = readFileSync27(path40.join(identityDir, file), "utf-8");
|
|
22131
22178
|
} catch {
|
|
22132
22179
|
}
|
|
22133
22180
|
}
|
|
22134
22181
|
}
|
|
22135
22182
|
let config2;
|
|
22136
|
-
if (
|
|
22183
|
+
if (existsSync33(configPath)) {
|
|
22137
22184
|
try {
|
|
22138
|
-
config2 = JSON.parse(
|
|
22185
|
+
config2 = JSON.parse(readFileSync27(configPath, "utf-8"));
|
|
22139
22186
|
} catch {
|
|
22140
22187
|
}
|
|
22141
22188
|
}
|
|
22142
22189
|
let agentConfig;
|
|
22143
22190
|
const agentConfigPath = path40.join(EXE_AI_DIR, "agent-config.json");
|
|
22144
|
-
if (
|
|
22191
|
+
if (existsSync33(agentConfigPath)) {
|
|
22145
22192
|
try {
|
|
22146
|
-
agentConfig = JSON.parse(
|
|
22193
|
+
agentConfig = JSON.parse(readFileSync27(agentConfigPath, "utf-8"));
|
|
22147
22194
|
} catch {
|
|
22148
22195
|
}
|
|
22149
22196
|
}
|
|
@@ -22221,9 +22268,9 @@ async function cloudPullRoster(config2) {
|
|
|
22221
22268
|
function mergeConfig(remoteConfig, configPath) {
|
|
22222
22269
|
const cfgPath = configPath ?? path40.join(EXE_AI_DIR, "config.json");
|
|
22223
22270
|
let local = {};
|
|
22224
|
-
if (
|
|
22271
|
+
if (existsSync33(cfgPath)) {
|
|
22225
22272
|
try {
|
|
22226
|
-
local = JSON.parse(
|
|
22273
|
+
local = JSON.parse(readFileSync27(cfgPath, "utf-8"));
|
|
22227
22274
|
} catch {
|
|
22228
22275
|
}
|
|
22229
22276
|
}
|
|
@@ -22257,11 +22304,11 @@ async function mergeRosterFromRemote(remote, paths) {
|
|
|
22257
22304
|
) ?? lookupKey;
|
|
22258
22305
|
const remoteIdentity = remote.identities[matchedKey];
|
|
22259
22306
|
if (remoteIdentity) {
|
|
22260
|
-
if (!
|
|
22307
|
+
if (!existsSync33(identityDir)) mkdirSync17(identityDir, { recursive: true });
|
|
22261
22308
|
const idPath = path40.join(identityDir, `${remoteEmp.name}.md`);
|
|
22262
22309
|
let localIdentity = null;
|
|
22263
22310
|
try {
|
|
22264
|
-
localIdentity =
|
|
22311
|
+
localIdentity = existsSync33(idPath) ? readFileSync27(idPath, "utf-8") : null;
|
|
22265
22312
|
} catch {
|
|
22266
22313
|
}
|
|
22267
22314
|
if (localIdentity !== remoteIdentity) {
|
|
@@ -22293,9 +22340,9 @@ async function mergeRosterFromRemote(remote, paths) {
|
|
|
22293
22340
|
try {
|
|
22294
22341
|
const agentConfigPath = path40.join(EXE_AI_DIR, "agent-config.json");
|
|
22295
22342
|
let local = {};
|
|
22296
|
-
if (
|
|
22343
|
+
if (existsSync33(agentConfigPath)) {
|
|
22297
22344
|
try {
|
|
22298
|
-
local = JSON.parse(
|
|
22345
|
+
local = JSON.parse(readFileSync27(agentConfigPath, "utf-8"));
|
|
22299
22346
|
} catch {
|
|
22300
22347
|
}
|
|
22301
22348
|
}
|
|
@@ -23439,11 +23486,11 @@ import { z as z74 } from "zod";
|
|
|
23439
23486
|
// src/lib/people.ts
|
|
23440
23487
|
init_config();
|
|
23441
23488
|
import { readFile as readFile5, writeFile as writeFile6, mkdir as mkdir5 } from "fs/promises";
|
|
23442
|
-
import { existsSync as
|
|
23489
|
+
import { existsSync as existsSync34, readFileSync as readFileSync28 } from "fs";
|
|
23443
23490
|
import path41 from "path";
|
|
23444
23491
|
var PEOPLE_PATH = path41.join(EXE_AI_DIR, "people.json");
|
|
23445
23492
|
async function loadPeople() {
|
|
23446
|
-
if (!
|
|
23493
|
+
if (!existsSync34(PEOPLE_PATH)) return [];
|
|
23447
23494
|
try {
|
|
23448
23495
|
const raw = await readFile5(PEOPLE_PATH, "utf-8");
|
|
23449
23496
|
return JSON.parse(raw);
|
|
@@ -24908,13 +24955,13 @@ try {
|
|
|
24908
24955
|
const MCP_VERSION_PATH = path46.join(os19.homedir(), ".exe-os", "mcp-version");
|
|
24909
24956
|
let _currentMcpVersion = null;
|
|
24910
24957
|
try {
|
|
24911
|
-
_currentMcpVersion =
|
|
24958
|
+
_currentMcpVersion = existsSync35(MCP_VERSION_PATH) ? readFileSync29(MCP_VERSION_PATH, "utf8").trim() : null;
|
|
24912
24959
|
} catch {
|
|
24913
24960
|
}
|
|
24914
24961
|
const _versionWatchdog = setInterval(() => {
|
|
24915
24962
|
try {
|
|
24916
|
-
if (!
|
|
24917
|
-
const diskVersion =
|
|
24963
|
+
if (!existsSync35(MCP_VERSION_PATH)) return;
|
|
24964
|
+
const diskVersion = readFileSync29(MCP_VERSION_PATH, "utf8").trim();
|
|
24918
24965
|
if (_currentMcpVersion && diskVersion !== _currentMcpVersion) {
|
|
24919
24966
|
process.stderr.write(
|
|
24920
24967
|
`[exe-os] MCP version changed (${_currentMcpVersion} \u2192 ${diskVersion}). Hot-reloading...
|
|
@@ -24951,7 +24998,7 @@ try {
|
|
|
24951
24998
|
path46.dirname(thisFile),
|
|
24952
24999
|
"../bin/backfill-vectors.js"
|
|
24953
25000
|
);
|
|
24954
|
-
if (
|
|
25001
|
+
if (existsSync35(backfillPath)) {
|
|
24955
25002
|
const { EXE_AI_DIR: exeDir } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
24956
25003
|
const logPath = path46.join(exeDir, "workers.log");
|
|
24957
25004
|
mkdirSync18(path46.dirname(logPath), { recursive: true });
|