@lmzhen/dsh-evolution-core 0.49.0 → 0.51.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 (110) hide show
  1. package/lib/authority-plugin.js +2 -1
  2. package/lib/citations-CZKTUGQF.js +198 -0
  3. package/lib/composition/index.js +3 -3
  4. package/lib/{composition-Cqjbho0t.js → composition-CtNbVHq3.js} +1 -1
  5. package/lib/connection-DAJy7Xjm.js +28 -0
  6. package/lib/{ensure-CAjLGd9f.js → ensure-BLmEW0Ju.js} +25 -7
  7. package/lib/errors.js +2 -0
  8. package/lib/extract-plan-D6o__2Kf.js +271 -0
  9. package/lib/extract.js +240 -0
  10. package/lib/http-routes.js +27 -7
  11. package/lib/index.js +100 -811
  12. package/lib/{numeric-D8js3sqC.js → limits-C9jfvxBl.js} +1 -43
  13. package/lib/{mutation-authority-l57R626O.js → mutation-authority-DQfpXs1O.js} +2 -54
  14. package/lib/numeric-Dc53KQoe.js +43 -0
  15. package/lib/platform/index.js +4 -3
  16. package/lib/platform-DyHnHUmQ.js +251 -0
  17. package/lib/policy.js +3 -2
  18. package/lib/quality-DpAS0rd9.js +554 -0
  19. package/lib/restrictor.js +1 -1
  20. package/lib/result.js +33 -0
  21. package/lib/runtime/plugin.js +97 -43
  22. package/lib/{session-projection-DSXnUNZG.js → session-projection-ByNxQi9O.js} +2 -198
  23. package/lib/skill-health-BQCM4N8z.js +1419 -0
  24. package/lib/{skill-history-CxrDE3Rb.js → skill-history-CZp8vhyL.js} +46 -2
  25. package/lib/skills.js +140 -20
  26. package/lib/state-store-Jpa-iYIZ.js +54 -0
  27. package/lib/subagent/index.js +214 -176
  28. package/lib/{tools-DzcNFex2.js → tools-BrUswg8v.js} +3 -1
  29. package/lib/types/composition/ensure.js +21 -7
  30. package/lib/types/composition/preset-ids.d.ts +2 -1
  31. package/lib/types/composition/preset-ids.js +7 -1
  32. package/lib/types/events.d.ts +3 -0
  33. package/lib/types/extract-plan.d.ts +2 -0
  34. package/lib/types/extract.d.ts +12 -0
  35. package/lib/types/extract.js +12 -0
  36. package/lib/types/http-routes.js +32 -9
  37. package/lib/types/index.d.ts +0 -3
  38. package/lib/types/index.js +0 -3
  39. package/lib/types/opt-in.js +4 -3
  40. package/lib/types/params.js +2 -1
  41. package/lib/types/platform/agents.d.ts +32 -0
  42. package/lib/types/platform/agents.js +26 -0
  43. package/lib/types/platform/commands.d.ts +14 -0
  44. package/lib/types/platform/commands.js +9 -0
  45. package/lib/types/platform/connection.d.ts +26 -0
  46. package/lib/types/platform/connection.js +27 -0
  47. package/lib/types/platform/index.d.ts +26 -0
  48. package/lib/types/platform/index.js +13 -0
  49. package/lib/types/platform/llm.d.ts +3 -1
  50. package/lib/types/platform/llm.js +1 -0
  51. package/lib/types/platform/platformView.d.ts +21 -0
  52. package/lib/types/platform/platformView.js +29 -0
  53. package/lib/types/platform/profileContext.d.ts +16 -0
  54. package/lib/types/platform/profileContext.js +14 -0
  55. package/lib/types/platform/sessionQuery.d.ts +14 -0
  56. package/lib/types/platform/sessionQuery.js +9 -0
  57. package/lib/types/platform/settings.d.ts +22 -0
  58. package/lib/types/platform/settings.js +14 -0
  59. package/lib/types/platform/skills.d.ts +16 -0
  60. package/lib/types/platform/skills.js +9 -0
  61. package/lib/types/platform/storageDomain.d.ts +13 -0
  62. package/lib/types/platform/storageDomain.js +9 -0
  63. package/lib/types/platform/subagents.d.ts +25 -0
  64. package/lib/types/platform/subagents.js +17 -0
  65. package/lib/types/platform/systemPrompt.d.ts +16 -0
  66. package/lib/types/platform/systemPrompt.js +13 -0
  67. package/lib/types/platform/tools.d.ts +4 -0
  68. package/lib/types/platform/tools.js +2 -0
  69. package/lib/types/platform/userQuestions.d.ts +33 -0
  70. package/lib/types/platform/userQuestions.js +9 -0
  71. package/lib/types/platform/workingDirectory.d.ts +14 -0
  72. package/lib/types/platform/workingDirectory.js +9 -0
  73. package/lib/types/platform-line.generated.d.ts +5 -5
  74. package/lib/types/platform-line.generated.js +5 -5
  75. package/lib/types/platform-services.js +4 -0
  76. package/lib/types/prompts.d.ts +9 -8
  77. package/lib/types/prompts.js +20 -1
  78. package/lib/types/result.d.ts +35 -0
  79. package/lib/types/result.js +25 -0
  80. package/lib/types/review-context.d.ts +8 -0
  81. package/lib/types/review-context.js +11 -0
  82. package/lib/types/run-registry.d.ts +2 -1
  83. package/lib/types/run-registry.js +37 -7
  84. package/lib/types/runtime/llm.d.ts +2 -2
  85. package/lib/types/runtime/llm.js +5 -8
  86. package/lib/types/runtime/platform.d.ts +37 -4
  87. package/lib/types/runtime/platform.js +40 -5
  88. package/lib/types/runtime/projections.d.ts +9 -4
  89. package/lib/types/runtime/projections.js +64 -28
  90. package/lib/types/section-selection.js +5 -0
  91. package/lib/types/skill-history.d.ts +29 -3
  92. package/lib/types/skill-history.js +30 -0
  93. package/lib/types/skill-store.d.ts +32 -4
  94. package/lib/types/skill-store.js +109 -15
  95. package/lib/types/subagent/channel.d.ts +1 -3
  96. package/lib/types/subagent/channel.js +2 -332
  97. package/lib/types/subagent/index.d.ts +2 -0
  98. package/lib/types/subagent/index.js +2 -0
  99. package/lib/types/subagent/kernel.d.ts +4 -0
  100. package/lib/types/subagent/kernel.js +234 -0
  101. package/lib/types/subagent/readiness.js +5 -7
  102. package/lib/types/subagent/run.d.ts +53 -0
  103. package/lib/types/subagent/run.js +125 -0
  104. package/lib/types/subagent/types.d.ts +3 -3
  105. package/lib/types/write-gates.js +11 -1
  106. package/lib/usage-B5a90TKv.js +1257 -0
  107. package/lib/write.js +1 -1
  108. package/package.json +37 -25
  109. package/lib/platform-Cc9cNt5j.js +0 -111
  110. package/lib/skill-health-DP8z9TPf.js +0 -2923
