@lmzhen/dsh-evolution-core 0.49.0 → 0.50.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.
- package/lib/authority-plugin.js +2 -1
- package/lib/citations-CZKTUGQF.js +198 -0
- package/lib/composition/index.js +2 -2
- package/lib/{composition-Cqjbho0t.js → composition-DA8XPfMc.js} +1 -1
- package/lib/connection-DAJy7Xjm.js +28 -0
- package/lib/{ensure-CAjLGd9f.js → ensure-Bx4ksgJk.js} +15 -5
- package/lib/errors.js +2 -0
- package/lib/extract-plan-Bru3c9ec.js +271 -0
- package/lib/extract.js +240 -0
- package/lib/http-routes.js +27 -7
- package/lib/index.js +41 -800
- package/lib/{numeric-D8js3sqC.js → limits-C9jfvxBl.js} +1 -43
- package/lib/{mutation-authority-l57R626O.js → mutation-authority-DQfpXs1O.js} +2 -54
- package/lib/numeric-Dc53KQoe.js +43 -0
- package/lib/platform/index.js +4 -3
- package/lib/platform-DyHnHUmQ.js +251 -0
- package/lib/policy.js +3 -2
- package/lib/quality-WAU6YatF.js +554 -0
- package/lib/restrictor.js +1 -1
- package/lib/result.js +33 -0
- package/lib/runtime/plugin.js +97 -43
- package/lib/{session-projection-DSXnUNZG.js → session-projection-ByNxQi9O.js} +2 -198
- package/lib/skill-health-Bl-MdXZ4.js +1409 -0
- package/lib/skills.js +7 -4
- package/lib/state-store-Jpa-iYIZ.js +54 -0
- package/lib/subagent/index.js +214 -176
- package/lib/{tools-DzcNFex2.js → tools-BrUswg8v.js} +3 -1
- package/lib/types/composition/ensure.js +21 -7
- package/lib/types/extract-plan.d.ts +2 -0
- package/lib/types/extract.d.ts +12 -0
- package/lib/types/extract.js +12 -0
- package/lib/types/http-routes.js +32 -9
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -3
- package/lib/types/opt-in.js +4 -3
- package/lib/types/params.js +2 -1
- package/lib/types/platform/agents.d.ts +32 -0
- package/lib/types/platform/agents.js +26 -0
- package/lib/types/platform/commands.d.ts +14 -0
- package/lib/types/platform/commands.js +9 -0
- package/lib/types/platform/connection.d.ts +26 -0
- package/lib/types/platform/connection.js +27 -0
- package/lib/types/platform/index.d.ts +26 -0
- package/lib/types/platform/index.js +13 -0
- package/lib/types/platform/llm.d.ts +3 -1
- package/lib/types/platform/llm.js +1 -0
- package/lib/types/platform/platformView.d.ts +21 -0
- package/lib/types/platform/platformView.js +29 -0
- package/lib/types/platform/profileContext.d.ts +16 -0
- package/lib/types/platform/profileContext.js +14 -0
- package/lib/types/platform/sessionQuery.d.ts +14 -0
- package/lib/types/platform/sessionQuery.js +9 -0
- package/lib/types/platform/settings.d.ts +22 -0
- package/lib/types/platform/settings.js +14 -0
- package/lib/types/platform/skills.d.ts +16 -0
- package/lib/types/platform/skills.js +9 -0
- package/lib/types/platform/storageDomain.d.ts +13 -0
- package/lib/types/platform/storageDomain.js +9 -0
- package/lib/types/platform/subagents.d.ts +25 -0
- package/lib/types/platform/subagents.js +17 -0
- package/lib/types/platform/systemPrompt.d.ts +16 -0
- package/lib/types/platform/systemPrompt.js +13 -0
- package/lib/types/platform/tools.d.ts +4 -0
- package/lib/types/platform/tools.js +2 -0
- package/lib/types/platform/userQuestions.d.ts +33 -0
- package/lib/types/platform/userQuestions.js +9 -0
- package/lib/types/platform/workingDirectory.d.ts +14 -0
- package/lib/types/platform/workingDirectory.js +9 -0
- package/lib/types/platform-line.generated.d.ts +5 -5
- package/lib/types/platform-line.generated.js +5 -5
- package/lib/types/platform-services.js +3 -0
- package/lib/types/result.d.ts +35 -0
- package/lib/types/result.js +25 -0
- package/lib/types/runtime/llm.d.ts +2 -2
- package/lib/types/runtime/llm.js +5 -8
- package/lib/types/runtime/platform.d.ts +37 -4
- package/lib/types/runtime/platform.js +40 -5
- package/lib/types/runtime/projections.d.ts +9 -4
- package/lib/types/runtime/projections.js +64 -28
- package/lib/types/subagent/channel.d.ts +1 -3
- package/lib/types/subagent/channel.js +2 -332
- package/lib/types/subagent/index.d.ts +2 -0
- package/lib/types/subagent/index.js +2 -0
- package/lib/types/subagent/kernel.d.ts +4 -0
- package/lib/types/subagent/kernel.js +234 -0
- package/lib/types/subagent/readiness.js +5 -7
- package/lib/types/subagent/run.d.ts +53 -0
- package/lib/types/subagent/run.js +125 -0
- package/lib/types/subagent/types.d.ts +2 -2
- package/lib/usage-DdjIBAkm.js +1252 -0
- package/package.json +37 -25
- package/lib/platform-Cc9cNt5j.js +0 -111
- package/lib/skill-health-DP8z9TPf.js +0 -2923
|
@@ -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,4 +1,4 @@
|
|
|
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';
|
|
@@ -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:
|
|
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 {
|