dsh-codex-subscription 3.2.3 → 3.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -333,6 +333,7 @@ window.__ModuleLoader__.load({
333
333
  }
334
334
  //#endregion
335
335
  //#region src/composer-attachment-native.js
336
+ const needsSubscriptionImageEnhancement = (settings) => settings.imageViewer && (settings.imageEditing || settings.imageAnnotations);
336
337
  function nativeComposerAttachments(entries, ownComponent) {
337
338
  return entries.find((entry) => entry.component !== ownComponent && entry.locale === "conversation" && !entry.store && !entry.children && (entry.inject === void 0 || typeof entry.inject === "function"));
338
339
  }
@@ -1398,9 +1399,9 @@ window.__ModuleLoader__.load({
1398
1399
  }
1399
1400
  //#endregion
1400
1401
  //#region src/image-composer.js
1401
- function attachImageFiles(conversation, input, files, sessionId) {
1402
+ function attachImageFiles(conversation, input, files, sessionId, { uploadImages = false } = {}) {
1402
1403
  if (typeof conversation.createDrafts !== "function" || typeof input.addAttachments !== "function" || !sessionId) throw new Error("Image composer is unavailable");
1403
- const created = conversation.createDrafts(sessionId, files);
1404
+ const created = conversation.createDrafts(sessionId, files, uploadImages);
1404
1405
  try {
1405
1406
  if (!input.addAttachments(created.map((item) => item.id))) throw new Error("The composer is busy");
1406
1407
  } catch (error) {
@@ -1454,6 +1455,8 @@ window.__ModuleLoader__.load({
1454
1455
  //#endregion
1455
1456
  //#region src/client-locales.js
1456
1457
  const zh = {
1458
+ openSubscriptionSettings: "订阅设置",
1459
+ projectHomepage: "GitHub 项目主页",
1457
1460
  voiceNativeCaptureConfirm: "允许本次通话使用此电脑的麦克风和扬声器?挂断或离开会话后会停止收音。",
1458
1461
  voiceMediaHint: "窗口不支持 WebRTC 时,可在浏览器中继续同一会话。音色试听不受影响,仍使用当前订阅,无需 API Key。",
1459
1462
  voiceBrowserContinue: "在浏览器继续此会话",
@@ -1638,6 +1641,12 @@ window.__ModuleLoader__.load({
1638
1641
  subagentBackendTitle: "独立子任务",
1639
1642
  subagentBackend_dsh: "DSH",
1640
1643
  subagentBackend_codex: "Codex",
1644
+ subagentDefaultModel: "子任务默认模型",
1645
+ subagentDefaultEffort: "子任务默认推理等级",
1646
+ subagentFollowParent: "跟随父会话",
1647
+ subagentModelEffort: "模型默认",
1648
+ subagentDefaultHint: "仅适用于未单独指定模型或推理等级的 Codex 子任务。模型不可用或不在允许列表中时,沿用父会话设置。",
1649
+ subagentDefaultUnavailable: "已保存的子任务模型当前不可用,将跟随父会话。",
1641
1650
  connectionTitle: "连接方式",
1642
1651
  state_connection_cloud: "已开启云端压缩,本次请求实际使用 SSE。",
1643
1652
  diagnosticsLog: "运行日志",
@@ -1976,12 +1985,22 @@ window.__ModuleLoader__.load({
1976
1985
  imageEditReferenceGuide: "本次编辑的干净源图为「{sourceName}」,编号定位参考图为「{referenceName}」。坐标以图片左上角为原点,x 向右、y 向下,百分比相对于整张图片。请查看这两张图片,将它们同时作为编辑工具的参考图,并在工具提示词中完整保留下方编号、位置和修改要求。只修改源图中对应位置的内容;定位参考图上的编号、圆点和引线仅用于定位,不得绘入最终结果。若无法读取两张图片或确定位置,请说明问题,不要猜测或忽略标注。",
1977
1986
  nav: "Codex 订阅",
1978
1987
  title: "Codex 订阅",
1979
- connected: "已登录",
1988
+ savedAccounts: "已登记账号",
1980
1989
  disconnected: "未登录",
1981
1990
  accountLoading: "正在读取账户状态…",
1991
+ accountVerifying: "正在验证…",
1992
+ accountVerified: "认证有效",
1993
+ accountRenewSignIn: "登录已失效",
1994
+ accountUnverified: "暂时无法确认认证状态",
1995
+ renewAccount: "重新登录",
1996
+ renewAccountHint: "请在浏览器中使用原来的 ChatGPT 账号和工作区完成授权。",
1997
+ failed_account_mismatch: "无法确认是原来的 ChatGPT 账号和工作区。请切回原账号后重试。",
1982
1998
  browserLogin: "浏览器登录",
1983
1999
  deviceLogin: "设备代码登录",
1984
2000
  logout: "退出登录",
2001
+ accessDenied: "ChatGPT 拒绝了这次请求(HTTP 403)。请检查账号访问权限,或联系 OpenAI 支持;重新登录不一定能解决。",
2002
+ deviceLimit: "ChatGPT 不允许在这台设备使用此付费账号。请手动选择你拥有的其他获准账号,或联系 OpenAI 支持。退出登录或重置额度不会解除限制。",
2003
+ purchaseLimit: "此卡或设备关联的订阅过多,ChatGPT 已阻止本次购买。如有误,请联系 OpenAI 支持。",
1985
2004
  addAccount: "添加账号",
1986
2005
  switchAccount: "切换",
1987
2006
  removeAccount: "移除",
@@ -2073,6 +2092,7 @@ window.__ModuleLoader__.load({
2073
2092
  historyAutomation: "自动任务",
2074
2093
  usageLoading: "正在读取额度…",
2075
2094
  usageEmpty: "当前账户没有返回可显示的额度窗口。请稍后刷新;这不代表额度为零。",
2095
+ usageRefreshFailed: "暂时无法更新额度,请稍后重试。",
2076
2096
  usageUpdated: "更新于 {value}",
2077
2097
  remaining: "剩余 {value}%",
2078
2098
  windowFiveHours: "5 小时额度",
@@ -2114,8 +2134,6 @@ window.__ModuleLoader__.load({
2114
2134
  resetFailed: "无法使用额度重置。",
2115
2135
  accountQuotaLeft: "{label}剩余 {value}%",
2116
2136
  accountQuotaResets: "{value} 重置",
2117
- accountQuotaLoading: "正在读取额度…",
2118
- accountQuotaError: "暂时读不到这个账号的额度",
2119
2137
  accountQuotaNone: "没有额度窗口信息",
2120
2138
  resetRenewLogin: "登录状态已失效,请重新登录。",
2121
2139
  resetBlocked: "ChatGPT 的网络防护拦截了这次请求(HTTP 403),登录状态没有问题。请稍后再试,或检查网络、代理或 VPN。",
@@ -2373,6 +2391,8 @@ window.__ModuleLoader__.load({
2373
2391
  imageRemoveAnnotation: "删除标注"
2374
2392
  };
2375
2393
  const en = {
2394
+ openSubscriptionSettings: "Subscription settings",
2395
+ projectHomepage: "GitHub project",
2376
2396
  voiceNativeCaptureConfirm: "Use this computer’s microphone and speakers for this call? Capture stops when you hang up or leave the conversation.",
2377
2397
  voiceMediaHint: "If this window does not support WebRTC, continue the same conversation in a browser. Voice samples remain available. Your existing subscription is used; no API key is needed.",
2378
2398
  voiceBrowserContinue: "Continue this conversation in a browser",
@@ -2557,6 +2577,12 @@ window.__ModuleLoader__.load({
2557
2577
  subagentBackendTitle: "Independent subtasks",
2558
2578
  subagentBackend_dsh: "DSH",
2559
2579
  subagentBackend_codex: "Codex",
2580
+ subagentDefaultModel: "Default subtask model",
2581
+ subagentDefaultEffort: "Default subtask reasoning",
2582
+ subagentFollowParent: "Follow parent",
2583
+ subagentModelEffort: "Model default",
2584
+ subagentDefaultHint: "Applies to Codex subtasks without a per-task model or effort. If the model is unavailable or disallowed, the subtask follows its parent.",
2585
+ subagentDefaultUnavailable: "The saved subtask model is currently unavailable. Subtasks will follow the parent.",
2560
2586
  connectionTitle: "Connection",
2561
2587
  diagnosticsLog: "Log",
2562
2588
  diagnosticsLogHint: "What happened while running, in order. Filter to warnings and errors above. Tokens, emails and paths are removed.",
@@ -2895,12 +2921,22 @@ window.__ModuleLoader__.load({
2895
2921
  imageEditReferenceGuide: "The clean source for this edit is \"{sourceName}\"; \"{referenceName}\" is the numbered location reference. Coordinates start at the top-left, x increases rightward and y downward; percentages refer to the whole image. Inspect both images and pass both as references to the image-editing tool. Preserve every number, position and requested change below in the tool prompt. Edit the corresponding content in the clean source; numbers, dots and leader lines on the location reference are guidance only and must not appear in the final result. If either image cannot be read or a location is unclear, explain the problem instead of guessing or ignoring annotations.",
2896
2922
  nav: "Codex",
2897
2923
  title: "Codex subscription",
2898
- connected: "Signed in",
2924
+ savedAccounts: "Saved accounts",
2899
2925
  disconnected: "Not signed in",
2900
2926
  accountLoading: "Reading account status…",
2927
+ accountVerifying: "Checking sign-in…",
2928
+ accountVerified: "Sign-in verified",
2929
+ accountRenewSignIn: "Sign-in expired",
2930
+ accountUnverified: "Could not verify sign-in",
2931
+ renewAccount: "Sign in again",
2932
+ renewAccountHint: "Complete authorization in your browser with the original ChatGPT account and workspace.",
2933
+ failed_account_mismatch: "Could not verify the same ChatGPT account and workspace. Switch to the original account and try again.",
2901
2934
  browserLogin: "Browser sign-in",
2902
2935
  deviceLogin: "Device-code sign-in",
2903
2936
  logout: "Sign out",
2937
+ accessDenied: "ChatGPT denied this request (HTTP 403). Check account access or contact OpenAI Support; signing in again may not resolve it.",
2938
+ deviceLimit: "ChatGPT does not allow this paid account on this device. Manually select another permitted account you own or contact OpenAI Support. Signing out or resetting usage does not clear the restriction.",
2939
+ purchaseLimit: "ChatGPT blocked this purchase because too many subscriptions are associated with this card or device. Contact OpenAI Support if this is unexpected.",
2904
2940
  addAccount: "Add account",
2905
2941
  switchAccount: "Switch",
2906
2942
  removeAccount: "Remove",
@@ -2992,6 +3028,7 @@ window.__ModuleLoader__.load({
2992
3028
  historyAutomation: "Automations",
2993
3029
  usageLoading: "Reading quota…",
2994
3030
  usageEmpty: "This account returned no displayable quota windows. Refresh later; this does not mean zero quota.",
3031
+ usageRefreshFailed: "Quota could not be updated. Try again shortly.",
2995
3032
  usageUpdated: "Updated {value}",
2996
3033
  remaining: "{value}% remaining",
2997
3034
  windowFiveHours: "5-hour quota",
@@ -3033,8 +3070,6 @@ window.__ModuleLoader__.load({
3033
3070
  resetFailed: "Could not use the quota reset.",
3034
3071
  accountQuotaLeft: "{label} {value}% left",
3035
3072
  accountQuotaResets: "resets {value}",
3036
- accountQuotaLoading: "Reading quota…",
3037
- accountQuotaError: "The quota of this account could not be read right now",
3038
3073
  accountQuotaNone: "No quota window reported",
3039
3074
  resetRenewLogin: "Your sign-in expired. Sign in again.",
3040
3075
  resetBlocked: "ChatGPT network protection blocked this request (HTTP 403). Your sign-in is fine; try again later or check your network, proxy or VPN.",
@@ -3294,6 +3329,10 @@ window.__ModuleLoader__.load({
3294
3329
  //#endregion
3295
3330
  //#region src/client-styles.js
3296
3331
  const STYLE = `
3332
+ .codexSubscription[data-embedded=true]{max-width:960px}
3333
+ .codexQuotaSettingsLink{display:block;width:100%;margin-top:8px;padding:8px 0 0;border:0;border-top:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-link,var(--dsw-alias-label-primary));font:inherit;text-align:start;cursor:pointer}
3334
+ .codexQuotaSettingsLink:hover{text-decoration:underline}
3335
+ .codexQuotaSettingsLink:focus-visible{outline:2px solid var(--dsw-alias-border-l3);outline-offset:3px;border-radius:2px}
3297
3336
  .codexSubscriptionAdvancedPreferences{display:flex;flex-direction:column;gap:10px}
3298
3337
  .codexSubscriptionAdvancedPreferences[data-others-off=true]>[data-governed=true]{opacity:.55;transition:opacity .15s}
3299
3338
  .codexSubscriptionSearchChoices.codexSubscriptionQuotaModes{display:flex;flex:0 0 auto;gap:0;grid-template-columns:none}
@@ -3375,7 +3414,6 @@ window.__ModuleLoader__.load({
3375
3414
  .codexSubscriptionAccount:last-child{border-bottom:0}
3376
3415
  .codexSubscriptionAccountMain{display:flex;flex-direction:column;gap:2px;padding:6px 0;min-width:0}
3377
3416
  .codexSubscriptionAccountQuota{display:flex;flex-wrap:wrap;gap:2px 12px;font-size:12px;color:var(--dsw-alias-text-l2)}
3378
- .codexSubscriptionAccountQuota[data-state=error]{color:var(--dsw-alias-text-danger,#c0392b)}
3379
3417
  .codexSubscriptionAccount[data-active=true] .codexSubscriptionEmail,.codexSubscriptionAccount[data-active=true]>span{font-weight:600}
3380
3418
  .codexSubscriptionEmail{max-width:100%;overflow:hidden;padding:2px 4px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}
3381
3419
  .codexSubscriptionEmail:hover{background:var(--dsw-alias-interactive-bg-hover)}
@@ -3744,8 +3782,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
3744
3782
  .codexSubscriptionLimit[data-pace=true] progress::-moz-progress-bar{background:var(--dsw-alias-state-warning-primary,#f5a300)}
3745
3783
  .codexDiagResult{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 0;border-top:1px solid var(--dsw-alias-border-l2)}
3746
3784
  .codexDiagBadge{font-size:13px;line-height:20px;font-weight:500;color:var(--dsw-alias-label-primary)}
3747
- .codexDiagResult[data-state=ok] .codexDiagBadge::before,.codexDiagResult[data-state=attention] .codexDiagBadge::before{content:'';display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:8px;background:var(--dsw-alias-state-success-primary,#1a9d58)}
3748
- .codexDiagResult[data-state=attention] .codexDiagBadge::before{background:var(--dsw-alias-state-warning-primary,#f5a300)}
3785
+ .codexDiagResult[data-state=attention] .codexDiagBadge::before{content:'';display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:8px;background:var(--dsw-alias-state-warning-primary,#f5a300)}
3749
3786
  .codexDiagTime{font-size:12px;color:var(--dsw-alias-label-tertiary)}
3750
3787
  .codexDiagFindings{list-style:none;margin:0;padding:0 0 6px;display:flex;flex-direction:column;gap:8px}
3751
3788
  .codexDiagFindings>li{display:flex;flex-direction:column;gap:2px;font-size:13px;line-height:20px}
@@ -4370,6 +4407,11 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4370
4407
  "forecast"
4371
4408
  ].includes(value) ? value : legacyVisible === true ? QUICK_QUOTA_MODE_PERCENT : "off";
4372
4409
  const supportsCodexFastMode = (modelId) => typeof modelId === "string" && (/^gpt-5\.(?:5|6)(?:$|-)/u.test(modelId) || modelId === "gpt-5.4" || modelId === "gpt-6-astra");
4410
+ //#endregion
4411
+ //#region src/subagent-defaults.js
4412
+ const SUBAGENT_EFFORTS = Object.freeze(DEFAULT_REASONING_EFFORTS.filter((value) => value !== "ultra"));
4413
+ const normalizeSubagentModel = (value) => typeof value === "string" && /^[a-z][a-z0-9._-]{0,79}$/u.test(value) ? value : "";
4414
+ const normalizeSubagentEffort = (value) => SUBAGENT_EFFORTS.includes(value) ? value : "auto";
4373
4415
  Object.freeze({
4374
4416
  compactionMode: {
4375
4417
  choices: ["dsh", "cloud"],
@@ -4420,6 +4462,11 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4420
4462
  default: "dsh",
4421
4463
  error: "Invalid subagent backend"
4422
4464
  },
4465
+ subagentDefaultEffort: {
4466
+ choices: SUBAGENT_EFFORTS,
4467
+ default: "auto",
4468
+ error: "Invalid subtask reasoning effort"
4469
+ },
4423
4470
  [QUICK_QUOTA_MODE_FIELD]: {
4424
4471
  choices: [
4425
4472
  "off",
@@ -4536,6 +4583,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4536
4583
  let disposed = false;
4537
4584
  let subagentBackendAvailable = false;
4538
4585
  let subagentRuntimeInstalled = false;
4586
+ let subagentModels = [];
4539
4587
  let fetchRoutingAvailable = false;
4540
4588
  let restartRequired = false;
4541
4589
  const sameModels = (left, right) => left.length === right.length && left.every((model, index) => JSON.stringify(model) === JSON.stringify(right[index]));
@@ -4559,6 +4607,9 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4559
4607
  reasoningCache: normalizeReasoningCache(value?.reasoningCache),
4560
4608
  defaultReasoningEffort: normalizeDefaultReasoningEffort(value?.[DEFAULT_REASONING_EFFORT_FIELD]),
4561
4609
  subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
4610
+ subagentDefaultModel: normalizeSubagentModel(value?.subagentDefaultModel),
4611
+ subagentDefaultEffort: normalizeSubagentEffort(value?.subagentDefaultEffort),
4612
+ subagentModels,
4562
4613
  subagentBackendAvailable,
4563
4614
  subagentRuntimeInstalled,
4564
4615
  quickQuotaMode: normalizeQuickQuotaMode(value?.[QUICK_QUOTA_MODE_FIELD], value?.[LEGACY_QUICK_QUOTA_FIELD]),
@@ -4616,6 +4667,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4616
4667
  if (!modelRefreshStarted) {
4617
4668
  contextModels = Array.isArray(value?.contextModels) ? value.contextModels : [];
4618
4669
  availableModels = Array.isArray(value?.availableModels) ? value.availableModels : [];
4670
+ subagentModels = Array.isArray(value?.subagentModels) ? value.subagentModels : [];
4619
4671
  verbosityModels = Array.isArray(value?.verbosityModels) ? value.verbosityModels : [];
4620
4672
  fastModels = Array.isArray(value?.fastModels) ? value.fastModels : void 0;
4621
4673
  ultrafastModels = Array.isArray(value?.ultrafastModels) ? value.ultrafastModels : [];
@@ -4637,6 +4689,8 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4637
4689
  reasoningCache: normalizeReasoningCache(value?.reasoningCache),
4638
4690
  [DEFAULT_REASONING_EFFORT_FIELD]: normalizeDefaultReasoningEffort(value?.[DEFAULT_REASONING_EFFORT_FIELD]),
4639
4691
  subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
4692
+ subagentDefaultModel: normalizeSubagentModel(value?.subagentDefaultModel),
4693
+ subagentDefaultEffort: normalizeSubagentEffort(value?.subagentDefaultEffort),
4640
4694
  ...readCapabilitySettings(value),
4641
4695
  [QUICK_QUOTA_MODE_FIELD]: normalizeQuickQuotaMode(value?.[QUICK_QUOTA_MODE_FIELD], value?.[LEGACY_QUICK_QUOTA_FIELD]),
4642
4696
  [SEARCH_PROVIDER_FIELD]: normalizeSearchProvider(value?.[SEARCH_PROVIDER_FIELD]),
@@ -4690,15 +4744,17 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
4690
4744
  if (disposed || current !== modelRefreshGeneration) return false;
4691
4745
  const nextContextModels = Array.isArray(value?.contextModels) ? value.contextModels : [];
4692
4746
  const nextAvailableModels = Array.isArray(value?.availableModels) ? value.availableModels : [];
4747
+ const nextSubagentModels = Array.isArray(value?.subagentModels) ? value.subagentModels : [];
4693
4748
  const nextVerbosityModels = Array.isArray(value?.verbosityModels) ? value.verbosityModels : [];
4694
4749
  const nextFastModels = Array.isArray(value?.fastModels) ? value.fastModels : void 0;
4695
4750
  const nextUltrafastModels = Array.isArray(value?.ultrafastModels) ? value.ultrafastModels : [];
4696
4751
  const nextUltraModels = Array.isArray(value?.ultraModels) ? value.ultraModels : [];
4697
4752
  catalogStatus = value?.catalogStatus;
4698
- const changed = !sameModels(contextModels, nextContextModels) || !sameModels(availableModels, nextAvailableModels) || !sameModels(verbosityModels, nextVerbosityModels) || JSON.stringify(fastModels) !== JSON.stringify(nextFastModels) || JSON.stringify(ultrafastModels) !== JSON.stringify(nextUltrafastModels) || JSON.stringify(ultraModels) !== JSON.stringify(nextUltraModels);
4753
+ const changed = !sameModels(contextModels, nextContextModels) || !sameModels(availableModels, nextAvailableModels) || !sameModels(subagentModels, nextSubagentModels) || !sameModels(verbosityModels, nextVerbosityModels) || JSON.stringify(fastModels) !== JSON.stringify(nextFastModels) || JSON.stringify(ultrafastModels) !== JSON.stringify(nextUltrafastModels) || JSON.stringify(ultraModels) !== JSON.stringify(nextUltraModels);
4699
4754
  if (changed) {
4700
4755
  contextModels = nextContextModels;
4701
4756
  availableModels = nextAvailableModels;
4757
+ subagentModels = nextSubagentModels;
4702
4758
  verbosityModels = nextVerbosityModels;
4703
4759
  fastModels = nextFastModels;
4704
4760
  ultrafastModels = nextUltrafastModels;
@@ -5171,9 +5227,33 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
5171
5227
  });
5172
5228
  }
5173
5229
  //#endregion
5230
+ //#region src/http-failure.js
5231
+ const SIGN_IN_RENEW = "ChatGPT sign-in needs to be renewed";
5232
+ const ACCESS_DENIED = "ChatGPT denied this request (HTTP 403). Check account access or contact OpenAI Support; signing in again may not resolve it.";
5233
+ const DEVICE_LIMIT = "ChatGPT does not allow this paid account on this device. Use another permitted account you own or contact OpenAI Support. Signing out or resetting usage does not clear this restriction.";
5234
+ const PURCHASE_LIMIT = "ChatGPT blocked this purchase because too many subscriptions are associated with this card or device. Contact OpenAI Support if this is unexpected.";
5235
+ const PUBLIC_ACCESS_MESSAGES = /* @__PURE__ */ new Set([
5236
+ ACCESS_DENIED,
5237
+ DEVICE_LIMIT,
5238
+ PURCHASE_LIMIT
5239
+ ]);
5240
+ const isAccessFailureMessage = (message) => PUBLIC_ACCESS_MESSAGES.has(message);
5241
+ //#endregion
5174
5242
  //#region src/client-shared.js
5243
+ const ACCESS_FAILURE_KEYS = /* @__PURE__ */ new Map([
5244
+ [ACCESS_DENIED, "accessDenied"],
5245
+ [DEVICE_LIMIT, "deviceLimit"],
5246
+ [PURCHASE_LIMIT, "purchaseLimit"],
5247
+ [SIGN_IN_RENEW, "resetRenewLogin"]
5248
+ ]);
5249
+ const accessFailureText = (message, t) => {
5250
+ const key = ACCESS_FAILURE_KEYS.get(message);
5251
+ return key === void 0 ? message : t(key);
5252
+ };
5253
+ const usageFailureText = (message, t) => ["Request timed out", "Could not read ChatGPT usage"].includes(message) ? t("usageRefreshFailed") : accessFailureText(message, t);
5175
5254
  const NS = "settings.codexSubscription";
5176
- const SUPPORT_ISSUE_URL = "https://github.com/WSL043/dsh-codex-subscription/issues/new?template=install-problem.yml";
5255
+ const PROJECT_URL = "https://github.com/WSL043/dsh-codex-subscription";
5256
+ const SUPPORT_ISSUE_URL = `${PROJECT_URL}/issues/new?template=install-problem.yml`;
5177
5257
  const QUICK_QUOTA_REFRESH_EVENT = "dsh-codex-subscription:refresh-quick-quota";
5178
5258
  const accountStatusErrorText = (error, t) => {
5179
5259
  const key = {
@@ -5256,10 +5336,10 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
5256
5336
  }
5257
5337
  //#endregion
5258
5338
  //#region src/version.js
5259
- const PACKAGE_VERSION = "3.2.3";
5339
+ const PACKAGE_VERSION = "3.2.5";
5260
5340
  //#endregion
5261
5341
  //#region src/client-recovery.js
5262
- async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
5342
+ async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = endpoint === "usage" || endpoint.startsWith("usage/") ? 3e4 : 1e4) {
5263
5343
  let timer;
5264
5344
  const controller = new AbortController();
5265
5345
  try {
@@ -5474,7 +5554,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
5474
5554
  }
5475
5555
  //#endregion
5476
5556
  //#region src/client-composer-quota.jsx
5477
- function CodexComposerQuota({ preference, rpc, t, directory }) {
5557
+ function CodexComposerQuota({ preference, rpc, t, directory, openSettings }) {
5478
5558
  const preferenceSnapshot = usePreferenceSnapshot(preference);
5479
5559
  const current = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot()).current;
5480
5560
  const quotaEnabled = preferenceSnapshot.status === "ready" && preferenceSnapshot.quickQuotaMode !== "off" && current?.provider === "openai-codex";
@@ -5569,7 +5649,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
5569
5649
  preferenceSnapshot.quickQuotaMode !== "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${percent(quota.remainingPercent)}%` }) : null
5570
5650
  ]
5571
5651
  }, `${quota.windowSeconds}-${index}`))
5572
- }), visible ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
5652
+ }), visible ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
5573
5653
  ref: panel,
5574
5654
  id,
5575
5655
  role: "dialog",
@@ -5582,7 +5662,7 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
5582
5662
  ...position,
5583
5663
  visibility: position ? "visible" : "hidden"
5584
5664
  },
5585
- children: quotas.map((quota, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5665
+ children: [quotas.map((quota, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5586
5666
  className: "codexQuotaDetail",
5587
5667
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
5588
5668
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: windowLabel(quota.windowSeconds, t) }),
@@ -5592,7 +5672,15 @@ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizi
5592
5672
  children: shortReset(quota, t)
5593
5673
  })
5594
5674
  ] }), forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: formatQuotaForecast(quota.forecast, t, quota) }) : null]
5595
- }, `${quota.windowSeconds}-${index}`))
5675
+ }, `${quota.windowSeconds}-${index}`)), openSettings ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5676
+ type: "button",
5677
+ className: "codexQuotaSettingsLink",
5678
+ onClick: () => {
5679
+ dismiss();
5680
+ openSettings();
5681
+ },
5682
+ children: t("openSubscriptionSettings")
5683
+ }) : null]
5596
5684
  }), document.body) : null] });
