@morlay/dsh-subagent 0.0.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.
@@ -0,0 +1,2197 @@
1
+ import { Context, Service, Volatile } from "@deepseek-ai/cordis";
2
+ import z from "@deepseek-ai/schemastery";
3
+ import { ContentBlock, HarnessError, MessageId, ReasoningEffortId } from "@deepseek-ai/dsh-llm";
4
+ import { Agent, AgentOptions, CreateAgentOptions } from "@deepseek-ai/dsh-agent";
5
+ import { Session, SessionEvent, SessionId, SessionLogOffset } from "@deepseek-ai/dsh-session";
6
+ import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
7
+ import { PromptContentPart } from "@deepseek-ai/dsh-attachment/types";
8
+ import { Branded } from "@deepseek-ai/dsh-brand";
9
+ import { MessageId as MessageId$1 } from "@deepseek-ai/dsh-llm/brand";
10
+ import { SessionId as SessionId$1, SessionSeq } from "@deepseek-ai/dsh-session/types";
11
+ import { ObjectJsonSchema, ToolRestriction } from "@deepseek-ai/dsh-tools";
12
+ import { Scoped } from "@deepseek-ai/dsh-scope";
13
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/control-types.d.ts
14
+ /**
15
+ * Client-minted identity of one browser prompt, persisted on the exact accepted
16
+ * message. It carries the Session Controller's `session-request-id` brand so a
17
+ * subagent prompt and an ordinary Session prompt share one identity
18
+ * vocabulary; that package depends on this one, so the brand is spelled here
19
+ * rather than imported.
20
+ */
21
+ type SubagentPromptRequestId = Branded<'session-request-id'>;
22
+ /** Shared child fields for complete-descendant listing. */
23
+ type SubagentCatalogRow = {
24
+ /** The durable child session id, stable across Activations. */
25
+ readonly id: SessionId$1;
26
+ /**
27
+ * Whether complete-descendant listing observed a resident Session. This
28
+ * does not encode a durable outcome or guarantee continuation delivery.
29
+ */
30
+ readonly activity: 'running' | 'inactive';
31
+ } & ({
32
+ /** A terminal one-shot child. */
33
+ readonly mode: 'one-shot';
34
+ /** Optional durable creation label from the owning catalog or child descriptor. */
35
+ readonly label?: string;
36
+ } | {
37
+ /** A resumable conversation. */
38
+ readonly mode: 'continuable';
39
+ /** Durable creation label from the owning catalog or child descriptor. */
40
+ readonly label: string;
41
+ });
42
+ /**
43
+ * One complete-descendant row. Enumeration may also return diagnostics for
44
+ * child identity observations from the complete Session corpus.
45
+ */
46
+ type SubagentListEntry = (SubagentCatalogRow & {
47
+ readonly kind: 'child';
48
+ /** Whether complete-corpus enumeration observed a direct child. */
49
+ readonly hasChildren: boolean;
50
+ }) | {
51
+ readonly kind: 'diagnostic';
52
+ /** The candidate's session id. */
53
+ readonly id: SessionId$1;
54
+ /**
55
+ * Why the candidate has no `child` row: `corrupt` for a settled candidate
56
+ * whose projection fold served no identity (a missing, malformed, or
57
+ * unrecognized-version descriptor — deliberately undistinguished), and
58
+ * for any candidate whose log makes a registered unit's fold or schema
59
+ * throw (deterministic data damage, contained per child); `unavailable`
60
+ * when the candidate's Session observation was absent or transiently
61
+ * unreadable (retried on the next listing). `unsupported` is never produced; it remains in the
62
+ * union for consumers that route on it.
63
+ */
64
+ readonly reason: 'corrupt' | 'unsupported' | 'unavailable';
65
+ };
66
+ /** Durable parent/child browsing address; unknown mode is resolved when child history is read. */
67
+ type SubagentAddress = {
68
+ readonly parentSessionId: SessionId$1;
69
+ readonly childSessionId: SessionId$1;
70
+ } & ({
71
+ readonly mode: 'one-shot';
72
+ } | {
73
+ readonly mode: 'continuable';
74
+ } | {
75
+ readonly mode: 'unknown';
76
+ });
77
+ /** One human message addressed to a continuable direct child. */
78
+ interface SubagentPromptRequest {
79
+ /** Identity persisted on the accepted message, minted before the call. */
80
+ readonly requestId: SubagentPromptRequestId;
81
+ readonly parentSessionId: SessionId$1;
82
+ readonly childSessionId: SessionId$1;
83
+ /** Required discriminator retained from the browser control address. */
84
+ readonly mode: 'continuable';
85
+ /** Whether this message queues a later turn or targets the nearest step. */
86
+ readonly delivery: 'queue' | 'steer';
87
+ /**
88
+ * Browser prompt parts delivered as the child's user message. The Host
89
+ * admits and persists image parts before delivery, so the wire never
90
+ * carries a durable attachment reference the caller could fabricate.
91
+ */
92
+ readonly content: readonly PromptContentPart[];
93
+ /** Optional browser zone sampled for this exact human prompt. */
94
+ readonly clientTimeZone?: string;
95
+ }
96
+ /** Inbox identity returned once the continuation accepts one human message. */
97
+ interface SubagentPromptReceipt {
98
+ readonly messageId: MessageId$1;
99
+ }
100
+ /** Uniform acknowledgement that one interrupt request was admitted. */
101
+ interface SubagentInterruptReceipt {
102
+ readonly accepted: true;
103
+ }
104
+ /**
105
+ * Failure details the control surface answers with. Prompts and interrupts
106
+ * share these failures with the Client Remote result.
107
+ */
108
+ declare module '@deepseek-ai/dsh-workspace/types' {
109
+ interface SessionActivityKindMap {
110
+ /** A subagent session delegated from this session (at any depth) is inside a turn. */
111
+ subagent: true;
112
+ }
113
+ }
114
+ declare module '@deepseek-ai/dsh-typert-protocol' {
115
+ interface RemoteErrorDetailsMap {
116
+ /** A browser-supplied zone is neither UTC nor a canonical IANA name. */
117
+ 'subagent/invalid-time-zone': {
118
+ readonly value: string;
119
+ };
120
+ /** No live Agent carries the addressed parent session. */
121
+ 'subagent/parent-unavailable': {
122
+ readonly parentSessionId: SessionId$1;
123
+ };
124
+ /** The addressed child cannot take a continuation. */
125
+ 'subagent/not-resumable': {
126
+ readonly childSessionId: SessionId$1;
127
+ };
128
+ /** The claimed parent does not own the addressed child. */
129
+ 'subagent/unauthorized': {
130
+ readonly childSessionId: SessionId$1;
131
+ };
132
+ /** Image admission or model image-capability refusal. */
133
+ 'subagent/attachment-invalid': {
134
+ readonly reason: string;
135
+ };
136
+ /** The child exists but its inbox cannot admit the message now. */
137
+ 'subagent/delivery-unavailable': {
138
+ readonly childSessionId: SessionId$1;
139
+ };
140
+ }
141
+ }
142
+ //#endregion
143
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/descriptor.d.ts
144
+ declare module '@deepseek-ai/dsh-session/types' {
145
+ interface SessionEventMap {
146
+ /**
147
+ * Durable identity and lifecycle mode of a session-backed subagent child,
148
+ * appended once by the establishing provider inside the child's initial
149
+ * turn, before its first request. Continuable records also carry their
150
+ * resumable composition. Log-only: it carries no `surfaceOp`, never enters
151
+ * model history, and survives compaction.
152
+ */
153
+ 'subagent/descriptor': SubagentDescriptorData;
154
+ }
155
+ }
156
+ /**
157
+ * The current descriptor format version, stamped into every appended
158
+ * `subagent/descriptor` event and required verbatim by {@link foldSubagentDescriptor}.
159
+ * Supporting another composition input is a deliberate version change, never
160
+ * an implicit extra field.
161
+ */
162
+ declare const SUBAGENT_DESCRIPTOR_VERSION = 3;
163
+ /** Fields shared by every supported `subagent/descriptor` payload. */
164
+ interface SubagentDescriptorBase {
165
+ /** Descriptor format version ({@link SUBAGENT_DESCRIPTOR_VERSION}). */
166
+ readonly version: number;
167
+ /** Whether the child is a terminal one-shot run or a resumable conversation. */
168
+ readonly mode: 'one-shot' | 'continuable';
169
+ /** The `ctx.subagents` provider name that established the child. */
170
+ readonly provider: string;
171
+ }
172
+ /** A session-backed subagent that cannot be cold-resumed after its run. */
173
+ interface OneShotSubagentDescriptorData extends SubagentDescriptorBase {
174
+ readonly mode: 'one-shot';
175
+ /**
176
+ * The initial delegation's short `description`, kept as the child's durable
177
+ * creation label so enumeration can identify the conversation without
178
+ * replaying parent tool results or exposing the child prompt.
179
+ */
180
+ readonly label?: string;
181
+ }
182
+ /** A session-backed subagent whose declared composition supports cold resume. */
183
+ interface ContinuableSubagentDescriptorData extends SubagentDescriptorBase {
184
+ readonly mode: 'continuable';
185
+ /** The initial delegation's short `description`, used for durable enumeration. */
186
+ readonly label: string;
187
+ /** Resolved child `agentOptions.provider`, when one was declared. */
188
+ readonly agentProvider?: string;
189
+ /** Resolved child `agentOptions.model`, when one was declared. */
190
+ readonly agentModel?: string;
191
+ /** Resolved child `agentOptions.reasoningEffort`, when one was declared. */
192
+ readonly agentReasoningEffort?: ReasoningEffortId;
193
+ /** Per-child persona that shadows the deployment persona on resume. */
194
+ readonly persona?: string;
195
+ /** Child tool scoping reapplied on resume. */
196
+ readonly toolFilter?: ToolRestriction;
197
+ }
198
+ /** The supported durable subagent identity and optional continuation composition. */
199
+ type SubagentDescriptorData = OneShotSubagentDescriptorData | ContinuableSubagentDescriptorData;
200
+ /** Fields shared by descriptor snapshot inputs. */
201
+ interface SubagentDescriptorInputBase {
202
+ /** Whether the child is a terminal one-shot run or a resumable conversation. */
203
+ readonly mode: 'one-shot' | 'continuable';
204
+ /** The `ctx.subagents` provider name that will establish the child. */
205
+ readonly provider: string;
206
+ }
207
+ /** Input for a one-shot child's durable identity. */
208
+ interface OneShotSubagentDescriptorInput extends SubagentDescriptorInputBase {
209
+ readonly mode: 'one-shot';
210
+ /** Optional initial delegation `description` used as the durable creation label. */
211
+ readonly label?: string;
212
+ }
213
+ /** Input for a continuable child's durable identity and resumable composition. */
214
+ interface ContinuableSubagentDescriptorInput extends SubagentDescriptorInputBase {
215
+ readonly mode: 'continuable';
216
+ /** Initial delegation `description` used for durable enumeration. */
217
+ readonly label: string;
218
+ /** Requested child `agentOptions.provider`. */
219
+ readonly agentProvider?: string;
220
+ /** Requested child `agentOptions.model`. */
221
+ readonly agentModel?: string;
222
+ /** Requested child `agentOptions.reasoningEffort`. */
223
+ readonly agentReasoningEffort?: ReasoningEffortId;
224
+ /** Requested per-child persona. */
225
+ readonly persona?: string;
226
+ /** Requested child tool scoping. */
227
+ readonly toolFilter?: ToolRestriction;
228
+ }
229
+ /** Inputs {@link snapshotSubagentDescriptor} validates and detaches. */
230
+ type SubagentDescriptorInput = OneShotSubagentDescriptorInput | ContinuableSubagentDescriptorInput;
231
+ /**
232
+ * Validate and detach descriptor inputs into the durable payload, before any
233
+ * Task or provider work begins — the same detached lossless-JSON boundary the
234
+ * session log itself enforces, applied early so a synchronous validation
235
+ * failure rejects the tool call without creating a Task.
236
+ * @param input - the caller-collected composition fields.
237
+ * @returns the versioned, detached descriptor payload.
238
+ * @throws when a field is not losslessly JSON-serializable.
239
+ */
240
+ declare function snapshotSubagentDescriptor(input: OneShotSubagentDescriptorInput): OneShotSubagentDescriptorData;
241
+ /**
242
+ * Validate and detach a continuable descriptor input.
243
+ * @param input - the caller-collected continuable composition fields.
244
+ * @returns the versioned, detached continuable descriptor payload.
245
+ * @throws when a field is not losslessly JSON-serializable.
246
+ */
247
+ declare function snapshotSubagentDescriptor(input: ContinuableSubagentDescriptorInput): ContinuableSubagentDescriptorData;
248
+ /**
249
+ * Fold a persisted child log to its supported descriptor. The first
250
+ * `subagent/descriptor` event is authoritative — the establishing provider
251
+ * appends exactly one, so a later same-type event cannot rewrite the declared
252
+ * composition.
253
+ * @param events - the loaded child session events.
254
+ * @returns the descriptor, or `undefined` when the log has none or its
255
+ * version is not {@link SUBAGENT_DESCRIPTOR_VERSION} (the child cannot be
256
+ * classified by this runtime).
257
+ * @throws when a current-version persisted payload does not match its complete
258
+ * declared schema.
259
+ */
260
+ declare function foldSubagentDescriptor(events: readonly SessionEvent[]): SubagentDescriptorData | undefined;
261
+ //#endregion
262
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/types.d.ts
263
+ /** Identifies one accepted subagent run across its lifecycle event pair. */
264
+ type SubagentRunId = Branded<'SubagentRunId'>;
265
+ /**
266
+ * Brand a string as a {@link SubagentRunId}.
267
+ * @param id - the raw run id.
268
+ * @returns the same string, branded.
269
+ */
270
+ declare function SubagentRunId(id: string): SubagentRunId;
271
+ /** What a caller asks for when starting a continuable background child. */
272
+ interface ContinuableStartSpec {
273
+ /** The `ctx.subagents` provider whose continuable-creation capability establishes the child. */
274
+ readonly provider: string;
275
+ /** The initial delegation's short `description`, persisted as the child's creation label. */
276
+ readonly label: string;
277
+ /**
278
+ * Optional caller-reserved child identity. Omission preserves the manager's
279
+ * UUID allocation; supplying one lets a durable parent record provisioning
280
+ * before child materialization without a second identity handshake.
281
+ */
282
+ readonly childId?: SessionId;
283
+ /**
284
+ * The delegation request. The manager reserves the stable child id, resolves
285
+ * the durable descriptor, and composes the child itself.
286
+ */
287
+ readonly request: Omit<SubagentStartRequest, 'label' | 'signal' | 'outputSchema'>;
288
+ /** Caller cancellation, owning the operation only until inbox acceptance. */
289
+ readonly signal: AbortSignal;
290
+ }
291
+ /** Identities returned once a continuable child accepted its initial prompt. */
292
+ interface ContinuableStart {
293
+ /** The durable child session id, stable across activations. */
294
+ readonly childId: SessionId;
295
+ /** The accepted initial prompt's inbox message id. */
296
+ readonly messageId: MessageId;
297
+ }
298
+ /**
299
+ * Authority under which one interrupt request is admitted. `user` carries the
300
+ * durable direct-parent address a human client presented; `ancestor` carries
301
+ * the exact live Agent object whose recorded lineage must contain the caller.
302
+ */
303
+ type SubagentInterruptAuthority = {
304
+ readonly kind: 'user';
305
+ readonly parentSessionId: SessionId;
306
+ } | {
307
+ readonly kind: 'ancestor';
308
+ readonly agent: Agent;
309
+ };
310
+ /** Options for one model-authored message between adjacent Agents. */
311
+ interface SubagentSendMessageOptions {
312
+ /** Caller cancellation, owning the operation only until inbox acceptance. */
313
+ readonly signal: AbortSignal;
314
+ }
315
+ /**
316
+ * Observe-only identifying detail for a published subagent run, carried by
317
+ * `subagent/start`. One-shot runs and continuable Activation epochs share this
318
+ * payload, so an observer sees the same vocabulary for both.
319
+ */
320
+ interface SubagentRunInfo {
321
+ /** Unique identity shared with the paired terminal event. */
322
+ readonly runId: SubagentRunId;
323
+ /**
324
+ * Provider name recorded when the child was first created. The provider may
325
+ * be absent when an accepted one-shot run becomes ready or a persisted
326
+ * Activation cold-resumes, because neither lifecycle depends on continued
327
+ * registration.
328
+ */
329
+ readonly provider: string;
330
+ /** The child agent's id. */
331
+ readonly id: SessionId;
332
+ /** Snapshot of whether `SubagentRun.localAgent` was present when start fulfilled. */
333
+ readonly local: boolean;
334
+ }
335
+ /**
336
+ * Observe-only outcome detail for a settled subagent run, carried by
337
+ * `subagent/end` and paired with one {@link SubagentRunInfo} by `runId`.
338
+ */
339
+ interface SubagentRunEndInfo {
340
+ /** Unique identity shared with the paired start event. */
341
+ readonly runId: SubagentRunId;
342
+ /** The same provider name carried by the paired start event. */
343
+ readonly provider: string;
344
+ /** The child agent's id. */
345
+ readonly id: SessionId;
346
+ /** Snapshot of whether `SubagentRun.localAgent` was present when start fulfilled. */
347
+ readonly local: boolean;
348
+ /** The terminal stop reason. */
349
+ readonly stopReason: SubagentResult['stopReason'];
350
+ /**
351
+ * The child's final assistant output, selected by the same rule as
352
+ * {@link SubagentResult.output}; absent on infrastructure rejection or when
353
+ * the child produced none.
354
+ */
355
+ readonly lastAssistantMessage?: readonly ContentBlock[];
356
+ }
357
+ /**
358
+ * Which START-TIME features a provider supports. Checked by the service before delegating to
359
+ * {@link SubagentProvider.start}: a request that needs a capability the chosen provider lacks
360
+ * is rejected with a typed error rather than accepted-then-ignored (the "fail loud, no silent
361
+ * degradation" rule). These flags describe the ONE-SHOT
362
+ * {@link SubagentProvider.start} path, where the provider composes the child;
363
+ * continuable children are composed by the continuation manager itself and are
364
+ * gated by {@link SubagentProvider.prepareContinuable} instead. Each flag
365
+ * corresponds one-to-one to a {@link SubagentStartRequest} option: `depthLimit`
366
+ * to `maxDepth`; the other names match.
367
+ */
368
+ interface SubagentCapabilities {
369
+ readonly agentOptions: boolean;
370
+ readonly outputSchema: boolean;
371
+ readonly depthLimit: boolean;
372
+ readonly toolFilter: boolean;
373
+ readonly persona: boolean;
374
+ }
375
+ /**
376
+ * What a caller asks for when starting a ONE-SHOT subagent. The tool layer
377
+ * builds this from the model's `{ description, prompt }` plus its own config;
378
+ * the service validates {@link SubagentCapabilities} against the named provider
379
+ * and resolves the durable descriptor before dispatching to
380
+ * {@link SubagentProvider.start}.
381
+ */
382
+ interface SubagentStartRequest {
383
+ /** Optional short display label persisted with a session-backed child. */
384
+ readonly label?: string;
385
+ /** Content delivered as the child's user message. */
386
+ readonly prompt: ContentBlock[];
387
+ /**
388
+ * The spawning agent. In-process providers derive workspace, lineage, and
389
+ * delegation depth from its durable session state. ACP reads only its cwd,
390
+ * and only when no deployment `cwd` override is configured.
391
+ */
392
+ readonly parent: Agent;
393
+ /**
394
+ * Cancellation signal from the spawning context (the tool's `exec.signal`).
395
+ * This is the canonical cancellation channel both before and after startup:
396
+ * a provider rejects `start()` after cleaning partial resources when it
397
+ * fires before the run is published, and cancels the published run's
398
+ * remaining turn work when it fires afterward.
399
+ */
400
+ readonly signal: AbortSignal;
401
+ /**
402
+ * Optional host-Agent provider, model, reasoning-effort, and output-token
403
+ * overrides. Requires {@link SubagentCapabilities.agentOptions}; in-process
404
+ * providers merge them over the parent Agent's options when they create the
405
+ * child, while the DSH SDK provider merges them over its instance defaults
406
+ * before initializing the separate child runtime.
407
+ */
408
+ readonly agentOptions?: AgentOptions;
409
+ /**
410
+ * Object-rooted JSON Schema within `assertObjectJsonSchema`'s enforced subset. Start rejects
411
+ * unsupported schemas or providers without the capability. Data must be plain host-realm JSON;
412
+ * a successful child returns the matching value as {@link SubagentResult.structured}.
413
+ */
414
+ readonly outputSchema?: ObjectJsonSchema;
415
+ /**
416
+ * Optional absolute delegation-depth cap for the child being started: its
417
+ * computed depth must be less than or equal to this non-negative safe
418
+ * integer. Requires {@link SubagentCapabilities.depthLimit}; rejected at
419
+ * start otherwise.
420
+ */
421
+ readonly maxDepth?: number;
422
+ /**
423
+ * Optional child tool scoping. Requires {@link SubagentCapabilities.toolFilter};
424
+ * rejected at start otherwise. In-process backends apply it as a scoped
425
+ * `tools.restrict()` in the child's creation window: the named tools vanish
426
+ * from the child's prompt AND refuse to execute (one visibility), with loud
427
+ * unknown-name validation.
428
+ */
429
+ readonly toolFilter?: ToolRestriction;
430
+ /**
431
+ * Optional per-child persona. Requires {@link SubagentCapabilities.persona};
432
+ * rejected at start otherwise. In-process backends register it as a scoped
433
+ * `deployment:persona-prefix` section on the child, SHADOWING the deployment's
434
+ * persona for this child alone — same template semantics as the deployment
435
+ * persona (strict `{{…}}` interpolation against the registered variables).
436
+ */
437
+ readonly persona?: string;
438
+ }
439
+ /**
440
+ * Provider-facing one-shot request after {@link SubagentRuntime.start} resolves
441
+ * the durable child descriptor.
442
+ */
443
+ interface ResolvedSubagentStartRequest extends SubagentStartRequest {
444
+ /** Detached descriptor a session-backed provider persists in the child log. */
445
+ readonly descriptor: SubagentDescriptorData;
446
+ }
447
+ /**
448
+ * What the continuation manager asks a provider for while materializing one
449
+ * continuable child's FIRST activation. The manager has already reserved the
450
+ * durable child identity and owns every later operation, so this request
451
+ * carries only what distinguishes a fresh child from one seeded with parent
452
+ * history.
453
+ */
454
+ interface ContinuableCreateRequest {
455
+ /** The reserved durable child session id, for provider diagnostics. */
456
+ readonly sessionId: SessionId;
457
+ /** The delegating parent agent whose history a seeding provider reads. */
458
+ readonly parent: Agent;
459
+ /**
460
+ * Caller cancellation, which owns preparation only until the manager accepts
461
+ * the initial prompt into the child's inbox.
462
+ */
463
+ readonly signal: AbortSignal;
464
+ }
465
+ /**
466
+ * A provider's detached contribution to one continuable child's creation. This
467
+ * is DATA, never a capability: it carries no Agent, `AgentHandle`, prompt
468
+ * delivery, result, disposal, or resume operation, because the continuation
469
+ * manager owns the child's whole lifecycle after preparation.
470
+ */
471
+ interface ContinuableCreateSpec {
472
+ /**
473
+ * Completed-turn prefix of the parent's log to seed the child session with,
474
+ * or absent for a fresh child. Same durable contract as
475
+ * `CreateAgentOptions.seed`: contiguous from seq 0, lossless JSON, balanced.
476
+ */
477
+ readonly seed?: readonly SessionEvent[];
478
+ }
479
+ /**
480
+ * Why a subagent run ended. Merge-extensible (a backend may add variants);
481
+ * consumers branch on the known cases and fall through `default`. The known
482
+ * cases mirror the harness turn-end vocabulary so the tool layer can map a
483
+ * non-`completed` result to an `isError` tool result.
484
+ */
485
+ interface SubagentStopReasonMap {
486
+ /** The child finished its turn normally. */
487
+ completed: 'completed';
488
+ /** Cancelled through the request signal or disposal. */
489
+ aborted: 'aborted';
490
+ /** Model or transport failure. */
491
+ error: 'error';
492
+ /** The child hit its token ceiling before finishing. */
493
+ 'max-tokens': 'max-tokens';
494
+ /** The child declined the task. */
495
+ refusal: 'refusal';
496
+ }
497
+ /** The union over {@link SubagentStopReasonMap} — widens automatically as backends merge in variants. */
498
+ type SubagentStopReason = SubagentStopReasonMap[keyof SubagentStopReasonMap];
499
+ /**
500
+ * The terminal outcome of a subagent run, resolved by {@link SubagentRun.result}.
501
+ */
502
+ interface SubagentResult {
503
+ /**
504
+ * The child's final assistant output is the content of its last non-empty
505
+ * assistant message. Empty-content messages, including usage-only messages,
506
+ * are skipped. Without a non-empty message, the output is its accumulated
507
+ * assistant text stream, or `[]` when the child produced neither.
508
+ */
509
+ readonly output: readonly ContentBlock[];
510
+ /**
511
+ * The structured result after a requested `outputSchema` was successfully
512
+ * satisfied. Requesting a schema does not guarantee presence: a provider can
513
+ * end with `stopReason: 'error'` when the child fails or finishes without a
514
+ * valid capture. The structured value is validated against the requested
515
+ * output schema by the provider; `unknown` here because the seam is
516
+ * schema-agnostic.
517
+ */
518
+ readonly structured?: unknown;
519
+ /**
520
+ * Provider-authored, non-assistant failure detail for a non-`completed`
521
+ * result. Providers keep this text free of tool inputs, file contents,
522
+ * environment values, credentials, and raw protocol payloads, and limit it
523
+ * to 4096 UTF-8 bytes. Consumers present it separately from {@link output}.
524
+ */
525
+ readonly diagnostic?: string;
526
+ /** Why the run ended. A non-`completed` reason means `output` may be partial. */
527
+ readonly stopReason: SubagentStopReason;
528
+ }
529
+ /**
530
+ * ONE-SHOT child handle returned after publication. Prompt submission, turn
531
+ * work, and infrastructure faults after that boundary belong to {@link result}.
532
+ * Consumers await that result and must always {@link dispose} to cancel
533
+ * remaining work and reach quiescence. A run is one disposable foreground
534
+ * delegation with one result; continuable conversations have no run — the
535
+ * continuation manager holds their `AgentHandle` directly and orders every
536
+ * turn through the child's own inbox.
537
+ */
538
+ interface SubagentRun {
539
+ /**
540
+ * Parent-scoped run id. For a local run, this MUST equal the published child
541
+ * session id, whose `parentSession` records `request.parent.session.id`; a
542
+ * remote provider mints an id unique in the parent namespace.
543
+ */
544
+ readonly id: SessionId;
545
+ /**
546
+ * The exact published in-process child, or `undefined` for a remote run.
547
+ * When present, its id is {@link id}; the provider retains no ownership
548
+ * implication beyond the run's ordinary {@link dispose} contract.
549
+ */
550
+ readonly localAgent: Agent | undefined;
551
+ /**
552
+ * Resolves with the child's terminal {@link SubagentResult} when the run
553
+ * settles. Does NOT reject on a child-level failure — a model/transport
554
+ * failure resolves with `stopReason: 'error'` so the consumer maps it to an
555
+ * `isError` tool result. Rejects on an infrastructure fault the seam cannot
556
+ * represent as a stop reason.
557
+ */
558
+ readonly result: Promise<SubagentResult>;
559
+ /**
560
+ * Cancel remaining work, reach child quiescence, and release resources.
561
+ * Idempotent.
562
+ */
563
+ dispose(): Promise<void>;
564
+ }
565
+ /**
566
+ * One registered transport for running child agents. Providers are trusted
567
+ * same-process implementations; callers treat descriptors and returned values
568
+ * as borrowed immutable data. The service may call one provider concurrently
569
+ * for distinct children. Providers isolate operation-local mutable state; a
570
+ * shared capacity controller may delay an operation but must not couple its
571
+ * settlement or cleanup to a sibling.
572
+ */
573
+ interface SubagentProvider {
574
+ /** Unique registry name (e.g. `spawn`, `fork`, `acp`). */
575
+ readonly name: string;
576
+ /** The start-time features this provider supports (see {@link SubagentCapabilities}). */
577
+ readonly capabilities: SubagentCapabilities;
578
+ /**
579
+ * Whether the child sees the parent's completed-turn prefix. This is descriptive, not a
580
+ * service-validated start capability: the model-facing tool derives truthful wording from it.
581
+ * It says nothing about tool registration, injected services, or authority inheritance.
582
+ */
583
+ readonly inheritsParentContext: boolean;
584
+ /**
585
+ * Optional static provider-owned provider/model route for one-shot Agent
586
+ * options. Consumers merge tool/model overrides over these values before
587
+ * preflight; providers whose route derives from the parent omit it. The value
588
+ * is detached immutable data and requires `agentOptions` support.
589
+ */
590
+ readonly agentRouteDefaults?: Readonly<{
591
+ provider: string;
592
+ model: string;
593
+ }>;
594
+ /**
595
+ * Establish a ONE-SHOT child and return its handle after publication.
596
+ * The service has already validated that every requested start-time
597
+ * capability is supported and resolved `request.descriptor`, so a
598
+ * session-backed implementation appends that descriptor inside the child's
599
+ * initial turn. Before fulfillment, the provider owns setup and cleans any
600
+ * unpublished partial resources before rejecting. Ownership transfers on
601
+ * fulfillment; subsequent turn or infrastructure failure settles through
602
+ * the returned run. Distinct starts may overlap; cancellation, failure,
603
+ * result settlement, and disposal remain independent for each run.
604
+ */
605
+ start(request: ResolvedSubagentStartRequest): Promise<SubagentRun>;
606
+ /**
607
+ * OPTIONAL (continuable-creation capability): contribute the detached
608
+ * creation inputs that distinguish this provider's continuable children —
609
+ * only whether the child session is seeded with parent history. Method
610
+ * presence IS the capability: the service rejects continuable starts on
611
+ * providers without it, while a provider that has it may still serve
612
+ * ordinary one-shot delegations.
613
+ *
614
+ * This is the provider's ONLY participation in a continuable child. The
615
+ * continuation manager owns identity reservation, composition, Agent
616
+ * creation, prompt delivery, cold resume, ownership, and disposal, so a
617
+ * provider never sees the child's Agent, handle, turns, or teardown.
618
+ * Distinct preparations may overlap; each follows its own signal and returns
619
+ * data belonging only to `request.sessionId`.
620
+ */
621
+ prepareContinuable?(request: ContinuableCreateRequest): Promise<ContinuableCreateSpec>;
622
+ }
623
+ //#endregion
624
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/projection-types.d.ts
625
+ /** One current direct-child discovery row materialized from parent facts. */
626
+ type SubagentCatalogEntry = {
627
+ readonly id: SessionId$1;
628
+ readonly createdAt: number;
629
+ } & ({
630
+ readonly mode: 'one-shot';
631
+ readonly label?: string;
632
+ } | {
633
+ readonly mode: 'continuable';
634
+ readonly label: string;
635
+ } | {
636
+ readonly mode: 'unknown';
637
+ readonly label?: string;
638
+ });
639
+ /** Durable active-turn timing for one descriptor-backed child session. */
640
+ interface SubagentTimingProjection {
641
+ /** Milliseconds accumulated across completed turns after the child's own descriptor. */
642
+ settledMs: number;
643
+ /** Same-cut bounds of the currently open turn, when one has not reached `turn/end`. */
644
+ active?: {
645
+ /** Start of the open turn. */
646
+ since: number;
647
+ /** Latest event time folded into this projection cut. */
648
+ through: number;
649
+ };
650
+ /**
651
+ * Whether the latest closed turn after the child's own descriptor completed
652
+ * normally; absent while a turn is open or before one closes.
653
+ */
654
+ lastTurnCompleted?: boolean;
655
+ }
656
+ /**
657
+ * Durable identity of one descriptor-backed subagent session: lifecycle mode
658
+ * plus creation label, folded last-wins from `subagent/descriptor` events.
659
+ * Label strength follows the descriptor schema: a continuable child always
660
+ * carries one, a one-shot child may omit it.
661
+ */
662
+ type SubagentIdentityProjection = {
663
+ /** A terminal one-shot child. */
664
+ mode: 'one-shot';
665
+ /** Optional durable creation label from the child's descriptor. */
666
+ label?: string;
667
+ /**
668
+ * Seq of the `subagent/descriptor` event this identity was folded from.
669
+ * `session.isOwnSeq(seq)` proves the identity comes from the child's
670
+ * OWN log suffix — where a descriptor is immutable once appended — and
671
+ * not from a fork seed's replayed ancestor descriptor.
672
+ */
673
+ seq: SessionSeq;
674
+ } | {
675
+ /** A resumable conversation. */
676
+ mode: 'continuable';
677
+ /** Durable creation label from the child's descriptor. */
678
+ label: string;
679
+ /** Seq of the folded descriptor event; see the one-shot arm for the own-suffix proof. */
680
+ seq: SessionSeq;
681
+ };
682
+ declare module '@deepseek-ai/dsh-session-projection/types' {
683
+ interface SessionProjectionMap {
684
+ /** Direct children in parent catalog event order, excluding fork-inherited facts. */
685
+ subagentCatalog: SubagentCatalogEntry[];
686
+ /** Active-turn duration and latest closed-turn completion for a descriptor-backed subagent session. */
687
+ subagentTiming: SubagentTimingProjection;
688
+ /**
689
+ * Identity of a descriptor-backed subagent session. `null` ⟺ no valid
690
+ * descriptor (missing, malformed, or unrecognized-version — deliberately
691
+ * undistinguished). The sentinel is deliberately serializable: a
692
+ * value pushed over JSON transports must survive `JSON.stringify`
693
+ * losslessly, where an `undefined` field would be dropped and a stale
694
+ * identity would survive on the receiving side. The entry itself stays
695
+ * non-optional.
696
+ */
697
+ subagent: SubagentIdentityProjection | null;
698
+ }
699
+ }
700
+ //#endregion
701
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/list-children.d.ts
702
+ /**
703
+ * One entry of a descendant listing: the interpreted subagent facts plus its
704
+ * position in the complete session tree. `parentId` is the durable direct
705
+ * parent from the enumerated header, and `depth` counts edges from the root.
706
+ */
707
+ type SubagentDescendantListEntry = SubagentListEntry & {
708
+ /** Durable direct parent of this candidate in the enumerated tree. */
709
+ readonly parentId: SessionId;
710
+ /** Edge distance from the requested root; direct children are `1`. */
711
+ readonly depth: number;
712
+ };
713
+ //#endregion
714
+ //#region ../../../vendor/deepseek-harness/packages/util/chunked-list/lib/types/index.d.ts
715
+ /**
716
+ * Newest chunk of an immutable list; `undefined` represents the empty list.
717
+ * Values within each chunk follow insertion order. Callers treat nodes, arrays,
718
+ * and stored values as immutable; operations share values and older chunks.
719
+ */
720
+ interface ChunkedList<T> {
721
+ readonly values: readonly T[];
722
+ readonly previous?: ChunkedList<T> | undefined;
723
+ }
724
+ //#endregion
725
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/catalog.d.ts
726
+ type KnownCatalogMode = {
727
+ readonly mode: 'one-shot';
728
+ readonly label?: string;
729
+ } | {
730
+ readonly mode: 'continuable';
731
+ readonly label: string;
732
+ };
733
+ /** Parent catalog v0 records known modes; v1 also retains children with unknown mode. */
734
+ type SubagentCatalogEvent = {
735
+ readonly childId: SessionId;
736
+ readonly childCreatedAt: number;
737
+ } & (({
738
+ readonly version: 0;
739
+ } & KnownCatalogMode) | ({
740
+ readonly version: 1;
741
+ } & (KnownCatalogMode | {
742
+ readonly mode: 'unknown';
743
+ readonly label?: string;
744
+ })));
745
+ declare module '@deepseek-ai/dsh-session/types' {
746
+ interface SessionEventMap {
747
+ /**
748
+ * A direct child's identity and available discovery fields.
749
+ * @param data - versioned parent-owned catalog entry.
750
+ */
751
+ 'subagent/catalog': SubagentCatalogEvent;
752
+ }
753
+ }
754
+ /** Host fold state for one parent catalog. */
755
+ interface SubagentCatalogState {
756
+ readonly inheritedEventCount: SessionLogOffset;
757
+ readonly head?: ChunkedList<SubagentCatalogEvent> | undefined;
758
+ }
759
+ declare module '@deepseek-ai/dsh-session-projection/types' {
760
+ interface SessionProjectionStateMap {
761
+ subagentCatalog: SubagentCatalogState;
762
+ }
763
+ }
764
+ //#endregion
765
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/out-of-process.d.ts
766
+ /**
767
+ * The capability advertisement of an out-of-process backend: NONE. A child in
768
+ * another process cannot honor parent-enforced start features
769
+ * (`agentOptions`/`outputSchema`/`maxDepth`/`toolFilter`/`persona`), so the service rejects a
770
+ * request needing any of them before `start` runs — never accepted-then-ignored.
771
+ */
772
+ declare const NO_START_CAPABILITIES: SubagentCapabilities;
773
+ /**
774
+ * Assert a configured timing bound is a positive finite number (it bounds a
775
+ * teardown or shutdown wait; zero, negative, or NaN would skip or wedge it).
776
+ * @param prefix - the consuming plugin's diagnostic prefix (e.g. `subagent-acp`).
777
+ * @param name - the config field name, for the diagnostic.
778
+ * @param value - the configured value.
779
+ */
780
+ declare function assertPositiveFinite(prefix: string, name: string, value: number): void;
781
+ /**
782
+ * Assert `cwd` can actually host the child: absolute (it doubles as the
783
+ * child's workspace identity, and a relative path would be re-anchored to the
784
+ * server process's launch directory) and an existing directory (fail here,
785
+ * before the process boundary, instead of as an ambiguous spawn ENOENT).
786
+ * @param prefix - the consuming plugin's diagnostic prefix.
787
+ * @param label - which source supplied the value, for the diagnostic.
788
+ * @param cwd - the candidate working directory.
789
+ * @returns `cwd`, validated.
790
+ */
791
+ declare function assertUsableCwd(prefix: string, label: string, cwd: string): string;
792
+ /**
793
+ * Validate a configured `cwd` override ONCE, at plugin load: reject the empty
794
+ * string (`path.resolve('')` is the process cwd — it would silently
795
+ * reintroduce the launch-directory fallback this resolution removes),
796
+ * interpret a relative path against the harness launch directory, and require
797
+ * an enterable directory.
798
+ * @param prefix - the consuming plugin's diagnostic prefix.
799
+ * @param cwd - the configured override, or `undefined` when the config omits it.
800
+ * @returns the validated absolute override, or `undefined` when omitted.
801
+ */
802
+ declare function validateConfiguredCwd(prefix: string, cwd: string | undefined): string | undefined;
803
+ /**
804
+ * Resolve the child's working directory at start: the deployment override
805
+ * when configured (already validated at load), else the parent session's
806
+ * workspace cwd (validated here, its earliest resolvable point). Fails loud
807
+ * when neither exists — falling back to the harness process cwd would
808
+ * silently bind the child to the server's launch directory instead of the
809
+ * delegating session's workspace (one server process serves many sessions,
810
+ * each with its own cwd).
811
+ * @param prefix - the consuming plugin's diagnostic prefix.
812
+ * @param configured - the load-validated override, or `undefined`.
813
+ * @param parentCwd - the delegating parent session's workspace cwd, if any.
814
+ * @returns the absolute child working directory.
815
+ */
816
+ declare function resolveChildCwd(prefix: string, configured: string | undefined, parentCwd: string | undefined): string;
817
+ /** Inputs to {@link settleRunResult}. */
818
+ interface RunResultSettlement {
819
+ /** The turn attempt (typically racing local cancellation); returns the terminal result. */
820
+ attempt: () => Promise<SubagentResult>;
821
+ /** Snapshot the provider exposes when cancellation or failure wins settlement. */
822
+ collectOutput: () => readonly ContentBlock[];
823
+ /** Snapshot safe provider-authored detail when a failure wins settlement. */
824
+ collectDiagnostic?: (() => string | undefined) | undefined;
825
+ /** Whether local cancellation settled before the attempt's outcome is observed. */
826
+ cancelled: () => boolean;
827
+ /** Diagnostic sink for a failure flattened to a stop reason; a throw from it is contained. */
828
+ onError?: ((error: Error, stopReason: SubagentStopReason) => void) | undefined;
829
+ /** The request's cancellation signal (the listener is removed at settlement). */
830
+ signal: AbortSignal;
831
+ /** The abort listener registered on {@link signal} at start. */
832
+ onAbort: () => void;
833
+ }
834
+ /**
835
+ * Settle an out-of-process run result under the seam contract: `result` never
836
+ * rejects after publication. A normally completed or rejected attempt resolves
837
+ * as `aborted` when cancellation already settled locally; another rejection is
838
+ * flattened to `stopReason: 'error'` through the contained diagnostic sink.
839
+ * Provider-returned diagnostics use the same byte limit. The abort listener is
840
+ * removed on every path.
841
+ * @param parts - the attempt, output snapshot, cancellation state, sink, and signal wiring.
842
+ * @returns the terminal result (never a rejection).
843
+ */
844
+ declare function settleRunResult(parts: RunResultSettlement): Promise<SubagentResult>;
845
+ /** Inputs to {@link subprocessRunHandle}. */
846
+ interface SubprocessRunHandleParts {
847
+ /** The parent-scoped run id. */
848
+ id: SubagentRun['id'];
849
+ /** The flattened, never-rejecting result (the seam contract). */
850
+ result: Promise<SubagentResult>;
851
+ /** The request's cancellation signal (the listener is removed on dispose). */
852
+ signal: AbortSignal;
853
+ /** The abort listener registered on {@link signal} at start. */
854
+ onAbort: () => void;
855
+ /** Settle local cancellation so {@link result} resolves without the child. */
856
+ requestCancel: () => void;
857
+ /** Tear the child process down to quiescence (backend-owned ladder). */
858
+ teardown: () => Promise<void>;
859
+ }
860
+ /**
861
+ * Publish the seam run handle for an out-of-process child. `dispose()` is
862
+ * idempotent (one memoized teardown): it removes the abort listener, settles
863
+ * local cancellation — there is no assumption the child cooperates — and then
864
+ * awaits the backend's teardown to actual exit.
865
+ * @param parts - the run identity, result, cancellation wiring, and teardown.
866
+ * @returns the seam run handle (`localAgent` is `undefined` for remote runs).
867
+ */
868
+ declare function subprocessRunHandle(parts: SubprocessRunHandleParts): SubagentRun;
869
+ //#endregion
870
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/assistant-output.d.ts
871
+ /**
872
+ * Incremental fold of the selection rule, for backends that observe a child's
873
+ * output as it streams: session-event backends {@link push} each event, and
874
+ * transports without session events (ACP content chunks) {@link pushText} raw
875
+ * text into the same streamed fallback.
876
+ */
877
+ declare class AssistantOutputFold {
878
+ private message;
879
+ private partial;
880
+ /**
881
+ * Fold one session event: a non-empty assistant message becomes the
882
+ * candidate final answer, while its embedded stream and any log-only attempt
883
+ * extend the streamed fallback; every other event contributes nothing.
884
+ * @param event - the next observed session event.
885
+ */
886
+ push(event: SessionEvent): void;
887
+ /**
888
+ * Extend the streamed fallback with text observed outside session events.
889
+ * @param text - the next streamed text piece (an empty piece is a no-op).
890
+ */
891
+ pushText(text: string): void;
892
+ /**
893
+ * Select the final output folded so far.
894
+ * @returns the last non-empty assistant message, else the accumulated
895
+ * streamed text, or `undefined` when the child produced neither.
896
+ */
897
+ collect(): readonly ContentBlock[] | undefined;
898
+ }
899
+ /**
900
+ * Apply the selection rule to one complete child-owned event suffix.
901
+ * @param events - the child-owned events (after any seed or epoch boundary).
902
+ * @returns the selected output, or `undefined` when the child produced none.
903
+ */
904
+ declare function finalAssistantOutput(events: readonly SessionEvent[]): readonly ContentBlock[] | undefined;
905
+ //#endregion
906
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/error.d.ts
907
+ /** Typed failure for the subagent seam. */
908
+ declare class SubagentError extends HarnessError {
909
+ constructor(message: string, code: string, options?: ErrorOptions);
910
+ }
911
+ //#endregion
912
+ //#region ../../../vendor/deepseek-harness/packages/jobs/jobs/lib/types/brand.d.ts
913
+ /**
914
+ * Identifies a background job. The registry generates `<kind>-N`; predictable
915
+ * ids rely on owner authorization rather than secrecy.
916
+ */
917
+ type JobId = Branded<'JobId'>;
918
+ /**
919
+ * Brand a string as a {@link JobId}.
920
+ * @param id - the raw job-id string (the registry generates `<kind>-N`).
921
+ * @returns the same string, branded; no validation is performed.
922
+ */
923
+ declare function JobId(id: string): JobId;
924
+ //#endregion
925
+ //#region ../../../vendor/deepseek-harness/packages/jobs/jobs/lib/types/view.d.ts
926
+ /**
927
+ * Job lifecycle: `running`, optionally `stopping`, then exactly one terminal
928
+ * status. Producer-specific facts belong in {@link JobView.progress} and
929
+ * {@link JobView.detail}.
930
+ */
931
+ type JobStatus = 'running' | 'stopping' | 'completed' | 'killed' | 'failed';
932
+ declare module '@deepseek-ai/dsh-workspace/types' {
933
+ interface SessionActivityKindMap {
934
+ /** A background job owned by this session is running or stopping. */
935
+ job: true;
936
+ }
937
+ }
938
+ /**
939
+ * Producer-defined job kinds. Plugins extend this map by declaration merging;
940
+ * the registry treats every value as an opaque id namespace.
941
+ */
942
+ interface JobKindMap {
943
+ bash: 'bash';
944
+ subagent: 'subagent';
945
+ }
946
+ /** The merge-extensible union of registered producer kind names. */
947
+ type JobKind = JobKindMap[keyof JobKindMap];
948
+ /**
949
+ * Stream label of one output chunk. `stdout` and `stderr` reach the model's
950
+ * consuming read; `log` marks producer narration (a workflow's phase lines)
951
+ * that only observers see. Consumers treat an unrecognized label like an
952
+ * absent one.
953
+ */
954
+ type JobChannel = 'stdout' | 'stderr' | 'log';
955
+ /** One chunk of a job's output ring: absolute offset, text, channel, and loss marker. */
956
+ interface JobChunk {
957
+ /** Absolute offset of the chunk's first byte; offsets never move once assigned. */
958
+ readonly at: number;
959
+ /** Chunk text exactly as appended (possibly tail-trimmed by retention). */
960
+ readonly text: string;
961
+ /** Stream label, when the producer supplied one. */
962
+ readonly channel?: JobChannel;
963
+ /** Bytes immediately before this chunk were lost, at the producer or to retention. */
964
+ readonly gapBefore?: true;
965
+ }
966
+ /**
967
+ * Read-only projection of one job — a fresh object per call, never live
968
+ * registry state. The model tools, the browser roster, and the observation
969
+ * stream all consume this one shape.
970
+ */
971
+ interface JobView {
972
+ /** The registry-issued id (`<kind>-N`). */
973
+ readonly id: JobId;
974
+ /**
975
+ * The producer kind the job was registered with: a Host-registered
976
+ * `JobKind`, carried as an open string because a browser bundle or a Remote
977
+ * codec sees only the `JobKindMap` merges its own program compiles.
978
+ */
979
+ readonly kind: string;
980
+ /** The producer-supplied one-line label. */
981
+ readonly label: string;
982
+ /** Owning session; absent for an unowned job, which every caller can see. */
983
+ readonly owner?: SessionId$1;
984
+ /** Producer-owned cap for complete model-facing notices and reads, in UTF-8 bytes. */
985
+ readonly outputLimitBytes?: number;
986
+ /** Current lifecycle state. */
987
+ readonly status: JobStatus;
988
+ /** The producer's live progress line (`3/10`, the current phase); cleared at settlement. */
989
+ readonly progress?: string;
990
+ /** Terminal reason (`exit code: 3`); a recorded kill reason is merged in. */
991
+ readonly detail?: string;
992
+ /** Epoch ms when the job was registered. */
993
+ readonly startedAt: number;
994
+ /** Epoch ms when the job settled; absent while live. */
995
+ readonly finishedAt?: number;
996
+ /**
997
+ * The output ring's absolute coordinates and the complete-stream files
998
+ * behind it. `total` is the offset the next chunk starts at (0 while
999
+ * nothing was written); `earliest` is the oldest retained byte, greater
1000
+ * than zero exactly when retention dropped the head. `spillPaths` lists the
1001
+ * spill files the job's pull sources currently keep, in source order and
1002
+ * deduplicated, and is absent while no source keeps one: it outlives any
1003
+ * chunk, so a reader below `earliest` can still name where the bytes went.
1004
+ */
1005
+ readonly output: {
1006
+ readonly total: number;
1007
+ readonly earliest: number;
1008
+ readonly spillPaths?: readonly string[];
1009
+ };
1010
+ }
1011
+ //#endregion
1012
+ //#region ../../../vendor/deepseek-harness/packages/jobs/jobs/lib/types/types.d.ts
1013
+ /** Terminal result supplied by a producer through {@link JobHooks.done}. */
1014
+ interface JobOutcome {
1015
+ /** How the job ended: finished (`completed`), cancelled (`killed`), or broke (`failed`). */
1016
+ status: 'completed' | 'killed' | 'failed';
1017
+ /**
1018
+ * Terminal reason rendered into status lines (`exit code: 3`, `max-tokens`).
1019
+ * When the job settles `killed` after a {@link JobRegistry.kill} with a
1020
+ * reason, the registry appends that reason.
1021
+ */
1022
+ detail?: string;
1023
+ /**
1024
+ * Return value for jobs whose result is a value rather than a stream (a
1025
+ * workflow's rendered result, a subagent's report). The output ring carries
1026
+ * the stream; this is handed out once by the model's next {@link JobRegistry.read}.
1027
+ */
1028
+ result?: string;
1029
+ }
1030
+ /** One incremental read from a {@link JobOutputSource}. */
1031
+ interface JobSourceRead {
1032
+ /** Text captured since the requested offset (the whole retained tail when lossy). */
1033
+ text: string;
1034
+ /** Whole-stream offset to resume from on the next read. */
1035
+ nextOffset: number;
1036
+ /** True when the requested offset slid out of the source's retained window. */
1037
+ lossy: boolean;
1038
+ /**
1039
+ * Host path of a file holding the complete stream, when the source
1040
+ * currently keeps an intact one. Reported on every read, so the registry
1041
+ * tracks it as source metadata: a later read without it withdraws the file.
1042
+ */
1043
+ spillPath?: string;
1044
+ }
1045
+ /**
1046
+ * A pull source the registry pumps into the job's output ring — the subprocess
1047
+ * `readFrom` family. The registry owns the cadence and drains every source one
1048
+ * last time before settlement closes the ring, so a producer folds nothing
1049
+ * into its `done`.
1050
+ */
1051
+ interface JobOutputSource {
1052
+ /** Stream label attached to every chunk this source yields. */
1053
+ channel?: JobChannel;
1054
+ /**
1055
+ * Read everything captured since `fromByte` without consuming it.
1056
+ * @param fromByte - whole-stream offset to resume from (a prior read's `nextOffset`; 0 first).
1057
+ * @returns the delta text, the next offset, the lossy flag, and the spill path the source currently keeps.
1058
+ */
1059
+ read(fromByte: number): JobSourceRead;
1060
+ }
1061
+ /** Options for one {@link JobHandle.append}. */
1062
+ interface JobAppendOptions {
1063
+ /** Stream label for the chunk; omitted for producers without distinct streams. */
1064
+ channel?: JobChannel;
1065
+ /**
1066
+ * Marks that producer-side bytes between the previous chunk and this one
1067
+ * were lost, so an observer can render the discontinuity instead of a
1068
+ * silent splice.
1069
+ */
1070
+ gapBefore?: true;
1071
+ }
1072
+ /**
1073
+ * Producer face of one registered job, handed to {@link JobSpec.run} and
1074
+ * valid for the job's whole life. All methods are synchronous. Writes staged
1075
+ * inside the starter call are retained and become visible with the
1076
+ * registration commit; after settlement — the producer's own outcome, a kill,
1077
+ * or a registry-forced teardown end — writes log and drop instead of
1078
+ * throwing, so a producer's trailing flush cannot break its own teardown path.
1079
+ */
1080
+ interface JobHandle {
1081
+ /** The registry-issued id (`<kind>-N`). */
1082
+ readonly id: JobId;
1083
+ /**
1084
+ * Append one chunk to the output ring. Offsets advance by the chunk's UTF-8
1085
+ * byte length; an empty chunk is dropped without waking observers.
1086
+ * @param text - the chunk text, exactly as produced.
1087
+ * @param options - stream label and gap marker.
1088
+ */
1089
+ append(text: string, options?: JobAppendOptions): void;
1090
+ /**
1091
+ * Replace the live progress line (`3/10`, the current phase). Settlement
1092
+ * clears it; the terminal reason travels in {@link JobOutcome.detail}.
1093
+ * @param line - the new progress line.
1094
+ */
1095
+ updateProgress(line: string): void;
1096
+ }
1097
+ /** Hooks through which the runtime controls and observes producer work. */
1098
+ interface JobHooks {
1099
+ /**
1100
+ * Request termination. Must be synchronous, idempotent, and eventually settle
1101
+ * {@link done}; throws propagate. The optional reason is forwarded verbatim.
1102
+ */
1103
+ cancel(reason?: string): void;
1104
+ /**
1105
+ * Resolves after the producer releases its resources, not merely when work
1106
+ * finishes. Must not reject; the runtime converts a rejection to `failed`.
1107
+ * If teardown cancellation throws, the runtime may force-fail only the
1108
+ * registry record without claiming that the work stopped.
1109
+ */
1110
+ done: Promise<JobOutcome>;
1111
+ }
1112
+ /**
1113
+ * Producer declaration passed to {@link JobRegistry.start}. The runtime
1114
+ * preflights access and cleanup before invoking {@link run}; the producer owns
1115
+ * execution resources while the runtime owns identity, lifecycle state, and
1116
+ * the output ring.
1117
+ */
1118
+ interface JobSpec {
1119
+ /** Producer kind — also the id prefix (`bash`, `subagent`, …). */
1120
+ kind: JobKind;
1121
+ /** One-line model-facing label (the command; the delegation description). */
1122
+ label: string;
1123
+ /**
1124
+ * Owning session. Access is fenced by it, and the owner's live Agent must be
1125
+ * the one currently registered under that id: its disposal cancels and
1126
+ * awaits the job. Omitting the owner creates an unowned job, open to any
1127
+ * caller until service disposal.
1128
+ */
1129
+ owner?: SessionId;
1130
+ /**
1131
+ * Optional UTF-8 byte cap for each complete model-facing completion notice or
1132
+ * output read, including controller status metadata. Independent of ring
1133
+ * retention: it bounds the consuming model surface, never observers.
1134
+ */
1135
+ outputLimitBytes?: number;
1136
+ /**
1137
+ * Pull sources the registry pumps into the ring at its own cadence.
1138
+ * Producers that narrate their own progress use {@link JobHandle.append}
1139
+ * instead; a job may use both.
1140
+ */
1141
+ output?: readonly JobOutputSource[];
1142
+ /**
1143
+ * Start the work after preflight and synchronously return its hooks. Called
1144
+ * once with the job's producer face; a throw leaves nothing registered (the
1145
+ * spent ordinal is skipped), and the producer must clean up any partially
1146
+ * started resources.
1147
+ * @param job - the issued id plus the ring append and progress writers.
1148
+ */
1149
+ run(job: JobHandle): JobHooks;
1150
+ }
1151
+ /** Output and post-read state returned by the consuming {@link JobRegistry.read}. */
1152
+ interface JobRead {
1153
+ /** Ring chunks appended since the model cursor, in offset order; every channel included. */
1154
+ chunks: readonly JobChunk[];
1155
+ /** True when the cursor fell below the oldest retained byte, so bytes are missing before `chunks`. */
1156
+ lossy: boolean;
1157
+ /** The producer's {@link JobOutcome.result}, handed out by the first read after settlement only. */
1158
+ result?: string;
1159
+ /** The job's state at read time. */
1160
+ job: JobView;
1161
+ }
1162
+ /** Result of one non-consuming {@link JobRegistry.readAt}. */
1163
+ interface JobOutputRead {
1164
+ /** Retained chunks overlapping `[from, total)`, in offset order. */
1165
+ chunks: readonly JobChunk[];
1166
+ /**
1167
+ * Offset to resume from — the ring's current `total`. Always a chunk
1168
+ * boundary: appends land whole and trimming only advances chunk starts, and
1169
+ * consumers concatenate `chunks` under that assumption, so a provider
1170
+ * serving partial chunks would silently duplicate text.
1171
+ */
1172
+ next: number;
1173
+ /** True when `from` fell below the oldest retained byte, so bytes are missing before `chunks`. */
1174
+ lossy: boolean;
1175
+ }
1176
+ /**
1177
+ * Why a job settled: its producer finished (`producer`), a
1178
+ * {@link JobRegistry.kill} ran first (`kill`), or owner or service teardown
1179
+ * cancelled it (`teardown`) — a settlement whose owner has no reader left.
1180
+ */
1181
+ type JobSettleCause = 'producer' | 'kill' | 'teardown';
1182
+ /**
1183
+ * One lifecycle or output event. Lifecycle events carry the job's projection
1184
+ * after the commit they announce; `output` carries only the id and the new
1185
+ * total, so an observer schedules a {@link JobRegistry.readAt} from its own
1186
+ * cursor and the registry never pushes payloads.
1187
+ */
1188
+ type JobEvent = {
1189
+ /** Registration commit, progress line change, stopping transition, or removal from the visible set. */
1190
+ readonly type: 'registered' | 'progress' | 'stopping' | 'removed';
1191
+ readonly job: JobView;
1192
+ } | {
1193
+ readonly type: 'settled';
1194
+ readonly job: JobView;
1195
+ readonly cause: JobSettleCause;
1196
+ /**
1197
+ * Whether this settlement released a live {@link JobRegistry.wait}. That
1198
+ * waiter's caller receives the terminal projection as its own result, so
1199
+ * a completion reporter treats an awaited settlement as already delivered
1200
+ * and reports only the unawaited ones. A wait that timed out or was
1201
+ * aborted before the settlement does not count.
1202
+ */
1203
+ readonly awaited: boolean;
1204
+ } | {
1205
+ readonly type: 'output';
1206
+ readonly id: JobId;
1207
+ /** Owning session, absent for an unowned job. */
1208
+ readonly owner?: SessionId;
1209
+ /** The ring's total after the append (or at settlement, which ends the stream). */
1210
+ readonly total: number;
1211
+ };
1212
+ /**
1213
+ * Who a subscription hears about. `{ owner }` delivers that session's jobs
1214
+ * plus every unowned job (the set that session can see). `{ owners: 'scope' }`
1215
+ * delivers the owners composed under the subscribing context — one registry
1216
+ * serves every composition in the process, and a mount under one preset must
1217
+ * not hear another preset's agents. `{ owners: 'all' }` delivers everything.
1218
+ */
1219
+ type JobEventFilter = {
1220
+ readonly owner: SessionId;
1221
+ } | {
1222
+ readonly owners: 'all' | 'scope';
1223
+ };
1224
+ /** Event callback; contained by the registry, never awaited. */
1225
+ type JobEventListener = (event: JobEvent) => void;
1226
+ /** The registry's event stream. */
1227
+ interface JobEvents {
1228
+ /**
1229
+ * Register an effect-scoped listener. Events are dispatched synchronously
1230
+ * after the commit they announce; a job's first event is `registered`, and
1231
+ * a `settled` event follows the release of every waiter. No listener runs
1232
+ * after service disposal.
1233
+ * @param filter - which owners' events to deliver.
1234
+ * @param listener - receives each matching event.
1235
+ * @returns disposer that unregisters the listener.
1236
+ */
1237
+ subscribe(filter: JobEventFilter, listener: JobEventListener): () => void;
1238
+ }
1239
+ //#endregion
1240
+ //#region ../../../vendor/deepseek-harness/packages/jobs/jobs/lib/types/index.d.ts
1241
+ declare module '@deepseek-ai/cordis' {
1242
+ interface Context {
1243
+ jobs: JobRegistry;
1244
+ }
1245
+ }
1246
+ /**
1247
+ * Abstract background job registry. Subclass, implement the abstract members,
1248
+ * and load the subclass as a plugin — it registers as `ctx.jobs` (one
1249
+ * implementation per context; loading a second throws, which is cordis'
1250
+ * standard duplicate-service behavior).
1251
+ *
1252
+ * Implementations must honor these semantics:
1253
+ * - Registrations outlive producer and controller fibers. Owner and
1254
+ * service disposal cancel live work and await compliant producers; a
1255
+ * throwing teardown cancel force-fails only the record. Such settlements
1256
+ * announce `cause: 'teardown'`, because a job whose owner is being destroyed
1257
+ * has no reader left.
1258
+ * - Owned-job access is fenced by the owner's session id. Ids are
1259
+ * predictable, so authorization — not secrecy — is the boundary.
1260
+ * - Settlement is first-wins: one terminal record, released waiters, then one
1261
+ * round of contained event delivery, even against a late producer outcome.
1262
+ * The `settled` event follows every released waiter and reports whether it
1263
+ * released one (`awaited`), so a completion reporter can skip settlements a
1264
+ * waiting caller already collected.
1265
+ * - A settled record stays listed until its owner's disposal, service
1266
+ * disposal, or an explicit {@link remove} by a caller that collected the
1267
+ * terminal state itself and never handed the id out.
1268
+ * - {@link start} refuses work while no attached job controller serves the
1269
+ * spec's owner, so a producer cannot start work that owner cannot collect
1270
+ * or stop. One registry serves every composition in the process, so this
1271
+ * question — and event delivery under `{ owners: 'scope' }` — is
1272
+ * owner-relative rather than process-wide: registrations made from an
1273
+ * unscoped context serve every owner, and registrations made under an agent
1274
+ * composition's scope serve exactly the agents composed under it.
1275
+ * - Every job owns one output ring. Pull sources named by the spec are pumped
1276
+ * by the registry and drained once more before settlement; pushed appends
1277
+ * land whole. The model's consuming cursor and observers' absolute offsets
1278
+ * read the same bytes and never disturb each other.
1279
+ * - Ring retention is bounded. Appends past the live cap drop the oldest
1280
+ * retained bytes; a reader below the retained window gets a lossy read,
1281
+ * never an error. Settlement trims retention to the settled cap and ends
1282
+ * the stream; the ring has no separate lifecycle.
1283
+ */
1284
+ declare abstract class JobRegistry extends Service {
1285
+ constructor(ctx: Context);
1286
+ /** Lifecycle and output events, filtered per subscription. */
1287
+ abstract readonly events: JobEvents;
1288
+ /**
1289
+ * Preflight access, validation, owner cleanup, and implementation-owned
1290
+ * admission before starting and atomically registering work. Any preflight
1291
+ * rejection leaves no job id or execution resource. A throwing starter
1292
+ * leaves nothing registered; after it returns, registration cannot fail.
1293
+ * @param spec - job identity, owner, output sources, and synchronous starter.
1294
+ * @returns the registry-issued `<kind>-N` id.
1295
+ */
1296
+ abstract start(spec: JobSpec): JobId;
1297
+ /**
1298
+ * List caller-owned and unowned jobs in registration order.
1299
+ * @param caller - reading session; omission sees only unowned jobs.
1300
+ * @returns fresh projections.
1301
+ */
1302
+ abstract list(caller?: SessionId): JobView[];
1303
+ /**
1304
+ * Project one job without changing its cursor. Throws for an unknown or
1305
+ * foreign job.
1306
+ * @param id - job to look up.
1307
+ * @param caller - reading session checked against the owner.
1308
+ * @returns a fresh projection.
1309
+ */
1310
+ abstract get(id: JobId, caller?: SessionId): JobView;
1311
+ /**
1312
+ * Consume the ring from the model cursor and advance it to the current
1313
+ * total. After settlement the first read also carries the producer's
1314
+ * result. Throws for an unknown or foreign job.
1315
+ * @param id - job to read.
1316
+ * @param caller - reading session checked against the owner.
1317
+ * @returns the chunks since the cursor, the lossy flag, the result once, and the post-read projection.
1318
+ */
1319
+ abstract read(id: JobId, caller?: SessionId): JobRead;
1320
+ /**
1321
+ * Read retained ring output without moving the model cursor. Resume with
1322
+ * a previous read's `next`; an offset inside a retained chunk returns the
1323
+ * whole chunk (its `at` may precede `from`). Throws for a negative or
1324
+ * non-integer offset, or an unknown or foreign job.
1325
+ * @param id - job to read.
1326
+ * @param from - absolute byte offset to read from (0 for the retained head).
1327
+ * @param caller - reading session checked against the owner.
1328
+ * @returns retained chunks overlapping `[from, total)`, the resume offset, and the lossy flag.
1329
+ */
1330
+ abstract readAt(id: JobId, from: number, caller?: SessionId): JobOutputRead;
1331
+ /**
1332
+ * Request cancellation, then mark the job stopping. A producer throw
1333
+ * propagates without changing job state. A supplied reason is merged into
1334
+ * terminal `detail` when the job settles `killed`. Throws for an unknown
1335
+ * or foreign job.
1336
+ * @param id - job to cancel.
1337
+ * @param caller - killing session checked against the owner.
1338
+ * @param reason - cancellation reason forwarded verbatim to the producer.
1339
+ * @returns `requested` for live work, otherwise `already-finished`.
1340
+ */
1341
+ abstract kill(id: JobId, caller?: SessionId, reason?: string): 'requested' | 'already-finished';
1342
+ /**
1343
+ * Wait for settlement or timeout without cancelling the job. Caller abort
1344
+ * rejects only while the job is live; after settlement the terminal
1345
+ * projection wins. Rejects for an invalid timeout or an unknown or foreign
1346
+ * job.
1347
+ * @param id - job to wait for.
1348
+ * @param timeoutMs - positive finite wait bound in milliseconds.
1349
+ * @param caller - waiting session checked against the owner.
1350
+ * @param signal - optional cancellation of the wait itself.
1351
+ * @returns projection at settlement or timeout.
1352
+ */
1353
+ abstract wait(id: JobId, timeoutMs: number, caller?: SessionId, signal?: AbortSignal): Promise<JobView>;
1354
+ /**
1355
+ * Drop one settled job's record from the visible set and announce
1356
+ * `removed`. For a caller that collected the terminal state through its own
1357
+ * {@link wait} and never handed the id to the model, such as a shell tool's
1358
+ * foreground call. Throws for a job that is still live, unknown, or foreign.
1359
+ * @param id - settled job to drop.
1360
+ * @param caller - removing session checked against the owner.
1361
+ */
1362
+ abstract remove(id: JobId, caller?: SessionId): void;
1363
+ /**
1364
+ * Attach an effect-scoped controller that can read and stop jobs. It serves the
1365
+ * owners its registering context's scope covers, and {@link start} refuses an
1366
+ * owner no attached controller serves.
1367
+ * @param name - diagnostic label; duplicate names remain independent.
1368
+ * @returns disposer that detaches this controller.
1369
+ */
1370
+ abstract attachController(name: string): () => void;
1371
+ }
1372
+ //#endregion
1373
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/run-settlement.d.ts
1374
+ /**
1375
+ * Await the child result, dispose the run, then return its task outcome. Result
1376
+ * and disposal failures become `failed`; when both fail, both details survive.
1377
+ * @param run - live run to settle and release.
1378
+ * @returns outcome after child resources are released.
1379
+ */
1380
+ declare function settleRun(run: SubagentRun): Promise<JobOutcome>;
1381
+ //#endregion
1382
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/depth.d.ts
1383
+ declare module '@deepseek-ai/dsh-agent' {
1384
+ interface AgentOptions {
1385
+ /** Delegation depth: zero for a top-level agent and parent depth + 1 for a child. */
1386
+ subagentDepth?: number;
1387
+ }
1388
+ }
1389
+ /**
1390
+ * Read an agent's delegation depth, treating absence as top-level depth zero.
1391
+ * The persisted session header is authoritative and monotone: runtime
1392
+ * `AgentOptions.subagentDepth` may DEEPEN the count but can never lower it —
1393
+ * a resumed child arrives with fresh options, and counting it from zero would
1394
+ * let it delegate as if it were top-level.
1395
+ * @param agent - the agent whose header and options carry the depth.
1396
+ * @returns its non-negative safe-integer depth.
1397
+ * @throws if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
1398
+ */
1399
+ declare function delegationDepthOf(agent: Agent): number;
1400
+ /**
1401
+ * Reject a recursion cap that cannot represent an exact delegation depth.
1402
+ * @param maxDepth - the optional runtime value to validate.
1403
+ */
1404
+ declare function assertSubagentMaxDepth(maxDepth: unknown): void;
1405
+ //#endregion
1406
+ //#region ../../../vendor/deepseek-harness/packages/sandbox/sandbox/lib/types/index.d.ts
1407
+ /**
1408
+ * File-effect policy for confined processes. `read-only` permits only required
1409
+ * sinks such as `/dev/null`; `workspace-write` also permits the workspace and a
1410
+ * backend-defined temp area; `danger-full-access` bypasses confinement. Network
1411
+ * and process visibility are outside this vocabulary.
1412
+ */
1413
+ type SandboxMode = 'read-only' | 'workspace-write' | 'danger-full-access';
1414
+ /** A confining (non-`danger-full-access`) mode — the modes a {@link SandboxPolicy} can carry. */
1415
+ type ConfinedSandboxMode = Exclude<SandboxMode, 'danger-full-access'>;
1416
+ /**
1417
+ * The complete file-effect policy resolved for one capability call. The root
1418
+ * is carried even under modes that do not consume it so callers can resolve
1419
+ * policy once before choosing the enforcement path.
1420
+ */
1421
+ interface SandboxExecutionPolicy {
1422
+ /** The file-effect mode this execution runs under. */
1423
+ mode: SandboxMode;
1424
+ /** Absolute root directory `workspace-write` may write under. */
1425
+ workspaceRoot: string;
1426
+ /**
1427
+ * Opaque identity of the calling session (the branded `dsh-session`
1428
+ * SessionId). Backends key per-session state off it (e.g. windows-acl gives
1429
+ * each live session/workspace pair a random private temp directory and SID,
1430
+ * while the workspace SID and standing grant remain per-workspace); absent
1431
+ * for agentless calls, which fall back to per-call backend state.
1432
+ */
1433
+ sessionId?: SessionId;
1434
+ }
1435
+ /**
1436
+ * Enforcement completeness for this host. `partial` means an active backend or
1437
+ * older kernel ABI cannot govern every promised file effect; callers requiring
1438
+ * an absolute boundary must not treat it as `full`.
1439
+ */
1440
+ type SandboxEnforcement = 'full' | 'partial';
1441
+ /**
1442
+ * What one confined execution is allowed to touch — carried PER CALL, not
1443
+ * fixed on the provider: two consumers may confine under different policies
1444
+ * at the same instant (bash under `read-only` while a confined child agent
1445
+ * needs its state directory writable), and an approved escalated retry is a
1446
+ * new call with a wider policy. Defaulting/resolution is an explicit step at
1447
+ * the consumer boundary; the provider treats the policy as fully specified.
1448
+ */
1449
+ interface SandboxPolicy extends SandboxExecutionPolicy {
1450
+ /** The file-effect mode this execution runs under. */
1451
+ mode: ConfinedSandboxMode;
1452
+ }
1453
+ /**
1454
+ * Evidence that identifies a sandbox runner failing before it executes the
1455
+ * wrapped command. A consumer first applies {@link allowedExitCodes} when
1456
+ * present, removes {@link informationalLines} by case-insensitive exact line
1457
+ * equality, then matches {@link fatalSignatures} case-insensitively within
1458
+ * each remaining stderr line. Exit status alone never proves runner failure.
1459
+ */
1460
+ interface RunnerFailureRule {
1461
+ /** Nonzero process exit codes on which this rule may match; omitted permits any nonzero exit. */
1462
+ allowedExitCodes?: readonly number[];
1463
+ /** Non-empty substrings identifying a fatal runner diagnostic on one stderr line. */
1464
+ fatalSignatures: readonly string[];
1465
+ /** Benign stderr lines excluded by exact full-line equality before fatal matching. */
1466
+ informationalLines?: readonly string[];
1467
+ }
1468
+ /**
1469
+ * A {@link SandboxProvider.confine} result: the argv to spawn in place of
1470
+ * the caller's own, plus the enforcement completeness the selected backend
1471
+ * achieves for it.
1472
+ */
1473
+ interface ConfinedArgv {
1474
+ /** The wrapped argv (runner, profile, separator, then the caller's argv). */
1475
+ argv: string[];
1476
+ /** How completely the selected backend enforces the policy's file effects. */
1477
+ enforcement: SandboxEnforcement;
1478
+ /**
1479
+ * The selected backend's denial DIALECT: the case-insensitive stderr
1480
+ * substrings a file effect denied by THIS backend produces (EROFS text
1481
+ * under bwrap's read-only binds, EACCES under Landlock, EPERM under
1482
+ * Seatbelt). A consumer that infers denials from a failed run's stderr
1483
+ * matches against exactly these rather than a cross-backend union — the
1484
+ * union claims denials a given backend never produces.
1485
+ */
1486
+ denialSignatures: readonly string[];
1487
+ /**
1488
+ * Structured runner-failure evidence rules. Consumers require a matching
1489
+ * fatal stderr line (after informational exclusions) and any rule-specific
1490
+ * exit-code gate before checking denial signatures: runner failure means the
1491
+ * command never ran, while denial means confinement worked and blocked it.
1492
+ */
1493
+ runnerFailureRules: readonly RunnerFailureRule[];
1494
+ }
1495
+ declare module '@deepseek-ai/cordis' {
1496
+ interface Context {
1497
+ sandbox: SandboxProvider;
1498
+ }
1499
+ }
1500
+ /**
1501
+ * Abstract process-sandbox service. {@link confine} must return enforcing argv
1502
+ * or fail closed at wrap or runner-execution time; silent unconfined passthrough
1503
+ * is forbidden. Functional probes arbitrate multi-runner chains and may be
1504
+ * skipped for a sole candidate, whose own refusal remains the fail-closed end.
1505
+ */
1506
+ declare abstract class SandboxProvider extends Service {
1507
+ constructor(ctx: Context);
1508
+ /**
1509
+ * Wrap `argv` so it executes confined under `policy` on this host; the
1510
+ * caller spawns the returned argv in place of its own.
1511
+ * @param argv - the exact argv the caller is about to spawn (program plus
1512
+ * arguments), NOT a shell string — a shell-shaped consumer passes
1513
+ * `['bash', '-c', command]`.
1514
+ * @param policy - the file-effect policy this execution runs under,
1515
+ * carried per call (see {@link SandboxPolicy}).
1516
+ * @param signal - cancellation while the provider resolves the policy and runner.
1517
+ * @returns the argv to spawn instead, plus the enforcement completeness
1518
+ * the selected backend achieves for it.
1519
+ */
1520
+ abstract confine(argv: readonly string[], policy: SandboxPolicy, signal?: AbortSignal): Promise<ConfinedArgv>;
1521
+ }
1522
+ //#endregion
1523
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/child-agent.d.ts
1524
+ /** Thrown when starting a child would exceed the requested depth cap. */
1525
+ declare class SubagentDepthError extends Error {
1526
+ readonly attemptedDepth: number;
1527
+ readonly maxDepth: number;
1528
+ constructor(attemptedDepth: number, maxDepth: number);
1529
+ }
1530
+ /**
1531
+ * Resolve the child's delegation depth from its parent and enforce an optional
1532
+ * cap. The persisted parent header is the monotone floor, so a resumed parent
1533
+ * cannot delegate as if it were top-level.
1534
+ * @param parent - the delegating parent agent.
1535
+ * @param maxDepth - optional absolute cap the resolved depth must not exceed.
1536
+ * @returns the child's non-negative safe-integer depth.
1537
+ * @throws {SubagentDepthError} when the resolved depth exceeds `maxDepth`.
1538
+ * @throws {RangeError} when the resolved depth leaves the safe-integer range.
1539
+ */
1540
+ declare function resolveChildDepth(parent: Agent, maxDepth: number | undefined): number;
1541
+ /**
1542
+ * Resolve the parent values inherited by a child. The latest request header
1543
+ * owns provider, model, and reasoning effort after request-time selection;
1544
+ * creation options remain the fallback before the first request and retain
1545
+ * the configured output-token limit.
1546
+ * @param parent - delegating parent Agent.
1547
+ * @returns detached Agent options for child-option merging.
1548
+ */
1549
+ declare function parentAgentOptionsForDelegation(parent: Agent): AgentOptions;
1550
+ /**
1551
+ * Resolve the child's `AgentOptions`: the parent's provider/model,
1552
+ * reasoning-effort, and maxTokens values unless the request overrides them,
1553
+ * stamped with the child's own delegation depth. Changing the route without
1554
+ * naming an effort clears the parent's route-owned effort so the selected
1555
+ * model resolves its own default.
1556
+ * @param parent - the delegating parent whose route the child inherits.
1557
+ * @param requested - per-child overrides, if any.
1558
+ * @param childDepth - the resolved delegation depth to stamp.
1559
+ * @returns the resolved options for `ctx.agents.create()`.
1560
+ */
1561
+ declare function resolveChildAgentOptions(parent: Agent, requested: AgentOptions | undefined, childDepth: number): AgentOptions;
1562
+ /**
1563
+ * Build the child session's durable creation metadata: the parent's workspace,
1564
+ * its direct lineage, coarse product origin, the recursion budget that must
1565
+ * survive persistence, the seed boundary that separates inherited parent
1566
+ * history from child work, and the composition the child runs under.
1567
+ *
1568
+ * The preset is read from the parent's LIVE scope chain rather than from its
1569
+ * header, because a parent that switched preset while blank runs on the newer
1570
+ * composition and its header still names the older one. Recording it is what
1571
+ * makes a child's history reconstructable: without it a cold read of the child
1572
+ * resolves the deployment default and rebuilds turns under a tool set the
1573
+ * child never had.
1574
+ * @param parent - the delegating parent agent.
1575
+ * @param childDepth - the resolved delegation depth to persist.
1576
+ * @param isSeeded - whether this child inherits a parent-log prefix, including an explicitly empty one.
1577
+ * @returns the `meta` for `ctx.agents.create()`.
1578
+ */
1579
+ declare function childSessionMeta(parent: Agent, childDepth: number, isSeeded: boolean): NonNullable<CreateAgentOptions['meta']>;
1580
+ /** The scoped composition a child agent's creation window applies. */
1581
+ interface ChildComposition {
1582
+ /** Per-child persona shadowing the deployment persona. */
1583
+ readonly persona?: string | undefined;
1584
+ /** Per-child tool scoping. */
1585
+ readonly toolFilter?: ToolRestriction | undefined;
1586
+ }
1587
+ /**
1588
+ * Compose one child inside its creation window: join its parent's preset,
1589
+ * register the fixed delegation-scope statement, then apply the child's own
1590
+ * shadowing persona section and tool restriction, all owned by the child's
1591
+ * scope and therefore invisible to its parent and siblings. Creation and cold
1592
+ * resume both pass through here.
1593
+ *
1594
+ * The join comes first and the child's own registrations second, which is the
1595
+ * order the layering already implies — the nearest scope wins a name, and a
1596
+ * per-child restriction intersects with everything its chain admits — but
1597
+ * stating it here keeps the two steps from being read as independent.
1598
+ *
1599
+ * The join and the per-child registrations live in ONE call because a child
1600
+ * composed without the join is exactly the defect this function exists to
1601
+ * prevent: with every model-facing row on the agent plane, a child that joins
1602
+ * no preset sees an empty tool registry and none of its parent's prompt
1603
+ * sections. Taking the parent as a parameter is what makes that omission
1604
+ * unrepresentable at the call sites.
1605
+ * @param childCtx - the child agent's scoped creation context.
1606
+ * @param parent - the delegating parent whose composition the child joins.
1607
+ * @param composition - the per-child persona and tool filter to install.
1608
+ */
1609
+ declare function applyChildComposition(childCtx: Context, parent: Agent, composition: ChildComposition): void;
1610
+ /** Policy seeded onto a child session's log at the delegation boundary. */
1611
+ interface DelegatedPolicyOverrides {
1612
+ /** The shared-bundle preset identity when the parent currently runs in Auto or Full access. */
1613
+ readonly permissionPreset: 'auto' | 'danger-full-access' | undefined;
1614
+ /** The parent session's explicit sandbox-mode override, or `undefined` without one. */
1615
+ readonly sandboxMode: SandboxMode | undefined;
1616
+ /**
1617
+ * `'never'` whenever the approval capability is composed, `undefined`
1618
+ * otherwise: a delegated child acts only within the sandbox scope fixed at
1619
+ * delegation, so its asks are rejected deterministically.
1620
+ */
1621
+ readonly approvalPolicy: 'never' | undefined;
1622
+ }
1623
+ /**
1624
+ * Capture the permission state to seed into one delegation. Call synchronously before
1625
+ * the child start's first await: a later parent switch belongs to the
1626
+ * parent's future, not to this child. Auto and Full access identities are
1627
+ * inherited only through the in-process DSH path so either can replace a stale
1628
+ * same-bundle fork value. Only the parent session's explicit sandbox override
1629
+ * is captured — never deployment defaults or one-shot grants — and the approval
1630
+ * policy is pinned to `'never'` regardless of the parent's own policy.
1631
+ * @param parent - the delegating parent agent.
1632
+ * @returns the sandbox override (or `undefined` without one) and the approval pin.
1633
+ */
1634
+ declare function captureDelegatedPolicyOverrides(parent: Agent): DelegatedPolicyOverrides;
1635
+ /**
1636
+ * Append the captured delegation policy onto the child's own log as
1637
+ * `source: 'delegation'` events inside the unpublished creation window, so the
1638
+ * child's effective policy is reconstructable from its log alone. Appends land
1639
+ * after any fork seed, so fresh policy wins stale seed state; later child
1640
+ * switches still win over these events.
1641
+ * @param childSession - the unpublished child's session.
1642
+ * @param overrides - the policy captured at delegation.
1643
+ */
1644
+ declare function appendDelegatedPolicyOverrides(childSession: Session, overrides: DelegatedPolicyOverrides): void;
1645
+ //#endregion
1646
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/continuation-messages.d.ts
1647
+ /** Durable attribution for one model-authored message between adjacent Agents. */
1648
+ interface AgentMessageSource$1 {
1649
+ readonly kind: 'agent-message';
1650
+ /** A message another agent addressed to this one (`relay` context form). */
1651
+ readonly form: 'relay';
1652
+ /** Session id of the Agent whose tool call produced the message. */
1653
+ readonly senderSessionId: SessionId;
1654
+ }
1655
+ /**
1656
+ * Durable attribution for the runtime's own account of a continuable child
1657
+ * settling. Deliberately a different kind from
1658
+ * {@link AgentMessageSource}: an Agent message is content the sender chose,
1659
+ * while this message is the manager stating what became of the child, and a
1660
+ * transcript that merged them would credit the child with words it never wrote.
1661
+ */
1662
+ interface SubagentSettledMessageSource$1 {
1663
+ readonly kind: 'subagent-settled';
1664
+ /** A runtime account shown without expanding the row (`notice` context form). */
1665
+ readonly form: 'notice';
1666
+ /** One-line account of how the child ended. */
1667
+ readonly summary: string;
1668
+ /** Session id of the child that settled. */
1669
+ readonly senderSessionId: SessionId;
1670
+ }
1671
+ declare module '@deepseek-ai/dsh-llm' {
1672
+ interface MessageSourceMap {
1673
+ 'agent-message': AgentMessageSource$1;
1674
+ 'subagent-settled': SubagentSettledMessageSource$1;
1675
+ }
1676
+ }
1677
+ //#endregion
1678
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/index.d.ts
1679
+ declare module '@deepseek-ai/cordis' {
1680
+ interface Context {
1681
+ subagents: SubagentRuntime$1;
1682
+ }
1683
+ interface Events {
1684
+ /**
1685
+ * A provider became resolvable in the registry.
1686
+ * @param provider - the registered provider.
1687
+ * @mode emit
1688
+ */
1689
+ 'subagent/provider-added'(provider: SubagentProvider): void;
1690
+ /**
1691
+ * A provider left the registry. Accepted runs remain holder-owned.
1692
+ * @param name - the provider name that no longer resolves.
1693
+ * @mode emit
1694
+ */
1695
+ 'subagent/provider-removed'(name: string): void;
1696
+ /**
1697
+ * A provider established a published child. For in-process providers,
1698
+ * `ctx.agents.get(info.id)` resolves during this notification.
1699
+ * Scope-filtered dispatch keys the carrier by the delegating parent, so a
1700
+ * parent-scoped listener observes only its own delegations. Paired with
1701
+ * `subagent/end`.
1702
+ * @param info - the provider and published child identity.
1703
+ * @dshScopeScan unsupported
1704
+ * @mode emit
1705
+ */
1706
+ 'subagent/start'(this: Scoped<SubagentRuntime$1>, info: SubagentRunInfo): void;
1707
+ /**
1708
+ * A published child settled. Scope-filtered dispatch uses the same delegating
1709
+ * parent carrier as `subagent/start`, so the lifecycle pair reaches the
1710
+ * same scoped audience.
1711
+ * @param info - the run identity and terminal outcome.
1712
+ * @dshScopeScan unsupported
1713
+ * @mode emit
1714
+ */
1715
+ 'subagent/end'(this: Scoped<SubagentRuntime$1>, info: SubagentRunEndInfo): void;
1716
+ }
1717
+ }
1718
+ /** Host configuration for continuable subagent capacity. */
1719
+ interface Config$1 {
1720
+ /** Maximum live children sharing uninterrupted continuable parent links; defaults to 8. */
1721
+ maxActiveSubagents: Volatile<number>;
1722
+ /** Default delegation depth for tools without an explicit limit; defaults to 1. */
1723
+ maxDepth: Volatile<number>;
1724
+ }
1725
+ /** Named provider registry with one-shot runs, durable discovery, and continuable-child operations. */
1726
+ declare class SubagentRuntime$1 extends TypertRemoteService {
1727
+ private config;
1728
+ static Config: z<Schemastery.ObjectS<NoInfer<{
1729
+ maxDepth: z<number, number, "volatile-defined">;
1730
+ maxActiveSubagents: z<number, number, "volatile-defined">;
1731
+ }>>, Schemastery.ObjectT<NoInfer<{
1732
+ maxDepth: z<number, number, "volatile-defined">;
1733
+ maxActiveSubagents: z<number, number, "volatile-defined">;
1734
+ }>>, "plain">;
1735
+ private providers;
1736
+ private continuations;
1737
+ /**
1738
+ * The contained lifecycle-edge publisher. Built here because scoped dispatch
1739
+ * keys its carrier by this exact service instance, whose own context filter
1740
+ * composes into the carrier.
1741
+ */
1742
+ private readonly emitLifecycle;
1743
+ constructor(ctx: Context, config: Config$1);
1744
+ /**
1745
+ * Resolve a delegation tool's depth policy against the current user setting.
1746
+ * @param configured - Explicit tool limit, or provider-managed for external delegation.
1747
+ * @returns The numeric limit, or undefined when the provider owns depth enforcement.
1748
+ */
1749
+ resolveMaxDepth(configured?: number | 'provider-managed'): number | undefined;
1750
+ /**
1751
+ * Establish one durable continuable child and deliver its initial prompt.
1752
+ * Resolves when the child's inbox accepts that prompt, without waiting for the
1753
+ * turn to start or for the message to reach the Session log; any earlier
1754
+ * failure rejects with no ids and rolls back the child entirely.
1755
+ * @param spec - provider, delegation request, and caller cancellation.
1756
+ * @returns the durable child id and the accepted prompt's message id.
1757
+ * @throws when continuation services are unavailable or materialization fails.
1758
+ */
1759
+ startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
1760
+ /**
1761
+ * Steer one model-authored message to the sender's direct parent or direct
1762
+ * continuable child. A running target admits it at the nearest step boundary;
1763
+ * an idle target starts a turn, and an absent direct child cold-resumes from
1764
+ * persistence. The service derives durable sender attribution from the exact
1765
+ * live sender. Caller cancellation stops only pre-acceptance work.
1766
+ * @param sender - exact live Agent authorizing and originating the message.
1767
+ * @param targetId - durable direct-parent or direct-child session id.
1768
+ * @param content - model-authored content to deliver.
1769
+ * @param options - caller cancellation before inbox acceptance.
1770
+ * @returns the accepted message's inbox id.
1771
+ * @throws when continuation services are unavailable, adjacency is rejected,
1772
+ * or the message was not admitted.
1773
+ */
1774
+ sendMessage(sender: Agent, targetId: SessionId, content: ContentBlock[], options: SubagentSendMessageOptions): Promise<MessageId>;
1775
+ /**
1776
+ * Deliver one host-protocol message to a direct continuable child.
1777
+ * Symbol-keyed so host adapters can preserve their own source descriptors without
1778
+ * widening the public Service Definition or impersonating an Agent sender.
1779
+ * @param parent - exact live direct parent authorizing delivery.
1780
+ * @param childId - durable direct-child session id.
1781
+ * @param content - host-authored content to deliver.
1782
+ * @param source - durable host-protocol source descriptor.
1783
+ * @param signal - caller cancellation before inbox acceptance.
1784
+ * @param delivery - Queue as a distinct turn or Steer at the nearest step.
1785
+ * @returns the accepted message's inbox id.
1786
+ */
1787
+ private [deliverSubagentPrompt];
1788
+ /**
1789
+ * Interrupt one live continuable child's current turn under a human parent
1790
+ * address or an exact live ancestor Agent. Fire-and-return: the cancel
1791
+ * signal is issued before this returns, but the target may keep running
1792
+ * until it observes the signal. Unclaimed pending inbox work, the Activation,
1793
+ * and published descendants are preserved; claimed work is not requeued.
1794
+ * Once the interrupted driver is idle, a waking send resumes the parked FIFO
1795
+ * queue. An absent target — including a one-shot or unknown id —
1796
+ * is an accepted no-op, as is a manager-less composition, which cannot own a
1797
+ * live Activation.
1798
+ * @param targetSessionId - the durable child session id to interrupt.
1799
+ * @param authority - the human parent address or exact live ancestor Agent.
1800
+ * @throws {SubagentError} `UNAUTHORIZED` when the authority does not own the
1801
+ * live target.
1802
+ */
1803
+ interrupt(targetSessionId: SessionId, authority: SubagentInterruptAuthority): void;
1804
+ /**
1805
+ * Close continuable admission below exact live parent Agents, stop only their
1806
+ * visible descendant Activations synchronously, then await admitted scoped
1807
+ * materializations and release those forests child-first. The scoped cutoff
1808
+ * lasts until each exact parent leaves the registry; unrelated parent trees
1809
+ * remain live.
1810
+ * @param parents - exact host-owned parent Agents entering teardown.
1811
+ * @returns once every retained descendant Activation released its `AgentHandle`.
1812
+ * @throws an aggregate error after all branches settle when any failed.
1813
+ */
1814
+ drainContinuableDescendants(parents: readonly Agent[]): Promise<void>;
1815
+ /**
1816
+ * Release selected resident continuable direct children of one exact live
1817
+ * parent. Other children of the same parent remain admitted and resident.
1818
+ * Absent targets and a manager-less composition are accepted no-ops.
1819
+ * @param parent - exact live direct parent authorizing the selected release.
1820
+ * @param childIds - durable direct-child ids to release when resident.
1821
+ * @returns once every selected Activation released its `AgentHandle`.
1822
+ * @throws {SubagentError} `UNAUTHORIZED` when a resident target belongs to a
1823
+ * different parent or the supplied parent identity is stale.
1824
+ */
1825
+ drainContinuableChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
1826
+ /**
1827
+ * Read the parent's durable direct-child catalog without loading or resuming an Agent.
1828
+ * The service owns and releases the live-preferred Session observation.
1829
+ * @param parentSessionId - parent whose direct children are requested.
1830
+ * @param signal - cancellation forwarded to the Session query.
1831
+ * @returns catalog children in parent event order.
1832
+ * @throws {@link SubagentError} when query or catalog projection is unavailable.
1833
+ * @throws SessionQueryError when the parent cannot be read or the query is cancelled.
1834
+ */
1835
+ listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentCatalogEntry[]>;
1836
+ /**
1837
+ * Enumerate the root's complete session-backed subagent tree in stable
1838
+ * pre-order from one live-preferred corpus, without loading or resuming an
1839
+ * Agent. Ordinary sessions and one-shot children remain traversal nodes so
1840
+ * continuable descendants below them are discovered; each returned entry
1841
+ * adds its durable `parentId` and root-relative `depth`. Identity resolution,
1842
+ * diagnostics, optional persistence, and cancellation use the registered
1843
+ * child identity projection and complete Session corpus.
1844
+ * @param rootSessionId - session whose complete descendant tree is listed.
1845
+ * @param signal - caller-owned cancellation forwarded to persistence reads
1846
+ * and observed around every read await.
1847
+ * @returns children and per-candidate diagnostics with tree position, in
1848
+ * stable pre-order.
1849
+ * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.
1850
+ */
1851
+ listDescendants(rootSessionId: SessionId, signal?: AbortSignal): Promise<SubagentDescendantListEntry[]>;
1852
+ /**
1853
+ * Deliver one browser-authored message to a continuable child through the
1854
+ * exact live direct parent, retaining the caller-minted request identity and
1855
+ * validated browser zone on the accepted message. Success identifies the
1856
+ * message the child's inbox accepted; later execution is independent of this
1857
+ * call. Queue delivery targets a later turn; steer delivery targets the
1858
+ * nearest step and retains the Agent loop's best-effort fallback semantics.
1859
+ * Image parts are admitted and persisted through the attachment store
1860
+ * before delivery, and the child's model must accept image input.
1861
+ * Cold resume at capacity rejects with `subagent/delivery-unavailable`.
1862
+ * @param request - durable address, delivery, minted identity, content, and optional browser zone.
1863
+ * @param signal - carrier cancellation, owning the call until inbox acceptance.
1864
+ * @returns the accepted message's inbox identity.
1865
+ * @throws {RemoteError} `gateway/bad-request`, `subagent/attachment-invalid`,
1866
+ * `subagent/invalid-time-zone`, `subagent/parent-unavailable`,
1867
+ * `subagent/not-resumable`, `subagent/unauthorized`,
1868
+ * `subagent/delivery-unavailable`, `gateway/cancelled`, or `gateway/internal`.
1869
+ */
1870
+ prompt(request: SubagentPromptRequest, signal: AbortSignal): Promise<SubagentPromptReceipt>;
1871
+ /**
1872
+ * Remote face of {@link interrupt} under one durable parent address. No
1873
+ * catalog, history, persistence, or parent Agent lookup runs: the core
1874
+ * primitive alone authorizes the address against the live Activation, which
1875
+ * is what keeps a live child interruptible while its parent Agent is offline.
1876
+ * Absent, idle, and already-completed targets are accepted no-ops there.
1877
+ * @param childSessionId - durable child session id to interrupt.
1878
+ * @param parentSessionId - durable direct parent whose authority is claimed.
1879
+ * @param mode - required continuable-address discriminator.
1880
+ * @returns acknowledgement that the cancel signal was admitted, not that the target is quiescent.
1881
+ * @throws {RemoteError} `gateway/bad-request` for an empty id,
1882
+ * `subagent/unauthorized` when the address does not own the live target,
1883
+ * otherwise `gateway/internal`.
1884
+ */
1885
+ interruptByParent(childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable'): SubagentInterruptReceipt;
1886
+ /**
1887
+ * Register a provider under its name. Registration is effect-scoped and HMR
1888
+ * safe; removing a provider blocks new starts but does not revoke runs that
1889
+ * were already returned to their holders.
1890
+ * @param provider - the trusted provider implementation.
1891
+ * @returns the exact Cordis effect disposer.
1892
+ */
1893
+ registerProvider(provider: SubagentProvider): () => void;
1894
+ /**
1895
+ * Look up a provider by name.
1896
+ * @param name - the provider name.
1897
+ * @returns the provider, or undefined when absent.
1898
+ */
1899
+ getProvider(name: string): SubagentProvider | undefined;
1900
+ /**
1901
+ * List registered provider names in insertion order.
1902
+ * @returns the registered names.
1903
+ */
1904
+ list(): string[];
1905
+ /**
1906
+ * Establish a published child on the named provider. Capability and semantic
1907
+ * checks run before delegation. Provider ownership lasts until its promise
1908
+ * fulfills; a rejection therefore has no run for the caller to dispose and
1909
+ * emits no run lifecycle events. Post-publication turn and infrastructure
1910
+ * failures settle through the returned run.
1911
+ * A catalog append failure disposes the run and handles its result rejection;
1912
+ * the caller receives the catalog error even if disposal also fails.
1913
+ * @param name - the provider to use.
1914
+ * @param request - child label, prompt, parent, signal, and optional capabilities.
1915
+ * @returns the published holder-owned run.
1916
+ */
1917
+ start(name: string, request: SubagentStartRequest): Promise<SubagentRun>;
1918
+ /**
1919
+ * Resolve one provider's detached continuable-creation contribution. Method
1920
+ * presence on the provider IS the capability, so a provider without it is
1921
+ * rejected before the manager reserves any child resources.
1922
+ */
1923
+ private prepareContinuable;
1924
+ /** Look up a provider for dispatch or fail loud. */
1925
+ private expectProvider;
1926
+ /** Resolve the optional continuable-subagent manager or fail loud. */
1927
+ private requireContinuations;
1928
+ /**
1929
+ * Build the lifecycle observer for one continuable Activation's residency
1930
+ * epoch, so the manager publishes its edges without owning event dispatch.
1931
+ */
1932
+ private observeActivation;
1933
+ /** Reject the first requested capability that the provider lacks. */
1934
+ private assertCapabilities;
1935
+ }
1936
+ //#endregion
1937
+ //#region ../../../vendor/deepseek-harness/packages/subagent/subagent/src/internal.d.ts
1938
+ /**
1939
+ * Process-stable symbol-keyed host delivery shared by the bundled runtime
1940
+ * entry and this unbundled internal subpath.
1941
+ * @internal
1942
+ */
1943
+ declare const deliverSubagentPrompt: unique symbol;
1944
+ //#endregion
1945
+ //#region src/continuation-messages.d.ts
1946
+ /** Durable attribution for one model-authored message between adjacent Agents. */
1947
+ interface AgentMessageSource {
1948
+ readonly kind: 'agent-message';
1949
+ /** A message another agent addressed to this one (`relay` context form). */
1950
+ readonly form: 'relay';
1951
+ /** Session id of the Agent whose tool call produced the message. */
1952
+ readonly senderSessionId: SessionId;
1953
+ }
1954
+ /**
1955
+ * Durable attribution for the runtime's own account of a continuable child
1956
+ * settling. Deliberately a different kind from
1957
+ * {@link AgentMessageSource}: an Agent message is content the sender chose,
1958
+ * while this message is the manager stating what became of the child, and a
1959
+ * transcript that merged them would credit the child with words it never wrote.
1960
+ */
1961
+ interface SubagentSettledMessageSource {
1962
+ readonly kind: 'subagent-settled';
1963
+ /** A runtime account shown without expanding the row (`notice` context form). */
1964
+ readonly form: 'notice';
1965
+ /** One-line account of how the child ended. */
1966
+ readonly summary: string;
1967
+ /** Session id of the child that settled. */
1968
+ readonly senderSessionId: SessionId;
1969
+ }
1970
+ declare module '@deepseek-ai/dsh-llm' {
1971
+ interface MessageSourceMap {
1972
+ 'agent-message': AgentMessageSource;
1973
+ 'subagent-settled': SubagentSettledMessageSource;
1974
+ }
1975
+ }
1976
+ //#endregion
1977
+ //#region src/index.d.ts
1978
+ /** Host configuration for continuable subagent capacity. */
1979
+ interface Config {
1980
+ /** Maximum live children sharing uninterrupted continuable parent links; defaults to 8. */
1981
+ maxActiveSubagents: Volatile<number>;
1982
+ /** Default delegation depth for tools without an explicit limit; defaults to 1. */
1983
+ maxDepth: Volatile<number>;
1984
+ }
1985
+ /** Named provider registry with one-shot runs, durable discovery, and continuable-child operations. */
1986
+ declare class SubagentRuntime extends TypertRemoteService {
1987
+ private config;
1988
+ static Config: z<Schemastery.ObjectS<NoInfer<{
1989
+ maxDepth: z<number, number, "volatile-defined">;
1990
+ maxActiveSubagents: z<number, number, "volatile-defined">;
1991
+ }>>, Schemastery.ObjectT<NoInfer<{
1992
+ maxDepth: z<number, number, "volatile-defined">;
1993
+ maxActiveSubagents: z<number, number, "volatile-defined">;
1994
+ }>>, "plain">;
1995
+ private providers;
1996
+ private continuations;
1997
+ /**
1998
+ * The contained lifecycle-edge publisher. Built here because scoped dispatch
1999
+ * keys its carrier by this exact service instance, whose own context filter
2000
+ * composes into the carrier.
2001
+ */
2002
+ private readonly emitLifecycle;
2003
+ constructor(ctx: Context, config: Config);
2004
+ /**
2005
+ * Resolve a delegation tool's depth policy against the current user setting.
2006
+ * @param configured - Explicit tool limit, or provider-managed for external delegation.
2007
+ * @returns The numeric limit, or undefined when the provider owns depth enforcement.
2008
+ */
2009
+ resolveMaxDepth(configured?: number | 'provider-managed'): number | undefined;
2010
+ /**
2011
+ * Establish one durable continuable child and deliver its initial prompt.
2012
+ * Resolves when the child's inbox accepts that prompt, without waiting for the
2013
+ * turn to start or for the message to reach the Session log; any earlier
2014
+ * failure rejects with no ids and rolls back the child entirely.
2015
+ * @param spec - provider, delegation request, and caller cancellation.
2016
+ * @returns the durable child id and the accepted prompt's message id.
2017
+ * @throws when continuation services are unavailable or materialization fails.
2018
+ */
2019
+ startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
2020
+ /**
2021
+ * Steer one model-authored message to the sender's direct parent or direct
2022
+ * continuable child. A running target admits it at the nearest step boundary;
2023
+ * an idle target starts a turn, and an absent direct child cold-resumes from
2024
+ * persistence. The service derives durable sender attribution from the exact
2025
+ * live sender. Caller cancellation stops only pre-acceptance work.
2026
+ * @param sender - exact live Agent authorizing and originating the message.
2027
+ * @param targetId - durable direct-parent or direct-child session id.
2028
+ * @param content - model-authored content to deliver.
2029
+ * @param options - caller cancellation before inbox acceptance.
2030
+ * @returns the accepted message's inbox id.
2031
+ * @throws when continuation services are unavailable, adjacency is rejected,
2032
+ * or the message was not admitted.
2033
+ */
2034
+ sendMessage(sender: Agent, targetId: SessionId, content: ContentBlock[], options: SubagentSendMessageOptions): Promise<MessageId>;
2035
+ /**
2036
+ * Deliver one host-protocol message to a direct continuable child.
2037
+ * Symbol-keyed so host adapters can preserve their own source descriptors without
2038
+ * widening the public Service Definition or impersonating an Agent sender.
2039
+ * @param parent - exact live direct parent authorizing delivery.
2040
+ * @param childId - durable direct-child session id.
2041
+ * @param content - host-authored content to deliver.
2042
+ * @param source - durable host-protocol source descriptor.
2043
+ * @param signal - caller cancellation before inbox acceptance.
2044
+ * @param delivery - Queue as a distinct turn or Steer at the nearest step.
2045
+ * @returns the accepted message's inbox id.
2046
+ */
2047
+ private [deliverSubagentPrompt];
2048
+ /**
2049
+ * Interrupt one live continuable child's current turn under a human parent
2050
+ * address or an exact live ancestor Agent. Fire-and-return: the cancel
2051
+ * signal is issued before this returns, but the target may keep running
2052
+ * until it observes the signal. Unclaimed pending inbox work, the Activation,
2053
+ * and published descendants are preserved; claimed work is not requeued.
2054
+ * Once the interrupted driver is idle, a waking send resumes the parked FIFO
2055
+ * queue. An absent target — including a one-shot or unknown id —
2056
+ * is an accepted no-op, as is a manager-less composition, which cannot own a
2057
+ * live Activation.
2058
+ * @param targetSessionId - the durable child session id to interrupt.
2059
+ * @param authority - the human parent address or exact live ancestor Agent.
2060
+ * @throws {SubagentError} `UNAUTHORIZED` when the authority does not own the
2061
+ * live target.
2062
+ */
2063
+ interrupt(targetSessionId: SessionId, authority: SubagentInterruptAuthority): void;
2064
+ /**
2065
+ * Close continuable admission below exact live parent Agents, stop only their
2066
+ * visible descendant Activations synchronously, then await admitted scoped
2067
+ * materializations and release those forests child-first. The scoped cutoff
2068
+ * lasts until each exact parent leaves the registry; unrelated parent trees
2069
+ * remain live.
2070
+ * @param parents - exact host-owned parent Agents entering teardown.
2071
+ * @returns once every retained descendant Activation released its `AgentHandle`.
2072
+ * @throws an aggregate error after all branches settle when any failed.
2073
+ */
2074
+ drainContinuableDescendants(parents: readonly Agent[]): Promise<void>;
2075
+ /**
2076
+ * Release selected resident continuable direct children of one exact live
2077
+ * parent. Other children of the same parent remain admitted and resident.
2078
+ * Absent targets and a manager-less composition are accepted no-ops.
2079
+ * @param parent - exact live direct parent authorizing the selected release.
2080
+ * @param childIds - durable direct-child ids to release when resident.
2081
+ * @returns once every selected Activation released its `AgentHandle`.
2082
+ * @throws {SubagentError} `UNAUTHORIZED` when a resident target belongs to a
2083
+ * different parent or the supplied parent identity is stale.
2084
+ */
2085
+ drainContinuableChildren(parent: Agent, childIds: readonly SessionId[]): Promise<void>;
2086
+ /**
2087
+ * Read the parent's durable direct-child catalog without loading or resuming an Agent.
2088
+ * The service owns and releases the live-preferred Session observation.
2089
+ * @param parentSessionId - parent whose direct children are requested.
2090
+ * @param signal - cancellation forwarded to the Session query.
2091
+ * @returns catalog children in parent event order.
2092
+ * @throws {@link SubagentError} when query or catalog projection is unavailable.
2093
+ * @throws SessionQueryError when the parent cannot be read or the query is cancelled.
2094
+ */
2095
+ listChildren(parentSessionId: SessionId, signal?: AbortSignal): Promise<SubagentCatalogEntry[]>;
2096
+ /**
2097
+ * Enumerate the root's complete session-backed subagent tree in stable
2098
+ * pre-order from one live-preferred corpus, without loading or resuming an
2099
+ * Agent. Ordinary sessions and one-shot children remain traversal nodes so
2100
+ * continuable descendants below them are discovered; each returned entry
2101
+ * adds its durable `parentId` and root-relative `depth`. Identity resolution,
2102
+ * diagnostics, optional persistence, and cancellation use the registered
2103
+ * child identity projection and complete Session corpus.
2104
+ * @param rootSessionId - session whose complete descendant tree is listed.
2105
+ * @param signal - caller-owned cancellation forwarded to persistence reads
2106
+ * and observed around every read await.
2107
+ * @returns children and per-candidate diagnostics with tree position, in
2108
+ * stable pre-order.
2109
+ * @throws {@link SubagentError} when listing dependencies are unavailable or the caller cancels.
2110
+ */
2111
+ listDescendants(rootSessionId: SessionId, signal?: AbortSignal): Promise<SubagentDescendantListEntry[]>;
2112
+ /**
2113
+ * Deliver one browser-authored message to a continuable child through the
2114
+ * exact live direct parent, retaining the caller-minted request identity and
2115
+ * validated browser zone on the accepted message. Success identifies the
2116
+ * message the child's inbox accepted; later execution is independent of this
2117
+ * call. Queue delivery targets a later turn; steer delivery targets the
2118
+ * nearest step and retains the Agent loop's best-effort fallback semantics.
2119
+ * Image parts are admitted and persisted through the attachment store
2120
+ * before delivery, and the child's model must accept image input.
2121
+ * Cold resume at capacity rejects with `subagent/delivery-unavailable`.
2122
+ * @param request - durable address, delivery, minted identity, content, and optional browser zone.
2123
+ * @param signal - carrier cancellation, owning the call until inbox acceptance.
2124
+ * @returns the accepted message's inbox identity.
2125
+ * @throws {RemoteError} `gateway/bad-request`, `subagent/attachment-invalid`,
2126
+ * `subagent/invalid-time-zone`, `subagent/parent-unavailable`,
2127
+ * `subagent/not-resumable`, `subagent/unauthorized`,
2128
+ * `subagent/delivery-unavailable`, `gateway/cancelled`, or `gateway/internal`.
2129
+ */
2130
+ prompt(request: SubagentPromptRequest, signal: AbortSignal): Promise<SubagentPromptReceipt>;
2131
+ /**
2132
+ * Remote face of {@link interrupt} under one durable parent address. No
2133
+ * catalog, history, persistence, or parent Agent lookup runs: the core
2134
+ * primitive alone authorizes the address against the live Activation, which
2135
+ * is what keeps a live child interruptible while its parent Agent is offline.
2136
+ * Absent, idle, and already-completed targets are accepted no-ops there.
2137
+ * @param childSessionId - durable child session id to interrupt.
2138
+ * @param parentSessionId - durable direct parent whose authority is claimed.
2139
+ * @param mode - required continuable-address discriminator.
2140
+ * @returns acknowledgement that the cancel signal was admitted, not that the target is quiescent.
2141
+ * @throws {RemoteError} `gateway/bad-request` for an empty id,
2142
+ * `subagent/unauthorized` when the address does not own the live target,
2143
+ * otherwise `gateway/internal`.
2144
+ */
2145
+ interruptByParent(childSessionId: SessionId, parentSessionId: SessionId, mode: 'continuable'): SubagentInterruptReceipt;
2146
+ /**
2147
+ * Register a provider under its name. Registration is effect-scoped and HMR
2148
+ * safe; removing a provider blocks new starts but does not revoke runs that
2149
+ * were already returned to their holders.
2150
+ * @param provider - the trusted provider implementation.
2151
+ * @returns the exact Cordis effect disposer.
2152
+ */
2153
+ registerProvider(provider: SubagentProvider): () => void;
2154
+ /**
2155
+ * Look up a provider by name.
2156
+ * @param name - the provider name.
2157
+ * @returns the provider, or undefined when absent.
2158
+ */
2159
+ getProvider(name: string): SubagentProvider | undefined;
2160
+ /**
2161
+ * List registered provider names in insertion order.
2162
+ * @returns the registered names.
2163
+ */
2164
+ list(): string[];
2165
+ /**
2166
+ * Establish a published child on the named provider. Capability and semantic
2167
+ * checks run before delegation. Provider ownership lasts until its promise
2168
+ * fulfills; a rejection therefore has no run for the caller to dispose and
2169
+ * emits no run lifecycle events. Post-publication turn and infrastructure
2170
+ * failures settle through the returned run.
2171
+ * A catalog append failure disposes the run and handles its result rejection;
2172
+ * the caller receives the catalog error even if disposal also fails.
2173
+ * @param name - the provider to use.
2174
+ * @param request - child label, prompt, parent, signal, and optional capabilities.
2175
+ * @returns the published holder-owned run.
2176
+ */
2177
+ start(name: string, request: SubagentStartRequest): Promise<SubagentRun>;
2178
+ /**
2179
+ * Resolve one provider's detached continuable-creation contribution. Method
2180
+ * presence on the provider IS the capability, so a provider without it is
2181
+ * rejected before the manager reserves any child resources.
2182
+ */
2183
+ private prepareContinuable;
2184
+ /** Look up a provider for dispatch or fail loud. */
2185
+ private expectProvider;
2186
+ /** Resolve the optional continuable-subagent manager or fail loud. */
2187
+ private requireContinuations;
2188
+ /**
2189
+ * Build the lifecycle observer for one continuable Activation's residency
2190
+ * epoch, so the manager publishes its edges without owning event dispatch.
2191
+ */
2192
+ private observeActivation;
2193
+ /** Reject the first requested capability that the provider lacks. */
2194
+ private assertCapabilities;
2195
+ }
2196
+ //#endregion
2197
+ export { type AgentMessageSource, AssistantOutputFold, type ChildComposition, Config, type ContinuableCreateRequest, type ContinuableCreateSpec, type ContinuableStart, type ContinuableStartSpec, type ContinuableSubagentDescriptorData, type ContinuableSubagentDescriptorInput, type DelegatedPolicyOverrides, NO_START_CAPABILITIES, type OneShotSubagentDescriptorData, type OneShotSubagentDescriptorInput, type ResolvedSubagentStartRequest, RunResultSettlement, SUBAGENT_DESCRIPTOR_VERSION, type SubagentAddress, type SubagentCapabilities, type SubagentCatalogEntry, type SubagentCatalogRow, SubagentDepthError, type SubagentDescendantListEntry, type SubagentDescriptorData, type SubagentDescriptorInput, SubagentError, type SubagentIdentityProjection, type SubagentInterruptAuthority, type SubagentInterruptReceipt, type SubagentListEntry, type SubagentPromptReceipt, type SubagentPromptRequest, type SubagentPromptRequestId, type SubagentProvider, type SubagentResult, type SubagentRun, type SubagentRunEndInfo, SubagentRunId, type SubagentRunInfo, SubagentRuntime, SubagentRuntime as default, type SubagentSendMessageOptions, type SubagentSettledMessageSource, type SubagentStartRequest, type SubagentStopReason, type SubagentStopReasonMap, type SubagentTimingProjection, SubprocessRunHandleParts, appendDelegatedPolicyOverrides, applyChildComposition, assertPositiveFinite, assertSubagentMaxDepth, assertUsableCwd, captureDelegatedPolicyOverrides, childSessionMeta, delegationDepthOf, finalAssistantOutput, foldSubagentDescriptor, parentAgentOptionsForDelegation, resolveChildAgentOptions, resolveChildCwd, resolveChildDepth, settleRun, settleRunResult, snapshotSubagentDescriptor, subprocessRunHandle, validateConfiguredCwd };