@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.js
CHANGED
|
@@ -1790,19 +1790,51 @@ async function openConcrete(options) {
|
|
|
1790
1790
|
await options.onOpen?.(db);
|
|
1791
1791
|
return db;
|
|
1792
1792
|
}
|
|
1793
|
+
function adaptNodeSqlite(db) {
|
|
1794
|
+
const pragma = (statement, options) => {
|
|
1795
|
+
const stmt = db.prepare(`PRAGMA ${statement}`);
|
|
1796
|
+
const row = stmt.get();
|
|
1797
|
+
if (options?.simple === true) {
|
|
1798
|
+
return row === void 0 ? void 0 : Object.values(row)[0];
|
|
1799
|
+
}
|
|
1800
|
+
return row === void 0 ? [] : [row];
|
|
1801
|
+
};
|
|
1802
|
+
return new Proxy(db, {
|
|
1803
|
+
get(target, prop, receiver) {
|
|
1804
|
+
if (prop === "pragma") return pragma;
|
|
1805
|
+
if (prop === "loadExtension" && typeof db.loadExtension !== "function") {
|
|
1806
|
+
return () => {
|
|
1807
|
+
throw new Error(
|
|
1808
|
+
"SQLite extension loading is unavailable on the node:sqlite fallback \u2014 install better-sqlite3 for sqlite-vec"
|
|
1809
|
+
);
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
const value = Reflect.get(target, prop, receiver);
|
|
1813
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1793
1817
|
async function loadDriver(filePath) {
|
|
1818
|
+
let betterSqliteCause;
|
|
1794
1819
|
try {
|
|
1795
|
-
const mod = await import('better-sqlite3');
|
|
1820
|
+
const mod = await (driverLoaderOverrides?.betterSqlite3?.() ?? import('better-sqlite3'));
|
|
1796
1821
|
const Ctor = mod.default ?? mod;
|
|
1797
1822
|
if (typeof Ctor !== "function") {
|
|
1798
1823
|
throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);
|
|
1799
1824
|
}
|
|
1800
1825
|
return new Ctor(filePath);
|
|
1801
1826
|
} catch (cause) {
|
|
1802
|
-
|
|
1827
|
+
betterSqliteCause = cause;
|
|
1828
|
+
}
|
|
1829
|
+
try {
|
|
1830
|
+
const mod = await (driverLoaderOverrides?.nodeSqlite?.() ?? import('sqlite'));
|
|
1831
|
+
return adaptNodeSqlite(new mod.DatabaseSync(filePath));
|
|
1832
|
+
} catch (nodeSqliteCause) {
|
|
1833
|
+
const b = betterSqliteCause instanceof Error ? betterSqliteCause.message : String(betterSqliteCause);
|
|
1834
|
+
const n = nodeSqliteCause instanceof Error ? nodeSqliteCause.message : String(nodeSqliteCause);
|
|
1803
1835
|
throw new ConfigurationError(
|
|
1804
|
-
`Failed to load SQLite driver. Install \`better-sqlite3\` or run on Node 22.5+ for built-in \`node:sqlite\`.
|
|
1805
|
-
{ code: "sqlite_driver_unavailable", cause }
|
|
1836
|
+
`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}`,
|
|
1837
|
+
{ code: "sqlite_driver_unavailable", cause: nodeSqliteCause }
|
|
1806
1838
|
);
|
|
1807
1839
|
}
|
|
1808
1840
|
}
|
|
@@ -1821,6 +1853,7 @@ async function renameAside(filePath, label) {
|
|
|
1821
1853
|
`
|
|
1822
1854
|
);
|
|
1823
1855
|
}
|
|
1856
|
+
var driverLoaderOverrides;
|
|
1824
1857
|
var init_sqlite_open = __esm({
|
|
1825
1858
|
"src/internal/persistence/sqlite-open.ts"() {
|
|
1826
1859
|
init_errors();
|
|
@@ -9723,7 +9756,7 @@ var SkillsManager = class {
|
|
|
9723
9756
|
}
|
|
9724
9757
|
async refresh() {
|
|
9725
9758
|
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
9726
|
-
const
|
|
9759
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
9727
9760
|
onInvalidSkill: (info) => {
|
|
9728
9761
|
process.stderr.write(
|
|
9729
9762
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -9731,13 +9764,13 @@ var SkillsManager = class {
|
|
|
9731
9764
|
);
|
|
9732
9765
|
}
|
|
9733
9766
|
});
|
|
9734
|
-
this.skills = this.mergeInline(
|
|
9767
|
+
this.skills = this.mergeInline(discovered);
|
|
9735
9768
|
}
|
|
9736
9769
|
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
9737
|
-
mergeInline(
|
|
9738
|
-
if (this.inline === void 0 || this.inline.length === 0) return
|
|
9770
|
+
mergeInline(discovered) {
|
|
9771
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
9739
9772
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
9740
|
-
return [...
|
|
9773
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
9741
9774
|
}
|
|
9742
9775
|
list() {
|
|
9743
9776
|
return Promise.resolve(this.skills);
|
|
@@ -11298,7 +11331,7 @@ var FileContextManager = class {
|
|
|
11298
11331
|
const legacy = await loadSources(config, this.cwd);
|
|
11299
11332
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
11300
11333
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
11301
|
-
const
|
|
11334
|
+
const discovered = await runDiscovery({
|
|
11302
11335
|
cwd: this.cwd,
|
|
11303
11336
|
maxBytesPerFile,
|
|
11304
11337
|
touchedFiles
|
|
@@ -11311,7 +11344,7 @@ var FileContextManager = class {
|
|
|
11311
11344
|
// matches DEFAULT_DISCOVERY_SPECS theokit-context
|
|
11312
11345
|
truncated: false
|
|
11313
11346
|
}));
|
|
11314
|
-
const { kept } = applyAggregateCap([...
|
|
11347
|
+
const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
|
|
11315
11348
|
const loadedSources = kept.map((s) => ({
|
|
11316
11349
|
name: s.id,
|
|
11317
11350
|
path: s.source,
|
|
@@ -14632,7 +14665,15 @@ function registerBuiltins() {
|
|
|
14632
14665
|
registerProvider(CEREBRAS);
|
|
14633
14666
|
registerCatalogProviders();
|
|
14634
14667
|
}
|
|
14635
|
-
|
|
14668
|
+
function globalSingleton3(key2, create) {
|
|
14669
|
+
const g = globalThis;
|
|
14670
|
+
const sym = Symbol.for(key2);
|
|
14671
|
+
if (g[sym] === void 0) g[sym] = create();
|
|
14672
|
+
return g[sym];
|
|
14673
|
+
}
|
|
14674
|
+
var discoveryState = globalSingleton3("theokit-sdk.providers.discovered", () => ({
|
|
14675
|
+
done: false
|
|
14676
|
+
}));
|
|
14636
14677
|
function pluginsRoot() {
|
|
14637
14678
|
return join(homedir(), ".theokit", "plugins", "model-providers");
|
|
14638
14679
|
}
|
|
@@ -14646,8 +14687,16 @@ function loadTrustedNames() {
|
|
|
14646
14687
|
try {
|
|
14647
14688
|
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
14648
14689
|
if (Array.isArray(parsed)) {
|
|
14690
|
+
let discarded = 0;
|
|
14649
14691
|
for (const name of parsed) {
|
|
14650
14692
|
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
14693
|
+
else discarded += 1;
|
|
14694
|
+
}
|
|
14695
|
+
if (discarded > 0) {
|
|
14696
|
+
process.stderr.write(
|
|
14697
|
+
`[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
|
|
14698
|
+
`
|
|
14699
|
+
);
|
|
14651
14700
|
}
|
|
14652
14701
|
} else {
|
|
14653
14702
|
process.stderr.write(
|
|
@@ -14669,8 +14718,8 @@ function loadTrustedNames() {
|
|
|
14669
14718
|
return trusted;
|
|
14670
14719
|
}
|
|
14671
14720
|
async function discoverProviderPlugins() {
|
|
14672
|
-
if (
|
|
14673
|
-
|
|
14721
|
+
if (discoveryState.done) return;
|
|
14722
|
+
discoveryState.done = true;
|
|
14674
14723
|
const root = pluginsRoot();
|
|
14675
14724
|
if (!existsSync(root)) return;
|
|
14676
14725
|
let entries;
|
|
@@ -14683,7 +14732,7 @@ async function discoverProviderPlugins() {
|
|
|
14683
14732
|
for (const entry of entries) {
|
|
14684
14733
|
if (!trusted.has(entry)) {
|
|
14685
14734
|
process.stderr.write(
|
|
14686
|
-
`[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.
|
|
14735
|
+
`[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.
|
|
14687
14736
|
`
|
|
14688
14737
|
);
|
|
14689
14738
|
continue;
|
|
@@ -18928,8 +18977,14 @@ var LocalAgentMemory = class {
|
|
|
18928
18977
|
return this.toolsCache;
|
|
18929
18978
|
} catch (cause) {
|
|
18930
18979
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
18931
|
-
|
|
18980
|
+
const g = globalThis;
|
|
18981
|
+
const sym = /* @__PURE__ */ Symbol.for("theokit-sdk.memory.warned");
|
|
18982
|
+
const warned3 = g[sym] ??= /* @__PURE__ */ new Set();
|
|
18983
|
+
if (!warned3.has(message)) {
|
|
18984
|
+
warned3.add(message);
|
|
18985
|
+
process.stderr.write(`[theokit-sdk] memory tools unavailable: ${message}
|
|
18932
18986
|
`);
|
|
18987
|
+
}
|
|
18933
18988
|
return void 0;
|
|
18934
18989
|
}
|
|
18935
18990
|
}
|
|
@@ -20315,6 +20370,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
20315
20370
|
return process.cwd();
|
|
20316
20371
|
}
|
|
20317
20372
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
20373
|
+
await discoverProviderPlugins();
|
|
20318
20374
|
await validateRehydratedAgent(agentId, existing);
|
|
20319
20375
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
20320
20376
|
const mergedOptions = {
|
|
@@ -23393,6 +23449,7 @@ var Theokit = class {
|
|
|
23393
23449
|
};
|
|
23394
23450
|
async function maybeListLocalModels(providerName) {
|
|
23395
23451
|
registerBuiltins();
|
|
23452
|
+
await discoverProviderPlugins();
|
|
23396
23453
|
const profile = getProviderProfile(providerName);
|
|
23397
23454
|
if (profile === void 0) return void 0;
|
|
23398
23455
|
if (profile.authType !== "none") return void 0;
|