dsh-model-switch 0.4.62 → 0.4.64
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 -1
- package/cordis.patch.yml +3 -6
- package/lib/client.js +120 -43
- package/lib/session-title.js +77 -27
- package/lib/subagent-runtime.js +204 -201
- package/lib/types/client/picker/popup-placement.d.ts +53 -0
- package/lib/types/client/picker/useComposerPickerSurface.d.ts +2 -3
- package/lib/types/subagent-runtime-legacy.d.ts +34 -0
- package/lib/types/subagent-runtime.d.ts +40 -100
- package/lib/types/title-settings-reader.d.ts +34 -0
- package/package.json +4 -2
|
@@ -1,116 +1,56 @@
|
|
|
1
|
-
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import
|
|
1
|
+
import { type Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { SubagentStartRequest } from '@deepseek-ai/dsh-subagent';
|
|
3
3
|
import { type SubagentRoute } from './session-route.js';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
constructor(surfaceOrMessage: string, message?: string);
|
|
4
|
+
export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, mountWithStartupFallback, routedRuntimeUnavailableNotice, subagentRuntimeInject, subagentSurfaceOf, } from './subagent-runtime-legacy.js';
|
|
5
|
+
export type { MountedStartup, StartupCleanupTracker, StartupDisposer, SubagentSurfaceLine, } from './subagent-runtime-legacy.js';
|
|
6
|
+
type RoutableSubagentRequest = Pick<SubagentStartRequest, 'parent' | 'agentOptions'>;
|
|
7
|
+
interface SubagentProviderSurface {
|
|
8
|
+
readonly capabilities?: {
|
|
9
|
+
readonly agentOptions?: boolean;
|
|
10
|
+
};
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export interface MountedStartup<T> {
|
|
20
|
-
readonly value: T;
|
|
21
|
-
readonly dispose: () => Promise<void>;
|
|
12
|
+
interface SubagentRuntimeSurface {
|
|
13
|
+
getProvider?(name: string): SubagentProviderSurface | undefined;
|
|
14
|
+
readonly startActivation?: unknown;
|
|
15
|
+
readonly start?: unknown;
|
|
16
|
+
readonly startContinuable?: unknown;
|
|
22
17
|
}
|
|
23
|
-
type RoutableSubagentRequest = Pick<SubagentStartRequest, 'parent' | 'agentOptions'>;
|
|
24
18
|
/**
|
|
25
|
-
* The 0.2.1
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* the same `parent`/`agentOptions` pair the legacy start request does, which is
|
|
30
|
-
* why one route adapter serves both lines.
|
|
19
|
+
* The public activation shape used by tools and Agent Teams. 0.2.1 through
|
|
20
|
+
* 0.2.2-rc.1 nest the SubagentStartRequest under a request field; 0.2.2-rc.2+
|
|
21
|
+
* flatten those fields onto the spec itself, so the request field is absent
|
|
22
|
+
* there and the spec's own parent/agentOptions carry the same meaning.
|
|
31
23
|
*/
|
|
32
|
-
export interface SubagentActivationSpecLike {
|
|
24
|
+
export interface SubagentActivationSpecLike extends RoutableSubagentRequest {
|
|
25
|
+
readonly provider: string;
|
|
26
|
+
readonly request?: RoutableSubagentRequest & Record<string, unknown>;
|
|
27
|
+
readonly [field: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
/** Structural form of the pre-0.2.1 continuation start API. */
|
|
30
|
+
export interface ContinuableStartSpecLike {
|
|
33
31
|
readonly provider: string;
|
|
34
|
-
readonly request:
|
|
32
|
+
readonly request: RoutableSubagentRequest & Record<string, unknown>;
|
|
35
33
|
readonly [field: string]: unknown;
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
|
-
* Inject
|
|
39
|
-
*
|
|
40
|
-
* A spawn that already names a provider, model, or effort keeps it: the caller's
|
|
41
|
-
* explicit selection outranks any profile policy. The route itself is derived
|
|
42
|
-
* from the DELEGATING session (its provider selects a saved group, else the flat
|
|
43
|
-
* Subagent card in `fixed` mode), so two sessions on different providers route
|
|
44
|
-
* their own spawns and neither can rewrite the other's policy.
|
|
45
|
-
* @param request - the caller's spawn request.
|
|
46
|
-
* @param route - the delegating session's resolved route, or undefined for official inherit.
|
|
47
|
-
* @returns The request to hand the official runtime.
|
|
36
|
+
* Inject a parent-session route only when the caller named no provider, model,
|
|
37
|
+
* or reasoning effort. All other request and Agent options pass through.
|
|
48
38
|
*/
|
|
49
39
|
export declare function routeSubagentRequest<T extends RoutableSubagentRequest>(request: T, route: SubagentRoute | undefined): T;
|
|
50
|
-
/**
|
|
51
|
-
export
|
|
40
|
+
/** Resolve the current public route surface, never retaining a disposed service. */
|
|
41
|
+
export declare function routedSubagentRequest<T extends RoutableSubagentRequest>(ctx: Context, runtime: SubagentRuntimeSurface, providerName: string, request: T): T;
|
|
52
42
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* lines instead of hard-coding one.
|
|
58
|
-
*
|
|
59
|
-
* @param value - a runtime class's prototype or a mounted runtime instance.
|
|
60
|
-
* @returns `activation` (0.2.1+), `start` (0.1.7/0.2.0), or undefined when neither is published.
|
|
43
|
+
* Wrap the official service's start entries only. Its identity, prototype,
|
|
44
|
+
* registry, manager, Typert binding and prompt/interrupt methods are untouched.
|
|
45
|
+
* Disposers are idempotent and safe when overlapping adapter fibers unload in
|
|
46
|
+
* either order. Unsupported or sealed surfaces leave the official route usable.
|
|
61
47
|
*/
|
|
62
|
-
export declare function
|
|
48
|
+
export declare function installSubagentRouteWrappers(ctx: Context): () => void;
|
|
63
49
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* running after failures, and a startup error stays first in any aggregate.
|
|
69
|
-
*
|
|
70
|
-
* @param candidate - startup callback for the routed candidate.
|
|
71
|
-
* @param fallback - startup callback for the untouched official runtime.
|
|
72
|
-
* @returns the selected value and an idempotent disposer.
|
|
73
|
-
* @throws the candidate error unless it is a StartupIncompatibilityError.
|
|
74
|
-
* @throws the fallback startup error when fallback startup fails.
|
|
50
|
+
* Wait for the official service without replacing it or copying its dependency
|
|
51
|
+
* list. Model Switch is read optionally per call, so its absence cannot hold a
|
|
52
|
+
* startup fiber or retain a stale settings service. Cordis rebinds this effect
|
|
53
|
+
* when the official service is recreated.
|
|
75
54
|
*/
|
|
76
|
-
export declare function
|
|
77
|
-
/**
|
|
78
|
-
* Operator-facing notice for a Host whose Subagent runtime cannot be routed.
|
|
79
|
-
*
|
|
80
|
-
* DSH 0.2.1 replaced `start()`/`startContinuable()` with the activation API, so
|
|
81
|
-
* this adapter's override point is gone; the row then mounts the untouched
|
|
82
|
-
* official runtime instead of guessing a new seam.
|
|
83
|
-
* @param error - the typed startup incompatibility that rejected the candidate.
|
|
84
|
-
* @returns The notice logged once at startup.
|
|
85
|
-
*/
|
|
86
|
-
export declare function routedRuntimeUnavailableNotice(error: StartupIncompatibilityError): string;
|
|
87
|
-
/** Profile replacement that selects the routed runtime or the untouched official runtime. */
|
|
88
|
-
export declare const profileSubagentRuntime: (ctx: Context) => Promise<() => Promise<void>>;
|
|
89
|
-
/**
|
|
90
|
-
* The plugin dependency list for the mounted runtime.
|
|
91
|
-
*
|
|
92
|
-
* Static inheritance does not merge `inject`: cordis reads the static list off
|
|
93
|
-
* the class it mounts, so the subclass must repeat every service the official
|
|
94
|
-
* runtime's own code reads and add the route surface this adapter uses.
|
|
95
|
-
* @param officialInject - the installed runtime's declared dependencies (absent on 0.1.7/0.2.0).
|
|
96
|
-
* @returns The deduplicated list, official dependencies first.
|
|
97
|
-
*/
|
|
98
|
-
export declare function subagentRuntimeInject(officialInject: readonly string[] | undefined): string[];
|
|
99
|
-
/** Official runtime with only a pre-descriptor route-selection adapter. */
|
|
100
|
-
export declare class ModelSwitchSubagentRuntime extends OfficialSubagentRuntime {
|
|
101
|
-
static inject: string[];
|
|
102
|
-
private routed;
|
|
103
|
-
start(name: string, request: SubagentStartRequest): Promise<SubagentRun>;
|
|
104
|
-
startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
|
|
105
|
-
/**
|
|
106
|
-
* 0.2.1+ activation entry: delegation tools call this instead of
|
|
107
|
-
* `start()`/`startContinuable()`, and its spec carries the same
|
|
108
|
-
* `request.agentOptions` this adapter already rewrites. Every other spec
|
|
109
|
-
* field (label, childId, signal, delivery) passes through untouched.
|
|
110
|
-
*
|
|
111
|
-
* @param spec - the activation spec published by the installed Host.
|
|
112
|
-
* @returns The official activation result.
|
|
113
|
-
*/
|
|
114
|
-
startActivation(spec: SubagentActivationSpecLike): Promise<unknown>;
|
|
115
|
-
}
|
|
55
|
+
export declare function profileSubagentRuntime(ctx: Context): void;
|
|
116
56
|
export default profileSubagentRuntime;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe reads of the optional Model Switch settings service for the naming row.
|
|
3
|
+
*
|
|
4
|
+
* The session-naming row must keep the official naming behavior when the
|
|
5
|
+
* `model-switch` row is absent, so `modelSwitch` can never join the row's own
|
|
6
|
+
* `inject` list: Cordis waits for every declared dependency before a fiber
|
|
7
|
+
* loads (there is no "optional" inject), and a never-provided service would
|
|
8
|
+
* leave the row pending forever.
|
|
9
|
+
*
|
|
10
|
+
* Two reads are tried per call, in this order:
|
|
11
|
+
*
|
|
12
|
+
* 1. `ctx.get('modelSwitch')` with Cordis' default strict mode — the active
|
|
13
|
+
* implementation only, or undefined. This is the read the shipped row used
|
|
14
|
+
* and it keeps working across a settings-row rebuild because the store
|
|
15
|
+
* entry is replaced, not cached here.
|
|
16
|
+
* 2. A scoped `ctx.inject(['modelSwitch'])` child fiber, which binds a
|
|
17
|
+
* dependent scope and resets it on dispose. This covers compositions where
|
|
18
|
+
* the strict store read is invisible from the row's own entry context.
|
|
19
|
+
*
|
|
20
|
+
* The returned function identity is stable for the row's lifetime and every
|
|
21
|
+
* call re-reads, so a settings save or a service rebuild needs no remount.
|
|
22
|
+
* Reads never throw: a missing face, a disposed scope, or a throwing read all
|
|
23
|
+
* answer undefined, which means "official behavior" to the caller.
|
|
24
|
+
*
|
|
25
|
+
* @module dsh-model-switch/title-settings-reader
|
|
26
|
+
*/
|
|
27
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
28
|
+
import type { ModelSwitchSettings } from './host-settings.js';
|
|
29
|
+
/**
|
|
30
|
+
* Create the settings reader for one naming row context.
|
|
31
|
+
* @param ctx - this row's context (the row fiber's own scope).
|
|
32
|
+
* @returns The reader: per-request live settings, or undefined when unavailable.
|
|
33
|
+
*/
|
|
34
|
+
export declare function titleSettingsReaderOf(ctx: Context): () => ModelSwitchSettings | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model-switch",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.64",
|
|
4
4
|
"description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -122,7 +122,9 @@
|
|
|
122
122
|
"0.2.0-rc.2": "compatible",
|
|
123
123
|
"0.2.1-rc.2": "compatible",
|
|
124
124
|
"0.2.1-rc.3": "compatible",
|
|
125
|
-
"0.2.1-rc.5": "compatible"
|
|
125
|
+
"0.2.1-rc.5": "compatible",
|
|
126
|
+
"0.2.2-rc.1": "compatible",
|
|
127
|
+
"0.2.2-rc.2": "compatible"
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
},
|