@@ -0,0 +1,234 @@
1
+ import { ensureRestrictedPreset } from "../composition/ensure.js";
2
+ import { probeChannelState } from "./readiness.js";
3
+ import { abortLink, createSubagentRun, textOfValue } from "./run.js";
4
+ function platformOf(ctx) {
5
+ return ctx.get('evolutionPlatform');
6
+ }
7
+ function messageOf(error) {
8
+ return error instanceof Error ? error.message : String(error);
9
+ }
10
+ export function createSubagentKernel(ctx) {
11
+ let lastKind = 'reviewer';
12
+ const active = new Map();
13
+ const disposed = new Set();
14
+ /**
15
+ * The one policy/probe/preset preparation shared by run and open. Starting the
16
+ * activation stays separate because run disposes and open keeps the handle.
17
+ */
18
+ async function prepare(spec) {
19
+ lastKind = spec.kind;
20
+ const probe = probeChannelState(ctx, spec.kind);
21
+ if (probe.kind === 'unavailable')
22
+ return { ok: false, outcome: probe };
23
+ const platform = platformOf(ctx);
24
+ const subagents = platform?.ports.subagents;
25
+ const presets = platform?.ports.presets;
26
+ if (platform === undefined || subagents === undefined || presets === undefined) {
27
+ return { ok: false, outcome: { kind: 'unavailable', code: 'E-323', reason: 'subagents/agentPresets service unavailable' } };
28
+ }
29
+ const parentPresetId = presets.composedPreset(spec.parent.ctx);
30
+ if (parentPresetId === undefined) {
31
+ return { ok: false, outcome: { kind: 'unavailable', code: 'E-323', reason: 'parent preset could not be resolved' } };
32
+ }
33
+ const ensured = await ensureRestrictedPreset(ctx, { kind: spec.kind, parentPresetId, allow: spec.allow });
34
+ if (ensured.kind === 'failed') {
35
+ return { ok: false, outcome: { kind: 'unavailable', code: 'E-324', reason: ensured.reason } };
36
+ }
37
+ return { ok: true, platform, subagents, ensured };
38
+ }
39
+ /** Start one activation after the shared policy/prepare step; the caller owns its link/run. */
40
+ async function startRun(spec, options) {
41
+ const prepared = await prepare(spec);
42
+ if (!prepared.ok)
43
+ return { ok: false, outcome: prepared.outcome };
44
+ const link = abortLink(spec.signal, spec.timeoutMs);
45
+ try {
46
+ const activation = await prepared.subagents.start({
47
+ provider: 'spawn',
48
+ label: spec.label,
49
+ delivery: 'caller',
50
+ parent: spec.parent,
51
+ prompt: [{ type: 'text', text: spec.promptText }],
52
+ agentPreset: prepared.ensured.presetId,
53
+ ...(options.outputSchema !== undefined ? { outputSchema: options.outputSchema } : {}),
54
+ ...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
55
+ ...(spec.maxDepth !== undefined ? { maxDepth: spec.maxDepth } : {}),
56
+ ...(spec.agentOptions !== undefined ? { agentOptions: spec.agentOptions } : {}),
57
+ signal: link.controller.signal,
58
+ });
59
+ return { ok: true, run: createSubagentRun(ctx, spec.parent, spec.label, activation), link, platform: prepared.platform };
60
+ }
61
+ catch (error) {
62
+ link.cleanup();
63
+ if (link.controller.signal.aborted)
64
+ return { ok: false, outcome: { kind: 'aborted' } };
65
+ return { ok: false, outcome: { kind: 'unavailable', code: 'E-323', reason: messageOf(error) } };
66
+ }
67
+ }
68
+ const channel = {
69
+ get state() {
70
+ return probeChannelState(ctx, lastKind);
71
+ },
72
+ prepare(spec) {
73
+ lastKind = spec.kind;
74
+ const state = probeChannelState(ctx, spec.kind);
75
+ if (state.kind === 'unavailable')
76
+ return Promise.resolve(state);
77
+ if (spec.allow.length === 0)
78
+ return Promise.resolve({ kind: 'unavailable', code: 'E-324', reason: 'allow set is empty' });
79
+ return Promise.resolve(state);
80
+ },
81
+ async run(spec) {
82
+ const started = await startRun(spec, spec.outputSchema === undefined ? {} : { outputSchema: spec.outputSchema });
83
+ if (!started.ok)
84
+ return started.outcome;
85
+ const { run, link, platform } = started;
86
+ try {
87
+ const result = await run.result;
88
+ let evidence;
89
+ if (spec.afterResult !== undefined) {
90
+ try {
91
+ const child = platform.ports.agents?.get(run.id);
92
+ if (child !== undefined)
93
+ evidence = spec.afterResult(child);
94
+ }
95
+ catch {
96
+ evidence = undefined;
97
+ }
98
+ }
99
+ const stopReason = result.stopReason;
100
+ if (stopReason === 'completed' && result.structured !== undefined && result.structured !== null) {
101
+ return {
102
+ kind: 'ok',
103
+ structured: result.structured,
104
+ childId: run.id,
105
+ stopReason: 'completed',
106
+ ...(evidence !== undefined ? { evidence } : {}),
107
+ };
108
+ }
109
+ if (stopReason === 'aborted')
110
+ return { kind: 'aborted' };
111
+ return {
112
+ kind: 'no-structured',
113
+ childId: run.id,
114
+ stopReason,
115
+ ...(result.diagnostic !== undefined ? { diagnostic: result.diagnostic } : {}),
116
+ ...(evidence !== undefined ? { evidence } : {}),
117
+ };
118
+ }
119
+ catch (error) {
120
+ if (link.controller.signal.aborted)
121
+ return { kind: 'aborted' };
122
+ return { kind: 'unavailable', code: 'E-323', reason: messageOf(error) };
123
+ }
124
+ finally {
125
+ link.cleanup();
126
+ try {
127
+ await run.dispose();
128
+ }
129
+ catch (error) {
130
+ try {
131
+ ctx.logger.warn('subagent channel: activation dispose failed: ' + messageOf(error));
132
+ }
133
+ catch { /* logging must not mask teardown */ }
134
+ }
135
+ }
136
+ },
137
+ async open(spec) {
138
+ const started = await startRun(spec, spec.cwd === undefined ? {} : { cwd: spec.cwd });
139
+ if (!started.ok)
140
+ return started.outcome;
141
+ const { run, link } = started;
142
+ try {
143
+ const result = await run.result;
144
+ if (result.stopReason === 'aborted') {
145
+ try {
146
+ await run.dispose();
147
+ }
148
+ catch { /* teardown must not replace the outcome */ }
149
+ return { kind: 'aborted' };
150
+ }
151
+ if (result.stopReason !== 'completed') {
152
+ try {
153
+ await run.dispose();
154
+ }
155
+ catch { /* teardown must not replace the outcome */ }
156
+ return { kind: 'unavailable', code: 'E-323', reason: 'round 1 did not complete: ' + result.stopReason };
157
+ }
158
+ const turn = {
159
+ childId: run.id,
160
+ stopReason: result.stopReason,
161
+ text: textOfValue(result.output),
162
+ ...(result.structured !== undefined ? { structured: result.structured } : {}),
163
+ ...(result.diagnostic !== undefined ? { diagnostic: result.diagnostic } : {}),
164
+ };
165
+ active.set(run.id, { childId: run.id, run, disposed: false });
166
+ disposed.delete(run.id);
167
+ return { kind: 'ok', childId: run.id, turn };
168
+ }
169
+ catch (error) {
170
+ try {
171
+ await run.dispose();
172
+ }
173
+ catch { /* teardown must not replace the outcome */ }
174
+ if (link.controller.signal.aborted)
175
+ return { kind: 'aborted' };
176
+ return { kind: 'unavailable', code: 'E-323', reason: messageOf(error) };
177
+ }
178
+ finally {
179
+ link.cleanup();
180
+ }
181
+ },
182
+ async continueTurn(childId, promptText, options) {
183
+ if (disposed.has(childId))
184
+ return { kind: 'unavailable', code: 'E-324', reason: 'conversation is disposed' };
185
+ const current = active.get(childId);
186
+ if (current === undefined || current.disposed) {
187
+ return { kind: 'unavailable', code: 'E-323', reason: 'no open conversation for ' + childId };
188
+ }
189
+ try {
190
+ await current.run.send([{ type: 'text', text: promptText }], options);
191
+ const result = await current.run.next(options);
192
+ if (result.stopReason === 'aborted')
193
+ return { kind: 'aborted' };
194
+ if (result.stopReason !== 'completed') {
195
+ return { kind: 'unavailable', code: 'E-323', reason: 'round 2 did not complete: ' + result.stopReason };
196
+ }
197
+ const turn = {
198
+ childId,
199
+ stopReason: 'completed',
200
+ text: textOfValue(result.output),
201
+ ...(result.structured !== undefined ? { structured: result.structured } : {}),
202
+ ...(result.diagnostic !== undefined ? { diagnostic: result.diagnostic } : {}),
203
+ };
204
+ return { kind: 'ok', childId, turn };
205
+ }
206
+ catch (error) {
207
+ if (options?.signal?.aborted === true)
208
+ return { kind: 'aborted' };
209
+ return { kind: 'unavailable', code: 'E-323', reason: messageOf(error) };
210
+ }
211
+ },
212
+ async dispose(childId) {
213
+ const current = active.get(childId);
214
+ if (current === undefined || current.disposed) {
215
+ disposed.add(childId);
216
+ return;
217
+ }
218
+ current.disposed = true;
219
+ active.delete(childId);
220
+ disposed.add(childId);
221
+ try {
222
+ await current.run.dispose();
223
+ }
224
+ catch (error) {
225
+ try {
226
+ ctx.logger.warn('subagent conversation: dispose failed: ' + messageOf(error));
227
+ }
228
+ catch { /* logging must not mask teardown */ }
229
+ }
230
+ },
231
+ };
232
+ return channel;
233
+ }
234
+ //# sourceMappingURL=kernel.js.map
@@ -1,12 +1,10 @@
1
1
  import { restrictedPresetState } from "../composition/ensure.js";
