@blockrun/clawrouter 0.12.301 → 0.12.302

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/cli.js CHANGED
@@ -45706,10 +45706,10 @@ function isEligible(modelId, features, maxOutputTokens, options) {
45706
45706
  return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;
45707
45707
  }
45708
45708
  function estimatedCost(modelId, options, inputTokens, outputTokens) {
45709
- const price = options.modelPricing.get(modelId);
45710
- if (!price) return Number.POSITIVE_INFINITY;
45711
- if (price.flatPrice !== void 0) return price.flatPrice;
45712
- return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1e6;
45709
+ const price2 = options.modelPricing.get(modelId);
45710
+ if (!price2) return Number.POSITIVE_INFINITY;
45711
+ if (price2.flatPrice !== void 0) return price2.flatPrice;
45712
+ return (inputTokens * price2.inputPrice + outputTokens * price2.outputPrice) / 1e6;
45713
45713
  }
45714
45714
  function profileScore(modelId, options, now2) {
45715
45715
  const profile = options.modelPerformance?.[modelId] ?? LIVE_MODEL_PROFILES[modelId] ?? HISTORICAL_MODEL_PROFILES[modelId];
package/dist/index.js CHANGED
@@ -259128,10 +259128,10 @@ function isEligible(modelId, features, maxOutputTokens, options) {
259128
259128
  return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;
259129
259129
  }
259130
259130
  function estimatedCost(modelId, options, inputTokens, outputTokens) {
259131
- const price = options.modelPricing.get(modelId);
259132
- if (!price) return Number.POSITIVE_INFINITY;
259133
- if (price.flatPrice !== void 0) return price.flatPrice;
259134
- return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1e6;
259131
+ const price2 = options.modelPricing.get(modelId);
259132
+ if (!price2) return Number.POSITIVE_INFINITY;
259133
+ if (price2.flatPrice !== void 0) return price2.flatPrice;
259134
+ return (inputTokens * price2.inputPrice + outputTokens * price2.outputPrice) / 1e6;
259135
259135
  }
259136
259136
  function profileScore(modelId, options, now2) {
259137
259137
  const profile = options.modelPerformance?.[modelId] ?? LIVE_MODEL_PROFILES[modelId] ?? HISTORICAL_MODEL_PROFILES[modelId];
@@ -2361,10 +2361,10 @@ function isEligible(modelId, features, maxOutputTokens, options) {
2361
2361
  return model.contextWindow >= (features.estimatedInputTokens + maxOutputTokens) * 1.1;
2362
2362
  }
2363
2363
  function estimatedCost(modelId, options, inputTokens, outputTokens) {
2364
- const price = options.modelPricing.get(modelId);
2365
- if (!price) return Number.POSITIVE_INFINITY;
2366
- if (price.flatPrice !== void 0) return price.flatPrice;
2367
- return (inputTokens * price.inputPrice + outputTokens * price.outputPrice) / 1e6;
2364
+ const price2 = options.modelPricing.get(modelId);
2365
+ if (!price2) return Number.POSITIVE_INFINITY;
2366
+ if (price2.flatPrice !== void 0) return price2.flatPrice;
2367
+ return (inputTokens * price2.inputPrice + outputTokens * price2.outputPrice) / 1e6;
2368
2368
  }
2369
2369
  function profileScore(modelId, options, now) {
2370
2370
  const profile = options.modelPerformance?.[modelId] ?? LIVE_MODEL_PROFILES[modelId] ?? HISTORICAL_MODEL_PROFILES[modelId];
@@ -2525,6 +2525,81 @@ var PortfolioStrategy = class {
2525
2525
  };
2526
2526
  }
2527
2527
  };
2528
+ var MODEL_KINDS = ["chat", "image", "video", "music"];
2529
+ var PRICE_KEYS = [
2530
+ "input",
2531
+ "output",
2532
+ "per_image",
2533
+ "per_second",
2534
+ "per_track",
2535
+ "cache_read",
2536
+ "cache_write",
2537
+ "transaction_fee",
2538
+ "per_call_surcharge",
2539
+ "default_duration_seconds",
2540
+ "max_duration_seconds"
2541
+ ];
2542
+ var UNIT_PRICE = { image: "per_image", video: "per_second", music: "per_track" };
2543
+ var MODEL_ID = /^[a-z0-9][a-z0-9._-]*\/[a-zA-Z0-9][a-zA-Z0-9._:+-]*$/;
2544
+ var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
2545
+ var price = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
2546
+ var capacity = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
2547
+ function parseModelCatalog(value) {
2548
+ if (!record(value) || !Array.isArray(value.data)) {
2549
+ throw new TypeError("Model catalog must contain a data array");
2550
+ }
2551
+ const entries = /* @__PURE__ */ new Map();
2552
+ for (const entry of value.data) {
2553
+ if (record(entry) && typeof entry.id === "string" && entry.id.length <= 200 && MODEL_ID.test(entry.id)) {
2554
+ entries.set(entry.id, entry);
2555
+ }
2556
+ }
2557
+ const result = { models: [], chat: [], image: [], video: [], music: [], unavailable: [] };
2558
+ const models = [];
2559
+ const unavailable = [];
2560
+ for (const [id, entry] of entries) {
2561
+ if (entry.available === false) unavailable.push(id);
2562
+ if (entry.available !== void 0 && entry.available !== true || entry.hidden !== void 0 && entry.hidden !== false || !Array.isArray(entry.categories) || !record(entry.pricing)) continue;
2563
+ const categories = [...new Set(entry.categories.filter((c) => typeof c === "string"))];
2564
+ const rawPricing = entry.pricing;
2565
+ const pricing = {};
2566
+ for (const key of PRICE_KEYS) if (price(rawPricing[key])) pricing[key] = rawPricing[key];
2567
+ const kinds = MODEL_KINDS.filter((kind) => categories.includes(kind) && (kind === "chat" ? price(rawPricing.input) && price(rawPricing.output) : price(rawPricing[UNIT_PRICE[kind]])));
2568
+ if (!kinds.length) continue;
2569
+ const model = {
2570
+ id,
2571
+ name: typeof entry.name === "string" && entry.name.trim() ? entry.name : id,
2572
+ categories,
2573
+ kinds,
2574
+ pricing,
2575
+ free: kinds.includes("chat") && entry.billing_mode === "free" && pricing.input === 0 && pricing.output === 0,
2576
+ ...typeof entry.billing_mode === "string" ? { billingMode: entry.billing_mode } : {},
2577
+ ...capacity(entry.context_window) !== void 0 ? { contextWindow: capacity(entry.context_window) } : {},
2578
+ ...capacity(entry.max_output) !== void 0 ? { maxOutputTokens: capacity(entry.max_output) } : {}
2579
+ };
2580
+ models.push(model);
2581
+ }
2582
+ result.models = models;
2583
+ result.unavailable = unavailable;
2584
+ for (const kind of MODEL_KINDS) result[kind] = models.filter((model) => model.kinds.includes(kind));
2585
+ return result;
2586
+ }
2587
+ function toRoutingCatalog(catalog, options = {}) {
2588
+ const verified = { ...DEFAULT_MODEL_CAPABILITIES, ...options.verifiedCapabilities };
2589
+ const modelPricing = /* @__PURE__ */ new Map();
2590
+ const modelCapabilities = {};
2591
+ for (const model of catalog.chat) {
2592
+ modelPricing.set(model.id, { inputPrice: model.pricing.input, outputPrice: model.pricing.output });
2593
+ const evidence = verified[model.id];
2594
+ modelCapabilities[model.id] = {
2595
+ contextWindow: model.contextWindow ?? evidence?.contextWindow ?? 0,
2596
+ maxOutputTokens: model.maxOutputTokens ?? evidence?.maxOutputTokens ?? 0,
2597
+ supportsTools: evidence?.supportsTools === true,
2598
+ supportsVision: model.categories.includes("vision")
2599
+ };
2600
+ }
2601
+ return { modelPricing, modelCapabilities, unavailableModels: [...catalog.unavailable] };
2602
+ }
2528
2603
  var DEFAULT_ROUTING_CONFIG = {
2529
2604
  version: "3.5",
2530
2605
  strategy: "portfolio",
@@ -4021,6 +4096,7 @@ export {
4021
4096
  DEFAULT_ROUTING_CONFIG,
4022
4097
  HISTORICAL_MODEL_PROFILES,
4023
4098
  LIVE_MODEL_PROFILES,
4099
+ MODEL_KINDS,
4024
4100
  PortfolioStrategy,
4025
4101
  RulesStrategy,
4026
4102
  applyUnavailableModels,
@@ -4035,7 +4111,9 @@ export {
4035
4111
  getFallbackChainFiltered,
4036
4112
  getStrategy,
4037
4113
  inferToolRequirement,
4114
+ parseModelCatalog,
4038
4115
  registerStrategy,
4039
- route
4116
+ route,
4117
+ toRoutingCatalog
4040
4118
  };
4041
4119
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.301",
3
+ "version": "0.12.302",
4
4
  "description": "Smart LLM router — save 84% on inference costs. 90 models (7 free). Pay by credit card (API key) or USDC (x402 wallet).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -116,7 +116,7 @@
116
116
  },
117
117
  "devDependencies": {
118
118
  "@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/b95efe2f025c9968742e6479bc9ec71b6a40c0f4",
119
- "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/8773a9954b091bd0090acdfec67c75a006c0e156",
119
+ "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/fd6d03d035ff676642ba1683c333d929939f8a00",
120
120
  "@eslint/js": "^10.0.1",
121
121
  "eslint": "^10.2.0",
122
122
  "openclaw": "^2026.7.2-beta.7",