dsh-free-model 3.0.1 → 3.2.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.
package/SECURITY-AUDIT.md CHANGED
@@ -11,11 +11,11 @@
11
11
  | 文件 | sha256 |
12
12
  | --- | --- |
13
13
  | `index.js` | `a932bcb6bdeef608496071a60d1f9e8499997fca52765e0eb300171d8728aa57` |
14
- | `client.js` | `13332f9b4102e5cc7125998983126df7b50cfa6a32ef5e20aefc51aca0a5e820` |
15
- | `vendor/channel-pack/pack.js` | `2f9a8d58007fcec287c5f9be484b79adbfea8ec332bddc1ba01d52acb5877c19` |
14
+ | `client.js` | `ddd7680be53b06a8cdcea19b3e3ece7b4a134783d9a88a66bb08a5c554a59f69` |
15
+ | `vendor/channel-pack/pack.js` | `b5ffd11cbd36aabb756b50766728023ad221845164c641b4eb74f32998b1bbf2` |
16
16
 
17
17
  ⚠️ `pack.js` 的指纹随每次「刷新模型数据 / 移植上游修复」而变(它是构建产物)。
18
- 上面的值对应**3.0.1(2026-11-09:目录刷新加账号闸门)之后**的版本;
18
+ 上面的值对应**3.2.0(2026-11-16:目录刷新改为每日一次 + 账号变更即时)之后**的版本;
19
19
  域名面结论未变,`scripts/egress-audit.mjs` 可随时重跑复验。
20
20
  (上一版 `9255642f…` 是上游第二轮跟进后的产物。)
21
21
 
