@narumitw/pi-usage 0.54.0 → 0.57.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 +103 -64
- package/dist/index.ts +329 -110
- package/dist/index.ts.map +4 -4
- package/package.json +9 -10
- package/src/format.ts +94 -7
- package/src/index.ts +2 -0
- package/src/providers/deepseek.ts +85 -0
- package/src/query.ts +58 -10
- package/src/settings.ts +10 -5
- package/src/types.ts +5 -0
- package/src/usage-helpers.ts +2 -2
- package/src/usage-settings-ui.ts +10 -11
- package/src/usage.ts +121 -85
package/README.md
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
# 📊 pi-usage — Check Provider Usage and Codex Fast Mode
|
|
1
|
+
# 📊 pi-usage — Check Provider Usage, API Balance, and Codex Fast Mode
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@narumitw/pi-usage) [](https://pi.dev) [](./LICENSE)
|
|
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
|
|
|
7
|
-
The extension
|
|
8
|
-
xAI
|
|
7
|
+
The extension keeps each provider's native quota, allowance, and spending semantics instead of treating unlike values as equivalent.
|
|
8
|
+
xAI OAuth subscription reporting follows the reviewed Grok Build contract and runs only after an explicit `/usage` action.
|
|
9
9
|
|
|
10
10
|
## ✨ Features
|
|
11
11
|
|
|
12
|
-
- Shows
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
12
|
+
- Shows active-account usage and next actions through `/usage`.
|
|
13
|
+
- Reports OpenAI Codex subscription windows, credits, resets, and model-specific buckets.
|
|
14
|
+
- Reports Kimi For Coding plan windows, resets, and separately labeled booster-wallet currency.
|
|
15
|
+
- Reports GitHub Copilot allowances and OpenRouter per-key limits and spending windows.
|
|
16
|
+
- Reports exact DeepSeek API balances with separate CNY and USD values.
|
|
17
|
+
- Reports OpenCode Go plan windows and Z.AI Coding Plan quotas.
|
|
18
|
+
- Reports xAI OAuth subscription allowances and credits.
|
|
19
|
+
- Toggles persistent Codex Fast routing through `/fast` or the usage menu.
|
|
18
20
|
- Redeems eligible Codex resets only after fresh account matching and explicit confirmation.
|
|
19
|
-
- Refreshes one or all configured providers with bounded concurrency
|
|
20
|
-
-
|
|
21
|
+
- Refreshes one or all configured providers with bounded concurrency while preserving partial results.
|
|
22
|
+
- Scopes statusline and cache data to the active provider and runtime account.
|
|
21
23
|
- Resolves credentials through Pi or the process-local OAuth credential-source protocol and validates the effective provider endpoint before sending them.
|
|
22
24
|
|
|
23
25
|
## 📦 Install
|
|
24
26
|
|
|
25
|
-
Requires Pi 0.81.0 or newer
|
|
26
|
-
The v1 credential-source
|
|
27
|
+
Requires Pi 0.81.0 or newer to validate the effective base URL for resolved provider auth before sending credentials to an official usage endpoint.
|
|
28
|
+
The v1 credential-source path is characterized against Pi 0.84.3; other runtimes keep the standalone fallback without its protocol timing guarantee.
|
|
29
|
+
|
|
30
|
+
Like every Pi extension, this package runs with Pi's process permissions.
|
|
31
|
+
Review [Security and privacy](#-security-and-privacy) before installation.
|
|
27
32
|
|
|
28
33
|
```bash
|
|
29
34
|
pi install npm:@narumitw/pi-usage
|
|
@@ -46,18 +51,18 @@ The package declares `dist/index.ts`, so an unbuilt local checkout must run the
|
|
|
46
51
|
|
|
47
52
|
## 🚀 Quick start
|
|
48
53
|
|
|
49
|
-
Run `/usage` in TUI or RPC mode to inspect the
|
|
50
|
-
|
|
54
|
+
Run `/usage` in TUI or RPC mode to inspect the active provider, refresh its usage, or choose another configured provider.
|
|
55
|
+
Run `/fast` to toggle Fast mode for a supported active Codex model.
|
|
51
56
|
|
|
52
57
|
## 💬 Commands
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
Open the manager with:
|
|
55
60
|
|
|
56
61
|
```text
|
|
57
62
|
/usage
|
|
58
63
|
```
|
|
59
64
|
|
|
60
|
-
In TUI or RPC mode, the
|
|
65
|
+
In TUI or RPC mode, the menu first queries the active model provider and then offers these actions:
|
|
61
66
|
|
|
62
67
|
```text
|
|
63
68
|
Refresh current usage
|
|
@@ -69,13 +74,14 @@ View all configured providers…
|
|
|
69
74
|
Close
|
|
70
75
|
```
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
Cross-provider
|
|
74
|
-
Escape returns from provider selection
|
|
75
|
-
Print and JSON modes reject `/usage`
|
|
76
|
-
The cancellable live-query progress view
|
|
77
|
+
`/usage` accepts no arguments, including `--refresh`, a provider ID, or `--all`.
|
|
78
|
+
Cross-provider requests require an explicit interactive choice.
|
|
79
|
+
Escape returns from provider selection or closes the root menu.
|
|
80
|
+
Print and JSON modes reject `/usage` because they cannot host the interactive flow.
|
|
81
|
+
The extension owns the cancellable live-query progress view because it streams provider work and supports in-flight abort.
|
|
77
82
|
|
|
78
|
-
For the current OpenAI Codex provider, **Redeem usage limit reset…** checks fresh earned-reset details
|
|
83
|
+
For the current OpenAI Codex provider, **Redeem usage limit reset…** first checks fresh earned-reset details.
|
|
84
|
+
When details are available, you select a reset and review its exact effect before confirmation.
|
|
79
85
|
**No, go back** is the safe default and cancellation before confirmation sends no mutation.
|
|
80
86
|
After confirmation, the reset operation cannot be cancelled from its progress view; session replacement or shutdown still aborts owned work.
|
|
81
87
|
A transport failure offers **Try again** with the same redemption request ID so the backend can treat an uncertain retry idempotently.
|
|
@@ -83,48 +89,45 @@ Successful, already-completed, not-needed, and no-credit outcomes are reported s
|
|
|
83
89
|
|
|
84
90
|
## ⚙️ Settings
|
|
85
91
|
|
|
86
|
-
Choose **Settings** in `/usage` to edit Codex Fast mode and
|
|
92
|
+
Choose **Settings** in `/usage` to edit Codex Fast mode and the Codex reset countdown through Pi's settings-list interaction in TUI mode.
|
|
87
93
|
RPC mode reports the active manual settings path instead of opening terminal UI.
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
The
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
These preferences live in `pi-usage.json` under Pi's user agent directory, normally `~/.pi/agent/pi-usage.json`.
|
|
96
|
+
The extension reloads this file at every session start and does not create it until the first successful save.
|
|
97
|
+
Within one Pi process, changes save immediately in invocation order.
|
|
98
|
+
Saves preserve unknown JSON fields and publish through a private temporary file plus rename.
|
|
99
|
+
Malformed or invalid files remain untouched.
|
|
93
100
|
A failed save restores the prior displayed and effective value, while shutdown waits for queued writes.
|
|
94
101
|
Separate Pi processes are not mutually locked.
|
|
95
102
|
|
|
96
103
|
### Codex Fast mode
|
|
97
104
|
|
|
98
|
-
Run
|
|
105
|
+
Run `/fast` without arguments to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
|
|
99
106
|
|
|
100
107
|
Fast is about 1.5× faster and uses more of your plan allowance.
|
|
101
108
|
The `codexFastMode` preference defaults to Off.
|
|
102
109
|
|
|
103
110
|
Fast currently applies only to official `openai-codex-responses` requests for `gpt-5.4`, `gpt-5.5`, `gpt-5.6-sol`, `gpt-5.6-terra`, and `gpt-5.6-luna` at `https://chatgpt.com`.
|
|
104
111
|
It sends `service_tier: "priority"` while enabled and explicit `service_tier: "default"` otherwise.
|
|
105
|
-
The statusline adds `fast` only while the preference is effective, for example `codex fast 59%
|
|
112
|
+
The statusline adds `fast` only while the preference is effective, for example `codex fast 59% ↻ 2h30m` with the default reset countdown.
|
|
106
113
|
Unsupported models and custom or proxy origins are left unchanged.
|
|
107
114
|
|
|
108
115
|
`/fast` supports TUI and RPC mode, accepts no arguments, and rejects print or JSON mode before mutation.
|
|
109
116
|
A toggle affects provider requests whose payload hook starts after the save; a request already sent is unchanged.
|
|
110
117
|
Repair or remove an invalid file, then run `/reload` before trying the toggle again.
|
|
111
118
|
|
|
112
|
-
###
|
|
119
|
+
### Codex statusline reset countdown
|
|
120
|
+
|
|
121
|
+
The `codexStatusResetCountdown` preference defaults to `true`. It replaces the window labels with the time remaining until each returned limit resets.
|
|
113
122
|
|
|
114
|
-
|
|
115
|
-
Turn it Off in the TUI Settings screen or edit the active user file manually, then run `/reload`:
|
|
123
|
+
Turn **Codex reset countdown** Off in the TUI Settings screen, or set it to `false` in `pi-usage.json` and run `/reload`, to restore the legacy `5h` and `wk` labels:
|
|
116
124
|
|
|
117
125
|
```json
|
|
118
126
|
{
|
|
119
|
-
"
|
|
127
|
+
"codexStatusResetCountdown": false
|
|
120
128
|
}
|
|
121
129
|
```
|
|
122
130
|
|
|
123
|
-
While enabled, xAI is available only through explicit `/usage` current, configured-provider, or all-provider actions.
|
|
124
|
-
It does not schedule xAI requests or publish xAI data to the statusline.
|
|
125
|
-
The disabled, malformed, and invalid-settings states perform no xAI usage auth resolution or consumer requests.
|
|
126
|
-
Turning it Off clears xAI cache state and prevents stale in-flight results from being published.
|
|
127
|
-
|
|
128
131
|
## 📋 Provider semantics
|
|
129
132
|
|
|
130
133
|
### OpenAI Codex
|
|
@@ -134,12 +137,13 @@ Turning it Off clears xAI cache state and prevents stale in-flight results from
|
|
|
134
137
|
- Source: the Codex usage and earned-reset endpoints using Pi's resolved runtime authorization
|
|
135
138
|
- Displayed data: returned duration-based windows, resets, credits, earned usage-limit resets, and additional model buckets
|
|
136
139
|
- Reset mutation: `POST /wham/rate-limit-reset-credits/consume` with a unique redemption request ID and, when available, the selected opaque credit ID
|
|
137
|
-
- Statusline examples: `codex 59%
|
|
140
|
+
- Statusline examples: `codex 59% ↻ 2h30m 61% ↻ 2d15m`, `codex fast 59% ↻ 2h30m`, or `codex spark 100% ↻ 2h30m`. Set `codexStatusResetCountdown` to `false` for the legacy `5h` and `wk` labels.
|
|
138
141
|
|
|
139
142
|
The statusline selects a returned bucket that matches the current Codex model when one is available.
|
|
140
143
|
Unlike `pi-codex-usage`, this successor intentionally has no Codex CLI fallback because the CLI may be logged into a different account than Pi's active runtime account.
|
|
141
144
|
|
|
142
|
-
Reset redemption is available only when Codex is the current provider
|
|
145
|
+
Reset redemption is available only when Codex is the current provider.
|
|
146
|
+
Pi's freshly resolved access token must exactly match an OAuth credential from Pi's stored login or a compatible credential source.
|
|
143
147
|
`pi-usage` forwards only the bearer authorization and matching `chatgpt-account-id` to the official ChatGPT origin.
|
|
144
148
|
API-key credentials, configured-but-not-current Codex accounts, account changes during the flow, and custom/proxy origins fail before mutation.
|
|
145
149
|
Backend-provided titles and descriptions are sanitized for terminal display.
|
|
@@ -150,7 +154,8 @@ Opaque credit and account IDs are never shown or persisted by the extension.
|
|
|
150
154
|
- Provider ID: `kimi-coding`
|
|
151
155
|
- Semantics: Kimi Coding Plan request windows plus a separate Extra Usage booster wallet
|
|
152
156
|
- Source: `GET https://api.kimi.com/coding/v1/usages` using Pi's freshly resolved runtime Bearer credential
|
|
153
|
-
- Displayed data: the weekly
|
|
157
|
+
- Displayed plan data: the weekly summary, returned sub-windows, used and remaining request percentages, and valid reset times
|
|
158
|
+
- Displayed wallet data: balance, monthly spend, and monthly charge limit
|
|
154
159
|
- Statusline examples: `kimi 99% 5h 96% wk` or `kimi 95% 1d`
|
|
155
160
|
|
|
156
161
|
Both Pi API-key credentials and Pi OAuth credentials are accepted because current Pi resolves each form as Bearer authorization for the same official Kimi inference origin.
|
|
@@ -171,7 +176,8 @@ The pinned Kimi managed-usage source at `cd7c97b377a77f7ae1b9d541cafe314e986ec07
|
|
|
171
176
|
### GitHub Copilot
|
|
172
177
|
|
|
173
178
|
- Provider ID: `github-copilot`
|
|
174
|
-
- Semantics: the allowance reported for the active Copilot plan
|
|
179
|
+
- Semantics: the allowance reported for the active Copilot plan
|
|
180
|
+
- Allowance labels: AI credits for usage-based billing, premium requests for legacy annual billing, or chat requests for Copilot Free
|
|
175
181
|
- Source: GitHub's undocumented `GET /copilot_internal/user` endpoint
|
|
176
182
|
- Displayed data: entitlement, remaining allowance, percentage, reset time, plan, and any additional usage beyond the included allowance
|
|
177
183
|
- Statusline examples: `copilot credits 1200/1500 80%`, `copilot 245/300 82%`, or `copilot chat 40/50 80%`
|
|
@@ -181,7 +187,8 @@ GitHub's quota endpoint requires the original GitHub OAuth token rather than the
|
|
|
181
187
|
It uses a candidate only when its short-lived access token exactly matches the freshly resolved active runtime credential.
|
|
182
188
|
Duplicate equivalent candidates are harmless, while conflicting matches fail closed without choosing by extension load order.
|
|
183
189
|
API-key credentials, account mismatches, GitHub Enterprise accounts, and proxy/custom provider origins fail closed.
|
|
184
|
-
The detailed report follows the endpoint's `token_based_billing` marker so AI credits are not mislabeled as legacy premium requests
|
|
190
|
+
The detailed report follows the endpoint's `token_based_billing` marker so AI credits are not mislabeled as legacy premium requests.
|
|
191
|
+
It reports overage without treating a negative included balance as malformed.
|
|
185
192
|
|
|
186
193
|
### OpenRouter
|
|
187
194
|
|
|
@@ -194,15 +201,36 @@ The detailed report follows the endpoint's `token_based_billing` marker so AI cr
|
|
|
194
201
|
The extension does not call OpenRouter's account-level `/credits` endpoint because that operation requires a separate management key.
|
|
195
202
|
OpenRouter documents the distinction between credit and rate limits in its [API limits guide](https://openrouter.ai/docs/api_reference/limits).
|
|
196
203
|
|
|
204
|
+
### DeepSeek API balance
|
|
205
|
+
|
|
206
|
+
- Provider ID: `deepseek`
|
|
207
|
+
- Semantics: current API account balance, not historical usage or quota
|
|
208
|
+
- Source: documented `GET https://api.deepseek.com/user/balance` using Pi's freshly resolved runtime API key
|
|
209
|
+
- Displayed data: whether API calls are available plus separate total, granted, and topped-up balances for each returned CNY or USD currency
|
|
210
|
+
- Statusline examples: `deepseek CNY 110.00` or `deepseek CNY 110.00 · USD 20.00`
|
|
211
|
+
|
|
212
|
+
The extension queries the fixed balance endpoint only when the selected model origin is `https://api.deepseek.com` and any resolved-auth origin override, when present, has the same official origin.
|
|
213
|
+
Pi's built-in DeepSeek API-key resolver does not attach a redundant auth origin, so the validated model origin remains authoritative when no override exists.
|
|
214
|
+
Custom and proxy origins fail before network access, redirects are rejected, and only the resolved Bearer credential is forwarded from Pi's runtime auth.
|
|
215
|
+
Monetary decimal strings remain exact from the response through display.
|
|
216
|
+
CNY and USD stay separate and are never converted or added together.
|
|
217
|
+
The balance endpoint does not provide historical spend, request windows, reset times, or aggregate token usage, so `pi-usage` does not claim those DeepSeek capabilities.
|
|
218
|
+
|
|
219
|
+
The contract was verified on 2026-08-28 against [DeepSeek's Get User Balance documentation](https://api-docs.deepseek.com/api/get-user-balance) and Pi's [`deepseek.ts`](https://github.com/earendil-works/pi/blob/c49906ec77788625aacbdc53ebca6fbe65bd20f5/packages/ai/src/providers/deepseek.ts) at `c49906ec77788625aacbdc53ebca6fbe65bd20f5`.
|
|
220
|
+
DeepSeek Harness `cd5ef8148158c3a752a658978873241fdf8e2bbc` reports only per-request model token usage and does not provide account balance data.
|
|
221
|
+
|
|
197
222
|
### OpenCode Go (Zen)
|
|
198
223
|
|
|
199
224
|
- Provider ID: `opencode-go`
|
|
200
225
|
- Semantics: OpenCode Zen plan usage windows—rolling, weekly, and monthly
|
|
201
226
|
- Source: `GET https://opencode.ai/zen/go/v1/usage` using Pi's resolved inference API key
|
|
202
|
-
- Displayed data: used percentage and reset time for each window
|
|
227
|
+
- Displayed data: used percentage and reset time for each window
|
|
228
|
+
- Status handling: `rate-limited` windows remain visible, while unknown statuses become unavailable notes
|
|
203
229
|
- Statusline examples: `zen 0% r 4% w 2% m`
|
|
204
230
|
|
|
205
|
-
The fixed endpoint is queried only when the
|
|
231
|
+
The fixed endpoint is queried only when the OpenCode Go model uses the official `https://opencode.ai` origin.
|
|
232
|
+
When resolved provider auth includes a base URL, that URL must use the same origin.
|
|
233
|
+
Other origins fail before the credential is sent.
|
|
206
234
|
|
|
207
235
|
### xAI consumer subscriptions
|
|
208
236
|
|
|
@@ -210,12 +238,13 @@ The fixed endpoint is queried only when the candidate OpenCode Go model and the
|
|
|
210
238
|
- Semantics: consumer subscription allowance and credits, not xAI API-team billing
|
|
211
239
|
- Identity route: `GET https://cli-chat-proxy.grok.com/v1/user?include=subscription`
|
|
212
240
|
- Billing route: `GET https://cli-chat-proxy.grok.com/v1/billing?format=credits`
|
|
213
|
-
- Displayed data: included allowance
|
|
214
|
-
- Statusline: not published; xAI is queried only through an explicit `/usage` action
|
|
241
|
+
- Displayed data: included allowance or legacy monetary limit, period and reset, on-demand spend and cap, prepaid balance, and a sanitized optional plan tier
|
|
242
|
+
- Statusline: not published; xAI is queried only through an explicit `/usage` action
|
|
215
243
|
|
|
216
244
|
The adapter accepts only the official Pi inference origin `https://api.x.ai` and a freshly resolved bearer that exactly matches one complete Pi OAuth credential.
|
|
217
245
|
Pi's reviewed OAuth scope is `openid profile email offline_access grok-cli:access api:access`.
|
|
218
|
-
`XAI_API_KEY`, duplicate or conflicting OAuth candidates, account mismatches, incomplete OAuth records
|
|
246
|
+
The adapter rejects `XAI_API_KEY`, duplicate or conflicting OAuth candidates, account mismatches, and incomplete OAuth records.
|
|
247
|
+
It also rejects custom or proxy-resolved origins before consumer-proxy access.
|
|
219
248
|
API-key users can review API-team spend through [console.x.ai](https://console.x.ai/) instead.
|
|
220
249
|
The public Management API requires a separate management key and team ID and is intentionally outside this runtime-credential integration.
|
|
221
250
|
|
|
@@ -232,30 +261,35 @@ The implementation contract was verified against these first-party revisions:
|
|
|
232
261
|
- Grok Build [`UserInfo`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/auth/model.rs), [`subscription_check.rs`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/agent/subscription_check.rs), [`billing.rs`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/extensions/billing.rs), [`auth/config.rs`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-shell/src/auth/config.rs), [`xai-grok-http`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-http/src/lib.rs), and [`xai-grok-version`](https://github.com/xai-org/grok-build/blob/9684fa3cdbf2995e30ea8b9b637f1db008f144fc/crates/codegen/xai-grok-version/Cargo.toml) at `9684fa3`.
|
|
233
262
|
- [xAI Management API team billing boundary at `723dd2a`](https://github.com/xai-org/xai-proto/blob/723dd2aa22d17be35617463837dc47cda008d90e/proto/xai/management_api/v1/billing.proto).
|
|
234
263
|
|
|
235
|
-
The approved 2026-08-27
|
|
264
|
+
The approved 2026-08-27 protocol smoke used only Pi's OAuth bearer and read no Grok-local files.
|
|
265
|
+
A disposable or maintainer account received HTTP 200 without redirects from both routes.
|
|
236
266
|
The implementation also sends the non-secret client headers present on both routes in current Grok Build source, with `x-userid` added only for billing.
|
|
237
|
-
The sanitized identity shape contained a string `userId` and nullable `subscriptionTier
|
|
267
|
+
The sanitized identity shape contained a string `userId` and nullable `subscriptionTier`.
|
|
268
|
+
The billing shape contained a `config` object with period and distinct on-demand and prepaid wrappers, without retaining field values.
|
|
238
269
|
|
|
239
|
-
|
|
270
|
+
xAI identity and billing requests occur only after an explicit current, configured-provider, or all-provider `/usage` action.
|
|
240
271
|
|
|
241
272
|
### Z.AI (GLM Coding Plan)
|
|
242
273
|
|
|
243
274
|
- Provider ID: `zai` and `zai-coding-cn`
|
|
244
275
|
- Semantics: GLM Coding Plan quota windows—the rolling 5-hour and weekly plan-usage windows plus the monthly MCP allowance
|
|
245
|
-
- Source:
|
|
246
|
-
-
|
|
247
|
-
-
|
|
276
|
+
- Source: the undocumented `GET {origin}/api/monitor/usage/quota/limit` endpoint also used by Z.AI's official coding plugin
|
|
277
|
+
- Allowed origins: the model base URL must resolve to `https://api.z.ai` or `https://open.bigmodel.cn`
|
|
278
|
+
- Displayed data: explicit used and remaining values, reset times, provider-reported per-tool MCP details, and the reported plan level
|
|
279
|
+
- Percentage-only windows remain percent-based
|
|
280
|
+
- Statusline: publishes remaining plan percentages such as `zai 87% 5h 76% wk`; monthly MCP details remain available through `/usage`
|
|
248
281
|
|
|
249
282
|
The monitor endpoint is not a published API contract and may return legacy `TOKENS_LIMIT` or newer `CREDIT_LIMIT` window names.
|
|
250
283
|
The extension classifies both forms by the provider's window unit and does not label provider-reported counts as tokens or calls.
|
|
251
|
-
The quota monitor expects
|
|
284
|
+
The quota monitor expects a raw API key without a `Bearer` prefix.
|
|
285
|
+
The extension removes that prefix from resolved authorization before sending it to the monitor endpoint.
|
|
252
286
|
Fingerprinting and redaction keep using the original resolved credential.
|
|
253
287
|
Only the official `api.z.ai` and `open.bigmodel.cn` origins are queried; other origins fail before sending the credential.
|
|
254
288
|
|
|
255
289
|
## 🧭 Current and configured accounts
|
|
256
290
|
|
|
257
|
-
`Current`
|
|
258
|
-
`Configured`
|
|
291
|
+
`Current` identifies the provider and credential used by Pi's selected model.
|
|
292
|
+
`Configured` identifies runtime auth for another supported provider, not an active provider.
|
|
259
293
|
|
|
260
294
|
The extension does not enumerate multiple accounts inside one provider and does not switch accounts.
|
|
261
295
|
Account selection remains owned by Pi or an account-management extension.
|
|
@@ -268,9 +302,11 @@ After the active runtime credential changes, the next command, turn, or schedule
|
|
|
268
302
|
|
|
269
303
|
The `usage` status item is active only for selected providers that publish statusline usage.
|
|
270
304
|
It refreshes every five minutes while the session remains on such a provider and is cleared when the model changes to an unsupported or menu-only provider.
|
|
305
|
+
DeepSeek publishes each returned currency as a separate exact balance segment and reports when the API is unavailable.
|
|
271
306
|
xAI is always menu-only and never starts a scheduled status refresh.
|
|
307
|
+
Z.AI statusline usage refreshes every five minutes while the selected model remains on Z.AI.
|
|
272
308
|
|
|
273
|
-
|
|
309
|
+
Queries for another provider or all providers never publish their results to the statusline.
|
|
274
310
|
`@narumitw/pi-statusline` supplies the default `📊` icon; `pi-usage` publishes text-only values.
|
|
275
311
|
|
|
276
312
|
## 🔄 Migrating from pi-codex-usage
|
|
@@ -296,10 +332,12 @@ Behavior changes:
|
|
|
296
332
|
|
|
297
333
|
Credential candidates are collected synchronously in memory and are not cached, persisted, logged, formatted, or appended to the Pi session.
|
|
298
334
|
The protocol carries no account name or extension identity.
|
|
299
|
-
Only the selected provider's exact runtime match is used, and secrets are sent only to
|
|
335
|
+
Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
|
|
336
|
+
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.
|
|
300
337
|
Pi extensions run with the user's process privileges, so the shared event bus is not a security boundary between installed extensions.
|
|
301
|
-
Install only trusted extensions because
|
|
302
|
-
Protocol v1 interoperability is characterized for the repository's supported Pi runtime
|
|
338
|
+
Install only trusted extensions because they can read user files and process memory.
|
|
339
|
+
Protocol v1 interoperability is characterized for the repository's supported Pi runtime.
|
|
340
|
+
An absent or incompatible peer preserves standalone fallback and fail-closed mismatch behavior.
|
|
303
341
|
|
|
304
342
|
## 🚧 Limitations
|
|
305
343
|
|
|
@@ -309,6 +347,7 @@ Protocol v1 interoperability is characterized for the repository's supported Pi
|
|
|
309
347
|
- xAI usage supports only a uniquely matched Pi OAuth subscription credential; xAI API keys and Management API credentials are unsupported.
|
|
310
348
|
- Credentials resolved for custom provider base URLs are never forwarded to the providers' official usage endpoints; effective auth origin validation requires Pi 0.81.0 or newer.
|
|
311
349
|
- Provider reports are snapshots and may themselves be delayed by the provider.
|
|
350
|
+
- DeepSeek reports current API balance only; it does not expose historical usage, quota windows, reset times, or account-wide token totals through the balance endpoint.
|
|
312
351
|
- OpenRouter successful inference responses do not expose proactive request-rate counters; `/usage` reports the documented per-key credit/spend fields instead.
|
|
313
352
|
- A provider may not return a safe human-readable account identity.
|
|
314
353
|
In that case the provider and runtime credential state remain visible without exposing secrets.
|
|
@@ -351,7 +390,7 @@ The generated runtime is built from the authoritative `src/index.ts` graph and d
|
|
|
351
390
|
|
|
352
391
|
## 🔎 Keywords
|
|
353
392
|
|
|
354
|
-
Pi extension, Pi coding agent, usage, quota, OpenAI Codex usage, ChatGPT subscription limits, Kimi For Coding, Kimi Coding Plan usage, GitHub Copilot AI credits, GitHub Copilot premium requests, OpenRouter credits, xAI OAuth usage, Grok subscription allowance, API-key spend limits, TypeScript Pi package, npm Pi extension.
|
|
393
|
+
Pi extension, Pi coding agent, usage, quota, DeepSeek API balance, DeepSeek balance, OpenAI Codex usage, ChatGPT subscription limits, Kimi For Coding, Kimi Coding Plan usage, GitHub Copilot AI credits, GitHub Copilot premium requests, OpenRouter credits, xAI OAuth usage, Grok subscription allowance, API-key spend limits, TypeScript Pi package, npm Pi extension.
|
|
355
394
|
|
|
356
395
|
## 📄 License
|
|
357
396
|
|