@narumitw/pi-usage 0.61.2 → 0.62.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 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 verified authentication status and a usage-settings link, not numerical quotas or reset times.
7
+ Native `openai` ChatGPT OAuth shows authentication status and a usage-settings link by default; experimental companion quota reporting requires explicit opt-in.
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
@@ -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 the reset countdown through Pi's settings-list interaction in TUI mode.
73
+ Choose **Settings** in `/usage` to edit Codex Fast mode, percentage display, reset countdown, and experimental ChatGPT companion usage 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,34 @@ 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
+ ### Experimental ChatGPT companion usage
89
+
90
+ **Experimental:** this read-only feature uses undocumented ChatGPT backend endpoints. Live numerical agreement has not been independently verified; endpoint changes can make reporting unavailable.
91
+
92
+ Keep `/login openai` for native inference, then run `/login openai-codex` with the **same ChatGPT account and workspace**.
93
+ Enable **Experimental ChatGPT companion usage** in Settings and accept its disclosure.
94
+ The confirmation returns to the same settings row; exit Settings to refresh the report and footer without `/reload`.
95
+ Declining or cancelling confirmation leaves the preference unchanged.
96
+ Alternatively, explicitly set this user-level preference and run `/reload`:
97
+
98
+ ```json
99
+ {
100
+ "openaiCompanionUsage": true
101
+ }
102
+ ```
103
+
104
+ The preference defaults to `false`; there is no project or environment override.
105
+ The extension sends only the independently validated companion bearer and account ID to ChatGPT, never the native token.
106
+ It requires exactly one app registration matching the native grant's client ID, but that match is **not independent proof of shared identity**.
107
+
108
+ Reports and the statusline keep shared **plan limits** and **app limits** separate, including their reset times.
109
+ **App allowance** is a cap on shared plan usage, not remaining quota or a reserved pool.
110
+ Codex percentage/countdown preferences do not change this native report.
111
+ No reset tickets are listed or redeemed, and no allowance is changed.
112
+
113
+ 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.
114
+ Turn the setting Off or remove the companion login to restore web-only reporting without changing native inference.
115
+
88
116
  ### Codex Fast mode
89
117
 
90
118
  Run `/fast` without arguments to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
@@ -131,7 +159,7 @@ Currencies and billing targets remain separate.
131
159
 
132
160
  | Provider | Reported data |
133
161
  | --- | --- |
134
- | OpenAI (native ChatGPT OAuth) | Verified authentication status and usage-settings link; no numerical quota or reset data |
162
+ | OpenAI (native ChatGPT OAuth) | Authentication status by default; opt-in experimental companion-sourced plan/app windows and resets |
135
163
  | OpenAI Codex (legacy) | Subscription windows, credits, resets, and model buckets |
136
164
  | Kimi For Coding | Plan request windows and a separate booster wallet |
137
165
  | Moonshot AI Global/China | Current API balance in USD/CNY |
@@ -174,7 +202,8 @@ MiniMax publishes Token Plan window percentages or the regional pay-as-you-go av
174
202
  Baseten publishes the exact trailing 30-day Model APIs net subtotal after credits.
175
203
  xAI is always menu-only and never starts a scheduled status refresh.
176
204
  Z.AI statusline usage refreshes every five minutes while the selected model remains on Z.AI.
177
- Verified native OpenAI OAuth publishes `chatgpt usage: web only`; its five-minute refresh revalidates authentication locally without calling a usage endpoint.
205
+ Verified native OpenAI OAuth publishes `chatgpt usage: web only` by default; its five-minute refresh revalidates authentication locally without calling a usage endpoint.
206
+ With companion usage enabled, refreshes query both read-only endpoints and publish distinct remaining values, for example `chatgpt plan 70% ↻ 2h30m · app 80% ↻ 3d`.
178
207
  OpenAI API-key auth clears this status.
179
208
 
180
209
  Queries for another provider or all providers never publish their results to the statusline.
@@ -206,7 +235,9 @@ The protocols carry no account name or extension identity.
206
235
  Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
207
236
  Native OpenAI status requires fresh Pi OAuth resolution and a matching complete ChatGPT grant, including the direct-token scope and client ID.
208
237
  Model-level Authorization overrides cannot inherit subscription status from a stored login.
209
- The native status adapter sends no usage request and never forwards native tokens to legacy ChatGPT backend endpoints.
238
+ Default native status sends no usage request, and native tokens are never forwarded to ChatGPT backend endpoints.
239
+ The opt-in 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.
240
+ Both credential identities and the enabled setting bind cache identity and request-boundary revalidation.
210
241
  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
242
  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
243
  Moonshot balance requests send only the resolved Bearer credential to the matching official Global or China balance origin and refuse redirects.
@@ -221,7 +252,8 @@ An absent or incompatible peer preserves standalone fallback and fail-closed mis
221
252
  ## 🚧 Limitations
222
253
 
223
254
  - Numerical usage requires a meaningful provider usage source and verifiable Pi runtime auth.
224
- - Native `openai` reports authentication only: numerical usage, reset times, Fast mode, and earned reset redemption are not supported, and OpenAI API-key usage reporting remains unsupported.
255
+ - 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. Live availability and dashboard agreement remain unverified.
256
+ - Native Fast mode and earned reset redemption, and OpenAI API-key usage reporting, remain unsupported.
225
257
  - 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
258
  - 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
259
  - xAI usage supports only a uniquely matched Pi OAuth subscription credential; xAI API keys and Management API credentials are unsupported.