dsh-agent-sdk-bridge 1.1.5 → 1.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/DEVELOPMENT.md CHANGED
@@ -9,6 +9,17 @@
9
9
  没装时只有对应页面报错,插件照常加载。
10
10
  - **品牌隔离**:各 provider 的 CLI 查找、模型目录缓存、会话池、账户读取、模型开关全部按 brand
11
11
  分开。`QODERCLI_PATH` 若指向另一 Qoder 版本,对应版本会明确报错而不是借用那个 CLI 的账号。
12
+ - **Qoder 的声明窗口必须稳定**:Qoder 的 `context_usage_ratio` 是「按 CLI 实际运行的窗口」算的,
13
+ 而 DSH 又用适配器上报的 `contextWindow` 当分母。两者一变,环就会跳。实测目录里 `dfmodel`
14
+ 等模型声明 `availableContextWindows: [200000, 400000, 1000000]`、默认 200000,用户选 1M 是
15
+ 上游真支持的档位。旧代码在目录短暂读不到时退回静态 `DEFAULT_CONTEXT_WINDOW`(200000),
16
+ 于是同一会话会在 1M 与 200K 之间翻转:分母变了,DSH 的压缩预算 `contextWindow - maxTokens
17
+ - headroom` 也一起从 800K 掉到约 102K,一个才 10% 的会话就被自动压缩(历史里 t18 在
18
+ 99,747 token 时压缩、随后掉到 37,699,正是这种「小幅跳变」)。现在 `declaredWindow()` 记住
19
+ 每个路由上一次成功解析的窗口与可选项,目录缺席时复用它而不是退回 200K;
20
+ `resolveDeclaredWindow()` 只在模型确实声明了该档位时才采用用户覆盖(`auto` 只声明
21
+ `[200000]`,存了 1M 也会被忽略),`/models` 对单档模型回传
22
+ `contextWindowSelectable: false`,页面显示「上游固定」。
12
23
  - **CodeBuddy**:`src/codebuddy.ts` 自成一体会话(`unstable_v2_createSession` + 流式消息),
13
24
  模型目录取自 `getAvailableModelsRaw()`,账户取自一次性 `query().accountInfo()`;登录走
14
25
  `unstable_v2_authenticate`,`global`/`cn` 分别映射为 SDK 的 `external`/`internal`。
@@ -49,6 +60,29 @@
49
60
  `CODEBUDDY_AUTH_TOKEN` + 该目录启动。页面在切区域时用 `fresh=1` 绕开宿主缓存,并校验
50
61
  `/models` 回显的 `region`。设置页的所有分支都渲染相同的 h2 / intro / 卡片前缀,避免切区时
51
62
  卡片因子节点下标变化被重建、把下拉框弹回配置里的旧区域。
