@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/index.cjs
CHANGED
|
@@ -1793,19 +1793,51 @@ async function openConcrete(options) {
|
|
|
1793
1793
|
await options.onOpen?.(db);
|
|
1794
1794
|
return db;
|
|
1795
1795
|
}
|
|
1796
|
+
function adaptNodeSqlite(db) {
|
|
1797
|
+
const pragma = (statement, options) => {
|
|
1798
|
+
const stmt = db.prepare(`PRAGMA ${statement}`);
|
|
1799
|
+
const row = stmt.get();
|
|
1800
|
+
if (options?.simple === true) {
|
|
1801
|
+
return row === void 0 ? void 0 : Object.values(row)[0];
|
|
1802
|
+
}
|
|
1803
|
+
return row === void 0 ? [] : [row];
|
|
1804
|
+
};
|
|
1805
|
+
return new Proxy(db, {
|
|
1806
|
+
get(target, prop, receiver) {
|
|
1807
|
+
if (prop === "pragma") return pragma;
|
|
1808
|
+
if (prop === "loadExtension" && typeof db.loadExtension !== "function") {
|
|
1809
|
+
return () => {
|
|
1810
|
+
throw new Error(
|
|
1811
|
+
"SQLite extension loading is unavailable on the node:sqlite fallback \u2014 install better-sqlite3 for sqlite-vec"
|
|
1812
|
+
);
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
const value = Reflect.get(target, prop, receiver);
|
|
1816
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
1817
|
+
}
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1796
1820
|
async function loadDriver(filePath) {
|
|
1821
|
+
let betterSqliteCause;
|
|
1797
1822
|
try {
|
|
1798
|
-
const mod = await import('better-sqlite3');
|
|
1823
|
+
const mod = await (driverLoaderOverrides?.betterSqlite3?.() ?? import('better-sqlite3'));
|
|
1799
1824
|
const Ctor = mod.default ?? mod;
|
|
1800
1825
|
if (typeof Ctor !== "function") {
|
|
1801
1826
|
throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);
|
|
1802
1827
|
}
|
|
1803
1828
|
return new Ctor(filePath);
|
|
1804
1829
|
} catch (cause) {
|
|
1805
|
-
|
|
1830
|
+
betterSqliteCause = cause;
|
|
1831
|
+
}
|
|
1832
|
+
try {
|
|
1833
|
+
const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? import('sqlite'));
|
|
1834
|
+
return adaptNodeSqlite(new mod.DatabaseSync(filePath));
|
|
1835
|
+
} catch (nodeSqliteCause) {
|
|
1836
|
+
const b = betterSqliteCause instanceof Error ? betterSqliteCause.message : String(betterSqliteCause);
|
|
1837
|
+
const n = nodeSqliteCause instanceof Error ? nodeSqliteCause.message : String(nodeSqliteCause);
|
|
1806
1838
|
throw new exports.ConfigurationError(
|
|
1807
|
-
`Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`.
|
|
1808
|
-
{ code: "sqlite_driver_unavailable", cause }
|
|
1839
|
+
`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}`,
|
|
1840
|
+
{ code: "sqlite_driver_unavailable", cause: nodeSqliteCause }
|
|
1809
1841
|
);
|
|
1810
1842
|
}
|
|
1811
1843
|
}
|
|
@@ -1824,6 +1856,7 @@ async function renameAside(filePath, label) {
|
|
|
1824
1856
|
`
|
|
1825
1857
|
);
|
|
1826
1858
|
}
|
|
1859
|
+
var driverLoaderOverrides;
|
|
1827
1860
|
var init_sqlite_open = __esm({
|
|
1828
1861
|
"src/internal/persistence/sqlite-open.ts"() {
|
|
1829
1862
|
init_errors();
|
|
@@ -9726,7 +9759,7 @@ var SkillsManager = class {
|
|
|
9726
9759
|
}
|
|
9727
9760
|
async refresh() {
|
|
9728
9761
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
9729
|
-
const
|
|
9762
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
9730
9763
|
onInvalidSkill: (info) => {
|
|
9731
9764
|
process.stderr.write(
|
|
9732
9765
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -9734,13 +9767,13 @@ var SkillsManager = class {
|
|
|
9734
9767
|
);
|
|
9735
9768
|
}
|
|
9736
9769
|
});
|
|
9737
|
-
this.skills = this.mergeInline(
|
|
9770
|
+
this.skills = this.mergeInline(discovered);
|
|
9738
9771
|
}
|
|
9739
9772
|
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
9740
|
-
mergeInline(
|
|
9741
|
-
if (this.inline === void 0 || this.inline.length === 0) return
|
|
9773
|
+
mergeInline(discovered) {
|
|
9774
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
9742
9775
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
9743
|
-
return [...
|
|
9776
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
9744
9777
|
}
|
|
9745
9778
|
list() {
|
|
9746
9779
|
return Promise.resolve(this.skills);
|
|
@@ -11301,7 +11334,7 @@ var FileContextManager = class {
|
|
|
11301
11334
|
const legacy = await loadSources(config, this.cwd);
|
|
11302
11335
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
11303
11336
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
11304
|
-
const
|
|
11337
|
+
const discovered = await runDiscovery({
|
|
11305
11338
|
cwd: this.cwd,
|
|
11306
11339
|
maxBytesPerFile,
|
|
11307
11340
|
touchedFiles
|
|
@@ -11314,7 +11347,7 @@ var FileContextManager = class {
|
|
|
11314
11347
|
// matches DEFAULT_DISCOVERY_SPECS theokit-context
|
|
11315
11348
|
truncated: false
|
|
11316
11349
|
}));
|
|
11317
|
-
const { kept } = applyAggregateCap([...
|
|
11350
|
+
const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
|
|
11318
11351
|
const loadedSources = kept.map((s) => ({
|
|
11319
11352
|
name: s.id,
|
|
11320
11353
|
path: s.source,
|
|
@@ -14635,7 +14668,15 @@ function registerBuiltins() {
|
|
|
14635
14668
|
registerProvider(CEREBRAS);
|
|
14636
14669
|
registerCatalogProviders();
|
|
14637
14670
|
}
|
|
14638
|
-
|
|
14671
|
+
function globalSingleton3(key2, create) {
|
|
14672
|
+
const g = globalThis;
|
|
14673
|
+
const sym = Symbol.for(key2);
|
|
14674
|
+
if (g[sym] === void 0) g[sym] = create();
|
|
14675
|
+
return g[sym];
|
|
14676
|
+
}
|
|
14677
|
+
var discoveryState = globalSingleton3("theokit-sdk.providers.discovered", () => ({
|
|
14678
|
+
done: false
|
|
14679
|
+
}));
|
|
14639
14680
|
function pluginsRoot() {
|
|
14640
14681
|
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
14641
14682
|
}
|
|
@@ -14649,8 +14690,16 @@ function loadTrustedNames() {
|
|
|
14649
14690
|
try {
|
|
14650
14691
|
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
14651
14692
|
if (Array.isArray(parsed)) {
|
|
14693
|
+
let discarded = 0;
|
|
14652
14694
|
for (const name of parsed) {
|
|
14653
14695
|
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
14696
|
+
else discarded += 1;
|
|
14697
|
+
}
|
|
14698
|
+
if (discarded > 0) {
|
|
14699
|
+
process.stderr.write(
|
|
14700
|
+
`[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
|
|
14701
|
+
`
|
|
14702
|
+
);
|
|
14654
14703
|
}
|
|
14655
14704
|
} else {
|
|
14656
14705
|
process.stderr.write(
|
|
@@ -14672,8 +14721,8 @@ function loadTrustedNames() {
|
|
|
14672
14721
|
return trusted;
|
|
14673
14722
|
}
|
|
14674
14723
|
async function discoverProviderPlugins() {
|
|
14675
|
-
if (
|
|
14676
|
-
|
|
14724
|
+
if (discoveryState.done) return;
|
|
14725
|
+
discoveryState.done = true;
|
|
14677
14726
|
const root = pluginsRoot();
|
|
14678
14727
|
if (!fs.existsSync(root)) return;
|
|
14679
14728
|
let entries;
|
|
@@ -14686,7 +14735,7 @@ async function discoverProviderPlugins() {
|
|
|
14686
14735
|
for (const entry of entries) {
|
|
14687
14736
|
if (!trusted.has(entry)) {
|
|
14688
14737
|
process.stderr.write(
|
|
14689
|
-
`[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.
|
|
14738
|
+
`[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.
|
|
14690
14739
|
`
|
|
14691
14740
|
);
|
|
14692
14741
|
continue;
|
|
@@ -18931,8 +18980,14 @@ var LocalAgentMemory = class {
|
|
|
18931
18980
|
return this.toolsCache;
|
|
18932
18981
|
} catch (cause) {
|
|
18933
18982
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
18934
|
-
|
|
18983
|
+
const g = globalThis;
|
|
18984
|
+
const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.memory.warned");
|
|
18985
|
+
const warned3 = g[sym] ??= /* @__PURE__ */ new Set();
|
|
18986
|
+
if (!warned3.has(message)) {
|
|
18987
|
+
warned3.add(message);
|
|
18988
|
+
process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
|
|
18935
18989
|
`);
|
|
18990
|
+
}
|
|
18936
18991
|
return void 0;
|
|
18937
18992
|
}
|
|
18938
18993
|
}
|
|
@@ -20318,6 +20373,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
20318
20373
|
return process.cwd();
|
|
20319
20374
|
}
|
|
20320
20375
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
20376
|
+
await discoverProviderPlugins();
|
|
20321
20377
|
await validateRehydratedAgent(agentId, existing);
|
|
20322
20378
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
20323
20379
|
const mergedOptions = {
|
|
@@ -23396,6 +23452,7 @@ var Theokit = class {
|
|
|
23396
23452
|
};
|
|
23397
23453
|
async function maybeListLocalModels(providerName) {
|
|
23398
23454
|
registerBuiltins();
|
|
23455
|
+
await discoverProviderPlugins();
|
|
23399
23456
|
const profile = getProviderProfile(providerName);
|
|
23400
23457
|
if (profile === void 0) return void 0;
|
|
23401
23458
|
if (profile.authType !== "none") return void 0;
|