@morlay/dsh-subagent 0.0.9 → 0.0.11-alpha.0
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/dist/index.d.mts +86 -129
- package/dist/index.mjs +43 -49
- package/dist/rows.d.mts +1 -3
- package/dist/rows.mjs +1 -2
- package/package.json +28 -28
- package/src/continuation-messages.ts +73 -59
- package/src/index.ts +263 -189
- package/src/manager.ts +900 -716
- package/src/vendor/dsh-subagent/activation.ts +81 -89
- package/src/vendor/dsh-subagent/archive-admission.ts +38 -45
- package/src/vendor/dsh-subagent/assistant-output.ts +17 -19
- package/src/vendor/dsh-subagent/catalog.ts +79 -111
- package/src/vendor/dsh-subagent/child-agent.ts +83 -92
- package/src/vendor/dsh-subagent/continuation-messages.ts +64 -68
- package/src/vendor/dsh-subagent/control-types.ts +71 -68
- package/src/vendor/dsh-subagent/control.ts +39 -55
- package/src/vendor/dsh-subagent/depth.ts +14 -18
- package/src/vendor/dsh-subagent/descriptor.ts +107 -113
- package/src/vendor/dsh-subagent/error.ts +3 -3
- package/src/vendor/dsh-subagent/index.ts +193 -254
- package/src/vendor/dsh-subagent/internal.ts +17 -21
- package/src/vendor/dsh-subagent/lifecycle.ts +48 -51
- package/src/vendor/dsh-subagent/list-children.ts +57 -65
- package/src/vendor/dsh-subagent/manager.ts +726 -862
- package/src/vendor/dsh-subagent/out-of-process.ts +59 -61
- package/src/vendor/dsh-subagent/projection-types.ts +40 -38
- package/src/vendor/dsh-subagent/projection.ts +85 -107
- package/src/vendor/dsh-subagent/structured.ts +48 -57
- package/src/vendor/dsh-subagent/types.ts +68 -68
|
@@ -10,27 +10,23 @@
|
|
|
10
10
|
* @module @deepseek-ai/dsh-subagent/structured
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type { Context } from
|
|
14
|
-
import type { ToolSchema } from
|
|
15
|
-
import type { ToolExecution, ToolRunContext } from
|
|
16
|
-
import {
|
|
17
|
-
ToolArgsError,
|
|
18
|
-
validateJsonSchemaValue,
|
|
19
|
-
type ObjectJsonSchema,
|
|
20
|
-
} from "@deepseek-ai/dsh-tools";
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
14
|
+
import type { ToolSchema } from '@deepseek-ai/dsh-llm'
|
|
15
|
+
import type { ToolExecution, ToolRunContext } from '@deepseek-ai/dsh-tools'
|
|
16
|
+
import { ToolArgsError, validateJsonSchemaValue, type ObjectJsonSchema } from '@deepseek-ai/dsh-tools'
|
|
21
17
|
|
|
22
18
|
/** The model-facing tool name a structured child must call to finish. */
|
|
23
|
-
export const STRUCTURED_OUTPUT_TOOL =
|
|
19
|
+
export const STRUCTURED_OUTPUT_TOOL = 'structured_output'
|
|
24
20
|
|
|
25
21
|
/**
|
|
26
22
|
* The instruction registered as the child's trailing scoped prompt section:
|
|
27
23
|
* the demand travels with the
|
|
28
24
|
* tool, as ordinary prompt state of exactly one agent.
|
|
29
25
|
*/
|
|
30
|
-
export const STRUCTURED_OUTPUT_INSTRUCTION
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
export const STRUCTURED_OUTPUT_INSTRUCTION
|
|
27
|
+
= 'When you have your final answer, you MUST report it by calling the '
|
|
28
|
+
+ `\`${STRUCTURED_OUTPUT_TOOL}\` tool with arguments matching its parameter schema exactly. `
|
|
29
|
+
+ 'Do not finish with a plain text answer: only the tool call counts as your result.'
|
|
34
30
|
|
|
35
31
|
/** One structured run's live handle: read the captured value once the child settles. */
|
|
36
32
|
export interface StructuredAttachment {
|
|
@@ -39,13 +35,13 @@ export interface StructuredAttachment {
|
|
|
39
35
|
* an enclosing PTC execution. A failed result discards its capture and reopens input.
|
|
40
36
|
* @returns whether the activation can accept another message.
|
|
41
37
|
*/
|
|
42
|
-
acceptsInput(): boolean
|
|
38
|
+
acceptsInput(): boolean
|
|
43
39
|
/**
|
|
44
40
|
* The captured value, once the child called the tool with valid arguments
|
|
45
41
|
* and the authoritative final tool result accepted that call.
|
|
46
42
|
* @returns the committed value, or undefined while none was accepted.
|
|
47
43
|
*/
|
|
48
|
-
captured(): { value: unknown } | undefined
|
|
44
|
+
captured(): { value: unknown } | undefined
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
/**
|
|
@@ -71,94 +67,89 @@ export function attachStructuredRuntime(
|
|
|
71
67
|
* correlate nested transports. The final notification always deletes its own
|
|
72
68
|
* stage, whether the result succeeded or failed.
|
|
73
69
|
*/
|
|
74
|
-
const staged = new Map<ToolExecution, { value: unknown }>()
|
|
70
|
+
const staged = new Map<ToolExecution, { value: unknown }>()
|
|
75
71
|
/** Successful nested capture waiting for its enclosing transport to commit. */
|
|
76
|
-
let pending: { parent: ToolExecution[
|
|
77
|
-
let captured: { value: unknown } | undefined
|
|
72
|
+
let pending: { parent: ToolExecution['token']; value: unknown } | undefined
|
|
73
|
+
let captured: { value: unknown } | undefined
|
|
78
74
|
|
|
79
75
|
const schemaEntry: ToolSchema = {
|
|
80
76
|
name: STRUCTURED_OUTPUT_TOOL,
|
|
81
77
|
description:
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
'Report your final structured result. Call this exactly once, when your answer is complete; '
|
|
79
|
+
+ 'the arguments must match this tool\'s parameter schema exactly.',
|
|
84
80
|
parameters: { ...schema },
|
|
85
|
-
}
|
|
81
|
+
}
|
|
86
82
|
|
|
87
83
|
childCtx.tools.register({
|
|
88
84
|
...schemaEntry,
|
|
89
85
|
output: {
|
|
90
86
|
schema: {
|
|
91
|
-
type:
|
|
92
|
-
properties: { recorded: { type:
|
|
93
|
-
required: [
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: { recorded: { type: 'boolean', const: true } },
|
|
89
|
+
required: ['recorded'],
|
|
94
90
|
additionalProperties: false,
|
|
95
91
|
},
|
|
96
|
-
render: () => [{ type:
|
|
92
|
+
render: () => [{ type: 'text', text: 'Structured output recorded.' }],
|
|
97
93
|
},
|
|
98
94
|
execute(args: unknown, exec: ToolRunContext): Promise<{ recorded: true }> {
|
|
99
|
-
const violations = validateJsonSchemaValue(schema, args)
|
|
95
|
+
const violations = validateJsonSchemaValue(schema, args)
|
|
100
96
|
// ToolArgsError → isError result with INVALID_ARGS: the model retries
|
|
101
97
|
// within the same turn, exactly like a schema-validated defineTool call.
|
|
102
|
-
if (violations.length > 0) throw new ToolArgsError(violations)
|
|
103
|
-
if (!canComplete())
|
|
104
|
-
throw new Error(
|
|
105
|
-
"Wait for all delegated child tasks to finish and process pending messages before submitting structured output.",
|
|
106
|
-
);
|
|
98
|
+
if (violations.length > 0) throw new ToolArgsError(violations)
|
|
99
|
+
if (!canComplete()) throw new Error('Wait for all delegated child tasks to finish and process pending messages before submitting structured output.')
|
|
107
100
|
// Two-phase commit, keyed by THIS execution: later transformable
|
|
108
101
|
// waterfalls may still turn the success into an error. ToolRuntime has
|
|
109
102
|
// already frozen model-bound arguments at the actual input boundary.
|
|
110
|
-
staged.set(exec, { value: args })
|
|
111
|
-
exec.concludeTurn()
|
|
112
|
-
return Promise.resolve({ recorded: true })
|
|
103
|
+
staged.set(exec, { value: args })
|
|
104
|
+
exec.concludeTurn()
|
|
105
|
+
return Promise.resolve({ recorded: true })
|
|
113
106
|
},
|
|
114
|
-
})
|
|
107
|
+
})
|
|
115
108
|
|
|
116
109
|
childCtx.systemPrompt.section({
|
|
117
110
|
name: `tool:${STRUCTURED_OUTPUT_TOOL}`,
|
|
118
|
-
order: childCtx.systemPrompt.getSectionOrder(
|
|
111
|
+
order: childCtx.systemPrompt.getSectionOrder('STRUCTURED_OUTPUT'),
|
|
119
112
|
text: STRUCTURED_OUTPUT_INSTRUCTION,
|
|
120
|
-
})
|
|
113
|
+
})
|
|
121
114
|
|
|
122
115
|
// Terminal WITHIN the step. Guards run after the whole pre-execute
|
|
123
116
|
// waterfall and compose monotonically (deny or abstain, never allow), so a
|
|
124
117
|
// later prepended listener cannot resurrect dispatch. Calls that precede
|
|
125
118
|
// capture in the same response remain untouched.
|
|
126
|
-
childCtx.tools.guard(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
: `structured output already recorded: the run is complete, so \`${exec.name}\` is not executed`,
|
|
130
|
-
);
|
|
119
|
+
childCtx.tools.guard(exec => captured === undefined && pending === undefined
|
|
120
|
+
? undefined
|
|
121
|
+
: `structured output already recorded: the run is complete, so \`${exec.name}\` is not executed`)
|
|
131
122
|
|
|
132
123
|
// The capture COMMIT observes the immutable, authoritative result after the
|
|
133
124
|
// complete pipeline and outer error normalization. This notification cannot
|
|
134
125
|
// transform the outcome, so there is no wrapper outside the commit verdict.
|
|
135
|
-
childCtx.on(
|
|
126
|
+
childCtx.on('tools/result', function (this: unknown, exec, result) {
|
|
136
127
|
if (exec.name === STRUCTURED_OUTPUT_TOOL) {
|
|
137
|
-
const entry = staged.get(exec)
|
|
138
|
-
if (entry === undefined) return
|
|
139
|
-
staged.delete(exec)
|
|
140
|
-
if (result.isError) return
|
|
128
|
+
const entry = staged.get(exec)
|
|
129
|
+
if (entry === undefined) return
|
|
130
|
+
staged.delete(exec)
|
|
131
|
+
if (result.isError) return
|
|
141
132
|
if (exec.parent === undefined) {
|
|
142
133
|
/* v8 ignore else -- sequential agent-loop dispatch lets the guard block every later supported call */
|
|
143
|
-
if (captured === undefined) captured = { value: entry.value }
|
|
134
|
+
if (captured === undefined) captured = { value: entry.value }
|
|
144
135
|
} else {
|
|
145
136
|
/* v8 ignore else -- PTC mode serializes sub-dispatches, so the guard blocks every later supported call */
|
|
146
137
|
if (captured === undefined && pending === undefined) {
|
|
147
|
-
pending = { parent: exec.parent, value: entry.value }
|
|
138
|
+
pending = { parent: exec.parent, value: entry.value }
|
|
148
139
|
}
|
|
149
140
|
}
|
|
150
|
-
return
|
|
141
|
+
return
|
|
151
142
|
}
|
|
152
|
-
if (pending?.parent !== exec.token) return
|
|
153
|
-
const entry = pending
|
|
154
|
-
pending = undefined
|
|
155
|
-
if (result.isError) return
|
|
143
|
+
if (pending?.parent !== exec.token) return
|
|
144
|
+
const entry = pending
|
|
145
|
+
pending = undefined
|
|
146
|
+
if (result.isError) return
|
|
156
147
|
/* v8 ignore else -- PTC mode serializes outer executions, so the guard blocks every later supported call */
|
|
157
|
-
if (captured === undefined) captured = { value: entry.value }
|
|
158
|
-
})
|
|
148
|
+
if (captured === undefined) captured = { value: entry.value }
|
|
149
|
+
})
|
|
159
150
|
|
|
160
151
|
return {
|
|
161
152
|
captured: () => captured,
|
|
162
153
|
acceptsInput: () => staged.size === 0 && pending === undefined && captured === undefined,
|
|
163
|
-
}
|
|
154
|
+
}
|
|
164
155
|
}
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
* @module @deepseek-ai/dsh-subagent/types
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { Agent, AgentOptions } from
|
|
13
|
-
import type { Branded } from
|
|
14
|
-
import type { ContentBlock, MessageId } from
|
|
15
|
-
import type { SessionEvent, SessionId } from
|
|
16
|
-
import type { ObjectJsonSchema } from
|
|
12
|
+
import type { Agent, AgentOptions } from '@deepseek-ai/dsh-agent'
|
|
13
|
+
import type { Branded } from '@deepseek-ai/dsh-brand'
|
|
14
|
+
import type { ContentBlock, MessageId } from '@deepseek-ai/dsh-llm'
|
|
15
|
+
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
|
|
16
|
+
import type { ObjectJsonSchema } from '@deepseek-ai/dsh-tools'
|
|
17
17
|
|
|
18
18
|
/** Identifies one accepted subagent run across its lifecycle event pair. */
|
|
19
|
-
export type SubagentRunId = Branded<
|
|
19
|
+
export type SubagentRunId = Branded<'SubagentRunId'>
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Brand a string as a {@link SubagentRunId}.
|
|
@@ -24,38 +24,38 @@ export type SubagentRunId = Branded<"SubagentRunId">;
|
|
|
24
24
|
* @returns the same string, branded.
|
|
25
25
|
*/
|
|
26
26
|
export function SubagentRunId(id: string): SubagentRunId {
|
|
27
|
-
return id as SubagentRunId
|
|
27
|
+
return id as SubagentRunId
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** One managed child execution and its result delivery policy. */
|
|
31
31
|
export interface SubagentActivationSpec {
|
|
32
32
|
/** Registered backend to use. */
|
|
33
|
-
readonly provider: string
|
|
33
|
+
readonly provider: string
|
|
34
34
|
/** Short task label retained in cataloged child membership. */
|
|
35
|
-
readonly label: string
|
|
35
|
+
readonly label: string
|
|
36
36
|
/** Optional reserved identity for a local child; external backends allocate their own ids. */
|
|
37
|
-
readonly childId?: SessionId
|
|
37
|
+
readonly childId?: SessionId
|
|
38
38
|
/** Task, parent, and backend-supported execution options. */
|
|
39
|
-
readonly request: Omit<SubagentStartRequest,
|
|
39
|
+
readonly request: Omit<SubagentStartRequest, 'label' | 'signal'>
|
|
40
40
|
/** Cancellation before publication; callers own later cancellation through dispose. */
|
|
41
|
-
readonly signal: AbortSignal
|
|
41
|
+
readonly signal: AbortSignal
|
|
42
42
|
/** Parent delivery notifies the model; caller delivery only returns the result. Local children always enter the parent catalog. */
|
|
43
|
-
readonly delivery:
|
|
43
|
+
readonly delivery: 'parent' | 'caller'
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/** A managed execution; disposal addresses this exact activation, never a later resume. */
|
|
47
47
|
export interface SubagentActivation {
|
|
48
48
|
/** Stable identity of the child. */
|
|
49
|
-
readonly childId: SessionId
|
|
49
|
+
readonly childId: SessionId
|
|
50
50
|
/** Accepted inbox message, when the backend has a local inbox. */
|
|
51
|
-
readonly messageId?: MessageId
|
|
51
|
+
readonly messageId?: MessageId
|
|
52
52
|
/**
|
|
53
53
|
* Execution result after teardown settles and notifications are sent; capture failures reject.
|
|
54
54
|
* Teardown failures are reported by dispose() without replacing a captured result.
|
|
55
55
|
*/
|
|
56
|
-
readonly result: Promise<SubagentResult
|
|
56
|
+
readonly result: Promise<SubagentResult>
|
|
57
57
|
/** Stop and release this activation and its owned descendants; rejects on teardown failure. */
|
|
58
|
-
dispose(): Promise<void
|
|
58
|
+
dispose(): Promise<void>
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -64,13 +64,13 @@ export interface SubagentActivation {
|
|
|
64
64
|
* the exact live Agent object whose recorded lineage must contain the caller.
|
|
65
65
|
*/
|
|
66
66
|
export type SubagentInterruptAuthority =
|
|
67
|
-
| { readonly kind:
|
|
68
|
-
| { readonly kind:
|
|
67
|
+
| { readonly kind: 'user'; readonly parentSessionId: SessionId }
|
|
68
|
+
| { readonly kind: 'ancestor'; readonly agent: Agent }
|
|
69
69
|
|
|
70
70
|
/** Options for one model-authored message between adjacent Agents. */
|
|
71
71
|
export interface SubagentSendMessageOptions {
|
|
72
72
|
/** Caller cancellation, owning the operation only until inbox acceptance. */
|
|
73
|
-
readonly signal: AbortSignal
|
|
73
|
+
readonly signal: AbortSignal
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -79,16 +79,16 @@ export interface SubagentSendMessageOptions {
|
|
|
79
79
|
*/
|
|
80
80
|
export interface SubagentRunInfo {
|
|
81
81
|
/** Unique identity shared with the paired terminal event. */
|
|
82
|
-
readonly runId: SubagentRunId
|
|
82
|
+
readonly runId: SubagentRunId
|
|
83
83
|
/**
|
|
84
84
|
* Provider name recorded when the child was first created, retained even
|
|
85
85
|
* after that provider is unregistered.
|
|
86
86
|
*/
|
|
87
|
-
readonly provider: string
|
|
87
|
+
readonly provider: string
|
|
88
88
|
/** The child agent's id. */
|
|
89
|
-
readonly id: SessionId
|
|
89
|
+
readonly id: SessionId
|
|
90
90
|
/** Whether this activation owns a local Agent, fixed at publication. */
|
|
91
|
-
readonly local: boolean
|
|
91
|
+
readonly local: boolean
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -97,21 +97,21 @@ export interface SubagentRunInfo {
|
|
|
97
97
|
*/
|
|
98
98
|
export interface SubagentRunEndInfo {
|
|
99
99
|
/** Unique identity shared with the paired start event. */
|
|
100
|
-
readonly runId: SubagentRunId
|
|
100
|
+
readonly runId: SubagentRunId
|
|
101
101
|
/** The same provider name carried by the paired start event. */
|
|
102
|
-
readonly provider: string
|
|
102
|
+
readonly provider: string
|
|
103
103
|
/** The child agent's id. */
|
|
104
|
-
readonly id: SessionId
|
|
104
|
+
readonly id: SessionId
|
|
105
105
|
/** Whether this activation owns a local Agent, fixed at publication. */
|
|
106
|
-
readonly local: boolean
|
|
106
|
+
readonly local: boolean
|
|
107
107
|
/** The terminal stop reason. */
|
|
108
|
-
readonly stopReason: SubagentResult[
|
|
108
|
+
readonly stopReason: SubagentResult['stopReason']
|
|
109
109
|
/**
|
|
110
110
|
* The child's final assistant output, selected by the same rule as
|
|
111
111
|
* {@link SubagentResult.output}; absent on infrastructure rejection or when
|
|
112
112
|
* the child produced none.
|
|
113
113
|
*/
|
|
114
|
-
readonly lastAssistantMessage?: readonly ContentBlock[]
|
|
114
|
+
readonly lastAssistantMessage?: readonly ContentBlock[]
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -121,11 +121,11 @@ export interface SubagentRunEndInfo {
|
|
|
121
121
|
* SubagentStartRequest fields.
|
|
122
122
|
*/
|
|
123
123
|
export interface SubagentCapabilities {
|
|
124
|
-
readonly agentOptions: boolean
|
|
124
|
+
readonly agentOptions: boolean
|
|
125
125
|
/** Supports selecting a preset independently of the parent's composition. */
|
|
126
|
-
readonly agentPreset: boolean
|
|
127
|
-
readonly outputSchema: boolean
|
|
128
|
-
readonly depthLimit: boolean
|
|
126
|
+
readonly agentPreset: boolean
|
|
127
|
+
readonly outputSchema: boolean
|
|
128
|
+
readonly depthLimit: boolean
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -135,22 +135,22 @@ export interface SubagentCapabilities {
|
|
|
135
135
|
*/
|
|
136
136
|
export interface SubagentStartRequest {
|
|
137
137
|
/** Initial child directory; relative paths resolve against the parent's current directory. Omitted inherits that directory at start. */
|
|
138
|
-
readonly cwd?: string
|
|
138
|
+
readonly cwd?: string
|
|
139
139
|
/**
|
|
140
140
|
* Independent preset id; omission joins the parent's current generation.
|
|
141
141
|
* Requires a provider with `capabilities.agentPreset` that does not inherit
|
|
142
142
|
* parent context.
|
|
143
143
|
*/
|
|
144
|
-
readonly agentPreset?: string
|
|
144
|
+
readonly agentPreset?: string
|
|
145
145
|
/** Optional short display label persisted with a session-backed child. */
|
|
146
|
-
readonly label?: string
|
|
146
|
+
readonly label?: string
|
|
147
147
|
/** Content delivered as the child's user message. */
|
|
148
|
-
readonly prompt: ContentBlock[]
|
|
148
|
+
readonly prompt: ContentBlock[]
|
|
149
149
|
/**
|
|
150
150
|
* The spawning agent. Its effective directory supplies the default cwd;
|
|
151
151
|
* in-process children retain its origin, lineage, and delegation depth.
|
|
152
152
|
*/
|
|
153
|
-
readonly parent: Agent
|
|
153
|
+
readonly parent: Agent
|
|
154
154
|
/**
|
|
155
155
|
* Cancellation signal from the spawning context (the tool's `exec.signal`).
|
|
156
156
|
* This is the canonical cancellation channel both before and after startup:
|
|
@@ -158,7 +158,7 @@ export interface SubagentStartRequest {
|
|
|
158
158
|
* fires before the run is published, and cancels the published run's
|
|
159
159
|
* remaining turn work when it fires afterward.
|
|
160
160
|
*/
|
|
161
|
-
readonly signal: AbortSignal
|
|
161
|
+
readonly signal: AbortSignal
|
|
162
162
|
/**
|
|
163
163
|
* Optional host-Agent provider, model, reasoning-effort, and output-token
|
|
164
164
|
* overrides. Requires {@link SubagentCapabilities.agentOptions}; in-process
|
|
@@ -166,26 +166,26 @@ export interface SubagentStartRequest {
|
|
|
166
166
|
* child, while the DSH SDK provider merges them over its instance defaults
|
|
167
167
|
* before initializing the separate child runtime.
|
|
168
168
|
*/
|
|
169
|
-
readonly agentOptions?: AgentOptions
|
|
169
|
+
readonly agentOptions?: AgentOptions
|
|
170
170
|
/**
|
|
171
171
|
* Object-rooted JSON Schema within `assertObjectJsonSchema`'s enforced subset. Start rejects
|
|
172
172
|
* unsupported schemas or providers without the capability. Data must be plain host-realm JSON;
|
|
173
173
|
* a successful child returns the matching value as {@link SubagentResult.structured}.
|
|
174
174
|
*/
|
|
175
|
-
readonly outputSchema?: ObjectJsonSchema
|
|
175
|
+
readonly outputSchema?: ObjectJsonSchema
|
|
176
176
|
/**
|
|
177
177
|
* Optional absolute delegation-depth cap for the child being started: its
|
|
178
178
|
* computed depth must be less than or equal to this non-negative safe
|
|
179
179
|
* integer. Requires {@link SubagentCapabilities.depthLimit}; rejected at
|
|
180
180
|
* start otherwise.
|
|
181
181
|
*/
|
|
182
|
-
readonly maxDepth?: number
|
|
182
|
+
readonly maxDepth?: number
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/** Provider-facing request with an absolute directory selected before startup. */
|
|
186
186
|
export interface ResolvedSubagentStartRequest extends SubagentStartRequest {
|
|
187
187
|
/** Absolute child directory captured from the parent or explicit request. */
|
|
188
|
-
readonly cwd: string
|
|
188
|
+
readonly cwd: string
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -197,16 +197,16 @@ export interface ResolvedSubagentStartRequest extends SubagentStartRequest {
|
|
|
197
197
|
*/
|
|
198
198
|
export interface ContinuableCreateRequest {
|
|
199
199
|
/** Absolute initial directory captured before provider preparation. */
|
|
200
|
-
readonly cwd: string
|
|
200
|
+
readonly cwd: string
|
|
201
201
|
/** The reserved durable child session id, for provider diagnostics. */
|
|
202
|
-
readonly sessionId: SessionId
|
|
202
|
+
readonly sessionId: SessionId
|
|
203
203
|
/** The delegating parent agent whose history a seeding provider reads. */
|
|
204
|
-
readonly parent: Agent
|
|
204
|
+
readonly parent: Agent
|
|
205
205
|
/**
|
|
206
206
|
* Caller cancellation, which owns preparation only until the manager accepts
|
|
207
207
|
* the initial prompt into the child's inbox.
|
|
208
208
|
*/
|
|
209
|
-
readonly signal: AbortSignal
|
|
209
|
+
readonly signal: AbortSignal
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/**
|
|
@@ -221,7 +221,7 @@ export interface ContinuableCreateSpec {
|
|
|
221
221
|
* or absent for a fresh child. Same durable contract as
|
|
222
222
|
* `CreateAgentOptions.seed`: contiguous from seq 0, lossless JSON, balanced.
|
|
223
223
|
*/
|
|
224
|
-
readonly seed?: readonly SessionEvent[]
|
|
224
|
+
readonly seed?: readonly SessionEvent[]
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
/**
|
|
@@ -232,19 +232,19 @@ export interface ContinuableCreateSpec {
|
|
|
232
232
|
*/
|
|
233
233
|
export interface SubagentStopReasonMap {
|
|
234
234
|
/** The child finished its turn normally. */
|
|
235
|
-
completed:
|
|
235
|
+
completed: 'completed'
|
|
236
236
|
/** Cancelled through the request signal or disposal. */
|
|
237
|
-
aborted:
|
|
237
|
+
aborted: 'aborted'
|
|
238
238
|
/** Model or transport failure. */
|
|
239
|
-
error:
|
|
239
|
+
error: 'error'
|
|
240
240
|
/** The child hit its token ceiling before finishing. */
|
|
241
|
-
|
|
241
|
+
'max-tokens': 'max-tokens'
|
|
242
242
|
/** The child declined the task. */
|
|
243
|
-
refusal:
|
|
243
|
+
refusal: 'refusal'
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/** The union over {@link SubagentStopReasonMap} — widens automatically as backends merge in variants. */
|
|
247
|
-
export type SubagentStopReason = SubagentStopReasonMap[keyof SubagentStopReasonMap]
|
|
247
|
+
export type SubagentStopReason = SubagentStopReasonMap[keyof SubagentStopReasonMap]
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
250
|
* The terminal outcome of a subagent run, resolved by {@link SubagentRun.result}.
|
|
@@ -256,7 +256,7 @@ export interface SubagentResult {
|
|
|
256
256
|
* are skipped. Without a non-empty message, the output is its accumulated
|
|
257
257
|
* assistant text stream, or `[]` when the child produced neither.
|
|
258
258
|
*/
|
|
259
|
-
readonly output: readonly ContentBlock[]
|
|
259
|
+
readonly output: readonly ContentBlock[]
|
|
260
260
|
/**
|
|
261
261
|
* The structured result after a requested `outputSchema` was successfully
|
|
262
262
|
* satisfied. Requesting a schema does not guarantee presence: a provider can
|
|
@@ -265,16 +265,16 @@ export interface SubagentResult {
|
|
|
265
265
|
* output schema by the provider; `unknown` here because the seam is
|
|
266
266
|
* schema-agnostic.
|
|
267
267
|
*/
|
|
268
|
-
readonly structured?: unknown
|
|
268
|
+
readonly structured?: unknown
|
|
269
269
|
/**
|
|
270
270
|
* Provider-authored, non-assistant failure detail for a non-`completed`
|
|
271
271
|
* result. Providers keep this text free of tool inputs, file contents,
|
|
272
272
|
* environment values, credentials, and raw protocol payloads, and limit it
|
|
273
273
|
* to 4096 UTF-8 bytes. Consumers present it separately from {@link output}.
|
|
274
274
|
*/
|
|
275
|
-
readonly diagnostic?: string
|
|
275
|
+
readonly diagnostic?: string
|
|
276
276
|
/** Why the run ended. A non-`completed` reason means `output` may be partial. */
|
|
277
|
-
readonly stopReason: SubagentStopReason
|
|
277
|
+
readonly stopReason: SubagentStopReason
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
/**
|
|
@@ -286,7 +286,7 @@ export interface SubagentResult {
|
|
|
286
286
|
*/
|
|
287
287
|
export interface SubagentRun {
|
|
288
288
|
/** Provider-minted id, unique across all parents, providers, and local Sessions in this runtime. */
|
|
289
|
-
readonly id: SessionId
|
|
289
|
+
readonly id: SessionId
|
|
290
290
|
/**
|
|
291
291
|
* Resolves with the child's terminal {@link SubagentResult} when the run
|
|
292
292
|
* settles. Does NOT reject on a child-level failure — a model/transport
|
|
@@ -294,12 +294,12 @@ export interface SubagentRun {
|
|
|
294
294
|
* `isError` tool result. Rejects on an infrastructure fault the seam cannot
|
|
295
295
|
* represent as a stop reason.
|
|
296
296
|
*/
|
|
297
|
-
readonly result: Promise<SubagentResult
|
|
297
|
+
readonly result: Promise<SubagentResult>
|
|
298
298
|
/**
|
|
299
299
|
* Cancel remaining work, reach child quiescence, and release resources.
|
|
300
300
|
* Idempotent.
|
|
301
301
|
*/
|
|
302
|
-
dispose(): Promise<void
|
|
302
|
+
dispose(): Promise<void>
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
/**
|
|
@@ -312,22 +312,22 @@ export interface SubagentRun {
|
|
|
312
312
|
*/
|
|
313
313
|
export interface SubagentProvider {
|
|
314
314
|
/** Unique registry name (e.g. `spawn`, `fork`, `acp`). */
|
|
315
|
-
readonly name: string
|
|
315
|
+
readonly name: string
|
|
316
316
|
/** The start-time features this provider supports (see {@link SubagentCapabilities}). */
|
|
317
|
-
readonly capabilities: SubagentCapabilities
|
|
317
|
+
readonly capabilities: SubagentCapabilities
|
|
318
318
|
/**
|
|
319
319
|
* Whether the child sees the parent's completed-turn prefix. This is descriptive, not a
|
|
320
320
|
* service-validated start capability: the model-facing tool derives truthful wording from it.
|
|
321
321
|
* It says nothing about tool registration, injected services, or authority inheritance.
|
|
322
322
|
*/
|
|
323
|
-
readonly inheritsParentContext: boolean
|
|
323
|
+
readonly inheritsParentContext: boolean
|
|
324
324
|
/**
|
|
325
325
|
* Optional static provider-owned provider/model route for child Agent
|
|
326
326
|
* options. Consumers merge tool/model overrides over these values before
|
|
327
327
|
* preflight; providers whose route derives from the parent omit it. The value
|
|
328
328
|
* is detached immutable data and requires `agentOptions` support.
|
|
329
329
|
*/
|
|
330
|
-
readonly agentRouteDefaults?: Readonly<{ provider: string; model: string }
|
|
330
|
+
readonly agentRouteDefaults?: Readonly<{ provider: string; model: string }>
|
|
331
331
|
/**
|
|
332
332
|
* Establish one external execution and return its owned handle.
|
|
333
333
|
* The service has already validated that every requested start-time
|
|
@@ -337,7 +337,7 @@ export interface SubagentProvider {
|
|
|
337
337
|
* the returned run. Distinct starts may overlap; cancellation, failure,
|
|
338
338
|
* result settlement, and disposal remain independent for each run.
|
|
339
339
|
*/
|
|
340
|
-
start?(request: ResolvedSubagentStartRequest): Promise<SubagentRun
|
|
340
|
+
start?(request: ResolvedSubagentStartRequest): Promise<SubagentRun>
|
|
341
341
|
/**
|
|
342
342
|
* OPTIONAL (continuable-creation capability): contribute the detached
|
|
343
343
|
* creation inputs that distinguish this provider's continuable children —
|
|
@@ -352,5 +352,5 @@ export interface SubagentProvider {
|
|
|
352
352
|
* Distinct preparations may overlap; each follows its own signal and returns
|
|
353
353
|
* data belonging only to `request.sessionId`.
|
|
354
354
|
*/
|
|
355
|
-
prepareContinuable?(request: ContinuableCreateRequest): Promise<ContinuableCreateSpec
|
|
355
|
+
prepareContinuable?(request: ContinuableCreateRequest): Promise<ContinuableCreateSpec>
|
|
356
356
|
}
|