@deepseek-ai/dsh-subagent 0.1.5-rc.2 → 0.1.6-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 +17 -3
- package/README.zh.md +26 -12
- package/lib/index.js +131 -60
- package/lib/typert.host.js +54 -35
- package/lib/typert.remote-client.js +31 -23
- package/lib/types/child-agent.d.ts +8 -5
- package/lib/types/child-agent.js +11 -5
- package/lib/types/continuation-activation.d.ts +17 -1
- package/lib/types/continuation-activation.js +41 -4
- package/lib/types/continuation-messages.d.ts +1 -1
- package/lib/types/continuation-messages.js +7 -3
- package/lib/types/continuation.d.ts +1 -1
- package/lib/types/continuation.js +2 -2
- package/lib/types/control.js +1 -0
- package/lib/types/index.d.ts +20 -3
- package/lib/types/index.js +31 -5
- package/lib/types/internal.d.ts +2 -2
- package/lib/types/internal.js +2 -2
- package/lib/types/lifecycle.js +1 -0
- package/package.json +57 -46
package/lib/typert.host.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/* Generated by @deepseek-ai/dsh-typert-generator from FaceModel — do not edit. */
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
4
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema$value
|
|
5
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
|
|
6
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema$value
|
|
7
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema$value ??= z.intersection(z.string(), z.unknown()))
|
|
8
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema$value
|
|
9
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema$value ??= z.literal("continuable"))
|
|
10
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value
|
|
11
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value ??= z.object({
|
|
8
12
|
'accepted': z.literal(true).readonly(),
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const
|
|
13
|
+
}))
|
|
14
|
+
let _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema$value
|
|
15
|
+
const _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
|
|
16
|
+
let _deepseek_ai_dsh_subagent_subagents_list_result$schema$value
|
|
17
|
+
const _deepseek_ai_dsh_subagent_subagents_list_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_list_result$schema$value ??= z.object({
|
|
12
18
|
'entries': z.array(z.union([z.intersection(z.object({
|
|
13
19
|
'kind': z.literal("child").readonly(),
|
|
14
20
|
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
@@ -31,8 +37,9 @@ const _deepseek_ai_dsh_subagent_subagents_list_result$schema = z.object({
|
|
|
31
37
|
'reason': z.union([z.literal("corrupt"), z.literal("unsupported"), z.literal("unavailable")]).readonly(),
|
|
32
38
|
})])).readonly(),
|
|
33
39
|
'parentAvailable': z.boolean().readonly(),
|
|
34
|
-
})
|
|
35
|
-
|
|
40
|
+
}))
|
|
41
|
+
let _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value
|
|
42
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value ??= z.object({
|
|
36
43
|
'requestId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
37
44
|
'parentSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
38
45
|
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
@@ -48,10 +55,11 @@ const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = z.object({
|
|
|
48
55
|
'name': z.string().readonly().optional(),
|
|
49
56
|
})])).readonly(),
|
|
50
57
|
'clientTimeZone': z.string().readonly().optional(),
|
|
51
|
-
})
|
|
52
|
-
|
|
58
|
+
}))
|
|
59
|
+
let _deepseek_ai_dsh_subagent_subagents_prompt_result$schema$value
|
|
60
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_result$schema$value ??= z.object({
|
|
53
61
|
'messageId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
54
|
-
})
|
|
62
|
+
}))
|
|
55
63
|
|
|
56
64
|
export const TYPERT = {
|
|
57
65
|
package: '@deepseek-ai/dsh-subagent',
|
|
@@ -73,7 +81,7 @@ export const TYPERT = {
|
|
|
73
81
|
codec: {
|
|
74
82
|
mode: 'strict',
|
|
75
83
|
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
76
|
-
|
|
84
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema,
|
|
77
85
|
},
|
|
78
86
|
},
|
|
79
87
|
{
|
|
@@ -83,7 +91,7 @@ export const TYPERT = {
|
|
|
83
91
|
codec: {
|
|
84
92
|
mode: 'strict',
|
|
85
93
|
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
86
|
-
|
|
94
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema,
|
|
87
95
|
},
|
|
88
96
|
},
|
|
89
97
|
{
|
|
@@ -93,16 +101,16 @@ export const TYPERT = {
|
|
|
93
101
|
codec: {
|
|
94
102
|
mode: 'strict',
|
|
95
103
|
typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
|
|
96
|
-
|
|
104
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema,
|
|
97
105
|
},
|
|
98
106
|
},
|
|
99
107
|
],
|
|
100
108
|
result: {
|
|
101
109
|
mode: 'strict',
|
|
102
110
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
103
|
-
|
|
111
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
104
112
|
},
|
|
105
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
113
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":515,"column":3},
|
|
106
114
|
},
|
|
107
115
|
{
|
|
108
116
|
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
@@ -119,7 +127,7 @@ export const TYPERT = {
|
|
|
119
127
|
codec: {
|
|
120
128
|
mode: 'strict',
|
|
121
129
|
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
122
|
-
|
|
130
|
+
create: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
|
|
123
131
|
},
|
|
124
132
|
},
|
|
125
133
|
],
|
|
@@ -127,9 +135,9 @@ export const TYPERT = {
|
|
|
127
135
|
result: {
|
|
128
136
|
mode: 'strict',
|
|
129
137
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
130
|
-
|
|
138
|
+
create: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
131
139
|
},
|
|
132
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
140
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":420,"column":9},
|
|
133
141
|
},
|
|
134
142
|
{
|
|
135
143
|
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
@@ -145,7 +153,7 @@ export const TYPERT = {
|
|
|
145
153
|
codec: {
|
|
146
154
|
mode: 'strict',
|
|
147
155
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
|
|
148
|
-
|
|
156
|
+
create: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema,
|
|
149
157
|
},
|
|
150
158
|
},
|
|
151
159
|
],
|
|
@@ -153,9 +161,9 @@ export const TYPERT = {
|
|
|
153
161
|
result: {
|
|
154
162
|
mode: 'strict',
|
|
155
163
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
|
|
156
|
-
|
|
164
|
+
create: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
|
|
157
165
|
},
|
|
158
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
166
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":448,"column":9},
|
|
159
167
|
},
|
|
160
168
|
],
|
|
161
169
|
model: {
|
|
@@ -168,6 +176,13 @@ export const TYPERT = {
|
|
|
168
176
|
"key": "subagents",
|
|
169
177
|
"exportName": "SubagentRuntime",
|
|
170
178
|
"members": [
|
|
179
|
+
{
|
|
180
|
+
"kind": "method",
|
|
181
|
+
"name": "resolveMaxDepth",
|
|
182
|
+
"signature": "resolveMaxDepth(configured?: number | 'provider-managed'): number | undefined",
|
|
183
|
+
"summary": "Resolve a delegation tool's depth policy against the current user setting.",
|
|
184
|
+
"jsDoc": "/**\n * Resolve a delegation tool's depth policy against the current user setting.\n * @param configured - Explicit tool limit, or provider-managed for external delegation.\n * @returns The numeric limit, or undefined when the provider owns depth enforcement.\n */"
|
|
185
|
+
},
|
|
171
186
|
{
|
|
172
187
|
"kind": "method",
|
|
173
188
|
"name": "startContinuable",
|
|
@@ -229,7 +244,7 @@ export const TYPERT = {
|
|
|
229
244
|
"name": "prompt",
|
|
230
245
|
"signature": "@Remote('prompt') async prompt(request: SubagentPromptRequest, signal: AbortSignal): Promise<SubagentPromptReceipt>",
|
|
231
246
|
"summary": "Deliver one browser-authored message to a continuable child through the exact live direct parent, retaining the caller-minted request identity and validated browser zone on the accepted message.",
|
|
232
|
-
"jsDoc": "/**\n * Deliver one browser-authored message to a continuable child through the\n * exact live direct parent, retaining the caller-minted request identity and\n * validated browser zone on the accepted message. Success identifies the\n * message the child's inbox accepted; later execution is independent of this\n * call. Queue delivery targets a later turn; steer delivery targets the\n * nearest step and retains the Agent loop's best-effort fallback semantics.\n * Image parts are admitted and persisted through the attachment store\n * before delivery, and the child's model must accept image input.\n * @param request - durable address, delivery, minted identity, content, and optional browser zone.\n * @param signal - carrier cancellation, owning the call until inbox acceptance.\n * @returns the accepted message's inbox identity.\n * @throws {RemoteError} `gateway/bad-request`, `subagent/attachment-invalid`,\n * `subagent/invalid-time-zone`, `subagent/parent-unavailable`,\n * `subagent/not-resumable`, `subagent/unauthorized`,\n * `subagent/delivery-unavailable`, `gateway/cancelled`, or `gateway/internal`.\n */"
|
|
247
|
+
"jsDoc": "/**\n * Deliver one browser-authored message to a continuable child through the\n * exact live direct parent, retaining the caller-minted request identity and\n * validated browser zone on the accepted message. Success identifies the\n * message the child's inbox accepted; later execution is independent of this\n * call. Queue delivery targets a later turn; steer delivery targets the\n * nearest step and retains the Agent loop's best-effort fallback semantics.\n * Image parts are admitted and persisted through the attachment store\n * before delivery, and the child's model must accept image input.\n * Cold resume at capacity rejects with `subagent/delivery-unavailable`.\n * @param request - durable address, delivery, minted identity, content, and optional browser zone.\n * @param signal - carrier cancellation, owning the call until inbox acceptance.\n * @returns the accepted message's inbox identity.\n * @throws {RemoteError} `gateway/bad-request`, `subagent/attachment-invalid`,\n * `subagent/invalid-time-zone`, `subagent/parent-unavailable`,\n * `subagent/not-resumable`, `subagent/unauthorized`,\n * `subagent/delivery-unavailable`, `gateway/cancelled`, or `gateway/internal`.\n */"
|
|
233
248
|
},
|
|
234
249
|
{
|
|
235
250
|
"kind": "method",
|
|
@@ -305,8 +320,8 @@ export const TYPERT = {
|
|
|
305
320
|
"declaration": "export interface AssistantMessage extends Message {\n readonly role: 'assistant';\n readonly source: ModelMessageSource;\n}"
|
|
306
321
|
},
|
|
307
322
|
{
|
|
308
|
-
"name": "
|
|
309
|
-
"declaration": "export interface
|
|
323
|
+
"name": "AssistantProviderMetadata",
|
|
324
|
+
"declaration": "export interface AssistantProviderMetadata {\n provider: string;\n model: string;\n replayState?: unknown;\n}"
|
|
310
325
|
},
|
|
311
326
|
{
|
|
312
327
|
"name": "AssistantStreamRecord",
|
|
@@ -458,12 +473,16 @@ export const TYPERT = {
|
|
|
458
473
|
},
|
|
459
474
|
{
|
|
460
475
|
"name": "ImageBlock",
|
|
461
|
-
"declaration": "export interface ImageBlock {\n type: 'image';\n attachment: ImageAttachmentRef;\n}"
|
|
476
|
+
"declaration": "export interface ImageBlock {\n type: 'image';\n attachment: ImageAttachmentRef;\n offloaded?: true;\n}"
|
|
462
477
|
},
|
|
463
478
|
{
|
|
464
479
|
"name": "ImageMediaType",
|
|
465
480
|
"declaration": "export type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';"
|
|
466
481
|
},
|
|
482
|
+
{
|
|
483
|
+
"name": "ImageOffloadTarget",
|
|
484
|
+
"declaration": "export interface ImageOffloadTarget {\n seq: SessionSeq;\n imageIndexes: number[];\n}"
|
|
485
|
+
},
|
|
467
486
|
{
|
|
468
487
|
"name": "Inbox",
|
|
469
488
|
"declaration": "export interface Inbox {\n readonly nextTurn: readonly UserMessage[];\n readonly nextStep: readonly UserMessage[];\n clear(): void;\n append(target: InboxTarget, message: UserMessage): void;\n prepend(target: InboxTarget, message: UserMessage): void;\n replace(messageId: MessageId, newMessage: UserMessage): boolean;\n remove(messageId: MessageId): boolean;\n splice(target: InboxTarget, start: number, deleteCount: number, inserted: UserMessage[]): UserMessage[];\n}"
|
|
@@ -498,7 +517,7 @@ export const TYPERT = {
|
|
|
498
517
|
},
|
|
499
518
|
{
|
|
500
519
|
"name": "LlmFailure",
|
|
501
|
-
"declaration": "export interface LlmFailure {\n readonly message: string;\n readonly code: string;\n readonly status?: number;\n readonly providerRetryAfterMs?: number;\n readonly requestId?: ProviderRequestId;\n}"
|
|
520
|
+
"declaration": "export interface LlmFailure {\n readonly message: string;\n readonly code: string;\n readonly status?: number;\n readonly providerRetryAfterMs?: number;\n readonly requestId?: ProviderRequestId;\n readonly offloadImages?: number;\n}"
|
|
502
521
|
},
|
|
503
522
|
{
|
|
504
523
|
"name": "Message",
|
|
@@ -538,7 +557,7 @@ export const TYPERT = {
|
|
|
538
557
|
},
|
|
539
558
|
{
|
|
540
559
|
"name": "ModelMessageSource",
|
|
541
|
-
"declaration": "export interface ModelMessageSource extends
|
|
560
|
+
"declaration": "export interface ModelMessageSource extends AssistantProviderMetadata {\n kind: 'model';\n}"
|
|
542
561
|
},
|
|
543
562
|
{
|
|
544
563
|
"name": "ModelSelection",
|
|
@@ -566,7 +585,7 @@ export const TYPERT = {
|
|
|
566
585
|
},
|
|
567
586
|
{
|
|
568
587
|
"name": "PtcDispatchEventData",
|
|
569
|
-
"declaration": "export interface PtcDispatchEventData extends PtcDispatchStartEventData {\n isError: boolean;\n content: ContentBlock[];\n}"
|
|
588
|
+
"declaration": "export interface PtcDispatchEventData extends PtcDispatchStartEventData {\n isError: boolean;\n content: ContentBlock[];\n error?: { name: string; code: string; reason?: string; };\n}"
|
|
570
589
|
},
|
|
571
590
|
{
|
|
572
591
|
"name": "PtcDispatchStartEventData",
|
|
@@ -610,7 +629,7 @@ export const TYPERT = {
|
|
|
610
629
|
},
|
|
611
630
|
{
|
|
612
631
|
"name": "SessionEventMap",
|
|
613
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n '
|
|
632
|
+
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'team/member': { version: 2; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 2; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 2; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 2; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
614
633
|
},
|
|
615
634
|
{
|
|
616
635
|
"name": "SessionEventType",
|
|
@@ -642,15 +661,15 @@ export const TYPERT = {
|
|
|
642
661
|
},
|
|
643
662
|
{
|
|
644
663
|
"name": "SessionSurface",
|
|
645
|
-
"declaration": "export interface SessionSurface {\n readonly nodes: readonly SessionSeq[];\n readonly replaceGeneration: number;\n}"
|
|
664
|
+
"declaration": "export interface SessionSurface {\n readonly nodes: readonly SessionSeq[];\n readonly replaceGeneration: number;\n readonly contentGeneration: number;\n}"
|
|
646
665
|
},
|
|
647
666
|
{
|
|
648
667
|
"name": "SessionTitleEventData",
|
|
649
668
|
"declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs: SessionSeq[];\n readonly source: SessionTitleSource;\n}"
|
|
650
669
|
},
|
|
651
670
|
{
|
|
652
|
-
"name": "
|
|
653
|
-
"declaration": "export interface
|
|
671
|
+
"name": "SessionTitleModelIdentity",
|
|
672
|
+
"declaration": "export interface SessionTitleModelIdentity {\n readonly provider: string;\n readonly model: string;\n}"
|
|
654
673
|
},
|
|
655
674
|
{
|
|
656
675
|
"name": "SessionTitleProviderId",
|
|
@@ -658,7 +677,7 @@ export const TYPERT = {
|
|
|
658
677
|
},
|
|
659
678
|
{
|
|
660
679
|
"name": "SessionTitleSource",
|
|
661
|
-
"declaration": "export type SessionTitleSource = { readonly kind: 'fallback'; } | { readonly kind: 'provider'; readonly provider: SessionTitleProviderId; readonly model?:
|
|
680
|
+
"declaration": "export type SessionTitleSource = { readonly kind: 'fallback'; } | { readonly kind: 'provider'; readonly provider: SessionTitleProviderId; readonly model?: SessionTitleModelIdentity; } | { readonly kind: 'user'; };"
|
|
662
681
|
},
|
|
663
682
|
{
|
|
664
683
|
"name": "SkillInvocationSource",
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
4
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema$value
|
|
5
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
|
|
6
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema$value
|
|
7
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema$value ??= z.intersection(z.string(), z.unknown()))
|
|
8
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema$value
|
|
9
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema$value ??= z.literal("continuable"))
|
|
10
|
+
let _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value
|
|
11
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value ??= z.object({
|
|
8
12
|
'accepted': z.literal(true).readonly(),
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const
|
|
13
|
+
}))
|
|
14
|
+
let _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema$value
|
|
15
|
+
const _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
|
|
16
|
+
let _deepseek_ai_dsh_subagent_subagents_list_result$schema$value
|
|
17
|
+
const _deepseek_ai_dsh_subagent_subagents_list_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_list_result$schema$value ??= z.object({
|
|
12
18
|
'entries': z.array(z.union([z.intersection(z.object({
|
|
13
19
|
'kind': z.literal("child").readonly(),
|
|
14
20
|
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
@@ -31,8 +37,9 @@ const _deepseek_ai_dsh_subagent_subagents_list_result$schema = z.object({
|
|
|
31
37
|
'reason': z.union([z.literal("corrupt"), z.literal("unsupported"), z.literal("unavailable")]).readonly(),
|
|
32
38
|
})])).readonly(),
|
|
33
39
|
'parentAvailable': z.boolean().readonly(),
|
|
34
|
-
})
|
|
35
|
-
|
|
40
|
+
}))
|
|
41
|
+
let _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value
|
|
42
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value ??= z.object({
|
|
36
43
|
'requestId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
37
44
|
'parentSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
38
45
|
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
@@ -48,10 +55,11 @@ const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = z.object({
|
|
|
48
55
|
'name': z.string().readonly().optional(),
|
|
49
56
|
})])).readonly(),
|
|
50
57
|
'clientTimeZone': z.string().readonly().optional(),
|
|
51
|
-
})
|
|
52
|
-
|
|
58
|
+
}))
|
|
59
|
+
let _deepseek_ai_dsh_subagent_subagents_prompt_result$schema$value
|
|
60
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_result$schema$value ??= z.object({
|
|
53
61
|
'messageId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
54
|
-
})
|
|
62
|
+
}))
|
|
55
63
|
|
|
56
64
|
export const TYPERT_REMOTE = {
|
|
57
65
|
package: '@deepseek-ai/dsh-subagent',
|
|
@@ -70,7 +78,7 @@ export const TYPERT_REMOTE = {
|
|
|
70
78
|
codec: {
|
|
71
79
|
mode: 'strict',
|
|
72
80
|
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
73
|
-
|
|
81
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema,
|
|
74
82
|
},
|
|
75
83
|
},
|
|
76
84
|
{
|
|
@@ -80,7 +88,7 @@ export const TYPERT_REMOTE = {
|
|
|
80
88
|
codec: {
|
|
81
89
|
mode: 'strict',
|
|
82
90
|
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
83
|
-
|
|
91
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema,
|
|
84
92
|
},
|
|
85
93
|
},
|
|
86
94
|
{
|
|
@@ -90,16 +98,16 @@ export const TYPERT_REMOTE = {
|
|
|
90
98
|
codec: {
|
|
91
99
|
mode: 'strict',
|
|
92
100
|
typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
|
|
93
|
-
|
|
101
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema,
|
|
94
102
|
},
|
|
95
103
|
},
|
|
96
104
|
],
|
|
97
105
|
result: {
|
|
98
106
|
mode: 'strict',
|
|
99
107
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
100
|
-
|
|
108
|
+
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
101
109
|
},
|
|
102
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
110
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":515,"column":3},
|
|
103
111
|
},
|
|
104
112
|
{
|
|
105
113
|
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
@@ -116,7 +124,7 @@ export const TYPERT_REMOTE = {
|
|
|
116
124
|
codec: {
|
|
117
125
|
mode: 'strict',
|
|
118
126
|
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
119
|
-
|
|
127
|
+
create: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
|
|
120
128
|
},
|
|
121
129
|
},
|
|
122
130
|
],
|
|
@@ -124,9 +132,9 @@ export const TYPERT_REMOTE = {
|
|
|
124
132
|
result: {
|
|
125
133
|
mode: 'strict',
|
|
126
134
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
127
|
-
|
|
135
|
+
create: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
128
136
|
},
|
|
129
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
137
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":420,"column":9},
|
|
130
138
|
},
|
|
131
139
|
{
|
|
132
140
|
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
@@ -142,7 +150,7 @@ export const TYPERT_REMOTE = {
|
|
|
142
150
|
codec: {
|
|
143
151
|
mode: 'strict',
|
|
144
152
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
|
|
145
|
-
|
|
153
|
+
create: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema,
|
|
146
154
|
},
|
|
147
155
|
},
|
|
148
156
|
],
|
|
@@ -150,9 +158,9 @@ export const TYPERT_REMOTE = {
|
|
|
150
158
|
result: {
|
|
151
159
|
mode: 'strict',
|
|
152
160
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
|
|
153
|
-
|
|
161
|
+
create: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
|
|
154
162
|
},
|
|
155
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
163
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":448,"column":9},
|
|
156
164
|
},
|
|
157
165
|
],
|
|
158
166
|
}
|
|
@@ -106,6 +106,8 @@ export declare const SUBAGENT_DELEGATION_CONTEXT: string;
|
|
|
106
106
|
export declare function applyChildComposition(childCtx: Context, parent: Agent, composition: ChildComposition): void;
|
|
107
107
|
/** Policy seeded onto a child session's log at the delegation boundary. */
|
|
108
108
|
export interface DelegatedPolicyOverrides {
|
|
109
|
+
/** The shared-bundle preset identity when the parent currently runs in Auto or Full access. */
|
|
110
|
+
readonly permissionPreset: 'auto' | 'danger-full-access' | undefined;
|
|
109
111
|
/** The parent session's explicit sandbox-mode override, or `undefined` without one. */
|
|
110
112
|
readonly sandboxMode: SandboxMode | undefined;
|
|
111
113
|
/**
|
|
@@ -116,12 +118,13 @@ export interface DelegatedPolicyOverrides {
|
|
|
116
118
|
readonly approvalPolicy: 'never' | undefined;
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
119
|
-
* Capture the
|
|
121
|
+
* Capture the permission state to seed into one delegation. Call synchronously before
|
|
120
122
|
* the child start's first await: a later parent switch belongs to the
|
|
121
|
-
* parent's future, not to this child.
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
123
|
+
* parent's future, not to this child. Auto and Full access identities are
|
|
124
|
+
* inherited only through the in-process DSH path so either can replace a stale
|
|
125
|
+
* same-bundle fork value. Only the parent session's explicit sandbox override
|
|
126
|
+
* is captured — never deployment defaults or one-shot grants — and the approval
|
|
127
|
+
* policy is pinned to `'never'` regardless of the parent's own policy.
|
|
125
128
|
* @param parent - the delegating parent agent.
|
|
126
129
|
* @returns the sandbox override (or `undefined` without one) and the approval pin.
|
|
127
130
|
*/
|
package/lib/types/child-agent.js
CHANGED
|
@@ -172,17 +172,20 @@ export function applyChildComposition(childCtx, parent, composition) {
|
|
|
172
172
|
childCtx.tools.restrict(composition.toolFilter);
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
|
-
* Capture the
|
|
175
|
+
* Capture the permission state to seed into one delegation. Call synchronously before
|
|
176
176
|
* the child start's first await: a later parent switch belongs to the
|
|
177
|
-
* parent's future, not to this child.
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
177
|
+
* parent's future, not to this child. Auto and Full access identities are
|
|
178
|
+
* inherited only through the in-process DSH path so either can replace a stale
|
|
179
|
+
* same-bundle fork value. Only the parent session's explicit sandbox override
|
|
180
|
+
* is captured — never deployment defaults or one-shot grants — and the approval
|
|
181
|
+
* policy is pinned to `'never'` regardless of the parent's own policy.
|
|
181
182
|
* @param parent - the delegating parent agent.
|
|
182
183
|
* @returns the sandbox override (or `undefined` without one) and the approval pin.
|
|
183
184
|
*/
|
|
184
185
|
export function captureDelegatedPolicyOverrides(parent) {
|
|
186
|
+
const preset = parent.ctx.get('permissionPresets')?.current(parent.session);
|
|
185
187
|
return {
|
|
188
|
+
permissionPreset: preset === 'auto' || preset === 'danger-full-access' ? preset : undefined,
|
|
186
189
|
sandboxMode: parent.ctx.get('sandboxPolicy')?.overrideOf(parent.session),
|
|
187
190
|
approvalPolicy: parent.ctx.get('approval') === undefined ? undefined : 'never',
|
|
188
191
|
};
|
|
@@ -203,5 +206,8 @@ export function appendDelegatedPolicyOverrides(childSession, overrides) {
|
|
|
203
206
|
if (overrides.approvalPolicy !== undefined) {
|
|
204
207
|
childSession.append('approval/policy', { policy: overrides.approvalPolicy, source: 'delegation' });
|
|
205
208
|
}
|
|
209
|
+
if (overrides.permissionPreset !== undefined) {
|
|
210
|
+
childSession.append('permission/preset', { preset: overrides.permissionPreset });
|
|
211
|
+
}
|
|
206
212
|
}
|
|
207
213
|
//# sourceMappingURL=child-agent.js.map
|
|
@@ -18,12 +18,22 @@ import type { SubagentDescriptorData } from './descriptor.ts';
|
|
|
18
18
|
import { SubagentInbox } from './inbox.ts';
|
|
19
19
|
import type { SubagentDelivery } from './inbox.ts';
|
|
20
20
|
import type { ActivationObserver } from './lifecycle.ts';
|
|
21
|
+
/** Process-local slots shared through uninterrupted continuable parent links. */
|
|
22
|
+
declare class ActivationPool {
|
|
23
|
+
private readonly slots;
|
|
24
|
+
/** Reserve before reconstruction; the returned release also tolerates unpublished rollback. */
|
|
25
|
+
reserve(capacity: number): () => void;
|
|
26
|
+
}
|
|
21
27
|
/**
|
|
22
28
|
* One residency epoch for a reconstructed continuable child Agent. It directly
|
|
23
29
|
* owns the published `AgentHandle`; the registry's private activation-owner
|
|
24
30
|
* scope is its structural Cordis owner.
|
|
25
31
|
*/
|
|
26
32
|
export interface Activation {
|
|
33
|
+
/** Shared capacity for this Activation and all its continuable descendants. */
|
|
34
|
+
readonly pool: ActivationPool;
|
|
35
|
+
/** Return this epoch's slot after its handle has finished disposal. */
|
|
36
|
+
readonly releaseSlot: () => void;
|
|
27
37
|
/** The durable child this Activation is an epoch of. */
|
|
28
38
|
readonly childId: SessionId;
|
|
29
39
|
/**
|
|
@@ -104,8 +114,11 @@ export declare class ChildLock {
|
|
|
104
114
|
export declare class ContinuableActivationRegistry {
|
|
105
115
|
private readonly ctx;
|
|
106
116
|
private readonly observeActivation;
|
|
117
|
+
private readonly maxActiveSubagents;
|
|
107
118
|
/** Child session id → its live Activation. Process-local, never durable. */
|
|
108
119
|
private readonly resident;
|
|
120
|
+
/** Root identities retain their pool across child settlement without retaining dead roots. */
|
|
121
|
+
private readonly rootPools;
|
|
109
122
|
/** Materializations admitted before drain, tracked through publication or rollback. */
|
|
110
123
|
private readonly materializations;
|
|
111
124
|
/** Per-child serializer shared by delivery, release, and disposal. */
|
|
@@ -125,7 +138,7 @@ export declare class ContinuableActivationRegistry {
|
|
|
125
138
|
* @param ctx - context providing Agents, Sessions, and teardown ownership.
|
|
126
139
|
* @param observeActivation - build the lifecycle observer for one residency epoch.
|
|
127
140
|
*/
|
|
128
|
-
constructor(ctx: Context, observeActivation: (provider: string, childId: SessionId, parent: Agent) => ActivationObserver);
|
|
141
|
+
constructor(ctx: Context, observeActivation: (provider: string, childId: SessionId, parent: Agent) => ActivationObserver, maxActiveSubagents: () => number);
|
|
129
142
|
/**
|
|
130
143
|
* Return the live Activation for a durable child id, if resident.
|
|
131
144
|
* @param childId - durable child session id to look up.
|
|
@@ -227,6 +240,8 @@ export declare class ContinuableActivationRegistry {
|
|
|
227
240
|
private liveLineage;
|
|
228
241
|
/** Return the teardown that closed continuable admission for this agent's lineage. */
|
|
229
242
|
private closingTeardownFor;
|
|
243
|
+
/** Resolve a root's pool once; descendants inherit their resident parent's pool directly. */
|
|
244
|
+
private rootPool;
|
|
230
245
|
/** Perform one tracked materialization through publication or rollback. */
|
|
231
246
|
private materializeTracked;
|
|
232
247
|
/** Release an Activation whose start edge was not published. */
|
|
@@ -248,4 +263,5 @@ export declare class ContinuableActivationRegistry {
|
|
|
248
263
|
/** Request a best-effort final session flush before closing natural-settlement admission. */
|
|
249
264
|
private flushFinalState;
|
|
250
265
|
}
|
|
266
|
+
export {};
|
|
251
267
|
//# sourceMappingURL=continuation-activation.d.ts.map
|
|
@@ -13,6 +13,20 @@ import { appendDelegatedPolicyOverrides, applyChildComposition, } from "./child-
|
|
|
13
13
|
import { createSettlementMessage } from "./continuation-messages.js";
|
|
14
14
|
import { SubagentError } from "./error.js";
|
|
15
15
|
import { SubagentInbox } from "./inbox.js";
|
|
16
|
+
/** Process-local slots shared through uninterrupted continuable parent links. */
|
|
17
|
+
class ActivationPool {
|
|
18
|
+
slots = new Set();
|
|
19
|
+
/** Reserve before reconstruction; the returned release also tolerates unpublished rollback. */
|
|
20
|
+
reserve(capacity) {
|
|
21
|
+
if (this.slots.size >= capacity) {
|
|
22
|
+
throw new SubagentError(`subagent limit reached (active child limit: ${capacity}); wait for an existing child to finish `
|
|
23
|
+
+ 'or complete this work with the current agents', 'ACTIVATION_LIMIT_REACHED');
|
|
24
|
+
}
|
|
25
|
+
const slot = Symbol();
|
|
26
|
+
this.slots.add(slot);
|
|
27
|
+
return () => { this.slots.delete(slot); };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
16
30
|
/** Serialize each durable child's delivery, release, and disposal. */
|
|
17
31
|
export class ChildLock {
|
|
18
32
|
tails = new Map();
|
|
@@ -40,8 +54,11 @@ export class ChildLock {
|
|
|
40
54
|
export class ContinuableActivationRegistry {
|
|
41
55
|
ctx;
|
|
42
56
|
observeActivation;
|
|
57
|
+
maxActiveSubagents;
|
|
43
58
|
/** Child session id → its live Activation. Process-local, never durable. */
|
|
44
59
|
resident = new Map();
|
|
60
|
+
/** Root identities retain their pool across child settlement without retaining dead roots. */
|
|
61
|
+
rootPools = new WeakMap();
|
|
45
62
|
/** Materializations admitted before drain, tracked through publication or rollback. */
|
|
46
63
|
materializations = new Set();
|
|
47
64
|
/** Per-child serializer shared by delivery, release, and disposal. */
|
|
@@ -61,9 +78,10 @@ export class ContinuableActivationRegistry {
|
|
|
61
78
|
* @param ctx - context providing Agents, Sessions, and teardown ownership.
|
|
62
79
|
* @param observeActivation - build the lifecycle observer for one residency epoch.
|
|
63
80
|
*/
|
|
64
|
-
constructor(ctx, observeActivation) {
|
|
81
|
+
constructor(ctx, observeActivation, maxActiveSubagents) {
|
|
65
82
|
this.ctx = ctx;
|
|
66
83
|
this.observeActivation = observeActivation;
|
|
84
|
+
this.maxActiveSubagents = maxActiveSubagents;
|
|
67
85
|
// Ordinary Cordis owner effects unwind in reverse registration order, which
|
|
68
86
|
// cannot express the dynamic child graph. Register the private scope's
|
|
69
87
|
// structural disposer FIRST and the drain SECOND, so reverse unwind invokes
|
|
@@ -305,14 +323,20 @@ export class ContinuableActivationRegistry {
|
|
|
305
323
|
*/
|
|
306
324
|
materialize(inputs) {
|
|
307
325
|
this.assertAdmitting(inputs.parent);
|
|
308
|
-
|
|
326
|
+
inputs.signal.throwIfAborted();
|
|
309
327
|
const lineage = this.liveLineage(inputs.parent);
|
|
328
|
+
const pool = this.resident.get(inputs.parent.id)?.pool ?? this.rootPool(inputs.parent);
|
|
329
|
+
const releaseSlot = pool.reserve(this.maxActiveSubagents());
|
|
330
|
+
const settled = Promise.withResolvers();
|
|
310
331
|
const materialization = {
|
|
311
332
|
lineage,
|
|
312
333
|
settled: settled.promise,
|
|
313
334
|
};
|
|
314
335
|
this.materializations.add(materialization);
|
|
315
|
-
return this.materializeTracked(inputs, lineage).
|
|
336
|
+
return this.materializeTracked(inputs, lineage, pool, releaseSlot).catch((error) => {
|
|
337
|
+
releaseSlot();
|
|
338
|
+
throw error;
|
|
339
|
+
}).finally(() => {
|
|
316
340
|
this.materializations.delete(materialization);
|
|
317
341
|
settled.resolve();
|
|
318
342
|
});
|
|
@@ -400,8 +424,17 @@ export class ContinuableActivationRegistry {
|
|
|
400
424
|
}
|
|
401
425
|
return undefined;
|
|
402
426
|
}
|
|
427
|
+
/** Resolve a root's pool once; descendants inherit their resident parent's pool directly. */
|
|
428
|
+
rootPool(parent) {
|
|
429
|
+
let pool = this.rootPools.get(parent);
|
|
430
|
+
if (pool === undefined) {
|
|
431
|
+
pool = new ActivationPool();
|
|
432
|
+
this.rootPools.set(parent, pool);
|
|
433
|
+
}
|
|
434
|
+
return pool;
|
|
435
|
+
}
|
|
403
436
|
/** Perform one tracked materialization through publication or rollback. */
|
|
404
|
-
async materializeTracked(inputs, parentLineage) {
|
|
437
|
+
async materializeTracked(inputs, parentLineage, pool, releaseSlot) {
|
|
405
438
|
const { childId, provider, parent, create } = inputs;
|
|
406
439
|
inputs.signal.throwIfAborted();
|
|
407
440
|
const setup = (childCtx, child) => {
|
|
@@ -433,6 +466,8 @@ export class ContinuableActivationRegistry {
|
|
|
433
466
|
setup,
|
|
434
467
|
});
|
|
435
468
|
const activation = {
|
|
469
|
+
pool,
|
|
470
|
+
releaseSlot,
|
|
436
471
|
childId,
|
|
437
472
|
parentSession: parent.id,
|
|
438
473
|
provider,
|
|
@@ -471,6 +506,7 @@ export class ContinuableActivationRegistry {
|
|
|
471
506
|
}
|
|
472
507
|
finally {
|
|
473
508
|
this.resident.delete(activation.childId);
|
|
509
|
+
activation.releaseSlot();
|
|
474
510
|
this.releaseOwnership(activation.childId);
|
|
475
511
|
}
|
|
476
512
|
});
|
|
@@ -622,6 +658,7 @@ export class ContinuableActivationRegistry {
|
|
|
622
658
|
+ failures.map(item => errorChain(item)).join('; '), 'ACTIVATION_TEARDOWN_FAILED', { cause: new AggregateError(failures) });
|
|
623
659
|
}
|
|
624
660
|
this.resident.delete(childId);
|
|
661
|
+
activation.releaseSlot();
|
|
625
662
|
this.notifySettlement(activation, activation.observer.terminal(failure));
|
|
626
663
|
this.releaseOwnership(childId);
|
|
627
664
|
activation.observer.settle(failure);
|