@deepseek-ai/dsh-tool-subagent 0.2.1-rc.5 → 0.2.2-alpha.3

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.
@@ -1,5 +1,7 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import z from "@deepseek-ai/schemastery";
3
+ import { SessionSeq } from "@deepseek-ai/dsh-session";
4
+ import { z as z$1 } from "zod";
3
5
  import "@deepseek-ai/dsh-llm";
4
6
  //#region lib/types/model-selection.js
5
7
  /** Schema shared by the Host setting and its deployment base. */
@@ -35,11 +37,41 @@ function assertAllowedModelRoutes(routes) {
35
37
  seen.add(key);
36
38
  }
37
39
  }
40
+ /**
41
+ * Host-only projection of the durable model-selection policy.
42
+ * Each independently mounted consumer registers this shared definition; the registry reference-counts it.
43
+ */
44
+ const subagentModelSelectionProjectionDefinition = {
45
+ key: "subagentModelSelectionPolicy",
46
+ stateVersion: 1,
47
+ stateSchema: z$1.array(z$1.object({
48
+ provider: z$1.string().min(1),
49
+ model: z$1.string().min(1)
50
+ }).strict()).min(1).nullable(),
51
+ init: () => null,
52
+ apply: (policy, event) => {
53
+ if (policy !== null || event.type !== "subagent/model-selection-policy") return policy;
54
+ const { allowedModels } = event.data;
55
+ assertAllowedModelRoutes(allowedModels);
56
+ if (allowedModels.length === 0) throw new Error("subagent/model-selection-policy requires at least one route");
57
+ return allowedModels;
58
+ }
59
+ };
60
+ /**
61
+ * Read the exact route list authorized for a Session.
62
+ * @param subagentModelSelectionProjectionHandle - registered policy state reader.
63
+ * @param session - session whose durable decision is read.
64
+ * @returns a detached route list, or undefined to restrict selection to the parent route.
65
+ */
66
+ function subagentModelSelectionPolicy(subagentModelSelectionProjectionHandle, session) {
67
+ return subagentModelSelectionProjectionHandle.stateOf(session)?.map((route) => ({ ...route }));
68
+ }
38
69
  //#endregion
39
70
  //#region lib/types/model-selection-settings.js
