@deepseek-ai/dsh-subagent 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.
Files changed (108) hide show
  1. package/README.i18n.yaml +46 -28
  2. package/README.md +52 -23
  3. package/README.zh.md +52 -23
  4. package/lib/index.js +845 -902
  5. package/lib/typert.host.js +91 -125
  6. package/lib/typert.remote-client.d.ts +3 -3
  7. package/lib/typert.remote-client.d.ts.map +1 -0
  8. package/lib/typert.remote-client.js +17 -63
  9. package/lib/types/activation.d.ts +17 -25
  10. package/lib/types/activation.d.ts.map +1 -0
  11. package/lib/types/activation.js +1 -1
  12. package/lib/types/activation.js.map +1 -0
  13. package/lib/types/archive-admission.d.ts +11 -4
  14. package/lib/types/archive-admission.d.ts.map +1 -0
  15. package/lib/types/archive-admission.js +39 -115
  16. package/lib/types/archive-admission.js.map +1 -0
  17. package/lib/types/assistant-output.d.ts.map +1 -0
  18. package/lib/types/assistant-output.js.map +1 -0
  19. package/lib/types/catalog.d.ts +27 -7
  20. package/lib/types/catalog.d.ts.map +1 -0
  21. package/lib/types/catalog.js +31 -8
  22. package/lib/types/catalog.js.map +1 -0
  23. package/lib/types/child-agent.d.ts +7 -17
  24. package/lib/types/child-agent.d.ts.map +1 -0
  25. package/lib/types/child-agent.js +6 -4
  26. package/lib/types/child-agent.js.map +1 -0
  27. package/lib/types/client.d.ts.map +1 -0
  28. package/lib/types/client.js.map +1 -0
  29. package/lib/types/continuation-messages.d.ts +13 -10
  30. package/lib/types/continuation-messages.d.ts.map +1 -0
  31. package/lib/types/continuation-messages.js +22 -22
  32. package/lib/types/continuation-messages.js.map +1 -0
  33. package/lib/types/control-types.d.ts +7 -28
  34. package/lib/types/control-types.d.ts.map +1 -0
  35. package/lib/types/control-types.js.map +1 -0
  36. package/lib/types/control.d.ts +0 -4
  37. package/lib/types/control.d.ts.map +1 -0
  38. package/lib/types/control.js +1 -5
  39. package/lib/types/control.js.map +1 -0
  40. package/lib/types/depth.d.ts.map +1 -0
  41. package/lib/types/depth.js.map +1 -0
  42. package/lib/types/descriptor.d.ts +1 -1
  43. package/lib/types/descriptor.d.ts.map +1 -0
  44. package/lib/types/descriptor.js +1 -1
  45. package/lib/types/descriptor.js.map +1 -0
  46. package/lib/types/error.d.ts.map +1 -0
  47. package/lib/types/error.js.map +1 -0
  48. package/lib/types/index.d.ts +74 -97
  49. package/lib/types/index.d.ts.map +1 -0
  50. package/lib/types/index.js +125 -146
  51. package/lib/types/index.js.map +1 -0
  52. package/lib/types/lifecycle.d.ts +9 -38
  53. package/lib/types/lifecycle.d.ts.map +1 -0
  54. package/lib/types/lifecycle.js +5 -31
  55. package/lib/types/lifecycle.js.map +1 -0
  56. package/lib/types/list-children.d.ts +12 -0
  57. package/lib/types/list-children.d.ts.map +1 -0
  58. package/lib/types/list-children.js +35 -6
  59. package/lib/types/list-children.js.map +1 -0
  60. package/lib/types/manager.d.ts +96 -112
  61. package/lib/types/manager.d.ts.map +1 -0
  62. package/lib/types/manager.js +471 -568
  63. package/lib/types/manager.js.map +1 -0
  64. package/lib/types/names.d.ts +56 -0
  65. package/lib/types/names.d.ts.map +1 -0
  66. package/lib/types/names.js +96 -0
  67. package/lib/types/names.js.map +1 -0
  68. package/lib/types/out-of-process.d.ts.map +1 -0
  69. package/lib/types/out-of-process.js.map +1 -0
  70. package/lib/types/projection-types.d.ts +18 -6
  71. package/lib/types/projection-types.d.ts.map +1 -0
  72. package/lib/types/projection-types.js.map +1 -0
  73. package/lib/types/projection.d.ts +2 -2
  74. package/lib/types/projection.d.ts.map +1 -0
  75. package/lib/types/projection.js.map +1 -0
  76. package/lib/types/structured.d.ts +1 -1
  77. package/lib/types/structured.d.ts.map +1 -0
  78. package/lib/types/structured.js +2 -2
  79. package/lib/types/structured.js.map +1 -0
  80. package/lib/types/types.d.ts +34 -28
  81. package/lib/types/types.d.ts.map +1 -0
  82. package/lib/types/types.js +2 -4
  83. package/lib/types/types.js.map +1 -0
  84. package/package.json +59 -59
  85. package/src/activation.ts +184 -0
  86. package/src/archive-admission.ts +84 -0
  87. package/src/assistant-output.ts +75 -0
  88. package/src/catalog.ts +194 -0
  89. package/src/child-agent.ts +280 -0
  90. package/src/client.ts +8 -0
  91. package/src/continuation-messages.ts +176 -0
  92. package/src/control-types.ts +127 -0
  93. package/src/control.ts +103 -0
  94. package/src/depth.ts +51 -0
  95. package/src/descriptor.ts +269 -0
  96. package/src/error.ts +15 -0
  97. package/src/index.ts +604 -0
  98. package/src/lifecycle.ts +116 -0
  99. package/src/list-children.ts +168 -0
  100. package/src/manager.ts +1359 -0
  101. package/src/names.ts +113 -0
  102. package/src/out-of-process.ts +217 -0
  103. package/src/projection-types.ts +109 -0
  104. package/src/projection.ts +184 -0
  105. package/src/structured.ts +155 -0
  106. package/src/types.ts +364 -0
  107. package/lib/types/internal.d.ts +0 -58
  108. package/lib/types/internal.js +0 -58
