@wengine-ai/ccr-provider-codex 1.0.11 → 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 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 { fresh, reconcileFailed: failed } = await settle(id);
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") void autoReadUsage();
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 now2 = Date.now();
154
- if (resetMs && resetMs > now2) return Math.max(resetMs - now2, 6e4);
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
- if (account.lastError) status = "error";
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
- lastError: account.lastError ? CODEX_SAFE_MESSAGES[account.lastError.code] ?? null : null
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,11 +1547,119 @@ 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();
1424
1635
  return this.latestCooldown(data) !== void 0;
1425
1636
  }
1637
+ /**
1638
+ * Data-plane success channel: clears non-sticky failure residue once the
1639
+ * upstream produced real output. Without this a single rejected request
1640
+ * (e.g. a 400 on an unsupported payload) latches status="error" on the card
1641
+ * until the next re-login — users experience that as "the login keeps
1642
+ * dropping" even though the token was never invalid. The sticky reauth
1643
+ * marker survives: one good request cannot prove the saved sign-in healthy
1644
+ * again, so only a fresh login clears it. rateLimitCooldownUntil is a
1645
+ * separate quota-window truth with its own expiry and is left alone.
1646
+ * Serialized on the mutation queue like every account write; silently
1647
+ * ignored when disconnected or on a write failure (bookkeeping never breaks
1648
+ * the response path).
1649
+ */
1650
+ noteRequestSuccess() {
1651
+ return this.enqueueMutation(async () => {
1652
+ const current = await this.store.load().catch(() => null);
1653
+ if (!current) return;
1654
+ if (!current.account.lastError && !current.account.cooldownUntil) return;
1655
+ if (current.account.lastError?.code === "codex_reauth_required") return;
1656
+ await this.saveData({
1657
+ ...current,
1658
+ account: { ...current.account, lastError: null, cooldownUntil: null }
1659
+ });
1660
+ }).catch(() => {
1661
+ });
1662
+ }
1426
1663
  /** Data-plane error channel (usage_limit_reached, 401, …). Never throws. */
