dsh-agent-sdk-bridge 1.1.6 → 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 +34 -9
- package/FAQ.md +23 -8
- package/client.js +115 -50
- package/lib/index.js +248 -56
- package/lib/types/adapter.d.ts +59 -12
- package/lib/types/codebuddy-adapter.d.ts +20 -0
- package/lib/types/codebuddy.d.ts +23 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/minimax-adapter.d.ts +8 -0
- package/lib/types/render.d.ts +17 -4
- package/package.json +1 -1
- package/src/adapter.ts +125 -25
- package/src/api.ts +3 -0
- package/src/codebuddy-adapter.ts +66 -15
- package/src/codebuddy.ts +43 -2
- package/src/index.ts +33 -0
- package/src/minimax-adapter.ts +37 -13
- package/src/render.ts +42 -12
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,15 +60,29 @@
|
|
|
49
60
|
`CODEBUDDY_AUTH_TOKEN` + 该目录启动。页面在切区域时用 `fresh=1` 绕开宿主缓存,并校验
|
|
50
61
|
`/models` 回显的 `region`。设置页的所有分支都渲染相同的 h2 / intro / 卡片前缀,避免切区时
|
|
51
62
|
卡片因子节点下标变化被重建、把下拉框弹回配置里的旧区域。
|
|
52
|
-
- **CodeBuddy
|
|
53
|
-
`maxInputTokens`
|
|
54
|
-
|
|
55
|
-
`
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 在适配器之前就把像素剥成占位符。
|
|
61
86
|
- **CodeBuddy 额度**:SDK 没有额度方法,`readQuotaWithToken()` 用登录 token 调
|
|
62
87
|
`POST /v2/billing/meter/get-user-resource`(国内与国际同协议),按积分包汇总实时余额;
|
|
63
88
|
额度读取优先用保存的 token,缺失时才静默 `authenticate`,不会拉起浏览器。卡片里的积分包
|
package/FAQ.md
CHANGED
|
@@ -44,14 +44,29 @@ bearer token,只留在本机,请不要分享或提交到仓库。从旧版
|
|
|
44
44
|
`tools: []` 禁用 CLI 内置工具,只保留宿主通过 MCP 挂入的工具;CodeBuddy 把 MCP server 名
|
|
45
45
|
规范成 `dsh_host` 的写法也已兼容。升级后重启 DSH Web 即可。
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 会在适配器之前就把像素换成占位文本。
|
|
55
70
|
|
|
56
71
|
**点了「登录」却没有弹出浏览器,或者弹出了两个?** CodeBuddy 的 CLI 在登录流程里会自己打开
|
|
57
72
|
浏览器,插件只把登录链接显示在卡片上作为兜底,不再额外打开,所以一次登录只会有一个标签页。
|
package/client.js
CHANGED
|
@@ -101,8 +101,7 @@ window.__ModuleLoader__.load({
|
|
|
101
101
|
usagePlan: '套餐',
|
|
102
102
|
usageUsed: '已用',
|
|
103
103
|
usageRemaining: '剩余',
|
|
104
|
-
|
|
105
|
-
usageCredits: 'credits',
|
|
104
|
+
usageCredits: '积分',
|
|
106
105
|
usagePlanQuota: '套餐额度',
|
|
107
106
|
usageAddOn: '加量包',
|
|
108
107
|
usageOrgPackage: '组织资源包',
|
|
@@ -291,7 +290,6 @@ window.__ModuleLoader__.load({
|
|
|
291
290
|
usagePlan: 'Plan',
|
|
292
291
|
usageUsed: 'Used',
|
|
293
292
|
usageRemaining: 'Remaining',
|
|
294
|
-
usageOf: '/',
|
|
295
293
|
usageCredits: 'credits',
|
|
296
294
|
usagePlanQuota: 'Plan quota',
|
|
297
295
|
usageAddOn: 'Add-on package',
|
|
@@ -562,10 +560,18 @@ window.__ModuleLoader__.load({
|
|
|
562
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' },
|
|
563
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))' },
|
|
564
562
|
usageHead: { display: 'flex', alignItems: 'baseline', gap: '10px', flexWrap: 'wrap' },
|
|
565
|
-
usagePct: { marginLeft: 'auto', fontSize: '0.9em', fontWeight: 600 },
|
|
566
563
|
progressOuter: { height: '8px', borderRadius: '999px', background: 'var(--dsw-alias-border-l2, rgba(128,128,128,0.22))', overflow: 'hidden' },
|
|
567
564
|
progressInner: { height: '100%', borderRadius: '999px', background: 'var(--dsw-alias-brand-primary, #4c6ef5)', transition: 'width .25s ease' },
|
|
568
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' },
|
|
569
575
|
usageLine: { display: 'flex', alignItems: 'baseline', gap: '8px', flexWrap: 'wrap', fontSize: '0.86em' },
|
|
570
576
|
usageLabel: { opacity: 0.62, minWidth: '72px' },
|
|
571
577
|
usageValue: { fontWeight: 500 },
|
|
@@ -765,32 +771,80 @@ window.__ModuleLoader__.load({
|
|
|
765
771
|
return t('minimaxTokenRemainingHours').replace('{n}', String(Math.floor(minutes / 60)))
|
|
766
772
|
}
|
|
767
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
|
+
|
|
768
812
|
/**
|
|
769
|
-
* One
|
|
813
|
+
* One credit bucket in the shape both account cards use: `used / total`
|
|
814
|
+
* with the percentage on the right and a bar underneath.
|
|
770
815
|
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
* 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.
|
|
774
818
|
*/
|
|
775
|
-
function
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const remaining =
|
|
779
|
-
const
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
+
),
|
|
794
848
|
)
|
|
795
849
|
}
|
|
796
850
|
|
|
@@ -838,7 +892,6 @@ window.__ModuleLoader__.load({
|
|
|
838
892
|
const usage = snapshot?.usage
|
|
839
893
|
const account = snapshot?.account
|
|
840
894
|
const error = failure ?? (snapshot?.usage === undefined && snapshot?.error !== undefined ? String(snapshot.error) : undefined)
|
|
841
|
-
const pct = percentOf(usage?.totalUsagePercentage)
|
|
842
895
|
const plan = account?.subscriptionType ?? usage?.userType ?? t('usageUnknownPlan')
|
|
843
896
|
const identity = account?.name ?? account?.email ?? usage?.userId
|
|
844
897
|
const exceeded = usage?.isQuotaExceeded === true
|
|
@@ -876,16 +929,31 @@ window.__ModuleLoader__.load({
|
|
|
876
929
|
h('span', { style: css.usageLabel }, t('usagePlan')),
|
|
877
930
|
h('span', { style: css.usageValue }, plan),
|
|
878
931
|
exceeded ? h('span', { style: { ...css.err, fontWeight: 600 } }, t('usageExceeded')) : null,
|
|
879
|
-
pct === undefined ? null : h('span', { style: css.usagePct }, `${Number(pct.toFixed(1))}%`),
|
|
880
932
|
),
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
+
})(),
|
|
885
956
|
),
|
|
886
|
-
h(QuotaLine, { t, label: t('usagePlanQuota'), bucket: usage?.userQuota }),
|
|
887
|
-
h(QuotaLine, { t, label: t('usageAddOn'), bucket: usage?.addOnQuota }),
|
|
888
|
-
h(QuotaLine, { t, label: t('usageOrgPackage'), bucket: usage?.orgResourcePackage }),
|
|
889
957
|
h('div', { style: css.usageFoot },
|
|
890
958
|
expiry === undefined || neverExpires(expiry)
|
|
891
959
|
? h('span', null, `${t('usageExpires')} ${t('usageNever')}`)
|
|
@@ -1110,9 +1178,6 @@ window.__ModuleLoader__.load({
|
|
|
1110
1178
|
.filter(part => typeof part === 'string' && part.length > 0)
|
|
1111
1179
|
.join(' · ')
|
|
1112
1180
|
const quota = account?.quota
|
|
1113
|
-
const quotaPct = quota !== undefined && quota.total > 0
|
|
1114
|
-
? Math.max(0, Math.min(100, (quota.used / quota.total) * 100))
|
|
1115
|
-
: undefined
|
|
1116
1181
|
// Every package is kept: the collapsed row carries the count and the
|
|
1117
1182
|
// combined total, so nothing disappears behind an invisible cut.
|
|
1118
1183
|
const packages = Array.isArray(quota?.packages)
|
|
@@ -1167,15 +1232,12 @@ window.__ModuleLoader__.load({
|
|
|
1167
1232
|
? h('div', { style: css.err }, `${t('codebuddyQuotaFailed')}:${account.quotaError}`)
|
|
1168
1233
|
: h('div', { style: css.note }, t('codebuddyNoQuota')))
|
|
1169
1234
|
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } },
|
|
1170
|
-
h(
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
),
|
|
1176
|
-
quotaPct === undefined ? null : h('div', { style: css.progressOuter },
|
|
1177
|
-
h('div', { style: { ...css.progressInner, width: `${quotaPct}%` } }),
|
|
1178
|
-
),
|
|
1235
|
+
h(CreditMeter, {
|
|
1236
|
+
t,
|
|
1237
|
+
label: t('codebuddyQuotaTitle'),
|
|
1238
|
+
bucket: quota,
|
|
1239
|
+
danger: quota.total > 0 && quota.used >= quota.total,
|
|
1240
|
+
}),
|
|
1179
1241
|
packages.length === 0 ? null : (() => {
|
|
1180
1242
|
// Same rule as the other adapters: collapsed is one summary
|
|
1181
1243
|
// row (count, combined total, nearest expiry), expanded is
|
|
@@ -2144,6 +2206,9 @@ window.__ModuleLoader__.load({
|
|
|
2144
2206
|
// CLI rejects every other value, so a dropdown here would be a control
|
|
2145
2207
|
// that never reaches the upstream. Show the value instead.
|
|
2146
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)
|
|
2147
2212
|
return h('div', {
|
|
2148
2213
|
key: m.id,
|
|
2149
2214
|
style: { ...css.row, ...(index === 0 ? css.rowFirst : {}), ...(m.enabled ? {} : css.rowOff) },
|
|
@@ -2182,7 +2247,7 @@ window.__ModuleLoader__.load({
|
|
|
2182
2247
|
},
|
|
2183
2248
|
},
|
|
2184
2249
|
h('option', { key: 'default', value: '' }, `${t('windowDefault')} · ${windowLabel(m.defaultContextWindow)}`),
|
|
2185
|
-
|
|
2250
|
+
offered.map(n => h('option', { key: String(n), value: String(n) }, windowLabel(n))),
|
|
2186
2251
|
),
|
|
2187
2252
|
)
|
|
2188
2253
|
})
|
|
@@ -2513,7 +2578,7 @@ window.__ModuleLoader__.load({
|
|
|
2513
2578
|
exports.name = 'dsh-agent-sdk-bridge'
|
|
2514
2579
|
exports.__test = {
|
|
2515
2580
|
windowLabel, priceSuffix, ADVANCED, BRANDS, zh, en,
|
|
2516
|
-
SettingsPage, BundleSettings, UsageCard, CodeBuddyCard,
|
|
2581
|
+
SettingsPage, BundleSettings, UsageCard, CodeBuddyCard, CreditMeter, creditReading, creditUnit, creditsOf, neverExpires,
|
|
2517
2582
|
dateLabel, tokenExpiryText, packageSummary,
|
|
2518
2583
|
readCache, writeCache,
|
|
2519
2584
|
}
|