@deepseek-ai/dsh-subagent 0.1.2-alpha.5 → 0.1.3-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 +11 -7
- package/README.zh.md +11 -7
- package/lib/index.js +958 -914
- package/lib/typert.host.js +44 -11
- package/lib/typert.remote-client.js +3 -2
- package/lib/types/assistant-output.d.ts +3 -3
- package/lib/types/assistant-output.js +5 -4
- package/lib/types/child-agent.js +2 -2
- package/lib/types/continuation-activation.d.ts +251 -0
- package/lib/types/continuation-activation.js +663 -0
- package/lib/types/continuation-messages.d.ts +62 -0
- package/lib/types/continuation-messages.js +102 -0
- package/lib/types/continuation.d.ts +44 -358
- package/lib/types/continuation.js +135 -987
- package/lib/types/control-types.d.ts +2 -0
- package/lib/types/control.d.ts +4 -0
- package/lib/types/control.js +1 -0
- package/lib/types/inbox.d.ts +43 -0
- package/lib/types/inbox.js +61 -0
- package/lib/types/index.d.ts +11 -11
- package/lib/types/index.js +14 -12
- package/lib/types/internal.d.ts +17 -5
- package/lib/types/internal.js +16 -3
- package/lib/types/out-of-process.d.ts +1 -1
- package/lib/types/out-of-process.js +1 -1
- package/lib/types/types.d.ts +46 -2
- package/package.json +44 -44
- package/lib/types/descriptor-seed.d.ts +0 -21
- package/lib/types/descriptor-seed.js +0 -24
package/lib/typert.host.js
CHANGED
|
@@ -37,6 +37,7 @@ const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = z.object({
|
|
|
37
37
|
'parentSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
38
38
|
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
39
39
|
'mode': z.literal("continuable").readonly(),
|
|
40
|
+
'delivery': z.union([z.literal("queue"), z.literal("steer")]).readonly(),
|
|
40
41
|
'content': z.array(z.union([z.object({
|
|
41
42
|
'type': z.literal("text").readonly(),
|
|
42
43
|
'text': z.string().readonly(),
|
|
@@ -101,7 +102,7 @@ export const TYPERT = {
|
|
|
101
102
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
102
103
|
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
103
104
|
},
|
|
104
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
105
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":477,"column":3},
|
|
105
106
|
},
|
|
106
107
|
{
|
|
107
108
|
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
@@ -128,7 +129,7 @@ export const TYPERT = {
|
|
|
128
129
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
129
130
|
schema: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
130
131
|
},
|
|
131
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
132
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":383,"column":9},
|
|
132
133
|
},
|
|
133
134
|
{
|
|
134
135
|
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
@@ -228,7 +229,7 @@ export const TYPERT = {
|
|
|
228
229
|
"name": "prompt",
|
|
229
230
|
"signature": "@Remote('prompt') async prompt(request: SubagentPromptRequest, signal: AbortSignal): Promise<SubagentPromptReceipt>",
|
|
230
231
|
"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.",
|
|
231
|
-
"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
|
|
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 */"
|
|
232
233
|
},
|
|
233
234
|
{
|
|
234
235
|
"kind": "method",
|
|
@@ -307,6 +308,10 @@ export const TYPERT = {
|
|
|
307
308
|
"name": "AssistantProvenance",
|
|
308
309
|
"declaration": "export interface AssistantProvenance {\n provider: string;\n model: string;\n replayState?: unknown;\n}"
|
|
309
310
|
},
|
|
311
|
+
{
|
|
312
|
+
"name": "AssistantStreamRecord",
|
|
313
|
+
"declaration": "export type AssistantStreamRecord = { readonly type: 'text-chunks'; readonly time0: number; readonly index: number; readonly dt: readonly number[]; readonly texts: readonly string[]; } | { readonly type: 'reasoning-chunks'; readonly time0: number; readonly index: number; readonly dt: readonly number[]; readonly texts: readonly string[]; } | { readonly type: 'tool-call-chunks'; readonly time0: number; readonly index: number; readonly dt: readonly number[]; readonly id: ToolCallId; readonly name?: string; readonly args: readonly string[]; } | { readonly type: 'chunk'; readonly time: number; readonly chunk: StreamChunk; };"
|
|
314
|
+
},
|
|
310
315
|
{
|
|
311
316
|
"name": "AttachmentId",
|
|
312
317
|
"declaration": "export type AttachmentId = Branded<'AttachmentId'>;"
|
|
@@ -345,7 +350,7 @@ export const TYPERT = {
|
|
|
345
350
|
},
|
|
346
351
|
{
|
|
347
352
|
"name": "ContentBlockMap",
|
|
348
|
-
"declaration": "export interface ContentBlockMap {\n text: TextBlock;\n reasoning: ReasoningBlock;\n image: ImageBlock;\n 'tool-call': ToolCallBlock;\n 'tool-result': ToolResultBlock;\n}"
|
|
353
|
+
"declaration": "export interface ContentBlockMap {\n text: TextBlock;\n reasoning: ReasoningBlock;\n image: ImageBlock;\n file: FileBlock;\n 'tool-call': ToolCallBlock;\n 'tool-result': ToolResultBlock;\n}"
|
|
349
354
|
},
|
|
350
355
|
{
|
|
351
356
|
"name": "ContentBlockType",
|
|
@@ -383,6 +388,14 @@ export const TYPERT = {
|
|
|
383
388
|
"name": "EpochHeader",
|
|
384
389
|
"declaration": "export interface EpochHeader {\n config: LlmCallConfig;\n adapterDefaults?: LlmCallConfigAdapterDefaults;\n system?: string;\n tools?: ToolSchema[];\n}"
|
|
385
390
|
},
|
|
391
|
+
{
|
|
392
|
+
"name": "FileAttachmentRef",
|
|
393
|
+
"declaration": "export interface FileAttachmentRef {\n attachmentId: AttachmentId;\n name: string;\n bytes: number;\n}"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"name": "FileBlock",
|
|
397
|
+
"declaration": "export interface FileBlock {\n type: 'file';\n attachment: FileAttachmentRef;\n}"
|
|
398
|
+
},
|
|
386
399
|
{
|
|
387
400
|
"name": "FinishReason",
|
|
388
401
|
"declaration": "export type FinishReason = FinishReasonMap[keyof FinishReasonMap];"
|
|
@@ -483,6 +496,26 @@ export const TYPERT = {
|
|
|
483
496
|
"name": "Message",
|
|
484
497
|
"declaration": "export interface Message {\n readonly id: MessageId;\n readonly role: 'system' | 'user' | 'assistant';\n readonly content: ContentBlock[];\n readonly source: MessageSource;\n}"
|
|
485
498
|
},
|
|
499
|
+
{
|
|
500
|
+
"name": "MessageFeedbackDelete",
|
|
501
|
+
"declaration": "export interface MessageFeedbackDelete {\n readonly sessionId: SessionId;\n readonly messageId: MessageId;\n}"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"name": "MessageFeedbackItem",
|
|
505
|
+
"declaration": "export interface MessageFeedbackItem {\n readonly messageId: MessageId;\n readonly rating: MessageFeedbackRating;\n readonly note?: string;\n readonly version: MessageFeedbackVersion;\n readonly createdAt: number;\n readonly updatedAt: number;\n}"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"name": "MessageFeedbackPut",
|
|
509
|
+
"declaration": "export interface MessageFeedbackPut {\n readonly sessionId: SessionId;\n readonly item: MessageFeedbackItem;\n}"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"name": "MessageFeedbackRating",
|
|
513
|
+
"declaration": "export type MessageFeedbackRating = 'positive' | 'negative';"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"name": "MessageFeedbackVersion",
|
|
517
|
+
"declaration": "export type MessageFeedbackVersion = Branded<'MessageFeedbackVersion'>;"
|
|
518
|
+
},
|
|
486
519
|
{
|
|
487
520
|
"name": "MessageId",
|
|
488
521
|
"declaration": "export type MessageId = Branded<'MessageId'>;"
|
|
@@ -561,7 +594,7 @@ export const TYPERT = {
|
|
|
561
594
|
},
|
|
562
595
|
{
|
|
563
596
|
"name": "Session",
|
|
564
|
-
"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] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
597
|
+
"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}"
|
|
565
598
|
},
|
|
566
599
|
{
|
|
567
600
|
"name": "SessionEvent",
|
|
@@ -569,7 +602,7 @@ export const TYPERT = {
|
|
|
569
602
|
},
|
|
570
603
|
{
|
|
571
604
|
"name": "SessionEventMap",
|
|
572
|
-
"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 'assistant/
|
|
605
|
+
"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 '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/code-dispatch-start': PtcDispatchStartEventData;\n 'tool/code-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 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\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}"
|
|
573
606
|
},
|
|
574
607
|
{
|
|
575
608
|
"name": "SessionEventType",
|
|
@@ -577,7 +610,7 @@ export const TYPERT = {
|
|
|
577
610
|
},
|
|
578
611
|
{
|
|
579
612
|
"name": "SessionHeader",
|
|
580
|
-
"declaration": "export interface SessionHeader {\n readonly version:
|
|
613
|
+
"declaration": "export interface SessionHeader {\n readonly version: typeof SESSION_FORMAT_VERSION;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly isSeeded: boolean;\n readonly origin?: 'subagent';\n readonly delegationDepth?: number;\n readonly agentPreset?: string;\n}"
|
|
581
614
|
},
|
|
582
615
|
{
|
|
583
616
|
"name": "SessionId",
|
|
@@ -589,7 +622,7 @@ export const TYPERT = {
|
|
|
589
622
|
},
|
|
590
623
|
{
|
|
591
624
|
"name": "SessionReferenceSource",
|
|
592
|
-
"declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq: OptionalSessionSeq; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
|
|
625
|
+
"declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedFormatVersion?: number; capturedThroughSeq: OptionalSessionSeq; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
|
|
593
626
|
},
|
|
594
627
|
{
|
|
595
628
|
"name": "SessionRequestId",
|
|
@@ -665,7 +698,7 @@ export const TYPERT = {
|
|
|
665
698
|
},
|
|
666
699
|
{
|
|
667
700
|
"name": "SubagentPromptRequest",
|
|
668
|
-
"declaration": "export interface SubagentPromptRequest {\n readonly requestId: SubagentPromptRequestId;\n readonly parentSessionId: SessionId;\n readonly childSessionId: SessionId;\n readonly mode: 'continuable';\n readonly content: readonly PromptContentPart[];\n readonly clientTimeZone?: string;\n}"
|
|
701
|
+
"declaration": "export interface SubagentPromptRequest {\n readonly requestId: SubagentPromptRequestId;\n readonly parentSessionId: SessionId;\n readonly childSessionId: SessionId;\n readonly mode: 'continuable';\n readonly delivery: 'queue' | 'steer';\n readonly content: readonly PromptContentPart[];\n readonly clientTimeZone?: string;\n}"
|
|
669
702
|
},
|
|
670
703
|
{
|
|
671
704
|
"name": "SubagentPromptRequestId",
|
|
@@ -709,7 +742,7 @@ export const TYPERT = {
|
|
|
709
742
|
},
|
|
710
743
|
{
|
|
711
744
|
"name": "SurfaceIntent",
|
|
712
|
-
"declaration": "export
|
|
745
|
+
"declaration": "export type SurfaceIntent<T extends SurfaceEventType = SurfaceEventType> = { surfaceOp: SurfaceOp; } & (T extends 'assistant/message' ? { sourceEventSeqs?: never; } : { sourceEventSeqs?: SessionSeq[]; });"
|
|
713
746
|
},
|
|
714
747
|
{
|
|
715
748
|
"name": "SurfaceOp",
|
|
@@ -733,7 +766,7 @@ export const TYPERT = {
|
|
|
733
766
|
},
|
|
734
767
|
{
|
|
735
768
|
"name": "TeamMessageSnapshot",
|
|
736
|
-
"declaration": "export interface TeamMessageSnapshot {\n readonly id: TeamMessageId;\n readonly senderId: SessionId;\n readonly senderName: string;\n readonly targetId: SessionId;\n readonly
|
|
769
|
+
"declaration": "export interface TeamMessageSnapshot {\n readonly id: TeamMessageId;\n readonly senderId: SessionId;\n readonly senderName: string;\n readonly targetId: SessionId;\n readonly content: ContentBlock[];\n}"
|
|
737
770
|
},
|
|
738
771
|
{
|
|
739
772
|
"name": "TeamMessageSource",
|
|
@@ -37,6 +37,7 @@ const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = z.object({
|
|
|
37
37
|
'parentSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
38
38
|
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
39
39
|
'mode': z.literal("continuable").readonly(),
|
|
40
|
+
'delivery': z.union([z.literal("queue"), z.literal("steer")]).readonly(),
|
|
40
41
|
'content': z.array(z.union([z.object({
|
|
41
42
|
'type': z.literal("text").readonly(),
|
|
42
43
|
'text': z.string().readonly(),
|
|
@@ -98,7 +99,7 @@ export const TYPERT_REMOTE = {
|
|
|
98
99
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
99
100
|
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
100
101
|
},
|
|
101
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
102
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":477,"column":3},
|
|
102
103
|
},
|
|
103
104
|
{
|
|
104
105
|
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
@@ -125,7 +126,7 @@ export const TYPERT_REMOTE = {
|
|
|
125
126
|
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
126
127
|
schema: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
127
128
|
},
|
|
128
|
-
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":
|
|
129
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":383,"column":9},
|
|
129
130
|
},
|
|
130
131
|
{
|
|
131
132
|
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module @deepseek-ai/dsh-subagent/assistant-output
|
|
11
11
|
*/
|
|
12
|
-
import type
|
|
12
|
+
import { type ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
13
13
|
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
14
14
|
/**
|
|
15
15
|
* Incremental fold of the selection rule, for backends that observe a child's
|
|
@@ -22,8 +22,8 @@ export declare class AssistantOutputFold {
|
|
|
22
22
|
private partial;
|
|
23
23
|
/**
|
|
24
24
|
* Fold one session event: a non-empty assistant message becomes the
|
|
25
|
-
* candidate final answer,
|
|
26
|
-
* fallback; every other event contributes nothing.
|
|
25
|
+
* candidate final answer, while its embedded stream and any log-only attempt
|
|
26
|
+
* extend the streamed fallback; every other event contributes nothing.
|
|
27
27
|
* @param event - the next observed session event.
|
|
28
28
|
*/
|
|
29
29
|
push(event: SessionEvent): void;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module @deepseek-ai/dsh-subagent/assistant-output
|
|
11
11
|
*/
|
|
12
|
+
import { joinAssistantStreamText } from '@deepseek-ai/dsh-llm';
|
|
12
13
|
/**
|
|
13
14
|
* Incremental fold of the selection rule, for backends that observe a child's
|
|
14
15
|
* output as it streams: session-event backends {@link push} each event, and
|
|
@@ -20,8 +21,8 @@ export class AssistantOutputFold {
|
|
|
20
21
|
partial = [];
|
|
21
22
|
/**
|
|
22
23
|
* Fold one session event: a non-empty assistant message becomes the
|
|
23
|
-
* candidate final answer,
|
|
24
|
-
* fallback; every other event contributes nothing.
|
|
24
|
+
* candidate final answer, while its embedded stream and any log-only attempt
|
|
25
|
+
* extend the streamed fallback; every other event contributes nothing.
|
|
25
26
|
* @param event - the next observed session event.
|
|
26
27
|
*/
|
|
27
28
|
push(event) {
|
|
@@ -30,8 +31,8 @@ export class AssistantOutputFold {
|
|
|
30
31
|
if (content.length > 0)
|
|
31
32
|
this.message = content;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
this.pushText(event.data.
|
|
34
|
+
if (event.type === 'assistant/message' || event.type === 'assistant/attempt') {
|
|
35
|
+
this.pushText(joinAssistantStreamText(event.data.stream));
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
/**
|
package/lib/types/child-agent.js
CHANGED
|
@@ -163,8 +163,8 @@ export function applyChildComposition(childCtx, parent, composition) {
|
|
|
163
163
|
});
|
|
164
164
|
if (composition.persona !== undefined) {
|
|
165
165
|
childCtx.systemPrompt.section({
|
|
166
|
-
name: 'deployment:persona',
|
|
167
|
-
order: childCtx.systemPrompt.getSectionOrder('
|
|
166
|
+
name: 'deployment:persona-prefix',
|
|
167
|
+
order: childCtx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX'),
|
|
168
168
|
text: composition.persona,
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local Activation ownership for continuable subagents: admission,
|
|
3
|
+
* parent-child residency, serialized delivery, settlement, and disposal.
|
|
4
|
+
*
|
|
5
|
+
* The continuation manager owns durable request orchestration and delegates
|
|
6
|
+
* every mutable residency decision to this registry, so delivery and teardown
|
|
7
|
+
* share one child lock and one Activation map.
|
|
8
|
+
*
|
|
9
|
+
* @module @deepseek-ai/dsh-subagent/continuation-activation
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { Agent, AgentHandle, AgentOptions, CreateAgentOptions } from '@deepseek-ai/dsh-agent';
|
|
13
|
+
import type { MessageId } from '@deepseek-ai/dsh-llm';
|
|
14
|
+
import type { SessionEvent, SessionId, SessionLogOffset as SessionLogOffsetType, UserMessage } from '@deepseek-ai/dsh-session';
|
|
15
|
+
import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
|
|
16
|
+
import type { DelegatedPolicyOverrides } from './child-agent.ts';
|
|
17
|
+
import type { SubagentDescriptorData } from './descriptor.ts';
|
|
18
|
+
import { SubagentInbox } from './inbox.ts';
|
|
19
|
+
import type { SubagentDelivery } from './inbox.ts';
|
|
20
|
+
import type { ActivationObserver } from './lifecycle.ts';
|
|
21
|
+
/**
|
|
22
|
+
* One residency epoch for a reconstructed continuable child Agent. It directly
|
|
23
|
+
* owns the published `AgentHandle`; the registry's private activation-owner
|
|
24
|
+
* scope is its structural Cordis owner.
|
|
25
|
+
*/
|
|
26
|
+
export interface Activation {
|
|
27
|
+
/** The durable child this Activation is an epoch of. */
|
|
28
|
+
readonly childId: SessionId;
|
|
29
|
+
/**
|
|
30
|
+
* The durable direct parent, stored because settlement delivery must resolve
|
|
31
|
+
* that parent after the child handle is gone. {@link ancestry} cannot answer
|
|
32
|
+
* it: a `WeakSet` is not enumerable, and the child's own header is only
|
|
33
|
+
* reachable through a handle disposal has already released.
|
|
34
|
+
*/
|
|
35
|
+
readonly parentSession: SessionId;
|
|
36
|
+
/** The provider name recorded in the durable descriptor. */
|
|
37
|
+
readonly provider: string;
|
|
38
|
+
/** The retained live Agent handle, disposed exactly once at settlement. */
|
|
39
|
+
readonly handle: AgentHandle;
|
|
40
|
+
/** The Activation-local admission and close wrapper around the handle's Agent inbox. */
|
|
41
|
+
readonly inbox: SubagentInbox;
|
|
42
|
+
/**
|
|
43
|
+
* Exact live Agent ancestry observed when this Activation materialized.
|
|
44
|
+
* Weak membership preserves host-scope identity across an intermediate
|
|
45
|
+
* ancestor leaving the registry without retaining that ancestor's runtime.
|
|
46
|
+
*/
|
|
47
|
+
readonly ancestry: WeakSet<Agent>;
|
|
48
|
+
/**
|
|
49
|
+
* Session ids of the child Activations this one owns. Because one Session has
|
|
50
|
+
* at most one live Activation, the id identifies the live child without
|
|
51
|
+
* another runtime-incarnation reference. Non-empty blocks settlement.
|
|
52
|
+
*/
|
|
53
|
+
readonly ownedChildren: Set<SessionId>;
|
|
54
|
+
/** The lifecycle observer that emits this epoch's start and terminal edges. */
|
|
55
|
+
readonly observer: ActivationObserver;
|
|
56
|
+
/**
|
|
57
|
+
* Whether any delivery to this child was ever accepted. A materialization
|
|
58
|
+
* rolled back before its first acceptance is a child the caller was told does
|
|
59
|
+
* not exist, so its teardown owes the parent no settlement account.
|
|
60
|
+
*/
|
|
61
|
+
announced: boolean;
|
|
62
|
+
/** Renewed whenever a settlement watcher must re-check residency state. */
|
|
63
|
+
poke: PromiseWithResolvers<void>;
|
|
64
|
+
}
|
|
65
|
+
/** Inputs shared by fresh and resumed Activation materialization. */
|
|
66
|
+
export interface MaterializeInputs {
|
|
67
|
+
childId: SessionId;
|
|
68
|
+
provider: string;
|
|
69
|
+
parent: Agent;
|
|
70
|
+
/**
|
|
71
|
+
* Creation inputs; absent for a cold resume, which loads the persisted
|
|
72
|
+
* session — including the delegation policy events a fresh creation seeded,
|
|
73
|
+
* so a resume never re-captures the parent's policy.
|
|
74
|
+
*/
|
|
75
|
+
create?: {
|
|
76
|
+
seed: readonly SessionEvent[] | undefined;
|
|
77
|
+
meta: NonNullable<CreateAgentOptions['meta']>;
|
|
78
|
+
/** Exact parent-log prefix length inside {@link seed}. */
|
|
79
|
+
inheritedEventCount: SessionLogOffsetType;
|
|
80
|
+
/** Policy captured at delegation: the parent's sandbox override plus the approval pin. */
|
|
81
|
+
delegatedPolicies: DelegatedPolicyOverrides;
|
|
82
|
+
/** Child-owned composition record appended after the inherited marker. */
|
|
83
|
+
descriptor: SubagentDescriptorData;
|
|
84
|
+
};
|
|
85
|
+
agentOptions: AgentOptions;
|
|
86
|
+
composition: {
|
|
87
|
+
persona?: string | undefined;
|
|
88
|
+
toolFilter?: ToolRestriction | undefined;
|
|
89
|
+
};
|
|
90
|
+
signal: AbortSignal;
|
|
91
|
+
}
|
|
92
|
+
/** Serialize each durable child's delivery, release, and disposal. */
|
|
93
|
+
export declare class ChildLock {
|
|
94
|
+
private tails;
|
|
95
|
+
/**
|
|
96
|
+
* Run `operation` after every previously queued operation for `childId`.
|
|
97
|
+
* @param childId - the durable child whose operations are linearized.
|
|
98
|
+
* @param operation - the critical section to run in order.
|
|
99
|
+
* @returns the operation's own settlement.
|
|
100
|
+
*/
|
|
101
|
+
run<T>(childId: SessionId, operation: () => Promise<T>): Promise<T>;
|
|
102
|
+
}
|
|
103
|
+
/** Own the complete process-local lifetime of continuable child Activations. */
|
|
104
|
+
export declare class ContinuableActivationRegistry {
|
|
105
|
+
private readonly ctx;
|
|
106
|
+
private readonly observeActivation;
|
|
107
|
+
/** Child session id → its live Activation. Process-local, never durable. */
|
|
108
|
+
private readonly resident;
|
|
109
|
+
/** Materializations admitted before drain, tracked through publication or rollback. */
|
|
110
|
+
private readonly materializations;
|
|
111
|
+
/** Per-child serializer shared by delivery, release, and disposal. */
|
|
112
|
+
readonly locks: ChildLock;
|
|
113
|
+
/** Structural Cordis owner of every Activation handle. */
|
|
114
|
+
readonly ownerCtx: Context;
|
|
115
|
+
/**
|
|
116
|
+
* Exact roots whose host teardown has begun, with the live lineage members
|
|
117
|
+
* observed under each root. Entries remain until that exact root leaves the
|
|
118
|
+
* Agent registry, closing admission throughout its host's teardown without
|
|
119
|
+
* poisoning a later same-id replacement.
|
|
120
|
+
*/
|
|
121
|
+
private readonly closingScopes;
|
|
122
|
+
private draining;
|
|
123
|
+
/**
|
|
124
|
+
* Build one registry inside the service's Agent-injected context.
|
|
125
|
+
* @param ctx - context providing Agents, Sessions, and teardown ownership.
|
|
126
|
+
* @param observeActivation - build the lifecycle observer for one residency epoch.
|
|
127
|
+
*/
|
|
128
|
+
constructor(ctx: Context, observeActivation: (provider: string, childId: SessionId, parent: Agent) => ActivationObserver);
|
|
129
|
+
/**
|
|
130
|
+
* Return the live Activation for a durable child id, if resident.
|
|
131
|
+
* @param childId - durable child session id to look up.
|
|
132
|
+
* @returns the process-local Activation, or `undefined` when it is not resident.
|
|
133
|
+
*/
|
|
134
|
+
get(childId: SessionId): Activation | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Reject one child identity already owned by a live Agent or Session.
|
|
137
|
+
* @param childId - proposed durable child session id.
|
|
138
|
+
*/
|
|
139
|
+
assertChildIdAvailable(childId: SessionId): void;
|
|
140
|
+
/**
|
|
141
|
+
* Pre-register `childId` in a continuation-managed parent's owned set so the
|
|
142
|
+
* parent cannot settle while a caller is still establishing or resuming that
|
|
143
|
+
* child. Returns a releaser for the failure path; it removes only a hold
|
|
144
|
+
* this call added, and leaves ownership in place once a live Activation for
|
|
145
|
+
* the child exists.
|
|
146
|
+
* @param parent - the live direct parent the operation is admitted under.
|
|
147
|
+
* @param childId - the durable child the operation addresses.
|
|
148
|
+
* @returns the failure-path releaser; a no-op when nothing was added.
|
|
149
|
+
*/
|
|
150
|
+
holdOwnership(parent: Agent, childId: SessionId): () => void;
|
|
151
|
+
/**
|
|
152
|
+
* Interrupt one live continuable child's current turn under the supplied authority.
|
|
153
|
+
* @param targetSessionId - the durable child session id to interrupt.
|
|
154
|
+
* @param authority - the human parent address or exact live ancestor Agent.
|
|
155
|
+
*/
|
|
156
|
+
interrupt(targetSessionId: SessionId, authority: {
|
|
157
|
+
readonly kind: 'user';
|
|
158
|
+
readonly parentSessionId: SessionId;
|
|
159
|
+
} | {
|
|
160
|
+
readonly kind: 'ancestor';
|
|
161
|
+
readonly agent: Agent;
|
|
162
|
+
}): void;
|
|
163
|
+
/**
|
|
164
|
+
* Send through a receiving parent's Activation inbox when it has one.
|
|
165
|
+
* @param parent - exact live Agent receiving the message.
|
|
166
|
+
* @param message - durable user message to deliver.
|
|
167
|
+
* @param delivery - receiving inbox destination.
|
|
168
|
+
*/
|
|
169
|
+
sendWaking(parent: Agent, message: UserMessage, delivery: SubagentDelivery): void;
|
|
170
|
+
/**
|
|
171
|
+
* Close admission, await every already-admitted materialization through
|
|
172
|
+
* publication or rollback, then dispose the stable live Activation graph
|
|
173
|
+
* child-first.
|
|
174
|
+
*/
|
|
175
|
+
drain(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Stop only the continuable descendants of exact live host-owned parents.
|
|
178
|
+
* @param parents - exact live roots whose continuable descendants must stop.
|
|
179
|
+
*/
|
|
180
|
+
drainDescendants(parents: readonly Agent[]): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Release selected resident direct children of one exact live parent.
|
|
183
|
+
* @param parent - exact live direct parent authorizing the selected release.
|
|
184
|
+
* @param childIds - durable direct-child ids to release when resident.
|
|
185
|
+
*/
|
|
186
|
+
drainChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Reject new admission once the registry or this exact parent tree began draining.
|
|
189
|
+
* @param agent - exact live Agent whose lineage determines admission.
|
|
190
|
+
*/
|
|
191
|
+
assertAdmitting(agent: Agent): void;
|
|
192
|
+
/**
|
|
193
|
+
* Authorize one operation against the durable direct-parent lineage.
|
|
194
|
+
* @param parent - exact live Agent claiming direct-parent authority.
|
|
195
|
+
* @param childId - durable child session id addressed by the operation.
|
|
196
|
+
* @param parentSession - durable direct-parent id recorded by the child.
|
|
197
|
+
*/
|
|
198
|
+
authorizeLineage(parent: Agent, childId: SessionId, parentSession: SessionId | undefined): void;
|
|
199
|
+
/**
|
|
200
|
+
* Create or resume one child Agent and publish its Activation.
|
|
201
|
+
* @param inputs - reconstruction and admission inputs for the residency epoch.
|
|
202
|
+
* @returns the published process-local Activation.
|
|
203
|
+
*/
|
|
204
|
+
materialize(inputs: MaterializeInputs): Promise<Activation>;
|
|
205
|
+
/**
|
|
206
|
+
* Cross the final admission cutoff and submit without yielding.
|
|
207
|
+
* @param activation - the exact resident child receiving the message.
|
|
208
|
+
* @param message - the already-built durable user message.
|
|
209
|
+
* @param delivery - the Agent inbox destination.
|
|
210
|
+
* @param parent - exact live direct parent authorizing admission.
|
|
211
|
+
* @param signal - caller cancellation before inbox acceptance.
|
|
212
|
+
* @returns the accepted durable message id.
|
|
213
|
+
*/
|
|
214
|
+
submitAdmitted(activation: Activation, message: UserMessage, delivery: SubagentDelivery, parent: Agent, signal: AbortSignal): MessageId;
|
|
215
|
+
/**
|
|
216
|
+
* Stop and release one Activation through its memoized close transaction.
|
|
217
|
+
* @param activation - exact residency epoch to close.
|
|
218
|
+
* @param finalStateFlushed - whether natural settlement already flushed final state.
|
|
219
|
+
* @returns the shared close transaction.
|
|
220
|
+
*/
|
|
221
|
+
dispose(activation: Activation, finalStateFlushed?: boolean): Promise<void>;
|
|
222
|
+
/** Dispose independent roots and report every branch failure after all settle. */
|
|
223
|
+
private disposeRoots;
|
|
224
|
+
/** Return the retained member set for one exact scoped-teardown root. */
|
|
225
|
+
private closingMembers;
|
|
226
|
+
/** Return the exact currently resolvable ancestry from `agent` upward. */
|
|
227
|
+
private liveLineage;
|
|
228
|
+
/** Return the teardown that closed continuable admission for this agent's lineage. */
|
|
229
|
+
private closingTeardownFor;
|
|
230
|
+
/** Perform one tracked materialization through publication or rollback. */
|
|
231
|
+
private materializeTracked;
|
|
232
|
+
/** Release an Activation whose start edge was not published. */
|
|
233
|
+
private rollbackUnpublished;
|
|
234
|
+
/** Register the child in a continuation-managed parent's owned set. */
|
|
235
|
+
private acquireOwnership;
|
|
236
|
+
/** Remove one child from its live owner's set and let that owner re-check settlement. */
|
|
237
|
+
private releaseOwnership;
|
|
238
|
+
/** Let a settlement watcher re-check residency after relevant state changes. */
|
|
239
|
+
private wake;
|
|
240
|
+
/** Follow one Activation to natural settlement. */
|
|
241
|
+
private watchSettlement;
|
|
242
|
+
/** Classify one Inbox and owned-child observation without reading Agent execution state. */
|
|
243
|
+
private settlementState;
|
|
244
|
+
/** Propagate stop synchronously, then finish the child-first release. */
|
|
245
|
+
private finishDisposal;
|
|
246
|
+
/** Tell the durable direct parent how this Activation ended. */
|
|
247
|
+
private notifySettlement;
|
|
248
|
+
/** Request a best-effort final session flush before closing natural-settlement admission. */
|
|
249
|
+
private flushFinalState;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=continuation-activation.d.ts.map
|