Skip to content

feat(oauth): add experimental Muse Code subscription provider - #14492

Closed
CanadaOrNaw wants to merge 1 commit into
cheaper-inference:release/v3.8.53from
CanadaOrNaw:feat/muse-code-subscription
Closed

CanadaOrNaw wants to merge 1 commit into
cheaper-inference:release/v3.8.53from
CanadaOrNaw:feat/muse-code-subscription

Conversation

@CanadaOrNaw

@CanadaOrNaw CanadaOrNaw commented Sep 22, 2026 •

Copy link
Copy Markdown

Summary
Adds an experimental Muse Code subscription-backed provider for OmniRoute using Meta's device-login flow and the Muse Code key-mint endpoint.
Provider ID: muse-code-subscription
Alias: mcs
This implementation keeps Muse subscription credentials separate from generic Meta API-key billing and from the existing Muse web/API paths.
Authentication flow

  1. Request a Meta device code.
  2. User approves the login in their browser.
  3. Exchange the device code for a DCA/session token.
  4. Exchange that DCA token at https://api.meta.ai/muse-code/key.
  5. Require is_subs_active === true and reject require_payment === true.
  6. Persist only the minted Muse Code inference key through OmniRoute's existing OAuth credential storage.
  7. Route native Responses requests to https://api.meta.ai/v1/responses.
    The implementation deliberately does not:
  • treat META_API_KEY as a subscription credential;
  • silently fall back to pay-as-you-go API billing;
  • spawn or wrap the Muse CLI;
  • execute model-proposed tools on the OmniRoute server;
  • persist the DCA token as an OAuth refresh token;
  • copy the DCA token's expiry onto the minted inference key.
    Related Issues / PRs
  • Related to [Feature] Muse Spark CLI Support (monthly subscription plan quota via Muse Code) #13415
  • Related to feat(oauth): add Muse Code subscription provider (muse-code-oauth) + fix muse-code apikey #14138
  • Related to feat(oauth): Muse Code subscription device-flow login #14267
  • Related to feat(oauth): add Muse Code device login with CLIProxyAPI-parity remint #14329
    Several implementations of Muse subscription auth are currently open. Their main architectural differences are around provider identity and the DCA/key lifecycle.
    This PR is intentionally a draft alternative / comparison implementation, not a claim that it should supersede the other open PRs. In particular:
  • feat(oauth): Muse Code subscription device-flow login #14267 reports live Meta login and gateway inference validation.
  • feat(oauth): add Muse Code device login with CLIProxyAPI-parity remint #14329 retains the DCA credential for re-minting and implements a fuller refresh lifecycle.
  • This PR takes the more conservative position of discarding DCA after minting until the key lifecycle is verified, requiring a fresh device login after a 401.
    Maintainers should prefer whichever lifecycle and provider structure is best supported by Meta's current behavior and product terms.
    Changes
  • Add muse-code-subscription / mcs provider registration.
  • Add dedicated Muse subscription executor and dashboard metadata.
  • Add RFC 8628-style device authorization and polling.
  • Add Muse Code subscription-key minting through /muse-code/key.
  • Require an active subscription before saving the minted key.
  • Reject pay-as-you-go fallback and ordinary API-key substitution.
  • Use a fixed inference destination: https://api.meta.ai/v1/responses.
  • Reject redirects and unexpected verification/inference hosts.
  • Bound authentication requests by timeout and response size.
  • Sanitize authentication errors so upstream bodies, tokens, URLs, and stack traces are not reflected.
  • Reject extra API-key rotation and caller auth/header overrides on this provider.
  • Preserve upstream 403 / 429 / 5xx behavior for OmniRoute's existing routing logic.
  • Convert upstream 401 into a sanitized re-login error.
  • Force native Responses streaming while retaining OmniRoute's existing stream accumulation path for non-streaming clients.
  • Add explicit standard and Contributor model entries rather than silently switching between data-use modes.
  • Update executor-map golden snapshot.
  • Add provider documentation and a live-acceptance checklist.
    Tests Added Or Updated
  • tests/unit/auth/muse-code-subscription-protocol.test.ts
  • tests/unit/auth/muse-code-subscription-http.test.ts
  • tests/unit/muse-code-subscription-integration.test.ts
  • tests/snapshots/executors/executor-map.json
    The protocol tests cover device authorization, RFC 8628 polling behavior, hostile verification URLs, DCA-to-key minting, active-subscription enforcement, inference-endpoint pinning, credential provenance, error redaction, response-size bounds, Responses normalization, tool-result continuity, vision payload preservation, and generic API-key rejection.
    The HTTP test exercises the complete flow against a loopback mock server: device code -> pending -> approved -> key mint -> authenticated Responses SSE request.
    Validation
    Change type: provider / OAuth / routing
    Pre-publication sandbox validation performed on the prepared implementation:
  • Dependency-free protocol/HTTP tests: 50 passed, 0 failed
  • Strict TypeScript check of the dependency-free protocol core/tests
  • New TypeScript files parsed successfully
  • Patch application/stat verification completed
  • Production-code changes include new automated tests
  • Full OmniRoute dependency install/build
  • npm run lint
  • npm run typecheck:core
  • Full focused provider/OAuth test matrix in a complete checkout
  • Reconcile/rebase against the latest active release base and rerun focused checks
  • Full CI
    The published branch is a single commit with 17 changed files, 1,298 insertions, and 1 deletion.
    Coverage Notes
    New production paths are covered by the new protocol, HTTP, and integration tests. The standalone protocol/HTTP tests intentionally avoid importing the full OmniRoute application so they can validate the credential and transport contract independently.
    The full application integration test still needs to be run in a complete checkout with OmniRoute dependencies installed.
    Live Validation Required Before Ready for Review
    This PR should remain draft until the following are verified with an active Muse Code subscription:
  • Complete a real Meta device login.
  • Confirm a subscription key is minted successfully.
  • Send one minimal request through OmniRoute using muse-spark-1.3.
  • Verify the request consumes Muse Code subscription allowance.
  • Verify it does not create separate Meta API billing.
  • Test streaming output.
  • Test non-streaming accumulation.
  • Test a function/tool call plus its result on the next turn.
  • Test cancellation.
  • Test revoked/expired credentials.
  • Decide, based on observed key lifecycle, whether DCA should remain discarded or be retained for automatic re-minting.
  • Compare live behavior with feat(oauth): Muse Code subscription device-flow login #14267 and feat(oauth): add Muse Code device login with CLIProxyAPI-parity remint #14329 before choosing a final architecture.
    A successful HTTP 200 alone is not sufficient evidence for the billing boundary. Subscription-meter movement and API billing need to be checked separately.
    Reviewer Notes
    Security / billing boundary
    Authentication and inference destinations are fixed. The provider does not accept generic API keys, alternate base URLs, extra key rotation, or caller-supplied auth headers. This is intended to reduce the chance of accidentally crossing from subscription usage into normal API billing.
    The client identifies itself as OmniRoute/MuseCodeSubscription rather than impersonating a specific official Muse CLI build.
    Credential lifecycle
    This PR takes a conservative lifecycle approach:
  • DCA is used only to mint the Muse Code key.
  • DCA is not persisted as refreshToken.
  • DCA expiry is not treated as minted-key expiry.
  • A 401 requires a new device login.
    That may be too conservative if Meta expects DCA retention for key re-minting. feat(oauth): add Muse Code device login with CLIProxyAPI-parity remint #14329 takes the opposite approach and is useful comparison material.
    Protocol research
    The key-mint wire contract was independently implemented from the public CLIProxyAPI Meta integration. Meta's current documentation and observed live behavior should remain the source of truth for whether this credential can be routed by third-party clients and how usage is metered.
    See docs/providers/MUSE_CODE_SUBSCRIPTION.md for the implementation assumptions and full live-acceptance checklist.

