dsh-codearts 1.2.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
3
3
  本文件记录本插件的重要改动。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),
4
4
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
5
5
 
6
+ ## [1.2.1] - 2026-10-28
7
+
8
+ ### 新增
9
+
10
+ - **底部那一行改成段式,与 `dsh-codebuddy-cli` 同构**:`积分 24,091 · Provider CodeArts ·
11
+ Model DeepSeek-V4.1-Flash-1017 · x0.18`。积分挪到最前,倍率单独成段(不再粘在模型名
12
+ 尾巴上),段与段用 ` · ` 连接,和邻居那一行的观感一致。**只有积分那一段**是开积分弹层
13
+ 的按钮(原来的设定不变):模型、倍率、排队都是纯文本,点它们不会弹面板。
14
+ `/api/codearts/status` 与 `/api/codearts/models` 的模型条目因此多了一个 `ratio` 字段
15
+ (`x0.18`;福利恒为 `x0.00`;上游没给倍率的模型缺席),免得客户端去拆显示名。
16
+ - **对话底部那行先说自己是谁了**:中间是 `Provider CodeArts · Model <模型名> · <倍率>`。
17
+ 这一段**不受**「显示剩余积分 / 显示上游排队位置」两个开关影响,始终出现;
18
+ 开关只管积分与排队两段。
19
+ - 这一行以前是靠邻居插件(`dsh-codebuddy-cli` 的 dock 会替任何 provider 画
20
+ `Provider <id> · Model <id>`)顺带显示的,但它在 codearts 下只给模型 **id**、
21
+ 给不出倍率,而且受那个插件自己的「切换到其它 provider 时也显示这一行」开关控制
22
+ (关了整行就消失)。现在身份行由本插件自己负责,不依赖别人。
23
+ - **选中我们的模型时,那一行里别人的条目会暂时消失**:我们改不了别人的注册,但
24
+ `conversation.composer.dock` 是 list 槽位、每条注册都被宿主平铺成同一个
25
+ `[data-composer-dock]` 行里的兄弟节点,所以我们这条会认出新出现的**别人**、给它们
26
+ 打上 `data-codearts-dock-suppressed` 属性,由我们注入的一条 CSS 隐藏。切换 provider
27
+ 或卸载时逐个摘掉属性,别人的行立刻回来。**不碰**宿主自己的轮次/token 统计 pill
28
+ (`data-composer-stat`)和上下文占用格子。规则与边界在 `src/client/dock-suppress.ts`,
29
+ 单测见 `test/dock-suppress.spec.ts`。
30
+ - **模型勾选区标出「识图」**:`/api/codearts/enabled-models` 的 choices 多了
31
+ `supportsImages`,卡片给支持图片输入的模型挂一个「识图」Tag。声明了 `reasoning` 之外
32
+ 的模型能力本来就该在勾选时看得见,不然只有发了图才知道谁不吃图。
33
+ - **新增 `DeepSeek-V4.1-Flash-1017` 种子条目**(1,048,576 context)。
34
+
35
+ ### 修复
36
+
37
+ - **`deepseek-v4.1-flash` 带图必报 `The request model is not multimodal`(issue #4)**:
38
+ 这个裸别名在上游不算多模态,种子目录却标了 `supportsImages: true`,于是带图的请求在
39
+ 出网前就被当成合法、到了上游才被拒。现在它标 false;多模态的是带日期的 `-1017`。
40
+ 上游发现接口对 `-1017` 的 `supports_images` 也给 false,但 issue 报告者实测带图可用,
41
+ 按实测为准标 true。
42
+ - **模型目录为空时会干等一小时**:启动/热重载后第一次模型发现如果正好撞上上游抖动,
43
+ 目录会一直空着,期间每条消息都死在 pi-ai 的 `has no configured model`,而重试要等整
44
+ 整 `CATALOG_REFRESH_MS`(1 小时)。现在发现循环自我重排:目录为空时 60 秒后重试,
45
+ 有货后回到每小时。
46
+
47
+ ### 开发
48
+
49
+ - **`scripts/deploy.mjs` 不再改写 profile 的依赖版本**:它以前把仓库 `version` 无条件写成
50
+ profile `dependencies` 的值,本地产物先于 npm 发布升版本时,profile 就会依赖一个
51
+ registry 里不存在的 specifier,宿主重载后整个 bundle 掉线(表现是模型选择器里
52
+ provider 消失,而 HTTP 路由还活着)。现在只在缺这一条时才补,版本不一致时打一行提示。
53
+ 仍建议**先发布、再升仓库版本**。
54
+
6
55
  ## [1.2.0] - 2026-10-27
7
56
 
8
57
  ### 新增
package/lib/bin.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { I as codeartsAccountsPath, M as isBenefitModel, N as CodeArtsAccountStore, d as fetchCallerIdentity, n as codeartsUsagePath, r as discoverModels, t as CodeArtsUsageTracker } from "./usage-B0NfG8vZ.mjs";
2
+ import { I as codeartsAccountsPath, M as isBenefitModel, N as CodeArtsAccountStore, d as fetchCallerIdentity, n as codeartsUsagePath, r as discoverModels, t as CodeArtsUsageTracker } from "./usage-05PgtUIP.mjs";
3
3
  import { existsSync, statSync } from "node:fs";
4
4
  //#region src/version.ts
5
- const CODEARTS_VERSION = "1.2.0";
5
+ const CODEARTS_VERSION = "1.2.1";
6
6
  //#endregion
7
7
  //#region src/bin.ts
8
8
  /**
@@ -40,6 +40,7 @@ interface CodeArtsSettingsKey {
40
40
  benefit: string;
41
41
  benefitBlocked: string;
42
42
  benefitBlockedHint: string;
43
+ modelImages: string;
43
44
  refreshModels: string;
44
45
  refreshing: string;
45
46
  refreshed: string;
@@ -85,7 +86,6 @@ interface CodeArtsSettingsKey {
85
86
  creditsNeedSignIn: string;
86
87
  creditsDock: string;
87
88
  creditsDockTitle: string;
88
- creditsDockExpand: string;
89
89
  creditsDockPanelTitle: string;
90
90
  creditsDockRefresh: string;
91
91
  creditsDockRefreshing: string;
@@ -94,6 +94,9 @@ interface CodeArtsSettingsKey {
94
94
  creditsDockEmpty: string;
95
95
  creditsDockExpiring: string;
96
96
  creditsDockUpdated: string;
97
+ dockProvider: string;
98
+ dockModel: string;
99
+ dockNoModel: string;
97
100
  tabDisplay: string;
98
101
  displayTitle: string;
99
102
  displayHint: string;
@@ -33,70 +33,70 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
33
33
  document.head.appendChild(tag);
34
34
  }
35
35
  var CodeArtsPluginCard_module_css_default = {
36
- "accountName": "xoziZG_accountName",
36
+ "modelChart": "xoziZG_modelChart",
37
+ "accountRowActions": "xoziZG_accountRowActions",
38
+ "field": "xoziZG_field",
39
+ "statusLine": "xoziZG_statusLine",
40
+ "meta": "xoziZG_meta",
41
+ "manualForm": "xoziZG_manualForm",
42
+ "usageBar": "xoziZG_usageBar",
43
+ "check": "xoziZG_check",
44
+ "tabs": "xoziZG_tabs",
45
+ "modelTrack": "xoziZG_modelTrack",
37
46
  "modelFill": "xoziZG_modelFill",
38
- "hint": "xoziZG_hint",
39
- "section": "xoziZG_section",
47
+ "balance": "xoziZG_balance",
48
+ "creditLink": "xoziZG_creditLink",
49
+ "actions": "xoziZG_actions",
50
+ "accountName": "xoziZG_accountName",
40
51
  "area": "xoziZG_area",
41
- "updated": "xoziZG_updated",
42
- "error": "xoziZG_error",
43
- "headText": "xoziZG_headText",
52
+ "sectionHead": "xoziZG_sectionHead",
53
+ "accountHint": "xoziZG_accountHint",
54
+ "expiryRow": "xoziZG_expiryRow",
55
+ "bar": "xoziZG_bar",
44
56
  "accountCard": "xoziZG_accountCard",
57
+ "accountRow": "xoziZG_accountRow",
58
+ "balanceMeta": "xoziZG_balanceMeta",
59
+ "sectionLabel": "xoziZG_sectionLabel",
45
60
  "barFill": "xoziZG_barFill",
46
- "choiceRow": "xoziZG_choiceRow",
47
- "field": "xoziZG_field",
48
- "body": "xoziZG_body",
49
- "accountEntry": "xoziZG_accountEntry",
50
- "modelChart": "xoziZG_modelChart",
51
- "modelRequests": "xoziZG_modelRequests",
52
61
  "link": "xoziZG_link",
53
- "actions": "xoziZG_actions",
54
- "creditRows": "xoziZG_creditRows",
55
- "desc": "xoziZG_desc",
56
- "balanceRow": "xoziZG_balanceRow",
57
- "creditLink": "xoziZG_creditLink",
58
- "modelName": "xoziZG_modelName",
59
- "card": "xoziZG_card",
60
- "bar": "xoziZG_bar",
61
- "meta": "xoziZG_meta",
62
- "sectionHead": "xoziZG_sectionHead",
63
- "balanceMeta": "xoziZG_balanceMeta",
64
- "modelTrack": "xoziZG_modelTrack",
65
- "usageFill": "xoziZG_usageFill",
66
- "choices": "xoziZG_choices",
67
- "accountRowActions": "xoziZG_accountRowActions",
68
- "tabPanel": "xoziZG_tabPanel",
69
- "expiryRow": "xoziZG_expiryRow",
70
- "tabs": "xoziZG_tabs",
62
+ "manual": "xoziZG_manual",
63
+ "accountNameRow": "xoziZG_accountNameRow",
71
64
  "fieldLabel": "xoziZG_fieldLabel",
72
- "manualSummary": "xoziZG_manualSummary",
65
+ "creditFooter": "xoziZG_creditFooter",
66
+ "creditBlock": "xoziZG_creditBlock",
67
+ "error": "xoziZG_error",
73
68
  "creditRow": "xoziZG_creditRow",
69
+ "modelRow": "xoziZG_modelRow",
70
+ "updated": "xoziZG_updated",
74
71
  "creditHint": "xoziZG_creditHint",
75
- "statusLine": "xoziZG_statusLine",
72
+ "balanceRow": "xoziZG_balanceRow",
73
+ "expiryLabel": "xoziZG_expiryLabel",
74
+ "count": "xoziZG_count",
75
+ "accountInfo": "xoziZG_accountInfo",
76
+ "balanceUnit": "xoziZG_balanceUnit",
76
77
  "danger": "xoziZG_danger",
77
- "modelRow": "xoziZG_modelRow",
78
+ "choiceRow": "xoziZG_choiceRow",
79
+ "body": "xoziZG_body",
78
80
  "claimAllRow": "xoziZG_claimAllRow",
81
+ "usageFill": "xoziZG_usageFill",
82
+ "header": "xoziZG_header",
83
+ "tabPanel": "xoziZG_tabPanel",
84
+ "desc": "xoziZG_desc",
85
+ "card": "xoziZG_card",
86
+ "accountEntry": "xoziZG_accountEntry",
87
+ "hint": "xoziZG_hint",
79
88
  "accountToolbar": "xoziZG_accountToolbar",
80
- "accountHint": "xoziZG_accountHint",
81
- "expiryLabel": "xoziZG_expiryLabel",
89
+ "headText": "xoziZG_headText",
90
+ "section": "xoziZG_section",
91
+ "modelName": "xoziZG_modelName",
82
92
  "name": "xoziZG_name",
83
- "header": "xoziZG_header",
84
- "accountRow": "xoziZG_accountRow",
85
- "sectionLabel": "xoziZG_sectionLabel",
86
- "count": "xoziZG_count",
87
- "balanceUnit": "xoziZG_balanceUnit",
88
- "modelTokens": "xoziZG_modelTokens",
89
- "accountNameRow": "xoziZG_accountNameRow",
90
- "accountInfo": "xoziZG_accountInfo",
91
- "creditBlock": "xoziZG_creditBlock",
92
- "balance": "xoziZG_balance",
93
+ "creditRows": "xoziZG_creditRows",
94
+ "modelShare": "xoziZG_modelShare",
95
+ "modelRequests": "xoziZG_modelRequests",
96
+ "choices": "xoziZG_choices",
97
+ "manualSummary": "xoziZG_manualSummary",
93
98
  "avatar": "xoziZG_avatar",
94
- "manual": "xoziZG_manual",
95
- "usageBar": "xoziZG_usageBar",
96
- "creditFooter": "xoziZG_creditFooter",
97
- "check": "xoziZG_check",
98
- "manualForm": "xoziZG_manualForm",
99
- "modelShare": "xoziZG_modelShare"
99
+ "modelTokens": "xoziZG_modelTokens"
100
100
  };
101
101
  //#endregion
102
102
  //#region src/client/CodeArtsPluginCard.tsx
@@ -1160,6 +1160,10 @@ function CodeArtsPluginCard({ t }) {
1160
1160
  choice.ratio !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1161
1161
  tone: "quiet",
1162
1162
  children: choice.ratio
1163
+ }),
1164
+ choice.supportsImages === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1165
+ tone: "quiet",
1166
+ children: t("modelImages")
1163
1167
  })
1164
1168
  ]
1165
1169
  }, choice.id))
@@ -1311,14 +1315,94 @@ function CodeArtsPluginCard({ t }) {
1311
1315
  });
1312
1316
  }
1313
1317
  //#endregion
1318
+ //#region src/client/dock-line.ts
1319
+ /** 段分隔符 —— 与邻居插件一致,改这里等于改整行的样子。 */
1320
+ const DOCK_SEGMENT_SEPARATOR = " · ";
1321
+ function buildDockLine(parts, t) {
1322
+ const rest = [];
1323
+ rest.push(t("dockProvider", { provider: parts.provider }));
1324
+ rest.push(parts.model === void 0 ? t("dockNoModel") : t("dockModel", { model: parts.model }));
1325
+ if (parts.ratio !== void 0) rest.push(parts.ratio);
1326
+ if (parts.queue !== void 0) rest.push(parts.queue);
1327
+ return {
1328
+ ...parts.credits === void 0 ? {} : { credits: parts.credits },
1329
+ rest: rest.join(DOCK_SEGMENT_SEPARATOR)
1330
+ };
1331
+ }
1332
+ //#endregion
1333
+ //#region src/client/dock-suppress.ts
1334
+ /**
1335
+ * 选中我们的模型时,把对话底部那一行里**别人**的条目暂时压掉。
1336
+ *
1337
+ * 别人注册什么我们管不了 —— `conversation.composer.dock` 是 list 槽位,每条注册由
1338
+ * 宿主平铺成同一个 `[data-composer-dock]` 行里的一个直接子节点。所以我们能做的是:
1339
+ * 在自己这条的 effect 里认出兄弟节点、给它们打个属性,再用一条我们注入的 CSS 隐藏。
1340
+ * 切走或卸载时逐个摘掉属性,绝不留下别人的行永久消失。
1341
+ *
1342
+ * 不碰的:宿主自己的轮次/token 统计 pill(带 `data-composer-stat`),以及上下文占用
1343
+ * 那一格 —— 那些不是「别人的 provider 行」,压掉就是抢宿主的 UI。
1344
+ *
1345
+ * 这里刻意不写 `instanceof HTMLElement`:结构够了就能用,逻辑也就能在没装 jsdom 的
1346
+ * 测试环境里用假节点跑(见 test/dock-suppress.spec.ts)。
1347
+ */
1348
+ /** 标记属性:带上它的节点被我们隐藏。 */
1349
+ const SUPPRESS_ATTR = "data-codearts-dock-suppressed";
1350
+ /** 注入的那条样式表 id。 */
1351
+ const SUPPRESS_STYLE_ID = "dsh-codearts-dock-suppress";
1352
+ /**
1353
+ * 这个兄弟节点该不该被压掉。
1354
+ *
1355
+ * 该压:别人的一条注册(既不是我们自己,也不包含我们,也不是宿主统计 pill)。
1356
+ * 不该压:我们自己、我们自己的子孙(有些宿主会包一层)、宿主的统计 pill。
1357
+ */
1358
+ function isForeignDockEntry(node, self) {
1359
+ if (node === self) return false;
1360
+ if (node.contains?.(self) === true) return false;
1361
+ if (node.hasAttribute("data-composer-stat")) return false;
1362
+ if (node.querySelector("[data-composer-stat]") !== null) return false;
1363
+ return true;
1364
+ }
1365
+ /**
1366
+ * 扫一遍并给新发现的「别人」打标记。返回**这次**新标记的节点,调用方负责在清理时
1367
+ * 逐个摘掉(只摘自己打的那批,别动别人的状态)。
1368
+ */
1369
+ function markForeignDockEntries(parent, self) {
1370
+ const marked = [];
1371
+ for (const child of Array.from(parent.children)) {
1372
+ if (!isForeignDockEntry(child, self)) continue;
1373
+ if (child.getAttribute("data-codearts-dock-suppressed") === "") continue;
1374
+ child.setAttribute(SUPPRESS_ATTR, "");
1375
+ marked.push(child);
1376
+ }
1377
+ return marked;
1378
+ }
1379
+ /** 摘掉标记 —— 切走 provider 或组件卸载时调用。 */
1380
+ function releaseDockEntries(nodes) {
1381
+ for (const node of nodes) node.removeAttribute(SUPPRESS_ATTR);
1382
+ }
1383
+ /** 注入一次隐藏规则;重复调用无副作用。没有 document 的环境(SSR/测试)直接跳过。 */
1384
+ function ensureSuppressStyle() {
1385
+ if (typeof document === "undefined") return;
1386
+ if (document.getElementById("dsh-codearts-dock-suppress") !== null) return;
1387
+ const style = document.createElement("style");
1388
+ style.id = SUPPRESS_STYLE_ID;
1389
+ style.textContent = `[${SUPPRESS_ATTR}]{display:none!important}`;
1390
+ document.head.appendChild(style);
1391
+ }
1392
+ //#endregion
1314
1393
  //#region src/client/CodeArtsCreditDock.tsx
1315
1394
  /**
1316
- * 对话底部的积分条 + 点开后的积分弹层。
1395
+ * 对话底部的「模型 + 积分」条,以及点开后的积分弹层。
1396
+ *
1397
+ * 这一条挂在 `conversation.composer.dock` 槽位上(与宿主 session-stats strip 同位)。
1398
+ * 只在当前 provider 是 codearts 时才渲染,别的 provider 下完全不出现,不抢别人的行。
1317
1399
  *
1318
- * 用户最初的诉求就是「对话底部要显示积分」—— 这一条挂在
1319
- * `conversation.composer.dock` 槽位上(与宿主 session-stats strip 同位)。
1320
- * 只在当前 provider 是 codearts 时才拉取并显示一行「积分 N」,别的 provider 下
1321
- * 完全不渲染,不抢别人的行。
1400
+ * 第一段是 `Provider CodeArts · <模型名>`,模型名直接用目录里的 `name`
1401
+ * (`catalog.ts` 的 `modelDisplayName` 已经把倍率写进去了,如
1402
+ * `DeepSeek-V4.1-Flash-1017 · x0.18`),所以这一行自带倍率、不必另算。
1403
+ * 这段是**我们自己的**身份行:邻居插件(如 dsh-codebuddy-cli)对任何 provider
1404
+ * 都会画一行 `Provider <id> · Model <id>`,在 codearts 下那行只有模型 id、没有
1405
+ * 倍率;两边都开就会重复,所以优先我们这条,邻居那条应在它自己的设置里关掉。
1322
1406
  *
1323
1407
  * 那一行是个按钮:点开就是逐号明细(多账号下聚合数字本身没意义,得能看出是哪个号)。
1324
1408
  * 显隐由设置卡片「显示」页那两个开关管着,开关值随 `/status` 一起下发 —— 底部条本来
@@ -1350,8 +1434,11 @@ function readSelection(useProjection) {
1350
1434
  return;
1351
1435
  }
1352
1436
  }
1437
+ function currentOf(selection) {
1438
+ return selection?.next ?? selection?.lastUsed;
1439
+ }
1353
1440
  function isCodeArts(selection) {
1354
- return (selection?.next ?? selection?.lastUsed)?.provider === CODEARTS_PROVIDER;
1441
+ return currentOf(selection)?.provider === CODEARTS_PROVIDER;
1355
1442
  }
1356
1443
  function formatNumber(value) {
1357
1444
  return new Intl.NumberFormat().format(Math.round(value));
@@ -1407,10 +1494,18 @@ function anchorOf(rect) {
1407
1494
  };
1408
1495
  }
1409
1496
  function CodeArtsCreditDock({ useProjection, t }) {
1410
- const active = isCodeArts(readSelection(useProjection));
1497
+ const selection = readSelection(useProjection);
1498
+ const active = isCodeArts(selection);
1411
1499
  const [remain, setRemain] = (0, react.useState)(null);
1412
1500
  const [total, setTotal] = (0, react.useState)(0);
1413
1501
  const [rows, setRows] = (0, react.useState)([]);
1502
+ /**
1503
+ * 模型 id -> 目录条目(显示名 + 已格式化的倍率)。
1504
+ *
1505
+ * 显示名自带 ` · x0.18` 尾巴,倍率单独放一段,所以两个都要拿:
1506
+ * 名字用 `stripModelSuffixes` 剥掉尾巴,倍率直接用服务端算好的 `ratio`。
1507
+ */
1508
+ const [modelInfo, setModelInfo] = (0, react.useState)({});
1414
1509
  const [flags, setFlags] = (0, react.useState)({
1415
1510
  credits: true,
1416
1511
  queue: true
@@ -1421,6 +1516,8 @@ function CodeArtsCreditDock({ useProjection, t }) {
1421
1516
  const mounted = (0, react.useRef)(true);
1422
1517
  const triggerRef = (0, react.useRef)(null);
1423
1518
  const panelRef = (0, react.useRef)(null);
1519
+ /** 这一行的根节点 —— 它的 parentElement 就是宿主那条共享 flex 行。 */
1520
+ const rootRef = (0, react.useRef)(null);
1424
1521
  (0, react.useEffect)(() => {
1425
1522
  mounted.current = true;
1426
1523
  return () => {
@@ -1441,6 +1538,10 @@ function CodeArtsCreditDock({ useProjection, t }) {
1441
1538
  queue: true
1442
1539
  });
1443
1540
  setRows(rowsOf(data));
1541
+ setModelInfo(Object.fromEntries((data.models ?? []).map((model) => [model.id, {
1542
+ name: model.name,
1543
+ ...model.ratio === void 0 ? {} : { ratio: model.ratio }
1544
+ }])));
1444
1545
  const snapshots = (data.creditsByAccount ?? []).map((entry) => entry.credits).filter((value) => value !== void 0);
1445
1546
  const pool = snapshots.length > 0 ? snapshots : data.credits === void 0 ? [] : [data.credits];
1446
1547
  if (pool.length === 0) {
@@ -1511,10 +1612,41 @@ function CodeArtsCreditDock({ useProjection, t }) {
1511
1612
  window.removeEventListener("scroll", close, true);
1512
1613
  };
1513
1614
  }, [anchor, close]);
1615
+ (0, react.useEffect)(() => {
1616
+ if (!active) return;
1617
+ const self = rootRef.current;
1618
+ const slot = self?.closest("[data-slot=\"conversation.composer.dock\"]") ?? null;
1619
+ if (self === null || slot === null) return;
1620
+ const node = slot;
1621
+ const me = self;
1622
+ const marked = /* @__PURE__ */ new Set();
1623
+ const sweep = () => {
1624
+ for (const found of markForeignDockEntries(node, me)) marked.add(found);
1625
+ };
1626
+ ensureSuppressStyle();
1627
+ sweep();
1628
+ const observer = new MutationObserver(sweep);
1629
+ observer.observe(slot, { childList: true });
1630
+ return () => {
1631
+ observer.disconnect();
1632
+ releaseDockEntries(marked);
1633
+ marked.clear();
1634
+ };
1635
+ }, [active]);
1514
1636
  if (!active) return null;
1515
1637
  const showCredits = flags.credits && remain !== null;
1516
1638
  const showQueue = flags.queue && queued !== null;
1517
- if (!showCredits && !showQueue) return null;
1639
+ const modelId = currentOf(selection)?.model;
1640
+ const entry = modelId === void 0 ? void 0 : modelInfo[modelId];
1641
+ const modelLabel = entry === void 0 ? modelId ?? "" : stripModelSuffixes(entry.name);
1642
+ const ratio = entry?.ratio;
1643
+ const line = buildDockLine({
1644
+ ...showCredits ? { credits: t("creditsDock", { remain: formatNumber(remain ?? 0) }) } : {},
1645
+ provider: "CodeArts",
1646
+ ...modelLabel === "" ? {} : { model: modelLabel },
1647
+ ...ratio === void 0 ? {} : { ratio },
1648
+ ...showQueue && queued !== null ? { queue: t("queueDock", { position: queued.position }) } : {}
1649
+ }, t);
1518
1650
  const queueTitle = queued === null ? void 0 : t("queueDockTitle", {
1519
1651
  model: queued.model,
1520
1652
  position: queued.position,
@@ -1542,10 +1674,11 @@ function CodeArtsCreditDock({ useProjection, t }) {
1542
1674
  }
1543
1675
  };
1544
1676
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1677
+ ref: rootRef,
1545
1678
  style: {
1546
1679
  display: "inline-flex",
1547
1680
  alignItems: "center",
1548
- gap: 6,
1681
+ gap: 0,
1549
1682
  color: "var(--dsw-alias-label-tertiary)",
1550
1683
  fontSize: "var(--dsh-content-font-size-secondary, 13px)",
1551
1684
  lineHeight: "18px",
@@ -1556,36 +1689,29 @@ function CodeArtsCreditDock({ useProjection, t }) {
1556
1689
  },
1557
1690
  title: queueTitle ?? creditsTitle,
1558
1691
  children: [
1559
- showQueue && queued !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("queueDock", { position: queued.position }) }),
1560
- showCredits && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1692
+ line.credits !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1561
1693
  ref: triggerRef,
1562
1694
  type: "button",
1695
+ "aria-haspopup": "dialog",
1563
1696
  "aria-expanded": anchor !== null,
1564
- "aria-label": t("creditsDockExpand"),
1697
+ "aria-label": t("creditsDockPanelTitle"),
1565
1698
  title: creditsTitle,
1566
1699
  onClick: toggle,
1567
1700
  style: {
1568
- display: "inline-flex",
1569
- alignItems: "center",
1570
- gap: 4,
1571
- margin: 0,
1572
- padding: 0,
1573
- border: 0,
1574
- background: "none",
1575
- color: "inherit",
1701
+ all: "unset",
1702
+ cursor: "pointer",
1576
1703
  font: "inherit",
1704
+ color: "inherit",
1705
+ fontVariantNumeric: "inherit",
1577
1706
  lineHeight: "inherit",
1578
- cursor: "pointer"
1707
+ whiteSpace: "inherit"
1579
1708
  },
1580
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("creditsDock", { remain: formatNumber(remain ?? 0) }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1581
- "aria-hidden": "true",
1582
- style: {
1583
- opacity: .6,
1584
- fontSize: "0.8em"
1585
- },
1586
- children: "▾"
1587
- })]
1588
- }),
1709
+ children: line.credits
1710
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1711
+ "aria-hidden": "true",
1712
+ children: " · "
1713
+ })] }),
1714
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: line.rest }),
1589
1715
  anchor !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1590
