@deepseek-ai/dsh-subagent 0.1.6-alpha.2 → 0.1.7-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 +9 -6
- package/README.zh.md +9 -6
- package/lib/index.js +294 -228
- package/lib/typert.host.js +60 -89
- package/lib/typert.remote-client.d.ts +1 -3
- package/lib/typert.remote-client.js +2 -56
- package/lib/types/archive-admission.d.ts +16 -0
- package/lib/types/archive-admission.js +151 -0
- package/lib/types/assistant-output.d.ts +2 -2
- package/lib/types/catalog.d.ts +17 -10
- package/lib/types/catalog.js +12 -6
- package/lib/types/control-types.d.ts +29 -36
- package/lib/types/control-types.js +2 -3
- package/lib/types/control.d.ts +2 -28
- package/lib/types/control.js +2 -40
- package/lib/types/index.d.ts +29 -42
- package/lib/types/index.js +29 -91
- package/lib/types/lifecycle.d.ts +1 -1
- package/lib/types/lifecycle.js +4 -3
- package/lib/types/list-children.d.ts +15 -32
- package/lib/types/list-children.js +45 -49
- package/lib/types/out-of-process.d.ts +1 -1
- package/lib/types/projection-types.d.ts +9 -1
- package/lib/types/projection.d.ts +5 -0
- package/lib/types/projection.js +10 -4
- package/lib/types/run-settlement.js +1 -1
- package/lib/types/types.d.ts +2 -2
- package/package.json +57 -54
package/lib/typert.host.js
CHANGED
|
@@ -11,33 +11,6 @@ let _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value
|
|
|
11
11
|
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value ??= z.object({
|
|
12
12
|
'accepted': z.literal(true).readonly(),
|
|
13
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({
|
|
18
|
-
'entries': z.array(z.union([z.intersection(z.object({
|
|
19
|
-
'kind': z.literal("child").readonly(),
|
|
20
|
-
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
21
|
-
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
22
|
-
'hasChildren': z.boolean().readonly(),
|
|
23
|
-
}), z.object({
|
|
24
|
-
'mode': z.literal("one-shot").readonly(),
|
|
25
|
-
'label': z.string().readonly().optional(),
|
|
26
|
-
})), z.intersection(z.object({
|
|
27
|
-
'kind': z.literal("child").readonly(),
|
|
28
|
-
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
29
|
-
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
30
|
-
'hasChildren': z.boolean().readonly(),
|
|
31
|
-
}), z.object({
|
|
32
|
-
'mode': z.literal("continuable").readonly(),
|
|
33
|
-
'label': z.string().readonly(),
|
|
34
|
-
})), z.object({
|
|
35
|
-
'kind': z.literal("diagnostic").readonly(),
|
|
36
|
-
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
37
|
-
'reason': z.union([z.literal("corrupt"), z.literal("unsupported"), z.literal("unavailable")]).readonly(),
|
|
38
|
-
})])).readonly(),
|
|
39
|
-
'parentAvailable': z.boolean().readonly(),
|
|
40
|
-
}))
|
|
41
14
|
let _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value
|
|
42
15
|
const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value ??= z.object({
|
|
43
16
|
'requestId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
@@ -110,34 +83,7 @@ export const TYPERT = {
|
|
|
110
83
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
111
84
|
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
112
85
|
},
|
|
113
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
117
|
-
service: 'subagents',
|
|
118
|
-
namespace: 'subagents',
|
|
119
|
-
method: 'list',
|
|
120
|
-
implementation: 'remoteExportList',
|
|
121
|
-
invocation: { kind: 'direct' },
|
|
122
|
-
parameters: [
|
|
123
|
-
{
|
|
124
|
-
name: 'parentSessionId',
|
|
125
|
-
wire: 'parentSessionId',
|
|
126
|
-
source: 'json',
|
|
127
|
-
codec: {
|
|
128
|
-
mode: 'strict',
|
|
129
|
-
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
130
|
-
create: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
cancellation: { parameter: 'signal' },
|
|
135
|
-
result: {
|
|
136
|
-
mode: 'strict',
|
|
137
|
-
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
138
|
-
create: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
139
|
-
},
|
|
140
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":420,"column":9},
|
|
86
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":483,"column":3},
|
|
141
87
|
},
|
|
142
88
|
{
|
|
143
89
|
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
@@ -163,7 +109,7 @@ export const TYPERT = {
|
|
|
163
109
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
|
|
164
110
|
create: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
|
|
165
111
|
},
|
|
166
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
112
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":416,"column":9},
|
|
167
113
|
},
|
|
168
114
|
],
|
|
169
115
|
model: {
|
|
@@ -221,23 +167,16 @@ export const TYPERT = {
|
|
|
221
167
|
{
|
|
222
168
|
"kind": "method",
|
|
223
169
|
"name": "listChildren",
|
|
224
|
-
"signature": "listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<
|
|
225
|
-
"summary": "
|
|
226
|
-
"jsDoc": "/**\n *
|
|
170
|
+
"signature": "listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentCatalogEntry[]>",
|
|
171
|
+
"summary": "Read the parent's durable direct-child catalog without loading or resuming an Agent.",
|
|
172
|
+
"jsDoc": "/**\n * Read the parent's durable direct-child catalog without loading or resuming an Agent.\n * The service owns and releases the live-preferred Session observation.\n * @param parentSessionId - parent whose direct children are requested.\n * @param signal - cancellation forwarded to the Session query.\n * @returns catalog children in parent event order.\n * @throws {@link SubagentError} when query or catalog projection is unavailable.\n * @throws SessionQueryError when the parent cannot be read or the query is cancelled.\n */"
|
|
227
173
|
},
|
|
228
174
|
{
|
|
229
175
|
"kind": "method",
|
|
230
176
|
"name": "listDescendants",
|
|
231
177
|
"signature": "listDescendants(rootSessionId: SessionId, signal?: AbortSignal): Promise<SubagentDescendantListEntry[]>",
|
|
232
178
|
"summary": "Enumerate the root's complete session-backed subagent tree in stable pre-order from one live-preferred corpus, without loading or resuming an Agent.",
|
|
233
|
-
"jsDoc": "/**\n * Enumerate the root's complete session-backed subagent tree in stable\n * pre-order from one live-preferred corpus, without loading or resuming an\n * Agent. Ordinary sessions and one-shot children remain traversal nodes so\n * continuable descendants below them are discovered; each returned entry\n * adds its durable `parentId` and root-relative `depth`. Identity resolution,\n * diagnostics, optional persistence, and cancellation
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"kind": "method",
|
|
237
|
-
"name": "remoteExportList",
|
|
238
|
-
"signature": "@Remote('list') async remoteExportList(parentSessionId: SessionId, signal: AbortSignal): Promise<SubagentCatalog>",
|
|
239
|
-
"summary": "Remote face of {@link listChildren} for one browser: the durable listing plus live Agent activity and the delivery-time parent availability hint.",
|
|
240
|
-
"jsDoc": "/**\n * Remote face of {@link listChildren} for one browser: the durable listing\n * plus live Agent activity and the delivery-time parent availability hint.\n * Parent availability is a hint; {@link prompt} performs the authoritative\n * check. Named apart from the provider-name {@link list}, which owns the\n * member.\n * @param parentSessionId - parent session whose direct children are listed.\n * @param signal - carrier cancellation forwarded to Session queries.\n * @returns the catalog view for that parent.\n * @throws {RemoteError} `gateway/bad-request` for an empty parent id,\n * `gateway/cancelled` for an aborted read, `subagent/projections-unavailable` when\n * the deployment has no projection registry, otherwise `gateway/internal`.\n */"
|
|
179
|
+
"jsDoc": "/**\n * Enumerate the root's complete session-backed subagent tree in stable\n * pre-order from one live-preferred corpus, without loading or resuming an\n * Agent. Ordinary sessions and one-shot children remain traversal nodes so\n * continuable descendants below them are discovered; each returned entry\n * adds its durable `parentId` and root-relative `depth`. Identity resolution,\n * diagnostics, optional persistence, and cancellation use the registered\n * child identity projection and complete Session corpus.\n * @param rootSessionId - session whose complete descendant tree is listed.\n * @param signal - caller-owned cancellation forwarded to persistence reads\n * and observed around every read await.\n * @returns children and per-candidate diagnostics with tree position, in\n * stable pre-order.\n * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.\n */"
|
|
241
180
|
},
|
|
242
181
|
{
|
|
243
182
|
"kind": "method",
|
|
@@ -317,7 +256,7 @@ export const TYPERT = {
|
|
|
317
256
|
},
|
|
318
257
|
{
|
|
319
258
|
"name": "AssistantMessage",
|
|
320
|
-
"declaration": "export interface AssistantMessage extends
|
|
259
|
+
"declaration": "export interface AssistantMessage extends MessageBase {\n readonly role: 'assistant';\n readonly source: ModelMessageSource;\n}"
|
|
321
260
|
},
|
|
322
261
|
{
|
|
323
262
|
"name": "AssistantProviderMetadata",
|
|
@@ -355,6 +294,10 @@ export const TYPERT = {
|
|
|
355
294
|
"name": "CommandSourceMap",
|
|
356
295
|
"declaration": "export interface CommandSourceMap {\n user: { kind: 'user'; };\n}"
|
|
357
296
|
},
|
|
297
|
+
{
|
|
298
|
+
"name": "CompactionCheckpointSource",
|
|
299
|
+
"declaration": "export type CompactionCheckpointSource = typeof COMPACT_CHECKPOINT_MARKER & { readonly compactionId: CompactionId; readonly sourceCommandId?: CommandId; };"
|
|
300
|
+
},
|
|
358
301
|
{
|
|
359
302
|
"name": "CompactionId",
|
|
360
303
|
"declaration": "export type CompactionId = Branded<'CompactionId'>;"
|
|
@@ -365,7 +308,7 @@ export const TYPERT = {
|
|
|
365
308
|
},
|
|
366
309
|
{
|
|
367
310
|
"name": "ContentBlockMap",
|
|
368
|
-
"declaration": "export interface ContentBlockMap {\n text: TextBlock;\n reasoning: ReasoningBlock;\n image: ImageBlock;\n file: FileBlock;\n 'tool-call': ToolCallBlock;\n 'tool-
|
|
311
|
+
"declaration": "export interface ContentBlockMap {\n text: TextBlock;\n reasoning: ReasoningBlock;\n image: ImageBlock;\n file: FileBlock;\n 'tool-call': ToolCallBlock;\n 'tool-addition': ToolAdditionBlock;\n 'tool-removal': ToolRemovalBlock;\n}"
|
|
369
312
|
},
|
|
370
313
|
{
|
|
371
314
|
"name": "ContentBlockType",
|
|
@@ -399,9 +342,13 @@ export const TYPERT = {
|
|
|
399
342
|
"name": "ContinuableSubagentDescriptorData",
|
|
400
343
|
"declaration": "export interface ContinuableSubagentDescriptorData extends SubagentDescriptorBase {\n readonly mode: 'continuable';\n readonly label: string;\n readonly agentProvider?: string;\n readonly agentModel?: string;\n readonly agentReasoningEffort?: ReasoningEffortId;\n readonly persona?: string;\n readonly toolFilter?: ToolRestriction;\n}"
|
|
401
344
|
},
|
|
345
|
+
{
|
|
346
|
+
"name": "DeveloperMessage",
|
|
347
|
+
"declaration": "export interface DeveloperMessage extends MessageBase {\n readonly role: 'developer';\n}"
|
|
348
|
+
},
|
|
402
349
|
{
|
|
403
350
|
"name": "EpochHeader",
|
|
404
|
-
"declaration": "export interface EpochHeader {\n config: LlmCallConfig;\n adapterDefaults?: LlmCallConfigAdapterDefaults;\n tools?: ToolSchema[];\n}"
|
|
351
|
+
"declaration": "export interface EpochHeader {\n config: LlmCallConfig;\n adapterDefaults?: LlmCallConfigAdapterDefaults;\n tools?: ToolSchema[];\n system?: never;\n}"
|
|
405
352
|
},
|
|
406
353
|
{
|
|
407
354
|
"name": "FeedbackCategory",
|
|
@@ -507,6 +454,10 @@ export const TYPERT = {
|
|
|
507
454
|
"name": "JsonValue",
|
|
508
455
|
"declaration": "export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue; };"
|
|
509
456
|
},
|
|
457
|
+
{
|
|
458
|
+
"name": "KnownCatalogMode",
|
|
459
|
+
"declaration": "export type KnownCatalogMode = { readonly mode: 'one-shot'; readonly label?: string; } | { readonly mode: 'continuable'; readonly label: string; };"
|
|
460
|
+
},
|
|
510
461
|
{
|
|
511
462
|
"name": "LlmCallConfig",
|
|
512
463
|
"declaration": "export interface LlmCallConfig {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n}"
|
|
@@ -521,7 +472,11 @@ export const TYPERT = {
|
|
|
521
472
|
},
|
|
522
473
|
{
|
|
523
474
|
"name": "Message",
|
|
524
|
-
"declaration": "export
|
|
475
|
+
"declaration": "export type Message = MessageRoleMap[keyof MessageRoleMap];"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"name": "MessageBase",
|
|
479
|
+
"declaration": "export interface MessageBase {\n readonly id: MessageId;\n readonly content: readonly ContentBlock[];\n readonly source: MessageSource;\n}"
|
|
525
480
|
},
|
|
526
481
|
{
|
|
527
482
|
"name": "MessageFeedbackDelete",
|
|
@@ -547,13 +502,17 @@ export const TYPERT = {
|
|
|
547
502
|
"name": "MessageId",
|
|
548
503
|
"declaration": "export type MessageId = Branded<'MessageId'>;"
|
|
549
504
|
},
|
|
505
|
+
{
|
|
506
|
+
"name": "MessageRoleMap",
|
|
507
|
+
"declaration": "export interface MessageRoleMap {\n system: SystemMessage;\n developer: DeveloperMessage;\n user: UserMessage;\n assistant: AssistantMessage;\n tool: ToolResultMessage;\n}"
|
|
508
|
+
},
|
|
550
509
|
{
|
|
551
510
|
"name": "MessageSource",
|
|
552
511
|
"declaration": "export type MessageSource = MessageSourceMap[keyof MessageSourceMap];"
|
|
553
512
|
},
|
|
554
513
|
{
|
|
555
514
|
"name": "MessageSourceMap",
|
|
556
|
-
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n
|
|
515
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'tool-registry': { kind: 'tool-registry'; };\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n 'team-message': TeamMessageSource;\n goal: GoalMessageSource;\n 'compact-checkpoint': CompactionCheckpointSource;\n 'session-reference': SessionReferenceSource;\n}"
|
|
557
516
|
},
|
|
558
517
|
{
|
|
559
518
|
"name": "ModelMessageSource",
|
|
@@ -621,7 +580,7 @@ export const TYPERT = {
|
|
|
621
580
|
},
|
|
622
581
|
{
|
|
623
582
|
"name": "Session",
|
|
624
|
-
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
583
|
+
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
625
584
|
},
|
|
626
585
|
{
|
|
627
586
|
"name": "SessionEvent",
|
|
@@ -629,7 +588,7 @@ export const TYPERT = {
|
|
|
629
588
|
},
|
|
630
589
|
{
|
|
631
590
|
"name": "SessionEventMap",
|
|
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}"
|
|
591
|
+
"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 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\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}"
|
|
633
592
|
},
|
|
634
593
|
{
|
|
635
594
|
"name": "SessionEventType",
|
|
@@ -692,12 +651,16 @@ export const TYPERT = {
|
|
|
692
651
|
"declaration": "export interface SubagentCapabilities {\n readonly agentOptions: boolean;\n readonly outputSchema: boolean;\n readonly depthLimit: boolean;\n readonly toolFilter: boolean;\n readonly persona: boolean;\n}"
|
|
693
652
|
},
|
|
694
653
|
{
|
|
695
|
-
"name": "
|
|
696
|
-
"declaration": "export
|
|
654
|
+
"name": "SubagentCatalogEntry",
|
|
655
|
+
"declaration": "export type SubagentCatalogEntry = { readonly id: SessionId; readonly createdAt: number; } & ({ readonly mode: 'one-shot'; readonly label?: string; } | { readonly mode: 'continuable'; readonly label: string; } | { readonly mode: 'unknown'; readonly label?: string; });"
|
|
697
656
|
},
|
|
698
657
|
{
|
|
699
658
|
"name": "SubagentCatalogEvent",
|
|
700
|
-
"declaration": "export type SubagentCatalogEvent = { readonly
|
|
659
|
+
"declaration": "export type SubagentCatalogEvent = { readonly childId: SessionId; readonly childCreatedAt: number; } & (({ readonly version: 0; } & KnownCatalogMode) | ({ readonly version: 1; } & (KnownCatalogMode | { readonly mode: 'unknown'; readonly label?: string; })));"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"name": "SubagentCatalogRow",
|
|
663
|
+
"declaration": "export type SubagentCatalogRow = { readonly id: SessionId; readonly activity: 'running' | 'inactive'; } & ({ readonly mode: 'one-shot'; readonly label?: string; } | { readonly mode: 'continuable'; readonly label: string; });"
|
|
701
664
|
},
|
|
702
665
|
{
|
|
703
666
|
"name": "SubagentDescendantListEntry",
|
|
@@ -721,7 +684,7 @@ export const TYPERT = {
|
|
|
721
684
|
},
|
|
722
685
|
{
|
|
723
686
|
"name": "SubagentListEntry",
|
|
724
|
-
"declaration": "export type SubagentListEntry = { readonly kind: 'child'; readonly
|
|
687
|
+
"declaration": "export type SubagentListEntry = SubagentCatalogRow & { readonly kind: 'child'; readonly hasChildren: boolean; } | { readonly kind: 'diagnostic'; readonly id: SessionId; readonly reason: 'corrupt' | 'unsupported' | 'unavailable'; };"
|
|
725
688
|
},
|
|
726
689
|
{
|
|
727
690
|
"name": "SubagentPromptReceipt",
|
|
@@ -741,7 +704,7 @@ export const TYPERT = {
|
|
|
741
704
|
},
|
|
742
705
|
{
|
|
743
706
|
"name": "SubagentResult",
|
|
744
|
-
"declaration": "export interface SubagentResult {\n readonly output: ContentBlock[];\n readonly structured?: unknown;\n readonly diagnostic?: string;\n readonly stopReason: SubagentStopReason;\n}"
|
|
707
|
+
"declaration": "export interface SubagentResult {\n readonly output: readonly ContentBlock[];\n readonly structured?: unknown;\n readonly diagnostic?: string;\n readonly stopReason: SubagentStopReason;\n}"
|
|
745
708
|
},
|
|
746
709
|
{
|
|
747
710
|
"name": "SubagentRun",
|
|
@@ -769,7 +732,7 @@ export const TYPERT = {
|
|
|
769
732
|
},
|
|
770
733
|
{
|
|
771
734
|
"name": "SurfaceEventType",
|
|
772
|
-
"declaration": "export type SurfaceEventType = 'system/message' | 'user/message' | 'assistant/message' | 'tool/result';"
|
|
735
|
+
"declaration": "export type SurfaceEventType = 'system/message' | 'developer/message' | 'user/message' | 'assistant/message' | 'tool/result';"
|
|
773
736
|
},
|
|
774
737
|
{
|
|
775
738
|
"name": "SurfaceIntent",
|
|
@@ -781,7 +744,11 @@ export const TYPERT = {
|
|
|
781
744
|
},
|
|
782
745
|
{
|
|
783
746
|
"name": "SystemMessage",
|
|
784
|
-
"declaration": "export interface SystemMessage extends
|
|
747
|
+
"declaration": "export interface SystemMessage extends MessageBase {\n readonly role: 'system';\n readonly source: MessageSourceMap['system-prompt'];\n}"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
"name": "SystemPromptMessageSource",
|
|
751
|
+
"declaration": "export interface SystemPromptMessageSource {\n kind: 'system-prompt';\n}"
|
|
785
752
|
},
|
|
786
753
|
{
|
|
787
754
|
"name": "SystemPromptUpdate",
|
|
@@ -835,6 +802,10 @@ export const TYPERT = {
|
|
|
835
802
|
"name": "TokenUsage",
|
|
836
803
|
"declaration": "export interface TokenUsage {\n inputTokens: number;\n outputTokens: number;\n totalTokens?: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n reasoningTokens?: number;\n}"
|
|
837
804
|
},
|
|
805
|
+
{
|
|
806
|
+
"name": "ToolAdditionBlock",
|
|
807
|
+
"declaration": "export interface ToolAdditionBlock {\n type: 'tool-addition';\n toolName: string;\n tool?: never;\n}"
|
|
808
|
+
},
|
|
838
809
|
{
|
|
839
810
|
"name": "ToolCallBlock",
|
|
840
811
|
"declaration": "export interface ToolCallBlock {\n type: 'tool-call';\n id: ToolCallId;\n name: string;\n arguments: string;\n}"
|
|
@@ -848,20 +819,20 @@ export const TYPERT = {
|
|
|
848
819
|
"declaration": "export interface ToolMessageSource {\n kind: 'tool';\n callId: ToolCallId;\n}"
|
|
849
820
|
},
|
|
850
821
|
{
|
|
851
|
-
"name": "
|
|
852
|
-
"declaration": "export interface
|
|
822
|
+
"name": "ToolRemovalBlock",
|
|
823
|
+
"declaration": "export interface ToolRemovalBlock {\n type: 'tool-removal';\n toolName: string;\n}"
|
|
853
824
|
},
|
|
854
825
|
{
|
|
855
|
-
"name": "
|
|
856
|
-
"declaration": "export interface
|
|
826
|
+
"name": "ToolRestriction",
|
|
827
|
+
"declaration": "export interface ToolRestriction {\n readonly allow?: readonly string[];\n readonly deny?: readonly string[];\n}"
|
|
857
828
|
},
|
|
858
829
|
{
|
|
859
830
|
"name": "ToolResultMessage",
|
|
860
|
-
"declaration": "export interface ToolResultMessage extends
|
|
831
|
+
"declaration": "export interface ToolResultMessage extends MessageBase {\n readonly role: 'tool';\n readonly source: ToolMessageSource;\n readonly toolCallId: ToolCallId;\n readonly isError?: boolean;\n}"
|
|
861
832
|
},
|
|
862
833
|
{
|
|
863
834
|
"name": "ToolSchema",
|
|
864
|
-
"declaration": "export interface ToolSchema {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n}"
|
|
835
|
+
"declaration": "export interface ToolSchema {\n deferLoading?: true;\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n}"
|
|
865
836
|
},
|
|
866
837
|
{
|
|
867
838
|
"name": "TurnEndCancelCause",
|
|
@@ -873,11 +844,11 @@ export const TYPERT = {
|
|
|
873
844
|
},
|
|
874
845
|
{
|
|
875
846
|
"name": "TurnEndReasonMap",
|
|
876
|
-
"declaration": "export interface TurnEndReasonMap {\n completed: { kind: 'completed'; };\n aborted: { kind: 'aborted'; reason: TurnEndCancelCause; };\n blocked: { kind: 'blocked'; };\n error: { kind: 'error'; error: LlmFailure; };\n 'max-tokens': { kind: 'max-tokens'; };\n interrupted: { kind: 'interrupted'; };\n}"
|
|
847
|
+
"declaration": "export interface TurnEndReasonMap {\n completed: { kind: 'completed'; };\n aborted: { kind: 'aborted'; reason: TurnEndCancelCause; };\n blocked: { kind: 'blocked'; };\n error: { kind: 'error'; error: LlmFailure; };\n 'max-tokens': { kind: 'max-tokens'; };\n interrupted: { kind: 'interrupted'; };\n forked: { kind: 'forked'; };\n}"
|
|
877
848
|
},
|
|
878
849
|
{
|
|
879
850
|
"name": "UserMessage",
|
|
880
|
-
"declaration": "export interface UserMessage extends
|
|
851
|
+
"declaration": "export interface UserMessage extends MessageBase {\n readonly role: 'user';\n}"
|
|
881
852
|
}
|
|
882
853
|
]
|
|
883
854
|
}
|
|
@@ -4,17 +4,15 @@ import type {
|
|
|
4
4
|
TypertRemoteContribution,
|
|
5
5
|
} from '@deepseek-ai/dsh-typert-protocol'
|
|
6
6
|
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
7
|
-
import type {
|
|
7
|
+
import type { SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from '@deepseek-ai/dsh-subagent/client'
|
|
8
8
|
|
|
9
9
|
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
10
10
|
interface TypertRemoteNamespace$7375626167656e7473 {
|
|
11
11
|
interruptByParent: (childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable') => Promise<RemoteResult<SubagentInterruptReceipt>>
|
|
12
|
-
list: (parentSessionId: SessionId, signal?: AbortSignal) => Promise<RemoteResult<SubagentCatalog>>
|
|
13
12
|
prompt: (request: SubagentPromptRequest, signal?: AbortSignal) => Promise<RemoteResult<SubagentPromptReceipt>>
|
|
14
13
|
}
|
|
15
14
|
interface TypertRemoteMap {
|
|
16
15
|
'subagents/interruptByParent': (childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable') => Promise<RemoteResult<SubagentInterruptReceipt>>
|
|
17
|
-
'subagents/list': (parentSessionId: SessionId, signal?: AbortSignal) => Promise<RemoteResult<SubagentCatalog>>
|
|
18
16
|
'subagents/prompt': (request: SubagentPromptRequest, signal?: AbortSignal) => Promise<RemoteResult<SubagentPromptReceipt>>
|
|
19
17
|
}
|
|
20
18
|
interface TypertRemoteNamespaceMap {
|
|
@@ -11,33 +11,6 @@ let _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value
|
|
|
11
11
|
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value ??= z.object({
|
|
12
12
|
'accepted': z.literal(true).readonly(),
|
|
13
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({
|
|
18
|
-
'entries': z.array(z.union([z.intersection(z.object({
|
|
19
|
-
'kind': z.literal("child").readonly(),
|
|
20
|
-
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
21
|
-
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
22
|
-
'hasChildren': z.boolean().readonly(),
|
|
23
|
-
}), z.object({
|
|
24
|
-
'mode': z.literal("one-shot").readonly(),
|
|
25
|
-
'label': z.string().readonly().optional(),
|
|
26
|
-
})), z.intersection(z.object({
|
|
27
|
-
'kind': z.literal("child").readonly(),
|
|
28
|
-
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
29
|
-
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
30
|
-
'hasChildren': z.boolean().readonly(),
|
|
31
|
-
}), z.object({
|
|
32
|
-
'mode': z.literal("continuable").readonly(),
|
|
33
|
-
'label': z.string().readonly(),
|
|
34
|
-
})), z.object({
|
|
35
|
-
'kind': z.literal("diagnostic").readonly(),
|
|
36
|
-
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
37
|
-
'reason': z.union([z.literal("corrupt"), z.literal("unsupported"), z.literal("unavailable")]).readonly(),
|
|
38
|
-
})])).readonly(),
|
|
39
|
-
'parentAvailable': z.boolean().readonly(),
|
|
40
|
-
}))
|
|
41
14
|
let _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value
|
|
42
15
|
const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value ??= z.object({
|
|
43
16
|
'requestId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
@@ -107,34 +80,7 @@ export const TYPERT_REMOTE = {
|
|
|
107
80
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
108
81
|
create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
109
82
|
},
|
|
110
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
114
|
-
service: 'subagents',
|
|
115
|
-
namespace: 'subagents',
|
|
116
|
-
method: 'list',
|
|
117
|
-
implementation: 'remoteExportList',
|
|
118
|
-
invocation: { kind: 'direct' },
|
|
119
|
-
parameters: [
|
|
120
|
-
{
|
|
121
|
-
name: 'parentSessionId',
|
|
122
|
-
wire: 'parentSessionId',
|
|
123
|
-
source: 'json',
|
|
124
|
-
codec: {
|
|
125
|
-
mode: 'strict',
|
|
126
|
-
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
127
|
-
create: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
cancellation: { parameter: 'signal' },
|
|
132
|
-
result: {
|
|
133
|
-
mode: 'strict',
|
|
134
|
-
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
135
|
-
create: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
136
|
-
},
|
|
137
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":420,"column":9},
|
|
83
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":483,"column":3},
|
|
138
84
|
},
|
|
139
85
|
{
|
|
140
86
|
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
@@ -160,7 +106,7 @@ export const TYPERT_REMOTE = {
|
|
|
160
106
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
|
|
161
107
|
create: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
|
|
162
108
|
},
|
|
163
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
109
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":416,"column":9},
|
|
164
110
|
},
|
|
165
111
|
],
|
|
166
112
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `subagent` family of the Workspace registry's archive admission: which
|
|
3
|
+
* subagent descendants of a Session are still inside a turn, and how they
|
|
4
|
+
* stop when the Session is archived with its work.
|
|
5
|
+
*
|
|
6
|
+
* @module @deepseek-ai/dsh-subagent
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
/**
|
|
10
|
+
* Answer `workspace/session-activity` with the running subagent descendants of
|
|
11
|
+
* the asked Session, and `workspace/session-stop` by cancelling each of them
|
|
12
|
+
* as their parent would. Both listeners live as long as `ctx`'s fiber.
|
|
13
|
+
* @param ctx - context carrying the Agent registry; the Session query service is optional and only supplies labels.
|
|
14
|
+
*/
|
|
15
|
+
export declare function installSubagentArchiveAdmission(ctx: Context): void;
|
|
16
|
+
//# sourceMappingURL=archive-admission.d.ts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `subagent` family of the Workspace registry's archive admission: which
|
|
3
|
+
* subagent descendants of a Session are still inside a turn, and how they
|
|
4
|
+
* stop when the Session is archived with its work.
|
|
5
|
+
*
|
|
6
|
+
* @module @deepseek-ai/dsh-subagent
|
|
7
|
+
*/
|
|
8
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
9
|
+
if (value !== null && value !== void 0) {
|
|
10
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
11
|
+
var dispose, inner;
|
|
12
|
+
if (async) {
|
|
13
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
14
|
+
dispose = value[Symbol.asyncDispose];
|
|
15
|
+
}
|
|
16
|
+
if (dispose === void 0) {
|
|
17
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
18
|
+
dispose = value[Symbol.dispose];
|
|
19
|
+
if (async) inner = dispose;
|
|
20
|
+
}
|
|
21
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
22
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
23
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
24
|
+
}
|
|
25
|
+
else if (async) {
|
|
26
|
+
env.stack.push({ async: true });
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
31
|
+
return function (env) {
|
|
32
|
+
function fail(e) {
|
|
33
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
34
|
+
env.hasError = true;
|
|
35
|
+
}
|
|
36
|
+
var r, s = 0;
|
|
37
|
+
function next() {
|
|
38
|
+
while (r = env.stack.pop()) {
|
|
39
|
+
try {
|
|
40
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
41
|
+
if (r.dispose) {
|
|
42
|
+
var result = r.dispose.call(r.value);
|
|
43
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
44
|
+
}
|
|
45
|
+
else s |= 1;
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
fail(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
52
|
+
if (env.hasError) throw env.error;
|
|
53
|
+
}
|
|
54
|
+
return next();
|
|
55
|
+
};
|
|
56
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
57
|
+
var e = new Error(message);
|
|
58
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
59
|
+
});
|
|
60
|
+
import { foldSubagentDescriptor } from "./descriptor.js";
|
|
61
|
+
/**
|
|
62
|
+
* Answer `workspace/session-activity` with the running subagent descendants of
|
|
63
|
+
* the asked Session, and `workspace/session-stop` by cancelling each of them
|
|
64
|
+
* as their parent would. Both listeners live as long as `ctx`'s fiber.
|
|
65
|
+
* @param ctx - context carrying the Agent registry; the Session query service is optional and only supplies labels.
|
|
66
|
+
*/
|
|
67
|
+
export function installSubagentArchiveAdmission(ctx) {
|
|
68
|
+
ctx.on('workspace/session-activity', async ({ sessionId }, next) => {
|
|
69
|
+
const running = runningDescendants(ctx, sessionId);
|
|
70
|
+
const rest = await next();
|
|
71
|
+
if (running.length === 0)
|
|
72
|
+
return rest;
|
|
73
|
+
const own = { kind: 'subagent', items: await Promise.all(running.map(child => describe(ctx, child))) };
|
|
74
|
+
return [own, ...rest];
|
|
75
|
+
});
|
|
76
|
+
ctx.on('workspace/session-stop', ({ sessionId }) => {
|
|
77
|
+
for (const child of runningDescendants(ctx, sessionId)) {
|
|
78
|
+
try {
|
|
79
|
+
child.cancel({ kind: 'parent' });
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// One child refusing its cancel must not keep its siblings running for an archived parent.
|
|
83
|
+
ctx.logger.warn(`subagent: cancelling "${child.id}" for an archived Session failed: ${String(error)}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Live subagent descendants inside a turn, by durable lineage: a child whose
|
|
90
|
+
* header names its parent and carries the subagent origin this package
|
|
91
|
+
* records, at any depth. A fork shares the lineage field without the origin
|
|
92
|
+
* and is an independent conversation, so it never holds its source. Lineage
|
|
93
|
+
* is read as data, so a damaged header chain that loops is visited once.
|
|
94
|
+
*/
|
|
95
|
+
function runningDescendants(ctx, rootId) {
|
|
96
|
+
const childrenOf = new Map();
|
|
97
|
+
for (const agent of ctx.agents.list()) {
|
|
98
|
+
const { parentSession, origin } = agent.session.header;
|
|
99
|
+
if (parentSession === undefined || origin !== 'subagent')
|
|
100
|
+
continue;
|
|
101
|
+
const siblings = childrenOf.get(parentSession) ?? [];
|
|
102
|
+
siblings.push(agent);
|
|
103
|
+
childrenOf.set(parentSession, siblings);
|
|
104
|
+
}
|
|
105
|
+
const running = [];
|
|
106
|
+
const pending = [rootId];
|
|
107
|
+
const visited = new Set();
|
|
108
|
+
while (pending.length > 0) {
|
|
109
|
+
const parentId = pending.shift();
|
|
110
|
+
if (visited.has(parentId))
|
|
111
|
+
continue;
|
|
112
|
+
visited.add(parentId);
|
|
113
|
+
for (const child of childrenOf.get(parentId) ?? []) {
|
|
114
|
+
if (child.status === 'running')
|
|
115
|
+
running.push(child);
|
|
116
|
+
pending.push(child.id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return running;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The child's activity item: its id, plus the durable creation label its
|
|
123
|
+
* descriptor carries, read through a live Session observation. Without the
|
|
124
|
+
* Session query service, or with a descriptor that is absent or unreadable,
|
|
125
|
+
* the item names the child by id alone.
|
|
126
|
+
*/
|
|
127
|
+
async function describe(ctx, child) {
|
|
128
|
+
const query = ctx.get('sessionQuery');
|
|
129
|
+
if (query === undefined)
|
|
130
|
+
return { id: child.id };
|
|
131
|
+
try {
|
|
132
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
133
|
+
try {
|
|
134
|
+
const observation = __addDisposableResource(env_1, await query.observeSession(child.id, { projectionMode: 'none' }), false);
|
|
135
|
+
const label = foldSubagentDescriptor(observation.events.slice(observation.inheritedEventCount))?.label;
|
|
136
|
+
return label === undefined ? { id: child.id } : { id: child.id, label };
|
|
137
|
+
}
|
|
138
|
+
catch (e_1) {
|
|
139
|
+
env_1.error = e_1;
|
|
140
|
+
env_1.hasError = true;
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
__disposeResources(env_1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// A damaged descriptor is data damage in the child; the report still names the child.
|
|
148
|
+
return { id: child.id };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=archive-admission.js.map
|
|
@@ -37,12 +37,12 @@ export declare class AssistantOutputFold {
|
|
|
37
37
|
* @returns the last non-empty assistant message, else the accumulated
|
|
38
38
|
* streamed text, or `undefined` when the child produced neither.
|
|
39
39
|
*/
|
|
40
|
-
collect(): ContentBlock[] | undefined;
|
|
40
|
+
collect(): readonly ContentBlock[] | undefined;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Apply the selection rule to one complete child-owned event suffix.
|
|
44
44
|
* @param events - the child-owned events (after any seed or epoch boundary).
|
|
45
45
|
* @returns the selected output, or `undefined` when the child produced none.
|
|
46
46
|
*/
|
|
47
|
-
export declare function finalAssistantOutput(events: readonly SessionEvent[]): ContentBlock[] | undefined;
|
|
47
|
+
export declare function finalAssistantOutput(events: readonly SessionEvent[]): readonly ContentBlock[] | undefined;
|
|
48
48
|
//# sourceMappingURL=assistant-output.d.ts.map
|