@deepseek-ai/dsh-subagent-fork-in-process 0.2.2-alpha.3 → 0.2.2-rc.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 CHANGED
@@ -27,8 +27,8 @@
27
27
  en: d6058c358890c64c
28
28
  zh: 93f8cc2b60975d42
29
29
  /deepseek-ai-dsh-subagent-fork-in-process/use-this-package/what-a-fork-delegation-does:
30
- en: 461063deda821a1b
31
- zh: 18d2d41d64884f22
30
+ en: 69aa80db5f3aff0c
31
+ zh: 9b3b77ea42a6f29c
32
32
  /deepseek-ai-dsh-subagent-fork-in-process/understand-the-implementation:
33
33
  en: 6a0fe4b9cc780aaa
34
34
  zh: 50cd69ceb8296827
@@ -42,8 +42,8 @@
42
42
  en: cca92ec964b4314b
43
43
  zh: edd8ecd4b59dbe8f
44
44
  /deepseek-ai-dsh-subagent-fork-in-process/understand-the-implementation/lifecycle-binding:
45
- en: 8dad0155ed1b32d2
46
- zh: f4d82d5ede03c4d7
45
+ en: b4dee8f57a537f0a
46
+ zh: 0c759154a69de3ba
47
47
  /deepseek-ai-dsh-subagent-fork-in-process/further-exploration:
48
48
  en: 29ea6e0669b665a8
49
49
  zh: 46d435e79d356898
@@ -66,8 +66,8 @@
66
66
  en: 75d061c2151624a7
67
67
  zh: 71e58e020b60ff90
68
68
  /deepseek-ai-dsh-subagent-fork-in-process/model-experience/parent-tool-result-indirectly/what-the-model-sees:
69
- en: 54d10ba4da6cdece
70
- zh: bb9cb4d685098483
69
+ en: 7452223ab8b13d47
70
+ zh: f315ec4db035c652
71
71
  /deepseek-ai-dsh-subagent-fork-in-process/model-experience/parent-tool-result-indirectly/token-effect:
72
72
  en: 8c81bab3c5d6a38a
73
73
  zh: 44c798432a4bfdfb
package/README.md CHANGED
@@ -55,7 +55,7 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
55
55
 
56
56
  ### What a fork delegation does
57
57
 
58
- One tool call creates a background child and returns its session id immediately. The child works in its own session; the parent receives its final answer in a completion notice. The child can also send messages through `send_message`. A rejected start leaves no published child. Programmatic callers such as workflows can await the activation result directly.
58
+ One tool call creates a background child and returns its name immediately. The child works in its own session; the parent receives its final answer in a completion notice. The child can also send messages through `send_message`. A rejected start leaves no published child. Programmatic callers such as workflows can await the activation result directly.
59
59
 
60
60
  -----
61
61
 
@@ -83,7 +83,7 @@ This backend supplies the balanced completed-turn prefix of the parent log as th
83
83
 
84
84
  ### Lifecycle binding
85
85
 
86
- The delegation tool creates a background activation and returns a stable child session id. Parent and child share the same messaging tool definitions and ordering; the parent id and return guidance follow inherited history in the initial task. Workflows await results with caller delivery and send no completion notice to the parent.
86
+ The delegation tool creates a background activation and returns the child's name. Parent and child share the same messaging tool definitions and ordering; the parent's name in identity runtime context and the return guidance in the initial task both follow inherited history. Workflows await results with caller delivery and send no completion notice to the parent.
87
87
 
88
88
  </details>
89
89
 
@@ -123,7 +123,7 @@ The child may reuse the inherited byte-identical prefix under the same provider
123
123
 
124
124
  #### What the model sees
125
125
 
126
- Through `dsh-tool-subagent`, the parent first receives the child session id, then a completion notice with its final answer. Child-authored messages arrive through `send_message`; the inherited prefix and internal work remain in the child session.
126
+ Through `dsh-tool-subagent`, the parent first receives the child's name, then a completion notice with its final answer. Child-authored messages arrive through `send_message`; the inherited prefix and internal work remain in the child session.
127
127
 
128
128
  #### Token effect
129
129
 
package/README.zh.md CHANGED
@@ -55,7 +55,7 @@ kind: "package-reference"
55
55
 
56
56
  ### 一次 fork 委派会做什么
57
57
 
