@deepseek-ai/dsh-tool-subagent 0.1.3-alpha.2 → 0.1.5-alpha.1
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/README.i18n.yaml +2 -2
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/lib/index.js +24 -16
- package/lib/model-selection-settings.js +2 -2
- package/lib/types/index.d.ts +10 -3
- package/lib/types/model-selection-settings.d.ts +3 -3
- package/package.json +28 -28
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/subagent/tool-subagent/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 97bb9b143f003c830b68ffae9e25dee588a8fa67
|
|
6
|
+
README.zh.md: 1804f8f5da2dcd8fbdd043d247e6c234ea090529
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Use this package to give an agent a named tool that delegates work to a configured child-agent backend. In `one-shot` mode, calls wait for the child by default; in `continuable` mode, they start a persistent child in the background and return an id for later messages. Supported backends can also expose approved child LLM providers, models, and reasoning effort for selection. Each instance can set child persona, tool access, and depth limits, while failed runs return errors instead of partial success.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ Load the subagent service, an in-process or remote backend, and this tool; then
|
|
|
44
44
|
|---|---|---|
|
|
45
45
|
| `provider` | required | Provider name on `ctx.subagents` (e.g. `spawn`, `fork`, `acp`) |
|
|
46
46
|
| `toolName` | `subagent` | Model-facing tool name; distinct for every loaded instance |
|
|
47
|
-
| `modelSelectionSettings` | `false` | Sample the Host's exact-route authorization preference for each
|
|
47
|
+
| `modelSelectionSettings` | `false` | Sample the Host's exact-route authorization preference for each top-level Session; a standing preset observes matching Sessions, while direct Agent setup passes its Session explicitly; requires provider `agentOptions` support |
|
|
48
48
|
| `enableRunInBackground` | `true` | Expose `run_in_background`; disabling also rejects forced background calls |
|
|
49
49
|
| `backgroundMode` | `one-shot` | Background policy: `one-shot` defaults calls to foreground; `continuable` defaults them to background and requires the provider's `prepareContinuable` capability |
|
|
50
50
|
| `agentOptions` | — | Configured child `provider`, `model`, adapter-owned `reasoningEffort`, and positive `maxTokens` defaults; requires provider `agentOptions` support and overlays any provider-owned route defaults |
|
|
@@ -80,7 +80,7 @@ This section explains how the tool mirrors provider lifecycle and settles runs;
|
|
|
80
80
|
|
|
81
81
|
### Design concept
|
|
82
82
|
|
|
83
|
-
One instance is one provider plus one tool name. The plugin mirrors provider lifecycle: it registers the tool when the named provider appears and disposes it when the provider leaves, so sibling load order and HMR replacement cannot strand a dangling tool. A numeric `maxDepth` or configured LLM selection the provider cannot enforce fails the mount instead of the first delegation. At most one instance in a tool scope may own model selection because `list_subagent_models` has a global name.
|
|
83
|
+
One instance is one provider plus one tool name. The plugin mirrors provider lifecycle: it registers the tool when the named provider appears and disposes it when the provider leaves, so sibling load order and HMR replacement cannot strand a dangling tool. Direct Agent setup passes its unpublished Session explicitly and awaits installation before publication. A settings-backed standing preset receives each matching Agent from lifecycle events, selects policy from its Session, and installs through its Context. A numeric `maxDepth` or configured LLM selection the provider cannot enforce fails the mount instead of the first delegation. At most one instance in a tool scope may own model selection because `list_subagent_models` has a global name.
|
|
84
84
|
|
|
85
85
|
### Foreground settlement
|
|
86
86
|
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@ kind: "package-reference"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
使用本包可为 agent 提供一个具名工具,把工作委派给已配置的子 agent 后端。`one-shot` 模式下,调用默认等待子 agent;`continuable` 模式下,调用默认在后台启动持久化子 agent,并返回可用于后续消息的 id。受支持的后端还可公开获准的子级 LLM 提供方、模型与推理等级供模型选择。每个实例均可设置子 agent 的 persona、工具权限与深度限制,失败的运行会返回错误,而非部分成功。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ kind: "package-reference"
|
|
|
44
44
|
|---|---|---|
|
|
45
45
|
| `provider` | 必填 | `ctx.subagents` 上的提供方名称(如 `spawn`、`fork`、`acp`) |
|
|
46
46
|
| `toolName` | `subagent` | 面向模型的工具名称;每个已加载实例必须不同 |
|
|
47
|
-
| `modelSelectionSettings` | `false` |
|
|
47
|
+
| `modelSelectionSettings` | `false` | 为每个顶层 Session 读取宿主的精确路由授权偏好;常驻 preset 观察匹配 Session,直接 Agent setup 则显式传入其 Session;要求提供方支持 `agentOptions` |
|
|
48
48
|
| `enableRunInBackground` | `true` | 公开 `run_in_background`;禁用时也会拒绝强制后台调用 |
|
|
49
49
|
| `backgroundMode` | `one-shot` | 后台策略:`one-shot` 默认前台调用;`continuable` 默认后台调用,并要求提供方具备 `prepareContinuable` 能力 |
|
|
50
50
|
| `agentOptions` | — | 配置的子级 `provider`、`model`、适配器所有的 `reasoningEffort` 与正整数 `maxTokens` 默认值;要求提供方支持 `agentOptions`,并会覆盖提供方持有的路由默认值 |
|
|
@@ -80,7 +80,7 @@ kind: "package-reference"
|
|
|
80
80
|
|
|
81
81
|
### 设计理念
|
|
82
82
|
|
|
83
|
-
一个实例就是一个提供方加一个工具名称。插件镜像提供方生命周期:具名提供方出现时注册工具,提供方离开时释放工具,因此同级加载顺序与 HMR
|
|
83
|
+
一个实例就是一个提供方加一个工具名称。插件镜像提供方生命周期:具名提供方出现时注册工具,提供方离开时释放工具,因此同级加载顺序与 HMR 替换不会让工具悬空。直接 Agent setup 显式传入尚未发布的 Session,并在发布前等待安装完成。由设置控制的常驻 preset 从生命周期事件接收每个匹配 Agent,从其 Session 选择策略,并通过其 Context 安装。提供方无法执行的数值型 `maxDepth` 或已配置 LLM 选择会在挂载时失败,而不是在首次委派时失败。每个工具作用域内最多一个实例可以拥有模型选择,因为 `list_subagent_models` 使用全局名称。
|
|
84
84
|
|
|
85
85
|
### 前台结算
|
|
86
86
|
|
package/lib/index.js
CHANGED
|
@@ -359,7 +359,13 @@ function resolveDelegationRun(request, options) {
|
|
|
359
359
|
}
|
|
360
360
|
return { runInBackground: request.run_in_background ?? options.continuable };
|
|
361
361
|
}
|
|
362
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Install one delegation-tool composition.
|
|
364
|
+
* @param ctx - Context that owns the registrations.
|
|
365
|
+
* @param config - delegation-tool configuration.
|
|
366
|
+
* @param session - unpublished Session supplied by a direct Agent setup; omit for a standing composition.
|
|
367
|
+
*/
|
|
368
|
+
function apply(ctx, config, session) {
|
|
363
369
|
if (config.maxDepth !== "provider-managed") assertSubagentMaxDepth(config.maxDepth);
|
|
364
370
|
if (config.toolFilter !== void 0 && config.toolFilter.allow === void 0 && config.toolFilter.deny === void 0) throw new Error("tool-subagent: `toolFilter` is configured but names neither `allow` nor `deny` — remove the key or fill the filter");
|
|
365
371
|
const backgroundEnabled = config.enableRunInBackground !== false;
|
|
@@ -579,32 +585,33 @@ function apply(ctx, config) {
|
|
|
579
585
|
}
|
|
580
586
|
const settings = ctx.get("subagentModelSelection");
|
|
581
587
|
if (settings === void 0) throw new Error("tool-subagent: `modelSelectionSettings` requires @deepseek-ai/dsh-tool-subagent/model-selection-settings in the Host scope");
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const freshSession = agent.session.firstLiveSeq === 0 && agent.session.eventAt(SessionSeq(0))?.type !== "session/end-seed";
|
|
586
|
-
let allowedModels = subagentModelSelectionPolicy(ctx.sessionProjections, agent.session);
|
|
588
|
+
const selectForSession = (target) => {
|
|
589
|
+
const freshSession = target.firstLiveSeq === 0 && target.eventAt(SessionSeq(0))?.type !== "session/end-seed";
|
|
590
|
+
let allowedModels = subagentModelSelectionPolicy(ctx.sessionProjections, target);
|
|
587
591
|
if (allowedModels === void 0) {
|
|
588
|
-
const parentId =
|
|
592
|
+
const parentId = target.header.origin === "subagent" ? target.header.parentSession : void 0;
|
|
589
593
|
if (parentId !== void 0) {
|
|
590
|
-
const
|
|
591
|
-
|
|
594
|
+
const sessions = ctx.get("sessions");
|
|
595
|
+
if (sessions === void 0) throw new Error("tool-subagent: child model-selection inheritance requires the Session registry");
|
|
596
|
+
const parent = sessions.get(parentId);
|
|
597
|
+
allowedModels = parent === void 0 ? void 0 : subagentModelSelectionPolicy(ctx.sessionProjections, parent);
|
|
592
598
|
} else if (freshSession) {
|
|
593
599
|
const current = settings.current();
|
|
594
600
|
allowedModels = current.enabled ? current.allowedModels : void 0;
|
|
595
601
|
}
|
|
596
602
|
}
|
|
597
|
-
if (allowedModels !== void 0) recordSubagentModelSelection(ctx.sessionProjections,
|
|
603
|
+
if (allowedModels !== void 0) recordSubagentModelSelection(ctx.sessionProjections, target, allowedModels);
|
|
598
604
|
return allowedModels === void 0 ? void 0 : { routes: allowedModels };
|
|
599
605
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
install(ctx, selectForAgent(agent));
|
|
606
|
+
if (session !== void 0) {
|
|
607
|
+
install(ctx, selectForSession(session));
|
|
603
608
|
return;
|
|
604
609
|
}
|
|
610
|
+
const compositionScope = scopeOf(ctx);
|
|
611
|
+
if (compositionScope === void 0) throw new Error("tool-subagent: standing `modelSelectionSettings` requires a scoped preset Context");
|
|
605
612
|
const agents = ctx.get("agents");
|
|
606
|
-
/* v8 ignore next --
|
|
607
|
-
if (agents === void 0) throw new Error("tool-subagent:
|
|
613
|
+
/* v8 ignore next -- shipped preset compositions always include the Agent registry. */
|
|
614
|
+
if (agents === void 0) throw new Error("tool-subagent: standing `modelSelectionSettings` requires the Agent registry");
|
|
608
615
|
const scopedInstalls = /* @__PURE__ */ new WeakMap();
|
|
609
616
|
const installing = /* @__PURE__ */ new WeakSet();
|
|
610
617
|
const belongsToComposition = (candidate) => scopeChainOf(scopeOf(candidate.ctx)).includes(compositionScope);
|
|
@@ -613,7 +620,7 @@ function apply(ctx, config) {
|
|
|
613
620
|
installing.add(candidate);
|
|
614
621
|
let fiber;
|
|
615
622
|
try {
|
|
616
|
-
const policy =
|
|
623
|
+
const policy = selectForSession(candidate.session);
|
|
617
624
|
fiber = candidate.ctx.inject([
|
|
618
625
|
"tools",
|
|
619
626
|
"subagents",
|
|
@@ -646,6 +653,7 @@ function apply(ctx, config) {
|
|
|
646
653
|
removeScoped(disposed);
|
|
647
654
|
});
|
|
648
655
|
ctx.on("tools/change", reconcileComposedAgents);
|
|
656
|
+
reconcileComposedAgents();
|
|
649
657
|
}
|
|
650
658
|
//#endregion
|
|
651
659
|
export { Config, apply, inject, name };
|
|
@@ -45,7 +45,7 @@ const SUBAGENT_MODEL_SELECTION_SETTINGS_SCHEMA = z.object({
|
|
|
45
45
|
enabled: z.boolean().default(false),
|
|
46
46
|
allowedModels: z.array(AllowedModelRouteSchema).default([])
|
|
47
47
|
});
|
|
48
|
-
/** Singleton settings owner read
|
|
48
|
+
/** Singleton settings owner read when delegation tools are composed for a Session. */
|
|
49
49
|
var SubagentModelSelectionConfig = class extends Service {
|
|
50
50
|
static Config = z.object({
|
|
51
51
|
enabled: z.boolean().default(false),
|
|
@@ -74,7 +74,7 @@ var SubagentModelSelectionConfig = class extends Service {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Read a detached selection preference for the next eligible
|
|
77
|
+
* Read a detached selection preference for the next eligible Session composition.
|
|
78
78
|
* @returns the enabled state and exact allowed routes.
|
|
79
79
|
*/
|
|
80
80
|
current() {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import type { Context } from '@deepseek-ai/cordis';
|
|
11
11
|
import z from '@deepseek-ai/schemastery';
|
|
12
12
|
import type { AgentOptions } from '@deepseek-ai/dsh-agent';
|
|
13
|
+
import type { Session } from '@deepseek-ai/dsh-session';
|
|
13
14
|
export declare const name = "tool-subagent";
|
|
14
15
|
export declare const inject: string[];
|
|
15
16
|
/** Config: which registered provider this tool delegates to, plus child defaults. */
|
|
@@ -22,8 +23,8 @@ export interface Config {
|
|
|
22
23
|
*/
|
|
23
24
|
toolName?: string;
|
|
24
25
|
/**
|
|
25
|
-
* Sample the Host `subagent-model-selection`
|
|
26
|
-
*
|
|
26
|
+
* Sample the Host `subagent-model-selection` setting for each new top-level
|
|
27
|
+
* Session and inherit that decision in its child Sessions.
|
|
27
28
|
*/
|
|
28
29
|
modelSelectionSettings?: boolean;
|
|
29
30
|
/**
|
|
@@ -70,5 +71,11 @@ export interface Config {
|
|
|
70
71
|
maxDepth?: number | 'provider-managed';
|
|
71
72
|
}
|
|
72
73
|
export declare const Config: z<Config>;
|
|
73
|
-
|
|
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;
|
|
74
81
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,7 +4,7 @@ import z from '@deepseek-ai/schemastery';
|
|
|
4
4
|
import { type AllowedModelRoute } from './model-selection.ts';
|
|
5
5
|
declare module '@deepseek-ai/cordis' {
|
|
6
6
|
interface Context {
|
|
7
|
-
/** User preference sampled when a new
|
|
7
|
+
/** User preference sampled when a new Session receives delegation tools. */
|
|
8
8
|
subagentModelSelection: SubagentModelSelectionConfig;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -26,13 +26,13 @@ export interface Config {
|
|
|
26
26
|
/** Initial route list inherited when the user document does not override it. */
|
|
27
27
|
allowedModels?: AllowedModelRoute[];
|
|
28
28
|
}
|
|
29
|
-
/** Singleton settings owner read
|
|
29
|
+
/** Singleton settings owner read when delegation tools are composed for a Session. */
|
|
30
30
|
export declare class SubagentModelSelectionConfig extends Service {
|
|
31
31
|
static Config: z<Config>;
|
|
32
32
|
private source;
|
|
33
33
|
constructor(ctx: Context, config?: Config);
|
|
34
34
|
/**
|
|
35
|
-
* Read a detached selection preference for the next eligible
|
|
35
|
+
* Read a detached selection preference for the next eligible Session composition.
|
|
36
36
|
* @returns the enabled state and exact allowed routes.
|
|
37
37
|
*/
|
|
38
38
|
current(): SubagentModelSelectionSettings;
|
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.1.
|
|
4
|
+
"version": "0.1.5-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
],
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-
|
|
41
|
-
"@deepseek-ai/dsh-
|
|
42
|
-
"@deepseek-ai/dsh-
|
|
43
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
44
|
-
"@deepseek-ai/dsh-
|
|
45
|
-
"@deepseek-ai/dsh-
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-
|
|
48
|
-
"@deepseek-ai/dsh-system-prompt": "^0.1.
|
|
49
|
-
"@deepseek-ai/dsh-jobs": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-alpha.1",
|
|
41
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-alpha.1",
|
|
42
|
+
"@deepseek-ai/dsh-session": "^0.1.5-alpha.1",
|
|
43
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.5-alpha.1",
|
|
44
|
+
"@deepseek-ai/dsh-subagent": "^0.1.5-alpha.1",
|
|
45
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-alpha.1",
|
|
46
|
+
"@deepseek-ai/dsh-scope": "^0.1.5-alpha.1",
|
|
47
|
+
"@deepseek-ai/dsh-tools": "^0.1.5-alpha.1",
|
|
48
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.5-alpha.1",
|
|
49
|
+
"@deepseek-ai/dsh-jobs": "^0.1.5-alpha.1",
|
|
50
|
+
"@deepseek-ai/dsh-agent": "^0.1.5-alpha.1",
|
|
51
51
|
"@deepseek-ai/cordis": "^4.0.2"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
@@ -56,22 +56,22 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.3",
|
|
59
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
60
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
61
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
62
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-
|
|
65
|
-
"@deepseek-ai/dsh-settings": "^0.1.
|
|
66
|
-
"@deepseek-ai/dsh-
|
|
67
|
-
"@deepseek-ai/dsh-scope": "^0.1.
|
|
68
|
-
"@deepseek-ai/dsh-
|
|
69
|
-
"@deepseek-ai/dsh-
|
|
70
|
-
"@deepseek-ai/dsh-jobs": "^0.1.
|
|
71
|
-
"@deepseek-ai/dsh-
|
|
72
|
-
"@deepseek-ai/dsh-tools": "^0.1.3-alpha.2",
|
|
73
|
-
"@deepseek-ai/dsh-jobs-local": "^0.1.3-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-agent": "^0.1.5-alpha.1",
|
|
60
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-alpha.1",
|
|
61
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-alpha.1",
|
|
62
|
+
"@deepseek-ai/dsh-session": "^0.1.5-alpha.1",
|
|
63
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "^0.1.5-alpha.1",
|
|
64
|
+
"@deepseek-ai/dsh-subagent": "^0.1.5-alpha.1",
|
|
65
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-alpha.1",
|
|
66
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.5-alpha.1",
|
|
67
|
+
"@deepseek-ai/dsh-scope": "^0.1.5-alpha.1",
|
|
68
|
+
"@deepseek-ai/dsh-jobs": "^0.1.5-alpha.1",
|
|
69
|
+
"@deepseek-ai/dsh-tool-jobs": "^0.1.5-alpha.1",
|
|
70
|
+
"@deepseek-ai/dsh-jobs-local": "^0.1.5-alpha.1",
|
|
71
|
+
"@deepseek-ai/dsh-tools": "^0.1.5-alpha.1",
|
|
74
72
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
75
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.
|
|
73
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.5-alpha.1",
|
|
74
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.5-alpha.1",
|
|
75
|
+
"@deepseek-ai/dsh-session-persistence": "^0.1.5-alpha.1"
|
|
76
76
|
}
|
|
77
77
|
}
|