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