@monotykamary/pi-better-openai 0.2.10 → 0.2.11
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 +6 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/config.ts +1 -1
- package/src/reset-controller.ts +5 -3
- package/src/resets.ts +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.11
|
|
4
|
+
|
|
5
|
+
- Auto-redeem banked Codex resets ten minutes before expiry instead of one minute, with matching settings and redemption-time displays.
|
|
6
|
+
- Preserve the scheduled credit across polling refreshes so the longer lead retains the no-fallback safeguard.
|
|
7
|
+
- Extend the shared redemption cooldown to ten minutes and add regression coverage for exact timing and startup inside the redemption window.
|
|
8
|
+
|
|
3
9
|
## 0.2.10
|
|
4
10
|
|
|
5
11
|
- Hide disabled image, web search, and decision tools and their prompt guidance, including from pi-fabric capture.
|
package/README.md
CHANGED
|
@@ -54,9 +54,9 @@ Usage display, image generation, and live voice require pi's `openai-codex` OAut
|
|
|
54
54
|
|
|
55
55
|
## Banked resets
|
|
56
56
|
|
|
57
|
-
Unused banked Codex resets **auto-redeem by default,
|
|
57
|
+
Unused banked Codex resets **auto-redeem by default, 10 minutes before expiry**, while an interactive pi session is running and Codex credentials are available. Starting pi within that final ten-minute window also triggers the check; expired credits are skipped. This runs independently of the usage display and current model. The reset picker and confirmation show each credit's actual local auto-redemption date and time (expiry minus ten minutes) beside its expiry. Disable **Auto-redeem banked resets** in `/openai-settings` or set `usage.autoRedeemBankedResets` to `false` to opt out.
|
|
58
58
|
|
|
59
|
-
For safety, each attempt targets one explicit, freshly checked credit ID, with no fallback to another credit and no automatic retry after a consume request (including errors or `nothing_to_reset`). A persistent per-account guard permits at most one redemption attempt in
|
|
59
|
+
For safety, each attempt targets one explicit, freshly checked credit ID, with no fallback to another credit and no automatic retry after a consume request (including errors or `nothing_to_reset`). A persistent per-account guard permits at most one redemption attempt in ten minutes across pi sessions sharing the same agent directory; manual redemption uses the same guard. Automatic reservations recheck the ten-minute eligibility window while holding an exclusive filesystem lock, and attempted credit IDs remain blocked even after later redemptions or restarts. Simultaneously expiring credits are not drained, and later credits wait for their own final ten-minute window. Reservations live under `$PI_CODING_AGENT_DIR/pi-better-openai/reset-redemptions` (default `~/.pi/agent/pi-better-openai/reset-redemptions`); unreadable state or an orphaned lock blocks redemption rather than risking a duplicate. Update/restart all pi instances to use the current guard. Separate machines/agent directories cannot coordinate this local guard; instances using the same account should share an agent directory.
|
|
60
60
|
|
|
61
61
|
Pi must remain running and awake; this is not an OS-level scheduled task. No eligible usage window or unavailable credentials can prevent redemption.
|
|
62
62
|
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -410,7 +410,7 @@ export const USAGE_SETTING_DESCRIPTORS: readonly SettingsOptionDescriptor[] = [
|
|
|
410
410
|
label: "Auto-redeem banked resets",
|
|
411
411
|
currentValue: (cfg) => String(cfg.usage.autoRedeemBankedResets),
|
|
412
412
|
values: ["true", "false"],
|
|
413
|
-
description: "Redeem one unused banked reset
|
|
413
|
+
description: "Redeem one unused banked reset 10 minutes before expiry while pi is running.",
|
|
414
414
|
parse: booleanSetting,
|
|
415
415
|
},
|
|
416
416
|
];
|
package/src/reset-controller.ts
CHANGED
|
@@ -159,7 +159,7 @@ export class ResetController {
|
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
private scheduleAutoRedeem(): void {
|
|
162
|
+
private scheduleAutoRedeem(scheduled?: BankedResetCredit): void {
|
|
163
163
|
const ctx = this.activeCtx;
|
|
164
164
|
if (!ctx || this.redeeming) return;
|
|
165
165
|
try {
|
|
@@ -170,7 +170,7 @@ export class ResetController {
|
|
|
170
170
|
// A cache refresh must not replace a due timer with the next credit,
|
|
171
171
|
// particularly when the scheduled one was redeemed in another client.
|
|
172
172
|
if (this.autoTimer) return;
|
|
173
|
-
const credit = selectAutoRedeemCredit(this.cache?.credits.credits ?? []);
|
|
173
|
+
const credit = scheduled ?? selectAutoRedeemCredit(this.cache?.credits.credits ?? []);
|
|
174
174
|
if (!credit || credit.expiresAtMs === null) return;
|
|
175
175
|
const dueAt = Math.max(
|
|
176
176
|
credit.expiresAtMs - BANKED_RESET_AUTO_REDEEM_LEAD_MS,
|
|
@@ -179,7 +179,9 @@ export class ResetController {
|
|
|
179
179
|
this.autoTimer = setTimeout(
|
|
180
180
|
() => {
|
|
181
181
|
this.autoTimer = undefined;
|
|
182
|
-
|
|
182
|
+
// Preserve the exact credit across capped timer wakeups, even when
|
|
183
|
+
// a polling refresh has changed the cached credit list.
|
|
184
|
+
if (Date.now() < dueAt) this.scheduleAutoRedeem(credit);
|
|
183
185
|
else void this.autoRedeem(ctx, credit);
|
|
184
186
|
},
|
|
185
187
|
Math.max(0, Math.min(dueAt - Date.now(), BANKED_RESET_CACHE_TTL_MS)),
|
package/src/resets.ts
CHANGED
|
@@ -7,11 +7,10 @@ export const RESET_CREDITS_URL = "https://chatgpt.com/backend-api/wham/rate-limi
|
|
|
7
7
|
export const CONSUME_RESET_URL =
|
|
8
8
|
"https://chatgpt.com/backend-api/wham/rate-limit-reset-credits/consume";
|
|
9
9
|
|
|
10
|
-
// Auto-redeem fires
|
|
11
|
-
// (credentials, a fresh credit re-check,
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
export const BANKED_RESET_AUTO_REDEEM_LEAD_MS = 60_000;
|
|
10
|
+
// Auto-redeem fires ten minutes before expiry to leave more headroom than a
|
|
11
|
+
// last-minute attempt. The automatic flow (credentials, a fresh credit re-check,
|
|
12
|
+
// reservation, and consume POST) still shares one 10s abort deadline.
|
|
13
|
+
export const BANKED_RESET_AUTO_REDEEM_LEAD_MS = 10 * 60_000;
|
|
15
14
|
|
|
16
15
|
export type BankedResetStatus = "available" | "redeeming" | "redeemed" | "unknown";
|
|
17
16
|
|