63
+ - **CodeBuddy 的上下文窗口必须真正下发**:`contextWindow.supportedLengths` 才是可选项,
64
+ `maxInputTokens` 只是物理上限。两套目录实测不同:国内站所有模型 `supportedLengths: null`
65
+ (`set_config{contextWindow}` 被拒,`Allowed: <none>`);国际站如 `deepseek-v4.1-flash` 是
66
+ `[300K, 1M]`、`defaultLength` 300K。CLI 按「会话 override > defaultLength > 最小档 > 物理
67
+ 上限」解析有效预算,并据此设压缩阈值(92%)与网关限额。只把窗口告诉 DSH 而不下发时,宿主按
68
+ 1M 算、会话按 300K 跑:历史一过 276K 就被紧急压缩(日志 `Compact … trigger=blocking_limit`),
69
+ 上下文环从几十 % 塌到 2–3 %,下一轮补齐再涨回,正是「每轮被重置」的现象。实现:
70
+ `contextWindows` 只收集 `supportedLengths`,`contextWindowFor()` 对不支持档位的模型返回
71
+ `undefined`(旧覆盖值也随之失效);`windowOption()` 对支持档位的模型始终返回一个值——用户选
72
+ 的档位,或模型默认(CLI 拒绝 `null` 清空:`contextWindow must be a positive safe integer`);
73
+ `CodeBuddySession.applyContextWindow()` 在 `setModel` 之后按 model+window 去重发送。
74
+ `/models` 回传 `contextWindowSelectable`,页面把固定窗口模型显示为「上游固定」。
75
+ 另注:`CBC_SESSION_CONFIG_SYNC=1` 时 `result._meta` 的 `codebuddy.ai/contextWindow` 是模型
76
+ 物理窗口(如 1000000),不是用户选择。
77
+ - **图片要同时给像素和路径**:DSH 原生适配器除了图片块,还会附一句
78
+ `requestImageHandleText()`——附件名、像素尺寸、**只读归一化副本的宿主路径**,以及「编辑前先复制成
79
+ 可写 `.png`」的指示。桥接此前只发像素:模型能看懂图,但用户说「取反色保存」时它去工作区找一个
80
+ 从未存在过的文件(Qoder 的原话是「图片没有保存在工作目录中」),而 DeepSeek 官方因为有路径能直接
81
+ 处理。现在 `render.ts` 的 `imageRefText()` 复用同一文案,`ImagePathResolver` 由
82
+ `ctx.attachments.imageHostPath()` 取宿主路径、再经 `ctx.fs.processPathFromHostPath()` 映射到工具
83
+ 执行世界;Qoder / CodeBuddy / MiniMax 在图片块前插入这条句柄,历史图片(rebuild 时按文本重放、
84
+ 不发像素)同样带路径。另外三个适配器都会记住每个路由上一次验证过的 `vision` 能力:目录某次读不到
85
+ 时不再谎报 text-only——那会让 DSH 在适配器之前就把像素剥成占位符。
52
86
  - **CodeBuddy 额度**:SDK 没有额度方法,`readQuotaWithToken()` 用登录 token 调
53
87
  `POST /v2/billing/meter/get-user-resource`(国内与国际同协议),按积分包汇总实时余额;
54
88
  额度读取优先用保存的 token,缺失时才静默 `authenticate`,不会拉起浏览器。卡片里的积分包
package/FAQ.md CHANGED
@@ -44,6 +44,30 @@ bearer token,只留在本机,请不要分享或提交到仓库。从旧版
44
44
  `tools: []` 禁用 CLI 内置工具,只保留宿主通过 MCP 挂入的工具;CodeBuddy 把 MCP server 名
45
45
  规范成 `dsh_host` 的写法也已兼容。升级后重启 DSH Web 即可。
46
46
 
47
+ **Qoder 的上下文环为什么也会小幅跳一下(比如从 60% 掉到 20% 又涨回来)?** 因为分母曾经会
48
+ 短暂变成 200K。Qoder 的 `context_usage_ratio` 按「CLI 实际运行的窗口」算,DSH 又用适配器上报的
49
+ 窗口当分母;目录里 `dfmodel` 等模型其实声明了 `[200K, 400K, 1M]`,你选 1M 是上游支持的。旧代码
50
+ 在目录某一刻没读到时退回静态 200K,同一会话的窗口就在 1M 与 200K 之间翻转:分母变小,压缩预算
51
+ 也从 80 万掉到约 10 万,于是一个才 10% 的会话被自动压缩,环从 60% 掉到 20% 再随历史增长爬回来。
52
+ 现在插件会记住每个模型上一次解析到的真实窗口,目录暂时读不到时继续用它;只有模型确实声明过的
53
+ 档位才会被采用(例如 `auto` 只支持 200K,存了 1M 也不会再按 1M 算)。
54
+
55
+ **给 CodeBuddy 设了 1M 上下文,为什么对话里上下文环会突然变得很小、过一阵又变大?** 因为窗口
56
+ 设置过去只告诉了 DSH,没告诉 CodeBuddy 的会话。CodeBuddy 只接受模型自己声明的档位
57
+ (`contextWindow.supportedLengths`):国际站目录里 `deepseek-v4.1-flash` 是 `[300K, 1M]`、
58
+ 默认 **300K**,而插件按物理上限 1M 上报给 DSH。内层会话按 300K 运行,历史一旦越过 276K(92%)
59
+ 就被 CLI 紧急压缩成摘要,上下文环从几十 % 掉到 2–3 %;下一轮历史重新补齐又涨回去,看起来就像
60
+ 「每轮被重置」。现在插件会把 DSH 显示的那个窗口用 `set_config{contextWindow}` 真正下发给内层
61
+ 会话,两边分母一致;改回「默认」时会显式下发模型默认值(CLI 拒绝清空),不支持档位的模型
62
+ (国内站全部报 `null`)页面显示「上游固定」,不再给无效下拉框。
63
+
64
+ **为什么 DeepSeek 官方能让模型改图,Qoder / CodeBuddy 只会说「找不到这张图片」?** 因为像素和路径
65
+ 是两件事。图片块让模型**看见**内容,但「取反色后保存」还需要知道文件在哪;DSH 原生适配器会在图片旁
66
+ 附上只读副本的路径并提示「编辑前先复制成可写 `.png`」,桥接此前只发了像素,模型只能去工作区里瞎找。
67
+ 现在 Qoder、CodeBuddy、MiniMax 都会带上同一句路径句柄(历史上传过的图片在重建上下文时也保留),
68
+ 模型可以直接复制、处理并保存。顺带修好另一个隐患:目录某一刻读不到时,不再把视觉模型临时当成
69
+ text-only,否则 DSH 会在适配器之前就把像素换成占位文本。
70
+
47
71
  **点了「登录」却没有弹出浏览器,或者弹出了两个?** CodeBuddy 的 CLI 在登录流程里会自己打开
