dsh-model-think-level 1.1.8 → 2.0.2

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.
Files changed (56) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +38 -0
  3. package/assets/NOTICE.md +15 -0
  4. package/assets/unified_bank.json +32910 -0
  5. package/lib/client/ComposerSlider.d.ts +9 -9
  6. package/lib/client/EffortEditor.d.ts +22 -12
  7. package/lib/client/FingerprintPane.d.ts +36 -0
  8. package/lib/client/KeyManager.d.ts +36 -10
  9. package/lib/client/ProtocolMenu.d.ts +51 -0
  10. package/lib/client/capacity.d.ts +30 -0
  11. package/lib/client/events.d.ts +26 -0
  12. package/lib/client/fingerprint-client.d.ts +81 -0
  13. package/lib/client/fingerprint-runner.d.ts +61 -0
  14. package/lib/client/index.d.ts +6 -0
  15. package/lib/client/injection/add-card.d.ts +4 -0
  16. package/lib/client/injection/create-card-pane.d.ts +15 -0
  17. package/lib/client/injection/create-key-seat.d.ts +53 -0
  18. package/lib/client/injection/create-keys-pane.d.ts +46 -0
  19. package/lib/client/injection/editor-tab-bar.d.ts +2 -1
  20. package/lib/client/injection/editor-tabs.d.ts +11 -1
  21. package/lib/client/injection/key-reveal.d.ts +24 -0
  22. package/lib/client/injection/models-page-editor.d.ts +165 -1
  23. package/lib/client/injection/provider-card-slot.d.ts +3 -1
  24. package/lib/client/injection/provider-endpoints.d.ts +70 -0
  25. package/lib/client/injection/staged-keys.d.ts +169 -0
  26. package/lib/client/key-manager-client.d.ts +89 -12
  27. package/lib/client/locales.d.ts +80 -6
  28. package/lib/client/ops.d.ts +4 -0
  29. package/lib/client/refresh-scheduler.d.ts +29 -0
  30. package/lib/client/styles.d.ts +1 -1
  31. package/lib/client/types.d.ts +44 -2
  32. package/lib/client.js +2275 -266
  33. package/lib/client.js.map +4 -4
  34. package/lib/constants.d.ts +11 -0
  35. package/lib/discovery-merge.d.ts +35 -0
  36. package/lib/fingerprint/bank.d.ts +24 -0
  37. package/lib/fingerprint/challenges.d.ts +14 -0
  38. package/lib/fingerprint/core.d.ts +85 -0
  39. package/lib/fingerprint/eligibility.d.ts +8 -0
  40. package/lib/fingerprint/random.d.ts +4 -0
  41. package/lib/fingerprint/run.d.ts +110 -0
  42. package/lib/fingerprint/store.d.ts +31 -0
  43. package/lib/fingerprint/verdict.d.ts +64 -0
  44. package/lib/headers-fetch.d.ts +53 -3
  45. package/lib/headers-pi-ai.d.ts +31 -1
  46. package/lib/index.d.ts +3 -19
  47. package/lib/index.js +2438 -153
  48. package/lib/index.js.map +4 -4
  49. package/lib/key-index.d.ts +58 -1
  50. package/lib/key-probe.d.ts +126 -0
  51. package/lib/key-refs.d.ts +106 -0
  52. package/lib/key-route-core.d.ts +415 -0
  53. package/lib/knowledge.d.ts +6 -5
  54. package/lib/listing.d.ts +118 -0
  55. package/lib/multi-key-listing.d.ts +101 -0
  56. package/package.json +13 -5
@@ -20,19 +20,19 @@ export interface ComposerSliderProps {
20
20
  configuredInputs?: ConfiguredInputs;
21
21
  /** Localized copy (the plugin's bound translator). */
22
22
  t: Translator;
23
- /**
24
- * Re-measure hook. The official card measures itself from its own layout
25
- * effect (`[open, pane, state]`) and only re-runs on a window `resize`, so a
26
- * body that grows here must ask the injector to re-place it — in the same
27
- * frame, never from a deferred task.
28
- */
29
- onLayoutChange?: () => void;
30
23
  }
31
24
  /** Provider label: the SDK face names it differently across kernel lines. */
32
25
  export declare function providerLabelOf(group: DirectoryGroupLike): string;
33
26
  /**
34
- * Render the model row and the reasoning-level row. Both values come from the
35
- * store; the commit travels through {@link ModelDirectoryLike.select}
27
+ * The ramp colour at `t` in 0..1 — the hue a ladder stop at that fraction of
28
+ * the track wears. Every stop of every ladder length lands on the same
29
+ * continuous cool→hot scale, so the colour alone reads as the effort's
30
+ * intensity whatever the ladder spells its levels.
31
+ */
32
+ export declare function effortRampColor(t: number): string;
33
+ /**
34
+ * Render the model switcher and the reasoning-level footer. Both values come
35
+ * from the store; the commit travels through {@link ModelDirectoryLike.select}
36
36
  * (optimistic, rolled back on refusal).
37
37
  */
