dsh-model-switch 0.4.21 → 0.4.23
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 +17 -0
- package/PRODUCT.md +4 -4
- package/README.md +17 -12
- package/README.zh.md +17 -12
- package/lib/client.js +820 -512
- package/lib/index.js +93 -23
- package/lib/types/client/ModelSwitchSettings.d.ts +4 -3
- package/lib/types/client/locales.d.ts +9 -5
- package/lib/types/client/main-row-controller.d.ts +16 -35
- package/lib/types/client/picker/ComposerPicker.d.ts +1 -3
- package/lib/types/client/picker/PlanReviewCard.d.ts +0 -6
- package/lib/types/client/picker/locales.d.ts +0 -8
- package/lib/types/client/picker/provider-group-watch.d.ts +48 -0
- package/lib/types/client-contract.d.ts +3 -9
- package/lib/types/host-runtime.d.ts +3 -41
- package/lib/types/host-settings.d.ts +11 -29
- package/lib/types/index.d.ts +1 -1
- package/lib/types/picker/plan-review.d.ts +2 -10
- package/lib/types/provider-group.d.ts +78 -0
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider configuration groups: per-provider presets for the compaction,
|
|
3
|
+
* subagent, and auto-review routes.
|
|
4
|
+
*
|
|
5
|
+
* A group stores the exact flat settings fields it will write, so applying a
|
|
6
|
+
* group is a plain settings-layer write: every capability consumer keeps
|
|
7
|
+
* reading the live values unchanged. All functions here are pure and never
|
|
8
|
+
* throw on malformed storage.
|
|
9
|
+
*/
|
|
10
|
+
import type { SubagentMode } from './host-settings.js';
|
|
11
|
+
/** Flat settings fields a provider group can pin — exactly what an application writes. */
|
|
12
|
+
export type ProviderGroupRouteField = 'compactProvider' | 'compactModel' | 'autoReviewProvider' | 'autoReviewModel' | 'subagentProvider' | 'subagentModel' | 'subagentReasoningEffort';
|
|
13
|
+
/** Stored entry: the owning provider plus every route field; '' means the capability stays at its default. */
|
|
14
|
+
export interface ProviderGroupEntry {
|
|
15
|
+
provider: string;
|
|
16
|
+
compactProvider: string;
|
|
17
|
+
compactModel: string;
|
|
18
|
+
autoReviewProvider: string;
|
|
19
|
+
autoReviewModel: string;
|
|
20
|
+
subagentProvider: string;
|
|
21
|
+
subagentModel: string;
|
|
22
|
+
subagentReasoningEffort: string;
|
|
23
|
+
}
|
|
24
|
+
/** Normalized view of one provider's group; absent fields follow their default state. */
|
|
25
|
+
export type ProviderGroupConfig = Partial<Record<ProviderGroupRouteField, string>>;
|
|
26
|
+
/** Normalized provider → group map. */
|
|
27
|
+
export type ProviderGroups = Readonly<Record<string, ProviderGroupConfig>>;
|
|
28
|
+
/** Storage shape of the volatile `providerGroups` config field: one entry per provider. */
|
|
29
|
+
export type ProviderGroupsStorage = readonly ProviderGroupEntry[];
|
|
30
|
+
/**
|
|
31
|
+
* Strip a raw stored value to well-formed groups; never throws. Both storage
|
|
32
|
+
* shapes are accepted: the stored entry array (keys live in each entry's
|
|
33
|
+
* `provider` field) and a hand-written provider → routes map (keys are the
|
|
34
|
+
* providers). All-empty entries stay: they pin a provider to every default.
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeProviderGroups(raw: unknown): ProviderGroups;
|
|
37
|
+
/**
|
|
38
|
+
* The saved group for a provider.
|
|
39
|
+
* @returns the normalized group, or undefined when the provider has no group —
|
|
40
|
+
* which is what leaves the live routes untouched during a switch.
|
|
41
|
+
*/
|
|
42
|
+
export declare function groupOf(groups: ProviderGroups | undefined, provider: string): ProviderGroupConfig | undefined;
|
|
43
|
+
/** One application write; `value` undefined means "unset this field". */
|
|
44
|
+
export type ProviderGroupWrite = {
|
|
45
|
+
readonly field: 'subagentMode';
|
|
46
|
+
readonly mode: SubagentMode;
|
|
47
|
+
} | {
|
|
48
|
+
readonly field: ProviderGroupRouteField;
|
|
49
|
+
readonly value: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Ordered writes applying one group with full-replacement semantics: pinned
|
|
53
|
+
* capabilities land as pairs, everything else reverts to its default state
|
|
54
|
+
* (compaction/review follow the session model; Subagent follows official
|
|
55
|
+
* inherit). The mode write comes last so a fixed route never publishes with
|
|
56
|
+
* the previous provider's fields still half-written.
|
|
57
|
+
*/
|
|
58
|
+
export declare function providerGroupWrites(group: ProviderGroupConfig): ProviderGroupWrite[];
|
|
59
|
+
/** Storage entry for one provider's group; absent or blank route fields become ''. */
|
|
60
|
+
export declare function entryOf(provider: string, group: ProviderGroupConfig): ProviderGroupEntry;
|
|
61
|
+
/**
|
|
62
|
+
* The stored entry list with one provider's group replaced (an entry) or
|
|
63
|
+
* removed (undefined). Every entry is re-normalized and de-duplicated so a
|
|
64
|
+
* save can never write junk back; the input is never mutated. A blank
|
|
65
|
+
* provider only normalizes.
|
|
66
|
+
*/
|
|
67
|
+
export declare function withProviderGroup(storage: unknown, provider: string, group: ProviderGroupConfig | undefined): ProviderGroupsStorage;
|
|
68
|
+
/** Minimal writable settings surface an application needs; satisfied by the owned ConfigForm. */
|
|
69
|
+
export interface ProviderGroupSink {
|
|
70
|
+
set(field: 'subagentMode' | ProviderGroupRouteField, value: string): Promise<unknown>;
|
|
71
|
+
unset(field: ProviderGroupRouteField): Promise<unknown>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Apply a saved group's routes to the live flat settings.
|
|
75
|
+
* @returns true when a group existed and every write settled; false when the
|
|
76
|
+
* provider has no group (nothing was written). A rejected write propagates.
|
|
77
|
+
*/
|
|
78
|
+
export declare function applyProviderGroupTo(sink: ProviderGroupSink, groups: ProviderGroups | undefined, provider: string): Promise<boolean>;
|