dsh-thinking-levels 4.4.8 → 4.4.10

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,311 +1,311 @@
1
- # dsh-thinking-levels
2
-
3
- **Per-round thinking-level (`reasoning_effort`) control for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness): pick `Auto` (a mask) in the session model selector and the plugin schedules `low` / `high` / `max` from the recent tool-call history before submitting the API effort — or fix a wire level (`off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max`) manually. Cheap tool rounds stay cheap; heavy work never starves.**
4
-
5
- - [English README](./README.md)
6
- > **v0.7.0-beta.1 (2026-09-06): the short-circuit route is retired.** This release no longer depends on `dsh-llm-openai-completions` — custom-gateway fixes ride the official `llm-pi-ai` compat surface (requires **dsh ≥ v0.1.2-alpha.1**); keep the adapter plugin uninstalled. See the [CHANGELOG](./CHANGELOG.md).
7
-
8
- - [中文 README](./README.zh.md)
9
- - [日本語 README](./README.ja.md)
10
- - [한국어 README](./README.ko.md)
11
- - [README en français](./README.fr.md)
12
- - [Deutsche README](./README.de.md)
13
- - [README in italiano](./README.it.md)
14
- - [README на русском](./README.ru.md)
15
- - [README en español](./README.es.md)
16
- - [Installation guide](./INSTALL.md)
17
- - [中文安装指南](./INSTALL.zh.md)
18
- - [日本語インストールガイド](./INSTALL.ja.md)
19
- - [한국어 설치 안내](./INSTALL.ko.md)
20
- - [Guide d'installation en français](./INSTALL.fr.md)
21
- - [Installationsanleitung auf Deutsch](./INSTALL.de.md)
22
- - [Guida all'installazione in italiano](./INSTALL.it.md)
23
- - [Руководство по установке на русском](./INSTALL.ru.md)
24
- - [Guía de instalación en español](./INSTALL.es.md)
25
- - [Changelog](./CHANGELOG.md)
26
- - [日本語 changelog](./CHANGELOG.ja.md)
27
- - [한국어 changelog](./CHANGELOG.ko.md)
28
- - [Changelog en français](./CHANGELOG.fr.md)
29
- - [Changelog auf Deutsch](./CHANGELOG.de.md)
30
- - [Changelog in italiano](./CHANGELOG.it.md)
31
- - [Список изменений на русском](./CHANGELOG.ru.md)
32
- - [Changelog en español](./CHANGELOG.es.md)
33
-
34
- > **▼ DSH version support**
35
- >
36
- > This release (4.3.x) pins DSH hosts by the exact 14-term enumeration `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3` — each rc listed individually, no ranges or carets; 0.2.1 stable is not declared until it ships.
37
- >
38
- > | DSH version | Status | Notes |
39
- > | --- | --- | --- |
40
- > | ≥ 0.2.0-rc.1 | ✅ Supported | This release (4.0.x): same declarative settings surface (`.volatile()` schema fields rendered by the host; cross-plugin reads/writes through the `configForms` service), with the peer gate retargeted to the 0.2.0-rc segment |
41
- > | ≥ 0.1.7-rc.1 to < 0.2.0 | ✅ Supported | Use the 3.x line (3.4.3, npm dist-tag `dsh-0.1.7`): declarative settings — the host renders the Plugins form from the plugin's `.volatile()` schema fields; cross-plugin reads/writes go through the `configForms` service |
42
- > | < 0.1.7-rc.1 | ⚠️ Not supported | DSH 0.1.7 removed the imperative settings registration and the per-plugin card seat the earlier lines (3.0.x and below) relied on — stay on plugin 3.0.2 for 0.1.2–0.1.6 hosts. |
43
- >
44
- > The boundary is `0.1.7-rc.1`, where DSH removed the imperative settings registration (`settings.register` / `installSettingsSection`) and the client `settingsScope` service. Since that boundary the runtime-adjustable config fields are marked `.volatile()` in the schemastery schema, the host generates the settings form from that schema alone (no registration call, no client settings card), and the plugin reads the live values per request, driven by `loader/volatile-update`. The 3.1.x–3.4.x lines target the 0.1.7 declarative surface; the 4.0.x line is the same surface retargeted to the 0.2.0-rc segment.
45
-
46
- > **Version-range policy:** every compatibility line pins its host segment tightly. Lines targeting 0.1.x hosts follow `>=0.1.x-rc.1 <0.1.(x+1)-0` (3.1.x: `>=0.1.7-rc.1 <0.1.8-0`; 3.0.x: `>=0.1.5-alpha.1 <0.1.6-0`; 2.0.x: `>=0.1.2-alpha.1 <0.1.3-0`; 1.0.0-beta: `>=0.1.0-rc.8 <0.1.2-alpha.1`); lines targeting the 0.2.x segment follow `>=0.2.0-rc.1 <0.2.1-0` (4.0.x: `>=0.2.0-rc.1 <0.2.1-0`). No line ever declares an open upper bound, so a compatibility resolver can never match a plugin line against a newer host segment it was not built for. 0.4.0–0.6.0 carried no dsh peer declarations at all and are effectively compatibility-untyped — do not install them. Since the 4.2.x multi-line era, the 4.x line pins hosts with the exact per-rc enumeration above instead of a segment range — the range formulas describe the historical per-segment lines.
47
-
48
- > **Compatibility note:** Version `0.6.0` includes Japanese (`ja`) and Korean (`ko`) dictionaries and selector entries, but the current official DSH releases expose only `zh` and `en` through `LocaleRuntime`. On stock DSH, selecting `ja` or `ko` fails with `locale "<id>" is not registered`. These languages will work after official DSH adds the locale IDs. Advanced users can use a DSH fork that updates `packages/client/locale/src/locale-settings.ts` (`LOCALE_IDS`) and `packages/client/locale/src/client/index.ts` (`LOCALES` labels), together with the corresponding core dictionaries and tests, then rebuild and run the forked DSH. Changing this plugin alone cannot extend DSH's global locale list.
49
-
50
- In a multi-step tool chain, the model re-thinks before **every** tool call — and that thinking dominates the wall-clock time (a 50-step agent task can spend minutes reasoning between tools). `dsh-thinking-levels` plugs into the `agent/request` waterfall that dsh re-resolves for every step (registered with `prepend` so the session model-selection assembly cannot overwrite its decision) and injects a thinking level into the next model request.
51
-
52
- ## Preview
53
-
54
- Screenshots of the live UI (dsh web):
55
-
56
- <figure>
57
- <img width="460" alt="Model selector Auto dropdown injected by the plugin: levels Off / Low / High / Max / Auto, High currently selected, Auto highlighted — Auto is a mask, the plugin schedules low/high/max per step from the tool history." src="assets/官方模型的自动级别调整.png" />
58
- <figcaption>Native model selector gains <strong>Auto</strong> — pick it and the plugin schedules low/high/max per step instead of a fixed wire level.</figcaption>
59
- </figure>
60
-
61
- <figure>
62
- <img style="max-width:100%" alt="Thinking-level settings (3.0.x card shown): default level (auto scheduling), enable / allow-downgrade / allow-upgrade toggles, llm-pi-ai custom-provider model-capability table with the progressive per-model editor, and apply-to-all presets (Off/High/Max official DeepSeek style, Off/Low/Medium/High generic)." src="assets/自动思考级别配置.png" />
63
- <figcaption>Thinking-level settings, 3.0.x card (screenshot kept for reference). Since 3.1.0 / DSH 0.1.7 the level, enable and scheduler toggles render as a host-generated declarative form; the custom card and its llm-pi-ai capability editor were removed with the retired seat.</figcaption>
64
- </figure>
65
-
66
- <figure>
67
- <img style="max-width:100%" alt="Per-model capability editor for a custom openai-completions model (local-35b / Qwen3.6-35B-A3B), as shipped in the 3.0.x settings card: thinking model and vision enabled, support think effort off, thinking format qwen-chat-template (auto-filled); no takeover switch — the official compat flag lives on the provider row; context-window limit presets 64K/128K/256K/400K/512K/1M with a custom input." src="assets/自定义模型的思考接管-短路-上下文窗口限制.png" />
68
- <figcaption>Per-model capability card, 3.0.x (screenshot kept for reference). Since 3.1.0 / DSH 0.1.7 the capability editor ships no more; edit `llm-pi-ai` model capabilities through the official Models settings instead.</figcaption>
69
- </figure>
70
-
71
- ## Levels
72
-
73
- | Level | Meaning | Where |
74
- |---|---|---|
75
- | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
76
- | `on` | thinking enabled (toggle-only models only): sends `enable_thinking`, never a think effort | model selector / default level |
77
- | `minimal` | least effort (very light tasks) | model selector / default level |
78
- | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
79
- | `medium` | medium effort | model selector / default level |
80
- | `high` | the official default effort | model selector / default level |
81
- | `xhigh` | extra high effort | model selector / default level |
82
- | `max` | heavy work | model selector / default level |
83
- | `auto` | **mask**: schedule per step from the recent tool-call history, resolved to a wire level before submission | model selector (injected by the plugin) / default level |
84
-
85
- Wire-level facts (verified against the official DeepSeek docs and dsh's `llm-deepseek` adapter): `low` maps 1:1 on deepseek-v4-flash / v4-pro, while `medium` / `xhigh` collapse onto `high`. The adapter accepts `off | low | high | max` and rejects anything else with `UNSUPPORTED_REASONING_EFFORT` — `auto` is the plugin's mask layer, never sent to the API, always resolved to a concrete wire level before injection. `on` is **not** an effort level: it is advertised only by toggle-only models (Qwen3.6-style), and it only flips `enable_thinking` true — no `reasoning_effort` is sent; an effort-capable model never advertises `on`, so a manual `on` pick on one is stripped.
86
-
87
- ## Custom wire mapping
88
-
89
- For hand-declared `llm-pi-ai` models, map each level to the exact value your gateway expects (borrowed from dsh-thinking-effort): tick a level and enter its wire value, e.g. `high` → `ultra`. The mapping is stored as the model's `reasoningEfforts` table in the `llm-pi-ai` config, so the Composer selection `High` sends `ultra` to the gateway. Leaving `off` empty means "do not send".
90
-
91
- - Official preset: `Off / High / Max` (official DeepSeek style)
92
- - Generic preset: `Off / Low / Medium / High`
93
-
94
- > The visual editor for this mapping rode the plugin's settings card, which the DSH 0.1.7 migration removed (the seat no longer exists). Edit the `reasoningEfforts` table through the official Models settings surface instead — the host-side detection and injection read it live either way.
95
-
96
- ## Effort slider (per model line)
97
-
98
- The model panel's per-line effort `<select>` became a **segment slider**: click a line's effort chip (it shows the effective level, or *Provider default*) and a full-width slider expands under that line. The stop count adapts to what the model advertises — two-stop toggle-only models, the official `off/low/high/max` set, custom gateway wire values; `auto` (when the directory carries the mask) is pinned **leftmost**, then `off`/`on`, then the strength gradient, unknown wire values last.
99
-
100
- Since 4.4.0 the selector's own effort chip shows the **user intent**, not the scheduler's resolved level: with the intent `auto` the main label stays **Auto** and the level actually sent in the last step is demoted to a secondary hint (`→ low`). Note: while the model-UI takeover below is off, the *official* selector's chip keeps showing the last resolved level — that is host projection semantics the plugin cannot restyle.
101
-
102
- Interaction follows the approved dsh-reasoning-effort visual baseline: the thumb follows the pointer continuously and **snaps on release** (one route write per gesture), the plain thumb is pure white in every theme, the thumb stays fully visible at both endpoints, and ←/→/Home/End step stop-by-stop. The select's *Provider default* reset survives as the ↺ button of the slider row.
103
-
104
- DeepSeek lines (the official route, or any gateway model whose id/name says deepseek) run the **whale-girl runner** as the thumb: an 8-frame side-run strip, ping-pong looped (720 ms per direction at rest, 420 ms while dragging), frozen under `prefers-reduced-motion`. Every other model gets the plain knob.
105
-
106
- ## Model UI takeover (since 4.4.0)
107
-
108
- New setting `takeoverUi` (default **off**): the plugin no longer replaces the composer's model popup — search, grouping and loading stay with the shipped selector, and the `auto` mask still arrives through the server-side advertisement; official-model context editing lives on the settings card. Turning it on restores the ModelPanel takeover (per-line editors + popup search). Changes apply immediately — no reload needed.
109
-
110
- The strip is community whale-girl artwork sourced from [HanaAyane/dsh-reasoning-effort](https://github.com/HanaAyane/dsh-reasoning-effort) (`assets/chibi-runner-strip.png`); regenerate the inlined asset with `python tools/whale-mascot.py`.
111
-
112
- ## Context-window presets
113
-
114
- The composer tool-row quick control (next to the model/effort select) edits a **context window limit**: preset stops `64K / 128K / 256K / 400K / 512K / 1M`, a custom integer input, and a clear button. The value is written to the `llm-pi-ai` model entry `contextWindow` (integer `2000`–`1000000`) — or to the `llm-deepseek` entry for official DeepSeek models.
115
-
116
- Upstream, the harness consumes it through `resolveModelInfo(...).context.contextWindow` for compaction thresholds, context-overflow detection and context-pressure projections. Because `llm-pi-ai` re-reads the live config on every resolve and the compat sync does not block model discovery, a settings edit takes effect on the next request without a restart.
117
-
118
- The plugin config also accepts `models['provider/model'].contextWindow` as a validated (integer `2000`–`1000000`) declaration at the composition/config surface.
119
-
120
- ## Model-aware guard (v0.5.0)
121
-
122
- The plugin never sends a `reasoning_effort` to a model that does not advertise one. Custom
123
- openai-completions routes (e.g. a local Qwen3.6 without `reasoningEfforts`) are classified
124
- non-reasoning via `ctx.llm.resolveModelInfo`, and any effort — inherited or scheduled — is
125
- **stripped** instead of sent, so dsh's per-request `UNSUPPORTED_REASONING_EFFORT` rejection
126
- cannot fire. Unsupported fields are never passed to an API that cannot take them.
127
-
128
- Version behavior:
129
-
130
- | dsh version | `low` handling |
131
- |---|---|
132
- | rc.6 (old) | not native: the selector only shows it when a configurer-confirmed `models` override names it; the level is then advertised (selector + request validation) and passed through verbatim |
133
- | rc.7+ (new) | native: the plugin neither rewrites nor re-injects it; a manual `low` pick passes through unchanged |
134
-
135
- The auto scheduler may still pick `low` for supporting models — the capability guard above is
136
- what keeps it away from models that cannot take it.
137
-
138
- ## Model-selector Auto
139
-
140
- The session model selector (next to the model) now offers **Auto** after the wire levels (injected into the model-directory metadata by the plugin):
141
-
142
- | Model-selector pick | Behavior |
143
- |---|---|
144
- | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
145
- | `off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max` | **manual choice wins** — plugin does not intervene (`on` stays `on` on toggle-only models, never lifted to an effort; effort-capable models strip it) |
146
- | unset | the plugin's default level applies (below) |
147
-
148
- ## Auto scheduler
149
-
150
- The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
151
-
152
- | Recent tool calls | Level |
153
- |---|---|
154
- | none (fresh prompt, pure chat) | `low` |
155
- | ≥75% simple tools, small args, downgrades allowed | `low` |
156
- | mixed / heavy tools | `high` |
157
- | very heavy payloads, upgrades allowed | `max` |
158
-
159
- The scheduling policy is the same source as [dsh-tool-turbo](https://github.com/drscrewdriver/dsh-tool-turbo) (same simple-tool whitelist / payload thresholds / 75% ratio rule).
160
-
161
- **Where the samples come from (4.4.7+).** The scheduler folds `tool/call` events into a Session projection (`tlAutoSchedule`), so it sees real tool history on every host from 0.1.2-rc.1 on; the pre-4.4.7 `session.events` read only ever produced samples on 0.1.0-rc.8. The session's explicit pick is folded from `model/selection` events, so a level the host echoes back can never be mistaken for a manual choice. Known limitation: host `0.1.0-rc.8` exposes no `stateOf` on its projection registry (legacy plane contract), so that one line keeps the old array read — scheduling works there, the echo correction does not.
162
-
163
- ## Install
164
-
165
- See [INSTALL.md](./INSTALL.md) for the full official-CLI guide (profile discovery, upgrade, migration, verification, troubleshooting). Quick start:
166
-
167
- ```bash
168
- # 1. install the plugin into a profile from npm (web shown; any profile works)
169
- # (the web profile is a pnpm workspace root, so -w is required)
170
- dsh plugin --profile web add dsh-thinking-levels -w
171
- # GitHub alternative:
172
- # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
173
- # local-path alternative (no network needed):
174
- # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
175
-
176
- # 2. restart dsh web (a running instance does not hot-load new bundle layers)
177
- dsh web
178
- ```
179
-
180
- > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
181
- > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
182
- > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
183
-
184
- Manual `link:` registration (alternative to `dsh plugin add`):
185
-
186
- ```bash
187
- # ~/.dsh/profiles/web/package.json dependencies:
188
- # "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
189
- # ~/.dsh/profiles/web/cordis.patch.yml:
190
- # - insert:
191
- # - id: thinking-levels
192
- # name: dsh-thinking-levels
193
- cd ~/.dsh/profiles/web && pnpm install && dsh web
194
- ```
195
-
196
- ## Configuration
197
-
198
- Two surfaces share one schema:
199
-
200
- - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
201
- ```yaml
202
- config:
203
- level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — the default level when the session picks nothing
204
- allowDowngrade: true # let the scheduler drop below `high`
205
- allowUpgrade: false # forbid the scheduler lifting to `max`
206
- ```
207
- - **Runtime** — the plugin's `.volatile()` config fields (`enabled`, `level`, `allowDowngrade`, `allowUpgrade`): DSH 0.1.7 renders the Plugins settings form from the declared schema, and committed changes reach the plugin as live config references (`loader/volatile-update`) — they apply to the next model request, no restart needed. (`models` stays a configurer-level field: edit it in the profile composition.)
208
-
209
- Per-model capability overrides (`models`, keyed `provider/model`) confirm what auto-detection
210
- finds; the configurer has the final word:
211
-
212
- ```yaml
213
- config:
214
- level: auto
215
- models:
216
- llm-pi-ai/Qwen3.6-35B-A3B: # non-reasoning thinking model (thinking toggle + budget)
217
- vision: false
218
- thinking: true
219
- efforts: false # never send reasoning_effort (stripped at request time)
220
- llm-pi-ai/Qwen3.8-27B: # effort-capable model (rc.6-era adapter without low)
221
- efforts: [low, high] # confirm low → advertised in the selector + passed through
222
- ```
223
-
224
- > For Qwen thinking on/off + budget, configure the **llm-pi-ai** route instead:
225
- > `compat.thinkingFormat: qwen` (→ wire `enable_thinking` + `thinking_budget` via
226
- > `thinkingBudgets`), or `qwen-chat-template` (→ `chat_template_kwargs.enable_thinking`) for
227
- > effort models like Qwen3.8-27B.
228
-
229
- Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
230
-
231
- > Semantics: the model-selector pick outranks the plugin's default level. Pick `auto` (mask) → plugin schedules; pick a wire level → applied directly; pick nothing → the plugin's `level` default is used. `allowDowngrade` / `allowUpgrade` constrain `auto` scheduling only.
232
-
233
- ## Third-party transport takeover (three protocols)
234
-
235
- The settings card's **Third-party takeover** switch (「第三方接管」) adds a route to the
236
- `dsh-llm-openai-completions` transport's `providers` list. **The transport's name is
237
- legacy** — since the 4.4.x line it fronts three wire protocols, not just
238
- `openai-completions`: `openai-completions`, `openai-responses` and `anthropic`. When a
239
- route is taken over, its model requests are short-circuited through that transport
240
- (multimodal true-send, modality gate, prompt injection) and `llm-pi-ai` steps out.
241
-
242
- The per-level wire editor (`reasoningEfforts`) is **protocol-neutral** since 4.4.4: the
243
- host turns the table into pi-ai's `thinkingLevelMap`, which every protocol reads
244
- (Anthropic thinking budget, Responses reasoning effort, completions `reasoning_effort`
245
- string). The two completions-only compat switches (`支持 think effort` / `思考格式`)
246
- render *only* on `openai-completions` routes — elsewhere the host rejects them at write
247
- time, so they are absent from the DOM.
248
-
249
- > **Toggle-folding caveat (fixed in 4.4.5).** The Off/On collapse of a thinking model's selector is an
250
- > `openai-completions`-only behavior: it fires when a route is taken over **and** the
251
- > model carries a `reasoningEfforts` table **without** `compat.supportsReasoningEffort: true`.
252
- > That fold exists because pi-ai rejects a `reasoning_effort` string outside its fixed seven
253
- > levels — a completions-wire concern. On a Responses/Anthropic route the levels map natively
254
- > (thinking budget / reasoning-effort enum) and `supportsReasoningEffort` cannot be written at
255
- > all, so through 4.4.4 taking such a route over wrongly folded a multi-level table to Off/On.
256
- > Since 4.4.5 the fold additionally requires the route's `api` to be `openai-completions` (or
257
- > absent), so a taken-over Responses/Anthropic route keeps its full level set end to end.
258
-
259
- ## Official compat surface: the short-circuit tool is retired (0.7.0-beta.1)
260
-
261
- Once custom gateways (vLLM / LM Studio / self-hosted OpenAI-compatible proxies) declare
262
- thinking, this plugin writes the fixes into the **official `llm-pi-ai` compat surface**
263
- (introduced in dsh ≥ **v0.1.0-rc.8**, commit `884f7b9c41`) —
264
- [dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions)
265
- is no longer needed for the developer-role fix and should stay uninstalled unless you
266
- explicitly want its three-protocol takeover (see above):
267
-
268
- - Scans `llm-pi-ai.providers` for routes that are custom gateways **and** declare a
269
- `reasoningEfforts` table on any model (including `modelOverrides`), then writes:
270
- - route-level `compat.supportsDeveloperRole: false` — the system prompt goes out as
271
- `system`, fixing the vLLM / SGLang `Unexpected message role` 400;
272
- - model-level `compat.thinkingFormat: 'qwen-chat-template'` on toggle-style thinking rows
273
- (thinking table without row-level `supportsReasoningEffort`) — pi-ai then sends
274
- `chat_template_kwargs.enable_thinking` (bare vLLM servers ignore the top-level
275
- `enable_thinking` of the plain `qwen` format);
276
- - Writes go through the official settings channel (read → pure transform → whole-section
277
- `settings.update('llm-pi-ai', …)`), so dsh's schema validates the write **where it is
278
- written**: a dsh older than rc.8 rejects the fields with a log warning — no silent
279
- misconfiguration; explicit values on any layer are never clobbered;
280
- - Triggers on plugin start, `llm/adapters-updated`, and `llm-pi-ai` config changes — no
281
- manual config editing;
282
- - Response-side inline `<think>` splitting remains a **gateway concern**: bare vLLM needs
283
- `--reasoning-parser qwen3` (pi-ai parses only `reasoning_content` / `reasoning` /
284
- `reasoning_text`).
285
-
286
- # Dependency note
287
-
288
- The host half does **not** value-depend on `@deepseek-ai/dsh-settings` — since the DSH 0.1.7 line there is no settings registration at all: the settings form is generated by the host from the plugin's declared schemastery schema (`.volatile()` fields), and the client half talks to the `configForms` service provided by the dsh runtime. No need to install official packages into the profile manually. `dependencies` is just `@deepseek-ai/schemastery` (installed automatically with the package).
289
-
290
- ## Development
291
-
292
- ```bash
293
- npm run lint # eslint (typescript-eslint flat config)
294
- npm run typecheck # tsc --noEmit
295
- npm test # vitest — 46 tests
296
- ```
297
-
298
- Test coverage: level policy (manual pass-through incl. the extended levels, `on` clamping, auto scheduler, validation, simple-tool boundary), the model-capability guard (`reasoningEffortSupported`, `resolveEffortInjection` stripping/passthrough), session-event parsing (guards, window cap, malformed records), the config schema (defaults lockstep, out-of-band rejection, `models` overrides), and the official-compat sync (identification, explicit-value respect, identity idempotence, write-time schema gating).
299
-
300
-
301
- ## Pricing catalog (4.3.0+)
302
-
303
- Billing samples are priced at fold time from a builtin catalog (src/price-catalog.ts): 29 model entries x region. DeepSeek V4.1-Flash / V4-Flash / V4-Pro carry the official peak/off-peak pairs (Beijing 09:00-12:00 and 14:00-18:00 on workdays are peak; the 2026 State Council holiday/make-up table is applied, with make-up-workday weekends counted as workdays); GLM / Kimi / Qwen / Doubao / MiniMax / Ernie carry flat CN rates. Each entry prices three slots per million tokens — non-cached input, cache-hit input and output — with asOf + source annotations; currency follows the entry (¥ CNY, $ USD, no FX conversion). Overseas (USD) catalog slots are intentionally empty until official pages can be re-verified.
304
-
305
- Models outside the catalog fall to the defaultPricing setting (cn / global / custom / off, default off): "off" renders the billing popover as unpriced while token counters keep working — nothing is silently estimated any more.
306
-
307
- Semantics note: a pricing or policy change only affects samples booked after the change; the first time you open an old session right after upgrading, its cumulative ledger is refolded once against the current catalog.
308
-
309
- ## License
310
-
311
- MIT
1
+ # dsh-thinking-levels
2
+
3
+ **Per-round thinking-level (`reasoning_effort`) control for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness): pick `Auto` (a mask) in the session model selector and the plugin schedules `low` / `high` / `max` from the recent tool-call history before submitting the API effort — or fix a wire level (`off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max`) manually. Cheap tool rounds stay cheap; heavy work never starves.**
4
+
5
+ - [English README](./README.md)
6
+ > **v0.7.0-beta.1 (2026-09-06): the short-circuit route is retired.** This release no longer depends on `dsh-llm-openai-completions` — custom-gateway fixes ride the official `llm-pi-ai` compat surface (requires **dsh ≥ v0.1.2-alpha.1**); keep the adapter plugin uninstalled. See the [CHANGELOG](./CHANGELOG.md).
7
+
8
+ - [中文 README](./README.zh.md)
9
+ - [日本語 README](./README.ja.md)
10
+ - [한국어 README](./README.ko.md)
11
+ - [README en français](./README.fr.md)
12
+ - [Deutsche README](./README.de.md)
13
+ - [README in italiano](./README.it.md)
14
+ - [README на русском](./README.ru.md)
15
+ - [README en español](./README.es.md)
16
+ - [Installation guide](./INSTALL.md)
17
+ - [中文安装指南](./INSTALL.zh.md)
18
+ - [日本語インストールガイド](./INSTALL.ja.md)
19
+ - [한국어 설치 안내](./INSTALL.ko.md)
20
+ - [Guide d'installation en français](./INSTALL.fr.md)
21
+ - [Installationsanleitung auf Deutsch](./INSTALL.de.md)
22
+ - [Guida all'installazione in italiano](./INSTALL.it.md)
23
+ - [Руководство по установке на русском](./INSTALL.ru.md)
24
+ - [Guía de instalación en español](./INSTALL.es.md)
25
+ - [Changelog](./CHANGELOG.md)
26
+ - [日本語 changelog](./CHANGELOG.ja.md)
27
+ - [한국어 changelog](./CHANGELOG.ko.md)
28
+ - [Changelog en français](./CHANGELOG.fr.md)
29
+ - [Changelog auf Deutsch](./CHANGELOG.de.md)
30
+ - [Changelog in italiano](./CHANGELOG.it.md)
31
+ - [Список изменений на русском](./CHANGELOG.ru.md)
32
+ - [Changelog en español](./CHANGELOG.es.md)
33
+
34
+ > **▼ DSH version support**
35
+ >
36
+ > This release (4.3.x) pins DSH hosts by the exact 16-term enumeration `0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5` — each rc listed individually, no ranges or carets; 0.2.1 stable is not declared until it ships.
37
+ >
38
+ > | DSH version | Status | Notes |
39
+ > | --- | --- | --- |
40
+ > | ≥ 0.2.0-rc.1 | ✅ Supported | This release (4.0.x): same declarative settings surface (`.volatile()` schema fields rendered by the host; cross-plugin reads/writes through the `configForms` service), with the peer gate retargeted to the 0.2.0-rc segment |
41
+ > | ≥ 0.1.7-rc.1 to < 0.2.0 | ✅ Supported | Use the 3.x line (3.4.3, npm dist-tag `dsh-0.1.7`): declarative settings — the host renders the Plugins form from the plugin's `.volatile()` schema fields; cross-plugin reads/writes go through the `configForms` service |
42
+ > | < 0.1.7-rc.1 | ⚠️ Not supported | DSH 0.1.7 removed the imperative settings registration and the per-plugin card seat the earlier lines (3.0.x and below) relied on — stay on plugin 3.0.2 for 0.1.2–0.1.6 hosts. |
43
+ >
44
+ > The boundary is `0.1.7-rc.1`, where DSH removed the imperative settings registration (`settings.register` / `installSettingsSection`) and the client `settingsScope` service. Since that boundary the runtime-adjustable config fields are marked `.volatile()` in the schemastery schema, the host generates the settings form from that schema alone (no registration call, no client settings card), and the plugin reads the live values per request, driven by `loader/volatile-update`. The 3.1.x–3.4.x lines target the 0.1.7 declarative surface; the 4.0.x line is the same surface retargeted to the 0.2.0-rc segment.
45
+
46
+ > **Version-range policy:** every compatibility line pins its host segment tightly. Lines targeting 0.1.x hosts follow `>=0.1.x-rc.1 <0.1.(x+1)-0` (3.1.x: `>=0.1.7-rc.1 <0.1.8-0`; 3.0.x: `>=0.1.5-alpha.1 <0.1.6-0`; 2.0.x: `>=0.1.2-alpha.1 <0.1.3-0`; 1.0.0-beta: `>=0.1.0-rc.8 <0.1.2-alpha.1`); lines targeting the 0.2.x segment follow `>=0.2.0-rc.1 <0.2.1-0` (4.0.x: `>=0.2.0-rc.1 <0.2.1-0`). No line ever declares an open upper bound, so a compatibility resolver can never match a plugin line against a newer host segment it was not built for. 0.4.0–0.6.0 carried no dsh peer declarations at all and are effectively compatibility-untyped — do not install them. Since the 4.2.x multi-line era, the 4.x line pins hosts with the exact per-rc enumeration above instead of a segment range — the range formulas describe the historical per-segment lines.
47
+
48
+ > **Compatibility note:** Version `0.6.0` includes Japanese (`ja`) and Korean (`ko`) dictionaries and selector entries, but the current official DSH releases expose only `zh` and `en` through `LocaleRuntime`. On stock DSH, selecting `ja` or `ko` fails with `locale "<id>" is not registered`. These languages will work after official DSH adds the locale IDs. Advanced users can use a DSH fork that updates `packages/client/locale/src/locale-settings.ts` (`LOCALE_IDS`) and `packages/client/locale/src/client/index.ts` (`LOCALES` labels), together with the corresponding core dictionaries and tests, then rebuild and run the forked DSH. Changing this plugin alone cannot extend DSH's global locale list.
49
+
50
+ In a multi-step tool chain, the model re-thinks before **every** tool call — and that thinking dominates the wall-clock time (a 50-step agent task can spend minutes reasoning between tools). `dsh-thinking-levels` plugs into the `agent/request` waterfall that dsh re-resolves for every step (registered with `prepend` so the session model-selection assembly cannot overwrite its decision) and injects a thinking level into the next model request.
51
+
52
+ ## Preview
53
+
54
+ Screenshots of the live UI (dsh web):
55
+
56
+ <figure>
57
+ <img width="460" alt="Model selector Auto dropdown injected by the plugin: levels Off / Low / High / Max / Auto, High currently selected, Auto highlighted — Auto is a mask, the plugin schedules low/high/max per step from the tool history." src="assets/官方模型的自动级别调整.png" />
58
+ <figcaption>Native model selector gains <strong>Auto</strong> — pick it and the plugin schedules low/high/max per step instead of a fixed wire level.</figcaption>
59
+ </figure>
60
+
61
+ <figure>
62
+ <img style="max-width:100%" alt="Thinking-level settings (3.0.x card shown): default level (auto scheduling), enable / allow-downgrade / allow-upgrade toggles, llm-pi-ai custom-provider model-capability table with the progressive per-model editor, and apply-to-all presets (Off/High/Max official DeepSeek style, Off/Low/Medium/High generic)." src="assets/自动思考级别配置.png" />
63
+ <figcaption>Thinking-level settings, 3.0.x card (screenshot kept for reference). Since 3.1.0 / DSH 0.1.7 the level, enable and scheduler toggles render as a host-generated declarative form; the custom card and its llm-pi-ai capability editor were removed with the retired seat.</figcaption>
64
+ </figure>
65
+
66
+ <figure>
67
+ <img style="max-width:100%" alt="Per-model capability editor for a custom openai-completions model (local-35b / Qwen3.6-35B-A3B), as shipped in the 3.0.x settings card: thinking model and vision enabled, support think effort off, thinking format qwen-chat-template (auto-filled); no takeover switch — the official compat flag lives on the provider row; context-window limit presets 64K/128K/256K/400K/512K/1M with a custom input." src="assets/自定义模型的思考接管-短路-上下文窗口限制.png" />
68
+ <figcaption>Per-model capability card, 3.0.x (screenshot kept for reference). Since 3.1.0 / DSH 0.1.7 the capability editor ships no more; edit `llm-pi-ai` model capabilities through the official Models settings instead.</figcaption>
69
+ </figure>
70
+
71
+ ## Levels
72
+
73
+ | Level | Meaning | Where |
74
+ |---|---|---|
75
+ | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
76
+ | `on` | thinking enabled (toggle-only models only): sends `enable_thinking`, never a think effort | model selector / default level |
77
+ | `minimal` | least effort (very light tasks) | model selector / default level |
78
+ | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
79
+ | `medium` | medium effort | model selector / default level |
80
+ | `high` | the official default effort | model selector / default level |
81
+ | `xhigh` | extra high effort | model selector / default level |
82
+ | `max` | heavy work | model selector / default level |
83
+ | `auto` | **mask**: schedule per step from the recent tool-call history, resolved to a wire level before submission | model selector (injected by the plugin) / default level |
84
+
85
+ Wire-level facts (verified against the official DeepSeek docs and dsh's `llm-deepseek` adapter): `low` maps 1:1 on deepseek-v4-flash / v4-pro, while `medium` / `xhigh` collapse onto `high`. The adapter accepts `off | low | high | max` and rejects anything else with `UNSUPPORTED_REASONING_EFFORT` — `auto` is the plugin's mask layer, never sent to the API, always resolved to a concrete wire level before injection. `on` is **not** an effort level: it is advertised only by toggle-only models (Qwen3.6-style), and it only flips `enable_thinking` true — no `reasoning_effort` is sent; an effort-capable model never advertises `on`, so a manual `on` pick on one is stripped.
86
+
87
+ ## Custom wire mapping
88
+
89
+ For hand-declared `llm-pi-ai` models, map each level to the exact value your gateway expects (borrowed from dsh-thinking-effort): tick a level and enter its wire value, e.g. `high` → `ultra`. The mapping is stored as the model's `reasoningEfforts` table in the `llm-pi-ai` config, so the Composer selection `High` sends `ultra` to the gateway. Leaving `off` empty means "do not send".
90
+
91
+ - Official preset: `Off / High / Max` (official DeepSeek style)
92
+ - Generic preset: `Off / Low / Medium / High`
93
+
94
+ > The visual editor for this mapping rode the plugin's settings card, which the DSH 0.1.7 migration removed (the seat no longer exists). Edit the `reasoningEfforts` table through the official Models settings surface instead — the host-side detection and injection read it live either way.
95
+
96
+ ## Effort slider (per model line)
97
+
98
+ The model panel's per-line effort `<select>` became a **segment slider**: click a line's effort chip (it shows the effective level, or *Provider default*) and a full-width slider expands under that line. The stop count adapts to what the model advertises — two-stop toggle-only models, the official `off/low/high/max` set, custom gateway wire values; `auto` (when the directory carries the mask) is pinned **leftmost**, then `off`/`on`, then the strength gradient, unknown wire values last.
99
+
100
+ Since 4.4.0 the selector's own effort chip shows the **user intent**, not the scheduler's resolved level: with the intent `auto` the main label stays **Auto** and the level actually sent in the last step is demoted to a secondary hint (`→ low`). Note: while the model-UI takeover below is off, the *official* selector's chip keeps showing the last resolved level — that is host projection semantics the plugin cannot restyle.
101
+
102
+ Interaction follows the approved dsh-reasoning-effort visual baseline: the thumb follows the pointer continuously and **snaps on release** (one route write per gesture), the plain thumb is pure white in every theme, the thumb stays fully visible at both endpoints, and ←/→/Home/End step stop-by-stop. The select's *Provider default* reset survives as the ↺ button of the slider row.
103
+
104
+ DeepSeek lines (the official route, or any gateway model whose id/name says deepseek) run the **whale-girl runner** as the thumb: an 8-frame side-run strip, ping-pong looped (720 ms per direction at rest, 420 ms while dragging), frozen under `prefers-reduced-motion`. Every other model gets the plain knob.
105
+
106
+ ## Model UI takeover (since 4.4.0)
107
+
108
+ New setting `takeoverUi` (default **off**): the plugin no longer replaces the composer's model popup — search, grouping and loading stay with the shipped selector, and the `auto` mask still arrives through the server-side advertisement; official-model context editing lives on the settings card. Turning it on restores the ModelPanel takeover (per-line editors + popup search). Changes apply immediately — no reload needed.
109
+
110
+ The strip is community whale-girl artwork sourced from [HanaAyane/dsh-reasoning-effort](https://github.com/HanaAyane/dsh-reasoning-effort) (`assets/chibi-runner-strip.png`); regenerate the inlined asset with `python tools/whale-mascot.py`.
111
+
112
+ ## Context-window presets
113
+
114
+ The composer tool-row quick control (next to the model/effort select) edits a **context window limit**: preset stops `64K / 128K / 256K / 400K / 512K / 1M`, a custom integer input, and a clear button. The value is written to the `llm-pi-ai` model entry `contextWindow` (integer `2000`–`1000000`) — or to the `llm-deepseek` entry for official DeepSeek models.
115
+
116
+ Upstream, the harness consumes it through `resolveModelInfo(...).context.contextWindow` for compaction thresholds, context-overflow detection and context-pressure projections. Because `llm-pi-ai` re-reads the live config on every resolve and the compat sync does not block model discovery, a settings edit takes effect on the next request without a restart.
117
+
118
+ The plugin config also accepts `models['provider/model'].contextWindow` as a validated (integer `2000`–`1000000`) declaration at the composition/config surface.
119
+
120
+ ## Model-aware guard (v0.5.0)
121
+
122
+ The plugin never sends a `reasoning_effort` to a model that does not advertise one. Custom
123
+ openai-completions routes (e.g. a local Qwen3.6 without `reasoningEfforts`) are classified
124
+ non-reasoning via `ctx.llm.resolveModelInfo`, and any effort — inherited or scheduled — is
125
+ **stripped** instead of sent, so dsh's per-request `UNSUPPORTED_REASONING_EFFORT` rejection
126
+ cannot fire. Unsupported fields are never passed to an API that cannot take them.
127
+
128
+ Version behavior:
129
+
130
+ | dsh version | `low` handling |
131
+ |---|---|
132
+ | rc.6 (old) | not native: the selector only shows it when a configurer-confirmed `models` override names it; the level is then advertised (selector + request validation) and passed through verbatim |
133
+ | rc.7+ (new) | native: the plugin neither rewrites nor re-injects it; a manual `low` pick passes through unchanged |
134
+
135
+ The auto scheduler may still pick `low` for supporting models — the capability guard above is
136
+ what keeps it away from models that cannot take it.
137
+
138
+ ## Model-selector Auto
139
+
140
+ The session model selector (next to the model) now offers **Auto** after the wire levels (injected into the model-directory metadata by the plugin):
141
+
142
+ | Model-selector pick | Behavior |
143
+ |---|---|
144
+ | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
145
+ | `off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max` | **manual choice wins** — plugin does not intervene (`on` stays `on` on toggle-only models, never lifted to an effort; effort-capable models strip it) |
146
+ | unset | the plugin's default level applies (below) |
147
+
148
+ ## Auto scheduler
149
+
150
+ The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
151
+
152
+ | Recent tool calls | Level |
153
+ |---|---|
154
+ | none (fresh prompt, pure chat) | `low` |
155
+ | ≥75% simple tools, small args, downgrades allowed | `low` |
156
+ | mixed / heavy tools | `high` |
157
+ | very heavy payloads, upgrades allowed | `max` |
158
+
159
+ The scheduling policy is the same source as [dsh-tool-turbo](https://github.com/drscrewdriver/dsh-tool-turbo) (same simple-tool whitelist / payload thresholds / 75% ratio rule).
160
+
161
+ **Where the samples come from (4.4.7+).** The scheduler folds `tool/call` events into a Session projection (`tlAutoSchedule`), so it sees real tool history on every host from 0.1.2-rc.1 on; the pre-4.4.7 `session.events` read only ever produced samples on 0.1.0-rc.8. The session's explicit pick is folded from `model/selection` events, so a level the host echoes back can never be mistaken for a manual choice. Known limitation: host `0.1.0-rc.8` exposes no `stateOf` on its projection registry (legacy plane contract), so that one line keeps the old array read — scheduling works there, the echo correction does not.
162
+
163
+ ## Install
164
+
165
+ See [INSTALL.md](./INSTALL.md) for the full official-CLI guide (profile discovery, upgrade, migration, verification, troubleshooting). Quick start:
166
+
167
+ ```bash
168
+ # 1. install the plugin into a profile from npm (web shown; any profile works)
169
+ # (the web profile is a pnpm workspace root, so -w is required)
170
+ dsh plugin --profile web add dsh-thinking-levels -w
171
+ # GitHub alternative:
172
+ # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
173
+ # local-path alternative (no network needed):
174
+ # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
175
+
176
+ # 2. restart dsh web (a running instance does not hot-load new bundle layers)
177
+ dsh web
178
+ ```
179
+
180
+ > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
181
+ > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
182
+ > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
183
+
184
+ Manual `link:` registration (alternative to `dsh plugin add`):
185
+
186
+ ```bash
187
+ # ~/.dsh/profiles/web/package.json dependencies:
188
+ # "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
189
+ # ~/.dsh/profiles/web/cordis.patch.yml:
190
+ # - insert:
191
+ # - id: thinking-levels
192
+ # name: dsh-thinking-levels
193
+ cd ~/.dsh/profiles/web && pnpm install && dsh web
194
+ ```
195
+
196
+ ## Configuration
197
+
198
+ Two surfaces share one schema:
199
+
200
+ - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
201
+ ```yaml
202
+ config:
203
+ level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — the default level when the session picks nothing
204
+ allowDowngrade: true # let the scheduler drop below `high`
205
+ allowUpgrade: false # forbid the scheduler lifting to `max`
206
+ ```
207
+ - **Runtime** — the plugin's `.volatile()` config fields (`enabled`, `level`, `allowDowngrade`, `allowUpgrade`): DSH 0.1.7 renders the Plugins settings form from the declared schema, and committed changes reach the plugin as live config references (`loader/volatile-update`) — they apply to the next model request, no restart needed. (`models` stays a configurer-level field: edit it in the profile composition.)
208
+
209
+ Per-model capability overrides (`models`, keyed `provider/model`) confirm what auto-detection
210
+ finds; the configurer has the final word:
211
+
212
+ ```yaml
213
+ config:
214
+ level: auto
215
+ models:
216
+ llm-pi-ai/Qwen3.6-35B-A3B: # non-reasoning thinking model (thinking toggle + budget)
217
+ vision: false
218
+ thinking: true
219
+ efforts: false # never send reasoning_effort (stripped at request time)
220
+ llm-pi-ai/Qwen3.8-27B: # effort-capable model (rc.6-era adapter without low)
221
+ efforts: [low, high] # confirm low → advertised in the selector + passed through
222
+ ```
223
+
224
+ > For Qwen thinking on/off + budget, configure the **llm-pi-ai** route instead:
225
+ > `compat.thinkingFormat: qwen` (→ wire `enable_thinking` + `thinking_budget` via
226
+ > `thinkingBudgets`), or `qwen-chat-template` (→ `chat_template_kwargs.enable_thinking`) for
227
+ > effort models like Qwen3.8-27B.
228
+
229
+ Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
230
+
231
+ > Semantics: the model-selector pick outranks the plugin's default level. Pick `auto` (mask) → plugin schedules; pick a wire level → applied directly; pick nothing → the plugin's `level` default is used. `allowDowngrade` / `allowUpgrade` constrain `auto` scheduling only.
232
+
233
+ ## Third-party transport takeover (three protocols)
234
+
235
+ The settings card's **Third-party takeover** switch (「第三方接管」) adds a route to the
236
+ `dsh-llm-openai-completions` transport's `providers` list. **The transport's name is
237
+ legacy** — since the 4.4.x line it fronts three wire protocols, not just
238
+ `openai-completions`: `openai-completions`, `openai-responses` and `anthropic`. When a
239
+ route is taken over, its model requests are short-circuited through that transport
240
+ (multimodal true-send, modality gate, prompt injection) and `llm-pi-ai` steps out.
241
+
242
+ The per-level wire editor (`reasoningEfforts`) is **protocol-neutral** since 4.4.4: the
243
+ host turns the table into pi-ai's `thinkingLevelMap`, which every protocol reads
244
+ (Anthropic thinking budget, Responses reasoning effort, completions `reasoning_effort`
245
+ string). The two completions-only compat switches (`支持 think effort` / `思考格式`)
246
+ render *only* on `openai-completions` routes — elsewhere the host rejects them at write
247
+ time, so they are absent from the DOM.
248
+
249
+ > **Toggle-folding caveat (fixed in 4.4.5).** The Off/On collapse of a thinking model's selector is an
250
+ > `openai-completions`-only behavior: it fires when a route is taken over **and** the
251
+ > model carries a `reasoningEfforts` table **without** `compat.supportsReasoningEffort: true`.
252
+ > That fold exists because pi-ai rejects a `reasoning_effort` string outside its fixed seven
253
+ > levels — a completions-wire concern. On a Responses/Anthropic route the levels map natively
254
+ > (thinking budget / reasoning-effort enum) and `supportsReasoningEffort` cannot be written at
255
+ > all, so through 4.4.4 taking such a route over wrongly folded a multi-level table to Off/On.
256
+ > Since 4.4.5 the fold additionally requires the route's `api` to be `openai-completions` (or
257
+ > absent), so a taken-over Responses/Anthropic route keeps its full level set end to end.
258
+
259
+ ## Official compat surface: the short-circuit tool is retired (0.7.0-beta.1)
260
+
261
+ Once custom gateways (vLLM / LM Studio / self-hosted OpenAI-compatible proxies) declare
262
+ thinking, this plugin writes the fixes into the **official `llm-pi-ai` compat surface**
263
+ (introduced in dsh ≥ **v0.1.0-rc.8**, commit `884f7b9c41`) —
264
+ [dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions)
265
+ is no longer needed for the developer-role fix and should stay uninstalled unless you
266
+ explicitly want its three-protocol takeover (see above):
267
+
268
+ - Scans `llm-pi-ai.providers` for routes that are custom gateways **and** declare a
269
+ `reasoningEfforts` table on any model (including `modelOverrides`), then writes:
270
+ - route-level `compat.supportsDeveloperRole: false` — the system prompt goes out as
271
+ `system`, fixing the vLLM / SGLang `Unexpected message role` 400;
272
+ - model-level `compat.thinkingFormat: 'qwen-chat-template'` on toggle-style thinking rows
273
+ (thinking table without row-level `supportsReasoningEffort`) — pi-ai then sends
274
+ `chat_template_kwargs.enable_thinking` (bare vLLM servers ignore the top-level
275
+ `enable_thinking` of the plain `qwen` format);
276
+ - Writes go through the official settings channel (read → pure transform → whole-section
277
+ `settings.update('llm-pi-ai', …)`), so dsh's schema validates the write **where it is
278
+ written**: a dsh older than rc.8 rejects the fields with a log warning — no silent
279
+ misconfiguration; explicit values on any layer are never clobbered;
280
+ - Triggers on plugin start, `llm/adapters-updated`, and `llm-pi-ai` config changes — no
281
+ manual config editing;
282
+ - Response-side inline `<think>` splitting remains a **gateway concern**: bare vLLM needs
283
+ `--reasoning-parser qwen3` (pi-ai parses only `reasoning_content` / `reasoning` /
284
+ `reasoning_text`).
285
+
286
+ # Dependency note
287
+
288
+ The host half does **not** value-depend on `@deepseek-ai/dsh-settings` — since the DSH 0.1.7 line there is no settings registration at all: the settings form is generated by the host from the plugin's declared schemastery schema (`.volatile()` fields), and the client half talks to the `configForms` service provided by the dsh runtime. No need to install official packages into the profile manually. `dependencies` is just `@deepseek-ai/schemastery` (installed automatically with the package).
289
+
290
+ ## Development
291
+
292
+ ```bash
293
+ npm run lint # eslint (typescript-eslint flat config)
294
+ npm run typecheck # tsc --noEmit
295
+ npm test # vitest — 46 tests
296
+ ```
297
+
298
+ Test coverage: level policy (manual pass-through incl. the extended levels, `on` clamping, auto scheduler, validation, simple-tool boundary), the model-capability guard (`reasoningEffortSupported`, `resolveEffortInjection` stripping/passthrough), session-event parsing (guards, window cap, malformed records), the config schema (defaults lockstep, out-of-band rejection, `models` overrides), and the official-compat sync (identification, explicit-value respect, identity idempotence, write-time schema gating).
299
+
300
+
301
+ ## Pricing catalog (4.3.0+)
302
+
303
+ Billing samples are priced at fold time from a builtin catalog (src/price-catalog.ts): 29 model entries x region. DeepSeek V4.1-Flash / V4-Flash / V4-Pro carry the official peak/off-peak pairs (Beijing 09:00-12:00 and 14:00-18:00 on workdays are peak; the 2026 State Council holiday/make-up table is applied, with make-up-workday weekends counted as workdays); GLM / Kimi / Qwen / Doubao / MiniMax / Ernie carry flat CN rates. Each entry prices three slots per million tokens — non-cached input, cache-hit input and output — with asOf + source annotations; currency follows the entry (¥ CNY, $ USD, no FX conversion). Overseas (USD) catalog slots are intentionally empty until official pages can be re-verified.
304
+
305
+ Models outside the catalog fall to the defaultPricing setting (cn / global / custom / off, default off): "off" renders the billing popover as unpriced while token counters keep working — nothing is silently estimated any more.
306
+
307
+ Semantics note: a pricing or policy change only affects samples booked after the change; the first time you open an old session right after upgrading, its cumulative ledger is refolded once against the current catalog.
308
+
309
+ ## License
310
+
311
+ MIT