dsh-multi-router 0.6.10 → 0.6.11
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 +6 -0
- package/README.md +9 -2
- package/cordis.patch.yml +2 -2
- package/lib/api-service.js +2 -2
- package/lib/{chunk-R2Z4WGR6.js → chunk-4L2CBGXN.js} +31 -27
- package/lib/chunk-4L2CBGXN.js.map +7 -0
- package/lib/{chunk-LXDLKLM6.js → chunk-NZF36O5I.js} +2 -2
- package/lib/{chunk-47YTECKF.js → chunk-TM5XDMGY.js} +2 -2
- package/lib/{chunk-LH6RKOZD.js → chunk-WDIT4E2W.js} +2 -2
- package/lib/{chunk-P7CNCBSY.js → chunk-YCAO7GCT.js} +5 -5
- package/lib/{chunk-P7CNCBSY.js.map → chunk-YCAO7GCT.js.map} +1 -1
- package/lib/cli.js +2 -2
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/clients.js +2 -2
- package/lib/{host-v0.6.10.js → host-v0.6.11.js} +5 -5
- package/lib/host.js +5 -5
- package/lib/index.js +5 -5
- package/lib/manager.js +4 -4
- package/lib/router.js +1 -1
- package/lib/shim.js +2 -2
- package/package.json +1 -1
- package/lib/chunk-R2Z4WGR6.js.map +0 -7
- /package/lib/{chunk-LXDLKLM6.js.map → chunk-NZF36O5I.js.map} +0 -0
- /package/lib/{chunk-47YTECKF.js.map → chunk-TM5XDMGY.js.map} +0 -0
- /package/lib/{chunk-LH6RKOZD.js.map → chunk-WDIT4E2W.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。版本号从 `0.1` 起以功能迭代为主,接口在 `1.0` 前可能变化。
|
|
4
4
|
|
|
5
|
+
## 0.6.11
|
|
6
|
+
|
|
7
|
+
- 修复 0.6.10 引入的回归:「积分使用均衡」在临期账号之间不再生效。0.6.10 按**精确到期日**分组,到期日不同的临期账号各自成为独立分组,降权只在组内进行,于是最早到期的账号用完额度后仍会一直霸占请求,直到积分包耗尽或到期——恰好废掉了「每用满阈值就换账号」这个功能本身。
|
|
8
|
+
- 分组改为按**是否持有临期积分**:临期账号整体排在非临期账号之前(临期优先不被折扣与均衡破坏),临期账号之间仍正常按额度轮换。折扣排序则仍按精确到期日分组,因为倍率与到期时间无关,不能把到期更晚但更便宜的积分包排到前面。
|
|
9
|
+
- 新增回归测试覆盖临期组内的额度轮换,并已验证按精确到期日分组时该测试立即失败。
|
|
10
|
+
|
|
5
11
|
## 0.6.10
|
|
6
12
|
|
|
7
13
|
- 修复「按积分折扣排序」与「积分使用均衡」会打乱临期积分优先级的问题:两者此前都是对全部候选做整体重排,因此一个更便宜、或本轮还没用完额度的非临期账号,可能插到仍有临期积分的账号前面。
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
一个插件内置 WorkBuddy、Trae、Qoder 的认证、模型发现和聊天传输,提供三家的多账号池及集中路由。运行不依赖原来三个 DSH 插件;三家代码随安装包一起打包。基于 MIT 上游,固定版本见 `upstream-lock.json`,许可见 `THIRD_PARTY_NOTICES.md`。
|
|
8
8
|
|
|
9
|
-
版本:0.6.
|
|
9
|
+
版本:0.6.11。适配 DSH Desktop / Web 0.2.1-rc.2(同时兼容 0.2.0-rc.2),Node.js ^22.19.0 或 >=24。
|
|
10
10
|
|
|
11
11
|
## 在 DSH 里管理
|
|
12
12
|
|
|
@@ -115,7 +115,14 @@ Qoder 的 `dfmodel` 在真实目录里显示为 DeepSeek-Flash,未声明具体
|
|
|
115
115
|
|
|
116
116
|
`discountOrder: true` 开启「按积分折扣排序」(默认开启)。每次请求按各渠道当前公布的**积分倍率**从小到大排列候选账号,倍率越低越便宜、越先用。倍率来自模型目录并随目录刷新,限时促销到期后自动恢复,因此不需要定时任务。三家的数据形态不同(Trae 为数值 `creditMultiplier`,WorkBuddy 与 Qoder 为 `x0.11` 字符串),统一解析后把生效中的 `promotions[].factor` 作为折上折计入,`factor` 为 0 表示直接替换成本价。
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
优先级沿用既有约定,并按**是否持有临期积分**分成互不跨越的两组:持有临期积分的账号整体排在其余账号之前,无论倍率高低或本轮是否已用完额度,因此折扣与额度都不会破坏临期优先。
|
|
119
|
+
|
|
120
|
+
两组内部规则不同:
|
|
121
|
+
|
|
122
|
+
- **临期组**:先按到期时间排列(越早到期越优先),折扣不参与(倍率与到期时间无关,不能让到期更晚但更便宜的积分包排到前面);「积分使用均衡」的额度降权在组内生效,所以最早到期的账号用完阈值后会让位给同为临期的其他账号,而不是被非临期账号插队。
|
|
123
|
+
- **其余账号**:按配置顺序排列,折扣排序与额度降权同样在组内生效;未公布倍率的账号排在最后,不会被当成免费。
|
|
124
|
+
|
|
125
|
+
冷却只作用于临期优先本身,普通路由照常运行。`creditRates` 是每次发布时从目录派生的运行时数据而非配置,面板回传或手工编辑会在归一化阶段被丢弃。Free 自动免费模型路由不参与,也不展示该开关。
|
|
119
126
|
|
|
120
127
|
额度只决定下一次请求选哪个账号,不中断正在生成的回答;并发请求、最后一次请求可能使阈值超过,积分结算延迟也可能造成超额。这是轮换阈值,不是上游消费硬上限。
|
|
121
128
|
|
package/cordis.patch.yml
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
- insert:
|
|
2
|
-
- id: llm-multi-router-v2-0.6.
|
|
3
|
-
name: ./lib/host-v0.6.
|
|
2
|
+
- id: llm-multi-router-v2-0.6.11
|
|
3
|
+
name: ./lib/host-v0.6.11.js
|
package/lib/api-service.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TM5XDMGY.js";
|
|
4
4
|
import "./chunk-4V52V5GO.js";
|
|
5
5
|
import "./chunk-DNQPZMPF.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-4L2CBGXN.js";
|
|
7
7
|
import "./chunk-GEBZMIMA.js";
|
|
8
8
|
export {
|
|
9
9
|
ApiService
|
|
@@ -338,22 +338,22 @@ var Router = class {
|
|
|
338
338
|
/**
|
|
339
339
|
* Sort candidates inside each expiring-credit group, never across the boundary.
|
|
340
340
|
*
|
|
341
|
-
* `
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* its own group rather than counting as the cheapest.
|
|
341
|
+
* `group` classifies a candidate — expiring versus not — and only the order inside a
|
|
342
|
+
* group changes. That keeps every account holding expiring credits ahead of the ones
|
|
343
|
+
* that do not, whatever their price, while the accounts within the expiring group are
|
|
344
|
+
* still ordered among themselves. `key` returning undefined means "no opinion" and
|
|
345
|
+
* sorts last inside its own group rather than counting as the cheapest.
|
|
346
346
|
*/
|
|
347
|
-
sortWithinGroups(candidates,
|
|
347
|
+
sortWithinGroups(candidates, group, key) {
|
|
348
348
|
const groups = /* @__PURE__ */ new Map();
|
|
349
349
|
for (const candidate of candidates) {
|
|
350
|
-
const
|
|
351
|
-
if (!groups.has(
|
|
352
|
-
groups.get(
|
|
350
|
+
const name = group(candidate);
|
|
351
|
+
if (!groups.has(name)) groups.set(name, []);
|
|
352
|
+
groups.get(name).push(candidate);
|
|
353
353
|
}
|
|
354
354
|
const result = [];
|
|
355
|
-
for (const
|
|
356
|
-
const decorated =
|
|
355
|
+
for (const members of groups.values()) {
|
|
356
|
+
const decorated = members.map((candidate, index) => ({ candidate, index, key: key(candidate) }));
|
|
357
357
|
decorated.sort((a, b) => {
|
|
358
358
|
if (a.key === b.key) return a.index - b.index;
|
|
359
359
|
if (a.key === void 0) return 1;
|
|
@@ -366,15 +366,18 @@ var Router = class {
|
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* Move accounts whose observed credit spend exceeded this route's threshold behind
|
|
369
|
-
* the ones that still have headroom,
|
|
369
|
+
* the ones that still have headroom, inside each expiring-credit group.
|
|
370
370
|
*
|
|
371
371
|
* This is a preference, not a filter: the caller keeps every candidate, so a route
|
|
372
372
|
* whose accounts are all over budget still serves requests instead of failing. The
|
|
373
373
|
* baseline is per route and per account, so switching accounts resets a newcomer's
|
|
374
374
|
* counter to zero while the previous account stays demoted for the rest of the round.
|
|
375
375
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
376
|
+
* `group` splits candidates into expiring and non-expiring. Scoping the demotion to
|
|
377
|
+
* that split keeps an account holding expiring credits ahead of one that does not,
|
|
378
|
+
* while the expiring accounts still take turns among themselves — grouping by the exact
|
|
379
|
+
* expiry date instead would leave each of them alone in its own group, and the allowance
|
|
380
|
+
* would never move a request off an account that still has credits left.
|
|
378
381
|
*
|
|
379
382
|
* Once every candidate in a group has spent its allowance the round is over and those
|
|
380
383
|
* baselines restart from the current total. Without that reset the counters only ever
|
|
@@ -383,7 +386,7 @@ var Router = class {
|
|
|
383
386
|
* Spend is inferred from platform balance drops, so one request may overshoot and an
|
|
384
387
|
* account without a usable balance reading is never demoted on a guess.
|
|
385
388
|
*/
|
|
386
|
-
demoteOverBudget(alias, route, candidates,
|
|
389
|
+
demoteOverBudget(alias, route, candidates, group = () => false) {
|
|
387
390
|
if (!candidates.length) return candidates;
|
|
388
391
|
const threshold = route.creditBalanceThreshold ?? 1e3;
|
|
389
392
|
const bases = this.budgets.get(alias) ?? /* @__PURE__ */ new Map();
|
|
@@ -392,14 +395,14 @@ var Router = class {
|
|
|
392
395
|
for (const id of bases.keys()) if (!live.has(id)) bases.delete(id);
|
|
393
396
|
const groups = /* @__PURE__ */ new Map();
|
|
394
397
|
for (const candidate of candidates) {
|
|
395
|
-
const
|
|
396
|
-
if (!groups.has(
|
|
397
|
-
groups.get(
|
|
398
|
+
const name = group(candidate);
|
|
399
|
+
if (!groups.has(name)) groups.set(name, []);
|
|
400
|
+
groups.get(name).push(candidate);
|
|
398
401
|
}
|
|
399
402
|
const result = [];
|
|
400
|
-
for (const
|
|
403
|
+
for (const group2 of groups.values()) {
|
|
401
404
|
const fresh = [], spent = [];
|
|
402
|
-
for (const candidate of
|
|
405
|
+
for (const candidate of group2) {
|
|
403
406
|
const id = candidate.account.id, row = this.telemetry.row("accounts", id);
|
|
404
407
|
const observed = row.creditsObserved ?? 0;
|
|
405
408
|
if (!bases.has(id)) bases.set(id, observed);
|
|
@@ -415,9 +418,9 @@ var Router = class {
|
|
|
415
418
|
result.push(...fresh);
|
|
416
419
|
continue;
|
|
417
420
|
}
|
|
418
|
-
if (spent.length ===
|
|
419
|
-
for (const candidate of
|
|
420
|
-
result.push(...
|
|
421
|
+
if (spent.length === group2.length) {
|
|
422
|
+
for (const candidate of group2) bases.set(candidate.account.id, this.telemetry.row("accounts", candidate.account.id).creditsObserved ?? 0);
|
|
423
|
+
result.push(...group2);
|
|
421
424
|
continue;
|
|
422
425
|
}
|
|
423
426
|
result.push(...fresh, ...spent);
|
|
@@ -562,16 +565,17 @@ var Router = class {
|
|
|
562
565
|
}
|
|
563
566
|
preferActive ??= await this.syncExpiring(alias, route, expiryCandidates, below);
|
|
564
567
|
const expiry = (c) => preferActive && !this.telemetry.expiring(alias).completed.includes(c.account.id) ? this.expiringAt(c.account, route) : Infinity;
|
|
568
|
+
const expiringGroup = (c) => Number.isFinite(expiry(c));
|
|
565
569
|
if (preferActive) {
|
|
566
570
|
const ordered = candidates.map((candidate, index) => ({ candidate, index }));
|
|
567
|
-
ordered.sort((a, b) => expiry(a.candidate) - expiry(b.candidate) || a.index - b.index);
|
|
571
|
+
ordered.sort((a, b) => Number(expiringGroup(b.candidate)) - Number(expiringGroup(a.candidate)) || expiry(a.candidate) - expiry(b.candidate) || a.index - b.index);
|
|
568
572
|
candidates = ordered.map((entry) => entry.candidate);
|
|
569
573
|
}
|
|
570
|
-
if (route.discountOrder && !route.freeOnly) candidates = this.sortWithinGroups(candidates, expiry, (candidate) => {
|
|
574
|
+
if (route.discountOrder && !route.freeOnly) candidates = this.sortWithinGroups(candidates, (candidate) => expiry(candidate), (candidate) => {
|
|
571
575
|
const rate = route.creditRates?.[candidate.account.id];
|
|
572
576
|
return rate === void 0 ? void 0 : rate;
|
|
573
577
|
});
|
|
574
|
-
if (route.balanceCredits && !route.freeOnly && this.telemetry) candidates = this.demoteOverBudget(alias, route, candidates,
|
|
578
|
+
if (route.balanceCredits && !route.freeOnly && this.telemetry) candidates = this.demoteOverBudget(alias, route, candidates, expiringGroup);
|
|
575
579
|
if (strategy === "weighted") {
|
|
576
580
|
let eligible = candidates.filter(available);
|
|
577
581
|
const nearest = Math.min(Infinity, ...eligible.map(expiry));
|
|
@@ -667,4 +671,4 @@ export {
|
|
|
667
671
|
matchModel,
|
|
668
672
|
Router
|
|
669
673
|
};
|
|
670
|
-
//# sourceMappingURL=chunk-
|
|
674
|
+
//# sourceMappingURL=chunk-4L2CBGXN.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/telemetry.mjs", "../src/model-context.mjs", "../src/router.mjs"],
|
|
4
|
+
"sourcesContent": ["import { createHash, randomUUID } from 'node:crypto';\nimport { assistantStreamFirstTokenTime } from '@deepseek-ai/dsh-llm';\nimport { readFile } from 'node:fs/promises';\nimport { writePrivateJson } from './config.mjs';\nconst empty = () => ({ requests: 0, failures: 0, input: 0, output: 0, tokens: 0, unmetered: 0 });\nconst day = at => new Date(at).toLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' });\nconst safe = n => typeof n === 'number' && Number.isFinite(n) && n >= 0 ? n : 0;\nconst measured = n => typeof n === 'number' && Number.isFinite(n) && n >= 0 ? n : null;\nexport class Telemetry {\n constructor(file, now = Date.now) { this.file = file; this.now = now; this.retentionDays = 30; this.data = { accounts: {}, routes: {}, days: {}, rounds: {}, expiringRounds: {}, events: [] }; this.queue = Promise.resolve(); }\n async load() {\n try { const saved = JSON.parse(await readFile(this.file, 'utf8')); if (saved.version !== 1) throw Error('Unsupported telemetry'); this.data = { ...saved, expiringRounds: saved.expiringRounds ?? {} }; }\n catch (e) { if (e.code !== 'ENOENT') throw e; }\n if (this.prune()) await this.persist();\n }\n configure(retentionDays) { this.retentionDays = retentionDays; }\n prune() {\n const cutoff = this.now() - this.retentionDays * 86400000, before = this.data.events.length;\n this.data.events = this.data.events.filter(e => Number.isFinite(e.at) && e.at >= cutoff);\n return before !== this.data.events.length;\n }\n row(group, key) { if (!Object.hasOwn(this.data[group], key)) Object.defineProperty(this.data[group], key, { value: empty(), enumerable: true, writable: true }); return this.data[group][key]; }\n count(alias, account) { return this.row('routes', JSON.stringify([alias, account])); }\n expiring(alias) {\n if (!Object.hasOwn(this.data.expiringRounds, alias)) Object.defineProperty(this.data.expiringRounds, alias, { value: { accounts: [], completed: [], cooldownUntil: 0, number: 1 }, enumerable: true, writable: true });\n return this.data.expiringRounds[alias];\n }\n restartExpiring(alias) { const row = this.expiring(alias); row.accounts = []; row.completed = []; row.cooldownUntil = 0; row.number++; return this.persist(); }\n round(alias, signature) {\n if (!Object.hasOwn(this.data.rounds, alias) || this.data.rounds[alias].signature !== signature) Object.defineProperty(this.data.rounds, alias, { value: { signature, number: 1, bases: {} }, enumerable: true, writable: true });\n return this.data.rounds[alias];\n }\n advance(alias, candidates, signature) {\n const round = this.round(alias, signature); round.number++;\n for (const c of candidates) Object.defineProperty(round.bases, c.account.id, { value: { tokens: this.count(alias, c.account.id).tokens, credits: this.row('accounts', c.account.id).creditsObserved ?? 0 }, enumerable: true, writable: true, configurable: true });\n return this.persist();\n }\n observe(account, snapshot) {\n const row = this.row('accounts', account);\n if (Number.isFinite(snapshot.remaining) && snapshot.unit === 'credits') {\n const sameCycle = row.balance?.cycle === snapshot.cycle;\n const change = sameCycle && Number.isFinite(row.balance?.remaining) ? Math.max(0, row.balance.remaining - snapshot.remaining) : 0;\n row.creditsObserved = (row.creditsObserved ?? 0) + change;\n }\n row.balance = snapshot;\n return this.persist();\n }\n record(event) {\n const at = this.now();\n const rows = [this.row('accounts', event.account), this.count(event.alias, event.account), this.row('days', day(at))];\n for (const row of rows) {\n row.requests++; if (!event.ok) row.failures++;\n if (event.usage) { const input = safe(event.usage.prompt_tokens), output = safe(event.usage.completion_tokens); row.input += input; row.output += output; row.tokens += safe(event.usage.total_tokens) || input + output; }\n else if (event.status === 200 || event.accepted) row.unmetered++;\n }\n const input = measured(event.usage?.prompt_tokens), output = measured(event.usage?.completion_tokens);\n this.data.events.unshift({ at, account: event.account, provider: event.provider, alias: event.alias, model: event.model ?? null, status: event.status,\n outcome: event.ok ? 'completed' : event.cancelled ? 'cancelled' : 'failed', input, output,\n tokens: measured(event.usage?.total_tokens) ?? (input !== null && output !== null ? input + output : null),\n cachedInput: measured(event.usage?.prompt_tokens_details?.cached_tokens), reasoningOutput: measured(event.usage?.completion_tokens_details?.reasoning_tokens),\n callId: event.callId ?? null, session: event.session ?? null, source: event.source === 'api' ? 'api' : 'dsh',\n timing: event.timing ? Object.fromEntries(['modelMs', 'ttftMs', 'decodeMs', 'decodeTokens'].map(k => [k, measured(event.timing[k])])) : null, timingSource: event.timing ? 'upstream' : null });\n const dates = Object.keys(this.data.days).sort(); for (const key of dates.slice(0, -31)) delete this.data.days[key];\n return this.persist();\n }\n persist() { this.prune(); const saved = structuredClone({ ...this.data, version: 1 }); this.queue = this.queue.catch(() => {}).then(() => writePrivateJson(this.file, saved)); return this.queue; }\n state() { this.prune(); return { ...structuredClone(this.data), retentionDays: this.retentionDays, today: day(this.now()), updatedAt: this.now() }; }\n}\n\n// Pass bytes through unchanged; parse only usage and terminal/error markers, never persist content.\nexport function meterResponse(response, complete, signal, { now = () => performance.now(), startedAt = now() } = {}) {\n if (!response.body) return response;\n const reader = response.body.getReader(), decoder = new TextDecoder();\n let pending = '', usage, ended = false, failed = false, finished = false, firstToken = null, terminalAt = null;\n async function finish(cancelled = false) { if (finished) return; finished = true; const end = terminalAt ?? now(); await complete({ usage, ok: ended && !failed && !cancelled, cancelled, timing: { modelMs: Math.max(0, end - startedAt), ttftMs: firstToken === null ? null : Math.max(0, firstToken - startedAt), decodeMs: firstToken === null ? null : Math.max(0, end - firstToken), decodeTokens: firstToken === null ? null : measured(usage?.completion_tokens) } }); }\n function inspect(bytes) {\n pending += decoder.decode(bytes, { stream: true });\n let split;\n while ((split = /\\r?\\n\\r?\\n/.exec(pending))) {\n const frame = pending.slice(0, split.index); pending = pending.slice(split.index + split[0].length);\n const data = frame.split(/\\r?\\n/).filter(l => l.startsWith('data:')).map(l => l.slice(5).trimStart()).join('\\n');\n if (data === '[DONE]') { ended = true; terminalAt ??= now(); continue; }\n try { const value = JSON.parse(data); if (value.usage && ['prompt_tokens', 'completion_tokens', 'total_tokens'].some(k => Number.isFinite(value.usage[k]) && value.usage[k] >= 0)) usage = value.usage; if (value.error) failed = true; if (firstToken === null && value.choices?.some(c => { const d = c.delta; return [d?.content, d?.reasoning_content, d?.reasoning].some(v => typeof v === 'string' && v.trim()) || d?.tool_calls?.some(t => t.function?.name || t.function?.arguments); })) firstToken = now(); if (value.choices?.some(c => c.finish_reason)) { ended = true; terminalAt ??= now(); } } catch { /* Unknown frame is forwarded. */ }\n }\n if (pending.length > 1024 * 1024) { pending = ''; failed = true; }\n }\n const body = new ReadableStream({\n async pull(controller) {\n try { signal?.throwIfAborted(); const chunk = await reader.read(); if (chunk.done) { await finish(); controller.close(); } else { inspect(chunk.value); controller.enqueue(chunk.value); } }\n catch (e) { await finish(signal?.aborted); controller.error(e); await reader.cancel().catch(() => {}); }\n },\n async cancel(reason) { await reader.cancel(reason).catch(() => {}); await finish(!ended); },\n });\n return new Response(body, { status: response.status, headers: response.headers });\n}\n\n// Link local transport attempts to DSH steps without retaining titles, prompts,\n// tool names/arguments/results, or the original session identity.\nexport class SessionMetrics {\n constructor(telemetry) { this.telemetry = telemetry; this.steps = new Map(); }\n key(id) { return createHash('sha256').update(String(id)).digest('hex').slice(0, 24); }\n beginCall(sessionId, purpose) {\n const callId = randomUUID(), session = sessionId == null ? null : this.key(sessionId);\n const step = session && this.steps.get(session);\n if (step && !purpose) step.callId = callId;\n return { callId, session };\n }\n event(session, event) {\n const key = this.key(session.id), d = event.data;\n if (event.type === 'step/start') { this.steps.set(key, { turn: d.turn, step: d.step, start: event.time, first: null, calls: new Map(), toolMs: 0, toolCount: 0, toolsCompleted: 0 }); return; }\n const step = this.steps.get(key);\n if (!step) return;\n if (d.turn !== undefined && (d.turn !== step.turn || d.step !== undefined && d.step !== step.step)) return;\n if (event.type === 'assistant/attempt') { step.first ??= assistantStreamFirstTokenTime(d.stream) ?? null; return; }\n const row = this.telemetry.data.events.find(e => e.callId === step.callId && e.session === key);\n if (event.type === 'assistant/message') {\n if (!row || d.interrupted) return;\n const first = step.first ?? assistantStreamFirstTokenTime(d.stream) ?? null;\n const output = measured(d.usage?.outputTokens);\n row.timing = { modelMs: Math.max(0, event.time - step.start), ttftMs: first === null ? null : Math.max(0, first - step.start),\n decodeMs: first === null || output === null ? null : Math.max(0, event.time - first), decodeTokens: first === null ? null : output };\n row.timingSource = 'dsh-step';\n } else if (event.type === 'tool/call' && row?.timingSource === 'dsh-step') {\n if (!step.calls.has(d.callId)) { step.calls.set(d.callId, event.time); step.toolCount++; }\n } else if (event.type === 'tool/result' && step.calls.has(d.message?.source?.callId)) {\n const id = d.message.source.callId;\n step.toolMs += Math.max(0, event.time - step.calls.get(id)); step.toolsCompleted++; step.calls.delete(id);\n } else if (event.type === 'step/end' || event.type === 'turn/end') {\n this.steps.delete(key);\n } else return;\n if (row?.timingSource !== 'dsh-step') return;\n Object.assign(row.timing, { toolMs: step.toolMs, toolCount: step.toolCount, toolsCompleted: step.toolsCompleted });\n return this.telemetry.persist();\n }\n dispose(session) { this.steps.delete(this.key(session.id)); }\n}\n", "const positive = n => Number.isSafeInteger(n) && n > 0;\n\n// Preserve native/default tiers separately from the local DSH budget.\nexport function contextInfo(model) {\n const defaultContextWindow = positive(model.defaultContextWindow) ? model.defaultContextWindow\n : positive(model.contextWindow) ? model.contextWindow : 200000;\n const supportedContextWindows = [...new Set([defaultContextWindow, model.contextWindow, model.maxContextWindow,\n ...(Array.isArray(model.supportedContextWindows) ? model.supportedContextWindows : [])].filter(positive))].sort((a, b) => a - b);\n const maxContextWindow = supportedContextWindows.at(-1);\n return { defaultContextWindow, supportedContextWindows, maxContextWindow, contextWindow: maxContextWindow };\n}\n\nexport function resolveContext(models, selected, fallback = 200000) {\n const infos = models.map(contextInfo);\n const maxContextWindow = infos.length ? Math.max(...infos.map(m => m.maxContextWindow)) : fallback;\n const contextWindow = positive(selected) ? Math.min(selected, maxContextWindow) : maxContextWindow;\n return { maxContextWindow, contextWindow, contextKnown: infos.length > 0, configuredContextWindow: positive(selected) ? selected : null,\n supportedContextWindows: [...new Set([contextWindow, ...infos.flatMap(m => m.supportedContextWindows)])].sort((a, b) => a - b) };\n}\n\n// Select the smallest real wire tier that can honour a local budget. Never mutate\n// the shared discovered catalog: concurrent routes may request different tiers.\nexport function qoderContextModel(model, budget) {\n if (!model?.contextOptions) return model;\n const entries = Object.entries(model.contextOptions).filter(([, v]) => positive(v.tokenCount)).sort((a, b) => a[1].tokenCount - b[1].tokenCount);\n if (!entries.length) return model;\n const selected = budget == null ? entries.at(-1) : entries.find(([, v]) => v.tokenCount >= budget);\n if (!selected) throw Object.assign(Error('context_window_unavailable'), { status: 400, code: 'context_window_unavailable' });\n return { ...model, contextWindow: selected[1].tokenCount,\n contextOptions: Object.fromEntries(Object.entries(model.contextOptions).map(([key, value]) => [key, { ...value, isDefault: key === selected[0] }])) };\n}\n", "import { meterResponse } from './telemetry.mjs';\nimport { isFreeModel } from './config.mjs';\nimport { reasoningModes } from './reasoning.mjs';\nimport { contextInfo } from './model-context.mjs';\nexport class RouteError extends Error {\n constructor(status, code, attempts = [], hint) {\n super(`${code}${attempts.length ? ': ' + attempts.map(a => `${a.account} HTTP ${a.status}`).join(', ') : ''}${hint ? `\uFF08${hint}\uFF09` : ''}`);\n this.status = status; this.code = code; this.attempts = attempts; this.hint = hint;\n }\n}\nconst normalize = value => value.toLowerCase().replace(/[^a-z0-9]/g, '').replace(/official$/, '');\nexport function abortable(promise, signal) {\n if (!signal) return promise;\n // Attach handlers even if already aborted, so a late rejection is consumed.\n return new Promise((resolve, reject) => {\n const abort = () => reject(signal.reason ?? new DOMException('Aborted', 'AbortError'));\n signal.addEventListener('abort', abort, { once: true });\n if (signal.aborted) abort();\n Promise.resolve(promise).then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));\n });\n}\nexport function matchModel(alias, target, catalog, effort, provider = target.provider) {\n const allowed = m => m && (effort === undefined || reasoningModes(m, provider).includes(effort));\n if (target.model) return catalog.find(m => m.id === target.model && allowed(m));\n if (target.models) return target.models.map(id => catalog.find(m => m.id === id)).find(allowed);\n if (alias === 'ds4.1f') return catalog.find(m => allowed(m) && [m.id, m.name ?? ''].some(x => normalize(x) === 'deepseekv41flash'));\n}\n\nexport class Router {\n constructor(config, createClient, onAttempt = () => {}, now = Date.now) {\n this.config = config; this.createClient = createClient; this.onAttempt = onAttempt; this.now = now;\n this.telemetry = null; this.scores = new Map(); this.monitor = null; this.clients = new Map(); this.cooldowns = new Map(); this.active = new Map(); this.budgets = new Map();\n }\n /**\n * Sort candidates inside each expiring-credit group, never across the boundary.\n *\n * `group` classifies a candidate \u2014 expiring versus not \u2014 and only the order inside a\n * group changes. That keeps every account holding expiring credits ahead of the ones\n * that do not, whatever their price, while the accounts within the expiring group are\n * still ordered among themselves. `key` returning undefined means \"no opinion\" and\n * sorts last inside its own group rather than counting as the cheapest.\n */\n sortWithinGroups(candidates, group, key) {\n const groups = new Map();\n for (const candidate of candidates) {\n const name = group(candidate);\n if (!groups.has(name)) groups.set(name, []);\n groups.get(name).push(candidate);\n }\n const result = [];\n for (const members of groups.values()) {\n const decorated = members.map((candidate, index) => ({ candidate, index, key: key(candidate) }));\n decorated.sort((a, b) => {\n if (a.key === b.key) return a.index - b.index;\n if (a.key === undefined) return 1;\n if (b.key === undefined) return -1;\n return a.key - b.key;\n });\n result.push(...decorated.map(entry => entry.candidate));\n }\n return result;\n }\n /**\n * Move accounts whose observed credit spend exceeded this route's threshold behind\n * the ones that still have headroom, inside each expiring-credit group.\n *\n * This is a preference, not a filter: the caller keeps every candidate, so a route\n * whose accounts are all over budget still serves requests instead of failing. The\n * baseline is per route and per account, so switching accounts resets a newcomer's\n * counter to zero while the previous account stays demoted for the rest of the round.\n *\n * `group` splits candidates into expiring and non-expiring. Scoping the demotion to\n * that split keeps an account holding expiring credits ahead of one that does not,\n * while the expiring accounts still take turns among themselves \u2014 grouping by the exact\n * expiry date instead would leave each of them alone in its own group, and the allowance\n * would never move a request off an account that still has credits left.\n *\n * Once every candidate in a group has spent its allowance the round is over and those\n * baselines restart from the current total. Without that reset the counters only ever\n * grow, every account stays demoted forever and the ordering stops changing after one pass.\n *\n * Spend is inferred from platform balance drops, so one request may overshoot and an\n * account without a usable balance reading is never demoted on a guess.\n */\n demoteOverBudget(alias, route, candidates, group = () => false) {\n if (!candidates.length) return candidates;\n const threshold = route.creditBalanceThreshold ?? 1000;\n const bases = this.budgets.get(alias) ?? new Map();\n this.budgets.set(alias, bases);\n const live = new Set(candidates.map(c => c.account.id));\n for (const id of bases.keys()) if (!live.has(id)) bases.delete(id);\n const groups = new Map();\n for (const candidate of candidates) {\n const name = group(candidate);\n if (!groups.has(name)) groups.set(name, []);\n groups.get(name).push(candidate);\n }\n const result = [];\n for (const group of groups.values()) {\n const fresh = [], spent = [];\n for (const candidate of group) {\n const id = candidate.account.id, row = this.telemetry.row('accounts', id);\n const observed = row.creditsObserved ?? 0;\n if (!bases.has(id)) bases.set(id, observed);\n const used = observed - bases.get(id);\n // A balance rewrite (prepaid top-up, new settlement cycle) must not keep an account\n // demoted on a negative counter.\n if (!Number.isFinite(used) || used < 0) { bases.set(id, observed); fresh.push(candidate); continue; }\n (used >= threshold ? spent : fresh).push(candidate);\n }\n if (!spent.length) { result.push(...fresh); continue; }\n if (spent.length === group.length) {\n // Every account in this group has used its allowance: bank the totals and start a\n // new round for the group.\n for (const candidate of group) bases.set(candidate.account.id, this.telemetry.row('accounts', candidate.account.id).creditsObserved ?? 0);\n result.push(...group);\n continue;\n }\n result.push(...fresh, ...spent);\n }\n return result;\n }\n updateConfig(config) {\n for (const old of this.config.accounts) {\n const next = config.accounts.find(a => a.id === old.id);\n if (!next || next.provider !== old.provider || next.credentialFile !== old.credentialFile || next.identityFile !== old.identityFile) this.clients.delete(old.id);\n }\n this.config = config;\n for (const alias of this.active.keys()) if (!Object.hasOwn(config.routes, alias)) this.active.delete(alias);\n for (const alias of this.budgets.keys()) if (!Object.hasOwn(config.routes, alias)) this.budgets.delete(alias);\n }\n async client(account) {\n if (!this.clients.has(account.id)) this.clients.set(account.id, Promise.resolve().then(() => this.createClient(account)));\n try { return await this.clients.get(account.id); }\n catch (error) { this.clients.delete(account.id); throw error; }\n }\n status() {\n return this.config.accounts.map(a => ({ id: a.id, provider: a.provider, enabled: a.enabled !== false,\n cooldowns: [...this.cooldowns].filter(([key, time]) => key.startsWith(`${a.id}:`) && time > this.now())\n .map(([key, time]) => ({ route: key.slice(a.id.length + 1), remainingMs: time - this.now() })),\n activeFor: [...this.active].filter(([, key]) => key.split(':')[0] === a.id).map(([alias]) => alias) }));\n }\n candidates(alias) {\n const route = this.config.routes[alias];\n if (!Object.hasOwn(this.config.routes, alias)) throw new RouteError(404, 'unknown_model', [], '\u63D2\u4EF6\u8DEF\u7531\u8868\u4E2D\u6CA1\u6709\u8BE5\u8C03\u7528\u540D\u79F0\uFF0C\u8BF7\u5728\u914D\u7F6E\u9875\u65B0\u5EFA\u6216\u6062\u590D\u5BF9\u5E94\u8DEF\u7531');\n const candidates = route.targets.flatMap((target, index) => this.config.accounts\n .filter(a => a.enabled !== false && a.provider === target.provider && (!target.account || a.id === target.account))\n .flatMap(account => route.freeOnly ? (this.freeModels?.(account) ?? []).filter(m => (!target.model || m.id === target.model) && (!target.models || target.models.includes(m.id)))\n .map(model => ({ account, target: { ...target, model: model.id, models: undefined }, key: `${account.id}:${index}:${model.id}` }))\n : [{ account, target, key: `${account.id}:${index}` }]));\n const active = candidates.findIndex(c => c.key === this.active.get(alias));\n return active < 0 ? candidates : [...candidates.slice(active), ...candidates.slice(0, active)];\n }\n expiringAt(account, route) {\n const balance = this.telemetry?.row('accounts', account.id).balance;\n if (!balance || balance.error || balance.unit !== 'credits' || this.now() - balance.fetchedAt > 120000) return Infinity;\n const horizon = this.now() + (route.expiringWithinDays ?? 7) * 86400000;\n return Math.min(Infinity, ...(balance.packages ?? []).filter(p => p.remaining > 0 && !p.unlimited && p.expiresAt > this.now() && p.expiresAt <= horizon).map(p => p.expiresAt));\n }\n async syncExpiring(alias, route, candidates, below = () => true) {\n if (!route.preferExpiringCredits || !this.telemetry) return false;\n const round = this.telemetry.expiring(alias);\n if (round.cooldownUntil > this.now()) return false;\n const before = JSON.stringify(round);\n if (round.cooldownUntil) { round.accounts = []; round.completed = []; round.cooldownUntil = 0; round.number++; }\n for (const id of round.accounts) {\n const matches = candidates.filter(c => c.account.id === id), balance = this.telemetry.row('accounts', id).balance;\n const fresh = balance && !balance.error && balance.unit === 'credits' && this.now() - balance.fetchedAt <= 120000;\n if (!matches.length || matches.every(c => !below(c)) || (fresh && !Number.isFinite(this.expiringAt({ id }, route)))) {\n if (!round.completed.includes(id)) round.completed.push(id);\n }\n }\n for (const c of candidates) if (below(c) && Number.isFinite(this.expiringAt(c.account, route)) && !round.accounts.includes(c.account.id)) round.accounts.push(c.account.id);\n // Cooling applies only to expiring-credit priority; ordinary routing keeps running.\n if (round.accounts.length && round.accounts.every(id => round.completed.includes(id))) round.cooldownUntil = this.now() + 3 * 86400000;\n if (JSON.stringify(round) !== before) await this.telemetry.persist();\n return round.cooldownUntil <= this.now();\n }\n remainingCooldown(candidate, alias, route) {\n const id = candidate.account.id;\n const keys = [`${id}:*`, `${id}:${alias}`];\n if (route.freeOnly) keys.push(`${id}:${alias}:${candidate.target.model}`);\n return Math.max(0, ...keys.map(key => (this.cooldowns.get(key) ?? 0) - this.now()));\n }\n exhaustHint({ alias, route, strategy, candidates, expiryCandidates, attempts }) {\n const kinds = new Set(attempts.map(a => a.kind));\n const modelOnly = attempts.length > 0 && [...kinds].every(k => ['model_unavailable', 'reasoning_effort_unavailable', 'model_no_longer_free', 'context_window_unavailable'].includes(k));\n const cooling = candidates.map(c => this.remainingCooldown(c, alias, route)).filter(ms => ms > 0);\n const soonest = cooling.length ? Math.min(...cooling) : undefined;\n const countdown = soonest === undefined ? undefined : `\u7EA6 ${Math.max(1, Math.ceil(soonest / 1000))} \u79D2\u540E\u53EF\u91CD\u8BD5`;\n if (!expiryCandidates.length) return route.freeOnly\n ? '\u8BE5\u8DEF\u7531\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u7684\u514D\u8D39\u6A21\u578B\uFF1A\u53EF\u80FD\u5DF2\u6062\u590D\u6536\u8D39\u3001\u9650\u514D\u5230\u671F\u6216\u76EE\u5F55\u83B7\u53D6\u5931\u8D25'\n : '\u8BE5\u8DEF\u7531\u6CA1\u6709\u53EF\u7528\u7684\u8D26\u53F7\u76EE\u6807\uFF1A\u8D26\u53F7\u53EF\u80FD\u5DF2\u5168\u90E8\u7981\u7528\uFF0C\u6216\u4E0E\u76EE\u6807\u6E20\u9053\u4E0D\u5339\u914D';\n if (kinds.has('context_window_unavailable') && modelOnly) return '\u5019\u9009\u6E20\u9053\u4E0D\u652F\u6301\u5F53\u524D\u4E0A\u4E0B\u6587\u9884\u7B97\uFF0C\u8BF7\u5237\u65B0\u76EE\u5F55\u6216\u5728\u6A21\u578B\uFF0F\u8DEF\u7531\u8BBE\u7F6E\u4E2D\u8C03\u4F4E\u9884\u7B97\uFF1B\u4E0D\u4F1A\u622A\u65AD\u4F1A\u8BDD\u6216\u964D\u7EA7\u5230\u5C0F\u5BB9\u91CF\u6E20\u9053';\n if (modelOnly) return `\u5DF2\u5C1D\u8BD5\u7684\u8D26\u53F7\u76EE\u5F55\u4E2D\u90FD\u6CA1\u6709\u8BE5\u6A21\u578B\u3001\u6240\u9009\u63A8\u7406\u6863\u4F4D\u6216\u514D\u8D39\u8D44\u683C\u4E0D\u6EE1\u8DB3${countdown ? `\uFF1B\u5176\u4F59\u8D26\u53F7\u51B7\u5374\u4E2D\uFF0C${countdown}` : ''}`;\n if (soonest !== undefined && cooling.length >= candidates.length) {\n return attempts.length ? `\u6240\u6709\u5019\u9009\u8D26\u53F7\u672C\u6B21\u8C03\u7528\u5747\u5931\u8D25\u5E76\u5DF2\u8FDB\u5165\u51B7\u5374\uFF0C${countdown}` : `\u5168\u90E8\u8D26\u53F7\u90FD\u5728\u5931\u8D25\u51B7\u5374\u4E2D\uFF0C${countdown}`;\n }\n if (soonest !== undefined) return `\u90E8\u5206\u8D26\u53F7\u4ECD\u5728\u5931\u8D25\u51B7\u5374\u4E2D\uFF0C${countdown}`;\n if (!attempts.length && ['tokens', 'credits'].includes(strategy)) return `\u6240\u6709\u8D26\u53F7\u7684\u672C\u8F6E${strategy === 'tokens' ? ' Token' : '\u79EF\u5206'}\u989D\u5EA6\u5DF2\u7528\u5B8C\uFF0C\u6216\u56E0\u7F3A\u5C11\u7528\u91CF\u8BA1\u91CF\u800C\u6682\u505C\u53C2\u4E0E\u8F6E\u6362`;\n return undefined;\n }\n async chat(input, signal, metadata = {}) {\n const alias = input.model;\n if (!Array.isArray(input.messages) || !input.messages.length || input.stream !== true) throw new RouteError(400, 'messages_and_stream_true_required');\n const initialRoute = this.config.routes[alias];\n if (initialRoute?.freeOnly) {\n await abortable(this.prepareFree?.(), signal);\n if (!this.config.routes[alias]) throw new RouteError(503, 'free_model_pool_unavailable', [], '\u672C\u8DEF\u7531\u4ECA\u5929\u6CA1\u6709\u53EF\u7528\u7684\u514D\u8D39\u6A21\u578B');\n }\n const effort = Object.hasOwn(input, 'reasoning_effort') ? input.reasoning_effort : this.config.routes[alias]?.reasoningEffort;\n input = { ...input }; delete input.reasoning_effort;\n if (effort !== undefined && effort !== null) input.reasoning_effort = effort;\n let candidates = this.candidates(alias);\n const expiryCandidates = [...candidates];\n const route = this.config.routes[alias], strategy = route.strategy ?? 'failover';\n const available = c => (this.cooldowns.get(`${c.account.id}:*`) ?? 0) <= this.now() && (this.cooldowns.get(`${c.account.id}:${alias}`) ?? 0) <= this.now()\n && (!route.freeOnly || (this.cooldowns.get(`${c.account.id}:${alias}:${c.target.model}`) ?? 0) <= this.now());\n if (route.preferExpiringCredits && this.monitor) {\n await Promise.all([...new Map(candidates.filter(available).map(c => [c.account.id, c.account])).values()].map(a => {\n const snapshot = this.telemetry?.row('accounts', a.id).balance;\n return !snapshot || snapshot.error || this.now() - snapshot.fetchedAt > 60000 ? this.monitor(a) : undefined;\n }));\n signal?.throwIfAborted();\n }\n if (strategy === 'credits') {\n await Promise.all([...new Map(candidates.filter(available).map(c => [c.account.id, c.account])).values()].map(a => this.monitor?.(a)));\n signal?.throwIfAborted();\n candidates = candidates.filter(c => { const balance = this.telemetry?.row('accounts', c.account.id).balance; return balance?.unit === 'credits' && Number.isFinite(balance.remaining) && this.now() - balance.fetchedAt < 120000 && !balance.error; });\n if (!candidates.length) throw new RouteError(503, 'credit_usage_unavailable', [], '\u65E0\u6CD5\u83B7\u53D6\u4EFB\u4F55\u5019\u9009\u8D26\u53F7\u7684\u79EF\u5206\u4F59\u989D\u6570\u636E');\n }\n const signature = JSON.stringify({ strategy, targets: route.targets });\n let below = () => true, preferActive;\n if (this.telemetry && ['tokens', 'credits'].includes(strategy)) {\n const round = this.telemetry.round(alias, signature);\n const counters = c => ({ tokens: this.telemetry.count(alias, c.account.id).tokens, credits: this.telemetry.row('accounts', c.account.id).creditsObserved ?? 0 });\n for (const c of candidates) if (!Object.hasOwn(round.bases, c.account.id)) Object.defineProperty(round.bases, c.account.id, { value: counters(c), enumerable: true, writable: true, configurable: true });\n below = c => !round.bases[c.account.id] || counters(c)[strategy] - round.bases[c.account.id][strategy] < (strategy === 'tokens' ? c.target.tokenBudget : c.target.creditBudget);\n preferActive = await this.syncExpiring(alias, route, expiryCandidates, below);\n // Start another round only when every configured, metered candidate has used its budget.\n if (candidates.length && candidates.every(c => !below(c))) {\n await this.telemetry.advance(alias, candidates, signature);\n this.active.delete(alias);\n const allowed = new Set(candidates.map(c => c.key));\n candidates = this.candidates(alias).filter(c => allowed.has(c.key));\n }\n candidates = candidates.filter(below);\n if (strategy === 'tokens' && candidates.some(c => this.telemetry.count(alias, c.account.id).unmetered > 0)) {\n // A missing upstream usage marker cannot silently count as zero forever.\n candidates = candidates.filter(c => this.telemetry.count(alias, c.account.id).unmetered === 0);\n }\n }\n preferActive ??= await this.syncExpiring(alias, route, expiryCandidates, below);\n const expiry = c => preferActive && !this.telemetry.expiring(alias).completed.includes(c.account.id) ? this.expiringAt(c.account, route) : Infinity;\n // One group for accounts holding expiring credits and one for the rest. Every rule\n // below reorders only inside a group, so an expiring account stays ahead of a\n // non-expiring one whatever its price or remaining allowance.\n const expiringGroup = c => Number.isFinite(expiry(c));\n // Soonest expiry first, and that order is the starting point every later rule refines.\n // Comparing dates directly and breaking ties by the original index keeps two\n // non-expiring accounts equal, which subtracting two Infinity values would not.\n if (preferActive) {\n const ordered = candidates.map((candidate, index) => ({ candidate, index }));\n ordered.sort((a, b) => Number(expiringGroup(b.candidate)) - Number(expiringGroup(a.candidate))\n || expiry(a.candidate) - expiry(b.candidate) || a.index - b.index);\n candidates = ordered.map(entry => entry.candidate);\n }\n // Cheapest known rate first, inside the expiring group only. The rate is unrelated to\n // expiry, so it must not reorder accounts by how soon their credits run out: that\n // ordering is the point of the priority rule, and a cheaper pack expiring later is not\n // a reason to spend it first.\n if (route.discountOrder && !route.freeOnly) candidates = this.sortWithinGroups(candidates, candidate => expiry(candidate), candidate => {\n const rate = route.creditRates?.[candidate.account.id];\n return rate === undefined ? undefined : rate;\n });\n if (route.balanceCredits && !route.freeOnly && this.telemetry) candidates = this.demoteOverBudget(alias, route, candidates, expiringGroup);\n if (strategy === 'weighted') {\n let eligible = candidates.filter(available);\n const nearest = Math.min(Infinity, ...eligible.map(expiry));\n if (Number.isFinite(nearest)) eligible = eligible.filter(c => expiry(c) === nearest);\n if (eligible.length) {\n let scores = this.scores.get(alias);\n if (scores?.signature !== signature) { scores = { signature, values: new Map() }; this.scores.set(alias, scores); }\n let total = 0, winner;\n for (const c of eligible) { const weight = c.target.weight ?? 1; total += weight; scores.values.set(c.key, (scores.values.get(c.key) ?? 0) + weight); if (!winner || scores.values.get(c.key) > scores.values.get(winner.key)) winner = c; }\n scores.values.set(winner.key, scores.values.get(winner.key) - total);\n candidates = [winner, ...candidates.filter(c => c !== winner)];\n }\n }\n const attempts = [];\n // Each account/model target is attempted once, even when configuration repeats it.\n const tried = new Set();\n for (const candidate of candidates) {\n signal?.throwIfAborted();\n const { account, target, key } = candidate;\n if (!available(candidate)) continue;\n let result, actualModel, startedAt;\n try {\n const client = await abortable(this.client(account), signal);\n const catalog = await abortable(client.models(signal), signal);\n const suitable = route.enforceContext ? catalog.filter(m => contextInfo(m).maxContextWindow >= route.contextWindow) : catalog;\n const model = matchModel(alias, target, suitable, effort ?? undefined);\n if (!model) { attempts.push({ account: account.id, provider: account.provider, status: 404,\n kind: matchModel(alias, target, catalog, effort ?? undefined) ? 'context_window_unavailable'\n : matchModel(alias, target, catalog) ? 'reasoning_effort_unavailable' : 'model_unavailable' }); continue; }\n if (route.freeOnly && !isFreeModel(model, this.now())) { attempts.push({ account: account.id, provider: account.provider, status: 404, kind: 'model_no_longer_free' }); continue; }\n actualModel = model.id;\n const dedupe = `${account.id}:${model.id}`;\n if (tried.has(dedupe)) continue;\n tried.add(dedupe);\n startedAt = performance.now();\n result = await abortable(client.chat({ ...input, model: model.id }, signal, { contextWindow: route.contextWindow }), signal);\n signal?.throwIfAborted();\n if (result.ok) {\n this.active.set(alias, key);\n this.onAttempt({ account: account.id, provider: account.provider, alias, model: model.id, status: 200 });\n const response = this.telemetry ? meterResponse(result.response, async summary => {\n await this.telemetry.record({ ...summary, ...metadata, account: account.id, provider: account.provider, alias, model: model.id, accepted: true, status: summary.ok ? 200 : summary.cancelled ? 499 : 502 });\n await this.syncExpiring(alias, route, expiryCandidates, below);\n if (strategy === 'credits' || route.preferExpiringCredits) void this.monitor?.(account).then(() => this.syncExpiring(alias, route, expiryCandidates, below)).catch(() => {});\n }, signal, { startedAt }) : result.response;\n return { response, account: account.id, provider: account.provider };\n }\n } catch (error) {\n signal?.throwIfAborted();\n const reported = error.status ?? error.failure?.status ?? /\\bhttp\\s+(\\d{3})\\b/i.exec(error.message ?? '')?.[1];\n result = { ok: false, status: Number(reported) || 502, kind: error.code ?? error.failure?.code ?? 'transport' };\n }\n const status = result.status >= 400 && result.status <= 599 ? result.status : 502;\n const attempt = { account: account.id, provider: account.provider, status, kind: result.kind };\n attempts.push(attempt);\n await this.telemetry?.record({ ...attempt, ...metadata, alias, model: actualModel, ok: false, timing: startedAt === undefined ? null : { modelMs: Math.max(0, performance.now() - startedAt) } });\n // Upstream messages can contain credentials or request text: log metadata only.\n this.onAttempt({ ...attempt, alias });\n const retryable = status < 500 || this.config.retryServerErrors;\n if (!retryable) throw new RouteError(status, 'upstream_failed', attempts, '\u4E0A\u6E38\u8FD4\u56DE 5xx \u4E14\u672A\u5F00\u542F\u300C5xx \u548C\u7F51\u7EDC\u9519\u8BEF\u4E5F\u5207\u6362\u8D26\u53F7\u300D\uFF0C\u672C\u6B21\u8BF7\u6C42\u5DF2\u505C\u6B62');\n const scope = [401, 402, 429].includes(status) ? '*' : route.freeOnly && actualModel ? `${alias}:${actualModel}` : alias;\n this.cooldowns.set(`${account.id}:${scope}`, this.now() + this.config.cooldownMs);\n }\n const hint = this.exhaustHint({ alias, route, strategy, candidates, expiryCandidates, attempts });\n throw new RouteError(503, route.freeOnly ? 'free_model_pool_unavailable' : 'account_pool_exhausted', attempts, hint);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA,SAAS,YAAY,kBAAkB;AACvC,SAAS,qCAAqC;AAC9C,SAAS,gBAAgB;AAEzB,IAAM,QAAQ,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,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AAQ,UAAU,QAAQ,MAAM,OAAO,KAAK;AAC7F,eAAS,KAAK,OAAO;AACrB,YAAM,KAAK,WAAW,OAAO,EAAE,GAAG,SAAS,GAAG,UAAU,OAAO,OAAO,aAAa,IAAI,OAAO,QAAQ,cAAc,SAAY,OAAO,EAAE,SAAS,KAAK,IAAI,GAAG,YAAY,IAAI,IAAI,SAAS,EAAE,EAAE,CAAC;AAEhM,WAAK,UAAU,EAAE,GAAG,SAAS,MAAM,CAAC;AACpC,YAAM,YAAY,SAAS,OAAO,KAAK,OAAO;AAC9C,UAAI,CAAC,UAAW,OAAM,IAAI,WAAW,QAAQ,mBAAmB,UAAU,mLAAuC;AACjH,YAAM,QAAQ,CAAC,KAAK,KAAK,GAAG,EAAE,SAAS,MAAM,IAAI,MAAM,MAAM,YAAY,cAAc,GAAG,KAAK,IAAI,WAAW,KAAK;AACnH,WAAK,UAAU,IAAI,GAAG,QAAQ,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,OAAO,UAAU;AAAA,IAClF;AACA,UAAM,OAAO,KAAK,YAAY,EAAE,OAAO,OAAO,UAAU,YAAY,kBAAkB,SAAS,CAAC;AAChG,UAAM,IAAI,WAAW,KAAK,MAAM,WAAW,gCAAgC,0BAA0B,UAAU,IAAI;AAAA,EACrH;AACF;",
|
|
6
|
+
"names": ["input", "output", "group"]
|
|
7
|
+
}
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
RouteError,
|
|
23
23
|
abortable,
|
|
24
24
|
qoderContextModel
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-4L2CBGXN.js";
|
|
26
26
|
import {
|
|
27
27
|
beijingDay,
|
|
28
28
|
writePrivateJson
|
|
@@ -5418,4 +5418,4 @@ export {
|
|
|
5418
5418
|
refreshWorkBuddyCheckinCredential,
|
|
5419
5419
|
createWorkBuddyCheckin
|
|
5420
5420
|
};
|
|
5421
|
-
//# sourceMappingURL=chunk-
|
|
5421
|
+
//# sourceMappingURL=chunk-NZF36O5I.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
RouteError,
|
|
9
9
|
abortable
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4L2CBGXN.js";
|
|
11
11
|
import {
|
|
12
12
|
REASONING_EFFORTS,
|
|
13
13
|
beijingDay,
|
|
@@ -329,4 +329,4 @@ async function collectCompletion(frames, model) {
|
|
|
329
329
|
export {
|
|
330
330
|
ApiService
|
|
331
331
|
};
|
|
332
|
-
//# sourceMappingURL=chunk-
|
|
332
|
+
//# sourceMappingURL=chunk-TM5XDMGY.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-DNQPZMPF.js";
|
|
5
5
|
import {
|
|
6
6
|
RouteError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4L2CBGXN.js";
|
|
8
8
|
import {
|
|
9
9
|
REASONING_EFFORTS
|
|
10
10
|
} from "./chunk-GEBZMIMA.js";
|
|
@@ -117,4 +117,4 @@ function createShim(router, { modelPrefix = "" } = {}) {
|
|
|
117
117
|
export {
|
|
118
118
|
createShim
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-WDIT4E2W.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
refreshWorkBuddyCheckinCredential,
|
|
7
7
|
supportsCheckin,
|
|
8
8
|
workbuddyToken
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NZF36O5I.js";
|
|
10
10
|
import {
|
|
11
11
|
discoverLocalAccounts,
|
|
12
12
|
importAccount,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./chunk-KWXLQJS5.js";
|
|
20
20
|
import {
|
|
21
21
|
ApiService
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-TM5XDMGY.js";
|
|
23
23
|
import {
|
|
24
24
|
hostIsLoopback
|
|
25
25
|
} from "./chunk-DNQPZMPF.js";
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
contextInfo,
|
|
29
29
|
matchModel,
|
|
30
30
|
resolveContext
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-4L2CBGXN.js";
|
|
32
32
|
import {
|
|
33
33
|
PROVIDERS,
|
|
34
34
|
PROVIDER_NAMES,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
import { createHash, randomBytes as randomBytes3, timingSafeEqual } from "node:crypto";
|
|
46
46
|
|
|
47
47
|
// package.json
|
|
48
|
-
var version = "0.6.
|
|
48
|
+
var version = "0.6.11";
|
|
49
49
|
|
|
50
50
|
// src/manager.mjs
|
|
51
51
|
import { readFile as readFile4, mkdir as mkdir2, mkdtemp as mkdtemp2, rm as rm3 } from "node:fs/promises";
|
|
@@ -2056,4 +2056,4 @@ export {
|
|
|
2056
2056
|
Manager,
|
|
2057
2057
|
managementHandler
|
|
2058
2058
|
};
|
|
2059
|
-
//# sourceMappingURL=chunk-
|
|
2059
|
+
//# sourceMappingURL=chunk-YCAO7GCT.js.map
|