dsh-model-think-level 2.3.2 → 2.3.3

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/README.md CHANGED
@@ -76,9 +76,9 @@ DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行
76
76
 
77
77
  - 密钥按列表顺序排队。一个模型如果多把密钥都能访问,先走列表靠前的那把;某把密钥对某模型请求失败时:401/403/408/429/5xx 自动换下一把能访问该模型的密钥重试;**响应体说明「这个模型(或这个分组)没有它」**时也换下一把——`model_not_found`、`Model "…" is not supported by any configured account in this group`、`no available channel`,以及中文的「模型不存在/不支持/无可用渠道」等文案都算,因为这说的是**这把密钥所在的上游分组没有这个模型**,换一把密钥可能就有。**裸 404**(如 `404 page not found`)与 400/422 这类请求本身的问题仍然不重试,立即返回。所有密钥都拒绝同一个模型时,返回的错误里会补一句「这个供应商的全部 N 把密钥都拒绝了模型 X,通常是各密钥所在的分组不同」,而不是只留一句看不懂的 404。被拒的那把密钥会记住这次失败(时长取自 `Retry-After`,没有就按「模型没有」10 分钟、「太频繁」60 秒、「额度耗尽」30 分钟、「连接被拒」60 秒推算,重复失败翻倍并封顶),下次请求自动排到健康密钥后面;「模型没有」这条只冷却**这一对(密钥, 模型)**,同一把密钥的其它模型照常由它服务。冷却只是排序,密钥永远不会被真正丢弃——全体都在冷却时仍按原顺序尝试。
78
78
  - 密钥能访问哪些模型在密钥面板的「模型」里圈定(候选就是该供应商已添加的模型,做成多选胶囊),也可留空表示不限制。需要更多模型时用模型页的「获取模型」手动读取并勾选,见下文。
79
- - **保存后自动探测各密钥支持的模型**:供应商保存之后(以及新增/更换密钥、改动端点地址之后),插件会在后台按密钥逐把读取它自己的模型目录,并自动为每把密钥勾选「它列出的模型 ∩ 已添加到该供应商的模型」;某把密钥能服务全部已添加模型时保持「通吃」不再重复写。这套自动勾选的范围随每次保存重新校准。探测完全在后台进行,界面上没有任何中间过程——唯一可见的变化就是探测结束后密钥上的勾选直接更新。只要你在「模型」表单里手动保存过一次,这个范围就归你管,探测不再改动它。探测只读目录接口,不会用你的模型发请求。
79
+ - **自动探测各密钥支持的模型**:供应商保存之后(以及新增/更换密钥、改动端点地址之后),插件会在后台按密钥逐把读取它自己的模型目录,并为每把密钥写「它列出的模型 ∩ 已添加到该供应商的模型」:能提供全部已添加模型的密钥保持「通吃」不再写清单;只提供其中一部分的密钥写成交集;**一个已添加模型都不提供的密钥直接关闭**(只关这一把密钥的行,不动供应商本身;供应商下的密钥少于两把时不做探测,因为一把密钥本来就是全服)。这套清单随每次保存与每次点「自动探测」重新校准,手动在「模型」表单里改过的清单同样会在下一次探测时被覆盖。探测完全在后台进行,界面上没有任何中间过程——唯一可见的变化就是探测结束后密钥上的勾选直接更新。探测只读目录接口,不会用你的模型发请求。被自动关闭的密钥不会自己恢复,需要在密钥行上手动重新开启。
80
80
  - 未圈定模型清单的密钥视为「通吃」,可以服务任何模型;圈定后只服务清单内的模型。
