@mcp-abap-adt/llm-agent 2.9.2 → 2.10.1
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/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/smart-agent/agent.d.ts +18 -1
- package/dist/smart-agent/agent.d.ts.map +1 -1
- package/dist/smart-agent/agent.js +218 -37
- package/dist/smart-agent/agent.js.map +1 -1
- package/dist/smart-agent/builder.d.ts +114 -51
- package/dist/smart-agent/builder.d.ts.map +1 -1
- package/dist/smart-agent/builder.js +234 -110
- package/dist/smart-agent/builder.js.map +1 -1
- package/dist/smart-agent/cli.d.ts +1 -0
- package/dist/smart-agent/cli.d.ts.map +1 -1
- package/dist/smart-agent/cli.js +2 -0
- package/dist/smart-agent/cli.js.map +1 -1
- package/dist/smart-agent/config/config-watcher.d.ts +4 -0
- package/dist/smart-agent/config/config-watcher.d.ts.map +1 -1
- package/dist/smart-agent/config/config-watcher.js +8 -0
- package/dist/smart-agent/config/config-watcher.js.map +1 -1
- package/dist/smart-agent/config.d.ts +2 -1
- package/dist/smart-agent/config.d.ts.map +1 -1
- package/dist/smart-agent/config.js +46 -4
- package/dist/smart-agent/config.js.map +1 -1
- package/dist/smart-agent/interfaces/index.d.ts +1 -1
- package/dist/smart-agent/interfaces/index.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/index.js.map +1 -1
- package/dist/smart-agent/interfaces/rag.d.ts +16 -0
- package/dist/smart-agent/interfaces/rag.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/condition-evaluator.d.ts +35 -0
- package/dist/smart-agent/pipeline/condition-evaluator.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/condition-evaluator.js +143 -0
- package/dist/smart-agent/pipeline/condition-evaluator.js.map +1 -0
- package/dist/smart-agent/pipeline/context.d.ts +104 -0
- package/dist/smart-agent/pipeline/context.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/context.js +19 -0
- package/dist/smart-agent/pipeline/context.js.map +1 -0
- package/dist/smart-agent/pipeline/default-pipeline.d.ts +45 -0
- package/dist/smart-agent/pipeline/default-pipeline.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/default-pipeline.js +118 -0
- package/dist/smart-agent/pipeline/default-pipeline.js.map +1 -0
- package/dist/smart-agent/pipeline/executor.d.ts +54 -0
- package/dist/smart-agent/pipeline/executor.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/executor.js +133 -0
- package/dist/smart-agent/pipeline/executor.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/assemble.d.ts +16 -0
- package/dist/smart-agent/pipeline/handlers/assemble.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/assemble.js +57 -0
- package/dist/smart-agent/pipeline/handlers/assemble.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/classify.d.ts +21 -0
- package/dist/smart-agent/pipeline/handlers/classify.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/classify.js +53 -0
- package/dist/smart-agent/pipeline/handlers/classify.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/expand.d.ts +16 -0
- package/dist/smart-agent/pipeline/handlers/expand.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/expand.js +24 -0
- package/dist/smart-agent/pipeline/handlers/expand.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/index.d.ts +28 -0
- package/dist/smart-agent/pipeline/handlers/index.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/index.js +39 -0
- package/dist/smart-agent/pipeline/handlers/index.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/rag-query.d.ts +25 -0
- package/dist/smart-agent/pipeline/handlers/rag-query.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/rag-query.js +53 -0
- package/dist/smart-agent/pipeline/handlers/rag-query.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/rag-upsert.d.ts +17 -0
- package/dist/smart-agent/pipeline/handlers/rag-upsert.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/rag-upsert.js +47 -0
- package/dist/smart-agent/pipeline/handlers/rag-upsert.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/rerank.d.ts +16 -0
- package/dist/smart-agent/pipeline/handlers/rerank.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/rerank.js +38 -0
- package/dist/smart-agent/pipeline/handlers/rerank.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/summarize.d.ts +17 -0
- package/dist/smart-agent/pipeline/handlers/summarize.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/summarize.js +47 -0
- package/dist/smart-agent/pipeline/handlers/summarize.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/tool-loop.d.ts +32 -0
- package/dist/smart-agent/pipeline/handlers/tool-loop.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/tool-loop.js +416 -0
- package/dist/smart-agent/pipeline/handlers/tool-loop.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/tool-select.d.ts +21 -0
- package/dist/smart-agent/pipeline/handlers/tool-select.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/tool-select.js +95 -0
- package/dist/smart-agent/pipeline/handlers/tool-select.js.map +1 -0
- package/dist/smart-agent/pipeline/handlers/translate.d.ts +18 -0
- package/dist/smart-agent/pipeline/handlers/translate.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/handlers/translate.js +39 -0
- package/dist/smart-agent/pipeline/handlers/translate.js.map +1 -0
- package/dist/smart-agent/pipeline/index.d.ts +14 -0
- package/dist/smart-agent/pipeline/index.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/index.js +16 -0
- package/dist/smart-agent/pipeline/index.js.map +1 -0
- package/dist/smart-agent/pipeline/stage-handler.d.ts +36 -0
- package/dist/smart-agent/pipeline/stage-handler.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/stage-handler.js +24 -0
- package/dist/smart-agent/pipeline/stage-handler.js.map +1 -0
- package/dist/smart-agent/pipeline/types.d.ts +129 -0
- package/dist/smart-agent/pipeline/types.d.ts.map +1 -0
- package/dist/smart-agent/pipeline/types.js +54 -0
- package/dist/smart-agent/pipeline/types.js.map +1 -0
- package/dist/smart-agent/pipeline.d.ts +22 -6
- package/dist/smart-agent/pipeline.d.ts.map +1 -1
- package/dist/smart-agent/pipeline.js +5 -142
- package/dist/smart-agent/pipeline.js.map +1 -1
- package/dist/smart-agent/plugins/index.d.ts +4 -0
- package/dist/smart-agent/plugins/index.d.ts.map +1 -0
- package/dist/smart-agent/plugins/index.js +3 -0
- package/dist/smart-agent/plugins/index.js.map +1 -0
- package/dist/smart-agent/plugins/loader.d.ts +67 -0
- package/dist/smart-agent/plugins/loader.d.ts.map +1 -0
- package/dist/smart-agent/plugins/loader.js +114 -0
- package/dist/smart-agent/plugins/loader.js.map +1 -0
- package/dist/smart-agent/plugins/types.d.ts +149 -0
- package/dist/smart-agent/plugins/types.d.ts.map +1 -0
- package/dist/smart-agent/plugins/types.js +111 -0
- package/dist/smart-agent/plugins/types.js.map +1 -0
- package/dist/smart-agent/providers.d.ts +76 -0
- package/dist/smart-agent/providers.d.ts.map +1 -0
- package/dist/smart-agent/providers.js +175 -0
- package/dist/smart-agent/providers.js.map +1 -0
- package/dist/smart-agent/rag/embedder-factories.d.ts +9 -0
- package/dist/smart-agent/rag/embedder-factories.d.ts.map +1 -0
- package/dist/smart-agent/rag/embedder-factories.js +27 -0
- package/dist/smart-agent/rag/embedder-factories.js.map +1 -0
- package/dist/smart-agent/rag/index.d.ts +7 -0
- package/dist/smart-agent/rag/index.d.ts.map +1 -1
- package/dist/smart-agent/rag/index.js +4 -0
- package/dist/smart-agent/rag/index.js.map +1 -1
- package/dist/smart-agent/smart-server.d.ts +25 -1
- package/dist/smart-agent/smart-server.d.ts.map +1 -1
- package/dist/smart-agent/smart-server.js +122 -27
- package/dist/smart-agent/smart-server.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,11 +20,22 @@ export type { IToolCache } from './smart-agent/cache/types.js';
|
|
|
20
20
|
export { ConfigWatcher, type ConfigWatcherOptions, type HotReloadableConfig, } from './smart-agent/config/config-watcher.js';
|
|
21
21
|
export { HealthChecker, type HealthCheckerDeps, } from './smart-agent/health/health-checker.js';
|
|
22
22
|
export type { CircuitBreakerStatus, HealthComponentStatus, HealthStatus, } from './smart-agent/health/types.js';
|
|
23
|
+
export type { EmbedderFactory, EmbedderFactoryConfig, IEmbedder, IRag, } from './smart-agent/interfaces/rag.js';
|
|
24
|
+
export type { CallOptions, LlmTool, RagError, RagResult, Result, } from './smart-agent/interfaces/types.js';
|
|
23
25
|
export { type CounterSnapshot, type HistogramSnapshot, InMemoryMetrics, type MetricsSnapshot, } from './smart-agent/metrics/in-memory-metrics.js';
|
|
24
26
|
export { NoopMetrics } from './smart-agent/metrics/noop-metrics.js';
|
|
25
27
|
export type { ICounter, IHistogram, IMetrics, } from './smart-agent/metrics/types.js';
|
|
28
|
+
export type { BuiltInStageType, ControlFlowType, IStageHandler, PipelineContext, StageDefinition, StageType, StructuredPipelineDefinition, } from './smart-agent/pipeline/index.js';
|
|
29
|
+
export { buildDefaultHandlerRegistry, evaluateCondition, getDefaultPipelineDefinition, getDefaultStages, PipelineExecutor, } from './smart-agent/pipeline/index.js';
|
|
30
|
+
export type { IPluginLoader, LoadedPlugins, PluginExports, } from './smart-agent/plugins/index.js';
|
|
31
|
+
export { emptyLoadedPlugins, FileSystemPluginLoader, type FileSystemPluginLoaderConfig, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './smart-agent/plugins/index.js';
|
|
32
|
+
export { builtInEmbedderFactories } from './smart-agent/rag/embedder-factories.js';
|
|
33
|
+
export { InMemoryRag } from './smart-agent/rag/in-memory-rag.js';
|
|
34
|
+
export { OllamaEmbedder, type OllamaEmbedderConfig, OllamaRag, } from './smart-agent/rag/ollama-rag.js';
|
|
35
|
+
export { OpenAiEmbedder, type OpenAiEmbedderConfig, } from './smart-agent/rag/openai-embedder.js';
|
|
26
36
|
export { QdrantRag, type QdrantRagConfig, } from './smart-agent/rag/qdrant-rag.js';
|
|
27
37
|
export { type IQueryExpander, LlmQueryExpander, NoopQueryExpander, } from './smart-agent/rag/query-expander.js';
|
|
38
|
+
export { VectorRag, type VectorRagConfig, } from './smart-agent/rag/vector-rag.js';
|
|
28
39
|
export { LlmReranker } from './smart-agent/reranker/llm-reranker.js';
|
|
29
40
|
export { NoopReranker } from './smart-agent/reranker/noop-reranker.js';
|
|
30
41
|
export type { IReranker } from './smart-agent/reranker/types.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,GAC1B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,eAAe,EACpB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EACL,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO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M,iDAAiD,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,YAAY,EACV,KAAK,EACL,OAAO,EACP,WAAW,EACX,UAAU,GACX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,YAAY,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,10 +28,17 @@ export { ConfigWatcher, } from './smart-agent/config/config-watcher.js';
|
|
|
28
28
|
export { HealthChecker, } from './smart-agent/health/health-checker.js';
|
|
29
29
|
export { InMemoryMetrics, } from './smart-agent/metrics/in-memory-metrics.js';
|
|
30
30
|
export { NoopMetrics } from './smart-agent/metrics/noop-metrics.js';
|
|
31
|
+
export { buildDefaultHandlerRegistry, evaluateCondition, getDefaultPipelineDefinition, getDefaultStages, PipelineExecutor, } from './smart-agent/pipeline/index.js';
|
|
32
|
+
export { emptyLoadedPlugins, FileSystemPluginLoader, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './smart-agent/plugins/index.js';
|
|
33
|
+
export { builtInEmbedderFactories } from './smart-agent/rag/embedder-factories.js';
|
|
34
|
+
export { InMemoryRag } from './smart-agent/rag/in-memory-rag.js';
|
|
35
|
+
export { OllamaEmbedder, OllamaRag, } from './smart-agent/rag/ollama-rag.js';
|
|
36
|
+
export { OpenAiEmbedder, } from './smart-agent/rag/openai-embedder.js';
|
|
31
37
|
// Qdrant RAG
|
|
32
38
|
export { QdrantRag, } from './smart-agent/rag/qdrant-rag.js';
|
|
33
39
|
// Query Expander
|
|
34
40
|
export { LlmQueryExpander, NoopQueryExpander, } from './smart-agent/rag/query-expander.js';
|
|
41
|
+
export { VectorRag, } from './smart-agent/rag/vector-rag.js';
|
|
35
42
|
// Reranker
|
|
36
43
|
export { LlmReranker } from './smart-agent/reranker/llm-reranker.js';
|
|
37
44
|
export { NoopReranker } from './smart-agent/reranker/noop-reranker.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,iEAAiE;AACjE,OAAO,EAAE,KAAK,EAAoB,MAAM,YAAY,CAAC;AACrD,OAAO,EACL,cAAc,GAEf,MAAM,6BAA6B,CAAC;AACrC,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,aAAa,GAEd,MAAM,4BAA4B,CAAC;AACpC,8DAA8D;AAC9D,mFAAmF;AACnF,OAAO,EAAE,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,gBAAgB,GAEjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,GAEf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAoB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAEL,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAqB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9E,gBAAgB;AAChB,2DAA2D;AAC3D,OAAO,EAGL,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAExC,aAAa;AACb,OAAO,EAEL,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AACzB,O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O,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAOjE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC"}
|
|
@@ -8,6 +8,8 @@ import type { IRag } from './interfaces/rag.js';
|
|
|
8
8
|
import { type CallOptions, type LlmStreamChunk, type Result, SmartAgentError } from './interfaces/types.js';
|
|
9
9
|
import type { ILogger } from './logger/index.js';
|
|
10
10
|
import type { IMetrics } from './metrics/types.js';
|
|
11
|
+
import type { PipelineExecutor } from './pipeline/executor.js';
|
|
12
|
+
import type { StageDefinition } from './pipeline/types.js';
|
|
11
13
|
import type { IPromptInjectionDetector, IToolPolicy, SessionPolicy } from './policy/types.js';
|
|
12
14
|
import { type IQueryExpander } from './rag/query-expander.js';
|
|
13
15
|
import type { IReranker } from './reranker/types.js';
|
|
@@ -59,6 +61,14 @@ export interface SmartAgentConfig {
|
|
|
59
61
|
sessionTokenBudget?: number;
|
|
60
62
|
/** Interval (ms) for SSE heartbeat comments during MCP tool execution. Default: 5000. */
|
|
61
63
|
heartbeatIntervalMs?: number;
|
|
64
|
+
/** Whether classification stage runs. Default: true. When false, input is treated as a single action. */
|
|
65
|
+
classificationEnabled?: boolean;
|
|
66
|
+
/** RAG retrieval behavior. 'auto': based on SAP context detection (default), 'always': force retrieval, 'never': skip. */
|
|
67
|
+
ragRetrievalMode?: 'auto' | 'always' | 'never';
|
|
68
|
+
/** Whether to translate non-ASCII RAG queries to English. Default: true. */
|
|
69
|
+
ragTranslationEnabled?: boolean;
|
|
70
|
+
/** Whether to upsert classified subprompts to RAG stores. Default: true. */
|
|
71
|
+
ragUpsertEnabled?: boolean;
|
|
62
72
|
}
|
|
63
73
|
export type StopReason = 'stop' | 'iteration_limit' | 'tool_call_limit';
|
|
64
74
|
export interface SmartAgentResponse {
|
|
@@ -75,6 +85,8 @@ export interface SmartAgentResponse {
|
|
|
75
85
|
export declare class SmartAgent {
|
|
76
86
|
private readonly deps;
|
|
77
87
|
private config;
|
|
88
|
+
private readonly pipelineExecutor?;
|
|
89
|
+
private readonly pipelineStages?;
|
|
78
90
|
private readonly toolAvailabilityRegistry;
|
|
79
91
|
private readonly tracer;
|
|
80
92
|
private readonly metrics;
|
|
@@ -83,7 +95,7 @@ export declare class SmartAgent {
|
|
|
83
95
|
private readonly toolCache;
|
|
84
96
|
private readonly outputValidator;
|
|
85
97
|
private readonly sessionManager;
|
|
86
|
-
constructor(deps: SmartAgentDeps, config: SmartAgentConfig);
|
|
98
|
+
constructor(deps: SmartAgentDeps, config: SmartAgentConfig, pipelineExecutor?: PipelineExecutor | undefined, pipelineStages?: StageDefinition[] | undefined);
|
|
87
99
|
/** Apply a partial config update at runtime (hot-reload). */
|
|
88
100
|
applyConfigUpdate(update: Partial<SmartAgentConfig>): void;
|
|
89
101
|
healthCheck(options?: CallOptions): Promise<Result<{
|
|
@@ -105,5 +117,10 @@ export declare class SmartAgent {
|
|
|
105
117
|
private _toEnglishForRag;
|
|
106
118
|
private _summarizeHistory;
|
|
107
119
|
private _buildRagMetadata;
|
|
120
|
+
/**
|
|
121
|
+
* Execute the structured pipeline — delegates stage execution to
|
|
122
|
+
* the PipelineExecutor instead of running the hardcoded flow.
|
|
123
|
+
*/
|
|
124
|
+
private _runStructuredPipeline;
|
|
108
125
|
}
|
|
109
126
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/smart-agent/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EA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,EAAE,OAAO,EAAE,CAAA;KAAE,GACpD,aAAa,CAAC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;YA0S7C,gBAAgB;YA8Ff,qBAAqB;YAyctB,aAAa;YAwBb,gBAAgB;YAsBhB,iBAAiB;IAkC/B,OAAO,CAAC,iBAAiB;IAUzB;;;OAGG;YACY,sBAAsB;CAkHtC"}
|
|
@@ -37,6 +37,8 @@ function createTimeoutSignal(ms) {
|
|
|
37
37
|
export class SmartAgent {
|
|
38
38
|
deps;
|
|
39
39
|
config;
|
|
40
|
+
pipelineExecutor;
|
|
41
|
+
pipelineStages;
|
|
40
42
|
toolAvailabilityRegistry;
|
|
41
43
|
tracer;
|
|
42
44
|
metrics;
|
|
@@ -45,9 +47,11 @@ export class SmartAgent {
|
|
|
45
47
|
toolCache;
|
|
46
48
|
outputValidator;
|
|
47
49
|
sessionManager;
|
|
48
|
-
constructor(deps, config) {
|
|
50
|
+
constructor(deps, config, pipelineExecutor, pipelineStages) {
|
|
49
51
|
this.deps = deps;
|
|
50
52
|
this.config = config;
|
|
53
|
+
this.pipelineExecutor = pipelineExecutor;
|
|
54
|
+
this.pipelineStages = pipelineStages;
|
|
51
55
|
this.toolAvailabilityRegistry = new ToolAvailabilityRegistry(this.config.toolUnavailableTtlMs);
|
|
52
56
|
this.tracer = deps.tracer ?? new NoopTracer();
|
|
53
57
|
this.metrics = deps.metrics ?? new NoopMetrics();
|
|
@@ -62,33 +66,59 @@ export class SmartAgent {
|
|
|
62
66
|
this.config = { ...this.config, ...update };
|
|
63
67
|
}
|
|
64
68
|
async healthCheck(options) {
|
|
69
|
+
const HEALTH_TIMEOUT_MS = 5_000;
|
|
70
|
+
const healthSignal = AbortSignal.timeout(HEALTH_TIMEOUT_MS);
|
|
71
|
+
const healthOptions = {
|
|
72
|
+
...options,
|
|
73
|
+
signal: healthSignal,
|
|
74
|
+
maxTokens: 1,
|
|
75
|
+
};
|
|
65
76
|
const results = {
|
|
66
77
|
llm: false,
|
|
67
78
|
rag: false,
|
|
68
79
|
mcp: [],
|
|
69
80
|
};
|
|
70
81
|
try {
|
|
71
|
-
const llmRes = await this.deps.mainLlm.chat([{ role: 'user', content: 'ping' }], [],
|
|
82
|
+
const llmRes = await this.deps.mainLlm.chat([{ role: 'user', content: 'ping' }], [], healthOptions);
|
|
72
83
|
results.llm = llmRes.ok;
|
|
73
84
|
}
|
|
74
85
|
catch {
|
|
75
86
|
results.llm = false;
|
|
76
87
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
try {
|
|
89
|
+
const ragRes = await this.deps.ragStores.facts.healthCheck(healthOptions);
|
|
90
|
+
results.rag = ragRes.ok;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
results.rag = false;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const mcpChecks = await Promise.all(this.deps.mcpClients.map(async (client) => {
|
|
97
|
+
try {
|
|
98
|
+
const tools = await client.listTools(healthOptions);
|
|
99
|
+
return {
|
|
100
|
+
name: 'mcp-client',
|
|
101
|
+
ok: tools.ok,
|
|
102
|
+
error: tools.ok || !tools.error
|
|
103
|
+
? undefined
|
|
104
|
+
: tools.error instanceof Error
|
|
105
|
+
? tools.error.message
|
|
106
|
+
: String(tools.error),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
return {
|
|
111
|
+
name: 'mcp-client',
|
|
112
|
+
ok: false,
|
|
113
|
+
error: err instanceof Error ? err.message : String(err),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
results.mcp = mcpChecks;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// AbortSignal timeout — leave mcp as empty
|
|
121
|
+
}
|
|
92
122
|
return { ok: true, value: results };
|
|
93
123
|
}
|
|
94
124
|
async process(textOrMessages, options) {
|
|
@@ -161,7 +191,16 @@ export class SmartAgent {
|
|
|
161
191
|
rootSpan.end();
|
|
162
192
|
return;
|
|
163
193
|
}
|
|
164
|
-
//
|
|
194
|
+
// Structured pipeline path (when configured via Builder.withPipeline)
|
|
195
|
+
if (this.pipelineExecutor && this.pipelineStages) {
|
|
196
|
+
const stream = this._runStructuredPipeline(textOrMessages, externalTools, opts, rootSpan, sessionId);
|
|
197
|
+
for await (const chunk of stream)
|
|
198
|
+
yield chunk;
|
|
199
|
+
rootSpan.setStatus('ok');
|
|
200
|
+
rootSpan.end();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// 1. Unified Preparation (default hardcoded flow)
|
|
165
204
|
const initResult = await this._preparePipeline(textOrMessages, opts, rootSpan);
|
|
166
205
|
if (!initResult.ok) {
|
|
167
206
|
rootSpan.setStatus('error', initResult.error.message);
|
|
@@ -180,7 +219,9 @@ export class SmartAgent {
|
|
|
180
219
|
}
|
|
181
220
|
// 2. Decide context and tools for the WHOLE request
|
|
182
221
|
const actions = subprompts.filter((sp) => sp.type === 'action');
|
|
222
|
+
const ragMode = this.config.ragRetrievalMode ?? 'auto';
|
|
183
223
|
const isSapRequired = actions.some((a) => a.context === 'sap-abap') || mode === 'hard';
|
|
224
|
+
const shouldRetrieve = ragMode === 'always' || (ragMode === 'auto' && isSapRequired);
|
|
184
225
|
let finalTools = [];
|
|
185
226
|
let retrieved = {
|
|
186
227
|
facts: [],
|
|
@@ -188,10 +229,12 @@ export class SmartAgent {
|
|
|
188
229
|
state: [],
|
|
189
230
|
tools: [],
|
|
190
231
|
};
|
|
191
|
-
if (
|
|
232
|
+
if (shouldRetrieve) {
|
|
192
233
|
// Collect all action texts for RAG
|
|
193
234
|
const combinedActionText = actions.map((a) => a.text).join(' ');
|
|
194
|
-
let ragText =
|
|
235
|
+
let ragText = this.config.ragTranslationEnabled !== false
|
|
236
|
+
? await this._toEnglishForRag(combinedActionText, opts)
|
|
237
|
+
: combinedActionText;
|
|
195
238
|
if (this.config.queryExpansionEnabled) {
|
|
196
239
|
const expandResult = await this.queryExpander.expand(ragText, opts);
|
|
197
240
|
if (expandResult.ok)
|
|
@@ -234,6 +277,17 @@ export class SmartAgent {
|
|
|
234
277
|
]);
|
|
235
278
|
const { tools: mcpTools } = await this._listAllTools(opts);
|
|
236
279
|
const facts = rerankedFacts.ok ? rerankedFacts.value : [];
|
|
280
|
+
// Log RAG results with scores for diagnostics
|
|
281
|
+
opts?.sessionLogger?.logStep('rag_query_facts', {
|
|
282
|
+
query: ragText.slice(0, 200),
|
|
283
|
+
k,
|
|
284
|
+
resultCount: facts.length,
|
|
285
|
+
results: facts.map((r) => ({
|
|
286
|
+
id: r.metadata.id,
|
|
287
|
+
score: r.score,
|
|
288
|
+
text: r.text.slice(0, 120),
|
|
289
|
+
})),
|
|
290
|
+
});
|
|
237
291
|
const ragToolNames = new Set(facts
|
|
238
292
|
.map((r) => r.metadata.id)
|
|
239
293
|
.filter((id) => id?.startsWith('tool:'))
|
|
@@ -243,6 +297,16 @@ export class SmartAgent {
|
|
|
243
297
|
: mode === 'hard'
|
|
244
298
|
? mcpTools
|
|
245
299
|
: [];
|
|
300
|
+
// Log tool selection diagnostics
|
|
301
|
+
opts?.sessionLogger?.logStep('tools_selected', {
|
|
302
|
+
totalMcp: mcpTools.length,
|
|
303
|
+
ragMatchedTools: [...ragToolNames],
|
|
304
|
+
selectedCount: selectedMcpTools.length + externalTools.length,
|
|
305
|
+
selectedNames: [
|
|
306
|
+
...selectedMcpTools.map((t) => t.name),
|
|
307
|
+
...externalTools.map((t) => t.name),
|
|
308
|
+
],
|
|
309
|
+
});
|
|
246
310
|
retrieved = {
|
|
247
311
|
facts,
|
|
248
312
|
feedback: rerankedFeedback.ok ? rerankedFeedback.value : [],
|
|
@@ -332,28 +396,42 @@ export class SmartAgent {
|
|
|
332
396
|
if (res.ok)
|
|
333
397
|
processedHistory = res.value;
|
|
334
398
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
399
|
+
let subprompts;
|
|
400
|
+
if (this.config.classificationEnabled === false) {
|
|
401
|
+
// Skip classification — treat entire input as a single action
|
|
402
|
+
subprompts = [
|
|
403
|
+
{ type: 'action', text, dependency: 'independent' },
|
|
404
|
+
];
|
|
405
|
+
opts?.sessionLogger?.logStep('classification_skipped', { text });
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
const classifySpan = this.tracer.startSpan('smart_agent.classify', {
|
|
409
|
+
parent: parentSpan,
|
|
410
|
+
});
|
|
411
|
+
const classifyResult = await this.deps.classifier.classify(text, opts);
|
|
412
|
+
if (!classifyResult.ok) {
|
|
413
|
+
classifySpan.setStatus('error', classifyResult.error.message);
|
|
414
|
+
classifySpan.end();
|
|
415
|
+
return {
|
|
416
|
+
ok: false,
|
|
417
|
+
error: new OrchestratorError(classifyResult.error.message, 'CLASSIFIER_ERROR'),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
classifySpan.setStatus('ok');
|
|
341
421
|
classifySpan.end();
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
422
|
+
opts?.sessionLogger?.logStep('classifier_response', {
|
|
423
|
+
subprompts: classifyResult.value,
|
|
424
|
+
});
|
|
425
|
+
subprompts = classifyResult.value;
|
|
346
426
|
}
|
|
347
|
-
classifySpan.setStatus('ok');
|
|
348
|
-
classifySpan.end();
|
|
349
|
-
opts?.sessionLogger?.logStep('classifier_response', {
|
|
350
|
-
subprompts: classifyResult.value,
|
|
351
|
-
});
|
|
352
|
-
const subprompts = classifyResult.value;
|
|
353
427
|
for (const sp of subprompts) {
|
|
354
428
|
this.metrics.classifierIntentCount.add(1, { intent: sp.type });
|
|
355
429
|
}
|
|
356
|
-
const others =
|
|
430
|
+
const others = this.config.ragUpsertEnabled !== false
|
|
431
|
+
? subprompts.filter((sp) => sp.type === 'fact' ||
|
|
432
|
+
sp.type === 'state' ||
|
|
433
|
+
sp.type === 'feedback')
|
|
434
|
+
: [];
|
|
357
435
|
const ragStoreMap = new Map([
|
|
358
436
|
['fact', this.deps.ragStores.facts],
|
|
359
437
|
['feedback', this.deps.ragStores.feedback],
|
|
@@ -838,5 +916,108 @@ export class SmartAgent {
|
|
|
838
916
|
m.ttl = Math.floor((Date.now() + p.maxSessionAgeMs) / 1000);
|
|
839
917
|
return m;
|
|
840
918
|
}
|
|
919
|
+
/**
|
|
920
|
+
* Execute the structured pipeline — delegates stage execution to
|
|
921
|
+
* the PipelineExecutor instead of running the hardcoded flow.
|
|
922
|
+
*/
|
|
923
|
+
async *_runStructuredPipeline(textOrMessages, externalTools, opts, parentSpan, sessionId) {
|
|
924
|
+
if (!this.pipelineExecutor || !this.pipelineStages)
|
|
925
|
+
return;
|
|
926
|
+
const text = typeof textOrMessages === 'string'
|
|
927
|
+
? textOrMessages
|
|
928
|
+
: (textOrMessages.filter((m) => m.role === 'user').slice(-1)[0]
|
|
929
|
+
?.content ?? '');
|
|
930
|
+
const history = typeof textOrMessages === 'string' ? [] : textOrMessages;
|
|
931
|
+
// Collect yielded chunks via a queue
|
|
932
|
+
const chunkQueue = [];
|
|
933
|
+
let resolveWait = null;
|
|
934
|
+
let done = false;
|
|
935
|
+
const ctx = {
|
|
936
|
+
// Immutable input
|
|
937
|
+
textOrMessages,
|
|
938
|
+
options: opts,
|
|
939
|
+
config: this.config,
|
|
940
|
+
sessionId,
|
|
941
|
+
// Dependencies
|
|
942
|
+
mainLlm: this.deps.mainLlm,
|
|
943
|
+
helperLlm: this.deps.helperLlm,
|
|
944
|
+
classifierLlm: this.deps.mainLlm,
|
|
945
|
+
classifier: this.deps.classifier,
|
|
946
|
+
assembler: this.deps.assembler,
|
|
947
|
+
ragStores: this.deps.ragStores,
|
|
948
|
+
mcpClients: this.deps.mcpClients,
|
|
949
|
+
reranker: this.reranker,
|
|
950
|
+
queryExpander: this.queryExpander,
|
|
951
|
+
toolCache: this.toolCache,
|
|
952
|
+
outputValidator: this.outputValidator,
|
|
953
|
+
sessionManager: this.sessionManager,
|
|
954
|
+
tracer: this.tracer,
|
|
955
|
+
metrics: this.metrics,
|
|
956
|
+
logger: this.deps.logger,
|
|
957
|
+
toolPolicy: this.deps.toolPolicy,
|
|
958
|
+
injectionDetector: this.deps.injectionDetector,
|
|
959
|
+
toolAvailabilityRegistry: this.toolAvailabilityRegistry,
|
|
960
|
+
// Mutable state
|
|
961
|
+
inputText: text,
|
|
962
|
+
history: [...history],
|
|
963
|
+
subprompts: [],
|
|
964
|
+
toolClientMap: new Map(),
|
|
965
|
+
ragText: '',
|
|
966
|
+
ragResults: { facts: [], feedback: [], state: [] },
|
|
967
|
+
mcpTools: [],
|
|
968
|
+
selectedTools: [],
|
|
969
|
+
externalTools,
|
|
970
|
+
assembledMessages: [],
|
|
971
|
+
activeTools: [],
|
|
972
|
+
// Control flags
|
|
973
|
+
shouldRetrieve: false,
|
|
974
|
+
isAscii: true,
|
|
975
|
+
isSapRequired: false,
|
|
976
|
+
// Output
|
|
977
|
+
timing: [],
|
|
978
|
+
// Streaming yield
|
|
979
|
+
yield: (chunk) => {
|
|
980
|
+
chunkQueue.push(chunk);
|
|
981
|
+
if (resolveWait) {
|
|
982
|
+
resolveWait();
|
|
983
|
+
resolveWait = null;
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
};
|
|
987
|
+
// Run executor in background, yield chunks as they arrive
|
|
988
|
+
const executorPromise = this.pipelineExecutor
|
|
989
|
+
.executeStages(this.pipelineStages, ctx, parentSpan)
|
|
990
|
+
.then(() => {
|
|
991
|
+
done = true;
|
|
992
|
+
if (resolveWait) {
|
|
993
|
+
resolveWait();
|
|
994
|
+
resolveWait = null;
|
|
995
|
+
}
|
|
996
|
+
})
|
|
997
|
+
.catch((err) => {
|
|
998
|
+
chunkQueue.push({
|
|
999
|
+
ok: false,
|
|
1000
|
+
error: new OrchestratorError(String(err), 'PIPELINE_ERROR'),
|
|
1001
|
+
});
|
|
1002
|
+
done = true;
|
|
1003
|
+
if (resolveWait) {
|
|
1004
|
+
resolveWait();
|
|
1005
|
+
resolveWait = null;
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
while (!done || chunkQueue.length > 0) {
|
|
1009
|
+
if (chunkQueue.length > 0) {
|
|
1010
|
+
const chunk = chunkQueue.shift();
|
|
1011
|
+
if (chunk !== undefined)
|
|
1012
|
+
yield chunk;
|
|
1013
|
+
}
|
|
1014
|
+
else if (!done) {
|
|
1015
|
+
await new Promise((r) => {
|
|
1016
|
+
resolveWait = r;
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
await executorPromise;
|
|
1021
|
+
}
|
|
841
1022
|
}
|
|
842
1023
|
//# sourceMappingURL=agent.js.map
|