@deepseek-ai/dsh-subagent 0.0.1-rc.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.
Files changed (41) hide show
  1. package/LICENSE +28 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +132 -0
  4. package/README.zh.md +132 -0
  5. package/lib/index.js +2392 -0
  6. package/lib/invariant.js +76 -0
  7. package/lib/types/activation-setup-registry.d.ts +57 -0
  8. package/lib/types/activation-setup-registry.js +148 -0
  9. package/lib/types/child-agent.d.ts +139 -0
  10. package/lib/types/child-agent.js +169 -0
  11. package/lib/types/client.d.ts +7 -0
  12. package/lib/types/client.js +7 -0
  13. package/lib/types/continuation.d.ts +375 -0
  14. package/lib/types/continuation.js +951 -0
  15. package/lib/types/depth.d.ts +31 -0
  16. package/lib/types/depth.js +39 -0
  17. package/lib/types/descriptor-seed.d.ts +21 -0
  18. package/lib/types/descriptor-seed.js +24 -0
  19. package/lib/types/descriptor.d.ts +139 -0
  20. package/lib/types/descriptor.js +189 -0
  21. package/lib/types/error.d.ts +11 -0
  22. package/lib/types/error.js +14 -0
  23. package/lib/types/index.d.ts +278 -0
  24. package/lib/types/index.js +338 -0
  25. package/lib/types/invariant.d.ts +13 -0
  26. package/lib/types/invariant.js +91 -0
  27. package/lib/types/lifecycle.d.ts +93 -0
  28. package/lib/types/lifecycle.js +169 -0
  29. package/lib/types/list-children.d.ts +112 -0
  30. package/lib/types/list-children.js +316 -0
  31. package/lib/types/out-of-process.d.ts +115 -0
  32. package/lib/types/out-of-process.js +181 -0
  33. package/lib/types/projection-types.d.ts +60 -0
  34. package/lib/types/projection-types.js +7 -0
  35. package/lib/types/projection.d.ts +48 -0
  36. package/lib/types/projection.js +135 -0
  37. package/lib/types/run-settlement.d.ts +17 -0
  38. package/lib/types/run-settlement.js +59 -0
  39. package/lib/types/types.d.ts +293 -0
  40. package/lib/types/types.js +19 -0
  41. package/package.json +106 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Delegation-depth accounting: the recursion budget a parent passes to its
