@ravshansbox/pi-quota 0.6.0 → 0.7.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/README.md +2 -2
- package/index.ts +5 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,11 +12,11 @@ Add `-l` to install it in project settings.
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
Pi loads the extension from `./index.ts` and shows the remaining quota for the provider backing the active model
|
|
15
|
+
Pi loads the extension from `./index.ts` and shows the remaining quota for the provider backing the active model in the footer.
|
|
16
16
|
|
|
17
17
|
- Calls the Anthropic usage endpoint once on session start, then reads the Anthropic quota from the rate limit headers of each Anthropic response
|
|
18
18
|
- Polls the OpenAI Codex usage endpoint on session start, then at every 10-minute wall-clock mark (`HH:00`, `HH:10`, `HH:20`, `HH:30`, `HH:40`, `HH:50`)
|
|
19
|
-
- Shows a
|
|
19
|
+
- Shows a footer status for the provider backing the **active model**, and only when quota data for that provider has been polled; switching models re-renders it immediately
|
|
20
20
|
- The text stays compact, e.g. `93% 1h29m · 67% 3d13h`, where the 5-hour window comes first and the 7-day window second, and each window shows its remaining percentage followed by time until reset
|
|
21
21
|
- Available resets, when present, are appended as `· 2x 5h` (count, then time until the soonest expires)
|
|
22
22
|
- Both providers are checked on session start whenever their credentials exist, so quota is already known when the active model changes
|
package/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
type ExtensionAPI,
|
|
7
7
|
type ExtensionContext,
|
|
8
8
|
} from '@earendil-works/pi-coding-agent';
|
|
9
|
-
import { Text } from '@earendil-works/pi-tui';
|
|
10
9
|
|
|
11
10
|
interface QuotaConfig {
|
|
12
11
|
codexResets?: { autoRedeem?: boolean };
|
|
@@ -69,7 +68,7 @@ type CodexResetConsumeResponse = { code?: string };
|
|
|
69
68
|
|
|
70
69
|
const modelProviderNames: Record<QuotaState['provider'], string> = {
|
|
71
70
|
anthropic: 'anthropic',
|
|
72
|
-
'openai-codex': 'openai',
|
|
71
|
+
'openai-codex': 'openai-codex',
|
|
73
72
|
};
|
|
74
73
|
|
|
75
74
|
const requestTimeoutMs = 30_000;
|
|
@@ -235,9 +234,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
235
234
|
const text = buildStatusText();
|
|
236
235
|
const line = text === undefined ? undefined : ctxRef.ui.theme.fg('muted', text);
|
|
237
236
|
|
|
238
|
-
ctxRef.ui.
|
|
239
|
-
placement: 'belowEditor',
|
|
240
|
-
});
|
|
237
|
+
ctxRef.ui.setStatus('pi-quota', line);
|
|
241
238
|
}
|
|
242
239
|
|
|
243
240
|
function windowResetDetected(
|
|
@@ -626,10 +623,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
626
623
|
function scheduleCheck() {
|
|
627
624
|
const next = nextMarkAfter(new Date());
|
|
628
625
|
const delay = Math.max(0, next.getTime() - Date.now());
|
|
629
|
-
|
|
626
|
+
const timer = setTimeout(async () => {
|
|
630
627
|
await runCycle(false);
|
|
631
|
-
scheduleCheck();
|
|
628
|
+
if (checkTimer === timer) scheduleCheck();
|
|
632
629
|
}, delay);
|
|
630
|
+
checkTimer = timer;
|
|
633
631
|
}
|
|
634
632
|
|
|
635
633
|
function stopTimers() {
|