@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
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @mcp-abap-adt/llm-agent-server-libs
|
|
2
|
+
|
|
3
|
+
The SmartServer composition runtime as an **importable library**. It sits between the binary `@mcp-abap-adt/llm-agent-server` and the core `@mcp-abap-adt/llm-agent-libs`, so the SmartServer/coordinator composition can be reused in other projects without depending on the CLI/HTTP binary.
|
|
4
|
+
|
|
5
|
+
## Top-level exports
|
|
6
|
+
|
|
7
|
+
- `SmartServer` — HTTP-less SmartServer composition (config → built agent/coordinator).
|
|
8
|
+
- `buildStepperRoot` / `buildFromComposition` — build a Stepper coordinator tree from a composition spec; `buildFromComposition` accepts a `makeRoleLlm(role)` callback so it is decoupled from the server's YAML LLM-map.
|
|
9
|
+
- `StepperCoordinatorHandler` — the `coordinator` stage handler for the Stepper runtime.
|
|
10
|
+
- Coordinator config parsing (`parseStepperCoordinatorConfig`, `StepperCompositionSpec`, `CompositionNode`, …), session stores, and `pipeline` wiring.
|
|
11
|
+
|
|
12
|
+
### Pipeline builder-factories
|
|
13
|
+
|
|
14
|
+
Each pipeline variant is a standalone, exportable factory implementing `IPipelineFactory<TConfig>` (from `@mcp-abap-adt/llm-agent`). `build(config, deps)` returns a `{ handler }` you register as the `coordinator` stage.
|
|
15
|
+
|
|
16
|
+
| Factory | `kind` | Pipeline |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| `LinearFactory` | `linear` | linear tool-loop coordinator |
|
|
19
|
+
| `DagFactory` | `dag` | DAG coordinator (parallel workers) |
|
|
20
|
+
| `CyclicFactory` | `cyclic` | Stepper — planner `none` + cyclic-react executor |
|
|
21
|
+
| `PlannedFactory` | `planned` | Stepper — LLM planner + cyclic-react executor |
|
|
22
|
+
| `DeepStepperFactory` | `deep-stepper` | Stepper — LLM planner + recursive executor |
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { CyclicFactory } from '@mcp-abap-adt/llm-agent-server-libs';
|
|
26
|
+
|
|
27
|
+
const { handler } = await new CyclicFactory().build(stepperConfig, {
|
|
28
|
+
makeRoleLlm: async (role) => myLlm, // 'planner' | 'executor' | 'finalizer' | 'reviewer' | 'evaluator' | 'classifier'
|
|
29
|
+
callMcp,
|
|
30
|
+
knowledgeRagFor,
|
|
31
|
+
toolsRag,
|
|
32
|
+
mintStepperId: () => crypto.randomUUID(),
|
|
33
|
+
mintTurnId: () => crypto.randomUUID(),
|
|
34
|
+
});
|
|
35
|
+
registry.set('coordinator', handler);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
See `docs/INTEGRATION.md` (“Reusing pipeline builder-factories”) for the full example.
|
|
39
|
+
|
|
40
|
+
## Dependencies
|
|
41
|
+
|
|
42
|
+
Depends on `@mcp-abap-adt/llm-agent`, `@mcp-abap-adt/llm-agent-libs`, `@mcp-abap-adt/llm-agent-mcp`, `@mcp-abap-adt/llm-agent-rag`. The binary `@mcp-abap-adt/llm-agent-server` depends on this package.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { BuiltCoordinator, IKnowledgeRagHandle, IPipelineFactory, IStepper, IToolsRagHandle, LlmCallEntry, PipelineFactoryDepsBase } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { type StepperCompositionSpec } from '../smart-agent/build-stepper-root.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runtime dependencies for the Stepper builder-factories. Richer than
|
|
5
|
+
* {@link PipelineFactoryDepsBase}: the Stepper coordinator handler also needs the
|
|
6
|
+
* per-session knowledge RAG factory, the shared tools RAG handle, ID minters,
|
|
7
|
+
* and (optionally) a subagent catalog / pre-built child Stepper registry and a
|
|
8
|
+
* per-call usage logger.
|
|
9
|
+
*/
|
|
10
|
+
export interface StepperFactoryDeps extends PipelineFactoryDepsBase {
|
|
11
|
+
/** Per-sessionId knowledge RAG factory (run-time handler dep). */
|
|
12
|
+
knowledgeRagFor: (sessionId: string) => Promise<IKnowledgeRagHandle>;
|
|
13
|
+
/** Shared tools RAG handle (run-time handler dep). */
|
|
14
|
+
toolsRag: IToolsRagHandle;
|
|
15
|
+
/** Monotonically-unique stepper-ID minter. */
|
|
16
|
+
mintStepperId: () => string;
|
|
17
|
+
/** Per-request turn-ID minter. */
|
|
18
|
+
mintTurnId: () => string;
|
|
19
|
+
/** Declared subagents (name + description) for deep-stepper recursion. */
|
|
20
|
+
subagents?: ReadonlyArray<{
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** Pre-built named registry of child Steppers (DI/test override). */
|
|
25
|
+
registry?: ReadonlyMap<string, IStepper>;
|
|
26
|
+
/** Optional per-role LLM usage logger. */
|
|
27
|
+
logLlmCall?: (entry: LlmCallEntry) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The caller supplies everything in the spec EXCEPT the {planner,executor}
|
|
31
|
+
* preset, which each factory bakes in.
|
|
32
|
+
*/
|
|
33
|
+
export type StepperFactoryConfig = Omit<StepperCompositionSpec, 'planner' | 'executor'>;
|
|
34
|
+
/**
|
|
35
|
+
* Shared builder: wires a {@link StepperCoordinatorHandler} whose `buildBuilt`
|
|
36
|
+
* defers to {@link buildFromComposition} with the role-LLM resolution path.
|
|
37
|
+
* `knowledgeRagFor`/`toolsRag` are HANDLER deps used at run time, not build deps.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildStepperCoordinator(spec: StepperCompositionSpec, deps: StepperFactoryDeps): Promise<BuiltCoordinator>;
|
|
40
|
+
/**
|
|
41
|
+
* Cyclic Stepper variant: no planner, a single cyclic-ReAct executor loop.
|
|
42
|
+
* Preset: `{ planner: 'none', executor: 'cyclic-react' }`.
|
|
43
|
+
*/
|
|
44
|
+
export declare class CyclicFactory implements IPipelineFactory<StepperFactoryConfig> {
|
|
45
|
+
readonly kind: "cyclic";
|
|
46
|
+
build(config: StepperFactoryConfig, deps: StepperFactoryDeps): Promise<BuiltCoordinator>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMapp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C,oBAAoB,CAAC;IAC1E,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAElC,KAAK,CACH,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,CAAC;CAM7B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { buildFromComposition, } from '../smart-agent/build-stepper-root.js';
|
|
2
|
+
import { StepperCoordinatorHandler } from '../smart-agent/stepper-coordinator-handler.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared builder: wires a {@link StepperCoordinatorHandler} whose `buildBuilt`
|
|
5
|
+
* defers to {@link buildFromComposition} with the role-LLM resolution path.
|
|
6
|
+
* `knowledgeRagFor`/`toolsRag` are HANDLER deps used at run time, not build deps.
|
|
7
|
+
*/
|
|
8
|
+
export async function buildStepperCoordinator(spec, deps) {
|
|
9
|
+
const handler = new StepperCoordinatorHandler({
|
|
10
|
+
buildBuilt: async (_ctx, logLlmCall) => buildFromComposition(spec, {
|
|
11
|
+
makeRoleLlm: deps.makeRoleLlm,
|
|
12
|
+
callMcp: deps.callMcp,
|
|
13
|
+
mintStepperId: deps.mintStepperId,
|
|
14
|
+
registry: deps.registry ?? new Map(),
|
|
15
|
+
logLlmCall,
|
|
16
|
+
...(deps.subagents ? { subagents: deps.subagents } : {}),
|
|
17
|
+
}),
|
|
18
|
+
knowledgeRagFor: deps.knowledgeRagFor,
|
|
19
|
+
toolsRag: deps.toolsRag,
|
|
20
|
+
mintStepperId: deps.mintStepperId,
|
|
21
|
+
mintTurnId: deps.mintTurnId,
|
|
22
|
+
});
|
|
23
|
+
return { handler };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cyclic Stepper variant: no planner, a single cyclic-ReAct executor loop.
|
|
27
|
+
* Preset: `{ planner: 'none', executor: 'cyclic-react' }`.
|
|
28
|
+
*/
|
|
29
|
+
export class CyclicFactory {
|
|
30
|
+
kind = 'cyclic';
|
|
31
|
+
build(config, deps) {
|
|
32
|
+
return buildStepperCoordinator({ ...config, planner: 'none', executor: 'cyclic-react' }, deps);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=cyclic-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cyclic-factory.js","sourceRoot":"","sources":["../../src/factories/cyclic-factory.ts"],"names":[],"mappings":"AASA,OAAO,EACL,oBAAoB,GAErB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAmC1F;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,IAA4B,EAC5B,IAAwB;IAExB,MAAM,OAAO,GAAG,IAAI,yBAAyB,CAAC;QAC5C,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CACrC,oBAAoB,CAAC,IAAI,EAAE;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,GAAG,EAAE;YACpC,UAAU;YACV,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzD,CAAC;QACJ,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,aAAa;IACf,IAAI,GAAG,QAAiB,CAAC;IAElC,KAAK,CACH,MAA4B,EAC5B,IAAwB;QAExB,OAAO,uBAAuB,CAC5B,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,EACxD,IAAI,CACL,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuiltCoordinator, IPipelineFactory, PipelineFactoryDepsBase } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { type DagCoordinatorHandlerDeps } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
|
+
/**
|
|
4
|
+
* Builder-factory that wraps the existing {@link DagCoordinatorHandler}.
|
|
5
|
+
* The `config` parameter IS the fully-formed handler deps — the factory
|
|
6
|
+
* simply constructs the handler and returns it. The base pipeline deps
|
|
7
|
+
* (`_deps`) are unused because DAG wiring is captured entirely in `config`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DagFactory implements IPipelineFactory<DagCoordinatorHandlerDeps> {
|
|
10
|
+
readonly kind: "dag";
|
|
11
|
+
build(config: DagCoordinatorHandlerDeps, _deps: PipelineFactoryDepsBase): Promise<BuiltCoordinator>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=dag-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-factory.d.ts","sourceRoot":"","sources":["../../src/factories/dag-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,gBAAgB,CAAC,yBAAyB,CAAC;IAC5E,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAEzB,KAAK,CACT,MAAM,EAAE,yBAAyB,EACjC,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;CAG7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DagCoordinatorHandler, } from '@mcp-abap-adt/llm-agent-libs';
|
|
2
|
+
/**
|
|
3
|
+
* Builder-factory that wraps the existing {@link DagCoordinatorHandler}.
|
|
4
|
+
* The `config` parameter IS the fully-formed handler deps — the factory
|
|
5
|
+
* simply constructs the handler and returns it. The base pipeline deps
|
|
6
|
+
* (`_deps`) are unused because DAG wiring is captured entirely in `config`.
|
|
7
|
+
*/
|
|
8
|
+
export class DagFactory {
|
|
9
|
+
kind = 'dag';
|
|
10
|
+
async build(config, _deps) {
|
|
11
|
+
return { handler: new DagCoordinatorHandler(config) };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=dag-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-factory.js","sourceRoot":"","sources":["../../src/factories/dag-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,qBAAqB,GAEtB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACZ,IAAI,GAAG,KAAc,CAAC;IAE/B,KAAK,CAAC,KAAK,CACT,MAAiC,EACjC,KAA8B;QAE9B,OAAO,EAAE,OAAO,EAAE,IAAI,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuiltCoordinator, IPipelineFactory } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { type StepperFactoryConfig, type StepperFactoryDeps } from './cyclic-factory.js';
|
|
3
|
+
/**
|
|
4
|
+
* Deep-stepper variant: an LLM planner decomposes the goal and the recursive
|
|
5
|
+
* executor delegates sub-goals to child Steppers (subagents).
|
|
6
|
+
* Preset: `{ planner: 'llm', executor: 'recursive' }`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DeepStepperFactory implements IPipelineFactory<StepperFactoryConfig> {
|
|
9
|
+
readonly kind: "deep-stepper";
|
|
10
|
+
build(config: StepperFactoryConfig, deps: StepperFactoryDeps): Promise<BuiltCoordinator>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=deep-stepper-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-stepper-factory.d.ts","sourceRoot":"","sources":["../../src/factories/deep-stepper-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,qBAAa,kBACX,YAAW,gBAAgB,CAAC,oBAAoB,CAAC;IAEjD,QAAQ,CAAC,IAAI,EAAG,cAAc,CAAU;IAExC,KAAK,CACH,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,CAAC;CAM7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { buildStepperCoordinator, } from './cyclic-factory.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deep-stepper variant: an LLM planner decomposes the goal and the recursive
|
|
4
|
+
* executor delegates sub-goals to child Steppers (subagents).
|
|
5
|
+
* Preset: `{ planner: 'llm', executor: 'recursive' }`.
|
|
6
|
+
*/
|
|
7
|
+
export class DeepStepperFactory {
|
|
8
|
+
kind = 'deep-stepper';
|
|
9
|
+
build(config, deps) {
|
|
10
|
+
return buildStepperCoordinator({ ...config, planner: 'llm', executor: 'recursive' }, deps);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=deep-stepper-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-stepper-factory.js","sourceRoot":"","sources":["../../src/factories/deep-stepper-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,uBAAuB,GAGxB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAGpB,IAAI,GAAG,cAAuB,CAAC;IAExC,KAAK,CACH,MAA4B,EAC5B,IAAwB;QAExB,OAAO,uBAAuB,CAC5B,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,EACpD,IAAI,CACL,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { StepperFactoryConfig, StepperFactoryDeps, } from './cyclic-factory.js';
|
|
2
|
+
export { buildStepperCoordinator, CyclicFactory } from './cyclic-factory.js';
|
|
3
|
+
export { DagFactory } from './dag-factory.js';
|
|
4
|
+
export { DeepStepperFactory } from './deep-stepper-factory.js';
|
|
5
|
+
export { LinearFactory } from './linear-factory.js';
|
|
6
|
+
export { PlannedFactory } from './planned-factory.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { buildStepperCoordinator, CyclicFactory } from './cyclic-factory.js';
|
|
2
|
+
export { DagFactory } from './dag-factory.js';
|
|
3
|
+
export { DeepStepperFactory } from './deep-stepper-factory.js';
|
|
4
|
+
export { LinearFactory } from './linear-factory.js';
|
|
5
|
+
export { PlannedFactory } from './planned-factory.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factories/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuiltCoordinator, IPipelineFactory, PipelineFactoryDepsBase } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { type CoordinatorHandlerDeps } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
|
+
/**
|
|
4
|
+
* Builder-factory that wraps the existing linear {@link CoordinatorHandler}.
|
|
5
|
+
* The `config` parameter IS the fully-formed handler deps — the factory
|
|
6
|
+
* simply constructs the handler and returns it. The base pipeline deps
|
|
7
|
+
* (`_deps`) are unused because linear wiring is captured entirely in `config`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LinearFactory implements IPipelineFactory<CoordinatorHandlerDeps> {
|
|
10
|
+
readonly kind: "linear";
|
|
11
|
+
build(config: CoordinatorHandlerDeps, _deps: PipelineFactoryDepsBase): Promise<BuiltCoordinator>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=linear-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear-factory.d.ts","sourceRoot":"","sources":["../../src/factories/linear-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,gBAAgB,CAAC,sBAAsB,CAAC;IAC5E,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAE5B,KAAK,CACT,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;CAG7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CoordinatorHandler, } from '@mcp-abap-adt/llm-agent-libs';
|
|
2
|
+
/**
|
|
3
|
+
* Builder-factory that wraps the existing linear {@link CoordinatorHandler}.
|
|
4
|
+
* The `config` parameter IS the fully-formed handler deps — the factory
|
|
5
|
+
* simply constructs the handler and returns it. The base pipeline deps
|
|
6
|
+
* (`_deps`) are unused because linear wiring is captured entirely in `config`.
|
|
7
|
+
*/
|
|
8
|
+
export class LinearFactory {
|
|
9
|
+
kind = 'linear';
|
|
10
|
+
async build(config, _deps) {
|
|
11
|
+
return { handler: new CoordinatorHandler(config) };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=linear-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear-factory.js","sourceRoot":"","sources":["../../src/factories/linear-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACf,IAAI,GAAG,QAAiB,CAAC;IAElC,KAAK,CAAC,KAAK,CACT,MAA8B,EAC9B,KAA8B;QAE9B,OAAO,EAAE,OAAO,EAAE,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuiltCoordinator, IPipelineFactory } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { type StepperFactoryConfig, type StepperFactoryDeps } from './cyclic-factory.js';
|
|
3
|
+
/**
|
|
4
|
+
* Planned Stepper variant: an LLM planner decomposes the goal, then a
|
|
5
|
+
* cyclic-ReAct executor runs each step.
|
|
6
|
+
* Preset: `{ planner: 'llm', executor: 'cyclic-react' }`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PlannedFactory implements IPipelineFactory<StepperFactoryConfig> {
|
|
9
|
+
readonly kind: "planned";
|
|
10
|
+
build(config: StepperFactoryConfig, deps: StepperFactoryDeps): Promise<BuiltCoordinator>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=planned-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planned-factory.d.ts","sourceRoot":"","sources":["../../src/factories/planned-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,qBAAa,cAAe,YAAW,gBAAgB,CAAC,oBAAoB,CAAC;IAC3E,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;IAEnC,KAAK,CACH,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,CAAC;CAM7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { buildStepperCoordinator, } from './cyclic-factory.js';
|
|
2
|
+
/**
|
|
3
|
+
* Planned Stepper variant: an LLM planner decomposes the goal, then a
|
|
4
|
+
* cyclic-ReAct executor runs each step.
|
|
5
|
+
* Preset: `{ planner: 'llm', executor: 'cyclic-react' }`.
|
|
6
|
+
*/
|
|
7
|
+
export class PlannedFactory {
|
|
8
|
+
kind = 'planned';
|
|
9
|
+
build(config, deps) {
|
|
10
|
+
return buildStepperCoordinator({ ...config, planner: 'llm', executor: 'cyclic-react' }, deps);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=planned-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planned-factory.js","sourceRoot":"","sources":["../../src/factories/planned-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,uBAAuB,GAGxB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAChB,IAAI,GAAG,SAAkB,CAAC;IAEnC,KAAK,CACH,MAA4B,EAC5B,IAAwB;QAExB,OAAO,uBAAuB,CAC5B,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,EACvD,IAAI,CACL,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/generated/version.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './factories/index.js';
|
|
2
|
+
export * from './smart-agent/build-dag-coordinator-deps.js';
|
|
3
|
+
export * from './smart-agent/build-stepper-root.js';
|
|
4
|
+
export * from './smart-agent/config.js';
|
|
5
|
+
export * from './smart-agent/jsonl-knowledge-backend.js';
|
|
6
|
+
export * from './smart-agent/pipeline.js';
|
|
7
|
+
export * from './smart-agent/resolve-agent-embedder.js';
|
|
8
|
+
export * from './smart-agent/session-identity-resolver.js';
|
|
9
|
+
export * from './smart-agent/session-meta-store.js';
|
|
10
|
+
export * from './smart-agent/smart-server.js';
|
|
11
|
+
export * from './smart-agent/stepper-coordinator-handler.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0CAA0C,CAAC;AACzD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8CAA8C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './factories/index.js';
|
|
2
|
+
export * from './smart-agent/build-dag-coordinator-deps.js';
|
|
3
|
+
export * from './smart-agent/build-stepper-root.js';
|
|
4
|
+
export * from './smart-agent/config.js';
|
|
5
|
+
export * from './smart-agent/jsonl-knowledge-backend.js';
|
|
6
|
+
export * from './smart-agent/pipeline.js';
|
|
7
|
+
export * from './smart-agent/resolve-agent-embedder.js';
|
|
8
|
+
export * from './smart-agent/session-identity-resolver.js';
|
|
9
|
+
export * from './smart-agent/session-meta-store.js';
|
|
10
|
+
export * from './smart-agent/smart-server.js';
|
|
11
|
+
export * from './smart-agent/stepper-coordinator-handler.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,0CAA0C,CAAC;AACzD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8CAA8C,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ILlm, ISubAgent } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import type { DagCoordinatorHandlerDeps } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
|
+
import { type NormalizedLlmMap } from './config.js';
|
|
4
|
+
import type { SmartServerLlmConfig } from './smart-server.js';
|
|
5
|
+
export interface BuildDagCoordinatorDepsInput {
|
|
6
|
+
coordCfg: Record<string, unknown> | undefined;
|
|
7
|
+
llmMap: NormalizedLlmMap | undefined;
|
|
8
|
+
/** Adapted from `pipeline.llm.main` (already shape-normalized to
|
|
9
|
+
* SmartServerLlmConfig: `{ provider, apiKey, url: baseURL, model,
|
|
10
|
+
* temperature }`). When set, used as the final fallback in the
|
|
11
|
+
* role-resolution chain map[name] → map.main → pipelineFallback. */
|
|
12
|
+
pipelineFallback: SmartServerLlmConfig | undefined;
|
|
13
|
+
mainLlm: ILlm;
|
|
14
|
+
helperLlm: ILlm | undefined;
|
|
15
|
+
mainTemp: number;
|
|
16
|
+
registry: ReadonlyMap<string, ISubAgent>;
|
|
17
|
+
makeLlm: (config: SmartServerLlmConfig) => Promise<ILlm>;
|
|
18
|
+
warn: (msg: string) => void;
|
|
19
|
+
}
|
|
20
|
+
export type BuiltDagCoordinatorDeps = Omit<DagCoordinatorHandlerDeps, 'workers'> & {
|
|
21
|
+
workers: Map<string, ISubAgent>;
|
|
22
|
+
oracleName?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Assemble the full deps record for `withDagCoordinator`. Returns
|
|
26
|
+
* `undefined` when the YAML does not declare a DAG coordinator (no
|
|
27
|
+
* `planner` block), so the caller can branch.
|
|
28
|
+
*
|
|
29
|
+
* Roles resolve their LLM via the chain:
|
|
30
|
+
* resolveLlmConfig(llmMap, name, pipelineFallback)
|
|
31
|
+
* → top-level llm.<name> → llm.main → pipelineFallback (pipeline.llm.main)
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildDagCoordinatorDeps(input: BuildDagCoordinatorDepsInput): Promise<BuiltDagCoordinatorDeps | undefined>;
|
|
34
|
+
//# sourceMappingURL=build-dag-coordinator-deps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-dag-coordinator-deps.d.ts","sourceRoot":"","sources":["../../src/smart-agent/build-dag-coordinator-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,IAAI,EAEJ,SAAS,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAS9E,OAAO,EAEL,KAAK,gBAAgB,EAKtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC9C,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACrC;;;yEAGqE;IACrE,gBAAgB,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACnD,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,yBAAyB,EACzB,SAAS,CACV,GAAG;IACF,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CA0I9C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { AbortErrorStrategy, DagPlanInterpreter, LlmDagPlanner, LlmReviewStrategy, ReplanErrorStrategy, SubAgentStateOracle, } from '@mcp-abap-adt/llm-agent-libs';
|
|
2
|
+
import { buildFinalizer, resolveCoordinatorActivation, resolveLlmConfig, resolveLlmConfigStrict, resolveReviewerLlmName, } from './config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Assemble the full deps record for `withDagCoordinator`. Returns
|
|
5
|
+
* `undefined` when the YAML does not declare a DAG coordinator (no
|
|
6
|
+
* `planner` block), so the caller can branch.
|
|
7
|
+
*
|
|
8
|
+
* Roles resolve their LLM via the chain:
|
|
9
|
+
* resolveLlmConfig(llmMap, name, pipelineFallback)
|
|
10
|
+
* → top-level llm.<name> → llm.main → pipelineFallback (pipeline.llm.main)
|
|
11
|
+
*/
|
|
12
|
+
export async function buildDagCoordinatorDeps(input) {
|
|
13
|
+
const { coordCfg, llmMap, pipelineFallback, mainLlm, helperLlm, mainTemp, registry, makeLlm, warn, } = input;
|
|
14
|
+
if (!coordCfg || coordCfg.planner === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
// ---- Role LLM resolver -----------------------------------------------
|
|
17
|
+
// Priority chain:
|
|
18
|
+
// 1. map[name] — explicit named entry in the top-level llm: block
|
|
19
|
+
// 2. 'helper' | 'planner' alias — route to the prebuilt helperLlm
|
|
20
|
+
// 3. pipelineFallback (pipeline.llm.main) — last resort
|
|
21
|
+
// 4. fallbackPrebuilt (mainLlm) — when nothing else resolves
|
|
22
|
+
const resolveRoleLlm = async (name, fallbackPrebuilt = mainLlm) => {
|
|
23
|
+
// 1. Explicit map[name] — use it (strict: no main fallback here).
|
|
24
|
+
const strict = resolveLlmConfigStrict(llmMap, name);
|
|
25
|
+
if (strict) {
|
|
26
|
+
return makeLlm({
|
|
27
|
+
...strict,
|
|
28
|
+
temperature: Number(strict.temperature ?? mainTemp),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// 2. 'helper' | 'planner' alias → reuse prebuilt helperLlm.
|
|
32
|
+
if (name === 'helper' || name === 'planner') {
|
|
33
|
+
return helperLlm ?? fallbackPrebuilt;
|
|
34
|
+
}
|
|
35
|
+
// 3. Unknown name → final fallback chain via resolveLlmConfig (map.main → pipelineFallback).
|
|
36
|
+
if (name) {
|
|
37
|
+
const fb = resolveLlmConfig(llmMap, name, pipelineFallback);
|
|
38
|
+
if (fb) {
|
|
39
|
+
return makeLlm({
|
|
40
|
+
...fb,
|
|
41
|
+
temperature: Number(fb.temperature ?? mainTemp),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// 4. No name at all → fallbackPrebuilt (mainLlm by default).
|
|
46
|
+
return fallbackPrebuilt;
|
|
47
|
+
};
|
|
48
|
+
// ---- Planner ----------------------------------------------------------
|
|
49
|
+
const plannerBlock = coordCfg.planner;
|
|
50
|
+
const plannerLlm = await resolveRoleLlm(plannerBlock?.plannerLlm);
|
|
51
|
+
const planner = new LlmDagPlanner(plannerLlm);
|
|
52
|
+
// ---- Reviewer (optional) ---------------------------------------------
|
|
53
|
+
let reviewer;
|
|
54
|
+
if (coordCfg.reviewer !== undefined) {
|
|
55
|
+
const reviewerBlock = coordCfg.reviewer;
|
|
56
|
+
const reviewerName = resolveReviewerLlmName(reviewerBlock, warn);
|
|
57
|
+
const reviewerLlm = await resolveRoleLlm(reviewerName);
|
|
58
|
+
reviewer = new LlmReviewStrategy(reviewerLlm);
|
|
59
|
+
}
|
|
60
|
+
// ---- Interpreter, workers, oracle, activation, error strategy --------
|
|
61
|
+
const interpreter = new DagPlanInterpreter();
|
|
62
|
+
const oracleName = coordCfg.stateOracle;
|
|
63
|
+
let rawOracle;
|
|
64
|
+
if (oracleName) {
|
|
65
|
+
rawOracle = registry.get(oracleName);
|
|
66
|
+
if (!rawOracle) {
|
|
67
|
+
throw new Error(`coordinator.stateOracle '${oracleName}' is not a declared subagent`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const workers = new Map([...registry].filter(([name]) => name !== oracleName));
|
|
71
|
+
if (workers.size === 0) {
|
|
72
|
+
throw new Error('coordinator.planner is set (DAG mode) but no workers are configured. ' +
|
|
73
|
+
'Add at least one entry under the top-level `subagents:` block.');
|
|
74
|
+
}
|
|
75
|
+
const activation = resolveCoordinatorActivation((coordCfg.activation ?? 'explicit'));
|
|
76
|
+
let errorStrategy;
|
|
77
|
+
const esCfg = coordCfg.errorStrategy;
|
|
78
|
+
if (esCfg?.type === 'replan') {
|
|
79
|
+
errorStrategy = new ReplanErrorStrategy(planner, esCfg.maxReplans);
|
|
80
|
+
}
|
|
81
|
+
else if (esCfg?.type === 'abort') {
|
|
82
|
+
errorStrategy = new AbortErrorStrategy();
|
|
83
|
+
}
|
|
84
|
+
// ---- Finalizer --------------------------------------------------------
|
|
85
|
+
const finalizer = await buildFinalizer(coordCfg.finalizer, llmMap, pipelineFallback, async (lc) => makeLlm({
|
|
86
|
+
...lc,
|
|
87
|
+
temperature: Number(lc.temperature ?? mainTemp),
|
|
88
|
+
}));
|
|
89
|
+
// ---- Oracle wrap ------------------------------------------------------
|
|
90
|
+
const stateOracle = rawOracle
|
|
91
|
+
? new SubAgentStateOracle(rawOracle)
|
|
92
|
+
: undefined;
|
|
93
|
+
void mainLlm;
|
|
94
|
+
return {
|
|
95
|
+
planner,
|
|
96
|
+
interpreter,
|
|
97
|
+
workers,
|
|
98
|
+
activation,
|
|
99
|
+
reviewer,
|
|
100
|
+
errorStrategy,
|
|
101
|
+
stateOracle,
|
|
102
|
+
finalizer,
|
|
103
|
+
maxRoundTrips: coordCfg.maxRoundTrips,
|
|
104
|
+
oracleName,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=build-dag-coordinator-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-dag-coordinator-deps.js","sourceRoot":"","sources":["../../src/smart-agent/build-dag-coordinator-deps.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EAEd,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AA2BrB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAmC;IAEnC,MAAM,EACJ,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,IAAI,GACL,GAAG,KAAK,CAAC;IAEV,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAElE,yEAAyE;IACzE,kBAAkB;IAClB,oEAAoE;IACpE,oEAAoE;IACpE,0DAA0D;IAC1D,+DAA+D;IAC/D,MAAM,cAAc,GAAG,KAAK,EAC1B,IAAwB,EACxB,mBAAyB,OAAO,EACjB,EAAE;QACjB,kEAAkE;QAClE,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,OAAO,CAAC;gBACb,GAAG,MAAM;gBACT,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC;aACpD,CAAC,CAAC;QACL,CAAC;QACD,4DAA4D;QAC5D,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5C,OAAO,SAAS,IAAI,gBAAg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AAO;QACP,UAAU;QACV,QAAQ;QACR,aAAa;QACb,WAAW;QACX,SAAS;QACT,aAAa,EAAE,QAAQ,CAAC,aAAmC;QAC3D,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type IKnowledgeRagHandle, type ILlm, type IStepper, type ITaskFormalizer, type LlmCallEntry, TokenLedger } from '@mcp-abap-adt/llm-agent';
|
|
2
|
+
import { RootFinalizer, Stepper } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
|
+
import { type NormalizedLlmMap, type StepperCompositionSpec, type StepperCoordinatorConfig } from './config.js';
|
|
4
|
+
import type { SmartServerLlmConfig } from './smart-server.js';
|
|
5
|
+
export interface BuildStepperRootInput {
|
|
6
|
+
/** Raw coordinator config object (e.g. the `coordinator:` YAML block). */
|
|
7
|
+
coordCfg: Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Pre-built named registry of subagent Steppers — DI/test override for
|
|
10
|
+
* deep-stepper mode. When non-empty it is used as childSteppers verbatim;
|
|
11
|
+
* when empty, child Steppers are built from `subagents` (the normal path).
|
|
12
|
+
*/
|
|
13
|
+
registry: ReadonlyMap<string, IStepper>;
|
|
14
|
+
/**
|
|
15
|
+
* Declared subagents (name + description) from the `subagents:` YAML block.
|
|
16
|
+
* In deep-stepper mode each becomes a recursive child Stepper sharing this
|
|
17
|
+
* run's planner/executor/reviewer/ledger, and is advertised to the planner so
|
|
18
|
+
* it can delegate sub-goals via a node's `agent`. Ignored in other modes.
|
|
19
|
+
*/
|
|
20
|
+
subagents?: ReadonlyArray<{
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** Factory to build an ILlm from a config; used for all roles. */
|
|
25
|
+
makeLlm: (config: SmartServerLlmConfig) => Promise<ILlm>;
|
|
26
|
+
/** Per-sessionId knowledge RAG factory. */
|
|
27
|
+
knowledgeRagFor: (sessionId: string) => IKnowledgeRagHandle;
|
|
28
|
+
/** Shared tools RAG handle. */
|
|
29
|
+
toolsRag: import('@mcp-abap-adt/llm-agent').IToolsRagHandle;
|
|
30
|
+
/** MCP tool invoker. */
|
|
31
|
+
callMcp: (name: string, args: unknown, signal?: AbortSignal) => Promise<string>;
|
|
32
|
+
/** Monotonically-unique stepper-ID minter. */
|
|
33
|
+
mintStepperId: () => string;
|
|
34
|
+
/**
|
|
35
|
+
* Normalized per-role LLM map (top-level `llm:` block after normalization).
|
|
36
|
+
* Roles resolve via: llmMap[role] → llmMap.main → pipelineFallback.
|
|
37
|
+
* When both are undefined, roles fall back to a stub (test path).
|
|
38
|
+
*/
|
|
39
|
+
llmMap?: NormalizedLlmMap;
|
|
40
|
+
/**
|
|
41
|
+
* Pipeline fallback config (`pipeline.llm.main`). Used as last resort when
|
|
42
|
+
* a role is absent from llmMap.
|
|
43
|
+
*/
|
|
44
|
+
pipelineFallback?: SmartServerLlmConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Optional usage logger. When supplied, every per-role LLM call is logged
|
|
47
|
+
* via a LoggingLlm decorator so byComponent is populated in requestLogger.
|
|
48
|
+
* Matches IRequestLogger.logLlmCall(entry) — pass a bound wrapper that
|
|
49
|
+
* injects the traceId as requestId.
|
|
50
|
+
*/
|
|
51
|
+
logLlmCall?: (entry: LlmCallEntry) => void;
|
|
52
|
+
}
|
|
53
|
+
export interface BuiltStepperRoot {
|
|
54
|
+
rootStepper: Stepper;
|
|
55
|
+
finalizer: RootFinalizer;
|
|
56
|
+
budget: {
|
|
57
|
+
depthRemaining: number;
|
|
58
|
+
tokens: TokenLedger;
|
|
59
|
+
};
|
|
60
|
+
maxParallelSteps: number;
|
|
61
|
+
/**
|
|
62
|
+
* Present only when `coordinator.formalizeTask` is enabled. The handler calls
|
|
63
|
+
* it ONCE on the raw prompt and threads the resulting TaskSpec into
|
|
64
|
+
* rootStepper.run. Absent → no formalization (behaves as before).
|
|
65
|
+
*/
|
|
66
|
+
taskFormalizer?: ITaskFormalizer;
|
|
67
|
+
}
|
|
68
|
+
export type { CompositionNode, StepperCompositionSpec } from './config.js';
|
|
69
|
+
/** Build-time dependencies (everything not part of the composition itself). */
|
|
70
|
+
export interface BuildFromCompositionDeps {
|
|
71
|
+
/**
|
|
72
|
+
* Factory to build an ILlm from a server config. Used by the legacy
|
|
73
|
+
* llmMap/pipelineFallback resolution path. Optional when makeRoleLlm is
|
|
74
|
+
* supplied instead.
|
|
75
|
+
*/
|
|
76
|
+
makeLlm?: (config: SmartServerLlmConfig) => Promise<ILlm>;
|
|
77
|
+
callMcp: (name: string, args: unknown, signal?: AbortSignal) => Promise<string>;
|
|
78
|
+
mintStepperId: () => string;
|
|
79
|
+
/** Optional per-role LLM map (legacy server path). */
|
|
80
|
+
llmMap?: NormalizedLlmMap;
|
|
81
|
+
/** Pipeline fallback config (legacy server path). */
|
|
82
|
+
pipelineFallback?: SmartServerLlmConfig;
|
|
83
|
+
logLlmCall?: (entry: LlmCallEntry) => void;
|
|
84
|
+
subagents?: ReadonlyArray<{
|
|
85
|
+
name: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
}>;
|
|
88
|
+
registry: ReadonlyMap<string, IStepper>;
|
|
89
|
+
/**
|
|
90
|
+
* When present, supersedes llmMap/makeLlm resolution: resolve a role's LLM
|
|
91
|
+
* directly. Enables config-decoupled pipeline builder-factories that live in a
|
|
92
|
+
* library without depending on SmartServerLlmConfig.
|
|
93
|
+
*/
|
|
94
|
+
makeRoleLlm?: (role: string) => Promise<ILlm>;
|
|
95
|
+
}
|
|
96
|
+
/** Map a parsed coordinator config to the front-end-agnostic composition spec. */
|
|
97
|
+
export declare function toCompositionSpec(config: StepperCoordinatorConfig): StepperCompositionSpec;
|
|
98
|
+
/**
|
|
99
|
+
* yaml front-end: parse the raw coordinator config block → composition spec →
|
|
100
|
+
* build. Thin wrapper over {@link buildFromComposition}; a code builder can call
|
|
101
|
+
* buildFromComposition directly with a spec it constructs itself (parity).
|
|
102
|
+
*/
|
|
103
|
+
export declare function buildStepperRoot(input: BuildStepperRootInput): Promise<BuiltStepperRoot>;
|
|
104
|
+
/**
|
|
105
|
+
* Build the root Stepper + finalizer from a front-end-agnostic composition spec.
|
|
106
|
+
* The yaml path reaches here via buildStepperRoot; a code builder can call this
|
|
107
|
+
* directly. Each role LLM resolves via llmMap[role] → llmMap.main → fallback.
|
|
108
|
+
*/
|
|
109
|
+
export declare function buildFromComposition(spec: StepperCompositionSpec, deps: BuildFromCompositionDeps): Promise<BuiltStepperRoot>;
|
|
110
|
+
//# sourceMappingURL=build-stepper-root.d.ts.map
|