@theokit/sdk 4.15.1 → 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 +13 -0
- package/dist/cron.cjs +72 -16
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.js +72 -16
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +72 -16
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +72 -16
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +73 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -16
- package/dist/index.js.map +1 -1
- package/dist/internal/persistence/index.cjs +37 -4
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +37 -4
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/persistence.cjs +37 -4
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +37 -4
- package/dist/persistence.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
10
|
+
## 4.15.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fix(providers): M47 adversarial-review fixes on the dynamic-loader trust gate — (F1) `Agent.resume` now runs provider-plugin discovery (a fresh process resuming a persisted agent whose model targets a plugin provider no longer fails resolution); (F2) `Theokit.models.list({provider})` local path runs discovery too (sync surfaces stay builtins-only, documented); (F3) the discovery idempotence flag moved to `globalThis` (`Symbol.for`) matching the registry's M44 B1 pattern — no duplicate discovery per bundle entry; (F4/F7) the NOT-trusted WARN now says "then restart the process" and documents the comma-separated env format; (F5) non-string entries in a valid trust-file array WARN instead of being silently discarded.
|
|
15
|
+
|
|
3
16
|
## 4.15.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/cron.cjs
CHANGED
|
@@ -7148,7 +7148,7 @@ var SkillsManager = class {
|
|
|
7148
7148
|
}
|
|
7149
7149
|
async refresh() {
|
|
7150
7150
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
7151
|
-
const
|
|
7151
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
7152
7152
|
onInvalidSkill: (info) => {
|
|
7153
7153
|
process.stderr.write(
|
|
7154
7154
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -7156,13 +7156,13 @@ var SkillsManager = class {
|
|
|
7156
7156
|
);
|
|
7157
7157
|
}
|
|
7158
7158
|
});
|
|
7159
|
-
this.skills = this.mergeInline(
|
|
7159
|
+
this.skills = this.mergeInline(discovered);
|
|
7160
7160
|
}
|
|
7161
7161
|
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
7162
|
-
mergeInline(
|
|
7163
|
-
if (this.inline === void 0 || this.inline.length === 0) return
|
|
7162
|
+
mergeInline(discovered) {
|
|
7163
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
7164
7164
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
7165
|
-
return [...
|
|
7165
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
7166
7166
|
}
|
|
7167
7167
|
list() {
|
|
7168
7168
|
return Promise.resolve(this.skills);
|
|
@@ -8720,7 +8720,7 @@ var FileContextManager = class {
|
|
|
8720
8720
|
const legacy = await loadSources(config, this.cwd);
|
|
8721
8721
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
8722
8722
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
8723
|
-
const
|
|
8723
|
+
const discovered = await runDiscovery({
|
|
8724
8724
|
cwd: this.cwd,
|
|
8725
8725
|
maxBytesPerFile,
|
|
8726
8726
|
touchedFiles
|
|
@@ -8733,7 +8733,7 @@ var FileContextManager = class {
|
|
|
8733
8733
|
// matches DEFAULT_DISCOVERY_SPECS theokit-context
|
|
8734
8734
|
truncated: false
|
|
8735
8735
|
}));
|
|
8736
|
-
const { kept } = applyAggregateCap([...
|
|
8736
|
+
const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
|
|
8737
8737
|
const loadedSources = kept.map((s) => ({
|
|
8738
8738
|
name: s.id,
|
|
8739
8739
|
path: s.source,
|
|
@@ -12036,7 +12036,15 @@ function registerBuiltins() {
|
|
|
12036
12036
|
registerProvider(CEREBRAS);
|
|
12037
12037
|
registerCatalogProviders();
|
|
12038
12038
|
}
|
|
12039
|
-
|
|
12039
|
+
function globalSingleton3(key, create) {
|
|
12040
|
+
const g = globalThis;
|
|
12041
|
+
const sym = Symbol.for(key);
|
|
12042
|
+
if (g[sym] === void 0) g[sym] = create();
|
|
12043
|
+
return g[sym];
|
|
12044
|
+
}
|
|
12045
|
+
var discoveryState = globalSingleton3("theokit-sdk.providers.discovered", () => ({
|
|
12046
|
+
done: false
|
|
12047
|
+
}));
|
|
12040
12048
|
function pluginsRoot() {
|
|
12041
12049
|
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
12042
12050
|
}
|
|
@@ -12050,8 +12058,16 @@ function loadTrustedNames() {
|
|
|
12050
12058
|
try {
|
|
12051
12059
|
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
12052
12060
|
if (Array.isArray(parsed)) {
|
|
12061
|
+
let discarded = 0;
|
|
12053
12062
|
for (const name of parsed) {
|
|
12054
12063
|
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
12064
|
+
else discarded += 1;
|
|
12065
|
+
}
|
|
12066
|
+
if (discarded > 0) {
|
|
12067
|
+
process.stderr.write(
|
|
12068
|
+
`[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
|
|
12069
|
+
`
|
|
12070
|
+
);
|
|
12055
12071
|
}
|
|
12056
12072
|
} else {
|
|
12057
12073
|
process.stderr.write(
|
|
@@ -12073,8 +12089,8 @@ function loadTrustedNames() {
|
|
|
12073
12089
|
return trusted;
|
|
12074
12090
|
}
|
|
12075
12091
|
async function discoverProviderPlugins() {
|
|
12076
|
-
if (
|
|
12077
|
-
|
|
12092
|
+
if (discoveryState.done) return;
|
|
12093
|
+
discoveryState.done = true;
|
|
12078
12094
|
const root = pluginsRoot();
|
|
12079
12095
|
if (!fs.existsSync(root)) return;
|
|
12080
12096
|
let entries;
|
|
@@ -12087,7 +12103,7 @@ async function discoverProviderPlugins() {
|
|
|
12087
12103
|
for (const entry of entries) {
|
|
12088
12104
|
if (!trusted.has(entry)) {
|
|
12089
12105
|
process.stderr.write(
|
|
12090
|
-
`[theokit-sdk] WARN: provider plugin "${entry}" is present but NOT trusted \u2014 skipped. To trust it, add "${entry}" to ${trustFilePath()} (JSON array) or THEOKIT_TRUSTED_PROVIDERS.
|
|
12106
|
+
`[theokit-sdk] WARN: provider plugin "${entry}" is present but NOT trusted \u2014 skipped. To trust it, add "${entry}" to ${trustFilePath()} (JSON array of names) or THEOKIT_TRUSTED_PROVIDERS (comma-separated), then restart the process.
|
|
12091
12107
|
`
|
|
12092
12108
|
);
|
|
12093
12109
|
continue;
|
|
@@ -16230,19 +16246,52 @@ async function openConcrete(options) {
|
|
|
16230
16246
|
await options.onOpen?.(db);
|
|
16231
16247
|
return db;
|
|
16232
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
|
+
}
|
|
16233
16274
|
async function loadDriver(filePath) {
|
|
16275
|
+
let betterSqliteCause;
|
|
16234
16276
|
try {
|
|
16235
|
-
const mod = await import('better-sqlite3');
|
|
16277
|
+
const mod = await (driverLoaderOverrides?.betterSqlite3?.() ?? import('better-sqlite3'));
|
|
16236
16278
|
const Ctor = mod.default ?? mod;
|
|
16237
16279
|
if (typeof Ctor !== "function") {
|
|
16238
16280
|
throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);
|
|
16239
16281
|
}
|
|
16240
16282
|
return new Ctor(filePath);
|
|
16241
16283
|
} catch (cause) {
|
|
16242
|
-
|
|
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);
|
|
16243
16292
|
throw new ConfigurationError(
|
|
16244
|
-
`Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`.
|
|
16245
|
-
{ 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 }
|
|
16246
16295
|
);
|
|
16247
16296
|
}
|
|
16248
16297
|
}
|
|
@@ -17279,8 +17328,14 @@ var LocalAgentMemory = class {
|
|
|
17279
17328
|
return this.toolsCache;
|
|
17280
17329
|
} catch (cause) {
|
|
17281
17330
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
17282
|
-
|
|
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}
|
|
17283
17337
|
`);
|
|
17338
|
+
}
|
|
17284
17339
|
return void 0;
|
|
17285
17340
|
}
|
|
17286
17341
|
}
|
|
@@ -18665,6 +18720,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
18665
18720
|
return process.cwd();
|
|
18666
18721
|
}
|
|
18667
18722
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
18723
|
+
await discoverProviderPlugins();
|
|
18668
18724
|
await validateRehydratedAgent(agentId, existing);
|
|
18669
18725
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
18670
18726
|
const mergedOptions = {
|