5597
5685
  }
5598
5686
  function shortWindow(seconds, t) {
@@ -7654,6 +7742,7 @@ void main(){
7654
7742
  //#endregion
7655
7743
  //#region src/capability-preferences.jsx
7656
7744
  function CapabilityPreferences({ preference, t, section, disabled = false }) {
7745
+ const radioId = (0, react.useId)();
7657
7746
  const snapshot = (0, react.useSyncExternalStore)(preference.subscribe, preference.getSnapshot);
7658
7747
  const [domains, setDomains] = (0, react.useState)("");
7659
7748
  const [invalid, setInvalid] = (0, react.useState)(false);
@@ -7670,7 +7759,7 @@ void main(){
7670
7759
  className: "codexSubscriptionQuotaMode",
7671
7760
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
7672
7761
  type: "radio",
7673
- name: `codex-${field}`,
7762
+ name: `${radioId}-codex-${field}`,
7674
7763
  checked: snapshot[field] === value,
7675
7764
  disabled: !snapshot.writable || disabled,
7676
7765
  onChange: () => {
@@ -10750,6 +10839,7 @@ void main(){
10750
10839
  error: ["error"]
10751
10840
  };
10752
10841
  function DiagnosticsCard({ rpc, t, diagnostics }) {
10842
+ const radioId = (0, react.useId)();
10753
10843
  const [report, setReport] = (0, react.useState)();
10754
10844
  const [busy, setBusy] = (0, react.useState)(false);
10755
10845
  const [copied, setCopied] = (0, react.useState)(false);
@@ -10844,7 +10934,7 @@ void main(){
10844
10934
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10845
10935
  className: "codexDiagResult",
10846
10936
  role: "status",
10847
- "data-state": attention.length ? "attention" : "ok",
10937
+ "data-state": attention.length ? "attention" : void 0,
10848
10938
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10849
10939
  className: "codexDiagBadge",
10850
10940
  children: attention.length ? t("diagnosticsAttention").replace("{count}", String(attention.length)) : t("diagnosticsNoRecordedFailure")
@@ -10884,7 +10974,7 @@ void main(){
10884
10974
  className: "codexSubscriptionQuotaMode",
10885
10975
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10886
10976
  type: "radio",
10887
- name: "codex-log-level",
10977
+ name: `${radioId}-codex-log-level`,
10888
10978
  checked: level === value,
10889
10979
  onChange: () => {
10890
10980
  setLevel(value);
@@ -11114,13 +11204,14 @@ void main(){
11114
11204
  //#endregion
11115
11205
  //#region src/client-preferences.jsx
11116
11206
  function QuickQuotaPreference({ preference, t }) {
11207
+ const radioId = (0, react.useId)();
11117
11208
  const snapshot = usePreferenceSnapshot(preference);
11118
11209
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11119
11210
  const choice = (value, label) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
11120
11211
  className: "codexSubscriptionQuotaMode",
11121
11212
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11122
11213
  type: "radio",
11123
- name: "codex-subscription-quota-mode",
11214
+ name: `${radioId}-codex-subscription-quota-mode`,
11124
11215
  checked: snapshot.quickQuotaMode === value,
11125
11216
  disabled: !writable,
11126
11217
  onChange: () => {
@@ -11177,13 +11268,14 @@ void main(){
11177
11268
  });
11178
11269
  }
11179
11270
  function SearchProviderPreference({ preference, t }) {
11271
+ const radioId = (0, react.useId)();
11180
11272
  const snapshot = usePreferenceSnapshot(preference);
11181
11273
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11182
11274
  const choice = (value, label) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
11183
11275
  className: "codexSubscriptionQuotaMode",
11184
11276
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11185
11277
  type: "radio",
11186
- name: "codex-subscription-search-provider",
11278
+ name: `${radioId}-codex-subscription-search-provider`,
11187
11279
  checked: snapshot.searchProvider === value,
11188
11280
  disabled: !writable,
11189
11281
  onChange: () => {
@@ -11233,7 +11325,7 @@ void main(){
11233
11325
  className: "codexSubscriptionQuotaMode",
11234
11326
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11235
11327
  type: "radio",
11236
- name: "codex-subscription-fetch-provider",
11328
+ name: `${radioId}-codex-subscription-fetch-provider`,
11237
11329
  checked: snapshot.fetchProvider === value,
11238
11330
  disabled: !writable || value === "codex" && !snapshot.fetchRoutingAvailable,
11239
11331
  onChange: () => {
@@ -11252,6 +11344,7 @@ void main(){
11252
11344
  });
11253
11345
  }
11254
11346
  function InputImageDetailPreference({ preference, t }) {
11347
+ const radioId = (0, react.useId)();
11255
11348
  const snapshot = usePreferenceSnapshot(preference);
11256
11349
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11257
11350
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11272,7 +11365,7 @@ void main(){
11272
11365
  className: "codexSubscriptionQuotaMode",
11273
11366
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11274
11367
  type: "radio",
11275
- name: "codex-input-image-detail",
11368
+ name: `${radioId}-codex-input-image-detail`,
11276
11369
  checked: snapshot.inputImageDetail === value,
11277
11370
  disabled: !writable,
11278
11371
  onChange: () => {
@@ -11284,6 +11377,7 @@ void main(){
11284
11377
  });
11285
11378
  }
11286
11379
  function ReasoningSummaryPreference({ preference, t }) {
11380
+ const radioId = (0, react.useId)();
11287
11381
  const snapshot = usePreferenceSnapshot(preference);
11288
11382
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11289
11383
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11304,7 +11398,7 @@ void main(){
11304
11398
  className: "codexSubscriptionQuotaMode",
11305
11399
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11306
11400
  type: "radio",
11307
- name: "codex-reasoning-summary",
11401
+ name: `${radioId}-codex-reasoning-summary`,
11308
11402
  checked: snapshot.reasoningSummary === value,
11309
11403
  disabled: !writable,
11310
11404
  onChange: () => {
@@ -11364,6 +11458,7 @@ void main(){
11364
11458
  });
11365
11459
  }
11366
11460
  function RetryPolicyPreference({ preference, t }) {
11461
+ const radioId = (0, react.useId)();
11367
11462
  const snapshot = usePreferenceSnapshot(preference);
11368
11463
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11369
11464
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11384,7 +11479,7 @@ void main(){
11384
11479
  className: "codexSubscriptionQuotaMode",
11385
11480
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11386
11481
  type: "radio",
11387
- name: "codex-retry-policy",
11482
+ name: `${radioId}-codex-retry-policy`,
11388
11483
  checked: snapshot.retryPolicy === value,
11389
11484
  disabled: !writable,
11390
11485
  onChange: () => {
@@ -11396,6 +11491,7 @@ void main(){
11396
11491
  });
11397
11492
  }
11398
11493
  function ConnectorsPreference({ preference, t }) {
11494
+ const radioId = (0, react.useId)();
11399
11495
  const snapshot = usePreferenceSnapshot(preference);
11400
11496
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11401
11497
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11418,7 +11514,7 @@ void main(){
11418
11514
  className: "codexSubscriptionQuotaMode",
11419
11515
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11420
11516
  type: "radio",
11421
- name: "codex-connectors",
11517
+ name: `${radioId}-codex-connectors`,
11422
11518
  checked: snapshot.connectors === value,
11423
11519
  disabled: !writable,
11424
11520
  onChange: () => {
@@ -11437,6 +11533,7 @@ void main(){
11437
11533
  });
11438
11534
  }
11439
11535
  function StreamIdleTimeoutPreference({ preference, t }) {
11536
+ const radioId = (0, react.useId)();
11440
11537
  const snapshot = usePreferenceSnapshot(preference);
11441
11538
  const writable = snapshot.status === "ready" && snapshot.writable === true;
11442
11539
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -11457,7 +11554,7 @@ void main(){
11457
11554
  className: "codexSubscriptionQuotaMode",
11458
11555
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11459
11556
  type: "radio",
11460
- name: "codex-stream-idle-timeout",
11557
+ name: `${radioId}-codex-stream-idle-timeout`,
11461
11558
  checked: snapshot.streamIdleTimeoutMinutes === value,
11462
11559
  disabled: !writable,
11463
11560
  onChange: () => {
@@ -11873,6 +11970,7 @@ void main(){
11873
11970
  });
11874
11971
  }
11875
11972
  function OutputVerbosityPreference({ preference, t }) {
11973
+ const radioId = (0, react.useId)();
11876
11974
  const snapshot = usePreferenceSnapshot(preference);
11877
11975
  const writable = ready(snapshot);
11878
11976
  const values = [
@@ -11904,7 +12002,7 @@ void main(){
11904
12002
  className: "codexSubscriptionQuotaMode",
11905
12003
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11906
12004
  type: "radio",
11907
- name: "codex-output-verbosity",
12005
+ name: `${radioId}-codex-output-verbosity`,
11908
12006
  checked: snapshot.outputVerbosity === value,
11909
12007
  disabled: !writable,
11910
12008
  onChange: () => {
@@ -11916,6 +12014,7 @@ void main(){
11916
12014
  });
11917
12015
  }
11918
12016
  function Radios({ snapshot, preference, field, values, label, name, text, disabled, disabledValues = [] }) {
12017
+ const radioId = (0, react.useId)();
11919
12018
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11920
12019
  className: "codexSubscriptionQuotaModes",
11921
12020
  role: "radiogroup",
@@ -11925,7 +12024,7 @@ void main(){
11925
12024
  className: "codexSubscriptionQuotaMode",
11926
12025
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
11927
12026
  type: "radio",
11928
- name,
12027
+ name: `${radioId}-${name}`,
11929
12028
  checked: snapshot[field] === value,
11930
12029
  disabled: disabled || !snapshot.writable || disabledValues.includes(value),
11931
12030
  onChange: () => {
@@ -12070,6 +12169,56 @@ void main(){
12070
12169
  ]
12071
12170
  });
12072
12171
  }
12172
+ function SubagentDefaultPreferences({ preference, snapshot, t }) {
12173
+ const models = snapshot.subagentModels ?? [];
12174
+ const model = snapshot.subagentDefaultModel ?? "";
12175
+ const effort = snapshot.subagentDefaultEffort ?? "auto";
12176
+ const selected = models.find((candidate) => candidate.id === model);
12177
+ const efforts = model === "" ? [...new Set(models.flatMap((candidate) => candidate.efforts))] : selected?.efforts ?? [];
12178
+ const inherit = "__follow_parent__";
12179
+ const modelItems = [{
12180
+ id: inherit,
12181
+ label: t("subagentFollowParent")
12182
+ }, ...models.map((candidate) => ({
12183
+ id: candidate.id,
12184
+ label: candidate.name ?? candidate.id
12185
+ }))];
12186
+ const effortText = (id) => id === "auto" ? t(model === "" ? "subagentFollowParent" : "subagentModelEffort") : t(`defaultReasoningEffort_${id}`);
12187
+ const disabled = !ready(snapshot);
12188
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
12189
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageChoice, {
12190
+ t,
12191
+ label: t("subagentDefaultModel"),
12192
+ hint: t("subagentDefaultHint"),
12193
+ value: model || inherit,
12194
+ text: model === "" ? t("subagentFollowParent") : selected?.name ?? model,
12195
+ items: modelItems,
12196
+ disabled,
12197
+ onSelect: (id) => {
12198
+ const target = models.find((candidate) => candidate.id === id);
12199
+ preference.set({
12200
+ subagentDefaultModel: id === inherit ? "" : id,
12201
+ ...target && !target.efforts.includes(effort) ? { subagentDefaultEffort: "auto" } : {}
12202
+ });
12203
+ }
12204
+ }),
12205
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageChoice, {
12206
+ t,
12207
+ label: t("subagentDefaultEffort"),
12208
+ value: effort,
12209
+ text: effortText(effort),
12210
+ items: ["auto", ...efforts].map((id) => ({
12211
+ id,
12212
+ label: effortText(id)
12213
+ })),
12214
+ disabled,
12215
+ onSelect: (id) => {
12216
+ preference.set({ subagentDefaultEffort: id });
12217
+ }
12218
+ }),
12219
+ model !== "" && !selected ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, { children: t("subagentDefaultUnavailable") }) : null
12220
+ ] });
12221
+ }
12073
12222
  function ToolsPage({ preference, rpc, t, active = true }) {
12074
12223
  const snapshot = usePreferenceSnapshot(preference);
12075
12224
  const writable = ready(snapshot);
@@ -12113,35 +12262,43 @@ void main(){
12113
12262
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
12114
12263
  className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
12115
12264
  "aria-label": t("subagentBackendTitle"),
12116
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12117
- className: "codexSubscriptionPreference",
12118
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12119
- className: "codexSubscriptionPreferenceCopy",
12120
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SettingsLabel, {
12121
- description: t("subagentBackendHint"),
12122
- children: [
12123
- t("subagentBackendTitle"),
12124
- " ",
12125
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "Beta" })
12126
- ]
12127
- }), !snapshot.subagentBackendAvailable || !(codexReady || subagentsOn) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, { children: t(snapshot.subagentBackendAvailable ? "subagentBackendNeedsRuntime" : "subagentBackendUnavailable") }) : null]
12128
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Radios, {
12265
+ children: [
12266
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12267
+ className: "codexSubscriptionPreference",
12268
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12269
+ className: "codexSubscriptionPreferenceCopy",
12270
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SettingsLabel, {
12271
+ description: t("subagentBackendHint"),
12272
+ children: [
12273
+ t("subagentBackendTitle"),
12274
+ " ",
12275
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "Beta" })
12276
+ ]
12277
+ }), !snapshot.subagentBackendAvailable || !(codexReady || subagentsOn) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, { children: t(snapshot.subagentBackendAvailable ? "subagentBackendNeedsRuntime" : "subagentBackendUnavailable") }) : null]
12278
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Radios, {
12279
+ snapshot,
12280
+ preference,
12281
+ field: "subagentBackend",
12282
+ values: ["dsh", "codex"],
12283
+ name: "codex-subagent-backend",
12284
+ label: t("subagentBackendTitle"),
12285
+ text: (value) => t(`subagentBackend_${value}`),
12286
+ disabled: !snapshot.subagentBackendAvailable,
12287
+ disabledValues: codexReady || subagentsOn ? [] : ["codex"]
12288
+ })]
12289
+ }),
12290
+ subagentsOn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubagentDefaultPreferences, {
12291
+ preference,
12129
12292
  snapshot,
12293
+ t
12294
+ }) : null,
12295
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeManagement, {
12296
+ rpc,
12130
12297
  preference,
12131
- field: "subagentBackend",
12132
- values: ["dsh", "codex"],
12133
- name: "codex-subagent-backend",
12134
- label: t("subagentBackendTitle"),
12135
- text: (value) => t(`subagentBackend_${value}`),
12136
- disabled: !snapshot.subagentBackendAvailable,
12137
- disabledValues: codexReady || subagentsOn ? [] : ["codex"]
12138
- })]
12139
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuntimeManagement, {
12140
- rpc,
12141
- preference,
12142
- t,
12143
- active
12144
- })]
12298
+ t,
12299
+ active
12300
+ })
12301
+ ]
12145
12302
  })