38
38
  export declare function ComposerSlider(props: ComposerSliderProps): ReactNode;
@@ -5,12 +5,16 @@
5
5
  * everything arrives through a plain props face, so it stays testable in
6
6
  * isolation. The draft/intent rules live in the client/effort module.
7
7
  *
8
- * Suggestion feedback is ZONED: provenance + confidence form their own line;
9
- * capacity references render as a separate read-only block explicitly marked
10
- * "never auto-filled" -- the official capacity inputs above stay untouched.
11
- * The apply/reset actions sit at the very bottom and own every section.
12
- *
13
- * @module dsh-model-think-level/EffortEditor
8
+ * The shape is the design board's: one head line (the switch, the "declared N ·
9
+ * default X" state, and the applied suggestion's provenance pill) over a sunk
10
+ * panel with no outline of its own. Inside it, each decision is a section — a
11
+ * label row with its trailing action, the hint on its own line, and the control
12
+ * group under both: the level ladder as 28px chips, the armed levels' wire
13
+ * spellings folded behind a link into their own white sheet, then the default
14
+ * pick and the input modality side by side, then the two capacity fields. A
15
+ * hairline separates the declaration from the numbers. The only action is
16
+ * 放弃修改: the edits land with the official card's own Save, so this panel
17
+ * never grows a second commit button.
14
18
  */
15
19
  import type { ReactNode } from 'react';
16
20
  import type { CompatSuggestion, InputModalities, ReasoningEfforts } from '../knowledge.js';
