@theokit/sdk 4.15.0 → 4.15.2
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 +12 -0
- package/dist/cron.cjs +107 -8
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.js +110 -11
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +107 -8
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +110 -11
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +108 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +109 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/eval.cjs
CHANGED
|
@@ -8935,14 +8935,14 @@ var PluginsManager = class {
|
|
|
8935
8935
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + both-present detection per plugin folder — branch table is clearer inlined.
|
|
8936
8936
|
async refresh() {
|
|
8937
8937
|
this.plugins = [];
|
|
8938
|
-
const
|
|
8939
|
-
const entries = await readWorkspaceDir(
|
|
8938
|
+
const pluginsRoot2 = path.join(this.cwd, ".theokit", "plugins");
|
|
8939
|
+
const entries = await readWorkspaceDir(pluginsRoot2, "plugins_read_error", "plugins directory");
|
|
8940
8940
|
for (const entry of entries) {
|
|
8941
8941
|
if (!entry.isDirectory()) continue;
|
|
8942
8942
|
const folderName = entry.name;
|
|
8943
|
-
const mdPath = path.join(
|
|
8944
|
-
const jsonPath = path.join(
|
|
8945
|
-
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(
|
|
8943
|
+
const mdPath = path.join(pluginsRoot2, folderName, "PLUGIN.md");
|
|
8944
|
+
const jsonPath = path.join(pluginsRoot2, folderName, "plugin.json");
|
|
8945
|
+
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot2, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
8946
8946
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
8947
8947
|
warnOnce(
|
|
8948
8948
|
`plugin-${folderName}-both`,
|
|
@@ -9021,8 +9021,8 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
9021
9021
|
if (typeof record.entry === "string") metadata.entry = record.entry;
|
|
9022
9022
|
return metadata;
|
|
9023
9023
|
}
|
|
9024
|
-
async function loadPluginManifestFromMarkdown(
|
|
9025
|
-
const mdPath = path.join(
|
|
9024
|
+
async function loadPluginManifestFromMarkdown(pluginsRoot2, folderName) {
|
|
9025
|
+
const mdPath = path.join(pluginsRoot2, folderName, "PLUGIN.md");
|
|
9026
9026
|
let raw;
|
|
9027
9027
|
try {
|
|
9028
9028
|
raw = await promises.readFile(mdPath, "utf8");
|
|
@@ -9032,7 +9032,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
9032
9032
|
cause
|
|
9033
9033
|
});
|
|
9034
9034
|
}
|
|
9035
|
-
const fakeDir = path.join(
|
|
9035
|
+
const fakeDir = path.join(pluginsRoot2, folderName);
|
|
9036
9036
|
const entities = await loadMarkdownEntities({
|
|
9037
9037
|
dir: fakeDir,
|
|
9038
9038
|
schema: PluginFrontmatterSchema,
|
|
@@ -12031,6 +12031,103 @@ function registerBuiltins() {
|
|
|
12031
12031
|
registerProvider(CEREBRAS);
|
|
12032
12032
|
registerCatalogProviders();
|
|
12033
12033
|
}
|
|
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
|
+
}));
|
|
12043
|
+
function pluginsRoot() {
|
|
12044
|
+
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
12045
|
+
}
|
|
12046
|
+
function trustFilePath() {
|
|
12047
|
+
return path.join(os.homedir(), ".theokit", "plugins", "trusted-providers.json");
|
|
12048
|
+
}
|
|
12049
|
+
function loadTrustedNames() {
|
|
12050
|
+
const trusted = /* @__PURE__ */ new Set();
|
|
12051
|
+
const path = trustFilePath();
|
|
12052
|
+
if (fs.existsSync(path)) {
|
|
12053
|
+
try {
|
|
12054
|
+
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
12055
|
+
if (Array.isArray(parsed)) {
|
|
12056
|
+
let discarded = 0;
|
|
12057
|
+
for (const name of parsed) {
|
|
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
|
+
);
|
|
12066
|
+
}
|
|
12067
|
+
} else {
|
|
12068
|
+
process.stderr.write(
|
|
12069
|
+
`[theokit-sdk] WARN: ${path} is not a JSON array \u2014 trusting NO provider plugins (fail-closed)
|
|
12070
|
+
`
|
|
12071
|
+
);
|
|
12072
|
+
}
|
|
12073
|
+
} catch {
|
|
12074
|
+
process.stderr.write(
|
|
12075
|
+
`[theokit-sdk] WARN: ${path} is not valid JSON \u2014 trusting NO provider plugins (fail-closed)
|
|
12076
|
+
`
|
|
12077
|
+
);
|
|
12078
|
+
}
|
|
12079
|
+
}
|
|
12080
|
+
for (const name of (process.env.THEOKIT_TRUSTED_PROVIDERS ?? "").split(",")) {
|
|
12081
|
+
const trimmed = name.trim();
|
|
12082
|
+
if (trimmed.length > 0) trusted.add(trimmed);
|
|
12083
|
+
}
|
|
12084
|
+
return trusted;
|
|
12085
|
+
}
|
|
12086
|
+
async function discoverProviderPlugins() {
|
|
12087
|
+
if (discoveryState.done) return;
|
|
12088
|
+
discoveryState.done = true;
|
|
12089
|
+
const root = pluginsRoot();
|
|
12090
|
+
if (!fs.existsSync(root)) return;
|
|
12091
|
+
let entries;
|
|
12092
|
+
try {
|
|
12093
|
+
entries = await promises.readdir(root);
|
|
12094
|
+
} catch {
|
|
12095
|
+
return;
|
|
12096
|
+
}
|
|
12097
|
+
const trusted = loadTrustedNames();
|
|
12098
|
+
for (const entry of entries) {
|
|
12099
|
+
if (!trusted.has(entry)) {
|
|
12100
|
+
process.stderr.write(
|
|
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.
|
|
12102
|
+
`
|
|
12103
|
+
);
|
|
12104
|
+
continue;
|
|
12105
|
+
}
|
|
12106
|
+
await loadOne(path.join(root, entry), entry);
|
|
12107
|
+
}
|
|
12108
|
+
}
|
|
12109
|
+
async function loadOne(dir, entryName) {
|
|
12110
|
+
for (const ext of ["index.mjs", "index.js"]) {
|
|
12111
|
+
const indexPath = path.join(dir, ext);
|
|
12112
|
+
if (!fs.existsSync(indexPath)) continue;
|
|
12113
|
+
try {
|
|
12114
|
+
const mod = await import(url.pathToFileURL(indexPath).href);
|
|
12115
|
+
const plugin = mod.default ?? mod[entryName] ?? mod;
|
|
12116
|
+
if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
|
|
12117
|
+
const profile = plugin.profile;
|
|
12118
|
+
if (profile !== void 0 && typeof profile === "object") {
|
|
12119
|
+
registerProvider(profile);
|
|
12120
|
+
}
|
|
12121
|
+
}
|
|
12122
|
+
return;
|
|
12123
|
+
} catch (err) {
|
|
12124
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
12125
|
+
process.stderr.write(`[theokit-sdk] failed to load provider plugin "${entryName}": ${msg}
|
|
12126
|
+
`);
|
|
12127
|
+
return;
|
|
12128
|
+
}
|
|
12129
|
+
}
|
|
12130
|
+
}
|
|
12034
12131
|
|
|
12035
12132
|
// src/internal/llm/anthropic.ts
|
|
12036
12133
|
init_errors();
|
|
@@ -18579,6 +18676,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
18579
18676
|
return process.cwd();
|
|
18580
18677
|
}
|
|
18581
18678
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
18679
|
+
await discoverProviderPlugins();
|
|
18582
18680
|
await validateRehydratedAgent(agentId, existing);
|
|
18583
18681
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
18584
18682
|
const mergedOptions = {
|
|
@@ -18708,6 +18806,7 @@ var Agent = class _Agent {
|
|
|
18708
18806
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
18709
18807
|
});
|
|
18710
18808
|
try {
|
|
18809
|
+
await discoverProviderPlugins();
|
|
18711
18810
|
const agent = await runCreateUnderSpan(options, span);
|
|
18712
18811
|
return agent;
|
|
18713
18812
|
} catch (err) {
|