Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(probe): show the Muse Code login source and tier on the Key line
Jack Rudenko4eba3001d5db
diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.tsindex 645a2382..d9250b6c 100644--- a/packages/cli/src/cli.ts+++ b/packages/cli/src/cli.ts@@ -49,6 +49,7 @@ import { API_KEY_MAP } from "./providers/api-key-map.js";import { type KeyProvenance, resolveCredentialProvenance } from "./providers/api-key-provenance.js";import { normalizeNativeModelSpec } from "./providers/claude-code-aliases.js";import { ensureEndpointsRegistered } from "./providers/endpoint-registration.js";+import { describeMuseSigningSource } from "./providers/meta-muse/muse-credentials.js";import { parseModelChain, parseModelSpec } from "./providers/model-parser.js";import { NATIVE_NOT_PROBED } from "./providers/native-route.js";import { fetchOllamaModels } from "./providers/ollama-discovery.js";@@ -1592,6 +1593,24 @@ async function probeModelRouting(* instruction — its `effectiveSource` is the sentence that names both* remedies. Everyone else keeps the bare variable name they always had.*/+ /**+ * The Muse Code credential as a provenance record, through `effectiveLabel`+ * (the channel for a credential that is not an env var). Present:+ * `Key Muse Code borrowed copy · Muse Code Power Usage (signed the probe request)`.+ * Absent: `Key no Muse Code login (<the §4.2 login instruction>)`.+ */+ function museKeyProvenance(): KeyProvenance {+ const muse = describeMuseSigningSource();+ return {+ envVar: "",+ hasValue: muse.present,+ effectiveMasked: null,+ effectiveSource: muse.detail,+ effectiveLabel: muse.label,+ layers: [],+ };+ }+function credentialHintFrom(provenance: KeyProvenance | undefined,envVar: string | undefined@@ -1617,6 +1636,10 @@ async function probeModelRouting();},provenanceFor(provider) {+ // muse@ signs with a login, never an env var: its Key line names the+ // source and the tier (contract §4.3 item 5), from files and process+ // state only, so a probe in role `never` asks no Keychain question.+ if (provider === "meta-muse-code") return museKeyProvenance();const keyInfo = API_KEY_MAP[provider];return keyInfo?.envVar? resolveCredentialProvenance(provider, keyInfo.envVar, keyInfo.aliases)@@ -2017,6 +2040,12 @@ async function probeModelRouting(const printable: PrintableModelResult[] = [];const results: ProbeModelResult[] = [];for (const probe of modelProbes) {+ // The chain's provenance was read BEFORE the live requests. A muse@ hop's+ // is read again now, so its Key line names the source and tier the+ // probe request actually signed with (the proxy is in this process).+ for (const link of probe.chain) {+ if (link.provider === "meta-muse-code") link.provenance = museKeyProvenance();+ }const wiring = await computeWiring(probe.chain, probe.explanation.routedModel);const fields = routingFieldsFrom(probe.explanation);printable.push({diff --git a/packages/cli/src/providers/meta-muse/muse-credentials.ts b/packages/cli/src/providers/meta-muse/muse-credentials.tsindex 2298ecdc..1cdf58d7 100644--- a/packages/cli/src/providers/meta-muse/muse-credentials.ts+++ b/packages/cli/src/providers/meta-muse/muse-credentials.ts@@ -33,6 +33,7 @@* writes the Muse Code CLI's own Keychain item.*/+import { homedir } from "node:os";import { credentialPromptRole } from "../../auth/credentials/prompt-role.js";import { log } from "../../logger.js";import {@@ -43,7 +44,12 @@ import {withMuseKeychainLogin,} from "./muse-keychain.js";import { MuseLoginExpiredError, type MuseMint, mintMuseApiKey } from "./muse-mint.js";-import { defaultMuseStoreDir, readMuseStore, writeBorrowedCopy } from "./muse-store.js";+import {+ defaultMuseStoreDir,+ museStorePath,+ readMuseStore,+ writeBorrowedCopy,+} from "./muse-store.js";/** Re-mint once the entitlement confirmation is older than this. */export const MUSE_ENTITLEMENT_TTL_MS = 30 * 60_000;@@ -400,6 +406,63 @@ export function isMuseCredentialConfigured(status: MuseCredentialStatus): booleareturn status === "own-login" || status === "borrowed-copy" || status === "keychain";}+/** How `--probe` names each signing source. */+const SOURCE_LABELS: Record<MuseSource, string> = {+ "claudish-login": "claudish login",+ "borrowed-copy": "borrowed copy",+ keychain: "Muse Code CLI Keychain login",+};++/** What `--probe`'s Key line says about the Muse Code credential. */+export interface MuseSigningDescription {+ /** False when no source is known: no state in this process and neither file. */+ present: boolean;+ /** `Muse Code <source> · <tier>`, or `no Muse Code login`. */+ label: string;+ /** Where that came from: the request that signed, the file, or the remedy. */+ detail: string;+}++function displayPath(path: string): string {+ const home = homedir();+ return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;+}++/**+ * The source and tier a muse@ request signs (or would sign) with, for+ * `--probe` (contract §4.3 item 5 / R2-F28: a silent switch between the own+ * login and a borrowed one must be visible).+ *+ * Files and process state ONLY — never a Keychain read of any kind, so it is+ * safe in role `never`. The installed state wins: it is the source and tier+ * the last request in THIS process actually signed with (the probe's own proxy+ * runs in-process). Without one, the files are read in the order the resolve+ * tries them, and the tier is the `subs_tier_name` the confirming mint wrote.+ */+export function describeMuseSigningSource(): MuseSigningDescription {+ if (state) {+ return {+ present: true,+ label: `Muse Code ${SOURCE_LABELS[state.source]} · ${state.subsTierName ?? "tier unknown"}`,+ detail: "signed the probe request",+ };+ }+ for (const [kind, source] of [+ ["own-login", "claudish-login"],+ ["borrowed-copy", "borrowed-copy"],+ ] as const) {+ const record = deps.readStore(kind, deps.dir());+ if (!record) continue;+ const tier = typeof record.subs_tier_name === "string" ? record.subs_tier_name : undefined;+ return {+ present: true,+ label: `Muse Code ${SOURCE_LABELS[source]} · ${tier ?? "tier unknown"}`,+ detail: `${displayPath(museStorePath(kind, deps.dir()))}, not yet confirmed in this process`,+ };+ }+ return { present: false, label: "no Muse Code login", detail: MUSE_NO_LOGIN_MESSAGE };+}+/** The last resolve failure's message, for diagnostics. */export function lastMuseCredentialFailure(): string | undefined {return lastFailure;