pi-meta-oauth 0.6.1 → 0.7.1
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.
- package/README.md +88 -8
- package/extensions/meta.ts +32 -667
- package/package.json +13 -7
- package/src/meta/constants.ts +28 -0
- package/src/meta/environment.ts +17 -0
- package/src/meta/http.ts +83 -0
- package/src/meta/model-store.ts +183 -0
- package/src/meta/models.ts +355 -0
- package/src/meta/muse-policy.ts +32 -0
- package/src/meta/oauth.ts +382 -0
- package/src/meta/provider.ts +49 -0
- package/src/meta/request-policy.ts +96 -0
- package/src/meta/types.ts +33 -0
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Meta Model API OAuth for [pi](https://pi.dev).
|
|
|
10
10
|
|
|
11
11
|
- Use Muse Spark models through Pi's `openai-responses` provider (not `/chat/completions` — Muse prompt cache is ~0% there)
|
|
12
12
|
- Send `prompt_cache_retention: "24h"` on Meta Responses requests unless the payload already set a retention
|
|
13
|
+
- Optional, off by default: send the Muse CLI `User-Agent` on direct `muse-spark-1.3-contributor` requests so it accepts reasoning effort `max` (see [Contributor `max`](#contributor-max-opt-in))
|
|
13
14
|
- Device authorization against `https://auth.meta.com`
|
|
14
15
|
- Model API-key minting through `POST https://api.meta.ai/muse-code/key`
|
|
15
16
|
- Dynamic Muse model catalog from `GET https://api.meta.ai/v1/models`
|
|
@@ -17,8 +18,10 @@ Meta Model API OAuth for [pi](https://pi.dev).
|
|
|
17
18
|
## Install
|
|
18
19
|
|
|
19
20
|
```bash
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
pi install npm:pi-meta-oauth
|
|
22
|
+
|
|
23
|
+
# Or track main
|
|
24
|
+
pi install git:github.com/BlockedPath/pi-meta-oauth
|
|
22
25
|
|
|
23
26
|
# Or from a local checkout
|
|
24
27
|
pi install /absolute/path/to/pi-meta-oauth
|
|
@@ -40,9 +43,12 @@ Pi displays a device code, opens the Meta authorization flow, and mints a Model
|
|
|
40
43
|
|
|
41
44
|
The access key is re-minted daily.
|
|
42
45
|
|
|
46
|
+
Prefer a static key instead? Set `META_API_KEY` (or `MODEL_API_KEY`) and skip
|
|
47
|
+
`/login meta` entirely — requests use it directly.
|
|
48
|
+
|
|
43
49
|
## Models
|
|
44
50
|
|
|
45
|
-
Fallback models use a 1,048,576-token context window, up to 256K output tokens, image input, and reasoning levels `minimal`, `low`, `medium`, `high`, and `xhigh
|
|
51
|
+
Fallback models use a 1,048,576-token context window, up to 256K output tokens, image input, and reasoning levels `minimal`, `low`, `medium`, `high`, and `xhigh` (`muse-spark-1.3` additionally supports `max`; `muse-spark-1.3-contributor` does too when [opted in](#contributor-max-opt-in)).
|
|
46
52
|
|
|
47
53
|
| id | pricing (input/output/cached) $/M |
|
|
48
54
|
| --- | --- |
|
|
@@ -54,6 +60,25 @@ Fallback models use a 1,048,576-token context window, up to 256K output tokens,
|
|
|
54
60
|
|
|
55
61
|
> **Contributor-model privacy:** discounted contributor models allow Meta to use prompts and completions for product improvement, including training future Meta models. Use a standard model such as `muse-spark-1.3` if you do not want the contributor terms. See [Meta's model documentation](https://dev.meta.ai/docs/models).
|
|
56
62
|
|
|
63
|
+
### Contributor `max` (opt-in)
|
|
64
|
+
|
|
65
|
+
Meta documents reasoning effort `max` for standard-tier `muse-spark-1.3` only. `muse-spark-1.3-contributor` rejects it (HTTP 400) unless the request carries the Muse CLI's `User-Agent` (observed 2026-09-25, same for API-key and `/login meta` credentials). To use it anyway, set `META_MUSE_USER_AGENT=1` (`true` and `yes` also work) in the environment Pi starts from:
|
|
66
|
+
|
|
67
|
+
| OS / shell | Enable permanently |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| macOS (zsh, the default) | `echo 'export META_MUSE_USER_AGENT=1' >> ~/.zshrc` |
|
|
70
|
+
| Linux (bash) | `echo 'export META_MUSE_USER_AGENT=1' >> ~/.bashrc` |
|
|
71
|
+
| fish (any OS) | `set -Ux META_MUSE_USER_AGENT 1` |
|
|
72
|
+
| Windows (PowerShell) | `[Environment]::SetEnvironmentVariable("META_MUSE_USER_AGENT", "1", "User")` |
|
|
73
|
+
|
|
74
|
+
Then open a **new** terminal and restart Pi. Shells that were already open don't see the change, and long-running terminal apps or multiplexers (e.g. tmux) may need a full restart. On macOS/Linux you can instead run `source ~/.zshrc` (or `~/.bashrc`) in the current shell. For a single run, use `META_MUSE_USER_AGENT=1 pi`. To disable it, remove the line (fish: `set -Ue META_MUSE_USER_AGENT`; Windows: pass `$null` instead of `"1"`) and restart Pi.
|
|
75
|
+
|
|
76
|
+
The header is the same on every OS. The captured string names `linux-x86_64`, but the platform segment doesn't appear to be checked: it was accepted from Windows (2026-09-26), and oh-my-pi sends the same fixed string on every platform.
|
|
77
|
+
|
|
78
|
+
With the flag set, the extension exposes `max` on `muse-spark-1.3-contributor` and sends the captured Muse `User-Agent` on that model's requests to `https://api.meta.ai/v1` only. Other models, proxies and custom `baseUrl`s, and any `User-Agent` you set yourself are left untouched. Without the flag, Contributor `max` is hidden and Pi's own `User-Agent` is sent.
|
|
79
|
+
|
|
80
|
+
> **Warning:** this makes Pi identify as Meta's first-party Muse client. It relies on undocumented server behavior, is not supported by Meta, may stop working without notice, and may conflict with Meta's terms. Enable it only if you accept that risk for your account.
|
|
81
|
+
|
|
57
82
|
To scope Pi's model picker to Meta models:
|
|
58
83
|
|
|
59
84
|
```json
|
|
@@ -71,6 +96,17 @@ count. Pi writes the cache during interactive or RPC startup, and again after
|
|
|
71
96
|
not itself trigger a network catalog refresh. The cached catalog is also used
|
|
72
97
|
when Pi starts without network access.
|
|
73
98
|
|
|
99
|
+
On Pi 0.86.1 and later, Pi's built-in pi.dev catalog overlay for `meta` shares
|
|
100
|
+
this store entry and refreshes before the extension. The extension persists its
|
|
101
|
+
catalog with `lastModified: 0` and `source: "pi-meta-oauth"`, so the overlay
|
|
102
|
+
skips pi.dev for 4 hours after a successful Meta refresh. On restore, entries
|
|
103
|
+
written by the overlay are ignored in favor of the bundled models, and the base
|
|
104
|
+
URL is always `https://api.meta.ai/v1`. If a Meta refresh fails after the
|
|
105
|
+
overlay wrote its entry, the extension republishes its last good catalog. If
|
|
106
|
+
pi.dev fails while the cached Meta entry is missing, older than 4 hours, or
|
|
107
|
+
written by an earlier release, Pi aborts that refresh before the Meta catalog is
|
|
108
|
+
fetched.
|
|
109
|
+
|
|
74
110
|
The bundled fallback uses Meta's nominal `1,048,576`-token context window. A
|
|
75
111
|
cached Muse Code 0.1.0/R708.1 catalog observed on 2026-08-06 reported a lower
|
|
76
112
|
effective limit of `1,007,997` for `muse-spark-1.2` and
|
|
@@ -84,14 +120,58 @@ catalog.
|
|
|
84
120
|
```bash
|
|
85
121
|
pi --list-models meta
|
|
86
122
|
pi -p --provider meta --model muse-spark-1.3 "Reply exactly: META_OK"
|
|
87
|
-
bun
|
|
88
|
-
bun
|
|
123
|
+
bun install --frozen-lockfile
|
|
124
|
+
bun run check
|
|
89
125
|
```
|
|
90
126
|
|
|
91
|
-
`bun
|
|
127
|
+
`bun run check` runs Biome, TypeScript, and the hermetic test suite. Use
|
|
128
|
+
`bun run test` for tests alone, or pass a file or test filter after the command.
|
|
129
|
+
The launcher clears Meta credentials in the child process, disables dotenv
|
|
130
|
+
loading, and gives it an empty temporary home. Your environment and stored
|
|
131
|
+
credentials are preserved. CI uses the same command and committed lockfile.
|
|
132
|
+
|
|
133
|
+
Live probes require the explicit `bun run test:live` command. Direct `bun test`
|
|
134
|
+
also bypasses isolation and can run these probes when credentials are available.
|
|
135
|
+
The cache probe makes two billable Responses requests plus one retry on a cache
|
|
136
|
+
miss. The fingerprint probe makes two tiny Contributor-`max` requests; it sends
|
|
137
|
+
the header directly, independently of `META_MUSE_USER_AGENT`. The catalog probe
|
|
138
|
+
runs when `PI_META_LIVE_API_KEY` is set. Cache and fingerprint probes resolve
|
|
139
|
+
credentials from `PI_META_LIVE_API_KEY`, `META_API_KEY`, `MODEL_API_KEY`, or an
|
|
140
|
+
unexpired minted key in `~/.pi/agent/auth.json`, in that order. Probes skip when
|
|
141
|
+
no usable credential exists.
|
|
92
142
|
|
|
93
143
|
```bash
|
|
94
|
-
bun test tests/meta-cache.test.ts
|
|
144
|
+
bun run test:live tests/meta-cache.test.ts
|
|
95
145
|
# or, if you are not logged in:
|
|
96
|
-
PI_META_LIVE_API_KEY='LLM|...' bun test tests/meta-cache.test.ts
|
|
146
|
+
PI_META_LIVE_API_KEY='LLM|...' bun run test:live tests/meta-cache.test.ts
|
|
97
147
|
```
|
|
148
|
+
|
|
149
|
+
## Development
|
|
150
|
+
|
|
151
|
+
`extensions/meta.ts` is the only registered Pi extension. It registers the
|
|
152
|
+
provider; implementation modules live in `src/meta/` and ship with
|
|
153
|
+
the package:
|
|
154
|
+
|
|
155
|
+
- `oauth.ts`: device authorization, cancellable polling, key minting, and refresh.
|
|
156
|
+
- `models.ts`: fresh fallback definitions and validation of remote/cached models.
|
|
157
|
+
- `model-store.ts`: catalog refresh and Pi 0.83/0.84+ persistence compatibility.
|
|
158
|
+
- `muse-policy.ts` and `request-policy.ts`: opt-in effort gating and request hints.
|
|
159
|
+
- `provider.ts`, `environment.ts`, `http.ts`, `constants.ts`, and `types.ts`:
|
|
160
|
+
provider assembly and request-local streaming, key aliases, shared transport,
|
|
161
|
+
and common definitions.
|
|
162
|
+
|
|
163
|
+
The provider's stream adapter applies cache hints and the opt-in fingerprint
|
|
164
|
+
using the in-flight request's model and endpoint, not the session's current
|
|
165
|
+
selection. Switching models during request preparation cannot apply Meta
|
|
166
|
+
settings to another provider's request. Explicit headers and cache-retention
|
|
167
|
+
values remain authoritative, including payloads replaced by caller callbacks.
|
|
168
|
+
|
|
169
|
+
Network JSON and persisted catalogs are validated before becoming Pi model
|
|
170
|
+
definitions. Each provider configuration owns its model metadata; mutations
|
|
171
|
+
cannot alter later configurations or cached entries. Login honors Pi's abort
|
|
172
|
+
signal across authorization, polling, and minting. Catalog persistence remains
|
|
173
|
+
best-effort and uses the host's generation check when available.
|
|
174
|
+
|
|
175
|
+
Use `bun run format` to apply formatting and safe lint fixes, and
|
|
176
|
+
`bun run lint` or `bun run typecheck` for individual checks. The extension's
|
|
177
|
+
existing named exports remain available from `extensions/meta.ts`.
|