@CanadaOrNaw
CanadaOrNaw marked this pull request as draft September 22, 2026 11:58
@diegosouzapw diegosouzapw changed the title feat(oauth): add experimental Muse Code subscription provider [defer] feat(oauth): add experimental Muse Code subscription provider Sep 25, 2026
@diegosouzapw diegosouzapw added the deferred-v3.8.52 Grande demais / suspeito para o lote atual; precisa de sessão dedicada no ciclo v3.8.52 label Sep 25, 2026
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.51 to release/v3.8.52 September 29, 2026 11:21
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Re-homed to release/v3.8.52: v3.8.51 entered its release freeze, so the branch now belongs to the release captain and development continues on the next cycle. Nothing is wrong with this PR — it just needed a live base. No action needed from you; CI will re-run against the new base.

@diegosouzapw diegosouzapw changed the title [defer] feat(oauth): add experimental Muse Code subscription provider feat(oauth): add experimental Muse Code subscription provider Oct 1, 2026
@diegosouzapw diegosouzapw removed the deferred-v3.8.52 Grande demais / suspeito para o lote atual; precisa de sessão dedicada no ciclo v3.8.52 label Oct 1, 2026
thinh0704hcm pushed a commit to thinh0704hcm/OmniRoute that referenced this pull request Oct 5, 2026
, cheaper-inference#14138, cheaper-inference#13634, cheaper-inference#14267, cheaper-inference#12687)