1716
  ref: panelRef,
1591
1717
  role: "dialog",
@@ -1741,6 +1867,7 @@ const zh = {
1741
1867
  benefit: "福利",
1742
1868
  benefitBlocked: "福利今日不可用",
1743
1869
  benefitBlockedHint: "{n} 个福利模型今天被上游判定没有权益(活动领完或渠道未开),发出去会直接报 benefit not found。",
1870
+ modelImages: "识图",
1744
1871
  refreshModels: "刷新模型列表",
1745
1872
  refreshing: "刷新中…",
1746
1873
  refreshed: "已刷新:{n} 个模型,其中 {benefit} 个走福利路由",
@@ -1786,7 +1913,6 @@ const zh = {
1786
1913
  creditsNeedSignIn: "这个账号需要重新登录",
1787
1914
  creditsDock: "积分 {remain}",
1788
1915
  creditsDockTitle: "CodeArts 剩余积分 {remain} / {total}",
1789
- creditsDockExpand: "点开看各账号积分明细",
1790
1916
  creditsDockPanelTitle: "CodeArts 积分",
1791
1917
  creditsDockRefresh: "刷新积分",
1792
1918
  creditsDockRefreshing: "刷新中…",
@@ -1795,9 +1921,12 @@ const zh = {
1795
1921
  creditsDockEmpty: "暂时没有积分数据",
1796
1922
  creditsDockExpiring: "{account}:{expiring} 积分将在本周期结束时作废",
1797
1923
  creditsDockUpdated: "最近刷新 {time}",
1924
+ dockProvider: "Provider {provider}",
1925
+ dockModel: "Model {model}",
1926
+ dockNoModel: "未选择模型",
1798
1927
  tabDisplay: "显示",
1799
1928
  displayTitle: "对话底部显示",
1800
- displayHint: "这两项只管输入框下方那一行,设置卡片里的积分明细不受影响。底部那条每 60 秒读一次设置,所以关掉最多要等一分钟才见效。",
1929
+ displayHint: "这两项只管输入框下方那一行的积分与排队两段;中间那段「Provider CodeArts · Model 模型 · 倍率」一直显示,不受开关影响。底部那条每 60 秒读一次设置,所以关掉最多要等一分钟才见效。",
1801
1930
  displayCreditsToggle: "显示剩余积分(点开可看各账号明细)",
1802
1931
  displayQueueToggle: "显示上游排队位置",
1803
1932
  displayNotWritable: "这个宿主没给插件开配置存储,开关只能看不能改。",
@@ -1854,6 +1983,7 @@ const en = {
1854
1983
  benefit: "Benefit",
1855
1984
  benefitBlocked: "Benefit unavailable today",
1856
1985
  benefitBlockedHint: "{n} benefit model(s) were told they have no entitlement today (campaign exhausted or channel not opened); sending to them fails with benefit not found.",
1986
+ modelImages: "Images",
1857
1987
  refreshModels: "Refresh models",
1858
1988
  refreshing: "Refreshing…",
1859
1989
  refreshed: "Refreshed: {n} models, {benefit} on the benefit route",
@@ -1899,7 +2029,6 @@ const en = {
1899
2029
  creditsNeedSignIn: "This account needs signing in again",
1900
2030
  creditsDock: "Credits {remain}",
1901
2031
  creditsDockTitle: "CodeArts credits left {remain} / {total}",
1902
- creditsDockExpand: "Show per-account credit details",
1903
2032
  creditsDockPanelTitle: "CodeArts credits",
1904
2033
  creditsDockRefresh: "Refresh credits",
1905
2034
  creditsDockRefreshing: "Refreshing…",
@@ -1908,9 +2037,12 @@ const en = {
1908
2037
  creditsDockEmpty: "No credit data yet",
1909
2038
  creditsDockExpiring: "{account}: {expiring} credits expire when this cycle ends",
1910
2039
  creditsDockUpdated: "Last updated {time}",
2040
+ dockProvider: "Provider {provider}",
2041
+ dockModel: "Model {model}",
2042
+ dockNoModel: "No model selected",
1911
2043
  tabDisplay: "Display",
1912
2044
  displayTitle: "Under the chat input box",
1913
- displayHint: "These two only control that line under the input box — the credit details in this card are unaffected. The bar re-reads settings every 60 seconds, so hiding it can take up to a minute.",
2045
+ displayHint: "These two only control the credits and queue segments of that line under the input box; the middle “Provider CodeArts · Model … · rate” segments always show. The bar re-reads settings every 60 seconds, so hiding the rest can take up to a minute.",
1914
2046
  displayCreditsToggle: "Show remaining credits (click it for per-account details)",
1915
2047
  displayQueueToggle: "Show the upstream queue position",
1916
2048
  displayNotWritable: "This host gives the plugin nowhere to persist settings, so the switches are read-only.",
package/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as filterEnabledModels, C as rateLimitFrame, D as FALLBACK_CODEARTS_MODELS, E as CodeArtsCatalog, F as MANUAL_ACCOUNT_ID, I as codeartsAccountsPath, L as codeartsAuthPath, M as isBenefitModel, N as CodeArtsAccountStore, O as clearBenefitBlocked, P as CodeArtsCredentialStore, R as startLogin, S as prepareChatBody, T as upstreamErrorMessage, _ as isQueueableRate, a as SNAP_HOST, b as maxTokensCeilingFor, c as claimDailyWelfare, d as fetchCallerIdentity, f as fetchModels, g as isParamInvalidFrame, h as isConcurrencyCap, i as refreshCatalog, j as isBenefitBlocked, k as creditRatioLabel, l as clearQueueStatus, m as fetchWelfareCampaigns, n as codeartsUsagePath, o as canonicalModel, p as fetchQueueStatus, r as discoverModels, s as chatStream, t as CodeArtsUsageTracker, u as degradeTokenCeiling, v as isTpmLimit, w as signedGet, x as pickDailyWelfareCampaign, y as isWelfareClaimedStatus } from "./usage-B0NfG8vZ.mjs";
1
+ import { A as filterEnabledModels, C as rateLimitFrame, D as FALLBACK_CODEARTS_MODELS, E as CodeArtsCatalog, F as MANUAL_ACCOUNT_ID, I as codeartsAccountsPath, L as codeartsAuthPath, M as isBenefitModel, N as CodeArtsAccountStore, O as clearBenefitBlocked, P as CodeArtsCredentialStore, R as startLogin, S as prepareChatBody, T as upstreamErrorMessage, _ as isQueueableRate, a as SNAP_HOST, b as maxTokensCeilingFor, c as claimDailyWelfare, d as fetchCallerIdentity, f as fetchModels, g as isParamInvalidFrame, h as isConcurrencyCap, i as refreshCatalog, j as isBenefitBlocked, k as creditRatioLabel, l as clearQueueStatus, m as fetchWelfareCampaigns, n as codeartsUsagePath, o as canonicalModel, p as fetchQueueStatus, r as discoverModels, s as chatStream, t as CodeArtsUsageTracker, u as degradeTokenCeiling, v as isTpmLimit, w as signedGet, x as pickDailyWelfareCampaign, y as isWelfareClaimedStatus } from "./usage-05PgtUIP.mjs";
2
2
  import { i as lazyApi, r as createProvider } from "./models-CgKCibpk.mjs";
3
3
  import z from "@deepseek-ai/schemastery";
4
4
  import { randomBytes, timingSafeEqual } from "node:crypto";
@@ -1427,6 +1427,7 @@ function selectionOf(models, enabled, writable) {
1427
1427
  benefit: m.benefit,
1428
1428
  blocked: m.blocked,
1429
1429
  ratio: m.ratio,
1430
+ supportsImages: m.supportsImages,
1430
1431
  enabled: restricted ? allowed.has(m.id) : true
1431
1432
  })),
1432
1433
  restricted,
@@ -1443,6 +1444,23 @@ function choicesOf(deps) {
1443
1444
  name: m.name,
1444
1445
  benefit,
1445
1446
  blocked: isBenefitBlocked(m.id),
1447
+ ...ratio === void 0 ? {} : { ratio },
1448
+ ...m.supportsImages === true ? { supportsImages: true } : {}
1449
+ };
1450
+ });
1451
+ }
1452
+ /**
1453
+ * 目录 -> 底栏/卡片用的模型徽章。
1454
+ *
1455
+ * 倍率在这里就算好(`creditRatioLabel`:福利恒为 `x0.00`),客户端拿到的是可以直接
1456
+ * 印出来的字符串 —— 底栏那一行要把它作为独立的一段,所以不能只给带尾巴的名字。
1457
+ */
1458
+ function modelBadgesOf(models) {
1459
+ return models.map((m) => {
1460
+ const ratio = creditRatioLabel(m.ratio, isBenefitModel(m.id));
1461
+ return {
1462
+ id: m.id,
1463
+ name: m.name,
1446
1464
  ...ratio === void 0 ? {} : { ratio }
1447
1465
  };
1448
1466
  });
@@ -1593,10 +1611,7 @@ async function creditsOf(deps, force) {
1593
1611
  }
1594
1612
  }