2
2
  import { restrictedPresetId } from "../composition/preset-ids.js";
3
- function serviceOf(ctx, name) {
4
- return ctx.get(name);
5
- }
6
3
  /** Pure derivation (no side effects): the doctor reads this, the channel re-probes on every run. */
7
4
  export function probeChannelState(ctx, kind) {
8
- const subagents = serviceOf(ctx, 'subagents');
9
- if (subagents === undefined || typeof subagents.getProvider !== 'function') {
5
+ const platform = ctx.get('evolutionPlatform');
6
+ const subagents = platform?.ports.subagents;
7
+ if (subagents === undefined) {
10
8
  return { kind: 'unavailable', code: 'E-323', reason: 'subagents service unavailable' };
11
9
  }
12
10
  const provider = subagents.getProvider('spawn');
@@ -18,8 +16,8 @@ export function probeChannelState(ctx, kind) {
18
16
  if (provider.inheritsParentContext === true) {
19
17
  return { kind: 'unavailable', code: 'E-323', reason: 'spawn provider inherits the parent context (independent preset required)' };
20
18
  }
21
- const agentPresets = serviceOf(ctx, 'agentPresets');
22
- if (agentPresets === undefined || typeof agentPresets.readDocument !== 'function' || typeof agentPresets.register !== 'function') {
19
+ const presets = platform?.ports.presets;
20
+ if (presets === undefined) {
23
21
  return { kind: 'unavailable', code: 'E-323', reason: 'agentPresets service unavailable or incomplete' };
24
22
  }
25
23
  const id = restrictedPresetId(kind);
@@ -0,0 +1,53 @@
1
+ /**
2
+ * One handle over a started subagent activation: the attach point for
3
+ * multi-turn conversations. The kernel owns policy/preset resolution; this
4
+ * handle owns the continuation lifecycle and the end-event wait.
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { Agent, ContentBlock, SessionId, SubagentStopReason } from '../platform/index.ts';
8
+ export interface ActivationResultLike {
9
+ readonly output?: unknown;
10
+ readonly structured?: unknown;
11
+ readonly diagnostic?: string;
12
+ readonly stopReason: SubagentStopReason;
13
+ }
14
+ export interface ActivationLike {
15
+ readonly childId: SessionId;
16
+ readonly result: Promise<ActivationResultLike>;
17
+ dispose(): Promise<void>;
18
+ }
19
+ export interface SubagentResult {
20
+ readonly childId: SessionId;
21
+ readonly stopReason: SubagentStopReason;
22
+ readonly output?: unknown;
23
+ readonly structured?: unknown;
24
+ readonly diagnostic?: string;
25
+ }
26
+ export interface SubagentTurnOptions {
27
+ readonly timeoutMs?: number;
28
+ readonly signal?: AbortSignal;
29
+ }
30
+ export interface SubagentRun {
31
+ readonly id: SessionId;
32
+ readonly name: string;
33
+ readonly result: Promise<SubagentResult>;
34
+ send(prompt: readonly ContentBlock[], options?: SubagentTurnOptions): Promise<void>;
35
+ next(options?: SubagentTurnOptions): Promise<SubagentResult>;
36
+ dispose(): Promise<void>;
37
+ }
38
+ interface SubagentEndInfo {
39
+ readonly id?: string;
40
+ readonly stopReason?: SubagentStopReason;
41
+ readonly lastAssistantMessage?: unknown;
42
+ readonly diagnostic?: string;
43
+ }
44
+ export declare function textOfValue(value: unknown): string;
45
+ export declare function abortLink(signal: AbortSignal | undefined, timeoutMs: number): {
46
+ controller: AbortController;
47
+ cleanup: () => void;
48
+ };
49
+ export declare function waitForSubagentEnd(ctx: Context, childId: SessionId, signal: AbortSignal, timeoutMs: number): Promise<SubagentEndInfo>;
50
+ /** Wrap one started activation in the single continuation handle. */
51
+ export declare function createSubagentRun(ctx: Context, parent: Agent, name: string, activation: ActivationLike): SubagentRun;
52
+ export {};
53
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1,125 @@
1
+ export function textOfValue(value) {
2
+ if (typeof value === 'string')
3
+ return value;
4
+ if (!Array.isArray(value))
5
+ return '';
6
+ return value
7
+ .filter(block => typeof block === 'object' && block !== null && block.type === 'text')
8
+ .map((block) => {
9
+ const text = block.text;
10
+ return typeof text === 'string' ? text : '';
11
+ })
12
+ .join('');
13
+ }
14
+ export function abortLink(signal, timeoutMs) {
15
+ const controller = new AbortController();
16
+ const timer = setTimeout(() => { controller.abort(new Error('subagent turn timeout')); }, timeoutMs);
17
+ const onAbort = () => { controller.abort(signal?.reason); };
18
+ signal?.addEventListener('abort', onAbort, { once: true });
19
+ return {
20
+ controller,
21
+ cleanup: () => {
22
+ clearTimeout(timer);
23
+ signal?.removeEventListener('abort', onAbort);
24
+ },
25
+ };
26
+ }
27
+ export function waitForSubagentEnd(ctx, childId, signal, timeoutMs) {
28
+ return new Promise((resolve, reject) => {
29
+ let settled = false;
30
+ const finish = (fn) => {
31
+ if (settled)
32
+ return;
33
+ settled = true;
34
+ cleanup();
35
+ fn();
36
+ };
37
+ const eventCtx = ctx;
38
+ const off = typeof eventCtx.on === 'function'
39
+ ? eventCtx.on('subagent/end', (info) => {
40
+ if (info.id !== childId)
41
+ return;
42
+ finish(() => { resolve(info); });
43
+ })
44
+ : () => { };
45
+ const timer = setTimeout(() => {
46
+ finish(() => { reject(new Error('timed out waiting for subagent/end: ' + childId)); });
47
+ }, timeoutMs);
48
+ const onAbort = () => {
49
+ finish(() => { reject(signal.reason instanceof Error ? signal.reason : new Error('conversation turn aborted')); });
50
+ };
51
+ signal.addEventListener('abort', onAbort, { once: true });
52
+ function cleanup() {
53
+ clearTimeout(timer);
54
+ signal.removeEventListener('abort', onAbort);
55
+ off();
56
+ }
57
+ if (signal.aborted)
58
+ onAbort();
59
+ });
60
+ }
61
+ /** Wrap one started activation in the single continuation handle. */
62
+ export function createSubagentRun(ctx, parent, name, activation) {
63
+ let disposed = false;
64
+ let pending;
65
+ const map = (value) => {
66
+ const output = value.output ?? value.lastAssistantMessage;
67
+ return {
68
+ childId: activation.childId,
69
+ stopReason: value.stopReason,
70
+ ...(output === undefined ? {} : { output }),
71
+ ...(value.structured === undefined ? {} : { structured: value.structured }),
72
+ ...(value.diagnostic === undefined ? {} : { diagnostic: value.diagnostic }),
73
+ };
74
+ };
75
+ const openTurn = (options) => {
76
+ const link = abortLink(options?.signal, options?.timeoutMs ?? 120_000);
77
+ return { promise: waitForSubagentEnd(ctx, activation.childId, link.controller.signal, options?.timeoutMs ?? 120_000), cleanup: link.cleanup, controller: link.controller };
78
+ };
79
+ return {
80
+ id: activation.childId,
81
+ name,
82
+ result: activation.result.then(map),
83
+ async send(prompt, options) {
84
+ if (disposed)
85
+ throw new Error('subagent run is disposed');
86
+ const platform = ctx.get('evolutionPlatform');
87
+ const send = platform?.ports.subagents?.sendMessage;
88
+ if (send === undefined)
89
+ throw new Error('subagents.sendMessage unavailable');
90
+ pending?.cleanup();
91
+ const turn = openTurn(options);
92
+ pending = turn;
93
+ try {
94
+ await send(parent, activation.childId, prompt, { signal: turn.controller.signal });
95
+ }
96
+ catch (error) {
97
+ pending = undefined;
98
+ turn.cleanup();
99
+ throw error;
100
+ }
101
+ },
102
+ async next(options) {
103
+ if (disposed)
104
+ throw new Error('subagent run is disposed');
105
+ const turn = pending ?? openTurn(options);
106
+ pending = undefined;
107
+ try {
108
+ const info = await turn.promise;
109
+ return map({ ...info, stopReason: info.stopReason ?? 'completed' });
110
+ }
111
+ finally {
112
+ turn.cleanup();
113
+ }
114
+ },
115
+ async dispose() {
116
+ if (disposed)
117
+ return;
118
+ disposed = true;
119
+ pending?.cleanup();
120
+ pending = undefined;
121
+ await activation.dispose();
122
+ },
123
+ };
124
+ }
125
+ //# sourceMappingURL=run.js.map
@@ -1,9 +1,9 @@
1
- import type { Agent, AgentOptions } from '../platform/index.ts';
1
+ import type { Agent, AgentIdentity, AgentOptions } from '../platform/index.ts';
2
2
  import type { SessionId } from '../platform/index.ts';
3
3
  import type { SubagentStopReason } from '../platform/index.ts';
4
4
  import type { ObjectJsonSchema } from '../platform/index.ts';
5
5
  export type ChannelCode = 'E-323' | 'E-324';
6
- export type ChannelKind = 'reviewer' | 'maintainer';
6
+ export type ChannelKind = 'reviewer' | 'maintainer' | 'governance';
7
7
  export interface PresetStatus {
8
8
  readonly id: string;
9
9
  readonly registered: boolean;
@@ -48,7 +48,7 @@ export interface ChannelSpec<T = undefined> {
48
48
  readonly maxDepth?: number;
49
49
  readonly timeoutMs: number;
50
50
  readonly signal?: AbortSignal;
51
- readonly afterResult?: (child: Agent) => T;
51
+ readonly afterResult?: (child: AgentIdentity) => T;
52
52
  }
53
53
  /** Open one child for a multi-turn conversation. Round 1 is the prompt. */
54
54
  export interface ConversationOpenSpec {
@@ -160,7 +160,17 @@ const MISSING_ARGS = {
160
160
  const required = action === undefined || !Object.hasOwn(SKILL_ACTION_REQUIRED_FIELDS, action)
161
161
  ? []
162
162
  : SKILL_ACTION_REQUIRED_FIELDS[action] ?? [];
163
- const missing = required.filter(field => view.scalars[field] === undefined || view.scalars[field] === null);
163
+ // A section patch replaces the old/new pair with one in-place edit.
164
+ const section = view.scalars['section'];
165
+ const sectionPatch = action === 'patch'
166
+ && typeof section === 'object' && section !== null
167
+ && typeof section.heading === 'string'
168
+ && typeof section.content === 'string';
169
+ const missing = required.filter(field => {
170
+ if (sectionPatch && (field === 'old_string' || field === 'new_string'))
171
+ return false;
172
+ return view.scalars[field] === undefined || view.scalars[field] === null;
173
+ });
164
174
  if (missing.length === 0)
165
175
  return null;
166
176
  return `skill_manage ${action} requires ${missing.join(', ')}; the tool description lists the arguments per action.`;