dsh-cliproxyapi-pro 1.9.0 → 1.10.0

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.en.md +24 -408
  3. package/README.md +24 -408
  4. package/lib/client.js +265 -27
  5. package/lib/host/accounts.js +178 -0
  6. package/lib/host/apply/agent-tool.js +406 -0
  7. package/lib/host/apply/commands.js +122 -0
  8. package/lib/host/apply/controller.js +121 -0
  9. package/lib/host/apply/http-routes.js +273 -0
  10. package/lib/host/apply/image-jobs.js +171 -0
  11. package/lib/host/apply/index.js +41 -0
  12. package/lib/host/apply/interpret.js +72 -0
  13. package/lib/host/apply/lifecycle.js +50 -0
  14. package/lib/host/apply/media-failures.js +68 -0
  15. package/lib/host/apply/media-service.js +202 -0
  16. package/lib/host/apply/quota-service.js +42 -0
  17. package/lib/host/apply/references.js +43 -0
  18. package/lib/host/apply/session-status.js +104 -0
  19. package/lib/host/apply/state.js +78 -0
  20. package/lib/host/apply/updates.js +55 -0
  21. package/lib/host/apply/video-command.js +152 -0
  22. package/lib/host/apply/video-edit.js +253 -0
  23. package/lib/host/apply/video-jobs.js +206 -0
  24. package/lib/host/apply-utils.js +39 -0
  25. package/lib/host/config.js +210 -0
  26. package/lib/host/controller.js +464 -0
  27. package/lib/host/discovery.js +301 -0
  28. package/lib/host/http-gate.js +144 -0
  29. package/lib/host/model-info.js +363 -0
  30. package/lib/host/model-names.js +152 -0
  31. package/lib/host/models.js +75 -0
  32. package/lib/host/mount-guard.js +56 -0
  33. package/lib/host/recommend.js +367 -0
  34. package/lib/host/routes.js +165 -0
  35. package/lib/host/runtime.js +471 -0
  36. package/lib/host/state-store.js +39 -0
  37. package/lib/host/status-text.js +93 -0
  38. package/lib/index.js +18 -4417
  39. package/lib/media/agent-tool.js +255 -0
  40. package/lib/media/choice.js +83 -0
  41. package/lib/media/classify.js +65 -0
  42. package/lib/media/codec/fit.js +76 -0
  43. package/lib/media/codec/jpeg.js +158 -0
  44. package/lib/media/codec/png.js +102 -0
  45. package/lib/media/commands/parsing.js +269 -0
  46. package/lib/media/constants.js +46 -0
  47. package/lib/media/diagnose.js +134 -0
  48. package/lib/media/images.js +165 -0
  49. package/lib/media/index.js +29 -0
  50. package/lib/media/interpret.js +126 -0
  51. package/lib/media/job-store.js +99 -0
  52. package/lib/media/mp4.js +44 -0
  53. package/lib/media/output-files.js +59 -0
  54. package/lib/media/session-store.js +293 -0
  55. package/lib/media/settings.js +255 -0
  56. package/lib/media/util.js +45 -0
  57. package/lib/media/video.js +326 -0
  58. package/lib/quota/auth-state.js +33 -0
  59. package/lib/quota/constants.js +86 -0
  60. package/lib/quota/controller.js +467 -0
  61. package/lib/quota/helpers.js +325 -0
  62. package/lib/quota/index.js +19 -0
  63. package/lib/quota/management.js +216 -0
  64. package/lib/quota/matching.js +143 -0
  65. package/lib/quota/parsers.js +352 -0
  66. package/lib/quota/probes/billing.js +80 -0
  67. package/lib/quota/probes/google.js +120 -0
  68. package/lib/quota/probes/oauth.js +27 -0
  69. package/lib/quota/probes/plugin.js +18 -0
  70. package/lib/updater/constants.js +23 -0
  71. package/lib/updater/errors.js +8 -0
  72. package/lib/updater/index.js +11 -0
  73. package/lib/updater/registry.js +83 -0
  74. package/lib/updater/settings.js +45 -0
  75. package/lib/updater/store.js +23 -0
  76. package/lib/updater/updater.js +148 -0
  77. package/lib/updater/verify.js +110 -0
  78. package/lib/updater/version.js +31 -0
  79. package/locale/en.json +1 -1
  80. package/locale/zh.json +1 -1
  81. package/package.json +6 -9
  82. package/lib/media.js +0 -2542
  83. package/lib/quota.js +0 -1748
  84. package/lib/updater.js +0 -443
