dsh-thinking-levels 0.2.1 → 0.3.1

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,26 +1,36 @@
1
1
  # dsh-thinking-levels
2
2
 
3
- **Per-round thinking-level (`reasoning_effort`) control for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness): five levels — `off` / `low` / `high` / `max` for manual control, plus an `auto` scheduler that keeps cheap tool rounds cheap and never starves heavy work.**
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` / `low` / `high` / `max`) manually. Cheap tool rounds stay cheap; heavy work never starves.**
4
4
 
5
5
  [中文文档](./README.zh.md) · English
6
6
 
7
- 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, and injects a thinking level into the next model request.
7
+ 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.
8
8
 
9
9
  ## Levels
10
10
 
11
- | Level | Meaning |
12
- |---|---|
13
- | `off` | thinking disabled (manual only — never auto-picked) |
14
- | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) |
15
- | `high` | the official default effort |
16
- | `max` | heavy work |
17
- | `auto` | schedule per step from the recent tool-call history |
11
+ | Level | Meaning | Where |
12
+ |---|---|---|
13
+ | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
14
+ | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
15
+ | `high` | the official default effort | model selector / default level |
16
+ | `max` | heavy work | model selector / default level |
17
+ | `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 |
18
+
19
+ 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.
18
20
 
19
- 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` — this plugin validates the configured level before injecting, fail-loud.
21
+ ## Model-selector Auto
22
+
23
+ The session model selector (next to the model) now offers **Auto** after `Off / Low / High / Max` (injected into the model-directory metadata by the plugin):
24
+
25
+ | Model-selector pick | Behavior |
26
+ |---|---|
27
+ | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
28
+ | `off` / `low` / `high` / `max` | **manual choice wins** — plugin does not intervene |
29
+ | unset | the plugin's default level applies (below) |
20
30
 
21
31
  ## Auto scheduler
22
32
 
23
- The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`, and it always resolves to a wire level before injecting.
33
+ The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
24
34
 
25
35
  | Recent tool calls | Level |
26
36
  |---|---|
@@ -29,20 +39,27 @@ The hub is `high` (the official default). `auto` schedules between `low` / `high
29
39
  | mixed / heavy tools | `high` |
30
40
  | very heavy payloads, upgrades allowed | `max` |
31
41
 
42
+ 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).
43
+
32
44
  ## Install
33
45
 
34
46
  ```bash
35
- # 1. install the plugin into a profile from GitHub (web shown; any profile works)
47
+ # 1. install the plugin into a profile from npm (web shown; any profile works)
36
48
  # (the web profile is a pnpm workspace root, so -w is required)
37
- dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
38
- # local-path alternative (no network needed, no -w outside workspace roots):
49
+ dsh plugin --profile web add dsh-thinking-levels -w
50
+ # GitHub alternative:
51
+ # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
52
+ # local-path alternative (no network needed):
39
53
  # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
40
54
 
41
- # 2. restart dsh web
42
- # (a running instance does not hot-load new bundle layers)
55
+ # 2. restart dsh web (a running instance does not hot-load new bundle layers)
43
56
  dsh web
44
57
  ```
45
58
 
59
+ > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
60
+ > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
61
+ > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
62
+
46
63
  Manual `link:` registration (alternative to `dsh plugin add`):
47
64
 
48
65
  ```bash
@@ -62,14 +79,24 @@ Two surfaces share one schema:
62
79
  - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
63
80
  ```yaml
64
81
  config:
65
- level: high # off | low | high | max | auto
66
- allowDowngrade: false # forbid the scheduler dropping below `high`
82
+ level: auto # off | low | high | max | auto — the default level when the session picks nothing
83
+ allowDowngrade: true # let the scheduler drop below `high`
67
84
  allowUpgrade: false # forbid the scheduler lifting to `max`
68
85
  ```
69
- - **Runtime** — the dsh-settings namespace `thinking-levels` (`level`, `allowDowngrade`, `allowUpgrade`, `enabled`): changes apply to the next model request, no restart needed.
86
+ - **Runtime** — the dsh-settings namespace `thinking-levels` (`level`, `allowDowngrade`, `allowUpgrade`, `enabled`): changes apply to the next model request, no restart needed. A visual editor is available under Settings → Plugins → configurable plugins.
70
87
 
71
88
  Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false }`.
72
89
 
90
+ > Semantics: the model-selector pick outranks the plugin's default level. Pick `auto` (mask) → plugin schedules; pick `off/low/high/max` → applied directly; pick nothing → the plugin's `level` default is used. `allowDowngrade` / `allowUpgrade` constrain `auto` scheduling only.
91
+
92
+ ## Dependency note
93
+
94
+ The host half value-imports `@deepseek-ai/dsh-settings` (an official package absent from the profile's hoisted node_modules by design — it resolves from the dsh global install). If the plugin shows as disabled/unmounted in the plugin list, install the official dependency into the profile:
95
+
96
+ ```bash
97
+ dsh plugin --profile web add @deepseek-ai/dsh-settings@^0.1.0-rc.7 -w
98
+ ```
99
+
73
100
  ## Development
74
101
 
75
102
  ```bash
package/README.zh.md CHANGED
@@ -1,26 +1,36 @@
1
1
  # dsh-thinking-levels
2
2
 
