@toddzheng024/dscode-bundle 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/cordis.patch.yml +5 -3
- package/package.json +14 -1
- package/plugins/clipboard-image/clipboard-image.swift +56 -0
- package/plugins/clipboard-image/index.mjs +70 -0
- package/plugins/code-review/git.mjs +95 -0
- package/plugins/code-review/index.mjs +88 -0
- package/plugins/dscode/index.mjs +17 -3
- package/plugins/email/cli.mjs +32 -0
- package/plugins/email/contacts.mjs +36 -0
- package/plugins/email/gmail-oauth.mjs +69 -0
- package/plugins/email/gmail-store.mjs +2 -0
- package/plugins/email/gmail.mjs +194 -0
- package/plugins/email/imap.mjs +136 -0
- package/plugins/email/inbox.d.mts +25 -0
- package/plugins/email/inbox.mjs +76 -0
- package/plugins/email/smtp.mjs +69 -0
- package/plugins/email/store.mjs +32 -0
- package/plugins/email-tools/index.mjs +44 -0
- package/plugins/session-metrics/index.mjs +6 -2
- package/plugins/session-metrics/rate.mjs +62 -0
- package/plugins/session-metrics/view.mjs +15 -9
- package/plugins/tui-tools/doctor-cli.mjs +22 -0
- package/plugins/tui-tools/doctor.mjs +141 -0
- package/plugins/tui-tools/index.mjs +14 -6
- package/plugins/ultra/policy.mjs +12 -1
- package/plugins/worktree-subagent/worktree.mjs +50 -0
- package/presets/dscode/agent.cordis.yml +7 -2
- package/vendor/deepseek/index.js +12 -2
- package/vendor/subagent/index.js +29 -9
- package/vendor/subagent-core/LICENSE +21 -0
- package/vendor/subagent-core/index.js +3232 -0
- package/vendor/subagent-core/invariant.js +76 -0
- package/vendor/subagent-core/typert.host.d.ts +3 -0
- package/vendor/subagent-core/typert.host.js +964 -0
- package/vendor/subagent-core/typert.remote-client.d.ts +27 -0
- package/vendor/subagent-core/typert.remote-client.js +160 -0
- package/vendor/subagent-core/types/assistant-output.d.ts +48 -0
- package/vendor/subagent-core/types/assistant-output.js +73 -0
- package/vendor/subagent-core/types/catalog.d.ts +77 -0
- package/vendor/subagent-core/types/catalog.js +103 -0
- package/vendor/subagent-core/types/child-agent.d.ts +150 -0
- package/vendor/subagent-core/types/child-agent.js +207 -0
- package/vendor/subagent-core/types/client.d.ts +8 -0
- package/vendor/subagent-core/types/client.js +7 -0
- package/vendor/subagent-core/types/continuation-activation.d.ts +251 -0
- package/vendor/subagent-core/types/continuation-activation.js +663 -0
- package/vendor/subagent-core/types/continuation-messages.d.ts +62 -0
- package/vendor/subagent-core/types/continuation-messages.js +102 -0
- package/vendor/subagent-core/types/continuation.d.ts +124 -0
- package/vendor/subagent-core/types/continuation.js +455 -0
- package/vendor/subagent-core/types/control-types.d.ts +146 -0
- package/vendor/subagent-core/types/control-types.js +9 -0
- package/vendor/subagent-core/types/control.d.ts +71 -0
- package/vendor/subagent-core/types/control.js +116 -0
- package/vendor/subagent-core/types/depth.d.ts +31 -0
- package/vendor/subagent-core/types/depth.js +39 -0
- package/vendor/subagent-core/types/descriptor.d.ts +144 -0
- package/vendor/subagent-core/types/descriptor.js +193 -0
- package/vendor/subagent-core/types/error.d.ts +11 -0
- package/vendor/subagent-core/types/error.js +14 -0
- package/vendor/subagent-core/types/inbox.d.ts +43 -0
- package/vendor/subagent-core/types/inbox.js +61 -0
- package/vendor/subagent-core/types/index.d.ts +316 -0
- package/vendor/subagent-core/types/index.js +511 -0
- package/vendor/subagent-core/types/internal.d.ts +58 -0
- package/vendor/subagent-core/types/internal.js +58 -0
- package/vendor/subagent-core/types/invariant.d.ts +13 -0
- package/vendor/subagent-core/types/invariant.js +91 -0
- package/vendor/subagent-core/types/lifecycle.d.ts +113 -0
- package/vendor/subagent-core/types/lifecycle.js +178 -0
- package/vendor/subagent-core/types/list-children.d.ts +65 -0
- package/vendor/subagent-core/types/list-children.js +381 -0
- package/vendor/subagent-core/types/out-of-process.d.ts +118 -0
- package/vendor/subagent-core/types/out-of-process.js +219 -0
- package/vendor/subagent-core/types/projection-types.d.ts +74 -0
- package/vendor/subagent-core/types/projection-types.js +7 -0
- package/vendor/subagent-core/types/projection.d.ts +95 -0
- package/vendor/subagent-core/types/projection.js +151 -0
- package/vendor/subagent-core/types/run-settlement.d.ts +17 -0
- package/vendor/subagent-core/types/run-settlement.js +70 -0
- package/vendor/subagent-core/types/types.d.ts +377 -0
- package/vendor/subagent-core/types/types.js +19 -0
- package/vendor/subagent-driver/LICENSE +21 -0
- package/vendor/subagent-driver/index.js +255 -0
- package/vendor/subagent-driver/types/index.d.ts +33 -0
- package/vendor/subagent-driver/types/structured.d.ts +42 -0
- package/vendor/subagent-fork/LICENSE +21 -0
- package/vendor/subagent-fork/index.js +61 -0
- package/vendor/subagent-fork/types/index.d.ts +20 -0
- package/vendor/subagent-spawn/LICENSE +21 -0
- package/vendor/subagent-spawn/index.js +45 -0
- package/vendor/subagent-spawn/types/index.d.ts +19 -0
- package/vendor/terminal/LICENSE +21 -0
- package/vendor/terminal/index.js +1013 -0
- package/vendor/terminal/types/config.d.ts +71 -0
- package/vendor/terminal/types/index.d.ts +36 -0
- package/vendor/terminal/types/sanitize.d.ts +47 -0
- package/vendor/terminal/types/session.d.ts +87 -0
- package/vendor/tui/dscode-clipboard-image/clipboard-image.swift +56 -0
- package/vendor/tui/dscode-clipboard-image/index.mjs +70 -0
- package/vendor/tui/dscode-email/cli.mjs +32 -0
- package/vendor/tui/dscode-email/contacts.mjs +36 -0
- package/vendor/tui/dscode-email/gmail-oauth.mjs +69 -0
- package/vendor/tui/dscode-email/gmail-store.mjs +2 -0
- package/vendor/tui/dscode-email/gmail.mjs +194 -0
- package/vendor/tui/dscode-email/imap.mjs +136 -0
- package/vendor/tui/dscode-email/inbox.d.mts +25 -0
- package/vendor/tui/dscode-email/inbox.mjs +76 -0
- package/vendor/tui/dscode-email/smtp.mjs +69 -0
- package/vendor/tui/dscode-email/store.mjs +32 -0
- package/vendor/tui/dscode-email.mjs +69 -0
- package/vendor/tui/index.mjs +473 -82
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import type {
|
|
3
|
+
RemoteResult,
|
|
4
|
+
TypertRemoteContribution,
|
|
5
|
+
} from '@deepseek-ai/dsh-typert-protocol'
|
|
6
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
7
|
+
import type { SubagentCatalog, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from '@deepseek-ai/dsh-subagent/client'
|
|
8
|
+
|
|
9
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
10
|
+
interface TypertRemoteNamespace$7375626167656e7473 {
|
|
11
|
+
interruptByParent: (childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable') => Promise<RemoteResult<SubagentInterruptReceipt>>
|
|
12
|
+
list: (parentSessionId: SessionId, signal?: AbortSignal) => Promise<RemoteResult<SubagentCatalog>>
|
|
13
|
+
prompt: (request: SubagentPromptRequest, signal?: AbortSignal) => Promise<RemoteResult<SubagentPromptReceipt>>
|
|
14
|
+
}
|
|
15
|
+
interface TypertRemoteMap {
|
|
16
|
+
'subagents/interruptByParent': (childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable') => Promise<RemoteResult<SubagentInterruptReceipt>>
|
|
17
|
+
'subagents/list': (parentSessionId: SessionId, signal?: AbortSignal) => Promise<RemoteResult<SubagentCatalog>>
|
|
18
|
+
'subagents/prompt': (request: SubagentPromptRequest, signal?: AbortSignal) => Promise<RemoteResult<SubagentPromptReceipt>>
|
|
19
|
+
}
|
|
20
|
+
interface TypertRemoteNamespaceMap {
|
|
21
|
+
'subagents': TypertRemoteNamespace$7375626167656e7473
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare const TYPERT_REMOTE: TypertRemoteContribution
|
|
26
|
+
export default TYPERT_REMOTE
|
|
27
|
+
//# sourceMappingURL=typert.remote-client.d.ts.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
5
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema = z.intersection(z.string(), z.unknown())
|
|
6
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema = z.literal("continuable")
|
|
7
|
+
const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = z.object({
|
|
8
|
+
'accepted': z.literal(true).readonly(),
|
|
9
|
+
})
|
|
10
|
+
const _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
11
|
+
const _deepseek_ai_dsh_subagent_subagents_list_result$schema = z.object({
|
|
12
|
+
'entries': z.array(z.union([z.intersection(z.object({
|
|
13
|
+
'kind': z.literal("child").readonly(),
|
|
14
|
+
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
15
|
+
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
16
|
+
'hasChildren': z.boolean().readonly(),
|
|
17
|
+
}), z.object({
|
|
18
|
+
'mode': z.literal("one-shot").readonly(),
|
|
19
|
+
'label': z.string().readonly().optional(),
|
|
20
|
+
})), z.intersection(z.object({
|
|
21
|
+
'kind': z.literal("child").readonly(),
|
|
22
|
+
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
23
|
+
'activity': z.union([z.literal("running"), z.literal("inactive")]).readonly(),
|
|
24
|
+
'hasChildren': z.boolean().readonly(),
|
|
25
|
+
}), z.object({
|
|
26
|
+
'mode': z.literal("continuable").readonly(),
|
|
27
|
+
'label': z.string().readonly(),
|
|
28
|
+
})), z.object({
|
|
29
|
+
'kind': z.literal("diagnostic").readonly(),
|
|
30
|
+
'id': z.intersection(z.string(), z.unknown()).readonly(),
|
|
31
|
+
'reason': z.union([z.literal("corrupt"), z.literal("unsupported"), z.literal("unavailable")]).readonly(),
|
|
32
|
+
})])).readonly(),
|
|
33
|
+
'parentAvailable': z.boolean().readonly(),
|
|
34
|
+
})
|
|
35
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = z.object({
|
|
36
|
+
'requestId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
37
|
+
'parentSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
38
|
+
'childSessionId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
39
|
+
'mode': z.literal("continuable").readonly(),
|
|
40
|
+
'delivery': z.union([z.literal("queue"), z.literal("steer")]).readonly(),
|
|
41
|
+
'content': z.array(z.union([z.object({
|
|
42
|
+
'type': z.literal("text").readonly(),
|
|
43
|
+
'text': z.string().readonly(),
|
|
44
|
+
}), z.object({
|
|
45
|
+
'type': z.literal("image").readonly(),
|
|
46
|
+
'mediaType': z.union([z.literal("image/png"), z.literal("image/jpeg"), z.literal("image/webp"), z.literal("image/gif")]).readonly(),
|
|
47
|
+
'data': z.string().readonly(),
|
|
48
|
+
'name': z.string().readonly().optional(),
|
|
49
|
+
})])).readonly(),
|
|
50
|
+
'clientTimeZone': z.string().readonly().optional(),
|
|
51
|
+
})
|
|
52
|
+
const _deepseek_ai_dsh_subagent_subagents_prompt_result$schema = z.object({
|
|
53
|
+
'messageId': z.intersection(z.string(), z.unknown()).readonly(),
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
export const TYPERT_REMOTE = {
|
|
57
|
+
package: '@deepseek-ai/dsh-subagent',
|
|
58
|
+
descriptors: [
|
|
59
|
+
{
|
|
60
|
+
id: '@deepseek-ai/dsh-subagent#subagents/interruptByParent',
|
|
61
|
+
service: 'subagents',
|
|
62
|
+
namespace: 'subagents',
|
|
63
|
+
method: 'interruptByParent',
|
|
64
|
+
invocation: { kind: 'direct' },
|
|
65
|
+
parameters: [
|
|
66
|
+
{
|
|
67
|
+
name: 'childSessionId',
|
|
68
|
+
wire: 'childSessionId',
|
|
69
|
+
source: 'json',
|
|
70
|
+
codec: {
|
|
71
|
+
mode: 'strict',
|
|
72
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
73
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'parentSessionId',
|
|
78
|
+
wire: 'parentSessionId',
|
|
79
|
+
source: 'json',
|
|
80
|
+
codec: {
|
|
81
|
+
mode: 'strict',
|
|
82
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
83
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'mode',
|
|
88
|
+
wire: 'mode',
|
|
89
|
+
source: 'json',
|
|
90
|
+
codec: {
|
|
91
|
+
mode: 'strict',
|
|
92
|
+
typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
|
|
93
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
result: {
|
|
98
|
+
mode: 'strict',
|
|
99
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
|
|
100
|
+
schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
|
|
101
|
+
},
|
|
102
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":480,"column":3},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: '@deepseek-ai/dsh-subagent#subagents/list',
|
|
106
|
+
service: 'subagents',
|
|
107
|
+
namespace: 'subagents',
|
|
108
|
+
method: 'list',
|
|
109
|
+
implementation: 'remoteExportList',
|
|
110
|
+
invocation: { kind: 'direct' },
|
|
111
|
+
parameters: [
|
|
112
|
+
{
|
|
113
|
+
name: 'parentSessionId',
|
|
114
|
+
wire: 'parentSessionId',
|
|
115
|
+
source: 'json',
|
|
116
|
+
codec: {
|
|
117
|
+
mode: 'strict',
|
|
118
|
+
typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
|
|
119
|
+
schema: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
cancellation: { parameter: 'signal' },
|
|
124
|
+
result: {
|
|
125
|
+
mode: 'strict',
|
|
126
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
|
|
127
|
+
schema: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
|
|
128
|
+
},
|
|
129
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":386,"column":9},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: '@deepseek-ai/dsh-subagent#subagents/prompt',
|
|
133
|
+
service: 'subagents',
|
|
134
|
+
namespace: 'subagents',
|
|
135
|
+
method: 'prompt',
|
|
136
|
+
invocation: { kind: 'direct' },
|
|
137
|
+
parameters: [
|
|
138
|
+
{
|
|
139
|
+
name: 'request',
|
|
140
|
+
wire: 'request',
|
|
141
|
+
source: 'json',
|
|
142
|
+
codec: {
|
|
143
|
+
mode: 'strict',
|
|
144
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
|
|
145
|
+
schema: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
cancellation: { parameter: 'signal' },
|
|
150
|
+
result: {
|
|
151
|
+
mode: 'strict',
|
|
152
|
+
typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
|
|
153
|
+
schema: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
|
|
154
|
+
},
|
|
155
|
+
sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":413,"column":9},
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export default TYPERT_REMOTE
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical selection of a child's final assistant output. Backend run results
|
|
3
|
+
* and `subagent/end.lastAssistantMessage` apply the same rule: select the last
|
|
4
|
+
* non-empty assistant message. An empty-content message records usage only
|
|
5
|
+
* when the loop appends it after a max-tokens step with no executable blocks,
|
|
6
|
+
* so it does not replace earlier output. If no non-empty message exists,
|
|
7
|
+
* select the accumulated assistant text. Selection is independent of the
|
|
8
|
+
* run's stop reason.
|
|
9
|
+
*
|
|
10
|
+
* @module @deepseek-ai/dsh-subagent/assistant-output
|
|
11
|
+
*/
|
|
12
|
+
import { type ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
13
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
14
|
+
/**
|
|
15
|
+
* Incremental fold of the selection rule, for backends that observe a child's
|
|
16
|
+
* output as it streams: session-event backends {@link push} each event, and
|
|
17
|
+
* transports without session events (ACP content chunks) {@link pushText} raw
|
|
18
|
+
* text into the same streamed fallback.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AssistantOutputFold {
|
|
21
|
+
private message;
|
|
22
|
+
private partial;
|
|
23
|
+
/**
|
|
24
|
+
* Fold one session event: a non-empty assistant message becomes the
|
|
25
|
+
* candidate final answer, while its embedded stream and any log-only attempt
|
|
26
|
+
* extend the streamed fallback; every other event contributes nothing.
|
|
27
|
+
* @param event - the next observed session event.
|
|
28
|
+
*/
|
|
29
|
+
push(event: SessionEvent): void;
|
|
30
|
+
/**
|
|
31
|
+
* Extend the streamed fallback with text observed outside session events.
|
|
32
|
+
* @param text - the next streamed text piece (an empty piece is a no-op).
|
|
33
|
+
*/
|
|
34
|
+
pushText(text: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Select the final output folded so far.
|
|
37
|
+
* @returns the last non-empty assistant message, else the accumulated
|
|
38
|
+
* streamed text, or `undefined` when the child produced neither.
|
|
39
|
+
*/
|
|
40
|
+
collect(): ContentBlock[] | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Apply the selection rule to one complete child-owned event suffix.
|
|
44
|
+
* @param events - the child-owned events (after any seed or epoch boundary).
|
|
45
|
+
* @returns the selected output, or `undefined` when the child produced none.
|
|
46
|
+
*/
|
|
47
|
+
export declare function finalAssistantOutput(events: readonly SessionEvent[]): ContentBlock[] | undefined;
|
|
48
|
+
//# sourceMappingURL=assistant-output.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical selection of a child's final assistant output. Backend run results
|
|
3
|
+
* and `subagent/end.lastAssistantMessage` apply the same rule: select the last
|
|
4
|
+
* non-empty assistant message. An empty-content message records usage only
|
|
5
|
+
* when the loop appends it after a max-tokens step with no executable blocks,
|
|
6
|
+
* so it does not replace earlier output. If no non-empty message exists,
|
|
7
|
+
* select the accumulated assistant text. Selection is independent of the
|
|
8
|
+
* run's stop reason.
|
|
9
|
+
*
|
|
10
|
+
* @module @deepseek-ai/dsh-subagent/assistant-output
|
|
11
|
+
*/
|
|
12
|
+
import { joinAssistantStreamText } from '@deepseek-ai/dsh-llm';
|
|
13
|
+
/**
|
|
14
|
+
* Incremental fold of the selection rule, for backends that observe a child's
|
|
15
|
+
* output as it streams: session-event backends {@link push} each event, and
|
|
16
|
+
* transports without session events (ACP content chunks) {@link pushText} raw
|
|
17
|
+
* text into the same streamed fallback.
|
|
18
|
+
*/
|
|
19
|
+
export class AssistantOutputFold {
|
|
20
|
+
message;
|
|
21
|
+
partial = [];
|
|
22
|
+
/**
|
|
23
|
+
* Fold one session event: a non-empty assistant message becomes the
|
|
24
|
+
* candidate final answer, while its embedded stream and any log-only attempt
|
|
25
|
+
* extend the streamed fallback; every other event contributes nothing.
|
|
26
|
+
* @param event - the next observed session event.
|
|
27
|
+
*/
|
|
28
|
+
push(event) {
|
|
29
|
+
if (event.type === 'assistant/message') {
|
|
30
|
+
const content = event.data.message.content;
|
|
31
|
+
if (content.length > 0)
|
|
32
|
+
this.message = content;
|
|
33
|
+
}
|
|
34
|
+
if (event.type === 'assistant/message' || event.type === 'assistant/attempt') {
|
|
35
|
+
this.pushText(joinAssistantStreamText(event.data.stream));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extend the streamed fallback with text observed outside session events.
|
|
40
|
+
* @param text - the next streamed text piece (an empty piece is a no-op).
|
|
41
|
+
*/
|
|
42
|
+
pushText(text) {
|
|
43
|
+
if (text.length > 0)
|
|
44
|
+
this.partial.push(text);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Select the final output folded so far.
|
|
48
|
+
* @returns the last non-empty assistant message, else the accumulated
|
|
49
|
+
* streamed text, or `undefined` when the child produced neither.
|
|
50
|
+
*/
|
|
51
|
+
collect() {
|
|
52
|
+
if (this.message !== undefined)
|
|
53
|
+
return this.message;
|
|
54
|
+
const text = this.partial.join('');
|
|
55
|
+
return text.length > 0 ? [{ type: 'text', text }] : undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Apply the selection rule to one complete child-owned event suffix.
|
|
60
|
+
* @param events - the child-owned events (after any seed or epoch boundary).
|
|
61
|
+
* @returns the selected output, or `undefined` when the child produced none.
|
|
62
|
+
*/
|
|
63
|
+
export function finalAssistantOutput(events) {
|
|
64
|
+
// TODO: this folds the complete suffix once per run/epoch settlement. If a
|
|
65
|
+
// long continuable epoch ever profiles hot here, scan backward with early
|
|
66
|
+
// exit for the last non-empty message and fold text deltas only on the
|
|
67
|
+
// no-message fallback.
|
|
68
|
+
const fold = new AssistantOutputFold();
|
|
69
|
+
for (const event of events)
|
|
70
|
+
fold.push(event);
|
|
71
|
+
return fold.collect();
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=assistant-output.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parent-owned durable subagent catalog events and their chunked projection.
|
|
3
|
+
*
|
|
4
|
+
* @module @deepseek-ai/dsh-subagent/catalog
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { ChunkedList } from '@deepseek-ai/dsh-chunked-list';
|
|
8
|
+
import type { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session';
|
|
9
|
+
import type { SubagentCatalogEntry } from './projection-types.ts';
|
|
10
|
+
/** Current payload version for `subagent/catalog` events. */
|
|
11
|
+
export declare const SUBAGENT_CATALOG_VERSION = 0;
|
|
12
|
+
/** One complete parent-owned catalog fact. */
|
|
13
|
+
export type SubagentCatalogEvent = {
|
|
14
|
+
readonly version: 0;
|
|
15
|
+
readonly childId: SessionId;
|
|
16
|
+
readonly childCreatedAt: number;
|
|
17
|
+
} & ({
|
|
18
|
+
readonly mode: 'one-shot';
|
|
19
|
+
readonly label?: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly mode: 'continuable';
|
|
22
|
+
readonly label: string;
|
|
23
|
+
});
|
|
24
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
25
|
+
interface SessionEventMap {
|
|
26
|
+
/**
|
|
27
|
+
* A direct child's complete discovery fact.
|
|
28
|
+
* @param data - versioned parent-owned catalog entry.
|
|
29
|
+
*/
|
|
30
|
+
'subagent/catalog': SubagentCatalogEvent;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Host fold state for one parent catalog. */
|
|
34
|
+
export interface SubagentCatalogState {
|
|
35
|
+
readonly inheritedEventCount: SessionLogOffset;
|
|
36
|
+
readonly head?: ChunkedList<SubagentCatalogEvent> | undefined;
|
|
37
|
+
}
|
|
38
|
+
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
39
|
+
interface SessionProjectionStateMap {
|
|
40
|
+
subagentCatalog: SubagentCatalogState;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Materialize direct children from their parent's successful creation facts.
|
|
45
|
+
* @param state - parent catalog fold state.
|
|
46
|
+
* @returns current direct-child rows in parent catalog event order.
|
|
47
|
+
*/
|
|
48
|
+
declare function subagentCatalogEntries(state: SubagentCatalogState): SubagentCatalogEntry[];
|
|
49
|
+
/** Parent-owned direct-child catalog projection; invalid own facts reject restoration. */
|
|
50
|
+
export declare const subagentCatalogProjectionDefinition: {
|
|
51
|
+
key: "subagentCatalog";
|
|
52
|
+
stateSchema: z.ZodType<SubagentCatalogState, unknown, z.core.$ZodTypeInternals<SubagentCatalogState, unknown>>;
|
|
53
|
+
init: (_header: SessionHeader, inheritedEventCount: SessionLogOffset) => {
|
|
54
|
+
inheritedEventCount: SessionLogOffset;
|
|
55
|
+
};
|
|
56
|
+
apply: (state: NoInfer<SubagentCatalogState>, event: SessionEvent) => SubagentCatalogState;
|
|
57
|
+
stateVersion: number;
|
|
58
|
+
wire: {
|
|
59
|
+
viewSchema: z.ZodType<SubagentCatalogEntry[], unknown, z.core.$ZodTypeInternals<SubagentCatalogEntry[], unknown>>;
|
|
60
|
+
view: typeof subagentCatalogEntries;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Append a complete direct-child discovery fact to its parent Session.
|
|
65
|
+
* @param parent - durable direct parent receiving the discovery fact.
|
|
66
|
+
* @param child - established child's immutable Session metadata.
|
|
67
|
+
* @param descriptor - mode-discriminated creation label frozen with the child.
|
|
68
|
+
*/
|
|
69
|
+
export declare function establishCatalogChild(parent: Session, child: SessionHeader, descriptor: {
|
|
70
|
+
readonly mode: 'one-shot';
|
|
71
|
+
readonly label?: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly mode: 'continuable';
|
|
74
|
+
readonly label: string;
|
|
75
|
+
}): void;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parent-owned durable subagent catalog events and their chunked projection.
|
|
3
|
+
*
|
|
4
|
+
* @module @deepseek-ai/dsh-subagent/catalog
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { appendChunkedList, chunkedListSchema, iterateChunkedList } from '@deepseek-ai/dsh-chunked-list';
|
|
8
|
+
/** Current payload version for `subagent/catalog` events. */
|
|
9
|
+
export const SUBAGENT_CATALOG_VERSION = 0;
|
|
10
|
+
const sessionIdSchema = z.string();
|
|
11
|
+
const oneShotCatalogSchema = z.object({
|
|
12
|
+
version: z.literal(SUBAGENT_CATALOG_VERSION),
|
|
13
|
+
childId: sessionIdSchema,
|
|
14
|
+
childCreatedAt: z.number().int().nonnegative(),
|
|
15
|
+
mode: z.literal('one-shot'),
|
|
16
|
+
label: z.string().optional(),
|
|
17
|
+
}).strict();
|
|
18
|
+
const continuableCatalogSchema = z.object({
|
|
19
|
+
version: z.literal(SUBAGENT_CATALOG_VERSION),
|
|
20
|
+
childId: sessionIdSchema,
|
|
21
|
+
childCreatedAt: z.number().int().nonnegative(),
|
|
22
|
+
mode: z.literal('continuable'),
|
|
23
|
+
label: z.string(),
|
|
24
|
+
}).strict();
|
|
25
|
+
const eventDataSchema = z.union([
|
|
26
|
+
oneShotCatalogSchema,
|
|
27
|
+
continuableCatalogSchema,
|
|
28
|
+
]);
|
|
29
|
+
const viewSchema = z.array(z.union([
|
|
30
|
+
oneShotCatalogSchema.omit({ version: true, childId: true, childCreatedAt: true }).extend({
|
|
31
|
+
id: sessionIdSchema,
|
|
32
|
+
createdAt: oneShotCatalogSchema.shape.childCreatedAt,
|
|
33
|
+
}),
|
|
34
|
+
continuableCatalogSchema.omit({ version: true, childId: true, childCreatedAt: true }).extend({
|
|
35
|
+
id: sessionIdSchema,
|
|
36
|
+
createdAt: continuableCatalogSchema.shape.childCreatedAt,
|
|
37
|
+
}),
|
|
38
|
+
]));
|
|
39
|
+
const stateSchema = z.object({
|
|
40
|
+
inheritedEventCount: z.number().int().nonnegative(),
|
|
41
|
+
head: chunkedListSchema(eventDataSchema).optional(),
|
|
42
|
+
}).strict();
|
|
43
|
+
/**
|
|
44
|
+
* Materialize direct children from their parent's successful creation facts.
|
|
45
|
+
* @param state - parent catalog fold state.
|
|
46
|
+
* @returns current direct-child rows in parent catalog event order.
|
|
47
|
+
*/
|
|
48
|
+
function subagentCatalogEntries(state) {
|
|
49
|
+
const entries = [];
|
|
50
|
+
for (const data of iterateChunkedList(state.head)) {
|
|
51
|
+
entries.push(data.mode === 'one-shot'
|
|
52
|
+
? {
|
|
53
|
+
id: data.childId,
|
|
54
|
+
createdAt: data.childCreatedAt,
|
|
55
|
+
mode: data.mode,
|
|
56
|
+
...data.label === undefined ? {} : { label: data.label },
|
|
57
|
+
}
|
|
58
|
+
: {
|
|
59
|
+
id: data.childId,
|
|
60
|
+
createdAt: data.childCreatedAt,
|
|
61
|
+
mode: data.mode,
|
|
62
|
+
label: data.label,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return entries;
|
|
66
|
+
}
|
|
67
|
+
/** Parent-owned direct-child catalog projection; invalid own facts reject restoration. */
|
|
68
|
+
export const subagentCatalogProjectionDefinition = {
|
|
69
|
+
key: 'subagentCatalog',
|
|
70
|
+
stateSchema,
|
|
71
|
+
init: (_header, inheritedEventCount) => ({ inheritedEventCount }),
|
|
72
|
+
apply: (state, event) => {
|
|
73
|
+
if (event.type !== 'subagent/catalog' || event.seq < state.inheritedEventCount)
|
|
74
|
+
return state;
|
|
75
|
+
return { ...state, head: appendChunkedList(state.head, eventDataSchema.parse(event.data)) };
|
|
76
|
+
},
|
|
77
|
+
stateVersion: 2,
|
|
78
|
+
wire: { viewSchema, view: subagentCatalogEntries },
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Append a complete direct-child discovery fact to its parent Session.
|
|
82
|
+
* @param parent - durable direct parent receiving the discovery fact.
|
|
83
|
+
* @param child - established child's immutable Session metadata.
|
|
84
|
+
* @param descriptor - mode-discriminated creation label frozen with the child.
|
|
85
|
+
*/
|
|
86
|
+
export function establishCatalogChild(parent, child, descriptor) {
|
|
87
|
+
parent.append('subagent/catalog', descriptor.mode === 'one-shot'
|
|
88
|
+
? {
|
|
89
|
+
version: SUBAGENT_CATALOG_VERSION,
|
|
90
|
+
childId: child.id,
|
|
91
|
+
childCreatedAt: child.createdAt,
|
|
92
|
+
mode: descriptor.mode,
|
|
93
|
+
...descriptor.label === undefined ? {} : { label: descriptor.label },
|
|
94
|
+
}
|
|
95
|
+
: {
|
|
96
|
+
version: SUBAGENT_CATALOG_VERSION,
|
|
97
|
+
childId: child.id,
|
|
98
|
+
childCreatedAt: child.createdAt,
|
|
99
|
+
mode: descriptor.mode,
|
|
100
|
+
label: descriptor.label,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared in-process child composition: the delegation-depth budget, the
|
|
3
|
+
* durable session metadata, the resolved child `AgentOptions`, the delegated
|
|
4
|
+
* policy seed, and the scoped setup a child agent needs. Both the one-shot
|
|
5
|
+
* provider driver and the continuation manager compose children this way, so
|
|
6
|
+
* depth accounting, lineage stamping, and delegation policy have one home.
|
|
7
|
+
*
|
|
8
|
+
* @module @deepseek-ai/dsh-subagent/child-agent
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
import type { Agent, AgentOptions, CreateAgentOptions } from '@deepseek-ai/dsh-agent';
|
|
12
|
+
import type { SandboxMode } from '@deepseek-ai/dsh-sandbox';
|
|
13
|
+
import type { Session, SessionId } from '@deepseek-ai/dsh-session';
|
|
14
|
+
import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
|
|
15
|
+
/** Thrown when starting a child would exceed the requested depth cap. */
|
|
16
|
+
export declare class SubagentDepthError extends Error {
|
|
17
|
+
readonly attemptedDepth: number;
|
|
18
|
+
readonly maxDepth: number;
|
|
19
|
+
constructor(attemptedDepth: number, maxDepth: number);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the child's delegation depth from its parent and enforce an optional
|
|
23
|
+
* cap. The persisted parent header is the monotone floor, so a resumed parent
|
|
24
|
+
* cannot delegate as if it were top-level.
|
|
25
|
+
* @param parent - the delegating parent agent.
|
|
26
|
+
* @param maxDepth - optional absolute cap the resolved depth must not exceed.
|
|
27
|
+
* @returns the child's non-negative safe-integer depth.
|
|
28
|
+
* @throws {SubagentDepthError} when the resolved depth exceeds `maxDepth`.
|
|
29
|
+
* @throws {RangeError} when the resolved depth leaves the safe-integer range.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveChildDepth(parent: Agent, maxDepth: number | undefined): number;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the parent values inherited by a child. The latest request header
|
|
34
|
+
* owns provider, model, and reasoning effort after request-time selection;
|
|
35
|
+
* creation options remain the fallback before the first request and retain
|
|
36
|
+
* the configured output-token limit.
|
|
37
|
+
* @param parent - delegating parent Agent.
|
|
38
|
+
* @returns detached Agent options for child-option merging.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parentAgentOptionsForDelegation(parent: Agent): AgentOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the child's `AgentOptions`: the parent's provider/model,
|
|
43
|
+
* reasoning-effort, and maxTokens values unless the request overrides them,
|
|
44
|
+
* stamped with the child's own delegation depth. Changing the route without
|
|
45
|
+
* naming an effort clears the parent's route-owned effort so the selected
|
|
46
|
+
* model resolves its own default.
|
|
47
|
+
* @param parent - the delegating parent whose route the child inherits.
|
|
48
|
+
* @param requested - per-child overrides, if any.
|
|
49
|
+
* @param childDepth - the resolved delegation depth to stamp.
|
|
50
|
+
* @returns the resolved options for `ctx.agents.create()`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveChildAgentOptions(parent: Agent, requested: AgentOptions | undefined, childDepth: number): AgentOptions;
|
|
53
|
+
/**
|
|
54
|
+
* Build the child session's durable creation metadata: the parent's workspace,
|
|
55
|
+
* its direct lineage, coarse product origin, the recursion budget that must
|
|
56
|
+
* survive persistence, the seed boundary that separates inherited parent
|
|
57
|
+
* history from child work, and the composition the child runs under.
|
|
58
|
+
*
|
|
59
|
+
* The preset is read from the parent's LIVE scope chain rather than from its
|
|
60
|
+
* header, because a parent that switched preset while blank runs on the newer
|
|
61
|
+
* composition and its header still names the older one. Recording it is what
|
|
62
|
+
* makes a child's history reconstructable: without it a cold read of the child
|
|
63
|
+
* resolves the deployment default and rebuilds turns under a tool set the
|
|
64
|
+
* child never had.
|
|
65
|
+
* @param parent - the delegating parent agent.
|
|
66
|
+
* @param childDepth - the resolved delegation depth to persist.
|
|
67
|
+
* @param isSeeded - whether this child inherits a parent-log prefix, including an explicitly empty one.
|
|
68
|
+
* @returns the `meta` for `ctx.agents.create()`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function childSessionMeta(parent: Agent, childDepth: number, isSeeded: boolean): NonNullable<CreateAgentOptions['meta']>;
|
|
71
|
+
/** The scoped composition a child agent's creation window applies. */
|
|
72
|
+
export interface ChildComposition {
|
|
73
|
+
/** Per-child persona shadowing the deployment persona. */
|
|
74
|
+
readonly persona?: string | undefined;
|
|
75
|
+
/** Per-child tool scoping. */
|
|
76
|
+
readonly toolFilter?: ToolRestriction | undefined;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Model-facing delegation-scope statement for every in-process child. A
|
|
80
|
+
* runtime-context contribution rather than a system-prompt section, so the
|
|
81
|
+
* deployment's system prompt stays uniform across parents and children.
|
|
82
|
+
*/
|
|
83
|
+
export declare const SUBAGENT_DELEGATION_CONTEXT: string;
|
|
84
|
+
/**
|
|
85
|
+
* Compose one child inside its creation window: join its parent's preset,
|
|
86
|
+
* register the fixed delegation-scope statement, then apply the child's own
|
|
87
|
+
* shadowing persona section and tool restriction, all owned by the child's
|
|
88
|
+
* scope and therefore invisible to its parent and siblings. Creation and cold
|
|
89
|
+
* resume both pass through here.
|
|
90
|
+
*
|
|
91
|
+
* The join comes first and the child's own registrations second, which is the
|
|
92
|
+
* order the layering already implies — the nearest scope wins a name, and a
|
|
93
|
+
* per-child restriction intersects with everything its chain admits — but
|
|
94
|
+
* stating it here keeps the two steps from being read as independent.
|
|
95
|
+
*
|
|
96
|
+
* The join and the per-child registrations live in ONE call because a child
|
|
97
|
+
* composed without the join is exactly the defect this function exists to
|
|
98
|
+
* prevent: with every model-facing row on the agent plane, a child that joins
|
|
99
|
+
* no preset sees an empty tool registry and none of its parent's prompt
|
|
100
|
+
* sections. Taking the parent as a parameter is what makes that omission
|
|
101
|
+
* unrepresentable at the call sites.
|
|
102
|
+
* @param childCtx - the child agent's scoped creation context.
|
|
103
|
+
* @param parent - the delegating parent whose composition the child joins.
|
|
104
|
+
* @param composition - the per-child persona and tool filter to install.
|
|
105
|
+
*/
|
|
106
|
+
export declare function applyChildComposition(childCtx: Context, parent: Agent, composition: ChildComposition): void;
|
|
107
|
+
/** Policy seeded onto a child session's log at the delegation boundary. */
|
|
108
|
+
export interface DelegatedPolicyOverrides {
|
|
109
|
+
/** The parent session's explicit sandbox-mode override, or `undefined` without one. */
|
|
110
|
+
readonly sandboxMode: SandboxMode | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* `'never'` whenever the approval capability is composed, `undefined`
|
|
113
|
+
* otherwise: a delegated child acts only within the sandbox scope fixed at
|
|
114
|
+
* delegation, so its asks are rejected deterministically.
|
|
115
|
+
*/
|
|
116
|
+
readonly approvalPolicy: 'never' | undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Capture the policy to seed into one delegation. Call synchronously before
|
|
120
|
+
* the child start's first await: a later parent switch belongs to the
|
|
121
|
+
* parent's future, not to this child. Only the parent session's explicit
|
|
122
|
+
* sandbox override is captured — never deployment defaults or one-shot
|
|
123
|
+
* grants — and the approval policy is pinned to `'never'` regardless of the
|
|
124
|
+
* parent's own policy.
|
|
125
|
+
* @param parent - the delegating parent agent.
|
|
126
|
+
* @returns the sandbox override (or `undefined` without one) and the approval pin.
|
|
127
|
+
*/
|
|
128
|
+
export declare function captureDelegatedPolicyOverrides(parent: Agent): DelegatedPolicyOverrides;
|
|
129
|
+
/**
|
|
130
|
+
* Append the captured delegation policy onto the child's own log as
|
|
131
|
+
* `source: 'delegation'` events inside the unpublished creation window, so the
|
|
132
|
+
* child's effective policy is reconstructable from its log alone. Appends land
|
|
133
|
+
* after any fork seed, so fresh policy wins stale seed state; later child
|
|
134
|
+
* switches still win over these events.
|
|
135
|
+
* @param childSession - the unpublished child's session.
|
|
136
|
+
* @param overrides - the policy captured at delegation.
|
|
137
|
+
*/
|
|
138
|
+
export declare function appendDelegatedPolicyOverrides(childSession: Session, overrides: DelegatedPolicyOverrides): void;
|
|
139
|
+
/** Identity and lineage inputs shared by every in-process child creation. */
|
|
140
|
+
export interface ChildCreateInputs {
|
|
141
|
+
/** The child's reserved session id. */
|
|
142
|
+
readonly sessionId: SessionId;
|
|
143
|
+
/** The delegating parent agent. */
|
|
144
|
+
readonly parent: Agent;
|
|
145
|
+
/** The resolved delegation depth. */
|
|
146
|
+
readonly childDepth: number;
|
|
147
|
+
/** How many leading seed events came from the parent's log. */
|
|
148
|
+
readonly lineageSeedLength: number;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=child-agent.d.ts.map
|