dsh-model-think-level 2.0.3 → 2.2.0
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 +39 -22
- package/lib/autofill.d.ts +20 -2
- package/lib/balance.d.ts +44 -0
- package/lib/client/ComposerSlider.d.ts +19 -0
- package/lib/client/ConfigPane.d.ts +45 -0
- package/lib/client/EffortEditor.d.ts +1 -8
- package/lib/client/KeyManager.d.ts +2 -2
- package/lib/client/balance-client.d.ts +34 -0
- package/lib/client/events.d.ts +31 -2
- package/lib/client/image-config-client.d.ts +52 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/injection/autofill-run.d.ts +2 -2
- package/lib/client/injection/compat-guard.d.ts +33 -0
- package/lib/client/injection/config-button-seat.d.ts +96 -0
- package/lib/client/injection/create-key-seat.d.ts +3 -3
- package/lib/client/injection/create-keys-pane.d.ts +4 -2
- package/lib/client/injection/editor-tab-bar.d.ts +1 -1
- package/lib/client/injection/editor-tabs.d.ts +1 -1
- package/lib/client/injection/image-card.d.ts +85 -0
- package/lib/client/injection/imagegen-completion.d.ts +43 -0
- package/lib/client/injection/imagegen-entry.d.ts +22 -0
- package/lib/client/injection/key-prefetch.d.ts +56 -0
- package/lib/client/injection/key-reveal.d.ts +2 -3
- package/lib/client/injection/model-order-drag.d.ts +1 -1
- package/lib/client/injection/models-page-editor.d.ts +25 -29
- package/lib/client/injection/models-page-mutation.d.ts +6 -0
- package/lib/client/injection/models-page.d.ts +15 -3
- package/lib/client/injection/provider-balance.d.ts +94 -0
- package/lib/client/injection/provider-delete-seat.d.ts +4 -1
- package/lib/client/injection/provider-disabled-group.d.ts +4 -1
- package/lib/client/injection/provider-endpoints.d.ts +2 -2
- package/lib/client/injection/provider-order-drag.d.ts +5 -1
- package/lib/client/injection/provider-toggle.d.ts +4 -1
- package/lib/client/injection/row-drag.d.ts +7 -0
- package/lib/client/injection/staged-keys.d.ts +24 -12
- package/lib/client/key-manager-client.d.ts +82 -19
- package/lib/client/locales.d.ts +40 -6
- package/lib/client/model-order.d.ts +9 -0
- package/lib/client/ops.d.ts +1 -0
- package/lib/client/order-sync.d.ts +63 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/types.d.ts +4 -1
- package/lib/client.js +517 -13
- package/lib/client.js.map +4 -4
- package/lib/constants.d.ts +53 -0
- package/lib/fingerprint/estimate.d.ts +16 -0
- package/lib/fingerprint/run.d.ts +6 -0
- package/lib/fingerprint/store.d.ts +2 -2
- package/lib/fingerprint/verdict.d.ts +24 -0
- package/lib/headers-core.d.ts +3 -1
- package/lib/headers-fetch.d.ts +25 -0
- package/lib/image/command.d.ts +84 -0
- package/lib/image/config.d.ts +150 -0
- package/lib/image/generate.d.ts +135 -0
- package/lib/image/legacy-cleanup.d.ts +29 -0
- package/lib/image/sizes.d.ts +28 -0
- package/lib/image/tool.d.ts +107 -0
- package/lib/index.js +3969 -1555
- package/lib/index.js.map +4 -4
- package/lib/key-index.d.ts +48 -7
- package/lib/key-probe.d.ts +42 -17
- package/lib/key-refs.d.ts +43 -19
- package/lib/key-route-core.d.ts +100 -32
- package/lib/key-serves.d.ts +81 -0
- package/lib/knowledge.d.ts +26 -0
- package/lib/listing.d.ts +18 -20
- package/lib/order-store.d.ts +78 -0
- package/package.json +1 -8
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import type { ReactNode } from 'react';
|
|
24
24
|
import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
|
|
25
25
|
import type { RemoteApi } from '../types.js';
|
|
26
|
-
import { type DraftKeyStore, type StagedKeysState } from './staged-keys.js';
|
|
26
|
+
import { type DraftKeyStore, type StagedKeysState, type StagedKeyDraft } from './staged-keys.js';
|
|
27
27
|
export interface CreateKeysPaneProps {
|
|
28
28
|
/** The plugin's seat right after the official key field; the id read and the
|
|
29
29
|
* input listener both resolve the card from it. */
|
|
@@ -41,6 +41,8 @@ export interface CreateKeysPaneProps {
|
|
|
41
41
|
routeIdLabels: () => readonly string[];
|
|
42
42
|
/** The session's deferred-key ledger. */
|
|
43
43
|
staged: StagedKeysState;
|
|
44
|
+
/** Mirror the enabled draft key into the official form used by Fetch models. */
|
|
45
|
+
onChange?: (drafts: readonly StagedKeyDraft[]) => void;
|
|
44
46
|
}
|
|
45
47
|
/** 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;
|
|
48
|
+
export declare function CreateKeysPane({ host, store, api, t, routeIdLabels, staged, onChange }: CreateKeysPaneProps): ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The provider editor's segmented control
|
|
3
|
-
* (供应商配置 / 模型配置 /
|
|
3
|
+
* (供应商配置 / 模型配置 / 高级配置 / 指纹检测).
|
|
4
4
|
*
|
|
5
5
|
* This is the bar the editor-tabs pass drives. It lives HERE, in the plugin's
|
|
6
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", "
|
|
49
|
+
declare const TAB_IDS: readonly ["provider", "models", "advanced", "fingerprint"];
|
|
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. */
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keyed image card: the `tool.call.toolview` entry that renders the
|
|
3
|
+
* `generate_image` tool's result as actual pictures in the conversation.
|
|
4
|
+
*
|
|
5
|
+
* Without this entry the generic tool row shows only the result's TEXT — its
|
|
6
|
+
* image body (`imageCardModel`) is hard-wired to `read_image` — so the
|
|
7
|
+
* generated image would never be visible even though the durable result
|
|
8
|
+
* carries it. The card therefore reads the image blocks straight from the
|
|
9
|
+
* persisted result content and renders them through the OFFICIAL
|
|
10
|
+
* `tool.call.images` child slot (`dsh-client-ui-attachment`'s gallery), which
|
|
11
|
+
* needs no plugin-owned fetch route: the bytes load through the host's own
|
|
12
|
+
* attachment pipeline. Declaring `tool.call.images` under `children` is what
|
|
13
|
+
* authorizes the entry's `renderSlot` to dispatch it.
|
|
14
|
+
*
|
|
15
|
+
* The card is registered under the tool name the HOST reports (the config
|
|
16
|
+
* route's `tool.name`), because a dsh-image-gen install can own the plain
|
|
17
|
+
* `generate_image` key — the host then registers this plugin's tool under the
|
|
18
|
+
* fallback name, and the card must follow the tool, never the wishful name.
|
|
19
|
+
*
|
|
20
|
+
* @module dsh-model-think-level/client/injection/image-card
|
|
21
|
+
*/
|
|
22
|
+
import type { ReactNode } from 'react';
|
|
23
|
+
import type { ClientContext } from '../types.js';
|
|
24
|
+
import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
|
|
25
|
+
/** One attachment reference as the official gallery consumes it. */
|
|
26
|
+
interface ImageRefLike {
|
|
27
|
+
readonly attachment: {
|
|
28
|
+
readonly attachmentId: string;
|
|
29
|
+
readonly mediaType: string;
|
|
30
|
+
readonly bytes: number;
|
|
31
|
+
readonly width: number;
|
|
32
|
+
readonly height: number;
|
|
33
|
+
readonly name?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The block face the toolview slot occurrence carries, narrowed to what this card reads. */
|
|
37
|
+
interface ToolBlockLike {
|
|
38
|
+
/** Settled marker: a running call carries `phase` instead. */
|
|
39
|
+
readonly kind?: string;
|
|
40
|
+
readonly phase?: string;
|
|
41
|
+
readonly content?: readonly {
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly text?: string;
|
|
44
|
+
readonly attachment?: ImageRefLike['attachment'];
|
|
45
|
+
}[];
|
|
46
|
+
readonly resultView?: {
|
|
47
|
+
readonly content?: readonly {
|
|
48
|
+
readonly type: string;
|
|
49
|
+
readonly text?: string;
|
|
50
|
+
readonly attachment?: ImageRefLike['attachment'];
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
readonly meta?: {
|
|
54
|
+
readonly model?: string;
|
|
55
|
+
readonly paramsUsed?: {
|
|
56
|
+
readonly size?: string;
|
|
57
|
+
readonly quality?: string;
|
|
58
|
+
readonly n?: number;
|
|
59
|
+
};
|
|
60
|
+
readonly revisions?: readonly string[];
|
|
61
|
+
readonly images?: readonly {
|
|
62
|
+
readonly filePath?: string;
|
|
63
|
+
}[];
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** The occurrence props the Tool row hands a keyed toolview entry. */
|
|
67
|
+
interface ImageCardProps {
|
|
68
|
+
readonly block?: ToolBlockLike;
|
|
69
|
+
readonly renderSlot?: (name: string, props: Record<string, unknown>) => ReactNode;
|
|
70
|
+
readonly loadImage?: (ref: ImageRefLike['attachment']) => unknown;
|
|
71
|
+
}
|
|
72
|
+
/** The image attachments one settled result carries, in order. */
|
|
73
|
+
export declare function imageRefsOf(block: ToolBlockLike | undefined): readonly ImageRefLike[];
|
|
74
|
+
/** The card component: gallery through the official slot, caption under it. */
|
|
75
|
+
export declare function ImageToolCard(props: ImageCardProps & {
|
|
76
|
+
t: Translate;
|
|
77
|
+
}): ReactNode;
|
|
78
|
+
/**
|
|
79
|
+
* Register the image card under the tool name the host reports. The name is
|
|
80
|
+
* a host-side fact (the collision fallback may have renamed the tool), so the
|
|
81
|
+
* registration waits for one config read when the cache is cold; a host that
|
|
82
|
+
* never answers leaves no card and the generic row stays.
|
|
83
|
+
*/
|
|
84
|
+
export declare function registerImageCard(ctx: ClientContext, t: Translate): void;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `/生图` completion source's pure candidate logic (§4.8, 一期 = model-level).
|
|
3
|
+
*
|
|
4
|
+
* Two levels after the `/生图` trigger:
|
|
5
|
+
* 1. the first token completes to an image model (label and full id, fuzzy
|
|
6
|
+
* over both, the default marked);
|
|
7
|
+
* 2. after a model token (一期 stub): the param candidates arrive in 二期 —
|
|
8
|
+
* an empty list keeps the menu from showing a stale "nothing".
|
|
9
|
+
*
|
|
10
|
+
* Pure string logic — no DOM, no services — so the candidates are unit-testable
|
|
11
|
+
* against the exact strings the menu will render.
|
|
12
|
+
*
|
|
13
|
+
* @module dsh-model-think-level/client/injection/imagegen-completion
|
|
14
|
+
*/
|
|
15
|
+
/** One completion candidate as the menu renders it. */
|
|
16
|
+
export interface ImagegenCandidate {
|
|
17
|
+
/** The rendered line (what the user sees). */
|
|
18
|
+
readonly label: string;
|
|
19
|
+
/** What lands in the draft when picked. */
|
|
20
|
+
readonly insertText: string;
|
|
21
|
+
/** The candidate's class of thing (model | param) — ordering/uses tests. */
|
|
22
|
+
readonly kind: 'model' | 'param';
|
|
23
|
+
/** Extra hint shown beside the label, when one exists. */
|
|
24
|
+
readonly hint?: string;
|
|
25
|
+
}
|
|
26
|
+
/** A model the completion offers, straight from the config view's rows. */
|
|
27
|
+
export interface CompletionModel {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly label: string;
|
|
30
|
+
readonly isDefault: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The candidates for the text after `/生图`. A leading model token (or its
|
|
34
|
+
* prefix) completes to models; everything else is the prompt — no candidates
|
|
35
|
+
* (the command itself runs without completion noise over free text).
|
|
36
|
+
*/
|
|
37
|
+
export declare function imagegenCandidates(text: string, models: readonly CompletionModel[]): readonly ImagegenCandidate[];
|
|
38
|
+
/**
|
|
39
|
+
* The `/生图` word itself, as the top-level slash completion shows it (the
|
|
40
|
+
* menu that lists commands). Kept beside the candidates so the command's
|
|
41
|
+
* display and its completion can never drift apart.
|
|
42
|
+
*/
|
|
43
|
+
export declare function imagegenCommandCandidate(): ImagegenCandidate;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The image-generation entry's service wiring (the client's only jobs in the
|
|
3
|
+
* v3 design — the switcher badges are already shipped in ComposerSlider, and
|
|
4
|
+
* point-select stays `directory.select` untouched):
|
|
5
|
+
*
|
|
6
|
+
* 1. the `/生图` completion source over the host input-trigger pipeline
|
|
7
|
+
* (`/` trigger, model-level candidates), registered ONLY when the host
|
|
8
|
+
* exposes the service — an older kernel just loses the completion, never
|
|
9
|
+
* the command itself;
|
|
10
|
+
* 2. a 30s-cached read of the image config, so a burst of completions costs
|
|
11
|
+
* one route read.
|
|
12
|
+
*
|
|
13
|
+
* @module dsh-model-think-level/client/injection/imagegen-entry
|
|
14
|
+
*/
|
|
15
|
+
import type { ClientContext } from '../types.js';
|
|
16
|
+
/** Invalidate the cached model list (a settings change can add/remove rows). */
|
|
17
|
+
export declare function invalidateImagegenModels(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Register the completion source. @returns the disposer (a no-op when the
|
|
20
|
+
* host has no input-trigger service to register with).
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerImagegenCompletion(ctx: ClientContext): () => void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warming the key lists before any card opens.
|
|
3
|
+
*
|
|
4
|
+
* The key panel paints its rows from the last successful read and revalidates
|
|
5
|
+
* in the background, so an expansion is instant exactly as long as the route's
|
|
6
|
+
* list has been read once on this page. Nothing reads it before the first
|
|
7
|
+
* expansion, though — the user's first 编辑 on a freshly opened Models page
|
|
8
|
+
* paid the whole read latency (a settings read plus one credential resolve per
|
|
9
|
+
* key, behind the host's serialised settings service) as a visible "正在读取密
|
|
10
|
+
* 钥…" line, every session, on every route.
|
|
11
|
+
*
|
|
12
|
+
* This pass asks once per provider per page opening, fire-and-forget, the same
|
|
13
|
+
* moment the page's provider list first shows: the read is what an expansion
|
|
14
|
+
* would have asked for anyway, only earlier and off the critical path. It is
|
|
15
|
+
* the balance chip's timing contract (one read per provider per opening), put
|
|
16
|
+
* to work for the key panel. No interval, no polling — a failed warm-up is
|
|
17
|
+
* simply retried by the panel's own mount read when the card opens.
|
|
18
|
+
*
|
|
19
|
+
* @module dsh-model-think-level/client/injection/key-prefetch
|
|
20
|
+
*/
|
|
21
|
+
import type { KeyManagerClient } from '../key-manager-client.js';
|
|
22
|
+
import type { HostLabels } from './models-page-editor.js';
|
|
23
|
+
interface PendingKeyList {
|
|
24
|
+
readonly route: string;
|
|
25
|
+
readonly client: KeyManagerClient;
|
|
26
|
+
}
|
|
27
|
+
/** Per-session bookkeeping (one instance lives in `models-page.ts`). */
|
|
28
|
+
export interface KeyPrefetchState {
|
|
29
|
+
/** Routes already asked during THIS page opening. */
|
|
30
|
+
readonly requested: Set<string>;
|
|
31
|
+
/** Work not yet started; discarded when the provider list disappears. */
|
|
32
|
+
readonly pending: PendingKeyList[];
|
|
33
|
+
/** In-flight reads survive page reopen, keeping the shared limit at two. */
|
|
34
|
+
readonly running: Set<string>;
|
|
35
|
+
/** Whether the provider list was present in the previous pass. */
|
|
36
|
+
visible: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** A fresh state for one page instance. */
|
|
39
|
+
export declare function createKeyPrefetchState(): KeyPrefetchState;
|
|
40
|
+
/** What the pass needs from its host. */
|
|
41
|
+
export interface KeyPrefetchDeps {
|
|
42
|
+
/** The official `settings.models` label sets, resolved fresh on every scan. */
|
|
43
|
+
readonly labels: () => HostLabels;
|
|
44
|
+
/** Transport; injectable for tests. */
|
|
45
|
+
readonly client?: KeyManagerClient;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Visit the provider list once per scan: on a (re)opened page, ask the host for
|
|
49
|
+
* each visible provider's key list, once, and let the panel's cache hold the
|
|
50
|
+
* answer until an expansion needs it.
|
|
51
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
52
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
53
|
+
* per pass, and one burst runs several passes.
|
|
54
|
+
*/
|
|
55
|
+
export declare function reconcileKeyPrefetch(root: HTMLElement, deps: KeyPrefetchDeps, state: KeyPrefetchState, list?: HTMLElement | undefined): void;
|
|
56
|
+
export {};
|
|
@@ -101,8 +101,7 @@ export declare function loadProviderKey(route: string): Promise<string | undefin
|
|
|
101
101
|
* value into its draft state — so a re-render keeps it instead of reverting to
|
|
102
102
|
* the empty draft.
|
|
103
103
|
*
|
|
104
|
-
* The create card
|
|
105
|
-
*
|
|
106
|
-
* the field over.
|
|
104
|
+
* The create card uses the same gesture to mirror its enabled draft key into
|
|
105
|
+
* the official form, so Fetch models and Save use the key shown in the list.
|
|
107
106
|
*/
|
|
108
107
|
export declare function writeInputValue(input: HTMLInputElement, value: string): void;
|
|
@@ -71,7 +71,7 @@ export declare function modelListMutation(records: readonly MutationRecord[]): b
|
|
|
71
71
|
* that might belong to another provider, or writing one there, is worse than
|
|
72
72
|
* leaving that editor without grips for a scan.
|
|
73
73
|
*/
|
|
74
|
-
export declare function reconcileModelOrder(root: HTMLElement, deps: ModelOrderDeps, state: ModelOrderState): void;
|
|
74
|
+
export declare function reconcileModelOrder(root: HTMLElement, deps: ModelOrderDeps, state: ModelOrderState, lists?: readonly HTMLElement[]): void;
|
|
75
75
|
/**
|
|
76
76
|
* Undo everything this module put on the page. A plugin disable or an HMR
|
|
77
77
|
* replace unmounts React trees on its own, but the grips, the widened grids and
|
|
@@ -115,7 +115,10 @@ export interface InjectorDeps {
|
|
|
115
115
|
*/
|
|
116
116
|
api: RemoteApi;
|
|
117
117
|
/** Read the pi-ai namespace plus writability from the settings join. */
|
|
118
|
-
describeNamespace(
|
|
118
|
+
describeNamespace(options?: {
|
|
119
|
+
fresh?: boolean;
|
|
120
|
+
allowStale?: boolean;
|
|
121
|
+
}): Promise<SettingsJoin>;
|
|
119
122
|
/** Localized copy. */
|
|
120
123
|
t: (key: string, params?: Record<string, string | number>) => string;
|
|
121
124
|
/**
|
|
@@ -132,7 +135,7 @@ export interface InjectorDeps {
|
|
|
132
135
|
* browser half hangs its autofill complement here: "the user stopped
|
|
133
136
|
* editing" is the only moment this side may safely write the document.
|
|
134
137
|
*/
|
|
135
|
-
onIdle?(): void;
|
|
138
|
+
onIdle?(join?: SettingsJoin): void;
|
|
136
139
|
/** Wake the debounced scan after provider-wide adaptation stages a row. */
|
|
137
140
|
onPendingChanged?(): void;
|
|
138
141
|
/**
|
|
@@ -186,10 +189,6 @@ export interface EditorMountProps {
|
|
|
186
189
|
* DOM, never a kernel version.
|
|
187
190
|
*/
|
|
188
191
|
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;
|
|
193
192
|
api: EffortEditorApi;
|
|
194
193
|
readOnly: boolean;
|
|
195
194
|
t: (key: string, params?: Record<string, string | number>) => string;
|
|
@@ -280,6 +279,9 @@ export interface ScanState {
|
|
|
280
279
|
editWired: WeakSet<Element>;
|
|
281
280
|
/** The model lists' add-model buttons already wired for the top re-pin. */
|
|
282
281
|
addModelWired: WeakSet<Element>;
|
|
282
|
+
/** The provider list's own add-provider button already wired for the top
|
|
283
|
+
* re-pin — the click that replaces the button with the new-provider card. */
|
|
284
|
+
addProviderWired: WeakSet<Element>;
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
285
287
|
* One staged declaration: the level set plus the suggestion's compat block and
|
|
@@ -473,15 +475,7 @@ export declare function hideOfficialReasoning(container: HTMLElement): void;
|
|
|
473
475
|
* proves it — so an inline `display` the host wrote itself is left as it is.
|
|
474
476
|
*/
|
|
475
477
|
export declare function showOfficialReasoning(container: HTMLElement): void;
|
|
476
|
-
/**
|
|
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
|
-
*/
|
|
478
|
+
/** Stand both official copies down. Used when the editor leaves the row. */
|
|
485
479
|
export declare function hideOfficialCapacityChrome(container: HTMLElement): void;
|
|
486
480
|
/** Hand the official capacity/input-type chrome back when the editor goes. */
|
|
487
481
|
export declare function showOfficialCapacityChrome(container: HTMLElement): void;
|
|
@@ -517,18 +511,21 @@ export declare function officialImageCheckboxOf(container: HTMLElement, imageLab
|
|
|
517
511
|
*/
|
|
518
512
|
export declare function echoOfficialModality(container: HTMLElement, image: boolean, imageLabels: readonly string[]): boolean;
|
|
519
513
|
/**
|
|
520
|
-
* The modality intent a row's own write
|
|
521
|
-
* input-types control has been
|
|
514
|
+
* The modality intent a row's own write carries, after the official
|
|
515
|
+
* input-types control has been MIRRORED with the verdict.
|
|
522
516
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
517
|
+
* The official checkbox renders the official card's own DRAFT, not the
|
|
518
|
+
* settings document — so a document write of the plugin's can never tick it
|
|
519
|
+
* before the card is saved and reopened, and the box has to be clicked for the
|
|
520
|
+
* user to see the verdict in the official form. That click is a mirror, never a
|
|
521
|
+
* handover: the row's own declaration still travels its write (or its staging),
|
|
522
|
+
* because the plugin's 支持模态 pills and the composer's vision badge both read
|
|
523
|
+
* the DOCUMENT. Dropping the intent once the box took the click — what this
|
|
524
|
+
* function used to do — left a bulk-adapted new provider with an unselected
|
|
525
|
+
* modality everywhere the user could see it.
|
|
526
|
+
*
|
|
527
|
+
* `null` (the plugin's deliberate UNSET) is untouched: the official control
|
|
528
|
+
* cannot express it at all.
|
|
532
529
|
*/
|
|
533
530
|
export declare function officialModalityIntent(container: HTMLElement | undefined, input: InputModalities | null | undefined, imageLabels: readonly string[]): InputModalities | null | undefined;
|
|
534
531
|
/**
|
|
@@ -735,7 +732,7 @@ export declare function suppressScrollAnchoring(node: HTMLElement, windowMs?: nu
|
|
|
735
732
|
* offset is no longer the one this loop left is being scrolled by somebody
|
|
736
733
|
* else, and is skipped rather than fought.
|
|
737
734
|
*/
|
|
738
|
-
export declare function absorbDelta(chain: readonly HTMLElement[], watched: Set<HTMLElement>, lastSet: Map<HTMLElement, number>, delta: number): void;
|
|
735
|
+
export declare function absorbDelta(chain: readonly HTMLElement[], watched: Set<HTMLElement>, lastSet: Map<HTMLElement, number>, delta: number, priority?: readonly HTMLElement[]): void;
|
|
739
736
|
/**
|
|
740
737
|
* Start recording where a click inside a model list leaves its scroll host.
|
|
741
738
|
*
|
|
@@ -804,8 +801,7 @@ export declare function pinModelListCards(root: HTMLElement, windowMs?: number):
|
|
|
804
801
|
* own DOM are skipped, exactly like the Edit buttons above.
|
|
805
802
|
*/
|
|
806
803
|
export declare function addModelTriggersOf(scope: HTMLElement, labels: HostLabels): HTMLElement[];
|
|
807
|
-
/**
|
|
808
|
-
* Scan the settings DOM for official model rows and reconcile the injected
|
|
804
|
+
/** Scan the settings DOM for official model rows and reconcile the injected
|
|
809
805
|
* editors. Idempotent: existing editors are left alone, new disclosures get
|
|
810
806
|
* one, and removed ones are unmounted.
|
|
811
807
|
* @param root - the settings panel root to scan.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat streaming and foreign-root renders must not wake every Models-page seam.
|
|
3
|
+
* Inspect the mutation's subtree, not document.body. Removed subtrees are kept
|
|
4
|
+
* in the records too, so navigation away still releases page-opening sessions.
|
|
5
|
+
*/
|
|
6
|
+
export declare function modelsPageMutation(records: readonly MutationRecord[]): boolean;
|
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
import type { ReactNode } from 'react';
|
|
17
17
|
import type { Translate } from '@deepseek-ai/dsh-client-ui-slots';
|
|
18
18
|
import { type HostLabels, type ScanState } from './models-page-editor.js';
|
|
19
|
-
import type { ClientContext, RemoteApi } from '../types.js';
|
|
19
|
+
import type { ClientContext, RemoteApi, SettingsJoin } from '../types.js';
|
|
20
|
+
/** The Models-page title-row seat (the 「配置」 button) needs only copy + open. */
|
|
21
|
+
export interface ConfigSeatDeps {
|
|
22
|
+
readonly t: Translate;
|
|
23
|
+
readonly onOpen: () => void;
|
|
24
|
+
}
|
|
20
25
|
/** What the Models-page injection needs from its host. */
|
|
21
26
|
export interface ModelsPageDeps {
|
|
22
27
|
/** The client root context. */
|
|
@@ -25,10 +30,17 @@ export interface ModelsPageDeps {
|
|
|
25
30
|
api: RemoteApi;
|
|
26
31
|
/** The plugin's locale-bound translator. */
|
|
27
32
|
t: Translate;
|
|
28
|
-
/**
|
|
29
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Run once per idle pass, after everything the session held back landed.
|
|
35
|
+
* The pass's own snapshot (a fresh wire read taken when the official card
|
|
36
|
+
* just closed) is handed over so a complement that needs to look at the
|
|
37
|
+
* document does not pay a second round trip for the same view.
|
|
38
|
+
*/
|
|
39
|
+
onIdle: (join?: SettingsJoin) => void;
|
|
30
40
|
/** Wrap a subtree so it re-translates on a language switch. */
|
|
31
41
|
refreshed: (children: () => ReactNode) => ReactNode;
|
|
42
|
+
/** Present when the Models-page title row should carry the 「配置」 button. */
|
|
43
|
+
configSeat?: ConfigSeatDeps;
|
|
32
44
|
}
|
|
33
45
|
/** The Models-page injection's face. */
|
|
34
46
|
export interface ModelsPageInjection {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The balance chip in front of a provider's enable switch (Models page).
|
|
3
|
+
*
|
|
4
|
+
* The row shows the amount the provider's own balance endpoint answered, and
|
|
5
|
+
* nothing at all when that provider has no balance endpoint configured — the
|
|
6
|
+
* chip is decoration, not a control, so it must never invent a value or a
|
|
7
|
+
* placeholder. The URL lives in the plugin's key index (written from the
|
|
8
|
+
* provider card's 余额 row) and the host does the authenticated call
|
|
9
|
+
* (`../balance-client.ts`).
|
|
10
|
+
*
|
|
11
|
+
* Timing is deliberate: ONE read per provider per page opening. The Models page
|
|
12
|
+
* is the only place the list exists, so there is nothing to fetch while the
|
|
13
|
+
* user is elsewhere; when the provider list disappears the session is marked
|
|
14
|
+
* closed, and opening the page again starts one fresh read per provider. There
|
|
15
|
+
* is no interval and no polling — a second read inside the same opening only
|
|
16
|
+
* happens when the balance URL itself was written (see
|
|
17
|
+
* {@link invalidateProviderBalance}).
|
|
18
|
+
*
|
|
19
|
+
* A failed read does NOT throw the last answer away: the chip keeps the last
|
|
20
|
+
* successful amount (requirement: show the previous value when nothing new
|
|
21
|
+
* arrived). Only a route that has never answered falls back to the failed chip,
|
|
22
|
+
* and only when its endpoint really is configured — otherwise nothing is shown.
|
|
23
|
+
*
|
|
24
|
+
* The chip is placed immediately BEFORE the switch — the switch belongs to the
|
|
25
|
+
* provider's state, the balance is context for it — and the position is
|
|
26
|
+
* re-asserted on every scan, because the official row can re-render its action
|
|
27
|
+
* group at any time.
|
|
28
|
+
*
|
|
29
|
+
* @module dsh-model-think-level/client/injection/provider-balance
|
|
30
|
+
*/
|
|
31
|
+
import { type BalanceReading } from '../../balance.js';
|
|
32
|
+
import { type BalanceClient } from '../balance-client.js';
|
|
33
|
+
import type { HostLabels } from './models-page-editor.js';
|
|
34
|
+
/** Per-session bookkeeping (one instance lives in `models-page.ts`). */
|
|
35
|
+
export interface ProviderBalanceState {
|
|
36
|
+
/** Route → the last successful reading (kept across a failed re-read). */
|
|
37
|
+
readonly readings: Map<string, BalanceReading>;
|
|
38
|
+
/** Route → the last failure's reason, for routes with no reading yet. */
|
|
39
|
+
readonly errors: Map<string, string>;
|
|
40
|
+
/** Routes already asked during THIS page opening. */
|
|
41
|
+
readonly requested: Set<string>;
|
|
42
|
+
/** Routes with a read in flight. */
|
|
43
|
+
readonly inflight: Set<string>;
|
|
44
|
+
/** Routes invalidated while a read was in flight (re-read on settle). */
|
|
45
|
+
readonly pending: Set<string>;
|
|
46
|
+
/** Reads waiting for a concurrency slot; discarded when the page closes. */
|
|
47
|
+
readonly queued: PendingBalanceRead[];
|
|
48
|
+
/** Whether the provider list was present in the previous pass. */
|
|
49
|
+
visible: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** A read waiting for a slot: the row that asked and the route it asked for. */
|
|
52
|
+
interface PendingBalanceRead {
|
|
53
|
+
readonly head: HTMLElement;
|
|
54
|
+
readonly route: string;
|
|
55
|
+
}
|
|
56
|
+
/** What the chip needs from its host. */
|
|
57
|
+
export interface ProviderBalanceDeps {
|
|
58
|
+
/** The plugin's own translator, for the chip's label and tooltip. */
|
|
59
|
+
readonly t: (key: string, params?: Record<string, string | number>) => string;
|
|
60
|
+
/** The official `settings.models` label sets, resolved fresh on every scan. */
|
|
61
|
+
readonly labels: () => HostLabels;
|
|
62
|
+
/** Transport; injectable for tests. */
|
|
63
|
+
readonly client?: BalanceClient;
|
|
64
|
+
/**
|
|
65
|
+
* Ask the page for one more reconcile after an answer landed for a row that
|
|
66
|
+
* is no longer in the DOM (the page was closed and reopened while the read
|
|
67
|
+
* was in flight). Without it that answer would wait for an unrelated
|
|
68
|
+
* mutation to reach the new row.
|
|
69
|
+
*/
|
|
70
|
+
readonly repaint?: () => void;
|
|
71
|
+
}
|
|
72
|
+
/** A fresh state for one page instance. */
|
|
73
|
+
export declare function createProviderBalanceState(): ProviderBalanceState;
|
|
74
|
+
/**
|
|
75
|
+
* Visit every provider row: paint what is known, and ask once per page opening
|
|
76
|
+
* for a route that has not been asked in this opening.
|
|
77
|
+
*
|
|
78
|
+
* A missing provider list means the Models page is closed (or not rendered):
|
|
79
|
+
* the opening is over, so the next presence starts a new read session. No
|
|
80
|
+
* request is made from this function while the list is absent.
|
|
81
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
82
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
83
|
+
* per pass, and one burst runs several passes.
|
|
84
|
+
*/
|
|
85
|
+
export declare function reconcileProviderBalance(root: HTMLElement, deps: ProviderBalanceDeps, state: ProviderBalanceState, list?: HTMLElement | undefined): void;
|
|
86
|
+
/**
|
|
87
|
+
* Forget one route's session, so the next reconcile reads it now.
|
|
88
|
+
* A balance URL was just written (or cleared): the old amount belongs to the
|
|
89
|
+
* old endpoint, and waiting for a page reopening would leave the chip lying.
|
|
90
|
+
*/
|
|
91
|
+
export declare function invalidateProviderBalance(state: ProviderBalanceState, route: string): void;
|
|
92
|
+
/** Remove every chip (the fiber is going away). */
|
|
93
|
+
export declare function teardownProviderBalance(): void;
|
|
94
|
+
export {};
|
|
@@ -32,7 +32,10 @@ export interface ProviderDeleteDeps {
|
|
|
32
32
|
* Give every provider row the delete seat the host left out. Idempotent: a row
|
|
33
33
|
* that already has one is only relabelled, and a row whose provider became
|
|
34
34
|
* removable hands the seat back to the host's own button.
|
|
35
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
36
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
37
|
+
* per pass, and one burst runs several passes.
|
|
35
38
|
*/
|
|
36
|
-
export declare function reconcileProviderDeleteSeat(root: HTMLElement, deps: ProviderDeleteDeps): void;
|
|
39
|
+
export declare function reconcileProviderDeleteSeat(root: HTMLElement, deps: ProviderDeleteDeps, list?: HTMLElement | undefined): void;
|
|
37
40
|
/** Take every seat out again (plugin dispose, HMR teardown). */
|
|
38
41
|
export declare function teardownProviderDeleteSeats(): void;
|
|
@@ -50,7 +50,10 @@ export declare function createProviderDisabledGroupState(): ProviderDisabledGrou
|
|
|
50
50
|
* Idempotent: a row already folded stays folded, and the control is only ever
|
|
51
51
|
* written when a value genuinely changed, so a scan never mutates the page on
|
|
52
52
|
* behalf of a state that is already on it.
|
|
53
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
54
|
+
* `reconcileProviderOrder`); re-deriving it here costs a document-wide walk
|
|
55
|
+
* per pass, and one burst runs several passes.
|
|
53
56
|
*/
|
|
54
|
-
export declare function reconcileProviderDisabledGroup(root: HTMLElement, deps: ProviderDisabledGroupDeps, state: ProviderDisabledGroupState): void;
|
|
57
|
+
export declare function reconcileProviderDisabledGroup(root: HTMLElement, deps: ProviderDisabledGroupDeps, state: ProviderDisabledGroupState, list?: HTMLElement | undefined): void;
|
|
55
58
|
/** Remove the control and unfold every row it hid. */
|
|
56
59
|
export declare function teardownProviderDisabledGroup(): void;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
* - **extra endpoints can be added.** A grey "更多端点" text button directly
|
|
20
20
|
* under the API address — where the rows it reveals appear — opens one more
|
|
21
21
|
* address row for EVERY family the selected protocol does not serve
|
|
22
|
-
* (Anthropic
|
|
23
|
-
*
|
|
22
|
+
* (Anthropic under an OpenAI protocol, OpenAI under Anthropic). They persist
|
|
23
|
+
* to the route's `endpoints` in this plugin's key
|
|
24
24
|
* index, which is what a key pinned to that family signs against.
|
|
25
25
|
*
|
|
26
26
|
* The add card carries the same three fields, so the same decoration applies to
|
|
@@ -74,8 +74,12 @@ export declare function applyRowOrder(list: HTMLElement, ids: readonly string[])
|
|
|
74
74
|
* open, so this cannot ride along with it) and is idempotent by DOM presence —
|
|
75
75
|
* the same guard the editor injector uses, which keeps the insertion from
|
|
76
76
|
* re-triggering the scan that found it.
|
|
77
|
+
* @param list - the provider list already resolved by the caller's scan. Every
|
|
78
|
+
* pass of one `reconcileDom` shares one `rowsListOf` answer: the fallback
|
|
79
|
+
* re-derivation costs a full-document substring-class walk, and seven passes
|
|
80
|
+
* paying it separately is what showed up as tens of walks per burst.
|
|
77
81
|
*/
|
|
78
|
-
export declare function reconcileProviderOrder(root: HTMLElement, deps: ProviderOrderDeps, state: ProviderOrderState): void;
|
|
82
|
+
export declare function reconcileProviderOrder(root: HTMLElement, deps: ProviderOrderDeps, state: ProviderOrderState, list?: HTMLElement | undefined): void;
|
|
79
83
|
/**
|
|
80
84
|
* Undo everything this module put on the official page. A plugin disable or an
|
|
81
85
|
* HMR replace unmounts React trees on its own, but the grips, the draggable
|
|
@@ -36,7 +36,10 @@ export declare function createProviderToggleState(): ProviderToggleState;
|
|
|
36
36
|
* Visit every provider row and make sure it shows a switch carrying its own
|
|
37
37
|
* state. Idempotent: a row that already has one is only relabelled, which is
|
|
38
38
|
* also how a language switch and an external toggle reach the page.
|
|
39
|
+
* @param list - the provider list already resolved by the caller's scan (see
|
|
40
|
+
* {@link reconcileProviderOrder}); re-deriving it here costs a document-wide
|
|
41
|
+
* walk per pass, and one burst runs several passes.
|
|
39
42
|
*/
|
|
40
|
-
export declare function reconcileProviderEnabled(root: HTMLElement, deps: ProviderToggleDeps, state: ProviderToggleState): void;
|
|
43
|
+
export declare function reconcileProviderEnabled(root: HTMLElement, deps: ProviderToggleDeps, state: ProviderToggleState, list?: HTMLElement | undefined): void;
|
|
41
44
|
/** Remove every switch and every dimmed row. */
|
|
42
45
|
export declare function teardownProviderEnabled(): void;
|
|
@@ -163,6 +163,13 @@ export declare function scrollHostOf(node: HTMLElement): HTMLElement | undefined
|
|
|
163
163
|
* range away exactly like a deletion inside a small panel would.
|
|
164
164
|
*/
|
|
165
165
|
export declare function scrollChainOf(node: HTMLElement): HTMLElement[];
|
|
166
|
+
/**
|
|
167
|
+
* Every declared scroll container that can hold `node` after layout changes,
|
|
168
|
+
* nearest first, plus the page scroller. Unlike {@link scrollChainOf}, this
|
|
169
|
+
* includes auto/scroll containers before they overflow so a card can be pinned
|
|
170
|
+
* across the same render that creates their scroll range.
|
|
171
|
+
*/
|
|
172
|
+
export declare function scrollContainerCandidatesOf(node: HTMLElement): HTMLElement[];
|
|
166
173
|
/** The pixels per frame `host` should scroll while the pointer is at `clientY`. */
|
|
167
174
|
export declare function edgeScrollStep(host: HTMLElement, clientY: number): number;
|
|
168
175
|
/**
|