3
- **为 [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness) 提供按轮次的思考档位(`reasoning_effort`)控制:`off` / `low` / `high` / `max` 四档手动固定,外加 `auto` 自动调度——让廉价工具轮次保持廉价,同时绝不让重任务缺少推理。**
3
+ **为 [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness) 提供按轮次的思考档位(`reasoning_effort`)控制:在会话模型选择器中可选 `Auto`(mask)——由插件按工具调用历史自动在 `low` / `high` / `max` 间调度后提交 API;也可手动固定 `off` / `low` / `high` / `max`,让廉价工具轮次保持廉价,同时绝不让重任务缺少推理。**
4
4
 
5
5
  [中文文档](./README.zh.md) · English
6
6
 
7
- 在多步工具链任务中,模型在**每一次工具调用前**都会重新思考——而这个思考过程占据了绝大部分墙钟时间(一个 50 步的 agent 任务可能在工具之间花费数分钟思考)。`dsh-thinking-levels` 接入 dsh 每一步都会重新解析的 `agent/request` waterfall,向下一次模型请求注入思考档位。
7
+ 在多步工具链任务中,模型在**每一次工具调用前**都会重新思考——而这个思考过程占据了绝大部分墙钟时间(一个 50 步的 agent 任务可能在工具之间花费数分钟思考)。`dsh-thinking-levels` 接入 dsh 每一步都会重新解析的 `agent/request` waterfall(以 `prepend` 置于最外层,避免被会话模型选择覆盖),向下一次模型请求注入思考档位。
8
8
 
9
9
  ## 档位
10
10
 
11
- | 档位 | 含义 |
12
- |---|---|
13
- | `off` | 关闭思考(仅手动选择,自动调度永不选用) |
14
- | `low` | 手动低档,对应简单对话任务(廉价轮次保持廉价) |
15
- | `high` | 官方默认档位 |
16
- | `max` | 重任务 |
17
- | `auto` | 依据最近的工具调用历史逐轮调度 |
11
+ | 档位 | 含义 | 位置 |
12
+ |---|---|---|
13
+ | `off` | 关闭思考(仅手动选择,自动调度永不选用) | 模型选择器 / 默认档位 |
14
+ | `low` | 手动低档,对应简单对话任务(廉价轮次保持廉价) | 模型选择器 / 默认档位 |
15
+ | `high` | 官方默认档位 | 模型选择器 / 默认档位 |
16
+ | `max` | 重任务 | 模型选择器 / 默认档位 |
17
+ | `auto` | **mask**:按最近的工具调用历史逐轮调度,提交 API 前解析为具体档位 | 模型选择器(由插件注入元数据)/ 默认档位 |
18
+
19
+ 线缆档位事实(对照官方 DeepSeek 文档与 dsh `llm-deepseek` 适配器核实):deepseek-v4-flash / v4-pro 上 `low` 1:1 生效,`medium` / `xhigh` 折叠到 `high`。适配器只接受 `off | low | high | max`,其他值抛 `UNSUPPORTED_REASONING_EFFORT`——`auto` 是插件的 mask 层,永不直接发送给 API,注入前必然解析为具体线缆档位。
18
20
 
19
- 线缆档位事实(对照官方 DeepSeek 文档与 dsh `llm-deepseek` 适配器核实):deepseek-v4-flash / v4-pro 上 `low` 1:1 生效,`medium` / `xhigh` 折叠到 `high`。适配器只接受 `off | low | high | max`,其他值抛 `UNSUPPORTED_REASONING_EFFORT`——本插件在注入前 fail-loud 校验配置档位。
21
+ ## 模型选择器 Auto
22
+
23
+ 会话界面模型选择器(模型旁)现在提供 **Auto** 档位(由插件注入模型目录元数据,位于 `Off / Low / High / Max` 之后):
24
+
25
+ | 模型选择器选择 | 行为 |
26
+ |---|---|
27
+ | **Auto** | 插件按工具调用历史 + 升降档开关调度,解析成 `low` / `high` / `max` 后提交 API |
28
+ | `off` / `low` / `high` / `max` | **尊重手动选择**,插件不介入 |
29
+ | 未选择 | 使用插件的默认档位(见下) |
20
30
 
21
31
  ## 自动调度
22
32
 
23
- 中枢为 `high`(官方默认)。`auto` 只在 `low` / `high` / `max` 之间调度;永不选 `off`,且注入前必然解析为具体线缆档位。
33
+ 中枢为 `high`(官方默认)。`auto` 只在 `low` / `high` / `max` 之间调度;永不选 `off`。
24
34
 
25
35
  | 最近的工具调用 | 档位 |
26
36
  |---|---|
@@ -29,20 +39,27 @@
29
39
  | 混合 / 重工具 | `high` |
30
40
  | 超大载荷、允许升级 | `max` |
31
41
 
