Muse Code subscription sign-in for opencode
opencode plugin that registers the Muse Code subscription login method for the built-in meta
provider: no API key to copy, no third-party CLI to install. On the V2 plugin API it also routes
subscription inference through a local wire adapter that keeps requests compatible with Muse Code's
tool declarations; see ADAPTER_CONTRACT.md. A successful login still does not
guarantee model access: Meta may reject or restrict this use.
Unofficial and experimental. This plugin uses a Muse Code subscription credential from opencode. Meta's terms limit that credential to Muse Code, so this use may not be supported and Meta may suspend or revoke accounts or credentials. Use it at your own risk; the authors cannot recover an account. Read DISCLAIMER.md before installing.
Add the plugin to opencode.json; opencode installs it from npm:
- Run
/connectin opencode. - Pick the
metaprovider and the Muse Code subscription method. - Open the printed Meta device page, enter the code, and approve the login in your browser; it completes by itself.
- Select a
muse-*model from themetaprovider, for examplemeta/muse-spark-1.3. Inference goes through the local adapter on the V2 plugin API.
The plugin mints a stable, account-bound inference key for opencode; the OAuth access token stays in memory and is never written to disk.
- Registers an
authhook for the built-inmetaprovider (no separate provider id to configure) and runs the Meta device-code exchange (RFC 8628) inside/connect, then mints the subscription inference key through the Model API. - Routes through the Responses API; the
meta.txtsystem prompt applies automatically tomuse-*model ids. - Runs a loopback wire adapter for the V2 plugin API that aliases client tool names colliding
with Muse Code's builtins, restores them in responses, and normalizes parameters Meta rejects
(
tool_choice, reasoning effort, output-token floor, encrypted-reasoning include). The adapter's/v1origin becomes the per-request base URL, with the assembled request rewritten onto it where the override is ignored. Allmetaconnections use the adapter regardless of credential type; the OAuth token overridesAuthorizationonly while the V2 sign-in is active. On refusal the adapter retries once with every tool aliased. See ADAPTER_CONTRACT.md. - Stores the credential in the OpenCode auth store (V1) or integration store (V2); the V1 loader falls back to the legacy cache only when the store has no key, and V2 writes no local cache.
- Never re-mints on its own; re-run
/connectonly after a 401, because the mint endpoint is aggressively rate-limited. - Flow parameters are compatible with the published behavior of oh-my-pi (MIT); see NOTICE and AUTH_CONTRACT.md.
- opencode 2.2.4 or newer for inference through the adapter (the V2 plugin module shape; 2.2.0
loads the plugin without invoking its setup). On the V1 plugin API the plugin still
authenticates but keeps receiving Meta's
client_attestation_denied403. - Node.js 22.6 or newer for development (CI runs 22 and 24).
- An active Muse Code subscription on the Meta account used at login.
| Setting | Purpose | Default |
|---|---|---|
plugins entry in opencode.json |
Loads the plugin. | not set |
| Auth store | Credential storage read by the V1 loader. | ~/.local/share/opencode/auth.json |
| Legacy cache | Read-only fallback from earlier versions. | ~/.config/opencode/muse-code-sub.json |
/connect method |
Selects the Muse Code subscription login. | meta provider |
MUSE_CODE_ADAPTER |
off keeps the local proxy but disables reshaping and normalization. |
unset |
opencode holds the inference key in the V1 auth store or the V2 integration store. The
legacy cache, when present, stores only apiKey, accountId, and email; the OAuth access token
is never written to disk. The plugin contacts only auth.meta.com for the device login and
api.meta.ai for key minting and inference. The V2 wire adapter listens on 127.0.0.1 only,
forwards Authorization unchanged, and never reads, stores or logs credentials or bodies.
See SECURITY.md for vulnerability reporting and
ADAPTER_CONTRACT.md for the inference wire rules.
To remove access:
- disconnect the provider or log out in opencode (the store is
~/.local/share/opencode/auth.json); - delete
~/.config/opencode/muse-code-sub.jsonif an older version created it; - run
muse logoutto also clear the Muse Code CLI session; - remove
opencode-muse-authfromopencode.json.
The plugin is not loaded. Check the opencode.json syntax, the plugin name spelling, and the
package installation, then restart opencode.
A 401 may indicate a rotated or revoked key. Re-run /connect once; the plugin never re-mints on
its own.
Meta may return a 403 mentioning client_attestation_denied, or that Muse Code subscriptions cover
the Muse Code client only. With the V2 adapter running this should not happen for colliding tool
names. If it appears anyway, one of these is true:
- the adapter could not bind its loopback port; opencode's log records
the local request adapter could not startand the provider stays on the direct endpoint; MUSE_CODE_ADAPTER=offis set, which keeps the proxy but disables the reshaping;- you are on the V1 plugin API, which has no adapter, or on a plugin or opencode release
that predates the adapter wiring: first-generation adapter releases skipped plain
metaAPI-key credentials, and early opencode V2 hosts load the plugin without invoking its V2 setup. Checkopencode plugin listandopencode --version, then update; - Meta changed the gate, for example to a real per-client signature. Nothing in this plugin can forge one.
This is a client restriction, not an expired key, so signing in again does not remove it. Use Muse Code for the subscription, or a separate pay-as-you-go Meta Model API key for other clients, subject to Meta's terms.
Approve the printed code before the flow expires, then retry. A Meta rejection usually means the account has no active Muse Code subscription.
Harmless: the V1 loader prefers the OpenCode auth store and reads the cache only when the store has no key. Delete the file when migrating to V2 storage.
git clone https://github.com/TheStreamCode/opencode-muse-auth.git
cd opencode-muse-auth
npm install
npm run build
npm testnpm test builds with tsc and runs the TypeScript suite with the Node test runner. CI runs
the same gate on Node.js 22 and 24; Node 22 needs 22.6 or newer for test-runner type stripping.
The suite needs no Meta account.
Usage questions belong in GitHub Discussions; reproducible defects in GitHub Issues via the bug report form. See SUPPORT.md. Problems in opencode or Meta belong to their respective projects.
See CONTRIBUTING.md. Pull requests must pass the required CI checks.
MIT — see LICENSE. The software is provided "as is"; see
DISCLAIMER.md for the risk notice and liability terms.
Maintained by Michael Gasperini (Mikesoft). If this project is useful to you, consider sponsoring its maintenance.