@@ -65,13 +69,19 @@ export interface EffortEditorProps {
65
69
  */
66
70
  staged?: boolean;
67
71
  /**
68
- * Whether the official Models page owns input types for this row (the
69
- * 0.1.6-alpha.2 `ModelInputTypes` control was sniffed in the disclosure).
70
- * True hides the modality section: the official editor is the single
71
- * surface, so showing a second one would be duplicate UI. Older kernels
72
- * have no such control and keep the section.
72
+ * Whether the official Models page owns input types for this row. The
73
+ * injector now hides that official control and always shows this card's
74
+ * modality section, so the prop is kept only to document the old kernel
75
+ * split and is no longer read.
73
76
  */
74
77
  officialInputTypes?: boolean;
78
+ /**
79
+ * Report whether this card currently covers the official capacity and
80
+ * input-type chrome. The card exists only while the thinking switch is on;
81
+ * when it is off the row's own official controls have to come back, or a
82
+ * model that declares no reasoning would lose every way to edit its window.
83
+ */
84
+ onCoverageChange?: (covered: boolean) => void;
75
85
  /** The write seam (settings.mutate plus the suggestion engine). */
76
86
  api: EffortEditorApi;
77
87
  /** Read-only (settings document not writable). */
@@ -123,5 +133,5 @@ export declare function pendingWriteOf(parts: PendingWriteParts): PendingWrite;
123
133
  * checkboxes, the modality toggle, the auto-adapt action, and the
124
134
  * apply/reset actions that own both sections.
125
135
  */
126
- export declare function EffortEditor({ route, routeApi, routeBaseURL, modelId, modelName, efforts: initialEfforts, effortsUnset, input: initialInput, compat: initialCompat, defaultEffort: initialDefaultEffort, index, staged, officialInputTypes, api, readOnly, t }: EffortEditorProps): ReactNode;
136
+ export declare function EffortEditor({ route, routeApi, routeBaseURL, modelId, modelName, efforts: initialEfforts, effortsUnset, input: initialInput, compat: initialCompat, defaultEffort: initialDefaultEffort, index, staged, officialInputTypes, onCoverageChange, api, readOnly, t }: EffortEditorProps): ReactNode;
127
137
  export type { DraftLevels };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 指纹检测页签的面板:一家供应商的可检测模型清单、每行的状态徽章、逐行检测
3
+ * 与一键全测。
4
+ *
5
+ * 三条硬约束(m00702)在这里落成三件事:
6
+ * 1. **只认 GPT / Claude**:`isEligibleModel` 是唯一的闸,不在此列的模型连
7
+ * 行都不出现 —— 不给一个必然点不动的灰按钮。一个都没有就整页不显示。
8
+ * 2. **后台跑、不留进度**:没有浮层、没有 toast、没有遮罩、没有进度条。进
9
+ * 度只落在行徽章的 `检测中 · 2/3` 上;任务活在 `fingerprint-runner` 里,
10
+ * 这个组件只是订阅者,卸载时不中止任何东西。
11
+ * 3. **不进新增供应商卡片**:`isCreateProviderCard` 为真就整个渲染 null。
12
+ *
13
+ * 还有一条来自 m00883:指纹检测不与思考强度混在一行 —— 它有自己的页签、
14
+ * 自己的行、自己的结果卡,`.bre-model-grid` 一列都不动。
15
+ *
16
+ * @module dsh-model-think-level/client/FingerprintPane
17
+ */
18
+ import { type ReactNode } from 'react';
19
+ import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
20
+ import type { ClientContext, RemoteApi } from './types.js';
21
+ export interface FingerprintPaneProps {
22
+ /** 供应商的设置键。 */
23
+ route: string;
24
+ /** 设置 Remote(外加可选的 scope 镜像)。 */
25
+ api: RemoteApi;
26
+ /** 插件自己的翻译函数。 */
27
+ t: Translate;
28
+ /** 客户端根上下文;用于订阅设置文档变化。可选,缺了就只在挂载时读一次。 */
29
+ ctx?: ClientContext;
30
+ /** 挂载点:判定是不是新增供应商卡片用。 */
31
+ host: {
32
+ readonly current: HTMLElement | null;
33
+ };
34
+ }
35
+ /** 一家供应商的指纹检测面板。 */
36
+ export declare function FingerprintPane({ route, api, t, ctx, host }: FingerprintPaneProps): ReactNode;
@@ -1,6 +1,7 @@
1
1
  /**
2
- * The API-key list: one provider's keys, which one is in use, and the one
3
- * inline form that adds, relabels or replaces a key.
2
+ * The API-key list: one provider's keys, the model scope each key serves, the
3
+ * wire protocol each key speaks, the provider's two base URLs, and the one
4
+ * inline form that adds, relabels, replaces a key or edits its scope.
4
5
  *
5
6
  * Rendered inline under the official key field (see `injection/key-manager`),
6
7
  * not as a floating panel: the field's label already says "API key", so its list
@@ -11,18 +12,35 @@
11
12
  * The list is a view over host state and holds no truth of its own — every
12
13
  * mutation answers with the whole list, and the list is adopted as it arrives
13
14
  * (`adopt`), so the GUI can never drift from what the settings document and the
14
- * credential store actually say. Three facts it deliberately reflects:
15
+ * credential store actually say. The facts it reflects:
15
16
  *
16
- * - **the key in use is the profile's reference.** Choosing a row writes
17
- * `providers.<route>.apiKeyEnv`, so it holds for every request the route
18
- * makes, not only the ones this GUI starts. Exactly one key is in use per
19
- * provider, which is why the mark at the head of a row is a radio.
17
+ * - **every key switched on is active.** The keys are ordered by preference,
18
+ * the first one that can serve a model signs it, a model only one key lists
19
+ * sticks to that key, and a failed request fails over to the next capable
20
+ * key. Each row opens with a circular check that switches the key into or
21
+ * out of that pool: lit is in use, grey is paused — with the label, scope
22
+ * and protocol pin kept for the switch back on. Which key signs a request
23
+ * is decided by the model's scope, not by a row's position, so with several
24
+ * keys there is no "default" seat to mark any more.
25
+ * - **each key shows the models it serves.** Picked as chips from the models
26
+ * the route already offers — never the provider's whole catalog — so no one
27
+ * has to recall a model id, and an empty scope means "catch-all", serving
28
+ * whatever is left. The scope summary shares the hover-revealed action tray,
29
+ * so a resting row stays quiet.
30
+ * - **each key may pin a wire protocol.** A key that pins a protocol speaks
31
+ * that API shape (Anthropic Messages, Chat Completions or Responses) instead
32
+ * of the provider's default, and uses the matching base URL. A key left on
33
+ * "auto" speaks each model's own wire: claude models against the Anthropic
34
+ * address, gemini models against the Gemini one, the rest the provider's
35
+ * protocol — wherever that address is configured. The protocol picker lives
36
+ * in the same hover-revealed action tray as the other actions.
20
37
  * - **a value is shown masked, or not at all.** The host reads the stored
21
38
  * secret and answers a head-and-tail preview; the middle never leaves it,
22
39
  * and the eye beside the field stays the one gesture that reveals a value.
23
- * - **one form serves all three edits.** Adding, relabelling and replacing a
24
- * value differ only in which fields it shows, so they share a form rendered
25
- * as the row below the row they act on — for an add, the list's last row.
40
+ * - **one form serves all edits.** Adding, relabelling, replacing a value and
41
+ * editing a scope differ only in which fields the form shows, so they share
42
+ * one form rendered as the row below the row they act on — for an add, the
43
+ * list's last row.
26
44
  *
27
45
  * @module dsh-model-think-level/client/KeyManager
28
46
  */
@@ -38,6 +56,14 @@ export interface KeyManagerProps {
38
56
  readonly t: Translate;
39
57
  /** Transport; injectable for tests. */
40
58
  readonly client?: KeyManagerClient | undefined;
59
+ /**
60
+ * Draft mode — the create-provider card's list over an in-memory store
61
+ * instead of the host's. Rows read as "saved on create" rather than probed,
62
+ * the model-scope action is gone (the provider has no models to pick from
63
+ * before it exists), and every protocol is offered (the address a pin rides
64
+ * is the card's own Base URL field, which no endpoint family reports yet).
65
+ */
66
+ readonly draft?: boolean | undefined;
41
67
  }
42
68
  /**
43
69
  * Render the key list for one provider route.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The protocol menu a key's picker opens.
3
+ *
4
+ * A native `<select>` was the first shape of this control, but the OS draws its
5
+ * list and no page can put an explanation beside an option — and these options
6
+ * are not self-describing: "Chat Completions" and "Responses" are the same
7
+ * provider's two wires, and which one a key should use is a question about the
8
+ * models behind it, not about the acronym. The menu therefore renders its own
9
+ * list: one row per protocol, the protocol's name, and the line that says what
10
+ * it is for. The row in force takes the accent tint and accent ink — and no
11
+ * tick: a tick makes the picked row wider than its neighbours, so the list would
12
+ * shift under the pointer at the very moment of the pick (选中只高亮,不加对勾).
13
+ *
14
+ * It is portalled onto `<body>`: the key list clips its own overflow, so a menu
15
+ * drawn inside the row would be cut off by the panel it belongs to. Fixed
16
+ * positioning against the trigger's rect keeps it attached while the settings
17
+ * page scrolls, and it closes on an outside press, on Escape, and on a pick.
18
+ *
19
+ * @module dsh-model-think-level/client/ProtocolMenu
20
+ */
21
+ import type { ReactNode } from 'react';
22
+ /** One choice: the protocol's stored value, its name, and what it is for. */
23
+ export interface ProtocolOption {
24
+ /** The value written to the key index ('' = follow the provider's own). */
25
+ readonly value: string;
26
+ /** The protocol's name, as the row reads it. */
27
+ readonly title: string;
28
+ /** One line saying what the protocol is for. */
29
+ readonly hint: string;
30
+ }
31
+ /** Props of {@link ProtocolMenu}. */
32
+ export interface ProtocolMenuProps {
33
+ /** The trigger the menu hangs off. */
34
+ readonly anchor: HTMLElement;
35
+ /** The menu's own heading. */
36
+ readonly label: string;
37
+ /** The choices, in order; the pinned one keeps its own seat (see offeredProtocols). */
38
+ readonly options: readonly ProtocolOption[];
39
+ /** The value currently in force ('' for the provider's own protocol). */
40
+ readonly selected: string;
41
+ /** Called with the picked value; the menu closes itself afterwards. */
42
+ readonly onPick: (value: string) => void;
43
+ /** Called when the menu wants to close without a pick. */
44
+ readonly onClose: () => void;
45
+ }
46
+ /**
47
+ * Render the protocol menu for one key row.
48
+ * @param props - see {@link ProtocolMenuProps}.
49
+ * @returns the menu, portalled onto `<body>`.
50
+ */
51
+ export declare function ProtocolMenu(props: ProtocolMenuProps): ReactNode;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Capacity fields: the two token counts the official model row calls
3
+ * "context window" and "max output".
4
+ *
5
+ * The official inputs accept plain digits, but users write `1M` and `128K` —
6
+ * the catalogue itself shows those spellings — so one parser owns both the
7
+ * user's shorthand and the grouped digit string the form holds. The display
8
+ * side always groups the plain number: the value that reaches the official
9
+ * form is `1048576`, not `1M`, because that form's own parser only knows
10
+ * digits and its Save is what persists.
11
+ *
12
+ * @module dsh-model-think-level/client/capacity
13
+ */
14
+ /**
15
+ * Parse a capacity field into a token count.
16
+ *
17
+ * Accepts thousands separators and a `K`/`M` suffix (case-insensitive), with
18
+ * or without spaces, e.g. `1M`, `128 K`, `1,048,576`. A blank or malformed
19
+ * value is `undefined`: the caller writes an empty official field, which is
20
+ * how a capacity goes back to inheriting the catalogue value.
21
+ * @param text - the field's text as typed.
22
+ * @returns the token count, or undefined when the text is blank/invalid.
23
+ */
24
+ export declare function parseCapacity(text: string): number | undefined;
25
+ /**
26
+ * A capacity count as the field shows it when it is not being typed into.
27
+ * @param value - the token count, or undefined for a blank field.
28
+ * @returns the grouped digits, or an empty string.
29
+ */
30
+ export declare function capacityText(value: number | undefined): string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The one document-level event the browser half uses to keep its two separate
3
+ * React roots in step.
4
+ *
5
+ * The provider card and the key list are mounted independently: the card owns the
6
+ * two base URLs (`endpoints`) of a route, and the key list decides which protocols
7
+ * a key may pin from those very addresses. Neither can call the other, so the card
8
+ * says what changed and the list re-reads.
9
+ *
10
+ * A plain string, so the host half can import it too without pulling in DOM code.
11
+ *
12
+ * @module dsh-model-think-level/client/events
13
+ */
14
+ /** Fired on `document` when a route's two base URLs changed. */
15
+ export declare const ENDPOINTS_CHANGED_EVENT = "bre:endpoints-changed";
16
+ /** What {@link ENDPOINTS_CHANGED_EVENT} carries. */
17
+ export interface EndpointsChangedDetail {
18
+ /** The route whose addresses moved. */
19
+ readonly route: string;
20
+ /** Its OpenAI-family base URL, '' when unset. */
21
+ readonly openai: string;
22
+ /** Its Anthropic-family base URL, '' when unset. */
23
+ readonly anthropic: string;
24
+ /** Its Gemini-family base URL, '' when unset (absent from older events). */
25
+ readonly gemini?: string;
26
+ }
@@ -0,0 +1,81 @@
1
+ import type { FingerprintRecord } from '../fingerprint/verdict.js';
2
+ /**
3
+ * 银行摘要,**结构声明**:`fingerprint/bank.ts` 是 Node-only(它自己读
4
+ * `assets/unified_bank.json`),浏览器不能 import 它。所以这里只声明前端
5
+ * 真正读的两个字段,宿主以后加字段也不会打断激活 —— 与 `SlotRegistrarFace`
6
+ * 同一个理由。
7
+ */
8
+ export interface FingerprintBankView {
9
+ /** 银行的构建时间戳;换银行 = 所有落盘结论作废。 */
10
+ builtAt?: string;
11
+ /** 建议的题数,写在按钮旁边当成本说明。 */
12
+ recommendedQueries?: number;
13
+ }
14
+ /** GET 的应答体。 */
15
+ export interface FingerprintSnapshot {
16
+ bank: FingerprintBankView;
17
+ records: FingerprintRecord[];
18
+ }
19
+ /** 一行流式应答。顺序是 `progress`×N 然后 `result` 或 `error`。 */
20
+ export type FingerprintLine = {
21
+ type: 'progress';
22
+ index: number;
23
+ ok: boolean;
24
+ error?: string;
25
+ } | {
26
+ type: 'result';
27
+ record: FingerprintRecord;
28
+ } | {
29
+ type: 'error';
30
+ error: string;
31
+ };
32
+ /** 一次检测的答案:要么是落盘的那条记录,要么是一句面向用户的原因。 */
33
+ export type FingerprintRunAnswer = {
34
+ ok: true;
35
+ record: FingerprintRecord;
36
+ } | {
37
+ ok: false;
38
+ error: string;
39
+ };
40
+ /** 一次进行中的检测:可中止,且一定会 settle。 */
41
+ export interface FingerprintRun {
42
+ done: Promise<FingerprintRunAnswer>;
43
+ abort(): void;
44
+ }
45
+ /** 传输层的失败:不是"模型没测出来",是"这一次根本没跑成"。 */
46
+ export type TransportAnswer<T> = {
47
+ ok: true;
48
+ data: T;
49
+ } | {
50
+ ok: false;
51
+ error: string;
52
+ };
53
+ /**
54
+ * 取某供应商已落盘的检测结论。
55
+ * @param route - 供应商的设置键。
56
+ * @returns 银行摘要 + 该供应商的记录;传输失败是一句原因。
57
+ */
58
+ export declare function readFingerprints(route: string): Promise<TransportAnswer<FingerprintSnapshot>>;
59
+ /**
60
+ * 忘掉一个模型的检测结论。忘掉就是忘掉 —— 不留"上次测过"的痕迹,下次显示
61
+ * 回 `未检测`。
62
+ * @param route - 供应商的设置键。
63
+ * @param model - 模型 id。
64
+ */
65
+ export declare function forgetFingerprint(route: string, model: string): Promise<TransportAnswer<undefined>>;
66
+ /**
67
+ * 跑一个模型的三题,流式收进度。
68
+ *
69
+ * 应答是 NDJSON:每题一行 `progress`,末尾一行 `result` 或 `error`。**解析
70
+ * 容忍整个响应一次性到达**(有的代理会缓冲),所以按换行切而不是按到达次序
71
+ * 猜;丢行也不会卡死,`done` 一定会 settle。
72
+ *
73
+ * 调用方 abort 是"不要这个结论了",不是"回滚":已经跑完的题不重跑,已经
74
+ * 落盘的结论不撤 —— 落盘是宿主在 `result` 行之前做的。
75
+ *
76
+ * @param route - 供应商的设置键。
77
+ * @param model - 模型 id。
78
+ * @param onLine - 每收到一行调一次;`result` 那行也走这里,方便面板统一记账。
79
+ * @returns 可中止的句柄。
80
+ */
81
+ export declare function runFingerprint(route: string, model: string, onLine: (line: FingerprintLine) => void): FingerprintRun;
@@ -0,0 +1,61 @@
1
+ import type { FingerprintRecord } from '../fingerprint/verdict.js';
2
+ import { readFingerprints, type FingerprintLine } from './fingerprint-client.js';
3
+ /** 一个面板订阅到的、可安全渲染的快照(引用稳定,改了才换)。 */
4
+ export interface FingerprintRunnerState {
5
+ /** 正在跑的模型 → 已完成的题数。 */
6
+ readonly running: ReadonlyMap<string, number>;
7
+ /** 排队中的模型,按顺序。 */
8
+ readonly queued: readonly string[];
9
+ }
10
+ export interface FingerprintRunner {
11
+ /** 当前快照。 */
12
+ getState(): FingerprintRunnerState;
13
+ /** 订阅状态变化;返回退订函数。 */
14
+ subscribe(listener: () => void): () => void;
15
+ /** 订阅"某个模型的结论落盘了";返回退订函数。 */
16
+ onRecord(listener: (record: FingerprintRecord) => void): () => void;
17
+ /**
18
+ * 订阅"这次检测根本没跑成"(500、断网、流断在半路)。与落盘的 `failed`
19
+ * 记录不同:那不是模型的结论,是一次没有结论的尝试,面板要把它说出来,
20
+ * 否则按钮转一圈就复位,用户看不出有没有真的测过。
21
+ */
22
+ onFailure(listener: (model: string, error: string) => void): () => void;
23
+ /** 排队一个模型。已经在跑或已排队就什么都不做。 */
24
+ check(model: string): void;
25
+ /** 按顺序排队一批模型。 */
26
+ checkAll(models: readonly string[]): void;
27
+ /** 没有等待的或正在跑的检测。 */
28
+ idle(): boolean;
29
+ /** 中止整批:清队列、掐正在跑的。已落盘的不撤。 */
30
+ abort(): void;
31
+ /** 供应商被删掉 / 页面要走了:停干净并把自己忘掉。 */
32
+ dispose(): void;
33
+ }
34
+ /** 面板挂上来的传输缝,方便测试换成假的。 */
35
+ export interface FingerprintSender {
36
+ run(route: string, model: string, onLine: (line: FingerprintLine) => void): {
37
+ done: Promise<{
38
+ ok: true;
39
+ record: FingerprintRecord;
40
+ } | {
41
+ ok: false;
42
+ error: string;
43
+ }>;
44
+ abort(): void;
45
+ };
46
+ }
47
+ /**
48
+ * 取(或建)一个供应商的后台检测器。同一路由永远同一个实例,所以页签来回
49
+ * 挂载不会把队列弄丢。
50
+ * @param route - 供应商的设置键。
51
+ */
52
+ export declare function fingerprintRunner(route: string): FingerprintRunner;
53
+ /**
54
+ * 测试接缝:给一条路由换上传输实现。传 undefined 恢复真实传输。
55
+ * @param route - 供应商的设置键。
56
+ * @param sender - 假的传输。
57
+ */
58
+ export declare function setFingerprintSender(route: string, sender: FingerprintSender | undefined): void;
59
+ /** 页面要走了:把所有还在跑的掐掉。已落盘的不撤。 */
60
+ export declare function teardownFingerprintRunners(): void;
61
+ export { readFingerprints };
@@ -42,6 +42,12 @@
42
42
  */
43
43
  import type { ClientContext } from './types.js';
44
44
  import { STORE_NS } from '../constants.js';
45
+ /**
46
+ * Floor between two pushed-invalidation refreshes. The host's document
47
+ * notifications are its own, and some of them are echoes of work this plugin
48
+ * just did; without a floor the echo never lets the page settle.
49
+ */
50
+ export declare const REFRESH_MIN_INTERVAL_MS = 200;
45
51
  import { type BreKey } from './locales.ts';
46
52
  /** Stable plugin id, matching the cordis.patch.yml row and the bundle id. */
47
53
  export declare const name = "dsh-model-think-level";
@@ -28,6 +28,7 @@ import type { ReactNode } from 'react';
28
28
  import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
29
29
  import { type ForeignMount } from './mount.js';
30
30
  import type { StagedHeadersState } from './staged-headers.js';
31
+ import type { StagedKeysState } from './staged-keys.js';
31
32
  import type { RemoteApi } from '../types.js';
32
33
  export interface AddCardDeps {
33
34
  /** The plugin's own translator, for the tab labels and the pane's copy. */
@@ -38,6 +39,9 @@ export interface AddCardDeps {
38
39
  routeIdLabels: () => readonly string[];
39
40
  /** The session's deferred-header ledger (see `staged-headers`). */
40
41
  staged: StagedHeadersState;
42
+ /** The session's deferred-key ledger (see `staged-keys`): the drafts the
43
+ * custom form's key list stages, waiting for the route this card declares. */
44
+ stagedKeys: StagedKeysState;
41
45
  /** The plugin's locale-refresh seam, so the pane's copy follows a language
42
46
  * switch exactly as the seats the official slot mounts do. */
43
47
  refreshed: (children: () => ReactNode) => ReactNode;
@@ -51,3 +51,18 @@ export interface CreateCardPaneProps {
51
51
  }
52
52
  /** One create card's pane: its bar, and the headers pane once there is a route. */
53
53
  export declare function CreateCardPane({ host, api, t, routeIdLabels, staged }: CreateCardPaneProps): ReactNode;
54
+ /**
55
+ * The element whose typing can change the provider id: the panel this pane is
56
+ * mounted in, widened to the create card around it.
57
+ *
58
+ * The id field is the official form's, and which half of the card renders it is
59
+ * not something this pane may assume: the read is by label (never by position),
60
+ * so the card-wide scope can only ever find the SAME field the panel scope
61
+ * would — the difference is that it still finds it when the host puts that field
62
+ * outside the custom half. Shared with the create card's key-list pane, which
63
+ * needs the same live id for the same reason.
64
+ */
65
+ export declare function routeScopeOf(host: HTMLElement | null): HTMLElement | null;
66
+ /** The provider id the card's form currently holds, read by the official label.
67
+ * Shared with the create card's key-list pane. */
68
+ export declare function readRoute(host: HTMLElement | null, routeIdLabels: () => readonly string[]): string;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The create card's key-list seat: the official key field hands its input
3
+ * over to the plugin, and the DRAFT key list renders inline directly under it.
4
+ *
5
+ * The mirror of the edit card's seat (`injection/key-manager`), with two
6
+ * differences the create card forces. First, there is no route to key the
7
+ * list by — the id is being typed, and the drafts wait in the session ledger
8
+ * (`staged-keys`) for the route the card's own 保存 declares — so the list is
9
+ * the draft pane (`create-keys-pane`), not the host-backed one. Second, the
10
+ * official box keeps what the user typed into it: the create card is a FORM,
11
+ * and its own 保存 is what stores the provider's first key. The list below is
12
+ * for adding further keys, and lands once the route is declared.
13
+ *
14
+ * The field keeps the edit card's managed-field handover: `bre-key-managed`
15
+ * stands the official input down (the list below says the same thing once per
16
+ * key), the input stays in the DOM — the host's form still owns it — and
17
+ * unmanaging the field brings the official box back.
18
+ *
19
+ * @module dsh-model-think-level/client/injection/create-key-seat
20
+ */
21
+ import type { ReactNode } from 'react';
22
+ import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
23
+ import type { StagedKeysState } from './staged-keys.js';
24
+ import type { RemoteApi } from '../types.js';
25
+ /** What a reconcile tells the field's key list. */
26
+ export interface CreateKeySeatDeps {
27
+ /** Copy for the list and its failure boundary. */
28
+ readonly t: Translate;
29
+ /** The write seam, for the pane's route-baseline reads. */
30
+ readonly api: RemoteApi;
31
+ /** The official labels of the form's provider-id field, by locale. */
32
+ readonly routeIdLabels: () => readonly string[];
33
+ /** The session's deferred-key ledger. */
34
+ readonly staged: StagedKeysState;
35
+ /** The plugin's locale-refresh seam, so the list's copy follows a language
36
+ * switch exactly as the seats the official slot mounts do. */
37
+ readonly refreshed: (children: () => ReactNode) => ReactNode;
38
+ }
39
+ /**
40
+ * Mount the draft key list into a field, replacing whatever this module
41
+ * mounted there before. Idempotent: a field whose list is already up is left
42
+ * exactly as it is (only its region mirror is re-asserted, so a tab pass that
43
+ * tags the field after the fact brings the list into its pane too), and a
44
+ * field with no key input is handed to {@link resetCreateKeySeat}.
45
+ */
46
+ export declare function enhanceCreateKeySeat(field: HTMLElement, deps: CreateKeySeatDeps): void;
47
+ /**
48
+ * Drop the list of one field, leaving the official field exactly as the page
49
+ * rendered it: the managed-field mark goes, and the official input comes back.
50
+ */
51
+ export declare function resetCreateKeySeat(field: HTMLElement): void;
52
+ /** Drop every list this module mounted. */
53
+ export declare function teardownCreateKeySeats(): void;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The create-provider card's API-key list: the SAME card list the edit card
3
+ * runs ({@link KeyManager}), over a DRAFT store instead of the host's.
4
+ *
5
+ * The provider this list edits does not exist yet — the id the user is typing
6
+ * is declared by the card's own 保存 — so the host's key route would refuse
7
+ * every call. The list therefore runs on {@link createDraftKeyClient}, whose
8
+ * answers come from an in-memory store the seat seeds, and every change is
9
+ * filed with the session ledger (`staged-keys`) the moment there is a route to
10
+ * file it under. The ledger — not this pane — decides when those drafts may be
11
+ * written: the create landing is the only thing that may trigger the write,
12
+ * and it is also the proof the write is allowed.
13
+ *
14
+ * The route plumbing mirrors the card's 高级配置 pane (`create-card-pane`)
15
+ * exactly, because it solves the same problem against the same field: the id
16
+ * belongs to the official form's React state, so the DOM input event is the
17
+ * only notice this pane gets, the read is by label, and a retyped id MOVES the
18
+ * held list (the old key never comes back — the user is declaring the provider
19
+ * they ended up naming).
20
+ *
21
+ * @module dsh-model-think-level/client/injection/create-keys-pane
22
+ */
23
+ import type { ReactNode } from 'react';
24
+ import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
25
+ import type { RemoteApi } from '../types.js';
26
+ import { type DraftKeyStore, type StagedKeysState } from './staged-keys.js';
27
+ export interface CreateKeysPaneProps {
28
+ /** The plugin's seat right after the official key field; the id read and the
29
+ * input listener both resolve the card from it. */
30
+ host: {
31
+ readonly current: HTMLDivElement | null;
32
+ };
33
+ /** The working store the seat created (and seeded with a value the user had
34
+ * already typed into the official box, if there was one). */
35
+ store: DraftKeyStore;
36
+ /** The write seam, for the route-baseline reads. */
37
+ api: RemoteApi;
38
+ /** The plugin's translator. */
39
+ t: Translate;
40
+ /** The official labels of the form's provider-id field, by locale. */
41
+ routeIdLabels: () => readonly string[];
42
+ /** The session's deferred-key ledger. */
43
+ staged: StagedKeysState;
44
+ }
45
+ /** One create card's key list: the draft list itself, wired to the live id. */
46
+ export declare function CreateKeysPane({ host, store, api, t, routeIdLabels, staged }: CreateKeysPaneProps): ReactNode;
@@ -1,5 +1,6 @@
1
1
  /**
2
- * The provider editor's segmented control (供应商配置 / 模型配置 / 高级配置).
2
+ * The provider editor's segmented control
3
+ * (供应商配置 / 模型配置 / 指纹检测 / 高级配置).
3
4
  *
4
5
  * This is the bar the editor-tabs pass drives. It lives HERE, in the plugin's
5
6
  * own React subtree, rather than being built by the pass and inserted into the
@@ -46,7 +46,7 @@
46
46
  *
47
47
  * @module dsh-model-think-level/client/injection/editor-tabs
48
48
  */
49
- declare const TAB_IDS: readonly ["provider", "models", "advanced"];
49
+ declare const TAB_IDS: readonly ["provider", "models", "fingerprint", "advanced"];
50
50
  /** A tab id, as both the bar and the card attribute spell it. */
51
51
  export type EditorTabId = (typeof TAB_IDS)[number];
52
52
  /** The tab ids, in display order, for the tab-bar component. */
@@ -75,6 +75,16 @@ export declare function createEditorTabsState(): EditorTabsState;
75
75
  * other.
76
76
  */
77
77
  export declare function editorCardOf(element: Element | null): HTMLElement | null;
78
+ /**
79
+ * Whether the card a mount sits in is the one CREATING a provider.
80
+ *
81
+ * One rule for the two callers that need it — this pass (which refuses the
82
+ * fingerprint tab there) and the fingerprint pane (which refuses to render
83
+ * there at all). A card still choosing what to be must not offer to
84
+ * fingerprint what it is not yet, and the check is about the card, never about
85
+ * whether the draft happens to have an id typed in.
86
+ */
87
+ export declare function isCreateProviderCard(element: Element | null): boolean;
78
88
  /**
79
89
  * The part of a card that presents its editor.
80
90
  *