3
+ * children. Kept apart from the service so composition helpers can read it
4
+ * without importing the registry.
5
+ *
6
+ * @module @deepseek-ai/dsh-subagent/depth
7
+ */
8
+ import type { Agent } from '@deepseek-ai/dsh-agent';
9
+ declare module '@deepseek-ai/dsh-agent' {
10
+ interface AgentOptions {
11
+ /** Delegation depth: zero for a top-level agent and parent depth + 1 for a child. */
12
+ subagentDepth?: number;
13
+ }
14
+ }
15
+ /**
16
+ * Read an agent's delegation depth, treating absence as top-level depth zero.
17
+ * The persisted session header is authoritative and monotone: runtime
18
+ * `AgentOptions.subagentDepth` may DEEPEN the count but can never lower it —
19
+ * a resumed child arrives with fresh options, and counting it from zero would
20
+ * let it delegate as if it were top-level.
21
+ * @param agent - the agent whose header and options carry the depth.
22
+ * @returns its non-negative safe-integer depth.
23
+ * @throws if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
24
+ */
25
+ export declare function delegationDepthOf(agent: Agent): number;
26
+ /**
27
+ * Reject a recursion cap that cannot represent an exact delegation depth.
28
+ * @param maxDepth - the optional runtime value to validate.
29
+ */
30
+ export declare function assertSubagentMaxDepth(maxDepth: unknown): void;
31
+ //# sourceMappingURL=depth.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Delegation-depth accounting: the recursion budget a parent passes to its
3
+ * children. Kept apart from the service so composition helpers can read it
4
+ * without importing the registry.
5
+ *
6
+ * @module @deepseek-ai/dsh-subagent/depth
7
+ */
8
+ /**
9
+ * Read an agent's delegation depth, treating absence as top-level depth zero.
10
+ * The persisted session header is authoritative and monotone: runtime
11
+ * `AgentOptions.subagentDepth` may DEEPEN the count but can never lower it —
12
+ * a resumed child arrives with fresh options, and counting it from zero would
13
+ * let it delegate as if it were top-level.
14
+ * @param agent - the agent whose header and options carry the depth.
15
+ * @returns its non-negative safe-integer depth.
16
+ * @throws if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
17
+ */
18
+ export function delegationDepthOf(agent) {
19
+ const runtime = agent.options.subagentDepth;
20
+ if (runtime !== undefined && (!Number.isSafeInteger(runtime) || runtime < 0 || Object.is(runtime, -0))) {
21
+ throw new TypeError('agent subagentDepth must be a non-negative safe integer');
22
+ }
23
+ // The header value was validated at the session boundary (creation and
24
+ // persistence load both construct through the store).
25
+ return Math.max(agent.session.header.delegationDepth ?? 0, runtime ?? 0);
26
+ }
27
+ /**
28
+ * Reject a recursion cap that cannot represent an exact delegation depth.
29
+ * @param maxDepth - the optional runtime value to validate.
30
+ */
31
+ export function assertSubagentMaxDepth(maxDepth) {
32
+ if (maxDepth !== undefined && (typeof maxDepth !== 'number'
33
+ || !Number.isSafeInteger(maxDepth)
34
+ || maxDepth < 0
35
+ || Object.is(maxDepth, -0))) {
36
+ throw new TypeError('subagent maxDepth must be a non-negative safe integer');
37
+ }
38
+ }
39
+ //# sourceMappingURL=depth.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Seeding of a continuable child's durable descriptor event: the model-hidden
3
+ * record of the child's declared composition before its first request, so a
4
+ * later cold resume can reconstruct it from its own log.
5
+ *
6
+ * @module @deepseek-ai/dsh-subagent/descriptor-seed
7
+ */
8
+ import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session';
9
+ import type { SubagentDescriptorData } from './descriptor.ts';
10
+ /**
11
+ * Build the child's creation seed: any inherited parent-history prefix followed
12
+ * by one model-hidden, between-turn `descriptor` event. Staging through a
13
+ * `Session` assigns the sequence number and enforces the same lossless-JSON
14
+ * rules the durable log does.
15
+ * @param childId - the reserved child session id the staged log belongs to.
16
+ * @param seed - the inherited completed-turn prefix, or `undefined` for a fresh child.
17
+ * @param descriptor - the snapshotted composition record to persist.
18
+ * @returns the complete seed events, contiguous from sequence zero.
19
+ */
20
+ export declare function seedDescriptorTurn(childId: SessionId, seed: readonly SessionEvent[] | undefined, descriptor: SubagentDescriptorData): SessionEvent[];
21
+ //# sourceMappingURL=descriptor-seed.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Seeding of a continuable child's durable descriptor event: the model-hidden
3
+ * record of the child's declared composition before its first request, so a
4
+ * later cold resume can reconstruct it from its own log.
5
+ *
6
+ * @module @deepseek-ai/dsh-subagent/descriptor-seed
7
+ */
8
+ import { Session } from '@deepseek-ai/dsh-session';
9
+ /**
10
+ * Build the child's creation seed: any inherited parent-history prefix followed
11
+ * by one model-hidden, between-turn `descriptor` event. Staging through a
12
+ * `Session` assigns the sequence number and enforces the same lossless-JSON
13
+ * rules the durable log does.
14
+ * @param childId - the reserved child session id the staged log belongs to.
15
+ * @param seed - the inherited completed-turn prefix, or `undefined` for a fresh child.
16
+ * @param descriptor - the snapshotted composition record to persist.
17
+ * @returns the complete seed events, contiguous from sequence zero.
18
+ */
19
+ export function seedDescriptorTurn(childId, seed, descriptor) {
20
+ const staged = Session.create(childId, seed);
21
+ staged.append('subagent/descriptor', descriptor);
22
+ return [...staged.events];
23
+ }
24
+ //# sourceMappingURL=descriptor-seed.js.map
@@ -0,0 +1,139 @@
1
+ /**
2
+ * The durable subagent-child descriptor: the versioned, model-hidden
3
+ * `subagent/descriptor` session event that identifies every session-backed
4
+ * subagent and records whether it is one-shot or continuable. Continuable
5
+ * descriptors additionally preserve the declared composition required for
6
+ * cold resume. Providers append it turn-enclosed in the child's initial turn.
7
+ *
8
+ * The descriptor deliberately snapshots explicit fields rather than the
9
+ * merge-extensible `AgentOptions` object: an unrelated extension value cannot
10
+ * make continuation fail merely because it is not JSON, and later composition
11
+ * inputs require a deliberate {@link SUBAGENT_DESCRIPTOR_VERSION} change. It
12
+ * omits `subagentDepth` — cold resume trusts the persisted header's
13
+ * `delegationDepth` as the monotone floor — and `outputSchema`, which belongs
14
+ * to one activation's result contract rather than durable child composition.
15
+ * Per-activation knobs such as `maxTokens` are omitted for the same reason as
16
+ * `outputSchema`: they budget one activation. Cold resume requires the exact
17
+ * live parent for authorization but reconstructs child options only from the
18
+ * durable descriptor, so it neither restores the prior budget nor inherits
19
+ * the parent's current one; the resumed route's defaults apply instead.
20
+ *
21
+ * @module @deepseek-ai/dsh-subagent/descriptor
22
+ */
23
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
24
+ import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
25
+ declare module '@deepseek-ai/dsh-session/types' {
26
+ interface SessionEventMap {
27
+ /**
28
+ * Durable identity and lifecycle mode of a session-backed subagent child,
29
+ * appended once by the establishing provider inside the child's initial
30
+ * turn, before its first request. Continuable records also carry their
31
+ * resumable composition. Log-only: it carries no `surfaceOp`, never enters
32
+ * model history, and survives compaction.
33
+ */
34
+ 'subagent/descriptor': SubagentDescriptorData;
35
+ }
36
+ }
37
+ /**
38
+ * The current descriptor format version, stamped into every appended
39
+ * `subagent/descriptor` event and required verbatim by {@link foldSubagentDescriptor}.
40
+ * Supporting another composition input is a deliberate version change, never
41
+ * an implicit extra field.
42
+ */
43
+ export declare const SUBAGENT_DESCRIPTOR_VERSION = 2;
44
+ /** Fields shared by every supported `subagent/descriptor` payload. */
45
+ interface SubagentDescriptorBase {
46
+ /** Descriptor format version ({@link SUBAGENT_DESCRIPTOR_VERSION}). */
47
+ readonly version: number;
48
+ /** Whether the child is a terminal one-shot run or a resumable conversation. */
49
+ readonly mode: 'one-shot' | 'continuable';
50
+ /** The `ctx.subagents` provider name that established the child. */
51
+ readonly provider: string;
52
+ }
53
+ /** A session-backed subagent that cannot be cold-resumed after its run. */
54
+ export interface OneShotSubagentDescriptorData extends SubagentDescriptorBase {
55
+ readonly mode: 'one-shot';
56
+ /**
57
+ * The initial delegation's short `description`, kept as the child's durable
58
+ * creation label so enumeration can identify the conversation without
59
+ * replaying parent tool results or exposing the child prompt.
60
+ */
61
+ readonly label?: string;
62
+ }
63
+ /** A session-backed subagent whose declared composition supports cold resume. */
64
+ export interface ContinuableSubagentDescriptorData extends SubagentDescriptorBase {
65
+ readonly mode: 'continuable';
66
+ /** The initial delegation's short `description`, used for durable enumeration. */
67
+ readonly label: string;
68
+ /** Resolved child `agentOptions.provider`, when one was declared. */
69
+ readonly agentProvider?: string;
70
+ /** Resolved child `agentOptions.model`, when one was declared. */
71
+ readonly agentModel?: string;
72
+ /** Per-child persona that shadows the deployment persona on resume. */
73
+ readonly persona?: string;
74
+ /** Child tool scoping reapplied on resume. */
75
+ readonly toolFilter?: ToolRestriction;
76
+ }
77
+ /** The supported durable subagent identity and optional continuation composition. */
78
+ export type SubagentDescriptorData = OneShotSubagentDescriptorData | ContinuableSubagentDescriptorData;
79
+ /** Fields shared by descriptor snapshot inputs. */
80
+ interface SubagentDescriptorInputBase {
81
+ /** Whether the child is a terminal one-shot run or a resumable conversation. */
82
+ readonly mode: 'one-shot' | 'continuable';
83
+ /** The `ctx.subagents` provider name that will establish the child. */
84
+ readonly provider: string;
85
+ }
86
+ /** Input for a one-shot child's durable identity. */
87
+ export interface OneShotSubagentDescriptorInput extends SubagentDescriptorInputBase {
88
+ readonly mode: 'one-shot';
89
+ /** Optional initial delegation `description` used as the durable creation label. */
90
+ readonly label?: string;
91
+ }
92
+ /** Input for a continuable child's durable identity and resumable composition. */
93
+ export interface ContinuableSubagentDescriptorInput extends SubagentDescriptorInputBase {
94
+ readonly mode: 'continuable';
95
+ /** Initial delegation `description` used for durable enumeration. */
96
+ readonly label: string;
97
+ /** Requested child `agentOptions.provider`. */
98
+ readonly agentProvider?: string;
99
+ /** Requested child `agentOptions.model`. */
100
+ readonly agentModel?: string;
101
+ /** Requested per-child persona. */
102
+ readonly persona?: string;
103
+ /** Requested child tool scoping. */
104
+ readonly toolFilter?: ToolRestriction;
105
+ }
106
+ /** Inputs {@link snapshotSubagentDescriptor} validates and detaches. */
107
+ export type SubagentDescriptorInput = OneShotSubagentDescriptorInput | ContinuableSubagentDescriptorInput;
108
+ /**
109
+ * Validate and detach descriptor inputs into the durable payload, before any
110
+ * Task or provider work begins — the same detached lossless-JSON boundary the
111
+ * session log itself enforces, applied early so a synchronous validation
112
+ * failure rejects the tool call without creating a Task.
113
+ * @param input - the caller-collected composition fields.
114
+ * @returns the versioned, detached descriptor payload.
115
+ * @throws when a field is not losslessly JSON-serializable.
116
+ */
117
+ export declare function snapshotSubagentDescriptor(input: OneShotSubagentDescriptorInput): OneShotSubagentDescriptorData;
118
+ /**
119
+ * Validate and detach a continuable descriptor input.
120
+ * @param input - the caller-collected continuable composition fields.
121
+ * @returns the versioned, detached continuable descriptor payload.
122
+ * @throws when a field is not losslessly JSON-serializable.
123
+ */
124
+ export declare function snapshotSubagentDescriptor(input: ContinuableSubagentDescriptorInput): ContinuableSubagentDescriptorData;
125
+ /**
126
+ * Fold a persisted child log to its supported descriptor. The first
127
+ * `subagent/descriptor` event is authoritative — the establishing provider
128
+ * appends exactly one, so a later same-type event cannot rewrite the declared
129
+ * composition.
130
+ * @param events - the loaded child session events.
131
+ * @returns the descriptor, or `undefined` when the log has none or its
132
+ * version is not {@link SUBAGENT_DESCRIPTOR_VERSION} (the child cannot be
133
+ * classified by this runtime).
134
+ * @throws when a current-version persisted payload does not match its complete
135
+ * declared schema.
136
+ */
137
+ export declare function foldSubagentDescriptor(events: readonly SessionEvent[]): SubagentDescriptorData | undefined;
138
+ export {};
139
+ //# sourceMappingURL=descriptor.d.ts.map
@@ -0,0 +1,189 @@
1
+ /**
2
+ * The durable subagent-child descriptor: the versioned, model-hidden
3
+ * `subagent/descriptor` session event that identifies every session-backed
4
+ * subagent and records whether it is one-shot or continuable. Continuable
5
+ * descriptors additionally preserve the declared composition required for
6
+ * cold resume. Providers append it turn-enclosed in the child's initial turn.
7
+ *
8
+ * The descriptor deliberately snapshots explicit fields rather than the
9
+ * merge-extensible `AgentOptions` object: an unrelated extension value cannot
10
+ * make continuation fail merely because it is not JSON, and later composition
11
+ * inputs require a deliberate {@link SUBAGENT_DESCRIPTOR_VERSION} change. It
12
+ * omits `subagentDepth` — cold resume trusts the persisted header's
13
+ * `delegationDepth` as the monotone floor — and `outputSchema`, which belongs
14
+ * to one activation's result contract rather than durable child composition.
15
+ * Per-activation knobs such as `maxTokens` are omitted for the same reason as
16
+ * `outputSchema`: they budget one activation. Cold resume requires the exact
17
+ * live parent for authorization but reconstructs child options only from the
18
+ * durable descriptor, so it neither restores the prior budget nor inherits
19
+ * the parent's current one; the resumed route's defaults apply instead.
20
+ *
21
+ * @module @deepseek-ai/dsh-subagent/descriptor
22
+ */
23
+ import { snapshotJsonValue } from '@deepseek-ai/dsh-session';
24
+ /**
25
+ * The current descriptor format version, stamped into every appended
26
+ * `subagent/descriptor` event and required verbatim by {@link foldSubagentDescriptor}.
27
+ * Supporting another composition input is a deliberate version change, never
28
+ * an implicit extra field.
29
+ */
30
+ export const SUBAGENT_DESCRIPTOR_VERSION = 2;
31
+ const DESCRIPTOR_BASE_KEYS = [
32
+ 'version',
33
+ 'mode',
34
+ 'provider',
35
+ 'label',
36
+ ];
37
+ const ONE_SHOT_DESCRIPTOR_KEYS = new Set(DESCRIPTOR_BASE_KEYS);
38
+ const CONTINUABLE_DESCRIPTOR_KEYS = new Set([
39
+ ...DESCRIPTOR_BASE_KEYS,
40
+ 'agentProvider',
41
+ 'agentModel',
42
+ 'persona',
43
+ 'toolFilter',
44
+ ]);
45
+ const TOOL_FILTER_KEYS = new Set(['allow', 'deny']);
46
+ /** Whether a persisted JSON value is an object record. */
47
+ function isRecord(value) {
48
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
49
+ }
50
+ /** Reject fields outside one versioned record's declared schema. */
51
+ function assertKnownKeys(value, keys, path) {
52
+ const unknown = Object.keys(value).find(key => !keys.has(key));
53
+ if (unknown !== undefined) {
54
+ throw new Error(`persisted subagent descriptor ${path} has unknown field "${unknown}"`);
55
+ }
56
+ }
57
+ /** Read one optional string field from a persisted descriptor record. */
58
+ function optionalString(value, key) {
59
+ if (!Object.hasOwn(value, key))
60
+ return undefined;
61
+ const field = value[key];
62
+ if (typeof field !== 'string') {
63
+ throw new Error(`persisted subagent descriptor ${key} must be a string`);
64
+ }
65
+ return field;
66
+ }
67
+ /** Read one optional string-array field from a persisted tool restriction. */
68
+ function optionalStringArray(value, key) {
69
+ if (!Object.hasOwn(value, key))
70
+ return undefined;
71
+ const field = value[key];
72
+ if (!Array.isArray(field)) {
73
+ throw new Error(`persisted subagent descriptor toolFilter.${key} must be an array of strings`);
74
+ }
75
+ const items = field;
76
+ if (items.some(item => typeof item !== 'string')) {
77
+ throw new Error(`persisted subagent descriptor toolFilter.${key} must be an array of strings`);
78
+ }
79
+ return items;
80
+ }
81
+ /** Validate and reconstruct a persisted tool restriction. */
82
+ function parseToolFilter(value) {
83
+ if (!isRecord(value)) {
84
+ throw new Error('persisted subagent descriptor toolFilter must be an object');
85
+ }
86
+ assertKnownKeys(value, TOOL_FILTER_KEYS, 'toolFilter');
87
+ const allow = optionalStringArray(value, 'allow');
88
+ const deny = optionalStringArray(value, 'deny');
89
+ if (allow === undefined && deny === undefined) {
90
+ throw new Error('persisted subagent descriptor toolFilter must declare allow and/or deny');
91
+ }
92
+ return {
93
+ ...allow !== undefined ? { allow } : {},
94
+ ...deny !== undefined ? { deny } : {},
95
+ };
96
+ }
97
+ /** Validate one persisted descriptor payload for the current runtime. */
98
+ function parseSubagentDescriptor(value) {
99
+ if (!isRecord(value)) {
100
+ throw new Error('persisted subagent descriptor payload must be an object');
101
+ }
102
+ const version = value['version'];
103
+ if (typeof version !== 'number') {
104
+ throw new Error('persisted subagent descriptor version must be a number');
105
+ }
106
+ if (version !== SUBAGENT_DESCRIPTOR_VERSION)
107
+ return undefined;
108
+ const mode = value['mode'];
109
+ if (mode !== 'one-shot' && mode !== 'continuable') {
110
+ throw new Error('persisted subagent descriptor mode must be "one-shot" or "continuable"');
111
+ }
112
+ assertKnownKeys(value, mode === 'one-shot' ? ONE_SHOT_DESCRIPTOR_KEYS : CONTINUABLE_DESCRIPTOR_KEYS, 'payload');
113
+ const provider = value['provider'];
114
+ if (typeof provider !== 'string') {
115
+ throw new Error('persisted subagent descriptor provider must be a string');
116
+ }
117
+ if (mode === 'one-shot') {
118
+ const label = optionalString(value, 'label');
119
+ return {
120
+ version: SUBAGENT_DESCRIPTOR_VERSION,
121
+ mode,
122
+ provider,
123
+ ...label !== undefined ? { label } : {},
124
+ };
125
+ }
126
+ const label = value['label'];
127
+ if (typeof label !== 'string') {
128
+ throw new Error('persisted subagent descriptor label must be a string');
129
+ }
130
+ const agentProvider = optionalString(value, 'agentProvider');
131
+ const agentModel = optionalString(value, 'agentModel');
132
+ const persona = optionalString(value, 'persona');
133
+ const toolFilter = Object.hasOwn(value, 'toolFilter')
134
+ ? parseToolFilter(value['toolFilter'])
135
+ : undefined;
136
+ return {
137
+ version: SUBAGENT_DESCRIPTOR_VERSION,
138
+ mode,
139
+ provider,
140
+ label,
141
+ ...agentProvider !== undefined ? { agentProvider } : {},
142
+ ...agentModel !== undefined ? { agentModel } : {},
143
+ ...persona !== undefined ? { persona } : {},
144
+ ...toolFilter !== undefined ? { toolFilter } : {},
145
+ };
146
+ }
147
+ export function snapshotSubagentDescriptor(input) {
148
+ const candidate = input.mode === 'one-shot'
149
+ ? {
150
+ version: SUBAGENT_DESCRIPTOR_VERSION,
151
+ mode: input.mode,
152
+ provider: input.provider,
153
+ ...input.label !== undefined ? { label: input.label } : {},
154
+ }
155
+ : {
156
+ version: SUBAGENT_DESCRIPTOR_VERSION,
157
+ mode: input.mode,
158
+ provider: input.provider,
159
+ label: input.label,
160
+ ...input.agentProvider !== undefined ? { agentProvider: input.agentProvider } : {},
161
+ ...input.agentModel !== undefined ? { agentModel: input.agentModel } : {},
162
+ ...input.persona !== undefined ? { persona: input.persona } : {},
163
+ ...input.toolFilter !== undefined ? { toolFilter: input.toolFilter } : {},
164
+ };
165
+ const snapshot = snapshotJsonValue(candidate);
166
+ if (snapshot === undefined) {
167
+ throw new Error('subagent descriptor is not losslessly JSON-serializable');
168
+ }
169
+ return snapshot;
170
+ }
171
+ /**
172
+ * Fold a persisted child log to its supported descriptor. The first
173
+ * `subagent/descriptor` event is authoritative — the establishing provider
174
+ * appends exactly one, so a later same-type event cannot rewrite the declared
175
+ * composition.
176
+ * @param events - the loaded child session events.
177
+ * @returns the descriptor, or `undefined` when the log has none or its
178
+ * version is not {@link SUBAGENT_DESCRIPTOR_VERSION} (the child cannot be
179
+ * classified by this runtime).
180
+ * @throws when a current-version persisted payload does not match its complete
181
+ * declared schema.
182
+ */
183
+ export function foldSubagentDescriptor(events) {
184
+ const event = events.find((candidate) => candidate.type === 'subagent/descriptor');
185
+ if (event === undefined)
186
+ return undefined;
187
+ return parseSubagentDescriptor(event.data);
188
+ }
189
+ //# sourceMappingURL=descriptor.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Typed failures shared by subagent service and provider operations.
3
+ *
4
+ * @module @deepseek-ai/dsh-subagent
5
+ */
6
+ import { HarnessError } from '@deepseek-ai/dsh-llm';
7
+ /** Typed failure for the subagent seam. */
8
+ export declare class SubagentError extends HarnessError {
9
+ constructor(message: string, code: string, options?: ErrorOptions);
10
+ }
11
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Typed failures shared by subagent service and provider operations.
3
+ *
4
+ * @module @deepseek-ai/dsh-subagent
5
+ */
6
+ import { HarnessError } from '@deepseek-ai/dsh-llm';
7
+ /** Typed failure for the subagent seam. */
8
+ export class SubagentError extends HarnessError {
9
+ constructor(message, code, options) {
10
+ super(message, code, options);
11
+ this.name = 'SubagentError';
12
+ }
13
+ }
14
+ //# sourceMappingURL=error.js.map