package/lib/client.js CHANGED
@@ -1,6 +1,7 @@
1
1
  window.__ModuleLoader__.load({
2
2
  id: "dsh-cliproxyapi-pro",
3
3
  factory: (require) => {
4
+ // GENERATED from src/client by scripts/build-client.mjs - edit the sources, then run npm run build:client
4
5
  var module = { exports: {} };
5
6
  var exports = module.exports;
6
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -68,7 +69,7 @@ window.__ModuleLoader__.load({
68
69
  addAccountBtn: "+ 添加账号",
69
70
  removeAccountBtn: "删除此账号",
70
71
  removeConfirm: "确定删除账号「{name}」吗?它同步到模型选择器中的模型路由也会一并移除(已保存的密钥不会删除)。",
71
- addedToast: "账号已添加并启用,已按每个家族勾选最新模型。",
72
+ addedToast: "账号已添加并启用,已按产品线勾选推荐模型。",
72
73
  removedToast: "账号已删除,其模型已从模型选择器中移除",
73
74
  disabledHint: "未启用:模型不在模型选择器中,配置已保留。",
74
75
  enabledLabel: "启用此账号",
@@ -112,7 +113,7 @@ window.__ModuleLoader__.load({
112
113
  selectAllVisibleBtn: "全选当前列表",
113
114
  deselectAllVisibleBtn: "取消当前列表",
114
115
  selectRecommendedBtn: "恢复推荐精选",
115
- selectRecommendedHint: "按该服务的模型目录,每个模型家族勾选最新的一个。",
116
+ selectRecommendedHint: "只推荐旗舰:每条产品线(如 Claude Opus / Sonnet / Fable)取最新型号,再按在线资料的能力评分只保留达到本服务最强模型 80% 的产品线,最多 12 个;轻量、无评分的小众模型和被新品淘汰的旧线不推荐;另外每个接入的渠道(如 Devin、Grok)至少推荐一个它自己的最佳模型。关闭在线模型资料时改为推荐主流厂商的非轻量产品线。",
116
117
  badgeVision: "视觉 Image",
117
118
  badgeReasoning: "推理",
118
119
  badgeSelected: "已启用",
@@ -267,6 +268,9 @@ window.__ModuleLoader__.load({
267
268
  qKeyStatusSet: "已配置",
268
269
  qKeyStatusUnset: "未配置",
269
270
  qDataLabel: "额度数据",
271
+ qRefreshPolicy: "默认每 30 分钟自动刷新。账号刷新失败会暂停整个账号;单个凭证额度查询失败只暂停该凭证。手动刷新账号或保存管理密钥可重试。暂停仅保存在插件内存中,插件重启后清除,刷新页面不会清除。",
272
+ qAccountPaused: "此账号自动刷新已暂停。请手动刷新账号或保存管理密钥以重试;暂停保存在插件内存中,插件重启后清除,刷新页面不会清除。",
273
+ qCredentialPaused: "此凭证自动刷新已暂停,其他凭证不受影响。请手动刷新账号以重试;暂停保存在插件内存中,插件重启后清除,刷新页面不会清除。",
270
274
  qTotalCreds: "{n} 个凭证",
271
275
  qKeySaved: "管理密钥已保存",
272
276
  qKeyCleared: "管理密钥已清除",
@@ -551,6 +555,35 @@ window.__ModuleLoader__.load({
551
555
  mediaRunErrExpired: "CPA 已不再记得这个视频:提交已超过 3 小时。",
552
556
  mediaRunErrInvalidVideo: "CPA 返回的数据不是 MP4、MOV 或 WebM 视频。",
553
557
  mediaRunErrVideoTooLarge: "视频超过 200 MiB,未保存。",
558
+ badgeRecommended: "推荐",
559
+ recommendReason: "{line} 产品线的最新型号(依据:{source})",
560
+ recommendReasonDated: "{line} 产品线的最新型号,{date} 发布(依据:{source})",
561
+ recommendReasonChannel: "{channel} 渠道自己最好的模型({line} 产品线):每个接入的渠道至少推荐一个(依据:{source})",
562
+ recommendReasonScore: ";能力评分 {score},接近本服务最强模型",
563
+ recommendSourceOnline: "在线模型资料",
564
+ recommendSourceCatalog: "CPA 目录日期",
565
+ recommendSourceName: "模型名称中的版本号",
566
+ onlineInfoLabel: "在线模型资料",
567
+ onlineInfoHint: "开启后,每天从 models.dev 和 openrouter.ai 下载公开的模型资料(产品线、发布日期、下线状态、能力评分),用于改进推荐,并补全 CPA 未提供的上下文和输出上限。只下载,不上传任何账号、密钥、地址或模型列表。所有账号共用此开关;关闭后只按 CPA 目录推荐。",
568
+ onlineInfoOff: "已关闭,只按 CPA 目录推荐",
569
+ onlineInfoLoading: "正在获取…",
570
+ onlineInfoReady: "已更新({date})",
571
+ onlineInfoPartial: "部分来源不可用,资料更新于 {date}",
572
+ onlineInfoError: "暂时无法获取,暂按 CPA 目录推荐",
573
+ onlineInfoIdle: "尚未获取,稍后自动下载",
574
+ onlineInfoOnToast: "已开启在线模型资料",
575
+ onlineInfoOffToast: "已关闭在线模型资料",
576
+ adviceTitle: "选择建议",
577
+ adviceHint: "根据服务目录和在线资料给出的建议,不会自动修改你的选择;点击按钮后需「保存并应用」才生效。",
578
+ adviceUpgrade: "{to} 比已勾选的 {from} 更新",
579
+ adviceUpgradeDated: "{to}({date} 发布)比已勾选的 {from} 更新",
580
+ adviceMissing: "已勾选的 {id} 不在服务目录中,不会出现在模型选择器里",
581
+ adviceRetired: "已勾选的 {id} 已被上游标记为弃用或已过下线日期",
582
+ adviceAdd: "加入",
583
+ adviceReplace: "替换",
584
+ adviceRemove: "取消勾选",
585
+ adviceSwitchTo: "改为 {id}",
586
+ onlineLimitsNote: "(CPA 未提供,取自在线资料)",
554
587
  };
555
588
 
556
589
  const en = {
@@ -570,7 +603,7 @@ window.__ModuleLoader__.load({
570
603
  addAccountBtn: "+ Add Account",
571
604
  removeAccountBtn: "Delete Account",
572
605
  removeConfirm: "Delete account \"{name}\"? Its model routes are removed from the model picker too (the stored key is kept).",
573
- addedToast: "Account added and enabled; the newest model of each family is checked.",
606
+ addedToast: "Account added and enabled; the recommended model of each product line is checked.",
574
607
  removedToast: "Account deleted and its models removed from the picker",
575
608
  disabledHint: "Disabled: its models are not in the model picker; settings are kept.",
576
609
  enabledLabel: "Enable This Account",
@@ -614,7 +647,7 @@ window.__ModuleLoader__.load({
614
647
  selectAllVisibleBtn: "Check Visible",
615
648
  deselectAllVisibleBtn: "Uncheck Visible",
616
649
  selectRecommendedBtn: "Reset to Recommended",
617
- selectRecommendedHint: "Check the newest model of each family in this server's catalog.",
650
+ selectRecommendedHint: "Flagships only: the newest model of each product line (Claude Opus, Sonnet, Fable, …), keeping only lines whose online capability score reaches 80% of this server's strongest, at most 12; light, unscored niche models and lines a newer one left behind are skipped; every connected channel (Devin, Grok, …) also gets its own best model. With online model info off, the non-light lines of well-known vendors are recommended instead.",
618
651
  badgeVision: "Image",
619
652
  badgeReasoning: "Reasoning",
620
653
  badgeSelected: "Active",
@@ -769,6 +802,9 @@ window.__ModuleLoader__.load({
769
802
  qKeyStatusSet: "Set",
770
803
  qKeyStatusUnset: "Not set",
771
804
  qDataLabel: "Quota data",
805
+ qRefreshPolicy: "Automatic refresh defaults to every 30 minutes. An account refresh failure pauses the whole account; a credential quota failure pauses only that credential. Refresh the account manually or save its management key to retry. Pauses live only in plugin memory until plugin restart; reloading the page does not clear them.",
806
+ qAccountPaused: "Automatic refresh is paused for this account. Refresh the account manually or save its management key to retry. The pause lives in plugin memory until plugin restart; reloading the page does not clear it.",
807
+ qCredentialPaused: "Automatic refresh is paused for this credential; other credentials are unaffected. Refresh the account manually to retry. The pause lives in plugin memory until plugin restart; reloading the page does not clear it.",
772
808
  qTotalCreds: "{n} credentials",
773
809
  qKeySaved: "Management key saved",
774
810
  qKeyCleared: "Management key cleared",
@@ -1053,6 +1089,35 @@ window.__ModuleLoader__.load({
1053
1089
  mediaRunErrExpired: "CPA no longer knows this video: more than 3 hours have passed since it was submitted.",
1054
1090
  mediaRunErrInvalidVideo: "CPA returned data that is not an MP4, MOV or WebM video.",
1055
1091
  mediaRunErrVideoTooLarge: "The video is larger than 200 MiB and was not saved.",
1092
+ badgeRecommended: "Recommended",
1093
+ recommendReason: "Newest model of the {line} line (based on: {source})",
1094
+ recommendReasonDated: "Newest model of the {line} line, released {date} (based on: {source})",
1095
+ recommendReasonChannel: "The {channel} channel's own best model ({line} line): every connected channel gets at least one (based on: {source})",
1096
+ recommendReasonScore: "; capability score {score}, close to this server's strongest model",
1097
+ recommendSourceOnline: "online model info",
1098
+ recommendSourceCatalog: "CPA catalog dates",
1099
+ recommendSourceName: "version in the model name",
1100
+ onlineInfoLabel: "Online Model Info",
1101
+ onlineInfoHint: "When on, public model data (product lines, release dates, retirement, capability scores) is downloaded daily from models.dev and openrouter.ai to improve recommendations and to fill context and output limits the CPA catalog leaves out. Download only: no account, key, address or model list is sent. Shared by all accounts; when off, recommendations use the CPA catalog only.",
1102
+ onlineInfoOff: "Off: recommendations use the CPA catalog only",
1103
+ onlineInfoLoading: "Fetching…",
1104
+ onlineInfoReady: "Updated {date}",
1105
+ onlineInfoPartial: "Some sources unavailable; data from {date}",
1106
+ onlineInfoError: "Unavailable for now; using the CPA catalog",
1107
+ onlineInfoIdle: "Not fetched yet; downloads shortly",
1108
+ onlineInfoOnToast: "Online model info turned on",
1109
+ onlineInfoOffToast: "Online model info turned off",
1110
+ adviceTitle: "Suggestions",
1111
+ adviceHint: "Based on the server's catalog and online model info. Nothing changes on its own: a button edits the selection, and Save & Apply makes it take effect.",
1112
+ adviceUpgrade: "{to} is newer than checked {from}",
1113
+ adviceUpgradeDated: "{to} (released {date}) is newer than checked {from}",
1114
+ adviceMissing: "Checked {id} is not in the server's catalog and is missing from the model picker",
1115
+ adviceRetired: "Checked {id} is deprecated upstream or past its end date",
1116
+ adviceAdd: "Add",
1117
+ adviceReplace: "Replace",
1118
+ adviceRemove: "Uncheck",
1119
+ adviceSwitchTo: "Use {id}",
1120
+ onlineLimitsNote: " (not provided by CPA; from online model info)",
1056
1121
  };
1057
1122
 
1058
1123
  const CSS = `
@@ -2156,6 +2221,22 @@ select.dcpa-q-input { appearance: auto; padding-right: 8px; }
2156
2221
  .dcpa-models .dcpa-model-row:hover { background: var(--dsw-alias-interactive-bg-hover, transparent); }
2157
2222
  .dcpa-models .dcpa-badge { border: 0; background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2)); border-radius: 999px; padding: 1px 8px; }
2158
2223
  .dcpa-models .dcpa-editor { border-top: 0; padding: 4px 0 6px 25px; }
2224
+ /* Online model info switch, recommendation badge and selection suggestions. */
2225
+ .dcpa-advice { display: flex; flex-direction: column; gap: 8px; }
2226
+ .dcpa-advice-online { justify-content: space-between; gap: 12px; padding: 4px 0; }
2227
+ .dcpa-advice-label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
2228
+ .dcpa-advice-list {
2229
+ display: flex;
2230
+ flex-direction: column;
2231
+ gap: 4px;
2232
+ padding: 8px 10px;
2233
+ border-radius: var(--dsw-radius-md, 10px);
2234
+ background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2));
2235
+ }
2236
+ .dcpa-advice-list > .dcpa-q-sub { display: flex; align-items: center; gap: 4px; }
2237
+ .dcpa-advice-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
2238
+ .dcpa-advice-text { font-size: 13px; line-height: 18px; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }
2239
+ .dcpa-models .dcpa-badge-rec { display: inline-flex; align-items: center; gap: 4px; color: var(--dsw-alias-brand-primary, var(--dsw-alias-label-primary)); }
2159
2240
  /* Generation tab: flat rows without checkboxes, kind select + switch on the right. */
2160
2241
  .dcpa-media .dcpa-model-row { cursor: default; }
2161
2242
  .dcpa-media .dcpa-model-left { flex-wrap: wrap; }
@@ -3664,6 +3745,123 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3664
3745
  );
3665
3746
  }
3666
3747
 
3748
+ /** Why a model is recommended, from the Host's `recommendations` detail. */
3749
+ function recommendationReason(t, detail) {
3750
+ if (!detail) return "";
3751
+ const source = t(detail.source === "online" ? "recommendSourceOnline" : detail.source === "catalog" ? "recommendSourceCatalog" : "recommendSourceName");
3752
+ if (detail.via === "channel") {
3753
+ return fmt(t, "recommendReasonChannel", { channel: detail.channel ?? "", line: detail.line, source });
3754
+ }
3755
+ const base = detail.released
3756
+ ? fmt(t, "recommendReasonDated", { line: detail.line, date: detail.released, source })
3757
+ : fmt(t, "recommendReason", { line: detail.line, source });
3758
+ return typeof detail.score === "number" ? `${base}${fmt(t, "recommendReasonScore", { score: detail.score })}` : base;
3759
+ }
3760
+
3761
+ function modelInfoStatusText(t, info) {
3762
+ if (!info || info.enabled === false || info.state === "off") return t("onlineInfoOff");
3763
+ if (info.state === "loading") return t("onlineInfoLoading");
3764
+ const dates = Object.values(info.sources ?? {}).map((s) => s?.fetchedAt).filter(Boolean).sort();
3765
+ const latest = dates.length > 0 ? new Date(dates[dates.length - 1]) : null;
3766
+ if (latest && !Number.isNaN(latest.getTime())) {
3767
+ const when = latest.toLocaleDateString();
3768
+ return info.state === "partial" ? fmt(t, "onlineInfoPartial", { date: when }) : fmt(t, "onlineInfoReady", { date: when });
3769
+ }
3770
+ return info.state === "error" ? t("onlineInfoError") : t("onlineInfoIdle");
3771
+ }
3772
+
3773
+ /**
3774
+ * Stateless: the online-info switch (a global, saved at once) and advice
3775
+ * about the draft selection. Buttons only change the draft; the save bar
3776
+ * applies them like any other selection change.
3777
+ */
3778
+ function ModelAdvice({ t, account, global, selectedIds, busy, onSelection, onToggleOnline }) {
3779
+ const on = global?.onlineModelInfo !== false;
3780
+ const advice = account.suggestions ?? {};
3781
+ const has = (id) => selectedIds.has(id);
3782
+ const edit = (fn) => onSelection((prev) => {
3783
+ const next = new Set(prev);
3784
+ fn(next);
3785
+ return next;
3786
+ });
3787
+ const items = [];
3788
+ for (const u of Array.isArray(advice.upgrades) ? advice.upgrades : []) {
3789
+ const from = (u.from ?? []).filter(has);
3790
+ if (has(u.to) || from.length === 0) continue;
3791
+ items.push({
3792
+ key: `up:${u.to}`,
3793
+ text: fmt(t, u.released ? "adviceUpgradeDated" : "adviceUpgrade", { from: from.join(", "), to: u.to, date: u.released ?? "" }),
3794
+ actions: [
3795
+ [t("adviceAdd"), () => edit((s) => s.add(u.to))],
3796
+ [t("adviceReplace"), () => edit((s) => { s.add(u.to); for (const id of from) s.delete(id); })],
3797
+ ],
3798
+ });
3799
+ }
3800
+ const fix = (kind, entry) => {
3801
+ if (!has(entry.id)) return;
3802
+ const replacement = entry.replacement && !has(entry.replacement) ? entry.replacement : null;
3803
+ items.push({
3804
+ key: `${kind}:${entry.id}`,
3805
+ text: fmt(t, kind === "missing" ? "adviceMissing" : "adviceRetired", { id: entry.id }),
3806
+ actions: replacement
3807
+ ? [[fmt(t, "adviceSwitchTo", { id: replacement }), () => edit((s) => { s.delete(entry.id); s.add(replacement); })]]
3808
+ : [[t("adviceRemove"), () => edit((s) => s.delete(entry.id))]],
3809
+ });
3810
+ };
3811
+ for (const m of Array.isArray(advice.missing) ? advice.missing : []) fix("missing", m);
3812
+ for (const r of Array.isArray(advice.retired) ? advice.retired : []) fix("retired", r);
3813
+
3814
+ return h(
3815
+ "div",
3816
+ { className: "dcpa-advice" },
3817
+ h(
3818
+ "div",
3819
+ { className: "dcpa-switch-row dcpa-advice-online" },
3820
+ h(
3821
+ "div",
3822
+ { className: "dcpa-advice-label" },
3823
+ h("span", { className: "dcpa-label" }, t("onlineInfoLabel")),
3824
+ h(InfoTip, { t, text: t("onlineInfoHint") }),
3825
+ h("span", { className: "dcpa-q-sub", role: "status" }, modelInfoStatusText(t, global?.modelInfo))
3826
+ ),
3827
+ h(
3828
+ "button",
3829
+ {
3830
+ type: "button",
3831
+ role: "switch",
3832
+ className: "dcpa-switch",
3833
+ "aria-checked": on,
3834
+ "aria-label": t("onlineInfoLabel"),
3835
+ disabled: busy !== null,
3836
+ onClick: () => onToggleOnline(!on),
3837
+ },
3838
+ h("span", { className: "dcpa-switch-thumb" })
3839
+ )
3840
+ ),
3841
+ items.length > 0
3842
+ ? h(
3843
+ "div",
3844
+ { className: "dcpa-advice-list", role: "region", "aria-label": t("adviceTitle") },
3845
+ h("div", { className: "dcpa-q-sub" }, t("adviceTitle"), h(InfoTip, { t, text: t("adviceHint") })),
3846
+ items.map((item) =>
3847
+ h(
3848
+ "div",
3849
+ { key: item.key, className: "dcpa-advice-item" },
3850
+ h("span", { className: "dcpa-advice-text" }, item.text),
3851
+ h(
3852
+ "span",
3853
+ { className: "dcpa-actions" },
3854
+ item.actions.map(([label, run]) =>
3855
+ h("button", { key: label, type: "button", className: "dcpa-btn dcpa-btn-sm", onClick: run }, label)
3856
+ )
3857
+ )
3858
+ )
3859
+ )
3860
+ )
3861
+ : null
3862
+ );
3863
+ }
3864
+
3667
3865
  function AccountPanel({ t, account, global, rev, busy, notice, actions, onDirtyChange }) {
3668
3866
  const syncing = busy === "refresh";
3669
3867
  const saving = busy === "save";
@@ -3867,11 +4065,19 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
3867
4065
  });
3868
4066
  }, [visibleModels]);
3869
4067
 
3870
- // Computed by the Host from this account's own catalog: newest per family.
4068
+ // Computed by the Host from this account's catalog (and online model info):
4069
+ // the newest model of each product line, with a reason per model.
3871
4070
  const recommended = Array.isArray(account.recommendedModels) ? account.recommendedModels : [];
3872
4071
  const resetRecommended = useCallback(() => {
3873
4072
  setSelectedIds(new Set(recommended));
3874
4073
  }, [recommended]);
4074
+ const recommendedById = useMemo(() => {
4075
+ const details = Array.isArray(account.recommendations) ? account.recommendations : [];
4076
+ return new Map(recommended.map((id) => [id, details.find((d) => d.id === id) ?? { id }]));
4077
+ }, [recommended, account.recommendations]);
4078
+ // A global: saved at once without touching the drafts.
4079
+ const toggleOnlineInfo = (next) =>
4080
+ void actions.patch(account.id, { onlineModelInfo: next }, next ? t("onlineInfoOnToast") : t("onlineInfoOffToast"));
3875
4081
 
3876
4082
  const updateOverride = useCallback((model, patch) => {
3877
4083
  setModelOverrides((prev) => {
@@ -4101,6 +4307,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4101
4307
  "div",
4102
4308
  { className: "dcpa-tabbody dcpa-models" },
4103
4309
  h("p", { className: "dcpa-q-sub" }, t("modelsEmptyRule")),
4310
+ h(ModelAdvice, { t, account, global, selectedIds, busy, onSelection: setSelectedIds, onToggleOnline: toggleOnlineInfo }),
4104
4311
  // Search + Segmented Filter + Batch Actions
4105
4312
  h(
4106
4313
  "div",
@@ -4268,6 +4475,14 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4268
4475
  h(
4269
4476
  "div",
4270
4477
  { className: "dcpa-model-tags" },
4478
+ recommendedById.has(m.id)
4479
+ ? h(
4480
+ "span",
4481
+ { className: "dcpa-badge dcpa-badge-rec" },
4482
+ t("badgeRecommended"),
4483
+ h(InfoTip, { t, text: recommendationReason(t, recommendedById.get(m.id)) })
4484
+ )
4485
+ : null,
4271
4486
  hasOverride
4272
4487
  ? h("span", { className: "dcpa-badge dcpa-badge-warn" }, t("customParamsBadge"))
4273
4488
  : null,
@@ -4335,7 +4550,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4335
4550
  h(
4336
4551
  "p",
4337
4552
  { className: "dcpa-hint" },
4338
- `${t("discoveredValue")}: ${formatTokens(m.discovered?.contextWindow)}`
4553
+ `${t("discoveredValue")}: ${formatTokens(m.discovered?.contextWindow)}${
4554
+ m.discovered?.onlineLimits?.includes?.("contextWindow") ? t("onlineLimitsNote") : ""
4555
+ }`
4339
4556
  )
4340
4557
  ),
4341
4558
  h(
@@ -4357,7 +4574,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
4357
4574
  h(
4358
4575
  "p",
4359
4576
  { className: "dcpa-hint" },
4360
- `${t("discoveredValue")}: ${formatTokens(m.discovered?.maxTokens)}`
4577
+ `${t("discoveredValue")}: ${formatTokens(m.discovered?.maxTokens)}${
4578
+ m.discovered?.onlineLimits?.includes?.("maxTokens") ? t("onlineLimitsNote") : ""
4579
+ }`
4361
4580
  )
4362
4581
  )
4363
4582
  ),
@@ -5422,6 +5641,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5422
5641
  let timer = null;
5423
5642
  let disposed = false;
5424
5643
  let seq = 0;
5644
+ let retryDelay = 0;
5425
5645
  const inflight = new Set();
5426
5646
 
5427
5647
  const emit = (patch) => {
@@ -5452,7 +5672,8 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5452
5672
  if (timer !== null) clearT(timer);
5453
5673
  timer = null;
5454
5674
  if (disposed || listeners.size === 0) return;
5455
- const delay = state.data?.refreshing ? QUOTA_BUSY_POLL_MS : QUOTA_POLL_MS;
5675
+ // A stale "refreshing" snapshot must not turn failed status reads into a 4 s loop.
5676
+ const delay = retryDelay || (state.data?.refreshing ? QUOTA_BUSY_POLL_MS : QUOTA_POLL_MS);
5456
5677
  timer = setT(() => {
5457
5678
  timer = null;
5458
5679
  void load().finally(schedule);
@@ -5460,18 +5681,26 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5460
5681
  };
5461
5682
 
5462
5683
  const load = async () => {
5684
+ if (disposed) return;
5463
5685
  const mine = ++seq;
5464
5686
  emit({ loading: true });
5465
5687
  try {
5466
5688
  const body = await request(API.quotaStatus);
5467
- if (mine === seq) emit({ data: body.quota ?? null, error: null, loading: false, loadedAt: Date.now() });
5689
+ if (!disposed && mine === seq) {
5690
+ retryDelay = 0;
5691
+ emit({ data: body.quota ?? null, error: null, loading: false, loadedAt: Date.now() });
5692
+ }
5468
5693
  } catch (error) {
5469
5694
  if (disposed) return;
5470
- if (mine === seq) emit({ error: error instanceof Error ? error.message : String(error), loading: false });
5695
+ if (mine === seq) {
5696
+ retryDelay = retryDelay ? Math.min(retryDelay * 2, 300 * 1000) : QUOTA_POLL_MS;
5697
+ emit({ error: error instanceof Error ? error.message : String(error), loading: false });
5698
+ }
5471
5699
  }
5472
5700
  };
5473
5701
 
5474
5702
  const mutate = async (kind, url, payload) => {
5703
+ if (disposed) return { ok: false };
5475
5704
  const mine = ++seq;
5476
5705
  emit({ busy: kind, busyAccount: payload?.accountId ?? null, error: null });
5477
5706
  try {
@@ -5480,7 +5709,10 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5480
5709
  headers: { "content-type": "application/json" },
5481
5710
  body: JSON.stringify(payload ?? {}),
5482
5711
  });
5483
- if (mine === seq) emit({ data: body.quota ?? state.data, loadedAt: Date.now() });
5712
+ if (!disposed && mine === seq) {
5713
+ retryDelay = 0;
5714
+ emit({ data: body.quota ?? state.data, error: null, loading: false, loadedAt: Date.now() });
5715
+ }
5484
5716
  emit({ busy: null, busyAccount: null });
5485
5717
  schedule();
5486
5718
  return { ok: true };
@@ -5494,6 +5726,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5494
5726
  return {
5495
5727
  getSnapshot: () => state,
5496
5728
  subscribe(fn) {
5729
+ if (disposed) return () => {};
5497
5730
  listeners.add(fn);
5498
5731
  if (listeners.size === 1) {
5499
5732
  if (state.data === null || Date.now() - state.loadedAt > QUOTA_POLL_MS) void load().finally(schedule);
@@ -5705,20 +5938,21 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
5705
5938
  }
5706
5939
 
5707
5940
  function CredentialWindows({ t, cred, windows, now }) {
5708
- if (windows.length > 0) {
5709
- return h(
5710
- "div",
5711
- { className: "dcpa-q-meters" },
5712
- windows.map((w, i) => h(QuotaMeter, { key: w.id ?? i, t, w, now }))
5713
- );
5714
- }
5941
+ const failed = cred.quotaState === "error";
5942
+ const paused = cred.autoRefreshPaused === true;
5715
5943
  const lines = [
5716
- cred.quotaState === "error"
5717
- ? h("p", { key: "q", className: "dcpa-q-note", "data-tone": "error" }, t("qQuotaError"))
5718
- : h("p", { key: "q", className: "dcpa-q-note" }, t(cred.quotaState === "unsupported" ? "qQuotaUnsupported" : "qQuotaNone")),
5719
- cred.recent ? h("p", { key: "r", className: "dcpa-q-note" }, fmt(t, "qRecent", cred.recent)) : null,
5944
+ failed || paused
5945
+ ? h("p", { key: "q", className: "dcpa-q-note", "data-tone": "error" },
5946
+ failed ? t("qQuotaError") : null,
5947
+ paused ? `${failed ? " · " : ""}${t("qCredentialPaused")}` : null)
5948
+ : windows.length === 0
5949
+ ? h("p", { key: "q", className: "dcpa-q-note" }, t(cred.quotaState === "unsupported" ? "qQuotaUnsupported" : "qQuotaNone"))
5950
+ : null,
5951
+ windows.length === 0 && cred.recent ? h("p", { key: "r", className: "dcpa-q-note" }, fmt(t, "qRecent", cred.recent)) : null,
5720
5952
  ];
5721
- return h("div", { className: "dcpa-q-meters" }, h("div", null, lines));
5953
+ return h("div", { className: "dcpa-q-meters" },
5954
+ windows.map((w, i) => h(QuotaMeter, { key: w.id ?? i, t, w, now })),
5955
+ lines.some(Boolean) ? h("div", null, lines) : null);
5722
5956
  }
5723
5957
 
5724
5958
  function CredentialRow({ t, cred, now, pickerIds }) {
@@ -6003,7 +6237,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6003
6237
  h(
6004
6238
  "div",
6005
6239
  { className: "dcpa-q-row-main" },
6006
- h("div", { className: "dcpa-q-title" }, t("qDataLabel")),
6240
+ h("div", { className: "dcpa-q-title" }, t("qDataLabel"), h(InfoTip, { t, text: t("qRefreshPolicy") })),
6007
6241
  h(
6008
6242
  "div",
6009
6243
  { className: "dcpa-q-sub" },
@@ -6012,7 +6246,8 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6012
6246
  : account.fetchedAt
6013
6247
  ? fmt(t, "qUpdated", { time: agoText(t, account.fetchedAt, now) })
6014
6248
  : t("qNeverUpdated"),
6015
- account.enabled === false ? ` · ${t("qAccountDisabled")}` : ""
6249
+ account.enabled === false ? ` · ${t("qAccountDisabled")}` : "",
6250
+ account.autoRefreshPaused === true ? ` · ${t("qAccountPaused")}` : ""
6016
6251
  )
6017
6252
  ),
6018
6253
  h(
@@ -6203,7 +6438,9 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6203
6438
  h(
6204
6439
  "div",
6205
6440
  { className: "dcpa-q-pop-foot" },
6206
- h("span", null, account.fetchedAt ? fmt(t, "qUpdated", { time: agoText(t, account.fetchedAt, now) }) : t("qPeekFooter")),
6441
+ h("span", null,
6442
+ account.fetchedAt ? fmt(t, "qUpdated", { time: agoText(t, account.fetchedAt, now) }) : t("qPeekFooter"),
6443
+ account.autoRefreshPaused === true ? ` · ${t("qAccountPaused")}` : ""),
6207
6444
  h(
6208
6445
  "button",
6209
6446
  {
@@ -6644,7 +6881,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
6644
6881
 
6645
6882
  // #region generate_media tool rows (tool.call.toolview, key "generate_media")
6646
6883
 
6647
- /** The run id the host derives from a tool call id (mirrors lib/media.js toolRunId). */
6884
+ /** The run id the host derives from a tool call id (mirrors toolRunId in lib/media/agent-tool.js). */
6648
6885
  function toolRunId(callId) {
6649
6886
  const raw = String(callId ?? "").replace(/[^A-Za-z0-9._:-]/g, "_").replace(/^[^A-Za-z0-9]+/, "").slice(0, 119);
6650
6887
  return /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/.test(raw) ? raw : null;
@@ -7475,6 +7712,7 @@ select.dcpa-q-input.dcpa-media-kind { flex: none; width: auto; height: 28px; fon
7475
7712
  );
7476
7713
  }
7477
7714
  // #endregion
7715
+
7478
7716
  const inject = ["slots", "locale"];
7479
7717
 
7480
7718
  function apply(ctx) {