Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
feat(meta-muse-code): borrow reasoning effort from the meta direct-api wire
Jack Rudenko795c8aaad441
diff --git a/packages/cli/src/providers/meta-muse/muse-wire.ts b/packages/cli/src/providers/meta-muse/muse-wire.tsnew file mode 100644index 00000000..ace9abf9--- /dev/null+++ b/packages/cli/src/providers/meta-muse/muse-wire.ts@@ -0,0 +1,51 @@+/**+ * The request shape for `muse@`, borrowed from Meta's own direct-API wire.+ *+ * `meta-muse-code` has no catalog route binding yet (models-index publishes+ * its subscription profile later), so no connection describes how a Muse Code+ * request encodes its output limit and reasoning effort. Meta's METERED API+ * does: `meta/direct-api` publishes a known `responses` wire per model —+ * `max_output_tokens`, effort at `/reasoning/effort` with the values+ * `minimal … max` — and the subscription speaks the same Responses API to the+ * same host for the same model ids (muse-wire.md §4–5). So the owner's wire is+ * borrowed, exactly as `findOwnerWire` borrows an owner's fields elsewhere:+ *+ * - only from a KNOWN wire on the SAME API (`responses`);+ * - never its mode or speed: those carry entitlement and price (wire.md), so+ * both are set to `unknown` on the borrowed copy and step 5w sends neither;+ * - the exact wire id first (an explicit contributor id gets its own+ * connection's wire), never a family or sibling.+ *+ * A model the metered API does not publish (`muse-wonder-full-1.0`) gets no+ * borrowed wire, and its effort is whatever the Responses adapter sends.+ */++import { type ResolvedConnection, resolveConnection } from "../connection-resolver.js";+import type { KnownWire } from "../connection-wire.js";++/**+ * The owner wire to shape `muse@<modelName>` with, as a connection labelled+ * for `meta-muse-code`; undefined when Meta's direct API publishes no known+ * Responses wire for that id.+ */+export function ownerWireForModel(+ modelName: string,+ cachePath?: string+): ResolvedConnection | undefined {+ const resolution = cachePath+ ? resolveConnection("meta", modelName, cachePath)+ : resolveConnection("meta", modelName);+ if (!resolution.ok) return undefined;+ const { connection } = resolution;+ const wire = connection.wire;+ if (wire.status !== "known" || wire.api !== "responses") return undefined;+ const borrowed: KnownWire = {+ ...wire,+ speed: { status: "unknown" },+ reasoning:+ wire.reasoning.status === "supported"+ ? { ...wire.reasoning, mode: { status: "unknown" } }+ : wire.reasoning,+ };+ return { ...connection, provider: "meta-muse-code", wire: borrowed };+}diff --git a/packages/cli/src/providers/provider-profiles.ts b/packages/cli/src/providers/provider-profiles.tsindex 6b310809..29ab6375 100644--- a/packages/cli/src/providers/provider-profiles.ts+++ b/packages/cli/src/providers/provider-profiles.ts@@ -36,7 +36,9 @@ import { ComposedHandler } from "../handlers/composed-handler.js";import type { ModelHandler } from "../handlers/types.js";import { log, logStderr } from "../logger.js";import { formatProvenanceLog, resolveCredentialProvenance } from "./api-key-provenance.js";+import { ensureRouteRegistryReady } from "./catalog-client.js";import { declaredConnection, declaredWire } from "./declared-wire.js";+import { ownerWireForModel } from "./meta-muse/muse-wire.js";import { getProviderByName } from "./provider-definitions.js";import { getRuntimeProfiles } from "./runtime-providers.js";import { AnthropicProviderTransport } from "./transport/anthropic-compat.js";@@ -227,20 +229,37 @@ export const grokSubscriptionProfile: ProviderProfile = {* Responses format and the transport adds the CLI's `store: false` body.* The empty api key is intentional: `MuseCodeTransport` signs per request.*/-export const museCodeProfile: ProviderProfile = {- createHandler(ctx) {+export const museCodeProfile: AsyncProviderProfile = {+ async createHandler(ctx) {const transport = new MuseCodeTransport(ctx.provider, ctx.modelName, "");const adapter = new CodexAPIFormat(ctx.modelName);+ // The output limit and effort encoding are borrowed from Meta's own+ // direct-API wire for the same id (`muse-wire.ts`). Its own short wait for+ // the route registry, not the request path's 30 s: a cold registry skips+ // the borrow (and says so) rather than holding the handler. The cache path+ // is the test seam, which is never refreshed from the network.+ if (!ctx.catalogCachePath) await ensureRouteRegistryReady(MUSE_REGISTRY_WAIT_MS);+ const connection = ownerWireForModel(ctx.modelName, ctx.catalogCachePath);+ if (!connection) {+ log(+ `[Proxy] Muse Code ${ctx.modelName}: no meta/direct-api responses wire to borrow ` ++ "(model not published there, or the route registry is not ready); effort is the adapter's"+ );+ }const handler = new ComposedHandler(transport, ctx.targetModel, ctx.modelName, ctx.port, {adapter,tokenStrategy: "delta-aware",...ctx.sharedOpts,+ ...(connection ? { connection } : {}),});log(`[Proxy] Created Muse Code handler (composed): ${ctx.modelName}`);return handler;},};+/** How long building a `muse@` handler waits for the route registry (see museCodeProfile). */+const MUSE_REGISTRY_WAIT_MS = 5_000;+/*** OpenAI-compatible Chat Completions, for a provider the catalog does not route.* A catalog connection never reaches this profile: `buildWireHandler` builds it