@narumitw/pi-usage 0.61.1 โ†’ 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,11 +4,13 @@
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 authentication status and a usage-settings link by default; experimental companion quota reporting requires explicit opt-in.
7
8
  xAI OAuth subscription reporting follows the reviewed Grok Build contract and runs only after an explicit `/usage` action.
8
9
 
9
10
  ## โœจ Features
10
11
 
11
12
  - Shows active-account usage and next actions through `/usage`.
13
+ - Recognizes native `/login openai` ChatGPT OAuth separately from unsupported OpenAI API-key usage reporting.
12
14
  - Reports subscription allowances, API balances, and spending for the supported providers listed below without mixing their billing semantics.
13
15
  - Toggles persistent Codex Fast routing through `/fast` or the usage menu.
14
16
  - Redeems eligible Codex resets only after fresh account matching and explicit confirmation.
@@ -48,6 +50,8 @@ The package declares `dist/index.ts`, so an unbuilt local checkout must run the
48
50
  Run `/usage` in TUI or RPC mode to inspect the active provider, refresh its usage, or choose another configured provider.
49
51
  When a provider exposes several billing targets, `/usage` asks for one target before querying usage.
50
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` to verify ChatGPT authentication and find [ChatGPT usage settings](https://chatgpt.com/settings/usage).
54
+ Native OpenAI Fast mode and earned reset redemption are not implemented; those actions remain specific to legacy `openai-codex`.
51
55
 
52
56
  ## ๐Ÿ’ฌ Commands
53
57
 
@@ -66,7 +70,7 @@ Read the [query and reset guide](./docs/operations.md) for target selection, can
66
70
 
67
71
  ## โš™๏ธ Settings
68
72
 
69
- 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.
70
74
  RPC mode reports the active manual settings path instead of opening terminal UI.
71
75
 
72
76
  These preferences live in `pi-usage.json` under Pi's user agent directory, normally `~/.pi/agent/pi-usage.json`.
@@ -81,6 +85,34 @@ Target selections are stored only as IDs in the provider-neutral `selectedTarget
81
85
  The former `fireworksAccountId` field remains read-compatible: it supplies `selectedTargets.fireworks` in memory only when the generic value is absent.
82
86
  A successful explicit Fireworks account selection writes the generic field and removes the legacy field atomically; ordinary reads do not rewrite the file.
83
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
+
84
116
  ### Codex Fast mode
85
117
 
86
118
  Run `/fast` without arguments to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
@@ -127,7 +159,8 @@ Currencies and billing targets remain separate.
127
159
 
128
160
  | Provider | Reported data |
129
161
  | --- | --- |
130
- | OpenAI Codex | Subscription windows, credits, resets, and model buckets |
162
+ | OpenAI (native ChatGPT OAuth) | Authentication status by default; opt-in experimental companion-sourced plan/app windows and resets |
163
+ | OpenAI Codex (legacy) | Subscription windows, credits, resets, and model buckets |
131
164
  | Kimi For Coding | Plan request windows and a separate booster wallet |
132
165
  | Moonshot AI Global/China | Current API balance in USD/CNY |
133
166
  | MiniMax Global/China | Token Plan windows or pay-as-you-go API balance |
@@ -169,6 +202,9 @@ MiniMax publishes Token Plan window percentages or the regional pay-as-you-go av
169
202
  Baseten publishes the exact trailing 30-day Model APIs net subtotal after credits.
170
203
  xAI is always menu-only and never starts a scheduled status refresh.
171
204
  Z.AI statusline usage refreshes every five minutes while the selected model remains on Z.AI.
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`.
207
+ OpenAI API-key auth clears this status.
172
208
 
173
209
  Queries for another provider or all providers never publish their results to the statusline.
174
210
  `@narumitw/pi-statusline` supplies the default `๐Ÿ“Š` icon; `pi-usage` publishes text-only values.
@@ -197,6 +233,11 @@ Behavior changes:
197
233
  Credential candidates are collected synchronously in memory after any compatible readiness promises settle, and are not cached, persisted, logged, formatted, or appended to the Pi session.
198
234
  The protocols carry no account name or extension identity.
199
235
  Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
236
+ Native OpenAI status requires fresh Pi OAuth resolution and a matching complete ChatGPT grant, including the direct-token scope and client ID.
237
+ Model-level Authorization overrides cannot inherit subscription status from a stored login.
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.
200
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.
201
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.
202
243
  Moonshot balance requests send only the resolved Bearer credential to the matching official Global or China balance origin and refuse redirects.
@@ -210,7 +251,9 @@ An absent or incompatible peer preserves standalone fallback and fail-closed mis
210
251
 
211
252
  ## ๐Ÿšง Limitations
212
253
 
213
- - Only providers with a meaningful usage source and verifiable Pi runtime auth are supported.
254
+ - Numerical usage requires a meaningful provider usage source and verifiable Pi runtime auth.
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.
214
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.
215
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.
216
259
  - xAI usage supports only a uniquely matched Pi OAuth subscription credential; xAI API keys and Management API credentials are unsupported.