12146
12303
  ]
12147
12304
  });
@@ -12299,6 +12456,7 @@ void main(){
12299
12456
  async function readLoginProgress({ flow, readFlow, readAccount }) {
12300
12457
  try {
12301
12458
  const nextFlow = await readFlow();
12459
+ if (nextFlow.phase === "failed" && isAccessFailureMessage(nextFlow.error)) return { flow: nextFlow };
12302
12460
  if (nextFlow.phase === "failed") try {
12303
12461
  const account = await readAccount();
12304
12462
  if (account?.authenticated === true) return {
@@ -12343,7 +12501,7 @@ void main(){
12343
12501
  minute: "2-digit"
12344
12502
  });
12345
12503
  /** Quota of every signed-in account (read-only; the active account does not change). */
12346
- function useAccountQuotas(rpc, ids, active = true) {
12504
+ function useAccountQuotas(rpc, ids, active = true, revision = 0) {
12347
12505
  const [entries, setEntries] = (0, react.useState)({});
12348
12506
  const [busy, setBusy] = (0, react.useState)(false);
12349
12507
  const request = (0, react.useRef)(0);
@@ -12352,10 +12510,7 @@ void main(){
12352
12510
  activeRef.current = active;
12353
12511
  const key = ids.join(",");
12354
12512
  const load = (force) => {
12355
- if (ids.length < 2) {
12356
- setEntries({});
12357
- return;
12358
- }
12513
+ if (ids.length === 0) return;
12359
12514
  if (!activeRef.current || document.visibilityState === "hidden") return;
12360
12515
  if (flight.current) {
12361
12516
  const current = flight.current;
@@ -12383,17 +12538,19 @@ void main(){
12383
12538
  return current.promise;
12384
12539
  };
12385
12540
  (0, react.useEffect)(() => {
12386
- if (ids.length < 2) {
12387
- setEntries({});
12388
- setBusy(false);
12389
- }
12541
+ setEntries({});
12542
+ setBusy(false);
12390
12543
  return () => {
12391
12544
  request.current += 1;
12392
12545
  flight.current = void 0;
12393
12546
  };
12394
- }, [key, rpc]);
12547
+ }, [
12548
+ key,
12549
+ revision,
12550
+ rpc
12551
+ ]);
12395
12552
  (0, react.useEffect)(() => {
12396
- if (ids.length < 2 || !active) return void 0;
12553
+ if (ids.length === 0 || !active) return void 0;
12397
12554
  let timer;
12398
12555
  const stop = () => {
12399
12556
  clearInterval(timer);
@@ -12403,7 +12560,7 @@ void main(){
12403
12560
  const wake = () => {
12404
12561
  stop();
12405
12562
  if (document.visibilityState === "hidden") return;
12406
- again();
12563
+ load(true);
12407
12564
  timer = setInterval(again, 6e4);
12408
12565
  };
12409
12566
  wake();
@@ -12416,6 +12573,7 @@ void main(){
12416
12573
  };
12417
12574
  }, [
12418
12575
  key,
12576
+ revision,
12419
12577
  active,
12420
12578
  rpc
12421
12579
  ]);
@@ -12425,27 +12583,43 @@ void main(){
12425
12583
  refresh: () => load(true)
12426
12584
  };
12427
12585
  }
12428
- function AccountQuota({ entry, loading, t }) {
12429
- if (entry === void 0) return loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
12430
- className: "codexSubscriptionAccountQuota",
12431
- children: t("accountQuotaLoading")
12432
- }) : null;
12433
- if (entry.error !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
12434
- className: "codexSubscriptionAccountQuota",
12435
- "data-state": "error",
12436
- children: entry.error === "ChatGPT sign-in needs to be renewed" ? t("resetRenewLogin") : t("accountQuotaError")
12586
+ function AccountQuota({ entry, loading, showQuota, t }) {
12587
+ const state = entry === void 0 ? loading ? "loading" : "unknown" : entry.error === "ChatGPT sign-in needs to be renewed" ? "disconnected" : entry.error !== void 0 || entry.usage === void 0 ? "unknown" : "connected";
12588
+ const label = {
12589
+ connected: "accountVerified",
12590
+ disconnected: "accountRenewSignIn",
12591
+ loading: "accountVerifying",
12592
+ unknown: "accountUnverified"
12593
+ }[state];
12594
+ const status = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
12595
+ className: "codexSubscriptionStatus",
12596
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12597
+ className: "codexSubscriptionDot",
12598
+ "data-state": state,
12599
+ "aria-hidden": "true"
12600
+ }), t(label)]
12437
12601
  });
12438
- const windows = entry.usage?.rateLimits?.find((limit) => limit.id === "codex")?.windows ?? [];
12439
- if (windows.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
12602
+ if (entry?.error !== void 0 && state !== "disconnected") {
12603
+ const message = accessFailureText(entry.error, t);
12604
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", {
12605
+ className: "codexSubscriptionAccountQuota",
12606
+ role: "status",
12607
+ children: [status, message !== entry.error ? message : null]
12608
+ });
12609
+ }
12610
+ if (state !== "connected" || !showQuota) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
12440
12611
  className: "codexSubscriptionAccountQuota",
12441
- children: t("accountQuotaNone")
12612
+ role: "status",
12613
+ children: status
12442
12614
  });
12443
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
12615
+ const windows = entry.usage?.rateLimits?.find((limit) => limit.id === "codex")?.windows ?? [];
12616
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", {
12444
12617
  className: "codexSubscriptionAccountQuota",
12445
- children: windows.map((window) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [fill(t("accountQuotaLeft"), {
12618
+ role: "status",
12619
+ children: [status, windows.length === 0 ? t("accountQuotaNone") : windows.map((window) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [fill(t("accountQuotaLeft"), {
12446
12620
  label: windowLabel(window.windowSeconds, t),
12447
12621
  value: percent(window.remainingPercent)
12448
- }), window.resetsAt === void 0 ? "" : ` · ${fill(t("accountQuotaResets"), { value: when(window.resetsAt) })}`] }, window.windowSeconds))
12622
+ }), window.resetsAt === void 0 ? "" : ` · ${fill(t("accountQuotaResets"), { value: when(window.resetsAt) })}`] }, window.windowSeconds))]
12449
12623
  });
