@theokit/sdk 4.15.2 → 4.15.4

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/eval.js CHANGED
@@ -16238,19 +16238,56 @@ async function openConcrete(options) {
16238
16238
  await options.onOpen?.(db);
16239
16239
  return db;
16240
16240
  }
16241
+ var driverLoaderOverrides;
16242
+ function adaptNodeSqlite(db) {
16243
+ const pragma = (statement, options) => {
16244
+ const stmt = db.prepare(`PRAGMA ${statement}`);
16245
+ const row = stmt.get();
16246
+ if (options?.simple === true) {
16247
+ return row === void 0 ? void 0 : Object.values(row)[0];
16248
+ }
16249
+ return row === void 0 ? [] : [row];
16250
+ };
16251
+ return new Proxy(db, {
16252
+ get(target, prop, receiver) {
16253
+ if (prop === "pragma") return pragma;
16254
+ if (prop === "loadExtension" && typeof db.loadExtension !== "function") {
16255
+ return () => {
16256
+ throw new Error(
16257
+ "SQLite extension loading is unavailable on the node:sqlite fallback \u2014 install better-sqlite3 for sqlite-vec"
16258
+ );
16259
+ };
16260
+ }
16261
+ const value = Reflect.get(target, prop, receiver);
16262
+ return typeof value === "function" ? value.bind(target) : value;
16263
+ }
16264
+ });
16265
+ }
16241
16266
  async function loadDriver(filePath) {
16267
+ let betterSqliteCause;
16242
16268
  try {
16243
- const mod = await import('better-sqlite3');
16269
+ const mod = await (driverLoaderOverrides?.betterSqlite3?.() ?? import('better-sqlite3'));
16244
16270
  const Ctor = mod.default ?? mod;
16245
16271
  if (typeof Ctor !== "function") {
16246
16272
  throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);
16247
16273
  }
16248
16274
  return new Ctor(filePath);
16249
16275
  } catch (cause) {
16250
- const message = cause instanceof Error ? cause.message : String(cause);
16276
+ betterSqliteCause = cause;
16277
+ }
16278
+ try {
16279
+ const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? Promise.resolve(
16280
+ process.getBuiltinModule?.("node:sqlite") ?? (() => {
16281
+ throw new Error("node:sqlite built-in unavailable (Node < 22.3)");
16282
+ })()
16283
+ ));
16284
+ return adaptNodeSqlite(new mod.DatabaseSync(filePath));
16285
+ } catch (nodeSqliteCause) {
16286
+ const b = betterSqliteCause instanceof Error ? betterSqliteCause.message : String(betterSqliteCause);
16287
+ const n = nodeSqliteCause instanceof Error ? nodeSqliteCause.message : String(nodeSqliteCause);
16251
16288
  throw new ConfigurationError(
16252
- `Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`. Cause: ${message}`,
16253
- { code: "sqlite_driver_unavailable", cause }
16289
+ `Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`. better-sqlite3: ${b}; node:sqlite: ${n}`,
16290
+ { code: "sqlite_driver_unavailable", cause: nodeSqliteCause }
16254
16291
  );
16255
16292
  }
16256
16293
  }
@@ -17287,8 +17324,14 @@ var LocalAgentMemory = class {
17287
17324
  return this.toolsCache;
17288
17325
  } catch (cause) {
17289
17326
  const message = cause instanceof Error ? cause.message : String(cause);
17290
- process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
17327
+ const g = globalThis;
17328
+ const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.memory.warned");
17329
+ const warned3 = g[sym] ??= /* @__PURE__ */ new Set();
17330
+ if (!warned3.has(message)) {
17331
+ warned3.add(message);
17332
+ process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
17291
17333
  `);
17334
+ }
17292
17335
  return void 0;
17293
17336
  }
17294
17337
  }