@ravshansbox/pi-quota 0.10.3 → 0.10.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/index.ts +15 -13
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -196,7 +196,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
196
196
|
let anthropicPingTimer: ReturnType<typeof setTimeout> | null = null;
|
|
197
197
|
let ctxRef: ExtensionContext | null = null;
|
|
198
198
|
let codexRedeemAttempted = false;
|
|
199
|
-
let
|
|
199
|
+
let cycle: Promise<void> | null = null;
|
|
200
200
|
|
|
201
201
|
function notifyRefreshOnce(provider: string, message: string) {
|
|
202
202
|
if (refreshNotified.has(provider)) return;
|
|
@@ -617,17 +617,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
async function runCycle(includeAnthropic: boolean) {
|
|
620
|
-
if (
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
620
|
+
if (cycle) return;
|
|
621
|
+
cycle = (async () => {
|
|
622
|
+
try {
|
|
623
|
+
await pollQuotaStatus(includeAnthropic);
|
|
624
|
+
await tryAutoRedeemCodexReset();
|
|
625
|
+
updateStatus();
|
|
626
|
+
} catch (error) {
|
|
627
|
+
await logError('Run cycle error:', error);
|
|
628
|
+
} finally {
|
|
629
|
+
cycle = null;
|
|
630
|
+
}
|
|
631
|
+
})();
|
|
632
|
+
await cycle;
|
|
631
633
|
}
|
|
632
634
|
|
|
633
635
|
function scheduleCheck() {
|
|
@@ -654,7 +656,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
654
656
|
ctxRef = ctx;
|
|
655
657
|
codexRedeemAttempted = false;
|
|
656
658
|
|
|
657
|
-
void runCycle(true);
|
|
659
|
+
void (cycle ?? Promise.resolve()).then(() => runCycle(true));
|
|
658
660
|
scheduleCheck();
|
|
659
661
|
});
|
|
660
662
|
|