42
+ 调度策略与 [dsh-tool-turbo](https://github.com/drscrewdriver/dsh-tool-turbo) 同源(同一套简单工具白名单 / 载荷阈值 / 75% 比例规则)。
43
+
32
44
  ## 安装
33
45
 
34
46
  ```bash
35
- # 1. 从 GitHub 把插件装进某个 profile(以 web 为例,任意 profile 均可)
47
+ # 1. 从 npm 把插件装进某个 profile(以 web 为例,任意 profile 均可)
36
48
  # (web profile 是 pnpm workspace root,必须带 -w)
37
- dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
38
- # 本地路径备选(无需网络;非 workspace root 目录无需 -w):
49
+ dsh plugin --profile web add dsh-thinking-levels -w
50
+ # GitHub 安装备选:
51
+ # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
52
+ # 本地路径备选(无需网络):
39
53
  # dsh plugin --profile web add /dsh-thinking-levels 的绝对路径/
40
54
 
41
- # 2. 重启 dsh web
42
- # (运行中的实例不会热加载新的 bundle 层)
55
+ # 2. 重启 dsh web(运行中的实例不会热加载新的 bundle 层)
43
56
  dsh web
44
57
  ```
45
58
 
59
+ > 注意:dsh 运行环境使用 pnpm 11,新发布的版本会受 `minimumReleaseAge` 冷却期约束;如安装报
60
+ > `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`,在 `~/.dsh/profiles/web/pnpm-workspace.yaml` 的
61
+ > `minimumReleaseAgeExclude` 中加入对应版本即可。
62
+
46
63
  手动 `link:` 注册(`dsh plugin add` 的备选方式):
47
64
 
48
65
  ```bash
@@ -62,14 +79,24 @@ cd ~/.dsh/profiles/web && pnpm install && dsh web
62
79
  - **装配层** — profile 组合中插件行的 `config:`(如 `cordis.yml`):
63
80
  ```yaml
64
81
  config:
65
- level: high # off | low | high | max | auto
66
- allowDowngrade: false # 禁止调度器降到 `high` 以下
82
+ level: auto # off | low | high | max | auto —— 会话未显式选择时的默认档位
83
+ allowDowngrade: true # 允许调度器降到 `high` 以下
67
84
  allowUpgrade: false # 禁止调度器升到 `max`
68
85
  ```
69
- - **运行时** — dsh-settings 命名空间 `thinking-levels`(`level`、`allowDowngrade`、`allowUpgrade`、`enabled`):改动对下一次模型请求生效,无需重启。
86
+ - **运行时** — dsh-settings 命名空间 `thinking-levels`(`level`、`allowDowngrade`、`allowUpgrade`、`enabled`):改动对下一次模型请求生效,无需重启。设置面板(设置 → 插件 → 可配置插件)提供可视化编辑。
70
87
 
71
88
  默认值:`{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false }`。
72
89
 
90
+ > 语义说明:模型选择器选择优先于插件默认档位。选 `auto`(mask)→ 插件调度;选 `off/low/high/max` → 直接生效;未选择 → 使用插件的 `level` 默认档位。`allowDowngrade` / `allowUpgrade` 只约束 `auto` 调度。
91
+
92
+ ## 依赖说明
93
+
94
+ 插件 host 侧值依赖 `@deepseek-ai/dsh-settings`(官方包默认不在 profile 的 hoisted node_modules 中,会从 dsh 全局嵌套解析)。如插件在插件列表中显示“已停用/未挂载”,请将官方依赖装入 profile:
95
+
96
+ ```bash
97
+ dsh plugin --profile web add @deepseek-ai/dsh-settings@^0.1.0-rc.7 -w
98
+ ```
99
+
73
100
  ## 开发
74
101
 
75
102
  ```bash
package/lib/client.js CHANGED
@@ -13,13 +13,13 @@ window.__ModuleLoader__.load({
13
13
  /** Simplified Chinese dictionary (the key-set source of truth). */
14
14
  const zh = {
15
15
  "card.title": "思考档位",
16
- "card.description": "按轮次控制 reasoning_effort:auto 按工具调用历史自动在 low / high / max 间调度,或手动固定档位。",
17
- "card.level": "档位",
16
+ "card.description": "在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位与调度边界。",
17
+ "card.level": "默认档位",
18
18
  "card.level.off": "off — 关闭思考(仅手动,永不自动选择)",
19
19
  "card.level.low": "low — 低(简单任务,廉价轮保持廉价)",
20
20
  "card.level.high": "high — 高(官方默认)",
21
21
  "card.level.max": "max — 最大(重任务)",
22
- "card.level.auto": "auto — 按工具历史自动调度",
22
+ "card.level.auto": "auto — 按工具历史自动调度(默认)",
23
23
  "card.enabled": "启用",
24
24
  "card.allowDowngrade": "允许降档(auto 可降至 low)",
25
25
  "card.allowUpgrade": "允许升档(auto 可升至 max)",
@@ -29,13 +29,13 @@ window.__ModuleLoader__.load({
29
29
  /** English dictionary (keys mirror zh). */
30
30
  const en = {
31
31
  "card.title": "Thinking Levels",
32
- "card.description": "Per-round reasoning_effort control: auto schedules between low / high / max from the recent tool-call history, or fix a level manually.",
33
- "card.level": "Level",
32
+ "card.description": "Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level and scheduler bounds.",
33
+ "card.level": "Default level",
34
34
  "card.level.off": "off — disable thinking (manual only, never auto-picked)",
35
35
  "card.level.low": "low — cheap rounds stay cheap",
36
36
  "card.level.high": "high — the official default",
37
37
  "card.level.max": "max — heavy work",
38
- "card.level.auto": "auto — schedule from tool history",
38
+ "card.level.auto": "auto — schedule from tool history (default)",
39
39
  "card.enabled": "Enabled",
40
40
  "card.allowDowngrade": "Allow downgrade (auto may drop to low)",
41
41
  "card.allowUpgrade": "Allow upgrade (auto may lift to max)",
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["useSyncExternalStore"],"sources":["../src/client/locales.ts","../src/client/card.tsx","../src/client/index.ts"],"sourcesContent":["/** `thinking-levels` client dictionaries. */\r\n\r\n/** Dictionary namespace owned by this plugin. */\r\nexport const NS = 'thinking-levels'\r\n\r\n/** Simplified Chinese dictionary (the key-set source of truth). */\r\nexport const zh = {\r\n 'card.title': '思考档位',\r\n 'card.description': '按轮次控制 reasoning_effort:auto 按工具调用历史自动在 low / high / max 间调度,或手动固定档位。',\r\n 'card.level': '档位',\r\n 'card.level.off': 'off — 关闭思考(仅手动,永不自动选择)',\r\n 'card.level.low': 'low — 低(简单任务,廉价轮保持廉价)',\r\n 'card.level.high': 'high — 高(官方默认)',\r\n 'card.level.max': 'max — 最大(重任务)',\r\n 'card.level.auto': 'auto — 按工具历史自动调度',\r\n 'card.enabled': '启用',\r\n 'card.allowDowngrade': '允许降档(auto 可降至 low)',\r\n 'card.allowUpgrade': '允许升档(auto 可升至 max)',\r\n 'card.unavailable': '设置命名空间不可用:请确认 dsh-thinking-levels 已装配进 profile。',\r\n 'card.readonly': '只读',\r\n} satisfies Record<string, string>\r\n\r\n/** English dictionary (keys mirror zh). */\r\nexport const en: Record<keyof typeof zh, string> = {\r\n 'card.title': 'Thinking Levels',\r\n 'card.description': 'Per-round reasoning_effort control: auto schedules between low / high / max from the recent tool-call history, or fix a level manually.',\r\n 'card.level': 'Level',\r\n 'card.level.off': 'off — disable thinking (manual only, never auto-picked)',\r\n 'card.level.low': 'low — cheap rounds stay cheap',\r\n 'card.level.high': 'high — the official default',\r\n 'card.level.max': 'max — heavy work',\r\n 'card.level.auto': 'auto — schedule from tool history',\r\n 'card.enabled': 'Enabled',\r\n 'card.allowDowngrade': 'Allow downgrade (auto may drop to low)',\r\n 'card.allowUpgrade': 'Allow upgrade (auto may lift to max)',\r\n 'card.unavailable': 'Settings namespace unavailable: make sure dsh-thinking-levels is assembled into this profile.',\r\n 'card.readonly': 'Read-only',\r\n}\r\n","/**\r\n * Thinking-levels settings card — the `settings.plugin.item` face of the\r\n * dsh-thinking-levels plugin.\r\n *\r\n * The card binds the `thinking-levels` settings namespace through the\r\n * `settingsScope` cordis service and renders its four fields: the level picker\r\n * (off / low / high / max / auto) plus the three scheduler toggles. Every\r\n * change commits immediately through the scope (no staged form): the decision\r\n * is read per model request, so a committed change applies to the next request\r\n * without a restart.\r\n *\r\n * Kept dependency-free beyond react: the scope is subscribed with\r\n * `useSyncExternalStore`, and the controls are plain HTML so the client bundle\r\n * needs no CSS modules and no primitives value import.\r\n */\r\nimport { useSyncExternalStore } from 'react'\r\nimport type { CSSProperties, JSX } from 'react'\r\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\r\nimport type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { EffortId } from '../thinking-level.ts'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\n\r\n/** One injected face: the bound settings scope for the `thinking-levels` namespace. */\r\nexport interface ThinkingLevelsCardInjected {\r\n scope: SettingsScope<ThinkingLevelsConfig>\r\n}\r\n\r\n/** Full props: locale seat + the injected scope. */\r\nexport type ThinkingLevelsCardProps = PropsLocale<'thinking-levels'> & ThinkingLevelsCardInjected\r\n\r\n/** The five user-facing levels, in picker order. */\r\nconst EFFORT_OPTIONS: readonly EffortId[] = ['off', 'low', 'high', 'max', 'auto']\r\n\r\n/** Minimal shared row styling (inline; keeps the client bundle CSS-free). */\r\nconst rowStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'space-between',\r\n gap: '12px',\r\n padding: '6px 0',\r\n fontSize: '13px',\r\n lineHeight: '20px',\r\n}\r\n\r\nconst labelStyle: CSSProperties = { margin: 0, color: 'var(--dsw-alias-label-primary)' }\r\n\r\nconst controlStyle: CSSProperties = {\r\n background: 'var(--dsw-alias-bg-surface, #fff)',\r\n color: 'var(--dsw-alias-label-primary)',\r\n border: '1px solid var(--dsw-alias-border-l2)',\r\n borderRadius: '4px',\r\n padding: '3px 8px',\r\n fontSize: '13px',\r\n}\r\n\r\n/** One boolean field row (checkbox) bound to the scope. */\r\nfunction ToggleRow(props: {\r\n id: string\r\n label: string\r\n checked: boolean\r\n disabled: boolean\r\n onChange: (next: boolean) => void\r\n}): JSX.Element {\r\n const { id, label, checked, disabled, onChange } = props\r\n return (\r\n <div style={rowStyle}>\r\n <label htmlFor={id} style={labelStyle}>{label}</label>\r\n <input\r\n id={id}\r\n type=\"checkbox\"\r\n checked={checked}\r\n disabled={disabled}\r\n onChange={(event) => onChange(event.currentTarget.checked)}\r\n />\r\n </div>\r\n )\r\n}\r\n\r\n/**\r\n * The card body.\r\n * @param props - locale copy and the injected settings scope.\r\n */\r\nexport function ThinkingLevelsCard({ t, scope }: ThinkingLevelsCardProps): JSX.Element {\r\n const snapshot = useSyncExternalStore(\r\n (listener) => scope.subscribe(listener),\r\n () => scope.getSnapshot(),\r\n )\r\n const unavailable = snapshot.status === 'unavailable'\r\n const readonly = unavailable || !snapshot.writable\r\n const value = (snapshot.value ?? {}) as Partial<ThinkingLevelsConfig>\r\n const level = EFFORT_OPTIONS.includes(value.level as EffortId) ? value.level as EffortId : 'auto'\r\n\r\n if (unavailable) {\r\n return (\r\n <div style={{ padding: '12px 16px', fontSize: '13px', color: 'var(--dsw-alias-label-tertiary)' }}>\r\n {t('card.unavailable')}\r\n </div>\r\n )\r\n }\r\n\r\n return (\r\n <div style={{ padding: '12px 16px' }}>\r\n <div style={rowStyle}>\r\n <label htmlFor=\"plugin-config-thinking-levels-level\" style={labelStyle}>{t('card.level')}</label>\r\n <select\r\n id=\"plugin-config-thinking-levels-level\"\r\n value={level}\r\n disabled={readonly}\r\n style={controlStyle}\r\n onChange={(event) => { void scope.set('level', event.currentTarget.value as EffortId) }}\r\n >\r\n {EFFORT_OPTIONS.map((option) => (\r\n <option key={option} value={option}>{t(`card.level.${option}`)}</option>\r\n ))}\r\n </select>\r\n </div>\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-enabled\"\r\n label={t('card.enabled')}\r\n checked={value.enabled ?? true}\r\n disabled={readonly}\r\n onChange={(next) => { void scope.set('enabled', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-downgrade\"\r\n label={t('card.allowDowngrade')}\r\n checked={value.allowDowngrade ?? true}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowDowngrade', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-upgrade\"\r\n label={t('card.allowUpgrade')}\r\n checked={value.allowUpgrade ?? false}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowUpgrade', next) }}\r\n />\r\n {!snapshot.writable && <p style={{ margin: '8px 0 0', fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)' }}>{t('card.readonly')}</p>}\r\n </div>\r\n )\r\n}\r\n","/**\r\n * dsh-thinking-levels — browser half.\r\n *\r\n * Registers the `thinking-levels` dictionaries and one `settings.plugin.item`\r\n * card keyed by the plugin's settings namespace, so the shared Plugins\r\n * settings tab renders an editable card: the level picker (off / low / high /\r\n * max / auto) plus the scheduler toggles.\r\n *\r\n * All @deepseek-ai/* imports are type-only: collaboration happens through\r\n * cordis services (`settingsScope`) and slot registration only (client bundle\r\n * purity).\r\n */\r\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\r\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\r\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\nimport { NS, en, zh } from './locales.ts'\r\nimport { ThinkingLevelsCard, type ThinkingLevelsCardInjected } from './card.tsx'\r\n\r\n/** The settings namespace the host half registers (kept in lockstep with src/index.ts). */\r\nconst THINKING_LEVELS_NS = 'thinking-levels'\r\n\r\n/** Services required by the browser half. */\r\nexport const inject = ['slots', 'locale', 'settingsScope']\r\n\r\n/**\r\n * Client plugin body: dictionaries plus the settings card registration.\r\n * @param ctx - client root context.\r\n */\r\nexport function apply(ctx: ClientContext): void {\r\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-thinking-levels: dictionaries')\r\n\r\n ctx.slots.inject('settings.plugin.item', function* () {\r\n yield ctx.slots.register({\r\n name: 'settings.plugin.item',\r\n key: THINKING_LEVELS_NS,\r\n locale: NS,\r\n inject: (): ThinkingLevelsCardInjected => {\r\n const scope = ctx.settingsScope.bind<ThinkingLevelsConfig>({ namespace: THINKING_LEVELS_NS })\r\n return { scope }\r\n },\r\n }, ThinkingLevelsCard)\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;EAGA,MAAa,KAAK;;EAGlB,MAAa,KAAK;GAChB,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;EAGA,MAAa,KAAsC;GACjD,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;;;;;;;;;;;;;;;;;;ECNA,MAAM,iBAAsC;GAAC;GAAO;GAAO;GAAQ;GAAO;EAAM;;EAGhF,MAAM,WAA0B;GAC9B,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GACL,SAAS;GACT,UAAU;GACV,YAAY;EACd;EAEA,MAAM,aAA4B;GAAE,QAAQ;GAAG,OAAO;EAAiC;EAEvF,MAAM,eAA8B;GAClC,YAAY;GACZ,OAAO;GACP,QAAQ;GACR,cAAc;GACd,SAAS;GACT,UAAU;EACZ;;EAGA,SAAS,UAAU,OAMH;GACd,MAAM,EAAE,IAAI,OAAO,SAAS,UAAU,aAAa;G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AmB,CAC9E,EAAE;KACjB;IACF,GAAG,kBAAkB;GACvB,CAAC;EACH"}
1
+ {"version":3,"file":"client.js","names":["useSyncExternalStore"],"sources":["../src/client/locales.ts","../src/client/card.tsx","../src/client/index.ts"],"sourcesContent":["/** `thinking-levels` client dictionaries. */\r\n\r\n/** Dictionary namespace owned by this plugin. */\r\nexport const NS = 'thinking-levels'\r\n\r\n/** Simplified Chinese dictionary (the key-set source of truth). */\r\nexport const zh = {\r\n 'card.title': '思考档位',\r\n 'card.description': '在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位与调度边界。',\r\n 'card.level': '默认档位',\r\n 'card.level.off': 'off — 关闭思考(仅手动,永不自动选择)',\r\n 'card.level.low': 'low — 低(简单任务,廉价轮保持廉价)',\r\n 'card.level.high': 'high — 高(官方默认)',\r\n 'card.level.max': 'max — 最大(重任务)',\r\n 'card.level.auto': 'auto — 按工具历史自动调度(默认)',\r\n 'card.enabled': '启用',\r\n 'card.allowDowngrade': '允许降档(auto 可降至 low)',\r\n 'card.allowUpgrade': '允许升档(auto 可升至 max)',\r\n 'card.unavailable': '设置命名空间不可用:请确认 dsh-thinking-levels 已装配进 profile。',\r\n 'card.readonly': '只读',\r\n} satisfies Record<string, string>\r\n\r\n/** English dictionary (keys mirror zh). */\r\nexport const en: Record<keyof typeof zh, string> = {\r\n 'card.title': 'Thinking Levels',\r\n 'card.description': 'Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level and scheduler bounds.',\r\n 'card.level': 'Default level',\r\n 'card.level.off': 'off — disable thinking (manual only, never auto-picked)',\r\n 'card.level.low': 'low — cheap rounds stay cheap',\r\n 'card.level.high': 'high — the official default',\r\n 'card.level.max': 'max — heavy work',\r\n 'card.level.auto': 'auto — schedule from tool history (default)',\r\n 'card.enabled': 'Enabled',\r\n 'card.allowDowngrade': 'Allow downgrade (auto may drop to low)',\r\n 'card.allowUpgrade': 'Allow upgrade (auto may lift to max)',\r\n 'card.unavailable': 'Settings namespace unavailable: make sure dsh-thinking-levels is assembled into this profile.',\r\n 'card.readonly': 'Read-only',\r\n}\r\n","/**\r\n * Thinking-levels settings card — the `settings.plugin.item` face of the\r\n * dsh-thinking-levels plugin.\r\n *\r\n * The card binds the `thinking-levels` settings namespace through the\r\n * `settingsScope` cordis service and renders its four fields: the level picker\r\n * (off / low / high / max / auto) plus the three scheduler toggles. Every\r\n * change commits immediately through the scope (no staged form): the decision\r\n * is read per model request, so a committed change applies to the next request\r\n * without a restart.\r\n *\r\n * Kept dependency-free beyond react: the scope is subscribed with\r\n * `useSyncExternalStore`, and the controls are plain HTML so the client bundle\r\n * needs no CSS modules and no primitives value import.\r\n */\r\nimport { useSyncExternalStore } from 'react'\r\nimport type { CSSProperties, JSX } from 'react'\r\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\r\nimport type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { EffortId } from '../thinking-level.ts'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\n\r\n/** One injected face: the bound settings scope for the `thinking-levels` namespace. */\r\nexport interface ThinkingLevelsCardInjected {\r\n scope: SettingsScope<ThinkingLevelsConfig>\r\n}\r\n\r\n/** Full props: locale seat + the injected scope. */\r\nexport type ThinkingLevelsCardProps = PropsLocale<'thinking-levels'> & ThinkingLevelsCardInjected\r\n\r\n/** The five user-facing levels, in picker order. */\r\nconst EFFORT_OPTIONS: readonly EffortId[] = ['off', 'low', 'high', 'max', 'auto']\r\n\r\n/** Minimal shared row styling (inline; keeps the client bundle CSS-free). */\r\nconst rowStyle: CSSProperties = {\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'space-between',\r\n gap: '12px',\r\n padding: '6px 0',\r\n fontSize: '13px',\r\n lineHeight: '20px',\r\n}\r\n\r\nconst labelStyle: CSSProperties = { margin: 0, color: 'var(--dsw-alias-label-primary)' }\r\n\r\nconst controlStyle: CSSProperties = {\r\n background: 'var(--dsw-alias-bg-surface, #fff)',\r\n color: 'var(--dsw-alias-label-primary)',\r\n border: '1px solid var(--dsw-alias-border-l2)',\r\n borderRadius: '4px',\r\n padding: '3px 8px',\r\n fontSize: '13px',\r\n}\r\n\r\n/** One boolean field row (checkbox) bound to the scope. */\r\nfunction ToggleRow(props: {\r\n id: string\r\n label: string\r\n checked: boolean\r\n disabled: boolean\r\n onChange: (next: boolean) => void\r\n}): JSX.Element {\r\n const { id, label, checked, disabled, onChange } = props\r\n return (\r\n <div style={rowStyle}>\r\n <label htmlFor={id} style={labelStyle}>{label}</label>\r\n <input\r\n id={id}\r\n type=\"checkbox\"\r\n checked={checked}\r\n disabled={disabled}\r\n onChange={(event) => onChange(event.currentTarget.checked)}\r\n />\r\n </div>\r\n )\r\n}\r\n\r\n/**\r\n * The card body.\r\n * @param props - locale copy and the injected settings scope.\r\n */\r\nexport function ThinkingLevelsCard({ t, scope }: ThinkingLevelsCardProps): JSX.Element {\r\n const snapshot = useSyncExternalStore(\r\n (listener) => scope.subscribe(listener),\r\n () => scope.getSnapshot(),\r\n )\r\n const unavailable = snapshot.status === 'unavailable'\r\n const readonly = unavailable || !snapshot.writable\r\n const value = (snapshot.value ?? {}) as Partial<ThinkingLevelsConfig>\r\n const level = EFFORT_OPTIONS.includes(value.level as EffortId) ? value.level as EffortId : 'auto'\r\n\r\n if (unavailable) {\r\n return (\r\n <div style={{ padding: '12px 16px', fontSize: '13px', color: 'var(--dsw-alias-label-tertiary)' }}>\r\n {t('card.unavailable')}\r\n </div>\r\n )\r\n }\r\n\r\n return (\r\n <div style={{ padding: '12px 16px' }}>\r\n <div style={rowStyle}>\r\n <label htmlFor=\"plugin-config-thinking-levels-level\" style={labelStyle}>{t('card.level')}</label>\r\n <select\r\n id=\"plugin-config-thinking-levels-level\"\r\n value={level}\r\n disabled={readonly}\r\n style={controlStyle}\r\n onChange={(event) => { void scope.set('level', event.currentTarget.value as EffortId) }}\r\n >\r\n {EFFORT_OPTIONS.map((option) => (\r\n <option key={option} value={option}>{t(`card.level.${option}`)}</option>\r\n ))}\r\n </select>\r\n </div>\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-enabled\"\r\n label={t('card.enabled')}\r\n checked={value.enabled ?? true}\r\n disabled={readonly}\r\n onChange={(next) => { void scope.set('enabled', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-downgrade\"\r\n label={t('card.allowDowngrade')}\r\n checked={value.allowDowngrade ?? true}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowDowngrade', next) }}\r\n />\r\n <ToggleRow\r\n id=\"plugin-config-thinking-levels-upgrade\"\r\n label={t('card.allowUpgrade')}\r\n checked={value.allowUpgrade ?? false}\r\n disabled={readonly || value.level !== 'auto'}\r\n onChange={(next) => { void scope.set('allowUpgrade', next) }}\r\n />\r\n {!snapshot.writable && <p style={{ margin: '8px 0 0', fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)' }}>{t('card.readonly')}</p>}\r\n </div>\r\n )\r\n}\r\n","/**\r\n * dsh-thinking-levels — browser half.\r\n *\r\n * Registers the `thinking-levels` dictionaries and one `settings.plugin.item`\r\n * card keyed by the plugin's settings namespace, so the shared Plugins\r\n * settings tab renders an editable card: the level picker (off / low / high /\r\n * max / auto) plus the scheduler toggles.\r\n *\r\n * All @deepseek-ai/* imports are type-only: collaboration happens through\r\n * cordis services (`settingsScope`) and slot registration only (client bundle\r\n * purity).\r\n */\r\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\r\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\r\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\r\nimport type { ThinkingLevelsConfig } from '../index.ts'\r\nimport { NS, en, zh } from './locales.ts'\r\nimport { ThinkingLevelsCard, type ThinkingLevelsCardInjected } from './card.tsx'\r\n\r\n/** The settings namespace the host half registers (kept in lockstep with src/index.ts). */\r\nconst THINKING_LEVELS_NS = 'thinking-levels'\r\n\r\n/** Services required by the browser half. */\r\nexport const inject = ['slots', 'locale', 'settingsScope']\r\n\r\n/**\r\n * Client plugin body: dictionaries plus the settings card registration.\r\n * @param ctx - client root context.\r\n */\r\nexport function apply(ctx: ClientContext): void {\r\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-thinking-levels: dictionaries')\r\n\r\n ctx.slots.inject('settings.plugin.item', function* () {\r\n yield ctx.slots.register({\r\n name: 'settings.plugin.item',\r\n key: THINKING_LEVELS_NS,\r\n locale: NS,\r\n inject: (): ThinkingLevelsCardInjected => {\r\n const scope = ctx.settingsScope.bind<ThinkingLevelsConfig>({ namespace: THINKING_LEVELS_NS })\r\n return { scope }\r\n },\r\n }, ThinkingLevelsCard)\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;EAGA,MAAa,KAAK;;EAGlB,MAAa,KAAK;GAChB,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;EAGA,MAAa,KAAsC;GACjD,cAAc;GACd,oBAAoB;GACpB,cAAc;GACd,kBAAkB;GAClB,kBAAkB;GAClB,mBAAmB;GACnB,kBAAkB;GAClB,mBAAmB;GACnB,gBAAgB;GAChB,uBAAuB;GACvB,qBAAqB;GACrB,oBAAoB;GACpB,iBAAiB;EACnB;;;;;;;;;;;;;;;;;;;ECNA,MAAM,iBAAsC;GAAC;GAAO;GAAO;GAAQ;GAAO;EAAM;;EAGhF,MAAM,WAA0B;GAC9B,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GACL,SAAS;GACT,UAAU;GACV,YAAY;EACd;EAEA,MAAM,aAA4B;GAAE,QAAQ;GAAG,OAAO;EAAiC;EAEvF,MAAM,eAA8B;GAClC,YAAY;GACZ,OAAO;GACP,QAAQ;GAC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AAS;KACvB,MAAM;KACN,KAAK;KACL,QAAQ;KACR,cAA0C;MAExC,OAAO,EAAE,OADK,IAAI,cAAc,KAA2B,EAAE,WAAW,mBAAmB,CAC9E,EAAE;KACjB;IACF,GAAG,kBAAkB;GACvB,CAAC;EACH"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import z from '@deepseek-ai/schemastery';
2
2
  import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
3
- import { assertEffortId, decideEffort } from "./thinking-level.js";
3
+ import { assertEffortId, decideEffort, isEffortId } from "./thinking-level.js";
4
4
  import { recentToolCalls } from "./session-events.js";
5
5
  /**
6
6
  * Composition-entry schema: what a dsh profile may configure at assembly
@@ -24,6 +24,34 @@ export const DEFAULT_CONFIG = {
24
24
  /** Runtime-adjustable settings namespace: level + scheduler toggles. */
25
25
  export const THINKING_LEVELS_SETTINGS_NAMESPACE = settingsNamespace('thinking-levels');
26
26
  const TOOL_AGE_LIMIT_MS = 10 * 60 * 1000;
27
+ /**
28
+ * The `auto` mask shown in the model directory: a user-facing level that is
29
+ * never sent to the API — the plugin resolves it to a wire level per request.
30
+ * It is injected into the adapter's `reasoning.efforts` so the model selector
31
+ * offers it, and `resolveCallFor` accepts it until this plugin's request
32
+ * interceptor substitutes the resolved wire level.
33
+ */
34
+ const AUTO_EFFORT = { id: 'auto', name: 'Auto' };
35
+ /**
36
+ * Advertise `auto` in the model directory (and the call-config validation it
37
+ * feeds): wrap every registered adapter's `resolveModel` so the returned
38
+ * `reasoning.efforts` include the mask level. Idempotent per adapter.
39
+ * @param llm - the resolved `llm` service, when present.
40
+ */
41
+ function advertiseAutoEffort(llm) {
42
+ for (const registration of llm?.adapters?.values() ?? []) {
43
+ const adapter = registration.adapter;
44
+ const original = adapter.resolveModel.bind(adapter);
45
+ adapter.resolveModel = async (provider, model, signal) => {
46
+ const info = await original(provider, model, signal);
47
+ const reasoning = info.reasoning;
48
+ if (reasoning !== undefined && !reasoning.efforts?.some((effort) => effort.id === 'auto')) {
49
+ info.reasoning = { ...reasoning, efforts: [...(reasoning.efforts ?? []), AUTO_EFFORT] };
50
+ }
51
+ return info;
52
+ };
53
+ }
54
+ }
27
55
  /**
28
56
  * Plugin body.
29
57
  * @param ctx - host context carrying the agent-event dispatch.
@@ -52,6 +80,10 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
52
80
  // The 'agent/request' event key is augmented onto cordis Events by the
53
81
  // dsh-agent runtime's generated scope types; the npm package does not
54
82
  // re-export that augmentation, so the emitter is widened at the boundary.
83
+ //
84
+ // prepend: the host's model-selection assembly also listens on this event and
85
+ // overwrites `reasoningEffort` with the session's selection after `next()`;
86
+ // registering first keeps this plugin's decision OUTERMOST so it runs last.
55
87
  const on = ctx.on;
56
88
  on('agent/request', async (payload, next) => {
57
89
  const seed = await next();
@@ -59,18 +91,29 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
59
91
  // `enabled` may flip at runtime through the settings namespace.
60
92
  if (!cfg.enabled)
61
93
  return seed;
94
+ const selected = seed.reasoningEffort;
95
+ // A wire level picked in the model selector (off/low/high/max) wins — the
96
+ // plugin only intervenes for the `auto` mask or when nothing was selected.
97
+ if (isEffortId(selected) && selected !== 'auto')
98
+ return seed;
99
+ // `auto` mask (or an unset/unknown value): resolve through the plugin's
100
+ // scheduler, falling back to the configured default level.
101
+ const base = selected === 'auto' ? 'auto' : cfg.level;
62
102
  const calls = recentToolCalls(payload.agent);
63
103
  const level = decideEffort({
64
104
  recentCalls: calls,
65
- selected: cfg.level,
105
+ selected: base,
66
106
  allowDowngrade: cfg.allowDowngrade,
67
107
  allowUpgrade: cfg.allowUpgrade,
68
108
  });
69
109
  // Summary-only log: individual tool names/arg sizes are workflow metadata
70
110
  // that need not land in the host log; count and decision suffice.
71
- ctx.logger?.info?.('[thinking-levels] agent/request: selected=%s calls=%d => level=%s', cfg.level, calls.length, level);
111
+ ctx.logger?.info?.('[thinking-levels] agent/request: selected=%s calls=%d => level=%s', String(selected), calls.length, level);
72
112
  return { ...seed, reasoningEffort: level };
73
- });
113
+ }, { prepend: true });
114
+ // Advertise the `auto` mask in the model directory so the session model
115
+ // selector offers it alongside Off/Low/High/Max.
116
+ advertiseAutoEffort(ctx.get('llm'));
74
117
  // Per-tool wall-clock telemetry: log tool/call -> tool/result durations.
75
118
  // Same boundary widening as above (agent/tool is a generated scope event).
76
119
  const started = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-thinking-levels",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "DSH host plugin: thinking-level (reasoning_effort) control for dsh — auto-adjust per tool round, with optional manual lock and per-tool timing telemetry.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,16 +34,16 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@deepseek-ai/cordis": "^4.0.1",
37
- "@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
38
- "@deepseek-ai/dsh-settings": "^0.1.0-rc.6"
37
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
38
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.7"
39
39
  },
40
40
  "dependencies": {
41
41
  "@deepseek-ai/schemastery": "^3.18.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@deepseek-ai/cordis": "^4.0.1",
45
- "@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
46
- "@deepseek-ai/dsh-settings": "^0.1.0-rc.6",
45
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
46
+ "@deepseek-ai/dsh-settings": "^0.1.0-rc.7",
47
47
  "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.7",
48
48
  "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.7",
49
49
  "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.7",