dsh-model-switch 0.4.23 → 0.4.25
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 +25 -0
- package/PRODUCT.md +6 -3
- package/README.md +33 -12
- package/README.zh.md +33 -12
- package/cordis.patch.yml +15 -1
- package/docs/screenshots/settings-subagent.png +0 -0
- package/lib/auto-review.js +58 -7
- package/lib/client.js +438 -377
- package/lib/compaction.js +147 -19
- package/lib/index.js +10 -363
- package/lib/provider-group-CwadImhH.js +88 -0
- package/lib/session-route-BCQFzqRP.js +172 -0
- package/lib/session-title.js +217 -0
- package/lib/subagent-runtime.js +20 -17
- package/lib/types/adapter-registry.d.ts +1 -1
- package/lib/types/auto-review.d.ts +39 -4
- package/lib/types/client/ModelSwitchSettings.d.ts +8 -4
- package/lib/types/client/derived-config-form.d.ts +14 -0
- package/lib/types/client/locales.d.ts +8 -6
- package/lib/types/client-contract.d.ts +8 -1
- package/lib/types/compaction.d.ts +69 -4
- package/lib/types/host-settings.d.ts +6 -2
- package/lib/types/provider-group.d.ts +13 -35
- package/lib/types/session-route.d.ts +111 -0
- package/lib/types/session-title.d.ts +104 -0
- package/lib/types/subagent-runtime.d.ts +14 -3
- package/package.json +24 -1
- package/lib/types/client/derived-settings-scope.d.ts +0 -4
- package/lib/types/client/picker/main-default-restore.d.ts +0 -56
- package/lib/types/client/picker/provider-group-watch.d.ts +0 -48
- package/lib/types/client/remote-settings-scope.d.ts +0 -45
- package/lib/types/switch-compact.d.ts +0 -72
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apply a provider's saved capability group whenever the seat session's
|
|
3
|
-
* provider changes — on any switch surface.
|
|
4
|
-
*
|
|
5
|
-
* The official model-selection directory projects the Session's durable
|
|
6
|
-
* `model/selection` events into `store.current` (the sole emitter of those
|
|
7
|
-
* events is the `session.selectModel` RPC), so a switch performed through the
|
|
8
|
-
* TUI or any other client lands in the same store this plugin already reads.
|
|
9
|
-
* One watcher therefore covers every surface for sessions open in this Web
|
|
10
|
-
* UI, where the previous wiring only covered this plugin's own two call sites.
|
|
11
|
-
*
|
|
12
|
-
* Semantics stay exactly as before: a provider change applies the target
|
|
13
|
-
* provider's group when one exists; a provider without a group, a same-model
|
|
14
|
-
* change within one provider, and the subscription baseline itself write
|
|
15
|
-
* nothing. A failed apply is reported and never disturbs the switch.
|
|
16
|
-
*/
|
|
17
|
-
import type { ModelSelection } from '@deepseek-ai/dsh-api-session-controller/types';
|
|
18
|
-
/** The directory store slice the watcher observes. */
|
|
19
|
-
export interface DirectoryWatchSource {
|
|
20
|
-
subscribe: (listener: () => void) => () => void;
|
|
21
|
-
getSnapshot: () => {
|
|
22
|
-
current: ModelSelection | null;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export interface ProviderGroupWatchOptions {
|
|
26
|
-
source: DirectoryWatchSource;
|
|
27
|
-
/** Adopt the target provider's saved group; a group-less provider must write nothing. */
|
|
28
|
-
apply: (provider: string) => Promise<void>;
|
|
29
|
-
/** Reported apply failure; defaults to a console warning. */
|
|
30
|
-
onFailure?: (error: unknown) => void;
|
|
31
|
-
}
|
|
32
|
-
export interface ProviderGroupWatch {
|
|
33
|
-
/** Detach from the store; in-flight applies are left to finish. */
|
|
34
|
-
dispose: () => void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Watch one directory store and apply groups on provider changes.
|
|
38
|
-
*
|
|
39
|
-
* - The first observed provider (or the one already loaded) is the baseline
|
|
40
|
-
* and never triggers a write, so mounting and initial load stay silent.
|
|
41
|
-
* - Applies are serialized: a change arriving mid-apply coalesces to the
|
|
42
|
-
* latest target and runs once the current apply finishes, so two writes
|
|
43
|
-
* never interleave pair writes.
|
|
44
|
-
* - `current` being null (catalog still loading) is ignored, not a change.
|
|
45
|
-
* @param options - the store to watch and the apply to run.
|
|
46
|
-
* @returns the watch handle.
|
|
47
|
-
*/
|
|
48
|
-
export declare function createProviderGroupWatch(options: ProviderGroupWatchOptions): ProviderGroupWatch;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { SettingsPathOpView } from '@deepseek-ai/dsh-api-remotes/client';
|
|
2
|
-
import type { SettingsScope, SettingsScopeSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
3
|
-
interface RemoteError {
|
|
4
|
-
code: string;
|
|
5
|
-
message: string;
|
|
6
|
-
}
|
|
7
|
-
interface RemoteResult<T> {
|
|
8
|
-
ok: boolean;
|
|
9
|
-
value?: T;
|
|
10
|
-
error?: RemoteError;
|
|
11
|
-
}
|
|
12
|
-
interface NamespaceView {
|
|
13
|
-
ns: string;
|
|
14
|
-
value: unknown;
|
|
15
|
-
base?: unknown;
|
|
16
|
-
user?: unknown;
|
|
17
|
-
revision: number;
|
|
18
|
-
}
|
|
19
|
-
interface DescribeValue {
|
|
20
|
-
writable: boolean;
|
|
21
|
-
namespaces: readonly NamespaceView[];
|
|
22
|
-
}
|
|
23
|
-
export interface RemoteSettingsFace {
|
|
24
|
-
describe(): Promise<RemoteResult<DescribeValue>>;
|
|
25
|
-
mutate(ns: string, ops: readonly unknown[], expectedRevision: number | undefined): Promise<RemoteResult<NamespaceView>>;
|
|
26
|
-
}
|
|
27
|
-
/** Host-backed settings scope used by this plugin on authenticated remote browsers. */
|
|
28
|
-
export declare class RemoteSettingsScope<T> implements SettingsScope<T> {
|
|
29
|
-
private readonly api;
|
|
30
|
-
private readonly namespace;
|
|
31
|
-
private readonly decode;
|
|
32
|
-
private snapshot;
|
|
33
|
-
private readonly listeners;
|
|
34
|
-
constructor(api: RemoteSettingsFace, namespace: string, decode: (value: unknown) => T | undefined);
|
|
35
|
-
getSnapshot: () => SettingsScopeSnapshot<T>;
|
|
36
|
-
subscribe: (listener: () => void) => (() => void);
|
|
37
|
-
reload(): Promise<void>;
|
|
38
|
-
set(field: string, value: unknown): Promise<void>;
|
|
39
|
-
unset(field: string): Promise<void>;
|
|
40
|
-
mutate(ops: readonly SettingsPathOpView[], expectedRevision?: number): Promise<void>;
|
|
41
|
-
private write;
|
|
42
|
-
private accept;
|
|
43
|
-
private publish;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/** Send-time context check and optional old-model compaction before a switched request. */
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
-
import { type UserMessage } from '@deepseek-ai/dsh-llm';
|
|
4
|
-
declare module '@deepseek-ai/dsh-llm' {
|
|
5
|
-
interface MessageSourceMap {
|
|
6
|
-
'model-switch': {
|
|
7
|
-
kind: 'model-switch';
|
|
8
|
-
form: 'notice';
|
|
9
|
-
summary: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/** Provider and model selected for one model-routed request. */
|
|
14
|
-
export interface SwitchRoute {
|
|
15
|
-
readonly provider: string;
|
|
16
|
-
readonly model: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Compare two fully specified model routes.
|
|
20
|
-
* @param left - first route, if one was resolved.
|
|
21
|
-
* @param right - second route, if one was resolved.
|
|
22
|
-
* @returns Whether both routes identify the same provider and model.
|
|
23
|
-
*/
|
|
24
|
-
export declare function sameSwitchRoute(left: SwitchRoute | undefined, right: SwitchRoute | undefined): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Decide whether a changed, complete route needs send-time context protection.
|
|
27
|
-
* @param enabled - whether the user enabled send-time protection.
|
|
28
|
-
* @param previous - route used by the preceding request.
|
|
29
|
-
* @param selected - route assembled for the pending request.
|
|
30
|
-
* @returns Whether the pending request changes its provider or model.
|
|
31
|
-
*/
|
|
32
|
-
export declare function shouldProtectSwitch(enabled: boolean, previous: SwitchRoute | undefined, selected: SwitchRoute | undefined): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Input budget for the target window. Reserves output (maxTokens or 20%) plus a
|
|
35
|
-
* fixed estimator margin. `undefined` means the window cannot be used.
|
|
36
|
-
* @param contextWindow - adapter-owned combined request/response capacity.
|
|
37
|
-
* @param maxTokens - optional generation cap from the live agent options.
|
|
38
|
-
* @returns Tokens available to the request input, or undefined for an invalid window.
|
|
39
|
-
*/
|
|
40
|
-
export declare function switchInputBudget(contextWindow: number, maxTokens?: number): number | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Determine whether an estimated input exceeds its target route budget.
|
|
43
|
-
* @param tokens - estimated input tokens.
|
|
44
|
-
* @param budget - input budget for the target window.
|
|
45
|
-
* @returns Whether the budget is unusable or the estimate is too large.
|
|
46
|
-
*/
|
|
47
|
-
export declare function overSwitchBudget(tokens: number, budget: number): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Build one transcript-visible Model Switch progress notice.
|
|
50
|
-
* @param text - localized notice text shown in the transcript.
|
|
51
|
-
* @param summary - bounded event summary for durable session metadata.
|
|
52
|
-
* @returns A plugin-authored user message for the session log.
|
|
53
|
-
*/
|
|
54
|
-
export declare function switchNotice(text: string, summary: string): UserMessage;
|
|
55
|
-
/**
|
|
56
|
-
* Extract a complete route from partial request configuration.
|
|
57
|
-
* @param value - candidate provider and model values.
|
|
58
|
-
* @returns A complete route, or undefined when either identifier is absent.
|
|
59
|
-
*/
|
|
60
|
-
export declare function routeOf(value: {
|
|
61
|
-
provider?: string;
|
|
62
|
-
model?: string;
|
|
63
|
-
} | undefined): SwitchRoute | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* Install send-time switch protection on the host context.
|
|
66
|
-
* @param ctx - host context that owns agent-loop, llm, and tokenMeter.
|
|
67
|
-
* @param settings - live Model Switch settings; `compactOnSwitch !== false` is on.
|
|
68
|
-
* @param roleOf - provider-role lookup used to exclude native Agent runtimes.
|
|
69
|
-
*/
|
|
70
|
-
export declare function installSwitchCompaction(ctx: Context, settings: () => {
|
|
71
|
-
compactOnSwitch?: boolean;
|
|
72
|
-
}, roleOf?: (provider: string) => 'llm' | 'agent' | undefined): void;
|