@@ -3,22 +3,16 @@ import { z } from 'zod'
3
3
 
4
4
  import { createTypertRemoteInfo } from '@deepseek-ai/dsh-typert-protocol/remote-info'
5
5
 
6
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema$value
7
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema$value ??= z.string())
8
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema$value
9
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema$value ??= z.string())
10
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema$value
11
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema$value ??= z.literal("continuable"))
12
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value
13
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema$value ??= z.object({
6
+ let _deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0$schema$value
7
+ const _deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0$schema$value ??= z.string())
8
+ let _deepseek_ai_dsh_subagent_subagents_interruptByUser_result$schema$value
9
+ const _deepseek_ai_dsh_subagent_subagents_interruptByUser_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByUser_result$schema$value ??= z.object({
14
10
  'accepted': z.literal(true).readonly(),
15
11
  }))
16
12
  let _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value
17
13
  const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema$value ??= z.object({
18
14
  'requestId': z.string().readonly().describe('Identity persisted on the accepted message, minted before the call.'),
19
- 'parentSessionId': z.string().readonly(),
20
15
  'childSessionId': z.string().readonly(),
21
- 'mode': z.literal("continuable").readonly().describe('Required discriminator retained from the browser control address.'),
22
16
  'delivery': z.union([z.literal("queue"), z.literal("steer")]).readonly().describe('Whether this message queues a later turn or targets the nearest step.'),
23
17
  'content': z.array(z.union([z.object({
24
18
  'type': z.literal("text").readonly(),
@@ -35,18 +29,12 @@ let _deepseek_ai_dsh_subagent_subagents_prompt_result$schema$value
35
29
  const _deepseek_ai_dsh_subagent_subagents_prompt_result$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_result$schema$value ??= z.object({
36
30
  'messageId': z.string().readonly(),
37
31
  }))
38
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0_strict$schema$value
39
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0_strict$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0_strict$schema$value ??= z.string())
40
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1_strict$schema$value
41
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1_strict$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1_strict$schema$value ??= z.string())
42
- let _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2_strict$schema$value
43
- const _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2_strict$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2_strict$schema$value ??= z.literal("continuable"))
32
+ let _deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0_strict$schema$value
33
+ const _deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0_strict$schema = () => (_deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0_strict$schema$value ??= z.string())
44
34
  let _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0_strict$schema$value
45
35
  const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0_strict$schema = () => (_deepseek_ai_dsh_subagent_subagents_prompt_parameter_0_strict$schema$value ??= z.strictObject({
46
36
  'requestId': z.string().readonly().describe('Identity persisted on the accepted message, minted before the call.'),
47
- 'parentSessionId': z.string().readonly(),
48
37
  'childSessionId': z.string().readonly(),
49
- 'mode': z.literal("continuable").readonly().describe('Required discriminator retained from the browser control address.'),
50
38
  'delivery': z.union([z.literal("queue"), z.literal("steer")]).readonly().describe('Whether this message queues a later turn or targets the nearest step.'),
51
39
  'content': z.array(z.union([z.strictObject({
52
40
  'type': z.literal("text").readonly(),
@@ -63,9 +51,9 @@ const _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0_strict$schema = ()
63
51
  export const TYPERT_REMOTE = createTypertRemoteInfo({
64
52
  package: '@deepseek-ai/dsh-subagent',
65
53
  methods: {
66
- 'subagents/interruptByParent': {
54
+ 'subagents/interruptByUser': {
67
55
  service: 'subagents',
68
- description: 'Remote face of {@link interrupt} under one durable parent address. No catalog, history, persistence, or parent Agent lookup runs: the core primitive alone authorizes the address against the live Activation, which is what keeps a live child interruptible while its parent Agent is offline. Absent, idle, and already-completed targets are accepted no-ops there.',
56
+ description: 'Remote face of {@link interrupt}, authorized on the target Session by the Gateway. No catalog, history, persistence, or parent Agent lookup runs. Absent, idle, and already-completed targets are accepted no-ops there.',
69
57
  invocation: { kind: 'direct' },
70
58
  parameters: [
71
59
  {
@@ -75,80 +63,46 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
75
63
  codec: {
76
64
  mode: 'strict',
77
65
  typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
78
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0$schema,
66
+ create: _deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0$schema,
79
67
  jsonSchema: {"type":"string"},
80
68
  },
81
69
  strictCodec: {
82
70
  mode: 'strict',
83
71
  typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
84
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_0_strict$schema,
72
+ create: _deepseek_ai_dsh_subagent_subagents_interruptByUser_parameter_0_strict$schema,
85
73
  jsonSchema: {"type":"string"},
86
74
  },
87
75
  },
88
- {
89
- name: 'parentSessionId',
90
- description: 'durable direct parent whose authority is claimed.',
91
- source: 'json',
92
- codec: {
93
- mode: 'strict',
94
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
95
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1$schema,
96
- jsonSchema: {"type":"string"},
97
- },
98
- strictCodec: {
99
- mode: 'strict',
100
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
101
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_1_strict$schema,
102
- jsonSchema: {"type":"string"},
103
- },
104
- },
105
- {
106
- name: 'mode',
107
- description: 'required continuable-address discriminator.',
108
- source: 'json',
109
- codec: {
110
- mode: 'strict',
111
- typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
112
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2$schema,
113
- jsonSchema: {"type":"string","const":"continuable"},
114
- },
115
- strictCodec: {
116
- mode: 'strict',
117
- typeSymbol: '@deepseek-ai/dsh-subagent#subagents/interruptByParent:mode',
118
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_parameter_2_strict$schema,
119
- jsonSchema: {"type":"string","const":"continuable"},
120
- },
121
- },
122
76
  ],
123
77
  result: {
124
78
  mode: 'strict',
125
79
  typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentInterruptReceipt',
126
- create: _deepseek_ai_dsh_subagent_subagents_interruptByParent_result$schema,
80
+ create: _deepseek_ai_dsh_subagent_subagents_interruptByUser_result$schema,
127
81
  description: 'acknowledgement that the cancel signal was admitted, not that the target is quiescent.',
128
82
  jsonSchema: {"type":"object","properties":{"accepted":{"type":"boolean","const":true}},"required":["accepted"],"additionalProperties":true},
129
83
  },
130
- sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":519,"column":3},
84
+ sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":504,"column":3},
131
85
  },
132
86
  'subagents/prompt': {
133
87
  service: 'subagents',
134
- description: '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. Success identifies the message the child\'s inbox accepted; later execution is independent of this call. Queue delivery targets a later turn; steer delivery targets the nearest step and retains the Agent loop\'s best-effort fallback semantics. Image parts are admitted and persisted through the attachment store before delivery, and the child\'s model must accept image input. Cold resume at capacity rejects with `subagent/delivery-unavailable`.',
88
+ description: 'Deliver one browser-authored message to a continuable child through its live subagent tree root, retaining the caller-minted request identity and validated browser zone on the accepted message. Success identifies the message the child\'s inbox accepted; later execution is independent of this call. Queue delivery targets a later turn; steer delivery targets the nearest step and retains the Agent loop\'s best-effort fallback semantics. Image parts are admitted and persisted through the attachment store before delivery, and the child\'s model must accept image input. Cold resume at capacity rejects with `subagent/delivery-unavailable`. Access is checked on the target Session before attachment admission or restoration.',
135
89
  invocation: { kind: 'direct' },
136
90
  parameters: [
137
91
  {
138
92
  name: 'request',
139
- description: 'durable address, delivery, minted identity, content, and optional browser zone.',
93
+ description: 'target id, delivery, minted identity, content, and optional browser zone.',
140
94
  source: 'json',
141
95
  codec: {
142
96
  mode: 'strict',
143
97
  typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
144
98
  create: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0$schema,
145
- jsonSchema: {"type":"object","properties":{"requestId":{"type":"string","description":"Identity persisted on the accepted message, minted before the call."},"parentSessionId":{"type":"string"},"childSessionId":{"type":"string"},"mode":{"type":"string","const":"continuable","description":"Required discriminator retained from the browser control address."},"delivery":{"type":"string","enum":["queue","steer"],"description":"Whether this message queues a later turn or targets the nearest step."},"content":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","const":"text"},"text":{"type":"string"}},"required":["type","text"],"additionalProperties":true},{"type":"object","properties":{"type":{"type":"string","const":"image"},"mediaType":{"type":"string","enum":["image/png","image/jpeg","image/webp","image/gif"]},"data":{"type":"string"},"name":{"type":"string"}},"required":["type","mediaType","data"],"additionalProperties":true}]},"description":"Browser prompt parts delivered as the child's user message. The Host admits and persists image parts before delivery, so the wire never carries a durable attachment reference the caller could fabricate."},"clientTimeZone":{"type":"string","description":"Optional browser zone sampled for this exact human prompt."}},"required":["requestId","parentSessionId","childSessionId","mode","delivery","content"],"additionalProperties":true},
99
+ jsonSchema: {"type":"object","properties":{"requestId":{"type":"string","description":"Identity persisted on the accepted message, minted before the call."},"childSessionId":{"type":"string"},"delivery":{"type":"string","enum":["queue","steer"],"description":"Whether this message queues a later turn or targets the nearest step."},"content":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","const":"text"},"text":{"type":"string"}},"required":["type","text"],"additionalProperties":true},{"type":"object","properties":{"type":{"type":"string","const":"image"},"mediaType":{"type":"string","enum":["image/png","image/jpeg","image/webp","image/gif"]},"data":{"type":"string"},"name":{"type":"string"}},"required":["type","mediaType","data"],"additionalProperties":true}]},"description":"Browser prompt parts delivered as the child's user message. The Host admits and persists image parts before delivery, so the wire never carries a durable attachment reference the caller could fabricate."},"clientTimeZone":{"type":"string","description":"Optional browser zone sampled for this exact human prompt."}},"required":["requestId","childSessionId","delivery","content"],"additionalProperties":true},
146
100
  },
147
101
  strictCodec: {
148
102
  mode: 'strict',
149
103
  typeSymbol: '@deepseek-ai/dsh-subagent/client#SubagentPromptRequest',
150
104
  create: _deepseek_ai_dsh_subagent_subagents_prompt_parameter_0_strict$schema,
151
- jsonSchema: {"type":"object","properties":{"requestId":{"type":"string","description":"Identity persisted on the accepted message, minted before the call."},"parentSessionId":{"type":"string"},"childSessionId":{"type":"string"},"mode":{"type":"string","const":"continuable","description":"Required discriminator retained from the browser control address."},"delivery":{"type":"string","enum":["queue","steer"],"description":"Whether this message queues a later turn or targets the nearest step."},"content":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","const":"text"},"text":{"type":"string"}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"image"},"mediaType":{"type":"string","enum":["image/png","image/jpeg","image/webp","image/gif"]},"data":{"type":"string"},"name":{"type":"string"}},"required":["type","mediaType","data"],"additionalProperties":false}]},"description":"Browser prompt parts delivered as the child's user message. The Host admits and persists image parts before delivery, so the wire never carries a durable attachment reference the caller could fabricate."},"clientTimeZone":{"type":"string","description":"Optional browser zone sampled for this exact human prompt."}},"required":["requestId","parentSessionId","childSessionId","mode","delivery","content"],"additionalProperties":false},
105
+ jsonSchema: {"type":"object","properties":{"requestId":{"type":"string","description":"Identity persisted on the accepted message, minted before the call."},"childSessionId":{"type":"string"},"delivery":{"type":"string","enum":["queue","steer"],"description":"Whether this message queues a later turn or targets the nearest step."},"content":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","const":"text"},"text":{"type":"string"}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"image"},"mediaType":{"type":"string","enum":["image/png","image/jpeg","image/webp","image/gif"]},"data":{"type":"string"},"name":{"type":"string"}},"required":["type","mediaType","data"],"additionalProperties":false}]},"description":"Browser prompt parts delivered as the child's user message. The Host admits and persists image parts before delivery, so the wire never carries a durable attachment reference the caller could fabricate."},"clientTimeZone":{"type":"string","description":"Optional browser zone sampled for this exact human prompt."}},"required":["requestId","childSessionId","delivery","content"],"additionalProperties":false},
152
106
  },
153
107
  },
154
108
  ],
@@ -160,7 +114,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
160
114
  description: 'the accepted message\'s inbox identity.',
161
115
  jsonSchema: {"type":"object","properties":{"messageId":{"type":"string"}},"required":["messageId"],"additionalProperties":true},
162
116
  },
163
- sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":450,"column":9},
117
+ sourceLocation: {"file":"packages/subagent/subagent/src/index.ts","line":451,"column":9},
164
118
  },
165
119
  },
166
120
  }, z)
@@ -3,10 +3,9 @@
3
3
  */
4
4
  import type { Agent, AgentHandle } from '@deepseek-ai/dsh-agent';
5
5
  import type { SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session';
6
- import type { ActivationObserver } from './lifecycle.ts';
7
6
  import type { StructuredAttachment } from './structured.ts';
8
- import type { SubagentResult, SubagentRun } from './types.ts';
9
- /** Process-local slots shared through uninterrupted continuable parent links. */
7
+ import type { SubagentResult, SubagentRun, SubagentRunId } from './types.ts';
8
+ /** Process-local capacity shared by every member of a subagent tree. */
10
9
  export declare class ActivationPool {
11
10
  private readonly slots;
12
11
  /**
@@ -21,37 +20,30 @@ export declare class ActivationPool {
21
20
  * The manager owns admission, execution handles, and resource release.
22
21
  */
23
22
  interface ActivationBase {
24
- /** Shared capacity for this Activation and all its managed descendants. */
25
- readonly pool: ActivationPool;
26
23
  /** Return this epoch's slot after its handle has finished disposal. */
27
24
  readonly releaseSlot: () => void;
28
25
  /** The durable child this Activation is an epoch of. */
29
26
  readonly childId: SessionId;
30
- readonly parent: Agent;
27
+ /** Unique identity shared by this residency epoch's start/end event pair. */
28
+ readonly runId: SubagentRunId;
29
+ /** Provider recorded at creation, retained across cold resumes. */
30
+ readonly provider: string;
31
+ /** Exact live subagent tree root owning this instance and its shared capacity. */
32
+ readonly root: Agent;
33
+ /** Verified creation ancestors, from subagent tree root to direct creator. */
34
+ readonly ancestors: readonly SessionId[];
35
+ /** Slash-separated names from the root; undefined when this child or a creator below the root has no name. */
36
+ readonly path: string | undefined;
31
37
  readonly delivery: 'parent' | 'caller';
32
38
  readonly result: PromiseWithResolvers<SubagentResult>;
33
39
  /** Published synchronously before teardown; subsequent callers share this transaction. */
34
40
  closing: Promise<void> | undefined;
35
41
  /**
36
- * Exact live Agent ancestry observed when this Activation materialized.
37
- * Weak membership preserves host-scope identity across an intermediate
38
- * ancestor leaving the registry without retaining that ancestor's runtime.
42
+ * Whether local input was accepted or external startup completed, including
43
+ * any required catalog publication. Until then, teardown owes the parent no
44
+ * settlement notice, even if this epoch's start event was already published.
39
45
  */
40
- readonly ancestry: WeakSet<Agent>;
41
- /**
42
- * Session ids of the child Activations this one owns. Because one Session has
43
- * at most one live Activation, the id identifies the live child without
44
- * another runtime-incarnation reference. Non-empty blocks settlement.
45
- */
46
- readonly ownedChildren: Set<SessionId>;
47
- /** The lifecycle observer that emits this epoch's start and terminal edges. */
48
- readonly observer: ActivationObserver;
49
- /**
50
- * Whether any delivery to this child was ever accepted. A materialization
51
- * rolled back before its first acceptance is a child the caller was told does
52
- * not exist, so its teardown owes the parent no settlement account.
53
- */
54
- announced: boolean;
46
+ accepted: boolean;
55
47
  }
56
48
  /** Resources retained only for the selected execution kind. */
57
49
  export type ActivationResource = {
@@ -61,7 +53,7 @@ export type ActivationResource = {
61
53
  readonly structured: StructuredAttachment | undefined;
62
54
  /** Latest live failure not superseded by a later committed turn ending. */
63
55
  failureAt: SessionLogOffset | undefined;
64
- /** Renewed when local settlement must recheck input or owned children. */
56
+ /** Renewed when local settlement must recheck input. */
65
57
  poke: PromiseWithResolvers<void>;
66
58
  /**
67
59
  * Whether this child's settlement notice omits its closing text: true while
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../src/activation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAK3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE5E,wEAAwE;AACxE,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAE1C;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,IAAI;CAYtC;AAED;;;GAGG;AACH,UAAU,cAAc;IACtB,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;IAChC,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,SAAS,SAAS,EAAE,CAAA;IACxC,8GAA8G;IAC9G,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAA;IACtC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC,cAAc,CAAC,CAAA;IACrD,0FAA0F;IAC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;AACtE,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAyC;IAEtD;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAYpE"}
@@ -5,7 +5,7 @@ import { assertNever } from '@deepseek-ai/dsh-util-values';
5
5
  import { finalAssistantOutput } from "./assistant-output.js";
6
6
  import { epochStopReason } from "./lifecycle.js";
7
7
  import { SubagentError } from "./error.js";
8
- /** Process-local slots shared through uninterrupted continuable parent links. */
8
+ /** Process-local capacity shared by every member of a subagent tree. */
9
9
  export class ActivationPool {
10
10
  slots = new Set();
11
11
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activation.js","sourceRoot":"","sources":["../../src/activation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAI1C,wEAAwE;AACxE,MAAM,OAAO,cAAc;IACR,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAE1C;;;;OAIG;IACH,OAAO,CAAC,QAAgB;QACtB,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,aAAa,CACrB,+CAA+C,QAAQ,0CAA0C;kBAC/F,+CAA+C,EACjD,0BAA0B,CAC3B,CAAA;QACH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,EAAE,CAAA;QACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACpB,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,C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E,2CAA2C;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC7B,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YAClB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI;gBAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAClE,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
@@ -1,16 +1,23 @@
1
1
  /**
2
2
  * The `subagent` family of the Workspace registry's archive admission: which
3
3
  * subagent descendants of a Session are still inside a turn, and how they
4
- * stop when the Session is archived with its work.
4
+ * stop when the Session is archived with its work. Archived ancestors also
5
+ * block later model steps, including when their Sessions have been released.
5
6
  *
6
7
  * @module @deepseek-ai/dsh-subagent
7
8
  */
8
9
  import type { Context } from '@deepseek-ai/cordis';
10
+ import type { Agent } from '@deepseek-ai/dsh-agent';
11
+ import type { Session, SessionId } from '@deepseek-ai/dsh-session';
12
+ import type { SubagentIdentityProjection } from './projection-types.ts';
9
13
  /**
10
14
  * Answer `workspace/session-activity` with the running subagent descendants of
11
15
  * the asked Session, and `workspace/session-stop` by cancelling each of them
12
- * as their parent would. Both listeners live as long as `ctx`'s fiber.
13
- * @param ctx - context carrying the Agent registry; the Session query service is optional and only supplies labels.
16
+ * as their parent would. Reject subsequent steps beneath archived ancestors.
17
+ * All listeners live as long as `ctx`'s fiber.
18
+ * @param ctx - context carrying the Agent registry.
19
+ * @param residentAncestors - verified creation ancestors for an exact managed Agent, absent before publication or for unmanaged Agents.
20
+ * @param identityOf - ready service-owned descriptor identity reader; absent or invalid descriptors yield no identity.
14
21
  */
15
- export declare function installSubagentArchiveAdmission(ctx: Context): void;
22
+ export declare function installSubagentArchiveAdmission(ctx: Context, residentAncestors: (agent: Agent) => readonly SessionId[] | undefined, identityOf: (session: Session) => SubagentIdentityProjection | undefined): void;
16
23
  //# sourceMappingURL=archive-admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-admission.d.ts","sourceRoot":"","sources":["../../src/archive-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAEvE;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,OAAO,EACZ,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,SAAS,EAAE,GAAG,SAAS,EACrE,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,0BAA0B,GAAG,SAAS,GACvE,IAAI,CA2BN"}
@@ -1,80 +1,34 @@
1
1
  /**
2
2
  * The `subagent` family of the Workspace registry's archive admission: which
3
3
  * subagent descendants of a Session are still inside a turn, and how they
4
- * stop when the Session is archived with its work.
4
+ * stop when the Session is archived with its work. Archived ancestors also
5
+ * block later model steps, including when their Sessions have been released.
5
6
  *
6
7
  * @module @deepseek-ai/dsh-subagent
7
8
  */
8
- var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
9
- if (value !== null && value !== void 0) {
10
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
11
- var dispose, inner;
12
- if (async) {
13
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
14
- dispose = value[Symbol.asyncDispose];
15
- }
16
- if (dispose === void 0) {
17
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
18
- dispose = value[Symbol.dispose];
19
- if (async) inner = dispose;
20
- }
21
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
22
- if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
23
- env.stack.push({ value: value, dispose: dispose, async: async });
24
- }
25
- else if (async) {
26
- env.stack.push({ async: true });
27
- }
28
- return value;
29
- };
30
- var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
31
- return function (env) {
32
- function fail(e) {
33
- env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
34
- env.hasError = true;
35
- }
36
- var r, s = 0;
37
- function next() {
38
- while (r = env.stack.pop()) {
39
- try {
40
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
41
- if (r.dispose) {
42
- var result = r.dispose.call(r.value);
43
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
44
- }
45
- else s |= 1;
46
- }
47
- catch (e) {
48
- fail(e);
49
- }
50
- }
51
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
52
- if (env.hasError) throw env.error;
53
- }
54
- return next();
55
- };
56
- })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
57
- var e = new Error(message);
58
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
59
- });
60
- import { foldSubagentDescriptor } from "./descriptor.js";
61
9
  /**
62
10
  * Answer `workspace/session-activity` with the running subagent descendants of
63
11
  * the asked Session, and `workspace/session-stop` by cancelling each of them
64
- * as their parent would. Both listeners live as long as `ctx`'s fiber.
65
- * @param ctx - context carrying the Agent registry; the Session query service is optional and only supplies labels.
12
+ * as their parent would. Reject subsequent steps beneath archived ancestors.
13
+ * All listeners live as long as `ctx`'s fiber.
14
+ * @param ctx - context carrying the Agent registry.
15
+ * @param residentAncestors - verified creation ancestors for an exact managed Agent, absent before publication or for unmanaged Agents.
16
+ * @param identityOf - ready service-owned descriptor identity reader; absent or invalid descriptors yield no identity.
66
17
  */
67
- export function installSubagentArchiveAdmission(ctx) {
18
+ export function installSubagentArchiveAdmission(ctx, residentAncestors, identityOf) {
19
+ const ancestorsOf = (agent) => residentAncestors(agent) ?? headerAncestors(ctx, agent);
20
+ const runningDescendants = (sessionId) => ctx.agents.list()
21
+ .filter(agent => agent.status === 'running' && ancestorsOf(agent).includes(sessionId));
68
22
  ctx.on('workspace/session-activity', async ({ sessionId }, next) => {
69
- const running = runningDescendants(ctx, sessionId);
23
+ const running = runningDescendants(sessionId);
70
24
  const rest = await next();
71
25
  if (running.length === 0)
72
26
  return rest;
73
- const own = { kind: 'subagent', items: await Promise.all(running.map(child => describe(ctx, child))) };
27
+ const own = { kind: 'subagent', items: running.map(child => describe(child, identityOf(child.session))) };
74
28
  return [own, ...rest];
75
29
  });
76
30
  ctx.on('workspace/session-stop', ({ sessionId }) => {
77
- for (const child of runningDescendants(ctx, sessionId)) {
31
+ for (const child of runningDescendants(sessionId)) {
78
32
  try {
79
33
  child.cancel({ kind: 'parent' });
80
34
  }
@@ -84,68 +38,38 @@ export function installSubagentArchiveAdmission(ctx) {
84
38
  }
85
39
  }
86
40
  });
41
+ ctx.on('agent/pre-step', ({ agent }, next) => {
42
+ const archived = ctx.get('workspaceRegistry')?.archivedSessionIds;
43
+ return archived !== undefined && ancestorsOf(agent).some(id => archived.includes(id))
44
+ ? Promise.resolve({ kind: 'reject' })
45
+ : next();
46
+ });
87
47
  }
88
48
  /**
89
- * Live subagent descendants inside a turn, by durable lineage: a child whose
90
- * header names its parent and carries the subagent origin this package
91
- * records, at any depth. A fork shares the lineage field without the origin
92
- * and is an independent conversation, so it never holds its source. Lineage
93
- * is read as data, so a damaged header chain that loops is visited once.
49
+ * Header-only ancestry for Agents without a published Activation. Include an
50
+ * offline direct creator; ordinary forks stop the chain and cycles terminate.
94
51
  */
95
- function runningDescendants(ctx, rootId) {
96
- const childrenOf = new Map();
97
- for (const agent of ctx.agents.list()) {
98
- const { parentSession, origin } = agent.session.header;
99
- if (parentSession === undefined || origin !== 'subagent')
100
- continue;
101
- const siblings = childrenOf.get(parentSession) ?? [];
102
- siblings.push(agent);
103
- childrenOf.set(parentSession, siblings);
104
- }
105
- const running = [];
106
- const pending = [rootId];
107
- const visited = new Set();
108
- while (pending.length > 0) {
109
- const parentId = pending.shift();
110
- if (visited.has(parentId))
111
- continue;
52
+ function headerAncestors(ctx, agent) {
53
+ const ancestors = [];
54
+ const visited = new Set([agent.id]);
55
+ let header = agent.session.header;
56
+ while (header.origin === 'subagent' && header.parentSession !== undefined && !visited.has(header.parentSession)) {
57
+ const parentId = header.parentSession;
58
+ ancestors.push(parentId);
112
59
  visited.add(parentId);
113
- for (const child of childrenOf.get(parentId) ?? []) {
114
- if (child.status === 'running')
115
- running.push(child);
116
- pending.push(child.id);
117
- }
60
+ const parent = ctx.agents.get(parentId)?.session;
61
+ if (parent === undefined)
62
+ break;
63
+ header = parent.header;
118
64
  }
119
- return running;
65
+ return ancestors;
120
66
  }
121
67
  /**
122
- * The child's activity item: its id, plus the durable creation label its
123
- * descriptor carries, read through a live Session observation. Without the
124
- * Session query service, or with a descriptor that is absent or unreadable,
125
- * the item names the child by id alone.
68
+ * Report the child's current projected label only when its descriptor belongs
69
+ * to the child's own log; inherited, absent, or invalid identities yield the id alone.
126
70
  */
127
- async function describe(ctx, child) {
128
- const query = ctx.get('sessionQuery');
129
- if (query === undefined)
130
- return { id: child.id };
131
- try {
132
- const env_1 = { stack: [], error: void 0, hasError: false };
133
- try {
134
- const observation = __addDisposableResource(env_1, await query.observeSession(child.id, { projectionMode: 'none' }), false);
135
- const label = foldSubagentDescriptor(observation.events.slice(observation.inheritedEventCount))?.label;
136
- return label === undefined ? { id: child.id } : { id: child.id, label };
137
- }
138
- catch (e_1) {
139
- env_1.error = e_1;
140
- env_1.hasError = true;
141
- }
142
- finally {
143
- __disposeResources(env_1);
144
- }
145
- }
146
- catch {
147
- // A damaged descriptor is data damage in the child; the report still names the child.
148
- return { id: child.id };
149
- }
71
+ function describe(child, identity) {
72
+ const label = identity !== undefined && child.session.isOwnSeq(identity.seq) ? identity.label : undefined;
73
+ return label === undefined ? { id: child.id } : { id: child.id, label };
150
74
  }
151
75
  //# sourceMappingURL=archive-admission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-admission.js","sourceRoot":"","sources":["../../src/archive-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAC7C,GAAY,EACZ,iBAAqE,EACrE,UAAwE;IAExE,MAAM,WAAW,GAAG,CAAC,KAAY,EAAwB,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACnH,MAAM,kBAAkB,GAAG,CAAC,SAAoB,EAAW,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;SAC5E,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;IACxF,GAAG,CAAC,EAAE,CAAC,4BAA4B,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE;QACjE,MAAM,OAAO,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAA;QAC7C,MAAM,IAAI,GAAG,MAAM,IAAI,EAAE,CAAA;QACzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACrC,MAAM,GAAG,GAAoB,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;QAC1H,OAAO,CA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,IAAI,CAAC,CAAA;IAC9C,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAClC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC/D,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA+B;IAClE,2EAA2E;IAC3E,0EAA0E;IAC1E,uEAAuE;IACvE,uBAAuB;IACvB,MAAM,IAAI,GAAG,IAAI,mBAAmB,EAAE,CAAA;IACtC,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO,IAAI,CAAC,OAAO,EAAE,CAAA;AACvB,CAAC"}
@@ -7,8 +7,8 @@ import { z } from 'zod';
7
7
  import type { ChunkedList } from '@deepseek-ai/dsh-chunked-list';
8
8
  import type { Session, SessionEvent, SessionHeader, SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session';
9
9
  import type { SubagentCatalogEntry } from './projection-types.ts';
10
- /** Catalog payload version emitted by local child creation. */
11
- export declare const SUBAGENT_CATALOG_VERSION = 0;
10
+ /** Catalog payload version emitted by local and external child creation. */
11
+ export declare const SUBAGENT_CATALOG_VERSION = 3;
12
12
  type KnownCatalogMode = {
13
13
  readonly mode: 'one-shot';
14
14
  readonly label?: string;
@@ -16,7 +16,10 @@ type KnownCatalogMode = {
16
16
  readonly mode: 'continuable';
17
17
  readonly label: string;
18
18
  };
19
- /** Parent catalog v0 records local modes, v1 adds unknown children, and v2 records external executions. */
19
+ /**
20
+ * Parent catalog v0 records local modes, v1 adds unknown children, v2 records
21
+ * external executions, and v3 adds each child's name, unique among its siblings.
22
+ */
20
23
  export type SubagentCatalogEvent = {
21
24
  readonly childId: SessionId;
22
25
  readonly childCreatedAt: number;
@@ -31,7 +34,16 @@ export type SubagentCatalogEvent = {
31
34
  readonly version: 2;
32
35
  readonly mode: 'external';
33
36
  readonly label?: string;
34
- });
37
+ } | ({
38
+ readonly version: 3;
39
+ readonly name: string;
40
+ } & ({
41
+ readonly mode: 'continuable';
42
+ readonly label: string;
43
+ } | {
44
+ readonly mode: 'external';
45
+ readonly label?: string;
46
+ })));
35
47
  declare module '@deepseek-ai/dsh-session/types' {
36
48
  interface SessionEventMap {
37
49
  /**
@@ -52,7 +64,7 @@ export interface SubagentCatalogState {
52
64
  * @returns current direct-child rows in parent catalog event order.
53
65
  */
54
66
  declare function subagentCatalogEntries(state: SubagentCatalogState): SubagentCatalogEntry[];
55
- /** Parent-owned direct-child catalog projection; invalid own facts reject restoration. */
67
+ /** Parent-owned catalog; version-6 checkpoints retain unnamed facts, and invalid own facts reject restoration. */
56
68
  export declare const subagentCatalogProjectionDefinition: {
57
69
  key: "subagentCatalog";
58
70
  stateSchema: z.ZodType<SubagentCatalogState, unknown, z.core.$ZodTypeInternals<SubagentCatalogState, unknown>>;
@@ -71,17 +83,25 @@ export declare const subagentCatalogProjectionDefinition: {
71
83
  * @param parent - durable direct parent receiving the discovery fact.
72
84
  * @param child - established child's immutable Session metadata.
73
85
  * @param descriptor - mode-discriminated creation label frozen with the child.
86
+ * @param name - the child's name, reserved unique among the parent's children.
74
87
  */
75
88
  export declare function establishCatalogChild(parent: Session, child: SessionHeader, descriptor: {
76
89
  readonly mode: 'continuable';
77
90
  readonly label: string;
78
- }): void;
91
+ }, name: string): void;
79
92
  /**
80
93
  * Record an external execution without a local child Session.
81
94
  * @param parent - durable direct parent receiving the discovery fact.
82
95
  * @param childId - identity returned by the external provider.
83
96
  * @param label - display label assigned by the caller.
97
+ * @param name - the child's name, reserved unique among the parent's children.
98
+ */
99
+ export declare function establishExternalCatalogChild(parent: Session, childId: SessionId, label: string, name: string): void;
100
+ /**
101
+ * Collect the names recorded in one parent's catalog.
102
+ * @param entries - the parent's current catalog rows.
103
+ * @returns names of every named child; historical entries contribute none.
84
104
  */
85
- export declare function establishExternalCatalogChild(parent: Session, childId: SessionId, label: string): void;
105
+ export declare function catalogNames(entries: readonly SubagentCatalogEntry[]): Set<string>;
86
106
  export {};
87
107
  //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,aAAa,EACb,SAAS,EACT,gBAAgB,EACjB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,IAAI,CAAA;AAEzC,KAAK,gBAAgB,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5D;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACA,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAChC,GAAG,CACA,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,GAAG,gBAAgB,CAAC,GAC5C,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA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