dsh-model-switch 0.4.47 → 0.4.50
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 +39 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/cordis.patch.yml +7 -0
- package/lib/client.js +289 -153
- package/lib/index.js +89 -5
- package/lib/prime-memory-compat.js +5 -8
- package/lib/review-timeout.js +238 -0
- package/lib/types/client/ModelSwitchSettings.d.ts +2 -0
- package/lib/types/client/locales.d.ts +10 -0
- package/lib/types/client-contract.d.ts +11 -0
- package/lib/types/compatibility.d.ts +28 -2
- package/lib/types/host-settings.d.ts +15 -0
- package/lib/types/prime-memory-compat.d.ts +14 -0
- package/lib/types/review-timeout.d.ts +104 -0
- package/package.json +6 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable Auto-reviewer stream idle timeout.
|
|
3
|
+
*
|
|
4
|
+
* The reviewer call is a normal llm stream, so its idle watchdog is the one
|
|
5
|
+
* `@deepseek-ai/dsh-llm-pi-ai` puts on the **provider profile**:
|
|
6
|
+
* `providers.<id>.streamIdleTimeoutMs` (default 300 000 ms). There is no
|
|
7
|
+
* per-request override — `GenerateOptions` carries no timeout fields and the
|
|
8
|
+
* adapter reads the profile per call — so the only way to change the reviewer's
|
|
9
|
+
* timeout is to write that provider-profile key.
|
|
10
|
+
*
|
|
11
|
+
* Consequences, all surfaced in the UI copy:
|
|
12
|
+
*
|
|
13
|
+
* - The key lives on the provider, so it applies to **every** call through that
|
|
14
|
+
* provider (reviewer, main chat, other routes), not only the reviewer.
|
|
15
|
+
* - "Cancel the timeout" is legal only as the upstream ceiling
|
|
16
|
+
* (`MAX_TIMER_DELAY_MS` = 2147483647 ms ≈ 24.86 days); upstream rejects 0,
|
|
17
|
+
* negatives and Infinity, so the UI writes the ceiling and says so.
|
|
18
|
+
* - The profile document is read at Host start (same channel as the memory
|
|
19
|
+
* static pin), so a written value takes effect **after a restart**.
|
|
20
|
+
*
|
|
21
|
+
* Restoring is symmetric: the value a provider carried before the first
|
|
22
|
+
* overwrite is recorded in this plugin's own settings
|
|
23
|
+
* (`autoReviewTimeoutPrevious`) and written back when the setting returns to
|
|
24
|
+
* "follow the provider default", so clearing the setting never leaves an
|
|
25
|
+
* adapter-written value behind.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
30
|
+
import type { ModelSwitchSettings } from './host-settings.js';
|
|
31
|
+
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
|
32
|
+
export declare const name = "model-switch-review-timeout";
|
|
33
|
+
/** This row needs the Host's settings service (for `documentPath` and our ns). */
|
|
34
|
+
export declare const inject: string[];
|
|
35
|
+
/** The pi-ai row whose provider profiles carry `streamIdleTimeoutMs`. */
|
|
36
|
+
export declare const PI_AI_ROW = "llm-pi-ai";
|
|
37
|
+
/** Live state surfaced next to the reviewer card through the capabilities RPC. */
|
|
38
|
+
export declare const reviewTimeoutStatus: {
|
|
39
|
+
configuredMs: number | undefined;
|
|
40
|
+
applied: string[];
|
|
41
|
+
skipped: string[];
|
|
42
|
+
};
|
|
43
|
+
/** One resolved write decision. */
|
|
44
|
+
export interface ReviewTimeoutPlan {
|
|
45
|
+
/** Milliseconds to write per provider; undefined means "restore / follow default". */
|
|
46
|
+
readonly timeoutMs: number | undefined;
|
|
47
|
+
/** Reviewer provider ids collected from the global route and every group. */
|
|
48
|
+
readonly providers: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the stored setting into concrete write values.
|
|
52
|
+
*
|
|
53
|
+
* Stored values are user intent: absent = follow the provider default, `0` =
|
|
54
|
+
* cancelled (written as the upstream ceiling), anything else is clamped into
|
|
55
|
+
* the upstream-legal range so a hand-edited profile cannot produce a rejected
|
|
56
|
+
* value.
|
|
57
|
+
*
|
|
58
|
+
* @param settings - the plugin's current settings.
|
|
59
|
+
* @returns the write value and the reviewer providers to apply it to.
|
|
60
|
+
*/
|
|
61
|
+
export declare function planReviewTimeout(settings: ModelSwitchSettings): ReviewTimeoutPlan;
|
|
62
|
+
/** Why a provider was left untouched. */
|
|
63
|
+
export type ReviewTimeoutSkip = 'missing-row' | 'missing-provider' | 'unrecorded';
|
|
64
|
+
/** Result of one document patch attempt. */
|
|
65
|
+
export interface ReviewTimeoutPatch {
|
|
66
|
+
readonly text: string;
|
|
67
|
+
readonly outcome: 'written' | 'unchanged' | ReviewTimeoutSkip;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set or remove one pi-ai provider's `streamIdleTimeoutMs` in the profile
|
|
71
|
+
* document, touching only that provider's block.
|
|
72
|
+
*
|
|
73
|
+
* The pi-ai row's layout is fixed by its schema: the provider sits at six
|
|
74
|
+
* spaces under `providers:`, its fields at eight. The patch inserts the key at
|
|
75
|
+
* the top of the provider block, replaces it in place, or removes it, and never
|
|
76
|
+
* touches another provider or row.
|
|
77
|
+
*
|
|
78
|
+
* @param text - the full profile document.
|
|
79
|
+
* @param provider - the pi-ai provider id.
|
|
80
|
+
* @param timeoutMs - the value to write, or undefined to remove the key.
|
|
81
|
+
* @returns the patched text and what happened.
|
|
82
|
+
*/
|
|
83
|
+
export declare function patchProviderIdleTimeout(text: string, provider: string, timeoutMs: number | undefined): ReviewTimeoutPatch;
|
|
84
|
+
/**
|
|
85
|
+
* Read a provider's current `streamIdleTimeoutMs` from the document.
|
|
86
|
+
*
|
|
87
|
+
* Used to record the pre-overwrite value so a later reset restores it.
|
|
88
|
+
*
|
|
89
|
+
* @param text - the full profile document.
|
|
90
|
+
* @param provider - the pi-ai provider id.
|
|
91
|
+
* @returns the value, or null when the key is absent.
|
|
92
|
+
*/
|
|
93
|
+
export declare function readProviderIdleTimeout(text: string, provider: string): number | null;
|
|
94
|
+
/**
|
|
95
|
+
* Row entry point: apply the configured timeout to the reviewer providers'
|
|
96
|
+
* pi-ai profiles in the profile document.
|
|
97
|
+
*
|
|
98
|
+
* Every failure is contained and logged; a broken document must never take the
|
|
99
|
+
* Host down. The write is idempotent: replays find the value already in place
|
|
100
|
+
* and do nothing.
|
|
101
|
+
*
|
|
102
|
+
* @param ctx - this row's context.
|
|
103
|
+
*/
|
|
104
|
+
export declare function apply(ctx: Context): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model-switch",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -66,6 +66,10 @@
|
|
|
66
66
|
"types": "./lib/types/prime-memory-compat.d.ts",
|
|
67
67
|
"default": "./lib/prime-memory-compat.js"
|
|
68
68
|
},
|
|
69
|
+
"./review-timeout": {
|
|
70
|
+
"types": "./lib/types/review-timeout.d.ts",
|
|
71
|
+
"default": "./lib/review-timeout.js"
|
|
72
|
+
},
|
|
69
73
|
"./package.json": "./package.json"
|
|
70
74
|
},
|
|
71
75
|
"files": [
|
|
@@ -110,6 +114,7 @@
|
|
|
110
114
|
"platform": "web"
|
|
111
115
|
},
|
|
112
116
|
"compatibility": {
|
|
117
|
+
"dshRuntime": ">=0.2.0-rc.2",
|
|
113
118
|
"dshReleases": {
|
|
114
119
|
"0.1.7-alpha.2": "compatible",
|
|
115
120
|
"0.1.7-rc.1": "compatible",
|