pi-claude-billing-router 0.1.2 → 0.1.3
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/lib/usage-status.ts +10 -4
- package/package.json +1 -1
package/lib/usage-status.ts
CHANGED
|
@@ -264,8 +264,14 @@ interface ProviderState extends StatusSnapshot {
|
|
|
264
264
|
retryTimer: ReturnType<typeof setTimeout> | undefined;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
declare global {
|
|
268
|
+
// Hosts such as ThinkRail run many Pi sessions in one process; they share one poll per provider.
|
|
269
|
+
var __pcbrUsageStates: Map<UsageProvider, ProviderState> | undefined;
|
|
270
|
+
}
|
|
271
|
+
|
|
267
272
|
export default function usageStatus(pi: ExtensionAPI) {
|
|
268
|
-
|
|
273
|
+
globalThis.__pcbrUsageStates ??= new Map<UsageProvider, ProviderState>();
|
|
274
|
+
const states = globalThis.__pcbrUsageStates;
|
|
269
275
|
let currentCtx: StatusCtx | undefined;
|
|
270
276
|
let idleTimer: ReturnType<typeof setInterval> | undefined;
|
|
271
277
|
|
|
@@ -429,16 +435,16 @@ export default function usageStatus(pi: ExtensionAPI) {
|
|
|
429
435
|
pi.on("session_start", async (_event, ctx) => {
|
|
430
436
|
warnOnConflict(ctx as unknown as StatusCtx);
|
|
431
437
|
if (!ctx.hasUI) return;
|
|
432
|
-
await refresh(ctx as unknown as StatusCtx
|
|
438
|
+
await refresh(ctx as unknown as StatusCtx);
|
|
433
439
|
if (idleTimer) clearInterval(idleTimer);
|
|
434
440
|
idleTimer = setInterval(() => {
|
|
435
|
-
if (currentCtx) void refresh(currentCtx
|
|
441
|
+
if (currentCtx) void refresh(currentCtx);
|
|
436
442
|
}, IDLE_REFRESH_MS);
|
|
437
443
|
idleTimer.unref?.();
|
|
438
444
|
});
|
|
439
445
|
|
|
440
446
|
pi.on("model_select", async (event, ctx) => {
|
|
441
|
-
await refresh({ ...ctx, model: event.model } as unknown as StatusCtx
|
|
447
|
+
await refresh({ ...ctx, model: event.model } as unknown as StatusCtx);
|
|
442
448
|
});
|
|
443
449
|
|
|
444
450
|
pi.on("after_provider_response", async (event, ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-claude-billing-router",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Route Claude Pro/Max OAuth requests in pi between your plan and extra-usage credits: plan first, automatic fallback to credits when the 5h window is exhausted, /billing override, live usage in the footer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|