pi-meta-oauth 0.7.0 → 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 CHANGED
@@ -18,8 +18,10 @@ Meta Model API OAuth for [pi](https://pi.dev).
18
18
  ## Install
19
19
 
20
20
  ```bash
21
- # OAuth-only branch
22
- pi install git:github.com/BlockedPath/pi-meta-oauth@meta-oauth-only
21
+ pi install npm:pi-meta-oauth
22
+
23
+ # Or track main
24
+ pi install git:github.com/BlockedPath/pi-meta-oauth
23
25
 
24
26
  # Or from a local checkout
25
27
  pi install /absolute/path/to/pi-meta-oauth
@@ -94,6 +96,17 @@ count. Pi writes the cache during interactive or RPC startup, and again after
94
96
  not itself trigger a network catalog refresh. The cached catalog is also used
95
97
  when Pi starts without network access.
96
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
+
97
110
  The bundled fallback uses Meta's nominal `1,048,576`-token context window. A
98
111
  cached Muse Code 0.1.0/R708.1 catalog observed on 2026-08-06 reported a lower
99
112
  effective limit of `1,007,997` for `muse-spark-1.2` and
@@ -107,14 +120,58 @@ catalog.
107
120
  ```bash
108
121
  pi --list-models meta
109
122
  pi -p --provider meta --model muse-spark-1.3 "Reply exactly: META_OK"
110
- bun run typecheck
111
- bun test
123
+ bun install --frozen-lockfile
124
+ bun run check
112
125
  ```
113
126
 
114
- `bun test` is hermetic unless a Meta credential is already available. The live cache-hit probe makes real billable API calls when a credential resolves: two identical `/v1/responses` calls (asserting `cached_tokens` on the second), plus one 2s retry if that second call misses cache. The live fingerprint probe makes two tiny Contributor-`max` calls: one without the fingerprint (status logged only) and one with it (asserting HTTP 200). It sends the header directly and does not depend on `META_MUSE_USER_AGENT`. The credential is resolved, in order, from `PI_META_LIVE_API_KEY`, `META_API_KEY`, `MODEL_API_KEY`, or the minted key from `~/.pi/agent/auth.json` after `/login meta` (skipped if expired). OAuth is enough — you do not need a separate key. Skipped when no valid credential exists (CI):
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.
115
142
 
116
143
  ```bash
117
- bun test tests/meta-cache.test.ts
144
+ bun run test:live tests/meta-cache.test.ts
118
145
  # or, if you are not logged in:
119
- 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
120
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`.