@wengine-ai/ccr-provider-codex 1.0.12 → 1.0.13
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/dist/card.js +199 -7
- package/dist/plugin.js +303 -9
- package/dist/plugin.json +1 -1
- package/package.json +1 -1
package/dist/card.js
CHANGED
|
@@ -37,6 +37,10 @@ function parseCodexStatus(value) {
|
|
|
37
37
|
const coolingUntil = finiteNumber(value.coolingUntil);
|
|
38
38
|
if (coolingUntil !== null) next.coolingUntil = coolingUntil;
|
|
39
39
|
if (typeof value.lastError === "string") next.lastError = value.lastError;
|
|
40
|
+
if (typeof value.lastErrorCode === "string" && value.lastErrorCode) {
|
|
41
|
+
const code = sanitizeCodexErrorCode(value.lastErrorCode);
|
|
42
|
+
if (code) next.lastErrorCode = code;
|
|
43
|
+
}
|
|
40
44
|
return next;
|
|
41
45
|
}
|
|
42
46
|
function parseCodexLoginStart(value) {
|
|
@@ -94,6 +98,37 @@ function parseCodexMutation(value) {
|
|
|
94
98
|
if (modelCount !== null) next.modelCount = modelCount;
|
|
95
99
|
return next;
|
|
96
100
|
}
|
|
101
|
+
function parseCodexResetCredits(value) {
|
|
102
|
+
if (!isRecord(value)) return null;
|
|
103
|
+
const availableCount = finiteNumber(value.availableCount);
|
|
104
|
+
if (availableCount === null || availableCount < 0 || !Number.isInteger(availableCount)) return null;
|
|
105
|
+
const credits = [];
|
|
106
|
+
if (Array.isArray(value.credits)) {
|
|
107
|
+
if (value.credits.length > 256) return null;
|
|
108
|
+
for (const raw of value.credits) {
|
|
109
|
+
if (!isRecord(raw)) return null;
|
|
110
|
+
const id = typeof raw.id === "string" && raw.id.length > 0 && raw.id.length <= 256 ? raw.id : null;
|
|
111
|
+
const status = typeof raw.status === "string" && raw.status.length > 0 && raw.status.length <= 32 ? raw.status : null;
|
|
112
|
+
if (!id || !status) return null;
|
|
113
|
+
const expiresAt = finiteNumber(raw.expiresAt);
|
|
114
|
+
const title = typeof raw.title === "string" && raw.title.trim() ? raw.title.trim().slice(0, 200) : void 0;
|
|
115
|
+
credits.push({ id, status, ...expiresAt !== null && expiresAt > 0 ? { expiresAt } : {}, ...title ? { title } : {} });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return { credits, availableCount };
|
|
119
|
+
}
|
|
120
|
+
function parseCodexResetConsume(value) {
|
|
121
|
+
if (!isRecord(value)) return null;
|
|
122
|
+
const outcome = value.outcome;
|
|
123
|
+
if (outcome !== "reset" && outcome !== "nothing_to_reset" && outcome !== "no_credit" && outcome !== "already_redeemed") return null;
|
|
124
|
+
const windowsReset = finiteNumber(value.windowsReset);
|
|
125
|
+
const availableCount = finiteNumber(value.availableCount);
|
|
126
|
+
return {
|
|
127
|
+
outcome,
|
|
128
|
+
windowsReset: windowsReset !== null && windowsReset >= 0 ? Math.floor(windowsReset) : 0,
|
|
129
|
+
...availableCount !== null && availableCount >= 0 ? { availableCount: Math.floor(availableCount) } : {}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
97
132
|
function sanitizeCodexErrorCode(value) {
|
|
98
133
|
if (typeof value !== "string") return null;
|
|
99
134
|
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(value)) return null;
|
|
@@ -293,6 +328,16 @@ var codexLocales = {
|
|
|
293
328
|
usage_plan: "Plan: {{plan}}",
|
|
294
329
|
usage_unavailable: "Quota information is not available right now.",
|
|
295
330
|
usage_updated: "Updated {{time}}",
|
|
331
|
+
reset_available: "Usage resets: {{count}} available",
|
|
332
|
+
reset_expires: "next expires {{time}}",
|
|
333
|
+
reset_button: "Reset usage limits",
|
|
334
|
+
reset_title: "Use a usage reset?",
|
|
335
|
+
reset_warning: "This spends one gifted reset ({{count}} available) and immediately restores your usage limits. This cannot be undone.",
|
|
336
|
+
reset_confirm: "Use reset",
|
|
337
|
+
reset_done: "Usage limits reset. {{count}} resets remaining.",
|
|
338
|
+
reset_already: "This reset was already used. {{count}} resets remaining.",
|
|
339
|
+
reset_none_left: "No usage resets are available.",
|
|
340
|
+
reset_nothing: "Nothing to reset \u2014 your usage limits are already fresh.",
|
|
296
341
|
window: {
|
|
297
342
|
minutes: "{{count}} min",
|
|
298
343
|
hours: "{{count}} h",
|
|
@@ -315,7 +360,18 @@ var codexLocales = {
|
|
|
315
360
|
restore_failed: "Restoring the model failed.",
|
|
316
361
|
callback_invalid: "That does not look like a valid callback URL (expected code and state parameters).",
|
|
317
362
|
callback_rejected: "The callback was rejected. Please copy the full address and try again.",
|
|
318
|
-
reconciliation_failed: "Applied, but the local settings draft could not be refreshed \u2014 reload the page to see the change."
|
|
363
|
+
reconciliation_failed: "Applied, but the local settings draft could not be refreshed \u2014 reload the page to see the change.",
|
|
364
|
+
codex_usage_limit: "This account has reached its Codex usage limit \u2014 the window resets automatically; the card recovers on the next request.",
|
|
365
|
+
codex_rate_limited: "Codex is rate limiting this account temporarily.",
|
|
366
|
+
codex_overloaded: "Codex upstream is temporarily unavailable.",
|
|
367
|
+
codex_request_rejected: "Codex rejected the request.",
|
|
368
|
+
codex_upstream_error: "Codex upstream request failed.",
|
|
369
|
+
reset_failed: "The usage reset failed. Please try again.",
|
|
370
|
+
codex_reset_busy: "A usage reset is already running \u2014 wait for it to finish.",
|
|
371
|
+
codex_reset_no_credit: "No usage resets are available.",
|
|
372
|
+
codex_reset_unavailable: "The reset service is unavailable right now. Please try again.",
|
|
373
|
+
codex_reset_invalid: "The reset request was invalid.",
|
|
374
|
+
codex_reauth_required: "The sign-in has expired. Reconnect to refresh the authorization."
|
|
319
375
|
}
|
|
320
376
|
}
|
|
321
377
|
},
|
|
@@ -379,6 +435,16 @@ var codexLocales = {
|
|
|
379
435
|
usage_plan: "\u5957\u9910\uFF1A{{plan}}",
|
|
380
436
|
usage_unavailable: "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u914D\u989D\u4FE1\u606F\u3002",
|
|
381
437
|
usage_updated: "\u66F4\u65B0\u4E8E {{time}}",
|
|
438
|
+
reset_available: "\u7528\u91CF\u91CD\u7F6E\uFF1A\u5269\u4F59 {{count}} \u6B21",
|
|
439
|
+
reset_expires: "\u6700\u8FD1\u5230\u671F {{time}}",
|
|
440
|
+
reset_button: "\u91CD\u7F6E\u7528\u91CF\u9650\u989D",
|
|
441
|
+
reset_title: "\u4F7F\u7528\u4E00\u6B21\u7528\u91CF\u91CD\u7F6E\uFF1F",
|
|
442
|
+
reset_warning: "\u5C06\u6D88\u8017\u4E00\u6B21\u8D60\u9001\u7684\u91CD\u7F6E\u673A\u4F1A\uFF08\u5269\u4F59 {{count}} \u6B21\uFF09\uFF0C\u7ACB\u5373\u6062\u590D\u7528\u91CF\u9650\u989D\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",
|
|
443
|
+
reset_confirm: "\u4F7F\u7528\u91CD\u7F6E",
|
|
444
|
+
reset_done: "\u7528\u91CF\u9650\u989D\u5DF2\u91CD\u7F6E\u3002\u5269\u4F59 {{count}} \u6B21\u3002",
|
|
445
|
+
reset_already: "\u8BE5\u91CD\u7F6E\u673A\u4F1A\u5DF2\u88AB\u4F7F\u7528\u3002\u5269\u4F59 {{count}} \u6B21\u3002",
|
|
446
|
+
reset_none_left: "\u6CA1\u6709\u53EF\u7528\u7684\u7528\u91CF\u91CD\u7F6E\u673A\u4F1A\u3002",
|
|
447
|
+
reset_nothing: "\u65E0\u9700\u91CD\u7F6E\u2014\u2014\u5F53\u524D\u7528\u91CF\u9650\u989D\u5C1A\u672A\u7528\u5C3D\u3002",
|
|
382
448
|
window: {
|
|
383
449
|
minutes: "{{count}} \u5206\u949F",
|
|
384
450
|
hours: "{{count}} \u5C0F\u65F6",
|
|
@@ -401,7 +467,18 @@ var codexLocales = {
|
|
|
401
467
|
restore_failed: "\u6062\u590D\u6A21\u578B\u5931\u8D25\u3002",
|
|
402
468
|
callback_invalid: "\u8FD9\u770B\u8D77\u6765\u4E0D\u662F\u6709\u6548\u7684\u56DE\u8C03\u5730\u5740\uFF08\u5E94\u5305\u542B code \u4E0E state \u53C2\u6570\uFF09\u3002",
|
|
403
469
|
callback_rejected: "\u56DE\u8C03\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u590D\u5236\u5B8C\u6574\u5730\u5740\u540E\u91CD\u8BD5\u3002",
|
|
404
|
-
reconciliation_failed: "\u5DF2\u751F\u6548\uFF0C\u4F46\u672C\u5730\u8BBE\u7F6E\u8349\u7A3F\u672A\u80FD\u5237\u65B0\u2014\u2014\u5237\u65B0\u9875\u9762\u5373\u53EF\u770B\u5230\u53D8\u66F4\u3002"
|
|
470
|
+
reconciliation_failed: "\u5DF2\u751F\u6548\uFF0C\u4F46\u672C\u5730\u8BBE\u7F6E\u8349\u7A3F\u672A\u80FD\u5237\u65B0\u2014\u2014\u5237\u65B0\u9875\u9762\u5373\u53EF\u770B\u5230\u53D8\u66F4\u3002",
|
|
471
|
+
codex_usage_limit: "\u8D26\u53F7\u5DF2\u8FBE\u5230 Codex \u7528\u91CF\u4E0A\u9650\u2014\u2014\u7A97\u53E3\u4F1A\u81EA\u52A8\u91CD\u7F6E\uFF0C\u4E0B\u4E00\u6B21\u8BF7\u6C42\u6062\u590D\u663E\u793A\u3002",
|
|
472
|
+
codex_rate_limited: "Codex \u6B63\u5728\u4E34\u65F6\u9650\u6D41\u8BE5\u8D26\u53F7\u3002",
|
|
473
|
+
codex_overloaded: "Codex \u4E0A\u6E38\u6682\u65F6\u4E0D\u53EF\u7528\u3002",
|
|
474
|
+
codex_request_rejected: "Codex \u62D2\u7EDD\u4E86\u8BE5\u8BF7\u6C42\u3002",
|
|
475
|
+
codex_upstream_error: "Codex \u4E0A\u6E38\u8BF7\u6C42\u5931\u8D25\u3002",
|
|
476
|
+
reset_failed: "\u7528\u91CF\u91CD\u7F6E\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
477
|
+
codex_reset_busy: "\u5DF2\u6709\u7528\u91CF\u91CD\u7F6E\u6B63\u5728\u8FDB\u884C\u2014\u2014\u8BF7\u7B49\u5F85\u5B8C\u6210\u3002",
|
|
478
|
+
codex_reset_no_credit: "\u6CA1\u6709\u53EF\u7528\u7684\u7528\u91CF\u91CD\u7F6E\u673A\u4F1A\u3002",
|
|
479
|
+
codex_reset_unavailable: "\u91CD\u7F6E\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
480
|
+
codex_reset_invalid: "\u91CD\u7F6E\u8BF7\u6C42\u65E0\u6548\u3002",
|
|
481
|
+
codex_reauth_required: "\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5\u4EE5\u5237\u65B0\u6388\u6743\u3002"
|
|
405
482
|
}
|
|
406
483
|
}
|
|
407
484
|
}
|
|
@@ -584,6 +661,9 @@ function mount(el, props) {
|
|
|
584
661
|
let toast = null;
|
|
585
662
|
let reconcileFailed = false;
|
|
586
663
|
let confirmDisconnect = false;
|
|
664
|
+
let confirmReset = false;
|
|
665
|
+
let resetCredits = null;
|
|
666
|
+
let resetPhase = "idle";
|
|
587
667
|
let login = null;
|
|
588
668
|
let cancelling = false;
|
|
589
669
|
let pasteField = null;
|
|
@@ -744,6 +824,28 @@ function mount(el, props) {
|
|
|
744
824
|
const id = generation;
|
|
745
825
|
await readUsage(id, true);
|
|
746
826
|
};
|
|
827
|
+
const readResetCredits = async (id) => {
|
|
828
|
+
resetPhase = "reading";
|
|
829
|
+
try {
|
|
830
|
+
const raw = await props.callApi("/reset-credits", { timeoutMs: 1e4 });
|
|
831
|
+
const parsed = parseCodexResetCredits(raw);
|
|
832
|
+
if (alive && generation === id) {
|
|
833
|
+
resetCredits = parsed;
|
|
834
|
+
resetPhase = parsed ? "ready" : "unavailable";
|
|
835
|
+
}
|
|
836
|
+
} catch {
|
|
837
|
+
if (alive && generation === id) {
|
|
838
|
+
resetCredits = null;
|
|
839
|
+
resetPhase = "unavailable";
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (alive) render();
|
|
843
|
+
};
|
|
844
|
+
const oldestResetCredit = () => {
|
|
845
|
+
const available = (resetCredits?.credits ?? []).filter((c) => c.status === "available");
|
|
846
|
+
if (!available.length) return null;
|
|
847
|
+
return available.slice().sort((a, b) => (a.expiresAt ?? Infinity) - (b.expiresAt ?? Infinity))[0];
|
|
848
|
+
};
|
|
747
849
|
const run = async (kind, argument) => {
|
|
748
850
|
if (!alive || locked || loading || props.disabled) return;
|
|
749
851
|
if (kind === "usage") {
|
|
@@ -771,6 +873,35 @@ function mount(el, props) {
|
|
|
771
873
|
reconcileFailed = false;
|
|
772
874
|
render();
|
|
773
875
|
try {
|
|
876
|
+
if (kind === "reset") {
|
|
877
|
+
const creditId = argument || void 0;
|
|
878
|
+
const result = parseCodexResetConsume(await post("/reset-credits/consume", creditId ? { creditId } : {}, void 0, 6e4));
|
|
879
|
+
if (!alive || generation !== id) return;
|
|
880
|
+
confirmReset = false;
|
|
881
|
+
if (!result) {
|
|
882
|
+
errorKey = "reset_failed";
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
if (result.outcome === "reset" || result.outcome === "already_redeemed") {
|
|
886
|
+
clearCodexUsageCache();
|
|
887
|
+
usage = null;
|
|
888
|
+
usageUpdatedAt = null;
|
|
889
|
+
usagePhase = "idle";
|
|
890
|
+
resetPhase = "idle";
|
|
891
|
+
void readResetCredits(generation);
|
|
892
|
+
void readUsage(generation, true);
|
|
893
|
+
toast = t(result.outcome === "reset" ? "reset_done" : "reset_already", {
|
|
894
|
+
count: String(result.availableCount ?? resetCredits?.availableCount ?? 0)
|
|
895
|
+
});
|
|
896
|
+
} else if (result.outcome === "no_credit") {
|
|
897
|
+
resetCredits = { credits: [], availableCount: 0 };
|
|
898
|
+
resetPhase = "ready";
|
|
899
|
+
toast = t("reset_none_left");
|
|
900
|
+
} else {
|
|
901
|
+
toast = t("reset_nothing");
|
|
902
|
+
}
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
774
905
|
if (kind === "login") {
|
|
775
906
|
const current = createCodexLogin({
|
|
776
907
|
start: () => post("/login/start", {}),
|
|
@@ -808,6 +939,9 @@ function mount(el, props) {
|
|
|
808
939
|
usage = null;
|
|
809
940
|
usageUpdatedAt = null;
|
|
810
941
|
usagePhase = "idle";
|
|
942
|
+
resetCredits = null;
|
|
943
|
+
resetPhase = "idle";
|
|
944
|
+
confirmReset = false;
|
|
811
945
|
const { fresh, reconcileFailed: failed } = await settle(id);
|
|
812
946
|
if (!alive || generation !== id) return;
|
|
813
947
|
reconcileFailed = failed;
|
|
@@ -854,18 +988,21 @@ function mount(el, props) {
|
|
|
854
988
|
return;
|
|
855
989
|
}
|
|
856
990
|
clearCodexUsageCache();
|
|
857
|
-
const {
|
|
991
|
+
const { reconcileFailed: failed } = await settle(id);
|
|
858
992
|
if (!alive || generation !== id) return;
|
|
859
993
|
reconcileFailed = failed;
|
|
860
994
|
usage = null;
|
|
861
995
|
usagePhase = "idle";
|
|
862
996
|
usageUpdatedAt = null;
|
|
997
|
+
resetCredits = null;
|
|
998
|
+
resetPhase = "idle";
|
|
999
|
+
confirmReset = false;
|
|
863
1000
|
toast = t("disconnected");
|
|
864
1001
|
}
|
|
865
1002
|
} catch (error) {
|
|
866
1003
|
if (alive && generation === id) {
|
|
867
1004
|
const reason = error?.reason;
|
|
868
|
-
errorKey = sanitizeCodexErrorCode(typeof reason === "string" ? reason : null) ?? (kind === "login" ? "login_failed" : kind === "sync" ? "sync_failed" : kind === "hide" ? "hide_failed" : kind === "restore" ? "restore_failed" : "disconnect_failed");
|
|
1005
|
+
errorKey = sanitizeCodexErrorCode(typeof reason === "string" ? reason : null) ?? (kind === "login" ? "login_failed" : kind === "sync" ? "sync_failed" : kind === "hide" ? "hide_failed" : kind === "restore" ? "restore_failed" : kind === "reset" ? "reset_failed" : "disconnect_failed");
|
|
869
1006
|
}
|
|
870
1007
|
} finally {
|
|
871
1008
|
endBusy();
|
|
@@ -957,7 +1094,7 @@ function mount(el, props) {
|
|
|
957
1094
|
t("managed_provider", { name: status?.providerName || CODEX_PROVIDER_NAME })
|
|
958
1095
|
));
|
|
959
1096
|
body.append(styled("p", "max-w-md text-xs text-muted-foreground", t("description")));
|
|
960
|
-
const showAccountSurface = !loading && !!status && (connected || state === "cooldown");
|
|
1097
|
+
const showAccountSurface = !loading && !!status && (connected || state === "cooldown" || state === "error");
|
|
961
1098
|
if (showAccountSurface && status) {
|
|
962
1099
|
const rows = styled("dl", "grid max-w-md grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs");
|
|
963
1100
|
const account = maskCodexAccountId(status.accountId) ?? t("unknown");
|
|
@@ -1026,12 +1163,34 @@ function mount(el, props) {
|
|
|
1026
1163
|
} else if (usagePhase === "unavailable") {
|
|
1027
1164
|
usageBox.append(styled("p", "text-[11px] text-muted-foreground", t("usage_unavailable")));
|
|
1028
1165
|
}
|
|
1166
|
+
if (resetPhase === "ready" && resetCredits) {
|
|
1167
|
+
const row = styled("div", "flex flex-wrap items-center justify-between gap-2 border-t border-white/5 pt-1.5");
|
|
1168
|
+
const target = oldestResetCredit();
|
|
1169
|
+
const remaining = resetCredits.availableCount;
|
|
1170
|
+
row.append(styled("span", "text-[11px] text-muted-foreground", t("reset_available", { count: String(remaining) })));
|
|
1171
|
+
if (target?.expiresAt) {
|
|
1172
|
+
const expiry = formatCodexClock(target.expiresAt, locale);
|
|
1173
|
+
if (expiry) row.append(styled("span", "text-[10px] text-muted-foreground/60", t("reset_expires", { time: expiry })));
|
|
1174
|
+
}
|
|
1175
|
+
button(
|
|
1176
|
+
row,
|
|
1177
|
+
t("reset_button"),
|
|
1178
|
+
() => {
|
|
1179
|
+
confirmReset = true;
|
|
1180
|
+
render();
|
|
1181
|
+
},
|
|
1182
|
+
disabled || remaining <= 0 || !target,
|
|
1183
|
+
"outline",
|
|
1184
|
+
"h-7 px-2 text-[11px]"
|
|
1185
|
+
);
|
|
1186
|
+
usageBox.append(row);
|
|
1187
|
+
}
|
|
1029
1188
|
body.append(usageBox);
|
|
1030
1189
|
}
|
|
1031
1190
|
const cooldown = status?.coolingUntil !== void 0 && state === "cooldown" ? formatCodexClock(status.coolingUntil, locale) : null;
|
|
1032
1191
|
if (cooldown) body.append(styled("p", "text-xs font-medium text-yellow-600", t("cooldown_until", { time: cooldown })));
|
|
1033
1192
|
if (state === "needs_relogin") body.append(styled("p", "text-xs text-yellow-600", t("needs_relogin_help")));
|
|
1034
|
-
if (!connected && status?.lastError) body.append(errorAlert(errorText(status.lastError)));
|
|
1193
|
+
if (!connected && status?.lastError) body.append(errorAlert(errorText(status.lastErrorCode ?? status.lastError)));
|
|
1035
1194
|
if (errorKey) body.append(errorAlert(errorText(errorKey)));
|
|
1036
1195
|
if (reconcileFailed) body.append(errorAlert(t("errors.reconciliation_failed")));
|
|
1037
1196
|
if (login) {
|
|
@@ -1150,6 +1309,35 @@ function mount(el, props) {
|
|
|
1150
1309
|
panel.append(footer);
|
|
1151
1310
|
el.append(panel);
|
|
1152
1311
|
}
|
|
1312
|
+
if (confirmReset) {
|
|
1313
|
+
const panel = styled("div", "max-w-md space-y-2 rounded-xl border border-primary/30 bg-primary/5 p-4");
|
|
1314
|
+
panel.setAttribute("role", "alertdialog");
|
|
1315
|
+
panel.setAttribute("aria-label", t("reset_title"));
|
|
1316
|
+
const target = oldestResetCredit();
|
|
1317
|
+
panel.append(
|
|
1318
|
+
styled("h3", "text-sm font-semibold tracking-tight text-foreground", t("reset_title")),
|
|
1319
|
+
styled("p", "text-xs text-muted-foreground", t("reset_warning", { count: String(resetCredits?.availableCount ?? 0) }))
|
|
1320
|
+
);
|
|
1321
|
+
const footer = styled("div", "flex justify-end gap-2");
|
|
1322
|
+
button(footer, t("cancel"), () => {
|
|
1323
|
+
if (!action) {
|
|
1324
|
+
confirmReset = false;
|
|
1325
|
+
render();
|
|
1326
|
+
}
|
|
1327
|
+
}, !!action, "outline", "h-8 text-xs");
|
|
1328
|
+
button(
|
|
1329
|
+
footer,
|
|
1330
|
+
action ? t("working") : t("reset_confirm"),
|
|
1331
|
+
() => {
|
|
1332
|
+
if (confirmReset) void run("reset", target?.id);
|
|
1333
|
+
},
|
|
1334
|
+
loading || action !== null || props.disabled || !target || (resetCredits?.availableCount ?? 0) <= 0,
|
|
1335
|
+
"primary",
|
|
1336
|
+
"h-8 text-xs"
|
|
1337
|
+
);
|
|
1338
|
+
panel.append(footer);
|
|
1339
|
+
el.append(panel);
|
|
1340
|
+
}
|
|
1153
1341
|
};
|
|
1154
1342
|
mounted.set(el, () => {
|
|
1155
1343
|
alive = false;
|
|
@@ -1186,7 +1374,10 @@ function mount(el, props) {
|
|
|
1186
1374
|
loading = false;
|
|
1187
1375
|
render();
|
|
1188
1376
|
const mountState = codexStateKey(status);
|
|
1189
|
-
if (mountState === "connected" || mountState === "cooldown")
|
|
1377
|
+
if (mountState === "connected" || mountState === "cooldown") {
|
|
1378
|
+
void autoReadUsage();
|
|
1379
|
+
void readResetCredits(generation);
|
|
1380
|
+
}
|
|
1190
1381
|
});
|
|
1191
1382
|
};
|
|
1192
1383
|
mountRead(false);
|
|
@@ -1202,3 +1393,4 @@ export {
|
|
|
1202
1393
|
mount,
|
|
1203
1394
|
unmount
|
|
1204
1395
|
};
|
|
1396
|
+
//# sourceMappingURL=card.js.map
|
package/dist/plugin.js
CHANGED
|
@@ -33,7 +33,7 @@ function clearCodexRouterRefs(router, hidden, firstVisible) {
|
|
|
33
33
|
|
|
34
34
|
// src/auth-service.ts
|
|
35
35
|
import { createServer } from "node:http";
|
|
36
|
-
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
36
|
+
import { randomBytes as randomBytes2, randomUUID } from "node:crypto";
|
|
37
37
|
import { promises as fs, constants } from "node:fs";
|
|
38
38
|
import { dirname, join } from "node:path";
|
|
39
39
|
|
|
@@ -50,6 +50,9 @@ var CODEX_REFRESH_SCOPE = "openid profile email";
|
|
|
50
50
|
var CODEX_AUTHORIZE_PATH = "/oauth/authorize";
|
|
51
51
|
var CODEX_TOKEN_PATH = "/oauth/token";
|
|
52
52
|
var CODEX_BACKEND_BASE = "https://chatgpt.com/backend-api/codex";
|
|
53
|
+
var CODEX_CHATGPT_ORIGIN = "https://chatgpt.com";
|
|
54
|
+
var CODEX_RESET_CREDITS_PATH = "/backend-api/wham/rate-limit-reset-credits";
|
|
55
|
+
var CODEX_RESET_CONSUME_PATH = "/backend-api/wham/rate-limit-reset-credits/consume";
|
|
53
56
|
var CODEX_WHAM_USAGE_PATH = "/backend-api/wham/usage";
|
|
54
57
|
var CODEX_DEFAULT_CLIENT_VERSION = "0.160.1";
|
|
55
58
|
var CODEX_UPSTREAM_URL = `${CODEX_BACKEND_BASE}/responses`;
|
|
@@ -150,12 +153,11 @@ function classifyCodexError(status, body, _systemText) {
|
|
|
150
153
|
const resetInSeconds = Number(err?.resets_in_seconds ?? json?.resets_in_seconds);
|
|
151
154
|
const resetInMs = Number.isFinite(resetInSeconds) && resetInSeconds > 0 ? resetInSeconds * 1e3 : void 0;
|
|
152
155
|
const quotaCooldown = () => {
|
|
153
|
-
const
|
|
154
|
-
if (resetMs && resetMs >
|
|
156
|
+
const now = Date.now();
|
|
157
|
+
if (resetMs && resetMs > now) return Math.max(resetMs - now, 6e4);
|
|
155
158
|
if (resetInMs) return Math.max(resetInMs, 6e4);
|
|
156
159
|
return void 0;
|
|
157
160
|
};
|
|
158
|
-
const now = Date.now();
|
|
159
161
|
if (/usage_limit_reached|RESOURCE_EXHAUSTED|limit reached/i.test(errType) || status === 429 && /usage_limit_reached|limit reached/i.test(message)) {
|
|
160
162
|
return {
|
|
161
163
|
code: "codex_usage_limit",
|
|
@@ -397,6 +399,109 @@ function rateLimitsSaturated(limits, now) {
|
|
|
397
399
|
}
|
|
398
400
|
return false;
|
|
399
401
|
}
|
|
402
|
+
var RESET_CREDIT_TITLES = {
|
|
403
|
+
codex_rate_limits: "Full reset"
|
|
404
|
+
};
|
|
405
|
+
function parseResetCredit(raw) {
|
|
406
|
+
if (!raw || typeof raw !== "object") return null;
|
|
407
|
+
if (typeof raw.id !== "string" || !raw.id || raw.id.length > 256) return null;
|
|
408
|
+
if (typeof raw.status !== "string" || !raw.status || raw.status.length > 32) return null;
|
|
409
|
+
const expires = typeof raw.expires_at === "string" && raw.expires_at ? Date.parse(raw.expires_at) : NaN;
|
|
410
|
+
const title = typeof raw.title === "string" && raw.title.trim() ? raw.title.trim().slice(0, 200) : RESET_CREDIT_TITLES[typeof raw.reset_type === "string" ? raw.reset_type : ""];
|
|
411
|
+
const description = typeof raw.description === "string" && raw.description.trim() ? raw.description.trim().slice(0, 300) : void 0;
|
|
412
|
+
return {
|
|
413
|
+
id: raw.id,
|
|
414
|
+
status: raw.status,
|
|
415
|
+
...Number.isFinite(expires) && expires > 0 ? { expiresAt: expires } : {},
|
|
416
|
+
...title ? { title } : {},
|
|
417
|
+
...description ? { description } : {}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function parseCodexResetCredits(raw) {
|
|
421
|
+
if (!raw || typeof raw !== "object") return null;
|
|
422
|
+
const r = raw;
|
|
423
|
+
const availableCount = typeof r.available_count === "number" && Number.isFinite(r.available_count) ? Math.max(0, Math.floor(r.available_count)) : null;
|
|
424
|
+
if (availableCount === null) return null;
|
|
425
|
+
const credits = [];
|
|
426
|
+
if (Array.isArray(r.credits)) {
|
|
427
|
+
if (r.credits.length > 256) return null;
|
|
428
|
+
for (const item of r.credits) {
|
|
429
|
+
const credit = parseResetCredit(item);
|
|
430
|
+
if (!credit) return null;
|
|
431
|
+
credits.push(credit);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return { credits, availableCount };
|
|
435
|
+
}
|
|
436
|
+
function parseResetOutcome(code) {
|
|
437
|
+
switch (code) {
|
|
438
|
+
case "reset":
|
|
439
|
+
return "reset";
|
|
440
|
+
case "nothing_to_reset":
|
|
441
|
+
return "nothing_to_reset";
|
|
442
|
+
case "no_credit":
|
|
443
|
+
return "no_credit";
|
|
444
|
+
case "already_redeemed":
|
|
445
|
+
return "already_redeemed";
|
|
446
|
+
default:
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
async function resetCreditsFetch(params) {
|
|
451
|
+
const res = await params.fetchImpl(params.url, boundedFetchInit({
|
|
452
|
+
method: params.method,
|
|
453
|
+
headers: {
|
|
454
|
+
...codexManagementHeaders(params.accessToken, params.accountId),
|
|
455
|
+
...params.body !== void 0 ? { "Content-Type": "application/json" } : {}
|
|
456
|
+
},
|
|
457
|
+
...params.body !== void 0 ? { body: JSON.stringify(params.body) } : {}
|
|
458
|
+
}));
|
|
459
|
+
const text = await res.text().catch(() => "");
|
|
460
|
+
let json = null;
|
|
461
|
+
try {
|
|
462
|
+
json = text ? JSON.parse(text) : null;
|
|
463
|
+
} catch {
|
|
464
|
+
json = null;
|
|
465
|
+
}
|
|
466
|
+
return { ok: res.ok, status: res.status, json };
|
|
467
|
+
}
|
|
468
|
+
async function fetchCodexResetCredits(params) {
|
|
469
|
+
const origin = params.origin ?? CODEX_CHATGPT_ORIGIN;
|
|
470
|
+
const res = await resetCreditsFetch({
|
|
471
|
+
url: `${origin}${CODEX_RESET_CREDITS_PATH}`,
|
|
472
|
+
method: "GET",
|
|
473
|
+
accessToken: params.accessToken,
|
|
474
|
+
accountId: params.accountId,
|
|
475
|
+
fetchImpl: params.fetchImpl
|
|
476
|
+
});
|
|
477
|
+
if (!res.ok) return null;
|
|
478
|
+
return parseCodexResetCredits(res.json);
|
|
479
|
+
}
|
|
480
|
+
async function consumeCodexResetCredit(params) {
|
|
481
|
+
const origin = params.origin ?? CODEX_CHATGPT_ORIGIN;
|
|
482
|
+
const res = await resetCreditsFetch({
|
|
483
|
+
url: `${origin}${CODEX_RESET_CONSUME_PATH}`,
|
|
484
|
+
method: "POST",
|
|
485
|
+
body: { redeem_request_id: params.redeemRequest, ...params.creditId ? { credit_id: params.creditId } : {} },
|
|
486
|
+
accessToken: params.accessToken,
|
|
487
|
+
accountId: params.accountId,
|
|
488
|
+
fetchImpl: params.fetchImpl
|
|
489
|
+
});
|
|
490
|
+
if (res.status === 401 || res.status === 403) {
|
|
491
|
+
throw codexError({ code: "codex_reauth_required", message: CODEX_SAFE_MESSAGES.codex_reauth_required, httpStatus: 401 });
|
|
492
|
+
}
|
|
493
|
+
const outcome = res.ok && res.json ? parseResetOutcome(res.json.code) : null;
|
|
494
|
+
if (!outcome) {
|
|
495
|
+
throw codexError({
|
|
496
|
+
code: "codex_upstream_error",
|
|
497
|
+
message: `Codex reset consume failed (HTTP ${res.status}).`,
|
|
498
|
+
httpStatus: 502,
|
|
499
|
+
retryable: res.status >= 500 || res.status === 429
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
const windowsReset = typeof res.json.windows_reset === "number" && Number.isFinite(res.json.windows_reset) ? Math.max(0, Math.floor(res.json.windows_reset)) : 0;
|
|
503
|
+
return { outcome, windowsReset };
|
|
504
|
+
}
|
|
400
505
|
function isCodexModelId(value) {
|
|
401
506
|
return typeof value === "string" && value.length > 0 && value.length <= 256 && !/[\x00-\x1f\x7f,]/.test(value);
|
|
402
507
|
}
|
|
@@ -639,6 +744,21 @@ var CodexAuthService = class {
|
|
|
639
744
|
refreshFlight = null;
|
|
640
745
|
forceRefreshRequested = false;
|
|
641
746
|
usageCache = null;
|
|
747
|
+
/** Reset-credit listing cache (same short-TTL shape as usage). */
|
|
748
|
+
resetCache = null;
|
|
749
|
+
/** Single-flight for reset consumption: a queued second consume could
|
|
750
|
+
* redeem a second credit — reject instead. Assigned SYNCHRONOUSLY before
|
|
751
|
+
* any await (no race window). Key = in-flight redeem id. */
|
|
752
|
+
resetFlight = null;
|
|
753
|
+
/** Pending confirmation state: the redeem key survives a transport failure
|
|
754
|
+
* so a user-initiated retry reuses the SAME idempotency key until a
|
|
755
|
+
* terminal outcome (upstream dedupes per key — a lost response therefore
|
|
756
|
+
* cannot double-spend). Cleared on terminal outcomes and disconnect. */
|
|
757
|
+
pendingReset = null;
|
|
758
|
+
/** Locally marked spent credits: written only on a CONFIRMED terminal
|
|
759
|
+
* outcome; prevents re-consumption of a known-spent credit within this
|
|
760
|
+
* service lifetime. Upstream stays authoritative. */
|
|
761
|
+
spentResetCredits = /* @__PURE__ */ new Set();
|
|
642
762
|
get now() {
|
|
643
763
|
return (this.options.now ?? Date.now)();
|
|
644
764
|
}
|
|
@@ -711,8 +831,11 @@ var CodexAuthService = class {
|
|
|
711
831
|
return { status: "not_connected", providerName: CODEX_PROVIDER_NAME2, models, modelCount: models.length, hiddenModels: [] };
|
|
712
832
|
}
|
|
713
833
|
const coolingUntil = this.latestCooldown(data);
|
|
834
|
+
const latch = account.lastError;
|
|
835
|
+
const latchStale = !!latch && latch.code !== "codex_reauth_required" && typeof account.cooldownUntil === "number" && account.cooldownUntil <= now && !(typeof account.rateLimitCooldownUntil === "number" && account.rateLimitCooldownUntil > now);
|
|
714
836
|
let status = "connected";
|
|
715
|
-
|
|
837
|
+
const latchActive = !!latch && !latchStale;
|
|
838
|
+
if (latchActive) status = "error";
|
|
716
839
|
else if (typeof account.accessExp === "number" && account.accessExp <= now) status = "expired";
|
|
717
840
|
return {
|
|
718
841
|
status,
|
|
@@ -724,7 +847,10 @@ var CodexAuthService = class {
|
|
|
724
847
|
modelCount: models.length,
|
|
725
848
|
hiddenModels: [...data?.hiddenModels ?? []],
|
|
726
849
|
...coolingUntil ? { coolingUntil } : {},
|
|
727
|
-
|
|
850
|
+
...latchActive ? {
|
|
851
|
+
lastError: CODEX_SAFE_MESSAGES[latch.code] ?? null,
|
|
852
|
+
...latch.code ? { lastErrorCode: latch.code } : {}
|
|
853
|
+
} : { lastError: null }
|
|
728
854
|
};
|
|
729
855
|
}
|
|
730
856
|
latestCooldown(data) {
|
|
@@ -1265,6 +1391,9 @@ var CodexAuthService = class {
|
|
|
1265
1391
|
this.refreshFlight = null;
|
|
1266
1392
|
this.forceRefreshRequested = false;
|
|
1267
1393
|
this.usageCache = null;
|
|
1394
|
+
this.resetCache = null;
|
|
1395
|
+
this.spentResetCredits.clear();
|
|
1396
|
+
this.pendingReset = null;
|
|
1268
1397
|
const result = { status: "connected", models: registered, modelCount: registered.length };
|
|
1269
1398
|
job.result = result;
|
|
1270
1399
|
this.lastResult.set(job.loginId, result);
|
|
@@ -1418,6 +1547,88 @@ var CodexAuthService = class {
|
|
|
1418
1547
|
this.usageCache = { at: this.now, value: usage };
|
|
1419
1548
|
return usage;
|
|
1420
1549
|
}
|
|
1550
|
+
// ------------------------------------------------------ reset credits -
|
|
1551
|
+
/**
|
|
1552
|
+
* Available gifted usage resets. Null = surface absent/unreadable or the
|
|
1553
|
+
* caller is not connected. Short-TTL cached like usage; locally marked
|
|
1554
|
+
* spent credits are excluded from the visible availability.
|
|
1555
|
+
*/
|
|
1556
|
+
async getResetCredits() {
|
|
1557
|
+
const data = await this.ensureLoaded();
|
|
1558
|
+
if (!data?.account) return null;
|
|
1559
|
+
if (this.resetCache && this.now - this.resetCache.at < USAGE_CACHE_MS) {
|
|
1560
|
+
return this.resetCache.value;
|
|
1561
|
+
}
|
|
1562
|
+
const accessToken = await this.getAccessToken().catch(() => null);
|
|
1563
|
+
if (!accessToken) return null;
|
|
1564
|
+
const fresh = await this.ensureLoaded(true);
|
|
1565
|
+
const listing = await fetchCodexResetCredits({
|
|
1566
|
+
accessToken,
|
|
1567
|
+
accountId: fresh?.account.accountId || void 0,
|
|
1568
|
+
fetchImpl: (url, init) => this.directFetch(url, init)
|
|
1569
|
+
}).catch(() => null);
|
|
1570
|
+
const value = listing && listing.credits.length ? { ...listing, credits: listing.credits.filter((c) => !this.spentResetCredits.has(c.id)) } : listing;
|
|
1571
|
+
this.resetCache = { at: this.now, value };
|
|
1572
|
+
return value;
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Consume ONE gifted reset credit. Explicit user action only — never called
|
|
1576
|
+
* by mount/poll/refresh. Single-flight: a second concurrent consume is
|
|
1577
|
+
* rejected (two queued consumes could redeem two credits). The idempotency
|
|
1578
|
+
* key is minted here at confirmation time and retained across user-initiated
|
|
1579
|
+
* retries of the same confirmation (upstream dedupes on it), so a lost
|
|
1580
|
+
* response cannot double-spend. Outcomes map to the upstream taxonomy;
|
|
1581
|
+
* `reset`/`already_redeemed` clear the usage cache and locally mark the
|
|
1582
|
+
* credit spent, then the caller re-lists for the authoritative count.
|
|
1583
|
+
*/
|
|
1584
|
+
async consumeResetCredit(creditId) {
|
|
1585
|
+
if (this.resetFlight) throw codexAdminError("codex_reset_busy", 429);
|
|
1586
|
+
const redeemRequest = this.pendingReset && this.pendingReset.creditId === creditId ? this.pendingReset.redeemRequest : randomUUID();
|
|
1587
|
+
const promise = (async () => {
|
|
1588
|
+
try {
|
|
1589
|
+
const data = await this.ensureLoaded();
|
|
1590
|
+
if (!data?.account) throw codexAdminError("codex_not_connected", 409);
|
|
1591
|
+
if (creditId && this.spentResetCredits.has(creditId)) {
|
|
1592
|
+
throw codexAdminError("codex_reset_no_credit", 409);
|
|
1593
|
+
}
|
|
1594
|
+
const accessToken = await this.getAccessToken();
|
|
1595
|
+
const fresh = await this.ensureLoaded(true);
|
|
1596
|
+
const accountId = fresh?.account.accountId || void 0;
|
|
1597
|
+
return await consumeCodexResetCredit({
|
|
1598
|
+
redeemRequest,
|
|
1599
|
+
...creditId ? { creditId } : {},
|
|
1600
|
+
accessToken,
|
|
1601
|
+
accountId,
|
|
1602
|
+
fetchImpl: (url, init) => this.directFetch(url, init)
|
|
1603
|
+
});
|
|
1604
|
+
} catch (error) {
|
|
1605
|
+
if (error?.code === "codex_reauth_required") throw codexAdminError("codex_reauth_required", 422);
|
|
1606
|
+
if (error?.code === "codex_upstream_error") throw codexAdminError("codex_reset_unavailable", 502);
|
|
1607
|
+
throw error;
|
|
1608
|
+
}
|
|
1609
|
+
})();
|
|
1610
|
+
this.pendingReset = { redeemRequest, ...creditId ? { creditId } : {} };
|
|
1611
|
+
this.resetFlight = { redeemRequest, promise };
|
|
1612
|
+
try {
|
|
1613
|
+
const result = await this.resetFlight.promise;
|
|
1614
|
+
if (result.outcome === "reset" || result.outcome === "already_redeemed") {
|
|
1615
|
+
if (creditId) this.spentResetCredits.add(creditId);
|
|
1616
|
+
this.usageCache = null;
|
|
1617
|
+
this.resetCache = null;
|
|
1618
|
+
} else if (result.outcome === "no_credit") {
|
|
1619
|
+
this.resetCache = { at: this.now, value: { credits: [], availableCount: 0 } };
|
|
1620
|
+
}
|
|
1621
|
+
this.pendingReset = null;
|
|
1622
|
+
let availableCount;
|
|
1623
|
+
if (result.outcome === "reset" || result.outcome === "already_redeemed") {
|
|
1624
|
+
const listing = await this.getResetCredits().catch(() => null);
|
|
1625
|
+
availableCount = listing?.availableCount;
|
|
1626
|
+
}
|
|
1627
|
+
return { ...result, ...availableCount !== void 0 ? { availableCount } : {} };
|
|
1628
|
+
} finally {
|
|
1629
|
+
if (this.resetFlight?.redeemRequest === redeemRequest) this.resetFlight = null;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1421
1632
|
// -------------------------------------------------------------- cooling/... -
|
|
1422
1633
|
async isAccountCooling() {
|
|
1423
1634
|
const data = await this.ensureLoaded();
|
|
@@ -1544,6 +1755,9 @@ var CodexAuthService = class {
|
|
|
1544
1755
|
this.refreshFlight = null;
|
|
1545
1756
|
this.forceRefreshRequested = false;
|
|
1546
1757
|
this.usageCache = null;
|
|
1758
|
+
this.resetCache = null;
|
|
1759
|
+
this.spentResetCredits.clear();
|
|
1760
|
+
this.pendingReset = null;
|
|
1547
1761
|
return { success: true };
|
|
1548
1762
|
});
|
|
1549
1763
|
}
|
|
@@ -2273,7 +2487,12 @@ function registerCodexAdminRoutes(app, deps) {
|
|
|
2273
2487
|
codex_config_write_failed: 500,
|
|
2274
2488
|
codex_models_fetch_failed: 422,
|
|
2275
2489
|
codex_reauth_required: 422,
|
|
2276
|
-
codex_model_invalid: 422
|
|
2490
|
+
codex_model_invalid: 422,
|
|
2491
|
+
codex_reset_busy: 429,
|
|
2492
|
+
codex_reset_no_credit: 409,
|
|
2493
|
+
codex_reset_unavailable: 502,
|
|
2494
|
+
codex_reset_invalid: 422,
|
|
2495
|
+
codex_reset_failed: 500
|
|
2277
2496
|
};
|
|
2278
2497
|
const isCodexErrorCode = (value) => typeof value === "string" && Object.prototype.hasOwnProperty.call(CODEX_ERROR_STATUS, value);
|
|
2279
2498
|
function codexRouteError(error, reply, route, fallbackCode) {
|
|
@@ -2443,6 +2662,38 @@ function registerCodexAdminRoutes(app, deps) {
|
|
|
2443
2662
|
return codexRouteError(error, reply, "usage", "codex_request_failed");
|
|
2444
2663
|
}
|
|
2445
2664
|
});
|
|
2665
|
+
app.get("/api/codex/reset-credits", async (req, reply) => {
|
|
2666
|
+
try {
|
|
2667
|
+
assertLocalCodexRequest(req);
|
|
2668
|
+
const service = deps.getService();
|
|
2669
|
+
if (!service) {
|
|
2670
|
+
reply.status(503);
|
|
2671
|
+
return { ok: false, success: false, error: "codex_request_failed" };
|
|
2672
|
+
}
|
|
2673
|
+
reply.status(200);
|
|
2674
|
+
return await service.getResetCredits();
|
|
2675
|
+
} catch (error) {
|
|
2676
|
+
return codexRouteError(error, reply, "reset-credits", "codex_request_failed");
|
|
2677
|
+
}
|
|
2678
|
+
});
|
|
2679
|
+
app.post("/api/codex/reset-credits/consume", async (req, reply) => {
|
|
2680
|
+
try {
|
|
2681
|
+
assertLocalCodexRequest(req);
|
|
2682
|
+
const service = deps.getService();
|
|
2683
|
+
if (!service) {
|
|
2684
|
+
reply.status(503);
|
|
2685
|
+
return { ok: false, success: false, error: "codex_request_failed" };
|
|
2686
|
+
}
|
|
2687
|
+
const raw = req.body?.creditId;
|
|
2688
|
+
const creditId = raw === void 0 || raw === null || raw === "" ? void 0 : typeof raw === "string" && raw.length > 0 && raw.length <= 256 ? raw : (() => {
|
|
2689
|
+
throw codexAdminError("codex_reset_invalid", 422);
|
|
2690
|
+
})();
|
|
2691
|
+
const result = await service.consumeResetCredit(creditId);
|
|
2692
|
+
return { ok: true, success: true, ...result };
|
|
2693
|
+
} catch (error) {
|
|
2694
|
+
return codexRouteError(error, reply, "reset-credits/consume", "codex_reset_failed");
|
|
2695
|
+
}
|
|
2696
|
+
});
|
|
2446
2697
|
app.post("/api/codex/disconnect", async (req, reply) => {
|
|
2447
2698
|
try {
|
|
2448
2699
|
assertLocalCodexRequest(req);
|
|
@@ -2520,6 +2771,16 @@ var codexLocales = {
|
|
|
2520
2771
|
usage_plan: "Plan: {{plan}}",
|
|
2521
2772
|
usage_unavailable: "Quota information is not available right now.",
|
|
2522
2773
|
usage_updated: "Updated {{time}}",
|
|
2774
|
+
reset_available: "Usage resets: {{count}} available",
|
|
2775
|
+
reset_expires: "next expires {{time}}",
|
|
2776
|
+
reset_button: "Reset usage limits",
|
|
2777
|
+
reset_title: "Use a usage reset?",
|
|
2778
|
+
reset_warning: "This spends one gifted reset ({{count}} available) and immediately restores your usage limits. This cannot be undone.",
|
|
2779
|
+
reset_confirm: "Use reset",
|
|
2780
|
+
reset_done: "Usage limits reset. {{count}} resets remaining.",
|
|
2781
|
+
reset_already: "This reset was already used. {{count}} resets remaining.",
|
|
2782
|
+
reset_none_left: "No usage resets are available.",
|
|
2783
|
+
reset_nothing: "Nothing to reset \u2014 your usage limits are already fresh.",
|
|
2523
2784
|
window: {
|
|
2524
2785
|
minutes: "{{count}} min",
|
|
2525
2786
|
hours: "{{count}} h",
|
|
@@ -2542,7 +2803,18 @@ var codexLocales = {
|
|
|
2542
2803
|
restore_failed: "Restoring the model failed.",
|
|
2543
2804
|
callback_invalid: "That does not look like a valid callback URL (expected code and state parameters).",
|
|
2544
2805
|
callback_rejected: "The callback was rejected. Please copy the full address and try again.",
|
|
2545
|
-
reconciliation_failed: "Applied, but the local settings draft could not be refreshed \u2014 reload the page to see the change."
|
|
2806
|
+
reconciliation_failed: "Applied, but the local settings draft could not be refreshed \u2014 reload the page to see the change.",
|
|
2807
|
+
codex_usage_limit: "This account has reached its Codex usage limit \u2014 the window resets automatically; the card recovers on the next request.",
|
|
2808
|
+
codex_rate_limited: "Codex is rate limiting this account temporarily.",
|
|
2809
|
+
codex_overloaded: "Codex upstream is temporarily unavailable.",
|
|
2810
|
+
codex_request_rejected: "Codex rejected the request.",
|
|
2811
|
+
codex_upstream_error: "Codex upstream request failed.",
|
|
2812
|
+
reset_failed: "The usage reset failed. Please try again.",
|
|
2813
|
+
codex_reset_busy: "A usage reset is already running \u2014 wait for it to finish.",
|
|
2814
|
+
codex_reset_no_credit: "No usage resets are available.",
|
|
2815
|
+
codex_reset_unavailable: "The reset service is unavailable right now. Please try again.",
|
|
2816
|
+
codex_reset_invalid: "The reset request was invalid.",
|
|
2817
|
+
codex_reauth_required: "The sign-in has expired. Reconnect to refresh the authorization."
|
|
2546
2818
|
}
|
|
2547
2819
|
}
|
|
2548
2820
|
},
|
|
@@ -2606,6 +2878,16 @@ var codexLocales = {
|
|
|
2606
2878
|
usage_plan: "\u5957\u9910\uFF1A{{plan}}",
|
|
2607
2879
|
usage_unavailable: "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u914D\u989D\u4FE1\u606F\u3002",
|
|
2608
2880
|
usage_updated: "\u66F4\u65B0\u4E8E {{time}}",
|
|
2881
|
+
reset_available: "\u7528\u91CF\u91CD\u7F6E\uFF1A\u5269\u4F59 {{count}} \u6B21",
|
|
2882
|
+
reset_expires: "\u6700\u8FD1\u5230\u671F {{time}}",
|
|
2883
|
+
reset_button: "\u91CD\u7F6E\u7528\u91CF\u9650\u989D",
|
|
2884
|
+
reset_title: "\u4F7F\u7528\u4E00\u6B21\u7528\u91CF\u91CD\u7F6E\uFF1F",
|
|
2885
|
+
reset_warning: "\u5C06\u6D88\u8017\u4E00\u6B21\u8D60\u9001\u7684\u91CD\u7F6E\u673A\u4F1A\uFF08\u5269\u4F59 {{count}} \u6B21\uFF09\uFF0C\u7ACB\u5373\u6062\u590D\u7528\u91CF\u9650\u989D\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",
|
|
2886
|
+
reset_confirm: "\u4F7F\u7528\u91CD\u7F6E",
|
|
2887
|
+
reset_done: "\u7528\u91CF\u9650\u989D\u5DF2\u91CD\u7F6E\u3002\u5269\u4F59 {{count}} \u6B21\u3002",
|
|
2888
|
+
reset_already: "\u8BE5\u91CD\u7F6E\u673A\u4F1A\u5DF2\u88AB\u4F7F\u7528\u3002\u5269\u4F59 {{count}} \u6B21\u3002",
|
|
2889
|
+
reset_none_left: "\u6CA1\u6709\u53EF\u7528\u7684\u7528\u91CF\u91CD\u7F6E\u673A\u4F1A\u3002",
|
|
2890
|
+
reset_nothing: "\u65E0\u9700\u91CD\u7F6E\u2014\u2014\u5F53\u524D\u7528\u91CF\u9650\u989D\u5C1A\u672A\u7528\u5C3D\u3002",
|
|
2609
2891
|
window: {
|
|
2610
2892
|
minutes: "{{count}} \u5206\u949F",
|
|
2611
2893
|
hours: "{{count}} \u5C0F\u65F6",
|
|
@@ -2628,7 +2910,18 @@ var codexLocales = {
|
|
|
2628
2910
|
restore_failed: "\u6062\u590D\u6A21\u578B\u5931\u8D25\u3002",
|
|
2629
2911
|
callback_invalid: "\u8FD9\u770B\u8D77\u6765\u4E0D\u662F\u6709\u6548\u7684\u56DE\u8C03\u5730\u5740\uFF08\u5E94\u5305\u542B code \u4E0E state \u53C2\u6570\uFF09\u3002",
|
|
2630
2912
|
callback_rejected: "\u56DE\u8C03\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u590D\u5236\u5B8C\u6574\u5730\u5740\u540E\u91CD\u8BD5\u3002",
|
|
2631
|
-
reconciliation_failed: "\u5DF2\u751F\u6548\uFF0C\u4F46\u672C\u5730\u8BBE\u7F6E\u8349\u7A3F\u672A\u80FD\u5237\u65B0\u2014\u2014\u5237\u65B0\u9875\u9762\u5373\u53EF\u770B\u5230\u53D8\u66F4\u3002"
|
|
2913
|
+
reconciliation_failed: "\u5DF2\u751F\u6548\uFF0C\u4F46\u672C\u5730\u8BBE\u7F6E\u8349\u7A3F\u672A\u80FD\u5237\u65B0\u2014\u2014\u5237\u65B0\u9875\u9762\u5373\u53EF\u770B\u5230\u53D8\u66F4\u3002",
|
|
2914
|
+
codex_usage_limit: "\u8D26\u53F7\u5DF2\u8FBE\u5230 Codex \u7528\u91CF\u4E0A\u9650\u2014\u2014\u7A97\u53E3\u4F1A\u81EA\u52A8\u91CD\u7F6E\uFF0C\u4E0B\u4E00\u6B21\u8BF7\u6C42\u6062\u590D\u663E\u793A\u3002",
|
|
2915
|
+
codex_rate_limited: "Codex \u6B63\u5728\u4E34\u65F6\u9650\u6D41\u8BE5\u8D26\u53F7\u3002",
|
|
2916
|
+
codex_overloaded: "Codex \u4E0A\u6E38\u6682\u65F6\u4E0D\u53EF\u7528\u3002",
|
|
2917
|
+
codex_request_rejected: "Codex \u62D2\u7EDD\u4E86\u8BE5\u8BF7\u6C42\u3002",
|
|
2918
|
+
codex_upstream_error: "Codex \u4E0A\u6E38\u8BF7\u6C42\u5931\u8D25\u3002",
|
|
2919
|
+
reset_failed: "\u7528\u91CF\u91CD\u7F6E\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
|
|
2920
|
+
codex_reset_busy: "\u5DF2\u6709\u7528\u91CF\u91CD\u7F6E\u6B63\u5728\u8FDB\u884C\u2014\u2014\u8BF7\u7B49\u5F85\u5B8C\u6210\u3002",
|
|
2921
|
+
codex_reset_no_credit: "\u6CA1\u6709\u53EF\u7528\u7684\u7528\u91CF\u91CD\u7F6E\u673A\u4F1A\u3002",
|
|
2922
|
+
codex_reset_unavailable: "\u91CD\u7F6E\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
|
|
2923
|
+
codex_reset_invalid: "\u91CD\u7F6E\u8BF7\u6C42\u65E0\u6548\u3002",
|
|
2924
|
+
codex_reauth_required: "\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5\u4EE5\u5237\u65B0\u6388\u6743\u3002"
|
|
2632
2925
|
}
|
|
2633
2926
|
}
|
|
2634
2927
|
}
|
|
@@ -2672,3 +2965,4 @@ export {
|
|
|
2672
2965
|
plugin_default as default,
|
|
2673
2966
|
manifest
|
|
2674
2967
|
};
|
|
2968
|
+
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"coreApi": "1",
|
|
5
5
|
"description": "Codex subscription managed provider: chatgpt.com backend-api/codex data plane, browser OAuth login (PKCE, loopback 1455/1457 + paste), model sync, usage and admin routes."
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wengine-ai/ccr-provider-codex",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Codex subscription provider plugin for claude-code-router: browser OAuth login, fixed-origin responses data plane, transformer, managed runtime, admin routes, config protector and UI card.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|