@monotykamary/pi-better-openai 0.2.4 → 0.2.5
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/package.json +1 -1
- package/src/config.ts +1 -1
- package/src/resets.ts +5 -1
package/README.md
CHANGED
|
@@ -51,9 +51,9 @@ Usage display, image generation, and live voice require pi's `openai-codex` OAut
|
|
|
51
51
|
|
|
52
52
|
## Banked resets
|
|
53
53
|
|
|
54
|
-
Unused banked Codex resets **auto-redeem by default,
|
|
54
|
+
Unused banked Codex resets **auto-redeem by default, 1 minute before expiry**, while an interactive pi session is running and Codex credentials are available. Starting pi within that final one-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 one minute) beside its expiry. Disable **Auto-redeem banked resets** in `/openai-settings` or set `usage.autoRedeemBankedResets` to `false` to opt out.
|
|
55
55
|
|
|
56
|
-
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
|
|
56
|
+
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 one minute across pi sessions sharing the same agent directory; manual redemption uses the same guard. Automatic reservations recheck the one-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 one-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.
|
|
57
57
|
|
|
58
58
|
Pi must remain running and awake; this is not an OS-level scheduled task. No eligible usage window or unavailable credentials can prevent redemption.
|
|
59
59
|
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -357,7 +357,7 @@ export const USAGE_SETTING_DESCRIPTORS: readonly SettingsOptionDescriptor[] = [
|
|
|
357
357
|
label: "Auto-redeem banked resets",
|
|
358
358
|
currentValue: (cfg) => String(cfg.usage.autoRedeemBankedResets),
|
|
359
359
|
values: ["true", "false"],
|
|
360
|
-
description: "Redeem one unused banked reset
|
|
360
|
+
description: "Redeem one unused banked reset 1 minute before expiry while pi is running.",
|
|
361
361
|
parse: booleanSetting,
|
|
362
362
|
},
|
|
363
363
|
];
|
package/src/resets.ts
CHANGED
|
@@ -7,7 +7,11 @@ 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
|
-
|
|
10
|
+
// Auto-redeem fires in the final minute before expiry. The automatic flow
|
|
11
|
+
// (credentials, a fresh credit re-check, reservation, and consume POST) shares
|
|
12
|
+
// one 10s abort deadline, so a 60s lead still leaves the server tens of seconds
|
|
13
|
+
// of headroom while spending the credit as late as safely possible.
|
|
14
|
+
export const BANKED_RESET_AUTO_REDEEM_LEAD_MS = 60_000;
|
|
11
15
|
|
|
12
16
|
export type BankedResetStatus = "available" | "redeeming" | "redeemed" | "unknown";
|
|
13
17
|
|