dsh-model-think-level 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DSH Model Think Level
2
2
 
3
- DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行注入 Thinking 开关和强度/模态编辑器,在输入框模型菜单加供应商→模型选择器、视觉徽章与等级行,并带搜索、拖拽排序、供应商启用开关;以及按路由接管请求头与 user-agent。
3
+ DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行注入 Thinking 开关和强度/模态编辑器(插件编辑器所在的行会隐藏官方自带的「推理等级」编辑区,同一个字段只留一份控件),在输入框模型菜单加供应商→模型选择器、视觉徽章与等级行,并带搜索、拖拽排序、供应商启用开关;以及按路由接管请求头与 user-agent。
4
4
 
5
5
  ## 模型选择器
6
6
 
@@ -13,6 +13,21 @@ DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行
13
13
  ![模型能力配置](./docs/image4.png)
14
14
  ![供应商高级配置](./docs/image5.png)
15
15
 
16
+ ## 其他配置(高级配置)
17
+
18
+ 供应商卡片的「高级配置」里,请求头下面还有一节独立的「其他配置」,带自己的标题,不是请求头的一项;长缓存保留就是这一节里的一行开关,说明用小字写在该行下面。整块面板的「取消 / 保存」压在这一节之后,所以在高级配置里它是整个面板的提交行,而不是请求头那一节的。
19
+
20
+ 开关写的是该路由 profile 的 `compat.supportsLongCacheRetention`。有些中转站会拒绝 OpenAI 的缓存字段(典型报错 `未知请求字段:prompt_cache_key`);这两个字段由适配器写进**请求体**,任何请求头都加不进去也删不掉,能关掉它们的只有这个 `compat` 开关:
21
+
22
+ - 关掉「长缓存保留」→ 写入 `compat.supportsLongCacheRetention: false`,`prompt_cache_key` 与 `prompt_cache_retention` 都不再发送,短时缓存不受影响。
23
+ - 再打开 → 删除该键(`unset`),路由重新跟随适配器默认值。若下层配置(如 `cordis.patch.yml` 里手写的那份)同样固定了该键,删掉用户层的值只会把它暴露出来,此时改为显式写入 `true`,开关才不会看起来关不掉。
24
+
25
+ 开关跟着它标注的设置走:打开就是保留。没有显式配置时也是打开(跟随适配器默认的长缓存判定);一个开关表示不了「跟随默认」和「显式开启」的差别,所以该路由显式写入了值时,说明下面会再补一行小字。
26
+
27
+ 写入是立即生效的一步操作,没有单独的保存按钮;该路由后续请求按新值走,无需重启 DSH。只写这一个叶子键,`compat` 里其他开关(如 `supportsDeveloperRole`)不会被覆盖。
28
+
29
+ 仅在协议提供该开关时显示:`openai-completions`、`openai-responses`、`azure-openai-responses`、`openai-codex-responses`、`anthropic-messages`。其他协议(如 `mistral-conversations`)会直接说明该协议没有这个开关,而不是给一个写了也不生效的控件。新建供应商卡片时还没有真实路由可写,所以那里不显示这一节。
30
+
16
31
  ## 兼容字段与已有配置
17
32
 
