@theokit/sdk 4.15.2 → 4.15.3

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