dsh-model-think-level 2.0.0 → 2.0.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/LICENSE +13 -0
- package/README.md +23 -13
- package/assets/NOTICE.md +15 -0
- package/assets/unified_bank.json +32910 -0
- package/lib/client/EffortEditor.d.ts +53 -21
- package/lib/client/FingerprintPane.d.ts +36 -0
- package/lib/client/capacity.d.ts +46 -0
- package/lib/client/configured-inputs.d.ts +11 -2
- package/lib/client/fingerprint-client.d.ts +81 -0
- package/lib/client/fingerprint-runner.d.ts +73 -0
- package/lib/client/index.d.ts +6 -0
- package/lib/client/injection/create-key-seat.d.ts +4 -5
- package/lib/client/injection/editor-tab-bar.d.ts +2 -1
- package/lib/client/injection/editor-tabs.d.ts +11 -1
- package/lib/client/injection/key-reveal.d.ts +12 -0
- package/lib/client/injection/models-page-editor.d.ts +117 -2
- package/lib/client/injection/provider-card-slot.d.ts +3 -1
- package/lib/client/key-manager-client.d.ts +2 -1
- package/lib/client/locales.d.ts +37 -9
- package/lib/client/ops.d.ts +15 -2
- package/lib/client/refresh-scheduler.d.ts +29 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/types.d.ts +26 -2
- package/lib/client.js +701 -225
- package/lib/client.js.map +4 -4
- package/lib/constants.d.ts +24 -0
- package/lib/detection.d.ts +7 -0
- package/lib/fingerprint/bank.d.ts +24 -0
- package/lib/fingerprint/challenges.d.ts +14 -0
- package/lib/fingerprint/core.d.ts +85 -0
- package/lib/fingerprint/eligibility.d.ts +8 -0
- package/lib/fingerprint/random.d.ts +4 -0
- package/lib/fingerprint/run.d.ts +128 -0
- package/lib/fingerprint/store.d.ts +31 -0
- package/lib/fingerprint/verdict.d.ts +90 -0
- package/lib/index.js +1212 -251
- package/lib/index.js.map +4 -4
- package/lib/key-probe.d.ts +13 -98
- package/lib/knowledge.d.ts +21 -0
- package/lib/multi-key-listing.d.ts +3 -3
- package/package.json +13 -5
|
@@ -5,15 +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
|
-
* The
|
|
9
|
-
* default X" state
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
8
|
+
* The shape is the design board's: one head line (the switch and the
|
|
9
|
+
* "declared N · default X" state) 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.
|
|
17
18
|
*/
|
|
18
19
|
import type { ReactNode } from 'react';
|
|
19
20
|
import type { CompatSuggestion, InputModalities, ReasoningEfforts } from '../knowledge.js';
|
|
@@ -54,6 +55,8 @@ export interface EffortEditorProps {
|
|
|
54
55
|
effortsUnset?: boolean;
|
|
55
56
|
/** The model's current input-modality declaration. */
|
|
56
57
|
input?: InputModalities;
|
|
58
|
+
/** Whether the model is declared an image generator (生图). */
|
|
59
|
+
imageGen?: boolean;
|
|
57
60
|
/** The model's stored compat block (passthrough; suggestions merge over it). */
|
|
58
61
|
compat?: CompatSuggestion;
|
|
59
62
|
/** The model's stored per-model default-effort pick, when one is set. */
|
|
@@ -68,13 +71,19 @@ export interface EffortEditorProps {
|
|
|
68
71
|
*/
|
|
69
72
|
staged?: boolean;
|
|
70
73
|
/**
|
|
71
|
-
* Whether the official Models page owns input types for this row
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* have no such control and keep the section.
|
|
74
|
+
* Whether the official Models page owns input types for this row. The
|
|
75
|
+
* injector now hides that official control and always shows this card's
|
|
76
|
+
* modality section, so the prop is kept only to document the old kernel
|
|
77
|
+
* split and is no longer read.
|
|
76
78
|
*/
|
|
77
79
|
officialInputTypes?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Report whether this card currently covers the official capacity and
|
|
82
|
+
* input-type chrome. The card exists only while the thinking switch is on;
|
|
83
|
+
* when it is off the row's own official controls have to come back, or a
|
|
84
|
+
* model that declares no reasoning would lose every way to edit its window.
|
|
85
|
+
*/
|
|
86
|
+
onCoverageChange?: (covered: boolean) => void;
|
|
78
87
|
/** The write seam (settings.mutate plus the suggestion engine). */
|
|
79
88
|
api: EffortEditorApi;
|
|
80
89
|
/** Read-only (settings document not writable). */
|
|
@@ -82,19 +91,42 @@ export interface EffortEditorProps {
|
|
|
82
91
|
/** Localized copy. */
|
|
83
92
|
t: (key: string, params?: Record<string, string | number>) => string;
|
|
84
93
|
}
|
|
85
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Draft state of the modality part. The three pills are mutually exclusive
|
|
96
|
+
* by construction: 生图 (`imageGen`) stands alone — an image generator is a
|
|
97
|
+
* different kind of model, not a request-modality answer — while the 文本/图片
|
|
98
|
+
* pair is the ordinary chat-input declaration (`declared`).
|
|
99
|
+
*/
|
|
86
100
|
export interface DraftModality {
|
|
101
|
+
/** The 文本/图片 declaration is made (text always, image when `image`). */
|
|
87
102
|
declared: boolean;
|
|
103
|
+
/** The declared pair takes images. Meaningful only while `declared`. */
|
|
88
104
|
image: boolean;
|
|
105
|
+
/** The row is an image generator; text/image carry no answer beside it. */
|
|
106
|
+
imageGen: boolean;
|
|
89
107
|
}
|
|
90
108
|
/** Read the stored declaration into a draft. Empty mirrors undefined: the
|
|
91
109
|
* resolved settings layer materializes absent arrays as [], and core reads
|
|
92
110
|
* that as "no answer here" -- never as a phantom text-only declaration. */
|
|
93
|
-
export declare function modalityFrom(input: InputModalities | undefined): DraftModality;
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
111
|
+
export declare function modalityFrom(input: InputModalities | undefined, imageGen?: boolean): DraftModality;
|
|
112
|
+
/**
|
|
113
|
+
* The modality part of a write, from a draft. The parts are exact: a declared
|
|
114
|
+
* pair also clears the image-generation marker, and marking the row an image
|
|
115
|
+
* generator also unsets the chat-input declaration (its `null` — the durable
|
|
116
|
+
* unset — which is what keeps host auto-fill from refilling text/image under a
|
|
117
|
+
* model that cannot serve a chat turn). `undefined` members mean "touch
|
|
118
|
+
* nothing", which {@link sameModality} is what decides.
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildModalityWrite(draft: DraftModality): {
|
|
121
|
+
input?: InputModalities | null;
|
|
122
|
+
imageGen?: boolean;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Semantic equality between a modality draft and the row's stored state: the
|
|
126
|
+
* declaration AND the image-generation marker must both agree, or the draft is
|
|
127
|
+
* an edit.
|
|
128
|
+
*/
|
|
129
|
+
export declare function sameModality(draft: DraftModality, stored: InputModalities | undefined, storedImageGen?: boolean): boolean;
|
|
98
130
|
/**
|
|
99
131
|
* The ladder part of a write, from a switch state and the draft it resolves to.
|
|
100
132
|
*
|
|
@@ -126,5 +158,5 @@ export declare function pendingWriteOf(parts: PendingWriteParts): PendingWrite;
|
|
|
126
158
|
* checkboxes, the modality toggle, the auto-adapt action, and the
|
|
127
159
|
* apply/reset actions that own both sections.
|
|
128
160
|
*/
|
|
129
|
-
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;
|
|
161
|
+
export declare function EffortEditor({ route, routeApi, routeBaseURL, modelId, modelName, efforts: initialEfforts, effortsUnset, input: initialInput, imageGen: initialImageGen, compat: initialCompat, defaultEffort: initialDefaultEffort, index, staged, officialInputTypes, onCoverageChange, api, readOnly, t }: EffortEditorProps): ReactNode;
|
|
130
162
|
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;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
* A second formatter spells a count the way switchers and catalogues do —
|
|
13
|
+
* `200K`, `1M`, `1B` — for the model menu's capacity tag.
|
|
14
|
+
*
|
|
15
|
+
* @module dsh-model-think-level/client/capacity
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Parse a capacity field into a token count.
|
|
19
|
+
*
|
|
20
|
+
* Accepts thousands separators and a `K`/`M`/`B`/`T` suffix (case-insensitive),
|
|
21
|
+
* with or without spaces, e.g. `1M`, `128 K`, `2B`, `1,048,576`. A blank or
|
|
22
|
+
* malformed value is `undefined`: the caller writes an empty official field,
|
|
23
|
+
* which is how a capacity goes back to inheriting the catalogue value.
|
|
24
|
+
* @param text - the field's text as typed.
|
|
25
|
+
* @returns the token count, or undefined when the text is blank/invalid.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseCapacity(text: string): number | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* A capacity count as the field shows it when it is not being typed into.
|
|
30
|
+
* @param value - the token count, or undefined for a blank field.
|
|
31
|
+
* @returns the grouped digits, or an empty string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function capacityText(value: number | undefined): string;
|
|
34
|
+
/**
|
|
35
|
+
* A capacity count as a switcher tag spells it — `200K`, `1M`, `1B` — the way
|
|
36
|
+
* the model catalogues themselves write these numbers.
|
|
37
|
+
*
|
|
38
|
+
* The unit is picked by the value's decimal scale (catalogue numbers are
|
|
39
|
+
* decimal), then the spelling tries the binary units first — `131072` is
|
|
40
|
+
* `128K`, `1048576` is `1M` — before the decimal ones (`272000` is `272K`).
|
|
41
|
+
* A value neither family divides falls back to one binary decimal (`1536` →
|
|
42
|
+
* `1.5K`). Below a thousand the plain digits show.
|
|
43
|
+
* @param value - the token count, or undefined for "nothing declared".
|
|
44
|
+
* @returns the compact spelling, or an empty string.
|
|
45
|
+
*/
|
|
46
|
+
export declare function capacityShort(value: number | undefined): string;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { RemoteApi } from './types.js';
|
|
2
|
-
|
|
2
|
+
/** What the document says about one model, as the composer surfaces consume it. */
|
|
3
|
+
export interface ModelFacts {
|
|
4
|
+
/** The saved input-modality declaration, when the model declares one. */
|
|
5
|
+
input?: readonly string[];
|
|
6
|
+
/** Whether the model is declared an image generator (生图). */
|
|
7
|
+
imageGen?: boolean;
|
|
8
|
+
/** The declared context window, when the model carries one. */
|
|
9
|
+
contextWindow?: number;
|
|
10
|
+
}
|
|
11
|
+
export type ConfiguredInputSnapshot = ReadonlyMap<string, ReadonlyMap<string, ModelFacts>>;
|
|
3
12
|
/** Stable empty snapshot for a composer mounted without a settings reader. */
|
|
4
13
|
export declare const EMPTY_CONFIGURED_INPUTS: ConfiguredInputSnapshot;
|
|
5
|
-
/** Saved model
|
|
14
|
+
/** Saved model facts, shared by composer mounts and refreshed on settings pushes. */
|
|
6
15
|
export interface ConfiguredInputs {
|
|
7
16
|
getSnapshot(): ConfiguredInputSnapshot;
|
|
8
17
|
subscribe(listener: () => void): () => void;
|
|
@@ -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,73 @@
|
|
|
1
|
+
import type { FingerprintRecord } from '../fingerprint/verdict.js';
|
|
2
|
+
import { readFingerprints, type FingerprintLine } from './fingerprint-client.js';
|
|
3
|
+
/** 默认同时检测几个模型。 */
|
|
4
|
+
export declare const DEFAULT_FINGERPRINT_CONCURRENCY = 2;
|
|
5
|
+
/** 命中限流后的退避时长。 */
|
|
6
|
+
export declare const RATE_LIMIT_BACKOFF_MS = 15000;
|
|
7
|
+
/** Runner 的可调参数;测试用它注入假时钟与假并发。 */
|
|
8
|
+
export interface FingerprintRunnerOptions {
|
|
9
|
+
/** 同时检测的模型数上限,默认 {@link DEFAULT_FINGERPRINT_CONCURRENCY}。 */
|
|
10
|
+
concurrency?: number;
|
|
11
|
+
/** 限流退避时长,默认 {@link RATE_LIMIT_BACKOFF_MS}。 */
|
|
12
|
+
backoffMs?: number;
|
|
13
|
+
}
|
|
14
|
+
/** 一个面板订阅到的、可安全渲染的快照(引用稳定,改了才换)。 */
|
|
15
|
+
export interface FingerprintRunnerState {
|
|
16
|
+
/** 正在跑的模型 → 已完成的题数。 */
|
|
17
|
+
readonly running: ReadonlyMap<string, number>;
|
|
18
|
+
/** 排队中的模型,按顺序。 */
|
|
19
|
+
readonly queued: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface FingerprintRunner {
|
|
22
|
+
/** 当前快照。 */
|
|
23
|
+
getState(): FingerprintRunnerState;
|
|
24
|
+
/** 订阅状态变化;返回退订函数。 */
|
|
25
|
+
subscribe(listener: () => void): () => void;
|
|
26
|
+
/** 订阅"某个模型的结论落盘了";返回退订函数。 */
|
|
27
|
+
onRecord(listener: (record: FingerprintRecord) => void): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* 订阅"这次检测根本没跑成"(500、断网、流断在半路)。与落盘的 `failed`
|
|
30
|
+
* 记录不同:那不是模型的结论,是一次没有结论的尝试,面板要把它说出来,
|
|
31
|
+
* 否则按钮转一圈就复位,用户看不出有没有真的测过。
|
|
32
|
+
*/
|
|
33
|
+
onFailure(listener: (model: string, error: string) => void): () => void;
|
|
34
|
+
/** 排队一个模型。已经在跑或已排队就什么都不做。 */
|
|
35
|
+
check(model: string): void;
|
|
36
|
+
/** 按顺序排队一批模型。 */
|
|
37
|
+
checkAll(models: readonly string[]): void;
|
|
38
|
+
/** 没有等待的或正在跑的检测。 */
|
|
39
|
+
idle(): boolean;
|
|
40
|
+
/** 中止整批:清队列、掐正在跑的。已落盘的不撤。 */
|
|
41
|
+
abort(): void;
|
|
42
|
+
/** 供应商被删掉 / 页面要走了:停干净并把自己忘掉。 */
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
/** 面板挂上来的传输缝,方便测试换成假的。 */
|
|
46
|
+
export interface FingerprintSender {
|
|
47
|
+
run(route: string, model: string, onLine: (line: FingerprintLine) => void): {
|
|
48
|
+
done: Promise<{
|
|
49
|
+
ok: true;
|
|
50
|
+
record: FingerprintRecord;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
error: string;
|
|
54
|
+
}>;
|
|
55
|
+
abort(): void;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 取(或建)一个供应商的后台检测器。同一路由永远同一个实例,所以页签来回
|
|
60
|
+
* 挂载不会把队列弄丢。
|
|
61
|
+
* @param route - 供应商的设置键。
|
|
62
|
+
* @param options - 并发与退避的可调参数;只在实例首次创建时生效。
|
|
63
|
+
*/
|
|
64
|
+
export declare function fingerprintRunner(route: string, options?: FingerprintRunnerOptions): FingerprintRunner;
|
|
65
|
+
/**
|
|
66
|
+
* 测试接缝:给一条路由换上传输实现。传 undefined 恢复真实传输。
|
|
67
|
+
* @param route - 供应商的设置键。
|
|
68
|
+
* @param sender - 假的传输。
|
|
69
|
+
*/
|
|
70
|
+
export declare function setFingerprintSender(route: string, sender: FingerprintSender | undefined): void;
|
|
71
|
+
/** 页面要走了:把所有还在跑的掐掉。已落盘的不撤。 */
|
|
72
|
+
export declare function teardownFingerprintRunners(): void;
|
|
73
|
+
export { readFingerprints };
|
package/lib/client/index.d.ts
CHANGED
|
@@ -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";
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* differences the create card forces. First, there is no route to key the
|
|
7
7
|
* list by — the id is being typed, and the drafts wait in the session ledger
|
|
8
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,
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* draft row it becomes.
|
|
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.
|
|
14
13
|
*
|
|
15
14
|
* The field keeps the edit card's managed-field handover: `bre-key-managed`
|
|
16
15
|
* stands the official input down (the list below says the same thing once per
|
|
@@ -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
|
*
|
|
@@ -69,6 +69,18 @@ export interface KeyRevealDeps {
|
|
|
69
69
|
* how a takeover that has moved on (a provider whose key field is gone) drops
|
|
70
70
|
* the affordance it no longer needs.
|
|
71
71
|
*/
|
|
72
|
+
/**
|
|
73
|
+
* Mark a field's key input without giving it an eye.
|
|
74
|
+
*
|
|
75
|
+
* The official page already draws its own reveal button INSIDE the API-key box
|
|
76
|
+
* (`position: absolute; inset: 1px 1px 1px auto`) whenever the box holds text,
|
|
77
|
+
* so on the add-provider form — where there is no stored credential for an eye
|
|
78
|
+
* to fetch anyway — a second button hanging under the field was pure redundancy
|
|
79
|
+
* drawn twice (user item 9). The mark is still worth making: it is what keeps
|
|
80
|
+
* the input findable after the official toggle unmasks it, so the key list below
|
|
81
|
+
* survives the click.
|
|
82
|
+
*/
|
|
83
|
+
export declare function markKeyField(field: HTMLElement): void;
|
|
72
84
|
export declare function revealKeyField(field: HTMLElement, deps: KeyRevealDeps): void;
|
|
73
85
|
/** Undo {@link revealKeyField}: drop the button, the class, the marker, and
|
|
74
86
|
* re-mask the input, leaving the official field exactly as it was rendered. */
|
|
@@ -96,6 +96,14 @@ export interface HostLabels {
|
|
|
96
96
|
contextWindow: readonly string[];
|
|
97
97
|
/** The disclosure's max-output input ("Max output" / "最大输出"). */
|
|
98
98
|
maxOutput: readonly string[];
|
|
99
|
+
/**
|
|
100
|
+
* The model list's add button ("Add model" / "添加模型"). Clicking it appends
|
|
101
|
+
* a row and focuses its first input, and the browser's own scroll into view
|
|
102
|
+
* (plus the anchoring around the growth) is what made the whole card appear
|
|
103
|
+
* to squeeze upward — the capture-phase pin wired on it answers that (see
|
|
104
|
+
* {@link wireAddModelRepin}).
|
|
105
|
+
*/
|
|
106
|
+
addModel: readonly string[];
|
|
99
107
|
}
|
|
100
108
|
/** The join the injector renders from. */
|
|
101
109
|
export interface InjectorDeps {
|
|
@@ -159,6 +167,8 @@ export interface EditorMountProps {
|
|
|
159
167
|
effortsUnset?: boolean;
|
|
160
168
|
/** The model's current input-modality declaration. */
|
|
161
169
|
input?: InputModalities;
|
|
170
|
+
/** Whether the model is declared an image generator (生图). */
|
|
171
|
+
imageGen?: boolean;
|
|
162
172
|
/** The model's stored compat block (passthrough; the editor merges suggestions over it). */
|
|
163
173
|
compat?: CompatSuggestion;
|
|
164
174
|
/** The model's stored per-model default-effort pick, when one is set. */
|
|
@@ -176,6 +186,10 @@ export interface EditorMountProps {
|
|
|
176
186
|
* DOM, never a kernel version.
|
|
177
187
|
*/
|
|
178
188
|
officialInputTypes?: boolean;
|
|
189
|
+
/** The card reports whether it still covers the official capacity and
|
|
190
|
+
* input-type fields: it does while its thinking switch is on, and steps
|
|
191
|
+
* aside when the switch turns the card off. */
|
|
192
|
+
onCoverageChange?: (covered: boolean) => void;
|
|
179
193
|
api: EffortEditorApi;
|
|
180
194
|
readOnly: boolean;
|
|
181
195
|
t: (key: string, params?: Record<string, string | number>) => string;
|
|
@@ -264,6 +278,8 @@ export interface ScanState {
|
|
|
264
278
|
disclosureWired: WeakSet<Element>;
|
|
265
279
|
/** Provider-row Edit buttons already wired for the top re-pin. */
|
|
266
280
|
editWired: WeakSet<Element>;
|
|
281
|
+
/** The model lists' add-model buttons already wired for the top re-pin. */
|
|
282
|
+
addModelWired: WeakSet<Element>;
|
|
267
283
|
}
|
|
268
284
|
/**
|
|
269
285
|
* One staged declaration: the level set plus the suggestion's compat block and
|
|
@@ -281,6 +297,11 @@ export interface StagedDeclaration {
|
|
|
281
297
|
efforts: Exclude<EffortWriteIntent, undefined>;
|
|
282
298
|
compat?: CompatSuggestion;
|
|
283
299
|
input?: InputModalities;
|
|
300
|
+
/**
|
|
301
|
+
* The image-generation part, when the staging carried one: true marks the
|
|
302
|
+
* row 生图, false clears the marker. Undefined touches nothing.
|
|
303
|
+
*/
|
|
304
|
+
imageGen?: boolean;
|
|
284
305
|
defaultEffort?: string | null;
|
|
285
306
|
}
|
|
286
307
|
/**
|
|
@@ -313,7 +334,12 @@ export declare function stageEffortsInto(state: ScanState, route: string, modelI
|
|
|
313
334
|
* declaration" on an unsaved route) and stores as such: the staged flush
|
|
314
335
|
* reads it back verbatim, exactly like the saved-row seam does.
|
|
315
336
|
*/
|
|
316
|
-
input?: InputModalities | null, defaultEffort?: string | null
|
|
337
|
+
input?: InputModalities | null, defaultEffort?: string | null,
|
|
338
|
+
/**
|
|
339
|
+
* The image-generation part as the write carried it: true marks the row 生图,
|
|
340
|
+
* false or null clears the marker, undefined touches nothing.
|
|
341
|
+
*/
|
|
342
|
+
imageGen?: boolean | null): void;
|
|
317
343
|
/**
|
|
318
344
|
* Record (or replace) the write an on-screen editor asked for while the
|
|
319
345
|
* official card held the document. The latest intent for a row wins: the user
|
|
@@ -386,6 +412,8 @@ export interface EffectiveStagedIntents {
|
|
|
386
412
|
efforts: EffortWriteIntent;
|
|
387
413
|
compat?: CompatSuggestion;
|
|
388
414
|
input?: InputModalities;
|
|
415
|
+
/** The staged image-generation intent, when it is a change. */
|
|
416
|
+
imageGen?: boolean;
|
|
389
417
|
/** The staged default-effort pick, when the staging carried one. */
|
|
390
418
|
defaultEffort?: string | null;
|
|
391
419
|
}
|
|
@@ -446,7 +474,18 @@ export declare function hideOfficialReasoning(container: HTMLElement): void;
|
|
|
446
474
|
*/
|
|
447
475
|
export declare function showOfficialReasoning(container: HTMLElement): void;
|
|
448
476
|
/**
|
|
449
|
-
*
|
|
477
|
+
* Stand the official context-window / max-output labels and the input-types
|
|
478
|
+
* fieldset down for a row whose editor renders those same decisions.
|
|
479
|
+
*
|
|
480
|
+
* Only DIRECT children of the disclosure are touched: the editor's own inputs
|
|
481
|
+
* (and its own modality pills) live inside `.bre-effort-slot`, which carries
|
|
482
|
+
* neither class stem. The marker attribute distinguishes this hide from one the
|
|
483
|
+
* host wrote itself, exactly like {@link hideOfficialReasoning}.
|
|
484
|
+
*/
|
|
485
|
+
export declare function hideOfficialCapacityChrome(container: HTMLElement): void;
|
|
486
|
+
/** Hand the official capacity/input-type chrome back when the editor goes. */
|
|
487
|
+
export declare function showOfficialCapacityChrome(container: HTMLElement): void;
|
|
488
|
+
/** The official input-types checkbox an image verdict belongs to, or undefined
|
|
450
489
|
* when this row ships no such control (a legacy kernel) — or ships one whose
|
|
451
490
|
* boxes cannot be told apart.
|
|
452
491
|
*
|
|
@@ -617,6 +656,72 @@ export interface ScreenModel {
|
|
|
617
656
|
export declare function adaptEveryModel(state: ScanState, deps: InjectorDeps, route: string, visibleRows?: readonly ScreenModel[]): Promise<AutoAdaptReport>;
|
|
618
657
|
/** Restore anchoring and remove every live re-pin window's frame and listeners. */
|
|
619
658
|
export declare function releaseModelListRepins(): void;
|
|
659
|
+
/**
|
|
660
|
+
* Hold one card's viewport position while its content changes height.
|
|
661
|
+
*
|
|
662
|
+
* Growing a card below the header makes the browser's scroll anchoring keep a
|
|
663
|
+
* node near the GROWING part visually stable, which walks the card's header —
|
|
664
|
+
* and everything above it — up the viewport. Suppressing anchoring for the
|
|
665
|
+
* duration and re-pinning the card's top every frame turns that into the card
|
|
666
|
+
* growing DOWNWARD instead.
|
|
667
|
+
*
|
|
668
|
+
* The card does not reach its final height at once, which is what a
|
|
669
|
+
* stability-bounded loop got wrong: the official React commit renders the
|
|
670
|
+
* disclosure container on the click, and this plugin's editor mounts a
|
|
671
|
+
* debounced scan later through an async render. Measured on the live page with
|
|
672
|
+
* the settings list scrolled to its end, the first change lands in the click's
|
|
673
|
+
* own frame and the second ~100ms later: a loop that stopped three stable
|
|
674
|
+
* frames after the click (~50ms) had already handed anchoring back, and the
|
|
675
|
+
* second change then walked the card 587px up the viewport.
|
|
676
|
+
*
|
|
677
|
+
* So the window is TIME-bounded, and a window that is still watching the card
|
|
678
|
+
* grow is pushed out to {@link REPIN_QUIET_MS} past the last change it saw — it
|
|
679
|
+
* releases when the growth STOPS, not when a fixed guess says it should have.
|
|
680
|
+
* {@link REPIN_MAX_MS} bounds that.
|
|
681
|
+
*
|
|
682
|
+
* The window stands down early on two conditions, both of which mean the
|
|
683
|
+
* measurement it is working from is no longer valid: the USER scrolled (their
|
|
684
|
+
* scroll must not be fought), or the card left the document (React replaced
|
|
685
|
+
* it — a detached box measures 0, and correcting against that would throw the
|
|
686
|
+
* view somewhere arbitrary).
|
|
687
|
+
*
|
|
688
|
+
* "The user scrolled" is read from their INPUT — a wheel, a touch, a pointer
|
|
689
|
+
* press or a scrolling key — and NOT from the scroll offset, which is the one
|
|
690
|
+
* thing the page itself also moves: the browser clamps it when a card above
|
|
691
|
+
* collapses, and this loop moves it on purpose. Watching the offset called
|
|
692
|
+
* every one of those a user scroll and abandoned the pin, which is exactly
|
|
693
|
+
* what opening a provider card needs: one official editor at a time means the
|
|
694
|
+
* card that was open closes in the same commit, the content above the clicked
|
|
695
|
+
* row shrinks by the closing editor's height, and the row has to be held where
|
|
696
|
+
* the user left it rather than walk off the top of the view.
|
|
697
|
+
*
|
|
698
|
+
* The correction itself adds the delta to the offset because the offset and the
|
|
699
|
+
* viewport are inverse: a card that has moved DOWN the screen (a positive
|
|
700
|
+
* delta) is brought back by scrolling DOWN the document, and one that has moved
|
|
701
|
+
* up by scrolling up. Subtracting it — as this did while the suppression was
|
|
702
|
+
* doing all the work and the delta was always 0 — drives the card the wrong way
|
|
703
|
+
* whenever the page really did move it.
|
|
704
|
+
*/
|
|
705
|
+
/**
|
|
706
|
+
* Let a growing card keep its place on screen without the browser buying the
|
|
707
|
+
* growth back.
|
|
708
|
+
*
|
|
709
|
+
* User item 1: opening 添加供应商 makes three things taller at once — the
|
|
710
|
+
* official page opens the first provider's editor above the new card, the
|
|
711
|
+
* create-card pass adds the tab bar, and the card's own key list lands a moment
|
|
712
|
+
* later. Scroll anchoring answers any of those by scrolling the page by the
|
|
713
|
+
* height that grew, which reads as the new card jumping and shoving the
|
|
714
|
+
* configured provider above it upward. Anchoring is switched off for a short
|
|
715
|
+
* window instead: no scroll write of ours, no compensation by the browser, and
|
|
716
|
+
* the card simply extends downward.
|
|
717
|
+
*
|
|
718
|
+
* Unlike {@link pinCardTop} this never writes a scroll offset — it only stops
|
|
719
|
+
* the browser from writing one — so it cannot fight a pin that is already
|
|
720
|
+
* running, and it releases itself on the same deadline a mount pin uses.
|
|
721
|
+
* @param node - an element whose ancestors' scroll containers should hold still.
|
|
722
|
+
* @param windowMs - how long to hold them still.
|
|
723
|
+
*/
|
|
724
|
+
export declare function suppressScrollAnchoring(node: HTMLElement, windowMs?: number): void;
|
|
620
725
|
/**
|
|
621
726
|
* Hand a viewport delta back to whichever container actually moved the card.
|
|
622
727
|
*
|
|
@@ -689,6 +794,16 @@ export declare function unwatchModelListOffsets(): void;
|
|
|
689
794
|
* @param windowMs - how long each found card stays pinned.
|
|
690
795
|
*/
|
|
691
796
|
export declare function pinModelListCards(root: HTMLElement, windowMs?: number): void;
|
|
797
|
+
/**
|
|
798
|
+
* The model list's add-model buttons, found by the host's own copy.
|
|
799
|
+
*
|
|
800
|
+
* Matched like every other official control — by the resolved dictionary copy,
|
|
801
|
+
* never by a class — but through BOTH channels the button may carry: an
|
|
802
|
+
* aria-label when the host gave it one, else its own text content (the DSH
|
|
803
|
+
* host renders it as a plain labelled button). Buttons inside this plugin's
|
|
804
|
+
* own DOM are skipped, exactly like the Edit buttons above.
|
|
805
|
+
*/
|
|
806
|
+
export declare function addModelTriggersOf(scope: HTMLElement, labels: HostLabels): HTMLElement[];
|
|
692
807
|
/**
|
|
693
808
|
* Scan the settings DOM for official model rows and reconcile the injected
|
|
694
809
|
* editors. Idempotent: existing editors are left alone, new disclosures get
|