@mcp-abap-adt/llm-agent 5.1.2 → 5.4.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/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/smart-agent/agent.d.ts +10 -4
- package/dist/smart-agent/agent.d.ts.map +1 -1
- package/dist/smart-agent/agent.js +158 -80
- package/dist/smart-agent/agent.js.map +1 -1
- package/dist/smart-agent/builder.d.ts +9 -5
- package/dist/smart-agent/builder.d.ts.map +1 -1
- package/dist/smart-agent/builder.js +19 -8
- package/dist/smart-agent/builder.js.map +1 -1
- package/dist/smart-agent/interfaces/index.d.ts +2 -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/mcp-connection-strategy.d.ts +28 -0
- package/dist/smart-agent/interfaces/mcp-connection-strategy.d.ts.map +1 -0
- package/dist/smart-agent/interfaces/mcp-connection-strategy.js +2 -0
- package/dist/smart-agent/interfaces/mcp-connection-strategy.js.map +1 -0
- package/dist/smart-agent/interfaces/types.d.ts +4 -0
- package/dist/smart-agent/interfaces/types.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/types.js.map +1 -1
- package/dist/smart-agent/mcp-client-factory.d.ts +3 -0
- package/dist/smart-agent/mcp-client-factory.d.ts.map +1 -0
- package/dist/smart-agent/mcp-client-factory.js +21 -0
- package/dist/smart-agent/mcp-client-factory.js.map +1 -0
- package/dist/smart-agent/pipeline/context.d.ts +1 -10
- package/dist/smart-agent/pipeline/context.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/context.js +1 -1
- package/dist/smart-agent/pipeline/handlers/index.d.ts +1 -2
- package/dist/smart-agent/pipeline/handlers/index.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/handlers/index.js +1 -3
- package/dist/smart-agent/pipeline/handlers/index.js.map +1 -1
- package/dist/smart-agent/pipeline/handlers/present.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/handlers/present.js +0 -1
- package/dist/smart-agent/pipeline/handlers/present.js.map +1 -1
- package/dist/smart-agent/pipeline/handlers/tool-loop.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/handlers/tool-loop.js +112 -6
- package/dist/smart-agent/pipeline/handlers/tool-loop.js.map +1 -1
- package/dist/smart-agent/pipeline/index.d.ts +1 -1
- package/dist/smart-agent/pipeline/index.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/index.js +1 -1
- package/dist/smart-agent/pipeline/index.js.map +1 -1
- package/dist/smart-agent/pipeline/types.d.ts +1 -2
- package/dist/smart-agent/pipeline/types.d.ts.map +1 -1
- package/dist/smart-agent/pipeline/types.js +0 -1
- package/dist/smart-agent/pipeline/types.js.map +1 -1
- package/dist/smart-agent/strategies/index.d.ts +4 -0
- package/dist/smart-agent/strategies/index.d.ts.map +1 -0
- package/dist/smart-agent/strategies/index.js +4 -0
- package/dist/smart-agent/strategies/index.js.map +1 -0
- package/dist/smart-agent/strategies/lazy-connection-strategy.d.ts +15 -0
- package/dist/smart-agent/strategies/lazy-connection-strategy.d.ts.map +1 -0
- package/dist/smart-agent/strategies/lazy-connection-strategy.js +82 -0
- package/dist/smart-agent/strategies/lazy-connection-strategy.js.map +1 -0
- package/dist/smart-agent/strategies/noop-connection-strategy.d.ts +7 -0
- package/dist/smart-agent/strategies/noop-connection-strategy.d.ts.map +1 -0
- package/dist/smart-agent/strategies/noop-connection-strategy.js +6 -0
- package/dist/smart-agent/strategies/noop-connection-strategy.js.map +1 -0
- package/dist/smart-agent/strategies/periodic-connection-strategy.d.ts +13 -0
- package/dist/smart-agent/strategies/periodic-connection-strategy.d.ts.map +1 -0
- package/dist/smart-agent/strategies/periodic-connection-strategy.js +40 -0
- package/dist/smart-agent/strategies/periodic-connection-strategy.js.map +1 -0
- package/dist/smart-agent/testing/index.d.ts +2 -0
- package/dist/smart-agent/testing/index.d.ts.map +1 -1
- package/dist/smart-agent/testing/index.js +1 -0
- package/dist/smart-agent/testing/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,17 +31,19 @@ export { AdapterValidationError, type ApiRequestContext, type ApiSseEvent, type
|
|
|
31
31
|
export type { IClientAdapter } from './smart-agent/interfaces/client-adapter.js';
|
|
32
32
|
export type { ILlm } from './smart-agent/interfaces/llm.js';
|
|
33
33
|
export type { IMcpClient } from './smart-agent/interfaces/mcp-client.js';
|
|
34
|
+
export type { ConnectionStrategyOptions, IMcpConnectionStrategy, McpClientFactory, McpClientFactoryResult, McpConnectionConfig, McpConnectionResult, } from './smart-agent/interfaces/mcp-connection-strategy.js';
|
|
34
35
|
export type { IModelInfo, IModelProvider, } from './smart-agent/interfaces/model-provider.js';
|
|
35
36
|
export type { IQueryEmbedding } from './smart-agent/interfaces/query-embedding.js';
|
|
36
37
|
export type { EmbedderFactory, EmbedderFactoryConfig, IEmbedder, IRag, } from './smart-agent/interfaces/rag.js';
|
|
37
38
|
export type { ISkill, ISkillManager, ISkillMeta, ISkillResource, } from './smart-agent/interfaces/skill.js';
|
|
38
|
-
export type { CallOptions, LlmTool, RagError, RagResult, Result, } from './smart-agent/interfaces/types.js';
|
|
39
|
+
export type { CallOptions, LlmTool, RagError, RagResult, Result, StreamHookContext, } from './smart-agent/interfaces/types.js';
|
|
39
40
|
export { SkillError } from './smart-agent/interfaces/types.js';
|
|
41
|
+
export { createDefaultMcpClient } from './smart-agent/mcp-client-factory.js';
|
|
40
42
|
export { type CounterSnapshot, type HistogramSnapshot, InMemoryMetrics, type MetricsSnapshot, } from './smart-agent/metrics/in-memory-metrics.js';
|
|
41
43
|
export { NoopMetrics } from './smart-agent/metrics/noop-metrics.js';
|
|
42
44
|
export type { ICounter, IHistogram, IMetrics, } from './smart-agent/metrics/types.js';
|
|
43
45
|
export type { BuiltInStageType, ControlFlowType, IStageHandler, PipelineContext, StageDefinition, StageType, StructuredPipelineDefinition, } from './smart-agent/pipeline/index.js';
|
|
44
|
-
export { buildDefaultHandlerRegistry, evaluateCondition, getDefaultPipelineDefinition, getDefaultStages, PipelineExecutor,
|
|
46
|
+
export { buildDefaultHandlerRegistry, evaluateCondition, getDefaultPipelineDefinition, getDefaultStages, PipelineExecutor, } from './smart-agent/pipeline/index.js';
|
|
45
47
|
export type { IPluginLoader, LoadedPlugins, PluginExports, } from './smart-agent/plugins/index.js';
|
|
46
48
|
export { emptyLoadedPlugins, FileSystemPluginLoader, type FileSystemPluginLoaderConfig, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './smart-agent/plugins/index.js';
|
|
47
49
|
export { type EmbedderResolutionConfig, type EmbedderResolutionOptions, type LlmProviderConfig, makeDefaultLlm, makeLlm, makeRag, type RagResolutionConfig, type RagResolutionOptions, resolveEmbedder, } from './smart-agent/providers.js';
|
|
@@ -65,6 +67,7 @@ export { NoopSessionManager } from './smart-agent/session/noop-session-manager.j
|
|
|
65
67
|
export { SessionManager } from './smart-agent/session/session-manager.js';
|
|
66
68
|
export type { ISessionManager } from './smart-agent/session/types.js';
|
|
67
69
|
export { ClaudeSkillManager, CodexSkillManager, FileSystemSkillManager, } from './smart-agent/skills/index.js';
|
|
70
|
+
export { LazyConnectionStrategy, NoopConnectionStrategy, PeriodicConnectionStrategy, } from './smart-agent/strategies/index.js';
|
|
68
71
|
export { NoopTracer } from './smart-agent/tracer/noop-tracer.js';
|
|
69
72
|
export type { ISpan, ITracer, SpanOptions, SpanStatus, } from './smart-agent/tracer/types.js';
|
|
70
73
|
export { type ExternalToolValidationCode, type ExternalToolValidationError, normalizeAndValidateExternalTools, normalizeExternalTools, } from './smart-agent/utils/external-tools-normalizer.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,WA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AM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,YAAY,EACV,KAAK,EACL,OAAO,EACP,WAAW,EACX,UAAU,GACX,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EACL,aAAa,EACb,KAAK,WAAW,EAChB,IAAI,GACL,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,eAAe,GAChB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,YAAY,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kCAAkC,CAAC;AAE1C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -35,9 +35,10 @@ export { ConfigWatcher, } from './smart-agent/config/config-watcher.js';
|
|
|
35
35
|
export { HealthChecker, } from './smart-agent/health/health-checker.js';
|
|
36
36
|
export { AdapterValidationError, } from './smart-agent/interfaces/api-adapter.js';
|
|
37
37
|
export { SkillError } from './smart-agent/interfaces/types.js';
|
|
38
|
+
export { createDefaultMcpClient } from './smart-agent/mcp-client-factory.js';
|
|
38
39
|
export { InMemoryMetrics, } from './smart-agent/metrics/in-memory-metrics.js';
|
|
39
40
|
export { NoopMetrics } from './smart-agent/metrics/noop-metrics.js';
|
|
40
|
-
export { buildDefaultHandlerRegistry, evaluateCondition, getDefaultPipelineDefinition, getDefaultStages, PipelineExecutor,
|
|
41
|
+
export { buildDefaultHandlerRegistry, evaluateCondition, getDefaultPipelineDefinition, getDefaultStages, PipelineExecutor, } from './smart-agent/pipeline/index.js';
|
|
41
42
|
export { emptyLoadedPlugins, FileSystemPluginLoader, getDefaultPluginDirs, loadPlugins, mergePluginExports, } from './smart-agent/plugins/index.js';
|
|
42
43
|
export { makeDefaultLlm, makeLlm, makeRag, resolveEmbedder, } from './smart-agent/providers.js';
|
|
43
44
|
export { builtInEmbedderFactories } from './smart-agent/rag/embedder-factories.js';
|
|
@@ -62,6 +63,8 @@ export { RetryLlm, } from './smart-agent/resilience/retry-llm.js';
|
|
|
62
63
|
export { NoopSessionManager } from './smart-agent/session/noop-session-manager.js';
|
|
63
64
|
export { SessionManager } from './smart-agent/session/session-manager.js';
|
|
64
65
|
export { ClaudeSkillManager, CodexSkillManager, FileSystemSkillManager, } from './smart-agent/skills/index.js';
|
|
66
|
+
// Connection strategies
|
|
67
|
+
export { LazyConnectionStrategy, NoopConnectionStrategy, PeriodicConnectionStrategy, } from './smart-agent/strategies/index.js';
|
|
65
68
|
// Tracer
|
|
66
69
|
export { NoopTracer } from './smart-agent/tracer/noop-tracer.js';
|
|
67
70
|
// Utils
|
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,yB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F,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAG1E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,wBAAwB;AACxB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,SAAS;AACT,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAOjE,QAAQ;AACR,OAAO,EAGL,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,kDAAkD,CAAC;AAC1D,sBAAsB;AACtB,OAAO,EACL,aAAa,EAEb,IAAI,GACL,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,eAAe,GAChB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC"}
|
|
@@ -5,9 +5,10 @@ import type { ISubpromptClassifier } from './interfaces/classifier.js';
|
|
|
5
5
|
import type { IClientAdapter } from './interfaces/client-adapter.js';
|
|
6
6
|
import type { ILlm } from './interfaces/llm.js';
|
|
7
7
|
import type { IMcpClient } from './interfaces/mcp-client.js';
|
|
8
|
+
import type { IMcpConnectionStrategy } from './interfaces/mcp-connection-strategy.js';
|
|
8
9
|
import type { IEmbedder, IRag } from './interfaces/rag.js';
|
|
9
10
|
import type { ISkillManager } from './interfaces/skill.js';
|
|
10
|
-
import type { CallOptions, LlmStreamChunk, Result } from './interfaces/types.js';
|
|
11
|
+
import type { CallOptions, LlmStreamChunk, Result, StreamHookContext } from './interfaces/types.js';
|
|
11
12
|
export { type AgentCallOptions, OrchestratorError, type SmartAgentResponse, type StopReason, } from './interfaces/agent-contracts.js';
|
|
12
13
|
import { type AgentCallOptions, OrchestratorError, type SmartAgentResponse } from './interfaces/agent-contracts.js';
|
|
13
14
|
import type { ILogger } from './logger/index.js';
|
|
@@ -24,7 +25,6 @@ export type SmartAgentRagStores<K extends string = string> = Record<K, IRag>;
|
|
|
24
25
|
export interface SmartAgentDeps {
|
|
25
26
|
mainLlm: ILlm;
|
|
26
27
|
helperLlm?: ILlm;
|
|
27
|
-
presentationLlm?: ILlm;
|
|
28
28
|
mcpClients: IMcpClient[];
|
|
29
29
|
ragStores: SmartAgentRagStores;
|
|
30
30
|
classifier: ISubpromptClassifier;
|
|
@@ -43,6 +43,7 @@ export interface SmartAgentDeps {
|
|
|
43
43
|
clientAdapters?: IClientAdapter[];
|
|
44
44
|
/** Shared embedder for RAG queries. When set, creates memoized IQueryEmbedding per request. */
|
|
45
45
|
embedder?: IEmbedder;
|
|
46
|
+
connectionStrategy?: IMcpConnectionStrategy;
|
|
46
47
|
}
|
|
47
48
|
export interface SmartAgentConfig {
|
|
48
49
|
maxIterations: number;
|
|
@@ -76,8 +77,8 @@ export interface SmartAgentConfig {
|
|
|
76
77
|
* @deprecated No-op since 2.15.0 — tool lists are cached in McpClientAdapter.
|
|
77
78
|
*/
|
|
78
79
|
refreshToolsPerIteration?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
|
|
80
|
+
/** Re-select tools via RAG on each tool-loop iteration. Default: false. */
|
|
81
|
+
toolReselectPerIteration?: boolean;
|
|
81
82
|
/** Retry options for transient LLM failures (429, 5xx). When set, wraps LLM with RetryLlm. */
|
|
82
83
|
retry?: {
|
|
83
84
|
maxAttempts?: number;
|
|
@@ -91,6 +92,8 @@ export interface SmartAgentConfig {
|
|
|
91
92
|
* External tool calls and heartbeats are always streamed regardless of mode.
|
|
92
93
|
*/
|
|
93
94
|
streamMode?: 'full' | 'final';
|
|
95
|
+
/** Called before streaming the final response. Consumer can transform or pass through. */
|
|
96
|
+
onBeforeStream?: (content: string, ctx: StreamHookContext) => AsyncIterable<string>;
|
|
94
97
|
}
|
|
95
98
|
export declare class SmartAgent {
|
|
96
99
|
private readonly deps;
|
|
@@ -106,7 +109,10 @@ export declare class SmartAgent {
|
|
|
106
109
|
private readonly outputValidator;
|
|
107
110
|
private readonly sessionManager;
|
|
108
111
|
private readonly pendingToolResults;
|
|
112
|
+
private _activeClients;
|
|
109
113
|
constructor(deps: SmartAgentDeps, config: SmartAgentConfig, pipelineExecutor?: PipelineExecutor | undefined, pipelineStages?: StageDefinition[] | undefined);
|
|
114
|
+
private _resolveActiveClients;
|
|
115
|
+
private _revectorizeTools;
|
|
110
116
|
/** Apply a partial config update at runtime (hot-reload). */
|
|
111
117
|
applyConfigUpdate(update: Partial<SmartAgentConfig>): void;
|
|
112
118
|
healthCheck(options?: CallOptions): Promise<Result<{
|
|
@@ -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,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EACV,WAAW,EAEX,cAAc,EAKd,MAAM,
|
|
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,K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,MAAM,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;IAuDlD,aAAa,CAClB,cAAc,EAAE,MAAM,GAAG,OAAO,EAAE,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,aAAa,CAAC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;YAkV7C,gBAAgB;YA2Ff,qBAAqB;YAwsBtB,aAAa;YAyBb,gBAAgB;YAsBhB,iBAAiB;IAkC/B,OAAO,CAAC,iBAAiB;IAUzB;;;OAGG;YACY,sBAAsB;CA4HtC"}
|
|
@@ -46,6 +46,7 @@ export class SmartAgent {
|
|
|
46
46
|
outputValidator;
|
|
47
47
|
sessionManager;
|
|
48
48
|
pendingToolResults;
|
|
49
|
+
_activeClients;
|
|
49
50
|
constructor(deps, config, pipelineExecutor, pipelineStages) {
|
|
50
51
|
this.deps = deps;
|
|
51
52
|
this.config = config;
|
|
@@ -60,6 +61,30 @@ export class SmartAgent {
|
|
|
60
61
|
this.outputValidator = deps.outputValidator ?? new NoopValidator();
|
|
61
62
|
this.sessionManager = deps.sessionManager ?? new NoopSessionManager();
|
|
62
63
|
this.pendingToolResults = new PendingToolResultsRegistry();
|
|
64
|
+
this._activeClients = [...deps.mcpClients];
|
|
65
|
+
}
|
|
66
|
+
async _resolveActiveClients(opts) {
|
|
67
|
+
if (!this.deps.connectionStrategy)
|
|
68
|
+
return;
|
|
69
|
+
const result = await this.deps.connectionStrategy.resolve(this._activeClients, opts);
|
|
70
|
+
this._activeClients = result.clients;
|
|
71
|
+
if (result.toolsChanged) {
|
|
72
|
+
await this._revectorizeTools(result.clients, opts);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async _revectorizeTools(clients, opts) {
|
|
76
|
+
const toolsRag = this.deps.ragStores.tools ?? Object.values(this.deps.ragStores)[0];
|
|
77
|
+
if (!toolsRag)
|
|
78
|
+
return;
|
|
79
|
+
for (const client of clients) {
|
|
80
|
+
const result = await client.listTools(opts);
|
|
81
|
+
if (!result.ok)
|
|
82
|
+
continue;
|
|
83
|
+
for (const tool of result.value) {
|
|
84
|
+
const text = `Tool: ${tool.name}\nDescription: ${tool.description}\nSchema: ${JSON.stringify(tool.inputSchema)}`;
|
|
85
|
+
await toolsRag.upsert(text, { id: `tool:${tool.name}` });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
63
88
|
}
|
|
64
89
|
/** Apply a partial config update at runtime (hot-reload). */
|
|
65
90
|
applyConfigUpdate(update) {
|
|
@@ -103,7 +128,7 @@ export class SmartAgent {
|
|
|
103
128
|
results.rag = false;
|
|
104
129
|
}
|
|
105
130
|
try {
|
|
106
|
-
const mcpChecks = await Promise.all(this.
|
|
131
|
+
const mcpChecks = await Promise.all(this._activeClients.map(async (client) => {
|
|
107
132
|
try {
|
|
108
133
|
if (client.healthCheck) {
|
|
109
134
|
const hc = await client.healthCheck(healthOptions);
|
|
@@ -294,10 +319,11 @@ export class SmartAgent {
|
|
|
294
319
|
this.sessionManager.reset();
|
|
295
320
|
}
|
|
296
321
|
// 2. Decide context and tools for the WHOLE request
|
|
322
|
+
await this._resolveActiveClients(opts);
|
|
297
323
|
const actions = subprompts.filter((sp) => sp.type === 'action');
|
|
298
324
|
const ragMode = this.config.ragRetrievalMode ?? 'auto';
|
|
299
325
|
const hasActions = actions.length > 0;
|
|
300
|
-
const hasMcpClients = this.
|
|
326
|
+
const hasMcpClients = this._activeClients.length > 0;
|
|
301
327
|
const hasRagStores = Object.keys(this.deps.ragStores).length > 0;
|
|
302
328
|
const shouldRetrieve = ragMode === 'always' ||
|
|
303
329
|
mode === 'hard' ||
|
|
@@ -608,6 +634,119 @@ export class SmartAgent {
|
|
|
608
634
|
});
|
|
609
635
|
refreshSpan.end();
|
|
610
636
|
}
|
|
637
|
+
// Per-iteration RAG tool re-selection (when enabled)
|
|
638
|
+
if (iteration > 0 &&
|
|
639
|
+
this.config.toolReselectPerIteration &&
|
|
640
|
+
this.deps.ragStores?.tools) {
|
|
641
|
+
const reselectSpan = this.tracer.startSpan('smart_agent.tool_reselect', {
|
|
642
|
+
parent: toolLoopSpan,
|
|
643
|
+
attributes: { 'llm.iteration': iteration + 1 },
|
|
644
|
+
});
|
|
645
|
+
try {
|
|
646
|
+
// Extract last tool calls
|
|
647
|
+
const lastAssistant = [...messages]
|
|
648
|
+
.reverse()
|
|
649
|
+
.find((m) => m.role === 'assistant');
|
|
650
|
+
const toolCallNames = [];
|
|
651
|
+
if (lastAssistant && 'tool_calls' in lastAssistant) {
|
|
652
|
+
const tcs = lastAssistant.tool_calls;
|
|
653
|
+
if (Array.isArray(tcs)) {
|
|
654
|
+
for (const tc of tcs) {
|
|
655
|
+
const name = tc?.function?.name || tc?.name || '';
|
|
656
|
+
if (name)
|
|
657
|
+
toolCallNames.push(name);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
// Skip for read-only tools — they rarely need different tools on retry
|
|
662
|
+
const readOnlyPrefixes = [
|
|
663
|
+
'Search',
|
|
664
|
+
'Read',
|
|
665
|
+
'Get',
|
|
666
|
+
'List',
|
|
667
|
+
'Describe',
|
|
668
|
+
];
|
|
669
|
+
const allReadOnly = toolCallNames.length > 0 &&
|
|
670
|
+
toolCallNames.every((n) => readOnlyPrefixes.some((p) => n.startsWith(p)));
|
|
671
|
+
if (!allReadOnly) {
|
|
672
|
+
// Build context-aware query from error/result context
|
|
673
|
+
const lastToolMsg = [...messages]
|
|
674
|
+
.reverse()
|
|
675
|
+
.find((m) => m.role === 'tool');
|
|
676
|
+
const toolResult = typeof lastToolMsg?.content === 'string'
|
|
677
|
+
? lastToolMsg.content.slice(0, 200)
|
|
678
|
+
: '';
|
|
679
|
+
const isError = toolResult.toLowerCase().includes('error') ||
|
|
680
|
+
toolResult.toLowerCase().includes('already exist') ||
|
|
681
|
+
toolResult.toLowerCase().includes('failed');
|
|
682
|
+
const inputText = _action.text;
|
|
683
|
+
let reSelectQuery;
|
|
684
|
+
if (toolCallNames.length > 0 && isError) {
|
|
685
|
+
const updateHints = toolCallNames
|
|
686
|
+
.filter((n) => n.startsWith('Create'))
|
|
687
|
+
.map((n) => n.replace(/^Create/, 'Update'))
|
|
688
|
+
.join(', ');
|
|
689
|
+
const hints = updateHints ? ` Need ${updateHints}.` : '';
|
|
690
|
+
reSelectQuery = `${toolCallNames.join(', ')} failed: ${toolResult.slice(0, 150)}.${hints} ${inputText.slice(0, 200)}`;
|
|
691
|
+
}
|
|
692
|
+
else if (toolCallNames.length > 0) {
|
|
693
|
+
reSelectQuery = `After ${toolCallNames.join(', ')}: ${toolResult}\n${inputText.slice(0, 200)}`;
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
reSelectQuery = inputText;
|
|
697
|
+
}
|
|
698
|
+
// Query tools RAG
|
|
699
|
+
const embedding = this.deps.embedder
|
|
700
|
+
? new QueryEmbedding(reSelectQuery, this.deps.embedder, opts)
|
|
701
|
+
: new TextOnlyEmbedding(reSelectQuery);
|
|
702
|
+
const ragK = this.config.ragQueryK ?? 20;
|
|
703
|
+
const ragResult = await this.deps.ragStores.tools.query(embedding, ragK, opts);
|
|
704
|
+
if (ragResult.ok && ragResult.value.length > 0) {
|
|
705
|
+
const newToolNames = new Set(ragResult.value
|
|
706
|
+
.map((r) => r.metadata?.id || '')
|
|
707
|
+
.filter((id) => id.startsWith('tool:'))
|
|
708
|
+
.map((id) => id.slice(5)));
|
|
709
|
+
if (newToolNames.size > 0) {
|
|
710
|
+
const refreshed = await this._listAllTools(opts);
|
|
711
|
+
const newMcpTools = refreshed.tools.filter((t) => newToolNames.has(t.name));
|
|
712
|
+
currentTools = [
|
|
713
|
+
...newMcpTools,
|
|
714
|
+
...externalTools,
|
|
715
|
+
];
|
|
716
|
+
// Update system message "Available Tools" section
|
|
717
|
+
const sysIdx = messages.findIndex((m) => m.role === 'system');
|
|
718
|
+
if (sysIdx >= 0 &&
|
|
719
|
+
typeof messages[sysIdx].content === 'string') {
|
|
720
|
+
const toolsSection = currentTools
|
|
721
|
+
.filter((t) => !externalToolNames.has(t.name))
|
|
722
|
+
.map((t) => `- ${t.name}: ${t.description || ''}`)
|
|
723
|
+
.join('\n');
|
|
724
|
+
messages[sysIdx] = {
|
|
725
|
+
...messages[sysIdx],
|
|
726
|
+
content: messages[sysIdx].content.replace(/## Available Tools\n[\s\S]*?(?=\n##|$)/, `## Available Tools\n${toolsSection}`),
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
opts?.sessionLogger?.logStep('tools_reselected', {
|
|
730
|
+
iteration: iteration + 1,
|
|
731
|
+
query: reSelectQuery.slice(0, 100),
|
|
732
|
+
previousTools: toolCallNames,
|
|
733
|
+
newTools: [...newToolNames],
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
opts?.sessionLogger?.logStep('tools_reselect_skipped', {
|
|
740
|
+
iteration: iteration + 1,
|
|
741
|
+
reason: 'read-only tools only',
|
|
742
|
+
tools: toolCallNames,
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
finally {
|
|
747
|
+
reselectSpan.end();
|
|
748
|
+
}
|
|
749
|
+
}
|
|
611
750
|
const filteredForIteration = this.toolAvailabilityRegistry.filterTools(sessionId, currentTools);
|
|
612
751
|
currentTools = filteredForIteration.allowed;
|
|
613
752
|
if (filteredForIteration.blocked.length > 0) {
|
|
@@ -741,86 +880,26 @@ export class SmartAgent {
|
|
|
741
880
|
continue;
|
|
742
881
|
}
|
|
743
882
|
opts?.sessionLogger?.logStep('final_response', { content, usage });
|
|
744
|
-
//
|
|
745
|
-
if (this.
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
...messages,
|
|
750
|
-
{ role: 'assistant', content },
|
|
751
|
-
{ role: 'user', content: presentPrompt },
|
|
752
|
-
];
|
|
753
|
-
const presentSpan = this.tracer.startSpan('smart_agent.present', {
|
|
754
|
-
parent: parentSpan,
|
|
755
|
-
attributes: { 'llm.presentation': true },
|
|
756
|
-
});
|
|
757
|
-
const presentStart = Date.now();
|
|
758
|
-
try {
|
|
759
|
-
const presentStream = this.deps.presentationLlm.streamChat(presentMessages, [], opts);
|
|
760
|
-
let presentContent = '';
|
|
761
|
-
let presentOk = true;
|
|
762
|
-
for await (const chunkResult of presentStream) {
|
|
763
|
-
if (!chunkResult.ok) {
|
|
764
|
-
// Fall back to original content
|
|
765
|
-
presentSpan.setStatus('error', chunkResult.error.message);
|
|
766
|
-
presentOk = false;
|
|
767
|
-
break;
|
|
768
|
-
}
|
|
769
|
-
const pChunk = chunkResult.value;
|
|
770
|
-
if (pChunk.content) {
|
|
771
|
-
presentContent += pChunk.content;
|
|
772
|
-
if (!clientAdapter) {
|
|
773
|
-
yield { ok: true, value: { content: pChunk.content } };
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
if (pChunk.usage) {
|
|
777
|
-
usage.promptTokens += pChunk.usage.promptTokens;
|
|
778
|
-
usage.completionTokens += pChunk.usage.completionTokens;
|
|
779
|
-
usage.totalTokens += pChunk.usage.totalTokens;
|
|
780
|
-
this.sessionManager.addTokens(pChunk.usage.totalTokens);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
if (presentOk) {
|
|
784
|
-
presentSpan.setStatus('ok');
|
|
785
|
-
}
|
|
786
|
-
presentSpan.end();
|
|
787
|
-
timingLog.push({
|
|
788
|
-
phase: 'present',
|
|
789
|
-
duration: Date.now() - presentStart,
|
|
790
|
-
});
|
|
791
|
-
// Use presentation content for adapter wrapping if available
|
|
792
|
-
if (clientAdapter && presentContent) {
|
|
883
|
+
// onBeforeStream hook — consumer transforms content before streaming
|
|
884
|
+
if (this.config.onBeforeStream) {
|
|
885
|
+
const hookCtx = { messages };
|
|
886
|
+
for await (const chunk of this.config.onBeforeStream(content, hookCtx)) {
|
|
887
|
+
if (clientAdapter) {
|
|
793
888
|
yield {
|
|
794
889
|
ok: true,
|
|
795
|
-
value: {
|
|
796
|
-
content: clientAdapter.wrapResponse(presentContent),
|
|
797
|
-
},
|
|
890
|
+
value: { content: clientAdapter.wrapResponse(chunk) },
|
|
798
891
|
};
|
|
799
892
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
// Fall back to original content on error
|
|
803
|
-
presentSpan.setStatus('error', 'unexpected');
|
|
804
|
-
presentSpan.end();
|
|
805
|
-
if (clientAdapter && content) {
|
|
806
|
-
yield {
|
|
807
|
-
ok: true,
|
|
808
|
-
value: { content: clientAdapter.wrapResponse(content) },
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
else if (!clientAdapter && content) {
|
|
812
|
-
yield { ok: true, value: { content } };
|
|
893
|
+
else {
|
|
894
|
+
yield { ok: true, value: { content: chunk } };
|
|
813
895
|
}
|
|
814
896
|
}
|
|
815
897
|
}
|
|
816
|
-
else {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
value: { content: clientAdapter.wrapResponse(content) },
|
|
822
|
-
};
|
|
823
|
-
}
|
|
898
|
+
else if (clientAdapter && content) {
|
|
899
|
+
yield {
|
|
900
|
+
ok: true,
|
|
901
|
+
value: { content: clientAdapter.wrapResponse(content) },
|
|
902
|
+
};
|
|
824
903
|
}
|
|
825
904
|
timingLog.push({ phase: 'total', duration: Date.now() - loopStart });
|
|
826
905
|
toolLoopSpan.setStatus('ok');
|
|
@@ -1078,9 +1157,10 @@ export class SmartAgent {
|
|
|
1078
1157
|
}
|
|
1079
1158
|
}
|
|
1080
1159
|
async _listAllTools(opts) {
|
|
1160
|
+
await this._resolveActiveClients(opts);
|
|
1081
1161
|
const tools = [];
|
|
1082
1162
|
const toolClientMap = new Map();
|
|
1083
|
-
const settled = await Promise.allSettled(this.
|
|
1163
|
+
const settled = await Promise.allSettled(this._activeClients.map(async (client) => ({
|
|
1084
1164
|
client,
|
|
1085
1165
|
result: await client.listTools(opts),
|
|
1086
1166
|
})));
|
|
@@ -1165,6 +1245,7 @@ export class SmartAgent {
|
|
|
1165
1245
|
const chunkQueue = [];
|
|
1166
1246
|
let resolveWait = null;
|
|
1167
1247
|
let done = false;
|
|
1248
|
+
await this._resolveActiveClients(opts);
|
|
1168
1249
|
const ctx = {
|
|
1169
1250
|
// Immutable input
|
|
1170
1251
|
textOrMessages,
|
|
@@ -1178,7 +1259,7 @@ export class SmartAgent {
|
|
|
1178
1259
|
classifier: this.deps.classifier,
|
|
1179
1260
|
assembler: this.deps.assembler,
|
|
1180
1261
|
ragStores: this.deps.ragStores,
|
|
1181
|
-
mcpClients: this.
|
|
1262
|
+
mcpClients: this._activeClients,
|
|
1182
1263
|
reranker: this.reranker,
|
|
1183
1264
|
queryExpander: this.queryExpander,
|
|
1184
1265
|
toolCache: this.toolCache,
|
|
@@ -1192,7 +1273,6 @@ export class SmartAgent {
|
|
|
1192
1273
|
toolAvailabilityRegistry: this.toolAvailabilityRegistry,
|
|
1193
1274
|
pendingToolResults: this.pendingToolResults,
|
|
1194
1275
|
skillManager: this.deps.skillManager,
|
|
1195
|
-
presentationLlm: this.deps.presentationLlm,
|
|
1196
1276
|
embedder: this.deps.embedder,
|
|
1197
1277
|
// Mutable state
|
|
1198
1278
|
inputText: text,
|
|
@@ -1210,8 +1290,6 @@ export class SmartAgent {
|
|
|
1210
1290
|
skillContent: '',
|
|
1211
1291
|
skillArgs: '',
|
|
1212
1292
|
queryEmbedding: undefined,
|
|
1213
|
-
toolLoopContent: '',
|
|
1214
|
-
toolLoopMessages: [],
|
|
1215
1293
|
// Control flags
|
|
1216
1294
|
shouldRetrieve: false,
|
|
1217
1295
|
isAscii: true,
|