@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.cjs CHANGED
@@ -10534,8 +10534,17 @@ var catalogModelSchema = zod.z.object({
10534
10534
  }).loose();
10535
10535
 
10536
10536
  // src/internal/providers/registry.ts
10537
- var REGISTRY = /* @__PURE__ */ new Map();
10538
- var ALIASES = /* @__PURE__ */ new Map();
10537
+ function globalSingleton(key, create) {
10538
+ const g = globalThis;
10539
+ const sym = Symbol.for(key);
10540
+ if (g[sym] === void 0) g[sym] = create();
10541
+ return g[sym];
10542
+ }
10543
+ var REGISTRY = globalSingleton(
10544
+ "theokit-sdk.providers.registry",
10545
+ () => /* @__PURE__ */ new Map()
10546
+ );
10547
+ var ALIASES = globalSingleton("theokit-sdk.providers.aliases", () => /* @__PURE__ */ new Map());
10539
10548
  function registerProvider(profile) {
10540
10549
  if (REGISTRY.has(profile.name)) {
10541
10550
  process.stderr.write(`[theokit-sdk] Provider "${profile.name}" overridden by user plugin.
@@ -10560,18 +10569,43 @@ function getProviderProfile(name) {
10560
10569
 
10561
10570
  // src/internal/providers/catalog-loader.ts
10562
10571
  var __dirname_resolved = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('eval.cjs', document.baseURI).href))));
10563
- var modelInfoIndex = /* @__PURE__ */ new Map();
10572
+ function globalSingleton2(key, create) {
10573
+ const g = globalThis;
10574
+ const sym = Symbol.for(key);
10575
+ if (g[sym] === void 0) g[sym] = create();
10576
+ return g[sym];
10577
+ }
10578
+ var modelInfoIndex = globalSingleton2(
10579
+ "theokit-sdk.providers.model-info-index",
10580
+ () => /* @__PURE__ */ new Map()
10581
+ );
10582
+ var patchedModelKeys = globalSingleton2(
10583
+ "theokit-sdk.providers.model-info-patched",
10584
+ () => /* @__PURE__ */ new Set()
10585
+ );
10586
+ var indexState = globalSingleton2("theokit-sdk.providers.model-info-loaded", () => ({
10587
+ loaded: false
10588
+ }));
10564
10589
  function getCatalogModelInfo(key) {
10565
10590
  ensureModelIndexLoaded();
10566
10591
  return modelInfoIndex.get(key);
10567
10592
  }
10568
- var _modelIndexLoaded = false;
10593
+ function isPatchedModelKey(key) {
10594
+ return patchedModelKeys.has(key);
10595
+ }
10569
10596
  function ensureModelIndexLoaded() {
10570
- if (_modelIndexLoaded) return;
10571
- _modelIndexLoaded = true;
10572
- const catalog = loadProviderCatalog();
10573
- for (const entry of Object.values(catalog)) {
10574
- indexEntryModels(entry);
10597
+ if (indexState.loaded) return;
10598
+ indexState.loaded = true;
10599
+ try {
10600
+ const catalog = loadProviderCatalog();
10601
+ for (const entry of Object.values(catalog)) {
10602
+ indexEntryModels(entry);
10603
+ }
10604
+ } catch (err) {
10605
+ process.stderr.write(
10606
+ `[theokit-sdk] WARN: provider catalog unavailable (${err.message}) \u2014 per-model data disabled
10607
+ `
10608
+ );
10575
10609
  }
10576
10610
  }
10577
10611
  function indexEntryModels(entry) {
@@ -10824,8 +10858,10 @@ function getPricingEntry(opts) {
10824
10858
  return void 0;
10825
10859
  }
10826
10860
  function catalogCostFallback(provider, cleanedModel) {
10827
- const keys = [`${provider}/${cleanedModel}`, cleanedModel];
10828
- for (const key of keys) {
10861
+ const stripped = stripDateSuffix(cleanedModel);
10862
+ const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
10863
+ if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
10864
+ for (const key of candidates) {
10829
10865
  const info = getCatalogModelInfo(key);
10830
10866
  const cost = info?.cost;
10831
10867
  if (cost === void 0) continue;
@@ -10837,7 +10873,8 @@ function catalogCostFallback(provider, cleanedModel) {
10837
10873
  outputCostPerMillion: cost.output,
10838
10874
  ...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
10839
10875
  ...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
10840
- pricingVersion: "catalog-vendored"
10876
+ // M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
10877
+ pricingVersion: isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
10841
10878
  };
10842
10879
  }
10843
10880
  return void 0;