Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(probe): name the Muse signer when a signed probe request fails
Jack Rudenko20a2a87fd1bd
diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.tsindex 61551d52..e358d61d 100644--- a/packages/cli/src/cli.ts+++ b/packages/cli/src/cli.ts@@ -1595,6 +1595,8 @@ async function probeModelRouting(function museKeyProvenance(probe?: ProbeResult): KeyProvenance {const muse = describeMuseSigningSource({...(probe?.signedWith ? { signedWith: probe.signedWith } : {}),+ // Signed, then failed for another reason (a 5xx, a timeout): say how.+ ...(probe && probe.state !== "live" ? { failure: describeProbeState(probe) } : {}),probed: probe !== undefined,});return {diff --git a/packages/cli/src/handlers/composed-handler.ts b/packages/cli/src/handlers/composed-handler.tsindex 4981389d..427282a4 100644--- a/packages/cli/src/handlers/composed-handler.ts+++ b/packages/cli/src/handlers/composed-handler.ts@@ -993,7 +993,25 @@ export class ComposedHandler implements ModelHandler {}}+ /**+ * One request. Once it has been SIGNED (its headers fetched), every answer —+ * the stream, the JSON form, and an upstream error such as a 5xx or a+ * remapped 400 — names the credential that signed it, so `--probe` reports+ * the signer even when the request then failed for another reason. A request+ * that failed before it was signed (no usable login) names nothing.+ */async handle(c: Context, payload: any): Promise<Response> {+ const signing: { headers?: Record<string, string> } = {};+ const response = await this.handleSigned(c, payload, signing);+ if (!signing.headers || !this.provider.signingCredential) return response;+ return withSignerHeader(response, this.provider.signingCredential(signing.headers));+ }++ private async handleSigned(+ c: Context,+ payload: any,+ signing: { headers?: Record<string, string> }+ ): Promise<Response> {const startTime = performance.now();// Stamp the recovery deadline's ZERO POINT here, and not wherever something// first asks for it.@@ -1451,14 +1469,13 @@ export class ComposedHandler implements ModelHandler {// Every header fetch below goes through this, so a header the wire requires// (a beta token next to the field it wrote) survives the auth retries too.// The headers of THIS request's latest attempt — the one whose answer is- // returned (primary, parameter re-fetch or auth retry). Local to this call,- // so a concurrent request on the same handler cannot replace it; the- // signer named on the response is looked up from these (`signingCredential`).- let signedHeaders: Record<string, string> | undefined;+ // returned (primary, parameter re-fetch or auth retry), recorded on this+ // call's own `signing` record so a concurrent request on the same handler+ // cannot replace it. `handle` names the signer from them (`signingCredential`).const fetchHeaders = async (): Promise<Record<string, string>> => {const fetched = await this.provider.getHeaders(payload);mergeWireHeaders(fetched, wireHeaders);- signedHeaders = fetched;+ signing.headers = fetched;return fetched;};let headers: Record<string, string>;@@ -2430,12 +2447,8 @@ export class ComposedHandler implements ModelHandler {// ones, which is the bug being fixed. Claudish's own internal callers// (mcp-server.ts:235, probe-live.ts:139) both send `stream: true`// explicitly, so this changes nothing for them.- const signed = withSignerHeader(- streamed,- signedHeaders ? this.provider.signingCredential?.(signedHeaders) : undefined- );- if (payload?.stream === true) return signed;- return sseResponseToJson(signed, this.bareModelName);+ if (payload?.stream === true) return streamed;+ return sseResponseToJson(streamed, this.bareModelName);}/**diff --git a/packages/cli/src/providers/meta-muse/muse-credentials.ts b/packages/cli/src/providers/meta-muse/muse-credentials.tsindex 6de5fe39..5778ef26 100644--- a/packages/cli/src/providers/meta-muse/muse-credentials.ts+++ b/packages/cli/src/providers/meta-muse/muse-credentials.ts@@ -487,11 +487,12 @@ function displayPath(path: string): string {* R2-F28: a silent switch between the own login and a borrowed one must be* visible). Read AFTER the probe request, and in this order:*- * 1. `signedWith` — the signer THIS probe request's response named- * (`x-claudish-signed-with`). Per request, so concurrent probes in one- * process cannot borrow each other's answer.- * 2. A probe that ran and was refused because every login file was rejected+ * 1. A probe that ran and was refused because every login file was rejected* by Meta: `Muse Code login rejected`, with the rejection message.+ * 2. `signedWith` — the signer THIS probe request's response named+ * (`x-claudish-signed-with`). Per request, so concurrent probes in one+ * process cannot borrow each other's answer. Named on a failed answer too+ * (`failure`: a 5xx, a timeout): the request was signed, then failed.* 3. The files, in the order the resolve tries them, with the tier the* confirming mint wrote: what a request WOULD sign with (no probe sent, or* it failed for another reason).@@ -504,14 +505,22 @@ function displayPath(path: string): string {* Files and memos ONLY: never a Keychain question of any kind.*/export function describeMuseSigningSource(- opts: { signedWith?: string; probed?: boolean } = {}+ opts: { signedWith?: string; probed?: boolean; failure?: string } = {}): MuseSigningDescription {- if (opts.signedWith) {- return { present: true, label: opts.signedWith, detail: "signed this probe request" };- }+ // Rejected first: a request signed with a key whose re-mint then found every+ // login rejected also names its signer, but the login is what is wrong now.if (opts.probed && lastRejection) {return { present: false, label: "Muse Code login rejected", detail: lastRejection };}+ if (opts.signedWith) {+ return {+ present: true,+ label: opts.signedWith,+ detail: opts.failure+ ? `signed this probe request, which then failed: ${opts.failure}`+ : "signed this probe request",+ };+ }for (const [kind, source] of [["own-login", "claudish-login"],["borrowed-copy", "borrowed-copy"],diff --git a/packages/cli/src/providers/probe-live.ts b/packages/cli/src/providers/probe-live.tsindex 852eed42..95578dec 100644--- a/packages/cli/src/providers/probe-live.ts+++ b/packages/cli/src/providers/probe-live.ts@@ -273,7 +273,8 @@ export async function probeLink(if (!response.ok) {const body = await safeReadBody(response);return annotateOAuthHint(- classifyHttpError(response.status, body, ttfbMs),+ // A request that was signed and then failed still names its signer.+ { ...classifyHttpError(response.status, body, ttfbMs), ...signedWithOf(response) },link.provider,isOAuth);