@narumitw/pi-usage 0.62.0 → 0.63.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
@@ -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 authentication status and a usage-settings link by default; experimental companion quota reporting requires explicit opt-in.
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` to verify ChatGPT authentication and find [ChatGPT usage settings](https://chatgpt.com/settings/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, reset countdown, and experimental ChatGPT companion usage through Pi's settings-list interaction in TUI mode.
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,33 +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
- ### Experimental ChatGPT companion usage
88
+ ### ChatGPT companion usage
89
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.
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.
91
92
 
92
93
  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`:
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.
97
98
 
98
- ```json
99
- {
100
- "openaiCompanionUsage": true
101
- }
102
- ```
103
-
104
- The preference defaults to `false`; there is no project or environment override.
105
99
  The extension sends only the independently validated companion bearer and account ID to ChatGPT, never the native token.
106
100
  It requires exactly one app registration matching the native grant's client ID, but that match is **not independent proof of shared identity**.
107
101
 
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.
102
+ The statusline shows only shared **plan limits**, with percentages and reset times/window labels.
103
+ Detailed reports also show **app limits** with reset times/window labels only.
104
+ App used/remaining percentages are hidden, but their backend data remains validated.
105
+ **App allowance** is a separately labeled cap on shared plan usage, not remaining quota or a reserved pool.
110
106
  Codex percentage/countdown preferences do not change this native report.
111
107
  No reset tickets are listed or redeemed, and no allowance is changed.
112
108
 
113
109
  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.
110
+ Removing the companion login restores web-only reporting without changing native inference.
115
111
 
116
112
  ### Codex Fast mode
117
113
 
@@ -159,7 +155,7 @@ Currencies and billing targets remain separate.
159
155
 
160
156
  | Provider | Reported data |
161
157
  | --- | --- |
162
- | OpenAI (native ChatGPT OAuth) | Authentication status by default; opt-in experimental companion-sourced plan/app windows and resets |
158
+ | OpenAI (native ChatGPT OAuth) | Automatic companion-sourced plan percentages and plan/app resets; authentication status when companion login is absent |
163
159
  | OpenAI Codex (legacy) | Subscription windows, credits, resets, and model buckets |
164
160
  | Kimi For Coding | Plan request windows and a separate booster wallet |
165
161
  | Moonshot AI Global/China | Current API balance in USD/CNY |
@@ -202,8 +198,8 @@ MiniMax publishes Token Plan window percentages or the regional pay-as-you-go av
202
198
  Baseten publishes the exact trailing 30-day Model APIs net subtotal after credits.
203
199
  xAI is always menu-only and never starts a scheduled status refresh.
204
200
  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`.
201
+ Verified native OpenAI OAuth with valid companion auth refreshes both read-only endpoints automatically, for example `chatgpt plan 70% ↻ 2h30m`.
202
+ Without companion auth it publishes `chatgpt usage: web only`; refreshes revalidate auth without calling a usage endpoint.
207
203
  OpenAI API-key auth clears this status.
208
204
 
209
205
  Queries for another provider or all providers never publish their results to the statusline.
@@ -235,9 +231,9 @@ The protocols carry no account name or extension identity.
235
231
  Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
236
232
  Native OpenAI status requires fresh Pi OAuth resolution and a matching complete ChatGPT grant, including the direct-token scope and client ID.
237
233
  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.
234
+ Native tokens are never forwarded to ChatGPT backend endpoints.
235
+ 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.
236
+ Both credential identities and native registration metadata bind cache identity and request-boundary revalidation.
241
237
  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.
242
238
  Fireworks spend requests send only that resolved credential to the official `https://api.fireworks.ai` account-listing and billing-summary endpoints and refuse redirects.
243
239
  Moonshot balance requests send only the resolved Bearer credential to the matching official Global or China balance origin and refuse redirects.
@@ -252,7 +248,7 @@ An absent or incompatible peer preserves standalone fallback and fail-closed mis
252
248
  ## 🚧 Limitations
253
249
 
254
250
  - 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.
251
+ - 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.
256
252
  - Native Fast mode and earned reset redemption, and OpenAI API-key usage reporting, remain unsupported.
