@hk_net/pi-usage-bars 0.4.2 → 0.4.4

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/CHANGELOG.md CHANGED
@@ -1,103 +1,123 @@
1
- # Changelog
2
-
3
- ## Unreleased
4
-
5
- ## [0.4.2] - 2026-08-13
6
-
7
- ### Fixed
8
-
9
- - Added support for credit-based ZAI plan tiers that report `CREDIT_LIMIT` quota windows. Thanks to [@chrislucca](https://github.com/chrislucca) for the contribution in [#1](https://github.com/hknet/pi-usage-bars/pull/1).
10
-
11
- ### Changed
12
-
13
- - Updated the development and test baseline to Pi SDK 0.84.1 while retaining runtime compatibility with Pi 0.81.1 and newer.
14
-
15
- ### Security
16
-
17
- - Updated the Pi SDK development dependency chain to use `undici` 8.9.0, resolving the advisories affecting earlier 8.x releases.
18
-
19
- ## [0.4.1] - 2026-07-31
20
-
21
- ### Fixed
22
-
23
- - Classify Codex quota windows by `limit_window_seconds` instead of assuming `primary_window` is always the session limit. Codex accounts that expose only a seven-day primary window now show it as Weekly and no longer display a fabricated `Session 0%` lane.
24
-
25
- ### Changed
26
-
27
- - Updated the development and test baseline to Pi SDK 0.83.0 while retaining runtime compatibility with Pi 0.81.1 and newer.
28
-
29
- ## [0.4.0] - 2026-07-22
30
-
31
- ### Added
32
-
33
- - Added Kimi For Coding quota support through Pi's `kimi-coding` credential and the first-party five-hour/weekly usage endpoint.
34
- - Added separate MiniMax Global and China Coding/Token Plan support, including the current token-plan endpoint and legacy coding-plan fallback.
35
- - Added provider-specific quota labels and support for MiniMax responses that expose an interval quota without a weekly quota.
36
- - Added neutral MiniMax purchased-Credits balance rendering when a key-authenticated first-party response exposes a balance.
37
- - Added OpenRouter account balance and daily/weekly/monthly key spend using the first-party Credits and Key APIs.
38
- - Added OpenRouter per-key limit bars only when the key has a real configured credit limit.
39
- - Added DeepSeek total, topped-up, and granted balance support through the official key-authenticated balance API.
40
- - Added separate Moonshot/Kimi API Global and China available, cash, and voucher balance support.
41
- - Added a typed financial-metrics roadmap for further balance/spend providers.
42
- - Added provider parsing, regional routing, endpoint fallback, financial rendering, authentication lifecycle, and smoke tests.
43
- - Added CI, reproducible installs, production auditing, and a maintainer release guide.
44
-
45
- ### Changed
46
-
47
- - Treat MiniMax status `2062` as a neutral “No active Token Plan” account state rather than an API error; the cookie-only console balance endpoint remains out of scope.
48
- - Expanded endpoint configuration documentation for Kimi, MiniMax, OpenRouter, DeepSeek, and Moonshot.
49
- - Changed npm publishing to an explicit manual workflow so source tags cannot accidentally republish an already released version.
50
- - Bumped the package version to 0.4.0.
51
-
52
- ## [0.3.0] - 2026-07-22
53
-
54
- ### Breaking changes
55
-
56
- - Renamed the npm package to `@hk_net/pi-usage-bars`; install it with `pi install npm:@hk_net/pi-usage-bars`.
57
- - Updated the minimum supported Pi release to 0.81.1.
58
- - Removed Google Gemini CLI and Google Antigravity usage support, matching their removal from Pi 0.71.0.
59
- - Refactored core usage orchestration to accept resolved provider tokens instead of reading or refreshing Pi credentials directly.
60
-
61
- ### Added
62
-
63
- - Added ZAI Coding Plan (China) provider and quota endpoint support.
64
- - Added abort-aware polling and provider requests.
65
- - Added strict TypeScript checking, a current-Pi smoke test, pinned development dependencies, and reproducible npm installs.
66
- - Added Pi package gallery image metadata and documented endpoint/security behavior.
67
-
68
- ### Changed
69
-
70
- - Authentication now goes through `ctx.modelRegistry.getProviderAuth()`, allowing Pi to safely resolve and refresh credentials with its canonical locked credential store.
71
- - Renamed Z.AI to the current Pi labels, ZAI Coding Plan (Global) and ZAI Coding Plan (China).
72
- - Limited polling and custom `/usage` UI to interactive TUI mode.
73
- - Made startup and model-change polling non-blocking and added complete session shutdown cleanup.
74
- - Updated the selector to use typed TUI APIs, explicit render requests, abortable loading, and theme-safe invalidation.
75
-
76
- ### Fixed
77
-
78
- - Fixed OAuth refresh failures on Pi 0.81.1 caused by the removed runtime `getOAuthApiKey` export.
79
- - Fixed potential credential races and permission changes caused by direct `auth.json` writes.
80
- - Fixed in-flight polling and selector requests surviving session shutdown or dialog disposal.
81
-
82
- ## [0.2.3] - 2026-06-10
83
-
84
- ### Fixed
85
-
86
- - **`DynamicBorder` is not defined** added missing import of `DynamicBorder` from `@earendil-works/pi-coding-agent`. This fixes the `DynamicBorder is not defined` error when calling `/usage`.
87
-
88
- ### Changed
89
-
90
- - Updated repository URLs from `ajarellanod` to `hknet` in `package.json` and `README.md`.
91
- - Updated README image URLs to point to the `hknet` repository.
92
- - Updated LICENSE copyright to `ajarellanod (secondary: hknet)`.
93
-
94
- ### Removed
95
-
96
- - Removed stale tgz build artifacts and `package-lock.json` from the repository.
97
- - Removed `NOTE.md` compliance report (development artifact).
98
-
99
- ## [0.2.2] - 2026-06-10
100
-
101
- ### Fixed
102
-
103
- - **Keybinding violation in `UsageSelectorComponent`** — replaced `getKeybindings()` with the `keybindings` parameter injected by `ctx.ui.custom()`. Per the Pi extension docs, custom components must use the injected `KeybindingsManager` directly rather than calling `getKeybindings()` or `setKeybindings()`. This fixes a compliance issue that could cause unexpected behavior under custom keybinding configurations.
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## [0.4.4] - 2026-08-22
6
+
7
+ ### Documentation
8
+
9
+ - Clarified that Kimi For Coding supports both Pi's Kimi Coding Plan OAuth login and API-key authentication.
10
+
11
+ ## [0.4.3] - 2026-08-22
12
+
13
+ ### Fixed
14
+
15
+ - Resolve kimi-coding OAuth credentials that Pi exposes only as a Bearer `Authorization` header (no `apiKey`), so the Kimi For Coding usage indicator no longer reports "auth resolution failed (configured authentication did not resolve a token)". Thanks to [@Rakkael](https://github.com/Rakkael) for the contribution in [#2](https://github.com/hknet/pi-usage-bars/pull/2).
16
+
17
+ ### Changed
18
+
19
+ - Updated the development and test baseline to Pi SDK 0.84.2 while retaining runtime compatibility with Pi 0.81.1 and newer.
20
+
21
+ ### Documentation
22
+
23
+ - Recorded Qwen Token Plan and Baseten usage-API research, including the conditions for revisiting provider support.
24
+
25
+ ## [0.4.2] - 2026-08-13
26
+
27
+ ### Fixed
28
+
29
+ - Added support for credit-based ZAI plan tiers that report `CREDIT_LIMIT` quota windows. Thanks to [@chrislucca](https://github.com/chrislucca) for the contribution in [#1](https://github.com/hknet/pi-usage-bars/pull/1).
30
+
31
+ ### Changed
32
+
33
+ - Updated the development and test baseline to Pi SDK 0.84.1 while retaining runtime compatibility with Pi 0.81.1 and newer.
34
+
35
+ ### Security
36
+
37
+ - Updated the Pi SDK development dependency chain to use `undici` 8.9.0, resolving the advisories affecting earlier 8.x releases.
38
+
39
+ ## [0.4.1] - 2026-07-31
40
+
41
+ ### Fixed
42
+
43
+ - Classify Codex quota windows by `limit_window_seconds` instead of assuming `primary_window` is always the session limit. Codex accounts that expose only a seven-day primary window now show it as Weekly and no longer display a fabricated `Session 0%` lane.
44
+
45
+ ### Changed
46
+
47
+ - Updated the development and test baseline to Pi SDK 0.83.0 while retaining runtime compatibility with Pi 0.81.1 and newer.
48
+
49
+ ## [0.4.0] - 2026-07-22
50
+
51
+ ### Added
52
+
53
+ - Added Kimi For Coding quota support through Pi's `kimi-coding` credential and the first-party five-hour/weekly usage endpoint.
54
+ - Added separate MiniMax Global and China Coding/Token Plan support, including the current token-plan endpoint and legacy coding-plan fallback.
55
+ - Added provider-specific quota labels and support for MiniMax responses that expose an interval quota without a weekly quota.
56
+ - Added neutral MiniMax purchased-Credits balance rendering when a key-authenticated first-party response exposes a balance.
57
+ - Added OpenRouter account balance and daily/weekly/monthly key spend using the first-party Credits and Key APIs.
58
+ - Added OpenRouter per-key limit bars only when the key has a real configured credit limit.
59
+ - Added DeepSeek total, topped-up, and granted balance support through the official key-authenticated balance API.
60
+ - Added separate Moonshot/Kimi API Global and China available, cash, and voucher balance support.
61
+ - Added a typed financial-metrics roadmap for further balance/spend providers.
62
+ - Added provider parsing, regional routing, endpoint fallback, financial rendering, authentication lifecycle, and smoke tests.
63
+ - Added CI, reproducible installs, production auditing, and a maintainer release guide.
64
+
65
+ ### Changed
66
+
67
+ - Treat MiniMax status `2062` as a neutral “No active Token Plan” account state rather than an API error; the cookie-only console balance endpoint remains out of scope.
68
+ - Expanded endpoint configuration documentation for Kimi, MiniMax, OpenRouter, DeepSeek, and Moonshot.
69
+ - Changed npm publishing to an explicit manual workflow so source tags cannot accidentally republish an already released version.
70
+ - Bumped the package version to 0.4.0.
71
+
72
+ ## [0.3.0] - 2026-07-22
73
+
74
+ ### Breaking changes
75
+
76
+ - Renamed the npm package to `@hk_net/pi-usage-bars`; install it with `pi install npm:@hk_net/pi-usage-bars`.
77
+ - Updated the minimum supported Pi release to 0.81.1.
78
+ - Removed Google Gemini CLI and Google Antigravity usage support, matching their removal from Pi 0.71.0.
79
+ - Refactored core usage orchestration to accept resolved provider tokens instead of reading or refreshing Pi credentials directly.
80
+
81
+ ### Added
82
+
83
+ - Added ZAI Coding Plan (China) provider and quota endpoint support.
84
+ - Added abort-aware polling and provider requests.
85
+ - Added strict TypeScript checking, a current-Pi smoke test, pinned development dependencies, and reproducible npm installs.
86
+ - Added Pi package gallery image metadata and documented endpoint/security behavior.
87
+
88
+ ### Changed
89
+
90
+ - Authentication now goes through `ctx.modelRegistry.getProviderAuth()`, allowing Pi to safely resolve and refresh credentials with its canonical locked credential store.
91
+ - Renamed Z.AI to the current Pi labels, ZAI Coding Plan (Global) and ZAI Coding Plan (China).
92
+ - Limited polling and custom `/usage` UI to interactive TUI mode.
93
+ - Made startup and model-change polling non-blocking and added complete session shutdown cleanup.
94
+ - Updated the selector to use typed TUI APIs, explicit render requests, abortable loading, and theme-safe invalidation.
95
+
96
+ ### Fixed
97
+
98
+ - Fixed OAuth refresh failures on Pi 0.81.1 caused by the removed runtime `getOAuthApiKey` export.
99
+ - Fixed potential credential races and permission changes caused by direct `auth.json` writes.
100
+ - Fixed in-flight polling and selector requests surviving session shutdown or dialog disposal.
101
+
102
+ ## [0.2.3] - 2026-06-10
103
+
104
+ ### Fixed
105
+
106
+ - **`DynamicBorder` is not defined** — added missing import of `DynamicBorder` from `@earendil-works/pi-coding-agent`. This fixes the `DynamicBorder is not defined` error when calling `/usage`.
107
+
108
+ ### Changed
109
+
110
+ - Updated repository URLs from `ajarellanod` to `hknet` in `package.json` and `README.md`.
111
+ - Updated README image URLs to point to the `hknet` repository.
112
+ - Updated LICENSE copyright to `ajarellanod (secondary: hknet)`.
113
+
114
+ ### Removed
115
+
116
+ - Removed stale tgz build artifacts and `package-lock.json` from the repository.
117
+ - Removed `NOTE.md` compliance report (development artifact).
118
+
119
+ ## [0.2.2] - 2026-06-10
120
+
121
+ ### Fixed
122
+
123
+ - **Keybinding violation in `UsageSelectorComponent`** — replaced `getKeybindings()` with the `keybindings` parameter injected by `ctx.ui.custom()`. Per the Pi extension docs, custom components must use the injected `KeybindingsManager` directly rather than calling `getKeybindings()` or `setKeybindings()`. This fixes a compliance issue that could cause unexpected behavior under custom keybinding configurations.
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -17,7 +17,7 @@ It adds:
17
17
  | Anthropic Claude | `anthropic` | Claude Pro/Max OAuth |
18
18
  | ZAI Coding Plan (Global) | `zai` | ZAI API key |
19
19
  | ZAI Coding Plan (China) | `zai-coding-cn` | ZAI China API key |
20
- | Kimi For Coding | `kimi-coding` | Kimi Coding Plan API key |
20
+ | Kimi For Coding | `kimi-coding` | Kimi Coding Plan OAuth or API key |
21
21
  | MiniMax Coding Plan (Global) | `minimax` | MiniMax Global API key |
22
22
  | MiniMax Coding Plan (China) | `minimax-cn` | MiniMax China API key |
23
23
  | OpenRouter | `openrouter` | OpenRouter API key |
@@ -35,7 +35,7 @@ Google Gemini CLI and Google Antigravity are not supported because Pi removed th
35
35
 
36
36
  ## Requirements
37
37
 
38
- - Pi 0.81.1 or newer (tested with the current Pi 0.83.0 release)
38
+ - Pi 0.81.1 or newer (tested with the current Pi 0.84.2 release)
39
39
  - Node.js 22.19 or newer when using the npm-distributed Pi CLI
40
40
 
41
41
  Authenticate providers through Pi's `/login` command. The extension resolves credentials through Pi's provider API; it does not read or write `auth.json` itself.
@@ -105,6 +105,8 @@ The Codex and Claude usage endpoints are fixed to their first-party services. Cl
105
105
 
106
106
  Quota percentages and monetary account data have different meaning and color semantics. OpenRouter, DeepSeek, Moonshot, and MiniMax financial data are rendered as neutral account values; percentages are used only when an actual limit exists.
107
107
 
108
+ See [provider support research](docs/provider-research.md) for providers investigated but currently blocked by the absence of a suitable first-party usage API, including Qwen Token Plan and Baseten.
109
+
108
110
  ## Development
109
111
 
110
112
  Install Node.js 22.19+ and Bun 1.3, then run:
@@ -0,0 +1,39 @@
1
+ # Provider support research
2
+
3
+ This document records providers considered for usage-bar support but currently blocked by the absence of a suitable first-party API. Recheck these findings when a provider publishes a new quota, balance, or billing API.
4
+
5
+ ## Qwen Token Plan
6
+
7
+ **Status:** Blocked — no account-usage surface found as of 2026-08-13.
8
+
9
+ Pi 0.84.1 supports these provider IDs:
10
+
11
+ - `qwen-token-plan`
12
+ - `qwen-token-plan-individual`
13
+ - `qwen-token-plan-cn`
14
+
15
+ The Individual provider shares the international inference endpoint and `QWEN_TOKEN_PLAN_API_KEY` with the existing international provider, but exposes a narrower model catalog.
16
+
17
+ Research found no documented API-key-authenticated endpoint that reports consumed or remaining quota, percentages, or reset times. Independent probing of eight likely usage/quota paths on `token-plan.ap-southeast-1.maas.aliyuncs.com` returned `404`, and successful inference responses did not include quota or rate-limit headers. Qwen's client can recognize an exhausted-quota error, but that provides no usage percentage or reset timestamp.
18
+
19
+ Do not estimate account-wide quota from requests observed by this extension: other clients and sessions would make that value incomplete and misleading.
20
+
21
+ **Recheck when:** Alibaba Model Studio documents a Token Plan usage endpoint, adds quota headers to inference responses, or exposes a key-authenticated portal API.
22
+
23
+ ## Baseten
24
+
25
+ **Status:** Blocked — no account-usage surface found as of 2026-08-13.
26
+
27
+ Pi 0.84.0 added the `baseten` provider using `BASETEN_API_KEY`. Baseten is primarily usage-billed, and research found no documented API-key endpoint for account balance, credits, budget utilization, or billing usage that this extension could safely query.
28
+
29
+ **Recheck when:** Baseten publishes a first-party balance, credits, budget, or billing-usage API accessible with the inference credential or a documented monitoring credential.
30
+
31
+ ## Acceptance criteria for a new provider
32
+
33
+ A provider is suitable when a documented first-party API or response header supplies at least one meaningful account-level value:
34
+
35
+ - quota consumed or remaining, ideally with a reset time;
36
+ - account balance or credits; or
37
+ - spend for a defined billing period.
38
+
39
+ Authentication must work through Pi's provider credential API. The extension must not import browser cookies, scrape console pages, estimate account-wide usage from local traffic, or send credentials to third-party services.
package/docs/releasing.md CHANGED
File without changes
File without changes
@@ -506,7 +506,14 @@ export default function (pi: ExtensionAPI): void {
506
506
  const resolved = await ctx.modelRegistry.getProviderAuth(providerId);
507
507
  if (provider === "claude" && resolved?.source !== "OAuth") return {};
508
508
  const token = resolved?.auth.apiKey;
509
- return token ? { token } : { error: "configured authentication did not resolve a token" };
509
+ if (token) return { token };
510
+ // Some OAuth flows (e.g. kimi-coding) expose the token only as a Bearer
511
+ // Authorization header rather than as apiKey.
512
+ const authorization = resolved?.auth.headers?.Authorization ?? resolved?.auth.headers?.authorization;
513
+ if (typeof authorization === "string" && authorization.startsWith("Bearer ")) {
514
+ return { token: authorization.slice("Bearer ".length) };
515
+ }
516
+ return { error: "configured authentication did not resolve a token" };
510
517
  } catch (error) {
511
518
  return { error: error instanceof Error ? error.message : String(error) };
512
519
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hk_net/pi-usage-bars",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Quota, balance, and spend indicators for current Pi providers",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -51,8 +51,8 @@
51
51
  "@earendil-works/pi-tui": ">=0.81.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@earendil-works/pi-coding-agent": "0.84.1",
55
- "@earendil-works/pi-tui": "0.84.1",
54
+ "@earendil-works/pi-coding-agent": "0.84.2",
55
+ "@earendil-works/pi-tui": "0.84.2",
56
56
  "@types/bun": "1.3.14",
57
57
  "@types/node": "24.13.3",
58
58
  "typescript": "5.9.3"