dsh-free-model 3.1.0 → 3.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/SECURITY-AUDIT.md +2 -2
- package/package.json +1 -1
- package/vendor/channel-pack/pack.js +101 -1
package/SECURITY-AUDIT.md
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `index.js` | `a932bcb6bdeef608496071a60d1f9e8499997fca52765e0eb300171d8728aa57` |
|
|
14
14
|
| `client.js` | `ddd7680be53b06a8cdcea19b3e3ece7b4a134783d9a88a66bb08a5c554a59f69` |
|
|
15
|
-
| `vendor/channel-pack/pack.js` | `
|
|
15
|
+
| `vendor/channel-pack/pack.js` | `b5ffd11cbd36aabb756b50766728023ad221845164c641b4eb74f32998b1bbf2` |
|
|
16
16
|
|
|
17
17
|
⚠️ `pack.js` 的指纹随每次「刷新模型数据 / 移植上游修复」而变(它是构建产物)。
|
|
18
|
-
上面的值对应**3.
|
|
18
|
+
上面的值对应**3.2.0(2026-11-16:目录刷新改为每日一次 + 账号变更即时)之后**的版本;
|
|
19
19
|
域名面结论未变,`scripts/egress-audit.mjs` 可随时重跑复验。
|
|
20
20
|
(上一版 `9255642f…` 是上游第二轮跟进后的产物。)
|
|
21
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-free-model",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
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,
|