@askexenow/exe-os 0.9.14 → 0.9.15
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 +40 -32
- package/package.json +1 -1
package/dist/lib/exe-daemon.js
CHANGED
|
@@ -7687,6 +7687,7 @@ __export(projection_worker_exports, {
|
|
|
7687
7687
|
});
|
|
7688
7688
|
import os12 from "os";
|
|
7689
7689
|
import path19 from "path";
|
|
7690
|
+
import { existsSync as existsSync17 } from "fs";
|
|
7690
7691
|
import { createRequire as createRequire3 } from "module";
|
|
7691
7692
|
import { pathToFileURL as pathToFileURL3 } from "url";
|
|
7692
7693
|
function loadPrisma() {
|
|
@@ -7764,6 +7765,13 @@ async function processBatch() {
|
|
|
7764
7765
|
}
|
|
7765
7766
|
function startProjectionWorker() {
|
|
7766
7767
|
if (running) return;
|
|
7768
|
+
if (!process.env.DATABASE_URL) {
|
|
7769
|
+
const exeDbRoot = process.env.EXE_DB_ROOT ?? path19.join(os12.homedir(), "exe-db");
|
|
7770
|
+
if (!existsSync17(path19.join(exeDbRoot, "package.json"))) {
|
|
7771
|
+
process.stderr.write("[projection-worker] Skipped \u2014 no exe-db found. Set DATABASE_URL or EXE_DB_ROOT to enable.\n");
|
|
7772
|
+
return;
|
|
7773
|
+
}
|
|
7774
|
+
}
|
|
7767
7775
|
running = true;
|
|
7768
7776
|
process.stderr.write("[projection-worker] Starting...\n");
|
|
7769
7777
|
const tick = async () => {
|
|
@@ -7931,11 +7939,11 @@ __export(shard_manager_exports, {
|
|
|
7931
7939
|
shardExists: () => shardExists
|
|
7932
7940
|
});
|
|
7933
7941
|
import path20 from "path";
|
|
7934
|
-
import { existsSync as
|
|
7942
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
|
|
7935
7943
|
import { createClient as createClient2 } from "@libsql/client";
|
|
7936
7944
|
function initShardManager(encryptionKey) {
|
|
7937
7945
|
_encryptionKey = encryptionKey;
|
|
7938
|
-
if (!
|
|
7946
|
+
if (!existsSync18(SHARDS_DIR)) {
|
|
7939
7947
|
mkdirSync7(SHARDS_DIR, { recursive: true });
|
|
7940
7948
|
}
|
|
7941
7949
|
_shardingEnabled = true;
|
|
@@ -7976,10 +7984,10 @@ function getShardClient(projectName) {
|
|
|
7976
7984
|
}
|
|
7977
7985
|
function shardExists(projectName) {
|
|
7978
7986
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7979
|
-
return
|
|
7987
|
+
return existsSync18(path20.join(SHARDS_DIR, `${safeName}.db`));
|
|
7980
7988
|
}
|
|
7981
7989
|
function listShards() {
|
|
7982
|
-
if (!
|
|
7990
|
+
if (!existsSync18(SHARDS_DIR)) return [];
|
|
7983
7991
|
return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
7984
7992
|
}
|
|
7985
7993
|
async function ensureShardSchema(client) {
|
|
@@ -8248,7 +8256,7 @@ __export(keychain_exports, {
|
|
|
8248
8256
|
setMasterKey: () => setMasterKey
|
|
8249
8257
|
});
|
|
8250
8258
|
import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
|
|
8251
|
-
import { existsSync as
|
|
8259
|
+
import { existsSync as existsSync19 } from "fs";
|
|
8252
8260
|
import path21 from "path";
|
|
8253
8261
|
import os13 from "os";
|
|
8254
8262
|
function getKeyDir() {
|
|
@@ -8276,7 +8284,7 @@ async function getMasterKey() {
|
|
|
8276
8284
|
}
|
|
8277
8285
|
}
|
|
8278
8286
|
const keyPath = getKeyPath();
|
|
8279
|
-
if (!
|
|
8287
|
+
if (!existsSync19(keyPath)) {
|
|
8280
8288
|
process.stderr.write(
|
|
8281
8289
|
`[keychain] Key not found at ${keyPath} (HOME=${os13.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
|
|
8282
8290
|
`
|
|
@@ -8319,7 +8327,7 @@ async function deleteMasterKey() {
|
|
|
8319
8327
|
}
|
|
8320
8328
|
}
|
|
8321
8329
|
const keyPath = getKeyPath();
|
|
8322
|
-
if (
|
|
8330
|
+
if (existsSync19(keyPath)) {
|
|
8323
8331
|
await unlink(keyPath);
|
|
8324
8332
|
}
|
|
8325
8333
|
}
|
|
@@ -9736,10 +9744,10 @@ async function disposeEmbedder() {
|
|
|
9736
9744
|
async function embedDirect(text) {
|
|
9737
9745
|
const llamaCpp = await import("node-llama-cpp");
|
|
9738
9746
|
const { MODELS_DIR: MODELS_DIR2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
9739
|
-
const { existsSync:
|
|
9747
|
+
const { existsSync: existsSync24 } = await import("fs");
|
|
9740
9748
|
const path28 = await import("path");
|
|
9741
9749
|
const modelPath = path28.join(MODELS_DIR2, "jina-embeddings-v5-small-q4_k_m.gguf");
|
|
9742
|
-
if (!
|
|
9750
|
+
if (!existsSync24(modelPath)) {
|
|
9743
9751
|
throw new Error(`Embedding model not found at ${modelPath}. Run '/exe-setup' to download it.`);
|
|
9744
9752
|
}
|
|
9745
9753
|
const llama = await llamaCpp.getLlama();
|
|
@@ -9858,7 +9866,7 @@ __export(crdt_sync_exports, {
|
|
|
9858
9866
|
rebuildFromDb: () => rebuildFromDb
|
|
9859
9867
|
});
|
|
9860
9868
|
import * as Y from "yjs";
|
|
9861
|
-
import { readFileSync as readFileSync15, writeFileSync as writeFileSync10, existsSync as
|
|
9869
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync10, existsSync as existsSync20, mkdirSync as mkdirSync8, unlinkSync as unlinkSync7 } from "fs";
|
|
9862
9870
|
import path22 from "path";
|
|
9863
9871
|
import { homedir as homedir2 } from "os";
|
|
9864
9872
|
function getStatePath() {
|
|
@@ -9871,7 +9879,7 @@ function initCrdtDoc() {
|
|
|
9871
9879
|
if (doc) return doc;
|
|
9872
9880
|
doc = new Y.Doc();
|
|
9873
9881
|
const sp = getStatePath();
|
|
9874
|
-
if (
|
|
9882
|
+
if (existsSync20(sp)) {
|
|
9875
9883
|
try {
|
|
9876
9884
|
const state = readFileSync15(sp);
|
|
9877
9885
|
Y.applyUpdate(doc, new Uint8Array(state));
|
|
@@ -10016,7 +10024,7 @@ function persistState() {
|
|
|
10016
10024
|
try {
|
|
10017
10025
|
const sp = getStatePath();
|
|
10018
10026
|
const dir = path22.dirname(sp);
|
|
10019
|
-
if (!
|
|
10027
|
+
if (!existsSync20(dir)) mkdirSync8(dir, { recursive: true });
|
|
10020
10028
|
const state = Y.encodeStateAsUpdate(doc);
|
|
10021
10029
|
writeFileSync10(sp, Buffer.from(state));
|
|
10022
10030
|
} catch {
|
|
@@ -10094,7 +10102,7 @@ __export(cloud_sync_exports, {
|
|
|
10094
10102
|
pushToPostgres: () => pushToPostgres,
|
|
10095
10103
|
recordRosterDeletion: () => recordRosterDeletion
|
|
10096
10104
|
});
|
|
10097
|
-
import { readFileSync as readFileSync16, writeFileSync as writeFileSync11, existsSync as
|
|
10105
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync11, existsSync as existsSync21, readdirSync as readdirSync5, mkdirSync as mkdirSync9, appendFileSync as appendFileSync2, unlinkSync as unlinkSync8, openSync as openSync2, closeSync as closeSync2 } from "fs";
|
|
10098
10106
|
import crypto9 from "crypto";
|
|
10099
10107
|
import path23 from "path";
|
|
10100
10108
|
import { homedir as homedir3 } from "os";
|
|
@@ -10115,7 +10123,7 @@ function loadPgClient() {
|
|
|
10115
10123
|
const configPath = path23.join(EXE_AI_DIR, "config.json");
|
|
10116
10124
|
let cloudPostgresUrl;
|
|
10117
10125
|
try {
|
|
10118
|
-
if (
|
|
10126
|
+
if (existsSync21(configPath)) {
|
|
10119
10127
|
const cfg = JSON.parse(readFileSync16(configPath, "utf8"));
|
|
10120
10128
|
cloudPostgresUrl = cfg.cloud?.postgresUrl;
|
|
10121
10129
|
if (cfg.cloud?.syncToPostgres === false) {
|
|
@@ -10576,7 +10584,7 @@ async function cloudSync(config) {
|
|
|
10576
10584
|
const employees = await loadEmployees();
|
|
10577
10585
|
rosterResult.employees = employees.length;
|
|
10578
10586
|
const idDir = path23.join(EXE_AI_DIR, "identity");
|
|
10579
|
-
if (
|
|
10587
|
+
if (existsSync21(idDir)) {
|
|
10580
10588
|
rosterResult.identities = readdirSync5(idDir).filter((f) => f.endsWith(".md")).length;
|
|
10581
10589
|
}
|
|
10582
10590
|
} catch {
|
|
@@ -10597,7 +10605,7 @@ async function cloudSync(config) {
|
|
|
10597
10605
|
function recordRosterDeletion(name) {
|
|
10598
10606
|
let deletions = [];
|
|
10599
10607
|
try {
|
|
10600
|
-
if (
|
|
10608
|
+
if (existsSync21(ROSTER_DELETIONS_PATH)) {
|
|
10601
10609
|
deletions = JSON.parse(readFileSync16(ROSTER_DELETIONS_PATH, "utf-8"));
|
|
10602
10610
|
}
|
|
10603
10611
|
} catch {
|
|
@@ -10607,7 +10615,7 @@ function recordRosterDeletion(name) {
|
|
|
10607
10615
|
}
|
|
10608
10616
|
function consumeRosterDeletions() {
|
|
10609
10617
|
try {
|
|
10610
|
-
if (!
|
|
10618
|
+
if (!existsSync21(ROSTER_DELETIONS_PATH)) return [];
|
|
10611
10619
|
const deletions = JSON.parse(readFileSync16(ROSTER_DELETIONS_PATH, "utf-8"));
|
|
10612
10620
|
writeFileSync11(ROSTER_DELETIONS_PATH, "[]");
|
|
10613
10621
|
return deletions;
|
|
@@ -10620,14 +10628,14 @@ function buildRosterBlob(paths) {
|
|
|
10620
10628
|
const identityDir = paths?.identityDir ?? path23.join(EXE_AI_DIR, "identity");
|
|
10621
10629
|
const configPath = paths?.configPath ?? path23.join(EXE_AI_DIR, "config.json");
|
|
10622
10630
|
let roster = [];
|
|
10623
|
-
if (
|
|
10631
|
+
if (existsSync21(rosterPath)) {
|
|
10624
10632
|
try {
|
|
10625
10633
|
roster = JSON.parse(readFileSync16(rosterPath, "utf-8"));
|
|
10626
10634
|
} catch {
|
|
10627
10635
|
}
|
|
10628
10636
|
}
|
|
10629
10637
|
const identities = {};
|
|
10630
|
-
if (
|
|
10638
|
+
if (existsSync21(identityDir)) {
|
|
10631
10639
|
for (const file of readdirSync5(identityDir).filter((f) => f.endsWith(".md"))) {
|
|
10632
10640
|
try {
|
|
10633
10641
|
identities[file] = readFileSync16(path23.join(identityDir, file), "utf-8");
|
|
@@ -10636,7 +10644,7 @@ function buildRosterBlob(paths) {
|
|
|
10636
10644
|
}
|
|
10637
10645
|
}
|
|
10638
10646
|
let config;
|
|
10639
|
-
if (
|
|
10647
|
+
if (existsSync21(configPath)) {
|
|
10640
10648
|
try {
|
|
10641
10649
|
config = JSON.parse(readFileSync16(configPath, "utf-8"));
|
|
10642
10650
|
} catch {
|
|
@@ -10644,7 +10652,7 @@ function buildRosterBlob(paths) {
|
|
|
10644
10652
|
}
|
|
10645
10653
|
let agentConfig;
|
|
10646
10654
|
const agentConfigPath = path23.join(EXE_AI_DIR, "agent-config.json");
|
|
10647
|
-
if (
|
|
10655
|
+
if (existsSync21(agentConfigPath)) {
|
|
10648
10656
|
try {
|
|
10649
10657
|
agentConfig = JSON.parse(readFileSync16(agentConfigPath, "utf-8"));
|
|
10650
10658
|
} catch {
|
|
@@ -10724,7 +10732,7 @@ async function cloudPullRoster(config) {
|
|
|
10724
10732
|
function mergeConfig(remoteConfig, configPath) {
|
|
10725
10733
|
const cfgPath = configPath ?? path23.join(EXE_AI_DIR, "config.json");
|
|
10726
10734
|
let local = {};
|
|
10727
|
-
if (
|
|
10735
|
+
if (existsSync21(cfgPath)) {
|
|
10728
10736
|
try {
|
|
10729
10737
|
local = JSON.parse(readFileSync16(cfgPath, "utf-8"));
|
|
10730
10738
|
} catch {
|
|
@@ -10760,11 +10768,11 @@ async function mergeRosterFromRemote(remote, paths) {
|
|
|
10760
10768
|
) ?? lookupKey;
|
|
10761
10769
|
const remoteIdentity = remote.identities[matchedKey];
|
|
10762
10770
|
if (remoteIdentity) {
|
|
10763
|
-
if (!
|
|
10771
|
+
if (!existsSync21(identityDir)) mkdirSync9(identityDir, { recursive: true });
|
|
10764
10772
|
const idPath = path23.join(identityDir, `${remoteEmp.name}.md`);
|
|
10765
10773
|
let localIdentity = null;
|
|
10766
10774
|
try {
|
|
10767
|
-
localIdentity =
|
|
10775
|
+
localIdentity = existsSync21(idPath) ? readFileSync16(idPath, "utf-8") : null;
|
|
10768
10776
|
} catch {
|
|
10769
10777
|
}
|
|
10770
10778
|
if (localIdentity !== remoteIdentity) {
|
|
@@ -10796,7 +10804,7 @@ async function mergeRosterFromRemote(remote, paths) {
|
|
|
10796
10804
|
try {
|
|
10797
10805
|
const agentConfigPath = path23.join(EXE_AI_DIR, "agent-config.json");
|
|
10798
10806
|
let local = {};
|
|
10799
|
-
if (
|
|
10807
|
+
if (existsSync21(agentConfigPath)) {
|
|
10800
10808
|
try {
|
|
10801
10809
|
local = JSON.parse(readFileSync16(agentConfigPath, "utf-8"));
|
|
10802
10810
|
} catch {
|
|
@@ -12311,10 +12319,10 @@ __export(device_registry_exports, {
|
|
|
12311
12319
|
});
|
|
12312
12320
|
import crypto12 from "crypto";
|
|
12313
12321
|
import os15 from "os";
|
|
12314
|
-
import { readFileSync as readFileSync18, writeFileSync as writeFileSync12, mkdirSync as mkdirSync10, existsSync as
|
|
12322
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync12, mkdirSync as mkdirSync10, existsSync as existsSync22 } from "fs";
|
|
12315
12323
|
import path26 from "path";
|
|
12316
12324
|
function getDeviceInfo() {
|
|
12317
|
-
if (
|
|
12325
|
+
if (existsSync22(DEVICE_JSON_PATH)) {
|
|
12318
12326
|
try {
|
|
12319
12327
|
const raw = readFileSync18(DEVICE_JSON_PATH, "utf8");
|
|
12320
12328
|
const data = JSON.parse(raw);
|
|
@@ -12859,7 +12867,7 @@ init_daemon_auth();
|
|
|
12859
12867
|
init_daemon_orchestration();
|
|
12860
12868
|
import os16 from "os";
|
|
12861
12869
|
import net2 from "net";
|
|
12862
|
-
import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync9, mkdirSync as mkdirSync11, existsSync as
|
|
12870
|
+
import { writeFileSync as writeFileSync13, unlinkSync as unlinkSync9, mkdirSync as mkdirSync11, existsSync as existsSync23, readFileSync as readFileSync19, chmodSync as chmodSync2 } from "fs";
|
|
12863
12871
|
import path27 from "path";
|
|
12864
12872
|
import { getLlama } from "node-llama-cpp";
|
|
12865
12873
|
var SOCKET_PATH2 = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path27.join(EXE_AI_DIR, "exed.sock");
|
|
@@ -12892,7 +12900,7 @@ function enqueue(queue, entry) {
|
|
|
12892
12900
|
}
|
|
12893
12901
|
async function loadModel() {
|
|
12894
12902
|
const modelPath = path27.join(MODELS_DIR, MODEL_FILE);
|
|
12895
|
-
if (!
|
|
12903
|
+
if (!existsSync23(modelPath)) {
|
|
12896
12904
|
process.stderr.write(`[exed] FATAL: model not found at ${modelPath}
|
|
12897
12905
|
`);
|
|
12898
12906
|
process.exit(1);
|
|
@@ -13696,11 +13704,11 @@ function startIntercomQueueDrain() {
|
|
|
13696
13704
|
try {
|
|
13697
13705
|
const { baseAgentName: ban } = (init_employees(), __toCommonJS(employees_exports));
|
|
13698
13706
|
const path28 = __require("path");
|
|
13699
|
-
const { existsSync:
|
|
13707
|
+
const { existsSync: existsSync24 } = __require("fs");
|
|
13700
13708
|
const os17 = __require("os");
|
|
13701
13709
|
const agent = ban(session.split("-")[0] ?? session);
|
|
13702
13710
|
const markerPath = path28.join(os17.homedir(), ".exe-os", "session-cache", `current-task-${agent}.json`);
|
|
13703
|
-
return
|
|
13711
|
+
return existsSync24(markerPath);
|
|
13704
13712
|
} catch {
|
|
13705
13713
|
return false;
|
|
13706
13714
|
}
|
|
@@ -13825,7 +13833,7 @@ process.on("SIGINT", () => void shutdown());
|
|
|
13825
13833
|
process.on("SIGTERM", () => void shutdown());
|
|
13826
13834
|
function checkExistingDaemon() {
|
|
13827
13835
|
try {
|
|
13828
|
-
if (!
|
|
13836
|
+
if (!existsSync23(PID_PATH2)) return false;
|
|
13829
13837
|
const pid = parseInt(readFileSync19(PID_PATH2, "utf8").trim(), 10);
|
|
13830
13838
|
if (!pid || isNaN(pid)) return false;
|
|
13831
13839
|
process.kill(pid, 0);
|
package/package.json
CHANGED