@deepseek-ai/dsh-subagent 0.1.1-rc.2 → 0.1.2-alpha.3

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.
@@ -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,159 @@
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
+ 'content': z.array(z.union([z.object({
41
+ 'type': z.literal("text").readonly(),
42
+ 'text': z.string().readonly(),
43
+ }), z.object({
44
+ 'type': z.literal("image").readonly(),
45
+ 'mediaType': z.union([z.literal("image/png"), z.literal("image/jpeg"), z.literal("image/webp"), z.literal("image/gif")]).readonly(),
46
+ 'data': z.string().readonly(),
47
+ 'name': z.string().readonly().optional(),
48
+ })])).readonly(),
49
+ 'clientTimeZone': z.string().readonly().optional(),
50
+ })
51
+ const _deepseek_ai_dsh_subagent_subagents_prompt_result$schema = z.object({
52
+ 'messageId': z.intersection(z.string(), z.unknown()).readonly(),
53
+ })
54
+
55
+ export const TYPERT_REMOTE = {
56
+ package: '@deepseek-ai/dsh-subagent',
57
+ descriptors: [
58
+ {
59
+ id: '@deepseek-ai/dsh-subagent#subagents/interruptByParent',
60
+ service: 'subagents',
61
+ namespace: 'subagents',
62
+ method: 'interruptByParent',
63
+ invocation: { kind: 'direct' },
64
+ parameters: [
65
+ {
66
+ name: 'childSessionId',
67
+ wire: 'childSessionId',
68
+ source: 'json',
69
+ codec: {
70
+ mode: 'strict',
71
+ typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
72
+ schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema,
73
+ },
74
+ },
75
+ {
76
+ name: 'parentSessionId',
77
+ wire: 'parentSessionId',
78
+ source: 'json',
79
+ codec: {
80
+ mode: 'strict',
81
+ typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
82
+ schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema,
83
+ },
84
+ },
85
+ {
86
+ name: 'mode',
87
+ wire: 'mode',
88
+ source: 'json',
89
+ codec: {
90
+ mode: 'strict',
91
+ typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
92
+ schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema,
93
+ },
94
+ },
95
+ ],
96
+ result: {
97
+ mode: 'strict',
98
+ typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
99
+ schema: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
100
+ },
101
+ sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":491,"column":3},
102
+ },
103
+ {
104
+ id: '@deepseek-ai/dsh-subagent#subagents/list',
105
+ service: 'subagents',
106
+ namespace: 'subagents',
107
+ method: 'list',
108
+ implementation: 'remoteExportList',
109
+ invocation: { kind: 'direct' },
110
+ parameters: [
111
+ {
112
+ name: 'parentSessionId',
113
+ wire: 'parentSessionId',
114
+ source: 'json',
115
+ codec: {
116
+ mode: 'strict',
117
+ typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
118
+ schema: _deepseek_ai_dsh_subagent_subagents_list_parameter_0$schema,
119
+ },
120
+ },
121
+ ],
122
+ cancellation: { parameter: 'signal' },
123
+ result: {
124
+ mode: 'strict',
125
+ typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentCatalog',
126
+ schema: _deepseek_ai_dsh_subagent_subagents_list_result$schema,
127
+ },
128
+ sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":407,"column":9},
129
+ },
130
+ {
131
+ id: '@deepseek-ai/dsh-subagent#subagents/prompt',
132
+ service: 'subagents',
133
+ namespace: 'subagents',
134
+ method: 'prompt',
135
+ invocation: { kind: 'direct' },
136
+ parameters: [
137
+ {
138
+ name: 'request',
139
+ wire: 'request',
140
+ source: 'json',
141
+ codec: {
142
+ mode: 'strict',
143
+ typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
144
+ schema: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema,
145
+ },
146
+ },
147
+ ],
148
+ cancellation: { parameter: 'signal' },
149
+ result: {
150
+ mode: 'strict',
151
+ typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptReceipt',
152
+ schema: _deepseek_ai_dsh_subagent_subagents_prompt_result$schema,
153
+ },
154
+ sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":433,"column":9},
155
+ },
156
+ ],
157
+ }
158
+
159
+ export default TYPERT_REMOTE
@@ -30,9 +30,20 @@ export declare class SubagentDepthError extends Error {
30
30
  */
31
31
  export declare function resolveChildDepth(parent: Agent, maxDepth: number | undefined): number;
32
32
  /**
33
- * Resolve the child's `AgentOptions`: the parent's provider/model/maxTokens
34
- * route unless the request overrides it, stamped with the child's own
35
- * delegation depth.
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.
36
47
  * @param parent - the delegating parent whose route the child inherits.
37
48
  * @param requested - per-child overrides, if any.
38
49
  * @param childDepth - the resolved delegation depth to stamp.
@@ -40,25 +40,56 @@ export function resolveChildDepth(parent, maxDepth) {
40
40
  return childDepth;
41
41
  }
42
42
  /**
43
- * Resolve the child's `AgentOptions`: the parent's provider/model/maxTokens
44
- * route unless the request overrides it, stamped with the child's own
45
- * delegation depth.
43
+ * Resolve the parent values inherited by a child. The latest request header
44
+ * owns provider, model, and reasoning effort after request-time selection;
45
+ * creation options remain the fallback before the first request and retain
46
+ * the configured output-token limit.
47
+ * @param parent - delegating parent Agent.
48
+ * @returns detached Agent options for child-option merging.
49
+ */
50
+ export function parentAgentOptionsForDelegation(parent) {
51
+ const requestConfig = parent.session.requestHeader()?.config;
52
+ if (requestConfig === undefined)
53
+ return { ...parent.options };
54
+ const { provider: _createdProvider, model: _createdModel, reasoningEffort: _createdReasoningEffort, ...createdOptions } = parent.options;
55
+ return {
56
+ ...createdOptions,
57
+ provider: requestConfig.provider,
58
+ model: requestConfig.model,
59
+ ...requestConfig.reasoningEffort === undefined
60
+ ? {}
61
+ : { reasoningEffort: requestConfig.reasoningEffort },
62
+ };
63
+ }
64
+ /**
65
+ * Resolve the child's `AgentOptions`: the parent's provider/model,
66
+ * reasoning-effort, and maxTokens values unless the request overrides them,
67
+ * stamped with the child's own delegation depth. Changing the route without
68
+ * naming an effort clears the parent's route-owned effort so the selected
69
+ * model resolves its own default.
46
70
  * @param parent - the delegating parent whose route the child inherits.
47
71
  * @param requested - per-child overrides, if any.
48
72
  * @param childDepth - the resolved delegation depth to stamp.
49
73
  * @returns the resolved options for `ctx.agents.create()`.
50
74
  */
51
75
  export function resolveChildAgentOptions(parent, requested, childDepth) {
52
- const parentProvider = parent.options.provider;
53
- const parentModel = parent.options.model;
54
- const parentMaxTokens = parent.options.maxTokens;
55
- return {
76
+ const parentOptions = parentAgentOptionsForDelegation(parent);
77
+ const parentProvider = parentOptions.provider;
78
+ const parentModel = parentOptions.model;
79
+ const parentReasoningEffort = parentOptions.reasoningEffort;
80
+ const parentMaxTokens = parentOptions.maxTokens;
81
+ const resolved = {
56
82
  ...parentProvider !== undefined ? { provider: parentProvider } : {},
57
83
  ...parentModel !== undefined ? { model: parentModel } : {},
84
+ ...parentReasoningEffort !== undefined ? { reasoningEffort: parentReasoningEffort } : {},
58
85
  ...parentMaxTokens !== undefined ? { maxTokens: parentMaxTokens } : {},
59
86
  ...requested,
60
87
  subagentDepth: childDepth,
61
88
  };
89
+ const routeChanged = resolved.provider !== parentProvider || resolved.model !== parentModel;
90
+ if (routeChanged && requested?.reasoningEffort === undefined)
91
+ delete resolved.reasoningEffort;
92
+ return resolved;
62
93
  }
63
94
  /**
64
95
  * Build the child session's durable creation metadata: the parent's workspace,
@@ -125,10 +156,17 @@ export const SUBAGENT_DELEGATION_CONTEXT = 'You are a delegated subagent: your p
125
156
  */
126
157
  export function applyChildComposition(childCtx, parent, composition) {
127
158
  childCtx.get('agentPresets')?.composeFrom(childCtx, parent.ctx);
128
- // Order 120: after the sandbox:policy (110) and approval:policy (115) sentences.
129
- childCtx.systemPrompt.context({ name: 'subagent:delegation', order: 120, text: SUBAGENT_DELEGATION_CONTEXT });
159
+ childCtx.systemPrompt.context({
160
+ name: 'subagent:delegation',
161
+ order: childCtx.systemPrompt.getContextOrder('SUBAGENT_DELEGATION'),
162
+ text: SUBAGENT_DELEGATION_CONTEXT,
163
+ });
130
164
  if (composition.persona !== undefined) {
131
- childCtx.systemPrompt.section({ name: 'deployment:persona', order: 0, text: composition.persona });
165
+ childCtx.systemPrompt.section({
166
+ name: 'deployment:persona',
167
+ order: childCtx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA'),
168
+ text: composition.persona,
169
+ });
132
170
  }
133
171
  if (composition.toolFilter !== undefined)
134
172
  childCtx.tools.restrict(composition.toolFilter);
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Browser-safe subagent projection vocabulary.
2
+ * Browser-safe subagent projection and control vocabulary.
3
3
  *
4
4
  * @module @deepseek-ai/dsh-subagent/client
5
5
  */
6
+ export type * from './control-types.ts';
6
7
  export type { SubagentIdentityProjection, SubagentTimingProjection } from './projection-types.ts';
7
8
  //# sourceMappingURL=client.d.ts.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Browser-safe subagent projection vocabulary.
2
+ * Browser-safe subagent projection and control vocabulary.
3
3
  *
4
4
  * @module @deepseek-ai/dsh-subagent/client
5
5
  */
@@ -23,7 +23,7 @@
23
23
  import type { Context } from '@deepseek-ai/cordis';
24
24
  import type { Agent } from '@deepseek-ai/dsh-agent';
25
25
  import type { ContentBlock, MessageId, MessageSource } from '@deepseek-ai/dsh-llm';
26
- import { SessionId } from '@deepseek-ai/dsh-session';
26
+ import type { SessionId } from '@deepseek-ai/dsh-session';
27
27
  import type { SubagentDescriptorData } from './descriptor.ts';
28
28
  import type { ContinuableCreateRequest, ContinuableCreateSpec, SubagentStartRequest } from './types.ts';
29
29
  import type { ActivationObserver } from './lifecycle.ts';
@@ -323,7 +323,7 @@ export declare class SubagentContinuationManager {
323
323
  */
324
324
  private stateOf;
325
325
  /**
326
- * Cold-resume a persisted child: inspect and authorize its Session, fold the
326
+ * Cold-resume a persisted child: retain and authorize its prepared Session, fold the
327
327
  * generic descriptor, create the Activation through `ctx.agents.resume()`,
328
328
  * and submit the waiting turn. This never dispatches through a subagent
329
329
  * provider — the persisted Session already holds the initial prefix and the
@@ -340,6 +340,19 @@ export declare class SubagentContinuationManager {
340
340
  * @returns the accepted inbox message id.
341
341
  */
342
342
  private submitMaterialized;
343
+ /**
344
+ * Refuse image content addressed to a child whose model accepts text only.
345
+ * Callers guard with `contentHasImage`, so text-only delivery never awaits.
346
+ * The check runs inside the per-child delivery lock, before the message
347
+ * exists, so a rejection leaves no partial user message. When the child's
348
+ * route is not fixed by its options (a request-waterfall listener owns it)
349
+ * or no LLM registry is composed, delivery proceeds and the LLM layer's
350
+ * text-only projection replaces each image with its stable placeholder.
351
+ * @param agent - the live or freshly materialized child agent.
352
+ * @param signal - caller cancellation bounding the model-info read.
353
+ * @throws {SubagentError} `MODEL_DOES_NOT_SUPPORT_IMAGES` when the child's resolved model declines image input.
354
+ */
355
+ private assertImageCapable;
343
356
  /**
344
357
  * Create or resume the child Agent through the private activation-owner
345
358
  * scope, install the handle in a fresh Activation, and register ownership on
@@ -449,6 +462,8 @@ export declare class SubagentContinuationManager {
449
462
  private flushFinalState;
450
463
  /** Resolve the persistence service continuable children require, or fail loud. */
451
464
  private requirePersistence;
465
+ /** Resolve the Session query service used for cold child observations. */
466
+ private requireSessionQuery;
452
467
  }
453
468
  export type { SubagentDescriptorData };
454
469
  export default SubagentContinuationManager;