@monotykamary/pi-better-openai 0.2.3 → 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 +40 -3
- 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
|
@@ -45,6 +45,31 @@ export const DEFAULT_SUPPORTED_MODELS = [
|
|
|
45
45
|
"openai-codex/gpt-5.5",
|
|
46
46
|
] as const;
|
|
47
47
|
|
|
48
|
+
// Earlier versions seeded config files with an explicit copy of the then-current
|
|
49
|
+
// default list. Treat those exact snapshots as unset so later additions to
|
|
50
|
+
// DEFAULT_SUPPORTED_MODELS (such as gpt-6-astra) reach existing installs.
|
|
51
|
+
const LEGACY_SEEDED_SUPPORTED_MODELS: readonly (readonly string[])[] = [
|
|
52
|
+
["openai/gpt-5.4", "openai/gpt-5.5", "openai-codex/gpt-5.4", "openai-codex/gpt-5.5"],
|
|
53
|
+
[
|
|
54
|
+
"openai/gpt-5.4",
|
|
55
|
+
"openai/gpt-5.5",
|
|
56
|
+
"openai/gpt-5.6-sol",
|
|
57
|
+
"openai/gpt-5.6-terra",
|
|
58
|
+
"openai/gpt-5.6-luna",
|
|
59
|
+
"openai-codex/gpt-5.4",
|
|
60
|
+
"openai-codex/gpt-5.5",
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"openai/gpt-5.4",
|
|
64
|
+
"openai/gpt-5.5",
|
|
65
|
+
"openai-codex/gpt-5.6-sol",
|
|
66
|
+
"openai-codex/gpt-5.6-terra",
|
|
67
|
+
"openai-codex/gpt-5.6-luna",
|
|
68
|
+
"openai-codex/gpt-5.4",
|
|
69
|
+
"openai-codex/gpt-5.5",
|
|
70
|
+
],
|
|
71
|
+
];
|
|
72
|
+
|
|
48
73
|
export type FooterMode = (typeof FOOTER_MODES)[number];
|
|
49
74
|
export type ImageSaveMode = (typeof IMAGE_SAVE_MODES)[number];
|
|
50
75
|
export type ImageOutputFormat = (typeof IMAGE_OUTPUT_FORMATS)[number];
|
|
@@ -194,11 +219,12 @@ export const DEFAULT_PET_CONFIG: Required<PetConfig> = {
|
|
|
194
219
|
};
|
|
195
220
|
|
|
196
221
|
export const DEFAULT_CONFIG: ConfigFile = {
|
|
222
|
+
// supportedModels is intentionally omitted so generated config files never pin
|
|
223
|
+
// the default list; resolution falls back to DEFAULT_SUPPORTED_MODELS live.
|
|
197
224
|
persistState: true,
|
|
198
225
|
notifyOnModelSwitch: true,
|
|
199
226
|
active: false,
|
|
200
227
|
desiredActive: false,
|
|
201
|
-
supportedModels: [...DEFAULT_SUPPORTED_MODELS],
|
|
202
228
|
usage: DEFAULT_USAGE_CONFIG,
|
|
203
229
|
footer: DEFAULT_FOOTER_CONFIG,
|
|
204
230
|
image: DEFAULT_IMAGE_CONFIG,
|
|
@@ -331,7 +357,7 @@ export const USAGE_SETTING_DESCRIPTORS: readonly SettingsOptionDescriptor[] = [
|
|
|
331
357
|
label: "Auto-redeem banked resets",
|
|
332
358
|
currentValue: (cfg) => String(cfg.usage.autoRedeemBankedResets),
|
|
333
359
|
values: ["true", "false"],
|
|
334
|
-
description: "Redeem one unused banked reset
|
|
360
|
+
description: "Redeem one unused banked reset 1 minute before expiry while pi is running.",
|
|
335
361
|
parse: booleanSetting,
|
|
336
362
|
},
|
|
337
363
|
];
|
|
@@ -631,6 +657,14 @@ export function parseModels(value: unknown): SupportedModel[] | undefined {
|
|
|
631
657
|
.filter((entry): entry is SupportedModel => entry !== undefined);
|
|
632
658
|
}
|
|
633
659
|
|
|
660
|
+
function isLegacySeededSupportedModels(models: readonly SupportedModel[]): boolean {
|
|
661
|
+
return LEGACY_SEEDED_SUPPORTED_MODELS.some((snapshot) => {
|
|
662
|
+
if (snapshot.length !== models.length) return false;
|
|
663
|
+
const remaining = new Set(snapshot);
|
|
664
|
+
return models.every((model) => remaining.delete(`${model.provider}/${model.id}`));
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
|
|
634
668
|
export function readRawConfig(path: string): Record<string, unknown> {
|
|
635
669
|
if (!existsSync(path)) return {};
|
|
636
670
|
try {
|
|
@@ -823,6 +857,7 @@ export function resolveConfig(cwd: string): ResolvedConfig {
|
|
|
823
857
|
const merged = { ...DEFAULT_CONFIG, ...globalConfig, ...projectConfig };
|
|
824
858
|
const selectedPath = projectConfigExists ? paths.project : paths.global;
|
|
825
859
|
const desiredActive = merged.desiredActive ?? merged.active ?? false;
|
|
860
|
+
const configuredSupportedModels = parseModels(merged.supportedModels);
|
|
826
861
|
|
|
827
862
|
return {
|
|
828
863
|
configPath: selectedPath,
|
|
@@ -835,7 +870,9 @@ export function resolveConfig(cwd: string): ResolvedConfig {
|
|
|
835
870
|
active: merged.active ?? desiredActive,
|
|
836
871
|
desiredActive,
|
|
837
872
|
supportedModels:
|
|
838
|
-
|
|
873
|
+
configuredSupportedModels && !isLegacySeededSupportedModels(configuredSupportedModels)
|
|
874
|
+
? configuredSupportedModels
|
|
875
|
+
: (parseModels(DEFAULT_SUPPORTED_MODELS) ?? []),
|
|
839
876
|
usage: {
|
|
840
877
|
...DEFAULT_USAGE_CONFIG,
|
|
841
878
|
...globalConfig.usage,
|
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
|
|