@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/cron.js CHANGED
@@ -7145,7 +7145,7 @@ var SkillsManager = class {
7145
7145
  }
7146
7146
  async refresh() {
7147
7147
  const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
7148
- const discovered2 = await discoverSkills(skillsRoot, {
7148
+ const discovered = await discoverSkills(skillsRoot, {
7149
7149
  onInvalidSkill: (info) => {
7150
7150
  process.stderr.write(
7151
7151
  `[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
@@ -7153,13 +7153,13 @@ var SkillsManager = class {
7153
7153
  );
7154
7154
  }
7155
7155
  });
7156
- this.skills = this.mergeInline(discovered2);
7156
+ this.skills = this.mergeInline(discovered);
7157
7157
  }
7158
7158
  /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
7159
- mergeInline(discovered2) {
7160
- if (this.inline === void 0 || this.inline.length === 0) return discovered2;
7159
+ mergeInline(discovered) {
7160
+ if (this.inline === void 0 || this.inline.length === 0) return discovered;
7161
7161
  const inlineNames = new Set(this.inline.map((s) => s.name));
7162
- return [...discovered2.filter((s) => !inlineNames.has(s.name)), ...this.inline];
7162
+ return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
7163
7163
  }
7164
7164
  list() {
7165
7165
  return Promise.resolve(this.skills);
@@ -8717,7 +8717,7 @@ var FileContextManager = class {
8717
8717
  const legacy = await loadSources(config, this.cwd);
8718
8718
  const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
8719
8719
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
8720
- const discovered2 = await runDiscovery({
8720
+ const discovered = await runDiscovery({
8721
8721
  cwd: this.cwd,
8722
8722
  maxBytesPerFile,
8723
8723
  touchedFiles
@@ -8730,7 +8730,7 @@ var FileContextManager = class {
8730
8730
  // matches DEFAULT_DISCOVERY_SPECS theokit-context
8731
8731
  truncated: false
8732
8732
  }));
8733
- const { kept } = applyAggregateCap([...discovered2, ...legacyAsAggregator], maxBytesTotal);
8733
+ const { kept } = applyAggregateCap([...discovered, ...legacyAsAggregator], maxBytesTotal);
8734
8734
  const loadedSources = kept.map((s) => ({
8735
8735
  name: s.id,
8736
8736
  path: s.source,
@@ -12033,7 +12033,15 @@ function registerBuiltins() {
12033
12033
  registerProvider(CEREBRAS);
12034
12034
  registerCatalogProviders();
12035
12035
  }
12036
- var discovered = false;
12036
+ function globalSingleton3(key, create) {
12037
+ const g = globalThis;
12038
+ const sym = Symbol.for(key);
12039
+ if (g[sym] === void 0) g[sym] = create();
12040
+ return g[sym];
12041
+ }
12042
+ var discoveryState = globalSingleton3("theokit-sdk.providers.discovered", () => ({
12043
+ done: false
12044
+ }));
12037
12045
  function pluginsRoot() {
12038
12046
  return join(homedir(), ".theokit", "plugins", "model-providers");
12039
12047
  }
@@ -12047,8 +12055,16 @@ function loadTrustedNames() {
12047
12055
  try {
12048
12056
  const parsed = JSON.parse(readFileSync(path, "utf-8"));
12049
12057
  if (Array.isArray(parsed)) {
12058
+ let discarded = 0;
12050
12059
  for (const name of parsed) {
12051
12060
  if (typeof name === "string" && name.length > 0) trusted.add(name);
12061
+ else discarded += 1;
12062
+ }
12063
+ if (discarded > 0) {
12064
+ process.stderr.write(
12065
+ `[theokit-sdk] WARN: ${path} contains ${discarded} non-string entr${discarded === 1 ? "y" : "ies"} \u2014 discarded (entries must be plugin-name strings)
12066
+ `
12067
+ );
12052
12068
  }
12053
12069
  } else {
12054
12070
  process.stderr.write(
@@ -12070,8 +12086,8 @@ function loadTrustedNames() {
12070
12086
  return trusted;
12071
12087
  }
12072
12088
  async function discoverProviderPlugins() {
12073
- if (discovered) return;
12074
- discovered = true;
12089
+ if (discoveryState.done) return;
12090
+ discoveryState.done = true;
12075
12091
  const root = pluginsRoot();
12076
12092
  if (!existsSync(root)) return;
12077
12093
  let entries;
@@ -12084,7 +12100,7 @@ async function discoverProviderPlugins() {
12084
12100
  for (const entry of entries) {
12085
12101
  if (!trusted.has(entry)) {
12086
12102
  process.stderr.write(
12087
- `[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.
12103
+ `[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.
12088
12104
  `
12089
12105
  );
12090
12106
  continue;
@@ -18662,6 +18678,7 @@ function resolveAgentPersistenceCwd(options) {
18662
18678
  return process.cwd();
18663
18679
  }
18664
18680
  async function rehydrateExistingAgent(agentId, existing, options) {
18681
+ await discoverProviderPlugins();
18665
18682
  await validateRehydratedAgent(agentId, existing);
18666
18683
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
18667
18684
  const mergedOptions = {