@theokit/sdk 4.14.1 → 4.15.1
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 +97 -15
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.js +100 -18
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +97 -15
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +100 -18
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +97 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +98 -16
- package/dist/index.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 discovered2 = 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(discovered2);
|
|
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(discovered2) {
|
|
7158
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered2;
|
|
7159
7159
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
7160
|
-
return [...
|
|
7160
|
+
return [...discovered2.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 discovered2 = 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([...discovered2, ...legacyAsAggregator], maxBytesTotal);
|
|
8732
8732
|
const loadedSources = kept.map((s) => ({
|
|
8733
8733
|
name: s.id,
|
|
8734
8734
|
path: s.source,
|
|
@@ -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,87 @@ function registerBuiltins() {
|
|
|
12031
12031
|
registerProvider(CEREBRAS);
|
|
12032
12032
|
registerCatalogProviders();
|
|
12033
12033
|
}
|
|
12034
|
+
var discovered = false;
|
|
12035
|
+
function pluginsRoot() {
|
|
12036
|
+
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
12037
|
+
}
|
|
12038
|
+
function trustFilePath() {
|
|
12039
|
+
return path.join(os.homedir(), ".theokit", "plugins", "trusted-providers.json");
|
|
12040
|
+
}
|
|
12041
|
+
function loadTrustedNames() {
|
|
12042
|
+
const trusted = /* @__PURE__ */ new Set();
|
|
12043
|
+
const path = trustFilePath();
|
|
12044
|
+
if (fs.existsSync(path)) {
|
|
12045
|
+
try {
|
|
12046
|
+
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
12047
|
+
if (Array.isArray(parsed)) {
|
|
12048
|
+
for (const name of parsed) {
|
|
12049
|
+
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
12050
|
+
}
|
|
12051
|
+
} else {
|
|
12052
|
+
process.stderr.write(
|
|
12053
|
+
`[theokit-sdk] WARN: ${path} is not a JSON array \u2014 trusting NO provider plugins (fail-closed)
|
|
12054
|
+
`
|
|
12055
|
+
);
|
|
12056
|
+
}
|
|
12057
|
+
} catch {
|
|
12058
|
+
process.stderr.write(
|
|
12059
|
+
`[theokit-sdk] WARN: ${path} is not valid JSON \u2014 trusting NO provider plugins (fail-closed)
|
|
12060
|
+
`
|
|
12061
|
+
);
|
|
12062
|
+
}
|
|
12063
|
+
}
|
|
12064
|
+
for (const name of (process.env.THEOKIT_TRUSTED_PROVIDERS ?? "").split(",")) {
|
|
12065
|
+
const trimmed = name.trim();
|
|
12066
|
+
if (trimmed.length > 0) trusted.add(trimmed);
|
|
12067
|
+
}
|
|
12068
|
+
return trusted;
|
|
12069
|
+
}
|
|
12070
|
+
async function discoverProviderPlugins() {
|
|
12071
|
+
if (discovered) return;
|
|
12072
|
+
discovered = true;
|
|
12073
|
+
const root = pluginsRoot();
|
|
12074
|
+
if (!fs.existsSync(root)) return;
|
|
12075
|
+
let entries;
|
|
12076
|
+
try {
|
|
12077
|
+
entries = await promises.readdir(root);
|
|
12078
|
+
} catch {
|
|
12079
|
+
return;
|
|
12080
|
+
}
|
|
12081
|
+
const trusted = loadTrustedNames();
|
|
12082
|
+
for (const entry of entries) {
|
|
12083
|
+
if (!trusted.has(entry)) {
|
|
12084
|
+
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.
|
|
12086
|
+
`
|
|
12087
|
+
);
|
|
12088
|
+
continue;
|
|
12089
|
+
}
|
|
12090
|
+
await loadOne(path.join(root, entry), entry);
|
|
12091
|
+
}
|
|
12092
|
+
}
|
|
12093
|
+
async function loadOne(dir, entryName) {
|
|
12094
|
+
for (const ext of ["index.mjs", "index.js"]) {
|
|
12095
|
+
const indexPath = path.join(dir, ext);
|
|
12096
|
+
if (!fs.existsSync(indexPath)) continue;
|
|
12097
|
+
try {
|
|
12098
|
+
const mod = await import(url.pathToFileURL(indexPath).href);
|
|
12099
|
+
const plugin = mod.default ?? mod[entryName] ?? mod;
|
|
12100
|
+
if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
|
|
12101
|
+
const profile = plugin.profile;
|
|
12102
|
+
if (profile !== void 0 && typeof profile === "object") {
|
|
12103
|
+
registerProvider(profile);
|
|
12104
|
+
}
|
|
12105
|
+
}
|
|
12106
|
+
return;
|
|
12107
|
+
} catch (err) {
|
|
12108
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
12109
|
+
process.stderr.write(`[theokit-sdk] failed to load provider plugin "${entryName}": ${msg}
|
|
12110
|
+
`);
|
|
12111
|
+
return;
|
|
12112
|
+
}
|
|
12113
|
+
}
|
|
12114
|
+
}
|
|
12034
12115
|
|
|
12035
12116
|
// src/internal/llm/anthropic.ts
|
|
12036
12117
|
init_errors();
|
|
@@ -18708,6 +18789,7 @@ var Agent = class _Agent {
|
|
|
18708
18789
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
18709
18790
|
});
|
|
18710
18791
|
try {
|
|
18792
|
+
await discoverProviderPlugins();
|
|
18711
18793
|
const agent = await runCreateUnderSpan(options, span);
|
|
18712
18794
|
return agent;
|
|
18713
18795
|
} catch (err) {
|