@askexenow/exe-os 0.8.46 → 0.8.48

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.
@@ -1,24 +1,3 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __esm = (fn, res) => function __init() {
3
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
- };
5
-
6
- // src/lib/db-retry.ts
7
- var init_db_retry = __esm({
8
- "src/lib/db-retry.ts"() {
9
- "use strict";
10
- }
11
- });
12
-
13
- // src/lib/database.ts
14
- import { createClient } from "@libsql/client";
15
- var init_database = __esm({
16
- "src/lib/database.ts"() {
17
- "use strict";
18
- init_db_retry();
19
- }
20
- });
21
-
22
1
  // src/bin/exe-settings.ts
23
2
  import { createInterface } from "readline";
24
3
 
@@ -229,12 +208,14 @@ function isMainModule(importMetaUrl) {
229
208
  }
230
209
 
231
210
  // src/lib/cloud-sync.ts
232
- init_database();
233
211
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync4, readdirSync, mkdirSync as mkdirSync2, appendFileSync, unlinkSync, openSync, closeSync } from "fs";
234
212
  import crypto2 from "crypto";
235
213
  import path4 from "path";
236
214
  import { homedir } from "os";
237
215
 
216
+ // src/lib/database.ts
217
+ import { createClient } from "@libsql/client";
218
+
238
219
  // src/lib/crypto.ts
239
220
  import crypto from "crypto";
240
221
 
@@ -2546,6 +2546,7 @@ __export(cloud_sync_exports, {
2546
2546
  cloudPullBlob: () => cloudPullBlob,
2547
2547
  cloudPullConversations: () => cloudPullConversations,
2548
2548
  cloudPullDocuments: () => cloudPullDocuments,
2549
+ cloudPullGlobalProcedures: () => cloudPullGlobalProcedures,
2549
2550
  cloudPullGraphRAG: () => cloudPullGraphRAG,
2550
2551
  cloudPullRoster: () => cloudPullRoster,
2551
2552
  cloudPullTasks: () => cloudPullTasks,
@@ -2554,6 +2555,7 @@ __export(cloud_sync_exports, {
2554
2555
  cloudPushBlob: () => cloudPushBlob,
2555
2556
  cloudPushConversations: () => cloudPushConversations,
2556
2557
  cloudPushDocuments: () => cloudPushDocuments,
2558
+ cloudPushGlobalProcedures: () => cloudPushGlobalProcedures,
2557
2559
  cloudPushGraphRAG: () => cloudPushGraphRAG,
2558
2560
  cloudPushRoster: () => cloudPushRoster,
2559
2561
  cloudPushTasks: () => cloudPushTasks,
@@ -2715,19 +2717,16 @@ async function cloudSync(config) {
2715
2717
  } catch {
2716
2718
  throw new Error("[cloud-sync] Database not initialized. Call initStore() before cloudSync().");
2717
2719
  }
2718
- let pullMeta;
2719
2720
  try {
2720
- pullMeta = await client.execute(
2721
- "SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
2721
+ await client.execute(
2722
+ "CREATE TABLE IF NOT EXISTS sync_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL)"
2722
2723
  );
2723
2724
  } catch (e) {
2724
- logError(`[cloud-sync] sync_meta read failed (${e instanceof Error ? e.message : String(e)}), attempting ensureSchema`);
2725
- const { ensureSchema: ensureSchema2 } = await Promise.resolve().then(() => (init_database(), database_exports));
2726
- await ensureSchema2();
2727
- pullMeta = await client.execute(
2728
- "SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
2729
- );
2725
+ logError(`[cloud-sync] sync_meta CREATE failed: ${e instanceof Error ? e.message : String(e)}`);
2730
2726
  }
2727
+ const pullMeta = await client.execute(
2728
+ "SELECT value FROM sync_meta WHERE key = 'last_cloud_pull_version'"
2729
+ );
2731
2730
  const lastPullVersion = pullMeta.rows.length > 0 ? Number(pullMeta.rows[0].value) : 0;
2732
2731
  const pullResult = await cloudPull(lastPullVersion, config);
2733
2732
  let pulled = 0;
@@ -2816,6 +2815,16 @@ async function cloudSync(config) {
2816
2815
  } catch (err) {
2817
2816
  logError(`[cloud-sync] Roster pull: ${err instanceof Error ? err.message : String(err)}`);
2818
2817
  }
2818
+ try {
2819
+ await cloudPushGlobalProcedures(config);
2820
+ } catch (err) {
2821
+ logError(`[cloud-sync] Global procedures push: ${err instanceof Error ? err.message : String(err)}`);
2822
+ }
2823
+ try {
2824
+ await cloudPullGlobalProcedures(config);
2825
+ } catch (err) {
2826
+ logError(`[cloud-sync] Global procedures pull: ${err instanceof Error ? err.message : String(err)}`);
2827
+ }
2819
2828
  let behaviorsResult = { pushed: false, pulled: 0 };
2820
2829
  try {
2821
2830
  behaviorsResult.pushed = await cloudPushBehaviors(config);
@@ -3129,6 +3138,43 @@ async function cloudPullBlob(route, config) {
3129
3138
  return null;
3130
3139
  }
3131
3140
  }
3141
+ async function cloudPushGlobalProcedures(config) {
3142
+ const client = getClient();
3143
+ const result = await client.execute("SELECT * FROM global_procedures LIMIT 1000");
3144
+ const rows = result.rows;
3145
+ const { ok } = await cloudPushBlob(
3146
+ "/sync/push-global-procedures",
3147
+ rows,
3148
+ "last_global_procedures_push_version",
3149
+ config
3150
+ );
3151
+ return ok;
3152
+ }
3153
+ async function cloudPullGlobalProcedures(config) {
3154
+ const remoteProcs = await cloudPullBlob(
3155
+ "/sync/pull-global-procedures",
3156
+ config
3157
+ );
3158
+ if (!remoteProcs || remoteProcs.length === 0) return { pulled: 0 };
3159
+ const client = getClient();
3160
+ const stmts = remoteProcs.map((p) => ({
3161
+ sql: `INSERT OR IGNORE INTO global_procedures
3162
+ (id, title, content, priority, domain, active, created_at, updated_at)
3163
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
3164
+ args: [
3165
+ p.id ?? null,
3166
+ p.title ?? null,
3167
+ p.content ?? null,
3168
+ p.priority ?? "p0",
3169
+ p.domain ?? null,
3170
+ p.active ?? 1,
3171
+ p.created_at ?? null,
3172
+ p.updated_at ?? null
3173
+ ]
3174
+ }));
3175
+ await client.batch(stmts, "write");
3176
+ return { pulled: remoteProcs.length };
3177
+ }
3132
3178
  async function cloudPushBehaviors(config) {
3133
3179
  const client = getClient();
3134
3180
  const result = await client.execute("SELECT * FROM behaviors LIMIT 10000");