@toddzheng024/dscode-bundle 0.7.26 → 0.7.28

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 (99) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +10 -10
  3. package/bootstrap.mjs +1 -1
  4. package/cordis.patch.yml +418 -45
  5. package/package.json +279 -245
  6. package/plugins/auto-review/index.mjs +8 -5
  7. package/plugins/code-review/index.mjs +1 -1
  8. package/plugins/computer-use/index.mjs +37 -0
  9. package/plugins/cordis-config/plain.mjs +31 -0
  10. package/plugins/exec/cli.mjs +1 -1
  11. package/plugins/grok/index.mjs +28 -24
  12. package/plugins/memory/index.mjs +1 -1
  13. package/plugins/message-source/kind.mjs +20 -0
  14. package/plugins/openrouter/adapter.mjs +29 -13
  15. package/plugins/openrouter/index.mjs +31 -28
  16. package/plugins/session-bridge/communication.mjs +6 -3
  17. package/plugins/session-bridge/server.mjs +3 -2
  18. package/plugins/session-bridge/tasks.mjs +3 -1
  19. package/plugins/session-cards/index.mjs +1 -1
  20. package/plugins/time-marks/index.mjs +3 -2
  21. package/plugins/time-marks/marks.mjs +6 -5
  22. package/plugins/triggers/config.mjs +1 -1
  23. package/plugins/triggers/tools.mjs +1 -1
  24. package/plugins/tui-tools/doctor.mjs +1 -1
  25. package/plugins/tui-tools/index.mjs +16 -4
  26. package/plugins/ultra/policy.mjs +16 -0
  27. package/vendor/bash/index.js +455 -186
  28. package/vendor/bash/types/background.d.ts +38 -7
  29. package/vendor/bash/types/index.d.ts +20 -4
  30. package/vendor/bash/types/render.d.ts +28 -9
  31. package/vendor/command-goal/index.js +3 -1
  32. package/vendor/deepseek/index.js +1378 -1246
  33. package/vendor/deepseek/types/adapter.d.ts +16 -155
  34. package/vendor/deepseek/types/config.d.ts +127 -0
  35. package/vendor/deepseek/types/defaults.d.ts +24 -0
  36. package/vendor/deepseek/types/file-store.d.ts +5 -3
  37. package/vendor/deepseek/types/files-api.d.ts +12 -9
  38. package/vendor/deepseek/types/image-tokens.d.ts +24 -9
  39. package/vendor/deepseek/types/images.d.ts +35 -0
  40. package/vendor/deepseek/types/index.d.ts +10 -94
  41. package/vendor/deepseek/types/messages-api.d.ts +10 -0
  42. package/vendor/deepseek/types/model-info.d.ts +16 -0
  43. package/vendor/deepseek/types/models.d.ts +4 -0
  44. package/vendor/deepseek/types/replay.d.ts +27 -0
  45. package/vendor/deepseek/types/request-extensions.d.ts +16 -0
  46. package/vendor/deepseek/types/request-files.d.ts +49 -0
  47. package/vendor/deepseek/types/request-pricing.d.ts +32 -20
  48. package/vendor/deepseek/types/serialize.d.ts +17 -82
  49. package/vendor/deepseek/types/sse.d.ts +6 -22
  50. package/vendor/deepseek/types/translate.d.ts +13 -36
  51. package/vendor/deepseek/types/transport.d.ts +15 -0
  52. package/vendor/deepseek/types/types.d.ts +106 -167
  53. package/vendor/deepseek/types/wire-types.d.ts +62 -0
  54. package/vendor/persistent/index.js +9 -3
  55. package/vendor/subagent/index.js +11 -8
  56. package/vendor/subagent/model-selection-settings.js +12 -38
  57. package/vendor/subagent/types/index.d.ts +4 -3
  58. package/vendor/subagent/types/model-selection-settings.d.ts +12 -10
  59. package/vendor/subagent-core/index.js +401 -264
  60. package/vendor/subagent-core/typert.host.js +103 -113
  61. package/vendor/subagent-core/typert.remote-client.d.ts +1 -3
  62. package/vendor/subagent-core/typert.remote-client.js +23 -69
  63. package/vendor/subagent-core/types/archive-admission.d.ts +16 -0
  64. package/vendor/subagent-core/types/archive-admission.js +151 -0
  65. package/vendor/subagent-core/types/assistant-output.d.ts +2 -2
  66. package/vendor/subagent-core/types/catalog.d.ts +17 -10
  67. package/vendor/subagent-core/types/catalog.js +12 -6
  68. package/vendor/subagent-core/types/child-agent.d.ts +8 -5
  69. package/vendor/subagent-core/types/child-agent.js +11 -5
  70. package/vendor/subagent-core/types/continuation-activation.d.ts +17 -1
  71. package/vendor/subagent-core/types/continuation-activation.js +41 -4
  72. package/vendor/subagent-core/types/continuation-messages.d.ts +1 -1
  73. package/vendor/subagent-core/types/continuation-messages.js +7 -3
  74. package/vendor/subagent-core/types/continuation.d.ts +1 -1
  75. package/vendor/subagent-core/types/continuation.js +2 -2
  76. package/vendor/subagent-core/types/control-types.d.ts +29 -36
  77. package/vendor/subagent-core/types/control-types.js +2 -3
  78. package/vendor/subagent-core/types/control.d.ts +2 -28
  79. package/vendor/subagent-core/types/control.js +3 -40
  80. package/vendor/subagent-core/types/index.d.ts +45 -41
  81. package/vendor/subagent-core/types/index.js +46 -82
  82. package/vendor/subagent-core/types/internal.d.ts +2 -2
  83. package/vendor/subagent-core/types/internal.js +2 -2
  84. package/vendor/subagent-core/types/lifecycle.d.ts +1 -1
  85. package/vendor/subagent-core/types/lifecycle.js +5 -3
  86. package/vendor/subagent-core/types/list-children.d.ts +15 -32
  87. package/vendor/subagent-core/types/list-children.js +45 -49
  88. package/vendor/subagent-core/types/out-of-process.d.ts +1 -1
  89. package/vendor/subagent-core/types/projection-types.d.ts +9 -1
  90. package/vendor/subagent-core/types/projection.d.ts +5 -0
  91. package/vendor/subagent-core/types/projection.js +10 -4
  92. package/vendor/subagent-core/types/run-settlement.js +1 -1
  93. package/vendor/subagent-core/types/types.d.ts +2 -2
  94. package/vendor/terminal/index.js +94 -30
  95. package/vendor/tui/lib/index.mjs +2 -1
  96. package/vendor/tui/lib/kernel-panels.mjs +1 -1
  97. package/vendor/tui/lib/render/projection.mjs +50 -36
  98. package/presets/dscode/agent.cordis.yml +0 -321
  99. package/presets/dscode/preset.yml +0 -3
