Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(listing): show a native shortcut only where its route serves it
Jack Rudenko7c32c508717e
diff --git a/packages/cli/src/model-loader.ts b/packages/cli/src/model-loader.tsindex faae3375..fa809671 100644--- a/packages/cli/src/model-loader.ts+++ b/packages/cli/src/model-loader.ts@@ -9,7 +9,10 @@ import {import { PROVIDER_TO_PREFIX } from "./providers/auto-route.js";import { FIREBASE_CACHE_TTL_HOURS } from "./providers/cache-ttl.js";import { ensureCatalogReady } from "./providers/catalog-client.js";-import { providerForCatalogRoute } from "./providers/catalog-route-bindings.js";+import {+ catalogRouteMatchesProvider,+ providerForCatalogRoute,+} from "./providers/catalog-route-bindings.js";import {CATALOG_V3_ACCEPT,type CatalogV3Envelope,@@ -18,6 +21,7 @@ import {import type { ConnectionWire } from "./providers/connection-wire.js";import { normaliseCatalogPayload } from "./providers/content-use.js";import { compareByReleaseDateDesc } from "./providers/model-ordering.js";+import { nativeProviderForVendor } from "./providers/route-candidates.js";import type { OpenRouterModel } from "./types.js";// ─── Firebase Model Catalog Types ────────────────────────────────────────────@@ -105,6 +109,8 @@ export interface RecommendedModelEntry {supportsVision?: boolean;isModerated?: boolean;recommended?: boolean;+ /** Whether the model has a mapped connection on its vendor's native route. */+ nativeRouteAvailable?: boolean;subscription?: RecommendedSubscriptionRoute;/*** Every executable subscription route for this model, in preference order.@@ -360,8 +366,9 @@ const FIREBASE_RECOMMENDED_URL = `${FIREBASE_BASE_URL}?catalog=recommended`;* Bumped when {@link projectRecommendations} would answer differently for the* same generation. 1: content-use opt-in wire ids are never a `command`* (`content-use.ts`); a projection written before that may hold one.+ * 2: native shortcuts require a mapped connection on the vendor's native route.*/-export const RECOMMENDED_PROJECTION_VERSION = 1;+export const RECOMMENDED_PROJECTION_VERSION = 2;/*** The projected recommended-models list, on disk.@@ -536,6 +543,15 @@ export function projectRecommendations(rankByTier.set(recommended.tier, priority);const rich = richById.get(recommended.modelId);+ const nativeProvider = nativeProviderForVendor(rich?.provider ?? model.provider ?? "");+ const nativeRouteAvailable = Boolean(+ nativeProvider &&+ model.aggregators?.some(+ (connection) =>+ connection.routeStatus === "mapped" &&+ catalogRouteMatchesProvider(connection.route, nativeProvider)+ )+ );const subscription =recommended.tier === "subscription"? subscriptionRouteFor(recommended, model, catalog.plans)@@ -545,6 +561,7 @@ export function projectRecommendations(name: rich?.displayName ?? model.displayName ?? recommended.modelId,description: rich?.description ?? "",provider: rich?.provider ?? model.provider ?? "",+ nativeRouteAvailable,recommendationTier: recommended.tier,priority,pricing: {@@ -910,7 +927,7 @@ export function collectRoutingPrefixes(getNativePrefix: (firebaseSlug: string) => string | null): string[] {const slug = (group.primary.provider || "").toLowerCase();- const native = getNativePrefix(slug);+ const native = group.primary.nativeRouteAvailable === false ? null : getNativePrefix(slug);const seen = new Set<string>();const out: string[] = [];if (native) {diff --git a/packages/cli/src/recommended-listing.muse-access.test.ts b/packages/cli/src/recommended-listing.muse-access.test.tsnew file mode 100644index 00000000..e873b6f8--- /dev/null+++ b/packages/cli/src/recommended-listing.muse-access.test.ts@@ -0,0 +1,68 @@+import { expect, test } from "bun:test";+import { projectRecommendations } from "./model-loader.js";+import type { DiskCacheV3 } from "./providers/all-models-cache.js";+import {+ nativeShortcutForVendor,+ renderRecommendedMarkdown,+ renderRecommendedText,+} from "./recommended-listing.js";+import museCatalog from "./test-fixtures/catalog-v3/muse-code-g-20261021063612126-17350b71.json";++// MTL-189 follow-up: D — Access lists only published routes and wire ids (generation g-20261021063612126-17350b71).+const data = museCatalog as DiskCacheV3;+const plan = data.plans[0]!;++function listing(modelId: string) {+ return projectRecommendations(+ {+ contractVersion: plan.contractVersion!,+ generationId: data.catalogGenerationId,+ entries: [{ modelId, tier: "subscription", route: plan.route, planId: plan.id }],+ },+ data,+ [],+ new Date(data.lastUpdated)+ );+}++function access(modelId: string): string {+ return renderRecommendedMarkdown(listing(modelId), nativeShortcutForVendor)+ .split("\n")+ .find((line) => line.startsWith("- **Access**:"))!;+}++test("Wonder Full has no metered Meta connection in the real data", () => {+ const model = data.entries.find((entry) => entry.modelId === "muse-wonder-full")!;+ expect(+ model.aggregators!.every((row) => row.route?.routeProfileId === plan.route!.routeProfileId)+ ).toBe(true);+ expect(listing(model.modelId).models[0]!.subscription!.command).toBe("[email protected]");+});++test("Wonder Full Access does not offer the unserved meta@ route", () => {+ expect(access("muse-wonder-full")).not.toContain("`meta@muse-wonder-full`");+});++test("Wonder Full Access offers the muse@ subscription shortcut", () => {+ expect(access("muse-wonder-full")).toContain("`muse@muse-wonder-full`");+});++test("Wonder Full text lists muse@ without the unserved meta@ route", () => {+ const text = renderRecommendedText(listing("muse-wonder-full"), nativeShortcutForVendor);+ const via = text.split("\n").find((line) => line.includes("via:"))!;+ expect(via).toContain("muse@");+ expect(via).not.toContain("meta@");+});++test("Spark retains meta@ where the native API publishes a connection", () => {+ const model = data.entries.find((entry) => entry.modelId === "muse-spark-1.3")!;+ expect(model.aggregators).toContainEqual(+ expect.objectContaining({ route: { routeId: "meta", routeProfileId: "direct-api" } })+ );+ expect(access(model.modelId)).toContain("`[email protected]`");+ expect(access(model.modelId)).toContain("`[email protected]`");+ const text = renderRecommendedText(listing(model.modelId), nativeShortcutForVendor);+ const via = text.split("\n").find((line) => line.includes("via:"))!;+ expect(via).toContain("meta@");+ expect(via).toContain("muse@");+});