18
33
  1.1.4 起不再提供 `thinkingTokenBudgetField`、`vllmPriority`、`supportsMaxOutputTokens` 的专用编辑控件。已有值仍由 DSH 的 pi-ai 适配器使用;修改模型的思考档位或输入模态时,插件会保留这些值和其他手动兼容配置,避免覆盖供应商的定制行为。
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The 高级配置 pane's second section: the route settings that are not request
3
+ * headers. Its row is the long-cache switch.
4
+ *
5
+ * The section exists because the field a relay rejects (`prompt_cache_key`, and
6
+ * `prompt_cache_retention` beside it) is built into the REQUEST BODY by the
7
+ * adapter, so no header can add or remove it; the switch that does is the route
8
+ * profile's `compat.supportsLongCacheRetention`, which the adapter's own request
9
+ * builder reads. That is why this section exists at all, and why it wears its own
10
+ * heading at the 请求头 heading's level instead of sitting inside the header
11
+ * editor: a reader must not have to guess whether it is another header.
12
+ *
13
+ * The switch reads the setting it is labelled with — on keeps long-lived caches
14
+ * — and its write is immediate, one boolean, the shape of a switch everywhere
15
+ * else on this page. There is no Save of its own; the header editor's Save stays
16
+ * the header draft's and never restates this key.
17
+ *
18
+ * @module dsh-model-think-level/LongCacheSection
19
+ */
20
+ import type { ReactNode } from 'react';
21
+ import type { RemoteApi } from './types.js';
22
+ /** Props of {@link LongCacheSection}. */
23
+ export interface LongCacheSectionProps {
24
+ /** The provider route this card edits. */
25
+ route: string;
26
+ /** The write seam. */
27
+ api: RemoteApi;
28
+ /** Localized copy. */
29
+ t: (key: string, params?: Record<string, string | number>) => string;
30
+ }
31
+ /**
32
+ * Render the pane's long-cache section.
33
+ * @param props - route identity, write seam and copy.
34
+ * @returns the titled section.
35
+ */
36
+ export declare function LongCacheSection({ route, api, t }: LongCacheSectionProps): ReactNode;
@@ -6,15 +6,28 @@
6
6
  * provider prefix through a plugin-owned data attribute.
7
7
  *
8
8
  * This module is the single place that decides which pane the menu is showing,
9
- * where each foreign body sits, and when each one retires. The two pane probes
10
- * look alike but answer different questions, and must NOT be merged:
9
+ * where each foreign body sits, and when each one retires. The pane probes look
10
+ * alike but answer different questions, and must NOT be merged:
11
11
  *
12
- * - the slider's probe — `[role="menuitemradio"]` — asks "did the official
13
- * drill-in replace my replica body?". The effort pane matches too, which
14
- * is fine: our body belongs to the root pane either way.
12
+ * - the surface probe — `role="group"` — asks "did the popover OPEN in the
13
+ * model list pane?". Upstream sets the surface role from the pane it shows
14
+ * (`role: pane === "model" ? "group" : "menu"`) and opens straight into the
15
+ * list whenever it cannot name the session's current model
16
+ * (`currentChoice === void 0`). That is the HISTORICAL-session shape — the
17
+ * saved selection no longer resolves in today's catalog, or the session's
18
+ * projection had not landed when the popover was first opened. This plugin
19
+ * owns that pane too, so those sessions get the replica switcher instead of
20
+ * the bare official list they used to be left with.
21
+ * - the slider's retire probe — `[role="menuitemradio"]` outside our own
22
+ * wrapper — asks "did the official drill-in replace my replica body?". It
23
+ * only governs surfaces that still carry `role="menu"` (the root pane and
24
+ * the effort pane on kernels that keep one role for every pane).
15
25
  * - the search's probe — `section[role="group"]` — asks "is there a
16
26
  * filterable model list here?". The effort pane has no groups, so a
17
27
  * role-based probe would mount a search box over a list it cannot filter.
28
+ * It is skipped entirely on a surface upstream opened in its model-list
29
+ * pane: that pane already carries the host's own search row, so a second
30
+ * box would only duplicate it (and filter a list the replica replaced).
18
31
  *
19
32
  * @module dsh-model-think-level/client/injection/composer-menu
20
33
  */
@@ -14,14 +14,42 @@
14
14
  *
15
15
  * @module dsh-model-think-level/client/injection/model-menu
16
16
  */