81
- - 除了手写清单,插件还会**记住每把密钥各自的目录读到过什么**:宿主读取目录(模型页「获取模型」)时,插件按密钥逐把读取并把结果记在 `key-index.json` 同目录的 `key-serves.json`,只用于排序与提示,不写入你的清单。规则是「同一供应商下,别的密钥的目录里有这个模型、而这把没有」→ 这把不再作为该模型的候选;只有这一把的目录里有 → 它优先;没有任何密钥列出过(或还没读过)→ 当作未知,照旧都试。密钥面板的「模型」表单会显示这层观察结果,并给一个「用探测结果」按钮把它填进清单。某把密钥读取失败=未知,绝不会被当成「它什么模型都没有」;文件损坏时按空文件处理。
81
+ - 除了手写清单,插件还会**记住每把密钥各自的目录读到过什么**:宿主读取目录(模型页「获取模型」)时,插件按密钥逐把读取并把结果记在 `key-index.json` 同目录的 `key-serves.json`,只用于排序与提示,不写入你的清单。规则是「同一供应商下,别的密钥的目录里有这个模型、而这把没有」→ 这把不再作为该模型的候选;只有这一把的目录里有 → 它优先;没有任何密钥列出过(或还没读过)→ 当作未知,照旧都试。密钥面板「模型」里的勾选就是上面那层自动探测写下的结果。某把密钥读取失败=未知,绝不会被当成「它什么模型都没有」;文件损坏时按空文件处理。
82
82
  - 每把密钥行首有一个圆形对勾开关:亮起表示参与路由,灰色表示暂停使用。停用只是把密钥移出分流池,别名、模型清单与协议指定全部保留,重新点亮即恢复;最后一把启用中的密钥不允许停用(否则请求会回落到适配器自身的单密钥路径,仍然用刚被停用的那把签名)。
83
83
  - 「添加另一个密钥」会优先**填回已经列出、但凭据库里还没有值的引用**,而不是再铸一个新名字。这条是为跨机同步准备的:配置从另一台电脑同步过来时,点名的 `XXX_API_KEY_2` 在这台还没有值,直接填进去两台的名字就一致了;若改成铸 `XXX_API_KEY_3`,名字会分叉,旧名字还会在面板上留一行「未存储」的残行。填回时别名、模型清单与协议指定都保留(只补值,不改标签)。库里已有值的引用不会被顶掉——那种情况下仍然铸新名字。
84
84
  - 插件自身元数据保存在 DSH 数据目录的 `dsh-model-think-level/key-index.json`,只记录引用、别名、模型清单、协议指定、各协议族地址与启停状态,绝不保存密钥值(密钥值始终由 DSH 凭据库保管)。供应商暂时读不到、启动时快照不全,或从设置里删除,都**不会自动清除密钥、别名或凭据**:设置中的缺失不能证明用户要删除密钥。需要删除密钥时,请在密钥面板显式操作。旧 `routeSweepGraceMs` 配置继续接受,但已停用自动清扫,不再触发删除。
@@ -99,7 +99,7 @@ DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行
99
99
  - 同一协议(wire)的密钥会被当作一个池:先把这个池里的密钥都用完再换 wire,因为同一把密钥失败通常与协议无关;跨 wire 的切换排在池之后,且只有在上一次失败的请求还没开始产生内容时才会做。
100
100
  - 请求进行到一半再失败(已经开始流式输出、或调用方已经主动取消)不会触发换密钥——客户端已经消费了已经发出的内容,重放只会产生重复输出。
101
101
  - 密钥面板的「模型」选择是可点选的模型清单(该供应商已添加的模型做成多选胶囊),选中的模型才交给这把密钥;下面的「全部模型」表示不做限制。该项与其它操作按钮一样只在悬停时显示。
