@toddzheng024/dscode-bundle 0.7.27 → 0.7.29

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 (103) 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 +433 -46
  5. package/package.json +280 -245
  6. package/plugins/account/index.mjs +178 -0
  7. package/plugins/account/state.mjs +123 -0
  8. package/plugins/auto-review/index.mjs +8 -5
  9. package/plugins/code-review/index.mjs +1 -1
  10. package/plugins/computer-use/index.mjs +37 -0
  11. package/plugins/cordis-config/plain.mjs +31 -0
  12. package/plugins/dscode/index.mjs +1 -1
  13. package/plugins/exec/cli.mjs +1 -1
  14. package/plugins/grok/index.mjs +28 -24
  15. package/plugins/i18n/messages.mjs +204 -0
  16. package/plugins/memory/index.mjs +1 -1
  17. package/plugins/message-source/kind.mjs +20 -0
  18. package/plugins/openrouter/adapter.mjs +29 -13
  19. package/plugins/openrouter/index.mjs +31 -28
  20. package/plugins/session-bridge/communication.mjs +6 -3
  21. package/plugins/session-bridge/server.mjs +3 -2
  22. package/plugins/session-bridge/tasks.mjs +3 -1
  23. package/plugins/session-cards/index.mjs +1 -1
  24. package/plugins/time-marks/index.mjs +3 -2
  25. package/plugins/time-marks/marks.mjs +6 -5
  26. package/plugins/triggers/config.mjs +1 -1
  27. package/plugins/triggers/tools.mjs +1 -1
  28. package/plugins/tui-tools/doctor.mjs +1 -1
  29. package/plugins/tui-tools/index.mjs +16 -4
  30. package/plugins/ultra/policy.mjs +16 -0
  31. package/vendor/bash/index.js +455 -186
  32. package/vendor/bash/types/background.d.ts +38 -7
  33. package/vendor/bash/types/index.d.ts +20 -4
  34. package/vendor/bash/types/render.d.ts +28 -9
  35. package/vendor/command-goal/index.js +3 -1
  36. package/vendor/deepseek/index.js +1378 -1246
  37. package/vendor/deepseek/types/adapter.d.ts +16 -155
  38. package/vendor/deepseek/types/config.d.ts +127 -0
  39. package/vendor/deepseek/types/defaults.d.ts +24 -0
  40. package/vendor/deepseek/types/file-store.d.ts +5 -3
  41. package/vendor/deepseek/types/files-api.d.ts +12 -9
  42. package/vendor/deepseek/types/image-tokens.d.ts +24 -9
  43. package/vendor/deepseek/types/images.d.ts +35 -0
  44. package/vendor/deepseek/types/index.d.ts +10 -94
  45. package/vendor/deepseek/types/messages-api.d.ts +10 -0
  46. package/vendor/deepseek/types/model-info.d.ts +16 -0
  47. package/vendor/deepseek/types/models.d.ts +4 -0
  48. package/vendor/deepseek/types/replay.d.ts +27 -0
  49. package/vendor/deepseek/types/request-extensions.d.ts +16 -0
  50. package/vendor/deepseek/types/request-files.d.ts +49 -0
  51. package/vendor/deepseek/types/request-pricing.d.ts +32 -20
  52. package/vendor/deepseek/types/serialize.d.ts +17 -82
  53. package/vendor/deepseek/types/sse.d.ts +6 -22
  54. package/vendor/deepseek/types/translate.d.ts +13 -36
  55. package/vendor/deepseek/types/transport.d.ts +15 -0
  56. package/vendor/deepseek/types/types.d.ts +106 -167
  57. package/vendor/deepseek/types/wire-types.d.ts +62 -0
  58. package/vendor/persistent/index.js +9 -3
  59. package/vendor/subagent/index.js +11 -8
  60. package/vendor/subagent/model-selection-settings.js +12 -38
  61. package/vendor/subagent/types/index.d.ts +4 -3
  62. package/vendor/subagent/types/model-selection-settings.d.ts +12 -10
  63. package/vendor/subagent-core/index.js +401 -264
  64. package/vendor/subagent-core/typert.host.js +103 -113
  65. package/vendor/subagent-core/typert.remote-client.d.ts +1 -3
  66. package/vendor/subagent-core/typert.remote-client.js +23 -69
  67. package/vendor/subagent-core/types/archive-admission.d.ts +16 -0
  68. package/vendor/subagent-core/types/archive-admission.js +151 -0
  69. package/vendor/subagent-core/types/assistant-output.d.ts +2 -2
  70. package/vendor/subagent-core/types/catalog.d.ts +17 -10
  71. package/vendor/subagent-core/types/catalog.js +12 -6
  72. package/vendor/subagent-core/types/child-agent.d.ts +8 -5
  73. package/vendor/subagent-core/types/child-agent.js +11 -5
  74. package/vendor/subagent-core/types/continuation-activation.d.ts +17 -1
  75. package/vendor/subagent-core/types/continuation-activation.js +41 -4
  76. package/vendor/subagent-core/types/continuation-messages.d.ts +1 -1
  77. package/vendor/subagent-core/types/continuation-messages.js +7 -3
  78. package/vendor/subagent-core/types/continuation.d.ts +1 -1
  79. package/vendor/subagent-core/types/continuation.js +2 -2
  80. package/vendor/subagent-core/types/control-types.d.ts +29 -36
  81. package/vendor/subagent-core/types/control-types.js +2 -3
  82. package/vendor/subagent-core/types/control.d.ts +2 -28
  83. package/vendor/subagent-core/types/control.js +3 -40
  84. package/vendor/subagent-core/types/index.d.ts +45 -41
  85. package/vendor/subagent-core/types/index.js +46 -82
  86. package/vendor/subagent-core/types/internal.d.ts +2 -2
  87. package/vendor/subagent-core/types/internal.js +2 -2
  88. package/vendor/subagent-core/types/lifecycle.d.ts +1 -1
  89. package/vendor/subagent-core/types/lifecycle.js +5 -3
  90. package/vendor/subagent-core/types/list-children.d.ts +15 -32
  91. package/vendor/subagent-core/types/list-children.js +45 -49
  92. package/vendor/subagent-core/types/out-of-process.d.ts +1 -1
  93. package/vendor/subagent-core/types/projection-types.d.ts +9 -1
  94. package/vendor/subagent-core/types/projection.d.ts +5 -0
  95. package/vendor/subagent-core/types/projection.js +10 -4
  96. package/vendor/subagent-core/types/run-settlement.js +1 -1
  97. package/vendor/subagent-core/types/types.d.ts +2 -2
  98. package/vendor/terminal/index.js +94 -30
  99. package/vendor/tui/lib/index.mjs +2 -1
  100. package/vendor/tui/lib/kernel-panels.mjs +1 -1
  101. package/vendor/tui/lib/render/projection.mjs +50 -36
  102. package/presets/dscode/agent.cordis.yml +0 -321
  103. package/presets/dscode/preset.yml +0 -3
