@toddzheng024/dscode-bundle 0.1.0 → 0.2.0
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/THIRD_PARTY_NOTICES.md +3 -0
- package/cordis.patch.yml +6 -0
- package/package.json +5 -1
- package/plugins/dscode/index.mjs +1 -1
- package/plugins/memory/content.mjs +57 -0
- package/plugins/memory/index.mjs +123 -0
- package/plugins/memory/pipeline.mjs +78 -0
- package/plugins/memory/store.mjs +93 -0
- package/plugins/session-bridge/client.mjs +106 -0
- package/plugins/session-bridge/communication.mjs +217 -0
- package/plugins/session-bridge/index.mjs +61 -0
- package/plugins/session-bridge/mailbox.mjs +212 -0
- package/plugins/session-bridge/paths.mjs +21 -0
- package/plugins/session-bridge/server.mjs +169 -0
- package/plugins/session-cards/content.mjs +64 -0
- package/plugins/session-cards/index.mjs +31 -0
- package/plugins/session-cards/manager.mjs +131 -0
- package/plugins/session-metrics/view.mjs +3 -3
- package/plugins/tui-tools/index.mjs +2 -0
- package/plugins/tui-tools/shell.mjs +27 -0
- package/plugins/ultra/policy.mjs +7 -3
- package/presets/dscode/agent.cordis.yml +7 -5
- package/vendor/deepseek/index.js +1 -1
- package/vendor/subagent/LICENSE +21 -0
- package/vendor/subagent/index.js +664 -0
- package/vendor/subagent/invariant.js +52 -0
- package/vendor/subagent/model-selection-settings.js +94 -0
- package/vendor/subagent/types/index.d.ts +81 -0
- package/vendor/subagent/types/invariant.d.ts +16 -0
- package/vendor/subagent/types/list-models.d.ts +10 -0
- package/vendor/subagent/types/model-selection-settings.d.ts +43 -0
- package/vendor/subagent/types/model-selection-state.d.ts +48 -0
- package/vendor/subagent/types/model-selection.d.ts +81 -0
- package/vendor/tui/index.mjs +158 -100
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import "@deepseek-ai/dsh-llm";
|
|
3
|
+
import z$1 from "@deepseek-ai/schemastery";
|
|
4
|
+
z$1.object({
|
|
5
|
+
provider: z$1.string().min(1).required(),
|
|
6
|
+
model: z$1.string().min(1).required()
|
|
7
|
+
});
|
|
8
|
+
z.array(z.object({
|
|
9
|
+
provider: z.string().min(1),
|
|
10
|
+
model: z.string().min(1)
|
|
11
|
+
}).strict()).min(1).nullable();
|
|
12
|
+
/**
|
|
13
|
+
* Read the exact route list captured for a model-selectable definition.
|
|
14
|
+
* @param projections - registry that owns the policy projection.
|
|
15
|
+
* @param session - session whose durable decision is read.
|
|
16
|
+
* @returns a detached route list, or undefined for the fixed-route definition.
|
|
17
|
+
*/
|
|
18
|
+
function subagentModelSelectionPolicy(projections, session) {
|
|
19
|
+
return projections.stateOf(session, "subagentModelSelectionPolicy")?.map((route) => ({ ...route }));
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region lib/types/invariant.js
|
|
23
|
+
/**
|
|
24
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-tool-subagent`.
|
|
25
|
+
* @module @deepseek-ai/dsh-tool-subagent/invariant
|
|
26
|
+
*/
|
|
27
|
+
const PACKAGE_NAME = "@deepseek-ai/dsh-tool-subagent";
|
|
28
|
+
/** Cordis companion plugin name. */
|
|
29
|
+
const name = "tool-subagent-invariant";
|
|
30
|
+
/** Service required before the companion can reserve package ownership. */
|
|
31
|
+
const inject = ["invariants"];
|
|
32
|
+
/** Assert that model-selectable definitions are complete and reconstructable. */
|
|
33
|
+
const install = Object.assign((ctx, fail) => {
|
|
34
|
+
ctx.on("agent/pre-step", async ({ agent }, next) => {
|
|
35
|
+
const schemas = ctx.tools.schemas(agent);
|
|
36
|
+
const selectable = schemas.some((schema) => {
|
|
37
|
+
const properties = schema.parameters.properties;
|
|
38
|
+
return properties?.["provider"] !== void 0 && properties["model"] !== void 0 && properties["reasoning_effort"] !== void 0;
|
|
39
|
+
});
|
|
40
|
+
const discoverable = schemas.some((schema) => schema.name === "list_subagent_models");
|
|
41
|
+
if ((selectable || discoverable) && (subagentModelSelectionPolicy(ctx.sessionProjections, agent.session) === void 0 || !selectable || !discoverable)) fail("model-selectable subagent definitions require a durable policy, route fields, and list_subagent_models");
|
|
42
|
+
return next();
|
|
43
|
+
}, { global: true });
|
|
44
|
+
}, { inject: ["tools", "sessionProjections"] });
|
|
45
|
+
/**
|
|
46
|
+
* Register this package's invariant companion.
|
|
47
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
48
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
49
|
+
*/
|
|
50
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
51
|
+
//#endregion
|
|
52
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import z from "@deepseek-ai/schemastery";
|
|
3
|
+
import "@deepseek-ai/dsh-llm";
|
|
4
|
+
//#region lib/types/model-selection.js
|
|
5
|
+
/** Schema shared by the Host setting and its deployment base. */
|
|
6
|
+
const AllowedModelRouteSchema = z.object({
|
|
7
|
+
provider: z.string().min(1).required(),
|
|
8
|
+
model: z.string().min(1).required()
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Stable identity for one provider/model pair.
|
|
12
|
+
* @param route - Exact provider/model route.
|
|
13
|
+
* @returns Opaque key for equality checks.
|
|
14
|
+
*/
|
|
15
|
+
function modelRouteKey(route) {
|
|
16
|
+
return `${route.provider}\0${route.model}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reject malformed or duplicate route policy entries at a durable or configuration boundary.
|
|
20
|
+
* @param routes - Candidate exact routes to validate.
|
|
21
|
+
* @returns an assertion that the candidate is a validated exact-route array.
|
|
22
|
+
*/
|
|
23
|
+
function assertAllowedModelRoutes(routes) {
|
|
24
|
+
if (!Array.isArray(routes)) throw new Error("subagent model selection requires an array of routes");
|
|
25
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26
|
+
const candidates = routes;
|
|
27
|
+
for (const candidate of candidates) {
|
|
28
|
+
if (typeof candidate !== "object" || candidate === null || Array.isArray(candidate) || !("provider" in candidate) || typeof candidate.provider !== "string" || !("model" in candidate) || typeof candidate.model !== "string" || candidate.provider.length === 0 || candidate.model.length === 0) throw new Error("subagent model selection requires non-empty provider and model ids");
|
|
29
|
+
const route = {
|
|
30
|
+
provider: candidate.provider,
|
|
31
|
+
model: candidate.model
|
|
32
|
+
};
|
|
33
|
+
const key = modelRouteKey(route);
|
|
34
|
+
if (seen.has(key)) throw new Error(`subagent model selection repeats route "${route.provider}/${route.model}"`);
|
|
35
|
+
seen.add(key);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region lib/types/model-selection-settings.js
|
|
40
|
+
/** Host-owned opt-in setting for model-selectable subagent delegation. */
|
|
41
|
+
/** User-settings section for model-selectable subagent delegation. */
|
|
42
|
+
const SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE = "subagent-model-selection";
|
|
43
|
+
/** Schema served to settings clients for the opt-in preference. */
|
|
44
|
+
const SUBAGENT_MODEL_SELECTION_SETTINGS_SCHEMA = z.object({
|
|
45
|
+
enabled: z.boolean().default(false),
|
|
46
|
+
allowedModels: z.array(AllowedModelRouteSchema).default([])
|
|
47
|
+
});
|
|
48
|
+
/** Singleton settings owner read when delegation tools are composed for a Session. */
|
|
49
|
+
var SubagentModelSelectionConfig = class extends Service {
|
|
50
|
+
static Config = z.object({
|
|
51
|
+
enabled: z.boolean().default(false),
|
|
52
|
+
allowedModels: z.array(AllowedModelRouteSchema).default([])
|
|
53
|
+
});
|
|
54
|
+
source;
|
|
55
|
+
constructor(ctx, config = {}) {
|
|
56
|
+
super(ctx, "subagentModelSelection");
|
|
57
|
+
/* v8 ignore next */
|
|
58
|
+
const entry = {
|
|
59
|
+
enabled: config.enabled ?? false,
|
|
60
|
+
allowedModels: config.allowedModels ?? []
|
|
61
|
+
};
|
|
62
|
+
this.validate(entry);
|
|
63
|
+
this.source = () => entry;
|
|
64
|
+
ctx.inject(["settings"], (settingsCtx) => {
|
|
65
|
+
settingsCtx.settings.installSection(ctx, SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, SUBAGENT_MODEL_SELECTION_SETTINGS_SCHEMA, entry, {
|
|
66
|
+
setSource: (source) => {
|
|
67
|
+
this.source = source;
|
|
68
|
+
},
|
|
69
|
+
validate: (value) => {
|
|
70
|
+
this.validate(value);
|
|
71
|
+
},
|
|
72
|
+
onChange: () => {}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Read a detached selection preference for the next eligible Session composition.
|
|
78
|
+
* @returns the enabled state and exact allowed routes.
|
|
79
|
+
*/
|
|
80
|
+
current() {
|
|
81
|
+
const current = this.source();
|
|
82
|
+
return {
|
|
83
|
+
enabled: current.enabled,
|
|
84
|
+
allowedModels: current.allowedModels.map((route) => ({ ...route }))
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
validate(value) {
|
|
88
|
+
assertAllowedModelRoutes(value.allowedModels);
|
|
89
|
+
if (value.enabled && value.allowedModels.length === 0) throw new Error("enabled subagent model selection requires at least one allowed model");
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const name = "subagent-model-selection-settings";
|
|
93
|
+
//#endregion
|
|
94
|
+
export { SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, SUBAGENT_MODEL_SELECTION_SETTINGS_SCHEMA, SubagentModelSelectionConfig, SubagentModelSelectionConfig as default, name };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing delegation through one configured `ctx.subagents` provider.
|
|
3
|
+
* Provider lifecycle controls tool registration and context-sensitive schema
|
|
4
|
+
* wording. Foreground calls always dispose the run after collection.
|
|
5
|
+
* Background policy is selected by this plugin's configuration: one-shot
|
|
6
|
+
* calls own a plain Task, while continuable calls use
|
|
7
|
+
* `ctx.subagents.startContinuable()`.
|
|
8
|
+
* @module @deepseek-ai/dsh-tool-subagent
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
import z from '@deepseek-ai/schemastery';
|
|
12
|
+
import type { AgentOptions } from '@deepseek-ai/dsh-agent';
|
|
13
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
14
|
+
export declare const name = "tool-subagent";
|
|
15
|
+
export declare const inject: string[];
|
|
16
|
+
/** Config: which registered provider this tool delegates to, plus child defaults. */
|
|
17
|
+
export interface Config {
|
|
18
|
+
/** The `ctx.subagents` provider name to start runs on (e.g. `spawn`, `acp`). */
|
|
19
|
+
provider: string;
|
|
20
|
+
/**
|
|
21
|
+
* Model-facing tool name (default `subagent`). Each loaded instance must use
|
|
22
|
+
* a distinct name.
|
|
23
|
+
*/
|
|
24
|
+
toolName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Sample the Host `subagent-model-selection` setting for each new top-level
|
|
27
|
+
* Session and inherit that decision in its child Sessions.
|
|
28
|
+
*/
|
|
29
|
+
modelSelectionSettings?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Expose `run_in_background` (default true). Disabled instances omit the
|
|
32
|
+
* parameter and reject forced background calls.
|
|
33
|
+
*/
|
|
34
|
+
enableRunInBackground?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Background execution policy (default `one-shot`). `one-shot` defaults calls
|
|
37
|
+
* to foreground; `continuable` defaults them to background, requires a provider
|
|
38
|
+
* with the `prepareContinuable` capability, and returns the durable child id.
|
|
39
|
+
* Follow-up adapters remain independently optional.
|
|
40
|
+
*/
|
|
41
|
+
backgroundMode?: 'one-shot' | 'continuable';
|
|
42
|
+
/**
|
|
43
|
+
* Agent options applied to every child; omitted fields use child-loop defaults.
|
|
44
|
+
*/
|
|
45
|
+
agentOptions?: AgentOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Per-child persona that shadows `deployment:persona-prefix`. Requires the
|
|
48
|
+
* provider's `persona` capability; omission preserves the deployment persona.
|
|
49
|
+
*/
|
|
50
|
+
persona?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Tool filter applied to every child. Filtered tools disappear from its
|
|
53
|
+
* prompt and reject execution. Requires the provider's `toolFilter`
|
|
54
|
+
* capability; unknown names fail startup.
|
|
55
|
+
*/
|
|
56
|
+
toolFilter?: {
|
|
57
|
+
/** Global tool names the child keeps; everything else is removed. */
|
|
58
|
+
allow?: string[];
|
|
59
|
+
/** Global tool names removed from the child. */
|
|
60
|
+
deny?: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Maximum child depth: a non-negative safe integer (default `3`; `0` forbids
|
|
64
|
+
* delegation entirely), or `'provider-managed'` to send no cap. A numeric cap
|
|
65
|
+
* requires the provider's `depthLimit` capability (mount fails loud
|
|
66
|
+
* otherwise). The provider checks the calling agent's current depth at every
|
|
67
|
+
* start; the tool remains model-visible so runtime policy owns rejection.
|
|
68
|
+
* `'provider-managed'` is for an out-of-process provider whose recursion
|
|
69
|
+
* budget belongs to the child runtime or its own deployment.
|
|
70
|
+
*/
|
|
71
|
+
maxDepth?: number | 'provider-managed';
|
|
72
|
+
}
|
|
73
|
+
export declare const Config: z<Config>;
|
|
74
|
+
/**
|
|
75
|
+
* Install one delegation-tool composition.
|
|
76
|
+
* @param ctx - Context that owns the registrations.
|
|
77
|
+
* @param config - delegation-tool configuration.
|
|
78
|
+
* @param session - unpublished Session supplied by a direct Agent setup; omit for a standing composition.
|
|
79
|
+
*/
|
|
80
|
+
export declare function apply(ctx: Context, config: Config, session?: Session): void;
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-tool-subagent`.
|
|
3
|
+
* @module @deepseek-ai/dsh-tool-subagent/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "tool-subagent-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Model-facing discovery of LLM routes available to child Agents. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { ModelSelectionPolicy } from './model-selection.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Register `list_subagent_models` for one owning delegation-tool instance.
|
|
6
|
+
* @param ctx - Context whose tool registry owns the fixed discovery definition.
|
|
7
|
+
* @param policy - Route policy captured for this Session.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerListSubagentModels(ctx: Context, policy: ModelSelectionPolicy): void;
|
|
10
|
+
//# sourceMappingURL=list-models.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Host-owned opt-in setting for model-selectable subagent delegation. */
|
|
2
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
3
|
+
import z from '@deepseek-ai/schemastery';
|
|
4
|
+
import { type AllowedModelRoute } from './model-selection.ts';
|
|
5
|
+
declare module '@deepseek-ai/cordis' {
|
|
6
|
+
interface Context {
|
|
7
|
+
/** User preference sampled when a new Session receives delegation tools. */
|
|
8
|
+
subagentModelSelection: SubagentModelSelectionConfig;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** User-settings section for model-selectable subagent delegation. */
|
|
12
|
+
export declare const SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE = "subagent-model-selection";
|
|
13
|
+
/** Stored user preference; the shipped composition defaults it off. */
|
|
14
|
+
export interface SubagentModelSelectionSettings {
|
|
15
|
+
/** Whether newly composed top-level Sessions receive model selection. */
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Exact child LLM routes offered to newly composed top-level Sessions. */
|
|
18
|
+
allowedModels: AllowedModelRoute[];
|
|
19
|
+
}
|
|
20
|
+
/** Schema served to settings clients for the opt-in preference. */
|
|
21
|
+
export declare const SUBAGENT_MODEL_SELECTION_SETTINGS_SCHEMA: z<SubagentModelSelectionSettings>;
|
|
22
|
+
/** Optional deployment base for the preference. */
|
|
23
|
+
export interface Config {
|
|
24
|
+
/** Initial enabled state inherited when the user document does not override it. */
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/** Initial route list inherited when the user document does not override it. */
|
|
27
|
+
allowedModels?: AllowedModelRoute[];
|
|
28
|
+
}
|
|
29
|
+
/** Singleton settings owner read when delegation tools are composed for a Session. */
|
|
30
|
+
export declare class SubagentModelSelectionConfig extends Service {
|
|
31
|
+
static Config: z<Config>;
|
|
32
|
+
private source;
|
|
33
|
+
constructor(ctx: Context, config?: Config);
|
|
34
|
+
/**
|
|
35
|
+
* Read a detached selection preference for the next eligible Session composition.
|
|
36
|
+
* @returns the enabled state and exact allowed routes.
|
|
37
|
+
*/
|
|
38
|
+
current(): SubagentModelSelectionSettings;
|
|
39
|
+
private validate;
|
|
40
|
+
}
|
|
41
|
+
export declare const name = "subagent-model-selection-settings";
|
|
42
|
+
export default SubagentModelSelectionConfig;
|
|
43
|
+
//# sourceMappingURL=model-selection-settings.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Durable per-session state for the user-controlled model-selection opt-in. */
|
|
2
|
+
import { z as zod } from 'zod';
|
|
3
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
4
|
+
import type SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection';
|
|
5
|
+
import { type AllowedModelRoute } from './model-selection.ts';
|
|
6
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
7
|
+
interface SessionEventMap {
|
|
8
|
+
/**
|
|
9
|
+
* Records that this session's delegation tool exposes child provider,
|
|
10
|
+
* model, and reasoning-effort selection. Appended before the first model
|
|
11
|
+
* request; absence means the fixed-route definition. Log-only: it carries
|
|
12
|
+
* no `surfaceOp` and never enters model history.
|
|
13
|
+
*/
|
|
14
|
+
'subagent/model-selection-policy': {
|
|
15
|
+
/** Exact routes this Session may select explicitly for a child. */
|
|
16
|
+
allowedModels: AllowedModelRoute[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
21
|
+
interface SessionProjectionStateMap {
|
|
22
|
+
/** Exact routes authorized for child LLM selection, or null when disabled. */
|
|
23
|
+
subagentModelSelectionPolicy: AllowedModelRoute[] | null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Host-only projection of the durable model-selection policy. */
|
|
27
|
+
export declare const subagentModelSelectionProjectionDefinition: {
|
|
28
|
+
key: "subagentModelSelectionPolicy";
|
|
29
|
+
stateVersion: number;
|
|
30
|
+
stateSchema: zod.ZodType<AllowedModelRoute[] | null, unknown, zod.core.$ZodTypeInternals<AllowedModelRoute[] | null, unknown>>;
|
|
31
|
+
init: () => null;
|
|
32
|
+
apply: (policy: NoInfer<AllowedModelRoute[] | null>, event: import("@deepseek-ai/dsh-session").SessionEvent) => AllowedModelRoute[] | null;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Read the exact route list captured for a model-selectable definition.
|
|
36
|
+
* @param projections - registry that owns the policy projection.
|
|
37
|
+
* @param session - session whose durable decision is read.
|
|
38
|
+
* @returns a detached route list, or undefined for the fixed-route definition.
|
|
39
|
+
*/
|
|
40
|
+
export declare function subagentModelSelectionPolicy(projections: Pick<SessionProjectionRegistry, 'stateOf'>, session: Session): AllowedModelRoute[] | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Append the route policy once, before its definition can reach a model request.
|
|
43
|
+
* @param projections - registry that owns the policy projection.
|
|
44
|
+
* @param session - session receiving the model-selectable definition.
|
|
45
|
+
* @param allowedModels - exact routes the definition may select explicitly.
|
|
46
|
+
*/
|
|
47
|
+
export declare function recordSubagentModelSelection(projections: Pick<SessionProjectionRegistry, 'stateOf'>, session: Session, allowedModels: readonly AllowedModelRoute[]): void;
|
|
48
|
+
//# sourceMappingURL=model-selection-state.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Child LLM route selection for the subagent tool. */
|
|
2
|
+
import type { LlmRuntime } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
import type { AgentOptions } from '@deepseek-ai/dsh-agent';
|
|
4
|
+
import z from '@deepseek-ai/schemastery';
|
|
5
|
+
/** One exact child LLM route authorized by a user setting. */
|
|
6
|
+
export interface AllowedModelRoute {
|
|
7
|
+
/** Registered LLM provider id. */
|
|
8
|
+
readonly provider: string;
|
|
9
|
+
/** Provider-owned exact model id. */
|
|
10
|
+
readonly model: string;
|
|
11
|
+
}
|
|
12
|
+
/** Schema shared by the Host setting and its deployment base. */
|
|
13
|
+
export declare const AllowedModelRouteSchema: z<AllowedModelRoute>;
|
|
14
|
+
/** Route-selection authority captured by one delegation definition. */
|
|
15
|
+
export interface ModelSelectionPolicy {
|
|
16
|
+
/** Exact provider/model routes authorized for explicit selection. */
|
|
17
|
+
readonly routes: readonly AllowedModelRoute[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stable identity for one provider/model pair.
|
|
21
|
+
* @param route - Exact provider/model route.
|
|
22
|
+
* @returns Opaque key for equality checks.
|
|
23
|
+
*/
|
|
24
|
+
export declare function modelRouteKey(route: AllowedModelRoute): string;
|
|
25
|
+
/**
|
|
26
|
+
* Reject malformed or duplicate route policy entries at a durable or configuration boundary.
|
|
27
|
+
* @param routes - Candidate exact routes to validate.
|
|
28
|
+
* @returns an assertion that the candidate is a validated exact-route array.
|
|
29
|
+
*/
|
|
30
|
+
export declare function assertAllowedModelRoutes(routes: unknown): asserts routes is readonly AllowedModelRoute[];
|
|
31
|
+
/** Model-facing child LLM route fields. */
|
|
32
|
+
export interface DelegationModelRequest {
|
|
33
|
+
readonly provider?: string;
|
|
34
|
+
readonly model?: string;
|
|
35
|
+
readonly reasoning_effort?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a call explicitly selects any child LLM value.
|
|
39
|
+
* @param request - Model-facing route fields from the tool call.
|
|
40
|
+
* @returns Whether at least one route or effort field is present.
|
|
41
|
+
*/
|
|
42
|
+
export declare function hasDelegationModelRequest(request: DelegationModelRequest): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Merge model-supplied selection fields over configured child defaults.
|
|
45
|
+
* Provider and model form one route and must be supplied together. Changing
|
|
46
|
+
* that route without an effort clears the configured route-owned effort.
|
|
47
|
+
* @param parentOptions - Current parent values that supply missing child values.
|
|
48
|
+
* @param configured - Tool-instance child defaults.
|
|
49
|
+
* @param request - Model-facing route override.
|
|
50
|
+
* @param enabled - Whether this tool instance permits model-facing selection.
|
|
51
|
+
* @returns Child Agent options, preserving omission when no layer contributes one.
|
|
52
|
+
*/
|
|
53
|
+
export declare function requestedAgentOptions(parentOptions: AgentOptions, configured: AgentOptions | undefined, request: DelegationModelRequest, enabled: boolean): AgentOptions | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Enforce a settings-owned route list at the operation that creates the child.
|
|
56
|
+
* Pure inheritance remains outside this policy because no model-facing choice
|
|
57
|
+
* occurred; any explicit route or effort field must resolve to an allowed route.
|
|
58
|
+
* @param policy - Selection authority captured for this Session.
|
|
59
|
+
* @param parentOptions - Current parent values that supply missing child values.
|
|
60
|
+
* @param requested - Effective child options after request/config merging.
|
|
61
|
+
* @param request - Model-facing selection fields from the tool call.
|
|
62
|
+
*/
|
|
63
|
+
export declare function assertAllowedModelSelection(policy: ModelSelectionPolicy | undefined, parentOptions: AgentOptions, requested: AgentOptions | undefined, request: DelegationModelRequest): void;
|
|
64
|
+
/**
|
|
65
|
+
* Whether configured Agent options require route validation before delegation.
|
|
66
|
+
* @param options - Tool-instance child defaults.
|
|
67
|
+
* @returns Whether configured provider, model, or effort values must be resolved.
|
|
68
|
+
*/
|
|
69
|
+
export declare function hasConfiguredLlmSelection(options: AgentOptions | undefined): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve an effective child route through its live adapter before the child is
|
|
72
|
+
* created. The LLM runtime owns provider lookup, exact-model metadata, effort
|
|
73
|
+
* validation, and adapter defaults.
|
|
74
|
+
* @param llm - Live LLM runtime.
|
|
75
|
+
* @param parentOptions - Current parent values whose compatible fields the child inherits.
|
|
76
|
+
* @param requested - Per-child options after request/config merging.
|
|
77
|
+
* @param signal - Tool-call cancellation signal.
|
|
78
|
+
* @param inheritParentReasoningEffort - Whether an omitted effort may inherit from the parent route.
|
|
79
|
+
*/
|
|
80
|
+
export declare function preflightChildLlmRoute(llm: LlmRuntime, parentOptions: AgentOptions, requested: AgentOptions | undefined, signal: AbortSignal, inheritParentReasoningEffort?: boolean): Promise<void>;
|
|
81
|
+
//# sourceMappingURL=model-selection.d.ts.map
|