17
+ /**
18
+ * Whether the seat's popover is showing upstream's DRILLED-IN model list.
19
+ *
20
+ * Upstream derives the surface role from the pane (`role: pane === "model" ?
21
+ * "group" : "menu"`), so this single attribute answers "which pane did the
22
+ * popover open in?". It opens in the list pane whenever it cannot name the
23
+ * session's current model (`currentChoice === void 0`) — the HISTORICAL-session
24
+ * shape, where the saved selection no longer resolves in today's catalog (a
25
+ * provider or model id that was renamed or removed) or the session's projection
26
+ * had not landed when the popover was first opened.
27
+ *
28
+ * The distinction matters to injection, not just to discovery: in that pane the
29
+ * official list IS the switcher, so the plugin has to replace it to give the
30
+ * session the same two-row body a new session gets.
31
+ *
32
+ * @param surface - the element {@link findModelMenu} returned.
33
+ * @returns whether upstream is showing its model list rather than the root pane.
34
+ */
35
+ export declare function isDrilledModelPane(surface: HTMLElement): boolean;
17
36
  /**
18
37
  * The official composer model menu: the seat root's open popover.
19
38
  *
20
39
  * Shape-tolerant across kernels: newer kernels portal the menu to
21
40
  * document.body and link it from the seat trigger via aria-controls, while
22
41
  * older kernels render it inline right after the trigger. Both shapes keep
23
- * aria-haspopup="menu" on the trigger and role="menu" on the menu, so the
24
- * controls link is the primary route and the sibling check stays the fallback.
42
+ * aria-haspopup="menu" on the trigger, so the controls link is the primary
43
+ * route and the sibling check stays the fallback.
44
+ *
45
+ * The SURFACE role is NOT stable: upstream sets `role="menu"` on the root pane
46
+ * and `role="group"` while it shows the model list (see {@link isMenuSurface}).
47
+ * Requiring `role="menu"` therefore lost the seat exactly for the sessions that
48
+ * open straight into the model list — most visibly a HISTORICAL session, whose
49
+ * saved selection no longer resolves in the current catalog. Both roles are
50
+ * accepted here; what still has to hold is that the element IS the seat's
51
+ * `aria-controls` target (or its inline sibling), so no other surface's popover
52
+ * is ever mistaken for the model menu.
25
53
  *
26
54
  * The search NEVER leaves the composer card. When no card is mounted there is
27
55
  * no model seat, and answering with some other surface's menu is exactly the
@@ -12,7 +12,11 @@
12
12
  * `modelAdvanced` dictionary value: "Capacities"/容量 through 0.1.6-alpha.1,
13
13
  * "Model options"/模型选项 from 0.1.6-alpha.2); the editor is inserted into the
14
14
  * same disclosure container that holds the official context-window / max
15
- * tokens fields.
15
+ * tokens fields. A kernel that ships its OWN reasoning-levels group in that
16
+ * same disclosure (0.2.1-rc.2's `ModelReasoningEfforts`) would leave the row
17
+ * showing two controls for one declaration, so the official group is stood down
18
+ * on exactly the rows this editor owns — and handed back when the editor goes
19
+ * away. See {@link hideOfficialReasoning}.
16
20
  *
17
21
  * Because this walks the official page's rendered DOM (class names and
18
22
  * structure that the harness can change), the injector is defensive by
@@ -388,6 +392,49 @@ export interface AutofillFootprint {
388
392
  * position (the label's trailing number IS the position).
389
393
  */
390
394
  export declare function inputValueByLabel(card: HTMLElement, labels: readonly string[]): string;
