@qlzt/dsh-tool-subagent 0.0.0-stage → 0.2.1-alpha.2
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/LICENSE +21 -0
- package/README.i18n.yaml +121 -0
- package/README.md +221 -2
- package/README.zh.md +222 -0
- package/lib/index.js +533 -0
- package/lib/model-selection-settings.js +68 -0
- package/lib/types/index.d.ts +68 -0
- package/lib/types/list-models.d.ts +10 -0
- package/lib/types/model-selection-settings.d.ts +45 -0
- package/lib/types/model-selection-state.d.ts +48 -0
- package/lib/types/model-selection.d.ts +81 -0
- package/package.json +63 -4
|
@@ -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,45 @@
|
|
|
1
|
+
/** Host-owned opt-in setting for model-selectable subagent delegation. */
|
|
2
|
+
import type { Volatile } from '@deepseek-ai/cordis';
|
|
3
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
4
|
+
import z from '@deepseek-ai/schemastery';
|
|
5
|
+
import { type AllowedModelRoute } from './model-selection.ts';
|
|
6
|
+
declare module '@deepseek-ai/cordis' {
|
|
7
|
+
interface Context {
|
|
8
|
+
/** User preference sampled when a new Session receives delegation tools. */
|
|
9
|
+
subagentModelSelection: SubagentModelSelectionConfig;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Stored user preference; the shipped composition defaults it off. */
|
|
13
|
+
export interface SubagentModelSelectionSettings {
|
|
14
|
+
/** Whether newly composed top-level Sessions receive model selection. */
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
/** Exact child LLM routes offered to newly composed top-level Sessions. */
|
|
17
|
+
allowedModels: AllowedModelRoute[];
|
|
18
|
+
}
|
|
19
|
+
/** Optional deployment base for the preference. */
|
|
20
|
+
export interface Config {
|
|
21
|
+
/** Initial enabled state inherited when the user document does not override it. */
|
|
22
|
+
enabled: Volatile<boolean>;
|
|
23
|
+
/** Initial route list inherited when the user document does not override it. */
|
|
24
|
+
allowedModels: Volatile<AllowedModelRoute[]>;
|
|
25
|
+
}
|
|
26
|
+
/** Singleton settings owner read when delegation tools are composed for a Session. */
|
|
27
|
+
export declare class SubagentModelSelectionConfig extends Service {
|
|
28
|
+
private config;
|
|
29
|
+
static Config: z<Schemastery.ObjectS<NoInfer<{
|
|
30
|
+
enabled: z<boolean, boolean, "volatile-defined">;
|
|
31
|
+
allowedModels: z<NoInfer<AllowedModelRoute[]>, NoInfer<AllowedModelRoute[]>, "volatile-defined">;
|
|
32
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
33
|
+
enabled: z<boolean, boolean, "volatile-defined">;
|
|
34
|
+
allowedModels: z<NoInfer<AllowedModelRoute[]>, NoInfer<AllowedModelRoute[]>, "volatile-defined">;
|
|
35
|
+
}>>, "plain">;
|
|
36
|
+
constructor(ctx: Context, config: Config);
|
|
37
|
+
/**
|
|
38
|
+
* Read a detached selection preference for the next eligible Session composition.
|
|
39
|
+
* @returns the enabled state and exact allowed routes.
|
|
40
|
+
*/
|
|
41
|
+
current(): SubagentModelSelectionSettings;
|
|
42
|
+
}
|
|
43
|
+
export declare const name = "subagent-model-selection-settings";
|
|
44
|
+
export default SubagentModelSelectionConfig;
|
|
45
|
+
//# 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 '@qlzt/dsh-session';
|
|
4
|
+
import type SessionProjectionRegistry from '@qlzt/dsh-session-projection';
|
|
5
|
+
import { type AllowedModelRoute } from './model-selection.ts';
|
|
6
|
+
declare module '@qlzt/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 '@qlzt/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("@qlzt/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 '@qlzt/dsh-llm';
|
|
3
|
+
import type { AgentOptions } from '@qlzt/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
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlzt/dsh-tool-subagent",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Model-facing subagent delegation tool over the ctx.subagents seam",
|
|
4
|
+
"version": "0.2.1-alpha.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://gitee.com/zsping1989/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/subagent/tool-subagent"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./model-selection-settings": {
|
|
22
|
+
"types": "./lib/types/model-selection-settings.d.ts",
|
|
23
|
+
"default": "./lib/model-selection-settings.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/model-selection-settings.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@qlzt/dsh-agent": "0.2.1-alpha.2",
|
|
36
|
+
"@qlzt/dsh-llm": "0.2.1-alpha.2",
|
|
37
|
+
"@qlzt/dsh-session": "0.2.1-alpha.2",
|
|
38
|
+
"@qlzt/dsh-session-projection": "0.2.1-alpha.2",
|
|
39
|
+
"@qlzt/dsh-scope": "0.2.1-alpha.2",
|
|
40
|
+
"@qlzt/dsh-subagent": "0.2.1-alpha.2",
|
|
41
|
+
"@qlzt/dsh-system-prompt": "0.2.1-alpha.2",
|
|
42
|
+
"@qlzt/dsh-tools": "0.2.1-alpha.2",
|
|
43
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.1",
|
|
47
|
+
"zod": "^4.4.3"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.1",
|
|
51
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
|
|
53
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-scope": "0.2.1-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-subagent": "0.2.1-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
|
|
61
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
62
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.2"
|
|
63
|
+
},
|
|
64
|
+
"dsh": {}
|
|
65
|
+
}
|