@narumitw/pi-usage 0.61.2 → 0.63.0
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 +34 -7
- package/dist/chunks/chunk-ENCC7IBP.ts +3002 -0
- package/dist/chunks/chunk-ENCC7IBP.ts.map +7 -0
- package/dist/chunks/openai-companion-auth-6VLPFVHF.ts +83 -0
- package/dist/chunks/openai-companion-auth-6VLPFVHF.ts.map +7 -0
- package/dist/chunks/openai-companion-usage-4NOBHGP7.ts +120 -0
- package/dist/chunks/openai-companion-usage-4NOBHGP7.ts.map +7 -0
- package/dist/index.ts +382 -3202
- package/dist/index.ts.map +4 -4
- package/docs/providers.md +32 -8
- package/package.json +4 -4
- package/src/format.ts +35 -1
- package/src/openai-companion-auth.ts +101 -0
- package/src/providers/openai-chatgpt.ts +21 -10
- package/src/providers/openai-companion-usage.ts +146 -0
- package/src/query.ts +5 -1
- package/src/types.ts +3 -0
- package/src/usage-settings-ui.ts +116 -114
- package/src/usage.ts +62 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Inspect usage and DeepSeek API balance for Pi's active provider account, query other configured providers, and toggle Fast mode for supported OpenAI Codex models.
|
|
6
6
|
The extension keeps each provider's native quota, allowance, and spending semantics instead of treating unlike values as equivalent.
|
|
7
|
-
Native `openai` ChatGPT OAuth shows
|
|
7
|
+
Native `openai` ChatGPT OAuth automatically reports plan usage through a valid same-account Codex companion login; without that login it shows authentication status and a usage-settings link.
|
|
8
8
|
xAI OAuth subscription reporting follows the reviewed Grok Build contract and runs only after an explicit `/usage` action.
|
|
9
9
|
|
|
10
10
|
## ✨ Features
|
|
@@ -50,7 +50,7 @@ The package declares `dist/index.ts`, so an unbuilt local checkout must run the
|
|
|
50
50
|
Run `/usage` in TUI or RPC mode to inspect the active provider, refresh its usage, or choose another configured provider.
|
|
51
51
|
When a provider exposes several billing targets, `/usage` asks for one target before querying usage.
|
|
52
52
|
Run `/fast` to toggle Fast mode for a supported active Codex model.
|
|
53
|
-
For native `/login openai`, select an `openai` model and run `/usage
|
|
53
|
+
For native `/login openai`, select an `openai` model and run `/usage`. A same-account/workspace `/login openai-codex` supplies [companion usage](#chatgpt-companion-usage) automatically without changing native inference.
|
|
54
54
|
Native OpenAI Fast mode and earned reset redemption are not implemented; those actions remain specific to legacy `openai-codex`.
|
|
55
55
|
|
|
56
56
|
## 💬 Commands
|
|
@@ -70,7 +70,7 @@ Read the [query and reset guide](./docs/operations.md) for target selection, can
|
|
|
70
70
|
|
|
71
71
|
## ⚙️ Settings
|
|
72
72
|
|
|
73
|
-
Choose **Settings** in `/usage` to edit Codex Fast mode, percentage display, and
|
|
73
|
+
Choose **Settings** in `/usage` to edit Codex Fast mode, percentage display, and reset countdown through Pi's settings-list interaction in TUI mode.
|
|
74
74
|
RPC mode reports the active manual settings path instead of opening terminal UI.
|
|
75
75
|
|
|
76
76
|
These preferences live in `pi-usage.json` under Pi's user agent directory, normally `~/.pi/agent/pi-usage.json`.
|
|
@@ -85,6 +85,29 @@ Target selections are stored only as IDs in the provider-neutral `selectedTarget
|
|
|
85
85
|
The former `fireworksAccountId` field remains read-compatible: it supplies `selectedTargets.fireworks` in memory only when the generic value is absent.
|
|
86
86
|
A successful explicit Fireworks account selection writes the generic field and removes the legacy field atomically; ordinary reads do not rewrite the file.
|
|
87
87
|
|
|
88
|
+
### ChatGPT companion usage
|
|
89
|
+
|
|
90
|
+
**Experimental source:** this read-only feature uses undocumented ChatGPT backend endpoints that may change without notice.
|
|
91
|
+
A user observed the plan weekly remaining percentage and reset time matching the ChatGPT overview; app percentages and broader account/window agreement remain unverified.
|
|
92
|
+
|
|
93
|
+
Keep `/login openai` for native inference, then run `/login openai-codex` with the **same ChatGPT account and workspace**.
|
|
94
|
+
After native OAuth validation, companion usage is automatic on queries and scheduled refreshes; there is no enablement setting or confirmation.
|
|
95
|
+
This intentionally replaces the former default-off experimental opt-in.
|
|
96
|
+
Existing `openaiCompanionUsage` values, including `false`, are ignored and preserved as unrelated JSON during other settings saves; reads do not rewrite the file.
|
|
97
|
+
Remove the companion login if you do not want this automatic companion query path.
|
|
98
|
+
|
|
99
|
+
The extension sends only the independently validated companion bearer and account ID to ChatGPT, never the native token.
|
|
100
|
+
It requires exactly one app registration matching the native grant's client ID, but that match is **not independent proof of shared identity**.
|
|
101
|
+
|
|
102
|
+
Reports and the statusline show shared **plan limits** with percentages, and **app limits** with reset times/window labels only.
|
|
103
|
+
App used/remaining percentages are hidden, but their backend data remains validated.
|
|
104
|
+
**App allowance** is a separately labeled cap on shared plan usage, not remaining quota or a reserved pool.
|
|
105
|
+
Codex percentage/countdown preferences do not change this native report.
|
|
106
|
+
No reset tickets are listed or redeemed, and no allowance is changed.
|
|
107
|
+
|
|
108
|
+
Missing companion login preserves web-only setup guidance; invalid credentials, missing/duplicate registrations, unsupported pagination, malformed responses, and endpoint failures report unavailable data instead of guessed or stale quota.
|
|
109
|
+
Removing the companion login restores web-only reporting without changing native inference.
|
|
110
|
+
|
|
88
111
|
### Codex Fast mode
|
|
89
112
|
|
|
90
113
|
Run `/fast` without arguments to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
|
|
@@ -131,7 +154,7 @@ Currencies and billing targets remain separate.
|
|
|
131
154
|
|
|
132
155
|
| Provider | Reported data |
|
|
133
156
|
| --- | --- |
|
|
134
|
-
| OpenAI (native ChatGPT OAuth) |
|
|
157
|
+
| OpenAI (native ChatGPT OAuth) | Automatic companion-sourced plan percentages and plan/app resets; authentication status when companion login is absent |
|
|
135
158
|
| OpenAI Codex (legacy) | Subscription windows, credits, resets, and model buckets |
|
|
136
159
|
| Kimi For Coding | Plan request windows and a separate booster wallet |
|
|
137
160
|
| Moonshot AI Global/China | Current API balance in USD/CNY |
|
|
@@ -174,7 +197,8 @@ MiniMax publishes Token Plan window percentages or the regional pay-as-you-go av
|
|
|
174
197
|
Baseten publishes the exact trailing 30-day Model APIs net subtotal after credits.
|
|
175
198
|
xAI is always menu-only and never starts a scheduled status refresh.
|
|
176
199
|
Z.AI statusline usage refreshes every five minutes while the selected model remains on Z.AI.
|
|
177
|
-
Verified native OpenAI OAuth
|
|
200
|
+
Verified native OpenAI OAuth with valid companion auth refreshes both read-only endpoints automatically, for example `chatgpt plan 70% ↻ 2h30m · app ↻ 3d`.
|
|
201
|
+
Without companion auth it publishes `chatgpt usage: web only`; refreshes revalidate auth without calling a usage endpoint.
|
|
178
202
|
OpenAI API-key auth clears this status.
|
|
179
203
|
|
|
180
204
|
Queries for another provider or all providers never publish their results to the statusline.
|
|
@@ -206,7 +230,9 @@ The protocols carry no account name or extension identity.
|
|
|
206
230
|
Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
|
|
207
231
|
Native OpenAI status requires fresh Pi OAuth resolution and a matching complete ChatGPT grant, including the direct-token scope and client ID.
|
|
208
232
|
Model-level Authorization overrides cannot inherit subscription status from a stored login.
|
|
209
|
-
|
|
233
|
+
Native tokens are never forwarded to ChatGPT backend endpoints.
|
|
234
|
+
The automatic companion path sends only its validated Codex bearer and matching account ID to fixed `GET /backend-api/wham/usage/chatpass/apps` and `GET /backend-api/wham/usage` routes on `https://chatgpt.com`, rejects redirects, and bounds response sizes and request time.
|
|
235
|
+
Both credential identities and native registration metadata bind cache identity and request-boundary revalidation.
|
|
210
236
|
DeepSeek balance requests require Bearer authentication, send only that resolved credential from Pi's runtime auth to `https://api.deepseek.com/user/balance`, and refuse redirects.
|
|
211
237
|
Fireworks spend requests send only that resolved credential to the official `https://api.fireworks.ai` account-listing and billing-summary endpoints and refuse redirects.
|
|
212
238
|
Moonshot balance requests send only the resolved Bearer credential to the matching official Global or China balance origin and refuse redirects.
|
|
@@ -221,7 +247,8 @@ An absent or incompatible peer preserves standalone fallback and fail-closed mis
|
|
|
221
247
|
## 🚧 Limitations
|
|
222
248
|
|
|
223
249
|
- Numerical usage requires a meaningful provider usage source and verifiable Pi runtime auth.
|
|
224
|
-
- Native `openai`
|
|
250
|
+
- Native `openai` has no verified native-token numerical quota API. Experimental companion reports require same-account setup, cannot independently prove shared identity, and reject incomplete/paginated app lists. Only one user-reported plan weekly comparison has been observed; app agreement and broader live behavior remain unverified.
|
|
251
|
+
- Native Fast mode and earned reset redemption, and OpenAI API-key usage reporting, remain unsupported.
|
|
225
252
|
- GitHub Copilot quota, Kimi managed usage, Z.AI quota, and OpenAI Codex reset redemption rely on provider-owned endpoints that may change without notice.
|
|
226
253
|
- Codex reset redemption requires a current ChatGPT OAuth credential from Pi's login or a compatible credential source; Codex API keys cannot redeem earned subscription resets.
|
|
227
254
|
- xAI usage supports only a uniquely matched Pi OAuth subscription credential; xAI API keys and Management API credentials are unsupported.
|