@askexenow/exe-os 0.8.44 → 0.8.46
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 +33 -14
- package/dist/bin/exe-cloud.js +46 -39
- package/dist/bin/exe-link.js +999 -279
- package/dist/bin/exe-settings.js +36 -24
- package/dist/hooks/summary-worker.js +17 -6
- package/dist/lib/cloud-sync.js +1021 -274
- package/package.json +1 -1
package/dist/bin/exe-boot.js
CHANGED
|
@@ -417,6 +417,17 @@ 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
|
+
});
|
|
420
431
|
import { createClient } from "@libsql/client";
|
|
421
432
|
async function initDatabase(config) {
|
|
422
433
|
if (_client) {
|
|
@@ -1260,7 +1271,14 @@ async function ensureSchema() {
|
|
|
1260
1271
|
}
|
|
1261
1272
|
}
|
|
1262
1273
|
}
|
|
1263
|
-
|
|
1274
|
+
async function disposeDatabase() {
|
|
1275
|
+
if (_client) {
|
|
1276
|
+
_client.close();
|
|
1277
|
+
_client = null;
|
|
1278
|
+
_resilientClient = null;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
var _client, _resilientClient, initTurso, disposeTurso;
|
|
1264
1282
|
var init_database = __esm({
|
|
1265
1283
|
"src/lib/database.ts"() {
|
|
1266
1284
|
"use strict";
|
|
@@ -1268,6 +1286,7 @@ var init_database = __esm({
|
|
|
1268
1286
|
_client = null;
|
|
1269
1287
|
_resilientClient = null;
|
|
1270
1288
|
initTurso = initDatabase;
|
|
1289
|
+
disposeTurso = disposeDatabase;
|
|
1271
1290
|
}
|
|
1272
1291
|
});
|
|
1273
1292
|
|
|
@@ -2787,14 +2806,6 @@ function assertEmployeeLimitSync(rosterPath) {
|
|
|
2787
2806
|
);
|
|
2788
2807
|
}
|
|
2789
2808
|
}
|
|
2790
|
-
async function assertFeature(feature) {
|
|
2791
|
-
const license = await checkLicense();
|
|
2792
|
-
if (!isFeatureAllowed(license, feature)) {
|
|
2793
|
-
throw new PlanLimitError(
|
|
2794
|
-
`Feature "${feature}" requires a paid plan. Current plan: ${license.plan}. Upgrade at https://askexe.com.`
|
|
2795
|
-
);
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
2809
|
var PlanLimitError, CACHE_PATH2;
|
|
2799
2810
|
var init_plan_limits = __esm({
|
|
2800
2811
|
"src/lib/plan-limits.ts"() {
|
|
@@ -5575,16 +5586,25 @@ async function cloudPull(sinceVersion, config) {
|
|
|
5575
5586
|
}
|
|
5576
5587
|
}
|
|
5577
5588
|
async function cloudSync(config) {
|
|
5578
|
-
await assertFeature("cloud_sync");
|
|
5579
5589
|
let client;
|
|
5580
5590
|
try {
|
|
5581
5591
|
client = getClient();
|
|
5582
5592
|
} catch {
|
|
5583
5593
|
throw new Error("[cloud-sync] Database not initialized. Call initStore() before cloudSync().");
|
|
5584
5594
|
}
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5595
|
+
let pullMeta;
|
|
5596
|
+
try {
|
|
5597
|
+
pullMeta = await client.execute(
|
|
5598
|
+
"SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
|
|
5599
|
+
);
|
|
5600
|
+
} catch (e) {
|
|
5601
|
+
logError(`[cloud-sync] sync_meta read failed (${e instanceof Error ? e.message : String(e)}), attempting ensureSchema`);
|
|
5602
|
+
const { ensureSchema: ensureSchema2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5603
|
+
await ensureSchema2();
|
|
5604
|
+
pullMeta = await client.execute(
|
|
5605
|
+
"SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
|
|
5606
|
+
);
|
|
5607
|
+
}
|
|
5588
5608
|
const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
|
|
5589
5609
|
const pullResult = await cloudPull(lastPullVersion, config);
|
|
5590
5610
|
let pulled = 0;
|
|
@@ -6301,7 +6321,6 @@ var init_cloud_sync = __esm({
|
|
|
6301
6321
|
init_database();
|
|
6302
6322
|
init_crypto();
|
|
6303
6323
|
init_compress();
|
|
6304
|
-
init_plan_limits();
|
|
6305
6324
|
init_license();
|
|
6306
6325
|
init_config();
|
|
6307
6326
|
init_employees();
|
package/dist/bin/exe-cloud.js
CHANGED
|
@@ -213,6 +213,22 @@ 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
|
+
|
|
216
232
|
// src/lib/license.ts
|
|
217
233
|
var license_exports = {};
|
|
218
234
|
__export(license_exports, {
|
|
@@ -230,9 +246,9 @@ __export(license_exports, {
|
|
|
230
246
|
stopLicenseRevalidation: () => stopLicenseRevalidation,
|
|
231
247
|
validateLicense: () => validateLicense
|
|
232
248
|
});
|
|
233
|
-
import { readFileSync as
|
|
249
|
+
import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync3, mkdirSync } from "fs";
|
|
234
250
|
import { randomUUID } from "crypto";
|
|
235
|
-
import
|
|
251
|
+
import path3 from "path";
|
|
236
252
|
import { jwtVerify, importSPKI } from "jose";
|
|
237
253
|
async function fetchRetry(url, init) {
|
|
238
254
|
try {
|
|
@@ -243,17 +259,17 @@ async function fetchRetry(url, init) {
|
|
|
243
259
|
}
|
|
244
260
|
}
|
|
245
261
|
function loadDeviceId() {
|
|
246
|
-
const deviceJsonPath =
|
|
262
|
+
const deviceJsonPath = path3.join(EXE_AI_DIR, "device.json");
|
|
247
263
|
try {
|
|
248
|
-
if (
|
|
249
|
-
const data = JSON.parse(
|
|
264
|
+
if (existsSync3(deviceJsonPath)) {
|
|
265
|
+
const data = JSON.parse(readFileSync2(deviceJsonPath, "utf8"));
|
|
250
266
|
if (data.deviceId) return data.deviceId;
|
|
251
267
|
}
|
|
252
268
|
} catch {
|
|
253
269
|
}
|
|
254
270
|
try {
|
|
255
|
-
if (
|
|
256
|
-
const id2 =
|
|
271
|
+
if (existsSync3(DEVICE_ID_PATH)) {
|
|
272
|
+
const id2 = readFileSync2(DEVICE_ID_PATH, "utf8").trim();
|
|
257
273
|
if (id2) return id2;
|
|
258
274
|
}
|
|
259
275
|
} catch {
|
|
@@ -265,8 +281,8 @@ function loadDeviceId() {
|
|
|
265
281
|
}
|
|
266
282
|
function loadLicense() {
|
|
267
283
|
try {
|
|
268
|
-
if (!
|
|
269
|
-
return
|
|
284
|
+
if (!existsSync3(LICENSE_PATH)) return null;
|
|
285
|
+
return readFileSync2(LICENSE_PATH, "utf8").trim();
|
|
270
286
|
} catch {
|
|
271
287
|
return null;
|
|
272
288
|
}
|
|
@@ -299,8 +315,8 @@ async function verifyLicenseJwt(token) {
|
|
|
299
315
|
}
|
|
300
316
|
async function getCachedLicense() {
|
|
301
317
|
try {
|
|
302
|
-
if (!
|
|
303
|
-
const raw = JSON.parse(
|
|
318
|
+
if (!existsSync3(CACHE_PATH)) return null;
|
|
319
|
+
const raw = JSON.parse(readFileSync2(CACHE_PATH, "utf8"));
|
|
304
320
|
if (!raw.token || typeof raw.token !== "string") return null;
|
|
305
321
|
return await verifyLicenseJwt(raw.token);
|
|
306
322
|
} catch {
|
|
@@ -309,8 +325,8 @@ async function getCachedLicense() {
|
|
|
309
325
|
}
|
|
310
326
|
function readCachedToken() {
|
|
311
327
|
try {
|
|
312
|
-
if (!
|
|
313
|
-
const raw = JSON.parse(
|
|
328
|
+
if (!existsSync3(CACHE_PATH)) return null;
|
|
329
|
+
const raw = JSON.parse(readFileSync2(CACHE_PATH, "utf8"));
|
|
314
330
|
return typeof raw.token === "string" ? raw.token : null;
|
|
315
331
|
} catch {
|
|
316
332
|
return null;
|
|
@@ -376,9 +392,9 @@ async function checkLicense() {
|
|
|
376
392
|
let key = loadLicense();
|
|
377
393
|
if (!key) {
|
|
378
394
|
try {
|
|
379
|
-
const configPath =
|
|
380
|
-
if (
|
|
381
|
-
const raw = JSON.parse(
|
|
395
|
+
const configPath = path3.join(EXE_AI_DIR, "config.json");
|
|
396
|
+
if (existsSync3(configPath)) {
|
|
397
|
+
const raw = JSON.parse(readFileSync2(configPath, "utf8"));
|
|
382
398
|
const cloud = raw.cloud;
|
|
383
399
|
if (cloud?.apiKey) {
|
|
384
400
|
key = cloud.apiKey;
|
|
@@ -537,9 +553,9 @@ var init_license = __esm({
|
|
|
537
553
|
"src/lib/license.ts"() {
|
|
538
554
|
"use strict";
|
|
539
555
|
init_config();
|
|
540
|
-
LICENSE_PATH =
|
|
541
|
-
CACHE_PATH =
|
|
542
|
-
DEVICE_ID_PATH =
|
|
556
|
+
LICENSE_PATH = path3.join(EXE_AI_DIR, "license.key");
|
|
557
|
+
CACHE_PATH = path3.join(EXE_AI_DIR, "license-cache.json");
|
|
558
|
+
DEVICE_ID_PATH = path3.join(EXE_AI_DIR, "device-id");
|
|
543
559
|
API_BASE = "https://askexe.com/cloud";
|
|
544
560
|
RETRY_DELAY_MS = 500;
|
|
545
561
|
LICENSE_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
|
|
@@ -724,42 +740,33 @@ function isMainModule(importMetaUrl) {
|
|
|
724
740
|
}
|
|
725
741
|
|
|
726
742
|
// src/lib/cloud-sync.ts
|
|
727
|
-
|
|
743
|
+
init_database();
|
|
744
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync5, readdirSync, mkdirSync as mkdirSync2, appendFileSync, unlinkSync, openSync, closeSync } from "fs";
|
|
728
745
|
import crypto4 from "crypto";
|
|
729
|
-
import
|
|
746
|
+
import path5 from "path";
|
|
730
747
|
import { homedir } from "os";
|
|
731
748
|
|
|
732
|
-
// src/lib/database.ts
|
|
733
|
-
import { createClient } from "@libsql/client";
|
|
734
|
-
|
|
735
749
|
// src/lib/crypto.ts
|
|
736
750
|
import crypto3 from "crypto";
|
|
737
751
|
|
|
738
752
|
// src/lib/compress.ts
|
|
739
753
|
import { brotliCompressSync, brotliDecompressSync, constants } from "zlib";
|
|
740
754
|
|
|
741
|
-
// src/lib/
|
|
742
|
-
|
|
743
|
-
|
|
755
|
+
// src/lib/cloud-sync.ts
|
|
756
|
+
init_license();
|
|
757
|
+
init_config();
|
|
744
758
|
|
|
745
759
|
// src/lib/employees.ts
|
|
746
760
|
init_config();
|
|
747
761
|
import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
748
|
-
import { existsSync as
|
|
762
|
+
import { existsSync as existsSync4, symlinkSync, readlinkSync, readFileSync as readFileSync3 } from "fs";
|
|
749
763
|
import { execSync } from "child_process";
|
|
750
|
-
import
|
|
751
|
-
var EMPLOYEES_PATH =
|
|
752
|
-
|
|
753
|
-
// src/lib/plan-limits.ts
|
|
754
|
-
init_license();
|
|
755
|
-
init_config();
|
|
756
|
-
var CACHE_PATH2 = path5.join(EXE_AI_DIR, "license-cache.json");
|
|
764
|
+
import path4 from "path";
|
|
765
|
+
var EMPLOYEES_PATH = path4.join(EXE_AI_DIR, "exe-employees.json");
|
|
757
766
|
|
|
758
767
|
// src/lib/cloud-sync.ts
|
|
759
|
-
init_license();
|
|
760
|
-
init_config();
|
|
761
768
|
var LOCALHOST_PATTERNS = /^(localhost|127\.0\.0\.1|\[::1\])$/i;
|
|
762
|
-
var ROSTER_LOCK_PATH =
|
|
769
|
+
var ROSTER_LOCK_PATH = path5.join(EXE_AI_DIR, "roster-merge.lock");
|
|
763
770
|
function assertSecureEndpoint(endpoint) {
|
|
764
771
|
if (endpoint.startsWith("https://")) return;
|
|
765
772
|
if (endpoint.startsWith("http://")) {
|
|
@@ -774,7 +781,7 @@ function assertSecureEndpoint(endpoint) {
|
|
|
774
781
|
);
|
|
775
782
|
}
|
|
776
783
|
}
|
|
777
|
-
var ROSTER_DELETIONS_PATH =
|
|
784
|
+
var ROSTER_DELETIONS_PATH = path5.join(EXE_AI_DIR, "roster-deletions.json");
|
|
778
785
|
|
|
779
786
|
// src/bin/exe-cloud.ts
|
|
780
787
|
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";
|