@narumitw/pi-usage 0.57.0 → 0.58.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
@@ -15,6 +15,7 @@ xAI OAuth subscription reporting follows the reviewed Grok Build contract and ru
15
15
  - Reports GitHub Copilot allowances and OpenRouter per-key limits and spending windows.
16
16
  - Reports exact DeepSeek API balances with separate CNY and USD values.
17
17
  - Reports OpenCode Go plan windows and Z.AI Coding Plan quotas.
18
+ - Reports Fireworks rated API spend for the last 30 days with per-series subtotals.
18
19
  - Reports xAI OAuth subscription allowances and credits.
19
20
  - Toggles persistent Codex Fast routing through `/fast` or the usage menu.
20
21
  - Redeems eligible Codex resets only after fresh account matching and explicit confirmation.
@@ -89,7 +90,7 @@ Successful, already-completed, not-needed, and no-credit outcomes are reported s
89
90
 
90
91
  ## ⚙️ Settings
91
92
 
92
- Choose **Settings** in `/usage` to edit Codex Fast mode and the Codex reset countdown through Pi's settings-list interaction in TUI mode.
93
+ Choose **Settings** in `/usage` to edit Codex Fast mode, the Codex reset countdown, and the Fireworks account selector through Pi's settings-list interaction in TUI mode.
93
94
  RPC mode reports the active manual settings path instead of opening terminal UI.
94
95
 
95
96
  These preferences live in `pi-usage.json` under Pi's user agent directory, normally `~/.pi/agent/pi-usage.json`.
@@ -100,6 +101,20 @@ Malformed or invalid files remain untouched.
100
101
  A failed save restores the prior displayed and effective value, while shutdown waits for queued writes.
101
102
  Separate Pi processes are not mutually locked.
102
103
 
104
+ ### Fireworks account
105
+
106
+ A Fireworks key that can see one account needs no setting.
107
+ 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`:
108
+
109
+ ```json
110
+ {
111
+ "fireworksAccountId": "acme"
112
+ }
113
+ ```
114
+
115
+ The `fireworksAccountId` setting is validated as a URL-safe account slug and then checked against the official account listing before billing data is requested.
116
+ Submit a blank value from the TUI input, or remove the JSON field and run `/reload`, to restore single-account auto-selection.
117
+
103
118
  ### Codex Fast mode
104
119
 
105
120
  Run `/fast` without arguments to toggle Fast for the active supported Codex model, or use **Turn Fast mode on/off** in `/usage`.
@@ -219,6 +234,22 @@ The balance endpoint does not provide historical spend, request windows, reset t
219
234
  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
235
  DeepSeek Harness `cd5ef8148158c3a752a658978873241fdf8e2bbc` reports only per-request model token usage and does not provide account balance data.
221
236
 
237
+ ### Fireworks API spend
238
+
239
+ - Provider ID: `fireworks`
240
+ - Semantics: rated 30-day account spend, not credit balance or spend-cap quota
241
+ - Source: documented `GET https://api.fireworks.ai/v1/accounts` account discovery and `GET https://api.fireworks.ai/v1/accounts/{account_id}/billing/summary` rated costs using Pi's resolved inference API key
242
+ - Displayed data: exact rated spend per currency with serverless, dedicated-deployment, and training subtotals for the trailing 30 days
243
+ - Statusline example: `fireworks USD 12.345678901`
244
+
245
+ 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.
246
+ The account slug is discovered through the documented account listing; a key that can see several accounts must set `fireworksAccountId` in `pi-usage.json` to one of the listed account slugs, and the slug must remain visible to the key.
247
+ Monetary `units` and `nanos` values are summed exactly with integer arithmetic and stay exact through display.
248
+ 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.
249
+ Rated line items may differ from the final invoice once credits or adjustments are applied.
250
+
251
+ The contract was verified on 2026-07-31 against Fireworks' [Usage & Cost Breakdown](https://docs.fireworks.ai/accounts/exporting-usage-and-costs), [Get billing summary](https://docs.fireworks.ai/api-reference/get-billing-summary), and [List Accounts](https://docs.fireworks.ai/api-reference/list-accounts) API references.
252
+
222
253
  ### OpenCode Go (Zen)
223
254
 
224
255
  - Provider ID: `opencode-go`
@@ -303,6 +334,7 @@ After the active runtime credential changes, the next command, turn, or schedule
303
334
  The `usage` status item is active only for selected providers that publish statusline usage.
304
335
  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
336
  DeepSeek publishes each returned currency as a separate exact balance segment and reports when the API is unavailable.
337
+ Fireworks publishes exact per-currency rated spend totals and reports when no rated usage exists.
306
338
  xAI is always menu-only and never starts a scheduled status refresh.
307
339
  Z.AI statusline usage refreshes every five minutes while the selected model remains on Z.AI.
308
340
 
@@ -334,6 +366,7 @@ Credential candidates are collected synchronously in memory and are not cached,
334
366
  The protocol carries no account name or extension identity.
335
367
  Only the selected provider's exact runtime match is used, and secrets are sent only to its validated official origin.
336
368
  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.
369
+ Fireworks spend requests send only that resolved credential to the official `https://api.fireworks.ai` account-listing and billing-summary endpoints and refuse redirects.
337
370
  Pi extensions run with the user's process privileges, so the shared event bus is not a security boundary between installed extensions.
338
371
  Install only trusted extensions because they can read user files and process memory.
339
372
  Protocol v1 interoperability is characterized for the repository's supported Pi runtime.
@@ -348,6 +381,7 @@ An absent or incompatible peer preserves standalone fallback and fail-closed mis
348
381
  - 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.
349
382
  - Provider reports are snapshots and may themselves be delayed by the provider.
350
383
  - 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.
384
+ - Fireworks reports rated 30-day spend only; credit balance and spend caps are visible only in the Fireworks web console, and keys that can see several accounts must set `fireworksAccountId` in `pi-usage.json`.
351
385
  - OpenRouter successful inference responses do not expose proactive request-rate counters; `/usage` reports the documented per-key credit/spend fields instead.
352
386
  - A provider may not return a safe human-readable account identity.
353
387
  In that case the provider and runtime credential state remain visible without exposing secrets.
@@ -390,7 +424,7 @@ The generated runtime is built from the authoritative `src/index.ts` graph and d
390
424
 
391
425
  ## 🔎 Keywords
392
426
 
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.
427
+ Pi extension, Pi coding agent, usage, quota, DeepSeek API balance, DeepSeek balance, Fireworks API spend, Fireworks rated spend, 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.
394
428
 
395
429
  ## 📄 License
396
430