@deepseek-ai/dsh-subagent 0.1.1-rc.2 → 0.1.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 +2 -2
- package/README.md +105 -75
- package/README.zh.md +110 -84
- package/lib/index.js +910 -433
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1016 -0
- package/lib/typert.remote-client.d.ts +27 -0
- package/lib/typert.remote-client.js +242 -0
- package/lib/types/child-agent.d.ts +14 -3
- package/lib/types/child-agent.js +48 -10
- package/lib/types/client.d.ts +2 -1
- package/lib/types/client.js +1 -1
- package/lib/types/continuation.d.ts +4 -2
- package/lib/types/continuation.js +124 -46
- package/lib/types/control-types.d.ts +160 -0
- package/lib/types/control-types.js +9 -0
- package/lib/types/control.d.ts +83 -0
- package/lib/types/control.js +133 -0
- package/lib/types/descriptor.d.ts +6 -1
- package/lib/types/descriptor.js +6 -2
- package/lib/types/index.d.ts +60 -26
- package/lib/types/index.js +430 -299
- package/lib/types/list-children.d.ts +10 -58
- package/lib/types/list-children.js +161 -97
- package/lib/types/out-of-process.d.ts +3 -2
- package/lib/types/out-of-process.js +11 -3
- package/lib/types/run-settlement.js +7 -3
- package/lib/types/types.d.ts +18 -0
- package/package.json +63 -37
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import type {
|
|
3
|
+
RemoteResult,
|
|
4
|
+
TypertRemoteContribution,
|
|
5
|
+
} from '@deepseek-ai/dsh-typert-protocol'
|
|
6
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
7
|
+
import type { SubagentCatalog, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from '@deepseek-ai/dsh-subagent/client'
|
|
8
|
+
|
|
9
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
10
|
+
interface TypertRemoteNamespace$7375626167656e7473 {
|
|
11
|
+
interruptByParent: (childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable') => Promise<RemoteResult<SubagentInterruptReceipt>>
|
|
12
|
+
list: (parentSessionId: SessionId, signal?: AbortSignal) => Promise<RemoteResult<SubagentCatalog>>
|
|
13
|
+
prompt: (request: SubagentPromptRequest, signal?: AbortSignal) => Promise<RemoteResult<SubagentPromptReceipt>>
|
|
14
|
+
}
|
|
15
|
+
interface TypertRemoteMap {
|
|
16
|
+
'subagents/interruptByParent': (childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable') => Promise<RemoteResult<SubagentInterruptReceipt>>
|
|
17
|
+
'subagents/list': (parentSessionId: SessionId, signal?: AbortSignal) => Promise<RemoteResult<SubagentCatalog>>
|
|
18
|
+
'subagents/prompt': (request: SubagentPromptRequest, signal?: AbortSignal) => Promise<RemoteResult<SubagentPromptReceipt>>
|
|
19
|
+
}
|
|
20
|
+
interface TypertRemoteNamespaceMap {
|
|
21
|
+
'subagents': TypertRemoteNamespace$7375626167656e7473
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare const TYPERT_REMOTE: TypertRemoteContribution
|
|
26
|
+
export default TYPERT_REMOTE
|
|
27
|
+
//# sourceMappingURL=typert.remote-client.d.ts.map
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
const ToolResultBlockRemoteCodec$schema = z.object({
|
|
5
|
+
'type': z.literal("tool-result"),
|
|
6
|
+
'toolCallId': z.intersection(z.string(), z.unknown()),
|
|
7
|
+
'content': z.array(z.union([z.object({
|
|
8
|
+
'type': z.literal("text"),
|
|
9
|
+
'text': z.string(),
|
|
10
|
+
}), z.object({
|
|
11
|
+
'type': z.literal("image"),
|
|
12
|
+
'attachment': z.object({
|
|
13
|
+
'attachmentId': z.intersection(z.string(), z.unknown()),
|
|
14
|
+
'mediaType': z.union([z.literal("image/png"), z.literal("image/jpeg"), z.literal("image/webp"), z.literal("image/gif")]),
|
|
15
|
+
'bytes': z.number(),
|
|
16
|
+
'width': z.number(),
|
|
17
|
+
'height': z.number(),
|
|
18
|
+
'name': z.string().optional(),
|
|
19
|
+
'originalDimensions': z.object({
|
|
20
|
+
'width': z.number(),
|
|
21
|
+
'height': z.number(),
|
|
22
|
+
}).optional(),
|
|
23
|
+
}),
|
|
24
|
+
}), z.object({
|
|
25
|
+
'type': z.literal("reasoning"),
|
|
26
|
+
'text': z.string(),
|
|
27
|
+
}), z.object({
|
|
28
|
+
'type': z.literal("tool-call"),
|
|
29
|
+
'id': z.intersection(z.string(), z.unknown()),
|
|
30
|
+
'name': z.string(),
|
|
31
|
+
'arguments': z.string(),
|
|
32
|
+
}), z.lazy(() => ToolResultBlockRemoteCodec$schema)])),
|
|
33
|
+
'isError': z.boolean().optional(),
|
|
34
|
+
})
|
|
35
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
36
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema = z.intersection(z.string(), z.unknown())
|
|
37
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema = z.literal("continuable")
|
|
38
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = z.object({
|
|
39
|
+
'accepted': z.literal(true).readonly(),
|
|
40
|
+
})
|
|
41
|
+
const _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
42
|
+
const _deepseek_ai_dsh_subagent_subagents_list_result$schema = z.object({
|
|
43
|
+
'entries': z.array(z.union([z.intersection(z.object({
|
|
44
|
+
'kind': z.literal("child").readonly(),
|
|
45
|
+
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
46
|
+
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
47
|
+
'hasChildren': z.boolean().readonly(),
|
|
48
|
+
}), z.object({
|
|
49
|
+
'mode': z.literal("one-shot").readonly(),
|
|
50
|
+
'label': z.string().readonly().optional(),
|
|
51
|
+
})), z.intersection(z.object({
|
|
52
|
+
'kind': z.literal("child").readonly(),
|
|
53
|
+
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
54
|
+
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
55
|
+
'hasChildren': z.boolean().readonly(),
|
|
56
|
+
}), z.object({
|
|
57
|
+
'mode': z.literal("continuable").readonly(),
|
|
58
|
+
'label': z.string().readonly(),
|
|
59
|
+
})), z.object({
|
|
60
|
+
'kind': z.literal("diagnostic").readonly(),
|
|
61
|
+
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
62
|
+
'reason': z.union([z.literal("corrupt"), z.literal("unsupported"), z.literal("unavailable")]).readonly(),
|
|
63
|
+
})])).readonly(),
|
|
64
|
+
'parentAvailable': z.boolean().readonly(),
|
|
65
|
+
})
|
|
66
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = z.object({
|
|
67
|
+
'requestId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
68
|
+
'parentSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
69
|
+
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
70
|
+
'mode': z.literal("continuable").readonly(),
|
|
71
|
+
'content': z.array(z.union([z.object({
|
|
72
|
+
'type': z.literal("text"),
|
|
73
|
+
'text': z.string(),
|
|
74
|
+
}), z.object({
|
|
75
|
+
'type': z.literal("image"),
|
|
76
|
+
'attachment': z.object({
|
|
77
|
+
'attachmentId': z.intersection(z.string(), z.unknown()),
|
|
78
|
+
'mediaType': z.union([z.literal("image/png"), z.literal("image/jpeg"), z.literal("image/webp"), z.literal("image/gif")]),
|
|
79
|
+
'bytes': z.number(),
|
|
80
|
+
'width': z.number(),
|
|
81
|
+
'height': z.number(),
|
|
82
|
+
'name': z.string().optional(),
|
|
83
|
+
'originalDimensions': z.object({
|
|
84
|
+
'width': z.number(),
|
|
85
|
+
'height': z.number(),
|
|
86
|
+
}).optional(),
|
|
87
|
+
}),
|
|
88
|
+
}), z.object({
|
|
89
|
+
'type': z.literal("reasoning"),
|
|
90
|
+
'text': z.string(),
|
|
91
|
+
}), z.object({
|
|
92
|
+
'type': z.literal("tool-call"),
|
|
93
|
+
'id': z.intersection(z.string(), z.unknown()),
|
|
94
|
+
'name': z.string(),
|
|
95
|
+
'arguments': z.string(),
|
|
96
|
+
}), z.object({
|
|
97
|
+
'type': z.literal("tool-result"),
|
|
98
|
+
'toolCallId': z.intersection(z.string(), z.unknown()),
|
|
99
|
+
'content': z.array(z.union([z.object({
|
|
100
|
+
'type': z.literal("text"),
|
|
101
|
+
'text': z.string(),
|
|
102
|
+
}), z.object({
|
|
103
|
+
'type': z.literal("image"),
|
|
104
|
+
'attachment': z.object({
|
|
105
|
+
'attachmentId': z.intersection(z.string(), z.unknown()),
|
|
106
|
+
'mediaType': z.union([z.literal("image/png"), z.literal("image/jpeg"), z.literal("image/webp"), z.literal("image/gif")]),
|
|
107
|
+
'bytes': z.number(),
|
|
108
|
+
'width': z.number(),
|
|
109
|
+
'height': z.number(),
|
|
110
|
+
'name': z.string().optional(),
|
|
111
|
+
'originalDimensions': z.object({
|
|
112
|
+
'width': z.number(),
|
|
113
|
+
'height': z.number(),
|
|
114
|
+
}).optional(),
|
|
115
|
+
}),
|
|
116
|
+
}), z.object({
|
|
117
|
+
'type': z.literal("reasoning"),
|
|
118
|
+
'text': z.string(),
|
|
119
|
+
}), z.object({
|
|
120
|
+
'type': z.literal("tool-call"),
|
|
121
|
+
'id': z.intersection(z.string(), z.unknown()),
|
|
122
|
+
'name': z.string(),
|
|
123
|
+
'arguments': z.string(),
|
|
124
|
+
}), z.lazy(() => ToolResultBlockRemoteCodec$schema)])),
|
|
125
|
+
'isError': z.boolean().optional(),
|
|
126
|
+
}), z.object({
|
|
127
|
+
'type': z.literal("image").readonly(),
|
|
128
|
+
'mediaType': z.union([z.literal("image/png"), z.literal("image/jpeg"), z.literal("image/webp"), z.literal("image/gif")]),
|
|
129
|
+
'data': z.string(),
|
|
130
|
+
'name': z.string().optional(),
|
|
131
|
+
})])).readonly(),
|
|
132
|
+
'clientTimeZone': z.string().readonly().optional(),
|
|
133
|
+
})
|
|
134
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_result$schema = z.object({
|
|
135
|
+
'messageId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
export const TYPERT_REMOTE = {
|
|
139
|
+
package: '@deepseek-ai/dsh-subagent',
|
|
140
|
+
descriptors: [
|
|
141
|
+
{
|
|
142
|
+
id: '@deepseek-ai/dsh-subagent#subagents/interruptByParent',
|
|
143
|
+
service: 'subagents',
|
|
144
|
+
namespace: 'subagents',
|
|
145
|
+
method: 'interruptByParent',
|
|
146
|
+
invocation: { kind: 'direct' },
|
|
147
|
+
parameters: [
|
|
148
|
+
{
|
|
149
|
+
name: 'childSessionId',
|
|
150
|
+
wire: 'childSessionId',
|
|
151
|
+
source: 'json',
|
|
152
|
+
codec: {
|
|
153
|
+
mode: 'strict',
|
|
154
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
155
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'parentSessionId',
|
|
160
|
+
wire: 'parentSessionId',
|
|
161
|
+
source: 'json',
|
|
162
|
+
codec: {
|
|
163
|
+
mode: 'strict',
|
|
164
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
165
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'mode',
|
|
170
|
+
wire: 'mode',
|
|
171
|
+
source: 'json',
|
|
172
|
+
codec: {
|
|
173
|
+
mode: 'strict',
|
|
174
|
+
typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
|
|
175
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
result: {
|
|
180
|
+
mode: 'strict',
|
|
181
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
182
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
183
|
+
},
|
|
184
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":479,"column":3},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
188
|
+
service: 'subagents',
|
|
189
|
+
namespace: 'subagents',
|
|
190
|
+
method: 'list',
|
|
191
|
+
implementation: 'remoteExportList',
|
|
192
|
+
invocation: { kind: 'direct' },
|
|
193
|
+
parameters: [
|
|
194
|
+
{
|
|
195
|
+
name: 'parentSessionId',
|
|
196
|
+
wire: 'parentSessionId',
|
|
197
|
+
source: 'json',
|
|
198
|
+
codec: {
|
|
199
|
+
mode: 'strict',
|
|
200
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
201
|
+
schema: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
cancellation: { parameter: 'signal' },
|
|
206
|
+
result: {
|
|
207
|
+
mode: 'strict',
|
|
208
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
209
|
+
schema: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
210
|
+
},
|
|
211
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":406,"column":9},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
215
|
+
service: 'subagents',
|
|
216
|
+
namespace: 'subagents',
|
|
217
|
+
method: 'prompt',
|
|
218
|
+
invocation: { kind: 'direct' },
|
|
219
|
+
parameters: [
|
|
220
|
+
{
|
|
221
|
+
name: 'request',
|
|
222
|
+
wire: 'request',
|
|
223
|
+
source: 'json',
|
|
224
|
+
codec: {
|
|
225
|
+
mode: 'strict',
|
|
226
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
|
|
227
|
+
schema: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
cancellation: { parameter: 'signal' },
|
|
232
|
+
result: {
|
|
233
|
+
mode: 'strict',
|
|
234
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
|
|
235
|
+
schema: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
|
|
236
|
+
},
|
|
237
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":430,"column":9},
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default TYPERT_REMOTE
|
|
@@ -30,9 +30,20 @@ export declare class SubagentDepthError extends Error {
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function resolveChildDepth(parent: Agent, maxDepth: number | undefined): number;
|
|
32
32
|
/**
|
|
33
|
-
* Resolve the child
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* Resolve the parent values inherited by a child. The latest request header
|
|
34
|
+
* owns provider, model, and reasoning effort after request-time selection;
|
|
35
|
+
* creation options remain the fallback before the first request and retain
|
|
36
|
+
* the configured output-token limit.
|
|
37
|
+
* @param parent - delegating parent Agent.
|
|
38
|
+
* @returns detached Agent options for child-option merging.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parentAgentOptionsForDelegation(parent: Agent): AgentOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the child's `AgentOptions`: the parent's provider/model,
|
|
43
|
+
* reasoning-effort, and maxTokens values unless the request overrides them,
|
|
44
|
+
* stamped with the child's own delegation depth. Changing the route without
|
|
45
|
+
* naming an effort clears the parent's route-owned effort so the selected
|
|
46
|
+
* model resolves its own default.
|
|
36
47
|
* @param parent - the delegating parent whose route the child inherits.
|
|
37
48
|
* @param requested - per-child overrides, if any.
|
|
38
49
|
* @param childDepth - the resolved delegation depth to stamp.
|
package/lib/types/child-agent.js
CHANGED
|
@@ -40,25 +40,56 @@ export function resolveChildDepth(parent, maxDepth) {
|
|
|
40
40
|
return childDepth;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Resolve the child
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* Resolve the parent values inherited by a child. The latest request header
|
|
44
|
+
* owns provider, model, and reasoning effort after request-time selection;
|
|
45
|
+
* creation options remain the fallback before the first request and retain
|
|
46
|
+
* the configured output-token limit.
|
|
47
|
+
* @param parent - delegating parent Agent.
|
|
48
|
+
* @returns detached Agent options for child-option merging.
|
|
49
|
+
*/
|
|
50
|
+
export function parentAgentOptionsForDelegation(parent) {
|
|
51
|
+
const requestConfig = parent.session.requestHeader()?.config;
|
|
52
|
+
if (requestConfig === undefined)
|
|
53
|
+
return { ...parent.options };
|
|
54
|
+
const { provider: _createdProvider, model: _createdModel, reasoningEffort: _createdReasoningEffort, ...createdOptions } = parent.options;
|
|
55
|
+
return {
|
|
56
|
+
...createdOptions,
|
|
57
|
+
provider: requestConfig.provider,
|
|
58
|
+
model: requestConfig.model,
|
|
59
|
+
...requestConfig.reasoningEffort === undefined
|
|
60
|
+
? {}
|
|
61
|
+
: { reasoningEffort: requestConfig.reasoningEffort },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the child's `AgentOptions`: the parent's provider/model,
|
|
66
|
+
* reasoning-effort, and maxTokens values unless the request overrides them,
|
|
67
|
+
* stamped with the child's own delegation depth. Changing the route without
|
|
68
|
+
* naming an effort clears the parent's route-owned effort so the selected
|
|
69
|
+
* model resolves its own default.
|
|
46
70
|
* @param parent - the delegating parent whose route the child inherits.
|
|
47
71
|
* @param requested - per-child overrides, if any.
|
|
48
72
|
* @param childDepth - the resolved delegation depth to stamp.
|
|
49
73
|
* @returns the resolved options for `ctx.agents.create()`.
|
|
50
74
|
*/
|
|
51
75
|
export function resolveChildAgentOptions(parent, requested, childDepth) {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
76
|
+
const parentOptions = parentAgentOptionsForDelegation(parent);
|
|
77
|
+
const parentProvider = parentOptions.provider;
|
|
78
|
+
const parentModel = parentOptions.model;
|
|
79
|
+
const parentReasoningEffort = parentOptions.reasoningEffort;
|
|
80
|
+
const parentMaxTokens = parentOptions.maxTokens;
|
|
81
|
+
const resolved = {
|
|
56
82
|
...parentProvider !== undefined ? { provider: parentProvider } : {},
|
|
57
83
|
...parentModel !== undefined ? { model: parentModel } : {},
|
|
84
|
+
...parentReasoningEffort !== undefined ? { reasoningEffort: parentReasoningEffort } : {},
|
|
58
85
|
...parentMaxTokens !== undefined ? { maxTokens: parentMaxTokens } : {},
|
|
59
86
|
...requested,
|
|
60
87
|
subagentDepth: childDepth,
|
|
61
88
|
};
|
|
89
|
+
const routeChanged = resolved.provider !== parentProvider || resolved.model !== parentModel;
|
|
90
|
+
if (routeChanged && requested?.reasoningEffort === undefined)
|
|
91
|
+
delete resolved.reasoningEffort;
|
|
92
|
+
return resolved;
|
|
62
93
|
}
|
|
63
94
|
/**
|
|
64
95
|
* Build the child session's durable creation metadata: the parent's workspace,
|
|
@@ -125,10 +156,17 @@ export const SUBAGENT_DELEGATION_CONTEXT = 'You are a delegated subagent: your p
|
|
|
125
156
|
*/
|
|
126
157
|
export function applyChildComposition(childCtx, parent, composition) {
|
|
127
158
|
childCtx.get('agentPresets')?.composeFrom(childCtx, parent.ctx);
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
childCtx.systemPrompt.context({
|
|
160
|
+
name: 'subagent:delegation',
|
|
161
|
+
order: childCtx.systemPrompt.getContextOrder('SUBAGENT_DELEGATION'),
|
|
162
|
+
text: SUBAGENT_DELEGATION_CONTEXT,
|
|
163
|
+
});
|
|
130
164
|
if (composition.persona !== undefined) {
|
|
131
|
-
childCtx.systemPrompt.section({
|
|
165
|
+
childCtx.systemPrompt.section({
|
|
166
|
+
name: 'deployment:persona',
|
|
167
|
+
order: childCtx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA'),
|
|
168
|
+
text: composition.persona,
|
|
169
|
+
});
|
|
132
170
|
}
|
|
133
171
|
if (composition.toolFilter !== undefined)
|
|
134
172
|
childCtx.tools.restrict(composition.toolFilter);
|
package/lib/types/client.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser-safe subagent projection vocabulary.
|
|
2
|
+
* Browser-safe subagent projection and control vocabulary.
|
|
3
3
|
*
|
|
4
4
|
* @module @deepseek-ai/dsh-subagent/client
|
|
5
5
|
*/
|
|
6
|
+
export type * from './control-types.ts';
|
|
6
7
|
export type { SubagentIdentityProjection, SubagentTimingProjection } from './projection-types.ts';
|
|
7
8
|
//# sourceMappingURL=client.d.ts.map
|
package/lib/types/client.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import type { Context } from '@deepseek-ai/cordis';
|
|
24
24
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
25
25
|
import type { ContentBlock, MessageId, MessageSource } from '@deepseek-ai/dsh-llm';
|
|
26
|
-
import { SessionId } from '@deepseek-ai/dsh-session';
|
|
26
|
+
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
27
27
|
import type { SubagentDescriptorData } from './descriptor.ts';
|
|
28
28
|
import type { ContinuableCreateRequest, ContinuableCreateSpec, SubagentStartRequest } from './types.ts';
|
|
29
29
|
import type { ActivationObserver } from './lifecycle.ts';
|
|
@@ -323,7 +323,7 @@ export declare class SubagentContinuationManager {
|
|
|
323
323
|
*/
|
|
324
324
|
private stateOf;
|
|
325
325
|
/**
|
|
326
|
-
* Cold-resume a persisted child:
|
|
326
|
+
* Cold-resume a persisted child: retain and authorize its prepared Session, fold the
|
|
327
327
|
* generic descriptor, create the Activation through `ctx.agents.resume()`,
|
|
328
328
|
* and submit the waiting turn. This never dispatches through a subagent
|
|
329
329
|
* provider — the persisted Session already holds the initial prefix and the
|
|
@@ -449,6 +449,8 @@ export declare class SubagentContinuationManager {
|
|
|
449
449
|
private flushFinalState;
|
|
450
450
|
/** Resolve the persistence service continuable children require, or fail loud. */
|
|
451
451
|
private requirePersistence;
|
|
452
|
+
/** Resolve the Session query service used for cold child observations. */
|
|
453
|
+
private requireSessionQuery;
|
|
452
454
|
}
|
|
453
455
|
export type { SubagentDescriptorData };
|
|
454
456
|
export default SubagentContinuationManager;
|
|
@@ -20,9 +20,61 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @module @deepseek-ai/dsh-subagent
|
|
22
22
|
*/
|
|
23
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
24
|
+
if (value !== null && value !== void 0) {
|
|
25
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
26
|
+
var dispose, inner;
|
|
27
|
+
if (async) {
|
|
28
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
29
|
+
dispose = value[Symbol.asyncDispose];
|
|
30
|
+
}
|
|
31
|
+
if (dispose === void 0) {
|
|
32
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
33
|
+
dispose = value[Symbol.dispose];
|
|
34
|
+
if (async) inner = dispose;
|
|
35
|
+
}
|
|
36
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
37
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
38
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
39
|
+
}
|
|
40
|
+
else if (async) {
|
|
41
|
+
env.stack.push({ async: true });
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
};
|
|
45
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
46
|
+
return function (env) {
|
|
47
|
+
function fail(e) {
|
|
48
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
49
|
+
env.hasError = true;
|
|
50
|
+
}
|
|
51
|
+
var r, s = 0;
|
|
52
|
+
function next() {
|
|
53
|
+
while (r = env.stack.pop()) {
|
|
54
|
+
try {
|
|
55
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
56
|
+
if (r.dispose) {
|
|
57
|
+
var result = r.dispose.call(r.value);
|
|
58
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
59
|
+
}
|
|
60
|
+
else s |= 1;
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
fail(e);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
67
|
+
if (env.hasError) throw env.error;
|
|
68
|
+
}
|
|
69
|
+
return next();
|
|
70
|
+
};
|
|
71
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
72
|
+
var e = new Error(message);
|
|
73
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
74
|
+
});
|
|
23
75
|
import { randomUUID } from 'node:crypto';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
76
|
+
import { brandString } from '@deepseek-ai/dsh-brand';
|
|
77
|
+
import { ReasoningEffortId, boundContextSummary, createUserMessage, errorChain } from '@deepseek-ai/dsh-llm';
|
|
26
78
|
import { foldSubagentDescriptor, snapshotSubagentDescriptor } from "./descriptor.js";
|
|
27
79
|
import { appendDelegatedPolicyOverrides, applyChildComposition, captureDelegatedPolicyOverrides, childSessionMeta, resolveChildAgentOptions, resolveChildDepth, } from "./child-agent.js";
|
|
28
80
|
import { assertSubagentMaxDepth } from "./depth.js";
|
|
@@ -156,19 +208,22 @@ export class SubagentContinuationManager {
|
|
|
156
208
|
this.assertAdmitting(parent);
|
|
157
209
|
const persistence = this.requirePersistence();
|
|
158
210
|
assertSubagentMaxDepth(request.maxDepth);
|
|
159
|
-
const childId = spec.childId ??
|
|
211
|
+
const childId = spec.childId ?? brandString(randomUUID());
|
|
160
212
|
this.assertChildIdAvailable(childId);
|
|
161
213
|
const childDepth = resolveChildDepth(parent, request.maxDepth);
|
|
162
214
|
// Snapshot before any await: invalid descriptor JSON rejects the call
|
|
163
215
|
// before a child exists, and the detached value is what reaches the log.
|
|
164
|
-
const
|
|
165
|
-
const
|
|
216
|
+
const agentOptions = resolveChildAgentOptions(parent, request.agentOptions, childDepth);
|
|
217
|
+
const agentProvider = agentOptions.provider;
|
|
218
|
+
const agentModel = agentOptions.model;
|
|
219
|
+
const agentReasoningEffort = agentOptions.reasoningEffort;
|
|
166
220
|
const descriptor = snapshotSubagentDescriptor({
|
|
167
221
|
mode: 'continuable',
|
|
168
222
|
provider: spec.provider,
|
|
169
223
|
label: spec.label,
|
|
170
224
|
...agentProvider !== undefined ? { agentProvider } : {},
|
|
171
225
|
...agentModel !== undefined ? { agentModel } : {},
|
|
226
|
+
...agentReasoningEffort !== undefined ? { agentReasoningEffort } : {},
|
|
172
227
|
...request.persona !== undefined ? { persona: request.persona } : {},
|
|
173
228
|
...request.toolFilter !== undefined ? { toolFilter: request.toolFilter } : {},
|
|
174
229
|
});
|
|
@@ -202,7 +257,7 @@ export class SubagentContinuationManager {
|
|
|
202
257
|
provider: spec.provider,
|
|
203
258
|
parent,
|
|
204
259
|
create: { seed, meta: childSessionMeta(parent, childDepth, lineageSeedLength), delegatedPolicies },
|
|
205
|
-
agentOptions
|
|
260
|
+
agentOptions,
|
|
206
261
|
composition: { persona: request.persona, toolFilter: request.toolFilter },
|
|
207
262
|
signal: spec.signal,
|
|
208
263
|
});
|
|
@@ -610,56 +665,71 @@ export class SubagentContinuationManager {
|
|
|
610
665
|
return 'settled';
|
|
611
666
|
}
|
|
612
667
|
/**
|
|
613
|
-
* Cold-resume a persisted child:
|
|
668
|
+
* Cold-resume a persisted child: retain and authorize its prepared Session, fold the
|
|
614
669
|
* generic descriptor, create the Activation through `ctx.agents.resume()`,
|
|
615
670
|
* and submit the waiting turn. This never dispatches through a subagent
|
|
616
671
|
* provider — the persisted Session already holds the initial prefix and the
|
|
617
672
|
* descriptor is the whole reconstruction input.
|
|
618
673
|
*/
|
|
619
674
|
async coldResume(parent, childId, content, options) {
|
|
620
|
-
const
|
|
621
|
-
let loaded;
|
|
675
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
622
676
|
try {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
677
|
+
const query = this.requireSessionQuery();
|
|
678
|
+
let observation;
|
|
679
|
+
try {
|
|
680
|
+
observation = await query.observeSession(childId, {
|
|
681
|
+
signal: options.signal,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
catch (error) {
|
|
685
|
+
options.signal.throwIfAborted();
|
|
686
|
+
throw new SubagentError(`subagent "${childId}" is unavailable`, 'NOT_RESUMABLE', { cause: error });
|
|
687
|
+
}
|
|
688
|
+
const source = __addDisposableResource(env_1, observation, false);
|
|
689
|
+
this.assertAdmitting(parent);
|
|
690
|
+
// Authorize the persisted header before folding: only the durable child's
|
|
691
|
+
// exact live direct parent may continue it.
|
|
692
|
+
this.authorizeLineage(parent, childId, source.header.parentSession);
|
|
693
|
+
// Fold only the child's own suffix: a fork seed replays the parent's log,
|
|
694
|
+
// which may carry an ANCESTOR's descriptor when the parent is itself a
|
|
695
|
+
// continuable child.
|
|
696
|
+
const descriptor = foldSubagentDescriptor(source.events.slice(source.header.seedLength ?? 0));
|
|
697
|
+
if (descriptor === undefined || descriptor.mode !== 'continuable') {
|
|
698
|
+
throw new SubagentError(`subagent "${childId}" has no supported continuation state and cannot be resumed; `
|
|
699
|
+
+ 'do not retry send_message with this id', 'NOT_RESUMABLE');
|
|
700
|
+
}
|
|
701
|
+
let activation;
|
|
702
|
+
try {
|
|
703
|
+
activation = await this.materialize({
|
|
704
|
+
childId,
|
|
705
|
+
provider: descriptor.provider,
|
|
706
|
+
parent,
|
|
707
|
+
agentOptions: {
|
|
708
|
+
...descriptor.agentProvider !== undefined ? { provider: descriptor.agentProvider } : {},
|
|
709
|
+
...descriptor.agentModel !== undefined ? { model: descriptor.agentModel } : {},
|
|
710
|
+
...descriptor.agentReasoningEffort !== undefined
|
|
711
|
+
? { reasoningEffort: ReasoningEffortId(descriptor.agentReasoningEffort) }
|
|
712
|
+
: {},
|
|
713
|
+
},
|
|
714
|
+
composition: { persona: descriptor.persona, toolFilter: descriptor.toolFilter },
|
|
715
|
+
signal: options.signal,
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
catch (error) {
|
|
719
|
+
options.signal.throwIfAborted();
|
|
720
|
+
if (error instanceof SubagentError)
|
|
721
|
+
throw error;
|
|
722
|
+
throw new SubagentError(`subagent "${childId}" is unavailable`, 'NOT_RESUMABLE', { cause: error });
|
|
723
|
+
}
|
|
724
|
+
return await this.submitMaterialized(activation, content, options.source, parent, options.signal);
|
|
641
725
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
childId,
|
|
646
|
-
provider: descriptor.provider,
|
|
647
|
-
parent,
|
|
648
|
-
agentOptions: {
|
|
649
|
-
...descriptor.agentProvider !== undefined ? { provider: descriptor.agentProvider } : {},
|
|
650
|
-
...descriptor.agentModel !== undefined ? { model: descriptor.agentModel } : {},
|
|
651
|
-
},
|
|
652
|
-
composition: { persona: descriptor.persona, toolFilter: descriptor.toolFilter },
|
|
653
|
-
signal: options.signal,
|
|
654
|
-
});
|
|
726
|
+
catch (e_1) {
|
|
727
|
+
env_1.error = e_1;
|
|
728
|
+
env_1.hasError = true;
|
|
655
729
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (error instanceof SubagentError)
|
|
659
|
-
throw error;
|
|
660
|
-
throw new SubagentError(`subagent "${childId}" is unavailable`, 'NOT_RESUMABLE', { cause: error });
|
|
730
|
+
finally {
|
|
731
|
+
__disposeResources(env_1);
|
|
661
732
|
}
|
|
662
|
-
return this.submitMaterialized(activation, content, options.source, parent, options.signal);
|
|
663
733
|
}
|
|
664
734
|
/**
|
|
665
735
|
* Submit to a freshly materialized Activation or roll it back completely.
|
|
@@ -1146,6 +1216,14 @@ export class SubagentContinuationManager {
|
|
|
1146
1216
|
}
|
|
1147
1217
|
return persistence;
|
|
1148
1218
|
}
|
|
1219
|
+
/** Resolve the Session query service used for cold child observations. */
|
|
1220
|
+
requireSessionQuery() {
|
|
1221
|
+
const query = this.ctx.get('sessionQuery');
|
|
1222
|
+
if (query === undefined) {
|
|
1223
|
+
throw new SubagentError('continuable subagents require session query (load @deepseek-ai/dsh-session-query)', 'CONTINUATION_UNAVAILABLE');
|
|
1224
|
+
}
|
|
1225
|
+
return query;
|
|
1226
|
+
}
|
|
1149
1227
|
}
|
|
1150
1228
|
export default SubagentContinuationManager;
|
|
1151
1229
|
//# sourceMappingURL=continuation.js.map
|