dsh-thinking-levels 3.0.1 → 3.1.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/INSTALL.ja.md +162 -163
- package/INSTALL.ko.md +162 -163
- package/INSTALL.md +173 -174
- package/INSTALL.zh.md +174 -174
- package/README.ja.md +173 -172
- package/README.ko.md +173 -172
- package/README.md +15 -20
- package/README.zh.md +182 -181
- package/dsh.plugin.json +16 -16
- package/lib/client.js +8 -1186
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +63 -12
- package/lib/index.js +40 -46
- package/package.json +12 -10
package/lib/index.d.ts
CHANGED
|
@@ -29,10 +29,12 @@
|
|
|
29
29
|
* scope-event registry (`packages/core/scope/src/scoped-events.generated.ts`)
|
|
30
30
|
* lists no such name in 0.1.1-rc.2 or 0.1.2-rc.1, so tool recognition must
|
|
31
31
|
* stay a pull from `session.events`.
|
|
32
|
-
* - settings
|
|
33
|
-
* the
|
|
32
|
+
* - declarative settings (DSH 0.1.7+): the runtime-adjustable `Config` fields
|
|
33
|
+
* are marked `.volatile()`, the host generates the settings form from the
|
|
34
|
+
* schema alone, and the plugin reads the live values per request.
|
|
34
35
|
*/
|
|
35
36
|
import type { Context } from '@deepseek-ai/cordis';
|
|
37
|
+
import type { Volatile } from '@deepseek-ai/cosmokit';
|
|
36
38
|
import z from '@deepseek-ai/schemastery';
|
|
37
39
|
import { type EffortId } from './thinking-level.ts';
|
|
38
40
|
/** One configurer-confirmed capability override for a `provider/model` key. */
|
|
@@ -57,27 +59,76 @@ export interface ModelCapabilityOverride {
|
|
|
57
59
|
}
|
|
58
60
|
/** Plugin settings. */
|
|
59
61
|
export interface ThinkingLevelsConfig {
|
|
60
|
-
|
|
62
|
+
/** On a DSH 0.1.7+ host the schema's `.volatile()` fields arrive as live refs — read them through `readVolatile`. */
|
|
63
|
+
enabled: boolean | Volatile<boolean>;
|
|
61
64
|
/** User-selected level: off / on / minimal / low / medium / high / xhigh / max fix the wire level; `auto` schedules per step. */
|
|
62
|
-
level: EffortId
|
|
65
|
+
level: EffortId | Volatile<EffortId>;
|
|
63
66
|
/** Scheduler preference: allow dropping below the `high` hub. */
|
|
64
|
-
allowDowngrade: boolean
|
|
67
|
+
allowDowngrade: boolean | Volatile<boolean>;
|
|
65
68
|
/** Scheduler preference: allow lifting above the `high` hub to `max`. */
|
|
66
|
-
allowUpgrade: boolean
|
|
69
|
+
allowUpgrade: boolean | Volatile<boolean>;
|
|
67
70
|
/** Configurer-confirmed capability overrides, keyed `provider/model`. */
|
|
68
71
|
models: Record<string, ModelCapabilityOverride>;
|
|
69
72
|
}
|
|
70
73
|
/**
|
|
71
74
|
* Composition-entry schema: what a dsh profile may configure at assembly
|
|
72
|
-
* time (cordis.yml `config:` of the plugin row). The
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
+
* time (cordis.yml `config:` of the plugin row). The same schema doubles as
|
|
76
|
+
* the settings surface: DSH 0.1.7 renders the plugin's settings form from the
|
|
77
|
+
* `.volatile()` fields alone (no registration call), and hands `apply` the
|
|
78
|
+
* validated entry with those fields as live `Volatile` refs.
|
|
75
79
|
*/
|
|
76
|
-
export declare const Config: z<
|
|
80
|
+
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
81
|
+
enabled: z<boolean, boolean, "volatile-defined">;
|
|
82
|
+
level: z<"off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "volatile-defined">;
|
|
83
|
+
allowDowngrade: z<boolean, boolean, "volatile-defined">;
|
|
84
|
+
allowUpgrade: z<boolean, boolean, "volatile-defined">;
|
|
85
|
+
models: z<import("@deepseek-ai/cosmokit").Dict<{
|
|
86
|
+
vision?: boolean | null | undefined;
|
|
87
|
+
thinking?: boolean | null | undefined;
|
|
88
|
+
efforts?: false | ("off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max")[] | null | undefined;
|
|
89
|
+
contextWindow?: number | null | undefined;
|
|
90
|
+
} & import("@deepseek-ai/cosmokit").Dict, string>, import("@deepseek-ai/cosmokit").Dict<Schemastery.ObjectT<NoInfer<{
|
|
91
|
+
vision: z<boolean, boolean, "plain">;
|
|
92
|
+
thinking: z<boolean, boolean, "plain">;
|
|
93
|
+
efforts: z<false | ("off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max")[], false | ("off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max")[], "plain">;
|
|
94
|
+
contextWindow: z<number, number, "plain">;
|
|
95
|
+
}>>, string>, "defined">;
|
|
96
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
97
|
+
enabled: z<boolean, boolean, "volatile-defined">;
|
|
98
|
+
level: z<"off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "volatile-defined">;
|
|
99
|
+
allowDowngrade: z<boolean, boolean, "volatile-defined">;
|
|
100
|
+
allowUpgrade: z<boolean, boolean, "volatile-defined">;
|
|
101
|
+
models: z<import("@deepseek-ai/cosmokit").Dict<{
|
|
102
|
+
vision?: boolean | null | undefined;
|
|
103
|
+
thinking?: boolean | null | undefined;
|
|
104
|
+
efforts?: false | ("off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max")[] | null | undefined;
|
|
105
|
+
contextWindow?: number | null | undefined;
|
|
106
|
+
} & import("@deepseek-ai/cosmokit").Dict, string>, import("@deepseek-ai/cosmokit").Dict<Schemastery.ObjectT<NoInfer<{
|
|
107
|
+
vision: z<boolean, boolean, "plain">;
|
|
108
|
+
thinking: z<boolean, boolean, "plain">;
|
|
109
|
+
efforts: z<false | ("off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max")[], false | ("off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max")[], "plain">;
|
|
110
|
+
contextWindow: z<number, number, "plain">;
|
|
111
|
+
}>>, string>, "defined">;
|
|
112
|
+
}>>, "plain">;
|
|
77
113
|
/** Settings defaults, kept in lockstep with the schema defaults above. */
|
|
78
114
|
export declare const DEFAULT_CONFIG: ThinkingLevelsConfig;
|
|
79
|
-
/**
|
|
80
|
-
|
|
115
|
+
/**
|
|
116
|
+
* The `loader/volatile-update` event is emitted by the DSH 0.1.7+ loader when
|
|
117
|
+
* a `.volatile()` config field changes (no plugin remount). The dev pins
|
|
118
|
+
* predate the event, so the signature is augmented here — mirroring the host
|
|
119
|
+
* runtime, which passes the changed config paths.
|
|
120
|
+
*/
|
|
121
|
+
declare module '@deepseek-ai/cordis' {
|
|
122
|
+
interface Events {
|
|
123
|
+
'loader/volatile-update': (paths: string[]) => void;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Read a `.volatile()` field: a live `Volatile` ref on a DSH 0.1.7+ host, a
|
|
128
|
+
* plain value otherwise. `get()` may return undefined for an absent value, so
|
|
129
|
+
* the schema default is the fallback.
|
|
130
|
+
*/
|
|
131
|
+
export declare function readVolatile<T>(value: T | Volatile<T> | undefined, fallback: T): T;
|
|
81
132
|
/**
|
|
82
133
|
* Plugin body.
|
|
83
134
|
* @param ctx - host context carrying the agent-event dispatch.
|
package/lib/index.js
CHANGED
|
@@ -6,15 +6,16 @@ import { PI_AI_NAMESPACE, TAKEOVER_NAMESPACE, takeoverProvidersOf, withOfficialC
|
|
|
6
6
|
const effortId = z.union(['off', 'on', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
7
7
|
/**
|
|
8
8
|
* Composition-entry schema: what a dsh profile may configure at assembly
|
|
9
|
-
* time (cordis.yml `config:` of the plugin row). The
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* time (cordis.yml `config:` of the plugin row). The same schema doubles as
|
|
10
|
+
* the settings surface: DSH 0.1.7 renders the plugin's settings form from the
|
|
11
|
+
* `.volatile()` fields alone (no registration call), and hands `apply` the
|
|
12
|
+
* validated entry with those fields as live `Volatile` refs.
|
|
12
13
|
*/
|
|
13
14
|
export const Config = z.object({
|
|
14
|
-
enabled: z.boolean().default(true),
|
|
15
|
-
level: z.union(['off', 'on', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto']).default('auto'),
|
|
16
|
-
allowDowngrade: z.boolean().default(true),
|
|
17
|
-
allowUpgrade: z.boolean().default(false),
|
|
15
|
+
enabled: z.boolean().default(true).volatile(),
|
|
16
|
+
level: z.union(['off', 'on', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto']).default('auto').volatile(),
|
|
17
|
+
allowDowngrade: z.boolean().default(true).volatile(),
|
|
18
|
+
allowUpgrade: z.boolean().default(false).volatile(),
|
|
18
19
|
models: z.dict(z.object({
|
|
19
20
|
// schemastery fields are optional unless marked `.required()`.
|
|
20
21
|
vision: z.boolean(),
|
|
@@ -31,33 +32,32 @@ export const DEFAULT_CONFIG = {
|
|
|
31
32
|
allowUpgrade: false,
|
|
32
33
|
models: {},
|
|
33
34
|
};
|
|
34
|
-
/** Runtime-adjustable settings namespace: level + scheduler toggles. */
|
|
35
|
-
export const THINKING_LEVELS_SETTINGS_NAMESPACE = 'thinking-levels';
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* the host half has no value dependency on `@deepseek-ai/dsh-settings`.
|
|
41
|
-
* @param ctx - host context carrying the settings service.
|
|
42
|
-
* @param ns - settings namespace to register.
|
|
43
|
-
* @param schema - schemastery schema resolving the namespace value.
|
|
44
|
-
* @param entry - composition-entry config used as the `base` layer.
|
|
45
|
-
* @param hooks - source sink and change notification.
|
|
36
|
+
* Read a `.volatile()` field: a live `Volatile` ref on a DSH 0.1.7+ host, a
|
|
37
|
+
* plain value otherwise. `get()` may return undefined for an absent value, so
|
|
38
|
+
* the schema default is the fallback.
|
|
46
39
|
*/
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
export function readVolatile(value, fallback) {
|
|
41
|
+
if (value !== null && typeof value === 'object' && typeof value.get === 'function') {
|
|
42
|
+
const snapshot = value.get();
|
|
43
|
+
return (snapshot === undefined ? fallback : snapshot);
|
|
44
|
+
}
|
|
45
|
+
return value ?? fallback;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the live configuration snapshot: the runtime-adjustable fields are
|
|
49
|
+
* read through their (possibly volatile) composition-entry values on every
|
|
50
|
+
* call, so a committed settings change applies to the next request without a
|
|
51
|
+
* plugin remount.
|
|
52
|
+
*/
|
|
53
|
+
function resolveLiveConfig(config) {
|
|
54
|
+
return {
|
|
55
|
+
enabled: readVolatile(config.enabled, true),
|
|
56
|
+
level: readVolatile(config.level, 'auto'),
|
|
57
|
+
allowDowngrade: readVolatile(config.allowDowngrade, true),
|
|
58
|
+
allowUpgrade: readVolatile(config.allowUpgrade, false),
|
|
59
|
+
models: config.models,
|
|
60
|
+
};
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* The `auto` mask shown in the model directory: a user-facing level that is
|
|
@@ -221,23 +221,17 @@ function capabilityResolver(ctx) {
|
|
|
221
221
|
* @param config - resolved plugin configuration.
|
|
222
222
|
*/
|
|
223
223
|
export function apply(ctx, config = DEFAULT_CONFIG) {
|
|
224
|
-
if (!config.enabled)
|
|
225
|
-
return;
|
|
226
224
|
// Fail-loud: a stray config value (e.g. `medium` from an old profile) must
|
|
227
225
|
// not ride through into the model request, where dsh throws
|
|
228
226
|
// UNSUPPORTED_REASONING_EFFORT per request.
|
|
229
|
-
assertEffortId(config.level, 'dsh-thinking-levels config.level');
|
|
230
|
-
// Runtime-adjustable configuration
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
},
|
|
238
|
-
// The decision is read per request, so a committed change needs no
|
|
239
|
-
// re-registration.
|
|
240
|
-
onChange: () => { },
|
|
227
|
+
assertEffortId(resolveLiveConfig(config).level, 'dsh-thinking-levels config.level');
|
|
228
|
+
// Runtime-adjustable configuration: the `.volatile()` fields arrive as live
|
|
229
|
+
// refs (DSH 0.1.7+) and are re-read per request, so a committed settings
|
|
230
|
+
// change needs no re-registration; `loader/volatile-update` re-validates the
|
|
231
|
+
// committed level eagerly instead of failing on the next model request.
|
|
232
|
+
const current = () => resolveLiveConfig(config);
|
|
233
|
+
ctx.on('loader/volatile-update', () => {
|
|
234
|
+
assertEffortId(resolveLiveConfig(config).level, 'dsh-thinking-levels config.level');
|
|
241
235
|
});
|
|
242
236
|
// Official-compat bridge (check branch): write the OFFICIAL compat surface
|
|
243
237
|
// into the llm-pi-ai namespace for every provider that targets a custom
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-thinking-levels",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org",
|
|
6
6
|
"access": "public",
|
|
7
|
-
"tag": "dsh-0.1.
|
|
7
|
+
"tag": "dsh-0.1.7"
|
|
8
8
|
},
|
|
9
9
|
"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.",
|
|
10
10
|
"repository": {
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=22.19.0 || >=24.0.0",
|
|
49
|
-
"dsh": ">=0.1.
|
|
49
|
+
"dsh": ">=0.1.7-rc.1 <0.2.0-0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
53
|
-
"@deepseek-ai/dsh-client-locale": ">=0.1.
|
|
54
|
-
"@deepseek-ai/dsh-client-ui-renderer": ">=0.1.
|
|
55
|
-
"@deepseek-ai/dsh-client-ui-settings": ">=0.1.
|
|
56
|
-
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.
|
|
53
|
+
"@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.2.0-0",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-renderer": ">=0.1.7-rc.1 <0.2.0-0",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.1 <0.2.0-0",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.7-rc.1 <0.2.0-0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@deepseek-ai/dsh-client-locale": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
73
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
@@ -86,7 +86,8 @@
|
|
|
86
86
|
"tsdown": "^0.22.2",
|
|
87
87
|
"typescript": "^5.6.0",
|
|
88
88
|
"typescript-eslint": "^8.67.0",
|
|
89
|
-
"vitest": "^3.0.0"
|
|
89
|
+
"vitest": "^3.0.0",
|
|
90
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
90
91
|
},
|
|
91
92
|
"scripts": {
|
|
92
93
|
"build": "tsc -p tsconfig.build.json && tsdown",
|
|
@@ -109,4 +110,5 @@
|
|
|
109
110
|
],
|
|
110
111
|
"platform": "web"
|
|
111
112
|
}
|
|
112
|
-
}
|
|
113
|
+
}
|
|
114
|
+
}
|