@theokit/sdk 4.13.0 → 4.13.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/dist/eval.js CHANGED
@@ -10531,8 +10531,17 @@ var catalogModelSchema = z.object({
10531
10531
  }).loose();
10532
10532
 
10533
10533
  // src/internal/providers/registry.ts
10534
- var REGISTRY = /* @__PURE__ */ new Map();
10535
- var ALIASES = /* @__PURE__ */ new Map();
10534
+ function globalSingleton(key, create) {
10535
+ const g = globalThis;
10536
+ const sym = Symbol.for(key);
10537
+ if (g[sym] === void 0) g[sym] = create();
10538
+ return g[sym];
10539
+ }
10540
+ var REGISTRY = globalSingleton(
10541
+ "theokit-sdk.providers.registry",
10542
+ () => /* @__PURE__ */ new Map()
10543
+ );
10544
+ var ALIASES = globalSingleton("theokit-sdk.providers.aliases", () => /* @__PURE__ */ new Map());
10536
10545
  function registerProvider(profile) {
10537
10546
  if (REGISTRY.has(profile.name)) {
10538
10547
  process.stderr.write(`[theokit-sdk] Provider "${profile.name}" overridden by user plugin.
@@ -10557,18 +10566,43 @@ function getProviderProfile(name) {
10557
10566
 
10558
10567
  // src/internal/providers/catalog-loader.ts
10559
10568
  var __dirname_resolved = dirname(fileURLToPath(import.meta.url));
10560
- var modelInfoIndex = /* @__PURE__ */ new Map();
10569
+ function globalSingleton2(key, create) {
10570
+ const g = globalThis;
10571
+ const sym = Symbol.for(key);
10572
+ if (g[sym] === void 0) g[sym] = create();
10573
+ return g[sym];
10574
+ }
10575
+ var modelInfoIndex = globalSingleton2(
10576
+ "theokit-sdk.providers.model-info-index",
10577
+ () => /* @__PURE__ */ new Map()
10578
+ );
10579
+ var patchedModelKeys = globalSingleton2(
10580
+ "theokit-sdk.providers.model-info-patched",
10581
+ () => /* @__PURE__ */ new Set()
10582
+ );
10583
+ var indexState = globalSingleton2("theokit-sdk.providers.model-info-loaded", () => ({
10584
+ loaded: false
10585
+ }));
10561
10586
  function getCatalogModelInfo(key) {
10562
10587
  ensureModelIndexLoaded();
10563
10588
  return modelInfoIndex.get(key);
10564
10589
  }
10565
- var _modelIndexLoaded = false;
10590
+ function isPatchedModelKey(key) {
10591
+ return patchedModelKeys.has(key);
10592
+ }
10566
10593
  function ensureModelIndexLoaded() {
10567
- if (_modelIndexLoaded) return;
10568
- _modelIndexLoaded = true;
10569
- const catalog = loadProviderCatalog();
10570
- for (const entry of Object.values(catalog)) {
10571
- indexEntryModels(entry);
10594
+ if (indexState.loaded) return;
10595
+ indexState.loaded = true;
10596
+ try {
10597
+ const catalog = loadProviderCatalog();
10598
+ for (const entry of Object.values(catalog)) {
10599
+ indexEntryModels(entry);
10600
+ }
10601
+ } catch (err) {
10602
+ process.stderr.write(
10603
+ `[theokit-sdk] WARN: provider catalog unavailable (${err.message}) \u2014 per-model data disabled
10604
+ `
10605
+ );
10572
10606
  }
10573
10607
  }
10574
10608
  function indexEntryModels(entry) {
@@ -10821,8 +10855,10 @@ function getPricingEntry(opts) {
10821
10855
  return void 0;
10822
10856
  }
10823
10857
  function catalogCostFallback(provider, cleanedModel) {
10824
- const keys = [`${provider}/${cleanedModel}`, cleanedModel];
10825
- for (const key of keys) {
10858
+ const stripped = stripDateSuffix(cleanedModel);
10859
+ const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
10860
+ if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
10861
+ for (const key of candidates) {
10826
10862
  const info = getCatalogModelInfo(key);
10827
10863
  const cost = info?.cost;
10828
10864
  if (cost === void 0) continue;
@@ -10834,7 +10870,8 @@ function catalogCostFallback(provider, cleanedModel) {
10834
10870
  outputCostPerMillion: cost.output,
10835
10871
  ...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
10836
10872
  ...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
10837
- pricingVersion: "catalog-vendored"
10873
+ // M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
10874
+ pricingVersion: isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
10838
10875
  };
10839
10876
  }
10840
10877
  return void 0;