@askexenow/exe-os 0.8.44 → 0.8.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.
@@ -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
- var _client, _resilientClient, initTurso;
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
 
@@ -5582,9 +5601,19 @@ async function cloudSync(config) {
5582
5601
  } catch {
5583
5602
  throw new Error("[cloud-sync] Database not initialized. Call initStore() before cloudSync().");
5584
5603
  }
5585
- const pullMeta = await client.execute(
5586
- "SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
5587
- );
5604
+ let pullMeta;
5605
+ try {
5606
+ pullMeta = await client.execute(
5607
+ "SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
5608
+ );
5609
+ } catch (e) {
5610
+ logError(`[cloud-sync] sync_meta read failed (${e instanceof Error ? e.message : String(e)}), attempting ensureSchema`);
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
+ );
5616
+ }
5588
5617
  const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
5589
5618
  const pullResult = await cloudPull(lastPullVersion, config);
5590
5619
  let pulled = 0;
@@ -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, {
@@ -724,14 +740,12 @@ function isMainModule(importMetaUrl) {
724
740
  }
725
741
 
726
742
  // src/lib/cloud-sync.ts
743
+ init_database();
727
744
  import { readFileSync as readFileSync5, writeFileSync as writeFileSync2, existsSync as existsSync6, readdirSync, mkdirSync as mkdirSync2, appendFileSync, unlinkSync, openSync, closeSync } from "fs";
728
745
  import crypto4 from "crypto";
729
746
  import path6 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
 
@@ -739,6 +753,7 @@ import crypto3 from "crypto";
739
753
  import { brotliCompressSync, brotliDecompressSync, constants } from "zlib";
740
754
 
741
755
  // src/lib/plan-limits.ts
756
+ init_database();
742
757
  import { readFileSync as readFileSync4, existsSync as existsSync5 } from "fs";
743
758
  import path5 from "path";
744
759