@mcp-abap-adt/llm-agent-server-libs 18.1.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/README.md +42 -0
- package/dist/factories/cyclic-factory.d.ts +48 -0
- package/dist/factories/cyclic-factory.d.ts.map +1 -0
- package/dist/factories/cyclic-factory.js +35 -0
- package/dist/factories/cyclic-factory.js.map +1 -0
- package/dist/factories/dag-factory.d.ts +13 -0
- package/dist/factories/dag-factory.d.ts.map +1 -0
- package/dist/factories/dag-factory.js +14 -0
- package/dist/factories/dag-factory.js.map +1 -0
- package/dist/factories/deep-stepper-factory.d.ts +12 -0
- package/dist/factories/deep-stepper-factory.d.ts.map +1 -0
- package/dist/factories/deep-stepper-factory.js +13 -0
- package/dist/factories/deep-stepper-factory.js.map +1 -0
- package/dist/factories/index.d.ts +7 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +6 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/factories/linear-factory.d.ts +13 -0
- package/dist/factories/linear-factory.d.ts.map +1 -0
- package/dist/factories/linear-factory.js +14 -0
- package/dist/factories/linear-factory.js.map +1 -0
- package/dist/factories/planned-factory.d.ts +12 -0
- package/dist/factories/planned-factory.d.ts.map +1 -0
- package/dist/factories/planned-factory.js +13 -0
- package/dist/factories/planned-factory.js.map +1 -0
- package/dist/generated/version.d.ts +2 -0
- package/dist/generated/version.d.ts.map +1 -0
- package/dist/generated/version.js +3 -0
- package/dist/generated/version.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/smart-agent/build-dag-coordinator-deps.d.ts +34 -0
- package/dist/smart-agent/build-dag-coordinator-deps.d.ts.map +1 -0
- package/dist/smart-agent/build-dag-coordinator-deps.js +107 -0
- package/dist/smart-agent/build-dag-coordinator-deps.js.map +1 -0
- package/dist/smart-agent/build-stepper-root.d.ts +110 -0
- package/dist/smart-agent/build-stepper-root.d.ts.map +1 -0
- package/dist/smart-agent/build-stepper-root.js +270 -0
- package/dist/smart-agent/build-stepper-root.js.map +1 -0
- package/dist/smart-agent/config.d.ts +282 -0
- package/dist/smart-agent/config.d.ts.map +1 -0
- package/dist/smart-agent/config.js +1109 -0
- package/dist/smart-agent/config.js.map +1 -0
- package/dist/smart-agent/jsonl-knowledge-backend.d.ts +19 -0
- package/dist/smart-agent/jsonl-knowledge-backend.d.ts.map +1 -0
- package/dist/smart-agent/jsonl-knowledge-backend.js +46 -0
- package/dist/smart-agent/jsonl-knowledge-backend.js.map +1 -0
- package/dist/smart-agent/pipeline.d.ts +89 -0
- package/dist/smart-agent/pipeline.d.ts.map +1 -0
- package/dist/smart-agent/pipeline.js +8 -0
- package/dist/smart-agent/pipeline.js.map +1 -0
- package/dist/smart-agent/resolve-agent-embedder.d.ts +34 -0
- package/dist/smart-agent/resolve-agent-embedder.d.ts.map +1 -0
- package/dist/smart-agent/resolve-agent-embedder.js +48 -0
- package/dist/smart-agent/resolve-agent-embedder.js.map +1 -0
- package/dist/smart-agent/session-identity-resolver.d.ts +17 -0
- package/dist/smart-agent/session-identity-resolver.d.ts.map +1 -0
- package/dist/smart-agent/session-identity-resolver.js +37 -0
- package/dist/smart-agent/session-identity-resolver.js.map +1 -0
- package/dist/smart-agent/session-meta-store.d.ts +53 -0
- package/dist/smart-agent/session-meta-store.d.ts.map +1 -0
- package/dist/smart-agent/session-meta-store.js +36 -0
- package/dist/smart-agent/session-meta-store.js.map +1 -0
- package/dist/smart-agent/smart-server.d.ts +525 -0
- package/dist/smart-agent/smart-server.d.ts.map +1 -0
- package/dist/smart-agent/smart-server.js +2309 -0
- package/dist/smart-agent/smart-server.js.map +1 -0
- package/dist/smart-agent/stepper-coordinator-handler.d.ts +36 -0
- package/dist/smart-agent/stepper-coordinator-handler.d.ts.map +1 -0
- package/dist/smart-agent/stepper-coordinator-handler.js +230 -0
- package/dist/smart-agent/stepper-coordinator-handler.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-stepper-root.d.ts","sourceRoot":"","sources":["../../src/smart-agent/build-stepper-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,IAAI,EAET,KAAK,QAAQ,EAEb,KAAK,eAAe,EACpB,KAAK,YAAY,EAEjB,WAAW,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAQL,aAAa,EAEb,OAAO,EAER,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,gBAAgB,EAGrB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC;;;;OAIG;IACH,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClE,kEAAkE;IAClE,OAAO,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,2CAA2C;IAC3C,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,mBAAmB,CAAC;IAC5D,+BAA+B;IAC/B,QAAQ,EAAE,OAAO,yBAAyB,EAAE,eAAe,CAAC;IAC5D,wBAAwB;IACxB,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB,8CAA8C;IAC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;IACxC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,wBAAwB,GAC/B,sBAAsB,CAyBxB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAY3B;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,sBAAsB,EAC5B,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CA6P3B"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { TokenLedger, } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { CyclicReActExecutor, LlmEvaluator, LlmNeedResolver, LlmReviewStrategy, LlmStepperPlanner, LlmTaskFormalizer, LoggingLlm, RootFinalizer, StaticPlanner, Stepper, StepperInterpreter, } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
|
+
import { parseStepperCoordinatorConfig, resolveLlmConfig, } from './config.js';
|
|
4
|
+
const STUB_LLM_CFG = {
|
|
5
|
+
provider: 'openai',
|
|
6
|
+
apiKey: '',
|
|
7
|
+
model: 'stub',
|
|
8
|
+
};
|
|
9
|
+
/** Map a parsed coordinator config to the front-end-agnostic composition spec. */
|
|
10
|
+
export function toCompositionSpec(config) {
|
|
11
|
+
return {
|
|
12
|
+
planner: config.flow.planner,
|
|
13
|
+
granularity: config.flow.granularity,
|
|
14
|
+
...(config.flow.plan ? { plan: config.flow.plan } : {}),
|
|
15
|
+
...(config.flow.nodes ? { nodes: config.flow.nodes } : {}),
|
|
16
|
+
executor: config.flow.executor,
|
|
17
|
+
finalizer: config.flow.finalizer,
|
|
18
|
+
...(config.flow.plannerSystemPrompt
|
|
19
|
+
? { plannerSystemPrompt: config.flow.plannerSystemPrompt }
|
|
20
|
+
: {}),
|
|
21
|
+
...(config.flow.executorSystemPrompt
|
|
22
|
+
? { executorSystemPrompt: config.flow.executorSystemPrompt }
|
|
23
|
+
: {}),
|
|
24
|
+
evaluatorEnabled: config.flow.evaluatorEnabled,
|
|
25
|
+
evaluatorAtDepths: config.flow.evaluatorAtDepths,
|
|
26
|
+
...(config.flow.evaluatorSystemPrompt
|
|
27
|
+
? { evaluatorSystemPrompt: config.flow.evaluatorSystemPrompt }
|
|
28
|
+
: {}),
|
|
29
|
+
reviewerAtDepths: config.reviewerAtDepths,
|
|
30
|
+
maxParallelSteps: config.maxParallelSteps,
|
|
31
|
+
maxDepth: config.maxDepth,
|
|
32
|
+
tokenBudget: config.tokenBudget,
|
|
33
|
+
formalizeTask: config.formalizeTask,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* yaml front-end: parse the raw coordinator config block → composition spec →
|
|
38
|
+
* build. Thin wrapper over {@link buildFromComposition}; a code builder can call
|
|
39
|
+
* buildFromComposition directly with a spec it constructs itself (parity).
|
|
40
|
+
*/
|
|
41
|
+
export async function buildStepperRoot(input) {
|
|
42
|
+
const config = parseStepperCoordinatorConfig(input.coordCfg);
|
|
43
|
+
return buildFromComposition(toCompositionSpec(config), {
|
|
44
|
+
makeLlm: input.makeLlm,
|
|
45
|
+
callMcp: input.callMcp,
|
|
46
|
+
mintStepperId: input.mintStepperId,
|
|
47
|
+
llmMap: input.llmMap,
|
|
48
|
+
pipelineFallback: input.pipelineFallback,
|
|
49
|
+
logLlmCall: input.logLlmCall,
|
|
50
|
+
subagents: input.subagents,
|
|
51
|
+
registry: input.registry,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the root Stepper + finalizer from a front-end-agnostic composition spec.
|
|
56
|
+
* The yaml path reaches here via buildStepperRoot; a code builder can call this
|
|
57
|
+
* directly. Each role LLM resolves via llmMap[role] → llmMap.main → fallback.
|
|
58
|
+
*/
|
|
59
|
+
export async function buildFromComposition(spec, deps) {
|
|
60
|
+
const { registry, makeLlm, callMcp, mintStepperId, llmMap, pipelineFallback, logLlmCall, } = deps;
|
|
61
|
+
// Shared token ledger — ONE instance per run (review R2-F1). Created up-front
|
|
62
|
+
// so every role's LLM decorator can spend on it (see resolveRoleLlm).
|
|
63
|
+
const tokens = new TokenLedger(spec.tokenBudget);
|
|
64
|
+
// ---- Per-role LLM resolver -----------------------------------------------
|
|
65
|
+
// Priority chain: llmMap[role] → llmMap.main → pipelineFallback → STUB_LLM_CFG.
|
|
66
|
+
// Mirrors the resolution chain used in buildDagCoordinatorDeps.
|
|
67
|
+
//
|
|
68
|
+
// `spendOnLedger` makes the role's LLM decrement the SHARED token ledger after
|
|
69
|
+
// each call, so coordinator.stepper.tokenBudget bounds ALL stepper work — not
|
|
70
|
+
// just the executor (review Finding 2). The executor passes `false`: it spends
|
|
71
|
+
// on the same ledger itself (see CyclicReActExecutor) and double-counting must
|
|
72
|
+
// be avoided. The decorator is now installed whenever EITHER logging or ledger
|
|
73
|
+
// accounting is needed (previously it was skipped entirely without a logger).
|
|
74
|
+
const resolveRoleLlm = async (role, component, spendOnLedger) => {
|
|
75
|
+
let inner;
|
|
76
|
+
let cfgModel;
|
|
77
|
+
if (deps.makeRoleLlm) {
|
|
78
|
+
inner = await deps.makeRoleLlm(role);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const cfg = resolveLlmConfig(llmMap, role, pipelineFallback) ?? STUB_LLM_CFG;
|
|
82
|
+
cfgModel = cfg.model;
|
|
83
|
+
// makeLlm is safe here: this branch only runs when makeRoleLlm is absent.
|
|
84
|
+
// If both are absent the call throws at runtime, matching prior behaviour
|
|
85
|
+
// where makeLlm was required. The `?.` auto-fix is wrong — it would return
|
|
86
|
+
// undefined instead of throwing, masking a misconfiguration.
|
|
87
|
+
// biome-ignore lint/style/noNonNullAssertion: legacy path requires makeLlm; throwing when absent is intended
|
|
88
|
+
inner = await makeLlm(cfg);
|
|
89
|
+
}
|
|
90
|
+
if (!logLlmCall && !spendOnLedger)
|
|
91
|
+
return inner;
|
|
92
|
+
// Wrap with LoggingLlm so every call to this role's LLM is (a) logged to
|
|
93
|
+
// byComponent and (b) charged to the shared ledger. Fires once per call
|
|
94
|
+
// (chat or streamChat) after usage is known.
|
|
95
|
+
return new LoggingLlm(inner, (usage, durationMs) => {
|
|
96
|
+
if (logLlmCall) {
|
|
97
|
+
logLlmCall({
|
|
98
|
+
component,
|
|
99
|
+
model: inner.model ?? cfgModel ?? 'unknown',
|
|
100
|
+
promptTokens: usage.promptTokens,
|
|
101
|
+
completionTokens: usage.completionTokens,
|
|
102
|
+
totalTokens: usage.totalTokens,
|
|
103
|
+
durationMs,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (spendOnLedger)
|
|
107
|
+
tokens.spend(usage);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
// ---- Build per-role LLMs --------------------------------------------------
|
|
111
|
+
// Every non-executor role charges the shared ledger; the executor self-spends.
|
|
112
|
+
const plannerLlm = await resolveRoleLlm('planner', 'planner', true);
|
|
113
|
+
const executorLlm = await resolveRoleLlm('executor', 'tool-loop', false);
|
|
114
|
+
const finalizerLlm = await resolveRoleLlm('finalizer', 'finalizer', true);
|
|
115
|
+
const reviewerLlm = await resolveRoleLlm('reviewer', 'reviewer', true);
|
|
116
|
+
// Tool-definer LLM: detects an unmet-tool-need ("I can't … no tool") in a
|
|
117
|
+
// candidate final answer and yields the phrase to search toolsRag with before
|
|
118
|
+
// the retry. Logged under its OWN component 'tool-definer' — NOT 'classifier'
|
|
119
|
+
// — so its cost is distinct from the (skipped-in-stepper) request classifier
|
|
120
|
+
// and the name reflects its actual job. Resolves via role 'classifier' (falls
|
|
121
|
+
// back to main); point it at a small model via `llm.classifier` in YAML.
|
|
122
|
+
const toolDefinerLlm = await resolveRoleLlm('classifier', 'tool-definer', true);
|
|
123
|
+
// ---- Reviewer (always built; Stepper only invokes at configured depths) ---
|
|
124
|
+
const reviewer = new LlmReviewStrategy(reviewerLlm);
|
|
125
|
+
// ---- Evaluator (18.1; built only when enabled by the spec) ----------------
|
|
126
|
+
// Its own LLM role 'evaluator' → main, so a deployment can point it at a
|
|
127
|
+
// strong model independently. Shared across the whole tree.
|
|
128
|
+
const evaluator = spec.evaluatorEnabled
|
|
129
|
+
? new LlmEvaluator(await resolveRoleLlm('evaluator', 'evaluator', true), spec.evaluatorSystemPrompt)
|
|
130
|
+
: undefined;
|
|
131
|
+
// One shared interpreter + need-resolver across the whole tree.
|
|
132
|
+
const interpreter = new StepperInterpreter();
|
|
133
|
+
const needResolver = new LlmNeedResolver(toolDefinerLlm);
|
|
134
|
+
// Leaf executor per spec.executor profile (reuses the shared executor LLM +
|
|
135
|
+
// need-resolver): 'simple' = single pass (maxIter 2); cyclic-react/recursive
|
|
136
|
+
// run the full ReAct loop (maxIter 10).
|
|
137
|
+
const makeExecutor = (s) => new CyclicReActExecutor({
|
|
138
|
+
llm: executorLlm,
|
|
139
|
+
callMcp,
|
|
140
|
+
component: 'tool-loop',
|
|
141
|
+
maxIterations: s.executor === 'simple' ? 2 : 10,
|
|
142
|
+
needResolver,
|
|
143
|
+
...(s.executorSystemPrompt
|
|
144
|
+
? { systemPrompt: s.executorSystemPrompt }
|
|
145
|
+
: {}),
|
|
146
|
+
});
|
|
147
|
+
const trivialPlanner = {
|
|
148
|
+
name: 'trivial',
|
|
149
|
+
async plan(inp) {
|
|
150
|
+
return {
|
|
151
|
+
objective: inp.prompt,
|
|
152
|
+
nodes: [{ id: 'root', goal: inp.prompt }],
|
|
153
|
+
createdAt: 0,
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
// Recursive composition builder. LLMs, token ledger, reviewer, interpreter are
|
|
158
|
+
// SHARED across the whole tree (shared-ledger invariant); only the planner, the
|
|
159
|
+
// executor profile and the childSteppers vary per (nested) spec.
|
|
160
|
+
const buildNode = (s, depth) => {
|
|
161
|
+
const ex = makeExecutor(s);
|
|
162
|
+
const childMap = new Map();
|
|
163
|
+
const nodes = s.nodes ?? [];
|
|
164
|
+
// Planner selection. Declared `nodes` ⇒ static plan over them (nested nodes
|
|
165
|
+
// carry agent=id so the interpreter routes them into their child Stepper).
|
|
166
|
+
let planner;
|
|
167
|
+
if (nodes.length > 0) {
|
|
168
|
+
const planNodes = nodes.map((n) => ({
|
|
169
|
+
id: n.id,
|
|
170
|
+
goal: n.goal,
|
|
171
|
+
...(n.dependsOn ? { dependsOn: n.dependsOn } : {}),
|
|
172
|
+
...(n.flow ? { agent: n.id } : {}),
|
|
173
|
+
}));
|
|
174
|
+
planner = new StaticPlanner(planNodes);
|
|
175
|
+
}
|
|
176
|
+
else if (s.planner === 'none') {
|
|
177
|
+
planner = trivialPlanner;
|
|
178
|
+
}
|
|
179
|
+
else if (s.planner === 'static') {
|
|
180
|
+
planner = new StaticPlanner(s.plan ?? []);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
planner = new LlmStepperPlanner(plannerLlm, s.granularity, s.plannerSystemPrompt);
|
|
184
|
+
}
|
|
185
|
+
// (a) Structural recursion: declared nested-flow nodes → child Steppers.
|
|
186
|
+
for (const n of nodes) {
|
|
187
|
+
if (n.flow)
|
|
188
|
+
childMap.set(n.id, buildNode(n.flow, depth + 1));
|
|
189
|
+
}
|
|
190
|
+
// (b) Runtime subagent recursion (executor: recursive) — only when NO nested
|
|
191
|
+
// nodes were declared; preserves the existing deep-stepper behaviour. Children
|
|
192
|
+
// share this run's planner/executor/reviewer + role LLMs (shared ledger), and
|
|
193
|
+
// point childSteppers back to the SAME map so recursion continues.
|
|
194
|
+
let catalog = [];
|
|
195
|
+
if (s.executor === 'recursive' && nodes.length === 0) {
|
|
196
|
+
catalog = (deps.subagents ?? []).map((sa) => ({
|
|
197
|
+
name: sa.name,
|
|
198
|
+
description: sa.description,
|
|
199
|
+
}));
|
|
200
|
+
if (registry.size > 0) {
|
|
201
|
+
for (const [k, v] of registry)
|
|
202
|
+
childMap.set(k, v);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
for (const sa of catalog) {
|
|
206
|
+
childMap.set(sa.name, new Stepper({
|
|
207
|
+
name: sa.name,
|
|
208
|
+
planner,
|
|
209
|
+
interpreter,
|
|
210
|
+
executor: ex,
|
|
211
|
+
childSteppers: childMap,
|
|
212
|
+
reviewer,
|
|
213
|
+
reviewerAtDepths: s.reviewerAtDepths,
|
|
214
|
+
...(evaluator ? { evaluator } : {}),
|
|
215
|
+
evaluatorAtDepths: s.evaluatorAtDepths,
|
|
216
|
+
depth: depth + 1,
|
|
217
|
+
maxParallelSteps: s.maxParallelSteps,
|
|
218
|
+
mintStepperId,
|
|
219
|
+
childAgentCatalog: catalog,
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return new Stepper({
|
|
225
|
+
name: depth === 0 ? 'root' : `node-d${depth}`,
|
|
226
|
+
planner,
|
|
227
|
+
interpreter,
|
|
228
|
+
executor: ex,
|
|
229
|
+
childSteppers: childMap,
|
|
230
|
+
reviewer,
|
|
231
|
+
reviewerAtDepths: s.reviewerAtDepths,
|
|
232
|
+
...(evaluator ? { evaluator } : {}),
|
|
233
|
+
evaluatorAtDepths: s.evaluatorAtDepths,
|
|
234
|
+
depth,
|
|
235
|
+
maxParallelSteps: s.maxParallelSteps,
|
|
236
|
+
mintStepperId,
|
|
237
|
+
childAgentCatalog: catalog,
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
const rootStepper = buildNode(spec, 0);
|
|
241
|
+
// Depth budget covers BOTH declared nesting and runtime recursion.
|
|
242
|
+
const nestingDepth = (s) => {
|
|
243
|
+
const ds = (s.nodes ?? [])
|
|
244
|
+
.filter((n) => n.flow)
|
|
245
|
+
.map((n) => 1 + nestingDepth(n.flow));
|
|
246
|
+
return ds.length ? Math.max(...ds) : 0;
|
|
247
|
+
};
|
|
248
|
+
const anyRecursive = (s) => s.executor === 'recursive' ||
|
|
249
|
+
(s.nodes ?? []).some((n) => !!n.flow && anyRecursive(n.flow));
|
|
250
|
+
const baseDepth = spec.executor === 'recursive'
|
|
251
|
+
? spec.maxDepth
|
|
252
|
+
: spec.planner === 'none' && (spec.nodes?.length ?? 0) === 0
|
|
253
|
+
? 0
|
|
254
|
+
: 1;
|
|
255
|
+
const depthRemaining = Math.max(baseDepth, nestingDepth(spec), anyRecursive(spec) ? spec.maxDepth : 0);
|
|
256
|
+
const finalizer = new RootFinalizer(finalizerLlm);
|
|
257
|
+
// Task formalizer (opt-in): uses the strong planner-tier LLM to produce a
|
|
258
|
+
// compact TaskSpec once at the root. Built only when configured.
|
|
259
|
+
const taskFormalizer = spec.formalizeTask
|
|
260
|
+
? new LlmTaskFormalizer(plannerLlm)
|
|
261
|
+
: undefined;
|
|
262
|
+
return {
|
|
263
|
+
rootStepper,
|
|
264
|
+
finalizer,
|
|
265
|
+
budget: { depthRemaining, tokens },
|
|
266
|
+
maxParallelSteps: spec.maxParallelSteps,
|
|
267
|
+
...(taskFormalizer ? { taskFormalizer } : {}),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=build-stepper-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-stepper-root.js","sourceRoot":"","sources":["../../src/smart-agent/build-stepper-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,aAAa,EACb,OAAO,EACP,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,6BAA6B,EAC7B,gBAAgB,GAGjB,MAAM,aAAa,CAAC;AAkErB,MAAM,YAAY,GAAyB;IACzC,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,EAAE;IACV,K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AAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,WAAW;QACX,SAAS;QACT,MAAM,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE;QAClC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared config utilities for SmartServer.
|
|
3
|
+
*/
|
|
4
|
+
import type { IFinalizer, ILlm, ISubAgentContextBuilder, IToolSelectionStrategy, PlanNode } from '@mcp-abap-adt/llm-agent';
|
|
5
|
+
import { AutoActivation, ExplicitActivation, HybridDispatch, OneShotPlanning, ReplanOnErrorPlanning, SelfDispatch, SkillStepsPlanning, SubAgentDispatch } from '@mcp-abap-adt/llm-agent-libs';
|
|
6
|
+
import type { SmartServerConfig, SmartServerLlmConfig } from './smart-server.js';
|
|
7
|
+
export type LlmConfigMap = Record<string, SmartServerLlmConfig>;
|
|
8
|
+
export type NormalizedLlmMap = {
|
|
9
|
+
main: SmartServerLlmConfig;
|
|
10
|
+
} & LlmConfigMap;
|
|
11
|
+
/**
|
|
12
|
+
* Normalize the optional top-level `llm:` block.
|
|
13
|
+
* - undefined → undefined (pipeline-only configs stay valid)
|
|
14
|
+
* - flat shape (has `provider` | `apiKey` | `model` | `url`) → { main: flat } (backward compat)
|
|
15
|
+
* - map shape → must include `main`; returned as NormalizedLlmMap
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeLlmConfig(input?: SmartServerLlmConfig | LlmConfigMap): NormalizedLlmMap | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Strict lookup: returns map[name] if explicitly present, else undefined.
|
|
20
|
+
* Does NOT fall through to map.main. Use when the caller needs to
|
|
21
|
+
* detect explicit-presence (e.g. to decide between an alias and the
|
|
22
|
+
* named map entry).
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveLlmConfigStrict(map: NormalizedLlmMap | undefined, name: string | undefined): SmartServerLlmConfig | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a per-role LLM config by name from a normalized map.
|
|
27
|
+
* Lookup chain: map[name] → map.main → pipelineFallback.
|
|
28
|
+
* When map is undefined, falls back to pipelineFallback (so pipeline-only
|
|
29
|
+
* configs keep working with no top-level llm: block).
|
|
30
|
+
*
|
|
31
|
+
* The caller decides whether `undefined` is an error.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveLlmConfig(map: NormalizedLlmMap | undefined, name?: string, pipelineFallback?: SmartServerLlmConfig): SmartServerLlmConfig | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Read the reviewer block's LLM-name selector, accepting both the
|
|
36
|
+
* preferred `reviewerLlm` field and the deprecated `plannerLlm` alias.
|
|
37
|
+
* When the alias is used, calls `warn(message)`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveReviewerLlmName(block: {
|
|
40
|
+
reviewerLlm?: string;
|
|
41
|
+
plannerLlm?: string;
|
|
42
|
+
} | undefined, warn: (msg: string) => void): string | undefined;
|
|
43
|
+
export interface YamlCoordinator {
|
|
44
|
+
planning?: 'one-shot' | 'replan-on-error' | 'skill-steps';
|
|
45
|
+
dispatch?: 'subagent' | 'self' | 'hybrid';
|
|
46
|
+
activation?: 'auto' | 'explicit';
|
|
47
|
+
plannerLlm?: 'main' | 'planner' | 'helper';
|
|
48
|
+
maxSteps?: number;
|
|
49
|
+
maxRetriesPerStep?: number;
|
|
50
|
+
failPolicy?: 'abort' | 'continue';
|
|
51
|
+
maxLayer?: number;
|
|
52
|
+
planner?: {
|
|
53
|
+
type?: string;
|
|
54
|
+
plannerLlm?: 'main' | 'planner' | 'helper';
|
|
55
|
+
} | Record<string, unknown>;
|
|
56
|
+
interpreter?: {
|
|
57
|
+
type?: string;
|
|
58
|
+
} | Record<string, unknown>;
|
|
59
|
+
reviewer?: {
|
|
60
|
+
type?: string;
|
|
61
|
+
reviewerLlm?: string;
|
|
62
|
+
plannerLlm?: 'main' | 'planner' | 'helper';
|
|
63
|
+
};
|
|
64
|
+
finalizer?: {
|
|
65
|
+
type?: 'passthrough' | 'llm' | 'template';
|
|
66
|
+
finalizerLlm?: string;
|
|
67
|
+
systemPrompt?: string;
|
|
68
|
+
};
|
|
69
|
+
errorStrategy?: {
|
|
70
|
+
type?: string;
|
|
71
|
+
maxReplans?: number;
|
|
72
|
+
};
|
|
73
|
+
stateOracle?: string;
|
|
74
|
+
maxRoundTrips?: number;
|
|
75
|
+
}
|
|
76
|
+
/** Fail-loud guard: a coordinator block is either DAG (has `planner`) or linear,
|
|
77
|
+
* never mixed. `activation` is shared and always allowed. */
|
|
78
|
+
export declare function assertCoordinatorConfigShape(coord: Record<string, unknown>): void;
|
|
79
|
+
export declare function resolveCoordinatorPlanning(name: string, plannerLlm: ILlm): OneShotPlanning | ReplanOnErrorPlanning | SkillStepsPlanning;
|
|
80
|
+
/**
|
|
81
|
+
* Default coordinator dispatch kind. Omitted → 'hybrid' for ALL planning kinds:
|
|
82
|
+
* agentless steps — the synthesized answer-directly step (#155) and skill steps
|
|
83
|
+
* without an explicit `agent:` — need a self-LLM fallback. Pin 'subagent'
|
|
84
|
+
* explicitly for strict subagent-only routing.
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveCoordinatorDispatchKind(explicit?: 'subagent' | 'self' | 'hybrid'): 'subagent' | 'self' | 'hybrid';
|
|
87
|
+
export declare function resolveCoordinatorDispatch(name: string, fallbackLlm?: ILlm, contextBuilder?: ISubAgentContextBuilder): SubAgentDispatch | SelfDispatch | HybridDispatch;
|
|
88
|
+
export declare function resolveCoordinatorActivation(name: string): AutoActivation | ExplicitActivation;
|
|
89
|
+
export declare function resolveToolSelectionStrategy(name: string, params?: {
|
|
90
|
+
minScore?: number;
|
|
91
|
+
}): IToolSelectionStrategy;
|
|
92
|
+
export declare class ConfigValidationError extends Error {
|
|
93
|
+
constructor(issues: string[]);
|
|
94
|
+
}
|
|
95
|
+
export type YamlConfig = Record<string, unknown>;
|
|
96
|
+
export interface ResolveConfigArgs {
|
|
97
|
+
port?: string | boolean;
|
|
98
|
+
host?: string | boolean;
|
|
99
|
+
'llm-api-key'?: string | boolean;
|
|
100
|
+
'llm-model'?: string | boolean;
|
|
101
|
+
'llm-temperature'?: string | boolean;
|
|
102
|
+
'rag-type'?: string | boolean;
|
|
103
|
+
'rag-url'?: string | boolean;
|
|
104
|
+
'rag-model'?: string | boolean;
|
|
105
|
+
'rag-collection-name'?: string | boolean;
|
|
106
|
+
'rag-vector-weight'?: string | boolean;
|
|
107
|
+
'rag-keyword-weight'?: string | boolean;
|
|
108
|
+
'qdrant-api-key'?: string | boolean;
|
|
109
|
+
'mcp-type'?: string | boolean;
|
|
110
|
+
'mcp-url'?: string | boolean;
|
|
111
|
+
'mcp-command'?: string | boolean;
|
|
112
|
+
'mcp-args'?: string | boolean;
|
|
113
|
+
'prompt-system'?: string | boolean;
|
|
114
|
+
'prompt-classifier'?: string | boolean;
|
|
115
|
+
'agent-show-reasoning'?: boolean;
|
|
116
|
+
'log-dir'?: string;
|
|
117
|
+
'plugin-dir'?: string;
|
|
118
|
+
mode?: string | boolean;
|
|
119
|
+
}
|
|
120
|
+
export declare const YAML_TEMPLATE = "port: 4004\nhost: 0.0.0.0\n\n# Request routing mode:\n# hard \u2014 Fully managed context. Ignores client history/system prompt. Uses RAG + internal MCP tools only.\n# pass \u2014 Transparent proxy. Logs everything but modifies nothing.\n# smart \u2014 Hybrid. Preserves client history but enriches it with RAG context and MCP tools based on analysis. (default)\nmode: smart\n\nllm:\n provider: deepseek # deepseek | openai | anthropic | sap-ai-sdk | ollama\n apiKey: ${DEEPSEEK_API_KEY} # not required for ollama / sap-ai-sdk\n model: deepseek-chat\n temperature: 0.7\n classifierTemperature: 0.1\n\nrag:\n type: in-memory # in-memory | qdrant | hana-vector | pg-vector\n embedder: ollama # Embedder to use: ollama | openai | sap-ai-core | <custom>\n url: http://localhost:11434\n model: bge-m3\n # resourceGroup: default # SAP AI Core resource group (sap-ai-core embedder)\n # scenario: orchestration # SAP AI Core scenario: orchestration (default) | foundation-models\n # collectionName: llm-agent # Collection/table name (qdrant | hana-vector | pg-vector)\n dedupThreshold: 0.92\n vectorWeight: 0.7 # Semantic similarity weight (0..1)\n keywordWeight: 0.3 # Lexical matching weight (0..1)\n\nmcp:\n # type: none | http | stdio\n # To disable MCP, set type to 'none'\n type: http\n url: http://localhost:3001/mcp/stream/http\n\nagent:\n externalToolsValidationMode: permissive # permissive | strict\n maxIterations: 10\n maxToolCalls: 30\n toolUnavailableTtlMs: 600000 # Temporary tool blacklist TTL (ms)\n ragQueryK: 10\n # contextBudgetTokens: 4000 # Max tokens for RAG context in system prompt (0 = no limit)\n # semanticHistoryEnabled: false # Enable semantic history via RAG\n # historyRecencyWindow: 4 # Last N messages from client history in LLM context\n # historyTurnSummaryPrompt: \"...\" # LLM prompt for turn summarization\n showReasoning: false # Explain strategy at start of response\n historyAutoSummarizeLimit: 10 # History length to trigger compression\n queryExpansionEnabled: false # Expand RAG queries with LLM-generated synonyms\n toolResultCacheTtlMs: 300000 # Tool result cache TTL (ms); 0 to disable\n sessionTokenBudget: 0 # Multi-turn token budget; 0 to disable\n # ragTranslateEnabled: true # Translate non-ASCII RAG queries to English (default: true)\n # classificationEnabled: false # Enable for custom pipelines with multi-store routing\n # toolReselectPerIteration: false # Re-select tools via RAG on each tool-loop iteration\n # llmCallStrategy: streaming # streaming | non-streaming | fallback\n # streamMode: full # full | final \u2014 streaming behavior for tool loops\n # heartbeatIntervalMs: 5000 # SSE heartbeat interval during tool execution (ms)\n # healthTimeoutMs: 5000 # Health check probe timeout (ms); increase for slow providers (SAP AI Core: 15000)\n # retry: # LLM retry config for 429/5xx errors\n # maxAttempts: 3\n # backoffMs: 1000\n # retryOn: [429, 500, 502, 503]\n # retryOnMidStream: ['SSE stream'] # Substrings triggering mid-stream retry\n\n# --- Advanced Multi-Model Pipeline (optional) -------------------------------\n# Use this section to assign different models for different internal tasks.\n# pipeline:\n# llm:\n# main:\n# provider: deepseek # deepseek | openai | anthropic | sap-ai-sdk\n# apiKey: ${DEEPSEEK_API_KEY}\n# model: deepseek-chat\n# temperature: 0.7\n# streaming: true # false to disable streaming for this provider\n# classifier: # optional; if absent, main config is reused\n# provider: deepseek\n# apiKey: ${DEEPSEEK_API_KEY}\n# model: deepseek-chat\n# temperature: 0.1\n# helper: # optional; if absent, main config is reused\n# provider: deepseek\n# apiKey: ${DEEPSEEK_API_KEY}\n# model: deepseek-chat\n# temperature: 0.1\n#\n# rag:\n# tools:\n# type: qdrant\n# url: http://qdrant:6333\n# embedder: openai # ollama | openai | <custom registered name>\n# model: text-embedding-3-small\n# apiKey: ${OPENAI_API_KEY}\n# history:\n# type: in-memory\n#\n# mcp:\n# - type: http\n# url: http://localhost:3001/mcp/stream/http\n\n# --- Structured Pipeline (optional) -------------------------------------------\n# Replaces the hardcoded orchestration flow with a YAML-defined stage tree.\n# When absent, the default flow runs unchanged (full backwards compatibility).\n#\n# pipeline:\n# version: \"1\"\n# stages:\n# - id: classify\n# type: classify\n# - id: summarize\n# type: summarize\n# - id: rag-retrieval\n# type: parallel\n# when: \"shouldRetrieve\"\n# stages:\n# - { id: translate, type: translate }\n# - { id: expand, type: expand }\n# after:\n# - id: rag-queries\n# type: parallel\n# stages:\n# - { id: tools, type: rag-query, config: { store: tools, k: 10 } }\n# - { id: history, type: rag-query, config: { store: history, k: 5 } }\n# - { id: rerank, type: rerank }\n# - { id: tool-select, type: tool-select }\n# - id: assemble\n# type: assemble\n# - id: tool-loop\n# type: tool-loop\n\n# prompts:\n# system: \"You are a helpful assistant specialized in SAP ABAP development.\"\n# classifier: |\n# You are an intent classifier... (see source for full default prompt)\n# reasoning: |\n# IMPORTANT: Always start your response with a brief <reasoning> block...\n# ragTranslate: |\n# Translate the user request to English for search purposes...\n# historySummary: |\n# Summarize the conversation so far...\n\nlog: smart-server.log # path to log file; omit for stdout\n# logDir: sessions # Directory for detailed session debug logs\n# pluginDir: ./my-plugins # Additional plugin directory (loaded after defaults)\n\n# subagents: # Optional: nested agents callable from pipeline\n# - name: code-reviewer # Used as stage config: { agent: code-reviewer }\n# description: | # Optional. Shown to the Coordinator planner LLM\n# Reviews code and returns # so it can pick this agent for the right step.\n# structured JSON.\n# config: ./agents/code-reviewer.yaml\n\n# coordinator: # Optional: enable autonomous plan-execute loop\n# planning: one-shot # one-shot | replan-on-error | skill-steps\n# dispatch: subagent # subagent | self | hybrid\n# activation: explicit # explicit (default) | auto\n# plannerLlm: main # main | planner | helper (unused by skill-steps)\n# maxSteps: 12\n# maxRetriesPerStep: 1\n# failPolicy: abort # abort | continue\n# maxLayer: 1 # DEPRECATED \u2014 accepted but ignored (nested\n# # dispatch removed; subagents are leaves)\n";
|
|
121
|
+
export declare function resolveEnvVars(value: unknown, env?: NodeJS.ProcessEnv): unknown;
|
|
122
|
+
export declare function loadYamlConfig(filePath: string, env?: NodeJS.ProcessEnv): YamlConfig;
|
|
123
|
+
export declare function generateConfigTemplate(outputPath: string): void;
|
|
124
|
+
export type FinalizerYaml = {
|
|
125
|
+
type?: 'passthrough' | 'llm' | 'template';
|
|
126
|
+
finalizerLlm?: string;
|
|
127
|
+
systemPrompt?: string;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Build the IFinalizer impl from `coordinator.finalizer:` YAML.
|
|
131
|
+
*
|
|
132
|
+
* Lookup chain for `type: llm`:
|
|
133
|
+
* resolveLlmConfig(llmMap, cfg.finalizerLlm, pipelineFallback)
|
|
134
|
+
* → top-level llm.<name> → llm.main → pipelineFallback (pipeline.llm.main)
|
|
135
|
+
* → ConfigError if all three are missing.
|
|
136
|
+
*
|
|
137
|
+
* Absent block / `type: passthrough` → PassthroughFinalizer.
|
|
138
|
+
* `type: template` → TemplateFinalizer.
|
|
139
|
+
*/
|
|
140
|
+
export declare function buildFinalizer(cfg: FinalizerYaml | undefined, llmMap: NormalizedLlmMap | undefined, pipelineFallback: SmartServerLlmConfig | undefined, makeLlm: (config: SmartServerLlmConfig) => Promise<ILlm>): Promise<IFinalizer>;
|
|
141
|
+
export interface ResolveSmartServerConfigOptions {
|
|
142
|
+
/**
|
|
143
|
+
* Filesystem path of the YAML config that produced `yaml`. Required for
|
|
144
|
+
* resolving relative `subagents[].config` paths. When omitted, a `subagents:`
|
|
145
|
+
* block in `yaml` will cause an error.
|
|
146
|
+
*/
|
|
147
|
+
configPath?: string;
|
|
148
|
+
}
|
|
149
|
+
export declare function resolveSmartServerConfig(args?: ResolveConfigArgs, yaml?: YamlConfig, env?: NodeJS.ProcessEnv, options?: ResolveSmartServerConfigOptions): Omit<SmartServerConfig, 'log'>;
|
|
150
|
+
/**
|
|
151
|
+
* Stepper coordinator modes.
|
|
152
|
+
*/
|
|
153
|
+
export type StepperMode = 'cyclic-react' | 'planned-react' | 'deep-stepper';
|
|
154
|
+
/**
|
|
155
|
+
* Configuration for the recursive Stepper coordinator.
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* A node of a declared composition tree. A leaf executes via the executor; a
|
|
159
|
+
* node with a nested `flow` runs as a child Stepper (structural recursion —
|
|
160
|
+
* the sub-cycle is declared and visible).
|
|
161
|
+
*/
|
|
162
|
+
export interface CompositionNode {
|
|
163
|
+
id: string;
|
|
164
|
+
goal: string;
|
|
165
|
+
dependsOn?: string[];
|
|
166
|
+
flow?: StepperCompositionSpec;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Front-end-agnostic description of a Stepper composition. Produced by BOTH the
|
|
170
|
+
* yaml parser (`toCompositionSpec`) and a code builder; consumed by the runtime
|
|
171
|
+
* (`buildFromComposition`). Recursive via `nodes[].flow`.
|
|
172
|
+
*/
|
|
173
|
+
export interface StepperCompositionSpec {
|
|
174
|
+
planner: 'none' | 'llm' | 'static';
|
|
175
|
+
granularity: 'shallow' | 'detailed';
|
|
176
|
+
plan?: PlanNode[];
|
|
177
|
+
/** Declared composition nodes; a node with a nested `flow` is a sub-Stepper. */
|
|
178
|
+
nodes?: CompositionNode[];
|
|
179
|
+
executor: 'simple' | 'cyclic-react' | 'recursive';
|
|
180
|
+
finalizer: 'llm';
|
|
181
|
+
/** Optional system-prompt overrides (consumer-supplied via yaml/builder).
|
|
182
|
+
* Undefined → the built-in STEPPER_PLANNER_SYSTEM / EXECUTOR_SYSTEM. */
|
|
183
|
+
plannerSystemPrompt?: string;
|
|
184
|
+
executorSystemPrompt?: string;
|
|
185
|
+
/** 18.1 Evaluator: ON by default at all depths. Judges (sub-)prompt
|
|
186
|
+
* completeness WITH the RAG context before planning. */
|
|
187
|
+
evaluatorEnabled: boolean;
|
|
188
|
+
evaluatorAtDepths: {
|
|
189
|
+
has(depth: number): boolean;
|
|
190
|
+
};
|
|
191
|
+
evaluatorSystemPrompt?: string;
|
|
192
|
+
reviewerAtDepths: {
|
|
193
|
+
has(depth: number): boolean;
|
|
194
|
+
};
|
|
195
|
+
maxParallelSteps: number;
|
|
196
|
+
maxDepth: number;
|
|
197
|
+
tokenBudget: number;
|
|
198
|
+
formalizeTask: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface StepperCoordinatorConfig {
|
|
201
|
+
mode: StepperMode;
|
|
202
|
+
reviewerAtDepths: {
|
|
203
|
+
has(depth: number): boolean;
|
|
204
|
+
};
|
|
205
|
+
maxParallelSteps: number;
|
|
206
|
+
maxDepth: number;
|
|
207
|
+
tokenBudget: number;
|
|
208
|
+
/**
|
|
209
|
+
* Session-scope knowledge entries written into a NEW session's knowledge-RAG
|
|
210
|
+
* before planning. A deployment/config PARAMETER (not agent code) — the
|
|
211
|
+
* operator fills it with guidance for THEIR actual MCP tools (e.g. which read
|
|
212
|
+
* tool reads what). Surfaced to the planner/executor as "Known facts", and the
|
|
213
|
+
* executor enriches its tool-search query with these facts, so a tool named in
|
|
214
|
+
* a seed takes priority over tools the bare-prompt MCP search would surface.
|
|
215
|
+
* The runtime stays MCP-agnostic: tool knowledge lives here as data.
|
|
216
|
+
*/
|
|
217
|
+
knowledgeSeed: ReadonlyArray<{
|
|
218
|
+
content: string;
|
|
219
|
+
artifactType: string;
|
|
220
|
+
}>;
|
|
221
|
+
/**
|
|
222
|
+
* Opt-in (default false): formalize the raw prompt into a compact TaskSpec
|
|
223
|
+
* (objective + scope + constraints + deliverable) ONCE at the root, then
|
|
224
|
+
* thread it down to every planner and executor as a persistent anchor and as
|
|
225
|
+
* the overall-intent prefix for tool search. Off → behaves exactly as before.
|
|
226
|
+
*/
|
|
227
|
+
formalizeTask: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Resolved program flow (the composition the coordinator runs). Always
|
|
230
|
+
* present: parsed from an explicit `coordinator.flow` block when given, else
|
|
231
|
+
* derived from `mode` as a preset (so `mode` is now just a preset alias).
|
|
232
|
+
*
|
|
233
|
+
* - planner 'none' → trivial single-node plan (node goal = prompt)
|
|
234
|
+
* 'llm' → LlmStepperPlanner (LLM decomposition)
|
|
235
|
+
* 'static' → StaticPlanner (declarative `flow.plan`, no LLM)
|
|
236
|
+
* - executor 'cyclic-react' → leaf ReAct loop, no recursion
|
|
237
|
+
* 'recursive' → may spawn child Steppers up to maxDepth
|
|
238
|
+
* - finalizer 'llm' (RootFinalizer). 'passthrough' is reserved (not yet built).
|
|
239
|
+
*/
|
|
240
|
+
flow: {
|
|
241
|
+
planner: 'none' | 'llm' | 'static';
|
|
242
|
+
/** How much the LLM planner decomposes up front (eager): 'shallow' (few
|
|
243
|
+
* high-level steps) | 'detailed' (full concrete-leaf decomposition).
|
|
244
|
+
* Ignored by 'none'/'static'. Default 'shallow'. */
|
|
245
|
+
granularity: 'shallow' | 'detailed';
|
|
246
|
+
/** Leaf executor profile: 'simple' (single pass) | 'cyclic-react' (ReAct
|
|
247
|
+
* loop) | 'recursive' (spawns child Steppers — lazy decomposition). */
|
|
248
|
+
executor: 'simple' | 'cyclic-react' | 'recursive';
|
|
249
|
+
finalizer: 'llm';
|
|
250
|
+
/** Optional per-role system-prompt overrides:
|
|
251
|
+
* `flow.planner.systemPrompt` / `flow.executor.systemPrompt`. */
|
|
252
|
+
plannerSystemPrompt?: string;
|
|
253
|
+
executorSystemPrompt?: string;
|
|
254
|
+
/** 18.1 Evaluator (ON by default at all depths). Configure via
|
|
255
|
+
* `flow.evaluator: { enabled?, atDepths?, systemPrompt? }`. */
|
|
256
|
+
evaluatorEnabled: boolean;
|
|
257
|
+
evaluatorAtDepths: {
|
|
258
|
+
has(depth: number): boolean;
|
|
259
|
+
};
|
|
260
|
+
evaluatorSystemPrompt?: string;
|
|
261
|
+
/** Declarative plan nodes, required when planner === 'static'. */
|
|
262
|
+
plan?: PlanNode[];
|
|
263
|
+
/**
|
|
264
|
+
* Declared composition nodes (the "yaml is a tree" shape). A node with a
|
|
265
|
+
* nested `flow` is a sub-Stepper. When present at the root, the planner is
|
|
266
|
+
* effectively static over these nodes.
|
|
267
|
+
*/
|
|
268
|
+
nodes?: CompositionNode[];
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Parse stepper coordinator configuration from a raw config object.
|
|
273
|
+
*
|
|
274
|
+
* Supports:
|
|
275
|
+
* - `mode` (string) — default 'planned-react'; one of cyclic-react | planned-react
|
|
276
|
+
* - `stepper.maxParallelSteps` (number) — default 4
|
|
277
|
+
* - `stepper.maxDepth` (number) — default 4
|
|
278
|
+
* - `stepper.tokenBudget` (number) — default 1,000,000
|
|
279
|
+
* - `stepper.reviewer.atDepths` (number[] | 'all') — default [0,1]; 'all' means accept any depth
|
|
280
|
+
*/
|
|
281
|
+
export declare function parseStepperCoordinatorConfig(coord: Record<string, unknown>): StepperCoordinatorConfig;
|
|
282
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/smart-agent/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EACV,UAAU,EACV,IAAI,EACJ,uBAAu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