@deepseek-ai/dsh-subagent 0.2.2-rc.5 → 0.2.3-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 +20 -8
- package/README.md +21 -5
- package/README.zh.md +21 -5
- package/lib/index.js +94 -42
- package/lib/typert.host.js +45 -7
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +2 -2
- package/lib/types/activation.d.ts +2 -0
- package/lib/types/activation.d.ts.map +1 -1
- package/lib/types/activation.js +4 -0
- package/lib/types/activation.js.map +1 -1
- package/lib/types/child-agent.d.ts +8 -4
- package/lib/types/child-agent.d.ts.map +1 -1
- package/lib/types/child-agent.js +14 -8
- package/lib/types/child-agent.js.map +1 -1
- package/lib/types/control-types.d.ts +1 -1
- package/lib/types/depth.d.ts +1 -1
- package/lib/types/depth.d.ts.map +1 -1
- package/lib/types/depth.js +3 -2
- package/lib/types/depth.js.map +1 -1
- package/lib/types/error.d.ts +83 -2
- package/lib/types/error.d.ts.map +1 -1
- package/lib/types/error.js +8 -1
- package/lib/types/error.js.map +1 -1
- package/lib/types/index.d.ts +11 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +13 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/manager.d.ts +7 -1
- package/lib/types/manager.d.ts.map +1 -1
- package/lib/types/manager.js +30 -10
- package/lib/types/manager.js.map +1 -1
- package/lib/types/out-of-process.d.ts +1 -0
- package/lib/types/out-of-process.d.ts.map +1 -1
- package/lib/types/out-of-process.js +5 -3
- package/lib/types/out-of-process.js.map +1 -1
- package/lib/types/structured.d.ts.map +1 -1
- package/lib/types/structured.js +4 -2
- package/lib/types/structured.js.map +1 -1
- package/lib/types/types.d.ts +12 -4
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +49 -48
- package/src/activation.ts +5 -0
- package/src/child-agent.ts +14 -9
- package/src/control-types.ts +1 -1
- package/src/depth.ts +3 -2
- package/src/error.ts +86 -2
- package/src/index.ts +18 -2
- package/src/manager.ts +37 -11
- package/src/out-of-process.ts +5 -3
- package/src/structured.ts +4 -1
- package/src/types.ts +13 -4
package/lib/types/structured.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @module @deepseek-ai/dsh-subagent/structured
|
|
11
11
|
*/
|
|
12
12
|
import { ToolArgsError, validateJsonSchemaValue } from '@deepseek-ai/dsh-tools';
|
|
13
|
+
import { SubagentError } from "./error.js";
|
|
13
14
|
/** The model-facing tool name a structured child must call to finish. */
|
|
14
15
|
export const STRUCTURED_OUTPUT_TOOL = 'structured_output';
|
|
15
16
|
/**
|
|
@@ -66,8 +67,9 @@ export function attachStructuredRuntime(childCtx, schema, canComplete) {
|
|
|
66
67
|
// within the same turn, exactly like a schema-validated defineTool call.
|
|
67
68
|
if (violations.length > 0)
|
|
68
69
|
throw new ToolArgsError(violations);
|
|
69
|
-
if (!canComplete())
|
|
70
|
-
throw new
|
|
70
|
+
if (!canComplete()) {
|
|
71
|
+
throw new SubagentError('Process pending messages before submitting structured output.', 'STRUCTURED_OUTPUT_PENDING_INPUT');
|
|
72
|
+
}
|
|
71
73
|
// Two-phase commit, keyed by THIS execution: later transformable
|
|
72
74
|
// waterfalls may still turn the success into an error. ToolRuntime has
|
|
73
75
|
// already frozen model-bound arguments at the actual input boundary.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured.js","sourceRoot":"","sources":["../../src/structured.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAyB,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"structured.js","sourceRoot":"","sources":["../../src/structured.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAyB,MAAM,wBAAwB,CAAA;AACtG,OAAO,EAAE,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CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC9B,sGAAsG;gBACtG,IAAI,QAAQ,KAAK,SAAS;oBAAE,QAAQ,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;YAC/D,CAAC;iBAAM,CAAC;gBACN,0GAA0G;gBAC1G,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBACpD,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;gBACvD,CAAC;YACH,CAAC;YACD,OAAM;QACR,CAAC;QACD,IAAI,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,KAAK;YAAE,OAAM;QAC1C,MAAM,KAAK,GAAG,OAAO,CAAA;QACrB,OAAO,GAAG,SAAS,CAAA;QACnB,IAAI,MAAM,CAAC,OAAO;YAAE,OAAM;QAC1B,4GAA4G;QAC5G,IAAI,QAAQ,KAAK,SAAS;YAAE,QAAQ,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ;QACxB,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS;KACzF,CAAA;AACH,CAAC"}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ import type { Branded } from '@deepseek-ai/dsh-brand';
|
|
|
11
11
|
import type { ContentBlock, MessageId } from '@deepseek-ai/dsh-llm';
|
|
12
12
|
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session';
|
|
13
13
|
import type { ObjectJsonSchema } from '@deepseek-ai/dsh-tools';
|
|
14
|
+
/** Current concurrency capacity of one subagent tree; observing it reserves no slots. */
|
|
15
|
+
export interface SubagentCapacity {
|
|
16
|
+
/** Occupied slots, including starting, resident, and stopping children; excludes the root. */
|
|
17
|
+
readonly running: number;
|
|
18
|
+
/** Configured maximum; running may exceed it after the limit is lowered. */
|
|
19
|
+
readonly limit: number;
|
|
20
|
+
}
|
|
14
21
|
/** Identifies one subagent residency epoch across its lifecycle event pair. */
|
|
15
22
|
export type SubagentRunId = Branded<'SubagentRunId'>;
|
|
16
23
|
/**
|
|
@@ -141,7 +148,7 @@ export interface SubagentStartRequest {
|
|
|
141
148
|
readonly agentPreset?: string;
|
|
142
149
|
/** Optional short display label persisted with a session-backed child. */
|
|
143
150
|
readonly label?: string;
|
|
144
|
-
/**
|
|
151
|
+
/** Initial task; local continuable children record it as a message from the parent agent. */
|
|
145
152
|
readonly prompt: ContentBlock[];
|
|
146
153
|
/**
|
|
147
154
|
* The spawning agent. Its effective directory supplies the default cwd;
|
|
@@ -211,9 +218,10 @@ export interface ContinuableCreateRequest {
|
|
|
211
218
|
*/
|
|
212
219
|
export interface ContinuableCreateSpec {
|
|
213
220
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
221
|
+
* Unmodified completed-turn prefix of the parent's log, contiguous from seq
|
|
222
|
+
* 0 with lossless JSON and balanced steps and turns; absent for a fresh child.
|
|
223
|
+
* The manager uses its length as the fork cut and stores the prefix as
|
|
224
|
+
* supplied, so a transformed prefix would diverge from the parent history.
|
|
217
225
|
*/
|
|
218
226
|
readonly seed?: readonly SessionEvent[];
|
|
219
227
|
}
|
package/lib/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,E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G;IACpG,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAA;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IACxC;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yFAAyF;IACzF,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAA;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAA;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3E;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IACnE;;;;;;;;;;;;;OAaG;IACH,kBAAkB,CAAC,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;CACvF"}
|
package/lib/types/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,EAAmB,CAAA;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-subagent",
|
|
3
3
|
"description": "Abstract subagent seam (ctx.subagents): named-provider registry for delegating to child agents",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -50,33 +50,33 @@
|
|
|
50
50
|
],
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@deepseek-ai/dsh-brand": "0.2.
|
|
54
|
-
"@deepseek-ai/dsh-chunked-list": "0.2.
|
|
55
|
-
"@deepseek-ai/dsh-util-values": "0.2.
|
|
53
|
+
"@deepseek-ai/dsh-brand": "0.2.3-alpha.1",
|
|
54
|
+
"@deepseek-ai/dsh-chunked-list": "0.2.3-alpha.1",
|
|
55
|
+
"@deepseek-ai/dsh-util-values": "0.2.3-alpha.1",
|
|
56
56
|
"@deepseek-ai/schemastery": "~3.19.0",
|
|
57
57
|
"zod": "4.6.6"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
61
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
62
|
-
"@deepseek-ai/dsh-agent-preset-registry": "0.2.
|
|
63
|
-
"@deepseek-ai/dsh-attachment": "0.2.
|
|
64
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
65
|
-
"@deepseek-ai/dsh-sandbox": "0.2.
|
|
66
|
-
"@deepseek-ai/dsh-sandbox-policy": "0.2.
|
|
67
|
-
"@deepseek-ai/dsh-scope": "0.2.
|
|
68
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
69
|
-
"@deepseek-ai/dsh-session-persistence": "0.2.
|
|
70
|
-
"@deepseek-ai/dsh-session-projection": "0.2.
|
|
71
|
-
"@deepseek-ai/dsh-session-query": "0.2.
|
|
72
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.
|
|
73
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
74
|
-
"@deepseek-ai/dsh-typert-protocol": "0.2.
|
|
75
|
-
"@deepseek-ai/dsh-user-approval": "0.2.
|
|
76
|
-
"@deepseek-ai/dsh-util-time": "0.2.
|
|
77
|
-
"@deepseek-ai/dsh-permission-presets": "0.2.
|
|
78
|
-
"@deepseek-ai/dsh-workspace": "0.2.
|
|
79
|
-
"@deepseek-ai/dsh-working-directory": "0.2.
|
|
61
|
+
"@deepseek-ai/dsh-agent": "0.2.3-alpha.1",
|
|
62
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.3-alpha.1",
|
|
63
|
+
"@deepseek-ai/dsh-attachment": "0.2.3-alpha.1",
|
|
64
|
+
"@deepseek-ai/dsh-llm": "0.2.3-alpha.1",
|
|
65
|
+
"@deepseek-ai/dsh-sandbox": "0.2.3-alpha.1",
|
|
66
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.3-alpha.1",
|
|
67
|
+
"@deepseek-ai/dsh-scope": "0.2.3-alpha.1",
|
|
68
|
+
"@deepseek-ai/dsh-session": "0.2.3-alpha.1",
|
|
69
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.3-alpha.1",
|
|
70
|
+
"@deepseek-ai/dsh-session-projection": "0.2.3-alpha.1",
|
|
71
|
+
"@deepseek-ai/dsh-session-query": "0.2.3-alpha.1",
|
|
72
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.3-alpha.1",
|
|
73
|
+
"@deepseek-ai/dsh-tools": "0.2.3-alpha.1",
|
|
74
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.3-alpha.1",
|
|
75
|
+
"@deepseek-ai/dsh-user-approval": "0.2.3-alpha.1",
|
|
76
|
+
"@deepseek-ai/dsh-util-time": "0.2.3-alpha.1",
|
|
77
|
+
"@deepseek-ai/dsh-permission-presets": "0.2.3-alpha.1",
|
|
78
|
+
"@deepseek-ai/dsh-workspace": "0.2.3-alpha.1",
|
|
79
|
+
"@deepseek-ai/dsh-working-directory": "0.2.3-alpha.1"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"@deepseek-ai/dsh-agent-preset-registry": {
|
|
@@ -106,32 +106,33 @@
|
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
108
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
109
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
110
|
-
"@deepseek-ai/dsh-agent-preset-registry": "0.2.
|
|
111
|
-
"@deepseek-ai/dsh-attachment": "0.2.
|
|
112
|
-
"@deepseek-ai/dsh-
|
|
113
|
-
"@deepseek-ai/dsh-
|
|
114
|
-
"@deepseek-ai/dsh-sandbox
|
|
115
|
-
"@deepseek-ai/dsh-
|
|
116
|
-
"@deepseek-ai/dsh-
|
|
117
|
-
"@deepseek-ai/dsh-session
|
|
118
|
-
"@deepseek-ai/dsh-session-
|
|
119
|
-
"@deepseek-ai/dsh-session-
|
|
120
|
-
"@deepseek-ai/dsh-
|
|
121
|
-
"@deepseek-ai/dsh-
|
|
122
|
-
"@deepseek-ai/dsh-
|
|
123
|
-
"@deepseek-ai/dsh-
|
|
124
|
-
"@deepseek-ai/dsh-
|
|
125
|
-
"@deepseek-ai/dsh-
|
|
126
|
-
"@deepseek-ai/dsh-
|
|
127
|
-
"@deepseek-ai/dsh-
|
|
109
|
+
"@deepseek-ai/dsh-agent": "0.2.3-alpha.1",
|
|
110
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.3-alpha.1",
|
|
111
|
+
"@deepseek-ai/dsh-attachment": "0.2.3-alpha.1",
|
|
112
|
+
"@deepseek-ai/dsh-error": "0.2.3-alpha.1",
|
|
113
|
+
"@deepseek-ai/dsh-llm": "0.2.3-alpha.1",
|
|
114
|
+
"@deepseek-ai/dsh-sandbox": "0.2.3-alpha.1",
|
|
115
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.3-alpha.1",
|
|
116
|
+
"@deepseek-ai/dsh-scope": "0.2.3-alpha.1",
|
|
117
|
+
"@deepseek-ai/dsh-session": "0.2.3-alpha.1",
|
|
118
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.3-alpha.1",
|
|
119
|
+
"@deepseek-ai/dsh-session-projection": "0.2.3-alpha.1",
|
|
120
|
+
"@deepseek-ai/dsh-session-query": "0.2.3-alpha.1",
|
|
121
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.3-alpha.1",
|
|
122
|
+
"@deepseek-ai/dsh-tool-testkit": "0.2.3-alpha.1",
|
|
123
|
+
"@deepseek-ai/dsh-tools": "0.2.3-alpha.1",
|
|
124
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.3-alpha.1",
|
|
125
|
+
"@deepseek-ai/dsh-user-approval": "0.2.3-alpha.1",
|
|
126
|
+
"@deepseek-ai/dsh-util-time": "0.2.3-alpha.1",
|
|
127
|
+
"@deepseek-ai/dsh-permission-presets": "0.2.3-alpha.1",
|
|
128
|
+
"@deepseek-ai/dsh-workspace": "0.2.3-alpha.1",
|
|
128
129
|
"@deepseek-ai/cordis-plugin-include": "~1.1.0",
|
|
129
130
|
"@deepseek-ai/cordis-plugin-loader": "~1.1.0",
|
|
130
|
-
"@deepseek-ai/dsh-agent-loop": "0.2.
|
|
131
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.
|
|
132
|
-
"@deepseek-ai/dsh-fs-sandbox": "0.2.
|
|
133
|
-
"@deepseek-ai/dsh-tool-fs": "0.2.
|
|
134
|
-
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.
|
|
135
|
-
"@deepseek-ai/dsh-working-directory": "0.2.
|
|
131
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.3-alpha.1",
|
|
132
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.3-alpha.1",
|
|
133
|
+
"@deepseek-ai/dsh-fs-sandbox": "0.2.3-alpha.1",
|
|
134
|
+
"@deepseek-ai/dsh-tool-fs": "0.2.3-alpha.1",
|
|
135
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.3-alpha.1",
|
|
136
|
+
"@deepseek-ai/dsh-working-directory": "0.2.3-alpha.1"
|
|
136
137
|
}
|
|
137
138
|
}
|
package/src/activation.ts
CHANGED
|
@@ -15,6 +15,11 @@ import type { SubagentResult, SubagentRun, SubagentRunId } from './types.ts'
|
|
|
15
15
|
export class ActivationPool {
|
|
16
16
|
private readonly slots = new Set<symbol>()
|
|
17
17
|
|
|
18
|
+
/** Slots reserved by starting, resident, or stopping children. */
|
|
19
|
+
get size(): number {
|
|
20
|
+
return this.slots.size
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
/**
|
|
19
24
|
* Reserve before reconstruction; release also tolerates unpublished rollback.
|
|
20
25
|
* @param capacity - the maximum simultaneous activations in this pool.
|
package/src/child-agent.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { Context } from '@deepseek-ai/cordis'
|
|
|
10
10
|
import type { Agent, AgentOptions, CreateAgentOptions } from '@deepseek-ai/dsh-agent'
|
|
11
11
|
import type { SandboxMode } from '@deepseek-ai/dsh-sandbox'
|
|
12
12
|
import type { Session } from '@deepseek-ai/dsh-session'
|
|
13
|
-
import
|
|
13
|
+
import { PERSONA_PREFIX_SECTION } from '@deepseek-ai/dsh-system-prompt'
|
|
14
14
|
import type { ToolRestriction } from '@deepseek-ai/dsh-tools'
|
|
15
15
|
// Type-only: make `ctx.get('sandboxPolicy')`, `ctx.get('approval')`, and
|
|
16
16
|
// `ctx.get('permissionPresets')` resolve to their services when composed — delegation consumes them
|
|
@@ -28,10 +28,10 @@ import type {} from '@deepseek-ai/dsh-agent-preset-registry'
|
|
|
28
28
|
import { delegationDepthOf } from './depth.ts'
|
|
29
29
|
import { SubagentError } from './error.ts'
|
|
30
30
|
|
|
31
|
-
/** Thrown when starting a child would exceed the requested depth cap
|
|
32
|
-
export class SubagentDepthError extends
|
|
31
|
+
/** Thrown when starting a child would exceed the requested depth cap; `code` is `DEPTH_EXCEEDED`. */
|
|
32
|
+
export class SubagentDepthError extends SubagentError {
|
|
33
33
|
constructor(public readonly attemptedDepth: number, public readonly maxDepth: number) {
|
|
34
|
-
super(`subagent depth ${attemptedDepth} exceeds maxDepth ${maxDepth}
|
|
34
|
+
super(`subagent depth ${attemptedDepth} exceeds maxDepth ${maxDepth}`, 'DEPTH_EXCEEDED')
|
|
35
35
|
this.name = 'SubagentDepthError'
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -44,12 +44,12 @@ export class SubagentDepthError extends Error {
|
|
|
44
44
|
* @param maxDepth - optional absolute cap the resolved depth must not exceed.
|
|
45
45
|
* @returns the child's non-negative safe-integer depth.
|
|
46
46
|
* @throws {SubagentDepthError} when the resolved depth exceeds `maxDepth`.
|
|
47
|
-
* @throws {
|
|
47
|
+
* @throws {SubagentError} `INVALID_DEPTH` when the resolved depth leaves the safe-integer range.
|
|
48
48
|
*/
|
|
49
49
|
export function resolveChildDepth(parent: Agent, maxDepth: number | undefined): number {
|
|
50
50
|
const childDepth = delegationDepthOf(parent) + 1
|
|
51
51
|
if (!Number.isSafeInteger(childDepth)) {
|
|
52
|
-
throw new
|
|
52
|
+
throw new SubagentError('subagent child depth exceeds the safe-integer range', 'INVALID_DEPTH')
|
|
53
53
|
}
|
|
54
54
|
if (maxDepth !== undefined && childDepth > maxDepth) {
|
|
55
55
|
throw new SubagentDepthError(childDepth, maxDepth)
|
|
@@ -164,7 +164,7 @@ export interface ChildComposition {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
* Model-facing delegation-scope statement for every in-process child. A
|
|
167
|
+
* Model-facing delegation-scope and message-authorship statement for every in-process child. A
|
|
168
168
|
* runtime-context contribution rather than a system-prompt section, so the
|
|
169
169
|
* deployment's system prompt stays uniform across parents and children.
|
|
170
170
|
*/
|
|
@@ -172,7 +172,9 @@ export const SUBAGENT_DELEGATION_CONTEXT
|
|
|
172
172
|
= 'You are a delegated subagent: your permission scope was fixed when you were started and cannot be '
|
|
173
173
|
+ 'widened from inside this session — operations that require approval are rejected automatically. '
|
|
174
174
|
+ 'When the task needs access beyond that scope, do not retry the denied operation; state the '
|
|
175
|
-
+ 'limitation in your reply so the delegating agent can handle it.'
|
|
175
|
+
+ 'limitation in your reply so the delegating agent can handle it. Messages from other agents begin with '
|
|
176
|
+
+ '"Agent <name> sent a message:". Other user messages come from the human user, who reads this conversation '
|
|
177
|
+
+ 'directly. You can still message other agents to coordinate, but answer the human user in your reply.'
|
|
176
178
|
|
|
177
179
|
/**
|
|
178
180
|
* Compose a child before publication and restore historical descriptor overrides.
|
|
@@ -183,6 +185,9 @@ export const SUBAGENT_DELEGATION_CONTEXT
|
|
|
183
185
|
* @param parent - creator for fresh delegation; absent during target-only restoration.
|
|
184
186
|
* @param composition - independent preset and any overrides read from a historical descriptor.
|
|
185
187
|
* @returns A promise when mounting an independent preset; otherwise completes synchronously.
|
|
188
|
+
* @throws {SubagentError} `PRESET_UNAVAILABLE` when a preset is selected but the preset
|
|
189
|
+
* service is absent. An unknown or unloadable selected preset rejects with the registry's
|
|
190
|
+
* `RemoteError` code.
|
|
186
191
|
*/
|
|
187
192
|
export function applyChildComposition(
|
|
188
193
|
childCtx: Context,
|
|
@@ -210,7 +215,7 @@ function applyChildOverrides(childCtx: Context, composition: ChildComposition):
|
|
|
210
215
|
})
|
|
211
216
|
if (composition.persona !== undefined) {
|
|
212
217
|
childCtx.systemPrompt.section({
|
|
213
|
-
name:
|
|
218
|
+
name: PERSONA_PREFIX_SECTION,
|
|
214
219
|
order: childCtx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX'),
|
|
215
220
|
text: composition.persona,
|
|
216
221
|
})
|
package/src/control-types.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { PromptContentPart } from '@deepseek-ai/dsh-attachment/types'
|
|
9
9
|
import type { Branded } from '@deepseek-ai/dsh-brand'
|
|
10
|
-
import type { MessageId } from '@deepseek-ai/dsh-llm/
|
|
10
|
+
import type { MessageId } from '@deepseek-ai/dsh-llm/types'
|
|
11
11
|
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
12
12
|
import type { KnownSubagentCatalogFields } from './projection-types.ts'
|
|
13
13
|
// Type-only: the Workspace registry's archive-admission family map this runtime merges `subagent` into.
|
package/src/depth.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Agent } from '@deepseek-ai/dsh-agent'
|
|
10
|
+
import { SubagentError } from './error.ts'
|
|
10
11
|
|
|
11
12
|
declare module '@deepseek-ai/dsh-agent' {
|
|
12
13
|
interface AgentOptions {
|
|
@@ -23,12 +24,12 @@ declare module '@deepseek-ai/dsh-agent' {
|
|
|
23
24
|
* let it delegate as if it were top-level.
|
|
24
25
|
* @param agent - the agent whose header and options carry the depth.
|
|
25
26
|
* @returns its non-negative safe-integer depth.
|
|
26
|
-
* @throws if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
|
|
27
|
+
* @throws {SubagentError} `INVALID_DEPTH` if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
|
|
27
28
|
*/
|
|
28
29
|
export function delegationDepthOf(agent: Agent): number {
|
|
29
30
|
const runtime = agent.options.subagentDepth
|
|
30
31
|
if (runtime !== undefined && (!Number.isSafeInteger(runtime) || runtime < 0 || Object.is(runtime, -0))) {
|
|
31
|
-
throw new
|
|
32
|
+
throw new SubagentError('agent subagentDepth must be a non-negative safe integer', 'INVALID_DEPTH')
|
|
32
33
|
}
|
|
33
34
|
// The header value was validated at the session boundary (creation and
|
|
34
35
|
// persistence load both construct through the store).
|
package/src/error.ts
CHANGED
|
@@ -6,10 +6,94 @@
|
|
|
6
6
|
|
|
7
7
|
import { HarnessError } from '@deepseek-ai/dsh-llm'
|
|
8
8
|
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Every machine-routable subagent failure. Each code names one condition;
|
|
11
|
+
* reuse one only when the consumer action is the same.
|
|
12
|
+
*/
|
|
13
|
+
export type SubagentErrorCode =
|
|
14
|
+
/** A provider registration or a request needs a capability the selected backend lacks. */
|
|
15
|
+
| 'UNSUPPORTED_CAPABILITY'
|
|
16
|
+
/** A provider with the same name is already registered. */
|
|
17
|
+
| 'DUPLICATE_PROVIDER'
|
|
18
|
+
/** No subagent provider is registered under the requested name. */
|
|
19
|
+
| 'NO_PROVIDER'
|
|
20
|
+
/** The provider was removed or replaced while a delegation was starting; retry against the current registration. */
|
|
21
|
+
| 'PROVIDER_CHANGED'
|
|
22
|
+
/** A child preset was selected but the agent-presets service is absent. */
|
|
23
|
+
| 'PRESET_UNAVAILABLE'
|
|
24
|
+
/** The tool instance exposes no agent preset choice. */
|
|
25
|
+
| 'PRESET_SELECTION_DISABLED'
|
|
26
|
+
/** The selected agent preset is outside the tool's allowlist. */
|
|
27
|
+
| 'PRESET_NOT_ALLOWED'
|
|
28
|
+
/** The tool instance does not accept child model selection. */
|
|
29
|
+
| 'MODEL_SELECTION_DISABLED'
|
|
30
|
+
/** The enabled Host model-selection setting has invalid routes; correct the setting before retrying. */
|
|
31
|
+
| 'INVALID_MODEL_SELECTION_SETTINGS'
|
|
32
|
+
/** The current Host model-selection setting does not authorize the requested child provider or route. */
|
|
33
|
+
| 'MODEL_ROUTE_NOT_ALLOWED'
|
|
34
|
+
/** The requested LLM provider is not registered with the LLM runtime. */
|
|
35
|
+
| 'LLM_PROVIDER_NOT_FOUND'
|
|
36
|
+
/** The child's target model cannot accept image input. */
|
|
37
|
+
| 'MODEL_DOES_NOT_SUPPORT_IMAGES'
|
|
38
|
+
/** Starting the child would exceed the requested delegation depth; thrown as `SubagentDepthError`. */
|
|
39
|
+
| 'DEPTH_EXCEEDED'
|
|
40
|
+
/** A runtime delegation depth is not a non-negative safe integer. */
|
|
41
|
+
| 'INVALID_DEPTH'
|
|
42
|
+
/** An out-of-process child's working directory is relative or not enterable. */
|
|
43
|
+
| 'INVALID_CWD'
|
|
44
|
+
/** A local child cannot start because the working-directory service is absent. */
|
|
45
|
+
| 'WORKING_DIRECTORY_UNAVAILABLE'
|
|
46
|
+
/** The caller is not the exact live agent, or does not own the target in its subagent tree. */
|
|
47
|
+
| 'UNAUTHORIZED'
|
|
48
|
+
/** The tree's activation capacity is exhausted. */
|
|
49
|
+
| 'ACTIVATION_LIMIT_REACHED'
|
|
50
|
+
/** The target activation is closing. */
|
|
51
|
+
| 'ACTIVATION_CLOSING'
|
|
52
|
+
/** Releasing an activation's resources failed. */
|
|
53
|
+
| 'ACTIVATION_TEARDOWN_FAILED'
|
|
54
|
+
/** A child with the same Session id already exists. */
|
|
55
|
+
| 'DUPLICATE_CHILD'
|
|
56
|
+
/** The subagent tree is draining and admits no new work. */
|
|
57
|
+
| 'DRAINING'
|
|
58
|
+
/** The child accepts no more input after its structured result. */
|
|
59
|
+
| 'INPUT_CLOSED'
|
|
60
|
+
/** `structured_output` was called while accepted input is still pending. */
|
|
61
|
+
| 'STRUCTURED_OUTPUT_PENDING_INPUT'
|
|
62
|
+
/** The operation was cancelled by its caller. */
|
|
63
|
+
| 'CANCELLED'
|
|
64
|
+
/** A cold child cannot be restored from its persisted state. */
|
|
65
|
+
| 'NOT_RESUMABLE'
|
|
66
|
+
/** The child was not started as continuable and accepts no follow-up. */
|
|
67
|
+
| 'NOT_CONTINUABLE'
|
|
68
|
+
/** Continuation needs the agent runtime or a live tree root that is absent. */
|
|
69
|
+
| 'CONTINUATION_UNAVAILABLE'
|
|
70
|
+
/** Continuation needs Session persistence that is absent or failed. */
|
|
71
|
+
| 'PERSISTENCE_UNAVAILABLE'
|
|
72
|
+
/** A requested agent name does not satisfy the naming rule. */
|
|
73
|
+
| 'INVALID_AGENT_NAME'
|
|
74
|
+
/** A requested agent name is already used by a sibling. */
|
|
75
|
+
| 'DUPLICATE_AGENT_NAME'
|
|
76
|
+
/** An agent path names no member of the tree. */
|
|
77
|
+
| 'AGENT_NAME_NOT_FOUND'
|
|
78
|
+
/** Listing children needs the session-query service. */
|
|
79
|
+
| 'SUBAGENT_CONTROL_QUERY_UNAVAILABLE'
|
|
80
|
+
/** Listing children needs the session-projection service. */
|
|
81
|
+
| 'SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE'
|
|
82
|
+
/** Listing children needs the Session store. */
|
|
83
|
+
| 'SUBAGENT_CONTROL_SESSION_STORE_UNAVAILABLE'
|
|
84
|
+
|
|
85
|
+
/** Typed failure for the subagent seam; `code` is one {@link SubagentErrorCode}. */
|
|
10
86
|
export class SubagentError extends HarnessError {
|
|
11
|
-
|
|
87
|
+
override readonly code: SubagentErrorCode
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param message - reason and next step for the caller.
|
|
91
|
+
* @param code - failure class.
|
|
92
|
+
* @param options - standard `cause` chaining.
|
|
93
|
+
*/
|
|
94
|
+
constructor(message: string, code: SubagentErrorCode, options?: ErrorOptions) {
|
|
12
95
|
super(message, code, options)
|
|
13
96
|
this.name = 'SubagentError'
|
|
97
|
+
this.code = code
|
|
14
98
|
}
|
|
15
99
|
}
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ import type {
|
|
|
53
53
|
} from './control-types.ts'
|
|
54
54
|
import type {
|
|
55
55
|
SubagentCapabilities,
|
|
56
|
+
SubagentCapacity,
|
|
56
57
|
SubagentActivation,
|
|
57
58
|
SubagentActivationSpec,
|
|
58
59
|
SubagentInterruptAuthority,
|
|
@@ -84,6 +85,7 @@ export type {
|
|
|
84
85
|
ContinuableCreateRequest,
|
|
85
86
|
ContinuableCreateSpec,
|
|
86
87
|
SubagentCapabilities,
|
|
88
|
+
SubagentCapacity,
|
|
87
89
|
SubagentActivation,
|
|
88
90
|
SubagentActivationSpec,
|
|
89
91
|
SubagentInterruptAuthority,
|
|
@@ -109,7 +111,7 @@ export type {
|
|
|
109
111
|
SubagentDescriptorData,
|
|
110
112
|
} from './descriptor.ts'
|
|
111
113
|
export { STRUCTURED_OUTPUT_TOOL } from './structured.ts'
|
|
112
|
-
export { SubagentError } from './error.ts'
|
|
114
|
+
export { SubagentError, type SubagentErrorCode } from './error.ts'
|
|
113
115
|
export { assertSubagentMaxDepth, delegationDepthOf } from './depth.ts'
|
|
114
116
|
export {
|
|
115
117
|
appendDelegatedPolicyOverrides,
|
|
@@ -222,7 +224,7 @@ export class SubagentRuntime extends TypertRemoteService {
|
|
|
222
224
|
identityOf: session => identityProjection.stateOf(session).identity,
|
|
223
225
|
catalogOf: session => subagentCatalogProjectionDefinition.wire.view(catalogProjection.stateOf(session)),
|
|
224
226
|
emitLifecycle: this.emitLifecycle,
|
|
225
|
-
}, () => this.
|
|
227
|
+
}, () => this.maxActiveSubagents)
|
|
226
228
|
this.manager = manager
|
|
227
229
|
childCtx.effect(() => () => {
|
|
228
230
|
/* v8 ignore else -- one injected binding owns the slot until its fiber disposes. */
|
|
@@ -231,6 +233,11 @@ export class SubagentRuntime extends TypertRemoteService {
|
|
|
231
233
|
})
|
|
232
234
|
}
|
|
233
235
|
|
|
236
|
+
/** Current concurrency limit shared by all descendants in each subagent tree. */
|
|
237
|
+
get maxActiveSubagents(): number {
|
|
238
|
+
return this.config.maxActiveSubagents.get()
|
|
239
|
+
}
|
|
240
|
+
|
|
234
241
|
/**
|
|
235
242
|
* Resolve a delegation tool's depth policy against the current user setting.
|
|
236
243
|
* @param configured - Explicit tool limit, or provider-managed for external delegation.
|
|
@@ -301,6 +308,15 @@ export class SubagentRuntime extends TypertRemoteService {
|
|
|
301
308
|
return this.requireManager().rootOf(caller)
|
|
302
309
|
}
|
|
303
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Observe the shared concurrency capacity of the caller's subagent tree.
|
|
313
|
+
* @param caller - exact live root or resident tree member.
|
|
314
|
+
* @returns occupied slots and the current limit; this observation reserves no capacity.
|
|
315
|
+
*/
|
|
316
|
+
capacityOf(caller: Agent): SubagentCapacity {
|
|
317
|
+
return this.requireManager().capacityOf(caller)
|
|
318
|
+
}
|
|
319
|
+
|
|
304
320
|
/**
|
|
305
321
|
* Report the model-facing names of a live tree member and its direct creator.
|
|
306
322
|
* The root is `lead`; a descendant is the slash-separated path of names from
|
package/src/manager.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type {} from '@deepseek-ai/dsh-working-directory'
|
|
|
12
12
|
import { FiberState, type Context } from '@deepseek-ai/cordis'
|
|
13
13
|
import type { Agent, AgentOptions, CreateAgentOptions } from '@deepseek-ai/dsh-agent'
|
|
14
14
|
import { brandString } from '@deepseek-ai/dsh-brand'
|
|
15
|
-
import { ReasoningEffortId, contentHasImage, createUserMessage, errorChain } from '@deepseek-ai/dsh-llm'
|
|
15
|
+
import { type ReasoningEffortId, contentHasImage, createUserMessage, errorChain } from '@deepseek-ai/dsh-llm'
|
|
16
16
|
import type { ContentBlock, MessageId, MessageSource } from '@deepseek-ai/dsh-llm'
|
|
17
17
|
import { SessionLogOffset } from '@deepseek-ai/dsh-session'
|
|
18
18
|
import type { Session, SessionId, SessionEvent, UserMessage } from '@deepseek-ai/dsh-session'
|
|
@@ -36,9 +36,9 @@ import type { LifecycleEmitter } from './lifecycle.ts'
|
|
|
36
36
|
import { ROOT_AGENT_NAME, SiblingNameReservations, agentAddress, joinAgentPath, parentAgentPath } from './names.ts'
|
|
37
37
|
import type { SiblingNameReservation } from './names.ts'
|
|
38
38
|
import type { SubagentCatalogEntry, SubagentIdentityProjection } from './projection-types.ts'
|
|
39
|
-
import { SubagentRunId } from './types.ts'
|
|
39
|
+
import type { SubagentRunId } from './types.ts'
|
|
40
40
|
import type {
|
|
41
|
-
ContinuableCreateRequest, ContinuableCreateSpec, SubagentInterruptAuthority,
|
|
41
|
+
ContinuableCreateRequest, ContinuableCreateSpec, SubagentInterruptAuthority, SubagentCapacity,
|
|
42
42
|
SubagentActivationSpec, SubagentActivation, SubagentMemberNames, SubagentStartRequest, SubagentRun,
|
|
43
43
|
SubagentSendMessageOptions, SubagentResult, SubagentRunInfo, ResolvedSubagentStartRequest,
|
|
44
44
|
} from './types.ts'
|
|
@@ -403,12 +403,13 @@ export class SubagentManager {
|
|
|
403
403
|
established = activation
|
|
404
404
|
const child = requireLocalActivation(activation).handle.agent
|
|
405
405
|
const childHeader = child.session.header
|
|
406
|
+
const task = createAgentMessage(parent, agentAddress(this.pathOf(parent, ancestry.root), parent.id), spec.prompt)
|
|
406
407
|
return await this.submitMaterialized(
|
|
407
408
|
activation,
|
|
408
409
|
spec.delivery !== 'caller'
|
|
409
|
-
? withResultDeliveryGuidance(
|
|
410
|
-
:
|
|
411
|
-
{ source:
|
|
410
|
+
? withResultDeliveryGuidance([...task.content])
|
|
411
|
+
: [...task.content],
|
|
412
|
+
{ source: task.source, signal, delivery: 'queue', authorize: () => { this.assertAdmitting(parent) } },
|
|
412
413
|
ancestry.root,
|
|
413
414
|
() => {
|
|
414
415
|
this.assertAdmitting(parent)
|
|
@@ -787,6 +788,18 @@ export class SubagentManager {
|
|
|
787
788
|
return this.closingRoots.has(root) ? root : undefined
|
|
788
789
|
}
|
|
789
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Observe the shared capacity of a live tree member.
|
|
793
|
+
* @param caller - exact live root or resident child selecting the tree.
|
|
794
|
+
* @returns occupied slots and the current configured limit, without reserving capacity.
|
|
795
|
+
*/
|
|
796
|
+
capacityOf(caller: Agent): SubagentCapacity {
|
|
797
|
+
return {
|
|
798
|
+
running: this.rootPools.get(this.rootOf(caller))?.size ?? 0,
|
|
799
|
+
limit: this.maxActiveSubagents(),
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
790
803
|
/** Share one capacity pool across every instance in a subagent tree. */
|
|
791
804
|
private rootPool(parent: Agent): ActivationPool {
|
|
792
805
|
let pool = this.rootPools.get(parent)
|
|
@@ -836,7 +849,9 @@ export class SubagentManager {
|
|
|
836
849
|
child.session.append('subagent/descriptor', create.descriptor)
|
|
837
850
|
appendDelegatedPolicyOverrides(child.session, create.delegatedPolicies)
|
|
838
851
|
const workingDirectory = childCtx.get('workingDirectory')
|
|
839
|
-
if (workingDirectory === undefined)
|
|
852
|
+
if (workingDirectory === undefined) {
|
|
853
|
+
throw new SubagentError('local subagents require the working-directory service', 'WORKING_DIRECTORY_UNAVAILABLE')
|
|
854
|
+
}
|
|
840
855
|
await workingDirectory.set(child, create.cwd, inputs.signal)
|
|
841
856
|
}
|
|
842
857
|
if (inputs.composition.agentPreset === undefined) await applyChildComposition(childCtx, create?.parent, inputs.composition)
|
|
@@ -857,7 +872,9 @@ export class SubagentManager {
|
|
|
857
872
|
: await this.ownerCtx.agents.create({
|
|
858
873
|
sessionId: childId,
|
|
859
874
|
meta: create.meta,
|
|
860
|
-
...(create.seed === undefined ? {} : {
|
|
875
|
+
...(create.seed === undefined ? {} : {
|
|
876
|
+
seed: create.seed, parentSource: { sessionId: create.parent.id, endSeq: SessionLogOffset(create.seed.length) },
|
|
877
|
+
}),
|
|
861
878
|
inheritedEventCount: create.inheritedEventCount,
|
|
862
879
|
agentOptions: inputs.agentOptions,
|
|
863
880
|
signal: inputs.signal,
|
|
@@ -878,7 +895,7 @@ export class SubagentManager {
|
|
|
878
895
|
const activation: Activation = {
|
|
879
896
|
releaseSlot,
|
|
880
897
|
childId,
|
|
881
|
-
runId: SubagentRunId(randomUUID()),
|
|
898
|
+
runId: brandString<SubagentRunId>(randomUUID()),
|
|
882
899
|
provider,
|
|
883
900
|
...resource,
|
|
884
901
|
root,
|
|
@@ -1216,7 +1233,16 @@ export class SubagentManager {
|
|
|
1216
1233
|
using source = await this.observeContinuation(childId, signal)
|
|
1217
1234
|
this.assertAdmitting(root)
|
|
1218
1235
|
const ownEvents = source.events.slice(source.inheritedEventCount)
|
|
1219
|
-
|
|
1236
|
+
let descriptor: ReturnType<typeof foldSubagentDescriptor>
|
|
1237
|
+
try {
|
|
1238
|
+
descriptor = foldSubagentDescriptor(ownEvents)
|
|
1239
|
+
} catch (error: unknown) {
|
|
1240
|
+
throw new SubagentError(
|
|
1241
|
+
`subagent "${childId}" has a corrupt continuation descriptor and cannot be resumed; choose a different target`,
|
|
1242
|
+
'NOT_RESUMABLE',
|
|
1243
|
+
{ cause: error },
|
|
1244
|
+
)
|
|
1245
|
+
}
|
|
1220
1246
|
if (descriptor === undefined || descriptor.mode !== 'continuable') {
|
|
1221
1247
|
throw new SubagentError(
|
|
1222
1248
|
`subagent "${childId}" has no supported continuation state and cannot be resumed; choose a different target`,
|
|
@@ -1242,7 +1268,7 @@ export class SubagentManager {
|
|
|
1242
1268
|
...descriptor.agentProvider !== undefined ? { provider: descriptor.agentProvider } : {},
|
|
1243
1269
|
...descriptor.agentModel !== undefined ? { model: descriptor.agentModel } : {},
|
|
1244
1270
|
...descriptor.agentReasoningEffort !== undefined
|
|
1245
|
-
? { reasoningEffort: ReasoningEffortId(descriptor.agentReasoningEffort) }
|
|
1271
|
+
? { reasoningEffort: brandString<ReasoningEffortId>(descriptor.agentReasoningEffort) }
|
|
1246
1272
|
: {},
|
|
1247
1273
|
},
|
|
1248
1274
|
composition: {
|