@@ -1,33 +1,3 @@
1
- /**
2
- * Service Definition for the subagent capability seam (`ctx.subagents`): a named-provider registry plus a
3
- * capability-validating asynchronous start API. Providers establish a
4
- * child before returning its run, so fulfillment is the single publication and
5
- * ownership-transfer boundary.
6
- *
7
- * Multiple providers coexist: each registers under a unique name and callers
8
- * select one by name.
9
- *
10
- * This package owns the Service Definition role of the capability seam. Service Providers
11
- * (`@deepseek-ai/dsh-subagent-spawn-in-process`, `-fork`, `-acp`) and the model-facing
12
- * consumer (`@deepseek-ai/dsh-tool-subagent`) are separate packages.
13
- *
14
- * Public operations express caller intent: `start` returns one published owned
15
- * one-shot run, `startContinuable` establishes a durable continuable child, and
16
- * `sendMessage` steers between adjacent Agents without exposing whether a child
17
- * is resident. Continuable children never become a {@link SubagentRun}: the
18
- * continuation manager holds their `AgentHandle` directly and orders every turn
19
- * through the child's own inbox, so providers contribute only the detached
20
- * creation spec and see no handle, turn, or teardown. Child and descendant
21
- * discovery read the live session store and optional session persistence
22
- * directly and do not require that continuation runtime.
23
- *
24
- * Same-process providers are trusted typed collaborators. Requests, provider
25
- * descriptors, results, and lifecycle payloads are borrowed immutable values;
26
- * serialization and hostile-input validation belong at real process, worker,
27
- * persistence, and model boundaries.
28
- *
29
- * @module @deepseek-ai/dsh-subagent
30
- */
31
1
  var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
32
2
  var useValue = arguments.length > 2;
33
3
  for (var i = 0; i < initializers.length; i++) {
@@ -62,16 +32,18 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
62
32
  if (target) Object.defineProperty(target, contextIn.name, descriptor);
63
33
  done = true;
64
34
  };
35
+ import z from '@deepseek-ai/schemastery';
65
36
  import { scopeTarget } from '@deepseek-ai/dsh-scope';
66
37
  import { assertObjectJsonSchema } from '@deepseek-ai/dsh-tools';
67
38
  import { canonicalClientTimeZone } from '@deepseek-ai/dsh-util-time';
68
39
  import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
69
- import { catalogView, rejectCatalogRead, rejectPrompt, validateControlRequest, } from "./control.js";
40
+ import { rejectPrompt, validateControlRequest, } from "./control.js";
70
41
  import { SubagentError } from "./error.js";
71
42
  import { assertSubagentMaxDepth } from "./depth.js";
72
43
  import { createActivationObserver, createLifecycleEmitter, observeRun } from "./lifecycle.js";
73
44
  import SubagentContinuationManager from "./continuation.js";
74
45
  import { listChildren as listSubagentChildren, listDescendants as listSubagentDescendants } from "./list-children.js";
46
+ import { installSubagentArchiveAdmission } from "./archive-admission.js";
75
47
  import { snapshotSubagentDescriptor } from "./descriptor.js";
76
48
  import { subagentIdentityProjectionDefinition, subagentTimingProjectionDefinition } from "./projection.js";
77
49
  import { establishCatalogChild, subagentCatalogProjectionDefinition } from "./catalog.js";
