@morlay/dsh-subagent 0.0.9 → 0.0.10

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/dist/index.d.mts CHANGED
@@ -1252,9 +1252,9 @@ declare const deliverSubagentPrompt: unique symbol;
1252
1252
  //#region src/continuation-messages.d.ts
1253
1253
  /** Durable attribution for one model-authored message between Agents. */
1254
1254
  interface AgentMessageSource {
1255
- readonly kind: 'agent-message';
1255
+ readonly kind: "agent-message";
1256
1256
  /** A message another agent addressed to this one (`relay` context form). */
1257
- readonly form: 'relay';
1257
+ readonly form: "relay";
1258
1258
  /** Session id of the Agent whose tool call produced the message. */
1259
1259
  readonly senderSessionId: SessionId;
1260
1260
  }
@@ -1266,18 +1266,18 @@ interface AgentMessageSource {
1266
1266
  * transcript that merged them would credit the child with words it never wrote.
1267
1267
  */
1268
1268
  interface SubagentSettledMessageSource {
1269
- readonly kind: 'subagent-settled';
1269
+ readonly kind: "subagent-settled";
1270
1270
  /** A runtime account shown without expanding the row (`notice` context form). */
1271
- readonly form: 'notice';
1271
+ readonly form: "notice";
1272
1272
  /** One-line account of how the child ended. */
1273
1273
  readonly summary: string;
1274
1274
  /** Session id of the child that settled. */
1275
1275
  readonly senderSessionId: SessionId;
1276
1276
  }
1277
- declare module '@deepseek-ai/dsh-llm' {
1277
+ declare module "@deepseek-ai/dsh-llm" {
1278
1278
  interface MessageSourceMap {
1279
- 'agent-message': AgentMessageSource;
1280
- 'subagent-settled': SubagentSettledMessageSource;
1279
+ "agent-message": AgentMessageSource;
1280
+ "subagent-settled": SubagentSettledMessageSource;
1281
1281
  }
1282
1282
  }
1283
1283
  //#endregion
@@ -1323,7 +1323,7 @@ export declare class SubagentRuntime extends TypertRemoteService {
1323
1323
  * @param configured - Explicit tool limit, or provider-managed for external delegation.
1324
1324
  * @returns The numeric limit, or undefined when the provider owns depth enforcement.
1325
1325
  */
1326
- resolveMaxDepth(configured?: number | 'provider-managed'): number | undefined;
1326
+ resolveMaxDepth(configured?: number | "provider-managed"): number | undefined;
1327
1327
  /**
1328
1328
  * Start a local child under its reserved identity.
1329
1329
  * @param spec - local task, reserved child id, and result recipient.
@@ -1473,7 +1473,7 @@ export declare class SubagentRuntime extends TypertRemoteService {
1473
1473
  * `subagent/unauthorized` when the address does not own the live target,
1474
1474
  * otherwise `gateway/internal`.
1475
1475
  */
1476
- interruptByParent(childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable'): SubagentInterruptReceipt;
1476
+ interruptByParent(childSessionId: SessionId, parentSessionId: SessionId, mode: "continuable"): SubagentInterruptReceipt;
1477
1477
  /**
1478
1478
  * Register a provider under its name. Registration is effect-scoped and HMR
1479
1479
  * safe; removing a provider blocks new starts but does not revoke runs that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morlay/dsh-subagent",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Thin-shell fork of @deepseek-ai/dsh-subagent: takes over the official `subagent` row for two wording changes — the continuable child's return guidance in Chinese wording and the child's Chinese delegation-scope runtime context (`subagent:delegation`) — plus the row-id reuse (same `subagent` id, so the official settings card stays); everything not intentionally changed is imported from the vendored upstream source.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -4,19 +4,19 @@
4
4
  * @module @deepseek-ai/dsh-subagent/continuation-messages
5
5
  */
6
6
 
7
- import type { Agent } from '@deepseek-ai/dsh-agent'
8
- import { boundContextSummary, createUserMessage } from '@deepseek-ai/dsh-llm'
9
- import type { ContentBlock } from '@deepseek-ai/dsh-llm'
10
- import type { SessionId } from '@deepseek-ai/dsh-session'
11
- import type { SubagentResult } from './vendor/dsh-subagent/types.ts'
7
+ import type { Agent } from "@deepseek-ai/dsh-agent";
8
+ import { boundContextSummary, createUserMessage } from "@deepseek-ai/dsh-llm";
9
+ import type { ContentBlock } from "@deepseek-ai/dsh-llm";
10
+ import type { SessionId } from "@deepseek-ai/dsh-session";
11
+ import type { SubagentResult } from "./vendor/dsh-subagent/types.ts";
12
12
 
13
13
  /** Durable attribution for one model-authored message between Agents. */
14
14
  export interface AgentMessageSource {
15
- readonly kind: 'agent-message'
15
+ readonly kind: "agent-message";
16
16
  /** A message another agent addressed to this one (`relay` context form). */
17
- readonly form: 'relay'
17
+ readonly form: "relay";
18
18
  /** Session id of the Agent whose tool call produced the message. */
19
- readonly senderSessionId: SessionId
19
+ readonly senderSessionId: SessionId;
20
20
  }
21
21
 
22
22
  /**
@@ -27,29 +27,29 @@ export interface AgentMessageSource {
27
27
  * transcript that merged them would credit the child with words it never wrote.
28
28
  */
29
29
  export interface SubagentSettledMessageSource {
30
- readonly kind: 'subagent-settled'
30
+ readonly kind: "subagent-settled";
31
31
  /** A runtime account shown without expanding the row (`notice` context form). */
32
- readonly form: 'notice'
32
+ readonly form: "notice";
33
33
  /** One-line account of how the child ended. */
34
- readonly summary: string
34
+ readonly summary: string;
35
35
  /** Session id of the child that settled. */
36
- readonly senderSessionId: SessionId
36
+ readonly senderSessionId: SessionId;
37
37
  }
38
38
 
39
- declare module '@deepseek-ai/dsh-llm' {
39
+ declare module "@deepseek-ai/dsh-llm" {
40
40
  interface MessageSourceMap {
41
- 'agent-message': AgentMessageSource
42
- 'subagent-settled': SubagentSettledMessageSource
41
+ "agent-message": AgentMessageSource;
42
+ "subagent-settled": SubagentSettledMessageSource;
43
43
  }
44
44
  }
45
45
 
46
46
  /** Build durable attribution for one adjacent-Agent message. */
47
47
  function agentMessageSource(sender: Agent): AgentMessageSource {
48
48
  return {
49
- kind: 'agent-message',
50
- form: 'relay',
49
+ kind: "agent-message",
50
+ form: "relay",
51
51
  senderSessionId: sender.id,
52
- }
52
+ };
53
53
  }
54
54
 
55
55
  /**
@@ -63,12 +63,9 @@ export function createAgentMessage(
63
63
  content: ContentBlock[],
64
64
  ): ReturnType<typeof createUserMessage> {
65
65
  return createUserMessage({
66
- content: [
67
- { type: 'text' as const, text: `Agent ${sender.id} sent a message: ` },
68
- ...content,
69
- ],
66
+ content: [{ type: "text" as const, text: `Agent ${sender.id} sent a message: ` }, ...content],
70
67
  source: agentMessageSource(sender),
71
- })
68
+ });
72
69
  }
73
70
 
74
71
  /**
@@ -87,8 +84,8 @@ export function localizedReturnGuidance(
87
84
  composedPreset: string | undefined,
88
85
  configured: readonly string[],
89
86
  ): boolean {
90
- if (configured.length === 0) return true
91
- return composedPreset !== undefined && configured.includes(composedPreset)
87
+ if (configured.length === 0) return true;
88
+ return composedPreset !== undefined && configured.includes(composedPreset);
92
89
  }
93
90
  /**
94
91
  * Append adjacent-Agent return guidance to a continuable child's initial task.
@@ -100,16 +97,17 @@ export function withContinuableReturnGuidance(
100
97
  parentId: SessionId,
101
98
  prompt: ContentBlock[],
102
99
  ): ContentBlock[] {
103
- const encodedParentId = JSON.stringify(parentId)
100
+ const encodedParentId = JSON.stringify(parentId);
104
101
  return [
105
102
  ...prompt,
106
103
  {
107
- type: 'text',
108
- text: `你的父智能体 id 是 ${encodedParentId}。完成前用 send_message({ agent_id: ${encodedParentId}, `
109
- + 'message: "<自包含的结论>" }) 把结果发给它。父智能体与你共享工作区,但不会自动收到你的对话、'
110
- + '工具输出与推理过程。发现会改变父智能体下一步行动的事情时也尽早再发一条;发消息不会结束你的回合。',
104
+ type: "text",
105
+ text:
106
+ `你的父智能体 id 是 ${encodedParentId}。完成前用 send_message({ agent_id: ${encodedParentId}, ` +
107
+ 'message: "<自包含的结论>" }) 把结果发给它。父智能体与你共享工作区,但不会自动收到你的对话、' +
108
+ "工具输出与推理过程。发现会改变父智能体下一步行动的事情时也尽早再发一条;发消息不会结束你的回合。",
111
109
  },
112
- ]
110
+ ];
113
111
  }
114
112
 
115
113
  /**
@@ -120,28 +118,32 @@ export function withContinuableReturnGuidance(
120
118
  * @param continuable - whether the child accepts a later message.
121
119
  * @returns the model-facing opening line of the settlement notice.
122
120
  */
123
- function settlementSummary(childId: SessionId, stopReason: SubagentResult['stopReason'], continuable: boolean): string {
124
- const subject = `Background subagent ${childId}`
121
+ function settlementSummary(
122
+ childId: SessionId,
123
+ stopReason: SubagentResult["stopReason"],
124
+ continuable: boolean,
125
+ ): string {
126
+ const subject = `Background subagent ${childId}`;
125
127
  switch (stopReason) {
126
- case 'completed':
128
+ case "completed":
127
129
  return continuable
128
130
  ? `${subject} finished and will do no further work unless you send it more.`
129
- : `${subject} finished. It cannot receive follow-up messages.`
130
- case 'aborted':
131
- return `${subject} was stopped before it finished.`
132
- case 'max-tokens':
133
- return `${subject} ran out of room before it finished.`
131
+ : `${subject} finished. It cannot receive follow-up messages.`;
132
+ case "aborted":
133
+ return `${subject} was stopped before it finished.`;
134
+ case "max-tokens":
135
+ return `${subject} ran out of room before it finished.`;
134
136
  // A pre-step rejection — a hook deny, a policy plugin — discarded input
135
137
  // the child had claimed, so the parent must not treat the task as done.
136
- case 'refusal':
137
- return `${subject} declined the task.`
138
- case 'error':
139
- return `${subject} failed before it finished.`
138
+ case "refusal":
139
+ return `${subject} declined the task.`;
140
+ case "error":
141
+ return `${subject} failed before it finished.`;
140
142
  /* v8 ignore next 4 -- `SubagentResult['stopReason']` is merge-extensible, so this arm
141
143
  * needs a backend that adds a variant; an unnameable ending is reported as unfinished
142
144
  * rather than silently as success. */
143
145
  default:
144
- return `${subject} ended abnormally (${String(stopReason)}) before it finished.`
146
+ return `${subject} ended abnormally (${String(stopReason)}) before it finished.`;
145
147
  }
146
148
  }
147
149
 
@@ -157,29 +159,36 @@ export function createSettlementMessage(
157
159
  terminal: SubagentResult,
158
160
  continuable = true,
159
161
  ): ReturnType<typeof createUserMessage> {
160
- const summary = settlementSummary(childId, terminal.stopReason, continuable)
162
+ const summary = settlementSummary(childId, terminal.stopReason, continuable);
161
163
  // Parent providers receive this notice as a user message and may reject
162
164
  // nontext assistant blocks. Keep this conversion local so SDK/UI consumers
163
165
  // retain the complete child output.
164
- const closingText = terminal.output.flatMap(block =>
165
- block.type === 'text' && block.text.length > 0 ? [block] : [],
166
- )
166
+ const closingText = terminal.output.flatMap((block) =>
167
+ block.type === "text" && block.text.length > 0 ? [block] : [],
168
+ );
167
169
  return createUserMessage({
168
170
  content: [
169
- { type: 'text' as const, text: summary },
170
- ...closingText.length === 0
171
- ? [{ type: 'text' as const, text: 'It left no closing message.' }]
172
- : [{ type: 'text' as const, text: 'Its closing message:' }, ...closingText],
173
- ...terminal.structured !== undefined
174
- ? [{ type: 'text' as const, text: `Structured result: ${JSON.stringify(terminal.structured)}` }] : [],
175
- ...terminal.diagnostic !== undefined
176
- ? [{ type: 'text' as const, text: terminal.diagnostic }] : [],
171
+ { type: "text" as const, text: summary },
172
+ ...(closingText.length === 0
173
+ ? [{ type: "text" as const, text: "It left no closing message." }]
174
+ : [{ type: "text" as const, text: "Its closing message:" }, ...closingText]),
175
+ ...(terminal.structured !== undefined
176
+ ? [
177
+ {
178
+ type: "text" as const,
179
+ text: `Structured result: ${JSON.stringify(terminal.structured)}`,
180
+ },
181
+ ]
182
+ : []),
183
+ ...(terminal.diagnostic !== undefined
184
+ ? [{ type: "text" as const, text: terminal.diagnostic }]
185
+ : []),
177
186
  ],
178
187
  source: {
179
- kind: 'subagent-settled' as const,
180
- form: 'notice' as const,
188
+ kind: "subagent-settled" as const,
189
+ form: "notice" as const,
181
190
  summary: boundContextSummary(summary),
182
191
  senderSessionId: childId,
183
192
  },
184
- })
193
+ });
185
194
  }