48
72
  浏览器,插件只把登录链接显示在卡片上作为兜底,不再额外打开,所以一次登录只会有一个标签页。
49
73
  每次点击还会先清除该区域在 CLI 中缓存的旧凭据,再启动全新的授权流程;SDK 的 `authenticate()`
package/client.js CHANGED
@@ -62,6 +62,8 @@ window.__ModuleLoader__.load({
62
62
  colEnabled: '启用',
63
63
  windowDefault: '默认',
64
64
  windowDefaultHint: '跟随上游声明的窗口',
65
+ windowFixed: '上游固定',
66
+ windowFixedHint: '该模型在上游只提供这一个上下文窗口,选择其它值会被上游拒绝,因此这里不提供下拉选择。',
65
67
  vision: '读图',
66
68
  free: '免费',
67
69
  advanced: '高级设置',
@@ -99,8 +101,7 @@ window.__ModuleLoader__.load({
99
101
  usagePlan: '套餐',
100
102
  usageUsed: '已用',
101
103
  usageRemaining: '剩余',
102
- usageOf: '/',
103
- usageCredits: 'credits',
104
+ usageCredits: '积分',
104
105
  usagePlanQuota: '套餐额度',
105
106
  usageAddOn: '加量包',
106
107
  usageOrgPackage: '组织资源包',
@@ -250,6 +251,8 @@ window.__ModuleLoader__.load({
250
251
  colEnabled: 'On',
251
252
  windowDefault: 'Default',
252
253
  windowDefaultHint: "Follow upstream's declared window",
254
+ windowFixed: 'fixed upstream',
255
+ windowFixedHint: 'This model offers exactly one context window upstream; any other value is rejected, so there is no selector here.',
253
256
  vision: 'Vision',
254
257
  free: 'Free',
255
258
  advanced: 'Advanced',
@@ -287,7 +290,6 @@ window.__ModuleLoader__.load({
287
290
  usagePlan: 'Plan',
288
291
  usageUsed: 'Used',
289
292
  usageRemaining: 'Remaining',
290
- usageOf: '/',
291
293
  usageCredits: 'credits',
292
294
  usagePlanQuota: 'Plan quota',
293
295
  usageAddOn: 'Add-on package',
@@ -558,10 +560,18 @@ window.__ModuleLoader__.load({
558
560
  log: { margin: '0', maxHeight: '240px', overflowY: 'auto', padding: '8px 10px', borderRadius: '8px', border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,0.25))', background: 'var(--dsw-alias-bg-base, rgba(128,128,128,0.05))', fontFamily: 'ui-monospace, monospace', fontSize: '0.76em', lineHeight: 1.5, whiteSpace: 'pre-wrap', wordBreak: 'break-word' },
559
561
  usageCard: { display: 'flex', flexDirection: 'column', gap: '10px', padding: '14px 16px', borderRadius: '10px', border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,0.25))', background: 'var(--dsw-alias-bg-base, rgba(128,128,128,0.03))' },
560
562
  usageHead: { display: 'flex', alignItems: 'baseline', gap: '10px', flexWrap: 'wrap' },
561
- usagePct: { marginLeft: 'auto', fontSize: '0.9em', fontWeight: 600 },
562
563
  progressOuter: { height: '8px', borderRadius: '999px', background: 'var(--dsw-alias-border-l2, rgba(128,128,128,0.22))', overflow: 'hidden' },
563
564
  progressInner: { height: '100%', borderRadius: '999px', background: 'var(--dsw-alias-brand-primary, #4c6ef5)', transition: 'width .25s ease' },
564
565
  progressDanger: { background: 'var(--dsw-alias-label-danger, #e03131)' },
566
+ creditStack: { display: 'flex', flexDirection: 'column', gap: '14px' },
567
+ creditMeter: { display: 'flex', flexDirection: 'column', gap: '6px' },
568
+ creditName: { fontSize: '0.8em', opacity: 0.55 },
569
+ creditRow: { display: 'flex', alignItems: 'baseline', gap: '10px', flexWrap: 'wrap', fontSize: '0.9em' },
570
+ creditLabel: { opacity: 0.62, minWidth: '56px' },
571
+ creditAmount: { fontWeight: 600, fontSize: '1.04em', fontVariantNumeric: 'tabular-nums' },
572
+ creditPct: { marginLeft: 'auto', opacity: 0.62, fontVariantNumeric: 'tabular-nums' },
573
+ creditBar: { height: '6px', borderRadius: '999px', background: 'var(--dsw-alias-border-l2, rgba(128,128,128,0.22))', overflow: 'hidden' },
574
+ creditBarFill: { height: '100%', borderRadius: '999px', background: 'var(--dsw-alias-brand-primary, #4c6ef5)', transition: 'width .25s ease' },
565
575
  usageLine: { display: 'flex', alignItems: 'baseline', gap: '8px', flexWrap: 'wrap', fontSize: '0.86em' },
566
576
  usageLabel: { opacity: 0.62, minWidth: '72px' },
567
577
  usageValue: { fontWeight: 500 },
@@ -761,32 +771,80 @@ window.__ModuleLoader__.load({
761
771
  return t('minimaxTokenRemainingHours').replace('{n}', String(Math.floor(minutes / 60)))
762
772
  }
763
773
 
774
+ /** A finite number, or undefined for anything else. */
775
+ function countOf(value) {
776
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined
777
+ }
778
+
779
+ /**
780
+ * The used/total reading one credit bucket is rendered from.
781
+ *
782
+ * Upstream quotes a bucket either as `used` + `total` or as `remaining` +
783
+ * `total` (Qoder's organization package calls the total `cap`). Both shapes
784
+ * are normalized here, and the percentage is computed from the same numbers
785
+ * the row prints: an upstream percentage that disagreed with them would
786
+ * make the bar contradict its own label.
787
+ */
788
+ function creditReading(bucket) {
789
+ if (bucket === null || typeof bucket !== 'object') return undefined
790
+ const total = countOf(bucket.total) ?? countOf(bucket.cap)
791
+ const remaining = countOf(bucket.remaining)
792
+ const used = countOf(bucket.used) ?? (total !== undefined && remaining !== undefined ? Math.max(0, total - remaining) : undefined)
793
+ const measured = total !== undefined && total > 0 && used !== undefined
794
+ ? Math.max(0, Math.min(100, (used / total) * 100))
795
+ : undefined
796
+ const pct = measured ?? percentOf(bucket.percentage)
797
+ // Some plans report only a percentage: it still fills the bar even though
798
+ // the row has no counts to print.
799
+ if (used === undefined && total === undefined && remaining === undefined) {
800
+ return pct === undefined ? undefined : { pct }
801
+ }
802
+ return { used, total, remaining, pct }
803
+ }
804
+
805
+ /** A bucket's unit, localized when upstream says the generic "credits". */
806
+ function creditUnit(t, bucket) {
807
+ const unit = typeof bucket?.unit === 'string' ? bucket.unit.trim() : ''
808
+ if (unit === '') return t('usageCredits')
809
+ return /^credits?$/i.test(unit) ? t('usageCredits') : unit
810
+ }
811
+
764
812
  /**
765
- * One quota bucket as a line: label, `remaining / total`, percentage.
813
+ * One credit bucket in the shape both account cards use: `used / total`
814
+ * with the percentage on the right and a bar underneath.
766
815
  *
767
- * Both editions quote the same shape (`userQuota`, `addOnQuota`,
768
- * `orgResourcePackage`), so the three render through one function; a bucket
769
- * the account does not have is simply not passed in.
816
+ * A bucket the account does not have reports no numbers at all, so it
817
+ * renders nothing rather than an empty bar.
770
818
  */
771
- function QuotaLine({ t, label, bucket, fallbackUnit }) {
772
- if (bucket === undefined || bucket === null) return null
773
- const total = bucket.total ?? bucket.cap
774
- const remaining = bucket.remaining
775
- const used = bucket.used
776
- // A plan bucket the account does not have is reported as all zeros; an
777
- // empty line describes nothing, so it is omitted rather than rendered.
778
- if ((total === undefined || total === 0) && remaining === undefined) return null
779
- const pct = percentOf(bucket.percentage)
780
- const unit = bucket.unit ?? fallbackUnit ?? t('usageCredits')
781
- const amount = remaining !== undefined && total !== undefined
782
- ? `${t('usageRemaining')} ${creditsOf(remaining)} ${t('usageOf')} ${creditsOf(total)} ${unit}`
783
- : total !== undefined
784
- ? `${t('usageUsed')} ${creditsOf(used)} ${t('usageOf')} ${creditsOf(total)} ${unit}`
785
- : '—'
786
- return h('div', { style: css.usageLine },
787
- h('span', { style: css.usageLabel }, label),
788
- h('span', { style: css.usageValue }, amount),
789
- pct === undefined ? null : h('span', { style: { opacity: 0.55 } }, `${Number(pct.toFixed(1))}%`),
819
+ function CreditMeter({ t, label, bucket, danger }) {
820
+ const reading = creditReading(bucket)
821
+ if (reading === undefined) return null
822
+ const { used, total, remaining, pct } = reading
823
+ const amount = total !== undefined && used !== undefined
824
+ ? `${creditsOf(used)} / ${creditsOf(total)} ${creditUnit(t, bucket)}`
825
+ : total !== undefined && remaining !== undefined
826
+ ? `${creditsOf(remaining)} / ${creditsOf(total)} ${creditUnit(t, bucket)}`
827
+ : used !== undefined
828
+ ? `${creditsOf(used)} ${creditUnit(t, bucket)}`
829
+ : remaining !== undefined
830
+ ? `${creditsOf(remaining)} ${creditUnit(t, bucket)}`
831
+ : undefined
832
+ return h('div', { style: css.creditMeter },
833
+ label === undefined ? null : h('div', { style: css.creditName }, label),
834
+ h('div', { style: css.creditRow },
835
+ amount === undefined ? null : h('span', { style: css.creditLabel }, used !== undefined ? t('usageUsed') : t('usageRemaining')),
836
+ amount === undefined ? null : h('span', { style: css.creditAmount }, amount),
837
+ pct === undefined ? null : h('span', { style: css.creditPct }, `${Number(pct.toFixed(1))}%`),
838
+ ),
839
+ pct === undefined ? null : h('div', { style: css.creditBar },
840
+ h('div', {
841
+ style: {
842
+ ...css.creditBarFill,
843
+ width: `${pct}%`,
844
+ ...(danger === true || pct >= 100 ? css.progressDanger : {}),
845
+ },
846
+ }),
847
+ ),
790
848
  )
791
849
  }
792
850
 
@@ -834,7 +892,6 @@ window.__ModuleLoader__.load({
834
892
  const usage = snapshot?.usage
835
893
  const account = snapshot?.account
836
894
  const error = failure ?? (snapshot?.usage === undefined && snapshot?.error !== undefined ? String(snapshot.error) : undefined)
837
- const pct = percentOf(usage?.totalUsagePercentage)
838
895
  const plan = account?.subscriptionType ?? usage?.userType ?? t('usageUnknownPlan')
839
896
  const identity = account?.name ?? account?.email ?? usage?.userId
840
897
  const exceeded = usage?.isQuotaExceeded === true
@@ -872,16 +929,31 @@ window.__ModuleLoader__.load({
872
929
  h('span', { style: css.usageLabel }, t('usagePlan')),
873
930
  h('span', { style: css.usageValue }, plan),
874
931
  exceeded ? h('span', { style: { ...css.err, fontWeight: 600 } }, t('usageExceeded')) : null,
875
- pct === undefined ? null : h('span', { style: css.usagePct }, `${Number(pct.toFixed(1))}%`),
876
932
  ),
877
- pct === undefined ? null : h('div', { style: css.progressOuter },
878
- h('div', {
879
- style: { ...css.progressInner, width: `${pct}%`, ...(exceeded ? css.progressDanger : {}) },
880
- }),
933
+ h('div', { style: css.creditStack },
934
+ (() => {
935
+ const buckets = [
936
+ [t('usagePlanQuota'), usage?.userQuota],
937
+ [t('usageAddOn'), usage?.addOnQuota],
938
+ [t('usageOrgPackage'), usage?.orgResourcePackage],
939
+ ]
940
+ // Some accounts report only the overall percentage; a card with no
941
+ // meter at all would hide the one number the endpoint did give.
942
+ if (buckets.some(([, bucket]) => creditReading(bucket) !== undefined)) {
943
+ return buckets.map(([label, bucket]) => h(CreditMeter, {
944
+ key: label, t, label, bucket, danger: exceeded,
945
+ }))
946
+ }
947
+ return percentOf(usage?.totalUsagePercentage) === undefined
948
+ ? null
949
+ : h(CreditMeter, {
950
+ t,
951
+ label: t('usagePlanQuota'),
952
+ bucket: { percentage: usage.totalUsagePercentage },
953
+ danger: exceeded,
954
+ })
955
+ })(),
881
956
  ),
882
- h(QuotaLine, { t, label: t('usagePlanQuota'), bucket: usage?.userQuota }),
883
- h(QuotaLine, { t, label: t('usageAddOn'), bucket: usage?.addOnQuota }),
884
- h(QuotaLine, { t, label: t('usageOrgPackage'), bucket: usage?.orgResourcePackage }),
885
957
  h('div', { style: css.usageFoot },
886
958
  expiry === undefined || neverExpires(expiry)
887
959
  ? h('span', null, `${t('usageExpires')} ${t('usageNever')}`)
@@ -1106,9 +1178,6 @@ window.__ModuleLoader__.load({
1106
1178
  .filter(part => typeof part === 'string' && part.length > 0)
1107
1179
  .join(' · ')
1108
1180
  const quota = account?.quota
1109
- const quotaPct = quota !== undefined && quota.total > 0
1110
- ? Math.max(0, Math.min(100, (quota.used / quota.total) * 100))
1111
- : undefined
1112
1181
  // Every package is kept: the collapsed row carries the count and the
1113
1182
  // combined total, so nothing disappears behind an invisible cut.
1114
1183
  const packages = Array.isArray(quota?.packages)
@@ -1163,15 +1232,12 @@ window.__ModuleLoader__.load({
1163
1232
  ? h('div', { style: css.err }, `${t('codebuddyQuotaFailed')}:${account.quotaError}`)
1164
1233
  : h('div', { style: css.note }, t('codebuddyNoQuota')))
1165
1234
  : h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } },
1166
- h('div', { style: css.usageLine },
1167
- h('span', { style: css.usageLabel }, t('codebuddyQuotaTitle')),
1168
- h('span', { style: css.usageValue },
1169
- `${t('usageRemaining')} ${creditsOf(quota.remaining)} ${t('usageOf')} ${creditsOf(quota.total)} ${t('usageCredits')}`),
1170
- quotaPct === undefined ? null : h('span', { style: css.usagePct }, `${quotaPct.toFixed(1)}%`),
1171
- ),
1172
- quotaPct === undefined ? null : h('div', { style: css.progressOuter },
1173
- h('div', { style: { ...css.progressInner, width: `${quotaPct}%` } }),
1174
- ),
1235
+ h(CreditMeter, {
1236
+ t,
1237
+ label: t('codebuddyQuotaTitle'),
1238
+ bucket: quota,
1239
+ danger: quota.total > 0 && quota.used >= quota.total,
1240
+ }),
1175
1241
  packages.length === 0 ? null : (() => {
1176
1242
  // Same rule as the other adapters: collapsed is one summary
1177
1243
  // row (count, combined total, nearest expiry), expanded is
@@ -2136,6 +2202,13 @@ window.__ModuleLoader__.load({
2136
2202
 
2137
2203
  const rows = shown.map((m, index) => {
2138
2204
  const choices = Array.isArray(m.contextWindows) ? m.contextWindows : []
2205
+ // A model the provider pins to one window has nothing to choose: the
2206
+ // CLI rejects every other value, so a dropdown here would be a control
2207
+ // that never reaches the upstream. Show the value instead.
2208
+ const fixedWindow = m.contextWindowSelectable === false || choices.length === 0
2209
+ // The default window has its own entry; repeating it in the list reads
2210
+ // as two identical choices. A stored override equal to it still shows.
2211
+ const offered = choices.filter(n => n !== m.defaultContextWindow || n === m.override)
2139
2212
  return h('div', {
2140
2213
  key: m.id,
2141
2214
  style: { ...css.row, ...(index === 0 ? css.rowFirst : {}), ...(m.enabled ? {} : css.rowOff) },
@@ -2158,19 +2231,24 @@ window.__ModuleLoader__.load({
2158
2231
  ),
2159
2232
  h('div', { style: css.id }, m.id),
2160
2233
  ),
2161
- h('select', {
2162
- style: css.select,
2163
- value: m.override === undefined ? '' : String(m.override),
2164
- disabled: busy,
2165
- title: t('windowDefaultHint'),
2166
- onChange: event => {
2167
- const value = event.target.value
2168
- void writeWindow(all, m.id, value === '' ? undefined : Number(value))
2169
- },
2170
- },
2171
- h('option', { key: 'default', value: '' }, `${t('windowDefault')} · ${windowLabel(m.defaultContextWindow)}`),
2172
- choices.map(n => h('option', { key: String(n), value: String(n) }, windowLabel(n))),
2173
- ),
2234
+ fixedWindow
2235
+ ? h('span', {
2236
+ style: { ...css.note, minWidth: '104px', textAlign: 'right' },
2237
+ title: t('windowFixedHint'),
2238
+ }, `${windowLabel(m.contextWindow ?? m.defaultContextWindow)} · ${t('windowFixed')}`)
2239
+ : h('select', {
2240
+ style: css.select,
2241
+ value: m.override === undefined ? '' : String(m.override),
2242
+ disabled: busy,
2243
+ title: t('windowDefaultHint'),
2244
+ onChange: event => {
2245
+ const value = event.target.value
2246
+ void writeWindow(all, m.id, value === '' ? undefined : Number(value))
2247
+ },
2248
+ },
2249
+ h('option', { key: 'default', value: '' }, `${t('windowDefault')} · ${windowLabel(m.defaultContextWindow)}`),
2250
+ offered.map(n => h('option', { key: String(n), value: String(n) }, windowLabel(n))),
2251
+ ),
2174
2252
  )
2175
2253
  })
2176
2254
 
@@ -2500,7 +2578,7 @@ window.__ModuleLoader__.load({
2500
2578
  exports.name = 'dsh-agent-sdk-bridge'
2501
2579
  exports.__test = {
2502
2580
  windowLabel, priceSuffix, ADVANCED, BRANDS, zh, en,
2503
- SettingsPage, BundleSettings, UsageCard, CodeBuddyCard, QuotaLine, creditsOf, neverExpires,
2581
+ SettingsPage, BundleSettings, UsageCard, CodeBuddyCard, CreditMeter, creditReading, creditUnit, creditsOf, neverExpires,
2504
2582
  dateLabel, tokenExpiryText, packageSummary,
2505
2583
  readCache, writeCache,
2506
2584
  }