12450
12624
  }
12451
12625
  //#endregion
@@ -12454,7 +12628,8 @@ void main(){
12454
12628
  "account-claim",
12455
12629
  "network",
12456
12630
  "token-exchange",
12457
- "callback"
12631
+ "callback",
12632
+ "account-mismatch"
12458
12633
  ];
12459
12634
  function AccountEmail({ candidate, fallback, t, emailVisible, onClick }) {
12460
12635
  if (typeof candidate?.email !== "string" || candidate.email.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -12471,11 +12646,13 @@ void main(){
12471
12646
  });
12472
12647
  }
12473
12648
  const signedInIds = (account) => account?.authenticated === true ? (account.accounts ?? []).map((candidate) => candidate.id).filter((id) => typeof id === "string") : [];
12474
- function AccountCard({ rpc, t, account, setAccount, onSignedOut, active = true }) {
12649
+ function AccountCard({ rpc, t, account, setAccount, onSignedOut, active = true, revision }) {
12475
12650
  const [flow, setFlow] = (0, react.useState)();
12476
12651
  const flowGeneration = (0, react.useRef)(0);
12477
12652
  const [manualCode, setManualCode] = (0, react.useState)("");
12478
12653
  const [adding, setAdding] = (0, react.useState)(false);
12654
+ const [renewId, setRenewId] = (0, react.useState)();
12655
+ const accountFlow = adding || renewId !== void 0;
12479
12656
  const [removeId, setRemoveId] = (0, react.useState)();
12480
12657
  const [confirmSignOut, setConfirmSignOut] = (0, react.useState)(false);
12481
12658
  const [emailVisible, setEmailVisible] = (0, react.useState)(false);
@@ -12484,7 +12661,7 @@ void main(){
12484
12661
  const [emailVisibilityKey, setEmailVisibilityKey] = (0, react.useState)(accountVisibilityKey);
12485
12662
  const [busy, setBusy] = (0, react.useState)(false);
12486
12663
  const [error, setError] = (0, react.useState)();
12487
- const quotas = useAccountQuotas(rpc, signedInIds(account), active);
12664
+ const quotas = useAccountQuotas(rpc, signedInIds(account), active, revision);
12488
12665
  const call = (endpoint, payload = {}) => recoveryCall(rpc, endpoint, payload);
12489
12666
  (0, react.useEffect)(() => {
12490
12667
  if (emailVisibilityKey === accountVisibilityKey) return;
@@ -12492,18 +12669,14 @@ void main(){
12492
12669
  setEmailVisibilityKey(accountVisibilityKey);
12493
12670
  }, [accountVisibilityKey, emailVisibilityKey]);
12494
12671
  (0, react.useEffect)(() => {
12495
- if (busy || flow?.id === void 0 || [
12496
- "authenticated",
12497
- "failed",
12498
- "cancelled"
12499
- ].includes(flow.phase)) return void 0;
12672
+ if (busy || flow?.id === void 0 || ["failed", "cancelled"].includes(flow.phase)) return void 0;
12500
12673
  let live = true;
12501
12674
  let reading = false;
12502
12675
  const generation = flowGeneration.current;
12503
12676
  const timer = window.setInterval(() => {
12504
12677
  if (reading) return;
12505
12678
  reading = true;
12506
- (adding ? call("login/status", { id: flow.id }).then(async (nextFlow) => ({
12679
+ (accountFlow ? call("login/status", { id: flow.id }).then(async (nextFlow) => ({
12507
12680
  flow: nextFlow,
12508
12681
  account: nextFlow.phase === "authenticated" ? await call("status") : void 0
12509
12682
  })) : readLoginProgress({
@@ -12518,6 +12691,8 @@ void main(){
12518
12691
  setAccount(next.account);
12519
12692
  onSignedOut();
12520
12693
  setAdding(false);
12694
+ setRenewId(void 0);
12695
+ setEmailVisible(false);
12521
12696
  setFlow(void 0);
12522
12697
  notifyQuickQuota();
12523
12698
  }
@@ -12534,19 +12709,18 @@ void main(){
12534
12709
  }, [
12535
12710
  flow?.id,
12536
12711
  flow?.phase,
12537
- adding,
12712
+ accountFlow,
12538
12713
  busy
12539
12714
  ]);
12540
- const begin = (method, label) => {
12715
+ const begin = (method, target = adding ? { label: `Account ${accounts.length + 1}` } : {}) => {
12541
12716
  flowGeneration.current += 1;
12542
12717
  setFlow(void 0);
12543
12718
  setBusy(true);
12544
12719
  setError(void 0);
12545
- const loginLabel = adding && label === void 0 ? `Account ${accounts.length + 1}` : label;
12546
12720
  call("login/start", {
12547
12721
  method,
12548
12722
  openExternal: true,
12549
- ...loginLabel === void 0 ? {} : { label: loginLabel }
12723
+ ...target
12550
12724
  }).then(setFlow).catch(() => setError(t("failed"))).finally(() => setBusy(false));
12551
12725
  };
12552
12726
  const cancel = () => {
@@ -12555,9 +12729,12 @@ void main(){
12555
12729
  setBusy(true);
12556
12730
  setError(void 0);
12557
12731
  call("login/cancel", { id: flow.id }).then((next) => {
12558
- setFlow(adding ? void 0 : next);
12559
- if (adding) setAdding(false);
12560
- if (adding) return void 0;
12732
+ setFlow(accountFlow ? void 0 : next);
12733
+ if (accountFlow) {
12734
+ setAdding(false);
12735
+ setRenewId(void 0);
12736
+ return;
12737
+ }
12561
12738
  return call("status").then((account) => {
12562
12739
  if (account.authenticated === true) {
12563
12740
  setAccount(account);
@@ -12630,20 +12807,106 @@ void main(){
12630
12807
  setEmailVisible((value) => emailVisibilityKey === accountVisibilityKey ? !value : true);
12631
12808
  };
12632
12809
  const emailVisibleForAccount = emailVisible && emailVisibilityKey === accountVisibilityKey;
12810
+ const loginContent = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
12811
+ flow?.phase === "waiting_device" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12812
+ className: "codexSubscriptionFlow",
12813
+ children: [
12814
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("deviceHint") }),
12815
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
12816
+ className: "codexSubscriptionCode",
12817
+ children: flow.deviceCode?.userCode
12818
+ }),
12819
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
12820
+ href: flow.deviceCode?.verificationUri,
12821
+ target: "_blank",
12822
+ rel: "noreferrer",
12823
+ children: t("openLogin")
12824
+ }),
12825
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("waiting") }),
12826
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12827
+ type: "button",
12828
+ variant: "outline",
12829
+ disabled: busy,
12830
+ onClick: cancel,
12831
+ children: t("cancel")
12832
+ })
12833
+ ]
12834
+ }) : null,
12835
+ flow?.phase === "waiting_input" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
12836
+ className: "codexSubscriptionFlow",
12837
+ onSubmit: submit,
12838
+ children: [
12839
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("manualCode") }),
12840
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input, {
12841
+ className: "codexSubscriptionInput",
12842
+ value: manualCode,
12843
+ onChange: (event) => setManualCode(event.currentTarget.value),
12844
+ autoComplete: "off",
12845
+ spellCheck: false
12846
+ }),
12847
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12848
+ className: "codexSubscriptionActions",
12849
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12850
+ type: "submit",
12851
+ variant: "primary",
12852
+ disabled: busy || manualCode.trim() === "",
12853
+ children: t("submit")
12854
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12855
+ type: "button",
12856
+ variant: "outline",
12857
+ disabled: busy,
12858
+ onClick: cancel,
12859
+ children: t("cancel")
12860
+ })]
12861
+ })
12862
+ ]
12863
+ }) : null,
12864
+ renewId !== void 0 && busy && flow === void 0 || ["starting", "waiting_browser"].includes(flow?.phase) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12865
+ className: "codexSubscriptionFlow",
12866
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12867
+ role: "status",
12868
+ children: t(renewId === void 0 ? "waiting" : "renewAccountHint")
12869
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12870
+ className: "codexSubscriptionActions",
12871
+ children: [
12872
+ flow?.authUrl === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
12873
+ href: flow.authUrl,
12874
+ target: "_blank",
12875
+ rel: "noreferrer",
12876
+ children: t("openLogin")
12877
+ }),
12878
+ renewId === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12879
+ type: "button",
12880
+ variant: "outline",
12881
+ disabled: busy,
12882
+ onClick: () => begin("device_code", { renewId }),
12883
+ children: t("deviceLogin")
12884
+ }),
12885
+ flow === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12886
+ type: "button",
12887
+ variant: "outline",
12888
+ disabled: busy,
12889
+ onClick: cancel,
12890
+ children: t("cancel")
12891
+ })
12892
+ ]
12893
+ })]
12894
+ }) : null,
12895
+ flow?.phase === "failed" || error !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12896
+ className: "codexSubscriptionError",
12897
+ role: "alert",
12898
+ children: error ?? (isAccessFailureMessage(flow?.error) ? accessFailureText(flow.error, t) : LOGIN_FAILURES.includes(flow?.failure) ? t(`failed_${flow.failure.replace("-", "_")}`) : t("failed"))
12899
+ }) : null
12900
+ ] });
12633
12901
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12634
12902
  className: "codexSubscriptionCard",
