@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/dist/eval.cjs
CHANGED
|
@@ -7143,7 +7143,7 @@ var SkillsManager = class {
|
|
|
7143
7143
|
}
|
|
7144
7144
|
async refresh() {
|
|
7145
7145
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
7146
|
-
const
|
|
7146
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
7147
7147
|
onInvalidSkill: (info) => {
|
|
7148
7148
|
process.stderr.write(
|
|
7149
7149
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -7151,13 +7151,13 @@ var SkillsManager = class {
|
|
|
7151
7151
|
);
|
|
7152
7152
|
}
|
|
7153
7153
|
});
|
|
7154
|
-
this.skills = this.mergeInline(
|
|
7154
|
+
this.skills = this.mergeInline(discovered);
|
|
7155
7155
|
}
|
|
7156
7156
|
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
7157
|
-
mergeInline(
|
|
7158
|
-
if (this.inline === void 0 || this.inline.length === 0) return
|
|
7157
|
+
mergeInline(discovered) {
|
|
7158
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
7159
7159
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
7160
|
-
return [...
|
|
7160
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
7161
7161
|
}
|
|
7162
7162
|
list() {
|
|
7163
7163
|
return Promise.resolve(this.skills);
|
|
@@ -8715,7 +8715,7 @@ var FileContextManager = class {
|
|
|
8715
8715
|
const legacy = await loadSources(config, this.cwd);
|
|
8716
8716
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
8717
8717
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
8718
|
-
const
|
|
8718
|
+
const discovered = await runDiscovery({
|
|
8719
8719
|
cwd: this.cwd,
|
|
8720
8720
|
maxBytesPerFile,
|
|
8721
8721
|
touchedFiles
|
|
@@ -8728,7 +8728,7 @@ var FileContextManager = class {
|
|
|
8728
8728
|
// matches DEFAULT_DISCOVERY_SPECS theokit-context
|
|
8729
8729
|
truncated: false
|
|
8730
8730
|
}));
|
|
8731
|
-
const { kept } = applyAggregateCap([...
|
|
8731
|
+
const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
|
|
8732
8732
|
const loadedSources = kept.map((s) => ({
|
|
8733
8733
|
name: s.id,
|
|
8734
8734
|
path: s.source,
|
|
@@ -12031,7 +12031,15 @@ function registerBuiltins() {
|
|
|
12031
12031
|
registerProvider(CEREBRAS);
|
|
12032
12032
|
registerCatalogProviders();
|
|
12033
12033
|
}
|
|
12034
|
-
|
|
12034
|
+
function globalSingleton3(key, create) {
|
|
12035
|
+
const g = globalThis;
|
|
12036
|
+
const sym = Symbol.for(key);
|
|
12037
|
+
if (g[sym] === void 0) g[sym] = create();
|
|
12038
|
+
return g[sym];
|
|
12039
|
+
}
|
|
12040
|
+
var discoveryState = globalSingleton3("theokit-sdk.providers.discovered", () => ({
|
|
12041
|
+
done: false
|
|
12042
|
+
}));
|
|
12035
12043
|
function pluginsRoot() {
|
|
12036
12044
|
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
12037
12045
|
}
|
|
@@ -12045,8 +12053,16 @@ function loadTrustedNames() {
|
|
|
12045
12053
|
try {
|
|
12046
12054
|
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
12047
12055
|
if (Array.isArray(parsed)) {
|
|
12056
|
+
let discarded = 0;
|
|
12048
12057
|
for (const name of parsed) {
|
|
12049
12058
|
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
12059
|
+
else discarded += 1;
|
|
12060
|
+
}
|
|
12061
|
+
if (discarded > 0) {
|
|
12062
|
+
process.stderr.write(
|
|
12063
|
+
`[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
|
|
12064
|
+
`
|
|
12065
|
+
);
|
|
12050
12066
|
}
|
|
12051
12067
|
} else {
|
|
12052
12068
|
process.stderr.write(
|
|
@@ -12068,8 +12084,8 @@ function loadTrustedNames() {
|
|
|
12068
12084
|
return trusted;
|
|
12069
12085
|
}
|
|
12070
12086
|
async function discoverProviderPlugins() {
|
|
12071
|
-
if (
|
|
12072
|
-
|
|
12087
|
+
if (discoveryState.done) return;
|
|
12088
|
+
discoveryState.done = true;
|
|
12073
12089
|
const root = pluginsRoot();
|
|
12074
12090
|
if (!fs.existsSync(root)) return;
|
|
12075
12091
|
let entries;
|
|
@@ -12082,7 +12098,7 @@ async function discoverProviderPlugins() {
|
|
|
12082
12098
|
for (const entry of entries) {
|
|
12083
12099
|
if (!trusted.has(entry)) {
|
|
12084
12100
|
process.stderr.write(
|
|
12085
|
-
`[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.
|
|
12101
|
+
`[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.
|
|
12086
12102
|
`
|
|
12087
12103
|
);
|
|
12088
12104
|
continue;
|
|
@@ -16225,19 +16241,52 @@ async function openConcrete(options) {
|
|
|
16225
16241
|
await options.onOpen?.(db);
|
|
16226
16242
|
return db;
|
|
16227
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
|
+
}
|
|
16228
16269
|
async function loadDriver(filePath) {
|
|
16270
|
+
let betterSqliteCause;
|
|
16229
16271
|
try {
|
|
16230
|
-
const mod = await import('better-sqlite3');
|
|
16272
|
+
const mod = await (driverLoaderOverrides?.betterSqlite3?.() ?? import('better-sqlite3'));
|
|
16231
16273
|
const Ctor = mod.default ?? mod;
|
|
16232
16274
|
if (typeof Ctor !== "function") {
|
|
16233
16275
|
throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);
|
|
16234
16276
|
}
|
|
16235
16277
|
return new Ctor(filePath);
|
|
16236
16278
|
} catch (cause) {
|
|
16237
|
-
|
|
16279
|
+
betterSqliteCause = cause;
|
|
16280
|
+
}
|
|
16281
|
+
try {
|
|
16282
|
+
const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? import('sqlite'));
|
|
16283
|
+
return adaptNodeSqlite(new mod.DatabaseSync(filePath));
|
|
16284
|
+
} catch (nodeSqliteCause) {
|
|
16285
|
+
const b = betterSqliteCause instanceof Error ? betterSqliteCause.message : String(betterSqliteCause);
|
|
16286
|
+
const n = nodeSqliteCause instanceof Error ? nodeSqliteCause.message : String(nodeSqliteCause);
|
|
16238
16287
|
throw new ConfigurationError(
|
|
16239
|
-
`Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`.
|
|
16240
|
-
{ code: "sqlite_driver_unavailable", cause }
|
|
16288
|
+
`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}`,
|
|
16289
|
+
{ code: "sqlite_driver_unavailable", cause: nodeSqliteCause }
|
|
16241
16290
|
);
|
|
16242
16291
|
}
|
|
16243
16292
|
}
|
|
@@ -17274,8 +17323,14 @@ var LocalAgentMemory = class {
|
|
|
17274
17323
|
return this.toolsCache;
|
|
17275
17324
|
} catch (cause) {
|
|
17276
17325
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
17277
|
-
|
|
17326
|
+
const g = globalThis;
|
|
17327
|
+
const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.memory.warned");
|
|
17328
|
+
const warned3 = g[sym] ??= /* @__PURE__ */ new Set();
|
|
17329
|
+
if (!warned3.has(message)) {
|
|
17330
|
+
warned3.add(message);
|
|
17331
|
+
process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
|
|
17278
17332
|
`);
|
|
17333
|
+
}
|
|
17279
17334
|
return void 0;
|
|
17280
17335
|
}
|
|
17281
17336
|
}
|
|
@@ -18660,6 +18715,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
18660
18715
|
return process.cwd();
|
|
18661
18716
|
}
|
|
18662
18717
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
18718
|
+
await discoverProviderPlugins();
|
|
18663
18719
|
await validateRehydratedAgent(agentId, existing);
|
|
18664
18720
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
18665
18721
|
const mergedOptions = {
|