102
- - 模型页供应商卡片的「获取模型」是宿主自带的一次普通目录读取:读到的模型在官方勾选列表里供你取舍,勾选后才写入供应商。插件不替你探测目录,也不会自动把任何模型写进供应商或密钥清单;模型清单的每一次变化都来自你的手动勾选、手动添加或密钥面板的「模型」圈定。插件只是顺带观察这次读取里每把密钥各自返回了什么(见上一条),并在多把密钥的目录合并时做一次保守过滤:只有当这个供应商的**每一把**启用密钥都成功给出了目录、且没有任何一把列出某模型时,该模型不出现在合并结果里(有密钥没读到=情况未知,不过滤)。
102
+ - 模型页供应商卡片的「获取模型」是宿主自带的一次普通目录读取:读到的模型在官方勾选列表里供你取舍,勾选后才写入供应商。插件不替你探测目录,也不会自动把任何模型写进供应商;密钥清单的每一次变化只来自自动探测(见上文)或你在密钥面板「模型」里的手动圈定。插件只是顺带观察这次读取里每把密钥各自返回了什么(见上一条),并在多把密钥的目录合并时做一次保守过滤:只有当这个供应商的**每一把**启用密钥都成功给出了目录、且没有任何一把列出某模型时,该模型不出现在合并结果里(有密钥没读到=情况未知,不过滤)。
103
103
 
104
104
  插件不再支持 Gemini 原生协议或专用端点。旧的 `google-generative-ai` 密钥协议指定会按无效值回到「自动」,旧的 `gemini` 端点字段会在读取时忽略,并在下次保存插件密钥索引时移除。模型知识库中的 Gemini 思考档位仍保留,供支持 OpenAI 兼容协议的网关使用;不会根据 Gemini/Gemma 模型名自动切换到原生协议。若供应商主协议曾被手工设置为 `google-generative-ai`,仍需改回宿主支持的协议,并填写对应的兼容地址;插件不会自动改写宿主供应商配置。