395
+ /**
396
+ * The official page's own per-model reasoning-levels group inside this row's
397
+ * disclosure (0.2.1-rc.2's `ModelReasoningEfforts`), or undefined on a kernel
398
+ * that ships none.
399
+ *
400
+ * Matched the way every other anchor here is — by the official class-name stem,
401
+ * never by a kernel version. Every class in that subtree is a LONGER stem
402
+ * (`modelReasoningHead`, `modelReasoningLabel`, `modelReasoningRow`, …) and the
403
+ * group is the row's only such subtree, so the container's first match in
404
+ * document order is the group root: standing it down takes the official head,
405
+ * its switch and all of its level rows with it in one write.
406
+ */
407
+ export declare function officialReasoningOf(container: HTMLElement): HTMLElement | undefined;
408
+ /**
409
+ * Stand the official reasoning-levels group down for a row whose levels this
410
+ * plugin's own editor now owns.
411
+ *
412
+ * The host renders BOTH controls for one field — its own 推理等级 group beside
413
+ * this plugin's 思考等级 editor — which is two editors for the same declaration,
414
+ * and the plugin's is the one that stays: it is the surface that also carries
415
+ * the modality echo, the remembered level and the compat fields, none of which
416
+ * the official group knows about. A row whose document is not writable is
417
+ * covered too: the official group is disabled by that same state, so hiding it
418
+ * costs no editing path the plugin's read-only editor does not already stand in
419
+ * for.
420
+ *
421
+ * The hide is the element's OWN inline `display`, written only when it differs
422
+ * (compare-before-write, like every other DOM write here): the host renders this
423
+ * element from props that carry no `display`, so React never writes the property
424
+ * back, and no stylesheet of ours has to know the official class hash. The
425
+ * marker attribute is what later lets {@link showOfficialReasoning} tell a hide
426
+ * of ours from one the host wrote itself.
427
+ */
428
+ export declare function hideOfficialReasoning(container: HTMLElement): void;
429
+ /**
430
+ * Hand the official reasoning group back: the row's editor is going away, so the
431
+ * plugin no longer stands in for that control and must not leave the field
432
+ * hidden on the page the user still has open.
433
+ *
434
+ * Only a group THIS plugin stood down is restored — the marker attribute is what
435
+ * proves it — so an inline `display` the host wrote itself is left as it is.
436
+ */
437
+ export declare function showOfficialReasoning(container: HTMLElement): void;
391
438
  /**
392
439
  * The official input-types checkbox an image verdict belongs to, or undefined
393
440
  * when this row ships no such control (a legacy kernel) — or ships one whose
@@ -126,6 +126,15 @@ export declare const en: {
126
126
  headersConflictSiblings: string;
127
127
  headersError: string;
128
128
  headersNoRoute: string;
129
+ cacheTitle: string;
130
+ cacheRowLabel: string;
131
+ cacheHint: string;
132
+ cachePinned: string;
133
+ cacheUnavailable: string;
134
+ cacheSaved: string;
135
+ cacheInherited: string;
136
+ cacheError: string;
137
+ cacheReadOnly: string;
129
138
  providerReorderAria: string;
130
139
  providerReorderHint: string;
131
140
  providerToggleAria: string;
@@ -133,13 +133,69 @@ export interface RowWriteResult {
133
133
  * @returns one result per row, in the same order.
134
134
  */
135
135
  export declare function writeModelRows(api: RemoteApi, route: string, rows: readonly RowIntent[], describe?: () => Promise<SettingsJoin>, abort?: () => boolean): Promise<RowWriteResult[]>;