Single branch with everything useful from the open Muse Code PRs that
release/v3.8.52 does not have yet:

- cheaper-inference#15234: session-pinned multi-account round-robin, same-owner
  empty-response retry, semantic-cache bypass, Responses URL fix for
  custom baseUrl, 512 output-token floor.
- cheaper-inference#12687: opencode-go sends reasoning.effort=max verbatim for
  muse-spark-1.3+, one xhigh retry on the unsupported-effort 400.
- cheaper-inference#13634: MuseCodeExecutor restores the 24h prompt_cache_retention
  window stripped by the generic sanitizer.
- cheaper-inference#14267: device-flow hardening (origin pin, expiry cap, poll-error
  allowlist, bounded auth requests).
- cheaper-inference#14138: mint-failure contract (401/403 forces re-login,
  429/transient keeps the stored key).

Skipped as subsumed or rejected: duplicate OAuth flows (merged
cheaper-inference#14329 covers them), cheaper-inference#14492 parallel provider, llama catalog
removals, command-code/freebuff catalog additions.

Co-authored-by: mdc2122 <mdc2122@users.noreply.github.com>
Co-authored-by: SIGTERM-015 <SIGTERM-015@users.noreply.github.com>
Co-authored-by: KSonny4 <KSonny4@users.noreply.github.com>
Co-authored-by: caniko <caniko@users.noreply.github.com>
Co-authored-by: Chewji9875 <Chewji9875@users.noreply.github.com>
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Hi @CanadaOrNaw — closing this pull request to clear the open queue. The branch feat/muse-code-subscription is kept, so the commits stay. Comment here if it should be reopened.

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Hi @CanadaOrNaw — reopening this pull request. The close was a mistake, and it is back in the merge queue. The branch feat/muse-code-subscription was kept.

@diegosouzapw diegosouzapw reopened this Oct 10, 2026
@diegosouzapw diegosouzapw added the deferred-v3.8.53 Feat PRs held for v3.8.53. Keep open. Do not merge into v3.8.52. label Oct 13, 2026
@diegosouzapw diegosouzapw changed the title feat(oauth): add experimental Muse Code subscription provider [defer] feat(oauth): add experimental Muse Code subscription provider Oct 13, 2026
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.52 to release/v3.8.53 October 19, 2026 13:35
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Re-homed to release/v3.8.53: v3.8.52 entered its release freeze, so the branch now belongs to the release captain and development continues on the next cycle. Nothing is wrong with this PR — it just needed a live base. No action needed from you; CI will re-run against the new base.

@diegosouzapw diegosouzapw removed the deferred-v3.8.53 Feat PRs held for v3.8.53. Keep open. Do not merge into v3.8.52. label Oct 20, 2026
@diegosouzapw diegosouzapw changed the title [defer] feat(oauth): add experimental Muse Code subscription provider feat(oauth): add experimental Muse Code subscription provider Oct 20, 2026
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @CanadaOrNaw, this is a careful write-up and the host pinning and no-fallback billing boundary are well thought out. Since you opened this, #14329 landed with a Muse Code device login, key mint and re-mint under the muse-code provider, so a second muse-code-subscription provider would split the same credentials. We would love to take any hardening from here (response-size bounds on the auth calls, verification_uri host allow-list) as a small PR against the existing muse-code files, with you credited. Let us know if you would like to do that, or we can port the ideas and credit you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants