@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/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 discovered2 = await discoverSkills(skillsRoot, {
9729
+ const discovered = 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(discovered2);
9737
+ this.skills = this.mergeInline(discovered);
9738
9738
  }
9739
9739
  /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
9740
- mergeInline(discovered2) {
9741
- if (this.inline === void 0 || this.inline.length === 0) return discovered2;
9740
+ mergeInline(discovered) {
9741
+ if (this.inline === void 0 || this.inline.length === 0) return discovered;
9742
9742
  const inlineNames = new Set(this.inline.map((s) => s.name));
9743
- return [...discovered2.filter((s) => !inlineNames.has(s.name)), ...this.inline];
9743
+ return [...discovered.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 discovered2 = await runDiscovery({
11304
+ const discovered = 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([...discovered2, ...legacyAsAggregator], maxBytesTotal);
11317
+ const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
11318
11318
  const loadedSources = kept.map((s) => ({
11319
11319
  name: s.id,
11320
11320
  path: s.source,
@@ -14635,7 +14635,15 @@ function registerBuiltins() {
14635
14635
  registerProvider(CEREBRAS);
14636
14636
  registerCatalogProviders();
14637
14637
  }
14638
- var discovered = false;
14638
+ function globalSingleton3(key2, create) {
14639
+ const g = globalThis;
14640
+ const sym = Symbol.for(key2);
14641
+ if (g[sym] === void 0) g[sym] = create();
14642
+ return g[sym];
14643
+ }
14644
+ var discoveryState = globalSingleton3("theokit-sdk.providers.discovered", () => ({
14645
+ done: false
14646
+ }));
14639
14647
  function pluginsRoot() {
14640
14648
  return path.join(os.homedir(), ".theokit", "plugins", "model-providers");
14641
14649
  }
@@ -14649,8 +14657,16 @@ function loadTrustedNames() {
14649
14657
  try {
14650
14658
  const parsed = JSON.parse(fs.readFileSync(path, "utf-8"));
14651
14659
  if (Array.isArray(parsed)) {
14660
+ let discarded = 0;
14652
14661
  for (const name of parsed) {
14653
14662
  if (typeof name === "string" && name.length > 0) trusted.add(name);
14663
+ else discarded += 1;
14664
+ }
14665
+ if (discarded > 0) {
14666
+ process.stderr.write(
14667
+ `[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
14668
+ `
14669
+ );
14654
14670
  }
14655
14671
  } else {
14656
14672
  process.stderr.write(
@@ -14672,8 +14688,8 @@ function loadTrustedNames() {
14672
14688
  return trusted;
14673
14689
  }
14674
14690
  async function discoverProviderPlugins() {
14675
- if (discovered) return;
14676
- discovered = true;
14691
+ if (discoveryState.done) return;
14692
+ discoveryState.done = true;
14677
14693
  const root = pluginsRoot();
14678
14694
  if (!fs.existsSync(root)) return;
14679
14695
  let entries;
@@ -14686,7 +14702,7 @@ async function discoverProviderPlugins() {
14686
14702
  for (const entry of entries) {
14687
14703
  if (!trusted.has(entry)) {
14688
14704
  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.
14705
+ `[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.
14690
14706
  `
14691
14707
  );
14692
14708
  continue;
@@ -20318,6 +20334,7 @@ function resolveAgentPersistenceCwd(options) {
20318
20334
  return process.cwd();
20319
20335
  }
20320
20336
  async function rehydrateExistingAgent(agentId, existing, options) {
20337
+ await discoverProviderPlugins();
20321
20338
  await validateRehydratedAgent(agentId, existing);
20322
20339
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
20323
20340
  const mergedOptions = {
@@ -23396,6 +23413,7 @@ var Theokit = class {
23396
23413
  };
23397
23414
  async function maybeListLocalModels(providerName) {
23398
23415
  registerBuiltins();
23416
+ await discoverProviderPlugins();
23399
23417
  const profile = getProviderProfile(providerName);
23400
23418
  if (profile === void 0) return void 0;
23401
23419
  if (profile.authType !== "none") return void 0;