@theokit/sdk 4.15.0 → 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 +6 -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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.15.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(providers): wire `discoverProviderPlugins()` into `Agent.create` — the dynamic provider-plugin loader (and its M47 trust gate) was exported but never invoked on any production path, making the whole discovery surface dead code at runtime. Discovery now runs upfront on agent initialization (idempotent, fail-tolerant), honoring the `resolveProviderChain` contract.
|
|
8
|
+
|
|
3
9
|
## 4.15.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/cron.cjs
CHANGED
|
@@ -7148,7 +7148,7 @@ var SkillsManager = class {
|
|
|
7148
7148
|
}
|
|
7149
7149
|
async refresh() {
|
|
7150
7150
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
7151
|
-
const
|
|
7151
|
+
const discovered2 = await discoverSkills(skillsRoot, {
|
|
7152
7152
|
onInvalidSkill: (info) => {
|
|
7153
7153
|
process.stderr.write(
|
|
7154
7154
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -7156,13 +7156,13 @@ var SkillsManager = class {
|
|
|
7156
7156
|
);
|
|
7157
7157
|
}
|
|
7158
7158
|
});
|
|
7159
|
-
this.skills = this.mergeInline(
|
|
7159
|
+
this.skills = this.mergeInline(discovered2);
|
|
7160
7160
|
}
|
|
7161
7161
|
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
7162
|
-
mergeInline(
|
|
7163
|
-
if (this.inline === void 0 || this.inline.length === 0) return
|
|
7162
|
+
mergeInline(discovered2) {
|
|
7163
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered2;
|
|
7164
7164
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
7165
|
-
return [...
|
|
7165
|
+
return [...discovered2.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
7166
7166
|
}
|
|
7167
7167
|
list() {
|
|
7168
7168
|
return Promise.resolve(this.skills);
|
|
@@ -8720,7 +8720,7 @@ var FileContextManager = class {
|
|
|
8720
8720
|
const legacy = await loadSources(config, this.cwd);
|
|
8721
8721
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
8722
8722
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
8723
|
-
const
|
|
8723
|
+
const discovered2 = await runDiscovery({
|
|
8724
8724
|
cwd: this.cwd,
|
|
8725
8725
|
maxBytesPerFile,
|
|
8726
8726
|
touchedFiles
|
|
@@ -8733,7 +8733,7 @@ var FileContextManager = class {
|
|
|
8733
8733
|
// matches DEFAULT_DISCOVERY_SPECS theokit-context
|
|
8734
8734
|
truncated: false
|
|
8735
8735
|
}));
|
|
8736
|
-
const { kept } = applyAggregateCap([...
|
|
8736
|
+
const { kept } = applyAggregateCap([...discovered2, ...legacyAsAggregator], maxBytesTotal);
|
|
8737
8737
|
const loadedSources = kept.map((s) => ({
|
|
8738
8738
|
name: s.id,
|
|
8739
8739
|
path: s.source,
|
|
@@ -8940,14 +8940,14 @@ var PluginsManager = class {
|
|
|
8940
8940
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + both-present detection per plugin folder — branch table is clearer inlined.
|
|
8941
8941
|
async refresh() {
|
|
8942
8942
|
this.plugins = [];
|
|
8943
|
-
const
|
|
8944
|
-
const entries = await readWorkspaceDir(
|
|
8943
|
+
const pluginsRoot2 = path.join(this.cwd, ".theokit", "plugins");
|
|
8944
|
+
const entries = await readWorkspaceDir(pluginsRoot2, "plugins_read_error", "plugins directory");
|
|
8945
8945
|
for (const entry of entries) {
|
|
8946
8946
|
if (!entry.isDirectory()) continue;
|
|
8947
8947
|
const folderName = entry.name;
|
|
8948
|
-
const mdPath = path.join(
|
|
8949
|
-
const jsonPath = path.join(
|
|
8950
|
-
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(
|
|
8948
|
+
const mdPath = path.join(pluginsRoot2, folderName, "PLUGIN.md");
|
|
8949
|
+
const jsonPath = path.join(pluginsRoot2, folderName, "plugin.json");
|
|
8950
|
+
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot2, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
8951
8951
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
8952
8952
|
warnOnce(
|
|
8953
8953
|
`plugin-${folderName}-both`,
|
|
@@ -9026,8 +9026,8 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
9026
9026
|
if (typeof record.entry === "string") metadata.entry = record.entry;
|
|
9027
9027
|
return metadata;
|
|
9028
9028
|
}
|
|
9029
|
-
async function loadPluginManifestFromMarkdown(
|
|
9030
|
-
const mdPath = path.join(
|
|
9029
|
+
async function loadPluginManifestFromMarkdown(pluginsRoot2, folderName) {
|
|
9030
|
+
const mdPath = path.join(pluginsRoot2, folderName, "PLUGIN.md");
|
|
9031
9031
|
let raw;
|
|
9032
9032
|
try {
|
|
9033
9033
|
raw = await promises.readFile(mdPath, "utf8");
|
|
@@ -9037,7 +9037,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
9037
9037
|
cause
|
|
9038
9038
|
});
|
|
9039
9039
|
}
|
|
9040
|
-
const fakeDir = path.join(
|
|
9040
|
+
const fakeDir = path.join(pluginsRoot2, folderName);
|
|
9041
9041
|
const entities = await loadMarkdownEntities({
|
|
9042
9042
|
dir: fakeDir,
|
|
9043
9043
|
schema: PluginFrontmatterSchema,
|
|
@@ -12036,6 +12036,87 @@ function registerBuiltins() {
|
|
|
12036
12036
|
registerProvider(CEREBRAS);
|
|
12037
12037
|
registerCatalogProviders();
|
|
12038
12038
|
}
|
|
12039
|
+
var discovered = false;
|
|
12040
|
+
function pluginsRoot() {
|
|
12041
|
+
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
12042
|
+
}
|
|
12043
|
+
function trustFilePath() {
|
|
12044
|
+
return path.join(os.homedir(), ".theokit", "plugins", "trusted-providers.json");
|
|
12045
|
+
}
|
|
12046
|
+
function loadTrustedNames() {
|
|
12047
|
+
const trusted = /* @__PURE__ */ new Set();
|
|
12048
|
+
const path = trustFilePath();
|
|
12049
|
+
if (fs.existsSync(path)) {
|
|
12050
|
+
try {
|
|
12051
|
+
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
12052
|
+
if (Array.isArray(parsed)) {
|
|
12053
|
+
for (const name of parsed) {
|
|
12054
|
+
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
12055
|
+
}
|
|
12056
|
+
} else {
|
|
12057
|
+
process.stderr.write(
|
|
12058
|
+
`[theokit-sdk] WARN: ${path} is not a JSON array \u2014 trusting NO provider plugins (fail-closed)
|
|
12059
|
+
`
|
|
12060
|
+
);
|
|
12061
|
+
}
|
|
12062
|
+
} catch {
|
|
12063
|
+
process.stderr.write(
|
|
12064
|
+
`[theokit-sdk] WARN: ${path} is not valid JSON \u2014 trusting NO provider plugins (fail-closed)
|
|
12065
|
+
`
|
|
12066
|
+
);
|
|
12067
|
+
}
|
|
12068
|
+
}
|
|
12069
|
+
for (const name of (process.env.THEOKIT_TRUSTED_PROVIDERS ?? "").split(",")) {
|
|
12070
|
+
const trimmed = name.trim();
|
|
12071
|
+
if (trimmed.length > 0) trusted.add(trimmed);
|
|
12072
|
+
}
|
|
12073
|
+
return trusted;
|
|
12074
|
+
}
|
|
12075
|
+
async function discoverProviderPlugins() {
|
|
12076
|
+
if (discovered) return;
|
|
12077
|
+
discovered = true;
|
|
12078
|
+
const root = pluginsRoot();
|
|
12079
|
+
if (!fs.existsSync(root)) return;
|
|
12080
|
+
let entries;
|
|
12081
|
+
try {
|
|
12082
|
+
entries = await promises.readdir(root);
|
|
12083
|
+
} catch {
|
|
12084
|
+
return;
|
|
12085
|
+
}
|
|
12086
|
+
const trusted = loadTrustedNames();
|
|
12087
|
+
for (const entry of entries) {
|
|
12088
|
+
if (!trusted.has(entry)) {
|
|
12089
|
+
process.stderr.write(
|
|
12090
|
+
`[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.
|
|
12091
|
+
`
|
|
12092
|
+
);
|
|
12093
|
+
continue;
|
|
12094
|
+
}
|
|
12095
|
+
await loadOne(path.join(root, entry), entry);
|
|
12096
|
+
}
|
|
12097
|
+
}
|
|
12098
|
+
async function loadOne(dir, entryName) {
|
|
12099
|
+
for (const ext of ["index.mjs", "index.js"]) {
|
|
12100
|
+
const indexPath = path.join(dir, ext);
|
|
12101
|
+
if (!fs.existsSync(indexPath)) continue;
|
|
12102
|
+
try {
|
|
12103
|
+
const mod = await import(url.pathToFileURL(indexPath).href);
|
|
12104
|
+
const plugin = mod.default ?? mod[entryName] ?? mod;
|
|
12105
|
+
if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
|
|
12106
|
+
const profile = plugin.profile;
|
|
12107
|
+
if (profile !== void 0 && typeof profile === "object") {
|
|
12108
|
+
registerProvider(profile);
|
|
12109
|
+
}
|
|
12110
|
+
}
|
|
12111
|
+
return;
|
|
12112
|
+
} catch (err) {
|
|
12113
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
12114
|
+
process.stderr.write(`[theokit-sdk] failed to load provider plugin "${entryName}": ${msg}
|
|
12115
|
+
`);
|
|
12116
|
+
return;
|
|
12117
|
+
}
|
|
12118
|
+
}
|
|
12119
|
+
}
|
|
12039
12120
|
|
|
12040
12121
|
// src/internal/llm/anthropic.ts
|
|
12041
12122
|
init_errors();
|
|
@@ -18713,6 +18794,7 @@ var Agent = class _Agent {
|
|
|
18713
18794
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
18714
18795
|
});
|
|
18715
18796
|
try {
|
|
18797
|
+
await discoverProviderPlugins();
|
|
18716
18798
|
const agent = await runCreateUnderSpan(options, span);
|
|
18717
18799
|
return agent;
|
|
18718
18800
|
} catch (err) {
|