@deepseek-ai/dsh-subagent 0.2.1-alpha.1 → 0.2.1-alpha.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 (41) hide show
  1. package/README.i18n.yaml +34 -34
  2. package/README.md +32 -26
  3. package/README.zh.md +32 -26
  4. package/lib/index.js +1436 -1304
  5. package/lib/typert.host.js +59 -48
  6. package/lib/typert.remote-client.js +2 -2
  7. package/lib/types/activation.d.ts +114 -0
  8. package/lib/types/activation.js +112 -0
  9. package/lib/types/catalog.d.ts +14 -6
  10. package/lib/types/catalog.js +34 -30
  11. package/lib/types/child-agent.d.ts +1 -3
  12. package/lib/types/child-agent.js +1 -3
  13. package/lib/types/continuation-messages.d.ts +4 -3
  14. package/lib/types/continuation-messages.js +13 -5
  15. package/lib/types/control-types.d.ts +7 -0
  16. package/lib/types/descriptor.d.ts +7 -46
  17. package/lib/types/descriptor.js +20 -21
  18. package/lib/types/index.d.ts +52 -51
  19. package/lib/types/index.js +75 -95
  20. package/lib/types/internal.d.ts +1 -1
  21. package/lib/types/lifecycle.d.ts +28 -58
  22. package/lib/types/lifecycle.js +9 -74
  23. package/lib/types/list-children.js +1 -1
  24. package/lib/types/manager.d.ts +247 -0
  25. package/lib/types/manager.js +1294 -0
  26. package/lib/types/out-of-process.d.ts +2 -28
  27. package/lib/types/out-of-process.js +3 -44
  28. package/lib/types/projection-types.d.ts +3 -0
  29. package/lib/types/structured.d.ts +49 -0
  30. package/lib/types/structured.js +130 -0
  31. package/lib/types/types.d.ts +57 -81
  32. package/lib/types/types.js +1 -1
  33. package/package.json +50 -49
  34. package/lib/types/continuation-activation.d.ts +0 -267
  35. package/lib/types/continuation-activation.js +0 -700
  36. package/lib/types/continuation.d.ts +0 -124
  37. package/lib/types/continuation.js +0 -455
  38. package/lib/types/inbox.d.ts +0 -43
  39. package/lib/types/inbox.js +0 -61
  40. package/lib/types/run-settlement.d.ts +0 -17
  41. package/lib/types/run-settlement.js +0 -70
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-subagent",
3
3
  "description": "Abstract subagent seam (ctx.subagents): named-provider registry for delegating to child agents",
4
- "version": "0.2.1-alpha.1",
4
+ "version": "0.2.1-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -48,33 +48,33 @@
48
48
  ],
49
49
  "license": "MIT",