12635
12903
  children: [
12636
12904
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12637
12905
  className: "codexSubscriptionAccountRow",
12638
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12906
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12639
12907
  className: "codexSubscriptionStatus",
12640
12908
  role: "status",
12641
- "aria-live": "polite",
12642
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12643
- className: "codexSubscriptionDot",
12644
- "data-state": accountReady ? signedIn ? "connected" : "disconnected" : "loading",
12645
- "aria-hidden": "true"
12646
- }), accountReady ? signedIn ? t("connected") : t("disconnected") : t("accountLoading")]
12909
+ children: accountReady ? signedIn ? t("savedAccounts") : t("disconnected") : t("accountLoading")
12647
12910
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12648
12911
  className: "codexSubscriptionActions",
12649
12912
  children: signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
@@ -12652,6 +12915,8 @@ void main(){
12652
12915
  disabled: busy || loginVisible,
12653
12916
  onClick: () => {
12654
12917
  setFlow(void 0);
12918
+ setError(void 0);
12919
+ setRenewId(void 0);
12655
12920
  setAdding(true);
12656
12921
  },
12657
12922
  children: t("addAccount")
@@ -12671,7 +12936,7 @@ void main(){
12671
12936
  variant: "outline",
12672
12937
  disabled: busy || loginVisible,
12673
12938
  onClick: () => setConfirmSignOut(true),
12674
- children: t("signOutAll")
12939
+ children: t(accounts.length > 1 ? "signOutAll" : "logout")
12675
12940
  })] }) : accountReady && (flow === void 0 || ["failed", "cancelled"].includes(flow.phase)) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12676