40
- /** Singleton settings owner read when delegation tools are composed for a Session. */
71
+ /** Host settings owner that records Session authorization before the first model request. */
41
72
  var SubagentModelSelectionConfig = class extends Service {
42
73
  config;
74
+ static inject = ["sessionProjections", "sessions"];
43
75
  static Config = z.object({
44
76
  enabled: z.boolean().default(false).volatile(),
45
77
  allowedModels: z.array(AllowedModelRouteSchema).default([]).volatile()
@@ -48,8 +80,29 @@ var SubagentModelSelectionConfig = class extends Service {
48
80
  super(ctx, "subagentModelSelection");
49
81
  this.config = config;
50
82
  }
83
+ async [Service.init]() {
84
+ const ctx = this.ctx;
85
+ const policyReady = ctx.sessionProjections.register(subagentModelSelectionProjectionDefinition);
86
+ ctx.on("agent/created", async ({ agent }) => {
87
+ const policy = await policyReady;
88
+ ctx.fiber.assertActive();
89
+ const target = agent.session;
90
+ if (subagentModelSelectionPolicy(policy, target) !== void 0) return;
91
+ let allowedModels;
92
+ const parentId = target.header.origin === "subagent" ? target.header.parentSession : void 0;
93
+ if (parentId !== void 0) {
94
+ const parent = ctx.sessions.get(parentId);
95
+ if (parent !== void 0) allowedModels = subagentModelSelectionPolicy(policy, parent);
96
+ } else if (target.firstLiveSeq === 0 && target.eventAt(SessionSeq(0))?.type !== "session/end-seed") {
97
+ const current = this.current();
98
+ allowedModels = current.enabled ? current.allowedModels : void 0;
99
+ }
100
+ if (allowedModels !== void 0) target.append("subagent/model-selection-policy", { allowedModels });
101
+ });
102
+ await policyReady;
103
+ }
51
104
  /**
52
- * Read a detached selection preference for the next eligible Session composition.
105
+ * Read a detached selection preference for the next fresh top-level Session.
53
106
  * @returns the enabled state and exact allowed routes.
54
107
  */
55
108
  current() {
@@ -8,7 +8,6 @@
8
8
  import type { Context } from '@deepseek-ai/cordis';
9
9
  import z from '@deepseek-ai/schemastery';
10
10
  import type { AgentOptions } from '@deepseek-ai/dsh-agent';
11
- import type { Session } from '@deepseek-ai/dsh-session';
12
11
  import { type PresetSelectionConfig } from './preset-selection.ts';
13
12
  export declare const name = "tool-subagent";
14
13
  export declare const inject: string[];
@@ -22,10 +21,17 @@ export interface Config extends PresetSelectionConfig {
22
21
  */
23
22
  toolName?: string;
24
23
  /**
25
- * Sample the Host `subagent-model-selection` setting for each new top-level
26
- * Session and inherit that decision in its child Sessions.
24
+ * Expose optional child `provider`, `model`, and `reasoning_effort` fields.
25
+ * Requires provider `agentOptions` support. Execution enforces the Session
26
+ * policy, or restricts explicit selection to the current parent route.
27
27
  */
28
- modelSelectionSettings?: boolean;
28
+ modelSelection?: boolean;
29
+ /**
30
+ * Register the shared `list_subagent_models` tool for this scope.
31
+ * Enable on only one instance per scope; defaults to false and does not
32
+ * enable model selection. Discovery is removed when this instance unloads.
33
+ */
34
+ modelDiscovery?: boolean;
29
35
  /**
30
36
  * Agent options applied to every child; omitted fields use child-loop defaults.
31
37
  */
@@ -45,10 +51,10 @@ export interface Config extends PresetSelectionConfig {
45
51
  export declare const Config: z<Config>;
46
52
  /**
47
53
  * Install one delegation-tool composition.
48
- * Standing preset choices are validated for each Agent before its tool is installed.
54
+ * The owning composition shares its registrations across Agents; child startup resolves the selected preset.
49
55
  * @param ctx - Context that owns the registrations.
50
56
  * @param config - delegation-tool configuration.
51
- * @param session - unpublished Session supplied by a direct Agent setup; omit for a standing composition.
57
+ * @returns when the plugin is ready.
52
58
  */
53
- export declare function apply(ctx: Context, config: Config, session?: Session): Promise<void>;
59
+ export declare function apply(ctx: Context, config: Config): Promise<void>;
54
60
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,11 @@
1
1
  /** Model-facing discovery of LLM routes available to child Agents. */
2
2
  import type { Context } from '@deepseek-ai/cordis';
3
- import type { ModelSelectionPolicy } from './model-selection.ts';
3
+ import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection';
4
+ import type { AllowedModelRoute } from './model-selection.ts';
4
5
  /**
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.
6
+ * Register discovery of the calling Session’s authorized child models.
7
+ * @param ctx - Context carrying the tool registry and LLM service.
8
+ * @param policyHandle - retained reader for the Session’s authorized child routes.
8
9
  */
9
- export declare function registerListSubagentModels(ctx: Context, policy: ModelSelectionPolicy): void;
10
+ export declare function registerListSubagentModels(ctx: Context, policyHandle: ProjectionHandle<AllowedModelRoute[] | null>): void;
10
11
  //# sourceMappingURL=list-models.d.ts.map
@@ -5,15 +5,15 @@ import z from '@deepseek-ai/schemastery';
5
5
  import { type AllowedModelRoute } from './model-selection.ts';
6
6
  declare module '@deepseek-ai/cordis' {
7
7
  interface Context {
8
- /** User preference sampled when a new Session receives delegation tools. */
8
+ /** User preference sampled during Agent creation. */
9
9
  subagentModelSelection: SubagentModelSelectionConfig;
10
10
  }
11
11
  }
12
12
  /** Stored user preference; the shipped composition defaults it off. */
13
13
  export interface SubagentModelSelectionSettings {
14
- /** Whether newly composed top-level Sessions receive model selection. */
14
+ /** Whether new top-level Sessions receive model selection. */
15
15
  enabled: boolean;
16
- /** Exact child LLM routes offered to newly composed top-level Sessions. */
16
+ /** Exact child LLM routes offered to new top-level Sessions. */
17
17
  allowedModels: AllowedModelRoute[];
18
18
  }
19
19
  /** Optional deployment base for the preference. */
@@ -23,9 +23,10 @@ export interface Config {
23
23
  /** Initial route list inherited when the user document does not override it. */
24
24
  allowedModels: Volatile<AllowedModelRoute[]>;
25
25
  }
26
- /** Singleton settings owner read when delegation tools are composed for a Session. */
26
+ /** Host settings owner that records Session authorization before the first model request. */
27
27
  export declare class SubagentModelSelectionConfig extends Service {
28
28
  private config;
29
+ static inject: string[];
29
30
  static Config: z<Schemastery.ObjectS<NoInfer<{
30
31
  enabled: z<boolean, boolean, "volatile-defined">;
31
32
  allowedModels: z<NoInfer<AllowedModelRoute[]>, NoInfer<AllowedModelRoute[]>, "volatile-defined">;
@@ -34,11 +35,12 @@ export declare class SubagentModelSelectionConfig extends Service {
34
35
  allowedModels: z<NoInfer<AllowedModelRoute[]>, NoInfer<AllowedModelRoute[]>, "volatile-defined">;
35
36
  }>>, "plain">;
36
37
  constructor(ctx: Context, config: Config);
38
+ protected [Service.init](): Promise<void>;
37
39
  /**
38
- * Read a detached selection preference for the next eligible Session composition.
40
+ * Read a detached selection preference for the next fresh top-level Session.
39
41
  * @returns the enabled state and exact allowed routes.
40
42
  */
41
- current(): SubagentModelSelectionSettings;
43
+ private current;
42
44
  }
43
45
  export declare const name = "subagent-model-selection-settings";
44
46
  export default SubagentModelSelectionConfig;
@@ -1,14 +1,14 @@
1
1
  /** Durable per-session state for the user-controlled model-selection opt-in. */
2
2
  import { z as zod } from 'zod';
3
3
  import type { Session } from '@deepseek-ai/dsh-session';
4
- import type SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection';
4
+ import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection';
5
5
  import { type AllowedModelRoute } from './model-selection.ts';
6
6
  declare module '@deepseek-ai/dsh-session/types' {
7
7
  interface SessionEventMap {
8
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
9
+ * Records this Session’s authorized child provider/model routes. Appended
10
+ * before the first model request; absence restricts explicit selection
11
+ * to the current parent route. Log-only: it carries
12
12
  * no `surfaceOp` and never enters model history.
13
13
  */
14
14
  'subagent/model-selection-policy': {
@@ -17,13 +17,10 @@ declare module '@deepseek-ai/dsh-session/types' {
17
17
  };
18
18
  }
19
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. */
20
+ /**
21
+ * Host-only projection of the durable model-selection policy.
22
+ * Each independently mounted consumer registers this shared definition; the registry reference-counts it.
23
+ */
27
24
  export declare const subagentModelSelectionProjectionDefinition: {
28
25
  key: "subagentModelSelectionPolicy";
29
26
  stateVersion: number;
@@ -32,17 +29,10 @@ export declare const subagentModelSelectionProjectionDefinition: {
32
29
  apply: (policy: NoInfer<AllowedModelRoute[] | null>, event: import("@deepseek-ai/dsh-session").SessionEvent) => AllowedModelRoute[] | null;
33
30
  };
34
31
  /**
35
- * Read the exact route list captured for a model-selectable definition.
36
- * @param projections - registry that owns the policy projection.
32
+ * Read the exact route list authorized for a Session.
33
+ * @param subagentModelSelectionProjectionHandle - registered policy state reader.
37
34
  * @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.
35
+ * @returns a detached route list, or undefined to restrict selection to the parent route.
46
36
  */
47
- export declare function recordSubagentModelSelection(projections: Pick<SessionProjectionRegistry, 'stateOf'>, session: Session, allowedModels: readonly AllowedModelRoute[]): void;
37
+ export declare function subagentModelSelectionPolicy(subagentModelSelectionProjectionHandle: Pick<ProjectionHandle<AllowedModelRoute[] | null>, 'stateOf'>, session: Session): AllowedModelRoute[] | undefined;
48
38
  //# sourceMappingURL=model-selection-state.d.ts.map
@@ -11,7 +11,7 @@ export interface AllowedModelRoute {
11
11
  }
12
12
  /** Schema shared by the Host setting and its deployment base. */
13
13
  export declare const AllowedModelRouteSchema: z<AllowedModelRoute>;
14
- /** Route-selection authority captured by one delegation definition. */
14
+ /** Exact routes authorized for one Session. */
15
15
  export interface ModelSelectionPolicy {
16
16
  /** Exact provider/model routes authorized for explicit selection. */
17
17
  readonly routes: readonly AllowedModelRoute[];
@@ -55,7 +55,7 @@ export declare function requestedAgentOptions(parentOptions: AgentOptions, confi
55
55
  * Enforce a settings-owned route list at the operation that creates the child.
56
56
  * Pure inheritance remains outside this policy because no model-facing choice
57
57
  * occurred; any explicit route or effort field must resolve to an allowed route.
58
- * @param policy - Selection authority captured for this Session.
58
+ * @param policy - Session allowlist; omission permits only the current parent route.
59
59
  * @param parentOptions - Current parent values that supply missing child values.
60
60
  * @param requested - Effective child options after request/config merging.
61
61
  * @param request - Model-facing selection fields from the tool call.
@@ -1,5 +1,4 @@
1
1
  /** Deployment-owned preset choices for one delegation tool. */
2
- import type { Context } from '@deepseek-ai/cordis';
3
2
  import type { SubagentProvider } from '@deepseek-ai/dsh-subagent';
4
3
  /** Optional default and model-selectable preset ids for a spawn tool. */
5
4
  export interface PresetSelectionConfig {
@@ -12,22 +11,16 @@ export interface PresetSelectionConfig {
12
11
  export interface PresetSelectionRequest {
13
12
  readonly agent_preset?: unknown;
14
13
  }
15
- /** Validates configured references and resolves model input against the allowlist. */
14
+ /** Validates configured choices and resolves model input against the allowlist. */
16
15
  export declare class SubagentPresetSelection {
17
16
  private readonly config;
18
- private descriptions;
19
17
  constructor(config: PresetSelectionConfig);
20
18
  /** Whether this tool requires the preset service and an independently composing provider. */
21
19
  get configured(): boolean;
22
20
  /** Preset ids advertised in the model parameter. */
23
21
  get choices(): readonly string[] | undefined;
24
- /** Model-visible selection guidance and configured preset descriptions. */
22
+ /** Model-visible selection and default guidance. */
25
23
  get description(): string;
26
- /**
27
- * Read configured preset declarations before publishing the tool; mounting validates their activation.
28
- * @param ctx - Tool composition containing the preset service.
29
- */
30
- validate(ctx: Context): Promise<void>;
31
24
  /**
32
25
  * Reject independent selection for providers that inherit conversation history or lack support.
33
26
  * @param provider - Currently registered delegation provider.
package/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Subagenten-Delegierungstool",
4
+ "description": "Lassen Sie die KI Unteragenten Aufgaben zuweisen und die laufenden Ergebnisse erhalten."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Herramienta de delegación de subagente",
4
+ "description": "Deje que la IA asigne tareas a subagentes y obtenga los resultados en ejecución."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Outil de délégation de sous-agents",
4
+ "description": "Laissez l'IA attribuer des tâches aux sous-agents et obtenir les résultats en cours."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "サブエージェント委派ツール",
4
+ "description": "AI がタスクをサブエージェントに渡し、実行結果を取得できます。"
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "Modellauswahl für Unteragenten"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "Configuración de selección de modelos de subagentes"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "Paramètres de sélection des modèles des sous-agents"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "サブエージェントのモデル選択設定"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "Configurações de seleção de modelos dos subagentes"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "Настройки выбора модели для субагентов"
4
+ }
5
+ }
package/locale/pt.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Ferramenta de delegação de subagentes",
4
+ "description": "Deixe a IA atribuir tarefas aos subagentes e obter os resultados da execução."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Инструмент делегирования субагента",
4
+ "description": "Позвольте ИИ назначать задачи субагентам и получать текущие результаты."
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-subagent",
3
3
  "description": "Model-facing subagent delegation tool over the ctx.subagents seam",
4
- "version": "0.2.1-rc.5",
4
+ "version": "0.2.2-alpha.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -36,16 +36,15 @@
36
36
  ],
37
37
  "license": "MIT",
38
38
  "peerDependencies": {
39
- "@deepseek-ai/dsh-agent": "0.2.1-rc.5",
40
- "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.5",
41
- "@deepseek-ai/dsh-llm": "0.2.1-rc.5",
42
- "@deepseek-ai/dsh-session": "0.2.1-rc.5",
43
- "@deepseek-ai/dsh-session-projection": "0.2.1-rc.5",
44
- "@deepseek-ai/dsh-scope": "0.2.1-rc.5",
45
- "@deepseek-ai/dsh-subagent": "0.2.1-rc.5",
46
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.5",
47
- "@deepseek-ai/dsh-tools": "0.2.1-rc.5",
48
- "@deepseek-ai/cordis": "~4.0.5"
39
+ "@deepseek-ai/dsh-agent": "0.2.2-alpha.3",
40
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.2-alpha.3",
41
+ "@deepseek-ai/dsh-llm": "0.2.2-alpha.3",
42
+ "@deepseek-ai/dsh-session": "0.2.2-alpha.3",
43
+ "@deepseek-ai/dsh-session-projection": "0.2.2-alpha.3",
44
+ "@deepseek-ai/dsh-subagent": "0.2.2-alpha.3",
45
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-alpha.3",
46
+ "@deepseek-ai/dsh-tools": "0.2.2-alpha.3",
47
+ "@deepseek-ai/cordis": "~4.0.6-alpha.2"
49
48
  },
50
49
  "peerDependenciesMeta": {
51
50
  "@deepseek-ai/dsh-agent-preset-registry": {
@@ -53,23 +52,24 @@
53
52
  }
54
53
  },
55
54
  "dependencies": {
56
- "@deepseek-ai/schemastery": "~3.18.5",
55
+ "@deepseek-ai/schemastery": "~3.18.6-alpha.2",
57
56
  "zod": "4.4.3"
58
57
  },
59
58
  "devDependencies": {
60
- "@deepseek-ai/cordis-plugin-loader": "~1.0.6",
61
- "@deepseek-ai/dsh-agent": "0.2.1-rc.5",
62
- "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-rc.5",
63
- "@deepseek-ai/dsh-llm": "0.2.1-rc.5",
64
- "@deepseek-ai/dsh-session": "0.2.1-rc.5",
65
- "@deepseek-ai/dsh-scope": "0.2.1-rc.5",
66
- "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.5",
67
- "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.5",
68
- "@deepseek-ai/dsh-subagent": "0.2.1-rc.5",
69
- "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.1-rc.5",
70
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.5",
71
- "@deepseek-ai/dsh-tools": "0.2.1-rc.5",
72
- "@deepseek-ai/cordis": "~4.0.5",
73
- "@deepseek-ai/dsh-session-projection": "0.2.1-rc.5"
59
+ "@deepseek-ai/cordis-plugin-loader": "~1.0.7-alpha.2",
60
+ "@deepseek-ai/dsh-agent": "0.2.2-alpha.3",
61
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.2-alpha.3",
62
+ "@deepseek-ai/dsh-llm": "0.2.2-alpha.3",
63
+ "@deepseek-ai/dsh-session": "0.2.2-alpha.3",
64
+ "@deepseek-ai/dsh-session-persistence": "0.2.2-alpha.3",
65
+ "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.2-alpha.3",
66
+ "@deepseek-ai/dsh-subagent": "0.2.2-alpha.3",
67
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.2-alpha.3",
68
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-alpha.3",
69
+ "@deepseek-ai/dsh-tool-executor-native": "0.2.2-alpha.3",
70
+ "@deepseek-ai/dsh-tool-testkit": "0.2.2-alpha.3",
71
+ "@deepseek-ai/dsh-tools": "0.2.2-alpha.3",
72
+ "@deepseek-ai/cordis": "~4.0.6-alpha.2",
73
+ "@deepseek-ai/dsh-session-projection": "0.2.2-alpha.3"
74
74
  }
75
75
  }