package/client.js CHANGED
@@ -72,6 +72,8 @@ window.__ModuleLoader__.load({
72
72
  'chan.pack.failed': '渠道包未挂载:{reason}(免费车道与 EAC 不受影响)',
73
73
  'chan.pack.hint': '渠道包由本插件内置(vendor/channel-pack),随插件一起升级。',
74
74
  'chan.state.on': '已接入',
75
+ 'chan.group.on': '已接入',
76
+ 'chan.group.off': '未接入',
75
77
  'chan.state.off': '未接入',
76
78
  'chan.state.closed': '已关闭',
77
79
  'chan.meta.accounts': '账号',
@@ -254,6 +256,8 @@ window.__ModuleLoader__.load({
254
256
  'chan.pack.failed': 'Channel pack not mounted: {reason} (the free and EAC lanes are unaffected)',
255
257
  'chan.pack.hint': 'The pack ships inside this plugin (vendor/channel-pack) and upgrades with it.',
256
258
  'chan.state.on': 'Connected',
259
+ 'chan.group.on': 'Connected',
260
+ 'chan.group.off': 'Not connected',
257
261
  'chan.state.off': 'Not connected',
258
262
  'chan.state.closed': 'Turned off',
259
263
  'chan.meta.accounts': 'Accounts',
@@ -566,6 +570,14 @@ window.__ModuleLoader__.load({
566
570
  .ofm_glass{background:color-mix(in srgb,var(--dsw-alias-bg-layer-2) 68%,transparent);border:1px solid color-mix(in srgb,var(--dsw-alias-border-l2) 78%,transparent);box-shadow:inset 0 1px 0 rgb(255 255 255 / 6%),0 12px 34px rgb(0 0 0 / 9%)}.ofm_root .ofm_hero,.ofm_root .ofm_panel,.ofm_root .ofm_modal{background:color-mix(in srgb,var(--dsw-alias-bg-layer-2) 70%,transparent);box-shadow:inset 0 1px 0 rgb(255 255 255 / 7%),0 14px 40px rgb(0 0 0 / 10%)}
567
571
  /* ══ 渠道接入页 ════════════════════════════════════════════════════════ */
568
572
  .ofm_chanwrap{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:14px}
573
+ /* 渠道分组标题:已接入 / 未接入。⚠️ 必须 grid-column:1/-1 横跨整行 ——
574
+ 否则它会变成一个 330px 的格子(把第一张卡挤到第二列)。 */
575
+ .ofm_chargroup{grid-column:1/-1;display:flex;align-items:center;gap:9px;margin:2px 0 -4px;font-size:12px;font-weight:650;letter-spacing:.02em;color:var(--dsw-alias-text-l3)}
576
+ .ofm_chargroup:not(:first-child){margin-top:12px}
577
+ .ofm_chargroup::after{content:"";flex:1;height:1px;background:linear-gradient(90deg,var(--dsw-alias-border-l2),transparent)}
578
+ .ofm_chargroupn{font-variant-numeric:tabular-nums;font-weight:600;opacity:.72}
579
+ .ofm_chargroupdot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary,#12b76a);flex:none}
580
+ .ofm_chargroupdot.off{background:var(--dsw-alias-text-l3);opacity:.5}
569
581
  .ofm_chan{position:relative;display:flex;flex-direction:column;gap:12px;padding:16px 17px 15px;border-radius:16px;border:1px solid var(--dsw-alias-border-l2);background:color-mix(in srgb,var(--dsw-alias-bg-layer-3) 78%,transparent);box-shadow:inset 0 1px 0 rgb(255 255 255 / 5%),0 1px 2px rgb(0 0 0 / 5%);overflow:hidden;transition:transform .22s cubic-bezier(.32,.72,0,1),box-shadow .24s ease,border-color .2s ease}
570
582
  .ofm_chan::before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:linear-gradient(90deg,var(--chan-accent,var(--dsw-alias-state-business-primary)),transparent 78%);opacity:.95}
571
583
  .ofm_chan:hover{transform:translateY(-3px);box-shadow:inset 0 1px 0 rgb(255 255 255 / 8%),0 18px 40px rgb(0 0 0 / 15%);border-color:color-mix(in srgb,var(--chan-accent,var(--dsw-alias-state-business-primary)) 55%,transparent)}
@@ -1425,6 +1437,30 @@ window.__ModuleLoader__.load({
1425
1437
  { id: 'accio', name: 'Accio Work', org: '阿里', accent: '#FF6A00', note: '标准 OAuth + PKCE(公开客户端),可脱离 IDE 使用', login: 'browser' },
1426
1438
  ]
1427
1439
 
1440
+ /**
1441
+ * 把渠道按「是否已接入账号」分成两组:**已接入在前、未接入在后**,
1442
+ * 各自保持 `PROVIDERS` 里的原始相对顺序。
1443
+ *
1444
+ * ## 为什么抽成纯函数(2026-11-11)
1445
+ *
1446
+ * 卡片顺序是被用户直接看见的行为,值得一条**顺序语义**的回归钉子;
1447
+ * 而频道页要经 RPC 才拿到 `statuses`,渲染测试的替身里没有 connection,
1448
+ * 永远停在「未就绪」态(那一态刻意不分组)。⇒ 抽出来让套件直接测语义,
1449
+ * 而不是为了测顺序去伪造一整套 RPC。
1450
+ *
1451
+ * ⚠️ `statuses === undefined`(还没拉到数据)→ **不分组**:那时所有卡都是
1452
+ * 骨架态,硬分会让人看到列表在一次数据到达后整体跳动。
1453
+ * ⚠️ 「已接入」判据与卡片绿点/计数**必须同一个**(`accounts.enabled > 0`)。
1454
+ */
1455
+ function groupChannelsByConnected(providers, statuses, labels) {
1456
+ if (statuses === undefined) return [{ key: 'all', label: null, dot: null, rows: providers }]
1457
+ const isOn = row => (statuses?.[row.id]?.accounts?.enabled ?? 0) > 0
1458
+ return [
1459
+ { key: 'on', label: labels.on, dot: 'on', rows: providers.filter(isOn) },
1460
+ { key: 'off', label: labels.off, dot: 'off', rows: providers.filter(row => !isOn(row)) },
1461
+ ].filter(group => group.rows.length > 0)
1462
+ }
1463
+
1428
1464
  /** 与现有 RPC 的能力对应:余额、每日领取及独立签到状态分别判断。 */
1429
1465
  const CHANNEL_CREDITS = {
1430
1466
  codearts: { claim: true },
@@ -1920,6 +1956,26 @@ window.__ModuleLoader__.load({
1920
1956
 
1921
1957
  const connected = statuses === undefined ? 0 : CHANNEL_PROVIDERS.filter(row => (statuses[row.id]?.accounts?.enabled ?? 0) > 0).length
1922
1958
  const failed = !ready && pack.state === 'failed'
1959
+ /**
1960
+ * **渠道分组**(2026-11-11 用户要求):「已接入账号的一组、未接入的一组;
1961
+ * 已接入的上移、未接入的不动」。
1962
+ *
1963
+ * ⚠️ 顺序判据:`CHANNEL_PROVIDERS` 是**硬编码**的产品顺序(codearts → buddy →
1964
+ * … → accio),这是有意的品牌编排,不能在数组里就地重排(否则以后维护
1965
+ * 看不出原始顺序)。
1966
+ * ⇒ 渲染时**派生成两组**:`filter` 保持各自在源数组里的相对顺序,
1967
+ * 「已接入」在前、「未接入」在后 —— 正好是「上移 + 未动的保持原序」。
1968
+ *
1969
+ * ⚠️ 「已接入」判据与卡片上的绿点/计数**必须同一个**(`accounts.enabled > 0`):
1970
+ * 用别的判据(如 `accounts.total`)会出现「卡片显示未接入却排在已接入组」。
1971
+ *
1972
+ * ⚠️ `statuses === undefined`(还没拉到数据)时**不分组**:那时所有卡都是
1973
+ * 骨架态,硬分会让人看到列表在一次数据到达后整体跳动。
1974
+ */
1975
+ const channelGroups = groupChannelsByConnected(CHANNEL_PROVIDERS, statuses, {
1976
+ on: t('chan.group.on'),
1977
+ off: t('chan.group.off'),
1978
+ })
1923
1979
 
1924
1980
  return h('div', { className: 'ofm_page' },
1925
1981
  h('header', { className: 'ofm_hero ofm_glass' },
@@ -1941,15 +1997,22 @@ window.__ModuleLoader__.load({
1941
1997
  !available ? h('div', { className: 'ofm_callout' }, h('div', null, t('chan.rpc.unavailable'))) : null,
1942
1998
  !ready ? h('div', { className: 'ofm_chanwrap' },
1943
1999
  [0, 1, 2].map(index => h('div', { className: 'ofm_skel', key: index, style: { minHeight: 168 } }))) : null,
1944
- ready ? h('div', { className: 'ofm_chanwrap' }, CHANNEL_PROVIDERS.map(channel => h(ChannelCard, {
1945
- key: channel.id,
1946
- channel,
1947
- status: statuses?.[channel.id],
1948
- rpc: available ? rpc : null,
1949
- t,
1950
- onError,
1951
- onChanged,
1952
- }))) : null,
2000
+ ready ? h('div', { className: 'ofm_chanwrap' },
2001
+ channelGroups.flatMap(group => [
2002
+ group.label === null ? null : h('div', { className: 'ofm_chargroup', key: `g-${group.key}` },
2003
+ h('span', { className: `ofm_chargroupdot ${group.dot === 'off' ? 'off' : ''}`.trim() }),
2004
+ h('span', null, group.label),
2005
+ h('span', { className: 'ofm_chargroupn' }, String(group.rows.length))),
2006
+ ...group.rows.map(channel => h(ChannelCard, {
2007
+ key: channel.id,
2008
+ channel,
2009
+ status: statuses?.[channel.id],
2010
+ rpc: available ? rpc : null,
2011
+ t,
2012
+ onError,
2013
+ onChanged,
2014
+ })),
2015
+ ].filter(Boolean))) : null,
1953
2016
  error !== '' && !failed ? h('p', { className: 'ofm_note' }, `${t('chan.error').replace('{reason}', error)}`) : null)
1954
2017
  }
1955
2018
 
@@ -2525,7 +2588,7 @@ window.__ModuleLoader__.load({
2525
2588
  exports.inject = inject
2526
2589
  exports.name = 'our-free-model'
2527
2590
  // Headless test seams use the same stub React as scripts/client-lint.mjs.
2528
- exports.__test = { parseSafeHtml, safeUrl, sanitizeStyle, htmlToDom, ChannelsPage }
2591
+ exports.__test = { parseSafeHtml, safeUrl, sanitizeStyle, htmlToDom, ChannelsPage, groupChannelsByConnected, CHANNEL_PROVIDERS }
2529
2592
  return module.exports
2530
2593
  },
2531
2594
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-model",
3
- "version": "3.0.1",
3
+ "version": "3.2.0",
4
4
  "type": "module",
5
5
  "description": "dsh 插件(DeepSeek Harness / cordis bundle)· 模型接入 —— 把 CodeArts、CodeBuddy / WorkBuddy、LobsterAI、Qoder / Qoder CN、TRAE、Cline、Loomy、Raccoon、MiniMax Code、ZCode、Gemini、OfficeAce、Accio Work 十五个账号渠道接进 dsh 的模型选择器,并保留数据看板、运行日志与本地网关(含局域网中继)。上游 2.1.0 的匿名免费车道、EAC 协付车道、聚合渠道、省 Token、路由、公告/升级/热重载与独立 Web 产品已全部移除。",
6
6
  "main": "./index.js",
@@ -31058,6 +31058,14 @@ function allAccountsRateLimitedForModel(accounts, modelId, now = Date.now()) {
31058
31058
  }
31059
31059
  return earliest === void 0 ? void 0 : { resetAtMs: earliest, accountCount: accounts.length };
31060
31060
  }
31061
+ function diffChangedProviders(before, after) {
31062
+ const previous = new Set(before === "" ? [] : before.split(","));
31063
+ const current = new Set(after === "" ? [] : after.split(","));
31064
+ const changed = /* @__PURE__ */ new Set();
31065
+ for (const key of previous) if (!current.has(key)) changed.add(key.split(":")[0]);
31066
+ for (const key of current) if (!previous.has(key)) changed.add(key.split(":")[0]);
31067
+ return [...changed];
31068
+ }
31061
31069
  var AccountPool = class {
31062
31070
  constructor(ctx) {
31063
31071
  this.ctx = ctx;
@@ -31227,14 +31235,55 @@ var AccountPool = class {
31227
31235
  * **必须连同黑名单一起写回**:两种后端都是整体写入,
31228
31236
  * 只写 `{ accounts }` 会把同一文档里的 `disabledModels` 抹掉。
31229
31237
  */
31238
+ /**
31239
+ * **账号集合变更后的通知回调**(可选;由 `index.ts` 接线到「目录立即刷新」)。
31240
+ *
31241
+ * ## 为什么挂在 `writeAccounts` 上
31242
+ *
31243
+ * `addAccount` / `updateAccount` / `removeAccount` **全部**汇流到这里 ⇒ 一个
31244
+ * 收口点就覆盖「加账号 / 改账号 / 删账号」三类变更,不必在三个方法各埋一次
31245
+ *(那样迟早漏一个,且删/改的语义还得各判一遍)。
31246
+ *
31247
+ * ⚠️ **只在集合真的变了才触发**(调用方保证)—— 本回调的用途是「让模型目录跟上
31248
+ * 账号变化」,无变更时刷新等于白发请求。
31249
+ * ⚠️ 回调**绝不上抛**:账号落盘是主路径,通知是锦上添花;回调抛错不该让
31250
+ * 「添加账号」失败。
31251
+ */
31252
+ onAccountsChanged;
31230
31253
  async writeAccounts(accounts) {
31254
+ const before = this.cache?.map((entry) => `${entry.provider}:${entry.id}`).join(",") ?? "";
31231
31255
  this.cache = accounts;
31232
31256
  this.loaded = true;
31257
+ const after = accounts.map((entry) => `${entry.provider}:${entry.id}`).join(",");
31233
31258
  if (this.store.kind === "memory") {
31234
31259
  this.ctx.logger?.warn?.("[channel-pack] \u65E0\u6301\u4E45\u5316\u540E\u7AEF\uFF0C\u8D26\u53F7\u53D8\u66F4\u672A\u843D\u76D8");
31260
+ this.notifyAccountsChanged(before, after);
31235
31261
  return;
31236
31262
  }
31237
31263
  await this.queueStoreSave();
31264
+ this.notifyAccountsChanged(before, after);
31265
+ }
31266
+ /**
31267
+ * 把「账号集合变了」通知出去(**只在真的变了、且只报变动的 provider**)。
31268
+ *
31269
+ * ⚠️ 只报变动 provider:全量刷新会让 15 家渠道全部重拉,而我们刚刚才因为
31270
+ * 「不该无差别刷新」改过一次(3.0.1 的账号闸门)—— 同一条纪律。
31271
+ */
31272
+ notifyAccountsChanged(before, after) {
31273
+ if (before === after) return;
31274
+ const callback = this.onAccountsChanged;
31275
+ if (callback === void 0) return;
31276
+ const changed = diffChangedProviders(before, after);
31277
+ const providers = changed.length === 0 ? [void 0] : changed;
31278
+ for (const provider of providers) {
31279
+ try {
31280
+ callback(provider);
31281
+ } catch (error) {
31282
+ this.ctx.logger?.warn?.(
31283
+ `[channel-pack] \u8D26\u53F7\u53D8\u66F4\u901A\u77E5\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u8D26\u53F7\u672C\u8EAB\uFF09\uFF1A${String(error)}`
31284
+ );
31285
+ }
31286
+ }
31238
31287
  }
31239
31288
  /**
31240
31289
  * 读取某 provider 的模型黑名单(被关闭的模型 id 集合)。
@@ -72651,6 +72700,13 @@ function makeReadImageRequest(ctx) {
72651
72700
  }
72652
72701
  };
72653
72702
  }
72703
+ var CATALOG_DAILY_MS = 24 * 60 * 60 * 1e3;
72704
+ function msUntilNextUtc8Midnight(nowMs) {
72705
+ const utc8OffsetMs = 8 * 60 * 60 * 1e3;
72706
+ const shifted = nowMs + utc8OffsetMs;
72707
+ const nextShifted = Math.floor(shifted / CATALOG_DAILY_MS) * CATALOG_DAILY_MS + CATALOG_DAILY_MS;
72708
+ return Math.max(1e3, nextShifted - shifted + 5e3);
72709
+ }
72654
72710
  function refreshCatalogsOnce(deps) {
72655
72711
  return (async () => {
72656
72712
  for (const [tag2, adapter] of Object.entries(deps.adapters)) {
@@ -73562,6 +73618,30 @@ function apply(ctx, config = {}) {
73562
73618
  return false;
73563
73619
  }
73564
73620
  }
73621
+ async function refreshCatalogFor(provider) {
73622
+ if (typeof modelAdapters === "undefined") return;
73623
+ const adapter = modelAdapters[provider];
73624
+ if (adapter === void 0) return;
73625
+ await refreshCatalogsOnce({
73626
+ adapters: { [provider]: adapter },
73627
+ /**
73628
+ * ⚠️⚠️ **这里刻意不传 `hasAccount`**(与每日全量刷新相反)。
73629
+ *
73630
+ * 账号闸门是为了挡住「没配账号的渠道被定时器白刷」;而本函数**只由账号变更
73631
+ * 显式触发**,恰恰包括「**刚删掉最后一个账号**」这一情形 ——
73632
+ * 那时 `hasLoggedInAccount` 返回 false,若套用闸门就会**跳过刷新**,
73633
+ * 而删除账号正是最需要刷新的一次(目录要把那家的模型可用性收掉)。
73634
+ *
73635
+ * ⇒ 触发源是「明确的用户动作」时,闸门不适用(与 3.0.1 的定时器场景区分)。
73636
+ */
73637
+ hasAccount: void 0,
73638
+ onError: (tag2, error) => {
73639
+ ctx.logger?.warn?.(
73640
+ `[channel-pack] ${tag2} \u76EE\u5F55\u5237\u65B0\u5931\u8D25\uFF08\u4FDD\u7559\u65E7\u76EE\u5F55\uFF09\uFF1A${error instanceof Error ? error.message : String(error)}`
73641
+ );
73642
+ }
73643
+ });
73644
+ }
73565
73645
  async function refreshAllCatalogs() {
73566
73646
  if (catalogRefreshInFlight) return;
73567
73647
  if (typeof modelAdapters === "undefined") return;
@@ -73599,11 +73679,28 @@ function apply(ctx, config = {}) {
73599
73679
  void refreshAllCredentials();
73600
73680
  const refreshTimer = setInterval(() => {
73601
73681
  void refreshAllCredentials();
73602
- void refreshAllCatalogs();
73603
73682
  }, REFRESH_INTERVAL_MS);
73604
73683
  refreshTimer.unref?.();
73684
+ let dailyCatalogTimer;
73685
+ const scheduleDailyCatalog = () => {
73686
+ dailyCatalogTimer = setTimeout(() => {
73687
+ void refreshAllCatalogs();
73688
+ scheduleDailyCatalog();
73689
+ }, msUntilNextUtc8Midnight(Date.now()));
73690
+ dailyCatalogTimer.unref?.();
73691
+ };
73692
+ scheduleDailyCatalog();
73693
+ pool.onAccountsChanged = (provider) => {
73694
+ if (provider === void 0) {
73695
+ void refreshAllCatalogs();
73696
+ return;
73697
+ }
73698
+ void refreshCatalogFor(provider);
73699
+ };
73605
73700
  ctx.effect(() => () => {
73606
73701
  clearInterval(refreshTimer);
73702
+ if (dailyCatalogTimer !== void 0) clearTimeout(dailyCatalogTimer);
73703
+ pool.onAccountsChanged = void 0;
73607
73704
  service.stop();
73608
73705
  buddy.stop();
73609
73706
  workbuddy.stop();
@@ -73854,6 +73951,7 @@ function apply(ctx, config = {}) {
73854
73951
  ctx.provide("accountPool", pool);
73855
73952
  }
73856
73953
  export {
73954
+ CATALOG_DAILY_MS,
73857
73955
  CODEARTS_USER_AGENT,
73858
73956
  Config,
73859
73957
  ZCODE_INFERENCE_MIN_APP_VERSION,
@@ -73863,12 +73961,14 @@ export {
73863
73961
  httpErrorCode as codeartsHttpErrorCode,
73864
73962
  isAuthError as codeartsIsAuthError,
73865
73963
  createChannelFetch,
73964
+ diffChangedProviders as diffChangedProvidersForTest,
73866
73965
  findClineModelsDevEntry,
73867
73966
  httpErrorCodeForZcode,
73868
73967
  inject,
73869
73968
  makeReadImage,
73870
73969
  makeReadImageRequest,
73871
73970
  maybeClaimBonus,
73971
+ msUntilNextUtc8Midnight,
73872
73972
  name,
73873
73973
  parseWindowsProxy,
73874
73974
  refreshCatalogsOnce,