12941
  type: "button",
12677
12942
  variant: "primary",
@@ -12689,51 +12954,67 @@ void main(){
12689
12954
  }),
12690
12955
  signedIn && accounts.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12691
12956
  className: "codexSubscriptionAccounts",
12692
- children: accounts.map((candidate) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12693
- className: "codexSubscriptionAccount",
12694
- "data-active": candidate.active,
12695
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12696
- className: "codexSubscriptionAccountMain",
12697
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountEmail, {
12698
- candidate,
12699
- fallback: candidate.label,
12700
- t,
12701
- emailVisible: emailVisibleForAccount,
12702
- onClick: toggleEmail
12703
- }), accounts.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountQuota, {
12704
- entry: quotas.entries[candidate.id],
12705
- loading: quotas.busy,
12706
- t
12707
- }) : null]
12708
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12709
- className: "codexSubscriptionActions",
12710
- children: [
12711
- candidate.active ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12712
- type: "button",
12713
- variant: "outline",
12714
- disabled: busy || loginVisible,
12715
- onClick: () => selectAccount(candidate.id),
12716
- children: t("switchAccount")
12717
- }),
12718
- accounts.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12719
- type: "button",
12720
- variant: "outline",
12721
- disabled: busy || loginVisible,
12722
- onClick: () => removeAccount(candidate.id),
12723
- children: removeId === candidate.id ? t("removeConfirm") : t("removeAccount")
12724
- }) : null,
12725
- removeId === candidate.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12726
- type: "button",
12727
- variant: "outline",
12728
- disabled: busy,
12729
- onClick: () => setRemoveId(void 0),
12730
- children: t("removeCancel")
12731
- }) : null
12732
- ]
12733
- })]
12734
- }, candidate.id))
12957
+ children: accounts.map((candidate) => {
12958
+ const entry = quotas.entries[candidate.id];
12959
+ const disabled = busy || loginVisible;
12960
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12961
+ className: "codexSubscriptionAccount",
12962
+ "data-active": candidate.active,
12963
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12964
+ className: "codexSubscriptionAccountMain",
12965
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountEmail, {
12966
+ candidate,
12967
+ fallback: candidate.label,
12968
+ t,
12969
+ emailVisible: emailVisibleForAccount,
12970
+ onClick: toggleEmail
12971
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountQuota, {
12972
+ entry,
12973
+ loading: quotas.busy,
12974
+ showQuota: accounts.length > 1,
12975
+ t
12976
+ })]
12977
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12978
+ className: "codexSubscriptionActions",
12979
+ children: [
12980
+ entry?.error === "ChatGPT sign-in needs to be renewed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12981
+ type: "button",
12982
+ variant: "outline",
12983
+ disabled,
12984
+ onClick: () => {
12985
+ setAdding(false);
12986
+ setRenewId(candidate.id);
12987
+ begin("browser", { renewId: candidate.id });
12988
+ },
12989
+ children: t("renewAccount")
12990
+ }) : null,
12991
+ candidate.active ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12992
+ type: "button",
12993
+ variant: "outline",
12994
+ disabled,
12995
+ onClick: () => selectAccount(candidate.id),
12996
+ children: t("switchAccount")
12997
+ }),
12998
+ accounts.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12999
+ type: "button",
13000
+ variant: "outline",
13001
+ disabled,
13002
+ onClick: () => removeAccount(candidate.id),
13003
+ children: removeId === candidate.id ? t("removeConfirm") : t("removeAccount")
13004
+ }) : null,
13005
+ removeId === candidate.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
13006
+ type: "button",
13007
+ variant: "outline",
13008
+ disabled: busy,
13009
+ onClick: () => setRemoveId(void 0),
13010
+ children: t("removeCancel")
13011
+ }) : null
13012
+ ]
13013
+ })]
13014
+ }), renewId === candidate.id ? loginContent : null] }, candidate.id);
13015
+ })
12735
13016
  }) : null,