50
50
  "dependencies": {
51
- "zod": "^4.4.3",
52
- "@deepseek-ai/dsh-chunked-list": "0.2.1-alpha.1",
53
- "@deepseek-ai/dsh-util-values": "0.2.1-alpha.1",
51
+ "@deepseek-ai/dsh-brand": "0.2.1-alpha.2",
52
+ "@deepseek-ai/dsh-chunked-list": "0.2.1-alpha.2",
53
+ "@deepseek-ai/dsh-util-values": "0.2.1-alpha.2",
54
54
  "@deepseek-ai/schemastery": "~3.18.5-alpha.1",
55
- "@deepseek-ai/dsh-brand": "0.2.1-alpha.1"
55
+ "zod": "^4.4.3"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@deepseek-ai/cordis": "~4.0.5-alpha.1",
59
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
60
- "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.1",
61
- "@deepseek-ai/dsh-attachment": "0.2.1-alpha.1",
62
- "@deepseek-ai/dsh-jobs": "0.2.1-alpha.1",
63
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
64
- "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.1",
65
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.1",
66
- "@deepseek-ai/dsh-scope": "0.2.1-alpha.1",
67
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
68
- "@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.1",
69
- "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
70
- "@deepseek-ai/dsh-session-query": "0.2.1-alpha.1",
71
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
72
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
73
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.1",
74
- "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.1",
75
- "@deepseek-ai/dsh-permission-presets": "0.2.1-alpha.1",
76
- "@deepseek-ai/dsh-workspace": "0.2.1-alpha.1",
77
- "@deepseek-ai/dsh-util-time": "0.2.1-alpha.1"
59
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
60
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.2",
61
+ "@deepseek-ai/dsh-attachment": "0.2.1-alpha.2",
62
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
63
+ "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.2",
64
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.2",
65
+ "@deepseek-ai/dsh-scope": "0.2.1-alpha.2",
66
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.2",
67
+ "@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.2",
68
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.2",
69
+ "@deepseek-ai/dsh-session-query": "0.2.1-alpha.2",
70
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
71
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
72
+ "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.2",
73
+ "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.2",
74
+ "@deepseek-ai/dsh-util-time": "0.2.1-alpha.2",
75
+ "@deepseek-ai/dsh-permission-presets": "0.2.1-alpha.2",
76
+ "@deepseek-ai/dsh-workspace": "0.2.1-alpha.2",
77
+ "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.2"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@deepseek-ai/dsh-agent-preset-registry": {
@@ -101,36 +101,37 @@
101
101
  "@deepseek-ai/dsh-workspace": {
102
102
  "optional": true
103
103
  },
104
- "@deepseek-ai/dsh-jobs": {
105
- "optional": true
106
- },
107
104
  "@deepseek-ai/dsh-user-approval": {
108
105
  "optional": true
109
- },
110
- "@deepseek-ai/dsh-settings": {
111
- "optional": true
112
106
  }
113
107
  },
114
108
  "devDependencies": {
115
109
  "@deepseek-ai/cordis": "~4.0.5-alpha.1",
116
- "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.1",
117
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
118
- "@deepseek-ai/dsh-attachment": "0.2.1-alpha.1",
119
- "@deepseek-ai/dsh-jobs": "0.2.1-alpha.1",
120
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
121
- "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.1",
122
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.1",
123
- "@deepseek-ai/dsh-scope": "0.2.1-alpha.1",
124
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
125
- "@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.1",
126
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
127
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
128
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.1",
129
- "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.1",
130
- "@deepseek-ai/dsh-util-time": "0.2.1-alpha.1",
131
- "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
132
- "@deepseek-ai/dsh-permission-presets": "0.2.1-alpha.1",
133
- "@deepseek-ai/dsh-workspace": "0.2.1-alpha.1",
134
- "@deepseek-ai/dsh-session-query": "0.2.1-alpha.1"
110
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
111
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.2",
112
+ "@deepseek-ai/dsh-attachment": "0.2.1-alpha.2",
113
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
114
+ "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.2",
115
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.2",
116
+ "@deepseek-ai/dsh-scope": "0.2.1-alpha.2",
117
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.2",
118
+ "@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.2",
119
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.2",
120
+ "@deepseek-ai/dsh-session-query": "0.2.1-alpha.2",
121
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
122
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
123
+ "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.2",
124
+ "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.2",
125
+ "@deepseek-ai/dsh-util-time": "0.2.1-alpha.2",
126
+ "@deepseek-ai/dsh-permission-presets": "0.2.1-alpha.2",
127
+ "@deepseek-ai/dsh-workspace": "0.2.1-alpha.2",
128
+ "@deepseek-ai/cordis-plugin-include": "~1.0.10-alpha.1",
129
+ "@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.1",
130
+ "@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.2",
131
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.2",
132
+ "@deepseek-ai/dsh-fs-sandbox": "0.2.1-alpha.2",
133
+ "@deepseek-ai/dsh-tool-fs": "0.2.1-alpha.2",
134
+ "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-alpha.2",
135
+ "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.2"
135
136
  }
136
137
  }
