@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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.15.3
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(persistence): implement the `node:sqlite` fallback the SQLite driver-load error message has always promised — on Node 22.5+ without the optional `better-sqlite3`, memory tools now work via the built-in driver (adapter shims `pragma()`; `loadExtension` degrades with a clear error). Previously only better-sqlite3 was tried, so every consumer without the native dep silently lost memory tools.
8
+ - fix(memory): the "memory tools unavailable" WARN is now emitted ONCE per process per distinct message (globalThis registry) — it used to repeat on every `Agent.create` (the TUI creates one per turn), and raw stderr mid-frame corrupts Ink-style renderers (the flicker/duplicate-greeting bug).
9
+
3
10
  ## 4.15.2
4
11
 
5
12
  ### Patch Changes
package/dist/cron.cjs CHANGED
@@ -16246,19 +16246,52 @@ async function openConcrete(options) {
16246
16246
  await options.onOpen?.(db);
16247
16247
  return db;
16248
16248
  }
16249
+ var driverLoaderOverrides;
16250
+ function adaptNodeSqlite(db) {
16251
+ const pragma = (statement, options) => {
16252
+ const stmt = db.prepare(`PRAGMA ${statement}`);
16253
+ const row = stmt.get();
16254
+ if (options?.simple === true) {
16255
+ return row === void 0 ? void 0 : Object.values(row)[0];
16256
+ }
16257
+ return row === void 0 ? [] : [row];
16258
+ };
16259
+ return new Proxy(db, {
16260
+ get(target, prop, receiver) {
16261
+ if (prop === "pragma") return pragma;
16262
+ if (prop === "loadExtension" && typeof db.loadExtension !== "function") {
16263
+ return () => {
16264
+ throw new Error(
16265
+ "SQLite extension loading is unavailable on the node:sqlite fallback \u2014 install better-sqlite3 for sqlite-vec"
16266
+ );
16267
+ };
16268
+ }
16269
+ const value = Reflect.get(target, prop, receiver);
16270
+ return typeof value === "function" ? value.bind(target) : value;
16271
+ }
16272
+ });
16273
+ }
16249
16274
  async function loadDriver(filePath) {
16275
+ let betterSqliteCause;
16250
16276
  try {
16251
- const mod = await import('better-sqlite3');
16277
+ const mod = await (driverLoaderOverrides?.betterSqlite3?.() ?? import('better-sqlite3'));
16252
16278
  const Ctor = mod.default ?? mod;
16253
16279
  if (typeof Ctor !== "function") {
16254
16280
  throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);
16255
16281
  }
16256
16282
  return new Ctor(filePath);
16257
16283
  } catch (cause) {
16258
- const message = cause instanceof Error ? cause.message : String(cause);
16284
+ betterSqliteCause = cause;
16285
+ }
16286
+ try {
16287
+ const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? import('sqlite'));
16288
+ return adaptNodeSqlite(new mod.DatabaseSync(filePath));
16289
+ } catch (nodeSqliteCause) {
16290
+ const b = betterSqliteCause instanceof Error ? betterSqliteCause.message : String(betterSqliteCause);
16291
+ const n = nodeSqliteCause instanceof Error ? nodeSqliteCause.message : String(nodeSqliteCause);
16259
16292
  throw new ConfigurationError(
16260
- `Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`. Cause: ${message}`,
16261
- { code: "sqlite_driver_unavailable", cause }
16293
+ `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}`,
16294
+ { code: "sqlite_driver_unavailable", cause: nodeSqliteCause }
16262
16295
  );
16263
16296
  }
16264
16297
  }
@@ -17295,8 +17328,14 @@ var LocalAgentMemory = class {
17295
17328
  return this.toolsCache;
17296
17329
  } catch (cause) {
17297
17330
  const message = cause instanceof Error ? cause.message : String(cause);
17298
- process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
17331
+ const g = globalThis;
17332
+ const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.memory.warned");
17333
+ const warned3 = g[sym] ??= /* @__PURE__ */ new Set();
17334
+ if (!warned3.has(message)) {
17335
+ warned3.add(message);
17336
+ process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
17299
17337
  `);
17338
+ }
17300
17339
  return void 0;
17301
17340
  }
17302
17341
  }