dsh-codex-subscription 3.1.6 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +10 -6
- package/README.md +9 -7
- package/lib/client.js +731 -292
- package/lib/index.js +973 -263
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -7147,6 +7147,20 @@ window.__ModuleLoader__.load({
|
|
|
7147
7147
|
//#endregion
|
|
7148
7148
|
//#region src/client-locales.js
|
|
7149
7149
|
const zh = {
|
|
7150
|
+
voiceMediaHint: "窗口不支持 WebRTC 时,可在浏览器中继续同一会话。音色试听不受影响,仍使用当前订阅,无需 API Key。",
|
|
7151
|
+
voiceBrowserContinue: "在浏览器继续此会话",
|
|
7152
|
+
voiceBrowserCopy: "复制会话链接",
|
|
7153
|
+
voiceBrowserCopied: "已复制",
|
|
7154
|
+
voiceBrowserCopyFailed: "复制失败,请手动复制链接",
|
|
7155
|
+
voicePreviewSignIn: "试听需要重新登录 ChatGPT,请登录后再试。",
|
|
7156
|
+
voiceCatalogFailed: "语音目录加载失败,请检查网络后重试;这不表示该音色没有样本。",
|
|
7157
|
+
voiceDownloadFailed: "试听音频下载失败,请重试。",
|
|
7158
|
+
voicePlaybackFailed: "音频已取得,但播放失败。请检查浏览器的声音权限后重试。",
|
|
7159
|
+
voicePreviewFailed: "试听加载失败,请检查连接后重试。",
|
|
7160
|
+
voiceWebRTCUnavailable: "此窗口不支持语音通话所需的 WebRTC。请在支持 WebRTC 的浏览器中打开同一 DSH 会话;音色试听仍可使用。",
|
|
7161
|
+
voiceInsecure: "语音需要安全连接。请通过 HTTPS 或本机 localhost 打开 DSH。",
|
|
7162
|
+
voiceMicUnavailable: "此窗口无法使用麦克风。请在支持麦克风的浏览器中打开 DSH。",
|
|
7163
|
+
voiceMicMissing: "未找到可用麦克风,请检查设备连接。",
|
|
7150
7164
|
"diagnosticsSnapshotTime": "报告快照时间:",
|
|
7151
7165
|
"diagnosticsUnresolved": "仍有其他未恢复的失败记录,见上方摘要。",
|
|
7152
7166
|
"diagnosticSeverity_warning": "需关注",
|
|
@@ -7579,6 +7593,8 @@ window.__ModuleLoader__.load({
|
|
|
7579
7593
|
searchDomainCount: "个域名",
|
|
7580
7594
|
catalogRefresh: "刷新模型",
|
|
7581
7595
|
catalogOnline: "已加载账户在线模型目录",
|
|
7596
|
+
catalogCached: "正在使用本地保存的账户模型目录",
|
|
7597
|
+
catalogCachedFailed: "正在使用本地模型目录,在线更新失败。",
|
|
7582
7598
|
catalogSignedOut: "登录后显示账户可用的模型。",
|
|
7583
7599
|
catalogLoading: "正在读取账户模型目录…",
|
|
7584
7600
|
catalogFailed: "无法读取账户模型目录,请检查网络后重试。",
|
|
@@ -7711,7 +7727,7 @@ window.__ModuleLoader__.load({
|
|
|
7711
7727
|
historyPeriods: "额度周期",
|
|
7712
7728
|
historyUsed: "这个周期已用 {value}% 的额度",
|
|
7713
7729
|
historyPartial: "(统计尚未完成)",
|
|
7714
|
-
historyApproximate: "
|
|
7730
|
+
historyApproximate: "数据来自官方用量报告,可能不完整或延迟更新。",
|
|
7715
7731
|
historyBy_model: "按模型",
|
|
7716
7732
|
historyBy_surface: "按入口",
|
|
7717
7733
|
historyBy_thread_source: "按来源",
|
|
@@ -7799,7 +7815,7 @@ window.__ModuleLoader__.load({
|
|
|
7799
7815
|
quickQuotaBeta: "Beta",
|
|
7800
7816
|
autoQuotaRetry: "额度重置后自动重试",
|
|
7801
7817
|
autoQuotaRetryHint: "开启后,等待已确认的短时额度重置;对话会显示等待原因且可停止,等待期间切换账号会立即重试。",
|
|
7802
|
-
quickQuotaForecastHint: "
|
|
7818
|
+
quickQuotaForecastHint: "按最近两小时的用量估算何时用完;稳定时显示时间范围,变化后先校准或给粗估。未来用量变化会影响结果,仅供参考。历史保存在本机。",
|
|
7803
7819
|
contextTitle: "上下文窗口",
|
|
7804
7820
|
contextStandard: "标准",
|
|
7805
7821
|
contextStandardHint: "使用模型目录默认值;官方 Agent 预设会自动管理上下文。",
|
|
@@ -7855,8 +7871,8 @@ window.__ModuleLoader__.load({
|
|
|
7855
7871
|
diagnosticsAdvanced: "完整诊断(高级)",
|
|
7856
7872
|
historyAsOf: "数据截至 {date}",
|
|
7857
7873
|
historyPending: "还在统计中",
|
|
7858
|
-
historyPendingCurrent: "
|
|
7859
|
-
historyPendingPast: "
|
|
7874
|
+
historyPendingCurrent: "官方尚未提供这一周期的统计结果,稍后可刷新查看。",
|
|
7875
|
+
historyPendingPast: "官方尚未统计出这一周期的用量;报告数据截至 {date},稍后可刷新查看。",
|
|
7860
7876
|
triggerSketchName: "草图 · Beta",
|
|
7861
7877
|
triggerSketchHint: "让 Agent 画图或改图",
|
|
7862
7878
|
triggerImageName: "生图",
|
|
@@ -7924,11 +7940,29 @@ window.__ModuleLoader__.load({
|
|
|
7924
7940
|
quickQuotaForecastIdle: "用量稳定",
|
|
7925
7941
|
quickQuotaForecastIdleStatus: "Codex 剩余额度 {value}%,当前没有可测量的消耗速度",
|
|
7926
7942
|
quickQuotaForecastUntilReset: "够用到重置",
|
|
7927
|
-
quickQuotaForecastUntilResetStatus: "Codex 剩余额度 {value}
|
|
7943
|
+
quickQuotaForecastUntilResetStatus: "Codex 剩余额度 {value}%,按最近用量,预计可用到重置",
|
|
7928
7944
|
quotaForecast: "按当前速度 {symbol}{duration}",
|
|
7945
|
+
quotaForecastAt: "按最近用量,预计{when}用完",
|
|
7946
|
+
quotaForecastRoughAt: "按最近用量,粗估{when}左右用完",
|
|
7947
|
+
quotaExhausted: "额度已用尽",
|
|
7948
|
+
pacePart_early: "凌晨",
|
|
7949
|
+
quotaWhenToday: "{day}{part}",
|
|
7950
|
+
quotaWhenTonight: "{day}{part}",
|
|
7951
|
+
quotaWhenEarlyToday: "{day}{part}",
|
|
7952
|
+
quotaWhenEarly: "{day}{part}",
|
|
7953
|
+
quotaWhenRangeEnd: "{part}",
|
|
7954
|
+
quotaWhenRange: "{from}至{to}",
|
|
7955
|
+
quotaWhenEarlyMorningRange: "{from}至{to}",
|
|
7956
|
+
historyRefresh: "刷新",
|
|
7957
|
+
historyNoBreakdown: "官方尚未提供此周期的明细",
|
|
7958
|
+
historyPendingPastUnknown: "官方尚未统计出此周期用量",
|
|
7959
|
+
fetchTitle: "网页读取来源",
|
|
7960
|
+
fetchDshHint: "使用 DSH 当前配置的网页读取服务;与上面的搜索来源分别设置。",
|
|
7961
|
+
fetchCodexHint: "通过 Codex 订阅读取可访问的网页文本。失败会直接提示,不会转到 DeepSeek API。",
|
|
7962
|
+
fetchUnavailableHint: "当前 DSH 不支持切换到 Codex 网页读取,请先升级宿主。",
|
|
7929
7963
|
quotaForecastCalibrating: "续航正在校准",
|
|
7930
7964
|
quotaForecastIdle: "当前用量稳定",
|
|
7931
|
-
quotaForecastUntilReset: "
|
|
7965
|
+
quotaForecastUntilReset: "按最近用量,预计可用到重置",
|
|
7932
7966
|
runwayDaysHours: "{days} 天 {hours}h",
|
|
7933
7967
|
runwayDays: "{days} 天",
|
|
7934
7968
|
runwayHours: "{hours}h",
|
|
@@ -7997,6 +8031,20 @@ window.__ModuleLoader__.load({
|
|
|
7997
8031
|
imageRemoveAnnotation: "删除标注"
|
|
7998
8032
|
};
|
|
7999
8033
|
const en = {
|
|
8034
|
+
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.",
|
|
8035
|
+
voiceBrowserContinue: "Continue this conversation in a browser",
|
|
8036
|
+
voiceBrowserCopy: "Copy conversation link",
|
|
8037
|
+
voiceBrowserCopied: "Copied",
|
|
8038
|
+
voiceBrowserCopyFailed: "Copy failed; copy the link manually",
|
|
8039
|
+
voicePreviewSignIn: "Sign in to ChatGPT again to load voice samples.",
|
|
8040
|
+
voiceCatalogFailed: "The voice catalog could not load. Check the connection and retry; this does not mean the voice has no sample.",
|
|
8041
|
+
voiceDownloadFailed: "The voice sample could not download. Please retry.",
|
|
8042
|
+
voicePlaybackFailed: "The audio loaded but could not play. Check browser sound permissions and retry.",
|
|
8043
|
+
voicePreviewFailed: "The voice sample could not load. Check the connection and retry.",
|
|
8044
|
+
voiceWebRTCUnavailable: "This window does not support WebRTC voice calls. Open the same DSH conversation in a WebRTC-capable browser. Voice samples remain available.",
|
|
8045
|
+
voiceInsecure: "Voice requires a secure connection. Open DSH over HTTPS or local localhost.",
|
|
8046
|
+
voiceMicUnavailable: "Microphone access is unavailable in this window. Open DSH in a browser with microphone support.",
|
|
8047
|
+
voiceMicMissing: "No microphone was found. Check the device connection.",
|
|
8000
8048
|
"diagnosticsSnapshotTime": "Report captured at:",
|
|
8001
8049
|
"diagnosticsUnresolved": "Other failures remain without a later success; see the summary.",
|
|
8002
8050
|
"diagnosticSeverity_warning": "Attention",
|
|
@@ -8429,6 +8477,8 @@ window.__ModuleLoader__.load({
|
|
|
8429
8477
|
searchDomainCount: "domains",
|
|
8430
8478
|
catalogRefresh: "Refresh models",
|
|
8431
8479
|
catalogOnline: "Account model catalog loaded",
|
|
8480
|
+
catalogCached: "Using the locally saved account model catalog",
|
|
8481
|
+
catalogCachedFailed: "Using the local model catalog; the online update failed.",
|
|
8432
8482
|
catalogSignedOut: "Sign in to show the models your account can use.",
|
|
8433
8483
|
catalogLoading: "Reading the account model catalog…",
|
|
8434
8484
|
catalogFailed: "Could not read the account model catalog. Check the network and try again.",
|
|
@@ -8561,7 +8611,7 @@ window.__ModuleLoader__.load({
|
|
|
8561
8611
|
historyPeriods: "Allowance periods",
|
|
8562
8612
|
historyUsed: "{value}% of this period's allowance used",
|
|
8563
8613
|
historyPartial: "(still being counted)",
|
|
8564
|
-
historyApproximate: "From the official usage report;
|
|
8614
|
+
historyApproximate: "From the official usage report; data may be incomplete or delayed.",
|
|
8565
8615
|
historyBy_model: "By model",
|
|
8566
8616
|
historyBy_surface: "By surface",
|
|
8567
8617
|
historyBy_thread_source: "By source",
|
|
@@ -8649,7 +8699,7 @@ window.__ModuleLoader__.load({
|
|
|
8649
8699
|
quickQuotaBeta: "Beta",
|
|
8650
8700
|
autoQuotaRetry: "Retry after quota reset",
|
|
8651
8701
|
autoQuotaRetryHint: "Wait for confirmed short quota resets. The turn shows why it is waiting and can be stopped; switching accounts retries immediately.",
|
|
8652
|
-
quickQuotaForecastHint: "Estimates recent two-hour
|
|
8702
|
+
quickQuotaForecastHint: "Estimates run-out time from recent two-hour usage. Stable readings show a range; changes trigger calibration or a rough estimate. Future usage affects the result. History stays local.",
|
|
8653
8703
|
contextTitle: "Context window",
|
|
8654
8704
|
contextStandard: "Standard",
|
|
8655
8705
|
contextStandardHint: "Use the model catalog default; official agent presets manage context automatically.",
|
|
@@ -8681,7 +8731,7 @@ window.__ModuleLoader__.load({
|
|
|
8681
8731
|
pacePart_morning: "morning",
|
|
8682
8732
|
pacePart_afternoon: "afternoon",
|
|
8683
8733
|
pacePart_evening: "evening",
|
|
8684
|
-
pacePart_night: "
|
|
8734
|
+
pacePart_night: "night",
|
|
8685
8735
|
state_otherModels_on: "Now: on. Conversations on DeepSeek and other models can also use the subscription for search, images and connectors. Turning it off limits that to GPT / Codex conversations; DeepSeek and others keep DSH search and cannot generate images or use connectors.",
|
|
8686
8736
|
state_otherModels_off: "Now: off. Only GPT / Codex conversations use the subscription for search, images and connectors; DeepSeek and others keep DSH search and cannot generate images or use connectors. Turning it on lets them use these too.",
|
|
8687
8737
|
state_imageGeneration_on: "Now: on. The model can draw new pictures with your subscription. Turning it off stops the model from drawing in conversations.",
|
|
@@ -8705,8 +8755,8 @@ window.__ModuleLoader__.load({
|
|
|
8705
8755
|
diagnosticsAdvanced: "Full report (advanced)",
|
|
8706
8756
|
historyAsOf: "Data as of {date}",
|
|
8707
8757
|
historyPending: "Still being counted",
|
|
8708
|
-
historyPendingCurrent: "
|
|
8709
|
-
historyPendingPast: "The official report has not counted this period yet
|
|
8758
|
+
historyPendingCurrent: "The official report has not provided figures for this period yet. Refresh later to check.",
|
|
8759
|
+
historyPendingPast: "The official report has not counted this period yet. Data is as of {date}; refresh later to check.",
|
|
8710
8760
|
triggerSketchName: "Sketch · Beta",
|
|
8711
8761
|
triggerSketchHint: "Ask the Agent to draw or edit a sketch",
|
|
8712
8762
|
triggerImageName: "Image",
|
|
@@ -8776,9 +8826,27 @@ window.__ModuleLoader__.load({
|
|
|
8776
8826
|
quickQuotaForecastUntilReset: "Enough until reset",
|
|
8777
8827
|
quickQuotaForecastUntilResetStatus: "Codex quota: {value}% remaining; enough until reset at the current pace",
|
|
8778
8828
|
quotaForecast: "At current pace {symbol}{duration}",
|
|
8829
|
+
quotaForecastAt: "At recent usage, estimated to run out {when}",
|
|
8830
|
+
quotaForecastRoughAt: "Rough estimate at recent usage: around {when}",
|
|
8831
|
+
quotaExhausted: "Quota exhausted",
|
|
8832
|
+
pacePart_early: "early morning",
|
|
8833
|
+
quotaWhenToday: "this {part}",
|
|
8834
|
+
quotaWhenTonight: "tonight",
|
|
8835
|
+
quotaWhenEarlyToday: "early this morning",
|
|
8836
|
+
quotaWhenEarly: "early {day} morning",
|
|
8837
|
+
quotaWhenRangeEnd: "{label}",
|
|
8838
|
+
quotaWhenRange: "{from}–{to}",
|
|
8839
|
+
quotaWhenEarlyMorningRange: "{latest}",
|
|
8840
|
+
historyRefresh: "Refresh",
|
|
8841
|
+
historyNoBreakdown: "Official breakdown not yet available for this period",
|
|
8842
|
+
historyPendingPastUnknown: "Official usage for this period is not available yet",
|
|
8843
|
+
fetchTitle: "Webpage reading source",
|
|
8844
|
+
fetchDshHint: "Use the webpage reader configured in DSH, independently of the search source above.",
|
|
8845
|
+
fetchCodexHint: "Read accessible webpage text with your Codex subscription. Failures are reported directly, without falling back to the DeepSeek API.",
|
|
8846
|
+
fetchUnavailableHint: "This DSH version cannot switch to the Codex webpage reader. Update DSH first.",
|
|
8779
8847
|
quotaForecastCalibrating: "Runway calibrating",
|
|
8780
8848
|
quotaForecastIdle: "Usage currently stable",
|
|
8781
|
-
quotaForecastUntilReset: "
|
|
8849
|
+
quotaForecastUntilReset: "Estimated to last until reset at recent usage",
|
|
8782
8850
|
runwayDaysHours: "{days}d {hours}h",
|
|
8783
8851
|
runwayDays: "{days}d",
|
|
8784
8852
|
runwayHours: "{hours}h",
|
|
@@ -8970,6 +9038,8 @@ window.__ModuleLoader__.load({
|
|
|
8970
9038
|
.codexSubscriptionRefresh *{white-space:nowrap!important;word-break:keep-all!important;writing-mode:horizontal-tb!important}
|
|
8971
9039
|
.codexSubscriptionEmpty{padding:18px;border:1px dashed var(--dsw-alias-border-l3);border-radius:10px;text-align:center;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
|
|
8972
9040
|
.codexSubscriptionHistory{margin-top:10px;border-top:1px solid var(--dsw-alias-border-l3);padding-top:8px}
|
|
9041
|
+
.codexSubscriptionHistoryRefresh{margin:6px 0;padding:3px 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer}
|
|
9042
|
+
.codexSubscriptionHistoryRefresh:disabled{opacity:.5;cursor:default}
|
|
8973
9043
|
.codexSubscriptionHistory>summary{cursor:pointer;font-size:13px;font-weight:500;color:var(--dsw-alias-label-secondary)}
|
|
8974
9044
|
.codexSubscriptionHistoryPeriods{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
|
|
8975
9045
|
.codexSubscriptionHistoryPeriods button{height:26px;padding:0 10px;border:1px solid var(--dsw-alias-border-l3);border-radius:13px;background:transparent;color:inherit;font-size:12px;cursor:pointer}
|
|
@@ -9068,7 +9138,8 @@ window.__ModuleLoader__.load({
|
|
|
9068
9138
|
.codexComposerQuota:focus-visible{outline:1px solid var(--dsw-alias-border-l3);outline-offset:2px}
|
|
9069
9139
|
.codexComposerQuota{display:inline-flex;align-items:center;gap:9px;flex:0 0 auto;height:28px;box-sizing:border-box;padding:0 5px;border:0;border-radius:6px;background:transparent;cursor:pointer;color:var(--dsw-alias-label-secondary);font-family:inherit;font-size:12px;line-height:20px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
9070
9140
|
.codexComposerQuota:hover,.codexComposerQuota[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}
|
|
9071
|
-
.codexQuotaCompactWindow{display:inline-flex;align-items:center;gap:5px}
|
|
9141
|
+
.codexQuotaCompactWindow{display:inline-flex;align-items:center;gap:5px;min-width:0;max-width:min(380px,55vw)}
|
|
9142
|
+
.codexQuotaCompactWindow>span:last-child{overflow:hidden;text-overflow:ellipsis}
|
|
9072
9143
|
.codexQuotaPopover{position:fixed;z-index:1000;width:max-content;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px);overflow:auto;box-sizing:border-box;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 4px 16px #0002;font-size:12px;line-height:20px;outline:none}
|
|
9073
9144
|
.codexQuotaDetail+ .codexQuotaDetail{margin-top:5px;padding-top:5px;border-top:1px solid var(--dsw-alias-border-l2)}
|
|
9074
9145
|
.codexQuotaDetail>div{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
@@ -9180,6 +9251,7 @@ window.__ModuleLoader__.load({
|
|
|
9180
9251
|
.codexVoiceCall:disabled{cursor:progress}
|
|
9181
9252
|
.codexVoiceCall[data-state=connecting]{animation:codexVoicePulse 1.1s ease-in-out infinite}
|
|
9182
9253
|
.codexVoiceCallNote{position:absolute;bottom:calc(100% + 8px);z-index:3;width:max-content;max-width:320px;padding:6px 10px;border-radius:8px;background:var(--dsw-alias-surface-elevated,#2a2a2e);color:var(--dsw-alias-label-primary,#fff);font-size:12px;line-height:16px;box-shadow:0 4px 16px rgba(0,0,0,.3);white-space:normal}
|
|
9254
|
+
.codexVoiceBrowserActions{display:flex;gap:12px;flex-wrap:wrap;margin-top:6px}.codexVoiceBrowserActions a,.codexVoiceBrowserActions button{color:inherit;text-decoration:underline;background:none;border:0;padding:0;cursor:pointer;font:inherit}
|
|
9183
9255
|
@keyframes codexVoicePulse{50%{opacity:.55}}
|
|
9184
9256
|
@media (prefers-reduced-motion:reduce){.codexVoiceCall{animation:none!important}}
|
|
9185
9257
|
|
|
@@ -9291,6 +9363,7 @@ window.__ModuleLoader__.load({
|
|
|
9291
9363
|
.codexSubscriptionNotice{font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}
|
|
9292
9364
|
.codexSubscriptionNotices button{margin-left:6px;border:0;background:transparent;padding:0;font:inherit;color:var(--dsw-alias-label-primary);text-decoration:underline;cursor:pointer}
|
|
9293
9365
|
.codexSubscriptionPace{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-state-warning-primary,#b45309)}
|
|
9366
|
+
.codexSubscriptionForecast{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
9294
9367
|
.codexSubscriptionLimit[data-pace=true] progress{accent-color:var(--dsw-alias-state-warning-primary,#f5a300)}
|
|
9295
9368
|
.codexSubscriptionLimit[data-pace=true] progress::-webkit-progress-value{background:var(--dsw-alias-state-warning-primary,#f5a300)}
|
|
9296
9369
|
.codexSubscriptionLimit[data-pace=true] progress::-moz-progress-bar{background:var(--dsw-alias-state-warning-primary,#f5a300)}
|
|
@@ -10669,6 +10742,9 @@ window.__ModuleLoader__.load({
|
|
|
10669
10742
|
const SEARCH_PROVIDER_AUTO = "auto";
|
|
10670
10743
|
const SEARCH_PROVIDER_CODEX = "codex";
|
|
10671
10744
|
const DEFAULT_SEARCH_PROVIDER = SEARCH_PROVIDER_AUTO;
|
|
10745
|
+
const FETCH_PROVIDER_FIELD = "fetchProvider";
|
|
10746
|
+
const FETCH_PROVIDER_CODEX = "codex";
|
|
10747
|
+
const normalizeFetchProvider = (value) => value === "codex" ? FETCH_PROVIDER_CODEX : "dsh";
|
|
10672
10748
|
const SPEED_MODE_FIELD = "speedMode";
|
|
10673
10749
|
const SPEED_MODE_STANDARD = "standard";
|
|
10674
10750
|
const SPEED_MODE_FAST = "fast";
|
|
@@ -10900,6 +10976,11 @@ window.__ModuleLoader__.load({
|
|
|
10900
10976
|
default: DEFAULT_SEARCH_PROVIDER,
|
|
10901
10977
|
error: "Invalid search provider preference"
|
|
10902
10978
|
},
|
|
10979
|
+
[FETCH_PROVIDER_FIELD]: {
|
|
10980
|
+
choices: ["dsh", FETCH_PROVIDER_CODEX],
|
|
10981
|
+
default: "dsh",
|
|
10982
|
+
error: "Invalid fetch provider preference"
|
|
10983
|
+
},
|
|
10903
10984
|
[SPEED_MODE_FIELD]: {
|
|
10904
10985
|
choices: [
|
|
10905
10986
|
SPEED_MODE_STANDARD,
|
|
@@ -10992,6 +11073,7 @@ window.__ModuleLoader__.load({
|
|
|
10992
11073
|
let disposed = false;
|
|
10993
11074
|
let subagentBackendAvailable = false;
|
|
10994
11075
|
let subagentRuntimeInstalled = false;
|
|
11076
|
+
let fetchRoutingAvailable = false;
|
|
10995
11077
|
let restartRequired = false;
|
|
10996
11078
|
const sameModels = (left, right) => left.length === right.length && left.every((model, index) => JSON.stringify(model) === JSON.stringify(right[index]));
|
|
10997
11079
|
const read = () => {
|
|
@@ -11016,6 +11098,8 @@ window.__ModuleLoader__.load({
|
|
|
11016
11098
|
subagentRuntimeInstalled,
|
|
11017
11099
|
quickQuotaMode: normalizeQuickQuotaMode(value?.[QUICK_QUOTA_MODE_FIELD], value?.[LEGACY_QUICK_QUOTA_FIELD]),
|
|
11018
11100
|
searchProvider: normalizeSearchProvider(value?.[SEARCH_PROVIDER_FIELD]),
|
|
11101
|
+
fetchProvider: normalizeFetchProvider(value?.[FETCH_PROVIDER_FIELD]),
|
|
11102
|
+
fetchRoutingAvailable,
|
|
11019
11103
|
speedMode: normalizeSpeedMode(value?.[SPEED_MODE_FIELD]),
|
|
11020
11104
|
outputVerbosity: normalizeOutputVerbosity(value?.[OUTPUT_VERBOSITY_FIELD]),
|
|
11021
11105
|
inputImageDetail: normalizeInputImageDetail(value?.[INPUT_IMAGE_DETAIL_FIELD]),
|
|
@@ -11058,6 +11142,7 @@ window.__ModuleLoader__.load({
|
|
|
11058
11142
|
if (value?.liveSynced === false) restartRequired = true;
|
|
11059
11143
|
subagentBackendAvailable = value?.subagentBackendAvailable === true;
|
|
11060
11144
|
subagentRuntimeInstalled = value?.subagentRuntimeInstalled === true;
|
|
11145
|
+
fetchRoutingAvailable = value?.fetchRoutingAvailable === true;
|
|
11061
11146
|
if (!modelRefreshStarted) {
|
|
11062
11147
|
contextModels = Array.isArray(value?.contextModels) ? value.contextModels : [];
|
|
11063
11148
|
availableModels = Array.isArray(value?.availableModels) ? value.availableModels : [];
|
|
@@ -11082,6 +11167,7 @@ window.__ModuleLoader__.load({
|
|
|
11082
11167
|
...readCapabilitySettings(value),
|
|
11083
11168
|
[QUICK_QUOTA_MODE_FIELD]: normalizeQuickQuotaMode(value?.[QUICK_QUOTA_MODE_FIELD], value?.[LEGACY_QUICK_QUOTA_FIELD]),
|
|
11084
11169
|
[SEARCH_PROVIDER_FIELD]: normalizeSearchProvider(value?.[SEARCH_PROVIDER_FIELD]),
|
|
11170
|
+
[FETCH_PROVIDER_FIELD]: normalizeFetchProvider(value?.[FETCH_PROVIDER_FIELD]),
|
|
11085
11171
|
[SPEED_MODE_FIELD]: normalizeSpeedMode(value?.[SPEED_MODE_FIELD]),
|
|
11086
11172
|
[OUTPUT_VERBOSITY_FIELD]: normalizeOutputVerbosity(value?.[OUTPUT_VERBOSITY_FIELD]),
|
|
11087
11173
|
[INPUT_IMAGE_DETAIL_FIELD]: normalizeInputImageDetail(value?.[INPUT_IMAGE_DETAIL_FIELD]),
|
|
@@ -11474,42 +11560,8 @@ window.__ModuleLoader__.load({
|
|
|
11474
11560
|
dispose
|
|
11475
11561
|
});
|
|
11476
11562
|
}
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
if (!Number.isFinite(remainingPercent) || !Number.isSafeInteger(windowSeconds) || windowSeconds < 86400 || !Number.isSafeInteger(resetsAt)) return void 0;
|
|
11480
|
-
const used = Math.floor(Math.min(100, Math.max(0, 100 - remainingPercent)));
|
|
11481
|
-
if (used < 10 || used >= 100) return void 0;
|
|
11482
|
-
const resetMs = resetsAt * 1e3;
|
|
11483
|
-
const elapsed = now - (resetMs - windowSeconds * 1e3);
|
|
11484
|
-
if (!(elapsed >= 432e5) || resetMs <= now) return void 0;
|
|
11485
|
-
const runsOutAt = now + (100 - used) * elapsed / used;
|
|
11486
|
-
return runsOutAt < resetMs ? {
|
|
11487
|
-
runsOutAt,
|
|
11488
|
-
resetsAt: resetMs
|
|
11489
|
-
} : void 0;
|
|
11490
|
-
}
|
|
11491
|
-
const dayStart = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
11492
|
-
/** Plain words for a moment: the day (today, tomorrow, the weekday, or the date) and, for the run-out time, the part of the day. */
|
|
11493
|
-
function paceWords(pace, now, { t, locale }) {
|
|
11494
|
-
const today = dayStart(new Date(now));
|
|
11495
|
-
const day = (date) => {
|
|
11496
|
-
const gap = Math.round((dayStart(date) - today) / 864e5);
|
|
11497
|
-
if (gap <= 0) return t("paceDay_today");
|
|
11498
|
-
if (gap === 1) return t("paceDay_tomorrow");
|
|
11499
|
-
if (gap < 7) return date.toLocaleDateString(locale, { weekday: locale.startsWith("zh") || locale.startsWith("ja") ? "short" : "long" });
|
|
11500
|
-
return date.toLocaleDateString(locale, {
|
|
11501
|
-
month: "numeric",
|
|
11502
|
-
day: "numeric"
|
|
11503
|
-
});
|
|
11504
|
-
};
|
|
11505
|
-
const out = new Date(pace.runsOutAt), reset = new Date(pace.resetsAt);
|
|
11506
|
-
const hour = out.getHours();
|
|
11507
|
-
const part = hour < 5 ? "night" : hour < 12 ? "morning" : hour < 18 ? "afternoon" : hour < 23 ? "evening" : "night";
|
|
11508
|
-
return {
|
|
11509
|
-
runOut: t("paceWhen").replace("{day}", day(out)).replace("{part}", t(`pacePart_${part}`)),
|
|
11510
|
-
reset: t("paceResetOf").replace("{day}", day(reset))
|
|
11511
|
-
};
|
|
11512
|
-
}
|
|
11563
|
+
//#endregion
|
|
11564
|
+
//#region src/quota-pace.js
|
|
11513
11565
|
/**
|
|
11514
11566
|
* One reading of a runway forecast for every place that shows it (settings card, composer chip, composer details), so the
|
|
11515
11567
|
* same snapshot always reads the same hours. Raw seconds are rounded to a grid coarser than the percentage quantisation
|
|
@@ -11525,7 +11577,7 @@ window.__ModuleLoader__.load({
|
|
|
11525
11577
|
/** @returns {{kind:'reset'}|{kind:'range',min:number,max:number}|{kind:'point',seconds:number}|undefined} rounded seconds. */
|
|
11526
11578
|
function forecastRunway(forecast) {
|
|
11527
11579
|
if (forecast?.status !== "ready") return void 0;
|
|
11528
|
-
if (forecast.survivesReset) return { kind: "reset" };
|
|
11580
|
+
if (forecast.survivesReset && !forecast.provisional) return { kind: "reset" };
|
|
11529
11581
|
if (!forecast.provisional && Number.isFinite(forecast.runwayMinSeconds) && Number.isFinite(forecast.runwayMaxSeconds)) {
|
|
11530
11582
|
const min = roundRunwaySeconds(forecast.runwayMinSeconds), max = roundRunwaySeconds(forecast.runwayMaxSeconds);
|
|
11531
11583
|
if (min > 0 && max > min) return {
|
|
@@ -11541,6 +11593,90 @@ window.__ModuleLoader__.load({
|
|
|
11541
11593
|
} : void 0;
|
|
11542
11594
|
}
|
|
11543
11595
|
//#endregion
|
|
11596
|
+
//#region src/quota-forecast-view.js
|
|
11597
|
+
/** A time estimate is anchored to the reading, never advanced by opening another view later. */
|
|
11598
|
+
function quotaForecastView(forecast, { fetchedAt, now = Date.now(), resetsAt, remainingPercent, refreshError = false } = {}) {
|
|
11599
|
+
if (refreshError || Number.isFinite(fetchedAt) && (fetchedAt > now || now - fetchedAt > 5 * 6e4) || Number.isFinite(resetsAt) && resetsAt * 1e3 <= now) return { kind: "stale" };
|
|
11600
|
+
if (remainingPercent === 0) return { kind: "exhausted" };
|
|
11601
|
+
if (forecast?.status === "calibrating") return { kind: forecast.reason ?? "calibrating" };
|
|
11602
|
+
if (forecast?.status === "idle") return { kind: "idle" };
|
|
11603
|
+
if (!Number.isFinite(fetchedAt)) return { kind: "calibrating" };
|
|
11604
|
+
if (forecast?.status === "ready" && !forecast.provisional && Number.isFinite(forecast.runwayMinSeconds) && forecast.runwayMinSeconds > 0 && Number.isFinite(resetsAt) && fetchedAt + forecast.runwayMinSeconds * 1e3 >= resetsAt * 1e3) return { kind: "reset" };
|
|
11605
|
+
const rawMin = !forecast?.provisional && Number.isFinite(forecast?.runwayMinSeconds) ? forecast.runwayMinSeconds : forecast?.runwaySeconds;
|
|
11606
|
+
if (Number.isFinite(rawMin) && fetchedAt + rawMin * 1e3 <= now) return { kind: "stale" };
|
|
11607
|
+
const runway = forecastRunway({
|
|
11608
|
+
...forecast,
|
|
11609
|
+
survivesReset: false
|
|
11610
|
+
});
|
|
11611
|
+
if (!runway) return { kind: "calibrating" };
|
|
11612
|
+
const anchor = fetchedAt;
|
|
11613
|
+
const min = runway.kind === "range" ? runway.min : runway.seconds;
|
|
11614
|
+
const max = runway.kind === "range" ? runway.max : runway.seconds;
|
|
11615
|
+
if (anchor + min * 1e3 <= now) return { kind: "stale" };
|
|
11616
|
+
const grid = min < 3600 ? 5 * 6e4 : 36e5;
|
|
11617
|
+
const round = (value) => Math.round(value / grid) * grid;
|
|
11618
|
+
return {
|
|
11619
|
+
kind: "time",
|
|
11620
|
+
earliest: round(anchor + min * 1e3),
|
|
11621
|
+
latest: round(anchor + max * 1e3),
|
|
11622
|
+
provisional: forecast.provisional === true
|
|
11623
|
+
};
|
|
11624
|
+
}
|
|
11625
|
+
function formatQuotaRunout(view, { t, locale, now = Date.now(), timeZone }) {
|
|
11626
|
+
const clock = new Intl.DateTimeFormat("en-US-u-ca-gregory-nu-latn", {
|
|
11627
|
+
timeZone,
|
|
11628
|
+
year: "numeric",
|
|
11629
|
+
month: "numeric",
|
|
11630
|
+
day: "numeric",
|
|
11631
|
+
hour: "numeric",
|
|
11632
|
+
hourCycle: "h23"
|
|
11633
|
+
});
|
|
11634
|
+
const local = (time) => {
|
|
11635
|
+
const fields = Object.fromEntries(clock.formatToParts(time).filter((part) => part.type !== "literal").map((part) => [part.type, Number(part.value)]));
|
|
11636
|
+
return {
|
|
11637
|
+
day: Date.UTC(fields.year, fields.month - 1, fields.day),
|
|
11638
|
+
hour: fields.hour
|
|
11639
|
+
};
|
|
11640
|
+
};
|
|
11641
|
+
const today = local(now).day;
|
|
11642
|
+
const render = (key, values) => Object.entries(values).reduce((text, [name, value]) => text.replace(`{${name}}`, value), t(key));
|
|
11643
|
+
const when = (time) => {
|
|
11644
|
+
const date = local(time), gap = (date.day - today) / 864e5;
|
|
11645
|
+
const day = gap === 0 ? t("paceDay_today") : gap === 1 ? t("paceDay_tomorrow") : new Intl.DateTimeFormat(locale, gap > 1 && gap < 7 ? {
|
|
11646
|
+
timeZone,
|
|
11647
|
+
weekday: locale?.startsWith("zh") ? "short" : "long"
|
|
11648
|
+
} : {
|
|
11649
|
+
timeZone,
|
|
11650
|
+
month: "numeric",
|
|
11651
|
+
day: "numeric"
|
|
11652
|
+
}).format(time);
|
|
11653
|
+
const part = date.hour < 5 ? "early" : date.hour < 12 ? "morning" : date.hour < 18 ? "afternoon" : date.hour < 23 ? "evening" : "night";
|
|
11654
|
+
const partText = t(`pacePart_${part}`);
|
|
11655
|
+
const key = gap === 0 ? part === "early" ? "quotaWhenEarlyToday" : part === "night" ? "quotaWhenTonight" : "quotaWhenToday" : part === "early" ? "quotaWhenEarly" : "paceWhen";
|
|
11656
|
+
return {
|
|
11657
|
+
day: date.day,
|
|
11658
|
+
period: part,
|
|
11659
|
+
part: partText,
|
|
11660
|
+
label: render(key, {
|
|
11661
|
+
day,
|
|
11662
|
+
part: partText
|
|
11663
|
+
})
|
|
11664
|
+
};
|
|
11665
|
+
};
|
|
11666
|
+
if (view.kind !== "time") return void 0;
|
|
11667
|
+
const from = when(view.earliest), to = when(view.latest);
|
|
11668
|
+
if (from.label === to.label) return from.label;
|
|
11669
|
+
const end = from.day === to.day ? render("quotaWhenRangeEnd", {
|
|
11670
|
+
part: to.part,
|
|
11671
|
+
label: to.label
|
|
11672
|
+
}) : to.label;
|
|
11673
|
+
return render(from.day === to.day && from.period === "early" && to.period === "morning" ? "quotaWhenEarlyMorningRange" : "quotaWhenRange", {
|
|
11674
|
+
from: from.label,
|
|
11675
|
+
to: end,
|
|
11676
|
+
latest: to.label
|
|
11677
|
+
});
|
|
11678
|
+
}
|
|
11679
|
+
//#endregion
|
|
11544
11680
|
//#region src/client-shared.js
|
|
11545
11681
|
const NS = "settings.codexSubscription";
|
|
11546
11682
|
const SUPPORT_ISSUE_URL = "https://github.com/WSL043/dsh-codex-subscription/issues/new?template=install-problem.yml";
|
|
@@ -11583,33 +11719,23 @@ window.__ModuleLoader__.load({
|
|
|
11583
11719
|
const usePreferenceSnapshot = (preference) => (0, react.useSyncExternalStore)(preference.subscribe, preference.getSnapshot);
|
|
11584
11720
|
const useAccountStatusSnapshot = (accountStatus) => (0, react.useSyncExternalStore)(accountStatus.subscribe, accountStatus.getSnapshot);
|
|
11585
11721
|
const notifyQuickQuota = () => window.dispatchEvent(new Event(QUICK_QUOTA_REFRESH_EVENT));
|
|
11586
|
-
const
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
const days = Math.floor(minutes / 1440);
|
|
11590
|
-
const hours = Math.floor(minutes % 1440 / 60);
|
|
11591
|
-
if (days > 0) return hours > 0 ? fill(t("runwayDaysHours"), {
|
|
11592
|
-
days,
|
|
11593
|
-
hours
|
|
11594
|
-
}) : fill(t("runwayDays"), { days });
|
|
11595
|
-
if (hours > 0) return fill(t("runwayHours"), { hours });
|
|
11596
|
-
return fill(t("runwayMinutes"), { minutes });
|
|
11597
|
-
};
|
|
11598
|
-
const formatQuotaForecast = (forecast, t) => {
|
|
11599
|
-
if (forecast?.status === "calibrating") return t({
|
|
11722
|
+
const formatQuotaForecast = (forecast, t, options = {}) => {
|
|
11723
|
+
const view = quotaForecastView(forecast, options);
|
|
11724
|
+
if (view.kind !== "time") return t({
|
|
11600
11725
|
resolution: "forecastResolution",
|
|
11601
11726
|
"changing-pace": "forecastChanging",
|
|
11602
|
-
stale: "forecastStale"
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11727
|
+
stale: "forecastStale",
|
|
11728
|
+
idle: "quotaForecastIdle",
|
|
11729
|
+
reset: "quotaForecastUntilReset",
|
|
11730
|
+
exhausted: "quotaExhausted"
|
|
11731
|
+
}[view.kind] ?? "quotaForecastCalibrating");
|
|
11732
|
+
const when = formatQuotaRunout(view, {
|
|
11733
|
+
t,
|
|
11734
|
+
locale: options.locale ?? uiLocale(),
|
|
11735
|
+
now: options.now,
|
|
11736
|
+
timeZone: options.timeZone
|
|
11612
11737
|
});
|
|
11738
|
+
return fill(t(view.provisional ? "quotaForecastRoughAt" : "quotaForecastAt"), { when });
|
|
11613
11739
|
};
|
|
11614
11740
|
//#endregion
|
|
11615
11741
|
//#region src/sidebar-quota.js
|
|
@@ -11636,7 +11762,7 @@ window.__ModuleLoader__.load({
|
|
|
11636
11762
|
}
|
|
11637
11763
|
//#endregion
|
|
11638
11764
|
//#region src/version.js
|
|
11639
|
-
const PACKAGE_VERSION = "3.1.
|
|
11765
|
+
const PACKAGE_VERSION = "3.1.7";
|
|
11640
11766
|
//#endregion
|
|
11641
11767
|
//#region src/client-recovery.js
|
|
11642
11768
|
async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
|
|
@@ -11679,63 +11805,178 @@ window.__ModuleLoader__.load({
|
|
|
11679
11805
|
return values.length === 0 ? void 0 : Math.max(...values);
|
|
11680
11806
|
}
|
|
11681
11807
|
//#endregion
|
|
11682
|
-
//#region src/
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11808
|
+
//#region src/usage-controller.js
|
|
11809
|
+
/** One live quota snapshot and polling loop for every mounted view. */
|
|
11810
|
+
function createUsageController({ request, now = Date.now, schedule = setTimeout, cancel = clearTimeout, listen, visible = () => true, onUpdate }) {
|
|
11811
|
+
let snapshot = Object.freeze({
|
|
11812
|
+
usage: void 0,
|
|
11813
|
+
busy: false,
|
|
11814
|
+
error: void 0,
|
|
11815
|
+
now: now()
|
|
11816
|
+
});
|
|
11817
|
+
let generation = 0, consumers = 0, flight, timer, unlisten;
|
|
11818
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
11819
|
+
const publish = (next) => {
|
|
11820
|
+
snapshot = Object.freeze(next);
|
|
11821
|
+
for (const listener of [...listeners]) listener();
|
|
11822
|
+
};
|
|
11823
|
+
const stopTimer = () => {
|
|
11824
|
+
if (timer !== void 0) cancel(timer);
|
|
11825
|
+
timer = void 0;
|
|
11826
|
+
};
|
|
11827
|
+
const queue = () => {
|
|
11828
|
+
stopTimer();
|
|
11829
|
+
if (consumers === 0 || !visible()) return;
|
|
11830
|
+
timer = schedule(() => {
|
|
11831
|
+
timer = void 0;
|
|
11832
|
+
refresh().catch(() => {});
|
|
11833
|
+
}, quotaRefreshMs(highestUsed(snapshot.usage?.rateLimits?.flatMap((limit) => limit.windows) ?? [])));
|
|
11834
|
+
};
|
|
11835
|
+
const refresh = (force = false) => {
|
|
11836
|
+
if (flight) {
|
|
11837
|
+
if (force && !flight.force) {
|
|
11838
|
+
const current = generation;
|
|
11839
|
+
return flight.promise.catch(() => {}).then(() => current === generation ? refresh(true) : void 0);
|
|
11840
|
+
}
|
|
11841
|
+
return flight.promise;
|
|
11689
11842
|
}
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
setQuota(void 0);
|
|
11703
|
-
return;
|
|
11704
|
-
}
|
|
11705
|
-
const usage = await recoveryCall(rpc, "usage", { force: false });
|
|
11706
|
-
const windows = selectModelQuotaWindows(usage, model)?.map((window) => ({
|
|
11707
|
-
...window,
|
|
11708
|
-
fetchedAt: usage.fetchedAt
|
|
11709
|
-
}));
|
|
11710
|
-
latest = windows;
|
|
11711
|
-
if (live) setQuota(windows);
|
|
11712
|
-
} catch {
|
|
11713
|
-
latest = void 0;
|
|
11714
|
-
if (live) setQuota(void 0);
|
|
11715
|
-
} finally {
|
|
11716
|
-
loading = false;
|
|
11717
|
-
if (live) {
|
|
11718
|
-
window.clearTimeout(timer);
|
|
11719
|
-
timer = window.setTimeout(refresh, quotaRefreshMs(highestUsed(latest)));
|
|
11720
|
-
}
|
|
11843
|
+
stopTimer();
|
|
11844
|
+
const current = generation;
|
|
11845
|
+
const operation = { force };
|
|
11846
|
+
operation.promise = Promise.resolve().then(() => current === generation ? request(force) : void 0).then((usage) => {
|
|
11847
|
+
if (current === generation) {
|
|
11848
|
+
publish({
|
|
11849
|
+
usage,
|
|
11850
|
+
busy: false,
|
|
11851
|
+
error: void 0,
|
|
11852
|
+
now: now()
|
|
11853
|
+
});
|
|
11854
|
+
onUpdate?.({ force });
|
|
11721
11855
|
}
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11856
|
+
return usage;
|
|
11857
|
+
}).catch((error) => {
|
|
11858
|
+
if (current === generation) publish({
|
|
11859
|
+
...snapshot,
|
|
11860
|
+
busy: false,
|
|
11861
|
+
error: error?.message ?? "Could not read quota",
|
|
11862
|
+
now: now()
|
|
11863
|
+
});
|
|
11864
|
+
throw error;
|
|
11865
|
+
}).finally(() => {
|
|
11866
|
+
if (flight === operation) {
|
|
11867
|
+
flight = void 0;
|
|
11868
|
+
queue();
|
|
11869
|
+
}
|
|
11870
|
+
});
|
|
11871
|
+
flight = operation;
|
|
11872
|
+
publish({
|
|
11873
|
+
...snapshot,
|
|
11874
|
+
busy: true,
|
|
11875
|
+
now: now()
|
|
11876
|
+
});
|
|
11877
|
+
return operation.promise;
|
|
11878
|
+
};
|
|
11879
|
+
const invalidate = ({ preserveUsage = false } = {}) => {
|
|
11880
|
+
generation += 1;
|
|
11881
|
+
flight = void 0;
|
|
11882
|
+
stopTimer();
|
|
11883
|
+
const usage = preserveUsage && snapshot.usage ? {
|
|
11884
|
+
...snapshot.usage,
|
|
11885
|
+
rateLimits: snapshot.usage.rateLimits.map((limit) => ({
|
|
11886
|
+
...limit,
|
|
11887
|
+
windows: limit.windows.map(({ forecast, ...window }) => window)
|
|
11888
|
+
}))
|
|
11889
|
+
} : void 0;
|
|
11890
|
+
publish({
|
|
11891
|
+
usage,
|
|
11892
|
+
busy: false,
|
|
11893
|
+
error: void 0,
|
|
11894
|
+
now: now()
|
|
11895
|
+
});
|
|
11896
|
+
if (consumers > 0 && visible()) refresh().catch(() => {});
|
|
11897
|
+
};
|
|
11898
|
+
return Object.freeze({
|
|
11899
|
+
getSnapshot: () => snapshot,
|
|
11900
|
+
subscribe(listener) {
|
|
11901
|
+
listeners.add(listener);
|
|
11902
|
+
return () => listeners.delete(listener);
|
|
11903
|
+
},
|
|
11904
|
+
refresh,
|
|
11905
|
+
invalidate,
|
|
11906
|
+
retain() {
|
|
11907
|
+
consumers += 1;
|
|
11908
|
+
if (consumers === 1) {
|
|
11909
|
+
unlisten = listen?.({
|
|
11910
|
+
invalidate,
|
|
11911
|
+
wake: () => {
|
|
11912
|
+
if (visible()) refresh().catch(() => {});
|
|
11913
|
+
else stopTimer();
|
|
11914
|
+
}
|
|
11915
|
+
});
|
|
11916
|
+
invalidate();
|
|
11917
|
+
}
|
|
11918
|
+
let released = false;
|
|
11919
|
+
return () => {
|
|
11920
|
+
if (released) return;
|
|
11921
|
+
released = true;
|
|
11922
|
+
consumers -= 1;
|
|
11923
|
+
if (consumers === 0) {
|
|
11924
|
+
generation += 1;
|
|
11925
|
+
flight = void 0;
|
|
11926
|
+
stopTimer();
|
|
11927
|
+
unlisten?.();
|
|
11928
|
+
unlisten = void 0;
|
|
11929
|
+
publish({
|
|
11930
|
+
usage: void 0,
|
|
11931
|
+
busy: false,
|
|
11932
|
+
error: void 0,
|
|
11933
|
+
now: now()
|
|
11934
|
+
});
|
|
11935
|
+
}
|
|
11936
|
+
};
|
|
11937
|
+
}
|
|
11938
|
+
});
|
|
11939
|
+
}
|
|
11940
|
+
//#endregion
|
|
11941
|
+
//#region src/client-quota.jsx
|
|
11942
|
+
const controllers = /* @__PURE__ */ new WeakMap();
|
|
11943
|
+
function quotaUsageController(rpc) {
|
|
11944
|
+
if (!controllers.has(rpc)) controllers.set(rpc, createUsageController({
|
|
11945
|
+
request: async (force) => {
|
|
11946
|
+
return (await recoveryCall(rpc, "status"))?.authenticated === true ? recoveryCall(rpc, "usage", { force }) : void 0;
|
|
11947
|
+
},
|
|
11948
|
+
visible: () => document.visibilityState !== "hidden",
|
|
11949
|
+
onUpdate: ({ force }) => {
|
|
11950
|
+
if (force) window.dispatchEvent(new Event("codex-subscription:usage-loaded"));
|
|
11951
|
+
},
|
|
11952
|
+
listen: ({ invalidate, wake }) => {
|
|
11953
|
+
window.addEventListener(QUICK_QUOTA_REFRESH_EVENT, invalidate);
|
|
11954
|
+
document.addEventListener("visibilitychange", wake);
|
|
11955
|
+
return () => {
|
|
11956
|
+
window.removeEventListener(QUICK_QUOTA_REFRESH_EVENT, invalidate);
|
|
11957
|
+
document.removeEventListener("visibilitychange", wake);
|
|
11958
|
+
};
|
|
11959
|
+
}
|
|
11960
|
+
}));
|
|
11961
|
+
return controllers.get(rpc);
|
|
11962
|
+
}
|
|
11963
|
+
function useQuotaUsage(rpc, enabled) {
|
|
11964
|
+
const controller = quotaUsageController(rpc);
|
|
11965
|
+
const snapshot = (0, react.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
|
|
11966
|
+
(0, react.useEffect)(() => enabled ? controller.retain() : void 0, [controller, enabled]);
|
|
11967
|
+
return {
|
|
11968
|
+
...snapshot,
|
|
11969
|
+
refresh: controller.refresh
|
|
11970
|
+
};
|
|
11971
|
+
}
|
|
11972
|
+
function useQuickQuota(rpc, enabled, model) {
|
|
11973
|
+
const snapshot = useQuotaUsage(rpc, enabled);
|
|
11974
|
+
return enabled ? selectModelQuotaWindows(snapshot.usage, model).map((window) => ({
|
|
11975
|
+
...window,
|
|
11976
|
+
fetchedAt: snapshot.usage.fetchedAt,
|
|
11977
|
+
now: snapshot.now,
|
|
11978
|
+
refreshError: snapshot.error !== void 0
|
|
11979
|
+
})) : void 0;
|
|
11739
11980
|
}
|
|
11740
11981
|
//#endregion
|
|
11741
11982
|
//#region src/client-composer-quota.jsx
|
|
@@ -11821,14 +12062,14 @@ window.__ModuleLoader__.load({
|
|
|
11821
12062
|
children: compactQuotas.map((quota, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
11822
12063
|
className: "codexQuotaCompactWindow",
|
|
11823
12064
|
children: [
|
|
11824
|
-
|
|
12065
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: shortWindow(quota.windowSeconds, t) }),
|
|
11825
12066
|
preferenceSnapshot.quickQuotaMode === "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("progress", {
|
|
11826
12067
|
className: "codexComposerQuotaBar",
|
|
11827
12068
|
max: 100,
|
|
11828
12069
|
value: quota.remainingPercent,
|
|
11829
12070
|
"aria-hidden": "true"
|
|
11830
12071
|
}) : null,
|
|
11831
|
-
preferenceSnapshot.quickQuotaMode !== "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [`${percent(quota.remainingPercent)}%`, forecastMode ? ` · ${
|
|
12072
|
+
preferenceSnapshot.quickQuotaMode !== "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [`${percent(quota.remainingPercent)}%`, forecastMode ? ` · ${formatQuotaForecast(quota.forecast, t, quota)}` : ""] }) : null
|
|
11832
12073
|
]
|
|
11833
12074
|
}, `${quota.windowSeconds}-${index}`))
|
|
11834
12075
|
}), visible ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
@@ -11853,7 +12094,7 @@ window.__ModuleLoader__.load({
|
|
|
11853
12094
|
className: "codexQuotaReset",
|
|
11854
12095
|
children: shortReset(quota, t)
|
|
11855
12096
|
})
|
|
11856
|
-
] }), forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: formatQuotaForecast(quota.forecast, t) }) : null]
|
|
12097
|
+
] }), forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: formatQuotaForecast(quota.forecast, t, quota) }) : null]
|
|
11857
12098
|
}, `${quota.windowSeconds}-${index}`))
|
|
11858
12099
|
}), document.body) : null] });
|
|
11859
12100
|
}
|
|
@@ -11872,19 +12113,6 @@ window.__ModuleLoader__.load({
|
|
|
11872
12113
|
});
|
|
11873
12114
|
return fill(t("resets"), { value });
|
|
11874
12115
|
}
|
|
11875
|
-
function forecastText(quota, t) {
|
|
11876
|
-
const forecast = quota.forecast;
|
|
11877
|
-
if (forecast?.status === "calibrating") return t({
|
|
11878
|
-
"changing-pace": "forecastCompactChanging",
|
|
11879
|
-
stale: "forecastCompactStale"
|
|
11880
|
-
}[forecast.reason] ?? "forecastCompactPending");
|
|
11881
|
-
if (forecast?.status === "idle") return t("quickQuotaForecastIdle");
|
|
11882
|
-
const runway = forecastRunway(forecast);
|
|
11883
|
-
if (runway?.kind === "reset") return t("quickQuotaForecastUntilReset");
|
|
11884
|
-
if (runway?.kind === "range") return `≈${formatRunway(runway.min, t)}–${formatRunway(runway.max, t)}`;
|
|
11885
|
-
if (runway?.kind === "point") return `≈${formatRunway(runway.seconds, t)}`;
|
|
11886
|
-
return t("forecastCompactPending");
|
|
11887
|
-
}
|
|
11888
12116
|
//#endregion
|
|
11889
12117
|
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/16/solid/esm/BoltIcon.js
|
|
11890
12118
|
function BoltIcon({ title, titleId, ...props }, svgRef) {
|
|
@@ -12403,6 +12631,32 @@ window.__ModuleLoader__.load({
|
|
|
12403
12631
|
} };
|
|
12404
12632
|
}
|
|
12405
12633
|
//#endregion
|
|
12634
|
+
//#region src/voice-problems.js
|
|
12635
|
+
/** Stable user-facing categories; never render private server error strings. */
|
|
12636
|
+
function voicePreviewProblem(code) {
|
|
12637
|
+
return {
|
|
12638
|
+
"not-found": "voiceNoSample",
|
|
12639
|
+
"voice-auth": "voicePreviewSignIn",
|
|
12640
|
+
"voice-catalog": "voiceCatalogFailed",
|
|
12641
|
+
"voice-download": "voiceDownloadFailed",
|
|
12642
|
+
playback: "voicePlaybackFailed"
|
|
12643
|
+
}[code] ?? "voicePreviewFailed";
|
|
12644
|
+
}
|
|
12645
|
+
function voiceCallProblem(error) {
|
|
12646
|
+
if (error?.name === "NotAllowedError") return "voiceMicBlocked";
|
|
12647
|
+
if (error?.name === "NotFoundError") return "voiceMicMissing";
|
|
12648
|
+
return {
|
|
12649
|
+
"voice-insecure": "voiceInsecure",
|
|
12650
|
+
"voice-no-microphone": "voiceMicUnavailable",
|
|
12651
|
+
"voice-no-webrtc": "voiceWebRTCUnavailable"
|
|
12652
|
+
}[error?.code] ?? "voiceFailed";
|
|
12653
|
+
}
|
|
12654
|
+
function voiceCallCapability(surface = globalThis) {
|
|
12655
|
+
if (surface.isSecureContext === false) return "voice-insecure";
|
|
12656
|
+
if (typeof surface.navigator?.mediaDevices?.getUserMedia !== "function") return "voice-no-microphone";
|
|
12657
|
+
if (typeof surface.RTCPeerConnection !== "function") return "voice-no-webrtc";
|
|
12658
|
+
}
|
|
12659
|
+
//#endregion
|
|
12406
12660
|
//#region src/voice-call.js
|
|
12407
12661
|
const ICE_WAIT_MS = 3e3;
|
|
12408
12662
|
const waitForCandidates = (connection) => new Promise((resolve) => {
|
|
@@ -12456,18 +12710,33 @@ window.__ModuleLoader__.load({
|
|
|
12456
12710
|
* plugin's host turns the offer into a call, joins it, and runs what is asked as turns of this conversation.
|
|
12457
12711
|
* Resolves with a handle once the call is connected; rejects with the reason when it could not start.
|
|
12458
12712
|
*/
|
|
12459
|
-
async function openVoiceCall({ rpc, sessionId, onEnd }) {
|
|
12460
|
-
|
|
12461
|
-
const
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
|
|
12713
|
+
async function openVoiceCall({ rpc, sessionId, onEnd, signal }) {
|
|
12714
|
+
signal?.throwIfAborted();
|
|
12715
|
+
const unsupported = voiceCallCapability();
|
|
12716
|
+
if (unsupported) throw Object.assign(/* @__PURE__ */ new Error("Voice is not supported in this environment"), { code: unsupported });
|
|
12717
|
+
let connection;
|
|
12718
|
+
try {
|
|
12719
|
+
connection = new RTCPeerConnection();
|
|
12720
|
+
} catch {
|
|
12721
|
+
throw Object.assign(/* @__PURE__ */ new Error("WebRTC could not initialize"), { code: "voice-no-webrtc" });
|
|
12722
|
+
}
|
|
12723
|
+
let stream, sound, context;
|
|
12724
|
+
try {
|
|
12725
|
+
stream = await navigator.mediaDevices.getUserMedia({ audio: {
|
|
12726
|
+
echoCancellation: true,
|
|
12727
|
+
noiseSuppression: true,
|
|
12728
|
+
autoGainControl: true
|
|
12729
|
+
} });
|
|
12730
|
+
signal?.throwIfAborted();
|
|
12731
|
+
sound = new Audio();
|
|
12732
|
+
sound.autoplay = true;
|
|
12733
|
+
const AudioContextClass = window.AudioContext ?? window.webkitAudioContext;
|
|
12734
|
+
context = AudioContextClass ? new AudioContextClass() : void 0;
|
|
12735
|
+
} catch (error) {
|
|
12736
|
+
stream?.getTracks().forEach((track) => track.stop());
|
|
12737
|
+
connection.close();
|
|
12738
|
+
throw error;
|
|
12739
|
+
}
|
|
12471
12740
|
const analysers = {
|
|
12472
12741
|
mic: void 0,
|
|
12473
12742
|
assistant: void 0
|
|
@@ -12493,6 +12762,7 @@ window.__ModuleLoader__.load({
|
|
|
12493
12762
|
const end = async () => {
|
|
12494
12763
|
if (ended) return;
|
|
12495
12764
|
ended = true;
|
|
12765
|
+
signal?.removeEventListener("abort", aborted);
|
|
12496
12766
|
clearInterval(monitor);
|
|
12497
12767
|
if (context) chime(context, [740, 520]);
|
|
12498
12768
|
for (const track of stream.getTracks()) track.stop();
|
|
@@ -12508,6 +12778,10 @@ window.__ModuleLoader__.load({
|
|
|
12508
12778
|
}, 600);
|
|
12509
12779
|
onEnd?.();
|
|
12510
12780
|
};
|
|
12781
|
+
const aborted = () => {
|
|
12782
|
+
end();
|
|
12783
|
+
};
|
|
12784
|
+
signal?.addEventListener("abort", aborted, { once: true });
|
|
12511
12785
|
connection.addEventListener("connectionstatechange", () => {
|
|
12512
12786
|
if ([
|
|
12513
12787
|
"failed",
|
|
@@ -12522,7 +12796,8 @@ window.__ModuleLoader__.load({
|
|
|
12522
12796
|
const result = await rpc.call(CHANNEL, "voice/start", {
|
|
12523
12797
|
sessionId,
|
|
12524
12798
|
sdp: connection.localDescription.sdp
|
|
12525
|
-
});
|
|
12799
|
+
}, signal);
|
|
12800
|
+
signal?.throwIfAborted();
|
|
12526
12801
|
if (!result.ok) throw new Error(result.error?.message ?? "start failed");
|
|
12527
12802
|
await connection.setRemoteDescription({
|
|
12528
12803
|
type: "answer",
|
|
@@ -12530,6 +12805,7 @@ window.__ModuleLoader__.load({
|
|
|
12530
12805
|
});
|
|
12531
12806
|
} catch (error) {
|
|
12532
12807
|
ended = true;
|
|
12808
|
+
signal?.removeEventListener("abort", aborted);
|
|
12533
12809
|
for (const track of stream.getTracks()) track.stop();
|
|
12534
12810
|
try {
|
|
12535
12811
|
connection.close();
|
|
@@ -12579,6 +12855,41 @@ window.__ModuleLoader__.load({
|
|
|
12579
12855
|
};
|
|
12580
12856
|
}
|
|
12581
12857
|
//#endregion
|
|
12858
|
+
//#region src/voice-browser.js
|
|
12859
|
+
const PARAM = "codexVoiceSession";
|
|
12860
|
+
const validSession = (value) => typeof value === "string" && /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,255}$/u.test(value);
|
|
12861
|
+
/** A permalink, never an authentication URL or a native-shell URL. */
|
|
12862
|
+
function voiceBrowserUrl(href, sessionId) {
|
|
12863
|
+
if (!validSession(sessionId)) return void 0;
|
|
12864
|
+
try {
|
|
12865
|
+
const url = new URL(href);
|
|
12866
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) return void 0;
|
|
12867
|
+
url.search = "";
|
|
12868
|
+
url.hash = "";
|
|
12869
|
+
url.searchParams.set(PARAM, sessionId);
|
|
12870
|
+
return url.href;
|
|
12871
|
+
} catch {
|
|
12872
|
+
return;
|
|
12873
|
+
}
|
|
12874
|
+
}
|
|
12875
|
+
/** Let the host open its own session; consume only after that operation succeeds. */
|
|
12876
|
+
async function restoreVoiceConversation({ href, workspace, history, sessions, signal }) {
|
|
12877
|
+
const url = new URL(href);
|
|
12878
|
+
const sessionId = url.searchParams.get(PARAM);
|
|
12879
|
+
if (!validSession(sessionId) || typeof workspace?.openSession !== "function") return false;
|
|
12880
|
+
const reference = sessions?.retain(sessionId, { source: "controllerOperation" });
|
|
12881
|
+
try {
|
|
12882
|
+
if (reference) await reference.ready;
|
|
12883
|
+
signal?.throwIfAborted();
|
|
12884
|
+
await workspace.openSession(sessionId);
|
|
12885
|
+
url.searchParams.delete(PARAM);
|
|
12886
|
+
history.replaceState(history.state, "", url.href);
|
|
12887
|
+
return true;
|
|
12888
|
+
} finally {
|
|
12889
|
+
reference?.release();
|
|
12890
|
+
}
|
|
12891
|
+
}
|
|
12892
|
+
//#endregion
|
|
12582
12893
|
//#region src/voice-orb.js
|
|
12583
12894
|
const VERTEX = "attribute vec2 a;void main(){gl_Position=vec4(a,0.,1.);}";
|
|
12584
12895
|
const FRAGMENT = `
|
|
@@ -13231,12 +13542,16 @@ void main(){
|
|
|
13231
13542
|
const snapshot = usePreferenceSnapshot(preference);
|
|
13232
13543
|
const marker = (0, react.useRef)(null);
|
|
13233
13544
|
const call = (0, react.useRef)(null);
|
|
13545
|
+
const pendingCall = (0, react.useRef)(null);
|
|
13546
|
+
const alive = (0, react.useRef)(false);
|
|
13234
13547
|
const [liveCall, setLiveCall] = (0, react.useState)(null);
|
|
13235
13548
|
const accent = (0, react.useRef)("");
|
|
13236
13549
|
const button = (0, react.useRef)(null);
|
|
13237
13550
|
const [place, setPlace] = (0, react.useState)();
|
|
13238
13551
|
const [state, setState] = (0, react.useState)("idle");
|
|
13239
13552
|
const [problem, setProblem] = (0, react.useState)("");
|
|
13553
|
+
const [unsupported, setUnsupported] = (0, react.useState)(false);
|
|
13554
|
+
const [browserCopied, setBrowserCopied] = (0, react.useState)(false);
|
|
13240
13555
|
const [micOff, setMicOff] = (0, react.useState)(false);
|
|
13241
13556
|
const [speakerOff, setSpeakerOff] = (0, react.useState)(false);
|
|
13242
13557
|
const enabled = snapshot.status === "ready" && snapshot.voiceCall === "on";
|
|
@@ -13298,37 +13613,63 @@ void main(){
|
|
|
13298
13613
|
activity.setAttribute("data-voice-live", "");
|
|
13299
13614
|
return () => activity.removeAttribute("data-voice-live");
|
|
13300
13615
|
}, [place?.activity, live]);
|
|
13301
|
-
(0, react.useEffect)(() => () => {
|
|
13302
|
-
call.current?.stop();
|
|
13303
|
-
}, []);
|
|
13304
13616
|
(0, react.useEffect)(() => {
|
|
13305
|
-
|
|
13617
|
+
alive.current = true;
|
|
13618
|
+
call.current = null;
|
|
13619
|
+
setLiveCall(null);
|
|
13620
|
+
setState("idle");
|
|
13621
|
+
return () => {
|
|
13622
|
+
alive.current = false;
|
|
13623
|
+
pendingCall.current?.abort();
|
|
13624
|
+
call.current?.stop();
|
|
13625
|
+
};
|
|
13626
|
+
}, [sessionId]);
|
|
13627
|
+
(0, react.useEffect)(() => {
|
|
13628
|
+
if (!problem || unsupported) return void 0;
|
|
13306
13629
|
const timer = setTimeout(() => setProblem(""), 6e3);
|
|
13307
13630
|
return () => clearTimeout(timer);
|
|
13308
|
-
}, [problem]);
|
|
13631
|
+
}, [problem, unsupported]);
|
|
13309
13632
|
const start = async () => {
|
|
13633
|
+
const controller = new AbortController();
|
|
13634
|
+
pendingCall.current?.abort();
|
|
13635
|
+
pendingCall.current = controller;
|
|
13310
13636
|
setProblem("");
|
|
13637
|
+
setUnsupported(false);
|
|
13638
|
+
setBrowserCopied(false);
|
|
13311
13639
|
accent.current = button.current ? getComputedStyle(button.current).backgroundColor : "";
|
|
13312
13640
|
setMicOff(false);
|
|
13313
13641
|
setSpeakerOff(false);
|
|
13314
13642
|
setState("connecting");
|
|
13315
13643
|
try {
|
|
13316
|
-
|
|
13644
|
+
const opened = await openVoiceCall({
|
|
13317
13645
|
rpc,
|
|
13318
13646
|
sessionId,
|
|
13647
|
+
signal: controller.signal,
|
|
13319
13648
|
onEnd: () => {
|
|
13649
|
+
if (!alive.current || controller.signal.aborted || pendingCall.current !== controller) return;
|
|
13320
13650
|
call.current = null;
|
|
13321
13651
|
setLiveCall(null);
|
|
13322
13652
|
setState("idle");
|
|
13323
13653
|
}
|
|
13324
13654
|
});
|
|
13655
|
+
if (!alive.current || controller.signal.aborted) {
|
|
13656
|
+
await opened.stop();
|
|
13657
|
+
return;
|
|
13658
|
+
}
|
|
13659
|
+
call.current = opened;
|
|
13325
13660
|
setLiveCall(call.current);
|
|
13326
13661
|
setState("live");
|
|
13327
13662
|
} catch (error) {
|
|
13663
|
+
if (!alive.current || controller.signal.aborted) return;
|
|
13328
13664
|
call.current = null;
|
|
13329
13665
|
setLiveCall(null);
|
|
13330
13666
|
setState("idle");
|
|
13331
|
-
|
|
13667
|
+
setUnsupported([
|
|
13668
|
+
"voice-no-webrtc",
|
|
13669
|
+
"voice-no-microphone",
|
|
13670
|
+
"voice-insecure"
|
|
13671
|
+
].includes(error?.code) ? error.code : false);
|
|
13672
|
+
setProblem(voiceCallProblem(error));
|
|
13332
13673
|
}
|
|
13333
13674
|
};
|
|
13334
13675
|
const click = () => {
|
|
@@ -13354,9 +13695,11 @@ void main(){
|
|
|
13354
13695
|
hidden: true
|
|
13355
13696
|
});
|
|
13356
13697
|
if (!enabled || !place) return anchor;
|
|
13698
|
+
const visible = state !== "idle" || place.idle;
|
|
13699
|
+
const browserUrl = unsupported && unsupported !== "voice-insecure" ? voiceBrowserUrl(window.location.href, sessionId) : void 0;
|
|
13357
13700
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
13358
13701
|
anchor,
|
|
13359
|
-
|
|
13702
|
+
visible ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
13360
13703
|
ref: button,
|
|
13361
13704
|
type: "button",
|
|
13362
13705
|
className: `${place.className} codexVoiceCall`,
|
|
@@ -13372,11 +13715,25 @@ void main(){
|
|
|
13372
13715
|
height: place.height
|
|
13373
13716
|
},
|
|
13374
13717
|
children: live ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Cross, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Bars, {})
|
|
13375
|
-
}), problem ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
13718
|
+
}), problem ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
13376
13719
|
className: "codexVoiceCallNote",
|
|
13377
13720
|
role: "alert",
|
|
13378
13721
|
style: { right: 0 },
|
|
13379
|
-
children: problem
|
|
13722
|
+
children: [t(problem), browserUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
13723
|
+
className: "codexVoiceBrowserActions",
|
|
13724
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
13725
|
+
href: browserUrl,
|
|
13726
|
+
target: "_blank",
|
|
13727
|
+
rel: "noopener noreferrer",
|
|
13728
|
+
children: t("voiceBrowserContinue")
|
|
13729
|
+
}), typeof navigator.clipboard?.writeText === "function" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
13730
|
+
type: "button",
|
|
13731
|
+
onClick: () => {
|
|
13732
|
+
navigator.clipboard.writeText(browserUrl).then(() => setBrowserCopied(true)).catch(() => setBrowserCopied("error"));
|
|
13733
|
+
},
|
|
13734
|
+
children: t(browserCopied === "error" ? "voiceBrowserCopyFailed" : browserCopied ? "voiceBrowserCopied" : "voiceBrowserCopy")
|
|
13735
|
+
}) : null]
|
|
13736
|
+
}) : null]
|
|
13380
13737
|
}) : null] }), place.host) : null,
|
|
13381
13738
|
live && place.activity && liveCall ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
13382
13739
|
className: "codexVoiceTools",
|
|
@@ -13460,6 +13817,7 @@ void main(){
|
|
|
13460
13817
|
function VoiceCallCard({ rpc, preference, snapshot, t }) {
|
|
13461
13818
|
const audio = (0, react.useRef)();
|
|
13462
13819
|
const previewSequence = (0, react.useRef)(0);
|
|
13820
|
+
const previewAbort = (0, react.useRef)();
|
|
13463
13821
|
const alive = (0, react.useRef)(false);
|
|
13464
13822
|
const [offered, setOffered] = (0, react.useState)();
|
|
13465
13823
|
const [sample, setSample] = (0, react.useState)({
|
|
@@ -13471,39 +13829,62 @@ void main(){
|
|
|
13471
13829
|
alive.current = true;
|
|
13472
13830
|
return () => {
|
|
13473
13831
|
alive.current = false;
|
|
13832
|
+
previewAbort.current?.abort();
|
|
13474
13833
|
audio.current?.pause();
|
|
13475
13834
|
};
|
|
13476
13835
|
}, []);
|
|
13477
13836
|
(0, react.useEffect)(() => {
|
|
13478
|
-
if (!on)
|
|
13837
|
+
if (!on) {
|
|
13838
|
+
previewSequence.current++;
|
|
13839
|
+
previewAbort.current?.abort();
|
|
13840
|
+
audio.current?.pause();
|
|
13841
|
+
setSample({
|
|
13842
|
+
state: "idle",
|
|
13843
|
+
note: ""
|
|
13844
|
+
});
|
|
13845
|
+
setOffered(void 0);
|
|
13846
|
+
return;
|
|
13847
|
+
}
|
|
13848
|
+
const controller = new AbortController();
|
|
13849
|
+
setOffered(void 0);
|
|
13479
13850
|
(async () => {
|
|
13480
13851
|
try {
|
|
13481
|
-
const result = await rpc.call(CHANNEL, "voice/catalog", {});
|
|
13482
|
-
if (alive.current && result.ok) setOffered(result.value.voices);
|
|
13852
|
+
const result = await rpc.call(CHANNEL, "voice/catalog", { language: snapshot.voiceLanguage }, controller.signal);
|
|
13853
|
+
if (alive.current && !controller.signal.aborted && result.ok) setOffered(result.value.voices);
|
|
13483
13854
|
} catch {}
|
|
13484
13855
|
})();
|
|
13485
|
-
|
|
13856
|
+
return () => controller.abort();
|
|
13857
|
+
}, [
|
|
13858
|
+
on,
|
|
13859
|
+
snapshot.voiceLanguage,
|
|
13860
|
+
rpc
|
|
13861
|
+
]);
|
|
13486
13862
|
/** Play a short clip of a voice; picking a voice plays it too, so it can be heard before it is used. */
|
|
13487
13863
|
const playVoice = async (voice, language = snapshot.voiceLanguage) => {
|
|
13488
13864
|
const sequence = ++previewSequence.current;
|
|
13865
|
+
previewAbort.current?.abort();
|
|
13866
|
+
const controller = new AbortController();
|
|
13867
|
+
previewAbort.current = controller;
|
|
13489
13868
|
audio.current?.pause();
|
|
13490
13869
|
setSample({
|
|
13491
13870
|
state: "loading",
|
|
13492
13871
|
note: ""
|
|
13493
13872
|
});
|
|
13873
|
+
let phase = "request";
|
|
13494
13874
|
try {
|
|
13495
13875
|
const result = await rpc.call(CHANNEL, "voice/preview", {
|
|
13496
13876
|
voice,
|
|
13497
13877
|
language
|
|
13498
|
-
});
|
|
13878
|
+
}, controller.signal);
|
|
13499
13879
|
if (!alive.current || sequence !== previewSequence.current) return;
|
|
13500
13880
|
if (!result.ok) {
|
|
13501
13881
|
setSample({
|
|
13502
|
-
state: "
|
|
13503
|
-
|
|
13882
|
+
state: "error",
|
|
13883
|
+
code: voicePreviewProblem(result.error?.code)
|
|
13504
13884
|
});
|
|
13505
13885
|
return;
|
|
13506
13886
|
}
|
|
13887
|
+
phase = "playback";
|
|
13507
13888
|
const clip = new Audio(result.value.audio);
|
|
13508
13889
|
audio.current = clip;
|
|
13509
13890
|
clip.onended = () => {
|
|
@@ -13512,15 +13893,21 @@ void main(){
|
|
|
13512
13893
|
state: "idle"
|
|
13513
13894
|
}));
|
|
13514
13895
|
};
|
|
13896
|
+
clip.onerror = () => {
|
|
13897
|
+
if (alive.current && sequence === previewSequence.current) setSample({
|
|
13898
|
+
state: "error",
|
|
13899
|
+
code: "voicePlaybackFailed"
|
|
13900
|
+
});
|
|
13901
|
+
};
|
|
13515
13902
|
setSample({
|
|
13516
13903
|
state: "playing",
|
|
13517
13904
|
note: [result.value.description, result.value.accent].filter(Boolean).join(" · ")
|
|
13518
13905
|
});
|
|
13519
13906
|
await clip.play();
|
|
13520
13907
|
} catch {
|
|
13521
|
-
if (alive.current && sequence === previewSequence.current) setSample({
|
|
13522
|
-
state: "
|
|
13523
|
-
|
|
13908
|
+
if (alive.current && sequence === previewSequence.current && !controller.signal.aborted) setSample({
|
|
13909
|
+
state: "error",
|
|
13910
|
+
code: voicePreviewProblem(phase === "playback" ? "playback" : void 0)
|
|
13524
13911
|
});
|
|
13525
13912
|
}
|
|
13526
13913
|
};
|
|
@@ -13597,10 +13984,10 @@ void main(){
|
|
|
13597
13984
|
role: "status",
|
|
13598
13985
|
children: sample.note
|
|
13599
13986
|
}) : null,
|
|
13600
|
-
sample.state === "
|
|
13987
|
+
sample.state === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
13601
13988
|
className: "codexSubscriptionHelp",
|
|
13602
13989
|
role: "status",
|
|
13603
|
-
children: t(
|
|
13990
|
+
children: t(sample.code)
|
|
13604
13991
|
}) : null,
|
|
13605
13992
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceRow, {
|
|
13606
13993
|
label: t("voiceLanguage"),
|
|
@@ -13612,9 +13999,13 @@ void main(){
|
|
|
13612
13999
|
playVoice(snapshot.voiceVoice, value);
|
|
13613
14000
|
}
|
|
13614
14001
|
}),
|
|
13615
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
14002
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
13616
14003
|
className: "codexSubscriptionHelp",
|
|
13617
|
-
children:
|
|
14004
|
+
children: [
|
|
14005
|
+
t("voicePreviewHint"),
|
|
14006
|
+
" ",
|
|
14007
|
+
t("voiceMediaHint")
|
|
14008
|
+
]
|
|
13618
14009
|
})
|
|
13619
14010
|
] }) : null]
|
|
13620
14011
|
});
|
|
@@ -16428,6 +16819,7 @@ void main(){
|
|
|
16428
16819
|
search: "search",
|
|
16429
16820
|
image: "images",
|
|
16430
16821
|
model: "transport",
|
|
16822
|
+
voice: "transport",
|
|
16431
16823
|
login: "account",
|
|
16432
16824
|
"quota-reset": "quota"
|
|
16433
16825
|
};
|
|
@@ -17002,34 +17394,68 @@ void main(){
|
|
|
17002
17394
|
const hint = snapshot.searchProvider === "dsh" ? "searchDshHint" : snapshot.searchProvider === "codex" ? "searchCodexHint" : "searchAutoHint";
|
|
17003
17395
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17004
17396
|
className: "codexSubscriptionSearch",
|
|
17005
|
-
children: [
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
|
|
17397
|
+
children: [
|
|
17398
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17399
|
+
className: "codexSubscriptionPreference",
|
|
17400
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17401
|
+
className: "codexSubscriptionPreferenceCopy",
|
|
17402
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
17403
|
+
className: "codexSubscriptionPreferenceLabel",
|
|
17404
|
+
children: t("searchTitle")
|
|
17405
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
|
|
17406
|
+
t,
|
|
17407
|
+
children: t(hint)
|
|
17408
|
+
})]
|
|
17409
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17410
|
+
className: "codexSubscriptionSearchChoices codexSubscriptionQuotaModes",
|
|
17411
|
+
"data-saving": snapshot.saving || void 0,
|
|
17412
|
+
"aria-busy": snapshot.saving || void 0,
|
|
17413
|
+
role: "radiogroup",
|
|
17414
|
+
"aria-label": t("searchTitle"),
|
|
17415
|
+
children: [
|
|
17416
|
+
choice(SEARCH_PROVIDER_AUTO, t("searchAuto")),
|
|
17417
|
+
choice("dsh", "DSH"),
|
|
17418
|
+
choice(SEARCH_PROVIDER_CODEX, "Codex")
|
|
17419
|
+
]
|
|
17015
17420
|
})]
|
|
17016
|
-
}),
|
|
17017
|
-
|
|
17018
|
-
"
|
|
17019
|
-
|
|
17020
|
-
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
|
|
17024
|
-
|
|
17025
|
-
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
17031
|
-
|
|
17032
|
-
|
|
17421
|
+
}),
|
|
17422
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17423
|
+
className: "codexSubscriptionPreference",
|
|
17424
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17425
|
+
className: "codexSubscriptionPreferenceCopy",
|
|
17426
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
17427
|
+
className: "codexSubscriptionPreferenceLabel",
|
|
17428
|
+
children: t("fetchTitle")
|
|
17429
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
|
|
17430
|
+
t,
|
|
17431
|
+
children: t(!snapshot.fetchRoutingAvailable ? "fetchUnavailableHint" : snapshot.fetchProvider === "codex" ? "fetchCodexHint" : "fetchDshHint")
|
|
17432
|
+
})]
|
|
17433
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
17434
|
+
className: "codexSubscriptionSearchChoices codexSubscriptionQuotaModes",
|
|
17435
|
+
"data-saving": snapshot.saving || void 0,
|
|
17436
|
+
"aria-busy": snapshot.saving || void 0,
|
|
17437
|
+
role: "radiogroup",
|
|
17438
|
+
"aria-label": t("fetchTitle"),
|
|
17439
|
+
children: ["dsh", FETCH_PROVIDER_CODEX].map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
17440
|
+
className: "codexSubscriptionQuotaMode",
|
|
17441
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
17442
|
+
type: "radio",
|
|
17443
|
+
name: "codex-subscription-fetch-provider",
|
|
17444
|
+
checked: snapshot.fetchProvider === value,
|
|
17445
|
+
disabled: !writable || value === "codex" && !snapshot.fetchRoutingAvailable,
|
|
17446
|
+
onChange: () => {
|
|
17447
|
+
preference.set({ [FETCH_PROVIDER_FIELD]: value });
|
|
17448
|
+
}
|
|
17449
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: value === "codex" ? "Codex" : "DSH" })]
|
|
17450
|
+
}, value))
|
|
17451
|
+
})]
|
|
17452
|
+
}),
|
|
17453
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CapabilityPreferences, {
|
|
17454
|
+
preference,
|
|
17455
|
+
t,
|
|
17456
|
+
section: "search"
|
|
17457
|
+
})
|
|
17458
|
+
]
|
|
17033
17459
|
});
|
|
17034
17460
|
}
|
|
17035
17461
|
function InputImageDetailPreference({ preference, t }) {
|
|
@@ -17467,9 +17893,10 @@ void main(){
|
|
|
17467
17893
|
function ModelCatalogStatus({ preference, t, title }) {
|
|
17468
17894
|
const snapshot = usePreferenceSnapshot(preference);
|
|
17469
17895
|
const online = snapshot.catalogStatus?.source === "online";
|
|
17896
|
+
const cached = snapshot.catalogStatus?.source === "cached";
|
|
17470
17897
|
const { refresh: catalogRefresh } = snapshot.catalogStatus ?? {};
|
|
17471
17898
|
const failed = snapshot.modelError || catalogRefresh === "failed";
|
|
17472
|
-
const message = snapshot.modelsLoading || catalogRefresh === "refreshing" ? "catalogLoading" : failed && !online ? "catalogFailed" : online ? "catalogOnline" : "catalogSignedOut";
|
|
17899
|
+
const message = snapshot.modelsLoading || catalogRefresh === "refreshing" ? "catalogLoading" : failed && cached ? "catalogCachedFailed" : failed && !online ? "catalogFailed" : online ? "catalogOnline" : cached ? "catalogCached" : "catalogSignedOut";
|
|
17473
17900
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17474
17901
|
className: "codexModelsHead",
|
|
17475
17902
|
children: [
|
|
@@ -17479,7 +17906,7 @@ void main(){
|
|
|
17479
17906
|
role: failed && !online ? "alert" : void 0,
|
|
17480
17907
|
children: t(message)
|
|
17481
17908
|
}),
|
|
17482
|
-
online || catalogRefresh !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
17909
|
+
online || cached || catalogRefresh !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
17483
17910
|
type: "button",
|
|
17484
17911
|
variant: "outline",
|
|
17485
17912
|
disabled: snapshot.modelsLoading,
|
|
@@ -18773,6 +19200,10 @@ void main(){
|
|
|
18773
19200
|
if (period.usedPercent !== void 0) return void 0;
|
|
18774
19201
|
return period.endsAt > now ? "current" : "past";
|
|
18775
19202
|
}
|
|
19203
|
+
const historyPeriodKey = (period) => `${period.startsAt}:${period.endsAt}:${period.windowMinutes ?? ""}`;
|
|
19204
|
+
function selectHistoryPeriod(periods, selected, now = Date.now()) {
|
|
19205
|
+
return periods.find((period) => historyPeriodKey(period) === selected) ?? periods.find((period) => period.startsAt <= now && period.endsAt > now) ?? periods[0];
|
|
19206
|
+
}
|
|
18776
19207
|
//#endregion
|
|
18777
19208
|
//#region src/usage-heatmap.js
|
|
18778
19209
|
const pad = (value) => String(value).padStart(2, "0");
|
|
@@ -18959,7 +19390,7 @@ void main(){
|
|
|
18959
19390
|
const amount = (value) => value > 0 && value < .1 ? "<0.1" : (value >= 10 ? Math.round(value) : Math.round(value * 10) / 10).toLocaleString(uiLocale());
|
|
18960
19391
|
const labelOf = (dimension, key, t) => dimension === "model" ? key : LABELS.has(key) ? t(LABELS.get(key)) : key.replaceAll("_", " ");
|
|
18961
19392
|
function Rows({ dimension, rows, total, t }) {
|
|
18962
|
-
const top = Math.max(total, ...rows.map((row) => row.percent));
|
|
19393
|
+
const top = Math.max(total ?? 0, ...rows.map((row) => row.percent));
|
|
18963
19394
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
18964
19395
|
className: "codexSubscriptionHistoryGroup",
|
|
18965
19396
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { children: t(`historyBy_${dimension}`) }), rows.toSorted((a, b) => b.percent - a.percent).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -18979,7 +19410,7 @@ void main(){
|
|
|
18979
19410
|
}, row.key))]
|
|
18980
19411
|
});
|
|
18981
19412
|
}
|
|
18982
|
-
function UsageHistory({ rpc, t, signedIn, resetKey }) {
|
|
19413
|
+
function UsageHistory({ rpc, t, signedIn, resetKey, refreshKey }) {
|
|
18983
19414
|
const [open, setOpen] = (0, react.useState)(false);
|
|
18984
19415
|
const [state, setState] = (0, react.useState)({ status: "idle" });
|
|
18985
19416
|
const [selected, setSelected] = (0, react.useState)();
|
|
@@ -18989,11 +19420,14 @@ void main(){
|
|
|
18989
19420
|
setState({ status: "idle" });
|
|
18990
19421
|
setSelected(void 0);
|
|
18991
19422
|
}, [signedIn, resetKey]);
|
|
18992
|
-
(0, react.
|
|
18993
|
-
if (!
|
|
19423
|
+
const load = (0, react.useCallback)((force) => {
|
|
19424
|
+
if (!signedIn) return;
|
|
18994
19425
|
const id = ++request.current;
|
|
18995
|
-
setState(
|
|
18996
|
-
|
|
19426
|
+
setState((previous) => ({
|
|
19427
|
+
status: "loading",
|
|
19428
|
+
value: previous.value
|
|
19429
|
+
}));
|
|
19430
|
+
recoveryCall(rpc, "usage/history", { force }, 2e4).then((value) => {
|
|
18997
19431
|
if (request.current === id) setState({
|
|
18998
19432
|
status: "ready",
|
|
18999
19433
|
value
|
|
@@ -19004,16 +19438,24 @@ void main(){
|
|
|
19004
19438
|
message: error.message
|
|
19005
19439
|
});
|
|
19006
19440
|
});
|
|
19441
|
+
}, [signedIn, rpc]);
|
|
19442
|
+
(0, react.useEffect)(() => {
|
|
19443
|
+
if (!open || !signedIn) return;
|
|
19444
|
+
load(false);
|
|
19445
|
+
return () => {
|
|
19446
|
+
request.current += 1;
|
|
19447
|
+
};
|
|
19007
19448
|
}, [
|
|
19008
19449
|
open,
|
|
19009
19450
|
signedIn,
|
|
19010
|
-
|
|
19011
|
-
|
|
19451
|
+
resetKey,
|
|
19452
|
+
refreshKey,
|
|
19453
|
+
load
|
|
19012
19454
|
]);
|
|
19013
19455
|
if (!signedIn) return null;
|
|
19014
19456
|
const value = state.value;
|
|
19015
19457
|
const periods = [...value?.periods ?? []].sort((a, b) => b.startsAt - a.startsAt);
|
|
19016
|
-
const period = periods
|
|
19458
|
+
const period = selectHistoryPeriod(periods, selected);
|
|
19017
19459
|
const reason = period === void 0 ? void 0 : pendingReason(period);
|
|
19018
19460
|
const asOfDate = value?.asOf ? new Date(value.asOf).toLocaleDateString(uiLocale(), {
|
|
19019
19461
|
month: "numeric",
|
|
@@ -19025,6 +19467,13 @@ void main(){
|
|
|
19025
19467
|
onToggle: (event) => setOpen(event.currentTarget.open),
|
|
19026
19468
|
children: [
|
|
19027
19469
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: t("historyTitle") }),
|
|
19470
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
19471
|
+
className: "codexSubscriptionHistoryRefresh",
|
|
19472
|
+
type: "button",
|
|
19473
|
+
disabled: state.status === "loading",
|
|
19474
|
+
onClick: () => load(true),
|
|
19475
|
+
children: t("historyRefresh")
|
|
19476
|
+
}),
|
|
19028
19477
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19029
19478
|
"aria-live": "polite",
|
|
19030
19479
|
children: [
|
|
@@ -19038,12 +19487,12 @@ void main(){
|
|
|
19038
19487
|
role: "alert",
|
|
19039
19488
|
children: state.message
|
|
19040
19489
|
}) : null,
|
|
19041
|
-
state.status === "ready" && value
|
|
19490
|
+
state.status === "ready" && value?.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19042
19491
|
className: "codexSubscriptionEmpty",
|
|
19043
19492
|
role: "status",
|
|
19044
19493
|
children: t("historyUnavailable")
|
|
19045
19494
|
}) : null,
|
|
19046
|
-
state.status === "ready" && value
|
|
19495
|
+
state.status === "ready" && value?.available !== false && period === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19047
19496
|
className: "codexSubscriptionEmpty",
|
|
19048
19497
|
role: "status",
|
|
19049
19498
|
children: t("historyEmpty")
|
|
@@ -19059,9 +19508,9 @@ void main(){
|
|
|
19059
19508
|
type: "button",
|
|
19060
19509
|
"aria-pressed": item === period,
|
|
19061
19510
|
title: item.usedPercent === void 0 ? t("historyPending") : void 0,
|
|
19062
|
-
onClick: () => setSelected(item
|
|
19511
|
+
onClick: () => setSelected(historyPeriodKey(item)),
|
|
19063
19512
|
children: `${day(item.startsAt)}–${day(item.endsAt)}`
|
|
19064
|
-
}, item
|
|
19513
|
+
}, historyPeriodKey(item)))
|
|
19065
19514
|
}),
|
|
19066
19515
|
reason === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
19067
19516
|
className: "codexSubscriptionHistorySummary",
|
|
@@ -19069,8 +19518,13 @@ void main(){
|
|
|
19069
19518
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19070
19519
|
className: "codexSubscriptionEmpty",
|
|
19071
19520
|
role: "status",
|
|
19072
|
-
children: fill(t(reason === "current" ? "historyPendingCurrent" : "historyPendingPast"), { date: asOfDate })
|
|
19521
|
+
children: fill(t(reason === "current" ? "historyPendingCurrent" : asOfDate ? "historyPendingPast" : "historyPendingPastUnknown"), { date: asOfDate })
|
|
19073
19522
|
}),
|
|
19523
|
+
reason === void 0 && present.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19524
|
+
className: "codexSubscriptionEmpty",
|
|
19525
|
+
role: "status",
|
|
19526
|
+
children: t("historyNoBreakdown")
|
|
19527
|
+
}) : null,
|
|
19074
19528
|
present.map((dimension) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Rows, {
|
|
19075
19529
|
dimension,
|
|
19076
19530
|
rows: period.breakdowns[dimension],
|
|
@@ -19109,26 +19563,6 @@ void main(){
|
|
|
19109
19563
|
}), estimate ? ` ${t("creditsExpiryEstimate")}` : ""] })
|
|
19110
19564
|
});
|
|
19111
19565
|
}
|
|
19112
|
-
/** A long window that will run out before it resets says so, in plain words with a day and part of the day. */
|
|
19113
|
-
function PaceWarning({ window, t }) {
|
|
19114
|
-
const now = Date.now();
|
|
19115
|
-
const pace = quotaPace({
|
|
19116
|
-
remainingPercent: window.remainingPercent,
|
|
19117
|
-
windowSeconds: window.windowSeconds,
|
|
19118
|
-
resetsAt: window.resetsAt,
|
|
19119
|
-
now
|
|
19120
|
-
});
|
|
19121
|
-
if (pace === void 0) return null;
|
|
19122
|
-
const words = paceWords(pace, now, {
|
|
19123
|
-
t,
|
|
19124
|
-
locale: uiLocale()
|
|
19125
|
-
});
|
|
19126
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19127
|
-
className: "codexSubscriptionPace",
|
|
19128
|
-
role: "status",
|
|
19129
|
-
children: fill(t("paceWarning"), words)
|
|
19130
|
-
});
|
|
19131
|
-
}
|
|
19132
19566
|
function ResetTime({ resetsAt, t }) {
|
|
19133
19567
|
const date = Number.isSafeInteger(resetsAt) ? validDate(resetsAt * 1e3) : void 0;
|
|
19134
19568
|
if (date === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("resetUnknown") });
|
|
@@ -19356,42 +19790,12 @@ void main(){
|
|
|
19356
19790
|
])).get(error instanceof Error ? error.message : "") ?? "resetFailed");
|
|
19357
19791
|
}
|
|
19358
19792
|
function UsageCard({ rpc, t, signedIn, resetKey, preference }) {
|
|
19359
|
-
const
|
|
19360
|
-
const
|
|
19361
|
-
const [busy, setBusy] = (0, react.useState)(false);
|
|
19362
|
-
const [error, setError] = (0, react.useState)();
|
|
19363
|
-
const request = (0, react.useRef)(0);
|
|
19793
|
+
const { usage, busy, error, now, refresh } = useQuotaUsage(rpc, signedIn);
|
|
19794
|
+
const forecastMode = usePreferenceSnapshot(preference).quickQuotaMode === QUICK_QUOTA_MODE_FORECAST;
|
|
19364
19795
|
const load = (force) => {
|
|
19365
|
-
if (
|
|
19366
|
-
const id = ++request.current;
|
|
19367
|
-
setBusy(true);
|
|
19368
|
-
setError(void 0);
|
|
19369
|
-
recoveryCall(rpc, "usage", { force }).then((next) => {
|
|
19370
|
-
if (request.current === id) {
|
|
19371
|
-
setUsage(next);
|
|
19372
|
-
setUsageRefreshGeneration((value) => value + 1);
|
|
19373
|
-
if (typeof window !== "undefined") window.dispatchEvent(new Event("codex-subscription:usage-loaded"));
|
|
19374
|
-
if (force) notifyQuickQuota();
|
|
19375
|
-
}
|
|
19376
|
-
}).catch((error) => {
|
|
19377
|
-
if (request.current === id) setError(error.message);
|
|
19378
|
-
}).finally(() => {
|
|
19379
|
-
if (request.current === id) setBusy(false);
|
|
19380
|
-
});
|
|
19796
|
+
if (signedIn) refresh(force).catch(() => {});
|
|
19381
19797
|
};
|
|
19382
|
-
|
|
19383
|
-
setUsage(void 0);
|
|
19384
|
-
if (signedIn) load(false);
|
|
19385
|
-
else {
|
|
19386
|
-
request.current += 1;
|
|
19387
|
-
setUsage(void 0);
|
|
19388
|
-
setError(void 0);
|
|
19389
|
-
setBusy(false);
|
|
19390
|
-
}
|
|
19391
|
-
return () => {
|
|
19392
|
-
request.current += 1;
|
|
19393
|
-
};
|
|
19394
|
-
}, [signedIn, resetKey]);
|
|
19798
|
+
const usageRefreshGeneration = usage?.fetchedAt ?? 0;
|
|
19395
19799
|
const visibleUsage = signedIn ? usage : void 0;
|
|
19396
19800
|
const limits = visibleUsage?.rateLimits ?? [];
|
|
19397
19801
|
const exhausted = limits.some((limit) => limit.id !== "code_review" && limit.windows.some((window) => window.usedPercent >= 100));
|
|
@@ -19452,11 +19856,6 @@ void main(){
|
|
|
19452
19856
|
className: "codexSubscriptionLimits",
|
|
19453
19857
|
children: limits.flatMap((limit) => limit.windows.map((window, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19454
19858
|
className: "codexSubscriptionLimit",
|
|
19455
|
-
"data-pace": quotaPace({
|
|
19456
|
-
remainingPercent: window.remainingPercent,
|
|
19457
|
-
windowSeconds: window.windowSeconds,
|
|
19458
|
-
resetsAt: window.resetsAt
|
|
19459
|
-
}) ? "true" : void 0,
|
|
19460
19859
|
children: [
|
|
19461
19860
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19462
19861
|
className: "codexSubscriptionLimitTop",
|
|
@@ -19472,18 +19871,24 @@ void main(){
|
|
|
19472
19871
|
}),
|
|
19473
19872
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
19474
19873
|
className: "codexSubscriptionLimitMeta",
|
|
19475
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
19874
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
19476
19875
|
className: "codexSubscriptionLimitPeriod",
|
|
19477
|
-
children:
|
|
19876
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: windowLabel(window.windowSeconds, t) })
|
|
19478
19877
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResetTime, {
|
|
19479
19878
|
resetsAt: window.resetsAt,
|
|
19480
19879
|
t
|
|
19481
19880
|
})]
|
|
19482
19881
|
}),
|
|
19483
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
19484
|
-
|
|
19485
|
-
|
|
19486
|
-
|
|
19882
|
+
forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
19883
|
+
className: "codexSubscriptionForecast",
|
|
19884
|
+
role: "status",
|
|
19885
|
+
children: formatQuotaForecast(window.forecast, t, {
|
|
19886
|
+
...window,
|
|
19887
|
+
fetchedAt: visibleUsage.fetchedAt,
|
|
19888
|
+
now,
|
|
19889
|
+
refreshError: error !== void 0
|
|
19890
|
+
})
|
|
19891
|
+
}) : null
|
|
19487
19892
|
]
|
|
19488
19893
|
}, `${limit.id}-${window.windowSeconds}-${index}`)))
|
|
19489
19894
|
}),
|
|
@@ -19497,7 +19902,8 @@ void main(){
|
|
|
19497
19902
|
rpc,
|
|
19498
19903
|
t,
|
|
19499
19904
|
signedIn,
|
|
19500
|
-
resetKey
|
|
19905
|
+
resetKey,
|
|
19906
|
+
refreshKey: usageRefreshGeneration
|
|
19501
19907
|
}),
|
|
19502
19908
|
visibleUsage?.chatPass === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
19503
19909
|
className: "codexSubscriptionLimits",
|
|
@@ -20014,6 +20420,27 @@ void main(){
|
|
|
20014
20420
|
];
|
|
20015
20421
|
const ComposerRight = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodexComposerQuota, { ...props }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceCallButton, { ...props })] });
|
|
20016
20422
|
function apply(ctx) {
|
|
20423
|
+
if (new URL(window.location.href).searchParams.has("codexVoiceSession")) ctx.inject(["uiWorkspace", "sessions"], (scope) => scope.effect(() => {
|
|
20424
|
+
const sessions = scope.get("sessions"), controller = new AbortController();
|
|
20425
|
+
let attempted = false;
|
|
20426
|
+
const restore = () => {
|
|
20427
|
+
if (attempted || typeof sessions.list?.getSnapshot === "function" && sessions.list.getSnapshot().phase !== "ready") return;
|
|
20428
|
+
attempted = true;
|
|
20429
|
+
restoreVoiceConversation({
|
|
20430
|
+
href: window.location.href,
|
|
20431
|
+
workspace: scope.get("uiWorkspace"),
|
|
20432
|
+
history: window.history,
|
|
20433
|
+
sessions,
|
|
20434
|
+
signal: controller.signal
|
|
20435
|
+
}).catch(() => {});
|
|
20436
|
+
};
|
|
20437
|
+
const unsubscribe = sessions.list?.subscribe?.(restore) ?? (() => {});
|
|
20438
|
+
restore();
|
|
20439
|
+
return () => {
|
|
20440
|
+
controller.abort();
|
|
20441
|
+
unsubscribe();
|
|
20442
|
+
};
|
|
20443
|
+
}, "codex-subscription: browser voice conversation"));
|
|
20017
20444
|
const diagnostics = createHostDiagnostics();
|
|
20018
20445
|
ctx.effect(() => diagnostics.register(ctx.slots), "codex-subscription: host inspection");
|
|
20019
20446
|
const imageViewer = new SubscriptionImageViewerService();
|
|
@@ -20030,6 +20457,17 @@ void main(){
|
|
|
20030
20457
|
}, "codex-subscription: style");
|
|
20031
20458
|
const rpc = createSubscriptionRpcClient(ctx.get("connection").rpc);
|
|
20032
20459
|
const preference = createPreferenceController(rpc);
|
|
20460
|
+
const quotaUsage = quotaUsageController(rpc);
|
|
20461
|
+
ctx.effect(() => {
|
|
20462
|
+
let mode = preference.getSnapshot().quickQuotaMode;
|
|
20463
|
+
return preference.subscribe(() => {
|
|
20464
|
+
const next = preference.getSnapshot().quickQuotaMode;
|
|
20465
|
+
if (next !== mode) {
|
|
20466
|
+
mode = next;
|
|
20467
|
+
quotaUsage.invalidate({ preserveUsage: true });
|
|
20468
|
+
}
|
|
20469
|
+
});
|
|
20470
|
+
}, "codex-subscription: quota preference snapshot");
|
|
20033
20471
|
const defaultModel = createDefaultModelController(rpc);
|
|
20034
20472
|
ctx.effect(() => {
|
|
20035
20473
|
let previous = JSON.stringify(preference.getSnapshot(), (key, value) => key.startsWith("image") || key === "" ? value : void 0);
|
|
@@ -20044,6 +20482,7 @@ void main(){
|
|
|
20044
20482
|
preference.load();
|
|
20045
20483
|
accountStatus.load();
|
|
20046
20484
|
const disposeReset = ctx.on("connection/reset", () => {
|
|
20485
|
+
quotaUsage.invalidate();
|
|
20047
20486
|
preference.load();
|
|
20048
20487
|
preference.refreshModels();
|
|
20049
20488
|
accountStatus.reload();
|