@@ -88,21 +60,23 @@ export { appendDelegatedPolicyOverrides, applyChildComposition, captureDelegated
88
60
  let SubagentRuntime = (() => {
89
61
  let _classSuper = TypertRemoteService;
90
62
  let _instanceExtraInitializers = [];
91
- let _remoteExportList_decorators;
92
63
  let _prompt_decorators;
93
64
  let _interruptByParent_decorators;
94
65
  return class SubagentRuntime extends _classSuper {
95
66
  static {
96
67
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
97
- _remoteExportList_decorators = [Remote('list')];
98
68
  _prompt_decorators = [Remote('prompt')];
99
69
  _interruptByParent_decorators = [Remote('interruptByParent')];
100
- __esDecorate(this, null, _remoteExportList_decorators, { kind: "method", name: "remoteExportList", static: false, private: false, access: { has: obj => "remoteExportList" in obj, get: obj => obj.remoteExportList }, metadata: _metadata }, null, _instanceExtraInitializers);
101
70
  __esDecorate(this, null, _prompt_decorators, { kind: "method", name: "prompt", static: false, private: false, access: { has: obj => "prompt" in obj, get: obj => obj.prompt }, metadata: _metadata }, null, _instanceExtraInitializers);
102
71
  __esDecorate(this, null, _interruptByParent_decorators, { kind: "method", name: "interruptByParent", static: false, private: false, access: { has: obj => "interruptByParent" in obj, get: obj => obj.interruptByParent }, metadata: _metadata }, null, _instanceExtraInitializers);
103
72
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
104
73
  }
105
- providers = (__runInitializers(this, _instanceExtraInitializers), new Map());
74
+ config = __runInitializers(this, _instanceExtraInitializers);
75
+ static Config = z.object({
76
+ maxDepth: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(1).volatile(),
77
+ maxActiveSubagents: z.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(8).volatile(),
78
+ });
79
+ providers = new Map();
106
80
  continuations;
107
81
  /**
108
82
  * The contained lifecycle-edge publisher. Built here because scoped dispatch
@@ -110,14 +84,15 @@ let SubagentRuntime = (() => {
110
84
  * composes into the carrier.
111
85
  */
112
86
  emitLifecycle;
113
- constructor(ctx) {
87
+ constructor(ctx, config) {
114
88
  super(ctx, 'subagents');
89
+ this.config = config;
115
90
  this.emitLifecycle = createLifecycleEmitter(this.ctx, parent => scopeTarget(this, parent));
116
91
  ctx.inject(['agents'], (childCtx) => {
117
92
  const manager = new SubagentContinuationManager(childCtx, {
118
93
  prepareContinuable: (name, request) => this.prepareContinuable(name, request),
119
94
  observeActivation: (provider, childId, parent) => this.observeActivation(provider, childId, parent),
120
- });
95
+ }, () => this.config.maxActiveSubagents.get());
121
96
  this.continuations = manager;
122
97
  childCtx.effect(() => () => {
123
98
  /* v8 ignore else -- one injected binding owns the slot until its fiber disposes. */
@@ -126,10 +101,28 @@ let SubagentRuntime = (() => {
126
101
  }, 'subagents.continuationBinding()');
127
102
  });
128
103
  ctx.inject(['sessionProjections'], (projectionCtx) => {
129
- projectionCtx.sessionProjections.register(subagentCatalogProjectionDefinition);
130
- projectionCtx.sessionProjections.register(subagentTimingProjectionDefinition);
131
- projectionCtx.sessionProjections.register(subagentIdentityProjectionDefinition);
104
+ const projections = projectionCtx.sessionProjections;
105
+ projections.register(subagentCatalogProjectionDefinition);
106
+ projections.register(subagentTimingProjectionDefinition);
107
+ projections.register(subagentIdentityProjectionDefinition);
132
108
  });
109
+ // Archive admission: this runtime is the owner that knows which live
110
+ // children descend from a Session and how a parent stops them.
111
+ ctx.inject(['agents'], (agentsCtx) => { installSubagentArchiveAdmission(agentsCtx); });
112
+ }
113
+ /**
114
+ * Resolve a delegation tool's depth policy against the current user setting.
115
+ * @param configured - Explicit tool limit, or provider-managed for external delegation.
116
+ * @returns The numeric limit, or undefined when the provider owns depth enforcement.
117
+ */
118
+ resolveMaxDepth(configured) {
119
+ if (configured === 'provider-managed')
120
+ return undefined;
121
+ if (configured !== undefined)
122
+ return configured;
123
+ const depth = this.config.maxDepth.get();
124
+ assertSubagentMaxDepth(depth);
125
+ return depth;
133
126
  }
134
127
  /**
135
128
  * Establish one durable continuable child and deliver its initial prompt.
@@ -162,12 +155,12 @@ let SubagentRuntime = (() => {
162
155
  }
163
156
  /**
164
157
  * Deliver one host-protocol message to a direct continuable child.
165
- * Symbol-keyed so host adapters can preserve their own provenance without
158
+ * Symbol-keyed so host adapters can preserve their own source descriptors without
166
159
  * widening the public Service Definition or impersonating an Agent sender.
167
160
  * @param parent - exact live direct parent authorizing delivery.
168
161
  * @param childId - durable direct-child session id.
169
162
  * @param content - host-authored content to deliver.
170
- * @param source - durable host-protocol provenance.
163
+ * @param source - durable host-protocol source descriptor.
171
164
  * @param signal - caller cancellation before inbox acceptance.
172
165
  * @param delivery - Queue as a distinct turn or Steer at the nearest step.
173
166
  * @returns the accepted message's inbox id.
@@ -229,21 +222,13 @@ let SubagentRuntime = (() => {
229
222
  await manager.drainChildren(parent, childIds);
230
223
  }
231
224
  /**
232
- * Enumerate the parent's direct session-backed subagents without loading or
233
- * resuming an Agent. The Session query service supplies one live-preferred
234
- * corpus and shared point observations; the projection cache supplies
235
- * immutable descriptor hits without opening cold logs. The registered
236
- * `subagent` projection remains the sole mode/label classifier.
237
- *
238
- * Every query receives `signal`, and the listing rechecks cancellation
239
- * around each await. Read rejections that settle
240
- * after an abort become a stable `SubagentError` with code `CANCELLED`.
241
- * @param parentSessionId - parent session whose direct children are listed.
242
- * @param signal - caller-owned cancellation forwarded to Session queries
243
- * and observed around every read await.
244
- * @returns children and per-child diagnostics ordered by `createdAt`, then id.
245
- * @throws {@link SubagentError} when the projection registry or the session
246
- * store is not mounted, or the caller cancels the listing.
225
+ * Read the parent's durable direct-child catalog without loading or resuming an Agent.
226
+ * The service owns and releases the live-preferred Session observation.
227
+ * @param parentSessionId - parent whose direct children are requested.
228
+ * @param signal - cancellation forwarded to the Session query.
229
+ * @returns catalog children in parent event order.
230
+ * @throws {@link SubagentError} when query or catalog projection is unavailable.
231
+ * @throws SessionQueryError when the parent cannot be read or the query is cancelled.
247
232
  */
248
233
  listChildren(parentSessionId, signal) {
249
234
  return listSubagentChildren(this.ctx, parentSessionId, signal);
@@ -254,40 +239,18 @@ let SubagentRuntime = (() => {
254
239
  * Agent. Ordinary sessions and one-shot children remain traversal nodes so
255
240
  * continuable descendants below them are discovered; each returned entry
256
241
  * adds its durable `parentId` and root-relative `depth`. Identity resolution,
257
- * diagnostics, optional persistence, and cancellation follow the same
258
- * projection-backed contract as {@link listChildren}.
242
+ * diagnostics, optional persistence, and cancellation use the registered
243
+ * child identity projection and complete Session corpus.
259
244
  * @param rootSessionId - session whose complete descendant tree is listed.
260
245
  * @param signal - caller-owned cancellation forwarded to persistence reads
261
246
  * and observed around every read await.
262
247
  * @returns children and per-candidate diagnostics with tree position, in
263
248
  * stable pre-order.
264
- * @throws {@link SubagentError} under the same conditions as {@link listChildren}.
249
+ * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.
265
250
  */
266
251
  listDescendants(rootSessionId, signal) {
267
252
  return listSubagentDescendants(this.ctx, rootSessionId, signal);
268
253
  }
269
- /**
270
- * Remote face of {@link listChildren} for one browser: the durable listing
271
- * plus live Agent activity and the delivery-time parent availability hint.
272
- * Parent availability is a hint; {@link prompt} performs the authoritative
273
- * check. Named apart from the provider-name {@link list}, which owns the
274
- * member.
275
- * @param parentSessionId - parent session whose direct children are listed.
276
- * @param signal - carrier cancellation forwarded to Session queries.
277
- * @returns the catalog view for that parent.
278
- * @throws {RemoteError} `gateway/bad-request` for an empty parent id,
279
- * `gateway/cancelled` for an aborted read, `subagent/projections-unavailable` when
280
- * the deployment has no projection registry, otherwise `gateway/internal`.
281
- */
282
- async remoteExportList(parentSessionId, signal) {
283
- validateControlRequest('subagent.list', { parentSessionId });
284
- try {
285
- return catalogView(this.ctx, parentSessionId, await this.listChildren(parentSessionId, signal));
286
- }
287
- catch (error) {
288
- return rejectCatalogRead(error, signal);
289
- }
290
- }
291
254
  /**
292
255
  * Deliver one browser-authored message to a continuable child through the
293
256
  * exact live direct parent, retaining the caller-minted request identity and
@@ -297,6 +260,7 @@ let SubagentRuntime = (() => {
297
260
  * nearest step and retains the Agent loop's best-effort fallback semantics.
298
261
  * Image parts are admitted and persisted through the attachment store
299
262
  * before delivery, and the child's model must accept image input.
263
+ * Cold resume at capacity rejects with `subagent/delivery-unavailable`.
300
264
  * @param request - durable address, delivery, minted identity, content, and optional browser zone.
301
265
  * @param signal - carrier cancellation, owning the call until inbox acceptance.
302
266
  * @returns the accepted message's inbox identity.
@@ -39,7 +39,7 @@ export interface HostPromptDeliverer {
39
39
  * @param parent - exact live direct parent authorizing delivery.
40
40
  * @param childId - durable direct-child session id.
41
41
  * @param content - host-authored content to deliver.
42
- * @param source - durable host-protocol provenance.
42
+ * @param source - durable host-protocol source descriptor.
43
43
  * @param signal - caller cancellation before inbox acceptance.
44
44
  * @returns the accepted message's inbox id.
45
45
  */
@@ -50,7 +50,7 @@ export declare function queueHostSubagentPrompt(runtime: SubagentRuntime, parent
50
50
  * @param parent - exact live direct parent authorizing delivery.
51
51
  * @param childId - durable direct-child session id.
52
52
  * @param content - host-authored content to deliver.
53
- * @param source - durable host-protocol provenance.
53
+ * @param source - durable host-protocol source descriptor.
54
54
  * @param signal - caller cancellation before inbox acceptance.
55
55
  * @returns the accepted message's inbox id.
56
56
  */
@@ -35,7 +35,7 @@ export const deliverSubagentPrompt = Symbol.for('dsh.subagent.deliverPrompt');
35
35
  * @param parent - exact live direct parent authorizing delivery.
36
36
  * @param childId - durable direct-child session id.
37
37
  * @param content - host-authored content to deliver.
38
- * @param source - durable host-protocol provenance.
38
+ * @param source - durable host-protocol source descriptor.
39
39
  * @param signal - caller cancellation before inbox acceptance.
40
40
  * @returns the accepted message's inbox id.
41
41
  */
@@ -48,7 +48,7 @@ export function queueHostSubagentPrompt(runtime, parent, childId, content, sourc
48
48
  * @param parent - exact live direct parent authorizing delivery.
49
49
  * @param childId - durable direct-child session id.
50
50
  * @param content - host-authored content to deliver.
51
- * @param source - durable host-protocol provenance.
51
+ * @param source - durable host-protocol source descriptor.
52
52
  * @param signal - caller cancellation before inbox acceptance.
53
53
  * @returns the accepted message's inbox id.
54
54
  */
@@ -26,7 +26,7 @@ export interface ActivationTerminal {
26
26
  /** Why this epoch's last ordinary turn ended, or `error` when teardown failed. */
27
27
  readonly stopReason: SubagentResult['stopReason'];
28
28
  /** The epoch's final assistant content, absent when it produced none or failed. */
29
- readonly output?: ContentBlock[];
29
+ readonly output?: readonly ContentBlock[];
30
30
  }
31
31
  /**
32
32
  * Lifecycle observer for one Activation's residency epoch, so continuable
@@ -106,6 +106,7 @@ export function createActivationObserver(emit, provider, childId, parent) {
106
106
  emit('subagent/start', identity, parent);
107
107
  },
108
108
  capture: (child) => {
109
+ // oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
109
110
  const own = child.session.snapshotEvents(boundary);
110
111
  const output = finalAssistantOutput(own);
111
112
  captured = {
@@ -159,9 +160,10 @@ function epochStopReason(events) {
159
160
  case undefined:
160
161
  case 'completed':
161
162
  return droppedUnrun ? 'aborted' : 'completed';
162
- /* v8 ignore next 3 -- `TurnEndReason` is merge-extensible, so this arm needs a
163
- * backend that adds a variant; treating an unnameable reason as success would
164
- * report failed work as completed. */
163
+ /* v8 ignore next 4 -- `forked` appears only in constructor seed history, while
164
+ * this function reads an epoch-owned suffix. `TurnEndReason` is merge-extensible,
165
+ * so a backend-added variant cannot be listed; treating an unnameable reason as
166
+ * success would report failed work as completed. */
165
167
  default:
166
168
  return 'error';
167
169
  }
@@ -1,24 +1,16 @@
1
1
  /**
2
- * Read-only enumeration of durable subagent children and descendant trees
3
- * through the Session query service. Candidates come from one live-preferred
4
- * corpus; each child's mode/label is the registered `subagent` projection
5
- * unit's value, resolved
6
- * down a three-rung ladder: the registry's watermark cache for a live child,
7
- * an unseeded durable projection-cache row, and one shared Session observation
8
- * otherwise. A seeded header deliberately lacks its exact inherited cut, so
9
- * it takes the body-bearing observation path before classifying an identity.
10
- * The projection fold is the single classification
11
- * authority — this module parses no descriptor
12
- * itself. Absent persistence, enumeration is live-only: a cold child is
13
- * unreachable for resume anyway, so its absence is capability absence, not an
14
- * error. The module owns no catalog state and does not consult Activation,
15
- * Agent-registry, continuation-manager, or provider state.
2
+ * Direct-child discovery from a parent-owned `subagent/catalog` projection,
3
+ * plus complete descendant-tree enumeration from the Session corpus. A direct
4
+ * listing owns one parent observation and reads no child log. Descendant
5
+ * enumeration retains the complete corpus and the child identity projection
6
+ * because ordinary Sessions and one-shot children remain traversal nodes.
16
7
  *
17
8
  * @module @deepseek-ai/dsh-subagent
18
9
  */
19
10
  import type { Context } from '@deepseek-ai/cordis';
20
11
  import type { SessionId } from '@deepseek-ai/dsh-session';
21
12
  import type { SubagentListEntry } from './control-types.ts';
13
+ import type { SubagentCatalogEntry } from './projection-types.ts';
22
14
  export type { SubagentListEntry } from './control-types.ts';
23
15
  /**
24
16
  * One entry of a descendant listing: the interpreted subagent facts plus its
@@ -32,34 +24,25 @@ export type SubagentDescendantListEntry = SubagentListEntry & {
32
24
  readonly depth: number;
33
25
  };
34
26
  /**
35
- * Enumerate one parent's origin-classified direct children from the
36
- * live-preferred merge of `ctx.sessions` and optional session persistence,
37
- * serving each identity from the `subagent` projection unit: the registry's
38
- * watermark snapshot for a live child; for a cold one, a durable
39
- * projection-cache read for an unseeded lifecycle, else one bounded-concurrency
40
- * shared Session observation carrying the exact inherited cut.
41
- * @see SubagentRuntime.listChildren for the public cancellation and failure contract.
42
- * @param ctx - context carrying the session store, the projection registry,
43
- * optional persistence, and the optional projection cache.
44
- * @param parentSessionId - parent session whose direct children are listed.
45
- * @param signal - caller-owned cancellation observed around every persistence read.
46
- * @returns children and per-child diagnostics ordered by `createdAt`, then id.
47
- * @throws {@link SubagentError} when the projection registry or the session
48
- * store is not mounted, or the caller cancels the listing.
27
+ * Read one parent's durable catalog through a live-preferred Session observation.
28
+ * @param ctx - context carrying the Session query service.
29
+ * @param parentSessionId - parent whose direct children are requested.
30
+ * @param signal - cancellation forwarded to the Session observation.
31
+ * @returns direct-child rows in parent catalog event order.
32
+ * @throws {@link SubagentError} when query or catalog projection is unavailable.
49
33
  */
50
- export declare function listChildren(ctx: Context, parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentListEntry[]>;
34
+ export declare function listChildren(ctx: Context, parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentCatalogEntry[]>;
51
35
  /**
52
36
  * Enumerate every session-backed subagent below one root in stable pre-order.
53
37
  * Ordinary sessions and one-shot children remain traversal nodes, so a
54
38
  * continuable child below either is still discovered. Classification uses the
55
- * same projection-backed runtime as {@link listChildren}; no Agent is loaded or
56
- * resumed.
39
+ * registered child identity projection; no Agent is loaded or resumed.
57
40
  * @see SubagentRuntime.listDescendants for the public cancellation and failure contract.
58
41
  * @param ctx - context carrying the session store, projection registry, and optional persistence/cache.
59
42
  * @param rootSessionId - session whose complete descendant tree is listed.
60
43
  * @param signal - caller-owned cancellation observed around every persistence read.
61
44
  * @returns interpreted subagents with durable direct-parent and root-relative depth.
62
- * @throws {@link SubagentError} under the same conditions as {@link listChildren}.
45
+ * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.
63
46
  */
64
47
  export declare function listDescendants(ctx: Context, rootSessionId: SessionId, signal?: AbortSignal): Promise<SubagentDescendantListEntry[]>;
65
48
  //# sourceMappingURL=list-children.d.ts.map
@@ -1,18 +1,9 @@
1
1
  /**
2
- * Read-only enumeration of durable subagent children and descendant trees
3
- * through the Session query service. Candidates come from one live-preferred
4
- * corpus; each child's mode/label is the registered `subagent` projection
5
- * unit's value, resolved
6
- * down a three-rung ladder: the registry's watermark cache for a live child,
7
- * an unseeded durable projection-cache row, and one shared Session observation
8
- * otherwise. A seeded header deliberately lacks its exact inherited cut, so
9
- * it takes the body-bearing observation path before classifying an identity.
10
- * The projection fold is the single classification
11
- * authority — this module parses no descriptor
12
- * itself. Absent persistence, enumeration is live-only: a cold child is
13
- * unreachable for resume anyway, so its absence is capability absence, not an
14
- * error. The module owns no catalog state and does not consult Activation,
15
- * Agent-registry, continuation-manager, or provider state.
2
+ * Direct-child discovery from a parent-owned `subagent/catalog` projection,
3
+ * plus complete descendant-tree enumeration from the Session corpus. A direct
4
+ * listing owns one parent observation and reads no child log. Descendant
5
+ * enumeration retains the complete corpus and the child identity projection
6
+ * because ordinary Sessions and one-shot children remain traversal nodes.
16
7
  *
17
8
  * @module @deepseek-ai/dsh-subagent
18
9
  */
@@ -68,7 +59,6 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
68
59
  var e = new Error(message);
69
60
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
70
61
  });
71
- import { SessionLogOffset } from '@deepseek-ai/dsh-session';
72
62
  import { SubagentError } from "./error.js";
73
63
  /**
74
64
  * Concurrent cold observations per explicit catalog listing. Current Session
@@ -77,42 +67,48 @@ import { SubagentError } from "./error.js";
77
67
  */
78
68
  const COLD_READ_CONCURRENCY = 4;
79
69
  /**
80
- * Enumerate one parent's origin-classified direct children from the
81
- * live-preferred merge of `ctx.sessions` and optional session persistence,
82
- * serving each identity from the `subagent` projection unit: the registry's
83
- * watermark snapshot for a live child; for a cold one, a durable
84
- * projection-cache read for an unseeded lifecycle, else one bounded-concurrency
85
- * shared Session observation carrying the exact inherited cut.
86
- * @see SubagentRuntime.listChildren for the public cancellation and failure contract.
87
- * @param ctx - context carrying the session store, the projection registry,
88
- * optional persistence, and the optional projection cache.
89
- * @param parentSessionId - parent session whose direct children are listed.
90
- * @param signal - caller-owned cancellation observed around every persistence read.
91
- * @returns children and per-child diagnostics ordered by `createdAt`, then id.
92
- * @throws {@link SubagentError} when the projection registry or the session
93
- * store is not mounted, or the caller cancels the listing.
70
+ * Read one parent's durable catalog through a live-preferred Session observation.
71
+ * @param ctx - context carrying the Session query service.
72
+ * @param parentSessionId - parent whose direct children are requested.
73
+ * @param signal - cancellation forwarded to the Session observation.
74
+ * @returns direct-child rows in parent catalog event order.
75
+ * @throws {@link SubagentError} when query or catalog projection is unavailable.
94
76
  */
95
77
  export async function listChildren(ctx, parentSessionId, signal) {
96
- const listing = await prepareListing(ctx, signal);
97
- const candidates = [...listing.corpus.values()]
98
- .filter(record => record.header.parentSession === parentSessionId
99
- && record.header.origin === 'subagent')
100
- .sort(compareCorpusRecords);
101
- const rows = await resolveCandidateRows(candidates, listing, signal);
102
- return rows.filter((row) => row !== undefined);
78
+ const env_1 = { stack: [], error: void 0, hasError: false };
79
+ try {
80
+ const query = ctx.get('sessionQuery');
81
+ if (query === undefined) {
82
+ throw new SubagentError('listing subagents requires the sessionQuery service (load @deepseek-ai/dsh-session-query)', 'SUBAGENT_CONTROL_QUERY_UNAVAILABLE');
83
+ }
84
+ const parent = __addDisposableResource(env_1, await query.observeSession(parentSessionId, {
85
+ ...signal === undefined ? {} : { signal },
86
+ }), false);
87
+ const entries = parent.projections?.values.subagentCatalog;
88
+ if (entries === undefined) {
89
+ throw new SubagentError('listing subagents requires the registered subagentCatalog projection', 'SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE');
90
+ }
91
+ return entries;
92
+ }
93
+ catch (e_1) {
94
+ env_1.error = e_1;
95
+ env_1.hasError = true;
96
+ }
97
+ finally {
98
+ __disposeResources(env_1);
99
+ }
103
100
  }
104
101
  /**
105
102
  * Enumerate every session-backed subagent below one root in stable pre-order.
106
103
  * Ordinary sessions and one-shot children remain traversal nodes, so a
107
104
  * continuable child below either is still discovered. Classification uses the
108
- * same projection-backed runtime as {@link listChildren}; no Agent is loaded or
109
- * resumed.
105
+ * registered child identity projection; no Agent is loaded or resumed.
110
106
  * @see SubagentRuntime.listDescendants for the public cancellation and failure contract.
111
107
  * @param ctx - context carrying the session store, projection registry, and optional persistence/cache.
112
108
  * @param rootSessionId - session whose complete descendant tree is listed.
113
109
  * @param signal - caller-owned cancellation observed around every persistence read.
114
110
  * @returns interpreted subagents with durable direct-parent and root-relative depth.
115
- * @throws {@link SubagentError} under the same conditions as {@link listChildren}.
111
+ * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.
116
112
  */
117
113
  export async function listDescendants(ctx, rootSessionId, signal) {
118
114
  const listing = await prepareListing(ctx, signal);
@@ -271,17 +267,17 @@ function compareCorpusRecords(a, b) {
271
267
  * throw — are final, so they report `corrupt`.
272
268
  */
273
269
  async function resolveColdIdentity(query, cache, header, hasChildren, signal) {
274
- const env_1 = { stack: [], error: void 0, hasError: false };
270
+ const env_2 = { stack: [], error: void 0, hasError: false };
275
271
  try {
276
272
  const childId = header.id;
277
273
  // A header deliberately exposes only whether a fork cut exists, not its
278
- // integer. An unseeded lifecycle has the exact cut 0 and may use the cache;
279
- // a seeded lifecycle must read the body before an identity seq can be
280
- // classified as inherited or owned.
274
+ // integer. An unseeded lifecycle has the exact cut 0, so its cached
275
+ // descriptor is owned at every valid seq; a seeded lifecycle must read the
276
+ // body before an identity seq can be classified as inherited or owned.
281
277
  if (cache !== undefined && !header.isSeeded) {
282
278
  let cached;
283
279
  try {
284
- cached = cache.cachedSnapshot(header, SessionLogOffset(0), ['subagent'])?.values.subagent;
280
+ cached = cache.cachedSnapshot(header, ['subagent'])?.values.subagent;
285
281
  }
286
282
  catch {
287
283
  // Unlike the preparation fold below, a throwing cache read renders no
@@ -317,7 +313,7 @@ async function resolveColdIdentity(query, cache, header, hasChildren, signal) {
317
313
  : 'unavailable',
318
314
  };
319
315
  }
320
- const ownedObservation = __addDisposableResource(env_1, observation, false);
316
+ const ownedObservation = __addDisposableResource(env_2, observation, false);
321
317
  assertListingNotCancelled(signal);
322
318
  // A session id names a slot, not a lifecycle: a child deleted and
323
319
  // re-published under another owner between the enumeration and this read
@@ -332,12 +328,12 @@ async function resolveColdIdentity(query, cache, header, hasChildren, signal) {
332
328
  }
333
329
  return childRow(childId, identity, 'inactive', hasChildren);
334
330
  }
335
- catch (e_1) {
336
- env_1.error = e_1;
337
- env_1.hasError = true;
331
+ catch (e_2) {
332
+ env_2.error = e_2;
333
+ env_2.hasError = true;
338
334
  }
339
335
  finally {
340
- __disposeResources(env_1);
336
+ __disposeResources(env_2);
341
337
  }
342
338
  }
343
339
  /** Materialize one served identity as its child row. */
@@ -68,7 +68,7 @@ export interface RunResultSettlement {
68
68
  /** The turn attempt (typically racing local cancellation); returns the terminal result. */
69
69
  attempt: () => Promise<SubagentResult>;
70
70
  /** Snapshot the provider exposes when cancellation or failure wins settlement. */
71
- collectOutput: () => ContentBlock[];
71
+ collectOutput: () => readonly ContentBlock[];
72
72
  /** Snapshot safe provider-authored detail when a failure wins settlement. */
73
73
  collectDiagnostic?: (() => string | undefined) | undefined;
74
74
  /** Whether local cancellation settled before the attempt's outcome is observed. */
@@ -14,6 +14,9 @@ export type SubagentCatalogEntry = {
14
14
  } | {
15
15
  readonly mode: 'continuable';
16
16
  readonly label: string;
17
+ } | {
18
+ readonly mode: 'unknown';
19
+ readonly label?: string;
17
20
  });
18
21
  /** Durable active-turn timing for one descriptor-backed child session. */
19
22
  export interface SubagentTimingProjection {
@@ -26,6 +29,11 @@ export interface SubagentTimingProjection {
26
29
  /** Latest event time folded into this projection cut. */
27
30
  through: number;
28
31
  };
32
+ /**
33
+ * Whether the latest closed turn after the child's own descriptor completed
34
+ * normally; absent while a turn is open or before one closes.
35
+ */
36
+ lastTurnCompleted?: boolean;
29
37
  }
30
38
  /**
31
39
  * Durable identity of one descriptor-backed subagent session: lifecycle mode
@@ -57,7 +65,7 @@ declare module '@deepseek-ai/dsh-session-projection/types' {
57
65
  interface SessionProjectionMap {
58
66
  /** Direct children in parent catalog event order, excluding fork-inherited facts. */
59
67
  subagentCatalog: SubagentCatalogEntry[];
60
- /** Active-turn duration for a descriptor-backed subagent session. */
68
+ /** Active-turn duration and latest closed-turn completion for a descriptor-backed subagent session. */
61
69
  subagentTiming: SubagentTimingProjection;
62
70
  /**
63
71
  * Identity of a descriptor-backed subagent session. `null` ⟺ no valid
@@ -20,6 +20,8 @@ export interface TimingState {
20
20
  pendingTurnStart?: number | undefined;
21
21
  /** Whether the fold has crossed a descriptor in this logical log. */
22
22
  descriptorSeen: boolean;
23
+ /** Whether the latest closed post-descriptor turn completed normally; absent while a turn is open or before one closes. */
24
+ lastTurnCompleted?: boolean | undefined;
23
25
  }
24
26
  declare module '@deepseek-ai/dsh-session-projection/types' {
25
27
  interface SessionProjectionStateMap {
@@ -52,10 +54,13 @@ export declare const subagentTimingProjectionDefinition: {
52
54
  } | undefined;
53
55
  /** Whether the fold has crossed a descriptor in this logical log. */
54
56
  descriptorSeen: boolean;
57
+ /** Whether the latest closed post-descriptor turn completed normally; absent while a turn is open or before one closes. */
58
+ lastTurnCompleted?: boolean | undefined;
55
59
  };
56
60
  wire: {
57
61
  viewSchema: z.ZodType<SubagentTimingProjection, unknown, z.core.$ZodTypeInternals<SubagentTimingProjection, unknown>>;
58
62
  view: (state: NoInfer<TimingState>) => {
63
+ lastTurnCompleted?: boolean;
59
64
  active?: {
60
65
  since: number;
61
66
  through: number;