@llblab/pi-kit 0.27.0 → 0.27.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/BACKLOG.md +3 -1
- package/CHANGELOG.md +4 -0
- package/README.md +3 -3
- package/node_modules/@llblab/pi-claude-usage/AGENTS.md +1 -1
- package/node_modules/@llblab/pi-claude-usage/CHANGELOG.md +4 -0
- package/node_modules/@llblab/pi-claude-usage/README.md +3 -1
- package/node_modules/@llblab/pi-claude-usage/lib/status.ts +3 -8
- package/node_modules/@llblab/pi-claude-usage/lib/telegram.ts +15 -1
- package/node_modules/@llblab/pi-claude-usage/package.json +1 -1
- package/node_modules/@llblab/pi-codex-usage/AGENTS.md +1 -1
- package/node_modules/@llblab/pi-codex-usage/CHANGELOG.md +4 -0
- package/node_modules/@llblab/pi-codex-usage/README.md +2 -2
- package/node_modules/@llblab/pi-codex-usage/lib/status.ts +3 -11
- package/node_modules/@llblab/pi-codex-usage/lib/telegram.ts +15 -0
- package/node_modules/@llblab/pi-codex-usage/package.json +1 -1
- package/package.json +3 -3
package/BACKLOG.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Backlog
|
|
2
2
|
|
|
3
|
-
The 0.27.
|
|
3
|
+
The 0.27.1 composition is recorded in [CHANGELOG.md](./CHANGELOG.md). Package pins, resource order and bundled runtime ownership remain authoritative in `package.json`.
|
|
4
4
|
|
|
5
5
|
## Carried checks
|
|
6
6
|
|
|
7
|
+
- **Installed 0.27.1 Fast status smoke (operator-owned):** After separately authorized installation/reload, check Telegram menu Fast on/off and model switching for Codex and Claude Opus; unsupported Claude families must not show Fast. Use disposable settings and mocked quota where possible; do not mutate live stores or reconnect Telegram without separate authorization.
|
|
8
|
+
|
|
7
9
|
- **Installed 0.27.0 smoke (operator-owned):** After separately authorized installation/reload, check the exact released kit's terminal controls and optional Telegram rendering with disposable State Flow storage. Packed SDK validation does not certify the operator's running clients. Do not reconnect Telegram, change Pi settings or use live memory/usage/Recipe stores as fixtures without separate authorization.
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@llblab/pi-kit` are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.27.1: Telegram Fast Status
|
|
6
|
+
|
|
7
|
+
- `Telegram Fast Status`: Advances Codex Usage to `0.12.1` and Claude Usage to `0.2.1`. Their Telegram rows now show the active model's Fast preference alongside quota, or alone when quota is unavailable, and reread it at menu render time. Claude retains Opus-only eligibility. Other pins, resource order and quota coordination are unchanged.
|
|
8
|
+
|
|
5
9
|
## 0.27.0: Intent-Owned State Flow Memory
|
|
6
10
|
|
|
7
11
|
- `Intent-Owned Memory`: Advances the exact State Flow pin to published `0.25.0`. Deleting an intent removes the same-scope `working`/`lazy` keys it owns through structured `$ref`, so agents that work from intents keep memory self-cleaning. `/state-flow-status` shows per-scope plane sizes and intent-owned shares; lifecycle internals were consolidated without behaviour changes.
|
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ Package links lead to the owning repositories for usage, documentation, issues,
|
|
|
13
13
|
| Package | Version | Purpose |
|
|
14
14
|
| --- | ---: | --- |
|
|
15
15
|
| [`@llblab/pi-actors`](https://github.com/llblab/pi-actors) | `0.54.0` | Inspectable local Runs, reusable Recipes, persistent tools, and delegation Skills |
|
|
16
|
-
| [`@llblab/pi-claude-usage`](https://github.com/llblab/pi-claude-usage) | `0.2.
|
|
16
|
+
| [`@llblab/pi-claude-usage`](https://github.com/llblab/pi-claude-usage) | `0.2.1` | Claude subscription quota status and shared per-model Fast toggle for Opus, mirrored in Telegram |
|
|
17
17
|
| [`@llblab/pi-clean-room`](https://github.com/llblab/pi-clean-room) | `0.3.0` | Isolated nested Pi TUI with named npm extensions and compatible model selection |
|
|
18
|
-
| [`@llblab/pi-codex-usage`](https://github.com/llblab/pi-codex-usage) | `0.12.
|
|
18
|
+
| [`@llblab/pi-codex-usage`](https://github.com/llblab/pi-codex-usage) | `0.12.1` | Shared Codex quota/Business credit status and persistent priority Fast toggle, mirrored in Telegram |
|
|
19
19
|
| [`@llblab/pi-grow-loop`](https://github.com/llblab/pi-grow-loop) | `0.9.0` | Visible continuation scheduling and bounded worker Skills through compiled, manifest-owned resources |
|
|
20
20
|
| [`@llblab/pi-state-flow`](https://github.com/llblab/pi-state-flow) | `0.25.0` | Scoped context/memory compiler with intent-owned self-cleaning memory, memory-inert Off and ownership status |
|
|
21
21
|
| [`@llblab/pi-telegram`](https://github.com/llblab/pi-telegram) | `0.51.6` | Telegram companion with connection resume, Workspace slot recovery, follower Threads, filterable Skills, files, voice, and controls |
|
|
@@ -45,7 +45,7 @@ Prefer the kit instead of separately loading the same packages. If you already u
|
|
|
45
45
|
|
|
46
46
|
## Development
|
|
47
47
|
|
|
48
|
-
The `0.27.
|
|
48
|
+
The `0.27.1` composition includes published Codex Usage `0.12.1` and Claude Usage `0.2.1` with Telegram Fast status, alongside State Flow `0.25.0`, Telegram `0.51.6` and the Pi 1.0 cohort. The packed bundle loads all seven extensions on Pi 1.0.0 with no credentials or external requests. This does not certify installed-client rendering; carried checks remain in [Backlog](./BACKLOG.md).
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
npm install
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
- `Pi baseline`: Every declared `@earendil-works/*` peer requires ≥1.0.0. Keep Pi peer lock identities aligned and validate against that host generation.
|
|
5
5
|
- `Statusline-first scope`: Own usage state + usage mode; keep quota reporting zero-configuration and optional Fast on the existing terminal status.
|
|
6
6
|
- Trigger: Considering commands, menus, persisted settings, or notification output.
|
|
7
|
-
- Action: Prefer deleting the surface unless it is required for the optimistic TUI status widget, optional `pi-telegram` `/start` status-line mirror, or the argument-free shared `/fast`. Register only the `anthropic` provider handler through `@llblab/pi-command-fast` on session_start; release on session_shutdown. Never register the command directly or gate it on quota auth. Claude Fast eligibility is consumer-owned: permit the `claude-opus-` family without a version allowlist; warn `Fast mode is supported only for Opus` for other families without writes. Family eligibility is not proof of backend support; preserve server capability/billing errors. For rejected models, ignore stale unsupported overrides in status/request adaptation, and leave Codex eligibility unchanged. The library owns session WeakMap/reload arbitration and generic JSONC; `lib/fast.ts` owns Claude semantics; require Pi ≥1.0.0 for its assembled-beta payload contract, rather than copying upstream beta defaults. ON is `speed: "fast"` in the current model override; OFF deletes the property. Preserve existing request speed/betas, append the required Fast beta to the native assembled list rather than replacing a header, and keep Fast out of quota state
|
|
7
|
+
- Action: Prefer deleting the surface unless it is required for the optimistic TUI status widget, optional `pi-telegram` `/start` status-line mirror, or the argument-free shared `/fast`. Register only the `anthropic` provider handler through `@llblab/pi-command-fast` on session_start; release on session_shutdown. Never register the command directly or gate it on quota auth. Claude Fast eligibility is consumer-owned: permit the `claude-opus-` family without a version allowlist; warn `Fast mode is supported only for Opus` for other families without writes. Family eligibility is not proof of backend support; preserve server capability/billing errors. For rejected models, ignore stale unsupported overrides in status/request adaptation, and leave Codex eligibility unchanged. The library owns session WeakMap/reload arbitration and generic JSONC; `lib/fast.ts` owns Claude semantics; require Pi ≥1.0.0 for its assembled-beta payload contract, rather than copying upstream beta defaults. ON is `speed: "fast"` in the current model override; OFF deletes the property. Preserve existing request speed/betas, append the required Fast beta to the native assembled list rather than replacing a header, and keep Fast out of quota state. The optional Telegram row reads the active model's eligible Fast preference at render time and appends plain-text ` fast` (or shows `fast` alone without quota). Toggle redraws through the final terminal boundary without a quota request or success notification; unreadable config fails closed for Fast only.
|
|
8
8
|
- `Domain boundaries`: `index.ts` is export-only; `lib/extension.ts` composes lifecycle/Fast registration and request hooks. `lib/status.ts` owns refresh orchestration and terminal timers; `usage-store.ts` owns claims/fencing/mutex, `query.ts` owns OAuth/HTTP, `usage.ts` owns quota normalization, `status-format.ts` owns presentation, and `telegram.ts` owns optional registration. Preserve mature quota/auth/leadership behavior, keep imports acyclic with no domain importing the entrypoint, and keep domain-focused tests in `tests/`. Do not merge usage extensions or redesign polling to add Fast.
|
|
9
9
|
- `Optimistic refresh`: Preserve the last good statusline bar during refresh and transient failures.
|
|
10
10
|
- Trigger: Updating quota polling or error handling.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1: Telegram Fast Status
|
|
4
|
+
|
|
5
|
+
- The optional Telegram status row now appends lowercase ` fast` for the active eligible Opus model, or shows `fast` alone when quota is unavailable. It rereads the per-model preference at menu render time, so toggles and model changes do not wait for quota refresh. Unsupported Claude families ignore stale Fast overrides. Quota polling, auth, request adaptation and terminal behavior are unchanged; isolated tests cover eligibility, model/provider changes and unreadable configuration.
|
|
6
|
+
|
|
3
7
|
## 0.2.0: Shared Fast Mode and Pi 1.0 Baseline
|
|
4
8
|
|
|
5
9
|
- Split the monolithic extension into cohesive `lib/` domains matching Codex Usage: composition, status lifecycle, shared state, OAuth query, quota normalization, formatting, Telegram and Fast. `index.ts` now only re-exports the unchanged public API; tests follow domain owners. Quota/auth/leadership, mutex/fencing/backoff, status redraw and Fast behavior are preserved.
|
|
@@ -78,7 +78,7 @@ When Claude Usage and Codex Usage are loaded together, their shared library regi
|
|
|
78
78
|
claude ██████▀▀▀▀ 6d fast
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
Exactly lowercase ` fast` uses the existing dim/countdown role at the final terminal presentation boundary, including loading, single-window percentages, `n/a` and errors. Telegram
|
|
81
|
+
Exactly lowercase ` fast` uses the existing dim/countdown role at the final terminal presentation boundary, including loading, single-window percentages, `n/a` and errors. Telegram also appends plain-text ` fast` for the active eligible model; quota OAuth, polling, mutex, fencing and backoff are unchanged.
|
|
82
82
|
|
|
83
83
|
Native request adaptation adds `speed: "fast"` without overwriting an explicit speed. It adds `fast-mode-2026-02-01` to Pi's already-assembled request `betas`, preserving automatic OAuth/thinking/streaming and configured betas; the Anthropic SDK converts that list to the final `anthropic-beta` HTTP header. Setting a replacement header earlier would suppress Pi's automatic betas, so no header replacement or custom provider/transport is used. See [Anthropic Fast mode](https://platform.claude.com/docs/en/build-with-claude/fast-mode).
|
|
84
84
|
|
|
@@ -144,6 +144,8 @@ If `@llblab/pi-telegram` is loaded with the public status-line provider API, thi
|
|
|
144
144
|
claude: ██████▀▀▀▀ 6d
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
+
When Fast is enabled for the active Opus model, the row appends plain-text ` fast`; without a usable quota report it shows `claude: fast`. The preference is reread when the menu is rendered, so toggles and model changes do not depend on a quota refresh. Unsupported Claude families never show Fast, even with stale overrides.
|
|
148
|
+
|
|
147
149
|
If `pi-telegram` is absent or older, or the active model is not Anthropic, no Telegram row is added.
|
|
148
150
|
|
|
149
151
|
## Auth
|
|
@@ -4,9 +4,9 @@ import { type ExtensionAPI, type ExtensionContext, getAgentDir } from "@earendil
|
|
|
4
4
|
import { isFastEnabled } from "./fast.ts";
|
|
5
5
|
import { claimRefresh, isRefreshDue, nextRefreshAt, ownsRefreshClaim, publishRefresh, readState, MIN_ATTEMPT_GAP_MS, type SharedState } from "./usage-store.ts";
|
|
6
6
|
import { isAnthropicModel, type ClaudeUsageModel, type ClaudeUsageReport } from "./usage.ts";
|
|
7
|
-
import { DUAL_BAR_WIDTH,
|
|
7
|
+
import { DUAL_BAR_WIDTH, formatClaudeUsageBar, formatClaudeUsageStatusline, formatStatuslineLoading, formatStatuslineProblem, nextResetCountdownDelayMs } from "./status-format.ts";
|
|
8
8
|
import { queryUsage } from "./query.ts";
|
|
9
|
-
import { registerClaudeUsageTelegramStatusLine } from "./telegram.ts";
|
|
9
|
+
import { claudeUsageTelegramStatusLine, registerClaudeUsageTelegramStatusLine } from "./telegram.ts";
|
|
10
10
|
|
|
11
11
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
12
12
|
const SECOND_MS = 1000;
|
|
@@ -57,12 +57,7 @@ export function createClaudeUsageStatus(pi: ExtensionAPI) {
|
|
|
57
57
|
const ensureTelegramStatusLineRegistered = () => {
|
|
58
58
|
if (unregisterTelegramStatusLine || telegramStatusLineRegistration) return;
|
|
59
59
|
telegramStatusLineRegistration = registerClaudeUsageTelegramStatusLine(
|
|
60
|
-
({ activeModel }) =>
|
|
61
|
-
if (!isAnthropicModel(activeModel)) return undefined;
|
|
62
|
-
if (!shown.report) return undefined;
|
|
63
|
-
const value = formatClaudeUsageStatusValue(shown.report);
|
|
64
|
-
return value ? { label: STATUS_LABEL_TEXT, value } : undefined;
|
|
65
|
-
},
|
|
60
|
+
({ activeModel }) => claudeUsageTelegramStatusLine(shown.report, activeModel),
|
|
66
61
|
)
|
|
67
62
|
.then((unregister) => {
|
|
68
63
|
unregisterTelegramStatusLine = unregister;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Domain: Telegram status. Owns: optional status-provider discovery and registration. Excludes: quota state and terminal decoration. */
|
|
2
|
-
import
|
|
2
|
+
import { isFastEnabled } from "./fast.ts";
|
|
3
|
+
import { isAnthropicModel, type ClaudeUsageModel, type ClaudeUsageReport } from "./usage.ts";
|
|
4
|
+
import { formatClaudeUsageStatusValue, STATUS_LABEL_TEXT } from "./status-format.ts";
|
|
3
5
|
const CLAUDE_USAGE_EXTENSION_ID = "@llblab/pi-claude-usage";
|
|
4
6
|
const TELEGRAM_STATUS_IMPORT_SPECIFIERS = [
|
|
5
7
|
"@llblab/pi-telegram/status",
|
|
@@ -18,6 +20,18 @@ type TelegramStatusLineModule = {
|
|
|
18
20
|
) => () => void;
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
/** Read the selected model's preference at menu render time, not from the terminal cache. */
|
|
24
|
+
export function claudeUsageTelegramStatusLine(
|
|
25
|
+
report: ClaudeUsageReport | undefined,
|
|
26
|
+
activeModel: ClaudeUsageModel | undefined,
|
|
27
|
+
): TelegramStatusLineProviderResult {
|
|
28
|
+
if (!activeModel || !isAnthropicModel(activeModel)) return undefined;
|
|
29
|
+
const value = report ? formatClaudeUsageStatusValue(report) : undefined;
|
|
30
|
+
const fast = isFastEnabled(activeModel.id);
|
|
31
|
+
if (!value && !fast) return undefined;
|
|
32
|
+
return { label: STATUS_LABEL_TEXT, value: value ? `${value}${fast ? " fast" : ""}` : "fast" };
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
async function importTelegramStatusLineModule(): Promise<
|
|
22
36
|
TelegramStatusLineModule | undefined
|
|
23
37
|
> {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
- `Domain DAG`: `index.ts` only re-exports the extension and public contracts; `lib/extension.ts` composes the Pi extension. `lib/usage-store.ts` owns persistence/leadership, `lib/query.ts` owns quota I/O, `lib/usage.ts` owns normalized reports, `lib/status.ts` and `lib/status-format.ts` own local UI orchestration and formatting, `lib/telegram.ts` owns optional registration, and `lib/fast.ts` owns Codex Fast semantics/request adaptation. `@llblab/pi-command-fast` owns command arbitration and generic JSONC override editing. Keep dependency direction acyclic; do not import `index.ts` from `lib/` or mix Fast persistence into quota coordination. Place domain tests in `tests/<domain>.test.ts` (or a domain-prefixed focused integration test); use independent names such as `invariants.test.ts` only for cross-domain invariants.
|
|
6
6
|
- `Statusline-first scope`: Own usage state + usage mode: keep quota reporting zero-configuration and the optional Fast toggle focused on the existing terminal status.
|
|
7
7
|
- Trigger: Considering new commands, menus, persisted settings, or notification output.
|
|
8
|
-
- Action: Prefer deleting the surface unless it is required for the optimistic TUI status widget, the optional `pi-telegram` `/start` status-line mirror, or the existing argument-free `/fast` command. Register the `openai-codex` provider handler through `registerFastProvider` on session_start and release on session_shutdown; never register `/fast` directly or filter Fast by model ID/auth. Fast persists solely as `serviceTier: "priority"` in the current model override; OFF deletes only that property. Preserve JSONC/unrelated settings, existing wire tiers, and usage refresh/Telegram. Apply lowercase ` fast` through the final terminal boundary;
|
|
8
|
+
- Action: Prefer deleting the surface unless it is required for the optimistic TUI status widget, the optional `pi-telegram` `/start` status-line mirror, or the existing argument-free `/fast` command. Register the `openai-codex` provider handler through `registerFastProvider` on session_start and release on session_shutdown; never register `/fast` directly or filter Fast by model ID/auth. Fast persists solely as `serviceTier: "priority"` in the current model override; OFF deletes only that property. Preserve JSONC/unrelated settings, existing wire tiers, and usage refresh/Telegram. Apply lowercase ` fast` through the final terminal boundary; the optional Telegram row reads the active model's Fast preference at render time and appends plain-text ` fast` (or shows `fast` alone without quota). Toggle redraws without quota fetch or success notification. The library owns session WeakMap/reload arbitration, not Fast state. A Fast config read failure must not block usage status.
|
|
9
9
|
- `Optimistic refresh`: Preserve the last good statusline bar during refresh and transient failures.
|
|
10
10
|
- Trigger: Updating quota polling or error handling.
|
|
11
11
|
- Action: Do not collapse the bar while a request is in flight; only show `n/a` or `error` after repeated failures or no usable quota.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.1: Telegram Fast Status
|
|
4
|
+
|
|
5
|
+
- The optional Telegram status row now appends lowercase ` fast` for the active Codex model, or shows `fast` alone when quota is unavailable. It rereads the per-model preference at menu render time, so toggles, model changes and manual edits do not wait for quota refresh. Quota polling, auth, request adaptation and terminal behavior are unchanged; isolated tests cover enabled/disabled state, model/provider changes and unreadable configuration.
|
|
6
|
+
|
|
3
7
|
## 0.12.0: Shared Fast Mode and Pi 1.0 Baseline
|
|
4
8
|
|
|
5
9
|
- Requires Pi ≥1.0.0 across the coding-agent, AI and agent-core peers; previous hosts are outside this release's compatibility contract.
|
|
@@ -83,7 +83,7 @@ Enabled native requests receive `service_tier: "priority"` only when the payload
|
|
|
83
83
|
codex ██████▀▀▀▀ 6d fast
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
The lowercase ` fast` suffix uses the existing dim/countdown theme role and is applied at the final terminal boundary, including loading, percentages/credits, `n/a`, and errors. Telegram
|
|
86
|
+
The lowercase ` fast` suffix uses the existing dim/countdown theme role and is applied at the final terminal boundary, including loading, percentages/credits, `n/a`, and errors. Telegram also appends plain-text ` fast` for the active model; quota polling/auth/leadership are unchanged.
|
|
87
87
|
|
|
88
88
|
Pi 1.0.0 accepts the extra override but does not propagate it to native request options, so a small `before_provider_request` adapter remains necessary; no replacement provider or transport is registered. Its public command API cannot hide/unregister commands by current model, so `/fast` stays listed and checks the provider at invocation. Backend capability and actual priority service are not guaranteed by a stored preference or suffix: an earlier authorized sample sent `priority` but received `default`. Priority service may have different provider pricing.
|
|
89
89
|
|
|
@@ -161,7 +161,7 @@ If `@llblab/pi-telegram` is loaded with the public status-line provider API, thi
|
|
|
161
161
|
codex: ██████▀▀▀▀ 6d
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
The value is the same compact quota bar plus weekly reset countdown used by the terminal statusline, always with the `codex` label. If `pi-telegram` is absent, older, or the active model is not a Codex subscription model, no Telegram row is added.
|
|
164
|
+
The value is the same compact quota bar plus weekly reset countdown used by the terminal statusline, always with the `codex` label. When Fast is enabled for the active model, it appends plain-text ` fast`; without a usable quota report it shows `codex: fast`. The preference is reread when the menu is rendered, so toggles and model changes do not depend on a quota refresh. If `pi-telegram` is absent, older, or the active model is not a Codex subscription model, no Telegram row is added.
|
|
165
165
|
|
|
166
166
|
## Auth
|
|
167
167
|
|
|
@@ -4,11 +4,10 @@ import { type ExtensionAPI, type ExtensionContext, getAgentDir } from "@earendil
|
|
|
4
4
|
import { isFastEnabled, isFastEligibleModel } from "./fast.ts";
|
|
5
5
|
import { claimRefresh, isRefreshDue, nextRefreshAt, ownsRefreshClaim, publishRefresh, readState, type SharedState, MIN_ATTEMPT_GAP_MS } from "./usage-store.ts";
|
|
6
6
|
import { canReuseCachedReport, isFullyAvailableReport, isOpenAICodexModel, isUsageUnavailable, type CodexUsageModel, type CodexUsageReport } from "./usage.ts";
|
|
7
|
-
import { appendFastStatus, formatReportBar, formatStatuslineLoading, formatStatuslineProblem,
|
|
7
|
+
import { appendFastStatus, formatReportBar, formatStatuslineLoading, formatStatuslineProblem, formatCodexUsageStatusline, nextResetCountdownDelayMs } from "./status-format.ts";
|
|
8
8
|
import { queryUsage, type QueryUsageResult } from "./query.ts";
|
|
9
|
-
import { registerCodexUsageTelegramStatusLine } from "./telegram.ts";
|
|
9
|
+
import { codexUsageTelegramStatusLine, registerCodexUsageTelegramStatusLine } from "./telegram.ts";
|
|
10
10
|
|
|
11
|
-
const DEFAULT_STATUS_LABEL_TEXT = "codex";
|
|
12
11
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
13
12
|
const SECOND_MS = 1000;
|
|
14
13
|
const MINUTE_MS = 60 * SECOND_MS;
|
|
@@ -64,14 +63,7 @@ export function createCodexUsageStatus(pi: ExtensionAPI) {
|
|
|
64
63
|
const ensureTelegramStatusLineRegistered = () => {
|
|
65
64
|
if (unregisterTelegramStatusLine || telegramStatusLineRegistration) return;
|
|
66
65
|
telegramStatusLineRegistration = registerCodexUsageTelegramStatusLine(
|
|
67
|
-
({ activeModel }) =>
|
|
68
|
-
if (!isOpenAICodexModel(activeModel)) return undefined;
|
|
69
|
-
if (!shown.report) return undefined;
|
|
70
|
-
const value = formatCodexUsageStatusValue(shown.report, activeModel);
|
|
71
|
-
return value
|
|
72
|
-
? { label: DEFAULT_STATUS_LABEL_TEXT, value }
|
|
73
|
-
: undefined;
|
|
74
|
-
},
|
|
66
|
+
({ activeModel }) => codexUsageTelegramStatusLine(shown.report, activeModel),
|
|
75
67
|
)
|
|
76
68
|
.then((unregister) => {
|
|
77
69
|
unregisterTelegramStatusLine = unregister;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** Domain: Telegram adapter. Owns: optional provider registration. Excludes: quota state and terminal formatting. */
|
|
2
2
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { isFastEnabled } from "./fast.ts";
|
|
4
|
+
import { isOpenAICodexModel, type CodexUsageReport } from "./usage.ts";
|
|
5
|
+
import { formatCodexUsageStatusValue } from "./status-format.ts";
|
|
3
6
|
const CODEX_USAGE_EXTENSION_ID = "@llblab/pi-codex-usage";
|
|
4
7
|
const TELEGRAM_STATUS_IMPORT_SPECIFIERS = [
|
|
5
8
|
"@llblab/pi-telegram/status",
|
|
@@ -19,6 +22,18 @@ type TelegramStatusLineModule = {
|
|
|
19
22
|
) => () => void;
|
|
20
23
|
};
|
|
21
24
|
|
|
25
|
+
/** Read the selected model's preference at menu render time, not from the terminal cache. */
|
|
26
|
+
export function codexUsageTelegramStatusLine(
|
|
27
|
+
report: CodexUsageReport | undefined,
|
|
28
|
+
activeModel: CodexUsageTelegramStatusModel | undefined,
|
|
29
|
+
): TelegramStatusLineProviderResult {
|
|
30
|
+
if (!activeModel || !isOpenAICodexModel(activeModel)) return undefined;
|
|
31
|
+
const value = report ? formatCodexUsageStatusValue(report, activeModel) : undefined;
|
|
32
|
+
const fast = isFastEnabled(activeModel.id);
|
|
33
|
+
if (!value && !fast) return undefined;
|
|
34
|
+
return { label: "codex", value: value ? `${value}${fast ? " fast" : ""}` : "fast" };
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
async function importTelegramStatusLineModule(): Promise<
|
|
23
38
|
TelegramStatusLineModule | undefined
|
|
24
39
|
> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-kit",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@llblab/pi-actors": "0.54.0",
|
|
45
|
-
"@llblab/pi-claude-usage": "0.2.
|
|
45
|
+
"@llblab/pi-claude-usage": "0.2.1",
|
|
46
46
|
"@llblab/pi-clean-room": "0.3.0",
|
|
47
|
-
"@llblab/pi-codex-usage": "0.12.
|
|
47
|
+
"@llblab/pi-codex-usage": "0.12.1",
|
|
48
48
|
"@llblab/pi-grow-loop": "0.9.0",
|
|
49
49
|
"@llblab/pi-state-flow": "0.25.0",
|
|
50
50
|
"@llblab/pi-telegram": "0.51.6",
|