dsh-model-switch 0.4.52 → 0.4.54
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 +22 -0
- package/lib/automode-compat.js +49 -8
- package/lib/client.js +116 -10
- package/lib/fiber-hot-update-DrZANcwD.js +74 -0
- package/lib/index.js +9 -1
- package/lib/prime-memory-compat.js +76 -12
- package/lib/review-timeout-DXRFybFp.js +331 -0
- package/lib/review-timeout.js +2 -238
- package/lib/types/automode-compat.d.ts +8 -0
- package/lib/types/capabilities-rpc.d.ts +10 -0
- package/lib/types/client/locales.d.ts +3 -3
- package/lib/types/fiber-hot-update.d.ts +58 -0
- package/lib/types/prime-memory-compat.d.ts +27 -0
- package/lib/types/review-timeout.d.ts +31 -2
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-apply a plugin row's config in the running Host, without a Host restart.
|
|
3
|
+
*
|
|
4
|
+
* Cordis exposes this seam on the fiber that owns one loader row
|
|
5
|
+
* (`@deepseek-ai/cordis` `lib/types/fiber.d.ts`):
|
|
6
|
+
*
|
|
7
|
+
* update(config: any, noSave?: boolean): void
|
|
8
|
+
* // Validate and apply new config, then restart the plugin. Runs the
|
|
9
|
+
* // `internal/update` waterfall first, so update hooks (and HMR) can veto or
|
|
10
|
+
* // replace the restart. `noSave` — hint for persistence hooks not to write
|
|
11
|
+
* // the change back.
|
|
12
|
+
*
|
|
13
|
+
* So a row can be "remounted" with a config this plugin computed, while the
|
|
14
|
+
* profile document stays ours to write (or untouched, for rows this plugin only
|
|
15
|
+
* adapts in memory). Two consequences are deliberately the caller's business:
|
|
16
|
+
*
|
|
17
|
+
* - the remount disposes the running plugin instance, so whatever runtime state
|
|
18
|
+
* that instance held (a verdict cache, breaker counters, open streams) is
|
|
19
|
+
* gone afterwards;
|
|
20
|
+
* - `noSave` is a *hint*, not a guarantee — a loader with a persistence hook may
|
|
21
|
+
* still write the merged config back.
|
|
22
|
+
*
|
|
23
|
+
* This module only owns the mechanics: pick the fiber, refuse to touch a row
|
|
24
|
+
* that is not settled, contain every failure, and report what happened. It never
|
|
25
|
+
* throws and never persists anything itself.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import type { Entry } from '@deepseek-ai/cordis-plugin-loader';
|
|
30
|
+
/** How one hot config application ended. */
|
|
31
|
+
export type HotUpdateOutcome =
|
|
32
|
+
/** The row was reloaded with the new config. */
|
|
33
|
+
'updated'
|
|
34
|
+
/** The row has no fiber (not mounted, or already torn down). */
|
|
35
|
+
| 'no-fiber'
|
|
36
|
+
/** The row is mid-transition; the change was skipped on purpose. */
|
|
37
|
+
| 'not-active'
|
|
38
|
+
/** The new config failed the plugin's own validation, or the reload threw. */
|
|
39
|
+
| 'failed';
|
|
40
|
+
/** Result of one hot config application. */
|
|
41
|
+
export interface HotUpdateResult {
|
|
42
|
+
/** What happened. */
|
|
43
|
+
readonly outcome: HotUpdateOutcome;
|
|
44
|
+
/** The failure text, when `outcome === 'failed'`. */
|
|
45
|
+
readonly error?: string | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Apply `config` to one live row by restarting its fiber with that config.
|
|
49
|
+
*
|
|
50
|
+
* The caller keeps responsibility for *when* this is safe (for example: only
|
|
51
|
+
* when the value actually changed, and only for rows whose restart cannot cut a
|
|
52
|
+
* call the user is waiting on). This function does not validate that policy.
|
|
53
|
+
*
|
|
54
|
+
* @param entry - the loader row to reload; `undefined` is reported, not thrown.
|
|
55
|
+
* @param config - the complete raw config the row should run with.
|
|
56
|
+
* @returns the outcome; never throws.
|
|
57
|
+
*/
|
|
58
|
+
export declare function applyFiberConfig(entry: Entry | undefined, config: unknown): Promise<HotUpdateResult>;
|
|
@@ -43,6 +43,33 @@ export interface PrimeMemoryCompatStatus {
|
|
|
43
43
|
}
|
|
44
44
|
/** The state the settings page reads. */
|
|
45
45
|
export declare const primeMemoryCompatStatus: PrimeMemoryCompatStatus;
|
|
46
|
+
/**
|
|
47
|
+
* Write the memory row's static route into the profile patch itself.
|
|
48
|
+
*
|
|
49
|
+
* `settings.update` only accepts the entry's *live* schema fields, so the static
|
|
50
|
+
* `llm` pin never survives that call. The pin is what `resolveModelRoute` returns
|
|
51
|
+
* first, and it is the only key every distillation layer honours — so it has to be
|
|
52
|
+
* written where the next start reads it: the row config in the profile document.
|
|
53
|
+
* @param documentPath - the profile patch file.
|
|
54
|
+
* @param provider - route provider to pin.
|
|
55
|
+
* @param model - route model to pin.
|
|
56
|
+
* @returns whether the document changed.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Remove this plugin's own static pin from the memory row.
|
|
60
|
+
*
|
|
61
|
+
* `effectiveCfg` (dsh-prime-memory `pipeline/runner.js`) treats a non-empty
|
|
62
|
+
* `cfg.llm.provider + cfg.llm.model` pair as "pinned" and then ignores *both* the runtime
|
|
63
|
+
* chain and the legacy `distillProvider`/`distillModel` pair. A pin written earlier — for a
|
|
64
|
+
* host whose live RPC was not ready yet — is therefore not harmless: it keeps winning over
|
|
65
|
+
* every later live push, which is exactly the "the card changed, the calls did not" report.
|
|
66
|
+
* Once a live push is confirmed, the pin has to go.
|
|
67
|
+
*
|
|
68
|
+
* @param documentPath - the profile patch document that holds the memory row.
|
|
69
|
+
* @returns what happened, so the caller can log it without guessing.
|
|
70
|
+
*/
|
|
71
|
+
export declare function clearStaticPin(documentPath: string): Promise<'cleared' | 'absent' | 'missing'>;
|
|
72
|
+
export declare function writeStaticPin(documentPath: string, provider: string, model: string): Promise<'written' | 'unchanged' | 'missing'>;
|
|
46
73
|
/**
|
|
47
74
|
* The distillation chain a settings section currently carries.
|
|
48
75
|
*
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
* - "Cancel the timeout" is legal only as the upstream ceiling
|
|
16
16
|
* (`MAX_TIMER_DELAY_MS` = 2147483647 ms ≈ 24.86 days); upstream rejects 0,
|
|
17
17
|
* negatives and Infinity, so the UI writes the ceiling and says so.
|
|
18
|
-
* - The profile document is
|
|
19
|
-
*
|
|
18
|
+
* - The profile document is the durable copy. After writing it, the running
|
|
19
|
+
* pi-ai row is reloaded through the loader fiber so the value applies without
|
|
20
|
+
* a Host restart; that reload drops the provider's in-flight calls. When the
|
|
21
|
+
* reload cannot run (no live row, a vetoed update, a failed validation) the
|
|
22
|
+
* value still lands at the next Host start, and the status line says so.
|
|
20
23
|
*
|
|
21
24
|
* Restoring is symmetric: the value a provider carried before the first
|
|
22
25
|
* overwrite is recorded in this plugin's own settings
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
* @module
|
|
28
31
|
*/
|
|
29
32
|
import type { Context } from '@deepseek-ai/cordis';
|
|
33
|
+
import type { Entry, Loader } from '@deepseek-ai/cordis-plugin-loader';
|
|
30
34
|
import type { ModelSwitchSettings } from './host-settings.js';
|
|
31
35
|
/** Cordis plugin identity; matches the `cordis.patch.yml` insert row id. */
|
|
32
36
|
export declare const name = "model-switch-review-timeout";
|
|
@@ -39,6 +43,12 @@ export declare const reviewTimeoutStatus: {
|
|
|
39
43
|
configuredMs: number | undefined;
|
|
40
44
|
applied: string[];
|
|
41
45
|
skipped: string[];
|
|
46
|
+
/** Providers whose running row was reloaded with the new timeout. */
|
|
47
|
+
hotApplied: string[];
|
|
48
|
+
/** Whether the running row took the value, or the next start has to. */
|
|
49
|
+
hot: "applied" | "restart-required" | undefined;
|
|
50
|
+
/** Why the running row did not take the value, when it did not. */
|
|
51
|
+
hotReason: string | undefined;
|
|
42
52
|
};
|
|
43
53
|
/** One resolved write decision. */
|
|
44
54
|
export interface ReviewTimeoutPlan {
|
|
@@ -91,6 +101,25 @@ export declare function patchProviderIdleTimeout(text: string, provider: string,
|
|
|
91
101
|
* @returns the value, or null when the key is absent.
|
|
92
102
|
*/
|
|
93
103
|
export declare function readProviderIdleTimeout(text: string, provider: string): number | null;
|
|
104
|
+
/**
|
|
105
|
+
* Build the pi-ai row config with one provider's idle timeout set or removed.
|
|
106
|
+
*
|
|
107
|
+
* Pure: the caller decides whether to hand the result to the loader, and a shape
|
|
108
|
+
* this function does not recognize returns `undefined` instead of a guess.
|
|
109
|
+
*
|
|
110
|
+
* @param config - the row's current config object.
|
|
111
|
+
* @param provider - the pi-ai provider id inside `providers`.
|
|
112
|
+
* @param timeoutMs - the value to set, or undefined to remove the key.
|
|
113
|
+
* @returns the next config, or undefined when the current one is not an object.
|
|
114
|
+
*/
|
|
115
|
+
export declare function planProviderConfig(config: unknown, provider: string, timeoutMs: number | undefined): Record<string, unknown> | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Find the loader row that owns the pi-ai provider profiles.
|
|
118
|
+
*
|
|
119
|
+
* @param loader - the Host loader service, when present.
|
|
120
|
+
* @returns the row entry, or undefined when the profile does not load it.
|
|
121
|
+
*/
|
|
122
|
+
export declare function findPiAiEntry(loader: Loader | undefined): Entry | undefined;
|
|
94
123
|
/**
|
|
95
124
|
* Row entry point: apply the configured timeout to the reviewer providers'
|
|
96
125
|
* pi-ai profiles in the profile document.
|