136
- /** One result of writing a provider's request headers. */
137
- export type ProviderHeadersReply = {
136
+ /** One result of writing a provider-level settings leaf. */
137
+ export type ProviderSettingReply = {
138
138
  ok: true;
139
139
  } | {
140
140
  ok: false;
141
141
  error: string;
142
142
  };
143
+ /** One result of writing a provider's request headers. */
144
+ export type ProviderHeadersReply = ProviderSettingReply;
145
+ /**
146
+ * The compat switch that suppresses long-cache retention on a route.
147
+ *
148
+ * `prompt_cache_key` / `prompt_cache_retention` are BODY fields, not headers, so
149
+ * no request-header entry can remove them; this compat flag is the switch the
150
+ * adapter's own request builder reads. Setting it on the route applies to every
151
+ * model of the route -- `resolveModelCompat` merges route-level compat under the
152
+ * per-model entries, and a model-level value still wins.
153
+ */
154
+ export declare const LONG_CACHE_FIELD = "supportsLongCacheRetention";
155
+ /**
156
+ * Wire protocols whose compat gate offers {@link LONG_CACHE_FIELD}.
157
+ *
158
+ * Mirrors the adapter's `COMPAT_GATES` table. A route-level compat entry the
159
+ * protocol does not offer is silently SKIPPED by `resolveModelCompat` (only a
160
+ * model-level one is refused), so this list decides whether the switch is worth
161
+ * showing rather than whether writing it is legal: on a route outside it the
162
+ * write would land in the document and change nothing on the wire.
163
+ */
164
+ export declare const LONG_CACHE_PROTOCOLS: readonly string[];
165
+ /** What one route's long-cache compat says, as the section seeds itself. */
166
+ export interface ProviderLongCache {
167
+ /** The wire protocol the route declares (undefined = the adapter's default). */
168
+ api?: string;
169
+ /** Whether the route's wire protocol takes the switch at all. */
170
+ offered: boolean;
171
+ /**
172
+ * The EFFECTIVE pin: the user layer's value when it names one, else the lower
173
+ * layer's. `false` = long cache disabled, `true` = pinned on, undefined = no
174
+ * layer pins it, so the adapter's own detection decides.
175
+ */
176
+ value?: boolean;
177
+ /**
178
+ * The pin a LOWER layer carries, ignoring the user layer's.
179
+ *
180
+ * The switch's OFF position has to know this: unsetting the user's key cannot
181
+ * clear a pin the profile patch below it wrote, so OFF must override that one
182
+ * explicitly instead of pretending an unset restored anything.
183
+ */
184
+ inherited?: boolean;
185
+ }
186
+ /**
187
+ * The RAW layers' long-cache pin for one route.
188
+ *
189
+ * Read per KEY, not per field: `compat` is a plain object, so the settings
190
+ * layers deep-merge it and a user layer that names one switch does not replace
191
+ * the base's other ones. Asking the leaf through both layers is therefore the
192
+ * same answer the adapter's merge reaches, while reading the resolved `value`
193
+ * would report a schema-materialized default as if the user had chosen it.
194
+ * @param namespace - the namespace view carrying the layers.
195
+ * @param route - the provider route key.
196
+ * @returns whether the protocol takes the switch, the effective pin, and the pin a lower layer carries on its own.
197
+ */
198
+ export declare function providerLongCacheOf(namespace: SettingsNamespaceView | undefined, route: string): ProviderLongCache;
143
199
  /**
144
200
  * The RAW layer's `headers` dict for one route, as the editor seeds its draft.
145
201
  *
@@ -174,6 +230,23 @@ export declare function providerHeadersOf(namespace: SettingsNamespaceView | und
174
230
  * @returns whether the write landed, and the refusal text when it did not.
175
231
  */
176
232
  export declare function writeProviderHeaders(api: RemoteApi, route: string, headers: Record<string, string>): Promise<ProviderHeadersReply>;
233
+ /**
234
+ * Write ONE route's long-cache pin through the live settings seam.
235
+ *
236
+ * A LEAF path op, not a whole-dict `set`: `compat` carries switches this plugin
237
+ * does not own (`supportsDeveloperRole` from auto-fill, a hand-written
238
+ * `thinkingFormat`…), and the settings layer's path write merges into the
239
+ * existing profile, so naming one key can only change that key. `undefined`
240
+ * restores inheritance with an `unset` — the switch then reports whatever the
241
+ * next layer says, which is the installed catalog's detection.
242
+ *
243
+ * The conflict discipline is {@link writeProviderHeaders}'s, for the same race.
244
+ * @param api - the settings Remote (plus the optional scope).
245
+ * @param route - the provider route key.
246
+ * @param value - `false` disables long cache, `true` pins it on, undefined inherits.
247
+ * @returns whether the write landed, and the refusal text when it did not.
248
+ */
249
+ export declare function writeProviderLongCache(api: RemoteApi, route: string, value: boolean | undefined): Promise<ProviderSettingReply>;
177
250
  /**
178
251
  * Whether this document declares the route: its RESOLVED providers map, or
179
252
  * either raw layer, holding the key itself (own key, never a prototype name).