dsh-think-effort 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +50 -5
- package/client.js +736 -0
- package/cordis.patch.yml +3 -1
- package/docs/DETAIL.en.md +13 -1
- package/docs/DETAIL.zh.md +13 -1
- package/docs/settings-section.png +0 -0
- package/docs/settings.png +0 -0
- package/index.js +118 -3
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +15 -4
- package/src/policy.js +46 -13
package/cordis.patch.yml
CHANGED
package/docs/DETAIL.en.md
CHANGED
|
@@ -7,12 +7,23 @@ Declarative thinking-depth control for DeepSeek (and other) reasoning models: th
|
|
|
7
7
|
1. **Declares the capability (on by default).** A hand-declared DeepSeek gateway model under `llm-pi-ai` usually carries no reasoning metadata: the selector offers no depth, and any depth is refused. The plugin recognizes DeepSeek models by endpoint and model id and writes `reasoningEfforts` (default `low / high / max`) plus the route default depth (`high`) into the `llm-pi-ai` settings surface. A model that already declares `reasoningEfforts` — including an explicit `false` — is never touched.
|
|
8
8
|
2. **Offers `Auto`.** One `Auto` entry is prepended to the model's depth list.
|
|
9
9
|
3. **Resolves per request.** At the adapter boundary `auto` becomes the declared default; a request whose `purpose` is a cheap host-owned call becomes `low` when the model declares it — regardless of the session's own choice, because those bounded calls never inherit it; a manually picked depth passes through untouched and is validated by DSH itself.
|
|
10
|
+
4. **Subagent depth.** A subagent effort can be pinned (`inherit` / `auto` / `low`…`max`). `inherit` keeps DSH's native inheritance; a fixed depth overrides the child's own or inherited pick, while a cheap-call downgrade still wins.
|
|
10
11
|
|
|
11
12
|
## Usage
|
|
12
13
|
|
|
13
14
|
- Pick `Auto` in the model selector to state "use the default depth", or a concrete depth to pin it.
|
|
14
15
|
- Leaving the depth unset (the native "provider default" row) behaves like `Auto` on ordinary steps — both land on the declared default; `Auto` only records the intent in the session. The cheap-call downgrade applies either way.
|
|
15
16
|
- The recognized models, default depth and cheap-call list live in the plugin row's config (`think-effort` in `cordis.patch.yml`).
|
|
17
|
+
- The visual settings page has **two entries**, both editing the same form: **Settings → Automatic thinking depth** (recommended), or **Plugins → Automatic thinking depth → Configure** on the row. Every field is `volatile`, so Save applies immediately without a restart.
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Where the settings page comes from
|
|
22
|
+
|
|
23
|
+
- The row page registers into the plugin manager's `plugins.row.config`, keyed `dsh-think-effort#think-effort`.
|
|
24
|
+
- The Settings page registers into the settings panel's `settings.section` (same `id` `think-effort`, `order: 16`, right after the built-in Plugins section at 15); its glyph registers into `settings.section.icon` with the matching `id`.
|
|
25
|
+
- A Settings section receives no form from its owner, so the page reads the **row's settings namespace** (the profile entry id, `think-effort`) through the `configForms` service. `whileServed(['think-effort'])` registers the entry only while the Host serves that namespace, so a deployment without the row never shows an empty page.
|
|
26
|
+
- Both entries share one form controller inside `configForms`, so a save from either place is the same profile write.
|
|
16
27
|
|
|
17
28
|
## Limitations
|
|
18
29
|
|
|
@@ -36,8 +47,9 @@ Declarative thinking-depth control for DeepSeek (and other) reasoning models: th
|
|
|
36
47
|
| `auxPurposes` | `session-title, compaction, auto-review` | Purposes treated as cheap |
|
|
37
48
|
| `auxLevel` | `low` | Depth those calls request |
|
|
38
49
|
| `autoScope` | `all` | `all` / `declared` / `off` |
|
|
50
|
+
| `subagentLevel` | `inherit` | Subagent depth: `inherit` / `auto` / a fixed depth; a fixed depth overrides the child's own or inherited pick |
|
|
39
51
|
| `trace` | `false` | Write decisions to stderr for diagnosis |
|
|
40
52
|
|
|
41
53
|
## Diagnostic tool
|
|
42
54
|
|
|
43
|
-
An Agent can call `reasoning_effort_status` for a provider/model: it reports the declared depths, the default, what `Auto`
|
|
55
|
+
An Agent can call `reasoning_effort_status` for a provider/model: it reports the declared depths, the default, what `Auto` and subagents resolve to, and the cheap-call depth, without sending any model request.
|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -7,12 +7,23 @@
|
|
|
7
7
|
1. **声明能力(默认开启)**:手工在 `llm-pi-ai` 里声明的 DeepSeek 网关模型通常没有推理元数据——选择器里没有任何档位,任何档位也会被拒绝。插件按 endpoint 与模型 ID 识别 DeepSeek 模型,把 `reasoningEfforts`(默认 `low / high / max`)与路由默认档(`high`)写进 `llm-pi-ai` 的设置面。已经有 `reasoningEfforts`(包括显式 `false`)的模型不会被改动。
|
|
8
8
|
2. **提供 `Auto`**:在模型目录的档位列表最前面补一个 `Auto`。
|
|
9
9
|
3. **逐请求解析**:在适配器边界把 `auto` 换成声明默认档;`purpose` 属于廉价调用时换成 `low`(仅当模型声明了它,且**与会话选了什么都无关**——会话标题/图片摘要本来就不继承会话档位);手动选的档位一律原样透传,由 DSH 自己校验。
|
|
10
|
+
4. **子代理档位**:可给子代理统一指定强度(`inherit` / `auto` / `low`…`max`)。`inherit` 保持 DSH 原生继承;固定档会覆盖子代理自身或从父代理继承的选择,廉价调用的降档仍然优先。
|
|
10
11
|
|
|
11
12
|
## 使用
|
|
12
13
|
|
|
13
14
|
- 在模型选择器里选 `Auto` 即声明「按默认档走」;选具体档位即固定该档位。
|
|
14
15
|
- 不选任何档位(原生“提供方默认”)在普通步骤上与 `Auto` 等效,都会落到声明默认档;差别只是 `Auto` 把意图记录进会话。廉价调用的降档在任何情况下都生效。
|
|
15
16
|
- 识别范围、默认档、廉价调用清单都在插件配置里(`cordis.patch.yml` 的 `think-effort` 行)。
|
|
17
|
+
- 可视化设置有**两个入口**,表单与写入相同:**设置 → 自动思考档位**(推荐),或**插件 → 自动思考档位 → 行「配置」**。字段全部是 `volatile` 配置,保存后立即生效(无需重启)。
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## 设置页从哪里来
|
|
22
|
+
|
|
23
|
+
- 插件行页面注册进插件管理器的 `plugins.row.config`,键为 `dsh-think-effort#think-effort`;
|
|
24
|
+
- 设置页注册进设置面板的 `settings.section`(`id` 同为 `think-effort`,`order: 16`,紧跟 order 15 的内置插件),图标注册进 `settings.section.icon` 且 `id` 必须与之一致;
|
|
25
|
+
- 设置页没有 owner 传入的表单,所以它从 `configForms` 服务读取**行设置命名空间**(即 profile 条目 id `think-effort`)。`whileServed(['think-effort'])` 保证只有 Host 正在提供该命名空间时才注册,页面不会在没有这一行的部署里留下空壳;
|
|
26
|
+
- 两个入口共用 `configForms` 里同一个表单控制器,因此任一入口的保存都是同一次 profile 写入。
|
|
16
27
|
|
|
17
28
|
## 限制
|
|
18
29
|
|
|
@@ -36,8 +47,9 @@
|
|
|
36
47
|
| `auxPurposes` | `session-title, compaction, auto-review` | 视为廉价调用的 `purpose` |
|
|
37
48
|
| `auxLevel` | `low` | 廉价调用用的档位 |
|
|
38
49
|
| `autoScope` | `all` | `all` / `declared` / `off` |
|
|
50
|
+
| `subagentLevel` | `inherit` | 子代理档位:`inherit` / `auto` / 固定档;固定档覆盖子代理自身或继承的选择 |
|
|
39
51
|
| `trace` | `false` | 把决策写到 stderr(排查用) |
|
|
40
52
|
|
|
41
53
|
## 诊断工具
|
|
42
54
|
|
|
43
|
-
会话里可以让 Agent 调 `reasoning_effort_status`:它报告某模型声明的档位、默认档、`Auto`
|
|
55
|
+
会话里可以让 Agent 调 `reasoning_effort_status`:它报告某模型声明的档位、默认档、`Auto` 与子代理的解析结果、廉价调用档位,不发任何模型请求。
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -39,7 +39,10 @@
|
|
|
39
39
|
* @module dsh-think-effort
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
+
import z from '@deepseek-ai/schemastery';
|
|
43
|
+
|
|
42
44
|
import {
|
|
45
|
+
DEFAULT_CONFIG,
|
|
43
46
|
normalizeConfig,
|
|
44
47
|
planCapabilitySection,
|
|
45
48
|
resolveCallEffort,
|
|
@@ -50,6 +53,67 @@ import {
|
|
|
50
53
|
/** The llm-pi-ai settings entry id in a composed profile. */
|
|
51
54
|
const PI_AI_NAMESPACE = 'llm-pi-ai';
|
|
52
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The row's complete tuning surface, exposed to Settings as a live form.
|
|
58
|
+
*
|
|
59
|
+
* Every field is volatile: the plugin manager page edits one row and the
|
|
60
|
+
* running policy must follow without remounting the adapter facade, so the
|
|
61
|
+
* values arrive as references and are re-read on `loader/volatile-update`.
|
|
62
|
+
* Defaults mirror `cordis.patch.yml` and {@link DEFAULT_CONFIG}.
|
|
63
|
+
*/
|
|
64
|
+
export const Config = z.object({
|
|
65
|
+
/** Master switch for the whole policy. */
|
|
66
|
+
enabled: z.boolean().default(true).volatile(),
|
|
67
|
+
/** Declare `reasoningEfforts` for matched models that carry none. */
|
|
68
|
+
declareCapability: z.boolean().default(true).volatile(),
|
|
69
|
+
/** Endpoint suffixes treated as an official DeepSeek host. */
|
|
70
|
+
deepseekHosts: z.array(z.string()).default([...DEFAULT_CONFIG.deepseekHosts]).volatile(),
|
|
71
|
+
/** Model-id test for hand-declared gateways. */
|
|
72
|
+
deepseekModelPattern: z.string().default(DEFAULT_CONFIG.deepseekModelPattern).volatile(),
|
|
73
|
+
/** Extra `provider/model` keys or model-id tests to declare. */
|
|
74
|
+
declareModels: z.array(z.string()).default([]).volatile(),
|
|
75
|
+
/** Declared depth vocabulary, escalation-ordered. */
|
|
76
|
+
efforts: z.array(z.string()).default([...DEFAULT_CONFIG.efforts]).volatile(),
|
|
77
|
+
/** Route default depth; `auto` resolves here unless `autoLevel` pins another. */
|
|
78
|
+
defaultEffort: z.string().default(DEFAULT_CONFIG.defaultEffort).volatile(),
|
|
79
|
+
/** `model-default` follows the route default, or a fixed level id. */
|
|
80
|
+
autoLevel: z.string().default(DEFAULT_CONFIG.autoLevel).volatile(),
|
|
81
|
+
/** Which models offer Auto: `all` | `declared` | `off`. */
|
|
82
|
+
autoScope: z.union([z.const('all'), z.const('declared'), z.const('off')]).default(DEFAULT_CONFIG.autoScope).volatile(),
|
|
83
|
+
/** Downgrade cheap host-owned calls when the model declares the level. */
|
|
84
|
+
auxDowngrade: z.boolean().default(DEFAULT_CONFIG.auxDowngrade).volatile(),
|
|
85
|
+
/** LLM request purposes that are host-owned cheap calls. */
|
|
86
|
+
auxPurposes: z.array(z.string()).default([...DEFAULT_CONFIG.auxPurposes]).volatile(),
|
|
87
|
+
/** Level those calls request. */
|
|
88
|
+
auxLevel: z.string().default(DEFAULT_CONFIG.auxLevel).volatile(),
|
|
89
|
+
/** Subagent-owned calls: `inherit`, `auto`, or a fixed level. */
|
|
90
|
+
subagentLevel: z.string().default(DEFAULT_CONFIG.subagentLevel).volatile(),
|
|
91
|
+
/** Diagnostic stderr trace of each decision. */
|
|
92
|
+
trace: z.boolean().default(false).volatile(),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/** Whether one parsed config value is a volatile reference. */
|
|
96
|
+
function isVolatileRef(value) {
|
|
97
|
+
return value !== null && typeof value === 'object' && typeof value.get === 'function' && !Array.isArray(value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Read the live policy config from the row's (possibly volatile) values.
|
|
102
|
+
* Constants and tests pass plain values; the Loader passes references.
|
|
103
|
+
* @param {object} [rawConfig] this row's config.
|
|
104
|
+
* @returns {object} a normalized plain config.
|
|
105
|
+
*/
|
|
106
|
+
export function readConfig(rawConfig) {
|
|
107
|
+
const source = rawConfig !== null && typeof rawConfig === 'object' ? rawConfig : {};
|
|
108
|
+
const plain = {};
|
|
109
|
+
for (const key of Object.keys(DEFAULT_CONFIG)) {
|
|
110
|
+
const value = source[key];
|
|
111
|
+
const plainValue = isVolatileRef(value) ? value.get() : value;
|
|
112
|
+
if (plainValue !== undefined) plain[key] = plainValue;
|
|
113
|
+
}
|
|
114
|
+
return normalizeConfig(plain);
|
|
115
|
+
}
|
|
116
|
+
|
|
53
117
|
/**
|
|
54
118
|
* Marks one facade so a re-run can tell "this registration already carries my
|
|
55
119
|
* wrapper" from "this is a third party's adapter". Not enumerable: it must not
|
|
@@ -126,13 +190,26 @@ function readPiAiSection(ctx) {
|
|
|
126
190
|
}
|
|
127
191
|
}
|
|
128
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Whether one live Agent belongs to a subagent session.
|
|
195
|
+
* @param {object} [agent] a live Agent handle (`ctx.agents.get(id)`).
|
|
196
|
+
* @returns {boolean} true for a delegated child session.
|
|
197
|
+
*/
|
|
198
|
+
export function isSubagentAgent(agent) {
|
|
199
|
+
const header = agent?.session?.header;
|
|
200
|
+
if (header === null || typeof header !== 'object') return false;
|
|
201
|
+
return header.origin === 'subagent'
|
|
202
|
+
|| (typeof header.delegationDepth === 'number' && header.delegationDepth > 0);
|
|
203
|
+
}
|
|
204
|
+
|
|
129
205
|
/**
|
|
130
206
|
* Plugin body.
|
|
131
207
|
* @param {import('@deepseek-ai/cordis').Context} ctx the owning Host context.
|
|
132
208
|
* @param {object} [rawConfig] this row's config from the profile patch.
|
|
133
209
|
*/
|
|
134
210
|
export function apply(ctx, rawConfig) {
|
|
135
|
-
|
|
211
|
+
/** Live policy config; re-read after a volatile update so Settings edits apply at once. */
|
|
212
|
+
let config = readConfig(rawConfig);
|
|
136
213
|
/** Diagnostic channel: opt-in stderr trace for a profile that hides the Host log. */
|
|
137
214
|
const trace = (message, ...rest) => {
|
|
138
215
|
if (config.trace !== true) return;
|
|
@@ -152,6 +229,21 @@ export function apply(ctx, rawConfig) {
|
|
|
152
229
|
|
|
153
230
|
/** Models this plugin declared, keyed `provider/model` (used by `autoScope: declared`). */
|
|
154
231
|
const declaredModels = new Set();
|
|
232
|
+
/**
|
|
233
|
+
* Whether one request belongs to a subagent session. DSH stamps the session
|
|
234
|
+
* id on every request; the child's session header carries its durable
|
|
235
|
+
* delegation origin, so no extra seam or cached classification is needed.
|
|
236
|
+
* @param {string} [sessionId] stamped session identity.
|
|
237
|
+
* @returns {boolean} true for a subagent-owned session.
|
|
238
|
+
*/
|
|
239
|
+
const isSubagentSession = (sessionId) => {
|
|
240
|
+
if (typeof sessionId !== 'string' || sessionId === '') return false;
|
|
241
|
+
try {
|
|
242
|
+
return isSubagentAgent(ctx.get('agents')?.get?.(sessionId));
|
|
243
|
+
} catch {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
155
247
|
/** Log de-duplication for per-request decisions. */
|
|
156
248
|
const logged = new Set();
|
|
157
249
|
|
|
@@ -197,17 +289,20 @@ export function apply(ctx, rawConfig) {
|
|
|
197
289
|
|
|
198
290
|
const policyDeps = {
|
|
199
291
|
decorate(info, provider, model) {
|
|
292
|
+
if (config.enabled === false) return info;
|
|
200
293
|
if (info === null || typeof info !== 'object') return info;
|
|
201
294
|
const key = `${provider}/${model}`;
|
|
202
295
|
const declared = declaredModels.has(key) || shouldDeclare({ provider, modelId: model }, config).declared;
|
|
203
296
|
return withAutoEffort(info, config, { declared });
|
|
204
297
|
},
|
|
205
298
|
translate(provider, model, options, info) {
|
|
299
|
+
if (config.enabled === false) return options;
|
|
206
300
|
if (options === null || typeof options !== 'object') return options;
|
|
207
301
|
const reasoning = info !== null && typeof info === 'object' ? info.reasoning : undefined;
|
|
208
302
|
const level = resolveCallEffort({
|
|
209
303
|
requested: options.reasoningEffort,
|
|
210
304
|
purpose: options.purpose,
|
|
305
|
+
isSubagent: isSubagentSession(options.sessionId),
|
|
211
306
|
efforts: reasoning !== null && typeof reasoning === 'object' ? reasoning.efforts : undefined,
|
|
212
307
|
defaultEffort: reasoning !== null && typeof reasoning === 'object' ? reasoning.defaultEffort : undefined,
|
|
213
308
|
}, config);
|
|
@@ -292,6 +387,15 @@ export function apply(ctx, rawConfig) {
|
|
|
292
387
|
if (ns === PI_AI_NAMESPACE) syncCapabilities();
|
|
293
388
|
});
|
|
294
389
|
ctx.on('app-boot/config-reload', () => syncCapabilities());
|
|
390
|
+
// A Settings edit commits volatile fields into the running references; the
|
|
391
|
+
// adapter facade reads this `config` variable per request, so only a re-read
|
|
392
|
+
// and one capability reconciliation are needed here.
|
|
393
|
+
ctx.on('loader/volatile-update', () => {
|
|
394
|
+
config = readConfig(rawConfig);
|
|
395
|
+
trace('volatile update: enabled=%s subagentLevel=%s', config.enabled, config.subagentLevel);
|
|
396
|
+
if (config.enabled === false) return;
|
|
397
|
+
syncCapabilities();
|
|
398
|
+
});
|
|
295
399
|
// Delayed retries cover the boot order where this plugin applies before the
|
|
296
400
|
// settings service has described the llm-pi-ai entry, and no later commit
|
|
297
401
|
// touches that namespace. The second beat also covers a bundle installed
|
|
@@ -364,10 +468,21 @@ export function apply(ctx, rawConfig) {
|
|
|
364
468
|
const auto = resolveCallEffort({ requested: 'auto', efforts: reasoning?.efforts, defaultEffort, purpose: 'agent' }, config);
|
|
365
469
|
const auxPurpose = config.auxPurposes[0] ?? 'session-title';
|
|
366
470
|
const aux = resolveCallEffort({ requested: 'auto', efforts: reasoning?.efforts, defaultEffort, purpose: auxPurpose }, config);
|
|
471
|
+
const subagentLevel = config.subagentLevel ?? 'inherit';
|
|
472
|
+
const subagent = subagentLevel === 'inherit'
|
|
473
|
+
? undefined
|
|
474
|
+
: resolveCallEffort({ isSubagent: true, efforts: reasoning?.efforts, defaultEffort, purpose: 'agent' }, config);
|
|
367
475
|
const summary = efforts.length === 0
|
|
368
476
|
? `${provider}/${model} declares no reasoning depths; the selector offers only the provider default.`
|
|
369
|
-
: `${provider}/${model}: ${efforts.join(' | ')}; default=${defaultEffort ?? '(none)'}; Auto -> ${auto ?? '(adapter default)'} for a normal step -> ${aux ?? '(adapter default)'} for ${auxPurpose}
|
|
370
|
-
|
|
477
|
+
: `${provider}/${model}: ${efforts.join(' | ')}; default=${defaultEffort ?? '(none)'}; Auto -> ${auto ?? '(adapter default)'} for a normal step -> ${aux ?? '(adapter default)'} for ${auxPurpose}`
|
|
478
|
+
+ (subagentLevel === 'inherit'
|
|
479
|
+
? '; subagents follow their own selection.'
|
|
480
|
+
: `; subagents -> ${subagent ?? '(adapter default)'} (${subagentLevel}).`);
|
|
481
|
+
return {
|
|
482
|
+
ok: true, provider, model, efforts, defaultEffort: defaultEffort ?? null,
|
|
483
|
+
auto: auto ?? null, aux: aux ?? null, auxPurpose,
|
|
484
|
+
subagentLevel, subagent: subagent ?? null, summary,
|
|
485
|
+
};
|
|
371
486
|
},
|
|
372
487
|
};
|
|
373
488
|
ctx.inject?.(['tools'], (scope) => {
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Automatic thinking depth",
|
|
4
|
-
"description": "Adds Auto to the model selector for reasoning models and resolves it per request: the declared default
|
|
4
|
+
"description": "Adds Auto to the model selector for reasoning models and resolves it per request: the declared default for normal steps (high on DeepSeek), Low for cheap host-owned calls, and an optional depth just for subagents — all editable on a live visual settings page.",
|
|
5
5
|
"detail": "docs/DETAIL.en.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "自动思考档位",
|
|
4
|
-
"description": "为推理模型在模型选择器里加上 Auto
|
|
4
|
+
"description": "为推理模型在模型选择器里加上 Auto,并逐请求解析:普通步骤用声明的默认档(DeepSeek 为 high),廉价调用用 low,子代理可单独指定强度;全部规则都能在可视化设置页即时调整。",
|
|
5
5
|
"detail": "docs/DETAIL.zh.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-think-effort",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Automatic thinking depth for DeepSeek routes in DeepSeek Harness: declare the model's effort vocabulary, add Auto to the model selector, resolve it to the declared default,
|
|
5
|
+
"description": "Automatic thinking depth for DeepSeek routes in DeepSeek Harness: declare the model's effort vocabulary, add Auto to the model selector, resolve it to the declared default, give subagents their own depth, drop cheap host-owned calls to Low, and edit every rule on a live visual settings page reachable from both Settings and the Plugins row.",
|
|
6
6
|
"icon": "./icon.svg",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "mhlywxl",
|
|
@@ -12,16 +12,20 @@
|
|
|
12
12
|
"deepseek-harness",
|
|
13
13
|
"reasoning-effort",
|
|
14
14
|
"thinking-level",
|
|
15
|
-
"deepseek"
|
|
15
|
+
"deepseek",
|
|
16
|
+
"subagent",
|
|
17
|
+
"settings-page"
|
|
16
18
|
],
|
|
17
19
|
"exports": {
|
|
18
20
|
".": "./index.js",
|
|
19
21
|
"./locale/*.json": "./locale/*.json",
|
|
20
22
|
"./icon": "./icon.svg",
|
|
21
|
-
"./package.json": "./package.json"
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
"./client": "./client.js"
|
|
22
25
|
},
|
|
23
26
|
"files": [
|
|
24
27
|
"index.js",
|
|
28
|
+
"client.js",
|
|
25
29
|
"src/**",
|
|
26
30
|
"cordis.patch.yml",
|
|
27
31
|
"locale/*.json",
|
|
@@ -42,6 +46,10 @@
|
|
|
42
46
|
"dsh": {
|
|
43
47
|
"bundle": {
|
|
44
48
|
"patch": "./cordis.patch.yml"
|
|
49
|
+
},
|
|
50
|
+
"client": {
|
|
51
|
+
"platform": "web",
|
|
52
|
+
"immediately": true
|
|
45
53
|
}
|
|
46
54
|
},
|
|
47
55
|
"repository": {
|
|
@@ -51,5 +59,8 @@
|
|
|
51
59
|
"homepage": "https://github.com/mhlywxl/dsh-think-effort#readme",
|
|
52
60
|
"bugs": {
|
|
53
61
|
"url": "https://github.com/mhlywxl/dsh-think-effort/issues"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@deepseek-ai/schemastery": "^3.18.5"
|
|
54
65
|
}
|
|
55
66
|
}
|
package/src/policy.js
CHANGED
|
@@ -86,6 +86,14 @@ export const DEFAULT_CONFIG = {
|
|
|
86
86
|
auxLevel: 'low',
|
|
87
87
|
/** Which models get the `auto` mask in the model selector: `all` | `declared` | `off`. */
|
|
88
88
|
autoScope: 'all',
|
|
89
|
+
/**
|
|
90
|
+
* Effort for subagent-owned calls: `inherit` leaves the child agent's own
|
|
91
|
+
* selection alone; `auto` follows this plugin's default resolution; a level
|
|
92
|
+
* id forces that depth (clamped to the model's declared vocabulary).
|
|
93
|
+
*/
|
|
94
|
+
subagentLevel: 'inherit',
|
|
95
|
+
/** Diagnostic stderr trace of each decision. */
|
|
96
|
+
trace: false,
|
|
89
97
|
};
|
|
90
98
|
|
|
91
99
|
/** Merge a patch row over the defaults without validating types yet. */
|
|
@@ -373,6 +381,24 @@ export function isAuxPurpose(purpose, rawCfg) {
|
|
|
373
381
|
return typeof purpose === 'string' && cfg.auxPurposes.includes(purpose);
|
|
374
382
|
}
|
|
375
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Depth `auto` resolves to for ordinary steps.
|
|
386
|
+
* @param {object} cfg normalized plugin config.
|
|
387
|
+
* @param {readonly object[]} efforts declared vocabulary.
|
|
388
|
+
* @param {string} [defaultEffort] model/route default depth.
|
|
389
|
+
* @returns {string | undefined} a declared depth, or undefined without one.
|
|
390
|
+
*/
|
|
391
|
+
function autoTarget(cfg, efforts, defaultEffort) {
|
|
392
|
+
const depths = depthLevels(efforts);
|
|
393
|
+
if (depths.length === 0) return undefined;
|
|
394
|
+
const target = cfg.autoLevel === 'model-default' || cfg.autoLevel === undefined
|
|
395
|
+
? defaultEffort
|
|
396
|
+
: cfg.autoLevel;
|
|
397
|
+
if (typeof target === 'string' && depths.includes(target)) return target;
|
|
398
|
+
if (typeof target === 'string') return clampEffort(target, efforts);
|
|
399
|
+
return clampEffort('high', efforts, depths[depths.length - 1]);
|
|
400
|
+
}
|
|
401
|
+
|
|
376
402
|
/**
|
|
377
403
|
* Decide the effort one model request should carry.
|
|
378
404
|
*
|
|
@@ -382,36 +408,43 @@ export function isAuxPurpose(purpose, rawCfg) {
|
|
|
382
408
|
* with no explicit selection either: those calls are applied
|
|
383
409
|
* unconditionally, because a session's own depth never applies to a bounded
|
|
384
410
|
* summary request.
|
|
385
|
-
* 2.
|
|
411
|
+
* 2. A subagent-owned call with `subagentLevel` set → that level, or the
|
|
412
|
+
* plugin's `auto` resolution for `auto`. The child's own selection and
|
|
413
|
+
* inherited parent selection are overridden only when the user opted in.
|
|
414
|
+
* 3. An explicit level → `undefined`: a user pick is passed through untouched
|
|
386
415
|
* (DSH validates it against the same vocabulary, so an undeclared pick never
|
|
387
416
|
* reaches the wire).
|
|
388
|
-
*
|
|
417
|
+
* 4. No explicit selection on an ordinary call → `undefined`: the adapter's own
|
|
389
418
|
* default stands (with the declaration above, that is `high`).
|
|
390
|
-
*
|
|
419
|
+
* 5. `auto` → the declared route default (DeepSeek: `high`), or the
|
|
391
420
|
* highest declared depth when the route names none.
|
|
392
421
|
*
|
|
393
422
|
* @param {object} input decision inputs.
|
|
394
423
|
* @param {string} [input.requested] the selection's effort.
|
|
395
424
|
* @param {string} [input.purpose] LLM request purpose.
|
|
425
|
+
* @param {boolean} [input.isSubagent] whether the call belongs to a subagent session.
|
|
396
426
|
* @param {readonly object[]} [input.efforts] declared vocabulary.
|
|
397
427
|
* @param {string} [input.defaultEffort] route/model default depth.
|
|
398
428
|
* @param {object} rawCfg plugin config.
|
|
399
429
|
* @returns {string | undefined} the level to send, or undefined to leave the request alone.
|
|
400
430
|
*/
|
|
401
|
-
export function resolveCallEffort({ requested, purpose, efforts, defaultEffort }, rawCfg) {
|
|
431
|
+
export function resolveCallEffort({ requested, purpose, isSubagent, efforts, defaultEffort }, rawCfg) {
|
|
402
432
|
const cfg = normalizeConfig(rawCfg);
|
|
403
|
-
if (requested !== undefined && requested !== AUTO_EFFORT) return undefined;
|
|
404
433
|
const depths = depthLevels(efforts);
|
|
405
434
|
if (depths.length === 0) return undefined;
|
|
406
|
-
|
|
407
|
-
|
|
435
|
+
const aux = isAuxPurpose(purpose, cfg) ? clampEffort(cfg.auxLevel, efforts) : undefined;
|
|
436
|
+
// A pinned subagent depth outranks the child's own or inherited selection:
|
|
437
|
+
// without that, a child inheriting the parent's fixed depth could never be
|
|
438
|
+
// lowered and the setting would be inert for the common case. Cheap calls
|
|
439
|
+
// still win, because a summary request has no task difficulty to describe.
|
|
440
|
+
if (isSubagent === true && cfg.subagentLevel !== undefined && cfg.subagentLevel !== 'inherit') {
|
|
408
441
|
if (aux !== undefined) return aux;
|
|
442
|
+
return cfg.subagentLevel === AUTO_EFFORT
|
|
443
|
+
? autoTarget(cfg, efforts, defaultEffort)
|
|
444
|
+
: clampEffort(cfg.subagentLevel, efforts);
|
|
409
445
|
}
|
|
446
|
+
if (requested !== undefined && requested !== AUTO_EFFORT) return undefined;
|
|
447
|
+
if (aux !== undefined) return aux;
|
|
410
448
|
if (requested === undefined) return undefined;
|
|
411
|
-
|
|
412
|
-
? defaultEffort
|
|
413
|
-
: cfg.autoLevel;
|
|
414
|
-
if (typeof target === 'string' && depths.includes(target)) return target;
|
|
415
|
-
if (typeof target === 'string') return clampEffort(target, efforts);
|
|
416
|
-
return clampEffort('high', efforts, depths[depths.length - 1]);
|
|
449
|
+
return autoTarget(cfg, efforts, defaultEffort);
|
|
417
450
|
}
|