@askexenow/exe-os 0.8.45 → 0.8.47
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/bin/exe-boot.js +7 -39
- package/dist/bin/exe-cloud.js +32 -54
- package/dist/bin/exe-link.js +87 -1190
- package/dist/bin/exe-settings.js +17 -44
- package/dist/hooks/summary-worker.js +6 -11
- package/dist/lib/cloud-sync.js +85 -1211
- package/package.json +1 -1
package/dist/bin/exe-boot.js
CHANGED
|
@@ -417,17 +417,6 @@ var init_db_retry = __esm({
|
|
|
417
417
|
});
|
|
418
418
|
|
|
419
419
|
// src/lib/database.ts
|
|
420
|
-
var database_exports = {};
|
|
421
|
-
__export(database_exports, {
|
|
422
|
-
disposeDatabase: () => disposeDatabase,
|
|
423
|
-
disposeTurso: () => disposeTurso,
|
|
424
|
-
ensureSchema: () => ensureSchema,
|
|
425
|
-
getClient: () => getClient,
|
|
426
|
-
getRawClient: () => getRawClient,
|
|
427
|
-
initDatabase: () => initDatabase,
|
|
428
|
-
initTurso: () => initTurso,
|
|
429
|
-
isInitialized: () => isInitialized
|
|
430
|
-
});
|
|
431
420
|
import { createClient } from "@libsql/client";
|
|
432
421
|
async function initDatabase(config) {
|
|
433
422
|
if (_client) {
|
|
@@ -1271,14 +1260,7 @@ async function ensureSchema() {
|
|
|
1271
1260
|
}
|
|
1272
1261
|
}
|
|
1273
1262
|
}
|
|
1274
|
-
|
|
1275
|
-
if (_client) {
|
|
1276
|
-
_client.close();
|
|
1277
|
-
_client = null;
|
|
1278
|
-
_resilientClient = null;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
var _client, _resilientClient, initTurso, disposeTurso;
|
|
1263
|
+
var _client, _resilientClient, initTurso;
|
|
1282
1264
|
var init_database = __esm({
|
|
1283
1265
|
"src/lib/database.ts"() {
|
|
1284
1266
|
"use strict";
|
|
@@ -1286,7 +1268,6 @@ var init_database = __esm({
|
|
|
1286
1268
|
_client = null;
|
|
1287
1269
|
_resilientClient = null;
|
|
1288
1270
|
initTurso = initDatabase;
|
|
1289
|
-
disposeTurso = disposeDatabase;
|
|
1290
1271
|
}
|
|
1291
1272
|
});
|
|
1292
1273
|
|
|
@@ -2806,14 +2787,6 @@ function assertEmployeeLimitSync(rosterPath) {
|
|
|
2806
2787
|
);
|
|
2807
2788
|
}
|
|
2808
2789
|
}
|
|
2809
|
-
async function assertFeature(feature) {
|
|
2810
|
-
const license = await checkLicense();
|
|
2811
|
-
if (!isFeatureAllowed(license, feature)) {
|
|
2812
|
-
throw new PlanLimitError(
|
|
2813
|
-
`Feature "${feature}" requires a paid plan. Current plan: ${license.plan}. Upgrade at https://askexe.com.`
|
|
2814
|
-
);
|
|
2815
|
-
}
|
|
2816
|
-
}
|
|
2817
2790
|
var PlanLimitError, CACHE_PATH2;
|
|
2818
2791
|
var init_plan_limits = __esm({
|
|
2819
2792
|
"src/lib/plan-limits.ts"() {
|
|
@@ -5594,26 +5567,22 @@ async function cloudPull(sinceVersion, config) {
|
|
|
5594
5567
|
}
|
|
5595
5568
|
}
|
|
5596
5569
|
async function cloudSync(config) {
|
|
5597
|
-
await assertFeature("cloud_sync");
|
|
5598
5570
|
let client;
|
|
5599
5571
|
try {
|
|
5600
5572
|
client = getClient();
|
|
5601
5573
|
} catch {
|
|
5602
5574
|
throw new Error("[cloud-sync] Database not initialized. Call initStore() before cloudSync().");
|
|
5603
5575
|
}
|
|
5604
|
-
let pullMeta;
|
|
5605
5576
|
try {
|
|
5606
|
-
|
|
5607
|
-
"
|
|
5577
|
+
await client.execute(
|
|
5578
|
+
"CREATE TABLE IF NOT EXISTS sync_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL)"
|
|
5608
5579
|
);
|
|
5609
5580
|
} catch (e) {
|
|
5610
|
-
logError(`[cloud-sync] sync_meta
|
|
5611
|
-
const { ensureSchema: ensureSchema2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5612
|
-
await ensureSchema2();
|
|
5613
|
-
pullMeta = await client.execute(
|
|
5614
|
-
"SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
|
|
5615
|
-
);
|
|
5581
|
+
logError(`[cloud-sync] sync_meta CREATE failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
5616
5582
|
}
|
|
5583
|
+
const pullMeta = await client.execute(
|
|
5584
|
+
"SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
|
|
5585
|
+
);
|
|
5617
5586
|
const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
|
|
5618
5587
|
const pullResult = await cloudPull(lastPullVersion, config);
|
|
5619
5588
|
let pulled = 0;
|
|
@@ -6330,7 +6299,6 @@ var init_cloud_sync = __esm({
|
|
|
6330
6299
|
init_database();
|
|
6331
6300
|
init_crypto();
|
|
6332
6301
|
init_compress();
|
|
6333
|
-
init_plan_limits();
|
|
6334
6302
|
init_license();
|
|
6335
6303
|
init_config();
|
|
6336
6304
|
init_employees();
|
package/dist/bin/exe-cloud.js
CHANGED
|
@@ -213,22 +213,6 @@ var init_config = __esm({
|
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
-
// src/lib/db-retry.ts
|
|
217
|
-
var init_db_retry = __esm({
|
|
218
|
-
"src/lib/db-retry.ts"() {
|
|
219
|
-
"use strict";
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// src/lib/database.ts
|
|
224
|
-
import { createClient } from "@libsql/client";
|
|
225
|
-
var init_database = __esm({
|
|
226
|
-
"src/lib/database.ts"() {
|
|
227
|
-
"use strict";
|
|
228
|
-
init_db_retry();
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
216
|
// src/lib/license.ts
|
|
233
217
|
var license_exports = {};
|
|
234
218
|
__export(license_exports, {
|
|
@@ -246,9 +230,9 @@ __export(license_exports, {
|
|
|
246
230
|
stopLicenseRevalidation: () => stopLicenseRevalidation,
|
|
247
231
|
validateLicense: () => validateLicense
|
|
248
232
|
});
|
|
249
|
-
import { readFileSync as
|
|
233
|
+
import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync3, mkdirSync } from "fs";
|
|
250
234
|
import { randomUUID } from "crypto";
|
|
251
|
-
import
|
|
235
|
+
import path3 from "path";
|
|
252
236
|
import { jwtVerify, importSPKI } from "jose";
|
|
253
237
|
async function fetchRetry(url, init) {
|
|
254
238
|
try {
|
|
@@ -259,17 +243,17 @@ async function fetchRetry(url, init) {
|
|
|
259
243
|
}
|
|
260
244
|
}
|
|
261
245
|
function loadDeviceId() {
|
|
262
|
-
const deviceJsonPath =
|
|
246
|
+
const deviceJsonPath = path3.join(EXE_AI_DIR, "device.json");
|
|
263
247
|
try {
|
|
264
|
-
if (
|
|
265
|
-
const data = JSON.parse(
|
|
248
|
+
if (existsSync3(deviceJsonPath)) {
|
|
249
|
+
const data = JSON.parse(readFileSync2(deviceJsonPath, "utf8"));
|
|
266
250
|
if (data.deviceId) return data.deviceId;
|
|
267
251
|
}
|
|
268
252
|
} catch {
|
|
269
253
|
}
|
|
270
254
|
try {
|
|
271
|
-
if (
|
|
272
|
-
const id2 =
|
|
255
|
+
if (existsSync3(DEVICE_ID_PATH)) {
|
|
256
|
+
const id2 = readFileSync2(DEVICE_ID_PATH, "utf8").trim();
|
|
273
257
|
if (id2) return id2;
|
|
274
258
|
}
|
|
275
259
|
} catch {
|
|
@@ -281,8 +265,8 @@ function loadDeviceId() {
|
|
|
281
265
|
}
|
|
282
266
|
function loadLicense() {
|
|
283
267
|
try {
|
|
284
|
-
if (!
|
|
285
|
-
return
|
|
268
|
+
if (!existsSync3(LICENSE_PATH)) return null;
|
|
269
|
+
return readFileSync2(LICENSE_PATH, "utf8").trim();
|
|
286
270
|
} catch {
|
|
287
271
|
return null;
|
|
288
272
|
}
|
|
@@ -315,8 +299,8 @@ async function verifyLicenseJwt(token) {
|
|
|
315
299
|
}
|
|
316
300
|
async function getCachedLicense() {
|
|
317
301
|
try {
|
|
318
|
-
if (!
|
|
319
|
-
const raw = JSON.parse(
|
|
302
|
+
if (!existsSync3(CACHE_PATH)) return null;
|
|
303
|
+
const raw = JSON.parse(readFileSync2(CACHE_PATH, "utf8"));
|
|
320
304
|
if (!raw.token || typeof raw.token !== "string") return null;
|
|
321
305
|
return await verifyLicenseJwt(raw.token);
|
|
322
306
|
} catch {
|
|
@@ -325,8 +309,8 @@ async function getCachedLicense() {
|
|
|
325
309
|
}
|
|
326
310
|
function readCachedToken() {
|
|
327
311
|
try {
|
|
328
|
-
if (!
|
|
329
|
-
const raw = JSON.parse(
|
|
312
|
+
if (!existsSync3(CACHE_PATH)) return null;
|
|
313
|
+
const raw = JSON.parse(readFileSync2(CACHE_PATH, "utf8"));
|
|
330
314
|
return typeof raw.token === "string" ? raw.token : null;
|
|
331
315
|
} catch {
|
|
332
316
|
return null;
|
|
@@ -392,9 +376,9 @@ async function checkLicense() {
|
|
|
392
376
|
let key = loadLicense();
|
|
393
377
|
if (!key) {
|
|
394
378
|
try {
|
|
395
|
-
const configPath =
|
|
396
|
-
if (
|
|
397
|
-
const raw = JSON.parse(
|
|
379
|
+
const configPath = path3.join(EXE_AI_DIR, "config.json");
|
|
380
|
+
if (existsSync3(configPath)) {
|
|
381
|
+
const raw = JSON.parse(readFileSync2(configPath, "utf8"));
|
|
398
382
|
const cloud = raw.cloud;
|
|
399
383
|
if (cloud?.apiKey) {
|
|
400
384
|
key = cloud.apiKey;
|
|
@@ -553,9 +537,9 @@ var init_license = __esm({
|
|
|
553
537
|
"src/lib/license.ts"() {
|
|
554
538
|
"use strict";
|
|
555
539
|
init_config();
|
|
556
|
-
LICENSE_PATH =
|
|
557
|
-
CACHE_PATH =
|
|
558
|
-
DEVICE_ID_PATH =
|
|
540
|
+
LICENSE_PATH = path3.join(EXE_AI_DIR, "license.key");
|
|
541
|
+
CACHE_PATH = path3.join(EXE_AI_DIR, "license-cache.json");
|
|
542
|
+
DEVICE_ID_PATH = path3.join(EXE_AI_DIR, "device-id");
|
|
559
543
|
API_BASE = "https://askexe.com/cloud";
|
|
560
544
|
RETRY_DELAY_MS = 500;
|
|
561
545
|
LICENSE_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
|
|
@@ -740,41 +724,35 @@ function isMainModule(importMetaUrl) {
|
|
|
740
724
|
}
|
|
741
725
|
|
|
742
726
|
// src/lib/cloud-sync.ts
|
|
743
|
-
|
|
744
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync2, existsSync as existsSync6, readdirSync, mkdirSync as mkdirSync2, appendFileSync, unlinkSync, openSync, closeSync } from "fs";
|
|
727
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync5, readdirSync, mkdirSync as mkdirSync2, appendFileSync, unlinkSync, openSync, closeSync } from "fs";
|
|
745
728
|
import crypto4 from "crypto";
|
|
746
|
-
import
|
|
729
|
+
import path5 from "path";
|
|
747
730
|
import { homedir } from "os";
|
|
748
731
|
|
|
732
|
+
// src/lib/database.ts
|
|
733
|
+
import { createClient } from "@libsql/client";
|
|
734
|
+
|
|
749
735
|
// src/lib/crypto.ts
|
|
750
736
|
import crypto3 from "crypto";
|
|
751
737
|
|
|
752
738
|
// src/lib/compress.ts
|
|
753
739
|
import { brotliCompressSync, brotliDecompressSync, constants } from "zlib";
|
|
754
740
|
|
|
755
|
-
// src/lib/
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
import path5 from "path";
|
|
741
|
+
// src/lib/cloud-sync.ts
|
|
742
|
+
init_license();
|
|
743
|
+
init_config();
|
|
759
744
|
|
|
760
745
|
// src/lib/employees.ts
|
|
761
746
|
init_config();
|
|
762
747
|
import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
763
|
-
import { existsSync as
|
|
748
|
+
import { existsSync as existsSync4, symlinkSync, readlinkSync, readFileSync as readFileSync3 } from "fs";
|
|
764
749
|
import { execSync } from "child_process";
|
|
765
|
-
import
|
|
766
|
-
var EMPLOYEES_PATH =
|
|
767
|
-
|
|
768
|
-
// src/lib/plan-limits.ts
|
|
769
|
-
init_license();
|
|
770
|
-
init_config();
|
|
771
|
-
var CACHE_PATH2 = path5.join(EXE_AI_DIR, "license-cache.json");
|
|
750
|
+
import path4 from "path";
|
|
751
|
+
var EMPLOYEES_PATH = path4.join(EXE_AI_DIR, "exe-employees.json");
|
|
772
752
|
|
|
773
753
|
// src/lib/cloud-sync.ts
|
|
774
|
-
init_license();
|
|
775
|
-
init_config();
|
|
776
754
|
var LOCALHOST_PATTERNS = /^(localhost|127\.0\.0\.1|\[::1\])$/i;
|
|
777
|
-
var ROSTER_LOCK_PATH =
|
|
755
|
+
var ROSTER_LOCK_PATH = path5.join(EXE_AI_DIR, "roster-merge.lock");
|
|
778
756
|
function assertSecureEndpoint(endpoint) {
|
|
779
757
|
if (endpoint.startsWith("https://")) return;
|
|
780
758
|
if (endpoint.startsWith("http://")) {
|
|
@@ -789,7 +767,7 @@ function assertSecureEndpoint(endpoint) {
|
|
|
789
767
|
);
|
|
790
768
|
}
|
|
791
769
|
}
|
|
792
|
-
var ROSTER_DELETIONS_PATH =
|
|
770
|
+
var ROSTER_DELETIONS_PATH = path5.join(EXE_AI_DIR, "roster-deletions.json");
|
|
793
771
|
|
|
794
772
|
// src/bin/exe-cloud.ts
|
|
795
773
|
var BAR = "\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550";
|