@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/index.js CHANGED
@@ -13118,8 +13118,17 @@ var catalogModelSchema = z.object({
13118
13118
  }).loose();
13119
13119
 
13120
13120
  // src/internal/providers/registry.ts
13121
- var REGISTRY = /* @__PURE__ */ new Map();
13122
- var ALIASES = /* @__PURE__ */ new Map();
13121
+ function globalSingleton(key2, create) {
13122
+ const g = globalThis;
13123
+ const sym = Symbol.for(key2);
13124
+ if (g[sym] === void 0) g[sym] = create();
13125
+ return g[sym];
13126
+ }
13127
+ var REGISTRY = globalSingleton(
13128
+ "theokit-sdk.providers.registry",
13129
+ () => /* @__PURE__ */ new Map()
13130
+ );
13131
+ var ALIASES = globalSingleton("theokit-sdk.providers.aliases", () => /* @__PURE__ */ new Map());
13123
13132
  function registerProvider(profile) {
13124
13133
  if (REGISTRY.has(profile.name)) {
13125
13134
  process.stderr.write(`[theokit-sdk] Provider "${profile.name}" overridden by user plugin.
@@ -13147,18 +13156,43 @@ function listProviders() {
13147
13156
 
13148
13157
  // src/internal/providers/catalog-loader.ts
13149
13158
  var __dirname_resolved = dirname(fileURLToPath(import.meta.url));
13150
- var modelInfoIndex = /* @__PURE__ */ new Map();
13159
+ function globalSingleton2(key2, create) {
13160
+ const g = globalThis;
13161
+ const sym = Symbol.for(key2);
13162
+ if (g[sym] === void 0) g[sym] = create();
13163
+ return g[sym];
13164
+ }
13165
+ var modelInfoIndex = globalSingleton2(
13166
+ "theokit-sdk.providers.model-info-index",
13167
+ () => /* @__PURE__ */ new Map()
13168
+ );
13169
+ var patchedModelKeys = globalSingleton2(
13170
+ "theokit-sdk.providers.model-info-patched",
13171
+ () => /* @__PURE__ */ new Set()
13172
+ );
13173
+ var indexState = globalSingleton2("theokit-sdk.providers.model-info-loaded", () => ({
13174
+ loaded: false
13175
+ }));
13151
13176
  function getCatalogModelInfo(key2) {
13152
13177
  ensureModelIndexLoaded();
13153
13178
  return modelInfoIndex.get(key2);
13154
13179
  }
13155
- var _modelIndexLoaded = false;
13180
+ function isPatchedModelKey(key2) {
13181
+ return patchedModelKeys.has(key2);
13182
+ }
13156
13183
  function ensureModelIndexLoaded() {
13157
- if (_modelIndexLoaded) return;
13158
- _modelIndexLoaded = true;
13159
- const catalog = loadProviderCatalog();
13160
- for (const entry of Object.values(catalog)) {
13161
- indexEntryModels(entry);
13184
+ if (indexState.loaded) return;
13185
+ indexState.loaded = true;
13186
+ try {
13187
+ const catalog = loadProviderCatalog();
13188
+ for (const entry of Object.values(catalog)) {
13189
+ indexEntryModels(entry);
13190
+ }
13191
+ } catch (err) {
13192
+ process.stderr.write(
13193
+ `[theokit-sdk] WARN: provider catalog unavailable (${err.message}) \u2014 per-model data disabled
13194
+ `
13195
+ );
13162
13196
  }
13163
13197
  }
13164
13198
  function indexEntryModels(entry) {
@@ -13422,8 +13456,10 @@ function getPricingEntry(opts) {
13422
13456
  return void 0;
13423
13457
  }
13424
13458
  function catalogCostFallback(provider, cleanedModel) {
13425
- const keys = [`${provider}/${cleanedModel}`, cleanedModel];
13426
- for (const key2 of keys) {
13459
+ const stripped = stripDateSuffix(cleanedModel);
13460
+ const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
13461
+ if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
13462
+ for (const key2 of candidates) {
13427
13463
  const info = getCatalogModelInfo(key2);
13428
13464
  const cost = info?.cost;
13429
13465
  if (cost === void 0) continue;
@@ -13435,7 +13471,8 @@ function catalogCostFallback(provider, cleanedModel) {
13435
13471
  outputCostPerMillion: cost.output,
13436
13472
  ...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
13437
13473
  ...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
13438
- pricingVersion: "catalog-vendored"
13474
+ // M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
13475
+ pricingVersion: isPatchedModelKey(key2) ? "catalog-models-dev" : "catalog-vendored"
13439
13476
  };
13440
13477
  }
13441
13478
  return void 0;