1427
1664
  noteUpstreamError(info) {
1428
1665
  return this.enqueueMutation(async () => {
@@ -1518,6 +1755,9 @@ var CodexAuthService = class {
1518
1755
  this.refreshFlight = null;
1519
1756
  this.forceRefreshRequested = false;
1520
1757
  this.usageCache = null;
1758
+ this.resetCache = null;
1759
+ this.spentResetCredits.clear();
1760
+ this.pendingReset = null;
1521
1761
  return { success: true };
1522
1762
  });
1523
1763
  }
@@ -1595,6 +1835,7 @@ function normalizeItem(item, boundCallIds) {
1595
1835
  if (item.type === "item_reference") return null;
1596
1836
  const next = { ...item };
1597
1837
  delete next.id;
1838
+ delete next.thinking;
1598
1839
  if (next.role === "system") next.role = "developer";
1599
1840
  if (next.call_id !== void 0) {
1600
1841
  const bounded = boundCallId(next.call_id);
@@ -1861,7 +2102,7 @@ var CodexTransformer = class {
1861
2102
  async transformResponseOut(response, context) {
1862
2103
  this.observeHeaderRateLimits(response);
1863
2104
  const contentType = response.headers.get("content-type") ?? "";
1864
- if (!contentType.includes("text/event-stream") || !response.body) {
2105
+ if (!response.body || contentType.toLowerCase().includes("application/json")) {
1865
2106
  return response;
1866
2107
  }
1867
2108
  return this.inspectStream(response, context);
@@ -1879,6 +2120,20 @@ var CodexTransformer = class {
1879
2120
  } catch {
1880
2121
  }
1881
2122
  }
2123
+ /**
2124
+ * Clear non-sticky failure residue once the upstream produced real output:
2125
+ * a recovered account must not keep reporting its last rejection/quota
2126
+ * marker as a permanent error while requests succeed. Fire-and-forget;
2127
+ * bookkeeping never blocks or breaks the response path.
2128
+ */
2129
+ noteRequestSuccess() {
2130
+ try {
2131
+ const result = this.service.noteRequestSuccess?.();
2132
+ if (result && typeof result.then === "function") result.then(void 0, () => {
2133
+ });
2134
+ } catch {
2135
+ }
2136
+ }
1882
2137
  observeHeaderRateLimits(response) {
1883
2138
  const limits = readCodexRateLimitHeaders(response.headers);
1884
2139
  if (limits) this.reportRateLimits(limits);
@@ -1891,16 +2146,16 @@ var CodexTransformer = class {
1891
2146
  * After the prefix, bytes pass through untouched, including [DONE] and
1892
2147
  * comments; a client cancel propagates to the upstream reader.
1893
2148
  */
1894
- inspectStream(response, context) {
2149
+ inspectStream(response, _context) {
1895
2150
  const reader = response.body.getReader();
1896
2151
  const decoder = new TextDecoder();
1897
2152
  const chunks = [];
1898
2153
  let pending = "";
1899
2154
  let scanned = 0;
1900
2155
  let committed = false;
1901
- let finished = false;
1902
2156
  let rateLimitsSeen = false;
1903
2157
  let sawOutput = false;
2158
+ let successNoted = false;
1904
2159
  const handleEvent = async (data) => {
1905
2160
  if (data === "[DONE]") return true;
1906
2161
  let event;
@@ -1941,11 +2196,19 @@ var CodexTransformer = class {
1941
2196
  }
1942
2197
  if (typeof event?.type === "string" && (event.type.startsWith("response.output_text") || event.type.startsWith("response.function_call_arguments") || event.type.startsWith("response.reasoning") || event.type === "response.output_item.done")) {
1943
2198
  sawOutput = true;
2199
+ if (!successNoted) {
2200
+ successNoted = true;
2201
+ this.noteRequestSuccess();
2202
+ }
1944
2203
  return true;
1945
2204
  }
1946
2205
  if (event.type === "response.completed") {
1947
2206
  if (sawOutput || responseHasOutput(event.response)) {
1948
2207
  sawOutput = true;
2208
+ if (!successNoted) {
2209
+ successNoted = true;
2210
+ this.noteRequestSuccess();
2211
+ }
1949
2212
  return true;
1950
2213
  }
1951
2214
  throw codexEmptyAnswerError();
@@ -2224,7 +2487,12 @@ function registerCodexAdminRoutes(app, deps) {
2224
2487
  codex_config_write_failed: 500,
2225
2488
  codex_models_fetch_failed: 422,
2226
2489
  codex_reauth_required: 422,
2227
- 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
2228
2496
  };
2229
2497
  const isCodexErrorCode = (value) => typeof value === "string" && Object.prototype.hasOwnProperty.call(CODEX_ERROR_STATUS, value);
2230
2498
  function codexRouteError(error, reply, route, fallbackCode) {
@@ -2394,6 +2662,38 @@ function registerCodexAdminRoutes(app, deps) {
2394
2662
  return codexRouteError(error, reply, "usage", "codex_request_failed");
2395
2663
  }
2396
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
+ });
2397
2697
  app.post("/api/codex/disconnect", async (req, reply) => {
2398
2698
  try {
2399
2699
  assertLocalCodexRequest(req);
@@ -2471,6 +2771,16 @@ var codexLocales = {
2471
2771
  usage_plan: "Plan: {{plan}}",
2472
2772
  usage_unavailable: "Quota information is not available right now.",
2473
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.",
2474
2784
  window: {
2475
2785
  minutes: "{{count}} min",
2476
2786
  hours: "{{count}} h",
@@ -2493,7 +2803,18 @@ var codexLocales = {
2493
2803
  restore_failed: "Restoring the model failed.",
2494
2804
  callback_invalid: "That does not look like a valid callback URL (expected code and state parameters).",
2495
2805
  callback_rejected: "The callback was rejected. Please copy the full address and try again.",
2496
- 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."
2497
2818
  }
2498
2819
  }
2499
2820
  },
@@ -2557,6 +2878,16 @@ var codexLocales = {
2557
2878
  usage_plan: "\u5957\u9910\uFF1A{{plan}}",
2558
2879
  usage_unavailable: "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u914D\u989D\u4FE1\u606F\u3002",
2559
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",
2560
2891
  window: {
2561
2892
  minutes: "{{count}} \u5206\u949F",
2562
2893
  hours: "{{count}} \u5C0F\u65F6",
@@ -2579,7 +2910,18 @@ var codexLocales = {
2579
2910
  restore_failed: "\u6062\u590D\u6A21\u578B\u5931\u8D25\u3002",
2580
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",
2581
2912
  callback_rejected: "\u56DE\u8C03\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u590D\u5236\u5B8C\u6574\u5730\u5740\u540E\u91CD\u8BD5\u3002",
2582
- 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"
2583
2925
  }
2584
2926
  }
2585
2927
  }
@@ -2623,3 +2965,4 @@ export {
2623
2965
  plugin_default as default,
2624
2966
  manifest
2625
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.11",
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.11",
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",
@@ -30,4 +30,4 @@
30
30
  "dist/*.json",
31
31
  "dist/*.md"
32
32
  ]
33
- }
33
+ }