58
- 一次工具调用创建后台子 agent 并立即返回子会话 ID。子级在自己的会话中工作,父级通过完成通知收到其最终答案。子级也可以通过 `send_message` 发送消息。被拒绝的启动不会留下已发布的子 agent;工作流等程序调用方可以直接等待 activation 的结果。
58
+ 一次工具调用创建后台子 agent 并立即返回其名称。子级在自己的会话中工作,父级通过完成通知收到其最终答案。子级也可以通过 `send_message` 发送消息。被拒绝的启动不会留下已发布的子 agent;工作流等程序调用方可以直接等待 activation 的结果。
59
59
 
60
60
  -----
61
61
 
@@ -83,7 +83,7 @@ kind: "package-reference"
83
83
 
84
84
  ### 生命周期绑定
85
85
 
86
- 委派工具以后台 activation 创建子级,并返回稳定的子会话 ID。父级与子级共享相同的消息工具定义及顺序;父级 ID 与返回指导位于继承历史之后的初始任务中。工作流以调用方收集模式等待结果,不向父级发送完成通知。
86
+ 委派工具以后台 activation 创建子级,并返回子级名称。父级与子级共享相同的消息工具定义及顺序;身份运行时上下文中的父级名称和初始任务中的返回指导都位于继承历史之后。工作流以调用方收集模式等待结果,不向父级发送完成通知。
87
87
 
88
88
  </details>
89
89
 
@@ -123,7 +123,7 @@ fork 会把保留的已完成历史复制到子 agent 的请求中,子 agent
123
123
 
124
124
  #### 模型看到什么
125
125
 
126
- 父级通过 `dsh-tool-subagent` 先收到子会话 ID,随后收到包含最终答案的完成通知。子级自行编写的消息通过 `send_message` 到达;继承的前缀与内部工作保留在子会话中。
126
+ 父级通过 `dsh-tool-subagent` 先收到子级名称,随后收到包含最终答案的完成通知。子级自行编写的消息通过 `send_message` 到达;继承的前缀与内部工作保留在子会话中。
127
127
 
128
128
  #### Token 影响
129
129
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAUxC,eAAO,MAAM,IAAI,6BAA6B,CAAA;AAK9C,eAAO,MAAM,MAAM,UAAgB,CAAA;AAEnC,gEAAgE;AAChE,MAAM,WAAW,MAAM;IACrB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAE3B,CAAA;AA6CF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM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ACxE,sEAAsE;QACtE,2DAA2D;QAC3D,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAChD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IACzD,CAAC;CACF;AAED,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAc;IAChD,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;AAChF,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-subagent-fork-in-process",
3
3
  "description": "In-process fork subagent backend: runs a child agent seeded with a prefix of the parent's log",
4
- "version": "0.2.2-alpha.3",
4
+ "version": "0.2.2-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,28 +25,31 @@
25
25
  "files": [
26
26
  "locale/*.json",
27
27
  "lib/index.js",
28
- "lib/types/**/*.d.ts"
28
+ "lib/types/**/*.d.ts",
29
+ "lib/types/**/*.d.ts.map",
30
+ "lib/**/*.js.map",
31
+ "src"
29
32
  ],
30
33
  "license": "MIT",
31
34
  "peerDependencies": {
32
- "@deepseek-ai/dsh-agent": "0.2.2-alpha.3",
33
- "@deepseek-ai/dsh-session": "0.2.2-alpha.3",
34
- "@deepseek-ai/dsh-subagent": "0.2.2-alpha.3",
35
- "@deepseek-ai/cordis": "~4.0.6-alpha.2"
35
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
36
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
37
+ "@deepseek-ai/dsh-subagent": "0.2.2-rc.2",
38
+ "@deepseek-ai/cordis": "~4.1.0"
36
39
  },
37
40
  "dependencies": {
38
- "@deepseek-ai/schemastery": "~3.18.6-alpha.2"
41
+ "@deepseek-ai/schemastery": "~3.19.0"
39
42
  },
40
43
  "devDependencies": {
41
- "@deepseek-ai/cordis-plugin-loader": "~1.0.7-alpha.2",
42
- "@deepseek-ai/dsh-agent": "0.2.2-alpha.3",
43
- "@deepseek-ai/dsh-agent-loop": "0.2.2-alpha.3",
44
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-alpha.3",
45
- "@deepseek-ai/dsh-llm": "0.2.2-alpha.3",
46
- "@deepseek-ai/dsh-session": "0.2.2-alpha.3",
47
- "@deepseek-ai/dsh-subagent": "0.2.2-alpha.3",
48
- "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.2-alpha.3",
49
- "@deepseek-ai/cordis": "~4.0.6-alpha.2",
50
- "@deepseek-ai/dsh-session-projection": "0.2.2-alpha.3"
44
+ "@deepseek-ai/cordis-plugin-loader": "~1.1.0",
45
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
46
+ "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
47
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.2",
48
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
49
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
50
+ "@deepseek-ai/dsh-subagent": "0.2.2-rc.2",
51
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "0.2.2-rc.2",
52
+ "@deepseek-ai/cordis": "~4.1.0",
53
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2"
51
54
  }
