@mcp-abap-adt/llm-agent-libs 16.2.0 → 18.0.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/dist/adapters/llm-provider-bridge.js +2 -2
- package/dist/adapters/llm-provider-bridge.js.map +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +48 -37
- package/dist/agent.js.map +1 -1
- package/dist/builder.d.ts +19 -0
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +29 -3
- package/dist/builder.js.map +1 -1
- package/dist/classifier/llm-classifier.d.ts.map +1 -1
- package/dist/classifier/llm-classifier.js +1 -0
- package/dist/classifier/llm-classifier.js.map +1 -1
- package/dist/coordinator/dag/abort-error-strategy.d.ts +7 -0
- package/dist/coordinator/dag/abort-error-strategy.d.ts.map +1 -0
- package/dist/coordinator/dag/abort-error-strategy.js +8 -0
- package/dist/coordinator/dag/abort-error-strategy.js.map +1 -0
- package/dist/coordinator/dag/compose-node-task.d.ts +8 -0
- package/dist/coordinator/dag/compose-node-task.d.ts.map +1 -0
- package/dist/coordinator/dag/compose-node-task.js +41 -0
- package/dist/coordinator/dag/compose-node-task.js.map +1 -0
- package/dist/coordinator/dag/dag-plan-interpreter.d.ts +9 -0
- package/dist/coordinator/dag/dag-plan-interpreter.d.ts.map +1 -0
- package/dist/coordinator/dag/dag-plan-interpreter.js +236 -0
- package/dist/coordinator/dag/dag-plan-interpreter.js.map +1 -0
- package/dist/coordinator/dag/index.d.ts +5 -0
- package/dist/coordinator/dag/index.d.ts.map +1 -0
- package/dist/coordinator/dag/index.js +5 -0
- package/dist/coordinator/dag/index.js.map +1 -0
- package/dist/coordinator/dag/llm-dag-planner.d.ts +24 -0
- package/dist/coordinator/dag/llm-dag-planner.d.ts.map +1 -0
- package/dist/coordinator/dag/llm-dag-planner.js +161 -0
- package/dist/coordinator/dag/llm-dag-planner.js.map +1 -0
- package/dist/coordinator/dag/llm-finalizer.d.ts +21 -0
- package/dist/coordinator/dag/llm-finalizer.d.ts.map +1 -0
- package/dist/coordinator/dag/llm-finalizer.js +77 -0
- package/dist/coordinator/dag/llm-finalizer.js.map +1 -0
- package/dist/coordinator/dag/llm-review-strategy.d.ts +17 -0
- package/dist/coordinator/dag/llm-review-strategy.d.ts.map +1 -0
- package/dist/coordinator/dag/llm-review-strategy.js +149 -0
- package/dist/coordinator/dag/llm-review-strategy.js.map +1 -0
- package/dist/coordinator/dag/noop-review-strategy.d.ts +8 -0
- package/dist/coordinator/dag/noop-review-strategy.d.ts.map +1 -0
- package/dist/coordinator/dag/noop-review-strategy.js +11 -0
- package/dist/coordinator/dag/noop-review-strategy.js.map +1 -0
- package/dist/coordinator/dag/passthrough-finalizer.d.ts +11 -0
- package/dist/coordinator/dag/passthrough-finalizer.d.ts.map +1 -0
- package/dist/coordinator/dag/passthrough-finalizer.js +13 -0
- package/dist/coordinator/dag/passthrough-finalizer.js.map +1 -0
- package/dist/coordinator/dag/render-ancestor-context.d.ts +8 -0
- package/dist/coordinator/dag/render-ancestor-context.d.ts.map +1 -0
- package/dist/coordinator/dag/render-ancestor-context.js +27 -0
- package/dist/coordinator/dag/render-ancestor-context.js.map +1 -0
- package/dist/coordinator/dag/replan-error-strategy.d.ts +15 -0
- package/dist/coordinator/dag/replan-error-strategy.d.ts.map +1 -0
- package/dist/coordinator/dag/replan-error-strategy.js +32 -0
- package/dist/coordinator/dag/replan-error-strategy.js.map +1 -0
- package/dist/coordinator/dag/reviewer-error-strategy.d.ts +15 -0
- package/dist/coordinator/dag/reviewer-error-strategy.d.ts.map +1 -0
- package/dist/coordinator/dag/reviewer-error-strategy.js +38 -0
- package/dist/coordinator/dag/reviewer-error-strategy.js.map +1 -0
- package/dist/coordinator/dag/splice-sub-plan.d.ts +12 -0
- package/dist/coordinator/dag/splice-sub-plan.d.ts.map +1 -0
- package/dist/coordinator/dag/splice-sub-plan.js +41 -0
- package/dist/coordinator/dag/splice-sub-plan.js.map +1 -0
- package/dist/coordinator/dag/subagent-state-oracle.d.ts +19 -0
- package/dist/coordinator/dag/subagent-state-oracle.d.ts.map +1 -0
- package/dist/coordinator/dag/subagent-state-oracle.js +31 -0
- package/dist/coordinator/dag/subagent-state-oracle.js.map +1 -0
- package/dist/coordinator/dag/template-finalizer.d.ts +11 -0
- package/dist/coordinator/dag/template-finalizer.d.ts.map +1 -0
- package/dist/coordinator/dag/template-finalizer.js +17 -0
- package/dist/coordinator/dag/template-finalizer.js.map +1 -0
- package/dist/coordinator/dispatch/subagent.d.ts.map +1 -1
- package/dist/coordinator/dispatch/subagent.js +6 -12
- package/dist/coordinator/dispatch/subagent.js.map +1 -1
- package/dist/coordinator/index.d.ts +6 -0
- package/dist/coordinator/index.d.ts.map +1 -1
- package/dist/coordinator/index.js +6 -0
- package/dist/coordinator/index.js.map +1 -1
- package/dist/coordinator/planning/one-shot.d.ts.map +1 -1
- package/dist/coordinator/planning/one-shot.js +14 -7
- package/dist/coordinator/planning/one-shot.js.map +1 -1
- package/dist/coordinator/stepper/cyclic-react-executor.d.ts +42 -0
- package/dist/coordinator/stepper/cyclic-react-executor.d.ts.map +1 -0
- package/dist/coordinator/stepper/cyclic-react-executor.js +272 -0
- package/dist/coordinator/stepper/cyclic-react-executor.js.map +1 -0
- package/dist/coordinator/stepper/index.d.ts +10 -0
- package/dist/coordinator/stepper/index.d.ts.map +1 -0
- package/dist/coordinator/stepper/index.js +10 -0
- package/dist/coordinator/stepper/index.js.map +1 -0
- package/dist/coordinator/stepper/llm-stepper-planner.d.ts +27 -0
- package/dist/coordinator/stepper/llm-stepper-planner.d.ts.map +1 -0
- package/dist/coordinator/stepper/llm-stepper-planner.js +86 -0
- package/dist/coordinator/stepper/llm-stepper-planner.js.map +1 -0
- package/dist/coordinator/stepper/llm-task-formalizer.d.ts +22 -0
- package/dist/coordinator/stepper/llm-task-formalizer.d.ts.map +1 -0
- package/dist/coordinator/stepper/llm-task-formalizer.js +73 -0
- package/dist/coordinator/stepper/llm-task-formalizer.js.map +1 -0
- package/dist/coordinator/stepper/logging-llm.d.ts +30 -0
- package/dist/coordinator/stepper/logging-llm.d.ts.map +1 -0
- package/dist/coordinator/stepper/logging-llm.js +73 -0
- package/dist/coordinator/stepper/logging-llm.js.map +1 -0
- package/dist/coordinator/stepper/need-resolver.d.ts +18 -0
- package/dist/coordinator/stepper/need-resolver.d.ts.map +1 -0
- package/dist/coordinator/stepper/need-resolver.js +42 -0
- package/dist/coordinator/stepper/need-resolver.js.map +1 -0
- package/dist/coordinator/stepper/root-finalizer.d.ts +17 -0
- package/dist/coordinator/stepper/root-finalizer.d.ts.map +1 -0
- package/dist/coordinator/stepper/root-finalizer.js +53 -0
- package/dist/coordinator/stepper/root-finalizer.js.map +1 -0
- package/dist/coordinator/stepper/static-planner.d.ts +23 -0
- package/dist/coordinator/stepper/static-planner.d.ts.map +1 -0
- package/dist/coordinator/stepper/static-planner.js +25 -0
- package/dist/coordinator/stepper/static-planner.js.map +1 -0
- package/dist/coordinator/stepper/stepper-interpreter.d.ts +6 -0
- package/dist/coordinator/stepper/stepper-interpreter.d.ts.map +1 -0
- package/dist/coordinator/stepper/stepper-interpreter.js +130 -0
- package/dist/coordinator/stepper/stepper-interpreter.js.map +1 -0
- package/dist/coordinator/stepper/stepper.d.ts +36 -0
- package/dist/coordinator/stepper/stepper.d.ts.map +1 -0
- package/dist/coordinator/stepper/stepper.js +49 -0
- package/dist/coordinator/stepper/stepper.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/default-request-logger.d.ts +18 -6
- package/dist/logger/default-request-logger.d.ts.map +1 -1
- package/dist/logger/default-request-logger.js +25 -4
- package/dist/logger/default-request-logger.js.map +1 -1
- package/dist/logger/noop-request-logger.d.ts +10 -5
- package/dist/logger/noop-request-logger.d.ts.map +1 -1
- package/dist/logger/noop-request-logger.js +5 -3
- package/dist/logger/noop-request-logger.js.map +1 -1
- package/dist/logger/session-request-logger.d.ts +50 -0
- package/dist/logger/session-request-logger.d.ts.map +1 -0
- package/dist/logger/session-request-logger.js +161 -0
- package/dist/logger/session-request-logger.js.map +1 -0
- package/dist/pipeline/context.d.ts +8 -3
- package/dist/pipeline/context.d.ts.map +1 -1
- package/dist/pipeline/default-pipeline.d.ts +35 -4
- package/dist/pipeline/default-pipeline.d.ts.map +1 -1
- package/dist/pipeline/default-pipeline.js +49 -7
- package/dist/pipeline/default-pipeline.js.map +1 -1
- package/dist/pipeline/handlers/coordinator.d.ts +0 -3
- package/dist/pipeline/handlers/coordinator.d.ts.map +1 -1
- package/dist/pipeline/handlers/coordinator.js +33 -22
- package/dist/pipeline/handlers/coordinator.js.map +1 -1
- package/dist/pipeline/handlers/dag-coordinator.d.ts +47 -0
- package/dist/pipeline/handlers/dag-coordinator.d.ts.map +1 -0
- package/dist/pipeline/handlers/dag-coordinator.js +369 -0
- package/dist/pipeline/handlers/dag-coordinator.js.map +1 -0
- package/dist/pipeline/handlers/index.d.ts +14 -0
- package/dist/pipeline/handlers/index.d.ts.map +1 -1
- package/dist/pipeline/handlers/index.js +8 -1
- package/dist/pipeline/handlers/index.js.map +1 -1
- package/dist/pipeline/handlers/rag-query.d.ts.map +1 -1
- package/dist/pipeline/handlers/rag-query.js +1 -0
- package/dist/pipeline/handlers/rag-query.js.map +1 -1
- package/dist/pipeline/handlers/subagent.d.ts.map +1 -1
- package/dist/pipeline/handlers/subagent.js +0 -2
- package/dist/pipeline/handlers/subagent.js.map +1 -1
- package/dist/pipeline/handlers/summarize.d.ts.map +1 -1
- package/dist/pipeline/handlers/summarize.js +5 -0
- package/dist/pipeline/handlers/summarize.js.map +1 -1
- package/dist/pipeline/handlers/tool-loop.d.ts.map +1 -1
- package/dist/pipeline/handlers/tool-loop.js +17 -0
- package/dist/pipeline/handlers/tool-loop.js.map +1 -1
- package/dist/pipeline/handlers/translate.d.ts.map +1 -1
- package/dist/pipeline/handlers/translate.js +1 -0
- package/dist/pipeline/handlers/translate.js.map +1 -1
- package/dist/pipeline/index.d.ts +2 -1
- package/dist/pipeline/index.d.ts.map +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/pipeline/index.js.map +1 -1
- package/dist/rag/knowledge-rag.d.ts +74 -0
- package/dist/rag/knowledge-rag.d.ts.map +1 -0
- package/dist/rag/knowledge-rag.js +116 -0
- package/dist/rag/knowledge-rag.js.map +1 -0
- package/dist/session/session-graph-factory.d.ts +66 -0
- package/dist/session/session-graph-factory.d.ts.map +1 -0
- package/dist/session/session-graph-factory.js +63 -0
- package/dist/session/session-graph-factory.js.map +1 -0
- package/dist/session/session-graph.d.ts +54 -0
- package/dist/session/session-graph.d.ts.map +1 -0
- package/dist/session/session-graph.js +76 -0
- package/dist/session/session-graph.js.map +1 -0
- package/dist/session/session-registry.d.ts +96 -0
- package/dist/session/session-registry.d.ts.map +1 -0
- package/dist/session/session-registry.js +297 -0
- package/dist/session/session-registry.js.map +1 -0
- package/dist/subagent/direct-llm-subagent.d.ts.map +1 -1
- package/dist/subagent/direct-llm-subagent.js +0 -2
- package/dist/subagent/direct-llm-subagent.js.map +1 -1
- package/dist/subagent/smart-agent-subagent.d.ts.map +1 -1
- package/dist/subagent/smart-agent-subagent.js +3 -3
- package/dist/subagent/smart-agent-subagent.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An ILlm decorator that reports token usage after every `chat` or `streamChat`
|
|
3
|
+
* call via an injected `logUsage` callback. This is the authoritative path for
|
|
4
|
+
* per-role usage logging in the Stepper runtime — it ensures every role's LLM
|
|
5
|
+
* call is captured in the request-scoped byComponent breakdown regardless of
|
|
6
|
+
* whether the role is the executor, planner, reviewer, or finalizer.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const logged = new LoggingLlm(innerLlm, (u, d) =>
|
|
10
|
+
* requestLogger.logLlmCall({ component: 'planner', model, ...u, durationMs: d })
|
|
11
|
+
* );
|
|
12
|
+
*
|
|
13
|
+
* For `streamChat`, usage is accumulated from stream chunks and logged once the
|
|
14
|
+
* stream ends.
|
|
15
|
+
*/
|
|
16
|
+
export class LoggingLlm {
|
|
17
|
+
inner;
|
|
18
|
+
logUsage;
|
|
19
|
+
constructor(inner,
|
|
20
|
+
/** Called once per LLM invocation with the accumulated usage and duration. */
|
|
21
|
+
logUsage) {
|
|
22
|
+
this.inner = inner;
|
|
23
|
+
this.logUsage = logUsage;
|
|
24
|
+
}
|
|
25
|
+
get model() {
|
|
26
|
+
return this.inner.model;
|
|
27
|
+
}
|
|
28
|
+
async chat(messages, tools, options) {
|
|
29
|
+
const start = Date.now();
|
|
30
|
+
const result = await this.inner.chat(messages, tools, options);
|
|
31
|
+
const durationMs = Date.now() - start;
|
|
32
|
+
if (result.ok && result.value.usage) {
|
|
33
|
+
this.logUsage(result.value.usage, durationMs);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
async *streamChat(messages, tools, options) {
|
|
38
|
+
const start = Date.now();
|
|
39
|
+
let accPrompt = 0;
|
|
40
|
+
let accCompletion = 0;
|
|
41
|
+
let accTotal = 0;
|
|
42
|
+
let hasUsage = false;
|
|
43
|
+
for await (const chunk of this.inner.streamChat(messages, tools, options)) {
|
|
44
|
+
if (chunk.ok && chunk.value.usage) {
|
|
45
|
+
accPrompt += chunk.value.usage.promptTokens;
|
|
46
|
+
accCompletion += chunk.value.usage.completionTokens;
|
|
47
|
+
accTotal += chunk.value.usage.totalTokens;
|
|
48
|
+
hasUsage = true;
|
|
49
|
+
}
|
|
50
|
+
yield chunk;
|
|
51
|
+
}
|
|
52
|
+
if (hasUsage) {
|
|
53
|
+
this.logUsage({
|
|
54
|
+
promptTokens: accPrompt,
|
|
55
|
+
completionTokens: accCompletion,
|
|
56
|
+
totalTokens: accTotal,
|
|
57
|
+
}, Date.now() - start);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
healthCheck(options) {
|
|
61
|
+
// Optional passthrough: this method exists on the decorator only to forward
|
|
62
|
+
// to the inner LLM's optional healthCheck. `?.` is not usable (the return
|
|
63
|
+
// type is non-optional), so assert — the decorator's method is only invoked
|
|
64
|
+
// when the inner implements it.
|
|
65
|
+
// biome-ignore lint/style/noNonNullAssertion: decorator passthrough to inner's optional method
|
|
66
|
+
return this.inner.healthCheck(options);
|
|
67
|
+
}
|
|
68
|
+
getModels(options) {
|
|
69
|
+
// biome-ignore lint/style/noNonNullAssertion: decorator passthrough to inner's optional method
|
|
70
|
+
return this.inner.getModels(options);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=logging-llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging-llm.js","sourceRoot":"","sources":["../../../src/coordinator/stepper/logging-llm.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,UAAU;IAEF;IAEA;IAHnB,YACmB,KAAW;IAC5B,8EAA8E;IAC7D,QAAuD;QAFvD,UAAK,GAAL,KAAK,CAAM;QAEX,aAAQ,GAAR,QAAQ,CAA+C;IACvE,CAAC;IAEJ,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,IAAI,CACR,QAAmB,EACnB,KAAiB,EACjB,OAAqB;QAErB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACtC,IAAI,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,E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IAED,SAAS,CACP,OAAqB;QAErB,+FAA+F;QAC/F,OAAO,IAAI,CAAC,KAAK,CAAC,SAAU,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ILlm, INeedResolver } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
/** Deterministic need detector. Pattern-matches "I can't <X>" / "I need to
|
|
3
|
+
* <X>" and maps the captured phrase to a tools-RAG query. Default. */
|
|
4
|
+
export declare class RegexNeedResolver implements INeedResolver {
|
|
5
|
+
resolve(response: string): Promise<{
|
|
6
|
+
queryToolsRag: string;
|
|
7
|
+
} | undefined>;
|
|
8
|
+
}
|
|
9
|
+
/** LLM-driven need classifier. Opt-in (more accurate on paraphrase, costs a
|
|
10
|
+
* small classifier call). */
|
|
11
|
+
export declare class LlmNeedResolver implements INeedResolver {
|
|
12
|
+
private readonly llm;
|
|
13
|
+
constructor(llm: ILlm);
|
|
14
|
+
resolve(response: string): Promise<{
|
|
15
|
+
queryToolsRag: string;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=need-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"need-resolver.d.ts","sourceRoot":"","sources":["../../../src/coordinator/stepper/need-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAKnE;uEACuE;AACvE,qBAAa,iBAAkB,YAAW,aAAa;IAC/C,OAAO,CAAC,QAAQ,EAAE,MAAM;;;CAM/B;AAQD;8BAC8B;AAC9B,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,IAAI;IAChC,OAAO,CAAC,QAAQ,EAAE,MAAM;;;CAqB/B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const NEED_RE = /\bI (?:can'?t|cannot|am unable to|need to|lack (?:a|the) (?:tool|way) to)\s+(.+?)[.!]?$/i;
|
|
2
|
+
/** Deterministic need detector. Pattern-matches "I can't <X>" / "I need to
|
|
3
|
+
* <X>" and maps the captured phrase to a tools-RAG query. Default. */
|
|
4
|
+
export class RegexNeedResolver {
|
|
5
|
+
async resolve(response) {
|
|
6
|
+
const line = response.trim().split('\n').pop() ?? response.trim();
|
|
7
|
+
const m = NEED_RE.exec(line);
|
|
8
|
+
if (!m)
|
|
9
|
+
return undefined;
|
|
10
|
+
return { queryToolsRag: m[1].trim() };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const CLASSIFY_SYSTEM = 'Classify whether the assistant utterance expresses an unmet capability ' +
|
|
14
|
+
'need (it cannot proceed because it lacks a tool or data). Respond with ' +
|
|
15
|
+
'ONLY JSON: {"need":boolean,"capability":string}. capability is the ' +
|
|
16
|
+
'short description of what is needed, or "" when need is false.';
|
|
17
|
+
/** LLM-driven need classifier. Opt-in (more accurate on paraphrase, costs a
|
|
18
|
+
* small classifier call). */
|
|
19
|
+
export class LlmNeedResolver {
|
|
20
|
+
llm;
|
|
21
|
+
constructor(llm) {
|
|
22
|
+
this.llm = llm;
|
|
23
|
+
}
|
|
24
|
+
async resolve(response) {
|
|
25
|
+
const res = await this.llm.chat([
|
|
26
|
+
{ role: 'system', content: CLASSIFY_SYSTEM },
|
|
27
|
+
{ role: 'user', content: response },
|
|
28
|
+
], []);
|
|
29
|
+
if (res.ok === false)
|
|
30
|
+
return undefined;
|
|
31
|
+
try {
|
|
32
|
+
const parsed = JSON.parse(res.value.content);
|
|
33
|
+
if (parsed.need && parsed.capability)
|
|
34
|
+
return { queryToolsRag: parsed.capability };
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// ignore malformed classifier output → treat as no need
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=need-resolver.js.map
|
|
@@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MAAM,CAAC,UAAU;gBAClC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,wDAAwD;QAC1D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type IKnowledgeRagHandle, type ILlm, type LlmUsage, type StreamChunk } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
export declare class RootFinalizer {
|
|
3
|
+
private readonly llm;
|
|
4
|
+
constructor(llm: ILlm);
|
|
5
|
+
finalize(input: {
|
|
6
|
+
prompt: string;
|
|
7
|
+
knowledgeRag: IKnowledgeRagHandle;
|
|
8
|
+
turnId: string;
|
|
9
|
+
scope?: 'turn' | 'session';
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
onProgress?: (event: StreamChunk) => void;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
output: string;
|
|
14
|
+
usage?: LlmUsage;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=root-finalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-finalizer.d.ts","sourceRoot":"","sources":["../../../src/coordinator/stepper/root-finalizer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,IAAI,EAET,KAAK,QAAQ,EACb,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAMjC,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,IAAI;IAEhC,QAAQ,CAAC,KAAK,EAAE;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,mBAAmB,CAAC;QAClC,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;KAC3C,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC;CAgClD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InsufficientSignal, } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
const FINALIZER_SYSTEM = `You compose the final answer for the consumer from the provided knowledge entries.
|
|
3
|
+
If the entries contain enough information, write the answer directly in clean Markdown.
|
|
4
|
+
If a REQUIRED fact is missing, respond with ONLY JSON: {"insufficient":["<missing item>", ...]} and nothing else.`;
|
|
5
|
+
export class RootFinalizer {
|
|
6
|
+
llm;
|
|
7
|
+
constructor(llm) {
|
|
8
|
+
this.llm = llm;
|
|
9
|
+
}
|
|
10
|
+
async finalize(input) {
|
|
11
|
+
const filter = input.scope === 'session' ? {} : { turnId: input.turnId };
|
|
12
|
+
const entries = await input.knowledgeRag.list(filter);
|
|
13
|
+
const knowledge = entries
|
|
14
|
+
.map((e, i) => `[${i + 1}] (${e.metadata.artifactType}) ${e.content}`)
|
|
15
|
+
.join('\n\n');
|
|
16
|
+
const user = `Consumer request:\n${input.prompt}\n\nKnowledge entries:\n${knowledge || '(none)'}`;
|
|
17
|
+
let buf = '';
|
|
18
|
+
let usage;
|
|
19
|
+
for await (const chunk of this.llm.streamChat([
|
|
20
|
+
{ role: 'system', content: FINALIZER_SYSTEM },
|
|
21
|
+
{ role: 'user', content: user },
|
|
22
|
+
], [], { signal: input.signal })) {
|
|
23
|
+
if (chunk.ok === false)
|
|
24
|
+
throw new Error(chunk.error?.message ?? 'finalizer stream error');
|
|
25
|
+
const delta = chunk.value.content ?? '';
|
|
26
|
+
if (delta) {
|
|
27
|
+
buf += delta;
|
|
28
|
+
input.onProgress?.({ kind: 'content', delta });
|
|
29
|
+
}
|
|
30
|
+
if (chunk.value.usage)
|
|
31
|
+
usage = chunk.value.usage;
|
|
32
|
+
}
|
|
33
|
+
const insufficient = tryParseInsufficient(buf);
|
|
34
|
+
if (insufficient)
|
|
35
|
+
throw new InsufficientSignal(insufficient, usage);
|
|
36
|
+
return { output: buf, usage };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function tryParseInsufficient(text) {
|
|
40
|
+
const trimmed = text.trim();
|
|
41
|
+
if (!trimmed.startsWith('{'))
|
|
42
|
+
return undefined;
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(trimmed);
|
|
45
|
+
if (Array.isArray(parsed.insufficient))
|
|
46
|
+
return parsed.insufficient.map(String);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// not the insufficient marker → treat as a normal answer
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=root-finalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-finalizer.js","sourceRoot":"","sources":["../../../src/coordinator/stepper/root-finalizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,GAGnB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,gBAAgB,GAAG;;kHAEyF,CAAC;AAEnH,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,GAAS;QAAT,QAAG,GAAH,GAAG,CAAM;IAAG,CAAC;IAE1C,KAAK,CAAC,QAAQ,CAAC,KAOd;QACC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QACzE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,OAAO;aACtB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,MAA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SAAS,oBAAoB,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA+B,CAAC;QACjE,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;YACpC,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,yDAAyD;IAC3D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DagPlan, IStepperPlanner, PlanNode } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
/**
|
|
3
|
+
* StaticPlanner — emits a plan declared in yaml (`coordinator.flow.plan`)
|
|
4
|
+
* verbatim, with NO LLM call. This is the declarative end of the plan-depth
|
|
5
|
+
* axis: the operator describes the exact sequence of node goals + dependencies
|
|
6
|
+
* and the interpreter walks it. Deterministic, fully inspectable from the
|
|
7
|
+
* config (answers "what is the system doing" without a trace).
|
|
8
|
+
*
|
|
9
|
+
* The objective is taken from the formalized TaskSpec when present, else from
|
|
10
|
+
* the incoming prompt — so the executor anchor and the plan share one objective.
|
|
11
|
+
*/
|
|
12
|
+
export declare class StaticPlanner implements IStepperPlanner {
|
|
13
|
+
private readonly nodes;
|
|
14
|
+
readonly name = "static";
|
|
15
|
+
constructor(nodes: readonly PlanNode[]);
|
|
16
|
+
plan(input: {
|
|
17
|
+
prompt: string;
|
|
18
|
+
taskSpec?: {
|
|
19
|
+
objective: string;
|
|
20
|
+
};
|
|
21
|
+
}): Promise<DagPlan>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=static-planner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-planner.d.ts","sourceRoot":"","sources":["../../../src/coordinator/stepper/static-planner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;GASG;AACH,qBAAa,aAAc,YAAW,eAAe;IAGvC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,QAAQ,CAAC,IAAI,YAAY;gBAEI,KAAK,EAAE,SAAS,QAAQ,EAAE;IAEjD,IAAI,CAAC,KAAK,EAAE;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;KAClC,GAAG,OAAO,CAAC,OAAO,CAAC;CAOrB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StaticPlanner — emits a plan declared in yaml (`coordinator.flow.plan`)
|
|
3
|
+
* verbatim, with NO LLM call. This is the declarative end of the plan-depth
|
|
4
|
+
* axis: the operator describes the exact sequence of node goals + dependencies
|
|
5
|
+
* and the interpreter walks it. Deterministic, fully inspectable from the
|
|
6
|
+
* config (answers "what is the system doing" without a trace).
|
|
7
|
+
*
|
|
8
|
+
* The objective is taken from the formalized TaskSpec when present, else from
|
|
9
|
+
* the incoming prompt — so the executor anchor and the plan share one objective.
|
|
10
|
+
*/
|
|
11
|
+
export class StaticPlanner {
|
|
12
|
+
nodes;
|
|
13
|
+
name = 'static';
|
|
14
|
+
constructor(nodes) {
|
|
15
|
+
this.nodes = nodes;
|
|
16
|
+
}
|
|
17
|
+
async plan(input) {
|
|
18
|
+
return {
|
|
19
|
+
objective: input.taskSpec?.objective ?? input.prompt,
|
|
20
|
+
nodes: this.nodes.map((n) => ({ ...n })),
|
|
21
|
+
createdAt: 0,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=static-planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-planner.js","sourceRoot":"","sources":["../../../src/coordinator/stepper/static-planner.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAGK;IAFpB,IAAI,GAAG,QAAQ,CAAC;IAEzB,YAA6B,KAA0B;QAA1B,UAAK,GAAL,KAAK,CAAqB;IAAG,CAAC;IAE3D,KAAK,CAAC,IAAI,CAAC,KAGV;QACC,OAAO;YACL,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,IAAI,KAAK,CAAC,MAAM;YACpD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YACxC,SAAS,EAAE,CAAC;SACb,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DagPlan, IStepperInterpreter, IStepperResult } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
export declare class StepperInterpreter implements IStepperInterpreter {
|
|
3
|
+
readonly name = "stepper";
|
|
4
|
+
interpret(plan: DagPlan, ctx: Parameters<IStepperInterpreter['interpret']>[1]): Promise<IStepperResult>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=stepper-interpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper-interpreter.d.ts","sourceRoot":"","sources":["../../../src/coordinator/stepper/stepper-interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EACnB,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAUjC,qBAAa,kBAAmB,YAAW,mBAAmB;IAC5D,QAAQ,CAAC,IAAI,aAAa;IAEpB,SAAS,CACb,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,UAAU,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GACnD,OAAO,CAAC,cAAc,CAAC;CAmH3B"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const ZERO = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
2
|
+
const addUsage = (a, b) => ({
|
|
3
|
+
promptTokens: a.promptTokens + b.promptTokens,
|
|
4
|
+
completionTokens: a.completionTokens + b.completionTokens,
|
|
5
|
+
totalTokens: a.totalTokens + b.totalTokens,
|
|
6
|
+
});
|
|
7
|
+
const WORST = { ok: 0, incomplete: 1, 'budget-exhausted': 2 };
|
|
8
|
+
export class StepperInterpreter {
|
|
9
|
+
name = 'stepper';
|
|
10
|
+
async interpret(plan, ctx) {
|
|
11
|
+
const done = new Set();
|
|
12
|
+
const results = new Map();
|
|
13
|
+
let usage = ZERO;
|
|
14
|
+
let worst = 'ok';
|
|
15
|
+
const ready = () => plan.nodes.filter((n) => !done.has(n.id) && (n.dependsOn ?? []).every((d) => done.has(d)));
|
|
16
|
+
const runNode = async (node) => {
|
|
17
|
+
const childId = ctx.mintStepperId();
|
|
18
|
+
const childIdentity = {
|
|
19
|
+
...ctx.identity,
|
|
20
|
+
stepperId: childId,
|
|
21
|
+
parentStepperId: ctx.identity.stepperId,
|
|
22
|
+
};
|
|
23
|
+
const subagent = node.agent
|
|
24
|
+
? ctx.childSteppers.get(node.agent)
|
|
25
|
+
: undefined;
|
|
26
|
+
// Decide the route FIRST, then build the ref name accordingly (review R6-F2):
|
|
27
|
+
// a node with agent 'w' that is below the depth floor routes to the executor,
|
|
28
|
+
// so its spawned event must say 'executor', not 'w'.
|
|
29
|
+
const willRecurse = Boolean(node.agent && subagent && ctx.budget.depthRemaining > 0);
|
|
30
|
+
const refName = willRecurse ? node.agent : 'executor';
|
|
31
|
+
const ref = {
|
|
32
|
+
stepperId: childId,
|
|
33
|
+
parentStepperId: ctx.identity.stepperId,
|
|
34
|
+
name: refName,
|
|
35
|
+
};
|
|
36
|
+
ctx.onProgress?.({
|
|
37
|
+
kind: 'stepper-spawned',
|
|
38
|
+
source: ref,
|
|
39
|
+
goal: node.goal,
|
|
40
|
+
});
|
|
41
|
+
let result;
|
|
42
|
+
if (willRecurse && subagent) {
|
|
43
|
+
// Case 1 — recursive child Stepper. depthRemaining is a per-branch
|
|
44
|
+
// value (decremented), but tokens is the SAME shared ledger reference
|
|
45
|
+
// (review R2-F1) so spend is accounted across all branches (soft cap,
|
|
46
|
+
// bounded overshoot under parallelism — review R3-F2).
|
|
47
|
+
result = await subagent.run({
|
|
48
|
+
prompt: composeTask(node, plan),
|
|
49
|
+
knowledgeRag: ctx.knowledgeRag,
|
|
50
|
+
toolsRag: ctx.toolsRag,
|
|
51
|
+
budget: {
|
|
52
|
+
depthRemaining: ctx.budget.depthRemaining - 1,
|
|
53
|
+
tokens: ctx.budget.tokens,
|
|
54
|
+
},
|
|
55
|
+
identity: childIdentity,
|
|
56
|
+
taskSpec: ctx.taskSpec,
|
|
57
|
+
signal: ctx.signal,
|
|
58
|
+
sessionLogger: ctx.sessionLogger,
|
|
59
|
+
onProgress: ctx.onProgress,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else if (ctx.executor) {
|
|
63
|
+
// Case 2 (depth floor) + Case 3 (no agent) — terminal executor leaf
|
|
64
|
+
const r = await ctx.executor.execute({
|
|
65
|
+
prompt: composeTask(node, plan),
|
|
66
|
+
tools: [],
|
|
67
|
+
knowledgeRag: ctx.knowledgeRag,
|
|
68
|
+
toolsRag: ctx.toolsRag,
|
|
69
|
+
budget: ctx.budget,
|
|
70
|
+
identity: childIdentity,
|
|
71
|
+
taskSpec: ctx.taskSpec,
|
|
72
|
+
signal: ctx.signal,
|
|
73
|
+
sessionLogger: ctx.sessionLogger,
|
|
74
|
+
onProgress: ctx.onProgress,
|
|
75
|
+
});
|
|
76
|
+
result = { status: r.status, missing: r.missing, usage: r.usage };
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Case 4 — nothing can execute this node
|
|
80
|
+
result = {
|
|
81
|
+
status: 'incomplete',
|
|
82
|
+
missing: [
|
|
83
|
+
`node '${node.id}' references unknown agent '${node.agent}' and no executor is available`,
|
|
84
|
+
],
|
|
85
|
+
usage: ZERO,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
ctx.onProgress?.({
|
|
89
|
+
kind: 'stepper-done',
|
|
90
|
+
source: ref,
|
|
91
|
+
ok: result.status === 'ok',
|
|
92
|
+
});
|
|
93
|
+
results.set(node.id, result);
|
|
94
|
+
done.add(node.id);
|
|
95
|
+
usage = addUsage(usage, result.usage);
|
|
96
|
+
if (WORST[result.status] > WORST[worst])
|
|
97
|
+
worst = result.status;
|
|
98
|
+
};
|
|
99
|
+
// Wave scheduler with a maxParallelSteps pool.
|
|
100
|
+
// Each wave: collect all ready nodes, then execute them in batches of `cap`
|
|
101
|
+
// to ensure peak concurrency never exceeds the cap.
|
|
102
|
+
while (done.size < plan.nodes.length) {
|
|
103
|
+
const batch = ready();
|
|
104
|
+
if (batch.length === 0)
|
|
105
|
+
break; // dependency deadlock — shouldn't happen with valid plans
|
|
106
|
+
const cap = Math.max(1, ctx.maxParallelSteps || 1);
|
|
107
|
+
for (let i = 0; i < batch.length; i += cap) {
|
|
108
|
+
await Promise.all(batch.slice(i, i + cap).map(runNode));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
status: worst,
|
|
113
|
+
usage,
|
|
114
|
+
...(worst !== 'ok' ? { missing: collectMissing(results) } : {}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function composeTask(node, plan) {
|
|
119
|
+
return plan.objective
|
|
120
|
+
? `Objective: ${plan.objective}\nTask: ${node.goal}`
|
|
121
|
+
: node.goal;
|
|
122
|
+
}
|
|
123
|
+
function collectMissing(results) {
|
|
124
|
+
const out = [];
|
|
125
|
+
for (const r of results.values())
|
|
126
|
+
if (r.missing)
|
|
127
|
+
out.push(...r.missing);
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=stepper-interpreter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper-interpreter.js","sourceRoot":"","sources":["../../../src/coordinator/stepper/stepper-interpreter.ts"],"names":[],"mappings":"AAQA,MAAM,IAAI,GAAa,EAAE,YAAY,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AAChF,MAAM,QAAQ,GAAG,CAAC,CAAW,EAAE,CAAW,EAAY,EAAE,CAAC,CAAC;IACxD,YAAY,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;IAC7C,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB;IACzD,WAAW,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW;CAC3C,CAAC,CAAC;AACH,MAAM,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAW,CAAC;AAEvE,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAG,SAAS,CAAC;IAE1B,KAAK,CAAC,SAAS,CACb,IAAa,EACb,GAAoD;QAEpD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;QAClD,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,IAAI,KAAK,GAA6B,IAAI,CAAC;QAE3C,MAAM,KAAK,GAAG,GAAG,EAAE,CACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CACf,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CA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YACb,KAAK;YACL,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChE,CAAC;IACJ,CAAC;CACF;AAED,SAAS,WAAW,CAAC,IAA8B,EAAE,IAAa;IAChE,OAAO,IAAI,CAAC,SAAS;QACnB,CAAC,CAAC,cAAc,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,IAAI,EAAE;QACpD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,OAAoC;IAC1D,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,CAAC,OAAO;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IACxE,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IExecutor, IReviewStrategy, IStepper, IStepperInput, IStepperInterpreter, IStepperPlanner, IStepperResult } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
export interface StepperDeps {
|
|
3
|
+
name: string;
|
|
4
|
+
planner: IStepperPlanner;
|
|
5
|
+
interpreter: IStepperInterpreter;
|
|
6
|
+
executor: IExecutor;
|
|
7
|
+
childSteppers: ReadonlyMap<string, IStepper>;
|
|
8
|
+
reviewer?: IReviewStrategy;
|
|
9
|
+
/** Depth-membership predicate (NOT a Set) so config `atDepths: 'all'`
|
|
10
|
+
* works — see Task 14. A plain `new Set([0,1])` also satisfies this
|
|
11
|
+
* shape, so tests can pass a Set directly. */
|
|
12
|
+
reviewerAtDepths: {
|
|
13
|
+
has(depth: number): boolean;
|
|
14
|
+
};
|
|
15
|
+
depth: number;
|
|
16
|
+
maxParallelSteps: number;
|
|
17
|
+
mintStepperId: () => string;
|
|
18
|
+
parentPath?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Names + descriptions of the child worker Steppers this Stepper may delegate
|
|
21
|
+
* to (the keys of `childSteppers`, enriched with descriptions). Passed to the
|
|
22
|
+
* planner so it can emit `agent`-bearing nodes that the interpreter recurses
|
|
23
|
+
* into. Empty/omitted → planner emits only executor leaves.
|
|
24
|
+
*/
|
|
25
|
+
childAgentCatalog?: ReadonlyArray<{
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export declare class Stepper implements IStepper {
|
|
31
|
+
private readonly deps;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
constructor(deps: StepperDeps);
|
|
34
|
+
run(input: IStepperInput): Promise<IStepperResult>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=stepper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../../src/coordinator/stepper/stepper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,mBAAmB,CAAC;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;mDAE+C;IAC/C,gBAAgB,EAAE;QAAE,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED,qBAAa,OAAQ,YAAW,QAAQ;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IADjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBACO,IAAI,EAAE,WAAW;IAIxC,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;CAoDzD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export class Stepper {
|
|
2
|
+
deps;
|
|
3
|
+
name;
|
|
4
|
+
constructor(deps) {
|
|
5
|
+
this.deps = deps;
|
|
6
|
+
this.name = deps.name;
|
|
7
|
+
}
|
|
8
|
+
async run(input) {
|
|
9
|
+
const { planner, interpreter, executor, childSteppers, reviewer, reviewerAtDepths, depth, maxParallelSteps, mintStepperId, parentPath, childAgentCatalog, } = this.deps;
|
|
10
|
+
const plan = await planner.plan({
|
|
11
|
+
prompt: input.prompt,
|
|
12
|
+
knowledgeRag: input.knowledgeRag,
|
|
13
|
+
toolsRag: input.toolsRag,
|
|
14
|
+
parentPath: parentPath ?? [this.name],
|
|
15
|
+
identity: input.identity,
|
|
16
|
+
agents: childAgentCatalog,
|
|
17
|
+
taskSpec: input.taskSpec,
|
|
18
|
+
signal: input.signal,
|
|
19
|
+
});
|
|
20
|
+
if (reviewer && reviewerAtDepths.has(depth)) {
|
|
21
|
+
const result = await reviewer.review({
|
|
22
|
+
prompt: input.prompt,
|
|
23
|
+
plan,
|
|
24
|
+
agents: [],
|
|
25
|
+
sessionId: input.identity.sessionId,
|
|
26
|
+
signal: input.signal,
|
|
27
|
+
});
|
|
28
|
+
// On rejection, a bounded replan could be added here (17.0 semantics).
|
|
29
|
+
// v1: log and proceed if reviewer has no hard-fail contract.
|
|
30
|
+
void result;
|
|
31
|
+
}
|
|
32
|
+
return interpreter.interpret(plan, {
|
|
33
|
+
prompt: input.prompt,
|
|
34
|
+
knowledgeRag: input.knowledgeRag,
|
|
35
|
+
toolsRag: input.toolsRag,
|
|
36
|
+
childSteppers,
|
|
37
|
+
executor,
|
|
38
|
+
budget: input.budget,
|
|
39
|
+
identity: input.identity,
|
|
40
|
+
taskSpec: input.taskSpec,
|
|
41
|
+
maxParallelSteps,
|
|
42
|
+
mintStepperId,
|
|
43
|
+
signal: input.signal,
|
|
44
|
+
sessionLogger: input.sessionLogger,
|
|
45
|
+
onProgress: input.onProgress,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=stepper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../../src/coordinator/stepper/stepper.ts"],"names":[],"mappings":"AAkCA,MAAM,OAAO,OAAO;IAEW;IADpB,IAAI,CAAS;IACtB,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAoB;QAC5B,MAAM,EACJ,OAAO,EACP,WAAW,EACX,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,GAAG,IAAI,CAAC,IAAI,CAAC;QACd,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACrC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,MAAM,EAAE,iBAAiB;YACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC,CAAC;QACH,IAAI,QAAQ,IAAI,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBACnC,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,IAAI;gBACJ,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,SAAS;gBACnC,MAAM,EAAE,KAAK,CAAC,MAAM;aACZ,CAAC,CAAC;YACZ,uEAAuE;YACvE,6DAA6D;YAC7D,KAAK,MAAM,CAAC;QACd,CAAC;QACD,OAAO,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;YACjC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,aAAa;YACb,QAAQ;YACR,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,gBAAgB;YAChB,aAAa;YACb,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export { NonStreamingLlm } from './adapters/non-streaming-llm.js';
|
|
|
10
10
|
export { OrchestratorError, SmartAgent, type SmartAgentConfig, type SmartAgentDeps, type SmartAgentRagStores, type SmartAgentReconfigureOptions, type SmartAgentResponse, type StopReason, } from './agent.js';
|
|
11
11
|
export { type BuilderMcpConfig, type BuilderPromptsConfig, SmartAgentBuilder, type SmartAgentBuilderConfig, type SmartAgentHandle, } from './builder.js';
|
|
12
12
|
export { ConfigWatcher, type ConfigWatcherOptions, type HotReloadableConfig, } from './config/config-watcher.js';
|
|
13
|
-
export {
|
|
13
|
+
export { FINALIZER_SYSTEM, LlmFinalizer, PassthroughFinalizer, SubAgentStateOracle, TemplateFinalizer, } from './coordinator/dag/index.js';
|
|
14
|
+
export { AbortErrorStrategy, AutoActivation, DagPlanInterpreter, ExplicitActivation, HybridDispatch, LlmDagPlanner, LlmReviewStrategy, NoopReviewStrategy, OneShotPlanning, ReplanErrorStrategy, ReplanOnErrorPlanning, SelfDispatch, SkillStepsPlanning, SubAgentDispatch, } from './coordinator/index.js';
|
|
15
|
+
export * from './coordinator/stepper/index.js';
|
|
14
16
|
export { HealthChecker, type HealthCheckerDeps, } from './health/health-checker.js';
|
|
15
17
|
export { HistoryMemory } from './history/history-memory.js';
|
|
16
18
|
export { HistorySummarizer } from './history/history-summarizer.js';
|
|
@@ -20,18 +22,24 @@ export { NoopRequestLogger } from './logger/noop-request-logger.js';
|
|
|
20
22
|
export { SessionLogger } from './logger/session-logger.js';
|
|
21
23
|
export { type CounterSnapshot, type HistogramSnapshot, InMemoryMetrics, type MetricsSnapshot, } from './metrics/in-memory-metrics.js';
|
|
22
24
|
export { NoopMetrics } from './metrics/noop-metrics.js';
|
|
23
|
-
export { type BuiltInStageType, buildDefaultHandlerRegistry, type ControlFlowType, DefaultPipeline, evaluateCondition, type IStageHandler, type PipelineContext, PipelineExecutor, type StageDefinition, type StageType, } from './pipeline/index.js';
|
|
25
|
+
export { type BuiltInStageType, buildDefaultHandlerRegistry, type ControlFlowType, type DagCoordinatorHandlerDeps, DefaultPipeline, type DefaultPipelineOptions, evaluateCondition, type IStageHandler, type PipelineContext, PipelineExecutor, type StageDefinition, type StageType, } from './pipeline/index.js';
|
|
24
26
|
export { DEFAULT_TOOL_SELECTION, ScoreThresholdToolSelection, TopKToolSelection, } from './pipeline/tool-selection/index.js';
|
|
25
27
|
export type { IPluginLoader, LoadedPlugins, PluginExports, } from './plugins/index.js';
|
|
26
28
|
export { emptyLoadedPlugins, FileSystemPluginLoader, type FileSystemPluginLoaderConfig, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './plugins/index.js';
|
|
27
29
|
export { DefaultModelResolver, type MakeLlmConfig, makeDefaultLlm, makeLlm, } from './providers.js';
|
|
30
|
+
export { InMemoryKnowledgeBackend, type KnowledgeBackend, KnowledgeRag, } from './rag/knowledge-rag.js';
|
|
28
31
|
export { LlmReranker } from './reranker/llm-reranker.js';
|
|
29
32
|
export { NoopReranker } from './reranker/noop-reranker.js';
|
|
30
33
|
export { RateLimiterLlm } from './resilience/rate-limiter-llm.js';
|
|
31
34
|
export { RetryLlm, type RetryOptions } from './resilience/retry-llm.js';
|
|
32
35
|
export { type TokenBucketConfig, TokenBucketRateLimiter, } from './resilience/token-bucket-rate-limiter.js';
|
|
33
36
|
export { NoopSessionManager } from './session/noop-session-manager.js';
|
|
37
|
+
export { SessionGraph } from './session/session-graph.js';
|
|
38
|
+
export type { SessionAgentParts, SessionGraphFactoryOptions, SessionGraphIdentity, } from './session/session-graph-factory.js';
|
|
39
|
+
export { SessionGraphFactory } from './session/session-graph-factory.js';
|
|
34
40
|
export { SessionManager } from './session/session-manager.js';
|
|
41
|
+
export type { SessionGraphSource, SessionRegistryOptions, } from './session/session-registry.js';
|
|
42
|
+
export { SessionRegistry } from './session/session-registry.js';
|
|
35
43
|
export { ClaudeSkillManager, CodexSkillManager, FileSystemSkillManager, } from './skills/index.js';
|
|
36
44
|
export { DefaultSubAgentContextBuilder, type DefaultSubAgentContextBuilderConfig, type SubAgentRetrievalSource, } from './subagent/default-context-builder.js';
|
|
37
45
|
export { DirectLlmSubAgent, type DirectLlmSubAgentOptions, } from './subagent/direct-llm-subagent.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[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AiB,EACtB,eAAe,EACf,KAAK,eAAe,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIxD,OAAO,EACL,KAAK,gBAAgB,EACrB,2BAA2B,EAC3B,KAAK,eAAe,EACpB,eAAe,EACf,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACV,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,4BAA4B,EACjC,oBAAoB,EACpB,WAAW,EACX,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,oBAAoB,EACpB,KAAK,aAAa,EAClB,cAAc,EACd,OAAO,GACR,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,UAAU,EACV,KAAK,sBAAsB,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,iB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EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,6BAA6B,EAC7B,KAAK,mCAAmC,EACxC,KAAK,uBAAuB,GAC7B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,10 +19,15 @@ export { SmartAgentBuilder, } from './builder.js';
|
|
|
19
19
|
// Config
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
export { ConfigWatcher, } from './config/config-watcher.js';
|
|
22
|
+
export { FINALIZER_SYSTEM, LlmFinalizer, PassthroughFinalizer, SubAgentStateOracle, TemplateFinalizer, } from './coordinator/dag/index.js';
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
23
24
|
// Coordinator strategies
|
|
24
25
|
// ---------------------------------------------------------------------------
|
|
25
|
-
export { AutoActivation, ExplicitActivation, HybridDispatch, OneShotPlanning, ReplanOnErrorPlanning, SelfDispatch, SkillStepsPlanning, SubAgentDispatch, } from './coordinator/index.js';
|
|
26
|
+
export { AbortErrorStrategy, AutoActivation, DagPlanInterpreter, ExplicitActivation, HybridDispatch, LlmDagPlanner, LlmReviewStrategy, NoopReviewStrategy, OneShotPlanning, ReplanErrorStrategy, ReplanOnErrorPlanning, SelfDispatch, SkillStepsPlanning, SubAgentDispatch, } from './coordinator/index.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Stepper runtime (18.0)
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
export * from './coordinator/stepper/index.js';
|
|
26
31
|
// ---------------------------------------------------------------------------
|
|
27
32
|
// Health
|
|
28
33
|
// ---------------------------------------------------------------------------
|
|
@@ -56,6 +61,7 @@ export { emptyLoadedPlugins, FileSystemPluginLoader, getDefaultPluginDirs, loadP
|
|
|
56
61
|
// Providers (LLM)
|
|
57
62
|
// ---------------------------------------------------------------------------
|
|
58
63
|
export { DefaultModelResolver, makeDefaultLlm, makeLlm, } from './providers.js';
|
|
64
|
+
export { InMemoryKnowledgeBackend, KnowledgeRag, } from './rag/knowledge-rag.js';
|
|
59
65
|
// ---------------------------------------------------------------------------
|
|
60
66
|
// Reranker
|
|
61
67
|
// ---------------------------------------------------------------------------
|
|
@@ -71,7 +77,10 @@ export { TokenBucketRateLimiter, } from './resilience/token-bucket-rate-limiter.
|
|
|
71
77
|
// Session
|
|
72
78
|
// ---------------------------------------------------------------------------
|
|
73
79
|
export { NoopSessionManager } from './session/noop-session-manager.js';
|
|
80
|
+
export { SessionGraph } from './session/session-graph.js';
|
|
81
|
+
export { SessionGraphFactory } from './session/session-graph-factory.js';
|
|
74
82
|
export { SessionManager } from './session/session-manager.js';
|
|
83
|
+
export { SessionRegistry } from './session/session-registry.js';
|
|
75
84
|
// ---------------------------------------------------------------------------
|
|
76
85
|
// Skills
|
|
77
86
|
// ---------------------------------------------------------------------------
|