1595
1613
  async function buildStatus(deps, force = false) {
1596
- const models = deps.models().map((m) => ({
1597
- id: m.id,
1598
- name: m.name
1599
- }));
1614
+ const models = modelBadgesOf(deps.models());
1600
1615
  const accounts = await deps.store.list();
1601
1616
  const cred = await deps.store.current();
1602
1617
  const usage = usageOf(deps);
@@ -1714,10 +1729,7 @@ function modelsHandler(deps) {
1714
1729
  json(res, 403, { error: "request-not-trusted" });
1715
1730
  return;
1716
1731
  }
1717
- json(res, 200, { models: filterEnabledModels(deps.models(), deps.enabledModels?.()).map((m) => ({
1718
- id: m.id,
1719
- name: m.name
1720
- })) });
1732
+ json(res, 200, { models: modelBadgesOf(filterEnabledModels(deps.models(), deps.enabledModels?.())) });
1721
1733
  };
1722
1734
  }
1723
1735
  /**
@@ -2380,6 +2392,7 @@ function apply(ctx, rawConfig) {
2380
2392
  shim.close().catch(() => {});
2381
2393
  });
2382
2394
  const CATALOG_REFRESH_MS = 36e5;
2395
+ const CATALOG_EMPTY_RETRY_MS = 6e4;
2383
2396
  const abort = new AbortController();
2384
2397
  const discover = async () => {
2385
2398
  if (stopped) return;
@@ -2394,13 +2407,18 @@ function apply(ctx, rawConfig) {
2394
2407
  ctx.logger.debug("dsh-codearts: model discovery failed; keeping the current catalog", error);
2395
2408
  }
2396
2409
  };
2397
- ctx.effect(() => {
2398
- const timer = setInterval(() => void discover(), CATALOG_REFRESH_MS);
2399
- timer.unref?.();
2400
- return () => {
2401
- abort.abort();
2402
- clearInterval(timer);
2403
- };
2410
+ let discoveryTimer;
2411
+ /** 自我重排的发现循环:目录为空时加快到每分钟,有货后回到每小时。 */
2412
+ const discoverLoop = async () => {
2413
+ await discover();
2414
+ if (stopped) return;
2415
+ const delay = catalog.current().length === 0 ? CATALOG_EMPTY_RETRY_MS : CATALOG_REFRESH_MS;
2416
+ discoveryTimer = setTimeout(() => void discoverLoop(), delay);
2417
+ discoveryTimer.unref?.();
2418
+ };
2419
+ ctx.effect(() => () => {
2420
+ abort.abort();
2421
+ if (discoveryTimer !== void 0) clearTimeout(discoveryTimer);
2404
2422
  });