52
55
  }
package/src/index.ts ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The in-process FORK subagent backend: registers a {@link SubagentProvider} on
3
+ * `ctx.subagents` that runs each child as a child {@link Agent} SEEDED with a prefix of the
4
+ * parent's session log — so the child inherits the parent's conversation context instead of
5
+ * starting fresh. The seed ends at the last `turn/end`: the current tool-call turn is
6
+ * unbalanced and cannot be replayed as a valid child session.
7
+ * @module @deepseek-ai/dsh-subagent-fork-in-process
8
+ */
9
+
10
+ import type { Context } from '@deepseek-ai/cordis'
11
+ import z from '@deepseek-ai/schemastery'
12
+ import type { SessionEvent } from '@deepseek-ai/dsh-session'
13
+ import type { Agent } from '@deepseek-ai/dsh-agent'
14
+ import type {
15
+ ContinuableCreateRequest,
16
+ ContinuableCreateSpec,
17
+ SubagentCapabilities,
18
+ SubagentProvider,
19
+ } from '@deepseek-ai/dsh-subagent'
20
+
21
+ export const name = 'subagent-fork-in-process'
22
+ // `tools` is deliberately NOT injected — same rationale as subagent-spawn-in-process: the
23
+ // per-run structured runtime gates its capture-tool registration on `tools`
24
+ // itself, so this backend's apply timing (and the delegation tool's position
25
+ // in the model-visible tool list) is unchanged by structured output.
26
+ export const inject = ['subagents']
27
+
28
+ /** Config: the registry name to register the provider under. */
29
+ export interface Config {
30
+ /** Provider name on `ctx.subagents` (default `fork`). */
31
+ providerName: string
32
+ }
33
+
34
+ export const Config: z<Config> = z.object({
35
+ providerName: z.string().default('fork'),
36
+ })
37
+
38
+ /**
39
+ * The balanced completed-turn prefix of `parent`'s log: every event up to and including the
40
+ * last `turn/end`. The in-flight turn is excluded; before any completed turn the child starts
41
+ * fresh. Because live sequence numbers equal array indexes, the result remains a valid seed
42
+ * beginning at sequence zero.
43
+ * @param parent - the agent whose session log to slice.
44
+ * @returns the seed events, contiguous from seq 0; empty when no turn has completed.
45
+ */
46
+ function completedTurnPrefix(parent: Agent): SessionEvent[] {
47
+ // oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
48
+ const events = parent.session.snapshotEvents()
49
+ const lastEnd = events.findLast(e => e.type === 'turn/end')
50
+ if (lastEnd === undefined) return []
51
+ // seq === array index (the append contract), so slice up to and including it.
52
+ return events.slice(0, lastEnd.seq + 1)
53
+ }
54
+
55
+ /**
56
+ * The fork provider. Supports `depthLimit` and `outputSchema` (via the shared
57
+ * in-process structured runtime), `agentOptions` (merged over the parent
58
+ * route). The child inherits its parent's preset composition.
59
+ */
60
+ class ForkInProcessProvider implements SubagentProvider {
61
+ readonly capabilities: SubagentCapabilities = {
62
+ agentOptions: true,
63
+ agentPreset: false,
64
+ outputSchema: true,
65
+ depthLimit: true,
66
+ }
67
+ // Context contract: a forked child IS seeded with the parent's completed-turn prefix.
68
+ readonly inheritsParentContext = true
69
+
70
+ constructor(readonly name: string) {}
71
+
72
+ prepareContinuable(request: ContinuableCreateRequest): Promise<ContinuableCreateSpec> {
73
+ // The fork prefix is captured ONCE, at creation: it becomes part of the
74
+ // child's own durable transcript, so a later cold resume replays that
75
+ // prefix instead of re-forking the parent's newer history.
76
+ const seed = completedTurnPrefix(request.parent)
77
+ return Promise.resolve(seed.length > 0 ? { seed } : {})
78
+ }
79
+ }
80
+
81
+ export function apply(ctx: Context, config: Config): void {
82
+ ctx.subagents.registerProvider(new ForkInProcessProvider(config.providerName))
83
+ }