Skip to content

feat(oauth): add Muse Code device login with CLIProxyAPI-parity remint - #14329

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.51from
RaviTharuma:feat/muse-code-oauth-cliproxy-parity
Sep 22, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.51from
RaviTharuma:feat/muse-code-oauth-cliproxy-parity

Conversation

@RaviTharuma

Copy link
Copy Markdown
Contributor

Summary

  • Add native Muse Code (Meta) device-authorization OAuth on the existing muse-code provider card, matching CLIProxyAPI's Meta login: RFC 8628 against auth.meta.com, mint the subscription inference key at POST https://api.meta.ai/muse-code/key, persist the durable dca: token, remint on 401, honor error.resets_at quota cooldowns, and import CLIProxyAPI type: meta auth files.
  • Dual-auth keeps pasted META_API_KEY on the same dashboard card. Curated catalog adds Muse Spark 1.1/1.2/1.3 (+ contributor) alongside the existing Llama models. Responses API wire format is unchanged.

Related Issues

Validation

Choose the change type and focused loop from the
Contribution Golden Path. The full unit suite,
Vitest, the 60% coverage gate, and the production build all run in CI on this PR (#8329):

  • Change type: provider / OAuth
  • Focused tests and category gates from the golden path
  • npm run lint (eslint on new OAuth/mint modules; pre-existing unused-import findings in untouched default.ts / tokenRefresh.ts lines were not expanded)
  • Reconciled with the current active release base (release/v3.8.51 @ 7a921299c); focused checks rerun afterward
  • Production-code changes include a new or updated automated test in this PR
  • SonarQube is temporarily opt-in while the private project has no quota; it is not a PR gate.

Focused commands run locally:

  • tsx scripts/check/check-provider-consistency.ts
  • npm run check:provider-assets
  • node scripts/check/check-file-size.mjs
  • tsx scripts/docs/gen-provider-reference.ts
  • node --import tsx/esm --test tests/unit/muse-code-oauth.test.ts tests/unit/muse-code-provider.test.ts tests/unit/muse-code-models.test.ts tests/unit/oauth-providers-config.test.ts tests/unit/oauth-polltoken-nonjson-body.test.ts tests/unit/cliproxy-auth-import-1934.test.ts tests/unit/oauth-test-config-8408.test.ts tests/unit/providers-constants-split.test.ts tests/unit/publicCreds.test.ts tests/unit/provider-translate-path-golden.test.ts tests/unit/oauth-providers-error-handling.test.ts tests/unit/providers-page-utils.test.ts

Tests Added Or Updated

  • tests/unit/muse-code-oauth.test.ts (new)
  • tests/unit/muse-code-provider.test.ts
  • tests/unit/muse-code-models.test.ts
  • tests/unit/oauth-providers-config.test.ts
  • tests/unit/oauth-polltoken-nonjson-body.test.ts
  • tests/unit/oauth-providers-error-handling.test.ts
  • tests/unit/cliproxy-auth-import-1934.test.ts
  • tests/unit/publicCreds.test.ts
  • tests/unit/providers-page-utils.test.ts
  • tests/unit/providers-constants-split.test.ts
  • tests/snapshots/provider/translate-path.json

Coverage Notes

  • New OAuth provider, mint helper, remint path, error.resets_at parsing, and CLIProxy type: meta import are covered by the tests listed above.
  • open-sse/executors/default.ts is intentionally unchanged (frozen file-size). Minted keys have no advertised expiry (RefreshLead = nil in CLIProxyAPI); remint is the 401 / supportsTokenRefresh("muse-code") path.

Reviewer Notes

Meta Muse Code uses RFC 8628 against auth.meta.com, then mints a
subscription inference key at api.meta.ai/muse-code/key. Persist the
durable dca token as refreshToken, remint on 401, honor error.resets_at
quota cooldowns, and import CLIProxyAPI type=meta auth files. Dual-auth
keeps pasted META_API_KEY on the same dashboard card.
Regenerate the provider reference on release/v3.8.51 and list
MUSE_CODE_OAUTH_CLIENT_ID next to the other public OAuth client ids.
@RaviTharuma
RaviTharuma force-pushed the feat/muse-code-oauth-cliproxy-parity branch from e758bb1 to f055798 Compare September 22, 2026 11:00
@RaviTharuma

Copy link
Copy Markdown
Contributor Author

@diegosouzapw ping for review.

Rebased onto current release/v3.8.51 (6f1d4beab). The branch is mergeable again (it was 86 commits behind and conflicting). Muse Code device OAuth is unchanged: keep the dca: token, mint the inference key, remint on 401, and keep pasted API keys on the same card.

MUSE_CODE_OAUTH_CLIENT_ID is documented next to the other public OAuth client ids, and the provider reference was regenerated (OAuth 25, API key 242). Local checks that failed on the stale base now pass: provider catalog split, Muse unit tests, and the env/docs contract.

CI on the new head is queued. Happy to fix anything that comes back.

@diegosouzapw

Copy link
Copy Markdown
Owner

Cluster review is done, so here is the outcome and what happens to your work.

This is the most complete of the four Muse implementations and it is clean on the rule that usually trips these up: the public client id goes through EMBEDDED_DEFAULTS as an XOR byte array with zero literal occurrences in the diff, and .env.example says not to put it there. The dca:-token persistence and the MintAPIKey-equivalent naming also track internal/auth/meta/meta.go in the CLIProxyAPI reference very closely.

We are landing #13634 as the base for this feature. It was opened a week earlier and has since been verified end to end against real Meta endpoints — device grant → poll → key mint → models → first inference → re-mint, all 200s, with the maintainer's own browser approval in the loop — and our precedent is that a later, larger PR does not automatically beat an earlier one that was verified live.

Rather than let this go unused, three pieces of yours are unique in the cluster and we want to port them into that branch with a Co-authored-by trailer for you:

  1. src/lib/oauth/utils/cliProxyAuthImport.ts — the meta: "muse-code" mapping, which extends the existing generic CLIProxyAPI auth-file import (already used for codex/antigravity/kimi) so a user can import their muse login credential file directly. That is almost verbatim what [Feature] Muse Spark CLI Support (monthly subscription plan quota via Muse Code) #13415 asks for, and it reuses proven infrastructure.
  2. open-sse/services/retryAfterJson.ts — the error.resets_at quota-cooldown handling.
  3. src/lib/quota/planRegistry.ts + src/lib/usage/flatRateProviders.ts — registering muse-code as a flat-rate subscription provider. Yours is the only one of the four that does this, and it is the acceptance criterion in [Feature] Muse Spark CLI Support (monthly subscription plan quota via Muse Code) #13415 about usage being charged against the subscription's CLI quota rather than API credits — so [Feature] Muse Spark CLI Support (monthly subscription plan quota via Muse Code) #13415 cannot be closed without it.

Flagging before we do it so it is not a surprise; tell us if you would rather we take a different subset, or none of it. If #13634's remaining items (a dropped changelog fragment and a stuck fork-CI approval) turn out to be hard to resolve, this branch is the strongest standalone fallback and we would switch to it instead. One note either way: the reds you see are inherited from base-red #14496, not from your changes.

@RaviTharuma

Copy link
Copy Markdown
Contributor Author

Please port those three pieces into #13634. No different subset.

  1. CLIProxyAPI meta → muse-code auth-file import
  2. error.resets_at quota cooldown
  3. flat-rate plan registry (planRegistry.ts + flatRateProviders.ts)

Credit on the port commit:

Co-authored-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>

#14329 stays open as the fallback until #13634 lands. Understood on the reds coming from base-red #14496.

@RaviTharuma

Copy link
Copy Markdown
Contributor Author

Ported onto the #13634 branch instead of waiting: KSonny4#5

@diegosouzapw
diegosouzapw merged commit d54d313 into diegosouzapw:release/v3.8.51 Sep 22, 2026
9 of 16 checks passed
@RaviTharuma
RaviTharuma deleted the feat/muse-code-oauth-cliproxy-parity branch September 23, 2026 19:36
diegosouzapw added a commit that referenced this pull request Sep 24, 2026
…s lossy policy; drain 12 base-red files

#14529 moved lossy engines off the header-less path in the runtime but not in
deriveEffectivePreviewPlan(), so the dashboard preview showed rtk -> caveman
while requests ran session-dedup -> lite (#12063 again). The preview now
applies downgradeUnrequestedLossy(); the #12063 test pins preview == runtime
for the profile, engines-map and safe-profile cases (fails on the old code).

Test guards realigned to merged design changes, each traced to its commit:
- #14529: compression suites opt in with allow-lossy where they test the
  operator plan, and assert the header-less downgrade; default seed is
  session-dedup + lite; the #10503 probe ignores the loopback dashboard
  telemetry POST that stacked compression emits (the context gate still
  rejects locally — verified with logging).
- #14530: breaker profile asserted on the connection breaker; the
  provider-wide cooldown case drives the network-error path.
- #14370: @opencode/plugin (stable OpenCode 2.x contract, npm maintainer
  thdxr) added to the dependency allowlist.
- #14213: the opt-in empty-turn retry credential site is inventoried as
  class A (dispatch goes through assertManagedLeaseFence).
- #14223 / #14329: flag count 77, quota registry 13 (muse-code).

Refs #14496
thinh0704hcm pushed a commit to thinh0704hcm/OmniRoute that referenced this pull request Oct 5, 2026
…iegosouzapw#14138, diegosouzapw#13634, diegosouzapw#14267, diegosouzapw#12687)

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

- diegosouzapw#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.
- diegosouzapw#12687: opencode-go sends reasoning.effort=max verbatim for
  muse-spark-1.3+, one xhigh retry on the unsupported-effort 400.
- diegosouzapw#13634: MuseCodeExecutor restores the 24h prompt_cache_retention
  window stripped by the generic sanitizer.
- diegosouzapw#14267: device-flow hardening (origin pin, expiry cap, poll-error
  allowlist, bounded auth requests).
- diegosouzapw#14138: mint-failure contract (401/403 forces re-login,
  429/transient keeps the stored key).

Skipped as subsumed or rejected: duplicate OAuth flows (merged
diegosouzapw#14329 covers them), diegosouzapw#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>
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.

feat(providers): Muse Code device OAuth with CLIProxyAPI-parity credential lifecycle

2 participants