105
105
 
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The masked key list survives the page — one localStorage entry per route.
3
+ *
4
+ * A cold read (a settings read plus one credential resolve per key, behind the
5
+ * host's serialised settings service) is what the panel used to pay on every
6
+ * page opening: the in-memory cache only ever answered a re-open inside the
7
+ * same page, so a restart painted "正在读取密钥…" again. This store keeps the
8
+ * last successful answer on disk, the client's `listCache` hydrates from it at
9
+ * creation, and the panel's own mount read revalidates in the background —
10
+ * first paint is the real list, and a change made elsewhere (or in an earlier
11
+ * session) lands as soon as that read answers.
12
+ *
13
+ * What is stored is exactly what the panel already paints: references, labels,
14
+ * scopes, protocols and the host's MASKED preview. Revealed secret values never
15
+ * travel through this module — they have their own reveal route and are never
16
+ * cached (see `key-manager-client`).
17
+ *
18
+ * Every access is best-effort: a browser in private mode, a quota error or a
19
+ * corrupted entry degrades to "no cache", never to a thrown panel.
20
+ *
21
+ * @module dsh-model-think-level/client/key-list-store
22
+ */
23
+ import type { KeyState } from './key-manager-client.js';
24
+ /**
25
+ * The last successful list for a route, or undefined when there is none (or it
26
+ * is too old to be worth painting).
27
+ */
28
+ export declare function loadKeyList(route: string): KeyState | undefined;
29
+ /**
30
+ * Remember one successful answer. Transient fields (a probe in flight, the ref
31
+ * an add just produced) are stripped: they describe a moment, not the list.
32
+ */
33
+ export declare function saveKeyList(route: string, state: KeyState): void;
34
+ /** Forget one route (the list no longer exists or the route was deleted). */
35
+ export declare function dropKeyList(route: string): void;
36
+ /**
37
+ * Every route this browser has a stored list for, newest first.
38
+ *
39
+ * The boot warm-up uses this to revalidate what the last session left behind;
40
+ * nothing else reads it. A route that is gone from the document simply answers
41
+ * a refusal and settles the warm-up's queue.
42
+ */
43
+ export declare function storedKeyLists(): readonly {
44
+ readonly route: string;
45
+ readonly savedAt: number;
46
+ }[];
47
+ /** Forget every route — the panel's own escape hatch. */
48
+ export declare function clearKeyLists(): void;
49
+ export declare const KEY_LIST_STORAGE_KEY = "dsh-model-think-level:key-lists:v1";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Revalidating what the last session left on disk.
3
+ *
4
+ * The stored list is what makes an opening instant: the panel paints it before
5
+ * it asks the host anything. It can still be a session old, though — a key
6
+ * deleted on another machine's custody, a route whose addresses moved — so
7
+ * this pass re-reads every stored route once per page opening, well after the
8
+ * first paint and two at a time, and lets the normal write path update the
9
+ * stored copy. Nothing here is user-visible: a slow or refused read is simply
10
+ * the panel's own mount read happening later.
11
+ *
12
+ * Deliberately NOT fed by the panel's click: the panel revalidates what it
13
+ * paints anyway, and two readers racing would double the host's settings reads
14
+ * for one screen. This one only runs while nobody is asking.
15
+ *
16
+ * @module dsh-model-think-level/client/key-list-warm
17
+ */
18
+ import type { KeyManagerClient } from './key-manager-client.js';
19
+ export interface KeyListWarmOptions {
20
+ /** Delay before the first read, so boot work wins. */
21
+ readonly delayMs?: number;
22
+ /** Reads in flight at once. */
23
+ readonly concurrency?: number;
24
+ /** Routes warmed per opening, newest first. */
25
+ readonly limit?: number;
26
+ /** Only routes older than this are worth re-reading. */
27
+ readonly minAgeMs?: number;
28
+ /** Clock, injectable for tests. */
29
+ readonly now?: () => number;
30
+ }
31
+ /**
32
+ * Start the background revalidation of the stored key lists.
33
+ * @param client - transport; only `list` is used.
34
+ * @param options - timing knobs, all optional.
35
+ * @returns a disposer that cancels the pass (a read already on the wire finishes).
36
+ */
37
+ export declare function warmStoredKeyLists(client: Pick<KeyManagerClient, 'list'>, options?: KeyListWarmOptions): () => void;
@@ -54,16 +54,6 @@ export interface KeyRow {
54
54
  * Absent means "unscoped": a catch-all that serves whatever is left.
55
55
  */
56
56
  readonly models?: readonly string[];
57
- /**
58
- * The model ids this key's OWN listing advertised the last time it answered —
59
- * observed by the host, not assigned by the user. A relay may resolve each key
60
- * to a different upstream account with its own catalogue, so one key's list can
61
- * be smaller than the route's; the panel offers this list as a one-click scope
62
- * so "this key only carries half the models" can be made explicit instead of
63
- * being discovered as a 404 at request time. Absent means never listed (or the
64
- * list named none of the route's models), which is unknown, not empty.
65
- */
66
- readonly observed?: readonly string[];
67
57
  /**
68
58
  * The wire protocol this key pins. Absent means "follow the provider's own
69
59
  * protocol". A pinned protocol makes this key speak a different API shape than
@@ -71,10 +61,9 @@ export interface KeyRow {
71
61
  */
72
62
  readonly protocol?: RouteProtocol;
73
63
  /**
74
- * Whether the key's model scope is the probe's assignment rather than a
75
- * manual one — the panel shows it so a scope edit knows the checked chips
76
- * will keep being rewritten on every probe run until the user saves one by
77
- * hand.
64
+ * Whether the key's model scope was written by the probe rather than saved by
65
+ * hand. The panel says so, because every probe rewrites the scope against what
66
+ * each key actually lists — an edit here is honoured until the next sweep.
78
67
  */
79
68
  readonly auto?: boolean;
80
69
  /**
@@ -159,8 +159,6 @@ export declare const en: {
159
159
  keysProbeHint: string;
160
160
  keysProbeSingle: string;
161
161
  keysProbeDone: string;
162
- keysScopeObserved: string;
163
- keysScopeObservedHint: string;
164
162
  keysScopeEmpty: string;
165
163
  keysProtocolLabel: string;
166
164
  keysProtocolCreate: string;