claudish 7.58.0 → 7.59.0

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.
Files changed (2) hide show
  1. package/dist/index.js +70 -2
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -729,7 +729,7 @@ var init_onepassword_config = __esm(() => {
729
729
  });
730
730
 
731
731
  // src/version.ts
732
- var VERSION = "7.58.0";
732
+ var VERSION = "7.59.0";
733
733
 
734
734
  // src/logger.ts
735
735
  var exports_logger = {};
@@ -45049,6 +45049,36 @@ var init_default_routing_rules = __esm(() => {
45049
45049
  validateDefaultRoutingRules();
45050
45050
  });
45051
45051
 
45052
+ // src/providers/model-availability.ts
45053
+ function rosterHas(ids, wireId) {
45054
+ const needle = wireId.trim().toLowerCase();
45055
+ return ids.some((id) => id.trim().toLowerCase() === needle);
45056
+ }
45057
+ async function providerServesModel(provider, wireId) {
45058
+ const def = getProviderByName(provider);
45059
+ if (def?.modelDiscovery) {
45060
+ const models = await discoverProviderModels(provider);
45061
+ if (models.length > 0) {
45062
+ return rosterHas(models.map((m) => m.id), wireId) ? "serves" : "not-served";
45063
+ }
45064
+ getDiscoveryFailure(provider);
45065
+ return "unknown";
45066
+ }
45067
+ const entries = getCatalogEntries();
45068
+ if (!entries)
45069
+ return "unknown";
45070
+ const needle = wireId.trim().toLowerCase();
45071
+ const row = entries.find((e) => e.modelId.toLowerCase() === needle || e.aliases.some((a) => a.toLowerCase() === needle) || (e.aggregators ?? []).some((a) => a.externalId?.toLowerCase() === needle));
45072
+ if (!row)
45073
+ return "unknown";
45074
+ return (row.aggregators ?? []).some((a) => a.provider === provider) ? "serves" : "unknown";
45075
+ }
45076
+ var init_model_availability = __esm(() => {
45077
+ init_catalog_client();
45078
+ init_model_discovery();
45079
+ init_provider_definitions();
45080
+ });
45081
+
45052
45082
  // src/providers/routing-rules.ts
45053
45083
  function mergeRoutingRules(defaults, global_, local) {
45054
45084
  return { ...defaults, ...global_, ...local };
@@ -45157,6 +45187,13 @@ async function routeExplicit(modelSpec, model, provider, cachePath) {
45157
45187
  reason: `Could not build a route for "${modelSpec}".`
45158
45188
  };
45159
45189
  }
45190
+ if (await providerServesModel(built.provider, wireIdOf(built)) === "not-served") {
45191
+ return {
45192
+ kind: "no-route",
45193
+ reason: `${built.displayName} does not serve "${model}".`,
45194
+ hint: `Check the model id, or use a bare \`${model}\` to let claudish pick a provider ` + "that carries it."
45195
+ };
45196
+ }
45160
45197
  return { kind: "ok", primary: built, fallbacks: [] };
45161
45198
  }
45162
45199
  async function routeBare(model, nativeProvider, rules, defaultProvider, cachePath) {
@@ -45198,9 +45235,37 @@ async function routeBare(model, nativeProvider, rules, defaultProvider, cachePat
45198
45235
  hint: buildCredentialHint(model, skipped) ?? undefined
45199
45236
  };
45200
45237
  }
45201
- const [primary, ...fallbacks] = credentialed;
45238
+ const availability = await Promise.all(credentialed.map((candidate) => providerServesModel(candidate.provider, wireIdOf(candidate))));
45239
+ const serving = [];
45240
+ const notServing = [];
45241
+ credentialed.forEach((candidate, i) => {
45242
+ if (availability[i] === "not-served") {
45243
+ notServing.push(candidate.provider);
45244
+ } else {
45245
+ serving.push(candidate);
45246
+ }
45247
+ });
45248
+ if (serving.length === 0) {
45249
+ return {
45250
+ kind: "no-route",
45251
+ reason: `No provider serves "${model}" (checked: ${notServing.join(", ")}).`,
45252
+ hint: buildCredentialHint(model, notServing) ?? undefined
45253
+ };
45254
+ }
45255
+ if (notServing.length > 0) {
45256
+ log(`[routing] ${model}: skipped ${notServing.join(", ")} \u2014 does not serve this model`);
45257
+ const droppedSubscription = notServing.filter((p) => isSubscriptionProvider(p));
45258
+ if (droppedSubscription.length > 0 && !isSubscriptionProvider(serving[0].provider)) {
45259
+ logStderr(`[claudish] ${droppedSubscription.join(", ")} does not serve ${model} \u2014 ` + `using ${serving[0].displayName}, which bills per token.`);
45260
+ }
45261
+ }
45262
+ const [primary, ...fallbacks] = serving;
45202
45263
  return { kind: "ok", primary, fallbacks };
45203
45264
  }
45265
+ function wireIdOf(route) {
45266
+ const at = route.modelSpec.indexOf("@");
45267
+ return at === -1 ? route.modelSpec : route.modelSpec.slice(at + 1);
45268
+ }
45204
45269
  function normalizeGlmSlug(model) {
45205
45270
  return model.replace(/^glm-(\d+)-(\d+)(-.*)?$/i, (_m, major, minor, suffix) => `glm-${major}.${minor}${suffix ?? ""}`);
45206
45271
  }
@@ -45216,10 +45281,13 @@ async function route(modelSpec, rulesOverride, defaultProviderOverride, cachePat
45216
45281
  var init_routing_rules = __esm(() => {
45217
45282
  init_model_catalog();
45218
45283
  init_authority();
45284
+ init_remote_provider_types();
45285
+ init_logger();
45219
45286
  init_profile_config();
45220
45287
  init_auto_route();
45221
45288
  init_catalog_client();
45222
45289
  init_default_routing_rules();
45290
+ init_model_availability();
45223
45291
  init_model_parser();
45224
45292
  init_model_parser();
45225
45293
  init_routing_hints();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "7.58.0",
3
+ "version": "7.59.0",
4
4
  "description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "ai"
61
61
  ],
62
62
  "optionalDependencies": {
63
- "@claudish/magmux-darwin-arm64": "7.58.0",
64
- "@claudish/magmux-darwin-x64": "7.58.0",
65
- "@claudish/magmux-linux-arm64": "7.58.0",
66
- "@claudish/magmux-linux-x64": "7.58.0"
63
+ "@claudish/magmux-darwin-arm64": "7.59.0",
64
+ "@claudish/magmux-darwin-x64": "7.59.0",
65
+ "@claudish/magmux-linux-arm64": "7.59.0",
66
+ "@claudish/magmux-linux-x64": "7.59.0"
67
67
  },
68
68
  "author": "Jack Rudenko <i@madappgang.com>",
69
69
  "license": "MIT",