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