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