@@ -1,267 +0,0 @@
1
- /**
2
- * Process-local Activation ownership for continuable subagents: admission,
3
- * parent-child residency, serialized delivery, settlement, and disposal.
4
- *
5
- * The continuation manager owns durable request orchestration and delegates
6
- * every mutable residency decision to this registry, so delivery and teardown
7
- * share one child lock and one Activation map.
8
- *
9
- * @module @deepseek-ai/dsh-subagent/continuation-activation
10
- */
11
- import type { Context } from '@deepseek-ai/cordis';
12
- import type { Agent, AgentHandle, AgentOptions, CreateAgentOptions } from '@deepseek-ai/dsh-agent';
13
- import type { MessageId } from '@deepseek-ai/dsh-llm';
14
- import type { SessionEvent, SessionId, SessionLogOffset as SessionLogOffsetType, UserMessage } from '@deepseek-ai/dsh-session';
15
- import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
16
- import type { DelegatedPolicyOverrides } from './child-agent.ts';
17
- import type { SubagentDescriptorData } from './descriptor.ts';
18
- import { SubagentInbox } from './inbox.ts';
19
- import type { SubagentDelivery } from './inbox.ts';
20
- import type { ActivationObserver } from './lifecycle.ts';
21
- /** Process-local slots shared through uninterrupted continuable parent links. */
22
- declare class ActivationPool {
23
- private readonly slots;
24
- /** Reserve before reconstruction; the returned release also tolerates unpublished rollback. */
25
- reserve(capacity: number): () => void;
26
- }
27
- /**
28
- * One residency epoch for a reconstructed continuable child Agent. It directly
29
- * owns the published `AgentHandle`; the registry's private activation-owner
30
- * scope is its structural Cordis owner.
31
- */
32
- export interface Activation {
33
- /** Shared capacity for this Activation and all its continuable descendants. */
34
- readonly pool: ActivationPool;
35
- /** Return this epoch's slot after its handle has finished disposal. */
36
- readonly releaseSlot: () => void;
37
- /** The durable child this Activation is an epoch of. */
38
- readonly childId: SessionId;
39
- /**
40
- * The durable direct parent, stored because settlement delivery must resolve
41
- * that parent after the child handle is gone. {@link ancestry} cannot answer
42
- * it: a `WeakSet` is not enumerable, and the child's own header is only
43
- * reachable through a handle disposal has already released.
44
- */
45
- readonly parentSession: SessionId;
46
- /** The provider name recorded in the durable descriptor. */
47
- readonly provider: string;
48
- /** The retained live Agent handle, disposed exactly once at settlement. */
49
- readonly handle: AgentHandle;
50
- /** The Activation-local admission and close wrapper around the handle's Agent inbox. */
51
- readonly inbox: SubagentInbox;
52
- /**
53
- * Exact live Agent ancestry observed when this Activation materialized.
54
- * Weak membership preserves host-scope identity across an intermediate
55
- * ancestor leaving the registry without retaining that ancestor's runtime.
56
- */
57
- readonly ancestry: WeakSet<Agent>;
58
- /**
59
- * Session ids of the child Activations this one owns. Because one Session has
60
- * at most one live Activation, the id identifies the live child without
61
- * another runtime-incarnation reference. Non-empty blocks settlement.
62
- */
63
- readonly ownedChildren: Set<SessionId>;
64
- /** The lifecycle observer that emits this epoch's start and terminal edges. */
65
- readonly observer: ActivationObserver;
66
- /**
67
- * Whether any delivery to this child was ever accepted. A materialization
68
- * rolled back before its first acceptance is a child the caller was told does
69
- * not exist, so its teardown owes the parent no settlement account.
70
- */
71
- announced: boolean;
72
- /** Renewed whenever a settlement watcher must re-check residency state. */
73
- poke: PromiseWithResolvers<void>;
74
- }
75
- /** Inputs shared by fresh and resumed Activation materialization. */
76
- export interface MaterializeInputs {
77
- childId: SessionId;
78
- provider: string;
79
- parent: Agent;
80
- /**
81
- * Creation inputs; absent for a cold resume, which loads the persisted
82
- * session — including the delegation policy events a fresh creation seeded,
83
- * so a resume never re-captures the parent's policy.
84
- */
85
- create?: {
86
- seed: readonly SessionEvent[] | undefined;
87
- meta: NonNullable<CreateAgentOptions['meta']>;
88
- /** Exact parent-log prefix length inside {@link seed}. */
89
- inheritedEventCount: SessionLogOffsetType;
90
- /** Policy captured at delegation: the parent's sandbox override plus the approval pin. */
91
- delegatedPolicies: DelegatedPolicyOverrides;
92
- /** Child-owned composition record appended after the inherited marker. */
93
- descriptor: SubagentDescriptorData;
94
- };
95
- agentOptions: AgentOptions;
96
- composition: {
97
- persona?: string | undefined;
98
- toolFilter?: ToolRestriction | undefined;
99
- };
100
- signal: AbortSignal;
101
- }
102
- /** Serialize each durable child's delivery, release, and disposal. */
103
- export declare class ChildLock {
104
- private tails;
105
- /**
106
- * Run `operation` after every previously queued operation for `childId`.
107
- * @param childId - the durable child whose operations are linearized.
108
- * @param operation - the critical section to run in order.
109
- * @returns the operation's own settlement.
110
- */
111
- run<T>(childId: SessionId, operation: () => Promise<T>): Promise<T>;
112
- }
113
- /** Own the complete process-local lifetime of continuable child Activations. */
114
- export declare class ContinuableActivationRegistry {
115
- private readonly ctx;
116
- private readonly observeActivation;
117
- private readonly maxActiveSubagents;
118
- /** Child session id → its live Activation. Process-local, never durable. */
119
- private readonly resident;
120
- /** Root identities retain their pool across child settlement without retaining dead roots. */
121
- private readonly rootPools;
122
- /** Materializations admitted before drain, tracked through publication or rollback. */
123
- private readonly materializations;
124
- /** Per-child serializer shared by delivery, release, and disposal. */
125
- readonly locks: ChildLock;
126
- /** Structural Cordis owner of every Activation handle. */
127
- readonly ownerCtx: Context;
128
- /**
129
- * Exact roots whose host teardown has begun, with the live lineage members
130
- * observed under each root. Entries remain until that exact root leaves the
131
- * Agent registry, closing admission throughout its host's teardown without
132
- * poisoning a later same-id replacement.
133
- */
134
- private readonly closingScopes;
135
- private draining;
136
- /**
137
- * Build one registry inside the service's Agent-injected context.
138
- * @param ctx - context providing Agents, Sessions, and teardown ownership.
139
- * @param observeActivation - build the lifecycle observer for one residency epoch.
140
- */
141
- constructor(ctx: Context, observeActivation: (provider: string, childId: SessionId, parent: Agent) => ActivationObserver, maxActiveSubagents: () => number);
142
- /**
143
- * Return the live Activation for a durable child id, if resident.
144
- * @param childId - durable child session id to look up.
145
- * @returns the process-local Activation, or `undefined` when it is not resident.
146
- */
147
- get(childId: SessionId): Activation | undefined;
148
- /**
149
- * Reject one child identity already owned by a live Agent or Session.
150
- * @param childId - proposed durable child session id.
151
- */
152
- assertChildIdAvailable(childId: SessionId): void;
153
- /**
154
- * Pre-register `childId` in a continuation-managed parent's owned set so the
155
- * parent cannot settle while a caller is still establishing or resuming that
156
- * child. Returns a releaser for the failure path; it removes only a hold
157
- * this call added, and leaves ownership in place once a live Activation for
158
- * the child exists.
159
- * @param parent - the live direct parent the operation is admitted under.
160
- * @param childId - the durable child the operation addresses.
161
- * @returns the failure-path releaser; a no-op when nothing was added.
162
- */
163
- holdOwnership(parent: Agent, childId: SessionId): () => void;
164
- /**
165
- * Interrupt one live continuable child's current turn under the supplied authority.
166
- * @param targetSessionId - the durable child session id to interrupt.
167
- * @param authority - the human parent address or exact live ancestor Agent.
168
- */
169
- interrupt(targetSessionId: SessionId, authority: {
170
- readonly kind: 'user';
171
- readonly parentSessionId: SessionId;
172
- } | {
173
- readonly kind: 'ancestor';
174
- readonly agent: Agent;
175
- }): void;
176
- /**
177
- * Send through a receiving parent's Activation inbox when it has one.
178
- * @param parent - exact live Agent receiving the message.
179
- * @param message - durable user message to deliver.
180
- * @param delivery - receiving inbox destination.
181
- */
182
- sendWaking(parent: Agent, message: UserMessage, delivery: SubagentDelivery): void;
183
- /**
184
- * Close admission, await every already-admitted materialization through
185
- * publication or rollback, then dispose the stable live Activation graph
186
- * child-first.
187
- */
188
- drain(): Promise<void>;
189
- /**
190
- * Stop only the continuable descendants of exact live host-owned parents.
191
- * @param parents - exact live roots whose continuable descendants must stop.
192
- */
193
- drainDescendants(parents: readonly Agent[]): Promise<void>;
194
- /**
195
- * Release selected resident direct children of one exact live parent.
196
- * @param parent - exact live direct parent authorizing the selected release.
197
- * @param childIds - durable direct-child ids to release when resident.
198
- */
199
- drainChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
200
- /**
201
- * Reject new admission once the registry or this exact parent tree began draining.
202
- * @param agent - exact live Agent whose lineage determines admission.
203
- */
204
- assertAdmitting(agent: Agent): void;
205
- /**
206
- * Authorize one operation against the durable direct-parent lineage.
207
- * @param parent - exact live Agent claiming direct-parent authority.
208
- * @param childId - durable child session id addressed by the operation.
209
- * @param parentSession - durable direct-parent id recorded by the child.
210
- */
211
- authorizeLineage(parent: Agent, childId: SessionId, parentSession: SessionId | undefined): void;
212
- /**
213
- * Create or resume one child Agent and publish its Activation.
214
- * @param inputs - reconstruction and admission inputs for the residency epoch.
215
- * @returns the published process-local Activation.
216
- */
217
- materialize(inputs: MaterializeInputs): Promise<Activation>;
218
- /**
219
- * Cross the final admission cutoff and submit without yielding.
220
- * @param activation - the exact resident child receiving the message.
221
- * @param message - the already-built durable user message.
222
- * @param delivery - the Agent inbox destination.
223
- * @param parent - exact live direct parent authorizing admission.
224
- * @param signal - caller cancellation before inbox acceptance.
225
- * @returns the accepted durable message id.
226
- */
227
- submitAdmitted(activation: Activation, message: UserMessage, delivery: SubagentDelivery, parent: Agent, signal: AbortSignal): MessageId;
228
- /**
229
- * Stop and release one Activation through its memoized close transaction.
230
- * @param activation - exact residency epoch to close.
231
- * @param finalStateFlushed - whether natural settlement already flushed final state.
232
- * @returns the shared close transaction.
233
- */
234
- dispose(activation: Activation, finalStateFlushed?: boolean): Promise<void>;
235
- /** Dispose independent roots and report every branch failure after all settle. */
236
- private disposeRoots;
237
- /** Return the retained member set for one exact scoped-teardown root. */
238
- private closingMembers;
239
- /** Return the exact currently resolvable ancestry from `agent` upward. */
240
- private liveLineage;
241
- /** Return the teardown that closed continuable admission for this agent's lineage. */
242
- private closingTeardownFor;
243
- /** Resolve a root's pool once; descendants inherit their resident parent's pool directly. */
244
- private rootPool;
245
- /** Perform one tracked materialization through publication or rollback. */
246
- private materializeTracked;
247
- /** Release an Activation whose start edge was not published. */
248
- private rollbackUnpublished;
249
- /** Register the child in a continuation-managed parent's owned set. */
250
- private acquireOwnership;
251
- /** Remove one child from its live owner's set and let that owner re-check settlement. */
252
- private releaseOwnership;
253
- /** Let a settlement watcher re-check residency after relevant state changes. */
254
- private wake;
255
- /** Follow one Activation to natural settlement. */
256
- private watchSettlement;
257
- /** Classify one Inbox and owned-child observation without reading Agent execution state. */
258
- private settlementState;
259
- /** Propagate stop synchronously, then finish the child-first release. */
260
- private finishDisposal;
261
- /** Tell the durable direct parent how this Activation ended. */
262
- private notifySettlement;
263
- /** Request a best-effort final session flush before closing natural-settlement admission. */
264
- private flushFinalState;
265
- }
266
- export {};
267
- //# sourceMappingURL=continuation-activation.d.ts.map