@toddzheng024/dscode-bundle 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/THIRD_PARTY_NOTICES.md +15 -0
  2. package/cordis.patch.yml +3 -3
  3. package/package.json +7 -1
  4. package/plugins/clipboard-image/clipboard-image.swift +56 -0
  5. package/plugins/clipboard-image/index.mjs +70 -0
  6. package/plugins/code-review/git.mjs +95 -0
  7. package/plugins/code-review/index.mjs +88 -0
  8. package/plugins/dscode/index.mjs +57 -5
  9. package/plugins/email-tools/index.mjs +2 -2
  10. package/plugins/exec/index.mjs +107 -0
  11. package/plugins/session-metrics/index.mjs +6 -2
  12. package/plugins/session-metrics/rate.mjs +62 -0
  13. package/plugins/session-metrics/view.mjs +15 -9
  14. package/plugins/tui-tools/doctor-cli.mjs +22 -0
  15. package/plugins/tui-tools/doctor.mjs +141 -0
  16. package/plugins/tui-tools/index.mjs +14 -6
  17. package/plugins/ultra/policy.mjs +13 -2
  18. package/plugins/worktree-subagent/worktree.mjs +50 -0
  19. package/presets/dscode/agent.cordis.yml +14 -3
  20. package/vendor/deepseek/index.js +12 -2
  21. package/vendor/subagent/index.js +39 -12
  22. package/vendor/subagent-core/LICENSE +21 -0
  23. package/vendor/subagent-core/index.js +3232 -0
  24. package/vendor/subagent-core/invariant.js +76 -0
  25. package/vendor/subagent-core/typert.host.d.ts +3 -0
  26. package/vendor/subagent-core/typert.host.js +964 -0
  27. package/vendor/subagent-core/typert.remote-client.d.ts +27 -0
  28. package/vendor/subagent-core/typert.remote-client.js +160 -0
  29. package/vendor/subagent-core/types/assistant-output.d.ts +48 -0
  30. package/vendor/subagent-core/types/assistant-output.js +73 -0
  31. package/vendor/subagent-core/types/catalog.d.ts +77 -0
  32. package/vendor/subagent-core/types/catalog.js +103 -0
  33. package/vendor/subagent-core/types/child-agent.d.ts +150 -0
  34. package/vendor/subagent-core/types/child-agent.js +207 -0
  35. package/vendor/subagent-core/types/client.d.ts +8 -0
  36. package/vendor/subagent-core/types/client.js +7 -0
  37. package/vendor/subagent-core/types/continuation-activation.d.ts +251 -0
  38. package/vendor/subagent-core/types/continuation-activation.js +663 -0
  39. package/vendor/subagent-core/types/continuation-messages.d.ts +62 -0
  40. package/vendor/subagent-core/types/continuation-messages.js +102 -0
  41. package/vendor/subagent-core/types/continuation.d.ts +124 -0
  42. package/vendor/subagent-core/types/continuation.js +455 -0
  43. package/vendor/subagent-core/types/control-types.d.ts +146 -0
  44. package/vendor/subagent-core/types/control-types.js +9 -0
  45. package/vendor/subagent-core/types/control.d.ts +71 -0
  46. package/vendor/subagent-core/types/control.js +116 -0
  47. package/vendor/subagent-core/types/depth.d.ts +31 -0
  48. package/vendor/subagent-core/types/depth.js +39 -0
  49. package/vendor/subagent-core/types/descriptor.d.ts +144 -0
  50. package/vendor/subagent-core/types/descriptor.js +193 -0
  51. package/vendor/subagent-core/types/error.d.ts +11 -0
  52. package/vendor/subagent-core/types/error.js +14 -0
  53. package/vendor/subagent-core/types/inbox.d.ts +43 -0
  54. package/vendor/subagent-core/types/inbox.js +61 -0
  55. package/vendor/subagent-core/types/index.d.ts +316 -0
  56. package/vendor/subagent-core/types/index.js +511 -0
  57. package/vendor/subagent-core/types/internal.d.ts +58 -0
  58. package/vendor/subagent-core/types/internal.js +58 -0
  59. package/vendor/subagent-core/types/invariant.d.ts +13 -0
  60. package/vendor/subagent-core/types/invariant.js +91 -0
  61. package/vendor/subagent-core/types/lifecycle.d.ts +113 -0
  62. package/vendor/subagent-core/types/lifecycle.js +178 -0
  63. package/vendor/subagent-core/types/list-children.d.ts +65 -0
  64. package/vendor/subagent-core/types/list-children.js +381 -0
  65. package/vendor/subagent-core/types/out-of-process.d.ts +118 -0
  66. package/vendor/subagent-core/types/out-of-process.js +219 -0
  67. package/vendor/subagent-core/types/projection-types.d.ts +74 -0
  68. package/vendor/subagent-core/types/projection-types.js +7 -0
  69. package/vendor/subagent-core/types/projection.d.ts +95 -0
  70. package/vendor/subagent-core/types/projection.js +151 -0
  71. package/vendor/subagent-core/types/run-settlement.d.ts +17 -0
  72. package/vendor/subagent-core/types/run-settlement.js +70 -0
  73. package/vendor/subagent-core/types/types.d.ts +377 -0
  74. package/vendor/subagent-core/types/types.js +19 -0
  75. package/vendor/subagent-driver/LICENSE +21 -0
  76. package/vendor/subagent-driver/index.js +255 -0
  77. package/vendor/subagent-driver/types/index.d.ts +33 -0
  78. package/vendor/subagent-driver/types/structured.d.ts +42 -0
  79. package/vendor/subagent-fork/LICENSE +21 -0
  80. package/vendor/subagent-fork/index.js +61 -0
  81. package/vendor/subagent-fork/types/index.d.ts +20 -0
  82. package/vendor/subagent-spawn/LICENSE +21 -0
  83. package/vendor/subagent-spawn/index.js +45 -0
  84. package/vendor/subagent-spawn/types/index.d.ts +19 -0
  85. package/vendor/terminal/LICENSE +21 -0
  86. package/vendor/terminal/index.js +1013 -0
  87. package/vendor/terminal/types/config.d.ts +71 -0
  88. package/vendor/terminal/types/index.d.ts +36 -0
  89. package/vendor/terminal/types/sanitize.d.ts +47 -0
  90. package/vendor/terminal/types/session.d.ts +87 -0
  91. package/vendor/tui/dscode-clipboard-image/clipboard-image.swift +56 -0
  92. package/vendor/tui/dscode-clipboard-image/index.mjs +70 -0
  93. package/vendor/tui/index.mjs +341 -93