@@ -13,6 +13,20 @@ import { appendDelegatedPolicyOverrides, applyChildComposition, } from "./child-
13
13
  import { createSettlementMessage } from "./continuation-messages.js";
14
14
  import { SubagentError } from "./error.js";
15
15
  import { SubagentInbox } from "./inbox.js";
16
+ /** Process-local slots shared through uninterrupted continuable parent links. */
17
+ class ActivationPool {
18
+ slots = new Set();
19
+ /** Reserve before reconstruction; the returned release also tolerates unpublished rollback. */
20
+ reserve(capacity) {
21
+ if (this.slots.size >= capacity) {
22
+ throw new SubagentError(`subagent limit reached (active child limit: ${capacity}); wait for an existing child to finish `
23
+ + 'or complete this work with the current agents', 'ACTIVATION_LIMIT_REACHED');
24
+ }
25
+ const slot = Symbol();
26
+ this.slots.add(slot);
27
+ return () => { this.slots.delete(slot); };
28
+ }
29
+ }
16
30
  /** Serialize each durable child's delivery, release, and disposal. */
17
31
  export class ChildLock {
18
32
  tails = new Map();
@@ -40,8 +54,11 @@ export class ChildLock {
40
54
  export class ContinuableActivationRegistry {
41
55
  ctx;
42
56
  observeActivation;
57
+ maxActiveSubagents;
43
58
  /** Child session id → its live Activation. Process-local, never durable. */
44
59
  resident = new Map();
60
+ /** Root identities retain their pool across child settlement without retaining dead roots. */
61
+ rootPools = new WeakMap();
45
62
  /** Materializations admitted before drain, tracked through publication or rollback. */
46
63
  materializations = new Set();
47
64
  /** Per-child serializer shared by delivery, release, and disposal. */
@@ -61,9 +78,10 @@ export class ContinuableActivationRegistry {
61
78
  * @param ctx - context providing Agents, Sessions, and teardown ownership.
62
79
  * @param observeActivation - build the lifecycle observer for one residency epoch.
63
80
  */
64
- constructor(ctx, observeActivation) {
81
+ constructor(ctx, observeActivation, maxActiveSubagents) {
65
82
  this.ctx = ctx;
66
83
  this.observeActivation = observeActivation;
84
+ this.maxActiveSubagents = maxActiveSubagents;
67
85
  // Ordinary Cordis owner effects unwind in reverse registration order, which
68
86
  // cannot express the dynamic child graph. Register the private scope's
69
87
  // structural disposer FIRST and the drain SECOND, so reverse unwind invokes
@@ -305,14 +323,20 @@ export class ContinuableActivationRegistry {
305
323
  */
306
324
  materialize(inputs) {
307
325
  this.assertAdmitting(inputs.parent);
308
- const settled = Promise.withResolvers();
326
+ inputs.signal.throwIfAborted();
309
327
  const lineage = this.liveLineage(inputs.parent);
328
+ const pool = this.resident.get(inputs.parent.id)?.pool ?? this.rootPool(inputs.parent);
329
+ const releaseSlot = pool.reserve(this.maxActiveSubagents());
330
+ const settled = Promise.withResolvers();
310
331
  const materialization = {
311
332
  lineage,
312
333
  settled: settled.promise,
313
334
  };
314
335
  this.materializations.add(materialization);
315
- return this.materializeTracked(inputs, lineage).finally(() => {
336
+ return this.materializeTracked(inputs, lineage, pool, releaseSlot).catch((error) => {
337
+ releaseSlot();
338
+ throw error;
339
+ }).finally(() => {
316
340
  this.materializations.delete(materialization);
317
341
  settled.resolve();
318
342
  });
@@ -400,8 +424,17 @@ export class ContinuableActivationRegistry {
400
424
  }
401
425
  return undefined;
402
426
  }
427
+ /** Resolve a root's pool once; descendants inherit their resident parent's pool directly. */
428
+ rootPool(parent) {
429
+ let pool = this.rootPools.get(parent);
430
+ if (pool === undefined) {
431
+ pool = new ActivationPool();
432
+ this.rootPools.set(parent, pool);
433
+ }
434
+ return pool;
435
+ }
403
436
  /** Perform one tracked materialization through publication or rollback. */
404
- async materializeTracked(inputs, parentLineage) {
437
+ async materializeTracked(inputs, parentLineage, pool, releaseSlot) {
405
438
  const { childId, provider, parent, create } = inputs;
406
439
  inputs.signal.throwIfAborted();
407
440
  const setup = (childCtx, child) => {
@@ -433,6 +466,8 @@ export class ContinuableActivationRegistry {
433
466
  setup,
434
467
  });
435
468
  const activation = {
469
+ pool,
470
+ releaseSlot,
436
471
  childId,
437
472
  parentSession: parent.id,
438
473
  provider,
@@ -471,6 +506,7 @@ export class ContinuableActivationRegistry {
471
506
  }
472
507
  finally {
473
508
  this.resident.delete(activation.childId);
509
+ activation.releaseSlot();
474
510
  this.releaseOwnership(activation.childId);
475
511
  }
476
512
  });
@@ -622,6 +658,7 @@ export class ContinuableActivationRegistry {
622
658
  + failures.map(item => errorChain(item)).join('; '), 'ACTIVATION_TEARDOWN_FAILED', { cause: new AggregateError(failures) });
623
659
  }
624
660
  this.resident.delete(childId);
661
+ activation.releaseSlot();
625
662
  this.notifySettlement(activation, activation.observer.terminal(failure));
626
663
  this.releaseOwnership(childId);
627
664
  activation.observer.settle(failure);
@@ -53,7 +53,7 @@ export declare function createAgentMessage(sender: Agent, content: ContentBlock[
53
53
  */
54
54
  export declare function withContinuableReturnGuidance(parentId: SessionId, prompt: ContentBlock[]): ContentBlock[];
55
55
  /**
56
- * Build the runtime-owned settlement notice delivered to a child's parent.
56
+ * Build the runtime-owned settlement notice from the child's nonempty closing text.
57
57
  * @param childId - durable child session id named in the notice.
58
58
  * @param terminal - recorded terminal state for the settled Activation.
59
59
  * @returns the durable user-message representation delivered to the parent.
@@ -77,19 +77,23 @@ function settlementSummary(childId, stopReason) {
77
77
  }
78
78
  }
79
79
  /**
80
- * Build the runtime-owned settlement notice delivered to a child's parent.
80
+ * Build the runtime-owned settlement notice from the child's nonempty closing text.
81
81
  * @param childId - durable child session id named in the notice.
82
82
  * @param terminal - recorded terminal state for the settled Activation.
83
83
  * @returns the durable user-message representation delivered to the parent.
84
84
  */
85
85
  export function createSettlementMessage(childId, terminal) {
86
86
  const summary = settlementSummary(childId, terminal.stopReason);
87
+ // Parent providers receive this notice as a user message and may reject
88
+ // nontext assistant blocks. Keep this conversion local so SDK/UI consumers
89
+ // retain the complete child output.
90
+ const closingText = (terminal.output ?? []).flatMap(block => block.type === 'text' && block.text.length > 0 ? [block] : []);
87
91
  return createUserMessage({
88
92
  content: [
89
93
  { type: 'text', text: summary },
90
- ...terminal.output === undefined
94
+ ...closingText.length === 0
91
95
  ? [{ type: 'text', text: 'It left no closing message.' }]
92
- : [{ type: 'text', text: 'Its closing message:' }, ...terminal.output],
96
+ : [{ type: 'text', text: 'Its closing message:' }, ...closingText],
93
97
  ],
94
98
  source: {
95
99
  kind: 'subagent-settled',
@@ -35,7 +35,7 @@ export declare class SubagentContinuationManager {
35
35
  private readonly ctx;
36
36
  private readonly host;
37
37
  private readonly activations;
38
- constructor(ctx: Context, host: ContinuationHost);
38
+ constructor(ctx: Context, host: ContinuationHost, maxActiveSubagents: () => number);
39
39
  /**
40
40
  * Start one continuable background child and resolve at initial inbox acceptance.
41
41
  * Every earlier failure disposes any created handle and rolls back Activation
@@ -86,10 +86,10 @@ export class SubagentContinuationManager {
86
86
  ctx;
87
87
  host;
88
88
  activations;
89
- constructor(ctx, host) {
89
+ constructor(ctx, host, maxActiveSubagents) {
90
90
  this.ctx = ctx;
91
91
  this.host = host;
92
- this.activations = new ContinuableActivationRegistry(ctx, (provider, childId, parent) => host.observeActivation(provider, childId, parent));
92
+ this.activations = new ContinuableActivationRegistry(ctx, (provider, childId, parent) => host.observeActivation(provider, childId, parent), maxActiveSubagents);
93
93
  }
94
94
  /**
95
95
  * Start one continuable background child and resolve at initial inbox acceptance.
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Client-safe subagent catalog and control vocabulary: the durable direct-child
3
- * row both the listing and the browser catalog answer with, plus the
4
- * browser-facing control surface's prompt, receipts, and failures.
2
+ * Client-safe complete-descendant rows and browser continuation requests,
3
+ * receipts, and failures.
5
4
  *
6
5
  * @module @deepseek-ai/dsh-subagent/control-types
7
6
  */
@@ -17,42 +16,35 @@ import type { SessionId } from '@deepseek-ai/dsh-session/types';
17
16
  * rather than imported.
18
17
  */
19
18
  export type SubagentPromptRequestId = Branded<'session-request-id'>;
20
- /**
21
- * One durable direct-child row, ordered by header `createdAt` with ties broken
22
- * on id. Only a candidate whose durable header has `origin: 'subagent'` is
23
- * interpreted. A served `subagent` projection value produces a `child`; a
24
- * settled candidate whose fold served no identity produces a `diagnostic`; a
25
- * running candidate without one is omitted — its descriptor may not be
26
- * appended yet (the creation window). Diagnostics relay the projection fold's
27
- * outcome or a failed read, never a per-child event scan, and never expose
28
- * model-hidden descriptor content.
29
- */
30
- export type SubagentListEntry = {
31
- readonly kind: 'child';
19
+ /** Shared child fields for complete-descendant listing. */
20
+ export type SubagentCatalogRow = {
32
21
  /** The durable child session id, stable across Activations. */
33
22
  readonly id: SessionId;
34
23
  /**
35
- * Whether the child is live at the moment its reader sampled it: the
36
- * durable listing reads the Session store (`running` means the logical
37
- * record is resident, `inactive` that it exists only in persistence),
38
- * while the browser catalog re-samples the child's Agent driver. Neither
39
- * encodes a durable outcome, and a continuable child may still reject
40
- * delivery as an ownership conflict.
24
+ * Whether complete-descendant listing observed a resident Session. This
25
+ * does not encode a durable outcome or guarantee continuation delivery.
41
26
  */
42
27
  readonly activity: 'running' | 'inactive';
43
- /** Whether a direct descendant has durable `origin: 'subagent'`. */
44
- readonly hasChildren: boolean;
45
28
  } & ({
46
29
  /** A terminal one-shot child. */
47
30
  readonly mode: 'one-shot';
48
- /** Optional durable creation label from the child's descriptor. */
31
+ /** Optional durable creation label from the owning catalog or child descriptor. */
49
32
  readonly label?: string;
50
33
  } | {
51
34
  /** A resumable conversation. */
52
35
  readonly mode: 'continuable';
53
- /** Durable creation label from the child's descriptor. */
36
+ /** Durable creation label from the owning catalog or child descriptor. */
54
37
  readonly label: string;
55
- }) | {
38
+ });
39
+ /**
40
+ * One complete-descendant row. Enumeration may also return diagnostics for
41
+ * child identity observations from the complete Session corpus.
42
+ */
43
+ export type SubagentListEntry = SubagentCatalogRow & {
44
+ readonly kind: 'child';
45
+ /** Whether complete-corpus enumeration observed a direct child. */
46
+ readonly hasChildren: boolean;
47
+ } | {
56
48
  readonly kind: 'diagnostic';
57
49
  /** The candidate's session id. */
58
50
  readonly id: SessionId;
@@ -68,12 +60,7 @@ export type SubagentListEntry = {
68
60
  */
69
61
  readonly reason: 'corrupt' | 'unsupported' | 'unavailable';
70
62
  };
71
- /** Complete direct-child catalog plus the delivery-time parent availability hint. */
72
- export interface SubagentCatalog {
73
- readonly entries: readonly SubagentListEntry[];
74
- readonly parentAvailable: boolean;
75
- }
76
- /** Durable parent/child address that selects subagent transport in the client. */
63
+ /** Durable parent/child browsing address; unknown mode is resolved when child history is read. */
77
64
  export type SubagentAddress = {
78
65
  readonly parentSessionId: SessionId;
79
66
  readonly childSessionId: SessionId;
@@ -81,6 +68,8 @@ export type SubagentAddress = {
81
68
  readonly mode: 'one-shot';
82
69
  } | {
83
70
  readonly mode: 'continuable';
71
+ } | {
72
+ readonly mode: 'unknown';
84
73
  });
85
74
  /** One human message addressed to a continuable direct child. */
86
75
  export interface SubagentPromptRequest {
@@ -110,9 +99,15 @@ export interface SubagentInterruptReceipt {
110
99
  readonly accepted: true;
111
100
  }
112
101
  /**
113
- * Failure details the control surface answers with. Catalog reads, prompts,
114
- * and interrupts share this vocabulary with the Client Remote result.
102
+ * Failure details the control surface answers with. Prompts and interrupts
103
+ * share these failures with the Client Remote result.
115
104
  */
105
+ declare module '@deepseek-ai/dsh-workspace/types' {
106
+ interface SessionActivityKindMap {
107
+ /** A subagent session delegated from this session (at any depth) is inside a turn. */
108
+ subagent: true;
109
+ }
110
+ }
116
111
  declare module '@deepseek-ai/dsh-typert-protocol' {
117
112
  interface RemoteErrorDetailsMap {
118
113
  /** A browser-supplied zone is neither UTC nor a canonical IANA name. */
@@ -139,8 +134,6 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
139
134
  'subagent/delivery-unavailable': {
140
135
  readonly childSessionId: SessionId;
141
136
  };
142
- /** The deployment mounts no session-projection registry. */
143
- 'subagent/projections-unavailable': {};
144
137
  }
145
138
  }
146
139
  //# sourceMappingURL=control-types.d.ts.map
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Client-safe subagent catalog and control vocabulary: the durable direct-child
3
- * row both the listing and the browser catalog answer with, plus the
4
- * browser-facing control surface's prompt, receipts, and failures.
2
+ * Client-safe complete-descendant rows and browser continuation requests,
3
+ * receipts, and failures.
5
4
  *
6
5
  * @module @deepseek-ai/dsh-subagent/control-types
7
6
  */
@@ -1,18 +1,12 @@
1
1
  /**
2
- * Browser-facing subagent control assembly: the catalog view sampled against
3
- * the live Agent registry, one browser zone's validation, and the stable
4
- * failure codes the Remote surface answers with.
2
+ * Browser-facing subagent prompt and interrupt request validation plus the
3
+ * stable prompt failure codes returned by the Remote surface.
5
4
  *
6
5
  * @module @deepseek-ai/dsh-subagent
7
6
  */
8
- import type { Context } from '@deepseek-ai/cordis';
9
7
  import type { SessionId } from '@deepseek-ai/dsh-session';
10
8
  import { z } from 'zod';
11
- import type { SubagentCatalog, SubagentListEntry } from './control-types.ts';
12
9
  declare const CONTROL_ID_SCHEMAS: {
13
- readonly 'subagent.list': z.ZodObject<{
14
- parentSessionId: z.ZodString;
15
- }, z.core.$strip>;
16
10
  readonly 'subagent.prompt': z.ZodObject<{
17
11
  parentSessionId: z.ZodString;
18
12
  childSessionId: z.ZodString;
@@ -36,26 +30,6 @@ declare const CONTROL_ID_SCHEMAS: {
36
30
  * @throws {RemoteError} `gateway/bad-request` with the original Zod issues.
37
31
  */
38
32
  export declare function validateControlRequest(method: keyof typeof CONTROL_ID_SCHEMAS, payload: unknown): void;
39
- /**
40
- * Project one durable listing onto the catalog view, replacing each row's
41
- * store-derived activity with the live Agent driver's status and reporting
42
- * whether the exact parent Agent is live. Without an Agent registry no driver
43
- * runs at all, so every row is inactive and the parent is unavailable.
44
- * @param ctx - Host context that may carry the Agent registry.
45
- * @param parentSessionId - the listed parent.
46
- * @param entries - the durable direct-child listing.
47
- * @returns the catalog view answered to one browser.
48
- */
49
- export declare function catalogView(ctx: Context, parentSessionId: SessionId, entries: readonly SubagentListEntry[]): SubagentCatalog;
50
- /**
51
- * Refuse one catalog read while preserving cancellation and a missing
52
- * projections registry as distinct failures.
53
- * @param error - the thrown value.
54
- * @param signal - the caller's cancellation.
55
- * @returns Never — the refusal is thrown.
56
- * @throws {RemoteError} always.
57
- */
58
- export declare function rejectCatalogRead(error: unknown, signal: AbortSignal): never;
59
33
  /**
60
34
  * Refuse one continuation prompt without exposing provider detail: admission
61
35
  * failures the caller can act on keep their own code, everything else is
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Browser-facing subagent control assembly: the catalog view sampled against
3
- * the live Agent registry, one browser zone's validation, and the stable
4
- * failure codes the Remote surface answers with.
2
+ * Browser-facing subagent prompt and interrupt request validation plus the
3
+ * stable prompt failure codes returned by the Remote surface.
5
4
  *
6
5
  * @module @deepseek-ai/dsh-subagent
7
6
  */
@@ -11,7 +10,6 @@ import { z } from 'zod';
11
10
  import { SubagentError } from "./error.js";
12
11
  const SESSION_ID_SCHEMA = z.string().min(1);
13
12
  const CONTROL_ID_SCHEMAS = {
14
- 'subagent.list': z.object({ parentSessionId: SESSION_ID_SCHEMA }),
15
13
  'subagent.prompt': z.object({
16
14
  parentSessionId: SESSION_ID_SCHEMA,
17
15
  childSessionId: SESSION_ID_SCHEMA,
@@ -37,42 +35,6 @@ export function validateControlRequest(method, payload) {
37
35
  throw new RemoteError('gateway/bad-request', `invalid payload for ${method}`, { issues: parsed.error.issues });
38
36
  }
39
37
  }
40
- /**
41
- * Project one durable listing onto the catalog view, replacing each row's
42
- * store-derived activity with the live Agent driver's status and reporting
43
- * whether the exact parent Agent is live. Without an Agent registry no driver
44
- * runs at all, so every row is inactive and the parent is unavailable.
45
- * @param ctx - Host context that may carry the Agent registry.
46
- * @param parentSessionId - the listed parent.
47
- * @param entries - the durable direct-child listing.
48
- * @returns the catalog view answered to one browser.
49
- */
50
- export function catalogView(ctx, parentSessionId, entries) {
51
- const agents = ctx.get('agents');
52
- return {
53
- entries: entries.map((entry) => entry.kind === 'child'
54
- ? { ...entry, activity: agents?.get(entry.id)?.status === 'running' ? 'running' : 'inactive' }
55
- : entry),
56
- parentAvailable: agents?.get(parentSessionId) !== undefined,
57
- };
58
- }
59
- /**
60
- * Refuse one catalog read while preserving cancellation and a missing
61
- * projections registry as distinct failures.
62
- * @param error - the thrown value.
63
- * @param signal - the caller's cancellation.
64
- * @returns Never — the refusal is thrown.
65
- * @throws {RemoteError} always.
66
- */
67
- export function rejectCatalogRead(error, signal) {
68
- if (isCancellation(error, signal)) {
69
- throw new RemoteError('gateway/cancelled', 'subagent catalog read was cancelled', {}, { cause: error });
70
- }
71
- if (error instanceof SubagentError && error.code === 'SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE') {
72
- throw new RemoteError('subagent/projections-unavailable', 'subagent catalog is unavailable: this deployment does not mount the sessionProjections registry (load @deepseek-ai/dsh-session-projection)', {}, { cause: error });
73
- }
74
- throw new RemoteError('gateway/internal', 'subagent catalog read failed', {}, { cause: error });
75
- }
76
38
  /**
77
39
  * Refuse one continuation prompt without exposing provider detail: admission
78
40
  * failures the caller can act on keep their own code, everything else is
@@ -100,6 +62,7 @@ export function rejectPrompt(error, childSessionId, signal) {
100
62
  throw new RemoteError('subagent/unauthorized', 'subagent does not belong to this parent', { childSessionId }, { cause: error });
101
63
  case 'DRAINING':
102
64
  case 'ACTIVATION_CLOSING':
65
+ case 'ACTIVATION_LIMIT_REACHED':
103
66
  case 'CONTINUATION_UNAVAILABLE':
104
67
  case 'PERSISTENCE_UNAVAILABLE':
105
68
  throw new RemoteError('subagent/delivery-unavailable', 'subagent follow-up is temporarily unavailable', { childSessionId }, { cause: error });
@@ -17,9 +17,9 @@
17
17
  * is resident. Continuable children never become a {@link SubagentRun}: the
18
18
  * continuation manager holds their `AgentHandle` directly and orders every turn
19
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.
20
+ * creation spec and see no handle, turn, or teardown. Direct-child
21
+ * discovery uses the parent catalog; descendant discovery uses the Session
22
+ * corpus. Neither read requires the continuation runtime.
23
23
  *
24
24
  * Same-process providers are trusted typed collaborators. Requests, provider
25
25
  * descriptors, results, and lifecycle payloads are borrowed immutable values;
@@ -28,15 +28,18 @@
28
28
  *
29
29
  * @module @deepseek-ai/dsh-subagent
30
30
  */
31
+ import type { Volatile } from '@deepseek-ai/cordis';
31
32
  import { Context } from '@deepseek-ai/cordis';
33
+ import z from '@deepseek-ai/schemastery';
32
34
  import type { Scoped } from '@deepseek-ai/dsh-scope';
33
35
  import type { ContentBlock, MessageId } from '@deepseek-ai/dsh-llm';
34
36
  import type { Agent } from '@deepseek-ai/dsh-agent';
35
37
  import type { SessionId } from '@deepseek-ai/dsh-session';
36
38
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
37
- import type { SubagentCatalog, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from './control-types.ts';
39
+ import type { SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from './control-types.ts';
38
40
  import type { ContinuableStart, ContinuableStartSpec, SubagentInterruptAuthority, SubagentProvider, SubagentRun, SubagentRunEndInfo, SubagentRunInfo, SubagentSendMessageOptions, SubagentStartRequest } from './types.ts';
39
- import type { SubagentDescendantListEntry, SubagentListEntry } from './list-children.ts';
41
+ import type { SubagentDescendantListEntry } from './list-children.ts';
42
+ import type { SubagentCatalogEntry } from './projection-types.ts';
40
43
  import { deliverSubagentPrompt } from './internal.ts';
41
44
  export type {} from './catalog.ts';
42
45
  export * from './out-of-process.ts';
@@ -45,6 +48,7 @@ export { SubagentRunId } from './types.ts';
45
48
  export type { ContinuableCreateRequest, ContinuableCreateSpec, ContinuableStart, ContinuableStartSpec, ResolvedSubagentStartRequest, SubagentCapabilities, SubagentInterruptAuthority, SubagentProvider, SubagentResult, SubagentRun, SubagentSendMessageOptions, SubagentStartRequest, SubagentStopReason, SubagentStopReasonMap, } from './types.ts';
46
49
  export { foldSubagentDescriptor, snapshotSubagentDescriptor, SUBAGENT_DESCRIPTOR_VERSION, } from './descriptor.ts';
47
50
  export type { ContinuableSubagentDescriptorData, ContinuableSubagentDescriptorInput, OneShotSubagentDescriptorData, OneShotSubagentDescriptorInput, SubagentDescriptorData, SubagentDescriptorInput, } from './descriptor.ts';
51
+ export type { SubagentCatalogEntry } from './projection-types.ts';
48
52
  export { SubagentError } from './error.ts';
49
53
  export { settleRun } from './run-settlement.ts';
50
54
  export { assertSubagentMaxDepth, delegationDepthOf } from './depth.ts';
@@ -94,8 +98,23 @@ declare module '@deepseek-ai/cordis' {
94
98
  'subagent/end'(this: Scoped<SubagentRuntime>, info: SubagentRunEndInfo): void;
95
99
  }
96
100
  }
101
+ /** Host configuration for continuable subagent capacity. */
102
+ export interface Config {
103
+ /** Maximum live children sharing uninterrupted continuable parent links; defaults to 8. */
104
+ maxActiveSubagents: Volatile<number>;
105
+ /** Default delegation depth for tools without an explicit limit; defaults to 1. */
106
+ maxDepth: Volatile<number>;
107
+ }
97
108
  /** Named provider registry with one-shot runs, durable discovery, and continuable-child operations. */
98
109
  export declare class SubagentRuntime extends TypertRemoteService {
110
+ private config;
111
+ static Config: z<Schemastery.ObjectS<NoInfer<{
112
+ maxDepth: z<number, number, "volatile-defined">;
113
+ maxActiveSubagents: z<number, number, "volatile-defined">;
114
+ }>>, Schemastery.ObjectT<NoInfer<{
115
+ maxDepth: z<number, number, "volatile-defined">;
116
+ maxActiveSubagents: z<number, number, "volatile-defined">;
117
+ }>>, "plain">;
99
118
  private providers;
100
119
  private continuations;
101
120
  /**
@@ -104,7 +123,13 @@ export declare class SubagentRuntime extends TypertRemoteService {
104
123
  * composes into the carrier.
105
124
  */
106
125
  private readonly emitLifecycle;
107
- constructor(ctx: Context);
126
+ constructor(ctx: Context, config: Config);
127
+ /**
128
+ * Resolve a delegation tool's depth policy against the current user setting.
129
+ * @param configured - Explicit tool limit, or provider-managed for external delegation.
130
+ * @returns The numeric limit, or undefined when the provider owns depth enforcement.
131
+ */
132
+ resolveMaxDepth(configured?: number | 'provider-managed'): number | undefined;
108
133
  /**
109
134
  * Establish one durable continuable child and deliver its initial prompt.
110
135
  * Resolves when the child's inbox accepts that prompt, without waiting for the
@@ -132,12 +157,12 @@ export declare class SubagentRuntime extends TypertRemoteService {
132
157
  sendMessage(sender: Agent, targetId: SessionId, content: ContentBlock[], options: SubagentSendMessageOptions): Promise<MessageId>;
133
158
  /**
134
159
  * Deliver one host-protocol message to a direct continuable child.
135
- * Symbol-keyed so host adapters can preserve their own provenance without
160
+ * Symbol-keyed so host adapters can preserve their own source descriptors without
136
161
  * widening the public Service Definition or impersonating an Agent sender.
137
162
  * @param parent - exact live direct parent authorizing delivery.
138
163
  * @param childId - durable direct-child session id.
139
164
  * @param content - host-authored content to deliver.
140
- * @param source - durable host-protocol provenance.
165
+ * @param source - durable host-protocol source descriptor.
141
166
  * @param signal - caller cancellation before inbox acceptance.
142
167
  * @param delivery - Queue as a distinct turn or Steer at the nearest step.
143
168
  * @returns the accepted message's inbox id.
@@ -182,53 +207,31 @@ export declare class SubagentRuntime extends TypertRemoteService {
182
207
  */
183
208
  drainContinuableChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
184
209
  /**
185
- * Enumerate the parent's direct session-backed subagents without loading or
186
- * resuming an Agent. The Session query service supplies one live-preferred
187
- * corpus and shared point observations; the projection cache supplies
188
- * immutable descriptor hits without opening cold logs. The registered
189
- * `subagent` projection remains the sole mode/label classifier.
190
- *
191
- * Every query receives `signal`, and the listing rechecks cancellation
192
- * around each await. Read rejections that settle
193
- * after an abort become a stable `SubagentError` with code `CANCELLED`.
194
- * @param parentSessionId - parent session whose direct children are listed.
195
- * @param signal - caller-owned cancellation forwarded to Session queries
196
- * and observed around every read await.
197
- * @returns children and per-child diagnostics ordered by `createdAt`, then id.
198
- * @throws {@link SubagentError} when the projection registry or the session
199
- * store is not mounted, or the caller cancels the listing.
210
+ * Read the parent's durable direct-child catalog without loading or resuming an Agent.
211
+ * The service owns and releases the live-preferred Session observation.
212
+ * @param parentSessionId - parent whose direct children are requested.
213
+ * @param signal - cancellation forwarded to the Session query.
214
+ * @returns catalog children in parent event order.
215
+ * @throws {@link SubagentError} when query or catalog projection is unavailable.
216
+ * @throws SessionQueryError when the parent cannot be read or the query is cancelled.
200
217
  */
201
- listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentListEntry[]>;
218
+ listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentCatalogEntry[]>;
202
219
  /**
203
220
  * Enumerate the root's complete session-backed subagent tree in stable
204
221
  * pre-order from one live-preferred corpus, without loading or resuming an
205
222
  * Agent. Ordinary sessions and one-shot children remain traversal nodes so
206
223
  * continuable descendants below them are discovered; each returned entry
207
224
  * adds its durable `parentId` and root-relative `depth`. Identity resolution,
208
- * diagnostics, optional persistence, and cancellation follow the same
209
- * projection-backed contract as {@link listChildren}.
225
+ * diagnostics, optional persistence, and cancellation use the registered
226
+ * child identity projection and complete Session corpus.
210
227
  * @param rootSessionId - session whose complete descendant tree is listed.
211
228
  * @param signal - caller-owned cancellation forwarded to persistence reads
212
229
  * and observed around every read await.
213
230
  * @returns children and per-candidate diagnostics with tree position, in
214
231
  * stable pre-order.
215
- * @throws {@link SubagentError} under the same conditions as {@link listChildren}.
232
+ * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.
216
233
  */
217
234
  listDescendants(rootSessionId: SessionId, signal?: AbortSignal): Promise<SubagentDescendantListEntry[]>;
218
- /**
219
- * Remote face of {@link listChildren} for one browser: the durable listing
220
- * plus live Agent activity and the delivery-time parent availability hint.
221
- * Parent availability is a hint; {@link prompt} performs the authoritative
222
- * check. Named apart from the provider-name {@link list}, which owns the
223
- * member.
224
- * @param parentSessionId - parent session whose direct children are listed.
225
- * @param signal - carrier cancellation forwarded to Session queries.
226
- * @returns the catalog view for that parent.
227
- * @throws {RemoteError} `gateway/bad-request` for an empty parent id,
228
- * `gateway/cancelled` for an aborted read, `subagent/projections-unavailable` when
229
- * the deployment has no projection registry, otherwise `gateway/internal`.
230
- */
231
- remoteExportList(parentSessionId: SessionId, signal: AbortSignal): Promise<SubagentCatalog>;
232
235
  /**
233
236
  * Deliver one browser-authored message to a continuable child through the
234
237
  * exact live direct parent, retaining the caller-minted request identity and
@@ -238,6 +241,7 @@ export declare class SubagentRuntime extends TypertRemoteService {
238
241
  * nearest step and retains the Agent loop's best-effort fallback semantics.
239
242
  * Image parts are admitted and persisted through the attachment store
240
243
  * before delivery, and the child's model must accept image input.
244
+ * Cold resume at capacity rejects with `subagent/delivery-unavailable`.
241
245
  * @param request - durable address, delivery, minted identity, content, and optional browser zone.
242
246
  * @param signal - carrier cancellation, owning the call until inbox acceptance.
243
247
  * @returns the accepted message's inbox identity.