@narumitw/pi-usage 0.60.0 β 0.60.2
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 +27 -19
- package/dist/index.ts +804 -322
- package/dist/index.ts.map +4 -4
- package/package.json +1 -1
- package/src/core.ts +28 -2
- package/src/format.ts +37 -23
- package/src/index.ts +13 -0
- package/src/providers/fireworks.ts +112 -0
- package/src/providers/minimax.ts +21 -0
- package/src/query.ts +110 -150
- package/src/settings.ts +155 -8
- package/src/types.ts +39 -2
- package/src/usage-settings-ui.ts +88 -183
- package/src/usage-targets.ts +143 -0
- package/src/usage.ts +419 -107
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ xAI OAuth subscription reporting follows the reviewed Grok Build contract and ru
|
|
|
16
16
|
- Reports GitHub Copilot allowances and OpenRouter per-key limits and spending windows.
|
|
17
17
|
- Reports exact DeepSeek API balances with separate CNY and USD values.
|
|
18
18
|
- Reports OpenCode Go plan windows and Z.AI Coding Plan quotas.
|
|
19
|
-
- Reports Fireworks rated API spend for the last 30 days with per-series subtotals.
|
|
19
|
+
- Reports Fireworks rated API spend for the last 30 days with per-series subtotals and account selection.
|
|
20
20
|
- Reports Vercel AI Gateway credit balance and lifetime spend.
|
|
21
21
|
- Reports Baseten organization Model APIs spend after credits for the last 30 days.
|
|
22
22
|
- Reports xAI OAuth subscription allowances and credits.
|
|
@@ -56,6 +56,7 @@ The package declares `dist/index.ts`, so an unbuilt local checkout must run the
|
|
|
56
56
|
## π Quick start
|
|
57
57
|
|
|
58
58
|
Run `/usage` in TUI or RPC mode to inspect the active provider, refresh its usage, or choose another configured provider.
|
|
59
|
+
When a provider exposes several billing targets, `/usage` asks for one target before querying usage.
|
|
59
60
|
Run `/fast` to toggle Fast mode for a supported active Codex model.
|
|
60
61
|
|
|
61
62
|
## π¬ Commands
|
|
@@ -84,6 +85,21 @@ Escape returns from provider selection or closes the root menu.
|
|
|
84
85
|
Print and JSON modes reject `/usage` because they cannot host the interactive flow.
|
|
85
86
|
The extension owns the cancellable live-query progress view because it streams provider work and supports in-flight abort.
|
|
86
87
|
|
|
88
|
+
### Provider targets
|
|
89
|
+
|
|
90
|
+
A target is the provider-owned account, organization, project, team, or workspace used for one usage query.
|
|
91
|
+
Providers without target discovery query immediately, and a single returned target is selected automatically without writing settings.
|
|
92
|
+
When several targets are available, `/usage` remembers an explicit selection by provider and reuses it only while it remains in a fresh listing.
|
|
93
|
+
A missing remembered target returns **Selection required** instead of querying another target silently.
|
|
94
|
+
The current provider then offers **Select <target>β¦**, while a ready current or individually viewed provider offers **Change <target>β¦**.
|
|
95
|
+
|
|
96
|
+
Selecting another provider may open one Pi target prompt after that provider is queried lazily.
|
|
97
|
+
Cancelling the prompt changes nothing.
|
|
98
|
+
Auth and target membership are revalidated before an explicit selection is saved, then both are resolved again before billing is queried.
|
|
99
|
+
**View all configured providersβ¦** never opens nested target prompts: unresolved providers remain visible with guidance to view them individually.
|
|
100
|
+
Background status refresh also stays non-interactive and shows `selection required` until `/usage` completes the choice.
|
|
101
|
+
Fireworks accounts are the first implementation of this provider-neutral flow.
|
|
102
|
+
|
|
87
103
|
For the current OpenAI Codex provider, **Redeem usage limit resetβ¦** first checks fresh earned-reset details.
|
|
88
104
|
When details are available, you select a reset and review its exact effect before confirmation.
|
|
89
105
|
**No, go back** is the safe default and cancellation before confirmation sends no mutation.
|
|
@@ -93,7 +109,7 @@ Successful, already-completed, not-needed, and no-credit outcomes are reported s
|
|
|
93
109
|
|
|
94
110
|
## βοΈ Settings
|
|
95
111
|
|
|
96
|
-
Choose **Settings** in `/usage` to edit Codex Fast mode
|
|
112
|
+
Choose **Settings** in `/usage` to edit Codex Fast mode and the Codex reset countdown through Pi's settings-list interaction in TUI mode.
|
|
97
113
|
RPC mode reports the active manual settings path instead of opening terminal UI.
|
|
98
114
|
|
|
99
115
|
These preferences live in `pi-usage.json` under Pi's user agent directory, normally `~/.pi/agent/pi-usage.json`.
|
|
@@ -104,19 +120,9 @@ Malformed or invalid files remain untouched.
|
|
|
104
120
|
A failed save restores the prior displayed and effective value, while shutdown waits for queued writes.
|
|
105
121
|
Separate Pi processes are not mutually locked.
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
A Fireworks
|
|
110
|
-
For a key that can see several accounts, choose **Fireworks account** in the TUI Settings screen, or set the exact visible account slug in `pi-usage.json` and run `/reload`:
|
|
111
|
-
|
|
112
|
-
```json
|
|
113
|
-
{
|
|
114
|
-
"fireworksAccountId": "acme"
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
The `fireworksAccountId` setting is validated as a URL-safe account slug and then checked against the official account listing before billing data is requested.
|
|
119
|
-
Submit a blank value from the TUI input, or remove the JSON field and run `/reload`, to restore single-account auto-selection.
|
|
123
|
+
Target selections are stored only as IDs in the provider-neutral `selectedTargets` object in this file and are managed through `/usage`, not the Settings screen.
|
|
124
|
+
The former `fireworksAccountId` field remains read-compatible: it supplies `selectedTargets.fireworks` in memory only when the generic value is absent.
|
|
125
|
+
A successful explicit Fireworks account selection writes the generic field and removes the legacy field atomically; ordinary reads do not rewrite the file.
|
|
120
126
|
|
|
121
127
|
### Codex Fast mode
|
|
122
128
|
|
|
@@ -279,7 +285,8 @@ DeepSeek Harness `cd5ef8148158c3a752a658978873241fdf8e2bbc` reports only per-req
|
|
|
279
285
|
- Statusline example: `fireworks USD 12.345678901`
|
|
280
286
|
|
|
281
287
|
The extension queries the fixed endpoints only when the selected model origin is `https://api.fireworks.ai` and any resolved-auth origin override, when present, has the same official origin.
|
|
282
|
-
The account slug is discovered through the documented account listing
|
|
288
|
+
The account slug is discovered through the documented account listing.
|
|
289
|
+
One visible account is selected automatically; several visible accounts use the remembered selection or ask through `/usage`, and a disappeared selection returns **Selection required** without a billing request.
|
|
283
290
|
Monetary `units` and `nanos` values are summed exactly with integer arithmetic and stay exact through display.
|
|
284
291
|
Fireworks does not expose credit balance, spend caps, per-window quota, or reset times through its API, so `pi-usage` does not claim those Fireworks capabilities; the web console remains the authoritative balance source.
|
|
285
292
|
Rated line items may differ from the final invoice once credits or adjustments are applied.
|
|
@@ -390,8 +397,8 @@ Only the official `api.z.ai` and `open.bigmodel.cn` origins are queried; other o
|
|
|
390
397
|
`Current` identifies the provider and credential used by Pi's selected model.
|
|
391
398
|
`Configured` identifies runtime auth for another supported provider, not an active provider.
|
|
392
399
|
|
|
393
|
-
The extension
|
|
394
|
-
|
|
400
|
+
The extension selects one provider target for one query and never flattens targets into provider rows or aggregates every visible target.
|
|
401
|
+
Provider adapters own target discovery and validation; core owns one-target selection, persistence, cache identity, cancellation, and UI.
|
|
395
402
|
A compatible credential owner may offer the verified active named account through the versioned process-local protocol without exposing its account label or storage.
|
|
396
403
|
Without such an owner, `pi-usage` retains its standalone Pi `auth.json` behavior.
|
|
397
404
|
An older or incompatible owner degrades to the existing authentication-unavailable result when the stored login does not match runtime auth.
|
|
@@ -457,7 +464,7 @@ An absent or incompatible peer preserves standalone fallback and fail-closed mis
|
|
|
457
464
|
- 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.
|
|
458
465
|
- Provider reports are snapshots and may themselves be delayed by the provider.
|
|
459
466
|
- 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.
|
|
460
|
-
- Fireworks reports rated 30-day spend only; credit balance and spend caps are visible only in the Fireworks web console, and
|
|
467
|
+
- Fireworks reports rated 30-day spend only; credit balance and spend caps are visible only in the Fireworks web console, and `/usage` must select one visible account before querying a multi-account key.
|
|
461
468
|
- Moonshot AI reports current API balance only; it does not expose historical spend, aggregate token usage, quota windows, or reset times through the balance endpoint.
|
|
462
469
|
- Vercel AI Gateway reports current team credits and lifetime spend only; Custom Reporting and request-rate counters are not queried.
|
|
463
470
|
- MiniMax Token Plan field semantics have changed over time; contradictory counts and percentages are reported as unavailable rather than guessed.
|
|
@@ -484,6 +491,7 @@ packages/pi-usage/
|
|
|
484
491
|
β βββ codex-fast-runtime.ts # Fast command, persistence lifecycle, and request hooks
|
|
485
492
|
β βββ settings.ts # Validated user settings and atomic persistence
|
|
486
493
|
β βββ usage-helpers.ts # Small orchestration helpers
|
|
494
|
+
β βββ usage-targets.ts # Provider-neutral target resolution and safe picker descriptors
|
|
487
495
|
β βββ query.ts # Runtime auth resolution and bounded provider queries
|
|
488
496
|
β βββ oauth-credential-source.ts # Ephemeral OAuth candidate collection
|
|
489
497
|
β βββ codex-resets.ts # Codex reset auth, API contracts, and normalization
|