@deepseek-ai/dsh-tool-subagent-control 0.2.1-rc.3 → 0.2.2-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/README.i18n.yaml +14 -14
- package/README.md +8 -9
- package/README.zh.md +8 -9
- package/lib/index.js +140 -6
- package/lib/types/index.d.ts +4 -5
- package/lib/types/list-agents.d.ts +3 -7
- package/locale/de.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/package.json +26 -31
- package/lib/types/index.js +0 -98
- package/lib/types/list-agents.js +0 -136
- package/locale/list-agents/en.json +0 -5
- package/locale/list-agents/zh.json +0 -5
package/README.i18n.yaml
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
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-control/README.md
|
|
5
5
|
/:
|
|
6
|
-
en:
|
|
7
|
-
zh:
|
|
6
|
+
en: 2ed769ff79f88a4b
|
|
7
|
+
zh: 73fcdc6c2ec4334c
|
|
8
8
|
/deepseek-ai-dsh-tool-subagent-control:
|
|
9
9
|
en: 465d36925c792167
|
|
10
10
|
zh: 269cac314f638827
|
|
11
11
|
/deepseek-ai-dsh-tool-subagent-control/summary:
|
|
12
|
-
en:
|
|
13
|
-
zh:
|
|
12
|
+
en: 49b8e317dae5d896
|
|
13
|
+
zh: dabe302587aacde2
|
|
14
14
|
/deepseek-ai-dsh-tool-subagent-control/table-of-contents:
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
17
17
|
/deepseek-ai-dsh-tool-subagent-control/use-this-package:
|
|
18
|
-
en:
|
|
19
|
-
zh:
|
|
18
|
+
en: 8b2e49621394d15d
|
|
19
|
+
zh: eb235870eac36532
|
|
20
20
|
/deepseek-ai-dsh-tool-subagent-control/use-this-package/minimal-configuration:
|
|
21
|
-
en:
|
|
22
|
-
zh:
|
|
21
|
+
en: 4b4bf179ea0f1ecb
|
|
22
|
+
zh: f5cee3cb40710ace
|
|
23
23
|
/deepseek-ai-dsh-tool-subagent-control/use-this-package/send-message:
|
|
24
24
|
en: d80bb1df2eb740b7
|
|
25
25
|
zh: e3203d9868a82910
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
en: 70e344022e6e535e
|
|
43
43
|
zh: 355488590648a82e
|
|
44
44
|
/deepseek-ai-dsh-tool-subagent-control/understand-the-implementation/source-map:
|
|
45
|
-
en:
|
|
46
|
-
zh:
|
|
45
|
+
en: fd6385e36c6b457b
|
|
46
|
+
zh: 8fe9a57b7e75dd82
|
|
47
47
|
/deepseek-ai-dsh-tool-subagent-control/further-exploration:
|
|
48
|
-
en:
|
|
49
|
-
zh:
|
|
48
|
+
en: 3d7732f704f4c6eb
|
|
49
|
+
zh: 824876825a8b9a71
|
|
50
50
|
/deepseek-ai-dsh-tool-subagent-control/model-experience:
|
|
51
51
|
en: 215e7ba838619b7b
|
|
52
52
|
zh: a311da3843709f90
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
en: e4c7376d4f29dbd5
|
|
55
55
|
zh: 6b7a9eaf69c9ea53
|
|
56
56
|
/deepseek-ai-dsh-tool-subagent-control/model-experience/tool-schema/what-the-model-sees:
|
|
57
|
-
en:
|
|
58
|
-
zh:
|
|
57
|
+
en: e7622a6166907d37
|
|
58
|
+
zh: 3acea46fe839cf5e
|
|
59
59
|
/deepseek-ai-dsh-tool-subagent-control/model-experience/tool-schema/token-effect:
|
|
60
60
|
en: db207dc8d5860684
|
|
61
61
|
zh: ad2663b4967fbca9
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "Shared messaging, interruption, and child discovery tools for users and maintainers composing or debugging continuable-child control."
|
|
3
3
|
kind: "package-reference"
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
`dsh-tool-subagent-control`
|
|
12
|
+
`dsh-tool-subagent-control` lets agents message and interrupt subagents and list continuable children. One plugin instance registers all three tools for a scope shared by multiple delegation backends. Parents and continuable children inherit the same messaging definition and ordering. Tool presence does not select the delegation lifecycle.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -25,11 +25,11 @@ English | [中文](README.zh.md)
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## Use this package
|
|
27
27
|
|
|
28
|
-
Mount this package
|
|
28
|
+
Mount this package once per tool scope. It requires `tools`, `subagents`, and `agents`.
|
|
29
29
|
|
|
30
30
|
### Minimal configuration
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
With the required services available, load the subagent service, a backend, the delegation tool, and this package to expose all three control and discovery tools:
|
|
33
33
|
|
|
34
34
|
```yaml
|
|
35
35
|
- name: '@deepseek-ai/dsh-subagent'
|
|
@@ -38,10 +38,9 @@ Load the subagent service, a backend, the delegation tool, and this package. Add
|
|
|
38
38
|
config:
|
|
39
39
|
provider: spawn
|
|
40
40
|
- name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
41
|
-
- name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
42
41
|
```
|
|
43
42
|
|
|
44
|
-
This package takes no configuration
|
|
43
|
+
This package takes no configuration. Its main entry registers `send_message`, `interrupt_agent`, and `list_agents` together; existing tool restrictions can hide individual tools.
|
|
45
44
|
|
|
46
45
|
### send_message
|
|
47
46
|
|
|
@@ -81,7 +80,7 @@ The tool forwards its execution signal, which owns admission only until inbox ac
|
|
|
81
80
|
|
|
82
81
|
| File | Role |
|
|
83
82
|
|---|---|
|
|
84
|
-
| [`src/index.ts`](src/index.ts) |
|
|
83
|
+
| [`src/index.ts`](src/index.ts) | Shared registration of all three tools |
|
|
85
84
|
| [`src/list-agents.ts`](src/list-agents.ts) | `list_agents` registration: direct-child discovery and status refinement |
|
|
86
85
|
|
|
87
86
|
</details>
|
|
@@ -95,7 +94,7 @@ Read these pages when the package-level contract is not enough; they move from t
|
|
|
95
94
|
|
|
96
95
|
- [Subagent subsystem](../../../docs/subsystems/subagent.md) — continuable children, activations, inbox, interrupt, and follow-up authority.
|
|
97
96
|
- [dsh-tool-subagent](../tool-subagent/README.md) — the delegation tool that starts continuable children.
|
|
98
|
-
- [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent-control) — the
|
|
97
|
+
- [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent-control) — the tool schemas.
|
|
99
98
|
|
|
100
99
|
-----
|
|
101
100
|
|
|
@@ -106,7 +105,7 @@ Read these pages when the package-level contract is not enough; they move from t
|
|
|
106
105
|
|
|
107
106
|
#### What the model sees
|
|
108
107
|
|
|
109
|
-
The generated [schemas](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent-control): `send_message` takes `agent_id` and `message`; `interrupt_agent` takes `agent_id`; `list_agents`
|
|
108
|
+
The generated [schemas](../../../docs/tool-catalog.md#deepseek-aidsh-tool-subagent-control): `send_message` takes `agent_id` and `message`; `interrupt_agent` takes `agent_id`; `list_agents` accepts an optional `scope`.
|
|
110
109
|
|
|
111
110
|
#### Token effect
|
|
112
111
|
|
package/README.zh.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "供用户与维护者在组合或调试可继续子级控制功能时使用的共享消息、中断与子级发现工具。"
|
|
3
3
|
kind: "package-reference"
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ kind: "package-reference"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
`dsh-tool-subagent-control`
|
|
12
|
+
`dsh-tool-subagent-control` 让 agent 向子智能体发消息、中断子智能体、列出可继续子级。一个插件实例为多个委派后端共享的作用域注册全部三个工具。父级与可继续子级继承相同的消息定义和顺序。工具存在不选择委派生命周期。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -25,11 +25,11 @@ kind: "package-reference"
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## 使用本包
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
每个工具作用域挂载本包一次。它要求 `tools`、`subagents` 和 `agents`。
|
|
29
29
|
|
|
30
30
|
### 最小配置
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
在所需服务可用后,加载 subagent 服务、一个后端、委派工具与本包,即可公开全部三个控制和发现工具:
|
|
33
33
|
|
|
34
34
|
```yaml
|
|
35
35
|
- name: '@deepseek-ai/dsh-subagent'
|
|
@@ -38,10 +38,9 @@ kind: "package-reference"
|
|
|
38
38
|
config:
|
|
39
39
|
provider: spawn
|
|
40
40
|
- name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
41
|
-
- name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
42
41
|
```
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
本包不接收任何配置。主入口一起注册 `send_message`、`interrupt_agent` 和 `list_agents`;现有工具限制可以隐藏单个工具。
|
|
45
44
|
|
|
46
45
|
### send_message
|
|
47
46
|
|
|
@@ -81,7 +80,7 @@ kind: "package-reference"
|
|
|
81
80
|
|
|
82
81
|
| 文件 | 职责 |
|
|
83
82
|
|---|---|
|
|
84
|
-
| [`src/index.ts`](src/index.ts) |
|
|
83
|
+
| [`src/index.ts`](src/index.ts) | 统一注册全部三个工具 |
|
|
85
84
|
| [`src/list-agents.ts`](src/list-agents.ts) | `list_agents` 注册:直接子级发现与状态细化 |
|
|
86
85
|
|
|
87
86
|
</details>
|
|
@@ -95,7 +94,7 @@ kind: "package-reference"
|
|
|
95
94
|
|
|
96
95
|
- [Subagent 子系统](../../../docs/subsystems/subagent.zh.md)——可继续子级、Activation、inbox、中断与后续消息权限。
|
|
97
96
|
- [dsh-tool-subagent](../tool-subagent/README.zh.md)——启动可继续子级的委派工具。
|
|
98
|
-
- [生成工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent-control)
|
|
97
|
+
- [生成工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent-control)——工具 schema。
|
|
99
98
|
|
|
100
99
|
-----
|
|
101
100
|
|
|
@@ -106,7 +105,7 @@ kind: "package-reference"
|
|
|
106
105
|
|
|
107
106
|
#### 模型看到什么
|
|
108
107
|
|
|
109
|
-
已生成的 [schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent-control):`send_message` 接受 `agent_id` 与 `message`;`interrupt_agent` 接受 `agent_id`;`list_agents`
|
|
108
|
+
已生成的 [schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-subagent-control):`send_message` 接受 `agent_id` 与 `message`;`interrupt_agent` 接受 `agent_id`;`list_agents` 接受可选的 `scope`。
|
|
110
109
|
|
|
111
110
|
#### Token 影响
|
|
112
111
|
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,140 @@
|
|
|
1
1
|
import { brandString } from "@deepseek-ai/dsh-brand";
|
|
2
2
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
3
|
import { markAdjacentAgentSendMessageTool } from "@deepseek-ai/dsh-subagent/internal";
|
|
4
|
+
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
5
|
+
//#region lib/types/list-agents.js
|
|
6
|
+
/**
|
|
7
|
+
* The globally named `list_agents` tool: a thin model-facing adapter over
|
|
8
|
+
* the continuable projection of `ctx.subagents.listChildren()` and, for the
|
|
9
|
+
* `descendants` scope, `ctx.subagents.listDescendants()`. The control plugin owns
|
|
10
|
+
* registration and disposal alongside messaging and interruption.
|
|
11
|
+
*/
|
|
12
|
+
/** Resolve the optional model request into an internal required-scope spec. */
|
|
13
|
+
function resolveListAgentsRequest(request) {
|
|
14
|
+
return { scope: request.scope ?? "children" };
|
|
15
|
+
}
|
|
16
|
+
/** Report turn activity without exposing whether the child is loaded. */
|
|
17
|
+
function statusOf(agents, id) {
|
|
18
|
+
return agents.get(id)?.status === "running" ? "running" : "inactive";
|
|
19
|
+
}
|
|
20
|
+
/** Project one service row into the model-facing entry, or omit a one-shot child. */
|
|
21
|
+
function project(agents, entry, position) {
|
|
22
|
+
const at = position === void 0 ? {} : {
|
|
23
|
+
parent: position.parentId,
|
|
24
|
+
depth: position.depth
|
|
25
|
+
};
|
|
26
|
+
if ("kind" in entry && entry.kind === "diagnostic") return {
|
|
27
|
+
kind: "diagnostic",
|
|
28
|
+
id: entry.id,
|
|
29
|
+
reason: entry.reason,
|
|
30
|
+
...at
|
|
31
|
+
};
|
|
32
|
+
if (entry.mode !== "continuable") return void 0;
|
|
33
|
+
return {
|
|
34
|
+
kind: "child",
|
|
35
|
+
id: entry.id,
|
|
36
|
+
label: entry.label,
|
|
37
|
+
status: statusOf(agents, entry.id),
|
|
38
|
+
...at
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Register the `list_agents` tool.
|
|
43
|
+
* @param ctx - context carrying the tool registry, subagent service, and live Agent registry.
|
|
44
|
+
*/
|
|
45
|
+
function registerListAgents(ctx) {
|
|
46
|
+
ctx.tools.register(defineTool({
|
|
47
|
+
name: "list_agents",
|
|
48
|
+
description: "List subagents you started, with their ids, labels, and status. running means it is working; inactive means it is not currently working. You will be notified when a subagent finishes; there is no need to keep checking its status. Use send_message to continue the conversation.",
|
|
49
|
+
parameters: { scope: {
|
|
50
|
+
type: "string",
|
|
51
|
+
enum: ["children", "descendants"],
|
|
52
|
+
description: "children (default) lists direct children, which accept send_message in any status. descendants lists the whole tree below you with each entry's parent session id and depth; entries deeper than 1 accept only interrupt_agent."
|
|
53
|
+
} },
|
|
54
|
+
output: {
|
|
55
|
+
schema: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: { oneOf: [{
|
|
58
|
+
type: "object",
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
properties: {
|
|
61
|
+
kind: {
|
|
62
|
+
type: "string",
|
|
63
|
+
required: true,
|
|
64
|
+
enum: ["child"]
|
|
65
|
+
},
|
|
66
|
+
id: {
|
|
67
|
+
type: "string",
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
label: {
|
|
71
|
+
type: "string",
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
status: {
|
|
75
|
+
type: "string",
|
|
76
|
+
required: true,
|
|
77
|
+
enum: ["running", "inactive"]
|
|
78
|
+
},
|
|
79
|
+
parent: { type: "string" },
|
|
80
|
+
depth: { type: "number" }
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
type: "object",
|
|
84
|
+
additionalProperties: false,
|
|
85
|
+
properties: {
|
|
86
|
+
kind: {
|
|
87
|
+
type: "string",
|
|
88
|
+
required: true,
|
|
89
|
+
enum: ["diagnostic"]
|
|
90
|
+
},
|
|
91
|
+
id: {
|
|
92
|
+
type: "string",
|
|
93
|
+
required: true
|
|
94
|
+
},
|
|
95
|
+
reason: {
|
|
96
|
+
type: "string",
|
|
97
|
+
required: true,
|
|
98
|
+
enum: [
|
|
99
|
+
"corrupt",
|
|
100
|
+
"unsupported",
|
|
101
|
+
"unavailable"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
parent: { type: "string" },
|
|
105
|
+
depth: { type: "number" }
|
|
106
|
+
}
|
|
107
|
+
}] }
|
|
108
|
+
},
|
|
109
|
+
render: (args, entries) => {
|
|
110
|
+
const request = resolveListAgentsRequest(args);
|
|
111
|
+
return [{
|
|
112
|
+
type: "text",
|
|
113
|
+
text: entries.length === 0 ? "(no subagents)" : entries.map((entry) => {
|
|
114
|
+
const at = request.scope === "descendants" ? ` parent=${String(entry.parent)} depth=${String(entry.depth)}` : "";
|
|
115
|
+
return entry.kind === "child" ? `${entry.id} [${entry.status}]${at} — ${entry.label}` : `${entry.id} [diagnostic: ${entry.reason}]${at}`;
|
|
116
|
+
}).join("\n")
|
|
117
|
+
}];
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
async execute(args, exec) {
|
|
121
|
+
const parent = exec.agent;
|
|
122
|
+
if (!parent) throw new Error("list_agents requires a calling agent (exec.agent was undefined)");
|
|
123
|
+
const request = resolveListAgentsRequest(args);
|
|
124
|
+
switch (request.scope) {
|
|
125
|
+
case "children": return (await ctx.subagents.listChildren(parent.id, exec.signal)).map((entry) => project(ctx.agents, entry)).filter((entry) => entry !== void 0);
|
|
126
|
+
case "descendants": return (await ctx.subagents.listDescendants(parent.id, exec.signal)).map((entry) => project(ctx.agents, entry, entry)).filter((entry) => entry !== void 0);
|
|
127
|
+
/* v8 ignore next 2 -- the resolver normalizes the schema-validated closed scope before dispatch. */
|
|
128
|
+
default: return assertNever(request.scope, "list_agents scope");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
4
134
|
//#region lib/types/index.js
|
|
5
135
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `ctx.subagents.interrupt()`. They perform no lifecycle routing of their own —
|
|
136
|
+
* Shared messaging, interruption, and child discovery tools.
|
|
137
|
+
* They perform no lifecycle routing of their own —
|
|
9
138
|
* residency, cold resume, and interrupt authorization belong to the subagent
|
|
10
139
|
* service — and they live apart from the provider-bound
|
|
11
140
|
* `@deepseek-ai/dsh-tool-subagent` instances so multiple delegation tools share
|
|
@@ -13,12 +142,17 @@ import { markAdjacentAgentSendMessageTool } from "@deepseek-ai/dsh-subagent/inte
|
|
|
13
142
|
* @module @deepseek-ai/dsh-tool-subagent-control
|
|
14
143
|
*/
|
|
15
144
|
const name = "tool-subagent-control";
|
|
16
|
-
const inject = [
|
|
145
|
+
const inject = [
|
|
146
|
+
"tools",
|
|
147
|
+
"subagents",
|
|
148
|
+
"agents"
|
|
149
|
+
];
|
|
17
150
|
/**
|
|
18
|
-
* Register the
|
|
19
|
-
* @param ctx - context carrying
|
|
151
|
+
* Register the shared subagent control and discovery tools.
|
|
152
|
+
* @param ctx - context carrying tools, subagents, and live Agents.
|
|
20
153
|
*/
|
|
21
154
|
function apply(ctx) {
|
|
155
|
+
registerListAgents(ctx);
|
|
22
156
|
ctx.tools.register(markAdjacentAgentSendMessageTool(defineTool({
|
|
23
157
|
name: "send_message",
|
|
24
158
|
description: "Send a message to an agent. A working agent receives it at its next step; an idle agent starts a new turn with it. Returns delivery confirmation, not the agent's answer.",
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `ctx.subagents.interrupt()`. They perform no lifecycle routing of their own —
|
|
2
|
+
* Shared messaging, interruption, and child discovery tools.
|
|
3
|
+
* They perform no lifecycle routing of their own —
|
|
5
4
|
* residency, cold resume, and interrupt authorization belong to the subagent
|
|
6
5
|
* service — and they live apart from the provider-bound
|
|
7
6
|
* `@deepseek-ai/dsh-tool-subagent` instances so multiple delegation tools share
|
|
@@ -12,8 +11,8 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
12
11
|
export declare const name = "tool-subagent-control";
|
|
13
12
|
export declare const inject: string[];
|
|
14
13
|
/**
|
|
15
|
-
* Register the
|
|
16
|
-
* @param ctx - context carrying
|
|
14
|
+
* Register the shared subagent control and discovery tools.
|
|
15
|
+
* @param ctx - context carrying tools, subagents, and live Agents.
|
|
17
16
|
*/
|
|
18
17
|
export declare function apply(ctx: Context): void;
|
|
19
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The globally named `list_agents` tool: a thin model-facing adapter over
|
|
3
3
|
* the continuable projection of `ctx.subagents.listChildren()` and, for the
|
|
4
|
-
* `descendants` scope, `ctx.subagents.listDescendants()`.
|
|
5
|
-
*
|
|
6
|
-
* continuation delivery without exposing discovery.
|
|
7
|
-
* @module @deepseek-ai/dsh-tool-subagent-control/list-agents
|
|
4
|
+
* `descendants` scope, `ctx.subagents.listDescendants()`. The control plugin owns
|
|
5
|
+
* registration and disposal alongside messaging and interruption.
|
|
8
6
|
*/
|
|
9
7
|
import type { Context } from '@deepseek-ai/cordis';
|
|
10
|
-
export declare const name = "tool-subagent-list-agents";
|
|
11
|
-
export declare const inject: string[];
|
|
12
8
|
/**
|
|
13
9
|
* Register the `list_agents` tool.
|
|
14
10
|
* @param ctx - context carrying the tool registry, subagent service, and live Agent registry.
|
|
15
11
|
*/
|
|
16
|
-
export declare function
|
|
12
|
+
export declare function registerListAgents(ctx: Context): void;
|
|
17
13
|
//# sourceMappingURL=list-agents.d.ts.map
|
package/locale/de.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-tool-subagent-control",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.2.
|
|
3
|
+
"description": "Shared messaging, interruption, and child discovery tools for subagents",
|
|
4
|
+
"version": "0.2.2-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,48 +18,43 @@
|
|
|
18
18
|
"types": "./lib/types/index.d.ts",
|
|
19
19
|
"default": "./lib/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./list-agents": {
|
|
22
|
-
"types": "./lib/types/list-agents.d.ts",
|
|
23
|
-
"default": "./lib/types/list-agents.js"
|
|
24
|
-
},
|
|
25
21
|
"./src/*": "./src/*",
|
|
26
22
|
"./package.json": "./package.json",
|
|
27
|
-
"./locale/*.json": "./locale/*.json"
|
|
28
|
-
"./list-agents/locale/*.json": "./locale/list-agents/*.json"
|
|
23
|
+
"./locale/*.json": "./locale/*.json"
|
|
29
24
|
},
|
|
30
25
|
"files": [
|
|
31
26
|
"locale/*.json",
|
|
32
|
-
"locale/list-agents/*.json",
|
|
33
27
|
"lib/index.js",
|
|
34
|
-
"lib/types/**/*.js",
|
|
35
28
|
"lib/types/**/*.d.ts"
|
|
36
29
|
],
|
|
37
30
|
"license": "MIT",
|
|
38
31
|
"peerDependencies": {
|
|
39
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
40
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
41
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
42
|
-
"@deepseek-ai/dsh-subagent": "0.2.
|
|
43
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
32
|
+
"@deepseek-ai/cordis": "~4.0.6-alpha.1",
|
|
33
|
+
"@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
|
|
34
|
+
"@deepseek-ai/dsh-session": "0.2.2-alpha.2",
|
|
35
|
+
"@deepseek-ai/dsh-subagent": "0.2.2-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-tools": "0.2.2-alpha.2",
|
|
37
|
+
"@deepseek-ai/dsh-agent": "0.2.2-alpha.2"
|
|
44
38
|
},
|
|
45
39
|
"devDependencies": {
|
|
46
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
47
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
48
|
-
"@deepseek-ai/dsh-agent-loop": "0.2.
|
|
49
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.
|
|
50
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
51
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
52
|
-
"@deepseek-ai/dsh-session-persistence": "0.2.
|
|
53
|
-
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.
|
|
54
|
-
"@deepseek-ai/dsh-session-projection": "0.2.
|
|
55
|
-
"@deepseek-ai/dsh-session-query": "0.2.
|
|
56
|
-
"@deepseek-ai/dsh-subagent": "0.2.
|
|
57
|
-
"@deepseek-ai/dsh-subagent-fork-in-process": "0.2.
|
|
58
|
-
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
40
|
+
"@deepseek-ai/cordis": "~4.0.6-alpha.1",
|
|
41
|
+
"@deepseek-ai/dsh-agent": "0.2.2-alpha.2",
|
|
42
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.2-alpha.2",
|
|
43
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-alpha.2",
|
|
44
|
+
"@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
|
|
45
|
+
"@deepseek-ai/dsh-session": "0.2.2-alpha.2",
|
|
46
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.2-alpha.2",
|
|
47
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.2-alpha.2",
|
|
48
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-alpha.2",
|
|
49
|
+
"@deepseek-ai/dsh-session-query": "0.2.2-alpha.2",
|
|
50
|
+
"@deepseek-ai/dsh-subagent": "0.2.2-alpha.2",
|
|
51
|
+
"@deepseek-ai/dsh-subagent-fork-in-process": "0.2.2-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.2-alpha.2",
|
|
53
|
+
"@deepseek-ai/dsh-tool-testkit": "0.2.2-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-tools": "0.2.2-alpha.2"
|
|
60
55
|
},
|
|
61
56
|
"dependencies": {
|
|
62
|
-
"@deepseek-ai/dsh-brand": "0.2.
|
|
63
|
-
"@deepseek-ai/dsh-util-values": "0.2.
|
|
57
|
+
"@deepseek-ai/dsh-brand": "0.2.2-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-util-values": "0.2.2-alpha.2"
|
|
64
59
|
}
|
|
65
60
|
}
|
package/lib/types/index.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The globally named `send_message` and `interrupt_agent` tools: thin
|
|
3
|
-
* model-facing adapters over `ctx.subagents.sendMessage()` and
|
|
4
|
-
* `ctx.subagents.interrupt()`. They perform no lifecycle routing of their own —
|
|
5
|
-
* residency, cold resume, and interrupt authorization belong to the subagent
|
|
6
|
-
* service — and they live apart from the provider-bound
|
|
7
|
-
* `@deepseek-ai/dsh-tool-subagent` instances so multiple delegation tools share
|
|
8
|
-
* one control API.
|
|
9
|
-
* @module @deepseek-ai/dsh-tool-subagent-control
|
|
10
|
-
*/
|
|
11
|
-
import { brandString } from '@deepseek-ai/dsh-brand';
|
|
12
|
-
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
13
|
-
import { markAdjacentAgentSendMessageTool } from '@deepseek-ai/dsh-subagent/internal';
|
|
14
|
-
export const name = 'tool-subagent-control';
|
|
15
|
-
export const inject = ['tools', 'subagents'];
|
|
16
|
-
/**
|
|
17
|
-
* Register the `send_message` and `interrupt_agent` tools.
|
|
18
|
-
* @param ctx - context carrying the tool registry and subagent service.
|
|
19
|
-
*/
|
|
20
|
-
export function apply(ctx) {
|
|
21
|
-
ctx.tools.register(markAdjacentAgentSendMessageTool(defineTool({
|
|
22
|
-
name: 'send_message',
|
|
23
|
-
description: 'Send a message to an agent. A working agent receives it at its next step; an idle agent starts a new turn with it. '
|
|
24
|
-
+ 'Returns delivery confirmation, not the agent\'s answer.',
|
|
25
|
-
parameters: {
|
|
26
|
-
agent_id: {
|
|
27
|
-
type: 'string',
|
|
28
|
-
required: true,
|
|
29
|
-
description: 'The agent id of your direct continuable child, or your direct parent when you are a resident continuable child.',
|
|
30
|
-
},
|
|
31
|
-
message: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
required: true,
|
|
34
|
-
description: 'The message to deliver to the agent.',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
output: {
|
|
38
|
-
schema: {
|
|
39
|
-
type: 'object',
|
|
40
|
-
additionalProperties: false,
|
|
41
|
-
properties: {
|
|
42
|
-
messageId: { type: 'string', required: true },
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
render: (args, _value) => [{
|
|
46
|
-
type: 'text',
|
|
47
|
-
text: `message delivered to agent ${args.agent_id}`,
|
|
48
|
-
}],
|
|
49
|
-
},
|
|
50
|
-
async execute(args, exec) {
|
|
51
|
-
const sender = exec.agent;
|
|
52
|
-
if (!sender) {
|
|
53
|
-
throw new Error('send_message requires a calling agent (exec.agent was undefined)');
|
|
54
|
-
}
|
|
55
|
-
const message = [{ type: 'text', text: args.message }];
|
|
56
|
-
const messageId = await ctx.subagents.sendMessage(sender, brandString(args.agent_id), message, { signal: exec.signal });
|
|
57
|
-
return { messageId };
|
|
58
|
-
},
|
|
59
|
-
})));
|
|
60
|
-
ctx.tools.register(defineTool({
|
|
61
|
-
name: 'interrupt_agent',
|
|
62
|
-
description: 'Ask a subagent to stop its current work. This call returns without waiting for it to stop. '
|
|
63
|
-
+ 'You can continue a local direct child\'s conversation later with send_message. '
|
|
64
|
-
+ 'External executions stop permanently and cannot receive follow-ups. Subagents it started will keep running.',
|
|
65
|
-
parameters: {
|
|
66
|
-
agent_id: {
|
|
67
|
-
type: 'string',
|
|
68
|
-
required: true,
|
|
69
|
-
description: 'The id of an agent created under you: your direct child or a deeper descendant.',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
output: {
|
|
73
|
-
schema: {
|
|
74
|
-
type: 'object',
|
|
75
|
-
additionalProperties: false,
|
|
76
|
-
properties: {
|
|
77
|
-
accepted: { type: 'boolean', required: true },
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
render: (args, _value) => [{
|
|
81
|
-
type: 'text',
|
|
82
|
-
text: `interrupt requested for agent ${args.agent_id}`,
|
|
83
|
-
}],
|
|
84
|
-
},
|
|
85
|
-
execute(args, exec) {
|
|
86
|
-
const caller = exec.agent;
|
|
87
|
-
if (!caller) {
|
|
88
|
-
// Ancestor authority requires an exact live calling agent.
|
|
89
|
-
throw new Error('interrupt_agent requires a calling agent (exec.agent was undefined)');
|
|
90
|
-
}
|
|
91
|
-
// The service authorizes the exact live caller against the target's
|
|
92
|
-
// recorded lineage; the tool adds no authority of its own.
|
|
93
|
-
ctx.subagents.interrupt(brandString(args.agent_id), { kind: 'ancestor', agent: caller });
|
|
94
|
-
return Promise.resolve({ accepted: true });
|
|
95
|
-
},
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=index.js.map
|
package/lib/types/list-agents.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The globally named `list_agents` tool: a thin model-facing adapter over
|
|
3
|
-
* the continuable projection of `ctx.subagents.listChildren()` and, for the
|
|
4
|
-
* `descendants` scope, `ctx.subagents.listDescendants()`. It stays separately
|
|
5
|
-
* loadable from the root `send_message` plugin so a deployment can register
|
|
6
|
-
* continuation delivery without exposing discovery.
|
|
7
|
-
* @module @deepseek-ai/dsh-tool-subagent-control/list-agents
|
|
8
|
-
*/
|
|
9
|
-
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
10
|
-
import { assertNever } from '@deepseek-ai/dsh-util-values';
|
|
11
|
-
export const name = 'tool-subagent-list-agents';
|
|
12
|
-
export const inject = ['tools', 'subagents', 'agents'];
|
|
13
|
-
/** Resolve the optional model request into an internal required-scope spec. */
|
|
14
|
-
function resolveListAgentsRequest(request) {
|
|
15
|
-
return { scope: request.scope ?? 'children' };
|
|
16
|
-
}
|
|
17
|
-
/** Report turn activity without exposing whether the child is loaded. */
|
|
18
|
-
function statusOf(agents, id) {
|
|
19
|
-
return agents.get(id)?.status === 'running' ? 'running' : 'inactive';
|
|
20
|
-
}
|
|
21
|
-
/** Project one service row into the model-facing entry, or omit a one-shot child. */
|
|
22
|
-
function project(agents, entry, position) {
|
|
23
|
-
const at = position === undefined ? {} : { parent: position.parentId, depth: position.depth };
|
|
24
|
-
if ('kind' in entry && entry.kind === 'diagnostic') {
|
|
25
|
-
return { kind: 'diagnostic', id: entry.id, reason: entry.reason, ...at };
|
|
26
|
-
}
|
|
27
|
-
// One-shot children cannot be continued by send_message, so the model
|
|
28
|
-
// never selects them; discovery still traversed them for descendants.
|
|
29
|
-
if (entry.mode !== 'continuable')
|
|
30
|
-
return undefined;
|
|
31
|
-
return {
|
|
32
|
-
kind: 'child',
|
|
33
|
-
id: entry.id,
|
|
34
|
-
label: entry.label,
|
|
35
|
-
status: statusOf(agents, entry.id),
|
|
36
|
-
...at,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Register the `list_agents` tool.
|
|
41
|
-
* @param ctx - context carrying the tool registry, subagent service, and live Agent registry.
|
|
42
|
-
*/
|
|
43
|
-
export function apply(ctx) {
|
|
44
|
-
ctx.tools.register(defineTool({
|
|
45
|
-
name: 'list_agents',
|
|
46
|
-
description: 'List subagents you started, with their ids, labels, and status. '
|
|
47
|
-
+ 'running means it is working; inactive means it is not currently working. '
|
|
48
|
-
+ 'You will be notified when a subagent finishes; there is no need to keep checking its status. '
|
|
49
|
-
+ 'Use send_message to continue the conversation.',
|
|
50
|
-
parameters: {
|
|
51
|
-
scope: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
enum: ['children', 'descendants'],
|
|
54
|
-
description: 'children (default) lists direct children, which accept send_message in any status. '
|
|
55
|
-
+ 'descendants lists the whole tree below you with each entry\'s parent session id and depth; entries deeper than 1 accept only interrupt_agent.',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
output: {
|
|
59
|
-
schema: {
|
|
60
|
-
type: 'array',
|
|
61
|
-
items: {
|
|
62
|
-
oneOf: [
|
|
63
|
-
{
|
|
64
|
-
type: 'object',
|
|
65
|
-
additionalProperties: false,
|
|
66
|
-
properties: {
|
|
67
|
-
kind: { type: 'string', required: true, enum: ['child'] },
|
|
68
|
-
id: { type: 'string', required: true },
|
|
69
|
-
label: { type: 'string', required: true },
|
|
70
|
-
status: { type: 'string', required: true, enum: ['running', 'inactive'] },
|
|
71
|
-
parent: { type: 'string' },
|
|
72
|
-
depth: { type: 'number' },
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
type: 'object',
|
|
77
|
-
additionalProperties: false,
|
|
78
|
-
properties: {
|
|
79
|
-
kind: { type: 'string', required: true, enum: ['diagnostic'] },
|
|
80
|
-
id: { type: 'string', required: true },
|
|
81
|
-
reason: { type: 'string', required: true, enum: ['corrupt', 'unsupported', 'unavailable'] },
|
|
82
|
-
parent: { type: 'string' },
|
|
83
|
-
depth: { type: 'number' },
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
render: (args, entries) => {
|
|
90
|
-
const request = resolveListAgentsRequest(args);
|
|
91
|
-
return [{
|
|
92
|
-
type: 'text',
|
|
93
|
-
text: entries.length === 0
|
|
94
|
-
? '(no subagents)'
|
|
95
|
-
: entries.map((entry) => {
|
|
96
|
-
// A descendants row always carries its position; children rows
|
|
97
|
-
// never render it. String() spans the schema-optional shape
|
|
98
|
-
// without a dead fallback branch.
|
|
99
|
-
const at = request.scope === 'descendants'
|
|
100
|
-
? ` parent=${String(entry.parent)} depth=${String(entry.depth)}`
|
|
101
|
-
: '';
|
|
102
|
-
return entry.kind === 'child'
|
|
103
|
-
? `${entry.id} [${entry.status}]${at} — ${entry.label}`
|
|
104
|
-
: `${entry.id} [diagnostic: ${entry.reason}]${at}`;
|
|
105
|
-
}).join('\n'),
|
|
106
|
-
}];
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
async execute(args, exec) {
|
|
110
|
-
const parent = exec.agent;
|
|
111
|
-
if (!parent) {
|
|
112
|
-
// Non-agent callers have no session whose children could be listed.
|
|
113
|
-
throw new Error('list_agents requires a calling agent (exec.agent was undefined)');
|
|
114
|
-
}
|
|
115
|
-
const request = resolveListAgentsRequest(args);
|
|
116
|
-
switch (request.scope) {
|
|
117
|
-
case 'children': {
|
|
118
|
-
const entries = await ctx.subagents.listChildren(parent.id, exec.signal);
|
|
119
|
-
return entries
|
|
120
|
-
.map(entry => project(ctx.agents, entry))
|
|
121
|
-
.filter(entry => entry !== undefined);
|
|
122
|
-
}
|
|
123
|
-
case 'descendants': {
|
|
124
|
-
const entries = await ctx.subagents.listDescendants(parent.id, exec.signal);
|
|
125
|
-
return entries
|
|
126
|
-
.map(entry => project(ctx.agents, entry, entry))
|
|
127
|
-
.filter(entry => entry !== undefined);
|
|
128
|
-
}
|
|
129
|
-
/* v8 ignore next 2 -- the resolver normalizes the schema-validated closed scope before dispatch. */
|
|
130
|
-
default:
|
|
131
|
-
return assertNever(request.scope, 'list_agents scope');
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=list-agents.js.map
|