257
253
  - GitHub Copilot quota, Kimi managed usage, Z.AI quota, and OpenAI Codex reset redemption rely on provider-owned endpoints that may change without notice.
258
254
  - 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.
@@ -1356,7 +1356,7 @@ var OPENAI_CHATGPT_ADAPTER = {
1356
1356
  invalidateCacheOnFailure: true,
1357
1357
  async query(auth, signal, timeoutMs, guard) {
1358
1358
  if (auth.openaiCompanion) {
1359
- const { queryOpenAICompanionUsage } = await import("./openai-companion-usage-Y3WTMUB2.ts");
1359
+ const { queryOpenAICompanionUsage } = await import("./openai-companion-usage-4NOBHGP7.ts");
1360
1360
  signal.throwIfAborted();
1361
1361
  return queryOpenAICompanionUsage(auth, signal, timeoutMs, guard);
1362
1362
  }
@@ -1373,11 +1373,9 @@ var OPENAI_CHATGPT_ADAPTER = {
1373
1373
  buckets: [],
1374
1374
  metrics: [{ id: "plan-auth", label: "ChatGPT plan authentication", value: "Connected (native OAuth)" }],
1375
1375
  notes: [
1376
- "Numerical usage and reset times are unavailable in pi-usage for native OpenAI OAuth.",
1376
+ "Numerical usage requires a companion /login openai-codex with the same ChatGPT account/workspace; native inference stays on openai.",
1377
1377
  `Manage usage: ${CHATGPT_USAGE_SETTINGS_URL}`,
1378
- ...auth.openaiCompanionEnabled ? [
1379
- "Experimental companion usage requires /login openai-codex with the same ChatGPT account/workspace; native inference stays on openai."
1380
- ] : [],
1378
+ "Companion usage uses undocumented ChatGPT endpoints; registration matching is not independent identity proof.",
1381
1379
  "Fast mode and earned reset redemption remain legacy openai-codex features."
1382
1380
  ]
1383
1381
  };
@@ -2361,7 +2359,7 @@ function adapterForProvider(providerId) {
2361
2359
  function isStaleExtensionContextError(error) {
2362
2360
  return error instanceof Error && error.message.includes("This extension ctx is stale after session replacement or reload");
2363
2361
  }
2364
- async function resolveUsageAuth(ctx, adapter, salt = AUTH_FINGERPRINT_SALT, credentialReader = readStoredCredential2, candidateReader, openaiCompanionUsage = false) {
2362
+ async function resolveUsageAuth(ctx, adapter, salt = AUTH_FINGERPRINT_SALT, credentialReader = readStoredCredential2, candidateReader, _openaiCompanionUsage) {
2365
2363
  if (ctx.model?.provider === adapter.id && !hasOfficialOrigin(ctx.model, adapter.id)) {
2366
2364
  throw new Error(
2367
2365
  `${adapter.displayName} usage cannot send a custom provider base URL credential to the official usage endpoint.`
@@ -2448,8 +2446,7 @@ async function resolveUsageAuth(ctx, adapter, salt = AUTH_FINGERPRINT_SALT, cred
2448
2446
  const native = finalize(
2449
2447
  resolveOpenAIChatGPTAuth(auth, providerResult.auth, providerResult.source, model, offered.candidates)
2450
2448
  );
2451
- if (!openaiCompanionUsage) return native;
2452
- const { resolveOpenAICompanionAuth } = await import("./openai-companion-auth-Q456G46T.ts");
2449
+ const { resolveOpenAICompanionAuth } = await import("./openai-companion-auth-6VLPFVHF.ts");
2453
2450
  return resolveOpenAICompanionAuth(ctx, native, salt, credentialReader, candidateReader);
2454
2451
  }
2455
2452
  if (adapter.id === "github-copilot") {
@@ -3002,4 +2999,4 @@ export {
3002
2999
  providerIsConfigured,
3003
3000
  fetchProviderJson
3004
3001
  };
3005
- //# sourceMappingURL=chunk-WEXCFYZX.ts.map
3002
+ //# sourceMappingURL=chunk-ENCC7IBP.ts.map