@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/dist/index.cjs
CHANGED
|
@@ -9726,7 +9726,7 @@ var SkillsManager = class {
|
|
|
9726
9726
|
}
|
|
9727
9727
|
async refresh() {
|
|
9728
9728
|
const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
|
|
9729
|
-
const
|
|
9729
|
+
const discovered2 = await discoverSkills(skillsRoot, {
|
|
9730
9730
|
onInvalidSkill: (info) => {
|
|
9731
9731
|
process.stderr.write(
|
|
9732
9732
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -9734,13 +9734,13 @@ var SkillsManager = class {
|
|
|
9734
9734
|
);
|
|
9735
9735
|
}
|
|
9736
9736
|
});
|
|
9737
|
-
this.skills = this.mergeInline(
|
|
9737
|
+
this.skills = this.mergeInline(discovered2);
|
|
9738
9738
|
}
|
|
9739
9739
|
/** 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
|
|
9740
|
+
mergeInline(discovered2) {
|
|
9741
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered2;
|
|
9742
9742
|
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
9743
|
-
return [...
|
|
9743
|
+
return [...discovered2.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
9744
9744
|
}
|
|
9745
9745
|
list() {
|
|
9746
9746
|
return Promise.resolve(this.skills);
|
|
@@ -11301,7 +11301,7 @@ var FileContextManager = class {
|
|
|
11301
11301
|
const legacy = await loadSources(config, this.cwd);
|
|
11302
11302
|
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
11303
11303
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
11304
|
-
const
|
|
11304
|
+
const discovered2 = await runDiscovery({
|
|
11305
11305
|
cwd: this.cwd,
|
|
11306
11306
|
maxBytesPerFile,
|
|
11307
11307
|
touchedFiles
|
|
@@ -11314,7 +11314,7 @@ var FileContextManager = class {
|
|
|
11314
11314
|
// matches DEFAULT_DISCOVERY_SPECS theokit-context
|
|
11315
11315
|
truncated: false
|
|
11316
11316
|
}));
|
|
11317
|
-
const { kept } = applyAggregateCap([...
|
|
11317
|
+
const { kept } = applyAggregateCap([...discovered2, ...legacyAsAggregator], maxBytesTotal);
|
|
11318
11318
|
const loadedSources = kept.map((s) => ({
|
|
11319
11319
|
name: s.id,
|
|
11320
11320
|
path: s.source,
|
|
@@ -11522,14 +11522,14 @@ var PluginsManager = class {
|
|
|
11522
11522
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + both-present detection per plugin folder — branch table is clearer inlined.
|
|
11523
11523
|
async refresh() {
|
|
11524
11524
|
this.plugins = [];
|
|
11525
|
-
const
|
|
11526
|
-
const entries = await readWorkspaceDir(
|
|
11525
|
+
const pluginsRoot2 = path.join(this.cwd, ".theokit", "plugins");
|
|
11526
|
+
const entries = await readWorkspaceDir(pluginsRoot2, "plugins_read_error", "plugins directory");
|
|
11527
11527
|
for (const entry of entries) {
|
|
11528
11528
|
if (!entry.isDirectory()) continue;
|
|
11529
11529
|
const folderName = entry.name;
|
|
11530
|
-
const mdPath = path.join(
|
|
11531
|
-
const jsonPath = path.join(
|
|
11532
|
-
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(
|
|
11530
|
+
const mdPath = path.join(pluginsRoot2, folderName, "PLUGIN.md");
|
|
11531
|
+
const jsonPath = path.join(pluginsRoot2, folderName, "plugin.json");
|
|
11532
|
+
const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot2, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
|
|
11533
11533
|
if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
|
|
11534
11534
|
warnOnce(
|
|
11535
11535
|
`plugin-${folderName}-both`,
|
|
@@ -11608,8 +11608,8 @@ async function loadPluginManifestFromJson(manifestPath, folderName) {
|
|
|
11608
11608
|
if (typeof record.entry === "string") metadata.entry = record.entry;
|
|
11609
11609
|
return metadata;
|
|
11610
11610
|
}
|
|
11611
|
-
async function loadPluginManifestFromMarkdown(
|
|
11612
|
-
const mdPath = path.join(
|
|
11611
|
+
async function loadPluginManifestFromMarkdown(pluginsRoot2, folderName) {
|
|
11612
|
+
const mdPath = path.join(pluginsRoot2, folderName, "PLUGIN.md");
|
|
11613
11613
|
let raw;
|
|
11614
11614
|
try {
|
|
11615
11615
|
raw = await promises.readFile(mdPath, "utf8");
|
|
@@ -11619,7 +11619,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
11619
11619
|
cause
|
|
11620
11620
|
});
|
|
11621
11621
|
}
|
|
11622
|
-
const fakeDir = path.join(
|
|
11622
|
+
const fakeDir = path.join(pluginsRoot2, folderName);
|
|
11623
11623
|
const entities = await loadMarkdownEntities({
|
|
11624
11624
|
dir: fakeDir,
|
|
11625
11625
|
schema: PluginFrontmatterSchema,
|
|
@@ -14635,6 +14635,87 @@ function registerBuiltins() {
|
|
|
14635
14635
|
registerProvider(CEREBRAS);
|
|
14636
14636
|
registerCatalogProviders();
|
|
14637
14637
|
}
|
|
14638
|
+
var discovered = false;
|
|
14639
|
+
function pluginsRoot() {
|
|
14640
|
+
return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
|
|
14641
|
+
}
|
|
14642
|
+
function trustFilePath() {
|
|
14643
|
+
return path.join(os.homedir(), ".theokit", "plugins", "trusted-providers.json");
|
|
14644
|
+
}
|
|
14645
|
+
function loadTrustedNames() {
|
|
14646
|
+
const trusted = /* @__PURE__ */ new Set();
|
|
14647
|
+
const path = trustFilePath();
|
|
14648
|
+
if (fs.existsSync(path)) {
|
|
14649
|
+
try {
|
|
14650
|
+
const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
14651
|
+
if (Array.isArray(parsed)) {
|
|
14652
|
+
for (const name of parsed) {
|
|
14653
|
+
if (typeof name === "string" && name.length > 0) trusted.add(name);
|
|
14654
|
+
}
|
|
14655
|
+
} else {
|
|
14656
|
+
process.stderr.write(
|
|
14657
|
+
`[theokit-sdk] WARN: ${path} is not a JSON array \u2014 trusting NO provider plugins (fail-closed)
|
|
14658
|
+
`
|
|
14659
|
+
);
|
|
14660
|
+
}
|
|
14661
|
+
} catch {
|
|
14662
|
+
process.stderr.write(
|
|
14663
|
+
`[theokit-sdk] WARN: ${path} is not valid JSON \u2014 trusting NO provider plugins (fail-closed)
|
|
14664
|
+
`
|
|
14665
|
+
);
|
|
14666
|
+
}
|
|
14667
|
+
}
|
|
14668
|
+
for (const name of (process.env.THEOKIT_TRUSTED_PROVIDERS ?? "").split(",")) {
|
|
14669
|
+
const trimmed = name.trim();
|
|
14670
|
+
if (trimmed.length > 0) trusted.add(trimmed);
|
|
14671
|
+
}
|
|
14672
|
+
return trusted;
|
|
14673
|
+
}
|
|
14674
|
+
async function discoverProviderPlugins() {
|
|
14675
|
+
if (discovered) return;
|
|
14676
|
+
discovered = true;
|
|
14677
|
+
const root = pluginsRoot();
|
|
14678
|
+
if (!fs.existsSync(root)) return;
|
|
14679
|
+
let entries;
|
|
14680
|
+
try {
|
|
14681
|
+
entries = await promises.readdir(root);
|
|
14682
|
+
} catch {
|
|
14683
|
+
return;
|
|
14684
|
+
}
|
|
14685
|
+
const trusted = loadTrustedNames();
|
|
14686
|
+
for (const entry of entries) {
|
|
14687
|
+
if (!trusted.has(entry)) {
|
|
14688
|
+
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.
|
|
14690
|
+
`
|
|
14691
|
+
);
|
|
14692
|
+
continue;
|
|
14693
|
+
}
|
|
14694
|
+
await loadOne(path.join(root, entry), entry);
|
|
14695
|
+
}
|
|
14696
|
+
}
|
|
14697
|
+
async function loadOne(dir, entryName) {
|
|
14698
|
+
for (const ext of ["index.mjs", "index.js"]) {
|
|
14699
|
+
const indexPath = path.join(dir, ext);
|
|
14700
|
+
if (!fs.existsSync(indexPath)) continue;
|
|
14701
|
+
try {
|
|
14702
|
+
const mod = await import(url.pathToFileURL(indexPath).href);
|
|
14703
|
+
const plugin = mod.default ?? mod[entryName] ?? mod;
|
|
14704
|
+
if (plugin !== null && typeof plugin === "object" && plugin.kind === "model-provider") {
|
|
14705
|
+
const profile = plugin.profile;
|
|
14706
|
+
if (profile !== void 0 && typeof profile === "object") {
|
|
14707
|
+
registerProvider(profile);
|
|
14708
|
+
}
|
|
14709
|
+
}
|
|
14710
|
+
return;
|
|
14711
|
+
} catch (err) {
|
|
14712
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
14713
|
+
process.stderr.write(`[theokit-sdk] failed to load provider plugin "${entryName}": ${msg}
|
|
14714
|
+
`);
|
|
14715
|
+
return;
|
|
14716
|
+
}
|
|
14717
|
+
}
|
|
14718
|
+
}
|
|
14638
14719
|
|
|
14639
14720
|
// src/internal/llm/anthropic.ts
|
|
14640
14721
|
init_errors();
|
|
@@ -20366,6 +20447,7 @@ var Agent = class _Agent {
|
|
|
20366
20447
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
20367
20448
|
});
|
|
20368
20449
|
try {
|
|
20450
|
+
await discoverProviderPlugins();
|
|
20369
20451
|
const agent = await runCreateUnderSpan(options, span);
|
|
20370
20452
|
return agent;
|
|
20371
20453
|
} catch (err) {
|