2405
2423
  const shim = createCodeArtsShim({
2406
2424
  store,
@@ -2413,7 +2431,7 @@ function apply(ctx, rawConfig) {
2413
2431
  usage.load().catch(() => {});
2414
2432
  shim.ready.then(async () => {
2415
2433
  if (stopped) return;
2416
- discover();
2434
+ discoverLoop();
2417
2435
  const incompatible = await probePiAiCompat();
2418
2436
  if (incompatible !== void 0) ctx.logger.error(`dsh-codearts: ${incompatible}`);
2419
2437
  const codearts = createCodeArtsAdapter({
@@ -905,6 +905,13 @@ const FALLBACK_CODEARTS_MODELS = [
905
905
  name: "DeepSeek-V4.1-Flash",
906
906
  contextWindow: 131072,
907
907
  maxTokens: 65536,
908
+ supportsImages: false
909
+ },
910
+ {
911
+ id: "deepseek-v4.1-flash-1017",
912
+ name: "DeepSeek-V4.1-Flash-1017",
913
+ contextWindow: 1048576,
914
+ maxTokens: 65536,
908
915
  supportsImages: true
909
916
  },
910
917
  {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-codearts",
3
3
  "displayName": "DSH CodeArts Connect",
4
4
  "description": "把华为云 CodeArts 接入 DeepSeek Harness —— 内置 OAuth2 登录(PKCE + DPoP),登录后即可在 DSH 对话窗口使用 CodeArts 的模型。",
5
- "version": "1.2.0",
5
+ "version": "1.2.1",
6
6
  "packageManager": "pnpm@11.24.0",
7
7
  "author": "elegant01",
8
8
  "keywords": [