opencode-muse-auth 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +11 -6
  2. package/dist/index.js +11 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -55,8 +55,11 @@ token from the login flow is kept in memory only and is never written to disk.
55
55
  with Muse Code's builtins on the way to `api.meta.ai`, restores them in the response, and
56
56
  normalizes parameters Meta rejects (`tool_choice`, reasoning effort, output-token floor,
57
57
  encrypted-reasoning include). The adapter's `/v1` origin becomes the per-request base URL; on
58
- routes that ignore that override the plugin rewrites the assembled request onto the same origin. If Meta still refuses the request, the
59
- adapter retries once with every tool aliased. See [ADAPTER_CONTRACT.md](ADAPTER_CONTRACT.md).
58
+ routes that ignore that override the plugin rewrites the assembled request onto the same origin.
59
+ Routing does not depend on the credential type: an existing `meta` API key and the V2 Muse OAuth
60
+ connection both go through the adapter; the OAuth access token only overrides `Authorization`
61
+ when the V2 sign-in is active. If Meta still refuses the request, the adapter retries once with
62
+ every tool aliased. See [ADAPTER_CONTRACT.md](ADAPTER_CONTRACT.md).
60
63
  - V1 storage: the OpenCode auth store is the primary source, and the loader falls back to the
61
64
  legacy cache only when the store has no key.
62
65
  - V2 storage: the credential lives in the OpenCode integration store, and no local cache is
@@ -68,10 +71,9 @@ token from the login flow is kept in memory only and is never written to disk.
68
71
 
69
72
  ## Requirements
70
73
 
71
- - opencode with plugin support, including the v2 plugin module shape accepted by opencode 1.18.29+
72
- and 2.x.
73
- - The loopback adapter requires the V2 plugin API (opencode 2.x). V1 installs keep authenticating
74
- but still receive Meta's `client_attestation_denied` 403.
74
+ - opencode 2.2.4 or newer for inference through the adapter (the V2 plugin module shape; 2.2.0
75
+ loads the plugin but does not invoke its setup). On the V1 plugin API the plugin keeps
76
+ authenticating but still receives Meta's `client_attestation_denied` 403.
75
77
  - Node.js 22.6 or newer for development; CI runs Node.js 22 and 24.
76
78
  - An active Muse Code subscription on the Meta account used at login.
77
79
 
@@ -125,6 +127,9 @@ collide with Muse Code's builtins. If it appears anyway, one of these is true:
125
127
  `the local request adapter could not start`, and the provider stays on the direct endpoint;
126
128
  - `MUSE_CODE_ADAPTER=off` is set, which keeps the proxy but disables the reshaping;
127
129
  - you are on the V1 plugin API, which has no adapter;
130
+ - the plugin is older than 0.5.1 or opencode is older than 2.2.4: 0.5.0 skipped the adapter when
131
+ the active `meta` credential was a plain API key, and opencode 2.2.0 loads the plugin without
132
+ invoking its V2 setup. Check `opencode plugin list` and `opencode --version`, then update;
128
133
  - Meta changed the gate, for example to a real per-client signature. Nothing in this plugin can
129
134
  forge one.
130
135
 
package/dist/index.js CHANGED
@@ -131,23 +131,23 @@ export async function setupV2(ctx, options = {}) {
131
131
  return credential;
132
132
  }
133
133
  if (adapter) {
134
- // Primary mechanism: the provider uses the adapter's /v1 origin as its
135
- // request base URL. Native provider drivers honor this override.
134
+ // Every Meta inference request must reach the adapter: it reshapes the tool
135
+ // declarations the gate inspects, so the credential type does not matter
136
+ // (V1 API key or V2 OAuth). Native provider drivers honor this override.
136
137
  const baseUrl = adapter.baseUrl;
137
138
  await ctx.session.hook("model.request", async (event) => {
138
- if (await subscription())
139
- event.baseURL = baseUrl;
139
+ event.baseURL = baseUrl;
140
140
  }, { providerID: "meta" });
141
141
  }
142
- // Meta's native provider expects a bearer inference key, not the
143
- // short-lived OAuth token used to mint it. Honor the active connection.
144
- // AI SDK routes drop model.request.baseURL (opencode#55984), so this hook
145
- // also rewrites the assembled request onto the adapter origin.
142
+ // Meta's native provider expects a bearer inference key, not the short-lived
143
+ // OAuth token used to mint it: when the active Muse connection resolves one,
144
+ // put it on the request. AI SDK routes drop model.request.baseURL
145
+ // (opencode#55984), so this hook also rewrites the assembled request onto the
146
+ // adapter origin.
146
147
  await ctx.session.hook("http.request", async (event) => {
147
148
  const credential = await subscription();
148
- if (!credential)
149
- return;
150
- event.request.headers.set("Authorization", `Bearer ${credential.access}`);
149
+ if (credential)
150
+ event.request.headers.set("Authorization", `Bearer ${credential.access}`);
151
151
  if (adapter)
152
152
  event.request = routeThroughAdapter(event.request, adapter.baseUrl);
153
153
  }, { providerID: "meta" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-muse-auth",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Unofficial and experimental: Muse Spark in opencode using a Muse Code subscription credential, with a local loopback adapter for Meta's subscription wire format. May conflict with Meta's terms; use at your own risk. See DISCLAIMER.md.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",