12736
- signedIn && adding && flow === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
13017
+ signedIn && adding && !loginVisible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12737
13018
  className: "codexSubscriptionFlow",
12738
13019
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12739
13020
  className: "codexSubscriptionActions",
@@ -12756,89 +13037,18 @@ void main(){
12756
13037
  type: "button",
12757
13038
  variant: "outline",
12758
13039
  disabled: busy,
12759
- onClick: () => setAdding(false),
13040
+ onClick: () => {
13041
+ setAdding(false);
13042
+ setRenewId(void 0);
13043
+ setFlow(void 0);
13044
+ setError(void 0);
13045
+ },
12760
13046
  children: t("cancel")
12761
13047
  })
12762
13048
  ]
12763
13049
  })
12764
13050
  }) : null,
12765
- flow?.phase === "waiting_device" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12766
- className: "codexSubscriptionFlow",
12767
- children: [
12768
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("deviceHint") }),
12769
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
12770
- className: "codexSubscriptionCode",
12771
- children: flow.deviceCode?.userCode
12772
- }),
12773
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
12774
- href: flow.deviceCode?.verificationUri,
12775
- target: "_blank",
12776
- rel: "noreferrer",
12777
- children: t("openLogin")
12778
- }),
12779
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("waiting") }),
12780
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12781
- type: "button",
12782
- variant: "outline",
12783
- disabled: busy,
12784
- onClick: cancel,
12785
- children: t("cancel")
12786
- })
12787
- ]
12788
- }) : null,
12789
- flow?.phase === "waiting_input" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
12790
- className: "codexSubscriptionFlow",
12791
- onSubmit: submit,
12792
- children: [
12793
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("manualCode") }),
12794
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Input, {
12795
- className: "codexSubscriptionInput",
12796
- value: manualCode,
12797
- onChange: (event) => setManualCode(event.currentTarget.value),
12798
- autoComplete: "off",
12799
- spellCheck: false
12800
- }),
12801
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12802
- className: "codexSubscriptionActions",
12803
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12804
- type: "submit",
12805
- variant: "primary",
12806
- disabled: busy || manualCode.trim() === "",
12807
- children: t("submit")
12808
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12809
- type: "button",
12810
- variant: "outline",
12811
- disabled: busy,
12812
- onClick: cancel,
12813
- children: t("cancel")
12814
- })]
12815
- })
12816
- ]
12817
- }) : null,
12818
- flow !== void 0 && ["starting", "waiting_browser"].includes(flow.phase) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
12819
- className: "codexSubscriptionFlow",
12820
- children: [
12821
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("waiting") }),
12822
- flow.authUrl === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
12823
- href: flow.authUrl,
12824
- target: "_blank",
12825
- rel: "noreferrer",
12826
- children: t("openLogin")
12827
- }),
12828
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
12829
- type: "button",
12830
- variant: "outline",
12831
- disabled: busy,
12832
- onClick: cancel,
12833
- children: t("cancel")
12834
- })
12835
- ]
12836
- }) : null,
12837
- flow?.phase === "failed" || error !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
12838
- className: "codexSubscriptionError",
12839
- role: "alert",
12840
- children: error ?? (LOGIN_FAILURES.includes(flow?.failure) ? t(`failed_${flow.failure.replace("-", "_")}`) : t("failed"))
12841
- }) : null
13051
+ renewId === void 0 ? loginContent : null
12842
13052
  ]
12843
13053
  });
12844
13054
  }
@@ -13081,7 +13291,7 @@ void main(){
13081
13291
  state.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
13082
13292
  className: "codexSubscriptionError",
13083
13293
  role: "alert",
13084
- children: state.message
13294
+ children: accessFailureText(state.message, t)
13085
13295
  }) : null,
13086
13296
  state.status === "ready" && stats.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
13087
13297
  className: "codexSubscriptionEmpty",