@@ -0,0 +1,381 @@
1
+ /**
2
+ * Read-only enumeration of durable subagent children and descendant trees
3
+ * through the Session query service. Candidates come from one live-preferred
4
+ * corpus; each child's mode/label is the registered `subagent` projection
5
+ * unit's value, resolved
6
+ * down a three-rung ladder: the registry's watermark cache for a live child,
7
+ * an unseeded durable projection-cache row, and one shared Session observation
8
+ * otherwise. A seeded header deliberately lacks its exact inherited cut, so
9
+ * it takes the body-bearing observation path before classifying an identity.
10
+ * The projection fold is the single classification
11
+ * authority — this module parses no descriptor
12
+ * itself. Absent persistence, enumeration is live-only: a cold child is
13
+ * unreachable for resume anyway, so its absence is capability absence, not an
14
+ * error. The module owns no catalog state and does not consult Activation,
15
+ * Agent-registry, continuation-manager, or provider state.
16
+ *
17
+ * @module @deepseek-ai/dsh-subagent
18
+ */
19
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
20
+ if (value !== null && value !== void 0) {
21
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
22
+ var dispose, inner;
23
+ if (async) {
24
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
25
+ dispose = value[Symbol.asyncDispose];
26
+ }
27
+ if (dispose === void 0) {
28
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
29
+ dispose = value[Symbol.dispose];
30
+ if (async) inner = dispose;
31
+ }
32
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
33
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
34
+ env.stack.push({ value: value, dispose: dispose, async: async });
35
+ }
36
+ else if (async) {
37
+ env.stack.push({ async: true });
38
+ }
39
+ return value;
40
+ };
41
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
42
+ return function (env) {
43
+ function fail(e) {
44
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
45
+ env.hasError = true;
46
+ }
47
+ var r, s = 0;
48
+ function next() {
49
+ while (r = env.stack.pop()) {
50
+ try {
51
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
52
+ if (r.dispose) {
53
+ var result = r.dispose.call(r.value);
54
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
55
+ }
56
+ else s |= 1;
57
+ }
58
+ catch (e) {
59
+ fail(e);
60
+ }
61
+ }
62
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
63
+ if (env.hasError) throw env.error;
64
+ }
65
+ return next();
66
+ };
67
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
68
+ var e = new Error(message);
69
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
70
+ });
71
+ import { SessionLogOffset } from '@deepseek-ai/dsh-session';
72
+ import { SubagentError } from "./error.js";
73
+ /**
74
+ * Concurrent cold observations per explicit catalog listing. Current Session
75
+ * persistence providers are local; a networked provider must promote this to
76
+ * a validated deployment setting.
77
+ */
78
+ const COLD_READ_CONCURRENCY = 4;
79
+ /**
80
+ * Enumerate one parent's origin-classified direct children from the
81
+ * live-preferred merge of `ctx.sessions` and optional session persistence,
82
+ * serving each identity from the `subagent` projection unit: the registry's
83
+ * watermark snapshot for a live child; for a cold one, a durable
84
+ * projection-cache read for an unseeded lifecycle, else one bounded-concurrency
85
+ * shared Session observation carrying the exact inherited cut.
86
+ * @see SubagentRuntime.listChildren for the public cancellation and failure contract.
87
+ * @param ctx - context carrying the session store, the projection registry,
88
+ * optional persistence, and the optional projection cache.
89
+ * @param parentSessionId - parent session whose direct children are listed.
90
+ * @param signal - caller-owned cancellation observed around every persistence read.
91
+ * @returns children and per-child diagnostics ordered by `createdAt`, then id.
92
+ * @throws {@link SubagentError} when the projection registry or the session
93
+ * store is not mounted, or the caller cancels the listing.
94
+ */
95
+ export async function listChildren(ctx, parentSessionId, signal) {
96
+ const listing = await prepareListing(ctx, signal);
97
+ const candidates = [...listing.corpus.values()]
98
+ .filter(record => record.header.parentSession === parentSessionId
99
+ && record.header.origin === 'subagent')
100
+ .sort(compareCorpusRecords);
101
+ const rows = await resolveCandidateRows(candidates, listing, signal);
102
+ return rows.filter((row) => row !== undefined);
103
+ }
104
+ /**
105
+ * Enumerate every session-backed subagent below one root in stable pre-order.
106
+ * Ordinary sessions and one-shot children remain traversal nodes, so a
107
+ * continuable child below either is still discovered. Classification uses the
108
+ * same projection-backed runtime as {@link listChildren}; no Agent is loaded or
109
+ * resumed.
110
+ * @see SubagentRuntime.listDescendants for the public cancellation and failure contract.
111
+ * @param ctx - context carrying the session store, projection registry, and optional persistence/cache.
112
+ * @param rootSessionId - session whose complete descendant tree is listed.
113
+ * @param signal - caller-owned cancellation observed around every persistence read.
114
+ * @returns interpreted subagents with durable direct-parent and root-relative depth.
115
+ * @throws {@link SubagentError} under the same conditions as {@link listChildren}.
116
+ */
117
+ export async function listDescendants(ctx, rootSessionId, signal) {
118
+ const listing = await prepareListing(ctx, signal);
119
+ const positioned = descendantCandidates(listing.corpus, rootSessionId);
120
+ const rows = await resolveCandidateRows(positioned.map(candidate => candidate.record), listing, signal);
121
+ const entries = [];
122
+ positioned.forEach((position, index) => {
123
+ const row = rows[index];
124
+ if (row !== undefined) {
125
+ entries.push({ ...row, parentId: position.parentId, depth: position.depth });
126
+ }
127
+ });
128
+ return entries;
129
+ }
130
+ /** Resolve listing services once and build one live-preferred session corpus. */
131
+ async function prepareListing(ctx, signal) {
132
+ const projections = ctx.get('sessionProjections');
133
+ // Checked before any read, even with zero candidates: mode/label are the
134
+ // row's strong contract, so a missing fold capability is a deterministic
135
+ // deployment configuration error, never an empty success.
136
+ if (projections === undefined) {
137
+ throw new SubagentError('listing subagents requires the sessionProjections registry (load @deepseek-ai/dsh-session-projection)', 'SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE');
138
+ }
139
+ // Strict global read, never the `ctx.sessions` property proxy: the proxy is
140
+ // caller-scope bound, so a consumer plugin without its own `sessions`
141
+ // injection (the model-facing tool, the API proxy) would throw on access.
142
+ const sessions = ctx.get('sessions');
143
+ if (sessions === undefined) {
144
+ throw new SubagentError('listing subagents requires the session store (load @deepseek-ai/dsh-session)', 'SUBAGENT_CONTROL_SESSION_STORE_UNAVAILABLE');
145
+ }
146
+ assertListingNotCancelled(signal);
147
+ const query = ctx.get('sessionQuery');
148
+ if (query === undefined) {
149
+ throw new SubagentError('listing subagents requires the sessionQuery service (load @deepseek-ai/dsh-session-query)', 'SUBAGENT_CONTROL_QUERY_UNAVAILABLE');
150
+ }
151
+ // Optional acceleration only: an absent cache service just means every
152
+ // cold candidate takes the authoritative preparation rung, so it carries
153
+ // no error code and no configuration check.
154
+ const cache = ctx.get('sessionProjectionCache');
155
+ let records;
156
+ try {
157
+ records = await query.listSessions(signal);
158
+ }
159
+ catch (error) {
160
+ assertListingNotCancelled(signal);
161
+ throw error;
162
+ }
163
+ assertListingNotCancelled(signal);
164
+ // Live-preferred merge without header reconciliation: a live record wins
165
+ // its id wholesale, exactly as a live-preferred corpus would serve it.
166
+ const corpus = new Map();
167
+ for (const record of records) {
168
+ const live = sessions.get(record.header.id);
169
+ corpus.set(record.header.id, {
170
+ header: live?.header ?? record.header,
171
+ live,
172
+ });
173
+ }
174
+ const subagentParents = new Set();
175
+ for (const record of corpus.values()) {
176
+ if (record.header.origin === 'subagent' && record.header.parentSession !== undefined) {
177
+ subagentParents.add(record.header.parentSession);
178
+ }
179
+ }
180
+ return { projections, query, cache, corpus, subagentParents };
181
+ }
182
+ /** Resolve projection-backed rows for aligned candidates with bounded cold reads. */
183
+ async function resolveCandidateRows(candidates, listing, signal) {
184
+ const { projections, query, cache, subagentParents } = listing;
185
+ const rows = Array.from({ length: candidates.length });
186
+ const coldReads = [];
187
+ candidates.forEach((candidate, index) => {
188
+ const childId = candidate.header.id;
189
+ if (candidate.live === undefined) {
190
+ coldReads.push({ index, header: candidate.header });
191
+ return;
192
+ }
193
+ // Read only the identity unit. A live child without an identity yet is the
194
+ // creation window before the establishing provider appends its descriptor.
195
+ let identity;
196
+ try {
197
+ identity = projections.snapshot(candidate.live, ['subagent']).values.subagent;
198
+ }
199
+ catch {
200
+ // A rejecting identity fold is deterministic data damage in this child;
201
+ // contain it as one diagnostic instead of failing the whole listing.
202
+ rows[index] = { kind: 'diagnostic', id: childId, reason: 'corrupt' };
203
+ return;
204
+ }
205
+ // The unit's serializable no-value sentinel is `null`; `undefined` can
206
+ // only mean the key was dropped at a JSON boundary. Both are no value.
207
+ if (identity === undefined || identity === null
208
+ || !candidate.live.isOwnSeq(identity.seq))
209
+ return;
210
+ rows[index] = childRow(childId, identity, 'running', subagentParents.has(childId));
211
+ });
212
+ // Cold candidates came from the query corpus and are resolved concurrently.
213
+ if (coldReads.length > 0) {
214
+ const queue = [...coldReads];
215
+ await Promise.all(Array.from({ length: Math.min(COLD_READ_CONCURRENCY, queue.length) }, async () => {
216
+ for (let job = queue.shift(); job !== undefined; job = queue.shift()) {
217
+ rows[job.index] = await resolveColdIdentity(query, cache, job.header, subagentParents.has(job.header.id), signal);
218
+ }
219
+ }));
220
+ }
221
+ assertListingNotCancelled(signal);
222
+ return rows;
223
+ }
224
+ /** Build origin-classified candidates from the complete tree without recursion. */
225
+ function descendantCandidates(corpus, rootSessionId) {
226
+ const children = new Map();
227
+ for (const record of corpus.values()) {
228
+ const parentId = record.header.parentSession;
229
+ if (parentId === undefined)
230
+ continue;
231
+ const siblings = children.get(parentId);
232
+ if (siblings === undefined)
233
+ children.set(parentId, [record]);
234
+ else
235
+ siblings.push(record);
236
+ }
237
+ for (const siblings of children.values())
238
+ siblings.sort(compareCorpusRecords);
239
+ const positioned = [];
240
+ const stack = (children.get(rootSessionId) ?? [])
241
+ .map(record => ({ record, parentId: rootSessionId, depth: 1 }))
242
+ .reverse();
243
+ const visited = new Set([rootSessionId]);
244
+ while (stack.length > 0) {
245
+ // The length guard proves one frame exists.
246
+ // oxlint-disable-next-line typescript/no-non-null-assertion
247
+ const position = stack.pop();
248
+ const id = position.record.header.id;
249
+ if (visited.has(id))
250
+ continue;
251
+ visited.add(id);
252
+ if (position.record.header.origin === 'subagent')
253
+ positioned.push(position);
254
+ const descendants = children.get(id) ?? [];
255
+ for (const record of [...descendants].reverse()) {
256
+ stack.push({ record, parentId: id, depth: position.depth + 1 });
257
+ }
258
+ }
259
+ return positioned;
260
+ }
261
+ /** Compare siblings by durable creation time, then id. */
262
+ function compareCorpusRecords(a, b) {
263
+ return a.header.createdAt - b.header.createdAt || a.header.id.localeCompare(b.header.id);
264
+ }
265
+ /**
266
+ * Resolve one cold candidate down the remaining ladder: an unseeded durable
267
+ * projection-cache row, otherwise one shared Session observation. An absent or transiently failed
268
+ * observation is one `unavailable` row retried on the next listing; an observation
269
+ * source naming another lifecycle, and a
270
+ * settled log the fold cannot identify — or that makes any registered unit
271
+ * throw — are final, so they report `corrupt`.
272
+ */
273
+ async function resolveColdIdentity(query, cache, header, hasChildren, signal) {
274
+ const env_1 = { stack: [], error: void 0, hasError: false };
275
+ try {
276
+ const childId = header.id;
277
+ // A header deliberately exposes only whether a fork cut exists, not its
278
+ // integer. An unseeded lifecycle has the exact cut 0 and may use the cache;
279
+ // a seeded lifecycle must read the body before an identity seq can be
280
+ // classified as inherited or owned.
281
+ if (cache !== undefined && !header.isSeeded) {
282
+ let cached;
283
+ try {
284
+ cached = cache.cachedSnapshot(header, SessionLogOffset(0), ['subagent'])?.values.subagent;
285
+ }
286
+ catch {
287
+ // Unlike the preparation fold below, a throwing cache read renders no
288
+ // verdict: the cache is derived data, so its damage (a poisoned stored
289
+ // row of ANY unit) silently falls through to the authoritative re-fold.
290
+ cached = undefined;
291
+ }
292
+ // An unseeded child's descriptor is owned at every valid seq. Everything
293
+ // else falls through to preparation: an absent key and the `null`
294
+ // sentinel, whose verdict belongs to the authoritative re-fold, not to a
295
+ // derived row.
296
+ if (cached !== undefined && cached !== null) {
297
+ return childRow(childId, cached, 'inactive', hasChildren);
298
+ }
299
+ }
300
+ assertListingNotCancelled(signal);
301
+ let observation;
302
+ try {
303
+ observation = await query.observeSession(childId, {
304
+ ...(signal === undefined ? {} : { signal }),
305
+ });
306
+ }
307
+ catch (error) {
308
+ // Per-child isolation: durable corruption is stable; absence and backend
309
+ // failures remain retryable. Either way, the listing itself still succeeds.
310
+ assertListingNotCancelled(signal);
311
+ return {
312
+ kind: 'diagnostic',
313
+ id: childId,
314
+ reason: sessionQueryCode(error) === 'SESSION_QUERY_CORRUPT_SESSION'
315
+ || sessionQueryCode(error) === 'SESSION_QUERY_SOURCE_CONFLICT'
316
+ ? 'corrupt'
317
+ : 'unavailable',
318
+ };
319
+ }
320
+ const ownedObservation = __addDisposableResource(env_1, observation, false);
321
+ assertListingNotCancelled(signal);
322
+ // A session id names a slot, not a lifecycle: a child deleted and
323
+ // re-published under another owner between the enumeration and this read
324
+ // must not leak into the old parent's listing.
325
+ if (!sameLifecycle(ownedObservation.header, header)) {
326
+ return { kind: 'diagnostic', id: childId, reason: 'corrupt' };
327
+ }
328
+ const identity = ownedObservation.projections?.values.subagent;
329
+ if (identity === undefined || identity === null
330
+ || identity.seq < ownedObservation.inheritedEventCount) {
331
+ return { kind: 'diagnostic', id: childId, reason: 'corrupt' };
332
+ }
333
+ return childRow(childId, identity, 'inactive', hasChildren);
334
+ }
335
+ catch (e_1) {
336
+ env_1.error = e_1;
337
+ env_1.hasError = true;
338
+ }
339
+ finally {
340
+ __disposeResources(env_1);
341
+ }
342
+ }
343
+ /** Materialize one served identity as its child row. */
344
+ function childRow(id, identity, activity, hasChildren) {
345
+ return identity.mode === 'one-shot'
346
+ ? {
347
+ kind: 'child',
348
+ id,
349
+ mode: 'one-shot',
350
+ ...identity.label !== undefined ? { label: identity.label } : {},
351
+ activity,
352
+ hasChildren,
353
+ }
354
+ : {
355
+ kind: 'child',
356
+ id,
357
+ mode: 'continuable',
358
+ label: identity.label,
359
+ activity,
360
+ hasChildren,
361
+ };
362
+ }
363
+ /** Immutable header fields that distinguish one session lifecycle from another under the same id. */
364
+ const LIFECYCLE_WITNESS_KEYS = [
365
+ 'version', 'id', 'createdAt', 'cwd', 'parentSession', 'isSeeded', 'delegationDepth',
366
+ 'origin', 'agentPreset',
367
+ ];
368
+ /** Whether an inspected log still belongs to the enumerated lifecycle. */
369
+ function sameLifecycle(meta, expected) {
370
+ return LIFECYCLE_WITNESS_KEYS.every(key => meta[key] === expected[key]);
371
+ }
372
+ /** Stop a listing at its next cancellation checkpoint. */
373
+ function assertListingNotCancelled(signal) {
374
+ if (signal?.aborted) {
375
+ throw new SubagentError('subagent listing was cancelled', 'CANCELLED');
376
+ }
377
+ }
378
+ function sessionQueryCode(error) {
379
+ return error instanceof Error && 'code' in error ? error.code : undefined;
380
+ }
381
+ //# sourceMappingURL=list-children.js.map
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Provider-side vocabulary for OUT-OF-PROCESS subagent backends — the pieces
3
+ * that enforce this seam's own contracts around a child in another process:
4
+ * the no-capabilities advertisement, timing-bound validation, child
5
+ * working-directory resolution (config override, else the delegating parent
6
+ * session's workspace), the never-reject result settlement, and the standard
7
+ * run-handle publication. Backends compose these with their own wire drivers;
8
+ * the process machinery itself (spawn, env scrub, managed-range teardown)
9
+ * belongs to the `dsh-subprocess` seam.
10
+ *
11
+ * @module @deepseek-ai/dsh-subagent/out-of-process
12
+ */
13
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm';
14
+ import type { SubagentCapabilities, SubagentResult, SubagentRun, SubagentStopReason } from './types.ts';
15
+ /**
16
+ * The capability advertisement of an out-of-process backend: NONE. A child in
17
+ * another process cannot honor parent-enforced start features
18
+ * (`agentOptions`/`outputSchema`/`maxDepth`/`toolFilter`/`persona`), so the service rejects a
19
+ * request needing any of them before `start` runs — never accepted-then-ignored.
20
+ */
21
+ export declare const NO_START_CAPABILITIES: SubagentCapabilities;
22
+ /**
23
+ * Assert a configured timing bound is a positive finite number (it bounds a
24
+ * teardown or shutdown wait; zero, negative, or NaN would skip or wedge it).
25
+ * @param prefix - the consuming plugin's diagnostic prefix (e.g. `subagent-acp`).
26
+ * @param name - the config field name, for the diagnostic.
27
+ * @param value - the configured value.
28
+ */
29
+ export declare function assertPositiveFinite(prefix: string, name: string, value: number): void;
30
+ /**
31
+ * Assert `cwd` can actually host the child: absolute (it doubles as the
32
+ * child's workspace identity, and a relative path would be re-anchored to the
33
+ * server process's launch directory) and an existing directory (fail here,
34
+ * before the process boundary, instead of as an ambiguous spawn ENOENT).
35
+ * @param prefix - the consuming plugin's diagnostic prefix.
36
+ * @param label - which source supplied the value, for the diagnostic.
37
+ * @param cwd - the candidate working directory.
38
+ * @returns `cwd`, validated.
39
+ */
40
+ export declare function assertUsableCwd(prefix: string, label: string, cwd: string): string;
41
+ /**
42
+ * Validate a configured `cwd` override ONCE, at plugin load: reject the empty
43
+ * string (`path.resolve('')` is the process cwd — it would silently
44
+ * reintroduce the launch-directory fallback this resolution removes),
45
+ * interpret a relative path against the harness launch directory, and require
46
+ * an enterable directory.
47
+ * @param prefix - the consuming plugin's diagnostic prefix.
48
+ * @param cwd - the configured override, or `undefined` when the config omits it.
49
+ * @returns the validated absolute override, or `undefined` when omitted.
50
+ */
51
+ export declare function validateConfiguredCwd(prefix: string, cwd: string | undefined): string | undefined;
52
+ /**
53
+ * Resolve the child's working directory at start: the deployment override
54
+ * when configured (already validated at load), else the parent session's
55
+ * workspace cwd (validated here, its earliest resolvable point). Fails loud
56
+ * when neither exists — falling back to the harness process cwd would
57
+ * silently bind the child to the server's launch directory instead of the
58
+ * delegating session's workspace (one server process serves many sessions,
59
+ * each with its own cwd).
60
+ * @param prefix - the consuming plugin's diagnostic prefix.
61
+ * @param configured - the load-validated override, or `undefined`.
62
+ * @param parentCwd - the delegating parent session's workspace cwd, if any.
63
+ * @returns the absolute child working directory.
64
+ */
65
+ export declare function resolveChildCwd(prefix: string, configured: string | undefined, parentCwd: string | undefined): string;
66
+ /** Inputs to {@link settleRunResult}. */
67
+ export interface RunResultSettlement {
68
+ /** The turn attempt (typically racing local cancellation); returns the terminal result. */
69
+ attempt: () => Promise<SubagentResult>;
70
+ /** Snapshot the provider exposes when cancellation or failure wins settlement. */
71
+ collectOutput: () => ContentBlock[];
72
+ /** Snapshot safe provider-authored detail when a failure wins settlement. */
73
+ collectDiagnostic?: (() => string | undefined) | undefined;
74
+ /** Whether local cancellation settled before the attempt's outcome is observed. */
75
+ cancelled: () => boolean;
76
+ /** Diagnostic sink for a failure flattened to a stop reason; a throw from it is contained. */
77
+ onError?: ((error: Error, stopReason: SubagentStopReason) => void) | undefined;
78
+ /** The request's cancellation signal (the listener is removed at settlement). */
79
+ signal: AbortSignal;
80
+ /** The abort listener registered on {@link signal} at start. */
81
+ onAbort: () => void;
82
+ }
83
+ /**
84
+ * Settle an out-of-process run result under the seam contract: `result` never
85
+ * rejects after publication. A normally completed or rejected attempt resolves
86
+ * as `aborted` when cancellation already settled locally; another rejection is
87
+ * flattened to `stopReason: 'error'` through the contained diagnostic sink.
88
+ * Provider-returned diagnostics use the same byte limit. The abort listener is
89
+ * removed on every path.
90
+ * @param parts - the attempt, output snapshot, cancellation state, sink, and signal wiring.
91
+ * @returns the terminal result (never a rejection).
92
+ */
93
+ export declare function settleRunResult(parts: RunResultSettlement): Promise<SubagentResult>;
94
+ /** Inputs to {@link subprocessRunHandle}. */
95
+ export interface SubprocessRunHandleParts {
96
+ /** The parent-scoped run id. */
97
+ id: SubagentRun['id'];
98
+ /** The flattened, never-rejecting result (the seam contract). */
99
+ result: Promise<SubagentResult>;
100
+ /** The request's cancellation signal (the listener is removed on dispose). */
101
+ signal: AbortSignal;
102
+ /** The abort listener registered on {@link signal} at start. */
103
+ onAbort: () => void;
104
+ /** Settle local cancellation so {@link result} resolves without the child. */
105
+ requestCancel: () => void;
106
+ /** Tear the child process down to quiescence (backend-owned ladder). */
107
+ teardown: () => Promise<void>;
108
+ }
109
+ /**
110
+ * Publish the seam run handle for an out-of-process child. `dispose()` is
111
+ * idempotent (one memoized teardown): it removes the abort listener, settles
112
+ * local cancellation — there is no assumption the child cooperates — and then
113
+ * awaits the backend's teardown to actual exit.
114
+ * @param parts - the run identity, result, cancellation wiring, and teardown.
115
+ * @returns the seam run handle (`localAgent` is `undefined` for remote runs).
116
+ */
117
+ export declare function subprocessRunHandle(parts: SubprocessRunHandleParts): SubagentRun;
118
+ //# sourceMappingURL=out-of-process.d.ts.map