@theokit/sdk 4.15.1 → 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/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 discovered2 = await discoverSkills(skillsRoot, {
7146
+ const discovered = 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(discovered2);
7154
+ this.skills = this.mergeInline(discovered);
7155
7155
  }
7156
7156
  /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
7157
- mergeInline(discovered2) {
7158
- if (this.inline === void 0 || this.inline.length === 0) return discovered2;
7157
+ mergeInline(discovered) {
7158
+ if (this.inline === void 0 || this.inline.length === 0) return discovered;
7159
7159
  const inlineNames = new Set(this.inline.map((s) => s.name));
7160
- return [...discovered2.filter((s) => !inlineNames.has(s.name)), ...this.inline];
7160
+ return [...discovered.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 discovered2 = await runDiscovery({
8718
+ const discovered = 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([...discovered2, ...legacyAsAggregator], maxBytesTotal);
8731
+ const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
8732
8732
  const loadedSources = kept.map((s) => ({
8733
8733
  name: s.id,
8734
8734
  path: s.source,
@@ -12031,7 +12031,15 @@ function registerBuiltins() {
12031
12031
  registerProvider(CEREBRAS);
12032
12032
  registerCatalogProviders();
12033
12033
  }
12034
- var discovered = false;
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
+ }));
12035
12043
  function pluginsRoot() {
12036
12044
  return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
12037
12045
  }
@@ -12045,8 +12053,16 @@ function loadTrustedNames() {
12045
12053
  try {
12046
12054
  const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
12047
12055
  if (Array.isArray(parsed)) {
12056
+ let discarded = 0;
12048
12057
  for (const name of parsed) {
12049
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
+ );
12050
12066
  }
12051
12067
  } else {
12052
12068
  process.stderr.write(
@@ -12068,8 +12084,8 @@ function loadTrustedNames() {
12068
12084
  return trusted;
12069
12085
  }
12070
12086
  async function discoverProviderPlugins() {
12071
- if (discovered) return;
12072
- discovered = true;
12087
+ if (discoveryState.done) return;
12088
+ discoveryState.done = true;
12073
12089
  const root = pluginsRoot();
12074
12090
  if (!fs.existsSync(root)) return;
12075
12091
  let entries;
@@ -12082,7 +12098,7 @@ async function discoverProviderPlugins() {
12082
12098
  for (const entry of entries) {
12083
12099
  if (!trusted.has(entry)) {
12084
12100
  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.
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.
12086
12102
  `
12087
12103
  );
12088
12104
  continue;
@@ -18660,6 +18676,7 @@ function resolveAgentPersistenceCwd(options) {
18660
18676
  return process.cwd();
18661
18677
  }
18662
18678
  async function rehydrateExistingAgent(agentId, existing, options) {
18679
+ await discoverProviderPlugins();
18663
18680
  await validateRehydratedAgent(agentId, existing);
18664
18681
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
18665
18682
  const mergedOptions = {