@@ -13223,7 +13433,7 @@ void main(){
13223
13433
  }) : null, state.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
13224
13434
  className: "codexSubscriptionError",
13225
13435
  role: "alert",
13226
- children: state.message
13436
+ children: accessFailureText(state.message, t)
13227
13437
  }) : null]
13228
13438
  }),
13229
13439
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -13322,13 +13532,14 @@ void main(){
13322
13532
  (0, react.useEffect)(() => {
13323
13533
  let live = true;
13324
13534
  setState("loading");
13325
- setCredits([]);
13326
13535
  rpc.call(CHANNEL, "reset-credit/inspect", {}).then(unwrap).then((value) => {
13327
13536
  if (!live) return;
13328
13537
  setCredits(Array.isArray(value.credits) ? value.credits : []);
13329
13538
  setState("ready");
13330
- }).catch(() => {
13331
- if (live) setState("error");
13539
+ }).catch((error) => {
13540
+ if (!live) return;
13541
+ if (["No quota reset is available", "No usable quota reset is available"].includes(error?.message)) setCredits([]);
13542
+ setState("error");
13332
13543
  });
13333
13544
  return () => {
13334
13545
  live = false;
@@ -13498,6 +13709,7 @@ void main(){
13498
13709
  });
13499
13710
  }
13500
13711
  function resetCreditErrorText(error, t) {
13712
+ if (isAccessFailureMessage(error?.message)) return accessFailureText(error.message, t);
13501
13713
  return t((/* @__PURE__ */ new Map([
13502
13714
  ["ChatGPT subscription is not signed in", "resetRenewLogin"],
13503
13715
  ["ChatGPT sign-in needs to be renewed", "resetRenewLogin"],
@@ -13572,7 +13784,7 @@ void main(){
13572
13784
  error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
13573
13785
  className: "codexSubscriptionError",
13574
13786
  role: "alert",
13575
- children: error
13787
+ children: usageFailureText(error, t)
13576
13788
  }),
13577
13789
  visibleUsage?.spendControlReached === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
13578
13790
  className: "codexSubscriptionError",
@@ -13828,7 +14040,20 @@ void main(){
13828
14040
  children: items
13829
14041
  });
13830
14042
  }
13831
- function CodexSection({ preference, rpc, accountStatus, t, diagnostics, defaultModel }) {
14043
+ function ProjectLink({ t }) {
14044
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
14045
+ variant: "outline",
14046
+ size: "sm",
14047
+ title: t("projectHomepage"),
14048
+ onClick: () => window.open(PROJECT_URL, "_blank", "noopener,noreferrer"),
14049
+ children: "GitHub"
14050
+ });
14051
+ }
14052
+ /** The host owns the header and its layout; contribute only to our bundle. */
14053
+ function ProjectAction({ subject, t }) {
14054
+ return subject?.kind === "bundle" && subject.pkg.name === "dsh-codex-subscription" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectLink, { t }) : null;
14055
+ }
14056
+ function CodexSection({ preference, rpc, accountStatus, t, diagnostics, defaultModel, embedded = false }) {
13832
14057
  const [tab, setTab] = (0, react.useState)("start");
13833
14058
  const [visited, setVisited] = (0, react.useState)(() => /* @__PURE__ */ new Set(["start"]));
13834
14059
  const selectTab = (value) => {
@@ -13859,10 +14084,11 @@ void main(){
13859
14084
  }, [accountStatus, preference]);
13860
14085
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
13861
14086
  className: "codexSubscription",
14087
+ "data-embedded": embedded || void 0,
13862
14088
  children: [
13863
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14089
+ embedded ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
13864
14090
  className: "codexSubscriptionHead",
13865
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: t("title") })
14091
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: t("title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProjectLink, { t })]
13866
14092
  }),
13867
14093
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
13868
14094
  className: "codexSettingsTabs",
@@ -13913,7 +14139,8 @@ void main(){
13913
14139
  account,
13914
14140
  setAccount,
13915
14141
  onSignedOut: accountChanged,
13916
- active: tab === "start"
14142
+ active: tab === "start",
14143
+ revision: resetKey
13917
14144
  }),
13918
14145
  account === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageCard, {
13919
14146
  rpc,
@@ -13987,6 +14214,40 @@ void main(){
13987
14214
  });
13988
14215
  }
13989
14216
  //#endregion
14217
+ //#region src/subscription-settings-entry.js
14218
+ const PACKAGE_NAME = "dsh-codex-subscription";
14219
+ /** Both host surfaces use the same controllers, RPC client and quota cache. */
14220
+ function registerSubscriptionSettings(ctx, shared, Section, ProjectAction) {
14221
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
14222
+ name: "settings.section",
14223
+ id: "codex-subscription",
14224
+ order: 15,
14225
+ label: () => shared.t("nav"),
14226
+ locale: "settings.codexSubscription",
14227
+ inject: () => shared
14228
+ }, Section));
14229
+ ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
14230
+ name: "plugins.bundle.config",
14231
+ key: PACKAGE_NAME,
14232
+ locale: "settings.codexSubscription",
14233
+ inject: () => ({
14234
+ ...shared,
14235
+ embedded: true
14236
+ })
14237
+ }, Section));
14238
+ ctx.slots.inject("plugins.detail.actions", () => ctx.slots.register({
14239
+ name: "plugins.detail.actions",
14240
+ id: "codex-subscription-project",
14241
+ locale: "settings.codexSubscription",
14242
+ inject: () => ({ t: shared.t })
14243
+ }, ProjectAction));
14244
+ }
14245
+ /** Optional host navigation: older deployments retain their original settings entry. */
14246
+ function subscriptionSettingsOpener(ctx) {
14247
+ const navigation = ctx.get("pluginNavigation");
14248
+ return typeof navigation?.openBundle === "function" ? () => navigation.openBundle(PACKAGE_NAME) : void 0;
14249
+ }
14250
+ //#endregion
13990
14251
  //#region src/diagnostic-checks.js
13991
14252
  const states = /* @__PURE__ */ new Set([
13992
14253
  "pass",
@@ -14574,21 +14835,14 @@ void main(){
14574
14835
  t
14575
14836
  })
14576
14837
  }, DeferredImageViewer));
14577
- ctx.slots.inject("settings.section", () => ctx.slots.register({
14578
- name: "settings.section",
14579
- id: "codex-subscription",
14580
- order: 15,
14581
- label: () => t("nav"),
14582
- locale: NS,
14583
- inject: () => ({
14584
- preference,
14585
- rpc,
14586
- accountStatus,
14587
- t,
14588
- diagnostics,
14589
- defaultModel
14590
- })
14591
- }, CodexSection));
14838
+ registerSubscriptionSettings(ctx, {
14839
+ preference,
14840
+ rpc,
14841
+ accountStatus,
14842
+ t,
14843
+ diagnostics,
14844
+ defaultModel
14845
+ }, CodexSection, ProjectAction);
14592
14846
  const sessions = ctx.get("sessions");
14593
14847
  const rootDirectories = ctx.get("modelDirectories");
14594
14848
  let scopedDirectories;
@@ -14602,6 +14856,7 @@ void main(){
14602
14856
  preference,
14603
14857
  rpc,
14604
14858
  t,
14859
+ openSettings: subscriptionSettingsOpener(ctx),
14605
14860
  directory: (scopedDirectories ?? rootDirectories).directoryFor(sessionId).store
14606
14861
  })
14607
14862
  }, ComposerRight));
@@ -14728,7 +14983,7 @@ void main(){
14728
14983
  if (!preference.getSnapshot().imageEditing) throw new Error("Image editing is disabled");
14729
14984
  const ids = input.state.getSnapshot().attachmentIds;
14730
14985
  if (operation.sourceId && Array.isArray(ids) && !ids.includes(operation.sourceId)) throw new Error("The source attachment was removed");
14731
- if (files.length) attachImageFiles(conversation, input, files, sessionId);
14986
+ if (files.length) attachImageFiles(conversation, input, files, sessionId, { uploadImages: sessions.subagentAddress(sessionId) === void 0 });
14732
14987
  openComposerSession(sessions, ctx.get("uiWorkspace"), sessionId);
14733
14988
  if (sourceInDraft && !annotations.length && !tool) return;
14734
14989
  if (!input.state.getSnapshot().draft.trim()) input.setDraft(draft);
@@ -14748,7 +15003,7 @@ void main(){
14748
15003
  ]) ctx.slots.inject(name, () => {
14749
15004
  let dispose;
14750
15005
  const sync = () => {
14751
- if (preference.getSnapshot().imageViewer && (component !== ComposerImagePreviews || nativeAttachments())) dispose ??= ctx.slots.register({
15006
+ if (needsSubscriptionImageEnhancement(preference.getSnapshot()) && (component !== ComposerImagePreviews || nativeAttachments())) dispose ??= ctx.slots.register({
14752
15007
  name,
14753
15008
  priority: -10,
14754
15009
  inject: (sessionId) => ({
@@ -14791,7 +15046,7 @@ void main(){
14791
15046
  attachSketch: (blob) => {
14792
15047
  const current = preference.getSnapshot();
14793
15048
  if (!current.imageSketch || !current.imageEditing) throw new Error("Sketch editing is disabled");
14794
- attachImageFiles(conversation, sessionInput(sessionId), [new File([blob], "sketch-reference.png", { type: "image/png" })], sessionId);
15049
+ attachImageFiles(conversation, sessionInput(sessionId), [new File([blob], "sketch-reference.png", { type: "image/png" })], sessionId, { uploadImages: sessions.subagentAddress(sessionId) === void 0 });
14795
15050
  }
14796
15051
  })
14797
15052
  }, ImageWorkspace));