dsh-thinking-levels 4.4.5 → 4.4.7
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.de.md +11 -0
- package/CHANGELOG.es.md +11 -0
- package/CHANGELOG.fr.md +11 -0
- package/CHANGELOG.it.md +11 -0
- package/CHANGELOG.ja.md +11 -0
- package/CHANGELOG.ko.md +11 -0
- package/CHANGELOG.md +11 -0
- package/CHANGELOG.ru.md +11 -0
- package/README.de.md +2 -0
- package/README.es.md +2 -0
- package/README.fr.md +2 -0
- package/README.it.md +2 -0
- package/README.ja.md +2 -0
- package/README.ko.md +2 -0
- package/README.md +2 -0
- package/README.ru.md +2 -0
- package/README.zh.md +2 -0
- package/dsh.plugin.json +16 -16
- package/lib/auto-schedule-projection.d.ts +108 -0
- package/lib/auto-schedule-projection.js +141 -0
- package/lib/billing-projection.d.ts +9 -9
- package/lib/client.js +20 -2
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +12 -10
- package/lib/index.js +26 -4
- package/lib/session-events.d.ts +25 -8
- package/lib/session-events.js +33 -15
- package/lib/thinking-level.d.ts +27 -10
- package/lib/thinking-level.js +22 -19
- package/package.json +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -23,12 +23,14 @@
|
|
|
23
23
|
* - `agent/request` waterfall (packages/core/agent-loop/src/agent.ts
|
|
24
24
|
* buildRequest): each listener may return a modified GenerateOptions for
|
|
25
25
|
* the next listener — the sanctioned way to adjust request config.
|
|
26
|
-
* - `session.events` (agent.session)
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
26
|
+
* - `session.events` (agent.session) carried the step's tool/call records up to
|
|
27
|
+
* host 0.1.0-rc.8 only; from 0.1.2-rc.1 on the log is read through the
|
|
28
|
+
* projection registry instead (`tlAutoSchedule`, issue #6). The deprecated
|
|
29
|
+
* synchronous readers (`eventAt/snapshotEvents/ownEvents`) are prohibited for
|
|
30
|
+
* new production calls by `packages/core/session/README.md:62`.
|
|
31
|
+
* - The session's EXPLICIT effort pick is folded from `model/selection` events:
|
|
32
|
+
* the host seeds `reasoningEffort` from the previous request header (this
|
|
33
|
+
* plugin's own output), so the seed must never be read as a manual pick.
|
|
32
34
|
* - declarative settings (DSH 0.1.7+): the runtime-adjustable `Config` fields
|
|
33
35
|
* are marked `.volatile()`, the host generates the settings form from the
|
|
34
36
|
* schema alone, and the plugin reads the live values per request.
|
|
@@ -107,7 +109,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
107
109
|
allowUpgrade: z<boolean, boolean, "volatile-defined">;
|
|
108
110
|
takeover: z<boolean, boolean, "volatile-defined">;
|
|
109
111
|
takeoverUi: z<boolean, boolean, "volatile-defined">;
|
|
110
|
-
defaultPricing: z<"
|
|
112
|
+
defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "volatile-defined">;
|
|
111
113
|
models: z<import("@deepseek-ai/cosmokit").Dict<{
|
|
112
114
|
vision?: boolean | null | undefined;
|
|
113
115
|
thinking?: boolean | null | undefined;
|
|
@@ -126,7 +128,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
126
128
|
allowUpgrade: z<boolean, boolean, "volatile-defined">;
|
|
127
129
|
takeover: z<boolean, boolean, "volatile-defined">;
|
|
128
130
|
takeoverUi: z<boolean, boolean, "volatile-defined">;
|
|
129
|
-
defaultPricing: z<"
|
|
131
|
+
defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "volatile-defined">;
|
|
130
132
|
models: z<import("@deepseek-ai/cosmokit").Dict<{
|
|
131
133
|
vision?: boolean | null | undefined;
|
|
132
134
|
thinking?: boolean | null | undefined;
|
|
@@ -153,7 +155,7 @@ export declare const LegacyConfig: z<Schemastery.ObjectS<NoInfer<{
|
|
|
153
155
|
allowUpgrade: z<boolean, boolean, "defined">;
|
|
154
156
|
takeover: z<boolean, boolean, "defined">;
|
|
155
157
|
takeoverUi: z<boolean, boolean, "defined">;
|
|
156
|
-
defaultPricing: z<"
|
|
158
|
+
defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "defined">;
|
|
157
159
|
models: z<import("@deepseek-ai/cosmokit").Dict<{
|
|
158
160
|
vision?: boolean | null | undefined;
|
|
159
161
|
thinking?: boolean | null | undefined;
|
|
@@ -172,7 +174,7 @@ export declare const LegacyConfig: z<Schemastery.ObjectS<NoInfer<{
|
|
|
172
174
|
allowUpgrade: z<boolean, boolean, "defined">;
|
|
173
175
|
takeover: z<boolean, boolean, "defined">;
|
|
174
176
|
takeoverUi: z<boolean, boolean, "defined">;
|
|
175
|
-
defaultPricing: z<"
|
|
177
|
+
defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "defined">;
|
|
176
178
|
models: z<import("@deepseek-ai/cosmokit").Dict<{
|
|
177
179
|
vision?: boolean | null | undefined;
|
|
178
180
|
thinking?: boolean | null | undefined;
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import z from '@deepseek-ai/schemastery';
|
|
|
2
2
|
import { assertEffortId, reasoningEffortSupported, resolveEffortInjection } from "./thinking-level.js";
|
|
3
3
|
import { buildBillingDefinition } from "./billing-projection.js";
|
|
4
4
|
import { recentToolCalls } from "./session-events.js";
|
|
5
|
+
import { buildAutoScheduleDefinition, readAutoSchedule, requestedEffortOf } from "./auto-schedule-projection.js";
|
|
5
6
|
import { CONTEXT_WINDOW_MAX, CONTEXT_WINDOW_MIN } from "./context-window.js";
|
|
6
7
|
import { PI_AI_NAMESPACE, TAKEOVER_NAMESPACE_CANDIDATES, takeoverPatch, takeoverRoutesOf, withOfficialCompatFixes, } from "./takeover-sync.js";
|
|
7
8
|
import { describeSettings, readSection, readSectionOf, resolveNamespaceOf } from "./settings-read.js";
|
|
@@ -389,6 +390,17 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
|
|
|
389
390
|
}
|
|
390
391
|
});
|
|
391
392
|
const current = () => resolveLiveConfig(source());
|
|
393
|
+
ctx.inject?.(['sessionProjections'], (scope) => {
|
|
394
|
+
const registry = scope.sessionProjections;
|
|
395
|
+
if (typeof registry?.stateOf !== 'function' || typeof registry.register !== 'function')
|
|
396
|
+
return;
|
|
397
|
+
try {
|
|
398
|
+
registry.register(buildAutoScheduleDefinition());
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
console.warn(`[dsh-thinking-levels] tlAutoSchedule register failed (auto falls back to the legacy read): ${error instanceof Error ? error.message : String(error)}`);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
392
404
|
ctx.on('loader/volatile-update', () => {
|
|
393
405
|
assertEffortId(resolveLiveConfig(config).level, 'dsh-thinking-levels config.level');
|
|
394
406
|
// A flipped takeover switch mirrors immediately (identity-gated).
|
|
@@ -492,11 +504,18 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
|
|
|
492
504
|
// Unsupported fields are stripped, not sent; a resolved low/auto schedule
|
|
493
505
|
// only ever reaches models whose metadata admits the level.
|
|
494
506
|
const capabilityFor = await capability.resolve(seed.provider, seed.model);
|
|
495
|
-
|
|
507
|
+
// Folded projection state (issue #6): recent tool samples + the session's
|
|
508
|
+
// explicit pick. `undefined` on registries without `stateOf` (0.1.0-rc.8).
|
|
509
|
+
const session = payload.agent?.session;
|
|
510
|
+
const autoSchedule = readAutoSchedule(ctx, session);
|
|
511
|
+
const calls = autoSchedule?.samples ?? recentToolCalls(payload.agent);
|
|
512
|
+
// Intent comes from the session/config, never from the seed: the host
|
|
513
|
+
// echoes this plugin's own last injection back through the header.
|
|
514
|
+
const requested = requestedEffortOf(autoSchedule, cfg.level);
|
|
496
515
|
const decision = resolveEffortInjection({
|
|
497
516
|
supportsReasoning: capabilityFor.supportsReasoning,
|
|
517
|
+
requested,
|
|
498
518
|
seedEffort: seed.reasoningEffort,
|
|
499
|
-
selected: cfg.level,
|
|
500
519
|
recentCalls: calls,
|
|
501
520
|
allowDowngrade: cfg.allowDowngrade,
|
|
502
521
|
allowUpgrade: cfg.allowUpgrade,
|
|
@@ -512,8 +531,11 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
|
|
|
512
531
|
return stripped;
|
|
513
532
|
}
|
|
514
533
|
// Summary-only log: individual tool names/arg sizes are workflow metadata
|
|
515
|
-
// that need not land in the host log; count and decision suffice.
|
|
516
|
-
|
|
534
|
+
// that need not land in the host log; count and decision suffice. `user=`
|
|
535
|
+
// and `src=` make the runtime proof for issue #6 readable: a healthy
|
|
536
|
+
// session shows `src=projection`, `calls>0` after tool activity, and
|
|
537
|
+
// `user=auto` on every request after the first.
|
|
538
|
+
ctx.logger?.info?.('[thinking-levels] agent/request: model=%s/%s user=%s seed=%s calls=%d => level=%s src=%s', String(seed.provider), String(seed.model), String(requested), String(seed.reasoningEffort), calls.length, decision.level, autoSchedule === undefined ? 'legacy' : 'projection');
|
|
517
539
|
return { ...seed, reasoningEffort: decision.level };
|
|
518
540
|
}, { prepend: true });
|
|
519
541
|
// Advertise the `auto` mask (and, for configurer-confirmed rc.6-era models,
|
package/lib/session-events.d.ts
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Session tool-call sampling for dsh-thinking-levels.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Two readers, one extraction:
|
|
5
|
+
* - {@link toolSampleOf} normalizes a single raw Session event and is shared
|
|
6
|
+
* with the `tlAutoSchedule` projection (`auto-schedule-projection.ts`), so
|
|
7
|
+
* the `tool/call` wire shape lives in exactly one place.
|
|
8
|
+
* - {@link recentToolCalls} is the LEGACY pull path. `session.events` only
|
|
9
|
+
* ever existed on hosts up to 0.1.0-rc.8 (verified: `get events()` present at
|
|
10
|
+
* `dsh-v0.1.0-rc.8`, zero hits from `dsh-v0.1.2-rc.1` on), so on every newer
|
|
11
|
+
* line it returns `[]` — which is exactly the issue #6 defect. It survives
|
|
12
|
+
* only as the 0.1.0-rc.8 fallback for hosts whose projection registry
|
|
13
|
+
* predates `stateOf`.
|
|
9
14
|
*/
|
|
10
15
|
import type { ToolCallSample } from './thinking-level.ts';
|
|
11
16
|
/** How many recent tool calls to sample for one decision. */
|
|
12
17
|
export declare const TOOL_SAMPLE_WINDOW = 8;
|
|
18
|
+
/** Approximate argument size in characters (payload heft); unknown shapes read as 0. */
|
|
19
|
+
export declare function argsSizeOf(argumentsValue: unknown): number;
|
|
13
20
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
21
|
+
* Normalize one raw Session event into a tool-call sample.
|
|
22
|
+
*
|
|
23
|
+
* @param event - any committed Session event.
|
|
24
|
+
* @returns the sample, or undefined for any other event / malformed record.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toolSampleOf(event: unknown): ToolCallSample | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* LEGACY: recent tool calls off `agent.session.events`, oldest first.
|
|
29
|
+
*
|
|
30
|
+
* Only 0.1.0-rc.8 carries that array property; every host from 0.1.2-rc.1 on
|
|
31
|
+
* drops it in favour of `eventAt()/snapshotEvents()/ownEvents()`, so this
|
|
32
|
+
* returns `[]` there. Callers must treat `[]` as "no samples available" and
|
|
33
|
+
* prefer the projection read.
|
|
17
34
|
*
|
|
18
35
|
* @param agent - the `payload.agent` value from the `agent/request` waterfall.
|
|
19
36
|
* @returns the sampled tool calls, or `[]` for a fresh prompt / unknown shape.
|
package/lib/session-events.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Session tool-call sampling for dsh-thinking-levels.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Two readers, one extraction:
|
|
5
|
+
* - {@link toolSampleOf} normalizes a single raw Session event and is shared
|
|
6
|
+
* with the `tlAutoSchedule` projection (`auto-schedule-projection.ts`), so
|
|
7
|
+
* the `tool/call` wire shape lives in exactly one place.
|
|
8
|
+
* - {@link recentToolCalls} is the LEGACY pull path. `session.events` only
|
|
9
|
+
* ever existed on hosts up to 0.1.0-rc.8 (verified: `get events()` present at
|
|
10
|
+
* `dsh-v0.1.0-rc.8`, zero hits from `dsh-v0.1.2-rc.1` on), so on every newer
|
|
11
|
+
* line it returns `[]` — which is exactly the issue #6 defect. It survives
|
|
12
|
+
* only as the 0.1.0-rc.8 fallback for hosts whose projection registry
|
|
13
|
+
* predates `stateOf`.
|
|
9
14
|
*/
|
|
10
15
|
/** How many recent tool calls to sample for one decision. */
|
|
11
16
|
export const TOOL_SAMPLE_WINDOW = 8;
|
|
@@ -19,13 +24,29 @@ function isToolCallEvent(event) {
|
|
|
19
24
|
return isRecord(event.data);
|
|
20
25
|
}
|
|
21
26
|
/** Approximate argument size in characters (payload heft); unknown shapes read as 0. */
|
|
22
|
-
function argsSizeOf(argumentsValue) {
|
|
27
|
+
export function argsSizeOf(argumentsValue) {
|
|
23
28
|
return typeof argumentsValue === 'string' ? argumentsValue.length : 0;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* Normalize one raw Session event into a tool-call sample.
|
|
32
|
+
*
|
|
33
|
+
* @param event - any committed Session event.
|
|
34
|
+
* @returns the sample, or undefined for any other event / malformed record.
|
|
35
|
+
*/
|
|
36
|
+
export function toolSampleOf(event) {
|
|
37
|
+
if (!isToolCallEvent(event))
|
|
38
|
+
return undefined;
|
|
39
|
+
const data = event.data;
|
|
40
|
+
const name = typeof data.name === 'string' && data.name.length > 0 ? data.name : 'tool';
|
|
41
|
+
return { name, argsSize: argsSizeOf(data.arguments) };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* LEGACY: recent tool calls off `agent.session.events`, oldest first.
|
|
45
|
+
*
|
|
46
|
+
* Only 0.1.0-rc.8 carries that array property; every host from 0.1.2-rc.1 on
|
|
47
|
+
* drops it in favour of `eventAt()/snapshotEvents()/ownEvents()`, so this
|
|
48
|
+
* returns `[]` there. Callers must treat `[]` as "no samples available" and
|
|
49
|
+
* prefer the projection read.
|
|
29
50
|
*
|
|
30
51
|
* @param agent - the `payload.agent` value from the `agent/request` waterfall.
|
|
31
52
|
* @returns the sampled tool calls, or `[]` for a fresh prompt / unknown shape.
|
|
@@ -38,12 +59,9 @@ export function recentToolCalls(agent) {
|
|
|
38
59
|
return [];
|
|
39
60
|
const samples = [];
|
|
40
61
|
for (let index = session.events.length - 1; index >= 0 && samples.length < TOOL_SAMPLE_WINDOW; index -= 1) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
const data = event.data;
|
|
45
|
-
const name = typeof data.name === 'string' && data.name.length > 0 ? data.name : 'tool';
|
|
46
|
-
samples.push({ name, argsSize: argsSizeOf(data.arguments) });
|
|
62
|
+
const sample = toolSampleOf(session.events[index]);
|
|
63
|
+
if (sample !== undefined)
|
|
64
|
+
samples.push(sample);
|
|
47
65
|
}
|
|
48
66
|
return samples.reverse();
|
|
49
67
|
}
|
package/lib/thinking-level.d.ts
CHANGED
|
@@ -88,10 +88,24 @@ export declare function reasoningEffortSupported(reasoning: unknown): boolean;
|
|
|
88
88
|
export interface EffortInjectionInput {
|
|
89
89
|
/** Whether the target model advertises reasoning-effort support. */
|
|
90
90
|
supportsReasoning: boolean;
|
|
91
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* The level this request was ASKED for: the session's explicit pick (folded
|
|
93
|
+
* from `model/selection`) when present, else the plugin-configured default.
|
|
94
|
+
*
|
|
95
|
+
* Never derive this from the request seed. From dsh 0.1.2-rc.1 on, the host
|
|
96
|
+
* seeds `reasoningEffort` from the previous `request/header` — which is this
|
|
97
|
+
* plugin's own output (`core/agent-loop/src/agent.ts:573-581`). Reading it as
|
|
98
|
+
* a manual pick made `auto` resolve once and then stay frozen for the rest of
|
|
99
|
+
* the session (issue #6, bug 2).
|
|
100
|
+
*/
|
|
101
|
+
requested: EffortId;
|
|
102
|
+
/**
|
|
103
|
+
* The `reasoningEffort` already present on the request seed (host echo of a
|
|
104
|
+
* previous header, or route inheritance). Used ONLY to recognise the `on`
|
|
105
|
+
* toggle and to strip an inherited effort from a model that cannot take one —
|
|
106
|
+
* never as a manual-pick signal.
|
|
107
|
+
*/
|
|
92
108
|
seedEffort: unknown;
|
|
93
|
-
/** Plugin-configured default level when the seed carries none. */
|
|
94
|
-
selected: EffortId;
|
|
95
109
|
/** Recent tool calls of the step, for the auto scheduler. */
|
|
96
110
|
recentCalls: readonly ToolCallSample[];
|
|
97
111
|
/** Scheduler preference: allow the scheduler to drop below `high`. */
|
|
@@ -133,18 +147,21 @@ export declare function clampToEfforts(level: EffortId, efforts: readonly string
|
|
|
133
147
|
* - A model without reasoning support never receives the field: dsh would
|
|
134
148
|
* throw UNSUPPORTED_REASONING_EFFORT, so the seed's inherited effort (from a
|
|
135
149
|
* previous route or session header) is stripped.
|
|
136
|
-
* - A manual wire selection passes through unchanged when the
|
|
137
|
-
* it; an unsupported manual pick is stripped rather than
|
|
138
|
-
* asked for that exact level).
|
|
150
|
+
* - A manual wire selection (`requested`) passes through unchanged when the
|
|
151
|
+
* model advertises it; an unsupported manual pick is stripped rather than
|
|
152
|
+
* clamped (the user asked for that exact level).
|
|
139
153
|
* - `on` is the enable-thinking toggle, never a wire level: on a toggle-only
|
|
140
154
|
* model it injects the advertised thinking level (`high`), which the wire
|
|
141
155
|
* serializes as enable_thinking without a reasoning_effort; an
|
|
142
156
|
* effort-capable model does not advertise `on`, so it is stripped.
|
|
143
|
-
* - `auto`
|
|
144
|
-
*
|
|
145
|
-
*
|
|
157
|
+
* - `auto` resolves through the scheduler; the result is clamped to the
|
|
158
|
+
* model's advertised levels, so a scheduled `low` on a model that only takes
|
|
159
|
+
* off/high (Qwen3.6) becomes `high` instead of an error.
|
|
160
|
+
*
|
|
161
|
+
* The manual/auto branch reads `requested` only. The seed no longer influences
|
|
162
|
+
* it, so a header echoed back by the host cannot masquerade as a user pick.
|
|
146
163
|
*
|
|
147
|
-
* @param input - model capability plus the seed's
|
|
164
|
+
* @param input - model capability plus the requested level and the seed's effort.
|
|
148
165
|
* @returns whether to inject and the level to set.
|
|
149
166
|
*/
|
|
150
167
|
export declare function resolveEffortInjection(input: EffortInjectionInput): EffortInjectionDecision;
|
package/lib/thinking-level.js
CHANGED
|
@@ -147,50 +147,53 @@ export function clampToEfforts(level, efforts) {
|
|
|
147
147
|
* - A model without reasoning support never receives the field: dsh would
|
|
148
148
|
* throw UNSUPPORTED_REASONING_EFFORT, so the seed's inherited effort (from a
|
|
149
149
|
* previous route or session header) is stripped.
|
|
150
|
-
* - A manual wire selection passes through unchanged when the
|
|
151
|
-
* it; an unsupported manual pick is stripped rather than
|
|
152
|
-
* asked for that exact level).
|
|
150
|
+
* - A manual wire selection (`requested`) passes through unchanged when the
|
|
151
|
+
* model advertises it; an unsupported manual pick is stripped rather than
|
|
152
|
+
* clamped (the user asked for that exact level).
|
|
153
153
|
* - `on` is the enable-thinking toggle, never a wire level: on a toggle-only
|
|
154
154
|
* model it injects the advertised thinking level (`high`), which the wire
|
|
155
155
|
* serializes as enable_thinking without a reasoning_effort; an
|
|
156
156
|
* effort-capable model does not advertise `on`, so it is stripped.
|
|
157
|
-
* - `auto`
|
|
158
|
-
*
|
|
159
|
-
*
|
|
157
|
+
* - `auto` resolves through the scheduler; the result is clamped to the
|
|
158
|
+
* model's advertised levels, so a scheduled `low` on a model that only takes
|
|
159
|
+
* off/high (Qwen3.6) becomes `high` instead of an error.
|
|
160
160
|
*
|
|
161
|
-
*
|
|
161
|
+
* The manual/auto branch reads `requested` only. The seed no longer influences
|
|
162
|
+
* it, so a header echoed back by the host cannot masquerade as a user pick.
|
|
163
|
+
*
|
|
164
|
+
* @param input - model capability plus the requested level and the seed's effort.
|
|
162
165
|
* @returns whether to inject and the level to set.
|
|
163
166
|
*/
|
|
164
167
|
export function resolveEffortInjection(input) {
|
|
165
|
-
const { supportsReasoning,
|
|
168
|
+
const { supportsReasoning, requested, efforts, toggleOnly } = input;
|
|
166
169
|
if (!supportsReasoning)
|
|
167
170
|
return { inject: false };
|
|
168
171
|
if (toggleOnly) {
|
|
169
172
|
// Toggle-only model (Qwen3.6 / mimo-v2.5 style): thinking is an on/off
|
|
170
173
|
// switch expressed through the provider's enable_thinking semantics.
|
|
171
174
|
// - Off → inject `off`: the provider maps it to thinking disabled.
|
|
172
|
-
// - On / any other
|
|
173
|
-
// short-circuit adapter serializes a non-off effort as
|
|
174
|
-
// true — an explicit "thinking on" signal the wire needs.
|
|
175
|
-
// with NO effort at all is the ambiguous case: leaving it
|
|
176
|
-
// on the provider default, which some gateways
|
|
177
|
-
return { inject: true, level:
|
|
175
|
+
// - On / any other request → inject `high` (the advertised toggle level):
|
|
176
|
+
// the short-circuit adapter serializes a non-off effort as
|
|
177
|
+
// enable_thinking true — an explicit "thinking on" signal the wire needs.
|
|
178
|
+
// (A request with NO effort at all is the ambiguous case: leaving it
|
|
179
|
+
// absent relies on the provider default, which some gateways read as off.)
|
|
180
|
+
return { inject: true, level: requested === 'off' ? 'off' : 'high' };
|
|
178
181
|
}
|
|
179
|
-
if (seedEffort === 'on') {
|
|
182
|
+
if (requested === 'on' || input.seedEffort === 'on') {
|
|
180
183
|
// A stray On on an effort-capable model: never a wire level, stripped.
|
|
181
184
|
return { inject: false };
|
|
182
185
|
}
|
|
183
|
-
if (
|
|
186
|
+
if (requested !== 'auto') {
|
|
184
187
|
// A manual pick is the user asking for that exact level: pass it through
|
|
185
188
|
// only when the model advertises it, strip it otherwise (no clamping of an
|
|
186
189
|
// explicit choice).
|
|
187
|
-
return efforts.includes(
|
|
188
|
-
? { inject: true, level:
|
|
190
|
+
return efforts.includes(requested)
|
|
191
|
+
? { inject: true, level: requested }
|
|
189
192
|
: { inject: false };
|
|
190
193
|
}
|
|
191
194
|
const level = decideEffort({
|
|
192
195
|
recentCalls: input.recentCalls,
|
|
193
|
-
selected:
|
|
196
|
+
selected: 'auto',
|
|
194
197
|
allowDowngrade: input.allowDowngrade,
|
|
195
198
|
allowUpgrade: input.allowUpgrade,
|
|
196
199
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-thinking-levels",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org",
|
|
6
6
|
"access": "public",
|
|
@@ -103,11 +103,11 @@
|
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@deepseek-ai/cordis": "^4.0.4",
|
|
105
105
|
"@deepseek-ai/cosmokit": "^1.8.5",
|
|
106
|
-
"@deepseek-ai/dsh-client-locale": "0.2.1-rc.
|
|
107
|
-
"@deepseek-ai/dsh-client-store": "0.2.1-rc.
|
|
108
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.
|
|
109
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.
|
|
110
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.
|
|
106
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-rc.3",
|
|
107
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-rc.3",
|
|
108
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.3",
|
|
109
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.3",
|
|
110
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.3",
|
|
111
111
|
"@deepseek-ai/schemastery": "^3.18.4",
|
|
112
112
|
"@eslint/js": "^10.0.1",
|
|
113
113
|
"@types/node": "^24.0.0",
|